vsn 1.0.1 → 1.0.3
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/index.cjs +1864 -716
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -53
- package/dist/index.d.ts +194 -53
- package/dist/index.js +1859 -714
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +8 -8
- package/dist/index.min.js.map +1 -1
- package/dist/plugins/microdata.d.ts +481 -0
- package/dist/plugins/microdata.js +178 -0
- package/dist/plugins/microdata.js.map +1 -0
- package/dist/plugins/microdata.min.js +2 -0
- package/dist/plugins/microdata.min.js.map +1 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,9 @@ declare enum TokenType {
|
|
|
19
19
|
While = "While",
|
|
20
20
|
Try = "Try",
|
|
21
21
|
Catch = "Catch",
|
|
22
|
+
Assert = "Assert",
|
|
23
|
+
Break = "Break",
|
|
24
|
+
Continue = "Continue",
|
|
22
25
|
LBrace = "LBrace",
|
|
23
26
|
RBrace = "RBrace",
|
|
24
27
|
LParen = "LParen",
|
|
@@ -34,7 +37,9 @@ declare enum TokenType {
|
|
|
34
37
|
Greater = "Greater",
|
|
35
38
|
Less = "Less",
|
|
36
39
|
Plus = "Plus",
|
|
40
|
+
PlusPlus = "PlusPlus",
|
|
37
41
|
Minus = "Minus",
|
|
42
|
+
MinusMinus = "MinusMinus",
|
|
38
43
|
Tilde = "Tilde",
|
|
39
44
|
Star = "Star",
|
|
40
45
|
Slash = "Slash",
|
|
@@ -112,17 +117,19 @@ interface ExecutionContext {
|
|
|
112
117
|
element?: Element;
|
|
113
118
|
returnValue?: any;
|
|
114
119
|
returning?: boolean;
|
|
120
|
+
breaking?: boolean;
|
|
121
|
+
continuing?: boolean;
|
|
115
122
|
}
|
|
116
123
|
interface CFSNode {
|
|
117
124
|
type: string;
|
|
118
125
|
prepare(context: ExecutionContext): Promise<void>;
|
|
119
|
-
evaluate(context: ExecutionContext):
|
|
126
|
+
evaluate(context: ExecutionContext): any;
|
|
120
127
|
}
|
|
121
128
|
declare abstract class BaseNode implements CFSNode {
|
|
122
129
|
type: string;
|
|
123
130
|
constructor(type: string);
|
|
124
131
|
prepare(_context: ExecutionContext): Promise<void>;
|
|
125
|
-
evaluate(_context: ExecutionContext):
|
|
132
|
+
evaluate(_context: ExecutionContext): any;
|
|
126
133
|
}
|
|
127
134
|
declare class ProgramNode extends BaseNode {
|
|
128
135
|
behaviors: BehaviorNode[];
|
|
@@ -148,7 +155,7 @@ declare class UseNode extends BaseNode {
|
|
|
148
155
|
declare class BlockNode extends BaseNode {
|
|
149
156
|
statements: CFSNode[];
|
|
150
157
|
constructor(statements: CFSNode[]);
|
|
151
|
-
evaluate(context: ExecutionContext):
|
|
158
|
+
evaluate(context: ExecutionContext): any;
|
|
152
159
|
}
|
|
153
160
|
declare class SelectorNode extends BaseNode {
|
|
154
161
|
selectorText: string;
|
|
@@ -157,51 +164,75 @@ declare class SelectorNode extends BaseNode {
|
|
|
157
164
|
declare class BehaviorNode extends BaseNode {
|
|
158
165
|
selector: SelectorNode;
|
|
159
166
|
body: BlockNode;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
name: string;
|
|
164
|
-
value: ExpressionNode;
|
|
165
|
-
important: boolean;
|
|
166
|
-
constructor(name: string, value: ExpressionNode, important: boolean);
|
|
167
|
-
}
|
|
168
|
-
declare class StateBlockNode extends BaseNode {
|
|
169
|
-
entries: StateEntryNode[];
|
|
170
|
-
constructor(entries: StateEntryNode[]);
|
|
167
|
+
flags: BehaviorFlags;
|
|
168
|
+
flagArgs: BehaviorFlagArgs;
|
|
169
|
+
constructor(selector: SelectorNode, body: BlockNode, flags?: BehaviorFlags, flagArgs?: BehaviorFlagArgs);
|
|
171
170
|
}
|
|
172
171
|
declare class OnBlockNode extends BaseNode {
|
|
173
172
|
eventName: string;
|
|
174
173
|
args: string[];
|
|
175
174
|
body: BlockNode;
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
flags: DeclarationFlags;
|
|
176
|
+
flagArgs: DeclarationFlagArgs;
|
|
177
|
+
constructor(eventName: string, args: string[], body: BlockNode, flags?: DeclarationFlags, flagArgs?: DeclarationFlagArgs);
|
|
178
178
|
}
|
|
179
179
|
declare class AssignmentNode extends BaseNode {
|
|
180
180
|
target: AssignmentTarget;
|
|
181
181
|
value: ExpressionNode;
|
|
182
|
-
operator: "=" | "+=" | "-=" | "*=" | "/=";
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
operator: "=" | "+=" | "-=" | "*=" | "/=" | "++" | "--";
|
|
183
|
+
prefix: boolean;
|
|
184
|
+
constructor(target: AssignmentTarget, value: ExpressionNode, operator?: "=" | "+=" | "-=" | "*=" | "/=" | "++" | "--", prefix?: boolean);
|
|
185
|
+
evaluate(context: ExecutionContext): any;
|
|
185
186
|
private applyCompoundAssignment;
|
|
187
|
+
private applyIncrement;
|
|
188
|
+
private resolveAssignmentTarget;
|
|
189
|
+
private resolveIndexPath;
|
|
190
|
+
private resolveTargetPath;
|
|
186
191
|
private assignTarget;
|
|
192
|
+
private assignDirectiveTarget;
|
|
187
193
|
}
|
|
188
194
|
declare class ReturnNode extends BaseNode {
|
|
189
195
|
value?: ExpressionNode | undefined;
|
|
190
196
|
constructor(value?: ExpressionNode | undefined);
|
|
191
|
-
evaluate(context: ExecutionContext):
|
|
197
|
+
evaluate(context: ExecutionContext): any;
|
|
198
|
+
}
|
|
199
|
+
declare class BreakNode extends BaseNode {
|
|
200
|
+
constructor();
|
|
201
|
+
evaluate(context: ExecutionContext): any;
|
|
202
|
+
}
|
|
203
|
+
declare class ContinueNode extends BaseNode {
|
|
204
|
+
constructor();
|
|
205
|
+
evaluate(context: ExecutionContext): any;
|
|
206
|
+
}
|
|
207
|
+
declare class AssertError extends Error {
|
|
208
|
+
constructor(message?: string);
|
|
209
|
+
}
|
|
210
|
+
declare class AssertNode extends BaseNode {
|
|
211
|
+
test: ExpressionNode;
|
|
212
|
+
constructor(test: ExpressionNode);
|
|
213
|
+
evaluate(context: ExecutionContext): any;
|
|
192
214
|
}
|
|
193
215
|
declare class IfNode extends BaseNode {
|
|
194
216
|
test: ExpressionNode;
|
|
195
217
|
consequent: BlockNode;
|
|
196
218
|
alternate?: BlockNode | undefined;
|
|
197
219
|
constructor(test: ExpressionNode, consequent: BlockNode, alternate?: BlockNode | undefined);
|
|
198
|
-
evaluate(context: ExecutionContext):
|
|
220
|
+
evaluate(context: ExecutionContext): any;
|
|
199
221
|
}
|
|
200
222
|
declare class WhileNode extends BaseNode {
|
|
201
223
|
test: ExpressionNode;
|
|
202
224
|
body: BlockNode;
|
|
203
225
|
constructor(test: ExpressionNode, body: BlockNode);
|
|
204
|
-
evaluate(context: ExecutionContext):
|
|
226
|
+
evaluate(context: ExecutionContext): any;
|
|
227
|
+
}
|
|
228
|
+
declare class ForEachNode extends BaseNode {
|
|
229
|
+
target: IdentifierExpression;
|
|
230
|
+
iterable: ExpressionNode;
|
|
231
|
+
kind: "in" | "of";
|
|
232
|
+
body: BlockNode;
|
|
233
|
+
constructor(target: IdentifierExpression, iterable: ExpressionNode, kind: "in" | "of", body: BlockNode);
|
|
234
|
+
evaluate(context: ExecutionContext): any;
|
|
235
|
+
private getEntries;
|
|
205
236
|
}
|
|
206
237
|
declare class ForNode extends BaseNode {
|
|
207
238
|
init: CFSNode | undefined;
|
|
@@ -209,14 +240,14 @@ declare class ForNode extends BaseNode {
|
|
|
209
240
|
update: CFSNode | undefined;
|
|
210
241
|
body: BlockNode;
|
|
211
242
|
constructor(init: CFSNode | undefined, test: ExpressionNode | undefined, update: CFSNode | undefined, body: BlockNode);
|
|
212
|
-
evaluate(context: ExecutionContext):
|
|
243
|
+
evaluate(context: ExecutionContext): any;
|
|
213
244
|
}
|
|
214
245
|
declare class TryNode extends BaseNode {
|
|
215
246
|
body: BlockNode;
|
|
216
247
|
errorName: string;
|
|
217
248
|
handler: BlockNode;
|
|
218
249
|
constructor(body: BlockNode, errorName: string, handler: BlockNode);
|
|
219
|
-
evaluate(context: ExecutionContext):
|
|
250
|
+
evaluate(context: ExecutionContext): any;
|
|
220
251
|
}
|
|
221
252
|
declare class FunctionDeclarationNode extends BaseNode {
|
|
222
253
|
name: string;
|
|
@@ -230,7 +261,7 @@ declare class FunctionExpression extends BaseNode {
|
|
|
230
261
|
body: BlockNode;
|
|
231
262
|
isAsync: boolean;
|
|
232
263
|
constructor(params: FunctionParam[], body: BlockNode, isAsync?: boolean);
|
|
233
|
-
evaluate(context: ExecutionContext):
|
|
264
|
+
evaluate(context: ExecutionContext): any;
|
|
234
265
|
private applyParams;
|
|
235
266
|
private restoreParams;
|
|
236
267
|
}
|
|
@@ -244,6 +275,12 @@ interface DeclarationFlagArgs {
|
|
|
244
275
|
debounce?: number;
|
|
245
276
|
[key: string]: any;
|
|
246
277
|
}
|
|
278
|
+
interface BehaviorFlags {
|
|
279
|
+
[key: string]: boolean | undefined;
|
|
280
|
+
}
|
|
281
|
+
interface BehaviorFlagArgs {
|
|
282
|
+
[key: string]: any;
|
|
283
|
+
}
|
|
247
284
|
declare class DeclarationNode extends BaseNode {
|
|
248
285
|
target: DeclarationTarget;
|
|
249
286
|
operator: ":" | ":=" | ":<" | ":>";
|
|
@@ -252,9 +289,9 @@ declare class DeclarationNode extends BaseNode {
|
|
|
252
289
|
flagArgs: DeclarationFlagArgs;
|
|
253
290
|
constructor(target: DeclarationTarget, operator: ":" | ":=" | ":<" | ":>", value: ExpressionNode, flags: DeclarationFlags, flagArgs: DeclarationFlagArgs);
|
|
254
291
|
}
|
|
255
|
-
type ExpressionNode = IdentifierExpression | LiteralExpression | TemplateExpression | UnaryExpression | BinaryExpression | MemberExpression | CallExpression | ArrayExpression | ObjectExpression | IndexExpression | FunctionExpression | AwaitExpression | TernaryExpression | DirectiveExpression | QueryExpression;
|
|
292
|
+
type ExpressionNode = AssignmentNode | IdentifierExpression | LiteralExpression | TemplateExpression | UnaryExpression | BinaryExpression | MemberExpression | CallExpression | ArrayExpression | ObjectExpression | IndexExpression | FunctionExpression | AwaitExpression | TernaryExpression | DirectiveExpression | QueryExpression;
|
|
256
293
|
type DeclarationTarget = IdentifierExpression | DirectiveExpression;
|
|
257
|
-
type AssignmentTarget = IdentifierExpression | DirectiveExpression | ArrayPattern | ObjectPattern;
|
|
294
|
+
type AssignmentTarget = IdentifierExpression | MemberExpression | IndexExpression | DirectiveExpression | ArrayPattern | ObjectPattern;
|
|
258
295
|
type FunctionParam = {
|
|
259
296
|
name: string;
|
|
260
297
|
defaultValue?: ExpressionNode;
|
|
@@ -264,7 +301,7 @@ type PatternNode = IdentifierExpression | ArrayPattern | ObjectPattern;
|
|
|
264
301
|
declare class IdentifierExpression extends BaseNode {
|
|
265
302
|
name: string;
|
|
266
303
|
constructor(name: string);
|
|
267
|
-
evaluate(context: ExecutionContext):
|
|
304
|
+
evaluate(context: ExecutionContext): any;
|
|
268
305
|
}
|
|
269
306
|
declare class SpreadElement extends BaseNode {
|
|
270
307
|
value: ExpressionNode;
|
|
@@ -292,40 +329,44 @@ declare class ObjectPattern extends BaseNode {
|
|
|
292
329
|
declare class LiteralExpression extends BaseNode {
|
|
293
330
|
value: string | number | boolean | null;
|
|
294
331
|
constructor(value: string | number | boolean | null);
|
|
295
|
-
evaluate():
|
|
332
|
+
evaluate(): any;
|
|
296
333
|
}
|
|
297
334
|
declare class TemplateExpression extends BaseNode {
|
|
298
335
|
parts: ExpressionNode[];
|
|
299
336
|
constructor(parts: ExpressionNode[]);
|
|
300
|
-
evaluate(context: ExecutionContext):
|
|
337
|
+
evaluate(context: ExecutionContext): any;
|
|
301
338
|
}
|
|
302
339
|
declare class UnaryExpression extends BaseNode {
|
|
303
340
|
operator: string;
|
|
304
341
|
argument: ExpressionNode;
|
|
305
342
|
constructor(operator: string, argument: ExpressionNode);
|
|
306
|
-
evaluate(context: ExecutionContext):
|
|
343
|
+
evaluate(context: ExecutionContext): any;
|
|
307
344
|
}
|
|
308
345
|
declare class BinaryExpression extends BaseNode {
|
|
309
346
|
operator: string;
|
|
310
347
|
left: ExpressionNode;
|
|
311
348
|
right: ExpressionNode;
|
|
312
349
|
constructor(operator: string, left: ExpressionNode, right: ExpressionNode);
|
|
313
|
-
evaluate(context: ExecutionContext):
|
|
350
|
+
evaluate(context: ExecutionContext): any;
|
|
314
351
|
}
|
|
315
352
|
declare class TernaryExpression extends BaseNode {
|
|
316
353
|
test: ExpressionNode;
|
|
317
354
|
consequent: ExpressionNode;
|
|
318
355
|
alternate: ExpressionNode;
|
|
319
356
|
constructor(test: ExpressionNode, consequent: ExpressionNode, alternate: ExpressionNode);
|
|
320
|
-
evaluate(context: ExecutionContext):
|
|
357
|
+
evaluate(context: ExecutionContext): any;
|
|
321
358
|
}
|
|
322
359
|
declare class MemberExpression extends BaseNode {
|
|
323
360
|
target: ExpressionNode;
|
|
324
361
|
property: string;
|
|
325
362
|
optional: boolean;
|
|
326
363
|
constructor(target: ExpressionNode, property: string, optional?: boolean);
|
|
327
|
-
evaluate(context: ExecutionContext):
|
|
328
|
-
resolve(context: ExecutionContext):
|
|
364
|
+
evaluate(context: ExecutionContext): any;
|
|
365
|
+
resolve(context: ExecutionContext): {
|
|
366
|
+
value: any;
|
|
367
|
+
target?: any;
|
|
368
|
+
optional?: boolean;
|
|
369
|
+
} | undefined | Promise<{
|
|
329
370
|
value: any;
|
|
330
371
|
target?: any;
|
|
331
372
|
optional?: boolean;
|
|
@@ -343,14 +384,14 @@ declare class CallExpression extends BaseNode {
|
|
|
343
384
|
callee: ExpressionNode;
|
|
344
385
|
args: ExpressionNode[];
|
|
345
386
|
constructor(callee: ExpressionNode, args: ExpressionNode[]);
|
|
346
|
-
evaluate(context: ExecutionContext):
|
|
387
|
+
evaluate(context: ExecutionContext): any;
|
|
347
388
|
private resolveCallee;
|
|
348
389
|
}
|
|
349
390
|
type ArrayElement = ExpressionNode | SpreadElement;
|
|
350
391
|
declare class ArrayExpression extends BaseNode {
|
|
351
392
|
elements: ArrayElement[];
|
|
352
393
|
constructor(elements: ArrayElement[]);
|
|
353
|
-
evaluate(context: ExecutionContext):
|
|
394
|
+
evaluate(context: ExecutionContext): any;
|
|
354
395
|
}
|
|
355
396
|
type ObjectEntry = {
|
|
356
397
|
key: string;
|
|
@@ -366,46 +407,51 @@ type ObjectEntry = {
|
|
|
366
407
|
declare class ObjectExpression extends BaseNode {
|
|
367
408
|
entries: ObjectEntry[];
|
|
368
409
|
constructor(entries: ObjectEntry[]);
|
|
369
|
-
evaluate(context: ExecutionContext):
|
|
410
|
+
evaluate(context: ExecutionContext): any;
|
|
370
411
|
}
|
|
371
412
|
declare class IndexExpression extends BaseNode {
|
|
372
413
|
target: ExpressionNode;
|
|
373
414
|
index: ExpressionNode;
|
|
374
415
|
constructor(target: ExpressionNode, index: ExpressionNode);
|
|
375
|
-
evaluate(context: ExecutionContext):
|
|
416
|
+
evaluate(context: ExecutionContext): any;
|
|
417
|
+
private normalizeIndexKey;
|
|
376
418
|
}
|
|
377
419
|
declare class DirectiveExpression extends BaseNode {
|
|
378
420
|
kind: "attr" | "style";
|
|
379
421
|
name: string;
|
|
380
422
|
constructor(kind: "attr" | "style", name: string);
|
|
381
|
-
evaluate(context: ExecutionContext):
|
|
423
|
+
evaluate(context: ExecutionContext): any;
|
|
382
424
|
}
|
|
383
425
|
declare class AwaitExpression extends BaseNode {
|
|
384
426
|
argument: ExpressionNode;
|
|
385
427
|
constructor(argument: ExpressionNode);
|
|
386
|
-
evaluate(context: ExecutionContext):
|
|
428
|
+
evaluate(context: ExecutionContext): any;
|
|
387
429
|
}
|
|
388
430
|
declare class QueryExpression extends BaseNode {
|
|
389
431
|
direction: "self" | "descendant" | "ancestor";
|
|
390
432
|
selector: string;
|
|
391
433
|
constructor(direction: "self" | "descendant" | "ancestor", selector: string);
|
|
392
|
-
evaluate(context: ExecutionContext):
|
|
434
|
+
evaluate(context: ExecutionContext): any;
|
|
393
435
|
}
|
|
394
436
|
|
|
395
437
|
declare class Parser {
|
|
396
438
|
private stream;
|
|
397
439
|
private source;
|
|
398
440
|
private customFlags;
|
|
441
|
+
private behaviorFlags;
|
|
399
442
|
private allowImplicitSemicolon;
|
|
400
443
|
private awaitStack;
|
|
444
|
+
private functionDepth;
|
|
401
445
|
constructor(input: string, options?: {
|
|
402
446
|
customFlags?: Set<string>;
|
|
447
|
+
behaviorFlags?: Set<string>;
|
|
403
448
|
});
|
|
404
449
|
static parseInline(code: string): BlockNode;
|
|
405
450
|
parseProgram(): ProgramNode;
|
|
406
451
|
parseInlineBlock(): BlockNode;
|
|
407
452
|
private parseBehavior;
|
|
408
453
|
private parseSelector;
|
|
454
|
+
private parseBehaviorFlags;
|
|
409
455
|
private parseUseStatement;
|
|
410
456
|
private parseUseFlags;
|
|
411
457
|
private wrapErrors;
|
|
@@ -413,9 +459,7 @@ declare class Parser {
|
|
|
413
459
|
private getLineSnippet;
|
|
414
460
|
private parseBlock;
|
|
415
461
|
private parseStatement;
|
|
416
|
-
private parseStateBlock;
|
|
417
462
|
private parseOnBlock;
|
|
418
|
-
private parseOnModifiers;
|
|
419
463
|
private parseAssignment;
|
|
420
464
|
private parseExpression;
|
|
421
465
|
private parsePipeExpression;
|
|
@@ -429,6 +473,8 @@ declare class Parser {
|
|
|
429
473
|
private parseMultiplicativeExpression;
|
|
430
474
|
private parseAdditiveExpression;
|
|
431
475
|
private parseUnaryExpression;
|
|
476
|
+
private parsePostfixExpression;
|
|
477
|
+
private createIncrementNode;
|
|
432
478
|
private parseCallExpression;
|
|
433
479
|
private parsePrimaryExpression;
|
|
434
480
|
private parseArrayExpression;
|
|
@@ -447,10 +493,12 @@ declare class Parser {
|
|
|
447
493
|
private parseDeclarationOperator;
|
|
448
494
|
private parseFlags;
|
|
449
495
|
private parseCustomFlagArg;
|
|
496
|
+
private parseCustomFlagLiteral;
|
|
497
|
+
private parseCustomFlagArray;
|
|
498
|
+
private parseCustomFlagObject;
|
|
450
499
|
private isDeclarationStart;
|
|
451
500
|
private isAssignmentStart;
|
|
452
501
|
private isAssignmentOperatorStart;
|
|
453
|
-
private isCallStart;
|
|
454
502
|
private isExpressionStatementStart;
|
|
455
503
|
private isFunctionDeclarationStart;
|
|
456
504
|
private isArrowFunctionStart;
|
|
@@ -458,8 +506,11 @@ declare class Parser {
|
|
|
458
506
|
private isFunctionExpressionAssignmentStart;
|
|
459
507
|
private parseExpressionStatement;
|
|
460
508
|
private parseIfBlock;
|
|
509
|
+
private parseConditionalBody;
|
|
461
510
|
private parseWhileBlock;
|
|
462
511
|
private parseForBlock;
|
|
512
|
+
private detectForEachKind;
|
|
513
|
+
private parseForEachTarget;
|
|
463
514
|
private parseForClause;
|
|
464
515
|
private parseAssignmentExpression;
|
|
465
516
|
private parseAssignmentOperator;
|
|
@@ -468,8 +519,10 @@ declare class Parser {
|
|
|
468
519
|
private parseDestructBlock;
|
|
469
520
|
private parseQueryExpression;
|
|
470
521
|
private parseFunctionDeclaration;
|
|
471
|
-
private parseFunctionBlock;
|
|
472
522
|
private parseReturnStatement;
|
|
523
|
+
private parseAssertStatement;
|
|
524
|
+
private parseBreakStatement;
|
|
525
|
+
private parseContinueStatement;
|
|
473
526
|
private parseArrowFunctionExpression;
|
|
474
527
|
private parseFunctionParams;
|
|
475
528
|
private readSelectorUntil;
|
|
@@ -482,6 +535,7 @@ declare class Scope {
|
|
|
482
535
|
private root;
|
|
483
536
|
private listeners;
|
|
484
537
|
private anyListeners;
|
|
538
|
+
isEachItem: boolean;
|
|
485
539
|
constructor(parent?: Scope | undefined);
|
|
486
540
|
createChild(): Scope;
|
|
487
541
|
get(key: string): any;
|
|
@@ -499,6 +553,33 @@ declare class Scope {
|
|
|
499
553
|
private findNearestScopeWithKey;
|
|
500
554
|
}
|
|
501
555
|
|
|
556
|
+
interface RegisteredBehavior {
|
|
557
|
+
id: number;
|
|
558
|
+
hash: string;
|
|
559
|
+
selector: string;
|
|
560
|
+
rootSelector: string;
|
|
561
|
+
parentSelector?: string;
|
|
562
|
+
specificity: number;
|
|
563
|
+
order: number;
|
|
564
|
+
construct?: BlockNode;
|
|
565
|
+
destruct?: BlockNode;
|
|
566
|
+
onBlocks: {
|
|
567
|
+
event: string;
|
|
568
|
+
body: BlockNode;
|
|
569
|
+
flags: DeclarationFlags;
|
|
570
|
+
flagArgs: DeclarationFlagArgs;
|
|
571
|
+
args: string[];
|
|
572
|
+
}[];
|
|
573
|
+
declarations: DeclarationNode[];
|
|
574
|
+
functions: FunctionBinding[];
|
|
575
|
+
flags: BehaviorFlags;
|
|
576
|
+
flagArgs: BehaviorFlagArgs;
|
|
577
|
+
}
|
|
578
|
+
type FunctionBinding = {
|
|
579
|
+
name: string;
|
|
580
|
+
params: FunctionParam[];
|
|
581
|
+
body: BlockNode;
|
|
582
|
+
};
|
|
502
583
|
type AttributeHandler = {
|
|
503
584
|
id: string;
|
|
504
585
|
match: (name: string) => boolean;
|
|
@@ -513,6 +594,40 @@ type FlagApplyContext = {
|
|
|
513
594
|
};
|
|
514
595
|
type FlagHandler = {
|
|
515
596
|
onApply?: (context: FlagApplyContext) => void;
|
|
597
|
+
transformValue?: (context: FlagApplyContext, value: any) => any;
|
|
598
|
+
onEventBind?: (context: EventFlagContext) => EventBindPatch | void;
|
|
599
|
+
onEventBefore?: (context: EventFlagContext) => boolean | void;
|
|
600
|
+
onEventAfter?: (context: EventFlagContext) => void;
|
|
601
|
+
transformEventArgs?: (context: EventFlagContext, args: any[]) => any[];
|
|
602
|
+
};
|
|
603
|
+
type BehaviorModifierHandler = {
|
|
604
|
+
onBind?: (context: BehaviorModifierContext) => void | Promise<void>;
|
|
605
|
+
onConstruct?: (context: BehaviorModifierContext) => void | Promise<void>;
|
|
606
|
+
onDestruct?: (context: BehaviorModifierContext) => void | Promise<void>;
|
|
607
|
+
onUnbind?: (context: BehaviorModifierContext) => void | Promise<void>;
|
|
608
|
+
};
|
|
609
|
+
type BehaviorModifierContext = {
|
|
610
|
+
name: string;
|
|
611
|
+
args: any;
|
|
612
|
+
element: Element;
|
|
613
|
+
scope: Scope;
|
|
614
|
+
rootScope: Scope | undefined;
|
|
615
|
+
behavior: RegisteredBehavior;
|
|
616
|
+
engine: Engine;
|
|
617
|
+
};
|
|
618
|
+
type EventBindPatch = {
|
|
619
|
+
listenerTarget?: EventTarget;
|
|
620
|
+
options?: AddEventListenerOptions;
|
|
621
|
+
debounceMs?: number;
|
|
622
|
+
};
|
|
623
|
+
type EventFlagContext = {
|
|
624
|
+
name: string;
|
|
625
|
+
args: any;
|
|
626
|
+
element: Element;
|
|
627
|
+
scope: Scope;
|
|
628
|
+
rootScope: Scope | undefined;
|
|
629
|
+
event: Event | undefined;
|
|
630
|
+
engine: Engine;
|
|
516
631
|
};
|
|
517
632
|
type EngineOptions = {
|
|
518
633
|
diagnostics?: boolean;
|
|
@@ -529,18 +644,19 @@ declare class Engine {
|
|
|
529
644
|
private eachBindings;
|
|
530
645
|
private lifecycleBindings;
|
|
531
646
|
private behaviorRegistry;
|
|
647
|
+
private behaviorRegistryHashes;
|
|
532
648
|
private behaviorBindings;
|
|
533
649
|
private behaviorListeners;
|
|
534
650
|
private behaviorId;
|
|
535
651
|
private codeCache;
|
|
536
652
|
private behaviorCache;
|
|
537
653
|
private observer;
|
|
538
|
-
private observerRoot;
|
|
539
654
|
private attributeHandlers;
|
|
540
655
|
private globals;
|
|
541
656
|
private importantFlags;
|
|
542
657
|
private inlineDeclarations;
|
|
543
658
|
private flagHandlers;
|
|
659
|
+
private behaviorModifiers;
|
|
544
660
|
private pendingAdded;
|
|
545
661
|
private pendingRemoved;
|
|
546
662
|
private pendingUpdated;
|
|
@@ -549,13 +665,20 @@ declare class Engine {
|
|
|
549
665
|
private diagnostics;
|
|
550
666
|
private logger;
|
|
551
667
|
private pendingUses;
|
|
668
|
+
private pendingAutoBindToScope;
|
|
669
|
+
private scopeWatchers;
|
|
670
|
+
private executionStack;
|
|
671
|
+
private groupProxyCache;
|
|
552
672
|
constructor(options?: EngineOptions);
|
|
673
|
+
private getGroupTargetScope;
|
|
674
|
+
private getGroupProxy;
|
|
553
675
|
mount(root: HTMLElement): Promise<void>;
|
|
554
676
|
unmount(element: Element): void;
|
|
555
677
|
registerBehaviors(source: string): void;
|
|
556
678
|
registerGlobal(name: string, value: any): void;
|
|
557
679
|
registerGlobals(values: Record<string, any>): void;
|
|
558
680
|
registerFlag(name: string, handler?: FlagHandler): void;
|
|
681
|
+
registerBehaviorModifier(name: string, handler?: BehaviorModifierHandler): void;
|
|
559
682
|
getRegistryStats(): {
|
|
560
683
|
behaviorCount: number;
|
|
561
684
|
behaviorCacheSize: number;
|
|
@@ -585,6 +708,14 @@ declare class Engine {
|
|
|
585
708
|
private renderEach;
|
|
586
709
|
private attachBindInputHandler;
|
|
587
710
|
private parseBindDirection;
|
|
711
|
+
private resolveBindConfig;
|
|
712
|
+
private isFormControl;
|
|
713
|
+
private hasScopeValue;
|
|
714
|
+
private hasElementValue;
|
|
715
|
+
private coerceInt;
|
|
716
|
+
private coerceFloat;
|
|
717
|
+
private isInEachScope;
|
|
718
|
+
private flushAutoBindQueue;
|
|
588
719
|
private hasVsnAttributes;
|
|
589
720
|
private markInlineDeclaration;
|
|
590
721
|
private isInlineDeclaration;
|
|
@@ -592,10 +723,12 @@ declare class Engine {
|
|
|
592
723
|
private watch;
|
|
593
724
|
private watchWithDebounce;
|
|
594
725
|
private watchAllScopes;
|
|
726
|
+
private trackScopeWatcher;
|
|
727
|
+
private cleanupScopeWatchers;
|
|
728
|
+
private cleanupBehaviorListeners;
|
|
595
729
|
private parseOnAttribute;
|
|
596
|
-
private
|
|
597
|
-
private
|
|
598
|
-
private matchesTargetModifiers;
|
|
730
|
+
private parseInlineFlags;
|
|
731
|
+
private parseInlineFlagArg;
|
|
599
732
|
private describeElement;
|
|
600
733
|
private logDiagnostic;
|
|
601
734
|
private emitError;
|
|
@@ -603,8 +736,13 @@ declare class Engine {
|
|
|
603
736
|
private attachOnHandler;
|
|
604
737
|
private attachBehaviorOnHandler;
|
|
605
738
|
private attachGetHandler;
|
|
606
|
-
private
|
|
607
|
-
private
|
|
739
|
+
private getEventBindingConfig;
|
|
740
|
+
private applyEventFlagBefore;
|
|
741
|
+
private applyEventFlagAfter;
|
|
742
|
+
private applyEventFlagArgTransforms;
|
|
743
|
+
private matchesKeyFlag;
|
|
744
|
+
private withExecutionElement;
|
|
745
|
+
getCurrentElement(): Element | undefined;
|
|
608
746
|
private execute;
|
|
609
747
|
private executeBlock;
|
|
610
748
|
private safeExecute;
|
|
@@ -631,6 +769,9 @@ declare class Engine {
|
|
|
631
769
|
private applyBehaviorDeclarations;
|
|
632
770
|
private applyBehaviorDeclaration;
|
|
633
771
|
private applyCustomFlags;
|
|
772
|
+
private applyCustomFlagTransforms;
|
|
773
|
+
private applyBehaviorModifierHook;
|
|
774
|
+
private behaviorHasModifierHooks;
|
|
634
775
|
private applyDirectiveFromScope;
|
|
635
776
|
private applyDirectiveFromExpression;
|
|
636
777
|
private applyDirectiveToScope;
|
|
@@ -647,4 +788,4 @@ declare const VERSION = "0.1.0";
|
|
|
647
788
|
declare function parseCFS(source: string): ProgramNode;
|
|
648
789
|
declare function autoMount(root?: HTMLElement | Document): Engine | null;
|
|
649
790
|
|
|
650
|
-
export { type ArrayElement, ArrayExpression, ArrayPattern, type ArrayPatternElement, AssignmentNode, type AssignmentTarget, AwaitExpression, BaseNode, BehaviorNode, BinaryExpression, BlockNode, type CFSNode, CallExpression, type DeclarationFlagArgs, type DeclarationFlags, DeclarationNode, type DeclarationTarget, DirectiveExpression, Engine, type ExecutionContext, type ExpressionNode, ForNode, FunctionDeclarationNode, FunctionExpression, type FunctionParam, IdentifierExpression, IfNode, IndexExpression, Lexer, LiteralExpression, MemberExpression, type ObjectEntry, ObjectExpression, ObjectPattern, type ObjectPatternEntry, OnBlockNode, Parser, type PatternNode, ProgramNode, QueryExpression, RestElement, ReturnNode, SelectorNode, SpreadElement,
|
|
791
|
+
export { type ArrayElement, ArrayExpression, ArrayPattern, type ArrayPatternElement, AssertError, AssertNode, AssignmentNode, type AssignmentTarget, AwaitExpression, BaseNode, type BehaviorFlagArgs, type BehaviorFlags, BehaviorNode, BinaryExpression, BlockNode, BreakNode, type CFSNode, CallExpression, ContinueNode, type DeclarationFlagArgs, type DeclarationFlags, DeclarationNode, type DeclarationTarget, DirectiveExpression, Engine, type ExecutionContext, type ExpressionNode, ForEachNode, ForNode, FunctionDeclarationNode, FunctionExpression, type FunctionParam, IdentifierExpression, IfNode, IndexExpression, Lexer, LiteralExpression, MemberExpression, type ObjectEntry, ObjectExpression, ObjectPattern, type ObjectPatternEntry, OnBlockNode, Parser, type PatternNode, ProgramNode, QueryExpression, RestElement, ReturnNode, SelectorNode, SpreadElement, TemplateExpression, TernaryExpression, TokenType, TryNode, UnaryExpression, type UseFlagArgs, type UseFlags, UseNode, VERSION, WhileNode, autoMount, parseCFS };
|