@barefootjs/rust 0.31.9 → 0.32.0

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/index.js CHANGED
@@ -189248,7 +189248,11 @@ var conformancePins = {
189248
189248
  "rich-prop-client-read": [{ code: "BF049", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2648" }]
189249
189249
  };
189250
189250
  // src/render-divergences.ts
189251
- var renderDivergences = {};
189251
+ var renderDivergences = {
189252
+ "todo-app": "the `todos` signal seeds from `(props.initialTodos ?? []).map(t => ({ ...t, editing: false }))` — a different-prop-derived `.map()` chain `extractSsrDefaults` cannot statically resolve, and `computeSsrSeedPlan` classifies it opaque (no in-template recompute), so it seeds `null`; the non-`/* @client */`-marked `{todos().length > 0 && ...}` toggle-all block SSRs as if there are zero todos regardless of `initialTodos` (https://github.com/piconic-ai/barefootjs/issues/2696)",
189253
+ "todo-app-ssr": "same root cause as `todo-app` (https://github.com/piconic-ai/barefootjs/issues/2696); this fixture's todo-list loop carries no `/* @client */` marker and minijinja's `{% for %}` over a null value renders zero rows rather than throwing, so it SSRs an empty `<ul class=\"todo-list\">` with the toggle-all controls also absent, regardless of `initialTodos`",
189254
+ "callback-param-shadows-prop": "the `first` signal seeds from `[{ a: 'p' }].map((title) => title.a).join(',')` — a constant expression `extractSsrDefaults` still cannot statically resolve (`.map()` is unsupported for any receiver) and, unlike the sibling `joined` memo's structurally similar chain, gets no in-template recompute (`computeSsrSeedPlan` classifies it opaque too); `<span>{first()}</span>` SSRs empty instead of `p` (https://github.com/piconic-ai/barefootjs/issues/2696)"
189255
+ };
189252
189256
  export {
189253
189257
  renderDivergences,
189254
189258
  minijinjaAdapter,
@@ -1 +1 @@
1
- {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,iBAC/B,CAAA"}
1
+ {"version":3,"file":"render-divergences.d.ts","sourceRoot":"","sources":["../src/render-divergences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,eAAO,MAAM,iBAAiB,EAAE,iBAO/B,CAAA"}
package/dist/vite.js CHANGED
@@ -3968,6 +3968,38 @@ function classify(name, origin, expr, parsed, available) {
3968
3968
  }
3969
3969
  return { kind: "derived", name, origin, expr, parsed, frees: [...frees] };
3970
3970
  }
3971
+ function localConstExprsByName(metadata) {
3972
+ const out = new Map;
3973
+ for (const c of metadata.localConstants ?? []) {
3974
+ if (c.isModule || c.declarationKind !== "const" || c.value === undefined)
3975
+ continue;
3976
+ out.set(c.name, c.parsed ?? parseExpression(c.value.trim()));
3977
+ }
3978
+ return out;
3979
+ }
3980
+ function resolveThroughLocalConsts(parsed, localConsts) {
3981
+ let current = parsed;
3982
+ const maxIter = localConsts.size + 1;
3983
+ for (let i = 0;i < maxIter; i++) {
3984
+ const frees = freeIdentifiers(current);
3985
+ if (frees === null)
3986
+ break;
3987
+ let changed = false;
3988
+ for (const name of frees) {
3989
+ const value = localConsts.get(name);
3990
+ if (!value)
3991
+ continue;
3992
+ const inlined = inlineBinding(current, name, value);
3993
+ if (inlined === null)
3994
+ continue;
3995
+ current = inlined;
3996
+ changed = true;
3997
+ }
3998
+ if (!changed)
3999
+ break;
4000
+ }
4001
+ return current;
4002
+ }
3971
4003
  function computeSsrSeedPlan(metadata) {
3972
4004
  const baseScope = metadata.propsParams.map((p) => p.name);
3973
4005
  if (metadata.propsObjectName)
@@ -3976,6 +4008,7 @@ function computeSsrSeedPlan(metadata) {
3976
4008
  baseScope.push(name);
3977
4009
  }
3978
4010
  const available = new Set(baseScope);
4011
+ const localConsts = localConstExprsByName(metadata);
3979
4012
  const steps = [];
3980
4013
  for (const signal of metadata.signals) {
3981
4014
  if (signal.envReader) {
@@ -3987,13 +4020,13 @@ function computeSsrSeedPlan(metadata) {
3987
4020
  }
3988
4021
  }
3989
4022
  const expr = signal.initialValue.trim();
3990
- steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify(signal.getter, "signal", expr, parseExpression(expr), available));
4023
+ steps.push(expr === "" ? { kind: "opaque", name: signal.getter, origin: "signal" } : classify(signal.getter, "signal", expr, resolveThroughLocalConsts(parseExpression(expr), localConsts), available));
3991
4024
  available.add(signal.getter);
3992
4025
  }
3993
4026
  for (const memo of metadata.memos) {
3994
4027
  const body = extractArrowBodyExpression(memo.computation);
3995
4028
  const expr = body?.trim() ?? "";
3996
- steps.push(expr === "" ? { kind: "opaque", name: memo.name, origin: "memo" } : classify(memo.name, "memo", expr, memo.parsed ?? parseExpression(expr), available));
4029
+ steps.push(expr === "" ? { kind: "opaque", name: memo.name, origin: "memo" } : classify(memo.name, "memo", expr, resolveThroughLocalConsts(memo.parsed ?? parseExpression(expr), localConsts), available));
3997
4030
  available.add(memo.name);
3998
4031
  }
3999
4032
  return { baseScope, steps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barefootjs/rust",
3
- "version": "0.31.9",
3
+ "version": "0.32.0",
4
4
  "description": "minijinja (Rust) adapter for BarefootJS — compiles IR to .j2 templates and ships a Rust rendering runtime (packages/adapter-rust/runtime/); runs under any Rust web framework (axum, etc.)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -54,7 +54,7 @@
54
54
  "directory": "packages/adapter-rust"
55
55
  },
56
56
  "dependencies": {
57
- "@barefootjs/shared": "0.31.9"
57
+ "@barefootjs/shared": "0.32.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@barefootjs/jsx": ">=0.2.0",
@@ -71,9 +71,9 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@barefootjs/adapter-tests": "0.1.0",
74
- "@barefootjs/jsx": "0.31.9",
75
- "@barefootjs/vite": "0.31.9",
76
- "@barefootjs/client": "0.31.9",
74
+ "@barefootjs/jsx": "0.32.0",
75
+ "@barefootjs/vite": "0.32.0",
76
+ "@barefootjs/client": "0.32.0",
77
77
  "typescript": "^5.0.0",
78
78
  "vite": "^6.0.0"
79
79
  }
@@ -12,4 +12,10 @@
12
12
  import type { RenderDivergences } from '@barefootjs/jsx'
13
13
 
14
14
  export const renderDivergences: RenderDivergences = {
15
+ 'todo-app':
16
+ 'the `todos` signal seeds from `(props.initialTodos ?? []).map(t => ({ ...t, editing: false }))` — a different-prop-derived `.map()` chain `extractSsrDefaults` cannot statically resolve, and `computeSsrSeedPlan` classifies it opaque (no in-template recompute), so it seeds `null`; the non-`/* @client */`-marked `{todos().length > 0 && ...}` toggle-all block SSRs as if there are zero todos regardless of `initialTodos` (https://github.com/piconic-ai/barefootjs/issues/2696)',
17
+ 'todo-app-ssr':
18
+ "same root cause as `todo-app` (https://github.com/piconic-ai/barefootjs/issues/2696); this fixture's todo-list loop carries no `/* @client */` marker and minijinja's `{% for %}` over a null value renders zero rows rather than throwing, so it SSRs an empty `<ul class=\"todo-list\">` with the toggle-all controls also absent, regardless of `initialTodos`",
19
+ 'callback-param-shadows-prop':
20
+ "the `first` signal seeds from `[{ a: 'p' }].map((title) => title.a).join(',')` — a constant expression `extractSsrDefaults` still cannot statically resolve (`.map()` is unsupported for any receiver) and, unlike the sibling `joined` memo's structurally similar chain, gets no in-template recompute (`computeSsrSeedPlan` classifies it opaque too); `<span>{first()}</span>` SSRs empty instead of `p` (https://github.com/piconic-ai/barefootjs/issues/2696)",
15
21
  }
@@ -28,7 +28,7 @@
28
28
  * that closes that gap.
29
29
  */
30
30
 
31
- import { compileJSX, extractSsrDefaults, deriveStashFromDefaults, importsSearchParams, evaluateSignalInit } from '@barefootjs/jsx'
31
+ import { compileJSX, extractSsrDefaults, deriveStashFromDefaults, importsSearchParams } from '@barefootjs/jsx'
32
32
  import type { ComponentIR, SsrDefault } from '@barefootjs/jsx'
33
33
  import { mkdir, rm } from 'node:fs/promises'
34
34
  import { resolve } from 'node:path'
@@ -501,22 +501,22 @@ function buildVars(
501
501
  }
502
502
  }
503
503
 
504
- // Signal values evaluated from props (after user props).
504
+ // No initializer re-evaluation against raw props production's
505
+ // before_render seeds only from `deriveStashFromDefaults` (#2696).
505
506
  for (const signal of ir.metadata.signals) {
506
507
  // Env signals (#2057) are bound below via `search_params`, not from a
507
508
  // static initial value.
508
509
  if (signal.envReader) continue
509
- const value = evaluateSignalInit(signal.initialValue.trim(), props)
510
- if (value !== null) {
511
- vars[signal.getter] = value
510
+ if (Object.prototype.hasOwnProperty.call(derivedProps, signal.getter)) {
511
+ vars[signal.getter] = derivedProps[signal.getter]
512
512
  }
513
513
  }
514
514
 
515
- // Memo values seeded from the statically-evaluated ssrDefaults, same
516
- // as the production plugin's before_render hook.
515
+ // No `?? 0` for entries the manifest lacks — production seeds nothing there (#2696).
517
516
  for (const memo of ir.metadata.memos) {
518
- const entry = rootSsrDefaults[memo.name]
519
- vars[memo.name] = entry ? (entry.value ?? 0) : 0
517
+ if (Object.prototype.hasOwnProperty.call(derivedProps, memo.name)) {
518
+ vars[memo.name] = derivedProps[memo.name]
519
+ }
520
520
  }
521
521
 
522
522
  return vars