@barefootjs/jsx 0.18.4 → 0.18.5
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/adapters/parsed-expr-emitter.d.ts +2 -2
- package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
- package/dist/expression-parser.d.ts +2 -1
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/index.js +141 -44
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-event-delegation.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/event-delegation.d.ts +10 -0
- package/dist/ir-to-client-js/control-flow/plan/event-delegation.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/event-delegation.d.ts.map +1 -1
- package/dist/ir-to-client-js/csr-substitute.d.ts +1 -0
- package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +9 -0
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +25 -0
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/types.d.ts +66 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/event-delegation-index-param.test.ts +130 -0
- package/src/__tests__/expression-parser.test.ts +38 -0
- package/src/__tests__/ir-walker.test.ts +1 -0
- package/src/__tests__/materialize-getter-calls.test.ts +1 -0
- package/src/adapters/parsed-expr-emitter.ts +10 -1
- package/src/expression-parser.ts +59 -25
- package/src/ir-to-client-js/collect-elements.ts +3 -0
- package/src/ir-to-client-js/control-flow/plan/build-event-delegation.ts +6 -0
- package/src/ir-to-client-js/control-flow/plan/event-delegation.ts +10 -0
- package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +31 -7
- package/src/ir-to-client-js/csr-substitute.ts +1 -1
- package/src/ir-to-client-js/html-template.ts +57 -11
- package/src/ir-to-client-js/types.ts +10 -0
- package/src/ir-to-client-js/utils.ts +34 -1
- package/src/jsx-to-ir.ts +92 -9
- package/src/types.ts +68 -0
package/dist/index.js
CHANGED
|
@@ -206,7 +206,6 @@ var UNSUPPORTED_METHODS = new Set([
|
|
|
206
206
|
"some",
|
|
207
207
|
"forEach",
|
|
208
208
|
"flatMap",
|
|
209
|
-
"replaceAll",
|
|
210
209
|
"charAt",
|
|
211
210
|
"charCodeAt",
|
|
212
211
|
"codePointAt",
|
|
@@ -481,6 +480,9 @@ function convertNode(node, raw) {
|
|
|
481
480
|
if (callee.property === "trim") {
|
|
482
481
|
return { kind: "array-method", method: "trim", object: callee.object, args };
|
|
483
482
|
}
|
|
483
|
+
if (callee.property === "trimStart" || callee.property === "trimEnd") {
|
|
484
|
+
return { kind: "array-method", method: callee.property, object: callee.object, args };
|
|
485
|
+
}
|
|
484
486
|
if (callee.property === "toFixed") {
|
|
485
487
|
return { kind: "array-method", method: "toFixed", object: callee.object, args };
|
|
486
488
|
}
|
|
@@ -506,24 +508,25 @@ function convertNode(node, raw) {
|
|
|
506
508
|
}
|
|
507
509
|
return { kind: "array-method", method: callee.property, object: callee.object, args };
|
|
508
510
|
}
|
|
509
|
-
if (callee.property === "replace") {
|
|
511
|
+
if (callee.property === "replace" || callee.property === "replaceAll") {
|
|
512
|
+
const method = callee.property;
|
|
510
513
|
if (args.length < 2) {
|
|
511
514
|
return {
|
|
512
515
|
kind: "unsupported",
|
|
513
516
|
raw,
|
|
514
|
-
reason:
|
|
517
|
+
reason: `\`.${method}(${args.length === 0 ? "" : "pattern"})\` needs both a pattern and a replacement — JS coerces the missing argument to the string "undefined", a degenerate result. Pass both arguments, or pre-compute the value before the template.`
|
|
515
518
|
};
|
|
516
519
|
}
|
|
517
520
|
const patternNode = node.arguments[0];
|
|
518
521
|
if (patternNode && ts2.isRegularExpressionLiteral(patternNode)) {
|
|
519
|
-
return { kind: "array-method", method
|
|
522
|
+
return { kind: "array-method", method, object: callee.object, args };
|
|
520
523
|
}
|
|
521
524
|
const badArg = args[0].kind === "unsupported" || args[0].kind === "object-literal" ? args[0] : args[1].kind === "unsupported" || args[1].kind === "object-literal" ? args[1] : undefined;
|
|
522
525
|
if (badArg) {
|
|
523
526
|
const reason = badArg.kind === "unsupported" ? badArg.reason : "Unsupported syntax: ObjectLiteralExpression";
|
|
524
527
|
return { kind: "unsupported", raw, reason };
|
|
525
528
|
}
|
|
526
|
-
return { kind: "array-method", method
|
|
529
|
+
return { kind: "array-method", method, object: callee.object, args };
|
|
527
530
|
}
|
|
528
531
|
if (callee.property === "repeat") {
|
|
529
532
|
return { kind: "array-method", method: "repeat", object: callee.object, args };
|
|
@@ -558,7 +561,7 @@ function convertNode(node, raw) {
|
|
|
558
561
|
if (ts2.isPropertyAccessExpression(node)) {
|
|
559
562
|
const object = convertNode(node.expression, raw);
|
|
560
563
|
const property = node.name.text;
|
|
561
|
-
return { kind: "member", object, property, computed: false };
|
|
564
|
+
return { kind: "member", object, property, computed: false, optional: !!node.questionDotToken };
|
|
562
565
|
}
|
|
563
566
|
if (ts2.isElementAccessExpression(node)) {
|
|
564
567
|
const object = convertNode(node.expression, raw);
|
|
@@ -567,10 +570,10 @@ function convertNode(node, raw) {
|
|
|
567
570
|
return { kind: "unsupported", raw, reason: "Element access with no index expression" };
|
|
568
571
|
}
|
|
569
572
|
if (ts2.isNumericLiteral(argNode)) {
|
|
570
|
-
return { kind: "member", object, property: argNode.text, computed: true };
|
|
573
|
+
return { kind: "member", object, property: argNode.text, computed: true, optional: !!node.questionDotToken };
|
|
571
574
|
}
|
|
572
575
|
if (ts2.isStringLiteral(argNode)) {
|
|
573
|
-
return { kind: "member", object, property: argNode.text, computed: true };
|
|
576
|
+
return { kind: "member", object, property: argNode.text, computed: true, optional: !!node.questionDotToken };
|
|
574
577
|
}
|
|
575
578
|
const index = convertNode(argNode, raw);
|
|
576
579
|
if (index.kind === "unsupported" || index.kind === "object-literal")
|
|
@@ -1121,7 +1124,7 @@ function substituteDestructuredFields(expr, fieldMap, syntheticParam, restName)
|
|
|
1121
1124
|
return e;
|
|
1122
1125
|
let node = { kind: "identifier", name: syntheticParam };
|
|
1123
1126
|
for (const segment of entry.path) {
|
|
1124
|
-
node = { kind: "member", object: node, property: segment, computed: false };
|
|
1127
|
+
node = { kind: "member", object: node, property: segment, computed: false, optional: false };
|
|
1125
1128
|
}
|
|
1126
1129
|
if (entry.defaultExpr) {
|
|
1127
1130
|
return { kind: "logical", op: "??", left: node, right: entry.defaultExpr };
|
|
@@ -1136,10 +1139,11 @@ function substituteDestructuredFields(expr, fieldMap, syntheticParam, restName)
|
|
|
1136
1139
|
kind: "member",
|
|
1137
1140
|
object: { kind: "identifier", name: syntheticParam },
|
|
1138
1141
|
property: e.property,
|
|
1139
|
-
computed: false
|
|
1142
|
+
computed: false,
|
|
1143
|
+
optional: e.optional
|
|
1140
1144
|
};
|
|
1141
1145
|
}
|
|
1142
|
-
return { kind: "member", object: walk(e.object), property: e.property, computed: e.computed };
|
|
1146
|
+
return { kind: "member", object: walk(e.object), property: e.property, computed: e.computed, optional: e.optional };
|
|
1143
1147
|
case "index-access":
|
|
1144
1148
|
return { kind: "index-access", object: walk(e.object), index: walk(e.index) };
|
|
1145
1149
|
case "binary":
|
|
@@ -1251,10 +1255,10 @@ function checkSupport(expr) {
|
|
|
1251
1255
|
return { supported: true, level: "L2" };
|
|
1252
1256
|
}
|
|
1253
1257
|
case "array-method": {
|
|
1254
|
-
if (expr.method === "replace" && expr.args[0]?.kind === "regex") {
|
|
1258
|
+
if ((expr.method === "replace" || expr.method === "replaceAll") && expr.args[0]?.kind === "regex") {
|
|
1255
1259
|
return {
|
|
1256
1260
|
supported: false,
|
|
1257
|
-
reason:
|
|
1261
|
+
reason: `String.prototype.${expr.method} supports only a string pattern + string replacement (the regex form is deferred); use a string pattern or wrap the expression in /* @client */`
|
|
1258
1262
|
};
|
|
1259
1263
|
}
|
|
1260
1264
|
const objSupport = checkSupport(expr.object);
|
|
@@ -1628,7 +1632,7 @@ function inlineBinding(expr, name, value) {
|
|
|
1628
1632
|
case "call":
|
|
1629
1633
|
return { kind: "call", callee: walk(e.callee, enclosing), args: e.args.map((a) => walk(a, enclosing)) };
|
|
1630
1634
|
case "member":
|
|
1631
|
-
return { kind: "member", object: walk(e.object, enclosing), property: e.property, computed: e.computed };
|
|
1635
|
+
return { kind: "member", object: walk(e.object, enclosing), property: e.property, computed: e.computed, optional: e.optional };
|
|
1632
1636
|
case "index-access":
|
|
1633
1637
|
return { kind: "index-access", object: walk(e.object, enclosing), index: walk(e.index, enclosing) };
|
|
1634
1638
|
case "binary":
|
|
@@ -1879,7 +1883,7 @@ function materializeGetterCalls(expr, names) {
|
|
|
1879
1883
|
alternate: rw(expr.alternate)
|
|
1880
1884
|
};
|
|
1881
1885
|
case "member":
|
|
1882
|
-
return { kind: "member", object: rw(expr.object), property: expr.property, computed: expr.computed };
|
|
1886
|
+
return { kind: "member", object: rw(expr.object), property: expr.property, computed: expr.computed, optional: expr.optional };
|
|
1883
1887
|
case "index-access":
|
|
1884
1888
|
return { kind: "index-access", object: rw(expr.object), index: rw(expr.index) };
|
|
1885
1889
|
case "template-literal":
|
|
@@ -2293,13 +2297,23 @@ function attrValueToString(value, opts) {
|
|
|
2293
2297
|
return null;
|
|
2294
2298
|
}
|
|
2295
2299
|
}
|
|
2300
|
+
function applyObjectIterationWrap(node, arrayExpr) {
|
|
2301
|
+
if (node.objectIteration === "entries")
|
|
2302
|
+
return `Object.entries(${arrayExpr})`;
|
|
2303
|
+
if (node.objectIteration === "keys")
|
|
2304
|
+
return `Object.keys(${arrayExpr})`;
|
|
2305
|
+
if (node.objectIteration === "values")
|
|
2306
|
+
return `Object.values(${arrayExpr})`;
|
|
2307
|
+
return arrayExpr;
|
|
2308
|
+
}
|
|
2296
2309
|
function buildChainedArrayExpr(elem) {
|
|
2297
|
-
|
|
2310
|
+
const chained = buildLoopChainExpr({
|
|
2298
2311
|
base: elem.array,
|
|
2299
2312
|
sortComparator: elem.sortComparator,
|
|
2300
2313
|
filterPredicate: elem.filterPredicate,
|
|
2301
2314
|
chainOrder: elem.chainOrder
|
|
2302
2315
|
});
|
|
2316
|
+
return applyObjectIterationWrap(elem, chained);
|
|
2303
2317
|
}
|
|
2304
2318
|
function loopOffsetTerms(offset) {
|
|
2305
2319
|
if (!offset)
|
|
@@ -2971,7 +2985,7 @@ function normalizeSignalInitial(signal, propsObjectName) {
|
|
|
2971
2985
|
}
|
|
2972
2986
|
|
|
2973
2987
|
// src/ir-to-client-js/html-template.ts
|
|
2974
|
-
import { BF_PARENT_SCOPE_PLACEHOLDER, BF_SCOPE } from "@barefootjs/shared";
|
|
2988
|
+
import { BF_PARENT_SCOPE_PLACEHOLDER, BF_SCOPE, escapeHtml } from "@barefootjs/shared";
|
|
2975
2989
|
function createStringProtector() {
|
|
2976
2990
|
const strings = [];
|
|
2977
2991
|
const protect = (s) => {
|
|
@@ -3073,6 +3087,24 @@ function applyIterationShape(node, arrayExpr, indexParam) {
|
|
|
3073
3087
|
callbackParam: `(${node.param})`
|
|
3074
3088
|
};
|
|
3075
3089
|
}
|
|
3090
|
+
if (node.objectIteration === "entries") {
|
|
3091
|
+
return {
|
|
3092
|
+
array: `Object.entries(${arrayExpr})`,
|
|
3093
|
+
callbackParam: node.index ? `([${node.index}, ${node.param}])` : `(${node.param}${indexParam})`
|
|
3094
|
+
};
|
|
3095
|
+
}
|
|
3096
|
+
if (node.objectIteration === "keys") {
|
|
3097
|
+
return {
|
|
3098
|
+
array: `Object.keys(${arrayExpr})`,
|
|
3099
|
+
callbackParam: `(${node.param})`
|
|
3100
|
+
};
|
|
3101
|
+
}
|
|
3102
|
+
if (node.objectIteration === "values") {
|
|
3103
|
+
return {
|
|
3104
|
+
array: `Object.values(${arrayExpr})`,
|
|
3105
|
+
callbackParam: `(${node.param})`
|
|
3106
|
+
};
|
|
3107
|
+
}
|
|
3076
3108
|
return { array: arrayExpr, callbackParam: `(${node.param}${indexParam})` };
|
|
3077
3109
|
}
|
|
3078
3110
|
function childrenPropEntry(children, recurse) {
|
|
@@ -3132,7 +3164,7 @@ function renderTemplateAttrPart(attr, attrName, wrap, restSpreadNames) {
|
|
|
3132
3164
|
case "boolean-attr":
|
|
3133
3165
|
return attrName;
|
|
3134
3166
|
case "literal":
|
|
3135
|
-
return `${attrName}="${v.value}"`;
|
|
3167
|
+
return `${attrName}="${escapeHtml(v.value)}"`;
|
|
3136
3168
|
case "expression": {
|
|
3137
3169
|
const valExpr = wrap(v.expr);
|
|
3138
3170
|
return templateAttrExpr(attrName, valExpr, v.presenceOrUndefined);
|
|
@@ -3263,7 +3295,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
3263
3295
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
3264
3296
|
}
|
|
3265
3297
|
case "text":
|
|
3266
|
-
return node.value;
|
|
3298
|
+
return escapeHtml(node.value);
|
|
3267
3299
|
case "expression":
|
|
3268
3300
|
if (node.expr === "null" || node.expr === "undefined")
|
|
3269
3301
|
return "";
|
|
@@ -3371,7 +3403,7 @@ function buildLoopSkeletonTemplate(node, safe) {
|
|
|
3371
3403
|
const v = a.value;
|
|
3372
3404
|
switch (v.kind) {
|
|
3373
3405
|
case "literal":
|
|
3374
|
-
attrParts.push(`${toHtmlAttrName(a.name)}="${v.value}"`);
|
|
3406
|
+
attrParts.push(`${toHtmlAttrName(a.name)}="${escapeHtml(v.value)}"`);
|
|
3375
3407
|
break;
|
|
3376
3408
|
case "boolean-attr":
|
|
3377
3409
|
attrParts.push(toHtmlAttrName(a.name));
|
|
@@ -3406,7 +3438,7 @@ function buildLoopSkeletonTemplate(node, safe) {
|
|
|
3406
3438
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
3407
3439
|
}
|
|
3408
3440
|
case "text":
|
|
3409
|
-
return node.value;
|
|
3441
|
+
return escapeHtml(node.value);
|
|
3410
3442
|
case "expression":
|
|
3411
3443
|
if (node.expr === "null" || node.expr === "undefined")
|
|
3412
3444
|
return "";
|
|
@@ -3458,7 +3490,7 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
|
|
|
3458
3490
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
3459
3491
|
}
|
|
3460
3492
|
case "text":
|
|
3461
|
-
return node.value;
|
|
3493
|
+
return escapeHtml(node.value);
|
|
3462
3494
|
case "expression":
|
|
3463
3495
|
if (node.expr === "null" || node.expr === "undefined")
|
|
3464
3496
|
return "";
|
|
@@ -3650,7 +3682,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
3650
3682
|
return templateAttrExpr(keyName, transformExpr(tmplStr));
|
|
3651
3683
|
}
|
|
3652
3684
|
case "literal":
|
|
3653
|
-
return `${keyName}="${v.value}"`;
|
|
3685
|
+
return `${keyName}="${escapeHtml(v.value)}"`;
|
|
3654
3686
|
default:
|
|
3655
3687
|
return "";
|
|
3656
3688
|
}
|
|
@@ -3660,7 +3692,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
3660
3692
|
case "boolean-attr":
|
|
3661
3693
|
return attrName;
|
|
3662
3694
|
case "literal":
|
|
3663
|
-
return `${attrName}="${v.value}"`;
|
|
3695
|
+
return `${attrName}="${escapeHtml(v.value)}"`;
|
|
3664
3696
|
case "expression":
|
|
3665
3697
|
return templateAttrExpr(attrName, transformExpr(v.expr, v.templateExpr), v.presenceOrUndefined);
|
|
3666
3698
|
case "template": {
|
|
@@ -3686,7 +3718,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
3686
3718
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
3687
3719
|
}
|
|
3688
3720
|
case "text":
|
|
3689
|
-
return node.value;
|
|
3721
|
+
return escapeHtml(node.value);
|
|
3690
3722
|
case "expression":
|
|
3691
3723
|
if (node.expr === "null" || node.expr === "undefined")
|
|
3692
3724
|
return "";
|
|
@@ -3978,7 +4010,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
3978
4010
|
case "boolean-attr":
|
|
3979
4011
|
return attrName;
|
|
3980
4012
|
case "literal":
|
|
3981
|
-
return `${attrName}="${v.value}"`;
|
|
4013
|
+
return `${attrName}="${escapeHtml(v.value)}"`;
|
|
3982
4014
|
case "expression":
|
|
3983
4015
|
return templateAttrExpr(attrName, transformExpr(v.expr, v.templateExpr), v.presenceOrUndefined);
|
|
3984
4016
|
case "template": {
|
|
@@ -4004,7 +4036,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
4004
4036
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
4005
4037
|
}
|
|
4006
4038
|
case "text":
|
|
4007
|
-
return node.value;
|
|
4039
|
+
return escapeHtml(node.value);
|
|
4008
4040
|
case "expression":
|
|
4009
4041
|
if (node.expr === "null" || node.expr === "undefined")
|
|
4010
4042
|
return "";
|
|
@@ -8034,7 +8066,7 @@ function resolveFreeRefs(node, env) {
|
|
|
8034
8066
|
}
|
|
8035
8067
|
|
|
8036
8068
|
// src/jsx-to-ir.ts
|
|
8037
|
-
import { toHTMLAttrName } from "@barefootjs/shared";
|
|
8069
|
+
import { toHTMLAttrName, decodeEntities } from "@barefootjs/shared";
|
|
8038
8070
|
var CLIENT_DIRECTIVE_INTERIOR_RE2 = /^\s*@client\s*$/;
|
|
8039
8071
|
var BLOCK_COMMENT_RE2 = /\/\*([\s\S]*?)\*\//g;
|
|
8040
8072
|
function hasLeadingClientDirective(expr, sourceFile) {
|
|
@@ -8183,6 +8215,7 @@ function createTransformContext(analyzer) {
|
|
|
8183
8215
|
isRoot: true,
|
|
8184
8216
|
insideComponentChildren: false,
|
|
8185
8217
|
loopParams: new Set,
|
|
8218
|
+
loopDepth: 0,
|
|
8186
8219
|
patterns: {
|
|
8187
8220
|
signals: analyzer.signals.map((s) => ({
|
|
8188
8221
|
getter: s.getter,
|
|
@@ -8836,7 +8869,7 @@ function transformText(node, ctx) {
|
|
|
8836
8869
|
}
|
|
8837
8870
|
return {
|
|
8838
8871
|
type: "text",
|
|
8839
|
-
value: text,
|
|
8872
|
+
value: decodeEntities(text),
|
|
8840
8873
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath)
|
|
8841
8874
|
};
|
|
8842
8875
|
}
|
|
@@ -9392,6 +9425,22 @@ function isIteratorShapeCall(node) {
|
|
|
9392
9425
|
return null;
|
|
9393
9426
|
return { array: node.expression.expression, shape: name };
|
|
9394
9427
|
}
|
|
9428
|
+
function isObjectIteratorCall(node) {
|
|
9429
|
+
if (!ts11.isCallExpression(node))
|
|
9430
|
+
return null;
|
|
9431
|
+
if (!ts11.isPropertyAccessExpression(node.expression))
|
|
9432
|
+
return null;
|
|
9433
|
+
if (!ts11.isIdentifier(node.expression.expression))
|
|
9434
|
+
return null;
|
|
9435
|
+
if (node.expression.expression.text !== "Object")
|
|
9436
|
+
return null;
|
|
9437
|
+
if (node.arguments.length !== 1)
|
|
9438
|
+
return null;
|
|
9439
|
+
const name = node.expression.name.text;
|
|
9440
|
+
if (name !== "entries" && name !== "keys" && name !== "values")
|
|
9441
|
+
return null;
|
|
9442
|
+
return { object: node.arguments[0], shape: name };
|
|
9443
|
+
}
|
|
9395
9444
|
function extractSortComparator(callback, _method, ctx) {
|
|
9396
9445
|
const outerRaw = ctx.getJS(callback);
|
|
9397
9446
|
const unsupported = () => ({
|
|
@@ -9810,6 +9859,7 @@ function extractItemConditionalKey(cond) {
|
|
|
9810
9859
|
}
|
|
9811
9860
|
function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
9812
9861
|
const isNested = ctx.loopParams.size > 0;
|
|
9862
|
+
const depth = ctx.loopDepth;
|
|
9813
9863
|
const propAccess = node.expression;
|
|
9814
9864
|
const mapSource = propAccess.expression;
|
|
9815
9865
|
let array = "";
|
|
@@ -9822,6 +9872,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
9822
9872
|
let templateMapPreamble;
|
|
9823
9873
|
let typedMapPreamble;
|
|
9824
9874
|
let iterationShape;
|
|
9875
|
+
let objectIteration;
|
|
9825
9876
|
const setArray = (node2) => {
|
|
9826
9877
|
array = ctx.getJS(node2);
|
|
9827
9878
|
templateArray = rewriteBarePropRefs2(array, node2, ctx);
|
|
@@ -9836,6 +9887,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
9836
9887
|
} else if (iteratorInfo.shape === "keys") {
|
|
9837
9888
|
iterationShape = "keys";
|
|
9838
9889
|
}
|
|
9890
|
+
} else {
|
|
9891
|
+
const objectIteratorInfo = isObjectIteratorCall(mapSource);
|
|
9892
|
+
if (objectIteratorInfo) {
|
|
9893
|
+
chainSource = objectIteratorInfo.object;
|
|
9894
|
+
objectIteration = objectIteratorInfo.shape;
|
|
9895
|
+
}
|
|
9839
9896
|
}
|
|
9840
9897
|
const filterInfo = isFilterCall(chainSource);
|
|
9841
9898
|
const sortInfo = isSortCall(chainSource);
|
|
@@ -9933,7 +9990,8 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
9933
9990
|
if (firstParam.type) {
|
|
9934
9991
|
paramType = firstParam.type.getText(ctx.sourceFile);
|
|
9935
9992
|
}
|
|
9936
|
-
|
|
9993
|
+
const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
|
|
9994
|
+
if (isEntriesShape && ts11.isArrayBindingPattern(firstParam.name)) {
|
|
9937
9995
|
const elements = firstParam.name.elements.filter((el) => !ts11.isOmittedExpression(el));
|
|
9938
9996
|
if (elements.length === 2 && ts11.isBindingElement(elements[0]) && ts11.isIdentifier(elements[0].name) && ts11.isBindingElement(elements[1]) && ts11.isIdentifier(elements[1].name)) {
|
|
9939
9997
|
index = elements[0].name.text;
|
|
@@ -9955,7 +10013,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
9955
10013
|
}
|
|
9956
10014
|
}
|
|
9957
10015
|
}
|
|
9958
|
-
if (callback.parameters.length > 1 && iterationShape !== "entries") {
|
|
10016
|
+
if (callback.parameters.length > 1 && iterationShape !== "entries" && objectIteration !== "entries") {
|
|
9959
10017
|
const secondParam = callback.parameters[1];
|
|
9960
10018
|
index = secondParam.name.getText(ctx.sourceFile);
|
|
9961
10019
|
if (secondParam.type) {
|
|
@@ -9970,6 +10028,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
9970
10028
|
}
|
|
9971
10029
|
if (index)
|
|
9972
10030
|
ctx.loopParams.add(index);
|
|
10031
|
+
ctx.loopDepth++;
|
|
9973
10032
|
const tryTransformRenderableBody = (expr) => {
|
|
9974
10033
|
if (!ts11.isBinaryExpression(expr))
|
|
9975
10034
|
return;
|
|
@@ -10066,6 +10125,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
10066
10125
|
}
|
|
10067
10126
|
if (index)
|
|
10068
10127
|
ctx.loopParams.delete(index);
|
|
10128
|
+
ctx.loopDepth--;
|
|
10069
10129
|
}
|
|
10070
10130
|
if (children.length === 0 && !flatMapCallback) {
|
|
10071
10131
|
return null;
|
|
@@ -10094,7 +10154,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
10094
10154
|
const callsReactive = exprCallsReactiveGetters(arrayExpr, ctx);
|
|
10095
10155
|
const hasCalls = exprHasFunctionCalls(arrayExpr);
|
|
10096
10156
|
const isDirectPropArray = method !== "flatMap" && isArrayExprDirectPropRef(arrayExpr, ctx);
|
|
10097
|
-
const isStaticArray = !isSignalOrMemoArray(array, ctx) && !isDirectPropArray && !hasCalls;
|
|
10157
|
+
const isStaticArray = !isSignalOrMemoArray(array, ctx) && !isDirectPropArray && !hasCalls && !objectIteration;
|
|
10098
10158
|
const nestedComponents = collectNestedComponents(children).filter((c) => c.name !== childComponent?.name);
|
|
10099
10159
|
return {
|
|
10100
10160
|
type: "loop",
|
|
@@ -10121,6 +10181,8 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
10121
10181
|
sortComparator,
|
|
10122
10182
|
chainOrder,
|
|
10123
10183
|
iterationShape,
|
|
10184
|
+
objectIteration,
|
|
10185
|
+
depth,
|
|
10124
10186
|
clientOnly: isClientOnly || undefined,
|
|
10125
10187
|
mapPreamble,
|
|
10126
10188
|
templateMapPreamble,
|
|
@@ -10363,7 +10425,7 @@ function getAttributeValue(attr, ctx) {
|
|
|
10363
10425
|
return AttrValueOf.booleanAttr();
|
|
10364
10426
|
}
|
|
10365
10427
|
if (ts11.isStringLiteral(attr.initializer)) {
|
|
10366
|
-
return AttrValueOf.literal(attr.initializer.text);
|
|
10428
|
+
return AttrValueOf.literal(decodeEntities(attr.initializer.text));
|
|
10367
10429
|
}
|
|
10368
10430
|
if (ts11.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
10369
10431
|
let expr = attr.initializer.expression;
|
|
@@ -11677,6 +11739,7 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
|
|
|
11677
11739
|
bodyIsMultiRoot: n.bodyIsMultiRoot,
|
|
11678
11740
|
bodyIsItemConditional: n.bodyIsItemConditional,
|
|
11679
11741
|
iterationShape: n.iterationShape,
|
|
11742
|
+
objectIteration: n.objectIteration,
|
|
11680
11743
|
containerSlotId: scope.parentSlotId,
|
|
11681
11744
|
template,
|
|
11682
11745
|
mapPreamble: n.mapPreamble,
|
|
@@ -11898,6 +11961,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
11898
11961
|
bodyIsMultiRoot: l.bodyIsMultiRoot,
|
|
11899
11962
|
bodyIsItemConditional: l.bodyIsItemConditional,
|
|
11900
11963
|
iterationShape: l.iterationShape,
|
|
11964
|
+
objectIteration: l.objectIteration,
|
|
11901
11965
|
template,
|
|
11902
11966
|
staticItemTemplate,
|
|
11903
11967
|
skeletonTemplate,
|
|
@@ -12097,6 +12161,7 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
|
|
|
12097
12161
|
bodyIsMultiRoot: n.bodyIsMultiRoot,
|
|
12098
12162
|
bodyIsItemConditional: n.bodyIsItemConditional,
|
|
12099
12163
|
iterationShape: n.iterationShape,
|
|
12164
|
+
objectIteration: n.objectIteration,
|
|
12100
12165
|
template: childTemplate,
|
|
12101
12166
|
containerSlotId: containerSlot,
|
|
12102
12167
|
mapPreamble: n.mapPreamble ?? null,
|
|
@@ -15566,6 +15631,7 @@ function buildDynamicLoopDelegationPlan(elem, profileComponentName) {
|
|
|
15566
15631
|
param: elem.param,
|
|
15567
15632
|
paramBindings: elem.paramBindings,
|
|
15568
15633
|
key: elem.key,
|
|
15634
|
+
index: elem.index,
|
|
15569
15635
|
mapPreamble: elem.mapPreamble ?? null
|
|
15570
15636
|
})
|
|
15571
15637
|
};
|
|
@@ -15581,6 +15647,7 @@ function buildBranchLoopDelegationPlan(loop, cv, profileComponentName) {
|
|
|
15581
15647
|
param: loop.param,
|
|
15582
15648
|
paramBindings: loop.paramBindings,
|
|
15583
15649
|
key: loop.key,
|
|
15650
|
+
index: loop.index,
|
|
15584
15651
|
mapPreamble: loop.mapPreamble ?? null
|
|
15585
15652
|
})
|
|
15586
15653
|
};
|
|
@@ -15596,7 +15663,8 @@ function buildStaticArrayDelegationPlan(elem, profileComponentName) {
|
|
|
15596
15663
|
arrayExpr: buildChainedArrayExpr(elem),
|
|
15597
15664
|
param: elem.param,
|
|
15598
15665
|
mapPreamble: elem.mapPreamble ?? null,
|
|
15599
|
-
offset: elem.offset ?? null
|
|
15666
|
+
offset: elem.offset ?? null,
|
|
15667
|
+
indexParam: elem.index ?? null
|
|
15600
15668
|
}
|
|
15601
15669
|
};
|
|
15602
15670
|
}
|
|
@@ -15611,7 +15679,8 @@ function buildKeyedOrIndexLookup(args) {
|
|
|
15611
15679
|
paramBindings: args.paramBindings,
|
|
15612
15680
|
keyWithItem,
|
|
15613
15681
|
mapPreamble: args.mapPreamble,
|
|
15614
|
-
hasBindings
|
|
15682
|
+
hasBindings,
|
|
15683
|
+
indexParam: args.index
|
|
15615
15684
|
};
|
|
15616
15685
|
}
|
|
15617
15686
|
return {
|
|
@@ -15619,7 +15688,8 @@ function buildKeyedOrIndexLookup(args) {
|
|
|
15619
15688
|
arrayExpr: args.array,
|
|
15620
15689
|
param: args.param,
|
|
15621
15690
|
mapPreamble: args.mapPreamble,
|
|
15622
|
-
hasBindings
|
|
15691
|
+
hasBindings,
|
|
15692
|
+
indexParam: args.index
|
|
15623
15693
|
};
|
|
15624
15694
|
}
|
|
15625
15695
|
|
|
@@ -16662,6 +16732,13 @@ function withTurn(call, componentName, childSlotId, eventName) {
|
|
|
16662
16732
|
const id = JSON.stringify(`${componentName}#handler:${childSlotId}:${eventName}`);
|
|
16663
16733
|
return `beginTurn(${id}); try { ${call} } finally { endTurn() }`;
|
|
16664
16734
|
}
|
|
16735
|
+
function indexBindingLine(handler, indexParam, indexExpr) {
|
|
16736
|
+
if (!indexParam || indexParam === indexExpr)
|
|
16737
|
+
return null;
|
|
16738
|
+
if (!extractFreeIdentifiersFromText(handler).has(indexParam))
|
|
16739
|
+
return null;
|
|
16740
|
+
return `const ${indexParam} = ${indexExpr}`;
|
|
16741
|
+
}
|
|
16665
16742
|
function stringifyEventDelegation(lines, plan) {
|
|
16666
16743
|
const { containerVar, events, itemLookup, profileComponentName } = plan;
|
|
16667
16744
|
const eventsByName = new Map;
|
|
@@ -16707,8 +16784,9 @@ function stringifyEventDelegation(lines, plan) {
|
|
|
16707
16784
|
}
|
|
16708
16785
|
}
|
|
16709
16786
|
function emitKeyedLookup(ls, ev, handlerCall, lookup) {
|
|
16710
|
-
const { arrayExpr, param, keyWithItem, mapPreamble, hasBindings } = lookup;
|
|
16787
|
+
const { arrayExpr, param, keyWithItem, mapPreamble, hasBindings, indexParam } = lookup;
|
|
16711
16788
|
if (ev.nestedLoops.length === 0) {
|
|
16789
|
+
const idxLine2 = indexBindingLine(ev.handler, indexParam, `${arrayExpr}.findIndex(item => String(${keyWithItem}) === key)`);
|
|
16712
16790
|
ls.push(` const li = ${varSlotId(ev.childSlotId)}El.closest('[${DATA_KEY}]')`);
|
|
16713
16791
|
ls.push(` if (li) {`);
|
|
16714
16792
|
ls.push(` const key = li.getAttribute('${DATA_KEY}')`);
|
|
@@ -16718,13 +16796,18 @@ function emitKeyedLookup(ls, ev, handlerCall, lookup) {
|
|
|
16718
16796
|
ls.push(` const ${param} = __bfLoopItem`);
|
|
16719
16797
|
if (mapPreamble)
|
|
16720
16798
|
ls.push(` ${mapPreamble}`);
|
|
16799
|
+
if (idxLine2)
|
|
16800
|
+
ls.push(` ${idxLine2}`);
|
|
16721
16801
|
ls.push(` ${handlerCall}`);
|
|
16722
16802
|
ls.push(` }`);
|
|
16723
16803
|
} else {
|
|
16724
16804
|
ls.push(` const ${param} = ${arrayExpr}.find(item => String(${keyWithItem}) === key)`);
|
|
16725
16805
|
if (mapPreamble)
|
|
16726
16806
|
ls.push(` ${mapPreamble}`);
|
|
16727
|
-
|
|
16807
|
+
if (idxLine2)
|
|
16808
|
+
ls.push(` if (${param}) { ${idxLine2}; ${handlerCall} }`);
|
|
16809
|
+
else
|
|
16810
|
+
ls.push(` if (${param}) ${handlerCall}`);
|
|
16728
16811
|
}
|
|
16729
16812
|
ls.push(` }`);
|
|
16730
16813
|
return;
|
|
@@ -16753,10 +16836,15 @@ function emitKeyedLookup(ls, ev, handlerCall, lookup) {
|
|
|
16753
16836
|
const allParams = [outerGuard, ...ev.nestedLoops.map((n) => n.param)];
|
|
16754
16837
|
if (mapPreamble)
|
|
16755
16838
|
ls.push(` ${mapPreamble}`);
|
|
16756
|
-
|
|
16839
|
+
const idxLine = indexBindingLine(ev.handler, indexParam, `${arrayExpr}.findIndex(item => String(${keyWithItem}) === outerKey)`);
|
|
16840
|
+
if (idxLine)
|
|
16841
|
+
ls.push(` if (${allParams.join(" && ")}) { ${idxLine}; ${handlerCall} }`);
|
|
16842
|
+
else
|
|
16843
|
+
ls.push(` if (${allParams.join(" && ")}) ${handlerCall}`);
|
|
16757
16844
|
}
|
|
16758
16845
|
function emitDynamicIndexLookup(ls, ev, handlerCall, lookup) {
|
|
16759
|
-
const { arrayExpr, param, mapPreamble, hasBindings } = lookup;
|
|
16846
|
+
const { arrayExpr, param, mapPreamble, hasBindings, indexParam } = lookup;
|
|
16847
|
+
const idxLine = indexBindingLine(ev.handler, indexParam, "idx");
|
|
16760
16848
|
ls.push(` const li = ${varSlotId(ev.childSlotId)}El.closest('li, [bf-i]')`);
|
|
16761
16849
|
ls.push(` if (li && li.parentElement) {`);
|
|
16762
16850
|
ls.push(` const idx = Array.from(li.parentElement.children).indexOf(li)`);
|
|
@@ -16766,18 +16854,24 @@ function emitDynamicIndexLookup(ls, ev, handlerCall, lookup) {
|
|
|
16766
16854
|
ls.push(` const ${param} = __bfLoopItem`);
|
|
16767
16855
|
if (mapPreamble)
|
|
16768
16856
|
ls.push(` ${mapPreamble}`);
|
|
16857
|
+
if (idxLine)
|
|
16858
|
+
ls.push(` ${idxLine}`);
|
|
16769
16859
|
ls.push(` ${handlerCall}`);
|
|
16770
16860
|
ls.push(` }`);
|
|
16771
16861
|
} else {
|
|
16772
16862
|
ls.push(` const ${param} = ${arrayExpr}[idx]`);
|
|
16773
16863
|
if (mapPreamble)
|
|
16774
16864
|
ls.push(` ${mapPreamble}`);
|
|
16775
|
-
|
|
16865
|
+
if (idxLine)
|
|
16866
|
+
ls.push(` if (${param}) { ${idxLine}; ${handlerCall} }`);
|
|
16867
|
+
else
|
|
16868
|
+
ls.push(` if (${param}) ${handlerCall}`);
|
|
16776
16869
|
}
|
|
16777
16870
|
ls.push(` }`);
|
|
16778
16871
|
}
|
|
16779
16872
|
function emitStaticIndexLookup(ls, ev, handlerCall, lookup, containerVar) {
|
|
16780
|
-
const { arrayExpr, param, mapPreamble, offset } = lookup;
|
|
16873
|
+
const { arrayExpr, param, mapPreamble, offset, indexParam } = lookup;
|
|
16874
|
+
const idxLine = indexBindingLine(ev.handler, indexParam, "__idx");
|
|
16781
16875
|
ls.push(` let __el = ${varSlotId(ev.childSlotId)}El`);
|
|
16782
16876
|
ls.push(` while (__el.parentElement && __el.parentElement !== ${containerVar}) __el = __el.parentElement`);
|
|
16783
16877
|
ls.push(` if (__el.parentElement === ${containerVar}) {`);
|
|
@@ -16786,7 +16880,10 @@ function emitStaticIndexLookup(ls, ev, handlerCall, lookup, containerVar) {
|
|
|
16786
16880
|
ls.push(` const ${param} = ${arrayExpr}[__idx]`);
|
|
16787
16881
|
if (mapPreamble)
|
|
16788
16882
|
ls.push(` ${mapPreamble}`);
|
|
16789
|
-
|
|
16883
|
+
if (idxLine)
|
|
16884
|
+
ls.push(` if (${param}) { ${idxLine}; ${handlerCall} }`);
|
|
16885
|
+
else
|
|
16886
|
+
ls.push(` if (${param}) ${handlerCall}`);
|
|
16790
16887
|
ls.push(` }`);
|
|
16791
16888
|
}
|
|
16792
16889
|
|
|
@@ -20044,7 +20141,7 @@ function emitParsedExpr(expr, emitter) {
|
|
|
20044
20141
|
return emitter.call(expr.callee, expr.args, emit);
|
|
20045
20142
|
}
|
|
20046
20143
|
case "member":
|
|
20047
|
-
return emitter.member(expr.object, expr.property, expr.computed, emit);
|
|
20144
|
+
return emitter.member(expr.object, expr.property, expr.computed, expr.optional, emit);
|
|
20048
20145
|
case "index-access":
|
|
20049
20146
|
return emitter.indexAccess(expr.object, expr.index, emit);
|
|
20050
20147
|
case "binary":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect-elements.d.ts","sourceRoot":"","sources":["../../src/ir-to-client-js/collect-elements.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAoC,KAAK,MAAM,EAAmC,MAAM,aAAa,CAAA;AACzH,OAAO,KAAK,EAAE,eAAe,EAA+H,iBAAiB,EAA0B,oBAAoB,EAAc,UAAU,EAAE,MAAM,YAAY,CAAA;AAwGvQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CA0C7E;AAyBD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,EAAE,wBAIpC,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EAAE,EACf,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACrC,cAAc,CAAC,EAAE,MAAM,EACvB,GAAG,CAAC,EAAE,eAAe,EACrB,OAAO,CAAC,EAAE,wBAAwB,GACjC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"collect-elements.d.ts","sourceRoot":"","sources":["../../src/ir-to-client-js/collect-elements.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAoC,KAAK,MAAM,EAAmC,MAAM,aAAa,CAAA;AACzH,OAAO,KAAK,EAAE,eAAe,EAA+H,iBAAiB,EAA0B,oBAAoB,EAAc,UAAU,EAAE,MAAM,YAAY,CAAA;AAwGvQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CA0C7E;AAyBD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,EAAE,wBAIpC,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EAAE,EACf,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACrC,cAAc,CAAC,EAAE,MAAM,EACvB,GAAG,CAAC,EAAE,eAAe,EACrB,OAAO,CAAC,EAAE,wBAAwB,GACjC,UAAU,EAAE,CA0Id;AAqKD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,eAAe,EACpB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACrC,iBAAiB,UAAQ,GACxB,IAAI,CAqPN;AA+WD;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,GAAG,EAAE,eAAe,EACpB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACrC,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,SAAS,OAAO,aAAa,EAAE,gBAAgB,EAAE,GAAG,SAAS,GAC/E,iBAAiB,CAUnB;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,eAAe,EACpB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACrC,SAAS,CAAC,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,SAAS,OAAO,aAAa,EAAE,gBAAgB,EAAE,GACpE,oBAAoB,EAAE,CA4DxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-event-delegation.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/plan/build-event-delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE9E,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,YAAY,CAAA;AAEnB,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,YAAY,EAClB,oBAAoB,CAAC,EAAE,MAAM,GAC5B,mBAAmB,
|
|
1
|
+
{"version":3,"file":"build-event-delegation.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/plan/build-event-delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE9E,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,YAAY,CAAA;AAEnB,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,YAAY,EAClB,oBAAoB,CAAC,EAAE,MAAM,GAC5B,mBAAmB,CAmBrB;AAKD,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,UAAU,EAChB,EAAE,EAAE,MAAM,EACV,oBAAoB,CAAC,EAAE,MAAM,GAC5B,mBAAmB,CAgBrB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,YAAY,EAClB,oBAAoB,CAAC,EAAE,MAAM,GAC5B,mBAAmB,CAkBrB;AA0CD,YAAY,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -44,6 +44,12 @@ export interface KeyedItemLookup {
|
|
|
44
44
|
arrayExpr: string;
|
|
45
45
|
/** Loop param identifier (or destructure pattern text — used as receiver name only). */
|
|
46
46
|
param: string;
|
|
47
|
+
/**
|
|
48
|
+
* Loop index param name (e.g. `i` from `.map((item, i) => ...)`), or `null`.
|
|
49
|
+
* When a delegated handler closes over it, the stringifier re-derives the
|
|
50
|
+
* index at dispatch time and binds it so the reference resolves (#2189).
|
|
51
|
+
*/
|
|
52
|
+
indexParam: string | null;
|
|
47
53
|
/** Destructured-binding metadata. Determines TDZ-safe `__bfLoopItem` shape (#951). */
|
|
48
54
|
paramBindings: TopLevelLoop['paramBindings'];
|
|
49
55
|
/**
|
|
@@ -64,12 +70,16 @@ export interface DynamicIndexItemLookup {
|
|
|
64
70
|
param: string;
|
|
65
71
|
mapPreamble: string | null;
|
|
66
72
|
hasBindings: boolean;
|
|
73
|
+
/** Loop index param name — see `KeyedItemLookup.indexParam` (#2189). */
|
|
74
|
+
indexParam: string | null;
|
|
67
75
|
}
|
|
68
76
|
export interface StaticIndexItemLookup {
|
|
69
77
|
kind: 'static-index';
|
|
70
78
|
arrayExpr: string;
|
|
71
79
|
param: string;
|
|
72
80
|
mapPreamble: string | null;
|
|
81
|
+
/** Loop index param name — see `KeyedItemLookup.indexParam` (#2189). */
|
|
82
|
+
indexParam: string | null;
|
|
73
83
|
/**
|
|
74
84
|
* Offset of the loop's items past its preceding container siblings. Its
|
|
75
85
|
* terms are subtracted from the DOM child index to recover the array index,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-delegation.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/plan/event-delegation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE9E;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,kBAAkB,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB,eAAe,GACf,sBAAsB,GACtB,qBAAqB,CAAA;AAEzB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAA;IACb,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,wFAAwF;IACxF,KAAK,EAAE,MAAM,CAAA;IACb,sFAAsF;IACtF,aAAa,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IAC5C;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,gEAAgE;IAChE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,6EAA6E;IAC7E,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,eAAe,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,WAAW,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"event-delegation.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/plan/event-delegation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE9E;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,kBAAkB,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB,eAAe,GACf,sBAAsB,GACtB,qBAAqB,CAAA;AAEzB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAA;IACb,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,wFAAwF;IACxF,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,sFAAsF;IACtF,aAAa,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IAC5C;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,gEAAgE;IAChE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,6EAA6E;IAC7E,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,eAAe,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,WAAW,EAAE,OAAO,CAAA;IACpB,wEAAwE;IACxE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,cAAc,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,wEAAwE;IACxE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB;;;;;OAKG;IACH,MAAM,EAAE,UAAU,GAAG,IAAI,CAAA;CAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-delegation.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/stringify/event-delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;
|
|
1
|
+
{"version":3,"file":"event-delegation.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/stringify/event-delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH,OAAO,KAAK,EACV,mBAAmB,EAKpB,MAAM,kBAAkB,CAAA;AAkCzB,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI,CA4CzF"}
|
|
@@ -97,6 +97,7 @@ export declare function csrSubstitute(value: string, env: CsrEnv): {
|
|
|
97
97
|
* to detect bridged-arg calls (#1138).
|
|
98
98
|
*/
|
|
99
99
|
export declare function applyPropsRewrite(text: string, propsObjectName: string | null): string;
|
|
100
|
+
export declare function extractFreeIdentifiersFromText(text: string): Set<string>;
|
|
100
101
|
/**
|
|
101
102
|
* Reduce a memo's `() => expr` source to the expression that should be
|
|
102
103
|
* substituted in for `memoName()`. Matches the extraction done by the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csr-substitute.d.ts","sourceRoot":"","sources":["../../src/ir-to-client-js/csr-substitute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACrC;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC,CAAA;AAEtE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;IAC3B,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAA;IACnB,qFAAqF;IACrF,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,MAAM;IACrB;;;;;OAKG;IACH,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC3C,4EAA4E;IAC5E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,CAmB7D;AAmMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGtF;
|
|
1
|
+
{"version":3,"file":"csr-substitute.d.ts","sourceRoot":"","sources":["../../src/ir-to-client-js/csr-substitute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACrC;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC,CAAA;AAEtE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;IAC3B,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAA;IACnB,qFAAqF;IACrF,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,MAAM;IACrB;;;;;OAKG;IACH,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC3C,4EAA4E;IAC5E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,CAmB7D;AAmMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGtF;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAaxE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQ/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,eAAe,EAAE,MAAM,GAAG,IAAI,GAC7B,MAAM,CAsBR"}
|