@barefootjs/mojolicious 0.31.8 → 0.31.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.
|
@@ -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;IACnC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
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,CAgPjF"}
|
package/dist/vite.js
CHANGED
|
@@ -3025,6 +3025,34 @@ var SVG_ROOT_TAGS = new Set([
|
|
|
3025
3025
|
"animateTransform",
|
|
3026
3026
|
"animateMotion"
|
|
3027
3027
|
]);
|
|
3028
|
+
var MATHML_ROOT_TAGS = new Set([
|
|
3029
|
+
"math",
|
|
3030
|
+
"mrow",
|
|
3031
|
+
"mfrac",
|
|
3032
|
+
"msup",
|
|
3033
|
+
"msub",
|
|
3034
|
+
"msubsup",
|
|
3035
|
+
"mn",
|
|
3036
|
+
"mi",
|
|
3037
|
+
"mo",
|
|
3038
|
+
"mtext",
|
|
3039
|
+
"munder",
|
|
3040
|
+
"mover",
|
|
3041
|
+
"munderover",
|
|
3042
|
+
"mtable",
|
|
3043
|
+
"mtr",
|
|
3044
|
+
"mtd",
|
|
3045
|
+
"msqrt",
|
|
3046
|
+
"mroot",
|
|
3047
|
+
"mstyle",
|
|
3048
|
+
"merror",
|
|
3049
|
+
"mpadded",
|
|
3050
|
+
"mphantom",
|
|
3051
|
+
"menclose",
|
|
3052
|
+
"semantics",
|
|
3053
|
+
"annotation",
|
|
3054
|
+
"annotation-xml"
|
|
3055
|
+
]);
|
|
3028
3056
|
|
|
3029
3057
|
// ../jsx/src/ir-to-client-js/collect-elements.ts
|
|
3030
3058
|
var EMPTY_RENDER_EXPRS = new Set(["null", "undefined", "false", "''", '""', "``"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/mojolicious",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.9",
|
|
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.31.
|
|
55
|
+
"@barefootjs/shared": "0.31.9"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@barefootjs/jsx": ">=0.2.0",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
73
|
-
"@barefootjs/jsx": "0.31.
|
|
74
|
-
"@barefootjs/vite": "0.31.
|
|
75
|
-
"@barefootjs/client": "0.31.
|
|
73
|
+
"@barefootjs/jsx": "0.31.9",
|
|
74
|
+
"@barefootjs/vite": "0.31.9",
|
|
75
|
+
"@barefootjs/client": "0.31.9",
|
|
76
76
|
"vite": "^6.0.0"
|
|
77
77
|
}
|
|
78
78
|
}
|
package/src/test-render.ts
CHANGED
|
@@ -229,7 +229,7 @@ export async function renderMojoComponent(options: RenderOptions): Promise<strin
|
|
|
229
229
|
// bare `$var` aborts under Mojo::Template's strict vars.
|
|
230
230
|
augmentInheritedPropAccesses(ir)
|
|
231
231
|
// Build props hash for Perl
|
|
232
|
-
const propsPerl = buildPerlProps(componentName, props, ir)
|
|
232
|
+
const { propsPerl, userPropsPerl } = buildPerlProps(componentName, props, ir)
|
|
233
233
|
|
|
234
234
|
// Honour `__instanceId` from props for the root scope id so
|
|
235
235
|
// shared-component fixtures (which pin `<ComponentName>_test`) match
|
|
@@ -281,6 +281,18 @@ my $bf = BarefootJS->new($c, {});
|
|
|
281
281
|
# (which pin <ComponentName>_test scope ids for cross-adapter normalisation)
|
|
282
282
|
# match what Hono renderHonoComponent emits. Default to 'test' otherwise.
|
|
283
283
|
$bf->_scope_id('${rootScopeId}');
|
|
284
|
+
# Mirrors production's \`props_attr\` contract (BarefootJS.pm's \`_props\`
|
|
285
|
+
# accessor): the caller is expected to seed it before rendering the root
|
|
286
|
+
# component, so this harness must call it explicitly.
|
|
287
|
+
#
|
|
288
|
+
# \$user_props — NOT \$props above — is what \`_props\` gets: \$props is
|
|
289
|
+
# this harness's internal vars hash (scope_id, inherited-attribute \`undef\`
|
|
290
|
+
# placeholders, signal/memo seed values, and — when the component imports
|
|
291
|
+
# searchParams — a SearchParams reader object), none of which a real
|
|
292
|
+
# Mojolicious route handler has or passes. Production's bf-p carries none
|
|
293
|
+
# of those, only the caller-facing props.
|
|
294
|
+
my $user_props = ${userPropsPerl};
|
|
295
|
+
$bf->_props($user_props);
|
|
284
296
|
|
|
285
297
|
${childRenderers}
|
|
286
298
|
|
|
@@ -515,11 +527,22 @@ function buildChildDefaultsPerl(ir: ComponentIR): string {
|
|
|
515
527
|
return `{${entries.join(', ')}}`
|
|
516
528
|
}
|
|
517
529
|
|
|
530
|
+
/**
|
|
531
|
+
* Returns the full internal vars-hash Perl literal (`props`, what the
|
|
532
|
+
* inline `Mojo::Template` renders against) AND `userPropsPerl` — the
|
|
533
|
+
* exact raw fixture props (no defaults, no null-fill, no signal/memo
|
|
534
|
+
* seeding, no rest-bag nesting), mirroring production's route-handler
|
|
535
|
+
* call `$bf->_props($props)` verbatim. `userPropsPerl` is for
|
|
536
|
+
* `$bf->_props(...)` (bf-p hydration payload) only — these must NOT be
|
|
537
|
+
* the same value, and `userPropsPerl` must NOT be derived from
|
|
538
|
+
* `entries` or the defaulted stash: production's own bf-p carries only
|
|
539
|
+
* what the caller actually passed in, unmodified.
|
|
540
|
+
*/
|
|
518
541
|
function buildPerlProps(
|
|
519
542
|
_componentName: string,
|
|
520
543
|
props: Record<string, unknown> | undefined,
|
|
521
544
|
ir: ComponentIR,
|
|
522
|
-
): string {
|
|
545
|
+
): { propsPerl: string; userPropsPerl: string } {
|
|
523
546
|
const entries: string[] = []
|
|
524
547
|
|
|
525
548
|
// Add scope_id — honour an explicit `__instanceId` from props so
|
|
@@ -552,7 +575,8 @@ function buildPerlProps(
|
|
|
552
575
|
// emits a literal `$label` reference where the BF101 path used
|
|
553
576
|
// to emit `''`, exposing this latent test-harness gap.
|
|
554
577
|
const value = derivedProps[param.name]
|
|
555
|
-
|
|
578
|
+
const literal = value !== undefined && value !== null ? toPerlLiteral(value) : 'undef'
|
|
579
|
+
entries.push(`${param.name} => ${literal}`)
|
|
556
580
|
}
|
|
557
581
|
|
|
558
582
|
// (#checkbox) SolidJS props-object pattern: `function Checkbox(props:
|
|
@@ -623,8 +647,12 @@ function buildPerlProps(
|
|
|
623
647
|
const localParamNames = new Set(ir.metadata.propsParams.map(p => p.name))
|
|
624
648
|
if (props) {
|
|
625
649
|
for (const [key, value] of Object.entries(props)) {
|
|
650
|
+
// Internal hydration markers (`__instanceId` etc.) are routed by
|
|
651
|
+
// the framework, never a real caller-facing prop.
|
|
652
|
+
if (key.startsWith('__')) continue
|
|
626
653
|
if (routedKeys.has(key)) continue
|
|
627
654
|
if (localParamNames.has(key)) continue
|
|
655
|
+
let literal: string | null = null
|
|
628
656
|
if (value === null) {
|
|
629
657
|
// An explicit-null prop must still DECLARE the template var —
|
|
630
658
|
// `typeof null === 'object'` fails every branch below, so the key
|
|
@@ -632,15 +660,15 @@ function buildPerlProps(
|
|
|
632
660
|
// `my $user`, tripping Perl's strict-mode "Global symbol requires
|
|
633
661
|
// explicit package name" before the `//` fallback could apply
|
|
634
662
|
// (data-point conformance, optional-chaining-prop:null-user).
|
|
635
|
-
|
|
663
|
+
literal = 'undef'
|
|
636
664
|
} else if (typeof value === 'string') {
|
|
637
|
-
|
|
665
|
+
literal = `'${value.replace(/'/g, "\\'")}'`
|
|
638
666
|
} else if (typeof value === 'number') {
|
|
639
|
-
|
|
667
|
+
literal = `${value}`
|
|
640
668
|
} else if (typeof value === 'boolean') {
|
|
641
669
|
// Mojo::JSON sentinels so BarefootJS helpers can detect
|
|
642
670
|
// booleans via ref() (see toPerlLiteral / spread_attrs).
|
|
643
|
-
|
|
671
|
+
literal = value ? 'Mojo::JSON::true' : 'Mojo::JSON::false'
|
|
644
672
|
} else if (Array.isArray(value)) {
|
|
645
673
|
// Array → Perl arrayref literal. Fixtures that exercise
|
|
646
674
|
// array-receiver methods (`items.every(...)`, `items.some(...)`,
|
|
@@ -651,18 +679,39 @@ function buildPerlProps(
|
|
|
651
679
|
// declares `my $items` (the key is absent from the vars
|
|
652
680
|
// hash) and the template trips Perl's strict-mode "Global
|
|
653
681
|
// symbol $items requires explicit package name" check.
|
|
654
|
-
|
|
682
|
+
literal = toPerlLiteral(value)
|
|
655
683
|
} else if (value && typeof value === 'object') {
|
|
656
684
|
// Plain object → Perl hashref literal (#1407 follow-up).
|
|
657
685
|
// Used by the destructured-rest / propsObject fixtures
|
|
658
686
|
// (`jsx-spread-rest-prop`, `jsx-spread-props-object`) so
|
|
659
687
|
// the test harness can pass through bag-shaped props that
|
|
660
688
|
// weren't enumerated by the analyzer.
|
|
661
|
-
|
|
689
|
+
literal = toPerlLiteral(value)
|
|
690
|
+
}
|
|
691
|
+
if (literal !== null) {
|
|
692
|
+
entries.push(`${key} => ${literal}`)
|
|
662
693
|
}
|
|
663
694
|
}
|
|
664
695
|
}
|
|
665
696
|
|
|
697
|
+
// `$bf->_props(...)` payload (bf-p hydration): mirrors production's
|
|
698
|
+
// route-handler call `$bf->_props($props)` verbatim — the caller's raw
|
|
699
|
+
// props hash, unmodified. No default-filling, no signal/memo seeding,
|
|
700
|
+
// no rest-bag nesting: a real Mojolicious route handler never
|
|
701
|
+
// rearranges the hash it received before handing it to `_props`.
|
|
702
|
+
// Excludes internal harness-only keys (`__instanceId` etc.), which are
|
|
703
|
+
// never a real caller-facing prop. Bareword key relies on Perl's
|
|
704
|
+
// fat-comma auto-quoting, matching this function's other hash-literal
|
|
705
|
+
// construction above.
|
|
706
|
+
const userEntries: string[] = []
|
|
707
|
+
if (props) {
|
|
708
|
+
for (const [key, value] of Object.entries(props)) {
|
|
709
|
+
if (key.startsWith('__')) continue
|
|
710
|
+
userEntries.push(`${key} => ${toPerlLiteral(value)}`)
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
const userPropsPerl = `{${userEntries.join(', ')}}`
|
|
714
|
+
|
|
666
715
|
// Add signal values evaluated from props (must come after user props).
|
|
667
716
|
// Seed `undef` for a null / unevaluable initial (e.g. a
|
|
668
717
|
// `createSignal<SortKey>(null)` whose getter is read in a child-prop
|
|
@@ -697,7 +746,7 @@ function buildPerlProps(
|
|
|
697
746
|
entries.push(`searchParams => BarefootJS->search_params('')`)
|
|
698
747
|
}
|
|
699
748
|
|
|
700
|
-
return `{${entries.join(', ')}}
|
|
749
|
+
return { propsPerl: `{${entries.join(', ')}}`, userPropsPerl }
|
|
701
750
|
}
|
|
702
751
|
|
|
703
752
|
/**
|