@brust/core 2.0.0-alpha.3 → 2.0.0-alpha.4

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.
Files changed (47) hide show
  1. package/README.md +64 -6
  2. package/native/index.d.ts +37 -2
  3. package/native/index.js +56 -54
  4. package/package.json +11 -9
  5. package/src/actions/client.ts +22 -5
  6. package/src/actions/load.ts +2 -1
  7. package/src/actions/prefix.ts +24 -2
  8. package/src/actions-bridge.ts +2 -2
  9. package/src/browser.ts +3 -1
  10. package/src/build/actions-only.ts +86 -0
  11. package/src/build/build-eval.ts +199 -0
  12. package/src/build/build-icons.ts +69 -0
  13. package/src/build/bundle.ts +39 -13
  14. package/src/build/cf-assets.ts +4 -2
  15. package/src/build/cf-entry.ts +7 -3
  16. package/src/build/cf-wrangler.ts +3 -1
  17. package/src/build/cloudflare.ts +14 -9
  18. package/src/build/compile.ts +41 -4
  19. package/src/build/config.ts +46 -10
  20. package/src/build/css.ts +286 -0
  21. package/src/build/index.ts +135 -20
  22. package/src/build/manifest.ts +23 -4
  23. package/src/build/scan.ts +59 -20
  24. package/src/build/ssg-render.ts +65 -0
  25. package/src/build/ssg.ts +146 -0
  26. package/src/build/static-worker.ts +91 -0
  27. package/src/build/static.ts +258 -0
  28. package/src/build-time.ts +10 -0
  29. package/src/cf.ts +2 -1
  30. package/src/cli.ts +19 -4
  31. package/src/config.ts +111 -25
  32. package/src/css-modules.d.ts +8 -0
  33. package/src/dev/bun.ts +365 -0
  34. package/src/dev/client.ts +92 -0
  35. package/src/dev/devtools-data.ts +23 -0
  36. package/src/dev/devtools.ts +356 -0
  37. package/src/dev/diag.ts +30 -0
  38. package/src/dev/proxy.ts +236 -0
  39. package/src/dev/tui.ts +144 -0
  40. package/src/dev/watch.ts +81 -0
  41. package/src/dev.ts +11 -28
  42. package/src/handlers.ts +41 -2
  43. package/src/index.ts +3 -1
  44. package/src/native.ts +18 -0
  45. package/src/routes.ts +20 -1
  46. package/src/run.ts +40 -8
  47. package/src/worker.ts +88 -20
package/README.md CHANGED
@@ -18,19 +18,24 @@ export const routes = defineRoutes([
18
18
  ])
19
19
  ```
20
20
 
21
- Route fields are exactly `path`, `Component`, `loader`, `cache`, `children`; anything else fails the
21
+ Route fields are exactly `path`, `Component`, `loader`, `cache`, `ssg`, `children` (`ssg` only matters
22
+ to `--target static`, see [docs/static.md](../../docs/static.md)); anything else fails the
22
23
  build with `<field> is not supported in M2 (M3)`. Loaders run root → leaf, results merge flat
23
24
  (later keys win); return `notFound(data)` / `redirect(location, status)` or throw
24
25
  `httpError(status, body)` for a verdict. `cache(Comp, opts)` and `cache.invalidate(…)` ship too.
25
26
 
26
27
  ## `brust build [entry=routes.tsx] [--out-dir dist]`
27
28
 
29
+ `--target static [--strict]` also renders every page to `dist/static/` for Cloudflare Pages or Workers
30
+ Static Assets: see [docs/static.md](../../docs/static.md).
31
+
28
32
  Compiles every route component through lowering, then writes (always from scratch):
29
33
 
30
34
  ```
31
35
  dist/manifest.json the only build → server contract (spec S6)
