efront 4.0.30 → 4.0.32
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/parseURL.js +1 -1
- package/coms/basic/wait.js +2 -1
- package/coms/basic/wait_test.js +3 -0
- package/coms/compile/Javascript.js +13 -0
- package/coms/compile/scanner.js +3 -2
- package/coms/compile/unstruct.js +1 -0
- package/coms/compile/unstruct_test.js +1 -0
- package/coms/reptile/colored_console.js +3 -3
- package/coms/reptile/cross.js +1 -1
- package/package.json +2 -2
- package/public/efront.js +2 -1
package/coms/basic/parseURL.js
CHANGED
package/coms/basic/wait.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
async function wait(call, time = 80, step = +time >>> 4 | 1) {
|
|
2
2
|
var res;
|
|
3
|
-
while (!(res = await call()) && time > 0) await new Promise(ok => setTimeout(ok, step)), time -= step;
|
|
3
|
+
if (isFunction(call)) while (!(res = await call()) && time > 0) await new Promise(ok => setTimeout(ok, step)), time -= step;
|
|
4
|
+
else res = new Promise(ok => setTimeout(ok, call));
|
|
4
5
|
return res;
|
|
5
6
|
}
|
|
@@ -508,6 +508,18 @@ var removeImport = function (c, i, code) {
|
|
|
508
508
|
}
|
|
509
509
|
else o = c;
|
|
510
510
|
var n = o.next;
|
|
511
|
+
var t = null;
|
|
512
|
+
if (n && n.type === EXPRESS) {
|
|
513
|
+
t = Object.create(null);
|
|
514
|
+
var ts = n.text.split(".")
|
|
515
|
+
for (var e of ts) {
|
|
516
|
+
t[e] = true;
|
|
517
|
+
}
|
|
518
|
+
var ni = code.indexOf(n, i);
|
|
519
|
+
removeFromList(used[ts[0]], n);
|
|
520
|
+
splice(code, ni, 1);
|
|
521
|
+
n = n.next;
|
|
522
|
+
}
|
|
511
523
|
if (!n || n.type !== QUOTED) throw new Error("缺少导入路径!");
|
|
512
524
|
var oi = code.indexOf(o, i);
|
|
513
525
|
var ns = skipAssignment(n);
|
|
@@ -515,6 +527,7 @@ var removeImport = function (c, i, code) {
|
|
|
515
527
|
var q = scan(`require()`);
|
|
516
528
|
if (!used.require) used.require = [], envs.require = true;
|
|
517
529
|
used.require.push(q[0]);
|
|
530
|
+
Object.assign(q[0], t);
|
|
518
531
|
var cs = code.splice(oi + 1, nsi - oi - 1, ...q);
|
|
519
532
|
q[1].push.apply(q[1], cs);
|
|
520
533
|
relink(q[1]);
|
package/coms/compile/scanner.js
CHANGED
|
@@ -319,6 +319,7 @@ function block_code_scanner(index, blocks = [], keepdeep = Infinity) {
|
|
|
319
319
|
return tempIndex;
|
|
320
320
|
};
|
|
321
321
|
var saved_index = index;
|
|
322
|
+
var start_index = index;
|
|
322
323
|
var c, deep = 0;
|
|
323
324
|
var length = this.length;
|
|
324
325
|
var reg = /[\/\{\}'"`]/g;
|
|
@@ -348,8 +349,8 @@ function block_code_scanner(index, blocks = [], keepdeep = Infinity) {
|
|
|
348
349
|
// return/a/
|
|
349
350
|
//switch case break,while continue,break abcd;
|
|
350
351
|
var tempIndex = lookback.call(this, index - 1);
|
|
351
|
-
isReg = tempIndex
|
|
352
|
-
if (!isReg && tempIndex >= 5) {
|
|
352
|
+
isReg = tempIndex <= start_index || /[[|,+=*~?:&\^{\(\/><;%\-!]/.test(this[tempIndex]);
|
|
353
|
+
if (!isReg && tempIndex >= start_index + 5) {
|
|
353
354
|
var last_pice = this.slice(Math.max(tempIndex - 50, 0), tempIndex + 1);
|
|
354
355
|
isReg = /return\s*$|([)};:{]|[^\.\s]\s+)(continue|break|case)\s*$/.test(last_pice);
|
|
355
356
|
isReg = isReg || /([)};:{]|[^\.\s]\s+)(?:continue|break)\s+([\w\u0100-\u2027\u2030-\uffff]+?)$/.test(last_pice);
|
package/coms/compile/unstruct.js
CHANGED
|
@@ -9,6 +9,7 @@ function test(codetext, expect, ret = false) {
|
|
|
9
9
|
try { code = unstruct(code, () => ++i >= 0 ? "_" + i : '_', ret && "@"); } catch (e) { console.log(r); throw e }
|
|
10
10
|
assert(code.map(createString).join(";\r\n "), expect, r++);
|
|
11
11
|
}
|
|
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]");
|
|
12
13
|
test('a+b', "a + b");
|
|
13
14
|
test('var a = b', "a = b");
|
|
14
15
|
test('a + !c', "_ = !c, a + _");
|
|
@@ -179,7 +179,7 @@ var format = function (arg, deep = 0) {
|
|
|
179
179
|
if (deep > 1) return "<green>" + strings.encode(arg) + "</green>";
|
|
180
180
|
return arg;
|
|
181
181
|
}
|
|
182
|
-
if (typeof arg === 'function') return `<cyan>[${arg.
|
|
182
|
+
if (typeof arg === 'function') return `<cyan>[${arg.constructor.name}${arg.name ? ": " + arg.name : " (匿名)"}]</cyan>`;
|
|
183
183
|
if (/^(number|boolean)$/.test(typeof arg)) return '<yellow>' + arg + "</yellow>";
|
|
184
184
|
if (arg === undefined) return "<gray>undefined</gray>";
|
|
185
185
|
if (typeof arg === "object") {
|
|
@@ -194,12 +194,12 @@ var format = function (arg, deep = 0) {
|
|
|
194
194
|
}
|
|
195
195
|
if (arg instanceof Buffer || arg instanceof ArrayBuffer || arg instanceof SharedArrayBuffer) {
|
|
196
196
|
var data = new Uint8Array(arg.buffer || arg, arg.byteOffset || 0, arg.byteLength);
|
|
197
|
-
return `<magenta><${arg.
|
|
197
|
+
return `<magenta><${arg.constructor.name} ${Array.prototype.slice.call(data, 0, 20).map(a => a < 16 ? "0" + a.toString(16) : a.toString(16)).join(' ')}${arg.byteLength > 20 ? ` ... 其他 ${arg.byteLength - 20} 字节` : ''}></megenta>`;
|
|
198
198
|
}
|
|
199
199
|
else if (isFinite(arg.length)) {
|
|
200
200
|
var entry = "[";
|
|
201
201
|
var leave = "]";
|
|
202
|
-
entry = `${arg.
|
|
202
|
+
entry = `${arg.constructor.name}(${arg.length})${entry}`;
|
|
203
203
|
if (arg.length === 0) return entry + leave;
|
|
204
204
|
if (deep > 3 && deep + arg.length > 5) return `${entry} ... ${leave}`;
|
|
205
205
|
deepobjs.push(arg);
|
package/coms/reptile/cross.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "efront",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.32",
|
|
4
4
|
"description": "简化前端开发,优化web性能",
|
|
5
5
|
"main": "public/efront.js",
|
|
6
6
|
"directories": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"efront": "public/efront.js"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"prepare": "node tools/build-efront.js --uplevel",
|
|
13
|
+
"prepare": "node tools/build-efront.js --uplevel --node --deno",
|
|
14
14
|
"start": "efront ./efront/ --libs=typescript,esprima,escodegen,esmangle,pngjs,less-node"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|