@barefootjs/jsx 0.40.0 → 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.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 +18 -1
- package/dist/adapters/dsl-template-adapter.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/expression-parser.d.ts.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1006 -351
- 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 +8 -0
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/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 +22 -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.map +1 -1
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/binding-scope-ratchet.test.ts +12 -2
- package/src/__tests__/boolean-carrier.test.ts +74 -0
- package/src/__tests__/component-props.test.ts +14 -0
- package/src/__tests__/computed-const.test.ts +85 -0
- package/src/__tests__/expression-parser.test.ts +24 -0
- package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +142 -0
- 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 +19 -0
- package/src/adapters/ambiguous-nil-arithmetic.ts +94 -0
- package/src/adapters/attr-plan.ts +6 -2
- 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 +39 -0
- package/src/adapters/number-value.ts +95 -0
- package/src/analyzer-context.ts +8 -0
- package/src/analyzer.ts +187 -66
- package/src/expression-parser.ts +4 -1
- package/src/index.ts +12 -2
- package/src/ir-to-client-js/collect-elements.ts +104 -46
- package/src/ir-to-client-js/compute-inlinability.ts +1 -1
- 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 +70 -30
- 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 +15 -1
- package/src/jsx-to-ir.ts +78 -35
- package/src/nullable-signal-attr.ts +134 -13
- package/src/props-binding.ts +54 -3
- package/src/scope/binding-scope.ts +30 -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 +21 -1
- package/src/types.ts +30 -0
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,18 @@ 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
|
+
}
|
|
2970
2977
|
innermostNames() {
|
|
2971
2978
|
return this.frames[0] ? [...this.frames[0].bindings.keys()] : [];
|
|
2972
2979
|
}
|
|
@@ -3035,6 +3042,10 @@ function lookupPartToJsExpr(part, opts) {
|
|
|
3035
3042
|
const typed = opts?.typed ? " as Record<string, string>" : "";
|
|
3036
3043
|
return `(${obj}${typed})[${key}]`;
|
|
3037
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
|
+
}
|
|
3038
3049
|
function templatePartsToJsExpr(parts, opts) {
|
|
3039
3050
|
let result = "`";
|
|
3040
3051
|
for (const part of parts) {
|
|
@@ -3044,7 +3055,7 @@ function templatePartsToJsExpr(parts, opts) {
|
|
|
3044
3055
|
result += `\${${opts?.useTemplate ? part.templateExpr ?? part.expr : part.expr}}`;
|
|
3045
3056
|
} else if (part.type === "ternary") {
|
|
3046
3057
|
const cond = opts?.useTemplate && part.templateCondition ? part.templateCondition : part.condition;
|
|
3047
|
-
result += `\${${cond} ?
|
|
3058
|
+
result += `\${${cond} ? ${singleQuotedJsString(part.whenTrue)} : ${singleQuotedJsString(part.whenFalse)}}`;
|
|
3048
3059
|
} else if (part.type === "lookup") {
|
|
3049
3060
|
result += `\${${lookupPartToJsExpr(part, opts)}}`;
|
|
3050
3061
|
}
|
|
@@ -4065,7 +4076,10 @@ function varSlotId(slotId) {
|
|
|
4065
4076
|
function profileBindingId(componentName, slotId) {
|
|
4066
4077
|
if (!componentName || slotId === "?")
|
|
4067
4078
|
return "";
|
|
4068
|
-
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")}`);
|
|
4069
4083
|
}
|
|
4070
4084
|
function attrValueToString(value, opts) {
|
|
4071
4085
|
switch (value.kind) {
|
|
@@ -5001,6 +5015,29 @@ function isRenamedBodyPropParam(c, propsParams) {
|
|
|
5001
5015
|
return false;
|
|
5002
5016
|
return propsParams.some((p) => !p.isRest && p.name === c.name && p.sourceName === key);
|
|
5003
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
|
+
}
|
|
5004
5041
|
function signalPropSeed(parsed, propsParams, propsObjectName) {
|
|
5005
5042
|
if (!parsed)
|
|
5006
5043
|
return null;
|
|
@@ -5639,7 +5676,8 @@ function spliceChildValue(node, valueExpr, cx) {
|
|
|
5639
5676
|
if (cx.branchSlotsVar)
|
|
5640
5677
|
return branchSlotValue(valueExpr, cx.branchSlotsVar);
|
|
5641
5678
|
if (node.slotId) {
|
|
5642
|
-
|
|
5679
|
+
const markup = cx.markupSlotIds?.has(node.slotId) || node.loopRowPropRead;
|
|
5680
|
+
return markup ? escapedTextOrMarkup(valueExpr) : escapedText(valueExpr);
|
|
5643
5681
|
}
|
|
5644
5682
|
if (node.childrenRead === "bare" || node.childrenRead === "nullish-empty") {
|
|
5645
5683
|
return childrenMarkup(valueExpr);
|
|
@@ -5867,6 +5905,16 @@ function renderTemplateAttrPart(attr, attrName, wrap, restSpreadNames) {
|
|
|
5867
5905
|
return "";
|
|
5868
5906
|
}
|
|
5869
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
|
+
}
|
|
5870
5918
|
function resolvedKeyAttrName(node, loopDepth) {
|
|
5871
5919
|
return node.keyAttr ? keyAttrName(loopDepth) : null;
|
|
5872
5920
|
}
|
|
@@ -6071,7 +6119,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
6071
6119
|
if (node.name === "Portal") {
|
|
6072
6120
|
return node.children.map(recurse).join("");
|
|
6073
6121
|
}
|
|
6074
|
-
const propsEntries = node.props.filter(
|
|
6122
|
+
const propsEntries = node.props.filter(keepsTemplateComponentProp).filter((p) => p.name !== "ref" && !isEventHandlerName(p.name)).map((p) => {
|
|
6075
6123
|
if (p.clientOnly)
|
|
6076
6124
|
return null;
|
|
6077
6125
|
switch (p.value.kind) {
|
|
@@ -6090,7 +6138,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
6090
6138
|
case "template":
|
|
6091
6139
|
case "spread": {
|
|
6092
6140
|
const expr = wrapExpr(attrValueToString(p.value, { useTemplate: true }) ?? "undefined");
|
|
6093
|
-
return
|
|
6141
|
+
return templatePropEntry(p, expr);
|
|
6094
6142
|
}
|
|
6095
6143
|
}
|
|
6096
6144
|
}).filter((entry) => entry !== null);
|
|
@@ -6478,7 +6526,8 @@ function irNodeToJsExprs(node, brandMarkup = false) {
|
|
|
6478
6526
|
propsEntries.push(`get children() { return ${childrenExpr} }`);
|
|
6479
6527
|
}
|
|
6480
6528
|
const propsExpr = propsEntries.length > 0 ? `{ ${propsEntries.join(", ")} }` : "{}";
|
|
6481
|
-
|
|
6529
|
+
const slotArg = node.slotId && !node.loopItemRoot ? `, undefined, { parent: __scopeId, mount: '${node.slotId}' }` : "";
|
|
6530
|
+
return [`createComponent('${nameForRegistryRef(node.name)}', ${propsExpr}${slotArg})`];
|
|
6482
6531
|
}
|
|
6483
6532
|
case "expression":
|
|
6484
6533
|
if (node.expr === "null" || node.expr === "undefined")
|
|
@@ -6683,7 +6732,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
6683
6732
|
if (node.name === "Portal") {
|
|
6684
6733
|
return node.children.map(recurse).join("");
|
|
6685
6734
|
}
|
|
6686
|
-
const propsEntries = node.props.filter(
|
|
6735
|
+
const propsEntries = node.props.filter(keepsTemplateComponentProp).filter((p) => p.name !== "ref" && !isEventHandlerName(p.name)).map((p) => {
|
|
6687
6736
|
if (p.clientOnly)
|
|
6688
6737
|
return null;
|
|
6689
6738
|
switch (p.value.kind) {
|
|
@@ -6700,7 +6749,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
6700
6749
|
case "expression":
|
|
6701
6750
|
return `${quotePropName(p.name)}: ${transformExpr(p.value.expr, p.value.templateExpr)}`;
|
|
6702
6751
|
case "spread":
|
|
6703
|
-
return
|
|
6752
|
+
return templatePropEntry(p, transformExpr(p.value.expr, p.value.templateExpr));
|
|
6704
6753
|
case "template": {
|
|
6705
6754
|
const valueStr = attrValueToString(p.value, { useTemplate: true });
|
|
6706
6755
|
return `${quotePropName(p.name)}: ${transformExpr(valueStr)}`;
|
|
@@ -6896,18 +6945,19 @@ function computeDeferredChildSlots(node, ctx, inlinableConstants, unsafeLocalNam
|
|
|
6896
6945
|
function generateCsrTemplateWithOpts(node, opts) {
|
|
6897
6946
|
const { restSpreadNames, propsObjectName, restPropsName, csrEnv, unsafeLocalNames, loopDepth = 0 } = opts;
|
|
6898
6947
|
const env = csrEnv ?? { substitutions: new Map, propsObjectName: propsObjectName ?? null };
|
|
6899
|
-
const
|
|
6948
|
+
const transformExprOrUnsafe = (expr, templateExpr) => {
|
|
6900
6949
|
const source = templateExpr ?? expr;
|
|
6901
6950
|
if (!source)
|
|
6902
6951
|
return source;
|
|
6903
6952
|
const { rewritten, freeIdentifiers: freeIdentifiers2, writes } = csrSubstitute(source, env, opts.scope);
|
|
6904
6953
|
if (writes.size > 0)
|
|
6905
|
-
return
|
|
6954
|
+
return null;
|
|
6906
6955
|
if (unsafeLocalNames && unsafeLocalNames.size > 0 && setIntersects(freeIdentifiers2, unsafeLocalNames)) {
|
|
6907
|
-
return
|
|
6956
|
+
return null;
|
|
6908
6957
|
}
|
|
6909
6958
|
return rewritePropsObjectRef(rewritten, propsObjectName ?? null, restPropsName ?? null, { enclosingScope: opts.scope });
|
|
6910
6959
|
};
|
|
6960
|
+
const transformExpr = (expr, templateExpr) => transformExprOrUnsafe(expr, templateExpr) ?? UNSAFE_TEMPLATE_EXPR;
|
|
6911
6961
|
const recurse = (n) => generateCsrTemplateWithOpts(n, opts);
|
|
6912
6962
|
const childrenRecurse = (n) => generateCsrTemplateWithOpts(n, { ...opts, inHoistedChildren: false });
|
|
6913
6963
|
switch (node.type) {
|
|
@@ -6997,8 +7047,8 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
6997
7047
|
return `<!--bf:${node.slotId}--><!--/-->`;
|
|
6998
7048
|
}
|
|
6999
7049
|
{
|
|
7000
|
-
const transformed =
|
|
7001
|
-
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 }));
|
|
7002
7052
|
return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
|
|
7003
7053
|
}
|
|
7004
7054
|
case "conditional": {
|
|
@@ -7020,7 +7070,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
7020
7070
|
if (node.slotId && opts.deferredChildSlots?.has(node.slotId)) {
|
|
7021
7071
|
return `<div ${DATA_BF_PH}="${node.slotId}"></div>`;
|
|
7022
7072
|
}
|
|
7023
|
-
const propsEntries = node.props.filter(
|
|
7073
|
+
const propsEntries = node.props.filter(keepsTemplateComponentProp).filter((p) => p.name !== "ref" && !isEventHandlerName(p.name)).map((p) => {
|
|
7024
7074
|
if (p.clientOnly)
|
|
7025
7075
|
return null;
|
|
7026
7076
|
switch (p.value.kind) {
|
|
@@ -7036,17 +7086,17 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
7036
7086
|
return `${quotePropName(p.name)}: true`;
|
|
7037
7087
|
case "expression":
|
|
7038
7088
|
case "spread": {
|
|
7039
|
-
const transformed =
|
|
7040
|
-
if (transformed ===
|
|
7089
|
+
const transformed = transformExprOrUnsafe(p.value.expr, p.value.templateExpr);
|
|
7090
|
+
if (transformed === null)
|
|
7041
7091
|
return null;
|
|
7042
|
-
return
|
|
7092
|
+
return templatePropEntry(p, transformed);
|
|
7043
7093
|
}
|
|
7044
7094
|
case "template": {
|
|
7045
7095
|
const valueStr = attrValueToString(p.value, { useTemplate: true });
|
|
7046
7096
|
if (!valueStr)
|
|
7047
7097
|
return null;
|
|
7048
|
-
const transformed =
|
|
7049
|
-
if (transformed ===
|
|
7098
|
+
const transformed = transformExprOrUnsafe(valueStr);
|
|
7099
|
+
if (transformed === null)
|
|
7050
7100
|
return null;
|
|
7051
7101
|
return `${quotePropName(p.name)}: ${transformed}`;
|
|
7052
7102
|
}
|
|
@@ -7068,8 +7118,8 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
7068
7118
|
const hoistValues = [];
|
|
7069
7119
|
for (const name of hoisted) {
|
|
7070
7120
|
const sub = env.substitutions.get(name);
|
|
7071
|
-
const value =
|
|
7072
|
-
if (value ===
|
|
7121
|
+
const value = transformExprOrUnsafe(sub.kind === "call" ? `${name}()` : name);
|
|
7122
|
+
if (value === null)
|
|
7073
7123
|
continue;
|
|
7074
7124
|
const param = `__bf_outer_${name}`;
|
|
7075
7125
|
hoistParams.push(param);
|
|
@@ -7090,8 +7140,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
7090
7140
|
}
|
|
7091
7141
|
const indexParam = node.index ? `, ${node.index}` : "";
|
|
7092
7142
|
const chainedTemplateArray = node.sortComparator || node.filterPredicate ? applyLoopChain(node, node.templateArray) : node.templateArray;
|
|
7093
|
-
const
|
|
7094
|
-
const safeRawArrayExpr = rawArrayExpr === UNSAFE_TEMPLATE_EXPR ? "[]" : rawArrayExpr;
|
|
7143
|
+
const safeRawArrayExpr = transformExprOrUnsafe(node.array, chainedTemplateArray) ?? "[]";
|
|
7095
7144
|
const { array: iterArrayExpr, callbackParam } = applyIterationShape(node, safeRawArrayExpr, indexParam);
|
|
7096
7145
|
const iterMethod = node.method ?? "map";
|
|
7097
7146
|
let mapExpr;
|
|
@@ -7697,6 +7746,7 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
|
7697
7746
|
reactiveShapedHelpers: new Set,
|
|
7698
7747
|
cleanFactoryImports: new Set,
|
|
7699
7748
|
signalTupleRefs: new Map,
|
|
7749
|
+
templatePropReadWriters: [],
|
|
7700
7750
|
propsType: null,
|
|
7701
7751
|
propsParams: [],
|
|
7702
7752
|
propsObjectName: null,
|
|
@@ -8660,18 +8710,64 @@ function memoSeedExpr(memo) {
|
|
|
8660
8710
|
return memo.bodyExpr?.trim() ?? "";
|
|
8661
8711
|
return memo.parsed ? stringifyParsedExpr(memo.parsed) : "";
|
|
8662
8712
|
}
|
|
8663
|
-
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);
|
|
8664
8738
|
const steps = [];
|
|
8665
8739
|
for (const p of inDefaultReadOrder(metadata.propsParams)) {
|
|
8666
|
-
if (p
|
|
8740
|
+
if (!hasComputedDefault(p) || !p.parsed || !readable.has(p.name))
|
|
8667
8741
|
continue;
|
|
8668
8742
|
const parsed = { kind: "logical", op: "??", left: { kind: "identifier", name: p.name }, right: p.parsed };
|
|
8669
|
-
const step = classify(p.name, "prop", stringifyParsedExpr(parsed), parsed, available,
|
|
8743
|
+
const step = classify(p.name, "prop", stringifyParsedExpr(parsed), parsed, available, unshadowed);
|
|
8670
8744
|
if (step.kind === "derived")
|
|
8671
8745
|
steps.push(step);
|
|
8672
8746
|
}
|
|
8673
8747
|
return steps;
|
|
8674
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
|
+
}
|
|
8675
8771
|
function inDefaultReadOrder(params) {
|
|
8676
8772
|
const byName = new Map(params.filter((p) => !p.isRest).map((p) => [p.name, p]));
|
|
8677
8773
|
const ordered = [];
|
|
@@ -8700,7 +8796,7 @@ function computeSsrSeedPlan(metadata) {
|
|
|
8700
8796
|
const available = new Set(baseScope);
|
|
8701
8797
|
const localConsts = localConstExprsByName(metadata);
|
|
8702
8798
|
const steps = [];
|
|
8703
|
-
steps.push(...dependentPropDefaultSteps(metadata,
|
|
8799
|
+
steps.push(...dependentPropDefaultSteps(metadata, inlined));
|
|
8704
8800
|
for (const signal of metadata.signals) {
|
|
8705
8801
|
if (signal.envReader) {
|
|
8706
8802
|
const reader = envSignalReaderFor(signal.envReader);
|
|
@@ -8754,7 +8850,8 @@ var UNRESOLVED = Symbol("unresolved");
|
|
|
8754
8850
|
var NO_RETURN = Symbol("no-return");
|
|
8755
8851
|
function addPropSsrDefaults(metadata, propsLike, out) {
|
|
8756
8852
|
const plan = metadata.ssrSeedPlan ?? computeSsrSeedPlan(metadata);
|
|
8757
|
-
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));
|
|
8758
8855
|
for (const p of metadata.propsParams) {
|
|
8759
8856
|
if (p.isRest)
|
|
8760
8857
|
continue;
|
|
@@ -9232,25 +9329,69 @@ function programWithSeparatedSource(program, filePath, source) {
|
|
|
9232
9329
|
}
|
|
9233
9330
|
} });
|
|
9234
9331
|
}
|
|
9235
|
-
function collidingBindings(ctx, propsObjectName) {
|
|
9236
|
-
const propNames = new Set(ctx.propsParams.map((p) => p.name.toLowerCase()));
|
|
9332
|
+
function collidingBindings(ctx, propsObjectName, propNames) {
|
|
9237
9333
|
const localConsts = localConstValuesByName(ctx);
|
|
9238
|
-
const collides = (name
|
|
9239
|
-
const
|
|
9240
|
-
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) }));
|
|
9241
9338
|
return [...signals, ...memos];
|
|
9242
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
|
+
}
|
|
9243
9375
|
function separateSignalPropBindings(ctx, isNonReference) {
|
|
9244
|
-
|
|
9376
|
+
const propsObjectName = ctx.propsObjectName;
|
|
9377
|
+
const component = ctx.componentNode;
|
|
9378
|
+
if (!propsObjectName || !component)
|
|
9245
9379
|
return null;
|
|
9246
|
-
const
|
|
9247
|
-
|
|
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)
|
|
9248
9383
|
return null;
|
|
9249
9384
|
const sf = ctx.sourceFile;
|
|
9250
9385
|
const checker = ctx.checker ?? ts21.createProgram([sf.fileName], { noLib: true, noResolve: true }, {
|
|
9251
9386
|
...ts21.createCompilerHost({ noLib: true, noResolve: true }),
|
|
9252
9387
|
getSourceFile: () => sf
|
|
9253
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;
|
|
9254
9395
|
const occupied = new Set;
|
|
9255
9396
|
function collectNames(node) {
|
|
9256
9397
|
if (ts21.isIdentifier(node))
|
|
@@ -9268,7 +9409,7 @@ function separateSignalPropBindings(ctx, isNonReference) {
|
|
|
9268
9409
|
function collectBindings(node) {
|
|
9269
9410
|
if (ts21.isVariableDeclaration(node)) {
|
|
9270
9411
|
const binding = declarations.get(node.getStart(sf));
|
|
9271
|
-
if (binding) {
|
|
9412
|
+
if (binding && needsSeparation(binding, node, reads)) {
|
|
9272
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] : []) : [];
|
|
9273
9414
|
const id = names.find((n) => n.text === binding.name);
|
|
9274
9415
|
const symbol = id && checker.getSymbolAtLocation(id);
|
|
@@ -9285,7 +9426,7 @@ function separateSignalPropBindings(ctx, isNonReference) {
|
|
|
9285
9426
|
}
|
|
9286
9427
|
ts21.forEachChild(node, collectBindings);
|
|
9287
9428
|
}
|
|
9288
|
-
collectBindings(
|
|
9429
|
+
collectBindings(component);
|
|
9289
9430
|
const edits = [];
|
|
9290
9431
|
function collectEdits(node) {
|
|
9291
9432
|
if (ts21.isIdentifier(node) && !isNonReference(node)) {
|
|
@@ -9302,7 +9443,7 @@ function separateSignalPropBindings(ctx, isNonReference) {
|
|
|
9302
9443
|
}
|
|
9303
9444
|
ts21.forEachChild(node, collectEdits);
|
|
9304
9445
|
}
|
|
9305
|
-
collectEdits(
|
|
9446
|
+
collectEdits(component);
|
|
9306
9447
|
if (edits.length === 0)
|
|
9307
9448
|
return null;
|
|
9308
9449
|
let source = sf.text;
|
|
@@ -9360,9 +9501,12 @@ function findBrandPackageImportLoc(sourceFile, filePath) {
|
|
|
9360
9501
|
return null;
|
|
9361
9502
|
}
|
|
9362
9503
|
function createProgramForFile(source, filePath, hostOptions = {}) {
|
|
9504
|
+
return buildProgramForFile(source, filePath, hostOptions);
|
|
9505
|
+
}
|
|
9506
|
+
function buildProgramForFile(source, filePath, hostOptions) {
|
|
9363
9507
|
incrementCounter("programCreations");
|
|
9364
9508
|
try {
|
|
9365
|
-
const { currentDirectory } = hostOptions;
|
|
9509
|
+
const { currentDirectory, sourceFiles } = hostOptions;
|
|
9366
9510
|
const resolveFrom = (fileName) => currentDirectory === undefined ? path_default.resolve(fileName) : path_default.resolve(currentDirectory, fileName);
|
|
9367
9511
|
const normalizedPath = resolveFrom(filePath);
|
|
9368
9512
|
const compilerOptions = {
|
|
@@ -9381,8 +9525,14 @@ function createProgramForFile(source, filePath, hostOptions = {}) {
|
|
|
9381
9525
|
...currentDirectory === undefined ? {} : { getCurrentDirectory: () => currentDirectory },
|
|
9382
9526
|
getSourceFile(fileName, languageVersion) {
|
|
9383
9527
|
if (resolveFrom(fileName) === normalizedPath) {
|
|
9528
|
+
if (sourceFiles)
|
|
9529
|
+
return sourceFiles.get(fileName, languageVersion, source, VIRTUAL_SOURCE_PARSE);
|
|
9384
9530
|
return ts22.createSourceFile(fileName, source, languageVersion, true, ts22.ScriptKind.TSX);
|
|
9385
9531
|
}
|
|
9532
|
+
if (sourceFiles) {
|
|
9533
|
+
const text = defaultHost.readFile(fileName);
|
|
9534
|
+
return text === undefined ? undefined : sourceFiles.get(fileName, languageVersion, text, DISK_FILE_PARSE);
|
|
9535
|
+
}
|
|
9386
9536
|
return defaultHost.getSourceFile(fileName, languageVersion);
|
|
9387
9537
|
},
|
|
9388
9538
|
fileExists(fileName) {
|
|
@@ -9413,8 +9563,34 @@ function rewriteSourceForAnalysis(source, filePath, prescan) {
|
|
|
9413
9563
|
function createAnchoredProgram(source, filename, anchorDir) {
|
|
9414
9564
|
if (!needsTypeBasedDetection(source))
|
|
9415
9565
|
return;
|
|
9416
|
-
return
|
|
9566
|
+
return buildProgramForFile(source, filename, { currentDirectory: anchorDir, sourceFiles: anchoredSourceFiles })?.program;
|
|
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
|
+
}
|
|
9417
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;
|
|
9418
9594
|
function parseSignalInitializer(signal, ctx) {
|
|
9419
9595
|
if (!signal.initialValue)
|
|
9420
9596
|
return;
|
|
@@ -10042,27 +10218,24 @@ function collectSignal(node, ctx) {
|
|
|
10042
10218
|
const type = signalTypeInfo(callExpr, initialValue, ctx);
|
|
10043
10219
|
const envReader = resolveEnvSignalKey(callExpr, ctx) ?? undefined;
|
|
10044
10220
|
const envFactory = envReader ? callExpr.expression.getText(ctx.sourceFile) : undefined;
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
const propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
10048
|
-
if (propNames.size > 0) {
|
|
10049
|
-
const propAliases = buildPropAliasMap(ctx.propsParams);
|
|
10050
|
-
templateInitialValue = rewriteBarePropRefs(initialValue, callExpr.arguments[0], propNames, undefined, propAliases, destructuredPropTemplateRead(ctx));
|
|
10051
|
-
}
|
|
10052
|
-
}
|
|
10053
|
-
ctx.signals.push({
|
|
10221
|
+
const seedNode = callExpr.arguments[0];
|
|
10222
|
+
const signal = {
|
|
10054
10223
|
getter,
|
|
10055
10224
|
setter,
|
|
10056
10225
|
getterElided: getterElided || undefined,
|
|
10057
10226
|
initialValue,
|
|
10058
10227
|
typedInitialValue: typedInitialValue !== initialValue ? typedInitialValue : undefined,
|
|
10059
|
-
templateInitialValue,
|
|
10060
10228
|
type,
|
|
10061
10229
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
10062
|
-
initialFreeIdentifiers:
|
|
10230
|
+
initialFreeIdentifiers: seedNode ? extractFreeIdentifiersFromNode(seedNode) : new Set,
|
|
10063
10231
|
envReader,
|
|
10064
10232
|
envFactory
|
|
10065
|
-
}
|
|
10233
|
+
};
|
|
10234
|
+
ctx.signals.push(signal);
|
|
10235
|
+
if (seedNode)
|
|
10236
|
+
deferTemplatePropRead(initialValue, seedNode, ctx, (text) => {
|
|
10237
|
+
signal.templateInitialValue = text;
|
|
10238
|
+
});
|
|
10066
10239
|
}
|
|
10067
10240
|
function collectFactorySignal(node, pattern, callExpr, kind, ctx) {
|
|
10068
10241
|
const elements = pattern.elements;
|
|
@@ -10089,23 +10262,14 @@ function collectFactorySignal(node, pattern, callExpr, kind, ctx) {
|
|
|
10089
10262
|
} else if (initialNode.kind !== "absent") {
|
|
10090
10263
|
type = inferTypeFromValue(initialValue);
|
|
10091
10264
|
}
|
|
10092
|
-
let templateInitialValue;
|
|
10093
|
-
if (!ctx.propsObjectName && initialNode.kind === "expression") {
|
|
10094
|
-
const propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
10095
|
-
if (propNames.size > 0) {
|
|
10096
|
-
const propAliases = buildPropAliasMap(ctx.propsParams);
|
|
10097
|
-
templateInitialValue = rewriteBarePropRefs(initialValue, initialNode.node, propNames, undefined, propAliases, destructuredPropTemplateRead(ctx));
|
|
10098
|
-
}
|
|
10099
|
-
}
|
|
10100
10265
|
const argTexts = callExpr.arguments.map((arg) => ctx.getJS(arg));
|
|
10101
10266
|
const requestArg = callExpr.arguments[0];
|
|
10102
|
-
|
|
10267
|
+
const signal = {
|
|
10103
10268
|
getter: valueName ?? `__bfGet_${action}`,
|
|
10104
10269
|
setter: null,
|
|
10105
10270
|
getterElided: getterElided || undefined,
|
|
10106
10271
|
initialValue,
|
|
10107
10272
|
typedInitialValue: typedInitialValue !== undefined && typedInitialValue !== initialValue ? typedInitialValue : undefined,
|
|
10108
|
-
templateInitialValue,
|
|
10109
10273
|
type,
|
|
10110
10274
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
10111
10275
|
initialFreeIdentifiers,
|
|
@@ -10117,7 +10281,13 @@ function collectFactorySignal(node, pattern, callExpr, kind, ctx) {
|
|
|
10117
10281
|
requestFreeIdentifiers: requestArg ? extractFreeIdentifiersFromNode(requestArg) : new Set,
|
|
10118
10282
|
action
|
|
10119
10283
|
}
|
|
10120
|
-
}
|
|
10284
|
+
};
|
|
10285
|
+
ctx.signals.push(signal);
|
|
10286
|
+
if (initialNode.kind === "expression") {
|
|
10287
|
+
deferTemplatePropRead(initialValue, initialNode.node, ctx, (text) => {
|
|
10288
|
+
signal.templateInitialValue = text;
|
|
10289
|
+
});
|
|
10290
|
+
}
|
|
10121
10291
|
}
|
|
10122
10292
|
function factoryInitialNode(options) {
|
|
10123
10293
|
if (!options)
|
|
@@ -10374,18 +10544,15 @@ function memoStructuredBody(callback, ctx) {
|
|
|
10374
10544
|
return { parsed, parsedBlock, parsedBlockComplete };
|
|
10375
10545
|
}
|
|
10376
10546
|
function memoBodyFields(body, ctx) {
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
}
|
|
10387
|
-
}
|
|
10388
|
-
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
|
+
});
|
|
10389
10556
|
}
|
|
10390
10557
|
function collectMemo(node, ctx) {
|
|
10391
10558
|
const name = node.name.text;
|
|
@@ -10433,6 +10600,8 @@ function collectMemo(node, ctx) {
|
|
|
10433
10600
|
computationFreeIdentifiers: callExpr.arguments[0] ? extractFreeIdentifiersFromNode(callExpr.arguments[0]) : new Set
|
|
10434
10601
|
};
|
|
10435
10602
|
ctx.memos.push(memo);
|
|
10603
|
+
if (body)
|
|
10604
|
+
deferMemoTemplateBody(memo, body, ctx);
|
|
10436
10605
|
markBlockMemo(memo, blockTyped, body?.node, ctx);
|
|
10437
10606
|
}
|
|
10438
10607
|
function markBlockMemo(memo, blockTyped, bodyNode, ctx) {
|
|
@@ -11378,6 +11547,20 @@ function destructuredPropTemplateRead(ctx) {
|
|
|
11378
11547
|
const byName = new Map(ctx.propsParams.filter((p) => !p.isRest).map((p) => [p.name, p]));
|
|
11379
11548
|
return (localName, callerKey) => livePropReadExpr(byName.get(localName) ?? { name: localName, sourceName: callerKey }, undefined, false);
|
|
11380
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
|
+
}
|
|
11381
11564
|
function bindingElementDefaultFields(initializer, ctx, earlier = new Map) {
|
|
11382
11565
|
const defaultValue = initializer ? ctx.getJS(initializer) : undefined;
|
|
11383
11566
|
const defaultContainsArrow = initializer ? nodeContainsArrow(initializer) : false;
|
|
@@ -11634,6 +11817,7 @@ function extractProps(param, ctx) {
|
|
|
11634
11817
|
const info = {
|
|
11635
11818
|
name: localName,
|
|
11636
11819
|
type: resolvedType,
|
|
11820
|
+
...unresolvedDeclaredType(member),
|
|
11637
11821
|
optional: !!member?.optional || !!element.initializer,
|
|
11638
11822
|
...bindingElementDefaultFields(element.initializer, ctx, earlier),
|
|
11639
11823
|
...sourcePropName !== localName && { sourceName: sourcePropName }
|
|
@@ -11756,6 +11940,9 @@ function localObjectMemberTypesFor(ctx) {
|
|
|
11756
11940
|
return cache.get(name) ?? null;
|
|
11757
11941
|
};
|
|
11758
11942
|
}
|
|
11943
|
+
function unresolvedDeclaredType(member) {
|
|
11944
|
+
return member && !member.type && member.declared ? { declaredType: member.declared } : {};
|
|
11945
|
+
}
|
|
11759
11946
|
function collectMemberTypes(typeNode, ctx) {
|
|
11760
11947
|
const localObjectMembers = localObjectMemberTypesFor(ctx);
|
|
11761
11948
|
const fromMembers = (members) => {
|
|
@@ -11765,6 +11952,7 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
11765
11952
|
const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
|
|
11766
11953
|
map.set(member.name.getText(ctx.sourceFile), {
|
|
11767
11954
|
type: info && isResolvableMemberType(info, localObjectMembers) ? info : null,
|
|
11955
|
+
declared: info,
|
|
11768
11956
|
optional: !!member.questionToken
|
|
11769
11957
|
});
|
|
11770
11958
|
}
|
|
@@ -11916,6 +12104,7 @@ function validateContext(ctx) {
|
|
|
11916
12104
|
}
|
|
11917
12105
|
markMutatedConstants(ctx);
|
|
11918
12106
|
markWrittenBindings(ctx);
|
|
12107
|
+
writeTemplatePropReads(ctx);
|
|
11919
12108
|
validateInitStatementReferences(ctx);
|
|
11920
12109
|
validateReactiveFactoryCalls(ctx);
|
|
11921
12110
|
validateReactiveFactoryArity(ctx);
|
|
@@ -14774,8 +14963,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
14774
14963
|
}
|
|
14775
14964
|
function getDestructuredPropNames(ctx) {
|
|
14776
14965
|
if (ctx._destructuredPropNames === undefined) {
|
|
14777
|
-
const
|
|
14778
|
-
const eligible = ctx.analyzer.propsParams.filter((p) => !shadowed.has(p.name));
|
|
14966
|
+
const eligible = templatePropReadParams(ctx.analyzer);
|
|
14779
14967
|
const names = eligible.map((p) => p.name);
|
|
14780
14968
|
ctx._destructuredPropNames = names.length > 0 ? new Set(names) : null;
|
|
14781
14969
|
ctx._destructuredPropAliases = buildPropAliasMap(eligible) ?? null;
|
|
@@ -14786,30 +14974,6 @@ function getDestructuredPropNames(ctx) {
|
|
|
14786
14974
|
}
|
|
14787
14975
|
return ctx._destructuredPropNames ?? null;
|
|
14788
14976
|
}
|
|
14789
|
-
function propShadowingNames(analyzer) {
|
|
14790
|
-
const shadowed = new Set;
|
|
14791
|
-
if (!analyzer.propsObjectName)
|
|
14792
|
-
return shadowed;
|
|
14793
|
-
for (const s of analyzer.signals) {
|
|
14794
|
-
shadowed.add(s.getter);
|
|
14795
|
-
if (s.setter)
|
|
14796
|
-
shadowed.add(s.setter);
|
|
14797
|
-
}
|
|
14798
|
-
for (const m of analyzer.memos)
|
|
14799
|
-
shadowed.add(m.name);
|
|
14800
|
-
for (const c of analyzer.localConstants) {
|
|
14801
|
-
if (c.propsDestructure && !keepsDeclaredValue(c)) {
|
|
14802
|
-
shadowed.add(c.name);
|
|
14803
|
-
continue;
|
|
14804
|
-
}
|
|
14805
|
-
if (isPropsAliasConst(c, analyzer.propsObjectName))
|
|
14806
|
-
continue;
|
|
14807
|
-
if (isRenamedBodyPropParam(c, analyzer.propsParams))
|
|
14808
|
-
continue;
|
|
14809
|
-
shadowed.add(c.name);
|
|
14810
|
-
}
|
|
14811
|
-
return shadowed;
|
|
14812
|
-
}
|
|
14813
14977
|
function getDestructuredPropInfoByName(ctx) {
|
|
14814
14978
|
if (ctx._destructuredPropNames === undefined)
|
|
14815
14979
|
getDestructuredPropNames(ctx);
|
|
@@ -15025,6 +15189,33 @@ function childrenReadOf(parsed, analyzer, scope) {
|
|
|
15025
15189
|
const readsProps = parsed.kind === "member" && parsed.object.kind === "identifier" && !scope.isBound(parsed.object.name);
|
|
15026
15190
|
return readsProps && isPropsChildrenMember(parsed, analyzer) ? "bare" : null;
|
|
15027
15191
|
}
|
|
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
|
+
}
|
|
15028
15219
|
function attachParsedAttrValues(node, parse2, parseValue, resolve2) {
|
|
15029
15220
|
const attach = (value, spreads) => {
|
|
15030
15221
|
if (value.kind === "template" || value.kind === "expression") {
|
|
@@ -15057,9 +15248,8 @@ function attachParsedExpressions(node, analyzer, scope = BindingScope.EMPTY) {
|
|
|
15057
15248
|
const trimmed = node.expr.trim();
|
|
15058
15249
|
if (trimmed)
|
|
15059
15250
|
node.parsed = parse2(trimmed);
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
node.childrenRead = childrenRead;
|
|
15251
|
+
if (node.parsed)
|
|
15252
|
+
attachPropReadFlags(node, node.parsed, analyzer, scope);
|
|
15063
15253
|
} else if (node.type === "conditional" || node.type === "if-statement") {
|
|
15064
15254
|
const trimmed = node.condition.trim();
|
|
15065
15255
|
if (trimmed)
|
|
@@ -18976,7 +19166,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
18976
19166
|
const props = [];
|
|
18977
19167
|
for (const attr of attributes.properties) {
|
|
18978
19168
|
if (ts25.isJsxSpreadAttribute(attr)) {
|
|
18979
|
-
props.push(...expandSpreadAttribute(attr, ctx).map(({ restExpandedKey: _restExpandedKey, ...prop }) => prop));
|
|
19169
|
+
props.push(...expandSpreadAttribute(attr, ctx).map(({ restExpandedKey: _restExpandedKey, ...prop }) => markPropsObjectSpread(prop, ctx)));
|
|
18980
19170
|
continue;
|
|
18981
19171
|
}
|
|
18982
19172
|
if (!ts25.isJsxAttribute(attr))
|
|
@@ -19325,6 +19515,18 @@ function forwardsCallerRestProps(attrs, ctx) {
|
|
|
19325
19515
|
}
|
|
19326
19516
|
return false;
|
|
19327
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
|
+
}
|
|
19328
19530
|
function constantValuesByName(ctx) {
|
|
19329
19531
|
if (ctx._constantValuesByName)
|
|
19330
19532
|
return ctx._constantValuesByName;
|
|
@@ -19838,7 +20040,8 @@ function collectLoopChildEventsWithNesting(node, initialNestingStack = [], sibli
|
|
|
19838
20040
|
const initialScope = {
|
|
19839
20041
|
nestingStack: initialNestingStack,
|
|
19840
20042
|
lastElementSlotId: null,
|
|
19841
|
-
domDepth: 0
|
|
20043
|
+
domDepth: 0,
|
|
20044
|
+
receivers: []
|
|
19842
20045
|
};
|
|
19843
20046
|
walkIR(node, initialScope, {
|
|
19844
20047
|
element: ({ node: el, scope, descend }) => {
|
|
@@ -19849,7 +20052,8 @@ function collectLoopChildEventsWithNesting(node, initialNestingStack = [], sibli
|
|
|
19849
20052
|
childSlotId: el.slotId,
|
|
19850
20053
|
handler: event.handler,
|
|
19851
20054
|
nestedLoops: [...scope.nestingStack],
|
|
19852
|
-
domDepth: scope.domDepth
|
|
20055
|
+
domDepth: scope.domDepth,
|
|
20056
|
+
...el.slotId.startsWith("^") && scope.receivers.length > 0 && { receiverSlotIds: scope.receivers }
|
|
19853
20057
|
});
|
|
19854
20058
|
}
|
|
19855
20059
|
}
|
|
@@ -19859,9 +20063,13 @@ function collectLoopChildEventsWithNesting(node, initialNestingStack = [], sibli
|
|
|
19859
20063
|
domDepth: scope.domDepth + 1
|
|
19860
20064
|
});
|
|
19861
20065
|
},
|
|
20066
|
+
component: ({ node: c, scope, descend }) => {
|
|
20067
|
+
descend(c !== node && c.slotId ? { ...scope, receivers: [...scope.receivers, c.slotId] } : scope);
|
|
20068
|
+
},
|
|
19862
20069
|
loop: ({ node: l, scope, descend }) => {
|
|
19863
20070
|
descend({
|
|
19864
20071
|
...scope,
|
|
20072
|
+
receivers: [],
|
|
19865
20073
|
nestingStack: [
|
|
19866
20074
|
...scope.nestingStack,
|
|
19867
20075
|
{
|
|
@@ -19925,7 +20133,8 @@ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings,
|
|
|
19925
20133
|
slotId: n.slotId,
|
|
19926
20134
|
expression: expanded.expr,
|
|
19927
20135
|
insideConditional: insideConditional || undefined,
|
|
19928
|
-
...expanded.freeIds !== undefined && { freeIdentifiers: expanded.freeIds }
|
|
20136
|
+
...expanded.freeIds !== undefined && { freeIdentifiers: expanded.freeIds },
|
|
20137
|
+
...n.loopRowPropRead && { markup: true }
|
|
19929
20138
|
});
|
|
19930
20139
|
},
|
|
19931
20140
|
conditional: ({ node: c, descend }) => {
|
|
@@ -20372,6 +20581,9 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
|
|
|
20372
20581
|
childComponents,
|
|
20373
20582
|
insideConditional: !flat && scope.insideCond ? true : undefined,
|
|
20374
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,
|
|
20375
20587
|
bindings
|
|
20376
20588
|
});
|
|
20377
20589
|
if (!flat) {
|
|
@@ -20393,6 +20605,13 @@ function decideLoopRendering(loop, siblingOffsets, ctx, branchScope = false) {
|
|
|
20393
20605
|
const useElementReconciliation = !loop.childComponent && (!loop.isStaticArray || branchScope && hasInnerLoops) && (hasNestedComps || hasInnerLoops);
|
|
20394
20606
|
return { useElementReconciliation, innerLoops };
|
|
20395
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
|
+
}
|
|
20396
20615
|
function jsxChildrenContainComponent(nodes) {
|
|
20397
20616
|
for (const node of nodes) {
|
|
20398
20617
|
if (node.type === "component")
|
|
@@ -20408,6 +20627,42 @@ function jsxChildrenContainComponent(nodes) {
|
|
|
20408
20627
|
}
|
|
20409
20628
|
return false;
|
|
20410
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
|
+
}
|
|
20411
20666
|
function buildComponentPropsExpr(props, ctx) {
|
|
20412
20667
|
const knownSpreadProp = props.find((p) => {
|
|
20413
20668
|
if (p.name !== "..." && !p.name.startsWith("..."))
|
|
@@ -20418,47 +20673,21 @@ function buildComponentPropsExpr(props, ctx) {
|
|
|
20418
20673
|
return resolveRestSpreadOrigin(ctx, expr) !== null;
|
|
20419
20674
|
});
|
|
20420
20675
|
const spreadSource = knownSpreadProp ? PROPS_PARAM : null;
|
|
20676
|
+
const spreadAt = lastPropsObjectSpreadIndex(props);
|
|
20421
20677
|
const propsForInit = [];
|
|
20422
20678
|
const explicitPropNames = [];
|
|
20423
|
-
|
|
20679
|
+
props.forEach((prop, index) => {
|
|
20424
20680
|
if (prop.name === "..." || prop.name.startsWith("..."))
|
|
20425
|
-
|
|
20681
|
+
return;
|
|
20426
20682
|
explicitPropNames.push(prop.name);
|
|
20427
|
-
const
|
|
20428
|
-
|
|
20429
|
-
|
|
20430
|
-
|
|
20431
|
-
}
|
|
20432
|
-
|
|
20433
|
-
case "jsx-children": {
|
|
20434
|
-
if (jsxChildrenContainComponent(prop.value.children)) {
|
|
20435
|
-
const jsxExpr = irChildrenToJsExpr(prop.value.children);
|
|
20436
|
-
propsForInit.push(`get ${quotePropName(prop.name)}() { return __slot(() => ${jsxExpr}) }`);
|
|
20437
|
-
} else {
|
|
20438
|
-
const jsxExpr = jsxChildrenPropGetterExpr(prop.value.children, prop.name);
|
|
20439
|
-
propsForInit.push(`get ${quotePropName(prop.name)}() { return ${jsxExpr} }`);
|
|
20440
|
-
}
|
|
20441
|
-
break;
|
|
20442
|
-
}
|
|
20443
|
-
case "expression":
|
|
20444
|
-
case "template":
|
|
20445
|
-
case "spread": {
|
|
20446
|
-
const valueExpr = attrValueToString(prop.value);
|
|
20447
|
-
const expandedValue = expandDynamicPropValue(valueExpr, ctx);
|
|
20448
|
-
propsForInit.push(`get ${quotePropName(prop.name)}() { return ${expandedValue} }`);
|
|
20449
|
-
break;
|
|
20450
|
-
}
|
|
20451
|
-
case "literal":
|
|
20452
|
-
propsForInit.push(`${quotePropName(prop.name)}: ${JSON.stringify(prop.value.value)}`);
|
|
20453
|
-
break;
|
|
20454
|
-
case "boolean-shorthand":
|
|
20455
|
-
propsForInit.push(`${quotePropName(prop.name)}: true`);
|
|
20456
|
-
break;
|
|
20457
|
-
case "boolean-attr":
|
|
20458
|
-
propsForInit.push(`${quotePropName(prop.name)}: true`);
|
|
20459
|
-
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}`);
|
|
20460
20689
|
}
|
|
20461
|
-
}
|
|
20690
|
+
});
|
|
20462
20691
|
if (spreadSource) {
|
|
20463
20692
|
const overrides = propsForInit.length > 0 ? `{ ${propsForInit.join(", ")} }` : "{}";
|
|
20464
20693
|
const excludeKeys = JSON.stringify(explicitPropNames);
|
|
@@ -20467,7 +20696,8 @@ function buildComponentPropsExpr(props, ctx) {
|
|
|
20467
20696
|
return propsForInit.length > 0 ? `{ ${propsForInit.join(", ")} }` : "{}";
|
|
20468
20697
|
}
|
|
20469
20698
|
function collectReactiveChildProps(node, ctx) {
|
|
20470
|
-
|
|
20699
|
+
const spreadAt = lastPropsObjectSpreadIndex(node.props);
|
|
20700
|
+
for (const [index, prop] of node.props.entries()) {
|
|
20471
20701
|
if (prop.name === "..." || prop.name.startsWith("..."))
|
|
20472
20702
|
continue;
|
|
20473
20703
|
if (prop.value.kind === "jsx-children")
|
|
@@ -20487,7 +20717,7 @@ function collectReactiveChildProps(node, ctx) {
|
|
|
20487
20717
|
slotId: node.slotId,
|
|
20488
20718
|
propName: prop.name,
|
|
20489
20719
|
attrName,
|
|
20490
|
-
expression: expandedValue,
|
|
20720
|
+
expression: mergedMirrorExpr(prop.name, expandedValue, index, spreadAt),
|
|
20491
20721
|
...pickAttrMetaFromIR(prop)
|
|
20492
20722
|
});
|
|
20493
20723
|
}
|
|
@@ -20624,7 +20854,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
20624
20854
|
nestedComponents: l.nestedComponents,
|
|
20625
20855
|
isStaticArray: clientIsStaticArray,
|
|
20626
20856
|
useElementReconciliation,
|
|
20627
|
-
innerLoops:
|
|
20857
|
+
innerLoops: keepsInnerLoops(l, useElementReconciliation, innerLoops) ? innerLoops : undefined,
|
|
20628
20858
|
offset: resolveLoopOffset(siblingOffsets.get(l)),
|
|
20629
20859
|
filterPredicate: l.filterPredicate ? {
|
|
20630
20860
|
param: l.filterPredicate.param,
|
|
@@ -20651,7 +20881,8 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
20651
20881
|
},
|
|
20652
20882
|
component: ({ node: c, descend, descendJsxChildren }) => {
|
|
20653
20883
|
if (c.slotId) {
|
|
20654
|
-
|
|
20884
|
+
const spreadAt = lastPropsObjectSpreadIndex(c.props);
|
|
20885
|
+
for (const [index, prop] of c.props.entries()) {
|
|
20655
20886
|
if (prop.value.kind === "jsx-children")
|
|
20656
20887
|
continue;
|
|
20657
20888
|
if (isEventHandlerName(prop.name))
|
|
@@ -20667,7 +20898,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
20667
20898
|
ctx.reactiveProps.push({
|
|
20668
20899
|
slotId: c.slotId,
|
|
20669
20900
|
propName: prop.name,
|
|
20670
|
-
expression:
|
|
20901
|
+
expression: mergedMirrorExpr(prop.name, value, index, spreadAt),
|
|
20671
20902
|
componentName: c.name
|
|
20672
20903
|
});
|
|
20673
20904
|
}
|
|
@@ -22875,11 +23106,12 @@ function emitListenerLine(lines, indent, elementVar, eventName, handler, mode =
|
|
|
22875
23106
|
const name = mode === "dom" ? toDomEventName(eventName) : eventName;
|
|
22876
23107
|
lines.push(`${indent}if (${elementVar}) ${elementVar}.addEventListener('${name}', ${wrapped})`);
|
|
22877
23108
|
}
|
|
22878
|
-
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) {
|
|
22879
23110
|
const wrapped = handler.trim();
|
|
22880
23111
|
const name = mode === "dom" ? toDomEventName(eventName) : eventName;
|
|
22881
23112
|
const lookup = bodyIsMultiRoot ? "qsaItem" : "qsa";
|
|
22882
|
-
|
|
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}) }`);
|
|
22883
23115
|
}
|
|
22884
23116
|
|
|
22885
23117
|
// src/ir-to-client-js/control-flow/shared.ts
|
|
@@ -23040,18 +23272,19 @@ function buildDepthLevels(innerLoops, nestedComps, childEvents) {
|
|
|
23040
23272
|
}));
|
|
23041
23273
|
}
|
|
23042
23274
|
function emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot = false, loopIndex) {
|
|
23043
|
-
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 };
|
|
23044
23276
|
emitRowEventListener(ls, indent, elVar, binding, bodyIsMultiRoot);
|
|
23045
23277
|
}
|
|
23046
23278
|
function buildRowEventBinding(ev, loopParam, loopParamBindings, loopIndex) {
|
|
23047
23279
|
return {
|
|
23048
23280
|
childSlotId: ev.childSlotId,
|
|
23049
23281
|
eventName: ev.eventName,
|
|
23050
|
-
handler: wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings, loopIndex)
|
|
23282
|
+
handler: wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings, loopIndex),
|
|
23283
|
+
receiverSlotIds: ev.receiverSlotIds
|
|
23051
23284
|
};
|
|
23052
23285
|
}
|
|
23053
23286
|
function emitRowEventListener(ls, indent, elVar, binding, bodyIsMultiRoot = false) {
|
|
23054
|
-
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);
|
|
23055
23288
|
}
|
|
23056
23289
|
function buildCompSelector(comp) {
|
|
23057
23290
|
return comp.slotId ? `\`[${BF_HOST}="\${__scopeId}"][${BF_AT}="${comp.slotId}"], [${BF_SCOPE2}$="_${comp.slotId}"]\`` : `'[${BF_SCOPE2}^="${comp.name}_"]'`;
|
|
@@ -23260,7 +23493,8 @@ function buildBranchInnerLoopsPlan(args) {
|
|
|
23260
23493
|
const reactiveTexts = inner.bindings.reactiveTexts.map((text) => ({
|
|
23261
23494
|
slotId: text.slotId,
|
|
23262
23495
|
wrappedExpression: wrapBoth(text.expression),
|
|
23263
|
-
insideConditional: !!text.insideConditional
|
|
23496
|
+
insideConditional: !!text.insideConditional,
|
|
23497
|
+
...text.markup && { markup: true }
|
|
23264
23498
|
}));
|
|
23265
23499
|
plan.push({
|
|
23266
23500
|
uidSuffix: `br_${i}`,
|
|
@@ -23426,7 +23660,8 @@ function buildReactiveEffectsPlan(args) {
|
|
|
23426
23660
|
}
|
|
23427
23661
|
const outerTexts = texts.map((text) => ({
|
|
23428
23662
|
slotId: text.slotId,
|
|
23429
|
-
wrappedExpression: wrap(text.expression)
|
|
23663
|
+
wrappedExpression: wrap(text.expression),
|
|
23664
|
+
...text.markup && { markup: true }
|
|
23430
23665
|
}));
|
|
23431
23666
|
const conditionalPlans = [];
|
|
23432
23667
|
if (conditionals) {
|
|
@@ -23594,8 +23829,8 @@ function analyzeLazyPreamble(preamble, primableNames) {
|
|
|
23594
23829
|
return NO2(`map-callback preamble shadows the signal/memo getter '${name}'`);
|
|
23595
23830
|
}
|
|
23596
23831
|
}
|
|
23597
|
-
const
|
|
23598
|
-
const freeNames = new Set(
|
|
23832
|
+
const readNames2 = extractFreeIdentifiersFromStatementText(text);
|
|
23833
|
+
const freeNames = new Set(readNames2);
|
|
23599
23834
|
for (const declared of declaredNames)
|
|
23600
23835
|
freeNames.delete(declared);
|
|
23601
23836
|
return { lazySafe: true, facts: { declaredNames, freeNames } };
|
|
@@ -23988,7 +24223,8 @@ function decideLazyRow(args) {
|
|
|
23988
24223
|
ordinal: ordinal++,
|
|
23989
24224
|
readsItem: c.readsItem || !c.readsOuter,
|
|
23990
24225
|
readsOuter: c.readsOuter,
|
|
23991
|
-
readsPreamble: c.readsPreamble
|
|
24226
|
+
readsPreamble: c.readsPreamble,
|
|
24227
|
+
...text.markup && { markup: true }
|
|
23992
24228
|
};
|
|
23993
24229
|
});
|
|
23994
24230
|
const outerPrimeGetters = [];
|
|
@@ -24114,79 +24350,6 @@ function buildPlainRowCore(inputs) {
|
|
|
24114
24350
|
};
|
|
24115
24351
|
}
|
|
24116
24352
|
|
|
24117
|
-
// src/ir-to-client-js/control-flow/plan/build-component-loop.ts
|
|
24118
|
-
function collectTextOnlySlotIds(nodes, into) {
|
|
24119
|
-
for (const node of nodes) {
|
|
24120
|
-
if (node.type === "expression") {
|
|
24121
|
-
if (node.slotId)
|
|
24122
|
-
into.add(node.slotId);
|
|
24123
|
-
} else if (node.type === "conditional" && isTextOnlyConditional(node)) {
|
|
24124
|
-
collectTextOnlySlotIds([node.whenTrue, node.whenFalse], into);
|
|
24125
|
-
}
|
|
24126
|
-
}
|
|
24127
|
-
}
|
|
24128
|
-
function buildComponentLoopPlan(elem, profileComponentName) {
|
|
24129
|
-
const { name } = elem.childComponent;
|
|
24130
|
-
const propsExpr = buildComponentPropsExpr2(elem.childComponent, elem.param, elem.paramBindings, elem.index);
|
|
24131
|
-
const keyExpr = wrapLoopParamAsAccessor(elem.key || "__idx", elem.param, elem.paramBindings, elem.index);
|
|
24132
|
-
const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
|
|
24133
|
-
const mapPreambleWrapped = elem.preamble ? renderPreamble(elem.preamble, {
|
|
24134
|
-
transformJs: (text) => wrapLoopParamAsAccessor(text, elem.param, elem.paramBindings, elem.index),
|
|
24135
|
-
renderLeaf: () => {
|
|
24136
|
-
internalInvariant(false, "component-root loop received a JSX-bearing preamble — Phase 1 should have refused it");
|
|
24137
|
-
}
|
|
24138
|
-
}) : "";
|
|
24139
|
-
const outerNestedComps = (elem.nestedComponents ?? []).filter((c) => !c.loopDepth);
|
|
24140
|
-
const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings, elem.index);
|
|
24141
|
-
const nestedChildrenTextEffectSlotIds = new Set;
|
|
24142
|
-
const nestedComps = outerNestedComps.map((comp) => {
|
|
24143
|
-
const isTextOnly = comp.children?.length ? comp.children.every((c) => c.type === "expression" || c.type === "text" || isTextOnlyConditional(c)) : false;
|
|
24144
|
-
const rawChildrenExpr = isTextOnly ? irChildrenToJsExpr(comp.children) : null;
|
|
24145
|
-
const childrenFreeIds = isTextOnly && comp.children ? irChildrenFreeIds(comp.children) : undefined;
|
|
24146
|
-
const childrenRefsLoop = rawChildrenExpr != null && childrenFreeIds != null && (childrenFreeIds.has(elem.param) || !!elem.index && childrenFreeIds.has(elem.index));
|
|
24147
|
-
if (childrenRefsLoop && comp.children) {
|
|
24148
|
-
collectTextOnlySlotIds(comp.children, nestedChildrenTextEffectSlotIds);
|
|
24149
|
-
}
|
|
24150
|
-
return {
|
|
24151
|
-
componentName: comp.name,
|
|
24152
|
-
selector: buildCompSelector(comp),
|
|
24153
|
-
propsExpr: buildComponentPropsExpr2(comp, elem.param, elem.paramBindings, elem.index),
|
|
24154
|
-
childrenTextEffect: childrenRefsLoop ? buildChildrenTextEffect(comp.children, rawChildrenExpr, wrap) : null
|
|
24155
|
-
};
|
|
24156
|
-
});
|
|
24157
|
-
const rowReactiveTexts = nestedChildrenTextEffectSlotIds.size > 0 ? elem.bindings.reactiveTexts.filter((t) => !nestedChildrenTextEffectSlotIds.has(t.slotId)) : elem.bindings.reactiveTexts;
|
|
24158
|
-
const hasReactiveEffects = hasReactiveLoopBindings({ ...elem.bindings, reactiveTexts: rowReactiveTexts });
|
|
24159
|
-
const rowEvents = elem.bindings.events.filter((ev) => ev.nestedLoops.length === 0).map((ev) => buildRowEventBinding(ev, elem.param, elem.paramBindings, elem.index));
|
|
24160
|
-
return {
|
|
24161
|
-
kind: "component",
|
|
24162
|
-
rowConstruction: "dom-ops",
|
|
24163
|
-
mapPreambleWrapped,
|
|
24164
|
-
containerVar: `_${varSlotId(elem.slotId)}`,
|
|
24165
|
-
markerId: elem.markerId,
|
|
24166
|
-
arrayExpr: buildChainedArrayExpr(elem),
|
|
24167
|
-
keyFn: loopKeyFn(elem),
|
|
24168
|
-
paramHead,
|
|
24169
|
-
paramUnwrap,
|
|
24170
|
-
indexParam: elem.index || "__idx",
|
|
24171
|
-
componentName: name,
|
|
24172
|
-
componentPropsExpr: propsExpr,
|
|
24173
|
-
keyExpr,
|
|
24174
|
-
nestedComps,
|
|
24175
|
-
rowEvents,
|
|
24176
|
-
childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
|
|
24177
|
-
profileLoopId: profileComponentName ? `${profileComponentName}#binding:${elem.slotId}` : undefined,
|
|
24178
|
-
reactiveEffects: hasReactiveEffects ? buildReactiveEffectsPlan({
|
|
24179
|
-
attrs: elem.bindings.reactiveAttrs,
|
|
24180
|
-
texts: rowReactiveTexts,
|
|
24181
|
-
conditionals: elem.bindings.conditionals,
|
|
24182
|
-
loopParam: elem.param,
|
|
24183
|
-
loopParamBindings: elem.paramBindings,
|
|
24184
|
-
loopIndex: elem.index,
|
|
24185
|
-
profileComponentName
|
|
24186
|
-
}) : null
|
|
24187
|
-
};
|
|
24188
|
-
}
|
|
24189
|
-
|
|
24190
24353
|
// src/ir-to-client-js/control-flow/plan/build-inner-loop.ts
|
|
24191
24354
|
function wrapAttrValueExpression2(value, wrap) {
|
|
24192
24355
|
switch (value.kind) {
|
|
@@ -24233,7 +24396,12 @@ function buildInnerLoopsPlan(args) {
|
|
|
24233
24396
|
const uidSuffix = `${inner.depth}_${i}`;
|
|
24234
24397
|
const containerExpr = inner.containerSlotId ? `${rowHasPortal ? "qsaItem" : "qsa"}(${parentElVar}, '[bf="${inner.containerSlotId}"]')` : parentElVar;
|
|
24235
24398
|
const emit = buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex);
|
|
24236
|
-
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
|
+
}));
|
|
24237
24405
|
const childLevelsPlan = childLevels.length > 0 ? buildInnerLoopsPlan({
|
|
24238
24406
|
levels: childLevels,
|
|
24239
24407
|
parentElVar: `__innerEl${uidSuffix}`,
|
|
@@ -24293,13 +24461,15 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
|
|
|
24293
24461
|
children: comp.children?.map(wrapIRNode)
|
|
24294
24462
|
}));
|
|
24295
24463
|
const events = level.events.map((ev) => ({
|
|
24296
|
-
|
|
24297
|
-
|
|
24464
|
+
childSlotId: ev.childSlotId,
|
|
24465
|
+
eventName: ev.eventName,
|
|
24466
|
+
handler: wrapBoth(ev.handler)
|
|
24298
24467
|
}));
|
|
24299
24468
|
const reactiveTexts = inner.bindings.reactiveTexts.map((text) => ({
|
|
24300
24469
|
slotId: text.slotId,
|
|
24301
24470
|
wrappedExpression: wrapLoopParamAsAccessor(wrapOuterRow(text.expression), inner.param, inner.paramBindings, inner.index),
|
|
24302
|
-
insideConditional: !!text.insideConditional
|
|
24471
|
+
insideConditional: !!text.insideConditional,
|
|
24472
|
+
...text.markup && { markup: true }
|
|
24303
24473
|
}));
|
|
24304
24474
|
const reactiveAttrs = inner.bindings.reactiveAttrs.map((attr) => {
|
|
24305
24475
|
const wrapped = wrapLoopParamAsAccessor(wrapOuterRow(attr.expression), inner.param, inner.paramBindings, inner.index);
|
|
@@ -24351,6 +24521,114 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
|
|
|
24351
24521
|
childRefs
|
|
24352
24522
|
};
|
|
24353
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
|
+
}
|
|
24354
24632
|
|
|
24355
24633
|
// src/ir-to-client-js/control-flow/plan/build-composite-loop.ts
|
|
24356
24634
|
function buildTopLevelCompositePlan(elem, profileComponentName) {
|
|
@@ -24842,7 +25120,12 @@ function buildSingleCompPlan(elem, childComponent) {
|
|
|
24842
25120
|
indexParam: elem.index || "__idx",
|
|
24843
25121
|
outerPreludeStatements: staticPreludeStatements(elem.preamble),
|
|
24844
25122
|
propsExpr: buildStaticPropsExpr(props),
|
|
24845
|
-
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
|
+
})
|
|
24846
25129
|
};
|
|
24847
25130
|
}
|
|
24848
25131
|
function buildOuterNestedPlan(elem, comp) {
|
|
@@ -24945,6 +25228,12 @@ function buildStaticPropsExpr(props) {
|
|
|
24945
25228
|
import ts28 from "typescript";
|
|
24946
25229
|
|
|
24947
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
|
+
}
|
|
24948
25237
|
function slotSpecLiteral(slot) {
|
|
24949
25238
|
const pathSrc = slot.pathExpr ?? `[${slot.path.join(", ")}]`;
|
|
24950
25239
|
const markerlessSrc = slot.markerless ? ", markerless: true" : "";
|
|
@@ -25294,7 +25583,7 @@ function emitReactivePropBindings(lines, ctx) {
|
|
|
25294
25583
|
const ref = slotId === ctx.commentScopeRootSlotId ? "__scope" : `_${varSlotId(slotId)}`;
|
|
25295
25584
|
lines.push(` if (${ref}) {`);
|
|
25296
25585
|
for (const prop of props) {
|
|
25297
|
-
const value =
|
|
25586
|
+
const value = prop.expression;
|
|
25298
25587
|
if (prop.propName === "selected") {
|
|
25299
25588
|
if (prop.componentName === "TabsContent") {
|
|
25300
25589
|
lines.push(` ${ref}.setAttribute('data-state', ${value} ? 'active' : 'inactive')`);
|
|
@@ -25431,14 +25720,14 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
|
|
|
25431
25720
|
const plainTexts = inner.reactiveTexts.filter((t) => !t.insideConditional);
|
|
25432
25721
|
for (const text of conditionalTexts) {
|
|
25433
25722
|
const bf = profileBindingId(pc, text.slotId);
|
|
25434
|
-
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})`);
|
|
25435
25724
|
}
|
|
25436
25725
|
if (plainTexts.length > 0) {
|
|
25437
|
-
const slots = plainTexts.map((t) => ({ id: t.slotId, kind:
|
|
25726
|
+
const slots = plainTexts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
25438
25727
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
25439
25728
|
lines.push(`${indent} const ${writer} = lazySlots(__bel${uid}, ${claimPlanLiteral(slots)})`);
|
|
25440
25729
|
for (const text of plainTexts) {
|
|
25441
|
-
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}',
|
|
25730
|
+
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) }${profileBindingId(pc, text.slotId)})`);
|
|
25442
25731
|
}
|
|
25443
25732
|
}
|
|
25444
25733
|
if (inner.nestedConditionals.length > 0) {
|
|
@@ -25568,7 +25857,7 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
|
|
|
25568
25857
|
if (attrSlots.length > 0)
|
|
25569
25858
|
lines.push(`${indent}${DEDUP_STORE_DECL}`);
|
|
25570
25859
|
const claimSlots = [
|
|
25571
|
-
...outerTexts.map((t) => ({ id: t.slotId, kind:
|
|
25860
|
+
...outerTexts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [], pathExpr: textClaimPathExprs?.get(t.slotId) })),
|
|
25572
25861
|
...preambleRegions.map((r) => ({ id: r.slotId, kind: "markup", path: [] }))
|
|
25573
25862
|
];
|
|
25574
25863
|
const writer = claimSlots.length > 0 ? claimWriterVarName(claimSlots, varSlotId) : null;
|
|
@@ -25577,7 +25866,7 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
|
|
|
25577
25866
|
}
|
|
25578
25867
|
if (attrSlots.length === 0 && preambleRegions.length === 0 && outerTexts.length === 1) {
|
|
25579
25868
|
const text = outerTexts[0];
|
|
25580
|
-
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}',
|
|
25869
|
+
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) })`);
|
|
25581
25870
|
return;
|
|
25582
25871
|
}
|
|
25583
25872
|
lines.push(`${indent}createEffect(() => {`);
|
|
@@ -25596,7 +25885,7 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
|
|
|
25596
25885
|
lines.push(`${indent} }`);
|
|
25597
25886
|
}
|
|
25598
25887
|
for (const text of outerTexts) {
|
|
25599
|
-
lines.push(`${indent} ${writer}('${text.slotId}',
|
|
25888
|
+
lines.push(`${indent} ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")})`);
|
|
25600
25889
|
}
|
|
25601
25890
|
for (const region of preambleRegions) {
|
|
25602
25891
|
lines.push(`${indent} ${writer}('${region.slotId}', ${region.valueExpr})`);
|
|
@@ -25608,14 +25897,14 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
|
|
|
25608
25897
|
return;
|
|
25609
25898
|
const slots = texts.map((t) => ({
|
|
25610
25899
|
id: t.slotId,
|
|
25611
|
-
kind:
|
|
25900
|
+
kind: rowTextSlotKind(t),
|
|
25612
25901
|
path: [],
|
|
25613
25902
|
pathExpr: textClaimPathExprs?.get(t.slotId)
|
|
25614
25903
|
}));
|
|
25615
25904
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
25616
25905
|
lines.push(`${indent}const ${writer} = lazySlots(${elVar}, ${claimPlanLiteral(slots)})`);
|
|
25617
25906
|
for (const text of texts) {
|
|
25618
|
-
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}',
|
|
25907
|
+
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) }${bindingBfId(text.slotId)})`);
|
|
25619
25908
|
}
|
|
25620
25909
|
}
|
|
25621
25910
|
function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
|
|
@@ -25669,72 +25958,6 @@ function buildSkeletonPathPlan(skeletonPaths, elVar, opts) {
|
|
|
25669
25958
|
return { arrayElems, elementIndexBySlot, textIndexBySlot };
|
|
25670
25959
|
}
|
|
25671
25960
|
|
|
25672
|
-
// src/ir-to-client-js/control-flow/stringify/component-loop.ts
|
|
25673
|
-
function stringifyComponentLoop(lines, plan) {
|
|
25674
|
-
const {
|
|
25675
|
-
containerVar,
|
|
25676
|
-
markerId,
|
|
25677
|
-
arrayExpr,
|
|
25678
|
-
keyFn,
|
|
25679
|
-
paramHead,
|
|
25680
|
-
paramUnwrap,
|
|
25681
|
-
indexParam,
|
|
25682
|
-
componentName,
|
|
25683
|
-
componentPropsExpr,
|
|
25684
|
-
keyExpr,
|
|
25685
|
-
nestedComps,
|
|
25686
|
-
rowEvents,
|
|
25687
|
-
childRefs,
|
|
25688
|
-
reactiveEffects,
|
|
25689
|
-
profileLoopId,
|
|
25690
|
-
mapPreambleWrapped
|
|
25691
|
-
} = plan;
|
|
25692
|
-
const loopBfId = profileLoopId ? `, ${JSON.stringify(profileLoopId)}` : "";
|
|
25693
|
-
lines.push(` mapArray(() => ${arrayExpr}, ${containerVar}, ${keyFn}, (${paramHead}, ${indexParam}, __existing) => {`);
|
|
25694
|
-
if (paramUnwrap)
|
|
25695
|
-
lines.push(` ${paramUnwrap}`);
|
|
25696
|
-
if (mapPreambleWrapped)
|
|
25697
|
-
lines.push(` ${mapPreambleWrapped}`);
|
|
25698
|
-
const scopedComp = nameForRegistryRef(componentName);
|
|
25699
|
-
if (nestedComps.length === 0 && !reactiveEffects && rowEvents.length === 0 && childRefs.length === 0) {
|
|
25700
|
-
lines.push(` if (__existing) { initChild('${scopedComp}', __existing, ${componentPropsExpr}); return __existing }`);
|
|
25701
|
-
lines.push(` return createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`);
|
|
25702
|
-
lines.push(` }, '${markerId}'${loopBfId})`);
|
|
25703
|
-
return;
|
|
25704
|
-
}
|
|
25705
|
-
lines.push(` if (__existing) {`);
|
|
25706
|
-
lines.push(` initChild('${scopedComp}', __existing, ${componentPropsExpr})`);
|
|
25707
|
-
for (const nc of nestedComps)
|
|
25708
|
-
emitNestedInit(lines, " ", "__existing", nc);
|
|
25709
|
-
for (const ev of rowEvents)
|
|
25710
|
-
emitRowEventListener(lines, " ", "__existing", ev);
|
|
25711
|
-
if (reactiveEffects) {
|
|
25712
|
-
stringifyReactiveEffects(lines, reactiveEffects, { indent: " ", elVar: "__existing" });
|
|
25713
|
-
}
|
|
25714
|
-
emitLoopChildRefs(lines, childRefs, { indent: " ", elVar: "__existing", bodyIsMultiRoot: false, containerVar });
|
|
25715
|
-
lines.push(` return __existing`);
|
|
25716
|
-
lines.push(` }`);
|
|
25717
|
-
lines.push(` const __csrEl = createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`);
|
|
25718
|
-
for (const nc of nestedComps)
|
|
25719
|
-
emitNestedInit(lines, " ", "__csrEl", nc);
|
|
25720
|
-
for (const ev of rowEvents)
|
|
25721
|
-
emitRowEventListener(lines, " ", "__csrEl", ev);
|
|
25722
|
-
if (reactiveEffects) {
|
|
25723
|
-
stringifyReactiveEffects(lines, reactiveEffects, { indent: " ", elVar: "__csrEl" });
|
|
25724
|
-
}
|
|
25725
|
-
emitLoopChildRefs(lines, childRefs, { indent: " ", elVar: "__csrEl", bodyIsMultiRoot: false, containerVar });
|
|
25726
|
-
lines.push(` return __csrEl`);
|
|
25727
|
-
lines.push(` }, '${markerId}'${loopBfId})`);
|
|
25728
|
-
}
|
|
25729
|
-
function emitNestedInit(lines, indent, parentVar, nc) {
|
|
25730
|
-
const scopedNc = nameForRegistryRef(nc.componentName);
|
|
25731
|
-
if (nc.childrenTextEffect) {
|
|
25732
|
-
lines.push(`${indent}{ const __c = qsa(${parentVar}, ${nc.selector}); if (__c) { initChild('${scopedNc}', __c, ${nc.propsExpr}); ${stringifyChildrenTextEffect(nc.childrenTextEffect)} } }`);
|
|
25733
|
-
} else {
|
|
25734
|
-
lines.push(`${indent}{ const __c = qsa(${parentVar}, ${nc.selector}); if (__c) initChild('${scopedNc}', __c, ${nc.propsExpr}) }`);
|
|
25735
|
-
}
|
|
25736
|
-
}
|
|
25737
|
-
|
|
25738
25961
|
// src/ir-to-client-js/control-flow/stringify/inner-loop.ts
|
|
25739
25962
|
function stringifyInnerLoops(lines, plan, indent, pc) {
|
|
25740
25963
|
for (const inner of plan) {
|
|
@@ -25768,9 +25991,11 @@ function emitReactive(lines, inner, indent, pc) {
|
|
|
25768
25991
|
if (emit.wrappedKey) {
|
|
25769
25992
|
lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${emit.wrappedKey}))`);
|
|
25770
25993
|
}
|
|
25771
|
-
if (emit.components.length > 0
|
|
25772
|
-
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);
|
|
25773
25996
|
}
|
|
25997
|
+
for (const ev of emit.events)
|
|
25998
|
+
emitRowEventListener(lines, `${indent} `, `__innerEl${uid}`, ev);
|
|
25774
25999
|
if (inner.childLevels.length > 0) {
|
|
25775
26000
|
stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc);
|
|
25776
26001
|
}
|
|
@@ -25778,14 +26003,14 @@ function emitReactive(lines, inner, indent, pc) {
|
|
|
25778
26003
|
const plainTexts = emit.reactiveTexts.filter((t) => !t.insideConditional);
|
|
25779
26004
|
for (const text of conditionalTexts) {
|
|
25780
26005
|
const bf = profileBindingId(pc, text.slotId);
|
|
25781
|
-
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})`);
|
|
25782
26007
|
}
|
|
25783
26008
|
if (plainTexts.length > 0) {
|
|
25784
|
-
const slots = plainTexts.map((t) => ({ id: t.slotId, kind:
|
|
26009
|
+
const slots = plainTexts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
25785
26010
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
25786
26011
|
lines.push(`${indent} const ${writer} = lazySlots(__innerEl${uid}, ${claimPlanLiteral(slots)})`);
|
|
25787
26012
|
for (const text of plainTexts) {
|
|
25788
|
-
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}',
|
|
26013
|
+
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, "String")}) }${profileBindingId(pc, text.slotId)})`);
|
|
25789
26014
|
}
|
|
25790
26015
|
}
|
|
25791
26016
|
if (emit.reactiveAttrs.length > 0)
|
|
@@ -25812,6 +26037,76 @@ function emitReactive(lines, inner, indent, pc) {
|
|
|
25812
26037
|
lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!emit.wrappedKey, inner.keyDepth)}) }`);
|
|
25813
26038
|
}
|
|
25814
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
|
+
|
|
25815
26110
|
// src/ir-to-client-js/control-flow/stringify/composite-loop.ts
|
|
25816
26111
|
function stringifyCompositeLoop(lines, plan) {
|
|
25817
26112
|
const {
|
|
@@ -25903,13 +26198,13 @@ function stringifyLazyRowLoop(lines, o) {
|
|
|
25903
26198
|
let freshPlanVar = null;
|
|
25904
26199
|
if (lazyRow.texts.length > 0) {
|
|
25905
26200
|
adoptedPlanVar = `__lzs_${mid}`;
|
|
25906
|
-
const adoptedSlots = lazyRow.texts.map((t) => ({ id: t.slotId, kind:
|
|
26201
|
+
const adoptedSlots = lazyRow.texts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
25907
26202
|
lines.push(`${indent}const ${adoptedPlanVar} = ${claimPlanLiteral(adoptedSlots)}`);
|
|
25908
26203
|
if (textPathVar) {
|
|
25909
26204
|
freshPlanVar = `__lzsc_${mid}`;
|
|
25910
26205
|
const freshSlots = lazyRow.texts.map((t, i) => ({
|
|
25911
26206
|
id: t.slotId,
|
|
25912
|
-
kind:
|
|
26207
|
+
kind: rowTextSlotKind(t),
|
|
25913
26208
|
path: [],
|
|
25914
26209
|
pathExpr: `${textPathVar}[${i}]`
|
|
25915
26210
|
}));
|
|
@@ -26066,15 +26361,16 @@ function emitAttrBinding(lines, ind, a, mode) {
|
|
|
26066
26361
|
function emitTextBinding(lines, ind, t, doorExpr, mode, rwDoor) {
|
|
26067
26362
|
lines.push(`${ind}{ const __x = ${t.wrappedExpression}`);
|
|
26068
26363
|
const writeOf = (valueExpr) => rwDoor ? `${doorExpr}.write('${t.slotId}', ${valueExpr})` : `${doorExpr}('${t.slotId}', ${valueExpr})`;
|
|
26364
|
+
const value = rowTextSlotValue(t, "__x", "textOrNode");
|
|
26069
26365
|
if (mode === "outer") {
|
|
26070
26366
|
lines.push(`${ind}if (__seed) {`);
|
|
26071
|
-
lines.push(`${ind} const __s =
|
|
26367
|
+
lines.push(`${ind} const __s = ${value}`);
|
|
26072
26368
|
lines.push(`${ind} if (${doorExpr}.read('${t.slotId}') !== __s) ${writeOf("__s")}`);
|
|
26073
|
-
lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf(
|
|
26369
|
+
lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf(value)}`);
|
|
26074
26370
|
} else if (mode === "item") {
|
|
26075
|
-
lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf(
|
|
26371
|
+
lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf(value)}`);
|
|
26076
26372
|
} else {
|
|
26077
|
-
lines.push(`${ind}${writeOf(
|
|
26373
|
+
lines.push(`${ind}${writeOf(value)}`);
|
|
26078
26374
|
}
|
|
26079
26375
|
lines.push(`${ind}__l[${t.ordinal}] = __x }`);
|
|
26080
26376
|
}
|
|
@@ -26385,11 +26681,11 @@ function stringifyStaticLoop(lines, plan) {
|
|
|
26385
26681
|
lines.push(` }`);
|
|
26386
26682
|
}
|
|
26387
26683
|
if (texts.length > 0) {
|
|
26388
|
-
const slots = texts.map((t) => ({ id: t.slotId, kind:
|
|
26684
|
+
const slots = texts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
26389
26685
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
26390
26686
|
lines.push(` const ${writer} = lazySlots(__iterEl, ${claimPlanLiteral(slots)})`);
|
|
26391
26687
|
for (const text of texts) {
|
|
26392
|
-
lines.push(` createEffect(() => { ${writer}('${text.slotId}',
|
|
26688
|
+
lines.push(` createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.expression, "String")}) }${profileBindingId(pc, text.slotId)})`);
|
|
26393
26689
|
}
|
|
26394
26690
|
}
|
|
26395
26691
|
emitLoopChildRefs(lines, childRefs, { indent: " ", elVar: "__iterEl", bodyIsMultiRoot: rowHasPortal, containerVar });
|
|
@@ -26422,7 +26718,7 @@ function stringifyOne(lines, plan) {
|
|
|
26422
26718
|
}
|
|
26423
26719
|
}
|
|
26424
26720
|
function emitSingleComp(lines, plan) {
|
|
26425
|
-
const { containerVar, componentName, childSelector, arrayExpr, param, indexParam, outerPreludeStatements, propsExpr, rowEvents } = plan;
|
|
26721
|
+
const { containerVar, componentName, childSelector, arrayExpr, param, indexParam, outerPreludeStatements, propsExpr, rowEvents, innerLoops } = plan;
|
|
26426
26722
|
lines.push(` // Initialize static array children (hydrate skips nested instances)`);
|
|
26427
26723
|
lines.push(` if (${containerVar}) {`);
|
|
26428
26724
|
lines.push(` const __childScopes = qsaChildScopes(${containerVar}, ${childSelector})`);
|
|
@@ -26434,6 +26730,7 @@ function emitSingleComp(lines, plan) {
|
|
|
26434
26730
|
lines.push(` initChild('${nameForRegistryRef(componentName)}', childScope, ${propsExpr})`);
|
|
26435
26731
|
for (const ev of rowEvents)
|
|
26436
26732
|
emitRowEventListener(lines, " ", "childScope", ev);
|
|
26733
|
+
stringifyInnerLoops(lines, innerLoops, " ");
|
|
26437
26734
|
lines.push(` })`);
|
|
26438
26735
|
lines.push(` }`);
|
|
26439
26736
|
lines.push("");
|
|
@@ -26516,11 +26813,11 @@ function emitInnerLoopNested(lines, plan) {
|
|
|
26516
26813
|
lines.push(` }`);
|
|
26517
26814
|
}
|
|
26518
26815
|
if (texts.length > 0) {
|
|
26519
|
-
const slots = texts.map((t) => ({ id: t.slotId, kind:
|
|
26816
|
+
const slots = texts.map((t) => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }));
|
|
26520
26817
|
const writer = claimWriterVarName(slots, varSlotId);
|
|
26521
26818
|
lines.push(` const ${writer} = lazySlots(__innerEl, ${claimPlanLiteral(slots)})`);
|
|
26522
26819
|
for (const text of texts) {
|
|
26523
|
-
lines.push(` createEffect(() => { ${writer}('${text.slotId}',
|
|
26820
|
+
lines.push(` createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.expression, "String")}) })`);
|
|
26524
26821
|
}
|
|
26525
26822
|
}
|
|
26526
26823
|
emitLoopChildRefs(lines, refs, { indent: " ", elVar: "__innerEl", bodyIsMultiRoot: false });
|
|
@@ -29873,11 +30170,13 @@ function nullableNumberPropNil(type, optional) {
|
|
|
29873
30170
|
const members = type.kind === "union" ? type.unionTypes ?? [] : [type];
|
|
29874
30171
|
const families = new Set(members.map((m) => m.kind === "primitive" ? m.primitive : m.kind));
|
|
29875
30172
|
const admitsNull = families.has("null");
|
|
29876
|
-
const
|
|
30173
|
+
const admitsAbsent = optional || families.has("undefined");
|
|
29877
30174
|
families.delete("null");
|
|
29878
30175
|
families.delete("undefined");
|
|
29879
|
-
if (!
|
|
30176
|
+
if (!(admitsNull || admitsAbsent) || families.size !== 1 || !families.has("number"))
|
|
29880
30177
|
return null;
|
|
30178
|
+
if (admitsNull && admitsAbsent)
|
|
30179
|
+
return "either";
|
|
29881
30180
|
return admitsNull ? "null" : "undefined";
|
|
29882
30181
|
}
|
|
29883
30182
|
function collectNullableNumberProps(ir) {
|
|
@@ -29886,7 +30185,7 @@ function collectNullableNumberProps(ir) {
|
|
|
29886
30185
|
for (const p of ir.metadata.propsParams) {
|
|
29887
30186
|
if (p.isRest || p.defaultValue !== undefined)
|
|
29888
30187
|
continue;
|
|
29889
|
-
const nil = nullableNumberPropNil(p.type, p.optional);
|
|
30188
|
+
const nil = nullableNumberPropNil(p.declaredType ?? p.type, p.optional);
|
|
29890
30189
|
if (nil !== null)
|
|
29891
30190
|
names.set(objectName ? `${objectName}.${p.sourceName ?? p.name}` : p.name, nil);
|
|
29892
30191
|
}
|
|
@@ -29895,6 +30194,8 @@ function collectNullableNumberProps(ir) {
|
|
|
29895
30194
|
function attrValueMayBeNullish(parsed, ctx, isShadowed = () => false) {
|
|
29896
30195
|
const visiting = new Set;
|
|
29897
30196
|
const walk = (expr, shadowed) => {
|
|
30197
|
+
if (methodMayReturnUndefined(expr))
|
|
30198
|
+
return true;
|
|
29898
30199
|
switch (expr.kind) {
|
|
29899
30200
|
case "identifier":
|
|
29900
30201
|
return expr.name === "undefined";
|
|
@@ -29930,8 +30231,15 @@ function attrValueMayBeNullish(parsed, ctx, isShadowed = () => false) {
|
|
|
29930
30231
|
};
|
|
29931
30232
|
return parsed !== undefined && walk(parsed, isShadowed);
|
|
29932
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
|
+
}
|
|
29933
30240
|
function arithmeticOperandIsNull(parsed, ctx, isShadowed = () => false) {
|
|
29934
|
-
|
|
30241
|
+
const seed = arithmeticOperandSeed(parsed, ctx, isShadowed);
|
|
30242
|
+
return seed === "null" || seed === "either";
|
|
29935
30243
|
}
|
|
29936
30244
|
function arithmeticOperandIsUndefined(parsed, ctx, isShadowed = () => false) {
|
|
29937
30245
|
return arithmeticOperandSeed(parsed, ctx, isShadowed) === "undefined";
|
|
@@ -29945,7 +30253,7 @@ function arithmeticOperandSeed(parsed, ctx, isShadowed) {
|
|
|
29945
30253
|
return "undefined";
|
|
29946
30254
|
const prop = nullableNumberPropRead(expr, ctx, shadowed);
|
|
29947
30255
|
if (prop !== null)
|
|
29948
|
-
return prop === "undefined" ? "absent" :
|
|
30256
|
+
return prop === "undefined" ? "absent" : prop;
|
|
29949
30257
|
const getter = expr.kind === "identifier" ? expr.name : bareGetterCallName(expr);
|
|
29950
30258
|
if (getter === null || shadowed(getter))
|
|
29951
30259
|
return null;
|
|
@@ -29975,11 +30283,71 @@ function nullableNumberPropRead(expr, ctx, shadowed) {
|
|
|
29975
30283
|
}
|
|
29976
30284
|
var NULL_COERCING_ARITHMETIC_OPS = new Set(["-", "*", "/", "%", "**"]);
|
|
29977
30285
|
function arithmeticOperandCoercion(op, operand, other, ctx, isShadowed = () => false) {
|
|
29978
|
-
|
|
29979
|
-
if (!numeric)
|
|
30286
|
+
if (!isNumericArithmetic(op, other))
|
|
29980
30287
|
return null;
|
|
29981
30288
|
const seed = arithmeticOperandSeed(operand, ctx, isShadowed);
|
|
29982
|
-
|
|
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);
|
|
29983
30351
|
}
|
|
29984
30352
|
function isNumberLiteral(expr) {
|
|
29985
30353
|
if (expr?.kind === "unary" && expr.op === "-")
|
|
@@ -30090,6 +30458,43 @@ function rootPropReadName(name, scope, aliases) {
|
|
|
30090
30458
|
return name;
|
|
30091
30459
|
return aliases.get(name) ?? name;
|
|
30092
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
|
+
}
|
|
30093
30498
|
|
|
30094
30499
|
// src/adapters/component-tree.ts
|
|
30095
30500
|
function hasClientInteractivity(ir) {
|
|
@@ -30168,6 +30573,9 @@ function computedConstContext(metadata, isShadowed, isAdapterBound = () => false
|
|
|
30168
30573
|
getters: new Set([...metadata.signals.map((s) => s.getter), ...metadata.memos.map((m) => m.name)]),
|
|
30169
30574
|
contextConsumers: new Set(collectContextConsumers(metadata).map((c) => c.localName)),
|
|
30170
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),
|
|
30171
30579
|
isShadowed,
|
|
30172
30580
|
isAdapterBound,
|
|
30173
30581
|
isGlobal: (name) => !bindings.has(name) && name !== metadata.restPropsName && !isShadowed(name)
|
|
@@ -30190,6 +30598,50 @@ function propsBindingNames(metadata) {
|
|
|
30190
30598
|
}
|
|
30191
30599
|
return names;
|
|
30192
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
|
+
}
|
|
30193
30645
|
var MAX_DEPTH = 16;
|
|
30194
30646
|
function inlineComputedConsts(expr, ctx) {
|
|
30195
30647
|
if (!ctx?.constants?.length)
|
|
@@ -30212,10 +30664,88 @@ function inlineOnce(expr, ctx) {
|
|
|
30212
30664
|
const init = inlinableInitializer(name, ctx);
|
|
30213
30665
|
if (!init)
|
|
30214
30666
|
continue;
|
|
30215
|
-
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;
|
|
30216
30710
|
}
|
|
30217
30711
|
return result;
|
|
30218
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
|
+
}
|
|
30219
30749
|
function inlineComputedConstAttr(value, ctx) {
|
|
30220
30750
|
if (!ctx)
|
|
30221
30751
|
return value;
|
|
@@ -30226,7 +30756,7 @@ function inlineComputedConstAttr(value, ctx) {
|
|
|
30226
30756
|
return { ...value, expr: stringifyParsedExpr(inlined), parsed: inlined, templateExpr: undefined, parts: undefined };
|
|
30227
30757
|
}
|
|
30228
30758
|
function inlinableInitializer(name, ctx) {
|
|
30229
|
-
const constant = ctx
|
|
30759
|
+
const constant = componentConst(name, ctx) ?? (ctx.componentNames.has(name) ? undefined : moduleConst(name, ctx));
|
|
30230
30760
|
const init = constant?.parsed;
|
|
30231
30761
|
if (!constant || !init || !isPlainComputedConst(constant, init))
|
|
30232
30762
|
return null;
|
|
@@ -30234,12 +30764,11 @@ function inlinableInitializer(name, ctx) {
|
|
|
30234
30764
|
return null;
|
|
30235
30765
|
if (ctx.isAdapterBound(name))
|
|
30236
30766
|
return null;
|
|
30237
|
-
if (lookupLiteralConst(name,
|
|
30767
|
+
if (lookupLiteralConst(name, [constant], ctx.isShadowed) !== null)
|
|
30238
30768
|
return null;
|
|
30239
|
-
|
|
30240
|
-
if (!free || [...free].some((n) => ctx.isShadowed(n)))
|
|
30769
|
+
if (!callsOnlyGetters(init, ctx.getters))
|
|
30241
30770
|
return null;
|
|
30242
|
-
return
|
|
30771
|
+
return resolveInitializer(init, ctx, (n) => ctx.isShadowed(n), constant.isModule ? "module" : "component");
|
|
30243
30772
|
}
|
|
30244
30773
|
function isPlainComputedConst(constant, init) {
|
|
30245
30774
|
if (constant.mutatedAfterDeclaration)
|
|
@@ -30997,6 +31526,15 @@ class DslTemplateAdapter extends BaseAdapter {
|
|
|
30997
31526
|
this.scope = outer;
|
|
30998
31527
|
}
|
|
30999
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
|
+
}
|
|
31000
31538
|
loopPlanFor(loop, spelling) {
|
|
31001
31539
|
return planLoop(loop, { scope: this.scope, localConstants: this.localConstants ?? [], ...spelling });
|
|
31002
31540
|
}
|
|
@@ -31101,6 +31639,7 @@ ${children}` : children;
|
|
|
31101
31639
|
if (!options?.siblingTemplatesRegistered) {
|
|
31102
31640
|
this.errors.push(...collectImportedLoopChildComponentErrors(ir, this.componentName, this.loopChildDiagnosticName));
|
|
31103
31641
|
}
|
|
31642
|
+
refuseAmbiguousNilMemoArithmetic(ir.metadata.memos ?? [], this.nullishAttrCtx, this.ambiguousNilSink());
|
|
31104
31643
|
}
|
|
31105
31644
|
}
|
|
31106
31645
|
// src/adapters/jsx-adapter.ts
|
|
@@ -31212,9 +31751,9 @@ class JsxAdapter extends BaseAdapter {
|
|
|
31212
31751
|
continue;
|
|
31213
31752
|
if (!reachable.has(constant.name))
|
|
31214
31753
|
continue;
|
|
31215
|
-
const
|
|
31754
|
+
const constValue2 = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
|
|
31216
31755
|
const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
|
|
31217
|
-
lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${
|
|
31756
|
+
lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue2}`);
|
|
31218
31757
|
}
|
|
31219
31758
|
for (const func of localFunctions) {
|
|
31220
31759
|
if (moduleScopeNames.has(func.name))
|
|
@@ -31863,6 +32402,106 @@ function emitParsedExpr(expr, emitter) {
|
|
|
31863
32402
|
}
|
|
31864
32403
|
}
|
|
31865
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
|
+
}
|
|
31866
32505
|
// src/adapters/style-object.ts
|
|
31867
32506
|
function staticString(value) {
|
|
31868
32507
|
if (value.kind === "literal" && value.literalType === "string" && typeof value.value === "string")
|
|
@@ -32112,9 +32751,11 @@ function prefixedArrayMethodSpelling(prefix, undefinedLiteral) {
|
|
|
32112
32751
|
}
|
|
32113
32752
|
// src/adapters/component-props.ts
|
|
32114
32753
|
import { resolveJsxChildrenProp } from "@barefootjs/shared";
|
|
32115
|
-
function propsSpreadParam(param, earlier) {
|
|
32754
|
+
function propsSpreadParam(param, earlier, callerKeys = false) {
|
|
32116
32755
|
if (param.optional === false)
|
|
32117
32756
|
return "entry";
|
|
32757
|
+
if (callerKeys)
|
|
32758
|
+
return "present";
|
|
32118
32759
|
return earlier.spread || earlier.keys.has(param.name) ? "present" : "entry";
|
|
32119
32760
|
}
|
|
32120
32761
|
function componentPropKey(entry) {
|
|
@@ -32143,7 +32784,7 @@ function planComponentProps(comp, options) {
|
|
|
32143
32784
|
const pushPropsSpread = () => {
|
|
32144
32785
|
const before = { keys: new Set(earlier.keys), spread: earlier.spread };
|
|
32145
32786
|
for (const param of options.propsParams) {
|
|
32146
|
-
if (propsSpreadParam(param, before) === "entry") {
|
|
32787
|
+
if (propsSpreadParam(param, before, options.callerKeys) === "entry") {
|
|
32147
32788
|
push({ kind: "props-param", name: param.name });
|
|
32148
32789
|
} else {
|
|
32149
32790
|
earlier.keys.add(param.name);
|
|
@@ -32247,9 +32888,11 @@ function nullableBareRead(value, ctx) {
|
|
|
32247
32888
|
const bare = value.expr.trim();
|
|
32248
32889
|
const restKey = ctx.restPropsName !== null && bare.startsWith(`${ctx.restPropsName}.`);
|
|
32249
32890
|
let normalized = bare;
|
|
32250
|
-
if (ctx.propsObjectName && bare.startsWith(`${ctx.propsObjectName}.`))
|
|
32891
|
+
if (ctx.propsObjectName && bare.startsWith(`${ctx.propsObjectName}.`)) {
|
|
32892
|
+
if (ctx.isLoopBound(ctx.propsObjectName))
|
|
32893
|
+
return null;
|
|
32251
32894
|
normalized = bare.slice(ctx.propsObjectName.length + 1);
|
|
32252
|
-
else if (restKey)
|
|
32895
|
+
} else if (restKey)
|
|
32253
32896
|
normalized = bare.slice(ctx.restPropsName.length + 1);
|
|
32254
32897
|
const prop = IDENTIFIER.test(normalized) && ctx.nullableOptionalProps.has(normalized) && !ctx.isLoopBound(normalized);
|
|
32255
32898
|
const signal = nullableSignalAttrGetter(value.parsed, ctx.nullableSignalGetters);
|
|
@@ -35593,6 +36236,8 @@ export {
|
|
|
35593
36236
|
renameFreeIdentifiers,
|
|
35594
36237
|
registerLoweringPlugin,
|
|
35595
36238
|
registerBuiltinLoweringPlugins,
|
|
36239
|
+
refuseAmbiguousNilMemoArithmetic,
|
|
36240
|
+
refuseAmbiguousNilArithmetic,
|
|
35596
36241
|
queryHrefPlugin,
|
|
35597
36242
|
queryHrefLocalNames,
|
|
35598
36243
|
queryHrefArgs,
|
|
@@ -35614,11 +36259,13 @@ export {
|
|
|
35614
36259
|
parseExpression,
|
|
35615
36260
|
parseBlockBodyTolerant,
|
|
35616
36261
|
parseBlockBody,
|
|
36262
|
+
numberValuedSeedNames,
|
|
35617
36263
|
nullishChainParts,
|
|
35618
36264
|
nullableSignalAttrGetter,
|
|
35619
36265
|
nestedCallbackRefusal,
|
|
35620
36266
|
needsTypeBasedDetection,
|
|
35621
36267
|
missingFilterPredicateRefusal,
|
|
36268
|
+
mayYieldBooleanCarrier,
|
|
35622
36269
|
materializeGetterCalls,
|
|
35623
36270
|
matchSearchParamsMethodCall,
|
|
35624
36271
|
matchQueryHrefCall,
|
|
@@ -35644,9 +36291,11 @@ export {
|
|
|
35644
36291
|
isStringTypedOperand,
|
|
35645
36292
|
isStringTypeInfo,
|
|
35646
36293
|
isStringConcatBinary,
|
|
36294
|
+
isRootPropsObject,
|
|
35647
36295
|
isPredicateMethod,
|
|
35648
36296
|
isOpaqueLocalAccessorName,
|
|
35649
36297
|
isNumericArithmeticResult,
|
|
36298
|
+
isNumberValuedExpr,
|
|
35650
36299
|
isNullishLiteral,
|
|
35651
36300
|
isNullableSignal,
|
|
35652
36301
|
isLowerableObjectRestDestructure,
|
|
@@ -35674,6 +36323,7 @@ export {
|
|
|
35674
36323
|
identifierPath,
|
|
35675
36324
|
hasUnsafeStyleValue,
|
|
35676
36325
|
hasOpaqueCall,
|
|
36326
|
+
hasComputedDefault,
|
|
35677
36327
|
hasClientInteractivity,
|
|
35678
36328
|
groupUnaryOperand,
|
|
35679
36329
|
groupObjectLiteralSegments,
|
|
@@ -35750,6 +36400,7 @@ export {
|
|
|
35750
36400
|
compileJSX,
|
|
35751
36401
|
combineParentChildClientJs,
|
|
35752
36402
|
collectValueReferencedNames,
|
|
36403
|
+
collectNumberValueNames,
|
|
35753
36404
|
collectNullishAttrContext,
|
|
35754
36405
|
collectNullableSignalGetters,
|
|
35755
36406
|
collectNullableOptionalProps,
|
|
@@ -35759,6 +36410,7 @@ export {
|
|
|
35759
36410
|
collectContextConsumers,
|
|
35760
36411
|
collectBooleanValueNames,
|
|
35761
36412
|
collectBooleanTypedProps,
|
|
36413
|
+
collectBooleanCarrierNames,
|
|
35762
36414
|
collectAliasableGetterNames,
|
|
35763
36415
|
collectAbsentPropSeedReads,
|
|
35764
36416
|
childTemplateName,
|
|
@@ -35784,16 +36436,19 @@ export {
|
|
|
35784
36436
|
augmentInheritedPropAccesses,
|
|
35785
36437
|
attrValueMayBeNullish,
|
|
35786
36438
|
asCallbackMethodCall,
|
|
36439
|
+
arithmeticOperandNilIsAmbiguous,
|
|
35787
36440
|
arithmeticOperandIsUndefined,
|
|
35788
36441
|
arithmeticOperandIsNull,
|
|
35789
36442
|
arithmeticOperandCoercion,
|
|
35790
36443
|
arithmeticHelper,
|
|
36444
|
+
arithmeticCoercionOrRefuse,
|
|
35791
36445
|
applyCssLayerPrefix,
|
|
35792
36446
|
analyzeWastedReReruns,
|
|
35793
36447
|
analyzeHotSubscribers,
|
|
35794
36448
|
analyzeComponent,
|
|
35795
36449
|
analyzeClientNeeds,
|
|
35796
36450
|
analyzeBatchAdvisor,
|
|
36451
|
+
ambiguousNilArithmeticOperands,
|
|
35797
36452
|
__resetLoweringPluginsForTest,
|
|
35798
36453
|
USE_CLIENT_DIRECTIVE,
|
|
35799
36454
|
TestAdapter,
|