32
36
  dist/jinja/<id>.jinja templates dist/jobs.js + jobs/*.server.ts worker jobs
33
37
  dist/client/*-<hex>.js runtime, native chunks, react-<id> island chunks (served immutable)
38
+ dist/client/*-<hex>.css one minified stylesheet per imported .css / .module.css (see docs/css.md)
34
39
  dist/public/ copied from ./public dist/index.js `bun dist/index.js` = start
35
40
  ```
36
41
 
@@ -62,15 +67,64 @@ generated files resolve against the component's source dir, bare imports against
62
67
  `--out-dir` may point anywhere; at run time `dist/` must still resolve `react` and `@brust/core`
63
68
  (keep it inside the app, or next to a `node_modules` that has them).
64
69
 
70
+ ## `brust dev [entry=routes.tsx] [--port N] [--workers N]`
71
+
72
+ The Bun-target dev server. A long-lived parent owns your port and proxies to the newest build; every
73
+ successful build is booted as a new child (`brust start` on a loopback port, `--workers 1` unless you pass
74
+ `--workers`), the proxy switches over, browsers are told to `reload`, and the old child is stopped. A failed
75
+ build **or a failed boot** keeps the old child serving and shows the error as an overlay above the stale page
76
+ (a page opened while builds fail shows it too); the next good build clears it and reloads.
77
+
78
+ - Source changes do a full reload (debounced ~150 ms; an edit made during a rebuild is not dropped).
79
+ - A change to `public/*.css` skips the build: the file is copied into the running dist and the `<link>` is
80
+ swapped (`?v=`), the page keeps its state. Other `public/` files reload.
81
+ - Every `text/html` response, including error pages, gets `/_brust/dev/client.js` (a WebSocket at
82
+ `/_brust/dev/ws`); responses are `cache-control: no-store`. `Host` and `Origin` reach the child unchanged,
83
+ so the actions cross-site guard behaves as in production.
84
+ - Dev builds use React in development mode (`NODE_ENV=development`); `brust build` / `brust start` are unchanged.
85
+ - The terminal shows request lines (`method path status ms cache`) and a status block of at most 6 lines at the
86
+ bottom (state, URL, generation, build time, last request, warnings, hotkeys `r` reload, `o` open, `w` warnings,
87
+ `c` clear, `q` quit). It never uses the alternate screen. Not a TTY, `CI` or `NO_COLOR`: plain lines only.
88
+ - **Trace for dev tools (L14).** The dev proxy generates a token per session and gives it to each child (`BRUST_DEV_TOKEN`,
89
+ napi `devToken`) and to every upstream request (`x-brust-dev-token`). Only then the core answers `x-brust-dev: base64(json)`
90
+ (route, pattern, chain, params, cache outcome, loader and render ms, jobs with kind/key/tags/hit, bun calls, the components the
91
+ page is made of). It is added after the L1 store, so it is never cached; a core without a token (production) never makes it.
92
+ The proxy strips the header, puts the trace in the page as `<script type=application/json id=__brust_trace>` and keeps the
93
+ last 50 (actions included) at `/_brust/dev/traces`. `brust build --dev` (used by `brust dev`) also writes `dev.json`
94
+ (component id → source file, tier, the react reason, diagnostics with rule/line/col/remediation; served at `/_brust/dev/meta`);
95
+ a production build writes none. In dev only, every chain level is wrapped in `<!--brust:<id>-->…<!--/brust-->` (never inside a
96
+ `<brust-island>`), and the runtime exposes its live instances on `globalThis.__brustDev.instances` (`__BRUST_DEV__` is a
97
+ build define that is `false`, and removed by the minifier, in every other build).
98
+ - **`<brust-devtools>` (L15).** The dev proxy serves `/_brust/dev/devtools.js` (bundled from `src/dev/devtools.ts` on first request) and
99
+ injects it into every HTML response, so `brust start` and production builds contain none of it. A corner indicator shows the build state
100
+ and the page's tier counts (`ready · 2s 1n 1r`); `Alt+Shift+B` toggles the panel (real buttons and tabs, arrow keys, `Esc` closes and
101
+ restores focus, contrast ≥ 4.5:1 in light and dark). Panels, each from the trace, `dev.json`, the DOM or `__brustDev` only: **Page**
102
+ (route, params, cache, timings), **Components** (tree with tier badges; a react component shows its reason and diagnostic location;
103
+ hover highlights it), **Jobs**, **Store** (seed from `data-brust-store`, live values of mounted native stores), **Islands**
104
+ (hydrated or not), **Build** (diagnostics with `file:line:col`, the current build error), **Requests** (the last 50). The terminal
105
+ status block shows the same tier counts for the last page.
106
+ - Not hot module replacement: component state does not survive an edit. `brust dev --target cloudflare` keeps
107
+ its wrangler loop (now on the same watch loop).
108
+
65
109
  ## `brust start [--port N] [--workers N] [--dist-dir dist] [--entry routes.tsx]`
66
110
 
67
111
  Prints `[brust] listening on <addr>` then `[brust] ready (N workers)`. `--port 0` picks a free port.
68
112
  SIGINT/SIGTERM drains gracefully (`BRUST_DRAIN_TIMEOUT_MS`); a second signal exits at once.
69
113
  Config precedence: env (`BRUST_ADDR`, `BRUST_PORT`, `BRUST_WORKERS`, `BRUST_RENDER_SLOTS`,
70
- `BRUST_DRAIN_TIMEOUT_MS`, `BRUST_BOOT_TIMEOUT_MS`, `BRUST_CALL_TIMEOUT_MS`, `BRUST_DIST_DIR`, `BRUST_APP_ENTRY`) > flags
71
- (`--port`, `--workers`, `--dist-dir`, `--entry`) > `brust.toml` (`[server] address/port`,
72
- `[workers] count`) > defaults (`localhost:1337`, one worker per CPU, `min(cores, 16)` slots per worker (each slot is a 256 KiB shared response buffer, so 10 slots = 2.5 MiB per worker), 10 s drain, 30 s
73
- worker boot timeout, 30 s call timeout).
114
+ `BRUST_DRAIN_TIMEOUT_MS`, `BRUST_BOOT_TIMEOUT_MS`, `BRUST_CALL_TIMEOUT_MS`, `BRUST_SLOT_BYTES`,
115
+ `BRUST_MAX_LOADER_RESPONSE_BYTES`, `BRUST_DIST_DIR`, `BRUST_APP_ENTRY`) > flags
116
+ (`--port`, `--workers`, `--dist-dir`, `--entry`) and `run({ config })` > `brust.toml` (`[server] address/port/max_loader_response_bytes`,
117
+ `[workers] count/slot_bytes`, `[cors]`) > defaults (`localhost:1337`, one worker per CPU, `min(cores, 16)` slots per worker (each slot is a `slotBytes` shared response buffer, 256 KiB by default, so 10 slots = 2.5 MiB per worker), 10 s drain, 30 s
118
+ worker boot timeout, 30 s call timeout, 8 MiB loader response limit).
119
+ `slotBytes` (`[workers] slot_bytes`, env `BRUST_SLOT_BYTES`, `run({ config: { slotBytes } })`) is 64 KiB..16 MiB.
120
+ A loader, jobs or planned reply that does not fit its slot is not an error: the worker hands it to the server
121
+ over the heap, up to `maxLoaderResponseBytes` (`[server] max_loader_response_bytes`, env
122
+ `BRUST_MAX_LOADER_RESPONSE_BYTES`, `run({ config: { maxLoaderResponseBytes } })`; 256 KiB..64 MiB, default 8 MiB).
123
+ A bigger reply answers `{"error":"response too large: <n> > <limit> (maxLoaderResponseBytes)"}` (a 500). This
124
+ limit applies to loader and jobs replies; `[actions]` has its own `max_response_bytes`.
125
+ `[cors]` can also be given as `run({ config: { cors: { origins, methods, headers, exposeHeaders, credentials,
126
+ maxAgeSeconds } } })` (camelCase, an unknown key is rejected). It replaces a `brust.toml` `[cors]` as a whole,
127
+ never merging with it; `cors: null` turns the toml table off.
74
128
  A loader or job call that has not settled within `BRUST_CALL_TIMEOUT_MS` answers **504**; its worker
75
129
  slot stays claimed until the call settles (the late result is discarded), so a stuck call costs one
76
130
  slot, never a frozen worker. Waiting for a free slot is the separate 503 "all workers busy".
@@ -80,7 +134,11 @@ slot, never a frozen worker. Waiting for a free slot is the separate 503 "all wo
80
134
  ## Worker wire (contract 7, `crates/brust-server/src/protocol.rs`)
81
135
 
82
136
  Requests arrive as inline JSON; responses go into the worker's SharedArrayBuffer slot (never
83
- past `floor(len / slots)` bytes: an oversize response becomes `{"error":…}`). A handler never rejects.
137
+ past `floor(len / slots)` bytes). A `loader`/`jobs` reply that does not fit crosses by heap: the worker
138
+ puts the bytes with `putFetchReply` and writes the 5-byte marker `[0x00][u32 LE n]` into the slot (JSON
139
+ never starts with 0x00); the server reads the `n` bytes it was handed. A loader context too large for the
140
+ slot is planned from the bytes (`planJobsBuf`). Over `maxLoaderResponseBytes` the reply becomes
141
+ `{"error":…}`. A handler never rejects.
84
142
 
85
143
  `loader` `{routeId, params, path, req}` → `{ok:true, data}` | `{verdict, …}` | `{error}`;
86
144
  `jobs` `{jobs:[{id, componentId, kind, inputs, target?, row?}]}` → `{results:[{id, value}|{id, error}]}`
package/native/index.d.ts CHANGED
@@ -18,6 +18,13 @@ export declare function beginDrain(timeoutMs: number): Promise<void>
18
18
  /** Drop both tier-1 caches (a broadcast gap, R10); `stats.l2.resets`++. The L1 entries removed. */
