efront 4.31.1 → 4.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coms/basic/#loader.js +26 -20
- package/coms/basic_/&extendIfNeeded.js +1 -0
- package/coms/compile/Javascript.js +17 -6
- package/coms/compile/Javascript_test.js +2 -2
- package/coms/compile/Node.js +13 -4
- package/coms/compile/cloneNode.js +2 -1
- package/coms/compile/common.js +5 -1
- package/coms/compile/common_test.js +6 -0
- package/coms/compile/nametill.js +2 -2
- package/coms/compile/unstruct.js +23 -7
- package/coms/compile/unstruct_test.js +3 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/public//346/226/207/344/273/266/347/263/273/347/273/237//344/270/273/351/241/265.jsp +2 -2
package/coms/basic/#loader.js
CHANGED
|
@@ -254,7 +254,7 @@ var hasOwnProperty = {}.hasOwnProperty;
|
|
|
254
254
|
"use ./#decrypt.js";
|
|
255
255
|
var loadModule = function (url, then, prebuilds = {}) {
|
|
256
256
|
var name = url.replace(/[\*~][\s\S]*$/, '');
|
|
257
|
-
if (/^(?:module|exports|define|
|
|
257
|
+
if (/^(?:module|exports|define|\\import|require|window|global|undefined)$/.test(name)) return then();
|
|
258
258
|
if ((hasOwnProperty.call(prebuilds, url)) || hasOwnProperty.call(modules, url) || (!hasOwnProperty.call(forceRequest, name) && !/^on/.test(name) && window[name] !== null && window[name] !== void 0)
|
|
259
259
|
) return then();
|
|
260
260
|
preLoad(url);
|
|
@@ -432,16 +432,19 @@ function resolve(r1, base, prefix = '') {
|
|
|
432
432
|
return r2;
|
|
433
433
|
|
|
434
434
|
}
|
|
435
|
-
|
|
436
|
-
|
|
435
|
+
|
|
436
|
+
function Meta(url, fix) {
|
|
437
|
+
this.path = url;
|
|
438
|
+
this.url = url + fix;
|
|
437
439
|
}
|
|
438
440
|
Meta.prototype.resolve = function (url) {
|
|
439
|
-
return resolve(url, this.
|
|
441
|
+
return resolve(url, this.path);
|
|
440
442
|
}
|
|
441
|
-
|
|
442
|
-
var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
|
|
443
|
+
function Exports() { }
|
|
444
|
+
var createModule = function (exec, originNames, compiledNames, prebuilds = {}, argfix) {
|
|
445
|
+
if (argfix in exec) return exec[argfix];
|
|
443
446
|
var module = {};
|
|
444
|
-
var exports = module.exports =
|
|
447
|
+
var exports = module.exports = exec[argfix] || new Exports;
|
|
445
448
|
var isModuleInit = false;
|
|
446
449
|
var required = exec.required;
|
|
447
450
|
if (required) required = required.map(a => loadedModules[keyprefix + a]);
|
|
@@ -452,23 +455,26 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
|
|
|
452
455
|
}
|
|
453
456
|
if (argName === "module") {
|
|
454
457
|
isModuleInit = true;
|
|
458
|
+
if (argfix != null) exec[argfix] = exports;
|
|
455
459
|
return module;
|
|
456
460
|
}
|
|
457
461
|
if (argName === "exports") {
|
|
458
462
|
isModuleInit = true;
|
|
463
|
+
if (argfix != null) exec[argfix] = exports;
|
|
459
464
|
return exports;
|
|
460
465
|
}
|
|
461
|
-
if (argName === '
|
|
462
|
-
return new Meta(exec.file);
|
|
466
|
+
if (argName === '\\import') {
|
|
467
|
+
return new Meta(exec.file, argfix);
|
|
463
468
|
}
|
|
464
469
|
if (/^(?:window|global(This)?|undefined)$/.test(argName)) return window[argName];
|
|
465
470
|
if (argName === "require") {
|
|
466
471
|
var r1 = window.require;
|
|
467
|
-
let r = function (refer) {
|
|
472
|
+
let r = function (refer, argfix) {
|
|
468
473
|
if (refer.length) return r1(refer);
|
|
469
474
|
var mod = required[refer];
|
|
470
|
-
|
|
471
|
-
|
|
475
|
+
argfix = argfix || '';
|
|
476
|
+
if (argfix in mod) return mod[argfix];
|
|
477
|
+
var c = mod[argfix] = createModule(mod, mod.args || [], mod.argNames, prebuilds, argfix);
|
|
472
478
|
return c;
|
|
473
479
|
};
|
|
474
480
|
for (let k in r1) r[k] = r1[k];
|
|
@@ -514,7 +520,7 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
|
|
|
514
520
|
if (!argsPromises.length) {
|
|
515
521
|
return exec.apply(_this, argsList);
|
|
516
522
|
}
|
|
517
|
-
return Promise.all(argsList).then(function (args) {
|
|
523
|
+
else return Promise.all(argsList).then(function (args) {
|
|
518
524
|
return exec.apply(_this, args);
|
|
519
525
|
});
|
|
520
526
|
};
|
|
@@ -630,13 +636,13 @@ var init = function (url, then, prebuilds, keeppage) {
|
|
|
630
636
|
|
|
631
637
|
if (!args || !args.length) {
|
|
632
638
|
var created = module.call(window);
|
|
633
|
-
then(
|
|
639
|
+
then(modules[url] = module[''] = created);
|
|
634
640
|
return;
|
|
635
641
|
}
|
|
636
642
|
var filteredArgs = prebuilds ? args.filter(a => !hasOwnProperty.call(prebuilds, a)) : args;
|
|
637
643
|
|
|
638
|
-
|
|
639
|
-
if (
|
|
644
|
+
keeppage = keeppage || filteredArgs.length === args.length;
|
|
645
|
+
if (keeppage) {
|
|
640
646
|
if (penddings[key]) {
|
|
641
647
|
penddings[key].then(then);
|
|
642
648
|
return;
|
|
@@ -652,18 +658,18 @@ var init = function (url, then, prebuilds, keeppage) {
|
|
|
652
658
|
then(created);
|
|
653
659
|
return;
|
|
654
660
|
}
|
|
655
|
-
var created = createModule(module, args, module.argNames, prebuilds);
|
|
661
|
+
var created = createModule(module, args, module.argNames, prebuilds, keeppage ? '' : null);
|
|
656
662
|
if (isThenable(created)) {
|
|
657
|
-
if (
|
|
663
|
+
if (keeppage) {
|
|
658
664
|
penddings[key] = created;
|
|
659
665
|
created.then(function (res) {
|
|
660
666
|
delete penddings[key];
|
|
661
|
-
then(modules[url] = res);
|
|
667
|
+
then(modules[url] = module[""] = res);
|
|
662
668
|
});
|
|
663
669
|
return;
|
|
664
670
|
}
|
|
665
671
|
} else {
|
|
666
|
-
if (
|
|
672
|
+
if (keeppage) module[''] = modules[url] = created;
|
|
667
673
|
}
|
|
668
674
|
then(created);
|
|
669
675
|
}, prebuilds);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
basic$extendIfNeeded;
|
|
@@ -857,8 +857,9 @@ var wrapRequire = function (n, i, code) {
|
|
|
857
857
|
used.require.push(q[0]);
|
|
858
858
|
var cs = code.splice(ni, nsi - ni, ...q);
|
|
859
859
|
q[1].push.apply(q[1], cs);
|
|
860
|
-
|
|
861
|
-
|
|
860
|
+
cs = q[1];
|
|
861
|
+
relink(cs);
|
|
862
|
+
setqueue(cs);
|
|
862
863
|
return q;
|
|
863
864
|
};
|
|
864
865
|
|
|
@@ -888,10 +889,20 @@ Javascript.prototype.fix = function (code) {
|
|
|
888
889
|
}, this);
|
|
889
890
|
if (code.exportStars) {
|
|
890
891
|
var exportStars = code.exportStars;
|
|
891
|
-
if (
|
|
892
|
+
if (code.last.type !== STAMP || code.last.text !== ";") code.push({ text: ",", type: STAMP });
|
|
893
|
+
if (!code.exportDefault) code.push(...scan(`\r\nexports.default=undefined;`));
|
|
894
|
+
var extused = [];
|
|
892
895
|
exportStars.forEach(u => {
|
|
893
|
-
|
|
896
|
+
var a = scan(`\r\n&extendIfNeeded(exports,${u.text});`)
|
|
897
|
+
extused.push(a[1]);
|
|
898
|
+
code.push(a[0], a[1], a[2], a[3]);
|
|
899
|
+
code.used[u.text].push(a[2][2]);
|
|
900
|
+
code.used.exports.push(a[2][0]);
|
|
894
901
|
});
|
|
902
|
+
if (extused.length) {
|
|
903
|
+
code.used["&extendIfNeeded"] = extused;
|
|
904
|
+
code.envs["&extendIfNeeded"] = true;
|
|
905
|
+
}
|
|
895
906
|
delete code.exportStars;
|
|
896
907
|
delete code.exportDefault;
|
|
897
908
|
}
|
|
@@ -915,7 +926,7 @@ Javascript.prototype.fix = function (code) {
|
|
|
915
926
|
remove(m.next, s);
|
|
916
927
|
}
|
|
917
928
|
if (/^import\.meta($|\.)/.test(m.text)) {
|
|
918
|
-
m.text = m.text.replace(
|
|
929
|
+
m.text = m.text.replace(/^import\.meta/, '\\import');
|
|
919
930
|
return true;
|
|
920
931
|
}
|
|
921
932
|
m.text = m.text.replace(/^import/g, 'require');
|
|
@@ -923,7 +934,7 @@ Javascript.prototype.fix = function (code) {
|
|
|
923
934
|
});
|
|
924
935
|
delete code.used.import;
|
|
925
936
|
delete code.envs.import;
|
|
926
|
-
if (imports.length) code.used["
|
|
937
|
+
if (imports.length) code.used["\\import"] = imports, code.envs["\\import"] = true;
|
|
927
938
|
}
|
|
928
939
|
if (code.exportDecs) {
|
|
929
940
|
var exportDecs = code.exportDecs;
|
|
@@ -8,7 +8,7 @@ var testFix = function (a, e) {
|
|
|
8
8
|
js.debug = true;
|
|
9
9
|
assert(scanner2("/a/g", js)[0].type, common.QUOTED);
|
|
10
10
|
testFix(`export default function a(){} a.a=1`, `exports.default = function a() {} exports.default.a = 1`);
|
|
11
|
-
testFix(`export * from "a";`, 'var a = require("a");\r\nexports.default = undefined
|
|
11
|
+
testFix(`export * from "a";`, 'var a = require("a");\r\nexports.default = undefined;\r\n&extendIfNeeded(exports, a);');
|
|
12
12
|
testFix(`export {A} from "a";`, 'var a = require("a")\r\nexports.A = a.A;');
|
|
13
13
|
testFix(`import a from "a";console.log(a)`, 'var a = require("a"); console.log(a.default)');
|
|
14
14
|
testFix(`import {a} from "a";console.log(a)`, 'var a1 = require("a"); console.log(a1.a)');
|
|
@@ -20,7 +20,7 @@ testFix(`import("a")`, 'require("a")');
|
|
|
20
20
|
testFix(`import "windows.inc"`, 'require("windows.inc")');
|
|
21
21
|
testFix(`import "windows.inc";import "abc.inc";`, 'require("windows.inc"); require("abc.inc");');
|
|
22
22
|
testFix(`import "windows.inc";\r\nimport "abc.inc";`, 'require("windows.inc");\r\nrequire("abc.inc");');
|
|
23
|
-
testFix(`console.log(import.meta)`, `console.log(
|
|
23
|
+
testFix(`console.log(import.meta)`, `console.log(\\import)`);
|
|
24
24
|
testFix(`export async function a(){}`, 'exports.a = async function a() {}');
|
|
25
25
|
testFix(`export async function *a(){}`, 'exports.a = async function *a() {}');
|
|
26
26
|
testFix(`export function *a(){}`, 'exports.a = function *a() {}');
|
package/coms/compile/Node.js
CHANGED
|
@@ -15,7 +15,7 @@ function Node(o) {
|
|
|
15
15
|
});
|
|
16
16
|
t[types[o.type]] = o.text;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
Object.assign(t, o);
|
|
19
19
|
return t;
|
|
20
20
|
}
|
|
21
21
|
var node_props = [
|
|
@@ -41,16 +41,25 @@ defineProperty(Node, 'debug', {
|
|
|
41
41
|
node_props.forEach(debug ? def : del, Node.prototype);
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
+
|
|
44
45
|
var def = function (k) {
|
|
45
46
|
var k1 = Symbol(k);
|
|
47
|
+
var set = function (v) {
|
|
48
|
+
defineProperty(this, k1, { configurable: true, writable: true, enumerable: false, value: v });
|
|
49
|
+
};
|
|
46
50
|
defineProperty(this, k, {
|
|
47
51
|
configurable: true, enumerable: false,
|
|
48
52
|
get() {
|
|
49
53
|
return this[k1];
|
|
50
54
|
},
|
|
51
|
-
set(v) {
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
set: k === 'type' ? function (v) {
|
|
56
|
+
delete this[types[this[k1]]];
|
|
57
|
+
set.call(this, v);
|
|
58
|
+
this[types[v]] = this.text;
|
|
59
|
+
} : k === 'text' ? function (v) {
|
|
60
|
+
set.call(this, v);
|
|
61
|
+
this[types[this.type]] = v;
|
|
62
|
+
} : set,
|
|
54
63
|
});
|
|
55
64
|
};
|
|
56
65
|
var del = function (k) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
var { VALUE, QUOTED, EXPRESS, STRAP, relink } = require("./common");
|
|
2
2
|
var Node = require("./Node");
|
|
3
|
+
var cloneChild = o => cloneNode(o);
|
|
3
4
|
var cloneNode = function (o, keep) {
|
|
4
5
|
var c = o;
|
|
5
6
|
if (c instanceof Array && !c.text) {
|
|
6
7
|
if (keep) return c;
|
|
7
|
-
c = c.map(
|
|
8
|
+
c = c.map(cloneChild);
|
|
8
9
|
c.entry = o.entry;
|
|
9
10
|
c.leave = o.leave;
|
|
10
11
|
c.type = o.type;
|
package/coms/compile/common.js
CHANGED
|
@@ -710,6 +710,11 @@ var createScoped = function (parsed, wash) {
|
|
|
710
710
|
o = getnext(o);
|
|
711
711
|
o.isExpress = p?.isExpress;
|
|
712
712
|
}
|
|
713
|
+
if (n.isprop) {
|
|
714
|
+
var nn = n.next;
|
|
715
|
+
if (nn.type === STAMP && /^[\:\=]$/.test(nn.text)) break;
|
|
716
|
+
}
|
|
717
|
+
|
|
713
718
|
case "catch":
|
|
714
719
|
if (s === 'catch') isCatch = true;
|
|
715
720
|
case "class":
|
|
@@ -788,7 +793,6 @@ var createScoped = function (parsed, wash) {
|
|
|
788
793
|
vars = Object.create(null);
|
|
789
794
|
scoped = [];
|
|
790
795
|
var isExpress = o.isExpress;
|
|
791
|
-
|
|
792
796
|
if (isFunction || isArraw) {
|
|
793
797
|
scoped.used = used;
|
|
794
798
|
scoped.vars = vars;
|
|
@@ -44,3 +44,9 @@ assert(common.createString(common.pickArgument(scanner2(`a={a:1,c:d}`)[2][4])),
|
|
|
44
44
|
assert(common.createString(common.pickArgument(scanner2(`a=class{a=1\r\nc=d}`)[3][4])), 'c = d')
|
|
45
45
|
assert(common.createString(common.pickArgument(scanner2(`(a=1,c=d)`)[0][4])), 'c = d')
|
|
46
46
|
assert(scanner2(`for (let len of codeLengths) if (len) count[len]++;`).envs, { len: undefined })
|
|
47
|
+
function testCreateScope(code) {
|
|
48
|
+
code = scanner2(code);
|
|
49
|
+
common.createScoped(code);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
testCreateScope(`class a{ static barch = new arch('b')}`)
|
package/coms/compile/nametill.js
CHANGED
package/coms/compile/unstruct.js
CHANGED
|
@@ -226,7 +226,7 @@ var _switch = function (body, cx, unblock, result, getname) {
|
|
|
226
226
|
q = tmp.shift();
|
|
227
227
|
block = tmp.shift();
|
|
228
228
|
if (default_r === q) cy = default_r.index;
|
|
229
|
-
q.push({ type: VALUE, text: String(result.length - cy) }, { type: STAMP, text: "," }, { type: VALUE, text: '0' });
|
|
229
|
+
q.push({ type: VALUE, isdigit: true, text: String(result.length - cy) }, { type: STAMP, text: "," }, { type: VALUE, isdigit: true, text: '0' });
|
|
230
230
|
relink(q);
|
|
231
231
|
unblock(block);
|
|
232
232
|
ifpatch(result);
|
|
@@ -305,13 +305,29 @@ var getCondition = function (o, unblock, not_) {
|
|
|
305
305
|
if (not_) not = !not;
|
|
306
306
|
if (f && f === o.last) {
|
|
307
307
|
if (f.type & (EXPRESS | VALUE)) {
|
|
308
|
-
n =
|
|
308
|
+
n = f;
|
|
309
309
|
}
|
|
310
310
|
if (not && n) {
|
|
311
311
|
if (f.type === VALUE) {
|
|
312
|
-
|
|
312
|
+
if (f.isdigit) {
|
|
313
|
+
n = cloneNode(String(eval("!" + f.text)));
|
|
314
|
+
}
|
|
315
|
+
else switch (f.text) {
|
|
316
|
+
case "true":
|
|
317
|
+
case "Infinity":
|
|
318
|
+
case "-Infinity":
|
|
319
|
+
n = cloneNode("false");
|
|
320
|
+
break;
|
|
321
|
+
case "NaN":
|
|
322
|
+
case "null":
|
|
323
|
+
case "undefined":
|
|
324
|
+
n = cloneNode("true");
|
|
325
|
+
break;
|
|
326
|
+
default:
|
|
327
|
+
n = rescan.keep`!${f}`;
|
|
328
|
+
}
|
|
313
329
|
}
|
|
314
|
-
else n = rescan`!${n}`;
|
|
330
|
+
else n = rescan.keep`!${n}`;
|
|
315
331
|
}
|
|
316
332
|
}
|
|
317
333
|
if (!n) {
|
|
@@ -323,9 +339,9 @@ var getCondition = function (o, unblock, not_) {
|
|
|
323
339
|
n = ret_;
|
|
324
340
|
}
|
|
325
341
|
else n = n.name;
|
|
326
|
-
if (not) n = rescan`!${n}`;
|
|
342
|
+
if (not) n = rescan.keep`!${n}`;
|
|
327
343
|
}
|
|
328
|
-
return
|
|
344
|
+
return n;
|
|
329
345
|
}
|
|
330
346
|
var _while = function (body, cx, unblock, result) {
|
|
331
347
|
var o = body[cx];
|
|
@@ -1175,7 +1191,7 @@ var poplabel = function (result) {
|
|
|
1175
1191
|
if (r.indexOf(b) >= 0) { break }
|
|
1176
1192
|
}
|
|
1177
1193
|
if (cx < 0) throw console.log(result.map(r => createString(r)), e.text, createString([b.prev, b])), i18n`break语句异常`;
|
|
1178
|
-
end.push({ type: VALUE, text: b.continue ? b.continue.contat - cx : result.length - cx }, { type: STAMP, text: "," }, { type: VALUE, text: "0" });
|
|
1194
|
+
end.push({ type: VALUE, isdigit: true, text: String(b.continue ? b.continue.contat - cx : result.length - cx) }, { type: STAMP, text: "," }, { type: VALUE, isdigit: true, text: "0" });
|
|
1179
1195
|
relink(end);
|
|
1180
1196
|
}
|
|
1181
1197
|
}
|
|
@@ -12,6 +12,9 @@ function test(codetext, expect, ret = false) {
|
|
|
12
12
|
test('var o = loaded[f.name] = f.isFile() ? new File(p, rebuild, limit) : new Directory(p, rebuild, limit)', "_ = f.name; _0 = f.isFile(); if (!_0) return [1, 0]; _0 = new File(p, rebuild, limit); loaded[_] = _0; o = _0; return [2, 0];\r\n _0 = new Directory(p, rebuild, limit); loaded[_] = _0; o = _0; return [1, 0]");
|
|
13
13
|
test('a+b', "a + b");
|
|
14
14
|
test('var a = b', "a = b");
|
|
15
|
+
test('if(this){}',`if (!this) return [1, 0]; return [1, 0]`);
|
|
16
|
+
test('if(!this){}',`if (this) return [1, 0]; return [1, 0]`);
|
|
17
|
+
test('if(arguments){}',`if (!arguments) return [1, 0]; return [1, 0]`);
|
|
15
18
|
test('a | c & b', "_ = c & b, a | _");
|
|
16
19
|
test('a + !c', "_ = !c, a + _");
|
|
17
20
|
test('a + b * c', "_ = b * c, a + _");
|