@barefootjs/mojolicious 0.31.9 → 0.31.10

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/vite.js CHANGED
@@ -3916,6 +3916,38 @@ function classify(name, origin, expr, parsed, available) {
3916
3916
  }
3917
3917
  return { kind: "derived", name, origin, expr, parsed, frees: [...frees] };
3918
3918
  }
3919
+ function localConstExprsByName(metadata) {
3920
+ const out = new Map;
3921
+ for (const c of metadata.localConstants ?? []) {
3922
+ if (c.isModule || c.declarationKind !== "const" || c.value === undefined)
3923
+ continue;
3924
+ out.set(c.name, c.parsed ?? parseExpression(c.value.trim()));
3925
+ }
3926
+ return out;
3927
+ }
3928
+ function resolveThroughLocalConsts(parsed, localConsts) {
3929
+ let current = parsed;
3930
+ const maxIter = localConsts.size + 1;
3931
+ for (let i = 0;i < maxIter; i++) {
3932
+ const frees = freeIdentifiers(current);
3933
+ if (frees === null)
3934
+ break;
3935
+ let changed = false;
3936
+ for (const name of frees) {
3937
+ const value = localConsts.get(name);
3938
+ if (!value)
3939
+ continue;
3940
+ const inlined = inlineBinding(current, name, value);
3941
+ if (inlined === null)
3942
+ continue;
3943
+ current = inlined;
3944
+ changed = true;
3945
+ }
3946
+ if (!changed)
3947
+ break;
3948
+ }
3949
+ return current;
3950
+ }
3919
3951
  function computeSsrSeedPlan(metadata) {
3920
3952
  const baseScope = metadata.propsParams.map((p) => p.name);
3921
3953
  if (metadata.propsObjectName)
@@ -3924,6 +3956,7 @@ function computeSsrSeedPlan(metadata) {
3924
3956
  baseScope.push(name);
3925
3957
  }
3926
3958
  const available = new Set(baseScope);
3959
+ const localConsts = localConstExprsByName(metadata);
3927
3960
  const steps = [];
3928
3961
  for (const signal of metadata.signals) {
3929
3962
  if (signal.envReader) {
@@ -3935,13 +3968,13 @@ function computeSsrSeedPlan(metadata) {
3935
3968
  }
3936
3969
  }
3937
3970
  const expr = signal.initialValue.trim();
3938
- steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify(signal.getter, "signal", expr, parseExpression(expr), available));
3971
+ steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify(signal.getter, "signal", expr, resolveThroughLocalConsts(parseExpression(expr), localConsts), available));
3939
3972
  available.add(signal.getter);
3940
3973
  }
3941
3974
  for (const memo of metadata.memos) {
3942
3975
  const body = extractArrowBodyExpression(memo.computation);
3943
3976
  const expr = body?.trim() ?? "";
3944
- steps.push(expr === "" ? { kind: "opaque", name: memo.name, origin: "memo" } : classify(memo.name, "memo", expr, memo.parsed ?? parseExpression(expr), available));
3977
+ steps.push(expr === "" ? { kind: "opaque", name: memo.name, origin: "memo" } : classify(memo.name, "memo", expr, resolveThroughLocalConsts(memo.parsed ?? parseExpression(expr), localConsts), available));
3945
3978
  available.add(memo.name);
3946
3979
  }
3947
3980
  return { baseScope, steps };
@@ -1,5 +1,5 @@
1
1
  package BarefootJS::Backend::Mojo;
2
- our $VERSION = "0.31.8";
2
+ our $VERSION = "0.31.9";
3
3
  use Mojo::Base -base, -signatures;
4
4
 
5
5
  use Mojo::ByteStream qw(b);
@@ -1,5 +1,5 @@
1
1
  package Mojolicious::Plugin::BarefootJS::DevReload;
2
- our $VERSION = "0.31.8";
2
+ our $VERSION = "0.31.9";
3
3
  use Mojo::Base 'Mojolicious::Plugin', -signatures;
4
4
 
5
5
  =head1 NAME
@@ -1,5 +1,5 @@
1
1
  package Mojolicious::Plugin::BarefootJS;
2
- our $VERSION = "0.31.8";
2
+ our $VERSION = "0.31.9";
3
3
  use Mojo::Base 'Mojolicious::Plugin', -signatures;
4
4
 