19
19
  export declare function cacheClear(): number
20
20
 
21
+ /**
22
+ * Static output (gaps round R9.4): the request reads of one `cache.prefix` / `cache.bypass`
23
+ * expression (`header(x)`, `cookie(x)`, `query(x)`, `request(host)`), parsed by the server's own
24
+ * grammar. Errors when the expression does not parse. Needs no running server.
25
+ */
26
+ export declare function cacheExprReads(src: string): Array<string>
27
+
21
28
  /** `cache.invalidate({ key?, tags?, path?, method? })` (spec §5). */
22
29
  export declare function cacheInvalidate(args: NapiInvalidateArgs): NapiInvalidateResult
23
30
 
@@ -43,6 +50,8 @@ export interface CompiledComponent {
43
50
  ir: string
44
51
  jinja: string
45
52
  serverTs?: string
53
+ /** Build-time evaluation module (L2): one thunk per `ir.build_eval` slot. */
54
+ evalTs?: string
46
55
  clientJs?: string
47
56
  diagnostics: Array<NapiDiagnostic>
48
57
  }
@@ -52,12 +61,22 @@ export interface CompiledTree {
52
61
  error?: NapiDiagnostic
53
62
  }
54
63
 
55
- /** Compiles `path` (relative to `root`) and every child it reaches through lowering. */
56
- export declare function compileTree(path: string, root: string, runtimeImport: string, serverOnly: Array<string>): CompiledTree
64
+ /**
65
+ * Compiles `path` (relative to `root`) and every child it reaches through lowering. `css_modules` (L20): the class
66
+ * map of each `*.module.css`, keyed by its path relative to `root`; `styles.x` folds to the literal class.
67
+ */
68
+ export declare function compileTree(path: string, root: string, runtimeImport: string, serverOnly: Array<string>, slotValues?: string | undefined | null, cssModules?: Record<string, Record<string, string>> | undefined | null, iconSvgs?: string | undefined | null): CompiledTree
57
69
 
