dinou 9.0.1 → 9.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +503 -9883
  3. package/dinou/bun/build.js +38 -1
  4. package/{cli.js → dinou/cli.js} +14 -7
  5. package/dinou/cloudflare/build.js +37 -0
  6. package/dinou/core/build-static-pages.js +15 -7
  7. package/dinou/core/cache-revalidate.js +909 -151
  8. package/dinou/core/cache-slot.js +728 -97
  9. package/dinou/core/client-webpack.jsx +60 -9
  10. package/dinou/core/client.jsx +60 -9
  11. package/dinou/core/edge-ssr.js +33 -5
  12. package/dinou/core/generate-static.js +109 -47
  13. package/dinou/core/get-jsx.js +333 -329
  14. package/dinou/core/handler.js +2983 -2343
  15. package/dinou/core/layout-functions.js +102 -1
  16. package/dinou/core/ppr-context.js +256 -105
  17. package/dinou/core/ppr-runtime.js +540 -267
  18. package/dinou/core/render-jsx-to-client-jsx.js +131 -71
  19. package/dinou/core/slot.js +246 -33
  20. package/dinou/core/storage-adapter.js +117 -11
  21. package/dinou/deno/build.js +38 -1
  22. package/dinou/deno/seed-kv.js +43 -11
  23. package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +242 -225
  24. package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +253 -226
  25. package/dinou/esbuild/react-refresh/esm-hmr/client.js +209 -209
  26. package/dinou/node/build.js +2 -2
  27. package/dinou/node/bundle-dual-engine.js +2 -0
  28. package/dinou/node/dev.js +2853 -2704
  29. package/dinou/package.json +5 -2
  30. package/dinou/rollup/react-refresh/esm-hmr/client.js +220 -220
  31. package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +182 -160
  32. package/dinou/server.d.ts +25 -11
  33. package/dinou/server.js +5 -0
  34. package/dinou/webpack/loaders/server-functions-loader.js +101 -94
  35. package/dinou/webpack/webpack.config.js +9 -4
  36. package/eject.js +219 -223
  37. package/package.json +2 -2
@@ -141,6 +141,7 @@ function findClientComponents() {
141
141
  const coreCandidates = [
142
142
  ...Array.from(candidateLinkPaths),
143
143
  ...Array.from(candidateRedirectPaths),
144
+ ...Array.from(candidateSlotPaths),
144
145
  ];
145
146
  for (const f of coreCandidates) {
146
147
  if (fs.existsSync(f)) {
@@ -406,6 +407,17 @@ if (!isWebpackBuild && Object.keys(parsedClientManifest).length > 0) {
406
407
  }
407
408
  }
408
409
  }
410
+ if (slotChunkId) {
411
+ imports["dinou/core/slot.js"] = slotChunkId;
412
+ imports["dinou/core/slot"] = slotChunkId;
413
+ imports["/dinou/core/slot.js"] = slotChunkId;
414
+ imports["./dinou/core/slot.js"] = slotChunkId;
415
+ for (const sp of candidateSlotPaths) {
416
+ for (const u of generateAllUrlVariants(sp)) {
417
+ imports[u] = slotChunkId;
418
+ }
419
+ }
420
+ }
409
421
 
410
422
  importMapHtml = `<script type="importmap">{"imports":${JSON.stringify(imports)}}</script>`;
411
423
  }
@@ -421,6 +433,8 @@ function findLayoutRoutes(dir, rel = "") {
421
433
  findLayoutRoutes(path.join(dir, entry.name), rel ? `${rel}/${entry.name}` : entry.name);
422
434
  } else if (/^layout\.[jt]sx?$/.test(entry.name)) {
423
435
  discoveredLayouts.push(rel);
436
+ } else if (entry.name === "no_layout") {
437
+ discoveredLayouts.push("!" + rel);
424
438
  }
425
439
  }
426
440
  }
@@ -557,6 +571,17 @@ if (redirectChunkId) {
557
571
  }
558
572
  }
559
573
  }
574
+ if (slotChunkId) {
575
+ const slotCompIndex = clientComponents.findIndex((c) => candidateSlotPaths.has(path.resolve(c)));
576
+ if (slotCompIndex !== -1) {
577
+ addClientModule(slotChunkId, `mod_${slotCompIndex}`);
578
+ for (const sp of candidateSlotPaths) {
579
+ for (const u of generateAllUrlVariants(sp)) {
580
+ addClientModule(u, `mod_${slotCompIndex}`);
581
+ }
582
+ }
583
+ }
584
+ }
560
585
 
