bobe 0.0.38 → 0.0.40
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/dist/bobe.cjs.js +48 -6
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +48 -6
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +49 -7
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +49 -7
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +21 -5
- package/dist/index.umd.js +48 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Queue, isNum, matchIdStart2, jsVarRegexp } from 'bobe-shared';
|
|
1
|
+
import { Queue, isNum, matchIdStart2, matchId, jsVarRegexp } from 'bobe-shared';
|
|
2
2
|
import { getPulling, setPulling, Keys, Computed, Effect, toRaw, runWithPulling, Scope, deepSignal, Store, shareSignal, effect } from 'aoye';
|
|
3
3
|
export * from 'aoye';
|
|
4
4
|
|
|
@@ -18,6 +18,7 @@ let TokenType = function (TokenType) {
|
|
|
18
18
|
TokenType[TokenType["Boolean"] = 4096] = "Boolean";
|
|
19
19
|
TokenType[TokenType["Null"] = 8192] = "Null";
|
|
20
20
|
TokenType[TokenType["Undefined"] = 16384] = "Undefined";
|
|
21
|
+
TokenType[TokenType["Comment"] = 32768] = "Comment";
|
|
21
22
|
return TokenType;
|
|
22
23
|
}({});
|
|
23
24
|
const BaseTokenType = TokenType.String | TokenType.Number | TokenType.Boolean | TokenType.Null | TokenType.Undefined;
|
|
@@ -64,8 +65,9 @@ let ParseErrorCode = function (ParseErrorCode) {
|
|
|
64
65
|
ParseErrorCode[ParseErrorCode["MISSING_FOR_COLLECTION"] = 9012] = "MISSING_FOR_COLLECTION";
|
|
65
66
|
ParseErrorCode[ParseErrorCode["MISSING_FOR_SEMICOLON"] = 9013] = "MISSING_FOR_SEMICOLON";
|
|
66
67
|
ParseErrorCode[ParseErrorCode["MISSING_FOR_ITEM"] = 9014] = "MISSING_FOR_ITEM";
|
|
67
|
-
ParseErrorCode[ParseErrorCode["
|
|
68
|
-
ParseErrorCode[ParseErrorCode["
|
|
68
|
+
ParseErrorCode[ParseErrorCode["MISSING_COMMENT_SECOND_SLASH"] = 9015] = "MISSING_COMMENT_SECOND_SLASH";
|
|
69
|
+
ParseErrorCode[ParseErrorCode["MISSING_PROP_ASSIGNMENT"] = 9016] = "MISSING_PROP_ASSIGNMENT";
|
|
70
|
+
ParseErrorCode[ParseErrorCode["PIPE_IN_WRONG_CONTEXT"] = 9017] = "PIPE_IN_WRONG_CONTEXT";
|
|
69
71
|
return ParseErrorCode;
|
|
70
72
|
}({});
|
|
71
73
|
class ParseSyntaxError extends SyntaxError {
|
|
@@ -293,6 +295,9 @@ class Tokenizer {
|
|
|
293
295
|
this.needLoc = true;
|
|
294
296
|
}
|
|
295
297
|
switch (char) {
|
|
298
|
+
case '/':
|
|
299
|
+
this.comment();
|
|
300
|
+
break;
|
|
296
301
|
case "'":
|
|
297
302
|
case '"':
|
|
298
303
|
this.str(char);
|
|
@@ -332,6 +337,22 @@ class Tokenizer {
|
|
|
332
337
|
this.handledTokens.push(this.token);
|
|
333
338
|
}
|
|
334
339
|
}
|
|
340
|
+
getComment() {
|
|
341
|
+
let value = '/';
|
|
342
|
+
let nextC = this.code[this.i + 1];
|
|
343
|
+
if (nextC !== '/') {
|
|
344
|
+
throw new ParseSyntaxError(ParseErrorCode.MISSING_COMMENT_SECOND_SLASH, '注释开头必须是 //', this.emptyLoc());
|
|
345
|
+
}
|
|
346
|
+
while (this.code[this.i + 1] !== '\n') {
|
|
347
|
+
this.next();
|
|
348
|
+
value += this.code[this.i];
|
|
349
|
+
}
|
|
350
|
+
return value;
|
|
351
|
+
}
|
|
352
|
+
comment() {
|
|
353
|
+
this.getComment();
|
|
354
|
+
this.next();
|
|
355
|
+
}
|
|
335
356
|
condExp() {
|
|
336
357
|
{
|
|
337
358
|
this.preCol = this.column;
|
|
@@ -350,8 +371,8 @@ class Tokenizer {
|
|
|
350
371
|
this.next();
|
|
351
372
|
}
|
|
352
373
|
value += this.code[this.i];
|
|
353
|
-
const trimmed = value.trim();
|
|
354
|
-
this.setToken(TokenType.Identifier, trimmed ?
|
|
374
|
+
const trimmed = value.replace(/\/\/[\s\S]+/, '').trim();
|
|
375
|
+
this.setToken(TokenType.Identifier, trimmed ? trimmed : true);
|
|
355
376
|
return this.token;
|
|
356
377
|
} finally {
|
|
357
378
|
this.next();
|
|
@@ -361,6 +382,9 @@ class Tokenizer {
|
|
|
361
382
|
}
|
|
362
383
|
}
|
|
363
384
|
}
|
|
385
|
+
isEol(i) {
|
|
386
|
+
return this.code[i] === '\n' || this.code[i] === '/';
|
|
387
|
+
}
|
|
364
388
|
jsExp() {
|
|
365
389
|
{
|
|
366
390
|
this.preCol = this.column;
|
|
@@ -399,6 +423,13 @@ class Tokenizer {
|
|
|
399
423
|
}
|
|
400
424
|
return this.code[i];
|
|
401
425
|
}
|
|
426
|
+
peekCharIsEol() {
|
|
427
|
+
const char = this.peekChar();
|
|
428
|
+
return char === '\n' || char === '/';
|
|
429
|
+
}
|
|
430
|
+
charIsEol(char) {
|
|
431
|
+
return char === '\n' || char === '/';
|
|
432
|
+
}
|
|
402
433
|
assignment() {
|
|
403
434
|
this.setToken(TokenType.Assign, '=');
|
|
404
435
|
}
|
|
@@ -518,6 +549,9 @@ class Tokenizer {
|
|
|
518
549
|
case '\n':
|
|
519
550
|
nextC = '\n';
|
|
520
551
|
break;
|
|
552
|
+
case '/':
|
|
553
|
+
nextC = '/';
|
|
554
|
+
break;
|
|
521
555
|
default:
|
|
522
556
|
nextC = '';
|
|
523
557
|
break;
|
|
@@ -526,6 +560,12 @@ class Tokenizer {
|
|
|
526
560
|
isEmptyLine = true;
|
|
527
561
|
break;
|
|
528
562
|
}
|
|
563
|
+
if (nextC === '/') {
|
|
564
|
+
value += this.getComment();
|
|
565
|
+
this.next();
|
|
566
|
+
isEmptyLine = true;
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
529
569
|
if (!nextC) {
|
|
530
570
|
break;
|
|
531
571
|
}
|
|
@@ -555,6 +595,7 @@ class Tokenizer {
|
|
|
555
595
|
isEmptyLine = _this$getDentValue2.isEmptyLine;
|
|
556
596
|
if (isEmptyLine) {
|
|
557
597
|
this.needIndent = true;
|
|
598
|
+
this.next();
|
|
558
599
|
return;
|
|
559
600
|
}
|
|
560
601
|
this.needIndent = false;
|
|
@@ -630,7 +671,7 @@ class Tokenizer {
|
|
|
630
671
|
let nextC;
|
|
631
672
|
while (1) {
|
|
632
673
|
nextC = this.code[this.i + 1];
|
|
633
|
-
if (typeof nextC !== 'string' || !
|
|
674
|
+
if (typeof nextC !== 'string' || !matchId(nextC, 0)) {
|
|
634
675
|
break;
|
|
635
676
|
}
|
|
636
677
|
value += nextC;
|
|
@@ -964,6 +1005,7 @@ var NodeType = function (NodeType) {
|
|
|
964
1005
|
NodeType["Element"] = "Element";
|
|
965
1006
|
NodeType["Text"] = "Text";
|
|
966
1007
|
NodeType["Interpolation"] = "Interpolation";
|
|
1008
|
+
NodeType["Comment"] = "Comment";
|
|
967
1009
|
NodeType["Property"] = "Property";
|
|
968
1010
|
NodeType["PropertyKey"] = "PropertyKey";
|
|
969
1011
|
NodeType["StaticValue"] = "StaticValue";
|
|
@@ -1634,7 +1676,7 @@ class Interpreter {
|
|
|
1634
1676
|
i: 0
|
|
1635
1677
|
};
|
|
1636
1678
|
if (keyExp) {
|
|
1637
|
-
forNode.getKey = new Function('data', `let v;with(data){v=${keyExp}};return v;`);
|
|
1679
|
+
forNode.getKey = new Function('data', `let v;with(data){v=${keyExp}\n};return v;`);
|
|
1638
1680
|
}
|
|
1639
1681
|
window['for1'] = forNode;
|
|
1640
1682
|
const data = this.getData();
|