brustjs 0.1.25-alpha → 0.1.27-alpha

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.
@@ -1685,3 +1685,29 @@ code, pre { font-family: var(--font-mono); }
1685
1685
  .dex-type--fairy, .dex-tc__colhead--fairy, .dex-tc__rowhead--fairy { background: var(--magenta-300); }
1686
1686
 
1687
1687
  .dex-hide { display: none !important; }
1688
+
1689
+ /* ----------------------------------------------------------------------------
1690
+ * SPA navigation preloader — a top progress bar rendered by the NavPreloader
1691
+ * React ISLAND (components/NavPreloader.tsx) while brustjs/navigation reports
1692
+ * phase === 'loading'. The island reads the nav store via useNav() and mounts
1693
+ * this bar only during a navigation; the bar is fixed so it escapes the .aa-app
1694
+ * grid and sits above the sticky topbar (z-index:10).
1695
+ * ------------------------------------------------------------------------- */
1696
+ .nav-preloader {
1697
+ position: fixed;
1698
+ inset: 0 0 auto 0;
1699
+ height: 3px;
1700
+ z-index: 9999;
1701
+ overflow: hidden;
1702
+ pointer-events: none;
1703
+ }
1704
+ .nav-preloader__bar {
1705
+ height: 100%;
1706
+ width: 40%;
1707
+ background: var(--aa-gradient, #1B75BB);
1708
+ animation: nav-preloader-slide 0.9s ease-in-out infinite;
1709
+ }
1710
+ @keyframes nav-preloader-slide {
1711
+ from { transform: translateX(-110%); }
1712
+ to { transform: translateX(360%); }
1713
+ }
@@ -10,24 +10,25 @@
10
10
  //
11
11
  // MUST stay single-return with no local bindings above it — a local `const`
12
12
  // would make the compiler soft-fall-back to an SSR component (no <html> shell).
13
- // active-nav uses conditional ELEMENTS (S11), not a className ternary
14
- // (unsupported). AppLayout owns the single <main> (leaves are fragments in the
15
- // <Outlet/> slot) a leaf adding its own <main> breaks SPA-nav extraction.
16
- // See ../FRAMEWORK-GAPS.md.
13
+ // Active-nav is now CLIENT-driven: each <NavLink> is a native directive component
14
+ // whose behavior watches brustjs/navigation's `nav.path` and sets is-active itself
15
+ // (no SSR `active` conditional, no data-brust-active-nav magic). AppLayout owns the
16
+ // single <main> (leaves are fragments in the <Outlet/> slot) — a leaf adding its
17
+ // own <main> breaks SPA-nav extraction. See ../FRAMEWORK-GAPS.md.
17
18
  import { BrustPage, Island, Outlet } from 'brustjs'
18
19
  import type { TeamMember } from '../lib/types'
20
+ import NavLink from './NavLink'
21
+ import NavPreloader from './NavPreloader'
19
22
  import TeamBuilder from './TeamBuilder'
20
23
  import ThemeToggle from './ThemeToggle'
21
24
 
22
25
  export default function AppLayout({
23
26
  title,
24
- active,
25
27
  crumb,
26
28
  teamProps,
27
29
  mode,
28
30
  }: {
29
31
  title: string
30
- active: 'list' | 'typechart'
31
32
  crumb: string
32
33
  teamProps: { teamInitial: TeamMember[] }
33
34
  mode: 'dark' | 'light'
@@ -51,26 +52,8 @@ export default function AppLayout({
51
52
  </div>
52
53
  <nav className="aa-sidebar__nav">
53
54
  <div className="aa-sidebar__group-title">Pokédex</div>
54
- {active === 'list' ? (
55
- <a className="aa-nav-item is-active" href="/">
56
- <span>All Pokémon</span>
57
- </a>
58
- ) : (
59
- <a className="aa-nav-item" href="/">
60
- <span>All Pokémon</span>
61
- </a>
62
- )}
63
- {active === 'typechart' ? (
64
- <a className="aa-nav-item is-active" href="/type-chart">
65
- <span>Type chart</span>
66
- <span className="aa-nav-item__count">native</span>
67
- </a>
68
- ) : (
69
- <a className="aa-nav-item" href="/type-chart">
70
- <span>Type chart</span>
71
- <span className="aa-nav-item__count">native</span>
72
- </a>
73
- )}
55
+ <NavLink native href="/" label="All Pokémon" />
56
+ <NavLink native href="/type-chart" label="Type chart" count="native" />
74
57
  </nav>
75
58
  <div className="aa-sidebar__user">
76
59
  <span className="aa-avatar aa-avatar--sm dex-brand-avatar">B</span>
@@ -99,6 +82,7 @@ export default function AppLayout({
99
82
  </main>
100
83
 
101
84
  <Island component={TeamBuilder} props={teamProps} ssr hydrate="load" />
85
+ <Island component={NavPreloader} hydrate="load" />
102
86
  </div>
103
87
  </BrustPage>
104
88
  )
@@ -0,0 +1,50 @@
1
+ // NATIVE INTERACTIVE COMPONENT — a sidebar nav link whose active state is driven
2
+ // by the navigation store, WATCHED in the behavior and applied by the author (no
3
+ // data-brust-active-nav magic attribute). This is the "consume the nav store
4
+ // yourself" pattern: `nav` from brustjs/navigation is a plain reactive source
5
+ // (signals shared cross-chunk via brustjs/store's Symbol.for tracker), so a
6
+ // `computed` over `nav.path()` re-runs on every SPA navigation — the same store
7
+ // the React island reads via useNav(). The bootstrap-owned navigator commits
8
+ // nav.path; this behavior reacts.
9
+ //
10
+ // Single-file component: `export const behavior` → _directives.js (react-free);
11
+ // the JSX default → the native template the compiler lowers to minijinja.
12
+ import { nav } from 'brustjs/navigation'
13
+ import { computed } from 'brustjs/store'
14
+
15
+ // behavior → registered as "navLink". Reads the link's own href off the element
16
+ // (no x-props needed), watches nav.path, and returns the active className +
17
+ // aria-current. x-bind-class sets the full className; x-bind-aria-current with a
18
+ // null value removes the attribute (see runtime setBound).
19
+ export const behavior = ({ el }: { el: HTMLElement }) => {
20
+ const linkPath = new URL((el as HTMLAnchorElement).href, location.href).pathname
21
+ const cls = computed(() => (nav.path() === linkPath ? 'aa-nav-item is-active' : 'aa-nav-item'))
22
+ const current = computed(() => (nav.path() === linkPath ? 'page' : null))
23
+ return { cls, current }
24
+ }
25
+
26
+ // default → jinja. The SSR className is the inactive base; the behavior sets
27
+ // is-active on bind and on every SPA nav. `count` is an optional native inline
28
+ // conditional (the "native" chip on the type-chart link).
29
+ export default function NavLink({
30
+ href,
31
+ label,
32
+ count,
33
+ }: {
34
+ href: string
35
+ label: string
36
+ count?: string
37
+ }) {
38
+ return (
39
+ <a
40
+ x-data="navLink"
41
+ x-bind-class="cls"
42
+ x-bind-aria-current="current"
43
+ className="aa-nav-item"
44
+ href={href}
45
+ >
46
+ <span>{label}</span>
47
+ {count ? <span className="aa-nav-item__count">{count}</span> : null}
48
+ </a>
49
+ )
50
+ }
@@ -0,0 +1,21 @@
1
+ // REACT ISLAND demonstrating useNav() — a top "preloader" progress bar shown
2
+ // while an SPA navigation is in flight. This is the React-island counterpart to
3
+ // NavLink's native-behavior consumption of the SAME navigation store: the native
4
+ // behavior sets a class via x-bind, this island re-renders via React. Both read
5
+ // `brustjs/navigation` through brustjs/store's cross-chunk signal tracker.
6
+ //
7
+ // Placed OUTSIDE <main> in AppLayout so the bootstrap navigator (which only
8
+ // unmounts/​swaps islands inside <main>) never tears it down during the very
9
+ // navigation it is indicating. It renders nothing when idle, and an indeterminate
10
+ // bar while `phase === 'loading'`.
11
+ import { useNav } from 'brustjs/client'
12
+
13
+ export default function NavPreloader() {
14
+ const { phase } = useNav()
15
+ if (phase !== 'loading') return null
16
+ return (
17
+ <div className="nav-preloader" role="progressbar" aria-label="กำลังโหลดหน้า">
18
+ <div className="nav-preloader__bar" />
19
+ </div>
20
+ )
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brustjs",
3
- "version": "0.1.25-alpha",
3
+ "version": "0.1.27-alpha",
4
4
  "description": "Bun + Rust SSR framework — React on the server, Rust everywhere else (napi cdylib + per-worker SharedArrayBuffer).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,12 +40,12 @@
40
40
  "typescript": "^6.0.3"
41
41
  },
42
42
  "optionalDependencies": {
43
- "brustjs-darwin-x64": "0.1.25-alpha",
44
- "brustjs-darwin-arm64": "0.1.25-alpha",
45
- "brustjs-linux-x64-gnu": "0.1.25-alpha",
46
- "brustjs-linux-arm64-gnu": "0.1.25-alpha",
47
- "brustjs-linux-x64-musl": "0.1.25-alpha",
48
- "brustjs-linux-arm64-musl": "0.1.25-alpha"
43
+ "brustjs-darwin-x64": "0.1.27-alpha",
44
+ "brustjs-darwin-arm64": "0.1.27-alpha",
45
+ "brustjs-linux-x64-gnu": "0.1.27-alpha",
46
+ "brustjs-linux-arm64-gnu": "0.1.27-alpha",
47
+ "brustjs-linux-x64-musl": "0.1.27-alpha",
48
+ "brustjs-linux-arm64-musl": "0.1.27-alpha"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "^19.2.6",
@@ -69,7 +69,8 @@
69
69
  "./client": "./runtime/client/index.ts",
70
70
  "./create": "./runtime/create.ts",
71
71
  "./store": "./runtime/store/index.ts",
72
- "./native": "./runtime/native/index.ts"
72
+ "./native": "./runtime/native/index.ts",
73
+ "./navigation": "./runtime/navigation/index.ts"
73
74
  },
74
75
  "files": [
75
76
  "runtime",
@@ -0,0 +1,50 @@
1
+ import { type Dirent, existsSync, readdirSync, statSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+
4
+ // Dirs that never hold authored route/component source — skip them so a stray
5
+ // newer .tsx in a build cache or dependency doesn't force a needless recompile.
6
+ const IGNORED_DIRS = new Set(['node_modules', '.brust', 'dist', '.git'])
7
+
8
+ /** Walk `dir` recursively, returning the newest mtime (ms) of any `.tsx` file
9
+ * found, or 0 when there are none. Ignored dirs (build caches, deps) are pruned. */
10
+ function newestTsxMtime(dir: string): number {
11
+ let newest = 0
12
+ let entries: Dirent[]
13
+ try {
14
+ entries = readdirSync(dir, { withFileTypes: true }) as Dirent[]
15
+ } catch {
16
+ return newest
17
+ }
18
+ for (const entry of entries) {
19
+ if (entry.isDirectory()) {
20
+ if (IGNORED_DIRS.has(entry.name)) continue
21
+ newest = Math.max(newest, newestTsxMtime(join(dir, entry.name)))
22
+ } else if (entry.isFile() && entry.name.endsWith('.tsx')) {
23
+ try {
24
+ newest = Math.max(newest, statSync(join(dir, entry.name)).mtimeMs)
25
+ } catch {
26
+ // file vanished mid-walk — ignore
27
+ }
28
+ }
29
+ }
30
+ return newest
31
+ }
32
+
33
+ /** True when the emitted native templates in `jinjaDir` are missing or older
34
+ * than the authored `.tsx` sources under `scanRoot` — i.e. a boot-time
35
+ * recompile is warranted so `bun run <entry>` (source mode) doesn't require a
36
+ * prior `brust build`, and an edited page is picked up without a stale render.
37
+ *
38
+ * Staleness = the build marker (`_manifest.json`, written last by
39
+ * `emitNativeTemplates`) is absent, OR any source `.tsx` is newer than it. */
40
+ export function isJinjaStale(scanRoot: string, jinjaDir: string): boolean {
41
+ const manifestPath = join(jinjaDir, '_manifest.json')
42
+ if (!existsSync(manifestPath)) return true
43
+ let manifestMtime: number
44
+ try {
45
+ manifestMtime = statSync(manifestPath).mtimeMs
46
+ } catch {
47
+ return true
48
+ }
49
+ return newestTsxMtime(scanRoot) > manifestMtime
50
+ }
@@ -635,6 +635,14 @@ export function reconcileIslandManifest(
635
635
 
636
636
  const raw = JSON.parse(readFileSync(islandsJsonPath, 'utf8')) as RawIslandEntry[]
637
637
 
638
+ // sourcePath is written PROJECT-RELATIVE (relative to the build's cwd), never
639
+ // the build machine's absolute path — the absolute path leaks the developer's
640
+ // username into shipped dist/jinja artifacts, and a relative path survives the
641
+ // dual-emit copy into `.brust/jinja` (both dirs sit directly under cwd, so the
642
+ // same relative string resolves correctly from either). The runtime
643
+ // (`loadIslandManifest`) rehydrates it to an absolute path against cwd before
644
+ // the SSR import. Mirrors the .components.json contract (emitComponentArtifacts).
645
+ const projectRoot = process.cwd()
638
646
  const enriched: EnrichedIslandEntry[] = raw.map((entry) => {
639
647
  const sourcePath = pageImports.get(entry.component)
640
648
  if (!sourcePath) {
@@ -642,7 +650,7 @@ export function reconcileIslandManifest(
642
650
  `island component "${entry.component}" in native route "${routeName}" has no matching import in the page source (expected \`import ${entry.component} from "..."\`)`,
643
651
  )
644
652
  }
645
- return { ...entry, sourcePath }
653
+ return { ...entry, sourcePath: relative(projectRoot, sourcePath).replaceAll('\\', '/') }
646
654
  })
647
655
 
648
656
  writeFileSync(islandsJsonPath, JSON.stringify(enriched))
@@ -26,3 +26,7 @@ export type { TreatyResponse, ClientOptions } from '../treaty.ts'
26
26
  // surface and cannot be bundled for the browser. react.ts → define-store.ts is
27
27
  // browser-safe (no node:async_hooks; the server resolver is injected separately).
28
28
  export { useStore } from '../store/react.ts'
29
+
30
+ // Navigation-state view adapter (same rationale as useStore — browser/island
31
+ // entry only). brustjs/navigation itself stays React-free; the hook lives here.
32
+ export { useNav } from '../navigation/react.ts'
package/runtime/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('brustjs-android-arm64')
79
79
  const bindingPackageVersion = require('brustjs-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('brustjs-android-arm-eabi')
95
95
  const bindingPackageVersion = require('brustjs-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('brustjs-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('brustjs-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('brustjs-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('brustjs-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('brustjs-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('brustjs-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('brustjs-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('brustjs-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('brustjs-darwin-universal')
184
184
  const bindingPackageVersion = require('brustjs-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('brustjs-darwin-x64')
200
200
  const bindingPackageVersion = require('brustjs-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('brustjs-darwin-arm64')
216
216
  const bindingPackageVersion = require('brustjs-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('brustjs-freebsd-x64')
236
236
  const bindingPackageVersion = require('brustjs-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('brustjs-freebsd-arm64')
252
252
  const bindingPackageVersion = require('brustjs-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('brustjs-linux-x64-musl')
273
273
  const bindingPackageVersion = require('brustjs-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('brustjs-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('brustjs-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('brustjs-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('brustjs-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('brustjs-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('brustjs-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('brustjs-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('brustjs-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('brustjs-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('brustjs-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('brustjs-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('brustjs-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('brustjs-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('brustjs-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('brustjs-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('brustjs-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('brustjs-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('brustjs-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('brustjs-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('brustjs-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('brustjs-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('brustjs-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('brustjs-openharmony-arm64')
478
478
  const bindingPackageVersion = require('brustjs-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('brustjs-openharmony-x64')
494
494
  const bindingPackageVersion = require('brustjs-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('brustjs-openharmony-arm')
510
510
  const bindingPackageVersion = require('brustjs-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.1.25-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.1.25-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.1.27-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.1.27-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
package/runtime/index.ts CHANGED
@@ -459,6 +459,39 @@ export const brust = {
459
459
  const jinjaDir = prebuilt
460
460
  ? path.join(distDir!, 'jinja')
461
461
  : path.resolve(process.cwd(), '.brust/jinja')
462
+
463
+ // Source mode (`bun run <entry>`, not prebuilt): the emitted native
464
+ // templates in `.brust/jinja` may be missing (never built) or older than
465
+ // the authored `.tsx` (edited since). Recompile them at boot so a native
466
+ // route doesn't 404/stale without a prior `brust build` — the "must build
467
+ // first" papercut. `brust dev` already emits before this boot, so the
468
+ // staleness check is a no-op there; prebuilt ships the templates and skips
469
+ // entirely. A compile failure warns and continues (non-native routes still
470
+ // boot). The heavy emitter is imported lazily so it never enters the hot
471
+ // path (or the prebuilt bundle's live code).
472
+ if (!prebuilt) {
473
+ const routesPath = path.join(scanRoot, 'routes.tsx')
474
+ if (existsSync(routesPath)) {
475
+ const { isJinjaStale } = await import('./cli/jinja-staleness.ts')
476
+ if (isJinjaStale(scanRoot, jinjaDir)) {
477
+ try {
478
+ const { emitNativeTemplates } = await import('./cli/native-routes-emit.ts')
479
+ await emitNativeTemplates({
480
+ entryFile: routesPath,
481
+ flatRoutes: opts.routes as { nativeTemplate?: string }[],
482
+ outDir: jinjaDir,
483
+ repoRoot: process.cwd(),
484
+ })
485
+ console.log(`[brust] main: compiled native templates → ${jinjaDir}`)
486
+ } catch (err) {
487
+ console.warn(
488
+ `[brust] main: native template recompile failed (run \`brust build\`): ${(err as Error).message}`,
489
+ )
490
+ }
491
+ }
492
+ }
493
+ }
494
+
462
495
  configureJinjaDir(jinjaDir)
463
496
  loadJinjaOnce(jinjaDir)
464
497
  if (prebuilt && existsSync(jinjaDir)) {
@@ -708,11 +741,24 @@ export const brust = {
708
741
  console.log(`[brust] worker: mcp server ready (${mcpManifest.tools.length} tools)`)
709
742
  }
710
743
 
711
- // Sub-project J note: jinja templates are loaded ONCE process-wide by the
744
+ // Sub-project J note: jinja TEMPLATES are loaded ONCE process-wide by the
712
745
  // main branch's loadJinjaOnce call. Rust's ENV is a process-global
713
746
  // OnceLock; Bun Workers share that process, so calling it from each
714
747
  // worker would panic on second set(). The worker reads ENV.get() at
715
748
  // napi_render_jinja time — no per-worker load needed.
749
+ //
750
+ // BUT the JS-side island/component sidecar readers (native-render.ts)
751
+ // resolve against a MODULE-LOCAL `_configuredJinjaDir`, and Bun Workers
752
+ // are separate JS isolates — that variable is unset here unless we set it.
753
+ // Without this, the worker falls back to `cwd/.brust/jinja`; a prebuilt
754
+ // run then silently depends on the build's `.brust` dual-emit, and once
755
+ // that cache is removed the island manifest reads null → `data-brust-props`
756
+ // renders empty → the client's JSON.parse throws. Configure it to the SAME
757
+ // dir main loads from so native island/component render works dist-only.
758
+ const workerJinjaDir = prebuilt
759
+ ? path.join(distDir!, 'jinja')
760
+ : path.resolve(process.cwd(), '.brust/jinja')
761
+ configureJinjaDir(workerJinjaDir)
716
762
 
717
763
  const { makeRenderer: make } = await import('./routes.ts')
718
764
  let wid: number | null = null
@@ -16,6 +16,14 @@
16
16
  import { createRoot, hydrateRoot, type Root } from 'react-dom/client'
17
17
  import { createElement } from 'react'
18
18
  import { applyStoreSnapshot } from '../store/client-hydrate.ts'
19
+ import {
20
+ __navStart,
21
+ __navCommit,
22
+ __navError,
23
+ __navInit,
24
+ registerNavigator,
25
+ } from '../navigation/store.ts'
26
+ import { installActiveNav } from '../navigation/active-nav.ts'
19
27
 
20
28
  // Track React roots created by hydrateOne so we can unmount them before
21
29
  // removing their DOM in swapMainContent. Without this, removing the DOM
@@ -205,11 +213,12 @@ export function isInternalLink(a: HTMLAnchorElement, event: MouseEvent): boolean
205
213
 
206
214
  let inFlight: AbortController | null = null
207
215
 
208
- async function navigate(url: URL, push: boolean): Promise<void> {
216
+ export async function navigate(url: URL, mode: 'push' | 'replace' | 'none'): Promise<void> {
209
217
  inFlight?.abort()
210
218
  const ac = new AbortController()
211
219
  inFlight = ac
212
220
  try {
221
+ __navStart(url.pathname, url.search)
213
222
  const resp = await fetch(`/_brust/page${url.pathname}${url.search}`, {
214
223
  signal: ac.signal,
215
224
  headers: { Accept: 'application/json' },
@@ -226,11 +235,14 @@ async function navigate(url: URL, push: boolean): Promise<void> {
226
235
  swapMainContent(main as HTMLElement, html)
227
236
  if (store) applyStoreSnapshot(store)
228
237
  if (title) document.title = title
229
- if (push) history.pushState({}, '', url.href)
238
+ if (mode === 'push') history.pushState({}, '', url.href)
239
+ else if (mode === 'replace') history.replaceState({}, '', url.href)
230
240
  window.scrollTo(0, 0)
231
241
  hydrateMarkersIn(main as HTMLElement)
242
+ __navCommit(url.pathname, url.search)
232
243
  } catch (err) {
233
244
  if ((err as Error).name === 'AbortError') return
245
+ __navError(url.pathname, err)
234
246
  console.warn('[brust] SPA navigation failed, falling back to full reload:', err)
235
247
  location.href = url.href
236
248
  } finally {
@@ -250,20 +262,25 @@ function installInterceptor(): void {
250
262
  e.preventDefault()
251
263
  // 'reload' = clicking the page we're already on → no-op (no refetch).
252
264
  if (intent === 'reload') return
253
- void navigate(new URL(a.href, location.href), /* push */ true)
265
+ void navigate(new URL(a.href, location.href), 'push')
254
266
  })
255
267
  window.addEventListener('popstate', () => {
256
- void navigate(new URL(location.href), /* push */ false)
268
+ void navigate(new URL(location.href), 'none')
257
269
  })
258
270
  }
259
271
 
260
272
  if (typeof document !== 'undefined') {
273
+ registerNavigator((url, replace) => navigate(url, replace ? 'replace' : 'push'))
261
274
  if (document.readyState === 'loading') {
262
275
  document.addEventListener('DOMContentLoaded', () => {
276
+ __navInit(location.pathname, location.search)
277
+ installActiveNav()
263
278
  hydrateMarkersIn(document.body)
264
279
  installInterceptor()
265
280
  })
266
281
  } else {
282
+ __navInit(location.pathname, location.search)
283
+ installActiveNav()
267
284
  hydrateMarkersIn(document.body)
268
285
  installInterceptor()
269
286
  }
@@ -13,8 +13,11 @@ export interface IslandProps<P> {
13
13
  * component (no anonymous default export). */
14
14
  component: ComponentType<P>
15
15
  /** Props passed to the component on both server and client. Must be
16
- * JSON-serializable (no functions, classes, DOM nodes, etc.). */
17
- props: P
16
+ * JSON-serializable (no functions, classes, DOM nodes, etc.). Optional — a
17
+ * propless island (e.g. one that reads only global/client state) may omit it;
18
+ * it defaults to `{}`. On native routes, omitting `props` lowers to an empty
19
+ * props_path the renderer fills with `{}`. */
20
+ props?: P
18
21
  /** When to hydrate. Default 'load'. */
19
22
  hydrate?: HydrateTrigger
20
23
  /** Native routes only: render this island server-side (renderToString during
@@ -74,7 +77,8 @@ export function Island<P extends object>({
74
77
  'export or a minified/inlined function.',
75
78
  )
76
79
  }
77
- const propsJson = JSON.stringify(props)
80
+ const resolvedProps = (props ?? {}) as P
81
+ const propsJson = JSON.stringify(resolvedProps)
78
82
  return createElement(
79
83
  'div',
80
84
  {
@@ -82,6 +86,6 @@ export function Island<P extends object>({
82
86
  'data-brust-props': propsJson,
83
87
  'data-brust-hydrate': hydrate,
84
88
  },
85
- createElement(Component, props),
89
+ createElement(Component, resolvedProps),
86
90
  )
87
91
  }
@@ -128,6 +128,17 @@ export function loadIslandManifest(
128
128
  manifestCache.set(abs, null)
129
129
  return null
130
130
  }
131
+ // sourcePath ships PROJECT-RELATIVE (no leaked absolute build path). Rehydrate
132
+ // it to an absolute path against cwd so the SSR `import(entry.sourcePath)` in
133
+ // resolveIslandContext resolves regardless of where the manifest lives. An
134
+ // already-absolute path (old manifests, unit-test stubs) passes through.
135
+ if (parsed) {
136
+ for (const entry of parsed) {
137
+ if (entry.sourcePath && !path.isAbsolute(entry.sourcePath)) {
138
+ entry.sourcePath = path.resolve(process.cwd(), entry.sourcePath)
139
+ }
140
+ }
141
+ }
131
142
  manifestCache.set(abs, parsed)
132
143
  return parsed
133
144
  }
@@ -149,7 +160,9 @@ export async function resolveIslandContext(
149
160
  ): Promise<Record<string, string>> {
150
161
  const out: Record<string, string> = {}
151
162
  for (const entry of manifest) {
152
- const props = pathInto(data, entry.propsPath)
163
+ // Empty propsPath = a propless island → `{}`. (pathInto('') returns the whole
164
+ // context, which is NOT what an absent `props` attr means.)
165
+ const props = entry.propsPath === '' ? {} : pathInto(data, entry.propsPath)
153
166
  // `?? null` handles undefined props; the `?? 'null'` belt-and-braces covers
154
167
  // the case where JSON.stringify itself returns undefined (e.g. a function
155
168
  // value), so entityEncode never receives undefined. Hoisted ABOVE the ssr
@@ -0,0 +1,75 @@
1
+ // runtime/navigation/active-nav.ts
2
+ // The DOM consumer of the navigation store. Installs two effects:
3
+ // - nav.path → reconcile is-active/aria-current on links in [data-brust-active-nav]
4
+ // - nav.phase → mirror to <html data-brust-nav> for CSS-driven indicators
5
+ // Attribute name [data-brust-active-nav] is deliberately distinct from the
6
+ // <html data-brust-nav> phase attr so the reconciler never treats <html> as a
7
+ // container (which would toggle is-active on every <a> in the document).
8
+ import { effect } from '../store/signal.ts'
9
+ import { nav, type NavPhase } from './store.ts'
10
+
11
+ // The install guard lives on globalThis (like __BRUST_NAV__), NOT as a module
12
+ // `let`: every Bun.build island chunk inlines its own copy of this module, so a
13
+ // module-local flag would not stop a second chunk from installing a duplicate
14
+ // pair of effects (both resolve the same singleton signals → double reconcile).
15
+ interface ActiveNavState {
16
+ installed: boolean
17
+ disposers: Array<() => void>
18
+ }
19
+ const GA = globalThis as { __BRUST_ACTIVE_NAV__?: ActiveNavState }
20
+ function activeNavState(): ActiveNavState {
21
+ if (!GA.__BRUST_ACTIVE_NAV__) GA.__BRUST_ACTIVE_NAV__ = { installed: false, disposers: [] }
22
+ return GA.__BRUST_ACTIVE_NAV__
23
+ }
24
+
25
+ export function installActiveNav(): void {
26
+ const a = activeNavState()
27
+ if (a.installed) return
28
+ a.installed = true
29
+ // effect() runs eagerly once and re-runs whenever a signal it read changes;
30
+ // it returns a disposer we keep so __resetActiveNavForTest can unsubscribe.
31
+ a.disposers = [
32
+ effect(() => {
33
+ const path = nav.path()
34
+ reconcileActiveLinks(path)
35
+ }),
36
+ effect(() => {
37
+ const phase = nav.phase()
38
+ setHtmlNav(phase)
39
+ }),
40
+ ]
41
+ }
42
+
43
+ function setHtmlNav(phase: NavPhase): void {
44
+ if (typeof document === 'undefined' || !document.documentElement) return
45
+ // 'success' is a transient logical phase; the DOM attr returns to idle so
46
+ // loading indicators clear once committed.
47
+ document.documentElement.setAttribute('data-brust-nav', phase === 'success' ? 'idle' : phase)
48
+ }
49
+
50
+ function reconcileActiveLinks(currentPath: string): void {
51
+ if (typeof document === 'undefined') return
52
+ const containers = document.querySelectorAll<HTMLElement>('[data-brust-active-nav]')
53
+ for (const el of Array.from(containers)) {
54
+ const activeClass = el.dataset.brustActiveClass || 'is-active'
55
+ const prefix = el.dataset.brustActiveMatch === 'prefix'
56
+ const links = el.querySelectorAll<HTMLAnchorElement>('a[href]')
57
+ for (const a of Array.from(links)) {
58
+ const linkPath = new URL(a.href, location.href).pathname
59
+ const isActive = prefix
60
+ ? currentPath === linkPath || currentPath.startsWith(`${linkPath.replace(/\/$/, '')}/`)
61
+ : currentPath === linkPath
62
+ a.classList.toggle(activeClass, isActive)
63
+ if (isActive) a.setAttribute('aria-current', 'page')
64
+ else a.removeAttribute('aria-current')
65
+ }
66
+ }
67
+ }
68
+
69
+ // Test-only: dispose the installed effects and clear the guard so a subsequent
70
+ // installActiveNav() rebinds to the fresh singleton (after __resetNavForTest).
71
+ export function __resetActiveNavForTest(): void {
72
+ const a = activeNavState()
73
+ for (const d of a.disposers) d()
74
+ GA.__BRUST_ACTIVE_NAV__ = undefined
75
+ }
@@ -0,0 +1,15 @@
1
+ // runtime/navigation/index.ts — brustjs/navigation. React-free, DOM-free entry.
2
+ // (active-nav.ts uses DOM globals but imports no DOM module; it's re-exported for
3
+ // authors who add nav containers dynamically. bootstrap wires it automatically.)
4
+ export type { NavPhase, NavState, NavStore } from './store.ts'
5
+ export {
6
+ nav,
7
+ getNavState,
8
+ subscribe,
9
+ onBeforeNavigate,
10
+ onNavigate,
11
+ onNavigateError,
12
+ } from './store.ts'
13
+ export { installActiveNav } from './active-nav.ts'
14
+ export { navigate, buildSearch } from './navigate.ts'
15
+ export type { NavigateOptions, QueryInit, QueryValue } from './navigate.ts'
@@ -0,0 +1,58 @@
1
+ // runtime/navigation/navigate.ts — public imperative SPA navigation for
2
+ // brustjs/navigation. DOM-free at import (touches location/history only at call
3
+ // time, like active-nav.ts); delegates the swap to the navigator bootstrap
4
+ // registers, so this module never imports DOM/island code.
5
+ import { _getNavigator } from './store.ts'
6
+
7
+ export type QueryValue = string | number | boolean
8
+ export type QueryInit = Record<string, QueryValue | null | undefined | ReadonlyArray<QueryValue>>
9
+ export interface NavigateOptions {
10
+ query?: QueryInit
11
+ replace?: boolean
12
+ }
13
+
14
+ function applyQuery(params: URLSearchParams, query: QueryInit): void {
15
+ for (const key of Object.keys(query)) {
16
+ const v = query[key]
17
+ params.delete(key)
18
+ if (v === null || v === undefined) continue
19
+ if (Array.isArray(v)) {
20
+ for (const item of v) params.append(key, String(item))
21
+ } else {
22
+ params.append(key, String(v as QueryValue))
23
+ }
24
+ }
25
+ }
26
+
27
+ /** Serialize a query object to a `?...` string (or '' when empty). Pure, DOM-free. */
28
+ export function buildSearch(query: QueryInit): string {
29
+ const params = new URLSearchParams()
30
+ applyQuery(params, query)
31
+ const s = params.toString()
32
+ return s ? `?${s}` : ''
33
+ }
34
+
35
+ /** Programmatic SPA navigation. Resolves `path` against the current location,
36
+ * merges `options.query` over any query already in `path` (each key replaces all
37
+ * base occurrences; null/undefined deletes), then delegates to the registered
38
+ * navigator (full SPA swap + nav-state lifecycle). No navigator registered (no
39
+ * islands bootstrap) → full-document load so the call still navigates. */
40
+ export async function navigate(path: string, options?: NavigateOptions): Promise<void> {
41
+ // navigate() is a client-only action (resolves against location + drives the DOM
42
+ // swap). Guard the bare `location` access so a server-side call surfaces a
43
+ // legible error instead of a raw `ReferenceError` (mirrors active-nav.ts's
44
+ // typeof-guard discipline; see the SSR non-goal in the design).
45
+ if (typeof location === 'undefined') {
46
+ throw new Error(
47
+ '[brust] navigate() is a client-only action — no location/DOM available (called during SSR?)',
48
+ )
49
+ }
50
+ const url = new URL(path, location.href)
51
+ if (options?.query) applyQuery(url.searchParams, options.query)
52
+ const nav = _getNavigator()
53
+ if (nav) {
54
+ await nav(url, options?.replace ?? false)
55
+ } else {
56
+ location.assign(url.href)
57
+ }
58
+ }
@@ -0,0 +1,24 @@
1
+ // React view-layer adapter for the navigation store. Lives OUTSIDE navigation/
2
+ // index.ts (which stays React-free + in the typecheck:treaty gate) and is reached
3
+ // only via brustjs/client, the browser/island entry. Uses useSyncExternalStore so
4
+ // a React island re-renders on every navigation transition; getNavState is
5
+ // version-memoized (store.ts) so the snapshot is referentially stable.
6
+ import { useSyncExternalStore } from 'react'
7
+ import { getNavState, subscribe, type NavState } from './store.ts'
8
+
9
+ /** Watch the navigation state from a React island.
10
+ *
11
+ * ```tsx
12
+ * import { useNav } from 'brustjs/client'
13
+ * function Crumb() {
14
+ * const { path, phase } = useNav()
15
+ * return <span>{phase === 'loading' ? 'Loading…' : path}</span>
16
+ * }
17
+ * ```
18
+ *
19
+ * The third arg (server snapshot) is the same getter — on the server the store
20
+ * holds its idle defaults (no `location`), so SSR renders the idle state and the
21
+ * client hydrates the real one on mount. */
22
+ export function useNav(): NavState {
23
+ return useSyncExternalStore(subscribe, getNavState, getNavState)
24
+ }
@@ -0,0 +1,220 @@
1
+ // runtime/navigation/store.ts
2
+ // Client-side navigation state for brust, driven by the SPA navigator in
3
+ // runtime/islands/bootstrap.ts. Fully React-free AND DOM-free: __navInit takes
4
+ // the initial path/search as arguments (bootstrap reads location), so this module
5
+ // imports nothing web-API and unit-tests without a DOM. The DOM consumer (active
6
+ // links + html[data-brust-nav]) lives in ./active-nav.ts.
7
+ //
8
+ // The `nav` bag of signals is a singleton stashed on globalThis.__BRUST_NAV__:
9
+ // signals share their reactive tracker cross-chunk via Symbol.for (see
10
+ // store/signal.ts), but the bag OBJECT must also be shared or each Bun.build
11
+ // chunk would build its own — the stash gives one object identity for all chunks.
12
+ import { batch, signal, type Signal } from '../store/signal.ts'
13
+
14
+ export type NavPhase = 'idle' | 'loading' | 'success' | 'error'
15
+
16
+ export interface NavState {
17
+ path: string
18
+ search: string
19
+ phase: NavPhase
20
+ error: Error | null
21
+ from: string | null
22
+ to: string | null
23
+ }
24
+
25
+ export interface NavStore {
26
+ path: Signal<string>
27
+ search: Signal<string>
28
+ phase: Signal<NavPhase>
29
+ error: Signal<Error | null>
30
+ from: Signal<string | null>
31
+ to: Signal<string | null>
32
+ }
33
+
34
+ type BeforeCb = (e: { from: string; to: string }) => void
35
+ type NavCb = (e: NavState) => void
36
+ type ErrorCb = (e: { to: string; error: Error }) => void
37
+
38
+ interface NavInternal extends NavStore {
39
+ _subs: Set<NavCb>
40
+ _before: Set<BeforeCb>
41
+ _success: Set<NavCb>
42
+ _error: Set<ErrorCb>
43
+ // version bumps once per committed transition (in emit); `_snap` memoizes the
44
+ // NavState for that version so getNavState() returns a referentially-stable
45
+ // object — required by React's useSyncExternalStore (a fresh object each call
46
+ // would infinite-loop "getSnapshot should be cached"). Mirrors defineStore.
47
+ _version: number
48
+ _snap: { value: NavState; version: number } | null
49
+ _navigator: ((url: URL, replace: boolean) => Promise<void>) | null
50
+ }
51
+
52
+ function createNav(): NavInternal {
53
+ return {
54
+ path: signal(''),
55
+ search: signal(''),
56
+ phase: signal<NavPhase>('idle'),
57
+ error: signal<Error | null>(null),
58
+ from: signal<string | null>(null),
59
+ to: signal<string | null>(null),
60
+ _subs: new Set(),
61
+ _before: new Set(),
62
+ _success: new Set(),
63
+ _error: new Set(),
64
+ _version: 0,
65
+ _snap: null,
66
+ _navigator: null,
67
+ }
68
+ }
69
+
70
+ const G = globalThis as { __BRUST_NAV__?: NavInternal }
71
+ function store(): NavInternal {
72
+ if (!G.__BRUST_NAV__) G.__BRUST_NAV__ = createNav()
73
+ return G.__BRUST_NAV__
74
+ }
75
+
76
+ // Public reactive handle. A Proxy resolves the singleton on each property access
77
+ // so (a) every chunk's `nav` points at the one globalThis bag, and (b) tests that
78
+ // reset the singleton see the fresh signals.
79
+ export const nav: NavStore = new Proxy({} as NavStore, {
80
+ get(_t, prop: string | symbol) {
81
+ // Symbol keys (Symbol.toPrimitive, Symbol.for('brust.signal') brand probes,
82
+ // React DevTools, etc.) are never store fields — return undefined without
83
+ // forcing a lazy singleton init.
84
+ if (typeof prop !== 'string') return undefined
85
+ return (store() as unknown as Record<string, unknown>)[prop]
86
+ },
87
+ })
88
+
89
+ export function getNavState(): NavState {
90
+ const s = store()
91
+ // Return the memoized snapshot if no transition has happened since it was
92
+ // built (referential stability for useSyncExternalStore).
93
+ if (s._snap && s._snap.version === s._version) return s._snap.value
94
+ const value: NavState = {
95
+ path: s.path(),
96
+ search: s.search(),
97
+ phase: s.phase(),
98
+ error: s.error(),
99
+ from: s.from(),
100
+ to: s.to(),
101
+ }
102
+ s._snap = { value, version: s._version }
103
+ return value
104
+ }
105
+
106
+ // Bump the snapshot version immediately after a batch of signal writes so the
107
+ // NEXT getNavState() rebuilds (the lifecycle callbacks + emit must see committed
108
+ // state, not the stale memoized snapshot). Called once per transition, right
109
+ // after the batch and before any callback/getNavState read.
110
+ function bumpVersion(s: NavInternal): void {
111
+ s._version += 1
112
+ }
113
+
114
+ function emit(s: NavInternal): void {
115
+ const snap = getNavState()
116
+ for (const cb of [...s._subs]) cb(snap)
117
+ }
118
+
119
+ export function subscribe(cb: NavCb): () => void {
120
+ const s = store()
121
+ s._subs.add(cb)
122
+ return () => s._subs.delete(cb)
123
+ }
124
+ export function onBeforeNavigate(cb: BeforeCb): () => void {
125
+ const s = store()
126
+ s._before.add(cb)
127
+ return () => s._before.delete(cb)
128
+ }
129
+ export function onNavigate(cb: NavCb): () => void {
130
+ const s = store()
131
+ s._success.add(cb)
132
+ return () => s._success.delete(cb)
133
+ }
134
+ export function onNavigateError(cb: ErrorCb): () => void {
135
+ const s = store()
136
+ s._error.add(cb)
137
+ return () => s._error.delete(cb)
138
+ }
139
+
140
+ // Each lifecycle mutator writes several signals. We wrap the writes in batch()
141
+ // so a consumer effect reading multiple fields (e.g. nav.path() + nav.phase())
142
+ // re-runs ONCE on the settled state instead of firing on each torn intermediate
143
+ // write. The lifecycle callbacks (_before/_success/_error) and emit() run AFTER
144
+ // the batch so they observe fully-committed state.
145
+ export function __navInit(path: string, search: string): void {
146
+ const s = store()
147
+ batch(() => {
148
+ s.path.set(path)
149
+ s.search.set(search)
150
+ s.phase.set('idle')
151
+ s.from.set(null)
152
+ s.to.set(null)
153
+ s.error.set(null)
154
+ })
155
+ bumpVersion(s)
156
+ emit(s)
157
+ }
158
+
159
+ // `toSearch` is intentionally unused during 'loading': search is part of the
160
+ // COMMITTED state and is written by __navCommit, not while the fetch is pending.
161
+ // Kept in the signature for call-site symmetry with __navCommit.
162
+ export function __navStart(toPath: string, _toSearch: string): void {
163
+ const s = store()
164
+ const from = s.path()
165
+ batch(() => {
166
+ s.from.set(from)
167
+ s.to.set(toPath)
168
+ s.error.set(null)
169
+ s.phase.set('loading')
170
+ })
171
+ bumpVersion(s)
172
+ for (const cb of [...s._before]) cb({ from, to: toPath })
173
+ emit(s)
174
+ }
175
+
176
+ export function __navCommit(toPath: string, toSearch: string): void {
177
+ const s = store()
178
+ batch(() => {
179
+ s.path.set(toPath)
180
+ s.search.set(toSearch)
181
+ s.to.set(null)
182
+ s.error.set(null)
183
+ s.phase.set('success')
184
+ })
185
+ bumpVersion(s)
186
+ const snap = getNavState()
187
+ for (const cb of [...s._success]) cb(snap)
188
+ emit(s)
189
+ }
190
+
191
+ // Accepts `unknown` because the only caller is bootstrap's catch block (err is
192
+ // `unknown` under strict TS); coerce non-Error throws (strings, DOMException)
193
+ // into an Error so consumers always get a stable shape.
194
+ export function __navError(toPath: string, error: unknown): void {
195
+ const s = store()
196
+ const err = error instanceof Error ? error : new Error(String(error))
197
+ batch(() => {
198
+ s.to.set(null)
199
+ s.error.set(err)
200
+ s.phase.set('error')
201
+ })
202
+ bumpVersion(s)
203
+ for (const cb of [...s._error]) cb({ to: toPath, error: err })
204
+ emit(s)
205
+ }
206
+
207
+ /** Register the SPA navigator implementation (bootstrap's swap). Last-write-wins;
208
+ * re-registration with the same closure (HMR / multiple chunks) is idempotent. */
209
+ export function registerNavigator(fn: (url: URL, replace: boolean) => Promise<void>): void {
210
+ store()._navigator = fn
211
+ }
212
+ /** @internal — the registered navigator, or null when no islands bootstrap loaded. */
213
+ export function _getNavigator(): ((url: URL, replace: boolean) => Promise<void>) | null {
214
+ return store()._navigator
215
+ }
216
+
217
+ // Test-only: drop the singleton so the next access rebuilds fresh signals.
218
+ export function __resetNavForTest(): void {
219
+ G.__BRUST_NAV__ = undefined
220
+ }
package/runtime/routes.ts CHANGED
@@ -11,6 +11,7 @@ import { Buffer } from 'node:buffer'
11
11
  import * as native from './index.js'
12
12
  import { renderBranchStreaming } from './render/stream.ts'
13
13
  import { runInStoreContext, collectSnapshot } from './store/server-context.ts'
14
+ import { buildStoreScripts } from './render/inject-store.ts'
14
15
  import { runInRequestCache } from './loader-cache.ts'
15
16
  import { runInRequestScope, __scope } from './request-context.ts'
16
17
  import {
@@ -729,17 +730,22 @@ export function makeRenderer(
729
730
  let data: Record<string, unknown>
730
731
  const ctx = { params: call.params, path: call.path, req: call.req }
731
732
  let chainResult: NativeChainResult
733
+ let storeSnapshot: Record<string, Record<string, unknown>> | null = null
732
734
  try {
733
735
  // Run the WHOLE route chain's loaders top-down (parent → leaf) and
734
736
  // merge into ONE flat context (child keys win), mirroring the React
735
737
  // chain-loader path. Wrap the entire loop in a SINGLE per-request
736
738
  // store scope so a parent loader's defineStore writes are visible to
737
- // child loaders (one Map per request — NOT one per loader). No
738
- // snapshot is collected and no <script> is injected on native paths —
739
- // Spec B owns native store delivery (hard non-goal here).
740
- chainResult = await runInRequestContext(call.req?.cookies ?? {}, () =>
741
- runNativeChainLoaders(flat.chain, ctx),
742
- )
739
+ // child loaders (one Map per request — NOT one per loader). B7: the
740
+ // store snapshot IS collected here, inside the request-store scope and
741
+ // AFTER the loaders run (the only point native store writes happen
742
+ // the render is Rust-side and touches no store), feeding the
743
+ // document-shell `{{ __brust_store__ }}` slot below.
744
+ chainResult = await runInRequestContext(call.req?.cookies ?? {}, async () => {
745
+ const r = await runNativeChainLoaders(flat.chain, ctx)
746
+ storeSnapshot = collectSnapshot()
747
+ return r
748
+ })
743
749
  } catch (err) {
744
750
  console.error(`[brust] loader failed for native route ${flat.fullPath}:`, err)
745
751
  // FAST LANE: native routes take dispatch_single_chunk (no chunk
@@ -769,6 +775,24 @@ export function makeRenderer(
769
775
  } else {
770
776
  data = chainResult.data
771
777
  }
778
+ // B7 — native store-snapshot SSR. Fill the framework-owned
779
+ // `{{ __brust_store__ | safe }}` slot (emitted into every native
780
+ // full-document <head>) with the defineStore SSR snapshot collected
781
+ // inside the request-store scope above. buildStoreScripts(null) === '',
782
+ // so the key is always a string and both render sub-paths (the
783
+ // island/component JSON.parse path and the no-island encode path)
784
+ // inherit it for free.
785
+ if (data && typeof data === 'object') {
786
+ // `__brust_store__` is a framework-reserved render-context key. A user
787
+ // loader returning it would be silently overwritten here; dev-warn so
788
+ // the collision isn't invisible (mirrors the Set-Cookie warning below).
789
+ if (process.env.BRUST_DEV === '1' && '__brust_store__' in data) {
790
+ console.warn(
791
+ `[brust] native loader for "${flat.nativeTemplate}" returned a reserved "__brust_store__" key — overwritten by the store snapshot`,
792
+ )
793
+ }
794
+ ;(data as Record<string, unknown>).__brust_store__ = buildStoreScripts(storeSnapshot)
795
+ }
772
796
  const json = JSON.stringify(data)
773
797
  // napiRenderJinja has no headers param — any Set-Cookie staged by a
774
798
  // native loader is dropped on this path. Dev-warn so it's not silent.
@@ -11,5 +11,14 @@
11
11
  "jsx": "react-jsx",
12
12
  "types": []
13
13
  },
14
- "files": ["treaty.ts", "define-actions.ts", "standard-schema.ts", "treaty.type-test.ts"]
14
+ "files": [
15
+ "treaty.ts",
16
+ "define-actions.ts",
17
+ "standard-schema.ts",
18
+ "treaty.type-test.ts",
19
+ "navigation/index.ts",
20
+ "navigation/store.ts",
21
+ "navigation/active-nav.ts",
22
+ "navigation/navigate.ts"
23
+ ]
15
24
  }