@barefootjs/jsx 0.39.9 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts +41 -0
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts.map +1 -0
- package/dist/adapters/attr-plan.d.ts +1 -20
- package/dist/adapters/attr-plan.d.ts.map +1 -1
- package/dist/adapters/boolean-carrier.d.ts +31 -0
- package/dist/adapters/boolean-carrier.d.ts.map +1 -0
- package/dist/adapters/component-props.d.ts +22 -7
- package/dist/adapters/component-props.d.ts.map +1 -1
- package/dist/adapters/computed-const.d.ts +17 -0
- package/dist/adapters/computed-const.d.ts.map +1 -1
- package/dist/adapters/dsl-template-adapter.d.ts +95 -2
- package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
- package/dist/adapters/loop-plan.d.ts +41 -1
- package/dist/adapters/loop-plan.d.ts.map +1 -1
- package/dist/adapters/number-value.d.ts +43 -0
- package/dist/adapters/number-value.d.ts.map +1 -0
- package/dist/analyzer-context.d.ts +7 -0
- package/dist/analyzer-context.d.ts.map +1 -1
- package/dist/analyzer.d.ts +34 -0
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/augment-inherited-props.d.ts.map +1 -1
- package/dist/css-layer-prefixer.d.ts.map +1 -1
- package/dist/debug.d.ts.map +1 -1
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2102 -1344
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-component-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts +29 -0
- package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts +2 -0
- package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts +5 -4
- package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts +2 -0
- package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +15 -0
- package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts +2 -0
- package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts +20 -0
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts +3 -2
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/build-static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +7 -1
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
- package/dist/ir-to-client-js/safe-html.d.ts +9 -3
- package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
- package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +30 -0
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +9 -1
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/module-exports.d.ts.map +1 -1
- package/dist/nullable-signal-attr.d.ts +29 -3
- package/dist/nullable-signal-attr.d.ts.map +1 -1
- package/dist/props-binding.d.ts +27 -3
- package/dist/props-binding.d.ts.map +1 -1
- package/dist/scope/binding-scope.d.ts +24 -1
- package/dist/scope/binding-scope.d.ts.map +1 -1
- package/dist/scope/root-prop-alias.d.ts +14 -1
- package/dist/scope/root-prop-alias.d.ts.map +1 -1
- package/dist/signal-prop-name-collision.d.ts.map +1 -1
- package/dist/ssr-defaults.d.ts +4 -2
- package/dist/ssr-defaults.d.ts.map +1 -1
- package/dist/ssr-seed-plan.d.ts +14 -0
- package/dist/ssr-seed-plan.d.ts.map +1 -1
- package/dist/template-parts.d.ts +1 -1
- package/dist/template-parts.d.ts.map +1 -1
- package/dist/types.d.ts +35 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/attr-plan.test.ts +1 -14
- package/src/__tests__/binding-scope-ratchet.test.ts +12 -2
- package/src/__tests__/boolean-carrier.test.ts +74 -0
- package/src/__tests__/client-template-escape-soundness.test.ts +17 -4
- package/src/__tests__/client-template-static-delimiters.test.ts +57 -0
- package/src/__tests__/component-props.test.ts +14 -0
- package/src/__tests__/computed-const.test.ts +85 -0
- package/src/__tests__/dsl-template-adapter.test.ts +70 -0
- package/src/__tests__/expression-parser.test.ts +24 -0
- package/src/__tests__/extract-function-params.test.ts +37 -0
- package/src/__tests__/issue-2960-multi-root-cond-same-tag.test.ts +18 -0
- package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +142 -0
- package/src/__tests__/jsx-text-linebreak-whitespace.test.ts +11 -0
- package/src/__tests__/loop-plan.test.ts +66 -1
- package/src/__tests__/loop-row-prop-read.test.ts +111 -0
- package/src/__tests__/memo-body-expr.test.ts +137 -0
- package/src/__tests__/nullable-signal-attr.test.ts +97 -2
- package/src/__tests__/profile-binding-ids.test.ts +14 -0
- package/src/__tests__/root-prop-alias.test.ts +34 -1
- package/src/__tests__/signal-prop-name-collision.test.ts +102 -2
- package/src/__tests__/source-file-cache.test.ts +105 -0
- package/src/__tests__/ssr-seed-plan.test.ts +43 -0
- package/src/__tests__/template-parts-literal-boundary.test.ts +41 -0
- package/src/adapters/ambiguous-nil-arithmetic.ts +94 -0
- package/src/adapters/attr-plan.ts +8 -56
- package/src/adapters/boolean-carrier.ts +76 -0
- package/src/adapters/component-props.ts +28 -8
- package/src/adapters/computed-const.ts +206 -7
- package/src/adapters/dsl-template-adapter.ts +183 -2
- package/src/adapters/loop-plan.ts +67 -2
- package/src/adapters/number-value.ts +95 -0
- package/src/analyzer-context.ts +8 -0
- package/src/analyzer.ts +187 -66
- package/src/augment-inherited-props.ts +5 -9
- package/src/css-layer-prefixer.ts +4 -5
- package/src/debug.ts +1 -0
- package/src/expression-parser.ts +4 -1
- package/src/index.ts +23 -5
- package/src/ir-to-client-js/collect-elements.ts +104 -46
- package/src/ir-to-client-js/compute-inlinability.ts +2 -2
- package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +15 -1
- package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +79 -4
- package/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts +3 -0
- package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +1 -0
- package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +1 -0
- package/src/ir-to-client-js/control-flow/plan/inner-loop.ts +5 -4
- package/src/ir-to-client-js/control-flow/plan/loop-child-arm.ts +2 -0
- package/src/ir-to-client-js/control-flow/plan/loop.ts +12 -0
- package/src/ir-to-client-js/control-flow/plan/reactive-effects.ts +2 -0
- package/src/ir-to-client-js/control-flow/shared.ts +3 -2
- package/src/ir-to-client-js/control-flow/stringify/claim-plan.ts +27 -0
- package/src/ir-to-client-js/control-flow/stringify/component-loop.ts +8 -2
- package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +8 -1
- package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +8 -7
- package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +8 -7
- package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +4 -4
- package/src/ir-to-client-js/control-flow/stringify/loop.ts +3 -3
- package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +6 -6
- package/src/ir-to-client-js/emit-reactive.ts +1 -1
- package/src/ir-to-client-js/html-template.ts +122 -75
- package/src/ir-to-client-js/plan/build-static-array-child-init.ts +11 -1
- package/src/ir-to-client-js/plan/static-array-child-init.ts +7 -1
- package/src/ir-to-client-js/reactivity.ts +14 -0
- package/src/ir-to-client-js/safe-html.ts +11 -4
- package/src/ir-to-client-js/stringify/static-array-child-init.ts +6 -4
- package/src/ir-to-client-js/types.ts +23 -0
- package/src/ir-to-client-js/utils.ts +16 -2
- package/src/jsx-to-ir.ts +112 -55
- package/src/loop-destructure.ts +4 -1
- package/src/module-exports.ts +13 -21
- package/src/nullable-signal-attr.ts +134 -13
- package/src/props-binding.ts +54 -3
- package/src/rich-type-refusal.ts +3 -1
- package/src/scope/binding-scope.ts +35 -2
- package/src/scope/root-prop-alias.ts +17 -1
- package/src/signal-prop-name-collision.ts +113 -22
- package/src/ssr-defaults.ts +10 -4
- package/src/ssr-seed-plan.ts +82 -17
- package/src/template-parts.ts +25 -3
- package/src/template-position-walk.ts +3 -1
- package/src/types.ts +32 -1
package/dist/index.js
CHANGED
|
@@ -869,7 +869,7 @@ function convertNode(node, raw) {
|
|
|
869
869
|
if (ts3.isNumericLiteral(argNode)) {
|
|
870
870
|
return { kind: "member", object, property: argNode.text, computed: true, optional: !!node.questionDotToken };
|
|
871
871
|
}
|
|
872
|
-
if (ts3.
|
|
872
|
+
if (ts3.isStringLiteralLike(argNode)) {
|
|
873
873
|
return { kind: "member", object, property: argNode.text, computed: true, optional: !!node.questionDotToken };
|
|
874
874
|
}
|
|
875
875
|
const index = convertNode(argNode, raw);
|
|
@@ -2902,6 +2902,7 @@ function walkWithScope(root, visit) {
|
|
|
2902
2902
|
}
|
|
2903
2903
|
|
|
2904
2904
|
// src/scope/binding-scope.ts
|
|
2905
|
+
var PROPS_OBJECT_IDENTIFIER = "props";
|
|
2905
2906
|
function isStringLoopValue(type) {
|
|
2906
2907
|
return type.primitive === "string" || type.unionTypes !== undefined && type.unionTypes.length > 0 && type.unionTypes.every(isStringLoopValue);
|
|
2907
2908
|
}
|
|
@@ -2961,12 +2962,21 @@ class BindingScope {
|
|
|
2961
2962
|
}
|
|
2962
2963
|
return false;
|
|
2963
2964
|
}
|
|
2965
|
+
shadowsPropsObject() {
|
|
2966
|
+
return this.isBound(PROPS_OBJECT_IDENTIFIER);
|
|
2967
|
+
}
|
|
2964
2968
|
isStringValueName(name, outer, componentProperty = false) {
|
|
2965
2969
|
if (componentProperty)
|
|
2966
|
-
return outer(name);
|
|
2970
|
+
return !this.shadowsPropsObject() && outer(name);
|
|
2967
2971
|
const hit = this.lookup(name);
|
|
2968
2972
|
return hit ? hit.binding.stringValue === true : outer(name);
|
|
2969
2973
|
}
|
|
2974
|
+
insideLoopRow() {
|
|
2975
|
+
return this.frames.some((frame) => frame.kind === "loop-row");
|
|
2976
|
+
}
|
|
2977
|
+
innermostNames() {
|
|
2978
|
+
return this.frames[0] ? [...this.frames[0].bindings.keys()] : [];
|
|
2979
|
+
}
|
|
2970
2980
|
shadowedNames() {
|
|
2971
2981
|
if (!this.frames[0])
|
|
2972
2982
|
return [];
|
|
@@ -3032,14 +3042,20 @@ function lookupPartToJsExpr(part, opts) {
|
|
|
3032
3042
|
const typed = opts?.typed ? " as Record<string, string>" : "";
|
|
3033
3043
|
return `(${obj}${typed})[${key}]`;
|
|
3034
3044
|
}
|
|
3045
|
+
function singleQuotedJsString(value) {
|
|
3046
|
+
const body = value.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
3047
|
+
return `'${body}'`;
|
|
3048
|
+
}
|
|
3035
3049
|
function templatePartsToJsExpr(parts, opts) {
|
|
3036
3050
|
let result = "`";
|
|
3037
3051
|
for (const part of parts) {
|
|
3038
3052
|
if (part.type === "string") {
|
|
3039
|
-
result +=
|
|
3053
|
+
result += part.value.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${").replace(/\r/g, "\\r");
|
|
3054
|
+
} else if (part.type === "expression") {
|
|
3055
|
+
result += `\${${opts?.useTemplate ? part.templateExpr ?? part.expr : part.expr}}`;
|
|
3040
3056
|
} else if (part.type === "ternary") {
|
|
3041
3057
|
const cond = opts?.useTemplate && part.templateCondition ? part.templateCondition : part.condition;
|
|
3042
|
-
result += `\${${cond} ?
|
|
3058
|
+
result += `\${${cond} ? ${singleQuotedJsString(part.whenTrue)} : ${singleQuotedJsString(part.whenFalse)}}`;
|
|
3043
3059
|
} else if (part.type === "lookup") {
|
|
3044
3060
|
result += `\${${lookupPartToJsExpr(part, opts)}}`;
|
|
3045
3061
|
}
|
|
@@ -4060,7 +4076,10 @@ function varSlotId(slotId) {
|
|
|
4060
4076
|
function profileBindingId(componentName, slotId) {
|
|
4061
4077
|
if (!componentName || slotId === "?")
|
|
4062
4078
|
return "";
|
|
4063
|
-
return `, ${
|
|
4079
|
+
return `, ${codeSafeStringLiteral(`${componentName}#binding:${slotId}`)}`;
|
|
4080
|
+
}
|
|
4081
|
+
function codeSafeStringLiteral(value) {
|
|
4082
|
+
return JSON.stringify(value).replace(/[<>/\u2028\u2029]/g, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
4064
4083
|
}
|
|
4065
4084
|
function attrValueToString(value, opts) {
|
|
4066
4085
|
switch (value.kind) {
|
|
@@ -4996,6 +5015,29 @@ function isRenamedBodyPropParam(c, propsParams) {
|
|
|
4996
5015
|
return false;
|
|
4997
5016
|
return propsParams.some((p) => !p.isRest && p.name === c.name && p.sourceName === key);
|
|
4998
5017
|
}
|
|
5018
|
+
function templatePropReadParams(b) {
|
|
5019
|
+
if (!b.propsObjectName)
|
|
5020
|
+
return [...b.propsParams];
|
|
5021
|
+
const held = new Set;
|
|
5022
|
+
const other = new Set;
|
|
5023
|
+
for (const s of b.signals) {
|
|
5024
|
+
other.add(s.getter);
|
|
5025
|
+
if (s.setter)
|
|
5026
|
+
other.add(s.setter);
|
|
5027
|
+
}
|
|
5028
|
+
for (const m of b.memos)
|
|
5029
|
+
other.add(m.name);
|
|
5030
|
+
for (const f of b.localFunctions)
|
|
5031
|
+
other.add(f.name);
|
|
5032
|
+
for (const c of b.localConstants)
|
|
5033
|
+
(holdsProp(c, b.propsObjectName, b.propsParams) ? held : other).add(c.name);
|
|
5034
|
+
return b.propsParams.filter((p) => held.has(p.name) && !other.has(p.name));
|
|
5035
|
+
}
|
|
5036
|
+
function holdsProp(c, propsObjectName, propsParams) {
|
|
5037
|
+
if (c.propsDestructure && !keepsDeclaredValue(c))
|
|
5038
|
+
return false;
|
|
5039
|
+
return isPropsAliasConst(c, propsObjectName) || isRenamedBodyPropParam(c, propsParams);
|
|
5040
|
+
}
|
|
4999
5041
|
function signalPropSeed(parsed, propsParams, propsObjectName) {
|
|
5000
5042
|
if (!parsed)
|
|
5001
5043
|
return null;
|
|
@@ -5634,7 +5676,8 @@ function spliceChildValue(node, valueExpr, cx) {
|
|
|
5634
5676
|
if (cx.branchSlotsVar)
|
|
5635
5677
|
return branchSlotValue(valueExpr, cx.branchSlotsVar);
|
|
5636
5678
|
if (node.slotId) {
|
|
5637
|
-
|
|
5679
|
+
const markup = cx.markupSlotIds?.has(node.slotId) || node.loopRowPropRead;
|
|
5680
|
+
return markup ? escapedTextOrMarkup(valueExpr) : escapedText(valueExpr);
|
|
5638
5681
|
}
|
|
5639
5682
|
if (node.childrenRead === "bare" || node.childrenRead === "nullish-empty") {
|
|
5640
5683
|
return childrenMarkup(valueExpr);
|
|
@@ -5658,6 +5701,9 @@ function isEventHandlerName(name) {
|
|
|
5658
5701
|
}
|
|
5659
5702
|
|
|
5660
5703
|
// src/ir-to-client-js/html-template.ts
|
|
5704
|
+
function escapeStaticTemplateHtml(text) {
|
|
5705
|
+
return escapeHtml(text).replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
5706
|
+
}
|
|
5661
5707
|
function splitTemplateInterpolations(inner) {
|
|
5662
5708
|
const parts = [];
|
|
5663
5709
|
let i = 0;
|
|
@@ -5840,7 +5886,7 @@ function renderTemplateAttrPart(attr, attrName, wrap, restSpreadNames) {
|
|
|
5840
5886
|
case "boolean-attr":
|
|
5841
5887
|
return attrName;
|
|
5842
5888
|
case "literal":
|
|
5843
|
-
return `${attrName}="${
|
|
5889
|
+
return `${attrName}="${escapeStaticTemplateHtml(v.value)}"`;
|
|
5844
5890
|
case "expression": {
|
|
5845
5891
|
const valExpr = wrap(v.expr);
|
|
5846
5892
|
return templateAttrExpr(attrName, valExpr, v.presenceOrUndefined);
|
|
@@ -5859,6 +5905,16 @@ function renderTemplateAttrPart(attr, attrName, wrap, restSpreadNames) {
|
|
|
5859
5905
|
return "";
|
|
5860
5906
|
}
|
|
5861
5907
|
}
|
|
5908
|
+
function keepsTemplateComponentProp(p) {
|
|
5909
|
+
if (p.name === "key")
|
|
5910
|
+
return false;
|
|
5911
|
+
if (p.name === "..." || p.name.startsWith("..."))
|
|
5912
|
+
return p.value.kind === "spread" && p.value.propsObject === true;
|
|
5913
|
+
return true;
|
|
5914
|
+
}
|
|
5915
|
+
function templatePropEntry(p, valueExpr) {
|
|
5916
|
+
return p.name === "..." || p.name.startsWith("...") ? `...${valueExpr}` : `${quotePropName(p.name)}: ${valueExpr}`;
|
|
5917
|
+
}
|
|
5862
5918
|
function resolvedKeyAttrName(node, loopDepth) {
|
|
5863
5919
|
return node.keyAttr ? keyAttrName(loopDepth) : null;
|
|
5864
5920
|
}
|
|
@@ -6041,7 +6097,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
6041
6097
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
6042
6098
|
}
|
|
6043
6099
|
case "text":
|
|
6044
|
-
return
|
|
6100
|
+
return escapeStaticTemplateHtml(node.value);
|
|
6045
6101
|
case "expression": {
|
|
6046
6102
|
if (node.expr === "null" || node.expr === "undefined")
|
|
6047
6103
|
return "";
|
|
@@ -6063,7 +6119,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
6063
6119
|
if (node.name === "Portal") {
|
|
6064
6120
|
return node.children.map(recurse).join("");
|
|
6065
6121
|
}
|
|
6066
|
-
const propsEntries = node.props.filter(
|
|
6122
|
+
const propsEntries = node.props.filter(keepsTemplateComponentProp).filter((p) => p.name !== "ref" && !isEventHandlerName(p.name)).map((p) => {
|
|
6067
6123
|
if (p.clientOnly)
|
|
6068
6124
|
return null;
|
|
6069
6125
|
switch (p.value.kind) {
|
|
@@ -6082,7 +6138,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
6082
6138
|
case "template":
|
|
6083
6139
|
case "spread": {
|
|
6084
6140
|
const expr = wrapExpr(attrValueToString(p.value, { useTemplate: true }) ?? "undefined");
|
|
6085
|
-
return
|
|
6141
|
+
return templatePropEntry(p, expr);
|
|
6086
6142
|
}
|
|
6087
6143
|
}
|
|
6088
6144
|
}).filter((entry) => entry !== null);
|
|
@@ -6091,7 +6147,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
6091
6147
|
propsEntries.push(childrenEntry);
|
|
6092
6148
|
const propsExpr = propsEntries.length > 0 ? `{${propsEntries.join(", ")}}` : "{}";
|
|
6093
6149
|
const keyProp = node.props.find((p) => p.name === "key");
|
|
6094
|
-
const keyArg = keyProp ? `, ${
|
|
6150
|
+
const keyArg = keyProp ? `, ${transformKeyValue(keyProp.value, (expr, templateExpr) => wrapExpr(templateExpr ?? expr))}` : "";
|
|
6095
6151
|
return interp(renderChildCall(nameForRegistryRef(node.name), propsExpr, renderChildScopeArgs(node, keyArg)));
|
|
6096
6152
|
}
|
|
6097
6153
|
case "loop": {
|
|
@@ -6149,7 +6205,7 @@ function buildLoopSkeletonTemplate(node, safe) {
|
|
|
6149
6205
|
const v = a.value;
|
|
6150
6206
|
switch (v.kind) {
|
|
6151
6207
|
case "literal":
|
|
6152
|
-
attrParts.push(`${toHtmlAttrName(a.name)}="${
|
|
6208
|
+
attrParts.push(`${toHtmlAttrName(a.name)}="${escapeStaticTemplateHtml(v.value)}"`);
|
|
6153
6209
|
break;
|
|
6154
6210
|
case "boolean-attr":
|
|
6155
6211
|
attrParts.push(toHtmlAttrName(a.name));
|
|
@@ -6186,7 +6242,7 @@ function buildLoopSkeletonTemplate(node, safe) {
|
|
|
6186
6242
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
6187
6243
|
}
|
|
6188
6244
|
case "text":
|
|
6189
|
-
return
|
|
6245
|
+
return escapeStaticTemplateHtml(node.value);
|
|
6190
6246
|
case "expression":
|
|
6191
6247
|
if (node.expr === "null" || node.expr === "undefined")
|
|
6192
6248
|
return "";
|
|
@@ -6371,7 +6427,7 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
|
|
|
6371
6427
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
6372
6428
|
}
|
|
6373
6429
|
case "text":
|
|
6374
|
-
return
|
|
6430
|
+
return escapeStaticTemplateHtml(node.value);
|
|
6375
6431
|
case "expression": {
|
|
6376
6432
|
if (node.expr === "null" || node.expr === "undefined")
|
|
6377
6433
|
return "";
|
|
@@ -6470,7 +6526,8 @@ function irNodeToJsExprs(node, brandMarkup = false) {
|
|
|
6470
6526
|
propsEntries.push(`get children() { return ${childrenExpr} }`);
|
|
6471
6527
|
}
|
|
6472
6528
|
const propsExpr = propsEntries.length > 0 ? `{ ${propsEntries.join(", ")} }` : "{}";
|
|
6473
|
-
|
|
6529
|
+
const slotArg = node.slotId && !node.loopItemRoot ? `, undefined, { parent: __scopeId, mount: '${node.slotId}' }` : "";
|
|
6530
|
+
return [`createComponent('${nameForRegistryRef(node.name)}', ${propsExpr}${slotArg})`];
|
|
6474
6531
|
}
|
|
6475
6532
|
case "expression":
|
|
6476
6533
|
if (node.expr === "null" || node.expr === "undefined")
|
|
@@ -6504,29 +6561,50 @@ function addCondAttrToTemplate(html, condId) {
|
|
|
6504
6561
|
}
|
|
6505
6562
|
return `<!--bf-cond-start:${condId}-->${html}<!--bf-cond-end:${condId}-->`;
|
|
6506
6563
|
}
|
|
6564
|
+
function* templateHtmlTags(html) {
|
|
6565
|
+
let cursor = 0;
|
|
6566
|
+
let noCommentEnd = false;
|
|
6567
|
+
while (cursor < html.length) {
|
|
6568
|
+
const start = html.indexOf("<", cursor);
|
|
6569
|
+
if (start < 0)
|
|
6570
|
+
break;
|
|
6571
|
+
cursor = start + 1;
|
|
6572
|
+
if (html.startsWith("<!--", start) && !noCommentEnd) {
|
|
6573
|
+
const commentEnd = html.indexOf("-->", start + 4);
|
|
6574
|
+
if (commentEnd >= 0) {
|
|
6575
|
+
cursor = commentEnd + 3;
|
|
6576
|
+
continue;
|
|
6577
|
+
}
|
|
6578
|
+
noCommentEnd = true;
|
|
6579
|
+
}
|
|
6580
|
+
const nameStart = html[start + 1] === "/" ? start + 2 : start + 1;
|
|
6581
|
+
if (nameStart >= html.length || /[\s/>]/.test(html[nameStart]))
|
|
6582
|
+
continue;
|
|
6583
|
+
const end = html.indexOf(">", nameStart + 1);
|
|
6584
|
+
if (end < 0)
|
|
6585
|
+
break;
|
|
6586
|
+
cursor = end + 1;
|
|
6587
|
+
const raw = html.slice(start, cursor);
|
|
6588
|
+
if (raw.startsWith("<!--"))
|
|
6589
|
+
continue;
|
|
6590
|
+
yield { raw, end: cursor };
|
|
6591
|
+
}
|
|
6592
|
+
}
|
|
6507
6593
|
function isSingleRootElement(html) {
|
|
6508
6594
|
const trimmed = html.trim();
|
|
6509
6595
|
const match = trimmed.match(/^<(\w+)[\s>]/);
|
|
6510
6596
|
if (!match)
|
|
6511
6597
|
return false;
|
|
6512
|
-
if (/^<\w+[^>]*\/>$/.test(trimmed))
|
|
6513
|
-
return true;
|
|
6514
|
-
const tagPattern = /<!--[\s\S]*?-->|<\/?[^\s/>]+[^>]*>/g;
|
|
6515
6598
|
let depth = 0;
|
|
6516
|
-
|
|
6517
|
-
while (tagMatch = tagPattern.exec(trimmed)) {
|
|
6518
|
-
const raw = tagMatch[0];
|
|
6519
|
-
if (raw.startsWith("<!--"))
|
|
6520
|
-
continue;
|
|
6599
|
+
for (const { raw, end } of templateHtmlTags(trimmed)) {
|
|
6521
6600
|
if (raw.endsWith("/>")) {
|
|
6522
6601
|
if (depth === 0)
|
|
6523
|
-
return
|
|
6602
|
+
return end === trimmed.length;
|
|
6524
6603
|
continue;
|
|
6525
6604
|
}
|
|
6526
6605
|
depth += raw.startsWith("</") ? -1 : 1;
|
|
6527
|
-
if (depth === 0)
|
|
6528
|
-
return
|
|
6529
|
-
}
|
|
6606
|
+
if (depth === 0)
|
|
6607
|
+
return end === trimmed.length;
|
|
6530
6608
|
}
|
|
6531
6609
|
return false;
|
|
6532
6610
|
}
|
|
@@ -6590,7 +6668,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
6590
6668
|
return templateAttrExpr(keyName, transformExpr(tmplStr));
|
|
6591
6669
|
}
|
|
6592
6670
|
case "literal":
|
|
6593
|
-
return `${keyName}="${
|
|
6671
|
+
return `${keyName}="${escapeStaticTemplateHtml(v.value)}"`;
|
|
6594
6672
|
default:
|
|
6595
6673
|
return "";
|
|
6596
6674
|
}
|
|
@@ -6600,7 +6678,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
6600
6678
|
case "boolean-attr":
|
|
6601
6679
|
return attrName;
|
|
6602
6680
|
case "literal":
|
|
6603
|
-
return `${attrName}="${
|
|
6681
|
+
return `${attrName}="${escapeStaticTemplateHtml(v.value)}"`;
|
|
6604
6682
|
case "expression":
|
|
6605
6683
|
return templateAttrExpr(attrName, transformExpr(v.expr, v.templateExpr), v.presenceOrUndefined);
|
|
6606
6684
|
case "template": {
|
|
@@ -6626,7 +6704,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
6626
6704
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
6627
6705
|
}
|
|
6628
6706
|
case "text":
|
|
6629
|
-
return
|
|
6707
|
+
return escapeStaticTemplateHtml(node.value);
|
|
6630
6708
|
case "expression": {
|
|
6631
6709
|
if (node.expr === "null" || node.expr === "undefined")
|
|
6632
6710
|
return "";
|
|
@@ -6654,7 +6732,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
6654
6732
|
if (node.name === "Portal") {
|
|
6655
6733
|
return node.children.map(recurse).join("");
|
|
6656
6734
|
}
|
|
6657
|
-
const propsEntries = node.props.filter(
|
|
6735
|
+
const propsEntries = node.props.filter(keepsTemplateComponentProp).filter((p) => p.name !== "ref" && !isEventHandlerName(p.name)).map((p) => {
|
|
6658
6736
|
if (p.clientOnly)
|
|
6659
6737
|
return null;
|
|
6660
6738
|
switch (p.value.kind) {
|
|
@@ -6671,7 +6749,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
6671
6749
|
case "expression":
|
|
6672
6750
|
return `${quotePropName(p.name)}: ${transformExpr(p.value.expr, p.value.templateExpr)}`;
|
|
6673
6751
|
case "spread":
|
|
6674
|
-
return
|
|
6752
|
+
return templatePropEntry(p, transformExpr(p.value.expr, p.value.templateExpr));
|
|
6675
6753
|
case "template": {
|
|
6676
6754
|
const valueStr = attrValueToString(p.value, { useTemplate: true });
|
|
6677
6755
|
return `${quotePropName(p.name)}: ${transformExpr(valueStr)}`;
|
|
@@ -6867,18 +6945,19 @@ function computeDeferredChildSlots(node, ctx, inlinableConstants, unsafeLocalNam
|
|
|
6867
6945
|
function generateCsrTemplateWithOpts(node, opts) {
|
|
6868
6946
|
const { restSpreadNames, propsObjectName, restPropsName, csrEnv, unsafeLocalNames, loopDepth = 0 } = opts;
|
|
6869
6947
|
const env = csrEnv ?? { substitutions: new Map, propsObjectName: propsObjectName ?? null };
|
|
6870
|
-
const
|
|
6948
|
+
const transformExprOrUnsafe = (expr, templateExpr) => {
|
|
6871
6949
|
const source = templateExpr ?? expr;
|
|
6872
6950
|
if (!source)
|
|
6873
6951
|
return source;
|
|
6874
6952
|
const { rewritten, freeIdentifiers: freeIdentifiers2, writes } = csrSubstitute(source, env, opts.scope);
|
|
6875
6953
|
if (writes.size > 0)
|
|
6876
|
-
return
|
|
6954
|
+
return null;
|
|
6877
6955
|
if (unsafeLocalNames && unsafeLocalNames.size > 0 && setIntersects(freeIdentifiers2, unsafeLocalNames)) {
|
|
6878
|
-
return
|
|
6956
|
+
return null;
|
|
6879
6957
|
}
|
|
6880
6958
|
return rewritePropsObjectRef(rewritten, propsObjectName ?? null, restPropsName ?? null, { enclosingScope: opts.scope });
|
|
6881
6959
|
};
|
|
6960
|
+
const transformExpr = (expr, templateExpr) => transformExprOrUnsafe(expr, templateExpr) ?? UNSAFE_TEMPLATE_EXPR;
|
|
6882
6961
|
const recurse = (n) => generateCsrTemplateWithOpts(n, opts);
|
|
6883
6962
|
const childrenRecurse = (n) => generateCsrTemplateWithOpts(n, { ...opts, inHoistedChildren: false });
|
|
6884
6963
|
switch (node.type) {
|
|
@@ -6915,7 +6994,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
6915
6994
|
case "boolean-attr":
|
|
6916
6995
|
return keyName;
|
|
6917
6996
|
case "literal":
|
|
6918
|
-
return `${keyName}="${
|
|
6997
|
+
return `${keyName}="${escapeStaticTemplateHtml(v.value)}"`;
|
|
6919
6998
|
case "expression":
|
|
6920
6999
|
return templateAttrExpr(keyName, transformExpr(v.expr, v.templateExpr), v.presenceOrUndefined);
|
|
6921
7000
|
case "template": {
|
|
@@ -6932,7 +7011,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
6932
7011
|
case "boolean-attr":
|
|
6933
7012
|
return attrName;
|
|
6934
7013
|
case "literal":
|
|
6935
|
-
return `${attrName}="${
|
|
7014
|
+
return `${attrName}="${escapeStaticTemplateHtml(v.value)}"`;
|
|
6936
7015
|
case "expression":
|
|
6937
7016
|
return templateAttrExpr(attrName, transformExpr(v.expr, v.templateExpr), v.presenceOrUndefined);
|
|
6938
7017
|
case "template": {
|
|
@@ -6958,7 +7037,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
6958
7037
|
return `<${node.tag}${attrs ? " " + attrs : ""} />`;
|
|
6959
7038
|
}
|
|
6960
7039
|
case "text":
|
|
6961
|
-
return
|
|
7040
|
+
return escapeStaticTemplateHtml(node.value);
|
|
6962
7041
|
case "expression":
|
|
6963
7042
|
if (node.expr === "null" || node.expr === "undefined")
|
|
6964
7043
|
return "";
|
|
@@ -6968,8 +7047,8 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
6968
7047
|
return `<!--bf:${node.slotId}--><!--/-->`;
|
|
6969
7048
|
}
|
|
6970
7049
|
{
|
|
6971
|
-
const transformed =
|
|
6972
|
-
const hole = interp(transformed ===
|
|
7050
|
+
const transformed = transformExprOrUnsafe(node.expr, node.templateExpr);
|
|
7051
|
+
const hole = interp(transformed === null ? EMPTY_MARKUP : spliceChildValue(node, transformed, { markupSlotIds: opts.markupSlotIds }));
|
|
6973
7052
|
return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
|
|
6974
7053
|
}
|
|
6975
7054
|
case "conditional": {
|
|
@@ -6991,7 +7070,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
6991
7070
|
if (node.slotId && opts.deferredChildSlots?.has(node.slotId)) {
|
|
6992
7071
|
return `<div ${DATA_BF_PH}="${node.slotId}"></div>`;
|
|
6993
7072
|
}
|
|
6994
|
-
const propsEntries = node.props.filter(
|
|
7073
|
+
const propsEntries = node.props.filter(keepsTemplateComponentProp).filter((p) => p.name !== "ref" && !isEventHandlerName(p.name)).map((p) => {
|
|
6995
7074
|
if (p.clientOnly)
|
|
6996
7075
|
return null;
|
|
6997
7076
|
switch (p.value.kind) {
|
|
@@ -7007,17 +7086,17 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
7007
7086
|
return `${quotePropName(p.name)}: true`;
|
|
7008
7087
|
case "expression":
|
|
7009
7088
|
case "spread": {
|
|
7010
|
-
const transformed =
|
|
7011
|
-
if (transformed ===
|
|
7089
|
+
const transformed = transformExprOrUnsafe(p.value.expr, p.value.templateExpr);
|
|
7090
|
+
if (transformed === null)
|
|
7012
7091
|
return null;
|
|
7013
|
-
return
|
|
7092
|
+
return templatePropEntry(p, transformed);
|
|
7014
7093
|
}
|
|
7015
7094
|
case "template": {
|
|
7016
7095
|
const valueStr = attrValueToString(p.value, { useTemplate: true });
|
|
7017
7096
|
if (!valueStr)
|
|
7018
7097
|
return null;
|
|
7019
|
-
const transformed =
|
|
7020
|
-
if (transformed ===
|
|
7098
|
+
const transformed = transformExprOrUnsafe(valueStr);
|
|
7099
|
+
if (transformed === null)
|
|
7021
7100
|
return null;
|
|
7022
7101
|
return `${quotePropName(p.name)}: ${transformed}`;
|
|
7023
7102
|
}
|
|
@@ -7039,8 +7118,8 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
7039
7118
|
const hoistValues = [];
|
|
7040
7119
|
for (const name of hoisted) {
|
|
7041
7120
|
const sub = env.substitutions.get(name);
|
|
7042
|
-
const value =
|
|
7043
|
-
if (value ===
|
|
7121
|
+
const value = transformExprOrUnsafe(sub.kind === "call" ? `${name}()` : name);
|
|
7122
|
+
if (value === null)
|
|
7044
7123
|
continue;
|
|
7045
7124
|
const param = `__bf_outer_${name}`;
|
|
7046
7125
|
hoistParams.push(param);
|
|
@@ -7061,8 +7140,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
7061
7140
|
}
|
|
7062
7141
|
const indexParam = node.index ? `, ${node.index}` : "";
|
|
7063
7142
|
const chainedTemplateArray = node.sortComparator || node.filterPredicate ? applyLoopChain(node, node.templateArray) : node.templateArray;
|
|
7064
|
-
const
|
|
7065
|
-
const safeRawArrayExpr = rawArrayExpr === UNSAFE_TEMPLATE_EXPR ? "[]" : rawArrayExpr;
|
|
7143
|
+
const safeRawArrayExpr = transformExprOrUnsafe(node.array, chainedTemplateArray) ?? "[]";
|
|
7066
7144
|
const { array: iterArrayExpr, callbackParam } = applyIterationShape(node, safeRawArrayExpr, indexParam);
|
|
7067
7145
|
const iterMethod = node.method ?? "map";
|
|
7068
7146
|
let mapExpr;
|
|
@@ -7668,6 +7746,7 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
|
7668
7746
|
reactiveShapedHelpers: new Set,
|
|
7669
7747
|
cleanFactoryImports: new Set,
|
|
7670
7748
|
signalTupleRefs: new Map,
|
|
7749
|
+
templatePropReadWriters: [],
|
|
7671
7750
|
propsType: null,
|
|
7672
7751
|
propsParams: [],
|
|
7673
7752
|
propsObjectName: null,
|
|
@@ -8173,8 +8252,8 @@ function augmentInheritedPropAccesses(ir) {
|
|
|
8173
8252
|
const v = prop.value;
|
|
8174
8253
|
if (v?.parts) {
|
|
8175
8254
|
for (const part of v.parts) {
|
|
8176
|
-
if (part.type === "
|
|
8177
|
-
scan(part.
|
|
8255
|
+
if (part.type === "expression")
|
|
8256
|
+
scan(part.expr);
|
|
8178
8257
|
else if (part.type === "ternary") {
|
|
8179
8258
|
scan(part.condition);
|
|
8180
8259
|
scan(part.whenTrue);
|
|
@@ -8192,8 +8271,8 @@ function augmentInheritedPropAccesses(ir) {
|
|
|
8192
8271
|
const v = attr.value;
|
|
8193
8272
|
if (v?.parts) {
|
|
8194
8273
|
for (const part of v.parts) {
|
|
8195
|
-
if (part.type === "
|
|
8196
|
-
scan(part.
|
|
8274
|
+
if (part.type === "expression")
|
|
8275
|
+
scan(part.expr);
|
|
8197
8276
|
else if (part.type === "ternary") {
|
|
8198
8277
|
scan(part.condition);
|
|
8199
8278
|
scan(part.whenTrue);
|
|
@@ -8631,18 +8710,64 @@ function memoSeedExpr(memo) {
|
|
|
8631
8710
|
return memo.bodyExpr?.trim() ?? "";
|
|
8632
8711
|
return memo.parsed ? stringifyParsedExpr(memo.parsed) : "";
|
|
8633
8712
|
}
|
|
8634
|
-
function
|
|
8713
|
+
function hasComputedDefault(p) {
|
|
8714
|
+
if (p.isRest || p.defaultValue === undefined || !p.parsed || p.parsed.kind === "arrow")
|
|
8715
|
+
return false;
|
|
8716
|
+
return p.defaultParts !== undefined || !isLiteralData(p.parsed);
|
|
8717
|
+
}
|
|
8718
|
+
function isLiteralData(e) {
|
|
8719
|
+
switch (e.kind) {
|
|
8720
|
+
case "literal":
|
|
8721
|
+
return true;
|
|
8722
|
+
case "identifier":
|
|
8723
|
+
return e.name === "undefined";
|
|
8724
|
+
case "unary":
|
|
8725
|
+
return (e.op === "-" || e.op === "+") && e.argument.kind === "literal" && e.argument.literalType === "number";
|
|
8726
|
+
case "template-literal":
|
|
8727
|
+
return e.parts.every((part) => part.type === "string");
|
|
8728
|
+
case "array-literal":
|
|
8729
|
+
return e.elements.every(isLiteralData);
|
|
8730
|
+
case "object-literal":
|
|
8731
|
+
return e.properties.every((prop) => prop.kind !== "spread" && isLiteralData(prop.value));
|
|
8732
|
+
default:
|
|
8733
|
+
return false;
|
|
8734
|
+
}
|
|
8735
|
+
}
|
|
8736
|
+
function dependentPropDefaultSteps(metadata, inlined) {
|
|
8737
|
+
const { readable, available, unshadowed } = propDefaultScope(metadata, inlined);
|
|
8635
8738
|
const steps = [];
|
|
8636
8739
|
for (const p of inDefaultReadOrder(metadata.propsParams)) {
|
|
8637
|
-
if (p
|
|
8740
|
+
if (!hasComputedDefault(p) || !p.parsed || !readable.has(p.name))
|
|
8638
8741
|
continue;
|
|
8639
8742
|
const parsed = { kind: "logical", op: "??", left: { kind: "identifier", name: p.name }, right: p.parsed };
|
|
8640
|
-
const step = classify(p.name, "prop", stringifyParsedExpr(parsed), parsed, available,
|
|
8743
|
+
const step = classify(p.name, "prop", stringifyParsedExpr(parsed), parsed, available, unshadowed);
|
|
8641
8744
|
if (step.kind === "derived")
|
|
8642
8745
|
steps.push(step);
|
|
8643
8746
|
}
|
|
8644
8747
|
return steps;
|
|
8645
8748
|
}
|
|
8749
|
+
function propDefaultScope(metadata, inlined) {
|
|
8750
|
+
const readable = new Set(templatePropReadParams(metadata).map((p) => p.name));
|
|
8751
|
+
const locals = new Set;
|
|
8752
|
+
for (const c of metadata.localConstants ?? [])
|
|
8753
|
+
if (!c.isModule)
|
|
8754
|
+
locals.add(c.name);
|
|
8755
|
+
for (const f of metadata.localFunctions ?? [])
|
|
8756
|
+
if (!f.isModule)
|
|
8757
|
+
locals.add(f.name);
|
|
8758
|
+
for (const s of metadata.signals) {
|
|
8759
|
+
locals.add(s.getter);
|
|
8760
|
+
if (s.setter)
|
|
8761
|
+
locals.add(s.setter);
|
|
8762
|
+
}
|
|
8763
|
+
for (const m of metadata.memos)
|
|
8764
|
+
locals.add(m.name);
|
|
8765
|
+
const unshadowed = new Set([...inlined].filter((name) => !locals.has(name)));
|
|
8766
|
+
const available = new Set([...readable, ...unshadowed]);
|
|
8767
|
+
if (metadata.propsObjectName)
|
|
8768
|
+
available.add(metadata.propsObjectName);
|
|
8769
|
+
return { readable, available, unshadowed };
|
|
8770
|
+
}
|
|
8646
8771
|
function inDefaultReadOrder(params) {
|
|
8647
8772
|
const byName = new Map(params.filter((p) => !p.isRest).map((p) => [p.name, p]));
|
|
8648
8773
|
const ordered = [];
|
|
@@ -8671,7 +8796,7 @@ function computeSsrSeedPlan(metadata) {
|
|
|
8671
8796
|
const available = new Set(baseScope);
|
|
8672
8797
|
const localConsts = localConstExprsByName(metadata);
|
|
8673
8798
|
const steps = [];
|
|
8674
|
-
steps.push(...dependentPropDefaultSteps(metadata,
|
|
8799
|
+
steps.push(...dependentPropDefaultSteps(metadata, inlined));
|
|
8675
8800
|
for (const signal of metadata.signals) {
|
|
8676
8801
|
if (signal.envReader) {
|
|
8677
8802
|
const reader = envSignalReaderFor(signal.envReader);
|
|
@@ -8725,7 +8850,8 @@ var UNRESOLVED = Symbol("unresolved");
|
|
|
8725
8850
|
var NO_RETURN = Symbol("no-return");
|
|
8726
8851
|
function addPropSsrDefaults(metadata, propsLike, out) {
|
|
8727
8852
|
const plan = metadata.ssrSeedPlan ?? computeSsrSeedPlan(metadata);
|
|
8728
|
-
const
|
|
8853
|
+
const readsEarlier = new Set(metadata.propsParams.filter((p) => p.defaultParts).map((p) => p.name));
|
|
8854
|
+
const templateDefaulted = new Set(plan.steps.filter((s) => s.kind === "derived" && s.origin === "prop" && readsEarlier.has(s.name)).map((s) => s.name));
|
|
8729
8855
|
for (const p of metadata.propsParams) {
|
|
8730
8856
|
if (p.isRest)
|
|
8731
8857
|
continue;
|
|
@@ -9203,25 +9329,69 @@ function programWithSeparatedSource(program, filePath, source) {
|
|
|
9203
9329
|
}
|
|
9204
9330
|
} });
|
|
9205
9331
|
}
|
|
9206
|
-
function collidingBindings(ctx, propsObjectName) {
|
|
9207
|
-
const propNames = new Set(ctx.propsParams.map((p) => p.name.toLowerCase()));
|
|
9332
|
+
function collidingBindings(ctx, propsObjectName, propNames) {
|
|
9208
9333
|
const localConsts = localConstValuesByName(ctx);
|
|
9209
|
-
const collides = (name
|
|
9210
|
-
const
|
|
9211
|
-
const
|
|
9334
|
+
const collides = (name) => propNames.has(name.toLowerCase());
|
|
9335
|
+
const selfDerived = (name, derivation) => referencesOwnProp(derivation, propsObjectName, name, localConsts);
|
|
9336
|
+
const signals = ctx.signals.filter((s) => !s.isModule && !s.getterElided && !s.envReader && collides(s.getter)).map((s) => ({ name: s.getter, loc: s.loc, prefix: "bfSignal", selfDerived: selfDerived(s.getter, s.initialValue) }));
|
|
9337
|
+
const memos = ctx.memos.filter((m) => !m.isModule && collides(m.name)).map((m) => ({ name: m.name, loc: m.loc, prefix: "bfMemo", selfDerived: selfDerived(m.name, m.computation) }));
|
|
9212
9338
|
return [...signals, ...memos];
|
|
9213
9339
|
}
|
|
9340
|
+
function propsReadKey(node, propsObjectName) {
|
|
9341
|
+
if (ts21.isPropertyAccessExpression(node) && ts21.isIdentifier(node.name)) {
|
|
9342
|
+
return isNamedReceiver(node.expression, propsObjectName) ? { receiver: node.expression, key: node.name.text } : undefined;
|
|
9343
|
+
}
|
|
9344
|
+
if (!ts21.isElementAccessExpression(node) || !isNamedReceiver(node.expression, propsObjectName))
|
|
9345
|
+
return;
|
|
9346
|
+
const arg = node.argumentExpression;
|
|
9347
|
+
const literal = ts21.isStringLiteral(arg) || ts21.isNoSubstitutionTemplateLiteral(arg) || ts21.isNumericLiteral(arg);
|
|
9348
|
+
return { receiver: node.expression, key: literal ? arg.text : null };
|
|
9349
|
+
}
|
|
9350
|
+
function isNamedReceiver(expr, propsObjectName) {
|
|
9351
|
+
return ts21.isIdentifier(expr) && expr.text === propsObjectName;
|
|
9352
|
+
}
|
|
9353
|
+
function propsReads(component, propsObjectName, isPropsObject) {
|
|
9354
|
+
const reads = [];
|
|
9355
|
+
function visit2(node) {
|
|
9356
|
+
const read = propsReadKey(node, propsObjectName);
|
|
9357
|
+
if (read && isPropsObject(read.receiver)) {
|
|
9358
|
+
reads.push({ name: read.key === null ? null : read.key.toLowerCase(), pos: node.getStart() });
|
|
9359
|
+
}
|
|
9360
|
+
ts21.forEachChild(node, visit2);
|
|
9361
|
+
}
|
|
9362
|
+
visit2(component);
|
|
9363
|
+
return reads;
|
|
9364
|
+
}
|
|
9365
|
+
function readNames(reads) {
|
|
9366
|
+
return reads.flatMap((r) => r.name === null ? [] : [r.name]);
|
|
9367
|
+
}
|
|
9368
|
+
function needsSeparation(binding, declaration, reads) {
|
|
9369
|
+
if (!binding.selfDerived)
|
|
9370
|
+
return true;
|
|
9371
|
+
const init = declaration.initializer;
|
|
9372
|
+
const name = binding.name.toLowerCase();
|
|
9373
|
+
return reads.some((r) => (r.name === null || r.name === name) && (!init || r.pos < init.getStart() || r.pos >= init.getEnd()));
|
|
9374
|
+
}
|
|
9214
9375
|
function separateSignalPropBindings(ctx, isNonReference) {
|
|
9215
|
-
|
|
9376
|
+
const propsObjectName = ctx.propsObjectName;
|
|
9377
|
+
const component = ctx.componentNode;
|
|
9378
|
+
if (!propsObjectName || !component)
|
|
9216
9379
|
return null;
|
|
9217
|
-
const
|
|
9218
|
-
|
|
9380
|
+
const declared = ctx.propsParams.map((p) => p.name.toLowerCase());
|
|
9381
|
+
const spelled = readNames(propsReads(component, propsObjectName, () => true));
|
|
9382
|
+
if (collidingBindings(ctx, propsObjectName, new Set([...declared, ...spelled])).length === 0)
|
|
9219
9383
|
return null;
|
|
9220
9384
|
const sf = ctx.sourceFile;
|
|
9221
9385
|
const checker = ctx.checker ?? ts21.createProgram([sf.fileName], { noLib: true, noResolve: true }, {
|
|
9222
9386
|
...ts21.createCompilerHost({ noLib: true, noResolve: true }),
|
|
9223
9387
|
getSourceFile: () => sf
|
|
9224
9388
|
}).getTypeChecker();
|
|
9389
|
+
const param = component.parameters.find((p) => ts21.isIdentifier(p.name) && p.name.text === propsObjectName);
|
|
9390
|
+
const paramSymbol = param && checker.getSymbolAtLocation(param.name);
|
|
9391
|
+
const reads = paramSymbol ? propsReads(component, propsObjectName, (id) => checker.getSymbolAtLocation(id) === paramSymbol) : [];
|
|
9392
|
+
const candidates = collidingBindings(ctx, propsObjectName, new Set([...declared, ...readNames(reads)]));
|
|
9393
|
+
if (candidates.length === 0)
|
|
9394
|
+
return null;
|
|
9225
9395
|
const occupied = new Set;
|
|
9226
9396
|
function collectNames(node) {
|
|
9227
9397
|
if (ts21.isIdentifier(node))
|
|
@@ -9239,7 +9409,7 @@ function separateSignalPropBindings(ctx, isNonReference) {
|
|
|
9239
9409
|
function collectBindings(node) {
|
|
9240
9410
|
if (ts21.isVariableDeclaration(node)) {
|
|
9241
9411
|
const binding = declarations.get(node.getStart(sf));
|
|
9242
|
-
if (binding) {
|
|
9412
|
+
if (binding && needsSeparation(binding, node, reads)) {
|
|
9243
9413
|
const names = ts21.isIdentifier(node.name) ? [node.name] : ts21.isArrayBindingPattern(node.name) ? node.name.elements.flatMap((e) => ts21.isBindingElement(e) && ts21.isIdentifier(e.name) ? [e.name] : []) : [];
|
|
9244
9414
|
const id = names.find((n) => n.text === binding.name);
|
|
9245
9415
|
const symbol = id && checker.getSymbolAtLocation(id);
|
|
@@ -9256,7 +9426,7 @@ function separateSignalPropBindings(ctx, isNonReference) {
|
|
|
9256
9426
|
}
|
|
9257
9427
|
ts21.forEachChild(node, collectBindings);
|
|
9258
9428
|
}
|
|
9259
|
-
collectBindings(
|
|
9429
|
+
collectBindings(component);
|
|
9260
9430
|
const edits = [];
|
|
9261
9431
|
function collectEdits(node) {
|
|
9262
9432
|
if (ts21.isIdentifier(node) && !isNonReference(node)) {
|
|
@@ -9273,7 +9443,7 @@ function separateSignalPropBindings(ctx, isNonReference) {
|
|
|
9273
9443
|
}
|
|
9274
9444
|
ts21.forEachChild(node, collectEdits);
|
|
9275
9445
|
}
|
|
9276
|
-
collectEdits(
|
|
9446
|
+
collectEdits(component);
|
|
9277
9447
|
if (edits.length === 0)
|
|
9278
9448
|
return null;
|
|
9279
9449
|
let source = sf.text;
|
|
@@ -9331,9 +9501,12 @@ function findBrandPackageImportLoc(sourceFile, filePath) {
|
|
|
9331
9501
|
return null;
|
|
9332
9502
|
}
|
|
9333
9503
|
function createProgramForFile(source, filePath, hostOptions = {}) {
|
|
9504
|
+
return buildProgramForFile(source, filePath, hostOptions);
|
|
9505
|
+
}
|
|
9506
|
+
function buildProgramForFile(source, filePath, hostOptions) {
|
|
9334
9507
|
incrementCounter("programCreations");
|
|
9335
9508
|
try {
|
|
9336
|
-
const { currentDirectory } = hostOptions;
|
|
9509
|
+
const { currentDirectory, sourceFiles } = hostOptions;
|
|
9337
9510
|
const resolveFrom = (fileName) => currentDirectory === undefined ? path_default.resolve(fileName) : path_default.resolve(currentDirectory, fileName);
|
|
9338
9511
|
const normalizedPath = resolveFrom(filePath);
|
|
9339
9512
|
const compilerOptions = {
|
|
@@ -9352,8 +9525,14 @@ function createProgramForFile(source, filePath, hostOptions = {}) {
|
|
|
9352
9525
|
...currentDirectory === undefined ? {} : { getCurrentDirectory: () => currentDirectory },
|
|
9353
9526
|
getSourceFile(fileName, languageVersion) {
|
|
9354
9527
|
if (resolveFrom(fileName) === normalizedPath) {
|
|
9528
|
+
if (sourceFiles)
|
|
9529
|
+
return sourceFiles.get(fileName, languageVersion, source, VIRTUAL_SOURCE_PARSE);
|
|
9355
9530
|
return ts22.createSourceFile(fileName, source, languageVersion, true, ts22.ScriptKind.TSX);
|
|
9356
9531
|
}
|
|
9532
|
+
if (sourceFiles) {
|
|
9533
|
+
const text = defaultHost.readFile(fileName);
|
|
9534
|
+
return text === undefined ? undefined : sourceFiles.get(fileName, languageVersion, text, DISK_FILE_PARSE);
|
|
9535
|
+
}
|
|
9357
9536
|
return defaultHost.getSourceFile(fileName, languageVersion);
|
|
9358
9537
|
},
|
|
9359
9538
|
fileExists(fileName) {
|
|
@@ -9384,8 +9563,34 @@ function rewriteSourceForAnalysis(source, filePath, prescan) {
|
|
|
9384
9563
|
function createAnchoredProgram(source, filename, anchorDir) {
|
|
9385
9564
|
if (!needsTypeBasedDetection(source))
|
|
9386
9565
|
return;
|
|
9387
|
-
return
|
|
9566
|
+
return buildProgramForFile(source, filename, { currentDirectory: anchorDir, sourceFiles: anchoredSourceFiles })?.program;
|
|
9388
9567
|
}
|
|
9568
|
+
|
|
9569
|
+
class SourceFileCache {
|
|
9570
|
+
files = new Map;
|
|
9571
|
+
get(fileName, languageVersion, text, parse2) {
|
|
9572
|
+
const key = `${fileName}\x00${parseOptionsKey(languageVersion)}\x00${parse2.scriptKind ?? ""}\x00${parse2.setParentNodes}`;
|
|
9573
|
+
let byText = this.files.get(key);
|
|
9574
|
+
if (!byText) {
|
|
9575
|
+
byText = new Map;
|
|
9576
|
+
this.files.set(key, byText);
|
|
9577
|
+
}
|
|
9578
|
+
const cached = byText.get(text);
|
|
9579
|
+
if (cached)
|
|
9580
|
+
return cached;
|
|
9581
|
+
const parsed = ts22.createSourceFile(fileName, text, languageVersion, parse2.setParentNodes, parse2.scriptKind);
|
|
9582
|
+
byText.set(text, parsed);
|
|
9583
|
+
return parsed;
|
|
9584
|
+
}
|
|
9585
|
+
}
|
|
9586
|
+
var VIRTUAL_SOURCE_PARSE = { scriptKind: ts22.ScriptKind.TSX, setParentNodes: true };
|
|
9587
|
+
var DISK_FILE_PARSE = { setParentNodes: false };
|
|
9588
|
+
function parseOptionsKey(languageVersion) {
|
|
9589
|
+
if (typeof languageVersion === "number")
|
|
9590
|
+
return String(languageVersion);
|
|
9591
|
+
return `${languageVersion.languageVersion}:${languageVersion.impliedNodeFormat ?? ""}:${languageVersion.jsDocParsingMode ?? ""}`;
|
|
9592
|
+
}
|
|
9593
|
+
var anchoredSourceFiles = new SourceFileCache;
|
|
9389
9594
|
function parseSignalInitializer(signal, ctx) {
|
|
9390
9595
|
if (!signal.initialValue)
|
|
9391
9596
|
return;
|
|
@@ -10013,27 +10218,24 @@ function collectSignal(node, ctx) {
|
|
|
10013
10218
|
const type = signalTypeInfo(callExpr, initialValue, ctx);
|
|
10014
10219
|
const envReader = resolveEnvSignalKey(callExpr, ctx) ?? undefined;
|
|
10015
10220
|
const envFactory = envReader ? callExpr.expression.getText(ctx.sourceFile) : undefined;
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
const propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
10019
|
-
if (propNames.size > 0) {
|
|
10020
|
-
const propAliases = buildPropAliasMap(ctx.propsParams);
|
|
10021
|
-
templateInitialValue = rewriteBarePropRefs(initialValue, callExpr.arguments[0], propNames, undefined, propAliases, destructuredPropTemplateRead(ctx));
|
|
10022
|
-
}
|
|
10023
|
-
}
|
|
10024
|
-
ctx.signals.push({
|
|
10221
|
+
const seedNode = callExpr.arguments[0];
|
|
10222
|
+
const signal = {
|
|
10025
10223
|
getter,
|
|
10026
10224
|
setter,
|
|
10027
10225
|
getterElided: getterElided || undefined,
|
|
10028
10226
|
initialValue,
|
|
10029
10227
|
typedInitialValue: typedInitialValue !== initialValue ? typedInitialValue : undefined,
|
|
10030
|
-
templateInitialValue,
|
|
10031
10228
|
type,
|
|
10032
10229
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
10033
|
-
initialFreeIdentifiers:
|
|
10230
|
+
initialFreeIdentifiers: seedNode ? extractFreeIdentifiersFromNode(seedNode) : new Set,
|
|
10034
10231
|
envReader,
|
|
10035
10232
|
envFactory
|
|
10036
|
-
}
|
|
10233
|
+
};
|
|
10234
|
+
ctx.signals.push(signal);
|
|
10235
|
+
if (seedNode)
|
|
10236
|
+
deferTemplatePropRead(initialValue, seedNode, ctx, (text) => {
|
|
10237
|
+
signal.templateInitialValue = text;
|
|
10238
|
+
});
|
|
10037
10239
|
}
|
|
10038
10240
|
function collectFactorySignal(node, pattern, callExpr, kind, ctx) {
|
|
10039
10241
|
const elements = pattern.elements;
|
|
@@ -10060,23 +10262,14 @@ function collectFactorySignal(node, pattern, callExpr, kind, ctx) {
|
|
|
10060
10262
|
} else if (initialNode.kind !== "absent") {
|
|
10061
10263
|
type = inferTypeFromValue(initialValue);
|
|
10062
10264
|
}
|
|
10063
|
-
let templateInitialValue;
|
|
10064
|
-
if (!ctx.propsObjectName && initialNode.kind === "expression") {
|
|
10065
|
-
const propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
10066
|
-
if (propNames.size > 0) {
|
|
10067
|
-
const propAliases = buildPropAliasMap(ctx.propsParams);
|
|
10068
|
-
templateInitialValue = rewriteBarePropRefs(initialValue, initialNode.node, propNames, undefined, propAliases, destructuredPropTemplateRead(ctx));
|
|
10069
|
-
}
|
|
10070
|
-
}
|
|
10071
10265
|
const argTexts = callExpr.arguments.map((arg) => ctx.getJS(arg));
|
|
10072
10266
|
const requestArg = callExpr.arguments[0];
|
|
10073
|
-
|
|
10267
|
+
const signal = {
|
|
10074
10268
|
getter: valueName ?? `__bfGet_${action}`,
|
|
10075
10269
|
setter: null,
|
|
10076
10270
|
getterElided: getterElided || undefined,
|
|
10077
10271
|
initialValue,
|
|
10078
10272
|
typedInitialValue: typedInitialValue !== undefined && typedInitialValue !== initialValue ? typedInitialValue : undefined,
|
|
10079
|
-
templateInitialValue,
|
|
10080
10273
|
type,
|
|
10081
10274
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
10082
10275
|
initialFreeIdentifiers,
|
|
@@ -10088,7 +10281,13 @@ function collectFactorySignal(node, pattern, callExpr, kind, ctx) {
|
|
|
10088
10281
|
requestFreeIdentifiers: requestArg ? extractFreeIdentifiersFromNode(requestArg) : new Set,
|
|
10089
10282
|
action
|
|
10090
10283
|
}
|
|
10091
|
-
}
|
|
10284
|
+
};
|
|
10285
|
+
ctx.signals.push(signal);
|
|
10286
|
+
if (initialNode.kind === "expression") {
|
|
10287
|
+
deferTemplatePropRead(initialValue, initialNode.node, ctx, (text) => {
|
|
10288
|
+
signal.templateInitialValue = text;
|
|
10289
|
+
});
|
|
10290
|
+
}
|
|
10092
10291
|
}
|
|
10093
10292
|
function factoryInitialNode(options) {
|
|
10094
10293
|
if (!options)
|
|
@@ -10345,18 +10544,15 @@ function memoStructuredBody(callback, ctx) {
|
|
|
10345
10544
|
return { parsed, parsedBlock, parsedBlockComplete };
|
|
10346
10545
|
}
|
|
10347
10546
|
function memoBodyFields(body, ctx) {
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
}
|
|
10358
|
-
}
|
|
10359
|
-
return { bodyExpr, bodyExprIsCall: body.call || undefined, templateBodyExpr };
|
|
10547
|
+
return { bodyExpr: asMemoBodyExpr(ctx.getJS(body.node), body.call), bodyExprIsCall: body.call || undefined };
|
|
10548
|
+
}
|
|
10549
|
+
function asMemoBodyExpr(text, call) {
|
|
10550
|
+
return call ? `(${text})()` : text;
|
|
10551
|
+
}
|
|
10552
|
+
function deferMemoTemplateBody(memo, body, ctx) {
|
|
10553
|
+
deferTemplatePropRead(ctx.getJS(body.node), body.node, ctx, (text) => {
|
|
10554
|
+
memo.templateBodyExpr = text === undefined ? undefined : asMemoBodyExpr(text, body.call);
|
|
10555
|
+
});
|
|
10360
10556
|
}
|
|
10361
10557
|
function collectMemo(node, ctx) {
|
|
10362
10558
|
const name = node.name.text;
|
|
@@ -10404,6 +10600,8 @@ function collectMemo(node, ctx) {
|
|
|
10404
10600
|
computationFreeIdentifiers: callExpr.arguments[0] ? extractFreeIdentifiersFromNode(callExpr.arguments[0]) : new Set
|
|
10405
10601
|
};
|
|
10406
10602
|
ctx.memos.push(memo);
|
|
10603
|
+
if (body)
|
|
10604
|
+
deferMemoTemplateBody(memo, body, ctx);
|
|
10407
10605
|
markBlockMemo(memo, blockTyped, body?.node, ctx);
|
|
10408
10606
|
}
|
|
10409
10607
|
function markBlockMemo(memo, blockTyped, bodyNode, ctx) {
|
|
@@ -11349,6 +11547,20 @@ function destructuredPropTemplateRead(ctx) {
|
|
|
11349
11547
|
const byName = new Map(ctx.propsParams.filter((p) => !p.isRest).map((p) => [p.name, p]));
|
|
11350
11548
|
return (localName, callerKey) => livePropReadExpr(byName.get(localName) ?? { name: localName, sourceName: callerKey }, undefined, false);
|
|
11351
11549
|
}
|
|
11550
|
+
function deferTemplatePropRead(text, node, ctx, write) {
|
|
11551
|
+
ctx.templatePropReadWriters.push(() => {
|
|
11552
|
+
const readable = templatePropReadParams(ctx);
|
|
11553
|
+
if (readable.length === 0)
|
|
11554
|
+
return;
|
|
11555
|
+
const propNames = new Set(readable.map((p) => p.name));
|
|
11556
|
+
write(rewriteBarePropRefs(text, node, propNames, undefined, buildPropAliasMap(readable), destructuredPropTemplateRead(ctx)));
|
|
11557
|
+
});
|
|
11558
|
+
}
|
|
11559
|
+
function writeTemplatePropReads(ctx) {
|
|
11560
|
+
for (const write of ctx.templatePropReadWriters)
|
|
11561
|
+
write();
|
|
11562
|
+
ctx.templatePropReadWriters.length = 0;
|
|
11563
|
+
}
|
|
11352
11564
|
function bindingElementDefaultFields(initializer, ctx, earlier = new Map) {
|
|
11353
11565
|
const defaultValue = initializer ? ctx.getJS(initializer) : undefined;
|
|
11354
11566
|
const defaultContainsArrow = initializer ? nodeContainsArrow(initializer) : false;
|
|
@@ -11605,6 +11817,7 @@ function extractProps(param, ctx) {
|
|
|
11605
11817
|
const info = {
|
|
11606
11818
|
name: localName,
|
|
11607
11819
|
type: resolvedType,
|
|
11820
|
+
...unresolvedDeclaredType(member),
|
|
11608
11821
|
optional: !!member?.optional || !!element.initializer,
|
|
11609
11822
|
...bindingElementDefaultFields(element.initializer, ctx, earlier),
|
|
11610
11823
|
...sourcePropName !== localName && { sourceName: sourcePropName }
|
|
@@ -11727,6 +11940,9 @@ function localObjectMemberTypesFor(ctx) {
|
|
|
11727
11940
|
return cache.get(name) ?? null;
|
|
11728
11941
|
};
|
|
11729
11942
|
}
|
|
11943
|
+
function unresolvedDeclaredType(member) {
|
|
11944
|
+
return member && !member.type && member.declared ? { declaredType: member.declared } : {};
|
|
11945
|
+
}
|
|
11730
11946
|
function collectMemberTypes(typeNode, ctx) {
|
|
11731
11947
|
const localObjectMembers = localObjectMemberTypesFor(ctx);
|
|
11732
11948
|
const fromMembers = (members) => {
|
|
@@ -11736,6 +11952,7 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
11736
11952
|
const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
|
|
11737
11953
|
map.set(member.name.getText(ctx.sourceFile), {
|
|
11738
11954
|
type: info && isResolvableMemberType(info, localObjectMembers) ? info : null,
|
|
11955
|
+
declared: info,
|
|
11739
11956
|
optional: !!member.questionToken
|
|
11740
11957
|
});
|
|
11741
11958
|
}
|
|
@@ -11887,6 +12104,7 @@ function validateContext(ctx) {
|
|
|
11887
12104
|
}
|
|
11888
12105
|
markMutatedConstants(ctx);
|
|
11889
12106
|
markWrittenBindings(ctx);
|
|
12107
|
+
writeTemplatePropReads(ctx);
|
|
11890
12108
|
validateInitStatementReferences(ctx);
|
|
11891
12109
|
validateReactiveFactoryCalls(ctx);
|
|
11892
12110
|
validateReactiveFactoryArity(ctx);
|
|
@@ -13637,17 +13855,21 @@ function isAssignmentOperator3(kind) {
|
|
|
13637
13855
|
return kind >= ts23.SyntaxKind.FirstAssignment && kind <= ts23.SyntaxKind.LastAssignment;
|
|
13638
13856
|
}
|
|
13639
13857
|
function extractFunctionParams(value) {
|
|
13640
|
-
const
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13858
|
+
for (const kind of [ts23.ScriptKind.TSX, ts23.ScriptKind.TS]) {
|
|
13859
|
+
const source = ts23.createSourceFile("function.tsx", `(${value}
|
|
13860
|
+
)`, ts23.ScriptTarget.Latest, true, kind);
|
|
13861
|
+
const diagnostics = "parseDiagnostics" in source ? source.parseDiagnostics : undefined;
|
|
13862
|
+
if (Array.isArray(diagnostics) && diagnostics.length > 0)
|
|
13863
|
+
continue;
|
|
13864
|
+
const statement = source.statements[0];
|
|
13865
|
+
if (!statement || !ts23.isExpressionStatement(statement))
|
|
13866
|
+
return "";
|
|
13867
|
+
let expression = statement.expression;
|
|
13868
|
+
while (ts23.isParenthesizedExpression(expression))
|
|
13869
|
+
expression = expression.expression;
|
|
13870
|
+
if (!ts23.isArrowFunction(expression) && !ts23.isFunctionExpression(expression))
|
|
13871
|
+
return "";
|
|
13872
|
+
return expression.parameters.map((parameter) => `${parameter.dotDotDotToken ? "..." : ""}${parameter.name.getText(source)}`).join(", ");
|
|
13651
13873
|
}
|
|
13652
13874
|
return "";
|
|
13653
13875
|
}
|
|
@@ -14267,7 +14489,9 @@ function walkTemplateParts(parts, loc, attrName, visit3) {
|
|
|
14267
14489
|
visit3({ expr: parseExpression(trimmed), loc, role: "template-part", attrName });
|
|
14268
14490
|
};
|
|
14269
14491
|
for (const part of parts) {
|
|
14270
|
-
if (part.type === "
|
|
14492
|
+
if (part.type === "expression") {
|
|
14493
|
+
visit3({ expr: part.parsed, loc, role: "template-part", attrName });
|
|
14494
|
+
} else if (part.type === "ternary") {
|
|
14271
14495
|
visitText(part.condition);
|
|
14272
14496
|
visitText(part.whenTrue);
|
|
14273
14497
|
visitText(part.whenFalse);
|
|
@@ -14739,8 +14963,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
14739
14963
|
}
|
|
14740
14964
|
function getDestructuredPropNames(ctx) {
|
|
14741
14965
|
if (ctx._destructuredPropNames === undefined) {
|
|
14742
|
-
const
|
|
14743
|
-
const eligible = ctx.analyzer.propsParams.filter((p) => !shadowed.has(p.name));
|
|
14966
|
+
const eligible = templatePropReadParams(ctx.analyzer);
|
|
14744
14967
|
const names = eligible.map((p) => p.name);
|
|
14745
14968
|
ctx._destructuredPropNames = names.length > 0 ? new Set(names) : null;
|
|
14746
14969
|
ctx._destructuredPropAliases = buildPropAliasMap(eligible) ?? null;
|
|
@@ -14751,30 +14974,6 @@ function getDestructuredPropNames(ctx) {
|
|
|
14751
14974
|
}
|
|
14752
14975
|
return ctx._destructuredPropNames ?? null;
|
|
14753
14976
|
}
|
|
14754
|
-
function propShadowingNames(analyzer) {
|
|
14755
|
-
const shadowed = new Set;
|
|
14756
|
-
if (!analyzer.propsObjectName)
|
|
14757
|
-
return shadowed;
|
|
14758
|
-
for (const s of analyzer.signals) {
|
|
14759
|
-
shadowed.add(s.getter);
|
|
14760
|
-
if (s.setter)
|
|
14761
|
-
shadowed.add(s.setter);
|
|
14762
|
-
}
|
|
14763
|
-
for (const m of analyzer.memos)
|
|
14764
|
-
shadowed.add(m.name);
|
|
14765
|
-
for (const c of analyzer.localConstants) {
|
|
14766
|
-
if (c.propsDestructure && !keepsDeclaredValue(c)) {
|
|
14767
|
-
shadowed.add(c.name);
|
|
14768
|
-
continue;
|
|
14769
|
-
}
|
|
14770
|
-
if (isPropsAliasConst(c, analyzer.propsObjectName))
|
|
14771
|
-
continue;
|
|
14772
|
-
if (isRenamedBodyPropParam(c, analyzer.propsParams))
|
|
14773
|
-
continue;
|
|
14774
|
-
shadowed.add(c.name);
|
|
14775
|
-
}
|
|
14776
|
-
return shadowed;
|
|
14777
|
-
}
|
|
14778
14977
|
function getDestructuredPropInfoByName(ctx) {
|
|
14779
14978
|
if (ctx._destructuredPropNames === undefined)
|
|
14780
14979
|
getDestructuredPropNames(ctx);
|
|
@@ -14990,11 +15189,46 @@ function childrenReadOf(parsed, analyzer, scope) {
|
|
|
14990
15189
|
const readsProps = parsed.kind === "member" && parsed.object.kind === "identifier" && !scope.isBound(parsed.object.name);
|
|
14991
15190
|
return readsProps && isPropsChildrenMember(parsed, analyzer) ? "bare" : null;
|
|
14992
15191
|
}
|
|
14993
|
-
function
|
|
15192
|
+
function isPropsValueMember(parsed, analyzer) {
|
|
15193
|
+
return parsed?.kind === "member" && !parsed.computed && parsed.property !== "children" && parsed.object.kind === "identifier" && isPropsObjectBinding(parsed.object.name, analyzer);
|
|
15194
|
+
}
|
|
15195
|
+
function isPropValueBinding(name, analyzer) {
|
|
15196
|
+
const consts = childrenHopConstants(analyzer);
|
|
15197
|
+
const params = boundPropLocalNames(analyzer);
|
|
15198
|
+
const terminal = (n) => {
|
|
15199
|
+
if (consts.has(n))
|
|
15200
|
+
return isPropsValueMember(consts.get(n), analyzer) ? true : null;
|
|
15201
|
+
return params.has(n) && !analyzer.propsParams.some((p) => p.name === n && isChildrenPropParam(p)) ? true : null;
|
|
15202
|
+
};
|
|
15203
|
+
return resolveAliasOrigin(childrenAliasHops(analyzer), name, terminal) === true;
|
|
15204
|
+
}
|
|
15205
|
+
function isLoopRowPropRead(parsed, analyzer, scope) {
|
|
15206
|
+
if (!scope.insideLoopRow())
|
|
15207
|
+
return false;
|
|
15208
|
+
if (parsed.kind === "identifier")
|
|
15209
|
+
return !scope.isBound(parsed.name) && isPropValueBinding(parsed.name, analyzer);
|
|
15210
|
+
return parsed.kind === "member" && parsed.object.kind === "identifier" && !scope.isBound(parsed.object.name) && isPropsValueMember(parsed, analyzer);
|
|
15211
|
+
}
|
|
15212
|
+
function attachPropReadFlags(node, parsed, analyzer, scope) {
|
|
15213
|
+
const childrenRead = childrenReadOf(parsed, analyzer, scope);
|
|
15214
|
+
if (childrenRead)
|
|
15215
|
+
node.childrenRead = childrenRead;
|
|
15216
|
+
if (isLoopRowPropRead(parsed, analyzer, scope))
|
|
15217
|
+
node.loopRowPropRead = true;
|
|
15218
|
+
}
|
|
15219
|
+
function attachParsedAttrValues(node, parse2, parseValue, resolve2) {
|
|
14994
15220
|
const attach = (value, spreads) => {
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
15221
|
+
if (value.kind === "template" || value.kind === "expression") {
|
|
15222
|
+
for (const part of value.parts ?? []) {
|
|
15223
|
+
if (part.type === "expression")
|
|
15224
|
+
part.parsed = resolve2(part.parsed);
|
|
15225
|
+
}
|
|
15226
|
+
}
|
|
15227
|
+
if (value.kind === "expression" || spreads && value.kind === "spread") {
|
|
15228
|
+
const trimmed = value.expr.trim();
|
|
15229
|
+
if (trimmed)
|
|
15230
|
+
value.parsed = value.kind === "spread" ? parse2(trimmed) : parseValue(trimmed);
|
|
15231
|
+
}
|
|
14998
15232
|
};
|
|
14999
15233
|
if (node.type === "element") {
|
|
15000
15234
|
for (const attr of node.attrs)
|
|
@@ -15014,15 +15248,14 @@ function attachParsedExpressions(node, analyzer, scope = BindingScope.EMPTY) {
|
|
|
15014
15248
|
const trimmed = node.expr.trim();
|
|
15015
15249
|
if (trimmed)
|
|
15016
15250
|
node.parsed = parse2(trimmed);
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
node.childrenRead = childrenRead;
|
|
15251
|
+
if (node.parsed)
|
|
15252
|
+
attachPropReadFlags(node, node.parsed, analyzer, scope);
|
|
15020
15253
|
} else if (node.type === "conditional" || node.type === "if-statement") {
|
|
15021
15254
|
const trimmed = node.condition.trim();
|
|
15022
15255
|
if (trimmed)
|
|
15023
15256
|
node.parsedCondition = parse2(trimmed);
|
|
15024
15257
|
}
|
|
15025
|
-
attachParsedAttrValues(node, parse2, parseValue);
|
|
15258
|
+
attachParsedAttrValues(node, parse2, parseValue, (parsed) => resolveCallbackMethodFunctionReferences(parsed, analyzer, bound));
|
|
15026
15259
|
switch (node.type) {
|
|
15027
15260
|
case "element":
|
|
15028
15261
|
case "component":
|
|
@@ -15737,8 +15970,12 @@ function cleanJsxWhitespace(raw) {
|
|
|
15737
15970
|
let line = lines[i].replace(/\t/g, " ");
|
|
15738
15971
|
if (!isFirstLine)
|
|
15739
15972
|
line = line.replace(/^ +/, "");
|
|
15740
|
-
if (!isLastLine)
|
|
15741
|
-
|
|
15973
|
+
if (!isLastLine) {
|
|
15974
|
+
let end = line.length;
|
|
15975
|
+
while (end > 0 && line[end - 1] === " ")
|
|
15976
|
+
end--;
|
|
15977
|
+
line = line.slice(0, end);
|
|
15978
|
+
}
|
|
15742
15979
|
if (line !== "")
|
|
15743
15980
|
kept.push(line);
|
|
15744
15981
|
}
|
|
@@ -17808,7 +18045,9 @@ function attrValueText(value) {
|
|
|
17808
18045
|
return "";
|
|
17809
18046
|
const out = [];
|
|
17810
18047
|
for (const p of value.parts) {
|
|
17811
|
-
if (p.type === "
|
|
18048
|
+
if (p.type === "expression")
|
|
18049
|
+
out.push(p.expr);
|
|
18050
|
+
else if (p.type === "ternary")
|
|
17812
18051
|
out.push(p.condition, p.whenTrue, p.whenFalse);
|
|
17813
18052
|
else if (p.type === "lookup")
|
|
17814
18053
|
out.push(p.key);
|
|
@@ -18543,7 +18782,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
18543
18782
|
} else {
|
|
18544
18783
|
const val = ctx.getJS(span.expression);
|
|
18545
18784
|
const tVal = rewriteBarePropRefs2(val, span.expression, ctx);
|
|
18546
|
-
parts.push({ type: "
|
|
18785
|
+
parts.push({ type: "expression", expr: val, templateExpr: tVal, parsed: parseValueExpr(val) });
|
|
18547
18786
|
}
|
|
18548
18787
|
} else {
|
|
18549
18788
|
const resolved = tryResolveTemplateSpanFromConst(span.expression, ctx);
|
|
@@ -18552,7 +18791,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
18552
18791
|
} else {
|
|
18553
18792
|
const val = ctx.getJS(span.expression);
|
|
18554
18793
|
const tVal = rewriteBarePropRefs2(val, span.expression, ctx);
|
|
18555
|
-
parts.push({ type: "
|
|
18794
|
+
parts.push({ type: "expression", expr: val, templateExpr: tVal, parsed: parseValueExpr(val) });
|
|
18556
18795
|
}
|
|
18557
18796
|
}
|
|
18558
18797
|
if (span.literal.text) {
|
|
@@ -18693,9 +18932,10 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
|
|
|
18693
18932
|
const text = astText(span.expression);
|
|
18694
18933
|
const templateText = rewriteBarePropRefs2(text, span.expression, ctx);
|
|
18695
18934
|
parts.push({
|
|
18696
|
-
type: "
|
|
18697
|
-
|
|
18698
|
-
|
|
18935
|
+
type: "expression",
|
|
18936
|
+
expr: text,
|
|
18937
|
+
templateExpr: templateText,
|
|
18938
|
+
parsed: parseValueExpr(text)
|
|
18699
18939
|
});
|
|
18700
18940
|
}
|
|
18701
18941
|
if (span.literal.text)
|
|
@@ -18926,7 +19166,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
18926
19166
|
const props = [];
|
|
18927
19167
|
for (const attr of attributes.properties) {
|
|
18928
19168
|
if (ts25.isJsxSpreadAttribute(attr)) {
|
|
18929
|
-
props.push(...expandSpreadAttribute(attr, ctx).map(({ restExpandedKey: _restExpandedKey, ...prop }) => prop));
|
|
19169
|
+
props.push(...expandSpreadAttribute(attr, ctx).map(({ restExpandedKey: _restExpandedKey, ...prop }) => markPropsObjectSpread(prop, ctx)));
|
|
18930
19170
|
continue;
|
|
18931
19171
|
}
|
|
18932
19172
|
if (!ts25.isJsxAttribute(attr))
|
|
@@ -19275,6 +19515,18 @@ function forwardsCallerRestProps(attrs, ctx) {
|
|
|
19275
19515
|
}
|
|
19276
19516
|
return false;
|
|
19277
19517
|
}
|
|
19518
|
+
function markPropsObjectSpread(prop, ctx) {
|
|
19519
|
+
const value = prop.value;
|
|
19520
|
+
if (value.kind !== "spread")
|
|
19521
|
+
return prop;
|
|
19522
|
+
const constants = constantValuesByName(ctx);
|
|
19523
|
+
for (const name of new Set([value.expr, value.templateExpr])) {
|
|
19524
|
+
if (name && resolveRestSpreadOriginCore(ctx.analyzer, constants, name) === "props") {
|
|
19525
|
+
return { ...prop, value: { ...value, propsObject: true } };
|
|
19526
|
+
}
|
|
19527
|
+
}
|
|
19528
|
+
return prop;
|
|
19529
|
+
}
|
|
19278
19530
|
function constantValuesByName(ctx) {
|
|
19279
19531
|
if (ctx._constantValuesByName)
|
|
19280
19532
|
return ctx._constantValuesByName;
|
|
@@ -19330,11 +19582,13 @@ function attrValueReactivityProbe(value) {
|
|
|
19330
19582
|
case "template":
|
|
19331
19583
|
return value.parts.map((p) => {
|
|
19332
19584
|
if (p.type === "string")
|
|
19333
|
-
return
|
|
19585
|
+
return "";
|
|
19586
|
+
if (p.type === "expression")
|
|
19587
|
+
return p.expr;
|
|
19334
19588
|
if (p.type === "ternary")
|
|
19335
19589
|
return p.condition;
|
|
19336
19590
|
return p.key;
|
|
19337
|
-
}).join("");
|
|
19591
|
+
}).join(" ");
|
|
19338
19592
|
case "literal":
|
|
19339
19593
|
case "boolean-attr":
|
|
19340
19594
|
case "boolean-shorthand":
|
|
@@ -19786,7 +20040,8 @@ function collectLoopChildEventsWithNesting(node, initialNestingStack = [], sibli
|
|
|
19786
20040
|
const initialScope = {
|
|
19787
20041
|
nestingStack: initialNestingStack,
|
|
19788
20042
|
lastElementSlotId: null,
|
|
19789
|
-
domDepth: 0
|
|
20043
|
+
domDepth: 0,
|
|
20044
|
+
receivers: []
|
|
19790
20045
|
};
|
|
19791
20046
|
walkIR(node, initialScope, {
|
|
19792
20047
|
element: ({ node: el, scope, descend }) => {
|
|
@@ -19797,7 +20052,8 @@ function collectLoopChildEventsWithNesting(node, initialNestingStack = [], sibli
|
|
|
19797
20052
|
childSlotId: el.slotId,
|
|
19798
20053
|
handler: event.handler,
|
|
19799
20054
|
nestedLoops: [...scope.nestingStack],
|
|
19800
|
-
domDepth: scope.domDepth
|
|
20055
|
+
domDepth: scope.domDepth,
|
|
20056
|
+
...el.slotId.startsWith("^") && scope.receivers.length > 0 && { receiverSlotIds: scope.receivers }
|
|
19801
20057
|
});
|
|
19802
20058
|
}
|
|
19803
20059
|
}
|
|
@@ -19807,9 +20063,13 @@ function collectLoopChildEventsWithNesting(node, initialNestingStack = [], sibli
|
|
|
19807
20063
|
domDepth: scope.domDepth + 1
|
|
19808
20064
|
});
|
|
19809
20065
|
},
|
|
20066
|
+
component: ({ node: c, scope, descend }) => {
|
|
20067
|
+
descend(c !== node && c.slotId ? { ...scope, receivers: [...scope.receivers, c.slotId] } : scope);
|
|
20068
|
+
},
|
|
19810
20069
|
loop: ({ node: l, scope, descend }) => {
|
|
19811
20070
|
descend({
|
|
19812
20071
|
...scope,
|
|
20072
|
+
receivers: [],
|
|
19813
20073
|
nestingStack: [
|
|
19814
20074
|
...scope.nestingStack,
|
|
19815
20075
|
{
|
|
@@ -19873,7 +20133,8 @@ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings,
|
|
|
19873
20133
|
slotId: n.slotId,
|
|
19874
20134
|
expression: expanded.expr,
|
|
19875
20135
|
insideConditional: insideConditional || undefined,
|
|
19876
|
-
...expanded.freeIds !== undefined && { freeIdentifiers: expanded.freeIds }
|
|
20136
|
+
...expanded.freeIds !== undefined && { freeIdentifiers: expanded.freeIds },
|
|
20137
|
+
...n.loopRowPropRead && { markup: true }
|
|
19877
20138
|
});
|
|
19878
20139
|
},
|
|
19879
20140
|
conditional: ({ node: c, descend }) => {
|
|
@@ -20320,6 +20581,9 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
|
|
|
20320
20581
|
childComponents,
|
|
20321
20582
|
insideConditional: !flat && scope.insideCond ? true : undefined,
|
|
20322
20583
|
offset: flat ? undefined : resolveLoopOffset(siblingOffsets.get(n)),
|
|
20584
|
+
filterPredicate: n.filterPredicate ? { param: n.filterPredicate.param, raw: n.filterPredicate.raw } : undefined,
|
|
20585
|
+
sortComparator: n.sortComparator ? { paramA: n.sortComparator.paramA, paramB: n.sortComparator.paramB, raw: n.sortComparator.raw } : undefined,
|
|
20586
|
+
chainOrder: n.chainOrder,
|
|
20323
20587
|
bindings
|
|
20324
20588
|
});
|
|
20325
20589
|
if (!flat) {
|
|
@@ -20341,6 +20605,13 @@ function decideLoopRendering(loop, siblingOffsets, ctx, branchScope = false) {
|
|
|
20341
20605
|
const useElementReconciliation = !loop.childComponent && (!loop.isStaticArray || branchScope && hasInnerLoops) && (hasNestedComps || hasInnerLoops);
|
|
20342
20606
|
return { useElementReconciliation, innerLoops };
|
|
20343
20607
|
}
|
|
20608
|
+
function keepsInnerLoops(loop, useElementReconciliation, innerLoops) {
|
|
20609
|
+
if (useElementReconciliation)
|
|
20610
|
+
return true;
|
|
20611
|
+
if (!innerLoops || innerLoops.length === 0)
|
|
20612
|
+
return false;
|
|
20613
|
+
return loop.isStaticArray || !!loop.childComponent;
|
|
20614
|
+
}
|
|
20344
20615
|
function jsxChildrenContainComponent(nodes) {
|
|
20345
20616
|
for (const node of nodes) {
|
|
20346
20617
|
if (node.type === "component")
|
|
@@ -20356,6 +20627,42 @@ function jsxChildrenContainComponent(nodes) {
|
|
|
20356
20627
|
}
|
|
20357
20628
|
return false;
|
|
20358
20629
|
}
|
|
20630
|
+
function componentInitPropValue(prop, ctx) {
|
|
20631
|
+
if (isEventHandlerName(prop.name)) {
|
|
20632
|
+
return { expr: attrValueToString(prop.value) ?? prop.name, getter: false };
|
|
20633
|
+
}
|
|
20634
|
+
switch (prop.value.kind) {
|
|
20635
|
+
case "jsx-children":
|
|
20636
|
+
if (jsxChildrenContainComponent(prop.value.children)) {
|
|
20637
|
+
return { expr: `__slot(() => ${irChildrenToJsExpr(prop.value.children)})`, getter: true };
|
|
20638
|
+
}
|
|
20639
|
+
return { expr: jsxChildrenPropGetterExpr(prop.value.children, prop.name), getter: true };
|
|
20640
|
+
case "expression":
|
|
20641
|
+
case "template":
|
|
20642
|
+
case "spread":
|
|
20643
|
+
return { expr: expandDynamicPropValue(attrValueToString(prop.value), ctx), getter: true };
|
|
20644
|
+
case "literal":
|
|
20645
|
+
return { expr: JSON.stringify(prop.value.value), getter: false };
|
|
20646
|
+
case "boolean-shorthand":
|
|
20647
|
+
case "boolean-attr":
|
|
20648
|
+
return { expr: "true", getter: false };
|
|
20649
|
+
}
|
|
20650
|
+
}
|
|
20651
|
+
function lastPropsObjectSpreadIndex(props) {
|
|
20652
|
+
let at = -1;
|
|
20653
|
+
props.forEach((p, index) => {
|
|
20654
|
+
if (p.value.kind === "spread" && p.value.propsObject === true)
|
|
20655
|
+
at = index;
|
|
20656
|
+
});
|
|
20657
|
+
return at;
|
|
20658
|
+
}
|
|
20659
|
+
function callerFirstPropExpr(name, expr) {
|
|
20660
|
+
const key = JSON.stringify(name);
|
|
20661
|
+
return `(${key} in ${PROPS_PARAM} ? ${PROPS_PARAM}[${key}] : ${expr})`;
|
|
20662
|
+
}
|
|
20663
|
+
function mergedMirrorExpr(name, expr, index, spreadAt) {
|
|
20664
|
+
return index < spreadAt ? callerFirstPropExpr(name, expr) : expr;
|
|
20665
|
+
}
|
|
20359
20666
|
function buildComponentPropsExpr(props, ctx) {
|
|
20360
20667
|
const knownSpreadProp = props.find((p) => {
|
|
20361
20668
|
if (p.name !== "..." && !p.name.startsWith("..."))
|
|
@@ -20366,47 +20673,21 @@ function buildComponentPropsExpr(props, ctx) {
|
|
|
20366
20673
|
return resolveRestSpreadOrigin(ctx, expr) !== null;
|
|
20367
20674
|
});
|
|
20368
20675
|
const spreadSource = knownSpreadProp ? PROPS_PARAM : null;
|
|
20676
|
+
const spreadAt = lastPropsObjectSpreadIndex(props);
|
|
20369
20677
|
const propsForInit = [];
|
|
20370
20678
|
const explicitPropNames = [];
|
|
20371
|
-
|
|
20679
|
+
props.forEach((prop, index) => {
|
|
20372
20680
|
if (prop.name === "..." || prop.name.startsWith("..."))
|
|
20373
|
-
|
|
20681
|
+
return;
|
|
20374
20682
|
explicitPropNames.push(prop.name);
|
|
20375
|
-
const
|
|
20376
|
-
|
|
20377
|
-
|
|
20378
|
-
|
|
20379
|
-
}
|
|
20380
|
-
|
|
20381
|
-
case "jsx-children": {
|
|
20382
|
-
if (jsxChildrenContainComponent(prop.value.children)) {
|
|
20383
|
-
const jsxExpr = irChildrenToJsExpr(prop.value.children);
|
|
20384
|
-
propsForInit.push(`get ${quotePropName(prop.name)}() { return __slot(() => ${jsxExpr}) }`);
|
|
20385
|
-
} else {
|
|
20386
|
-
const jsxExpr = jsxChildrenPropGetterExpr(prop.value.children, prop.name);
|
|
20387
|
-
propsForInit.push(`get ${quotePropName(prop.name)}() { return ${jsxExpr} }`);
|
|
20388
|
-
}
|
|
20389
|
-
break;
|
|
20390
|
-
}
|
|
20391
|
-
case "expression":
|
|
20392
|
-
case "template":
|
|
20393
|
-
case "spread": {
|
|
20394
|
-
const valueExpr = attrValueToString(prop.value);
|
|
20395
|
-
const expandedValue = expandDynamicPropValue(valueExpr, ctx);
|
|
20396
|
-
propsForInit.push(`get ${quotePropName(prop.name)}() { return ${expandedValue} }`);
|
|
20397
|
-
break;
|
|
20398
|
-
}
|
|
20399
|
-
case "literal":
|
|
20400
|
-
propsForInit.push(`${quotePropName(prop.name)}: ${JSON.stringify(prop.value.value)}`);
|
|
20401
|
-
break;
|
|
20402
|
-
case "boolean-shorthand":
|
|
20403
|
-
propsForInit.push(`${quotePropName(prop.name)}: true`);
|
|
20404
|
-
break;
|
|
20405
|
-
case "boolean-attr":
|
|
20406
|
-
propsForInit.push(`${quotePropName(prop.name)}: true`);
|
|
20407
|
-
break;
|
|
20683
|
+
const key = quotePropName(prop.name);
|
|
20684
|
+
const { expr, getter } = componentInitPropValue(prop, ctx);
|
|
20685
|
+
if (index < spreadAt) {
|
|
20686
|
+
propsForInit.push(`get ${key}() { return ${callerFirstPropExpr(prop.name, expr)} }`);
|
|
20687
|
+
} else {
|
|
20688
|
+
propsForInit.push(getter ? `get ${key}() { return ${expr} }` : `${key}: ${expr}`);
|
|
20408
20689
|
}
|
|
20409
|
-
}
|
|
20690
|
+
});
|
|
20410
20691
|
if (spreadSource) {
|
|
20411
20692
|
const overrides = propsForInit.length > 0 ? `{ ${propsForInit.join(", ")} }` : "{}";
|
|
20412
20693
|
const excludeKeys = JSON.stringify(explicitPropNames);
|
|
@@ -20415,7 +20696,8 @@ function buildComponentPropsExpr(props, ctx) {
|
|
|
20415
20696
|
return propsForInit.length > 0 ? `{ ${propsForInit.join(", ")} }` : "{}";
|
|
20416
20697
|
}
|
|
20417
20698
|
function collectReactiveChildProps(node, ctx) {
|
|
20418
|
-
|
|
20699
|
+
const spreadAt = lastPropsObjectSpreadIndex(node.props);
|
|
20700
|
+
for (const [index, prop] of node.props.entries()) {
|
|
20419
20701
|
if (prop.name === "..." || prop.name.startsWith("..."))
|
|
20420
20702
|
continue;
|
|
20421
20703
|
if (prop.value.kind === "jsx-children")
|
|
@@ -20435,7 +20717,7 @@ function collectReactiveChildProps(node, ctx) {
|
|
|
20435
20717
|
slotId: node.slotId,
|
|
20436
20718
|
propName: prop.name,
|
|
20437
20719
|
attrName,
|
|
20438
|
-
expression: expandedValue,
|
|
20720
|
+
expression: mergedMirrorExpr(prop.name, expandedValue, index, spreadAt),
|
|
20439
20721
|
...pickAttrMetaFromIR(prop)
|
|
20440
20722
|
});
|
|
20441
20723
|
}
|
|
@@ -20572,7 +20854,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
20572
20854
|
nestedComponents: l.nestedComponents,
|
|
20573
20855
|
isStaticArray: clientIsStaticArray,
|
|
20574
20856
|
useElementReconciliation,
|
|
20575
|
-
innerLoops:
|
|
20857
|
+
innerLoops: keepsInnerLoops(l, useElementReconciliation, innerLoops) ? innerLoops : undefined,
|
|
20576
20858
|
offset: resolveLoopOffset(siblingOffsets.get(l)),
|
|
20577
20859
|
filterPredicate: l.filterPredicate ? {
|
|
20578
20860
|
param: l.filterPredicate.param,
|
|
@@ -20599,7 +20881,8 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
20599
20881
|
},
|
|
20600
20882
|
component: ({ node: c, descend, descendJsxChildren }) => {
|
|
20601
20883
|
if (c.slotId) {
|
|
20602
|
-
|
|
20884
|
+
const spreadAt = lastPropsObjectSpreadIndex(c.props);
|
|
20885
|
+
for (const [index, prop] of c.props.entries()) {
|
|
20603
20886
|
if (prop.value.kind === "jsx-children")
|
|
20604
20887
|
continue;
|
|
20605
20888
|
if (isEventHandlerName(prop.name))
|
|
@@ -20615,7 +20898,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
20615
20898
|
ctx.reactiveProps.push({
|
|
20616
20899
|
slotId: c.slotId,
|
|
20617
20900
|
propName: prop.name,
|
|
20618
|
-
expression:
|
|
20901
|
+
expression: mergedMirrorExpr(prop.name, value, index, spreadAt),
|
|
20619
20902
|
componentName: c.name
|
|
20620
20903
|
});
|
|
20621
20904
|
}
|
|
@@ -22823,11 +23106,12 @@ function emitListenerLine(lines, indent, elementVar, eventName, handler, mode =
|
|
|
22823
23106
|
const name = mode === "dom" ? toDomEventName(eventName) : eventName;
|
|
22824
23107
|
lines.push(`${indent}if (${elementVar}) ${elementVar}.addEventListener('${name}', ${wrapped})`);
|
|
22825
23108
|
}
|
|
22826
|
-
function emitListenerBlock(lines, indent, scopeVar, slotId, elementLocal, eventName, handler, mode = "dom", bodyIsMultiRoot = false) {
|
|
23109
|
+
function emitListenerBlock(lines, indent, scopeVar, slotId, elementLocal, eventName, handler, mode = "dom", bodyIsMultiRoot = false, receiverSlotIds) {
|
|
22827
23110
|
const wrapped = handler.trim();
|
|
22828
23111
|
const name = mode === "dom" ? toDomEventName(eventName) : eventName;
|
|
22829
23112
|
const lookup = bodyIsMultiRoot ? "qsaItem" : "qsa";
|
|
22830
|
-
|
|
23113
|
+
const receiverArgs = !bodyIsMultiRoot && receiverSlotIds && receiverSlotIds.length > 0 ? `, ${JSON.stringify(receiverSlotIds)}, __scopeId` : "";
|
|
23114
|
+
lines.push(`${indent}{ const ${elementLocal} = ${lookup}(${scopeVar}, '[bf="${slotId}"]'${receiverArgs}); if (${elementLocal}) ${elementLocal}.addEventListener('${name}', ${wrapped}) }`);
|
|
22831
23115
|
}
|
|
22832
23116
|
|
|
22833
23117
|
// src/ir-to-client-js/control-flow/shared.ts
|
|
@@ -22988,18 +23272,19 @@ function buildDepthLevels(innerLoops, nestedComps, childEvents) {
|
|
|
22988
23272
|
}));
|
|
22989
23273
|
}
|
|
22990
23274
|
function emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot = false, loopIndex) {
|
|
22991
|
-
const binding = loopParam ? buildRowEventBinding(ev, loopParam, loopParamBindings, loopIndex) : { childSlotId: ev.childSlotId, eventName: ev.eventName, handler: ev.handler };
|
|
23275
|
+
const binding = loopParam ? buildRowEventBinding(ev, loopParam, loopParamBindings, loopIndex) : { childSlotId: ev.childSlotId, eventName: ev.eventName, handler: ev.handler, receiverSlotIds: ev.receiverSlotIds };
|
|
22992
23276
|
emitRowEventListener(ls, indent, elVar, binding, bodyIsMultiRoot);
|
|
22993
23277
|
}
|
|
22994
23278
|
function buildRowEventBinding(ev, loopParam, loopParamBindings, loopIndex) {
|
|
22995
23279
|
return {
|
|
22996
23280
|
childSlotId: ev.childSlotId,
|
|
22997
23281
|
eventName: ev.eventName,
|
|
22998
|
-
handler: wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings, loopIndex)
|
|
23282
|
+
handler: wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings, loopIndex),
|
|
23283
|
+
receiverSlotIds: ev.receiverSlotIds
|
|
22999
23284
|
};
|
|
23000
23285
|
}
|
|
23001
23286
|
function emitRowEventListener(ls, indent, elVar, binding, bodyIsMultiRoot = false) {
|
|
23002
|
-
emitListenerBlock(ls, indent, elVar, binding.childSlotId, "__e", binding.eventName, binding.handler, "dom", bodyIsMultiRoot);
|
|
23287
|
+
emitListenerBlock(ls, indent, elVar, binding.childSlotId, "__e", binding.eventName, binding.handler, "dom", bodyIsMultiRoot, binding.receiverSlotIds);
|
|
23003
23288
|
}
|
|
23004
23289
|
function buildCompSelector(comp) {
|
|
23005
23290
|
return comp.slotId ? `\`[${BF_HOST}="\${__scopeId}"][${BF_AT}="${comp.slotId}"], [${BF_SCOPE2}$="_${comp.slotId}"]\`` : `'[${BF_SCOPE2}^="${comp.name}_"]'`;
|
|
@@ -23208,7 +23493,8 @@ function buildBranchInnerLoopsPlan(args) {
|
|
|
23208
23493
|
const reactiveTexts = inner.bindings.reactiveTexts.map((text) => ({
|
|
23209
23494
|
slotId: text.slotId,
|
|
23210
23495
|
wrappedExpression: wrapBoth(text.expression),
|
|
23211
|
-
insideConditional: !!text.insideConditional
|
|
23496
|
+
insideConditional: !!text.insideConditional,
|
|
23497
|
+
...text.markup && { markup: true }
|
|
23212
23498
|
}));
|
|
23213
23499
|
plan.push({
|
|
23214
23500
|
uidSuffix: `br_${i}`,
|
|
@@ -23374,7 +23660,8 @@ function buildReactiveEffectsPlan(args) {
|
|
|
23374
23660
|
}
|
|
23375
23661
|
const outerTexts = texts.map((text) => ({
|
|
23376
23662
|
slotId: text.slotId,
|
|
23377
|
-
wrappedExpression: wrap(text.expression)
|
|
23663
|
+
wrappedExpression: wrap(text.expression),
|
|
23664
|
+
...text.markup && { markup: true }
|
|
23378
23665
|
}));
|
|
23379
23666
|
const conditionalPlans = [];
|
|
23380
23667
|
if (conditionals) {
|
|
@@ -23542,8 +23829,8 @@ function analyzeLazyPreamble(preamble, primableNames) {
|
|
|
23542
23829
|
return NO2(`map-callback preamble shadows the signal/memo getter '${name}'`);
|
|
23543
23830
|
}
|
|
23544
23831
|
}
|
|
23545
|
-
const
|
|
23546
|
-
const freeNames = new Set(
|
|
23832
|
+
const readNames2 = extractFreeIdentifiersFromStatementText(text);
|
|
23833
|
+
const freeNames = new Set(readNames2);
|
|
23547
23834
|
for (const declared of declaredNames)
|
|
23548
23835
|
freeNames.delete(declared);
|
|
23549
23836
|
return { lazySafe: true, facts: { declaredNames, freeNames } };
|
|
@@ -23936,7 +24223,8 @@ function decideLazyRow(args) {
|
|
|
23936
24223
|
ordinal: ordinal++,
|
|
23937
24224
|
readsItem: c.readsItem || !c.readsOuter,
|
|
23938
24225
|
readsOuter: c.readsOuter,
|
|
23939
|
-
readsPreamble: c.readsPreamble
|
|
24226
|
+
readsPreamble: c.readsPreamble,
|
|
24227
|
+
...text.markup && { markup: true }
|
|
23940
24228
|
};
|
|
23941
24229
|
});
|
|
23942
24230
|
const outerPrimeGetters = [];
|
|
@@ -24062,79 +24350,6 @@ function buildPlainRowCore(inputs) {
|
|
|
24062
24350
|
};
|
|
24063
24351
|
}
|
|
24064
24352
|
|
|
24065
|
-
// src/ir-to-client-js/control-flow/plan/build-component-loop.ts
|
|
24066
|
-
function collectTextOnlySlotIds(nodes, into) {
|
|
24067
|
-
for (const node of nodes) {
|
|
24068
|
-
if (node.type === "expression") {
|
|
24069
|
-
if (node.slotId)
|
|
24070
|
-
into.add(node.slotId);
|
|
24071
|
-
} else if (node.type === "conditional" && isTextOnlyConditional(node)) {
|
|
24072
|
-
collectTextOnlySlotIds([node.whenTrue, node.whenFalse], into);
|
|
24073
|
-
}
|
|
24074
|
-
}
|
|
24075
|
-
}
|
|
24076
|
-
function buildComponentLoopPlan(elem, profileComponentName) {
|
|
24077
|
-
const { name } = elem.childComponent;
|
|
24078
|
-
const propsExpr = buildComponentPropsExpr2(elem.childComponent, elem.param, elem.paramBindings, elem.index);
|
|
24079
|
-
const keyExpr = wrapLoopParamAsAccessor(elem.key || "__idx", elem.param, elem.paramBindings, elem.index);
|
|
24080
|
-
const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
|
|
24081
|
-
const mapPreambleWrapped = elem.preamble ? renderPreamble(elem.preamble, {
|
|
24082
|
-
transformJs: (text) => wrapLoopParamAsAccessor(text, elem.param, elem.paramBindings, elem.index),
|
|
24083
|
-
renderLeaf: () => {
|
|
24084
|
-
internalInvariant(false, "component-root loop received a JSX-bearing preamble — Phase 1 should have refused it");
|
|
24085
|
-
}
|
|
24086
|
-
}) : "";
|
|
24087
|
-
const outerNestedComps = (elem.nestedComponents ?? []).filter((c) => !c.loopDepth);
|
|
24088
|
-
const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings, elem.index);
|
|
24089
|
-
const nestedChildrenTextEffectSlotIds = new Set;
|
|
24090
|
-
const nestedComps = outerNestedComps.map((comp) => {
|
|
24091
|
-
const isTextOnly = comp.children?.length ? comp.children.every((c) => c.type === "expression" || c.type === "text" || isTextOnlyConditional(c)) : false;
|
|
24092
|
-
const rawChildrenExpr = isTextOnly ? irChildrenToJsExpr(comp.children) : null;
|
|
24093
|
-
const childrenFreeIds = isTextOnly && comp.children ? irChildrenFreeIds(comp.children) : undefined;
|
|
24094
|
-
const childrenRefsLoop = rawChildrenExpr != null && childrenFreeIds != null && (childrenFreeIds.has(elem.param) || !!elem.index && childrenFreeIds.has(elem.index));
|
|
24095
|
-
if (childrenRefsLoop && comp.children) {
|
|
24096
|
-
collectTextOnlySlotIds(comp.children, nestedChildrenTextEffectSlotIds);
|
|
24097
|
-
}
|
|
24098
|
-
return {
|
|
24099
|
-
componentName: comp.name,
|
|
24100
|
-
selector: buildCompSelector(comp),
|
|
24101
|
-
propsExpr: buildComponentPropsExpr2(comp, elem.param, elem.paramBindings, elem.index),
|
|
24102
|
-
childrenTextEffect: childrenRefsLoop ? buildChildrenTextEffect(comp.children, rawChildrenExpr, wrap) : null
|
|
24103
|
-
};
|
|
24104
|
-
});
|
|
24105
|
-
const rowReactiveTexts = nestedChildrenTextEffectSlotIds.size > 0 ? elem.bindings.reactiveTexts.filter((t) => !nestedChildrenTextEffectSlotIds.has(t.slotId)) : elem.bindings.reactiveTexts;
|
|
24106
|
-
const hasReactiveEffects = hasReactiveLoopBindings({ ...elem.bindings, reactiveTexts: rowReactiveTexts });
|
|
24107
|
-
const rowEvents = elem.bindings.events.filter((ev) => ev.nestedLoops.length === 0).map((ev) => buildRowEventBinding(ev, elem.param, elem.paramBindings, elem.index));
|
|
24108
|
-
return {
|
|
24109
|
-
kind: "component",
|
|
24110
|
-
rowConstruction: "dom-ops",
|
|
24111
|
-
mapPreambleWrapped,
|
|
24112
|
-
containerVar: `_${varSlotId(elem.slotId)}`,
|
|
24113
|
-
markerId: elem.markerId,
|
|
24114
|
-
arrayExpr: buildChainedArrayExpr(elem),
|
|
24115
|
-
keyFn: loopKeyFn(elem),
|
|
24116
|
-
paramHead,
|
|
24117
|
-
paramUnwrap,
|
|
24118
|
-
indexParam: elem.index || "__idx",
|
|
24119
|
-
componentName: name,
|
|
24120
|
-
componentPropsExpr: propsExpr,
|
|
24121
|
-
keyExpr,
|
|
24122
|
-
nestedComps,
|
|
24123
|
-
rowEvents,
|
|
24124
|
-
childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
|
|
24125
|
-
profileLoopId: profileComponentName ? `${profileComponentName}#binding:${elem.slotId}` : undefined,
|
|
24126
|
-
reactiveEffects: hasReactiveEffects ? buildReactiveEffectsPlan({
|
|
24127
|
-
attrs: elem.bindings.reactiveAttrs,
|
|
24128
|
-
texts: rowReactiveTexts,
|
|
24129
|
-
conditionals: elem.bindings.conditionals,
|
|
24130
|
-
loopParam: elem.param,
|
|
24131
|
-
loopParamBindings: elem.paramBindings,
|
|
24132
|
-
loopIndex: elem.index,
|
|
24133
|
-
profileComponentName
|
|
24134
|
-
}) : null
|
|
24135
|
-
};
|
|
24136
|
-
}
|
|
24137
|
-
|
|
24138
24353
|
// src/ir-to-client-js/control-flow/plan/build-inner-loop.ts
|
|
24139
24354
|
function wrapAttrValueExpression2(value, wrap) {
|
|
24140
24355
|
switch (value.kind) {
|
|
@@ -24181,7 +24396,12 @@ function buildInnerLoopsPlan(args) {
|
|
|
24181
24396
|
const uidSuffix = `${inner.depth}_${i}`;
|
|
24182
24397
|
const containerExpr = inner.containerSlotId ? `${rowHasPortal ? "qsaItem" : "qsa"}(${parentElVar}, '[bf="${inner.containerSlotId}"]')` : parentElVar;
|
|
24183
24398
|
const emit = buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex);
|
|
24184
|
-
const arrayExpr = wrapOuter(
|
|
24399
|
+
const arrayExpr = wrapOuter(buildLoopChainExpr({
|
|
24400
|
+
base: inner.array,
|
|
24401
|
+
filterPredicate: inner.filterPredicate,
|
|
24402
|
+
sortComparator: inner.sortComparator,
|
|
24403
|
+
chainOrder: inner.chainOrder
|
|
24404
|
+
}));
|
|
24185
24405
|
const childLevelsPlan = childLevels.length > 0 ? buildInnerLoopsPlan({
|
|
24186
24406
|
levels: childLevels,
|
|
24187
24407
|
parentElVar: `__innerEl${uidSuffix}`,
|
|
@@ -24241,13 +24461,15 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
|
|
|
24241
24461
|
children: comp.children?.map(wrapIRNode)
|
|
24242
24462
|
}));
|
|
24243
24463
|
const events = level.events.map((ev) => ({
|
|
24244
|
-
|
|
24245
|
-
|
|
24464
|
+
childSlotId: ev.childSlotId,
|
|
24465
|
+
eventName: ev.eventName,
|
|
24466
|
+
handler: wrapBoth(ev.handler)
|
|
24246
24467
|
}));
|
|
24247
24468
|
const reactiveTexts = inner.bindings.reactiveTexts.map((text) => ({
|
|
24248
24469
|
slotId: text.slotId,
|
|
24249
24470
|
wrappedExpression: wrapLoopParamAsAccessor(wrapOuterRow(text.expression), inner.param, inner.paramBindings, inner.index),
|
|
24250
|
-
insideConditional: !!text.insideConditional
|
|
24471
|
+
insideConditional: !!text.insideConditional,
|
|
24472
|
+
...text.markup && { markup: true }
|
|
24251
24473
|
}));
|
|
24252
24474
|
const reactiveAttrs = inner.bindings.reactiveAttrs.map((attr) => {
|
|
24253
24475
|
const wrapped = wrapLoopParamAsAccessor(wrapOuterRow(attr.expression), inner.param, inner.paramBindings, inner.index);
|
|
@@ -24299,6 +24521,114 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
|
|
|
24299
24521
|
childRefs
|
|
24300
24522
|
};
|
|
24301
24523
|
}
|
|
24524
|
+
function buildForwardedInnerLoopsPlan(args) {
|
|
24525
|
+
const { innerLoops, events, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex } = args;
|
|
24526
|
+
if (!innerLoops || innerLoops.length === 0)
|
|
24527
|
+
return [];
|
|
24528
|
+
const levels = buildDepthLevels([...innerLoops], [], [...events]);
|
|
24529
|
+
const kept = levels.filter((_, i) => levelCarriesEvent(levels, i));
|
|
24530
|
+
if (kept.length === 0)
|
|
24531
|
+
return [];
|
|
24532
|
+
return buildInnerLoopsPlan({ levels: kept, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex });
|
|
24533
|
+
}
|
|
24534
|
+
function levelCarriesEvent(levels, i) {
|
|
24535
|
+
const depth = levels[i].loopInfo?.depth ?? 0;
|
|
24536
|
+
for (let j = i;j < levels.length; j++) {
|
|
24537
|
+
if (j > i && (levels[j].loopInfo?.depth ?? 0) <= depth)
|
|
24538
|
+
break;
|
|
24539
|
+
if (levels[j].events.length > 0)
|
|
24540
|
+
return true;
|
|
24541
|
+
if (conditionalsCarryEvent(levels[j].loopInfo?.bindings.conditionals ?? []))
|
|
24542
|
+
return true;
|
|
24543
|
+
}
|
|
24544
|
+
return false;
|
|
24545
|
+
}
|
|
24546
|
+
function conditionalsCarryEvent(conditionals) {
|
|
24547
|
+
return conditionals.some((c) => [c.whenTrue, c.whenFalse].some((branch) => (branch.events?.length ?? 0) > 0 || conditionalsCarryEvent(branch.conditionals ?? []) || (branch.innerLoops ?? []).some((l) => l.bindings.events.length > 0 || conditionalsCarryEvent(l.bindings.conditionals))));
|
|
24548
|
+
}
|
|
24549
|
+
|
|
24550
|
+
// src/ir-to-client-js/control-flow/plan/build-component-loop.ts
|
|
24551
|
+
function collectTextOnlySlotIds(nodes, into) {
|
|
24552
|
+
for (const node of nodes) {
|
|
24553
|
+
if (node.type === "expression") {
|
|
24554
|
+
if (node.slotId)
|
|
24555
|
+
into.add(node.slotId);
|
|
24556
|
+
} else if (node.type === "conditional" && isTextOnlyConditional(node)) {
|
|
24557
|
+
collectTextOnlySlotIds([node.whenTrue, node.whenFalse], into);
|
|
24558
|
+
}
|
|
24559
|
+
}
|
|
24560
|
+
}
|
|
24561
|
+
function buildComponentLoopPlan(elem, profileComponentName) {
|
|
24562
|
+
const { name } = elem.childComponent;
|
|
24563
|
+
const propsExpr = buildComponentPropsExpr2(elem.childComponent, elem.param, elem.paramBindings, elem.index);
|
|
24564
|
+
const keyExpr = wrapLoopParamAsAccessor(elem.key || "__idx", elem.param, elem.paramBindings, elem.index);
|
|
24565
|
+
const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
|
|
24566
|
+
const mapPreambleWrapped = elem.preamble ? renderPreamble(elem.preamble, {
|
|
24567
|
+
transformJs: (text) => wrapLoopParamAsAccessor(text, elem.param, elem.paramBindings, elem.index),
|
|
24568
|
+
renderLeaf: () => {
|
|
24569
|
+
internalInvariant(false, "component-root loop received a JSX-bearing preamble — Phase 1 should have refused it");
|
|
24570
|
+
}
|
|
24571
|
+
}) : "";
|
|
24572
|
+
const outerNestedComps = (elem.nestedComponents ?? []).filter((c) => !c.loopDepth);
|
|
24573
|
+
const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings, elem.index);
|
|
24574
|
+
const nestedChildrenTextEffectSlotIds = new Set;
|
|
24575
|
+
const nestedComps = outerNestedComps.map((comp) => {
|
|
24576
|
+
const isTextOnly = comp.children?.length ? comp.children.every((c) => c.type === "expression" || c.type === "text" || isTextOnlyConditional(c)) : false;
|
|
24577
|
+
const rawChildrenExpr = isTextOnly ? irChildrenToJsExpr(comp.children) : null;
|
|
24578
|
+
const childrenFreeIds = isTextOnly && comp.children ? irChildrenFreeIds(comp.children) : undefined;
|
|
24579
|
+
const childrenRefsLoop = rawChildrenExpr != null && childrenFreeIds != null && (childrenFreeIds.has(elem.param) || !!elem.index && childrenFreeIds.has(elem.index));
|
|
24580
|
+
if (childrenRefsLoop && comp.children) {
|
|
24581
|
+
collectTextOnlySlotIds(comp.children, nestedChildrenTextEffectSlotIds);
|
|
24582
|
+
}
|
|
24583
|
+
return {
|
|
24584
|
+
componentName: comp.name,
|
|
24585
|
+
selector: buildCompSelector(comp),
|
|
24586
|
+
propsExpr: buildComponentPropsExpr2(comp, elem.param, elem.paramBindings, elem.index),
|
|
24587
|
+
childrenTextEffect: childrenRefsLoop ? buildChildrenTextEffect(comp.children, rawChildrenExpr, wrap) : null
|
|
24588
|
+
};
|
|
24589
|
+
});
|
|
24590
|
+
const rowReactiveTexts = nestedChildrenTextEffectSlotIds.size > 0 ? elem.bindings.reactiveTexts.filter((t) => !nestedChildrenTextEffectSlotIds.has(t.slotId)) : elem.bindings.reactiveTexts;
|
|
24591
|
+
const hasReactiveEffects = hasReactiveLoopBindings({ ...elem.bindings, reactiveTexts: rowReactiveTexts });
|
|
24592
|
+
const rowEvents = elem.bindings.events.filter((ev) => ev.nestedLoops.length === 0).map((ev) => buildRowEventBinding(ev, elem.param, elem.paramBindings, elem.index));
|
|
24593
|
+
const forwardedInnerLoops = (parentElVar) => buildForwardedInnerLoopsPlan({
|
|
24594
|
+
innerLoops: elem.innerLoops,
|
|
24595
|
+
events: elem.bindings.events,
|
|
24596
|
+
parentElVar,
|
|
24597
|
+
outerLoopParam: elem.param,
|
|
24598
|
+
outerLoopParamBindings: elem.paramBindings,
|
|
24599
|
+
outerLoopIndex: elem.index
|
|
24600
|
+
});
|
|
24601
|
+
return {
|
|
24602
|
+
kind: "component",
|
|
24603
|
+
rowConstruction: "dom-ops",
|
|
24604
|
+
mapPreambleWrapped,
|
|
24605
|
+
containerVar: `_${varSlotId(elem.slotId)}`,
|
|
24606
|
+
markerId: elem.markerId,
|
|
24607
|
+
arrayExpr: buildChainedArrayExpr(elem),
|
|
24608
|
+
keyFn: loopKeyFn(elem),
|
|
24609
|
+
paramHead,
|
|
24610
|
+
paramUnwrap,
|
|
24611
|
+
indexParam: elem.index || "__idx",
|
|
24612
|
+
componentName: name,
|
|
24613
|
+
componentPropsExpr: propsExpr,
|
|
24614
|
+
keyExpr,
|
|
24615
|
+
nestedComps,
|
|
24616
|
+
rowEvents,
|
|
24617
|
+
innerLoops: { hydrated: forwardedInnerLoops("__existing"), created: forwardedInnerLoops("__csrEl") },
|
|
24618
|
+
childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
|
|
24619
|
+
profileLoopId: profileComponentName ? `${profileComponentName}#binding:${elem.slotId}` : undefined,
|
|
24620
|
+
profileComponentName,
|
|
24621
|
+
reactiveEffects: hasReactiveEffects ? buildReactiveEffectsPlan({
|
|
24622
|
+
attrs: elem.bindings.reactiveAttrs,
|
|
24623
|
+
texts: rowReactiveTexts,
|
|
24624
|
+
conditionals: elem.bindings.conditionals,
|
|
24625
|
+
loopParam: elem.param,
|
|
24626
|
+
loopParamBindings: elem.paramBindings,
|
|
24627
|
+
loopIndex: elem.index,
|
|
24628
|
+
profileComponentName
|
|
24629
|
+
}) : null
|
|
24630
|
+
};
|
|
24631
|
+
}
|
|
24302
24632
|
|
|
24303
24633
|
// src/ir-to-client-js/control-flow/plan/build-composite-loop.ts
|
|
24304
24634
|
function buildTopLevelCompositePlan(elem, profileComponentName) {
|
|
@@ -24790,7 +25120,12 @@ function buildSingleCompPlan(elem, childComponent) {
|
|
|
24790
25120
|
indexParam: elem.index || "__idx",
|
|
24791
25121
|
outerPreludeStatements: staticPreludeStatements(elem.preamble),
|
|
24792
25122
|
propsExpr: buildStaticPropsExpr(props),
|
|
24793
|
-
rowEvents: elem.bindings.events.filter((ev) => ev.nestedLoops.length === 0).map((ev) => ({ childSlotId: ev.childSlotId, eventName: ev.eventName, handler: ev.handler }))
|
|
25123
|
+
rowEvents: elem.bindings.events.filter((ev) => ev.nestedLoops.length === 0).map((ev) => ({ childSlotId: ev.childSlotId, eventName: ev.eventName, handler: ev.handler, receiverSlotIds: ev.receiverSlotIds })),
|
|
25124
|
+
innerLoops: buildForwardedInnerLoopsPlan({
|
|
25125
|
+
innerLoops: elem.innerLoops,
|
|
25126
|
+
events: elem.bindings.events,
|
|
25127
|
+
parentElVar: "childScope"
|
|
25128
|
+
})
|
|
24794
25129
|
};
|
|
24795
25130
|
}
|
|
24796
25131
|
function buildOuterNestedPlan(elem, comp) {
|
|
@@ -24893,6 +25228,12 @@ function buildStaticPropsExpr(props) {
|
|
|
24893
25228
|
import ts28 from "typescript";
|
|
24894
25229
|
|
|
24895
25230
|
// src/ir-to-client-js/control-flow/stringify/claim-plan.ts
|
|
25231
|
+
function rowTextSlotKind(text) {
|
|
25232
|
+
return text.markup ? "markup" : "text";
|
|
25233
|
+
}
|
|
25234
|
+
function rowTextSlotValue(text, expr, coerce) {
|
|
25235
|
+
return text.markup ? `escapeTextOrNode(${expr})` : `${coerce}(${expr})`;
|
|
25236
|
+
}
|
|
24896
25237
|
function slotSpecLiteral(slot) {
|
|
24897
25238
|
const pathSrc = slot.pathExpr ?? `[${slot.path.join(", ")}]`;
|
|
24898
25239
|
const markerlessSrc = slot.markerless ? ", markerless: true" : "";
|
|
@@ -25242,7 +25583,7 @@ function emitReactivePropBindings(lines, ctx) {
|
|
|
25242
25583
|
const ref = slotId === ctx.commentScopeRootSlotId ? "__scope" : `_${varSlotId(slotId)}`;
|
|
25243
25584
|
lines.push(` if (${ref}) {`);
|
|
25244
25585
|
for (const prop of props) {
|
|
25245
|
-
const value =
|
|
25586
|
+
const value = prop.expression;
|
|
25246
25587
|
if (prop.propName === "selected") {
|
|
25247
25588
|
if (prop.componentName === "TabsContent") {
|
|
25248
25589
|
lines.push(` ${ref}.setAttribute('data-state', ${value} ? 'active' : 'inactive')`);
|
|
@@ -25379,14 +25720,14 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
|
|
|
25379
25720
|
const plainTexts = inner.reactiveTexts.filter((t) => !t.insideConditional);
|
|
25380
25721
|
for (const text of conditionalTexts) {
|
|
25381
25722
|
const bf = profileBindingId(pc, text.slotId);
|
|
25382
|
-
lines.push(`${indent} createEffect(() => { claimSlots(__bel${uid}, [{ id: '${text.slotId}', kind: 'text', path: [] }]).write('${text.slotId}',
|
|
25723
|
+
lines.push(`${indent} createEffect(() => { claimSlots(__bel${uid}, [{ id: '${text.slotId}', kind: '${rowTextSlotKind(text)}', path: [] }]).write('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) }${bf})`);
|
|
25383
25724
|
}
|
|
25384
25725
|
if (plainTexts.length > 0) {
|
|
25385
|
-
const slots = plainTexts.map((t) => ({ id: t.slotId, kind:
|
|
25726
|
+
const slots = plainTexts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
25386
25727
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
25387
25728
|
lines.push(`${indent} const ${writer} = lazySlots(__bel${uid}, ${claimPlanLiteral(slots)})`);
|
|
25388
25729
|
for (const text of plainTexts) {
|
|
25389
|
-
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}',
|
|
25730
|
+
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) }${profileBindingId(pc, text.slotId)})`);
|
|
25390
25731
|
}
|
|
25391
25732
|
}
|
|
25392
25733
|
if (inner.nestedConditionals.length > 0) {
|
|
@@ -25516,7 +25857,7 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
|
|
|
25516
25857
|
if (attrSlots.length > 0)
|
|
25517
25858
|
lines.push(`${indent}${DEDUP_STORE_DECL}`);
|
|
25518
25859
|
const claimSlots = [
|
|
25519
|
-
...outerTexts.map((t) => ({ id: t.slotId, kind:
|
|
25860
|
+
...outerTexts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [], pathExpr: textClaimPathExprs?.get(t.slotId) })),
|
|
25520
25861
|
...preambleRegions.map((r) => ({ id: r.slotId, kind: "markup", path: [] }))
|
|
25521
25862
|
];
|
|
25522
25863
|
const writer = claimSlots.length > 0 ? claimWriterVarName(claimSlots, varSlotId) : null;
|
|
@@ -25525,7 +25866,7 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
|
|
|
25525
25866
|
}
|
|
25526
25867
|
if (attrSlots.length === 0 && preambleRegions.length === 0 && outerTexts.length === 1) {
|
|
25527
25868
|
const text = outerTexts[0];
|
|
25528
|
-
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}',
|
|
25869
|
+
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) })`);
|
|
25529
25870
|
return;
|
|
25530
25871
|
}
|
|
25531
25872
|
lines.push(`${indent}createEffect(() => {`);
|
|
@@ -25544,7 +25885,7 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
|
|
|
25544
25885
|
lines.push(`${indent} }`);
|
|
25545
25886
|
}
|
|
25546
25887
|
for (const text of outerTexts) {
|
|
25547
|
-
lines.push(`${indent} ${writer}('${text.slotId}',
|
|
25888
|
+
lines.push(`${indent} ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")})`);
|
|
25548
25889
|
}
|
|
25549
25890
|
for (const region of preambleRegions) {
|
|
25550
25891
|
lines.push(`${indent} ${writer}('${region.slotId}', ${region.valueExpr})`);
|
|
@@ -25556,14 +25897,14 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
|
|
|
25556
25897
|
return;
|
|
25557
25898
|
const slots = texts.map((t) => ({
|
|
25558
25899
|
id: t.slotId,
|
|
25559
|
-
kind:
|
|
25900
|
+
kind: rowTextSlotKind(t),
|
|
25560
25901
|
path: [],
|
|
25561
25902
|
pathExpr: textClaimPathExprs?.get(t.slotId)
|
|
25562
25903
|
}));
|
|
25563
25904
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
25564
25905
|
lines.push(`${indent}const ${writer} = lazySlots(${elVar}, ${claimPlanLiteral(slots)})`);
|
|
25565
25906
|
for (const text of texts) {
|
|
25566
|
-
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}',
|
|
25907
|
+
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) }${bindingBfId(text.slotId)})`);
|
|
25567
25908
|
}
|
|
25568
25909
|
}
|
|
25569
25910
|
function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
|
|
@@ -25617,72 +25958,6 @@ function buildSkeletonPathPlan(skeletonPaths, elVar, opts) {
|
|
|
25617
25958
|
return { arrayElems, elementIndexBySlot, textIndexBySlot };
|
|
25618
25959
|
}
|
|
25619
25960
|
|
|
25620
|
-
// src/ir-to-client-js/control-flow/stringify/component-loop.ts
|
|
25621
|
-
function stringifyComponentLoop(lines, plan) {
|
|
25622
|
-
const {
|
|
25623
|
-
containerVar,
|
|
25624
|
-
markerId,
|
|
25625
|
-
arrayExpr,
|
|
25626
|
-
keyFn,
|
|
25627
|
-
paramHead,
|
|
25628
|
-
paramUnwrap,
|
|
25629
|
-
indexParam,
|
|
25630
|
-
componentName,
|
|
25631
|
-
componentPropsExpr,
|
|
25632
|
-
keyExpr,
|
|
25633
|
-
nestedComps,
|
|
25634
|
-
rowEvents,
|
|
25635
|
-
childRefs,
|
|
25636
|
-
reactiveEffects,
|
|
25637
|
-
profileLoopId,
|
|
25638
|
-
mapPreambleWrapped
|
|
25639
|
-
} = plan;
|
|
25640
|
-
const loopBfId = profileLoopId ? `, ${JSON.stringify(profileLoopId)}` : "";
|
|
25641
|
-
lines.push(` mapArray(() => ${arrayExpr}, ${containerVar}, ${keyFn}, (${paramHead}, ${indexParam}, __existing) => {`);
|
|
25642
|
-
if (paramUnwrap)
|
|
25643
|
-
lines.push(` ${paramUnwrap}`);
|
|
25644
|
-
if (mapPreambleWrapped)
|
|
25645
|
-
lines.push(` ${mapPreambleWrapped}`);
|
|
25646
|
-
const scopedComp = nameForRegistryRef(componentName);
|
|
25647
|
-
if (nestedComps.length === 0 && !reactiveEffects && rowEvents.length === 0 && childRefs.length === 0) {
|
|
25648
|
-
lines.push(` if (__existing) { initChild('${scopedComp}', __existing, ${componentPropsExpr}); return __existing }`);
|
|
25649
|
-
lines.push(` return createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`);
|
|
25650
|
-
lines.push(` }, '${markerId}'${loopBfId})`);
|
|
25651
|
-
return;
|
|
25652
|
-
}
|
|
25653
|
-
lines.push(` if (__existing) {`);
|
|
25654
|
-
lines.push(` initChild('${scopedComp}', __existing, ${componentPropsExpr})`);
|
|
25655
|
-
for (const nc of nestedComps)
|
|
25656
|
-
emitNestedInit(lines, " ", "__existing", nc);
|
|
25657
|
-
for (const ev of rowEvents)
|
|
25658
|
-
emitRowEventListener(lines, " ", "__existing", ev);
|
|
25659
|
-
if (reactiveEffects) {
|
|
25660
|
-
stringifyReactiveEffects(lines, reactiveEffects, { indent: " ", elVar: "__existing" });
|
|
25661
|
-
}
|
|
25662
|
-
emitLoopChildRefs(lines, childRefs, { indent: " ", elVar: "__existing", bodyIsMultiRoot: false, containerVar });
|
|
25663
|
-
lines.push(` return __existing`);
|
|
25664
|
-
lines.push(` }`);
|
|
25665
|
-
lines.push(` const __csrEl = createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`);
|
|
25666
|
-
for (const nc of nestedComps)
|
|
25667
|
-
emitNestedInit(lines, " ", "__csrEl", nc);
|
|
25668
|
-
for (const ev of rowEvents)
|
|
25669
|
-
emitRowEventListener(lines, " ", "__csrEl", ev);
|
|
25670
|
-
if (reactiveEffects) {
|
|
25671
|
-
stringifyReactiveEffects(lines, reactiveEffects, { indent: " ", elVar: "__csrEl" });
|
|
25672
|
-
}
|
|
25673
|
-
emitLoopChildRefs(lines, childRefs, { indent: " ", elVar: "__csrEl", bodyIsMultiRoot: false, containerVar });
|
|
25674
|
-
lines.push(` return __csrEl`);
|
|
25675
|
-
lines.push(` }, '${markerId}'${loopBfId})`);
|
|
25676
|
-
}
|
|
25677
|
-
function emitNestedInit(lines, indent, parentVar, nc) {
|
|
25678
|
-
const scopedNc = nameForRegistryRef(nc.componentName);
|
|
25679
|
-
if (nc.childrenTextEffect) {
|
|
25680
|
-
lines.push(`${indent}{ const __c = qsa(${parentVar}, ${nc.selector}); if (__c) { initChild('${scopedNc}', __c, ${nc.propsExpr}); ${stringifyChildrenTextEffect(nc.childrenTextEffect)} } }`);
|
|
25681
|
-
} else {
|
|
25682
|
-
lines.push(`${indent}{ const __c = qsa(${parentVar}, ${nc.selector}); if (__c) initChild('${scopedNc}', __c, ${nc.propsExpr}) }`);
|
|
25683
|
-
}
|
|
25684
|
-
}
|
|
25685
|
-
|
|
25686
25961
|
// src/ir-to-client-js/control-flow/stringify/inner-loop.ts
|
|
25687
25962
|
function stringifyInnerLoops(lines, plan, indent, pc) {
|
|
25688
25963
|
for (const inner of plan) {
|
|
@@ -25716,9 +25991,11 @@ function emitReactive(lines, inner, indent, pc) {
|
|
|
25716
25991
|
if (emit.wrappedKey) {
|
|
25717
25992
|
lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${emit.wrappedKey}))`);
|
|
25718
25993
|
}
|
|
25719
|
-
if (emit.components.length > 0
|
|
25720
|
-
emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [
|
|
25994
|
+
if (emit.components.length > 0) {
|
|
25995
|
+
emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [], inner.outerLoopParam, inner.outerLoopParamBindings, false, inner.outerLoopIndex);
|
|
25721
25996
|
}
|
|
25997
|
+
for (const ev of emit.events)
|
|
25998
|
+
emitRowEventListener(lines, `${indent} `, `__innerEl${uid}`, ev);
|
|
25722
25999
|
if (inner.childLevels.length > 0) {
|
|
25723
26000
|
stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc);
|
|
25724
26001
|
}
|
|
@@ -25726,14 +26003,14 @@ function emitReactive(lines, inner, indent, pc) {
|
|
|
25726
26003
|
const plainTexts = emit.reactiveTexts.filter((t) => !t.insideConditional);
|
|
25727
26004
|
for (const text of conditionalTexts) {
|
|
25728
26005
|
const bf = profileBindingId(pc, text.slotId);
|
|
25729
|
-
lines.push(`${indent} createEffect(() => { claimSlots(__innerEl${uid}, [{ id: '${text.slotId}', kind: 'text', path: [] }]).write('${text.slotId}',
|
|
26006
|
+
lines.push(`${indent} createEffect(() => { claimSlots(__innerEl${uid}, [{ id: '${text.slotId}', kind: '${rowTextSlotKind(text)}', path: [] }]).write('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) }${bf})`);
|
|
25730
26007
|
}
|
|
25731
26008
|
if (plainTexts.length > 0) {
|
|
25732
|
-
const slots = plainTexts.map((t) => ({ id: t.slotId, kind:
|
|
26009
|
+
const slots = plainTexts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
25733
26010
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
25734
26011
|
lines.push(`${indent} const ${writer} = lazySlots(__innerEl${uid}, ${claimPlanLiteral(slots)})`);
|
|
25735
26012
|
for (const text of plainTexts) {
|
|
25736
|
-
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}',
|
|
26013
|
+
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) }${profileBindingId(pc, text.slotId)})`);
|
|
25737
26014
|
}
|
|
25738
26015
|
}
|
|
25739
26016
|
if (emit.reactiveAttrs.length > 0)
|
|
@@ -25760,6 +26037,76 @@ function emitReactive(lines, inner, indent, pc) {
|
|
|
25760
26037
|
lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!emit.wrappedKey, inner.keyDepth)}) }`);
|
|
25761
26038
|
}
|
|
25762
26039
|
|
|
26040
|
+
// src/ir-to-client-js/control-flow/stringify/component-loop.ts
|
|
26041
|
+
function stringifyComponentLoop(lines, plan) {
|
|
26042
|
+
const {
|
|
26043
|
+
containerVar,
|
|
26044
|
+
markerId,
|
|
26045
|
+
arrayExpr,
|
|
26046
|
+
keyFn,
|
|
26047
|
+
paramHead,
|
|
26048
|
+
paramUnwrap,
|
|
26049
|
+
indexParam,
|
|
26050
|
+
componentName,
|
|
26051
|
+
componentPropsExpr,
|
|
26052
|
+
keyExpr,
|
|
26053
|
+
nestedComps,
|
|
26054
|
+
rowEvents,
|
|
26055
|
+
innerLoops,
|
|
26056
|
+
childRefs,
|
|
26057
|
+
reactiveEffects,
|
|
26058
|
+
profileLoopId,
|
|
26059
|
+
profileComponentName,
|
|
26060
|
+
mapPreambleWrapped
|
|
26061
|
+
} = plan;
|
|
26062
|
+
const loopBfId = profileLoopId ? `, ${JSON.stringify(profileLoopId)}` : "";
|
|
26063
|
+
lines.push(` mapArray(() => ${arrayExpr}, ${containerVar}, ${keyFn}, (${paramHead}, ${indexParam}, __existing) => {`);
|
|
26064
|
+
if (paramUnwrap)
|
|
26065
|
+
lines.push(` ${paramUnwrap}`);
|
|
26066
|
+
if (mapPreambleWrapped)
|
|
26067
|
+
lines.push(` ${mapPreambleWrapped}`);
|
|
26068
|
+
const scopedComp = nameForRegistryRef(componentName);
|
|
26069
|
+
if (nestedComps.length === 0 && !reactiveEffects && rowEvents.length === 0 && innerLoops.hydrated.length === 0 && childRefs.length === 0) {
|
|
26070
|
+
lines.push(` if (__existing) { initChild('${scopedComp}', __existing, ${componentPropsExpr}); return __existing }`);
|
|
26071
|
+
lines.push(` return createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`);
|
|
26072
|
+
lines.push(` }, '${markerId}'${loopBfId})`);
|
|
26073
|
+
return;
|
|
26074
|
+
}
|
|
26075
|
+
lines.push(` if (__existing) {`);
|
|
26076
|
+
lines.push(` initChild('${scopedComp}', __existing, ${componentPropsExpr})`);
|
|
26077
|
+
for (const nc of nestedComps)
|
|
26078
|
+
emitNestedInit(lines, " ", "__existing", nc);
|
|
26079
|
+
for (const ev of rowEvents)
|
|
26080
|
+
emitRowEventListener(lines, " ", "__existing", ev);
|
|
26081
|
+
stringifyInnerLoops(lines, innerLoops.hydrated, " ", profileComponentName);
|
|
26082
|
+
if (reactiveEffects) {
|
|
26083
|
+
stringifyReactiveEffects(lines, reactiveEffects, { indent: " ", elVar: "__existing" });
|
|
26084
|
+
}
|
|
26085
|
+
emitLoopChildRefs(lines, childRefs, { indent: " ", elVar: "__existing", bodyIsMultiRoot: false, containerVar });
|
|
26086
|
+
lines.push(` return __existing`);
|
|
26087
|
+
lines.push(` }`);
|
|
26088
|
+
lines.push(` const __csrEl = createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`);
|
|
26089
|
+
for (const nc of nestedComps)
|
|
26090
|
+
emitNestedInit(lines, " ", "__csrEl", nc);
|
|
26091
|
+
for (const ev of rowEvents)
|
|
26092
|
+
emitRowEventListener(lines, " ", "__csrEl", ev);
|
|
26093
|
+
stringifyInnerLoops(lines, innerLoops.created, " ", profileComponentName);
|
|
26094
|
+
if (reactiveEffects) {
|
|
26095
|
+
stringifyReactiveEffects(lines, reactiveEffects, { indent: " ", elVar: "__csrEl" });
|
|
26096
|
+
}
|
|
26097
|
+
emitLoopChildRefs(lines, childRefs, { indent: " ", elVar: "__csrEl", bodyIsMultiRoot: false, containerVar });
|
|
26098
|
+
lines.push(` return __csrEl`);
|
|
26099
|
+
lines.push(` }, '${markerId}'${loopBfId})`);
|
|
26100
|
+
}
|
|
26101
|
+
function emitNestedInit(lines, indent, parentVar, nc) {
|
|
26102
|
+
const scopedNc = nameForRegistryRef(nc.componentName);
|
|
26103
|
+
if (nc.childrenTextEffect) {
|
|
26104
|
+
lines.push(`${indent}{ const __c = qsa(${parentVar}, ${nc.selector}); if (__c) { initChild('${scopedNc}', __c, ${nc.propsExpr}); ${stringifyChildrenTextEffect(nc.childrenTextEffect)} } }`);
|
|
26105
|
+
} else {
|
|
26106
|
+
lines.push(`${indent}{ const __c = qsa(${parentVar}, ${nc.selector}); if (__c) initChild('${scopedNc}', __c, ${nc.propsExpr}) }`);
|
|
26107
|
+
}
|
|
26108
|
+
}
|
|
26109
|
+
|
|
25763
26110
|
// src/ir-to-client-js/control-flow/stringify/composite-loop.ts
|
|
25764
26111
|
function stringifyCompositeLoop(lines, plan) {
|
|
25765
26112
|
const {
|
|
@@ -25851,13 +26198,13 @@ function stringifyLazyRowLoop(lines, o) {
|
|
|
25851
26198
|
let freshPlanVar = null;
|
|
25852
26199
|
if (lazyRow.texts.length > 0) {
|
|
25853
26200
|
adoptedPlanVar = `__lzs_${mid}`;
|
|
25854
|
-
const adoptedSlots = lazyRow.texts.map((t) => ({ id: t.slotId, kind:
|
|
26201
|
+
const adoptedSlots = lazyRow.texts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
25855
26202
|
lines.push(`${indent}const ${adoptedPlanVar} = ${claimPlanLiteral(adoptedSlots)}`);
|
|
25856
26203
|
if (textPathVar) {
|
|
25857
26204
|
freshPlanVar = `__lzsc_${mid}`;
|
|
25858
26205
|
const freshSlots = lazyRow.texts.map((t, i) => ({
|
|
25859
26206
|
id: t.slotId,
|
|
25860
|
-
kind:
|
|
26207
|
+
kind: rowTextSlotKind(t),
|
|
25861
26208
|
path: [],
|
|
25862
26209
|
pathExpr: `${textPathVar}[${i}]`
|
|
25863
26210
|
}));
|
|
@@ -26014,15 +26361,16 @@ function emitAttrBinding(lines, ind, a, mode) {
|
|
|
26014
26361
|
function emitTextBinding(lines, ind, t, doorExpr, mode, rwDoor) {
|
|
26015
26362
|
lines.push(`${ind}{ const __x = ${t.wrappedExpression}`);
|
|
26016
26363
|
const writeOf = (valueExpr) => rwDoor ? `${doorExpr}.write('${t.slotId}', ${valueExpr})` : `${doorExpr}('${t.slotId}', ${valueExpr})`;
|
|
26364
|
+
const value = rowTextSlotValue(t, "__x", "textOrNode");
|
|
26017
26365
|
if (mode === "outer") {
|
|
26018
26366
|
lines.push(`${ind}if (__seed) {`);
|
|
26019
|
-
lines.push(`${ind} const __s =
|
|
26367
|
+
lines.push(`${ind} const __s = ${value}`);
|
|
26020
26368
|
lines.push(`${ind} if (${doorExpr}.read('${t.slotId}') !== __s) ${writeOf("__s")}`);
|
|
26021
|
-
lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf(
|
|
26369
|
+
lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf(value)}`);
|
|
26022
26370
|
} else if (mode === "item") {
|
|
26023
|
-
lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf(
|
|
26371
|
+
lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf(value)}`);
|
|
26024
26372
|
} else {
|
|
26025
|
-
lines.push(`${ind}${writeOf(
|
|
26373
|
+
lines.push(`${ind}${writeOf(value)}`);
|
|
26026
26374
|
}
|
|
26027
26375
|
lines.push(`${ind}__l[${t.ordinal}] = __x }`);
|
|
26028
26376
|
}
|
|
@@ -26333,11 +26681,11 @@ function stringifyStaticLoop(lines, plan) {
|
|
|
26333
26681
|
lines.push(` }`);
|
|
26334
26682
|
}
|
|
26335
26683
|
if (texts.length > 0) {
|
|
26336
|
-
const slots = texts.map((t) => ({ id: t.slotId, kind:
|
|
26684
|
+
const slots = texts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
26337
26685
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
26338
26686
|
lines.push(` const ${writer} = lazySlots(__iterEl, ${claimPlanLiteral(slots)})`);
|
|
26339
26687
|
for (const text of texts) {
|
|
26340
|
-
lines.push(` createEffect(() => { ${writer}('${text.slotId}',
|
|
26688
|
+
lines.push(` createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.expression, "String")}) }${profileBindingId(pc, text.slotId)})`);
|
|
26341
26689
|
}
|
|
26342
26690
|
}
|
|
26343
26691
|
emitLoopChildRefs(lines, childRefs, { indent: " ", elVar: "__iterEl", bodyIsMultiRoot: rowHasPortal, containerVar });
|
|
@@ -26370,7 +26718,7 @@ function stringifyOne(lines, plan) {
|
|
|
26370
26718
|
}
|
|
26371
26719
|
}
|
|
26372
26720
|
function emitSingleComp(lines, plan) {
|
|
26373
|
-
const { containerVar, componentName, childSelector, arrayExpr, param, indexParam, outerPreludeStatements, propsExpr, rowEvents } = plan;
|
|
26721
|
+
const { containerVar, componentName, childSelector, arrayExpr, param, indexParam, outerPreludeStatements, propsExpr, rowEvents, innerLoops } = plan;
|
|
26374
26722
|
lines.push(` // Initialize static array children (hydrate skips nested instances)`);
|
|
26375
26723
|
lines.push(` if (${containerVar}) {`);
|
|
26376
26724
|
lines.push(` const __childScopes = qsaChildScopes(${containerVar}, ${childSelector})`);
|
|
@@ -26382,6 +26730,7 @@ function emitSingleComp(lines, plan) {
|
|
|
26382
26730
|
lines.push(` initChild('${nameForRegistryRef(componentName)}', childScope, ${propsExpr})`);
|
|
26383
26731
|
for (const ev of rowEvents)
|
|
26384
26732
|
emitRowEventListener(lines, " ", "childScope", ev);
|
|
26733
|
+
stringifyInnerLoops(lines, innerLoops, " ");
|
|
26385
26734
|
lines.push(` })`);
|
|
26386
26735
|
lines.push(` }`);
|
|
26387
26736
|
lines.push("");
|
|
@@ -26464,11 +26813,11 @@ function emitInnerLoopNested(lines, plan) {
|
|
|
26464
26813
|
lines.push(` }`);
|
|
26465
26814
|
}
|
|
26466
26815
|
if (texts.length > 0) {
|
|
26467
|
-
const slots = texts.map((t) => ({ id: t.slotId, kind:
|
|
26816
|
+
const slots = texts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
26468
26817
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
26469
26818
|
lines.push(` const ${writer} = lazySlots(__innerEl, ${claimPlanLiteral(slots)})`);
|
|
26470
26819
|
for (const text of texts) {
|
|
26471
|
-
lines.push(` createEffect(() => { ${writer}('${text.slotId}',
|
|
26820
|
+
lines.push(` createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.expression, "String")}) })`);
|
|
26472
26821
|
}
|
|
26473
26822
|
}
|
|
26474
26823
|
emitLoopChildRefs(lines, refs, { indent: " ", elVar: "__innerEl", bodyIsMultiRoot: false });
|
|
@@ -28154,8 +28503,8 @@ function collectAndPrefixAttrs(ir, layerName, referencedConstants, constantNames
|
|
|
28154
28503
|
case "template": {
|
|
28155
28504
|
prefixIRTemplateParts(attr.value.parts, layerName);
|
|
28156
28505
|
for (const part of attr.value.parts) {
|
|
28157
|
-
if (part.type === "
|
|
28158
|
-
collectConstantRefs(part.
|
|
28506
|
+
if (part.type === "expression") {
|
|
28507
|
+
collectConstantRefs(part.expr, referencedConstants, constantNames);
|
|
28159
28508
|
}
|
|
28160
28509
|
}
|
|
28161
28510
|
break;
|
|
@@ -28179,7 +28528,7 @@ function prefixIRTemplateParts(parts, layerName) {
|
|
|
28179
28528
|
if (part.type === "ternary") {
|
|
28180
28529
|
part.whenTrue = prefixClassString(part.whenTrue, layerName);
|
|
28181
28530
|
part.whenFalse = prefixClassString(part.whenFalse, layerName);
|
|
28182
|
-
} else if (part.type === "string"
|
|
28531
|
+
} else if (part.type === "string") {
|
|
28183
28532
|
part.value = prefixClassString(part.value, layerName);
|
|
28184
28533
|
}
|
|
28185
28534
|
}
|
|
@@ -28747,7 +29096,9 @@ function checkExpr(expr, loc, meta, bindings, matchers, errors, seen) {
|
|
|
28747
29096
|
}
|
|
28748
29097
|
function walkTemplateParts2(parts, loc, meta, bindings, matchers, errors, seen) {
|
|
28749
29098
|
for (const part of parts) {
|
|
28750
|
-
if (part.type === "
|
|
29099
|
+
if (part.type === "expression") {
|
|
29100
|
+
checkExpr(part.parsed, loc, meta, bindings, matchers, errors, seen);
|
|
29101
|
+
} else if (part.type === "ternary") {
|
|
28751
29102
|
const trimmed = part.condition.trim();
|
|
28752
29103
|
if (trimmed)
|
|
28753
29104
|
checkExpr(parseExpression(trimmed), loc, meta, bindings, matchers, errors, seen);
|
|
@@ -29819,11 +30170,13 @@ function nullableNumberPropNil(type, optional) {
|
|
|
29819
30170
|
const members = type.kind === "union" ? type.unionTypes ?? [] : [type];
|
|
29820
30171
|
const families = new Set(members.map((m) => m.kind === "primitive" ? m.primitive : m.kind));
|
|
29821
30172
|
const admitsNull = families.has("null");
|
|
29822
|
-
const
|
|
30173
|
+
const admitsAbsent = optional || families.has("undefined");
|
|
29823
30174
|
families.delete("null");
|
|
29824
30175
|
families.delete("undefined");
|
|
29825
|
-
if (!
|
|
30176
|
+
if (!(admitsNull || admitsAbsent) || families.size !== 1 || !families.has("number"))
|
|
29826
30177
|
return null;
|
|
30178
|
+
if (admitsNull && admitsAbsent)
|
|
30179
|
+
return "either";
|
|
29827
30180
|
return admitsNull ? "null" : "undefined";
|
|
29828
30181
|
}
|
|
29829
30182
|
function collectNullableNumberProps(ir) {
|
|
@@ -29832,7 +30185,7 @@ function collectNullableNumberProps(ir) {
|
|
|
29832
30185
|
for (const p of ir.metadata.propsParams) {
|
|
29833
30186
|
if (p.isRest || p.defaultValue !== undefined)
|
|
29834
30187
|
continue;
|
|
29835
|
-
const nil = nullableNumberPropNil(p.type, p.optional);
|
|
30188
|
+
const nil = nullableNumberPropNil(p.declaredType ?? p.type, p.optional);
|
|
29836
30189
|
if (nil !== null)
|
|
29837
30190
|
names.set(objectName ? `${objectName}.${p.sourceName ?? p.name}` : p.name, nil);
|
|
29838
30191
|
}
|
|
@@ -29841,6 +30194,8 @@ function collectNullableNumberProps(ir) {
|
|
|
29841
30194
|
function attrValueMayBeNullish(parsed, ctx, isShadowed = () => false) {
|
|
29842
30195
|
const visiting = new Set;
|
|
29843
30196
|
const walk = (expr, shadowed) => {
|
|
30197
|
+
if (methodMayReturnUndefined(expr))
|
|
30198
|
+
return true;
|
|
29844
30199
|
switch (expr.kind) {
|
|
29845
30200
|
case "identifier":
|
|
29846
30201
|
return expr.name === "undefined";
|
|
@@ -29876,8 +30231,15 @@ function attrValueMayBeNullish(parsed, ctx, isShadowed = () => false) {
|
|
|
29876
30231
|
};
|
|
29877
30232
|
return parsed !== undefined && walk(parsed, isShadowed);
|
|
29878
30233
|
}
|
|
30234
|
+
var UNDEFINED_ON_MISS_METHODS = new Set(["find", "findLast"]);
|
|
30235
|
+
function methodMayReturnUndefined(expr) {
|
|
30236
|
+
if (expr.kind === "array-method")
|
|
30237
|
+
return expr.method === "at";
|
|
30238
|
+
return expr.kind === "call" && expr.callee.kind === "member" && !expr.callee.computed && UNDEFINED_ON_MISS_METHODS.has(expr.callee.property);
|
|
30239
|
+
}
|
|
29879
30240
|
function arithmeticOperandIsNull(parsed, ctx, isShadowed = () => false) {
|
|
29880
|
-
|
|
30241
|
+
const seed = arithmeticOperandSeed(parsed, ctx, isShadowed);
|
|
30242
|
+
return seed === "null" || seed === "either";
|
|
29881
30243
|
}
|
|
29882
30244
|
function arithmeticOperandIsUndefined(parsed, ctx, isShadowed = () => false) {
|
|
29883
30245
|
return arithmeticOperandSeed(parsed, ctx, isShadowed) === "undefined";
|
|
@@ -29891,7 +30253,7 @@ function arithmeticOperandSeed(parsed, ctx, isShadowed) {
|
|
|
29891
30253
|
return "undefined";
|
|
29892
30254
|
const prop = nullableNumberPropRead(expr, ctx, shadowed);
|
|
29893
30255
|
if (prop !== null)
|
|
29894
|
-
return prop === "undefined" ? "absent" :
|
|
30256
|
+
return prop === "undefined" ? "absent" : prop;
|
|
29895
30257
|
const getter = expr.kind === "identifier" ? expr.name : bareGetterCallName(expr);
|
|
29896
30258
|
if (getter === null || shadowed(getter))
|
|
29897
30259
|
return null;
|
|
@@ -29921,11 +30283,71 @@ function nullableNumberPropRead(expr, ctx, shadowed) {
|
|
|
29921
30283
|
}
|
|
29922
30284
|
var NULL_COERCING_ARITHMETIC_OPS = new Set(["-", "*", "/", "%", "**"]);
|
|
29923
30285
|
function arithmeticOperandCoercion(op, operand, other, ctx, isShadowed = () => false) {
|
|
29924
|
-
|
|
29925
|
-
if (!numeric)
|
|
30286
|
+
if (!isNumericArithmetic(op, other))
|
|
29926
30287
|
return null;
|
|
29927
30288
|
const seed = arithmeticOperandSeed(operand, ctx, isShadowed);
|
|
29928
|
-
|
|
30289
|
+
if (seed === "absent")
|
|
30290
|
+
return "undefined";
|
|
30291
|
+
return seed === "either" ? "null" : seed;
|
|
30292
|
+
}
|
|
30293
|
+
function arithmeticOperandNilIsAmbiguous(op, operand, other, ctx, isShadowed = () => false) {
|
|
30294
|
+
return isNumericArithmetic(op, other) && arithmeticOperandSeed(operand, ctx, isShadowed) === "either";
|
|
30295
|
+
}
|
|
30296
|
+
function ambiguousNilArithmeticOperands(expr, ctx, scope = BindingScope.EMPTY) {
|
|
30297
|
+
const found = [];
|
|
30298
|
+
const visit3 = (e, at) => {
|
|
30299
|
+
if (e.kind === "arrow") {
|
|
30300
|
+
visit3(e.body, at.enterCallback(e.params));
|
|
30301
|
+
return;
|
|
30302
|
+
}
|
|
30303
|
+
for (const [op, operand, other] of arithmeticOperandsOf(e)) {
|
|
30304
|
+
if (arithmeticOperandNilIsAmbiguous(op, operand, other, ctx, at.asShadowPredicate()))
|
|
30305
|
+
found.push(operand);
|
|
30306
|
+
}
|
|
30307
|
+
for (const child of parsedExprChildren2(e))
|
|
30308
|
+
visit3(child, at);
|
|
30309
|
+
};
|
|
30310
|
+
if (!ctx.nullableNumberProps?.size)
|
|
30311
|
+
return found;
|
|
30312
|
+
visit3(expr, scope);
|
|
30313
|
+
return found;
|
|
30314
|
+
}
|
|
30315
|
+
function arithmeticOperandsOf(e) {
|
|
30316
|
+
if (e.kind === "binary")
|
|
30317
|
+
return [[e.op, e.left, e.right], [e.op, e.right, e.left]];
|
|
30318
|
+
if (e.kind === "unary" && e.op === "-")
|
|
30319
|
+
return [["-", e.argument, undefined]];
|
|
30320
|
+
return [];
|
|
30321
|
+
}
|
|
30322
|
+
function parsedExprChildren2(e) {
|
|
30323
|
+
switch (e.kind) {
|
|
30324
|
+
case "call":
|
|
30325
|
+
return [e.callee, ...e.args];
|
|
30326
|
+
case "member":
|
|
30327
|
+
return [e.object];
|
|
30328
|
+
case "index-access":
|
|
30329
|
+
return [e.object, e.index];
|
|
30330
|
+
case "binary":
|
|
30331
|
+
case "logical":
|
|
30332
|
+
return [e.left, e.right];
|
|
30333
|
+
case "unary":
|
|
30334
|
+
return [e.argument];
|
|
30335
|
+
case "conditional":
|
|
30336
|
+
return [e.test, e.consequent, e.alternate];
|
|
30337
|
+
case "template-literal":
|
|
30338
|
+
return e.parts.flatMap((p) => p.type === "expression" ? [p.expr] : []);
|
|
30339
|
+
case "array-literal":
|
|
30340
|
+
return e.elements;
|
|
30341
|
+
case "array-method":
|
|
30342
|
+
return [e.object, ...e.args, ...e.method === "flat" && e.depthExpr ? [e.depthExpr] : []];
|
|
30343
|
+
case "object-literal":
|
|
30344
|
+
return e.properties.map((p) => p.kind === "spread" ? p.expr : p.value);
|
|
30345
|
+
default:
|
|
30346
|
+
return [];
|
|
30347
|
+
}
|
|
30348
|
+
}
|
|
30349
|
+
function isNumericArithmetic(op, other) {
|
|
30350
|
+
return NULL_COERCING_ARITHMETIC_OPS.has(op) || op === "+" && isNumberLiteral(other);
|
|
29929
30351
|
}
|
|
29930
30352
|
function isNumberLiteral(expr) {
|
|
29931
30353
|
if (expr?.kind === "unary" && expr.op === "-")
|
|
@@ -30036,6 +30458,43 @@ function rootPropReadName(name, scope, aliases) {
|
|
|
30036
30458
|
return name;
|
|
30037
30459
|
return aliases.get(name) ?? name;
|
|
30038
30460
|
}
|
|
30461
|
+
function isRootPropsObject(expr, isBound) {
|
|
30462
|
+
return expr.kind === "identifier" && expr.name === PROPS_OBJECT_IDENTIFIER && !isBound(expr.name);
|
|
30463
|
+
}
|
|
30464
|
+
|
|
30465
|
+
// src/adapters/ambiguous-nil-arithmetic.ts
|
|
30466
|
+
function arithmeticCoercionOrRefuse(op, operand, other, ctx, isShadowed, sink) {
|
|
30467
|
+
if (arithmeticOperandNilIsAmbiguous(op, operand, other, ctx, isShadowed)) {
|
|
30468
|
+
recordAmbiguousNilArithmetic(exprToString(operand), sink);
|
|
30469
|
+
}
|
|
30470
|
+
return arithmeticOperandCoercion(op, operand, other, ctx, isShadowed);
|
|
30471
|
+
}
|
|
30472
|
+
function refuseAmbiguousNilArithmetic(expr, ctx, scope, sink) {
|
|
30473
|
+
for (const operand of ambiguousNilArithmeticOperands(expr, ctx, scope)) {
|
|
30474
|
+
recordAmbiguousNilArithmetic(exprToString(operand), sink);
|
|
30475
|
+
}
|
|
30476
|
+
}
|
|
30477
|
+
function refuseAmbiguousNilMemoArithmetic(memos, ctx, sink) {
|
|
30478
|
+
for (const memo of memos) {
|
|
30479
|
+
if (memo.parsed)
|
|
30480
|
+
refuseAmbiguousNilArithmetic(memo.parsed, ctx, BindingScope.EMPTY, sink);
|
|
30481
|
+
}
|
|
30482
|
+
}
|
|
30483
|
+
function recordAmbiguousNilArithmetic(operandText, sink) {
|
|
30484
|
+
const message = `Arithmetic over \`${operandText}\` reads a number prop declared both optional and nullable (\`?: number | null\`). JS reads it as \`undefined\` when the caller omits it (\`NaN\` in arithmetic) and as \`0\` when it is \`null\`, but a template engine holds both as the same nil, so the server render cannot tell which one it is.`;
|
|
30485
|
+
if (sink.errors.some((e) => e.code === "BF101" && e.message === message))
|
|
30486
|
+
return;
|
|
30487
|
+
sink.errors.push({
|
|
30488
|
+
code: "BF101",
|
|
30489
|
+
severity: "error",
|
|
30490
|
+
message,
|
|
30491
|
+
loc: { file: `${sink.componentName}.tsx`, start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
30492
|
+
suggestion: {
|
|
30493
|
+
message: "Declare the prop as only optional (`?: number`) or only nullable (`: number | null`), or give it a default value.",
|
|
30494
|
+
escape: [{ kind: "rewrite" }]
|
|
30495
|
+
}
|
|
30496
|
+
});
|
|
30497
|
+
}
|
|
30039
30498
|
|
|
30040
30499
|
// src/adapters/component-tree.ts
|
|
30041
30500
|
function hasClientInteractivity(ir) {
|
|
@@ -30114,6 +30573,9 @@ function computedConstContext(metadata, isShadowed, isAdapterBound = () => false
|
|
|
30114
30573
|
getters: new Set([...metadata.signals.map((s) => s.getter), ...metadata.memos.map((m) => m.name)]),
|
|
30115
30574
|
contextConsumers: new Set(collectContextConsumers(metadata).map((c) => c.localName)),
|
|
30116
30575
|
propsBindings: propsBindingNames(metadata),
|
|
30576
|
+
propReads: propReadKeys(metadata, bindings),
|
|
30577
|
+
localFunctions: new Set(metadata.localFunctions.filter((f) => !f.isModule).map((f) => f.name)),
|
|
30578
|
+
componentNames: componentScopeNames(metadata),
|
|
30117
30579
|
isShadowed,
|
|
30118
30580
|
isAdapterBound,
|
|
30119
30581
|
isGlobal: (name) => !bindings.has(name) && name !== metadata.restPropsName && !isShadowed(name)
|
|
@@ -30136,6 +30598,50 @@ function propsBindingNames(metadata) {
|
|
|
30136
30598
|
}
|
|
30137
30599
|
return names;
|
|
30138
30600
|
}
|
|
30601
|
+
function componentScopeNames(metadata) {
|
|
30602
|
+
const names = new Set;
|
|
30603
|
+
if (metadata.propsObjectName !== null)
|
|
30604
|
+
names.add(metadata.propsObjectName);
|
|
30605
|
+
else
|
|
30606
|
+
for (const p of metadata.propsParams)
|
|
30607
|
+
names.add(p.name);
|
|
30608
|
+
if (metadata.restPropsName)
|
|
30609
|
+
names.add(metadata.restPropsName);
|
|
30610
|
+
for (const c of metadata.localConstants)
|
|
30611
|
+
if (!c.isModule)
|
|
30612
|
+
names.add(c.name);
|
|
30613
|
+
for (const f of metadata.localFunctions)
|
|
30614
|
+
if (!f.isModule)
|
|
30615
|
+
names.add(f.name);
|
|
30616
|
+
for (const s of metadata.signals) {
|
|
30617
|
+
if (s.isModule)
|
|
30618
|
+
continue;
|
|
30619
|
+
names.add(s.getter);
|
|
30620
|
+
if (s.setter)
|
|
30621
|
+
names.add(s.setter);
|
|
30622
|
+
}
|
|
30623
|
+
for (const m of metadata.memos)
|
|
30624
|
+
if (!m.isModule)
|
|
30625
|
+
names.add(m.name);
|
|
30626
|
+
return names;
|
|
30627
|
+
}
|
|
30628
|
+
function propReadKeys(metadata, bindings) {
|
|
30629
|
+
const reads = new Map;
|
|
30630
|
+
const propsObject = metadata.propsObjectName;
|
|
30631
|
+
if (propsObject === null ? bindings.has(PROPS_OBJECT_IDENTIFIER) : propsObject !== PROPS_OBJECT_IDENTIFIER)
|
|
30632
|
+
return reads;
|
|
30633
|
+
const destructures = propsBindingNames(metadata);
|
|
30634
|
+
for (const param of metadata.propsParams) {
|
|
30635
|
+
if (param.isRest)
|
|
30636
|
+
continue;
|
|
30637
|
+
if (propsObject !== null && !destructures.has(param.name))
|
|
30638
|
+
continue;
|
|
30639
|
+
if (bindings.get(param.name) !== "prop")
|
|
30640
|
+
continue;
|
|
30641
|
+
reads.set(param.name, param.sourceName ?? param.name);
|
|
30642
|
+
}
|
|
30643
|
+
return reads;
|
|
30644
|
+
}
|
|
30139
30645
|
var MAX_DEPTH = 16;
|
|
30140
30646
|
function inlineComputedConsts(expr, ctx) {
|
|
30141
30647
|
if (!ctx?.constants?.length)
|
|
@@ -30158,10 +30664,88 @@ function inlineOnce(expr, ctx) {
|
|
|
30158
30664
|
const init = inlinableInitializer(name, ctx);
|
|
30159
30665
|
if (!init)
|
|
30160
30666
|
continue;
|
|
30161
|
-
result = inlineBinding(result, name, init) ?? result;
|
|
30667
|
+
result = inlineBinding(result, name, init) ?? inlineUnderCallbacks(result, name, init, ctx) ?? result;
|
|
30668
|
+
}
|
|
30669
|
+
return result;
|
|
30670
|
+
}
|
|
30671
|
+
function inlineUnderCallbacks(expr, name, init, ctx) {
|
|
30672
|
+
const params = arrowParamNames(expr);
|
|
30673
|
+
if (params.size === 0)
|
|
30674
|
+
return null;
|
|
30675
|
+
const resolved = resolveInComponentScope(init, ctx, (n) => params.has(n) || ctx.isShadowed(n));
|
|
30676
|
+
return resolved ? inlineBinding(expr, name, resolved) : null;
|
|
30677
|
+
}
|
|
30678
|
+
function arrowParamNames(expr) {
|
|
30679
|
+
const names = new Set;
|
|
30680
|
+
const visit3 = (node) => {
|
|
30681
|
+
if (node === null || typeof node !== "object")
|
|
30682
|
+
return;
|
|
30683
|
+
if (Array.isArray(node)) {
|
|
30684
|
+
node.forEach(visit3);
|
|
30685
|
+
return;
|
|
30686
|
+
}
|
|
30687
|
+
const e = node;
|
|
30688
|
+
if (e.kind === "arrow")
|
|
30689
|
+
for (const p of e.params)
|
|
30690
|
+
names.add(p);
|
|
30691
|
+
for (const value of Object.values(e))
|
|
30692
|
+
visit3(value);
|
|
30693
|
+
};
|
|
30694
|
+
visit3(expr);
|
|
30695
|
+
return names;
|
|
30696
|
+
}
|
|
30697
|
+
function resolveInitializer(init, ctx, captured, scope, depth = 0) {
|
|
30698
|
+
const free = freeIdentifiers(init);
|
|
30699
|
+
if (!free || depth >= MAX_DEPTH)
|
|
30700
|
+
return null;
|
|
30701
|
+
let result = init;
|
|
30702
|
+
for (const name of free) {
|
|
30703
|
+
if (!captured(name) && !(scope === "module" && ctx.componentNames.has(name)))
|
|
30704
|
+
continue;
|
|
30705
|
+
const value = scope === "module" ? moduleScopeValue(name, ctx, captured, depth) : componentScopeValue(name, ctx, captured, depth);
|
|
30706
|
+
const next = value ? inlineBinding(result, name, value) : null;
|
|
30707
|
+
if (!next)
|
|
30708
|
+
return null;
|
|
30709
|
+
result = next;
|
|
30162
30710
|
}
|
|
30163
30711
|
return result;
|
|
30164
30712
|
}
|
|
30713
|
+
function resolveInComponentScope(init, ctx, captured) {
|
|
30714
|
+
return resolveInitializer(init, ctx, captured, "component");
|
|
30715
|
+
}
|
|
30716
|
+
function componentScopeValue(name, ctx, captured, depth) {
|
|
30717
|
+
if (ctx.getters.has(name) || ctx.contextConsumers.has(name) || ctx.localFunctions.has(name))
|
|
30718
|
+
return null;
|
|
30719
|
+
if (ctx.isAdapterBound(name))
|
|
30720
|
+
return null;
|
|
30721
|
+
const key = ctx.propReads.get(name);
|
|
30722
|
+
if (key !== undefined) {
|
|
30723
|
+
if (captured(PROPS_OBJECT_IDENTIFIER))
|
|
30724
|
+
return null;
|
|
30725
|
+
return { kind: "member", object: { kind: "identifier", name: PROPS_OBJECT_IDENTIFIER }, property: key, computed: false, optional: false };
|
|
30726
|
+
}
|
|
30727
|
+
if (ctx.componentNames.has(name) && !componentConst(name, ctx))
|
|
30728
|
+
return null;
|
|
30729
|
+
return constValue(componentConst(name, ctx) ?? moduleConst(name, ctx), ctx, captured, depth);
|
|
30730
|
+
}
|
|
30731
|
+
function moduleScopeValue(name, ctx, captured, depth) {
|
|
30732
|
+
return constValue(moduleConst(name, ctx), ctx, captured, depth);
|
|
30733
|
+
}
|
|
30734
|
+
function constValue(constant, ctx, captured, depth) {
|
|
30735
|
+
const init = constant?.parsed;
|
|
30736
|
+
if (!constant || !init || !constant.isModule && ctx.propsBindings.has(constant.name))
|
|
30737
|
+
return null;
|
|
30738
|
+
const literal = lookupLiteralConst(constant.name, [constant], () => false) !== null;
|
|
30739
|
+
if (!literal && !(isPlainComputedConst(constant, init) && callsOnlyGetters(init, constant.isModule ? new Set : ctx.getters)))
|
|
30740
|
+
return null;
|
|
30741
|
+
return resolveInitializer(init, ctx, captured, constant.isModule ? "module" : "component", depth + 1);
|
|
30742
|
+
}
|
|
30743
|
+
function componentConst(name, ctx) {
|
|
30744
|
+
return ctx.constants?.find((c) => c.name === name && !c.isModule);
|
|
30745
|
+
}
|
|
30746
|
+
function moduleConst(name, ctx) {
|
|
30747
|
+
return ctx.constants?.find((c) => c.name === name && c.isModule);
|
|
30748
|
+
}
|
|
30165
30749
|
function inlineComputedConstAttr(value, ctx) {
|
|
30166
30750
|
if (!ctx)
|
|
30167
30751
|
return value;
|
|
@@ -30172,7 +30756,7 @@ function inlineComputedConstAttr(value, ctx) {
|
|
|
30172
30756
|
return { ...value, expr: stringifyParsedExpr(inlined), parsed: inlined, templateExpr: undefined, parts: undefined };
|
|
30173
30757
|
}
|
|
30174
30758
|
function inlinableInitializer(name, ctx) {
|
|
30175
|
-
const constant = ctx
|
|
30759
|
+
const constant = componentConst(name, ctx) ?? (ctx.componentNames.has(name) ? undefined : moduleConst(name, ctx));
|
|
30176
30760
|
const init = constant?.parsed;
|
|
30177
30761
|
if (!constant || !init || !isPlainComputedConst(constant, init))
|
|
30178
30762
|
return null;
|
|
@@ -30180,12 +30764,11 @@ function inlinableInitializer(name, ctx) {
|
|
|
30180
30764
|
return null;
|
|
30181
30765
|
if (ctx.isAdapterBound(name))
|
|
30182
30766
|
return null;
|
|
30183
|
-
if (lookupLiteralConst(name,
|
|
30767
|
+
if (lookupLiteralConst(name, [constant], ctx.isShadowed) !== null)
|
|
30184
30768
|
return null;
|
|
30185
|
-
|
|
30186
|
-
if (!free || [...free].some((n) => ctx.isShadowed(n)))
|
|
30769
|
+
if (!callsOnlyGetters(init, ctx.getters))
|
|
30187
30770
|
return null;
|
|
30188
|
-
return
|
|
30771
|
+
return resolveInitializer(init, ctx, (n) => ctx.isShadowed(n), constant.isModule ? "module" : "component");
|
|
30189
30772
|
}
|
|
30190
30773
|
function isPlainComputedConst(constant, init) {
|
|
30191
30774
|
if (constant.mutatedAfterDeclaration)
|
|
@@ -30219,279 +30802,910 @@ function callsOnlyGetters(init, getters) {
|
|
|
30219
30802
|
return ok;
|
|
30220
30803
|
}
|
|
30221
30804
|
|
|
30222
|
-
// src/
|
|
30223
|
-
function
|
|
30224
|
-
|
|
30225
|
-
|
|
30226
|
-
function collectNullableOptionalProps(ir) {
|
|
30227
|
-
return new Set([
|
|
30228
|
-
...ir.metadata.propsParams.filter((p) => p.defaultValue === undefined && !p.isRest && (p.type?.kind !== "primitive" || p.optional)).map((p) => p.name),
|
|
30229
|
-
...ir.metadata.restPropsExpandedKeys
|
|
30230
|
-
]);
|
|
30231
|
-
}
|
|
30232
|
-
function isBooleanTypedPropRef(expr, ctx) {
|
|
30233
|
-
let bare = expr.trim();
|
|
30234
|
-
if (ctx.propsObjectName && bare.startsWith(`${ctx.propsObjectName}.`)) {
|
|
30235
|
-
bare = bare.slice(ctx.propsObjectName.length + 1);
|
|
30236
|
-
}
|
|
30237
|
-
if (!/^[A-Za-z_$][\w$]*$/.test(bare))
|
|
30805
|
+
// src/loop-destructure.ts
|
|
30806
|
+
function isLowerableLoopDestructure(loop) {
|
|
30807
|
+
const bindings = loop.paramBindings;
|
|
30808
|
+
if (!bindings || bindings.length === 0)
|
|
30238
30809
|
return false;
|
|
30239
|
-
if (
|
|
30810
|
+
if (loop.filterPredicate)
|
|
30240
30811
|
return false;
|
|
30241
|
-
|
|
30812
|
+
for (const name of [...bindings.map((b) => b.name), loop.index]) {
|
|
30813
|
+
if (name && name.startsWith("__bf_"))
|
|
30814
|
+
return false;
|
|
30815
|
+
}
|
|
30816
|
+
for (const b of bindings) {
|
|
30817
|
+
if (b.rest) {
|
|
30818
|
+
if (!b.segments)
|
|
30819
|
+
return false;
|
|
30820
|
+
} else if (!b.segments || b.segments.length === 0) {
|
|
30821
|
+
return false;
|
|
30822
|
+
}
|
|
30823
|
+
}
|
|
30824
|
+
const objectRestNames = bindings.filter((b) => b.rest?.kind === "object").map((b) => b.name);
|
|
30825
|
+
if (objectRestNames.length === 0)
|
|
30826
|
+
return true;
|
|
30827
|
+
return !restNamesMisused(loop, objectRestNames);
|
|
30242
30828
|
}
|
|
30243
|
-
|
|
30244
|
-
|
|
30245
|
-
|
|
30246
|
-
const
|
|
30247
|
-
|
|
30248
|
-
|
|
30249
|
-
|
|
30250
|
-
|
|
30251
|
-
|
|
30252
|
-
|
|
30253
|
-
|
|
30254
|
-
|
|
30255
|
-
|
|
30256
|
-
const check = (scope) => {
|
|
30257
|
-
const byTarget = new Map;
|
|
30258
|
-
for (const name of new Set([...rootNames, ...scope.boundNames()])) {
|
|
30259
|
-
const target = ident(name);
|
|
30260
|
-
const group = byTarget.get(target);
|
|
30261
|
-
if (group)
|
|
30262
|
-
group.push(name);
|
|
30263
|
-
else
|
|
30264
|
-
byTarget.set(target, [name]);
|
|
30829
|
+
var isLowerableObjectRestDestructure = isLowerableLoopDestructure;
|
|
30830
|
+
function restNamesMisused(loop, names) {
|
|
30831
|
+
const nameSet = new Set(names);
|
|
30832
|
+
const valueUse = names.map((n) => new RegExp(`(?<![\\w.$])${escapeRe(n)}(?!\\s*\\??\\.)(?![\\w$])`));
|
|
30833
|
+
let misused = false;
|
|
30834
|
+
const check = (s) => {
|
|
30835
|
+
if (!s || misused)
|
|
30836
|
+
return;
|
|
30837
|
+
for (const re of valueUse) {
|
|
30838
|
+
if (re.test(s)) {
|
|
30839
|
+
misused = true;
|
|
30840
|
+
return;
|
|
30841
|
+
}
|
|
30265
30842
|
}
|
|
30266
|
-
|
|
30267
|
-
|
|
30268
|
-
|
|
30269
|
-
|
|
30270
|
-
|
|
30271
|
-
|
|
30272
|
-
|
|
30273
|
-
|
|
30274
|
-
|
|
30275
|
-
|
|
30276
|
-
severity: "error",
|
|
30277
|
-
message: `${list} both become the ${adapterName} template variable \`${target}\`, so they would read the same value. ${adapterName} reserves some names and renames them, and the new name collides with another name in this component.`,
|
|
30278
|
-
loc: { file: `${componentName}.tsx`, start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
30279
|
-
suggestion: {
|
|
30280
|
-
message: `Rename one of ${list} so the two names stay distinct after the ${adapterName} renaming.`,
|
|
30281
|
-
escape: [{ kind: "rewrite" }]
|
|
30282
|
-
}
|
|
30283
|
-
});
|
|
30843
|
+
};
|
|
30844
|
+
const attr = (v, isIntrinsicElementAttrs) => {
|
|
30845
|
+
if (v.kind === "spread" && isIntrinsicElementAttrs && nameSet.has(v.expr.trim())) {
|
|
30846
|
+
return;
|
|
30847
|
+
}
|
|
30848
|
+
if (v.kind === "expression" || v.kind === "spread") {
|
|
30849
|
+
check(v.expr);
|
|
30850
|
+
check(v.templateExpr);
|
|
30851
|
+
} else if (v.kind === "template") {
|
|
30852
|
+
v.parts.forEach(part);
|
|
30284
30853
|
}
|
|
30285
30854
|
};
|
|
30286
|
-
const
|
|
30287
|
-
if (
|
|
30855
|
+
const part = (p) => {
|
|
30856
|
+
if (p.type === "expression") {
|
|
30857
|
+
check(p.expr);
|
|
30858
|
+
check(p.templateExpr);
|
|
30859
|
+
} else if (p.type === "ternary") {
|
|
30860
|
+
check(p.condition);
|
|
30861
|
+
check(p.templateCondition);
|
|
30862
|
+
check(p.whenTrue);
|
|
30863
|
+
check(p.whenFalse);
|
|
30864
|
+
} else if (p.type === "lookup") {
|
|
30865
|
+
check(p.key);
|
|
30866
|
+
check(p.templateKey);
|
|
30867
|
+
}
|
|
30868
|
+
};
|
|
30869
|
+
const visitLoop = (l) => {
|
|
30870
|
+
if (misused)
|
|
30871
|
+
return;
|
|
30872
|
+
check(l.array);
|
|
30873
|
+
check(l.templateArray);
|
|
30874
|
+
check(l.key);
|
|
30875
|
+
if (l.preamble) {
|
|
30876
|
+
check(preambleAnalysisText(l.preamble));
|
|
30877
|
+
check(preambleAnalysisTemplateText(l.preamble));
|
|
30878
|
+
}
|
|
30879
|
+
if (l.flatMapCallback) {
|
|
30880
|
+
check(preambleAnalysisText(l.flatMapCallback));
|
|
30881
|
+
for (const seg of l.flatMapCallback.segments) {
|
|
30882
|
+
if (seg.kind === "jsx")
|
|
30883
|
+
visit3(seg.ir);
|
|
30884
|
+
}
|
|
30885
|
+
}
|
|
30886
|
+
l.children.forEach(visit3);
|
|
30887
|
+
};
|
|
30888
|
+
const visit3 = (node) => {
|
|
30889
|
+
if (misused)
|
|
30288
30890
|
return;
|
|
30289
30891
|
switch (node.type) {
|
|
30892
|
+
case "expression":
|
|
30893
|
+
check(node.expr);
|
|
30894
|
+
check(node.templateExpr);
|
|
30895
|
+
break;
|
|
30896
|
+
case "conditional":
|
|
30897
|
+
check(node.condition);
|
|
30898
|
+
check(node.templateCondition);
|
|
30899
|
+
visit3(node.whenTrue);
|
|
30900
|
+
visit3(node.whenFalse);
|
|
30901
|
+
break;
|
|
30902
|
+
case "if-statement":
|
|
30903
|
+
check(node.condition);
|
|
30904
|
+
check(node.templateCondition);
|
|
30905
|
+
for (const sv of node.scopeVariables) {
|
|
30906
|
+
check(sv.initializer);
|
|
30907
|
+
check(sv.templateInitializer);
|
|
30908
|
+
}
|
|
30909
|
+
visit3(node.consequent);
|
|
30910
|
+
if (node.alternate)
|
|
30911
|
+
visit3(node.alternate);
|
|
30912
|
+
break;
|
|
30290
30913
|
case "element":
|
|
30914
|
+
node.attrs.forEach((a) => attr(a.value, true));
|
|
30915
|
+
node.events.forEach((e) => check(e.handler));
|
|
30916
|
+
node.children.forEach(visit3);
|
|
30917
|
+
break;
|
|
30291
30918
|
case "component":
|
|
30292
|
-
|
|
30293
|
-
|
|
30294
|
-
for (const child of node.children)
|
|
30295
|
-
visit3(child, scope);
|
|
30919
|
+
node.props.forEach((p) => attr(p.value, false));
|
|
30920
|
+
node.children.forEach(visit3);
|
|
30296
30921
|
break;
|
|
30297
|
-
case "
|
|
30298
|
-
|
|
30299
|
-
|
|
30300
|
-
visit3(child, scope);
|
|
30922
|
+
case "provider":
|
|
30923
|
+
attr(node.valueProp.value, false);
|
|
30924
|
+
node.children.forEach(visit3);
|
|
30301
30925
|
break;
|
|
30302
|
-
case "
|
|
30303
|
-
|
|
30304
|
-
check(scope.enterCallback([node.filterPredicate.param]));
|
|
30305
|
-
const row = scope.enterLoopRow(node);
|
|
30306
|
-
check(row);
|
|
30307
|
-
for (const child of node.children)
|
|
30308
|
-
visit3(child, row);
|
|
30309
|
-
if (node.childComponent) {
|
|
30310
|
-
for (const child of node.childComponent.children)
|
|
30311
|
-
visit3(child, row);
|
|
30312
|
-
}
|
|
30313
|
-
for (const nested of node.nestedComponents ?? []) {
|
|
30314
|
-
for (const child of nested.children)
|
|
30315
|
-
visit3(child, row);
|
|
30316
|
-
}
|
|
30317
|
-
for (const seg of node.flatMapCallback?.segments ?? []) {
|
|
30318
|
-
if (seg.kind === "jsx")
|
|
30319
|
-
visit3(seg.ir, row);
|
|
30320
|
-
}
|
|
30321
|
-
for (const seg of node.preamble?.segments ?? []) {
|
|
30322
|
-
if (seg.kind === "jsx")
|
|
30323
|
-
visit3(seg.ir, row);
|
|
30324
|
-
}
|
|
30926
|
+
case "fragment":
|
|
30927
|
+
node.children.forEach(visit3);
|
|
30325
30928
|
break;
|
|
30326
|
-
|
|
30327
|
-
|
|
30328
|
-
|
|
30329
|
-
visit3(node.whenFalse, scope);
|
|
30929
|
+
case "async":
|
|
30930
|
+
visit3(node.fallback);
|
|
30931
|
+
node.children.forEach(visit3);
|
|
30330
30932
|
break;
|
|
30331
|
-
case "
|
|
30332
|
-
|
|
30333
|
-
if (node.alternate)
|
|
30334
|
-
visit3(node.alternate, scope);
|
|
30933
|
+
case "loop":
|
|
30934
|
+
visitLoop(node);
|
|
30335
30935
|
break;
|
|
30336
30936
|
case "text":
|
|
30337
|
-
case "expression":
|
|
30338
30937
|
case "slot":
|
|
30339
30938
|
break;
|
|
30340
30939
|
}
|
|
30341
30940
|
};
|
|
30342
|
-
|
|
30343
|
-
|
|
30344
|
-
|
|
30941
|
+
visitLoop(loop);
|
|
30942
|
+
return misused;
|
|
30943
|
+
}
|
|
30944
|
+
function escapeRe(s) {
|
|
30945
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
30345
30946
|
}
|
|
30346
30947
|
|
|
30347
|
-
// src/
|
|
30348
|
-
|
|
30349
|
-
|
|
30350
|
-
|
|
30351
|
-
|
|
30352
|
-
|
|
30353
|
-
|
|
30354
|
-
|
|
30355
|
-
|
|
30356
|
-
|
|
30357
|
-
|
|
30358
|
-
|
|
30359
|
-
|
|
30360
|
-
|
|
30361
|
-
|
|
30362
|
-
|
|
30363
|
-
|
|
30364
|
-
|
|
30365
|
-
nullishAttrCtx = { nullableSignals: new Set, memos: new Map };
|
|
30366
|
-
importAliases = new Map;
|
|
30367
|
-
childrenCaptureCounter = 0;
|
|
30368
|
-
templateIdentifierSpelling = null;
|
|
30369
|
-
resetAdapterState(_ir) {}
|
|
30370
|
-
renderInScope(scope, render) {
|
|
30371
|
-
const outer = this.scope;
|
|
30372
|
-
this.scope = scope;
|
|
30373
|
-
try {
|
|
30374
|
-
return render();
|
|
30375
|
-
} finally {
|
|
30376
|
-
this.scope = outer;
|
|
30377
|
-
}
|
|
30378
|
-
}
|
|
30379
|
-
generate(ir, options) {
|
|
30380
|
-
this.resetCompileState(ir);
|
|
30381
|
-
this.collectCompileErrors(ir, options);
|
|
30382
|
-
const templateBody = ir.root.type === "if-statement" ? this.renderIfStatement(ir.root) : this.renderNode(ir.root);
|
|
30383
|
-
const scriptReg = options?.skipScriptRegistration ? "" : this.generateScriptRegistrations(ir, options?.scriptBaseName, options?.scriptAssets, options?.preloadAssets);
|
|
30384
|
-
const ctxSeed = this.contextConsumerSeed(ir);
|
|
30385
|
-
const memoSeed = this.derivedMemoSeed(ir);
|
|
30386
|
-
const template = `${scriptReg}${ctxSeed}${memoSeed}${templateBody}
|
|
30387
|
-
`;
|
|
30388
|
-
if (this.errors.length > 0) {
|
|
30389
|
-
ir.errors.push(...this.errors);
|
|
30948
|
+
// src/static-literal.ts
|
|
30949
|
+
function evaluateStaticLiteral(expr, bindings) {
|
|
30950
|
+
switch (expr.kind) {
|
|
30951
|
+
case "literal":
|
|
30952
|
+
return { value: expr.value };
|
|
30953
|
+
case "template-literal": {
|
|
30954
|
+
let out = "";
|
|
30955
|
+
for (const part of expr.parts) {
|
|
30956
|
+
if (part.type === "string") {
|
|
30957
|
+
out += part.value;
|
|
30958
|
+
continue;
|
|
30959
|
+
}
|
|
30960
|
+
const resolved = evaluateStaticLiteral(part.expr, bindings);
|
|
30961
|
+
if (!resolved)
|
|
30962
|
+
return null;
|
|
30963
|
+
out += String(resolved.value);
|
|
30964
|
+
}
|
|
30965
|
+
return { value: out };
|
|
30390
30966
|
}
|
|
30391
|
-
|
|
30392
|
-
|
|
30393
|
-
|
|
30394
|
-
|
|
30395
|
-
|
|
30396
|
-
|
|
30397
|
-
|
|
30398
|
-
|
|
30399
|
-
|
|
30400
|
-
this.restPropsName = ir.metadata.restPropsName ?? null;
|
|
30401
|
-
augmentInheritedPropAccesses(ir);
|
|
30402
|
-
this.propsParams = ir.metadata.propsParams.map((p) => ({ name: p.name, optional: p.optional }));
|
|
30403
|
-
this.booleanTypedProps = collectBooleanTypedProps(ir);
|
|
30404
|
-
this.localConstants = ir.metadata.localConstants ?? [];
|
|
30405
|
-
this.rootPropAliases = rootPropAliasNames(ir, this.propsParams.map((p) => p.name));
|
|
30406
|
-
this.scope = BindingScope.EMPTY;
|
|
30407
|
-
this.nullableOptionalProps = collectNullableOptionalProps(ir);
|
|
30408
|
-
this.nullableSignalGetters = collectNullableSignalGetters(ir);
|
|
30409
|
-
this.nullishAttrCtx = collectNullishAttrContext(ir);
|
|
30410
|
-
this.stringValueNames = this.stringValueNamesFor(ir);
|
|
30411
|
-
this.moduleStringConsts = collectModuleStringConsts(ir.metadata.localConstants);
|
|
30412
|
-
this._searchParamsLocals = searchParamsLocalNames(ir.metadata);
|
|
30413
|
-
this._loweringMatchers = prepareLoweringMatchers(ir.metadata);
|
|
30414
|
-
this.computedConsts = computedConstContext(ir.metadata, (name) => this.scope.isBound(name));
|
|
30415
|
-
this.importAliases = buildImportAliasMap(ir.metadata.imports ?? []);
|
|
30416
|
-
this.childrenCaptureCounter = 0;
|
|
30417
|
-
this.errors = [];
|
|
30418
|
-
this.resetAdapterState(ir);
|
|
30419
|
-
}
|
|
30420
|
-
collectCompileErrors(ir, options) {
|
|
30421
|
-
const spelling = this.templateIdentifierSpelling;
|
|
30422
|
-
if (spelling) {
|
|
30423
|
-
const propNames = this.propsParams.map((p) => p.name);
|
|
30424
|
-
this.errors.push(...templateNameCollisionErrors(ir, propNames, spelling.ident, spelling.label, this.componentName));
|
|
30967
|
+
case "array-literal": {
|
|
30968
|
+
const values = [];
|
|
30969
|
+
for (const element of expr.elements) {
|
|
30970
|
+
const resolved = evaluateStaticLiteral(element, bindings);
|
|
30971
|
+
if (!resolved)
|
|
30972
|
+
return null;
|
|
30973
|
+
values.push(resolved.value);
|
|
30974
|
+
}
|
|
30975
|
+
return { value: values };
|
|
30425
30976
|
}
|
|
30426
|
-
|
|
30427
|
-
|
|
30977
|
+
case "object-literal": {
|
|
30978
|
+
const out = {};
|
|
30979
|
+
for (const prop of expr.properties) {
|
|
30980
|
+
if (prop.kind === "spread") {
|
|
30981
|
+
const resolved2 = evaluateStaticLiteral(prop.expr, bindings);
|
|
30982
|
+
if (!resolved2)
|
|
30983
|
+
return null;
|
|
30984
|
+
if (resolved2.value === null || resolved2.value === undefined)
|
|
30985
|
+
continue;
|
|
30986
|
+
if (typeof resolved2.value !== "object" || Array.isArray(resolved2.value))
|
|
30987
|
+
return null;
|
|
30988
|
+
Object.assign(out, resolved2.value);
|
|
30989
|
+
continue;
|
|
30990
|
+
}
|
|
30991
|
+
const resolved = evaluateStaticLiteral(prop.value, bindings);
|
|
30992
|
+
if (!resolved)
|
|
30993
|
+
return null;
|
|
30994
|
+
out[prop.key] = resolved.value;
|
|
30995
|
+
}
|
|
30996
|
+
return { value: out };
|
|
30428
30997
|
}
|
|
30429
|
-
|
|
30430
|
-
|
|
30431
|
-
|
|
30432
|
-
|
|
30433
|
-
|
|
30434
|
-
|
|
30435
|
-
|
|
30436
|
-
|
|
30437
|
-
|
|
30438
|
-
|
|
30439
|
-
|
|
30440
|
-
const parts = [];
|
|
30441
|
-
if (defaultSpec) {
|
|
30442
|
-
parts.push(defaultSpec.alias || defaultSpec.name);
|
|
30998
|
+
case "unary": {
|
|
30999
|
+
const resolved = evaluateStaticLiteral(expr.argument, bindings);
|
|
31000
|
+
if (!resolved)
|
|
31001
|
+
return null;
|
|
31002
|
+
if (expr.op === "-")
|
|
31003
|
+
return typeof resolved.value === "number" ? { value: -resolved.value } : null;
|
|
31004
|
+
if (expr.op === "+")
|
|
31005
|
+
return typeof resolved.value === "number" ? { value: +resolved.value } : null;
|
|
31006
|
+
if (expr.op === "!")
|
|
31007
|
+
return { value: !resolved.value };
|
|
31008
|
+
return null;
|
|
30443
31009
|
}
|
|
30444
|
-
|
|
30445
|
-
|
|
31010
|
+
case "identifier":
|
|
31011
|
+
return bindings?.has(expr.name) ? { value: bindings.get(expr.name) } : null;
|
|
31012
|
+
case "member": {
|
|
31013
|
+
const base = evaluateStaticLiteral(expr.object, bindings);
|
|
31014
|
+
if (!base || base.value === null || typeof base.value !== "object")
|
|
31015
|
+
return null;
|
|
31016
|
+
return { value: base.value[expr.property] };
|
|
30446
31017
|
}
|
|
30447
|
-
|
|
30448
|
-
const
|
|
30449
|
-
|
|
31018
|
+
case "index-access": {
|
|
31019
|
+
const base = evaluateStaticLiteral(expr.object, bindings);
|
|
31020
|
+
const index = evaluateStaticLiteral(expr.index, bindings);
|
|
31021
|
+
if (!base || !index || !Array.isArray(base.value) || typeof index.value !== "number")
|
|
31022
|
+
return null;
|
|
31023
|
+
return { value: base.value[index.value] };
|
|
30450
31024
|
}
|
|
30451
|
-
|
|
31025
|
+
default:
|
|
31026
|
+
return null;
|
|
30452
31027
|
}
|
|
30453
|
-
|
|
30454
|
-
|
|
30455
|
-
|
|
30456
|
-
|
|
30457
|
-
|
|
30458
|
-
|
|
30459
|
-
|
|
30460
|
-
|
|
30461
|
-
|
|
30462
|
-
|
|
30463
|
-
|
|
30464
|
-
|
|
30465
|
-
|
|
30466
|
-
|
|
30467
|
-
|
|
30468
|
-
|
|
30469
|
-
|
|
30470
|
-
|
|
30471
|
-
|
|
30472
|
-
|
|
30473
|
-
|
|
30474
|
-
|
|
30475
|
-
|
|
30476
|
-
|
|
30477
|
-
|
|
30478
|
-
|
|
30479
|
-
|
|
30480
|
-
|
|
30481
|
-
|
|
30482
|
-
|
|
30483
|
-
|
|
30484
|
-
|
|
30485
|
-
|
|
30486
|
-
|
|
30487
|
-
|
|
30488
|
-
|
|
30489
|
-
|
|
30490
|
-
|
|
30491
|
-
|
|
30492
|
-
|
|
30493
|
-
|
|
30494
|
-
|
|
31028
|
+
}
|
|
31029
|
+
function isFullyStaticLiteral(expr) {
|
|
31030
|
+
return evaluateStaticLiteral(expr) !== null;
|
|
31031
|
+
}
|
|
31032
|
+
function resolveStaticLoopSource(arrayParsed, localConstants, opts) {
|
|
31033
|
+
if (!arrayParsed)
|
|
31034
|
+
return null;
|
|
31035
|
+
let target = arrayParsed;
|
|
31036
|
+
if (arrayParsed.kind === "identifier") {
|
|
31037
|
+
if (opts?.isNameShadowed?.(arrayParsed.name))
|
|
31038
|
+
return null;
|
|
31039
|
+
const local = localConstants?.find((c) => c.name === arrayParsed.name);
|
|
31040
|
+
if (!local?.parsed || local.mutatedAfterDeclaration)
|
|
31041
|
+
return null;
|
|
31042
|
+
target = local.parsed;
|
|
31043
|
+
}
|
|
31044
|
+
const resolved = evaluateStaticLiteral(target);
|
|
31045
|
+
if (!resolved || !Array.isArray(resolved.value))
|
|
31046
|
+
return null;
|
|
31047
|
+
return resolved.value;
|
|
31048
|
+
}
|
|
31049
|
+
|
|
31050
|
+
// src/adapters/callback-method.ts
|
|
31051
|
+
var PREDICATE_EVAL = {
|
|
31052
|
+
filter: { helper: "filter_eval" },
|
|
31053
|
+
every: { helper: "every_eval" },
|
|
31054
|
+
some: { helper: "some_eval" },
|
|
31055
|
+
find: { helper: "find_eval", forward: true },
|
|
31056
|
+
findLast: { helper: "find_eval", forward: false },
|
|
31057
|
+
findIndex: { helper: "find_index_eval", forward: true },
|
|
31058
|
+
findLastIndex: { helper: "find_index_eval", forward: false }
|
|
31059
|
+
};
|
|
31060
|
+
function isPredicateMethod(method) {
|
|
31061
|
+
return Object.hasOwn(PREDICATE_EVAL, method);
|
|
31062
|
+
}
|
|
31063
|
+
function lowerCallbackMethod(method, arrow, restArgs, options) {
|
|
31064
|
+
const { adapterName } = options;
|
|
31065
|
+
const { body, params } = arrow;
|
|
31066
|
+
if (isPredicateMethod(method))
|
|
31067
|
+
return lowerPredicate(method, arrow, options);
|
|
31068
|
+
if (method === "sort" || method === "toSorted")
|
|
31069
|
+
return lowerSortComparator(method, arrow, adapterName);
|
|
31070
|
+
if (method === "reduce" || method === "reduceRight") {
|
|
31071
|
+
const init = restArgs[0];
|
|
31072
|
+
const plan = init ? reduceEvalPlan(body, params, init, method === "reduceRight" ? "right" : "left") : null;
|
|
31073
|
+
return plan ?? {
|
|
31074
|
+
kind: "refuse",
|
|
31075
|
+
message: `'.${method}(...)' is outside the ${adapterName} adapter's evaluable surface (needs a literal initial value and an evaluable reducer body)`,
|
|
31076
|
+
suggestion: `Pre-compute the reduced value, or move this position to a '/* @client */' boundary.`
|
|
31077
|
+
};
|
|
31078
|
+
}
|
|
31079
|
+
if (method === "flatMap" || method === "map") {
|
|
31080
|
+
const plan = projectionEvalPlan(method === "map" ? "map_eval" : "flat_map_eval", body, params);
|
|
31081
|
+
return plan ?? {
|
|
31082
|
+
kind: "refuse",
|
|
31083
|
+
message: `'.${method}(...)' projection is outside the ${adapterName} adapter's evaluable surface`,
|
|
31084
|
+
suggestion: `Pre-compute the projected array, or move this position to a '/* @client */' boundary.`
|
|
31085
|
+
};
|
|
31086
|
+
}
|
|
31087
|
+
return { kind: "receiver" };
|
|
31088
|
+
}
|
|
31089
|
+
function lowerPredicate(method, arrow, options) {
|
|
31090
|
+
const param = String(arrow.params[0]);
|
|
31091
|
+
const native = { kind: "native-predicate", method, param, predicate: arrow.body };
|
|
31092
|
+
const nativeOk = options.nativePredicate === true && !hasOpaqueCall(arrow.body) && !readsNestedCallbackIndex(arrow.body);
|
|
31093
|
+
const identity = method === "filter" && arrow.body.kind === "identifier" && arrow.body.name === param;
|
|
31094
|
+
if (nativeOk && identity)
|
|
31095
|
+
return native;
|
|
31096
|
+
const json = serializeParsedExpr(arrow.body);
|
|
31097
|
+
if (json !== null) {
|
|
31098
|
+
const { helper, forward } = PREDICATE_EVAL[method];
|
|
31099
|
+
const operands = [
|
|
31100
|
+
{ kind: "string", value: json },
|
|
31101
|
+
{ kind: "string", value: param }
|
|
31102
|
+
];
|
|
31103
|
+
if (forward !== undefined)
|
|
31104
|
+
operands.push({ kind: "boolean", value: forward });
|
|
31105
|
+
return { kind: "eval", helper, operands, captured: freeVarsInBody(arrow.body, new Set(arrow.params.slice(0, 1))) };
|
|
31106
|
+
}
|
|
31107
|
+
if (nativeOk)
|
|
31108
|
+
return native;
|
|
31109
|
+
return {
|
|
31110
|
+
kind: "refuse",
|
|
31111
|
+
message: `'.${method}(...)' predicate is outside the ${options.adapterName} adapter's evaluable surface`,
|
|
31112
|
+
suggestion: `Rewrite the predicate as a pure expression the evaluator can serialize (no nested method-call callbacks), or move this position to a '/* @client */' boundary.`
|
|
31113
|
+
};
|
|
31114
|
+
}
|
|
31115
|
+
function lowerSortComparator(method, arrow, adapterName) {
|
|
31116
|
+
const plan = sortEvalPlan(arrow.body, arrow.params);
|
|
31117
|
+
if (plan)
|
|
31118
|
+
return plan;
|
|
31119
|
+
const comparator = sortComparatorFromArrow(arrow);
|
|
31120
|
+
if (comparator)
|
|
31121
|
+
return { kind: "structured-sort", comparator };
|
|
31122
|
+
return sortRefusal(method, adapterName);
|
|
31123
|
+
}
|
|
31124
|
+
function sortEvalPlan(body, params) {
|
|
31125
|
+
const json = serializeParsedExpr(body);
|
|
31126
|
+
if (json === null || params.length < 2)
|
|
31127
|
+
return null;
|
|
31128
|
+
return {
|
|
31129
|
+
kind: "eval",
|
|
31130
|
+
helper: "sort_eval",
|
|
31131
|
+
operands: [
|
|
31132
|
+
{ kind: "string", value: json },
|
|
31133
|
+
{ kind: "string", value: params[0] },
|
|
31134
|
+
{ kind: "string", value: params[1] }
|
|
31135
|
+
],
|
|
31136
|
+
captured: freeVarsInBody(body, new Set(params))
|
|
31137
|
+
};
|
|
31138
|
+
}
|
|
31139
|
+
function sortRefusal(method, adapterName) {
|
|
31140
|
+
return {
|
|
31141
|
+
kind: "refuse",
|
|
31142
|
+
message: `'.${method}(...)' comparator is outside the ${adapterName} adapter's evaluable / structured surface`,
|
|
31143
|
+
suggestion: `Pre-compute the sorted array, or move this position to a '/* @client */' boundary.`
|
|
31144
|
+
};
|
|
31145
|
+
}
|
|
31146
|
+
function reduceEvalPlan(body, params, init, direction) {
|
|
31147
|
+
const json = serializeParsedExpr(body);
|
|
31148
|
+
if (json === null || init.kind !== "literal" || params.length < 2)
|
|
31149
|
+
return null;
|
|
31150
|
+
let seed;
|
|
31151
|
+
if (init.literalType === "string")
|
|
31152
|
+
seed = { kind: "string", value: String(init.value) };
|
|
31153
|
+
else if (init.literalType === "number")
|
|
31154
|
+
seed = { kind: "number", text: String(init.value) };
|
|
31155
|
+
else
|
|
31156
|
+
return null;
|
|
31157
|
+
return {
|
|
31158
|
+
kind: "eval",
|
|
31159
|
+
helper: "reduce_eval",
|
|
31160
|
+
operands: [
|
|
31161
|
+
{ kind: "string", value: json },
|
|
31162
|
+
{ kind: "string", value: params[0] },
|
|
31163
|
+
{ kind: "string", value: params[1] },
|
|
31164
|
+
seed,
|
|
31165
|
+
{ kind: "string", value: direction }
|
|
31166
|
+
],
|
|
31167
|
+
captured: freeVarsInBody(body, new Set(params))
|
|
31168
|
+
};
|
|
31169
|
+
}
|
|
31170
|
+
function projectionEvalPlan(helper, body, params) {
|
|
31171
|
+
const json = serializeParsedExpr(body);
|
|
31172
|
+
if (json === null)
|
|
31173
|
+
return null;
|
|
31174
|
+
return {
|
|
31175
|
+
kind: "eval",
|
|
31176
|
+
helper,
|
|
31177
|
+
operands: [
|
|
31178
|
+
{ kind: "string", value: json },
|
|
31179
|
+
{ kind: "string", value: String(params[0]) }
|
|
31180
|
+
],
|
|
31181
|
+
captured: freeVarsInBody(body, new Set(params.slice(0, 1)))
|
|
31182
|
+
};
|
|
31183
|
+
}
|
|
31184
|
+
function emitCallbackEval(plan, recv, emit, spelling) {
|
|
31185
|
+
const operands = [recv];
|
|
31186
|
+
for (const operand of plan.operands) {
|
|
31187
|
+
if (operand.kind === "string")
|
|
31188
|
+
operands.push(spelling.string(operand.value));
|
|
31189
|
+
else if (operand.kind === "number")
|
|
31190
|
+
operands.push(operand.text);
|
|
31191
|
+
else
|
|
31192
|
+
operands.push(spelling.boolean(operand.value));
|
|
31193
|
+
}
|
|
31194
|
+
const env = plan.captured.map((name) => [name, emit({ kind: "identifier", name })]);
|
|
31195
|
+
operands.push(spelling.env(env));
|
|
31196
|
+
return spelling.call(plan.helper, operands);
|
|
31197
|
+
}
|
|
31198
|
+
function isUnloweredCall(callee, args, propsObjectName, isGlobal) {
|
|
31199
|
+
if (args.length === 0) {
|
|
31200
|
+
const root = memberRoot(callee);
|
|
31201
|
+
return root !== null && isGlobal(root);
|
|
31202
|
+
}
|
|
31203
|
+
return !(callee.kind === "member" && callee.object.kind === "identifier" && callee.object.name === propsObjectName);
|
|
31204
|
+
}
|
|
31205
|
+
function memberRoot(callee) {
|
|
31206
|
+
if (callee.kind !== "member" && callee.kind !== "index-access")
|
|
31207
|
+
return null;
|
|
31208
|
+
let object = callee.object;
|
|
31209
|
+
while (object.kind === "member" || object.kind === "index-access")
|
|
31210
|
+
object = object.object;
|
|
31211
|
+
return object.kind === "identifier" ? object.name : null;
|
|
31212
|
+
}
|
|
31213
|
+
function unloweredCallRefusal(callee, args, adapterName) {
|
|
31214
|
+
const name = stringifyParsedExpr(callee);
|
|
31215
|
+
return {
|
|
31216
|
+
message: args.length === 0 ? `Call '${name}()' reads a JavaScript global, which has no ${adapterName} template binding; read as a value it would drop the call` : `Call '${name}(...)' has no ${adapterName} template lowering; read as a value it would drop the call and its arguments`,
|
|
31217
|
+
suggestion: "Pre-compute the value in the backend and pass it as a prop, or add /* @client */ for client-only evaluation (no SSR)."
|
|
31218
|
+
};
|
|
31219
|
+
}
|
|
31220
|
+
function filterPredicateShapeRefusal(shape, adapterName) {
|
|
31221
|
+
return {
|
|
31222
|
+
message: `Filter predicate contains ${shape}, which has no ${adapterName} loop-filter form`,
|
|
31223
|
+
suggestion: `Rewrite the predicate as comparisons joined with && / || / !, or add /* @client */ for client-only evaluation (no SSR).`
|
|
31224
|
+
};
|
|
31225
|
+
}
|
|
31226
|
+
function missingFilterPredicateRefusal(raw, adapterName) {
|
|
31227
|
+
return {
|
|
31228
|
+
message: `Filter predicate '${raw}' has no ${adapterName} loop-filter form`,
|
|
31229
|
+
suggestion: `Rewrite the predicate as an expression-body arrow, or add /* @client */ for client-only evaluation (no SSR).`
|
|
31230
|
+
};
|
|
31231
|
+
}
|
|
31232
|
+
function nestedCallbackRefusal(method, adapterName) {
|
|
31233
|
+
return {
|
|
31234
|
+
message: `Filter predicate contains a nested '.${method}(...)' callback, which has no ${adapterName} scalar form`,
|
|
31235
|
+
suggestion: `Rewrite the predicate without a nested callback method, or add /* @client */ for client-only evaluation (no SSR).`
|
|
31236
|
+
};
|
|
31237
|
+
}
|
|
31238
|
+
|
|
31239
|
+
// src/adapters/filter-capture-collisions.ts
|
|
31240
|
+
function filterCaptureCollisions(loop) {
|
|
31241
|
+
const filter = loop.filterPredicate;
|
|
31242
|
+
if (!filter?.predicate)
|
|
31243
|
+
return [];
|
|
31244
|
+
const free = freeIdentifiers(filter.predicate);
|
|
31245
|
+
if (!free)
|
|
31246
|
+
return [];
|
|
31247
|
+
free.delete(filter.param);
|
|
31248
|
+
const rowBound = new Set(loop.paramBindings && loop.paramBindings.length > 0 ? loop.paramBindings.map((b) => b.name) : [loop.param]);
|
|
31249
|
+
if (loop.index)
|
|
31250
|
+
rowBound.add(loop.index);
|
|
31251
|
+
return [...free].filter((name) => rowBound.has(name)).sort();
|
|
31252
|
+
}
|
|
31253
|
+
|
|
31254
|
+
// src/adapters/loop-plan.ts
|
|
31255
|
+
function spellDestructureLocals(plan, item, spelling) {
|
|
31256
|
+
return plan.destructureLocals.map(({ name, value }) => {
|
|
31257
|
+
const parent = spelling.accessor(item, value.segments);
|
|
31258
|
+
if (value.kind === "slice")
|
|
31259
|
+
return { name, value: spelling.slice(parent, value.from) };
|
|
31260
|
+
if (value.kind === "omit")
|
|
31261
|
+
return { name, value: spelling.omit(parent, value.exclude) };
|
|
31262
|
+
return { name, value: parent };
|
|
31263
|
+
});
|
|
31264
|
+
}
|
|
31265
|
+
function spellSortedSource(sort, recv, spelling) {
|
|
31266
|
+
if (!sort)
|
|
31267
|
+
return recv;
|
|
31268
|
+
if (sort.kind === "eval")
|
|
31269
|
+
return emitCallbackEval(sort, recv, spelling.emit, spelling.eval);
|
|
31270
|
+
if (sort.kind === "structured-sort")
|
|
31271
|
+
return spelling.structured(recv, sort.comparator);
|
|
31272
|
+
spelling.refuse(sort.message, sort.suggestion);
|
|
31273
|
+
return recv;
|
|
31274
|
+
}
|
|
31275
|
+
function loopHeaderTargets(loop, plan) {
|
|
31276
|
+
if (loop.objectIteration === "entries")
|
|
31277
|
+
return [loop.index ?? loop.param, loop.param];
|
|
31278
|
+
return loop.objectIteration || plan.itemVar === loop.param ? [loop.param] : [];
|
|
31279
|
+
}
|
|
31280
|
+
var SAVE_ORDER = ["item", "index", "destructure", "preamble"];
|
|
31281
|
+
function savedLoopBindings(scopes, skip, temporary) {
|
|
31282
|
+
const skipped = new Set(skip);
|
|
31283
|
+
const rank = (name) => SAVE_ORDER.indexOf(scopes.row.lookup(name)?.binding.source ?? "param");
|
|
31284
|
+
return scopes.row.innermostNames().filter((name) => !skipped.has(name) && (scopes.templateLevelNames.has(name) || scopes.outside.isBound(name))).sort((a, b) => rank(a) - rank(b)).map((name, ordinal) => {
|
|
31285
|
+
let held = temporary(name, ordinal);
|
|
31286
|
+
while (scopes.row.isBound(held) || scopes.templateLevelNames.has(held))
|
|
31287
|
+
held += "_";
|
|
31288
|
+
return { name, temporary: held };
|
|
31289
|
+
});
|
|
31290
|
+
}
|
|
31291
|
+
function spellFilteredRow(filter, row, spelling) {
|
|
31292
|
+
if (!filter)
|
|
31293
|
+
return [...row];
|
|
31294
|
+
return [spelling.open(filterCondition(filter, spelling)), ...row, spelling.close];
|
|
31295
|
+
}
|
|
31296
|
+
function filterCondition(filter, spelling) {
|
|
31297
|
+
if (filter.kind === "predicate")
|
|
31298
|
+
return spelling.condition(filter);
|
|
31299
|
+
spelling.refuse(filter.message, filter.suggestion);
|
|
31300
|
+
return spelling.refused;
|
|
31301
|
+
}
|
|
31302
|
+
function filterPlan(loop, captureAliases, adapterName) {
|
|
31303
|
+
const filter = loop.filterPredicate;
|
|
31304
|
+
if (!filter)
|
|
31305
|
+
return null;
|
|
31306
|
+
if (!filter.predicate)
|
|
31307
|
+
return { kind: "refuse", ...missingFilterPredicateRefusal(filter.raw, adapterName) };
|
|
31308
|
+
const captureRenames = new Map(captureAliases.map(({ name, alias }) => [name, alias]));
|
|
31309
|
+
const rowRenames = new Map(captureRenames);
|
|
31310
|
+
if (filter.param !== loop.param)
|
|
31311
|
+
rowRenames.set(filter.param, loop.param);
|
|
31312
|
+
return {
|
|
31313
|
+
kind: "predicate",
|
|
31314
|
+
param: filter.param,
|
|
31315
|
+
predicate: filter.predicate,
|
|
31316
|
+
captured: renameFreeIdentifiers(filter.predicate, captureRenames),
|
|
31317
|
+
onRow: renameFreeIdentifiers(filter.predicate, rowRenames),
|
|
31318
|
+
aliases: new Map(captureAliases.map(({ name, alias }) => [alias, name]))
|
|
31319
|
+
};
|
|
31320
|
+
}
|
|
31321
|
+
function planLoop(loop, ctx) {
|
|
31322
|
+
const staticItems = resolveStaticLoopSource(loop.arrayParsed, ctx.localConstants, {
|
|
31323
|
+
isNameShadowed: ctx.scope.asShadowPredicate()
|
|
31324
|
+
});
|
|
31325
|
+
const staticSource = staticItems !== null ? ctx.spellStatic(staticItems) : null;
|
|
31326
|
+
const destructure = destructureKind(loop);
|
|
31327
|
+
const captureAliases = filterCaptureCollisions(loop).map((name) => ({ name, alias: `__bf_cap_${loop.markerId}_${name}` }));
|
|
31328
|
+
return {
|
|
31329
|
+
destructure,
|
|
31330
|
+
staticSource,
|
|
31331
|
+
unresolvableConst: staticSource === null ? unresolvableConst(loop, ctx) : null,
|
|
31332
|
+
sort: loop.sortComparator ? lowerSortComparator("sort", loop.sortComparator.arrow, ctx.callbackLowering.adapterName) : null,
|
|
31333
|
+
captureAliases,
|
|
31334
|
+
filter: filterPlan(loop, captureAliases, ctx.callbackLowering.adapterName),
|
|
31335
|
+
itemVar: loop.iterationShape === "keys" || destructure === "lowerable" ? "__bf_item" : loop.param,
|
|
31336
|
+
indexLocal: indexLocal(loop),
|
|
31337
|
+
destructureLocals: destructure === "lowerable" ? destructureLocals(loop) : []
|
|
31338
|
+
};
|
|
31339
|
+
}
|
|
31340
|
+
function indexLocal(loop) {
|
|
31341
|
+
if (loop.objectIteration)
|
|
31342
|
+
return null;
|
|
31343
|
+
return loop.iterationShape === "keys" ? loop.param : loop.index;
|
|
31344
|
+
}
|
|
31345
|
+
function destructureLocals(loop) {
|
|
31346
|
+
return (loop.paramBindings ?? []).map((b) => {
|
|
31347
|
+
const segments = b.segments ?? [];
|
|
31348
|
+
if (b.rest?.kind === "array")
|
|
31349
|
+
return { name: b.name, value: { kind: "slice", segments, from: b.rest.from } };
|
|
31350
|
+
if (b.rest?.kind === "object")
|
|
31351
|
+
return { name: b.name, value: { kind: "omit", segments, exclude: b.rest.exclude.map((k) => k.key) } };
|
|
31352
|
+
return { name: b.name, value: { kind: "path", segments } };
|
|
31353
|
+
});
|
|
31354
|
+
}
|
|
31355
|
+
function destructureKind(loop) {
|
|
31356
|
+
if (!loop.paramBindings || loop.paramBindings.length === 0)
|
|
31357
|
+
return "none";
|
|
31358
|
+
return isLowerableLoopDestructure(loop) ? "lowerable" : "unlowerable";
|
|
31359
|
+
}
|
|
31360
|
+
function unresolvableConst(loop, ctx) {
|
|
31361
|
+
const source = loop.arrayParsed ?? parseExpression(loop.array.trim());
|
|
31362
|
+
if (source?.kind !== "identifier")
|
|
31363
|
+
return null;
|
|
31364
|
+
const name = source.name;
|
|
31365
|
+
if (ctx.scope.isBound(name))
|
|
31366
|
+
return null;
|
|
31367
|
+
const constant = ctx.localConstants.find((c) => c.name === name);
|
|
31368
|
+
return constant && ctx.resolveLiteralConst(name) === null ? constant : null;
|
|
31369
|
+
}
|
|
31370
|
+
|
|
31371
|
+
// src/adapters/prop-classes.ts
|
|
31372
|
+
function collectBooleanTypedProps(ir) {
|
|
31373
|
+
return new Set(ir.metadata.propsParams.filter((prop) => prop.type?.primitive === "boolean" || prop.type?.raw === "boolean").map((prop) => prop.name));
|
|
31374
|
+
}
|
|
31375
|
+
function collectNullableOptionalProps(ir) {
|
|
31376
|
+
return new Set([
|
|
31377
|
+
...ir.metadata.propsParams.filter((p) => p.defaultValue === undefined && !p.isRest && (p.type?.kind !== "primitive" || p.optional)).map((p) => p.name),
|
|
31378
|
+
...ir.metadata.restPropsExpandedKeys
|
|
31379
|
+
]);
|
|
31380
|
+
}
|
|
31381
|
+
function isBooleanTypedPropRef(expr, ctx) {
|
|
31382
|
+
let bare = expr.trim();
|
|
31383
|
+
if (ctx.propsObjectName && bare.startsWith(`${ctx.propsObjectName}.`)) {
|
|
31384
|
+
bare = bare.slice(ctx.propsObjectName.length + 1);
|
|
31385
|
+
}
|
|
31386
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(bare))
|
|
31387
|
+
return false;
|
|
31388
|
+
if (ctx.isBound(bare))
|
|
31389
|
+
return false;
|
|
31390
|
+
return ctx.booleanTypedProps.has(bare);
|
|
31391
|
+
}
|
|
31392
|
+
|
|
31393
|
+
// src/adapters/template-name-collisions.ts
|
|
31394
|
+
function templateNameCollisionErrors(ir, propNames, ident, adapterName, componentName) {
|
|
31395
|
+
const { metadata } = ir;
|
|
31396
|
+
const rootNames = new Set([
|
|
31397
|
+
...propNames,
|
|
31398
|
+
...metadata.localConstants.map((c) => c.name),
|
|
31399
|
+
...metadata.localFunctions.map((f) => f.name),
|
|
31400
|
+
...metadata.signals.flatMap((s) => s.setter ? [s.getter, s.setter] : [s.getter]),
|
|
31401
|
+
...metadata.memos.map((m) => m.name)
|
|
31402
|
+
]);
|
|
31403
|
+
const errors = [];
|
|
31404
|
+
const reported = new Set;
|
|
31405
|
+
const check = (scope) => {
|
|
31406
|
+
const byTarget = new Map;
|
|
31407
|
+
for (const name of new Set([...rootNames, ...scope.boundNames()])) {
|
|
31408
|
+
const target = ident(name);
|
|
31409
|
+
const group = byTarget.get(target);
|
|
31410
|
+
if (group)
|
|
31411
|
+
group.push(name);
|
|
31412
|
+
else
|
|
31413
|
+
byTarget.set(target, [name]);
|
|
31414
|
+
}
|
|
31415
|
+
for (const [target, group] of byTarget) {
|
|
31416
|
+
if (group.length < 2)
|
|
31417
|
+
continue;
|
|
31418
|
+
const key = `${target}\x00${[...group].sort().join("\x00")}`;
|
|
31419
|
+
if (reported.has(key))
|
|
31420
|
+
continue;
|
|
31421
|
+
reported.add(key);
|
|
31422
|
+
const list = group.map((n) => `\`${n}\``).join(" and ");
|
|
31423
|
+
errors.push({
|
|
31424
|
+
code: "BF105",
|
|
31425
|
+
severity: "error",
|
|
31426
|
+
message: `${list} both become the ${adapterName} template variable \`${target}\`, so they would read the same value. ${adapterName} reserves some names and renames them, and the new name collides with another name in this component.`,
|
|
31427
|
+
loc: { file: `${componentName}.tsx`, start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
31428
|
+
suggestion: {
|
|
31429
|
+
message: `Rename one of ${list} so the two names stay distinct after the ${adapterName} renaming.`,
|
|
31430
|
+
escape: [{ kind: "rewrite" }]
|
|
31431
|
+
}
|
|
31432
|
+
});
|
|
31433
|
+
}
|
|
31434
|
+
};
|
|
31435
|
+
const visit3 = (node, scope) => {
|
|
31436
|
+
if (!node)
|
|
31437
|
+
return;
|
|
31438
|
+
switch (node.type) {
|
|
31439
|
+
case "element":
|
|
31440
|
+
case "component":
|
|
31441
|
+
case "fragment":
|
|
31442
|
+
case "provider":
|
|
31443
|
+
for (const child of node.children)
|
|
31444
|
+
visit3(child, scope);
|
|
31445
|
+
break;
|
|
31446
|
+
case "async":
|
|
31447
|
+
visit3(node.fallback, scope);
|
|
31448
|
+
for (const child of node.children)
|
|
31449
|
+
visit3(child, scope);
|
|
31450
|
+
break;
|
|
31451
|
+
case "loop": {
|
|
31452
|
+
if (node.filterPredicate)
|
|
31453
|
+
check(scope.enterCallback([node.filterPredicate.param]));
|
|
31454
|
+
const row = scope.enterLoopRow(node);
|
|
31455
|
+
check(row);
|
|
31456
|
+
for (const child of node.children)
|
|
31457
|
+
visit3(child, row);
|
|
31458
|
+
if (node.childComponent) {
|
|
31459
|
+
for (const child of node.childComponent.children)
|
|
31460
|
+
visit3(child, row);
|
|
31461
|
+
}
|
|
31462
|
+
for (const nested of node.nestedComponents ?? []) {
|
|
31463
|
+
for (const child of nested.children)
|
|
31464
|
+
visit3(child, row);
|
|
31465
|
+
}
|
|
31466
|
+
for (const seg of node.flatMapCallback?.segments ?? []) {
|
|
31467
|
+
if (seg.kind === "jsx")
|
|
31468
|
+
visit3(seg.ir, row);
|
|
31469
|
+
}
|
|
31470
|
+
for (const seg of node.preamble?.segments ?? []) {
|
|
31471
|
+
if (seg.kind === "jsx")
|
|
31472
|
+
visit3(seg.ir, row);
|
|
31473
|
+
}
|
|
31474
|
+
break;
|
|
31475
|
+
}
|
|
31476
|
+
case "conditional":
|
|
31477
|
+
visit3(node.whenTrue, scope);
|
|
31478
|
+
visit3(node.whenFalse, scope);
|
|
31479
|
+
break;
|
|
31480
|
+
case "if-statement":
|
|
31481
|
+
visit3(node.consequent, scope);
|
|
31482
|
+
if (node.alternate)
|
|
31483
|
+
visit3(node.alternate, scope);
|
|
31484
|
+
break;
|
|
31485
|
+
case "text":
|
|
31486
|
+
case "expression":
|
|
31487
|
+
case "slot":
|
|
31488
|
+
break;
|
|
31489
|
+
}
|
|
31490
|
+
};
|
|
31491
|
+
check(BindingScope.EMPTY);
|
|
31492
|
+
visit3(ir.root, BindingScope.EMPTY);
|
|
31493
|
+
return errors;
|
|
31494
|
+
}
|
|
31495
|
+
|
|
31496
|
+
// src/adapters/dsl-template-adapter.ts
|
|
31497
|
+
class DslTemplateAdapter extends BaseAdapter {
|
|
31498
|
+
componentName = "";
|
|
31499
|
+
errors = [];
|
|
31500
|
+
propsObjectName = null;
|
|
31501
|
+
restPropsName = null;
|
|
31502
|
+
propsParams = [];
|
|
31503
|
+
booleanTypedProps = new Set;
|
|
31504
|
+
stringValueNames = new Set;
|
|
31505
|
+
moduleStringConsts = new Map;
|
|
31506
|
+
_searchParamsLocals = new Set;
|
|
31507
|
+
_loweringMatchers = [];
|
|
31508
|
+
computedConsts = null;
|
|
31509
|
+
localConstants = [];
|
|
31510
|
+
rootPropAliases = new Map;
|
|
31511
|
+
scope = BindingScope.EMPTY;
|
|
31512
|
+
nullableOptionalProps = new Set;
|
|
31513
|
+
nullableSignalGetters = new Set;
|
|
31514
|
+
nullishAttrCtx = { nullableSignals: new Set, memos: new Map };
|
|
31515
|
+
importAliases = new Map;
|
|
31516
|
+
childrenCaptureCounter = 0;
|
|
31517
|
+
inLoop = false;
|
|
31518
|
+
templateIdentifierSpelling = null;
|
|
31519
|
+
resetAdapterState(_ir) {}
|
|
31520
|
+
renderInScope(scope, render) {
|
|
31521
|
+
const outer = this.scope;
|
|
31522
|
+
this.scope = scope;
|
|
31523
|
+
try {
|
|
31524
|
+
return render();
|
|
31525
|
+
} finally {
|
|
31526
|
+
this.scope = outer;
|
|
31527
|
+
}
|
|
31528
|
+
}
|
|
31529
|
+
arithmeticCoercion(op, operand, other, isShadowed) {
|
|
31530
|
+
return arithmeticCoercionOrRefuse(op, operand, other, this.nullishAttrCtx, isShadowed, this.ambiguousNilSink());
|
|
31531
|
+
}
|
|
31532
|
+
refuseAmbiguousNilArithmeticIn(expr, params) {
|
|
31533
|
+
refuseAmbiguousNilArithmetic(expr, this.nullishAttrCtx, this.scope.enterCallback(params), this.ambiguousNilSink());
|
|
31534
|
+
}
|
|
31535
|
+
ambiguousNilSink() {
|
|
31536
|
+
return { errors: this.errors, componentName: this.componentName };
|
|
31537
|
+
}
|
|
31538
|
+
loopPlanFor(loop, spelling) {
|
|
31539
|
+
return planLoop(loop, { scope: this.scope, localConstants: this.localConstants ?? [], ...spelling });
|
|
31540
|
+
}
|
|
31541
|
+
recordLoopPlanRefusals(loop, plan, spelling) {
|
|
31542
|
+
const loc = loop.loc ?? { file: this.componentName + ".tsx", start: { line: 1, column: 0 }, end: { line: 1, column: 0 } };
|
|
31543
|
+
if (plan.destructure === "unlowerable") {
|
|
31544
|
+
this.errors.push({
|
|
31545
|
+
code: "BF104",
|
|
31546
|
+
severity: "error",
|
|
31547
|
+
message: spelling.destructureMessage(loop.param),
|
|
31548
|
+
loc,
|
|
31549
|
+
suggestion: { message: spelling.destructureSuggestion }
|
|
31550
|
+
});
|
|
31551
|
+
}
|
|
31552
|
+
const constant = plan.unresolvableConst;
|
|
31553
|
+
if (!constant)
|
|
31554
|
+
return;
|
|
31555
|
+
if (typeof spelling.unresolvableConst === "function") {
|
|
31556
|
+
spelling.unresolvableConst(constant);
|
|
31557
|
+
return;
|
|
31558
|
+
}
|
|
31559
|
+
this.errors.push({
|
|
31560
|
+
code: "BF101",
|
|
31561
|
+
severity: "error",
|
|
31562
|
+
message: `Loop array \`${constant.name}\` is a const (module- or function-scope) computed value (\`${constant.value}\`) that the ${spelling.unresolvableConst} adapter cannot bind as a template variable — only numeric/string-literal locals inline at their use site.`,
|
|
31563
|
+
loc,
|
|
31564
|
+
suggestion: {
|
|
31565
|
+
message: "Pre-compute the array server-side and pass it as a prop, or mark the loop position as @client-only so it runs in JS on the client.",
|
|
31566
|
+
escape: [{ kind: "prop-precompute" }, { kind: "client-directive" }]
|
|
31567
|
+
}
|
|
31568
|
+
});
|
|
31569
|
+
}
|
|
31570
|
+
renderLoopRow(loop, spelling) {
|
|
31571
|
+
const outside = this.scope;
|
|
31572
|
+
const row = outside.enterLoopRow(loop);
|
|
31573
|
+
return this.renderInScope(row, () => {
|
|
31574
|
+
spelling.enter?.(row, outside);
|
|
31575
|
+
const preamble = (loop.preamble?.declarations ?? []).map((d) => spelling.preamble(d));
|
|
31576
|
+
const children = this.renderInLoop(() => this.renderChildren(loop.children));
|
|
31577
|
+
const body = loop.bodyIsItemConditional && loop.key ? `${spelling.keyAnchor(loop.key)}
|
|
31578
|
+
${children}` : children;
|
|
31579
|
+
return { outside, row, rootAliases: rootPropAliasesForLoop(outside, row, this.rootPropAliases), preamble, body };
|
|
31580
|
+
});
|
|
31581
|
+
}
|
|
31582
|
+
renderInLoop(render) {
|
|
31583
|
+
const outer = this.inLoop;
|
|
31584
|
+
this.inLoop = true;
|
|
31585
|
+
try {
|
|
31586
|
+
return render();
|
|
31587
|
+
} finally {
|
|
31588
|
+
this.inLoop = outer;
|
|
31589
|
+
}
|
|
31590
|
+
}
|
|
31591
|
+
generate(ir, options) {
|
|
31592
|
+
this.resetCompileState(ir);
|
|
31593
|
+
this.collectCompileErrors(ir, options);
|
|
31594
|
+
const templateBody = ir.root.type === "if-statement" ? this.renderIfStatement(ir.root) : this.renderNode(ir.root);
|
|
31595
|
+
const scriptReg = options?.skipScriptRegistration ? "" : this.generateScriptRegistrations(ir, options?.scriptBaseName, options?.scriptAssets, options?.preloadAssets);
|
|
31596
|
+
const ctxSeed = this.contextConsumerSeed(ir);
|
|
31597
|
+
const memoSeed = this.derivedMemoSeed(ir);
|
|
31598
|
+
const template = `${scriptReg}${ctxSeed}${memoSeed}${templateBody}
|
|
31599
|
+
`;
|
|
31600
|
+
if (this.errors.length > 0) {
|
|
31601
|
+
ir.errors.push(...this.errors);
|
|
31602
|
+
}
|
|
31603
|
+
return {
|
|
31604
|
+
template,
|
|
31605
|
+
sections: { imports: "", types: "", component: template, defaultExport: "" },
|
|
31606
|
+
extension: this.extension
|
|
31607
|
+
};
|
|
31608
|
+
}
|
|
31609
|
+
resetCompileState(ir) {
|
|
31610
|
+
this.componentName = ir.metadata.componentName;
|
|
31611
|
+
this.propsObjectName = ir.metadata.propsObjectName ?? null;
|
|
31612
|
+
this.restPropsName = ir.metadata.restPropsName ?? null;
|
|
31613
|
+
augmentInheritedPropAccesses(ir);
|
|
31614
|
+
this.propsParams = ir.metadata.propsParams.map((p) => ({ name: p.name, optional: p.optional }));
|
|
31615
|
+
this.booleanTypedProps = collectBooleanTypedProps(ir);
|
|
31616
|
+
this.localConstants = ir.metadata.localConstants ?? [];
|
|
31617
|
+
this.rootPropAliases = rootPropAliasNames(ir, this.propsParams.map((p) => p.name));
|
|
31618
|
+
this.scope = BindingScope.EMPTY;
|
|
31619
|
+
this.nullableOptionalProps = collectNullableOptionalProps(ir);
|
|
31620
|
+
this.nullableSignalGetters = collectNullableSignalGetters(ir);
|
|
31621
|
+
this.nullishAttrCtx = collectNullishAttrContext(ir);
|
|
31622
|
+
this.stringValueNames = this.stringValueNamesFor(ir);
|
|
31623
|
+
this.moduleStringConsts = collectModuleStringConsts(ir.metadata.localConstants);
|
|
31624
|
+
this._searchParamsLocals = searchParamsLocalNames(ir.metadata);
|
|
31625
|
+
this._loweringMatchers = prepareLoweringMatchers(ir.metadata);
|
|
31626
|
+
this.computedConsts = computedConstContext(ir.metadata, (name) => this.scope.isBound(name));
|
|
31627
|
+
this.importAliases = buildImportAliasMap(ir.metadata.imports ?? []);
|
|
31628
|
+
this.childrenCaptureCounter = 0;
|
|
31629
|
+
this.inLoop = false;
|
|
31630
|
+
this.errors = [];
|
|
31631
|
+
this.resetAdapterState(ir);
|
|
31632
|
+
}
|
|
31633
|
+
collectCompileErrors(ir, options) {
|
|
31634
|
+
const spelling = this.templateIdentifierSpelling;
|
|
31635
|
+
if (spelling) {
|
|
31636
|
+
const propNames = this.propsParams.map((p) => p.name);
|
|
31637
|
+
this.errors.push(...templateNameCollisionErrors(ir, propNames, spelling.ident, spelling.label, this.componentName));
|
|
31638
|
+
}
|
|
31639
|
+
if (!options?.siblingTemplatesRegistered) {
|
|
31640
|
+
this.errors.push(...collectImportedLoopChildComponentErrors(ir, this.componentName, this.loopChildDiagnosticName));
|
|
31641
|
+
}
|
|
31642
|
+
refuseAmbiguousNilMemoArithmetic(ir.metadata.memos ?? [], this.nullishAttrCtx, this.ambiguousNilSink());
|
|
31643
|
+
}
|
|
31644
|
+
}
|
|
31645
|
+
// src/adapters/jsx-adapter.ts
|
|
31646
|
+
import { BF_SCOPE as BF_SCOPE4, BF_SLOT, BF_COND } from "@barefootjs/shared";
|
|
31647
|
+
class JsxAdapter extends BaseAdapter {
|
|
31648
|
+
componentName = "";
|
|
31649
|
+
acceptsCallbackBody = () => true;
|
|
31650
|
+
formatImportSpecifiers(specifiers) {
|
|
31651
|
+
const defaultSpec = specifiers.find((s) => s.isDefault);
|
|
31652
|
+
const namespaceSpec = specifiers.find((s) => s.isNamespace);
|
|
31653
|
+
const namedSpecs = specifiers.filter((s) => !s.isDefault && !s.isNamespace);
|
|
31654
|
+
const parts = [];
|
|
31655
|
+
if (defaultSpec) {
|
|
31656
|
+
parts.push(defaultSpec.alias || defaultSpec.name);
|
|
31657
|
+
}
|
|
31658
|
+
if (namespaceSpec) {
|
|
31659
|
+
parts.push(`* as ${namespaceSpec.name}`);
|
|
31660
|
+
}
|
|
31661
|
+
if (namedSpecs.length > 0) {
|
|
31662
|
+
const named = namedSpecs.map((s) => s.alias ? `${s.name} as ${s.alias}` : s.name).join(", ");
|
|
31663
|
+
parts.push(`{ ${named} }`);
|
|
31664
|
+
}
|
|
31665
|
+
return parts.join(", ");
|
|
31666
|
+
}
|
|
31667
|
+
generateSignalInitializers(ir, jsxBody) {
|
|
31668
|
+
const lines = [];
|
|
31669
|
+
const { preserveTypes } = this.jsxConfig;
|
|
31670
|
+
const primaryRefs = [jsxBody];
|
|
31671
|
+
for (const signal of ir.metadata.signals) {
|
|
31672
|
+
if (signal.isModule)
|
|
31673
|
+
continue;
|
|
31674
|
+
primaryRefs.push(signal.initialValue);
|
|
31675
|
+
}
|
|
31676
|
+
for (const memo of ir.metadata.memos) {
|
|
31677
|
+
if (memo.isModule)
|
|
31678
|
+
continue;
|
|
31679
|
+
primaryRefs.push(memo.computation);
|
|
31680
|
+
}
|
|
31681
|
+
const primaryRefText = primaryRefs.join(`
|
|
31682
|
+
`);
|
|
31683
|
+
const localFunctions = ir.metadata.localFunctions.filter((f) => !f.isExported);
|
|
31684
|
+
const localConstants = ir.metadata.localConstants.filter((c) => !c.isExported && c.value);
|
|
31685
|
+
const declarations = [
|
|
31686
|
+
...localFunctions.map((f) => ({ name: f.name, body: f.body })),
|
|
31687
|
+
...localConstants.map((c) => ({ name: c.name, body: c.value }))
|
|
31688
|
+
];
|
|
31689
|
+
const reachable = closeOverWritersOfMutableBindings(primaryRefText, declarations, new Set(ir.metadata.localConstants.filter((c) => (c.declarationKind ?? "const") !== "const").map((c) => c.name)));
|
|
31690
|
+
const reachableBodies = [...reachable].map((name) => {
|
|
31691
|
+
const func = localFunctions.find((f) => f.name === name);
|
|
31692
|
+
if (func)
|
|
31693
|
+
return func.body;
|
|
31694
|
+
const constant = localConstants.find((c) => c.name === name);
|
|
31695
|
+
return constant?.value ?? "";
|
|
31696
|
+
}).join(`
|
|
31697
|
+
`);
|
|
31698
|
+
const setterRefText = primaryRefText + `
|
|
31699
|
+
` + reachableBodies;
|
|
31700
|
+
for (const signal of ir.metadata.signals) {
|
|
31701
|
+
if (signal.isModule)
|
|
31702
|
+
continue;
|
|
31703
|
+
if (signal.envReader) {
|
|
31704
|
+
const factory = signal.envFactory ?? ENV_SIGNAL_CLIENT_FACTORY[signal.envReader];
|
|
31705
|
+
if (factory) {
|
|
31706
|
+
lines.push(signal.setter ? ` const [${signal.getter}, ${signal.setter}] = ${factory}()` : ` const [${signal.getter}] = ${factory}()`);
|
|
31707
|
+
}
|
|
31708
|
+
continue;
|
|
30495
31709
|
}
|
|
30496
31710
|
if (!isElidedFactoryGetter(signal)) {
|
|
30497
31711
|
const rawInitialValue = preserveTypes ? signal.typedInitialValue ?? signal.initialValue : signal.initialValue;
|
|
@@ -30537,9 +31751,9 @@ class JsxAdapter extends BaseAdapter {
|
|
|
30537
31751
|
continue;
|
|
30538
31752
|
if (!reachable.has(constant.name))
|
|
30539
31753
|
continue;
|
|
30540
|
-
const
|
|
31754
|
+
const constValue2 = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
|
|
30541
31755
|
const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
|
|
30542
|
-
lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${
|
|
31756
|
+
lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue2}`);
|
|
30543
31757
|
}
|
|
30544
31758
|
for (const func of localFunctions) {
|
|
30545
31759
|
if (moduleScopeNames.has(func.name))
|
|
@@ -31188,6 +32402,106 @@ function emitParsedExpr(expr, emitter) {
|
|
|
31188
32402
|
}
|
|
31189
32403
|
}
|
|
31190
32404
|
}
|
|
32405
|
+
// src/adapters/number-value.ts
|
|
32406
|
+
function collectNumberValueNames(ir) {
|
|
32407
|
+
const isNumber = (type) => type?.kind === "primitive" && type.primitive === "number";
|
|
32408
|
+
const names = new Set;
|
|
32409
|
+
const props = new Set;
|
|
32410
|
+
for (const s of ir.metadata.signals) {
|
|
32411
|
+
if (isNumber(s.type))
|
|
32412
|
+
names.add(s.getter);
|
|
32413
|
+
}
|
|
32414
|
+
for (const m of ir.metadata.memos ?? []) {
|
|
32415
|
+
if (isNumber(m.type))
|
|
32416
|
+
names.add(m.name);
|
|
32417
|
+
}
|
|
32418
|
+
for (const p of ir.metadata.propsParams) {
|
|
32419
|
+
if (!isNumber(p.type))
|
|
32420
|
+
continue;
|
|
32421
|
+
props.add(p.sourceName ?? p.name);
|
|
32422
|
+
if (!ir.metadata.propsObjectName)
|
|
32423
|
+
names.add(p.name);
|
|
32424
|
+
}
|
|
32425
|
+
for (const c of ir.metadata.localConstants) {
|
|
32426
|
+
if (isNumber(c.type))
|
|
32427
|
+
names.add(c.name);
|
|
32428
|
+
}
|
|
32429
|
+
return { names, props };
|
|
32430
|
+
}
|
|
32431
|
+
function isNumberValuedExpr(expr, isStringName, isNumberName) {
|
|
32432
|
+
if (!expr)
|
|
32433
|
+
return false;
|
|
32434
|
+
if (isNumericArithmeticResult(expr, isStringName))
|
|
32435
|
+
return true;
|
|
32436
|
+
if (expr.kind === "conditional") {
|
|
32437
|
+
return isNumberValuedExpr(expr.consequent, isStringName, isNumberName) || isNumberValuedExpr(expr.alternate, isStringName, isNumberName);
|
|
32438
|
+
}
|
|
32439
|
+
if (expr.kind === "call")
|
|
32440
|
+
return expr.callee.kind === "identifier" && expr.args.length === 0 && isNumberName(expr.callee.name);
|
|
32441
|
+
if (expr.kind === "member") {
|
|
32442
|
+
return !expr.computed && expr.object.kind === "identifier" && expr.object.name === "props" && isNumberName(expr.property, true);
|
|
32443
|
+
}
|
|
32444
|
+
return expr.kind === "identifier" && isNumberName(expr.name);
|
|
32445
|
+
}
|
|
32446
|
+
function numberValuedSeedNames(plan, isStringName, isNumberName) {
|
|
32447
|
+
const names = new Set;
|
|
32448
|
+
const isNumber = (n, componentProperty) => isNumberName(n, componentProperty) || !componentProperty && names.has(n);
|
|
32449
|
+
for (const step of plan.steps) {
|
|
32450
|
+
if (step.kind !== "derived" || step.origin === "prop")
|
|
32451
|
+
continue;
|
|
32452
|
+
if (isNumberValuedExpr(step.parsed, isStringName, isNumber))
|
|
32453
|
+
names.add(step.name);
|
|
32454
|
+
}
|
|
32455
|
+
return names;
|
|
32456
|
+
}
|
|
32457
|
+
// src/adapters/boolean-carrier.ts
|
|
32458
|
+
function admitsBoolean(type) {
|
|
32459
|
+
if (!type)
|
|
32460
|
+
return false;
|
|
32461
|
+
if (type.kind === "primitive")
|
|
32462
|
+
return type.primitive === "boolean";
|
|
32463
|
+
return type.kind === "union" && (type.unionTypes ?? []).some(admitsBoolean);
|
|
32464
|
+
}
|
|
32465
|
+
function collectBooleanCarrierNames(metadata) {
|
|
32466
|
+
const names = new Set;
|
|
32467
|
+
const props = new Set;
|
|
32468
|
+
for (const signal of metadata.signals) {
|
|
32469
|
+
const untyped = !signal.type || signal.type.kind === "unknown";
|
|
32470
|
+
const booleanSeed = signal.parsed?.kind === "literal" && signal.parsed.literalType === "boolean";
|
|
32471
|
+
if (admitsBoolean(signal.type) || untyped && booleanSeed)
|
|
32472
|
+
names.add(signal.getter);
|
|
32473
|
+
}
|
|
32474
|
+
for (const memo of metadata.memos ?? []) {
|
|
32475
|
+
if (admitsBoolean(memo.type))
|
|
32476
|
+
names.add(memo.name);
|
|
32477
|
+
}
|
|
32478
|
+
for (const param of metadata.propsParams) {
|
|
32479
|
+
if (!admitsBoolean(param.declaredType ?? param.type))
|
|
32480
|
+
continue;
|
|
32481
|
+
props.add(param.sourceName ?? param.name);
|
|
32482
|
+
if (!metadata.propsObjectName)
|
|
32483
|
+
names.add(param.name);
|
|
32484
|
+
}
|
|
32485
|
+
return { names, props };
|
|
32486
|
+
}
|
|
32487
|
+
function mayYieldBooleanCarrier(expr, isCarrierName) {
|
|
32488
|
+
if (!expr)
|
|
32489
|
+
return false;
|
|
32490
|
+
switch (expr.kind) {
|
|
32491
|
+
case "logical":
|
|
32492
|
+
return mayYieldBooleanCarrier(expr.left, isCarrierName) || mayYieldBooleanCarrier(expr.right, isCarrierName);
|
|
32493
|
+
case "conditional":
|
|
32494
|
+
return mayYieldBooleanCarrier(expr.consequent, isCarrierName) || mayYieldBooleanCarrier(expr.alternate, isCarrierName);
|
|
32495
|
+
case "call":
|
|
32496
|
+
return expr.callee.kind === "identifier" && expr.args.length === 0 && isCarrierName(expr.callee.name);
|
|
32497
|
+
case "member":
|
|
32498
|
+
return !expr.computed && expr.object.kind === "identifier" && expr.object.name === "props" && isCarrierName(expr.property, true);
|
|
32499
|
+
case "identifier":
|
|
32500
|
+
return isCarrierName(expr.name);
|
|
32501
|
+
default:
|
|
32502
|
+
return false;
|
|
32503
|
+
}
|
|
32504
|
+
}
|
|
31191
32505
|
// src/adapters/style-object.ts
|
|
31192
32506
|
function staticString(value) {
|
|
31193
32507
|
if (value.kind === "literal" && value.literalType === "string" && typeof value.value === "string")
|
|
@@ -31217,20 +32531,6 @@ function planStyleObject(value) {
|
|
|
31217
32531
|
}
|
|
31218
32532
|
return entries;
|
|
31219
32533
|
}
|
|
31220
|
-
// src/adapters/filter-capture-collisions.ts
|
|
31221
|
-
function filterCaptureCollisions(loop) {
|
|
31222
|
-
const filter = loop.filterPredicate;
|
|
31223
|
-
if (!filter?.predicate)
|
|
31224
|
-
return [];
|
|
31225
|
-
const free = freeIdentifiers(filter.predicate);
|
|
31226
|
-
if (!free)
|
|
31227
|
-
return [];
|
|
31228
|
-
free.delete(filter.param);
|
|
31229
|
-
const rowBound = new Set(loop.paramBindings && loop.paramBindings.length > 0 ? loop.paramBindings.map((b) => b.name) : [loop.param]);
|
|
31230
|
-
if (loop.index)
|
|
31231
|
-
rowBound.add(loop.index);
|
|
31232
|
-
return [...free].filter((name) => rowBound.has(name)).sort();
|
|
31233
|
-
}
|
|
31234
32534
|
// src/adapters/boolean-result.ts
|
|
31235
32535
|
var COMPARISON_OPS = new Set([
|
|
31236
32536
|
"<",
|
|
@@ -31324,324 +32624,138 @@ function collectBooleanValueNames(metadata) {
|
|
|
31324
32624
|
if (e.kind === "logical" && (e.op === "??" || e.op === "||")) {
|
|
31325
32625
|
const left = e.left;
|
|
31326
32626
|
return left.kind === "member" && !left.computed && !!propsObject && left.object.kind === "identifier" && left.object.name === propsObject && booleanTyped.has(left.property) && e.right.kind === "literal" && e.right.literalType === "boolean";
|
|
31327
|
-
}
|
|
31328
|
-
return false;
|
|
31329
|
-
};
|
|
31330
|
-
for (const constant of metadata.localConstants ?? []) {
|
|
31331
|
-
if (readsBooleanProp(constant.parsed) || isBooleanSeed(constant.type ?? undefined, constant.value))
|
|
31332
|
-
names.add(constant.name);
|
|
31333
|
-
else
|
|
31334
|
-
names.delete(constant.name);
|
|
31335
|
-
}
|
|
31336
|
-
return { names, props };
|
|
31337
|
-
}
|
|
31338
|
-
function isBooleanResultExpr(expr) {
|
|
31339
|
-
const parsed = parseExpression(expr.trim());
|
|
31340
|
-
if (!parsed)
|
|
31341
|
-
return false;
|
|
31342
|
-
return isBooleanResultParsed(parsed);
|
|
31343
|
-
}
|
|
31344
|
-
function isExplicitStringCall(expr) {
|
|
31345
|
-
const parsed = parseExpression(expr.trim());
|
|
31346
|
-
return !!parsed && parsed.kind === "call" && parsed.callee.kind === "identifier" && parsed.callee.name === "String" && parsed.args.length === 1;
|
|
31347
|
-
}
|
|
31348
|
-
var ARIA_BOOLEAN_ATTRS = new Set([
|
|
31349
|
-
"aria-atomic",
|
|
31350
|
-
"aria-busy",
|
|
31351
|
-
"aria-disabled",
|
|
31352
|
-
"aria-hidden",
|
|
31353
|
-
"aria-modal",
|
|
31354
|
-
"aria-multiline",
|
|
31355
|
-
"aria-multiselectable",
|
|
31356
|
-
"aria-readonly",
|
|
31357
|
-
"aria-required",
|
|
31358
|
-
"aria-selected",
|
|
31359
|
-
"aria-expanded",
|
|
31360
|
-
"aria-checked",
|
|
31361
|
-
"aria-pressed"
|
|
31362
|
-
]);
|
|
31363
|
-
function isAriaBooleanAttr(name) {
|
|
31364
|
-
return ARIA_BOOLEAN_ATTRS.has(name);
|
|
31365
|
-
}
|
|
31366
|
-
// src/adapters/literal-value.ts
|
|
31367
|
-
function isStringTypeInfo(type) {
|
|
31368
|
-
return type?.kind === "primitive" && type.primitive === "string";
|
|
31369
|
-
}
|
|
31370
|
-
function isBareStringLiteral(initialValue) {
|
|
31371
|
-
if (!initialValue)
|
|
31372
|
-
return false;
|
|
31373
|
-
const v = initialValue.trim();
|
|
31374
|
-
return v.startsWith("'") && v.endsWith("'") || v.startsWith('"') && v.endsWith('"');
|
|
31375
|
-
}
|
|
31376
|
-
function isLiteralIndex(index) {
|
|
31377
|
-
return index.kind === "literal" && (index.literalType === "number" || index.literalType === "string");
|
|
31378
|
-
}
|
|
31379
|
-
// src/adapters/array-method.ts
|
|
31380
|
-
var required = { kind: "required" };
|
|
31381
|
-
var optional = { kind: "optional" };
|
|
31382
|
-
var zero = { kind: "default", value: { kind: "number", value: 0 } };
|
|
31383
|
-
var ARRAY_METHOD_CATALOGUE = {
|
|
31384
|
-
join: { helper: "join", params: [{ kind: "default", value: { kind: "string", value: "," } }] },
|
|
31385
|
-
includes: { helper: "includes", params: [required] },
|
|
31386
|
-
indexOf: { helper: "index_of", params: [required] },
|
|
31387
|
-
lastIndexOf: { helper: "last_index_of", params: [required] },
|
|
31388
|
-
at: { helper: "at", params: [zero] },
|
|
31389
|
-
concat: { helper: "concat", params: [required], receiverWhenNoArgs: true },
|
|
31390
|
-
slice: { helper: "slice", params: [zero, { kind: "default", value: { kind: "undefined" } }] },
|
|
31391
|
-
reverse: { helper: "reverse", params: [] },
|
|
31392
|
-
toReversed: { helper: "reverse", params: [] },
|
|
31393
|
-
toLowerCase: { helper: "lc", params: [] },
|
|
31394
|
-
toUpperCase: { helper: "uc", params: [] },
|
|
31395
|
-
trim: { helper: "trim", params: [] },
|
|
31396
|
-
trimStart: { helper: "trim_start", params: [] },
|
|
31397
|
-
trimEnd: { helper: "trim_end", params: [] },
|
|
31398
|
-
toFixed: { helper: "to_fixed", params: [zero] },
|
|
31399
|
-
split: { helper: "split", params: [optional, optional] },
|
|
31400
|
-
startsWith: { helper: "starts_with", params: [required, optional] },
|
|
31401
|
-
endsWith: { helper: "ends_with", params: [required, optional] },
|
|
31402
|
-
replace: { helper: "replace", params: [required, required] },
|
|
31403
|
-
replaceAll: { helper: "replace_all", params: [required, required] },
|
|
31404
|
-
repeat: { helper: "repeat", params: [zero] },
|
|
31405
|
-
padStart: { helper: "pad_start", params: [zero, optional] },
|
|
31406
|
-
padEnd: { helper: "pad_end", params: [zero, optional] }
|
|
31407
|
-
};
|
|
31408
|
-
function lowerArrayMethod(method, object, args) {
|
|
31409
|
-
const entry = ARRAY_METHOD_CATALOGUE[method];
|
|
31410
|
-
if (entry.receiverWhenNoArgs && args.length === 0)
|
|
31411
|
-
return { kind: "receiver", object };
|
|
31412
|
-
const out = [];
|
|
31413
|
-
for (const [i, param] of entry.params.entries()) {
|
|
31414
|
-
const arg = args[i];
|
|
31415
|
-
if (arg) {
|
|
31416
|
-
out.push({ kind: "expr", expr: arg });
|
|
31417
|
-
} else if (param.kind === "default") {
|
|
31418
|
-
out.push({ kind: "default", value: param.value });
|
|
31419
|
-
} else if (param.kind === "optional") {
|
|
31420
|
-
break;
|
|
31421
|
-
} else {
|
|
31422
|
-
throw new Error(`lowerArrayMethod: '.${method}()' needs argument ${i + 1}`);
|
|
31423
|
-
}
|
|
31424
|
-
}
|
|
31425
|
-
return { kind: "call", helper: entry.helper, object, args: out };
|
|
31426
|
-
}
|
|
31427
|
-
function emitArrayMethod(plan, emit, spelling) {
|
|
31428
|
-
if (plan.kind === "receiver")
|
|
31429
|
-
return emit(plan.object);
|
|
31430
|
-
const operands = [emit(plan.object)];
|
|
31431
|
-
for (const arg of plan.args) {
|
|
31432
|
-
operands.push(arg.kind === "expr" ? emit(arg.expr) : defaultLiteral(arg.value, spelling));
|
|
31433
|
-
}
|
|
31434
|
-
return spelling.call(plan.helper, operands);
|
|
31435
|
-
}
|
|
31436
|
-
function defaultLiteral(value, spelling) {
|
|
31437
|
-
switch (value.kind) {
|
|
31438
|
-
case "number":
|
|
31439
|
-
return String(value.value);
|
|
31440
|
-
case "string":
|
|
31441
|
-
return `'${value.value}'`;
|
|
31442
|
-
case "undefined":
|
|
31443
|
-
return spelling.undefinedLiteral;
|
|
31444
|
-
}
|
|
31445
|
-
}
|
|
31446
|
-
function prefixedArrayMethodSpelling(prefix, undefinedLiteral) {
|
|
31447
|
-
return {
|
|
31448
|
-
call: (helper, operands) => `${prefix}${helper}(${operands.join(", ")})`,
|
|
31449
|
-
undefinedLiteral
|
|
31450
|
-
};
|
|
31451
|
-
}
|
|
31452
|
-
// src/adapters/callback-method.ts
|
|
31453
|
-
var PREDICATE_EVAL = {
|
|
31454
|
-
filter: { helper: "filter_eval" },
|
|
31455
|
-
every: { helper: "every_eval" },
|
|
31456
|
-
some: { helper: "some_eval" },
|
|
31457
|
-
find: { helper: "find_eval", forward: true },
|
|
31458
|
-
findLast: { helper: "find_eval", forward: false },
|
|
31459
|
-
findIndex: { helper: "find_index_eval", forward: true },
|
|
31460
|
-
findLastIndex: { helper: "find_index_eval", forward: false }
|
|
31461
|
-
};
|
|
31462
|
-
function isPredicateMethod(method) {
|
|
31463
|
-
return Object.hasOwn(PREDICATE_EVAL, method);
|
|
31464
|
-
}
|
|
31465
|
-
function lowerCallbackMethod(method, arrow, restArgs, options) {
|
|
31466
|
-
const { adapterName } = options;
|
|
31467
|
-
const { body, params } = arrow;
|
|
31468
|
-
if (isPredicateMethod(method))
|
|
31469
|
-
return lowerPredicate(method, arrow, options);
|
|
31470
|
-
if (method === "sort" || method === "toSorted")
|
|
31471
|
-
return lowerSortComparator(method, arrow, adapterName);
|
|
31472
|
-
if (method === "reduce" || method === "reduceRight") {
|
|
31473
|
-
const init = restArgs[0];
|
|
31474
|
-
const plan = init ? reduceEvalPlan(body, params, init, method === "reduceRight" ? "right" : "left") : null;
|
|
31475
|
-
return plan ?? {
|
|
31476
|
-
kind: "refuse",
|
|
31477
|
-
message: `'.${method}(...)' is outside the ${adapterName} adapter's evaluable surface (needs a literal initial value and an evaluable reducer body)`,
|
|
31478
|
-
suggestion: `Pre-compute the reduced value, or move this position to a '/* @client */' boundary.`
|
|
31479
|
-
};
|
|
31480
|
-
}
|
|
31481
|
-
if (method === "flatMap" || method === "map") {
|
|
31482
|
-
const plan = projectionEvalPlan(method === "map" ? "map_eval" : "flat_map_eval", body, params);
|
|
31483
|
-
return plan ?? {
|
|
31484
|
-
kind: "refuse",
|
|
31485
|
-
message: `'.${method}(...)' projection is outside the ${adapterName} adapter's evaluable surface`,
|
|
31486
|
-
suggestion: `Pre-compute the projected array, or move this position to a '/* @client */' boundary.`
|
|
31487
|
-
};
|
|
31488
|
-
}
|
|
31489
|
-
return { kind: "receiver" };
|
|
31490
|
-
}
|
|
31491
|
-
function lowerPredicate(method, arrow, options) {
|
|
31492
|
-
const param = String(arrow.params[0]);
|
|
31493
|
-
const native = { kind: "native-predicate", method, param, predicate: arrow.body };
|
|
31494
|
-
const nativeOk = options.nativePredicate === true && !hasOpaqueCall(arrow.body) && !readsNestedCallbackIndex(arrow.body);
|
|
31495
|
-
const identity = method === "filter" && arrow.body.kind === "identifier" && arrow.body.name === param;
|
|
31496
|
-
if (nativeOk && identity)
|
|
31497
|
-
return native;
|
|
31498
|
-
const json = serializeParsedExpr(arrow.body);
|
|
31499
|
-
if (json !== null) {
|
|
31500
|
-
const { helper, forward } = PREDICATE_EVAL[method];
|
|
31501
|
-
const operands = [
|
|
31502
|
-
{ kind: "string", value: json },
|
|
31503
|
-
{ kind: "string", value: param }
|
|
31504
|
-
];
|
|
31505
|
-
if (forward !== undefined)
|
|
31506
|
-
operands.push({ kind: "boolean", value: forward });
|
|
31507
|
-
return { kind: "eval", helper, operands, captured: freeVarsInBody(arrow.body, new Set(arrow.params.slice(0, 1))) };
|
|
31508
|
-
}
|
|
31509
|
-
if (nativeOk)
|
|
31510
|
-
return native;
|
|
31511
|
-
return {
|
|
31512
|
-
kind: "refuse",
|
|
31513
|
-
message: `'.${method}(...)' predicate is outside the ${options.adapterName} adapter's evaluable surface`,
|
|
31514
|
-
suggestion: `Rewrite the predicate as a pure expression the evaluator can serialize (no nested method-call callbacks), or move this position to a '/* @client */' boundary.`
|
|
31515
|
-
};
|
|
31516
|
-
}
|
|
31517
|
-
function lowerSortComparator(method, arrow, adapterName) {
|
|
31518
|
-
const plan = sortEvalPlan(arrow.body, arrow.params);
|
|
31519
|
-
if (plan)
|
|
31520
|
-
return plan;
|
|
31521
|
-
const comparator = sortComparatorFromArrow(arrow);
|
|
31522
|
-
if (comparator)
|
|
31523
|
-
return { kind: "structured-sort", comparator };
|
|
31524
|
-
return sortRefusal(method, adapterName);
|
|
31525
|
-
}
|
|
31526
|
-
function sortEvalPlan(body, params) {
|
|
31527
|
-
const json = serializeParsedExpr(body);
|
|
31528
|
-
if (json === null || params.length < 2)
|
|
31529
|
-
return null;
|
|
31530
|
-
return {
|
|
31531
|
-
kind: "eval",
|
|
31532
|
-
helper: "sort_eval",
|
|
31533
|
-
operands: [
|
|
31534
|
-
{ kind: "string", value: json },
|
|
31535
|
-
{ kind: "string", value: params[0] },
|
|
31536
|
-
{ kind: "string", value: params[1] }
|
|
31537
|
-
],
|
|
31538
|
-
captured: freeVarsInBody(body, new Set(params))
|
|
31539
|
-
};
|
|
31540
|
-
}
|
|
31541
|
-
function sortRefusal(method, adapterName) {
|
|
31542
|
-
return {
|
|
31543
|
-
kind: "refuse",
|
|
31544
|
-
message: `'.${method}(...)' comparator is outside the ${adapterName} adapter's evaluable / structured surface`,
|
|
31545
|
-
suggestion: `Pre-compute the sorted array, or move this position to a '/* @client */' boundary.`
|
|
31546
|
-
};
|
|
31547
|
-
}
|
|
31548
|
-
function reduceEvalPlan(body, params, init, direction) {
|
|
31549
|
-
const json = serializeParsedExpr(body);
|
|
31550
|
-
if (json === null || init.kind !== "literal" || params.length < 2)
|
|
31551
|
-
return null;
|
|
31552
|
-
let seed;
|
|
31553
|
-
if (init.literalType === "string")
|
|
31554
|
-
seed = { kind: "string", value: String(init.value) };
|
|
31555
|
-
else if (init.literalType === "number")
|
|
31556
|
-
seed = { kind: "number", text: String(init.value) };
|
|
31557
|
-
else
|
|
31558
|
-
return null;
|
|
31559
|
-
return {
|
|
31560
|
-
kind: "eval",
|
|
31561
|
-
helper: "reduce_eval",
|
|
31562
|
-
operands: [
|
|
31563
|
-
{ kind: "string", value: json },
|
|
31564
|
-
{ kind: "string", value: params[0] },
|
|
31565
|
-
{ kind: "string", value: params[1] },
|
|
31566
|
-
seed,
|
|
31567
|
-
{ kind: "string", value: direction }
|
|
31568
|
-
],
|
|
31569
|
-
captured: freeVarsInBody(body, new Set(params))
|
|
31570
|
-
};
|
|
31571
|
-
}
|
|
31572
|
-
function projectionEvalPlan(helper, body, params) {
|
|
31573
|
-
const json = serializeParsedExpr(body);
|
|
31574
|
-
if (json === null)
|
|
31575
|
-
return null;
|
|
31576
|
-
return {
|
|
31577
|
-
kind: "eval",
|
|
31578
|
-
helper,
|
|
31579
|
-
operands: [
|
|
31580
|
-
{ kind: "string", value: json },
|
|
31581
|
-
{ kind: "string", value: String(params[0]) }
|
|
31582
|
-
],
|
|
31583
|
-
captured: freeVarsInBody(body, new Set(params.slice(0, 1)))
|
|
32627
|
+
}
|
|
32628
|
+
return false;
|
|
31584
32629
|
};
|
|
31585
|
-
|
|
31586
|
-
|
|
31587
|
-
|
|
31588
|
-
for (const operand of plan.operands) {
|
|
31589
|
-
if (operand.kind === "string")
|
|
31590
|
-
operands.push(spelling.string(operand.value));
|
|
31591
|
-
else if (operand.kind === "number")
|
|
31592
|
-
operands.push(operand.text);
|
|
32630
|
+
for (const constant of metadata.localConstants ?? []) {
|
|
32631
|
+
if (readsBooleanProp(constant.parsed) || isBooleanSeed(constant.type ?? undefined, constant.value))
|
|
32632
|
+
names.add(constant.name);
|
|
31593
32633
|
else
|
|
31594
|
-
|
|
32634
|
+
names.delete(constant.name);
|
|
31595
32635
|
}
|
|
31596
|
-
|
|
31597
|
-
operands.push(spelling.env(env));
|
|
31598
|
-
return spelling.call(plan.helper, operands);
|
|
32636
|
+
return { names, props };
|
|
31599
32637
|
}
|
|
31600
|
-
function
|
|
31601
|
-
|
|
31602
|
-
|
|
31603
|
-
return
|
|
31604
|
-
|
|
31605
|
-
return !(callee.kind === "member" && callee.object.kind === "identifier" && callee.object.name === propsObjectName);
|
|
32638
|
+
function isBooleanResultExpr(expr) {
|
|
32639
|
+
const parsed = parseExpression(expr.trim());
|
|
32640
|
+
if (!parsed)
|
|
32641
|
+
return false;
|
|
32642
|
+
return isBooleanResultParsed(parsed);
|
|
31606
32643
|
}
|
|
31607
|
-
function
|
|
31608
|
-
|
|
31609
|
-
|
|
31610
|
-
let object = callee.object;
|
|
31611
|
-
while (object.kind === "member" || object.kind === "index-access")
|
|
31612
|
-
object = object.object;
|
|
31613
|
-
return object.kind === "identifier" ? object.name : null;
|
|
32644
|
+
function isExplicitStringCall(expr) {
|
|
32645
|
+
const parsed = parseExpression(expr.trim());
|
|
32646
|
+
return !!parsed && parsed.kind === "call" && parsed.callee.kind === "identifier" && parsed.callee.name === "String" && parsed.args.length === 1;
|
|
31614
32647
|
}
|
|
31615
|
-
|
|
31616
|
-
|
|
31617
|
-
|
|
31618
|
-
|
|
31619
|
-
|
|
31620
|
-
|
|
32648
|
+
var ARIA_BOOLEAN_ATTRS = new Set([
|
|
32649
|
+
"aria-atomic",
|
|
32650
|
+
"aria-busy",
|
|
32651
|
+
"aria-disabled",
|
|
32652
|
+
"aria-hidden",
|
|
32653
|
+
"aria-modal",
|
|
32654
|
+
"aria-multiline",
|
|
32655
|
+
"aria-multiselectable",
|
|
32656
|
+
"aria-readonly",
|
|
32657
|
+
"aria-required",
|
|
32658
|
+
"aria-selected",
|
|
32659
|
+
"aria-expanded",
|
|
32660
|
+
"aria-checked",
|
|
32661
|
+
"aria-pressed"
|
|
32662
|
+
]);
|
|
32663
|
+
function isAriaBooleanAttr(name) {
|
|
32664
|
+
return ARIA_BOOLEAN_ATTRS.has(name);
|
|
31621
32665
|
}
|
|
31622
|
-
|
|
31623
|
-
|
|
31624
|
-
|
|
31625
|
-
suggestion: `Rewrite the predicate as comparisons joined with && / || / !, or add /* @client */ for client-only evaluation (no SSR).`
|
|
31626
|
-
};
|
|
32666
|
+
// src/adapters/literal-value.ts
|
|
32667
|
+
function isStringTypeInfo(type) {
|
|
32668
|
+
return type?.kind === "primitive" && type.primitive === "string";
|
|
31627
32669
|
}
|
|
31628
|
-
function
|
|
31629
|
-
|
|
31630
|
-
|
|
31631
|
-
|
|
31632
|
-
|
|
32670
|
+
function isBareStringLiteral(initialValue) {
|
|
32671
|
+
if (!initialValue)
|
|
32672
|
+
return false;
|
|
32673
|
+
const v = initialValue.trim();
|
|
32674
|
+
return v.startsWith("'") && v.endsWith("'") || v.startsWith('"') && v.endsWith('"');
|
|
31633
32675
|
}
|
|
31634
|
-
function
|
|
32676
|
+
function isLiteralIndex(index) {
|
|
32677
|
+
return index.kind === "literal" && (index.literalType === "number" || index.literalType === "string");
|
|
32678
|
+
}
|
|
32679
|
+
// src/adapters/array-method.ts
|
|
32680
|
+
var required = { kind: "required" };
|
|
32681
|
+
var optional = { kind: "optional" };
|
|
32682
|
+
var zero = { kind: "default", value: { kind: "number", value: 0 } };
|
|
32683
|
+
var ARRAY_METHOD_CATALOGUE = {
|
|
32684
|
+
join: { helper: "join", params: [{ kind: "default", value: { kind: "string", value: "," } }] },
|
|
32685
|
+
includes: { helper: "includes", params: [required] },
|
|
32686
|
+
indexOf: { helper: "index_of", params: [required] },
|
|
32687
|
+
lastIndexOf: { helper: "last_index_of", params: [required] },
|
|
32688
|
+
at: { helper: "at", params: [zero] },
|
|
32689
|
+
concat: { helper: "concat", params: [required], receiverWhenNoArgs: true },
|
|
32690
|
+
slice: { helper: "slice", params: [zero, { kind: "default", value: { kind: "undefined" } }] },
|
|
32691
|
+
reverse: { helper: "reverse", params: [] },
|
|
32692
|
+
toReversed: { helper: "reverse", params: [] },
|
|
32693
|
+
toLowerCase: { helper: "lc", params: [] },
|
|
32694
|
+
toUpperCase: { helper: "uc", params: [] },
|
|
32695
|
+
trim: { helper: "trim", params: [] },
|
|
32696
|
+
trimStart: { helper: "trim_start", params: [] },
|
|
32697
|
+
trimEnd: { helper: "trim_end", params: [] },
|
|
32698
|
+
toFixed: { helper: "to_fixed", params: [zero] },
|
|
32699
|
+
split: { helper: "split", params: [optional, optional] },
|
|
32700
|
+
startsWith: { helper: "starts_with", params: [required, optional] },
|
|
32701
|
+
endsWith: { helper: "ends_with", params: [required, optional] },
|
|
32702
|
+
replace: { helper: "replace", params: [required, required] },
|
|
32703
|
+
replaceAll: { helper: "replace_all", params: [required, required] },
|
|
32704
|
+
repeat: { helper: "repeat", params: [zero] },
|
|
32705
|
+
padStart: { helper: "pad_start", params: [zero, optional] },
|
|
32706
|
+
padEnd: { helper: "pad_end", params: [zero, optional] }
|
|
32707
|
+
};
|
|
32708
|
+
function lowerArrayMethod(method, object, args) {
|
|
32709
|
+
const entry = ARRAY_METHOD_CATALOGUE[method];
|
|
32710
|
+
if (entry.receiverWhenNoArgs && args.length === 0)
|
|
32711
|
+
return { kind: "receiver", object };
|
|
32712
|
+
const out = [];
|
|
32713
|
+
for (const [i, param] of entry.params.entries()) {
|
|
32714
|
+
const arg = args[i];
|
|
32715
|
+
if (arg) {
|
|
32716
|
+
out.push({ kind: "expr", expr: arg });
|
|
32717
|
+
} else if (param.kind === "default") {
|
|
32718
|
+
out.push({ kind: "default", value: param.value });
|
|
32719
|
+
} else if (param.kind === "optional") {
|
|
32720
|
+
break;
|
|
32721
|
+
} else {
|
|
32722
|
+
throw new Error(`lowerArrayMethod: '.${method}()' needs argument ${i + 1}`);
|
|
32723
|
+
}
|
|
32724
|
+
}
|
|
32725
|
+
return { kind: "call", helper: entry.helper, object, args: out };
|
|
32726
|
+
}
|
|
32727
|
+
function emitArrayMethod(plan, emit, spelling) {
|
|
32728
|
+
if (plan.kind === "receiver")
|
|
32729
|
+
return emit(plan.object);
|
|
32730
|
+
const operands = [emit(plan.object)];
|
|
32731
|
+
for (const arg of plan.args) {
|
|
32732
|
+
operands.push(arg.kind === "expr" ? emit(arg.expr) : defaultLiteral(arg.value, spelling));
|
|
32733
|
+
}
|
|
32734
|
+
return spelling.call(plan.helper, operands);
|
|
32735
|
+
}
|
|
32736
|
+
function defaultLiteral(value, spelling) {
|
|
32737
|
+
switch (value.kind) {
|
|
32738
|
+
case "number":
|
|
32739
|
+
return String(value.value);
|
|
32740
|
+
case "string":
|
|
32741
|
+
return `'${value.value}'`;
|
|
32742
|
+
case "undefined":
|
|
32743
|
+
return spelling.undefinedLiteral;
|
|
32744
|
+
}
|
|
32745
|
+
}
|
|
32746
|
+
function prefixedArrayMethodSpelling(prefix, undefinedLiteral) {
|
|
31635
32747
|
return {
|
|
31636
|
-
|
|
31637
|
-
|
|
32748
|
+
call: (helper, operands) => `${prefix}${helper}(${operands.join(", ")})`,
|
|
32749
|
+
undefinedLiteral
|
|
31638
32750
|
};
|
|
31639
32751
|
}
|
|
31640
32752
|
// src/adapters/component-props.ts
|
|
31641
32753
|
import { resolveJsxChildrenProp } from "@barefootjs/shared";
|
|
31642
|
-
function propsSpreadParam(param, earlier) {
|
|
32754
|
+
function propsSpreadParam(param, earlier, callerKeys = false) {
|
|
31643
32755
|
if (param.optional === false)
|
|
31644
32756
|
return "entry";
|
|
32757
|
+
if (callerKeys)
|
|
32758
|
+
return "present";
|
|
31645
32759
|
return earlier.spread || earlier.keys.has(param.name) ? "present" : "entry";
|
|
31646
32760
|
}
|
|
31647
32761
|
function componentPropKey(entry) {
|
|
@@ -31670,7 +32784,7 @@ function planComponentProps(comp, options) {
|
|
|
31670
32784
|
const pushPropsSpread = () => {
|
|
31671
32785
|
const before = { keys: new Set(earlier.keys), spread: earlier.spread };
|
|
31672
32786
|
for (const param of options.propsParams) {
|
|
31673
|
-
if (propsSpreadParam(param, before) === "entry") {
|
|
32787
|
+
if (propsSpreadParam(param, before, options.callerKeys) === "entry") {
|
|
31674
32788
|
push({ kind: "props-param", name: param.name });
|
|
31675
32789
|
} else {
|
|
31676
32790
|
earlier.keys.add(param.name);
|
|
@@ -31751,36 +32865,6 @@ function childTemplateName(componentName, importAliases) {
|
|
|
31751
32865
|
}
|
|
31752
32866
|
// src/adapters/attr-plan.ts
|
|
31753
32867
|
var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
31754
|
-
function unsupportedAttrExpression(expr, loweringMatchers) {
|
|
31755
|
-
let probe = expr.trim();
|
|
31756
|
-
while (probe.startsWith("("))
|
|
31757
|
-
probe = probe.slice(1).trimStart();
|
|
31758
|
-
const startsAsObjectLiteral = probe.startsWith("{");
|
|
31759
|
-
const hasTaggedTemplate = /[A-Za-z_$][\w$]*\s*`/.test(probe);
|
|
31760
|
-
if (!startsAsObjectLiteral && !hasTaggedTemplate)
|
|
31761
|
-
return null;
|
|
31762
|
-
const parsed = parseExpression(expr.trim());
|
|
31763
|
-
const support = isSupported(parsed, { loweringMatchers });
|
|
31764
|
-
if (parsed.kind !== "unsupported" && support.supported)
|
|
31765
|
-
return null;
|
|
31766
|
-
return { reason: support.reason ?? (parsed.kind === "unsupported" ? parsed.reason : undefined) };
|
|
31767
|
-
}
|
|
31768
|
-
function unsupportedAttrExpressionError(expr, attrName, loweringMatchers, componentName, adapterLabel, languageLabel) {
|
|
31769
|
-
const refusal = unsupportedAttrExpression(expr, loweringMatchers);
|
|
31770
|
-
if (!refusal)
|
|
31771
|
-
return null;
|
|
31772
|
-
const reasonLine = refusal.reason ? `
|
|
31773
|
-
${refusal.reason}` : "";
|
|
31774
|
-
return {
|
|
31775
|
-
code: "BF101",
|
|
31776
|
-
severity: "error",
|
|
31777
|
-
message: `Expression not supported on attribute '${attrName}': ${expr.trim()}${reasonLine}`,
|
|
31778
|
-
loc: { file: componentName + ".tsx", start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
31779
|
-
suggestion: {
|
|
31780
|
-
message: `The ${adapterLabel} adapter cannot lower JS object literals or tagged-template-literal expressions into ${languageLabel}. Move the expression into a \`'use client'\` component (so hydration computes it), or expand it into discrete attributes whose values are values the adapter can lower.`
|
|
31781
|
-
}
|
|
31782
|
-
};
|
|
31783
|
-
}
|
|
31784
32868
|
function planAttrExpression(value, name, ctx) {
|
|
31785
32869
|
const booleanAttr = isBooleanAttr(name);
|
|
31786
32870
|
if (!booleanAttr && !value.presenceOrUndefined) {
|
|
@@ -31804,9 +32888,11 @@ function nullableBareRead(value, ctx) {
|
|
|
31804
32888
|
const bare = value.expr.trim();
|
|
31805
32889
|
const restKey = ctx.restPropsName !== null && bare.startsWith(`${ctx.restPropsName}.`);
|
|
31806
32890
|
let normalized = bare;
|
|
31807
|
-
if (ctx.propsObjectName && bare.startsWith(`${ctx.propsObjectName}.`))
|
|
32891
|
+
if (ctx.propsObjectName && bare.startsWith(`${ctx.propsObjectName}.`)) {
|
|
32892
|
+
if (ctx.isLoopBound(ctx.propsObjectName))
|
|
32893
|
+
return null;
|
|
31808
32894
|
normalized = bare.slice(ctx.propsObjectName.length + 1);
|
|
31809
|
-
else if (restKey)
|
|
32895
|
+
} else if (restKey)
|
|
31810
32896
|
normalized = bare.slice(ctx.restPropsName.length + 1);
|
|
31811
32897
|
const prop = IDENTIFIER.test(normalized) && ctx.nullableOptionalProps.has(normalized) && !ctx.isLoopBound(normalized);
|
|
31812
32898
|
const signal = nullableSignalAttrGetter(value.parsed, ctx.nullableSignalGetters);
|
|
@@ -31846,348 +32932,6 @@ function localConstInitializer(name, ctx) {
|
|
|
31846
32932
|
const init = ctx.localConstants.find((c) => c.name === name && !c.isModule)?.value?.trim();
|
|
31847
32933
|
return init !== undefined && !IDENTIFIER.test(init) ? init : null;
|
|
31848
32934
|
}
|
|
31849
|
-
// src/loop-destructure.ts
|
|
31850
|
-
function isLowerableLoopDestructure(loop) {
|
|
31851
|
-
const bindings = loop.paramBindings;
|
|
31852
|
-
if (!bindings || bindings.length === 0)
|
|
31853
|
-
return false;
|
|
31854
|
-
if (loop.filterPredicate)
|
|
31855
|
-
return false;
|
|
31856
|
-
for (const name of [...bindings.map((b) => b.name), loop.index]) {
|
|
31857
|
-
if (name && name.startsWith("__bf_"))
|
|
31858
|
-
return false;
|
|
31859
|
-
}
|
|
31860
|
-
for (const b of bindings) {
|
|
31861
|
-
if (b.rest) {
|
|
31862
|
-
if (!b.segments)
|
|
31863
|
-
return false;
|
|
31864
|
-
} else if (!b.segments || b.segments.length === 0) {
|
|
31865
|
-
return false;
|
|
31866
|
-
}
|
|
31867
|
-
}
|
|
31868
|
-
const objectRestNames = bindings.filter((b) => b.rest?.kind === "object").map((b) => b.name);
|
|
31869
|
-
if (objectRestNames.length === 0)
|
|
31870
|
-
return true;
|
|
31871
|
-
return !restNamesMisused(loop, objectRestNames);
|
|
31872
|
-
}
|
|
31873
|
-
var isLowerableObjectRestDestructure = isLowerableLoopDestructure;
|
|
31874
|
-
function restNamesMisused(loop, names) {
|
|
31875
|
-
const nameSet = new Set(names);
|
|
31876
|
-
const valueUse = names.map((n) => new RegExp(`(?<![\\w.$])${escapeRe(n)}(?!\\s*\\??\\.)(?![\\w$])`));
|
|
31877
|
-
let misused = false;
|
|
31878
|
-
const check = (s) => {
|
|
31879
|
-
if (!s || misused)
|
|
31880
|
-
return;
|
|
31881
|
-
for (const re of valueUse) {
|
|
31882
|
-
if (re.test(s)) {
|
|
31883
|
-
misused = true;
|
|
31884
|
-
return;
|
|
31885
|
-
}
|
|
31886
|
-
}
|
|
31887
|
-
};
|
|
31888
|
-
const attr = (v, isIntrinsicElementAttrs) => {
|
|
31889
|
-
if (v.kind === "spread" && isIntrinsicElementAttrs && nameSet.has(v.expr.trim())) {
|
|
31890
|
-
return;
|
|
31891
|
-
}
|
|
31892
|
-
if (v.kind === "expression" || v.kind === "spread") {
|
|
31893
|
-
check(v.expr);
|
|
31894
|
-
check(v.templateExpr);
|
|
31895
|
-
} else if (v.kind === "template") {
|
|
31896
|
-
v.parts.forEach(part);
|
|
31897
|
-
}
|
|
31898
|
-
};
|
|
31899
|
-
const part = (p) => {
|
|
31900
|
-
if (p.type === "ternary") {
|
|
31901
|
-
check(p.condition);
|
|
31902
|
-
check(p.templateCondition);
|
|
31903
|
-
check(p.whenTrue);
|
|
31904
|
-
check(p.whenFalse);
|
|
31905
|
-
} else if (p.type === "lookup") {
|
|
31906
|
-
check(p.key);
|
|
31907
|
-
check(p.templateKey);
|
|
31908
|
-
}
|
|
31909
|
-
};
|
|
31910
|
-
const visitLoop = (l) => {
|
|
31911
|
-
if (misused)
|
|
31912
|
-
return;
|
|
31913
|
-
check(l.array);
|
|
31914
|
-
check(l.templateArray);
|
|
31915
|
-
check(l.key);
|
|
31916
|
-
if (l.preamble) {
|
|
31917
|
-
check(preambleAnalysisText(l.preamble));
|
|
31918
|
-
check(preambleAnalysisTemplateText(l.preamble));
|
|
31919
|
-
}
|
|
31920
|
-
if (l.flatMapCallback) {
|
|
31921
|
-
check(preambleAnalysisText(l.flatMapCallback));
|
|
31922
|
-
for (const seg of l.flatMapCallback.segments) {
|
|
31923
|
-
if (seg.kind === "jsx")
|
|
31924
|
-
visit3(seg.ir);
|
|
31925
|
-
}
|
|
31926
|
-
}
|
|
31927
|
-
l.children.forEach(visit3);
|
|
31928
|
-
};
|
|
31929
|
-
const visit3 = (node) => {
|
|
31930
|
-
if (misused)
|
|
31931
|
-
return;
|
|
31932
|
-
switch (node.type) {
|
|
31933
|
-
case "expression":
|
|
31934
|
-
check(node.expr);
|
|
31935
|
-
check(node.templateExpr);
|
|
31936
|
-
break;
|
|
31937
|
-
case "conditional":
|
|
31938
|
-
check(node.condition);
|
|
31939
|
-
check(node.templateCondition);
|
|
31940
|
-
visit3(node.whenTrue);
|
|
31941
|
-
visit3(node.whenFalse);
|
|
31942
|
-
break;
|
|
31943
|
-
case "if-statement":
|
|
31944
|
-
check(node.condition);
|
|
31945
|
-
check(node.templateCondition);
|
|
31946
|
-
for (const sv of node.scopeVariables) {
|
|
31947
|
-
check(sv.initializer);
|
|
31948
|
-
check(sv.templateInitializer);
|
|
31949
|
-
}
|
|
31950
|
-
visit3(node.consequent);
|
|
31951
|
-
if (node.alternate)
|
|
31952
|
-
visit3(node.alternate);
|
|
31953
|
-
break;
|
|
31954
|
-
case "element":
|
|
31955
|
-
node.attrs.forEach((a) => attr(a.value, true));
|
|
31956
|
-
node.events.forEach((e) => check(e.handler));
|
|
31957
|
-
node.children.forEach(visit3);
|
|
31958
|
-
break;
|
|
31959
|
-
case "component":
|
|
31960
|
-
node.props.forEach((p) => attr(p.value, false));
|
|
31961
|
-
node.children.forEach(visit3);
|
|
31962
|
-
break;
|
|
31963
|
-
case "provider":
|
|
31964
|
-
attr(node.valueProp.value, false);
|
|
31965
|
-
node.children.forEach(visit3);
|
|
31966
|
-
break;
|
|
31967
|
-
case "fragment":
|
|
31968
|
-
node.children.forEach(visit3);
|
|
31969
|
-
break;
|
|
31970
|
-
case "async":
|
|
31971
|
-
visit3(node.fallback);
|
|
31972
|
-
node.children.forEach(visit3);
|
|
31973
|
-
break;
|
|
31974
|
-
case "loop":
|
|
31975
|
-
visitLoop(node);
|
|
31976
|
-
break;
|
|
31977
|
-
case "text":
|
|
31978
|
-
case "slot":
|
|
31979
|
-
break;
|
|
31980
|
-
}
|
|
31981
|
-
};
|
|
31982
|
-
visitLoop(loop);
|
|
31983
|
-
return misused;
|
|
31984
|
-
}
|
|
31985
|
-
function escapeRe(s) {
|
|
31986
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31987
|
-
}
|
|
31988
|
-
|
|
31989
|
-
// src/static-literal.ts
|
|
31990
|
-
function evaluateStaticLiteral(expr, bindings) {
|
|
31991
|
-
switch (expr.kind) {
|
|
31992
|
-
case "literal":
|
|
31993
|
-
return { value: expr.value };
|
|
31994
|
-
case "template-literal": {
|
|
31995
|
-
let out = "";
|
|
31996
|
-
for (const part of expr.parts) {
|
|
31997
|
-
if (part.type === "string") {
|
|
31998
|
-
out += part.value;
|
|
31999
|
-
continue;
|
|
32000
|
-
}
|
|
32001
|
-
const resolved = evaluateStaticLiteral(part.expr, bindings);
|
|
32002
|
-
if (!resolved)
|
|
32003
|
-
return null;
|
|
32004
|
-
out += String(resolved.value);
|
|
32005
|
-
}
|
|
32006
|
-
return { value: out };
|
|
32007
|
-
}
|
|
32008
|
-
case "array-literal": {
|
|
32009
|
-
const values = [];
|
|
32010
|
-
for (const element of expr.elements) {
|
|
32011
|
-
const resolved = evaluateStaticLiteral(element, bindings);
|
|
32012
|
-
if (!resolved)
|
|
32013
|
-
return null;
|
|
32014
|
-
values.push(resolved.value);
|
|
32015
|
-
}
|
|
32016
|
-
return { value: values };
|
|
32017
|
-
}
|
|
32018
|
-
case "object-literal": {
|
|
32019
|
-
const out = {};
|
|
32020
|
-
for (const prop of expr.properties) {
|
|
32021
|
-
if (prop.kind === "spread") {
|
|
32022
|
-
const resolved2 = evaluateStaticLiteral(prop.expr, bindings);
|
|
32023
|
-
if (!resolved2)
|
|
32024
|
-
return null;
|
|
32025
|
-
if (resolved2.value === null || resolved2.value === undefined)
|
|
32026
|
-
continue;
|
|
32027
|
-
if (typeof resolved2.value !== "object" || Array.isArray(resolved2.value))
|
|
32028
|
-
return null;
|
|
32029
|
-
Object.assign(out, resolved2.value);
|
|
32030
|
-
continue;
|
|
32031
|
-
}
|
|
32032
|
-
const resolved = evaluateStaticLiteral(prop.value, bindings);
|
|
32033
|
-
if (!resolved)
|
|
32034
|
-
return null;
|
|
32035
|
-
out[prop.key] = resolved.value;
|
|
32036
|
-
}
|
|
32037
|
-
return { value: out };
|
|
32038
|
-
}
|
|
32039
|
-
case "unary": {
|
|
32040
|
-
const resolved = evaluateStaticLiteral(expr.argument, bindings);
|
|
32041
|
-
if (!resolved)
|
|
32042
|
-
return null;
|
|
32043
|
-
if (expr.op === "-")
|
|
32044
|
-
return typeof resolved.value === "number" ? { value: -resolved.value } : null;
|
|
32045
|
-
if (expr.op === "+")
|
|
32046
|
-
return typeof resolved.value === "number" ? { value: +resolved.value } : null;
|
|
32047
|
-
if (expr.op === "!")
|
|
32048
|
-
return { value: !resolved.value };
|
|
32049
|
-
return null;
|
|
32050
|
-
}
|
|
32051
|
-
case "identifier":
|
|
32052
|
-
return bindings?.has(expr.name) ? { value: bindings.get(expr.name) } : null;
|
|
32053
|
-
case "member": {
|
|
32054
|
-
const base = evaluateStaticLiteral(expr.object, bindings);
|
|
32055
|
-
if (!base || base.value === null || typeof base.value !== "object")
|
|
32056
|
-
return null;
|
|
32057
|
-
return { value: base.value[expr.property] };
|
|
32058
|
-
}
|
|
32059
|
-
case "index-access": {
|
|
32060
|
-
const base = evaluateStaticLiteral(expr.object, bindings);
|
|
32061
|
-
const index = evaluateStaticLiteral(expr.index, bindings);
|
|
32062
|
-
if (!base || !index || !Array.isArray(base.value) || typeof index.value !== "number")
|
|
32063
|
-
return null;
|
|
32064
|
-
return { value: base.value[index.value] };
|
|
32065
|
-
}
|
|
32066
|
-
default:
|
|
32067
|
-
return null;
|
|
32068
|
-
}
|
|
32069
|
-
}
|
|
32070
|
-
function isFullyStaticLiteral(expr) {
|
|
32071
|
-
return evaluateStaticLiteral(expr) !== null;
|
|
32072
|
-
}
|
|
32073
|
-
function resolveStaticLoopSource(arrayParsed, localConstants, opts) {
|
|
32074
|
-
if (!arrayParsed)
|
|
32075
|
-
return null;
|
|
32076
|
-
let target = arrayParsed;
|
|
32077
|
-
if (arrayParsed.kind === "identifier") {
|
|
32078
|
-
if (opts?.isNameShadowed?.(arrayParsed.name))
|
|
32079
|
-
return null;
|
|
32080
|
-
const local = localConstants?.find((c) => c.name === arrayParsed.name);
|
|
32081
|
-
if (!local?.parsed || local.mutatedAfterDeclaration)
|
|
32082
|
-
return null;
|
|
32083
|
-
target = local.parsed;
|
|
32084
|
-
}
|
|
32085
|
-
const resolved = evaluateStaticLiteral(target);
|
|
32086
|
-
if (!resolved || !Array.isArray(resolved.value))
|
|
32087
|
-
return null;
|
|
32088
|
-
return resolved.value;
|
|
32089
|
-
}
|
|
32090
|
-
|
|
32091
|
-
// src/adapters/loop-plan.ts
|
|
32092
|
-
function spellDestructureLocals(plan, item, spelling) {
|
|
32093
|
-
return plan.destructureLocals.map(({ name, value }) => {
|
|
32094
|
-
const parent = spelling.accessor(item, value.segments);
|
|
32095
|
-
if (value.kind === "slice")
|
|
32096
|
-
return { name, value: spelling.slice(parent, value.from) };
|
|
32097
|
-
if (value.kind === "omit")
|
|
32098
|
-
return { name, value: spelling.omit(parent, value.exclude) };
|
|
32099
|
-
return { name, value: parent };
|
|
32100
|
-
});
|
|
32101
|
-
}
|
|
32102
|
-
function spellSortedSource(sort, recv, spelling) {
|
|
32103
|
-
if (!sort)
|
|
32104
|
-
return recv;
|
|
32105
|
-
if (sort.kind === "eval")
|
|
32106
|
-
return emitCallbackEval(sort, recv, spelling.emit, spelling.eval);
|
|
32107
|
-
if (sort.kind === "structured-sort")
|
|
32108
|
-
return spelling.structured(recv, sort.comparator);
|
|
32109
|
-
spelling.refuse(sort.message, sort.suggestion);
|
|
32110
|
-
return recv;
|
|
32111
|
-
}
|
|
32112
|
-
function spellFilteredRow(filter, row, spelling) {
|
|
32113
|
-
if (!filter)
|
|
32114
|
-
return [...row];
|
|
32115
|
-
return [spelling.open(filterCondition(filter, spelling)), ...row, spelling.close];
|
|
32116
|
-
}
|
|
32117
|
-
function filterCondition(filter, spelling) {
|
|
32118
|
-
if (filter.kind === "predicate")
|
|
32119
|
-
return spelling.condition(filter);
|
|
32120
|
-
spelling.refuse(filter.message, filter.suggestion);
|
|
32121
|
-
return spelling.refused;
|
|
32122
|
-
}
|
|
32123
|
-
function filterPlan(loop, captureAliases, adapterName) {
|
|
32124
|
-
const filter = loop.filterPredicate;
|
|
32125
|
-
if (!filter)
|
|
32126
|
-
return null;
|
|
32127
|
-
if (!filter.predicate)
|
|
32128
|
-
return { kind: "refuse", ...missingFilterPredicateRefusal(filter.raw, adapterName) };
|
|
32129
|
-
const captureRenames = new Map(captureAliases.map(({ name, alias }) => [name, alias]));
|
|
32130
|
-
const rowRenames = new Map(captureRenames);
|
|
32131
|
-
if (filter.param !== loop.param)
|
|
32132
|
-
rowRenames.set(filter.param, loop.param);
|
|
32133
|
-
return {
|
|
32134
|
-
kind: "predicate",
|
|
32135
|
-
param: filter.param,
|
|
32136
|
-
predicate: filter.predicate,
|
|
32137
|
-
captured: renameFreeIdentifiers(filter.predicate, captureRenames),
|
|
32138
|
-
onRow: renameFreeIdentifiers(filter.predicate, rowRenames),
|
|
32139
|
-
aliases: new Map(captureAliases.map(({ name, alias }) => [alias, name]))
|
|
32140
|
-
};
|
|
32141
|
-
}
|
|
32142
|
-
function planLoop(loop, ctx) {
|
|
32143
|
-
const staticItems = resolveStaticLoopSource(loop.arrayParsed, ctx.localConstants, {
|
|
32144
|
-
isNameShadowed: ctx.scope.asShadowPredicate()
|
|
32145
|
-
});
|
|
32146
|
-
const staticSource = staticItems !== null ? ctx.spellStatic(staticItems) : null;
|
|
32147
|
-
const destructure = destructureKind(loop);
|
|
32148
|
-
const captureAliases = filterCaptureCollisions(loop).map((name) => ({ name, alias: `__bf_cap_${loop.markerId}_${name}` }));
|
|
32149
|
-
return {
|
|
32150
|
-
destructure,
|
|
32151
|
-
staticSource,
|
|
32152
|
-
unresolvableConst: staticSource === null ? unresolvableConst(loop, ctx) : null,
|
|
32153
|
-
sort: loop.sortComparator ? lowerSortComparator("sort", loop.sortComparator.arrow, ctx.callbackLowering.adapterName) : null,
|
|
32154
|
-
captureAliases,
|
|
32155
|
-
filter: filterPlan(loop, captureAliases, ctx.callbackLowering.adapterName),
|
|
32156
|
-
itemVar: loop.iterationShape === "keys" || destructure === "lowerable" ? "__bf_item" : loop.param,
|
|
32157
|
-
indexLocal: indexLocal(loop),
|
|
32158
|
-
destructureLocals: destructure === "lowerable" ? destructureLocals(loop) : []
|
|
32159
|
-
};
|
|
32160
|
-
}
|
|
32161
|
-
function indexLocal(loop) {
|
|
32162
|
-
if (loop.objectIteration)
|
|
32163
|
-
return null;
|
|
32164
|
-
return loop.iterationShape === "keys" ? loop.param : loop.index;
|
|
32165
|
-
}
|
|
32166
|
-
function destructureLocals(loop) {
|
|
32167
|
-
return (loop.paramBindings ?? []).map((b) => {
|
|
32168
|
-
const segments = b.segments ?? [];
|
|
32169
|
-
if (b.rest?.kind === "array")
|
|
32170
|
-
return { name: b.name, value: { kind: "slice", segments, from: b.rest.from } };
|
|
32171
|
-
if (b.rest?.kind === "object")
|
|
32172
|
-
return { name: b.name, value: { kind: "omit", segments, exclude: b.rest.exclude.map((k) => k.key) } };
|
|
32173
|
-
return { name: b.name, value: { kind: "path", segments } };
|
|
32174
|
-
});
|
|
32175
|
-
}
|
|
32176
|
-
function destructureKind(loop) {
|
|
32177
|
-
if (!loop.paramBindings || loop.paramBindings.length === 0)
|
|
32178
|
-
return "none";
|
|
32179
|
-
return isLowerableLoopDestructure(loop) ? "lowerable" : "unlowerable";
|
|
32180
|
-
}
|
|
32181
|
-
function unresolvableConst(loop, ctx) {
|
|
32182
|
-
const source = loop.arrayParsed ?? parseExpression(loop.array.trim());
|
|
32183
|
-
if (source?.kind !== "identifier")
|
|
32184
|
-
return null;
|
|
32185
|
-
const name = source.name;
|
|
32186
|
-
if (ctx.scope.isBound(name))
|
|
32187
|
-
return null;
|
|
32188
|
-
const constant = ctx.localConstants.find((c) => c.name === name);
|
|
32189
|
-
return constant && ctx.resolveLiteralConst(name) === null ? constant : null;
|
|
32190
|
-
}
|
|
32191
32935
|
// src/query-href-lowering.ts
|
|
32192
32936
|
function matchQueryHrefCall(callee, args, localNames) {
|
|
32193
32937
|
if (callee.kind !== "identifier" || !localNames.has(callee.name))
|
|
@@ -34116,6 +34860,8 @@ function attrValueToString2(value) {
|
|
|
34116
34860
|
return value.expr;
|
|
34117
34861
|
case "template":
|
|
34118
34862
|
return value.parts.map((p) => {
|
|
34863
|
+
if (p.type === "expression")
|
|
34864
|
+
return p.expr;
|
|
34119
34865
|
if (p.type === "ternary")
|
|
34120
34866
|
return `${p.condition} ${p.whenTrue} ${p.whenFalse}`;
|
|
34121
34867
|
if (p.type === "lookup")
|
|
@@ -35449,8 +36195,6 @@ function profileToJSON(profile) {
|
|
|
35449
36195
|
// src/index.ts
|
|
35450
36196
|
registerBuiltinLoweringPlugins();
|
|
35451
36197
|
export {
|
|
35452
|
-
unsupportedAttrExpressionError,
|
|
35453
|
-
unsupportedAttrExpression,
|
|
35454
36198
|
unloweredCallRefusal,
|
|
35455
36199
|
unboundCallbackParamReason,
|
|
35456
36200
|
unboundCallbackParamRead,
|
|
@@ -35471,6 +36215,7 @@ export {
|
|
|
35471
36215
|
serializeParsedExpr,
|
|
35472
36216
|
searchParamsLocalNames,
|
|
35473
36217
|
scanComponentFile,
|
|
36218
|
+
savedLoopBindings,
|
|
35474
36219
|
rootPropReadName,
|
|
35475
36220
|
rootPropAliasesForLoop,
|
|
35476
36221
|
rootPropAliasNames,
|
|
@@ -35491,6 +36236,8 @@ export {
|
|
|
35491
36236
|
renameFreeIdentifiers,
|
|
35492
36237
|
registerLoweringPlugin,
|
|
35493
36238
|
registerBuiltinLoweringPlugins,
|
|
36239
|
+
refuseAmbiguousNilMemoArithmetic,
|
|
36240
|
+
refuseAmbiguousNilArithmetic,
|
|
35494
36241
|
queryHrefPlugin,
|
|
35495
36242
|
queryHrefLocalNames,
|
|
35496
36243
|
queryHrefArgs,
|
|
@@ -35512,11 +36259,13 @@ export {
|
|
|
35512
36259
|
parseExpression,
|
|
35513
36260
|
parseBlockBodyTolerant,
|
|
35514
36261
|
parseBlockBody,
|
|
36262
|
+
numberValuedSeedNames,
|
|
35515
36263
|
nullishChainParts,
|
|
35516
36264
|
nullableSignalAttrGetter,
|
|
35517
36265
|
nestedCallbackRefusal,
|
|
35518
36266
|
needsTypeBasedDetection,
|
|
35519
36267
|
missingFilterPredicateRefusal,
|
|
36268
|
+
mayYieldBooleanCarrier,
|
|
35520
36269
|
materializeGetterCalls,
|
|
35521
36270
|
matchSearchParamsMethodCall,
|
|
35522
36271
|
matchQueryHrefCall,
|
|
@@ -35526,6 +36275,7 @@ export {
|
|
|
35526
36275
|
lowerSortComparator,
|
|
35527
36276
|
lowerCallbackMethod,
|
|
35528
36277
|
lowerArrayMethod,
|
|
36278
|
+
loopHeaderTargets,
|
|
35529
36279
|
lookupStaticRecordLiteral,
|
|
35530
36280
|
lookupLiteralConst,
|
|
35531
36281
|
literalMemberIndex,
|
|
@@ -35541,9 +36291,11 @@ export {
|
|
|
35541
36291
|
isStringTypedOperand,
|
|
35542
36292
|
isStringTypeInfo,
|
|
35543
36293
|
isStringConcatBinary,
|
|
36294
|
+
isRootPropsObject,
|
|
35544
36295
|
isPredicateMethod,
|
|
35545
36296
|
isOpaqueLocalAccessorName,
|
|
35546
36297
|
isNumericArithmeticResult,
|
|
36298
|
+
isNumberValuedExpr,
|
|
35547
36299
|
isNullishLiteral,
|
|
35548
36300
|
isNullableSignal,
|
|
35549
36301
|
isLowerableObjectRestDestructure,
|
|
@@ -35571,6 +36323,7 @@ export {
|
|
|
35571
36323
|
identifierPath,
|
|
35572
36324
|
hasUnsafeStyleValue,
|
|
35573
36325
|
hasOpaqueCall,
|
|
36326
|
+
hasComputedDefault,
|
|
35574
36327
|
hasClientInteractivity,
|
|
35575
36328
|
groupUnaryOperand,
|
|
35576
36329
|
groupObjectLiteralSegments,
|
|
@@ -35647,6 +36400,7 @@ export {
|
|
|
35647
36400
|
compileJSX,
|
|
35648
36401
|
combineParentChildClientJs,
|
|
35649
36402
|
collectValueReferencedNames,
|
|
36403
|
+
collectNumberValueNames,
|
|
35650
36404
|
collectNullishAttrContext,
|
|
35651
36405
|
collectNullableSignalGetters,
|
|
35652
36406
|
collectNullableOptionalProps,
|
|
@@ -35656,6 +36410,7 @@ export {
|
|
|
35656
36410
|
collectContextConsumers,
|
|
35657
36411
|
collectBooleanValueNames,
|
|
35658
36412
|
collectBooleanTypedProps,
|
|
36413
|
+
collectBooleanCarrierNames,
|
|
35659
36414
|
collectAliasableGetterNames,
|
|
35660
36415
|
collectAbsentPropSeedReads,
|
|
35661
36416
|
childTemplateName,
|
|
@@ -35681,16 +36436,19 @@ export {
|
|
|
35681
36436
|
augmentInheritedPropAccesses,
|
|
35682
36437
|
attrValueMayBeNullish,
|
|
35683
36438
|
asCallbackMethodCall,
|
|
36439
|
+
arithmeticOperandNilIsAmbiguous,
|
|
35684
36440
|
arithmeticOperandIsUndefined,
|
|
35685
36441
|
arithmeticOperandIsNull,
|
|
35686
36442
|
arithmeticOperandCoercion,
|
|
35687
36443
|
arithmeticHelper,
|
|
36444
|
+
arithmeticCoercionOrRefuse,
|
|
35688
36445
|
applyCssLayerPrefix,
|
|
35689
36446
|
analyzeWastedReReruns,
|
|
35690
36447
|
analyzeHotSubscribers,
|
|
35691
36448
|
analyzeComponent,
|
|
35692
36449
|
analyzeClientNeeds,
|
|
35693
36450
|
analyzeBatchAdvisor,
|
|
36451
|
+
ambiguousNilArithmeticOperands,
|
|
35694
36452
|
__resetLoweringPluginsForTest,
|
|
35695
36453
|
USE_CLIENT_DIRECTIVE,
|
|
35696
36454
|
TestAdapter,
|