@barefootjs/jsx 0.39.9 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts +41 -0
- package/dist/adapters/ambiguous-nil-arithmetic.d.ts.map +1 -0
- package/dist/adapters/attr-plan.d.ts +1 -20
- package/dist/adapters/attr-plan.d.ts.map +1 -1
- package/dist/adapters/boolean-carrier.d.ts +31 -0
- package/dist/adapters/boolean-carrier.d.ts.map +1 -0
- package/dist/adapters/component-props.d.ts +22 -7
- package/dist/adapters/component-props.d.ts.map +1 -1
- package/dist/adapters/computed-const.d.ts +17 -0
- package/dist/adapters/computed-const.d.ts.map +1 -1
- package/dist/adapters/dsl-template-adapter.d.ts +95 -2
- package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
- package/dist/adapters/loop-plan.d.ts +41 -1
- package/dist/adapters/loop-plan.d.ts.map +1 -1
- package/dist/adapters/number-value.d.ts +43 -0
- package/dist/adapters/number-value.d.ts.map +1 -0
- package/dist/analyzer-context.d.ts +7 -0
- package/dist/analyzer-context.d.ts.map +1 -1
- package/dist/analyzer.d.ts +34 -0
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/augment-inherited-props.d.ts.map +1 -1
- package/dist/css-layer-prefixer.d.ts.map +1 -1
- package/dist/debug.d.ts.map +1 -1
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2102 -1344
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-component-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts +29 -0
- package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts +2 -0
- package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts +5 -4
- package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts +2 -0
- package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +15 -0
- package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts +2 -0
- package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts +20 -0
- package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts +3 -2
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/build-static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +7 -1
- package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
- package/dist/ir-to-client-js/safe-html.d.ts +9 -3
- package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
- package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +30 -0
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +9 -1
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/module-exports.d.ts.map +1 -1
- package/dist/nullable-signal-attr.d.ts +29 -3
- package/dist/nullable-signal-attr.d.ts.map +1 -1
- package/dist/props-binding.d.ts +27 -3
- package/dist/props-binding.d.ts.map +1 -1
- package/dist/scope/binding-scope.d.ts +24 -1
- package/dist/scope/binding-scope.d.ts.map +1 -1
- package/dist/scope/root-prop-alias.d.ts +14 -1
- package/dist/scope/root-prop-alias.d.ts.map +1 -1
- package/dist/signal-prop-name-collision.d.ts.map +1 -1
- package/dist/ssr-defaults.d.ts +4 -2
- package/dist/ssr-defaults.d.ts.map +1 -1
- package/dist/ssr-seed-plan.d.ts +14 -0
- package/dist/ssr-seed-plan.d.ts.map +1 -1
- package/dist/template-parts.d.ts +1 -1
- package/dist/template-parts.d.ts.map +1 -1
- package/dist/types.d.ts +35 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/attr-plan.test.ts +1 -14
- package/src/__tests__/binding-scope-ratchet.test.ts +12 -2
- package/src/__tests__/boolean-carrier.test.ts +74 -0
- package/src/__tests__/client-template-escape-soundness.test.ts +17 -4
- package/src/__tests__/client-template-static-delimiters.test.ts +57 -0
- package/src/__tests__/component-props.test.ts +14 -0
- package/src/__tests__/computed-const.test.ts +85 -0
- package/src/__tests__/dsl-template-adapter.test.ts +70 -0
- package/src/__tests__/expression-parser.test.ts +24 -0
- package/src/__tests__/extract-function-params.test.ts +37 -0
- package/src/__tests__/issue-2960-multi-root-cond-same-tag.test.ts +18 -0
- package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +142 -0
- package/src/__tests__/jsx-text-linebreak-whitespace.test.ts +11 -0
- package/src/__tests__/loop-plan.test.ts +66 -1
- package/src/__tests__/loop-row-prop-read.test.ts +111 -0
- package/src/__tests__/memo-body-expr.test.ts +137 -0
- package/src/__tests__/nullable-signal-attr.test.ts +97 -2
- package/src/__tests__/profile-binding-ids.test.ts +14 -0
- package/src/__tests__/root-prop-alias.test.ts +34 -1
- package/src/__tests__/signal-prop-name-collision.test.ts +102 -2
- package/src/__tests__/source-file-cache.test.ts +105 -0
- package/src/__tests__/ssr-seed-plan.test.ts +43 -0
- package/src/__tests__/template-parts-literal-boundary.test.ts +41 -0
- package/src/adapters/ambiguous-nil-arithmetic.ts +94 -0
- package/src/adapters/attr-plan.ts +8 -56
- package/src/adapters/boolean-carrier.ts +76 -0
- package/src/adapters/component-props.ts +28 -8
- package/src/adapters/computed-const.ts +206 -7
- package/src/adapters/dsl-template-adapter.ts +183 -2
- package/src/adapters/loop-plan.ts +67 -2
- package/src/adapters/number-value.ts +95 -0
- package/src/analyzer-context.ts +8 -0
- package/src/analyzer.ts +187 -66
- package/src/augment-inherited-props.ts +5 -9
- package/src/css-layer-prefixer.ts +4 -5
- package/src/debug.ts +1 -0
- package/src/expression-parser.ts +4 -1
- package/src/index.ts +23 -5
- package/src/ir-to-client-js/collect-elements.ts +104 -46
- package/src/ir-to-client-js/compute-inlinability.ts +2 -2
- package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +15 -1
- package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +79 -4
- package/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts +3 -0
- package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +1 -0
- package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +1 -0
- package/src/ir-to-client-js/control-flow/plan/inner-loop.ts +5 -4
- package/src/ir-to-client-js/control-flow/plan/loop-child-arm.ts +2 -0
- package/src/ir-to-client-js/control-flow/plan/loop.ts +12 -0
- package/src/ir-to-client-js/control-flow/plan/reactive-effects.ts +2 -0
- package/src/ir-to-client-js/control-flow/shared.ts +3 -2
- package/src/ir-to-client-js/control-flow/stringify/claim-plan.ts +27 -0
- package/src/ir-to-client-js/control-flow/stringify/component-loop.ts +8 -2
- package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +8 -1
- package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +8 -7
- package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +8 -7
- package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +4 -4
- package/src/ir-to-client-js/control-flow/stringify/loop.ts +3 -3
- package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +6 -6
- package/src/ir-to-client-js/emit-reactive.ts +1 -1
- package/src/ir-to-client-js/html-template.ts +122 -75
- package/src/ir-to-client-js/plan/build-static-array-child-init.ts +11 -1
- package/src/ir-to-client-js/plan/static-array-child-init.ts +7 -1
- package/src/ir-to-client-js/reactivity.ts +14 -0
- package/src/ir-to-client-js/safe-html.ts +11 -4
- package/src/ir-to-client-js/stringify/static-array-child-init.ts +6 -4
- package/src/ir-to-client-js/types.ts +23 -0
- package/src/ir-to-client-js/utils.ts +16 -2
- package/src/jsx-to-ir.ts +112 -55
- package/src/loop-destructure.ts +4 -1
- package/src/module-exports.ts +13 -21
- package/src/nullable-signal-attr.ts +134 -13
- package/src/props-binding.ts +54 -3
- package/src/rich-type-refusal.ts +3 -1
- package/src/scope/binding-scope.ts +35 -2
- package/src/scope/root-prop-alias.ts +17 -1
- package/src/signal-prop-name-collision.ts +113 -22
- package/src/ssr-defaults.ts +10 -4
- package/src/ssr-seed-plan.ts +82 -17
- package/src/template-parts.ts +25 -3
- package/src/template-position-walk.ts +3 -1
- package/src/types.ts +32 -1
package/src/index.ts
CHANGED
|
@@ -39,7 +39,7 @@ export { resolveGetterAliases, collectAliasableGetterNames } from './ir-to-clien
|
|
|
39
39
|
export { buildImportAliasMap } from './ir-to-client-js/component-scope.ts'
|
|
40
40
|
|
|
41
41
|
// Backend-neutral SSR seed plan (in-template derived signal/memo seeding)
|
|
42
|
-
export { computeSsrSeedPlan, inDefaultReadOrder } from './ssr-seed-plan.ts'
|
|
42
|
+
export { computeSsrSeedPlan, hasComputedDefault, inDefaultReadOrder } from './ssr-seed-plan.ts'
|
|
43
43
|
export type { SsrSeedPlan, SsrSeedStep } from './ssr-seed-plan.ts'
|
|
44
44
|
|
|
45
45
|
// Pure IR types
|
|
@@ -108,7 +108,13 @@ export { generateModuleExports, extractFunctionParams, formatParamWithType, find
|
|
|
108
108
|
// Adapters
|
|
109
109
|
export { BaseAdapter } from './adapters/interface.ts'
|
|
110
110
|
export { DslTemplateAdapter } from './adapters/dsl-template-adapter.ts'
|
|
111
|
-
export type {
|
|
111
|
+
export type {
|
|
112
|
+
LoopPlanSpelling,
|
|
113
|
+
LoopRefusalSpelling,
|
|
114
|
+
LoopRow,
|
|
115
|
+
LoopRowSpelling,
|
|
116
|
+
TemplateIdentifierSpelling,
|
|
117
|
+
} from './adapters/dsl-template-adapter.ts'
|
|
112
118
|
// Dependency-free adapter for tooling that only needs client JS (e.g. the
|
|
113
119
|
// profiler scenario driver) — the client output is adapter-independent.
|
|
114
120
|
export { TestAdapter, testAdapter } from './adapters/test-adapter.ts'
|
|
@@ -125,11 +131,19 @@ export { JsxAdapter } from './adapters/jsx-adapter.ts'
|
|
|
125
131
|
export type { JsxAdapterConfig } from './adapters/jsx-adapter.ts'
|
|
126
132
|
export { rewriteImportsForTemplate, rewriteDynamicImportsInSource } from './adapters/template-imports.ts'
|
|
127
133
|
export { emitParsedExpr, arithmeticHelper, groupBinaryOperand, groupUnaryOperand, groupObjectLiteralSegments, isStringTypedOperand, isStringConcatBinary, isNumericArithmeticResult } from './adapters/parsed-expr-emitter.ts'
|
|
134
|
+
export { collectNumberValueNames, isNumberValuedExpr, numberValuedSeedNames } from './adapters/number-value.ts'
|
|
135
|
+
export { collectBooleanCarrierNames, mayYieldBooleanCarrier } from './adapters/boolean-carrier.ts'
|
|
128
136
|
export type { ArithmeticHelper, ParsedExprEmitter, LoweringEmitter, HigherOrderMethod, ArrayMethod, SortMethod, LiteralType } from './adapters/parsed-expr-emitter.ts'
|
|
129
137
|
export { collectLoopBoundNames } from './adapters/loop-bound-names.ts'
|
|
130
138
|
export { planStyleObject, type StyleObjectPlanEntry } from './adapters/style-object.ts'
|
|
131
139
|
export { filterCaptureCollisions } from './adapters/filter-capture-collisions.ts'
|
|
132
140
|
export { templateNameCollisionErrors } from './adapters/template-name-collisions.ts'
|
|
141
|
+
export {
|
|
142
|
+
arithmeticCoercionOrRefuse,
|
|
143
|
+
refuseAmbiguousNilArithmetic,
|
|
144
|
+
refuseAmbiguousNilMemoArithmetic,
|
|
145
|
+
type AmbiguousNilArithmeticSink,
|
|
146
|
+
} from './adapters/ambiguous-nil-arithmetic.ts'
|
|
133
147
|
export {
|
|
134
148
|
collectBooleanValueNames,
|
|
135
149
|
isAriaBooleanAttr,
|
|
@@ -183,9 +197,9 @@ export type {
|
|
|
183
197
|
export { derivesScopeFromSlot } from './adapters/child-scope.ts'
|
|
184
198
|
export { childTemplateName, componentPropKey, isEmptyComponentProps, planComponentProps, propsSpreadParam, resolveComponentPropKeys, spellComponentProps } from './adapters/component-props.ts'
|
|
185
199
|
export type { ComponentPropEntry, ComponentPropSegment, ComponentPropSpelling, ComponentPropsOptions, ComponentPropsParam, EarlierComponentProps, ResolvedComponentProp, SpelledComponentPropSegment } from './adapters/component-props.ts'
|
|
186
|
-
export { parseUndefinedAlternateTernary, planAttrExpression, planSpreadAttr,
|
|
200
|
+
export { parseUndefinedAlternateTernary, planAttrExpression, planSpreadAttr, } from './adapters/attr-plan.ts'
|
|
187
201
|
export type { AttrExpressionPlan, AttrPlanContext, SpreadAttrPlan, SpreadPlanContext, UndefinedAlternateTernary } from './adapters/attr-plan.ts'
|
|
188
|
-
export { planLoop, spellDestructureLocals, spellFilteredRow, spellSortedSource } from './adapters/loop-plan.ts'
|
|
202
|
+
export { loopHeaderTargets, planLoop, savedLoopBindings, spellDestructureLocals, spellFilteredRow, spellSortedSource } from './adapters/loop-plan.ts'
|
|
189
203
|
export { computedConstContext, inlineComputedConstAttr, inlineComputedConsts } from './adapters/computed-const.ts'
|
|
190
204
|
export type { ComputedConstContext } from './adapters/computed-const.ts'
|
|
191
205
|
export type {
|
|
@@ -196,13 +210,17 @@ export type {
|
|
|
196
210
|
LoopFilterSpelling,
|
|
197
211
|
LoopPlan,
|
|
198
212
|
LoopPlanContext,
|
|
213
|
+
LoopRowScopes,
|
|
199
214
|
LoopSortSpelling,
|
|
215
|
+
SavedLoopBinding,
|
|
200
216
|
} from './adapters/loop-plan.ts'
|
|
201
217
|
export { evaluateStaticLiteral, isFullyStaticLiteral, resolveStaticLoopSource } from './static-literal.ts'
|
|
202
218
|
export {
|
|
203
219
|
arithmeticOperandIsNull,
|
|
204
220
|
arithmeticOperandIsUndefined,
|
|
205
221
|
arithmeticOperandCoercion,
|
|
222
|
+
arithmeticOperandNilIsAmbiguous,
|
|
223
|
+
ambiguousNilArithmeticOperands,
|
|
206
224
|
bareGetterCallName,
|
|
207
225
|
attrValueMayBeNullish,
|
|
208
226
|
collectAbsentPropSeedReads,
|
|
@@ -344,7 +362,7 @@ export { isLowerableLoopDestructure, isLowerableObjectRestDestructure } from './
|
|
|
344
362
|
// Binding scope (#2482) — shared loop-bound-name resolution service
|
|
345
363
|
export { BindingScope } from './scope/binding-scope.ts'
|
|
346
364
|
export type { ScopeBindingSource, ScopeBinding, ScopeFrame, LoopBindingSource } from './scope/binding-scope.ts'
|
|
347
|
-
export { rootPropAliasNames, rootPropAliasesForLoop, rootPropReadName } from './scope/root-prop-alias.ts'
|
|
365
|
+
export { isRootPropsObject, rootPropAliasNames, rootPropAliasesForLoop, rootPropReadName } from './scope/root-prop-alias.ts'
|
|
348
366
|
|
|
349
367
|
// Debug analysis
|
|
350
368
|
export {
|
|
@@ -445,6 +445,11 @@ export function collectInnerLoops(
|
|
|
445
445
|
childComponents,
|
|
446
446
|
insideConditional: !flat && scope.insideCond ? true : undefined,
|
|
447
447
|
offset: flat ? undefined : resolveLoopOffset(siblingOffsets.get(n)),
|
|
448
|
+
filterPredicate: n.filterPredicate ? { param: n.filterPredicate.param, raw: n.filterPredicate.raw } : undefined,
|
|
449
|
+
sortComparator: n.sortComparator
|
|
450
|
+
? { paramA: n.sortComparator.paramA, paramB: n.sortComparator.paramB, raw: n.sortComparator.raw }
|
|
451
|
+
: undefined,
|
|
452
|
+
chainOrder: n.chainOrder,
|
|
448
453
|
bindings,
|
|
449
454
|
})
|
|
450
455
|
// Branch-mode callers handle deeper nesting via their own collection paths.
|
|
@@ -504,6 +509,18 @@ function decideLoopRendering(
|
|
|
504
509
|
return { useElementReconciliation, innerLoops }
|
|
505
510
|
}
|
|
506
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Whether a top-level loop carries its collected inner loops to the client
|
|
514
|
+
* JS plans: a reconciled (composite) row, a static array's row, and a
|
|
515
|
+
* component-root row (#3694), whose forwarded children's inner loops get
|
|
516
|
+
* their event handlers wired per row (`buildForwardedInnerLoopsPlan`).
|
|
517
|
+
*/
|
|
518
|
+
function keepsInnerLoops(loop: IRLoop, useElementReconciliation: boolean, innerLoops: NestedLoop[] | undefined): boolean {
|
|
519
|
+
if (useElementReconciliation) return true
|
|
520
|
+
if (!innerLoops || innerLoops.length === 0) return false
|
|
521
|
+
return loop.isStaticArray || !!loop.childComponent
|
|
522
|
+
}
|
|
523
|
+
|
|
507
524
|
/** Check whether an array of IR nodes contains any component nodes (recursively). */
|
|
508
525
|
function jsxChildrenContainComponent(nodes: IRNode[]): boolean {
|
|
509
526
|
for (const node of nodes) {
|
|
@@ -517,6 +534,76 @@ function jsxChildrenContainComponent(nodes: IRNode[]): boolean {
|
|
|
517
534
|
return false
|
|
518
535
|
}
|
|
519
536
|
|
|
537
|
+
/**
|
|
538
|
+
* One explicit prop's `initChild` props-object entry: its value expression,
|
|
539
|
+
* and whether it is read through a getter (deferred, so reactive) or is a
|
|
540
|
+
* plain data property.
|
|
541
|
+
*/
|
|
542
|
+
function componentInitPropValue(prop: IRProp, ctx: ClientJsContext): { expr: string; getter: boolean } {
|
|
543
|
+
if (isEventHandlerName(prop.name)) {
|
|
544
|
+
// Event handlers reach here only as `expression` variants.
|
|
545
|
+
return { expr: attrValueToString(prop.value) ?? prop.name, getter: false }
|
|
546
|
+
}
|
|
547
|
+
switch (prop.value.kind) {
|
|
548
|
+
case 'jsx-children':
|
|
549
|
+
if (jsxChildrenContainComponent(prop.value.children)) {
|
|
550
|
+
return { expr: `__slot(() => ${irChildrenToJsExpr(prop.value.children)})`, getter: true }
|
|
551
|
+
}
|
|
552
|
+
// Brand via the shared door (#2651/#2702) — see
|
|
553
|
+
// `jsxChildrenPropGetterExpr`'s docstring.
|
|
554
|
+
return { expr: jsxChildrenPropGetterExpr(prop.value.children, prop.name), getter: true }
|
|
555
|
+
case 'expression':
|
|
556
|
+
case 'template':
|
|
557
|
+
case 'spread':
|
|
558
|
+
return { expr: expandDynamicPropValue(attrValueToString(prop.value)!, ctx), getter: true }
|
|
559
|
+
case 'literal':
|
|
560
|
+
return { expr: JSON.stringify(prop.value.value), getter: false }
|
|
561
|
+
case 'boolean-shorthand':
|
|
562
|
+
case 'boolean-attr':
|
|
563
|
+
// `boolean-attr` should not reach here for component props
|
|
564
|
+
// (processComponentProps promotes it to boolean-shorthand), but handle
|
|
565
|
+
// it defensively.
|
|
566
|
+
return { expr: 'true', getter: false }
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Index of the last spread of the component's own props object in a child
|
|
572
|
+
* component call (`<Tag tone="first" {...props} />`), or -1. An explicit
|
|
573
|
+
* prop written before it is only a default: the spread overrides it when
|
|
574
|
+
* the caller passed that key, as in JS (#3688). This is the one source-order
|
|
575
|
+
* decision `initChild`'s props and both reactive DOM mirrors
|
|
576
|
+
* (`ctx.reactiveProps`, `ctx.reactiveChildProps`) read, so an overridden
|
|
577
|
+
* explicit expression can't overwrite the spread-selected value on update.
|
|
578
|
+
*/
|
|
579
|
+
function lastPropsObjectSpreadIndex(props: IRProp[]): number {
|
|
580
|
+
let at = -1
|
|
581
|
+
props.forEach((p, index) => {
|
|
582
|
+
if (p.value.kind === 'spread' && p.value.propsObject === true) at = index
|
|
583
|
+
})
|
|
584
|
+
return at
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* The value of an explicit prop a later props-object spread overrides (see
|
|
589
|
+
* `lastPropsObjectSpreadIndex`): the caller's own value when it passed the
|
|
590
|
+
* key, `expr` otherwise. `forwardProps` lets every override win, so the
|
|
591
|
+
* merge is spelled into the value itself.
|
|
592
|
+
*/
|
|
593
|
+
function callerFirstPropExpr(name: string, expr: string): string {
|
|
594
|
+
const key = JSON.stringify(name)
|
|
595
|
+
return `(${key} in ${PROPS_PARAM} ? ${PROPS_PARAM}[${key}] : ${expr})`
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* The merged value of the explicit prop at `index` for a reactive DOM
|
|
600
|
+
* mirror: caller-first when a later props-object spread (at `spreadAt`, see
|
|
601
|
+
* `lastPropsObjectSpreadIndex`) overrides it, `expr` as written otherwise.
|
|
602
|
+
*/
|
|
603
|
+
function mergedMirrorExpr(name: string, expr: string, index: number, spreadAt: number): string {
|
|
604
|
+
return index < spreadAt ? callerFirstPropExpr(name, expr) : expr
|
|
605
|
+
}
|
|
606
|
+
|
|
520
607
|
/** Build propsExpr for a child component from its IR props. */
|
|
521
608
|
function buildComponentPropsExpr(props: IRProp[], ctx: ClientJsContext): string {
|
|
522
609
|
const knownSpreadProp = props.find(p => {
|
|
@@ -528,52 +615,21 @@ function buildComponentPropsExpr(props: IRProp[], ctx: ClientJsContext): string
|
|
|
528
615
|
return resolveRestSpreadOrigin(ctx, expr) !== null
|
|
529
616
|
})
|
|
530
617
|
const spreadSource = knownSpreadProp ? PROPS_PARAM : null
|
|
618
|
+
const spreadAt = lastPropsObjectSpreadIndex(props)
|
|
531
619
|
|
|
532
620
|
const propsForInit: string[] = []
|
|
533
621
|
const explicitPropNames: string[] = []
|
|
534
|
-
|
|
535
|
-
if (prop.name === '...' || prop.name.startsWith('...'))
|
|
622
|
+
props.forEach((prop, index) => {
|
|
623
|
+
if (prop.name === '...' || prop.name.startsWith('...')) return
|
|
536
624
|
explicitPropNames.push(prop.name)
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
propsForInit.push(
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
switch (prop.value.kind) {
|
|
544
|
-
case 'jsx-children': {
|
|
545
|
-
if (jsxChildrenContainComponent(prop.value.children)) {
|
|
546
|
-
const jsxExpr = irChildrenToJsExpr(prop.value.children)
|
|
547
|
-
propsForInit.push(`get ${quotePropName(prop.name)}() { return __slot(() => ${jsxExpr}) }`)
|
|
548
|
-
} else {
|
|
549
|
-
// Brand via the shared door (#2651/#2702) — see
|
|
550
|
-
// `jsxChildrenPropGetterExpr`'s docstring.
|
|
551
|
-
const jsxExpr = jsxChildrenPropGetterExpr(prop.value.children, prop.name)
|
|
552
|
-
propsForInit.push(`get ${quotePropName(prop.name)}() { return ${jsxExpr} }`)
|
|
553
|
-
}
|
|
554
|
-
break
|
|
555
|
-
}
|
|
556
|
-
case 'expression':
|
|
557
|
-
case 'template':
|
|
558
|
-
case 'spread': {
|
|
559
|
-
const valueExpr = attrValueToString(prop.value)!
|
|
560
|
-
const expandedValue = expandDynamicPropValue(valueExpr, ctx)
|
|
561
|
-
propsForInit.push(`get ${quotePropName(prop.name)}() { return ${expandedValue} }`)
|
|
562
|
-
break
|
|
563
|
-
}
|
|
564
|
-
case 'literal':
|
|
565
|
-
propsForInit.push(`${quotePropName(prop.name)}: ${JSON.stringify(prop.value.value)}`)
|
|
566
|
-
break
|
|
567
|
-
case 'boolean-shorthand':
|
|
568
|
-
propsForInit.push(`${quotePropName(prop.name)}: true`)
|
|
569
|
-
break
|
|
570
|
-
case 'boolean-attr':
|
|
571
|
-
// Should not reach here for component props (processComponentProps
|
|
572
|
-
// promotes to boolean-shorthand), but handle defensively.
|
|
573
|
-
propsForInit.push(`${quotePropName(prop.name)}: true`)
|
|
574
|
-
break
|
|
625
|
+
const key = quotePropName(prop.name)
|
|
626
|
+
const { expr, getter } = componentInitPropValue(prop, ctx)
|
|
627
|
+
if (index < spreadAt) {
|
|
628
|
+
propsForInit.push(`get ${key}() { return ${callerFirstPropExpr(prop.name, expr)} }`)
|
|
629
|
+
} else {
|
|
630
|
+
propsForInit.push(getter ? `get ${key}() { return ${expr} }` : `${key}: ${expr}`)
|
|
575
631
|
}
|
|
576
|
-
}
|
|
632
|
+
})
|
|
577
633
|
|
|
578
634
|
if (spreadSource) {
|
|
579
635
|
const overrides = propsForInit.length > 0 ? `{ ${propsForInit.join(', ')} }` : '{}'
|
|
@@ -589,7 +645,8 @@ function buildComponentPropsExpr(props: IRProp[], ctx: ClientJsContext): string
|
|
|
589
645
|
* side-effect helper so `buildComponentPropsExpr` stays a pure function.
|
|
590
646
|
*/
|
|
591
647
|
function collectReactiveChildProps(node: IRComponent, ctx: ClientJsContext): void {
|
|
592
|
-
|
|
648
|
+
const spreadAt = lastPropsObjectSpreadIndex(node.props)
|
|
649
|
+
for (const [index, prop] of node.props.entries()) {
|
|
593
650
|
if (prop.name === '...' || prop.name.startsWith('...')) continue
|
|
594
651
|
if (prop.value.kind === 'jsx-children') continue
|
|
595
652
|
// `classifyDOMProp` is the single source of truth for "how does this prop
|
|
@@ -629,7 +686,7 @@ function collectReactiveChildProps(node: IRComponent, ctx: ClientJsContext): voi
|
|
|
629
686
|
slotId: node.slotId,
|
|
630
687
|
propName: prop.name,
|
|
631
688
|
attrName,
|
|
632
|
-
expression: expandedValue,
|
|
689
|
+
expression: mergedMirrorExpr(prop.name, expandedValue, index, spreadAt),
|
|
633
690
|
...pickAttrMetaFromIR(prop),
|
|
634
691
|
})
|
|
635
692
|
}
|
|
@@ -971,7 +1028,7 @@ export function collectElements(
|
|
|
971
1028
|
nestedComponents: l.nestedComponents,
|
|
972
1029
|
isStaticArray: clientIsStaticArray,
|
|
973
1030
|
useElementReconciliation,
|
|
974
|
-
innerLoops: (
|
|
1031
|
+
innerLoops: keepsInnerLoops(l, useElementReconciliation, innerLoops) ? innerLoops : undefined,
|
|
975
1032
|
offset: resolveLoopOffset(siblingOffsets.get(l)),
|
|
976
1033
|
filterPredicate: l.filterPredicate ? {
|
|
977
1034
|
param: l.filterPredicate.param,
|
|
@@ -1004,7 +1061,8 @@ export function collectElements(
|
|
|
1004
1061
|
component: ({ node: c, descend, descendJsxChildren }) => {
|
|
1005
1062
|
if (c.slotId) {
|
|
1006
1063
|
// Reactive props need effects to update the element when values change.
|
|
1007
|
-
|
|
1064
|
+
const spreadAt = lastPropsObjectSpreadIndex(c.props)
|
|
1065
|
+
for (const [index, prop] of c.props.entries()) {
|
|
1008
1066
|
if (prop.value.kind === 'jsx-children') continue
|
|
1009
1067
|
if (isEventHandlerName(prop.name)) continue
|
|
1010
1068
|
// Only `expression` variants reach the signal/memo getter heuristic
|
|
@@ -1020,7 +1078,7 @@ export function collectElements(
|
|
|
1020
1078
|
ctx.reactiveProps.push({
|
|
1021
1079
|
slotId: c.slotId,
|
|
1022
1080
|
propName: prop.name,
|
|
1023
|
-
expression:
|
|
1081
|
+
expression: mergedMirrorExpr(prop.name, value, index, spreadAt),
|
|
1024
1082
|
componentName: c.name,
|
|
1025
1083
|
})
|
|
1026
1084
|
}
|
|
@@ -636,7 +636,7 @@ function collectTemplateRiskyNames(irRoot: IRNode): Set<string> {
|
|
|
636
636
|
// Mirror the emitter's input source for each template position
|
|
637
637
|
// (`transformExpr` in html-template.ts uses `templateExpr ?? expr`).
|
|
638
638
|
// The `template*` rewrites — bare prop refs to `_p.X`, plus
|
|
639
|
-
// `IRTemplateLiteral` parts' `
|
|
639
|
+
// `IRTemplateLiteral` parts' `templateExpr`/`templateCondition`/
|
|
640
640
|
// `templateKey` — are what `transformExpr` actually substitutes
|
|
641
641
|
// through, so the diagnostic gate needs to look at the same string.
|
|
642
642
|
// Reading the raw form would drift from emission and could miss /
|
|
@@ -683,7 +683,7 @@ function collectTemplateRiskyNames(irRoot: IRNode): Set<string> {
|
|
|
683
683
|
},
|
|
684
684
|
component: ({ descend, descendJsxChildren }) => {
|
|
685
685
|
// Component props are stripped from `renderChild` when
|
|
686
|
-
// `
|
|
686
|
+
// `transformExprOrUnsafe` reports them unsafe (see
|
|
687
687
|
// html-template.ts). `initChild`'s getter binding then fills
|
|
688
688
|
// the prop once init runs. No diagnostic needed.
|
|
689
689
|
descend()
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
} from '../shared.ts'
|
|
33
33
|
import { irChildrenToJsExpr, renderPreamble } from '../../html-template.ts'
|
|
34
34
|
import { buildReactiveEffectsPlan } from './build-reactive-effects.ts'
|
|
35
|
+
import { buildForwardedInnerLoopsPlan } from './build-inner-loop.ts'
|
|
35
36
|
import type { ComponentLoopPlan, NestedComponentInit } from './types.ts'
|
|
36
37
|
import { internalInvariant } from '../../../errors.ts'
|
|
37
38
|
|
|
@@ -146,10 +147,21 @@ export function buildComponentLoopPlan(elem: TopLevelLoop, profileComponentName?
|
|
|
146
147
|
// loop has no delegation pass (`loopEventDelegationVariant` returns null
|
|
147
148
|
// for it), so each row attaches its handlers directly, exactly like the
|
|
148
149
|
// composite row's `outerEvents`. Events inside an inner loop of the
|
|
149
|
-
// forwarded children (`nestedLoops` non-empty)
|
|
150
|
+
// forwarded children (`nestedLoops` non-empty) go to `innerLoops` below.
|
|
150
151
|
const rowEvents = elem.bindings.events
|
|
151
152
|
.filter(ev => ev.nestedLoops.length === 0)
|
|
152
153
|
.map(ev => buildRowEventBinding(ev, elem.param, elem.paramBindings, elem.index))
|
|
154
|
+
// #3694: an event inside an inner loop of the forwarded children is wired
|
|
155
|
+
// by running that inner loop's composite-row emission over each row's
|
|
156
|
+
// element, hydrated and client-built alike.
|
|
157
|
+
const forwardedInnerLoops = (parentElVar: '__existing' | '__csrEl') => buildForwardedInnerLoopsPlan({
|
|
158
|
+
innerLoops: elem.innerLoops,
|
|
159
|
+
events: elem.bindings.events,
|
|
160
|
+
parentElVar,
|
|
161
|
+
outerLoopParam: elem.param,
|
|
162
|
+
outerLoopParamBindings: elem.paramBindings,
|
|
163
|
+
outerLoopIndex: elem.index,
|
|
164
|
+
})
|
|
153
165
|
|
|
154
166
|
return {
|
|
155
167
|
kind: 'component',
|
|
@@ -170,6 +182,7 @@ export function buildComponentLoopPlan(elem: TopLevelLoop, profileComponentName?
|
|
|
170
182
|
keyExpr,
|
|
171
183
|
nestedComps,
|
|
172
184
|
rowEvents,
|
|
185
|
+
innerLoops: { hydrated: forwardedInnerLoops('__existing'), created: forwardedInnerLoops('__csrEl') },
|
|
173
186
|
// #3612: refs on elements forwarded as the root component's own
|
|
174
187
|
// `children` (`<Chip><input ref={el => …} /></Chip>`), collected by the
|
|
175
188
|
// same `collectLoopChildBindings` walk as `rowEvents` above and resolved
|
|
@@ -179,6 +192,7 @@ export function buildComponentLoopPlan(elem: TopLevelLoop, profileComponentName?
|
|
|
179
192
|
// binding here: it goes to the component through `componentPropsExpr`.
|
|
180
193
|
childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
|
|
181
194
|
profileLoopId: profileComponentName ? `${profileComponentName}#binding:${elem.slotId}` : undefined,
|
|
195
|
+
profileComponentName,
|
|
182
196
|
reactiveEffects: hasReactiveEffects
|
|
183
197
|
? buildReactiveEffectsPlan({
|
|
184
198
|
attrs: elem.bindings.reactiveAttrs,
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import type {
|
|
27
|
+
LoopChildConditional,
|
|
27
28
|
LoopChildEvent,
|
|
28
29
|
NestedLoop,
|
|
29
30
|
} from '../../types.ts'
|
|
@@ -42,6 +43,7 @@ import {
|
|
|
42
43
|
attrValueToString,
|
|
43
44
|
} from '../../utils.ts'
|
|
44
45
|
import { buildChildRefBindings } from '../shared.ts'
|
|
46
|
+
import { buildLoopChainExpr } from '../../../loop-chain.ts'
|
|
45
47
|
import { renderPreamble, irToHtmlTemplate } from '../../html-template.ts'
|
|
46
48
|
import { buildLoopChildConditionalsPlan } from './build-loop-child-arm.ts'
|
|
47
49
|
import type { LoopChildConditionalPlan } from './loop-child-arm.ts'
|
|
@@ -71,7 +73,9 @@ function wrapAttrValueExpression(value: AttrValue, wrap: (s: string) => string):
|
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
import type { DepthLevel } from '../shared.ts'
|
|
76
|
+
import type { LoopRowEventBinding } from './loop.ts'
|
|
74
77
|
import {
|
|
78
|
+
buildDepthLevels,
|
|
75
79
|
destructureLoopParam,
|
|
76
80
|
loopKeyFn,
|
|
77
81
|
nestedLoopIndexAlias,
|
|
@@ -143,7 +147,14 @@ export function buildInnerLoopsPlan(args: BuildInnerLoopsArgs): InnerLoopsPlan {
|
|
|
143
147
|
// shortcut was unsound.
|
|
144
148
|
const emit: InnerLoopReactiveEmit = buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex)
|
|
145
149
|
|
|
146
|
-
|
|
150
|
+
// The inner `.filter()` / `.toSorted()` chain (#3694), so the rows
|
|
151
|
+
// reconciled are the rows the template rendered.
|
|
152
|
+
const arrayExpr = wrapOuter(buildLoopChainExpr({
|
|
153
|
+
base: inner.array,
|
|
154
|
+
filterPredicate: inner.filterPredicate,
|
|
155
|
+
sortComparator: inner.sortComparator,
|
|
156
|
+
chainOrder: inner.chainOrder,
|
|
157
|
+
}))
|
|
147
158
|
|
|
148
159
|
const childLevelsPlan = childLevels.length > 0
|
|
149
160
|
? buildInnerLoopsPlan({
|
|
@@ -231,15 +242,20 @@ function buildReactiveEmit(
|
|
|
231
242
|
props: comp.props.map(p => ({ ...p, value: wrapAttrValueExpression(p.value, wrapInner) })),
|
|
232
243
|
children: comp.children?.map(wrapIRNode),
|
|
233
244
|
}))
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
245
|
+
// Resolved against every enclosing row, like the texts below (#3694): an
|
|
246
|
+
// inner-wrap-only handler left a grandparent row's item two loops up
|
|
247
|
+
// unwrapped (`o.id` on the accessor reads `undefined`).
|
|
248
|
+
const events: LoopRowEventBinding[] = level.events.map(ev => ({
|
|
249
|
+
childSlotId: ev.childSlotId,
|
|
250
|
+
eventName: ev.eventName,
|
|
251
|
+
handler: wrapBoth(ev.handler),
|
|
237
252
|
}))
|
|
238
253
|
|
|
239
254
|
const reactiveTexts: InnerLoopText[] = inner.bindings.reactiveTexts.map(text => ({
|
|
240
255
|
slotId: text.slotId,
|
|
241
256
|
wrappedExpression: wrapLoopParamAsAccessor(wrapOuterRow(text.expression), inner.param, inner.paramBindings, inner.index),
|
|
242
257
|
insideConditional: !!text.insideConditional,
|
|
258
|
+
...(text.markup && { markup: true as const }),
|
|
243
259
|
}))
|
|
244
260
|
|
|
245
261
|
const reactiveAttrs: InnerLoopReactiveAttr[] = inner.bindings.reactiveAttrs.map(attr => {
|
|
@@ -320,3 +336,62 @@ function buildReactiveEmit(
|
|
|
320
336
|
childRefs,
|
|
321
337
|
}
|
|
322
338
|
}
|
|
339
|
+
|
|
340
|
+
export interface BuildForwardedInnerLoopsArgs {
|
|
341
|
+
/** The row's inner loops, DFS-ordered (`TopLevelLoop.innerLoops`). */
|
|
342
|
+
innerLoops: readonly NestedLoop[] | undefined
|
|
343
|
+
/** The row's collected events (`TopLevelLoop.bindings.events`). */
|
|
344
|
+
events: readonly LoopChildEvent[]
|
|
345
|
+
/** The row element the inner loop containers are looked up in. */
|
|
346
|
+
parentElVar: string
|
|
347
|
+
/** The outer row's param, or `undefined` when the row binds it as a plain value (a static array). */
|
|
348
|
+
outerLoopParam?: string
|
|
349
|
+
outerLoopParamBindings?: readonly LoopParamBinding[]
|
|
350
|
+
outerLoopIndex?: string | null
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* The inner-loop plan for the inner loops of a component-root row's
|
|
355
|
+
* forwarded children (`<Chip key={o.id}><ul>{o.tags.map(tag => <li><button
|
|
356
|
+
* onClick={…}/></li>)}</ul></Chip>`, #3694). The child component renders its
|
|
357
|
+
* `children` once, so nothing else reaches an element inside such an inner
|
|
358
|
+
* loop: a handler there was dropped. Each row now runs the composite row's
|
|
359
|
+
* inner-loop emission (`buildInnerLoopsPlan`) over its own element, which
|
|
360
|
+
* claims the rendered inner rows and attaches the handlers with the inner
|
|
361
|
+
* and the outer bindings resolved the same way as on a composite row.
|
|
362
|
+
*
|
|
363
|
+
* Only inner loops that carry an event, and the enclosing loops they need,
|
|
364
|
+
* are planned; the others keep their output unchanged. Child components
|
|
365
|
+
* inside an inner loop are left to their existing pass (`comps` empty), so
|
|
366
|
+
* none is initialised twice.
|
|
367
|
+
*/
|
|
368
|
+
export function buildForwardedInnerLoopsPlan(args: BuildForwardedInnerLoopsArgs): InnerLoopsPlan {
|
|
369
|
+
const { innerLoops, events, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex } = args
|
|
370
|
+
if (!innerLoops || innerLoops.length === 0) return []
|
|
371
|
+
const levels = buildDepthLevels([...innerLoops], [], [...events])
|
|
372
|
+
const kept = levels.filter((_, i) => levelCarriesEvent(levels, i))
|
|
373
|
+
if (kept.length === 0) return []
|
|
374
|
+
return buildInnerLoopsPlan({ levels: kept, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex })
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Whether `levels[i]` or a loop nested inside it (the deeper levels right
|
|
379
|
+
* after it) carries an event, on its row or inside a conditional of its row.
|
|
380
|
+
*/
|
|
381
|
+
function levelCarriesEvent(levels: readonly DepthLevel[], i: number): boolean {
|
|
382
|
+
const depth = levels[i].loopInfo?.depth ?? 0
|
|
383
|
+
for (let j = i; j < levels.length; j++) {
|
|
384
|
+
if (j > i && (levels[j].loopInfo?.depth ?? 0) <= depth) break
|
|
385
|
+
if (levels[j].events.length > 0) return true
|
|
386
|
+
if (conditionalsCarryEvent(levels[j].loopInfo?.bindings.conditionals ?? [])) return true
|
|
387
|
+
}
|
|
388
|
+
return false
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function conditionalsCarryEvent(conditionals: readonly LoopChildConditional[]): boolean {
|
|
392
|
+
return conditionals.some(c => [c.whenTrue, c.whenFalse].some(branch =>
|
|
393
|
+
(branch.events?.length ?? 0) > 0
|
|
394
|
+
|| conditionalsCarryEvent(branch.conditionals ?? [])
|
|
395
|
+
|| (branch.innerLoops ?? []).some(l => l.bindings.events.length > 0 || conditionalsCarryEvent(l.bindings.conditionals)),
|
|
396
|
+
))
|
|
397
|
+
}
|
|
@@ -59,6 +59,8 @@ export interface LazyRowAttrBinding {
|
|
|
59
59
|
/** One reactive text (content slot) of a lazy row. */
|
|
60
60
|
export interface LazyRowTextBinding {
|
|
61
61
|
slotId: string
|
|
62
|
+
/** Claimed and written as markup (`RowTextSlot`). */
|
|
63
|
+
markup?: true
|
|
62
64
|
wrappedExpression: string
|
|
63
65
|
ordinal: number
|
|
64
66
|
readsItem: boolean
|
|
@@ -340,6 +342,7 @@ export function decideLazyRow(args: BuildLazyRowArgs): {
|
|
|
340
342
|
readsItem: c.readsItem || !c.readsOuter,
|
|
341
343
|
readsOuter: c.readsOuter,
|
|
342
344
|
readsPreamble: c.readsPreamble,
|
|
345
|
+
...(text.markup && { markup: true as const }),
|
|
343
346
|
}
|
|
344
347
|
})
|
|
345
348
|
|
|
@@ -98,6 +98,7 @@ export function buildReactiveEffectsPlan(
|
|
|
98
98
|
const outerTexts: ReactiveTextEffect[] = texts.map(text => ({
|
|
99
99
|
slotId: text.slotId,
|
|
100
100
|
wrappedExpression: wrap(text.expression),
|
|
101
|
+
...(text.markup && { markup: true as const }),
|
|
101
102
|
}))
|
|
102
103
|
|
|
103
104
|
// 3. Per-conditional plans. Each arm's own reactive attrs / texts come
|
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
* reactivity in the row. See `build-inner-loop.ts`'s module docstring.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import type { LoopChildEvent } from '../../types.ts'
|
|
20
19
|
import type {
|
|
21
20
|
AttrMeta,
|
|
22
21
|
IRLoopChildComponent,
|
|
23
22
|
LoopParamBinding,
|
|
24
23
|
} from '../../../types.ts'
|
|
25
|
-
import type { LoopChildRefBinding } from './loop.ts'
|
|
24
|
+
import type { LoopChildRefBinding, LoopRowEventBinding } from './loop.ts'
|
|
26
25
|
import type { LoopChildConditionalPlan } from './loop-child-arm.ts'
|
|
27
26
|
|
|
28
27
|
/**
|
|
@@ -40,6 +39,8 @@ export type PreludeStatements = readonly string[]
|
|
|
40
39
|
/** A reactive text effect inside a reactive inner loop's renderItem body. */
|
|
41
40
|
export interface InnerLoopText {
|
|
42
41
|
slotId: string
|
|
42
|
+
/** Claimed and written as markup (`RowTextSlot`). */
|
|
43
|
+
markup?: true
|
|
43
44
|
/** Already wrapped via inner+outer loop param accessor (`wrapBoth`). */
|
|
44
45
|
wrappedExpression: string
|
|
45
46
|
/**
|
|
@@ -142,8 +143,8 @@ export interface InnerLoopReactiveEmit {
|
|
|
142
143
|
wrappedKey: string | null
|
|
143
144
|
/** Inner-wrapped components for emitComponentAndEventSetup. */
|
|
144
145
|
components: readonly IRLoopChildComponent[]
|
|
145
|
-
/**
|
|
146
|
-
events: readonly
|
|
146
|
+
/** Events resolved against the inner and every enclosing row, attached directly to each inner row. */
|
|
147
|
+
events: readonly LoopRowEventBinding[]
|
|
147
148
|
/** Pre-wrapped reactive text effects for the inner-item body. */
|
|
148
149
|
reactiveTexts: readonly InnerLoopText[]
|
|
149
150
|
/** Pre-wrapped reactive attribute effects for the inner-item body. */
|
|
@@ -76,6 +76,8 @@ export type BranchChildComponentInitsPlan = readonly BranchChildComponentInit[]
|
|
|
76
76
|
/** A reactive text effect inside a branch inner loop's renderItem body. */
|
|
77
77
|
export interface BranchInnerLoopText {
|
|
78
78
|
slotId: string
|
|
79
|
+
/** Claimed and written as markup (`RowTextSlot`). */
|
|
80
|
+
markup?: true
|
|
79
81
|
/** Already wrapped via inner+outer loop param accessor (`wrapBoth`). */
|
|
80
82
|
wrappedExpression: string
|
|
81
83
|
/**
|
|
@@ -130,6 +130,8 @@ export interface LoopRowEventBinding {
|
|
|
130
130
|
eventName: string
|
|
131
131
|
/** Handler expression, as the row's binding of the item reads it. */
|
|
132
132
|
handler: JsSourceText
|
|
133
|
+
/** See `LoopChildEvent.receiverSlotIds` (#3695). */
|
|
134
|
+
receiverSlotIds?: readonly string[]
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
/**
|
|
@@ -240,6 +242,14 @@ interface ComponentLoopVariant extends DynamicLoopCommon {
|
|
|
240
242
|
* the SSR/CSR split shape (the simple shape has no row handle).
|
|
241
243
|
*/
|
|
242
244
|
rowEvents: readonly LoopRowEventBinding[]
|
|
245
|
+
/**
|
|
246
|
+
* Inner loops of the ROOT component's forwarded `children` that carry an
|
|
247
|
+
* event handler (#3694), planned once per row element: `hydrated` over
|
|
248
|
+
* `__existing`, `created` over `__csrEl`. Each row runs them after its own
|
|
249
|
+
* `rowEvents`, so the handlers reach the inner rows. Empty when no inner
|
|
250
|
+
* loop carries an event; non-empty forces the SSR/CSR split shape.
|
|
251
|
+
*/
|
|
252
|
+
innerLoops: { hydrated: InnerLoopsPlan; created: InnerLoopsPlan }
|
|
243
253
|
/**
|
|
244
254
|
* Reactive-effects plan for the loop ROOT component's own reactive attrs /
|
|
245
255
|
* texts / conditionals — i.e. bindings on elements forwarded as the root
|
|
@@ -254,6 +264,8 @@ interface ComponentLoopVariant extends DynamicLoopCommon {
|
|
|
254
264
|
* `mapArray`. Undefined off → byte-identical (SR8).
|
|
255
265
|
*/
|
|
256
266
|
profileLoopId?: string
|
|
267
|
+
/** Owning component name in profile mode, threaded to `stringifyInnerLoops`. */
|
|
268
|
+
profileComponentName?: string
|
|
257
269
|
}
|
|
258
270
|
|
|
259
271
|
/**
|
|
@@ -37,6 +37,8 @@ export interface ReactiveAttrSlot {
|
|
|
37
37
|
/** A reactive text effect (one createEffect updating textContent). */
|
|
38
38
|
export interface ReactiveTextEffect {
|
|
39
39
|
slotId: string
|
|
40
|
+
/** Claimed and written as markup (`RowTextSlot`). */
|
|
41
|
+
markup?: true
|
|
40
42
|
/** Already wrapped via wrapLoopParamAsAccessor at build time. */
|
|
41
43
|
wrappedExpression: string
|
|
42
44
|
}
|
|
@@ -385,7 +385,7 @@ function emitEventSetup(
|
|
|
385
385
|
): void {
|
|
386
386
|
const binding = loopParam
|
|
387
387
|
? buildRowEventBinding(ev, loopParam, loopParamBindings, loopIndex)
|
|
388
|
-
: { childSlotId: ev.childSlotId, eventName: ev.eventName, handler: ev.handler }
|
|
388
|
+
: { childSlotId: ev.childSlotId, eventName: ev.eventName, handler: ev.handler, receiverSlotIds: ev.receiverSlotIds }
|
|
389
389
|
emitRowEventListener(ls, indent, elVar, binding, bodyIsMultiRoot)
|
|
390
390
|
}
|
|
391
391
|
|
|
@@ -405,6 +405,7 @@ export function buildRowEventBinding(
|
|
|
405
405
|
childSlotId: ev.childSlotId,
|
|
406
406
|
eventName: ev.eventName,
|
|
407
407
|
handler: wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings, loopIndex),
|
|
408
|
+
receiverSlotIds: ev.receiverSlotIds,
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
411
|
|
|
@@ -422,7 +423,7 @@ export function emitRowEventListener(
|
|
|
422
423
|
binding: LoopRowEventBinding,
|
|
423
424
|
bodyIsMultiRoot: boolean = false,
|
|
424
425
|
): void {
|
|
425
|
-
emitListenerBlock(ls, indent, elVar, binding.childSlotId, '__e', binding.eventName, binding.handler, 'dom', bodyIsMultiRoot)
|
|
426
|
+
emitListenerBlock(ls, indent, elVar, binding.childSlotId, '__e', binding.eventName, binding.handler, 'dom', bodyIsMultiRoot, binding.receiverSlotIds)
|
|
426
427
|
}
|
|
427
428
|
|
|
428
429
|
/**
|