58
70
  /** The bound address as `host:port` (port 0 resolves here). */
59
71
  export declare function localAddr(): string
60
72
 
73
+ /** L16: what the page tells the browser client. `credentials`: `"same-origin"` (default), `"include"` or `"omit"`. */
74
+ export interface NapiActionsClient {
75
+ prefix?: string
76
+ baseUrl?: string
77
+ credentials?: string
78
+ }
79
+
61
80
  /** M3-F A3 consumer `{ prefix?, maxBodyBytes?, maxResponseBytes? }` (defaults `/_brust/action`, 1 MiB, 8 MiB). Present = actions on. */
62
81
  export interface NapiActionsOptions {
63
82
  prefix?: string
@@ -121,6 +140,13 @@ export interface NapiL2Options {
121
140
  */
122
141
  export declare function planJobs(slot: number, len: number): string
123
142
 
143
+ /**
144
+ * L10: [`plan_jobs`] for a loader response too large for the slot: the worker hands the bytes
145
+ * over in `buf` instead of writing them to the slot. Same answers (`""`, the misses' JSON, or
146
+ * `"!"`); a declined plan leaves the response for the worker to hand over with `putFetchReply`.
147
+ */
148
+ export declare function planJobsBuf(slot: number, buf: Uint8Array): string
149
+
124
150
  /**
125
151
  * F82: hand Rust the response body of the calling worker's in-flight `fetch` call for `slot`
126
152
  * (too large for the SAB slot). `false` = declined (over `max_response_bytes`, not in a `fetch`
@@ -152,6 +178,11 @@ export interface StartOptions {
152
178
  * 504 (the slot stays claimed until JS settles). Absent = 30 000.
153
179
  */
154
180
  callTimeoutMs?: number
181
+ /**
182
+ * L10: the biggest loader/jobs reply that may cross the heap when it does not fit the slot
183
+ * (256 KiB..=64 MiB; boot error otherwise). Absent = 8 MiB.
184
+ */
185
+ maxLoaderResponseBytes?: number
155
186
  /**
156
187
  * tokio threads of the HTTP runtime (every page renders there); absent =
157
188
  * one per core (`Tuning::default`).
@@ -165,8 +196,12 @@ export interface StartOptions {
165
196
  cors?: NapiCorsOptions
166
197
  /** The actions subtree (M3-F); absent = no actions (byte-identical server). */
167
198
  actions?: NapiActionsOptions
199
+ /** L16: base URL / credentials / prefix injected for the browser `client()`; absent = from `actions` alone. */
200
+ actionsClient?: NapiActionsClient
168
201
  /** The cache adapter; absent = none (byte-identical server). */
169
202
  l2?: NapiL2Options
203
+ /** `brust dev` only (L14): a request carrying this token in `x-brust-dev-token` is traced. Absent in production. */
204
+ devToken?: string
170
205
  }
171
206
 
172
207
  /**
package/native/index.js CHANGED
@@ -89,8 +89,8 @@ function requireNative() {
89
89
  try {
90
90
  const binding = require('@brust/native-android-arm64')
91
91
  const bindingPackageVersion = require('@brust/native-android-arm64/package.json').version
92
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
92
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
93
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
94
94
  }
95
95
  return binding
96
96
  } catch (e) {
@@ -105,8 +105,8 @@ function requireNative() {
105
105
  try {
106
106
  const binding = require('@brust/native-android-arm-eabi')
107
107
  const bindingPackageVersion = require('@brust/native-android-arm-eabi/package.json').version
108
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
108
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
109
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
110
110
  }
111
111
  return binding
112
112
  } catch (e) {
@@ -126,8 +126,8 @@ function requireNative() {
126
126
  try {
127
127
  const binding = require('@brust/native-win32-x64-gnu')
128
128
  const bindingPackageVersion = require('@brust/native-win32-x64-gnu/package.json').version
129
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
129
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
130
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
131
131
  }
132
132
  return binding
133
133
  } catch (e) {
@@ -142,8 +142,8 @@ function requireNative() {
142
142
  try {
143
143
  const binding = require('@brust/native-win32-x64-msvc')
144
144
  const bindingPackageVersion = require('@brust/native-win32-x64-msvc/package.json').version
145
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
145
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
146
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
147
147
  }
148
148
  return binding
149
149
  } catch (e) {
@@ -159,8 +159,8 @@ function requireNative() {
159
159
  try {
160
160
  const binding = require('@brust/native-win32-ia32-msvc')
161
161
  const bindingPackageVersion = require('@brust/native-win32-ia32-msvc/package.json').version
162
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
162
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
163
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
164
164
  }
165
165
  return binding
166
166
  } catch (e) {
@@ -175,8 +175,8 @@ function requireNative() {
175
175
  try {
176
176
  const binding = require('@brust/native-win32-arm64-msvc')
177
177
  const bindingPackageVersion = require('@brust/native-win32-arm64-msvc/package.json').version
178
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
178
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
179
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
180
180
  }
181
181
  return binding
182
182
  } catch (e) {
@@ -194,8 +194,8 @@ function requireNative() {
194
194
  try {
195
195
  const binding = require('@brust/native-darwin-universal')
196
196
  const bindingPackageVersion = require('@brust/native-darwin-universal/package.json').version
197
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
197
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
198
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
199
199
  }
200
200
  return binding
201
201
  } catch (e) {
@@ -210,8 +210,8 @@ function requireNative() {
210
210
  try {
211
211
  const binding = require('@brust/native-darwin-x64')
212
212
  const bindingPackageVersion = require('@brust/native-darwin-x64/package.json').version
213
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
213
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
214
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
215
215
  }
216
216
  return binding
217
217
  } catch (e) {
@@ -226,8 +226,8 @@ function requireNative() {
226
226
  try {
227
227
  const binding = require('@brust/native-darwin-arm64')
228
228
  const bindingPackageVersion = require('@brust/native-darwin-arm64/package.json').version
229
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
229
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
230
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
231
231
  }
232
232
  return binding
233
233
  } catch (e) {
@@ -246,8 +246,8 @@ function requireNative() {
246
246
  try {
247
247
  const binding = require('@brust/native-freebsd-x64')
248
248
  const bindingPackageVersion = require('@brust/native-freebsd-x64/package.json').version
249
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
249
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
250
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
251
251
  }
252
252
  return binding
253
253
  } catch (e) {
@@ -262,8 +262,8 @@ function requireNative() {
262
262
  try {
263
263
  const binding = require('@brust/native-freebsd-arm64')
264
264
  const bindingPackageVersion = require('@brust/native-freebsd-arm64/package.json').version
265
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
265
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
266
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
267
267
  }
268
268
  return binding
269
269
  } catch (e) {
@@ -283,8 +283,8 @@ function requireNative() {
283
283
  try {
284
284
  const binding = require('@brust/native-linux-x64-musl')
285
285
  const bindingPackageVersion = require('@brust/native-linux-x64-musl/package.json').version
286
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
286
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
287
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
288
288
  }
289
289
  return binding
290
290
  } catch (e) {
@@ -299,8 +299,8 @@ function requireNative() {
299
299
  try {
300
300
  const binding = require('@brust/native-linux-x64-gnu')
301
301
  const bindingPackageVersion = require('@brust/native-linux-x64-gnu/package.json').version
302
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
302
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
303
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
304
304
  }
305
305
  return binding
306
306
  } catch (e) {
@@ -317,8 +317,8 @@ function requireNative() {
317
317
  try {
318
318
  const binding = require('@brust/native-linux-arm64-musl')
319
319
  const bindingPackageVersion = require('@brust/native-linux-arm64-musl/package.json').version
320
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
320
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
321
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
322
322
  }
323
323
  return binding
324
324
  } catch (e) {
@@ -333,8 +333,8 @@ function requireNative() {
333
333
  try {
334
334
  const binding = require('@brust/native-linux-arm64-gnu')
335
335
  const bindingPackageVersion = require('@brust/native-linux-arm64-gnu/package.json').version
336
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
336
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
337
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
338
338
  }
339
339
  return binding
340
340
  } catch (e) {
@@ -351,8 +351,8 @@ function requireNative() {
351
351
  try {
352
352
  const binding = require('@brust/native-linux-arm-musleabihf')
353
353
  const bindingPackageVersion = require('@brust/native-linux-arm-musleabihf/package.json').version
354
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
354
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
355
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
356
356
  }
357
357
  return binding
358
358
  } catch (e) {
@@ -367,8 +367,8 @@ function requireNative() {
367
367
  try {
368
368
  const binding = require('@brust/native-linux-arm-gnueabihf')
369
369
  const bindingPackageVersion = require('@brust/native-linux-arm-gnueabihf/package.json').version
370
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
370
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
371
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
372
372
  }
373
373
  return binding
374
374
  } catch (e) {
@@ -385,8 +385,8 @@ function requireNative() {
385
385
  try {
386
386
  const binding = require('@brust/native-linux-loong64-musl')
387
387
  const bindingPackageVersion = require('@brust/native-linux-loong64-musl/package.json').version
388
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
388
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
389
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
390
390
  }
391
391
  return binding
392
392
  } catch (e) {
@@ -401,8 +401,8 @@ function requireNative() {
401
401
  try {
402
402
  const binding = require('@brust/native-linux-loong64-gnu')
403
403
  const bindingPackageVersion = require('@brust/native-linux-loong64-gnu/package.json').version
404
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
404
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
405
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
406
406
  }
407
407
  return binding
408
408
  } catch (e) {
@@ -419,8 +419,8 @@ function requireNative() {
419
419
  try {
420
420
  const binding = require('@brust/native-linux-riscv64-musl')
421
421
  const bindingPackageVersion = require('@brust/native-linux-riscv64-musl/package.json').version
422
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
422
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
423
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
424
424
  }
425
425
  return binding
426
426
  } catch (e) {
@@ -435,8 +435,8 @@ function requireNative() {
435
435
  try {
436
436
  const binding = require('@brust/native-linux-riscv64-gnu')
437
437
  const bindingPackageVersion = require('@brust/native-linux-riscv64-gnu/package.json').version
438
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
438
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
439
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
440
440
  }
441
441
  return binding
442
442
  } catch (e) {
@@ -452,8 +452,8 @@ function requireNative() {
452
452
  try {
453
453
  const binding = require('@brust/native-linux-ppc64-gnu')
454
454
  const bindingPackageVersion = require('@brust/native-linux-ppc64-gnu/package.json').version
455
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
455
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
456
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
457
457
  }
458
458
  return binding
459
459
  } catch (e) {
@@ -468,8 +468,8 @@ function requireNative() {
468
468
  try {
469
469
  const binding = require('@brust/native-linux-s390x-gnu')
470
470
  const bindingPackageVersion = require('@brust/native-linux-s390x-gnu/package.json').version
471
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
471
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
472
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
473
473
  }
474
474
  return binding
475
475
  } catch (e) {
@@ -488,8 +488,8 @@ function requireNative() {
488
488
  try {
489
489
  const binding = require('@brust/native-openharmony-arm64')
490
490
  const bindingPackageVersion = require('@brust/native-openharmony-arm64/package.json').version
491
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
491
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
492
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
493
493
  }
494
494
  return binding
495
495
  } catch (e) {
@@ -504,8 +504,8 @@ function requireNative() {
504
504
  try {
505
505
  const binding = require('@brust/native-openharmony-x64')
506
506
  const bindingPackageVersion = require('@brust/native-openharmony-x64/package.json').version
507
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
507
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
508
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
509
509
  }
510
510
  return binding
511
511
  } catch (e) {
@@ -520,8 +520,8 @@ function requireNative() {
520
520
  try {
521
521
  const binding = require('@brust/native-openharmony-arm')
522
522
  const bindingPackageVersion = require('@brust/native-openharmony-arm/package.json').version
523
- if (bindingPackageVersion !== '2.0.0-alpha.3' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
- throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
523
+ if (bindingPackageVersion !== '2.0.0-alpha.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
524
+ throw new Error(`Native binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
525
525
  }
526
526
  return binding
527
527
  } catch (e) {
@@ -661,8 +661,8 @@ if (!nativeBinding || forceWasi) {
661
661
  if (!candidateFailed) {
662
662
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
663
663
  const bindingPackageVersion = require('@brust/native-wasm32-wasi/package.json').version
664
- if (bindingPackageVersion !== '2.0.0-alpha.3') {
665
- throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.3 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
664
+ if (bindingPackageVersion !== '2.0.0-alpha.4') {
665
+ throw new Error(`WASI binding package version mismatch, expected 2.0.0-alpha.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
666
666
  }
667
667
  }
668
668
  wasiBinding = require('@brust/native-wasm32-wasi')
@@ -780,6 +780,7 @@ module.exports.__napiBindingTarget = __napiStampBindingTarget(nativeBinding, __n
780
780
  module.exports = nativeBinding
781
781
  module.exports.beginDrain = nativeBinding.beginDrain
782
782
  module.exports.cacheClear = nativeBinding.cacheClear
783
+ module.exports.cacheExprReads = nativeBinding.cacheExprReads
783
784
  module.exports.cacheInvalidate = nativeBinding.cacheInvalidate
784
785
  module.exports.cacheL2Count = nativeBinding.cacheL2Count
785
786
  module.exports.cacheReplay = nativeBinding.cacheReplay
@@ -787,6 +788,7 @@ module.exports.cacheStats = nativeBinding.cacheStats
787
788
  module.exports.compileTree = nativeBinding.compileTree
788
789
  module.exports.localAddr = nativeBinding.localAddr
789
790
  module.exports.planJobs = nativeBinding.planJobs
791
+ module.exports.planJobsBuf = nativeBinding.planJobsBuf
790
792
  module.exports.putFetchReply = nativeBinding.putFetchReply
791
793
  module.exports.registerWorker = nativeBinding.registerWorker
792
794
  module.exports.startServer = nativeBinding.startServer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brust/core",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.4",
4
4
  "description": "brust v2 — React components compiled to Rust-rendered templates",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,6 +17,7 @@
17
17
  "browser": "./src/browser.ts",
18
18
  "default": "./src/index.ts"
19
19
  },
20
+ "./build-time": "./src/build-time.ts",
20
21
  "./routes": "./src/routes.ts",
21
22
  "./server": "./src/server.ts",
22
23
  "./server-handlers": "./src/server-handlers.ts",
@@ -49,7 +50,7 @@
49
50
  ]
50
51
  },
51
52
  "dependencies": {
52
- "@brust/runtime-dom": "2.0.0-alpha.3"
53
+ "@brust/runtime-dom": "2.0.0-alpha.4"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "react": "^19.0.0",
@@ -71,6 +72,7 @@
71
72
  "@types/bun": "^1.4.0",
72
73
  "@types/react": "^19.2.0",
73
74
  "elysia": "2.0.0-beta.30",
75
+ "lucide-react": "1.55.0",
74
76
  "react": "^19.2.0",
75
77
  "react-dom": "^19.2.0",
76
78
  "typescript": "^7.0.2"
@@ -86,12 +88,12 @@
86
88
  "access": "public"
87
89
  },
88
90
  "optionalDependencies": {
89
- "@brust/native-darwin-x64": "2.0.0-alpha.3",
90
- "@brust/native-darwin-arm64": "2.0.0-alpha.3",
91
- "@brust/native-linux-x64-gnu": "2.0.0-alpha.3",
92
- "@brust/native-linux-arm64-gnu": "2.0.0-alpha.3",
93
- "@brust/native-linux-x64-musl": "2.0.0-alpha.3",
94
- "@brust/native-linux-arm64-musl": "2.0.0-alpha.3",
95
- "@brust/core-cf": "2.0.0-alpha.3"
91
+ "@brust/native-darwin-x64": "2.0.0-alpha.4",
92
+ "@brust/native-darwin-arm64": "2.0.0-alpha.4",
93
+ "@brust/native-linux-x64-gnu": "2.0.0-alpha.4",
94
+ "@brust/native-linux-arm64-gnu": "2.0.0-alpha.4",
95
+ "@brust/native-linux-x64-musl": "2.0.0-alpha.4",
96
+ "@brust/native-linux-arm64-musl": "2.0.0-alpha.4",
97
+ "@brust/core-cf": "2.0.0-alpha.4"
96
98
  }
97
99
  }
@@ -2,7 +2,7 @@
2
2
  // elysia is type-only here. Differences from 0.1.x runtime/treaty.ts: docs/actions.md "The client".
3
3
  import { type Treaty, treaty } from '@elysia/eden/treaty2'
4
4
  import type { AnyElysia } from 'elysia'
5
- import { DEFAULT_ACTION_PREFIX } from './prefix'
5
+ import { type ActionCredentials, DEFAULT_ACTION_PREFIX } from './prefix'
6
6
 
7
7
  export { DEFAULT_ACTION_PREFIX }
8
8
  export type { Treaty }
@@ -19,7 +19,17 @@ export interface ClientOptions<Head extends Record<string, unknown> = {}>
19
19
  init?: Treaty.Config<Head>['fetch']
20
20
  }
21
21
 
22
- /** 0.1.x runtime/treaty.ts:86-93, verbatim order. */
22
+ interface PageGlobals {
23
+ __BRUST_ACTION_PREFIX__?: string
24
+ /** L16 R16.1: injected from `[actions] base_url` / BRUST_ACTIONS_BASE_URL / run({ config: { actionsBaseUrl } }). */
25
+ __BRUST_ACTION_BASE__?: string
26
+ /** L16 R16.2: injected from `[actions] credentials`. */
27
+ __BRUST_ACTION_CREDENTIALS__?: ActionCredentials
28
+ }
29
+ const page = () => globalThis as PageGlobals
30
+
31
+ /** 0.1.x runtime/treaty.ts:86-93, verbatim order. A per-call `baseUrl` keeps the default prefix; a base that comes
32
+ * from the page global (L16) pairs with the page's injected prefix, both being the same deployment's config. */
23
33
  export function resolvePrefix(opts?: { prefix?: string; baseUrl?: string }): string {
24
34
  if (opts?.prefix) return opts.prefix
25
35
  if (opts?.baseUrl !== undefined) return DEFAULT_ACTION_PREFIX
@@ -31,7 +41,8 @@ export function resolvePrefix(opts?: { prefix?: string; baseUrl?: string }): str
31
41
 
32
42
  /** 0.1.x runtime/treaty.ts:95-106; message names `client`. */
33
43
  export function resolveBaseUrl(opts?: { baseUrl?: string }): string {
34
- const b = opts?.baseUrl
44
+ // R16.1 order: opts.baseUrl, the page's __BRUST_ACTION_BASE__, relative.
45
+ const b = opts?.baseUrl ?? page().__BRUST_ACTION_BASE__
35
46
  if (b === undefined) return ''
36
47
  if (!/^https?:\/\//.test(b))
37
48
  throw new Error(
@@ -44,11 +55,17 @@ export function client<const App extends AnyElysia, Head extends Record<string,
44
55
  opts: ClientOptions<Head> = {},
45
56
  ): Treaty.Instance<App, Head> {
46
57
  const { prefix: _p, baseUrl: _b, fetch: fetcher, init, ...rest } = opts
58
+ // R16.2: the page's credentials default (`opts.init` wins); only when it differs from the browser default.
59
+ const creds = page().__BRUST_ACTION_CREDENTIALS__
60
+ const defaults = creds !== undefined && creds !== 'same-origin' && typeof init !== 'function' ? { credentials: creds } : undefined
47
61
  // keepDomain: Eden would rewrite a relative base to `https:///…` (probe kd.ts).
48
- return treaty<App, Head>(resolveBaseUrl(opts) + resolvePrefix(opts), {
62
+ // The root prefix (an actions-only deployment) adds nothing to the base: `https://api.example.com/team`, not `//team`.
63
+ const base = resolveBaseUrl(opts)
64
+ const prefix = resolvePrefix(opts)
65
+ return treaty<App, Head>(base !== '' && prefix === '/' ? base : base + prefix, {
49
66
  ...rest,
50
67
  keepDomain: true,
51
68
  ...(fetcher ? { fetcher } : {}),
52
- ...(init ? { fetch: init } : {}),
69
+ ...(init || defaults ? { fetch: typeof init === 'function' ? init : { ...defaults, ...init } } : {}),
53
70
  })
54
71
  }