5
5
  use Mojo::File qw(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/mojolicious",
3
- "version": "0.31.9",
3
+ "version": "0.31.10",
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.9"
55
+ "@barefootjs/shared": "0.31.10"
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.9",
74
- "@barefootjs/vite": "0.31.9",
75
- "@barefootjs/client": "0.31.9",
73
+ "@barefootjs/jsx": "0.31.10",
74
+ "@barefootjs/vite": "0.31.10",
75
+ "@barefootjs/client": "0.31.10",
76
76
  "vite": "^6.0.0"
77
77
  }
78
78
  }
@@ -514,11 +514,37 @@ function buildChildDefaultsPerl(ir: ComponentIR): string {
514
514
  // semantic divergence from those adapters.
515
515
  for (const signal of ir.metadata.signals) {
516
516
  if (signal.envReader) continue // env signal is the request reader, not a stashed value (#2057)
517
+ // #2669: a self-derivation collision (the signal's initializer derives
518
+ // from a same-named prop) gets a `propName`-carrying entry from
519
+ // `extractSsrDefaults` (see its docstring's invariant) — that entry
520
+ // MUST stay a hashref so `_derive_stash_from_defaults` resolves it
521
+ // against the REAL child props at runtime; the declared-prop loop above
522
+ // already emitted it for a DECLARED prop, so only an undeclared one
523
+ // needs adding here. Either way, do NOT fall through to this harness's
524
+ // own `evaluateSignalInit(..., undefined)` recompute below — that call
525
+ // sees no props at all and would silently re-flatten the collision back
526
+ // to a bare, non-caller-overridable value.
527
+ const d = ssrDefaults[signal.getter]
528
+ if (d?.propName !== undefined) {
529
+ if (!declared.has(signal.getter)) {
530
+ entries.push(`${signal.getter} => ${ssrDefaultEntryToPerl(d)}`)
531
+ declared.add(signal.getter)
532
+ }
533
+ continue
534
+ }
517
535
  const value = evaluateSignalInit(signal.initialValue.trim(), undefined)
518
536
  entries.push(`${signal.getter} => ${value !== null ? toPerlLiteral(value) : 'undef'}`)
519
537
  }
520
538
  for (const memo of ir.metadata.memos) {
521
539
  const entry = ssrDefaults[memo.name]
540
+ // #2669: same self-derivation handling as the signal loop above.
541
+ if (entry?.propName !== undefined) {
542
+ if (!declared.has(memo.name)) {
543
+ entries.push(`${memo.name} => ${ssrDefaultEntryToPerl(entry)}`)
544
+ declared.add(memo.name)
545
+ }
546
+ continue
547
+ }
522
548
  const value = entry ? entry.value : undefined
523
549
  entries.push(
524
550
  `${memo.name} => ${value !== undefined && value !== null ? toPerlLiteral(value) : 'undef'}`,
@@ -720,6 +746,12 @@ function buildPerlProps(
720
746
  // rule `buildChildDefaultsPerl` applies to child signals (#1897).
721
747
  for (const signal of ir.metadata.signals) {
722
748
  if (signal.envReader) continue // env signal bound below via search_params('') (#2057)
749
+ // #2669: a self-derivation collision already got the correct RAW-prop
750
+ // seed above via `derivedProps` — `extractSsrDefaults` marks that with
751
+ // a `propName`-carrying entry (see its docstring's invariant). Skip
752
+ // re-seeding here or this harness's own `evaluateSignalInit` recompute
753
+ // clobbers the correctly-derived caller value.
754
+ if (rootSsrDefaults[signal.getter]?.propName !== undefined) continue
723
755
  const value = evaluateSignalInit(signal.initialValue.trim(), props)
724
756
  entries.push(`${signal.getter} => ${value !== null ? toPerlLiteral(value) : 'undef'}`)
725
757
  }
@@ -731,6 +763,8 @@ function buildPerlProps(
731
763
  // from the plugin: hard-coding `0` masked memos with non-zero
732
764
  // initial values until #1423 added a fixture that exposed the gap.
733
765
  for (const memo of ir.metadata.memos) {
766
+ // #2669: same self-derivation skip as the signal loop above.
767
+ if (rootSsrDefaults[memo.name]?.propName !== undefined) continue
734
768
  const entry = rootSsrDefaults[memo.name]
735
769
  const value = entry ? entry.value : 0
736
770
  entries.push(`${memo.name} => ${toPerlLiteral(value ?? 0)}`)