@barefootjs/go-template 0.18.5 → 0.19.0

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 (36) hide show
  1. package/dist/adapter/analysis/static-child-loop-bake.d.ts +61 -0
  2. package/dist/adapter/analysis/static-child-loop-bake.d.ts.map +1 -0
  3. package/dist/adapter/analysis/static-element-loop-bake.d.ts +83 -0
  4. package/dist/adapter/analysis/static-element-loop-bake.d.ts.map +1 -0
  5. package/dist/adapter/emit-context.d.ts +11 -5
  6. package/dist/adapter/emit-context.d.ts.map +1 -1
  7. package/dist/adapter/go-template-adapter.d.ts +153 -6
  8. package/dist/adapter/go-template-adapter.d.ts.map +1 -1
  9. package/dist/adapter/index.js +514 -53
  10. package/dist/adapter/lib/compile-state.d.ts +24 -0
  11. package/dist/adapter/lib/compile-state.d.ts.map +1 -1
  12. package/dist/adapter/lib/types.d.ts +9 -0
  13. package/dist/adapter/lib/types.d.ts.map +1 -1
  14. package/dist/adapter/props/prop-classes.d.ts +28 -9
  15. package/dist/adapter/props/prop-classes.d.ts.map +1 -1
  16. package/dist/adapter/props/prop-types.d.ts +45 -0
  17. package/dist/adapter/props/prop-types.d.ts.map +1 -1
  18. package/dist/build.js +514 -53
  19. package/dist/conformance-pins.d.ts.map +1 -1
  20. package/dist/index.js +516 -62
  21. package/dist/render-divergences.d.ts.map +1 -1
  22. package/dist/test-render.d.ts.map +1 -1
  23. package/package.json +3 -3
  24. package/src/__tests__/go-template-adapter.test.ts +876 -21
  25. package/src/adapter/analysis/static-child-loop-bake.ts +119 -0
  26. package/src/adapter/analysis/static-element-loop-bake.ts +211 -0
  27. package/src/adapter/emit-context.ts +14 -5
  28. package/src/adapter/go-template-adapter.ts +620 -45
  29. package/src/adapter/lib/compile-state.ts +27 -0
  30. package/src/adapter/lib/types.ts +9 -0
  31. package/src/adapter/props/prop-classes.ts +34 -9
  32. package/src/adapter/props/prop-types.ts +178 -1
  33. package/src/adapter/value/value-lowering.ts +1 -1
  34. package/src/conformance-pins.ts +30 -31
  35. package/src/render-divergences.ts +12 -0
  36. package/src/test-render.ts +127 -10
@@ -46,6 +46,14 @@ export declare class CompileState {
46
46
  * `Record`-index lookups without re-threading the full `ir` through helpers.
47
47
  */
48
48
  localConstants: IRMetadata['localConstants'];
49
+ /**
50
+ * Every name a `.map()`/`.filter()` loop callback binds as its item/index
51
+ * parameter anywhere in the component (#2208 fable review). Consulted by
52
+ * static loop-source resolution (`getBakedStaticChildLoop`) so a const
53
+ * whose name a DIFFERENT, enclosing loop's own callback param shadows is
54
+ * never resolved as that const's static value.
55
+ */
56
+ staticLoopSourceBoundNames: Set<string>;
49
57
  /**
50
58
  * Names of component-scope arrow-const helpers (`const sortClass = …`),
51
59
  * eligible for call-site inlining.
@@ -107,6 +115,22 @@ export declare class CompileState {
107
115
  * whose value is a bare reference to such a prop when it's nil.
108
116
  */
109
117
  nillablePropNames: Set<string>;
118
+ /**
119
+ * OPTIONAL prop names consumed nullish-sensitively (`??` left operand in a
120
+ * parsed expression tree, or a signal's `props.X ?? <literal>` seed) —
121
+ * #2248. Consulted by `resolvePropGoType` to flip an optional scalar to the
122
+ * nillable `interface{}` representation, so it MUST be populated before the
123
+ * first `resolvePropGoType` call of a compile (see `generate()`'s ordering
124
+ * against `collectNillablePropNames`).
125
+ */
126
+ nullishConsumedPropNames: Set<string>;
127
+ /**
128
+ * OPTIONAL no-default prop names consumed as a BARE omittable-attribute
129
+ * value (`rows={rows}`) — #2259. Same `resolvePropGoType` flip and same
130
+ * populate-before-first-resolve ordering as `nullishConsumedPropNames`:
131
+ * the attribute-omission guard (`{{if ne .X nil}}`) needs a nillable field.
132
+ */
133
+ omittableAttrConsumedPropNames: Set<string>;
110
134
  /**
111
135
  * String-typed signal getter / prop names (#2168 string-concat-plus).
112
136
  * Feeds `isStringName` for `isStringConcatBinary`, which decides whether a
@@ -1 +1 @@
1
- {"version":3,"file":"compile-state.d.ts","sourceRoot":"","sources":["../../../src/adapter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MAAM,CAAC,CAAY;IAEvD;;;;;OAKG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAY;IAEzC;gBACY;IACZ,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAY;IAEvC;;4DAEwD;IACxD,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAY;IAIpD;sEACkE;IAClE,gBAAgB,EAAE,OAAO,CAAQ;IAEjC;sCACkC;IAClC,OAAO,EAAE,OAAO,CAAQ;IAExB,uFAAuF;IACvF,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAY;IAEvC,mFAAmF;IACnF,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAY;IAEjD;;;;OAIG;IACH,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAY;IAE/D;;;OAGG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAY;IAEnD;yEACqE;IACrE,kBAAkB,UAAQ;CAC3B"}
@@ -127,6 +127,15 @@ export interface PropFallbackVar {
127
127
  goFallback: string;
128
128
  /** Go zero literal for the prop's type (`0`, `""`, etc.). */
129
129
  zeroLiteral: string;
130
+ /**
131
+ * Set when the prop lowered to the nillable `interface{}` representation
132
+ * (#2248): the concrete scalar Go type (`string`/`int`/`float64`/`bool`)
133
+ * the constructor materializes the hoisted local as. Presence switches
134
+ * the emission from the zero-value check (`if v == 0`) to a nil check
135
+ * (`if in.X != nil`), which is what makes an explicit `''`/`0` input
136
+ * distinguishable from an absent one.
137
+ */
138
+ assertType?: string;
130
139
  }
