@barefootjs/jsx 0.39.7 → 0.39.9

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 (192) hide show
  1. package/dist/adapters/callback-method.d.ts +36 -7
  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 +153 -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/loop-plan.d.ts +133 -9
  12. package/dist/adapters/loop-plan.d.ts.map +1 -1
  13. package/dist/adapters/parsed-expr-emitter.d.ts +44 -0
  14. package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
  15. package/dist/adapters/style-object.d.ts +33 -0
  16. package/dist/adapters/style-object.d.ts.map +1 -0
  17. package/dist/analyzer.d.ts.map +1 -1
  18. package/dist/assignment-target.d.ts +26 -0
  19. package/dist/assignment-target.d.ts.map +1 -0
  20. package/dist/children-nullish.d.ts +22 -0
  21. package/dist/children-nullish.d.ts.map +1 -0
  22. package/dist/errors.d.ts +2 -0
  23. package/dist/errors.d.ts.map +1 -1
  24. package/dist/expression-parser.d.ts +9 -19
  25. package/dist/expression-parser.d.ts.map +1 -1
  26. package/dist/free-refs.d.ts +6 -0
  27. package/dist/free-refs.d.ts.map +1 -1
  28. package/dist/index.d.ts +17 -14
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +15040 -13899
  31. package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
  32. package/dist/ir-to-client-js/control-flow/plan/build-component-loop.d.ts.map +1 -1
  33. package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts +2 -1
  34. package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts.map +1 -1
  35. package/dist/ir-to-client-js/control-flow/plan/insert.d.ts +2 -2
  36. package/dist/ir-to-client-js/control-flow/plan/insert.d.ts.map +1 -1
  37. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +24 -1
  38. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
  39. package/dist/ir-to-client-js/control-flow/shared.d.ts +16 -1
  40. package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
  41. package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts +6 -1
  42. package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts.map +1 -1
  43. package/dist/ir-to-client-js/control-flow/stringify/event-delegation.d.ts.map +1 -1
  44. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +10 -9
  45. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
  46. package/dist/ir-to-client-js/csr-substitute.d.ts +13 -2
  47. package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
  48. package/dist/ir-to-client-js/emit-reactive.d.ts +1 -1
  49. package/dist/ir-to-client-js/emit-reactive.d.ts.map +1 -1
  50. package/dist/ir-to-client-js/emit-registration.d.ts +10 -8
  51. package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
  52. package/dist/ir-to-client-js/generate-init.d.ts.map +1 -1
  53. package/dist/ir-to-client-js/html-template.d.ts +0 -9
  54. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  55. package/dist/ir-to-client-js/identifiers.d.ts +6 -8
  56. package/dist/ir-to-client-js/identifiers.d.ts.map +1 -1
  57. package/dist/ir-to-client-js/imports.d.ts +23 -2
  58. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  59. package/dist/ir-to-client-js/phases/props-extraction.d.ts +6 -3
  60. package/dist/ir-to-client-js/phases/props-extraction.d.ts.map +1 -1
  61. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +8 -0
  62. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
  63. package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts +1 -1
  64. package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts.map +1 -1
  65. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  66. package/dist/ir-to-client-js/rewrite-destructured-props.d.ts +1 -1
  67. package/dist/ir-to-client-js/rewrite-destructured-props.d.ts.map +1 -1
  68. package/dist/ir-to-client-js/rewrite-props-object.d.ts.map +1 -1
  69. package/dist/ir-to-client-js/safe-html.d.ts +20 -2
  70. package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
  71. package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts +1 -0
  72. package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
  73. package/dist/ir-to-client-js/types.d.ts +3 -3
  74. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  75. package/dist/ir-to-client-js/utils.d.ts +2 -11
  76. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  77. package/dist/jsx-to-ir.d.ts.map +1 -1
  78. package/dist/nullable-signal-attr.d.ts +40 -10
  79. package/dist/nullable-signal-attr.d.ts.map +1 -1
  80. package/dist/prop-rewrite.d.ts +35 -8
  81. package/dist/prop-rewrite.d.ts.map +1 -1
  82. package/dist/props-binding.d.ts +66 -1
  83. package/dist/props-binding.d.ts.map +1 -1
  84. package/dist/scanner/js-scanner.d.ts.map +1 -1
  85. package/dist/scanner/js-scanner.js +30 -2
  86. package/dist/scope/binding-scope.d.ts +30 -2
  87. package/dist/scope/binding-scope.d.ts.map +1 -1
  88. package/dist/scope/lexical-scope-walk.d.ts +26 -0
  89. package/dist/scope/lexical-scope-walk.d.ts.map +1 -0
  90. package/dist/signal-prop-name-collision.d.ts +6 -5
  91. package/dist/signal-prop-name-collision.d.ts.map +1 -1
  92. package/dist/ssr-defaults.d.ts +28 -0
  93. package/dist/ssr-defaults.d.ts.map +1 -1
  94. package/dist/ssr-seed-plan.d.ts +39 -14
  95. package/dist/ssr-seed-plan.d.ts.map +1 -1
  96. package/dist/types.d.ts +133 -19
  97. package/dist/types.d.ts.map +1 -1
  98. package/dist/value-references.d.ts +21 -0
  99. package/dist/value-references.d.ts.map +1 -1
  100. package/package.json +2 -2
  101. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +18 -18
  102. package/src/__tests__/adapter-output.test.ts +5 -3
  103. package/src/__tests__/analyzer.test.ts +33 -0
  104. package/src/__tests__/arithmetic-lowering.test.ts +48 -0
  105. package/src/__tests__/binding-scope.test.ts +29 -0
  106. package/src/__tests__/children-read.test.ts +226 -0
  107. package/src/__tests__/client-template-escape-soundness.test.ts +31 -1
  108. package/src/__tests__/component-props.test.ts +68 -1
  109. package/src/__tests__/constant-inlining-tree.test.ts +136 -0
  110. package/src/__tests__/create-query.test.ts +1 -1
  111. package/src/__tests__/destructure-default-reads-earlier-param.test.ts +138 -0
  112. package/src/__tests__/dsl-template-adapter.test.ts +173 -0
  113. package/src/__tests__/emit-to-string-call.test.ts +58 -0
  114. package/src/__tests__/event-handler-verbatim.test.ts +73 -0
  115. package/src/__tests__/expression-parser.test.ts +1 -44
  116. package/src/__tests__/loop-param-accessor-key-member-safety.test.ts +90 -31
  117. package/src/__tests__/loop-plan.test.ts +131 -1
  118. package/src/__tests__/loop-row-child-children-handler.test.ts +129 -0
  119. package/src/__tests__/loop-row-child-children-inner-loop-shadow.test.ts +74 -0
  120. package/src/__tests__/loop-row-child-children-ref.test.ts +117 -0
  121. package/src/__tests__/nullable-signal-attr.test.ts +67 -3
  122. package/src/__tests__/props-alias-const.test.ts +60 -1
  123. package/src/__tests__/props-named-callback-param.test.ts +256 -0
  124. package/src/__tests__/reference-graph-identifiers.test.ts +161 -0
  125. package/src/__tests__/renamed-body-destructure-template.test.ts +86 -0
  126. package/src/__tests__/rewrite-props-object.test.ts +90 -0
  127. package/src/__tests__/runtime-import-detection.test.ts +134 -0
  128. package/src/__tests__/signal-prop-name-collision.test.ts +30 -0
  129. package/src/__tests__/ssr-defaults.test.ts +19 -1
  130. package/src/__tests__/ssr-seed-plan.test.ts +119 -0
  131. package/src/__tests__/style-object-plan.test.ts +54 -0
  132. package/src/__tests__/written-binding-substitution.test.ts +430 -0
  133. package/src/__tests__/zero-param-helper-inline.test.ts +57 -0
  134. package/src/adapters/callback-method.ts +48 -10
  135. package/src/adapters/component-props.ts +130 -12
  136. package/src/adapters/dsl-template-adapter.ts +259 -0
  137. package/src/adapters/jsx-adapter.ts +12 -6
  138. package/src/adapters/literal-value.ts +2 -2
  139. package/src/adapters/loop-plan.ts +201 -13
  140. package/src/adapters/parsed-expr-emitter.ts +67 -0
  141. package/src/adapters/style-object.ts +61 -0
  142. package/src/analyzer.ts +396 -16
  143. package/src/assignment-target.ts +79 -0
  144. package/src/children-nullish.ts +33 -0
  145. package/src/debug.ts +2 -2
  146. package/src/errors.ts +23 -0
  147. package/src/expression-parser.ts +56 -53
  148. package/src/free-refs.ts +28 -17
  149. package/src/index.ts +31 -10
  150. package/src/ir-to-client-js/compute-inlinability.ts +35 -5
  151. package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +21 -5
  152. package/src/ir-to-client-js/control-flow/plan/event-collision.ts +2 -1
  153. package/src/ir-to-client-js/control-flow/plan/insert.ts +2 -2
  154. package/src/ir-to-client-js/control-flow/plan/loop.ts +25 -1
  155. package/src/ir-to-client-js/control-flow/shared.ts +41 -3
  156. package/src/ir-to-client-js/control-flow/stringify/component-loop.ts +23 -3
  157. package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +3 -2
  158. package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +13 -12
  159. package/src/ir-to-client-js/csr-substitute.ts +82 -24
  160. package/src/ir-to-client-js/emit-reactive.ts +3 -3
  161. package/src/ir-to-client-js/emit-registration.ts +34 -58
  162. package/src/ir-to-client-js/generate-init.ts +17 -1
  163. package/src/ir-to-client-js/html-template.ts +48 -57
  164. package/src/ir-to-client-js/identifiers.ts +75 -24
  165. package/src/ir-to-client-js/imports.ts +56 -19
  166. package/src/ir-to-client-js/index.ts +2 -1
  167. package/src/ir-to-client-js/phases/event-handlers.ts +2 -2
  168. package/src/ir-to-client-js/phases/props-extraction.ts +39 -17
  169. package/src/ir-to-client-js/plan/build-declaration-emit.ts +2 -2
  170. package/src/ir-to-client-js/plan/build-static-array-child-init.ts +7 -0
  171. package/src/ir-to-client-js/plan/static-array-child-init.ts +8 -0
  172. package/src/ir-to-client-js/prune-unused-prop-extractions.ts +7 -4
  173. package/src/ir-to-client-js/reactivity.ts +2 -2
  174. package/src/ir-to-client-js/rewrite-destructured-props.ts +22 -5
  175. package/src/ir-to-client-js/rewrite-props-object.ts +14 -8
  176. package/src/ir-to-client-js/safe-html.ts +29 -35
  177. package/src/ir-to-client-js/stringify/static-array-child-init.ts +4 -1
  178. package/src/ir-to-client-js/types.ts +3 -2
  179. package/src/ir-to-client-js/utils.ts +42 -122
  180. package/src/jsx-to-ir.ts +310 -90
  181. package/src/nullable-signal-attr.ts +149 -33
  182. package/src/prop-rewrite.ts +72 -72
  183. package/src/props-binding.ts +90 -3
  184. package/src/scanner/__tests__/js-scanner.test.ts +37 -0
  185. package/src/scanner/js-scanner.ts +64 -4
  186. package/src/scope/binding-scope.ts +34 -3
  187. package/src/scope/lexical-scope-walk.ts +167 -0
  188. package/src/signal-prop-name-collision.ts +50 -24
  189. package/src/ssr-defaults.ts +47 -20
  190. package/src/ssr-seed-plan.ts +103 -23
  191. package/src/types.ts +140 -20
  192. package/src/value-references.ts +132 -0
