Skip to content

Commit fe09421

Browse files
committed
gulp@5, closure compiler@2025
1 parent d398371 commit fe09421

5 files changed

Lines changed: 2274 additions & 5536 deletions

File tree

docs/index.html

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
}
3333
function G() {
3434
d = a.indexOf("<", d + 1);
35-
if (-1 === d && (d = a.length, q())) {
35+
if (d === -1 && (d = a.length, q())) {
3636
return !0;
3737
}
3838
}
@@ -42,7 +42,7 @@
4242
p = a.substr(0, d);
4343
a = a.substr(d);
4444
d = 0;
45-
if ((z || x && !ja[D]) && !0 === e.na(U && !ba[D] ? p : M(p))) {
45+
if ((z || x && !ja[D]) && e.na(U && !ba[D] ? p : M(p)) === !0) {
4646
return I(), !0;
4747
}
4848
}
@@ -54,7 +54,7 @@
5454
e.fa && e.fa(p);
5555
}
5656
function ka(p) {
57-
for (var h = 0, y = a.length, k = 3, c, u; k < y && 2 !== h; ++k) {
57+
for (var h = 0, y = a.length, k = 3, c, u; k < y && h !== 2; ++k) {
5858
switch(c = a.charAt(k), h) {
5959
case 0:
6060
if (A[c] & 4) {
@@ -63,10 +63,10 @@
6363
break;
6464
}
6565
case 1:
66-
">" === c && (h = 2, u = k);
66+
c === ">" && (h = 2, u = k);
6767
}
6868
}
69-
if (2 === h) {
69+
if (h === 2) {
7070
h = a.substring(2, u), a = a.substr(k), v || 0 < h.indexOf(":") ? Q(p, h, !1) : (k = h.toUpperCase(), ca[k] || Q(p, f ? h : k, !1));
7171
} else {
7272
return J(a), !0;
@@ -104,41 +104,41 @@
104104
}
105105
function y(B) {
106106
var S = a.substring(V, O);
107-
B = null != B ? a.substring(W, B) : !0;
108-
R[S] = !0 === B ? f || N ? S : B : ma[S.toLowerCase()] ? f || N ? Z(B || S) : !0 : Z(B || "");
107+
B = B != null ? a.substring(W, B) : !0;
108+
R[S] = B === !0 ? f || N ? S : B : ma[S.toLowerCase()] ? f || N ? Z(B || S) : !0 : Z(B || "");
109109
++fa;
110110
}
111111
function k() {
112-
(K = "/>" === a.substr(g, 2)) && ++g;
112+
(K = a.substr(g, 2) === "/>") && ++g;
113113
return K;
114114
}
115-
for (var c = 1, u = a.length, g = 2, R = {}, fa = 0, K = !1, ea = v, l, V, O, W, H, ha, T, N, P; g < u && 9 > c; ++g) {
115+
for (var c = 1, u = a.length, g = 2, R = {}, fa = 0, K = !1, ea = v, l, V, O, W, H, ha, T, N, P; g < u && c < 9; ++g) {
116116
switch(l = a.charAt(g), c) {
117117
case 1:
118-
A[l] & 4 ? (c = 2, h(g)) : ">" === l ? (c = 9, h(g)) : k() && (c = 9, h(g - 1));
118+
A[l] & 4 ? (c = 2, h(g)) : l === ">" ? (c = 9, h(g)) : k() && (c = 9, h(g - 1));
119119
break;
120120
case 2:
121-
">" === l || k() ? c = 9 : A[l] & 4 || (c = 3, V = g);
121+
l === ">" || k() ? c = 9 : A[l] & 4 || (c = 3, V = g);
122122
break;
123123
case 3:
124-
"=" === l ? (c = 5, O = g) : A[l] & 4 ? (c = 4, O = g) : ">" === l ? (c = 9, O = g, y()) : k() && (c = 9, O = g - 1, y());
124+
l === "=" ? (c = 5, O = g) : A[l] & 4 ? (c = 4, O = g) : l === ">" ? (c = 9, O = g, y()) : k() && (c = 9, O = g - 1, y());
125125
break;
126126
case 4:
127-
"=" === l ? c = 5 : ">" === l || k() ? (c = 9, y()) : A[l] & 4 || (c = 3, y(), V = g);
127+
l === "=" ? c = 5 : l === ">" || k() ? (c = 9, y()) : A[l] & 4 || (c = 3, y(), V = g);
128128
break;
129129
case 5:
130-
'"' === l || "'" === l ? (c = 6, ha = l, W = g + 1) : A[l] & 4 || (c = 7, W = g);
130+
l === '"' || l === "'" ? (c = 6, ha = l, W = g + 1) : A[l] & 4 || (c = 7, W = g);
131131
T = !1;
132132
break;
133133
case 6:
134134
T || l !== ha || (c = 2, y(g));
135-
T = "\\" === l && !T;
135+
T = l === "\\" && !T;
136136
break;
137137
case 7:
138-
A[l] & 4 ? (c = 2, y(g)) : ">" === l && (c = 9, y(g));
138+
A[l] & 4 ? (c = 2, y(g)) : l === ">" && (c = 9, y(g));
139139
}
140140
}
141-
if (9 === c) {
141+
if (c === 9) {
142142
if (N) {
143143
K ? v = ea : (x = m[m.length] = H, n());
144144
} else {
@@ -152,7 +152,7 @@
152152
(K = K || !!ca[P]) || (x = m[m.length] = f ? H : P, n());
153153
}
154154
a = a.substr(g);
155-
if (!0 === e.ma(f || N ? H : P, fa ? R : null, K, g)) {
155+
if (e.ma(f || N ? H : P, fa ? R : null, K, g) === !0) {
156156
return I(), !0;
157157
}
158158
} else {
@@ -170,10 +170,10 @@
170170
return;
171171
}
172172
r = a.indexOf("?>");
173-
if (-1 !== r) {
173+
if (r !== -1) {
174174
E = a.substring(2, r);
175175
a = a.substr(r + 2);
176-
if (!0 === e.la(M(E))) {
176+
if (e.la(M(E)) === !0) {
177177
I();
178178
return;
179179
}
@@ -196,7 +196,7 @@
196196
if (G()) {
197197
return;
198198
}
199-
} else if ("<" === a.charAt(d) && A[a.charAt(d + 1)] & 3) {
199+
} else if (a.charAt(d) === "<" && A[a.charAt(d + 1)] & 3) {
200200
if (q() || la(m)) {
201201
return;
202202
}
@@ -205,8 +205,8 @@
205205
return;
206206
}
207207
r = a.indexOf("--\x3e");
208-
if (-1 !== r) {
209-
if (E = a.substring(4, r), a = a.substr(r + 3), !0 === e.ja(M(E))) {
208+
if (r !== -1) {
209+
if (E = a.substring(4, r), a = a.substr(r + 3), e.ja(M(E)) === !0) {
210210
I();
211211
return;
212212
}
@@ -219,8 +219,8 @@
219219
return;
220220
}
221221
r = a.indexOf("]]\x3e");
222-
if (-1 !== r) {
223-
if (E = a.substring(9, r), a = a.substr(r + 3), !0 === e.ia(M(E))) {
222+
if (r !== -1) {
223+
if (E = a.substring(9, r), a = a.substr(r + 3), e.ia(M(E)) === !0) {
224224
I();
225225
return;
226226
}
@@ -229,8 +229,8 @@
229229
return;
230230
}
231231
} else if (a.indexOf("<!DOCTYPE ") === d || a.indexOf("<!doctype ") === d) {
232-
if (a = a.substr(d), d = 0, r = a.indexOf(">"), -1 !== r) {
233-
if (E = a.substring(0, r + 1), a = a.substr(r + 1), z && (f = 0 < E.indexOf("-//W3C//DTD XHTML ")), z = !1, !0 === e.ka(E)) {
232+
if (a = a.substr(d), d = 0, r = a.indexOf(">"), r !== -1) {
233+
if (E = a.substring(0, r + 1), a = a.substr(r + 1), z && (f = 0 < E.indexOf("-//W3C//DTD XHTML ")), z = !1, e.ka(E) === !0) {
234234
I();
235235
return;
236236
}
@@ -274,7 +274,7 @@
274274
b.$ += "<" + a;
275275
for (m in e) {
276276
w = e[m];
277-
b.$ += " " + m + (!0 !== w ? '="' + Y(w).split('"').join('\\"').split('\\\\"').join('\\"') + '"' : "");
277+
b.$ += " " + m + (w !== !0 ? '="' + Y(w).split('"').join('\\"').split('\\\\"').join('\\"') + '"' : "");
278278
}
279279
b.$ += (f ? "/" : "") + ">";
280280
f || b.ba.push(a.toUpperCase());
@@ -292,7 +292,7 @@
292292
for (a = a.split("\n").join(" ").split("\t").join(" "); 0 <= a.indexOf(" ");) {
293293
a = a.split(" ").join(" ");
294294
}
295-
a.split(" ").join("") && (a = " " === a.charAt(0) ? a.substr(1) : a, a = a.length && " " === a.charAt(a.length - 1) ? a.substr(0, a.length - 1) : a, b.$ += Y(a));
295+
a.split(" ").join("") && (a = a.charAt(0) === " " ? a.substr(1) : a, a = a.length && a.charAt(a.length - 1) === " " ? a.substr(0, a.length - 1) : a, b.$ += Y(a));
296296
}
297297
if (b.aa && b.aa + 16 < +new C()) {
298298
return !0;
@@ -306,7 +306,7 @@
306306
return !0;
307307
}
308308
}, la:function(a) {
309-
0 === a.indexOf("xml ") && (b.ca = "\x3c?" + a + "?>\n");
309+
a.indexOf("xml ") === 0 && (b.ca = "\x3c?" + a + "?>\n");
310310
if (b.aa && b.aa + 16 < +new C()) {
311311
return !0;
312312
}
@@ -325,7 +325,7 @@
325325
};
326326
m.onsubmit = function(n) {
327327
n && n.preventDefault();
328-
"undefined" != typeof event && (event.returnValue = !1);
328+
typeof event != "undefined" && (event.returnValue = !1);
329329
n = e.value.split("\r\n").join("\n").split("\n\r").join("\n").split("\r").join("\n");
330330
a ? f.firstChild.data = "" : f.value = "";
331331
z.value = v = n.length;
@@ -335,7 +335,7 @@
335335
return !1;
336336
};
337337
function bz(n, G, q) {
338-
w.style.width = 100 * n + "%";
338+
w.style.width = n * 100 + "%";
339339
setTimeout(function() {
340340
b.aa = +new C();
341341
a ? G(q[0], q[1], q[2], q[3], q[4], q[5], q[6]) : G.apply(null, q);

gulpfile.js

Lines changed: 1 addition & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1 @@
1-
const pkg = require('./package.json'),
2-
gulp = require('gulp'),
3-
ClosureCompiler = require('google-closure-compiler').gulp(),
4-
postProcessor = require( 'es2-postprocessor' );
5-
fs = require('fs'),
6-
moduleName = pkg.name,
7-
tempJsName = 'temp.js',
8-
tempDir = require('os').tmpdir() + '/' + moduleName,
9-
globalVariables = 'document,Date',
10-
copyright = moduleName + '@' + pkg.version + '\n' +
11-
'(c) 2024-' + (new Date).getFullYear() + ' ' + pkg.author + '(' + pkg.homepage + '), ' + pkg.license + '.';
12-
13-
let minify = false;
14-
let fileName = 'htmlparser.js';
15-
let outputDir = './dist';
16-
let formatting = 'PRETTY_PRINT';
17-
18-
gulp.task( 'dist', gulp.series(
19-
function(){
20-
return gulp
21-
.src(
22-
[ './src/closure-primitives/base.js', './src/js/**/*.js', './node_modules/@externs/nodejs/**/*.js' ]
23-
).pipe(
24-
ClosureCompiler(
25-
{
26-
// env : 'CUSTOM',
27-
dependency_mode : 'PRUNE',
28-
entry_point : 'goog:example.node',
29-
compilation_level : 'ADVANCED',
30-
define : [
31-
'htmlparser.DEFINE.USE_XHTML=' + true,
32-
'htmlparser.DEFINE.USE_XML_IN_HTML=' + true,
33-
'htmlparser.DEFINE.USE_DOCUMENT_TYPE_NODE=' + true,
34-
'htmlparser.DEFINE.USE_CDATA_SECTION=' + true,
35-
'htmlparser.DEFINE.USE_PROCESSING_INSTRUCTION=' + true,
36-
'htmlparser.DEFINE.USE_TRADITIONAL_TAGS=' + true,
37-
'htmlparser.DEFINE.USE_PAUSE=' + false
38-
],
39-
warning_level : 'VERBOSE',
40-
language_in : 'ECMASCRIPT6',
41-
language_out : 'ECMASCRIPT6',
42-
formatting : 'PRETTY_PRINT',
43-
js_output_file : 'index.js',
44-
output_wrapper : '\/* ' + copyright + ' *\/\n' + '%output%'
45-
}
46-
)
47-
).pipe(
48-
gulp.dest( outputDir )
49-
);
50-
},
51-
function(){
52-
return gulp
53-
.src(
54-
[ './src/closure-primitives/base.js', './src/js/**/*.js' ]
55-
).pipe(
56-
ClosureCompiler(
57-
{
58-
dependency_mode : 'PRUNE',
59-
entry_point : 'goog:example.browser',
60-
compilation_level : 'ADVANCED',
61-
define : [
62-
'htmlparser.DEFINE.USE_XHTML=' + true,
63-
'htmlparser.DEFINE.USE_XML_IN_HTML=' + true,
64-
'htmlparser.DEFINE.USE_DOCUMENT_TYPE_NODE=' + true,
65-
'htmlparser.DEFINE.USE_CDATA_SECTION=' + true,
66-
'htmlparser.DEFINE.USE_PROCESSING_INSTRUCTION=' + true,
67-
'htmlparser.DEFINE.USE_PAUSE=' + true
68-
],
69-
warning_level : 'VERBOSE',
70-
language_in : 'ECMASCRIPT3',
71-
language_out : 'ECMASCRIPT3',
72-
output_wrapper :
73-
'(function(window, ' + globalVariables + '){\n' +
74-
'%output%\n' +
75-
'})(this, ' + globalVariables + ');'
76-
}
77-
)
78-
).pipe(
79-
postProcessor.gulp(
80-
{
81-
hoist : true
82-
}
83-
)
84-
).pipe(
85-
ClosureCompiler(
86-
{
87-
warning_level : 'QUIET',
88-
language_in : 'ECMASCRIPT3',
89-
language_out : 'ECMASCRIPT3'
90-
}
91-
)
92-
).pipe(
93-
postProcessor.gulp(
94-
{
95-
minIEVersion : 5,
96-
minOperaVersion : 7,
97-
minGeckoVersion : 0.6
98-
}
99-
)
100-
).pipe(
101-
ClosureCompiler(
102-
{
103-
compilation_level : 'WHITESPACE_ONLY',
104-
warning_level : 'QUIET',
105-
formatting : formatting,
106-
js_output_file : fileName,
107-
output_wrapper : '\n\/* ' + copyright + ' *\/\n' + '%output%'
108-
}
109-
)
110-
).pipe(
111-
gulp.dest( tempDir )
112-
);
113-
},
114-
function( cb ){
115-
const fs = require( 'fs' );
116-
117-
fs.readFile(
118-
'src/html/index.html',
119-
( error, buffer ) => {
120-
if( error ) throw error;
121-
122-
const html = buffer.toString();
123-
124-
fs.readFile(
125-
tempDir + '/' + fileName,
126-
( error, buffer ) => {
127-
if( error ) throw error;
128-
129-
const js = buffer.toString().split( '<?' ).join( '\\x3c?' );//.split( '>' ).join( '\\x3e' );
130-
131-
fs.writeFile( 'docs/index.html', html.split( '<script></script>' ).join( '<script>' + js + '</script>' ), cb );
132-
}
133-
);
134-
}
135-
)
136-
}
137-
));
1+
module.exports.dist = require( './gulptasks/dist.js' );

0 commit comments

Comments
 (0)