@barefootjs/mojolicious 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
|
@@ -33,6 +33,13 @@ export interface RenderOptions {
|
|
|
33
33
|
props?: Record<string, unknown>;
|
|
34
34
|
/** Additional component files (filename → source) */
|
|
35
35
|
components?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* Explicit component to render when `source` declares multiple
|
|
38
|
+
* exports (e.g. `ReactiveProps.tsx` → `PropsReactivityComparison`).
|
|
39
|
+
* Mirrors the Hono reference's `componentName`; omitted for
|
|
40
|
+
* single-export fixtures, which fall back to the default/first export.
|
|
41
|
+
*/
|
|
42
|
+
componentName?: string;
|
|
36
43
|
}
|
|
37
44
|
export declare function renderMojoComponent(options: RenderOptions): Promise<string>;
|
|
38
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-render.d.ts","sourceRoot":"","sources":["../src/test-render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKxE;AAkCD,MAAM,WAAW,aAAa;IAC5B,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,8BAA8B;IAC9B,OAAO,EAAE,OAAO,iBAAiB,EAAE,eAAe,CAAA;IAClD,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;AAeH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKxE;AAkCD,MAAM,WAAW,aAAa;IAC5B,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,8BAA8B;IAC9B,OAAO,EAAE,OAAO,iBAAiB,EAAE,eAAe,CAAA;IAClD,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,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAgNjF;AA+RD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAuBT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/mojolicious",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Mojolicious EP template adapter for BarefootJS - generates .html.ep files from IR",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"directory": "packages/adapter-mojolicious"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@barefootjs/shared": "0.9.
|
|
55
|
+
"@barefootjs/shared": "0.9.2"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@barefootjs/jsx": ">=0.2.0",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
63
|
-
"@barefootjs/jsx": "0.9.
|
|
63
|
+
"@barefootjs/jsx": "0.9.2"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -22,13 +22,32 @@ runAdapterConformanceTests({
|
|
|
22
22
|
// template reads a stash key that's never seeded. Implemented on Go; the
|
|
23
23
|
// Perl stash-seed path is a follow-up port, so Mojo stays skipped (#1297).
|
|
24
24
|
'context-provider',
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
25
|
+
// `toggle-shared`: the parent maps a `ToggleItemProps[]` prop into
|
|
26
|
+
// sibling `ToggleItem` children inside a keyed `.map`. Each child's
|
|
27
|
+
// `on = props.defaultOn ?? false` signal is never seeded into the
|
|
28
|
+
// loop-child stash, so the rendered child template trips Perl strict
|
|
29
|
+
// mode (`Global symbol "$on" requires explicit package name`). The
|
|
30
|
+
// harness child renderer forwards only the explicitly-passed props;
|
|
31
|
+
// it does not run the `_derive_stash_from_defaults` seeding the
|
|
32
|
+
// production runtime applies. Plus the loop-child scope id is
|
|
33
|
+
// `toggle_item_<rand>` (snake-case template name) rather than the
|
|
34
|
+
// `ToggleItem_*` PascalCase the reference pins, and the `key=` →
|
|
35
|
+
// `data-key` attribute isn't emitted. Separate follow-up. (xslate
|
|
36
|
+
// skips this for the same reasons.)
|
|
31
37
|
'toggle-shared',
|
|
38
|
+
// `props-reactivity-comparison` (the `PropsReactivityComparison`
|
|
39
|
+
// export of `ReactiveProps.tsx`): componentName selection is now
|
|
40
|
+
// honoured (the test-render picks the requested export), but the
|
|
41
|
+
// child `PropsStyleChild` has a `displayValue = props.value * 10`
|
|
42
|
+
// memo. `extractSsrDefaults` cannot statically evaluate a
|
|
43
|
+
// prop-derived expression (it yields `null`), and the Perl SSR model
|
|
44
|
+
// seeds child memos from those *static* defaults — so `$displayValue`
|
|
45
|
+
// is never declared and the child render aborts under strict mode.
|
|
46
|
+
// Go matches only because it generates a child constructor that
|
|
47
|
+
// computes the memo from the passed prop at render time; the Perl
|
|
48
|
+
// adapters have no equivalent runtime memo-init in the static path
|
|
49
|
+
// (an opt-in `signal_init` sub would be required). (xslate skips this
|
|
50
|
+
// for the same reason.)
|
|
32
51
|
'props-reactivity-comparison',
|
|
33
52
|
],
|
|
34
53
|
// Per-fixture build-time contracts for shapes the Mojo adapter
|
package/src/test-render.ts
CHANGED
|
@@ -89,10 +89,17 @@ export interface RenderOptions {
|
|
|
89
89
|
props?: Record<string, unknown>
|
|
90
90
|
/** Additional component files (filename → source) */
|
|
91
91
|
components?: Record<string, string>
|
|
92
|
+
/**
|
|
93
|
+
* Explicit component to render when `source` declares multiple
|
|
94
|
+
* exports (e.g. `ReactiveProps.tsx` → `PropsReactivityComparison`).
|
|
95
|
+
* Mirrors the Hono reference's `componentName`; omitted for
|
|
96
|
+
* single-export fixtures, which fall back to the default/first export.
|
|
97
|
+
*/
|
|
98
|
+
componentName?: string
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
export async function renderMojoComponent(options: RenderOptions): Promise<string> {
|
|
95
|
-
const { source, adapter, props, components } = options
|
|
102
|
+
const { source, adapter, props, components, componentName: requestedName } = options
|
|
96
103
|
|
|
97
104
|
// Compile child components first
|
|
98
105
|
const childTemplates: Map<string, { template: string; ir: ComponentIR }> = new Map()
|
|
@@ -152,7 +159,12 @@ export async function renderMojoComponent(options: RenderOptions): Promise<strin
|
|
|
152
159
|
const irFiles = result.files.filter(f => f.type === 'ir')
|
|
153
160
|
if (irFiles.length === 0) throw new Error('No IR output (set outputIR: true)')
|
|
154
161
|
const irs = irFiles.map(f => JSON.parse(f.content) as ComponentIR)
|
|
162
|
+
// Explicit `componentName` wins (multi-export sources pin the render
|
|
163
|
+
// target); otherwise default-export, first inline-exported, first IR.
|
|
164
|
+
// Mirrors the Hono reference so multi-component fixtures render the
|
|
165
|
+
// same export across adapters.
|
|
155
166
|
const ir =
|
|
167
|
+
(requestedName ? irs.find(i => i.metadata.componentName === requestedName) : undefined) ??
|
|
156
168
|
irs.find(i => i.metadata.hasDefaultExport) ??
|
|
157
169
|
irs.find(i => i.metadata.isExported) ??
|
|
158
170
|
irs[0]
|