efront 4.9.4 → 4.10.1
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/Item.js +6 -1
- package/coms/basic/Tree.js +15 -1
- package/coms/basic/shallowClone.js +6 -2
- package/coms/basic_/JSON.js +1 -5
- package/coms/basic_/JSON_test.js +7 -1
- package/coms/compile/Html_test.js +12 -1
- package/coms/compile/Javascript.js +94 -58
- package/coms/compile/Javascript_test.js +70 -2
- package/coms/compile/Program.js +187 -53
- package/coms/compile/audit.js +1 -1
- package/coms/compile/autoenum.js +1 -1
- package/coms/compile/cloneNode.js +2 -0
- package/coms/compile/common.js +74 -43
- package/coms/compile/downLevel.js +6 -6
- package/coms/compile/downLevel_test.js +5 -1
- package/coms/compile/formatcode.js +1 -1
- package/coms/compile/powermap.js +1 -1
- package/coms/compile/unstruct.js +2 -2
- package/coms/docs/codecolor.js +47 -17
- package/coms/docs/codetext.xht +83 -12
- package/coms/frame/route.js +15 -15
- package/coms/zimoli/XMLHttpRequest.js +2 -5
- package/coms/zimoli/alert.js +2 -2
- package/coms/zimoli/confirm.js +1 -1
- package/coms/zimoli/createEvent.js +6 -7
- package/coms/zimoli/dispatch.js +8 -4
- package/coms/zimoli/getScreenPosition.js +6 -6
- package/coms/zimoli/grid.js +14 -10
- package/coms/zimoli/list.js +13 -1
- package/coms/zimoli/on.js +2 -1
- package/coms/zimoli/picture.js +1 -1
- package/coms/zimoli/render.js +1 -1
- package/coms/zimoli/slider.js +4 -0
- package/coms/zimoli/tree.js +133 -43
- package/coms/zimoli/tree.less +2 -1
- package/coms/zimoli/vbox.js +5 -5
- package/coms/zimoli/vbox.less +3 -1
- package/coms/zimoli/zimoli.js +1 -1
- package/data/packexe-setup.sfx +0 -0
- package/docs//347/273/204/344/273/266.xht +4 -4
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/basic/Item.js
CHANGED
|
@@ -15,7 +15,6 @@ class Item extends Array {
|
|
|
15
15
|
extended = false;
|
|
16
16
|
constructor(value) {
|
|
17
17
|
super();
|
|
18
|
-
this.children = this;
|
|
19
18
|
this.count = 0;//子项中的叶子节点数
|
|
20
19
|
this.total = 0;//子项中的节点数
|
|
21
20
|
this.crack = 0;
|
|
@@ -29,6 +28,7 @@ class Item extends Array {
|
|
|
29
28
|
if (value && value.children instanceof Array) {
|
|
30
29
|
var children = value.children.map(item => new Item(item));
|
|
31
30
|
children.forEach(item => item.parent = item);
|
|
31
|
+
this.children = this;
|
|
32
32
|
this.push.apply(this, children);
|
|
33
33
|
}
|
|
34
34
|
if (isObject(value)) {
|
|
@@ -82,6 +82,11 @@ class Item extends Array {
|
|
|
82
82
|
setClosed(value) {
|
|
83
83
|
if (isObject(this.value)) this.value.closed = value;
|
|
84
84
|
else this.closed = value;
|
|
85
|
+
var c = this;
|
|
86
|
+
while (c.joined) {
|
|
87
|
+
c = c[0];
|
|
88
|
+
c.setClosed(value);
|
|
89
|
+
}
|
|
85
90
|
}
|
|
86
91
|
isActive() {
|
|
87
92
|
if (isObject(this.value)) {
|
package/coms/basic/Tree.js
CHANGED
|
@@ -110,10 +110,13 @@ class Tree extends Array {
|
|
|
110
110
|
}
|
|
111
111
|
return root;
|
|
112
112
|
}
|
|
113
|
-
static toArray(root, skipClosed =
|
|
113
|
+
static toArray(root, skipClosed = 1) {
|
|
114
|
+
var autoJoin = typeof skipClosed === 'number' && skipClosed === skipClosed;
|
|
115
|
+
if (autoJoin) autoJoin = skipClosed < 0 ? -skipClosed : skipClosed;
|
|
114
116
|
var path = [root], pathcx = [0];
|
|
115
117
|
var result = [];
|
|
116
118
|
var max_deep = 1;
|
|
119
|
+
var joined = 0;
|
|
117
120
|
loop: while (pathcx.length) {
|
|
118
121
|
var pathindex = pathcx.length - 1;
|
|
119
122
|
var cx = pathcx[pathindex];
|
|
@@ -127,6 +130,17 @@ class Tree extends Array {
|
|
|
127
130
|
elem.parent = item;
|
|
128
131
|
result.push(elem);
|
|
129
132
|
pathcx[pathindex] = ++cx;
|
|
133
|
+
if (autoJoin && elem.length === 1) {
|
|
134
|
+
joined = 1;
|
|
135
|
+
while (joined < autoJoin && elem.length === 1) {
|
|
136
|
+
if (!elem[0].children) break;
|
|
137
|
+
item = elem;
|
|
138
|
+
elem = elem[0];
|
|
139
|
+
elem.parent = item;
|
|
140
|
+
item.joined = true;
|
|
141
|
+
joined++;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
130
144
|
if (!skipClosed || !elem.isClosed()) {
|
|
131
145
|
if (elem.length) {
|
|
132
146
|
path.push(elem);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
var shallowClone = function (origin, deep) {
|
|
2
|
-
if (--deep < 0) return origin;
|
|
1
|
+
var shallowClone = function (origin, deep = /^[^\$\_]/) {
|
|
3
2
|
if (!isObject(origin)) return origin;
|
|
4
3
|
var temp = origin instanceof Array ? [] : {};
|
|
4
|
+
if (deep instanceof RegExp) {
|
|
5
|
+
for (var k in origin) if (deep.test(k)) temp[k] = origin[k];
|
|
6
|
+
return temp;
|
|
7
|
+
}
|
|
8
|
+
if (--deep < 0) return origin;
|
|
5
9
|
if (deep > 0) for (var k in origin) temp[k] = shallowClone(origin[k], deep);
|
|
6
10
|
else for (var k in origin) temp[k] = origin[k];
|
|
7
11
|
return temp;
|
package/coms/basic_/JSON.js
CHANGED
|
@@ -145,11 +145,7 @@ var getString = function (object, filter, space) {
|
|
|
145
145
|
object = object.toISOString();
|
|
146
146
|
}
|
|
147
147
|
if (hasFilter) {
|
|
148
|
-
|
|
149
|
-
if (isObject(object1) && object !== object1) {
|
|
150
|
-
object1 = getString(object1, filter, space);
|
|
151
|
-
}
|
|
152
|
-
object = object1;
|
|
148
|
+
object = filter(key, object);
|
|
153
149
|
}
|
|
154
150
|
switch (typeof object) {
|
|
155
151
|
case "object":
|
package/coms/basic_/JSON_test.js
CHANGED
|
@@ -155,7 +155,13 @@ var test2 = function (JSON) {
|
|
|
155
155
|
"ratio": 1,
|
|
156
156
|
"readonly": true
|
|
157
157
|
}];
|
|
158
|
-
|
|
158
|
+
var unicode = a => a.replace(/\\u([a-f\d]{4})/g, (_, a) => String.fromCharCode(parseInt(a, 16)));
|
|
159
|
+
assert(unicode(JSON.stringify(data, null, 4)), JSON0.stringify(data, null, 4))
|
|
160
|
+
var filter = function (k, o) {
|
|
161
|
+
if (typeof o !== 'object' || o.length) return o;
|
|
162
|
+
return { name: o.name };
|
|
163
|
+
}
|
|
164
|
+
assert(unicode(JSON.stringify(data, filter, 4)), JSON0.stringify(data, filter, 4));
|
|
159
165
|
}
|
|
160
166
|
function JSON_test() {
|
|
161
167
|
window.JSON0 = JSON0;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var Html = require("./Html");
|
|
2
|
+
var fs = require("fs");
|
|
3
|
+
var path = require("path");
|
|
2
4
|
var test = function (source, pick, value) {
|
|
3
5
|
var h = new Html;
|
|
4
6
|
var b = h.exec(source);
|
|
@@ -8,6 +10,10 @@ var test = function (source, pick, value) {
|
|
|
8
10
|
assert(seek(b, pick), value);
|
|
9
11
|
}
|
|
10
12
|
};
|
|
13
|
+
var test2 = function (source) {
|
|
14
|
+
var s = scanner2(source, 'html');
|
|
15
|
+
assert(s.toString(), source);
|
|
16
|
+
}
|
|
11
17
|
test("<h><a #c>b</a><c b=x>d</c><d/><e>2px</e></h>");
|
|
12
18
|
test("<a>Let's Encrypt</a>");
|
|
13
19
|
test("<style>{a-b:2}</style>");
|
|
@@ -23,4 +29,9 @@ test('<div>${`<div></div>`}</div>');
|
|
|
23
29
|
test('<div>\\${${`<div></div>`}</div>');
|
|
24
30
|
test('<div>$\\{${`<div></div>`}</div>');
|
|
25
31
|
test('<div>$\\{${typeof `<div></div>`}</div>');
|
|
26
|
-
test('<div>$\\{${\\a+typeof`<div></div>`}</div>','<div>$\\{${\\a + typeof `<div></div>`}</div>');
|
|
32
|
+
test('<div>$\\{${\\a+typeof`<div></div>`}</div>', '<div>$\\{${\\a + typeof `<div></div>`}</div>');
|
|
33
|
+
test('${i18n`加载中..`}<div class="loader"></div>');
|
|
34
|
+
test('${a +typeof i18n`加载中..`}<div class="loader"></div>','${a + typeof i18n`加载中..`}<div class="loader"></div>');
|
|
35
|
+
test('${a > 1}');
|
|
36
|
+
test('a>1','a > 1');
|
|
37
|
+
test('a><a></a>','a > <a></a>');
|
|
@@ -40,31 +40,33 @@ return,typeof,delete,switch,export,import,static
|
|
|
40
40
|
default,finally,extends
|
|
41
41
|
function,continue,debugger
|
|
42
42
|
instanceof`.trim().split(/[,\s]+/);
|
|
43
|
+
var colonstrap_reg = /^(case|default)$/;
|
|
43
44
|
class Javascript extends Program {
|
|
44
45
|
straps = straps;
|
|
45
46
|
value_reg = /^(false|true|null|Infinity|NaN|undefined|eval)$/
|
|
46
47
|
transive_reg = /^(new|var|let|const|yield|void|in|of|typeof|delete|case|return|await|default|instanceof|throw|extends|import|from)$/
|
|
47
48
|
strapexp_reg = /^(new|void|typeof|delete|class|function|await)/;
|
|
48
49
|
forceend_reg = /^(return|yield|break|continue|debugger|async)$/;
|
|
49
|
-
|
|
50
|
-
colonstrap_reg = /^(case|default)$/;
|
|
51
|
-
|
|
50
|
+
type_reg = /^(var|let|const|function|class|interface|type)$/;
|
|
52
51
|
defaultType = EXPRESS;
|
|
53
52
|
}
|
|
54
|
-
var propresolve_reg = /^(static|get|set|async)$/;
|
|
53
|
+
var propresolve_reg = /^(static|get|set|async|readonly|private)$/;
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
var isProperty = function (o) {
|
|
57
56
|
var queue = o.queue;
|
|
58
57
|
var prev = o.prev;
|
|
59
58
|
if (queue.isObject) {
|
|
60
|
-
if (!prev || prev.type === STAMP && prev.text
|
|
59
|
+
if (!prev || prev.type === STAMP && /^[,;]$/.test(prev.text)) return true;
|
|
61
60
|
if (prev.type === STAMP && prev.isprop) return true;
|
|
62
61
|
}
|
|
63
62
|
if (queue.isClass) {
|
|
64
63
|
if (!prev) return true;
|
|
64
|
+
if (o.type === SCOPED && o.entry !== '{') {
|
|
65
|
+
return prev.isprop || prev.type === STAMP && prev.text === ';' || isShortMethodEnd(prev);
|
|
66
|
+
}
|
|
65
67
|
if (prev.type === STAMP) {
|
|
66
68
|
if (prev.isprop) return true;
|
|
67
|
-
return /^(
|
|
69
|
+
return /^(\+\+|\-\-|[,;])$/.test(prev.text) && (o.type !== STAMP || !/^[,;\=\:]$/.test(o.text));
|
|
68
70
|
}
|
|
69
71
|
if (prev.type === EXPRESS && !/\.$/.test(prev.text)) {
|
|
70
72
|
return prev.text !== 'async' || o.text !== 'function';
|
|
@@ -102,7 +104,7 @@ var setStrapExpress = function (mark_type, mark_text, prop, o, default_type) {
|
|
|
102
104
|
if (q.entry === '(') {
|
|
103
105
|
var pp = q.prev;
|
|
104
106
|
}
|
|
105
|
-
else if (q.
|
|
107
|
+
else if (q.brace) a: {
|
|
106
108
|
var p = q.prev;
|
|
107
109
|
if (p) {
|
|
108
110
|
if (p.type === STAMP && p.text === "=>") {
|
|
@@ -154,16 +156,14 @@ var setStrapExpress = function (mark_type, mark_text, prop, o, default_type) {
|
|
|
154
156
|
}
|
|
155
157
|
var setYieldExpress = setStrapExpress.bind(null, STAMP, "*", 'next');
|
|
156
158
|
var setAwaitExpress = setStrapExpress.bind(null, STRAP, "async", 'prev');
|
|
157
|
-
|
|
159
|
+
var fixType = function (o) {
|
|
158
160
|
var m = o.text;
|
|
159
|
-
if (m === 'yield') setYieldExpress(o, this.defaultType);
|
|
160
|
-
else if (m === 'await') setAwaitExpress(o, this.defaultType);
|
|
161
161
|
var last = o.prev;
|
|
162
162
|
var type = o.type;
|
|
163
163
|
var queue = o.queue;
|
|
164
164
|
switch (type) {
|
|
165
165
|
case QUOTED:
|
|
166
|
-
if (
|
|
166
|
+
if (isProperty(o)) o.isprop = true;
|
|
167
167
|
break;
|
|
168
168
|
case SCOPED:
|
|
169
169
|
if (o.entry === '(') {
|
|
@@ -173,14 +173,14 @@ Javascript.prototype.fixType = function (o) {
|
|
|
173
173
|
}
|
|
174
174
|
break;
|
|
175
175
|
case EXPRESS:
|
|
176
|
-
if ((!/^\./.test(m)) &&
|
|
176
|
+
if ((!/^\./.test(m)) && isProperty(o)) type = PROPERTY;
|
|
177
177
|
break;
|
|
178
178
|
case STRAP:
|
|
179
179
|
case VALUE:
|
|
180
180
|
if (last && last.type === EXPRESS && /[^\.]\.$/.test(last.text)) {
|
|
181
181
|
type = EXPRESS;
|
|
182
182
|
}
|
|
183
|
-
else if (
|
|
183
|
+
else if (isProperty(o)) type = PROPERTY;
|
|
184
184
|
else if (m === 'from') {
|
|
185
185
|
if (!last || last.type === STRAP && !/^(im|ex)port$/.test(last.text)) {
|
|
186
186
|
type = EXPRESS;
|
|
@@ -218,12 +218,13 @@ Javascript.prototype.fixType = function (o) {
|
|
|
218
218
|
}
|
|
219
219
|
break;
|
|
220
220
|
}
|
|
221
|
-
if (type === STRAP && m
|
|
222
|
-
queue.classed =
|
|
221
|
+
if (type === STRAP && /^(class|interface)$/.test(m) && !queue.classed) {
|
|
222
|
+
queue.classed = [m];
|
|
223
223
|
}
|
|
224
|
-
else if (queue.classed
|
|
225
|
-
if (type === STRAP && /^(class|function)$/.test(m)) queue.classed
|
|
224
|
+
else if (queue.classed) {
|
|
225
|
+
if (type === STRAP && /^(class|function|interface)$/.test(m)) queue.classed.push(m);
|
|
226
226
|
}
|
|
227
|
+
if (type === PROPERTY) o.isprop = true;
|
|
227
228
|
o.type = type;
|
|
228
229
|
|
|
229
230
|
};
|
|
@@ -278,12 +279,11 @@ var setObject = function (o) {
|
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
281
|
};
|
|
281
|
-
|
|
282
|
+
var detectLabel = function (o) {
|
|
282
283
|
var queue = o.queue;
|
|
283
284
|
var last = queue.last;
|
|
284
285
|
var m = o.text;
|
|
285
286
|
var type = o.type;
|
|
286
|
-
var colonstrap_reg = this.colonstrap_reg;
|
|
287
287
|
var end = o.end;
|
|
288
288
|
var inExpress = queue.inExpress;
|
|
289
289
|
if (type === SPACE);
|
|
@@ -294,17 +294,25 @@ Javascript.prototype.detectLabel = function (o) {
|
|
|
294
294
|
}
|
|
295
295
|
else if (last) check: switch (m) {
|
|
296
296
|
case "?":
|
|
297
|
+
if (last.isprop) {
|
|
298
|
+
o.type = EXPRESS;
|
|
299
|
+
o.isprop = true;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
297
302
|
inExpress = true;
|
|
298
303
|
if (!queue.question) queue.question = 1;
|
|
299
304
|
else queue.question++;
|
|
300
305
|
break;
|
|
301
306
|
case "=":
|
|
302
|
-
|
|
303
|
-
if (last.type === SCOPED && last.entry === "{") {
|
|
307
|
+
if (last.type === SCOPED && last.brace) {
|
|
304
308
|
if (!last.isObject) {
|
|
305
309
|
setObject(last);
|
|
306
310
|
}
|
|
307
311
|
}
|
|
312
|
+
var lp = last.prev;
|
|
313
|
+
if (lp?.type === STRAP && lp.text === 'type') {
|
|
314
|
+
o.istype = true;
|
|
315
|
+
}
|
|
308
316
|
case ",":
|
|
309
317
|
if (queue.isObject) {
|
|
310
318
|
if (last.type === PROPERTY) {
|
|
@@ -316,36 +324,48 @@ Javascript.prototype.detectLabel = function (o) {
|
|
|
316
324
|
case ":":
|
|
317
325
|
if (queue.question) {
|
|
318
326
|
queue.question--;
|
|
319
|
-
|
|
327
|
+
if (last.type === STAMP && last.text === '?') {
|
|
328
|
+
inExpress = false;
|
|
329
|
+
o.istype = true;
|
|
330
|
+
last.type = EXPRESS;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
inExpress = true;
|
|
334
|
+
}
|
|
320
335
|
break;
|
|
321
336
|
}
|
|
322
337
|
if (queue.isObject) {
|
|
323
|
-
if (last.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (last.type === SCOPED && (!last.prev || !last.prev.type === STAMP && last.prev.text === ",")) {
|
|
328
|
-
inExpress = true;
|
|
338
|
+
if (last.isprop) {
|
|
339
|
+
o.isExpress = false;
|
|
340
|
+
queue.inExpress = true;
|
|
341
|
+
return;
|
|
329
342
|
}
|
|
343
|
+
}
|
|
344
|
+
inExpress = false;
|
|
345
|
+
if (queue.entry && (!queue.brace || queue.isClass)) {
|
|
346
|
+
o.istype = true;
|
|
330
347
|
break;
|
|
331
348
|
}
|
|
332
349
|
var temp = last;
|
|
333
350
|
while (temp) {
|
|
334
351
|
if (temp.type === STRAP && colonstrap_reg.test(temp.text)) {
|
|
335
|
-
inExpress = false;
|
|
336
352
|
break check;
|
|
337
353
|
}
|
|
338
354
|
if (!temp.isExpress) break;
|
|
339
355
|
temp = temp.prev;
|
|
340
356
|
}
|
|
341
|
-
inExpress = false;
|
|
342
357
|
if (last.type & (EXPRESS | STRAP | VALUE | QUOTED)) {
|
|
343
358
|
// label
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
359
|
+
var lp = last.prev;
|
|
360
|
+
if (!lp || lp.type !== STRAP || lp.isend) {
|
|
361
|
+
last.type = LABEL;
|
|
362
|
+
last.text += ":";
|
|
363
|
+
last.end = end;
|
|
364
|
+
queue.inExpress = false;
|
|
365
|
+
return o;
|
|
366
|
+
}
|
|
348
367
|
}
|
|
368
|
+
o.istype = true;
|
|
349
369
|
break;
|
|
350
370
|
default:
|
|
351
371
|
inExpress = true;
|
|
@@ -359,31 +379,46 @@ Javascript.prototype.detectLabel = function (o) {
|
|
|
359
379
|
}
|
|
360
380
|
|
|
361
381
|
Javascript.prototype.setType = function (o) {
|
|
362
|
-
if (
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
var q = o.queue;
|
|
367
|
-
q.question--;
|
|
368
|
-
return false;
|
|
382
|
+
if (detectLabel(o)) return false;
|
|
383
|
+
switch (o.text) {
|
|
384
|
+
case "yield": setYieldExpress(o, this.defaultType); break;
|
|
385
|
+
case "await": setAwaitExpress(o, this.defaultType); break;
|
|
369
386
|
}
|
|
387
|
+
var last = o.prev;
|
|
388
|
+
var queue = o.queue;
|
|
389
|
+
|
|
370
390
|
if (last) {
|
|
391
|
+
if (last.type === STAMP && last.text === "?") {
|
|
392
|
+
if (o.type === EXPRESS && /^\.[^\.]|^\.$/.test(o.text)) {
|
|
393
|
+
last.type = EXPRESS;
|
|
394
|
+
var q = o.queue;
|
|
395
|
+
q.question--;
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
371
399
|
if (o.type === STRAP && o.text === "function") {
|
|
372
400
|
if (last.text === 'async' && !last.isend) last.type = STRAP;
|
|
373
401
|
}
|
|
402
|
+
if ((o.type & (EXPRESS | STRAP) && last.type === STAMP || o.type === STAMP && /^([\|\&]|\=\>)$/.test(o.text)) && (last.istype || queue.istype)) {
|
|
403
|
+
o.istype = true;
|
|
404
|
+
}
|
|
374
405
|
}
|
|
375
|
-
|
|
376
|
-
|
|
406
|
+
else {
|
|
407
|
+
if (queue.istype) {
|
|
408
|
+
o.istype = true;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
fixType(o);
|
|
377
413
|
if (queue.isObject || queue.isClass) {
|
|
378
|
-
if (o.type & (VALUE | QUOTED | STRAP)) {
|
|
379
|
-
o.isprop =
|
|
414
|
+
if (o.type & (VALUE | QUOTED | STRAP | ELEMENT)) {
|
|
415
|
+
o.isprop = isProperty(o);
|
|
380
416
|
}
|
|
381
417
|
else if (o.type === SCOPED) {
|
|
382
|
-
if (o.entry === '[') {
|
|
383
|
-
|
|
384
|
-
if (queue.isClass) o.isprop = !last || last.isprop || last.type === STAMP && last.text === ';' || isShortMethodEnd(last);
|
|
418
|
+
if (o.entry === '[' || o.entry === '(') {
|
|
419
|
+
o.isprop = isProperty(o);
|
|
385
420
|
}
|
|
386
|
-
else if (o.
|
|
421
|
+
else if (o.brace) {
|
|
387
422
|
if (last && last.type === PROPERTY && last.text === 'static') {
|
|
388
423
|
last.type = STRAP;
|
|
389
424
|
}
|
|
@@ -396,26 +431,27 @@ Javascript.prototype.setType = function (o) {
|
|
|
396
431
|
o.isprop = true;
|
|
397
432
|
}
|
|
398
433
|
if (o.isprop) {
|
|
399
|
-
if (last && last.type === PROPERTY && propresolve_reg.test(last.text)) {
|
|
434
|
+
if (last && last.type === PROPERTY && propresolve_reg.test(last.text) && (o.type !== SCOPED || o.entry === "[")) {
|
|
400
435
|
last.type = STRAP;
|
|
401
436
|
}
|
|
402
437
|
if (queue.isClass) o.isend = false;
|
|
403
438
|
}
|
|
404
439
|
}
|
|
405
|
-
if (o.
|
|
406
|
-
else if (o.type === STRAP
|
|
407
|
-
o.
|
|
440
|
+
if (o.isprop);
|
|
441
|
+
else if (o.type === STRAP) {
|
|
442
|
+
if (this.type_reg.test(o.text)) o.istype = true;
|
|
443
|
+
if (propresolve_reg.test(o.text)) o.type = EXPRESS;
|
|
408
444
|
}
|
|
409
445
|
if (last) {
|
|
410
446
|
if (o.type === STAMP && o.text === "=>") {
|
|
411
447
|
var pp = last.prev;
|
|
412
|
-
if (pp
|
|
448
|
+
if (pp?.type === EXPRESS && pp.text === 'async') {
|
|
413
449
|
if (!pp.isend) pp.type = STRAP;
|
|
414
450
|
}
|
|
415
451
|
}
|
|
416
452
|
}
|
|
417
453
|
if (o.type === STAMP) {
|
|
418
|
-
if (!last || last.type & (STAMP | STRAP) && !/^(\+\+|\-\-)$/.test(last.text) || last.type === SCOPED && /^[\{\[]$/.test(last.entry) && !last.isExpress) {
|
|
454
|
+
if (!last || last.type & (STAMP | STRAP) && !/^(\+\+|\-\-)$/.test(last.text) && !last.istype || last.type === SCOPED && /^[\{\[]$/.test(last.entry) && !last.isExpress) {
|
|
419
455
|
o.unary = /^[^=;,\*]$|.[^\=\>\<\|\&\^]$/.test(o.text);
|
|
420
456
|
if (o.unary && /^(\+|\-)$/.test(o.text) && last && last.type === STAMP && /^(\+\+|\-\-)$/.test(last.text)) o.unary = !!last.unary;
|
|
421
457
|
}
|
|
@@ -614,7 +650,7 @@ function detour(o, ie) {
|
|
|
614
650
|
}
|
|
615
651
|
if (!o.isprop) break;
|
|
616
652
|
case PROPERTY:
|
|
617
|
-
if (!o.isend &&
|
|
653
|
+
if (!o.isend && propresolve_reg.test(o.text) && o.next && (o.next.type === PROPERTY || o.next.isprop)) break;
|
|
618
654
|
if (o.text === 'static' && o.next && o.next.type === SCOPED && o.next.entry === '{') break;
|
|
619
655
|
if (/^\[/.test(o.text)) break;
|
|
620
656
|
if (o.queue.isObject) {
|
|
@@ -637,7 +673,7 @@ function detour(o, ie) {
|
|
|
637
673
|
var text = strings.recode(o.text);
|
|
638
674
|
if (o.prev) {
|
|
639
675
|
var prev = o.prev;
|
|
640
|
-
if (prev && prev.isprop && !prev.isend &&
|
|
676
|
+
if (prev && prev.isprop && !prev.isend && propresolve_reg.test(prev.text)) {
|
|
641
677
|
prev = prev.prev;
|
|
642
678
|
}
|
|
643
679
|
if (prev && prev.type === STAMP && prev.isprop) prev = prev.prev;
|
|
@@ -33,7 +33,7 @@ testDetour('1.e+10.a', '1e+10["a"]')
|
|
|
33
33
|
testDetour('0x1.a', '0x1["a"]')
|
|
34
34
|
testDetour('0b1.a', '0b1["a"]')
|
|
35
35
|
testDetour('01.a', '0o1["a"]')
|
|
36
|
-
testDetour('08.a', '08
|
|
36
|
+
testDetour('08.a', '08["a"]')
|
|
37
37
|
testDetour('0o1.a', '0o1["a"]')
|
|
38
38
|
testDetour('0o1n.a', '0o1n["a"]')
|
|
39
39
|
testDetour('0o1m.a', '0o1m["a"]')
|
|
@@ -41,4 +41,72 @@ testDetour('0o1i.a', '0o1i["a"]')
|
|
|
41
41
|
testDetour('0o1j.a', '0o1j["a"]')
|
|
42
42
|
testDetour('0o1k.a', '0o1k["a"]')
|
|
43
43
|
testDetour('0o1l.a', '0o1l["a"]')
|
|
44
|
-
testDetour('0o1ll.a', '0o1ll["a"]')
|
|
44
|
+
testDetour('0o1ll.a', '0o1ll["a"]')
|
|
45
|
+
var ts = new Javascript;
|
|
46
|
+
ts.straps.push('interface', 'implements', "declare", "module", "readonly", "enum", 'type');
|
|
47
|
+
ts.tags[0].push("{")
|
|
48
|
+
var testTypescript = function (text) {
|
|
49
|
+
var s = scanner2(text, ts);
|
|
50
|
+
return assert(s.toString(), text);
|
|
51
|
+
}
|
|
52
|
+
testTypescript(`const strict: Omit<typeof assert, 'equal' | 'notEqual' | 'deepEqual' | 'notDeepEqual' | 'ok' | 'strictEqual' | 'deepStrictEqual' | 'ifError' | 'strict'> & {
|
|
53
|
+
(value: unknown, message?: string | Error): asserts value;
|
|
54
|
+
equal: typeof strictEqual;
|
|
55
|
+
notEqual: typeof notStrictEqual;
|
|
56
|
+
deepEqual: typeof deepStrictEqual;
|
|
57
|
+
notDeepEqual: typeof notDeepStrictEqual;
|
|
58
|
+
// Mapped types and assertion functions are incompatible?
|
|
59
|
+
// TS2775: Assertions require every name in the call target
|
|
60
|
+
// to be declared with an explicit type annotation.
|
|
61
|
+
ok: typeof ok;
|
|
62
|
+
strictEqual: typeof strictEqual;
|
|
63
|
+
deepStrictEqual: typeof deepStrictEqual;
|
|
64
|
+
ifError: typeof ifError;
|
|
65
|
+
strict: typeof strict;
|
|
66
|
+
};`);
|
|
67
|
+
testTypescript(`
|
|
68
|
+
type ExecFileException =
|
|
69
|
+
& Omit<ExecException, 'code'>
|
|
70
|
+
& Omit<NodeJS.ErrnoException, 'code'>
|
|
71
|
+
& { code?: string | number | undefined | null };
|
|
72
|
+
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
|
73
|
+
const exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
|
|
74
|
+
`)
|
|
75
|
+
testTypescript(`class AsyncLocalStorage<T> {
|
|
76
|
+
static snapshot(): (<R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R) & {
|
|
77
|
+
asyncResource: AsyncResource;
|
|
78
|
+
};
|
|
79
|
+
}`);
|
|
80
|
+
|
|
81
|
+
testTypescript(`interface AsyncResourceOptions {
|
|
82
|
+
triggerAsyncId?: number | undefined;
|
|
83
|
+
requireManualDestroy?: boolean | undefined;
|
|
84
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
85
|
+
from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
|
|
86
|
+
getRandomValues<T extends Exclude<NodeJS.TypedArray, Float32Array | Float64Array>>(typedArray: T): T;
|
|
87
|
+
preopens?: NodeJS.Dict<string> | undefined;
|
|
88
|
+
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
|
89
|
+
}`);
|
|
90
|
+
|
|
91
|
+
testTypescript(`
|
|
92
|
+
interface WritableOptions extends StreamOptions<Writable> {
|
|
93
|
+
decodeStrings?: boolean | undefined;
|
|
94
|
+
defaultEncoding?: BufferEncoding | undefined;
|
|
95
|
+
write?(this: Writable, chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
96
|
+
writev?(
|
|
97
|
+
this: Writable,
|
|
98
|
+
chunks: Array<{
|
|
99
|
+
chunk: any;
|
|
100
|
+
encoding: BufferEncoding;
|
|
101
|
+
}>,
|
|
102
|
+
callback: (error?: Error | null) => void
|
|
103
|
+
): void;
|
|
104
|
+
final?(this: Writable, callback: (error?: Error | null) => void): void;
|
|
105
|
+
}`);
|
|
106
|
+
common.debug=true;
|
|
107
|
+
testTypescript(`
|
|
108
|
+
while(++i < 2) {}
|
|
109
|
+
a ? function() {} : function() {}
|
|
110
|
+
declare module 'buffer' {}
|
|
111
|
+
|
|
112
|
+
`)
|