@barefootjs/go-template 0.9.1 → 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.
package/dist/test-render.d.ts
CHANGED
|
@@ -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;
|
|
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.
|
|
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.
|
|
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
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
// `
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
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.
|
|
54
|
-
// unwraps `<><span/></>` into the bare-element form
|
|
55
|
-
// hits the identical `
|
|
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
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
// `
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
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
|
package/src/test-render.ts
CHANGED
|
@@ -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]
|