131
140
  /**
132
141
  * Scope for `lowerCtorExpr` — lowering a JS expression to Go in the
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapter/lib/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAC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us). Pure
7
7
  * function over `ir.metadata`; no adapter instance state.
8
8
  */
9
- import type { ComponentIR } from '@barefootjs/jsx';
9
+ import { type ComponentIR } from '@barefootjs/jsx';
10
10
  /**
11
- * String-typed signals and props. A signal is string-typed when its inferred
12
- * type is `string` (or, defensively, when its initial value is a bare string
13
- * literal); a prop when its annotated type is `string`. Drives `isStringName`
14
- * for `isStringConcatBinary` the shared helper (`@barefootjs/jsx`) that
15
- * decides whether a JS `+` is string concatenation rather than numeric
16
- * addition (Go's `html/template` has no native `+` at all; `binary()` always
17
- * emits a runtime call, `bf_add` for addition or `bf_concat_str` for
18
- * concatenation see `go-template-adapter.ts`'s `binary()`).
11
+ * String-typed signals, props, and same-file local consts (#2212, ported
12
+ * here for #2236). A signal is string-typed when its inferred type is
13
+ * `string` (or, defensively, when its initial value is a bare string
14
+ * literal); a prop when its annotated type is `string`; a local const the
15
+ * same way. Drives `isStringName` for `isStringConcatBinary` the shared
16
+ * helper (`@barefootjs/jsx`) that decides whether a JS `+` is string
17
+ * concatenation rather than numeric addition (Go's `html/template` has no
18
+ * native `+` at all; `binary()` always emits a runtime call, `bf_add` for
19
+ * addition or `bf_concat_str` for concatenation — see
20
+ * `go-template-adapter.ts`'s `binary()`). Local consts matter for exactly
21
+ * the shadowing shape this exclusion exists for: with a loop-bound `label`
22
+ * subtracted, an outer `{label + suffix}` (where `suffix = '!'`) must
23
+ * still classify as string concat via its OTHER operand, or it would fall
24
+ * back to `bf_add` and render `0`.
25
+ *
26
+ * Excludes any name bound as a `.map()`/`.filter()` loop callback's item or
27
+ * index parameter ANYWHERE in the component (#2212, ported here for #2236):
28
+ * this lookup is a flat, scope-blind `Set<string>` with no notion of a loop
29
+ * param shadowing an outer string-typed binding of the same name
30
+ * (`values.map((label) => 1 + label)` inside a component that also has a
31
+ * string `label` prop) — left unguarded, that shadowed `label` would be
32
+ * misdetected as string-typed and `1 + label` would silently lower to
33
+ * `bf_concat_str` instead of staying numeric `bf_add`. Subtracting loop-bound
34
+ * names is coarse (it also suppresses a genuinely non-shadowed same-named
35
+ * string elsewhere in the component) but safe: the suppressed case just
36
+ * falls back to today's numeric `bf_add` — the same, already-accepted
37
+ * residual as an unresolvable operand — never silently-wrong output.
19
38
  */
20
39
  export declare function collectStringValueNames(ir: ComponentIR): Set<string>;