@@ -50,23 +50,29 @@ export interface CallbackEvalPlan {
50
50
  operands: CallbackEvalOperand[];
51
51
  captured: string[];
52
52
  }
53
- /** A lowered callback method call, as data. */
54
- export type CallbackPlan = CallbackEvalPlan
53
+ /**
54
+ * A lowered `.sort` / `.toSorted` comparator: the evaluator call, the
55
+ * structured `{keys: …}` descriptor for a comparator the evaluator cannot
56
+ * model, or BF101.
57
+ */
58
+ export type SortPlan = CallbackEvalPlan
55
59
  /** A comparator the evaluator cannot model but the `{keys: …}` descriptor can. */
56
60
  | {
57
61
  kind: 'structured-sort';
58
62
  comparator: SortComparator;
59
- }
63
+ } | {
64
+ kind: 'refuse';
65
+ message: string;
66
+ suggestion: string;
67
+ };
68
+ /** A lowered callback method call, as data. */
69
+ export type CallbackPlan = SortPlan
60
70
  /** A predicate for the adapter's own native form (see `nativePredicate`). */
61
71
  | {
62
72
  kind: 'native-predicate';
63
73
  method: PredicateMethod;
64
74
  param: string;
65
75
  predicate: ParsedExpr;
66
- } | {
67
- kind: 'refuse';
68
- message: string;
69
- suggestion: string;
70
76
  }
