@barefootjs/jsx 0.39.7 → 0.39.8

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.
Files changed (146) hide show
  1. package/dist/adapters/callback-method.d.ts +17 -0
  2. package/dist/adapters/callback-method.d.ts.map +1 -1
  3. package/dist/adapters/component-props.d.ts +80 -13
  4. package/dist/adapters/component-props.d.ts.map +1 -1
  5. package/dist/adapters/dsl-template-adapter.d.ts +151 -0
  6. package/dist/adapters/dsl-template-adapter.d.ts.map +1 -0
  7. package/dist/adapters/jsx-adapter.d.ts +4 -0
  8. package/dist/adapters/jsx-adapter.d.ts.map +1 -1
  9. package/dist/adapters/literal-value.d.ts +2 -2
  10. package/dist/adapters/literal-value.d.ts.map +1 -1
  11. package/dist/adapters/parsed-expr-emitter.d.ts +27 -0
  12. package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
  13. package/dist/adapters/style-object.d.ts +33 -0
  14. package/dist/adapters/style-object.d.ts.map +1 -0
  15. package/dist/analyzer.d.ts.map +1 -1
  16. package/dist/children-nullish.d.ts +22 -0
  17. package/dist/children-nullish.d.ts.map +1 -0
  18. package/dist/errors.d.ts +1 -0
  19. package/dist/errors.d.ts.map +1 -1
  20. package/dist/expression-parser.d.ts +9 -19
  21. package/dist/expression-parser.d.ts.map +1 -1
  22. package/dist/free-refs.d.ts +6 -0
  23. package/dist/free-refs.d.ts.map +1 -1
  24. package/dist/index.d.ts +14 -11
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +14685 -14000
  27. package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
  28. package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts +2 -1
  29. package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts.map +1 -1
  30. package/dist/ir-to-client-js/control-flow/plan/insert.d.ts +2 -2
  31. package/dist/ir-to-client-js/control-flow/plan/insert.d.ts.map +1 -1
  32. package/dist/ir-to-client-js/control-flow/stringify/event-delegation.d.ts.map +1 -1
  33. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +10 -9
  34. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
  35. package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
  36. package/dist/ir-to-client-js/emit-reactive.d.ts +1 -1
  37. package/dist/ir-to-client-js/emit-reactive.d.ts.map +1 -1
  38. package/dist/ir-to-client-js/emit-registration.d.ts +10 -8
  39. package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
  40. package/dist/ir-to-client-js/generate-init.d.ts.map +1 -1
  41. package/dist/ir-to-client-js/html-template.d.ts +0 -9
  42. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  43. package/dist/ir-to-client-js/identifiers.d.ts +6 -8
  44. package/dist/ir-to-client-js/identifiers.d.ts.map +1 -1
  45. package/dist/ir-to-client-js/imports.d.ts +23 -2
  46. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  47. package/dist/ir-to-client-js/phases/props-extraction.d.ts +3 -2
  48. package/dist/ir-to-client-js/phases/props-extraction.d.ts.map +1 -1
  49. package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts +1 -1
  50. package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts.map +1 -1
  51. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  52. package/dist/ir-to-client-js/rewrite-destructured-props.d.ts +1 -1
  53. package/dist/ir-to-client-js/rewrite-destructured-props.d.ts.map +1 -1
  54. package/dist/ir-to-client-js/safe-html.d.ts +20 -2
  55. package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
  56. package/dist/ir-to-client-js/types.d.ts +3 -3
  57. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  58. package/dist/ir-to-client-js/utils.d.ts +2 -11
  59. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  60. package/dist/jsx-to-ir.d.ts.map +1 -1
  61. package/dist/nullable-signal-attr.d.ts +40 -10
  62. package/dist/nullable-signal-attr.d.ts.map +1 -1
  63. package/dist/prop-rewrite.d.ts +18 -0
  64. package/dist/prop-rewrite.d.ts.map +1 -1
  65. package/dist/props-binding.d.ts +9 -1
  66. package/dist/props-binding.d.ts.map +1 -1
  67. package/dist/scanner/js-scanner.d.ts.map +1 -1
  68. package/dist/scanner/js-scanner.js +30 -2
  69. package/dist/signal-prop-name-collision.d.ts +6 -5
  70. package/dist/signal-prop-name-collision.d.ts.map +1 -1
  71. package/dist/ssr-defaults.d.ts +28 -0
  72. package/dist/ssr-defaults.d.ts.map +1 -1
  73. package/dist/ssr-seed-plan.d.ts +39 -14
  74. package/dist/ssr-seed-plan.d.ts.map +1 -1
  75. package/dist/types.d.ts +108 -18
  76. package/dist/types.d.ts.map +1 -1
  77. package/dist/value-references.d.ts +21 -0
  78. package/dist/value-references.d.ts.map +1 -1
  79. package/package.json +2 -2
  80. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +18 -18
  81. package/src/__tests__/adapter-output.test.ts +5 -3
  82. package/src/__tests__/analyzer.test.ts +33 -0
  83. package/src/__tests__/arithmetic-lowering.test.ts +44 -0
  84. package/src/__tests__/children-read.test.ts +226 -0
  85. package/src/__tests__/client-template-escape-soundness.test.ts +31 -1
  86. package/src/__tests__/component-props.test.ts +68 -1
  87. package/src/__tests__/constant-inlining-tree.test.ts +136 -0
  88. package/src/__tests__/destructure-default-reads-earlier-param.test.ts +138 -0
  89. package/src/__tests__/dsl-template-adapter.test.ts +173 -0
  90. package/src/__tests__/event-handler-verbatim.test.ts +73 -0
  91. package/src/__tests__/expression-parser.test.ts +1 -44
  92. package/src/__tests__/nullable-signal-attr.test.ts +67 -3
  93. package/src/__tests__/reference-graph-identifiers.test.ts +161 -0
  94. package/src/__tests__/runtime-import-detection.test.ts +134 -0
  95. package/src/__tests__/signal-prop-name-collision.test.ts +30 -0
  96. package/src/__tests__/ssr-defaults.test.ts +19 -1
  97. package/src/__tests__/ssr-seed-plan.test.ts +119 -0
  98. package/src/__tests__/style-object-plan.test.ts +54 -0
  99. package/src/__tests__/zero-param-helper-inline.test.ts +57 -0
  100. package/src/adapters/callback-method.ts +23 -0
  101. package/src/adapters/component-props.ts +130 -12
  102. package/src/adapters/dsl-template-adapter.ts +248 -0
  103. package/src/adapters/jsx-adapter.ts +12 -6
  104. package/src/adapters/literal-value.ts +2 -2
  105. package/src/adapters/parsed-expr-emitter.ts +34 -0
  106. package/src/adapters/style-object.ts +61 -0
  107. package/src/analyzer.ts +114 -15
  108. package/src/children-nullish.ts +33 -0
  109. package/src/debug.ts +2 -2
  110. package/src/errors.ts +12 -0
  111. package/src/expression-parser.ts +56 -53
  112. package/src/free-refs.ts +28 -17
  113. package/src/index.ts +18 -8
  114. package/src/ir-to-client-js/compute-inlinability.ts +29 -2
  115. package/src/ir-to-client-js/control-flow/plan/event-collision.ts +2 -1
  116. package/src/ir-to-client-js/control-flow/plan/insert.ts +2 -2
  117. package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +3 -2
  118. package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +13 -12
  119. package/src/ir-to-client-js/csr-substitute.ts +12 -2
  120. package/src/ir-to-client-js/emit-reactive.ts +2 -2
  121. package/src/ir-to-client-js/emit-registration.ts +28 -57
  122. package/src/ir-to-client-js/generate-init.ts +17 -1
  123. package/src/ir-to-client-js/html-template.ts +30 -50
  124. package/src/ir-to-client-js/identifiers.ts +75 -24
  125. package/src/ir-to-client-js/imports.ts +56 -19
  126. package/src/ir-to-client-js/index.ts +2 -1
  127. package/src/ir-to-client-js/phases/event-handlers.ts +2 -2
  128. package/src/ir-to-client-js/phases/props-extraction.ts +16 -15
  129. package/src/ir-to-client-js/plan/build-declaration-emit.ts +2 -2
  130. package/src/ir-to-client-js/prune-unused-prop-extractions.ts +7 -4
  131. package/src/ir-to-client-js/reactivity.ts +2 -2
  132. package/src/ir-to-client-js/rewrite-destructured-props.ts +21 -4
  133. package/src/ir-to-client-js/safe-html.ts +29 -35
  134. package/src/ir-to-client-js/types.ts +3 -2
  135. package/src/ir-to-client-js/utils.ts +2 -26
  136. package/src/jsx-to-ir.ts +279 -78
  137. package/src/nullable-signal-attr.ts +149 -33
  138. package/src/prop-rewrite.ts +41 -0
  139. package/src/props-binding.ts +17 -2
  140. package/src/scanner/__tests__/js-scanner.test.ts +37 -0
  141. package/src/scanner/js-scanner.ts +64 -4
  142. package/src/signal-prop-name-collision.ts +50 -24
  143. package/src/ssr-defaults.ts +47 -20
  144. package/src/ssr-seed-plan.ts +103 -23
  145. package/src/types.ts +115 -19
  146. package/src/value-references.ts +132 -0
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@ export { isOpaqueLocalAccessorName } from './opaque-local-accessor.ts'
20
20
  // data props, not handlers. Shared by the IR builder, client-JS prop wiring