21
40
  //# sourceMappingURL=prop-classes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prop-classes.d.ts","sourceRoot":"","sources":["../../../src/adapter/props/prop-classes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,iBAAiB,CAAA;AAc5D;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAWpE"}
1
+ {"version":3,"file":"prop-classes.d.ts","sourceRoot":"","sources":["../../../src/adapter/props/prop-classes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAyB,KAAK,WAAW,EAAiB,MAAM,iBAAiB,CAAA;AAcxF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAiBpE"}
@@ -13,6 +13,51 @@ import type { GoEmitContext } from '../emit-context.ts';
13
13
  * generic prop types (containing `interface{}`) are overridden.
14
14
  */
15
15
  export declare function buildPropTypeOverrides(ctx: GoEmitContext, ir: ComponentIR): Map<string, string>;
16
+ /**
17
+ * Concrete scalar Go types eligible for the nullish (`??`) nillable flip in
18
+ * `resolvePropGoType`. Only these can round-trip through an `interface{}`
19
+ * field and back via a constructor type assertion / `bf.ToInt`-style
20
+ * coercion (see the fallback-var emission in `generateNewPropsFunction`).
21
+ */
22
+ export declare const NULLISH_SCALAR_GO_TYPES: ReadonlySet<string>;
23
+ /**
24
+ * Names of OPTIONAL props consumed nullish-sensitively — the left operand of
25
+ * a `??` anywhere in the component's parsed expression trees, or a signal's
26
+ * `props.X ?? <literal>` initial value (#2248).
27
+ *
28
+ * Why this matters: JS `??` falls back only on `null`/`undefined`, keeping
29
+ * `''`/`0`/`false`. A Go zero-valued scalar field cannot represent "absent",
30
+ * so a `??`-consumed optional scalar must lower to the adapter's established
31
+ * nillable representation (`interface{}`) for the distinction to exist at
32
+ * render time. `resolvePropGoType` applies that flip using this set.
33
+ *
34
+ * The IR walk is generic (any nested object/array is descended, so parsed
35
+ * trees inside expressions, conditions, attributes, and loops are all seen)
36
+ * and the match is shape-precise: `identifier` left (destructured props) or
37
+ * `<propsObject>.<name>` member left. KNOWN LIMITATION (same class as
38
+ * `collectToFixedPropNames`): an `identifier` left shadowed by a same-named
39
+ * loop/callback param is misattributed to the prop — the flip is then merely
40
+ * unnecessary, not incorrect.
41
+ */
42
+ export declare function collectNullishConsumedPropNames(ctx: GoEmitContext, ir: ComponentIR): Set<string>;
43
+ /**
44
+ * Names of OPTIONAL no-default props consumed as the BARE value of an
45
+ * omittable attribute (`rows={rows}` / `rows={props.rows}`) anywhere in the
46
+ * component's element tree.
47
+ *
48
+ * Why this matters: Hono omits an attribute whose value is `undefined`, and
49
+ * the adapter's `emitExpression` mirrors that with a `{{if ne .X nil}}` guard
50
+ * — which needs a nillable field to test. A concrete scalar field would
51
+ * render the zero value (`rows="0"`) instead of dropping the attribute, so
52
+ * these props take the same `interface{}` flip as `??` consumption
53
+ * (`resolvePropGoType`). The match mirrors `emitExpression`'s guard branch:
54
+ * bare identifiers / `<propsObject>.<name>` only, skipping `class`/`style`
55
+ * (own lowerings) and boolean/presence attrs (truthiness-tested, where a nil
56
+ * and a zero value already coincide). Same shadowing caveat as
57
+ * `collectNullishConsumedPropNames`: a same-named loop/callback param can
58
+ * misattribute, making the flip merely unnecessary, not incorrect.
59
+ */
60
+ export declare function collectOmittableAttrConsumedPropNames(ctx: GoEmitContext, ir: ComponentIR): Set<string>;
16
61
  /**
17
62
  * Resolve a prop param's Go struct-field type using the SAME logic
18
63
  * `generatePropsStruct` / `generateInputStruct` use: a `propTypeOverrides` entry
@@ -1 +1 @@
1
- {"version":3,"file":"prop-types.d.ts","sourceRoot":"","sources":["../../../src/adapter/props/prop-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAsB,MAAM,iBAAiB,CAAA;AAElF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGvD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAwC/F;AAkDD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EACxC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,MAAM,CAeR;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CASzF"}
1
+ {"version":3,"file":"prop-types.d.ts","sourceRoot":"","sources":["../../../src/adapter/props/prop-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAsB,MAAM,iBAAiB,CAAA;AAGlF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGvD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAwC/F;AAkDD;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAAiD,CAAA;AAEzG;;;;;;;;;;;;;;;;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