71
77
  /** A method outside `CALLBACK_METHODS`; unreachable, as the parser recognises only those. */
72
78
  | {
@@ -85,6 +91,12 @@ export interface CallbackLoweringOptions {
85
91
  }
86
92
  /** Lower `<recv>.<method>(arrow, ...restArgs)`. */
87
93
  export declare function lowerCallbackMethod(method: string, arrow: Arrow, restArgs: readonly ParsedExpr[], options: CallbackLoweringOptions): CallbackPlan;
94
+ /**
95
+ * Lower a `.sort` / `.toSorted` comparator: the evaluator first, then the
96
+ * structured `{keys: …}` descriptor, otherwise BF101. A loop source's sort
97
+ * (`planLoop`) and `.sort(cmp)` at an expression position decide the same.
98
+ */
99
+ export declare function lowerSortComparator(method: 'sort' | 'toSorted', arrow: Arrow, adapterName: string): SortPlan;
88
100
  /**
89
101
  * The evaluator plan for a sort comparator, or `null` when the body is
90
102
  * outside the evaluator surface (a `localeCompare` comparator) or the arrow
@@ -141,6 +153,23 @@ export declare function unloweredCallRefusal(callee: ParsedExpr, args: readonly
141
153
  message: string;
142
154
  suggestion: string;
143
155
  };
156
+ /**
157
+ * BF101 for a `.filter(...).map(...)` predicate shape a DSL adapter's filter
158
+ * emitter has no form for: a conditional, a template literal, an object
159
+ * literal, a standalone arrow or regex, or an unsupported node (#3534). The
160
+ * emitters used to stand a truthy constant in for these, so every row
161
+ * rendered; the same predicate outside a loop is evaluated or refused, never
162
+ * guessed.
163
+ */
164
+ export declare function filterPredicateShapeRefusal(shape: string, adapterName: string): {
165
+ message: string;
166
+ suggestion: string;
167
+ };
168
+ /** BF101 for a loop filter whose predicate never reached the IR (#3534). */
169
+ export declare function missingFilterPredicateRefusal(raw: string, adapterName: string): {
170
+ message: string;
171
+ suggestion: string;
172
+ };
144
173
  /**
145
174
  * The BF101 for a callback method nested inside a filter predicate, which a
146
175
  * predicate emitter has no scalar form for.
@@ -1 +1 @@
1
- {"version":3,"file":"callback-method.d.ts","sourceRoot":"","sources":["../../src/adapters/callback-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAA;AAEhC,KAAK,KAAK,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAA;AAEnD,mDAAmD;AACnD,MAAM,MAAM,eAAe,GACvB,QAAQ,GACR,OAAO,GACP,MAAM,GACN,MAAM,GACN,WAAW,GACX,UAAU,GACV,eAAe,CAAA;AAYnB,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,eAAe,CAE3E;AAED,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,GAC1B,WAAW,GACX,aAAa,GACb,aAAa,GACb,YAAY,GACZ,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,eAAe,GACf,UAAU,CAAA;AAEd,uEAAuE;AACvE,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACnC,sCAAsC;GACpC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAEvC;;;;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E,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAKvH;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAKlH"}
@@ -5,15 +5,19 @@
5
5
  * Every DSL adapter assembles them the same way: callback props and `ref`
6
6
  * are client-only and dropped; a named JSX-valued prop is captured as
7
7
  * HTML; `{...props}` (the component's own props object, which no DSL scope
8
- * holds as one value) enumerates the props params; any other spread is
9
- * folded in at its source position, so a later entry wins on a key
10
- * conflict, as in `{...a, ...b}`; then the compiler-controlled `_bf_slot`
11
- * and `children` entries come last, so a spread can never override them.
8
+ * holds as one value) enumerates the props params, and a param that
9
+ * something earlier in the call may have set is carried only when the
10
+ * caller passed it ({@link propsSpreadParam}); any other spread is folded
11
+ * in at its source position, so a later entry wins on a key conflict, as in
12
+ * `{...a, ...b}`; then the compiler-controlled `_bf_slot` and `children`
13
+ * entries come last, so a spread can never override them.
12
14
  * {@link planComponentProps} makes those decisions once. An adapter spells
13
15
  * the entries and spreads through {@link spellComponentProps}, keeps its
14
16
  * own capture mechanism (`{% set %}…{% endset %}`, `_erbout.slice!`,
15
17
  * `begin … end`, a Kolon macro), and folds the spelled segments into its
16
- * own hash literal.
18
+ * own hash literal. An adapter that builds the child's input as a typed
19
+ * literal at compile time instead (Go's `<Child>Input{...}`) reads the same
20
+ * plan one key at a time through {@link resolveComponentPropKeys}.
17
21
  */
18
22
  import type { AttrValue, IRComponent, IRNode, SpreadAttr } from '../types.ts';
19
23
  /** One entry of the props hash. */
@@ -45,31 +49,69 @@ export type ComponentPropEntry =
45
49
  kind: 'children';
46
50
  children: IRNode[];
47
51
  };
