rari 0.5.14 → 0.5.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { a as headers, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, t as defineRariConfig } from "./vite-qjOIQBvr.mjs";
1
+ import { a as headers, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, t as defineRariConfig } from "./vite-7bcdKkub.mjs";
2
2
  import { i as writeManifest, n as generateAppRouteManifest, r as loadManifest, t as AppRouteGenerator } from "./app-routes-DZjfJPdB.mjs";
3
3
  import { c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, m as extractServerPropsWithCache, p as extractServerProps, u as clearPropsCache } from "./runtime-client-AtnJSL0q.mjs";
4
- import "./server-build-CBAhNcXM.mjs";
4
+ import "./server-build-MmIJHCpL.mjs";
5
5
 
6
6
  export { AppRouteGenerator, HttpRuntimeClient, RariResponse, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, headers, loadManifest, rari, rariRouter, writeManifest };
@@ -0,0 +1,3 @@
1
+ import { n as createServerBuildPlugin, r as scanDirectory, t as ServerComponentBuilder } from "./server-build-MmIJHCpL.mjs";
2
+
3
+ export { ServerComponentBuilder, scanDirectory };
@@ -4,6 +4,39 @@ import process from "node:process";
4
4
  import { build } from "esbuild";
5
5
 
6
6
  //#region src/vite/server-build.ts
7
+ function isNodeBuiltin(moduleName) {
8
+ return [
9
+ "fs",
10
+ "path",
11
+ "os",
12
+ "crypto",
13
+ "util",
14
+ "stream",
15
+ "events",
16
+ "process",
17
+ "buffer",
18
+ "url",
19
+ "querystring",
20
+ "zlib",
21
+ "http",
22
+ "https",
23
+ "net",
24
+ "tls",
25
+ "child_process",
26
+ "cluster",
27
+ "worker_threads",
28
+ "assert",
29
+ "dns",
30
+ "readline",
31
+ "repl",
32
+ "string_decoder",
33
+ "timers",
34
+ "tty",
35
+ "v8",
36
+ "vm",
37
+ "perf_hooks"
38
+ ].includes(moduleName);
39
+ }
7
40
  var ServerComponentBuilder = class {
8
41
  serverComponents = /* @__PURE__ */ new Map();
9
42
  serverActions = /* @__PURE__ */ new Map();
@@ -193,7 +226,7 @@ const ${importName} = (props) => {
193
226
  loader
194
227
  },
195
228
  bundle: true,
196
- platform: "neutral",
229
+ platform: "node",
197
230
  target: "es2022",
198
231
  format: "esm",
199
232
  external: [],
@@ -256,11 +289,11 @@ const ${importName} = (props) => {
256
289
  path: args.path,
257
290
  external: true
258
291
  };
259
- if (args.path === "rari/client") return null;
260
- if (/^[^./]/.test(args.path)) return {
292
+ if (args.path.startsWith("node:") || isNodeBuiltin(args.path)) return {
261
293
  path: args.path,
262
294
  external: true
263
295
  };
296
+ if (args.path === "rari/client") return null;
264
297
  return null;
265
298
  });
266
299
  build$1.onLoad({
@@ -382,7 +415,7 @@ const ${importName} = (props) => {
382
415
  loader
383
416
  },
384
417
  bundle: true,
385
- platform: "neutral",
418
+ platform: "node",
386
419
  target: "es2022",
387
420
  format: "esm",
388
421
  outfile: outputPath,
@@ -440,11 +473,12 @@ const ${importName} = (props) => {
440
473
  path: args.path,
441
474
  external: true
442
475
  };
443
- if (args.path === "rari/client") return null;
444
- return {
476
+ if (args.path.startsWith("node:") || isNodeBuiltin(args.path)) return {
445
477
  path: args.path,
446
478
  external: true
447
479
  };
480
+ if (args.path === "rari/client") return null;
481
+ return null;
448
482
  });
449
483
  }
450
484
  },
