@barefootjs/go-template 0.9.0 → 0.9.2

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.
@@ -17,6 +17,13 @@ export interface RenderOptions {
17
17
  props?: Record<string, unknown>;
18
18
  /** Additional component files (filename → source) */
19
19
  components?: Record<string, string>;
20
+ /**
21
+ * Explicit component to render when `source` declares multiple
22
+ * exports (e.g. `ReactiveProps.tsx` → `PropsReactivityComparison`).
23
+ * Mirrors the Hono reference's `componentName`; omitted for
24
+ * single-export fixtures, which fall back to the default/first export.
25
+ */
26
+ componentName?: string;
20
27
  }
21
28
  export declare function renderGoTemplateComponent(options: RenderOptions): Promise<string>;
22
29
  //# sourceMappingURL=test-render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-render.d.ts","sourceRoot":"","sources":["../src/test-render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,iBAAiB,CAAA;AAOnE,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAgCD,MAAM,WAAW,aAAa;IAC5B,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,8BAA8B;IAC9B,OAAO,EAAE,eAAe,CAAA;IACxB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACpC;AAED,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAsRvF"}
1
+ {"version":3,"file":"test-render.d.ts","sourceRoot":"","sources":["../src/test-render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,iBAAiB,CAAA;AAOnE,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAgCD,MAAM,WAAW,aAAa;IAC5B,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,8BAA8B;IAC9B,OAAO,EAAE,eAAe,CAAA;IACxB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA4RvF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/go-template",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Go html/template adapter for BarefootJS - generates Go template files from IR",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -54,6 +54,6 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@barefootjs/adapter-tests": "0.1.0",
57
- "@barefootjs/jsx": "0.9.0"
57
+ "@barefootjs/jsx": "0.9.2"
58
58
  }
59
59
  }