48
- /** A run of entries, or a spread folded in at its source position. */
52
+ /**
53
+ * A run of entries, a spread folded in at its source position, or one param
54
+ * of `{...props}` that the spread carries only when the caller passed it
55
+ * ({@link propsSpreadParam}). An adapter folds a `present-param` in like a
56
+ * spread of a one-key (or empty) hash.
57
+ */
49
58
  export type ComponentPropSegment = {
50
59
  kind: 'entries';
51
60
  entries: ComponentPropEntry[];
52
61
  } | {
53
62
  kind: 'spread';
54
63
  value: SpreadAttr;
64
+ } | {
65
+ kind: 'present-param';
66
+ name: string;
55
67
  };
68
+ /** A props param as `{...props}` enumerates it. */
69
+ export interface ComponentPropsParam {
70
+ name: string;
71
+ /** `false` for a required param, which the caller always passes. Unknown counts as optional. */
72
+ optional?: boolean;
73
+ }
56
74
  export interface ComponentPropsOptions {
57
75
  /** The SolidJS-style props identifier (`function C(props: P)`), if any. */
58
76
  propsObjectName: string | null;
59
77
  /** The analyzer-extracted props params, which `{...props}` enumerates. */
60
- propsParams: ReadonlyArray<{
61
- name: string;
62
- }>;
78
+ propsParams: ReadonlyArray<ComponentPropsParam>;
63
79
  }
80
+ /** What a call has set before a `{...props}` spread, as far as the compiler can see. */
81
+ export interface EarlierComponentProps {
82
+ /** The keys an earlier entry sets. */
83
+ keys: ReadonlySet<string>;
84
+ /** Whether an earlier spread whose keys are unknown may have set any key. */
85
+ spread: boolean;
86
+ }
87
+ /**
88
+ * How `{...props}` carries one param. JS spreads only the keys the props
89
+ * object has, so a param the caller left out keeps whatever an earlier entry
90
+ * or spread set: `<Tag size="s" {...props} />` keeps `size="s"` when the
91
+ * caller passes no `size`.
92
+ *
93
+ * - `'entry'`: an ordinary entry. Either nothing earlier can set the key, so
94
+ * an absent param and a nil one read the same to the child, or the param is
95
+ * required, so the caller always passes it and it always wins.
96
+ * - `'present'`: carried only when the caller passed it, so an absent param
97
+ * leaves the earlier value alone.
98
+ *
99
+ * A template backend reads an absent prop and an explicit `undefined` or
100
+ * `null` one as the same nil, so "passed" is spelled "not nil" there: a
101
+ * caller that passes `undefined`/`null` keeps the earlier value, where JS
102
+ * would override it with the nil (limitation
103
+ * `props-spread-explicit-null-override`).
104
+ */
105
+ export declare function propsSpreadParam(param: ComponentPropsParam, earlier: EarlierComponentProps): 'entry' | 'present';
64
106
  /** The key an entry sets in the props hash. */
65
107
  export declare function componentPropKey(entry: ComponentPropEntry): string;
66
108
  /**
67
109
  * The ordered props segments for `comp`. The first segment is always an
68
- * (possibly empty) entries segment, and a spread is followed by a new one
69
- * only when an entry comes after it.
110
+ * (possibly empty) entries segment, and a spread or a `present-param` is
111
+ * followed by a new one only when an entry comes after it.
70
112
  */