@@ -480,8 +514,31 @@ const ${importName} = (props) => {
480
514
  code = code.replace(/import\s+\{[^}]*\}\s+from\s+['"]react\/jsx-dev-runtime['"];?\s*/g, "// jsx/jsxs are available as globals\n");
481
515
  code = code.replace(/import\s+React\d*(?:\s*,\s*\{[^}]*\})?\s+from\s+['"]react['"];?\s*/g, "// React is available as globalThis.React\n");
482
516
  code = code.replace(/import\s+\{[^}]*\}\s+from\s+['"]react['"];?\s*/g, "// React is available as globalThis.React\n");
483
- code = code.replace(/import\s+\w+\s+from\s+['"]node:[^'"]+['"];?\s*/g, "// Node.js built-ins are available in Deno runtime\n");
484
- code = code.replace(/import\s+\{[^}]*\}\s+from\s+['"]node:[^'"]+['"];?\s*/g, "// Node.js built-ins are available in Deno runtime\n");
517
+ code = code.replace(/import\s+\{([^}]+)\}\s+from\s+['"]node:fs['"];?\s*/g, (match, imports) => {
518
+ return imports.split(",").map((i) => i.trim()).map((imp) => {
519
+ if (imp === "readFileSync") return "const readFileSync = (path, encoding) => globalThis.Deno?.readTextFileSync ? globalThis.Deno.readTextFileSync(path) : \"\";";
520
+ if (imp === "existsSync") return "const existsSync = (path) => { try { globalThis.Deno?.statSync(path); return true; } catch { return false; } };";
521
+ if (imp === "statSync") return "const statSync = (path) => { const s = globalThis.Deno?.statSync(path); return { isFile: () => s?.isFile, isDirectory: () => s?.isDirectory, size: s?.size || 0 }; };";
522
+ if (imp === "readdirSync") return "const readdirSync = (path) => { const entries = []; for (const e of globalThis.Deno?.readDirSync(path) || []) entries.push(e.name); return entries; };";
523
+ return `const ${imp} = () => {};`;
524
+ }).join("\n");
525
+ });
526
+ code = code.replace(/import\s+\{([^}]+)\}\s+from\s+['"]node:path['"];?\s*/g, (match, imports) => {
527
+ return imports.split(",").map((i) => i.trim()).map((imp) => {
528
+ if (imp === "join") return "const join = (...parts) => parts.filter(p => p).join(\"/\").replace(/\\/+/g, \"/\") || \".\";";
529
+ if (imp === "resolve") return "const resolve = (...paths) => { const cwd = globalThis.Deno?.cwd?.() || \"/\"; let resolved = \"\"; let isAbs = false; for (let i = paths.length - 1; i >= -1 && !isAbs; i--) { const p = i >= 0 ? paths[i] : cwd; if (!p) continue; resolved = p + \"/\" + resolved; isAbs = p[0] === \"/\"; } const parts = resolved.split(\"/\").filter(Boolean); const result = []; for (const p of parts) { if (p === \"..\") { if (result.length && result[result.length-1] !== \"..\") result.pop(); else if (!isAbs) result.push(\"..\"); } else if (p !== \".\") result.push(p); } return (isAbs ? \"/\" : \"\") + result.join(\"/\") || \".\"; };";
530
+ if (imp === "dirname") return "const dirname = (path) => { const parts = path.split(\"/\").filter(Boolean); parts.pop(); return parts.length ? \"/\" + parts.join(\"/\") : \"/\"; };";
531
+ if (imp === "basename") return "const basename = (path) => path.split(\"/\").filter(Boolean).pop() || \"\";";
532
+ return `const ${imp} = () => {};`;
533
+ }).join("\n");
534
+ });
535
+ code = code.replace(/import\s+\{([^}]+)\}\s+from\s+['"]node:process['"];?\s*/g, (match, imports) => {
536
+ return imports.split(",").map((i) => i.trim()).map((imp) => {
537
+ if (imp === "cwd") return "const cwd = () => globalThis.Deno?.cwd?.() || \"/\";";
538
+ if (imp === "env") return "const env = new Proxy({}, { get: (_, prop) => globalThis.Deno?.env?.get?.(prop) });";
539
+ return `const ${imp} = () => {};`;
540
+ }).join("\n");
541
+ });
485
542
  const finalTransformedCode = this.createSelfRegisteringModule(code, componentId);
