brustjs 0.1.33-alpha → 0.1.35-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.
- package/README.md +5 -0
- package/example/pokedex/components/AddToTeamButton.tsx +1 -1
- package/example/pokedex/components/Breadcrumb.tsx +1 -1
- package/example/pokedex/components/DexFilter.tsx +1 -1
- package/example/pokedex/components/HeroSearch.tsx +0 -1
- package/example/pokedex/components/NavLink.tsx +0 -1
- package/example/pokedex/components/ThemeToggle.tsx +0 -1
- package/package.json +7 -7
- package/runtime/cli/native-routes-emit.ts +53 -4
- package/runtime/index.d.ts +1 -1
- package/runtime/index.js +52 -52
- package/runtime/native/build.ts +15 -9
package/README.md
CHANGED
|
@@ -93,6 +93,11 @@ brustjs new <name> # scaffold a project (partial — see Status)
|
|
|
93
93
|
`export const behavior` (single-file component); each component's JS is a
|
|
94
94
|
separate chunk loaded **on demand** — a page never downloads a component it
|
|
95
95
|
doesn't render.
|
|
96
|
+
- **Static lucide icons** — `lucide-react` icons on a `native` route compile to
|
|
97
|
+
inline `<svg>` at build time: **zero React**, no `renderToString`, no factory or
|
|
98
|
+
`{{ slot }}`. Static props bake into the markup; dynamic props (loader / `.map()`
|
|
99
|
+
item) become escaped jinja substitutions; `className` merges with the icon class.
|
|
100
|
+
Unsupported shapes (spread props, etc.) soft-fall to the React SSR path.
|
|
96
101
|
- **Isomorphic store** — `brustjs/store`: `signal`/`computed`/`effect` +
|
|
97
102
|
`defineStore(name, factory)`. One `window` singleton per name on the client (so
|
|
98
103
|
separate island/directive chunks share state), a per-request `AsyncLocalStorage`
|
|
@@ -78,7 +78,7 @@ export const behavior = ({ props }: { props: AddTeamProps }) => {
|
|
|
78
78
|
// emitted by the compiler as x-props="{{ (data) | json_attr }}" (XSS-safe).
|
|
79
79
|
export default function AddToTeamButton({ data }: { data: AddTeamProps }) {
|
|
80
80
|
return (
|
|
81
|
-
<div x-
|
|
81
|
+
<div x-props={data} className="relative">
|
|
82
82
|
<Plus
|
|
83
83
|
size={16}
|
|
84
84
|
className="pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-white"
|
|
@@ -42,7 +42,7 @@ export const behavior = () => {
|
|
|
42
42
|
// bind and on every SPA navigation.
|
|
43
43
|
export default function Breadcrumb({ crumb }: { crumb: string }) {
|
|
44
44
|
return (
|
|
45
|
-
<b x-
|
|
45
|
+
<b x-text="label" className="text-slate-600 dark:text-slate-300">
|
|
46
46
|
{crumb}
|
|
47
47
|
</b>
|
|
48
48
|
)
|
|
@@ -52,7 +52,7 @@ export const behavior = ({ props }: { el: HTMLElement; props: unknown }) => {
|
|
|
52
52
|
// behavior's props — one prop, no separate pre-stringified `dexProps`.
|
|
53
53
|
export default function DexFilter({ items }: { items: Card[] }) {
|
|
54
54
|
return (
|
|
55
|
-
<section x-
|
|
55
|
+
<section x-props={items}>
|
|
56
56
|
<div className="mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
|
57
57
|
<div className="relative w-full sm:max-w-xs">
|
|
58
58
|
<Search
|
|
@@ -29,7 +29,6 @@ export const behavior = () => {
|
|
|
29
29
|
export default function HeroSearch() {
|
|
30
30
|
return (
|
|
31
31
|
<form
|
|
32
|
-
x-data="heroSearch"
|
|
33
32
|
x-on-submit="go"
|
|
34
33
|
className="mx-auto mt-8 flex w-full max-w-md items-center gap-2 rounded-2xl bg-white/95 p-2 shadow-lg ring-1 ring-black/5 dark:bg-slate-900/90 dark:ring-white/10"
|
|
35
34
|
>
|
|
@@ -31,7 +31,6 @@ export const behavior = ({ el }: { el: HTMLElement }) => {
|
|
|
31
31
|
export default function NavLink({ href, label }: { href: string; label: string }) {
|
|
32
32
|
return (
|
|
33
33
|
<a
|
|
34
|
-
x-data="navLink"
|
|
35
34
|
x-bind-class="cls"
|
|
36
35
|
x-bind-aria-current="current"
|
|
37
36
|
className="inline-flex items-center rounded-lg px-3 py-1.5 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-white"
|
|
@@ -45,7 +45,6 @@ export default function ThemeToggle() {
|
|
|
45
45
|
return (
|
|
46
46
|
<button
|
|
47
47
|
type="button"
|
|
48
|
-
x-data="themeToggle"
|
|
49
48
|
x-on-click="toggle"
|
|
50
49
|
aria-label="Toggle theme"
|
|
51
50
|
className="inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-100 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brustjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35-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.
|
|
44
|
-
"brustjs-darwin-arm64": "0.1.
|
|
45
|
-
"brustjs-linux-x64-gnu": "0.1.
|
|
46
|
-
"brustjs-linux-arm64-gnu": "0.1.
|
|
47
|
-
"brustjs-linux-x64-musl": "0.1.
|
|
48
|
-
"brustjs-linux-arm64-musl": "0.1.
|
|
43
|
+
"brustjs-darwin-x64": "0.1.35-alpha",
|
|
44
|
+
"brustjs-darwin-arm64": "0.1.35-alpha",
|
|
45
|
+
"brustjs-linux-x64-gnu": "0.1.35-alpha",
|
|
46
|
+
"brustjs-linux-arm64-gnu": "0.1.35-alpha",
|
|
47
|
+
"brustjs-linux-x64-musl": "0.1.35-alpha",
|
|
48
|
+
"brustjs-linux-arm64-musl": "0.1.35-alpha"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "^19.2.6",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
2
3
|
import { dirname, relative, resolve } from 'node:path'
|
|
3
4
|
import { buildDevClientTag } from '../dev/client.ts'
|
|
4
5
|
import { DIRECTIVES_BOOTSTRAP, ISLANDS_IMPORTMAP_AND_BOOTSTRAP } from '../islands/importmap.ts'
|
|
@@ -482,6 +483,7 @@ export async function emitNativeTemplates(opts: NativeRouteEmitOpts): Promise<vo
|
|
|
482
483
|
path: string,
|
|
483
484
|
componentSources?: Record<string, string>,
|
|
484
485
|
lucideIcons?: Record<string, string>,
|
|
486
|
+
directiveNames?: Record<string, string>,
|
|
485
487
|
) => { template: string; islandsJson: string; warnings?: string[] })
|
|
486
488
|
| null = null
|
|
487
489
|
if (nativeRoutes.length > 0) {
|
|
@@ -572,9 +574,24 @@ export async function emitNativeTemplates(opts: NativeRouteEmitOpts): Promise<vo
|
|
|
572
574
|
const lucideIcons: Record<string, string> = {}
|
|
573
575
|
for (const p of lucidePaths) Object.assign(lucideIcons, await extractLucideIcons(p))
|
|
574
576
|
|
|
577
|
+
// Build directive name map: for each ident in `sources` whose source text
|
|
578
|
+
// contains `export const behavior`, resolve its absolute path from
|
|
579
|
+
// `mergedImports` and derive the canonical directive name. Uses a dynamic
|
|
580
|
+
// import to avoid a circular dependency (native/build.ts → scanImports here).
|
|
581
|
+
const { directiveName } = await import('../native/build.ts')
|
|
582
|
+
const BEHAVIOR_RE = /export\s+const\s+behavior\b/
|
|
583
|
+
const directiveNames: Record<string, string> = {}
|
|
584
|
+
for (const [ident, src] of Object.entries(sources)) {
|
|
585
|
+
if (!BEHAVIOR_RE.test(src)) continue
|
|
586
|
+
const ref = mergedImports.get(ident)
|
|
587
|
+
if (ref && !ref.bare && typeof ref.spec === 'string') {
|
|
588
|
+
directiveNames[ident] = directiveName(ref.spec, process.cwd())
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
575
592
|
let compiled: { template: string; islandsJson: string; warnings?: string[] }
|
|
576
593
|
try {
|
|
577
|
-
compiled = compileJsx!(routeSource, routeSourcePath, sources, lucideIcons)
|
|
594
|
+
compiled = compileJsx!(routeSource, routeSourcePath, sources, lucideIcons, directiveNames)
|
|
578
595
|
} catch (e) {
|
|
579
596
|
throw new Error(
|
|
580
597
|
`native route "${name}" failed to compile (${routeSourcePath}):\n${String(e)}`,
|
|
@@ -753,6 +770,28 @@ function toKebabCase(s: string): string {
|
|
|
753
770
|
return s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()
|
|
754
771
|
}
|
|
755
772
|
|
|
773
|
+
const requireFromHere = createRequire(import.meta.url)
|
|
774
|
+
|
|
775
|
+
/** Follow a lucide-react alias module to its canonical icon. ~249 icons (e.g.
|
|
776
|
+
* `arrow-down-az`) ship as a re-export STUB — `export { default } from
|
|
777
|
+
* './arrow-down-a-z.mjs'` — that carries NO `__iconNode` (the data lives in the
|
|
778
|
+
* canonical file, which lucide kebabs differently for consecutive capitals:
|
|
779
|
+
* `ArrowDownAZ` → `arrow-down-az` here vs `arrow-down-a-z` on disk). Read the
|
|
780
|
+
* stub's source and return the canonical kebab, or `null` if `<kebab>.mjs` is not
|
|
781
|
+
* an alias stub (i.e. already canonical / unresolvable). */
|
|
782
|
+
function followLucideAlias(kebab: string): string | null {
|
|
783
|
+
try {
|
|
784
|
+
const src = readFileSync(
|
|
785
|
+
requireFromHere.resolve(`lucide-react/dist/esm/icons/${kebab}.mjs`),
|
|
786
|
+
'utf8',
|
|
787
|
+
)
|
|
788
|
+
const m = src.match(/export\s*\{\s*default\s*\}\s*from\s*['"]\.\/(.+?)\.mjs['"]/)
|
|
789
|
+
return m ? m[1]! : null
|
|
790
|
+
} catch {
|
|
791
|
+
return null
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
756
795
|
/** Extract static SVG node data for every `lucide-react` icon imported by
|
|
757
796
|
* `file`, keyed by its in-source local name.
|
|
758
797
|
*
|
|
@@ -769,10 +808,20 @@ export async function extractLucideIcons(file: string): Promise<Record<string, s
|
|
|
769
808
|
for (const [local, entry] of refs) {
|
|
770
809
|
if (!entry.bare || entry.spec !== 'lucide-react') continue
|
|
771
810
|
const pascal = entry.imported ?? local // default import → local name
|
|
772
|
-
|
|
811
|
+
let kebab = toKebabCase(pascal)
|
|
773
812
|
try {
|
|
774
|
-
|
|
775
|
-
|
|
813
|
+
let mod = await import(`lucide-react/dist/esm/icons/${kebab}.mjs`)
|
|
814
|
+
let iconNode = mod.__iconNode
|
|
815
|
+
if (!Array.isArray(iconNode)) {
|
|
816
|
+
// Re-export alias stub (no __iconNode) → follow to the canonical icon
|
|
817
|
+
// file, and use ITS kebab for both the import and the `cls`.
|
|
818
|
+
const canonical = followLucideAlias(kebab)
|
|
819
|
+
if (canonical) {
|
|
820
|
+
mod = await import(`lucide-react/dist/esm/icons/${canonical}.mjs`)
|
|
821
|
+
iconNode = mod.__iconNode
|
|
822
|
+
kebab = canonical
|
|
823
|
+
}
|
|
824
|
+
}
|
|
776
825
|
if (!Array.isArray(iconNode)) continue
|
|
777
826
|
const node = iconNode.map(([tag, attrs]: [string, Record<string, unknown>]) => {
|
|
778
827
|
const pairs: [string, string][] = []
|
package/runtime/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface CachedIslandJs {
|
|
|
7
7
|
props: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export declare function compileJsx(source: string, path: string, componentSources?: Record<string, string> | undefined | null, lucideIcons?: Record<string, string> | undefined | null): NapiCompiledJsx
|
|
10
|
+
export declare function compileJsx(source: string, path: string, componentSources?: Record<string, string> | undefined | null, lucideIcons?: Record<string, string> | undefined | null, directiveNames?: Record<string, string> | undefined | null): NapiCompiledJsx
|
|
11
11
|
|
|
12
12
|
export declare function configureCache(maxEntries: number): NapiResult<undefined>
|
|
13
13
|
|
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.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
80
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
96
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
117
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
133
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
150
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
166
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
185
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
201
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
217
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
237
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
253
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
274
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
290
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
308
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
324
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
342
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
358
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
376
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
392
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
410
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
426
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
443
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
459
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
479
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
495
|
+
if (bindingPackageVersion !== '0.1.35-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.35-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.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
511
|
+
if (bindingPackageVersion !== '0.1.35-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.35-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
package/runtime/native/build.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
1
2
|
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
-
import { basename, extname, isAbsolute, resolve } from 'node:path'
|
|
3
|
+
import { basename, extname, isAbsolute, relative, resolve } from 'node:path'
|
|
3
4
|
import { scanImports } from '../cli/native-routes-emit.ts'
|
|
4
5
|
|
|
5
6
|
const BEHAVIOR_RE = /export\s+const\s+behavior\b/
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/** Deterministic, app-unique directive name = camelCase(basename) + "_" + 8 hex of
|
|
9
|
+
* sha256(cwd-relative path). The SINGLE name contract: chunk filename, runtime
|
|
10
|
+
* registry key, and the compiler-emitted `x-data` all derive from this. */
|
|
11
|
+
export function directiveName(absPath: string, projectRoot: string): string {
|
|
12
|
+
const base = basename(absPath, extname(absPath))
|
|
13
|
+
const camel = base.length > 0 ? base[0]!.toLowerCase() + base.slice(1) : base
|
|
14
|
+
const rel = relative(projectRoot, absPath).replaceAll('\\', '/')
|
|
15
|
+
const hash = createHash('sha256').update(rel).digest('hex').slice(0, 8)
|
|
16
|
+
return `${camel}_${hash}`
|
|
11
17
|
}
|
|
12
18
|
|
|
13
|
-
/** BFS the local import graph from the routes entry; return
|
|
19
|
+
/** BFS the local import graph from the routes entry; return directiveName →
|
|
14
20
|
* absolute sourcePath for every file that has `export const behavior`. Throws on
|
|
15
|
-
* two distinct files deriving the same
|
|
21
|
+
* two distinct files deriving the same directive name (path-hashed, collision-resistant). */
|
|
16
22
|
export function scanDirectiveComponents(routesEntryFile: string): Map<string, string> {
|
|
17
23
|
const found = new Map<string, string>()
|
|
18
24
|
const visited = new Set<string>()
|
|
@@ -31,11 +37,11 @@ export function scanDirectiveComponents(routesEntryFile: string): Map<string, st
|
|
|
31
37
|
if (!visited.has(dep)) queue.push(dep)
|
|
32
38
|
}
|
|
33
39
|
if (BEHAVIOR_RE.test(src)) {
|
|
34
|
-
const name =
|
|
40
|
+
const name = directiveName(filePath, process.cwd())
|
|
35
41
|
const existing = found.get(name)
|
|
36
42
|
if (existing && existing !== filePath) {
|
|
37
43
|
throw new Error(
|
|
38
|
-
`directive component name "${name}" derives from two files (${existing} and ${filePath});
|
|
44
|
+
`directive component name "${name}" (path-hashed) derives from two files (${existing} and ${filePath}); this should be impossible — please report a bug`,
|
|
39
45
|
)
|
|
40
46
|
}
|
|
41
47
|
found.set(name, filePath)
|