brustjs 0.1.61-alpha → 0.1.62-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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brustjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.62-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": {
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"typescript": "^6.0.3"
|
|
42
42
|
},
|
|
43
43
|
"optionalDependencies": {
|
|
44
|
-
"brustjs-darwin-x64": "0.1.
|
|
45
|
-
"brustjs-darwin-arm64": "0.1.
|
|
46
|
-
"brustjs-linux-x64-gnu": "0.1.
|
|
47
|
-
"brustjs-linux-arm64-gnu": "0.1.
|
|
48
|
-
"brustjs-linux-x64-musl": "0.1.
|
|
49
|
-
"brustjs-linux-arm64-musl": "0.1.
|
|
44
|
+
"brustjs-darwin-x64": "0.1.62-alpha",
|
|
45
|
+
"brustjs-darwin-arm64": "0.1.62-alpha",
|
|
46
|
+
"brustjs-linux-x64-gnu": "0.1.62-alpha",
|
|
47
|
+
"brustjs-linux-arm64-gnu": "0.1.62-alpha",
|
|
48
|
+
"brustjs-linux-x64-musl": "0.1.62-alpha",
|
|
49
|
+
"brustjs-linux-arm64-musl": "0.1.62-alpha"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": "^19.2.6",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
3
3
|
import { createRequire } from 'node:module'
|
|
4
4
|
import { dirname, relative, resolve } from 'node:path'
|
|
5
5
|
import { buildDevClientTag } from '../dev/client.ts'
|
|
6
6
|
import { insertGeneratorMeta, insertShellMeta, resolveGenerator } from '../generator.ts'
|
|
7
7
|
import { islandChunkBasename } from '../islands/chunk-id.ts'
|
|
8
|
+
import { emitBehaviorSsrModule } from '../islands/behavior-ssr-loader.ts'
|
|
8
9
|
import { DIRECTIVES_BOOTSTRAP, ISLANDS_IMPORTMAP_AND_BOOTSTRAP } from '../islands/importmap.ts'
|
|
9
10
|
|
|
10
11
|
/** Gather transitive component sources starting from a page source file.
|
|
@@ -391,6 +392,7 @@ interface RawComponentEntry {
|
|
|
391
392
|
factoryExpr: string
|
|
392
393
|
referencedComponents: string[]
|
|
393
394
|
usesIsland: boolean
|
|
395
|
+
behaviorModules: RawBehaviorModule[]
|
|
394
396
|
/** ISR cache fields (present only on components with an `isr` attr). Declared
|
|
395
397
|
* so the `{ ...entry }` / `{ ...e }` enrich spreads below are type-complete —
|
|
396
398
|
* they MUST survive into the enriched `<Name>.components.json`, or runtime ISR
|
|
@@ -400,10 +402,58 @@ interface RawComponentEntry {
|
|
|
400
402
|
revalidate?: number
|
|
401
403
|
}
|
|
402
404
|
|
|
405
|
+
interface RawBehaviorModule {
|
|
406
|
+
component: string
|
|
407
|
+
directiveName: string
|
|
408
|
+
source: string
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
interface EnrichedBehaviorModule extends RawBehaviorModule {
|
|
412
|
+
moduleId: string
|
|
413
|
+
sourcePath: string
|
|
414
|
+
}
|
|
415
|
+
|
|
403
416
|
/** Enriched component entry written to `<Name>.components.json`. */
|
|
404
417
|
interface EnrichedComponentEntry extends RawComponentEntry {
|
|
405
418
|
/** Absolute path to the component's source file (resolved from page imports). */
|
|
406
419
|
sourcePath: string
|
|
420
|
+
behaviorModules: EnrichedBehaviorModule[]
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function behaviorArtifactPrefix(routeName: string): string {
|
|
424
|
+
const routeScope = createHash('sha256').update(routeName).digest('hex').slice(0, 16)
|
|
425
|
+
return `__brust_behavior_${routeScope}_`
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function behaviorModuleId(
|
|
429
|
+
routeName: string,
|
|
430
|
+
sourcePath: string,
|
|
431
|
+
directiveName: string,
|
|
432
|
+
source: string,
|
|
433
|
+
): string {
|
|
434
|
+
return createHash('sha256')
|
|
435
|
+
.update(`${routeName}\0${sourcePath}\0${directiveName}\0${source}`)
|
|
436
|
+
.digest('hex')
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function behaviorArtifactPaths(jinjaPath: string, routeName: string): string[] {
|
|
440
|
+
const jinjaDir = dirname(jinjaPath)
|
|
441
|
+
const prefix = behaviorArtifactPrefix(routeName)
|
|
442
|
+
if (!existsSync(jinjaDir)) return []
|
|
443
|
+
return readdirSync(jinjaDir)
|
|
444
|
+
.filter((name) => name.startsWith(prefix) && name.endsWith('.tsx'))
|
|
445
|
+
.map((name) => resolve(jinjaDir, name))
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** Remove every server-only SSR-component sidecar owned by one route. The
|
|
449
|
+
* route hash in behavior filenames prevents cleanup from touching another
|
|
450
|
+
* route's generated module, even when both render the same component. */
|
|
451
|
+
export function cleanupComponentArtifacts(jinjaPath: string, routeName: string): void {
|
|
452
|
+
rmSync(jinjaPath.replace(/\.jinja$/, '.components.json'), { force: true })
|
|
453
|
+
rmSync(jinjaPath.replace(/\.jinja$/, '.factory.ts'), { force: true })
|
|
454
|
+
for (const generatedPath of behaviorArtifactPaths(jinjaPath, routeName)) {
|
|
455
|
+
rmSync(generatedPath, { force: true })
|
|
456
|
+
}
|
|
407
457
|
}
|
|
408
458
|
|
|
409
459
|
/** One entry in a `<Name>.islands.json` as emitted by `jsx-rustc` (camelCase,
|
|
@@ -454,9 +504,9 @@ export function emitComponentArtifacts(
|
|
|
454
504
|
componentsJsonStr: string,
|
|
455
505
|
pageImports: Map<string, ResolvedImport>,
|
|
456
506
|
routeName: string,
|
|
457
|
-
): { islandIdsFromComponents: string[] } {
|
|
507
|
+
): { islandIdsFromComponents: string[]; generatedPaths: string[] } {
|
|
458
508
|
const raw = JSON.parse(componentsJsonStr) as RawComponentEntry[]
|
|
459
|
-
if (raw.length === 0) return { islandIdsFromComponents: [] }
|
|
509
|
+
if (raw.length === 0) return { islandIdsFromComponents: [], generatedPaths: [] }
|
|
460
510
|
|
|
461
511
|
const jinjaDir = dirname(jinjaPath)
|
|
462
512
|
const projectRoot = process.cwd()
|
|
@@ -464,6 +514,67 @@ export function emitComponentArtifacts(
|
|
|
464
514
|
// Enrich with the resolved import ref. For local imports `ref.spec` is an
|
|
465
515
|
// ABSOLUTE path (kept absolute for the readFileSync island scan below); for
|
|
466
516
|
// bare imports it's the verbatim package specifier.
|
|
517
|
+
const behaviorByComponent = new Map<string, EnrichedBehaviorModule>()
|
|
518
|
+
for (const entry of raw) {
|
|
519
|
+
for (const module of entry.behaviorModules ?? []) {
|
|
520
|
+
const ref = pageImports.get(module.component)
|
|
521
|
+
if (!ref || ref.bare) {
|
|
522
|
+
throw new Error(
|
|
523
|
+
`SSR behavior component "${module.component}" in native route "${routeName}" has no local source import`,
|
|
524
|
+
)
|
|
525
|
+
}
|
|
526
|
+
const sourcePath = relative(projectRoot, ref.spec).replaceAll('\\', '/')
|
|
527
|
+
const moduleId = behaviorModuleId(routeName, sourcePath, module.directiveName, module.source)
|
|
528
|
+
const enrichedModule: EnrichedBehaviorModule = {
|
|
529
|
+
...module,
|
|
530
|
+
moduleId,
|
|
531
|
+
sourcePath,
|
|
532
|
+
}
|
|
533
|
+
const prior = behaviorByComponent.get(module.component)
|
|
534
|
+
if (
|
|
535
|
+
prior &&
|
|
536
|
+
(prior.moduleId !== enrichedModule.moduleId ||
|
|
537
|
+
prior.directiveName !== enrichedModule.directiveName ||
|
|
538
|
+
prior.sourcePath !== enrichedModule.sourcePath)
|
|
539
|
+
) {
|
|
540
|
+
throw new Error(
|
|
541
|
+
`SSR behavior component "${module.component}" has conflicting transformed definitions in native route "${routeName}"`,
|
|
542
|
+
)
|
|
543
|
+
}
|
|
544
|
+
behaviorByComponent.set(module.component, enrichedModule)
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// If an opaque fallback parent imports one of the transformed behavior
|
|
549
|
+
// modules, its original source would otherwise bundle that child's original
|
|
550
|
+
// (unwired) source. Add unchanged passthrough parents until the import graph
|
|
551
|
+
// reaches a fixed point; the loader rewrites their local imports to the
|
|
552
|
+
// generated child artifacts below.
|
|
553
|
+
let addedPassthrough = true
|
|
554
|
+
while (addedPassthrough) {
|
|
555
|
+
addedPassthrough = false
|
|
556
|
+
const generatedSourcePaths = new Set(
|
|
557
|
+
[...behaviorByComponent.values()].map((module) => resolve(projectRoot, module.sourcePath)),
|
|
558
|
+
)
|
|
559
|
+
for (const [component, ref] of pageImports) {
|
|
560
|
+
if (!isComponentIdent(component) || ref.bare || behaviorByComponent.has(component)) continue
|
|
561
|
+
const importsGeneratedModule = [...scanImportRefs(ref.spec).values()].some(
|
|
562
|
+
(dependency) => !dependency.bare && generatedSourcePaths.has(dependency.spec),
|
|
563
|
+
)
|
|
564
|
+
if (!importsGeneratedModule) continue
|
|
565
|
+
const source = readFileSync(ref.spec, 'utf8')
|
|
566
|
+
const sourcePath = relative(projectRoot, ref.spec).replaceAll('\\', '/')
|
|
567
|
+
behaviorByComponent.set(component, {
|
|
568
|
+
component,
|
|
569
|
+
directiveName: '',
|
|
570
|
+
source,
|
|
571
|
+
sourcePath,
|
|
572
|
+
moduleId: behaviorModuleId(routeName, sourcePath, '', source),
|
|
573
|
+
})
|
|
574
|
+
addedPassthrough = true
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
467
578
|
const enriched: Array<EnrichedComponentEntry & { ref: ResolvedImport }> = raw.map((entry) => {
|
|
468
579
|
const ref = pageImports.get(entry.component)
|
|
469
580
|
if (!ref) {
|
|
@@ -471,7 +582,14 @@ export function emitComponentArtifacts(
|
|
|
471
582
|
`SSR component "${entry.component}" in native route "${routeName}" has no matching import in the page source (expected \`import ${entry.component} from "..."\`)`,
|
|
472
583
|
)
|
|
473
584
|
}
|
|
474
|
-
return {
|
|
585
|
+
return {
|
|
586
|
+
...entry,
|
|
587
|
+
sourcePath: ref.spec,
|
|
588
|
+
behaviorModules: (entry.behaviorModules ?? []).map(
|
|
589
|
+
(module) => behaviorByComponent.get(module.component)!,
|
|
590
|
+
),
|
|
591
|
+
ref,
|
|
592
|
+
}
|
|
475
593
|
})
|
|
476
594
|
|
|
477
595
|
// Write <Name>.components.json. For LOCAL imports sourcePath is PROJECT-RELATIVE
|
|
@@ -479,12 +597,70 @@ export function emitComponentArtifacts(
|
|
|
479
597
|
// package spec verbatim. (sourcePath is build-time metadata — the factory
|
|
480
598
|
// import is what's load-bearing at runtime.)
|
|
481
599
|
const compJsonPath = jinjaPath.replace(/\.jinja$/, '.components.json')
|
|
482
|
-
const compJsonEntries = enriched.map(({ ref, ...e }) => ({
|
|
600
|
+
const compJsonEntries = enriched.map(({ ref, behaviorModules: _behaviorModules, ...e }) => ({
|
|
483
601
|
...e,
|
|
484
602
|
sourcePath: ref.bare ? ref.spec : relative(projectRoot, ref.spec).replaceAll('\\', '/'),
|
|
485
603
|
}))
|
|
486
604
|
writeFileSync(compJsonPath, JSON.stringify(compJsonEntries))
|
|
487
605
|
|
|
606
|
+
const generatedSpecByComponent = new Map<string, string>()
|
|
607
|
+
const generatedPathByComponent = new Map<string, string>()
|
|
608
|
+
const generatedPaths: string[] = []
|
|
609
|
+
const artifactPrefix = behaviorArtifactPrefix(routeName)
|
|
610
|
+
for (const module of behaviorByComponent.values()) {
|
|
611
|
+
const filename = `${artifactPrefix}${module.moduleId}.tsx`
|
|
612
|
+
const outputPath = resolve(jinjaDir, filename)
|
|
613
|
+
generatedSpecByComponent.set(module.component, `./${filename}`)
|
|
614
|
+
generatedPathByComponent.set(module.component, outputPath)
|
|
615
|
+
generatedPaths.push(outputPath)
|
|
616
|
+
}
|
|
617
|
+
const componentBySourcePath = new Map(
|
|
618
|
+
[...behaviorByComponent.values()].map((module) => [
|
|
619
|
+
resolve(projectRoot, module.sourcePath),
|
|
620
|
+
module.component,
|
|
621
|
+
]),
|
|
622
|
+
)
|
|
623
|
+
const emittedComponents = new Set<string>()
|
|
624
|
+
const emittingComponents = new Set<string>()
|
|
625
|
+
const emitGeneratedModule = (module: EnrichedBehaviorModule): void => {
|
|
626
|
+
if (emittedComponents.has(module.component)) return
|
|
627
|
+
if (!emittingComponents.add(module.component)) {
|
|
628
|
+
throw new Error(
|
|
629
|
+
`SSR behavior modules form an import cycle at "${module.component}" in native route "${routeName}"`,
|
|
630
|
+
)
|
|
631
|
+
}
|
|
632
|
+
const sourcePath = resolve(projectRoot, module.sourcePath)
|
|
633
|
+
for (const dependency of scanImportRefs(sourcePath).values()) {
|
|
634
|
+
if (dependency.bare) continue
|
|
635
|
+
const dependencyComponent = componentBySourcePath.get(dependency.spec)
|
|
636
|
+
if (!dependencyComponent) continue
|
|
637
|
+
emitGeneratedModule(behaviorByComponent.get(dependencyComponent)!)
|
|
638
|
+
}
|
|
639
|
+
const outputPath = generatedPathByComponent.get(module.component)!
|
|
640
|
+
emitBehaviorSsrModule(
|
|
641
|
+
{
|
|
642
|
+
...module,
|
|
643
|
+
sourcePath,
|
|
644
|
+
dependencies: [...behaviorByComponent.values()]
|
|
645
|
+
.filter((dependency) => dependency.component !== module.component)
|
|
646
|
+
.map((dependency) => ({
|
|
647
|
+
sourcePath: resolve(projectRoot, dependency.sourcePath),
|
|
648
|
+
outputPath: generatedPathByComponent.get(dependency.component)!,
|
|
649
|
+
})),
|
|
650
|
+
},
|
|
651
|
+
outputPath,
|
|
652
|
+
)
|
|
653
|
+
emittingComponents.delete(module.component)
|
|
654
|
+
emittedComponents.add(module.component)
|
|
655
|
+
}
|
|
656
|
+
for (const module of behaviorByComponent.values()) {
|
|
657
|
+
emitGeneratedModule(module)
|
|
658
|
+
}
|
|
659
|
+
const currentGeneratedPaths = new Set(generatedPaths)
|
|
660
|
+
for (const stalePath of behaviorArtifactPaths(jinjaPath, routeName)) {
|
|
661
|
+
if (!currentGeneratedPaths.has(stalePath)) rmSync(stalePath, { force: true })
|
|
662
|
+
}
|
|
663
|
+
|
|
488
664
|
// Collect import lines. Deduplicate referenced components.
|
|
489
665
|
const seen = new Set<string>()
|
|
490
666
|
const importLines: string[] = []
|
|
@@ -506,7 +682,12 @@ export function emitComponentArtifacts(
|
|
|
506
682
|
seen.add(compName)
|
|
507
683
|
const ref = pageImports.get(compName)
|
|
508
684
|
if (!ref) continue
|
|
509
|
-
const
|
|
685
|
+
const generatedSpec = generatedSpecByComponent.get(compName)
|
|
686
|
+
const spec = generatedSpec
|
|
687
|
+
? generatedSpec
|
|
688
|
+
: ref.bare
|
|
689
|
+
? ref.spec
|
|
690
|
+
: toRelativeSpecifier(jinjaDir, ref.spec)
|
|
510
691
|
const specStr = JSON.stringify(spec)
|
|
511
692
|
if (ref.kind === 'namespace') {
|
|
512
693
|
importLines.push(`import * as ${compName} from ${specStr}`)
|
|
@@ -566,7 +747,7 @@ export function emitComponentArtifacts(
|
|
|
566
747
|
}
|
|
567
748
|
}
|
|
568
749
|
|
|
569
|
-
return { islandIdsFromComponents }
|
|
750
|
+
return { islandIdsFromComponents, generatedPaths }
|
|
570
751
|
}
|
|
571
752
|
|
|
572
753
|
export async function emitNativeTemplates(opts: NativeRouteEmitOpts): Promise<NativeEmitStats> {
|
|
@@ -802,11 +983,14 @@ export async function emitNativeTemplates(opts: NativeRouteEmitOpts): Promise<Na
|
|
|
802
983
|
// SSR component artifacts: .components.json + .factory.ts
|
|
803
984
|
const compJsonStr = (compiled as any).componentsJson ?? '[]'
|
|
804
985
|
if (compJsonStr !== '[]') {
|
|
805
|
-
emitComponentArtifacts(outPath, compJsonStr, mergedImports, name)
|
|
986
|
+
const { generatedPaths } = emitComponentArtifacts(outPath, compJsonStr, mergedImports, name)
|
|
806
987
|
outputs.push(
|
|
807
988
|
outPath.replace(/\.jinja$/, '.components.json'),
|
|
808
989
|
outPath.replace(/\.jinja$/, '.factory.ts'),
|
|
990
|
+
...generatedPaths,
|
|
809
991
|
)
|
|
992
|
+
} else {
|
|
993
|
+
cleanupComponentArtifacts(outPath, name)
|
|
810
994
|
}
|
|
811
995
|
|
|
812
996
|
// R14 — memoize only what was hashed AND written by an incremental call;
|
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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-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.62-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto'
|
|
2
|
+
import { rmSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { dirname, relative, resolve } from 'node:path'
|
|
4
|
+
|
|
5
|
+
export interface BehaviorSsrDependency {
|
|
6
|
+
sourcePath: string
|
|
7
|
+
outputPath: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface BehaviorSsrModule {
|
|
11
|
+
component: string
|
|
12
|
+
directiveName: string
|
|
13
|
+
moduleId: string
|
|
14
|
+
source: string
|
|
15
|
+
sourcePath: string
|
|
16
|
+
dependencies?: BehaviorSsrDependency[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function rewriteBehaviorImports(entry: BehaviorSsrModule): string {
|
|
20
|
+
if (!entry.dependencies || entry.dependencies.length === 0) return entry.source
|
|
21
|
+
const dependencyBySource = new Map(
|
|
22
|
+
entry.dependencies.map((dependency) => [resolve(dependency.sourcePath), dependency.outputPath]),
|
|
23
|
+
)
|
|
24
|
+
return entry.source.replace(
|
|
25
|
+
/(\bfrom\s*['"])([^'"]+)(['"])/g,
|
|
26
|
+
(statement, before: string, specifier: string, after: string) => {
|
|
27
|
+
if (!specifier.startsWith('.')) return statement
|
|
28
|
+
const importBase = resolve(dirname(entry.sourcePath), specifier)
|
|
29
|
+
const candidates = [
|
|
30
|
+
importBase,
|
|
31
|
+
`${importBase}.tsx`,
|
|
32
|
+
`${importBase}.ts`,
|
|
33
|
+
resolve(importBase, 'index.tsx'),
|
|
34
|
+
resolve(importBase, 'index.ts'),
|
|
35
|
+
]
|
|
36
|
+
const dependencyOutput = candidates
|
|
37
|
+
.map((candidate) => dependencyBySource.get(candidate))
|
|
38
|
+
.find((candidate) => candidate !== undefined)
|
|
39
|
+
if (!dependencyOutput) return statement
|
|
40
|
+
const rewritten = relative(dirname(entry.sourcePath), dependencyOutput).replaceAll('\\', '/')
|
|
41
|
+
return `${before}${rewritten.startsWith('.') ? rewritten : `./${rewritten}`}${after}`
|
|
42
|
+
},
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function emitBehaviorSsrModule(entry: BehaviorSsrModule, outputPath: string): void {
|
|
47
|
+
const temporaryEntry = `${entry.sourcePath}.brust-behavior-${randomUUID()}.tsx`
|
|
48
|
+
writeFileSync(temporaryEntry, rewriteBehaviorImports(entry))
|
|
49
|
+
try {
|
|
50
|
+
const result = Bun.spawnSync({
|
|
51
|
+
cmd: [
|
|
52
|
+
process.execPath,
|
|
53
|
+
'build',
|
|
54
|
+
temporaryEntry,
|
|
55
|
+
'--target=bun',
|
|
56
|
+
'--format=esm',
|
|
57
|
+
'--packages=external',
|
|
58
|
+
`--outfile=${outputPath}`,
|
|
59
|
+
],
|
|
60
|
+
stdout: 'pipe',
|
|
61
|
+
stderr: 'pipe',
|
|
62
|
+
})
|
|
63
|
+
if (result.exitCode !== 0) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`failed to generate SSR behavior module "${entry.component}" (${entry.moduleId}): ${result.stderr.toString()}`,
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
} finally {
|
|
69
|
+
rmSync(temporaryEntry, { force: true })
|
|
70
|
+
}
|
|
71
|
+
}
|
package/runtime/md/emit.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { insertGeneratorMeta, resolveGenerator } from '../generator.ts'
|
|
|
16
16
|
import {
|
|
17
17
|
bakeDirectivesIfUsed,
|
|
18
18
|
buildChainWrapperSource,
|
|
19
|
+
cleanupComponentArtifacts,
|
|
19
20
|
countMainTags,
|
|
20
21
|
emitComponentArtifacts,
|
|
21
22
|
extractLucideIcons,
|
|
@@ -384,6 +385,8 @@ export async function emitMdTemplates(opts: MdEmitOpts): Promise<{
|
|
|
384
385
|
const compJsonStr = compiled.componentsJson ?? '[]'
|
|
385
386
|
if (compJsonStr !== '[]') {
|
|
386
387
|
emitComponentArtifacts(outPath, compJsonStr, mergedImports, name)
|
|
388
|
+
} else {
|
|
389
|
+
cleanupComponentArtifacts(outPath, name)
|
|
387
390
|
}
|
|
388
391
|
|
|
389
392
|
// 6. Single idempotent bake pass. Every append below is `includes()`-guarded
|
|
@@ -137,6 +137,10 @@ export interface NativeEmitStats {
|
|
|
137
137
|
}
|
|
138
138
|
/** Clear the incremental memo (test isolation). */
|
|
139
139
|
export declare function resetNativeEmitMemo(): void;
|
|
140
|
+
/** Remove every server-only SSR-component sidecar owned by one route. The
|
|
141
|
+
* route hash in behavior filenames prevents cleanup from touching another
|
|
142
|
+
* route's generated module, even when both render the same component. */
|
|
143
|
+
export declare function cleanupComponentArtifacts(jinjaPath: string, routeName: string): void;
|
|
140
144
|
/** Write `<Name>.components.json` and `<Name>.factory.ts` for a native route
|
|
141
145
|
* that has SSR components. Also scans each SSR component's source for Island
|
|
142
146
|
* `component={X}` references and returns those identifiers so the build step
|
|
@@ -152,6 +156,7 @@ export declare function resetNativeEmitMemo(): void;
|
|
|
152
156
|
* can carry layout SSR components and need the same sidecar emission. */
|
|
153
157
|
export declare function emitComponentArtifacts(jinjaPath: string, componentsJsonStr: string, pageImports: Map<string, ResolvedImport>, routeName: string): {
|
|
154
158
|
islandIdsFromComponents: string[];
|
|
159
|
+
generatedPaths: string[];
|
|
155
160
|
};
|
|
156
161
|
export declare function emitNativeTemplates(opts: NativeRouteEmitOpts): Promise<NativeEmitStats>;
|
|
157
162
|
/** A resolved import reference, capturing the import FORM so the SSR factory can
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface BehaviorSsrDependency {
|
|
2
|
+
sourcePath: string;
|
|
3
|
+
outputPath: string;
|
|
4
|
+
}
|
|
5
|
+
export interface BehaviorSsrModule {
|
|
6
|
+
component: string;
|
|
7
|
+
directiveName: string;
|
|
8
|
+
moduleId: string;
|
|
9
|
+
source: string;
|
|
10
|
+
sourcePath: string;
|
|
11
|
+
dependencies?: BehaviorSsrDependency[];
|
|
12
|
+
}
|
|
13
|
+
export declare function emitBehaviorSsrModule(entry: BehaviorSsrModule, outputPath: string): void;
|