561
586
  serverFunctionFiles.forEach((relPath, index) => {
562
587
  const normRel = relPath.replace(/\\/g, "/");
@@ -628,6 +653,18 @@ if (redirectChunkId) {
628
653
  }
629
654
  }
630
655
  }
656
+ if (slotChunkId) {
657
+ const slotCompIndex = clientComponents.findIndex((c) => candidateSlotPaths.has(path.resolve(c)));
658
+ if (slotCompIndex !== -1) {
659
+ const fileUrl = pathToFileURL(clientComponents[slotCompIndex]).href;
660
+ addModuleMap(slotChunkId, `{ "*": { id: ${JSON.stringify(fileUrl)}, chunks: [], name: "*" } }`);
661
+ for (const sp of candidateSlotPaths) {
662
+ for (const u of generateAllUrlVariants(sp)) {
663
+ addModuleMap(u, `{ "*": { id: ${JSON.stringify(fileUrl)}, chunks: [], name: "*" } }`);
664
+ }
665
+ }
666
+ }
667
+ }
631
668
  ssrManifestCode += ` },\n serverModuleMap: {\n`;
632
669
 
633
670
  const emittedServerModuleMap = new Set();
@@ -766,7 +803,7 @@ export async function fetch(req) {
766
803
  }
767
804
 
768
805
  export default {
769
- port: PORT,
806
+ port: PORT, ...(process.env.HOST ? { hostname: process.env.HOST } : {}),
770
807
  fetch,
771
808
  idleTimeout: IDLE_TIMEOUT,
772
809
  };
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import fs from "node:fs";
4
- import { program } from "commander";
3
+
4
+ import { program } from "#commander";
5
5
  import { execSync } from "node:child_process";
6
6
  import path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
- const dinouPath = fs.existsSync(path.resolve(__dirname, "dinou")) ? path.resolve(__dirname, "dinou") : __dirname;
10
+ const dinouPath = __dirname;
11
11
  const projectRoot = process.cwd();
12
12
 
13
13
  // Global CLI options for Dinou v9 (Dual-Mode Vendoring)
14
14
  program
15
15
  .name("dinou")
16
16
  .description("Full-stack React 19 framework with native RSC, progressive streaming, and dual-mode vendoring")
17
- .version("9.0.1")
17
+ .version("9.0.3")
18
18
  .option("-u, --unvendorized", "Run with standard node_modules dependencies instead of pre-bundled vendor packages");
19
19
 
20
20
  const isUnvendorizedRequested = () =>
@@ -27,17 +27,24 @@ const isUnvendorizedRequested = () =>
27
27
  const pathKey = Object.keys(process.env).find((k) => k.toLowerCase() === "path") || "PATH";
28
28
  const projectBin = path.join(projectRoot, "node_modules", ".bin");
29
29
  const dinouBin = path.join(dinouPath, "node_modules", ".bin");
30
- const extendedPath = [projectBin, dinouBin, process.env[pathKey]].filter(Boolean).join(path.delimiter);
30
+ const dinouParentBin = path.resolve(dinouPath, "..", "node_modules", ".bin");
31
+ const extendedPath = [projectBin, dinouBin, dinouParentBin, process.env[pathKey]].filter(Boolean).join(path.delimiter);
31
32
 