@@ -37,34 +37,38 @@ runAdapterConformanceTests({
37
37
  skipJsx: [
38
38
  // #1244 stress catalog (#1326): `children={<span/>}` — the IR
39
39
  // hoists the span with `needsScope: true` so the Hono reference
40
- // emits `bf-s` on the inner `<span>`. The Go adapter renders the
41
- // span up front as a compile-time HTML fragment containing the
42
- // `{{bfScopeAttr .}}` action, then passes it via `template.HTML`
43
- // through the parent's `{{.Children}}` interpolationbut
44
- // `template.HTML` is marked-as-safe-output, not recursively
45
- // parsed, so the action survives as literal text in the rendered
46
- // HTML. Fixing this requires either (a) re-emitting the inner
47
- // span as its own named template definition the outer template
48
- // can pass its struct to, or (b) embedding the resolved scope ID
49
- // at compile time. Neither lands in this PR; the Mojo sibling
50
- // case is handled by routing the hoisted JSX through the same
51
- // `begin %>…<% end` capture as nested children (see #1326 fix).
40
+ // emits `bf-s` on the inner `<span>`. The Go adapter has no path to
41
+ // render a hoisted-JSX child handed in through the `children`
42
+ // attribute, so the child is DROPPED: the parent renders
43
+ // `<div bf-s="test_s0"></div>` with an empty body (verified no
44
+ // compile error, no literal `{{bfScopeAttr}}` text either; that
45
+ // older literal-survives-in-output failure mode no longer occurs).
46
+ // Closing the gap needs the inner span re-emitted as its own named
47
+ // template definition the outer template can pass its struct to, or
48
+ // the resolved scope id embedded at compile time. Neither lands
49
+ // here; the Mojo / Xslate siblings already pass by routing the
50
+ // hoisted JSX through the same nested-children capture.
52
51
  'children-jsx-expression',
53
- // #1335: fragment-wrapped form of the same shape. Now that the IR
54
- // unwraps `<><span/></>` into the bare-element form, the Go adapter
55
- // hits the identical `template.HTML` interpolation gap as
56
- // `children-jsx-expression` above.
52
+ // #1335: fragment-wrapped form of the same shape. Once the IR
53
+ // unwraps `<><span/></>` into the bare-element form the Go adapter
54
+ // hits the identical drop as `children-jsx-expression` above.
57
55
  'fragment-wrapped-children-jsx-expression',
58
- // Shared-component multi-component fixtures (#1466). Boolean
59
- // attribute divergence is now collapsed by `normalizeHTML`, so
60
- // single-root variants (`conditional-return-*`, `form`, `portal`,
61
- // `reactive-props`) participate again. These two still diverge
62
- // because the harness's child renderer pins child `bf-s` to a
63
- // `test_<sN>` literal rather than `<ChildName>_<id>_<sN>`. Same
64
- // class of test-harness scope-id plumbing the `componentName`
65
- // option fixed on the Hono side. Separate follow-up.
56
+ // `toggle-shared`: the parent maps a `ToggleItemProps[]` prop into
57
+ // sibling `ToggleItem` children inside a keyed `.map`. The Go
58
+ // child-slice init types the loop input as `[]any` rather than
59
+ // `[]ToggleItemInput`, so the generated `NewToggleProps` struct
60
+ // literal fails to compile (`cannot use []any{…} as
61
+ // []ToggleItemInput value in struct literal`). Separate follow-up
62
+ // needs the loop-child init to emit the typed element slice, plus
63
+ // per-item `defaultOn` seeding and the `data-key` attribute shape.
64
+ //
65
+ // `props-reactivity-comparison` graduated: the Go test-render now
66
+ // honours the fixture's `componentName` (`PropsReactivityComparison`,
67
+ // the second export of `ReactiveProps.tsx`) instead of always
68
+ // rendering the first export, and the generated child constructors
69
+ // compute the `displayValue = props.value * 10` memo from the
70
+ // passed prop — so SSR matches Hono byte-for-byte.
66
71
  'toggle-shared',
67
- 'props-reactivity-comparison',
68
72
  ],
69
73
  // Per-fixture build-time contracts for shapes the Go template
70
74
  // adapter intentionally refuses to lower. Lives here (not on the
@@ -59,10 +59,17 @@ export interface RenderOptions {
59
59
  props?: Record<string, unknown>
60
60
  /** Additional component files (filename → source) */
61
61
  components?: Record<string, string>
62
+ /**
63
+ * Explicit component to render when `source` declares multiple
64
+ * exports (e.g. `ReactiveProps.tsx` → `PropsReactivityComparison`).
65
+ * Mirrors the Hono reference's `componentName`; omitted for
66
+ * single-export fixtures, which fall back to the default/first export.
67
+ */
68
+ componentName?: string
62
69
  }
63
70
 
64
71
  export async function renderGoTemplateComponent(options: RenderOptions): Promise<string> {
65
- const { source, adapter, props, components } = options
72
+ const { source, adapter, props, components, componentName: requestedName } = options
66
73
 
67
74
  if (!adapter.generateTypes) {
68
75
  throw new Error('Go Template adapter must implement generateTypes()')
@@ -139,7 +146,13 @@ export async function renderGoTemplateComponent(options: RenderOptions): Promise
139
146
  const irFiles = result.files.filter(f => f.type === 'ir')
140
147
  if (irFiles.length === 0) throw new Error('No IR output (set outputIR: true)')
141
148
  const irs = irFiles.map(f => JSON.parse(f.content) as ComponentIR)
149
+ // Explicit `componentName` wins (multi-export sources pin which export
150
+ // is the render target); otherwise default-export, then first inline-
151
+ // exported, then first IR. Mirrors the Hono reference's selection so
152
+ // multi-component fixtures (e.g. `ReactiveProps.tsx`) render the same
153
+ // export across adapters.
142
154
  const ir =
155
+ (requestedName ? irs.find(i => i.metadata.componentName === requestedName) : undefined) ??
143
156
  irs.find(i => i.metadata.hasDefaultExport) ??
144
157
  irs.find(i => i.metadata.isExported) ??
145
158
  irs[0]