21
21
  // and the SSR adapters' "a handler has no SSR value" skips.
22
22
  export { isEventHandlerName } from './event-handler-name.ts'
23
+ export { fallbackChainParts, nullishChainParts } from './children-nullish.ts'
23
24
 
24
25
  // Shared props-destructure binding + alias-map helpers (#2524, #2788)
25
26
  export { propsDestructureBinding, buildPropAliasMap, isIdentifierName, resolveBodyDestructuredPropAliases } from './props-binding.ts'
@@ -38,11 +39,12 @@ export { resolveGetterAliases, collectAliasableGetterNames } from './ir-to-clien
38
39
  export { buildImportAliasMap } from './ir-to-client-js/component-scope.ts'
39
40
 
40
41
  // Backend-neutral SSR seed plan (in-template derived signal/memo seeding)
41
- export { computeSsrSeedPlan } from './ssr-seed-plan.ts'
42
+ export { computeSsrSeedPlan, inDefaultReadOrder } from './ssr-seed-plan.ts'
42
43
  export type { SsrSeedPlan, SsrSeedStep } from './ssr-seed-plan.ts'
43
44
 
44
45
  // Pure IR types
45
46
  export type {
47
+ JsSourceText,
46
48
  ComponentIR,
47
49
  IRNode,
48
50
  IRElement,
@@ -64,6 +66,7 @@ export type {
64
66
  AttrValue,
65
67
  LiteralAttr,
66
68
  ExpressionAttr,
69
+ TypedExprSource,
67
70
  BooleanAttr,
68
71
  BooleanShorthandAttr,
69
72
  TemplateAttr,
@@ -72,6 +75,8 @@ export type {
72
75
  IRTemplatePart,
73
76
  IRProp,
74
77
  ParamInfo,
78
+ PropDefaultPart,
79
+ PropDefaultRead,
75
80
  PropertyInfo,
76
81
  MemoInfo,
77
82
  ConstantInfo,
@@ -87,7 +92,7 @@ export type {
87
92
  RenderDivergences,
88
93
  ImportInfo,
89
94
  } from './types.ts'
90
- export { isElidedFactoryGetter } from './types.ts'
95
+ export { isElidedFactoryGetter, isChildrenPropParam } from './types.ts'
91
96
 
92
97
  // Analyzer
93
98
  export { analyzeComponent, listComponentFunctions, listComponentFunctions as listExportedComponents, scanComponentFile, createProgramForFile, createAnchoredProgram, needsTypeBasedDetection, resolveRelativeImportToFile, REACTIVE_PRIMITIVES, CLIENT_EXPORTS, BROWSER_ONLY_CLIENT_APIS, type AnalyzerContext, type ComponentFileScan } from './analyzer.ts'
@@ -102,6 +107,8 @@ export { generateModuleExports, extractFunctionParams, formatParamWithType, find
102
107
 
103
108
  // Adapters
104
109
  export { BaseAdapter } from './adapters/interface.ts'
110
+ export { DslTemplateAdapter } from './adapters/dsl-template-adapter.ts'
111
+ export type { TemplateIdentifierSpelling } from './adapters/dsl-template-adapter.ts'
105
112
  // Dependency-free adapter for tooling that only needs client JS (e.g. the
106
113
  // profiler scenario driver) — the client output is adapter-independent.
107
114
  export { TestAdapter, testAdapter } from './adapters/test-adapter.ts'
@@ -117,9 +124,10 @@ export type {
117
124
  export { JsxAdapter } from './adapters/jsx-adapter.ts'
118
125
  export type { JsxAdapterConfig } from './adapters/jsx-adapter.ts'
119
126
  export { rewriteImportsForTemplate, rewriteDynamicImportsInSource } from './adapters/template-imports.ts'
120
- export { emitParsedExpr, groupBinaryOperand, groupObjectLiteralSegments, isStringTypedOperand, isStringConcatBinary, isNumericArithmeticResult } from './adapters/parsed-expr-emitter.ts'
121
- export type { ParsedExprEmitter, LoweringEmitter, HigherOrderMethod, ArrayMethod, SortMethod, LiteralType } from './adapters/parsed-expr-emitter.ts'
127
+ export { emitParsedExpr, arithmeticHelper, groupBinaryOperand, groupUnaryOperand, groupObjectLiteralSegments, isStringTypedOperand, isStringConcatBinary, isNumericArithmeticResult } from './adapters/parsed-expr-emitter.ts'
128
+ export type { ArithmeticHelper, ParsedExprEmitter, LoweringEmitter, HigherOrderMethod, ArrayMethod, SortMethod, LiteralType } from './adapters/parsed-expr-emitter.ts'
122
129
  export { collectLoopBoundNames } from './adapters/loop-bound-names.ts'
130
+ export { planStyleObject, type StyleObjectPlanEntry } from './adapters/style-object.ts'
123
131
  export { filterCaptureCollisions } from './adapters/filter-capture-collisions.ts'
124
132
  export { templateNameCollisionErrors } from './adapters/template-name-collisions.ts'
125
133
  export {
@@ -145,6 +153,8 @@ export {
145
153
  isPredicateMethod,
146
154
  lowerCallbackMethod,
147
155
  nestedCallbackRefusal,
156
+ filterPredicateShapeRefusal,
157
+ missingFilterPredicateRefusal,
148
158
  isUnloweredCall,
149
159
  unloweredCallRefusal,
150
160
  sortEvalPlan,
@@ -169,8 +179,8 @@ export type {
169
179
  ArrayMethodSpelling,
170
180
  } from './adapters/array-method.ts'
171
181
  export { derivesScopeFromSlot } from './adapters/child-scope.ts'
172
- export { childTemplateName, componentPropKey, isEmptyComponentProps, planComponentProps, spellComponentProps } from './adapters/component-props.ts'
173
- export type { ComponentPropEntry, ComponentPropSegment, ComponentPropSpelling, ComponentPropsOptions, SpelledComponentPropSegment } from './adapters/component-props.ts'
182
+ export { childTemplateName, componentPropKey, isEmptyComponentProps, planComponentProps, propsSpreadParam, resolveComponentPropKeys, spellComponentProps } from './adapters/component-props.ts'
183
+ export type { ComponentPropEntry, ComponentPropSegment, ComponentPropSpelling, ComponentPropsOptions, ComponentPropsParam, EarlierComponentProps, ResolvedComponentProp, SpelledComponentPropSegment } from './adapters/component-props.ts'
174
184
  export { parseUndefinedAlternateTernary, planAttrExpression, planSpreadAttr, unsupportedAttrExpression, unsupportedAttrExpressionError } from './adapters/attr-plan.ts'
175
185
  export type { AttrExpressionPlan, AttrPlanContext, SpreadAttrPlan, SpreadPlanContext, UndefinedAlternateTernary } from './adapters/attr-plan.ts'
176
186
  export { planLoop } from './adapters/loop-plan.ts'
@@ -184,6 +194,7 @@ export {
184
194
  arithmeticOperandCoercion,
185
195
  bareGetterCallName,
186
196
  attrValueMayBeNullish,
197
+ collectAbsentPropSeedReads,
187
198
  collectNullableSignalGetters,
188
199
  collectNullishAttrContext,
189
200
  isNullableSignal,
@@ -311,8 +322,7 @@ export { ErrorCodes, createError, formatError, generateCodeFrame } from './error
311
322
  export { isValueReferenceIdentifier, collectValueReferencedNames } from './value-references.ts'
312
323
 
313
324
  // Expression Parser
314
- export { parseExpression, tsNodeToParsedExpr, asCallbackMethodCall, hasOpaqueCall, unboundCallbackParamRead, unboundCallbackParamReason, CALLBACK_METHODS, sortComparatorFromArrow, serializeParsedExpr, freeVarsInBody, freeIdentifiers, renameFreeIdentifiers, materializeGetterCalls, isSupported, isSupportedValue, exprToString, stringifyParsedExpr, identifierPath, parseBlockBody, parseBlockBodyTolerant, foldBlockToExpr, predicateTernaryToLogical, containsHigherOrder, extractArrowBodyExpression, parseStyleObjectEntries, hasUnsafeStyleValue, parseProviderObjectLiteral, isFunctionShapedExpression, type ProviderObjectMember, type FoldBlockOptions } from './expression-parser.ts'
315
- export type { StyleObjectEntry } from './expression-parser.ts'
325
+ export { parseExpression, tsNodeToParsedExpr, asCallbackMethodCall, hasOpaqueCall, unboundCallbackParamRead, unboundCallbackParamReason, CALLBACK_METHODS, sortComparatorFromArrow, serializeParsedExpr, freeVarsInBody, freeIdentifiers, renameFreeIdentifiers, materializeGetterCalls, isSupported, isSupportedValue, exprToString, stringifyParsedExpr, identifierPath, parseBlockBody, parseBlockBodyTolerant, foldBlockToExpr, predicateTernaryToLogical, containsHigherOrder, extractArrowBodyExpression, hasUnsafeStyleValue, parseProviderObjectLiteral, isFunctionShapedExpression, type ProviderObjectMember, type FoldBlockOptions } from './expression-parser.ts'
316
326
  export { literalMemberIndex } from './literal-member-index.ts'
317
327
  export { PARSED_EXPR_KINDS, ARRAY_METHOD_NAMES, SORT_KEY_TYPES, SORT_KEY_TARGETS, SORT_KEY_DIRECTIONS } from './expression-parser.ts'
318
328
  export type { ParsedExpr, ObjectLiteralProperty, ParsedStatement, SortComparator, SortKey, FlatDepth, SupportLevel, SupportResult, TemplatePart } from './expression-parser.ts'
@@ -30,6 +30,7 @@ import { extractIdentifiers, extractTemplateIdentifiers } from './identifiers.ts
30
30
  import { isInlinableInTemplate, buildRelocateEnvFromIR } from '../relocate.ts'
31
31
  import type { RelocateEnv, RelocateDecision } from '../relocate.ts'
32
32
  import { createError, ErrorCodes } from '../errors.ts'
33
+ import { zeroArgCallBody } from '../expression-parser.ts'
33
34
  import { attrValueToString } from './utils.ts'
34
35
  import { walkIR, type IRVisitor } from './walker.ts'
35
36
  import { buildSignalMemoEnv, csrSubstitute, resolveGetterAliases, type CsrEnv, type CsrSubstitution } from './csr-substitute.ts'
@@ -368,7 +369,10 @@ export function computeInlinability(
368
369
  * in which case it gets an identity entry (`rewrittenValue: name`)
369
370
  * instead of `null` — the compiled bundle declares the const at
370
371
  * module scope too, so referencing it by its own bare name from the
371
- * CSR template is exactly as safe as a `module-scope-safe` function
372
+ * CSR template is exactly as safe as a `module-scope-safe` function.
373
+ * A zero-param arrow helper (`() => props.mode === 'wide'`) is not
374
+ * marked here either: it is substituted like any other value, so a
375
+ * template call `isWide()` reads its body (#3562)
372
376
  * - it's a system construct (`createContext`, `new WeakMap`)
373
377
  * - it's a JSX literal (handled by jsx-inline routing)
374
378
  * - it's a bare alias-hop chain naming a signal/memo getter (`getterAliases`)
@@ -437,7 +441,12 @@ function populateCsrInlinable(
437
441
  finalised.add(c.name)
438
442
  continue
439
443
  }
440
- if (c.isJsx || !c.value || c.containsArrow || c.systemConstructKind || c.mutatedAfterDeclaration || getterAliases.has(c.name)) {
444
+ // A zero-param helper (`const isWide = () => props.mode === 'wide'`) goes
445
+ // through the substitution below like any other const: `isWide()` then
446
+ // reads `(() => props.mode === 'wide')()` in template scope, so a seed
447
+ // or attribute that calls it renders its value instead of the empty
448
+ // fallback (#3562).
449
+ if (hasNoCsrSubstitute(c) || getterAliases.has(c.name)) {
441
450
  ctx.csrInlinable.set(c.name, null)
442
451
  finalised.add(c.name)
443
452
  }
@@ -523,6 +532,24 @@ function populateCsrInlinable(
523
532
  }
524
533
  }
525
534
 
535
+ /**
536
+ * A const whose value is a zero-param, synchronous arrow with a pure value
537
+ * body (`() => props.mode === 'wide'`, see `zeroArgCallBody`): calling it
538
+ * only reads the names its body reads, so splicing the arrow into template
539
+ * scope is as safe as splicing that body, which the substitution's own
540
+ * template-safety check decides. A body that mutates state
541
+ * (`() => ({ id: ++nextId })`) must run where it is declared.
542
+ */
543
+ function isZeroParamArrowHelper(c: ConstantInfo): boolean {
544
+ return c.parsed !== undefined && zeroArgCallBody(c.parsed) !== null
545
+ }
546
+
547
+ /** A const with no value this pass can substitute (see `populateCsrInlinable`). */
548
+ function hasNoCsrSubstitute(c: ConstantInfo): boolean {
549
+ const containsUnsplicedArrow = c.containsArrow && !isZeroParamArrowHelper(c)
550
+ return Boolean(c.isJsx || !c.value || containsUnsplicedArrow || c.systemConstructKind || c.mutatedAfterDeclaration)
551
+ }
552
+
526
553
  /**
527
554
  * The bridged CSR form of a const whose substituted text is `rewritten`, or
528
555
  * null when it isn't safe in template scope.
@@ -20,13 +20,14 @@
20
20
 
21
21
  import type { InteractiveElement } from '../../types.ts'
22
22
  import { toDomEventName, NON_BUBBLING_EVENTS } from '../../utils.ts'
23
+ import type { JsSourceText } from '../../../types.ts'
23
24
 
24
25
  export interface ContainerOwnHandler {
25
26
  /** The container element's own slot id (used for profile-mode turn ids). */
26
27
  slotId: string
27
28
  /** Original (pre-DOM-mapped) event name, e.g. 'contextmenu'. */
28
29
  eventName: string
29
- handler: string
30
+ handler: JsSourceText
30
31
  }
31
32
 
32
33
  /**
@@ -6,7 +6,7 @@
6
6
  * `ArmBody.conditionals`, so one stringifier handles arbitrary depth.
7
7
  */
8
8
 
9
- import type { AttrMeta } from '../../../types.ts'
9
+ import type { AttrMeta, JsSourceText } from '../../../types.ts'
10
10
  import type { ScopeRef } from './common.ts'
11
11
  import type { BranchLoopPlan } from './branch-loop.ts'
12
12
 
@@ -84,7 +84,7 @@ export interface ArmEventBind {
84
84
  slotId: string
85
85
  eventName: string
86
86
  /** Handler source expression (already trimmed). The stringifier wraps it. */
87
- handler: string
87
+ handler: JsSourceText
88
88
  /** Profile-mode turn id (#1690, SR3); when set the listener is turn-wrapped. */
89
89
  turnId?: string
90
90
  }
@@ -54,6 +54,7 @@ import type {
54
54
  StaticIndexItemLookup,
55
55
  LoopChildEvent,
56
56
  } from '../plan/types.ts'
57
+ import type { JsSourceText } from '../../../types.ts'
57
58
 
58
59
  /**
59
60
  * Profile mode (#1690, SR3): bracket a delegated handler call with turn
@@ -74,7 +75,7 @@ function withTurn(call: string, componentName: string | undefined, childSlotId:
74
75
  * or the name already equals the in-scope index var (a self-alias). Uses AST
75
76
  * free identifiers, not a token match, so `item.id` (property) doesn't count.
76
77
  */
77
- function indexBindingLine(handler: string, indexParam: string | null, indexExpr: string): string | null {
78
+ function indexBindingLine(handler: JsSourceText, indexParam: string | null, indexExpr: string): string | null {
78
79
  if (!indexParam || indexParam === indexExpr) return null
79
80
  if (!extractFreeIdentifiersFromText(handler).has(indexParam)) return null
80
81
  return `const ${indexParam} = ${indexExpr}`
@@ -93,7 +94,7 @@ function indexBindingLine(handler: string, indexParam: string | null, indexExpr:
93
94
  function preambleLineForHandler(
94
95
  mapPreamble: string | null,
95
96
  declaredNames: readonly string[],
96
- handler: string,
97
+ handler: JsSourceText,
97
98
  ): string | null {
98
99
  if (!mapPreamble || declaredNames.length === 0) return null
99
100
  const free = extractFreeIdentifiersFromText(handler)
@@ -6,36 +6,37 @@
6
6
  * 2. inline event setup (`emit-control-flow.ts::emitEventSetup`)
7
7
  * 3. loop-cond branch bindings (`stringify/loop-child-arm.ts::stringifyBranchEventBindings`)
8
8
  *
9
- * Each repeated `wrapHandlerInBlock(handler)` + DOM-event-name normalisation +
10
- * `if (elem) elem.addEventListener(...)` line. Centralising the shape here
11
- * keeps the wrap and the event-name decision in one place — useful when
9
+ * Each repeated the DOM-event-name normalisation + `if (elem)
10
+ * elem.addEventListener(...)` line. Centralising the shape here keeps the
11
+ * event-name decision in one place — useful when
12
12
  * we eventually drop the legacy "raw event name" mode (currently only used
13
13
  * by `@client` conditionals).
14
14
  */
15
15
 
16
- import { toDomEventName, wrapHandlerInBlock, wrapHandlerForTurn } from '../../utils.ts'
16
+ import { toDomEventName, wrapHandlerForTurn } from '../../utils.ts'
17
+ import type { JsSourceText } from '../../../types.ts'
17
18
 
18
19
  export type EventNameMode = 'dom' | 'raw'
19
20
 
20
21
  /**
21
22
  * Emit `if (<elementVar>) <elementVar>.addEventListener('<eventName>',
22
- * <wrappedHandler>)` on a single line. The handler is already
23
- * source-level — pass it verbatim; the helper applies
24
- * `wrapHandlerInBlock` so block-form arrow functions are safe to drop
25
- * into an expression position.
23
+ * <handler>)` on a single line. The handler is already source-level and
24
+ * an expression (Phase 1 parenthesizes a comma sequence), so it is passed
25
+ * verbatim: `addEventListener` ignores a listener's return value, so an
26
+ * expression-bodied arrow needs no block wrap (#3538).
26
27
  */
27
28
  export function emitListenerLine(
28
29
  lines: string[],
29
30
  indent: string,
30
31
  elementVar: string,
31
32
  eventName: string,
32
- handler: string,
33
+ handler: JsSourceText,
33
34
  mode: EventNameMode = 'dom',
34
35
  turnId?: string,
35
36
  ): void {
36
37
  // Profile mode (#1690, SR3): when a turn id is supplied the handler is
37
38
  // bracketed with beginTurn/endTurn instead of the plain block wrap.
38
- const wrapped = turnId ? wrapHandlerForTurn(handler, turnId) : wrapHandlerInBlock(handler)
39
+ const wrapped = turnId ? wrapHandlerForTurn(handler, turnId) : handler.trim()
39
40
  const name = mode === 'dom' ? toDomEventName(eventName) : eventName
40
41
  lines.push(`${indent}if (${elementVar}) ${elementVar}.addEventListener('${name}', ${wrapped})`)
41
42
  }
@@ -57,11 +58,11 @@ export function emitListenerBlock(
57
58
  slotId: string,
58
59
  elementLocal: string,
59
60
  eventName: string,
60
- handler: string,
61
+ handler: JsSourceText,
61
62
  mode: EventNameMode = 'dom',
62
63
  bodyIsMultiRoot: boolean = false,
63
64
  ): void {
64
- const wrapped = wrapHandlerInBlock(handler)
65
+ const wrapped = handler.trim()
65
66
  const name = mode === 'dom' ? toDomEventName(eventName) : eventName
66
67
  const lookup = bodyIsMultiRoot ? 'qsaItem' : 'qsa'
67
68
  lines.push(`${indent}{ const ${elementLocal} = ${lookup}(${scopeVar}, '[bf="${slotId}"]'); if (${elementLocal}) ${elementLocal}.addEventListener('${name}', ${wrapped}) }`)
@@ -102,6 +102,15 @@ export interface CsrEnv {
102
102
  propsObjectName: string | null
103
103
  }
104
104
 
105
+ /**
106
+ * The value positions of an object-literal `key: value` entry: the value,
107
+ * and a computed key's expression (`{ [size]: value }`, #3535). A plain key
108
+ * is a name, never a reference.
109
+ */
110
+ function propertyValueExpressions(node: ts.PropertyAssignment): ts.Expression[] {
111
+ return ts.isComputedPropertyName(node.name) ? [node.name.expression, node.initializer] : [node.initializer]
112
+ }
113
+
105
114
  /**
106
115
  * Substitute an expression for CSR template scope. Returns the rewritten
107
116
  * text plus the free identifiers of the rewritten form.
@@ -264,9 +273,10 @@ function csrSubstituteOnce(
264
273
  }
265
274
 
266
275
  // Property assignment in object literal: `{ X: value }` — `X` is a
267
- // key, not a free ref. `value` is.
276
+ // key, not a free ref. `value` is, and so is a computed key's
277
+ // expression (`{ [size]: value }`, #3535).
268
278
  if (ts.isPropertyAssignment(node)) {
269
- visit(node.initializer)
279
+ propertyValueExpressions(node).forEach(visit)
270
280
  return
271
281
  }
272
282
 
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import ts from 'typescript'
8
- import type { AttrMeta, IRMetadata } from '../types.ts'
8
+ import { type AttrMeta, type IRMetadata, isChildrenPropParam } from '../types.ts'
9
9
  import { isBooleanAttr } from '../html-constants.ts'
10
10
  import type { ClientJsContext } from './types.ts'
11
11
  import { toHtmlAttrName, varSlotId, PROPS_PARAM } from './utils.ts'
@@ -327,7 +327,7 @@ export function rewriteDestructuredPropsInExpr(expr: string, ctx: ClientJsContex
327
327
  const propAliases = new Map<string, string>()
328
328
  const propsByName = new Map<string, ClientJsContext['propsParams'][number]>()
329
329
  for (const prop of ctx.propsParams) {
330
- if (prop.name === 'children') continue
330
+ if (isChildrenPropParam(prop)) continue
331
331
  propNames.add(prop.name)
332
332
  propsByName.set(prop.name, prop)
333
333
  // `_p` is always keyed by the caller-facing name (#2524 CSR half).
@@ -9,72 +9,43 @@ import type { ClientJsContext } from './types.ts'
9
9
  import { PROPS_PARAM, componentDefScopeFlags, initFunctionName } from './utils.ts'
10
10
  import { collectReactiveGetterNames } from '../analyzer-context.ts'
11
11
  import { computeInlinability, toLegacyInlinability } from './compute-inlinability.ts'
12
- import { canGenerateStaticTemplate, irToComponentTemplate, generateCsrTemplate, createStringProtector } from './html-template.ts'
12
+ import { canGenerateStaticTemplate, irToComponentTemplate, generateCsrTemplate } from './html-template.ts'
13
+ import { csrSubstitute, type CsrEnv } from './csr-substitute.ts'
13
14
  import { markupSlotIdsOf } from './markup-slots.ts'
14
15
  import { nameForRegistryRef } from './component-scope.ts'
15
16
  import { resolveRestSpreadNames } from './prop-handling.ts'
16
17
 
17
18
  /**
18
19
  * Resolve chained references within a constants map.
19
- * If constant A references constant B, replace B's name in A's value with B's resolved value.
20
- * Uses pre-computed freeIdentifiers to skip unnecessary regex replacements.
20
+ * If constant A references constant B, replace B's name in A's value with
21
+ * B's resolved value. The substitution runs on the expression tree
22
+ * (`csrSubstitute`), so a constant's name inside a string or template
23
+ * literal, a member name, or a binding that shadows it is never replaced,
24
+ * and an object-literal shorthand expands to `name: (value)` (#3535).
21
25
  *
22
- * When `freeIdsMap` is supplied, it is updated in place: each substitution
23
- * removes the substituted name from the resolving constant's free-id set
24
- * and unions in the substituted constant's own free ids. The result is a
25
- * transitively-closed free-id map that downstream callers
26
- * (`toLegacyInlinability` unsafe-ref check, #1267) can read without
27
- * re-scanning the resolved string.
26
+ * When `freeIdsMap` is supplied, it is updated in place to the free
27
+ * identifiers of each resolved value, so downstream callers
28
+ * (`toLegacyInlinability` unsafe-ref check, #1267) can read a
29
+ * transitively-closed free-id map without re-scanning the resolved string.
30
+ * A constant whose recorded free ids name no other constant is skipped.
28
31
  */
29
32
  export function resolveChainedRefs(constants: Map<string, string>, freeIdsMap?: Map<string, Set<string>>): void {
30
- let changed = true
31
- const maxIterations = constants.size + 1
32
- let iteration = 0
33
- while (changed && iteration < maxIterations) {
34
- changed = false
35
- iteration++
36
- for (const [constName, constValue] of constants) {
37
- // String literal values (single/double quoted) cannot contain variable references.
38
- // Skip them to avoid corrupting CSS class names like "size-4" when a constant
39
- // named "size" exists (the regex would falsely match "size" in "size-4").
40
- const trimmed = constValue.trim()
41
- if ((trimmed.startsWith("'") && trimmed.endsWith("'")) ||
42
- (trimmed.startsWith('"') && trimmed.endsWith('"'))) {
43
- continue
44
- }
45
-
46
- // Protect string literals within compound values (e.g., Record objects
47
- // containing 'size-4') from regex-based identifier replacement
48
- const { protect, restore } = createStringProtector()
49
- let newValue = protect(constValue)
50
- const freeIds = freeIdsMap?.get(constName)
51
- for (const [otherName, otherValue] of constants) {
52
- if (otherName === constName) continue
53
- // Use freeIdentifiers to skip constants that are definitely not referenced.
54
- // On subsequent iterations the value may have been expanded beyond what
55
- // freeIdentifiers tracks, so fall through to regex when freeIds is unavailable
56
- // or when the iteration is > 1 (values have been mutated).
57
- if (freeIds && iteration === 1 && !freeIds.has(otherName)) continue
58
- const replaced = newValue.replace(new RegExp(`(?<![-.])\\b${otherName}\\b`, 'g'), `(${protect(otherValue)})`)
59
- if (replaced !== newValue) {
60
- newValue = replaced
61
- changed = true
62
- // Maintain a transitively-closed free-id set on the resolving
63
- // constant: drop the substituted name, union in the substituted
64
- // constant's own free ids.
65
- if (freeIds) {
66
- freeIds.delete(otherName)
67
- const otherFreeIds = freeIdsMap?.get(otherName)
68
- if (otherFreeIds) {
69
- for (const id of otherFreeIds) freeIds.add(id)
70
- }
71
- }
72
- }
73
- }
74
- newValue = restore(newValue)
75
- if (newValue !== constValue) {
76
- constants.set(constName, newValue)
77
- }
33
+ for (const [constName, constValue] of constants) {
34
+ const freeIds = freeIdsMap?.get(constName)
35
+ if (freeIds && ![...freeIds].some(id => id !== constName && constants.has(id))) continue
36
+ // Every other constant, not only the recorded free ids: a substituted
37
+ // value can bring in a name the original value did not mention.
38
+ const env: CsrEnv = { substitutions: new Map(), propsObjectName: null }
39
+ for (const [otherName, otherValue] of constants) {
40
+ if (otherName === constName) continue
41
+ env.substitutions.set(otherName, { kind: 'identifier', replacement: otherValue, freeIdentifiers: new Set() })
42
+ }
43
+ const { rewritten, freeIdentifiers } = csrSubstitute(constValue, env)
44
+ if (rewritten === constValue) continue
45
+ constants.set(constName, rewritten)
46
+ if (freeIds) {
47
+ freeIds.clear()
48
+ for (const id of freeIdentifiers) freeIds.add(id)
78
49
  }
79
50
  }
80
51
  }
@@ -13,7 +13,8 @@ import type { ClientJsContext } from './types.ts'
13
13
  import { PROPS_PARAM, isCommentScopedRoot, initFunctionName } from './utils.ts'
14
14
  import { buildReferencesGraph } from './build-references.ts'
15
15
  import { computePropUsage } from './compute-prop-usage.ts'
16
- import { IMPORT_PLACEHOLDER, MODULE_CONSTANTS_PLACEHOLDER } from './imports.ts'
16
+ import { IMPORT_PLACEHOLDER, MODULE_CONSTANTS_PLACEHOLDER, runtimeNameCollisions } from './imports.ts'
17
+ import { signalSecondBinding } from '../signal-initializer.ts'
17
18
  import { emitRegistrationAndHydration, csrInlinableConstantsFromCtx } from './emit-registration.ts'
18
19
  import { computeDeferredChildSlots } from './html-template.ts'
19
20
  import { emitChildComponentImports } from './child-components.ts'
@@ -137,6 +138,21 @@ export function generateInitFunction(
137
138
  const codeWithModuleConstants = pruneUnusedPropExtractions(
138
139
  generatedCode.replace(MODULE_CONSTANTS_PLACEHOLDER, () => moduleConstantsCode),
139
140
  )
141
+ ctx.warnings.push(
142
+ ...runtimeNameCollisions(
143
+ [
144
+ ...classification.moduleLevelConstants,
145
+ ...classification.moduleLevelFunctions,
146
+ ...classification.moduleLevelSignals.flatMap(s => {
147
+ const second = signalSecondBinding(s)
148
+ return [{ name: s.getter, loc: s.loc }, ...(second ? [{ name: second, loc: s.loc }] : [])]
149
+ }),
150
+ ...classification.moduleLevelMemos,
151
+ ],
152
+ ir.metadata.imports,
153
+ codeWithModuleConstants,
154
+ ),
155
+ )
140
156
  const allImportLines = resolveFinalImports(codeWithModuleConstants, ir, localImportPrefixes)
141
157
 
142
158
  return codeWithModuleConstants.replace(IMPORT_PLACEHOLDER, () => allImportLines)
@@ -2,7 +2,7 @@
2
2
  * IR → HTML template string generation and validation.
3
3
  */
4
4
 
5
- import type { AttrValue, FlatMapCallback, IRAttribute, IRElement, IRExpression, IRNode, IRProp, MapCallbackPreamble } from '../types.ts'
5
+ import type { AttrValue, FlatMapCallback, IRAttribute, IRElement, IRExpression, IRNode, IRProp, MapCallbackPreamble, JsSourceText } from '../types.ts'
6
6
  import { isBooleanAttr } from '../html-constants.ts'
7
7
  import { toHtmlAttrName, attrValueToString, quotePropName, PROPS_PARAM, DATA_BF_PH, keyAttrName, loopStartMarker, loopEndMarker, loopItemMarker, freeIdsFromRefs, setIntersects, wrapExprWithLoopParams, specsInsideRow } from './utils.ts'
8
8
  import type { LoopParamSpec } from './utils.ts'
@@ -19,29 +19,6 @@ import { interp, spliceChildValue, conditionalMarkup, renderChildCall, mappedRow
19
19
  import { markupSlotIdsOf } from './markup-slots.ts'
20
20
  import { isEventHandlerName } from '../event-handler-name.ts'
21
21
 
22
- /**
23
- * Protect string literals from regex-based replacements.
24
- * Returns protect/restore functions that extract string literals before
25
- * regex replacements and restore them after.
26
- */
27
- export function createStringProtector(): {
28
- protect: (s: string) => string
29
- restore: (s: string) => string
30
- } {
31
- const strings: string[] = []
32
- const protect = (s: string): string => {
33
- return s.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, (match) => {
34
- const idx = strings.length
35
- strings.push(match)
36
- return `__STRLIT_${idx}__`
37
- })
38
- }
39
- const restore = (s: string): string => {
40
- return s.replace(/__STRLIT_(\d+)__/g, (_, idx) => strings[Number(idx)])
41
- }
42
- return { protect, restore }
43
- }
44
-
45
22
  /**
46
23
  * Split a template literal body into static segments and `${...}` interpolations,
47
24
  * correctly handling nested braces (e.g. object literals inside interpolations).
@@ -327,7 +304,7 @@ function escapeAttrValueExpr(valExpr: string): string {
327
304
  */
328
305
  function dangerouslyHtmlChildren(
329
306
  attrs: ReadonlyArray<IRAttribute>,
330
- toExpr: (v: { expr: string; templateExpr?: string }) => string,
307
+ toExpr: (v: { expr: JsSourceText; templateExpr?: JsSourceText }) => string,
331
308
  ): string | null {
332
309
  const attr = attrs.find(a => a.name === 'dangerouslySetInnerHTML')
333
310
  if (!attr || attr.value.kind !== 'expression') return null
@@ -341,7 +318,7 @@ function dangerouslyHtmlChildren(
341
318
  * template path; for non-`expression`/`spread`/`template` variants we
342
319
  * delegate to the canonical projection.
343
320
  */
344
- function transformKeyValue(value: AttrValue, transformExpr: (expr: string, templateExpr?: string) => string): string {
321
+ function transformKeyValue(value: AttrValue, transformExpr: (expr: JsSourceText, templateExpr?: JsSourceText) => string): string {
345
322
  switch (value.kind) {
346
323
  case 'expression':
347
324
  case 'spread':
@@ -1838,8 +1815,22 @@ export function irToComponentTemplate(
1838
1815
  return irToComponentTemplateWithOpts(node, { inlinableConstants, restSpreadNames, propsObjectName, loopDepth: -1, markupSlotIds, restPropsName })
1839
1816
  }
1840
1817
 
1818
+ /**
1819
+ * The `csrSubstitute` environment that inlines each template constant by
1820
+ * name (#3535), or null when there is none to inline.
1821
+ */
1822
+ function inlinableConstantEnv(inlinableConstants: ReadonlyMap<string, string> | undefined): CsrEnv | null {
1823
+ if (!inlinableConstants || inlinableConstants.size === 0) return null
1824
+ const substitutions = new Map<string, CsrSubstitution>()
1825
+ for (const [name, value] of inlinableConstants) {
1826
+ substitutions.set(name, { kind: 'identifier', replacement: value, freeIdentifiers: new Set() })
1827
+ }
1828
+ return { substitutions, propsObjectName: null }
1829
+ }
1830
+
1841
1831
  function irToComponentTemplateWithOpts(node: IRNode, opts: TemplateOptions): string {
1842
1832
  const { inlinableConstants, restSpreadNames, propsObjectName, restPropsName, loopDepth = 0 } = opts
1833
+ const constantEnv = inlinableConstantEnv(inlinableConstants)
1843
1834
  // `recurse` preserves `inHoistedChildren` for structural pass-through
1844
1835
  // (fragment / conditional); `childrenRecurse` clears it so element
1845
1836
  // descendants don't re-emit the placeholder. (#1320)
@@ -1849,29 +1840,19 @@ function irToComponentTemplateWithOpts(node: IRNode, opts: TemplateOptions): str
1849
1840
  // Bare prop name prefixing (org → _p.org) is handled by templateExpr
1850
1841
  // from Phase 1 AST rewrite. Only constant inlining and props object
1851
1842
  // normalization are done here. (#807)
1852
- const transformExpr = (expr: string, templateExpr?: string): string => {
1853
- const { protect, restore } = createStringProtector()
1854
- let result = protect(templateExpr ?? expr)
1855
-
1856
- // Inline constant references with their resolved values (#343)
1857
- if (inlinableConstants && inlinableConstants.size > 0) {
1858
- for (const [constName, constValue] of inlinableConstants) {
1859
- result = result.replace(new RegExp(`(?<![-.])\\b${constName}\\b`, 'g'), `(${protect(constValue)})`)
1860
- }
1861
- }
1843
+ const transformExpr = (expr: JsSourceText, templateExpr?: JsSourceText): string => {
1844
+ // Inline constant references with their resolved values (#343), on the
1845
+ // expression tree: a constant's name inside a string or template
1846
+ // literal, a member name, or a binding that shadows it is never
1847
+ // replaced, and a shorthand `{ size }` expands to `size: (value)`
1848
+ // (#3535).
1849
+ const source = templateExpr ?? expr
1850
+ const restored = constantEnv ? csrSubstitute(source, constantEnv, opts.scope).rewritten : source
1862
1851
 
1863
- // Normalize source-level props object access (e.g., props.xxx → _p.xxx).
1864
- // Restore FIRST: `rewritePropsObjectRef` parses `result` as real
1865
- // TypeScript, and a still-protected string/template-literal span would
1866
- // parse as an opaque placeholder token instead of the source text it
1867
- // stands for (harmless for the placeholder itself, but it must not be
1868
- // mistaken for unparsed leftover input by a caller reading `result`
1869
- // before this point). Regex-based `\b${propsObjectName}\.` (removed
1870
- // here) required the name to be immediately followed by `.`, so a
1871
- // parenthesised receiver — `(props).label`, produced by this same
1872
- // function's own constant-inlining step just above when the inlined
1873
- // value is itself `props` (a local alias of the whole props object) —
1874
- // silently kept the pre-rewrite name instead of `_p`.
1852
+ // Normalize source-level props object access (e.g., props.xxx → _p.xxx),
1853
+ // also on the tree: a parenthesised receiver — `(props).label`, produced
1854
+ // by the constant inlining just above when the inlined value is itself
1855
+ // `props` (a local alias of the whole props object) — resolves too.
1875
1856
  //
1876
1857
  // The gate stays keyed on `propsObjectName` for the destructured-prop
1877
1858
  // case (unconditionally rewriting here would also change static-path
@@ -1881,7 +1862,6 @@ function irToComponentTemplateWithOpts(node: IRNode, opts: TemplateOptions): str
1881
1862
  // param), so `rest.header` resolves to `_p.header` here the same way
1882
1863
  // it already does in the init body (`generate-init.ts`, #2723) instead
1883
1864
  // of reaching the template as a bare, undeclared `rest` (#2806).
1884
- const restored = restore(result)
1885
1865
  return (propsObjectName && propsObjectName !== PROPS_PARAM) || restPropsName
1886
1866
  ? rewritePropsObjectRef(restored, propsObjectName ?? null, restPropsName ?? null, { enclosingScope: opts.scope })
1887
1867
  : restored
@@ -2478,7 +2458,7 @@ export function computeDeferredChildSlots(
2478
2458
  function generateCsrTemplateWithOpts(node: IRNode, opts: TemplateOptions): string {
2479
2459
  const { restSpreadNames, propsObjectName, restPropsName, csrEnv, unsafeLocalNames, loopDepth = 0 } = opts
2480
2460
  const env: CsrEnv = csrEnv ?? { substitutions: new Map(), propsObjectName: propsObjectName ?? null }
2481
- const transformExpr = (expr: string, templateExpr?: string): string => {
2461
+ const transformExpr = (expr: JsSourceText, templateExpr?: JsSourceText): string => {
2482
2462
  // Single AST substitution pass: replaces signal getter calls
2483
2463
  // (`count()` → `(initialValue)`), memo calls (`bars()` → `(body)`),
2484
2464
  // and inlinable-const refs (`label` → `(rewrittenValue)`) in one