32
33
  const runCommand = (command, options = {}) => {
33
34
  try {
34
35
  const unvendorized = isUnvendorizedRequested();
36
+ const baseNodeOptions = process.env.NODE_OPTIONS || "";
37
+ const nodeOptions = unvendorized && !baseNodeOptions.includes("unvendorized")
38
+ ? (baseNodeOptions ? `${baseNodeOptions} ` : "") + "--conditions=unvendorized"
39
+ : baseNodeOptions;
40
+
35
41
  const env = {
36
42
  ...process.env,
37
43
  [pathKey]: extendedPath,
38
44
  Path: extendedPath,
39
45
  PATH: extendedPath,
40
46
  ...(unvendorized ? { DINOU_UNVENDORIZED: "true" } : {}),
47
+ ...(nodeOptions ? { NODE_OPTIONS: nodeOptions } : {}),
41
48
  ...(options.env || {}),
42
49
  };
43
50
 
@@ -332,7 +339,7 @@ for (const t of denoTargets) {
332
339
  .command(cmdName)
333
340
  .description(`Compile standalone Deno executable (${t.name || "host"}, ${b})`)
334
341
  .action(() => {
335
- runCommand(`${runDenoBuild(b)} && deno compile ${t.flags}--no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output ${t.outfile} .dinou/deno/main.js`);
342
+ runCommand(`${runDenoBuild(b)} && deno compile ${t.flags}--unstable-kv --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output ${t.outfile} .dinou/deno/main.js`);
336
343
  });
337
344
  }
338
345
  }
@@ -518,7 +525,7 @@ program
518
525
  .description("Copy the framework to the root of the project")
519
526
  .action(async () => {
520
527
  console.log("Executing eject...");
521
- const { eject } = await import("./eject.js");
528
+ const { eject } = await import("../eject.js");
522
529
  eject();
523
530
  });
524
531
 
@@ -166,6 +166,7 @@ function findClientComponents() {
166
166
  const coreCandidates = [
167
167
  ...Array.from(candidateLinkPaths),
168
168
  ...Array.from(candidateRedirectPaths),
169
+ ...Array.from(candidateSlotPaths),
169
170
  ];
170
171
  for (const f of coreCandidates) {
171
172
  if (fs.existsSync(f)) {
@@ -433,6 +434,17 @@ if (!isWebpackBuild && Object.keys(parsedClientManifest).length > 0) {
433
434
  }
434
435
  }
435
436
  }
437
+ if (slotChunkId) {
438
+ imports["dinou/core/slot.js"] = slotChunkId;
439
+ imports["dinou/core/slot"] = slotChunkId;
440
+ imports["/dinou/core/slot.js"] = slotChunkId;
441
+ imports["./dinou/core/slot.js"] = slotChunkId;
442
+ for (const sp of candidateSlotPaths) {
443
+ for (const u of generateAllUrlVariants(sp)) {
444
+ imports[u] = slotChunkId;
445
+ }
446
+ }
447
+ }
436
448
 
437
449
  importMapHtml = `<script type="importmap">{"imports":${JSON.stringify(imports)}}</script>`;
438
450
  }
@@ -448,6 +460,8 @@ function findLayoutRoutes(dir, rel = "") {
448
460
  findLayoutRoutes(path.join(dir, entry.name), rel ? `${rel}/${entry.name}` : entry.name);
449
461
  } else if (/^layout\.[jt]sx?$/.test(entry.name)) {
450
462
  discoveredLayouts.push(rel);
463
+ } else if (entry.name === "no_layout") {
464
+ discoveredLayouts.push("!" + rel);
451
465
  }
452
466
  }
453
467
  }
@@ -584,6 +598,17 @@ if (redirectChunkId) {
584
598
  }
585
599
  }
586
600
  }
601
+ if (slotChunkId) {
602
+ const slotCompIndex = clientComponents.findIndex((c) => candidateSlotPaths.has(path.resolve(c)));
603
+ if (slotCompIndex !== -1) {
604
+ addClientModule(slotChunkId, `mod_${slotCompIndex}`);
605
+ for (const sp of candidateSlotPaths) {
606
+ for (const u of generateAllUrlVariants(sp)) {
607
+ addClientModule(u, `mod_${slotCompIndex}`);
608
+ }
609
+ }
610
+ }
611
+ }
587
612
 
588
613
  serverFunctionFiles.forEach((relPath, index) => {
589
614
  const normRel = relPath.replace(/\\/g, "/");
@@ -655,6 +680,18 @@ if (redirectChunkId) {
655
680
  }
656
681
  }
657
682
  }
683
+ if (slotChunkId) {
684
+ const slotCompIndex = clientComponents.findIndex((c) => candidateSlotPaths.has(path.resolve(c)));
685
+ if (slotCompIndex !== -1) {
686
+ const fileUrl = pathToFileURL(clientComponents[slotCompIndex]).href;
687
+ addModuleMap(slotChunkId, `{ "*": { id: ${JSON.stringify(fileUrl)}, chunks: [], name: "*" } }`);
688
+ for (const sp of candidateSlotPaths) {
689
+ for (const u of generateAllUrlVariants(sp)) {
690
+ addModuleMap(u, `{ "*": { id: ${JSON.stringify(fileUrl)}, chunks: [], name: "*" } }`);
691
+ }
692
+ }
693
+ }
694
+ }
658
695
  ssrManifestCode += ` },\n serverModuleMap: {\n`;
659
696
 
660
697
  const emittedServerModuleMap = new Set();
@@ -6,7 +6,7 @@ import { getFilePathAndDynamicParams } from "./get-file-path-and-dynamic-params.
6
6
  import importModule from "./import-module.js";
