bobe 0.0.48 → 0.0.49
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 +145 -64
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +153 -86
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +154 -87
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +146 -65
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +39 -18
- package/dist/index.umd.js +145 -64
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Queue, isNum, matchIdStart2, matchId, escapeMap, jsVarRegexp, date32 } from 'bobe-shared';
|
|
2
|
-
import { Signal, Computed, getPulling, setPulling,
|
|
2
|
+
import { Signal, Computed, Keys, getPulling, setPulling, deepSignal, toRaw, ScheduleType, runWithPulling, Scope, Store, noopEffect, NoopEffect, Effect, effect as effect$1, shareSignal } from 'aoye';
|
|
3
3
|
export { Store } from 'aoye';
|
|
4
4
|
|
|
5
5
|
let TokenType = function (TokenType) {
|
|
@@ -105,10 +105,13 @@ class Tokenizer {
|
|
|
105
105
|
this.hook = hook;
|
|
106
106
|
this.useDedentAsEof = useDedentAsEof;
|
|
107
107
|
if (useDedentAsEof) {
|
|
108
|
-
this.
|
|
109
|
-
this.isFirstToken = true;
|
|
108
|
+
this.initIndentWhenUseDedentAsEof();
|
|
110
109
|
}
|
|
111
110
|
}
|
|
111
|
+
initIndentWhenUseDedentAsEof() {
|
|
112
|
+
this.setToken(TokenType.Indent, '');
|
|
113
|
+
this.isFirstToken = true;
|
|
114
|
+
}
|
|
112
115
|
next() {
|
|
113
116
|
{
|
|
114
117
|
const char = this.code[this.i];
|
|
@@ -147,16 +150,23 @@ class Tokenizer {
|
|
|
147
150
|
throwUnclosed(code, message, startOffset, startLine, startCol) {
|
|
148
151
|
throw new ParseSyntaxError(code, message, this.unclosedLoc(startOffset, startLine, startCol));
|
|
149
152
|
}
|
|
150
|
-
resume(
|
|
153
|
+
resume({
|
|
154
|
+
dentStack,
|
|
155
|
+
waitingTokens,
|
|
156
|
+
..._snapshot
|
|
157
|
+
}) {
|
|
151
158
|
this.token = undefined;
|
|
152
159
|
this.needIndent = false;
|
|
153
160
|
this.isFirstToken = true;
|
|
154
|
-
this.dentStack = [0];
|
|
161
|
+
this.dentStack = dentStack ? dentStack.slice() : [0];
|
|
162
|
+
if (waitingTokens) {
|
|
163
|
+
this.waitingTokens = waitingTokens.clone();
|
|
164
|
+
}
|
|
155
165
|
Object.assign(this, _snapshot);
|
|
156
166
|
}
|
|
157
|
-
snapshot(keys) {
|
|
167
|
+
snapshot(keys, dtI = 0) {
|
|
158
168
|
const snap = {
|
|
159
|
-
i: this.i,
|
|
169
|
+
i: this.i + dtI,
|
|
160
170
|
waitingTokens: this.waitingTokens.clone()
|
|
161
171
|
};
|
|
162
172
|
if (keys) {
|
|
@@ -169,8 +179,10 @@ class Tokenizer {
|
|
|
169
179
|
}
|
|
170
180
|
return snap;
|
|
171
181
|
}
|
|
172
|
-
skip() {
|
|
173
|
-
|
|
182
|
+
skip(targetDentLen) {
|
|
183
|
+
if (targetDentLen == undefined) {
|
|
184
|
+
targetDentLen = this.dentStack[this.dentStack.length - 1];
|
|
185
|
+
}
|
|
174
186
|
let needIndent = false;
|
|
175
187
|
let skipFragment = ``;
|
|
176
188
|
this.token = undefined;
|
|
@@ -193,7 +205,7 @@ class Tokenizer {
|
|
|
193
205
|
isEmptyLine = _this$getDentValue.isEmptyLine;
|
|
194
206
|
const currLen = value.length;
|
|
195
207
|
if (isEmptyLine) continue;
|
|
196
|
-
if (currLen >
|
|
208
|
+
if (currLen > targetDentLen) {
|
|
197
209
|
skipFragment += value;
|
|
198
210
|
} else {
|
|
199
211
|
for (let i = this.dentStack.length - 1; i >= 0; i--) {
|
|
@@ -206,6 +218,9 @@ class Tokenizer {
|
|
|
206
218
|
break;
|
|
207
219
|
}
|
|
208
220
|
this.dentStack.pop();
|
|
221
|
+
if (expLen > targetDentLen) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
209
224
|
if (!this.token) {
|
|
210
225
|
this.setToken(TokenType.Dedent, String(expLen));
|
|
211
226
|
} else {
|
|
@@ -272,33 +287,31 @@ class Tokenizer {
|
|
|
272
287
|
}
|
|
273
288
|
outer: while (1) {
|
|
274
289
|
if (this.needIndent) {
|
|
290
|
+
this.locStart();
|
|
275
291
|
this.dent();
|
|
292
|
+
this.locEnd();
|
|
276
293
|
} else {
|
|
277
294
|
const char = this.code[this.i];
|
|
278
295
|
switch (char) {
|
|
279
296
|
case '\t':
|
|
280
297
|
case ' ':
|
|
281
298
|
break;
|
|
282
|
-
case '\n':
|
|
283
|
-
this.newLine();
|
|
284
|
-
this.needIndent = true;
|
|
285
|
-
break;
|
|
286
|
-
case '=':
|
|
287
|
-
this.assignment();
|
|
288
|
-
break;
|
|
289
|
-
case '|':
|
|
290
|
-
this.pipe();
|
|
291
|
-
break;
|
|
292
|
-
case ';':
|
|
293
|
-
this.setToken(TokenType.Semicolon, ';');
|
|
294
|
-
break;
|
|
295
299
|
default:
|
|
296
|
-
|
|
297
|
-
this.preI = this.i;
|
|
298
|
-
this.preCol = this.column;
|
|
299
|
-
this.needLoc = true;
|
|
300
|
-
}
|
|
300
|
+
this.locStart();
|
|
301
301
|
switch (char) {
|
|
302
|
+
case '\n':
|
|
303
|
+
this.newLine();
|
|
304
|
+
this.needIndent = true;
|
|
305
|
+
break;
|
|
306
|
+
case '=':
|
|
307
|
+
this.assignment();
|
|
308
|
+
break;
|
|
309
|
+
case '|':
|
|
310
|
+
this.pipe();
|
|
311
|
+
break;
|
|
312
|
+
case ';':
|
|
313
|
+
this.setToken(TokenType.Semicolon, ';');
|
|
314
|
+
break;
|
|
302
315
|
case '/':
|
|
303
316
|
this.comment();
|
|
304
317
|
break;
|
|
@@ -323,9 +336,7 @@ class Tokenizer {
|
|
|
323
336
|
}
|
|
324
337
|
break;
|
|
325
338
|
}
|
|
326
|
-
|
|
327
|
-
this.needLoc = false;
|
|
328
|
-
}
|
|
339
|
+
this.locEnd();
|
|
329
340
|
break;
|
|
330
341
|
}
|
|
331
342
|
this.next();
|
|
@@ -341,6 +352,18 @@ class Tokenizer {
|
|
|
341
352
|
this.handledTokens.push(this.token);
|
|
342
353
|
}
|
|
343
354
|
}
|
|
355
|
+
locStart() {
|
|
356
|
+
{
|
|
357
|
+
this.preCol = this.column;
|
|
358
|
+
this.preI = this.i;
|
|
359
|
+
this.needLoc = true;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
locEnd() {
|
|
363
|
+
{
|
|
364
|
+
this.needLoc = false;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
344
367
|
getComment() {
|
|
345
368
|
let value = '/';
|
|
346
369
|
let nextC = this.code[this.i + 1];
|
|
@@ -357,11 +380,7 @@ class Tokenizer {
|
|
|
357
380
|
this.getComment();
|
|
358
381
|
}
|
|
359
382
|
condExp() {
|
|
360
|
-
|
|
361
|
-
this.preCol = this.column;
|
|
362
|
-
this.preI = this.i;
|
|
363
|
-
this.needLoc = true;
|
|
364
|
-
}
|
|
383
|
+
this.locStart();
|
|
365
384
|
let value = '';
|
|
366
385
|
this.token = null;
|
|
367
386
|
let char = this.code[this.i];
|
|
@@ -376,20 +395,14 @@ class Tokenizer {
|
|
|
376
395
|
const trimmed = value.replace(/\/\/[\s\S]+/, '').trim();
|
|
377
396
|
this.setToken(TokenType.Identifier, trimmed ? trimmed : true, 0);
|
|
378
397
|
this.handledTokens.push(this.token);
|
|
379
|
-
|
|
380
|
-
this.needLoc = false;
|
|
381
|
-
}
|
|
398
|
+
this.locEnd();
|
|
382
399
|
return this.token;
|
|
383
400
|
}
|
|
384
401
|
isEol(i) {
|
|
385
402
|
return this.code[i] === '\n' || this.code[i] === '/';
|
|
386
403
|
}
|
|
387
404
|
jsExp() {
|
|
388
|
-
|
|
389
|
-
this.preCol = this.column;
|
|
390
|
-
this.preI = this.i;
|
|
391
|
-
this.needLoc = true;
|
|
392
|
-
}
|
|
405
|
+
this.locStart();
|
|
393
406
|
this.token = null;
|
|
394
407
|
let value = '';
|
|
395
408
|
let char = this.code[this.i];
|
|
@@ -403,9 +416,7 @@ class Tokenizer {
|
|
|
403
416
|
}
|
|
404
417
|
this.setToken(TokenType.Identifier, value, 0);
|
|
405
418
|
this.handledTokens.push(this.token);
|
|
406
|
-
|
|
407
|
-
this.needLoc = false;
|
|
408
|
-
}
|
|
419
|
+
this.locEnd();
|
|
409
420
|
return this.token;
|
|
410
421
|
}
|
|
411
422
|
peekChar() {
|
|
@@ -593,7 +604,7 @@ class Tokenizer {
|
|
|
593
604
|
const prevLen = this.dentStack[this.dentStack.length - 1];
|
|
594
605
|
if (currLen > prevLen) {
|
|
595
606
|
this.dentStack.push(currLen);
|
|
596
|
-
this.setToken(TokenType.Indent, currLen);
|
|
607
|
+
this.setToken(TokenType.Indent, currLen, 0);
|
|
597
608
|
return indentHasLen;
|
|
598
609
|
}
|
|
599
610
|
if (currLen < prevLen) {
|
|
@@ -608,7 +619,7 @@ class Tokenizer {
|
|
|
608
619
|
}
|
|
609
620
|
this.dentStack.pop();
|
|
610
621
|
if (!this.token) {
|
|
611
|
-
this.setToken(TokenType.Dedent, String(expLen));
|
|
622
|
+
this.setToken(TokenType.Dedent, String(expLen), 0);
|
|
612
623
|
} else {
|
|
613
624
|
this.waitingTokens.push({
|
|
614
625
|
type: TokenType.Dedent,
|
|
@@ -1015,7 +1026,7 @@ var NodeType = function (NodeType) {
|
|
|
1015
1026
|
let _initProto;
|
|
1016
1027
|
class Compiler {
|
|
1017
1028
|
static {
|
|
1018
|
-
var _applyDecs$e = _slicedToArray(_applyDecs2311(this, [], [[NodeHook, 2, "parseProgram"], [[NodeHook, NodeLoc], 2, "parseComponentNode"], [[NodeHook, NodeLoc], 2, "parseElementNode"], [[NodeHook, NodeLoc], 2, "parseConditionalNode"], [[NodeHook, NodeLoc], 2, "parseLoopNode"], [NodeHook, 2, "parseProperty"], [[NodeHook, TokenLoc], 2, "parsePropertyKey"], [[NodeHook, TokenLoc], 2, "parseJsExp"], [[NodeHook, TokenLoc], 2, "parsePropertyValue"], [[NodeHook, TokenLoc], 2, "parseName"]]).e, 1);
|
|
1029
|
+
var _applyDecs$e = _slicedToArray(_applyDecs2311(this, [], [[NodeHook, 2, "parseProgram"], [[NodeHook, NodeLoc], 2, "parseComponentNode"], [[NodeHook, NodeLoc], 2, "parseElementNode"], [[NodeHook, NodeLoc], 2, "parseConditionalNode"], [[NodeHook, NodeLoc], 2, "parseLoopNode"], [NodeHook, 2, "parseProperty"], [[NodeHook, TokenLoc], 2, "parsePropertyKey"], [[NodeHook, TokenLoc], 2, "parseJsExp"], [[NodeHook, TokenLoc], 2, "parsePropertyValue"], [[NodeHook, NodeLoc], 2, "parsePropertyInlineFragment"], [[NodeHook, TokenLoc], 2, "parseName"]]).e, 1);
|
|
1019
1030
|
_initProto = _applyDecs$e[0];
|
|
1020
1031
|
}
|
|
1021
1032
|
errors = (_initProto(this), []);
|
|
@@ -1117,9 +1128,9 @@ class Compiler {
|
|
|
1117
1128
|
parseComponentNode(node) {
|
|
1118
1129
|
const name = this.parseName();
|
|
1119
1130
|
this.tokenizer.nextToken();
|
|
1120
|
-
const props = this.headerLineAndExtensions();
|
|
1121
1131
|
node.type = NodeType.Component;
|
|
1122
1132
|
node.componentName = name;
|
|
1133
|
+
const props = this.headerLineAndExtensions();
|
|
1123
1134
|
node.props = props;
|
|
1124
1135
|
this.hooks.parseComponentNode?.propsAdded?.call(this, node);
|
|
1125
1136
|
const children = this.handleChildren();
|
|
@@ -1137,9 +1148,9 @@ class Compiler {
|
|
|
1137
1148
|
}
|
|
1138
1149
|
const tagName = tagToken.value;
|
|
1139
1150
|
this.tokenizer.nextToken();
|
|
1140
|
-
const props = this.headerLineAndExtensions();
|
|
1141
1151
|
node.type = NodeType.Element;
|
|
1142
1152
|
node.tagName = tagName;
|
|
1153
|
+
const props = this.headerLineAndExtensions();
|
|
1143
1154
|
node.props = props;
|
|
1144
1155
|
this.hooks.parseElementNode?.propsAdded?.call(this, node);
|
|
1145
1156
|
const children = this.handleChildren();
|
|
@@ -1213,17 +1224,17 @@ class Compiler {
|
|
|
1213
1224
|
}
|
|
1214
1225
|
headerLineAndExtensions() {
|
|
1215
1226
|
const props = [];
|
|
1216
|
-
|
|
1217
|
-
if (this.tokenizer.token.type & TokenType.NewLine) {
|
|
1218
|
-
this.tokenizer.nextToken();
|
|
1219
|
-
}
|
|
1220
|
-
while (this.tokenizer.token.type & TokenType.Pipe) {
|
|
1221
|
-
this.tokenizer.nextToken();
|
|
1227
|
+
do {
|
|
1222
1228
|
props.push(...this.attributeList());
|
|
1223
1229
|
if (this.tokenizer.token.type & TokenType.NewLine) {
|
|
1224
1230
|
this.tokenizer.nextToken();
|
|
1225
1231
|
}
|
|
1226
|
-
|
|
1232
|
+
if ((this.tokenizer.token.type & TokenType.Pipe) === 0) {
|
|
1233
|
+
break;
|
|
1234
|
+
} else {
|
|
1235
|
+
this.tokenizer.nextToken();
|
|
1236
|
+
}
|
|
1237
|
+
} while (true);
|
|
1227
1238
|
return props;
|
|
1228
1239
|
}
|
|
1229
1240
|
attributeList() {
|
|
@@ -1247,25 +1258,35 @@ class Compiler {
|
|
|
1247
1258
|
const token = this.tokenizer.nextToken();
|
|
1248
1259
|
if (token.value !== '=') {
|
|
1249
1260
|
this.addError(ParseErrorCode.MISSING_ASSIGN, `属性 "${node.key.key}" 缺少 "=" 赋值符号`, node.key.loc ?? this.tokenizer.emptyLoc(), node);
|
|
1250
|
-
|
|
1251
|
-
node.loc.end = node.key.loc.end;
|
|
1252
|
-
node.loc.source = this.tokenizer.code.slice(node.loc.start.offset, node.loc.end.offset);
|
|
1261
|
+
this.handleOnlyKeyLoc(node);
|
|
1253
1262
|
return node;
|
|
1254
1263
|
}
|
|
1255
1264
|
const valueToken = this.tokenizer.nextToken();
|
|
1265
|
+
if (valueToken.type & TokenType.NewLine) {
|
|
1266
|
+
this.tokenizer.nextToken();
|
|
1267
|
+
node.value = this.parsePropertyInlineFragment();
|
|
1268
|
+
this.handleKeyValueLoc(node);
|
|
1269
|
+
return node;
|
|
1270
|
+
}
|
|
1256
1271
|
if ((valueToken.type & ValueTokenType) === 0) {
|
|
1257
1272
|
this.addError(ParseErrorCode.MISSING_PROP_ASSIGNMENT, `属性值不合法, "${valueToken.value}" 不合法`, valueToken.loc ?? this.tokenizer.emptyLoc(), node);
|
|
1258
|
-
|
|
1259
|
-
node.loc.end = node.key.loc.end;
|
|
1260
|
-
node.loc.source = this.tokenizer.code.slice(node.loc.start.offset, node.loc.end.offset);
|
|
1273
|
+
this.handleOnlyKeyLoc(node);
|
|
1261
1274
|
return node;
|
|
1262
1275
|
}
|
|
1263
1276
|
node.value = this.parsePropertyValue();
|
|
1264
1277
|
this.tokenizer.nextToken();
|
|
1278
|
+
this.handleKeyValueLoc(node);
|
|
1279
|
+
return node;
|
|
1280
|
+
}
|
|
1281
|
+
handleOnlyKeyLoc(node) {
|
|
1282
|
+
node.loc.start = node.key.loc.start;
|
|
1283
|
+
node.loc.end = node.key.loc.end;
|
|
1284
|
+
node.loc.source = this.tokenizer.code.slice(node.loc.start.offset, node.loc.end.offset);
|
|
1285
|
+
}
|
|
1286
|
+
handleKeyValueLoc(node) {
|
|
1265
1287
|
node.loc.start = node.key.loc.start;
|
|
1266
1288
|
node.loc.end = node.value.loc.end;
|
|
1267
1289
|
node.loc.source = this.tokenizer.code.slice(node.loc.start.offset, node.loc.end.offset);
|
|
1268
|
-
return node;
|
|
1269
1290
|
}
|
|
1270
1291
|
parsePropertyKey(node) {
|
|
1271
1292
|
node.type = NodeType.PropertyKey;
|
|
@@ -1290,6 +1311,12 @@ class Compiler {
|
|
|
1290
1311
|
node.value = value;
|
|
1291
1312
|
return node;
|
|
1292
1313
|
}
|
|
1314
|
+
parsePropertyInlineFragment(node) {
|
|
1315
|
+
const list = this.handleChildren();
|
|
1316
|
+
node.type = NodeType.StaticValue;
|
|
1317
|
+
node.value = list;
|
|
1318
|
+
return node;
|
|
1319
|
+
}
|
|
1293
1320
|
parseName(node) {
|
|
1294
1321
|
const _this$tokenizer$_hook7 = this.tokenizer._hook({}),
|
|
1295
1322
|
_this$tokenizer$_hook8 = _slicedToArray(_this$tokenizer$_hook7, 2),
|
|
@@ -1513,6 +1540,9 @@ class Interpreter {
|
|
|
1513
1540
|
}
|
|
1514
1541
|
if (sort & NodeSort.TokenizerSwitcher) {
|
|
1515
1542
|
const switcher = stack.peekByType(NodeSort.TokenizerSwitcher)?.node;
|
|
1543
|
+
if (parent.resumeSnapshot) {
|
|
1544
|
+
this.tokenizer.resume(parent.resumeSnapshot);
|
|
1545
|
+
}
|
|
1516
1546
|
this.tokenizer = switcher.tokenizer;
|
|
1517
1547
|
}
|
|
1518
1548
|
if (parent.__logicType === FakeType.ForItem) {
|
|
@@ -1607,7 +1637,7 @@ class Interpreter {
|
|
|
1607
1637
|
} else {
|
|
1608
1638
|
const valueIsMapKey = Reflect.has(data[Keys.Raw], value);
|
|
1609
1639
|
const val = data[Keys.Raw][value];
|
|
1610
|
-
if (typeof val === 'function') {
|
|
1640
|
+
if (typeof val === 'function' || val instanceof InlineFragment) {
|
|
1611
1641
|
_node = this.componentOrFragmentDeclaration(val, ctx);
|
|
1612
1642
|
} else {
|
|
1613
1643
|
const str = valueIsMapKey ? value : this.getFn(data, value);
|
|
@@ -1619,11 +1649,15 @@ class Interpreter {
|
|
|
1619
1649
|
_node = this.createNode(value);
|
|
1620
1650
|
}
|
|
1621
1651
|
this.tokenizer.nextToken();
|
|
1622
|
-
this.
|
|
1623
|
-
this.extensionLines(_node);
|
|
1652
|
+
this.headerLineAndExtensions(_node);
|
|
1624
1653
|
this.onePropParsed = this.oneRealPropParsed;
|
|
1625
1654
|
if (_node.__logicType & TokenizerSwitcherBit) {
|
|
1626
1655
|
this.tokenizer = _node.tokenizer;
|
|
1656
|
+
if (_node.fragmentSnapshot) {
|
|
1657
|
+
this.tokenizer.resume(_node.fragmentSnapshot);
|
|
1658
|
+
this.tokenizer.useDedentAsEof = true;
|
|
1659
|
+
this.tokenizer.initIndentWhenUseDedentAsEof();
|
|
1660
|
+
}
|
|
1627
1661
|
}
|
|
1628
1662
|
return _node;
|
|
1629
1663
|
}
|
|
@@ -1999,16 +2033,25 @@ class Interpreter {
|
|
|
1999
2033
|
}
|
|
2000
2034
|
oneRealPropParsed = this.onePropParsed.bind(this);
|
|
2001
2035
|
componentOrFragmentDeclaration(ComponentOrRender, ctx) {
|
|
2002
|
-
let Component,
|
|
2036
|
+
let Component, tokenizer, child, fragmentSnapshot, resumeSnapshot;
|
|
2003
2037
|
const isCC = ComponentOrRender.prototype instanceof Store;
|
|
2004
2038
|
if (isCC) {
|
|
2005
2039
|
Component = ComponentOrRender;
|
|
2006
2040
|
child = Component.new();
|
|
2041
|
+
tokenizer = child.ui(true);
|
|
2042
|
+
} else if (ComponentOrRender instanceof InlineFragment) {
|
|
2043
|
+
const conf = ComponentOrRender;
|
|
2044
|
+
child = deepSignal({}, getPulling(), true);
|
|
2045
|
+
Object.setPrototypeOf(child, conf.data);
|
|
2046
|
+
tokenizer = conf.tokenizer;
|
|
2047
|
+
fragmentSnapshot = conf.snapshot;
|
|
2048
|
+
resumeSnapshot = tokenizer.snapshot(['token', 'needIndent', 'isFirstToken', 'dentStack', 'isFirstToken', 'useDedentAsEof']);
|
|
2007
2049
|
} else {
|
|
2008
|
-
render = ComponentOrRender;
|
|
2050
|
+
const render = ComponentOrRender;
|
|
2009
2051
|
const boundStore = render.boundStore;
|
|
2010
2052
|
child = deepSignal({}, getPulling(), true);
|
|
2011
2053
|
Object.setPrototypeOf(child, boundStore);
|
|
2054
|
+
tokenizer = render(true);
|
|
2012
2055
|
}
|
|
2013
2056
|
const node = {
|
|
2014
2057
|
__logicType: isCC ? FakeType.Component : FakeType.Fragment,
|
|
@@ -2016,7 +2059,9 @@ class Interpreter {
|
|
|
2016
2059
|
realBefore: null,
|
|
2017
2060
|
realAfter: null,
|
|
2018
2061
|
data: child,
|
|
2019
|
-
tokenizer
|
|
2062
|
+
tokenizer,
|
|
2063
|
+
fragmentSnapshot,
|
|
2064
|
+
resumeSnapshot
|
|
2020
2065
|
};
|
|
2021
2066
|
this.onePropParsed = createStoreOnePropParsed(child);
|
|
2022
2067
|
node.realAfter = this.insertAfterAnchor('component-after');
|
|
@@ -2153,26 +2198,38 @@ class Interpreter {
|
|
|
2153
2198
|
point = next;
|
|
2154
2199
|
}
|
|
2155
2200
|
}
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2201
|
+
headerLineAndExtensions(_node) {
|
|
2202
|
+
const tokenizer = this.tokenizer;
|
|
2203
|
+
do {
|
|
2204
|
+
const isComponent = _node.__logicType & TokenizerSwitcherBit;
|
|
2205
|
+
let snapshot, dentLen;
|
|
2206
|
+
const data = this.getData();
|
|
2207
|
+
const unHandledKey = this.attributeList(_node, data);
|
|
2208
|
+
if (isComponent) {
|
|
2209
|
+
snapshot = tokenizer.snapshot(undefined, -1);
|
|
2210
|
+
dentLen = tokenizer.dentStack[tokenizer.dentStack.length - 1];
|
|
2160
2211
|
}
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2212
|
+
tokenizer.nextToken();
|
|
2213
|
+
if ((tokenizer.token.type & TokenType.Pipe) === 0) {
|
|
2214
|
+
if (isComponent && tokenizer.token.type & TokenType.Indent) {
|
|
2215
|
+
this.inlineFragment(_node, snapshot, data, unHandledKey);
|
|
2216
|
+
tokenizer.skip(dentLen);
|
|
2217
|
+
if ((tokenizer.token.type & TokenType.Pipe) === 0) {
|
|
2218
|
+
break;
|
|
2219
|
+
}
|
|
2220
|
+
} else {
|
|
2221
|
+
break;
|
|
2222
|
+
}
|
|
2165
2223
|
}
|
|
2166
|
-
|
|
2167
|
-
}
|
|
2224
|
+
tokenizer.nextToken();
|
|
2225
|
+
} while (true);
|
|
2168
2226
|
}
|
|
2169
|
-
|
|
2170
|
-
this.
|
|
2171
|
-
this.
|
|
2227
|
+
inlineFragment(_node, snapshot, data, key = 'children') {
|
|
2228
|
+
const value = new InlineFragment(snapshot, data, key, this.tokenizer);
|
|
2229
|
+
this.onePropParsed(data, _node, key, value, false, true);
|
|
2172
2230
|
}
|
|
2173
|
-
attributeList(_node) {
|
|
2231
|
+
attributeList(_node, data) {
|
|
2174
2232
|
let key, eq;
|
|
2175
|
-
const data = this.getData();
|
|
2176
2233
|
while ((this.tokenizer.token.type & TokenType.NewLine) === 0) {
|
|
2177
2234
|
if (key == null) {
|
|
2178
2235
|
key = this.tokenizer.token.value;
|
|
@@ -2220,6 +2277,7 @@ class Interpreter {
|
|
|
2220
2277
|
}
|
|
2221
2278
|
this.tokenizer.nextToken();
|
|
2222
2279
|
}
|
|
2280
|
+
return key;
|
|
2223
2281
|
}
|
|
2224
2282
|
config(opt) {
|
|
2225
2283
|
Object.assign(this, opt);
|
|
@@ -2303,6 +2361,15 @@ function createStoreOnePropParsed(child) {
|
|
|
2303
2361
|
};
|
|
2304
2362
|
return onePropParsed;
|
|
2305
2363
|
}
|
|
2364
|
+
class InlineFragment {
|
|
2365
|
+
[Keys.ProxyFreeObject] = true;
|
|
2366
|
+
constructor(snapshot, data, key, tokenizer) {
|
|
2367
|
+
this.snapshot = snapshot;
|
|
2368
|
+
this.data = data;
|
|
2369
|
+
this.key = key;
|
|
2370
|
+
this.tokenizer = tokenizer;
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2306
2373
|
|
|
2307
2374
|
function bobe(fragments, ...values) {
|
|
2308
2375
|
const ui = function ui(isSub) {
|