@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
|
@@ -44,6 +44,33 @@ export interface ClaimSlotSpec {
|
|
|
44
44
|
readonly markerless?: boolean
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* A loop-row content slot. `markup` is set for a row's read of the
|
|
49
|
+
* component's own prop (Phase 1's `IRExpression.loopRowPropRead`, carried as
|
|
50
|
+
* `LoopChildReactiveText.markup`): the caller may pass a JSX element there,
|
|
51
|
+
* so the slot is claimed and written as markup, the same way the read is
|
|
52
|
+
* outside a loop (`markup-slots.ts`). Every other row text stays 'text'.
|
|
53
|
+
*/
|
|
54
|
+
export interface RowTextSlot {
|
|
55
|
+
readonly slotId: string
|
|
56
|
+
readonly markup?: true
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The claim kind of a loop-row content slot (see {@link RowTextSlot}). */
|
|
60
|
+
export function rowTextSlotKind(text: RowTextSlot): 'text' | 'markup' {
|
|
61
|
+
return text.markup ? 'markup' : 'text'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The value a loop-row content slot's writer receives: `escapeTextOrNode`
|
|
66
|
+
* for a markup slot (unwraps a `bfMarkup()` value, passes a Node or a
|
|
67
|
+
* `__slot()` marker through, escapes a string before the markup writer's
|
|
68
|
+
* `innerHTML`), `coerce(expr)` for a 'text' slot.
|
|
69
|
+
*/
|
|
70
|
+
export function rowTextSlotValue(text: RowTextSlot, expr: string, coerce: 'String' | 'textOrNode'): string {
|
|
71
|
+
return text.markup ? `escapeTextOrNode(${expr})` : `${coerce}(${expr})`
|
|
72
|
+
}
|
|
73
|
+
|
|
47
74
|
/** Render one `SlotSpec` as a source-text object literal. */
|
|
48
75
|
function slotSpecLiteral(slot: ClaimSlotSpec): string {
|
|
49
76
|
const pathSrc = slot.pathExpr ?? `[${slot.path.join(', ')}]`
|
|
@@ -42,6 +42,7 @@ import type { ComponentLoopPlan, NestedComponentInit } from '../plan/types.ts'
|
|
|
42
42
|
import { nameForRegistryRef } from '../../component-scope.ts'
|
|
43
43
|
import { stringifyChildrenTextEffect, emitRowEventListener } from '../shared.ts'
|
|
44
44
|
import { emitLoopChildRefs } from './loop.ts'
|
|
45
|
+
import { stringifyInnerLoops } from './inner-loop.ts'
|
|
45
46
|
|
|
46
47
|
export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan): void {
|
|
47
48
|
const {
|
|
@@ -57,9 +58,11 @@ export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan)
|
|
|
57
58
|
keyExpr,
|
|
58
59
|
nestedComps,
|
|
59
60
|
rowEvents,
|
|
61
|
+
innerLoops,
|
|
60
62
|
childRefs,
|
|
61
63
|
reactiveEffects,
|
|
62
64
|
profileLoopId,
|
|
65
|
+
profileComponentName,
|
|
63
66
|
mapPreambleWrapped,
|
|
64
67
|
} = plan
|
|
65
68
|
|
|
@@ -88,8 +91,9 @@ export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan)
|
|
|
88
91
|
//
|
|
89
92
|
// #3607: the same holds for a handler on a forwarded element — it needs
|
|
90
93
|
// the row element to attach to, and (#3612) for a `ref` callback on one —
|
|
91
|
-
// it needs the row element to look the target up in.
|
|
92
|
-
|
|
94
|
+
// it needs the row element to look the target up in. So does (#3694) an
|
|
95
|
+
// inner loop of the forwarded children that carries a handler.
|
|
96
|
+
if (nestedComps.length === 0 && !reactiveEffects && rowEvents.length === 0 && innerLoops.hydrated.length === 0 && childRefs.length === 0) {
|
|
93
97
|
lines.push(` if (__existing) { initChild('${scopedComp}', __existing, ${componentPropsExpr}); return __existing }`)
|
|
94
98
|
lines.push(` return createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`)
|
|
95
99
|
lines.push(` }, '${markerId}'${loopBfId})`)
|
|
@@ -101,6 +105,7 @@ export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan)
|
|
|
101
105
|
lines.push(` initChild('${scopedComp}', __existing, ${componentPropsExpr})`)
|
|
102
106
|
for (const nc of nestedComps) emitNestedInit(lines, ' ', '__existing', nc)
|
|
103
107
|
for (const ev of rowEvents) emitRowEventListener(lines, ' ', '__existing', ev)
|
|
108
|
+
stringifyInnerLoops(lines, innerLoops.hydrated, ' ', profileComponentName)
|
|
104
109
|
if (reactiveEffects) {
|
|
105
110
|
stringifyReactiveEffects(lines, reactiveEffects, { indent: ' ', elVar: '__existing' })
|
|
106
111
|
}
|
|
@@ -116,6 +121,7 @@ export function stringifyComponentLoop(lines: string[], plan: ComponentLoopPlan)
|
|
|
116
121
|
lines.push(` const __csrEl = createComponent('${scopedComp}', ${componentPropsExpr}, ${keyExpr})`)
|
|
117
122
|
for (const nc of nestedComps) emitNestedInit(lines, ' ', '__csrEl', nc)
|
|
118
123
|
for (const ev of rowEvents) emitRowEventListener(lines, ' ', '__csrEl', ev)
|
|
124
|
+
stringifyInnerLoops(lines, innerLoops.created, ' ', profileComponentName)
|
|
119
125
|
if (reactiveEffects) {
|
|
120
126
|
stringifyReactiveEffects(lines, reactiveEffects, { indent: ' ', elVar: '__csrEl' })
|
|
121
127
|
}
|
|
@@ -61,9 +61,16 @@ export function emitListenerBlock(
|
|
|
61
61
|
handler: JsSourceText,
|
|
62
62
|
mode: EventNameMode = 'dom',
|
|
63
63
|
bodyIsMultiRoot: boolean = false,
|
|
64
|
+
receiverSlotIds?: readonly string[],
|
|
64
65
|
): void {
|
|
65
66
|
const wrapped = handler.trim()
|
|
66
67
|
const name = mode === 'dom' ? toDomEventName(eventName) : eventName
|
|
67
68
|
const lookup = bodyIsMultiRoot ? 'qsaItem' : 'qsa'
|
|
68
|
-
|
|
69
|
+
// A parent-owned element forwarded through components nested below the
|
|
70
|
+
// row root (#3695) renders inside their scopes, which `qsa` crosses only
|
|
71
|
+
// for the nominated receivers hosted by this component (`__scopeId`).
|
|
72
|
+
const receiverArgs = !bodyIsMultiRoot && receiverSlotIds && receiverSlotIds.length > 0
|
|
73
|
+
? `, ${JSON.stringify(receiverSlotIds)}, __scopeId`
|
|
74
|
+
: ''
|
|
75
|
+
lines.push(`${indent}{ const ${elementLocal} = ${lookup}(${scopeVar}, '[bf="${slotId}"]'${receiverArgs}); if (${elementLocal}) ${elementLocal}.addEventListener('${name}', ${wrapped}) }`)
|
|
69
76
|
}
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import { keyAttrName, mapArrayKeyArgs, profileBindingId, varSlotId } from '../../utils.ts'
|
|
27
|
-
import { emitComponentAndEventSetup } from '../shared.ts'
|
|
27
|
+
import { emitComponentAndEventSetup, emitRowEventListener } from '../shared.ts'
|
|
28
28
|
import { emitDedupedAttrUpdate, DEDUP_STORE_DECL } from '../../emit-reactive.ts'
|
|
29
29
|
import { emitMultiRootTemplateCloneLines, namespaceWrapForTemplate } from './template-parse.ts'
|
|
30
30
|
import { emitLoopChildRefs } from './loop.ts'
|
|
31
|
-
import { claimPlanLiteral, claimWriterVarName, type ClaimSlotSpec } from './claim-plan.ts'
|
|
31
|
+
import { claimPlanLiteral, claimWriterVarName, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
|
|
32
32
|
import { stringifyLoopChildConditionals } from './loop-child-arm.ts'
|
|
33
33
|
import type {
|
|
34
34
|
InnerLoopPlan,
|
|
@@ -86,19 +86,20 @@ function emitReactive(lines: string[], inner: InnerLoopPlan, indent: string, pc:
|
|
|
86
86
|
if (emit.wrappedKey) {
|
|
87
87
|
lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${emit.wrappedKey}))`)
|
|
88
88
|
}
|
|
89
|
-
if (emit.components.length > 0
|
|
89
|
+
if (emit.components.length > 0) {
|
|
90
90
|
emitComponentAndEventSetup(
|
|
91
91
|
lines,
|
|
92
92
|
`${indent} `,
|
|
93
93
|
`__innerEl${uid}`,
|
|
94
94
|
[...emit.components],
|
|
95
|
-
[
|
|
95
|
+
[],
|
|
96
96
|
inner.outerLoopParam,
|
|
97
97
|
inner.outerLoopParamBindings,
|
|
98
98
|
false,
|
|
99
99
|
inner.outerLoopIndex,
|
|
100
100
|
)
|
|
101
101
|
}
|
|
102
|
+
for (const ev of emit.events) emitRowEventListener(lines, `${indent} `, `__innerEl${uid}`, ev)
|
|
102
103
|
if (inner.childLevels.length > 0) {
|
|
103
104
|
stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc)
|
|
104
105
|
}
|
|
@@ -111,14 +112,14 @@ function emitReactive(lines: string[], inner: InnerLoopPlan, indent: string, pc:
|
|
|
111
112
|
// writes are a plain, idempotent `nodeValue` assignment with no
|
|
112
113
|
// dedup/trust-first-run state to go stale — so re-claiming here is exactly
|
|
113
114
|
// as safe as, and replaces, the old re-query-$t-on-every-run discipline.
|
|
114
|
-
lines.push(`${indent} createEffect(() => { claimSlots(__innerEl${uid}, [{ id: '${text.slotId}', kind: 'text', path: [] }]).write('${text.slotId}',
|
|
115
|
+
lines.push(`${indent} createEffect(() => { claimSlots(__innerEl${uid}, [{ id: '${text.slotId}', kind: '${rowTextSlotKind(text)}', path: [] }]).write('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${bf})`)
|
|
115
116
|
}
|
|
116
117
|
if (plainTexts.length > 0) {
|
|
117
|
-
const slots: ClaimSlotSpec[] = plainTexts.map(t => ({ id: t.slotId, kind:
|
|
118
|
+
const slots: ClaimSlotSpec[] = plainTexts.map(t => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }))
|
|
118
119
|
const writer = claimWriterVarName(slots, varSlotId)
|
|
119
120
|
lines.push(`${indent} const ${writer} = lazySlots(__innerEl${uid}, ${claimPlanLiteral(slots)})`)
|
|
120
121
|
for (const text of plainTexts) {
|
|
121
|
-
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}',
|
|
122
|
+
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${profileBindingId(pc, text.slotId)})`)
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
if (emit.reactiveAttrs.length > 0) lines.push(`${indent} ${DEDUP_STORE_DECL}`)
|
|
@@ -63,7 +63,7 @@ import { isBooleanAttr } from '../../../html-constants.ts'
|
|
|
63
63
|
import { emitDedupedAttrUpdate, dedupGuard } from '../../emit-reactive.ts'
|
|
64
64
|
import { toHtmlAttrName } from '../../utils.ts'
|
|
65
65
|
import type { SkeletonSlotPaths } from '../../html-template.ts'
|
|
66
|
-
import { claimPlanLiteral, type ClaimSlotSpec } from './claim-plan.ts'
|
|
66
|
+
import { claimPlanLiteral, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
|
|
67
67
|
import { pathExpr } from './skeleton-paths.ts'
|
|
68
68
|
import {
|
|
69
69
|
emitHoistedTemplateDecl,
|
|
@@ -156,13 +156,13 @@ export function stringifyLazyRowLoop(lines: string[], o: StringifyLazyRowOptions
|
|
|
156
156
|
let freshPlanVar: string | null = null
|
|
157
157
|
if (lazyRow.texts.length > 0) {
|
|
158
158
|
adoptedPlanVar = `__lzs_${mid}`
|
|
159
|
-
const adoptedSlots: ClaimSlotSpec[] = lazyRow.texts.map(t => ({ id: t.slotId, kind:
|
|
159
|
+
const adoptedSlots: ClaimSlotSpec[] = lazyRow.texts.map(t => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }))
|
|
160
160
|
lines.push(`${indent}const ${adoptedPlanVar} = ${claimPlanLiteral(adoptedSlots)}`)
|
|
161
161
|
if (textPathVar) {
|
|
162
162
|
freshPlanVar = `__lzsc_${mid}`
|
|
163
163
|
const freshSlots: ClaimSlotSpec[] = lazyRow.texts.map((t, i) => ({
|
|
164
164
|
id: t.slotId,
|
|
165
|
-
kind:
|
|
165
|
+
kind: rowTextSlotKind(t),
|
|
166
166
|
path: [],
|
|
167
167
|
pathExpr: `${textPathVar}[${i}]`,
|
|
168
168
|
}))
|
|
@@ -535,15 +535,16 @@ function emitTextBinding(
|
|
|
535
535
|
? `${doorExpr}.write('${t.slotId}', ${valueExpr})`
|
|
536
536
|
: `${doorExpr}('${t.slotId}', ${valueExpr})`
|
|
537
537
|
|
|
538
|
+
const value = rowTextSlotValue(t, '__x', 'textOrNode')
|
|
538
539
|
if (mode === 'outer') {
|
|
539
540
|
lines.push(`${ind}if (__seed) {`)
|
|
540
|
-
lines.push(`${ind} const __s =
|
|
541
|
+
lines.push(`${ind} const __s = ${value}`)
|
|
541
542
|
lines.push(`${ind} if (${doorExpr}.read('${t.slotId}') !== __s) ${writeOf('__s')}`)
|
|
542
|
-
lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf(
|
|
543
|
+
lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf(value)}`)
|
|
543
544
|
} else if (mode === 'item') {
|
|
544
|
-
lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf(
|
|
545
|
+
lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf(value)}`)
|
|
545
546
|
} else {
|
|
546
|
-
lines.push(`${ind}${writeOf(
|
|
547
|
+
lines.push(`${ind}${writeOf(value)}`)
|
|
547
548
|
}
|
|
548
549
|
lines.push(`${ind}__l[${t.ordinal}] = __x }`)
|
|
549
550
|
}
|
|
@@ -17,7 +17,7 @@ import { emitDedupedAttrUpdate, DEDUP_STORE_DECL } from '../../emit-reactive.ts'
|
|
|
17
17
|
import { namespaceWrapForTemplate } from './template-parse.ts'
|
|
18
18
|
import { emitListenerLine } from './event-listener.ts'
|
|
19
19
|
import { nameForRegistryRef } from '../../component-scope.ts'
|
|
20
|
-
import { claimPlanLiteral, claimWriterVarName, type ClaimSlotSpec } from './claim-plan.ts'
|
|
20
|
+
import { claimPlanLiteral, claimWriterVarName, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
|
|
21
21
|
import type {
|
|
22
22
|
BranchChildComponentInitsPlan,
|
|
23
23
|
BranchEventBindingsPlan,
|
|
@@ -198,14 +198,14 @@ export function stringifyBranchInnerLoops(
|
|
|
198
198
|
// insert() may swap the branch's DOM between runs, and a 'text' write
|
|
199
199
|
// is a plain, idempotent `nodeValue` assignment with no dedup state to
|
|
200
200
|
// go stale — replaces the old re-query-$t-on-every-run discipline.
|
|
201
|
-
lines.push(`${indent} createEffect(() => { claimSlots(__bel${uid}, [{ id: '${text.slotId}', kind: 'text', path: [] }]).write('${text.slotId}',
|
|
201
|
+
lines.push(`${indent} createEffect(() => { claimSlots(__bel${uid}, [{ id: '${text.slotId}', kind: '${rowTextSlotKind(text)}', path: [] }]).write('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${bf})`)
|
|
202
202
|
}
|
|
203
203
|
if (plainTexts.length > 0) {
|
|
204
|
-
const slots: ClaimSlotSpec[] = plainTexts.map(t => ({ id: t.slotId, kind:
|
|
204
|
+
const slots: ClaimSlotSpec[] = plainTexts.map(t => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }))
|
|
205
205
|
const writer = claimWriterVarName(slots, varSlotId)
|
|
206
206
|
lines.push(`${indent} const ${writer} = lazySlots(__bel${uid}, ${claimPlanLiteral(slots)})`)
|
|
207
207
|
for (const text of plainTexts) {
|
|
208
|
-
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}',
|
|
208
|
+
lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${profileBindingId(pc, text.slotId)})`)
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
if (inner.nestedConditionals.length > 0) {
|
|
@@ -36,7 +36,7 @@ import { emitTemplateCloneInline, emitLoopItemElementSetup, emitHoistedTemplateD
|
|
|
36
36
|
import { buildSkeletonPathPlan, type SkeletonPathPlan } from './skeleton-paths.ts'
|
|
37
37
|
import { stringifyComponentLoop } from './component-loop.ts'
|
|
38
38
|
import { stringifyCompositeLoop } from './composite-loop.ts'
|
|
39
|
-
import { claimPlanLiteral, claimWriterVarName, type ClaimSlotSpec } from './claim-plan.ts'
|
|
39
|
+
import { claimPlanLiteral, claimWriterVarName, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
|
|
40
40
|
import { stringifyLazyRowLoop } from './lazy-row.ts'
|
|
41
41
|
import type { LoopChildRefBinding, LoopPlan, PlainLoopPlan, StaticLoopPlan } from '../plan/types.ts'
|
|
42
42
|
|
|
@@ -515,11 +515,11 @@ export function stringifyStaticLoop(lines: string[], plan: StaticLoopPlan): void
|
|
|
515
515
|
lines.push(` }`)
|
|
516
516
|
}
|
|
517
517
|
if (texts.length > 0) {
|
|
518
|
-
const slots: ClaimSlotSpec[] = texts.map(t => ({ id: t.slotId, kind:
|
|
518
|
+
const slots: ClaimSlotSpec[] = texts.map(t => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [] }))
|
|
519
519
|
const writer = claimWriterVarName(slots, varSlotId)
|
|
520
520
|
lines.push(` const ${writer} = lazySlots(__iterEl, ${claimPlanLiteral(slots)})`)
|
|
521
521
|
for (const text of texts) {
|
|
522
|
-
lines.push(` createEffect(() => { ${writer}('${text.slotId}',
|
|
522
|
+
lines.push(` createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.expression, 'String')}) }${profileBindingId(pc, text.slotId)})`)
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
// Ref callbacks fire on every forEach iteration — initial mount and any
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
import { varSlotId, profileBindingId } from '../../utils.ts'
|
|
35
35
|
import { emitDedupedAttrUpdate, DEDUP_STORE_DECL } from '../../emit-reactive.ts'
|
|
36
36
|
import { stringifyLoopChildArm, conditionGetterExpr } from './loop-child-arm.ts'
|
|
37
|
-
import { claimPlanLiteral, claimWriterVarName, type ClaimSlotSpec } from './claim-plan.ts'
|
|
37
|
+
import { claimPlanLiteral, claimWriterVarName, rowTextSlotKind, rowTextSlotValue, type ClaimSlotSpec } from './claim-plan.ts'
|
|
38
38
|
import type {
|
|
39
39
|
NestedConditionalPlan,
|
|
40
40
|
ReactiveAttrSlot,
|
|
@@ -277,7 +277,7 @@ function emitConsolidatedRowEffect(
|
|
|
277
277
|
// preamble regions (kind 'markup') — mixed-kind plans are supported by
|
|
278
278
|
// claim-slots.ts's per-slot `kind` dispatch.
|
|
279
279
|
const claimSlots: ClaimSlotSpec[] = [
|
|
280
|
-
...outerTexts.map((t): ClaimSlotSpec => ({ id: t.slotId, kind:
|
|
280
|
+
...outerTexts.map((t): ClaimSlotSpec => ({ id: t.slotId, kind: rowTextSlotKind(t), path: [], pathExpr: textClaimPathExprs?.get(t.slotId) })),
|
|
281
281
|
...preambleRegions.map((r): ClaimSlotSpec => ({ id: r.slotId, kind: 'markup', path: [] })),
|
|
282
282
|
]
|
|
283
283
|
const writer = claimSlots.length > 0 ? claimWriterVarName(claimSlots, varSlotId) : null
|
|
@@ -294,7 +294,7 @@ function emitConsolidatedRowEffect(
|
|
|
294
294
|
// preamble region) uses the multi-line block.
|
|
295
295
|
if (attrSlots.length === 0 && preambleRegions.length === 0 && outerTexts.length === 1) {
|
|
296
296
|
const text = outerTexts[0]
|
|
297
|
-
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}',
|
|
297
|
+
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) })`)
|
|
298
298
|
return
|
|
299
299
|
}
|
|
300
300
|
lines.push(`${indent}createEffect(() => {`)
|
|
@@ -319,7 +319,7 @@ function emitConsolidatedRowEffect(
|
|
|
319
319
|
lines.push(`${indent} }`)
|
|
320
320
|
}
|
|
321
321
|
for (const text of outerTexts) {
|
|
322
|
-
lines.push(`${indent} ${writer}('${text.slotId}',
|
|
322
|
+
lines.push(`${indent} ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')})`)
|
|
323
323
|
}
|
|
324
324
|
for (const region of preambleRegions) {
|
|
325
325
|
lines.push(`${indent} ${writer}('${region.slotId}', ${region.valueExpr})`)
|
|
@@ -338,14 +338,14 @@ function emitOuterTexts(
|
|
|
338
338
|
if (texts.length === 0) return
|
|
339
339
|
const slots: ClaimSlotSpec[] = texts.map(t => ({
|
|
340
340
|
id: t.slotId,
|
|
341
|
-
kind:
|
|
341
|
+
kind: rowTextSlotKind(t),
|
|
342
342
|
path: [],
|
|
343
343
|
pathExpr: textClaimPathExprs?.get(t.slotId),
|
|
344
344
|
}))
|
|
345
345
|
const writer = claimWriterVarName(slots, varSlotId)
|
|
346
346
|
lines.push(`${indent}const ${writer} = lazySlots(${elVar}, ${claimPlanLiteral(slots)})`)
|
|
347
347
|
for (const text of texts) {
|
|
348
|
-
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}',
|
|
348
|
+
lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', ${rowTextSlotValue(text, text.wrappedExpression, 'String')}) }${bindingBfId(text.slotId)})`)
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
|
|
@@ -732,7 +732,7 @@ export function emitReactivePropBindings(lines: string[], ctx: ClientJsContext):
|
|
|
732
732
|
const ref = slotId === ctx.commentScopeRootSlotId ? '__scope' : `_${varSlotId(slotId)}`
|
|
733
733
|
lines.push(` if (${ref}) {`)
|
|
734
734
|
for (const prop of props) {
|
|
735
|
-
const value =
|
|
735
|
+
const value = prop.expression
|
|
736
736
|
if (prop.propName === 'selected') {
|
|
737
737
|
if (prop.componentName === 'TabsContent') {
|
|
738
738
|
lines.push(` ${ref}.setAttribute('data-state', ${value} ? 'active' : 'inactive')`)
|