486
543
  await fs.promises.writeFile(outputPath, finalTransformedCode, "utf-8");
487
544
  if (returnCode) return finalTransformedCode;
@@ -556,44 +613,53 @@ if (!globalThis["${componentId}"]) {
556
613
  try {
557
614
  const moduleKey = "${componentId}";
558
615
  let mainExport = null;
559
- let exportedFunctions = {};
616
+ const exportedFunctions = {};
560
617
 
561
618
  globalThis.__server_functions = globalThis.__server_functions || {};
562
619
 
563
- ${namedExports.map((name) => `
564
- if (typeof ${name} !== 'undefined') {
565
- globalThis.${name} = ${name};
566
- globalThis.__server_functions['${name}'] = ${name};
567
- exportedFunctions['${name}'] = ${name};
568
- }`).join("")}
620
+ ${namedExports.map((name) => `if (typeof ${name} !== 'undefined') {
621
+ globalThis.${name} = ${name};
622
+ globalThis.__server_functions['${name}'] = ${name};
623
+ exportedFunctions['${name}'] = ${name};
624
+ }`).join("\n ")}
569
625
 
570
- ${defaultExportName ? `if (typeof ${defaultExportName} !== 'undefined') {
571
- mainExport = ${defaultExportName};
572
- } else ` : ""}{
573
- const potentialExports = {};
574
- ${namedExports.map((name) => `if (typeof ${name} !== 'undefined') potentialExports.${name} = ${name};`).join("\n ")}
626
+ ${defaultExportName ? `if (typeof ${defaultExportName} !== 'undefined') {
627
+ mainExport = ${defaultExportName};
628
+ }` : ""}
575
629
 
576
- if (Object.keys(potentialExports).length > 0) {
577
- if (Object.keys(potentialExports).length === 1) {
578
- mainExport = potentialExports[Object.keys(potentialExports)[0]];
630
+ if (mainExport === null && Object.keys(exportedFunctions).length > 0) {
631
+ if (Object.keys(exportedFunctions).length === 1) {
632
+ mainExport = exportedFunctions[Object.keys(exportedFunctions)[0]];
579
633
  } else {
580
- mainExport = potentialExports;
634
+ let componentFunction = null;
635
+ let firstFunction = null;
636
+
637
+ for (const [name, value] of Object.entries(exportedFunctions)) {
638
+ if (typeof value === 'function') {
639
+ if (!firstFunction) firstFunction = value;
640
+ if (/^[A-Z]/.test(name)) {
641
+ componentFunction = value;
642
+ break;
643
+ }
644
+ }
645
+ }
646
+
647
+ mainExport = componentFunction || firstFunction;
581
648
  }
582
649
  }
583
- }
584
650
 
585
- if (mainExport !== null) {
586
- if (!globalThis[moduleKey]) {
587
- globalThis[moduleKey] = mainExport;
588
- }
651
+ if (mainExport !== null) {
652
+ if (!globalThis[moduleKey]) {
653
+ globalThis[moduleKey] = mainExport;
654
+ }
589
655
 
590
- globalThis.__rsc_components = globalThis.__rsc_components || {};
591
- globalThis.__rsc_components[moduleKey] = mainExport;
656
+ globalThis.__rsc_components = globalThis.__rsc_components || {};
657
+ globalThis.__rsc_components[moduleKey] = mainExport;
592
658
 
593
- if (typeof globalThis.RscModuleManager !== 'undefined' && globalThis.RscModuleManager.register) {
594
- globalThis.RscModuleManager.register(moduleKey, mainExport, exportedFunctions);
659
+ if (typeof globalThis.RscModuleManager !== 'undefined' && globalThis.RscModuleManager.register) {
660
+ globalThis.RscModuleManager.register(moduleKey, mainExport, exportedFunctions);
661
+ }
595
662
  }
596
- }
597
663
  } catch (error) {
598
664
  console.error('Error in self-registration for ${componentId}:', error);
599
665
  }
@@ -1,5 +1,5 @@
1
1
  import { t as __require } from "./chunk-DFPPfDFE.mjs";
2
- import { n as createServerBuildPlugin } from "./server-build-CBAhNcXM.mjs";
2
+ import { n as createServerBuildPlugin } from "./server-build-MmIJHCpL.mjs";
3
3
  import fs, { promises, stat, unwatchFile, watch, watchFile } from "node:fs";
4
4
  import * as sp from "node:path";
5
5
  import path, { join, relative, resolve, sep } from "node:path";
@@ -2716,7 +2716,7 @@ const ${componentName$1} = registerClientReference(
2716
2716
  let serverComponentBuilder = null;
2717
2717
  const discoverAndRegisterComponents = async () => {
2718
2718
  try {
2719
- const { ServerComponentBuilder, scanDirectory } = await import("./server-build-C7crAeUc.mjs");
2719
+ const { ServerComponentBuilder, scanDirectory } = await import("./server-build-BqMz9o5w.mjs");
2720
2720
  const builder = new ServerComponentBuilder(projectRoot, {
2721
2721
  outDir: "dist",
2722
2722
  serverDir: "server",
@@ -2877,7 +2877,7 @@ const ${componentName$1} = registerClientReference(
2877
2877
  const handleServerComponentHMR = async (filePath) => {
2878
2878
  try {
2879
2879
  if (!isServerComponent(filePath)) return;
2880
- const { ServerComponentBuilder } = await import("./server-build-C7crAeUc.mjs");
2880
+ const { ServerComponentBuilder } = await import("./server-build-BqMz9o5w.mjs");
2881
2881
  const builder = new ServerComponentBuilder(projectRoot, {
2882
2882
  outDir: "dist",
2883
2883
  serverDir: "server",
package/dist/vite.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { a as headers, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, t as defineRariConfig } from "./vite-qjOIQBvr.mjs";
1
+ import { a as headers, i as rariRouter, n as defineRariOptions, o as RariResponse, r as rari, t as defineRariConfig } from "./vite-7bcdKkub.mjs";
2
2
  import { i as writeManifest, n as generateAppRouteManifest, r as loadManifest, t as AppRouteGenerator } from "./app-routes-DZjfJPdB.mjs";
3
3
  import { c as createHttpRuntimeClient, d as clearPropsCacheForComponent, f as extractMetadata, g as hasServerSideDataFetching, h as extractStaticParams, i as HttpRuntimeClient, m as extractServerPropsWithCache, p as extractServerProps, u as clearPropsCache } from "./runtime-client-AtnJSL0q.mjs";
4
- import "./server-build-CBAhNcXM.mjs";
4
+ import "./server-build-MmIJHCpL.mjs";
5
5
 
6
6
  export { AppRouteGenerator, HttpRuntimeClient, RariResponse, clearPropsCache, clearPropsCacheForComponent, createHttpRuntimeClient, defineRariConfig, defineRariOptions, extractMetadata, extractServerProps, extractServerPropsWithCache, extractStaticParams, generateAppRouteManifest, hasServerSideDataFetching, headers, loadManifest, rari, rariRouter, writeManifest };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rari",
3
3
  "type": "module",
4
- "version": "0.5.14",
4
+ "version": "0.5.15",
5
5
  "description": "Runtime Accelerated Rendering Infrastructure (Rari)",
6
6
  "author": "Ryan Skinner",
7
7
  "license": "MIT",
@@ -89,20 +89,20 @@
89
89
  "picocolors": "^1.1.1"
90
90
  },
91
91
  "optionalDependencies": {
92
- "rari-darwin-arm64": "0.5.9",
93
- "rari-darwin-x64": "0.5.9",
94
- "rari-linux-arm64": "0.5.9",
95
- "rari-linux-x64": "0.5.9",
96
- "rari-win32-x64": "0.5.9"
92
+ "rari-darwin-arm64": "0.5.10",
93
+ "rari-darwin-x64": "0.5.10",
94
+ "rari-linux-arm64": "0.5.10",
95
+ "rari-linux-x64": "0.5.10",
96
+ "rari-win32-x64": "0.5.10"
97
97
  },
98
98
  "devDependencies": {
99
- "@types/node": "^25.0.0",
99
+ "@types/node": "^25.0.1",
100
100
  "@types/react": "^19.2.7",
101
101
  "@typescript/native-preview": "7.0.0-dev.20251210.1",
102
102
  "chokidar": "^5.0.0",
103
103
  "eslint": "^9.39.1",
104
104
  "oxlint": "^1.32.0",
105
- "rolldown-vite": "^7.2.10",
106
- "tsdown": "^0.17.2"
105
+ "rolldown-vite": "^7.2.11",
106
+ "tsdown": "^0.17.3"
107
107
  }
108
108
  }
@@ -79,10 +79,17 @@ export class LoadingComponentRegistry {
79
79
  if (exactLoader) {
80
80
  try {
81
81
  const module = await exactLoader()
82
- if (module && module.default && typeof module.default === 'function') {
83
- return module.default
82
+ if (module) {
83
+ if (module.default && typeof module.default === 'function') {
84
+ return module.default
85
+ }
86
+ const exportedValues = Object.values(module).filter(
87
+ (value): value is React.ComponentType => typeof value === 'function',
88
+ )
89
+ if (exportedValues.length > 0) {
90
+ return exportedValues[0]
91
+ }
84
92
  }
85
- console.warn(`[LoadingRegistry] Invalid component for ${routePath}: module.default is not a function`)
86
93
  }
87
94
  catch (error) {
88
95
  console.warn(`[LoadingRegistry] Failed to load exact match for ${routePath}:`, error)
@@ -97,7 +104,17 @@ export class LoadingComponentRegistry {
97
104
  if (parentLoader) {
98
105
  try {
99
106
  const module = await parentLoader()
100
- return module.default
107
+ if (module) {
108
+ if (module.default && typeof module.default === 'function') {
109
+ return module.default
110
+ }
111
+ const exportedValues = Object.values(module).filter(
112
+ (value): value is React.ComponentType => typeof value === 'function',
113
+ )
114
+ if (exportedValues.length > 0) {
115
+ return exportedValues[0]
116
+ }
117
+ }
101
118
  }
102
119
  catch (error) {
103
120
  console.warn(`[LoadingRegistry] Failed to load parent match for ${parentPath}:`, error)
@@ -110,7 +127,17 @@ export class LoadingComponentRegistry {
110
127
  if (rootLoader) {
111
128
  try {
112
129
  const module = await rootLoader()
113
- return module.default
130
+ if (module) {
131
+ if (module.default && typeof module.default === 'function') {
132
+ return module.default
133
+ }
134
+ const exportedValues = Object.values(module).filter(
135
+ (value): value is React.ComponentType => typeof value === 'function',
136
+ )
137
+ if (exportedValues.length > 0) {
138
+ return exportedValues[0]
139
+ }
140
+ }
114
141
  }
115
142
  catch (error) {
116
143
  console.warn('[LoadingRegistry] Failed to load root loading component:', error)
@@ -4,6 +4,41 @@ import path from 'node:path'
4
4
  import process from 'node:process'
5
5
  import { build } from 'esbuild'
6
6
 
7
+ function isNodeBuiltin(moduleName: string): boolean {
8
+ const nodeBuiltins = [
9
+ 'fs',
10
+ 'path',
11
+ 'os',
12
+ 'crypto',
13
+ 'util',
14
+ 'stream',
15
+ 'events',
16
+ 'process',
17
+ 'buffer',
18
+ 'url',
19
+ 'querystring',
20
+ 'zlib',
21
+ 'http',
22
+ 'https',
23
+ 'net',
24
+ 'tls',
25
+ 'child_process',
26
+ 'cluster',
27
+ 'worker_threads',
28
+ 'assert',
29
+ 'dns',
30
+ 'readline',
31
+ 'repl',
32
+ 'string_decoder',
33
+ 'timers',
34
+ 'tty',
35
+ 'v8',
36
+ 'vm',
37
+ 'perf_hooks',
38
+ ]
39
+ return nodeBuiltins.includes(moduleName)
40
+ }
41
+
7
42
  interface ServerComponentManifest {
8
43
  components: Record<
9
44
  string,
@@ -356,7 +391,7 @@ const ${importName} = (props) => {
356
391
  loader: loader as any,
357
392
  },
358
393
  bundle: true,
359
- platform: 'neutral',
394
+ platform: 'node',
360
395
  target: 'es2022',
361
396
  format: 'esm',
362
397
  external: [],
@@ -410,12 +445,14 @@ const ${importName} = (props) => {
410
445
  if (args.path === 'react' || args.path === 'react-dom' || args.path === 'react/jsx-runtime' || args.path === 'react/jsx-dev-runtime') {
411
446
  return { path: args.path, external: true }
412
447
  }
448
+
449
+ if (args.path.startsWith('node:') || isNodeBuiltin(args.path)) {
450
+ return { path: args.path, external: true }
451
+ }
452
+
413
453
  if (args.path === 'rari/client') {
414
454
  return null
415
455
  }
416
- if (/^[^./]/.test(args.path)) {
417
- return { path: args.path, external: true }
418
- }
419
456
 
420
457
  return null
421
458
  })
@@ -607,7 +644,7 @@ const ${importName} = (props) => {
607
644
  loader: loader as any,
608
645
  },
609
646
  bundle: true,
610
- platform: 'neutral',
647
+ platform: 'node',
611
648
  target: 'es2022',
612
649
  format: 'esm',
613
650
  outfile: outputPath,
@@ -656,10 +693,16 @@ const ${importName} = (props) => {
656
693
  if (args.path === 'react' || args.path === 'react-dom' || args.path === 'react/jsx-runtime' || args.path === 'react/jsx-dev-runtime') {
657
694
  return { path: args.path, external: true }
658
695
  }
696
+
697
+ if (args.path.startsWith('node:') || isNodeBuiltin(args.path)) {
698
+ return { path: args.path, external: true }
699
+ }
700
+
659
701
  if (args.path === 'rari/client') {
660
702
  return null
661
703
  }
662
- return { path: args.path, external: true }
704
+
705
+ return null
663
706
  })
664
707
  },
665
708
  },
@@ -723,13 +766,65 @@ const ${importName} = (props) => {
723
766
  /import\s+\{[^}]*\}\s+from\s+['"]react['"];?\s*/g,
724
767
  '// React is available as globalThis.React\n',
725
768
  )
769
+
770
+ code = code.replace(
771
+ /import\s+\{([^}]+)\}\s+from\s+['"]node:fs['"];?\s*/g,
772
+ (match, imports) => {
773
+ const importList = imports.split(',').map((i: string) => i.trim())
774
+ return importList.map((imp: string) => {
775
+ if (imp === 'readFileSync') {
776
+ return 'const readFileSync = (path, encoding) => globalThis.Deno?.readTextFileSync ? globalThis.Deno.readTextFileSync(path) : "";'
777
+ }
778
+ if (imp === 'existsSync') {
779
+ return 'const existsSync = (path) => { try { globalThis.Deno?.statSync(path); return true; } catch { return false; } };'
780
+ }
781
+ if (imp === 'statSync') {
782
+ return 'const statSync = (path) => { const s = globalThis.Deno?.statSync(path); return { isFile: () => s?.isFile, isDirectory: () => s?.isDirectory, size: s?.size || 0 }; };'
783
+ }
784
+ if (imp === 'readdirSync') {
785
+ return 'const readdirSync = (path) => { const entries = []; for (const e of globalThis.Deno?.readDirSync(path) || []) entries.push(e.name); return entries; };'
786
+ }
787
+ return `const ${imp} = () => {};`
788
+ }).join('\n')
789
+ },
790
+ )
791
+
726
792
  code = code.replace(
727
- /import\s+\w+\s+from\s+['"]node:[^'"]+['"];?\s*/g,
728
- '// Node.js built-ins are available in Deno runtime\n',
793
+ /import\s+\{([^}]+)\}\s+from\s+['"]node:path['"];?\s*/g,
794
+ (match, imports) => {
795
+ const importList = imports.split(',').map((i: string) => i.trim())
796
+ return importList.map((imp: string) => {
797
+ if (imp === 'join') {
798
+ return 'const join = (...parts) => parts.filter(p => p).join("/").replace(/\\/+/g, "/") || ".";'
799
+ }
800
+ if (imp === 'resolve') {
801
+ return 'const resolve = (...paths) => { const cwd = globalThis.Deno?.cwd?.() || "/"; let resolved = ""; let isAbs = false; for (let i = paths.length - 1; i >= -1 && !isAbs; i--) { const p = i >= 0 ? paths[i] : cwd; if (!p) continue; resolved = p + "/" + resolved; isAbs = p[0] === "/"; } const parts = resolved.split("/").filter(Boolean); const result = []; for (const p of parts) { if (p === "..") { if (result.length && result[result.length-1] !== "..") result.pop(); else if (!isAbs) result.push(".."); } else if (p !== ".") result.push(p); } return (isAbs ? "/" : "") + result.join("/") || "."; };'
802
+ }
803
+ if (imp === 'dirname') {
804
+ return 'const dirname = (path) => { const parts = path.split("/").filter(Boolean); parts.pop(); return parts.length ? "/" + parts.join("/") : "/"; };'
805
+ }
806
+ if (imp === 'basename') {
807
+ return 'const basename = (path) => path.split("/").filter(Boolean).pop() || "";'
808
+ }
809
+ return `const ${imp} = () => {};`
810
+ }).join('\n')
811
+ },
729
812
  )
813
+
730
814
  code = code.replace(
731
- /import\s+\{[^}]*\}\s+from\s+['"]node:[^'"]+['"];?\s*/g,
732
- '// Node.js built-ins are available in Deno runtime\n',
815
+ /import\s+\{([^}]+)\}\s+from\s+['"]node:process['"];?\s*/g,
816
+ (match, imports) => {
817
+ const importList = imports.split(',').map((i: string) => i.trim())
818
+ return importList.map((imp: string) => {
819
+ if (imp === 'cwd') {
820
+ return 'const cwd = () => globalThis.Deno?.cwd?.() || "/";'
821
+ }
822
+ if (imp === 'env') {
823
+ return 'const env = new Proxy({}, { get: (_, prop) => globalThis.Deno?.env?.get?.(prop) });'
824
+ }
825
+ return `const ${imp} = () => {};`
826
+ }).join('\n')
827
+ },
733
828
  )
734
829
 
735
830
  const finalTransformedCode = this.createSelfRegisteringModule(
@@ -864,50 +959,59 @@ if (!globalThis["${componentId}"]) {
864
959
  try {
865
960
  const moduleKey = "${componentId}";
866
961
  let mainExport = null;
867
- let exportedFunctions = {};
962
+ const exportedFunctions = {};
868
963
 
869
964
  globalThis.__server_functions = globalThis.__server_functions || {};
870
965
 
871
- ${namedExports
872
- .map(
873
- name => `
874
- if (typeof ${name} !== 'undefined') {
875
- globalThis.${name} = ${name};
876
- globalThis.__server_functions['${name}'] = ${name};
877
- exportedFunctions['${name}'] = ${name};
878
- }`,
879
- )
880
- .join('')}
881
-
882
- ${defaultExportName
883
- ? `if (typeof ${defaultExportName} !== 'undefined') {
884
- mainExport = ${defaultExportName};
885
- } else `
886
- : ''}{
887
- const potentialExports = {};
888
- ${namedExports.map(name => `if (typeof ${name} !== 'undefined') potentialExports.${name} = ${name};`).join('\n ')}
889
-
890
- if (Object.keys(potentialExports).length > 0) {
891
- if (Object.keys(potentialExports).length === 1) {
892
- mainExport = potentialExports[Object.keys(potentialExports)[0]];
966
+ ${namedExports
967
+ .map(
968
+ name => `if (typeof ${name} !== 'undefined') {
969
+ globalThis.${name} = ${name};
970
+ globalThis.__server_functions['${name}'] = ${name};
971
+ exportedFunctions['${name}'] = ${name};
972
+ }`,
973
+ )
974
+ .join('\n ')}
975
+
976
+ ${defaultExportName
977
+ ? `if (typeof ${defaultExportName} !== 'undefined') {
978
+ mainExport = ${defaultExportName};
979
+ }`
980
+ : ''}
981
+
982
+ if (mainExport === null && Object.keys(exportedFunctions).length > 0) {
983
+ if (Object.keys(exportedFunctions).length === 1) {
984
+ mainExport = exportedFunctions[Object.keys(exportedFunctions)[0]];
893
985
  } else {
894
- mainExport = potentialExports;
986
+ let componentFunction = null;
987
+ let firstFunction = null;
988
+
989
+ for (const [name, value] of Object.entries(exportedFunctions)) {
990
+ if (typeof value === 'function') {
991
+ if (!firstFunction) firstFunction = value;
992
+ if (/^[A-Z]/.test(name)) {
993
+ componentFunction = value;
994
+ break;
995
+ }
996
+ }
997
+ }
998
+
999
+ mainExport = componentFunction || firstFunction;
895
1000
  }
896
1001
  }
897
- }
898
1002
 
899
- if (mainExport !== null) {
900
- if (!globalThis[moduleKey]) {
901
- globalThis[moduleKey] = mainExport;
902
- }
1003
+ if (mainExport !== null) {
1004
+ if (!globalThis[moduleKey]) {
1005
+ globalThis[moduleKey] = mainExport;
1006
+ }
903
1007
 
904
- globalThis.__rsc_components = globalThis.__rsc_components || {};
905
- globalThis.__rsc_components[moduleKey] = mainExport;
1008
+ globalThis.__rsc_components = globalThis.__rsc_components || {};
1009
+ globalThis.__rsc_components[moduleKey] = mainExport;
906
1010
 
907
- if (typeof globalThis.RscModuleManager !== 'undefined' && globalThis.RscModuleManager.register) {
908
- globalThis.RscModuleManager.register(moduleKey, mainExport, exportedFunctions);
1011
+ if (typeof globalThis.RscModuleManager !== 'undefined' && globalThis.RscModuleManager.register) {
1012
+ globalThis.RscModuleManager.register(moduleKey, mainExport, exportedFunctions);
1013
+ }
909
1014
  }
910
- }
911
1015
  } catch (error) {
912
1016
  console.error('Error in self-registration for ${componentId}:', error);
913
1017
  }
@@ -1,3 +0,0 @@
1
- import { n as createServerBuildPlugin, r as scanDirectory, t as ServerComponentBuilder } from "./server-build-CBAhNcXM.mjs";
2
-
3
- export { ServerComponentBuilder, scanDirectory };