71
- export declare function planComponentProps(comp: IRComponent, options: ComponentPropsOptions): ComponentPropSegment[];
72
- /** A spelled segment: the entries' hash-literal parts, or the spread's expression. */
113
+ export declare function planComponentProps(comp: Pick<IRComponent, 'props' | 'children' | 'slotId' | 'loopItemRoot'>, options: ComponentPropsOptions): ComponentPropSegment[];
114
+ /** A spelled segment: the entries' hash-literal parts, or the expression a spread folds in. */
73
115
  export type SpelledComponentPropSegment = {
74
116
  kind: 'entries';
75
117
  parts: string[];
@@ -82,12 +124,37 @@ export interface ComponentPropSpelling {
82
124
  entry(entry: ComponentPropEntry): string;
83
125
  /** The expression a spread folds in. */
84
126
  spread(value: SpreadAttr): string;
127
+ /**
128
+ * The expression a `present-param` segment folds in like a spread: a
129
+ * one-key hash `{ name: <param> }` when the param is not nil, an empty
130
+ * hash when it is.
131
+ */
132
+ presentParam(name: string): string;
85
133
  }
86
134
  /**
87
135
  * Spell a plan in source order, so the captures an entry's spelling emits
88
136
  * (named slots, then the children) keep their order and counter values.
89
137
  */
90
138
  export declare function spellComponentProps(segments: readonly ComponentPropSegment[], spelling: ComponentPropSpelling): SpelledComponentPropSegment[];
139
+ /**
140
+ * One key of the props hash, resolved at compile time: the latest of
141
+ * `presentParams` the caller passed, else `base`.
142
+ */
143
+ export interface ResolvedComponentProp {
144
+ key: string;
145
+ /** The last entry that sets the key unconditionally, or null when none does. */
146
+ base: ComponentPropEntry | null;
147
+ /** The `{...props}` params that override `base` when passed, earliest first. */
148
+ presentParams: string[];
149
+ }
150
+ /**
151
+ * A plan resolved one key at a time, in the order the keys are first set,
152
+ * for an adapter that builds the child's input as a typed literal at
153
+ * compile time rather than merging hashes at render time. Null when the
154
+ * plan folds in a spread whose keys are unknown: only a render-time merge
155
+ * can resolve that.
156
+ */
157
+ export declare function resolveComponentPropKeys(segments: readonly ComponentPropSegment[]): ResolvedComponentProp[] | null;
91
158
  /** Whether a spelled plan passes no props at all. */
92
159
  export declare function isEmptyComponentProps(segments: readonly SpelledComponentPropSegment[]): boolean;
93
160
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"component-props.d.ts","sourceRoot":"","sources":["../../src/adapters/component-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7E,mCAAmC;AACnC,MAAM,MAAM,kBAAkB;AAC5B,gFAAgF;AAC9E;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE;AACnD,wFAAwF;GACtF;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE;AAC1D,8FAA8F;GAC5F;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AACvC,yEAAyE;GACvE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACrC,gGAAgG;GAC9F;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAE5C,sEAAsE;AACtE,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,kBAAkB,EAAE,CAAA;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AAqB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,gFAAgF;IAChF,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;IAC/B,gFAAgF;IAChF,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,GAAG,qBAAqB,EAAE,GAAG,IAAI,CAuBlH;AAED,qDAAqD;AACrD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,2BAA2B,EAAE,GAAG,OAAO,CAE/F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAM3G"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * The `generate()` the eight DSL template adapters (Blade, ERB, Jinja,
3
+ * Mojolicious, Pebble, MiniJinja, Twig, Xslate) share (#3475), with the
4
+ * per-compile state it sets up. Each adapter renders the nodes in its own
5
+ * template language; how one compile begins and ends lives here once.
6
+ */
7
+ import { type LoweringMatcher } from '../lowering-registry.ts';
8
+ import { type NullishAttrContext } from '../nullable-signal-attr.ts';
9
+ import { BindingScope } from '../scope/binding-scope.ts';
10
+ import type { CompilerError, ComponentIR, IRIfStatement, IRMetadata } from '../types.ts';
11
+ import { type ComputedConstContext } from './computed-const.ts';
12
+ import { BaseAdapter, type AdapterGenerateOptions, type AdapterOutput } from './interface.ts';
13
+ /**
14
+ * How an adapter that renames reserved names spells a source identifier as
15
+ * a template variable, and the engine name its collision diagnostic uses.
16
+ */
17
+ export interface TemplateIdentifierSpelling {
18
+ /** The adapter's mangling (`jinjaIdent`, `twigIdent`, …). */
19
+ ident(name: string): string;
20
+ /** The engine name in the diagnostic ("Jinja", "MiniJinja", …). */
21
+ label: string;
22
+ }
23
+ export declare abstract class DslTemplateAdapter extends BaseAdapter {
24
+ protected componentName: string;
25
+ /** Diagnostics collected while rendering, merged into `ir.errors` at the end. */
26
+ protected errors: CompilerError[];
27
+ /**
28
+ * SolidJS-style props identifier (`function(props: P)`). The spread
29
+ * emission builds a props-object bag from it without re-walking the IR.
30
+ */
31
+ protected propsObjectName: string | null;
32
+ /**
33
+ * Name of the destructured `...rest` binding (`function X({ ...rest })`),
34
+ * if any. A closed-type rest-expanded attribute's expression is
35
+ * `${restPropsName}.${key}` (`expandSpreadAttribute`, #3057). Stripping
36
+ * this prefix the same way `propsObjectName.` is stripped lets the
37
+ * nullable-optional-props guard recognise it as a bare optional reference
38
+ * instead of falling through to unconditional emission.
39
+ */
40
+ protected restPropsName: string | null;
41
+ protected propsParams: {
42
+ name: string;
43
+ optional: boolean;
44
+ }[];
45
+ /** Props whose declared TS type is boolean (`collectBooleanTypedProps`). */
46
+ protected booleanTypedProps: Set<string>;
47
+ /** Names (signal getters + props) whose value is a string (`stringValueNamesFor`). */
48
+ protected stringValueNames: Set<string>;
49
+ /**
50
+ * Module-scope pure-string consts (`const x = 'literal'`), keyed by name →
51
+ * unescaped value. A className template literal that references such a
52
+ * const (`className={`${x} ${className}`}`) must inline the literal: the
53
+ * const is module-scope, so it never reaches the per-render context.
54
+ */
55
+ protected moduleStringConsts: Map<string, string>;
56
+ /**
57
+ * (#1922) Local binding names the request-scoped `searchParams()` env
58
+ * signal is imported under (handles `import { searchParams as sp }`). When
59
+ * non-empty the emitter lowers a `<binding>().get(k)` call to a real method
60
+ * call on the per-request `searchParams` reader instead of the generic
61
+ * deref. Read by the top-level ParsedExpr emitter.
62
+ */
63
+ protected _searchParamsLocals: Set<string>;
64
+ /**
65
+ * Call-lowering matchers active for this component (#2057), read by the
66
+ * top-level emitter. Covers both userland plugins and the compiler's
67
+ * built-in plugins (e.g. `queryHref`, #2042): one uniform path, no per-API
68
+ * branch.
69
+ */
70
+ protected _loweringMatchers: LoweringMatcher[];
71
+ /** The component's computed consts, inlined where a template reads them (#3494). */
72
+ protected computedConsts: ComputedConstContext | null;
73
+ /**
74
+ * Local + module constants from the IR, used by the conditional-spread and
75
+ * `Record<staticKeys, scalar>[propKey]` lowering paths (#textarea /
76
+ * #checkbox): the spread emission resolves a bare local const
77
+ * (`const sizeAttrs = size ? {…} : {}`) to its initializer text.
78
+ */
79
+ protected localConstants: IRMetadata['localConstants'];
80
+ /** Each prop's collision-free root alias (#3314), decided once per component. */
81
+ protected rootPropAliases: ReadonlyMap<string, string>;
82
+ /**
83
+ * The one canonical, position-accurate "names bound by an enclosing loop
84
+ * callback" service (#2482 Stage 2). Every shadow-guard site reads this
85
+ * one threaded, immutable scope: `renderLoop` enters the row with
86
+ * `enterLoopRow` around the loop's children and restores the outer scope
87
+ * by reference afterwards, mirroring `ctx.scope` in `jsx-to-ir.ts`.
88
+ * `IRLoop` structurally satisfies `LoopBindingSource`, so `renderLoop`
89
+ * passes the loop node straight to `enterLoopRow`.
90
+ */
91
+ protected scope: BindingScope;
92
+ /**
93
+ * Optional, no-default props that are absent when the caller omits them
94
+ * (`collectNullableOptionalProps`). A bare-reference attribute of one is
95
+ * guarded with the template's presence test, so the attribute drops rather
96
+ * than rendering `attr=""` (Hono-style nullish omission, e.g. textarea's
97
+ * `rows`).
98
+ */
99
+ protected nullableOptionalProps: Set<string>;
100
+ /** Getters of nullable signals (`collectNullableSignalGetters`, #3304). */
101
+ protected nullableSignalGetters: Set<string>;
102
+ /** Signals and memos `attrValueMayBeNullish` reads (#3322). */
103
+ protected nullishAttrCtx: NullishAttrContext;
104
+ /**
105
+ * Local alias -> declared/exported name for imported components (#2822,
106
+ * the SSR-side counterpart of #2777's client-JS registry-key fix). A child
107
+ * referenced under an import alias (`import { Foo as Bar }`, `<Bar/>`)
108
+ * must build its cross-template call against the child's own declared
109
+ * name (`Foo`, what `foo.tsx` registers its template as), never the
110
+ * caller-local binding. Read by `childTemplateName`.
111
+ */
112
+ protected importAliases: Map<string, string>;
113
+ /** Numbers the children captures of a child component that has no slot id. */
114
+ protected childrenCaptureCounter: number;
115
+ /** The adapter's name in the BF103 imported-loop-child diagnostic ("The Jinja adapter emits …"). */
116
+ protected abstract readonly loopChildDiagnosticName: string;
117
+ /**
118
+ * For an adapter that renames reserved names: two source names the
119
+ * renaming turns into one template variable would read the same value, so
120
+ * `generate()` refuses them (#3404). `null` when the adapter renames none.
121
+ */
122
+ protected readonly templateIdentifierSpelling: TemplateIdentifierSpelling | null;
123
+ /** The names whose value is a string, for `stringValueNames`. */
124
+ protected abstract stringValueNamesFor(ir: ComponentIR): Set<string>;
125
+ /**
126
+ * Sets the adapter's own per-compile state. Runs after the shared state
127
+ * above and before any diagnostic or rendering.
128
+ */
129
+ protected resetAdapterState(_ir: ComponentIR): void;
130
+ /** `render()` under `scope`, the current scope restored afterwards. */
131
+ protected renderInScope<T>(scope: BindingScope, render: () => T): T;
132
+ /** The root `if` statement of a component with conditional returns. */
133
+ protected abstract renderIfStatement(ifStmt: IRIfStatement): string;
134
+ /** The script registrations the template starts with. */
135
+ protected abstract generateScriptRegistrations(ir: ComponentIR, scriptBaseName?: string, scriptAssets?: string[], preloadAssets?: string[]): string;
136
+ /**
137
+ * SSR context consumers (`const x = useContext(Ctx)`): seeds each local
138
+ * from the active provider value, or the `createContext` default. The
139
+ * provider side pushes the value via `emitProvider` (#1297).
140
+ */
141
+ protected abstract contextConsumerSeed(ir: ComponentIR): string;
142
+ /**
143
+ * Prop/signal-derived memos with a `null` static SSR default (e.g.
144
+ * `createMemo(() => props.value * 10)`), computed in-template from the
145
+ * already-seeded prop/signal vars, mirroring Go's generated child
146
+ * constructor (#1297).
147
+ */
148
+ protected abstract derivedMemoSeed(ir: ComponentIR): string;
149
+ generate(ir: ComponentIR, options?: AdapterGenerateOptions): AdapterOutput;
150
+ private resetCompileState;
151
+ private collectCompileErrors;
152
+ }
153
+ //# sourceMappingURL=dsl-template-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dsl-template-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/dsl-template-adapter.ts"],"names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AE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAQlE;IACD,uEAAuE;IACvE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAA;IACnE,yDAAyD;IACzD,SAAS,CAAC,QAAQ,CAAC,2BAA2B,CAC5C,EAAE,EAAE,WAAW,EACf,cAAc,CAAC,EAAE,MAAM,EACvB,YAAY,CAAC,EAAE,MAAM,EAAE,EACvB,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,MAAM,CAAA;IACT;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAAA;IAC/D;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,CAAA;IAE3D,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,aAAa,CA4BzE;IAED,OAAO,CAAC,iBAAiB;IA6BzB,OAAO,CAAC,oBAAoB;CAgB7B"}
@@ -124,6 +124,10 @@ export declare abstract class JsxAdapter extends BaseAdapter {
124
124
  * `expr` (a presence peel, a prop-ref rewrite) fails the identity check
125
125
  * and wins, so this can only ever add the annotation, never undo a
126
126
  * downstream edit.
127
+ *
128
+ * The same identity rule brings back the author's own type syntax
129
+ * (`value={store as never}`, #2573): `typed.tsx` is written only while
130
+ * `expr` is still the text it was captured beside.
127
131
  */
128
132
  protected expressionValueToJs(value: Extract<AttrValue, {
129
133
  kind: 'expression';
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/jsx-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,MAAM,EACN,cAAc,EACd,eAAe,EAChB,MAAM,aAAa,CAAA;AAIpB,O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AC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C;IAMD;;;;;OAKG;IACH,SAAS,CAAC,uBAAuB,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAE1E;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE;QAAE,IAAI,EAAE,YAAY,CAAA;KAAE,CAAC,GAAG,MAAM,CAYvF;IAMD,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEhD;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;CACF"}
@@ -7,11 +7,11 @@
7
7
  * literal index from a variable one with {@link isLiteralIndex}.
8
8
  */
9
9
  import type { ParsedExpr } from '../expression-parser.ts';
10
- import type { TypeInfo } from '../types.ts';
10
+ import type { TypeInfo, JsSourceText } from '../types.ts';
11
11
  /** True when `type` is the `string` primitive. */
12
12
  export declare function isStringTypeInfo(type: TypeInfo | undefined): boolean;
13
13
  /** True when `initialValue` is a bare string-literal expression. */
14
- export declare function isBareStringLiteral(initialValue: string | undefined): boolean;
14
+ export declare function isBareStringLiteral(initialValue: JsSourceText | undefined): boolean;
15
15
  /**
16
16
  * True when a parsed index is a numeric or string literal (`arr[0]`,
17
17
  * `m['k']`). The spread lowerings refuse (BF101) an indexed spread value
@@ -1 +1 @@
1
- {"version":3,"file":"literal-value.d.ts","sourceRoot":"","sources":["../../src/adapters/literal-value.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,kDAAkD;AAClD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAEpE;AAED,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAI7E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAKzD"}
1
+ {"version":3,"file":"literal-value.d.ts","sourceRoot":"","sources":["../../src/adapters/literal-value.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEzD,kDAAkD;AAClD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAEpE;AAED,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAInF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAKzD"}
@@ -4,15 +4,18 @@
4
4
  * Every DSL adapter decides the same things about a `.map()` loop before it
5
5
  * spells a line of template: whether its destructure pattern lowers (BF104),
6
6
  * whether the source is a static literal, whether it names a computed const
7
- * no template binds (BF101), how its `.sort` comparator lowers, and which
8
- * filter captures need an alias. {@link planLoop} makes those decisions once,
9
- * against the scope outside the loop. The adapter keeps the spelling: the
10
- * loop header, the row bindings, the diagnostics' wording, and the order it
11
- * emits them in.
7
+ * no template binds (BF101), how its `.sort` comparator lowers, which filter
8
+ * captures need an alias, how the filter predicate reads on the row, and
9
+ * which locals the row binds for its index and its destructure bindings.
10
+ * {@link planLoop} makes those decisions once, against the scope outside the
11
+ * loop. The adapter keeps the spelling:
12
+ * the loop header, the row bindings, the diagnostics' wording, and the order
13
+ * it emits them in.
12
14
  */
15
+ import { type ParsedExpr, type SortComparator } from '../expression-parser.ts';
13
16
  import type { BindingScope } from '../scope/binding-scope.ts';
14
- import type { ConstantInfo, IRLoop } from '../types.ts';
15
- import { type CallbackLoweringOptions, type CallbackPlan } from './callback-method.ts';
17
+ import type { ConstantInfo, IRLoop, LoopBindingPathSegment } from '../types.ts';
18
+ import { type CallbackEvalSpelling, type CallbackLoweringOptions, type SortPlan } from './callback-method.ts';
16
19
  export interface LoopPlanContext<Spelled> {
17
20
  /** The scope outside the loop. */
18
21
  scope: BindingScope;
@@ -40,14 +43,135 @@ export interface LoopPlan<Spelled> {
40
43
  * name is the row's value, not the const (#3473).
41
44
  */
42
45
  unresolvableConst: ConstantInfo | null;
43
- /** The `.sort` / `.toSorted` comparator's lowering, or `null` without one. */
44
- sort: CallbackPlan | null;
46
+ /**
47
+ * The `.sort` / `.toSorted` comparator's lowering, or `null` without one:
48
+ * the evaluator, the structured `{keys: …}` descriptor, or BF101, the same
49
+ * chain as `.sort(cmp)` at an expression position.
50
+ */
51
+ sort: SortPlan | null;
45
52
  /** The filter predicate's captures that a row binding would shadow, each with its alias. */
46
53
  captureAliases: Array<{
47
54
  name: string;
48
55
  alias: string;
49
56
  }>;
57
+ /** The `.filter()` predicate of a `.filter().map()` loop, or `null` without one. */
58
+ filter: LoopFilterPlan | null;
59
+ /**
60
+ * The for-target of an array iteration: the param itself, or the synthetic
61
+ * `__bf_item` when the param is not the item (a `.keys()` iteration, whose
62
+ * param is the index, or a lowered destructure, whose bindings read off it).
63
+ */
64
+ itemVar: string;
65
+ /**
66
+ * The name a local binds to the row's 0-based index in an array iteration:
67
+ * a `.keys()` iteration's param, else the explicit index param. `null` for
68
+ * an object iteration, whose key the header binds.
69
+ */
70
+ indexLocal: string | null;
71
+ /** One local per binding of a lowered destructure, in pattern order. */
72
+ destructureLocals: Array<{
73
+ name: string;
74
+ value: DestructureValue;
75
+ }>;
76
+ }
77
+ /**
78
+ * What a lowered destructure binding reads off the row item: the value at
79
+ * `segments`, or for a rest binding the residual of the value there (the
80
+ * array from `from` on, or the object without the `exclude` keys).
81
+ */
82
+ export type DestructureValue = {
83
+ kind: 'path';
84
+ segments: readonly LoopBindingPathSegment[];
85
+ } | {
86
+ kind: 'slice';
87
+ segments: readonly LoopBindingPathSegment[];
88
+ from: number;
89
+ } | {
90
+ kind: 'omit';
91
+ segments: readonly LoopBindingPathSegment[];
92
+ exclude: readonly string[];
93
+ };
94
+ /** An adapter's spelling of a {@link DestructureValue}. */
95
+ export interface DestructureSpelling {
96
+ /** The value at `segments` off `item`. */
97
+ accessor(item: string, segments: readonly LoopBindingPathSegment[]): string;
98
+ /** The array `parent` from index `from` on. */
99
+ slice(parent: string, from: number): string;
100
+ /** The object `parent` without the `keys`. */
101
+ omit(parent: string, keys: readonly string[]): string;
102
+ }
103
+ /** Spell each destructure local's value off the row item `item`. */
104
+ export declare function spellDestructureLocals(plan: Pick<LoopPlan<unknown>, 'destructureLocals'>, item: string, spelling: DestructureSpelling): Array<{
105
+ name: string;
106
+ value: string;
107
+ }>;
108
+ /** An adapter's spelling of a {@link SortPlan} over the loop source. */
109
+ export interface LoopSortSpelling {
110
+ /** A captured name's SSR value, for the evaluator's env. */
111
+ emit(e: ParsedExpr): string;
112
+ /** The evaluator call. */
113
+ eval: CallbackEvalSpelling;
114
+ /** The structured `bf.sort` call over `recv` with the `{keys: …}` descriptor. */
115
+ structured(recv: string, comparator: SortComparator): string;
116
+ /** Record the refusal of a comparator neither form models (BF101). */
117
+ refuse(message: string, suggestion: string): void;
50
118
  }
119
+ /**
120
+ * The loop source `recv` sorted by the loop's comparator, or `recv` itself
121
+ * without one. A refused comparator is recorded and leaves `recv` unsorted,
122
+ * so the template stays valid.
123
+ */
124
+ export declare function spellSortedSource(sort: SortPlan | null, recv: string, spelling: LoopSortSpelling): string;
125
+ /**
126
+ * The `.filter()` predicate a `.filter().map()` loop tests on each row: the
127
+ * predicate with the names it reads renamed for the row, or the refusal of a
128
+ * filter whose predicate never reached the IR (BF101, #3534).
129
+ */
130
+ export type LoopFilterPlan = LoopFilterPredicate | {
131
+ kind: 'refuse';
132
+ message: string;
133
+ suggestion: string;
134
+ };
135
+ export interface LoopFilterPredicate {
136
+ kind: 'predicate';
137
+ /** The filter callback's own param. */
138
+ param: string;
139
+ /** The predicate as written. */
140
+ predicate: ParsedExpr;
141
+ /**
142
+ * The predicate with each capture a row binding would shadow renamed to
143
+ * its alias (`captureAliases`), for an emitter that maps the filter param
144
+ * itself (#3402).
145
+ */
146
+ captured: ParsedExpr;
147
+ /**
148
+ * `captured` with the filter param renamed to the loop param too: the
149
+ * predicate read off the row item. The tree is renamed, not the rendered
150
+ * text, so a string literal or a property key of the same spelling stays
151
+ * (#3404).
152
+ */
153
+ onRow: ParsedExpr;
154
+ /** Each capture alias and the enclosing name it keeps, for the scope the predicate renders under. */
155
+ aliases: ReadonlyMap<string, string>;
156
+ }
157
+ /** An adapter's spelling of a {@link LoopFilterPlan}. */
158
+ export interface LoopFilterSpelling {
159
+ /** The row's condition for a predicate. */
160
+ condition(filter: LoopFilterPredicate): string;
161
+ /** Record the refusal of a filter without a predicate. */
162
+ refuse(message: string, suggestion: string): void;
163
+ /** The condition that stands in for a refused predicate, so the template stays valid. */
164
+ refused: string;
165
+ /** The guard's opening line. */
166
+ open(condition: string): string;
167
+ /** The guard's closing line. */
168
+ close: string;
169
+ }
170
+ /**
171
+ * The lines of a loop row: `row` itself, or with a filter `row` inside the
172
+ * guard on the filter's condition.
173
+ */
174
+ export declare function spellFilteredRow(filter: LoopFilterPlan | null, row: readonly string[], spelling: LoopFilterSpelling): string[];
51
175
  /** Plan a loop against the scope outside it. */
52
176
  export declare function planLoop<Spelled>(loop: IRLoop, ctx: LoopPlanContext<Spelled>): LoopPlan<Spelled>;
53
177
  //# sourceMappingURL=loop-plan.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loop-plan.d.ts","sourceRoot":"","sources":["../../src/adapters/loop-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2B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