-
Notifications
You must be signed in to change notification settings - Fork 0
/
jscomp.go
244 lines (233 loc) · 13.2 KB
/
jscomp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
package main
import (
"bytes"
"compress/flate"
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"github.com/jessevdk/go-flags"
)
var base64Code = `KGZ1bmN0aW9uKHIpe2lmKHR5cGVvZiBleHBvcnRzPT09Im9iamVjdCImJnR5cGVvZiBtb2R1bGUh
PT0idW5kZWZpbmVkIil7bW9kdWxlLmV4cG9ydHM9cigpfWVsc2UgaWYodHlwZW9mIGRlZmluZT09
PSJmdW5jdGlvbiImJmRlZmluZS5hbWQpe2RlZmluZShbXSxyKX1lbHNle3ZhciBlO2lmKHR5cGVv
ZiB3aW5kb3chPT0idW5kZWZpbmVkIil7ZT13aW5kb3d9ZWxzZSBpZih0eXBlb2YgZ2xvYmFsIT09
InVuZGVmaW5lZCIpe2U9Z2xvYmFsfWVsc2UgaWYodHlwZW9mIHNlbGYhPT0idW5kZWZpbmVkIil7
ZT1zZWxmfWVsc2V7ZT10aGlzfWUuYmFz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LlJhd0luZmxhdGUiLHcpO3IoIlpsaWIuUmF3SW5m
bGF0ZS5wcm90b3R5cGUuZGVjb21wcmVzcyIsdy5wcm90b3R5cGUudCk7dmFyIFg9e0FEQVBUSVZF
OnksQkxPQ0s6QX0sWSxaLCQsZmE7aWYoT2JqZWN0LmtleXMpWT1PYmplY3Qua2V5cyhYKTtlbHNl
IGZvcihaIGluIFk9W10sJD0wLFgpWVskKytdPVo7JD0wO2ZvcihmYT1ZLmxlbmd0aDskPGZhOysr
JClaPVlbJF0scigiWmxpYi5SYXdJbmZsYXRlLkJ1ZmZlclR5cGUuIitaLFhbWl0pO30pLmNhbGwo
dGhpcyk7Cg==`
var opts struct {
InputFile string `short:"i" long:"input" description:"JS input file"`
OutputFile string `short:"o" long:"output" default:"-" description:"JS output file"`
}
func genCode(s string) string {
bin, err := base64.StdEncoding.DecodeString(s)
if err != nil {
panic(err)
}
return string(bin)
}
func main() {
flags.Parse(&opts)
if opts.InputFile == "" {
fmt.Fprintf(os.Stderr, "Input file not specified\n")
return
}
f, err := os.Open(opts.InputFile)
if err != nil {
fmt.Fprintf(os.Stderr, "Error opening input file: %#v\n", err)
return
}
input, err := ioutil.ReadAll(f)
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading input file: %#v\n", err)
return
}
buf := &bytes.Buffer{}
def, err := flate.NewWriter(buf, flate.BestCompression)
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating deflate object: %#v\n", err)
return
}
n, err := def.Write(input)
if err != nil {
fmt.Fprintf(os.Stderr, "Error compressing data: %#v\n", err)
return
}
if len(input) != n {
fmt.Fprintf(os.Stderr, "buffer size missmatch")
return
}
err = def.Flush()
if err != nil {
fmt.Fprintf(os.Stderr, "Error flushing deflate data: %#v\n", err)
return
}
err = def.Close()
if err != nil {
fmt.Fprintf(os.Stderr, "Error closing deflate: %#v\n", err)
return
}
b64str := base64.StdEncoding.EncodeToString(buf.Bytes())
var outFile *os.File
if opts.OutputFile == "-" {
outFile = os.Stdout
} else {
outFile, err = os.OpenFile(opts.OutputFile, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating output file: %#v\n", err)
return
}
}
fmt.Fprintf(outFile,
`/* Compressed with jscomp [https://github.com/jaracil/jscomp.git] */
%s
%s
eval(new TextDecoder("utf-8").decode(new Zlib.RawInflate(base64js.toByteArray("%s")).decompress()));`,
genCode(base64Code),
genCode(inflateCode),
b64str,
)
outFile.Close()
}