7
7
  import { requestStorage } from "./request-context.js";
8
8
  import { getLayoutProps, resolveLayoutFunctionsConfig, getLayoutFunctionsPath } from "./layout-functions.js";
9
- import { runWithPprContext, getRegisteredHoles } from "./ppr-context.js";
9
+ import { runWithPprContext, getRegisteredHoles, resetPprHoles } from "./ppr-context.js";
10
10
  import { resolveModulePpr } from "./resolve-module-ppr.js";
11
11
  import { getDinouConfig } from "./load-dinou-config.js";
12
12
  import { createBailoutProxy } from "./bailout-proxy.js";
@@ -916,6 +916,7 @@ async function buildStaticPages(onProgress = null) {
916
916
 
917
917
  let revalidate;
918
918
  let cacheTags = [];
919
+ let capturedHoles = [];
919
920
  const jsx = await requestStorage.run(mockContext, async () => {
920
921
  return await runWithPprContext({ isPpr: Boolean(pageIsPpr) }, async () => {
921
922
  const [pagePath] = getFilePathAndDynamicParams(
@@ -1083,11 +1084,14 @@ async function buildStaticPages(onProgress = null) {
1083
1084
  }
1084
1085
 
1085
1086
  // Render the layout-nested React element tree to client-side RSC JSON format
1086
- return await asyncRenderJSXToClientJSX(jsx);
1087
+ resetPprHoles();
1088
+ const renderedSingleJsx = await asyncRenderJSXToClientJSX(jsx);
1089
+ capturedHoles = pageIsPpr ? getRegisteredHoles() : [];
1090
+ return renderedSingleJsx;
1087
1091
  });
1088
1092
  });
1089
1093
 
1090
- if (!isStatic && !pageIsPpr) {
1094
+ if (!isStatic) {
1091
1095
  // ❌ DO NOT save file.
1092
1096
  // Will behave as pure SSR at runtime.
1093
1097
  if (process.env.DINOU_DEBUG) {
@@ -1105,7 +1109,7 @@ async function buildStaticPages(onProgress = null) {
1105
1109
  cookies: mockRes._cookies,
1106
1110
  };
1107
1111
 
1108
- const holes = pageIsPpr ? getRegisteredHoles() : [];
1112
+ const holes = pageIsPpr ? capturedHoles : [];
1109
1113
  staticRoutes.add(reqPath);
1110
1114
  staticMetadata.set(reqPath, {
1111
1115
  revalidate: typeof revalidate === "function" ? await revalidate() : revalidate,
@@ -1303,6 +1307,7 @@ async function buildStaticPage(reqPath, isDynamic = null) {
1303
1307
  );
1304
1308
 
1305
1309
  pageIsPpr = await resolveBuildPprForRoute(segments, pagePath, pageFunctionsPath, srcFolder);
1310
+ let capturedHoles = [];
1306
1311
 
1307
1312
  return await runWithPprContext({ isPpr: pageIsPpr }, async () => {
1308
1313
  let props = { params: dParams };
@@ -1447,11 +1452,14 @@ async function buildStaticPage(reqPath, isDynamic = null) {
1447
1452
  }
1448
1453
  }
1449
1454
 
1450
- return await asyncRenderJSXToClientJSX(jsx);
1455
+ resetPprHoles();
1456
+ const renderedSingleJsx = await asyncRenderJSXToClientJSX(jsx);
1457
+ capturedHoles = pageIsPpr ? getRegisteredHoles() : [];
1458
+ return renderedSingleJsx;
1451
1459
  });
1452
1460
  });
1453
1461
 
1454
- if (!isStatic && !pageIsPpr) {
1462
+ if (!isStatic) {
1455
1463
  // ❌ DO NOT save file.
1456
1464
  // It will behave as pure SSR at runtime.
1457
1465
  if (process.env.DINOU_DEBUG) {
@@ -1472,7 +1480,7 @@ async function buildStaticPage(reqPath, isDynamic = null) {
1472
1480
  cookies: mockRes._cookies,
1473
1481
  };
1474
1482
 
1475
- const holes = pageIsPpr ? getRegisteredHoles() : [];
1483
+ const holes = pageIsPpr ? capturedHoles : [];
1476
1484
  staticRoutes.add(reqPath);
1477
1485
  staticMetadata.set(reqPath, {
1478
1486
  revalidate: typeof revalidate === "function" ? await revalidate() : revalidate,