dinou 7.2.0 → 8.0.0
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/CHANGELOG.md +37 -0
- package/README.md +1 -1
- package/cli.js +124 -121
- package/dinou/adapters/netlify.js +1 -0
- package/dinou/adapters/{node.mjs → node.js} +9 -3
- package/dinou/bun/{build.mjs → build.js} +20 -8
- package/dinou/cloudflare/{build.mjs → build.js} +23 -8
- package/dinou/cloudflare/shims/fs.js +3 -0
- package/dinou/constants.js +3 -3
- package/dinou/core/asset-extensions.js +5 -5
- package/dinou/core/bailout-proxy.js +3 -3
- package/dinou/core/build-static-pages.js +21 -17
- package/dinou/core/cache-revalidate.js +14 -33
- package/dinou/core/cache-slot.js +21 -10
- package/dinou/core/config.js +2 -5
- package/dinou/core/createScopedName.js +3 -3
- package/dinou/core/dinou-paths.js +15 -12
- package/dinou/core/generate-route-types.js +8 -3
- package/dinou/core/generate-static-page.js +6 -5
- package/dinou/core/generate-static-rsc.js +15 -10
- package/dinou/core/generate-static.js +11 -10
- package/dinou/core/generating-isg.js +12 -11
- package/dinou/core/get-abs-path-with-ext.js +8 -6
- package/dinou/core/get-asset-from-manifest.js +4 -4
- package/dinou/core/get-error-jsx.js +12 -9
- package/dinou/core/get-file-path-and-dynamic-params.js +7 -4
- package/dinou/core/get-jsx.js +19 -13
- package/dinou/core/handler.js +73 -33
- package/dinou/core/http-adapter.js +6 -2
- package/dinou/core/import-module.js +5 -4
- package/dinou/core/layout-functions.js +11 -6
- package/dinou/core/load-dinou-config.js +10 -4
- package/dinou/core/manifest-provider.js +11 -4
- package/dinou/core/parse-exports.js +11 -6
- package/dinou/core/path-utils.js +2 -2
- package/dinou/core/ppr-context.js +11 -11
- package/dinou/core/ppr-runtime.js +10 -6
- package/dinou/core/render-jsx-to-client-jsx.js +6 -3
- package/dinou/core/request-context.js +11 -7
- package/dinou/core/resolve-module-ppr.js +2 -2
- package/dinou/core/resolve-setup-files.js +70 -0
- package/dinou/core/revalidating.js +14 -25
- package/dinou/core/route-generator.js +12 -8
- package/dinou/core/rsc-renderer.js +13 -2
- package/dinou/core/run-ssg.js +9 -4
- package/dinou/core/safe-rename.js +3 -3
- package/dinou/core/scan-dependency-components.js +9 -3
- package/dinou/core/status-manifest.js +5 -5
- package/dinou/core/storage-adapter.js +13 -3
- package/dinou/core/url-resolver.js +2 -2
- package/dinou/core/vfs.js +7 -7
- package/dinou/deno/{build.mjs → build.js} +20 -8
- package/dinou/esbuild/{build.mjs → build.js} +4 -4
- package/dinou/esbuild/{dev.mjs → dev.js} +6 -6
- package/dinou/esbuild/helpers-esbuild/{get-config-esbuild-prod.mjs → get-config-esbuild-prod.js} +7 -7
- package/dinou/esbuild/helpers-esbuild/{get-config-esbuild.mjs → get-config-esbuild.js} +8 -8
- package/dinou/esbuild/helpers-esbuild/{get-esbuild-entries.mjs → get-esbuild-entries.js} +2 -2
- package/dinou/esbuild/plugins-esbuild/{assets-plugin.mjs → assets-plugin.js} +1 -1
- package/dinou/esbuild/plugins-esbuild/{stable-chunk-names-and-maps-plugin.mjs → stable-chunk-names-and-maps-plugin.js} +1 -1
- package/dinou/esbuild/plugins-esbuild/{write-plugin.mjs → write-plugin.js} +1 -1
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +4 -3
- package/dinou/esbuild/react-refresh/babel-config.js +5 -1
- package/dinou/esbuild/react-refresh/esm-hmr/server.js +7 -4
- package/dinou/esbuild/react-refresh/{esm-hmr-plugin.mjs → esm-hmr-plugin.js} +4 -4
- package/dinou/esbuild/react-refresh/{react-refresh-runtime.mjs → react-refresh-runtime.js} +1 -1
- package/dinou/index.d.ts +13 -0
- package/dinou/index.js +40 -19
- package/dinou/node/{build.mjs → build.js} +10 -6
- package/dinou/node/{bundle-dual-engine.mjs → bundle-dual-engine.js} +22 -10
- package/dinou/node/{dev.mjs → dev.js} +43 -20
- package/dinou/package.json +8 -7
- package/dinou/rollup/postcss.config.js +1 -1
- package/dinou/rollup/react-refresh/esm-hmr/server.js +7 -4
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +2 -1
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +23 -16
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +6 -5
- package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +2 -1
- package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +3 -2
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +16 -13
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +7 -6
- package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +6 -3
- package/dinou/rollup/rollup.config.js +27 -23
- package/dinou/server.js +21 -26
- package/dinou/webpack/helpers/get-webpack-entries.js +14 -11
- package/dinou/webpack/loaders/server-functions-loader.js +5 -6
- package/dinou/webpack/loaders/swc-loader.js +4 -2
- package/dinou/webpack/plugins/manifest-generator-plugin.js +3 -1
- package/dinou/webpack/plugins/server-functions-plugin.js +4 -3
- package/dinou/webpack/plugins/webpack-memory-plugin.js +3 -2
- package/dinou/webpack/postcss.config.js +1 -1
- package/dinou/webpack/webpack.config.js +22 -20
- package/eject.js +198 -191
- package/package.json +111 -110
- package/dinou/config.js +0 -1
- package/dinou/config.mjs +0 -2
- package/dinou/core/css-require-hook.js +0 -64
- package/dinou/index.mjs +0 -43
- package/dinou/server.mjs +0 -30
- /package/dinou/core/{export-static.mjs → export-static.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{normalize-path.mjs → normalize-path.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{strip-namespace.mjs → strip-namespace.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{swc-disk-cache.mjs → swc-disk-cache.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{update-manifest-for-module.mjs → update-manifest-for-module.js} +0 -0
- /package/dinou/esbuild/helpers-esbuild/{write.mjs → write.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{babel-react-compiler-plugin.mjs → babel-react-compiler-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{css-processor-plugin.mjs → css-processor-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{manifest-generator-plugin.mjs → manifest-generator-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{react-client-manifest-plugin.mjs → react-client-manifest-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{server-functions-plugin.mjs → server-functions-plugin.js} +0 -0
- /package/dinou/esbuild/plugins-esbuild/{skip-missing-entry-points-plugin.mjs → skip-missing-entry-points-plugin.js} +0 -0
- /package/dinou/esbuild/react-refresh/esm-hmr/{client.mjs → client.js} +0 -0
- /package/dinou/esbuild/react-refresh/{is-react-refresh-boundary.mjs → is-react-refresh-boundary.js} +0 -0
- /package/dinou/node/{port-selector.mjs → port-selector.js} +0 -0
- /package/dinou/node/{terminal-status.mjs → terminal-status.js} +0 -0
|
@@ -7,23 +7,30 @@
|
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import esbuild from "esbuild";
|
|
10
|
-
import { createRequire } from "node:module";
|
|
11
10
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const { useClientRegex, useServerRegex } = require("../constants.js");
|
|
18
|
-
const {
|
|
12
|
+
import { generateRouteModulesCode, generateRouteTypes } from "../core/route-generator.js";
|
|
13
|
+
import parseExports from "../core/parse-exports.js";
|
|
14
|
+
import { useClientRegex, useServerRegex } from "../constants.js";
|
|
15
|
+
import {
|
|
19
16
|
isSupportedClientModule,
|
|
20
17
|
scanProjectDependenciesForClientComponents,
|
|
21
|
-
}
|
|
18
|
+
} from "../core/scan-dependency-components.js";
|
|
19
|
+
import { getDinouConfig } from "../core/load-dinou-config.js";
|
|
20
|
+
import { resolveSetupFiles } from "../core/resolve-setup-files.js";
|
|
21
|
+
|
|
22
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
22
23
|
|
|
23
24
|
const projectRoot = process.cwd();
|
|
24
25
|
const cloudflareDir = path.resolve(projectRoot, ".dinou/cloudflare");
|
|
25
26
|
fs.mkdirSync(cloudflareDir, { recursive: true });
|
|
26
27
|
|
|
28
|
+
const dinouConfig = await getDinouConfig(projectRoot);
|
|
29
|
+
const setupFiles = resolveSetupFiles(projectRoot, dinouConfig);
|
|
30
|
+
if (setupFiles.length > 0) {
|
|
31
|
+
console.log(` 🔌 [Dinou Setup] Active setup files (${setupFiles.length}): ${setupFiles.map((f) => path.basename(f)).join(", ")}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
try {
|
|
28
35
|
generateRouteTypes(projectRoot);
|
|
29
36
|
} catch (e) {}
|
|
@@ -688,6 +695,8 @@ fs.writeFileSync(ssrClientManifestPath, ssrManifestCode, "utf8");
|
|
|
688
695
|
const rscEntryContent = `// Auto-generated RSC Engine entry for Cloudflare Workers
|
|
689
696
|
import "./env-setup.js";
|
|
690
697
|
import "./route-modules.js";
|
|
698
|
+
import * as edgeRenderer from "react-server-dom-webpack/server.edge";
|
|
699
|
+
globalThis.__DINOU_EDGE_RENDERER__ = edgeRenderer;
|
|
691
700
|
export { handleRequest } from "${dinouDirSlash}/core/handler.js";
|
|
692
701
|
`;
|
|
693
702
|
const rscEntryPath = path.join(cloudflareDir, "rsc-entry.js");
|
|
@@ -1057,10 +1066,12 @@ try {
|
|
|
1057
1066
|
alias: commonAlias,
|
|
1058
1067
|
loader: commonLoader,
|
|
1059
1068
|
jsx: "automatic",
|
|
1069
|
+
inject: setupFiles.length > 0 ? setupFiles : undefined,
|
|
1060
1070
|
define: {
|
|
1061
1071
|
"process.env.NODE_ENV": '"production"',
|
|
1062
1072
|
"process.env.DINOU_RUNTIME": '"edge"',
|
|
1063
1073
|
"process.env.DINOU_BUILD_TOOL": JSON.stringify(isWebpackBuild ? "webpack" : (process.env.DINOU_BUILD_TOOL || "esbuild")),
|
|
1074
|
+
"import.meta.url": '"file:///worker.js"',
|
|
1064
1075
|
},
|
|
1065
1076
|
logLevel: "warning",
|
|
1066
1077
|
});
|
|
@@ -1080,10 +1091,12 @@ try {
|
|
|
1080
1091
|
alias: commonAlias,
|
|
1081
1092
|
loader: commonLoader,
|
|
1082
1093
|
jsx: "automatic",
|
|
1094
|
+
inject: setupFiles.length > 0 ? setupFiles : undefined,
|
|
1083
1095
|
define: {
|
|
1084
1096
|
"process.env.NODE_ENV": '"production"',
|
|
1085
1097
|
"process.env.DINOU_RUNTIME": '"edge"',
|
|
1086
1098
|
"process.env.DINOU_BUILD_TOOL": JSON.stringify(isWebpackBuild ? "webpack" : (process.env.DINOU_BUILD_TOOL || "esbuild")),
|
|
1099
|
+
"import.meta.url": '"file:///worker.js"',
|
|
1087
1100
|
},
|
|
1088
1101
|
logLevel: "warning",
|
|
1089
1102
|
});
|
|
@@ -1101,12 +1114,14 @@ try {
|
|
|
1101
1114
|
conditions: ["workerd", "worker", "browser"],
|
|
1102
1115
|
external: externalList,
|
|
1103
1116
|
banner,
|
|
1117
|
+
inject: setupFiles.length > 0 ? setupFiles : undefined,
|
|
1104
1118
|
alias: commonAlias,
|
|
1105
1119
|
loader: commonLoader,
|
|
1106
1120
|
define: {
|
|
1107
1121
|
"process.env.NODE_ENV": '"production"',
|
|
1108
1122
|
"process.env.DINOU_RUNTIME": '"edge"',
|
|
1109
1123
|
"process.env.DINOU_BUILD_TOOL": JSON.stringify(isWebpackBuild ? "webpack" : (process.env.DINOU_BUILD_TOOL || "esbuild")),
|
|
1124
|
+
"import.meta.url": '"file:///worker.js"',
|
|
1110
1125
|
},
|
|
1111
1126
|
logLevel: "warning",
|
|
1112
1127
|
});
|
|
@@ -77,6 +77,7 @@ export const statSync = (p) => {
|
|
|
77
77
|
export const mkdirSync = () => {};
|
|
78
78
|
export const writeFileSync = () => {};
|
|
79
79
|
export const rmSync = () => {};
|
|
80
|
+
export const copyFileSync = () => {};
|
|
80
81
|
|
|
81
82
|
export const promises = {
|
|
82
83
|
readFile: async (p) => readFileSync(p),
|
|
@@ -85,6 +86,7 @@ export const promises = {
|
|
|
85
86
|
stat: async (p) => statSync(p),
|
|
86
87
|
mkdir: async () => {},
|
|
87
88
|
rm: async () => {},
|
|
89
|
+
copyFile: async () => {},
|
|
88
90
|
};
|
|
89
91
|
|
|
90
92
|
export default {
|
|
@@ -95,5 +97,6 @@ export default {
|
|
|
95
97
|
mkdirSync,
|
|
96
98
|
writeFileSync,
|
|
97
99
|
rmSync,
|
|
100
|
+
copyFileSync,
|
|
98
101
|
promises,
|
|
99
102
|
};
|
package/dinou/constants.js
CHANGED
|
@@ -11,7 +11,7 @@ function hasDirective(code, directive) {
|
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const useClientRegex = {
|
|
14
|
+
export const useClientRegex = {
|
|
15
15
|
test(code) {
|
|
16
16
|
return hasDirective(code, "use client");
|
|
17
17
|
},
|
|
@@ -20,7 +20,7 @@ const useClientRegex = {
|
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const useServerRegex = {
|
|
23
|
+
export const useServerRegex = {
|
|
24
24
|
test(code) {
|
|
25
25
|
return hasDirective(code, "use server");
|
|
26
26
|
},
|
|
@@ -29,4 +29,4 @@ const useServerRegex = {
|
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
export default { useClientRegex, useServerRegex };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const extensions = [
|
|
1
|
+
export const extensions = [
|
|
2
2
|
"png",
|
|
3
3
|
"jpg",
|
|
4
4
|
"jpeg",
|
|
@@ -22,12 +22,12 @@ const extensions = [
|
|
|
22
22
|
"mjpg",
|
|
23
23
|
];
|
|
24
24
|
|
|
25
|
-
const globPattern = `**/*.{${extensions.join(",")}}`;
|
|
25
|
+
export const globPattern = `**/*.{${extensions.join(",")}}`;
|
|
26
26
|
|
|
27
27
|
// 🔹 regex useful for Rollup/PostCSS type plugins
|
|
28
|
-
const regex = new RegExp(`\\.(${extensions.join("|")})$`, "i");
|
|
28
|
+
export const regex = new RegExp(`\\.(${extensions.join("|")})$`, "i");
|
|
29
29
|
|
|
30
30
|
// 🔹 version with dot for direct comparisons
|
|
31
|
-
const extensionsWithDot = extensions.map((ext) => `.${ext}`);
|
|
31
|
+
export const extensionsWithDot = extensions.map((ext) => `.${ext}`);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
export default { extensions, extensionsWithDot, regex, globPattern };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { isPprBuildActive, isInsideSuspense, markDynamicAccess } from "./ppr-context.js";
|
|
2
2
|
|
|
3
3
|
function triggerBailout(label, onBailout) {
|
|
4
4
|
if (isPprBuildActive() && isInsideSuspense()) {
|
|
@@ -17,7 +17,7 @@ function triggerBailout(label, onBailout) {
|
|
|
17
17
|
* @param {Function} onBailout - Callback invoked when property access occurs
|
|
18
18
|
* @returns {Proxy}
|
|
19
19
|
*/
|
|
20
|
-
function createBailoutProxy(target, label = "Context", onBailout) {
|
|
20
|
+
export function createBailoutProxy(target, label = "Context", onBailout) {
|
|
21
21
|
const safeTarget = target || {};
|
|
22
22
|
|
|
23
23
|
return new Proxy(safeTarget, {
|
|
@@ -56,6 +56,6 @@ function createBailoutProxy(target, label = "Context", onBailout) {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
export default {
|
|
60
60
|
createBailoutProxy,
|
|
61
61
|
};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const { getDinouConfig } = require("./load-dinou-config");
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { existsSync, readdirSync, mkdirSync, rmSync } from "node:fs";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { asyncRenderJSXToClientJSX } from "./render-jsx-to-client-jsx.js";
|
|
5
|
+
import { getFilePathAndDynamicParams } from "./get-file-path-and-dynamic-params.js";
|
|
6
|
+
import importModule from "./import-module.js";
|
|
7
|
+
import { requestStorage } from "./request-context.js";
|
|
8
|
+
import { getLayoutProps, resolveLayoutFunctionsConfig, getLayoutFunctionsPath } from "./layout-functions.js";
|
|
9
|
+
import { runWithPprContext, getRegisteredHoles } from "./ppr-context.js";
|
|
10
|
+
import { resolveModulePpr } from "./resolve-module-ppr.js";
|
|
11
|
+
import { getDinouConfig } from "./load-dinou-config.js";
|
|
12
|
+
import { createBailoutProxy } from "./bailout-proxy.js";
|
|
14
13
|
|
|
15
14
|
async function resolveBuildPprForRoute(segments, pagePath, pageFunctionsPath, srcFolder) {
|
|
16
15
|
const globalCfg = await getDinouConfig();
|
|
@@ -76,7 +75,6 @@ async function isDynamicRoute(revalidate) {
|
|
|
76
75
|
return typeof val === "number" && val < 1;
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
const { createBailoutProxy } = require("./bailout-proxy.js");
|
|
80
78
|
|
|
81
79
|
/**
|
|
82
80
|
* Compiles all static pages in the application.
|
|
@@ -108,7 +106,6 @@ async function buildStaticPages(onProgress = null) {
|
|
|
108
106
|
const candidateLayout = path.join(currentPath, `layout${ext}`);
|
|
109
107
|
if (existsSync(candidateLayout)) {
|
|
110
108
|
const routePath = segments.length ? "/" + segments.join("/") : "/";
|
|
111
|
-
const { resolveLayoutFunctionsConfig } = require("./layout-functions");
|
|
112
109
|
const layoutConfig = await resolveLayoutFunctionsConfig(candidateLayout, params);
|
|
113
110
|
if (!layoutConfig.isDynamic) {
|
|
114
111
|
staticLayouts.set(routePath, {
|
|
@@ -552,7 +549,6 @@ async function buildStaticPages(onProgress = null) {
|
|
|
552
549
|
getStaticPaths = module.getStaticPaths || defMod?.getStaticPaths;
|
|
553
550
|
revalidate = module.revalidate || defMod?.revalidate;
|
|
554
551
|
}
|
|
555
|
-
const { getLayoutFunctionsPath } = require("./layout-functions");
|
|
556
552
|
const lfPath = getLayoutFunctionsPath(dynamicPath);
|
|
557
553
|
if (lfPath) {
|
|
558
554
|
const lmod = await importModule(lfPath);
|
|
@@ -1507,7 +1503,15 @@ function getStaticLayouts() {
|
|
|
1507
1503
|
return Array.from(staticLayouts.values());
|
|
1508
1504
|
}
|
|
1509
1505
|
|
|
1510
|
-
|
|
1506
|
+
export {
|
|
1507
|
+
buildStaticPages,
|
|
1508
|
+
buildStaticPage,
|
|
1509
|
+
getStaticPaths,
|
|
1510
|
+
getStaticMetadata,
|
|
1511
|
+
getStaticLayouts,
|
|
1512
|
+
isDynamicRoute,
|
|
1513
|
+
};
|
|
1514
|
+
export default {
|
|
1511
1515
|
buildStaticPages,
|
|
1512
1516
|
buildStaticPage,
|
|
1513
1517
|
getStaticPaths,
|
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
let _buildStaticPage = null;
|
|
10
|
-
function getBuildStaticPage() {
|
|
11
|
-
if (!_buildStaticPage) _buildStaticPage = require("./build-static-pages").buildStaticPage;
|
|
12
|
-
return _buildStaticPage;
|
|
13
|
-
}
|
|
14
|
-
let _generateStaticRSC = null;
|
|
15
|
-
function getGenerateStaticRSC() {
|
|
16
|
-
if (!_generateStaticRSC) _generateStaticRSC = require("./generate-static-rsc");
|
|
17
|
-
return _generateStaticRSC;
|
|
18
|
-
}
|
|
19
|
-
let _safeRename = null;
|
|
20
|
-
function getSafeRename() {
|
|
21
|
-
if (!_safeRename) _safeRename = require("./safe-rename").safeRename;
|
|
22
|
-
return _safeRename;
|
|
23
|
-
}
|
|
24
|
-
let _updateStatus = null;
|
|
25
|
-
function getUpdateStatus() {
|
|
26
|
-
if (!_updateStatus) _updateStatus = require("./status-manifest").updateStatus;
|
|
27
|
-
return _updateStatus;
|
|
28
|
-
}
|
|
29
|
-
const { getContext } = require("./request-context");
|
|
30
|
-
const { resolveRelativeUrl } = require("./url-resolver");
|
|
31
|
-
const { getStorageAdapter } = require("./storage-adapter");
|
|
32
|
-
const { isEdgeRuntime } = require("./rsc-renderer");
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import { existsSync, copyFileSync } from "node:fs";
|
|
4
|
+
import { getContext } from "./request-context.js";
|
|
5
|
+
import { resolveRelativeUrl } from "./url-resolver.js";
|
|
6
|
+
import { getStorageAdapter } from "./storage-adapter.js";
|
|
7
|
+
import { isEdgeRuntime } from "./rsc-renderer.js";
|
|
33
8
|
|
|
34
9
|
async function walkMetadataFiles(dir, fileList = []) {
|
|
35
10
|
try {
|
|
@@ -463,7 +438,13 @@ async function revalidateTag(tag, options = {}) {
|
|
|
463
438
|
await Promise.all(revalidatePromises);
|
|
464
439
|
}
|
|
465
440
|
|
|
466
|
-
|
|
441
|
+
export {
|
|
442
|
+
revalidatePath,
|
|
443
|
+
revalidatePage,
|
|
444
|
+
revalidateTag,
|
|
445
|
+
revalidateLayout,
|
|
446
|
+
};
|
|
447
|
+
export default {
|
|
467
448
|
revalidatePath,
|
|
468
449
|
revalidatePage,
|
|
469
450
|
revalidateTag,
|
package/dinou/core/cache-slot.js
CHANGED
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
// Primitive for Vertical Segmentation (Micro-ISR) in React Server Components.
|
|
3
3
|
// Caches and invalidates component sub-trees inside pages using revalidate & revalidateTag.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { getStorageAdapter } from "./storage-adapter.js";
|
|
9
|
+
import { asyncRenderJSXToClientJSX } from "./render-jsx-to-client-jsx.js";
|
|
10
|
+
import { DinouCacheSlotBoundary as RawDinouCacheSlotBoundary } from "./slot.js";
|
|
11
|
+
import { getContext } from "./request-context.js";
|
|
12
|
+
import { getJSX } from "./get-jsx.js";
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
10
17
|
|
|
11
18
|
const INFLIGHT_KEY = Symbol.for("dinou.slot.inflight.renders");
|
|
12
19
|
if (!globalThis[INFLIGHT_KEY]) {
|
|
@@ -29,12 +36,12 @@ const slotRegistry = globalThis[SLOT_REGISTRY_KEY];
|
|
|
29
36
|
let _DinouCacheSlotBoundary = null;
|
|
30
37
|
function getCacheSlotBoundary() {
|
|
31
38
|
if (!_DinouCacheSlotBoundary) {
|
|
32
|
-
let
|
|
39
|
+
let DinouCacheSlotBoundary = RawDinouCacheSlotBoundary;
|
|
33
40
|
if (
|
|
34
41
|
typeof DinouCacheSlotBoundary === "function" &&
|
|
35
42
|
DinouCacheSlotBoundary.$$typeof !== Symbol.for("react.client.reference")
|
|
36
43
|
) {
|
|
37
|
-
const slotPath = path.resolve(
|
|
44
|
+
const slotPath = path.resolve(currentDir, "slot.js");
|
|
38
45
|
const fileUrl = pathToFileURL(slotPath).href;
|
|
39
46
|
let regFn = null;
|
|
40
47
|
try {
|
|
@@ -255,7 +262,6 @@ async function DinouCacheSlot(props) {
|
|
|
255
262
|
})();
|
|
256
263
|
|
|
257
264
|
try {
|
|
258
|
-
const { getContext } = require("./request-context.js");
|
|
259
265
|
const reqContext = getContext();
|
|
260
266
|
const ctx = reqContext?.ctx || reqContext?.platformContext?.ctx || reqContext?.req?.ctx;
|
|
261
267
|
if (ctx && typeof ctx.waitUntil === "function") {
|
|
@@ -342,7 +348,6 @@ async function getSlotJSX(slotId, options = {}) {
|
|
|
342
348
|
// 2. If missing from storage (e.g. was invalidated) or expired or forced fresh:
|
|
343
349
|
if (!slotRegistry.has(slotId) && options.currentPath) {
|
|
344
350
|
try {
|
|
345
|
-
const { getJSX } = require("./get-jsx.js");
|
|
346
351
|
const isNotFound = { value: false };
|
|
347
352
|
await getJSX(options.currentPath, {}, isNotFound, false, false, { segment: "page" });
|
|
348
353
|
} catch (e) {
|
|
@@ -379,7 +384,13 @@ async function getSlotJSX(slotId, options = {}) {
|
|
|
379
384
|
return null;
|
|
380
385
|
}
|
|
381
386
|
|
|
382
|
-
|
|
387
|
+
export {
|
|
388
|
+
DinouCacheSlot,
|
|
389
|
+
getSlotJSX,
|
|
390
|
+
serializeJSX,
|
|
391
|
+
deserializeJSX,
|
|
392
|
+
};
|
|
393
|
+
export default {
|
|
383
394
|
DinouCacheSlot,
|
|
384
395
|
getSlotJSX,
|
|
385
396
|
serializeJSX,
|
package/dinou/core/config.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// dinou/core/config.js
|
|
2
2
|
// Type helper for defining Dinou configuration and plugins
|
|
3
3
|
|
|
4
|
-
function defineConfig(config) {
|
|
4
|
+
export function defineConfig(config) {
|
|
5
5
|
return config;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
defineConfig,
|
|
10
|
-
};
|
|
11
|
-
module.exports.default = defineConfig;
|
|
8
|
+
export default defineConfig;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import genericNames from "generic-names";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
const generate = genericNames("[hash:base64]", {
|
|
5
5
|
context: path.resolve(process.cwd(), "src"),
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export default generate;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
export function getDinouCoreDir() {
|
|
5
10
|
// Edge runtime guard: en Cloudflare Workers / Deno Edge no hay sistema de archivos dinámico
|
|
6
11
|
if (typeof process !== "undefined" && process.env && process.env.DINOU_RUNTIME === "edge") {
|
|
7
12
|
return "/dinou/core";
|
|
@@ -15,13 +20,11 @@ function getDinouCoreDir() {
|
|
|
15
20
|
} catch (e) {}
|
|
16
21
|
|
|
17
22
|
// 2. Modo librería sin empaquetar: dinou-paths.js ya está en dinou/core
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} catch (e) {}
|
|
24
|
-
}
|
|
23
|
+
try {
|
|
24
|
+
if (fs.existsSync && fs.existsSync(path.join(currentDir, "handler.js"))) {
|
|
25
|
+
return currentDir;
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {}
|
|
25
28
|
|
|
26
29
|
// 3. Resolución estándar de Node
|
|
27
30
|
try {
|
|
@@ -44,9 +47,9 @@ function getDinouCoreDir() {
|
|
|
44
47
|
return "/dinou/core";
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
const dinouCoreDir = getDinouCoreDir();
|
|
50
|
+
export const dinouCoreDir = getDinouCoreDir();
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
export default {
|
|
50
53
|
dinouCoreDir,
|
|
51
54
|
getDinouCoreDir,
|
|
52
55
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// dinou/core/generate-route-types.js
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
const PAGE_EXTENSIONS = [".tsx", ".jsx", ".ts", ".js"];
|
|
6
6
|
|
|
@@ -245,7 +245,12 @@ ${paramsEntries}
|
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
export {
|
|
249
|
+
collectRoutes,
|
|
250
|
+
generateRouteDefinitions,
|
|
251
|
+
generateRouteTypes,
|
|
252
|
+
};
|
|
253
|
+
export default {
|
|
249
254
|
collectRoutes,
|
|
250
255
|
generateRouteDefinitions,
|
|
251
256
|
generateRouteTypes,
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Generates static HTML for a given path using the in-memory Dual-Bundle streaming engine.
|
|
3
3
|
// Completely eliminates child_process.fork() and render-app-to-html.js.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import fs from "node:fs/promises";
|
|
7
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
8
|
+
import { pathToFileURL } from "node:url";
|
|
9
9
|
|
|
10
10
|
const OUT_DIR = path.resolve(".dinou/dist2");
|
|
11
11
|
|
|
@@ -78,4 +78,5 @@ async function generateStaticPage(reqPath) {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
export { generateStaticPage };
|
|
82
|
+
export default generateStaticPage;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { PassThrough } from "node:stream";
|
|
4
|
+
import url from "node:url";
|
|
5
|
+
import getJSX from "./get-jsx.js";
|
|
6
|
+
import { requestStorage } from "./request-context.js";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
6
10
|
let _renderToPipeableStream = null;
|
|
7
11
|
function getRenderToPipeableStream() {
|
|
8
12
|
if (!_renderToPipeableStream) {
|
|
@@ -14,7 +18,6 @@ function getRenderToPipeableStream() {
|
|
|
14
18
|
}
|
|
15
19
|
return _renderToPipeableStream;
|
|
16
20
|
}
|
|
17
|
-
const { requestStorage } = require("./request-context.js");
|
|
18
21
|
|
|
19
22
|
const OUT_DIR = path.resolve(".dinou/dist2");
|
|
20
23
|
const isWebpack = process.env.DINOU_BUILD_TOOL === "webpack";
|
|
@@ -159,7 +162,9 @@ async function generateStaticLayoutRSC(layoutFolderPath, layoutFilePath, options
|
|
|
159
162
|
});
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
export {
|
|
166
|
+
generateStaticRSC,
|
|
167
|
+
generateStaticPageRSC,
|
|
168
|
+
generateStaticLayoutRSC,
|
|
169
|
+
};
|
|
170
|
+
export default generateStaticRSC;
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// Unified Static Site Generation runner using the in-memory Dual-Bundle Engine.
|
|
3
3
|
// Guarantees 100% parity with runtime Incremental Static Generation (ISG).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { existsSync, rmSync, mkdirSync, renameSync } from "node:fs";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { setStorageAdapter, FileSystemStorage } from "./storage-adapter.js";
|
|
9
|
+
import {
|
|
10
10
|
generateStaticPageRSC,
|
|
11
11
|
generateStaticLayoutRSC,
|
|
12
|
-
}
|
|
12
|
+
} from "./generate-static-rsc.js";
|
|
13
|
+
import { resolveLayoutFunctionsConfig } from "./layout-functions.js";
|
|
13
14
|
|
|
14
15
|
async function generateStatic() {
|
|
15
16
|
const distFolder2 = path.resolve(process.cwd(), ".dinou/dist2");
|
|
@@ -19,12 +20,12 @@ async function generateStatic() {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const { updateBuildProgress, clearBuildProgress, isTTY } = await import(
|
|
22
|
-
"../node/terminal-status.
|
|
23
|
+
"../node/terminal-status.js"
|
|
23
24
|
);
|
|
24
25
|
|
|
25
26
|
// 1. Compile or ensure Dual-Bundle engines (Pass A & Pass B)
|
|
26
27
|
updateBuildProgress("[SSG] Compiling Dual-Engine for static generation...");
|
|
27
|
-
const { bundleDualEngine } = await import("../node/bundle-dual-engine.
|
|
28
|
+
const { bundleDualEngine } = await import("../node/bundle-dual-engine.js");
|
|
28
29
|
const { rscEnginePath, ssrEnginePath } = await bundleDualEngine({
|
|
29
30
|
isDev: false,
|
|
30
31
|
projectRoot: process.cwd(),
|
|
@@ -84,7 +85,6 @@ async function generateStatic() {
|
|
|
84
85
|
tags: [],
|
|
85
86
|
};
|
|
86
87
|
try {
|
|
87
|
-
const { resolveLayoutFunctionsConfig } = require("./layout-functions.js");
|
|
88
88
|
const layoutConfig = await resolveLayoutFunctionsConfig(
|
|
89
89
|
layoutInfo.layoutPath,
|
|
90
90
|
layoutInfo.params || {}
|
|
@@ -221,4 +221,5 @@ async function generateStatic() {
|
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
export { generateStatic };
|
|
225
|
+
export default generateStatic;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { regenerating } = require("./revalidating"); // We share the Set of locks
|
|
8
|
-
const { safeRename } = require("./safe-rename");
|
|
9
|
-
const { updateStatus } = require("./status-manifest");
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { existsSync, copyFileSync } from "node:fs";
|
|
4
|
+
import { regenerating } from "./revalidating.js";
|
|
5
|
+
import { safeRename } from "./safe-rename.js";
|
|
6
|
+
import { updateStatus } from "./status-manifest.js";
|
|
10
7
|
|
|
11
|
-
function generatingISG(reqPath, isDynamicFromServer) {
|
|
8
|
+
export function generatingISG(reqPath, isDynamicFromServer) {
|
|
12
9
|
const dist2Folder = path.resolve(process.cwd(), ".dinou/dist2");
|
|
13
10
|
// 1. Concurrency Protection
|
|
14
11
|
if (regenerating.has(reqPath)) return;
|
|
@@ -36,6 +33,10 @@ function generatingISG(reqPath, isDynamicFromServer) {
|
|
|
36
33
|
(async () => {
|
|
37
34
|
try {
|
|
38
35
|
console.log(`[ISG] Promoting new page to static: ${reqPath}...`);
|
|
36
|
+
const { buildStaticPage } = await import("./build-static-pages.js");
|
|
37
|
+
const { default: generateStaticRSC } = await import("./generate-static-rsc.js");
|
|
38
|
+
const { default: generateStaticPage } = await import("./generate-static-page.js");
|
|
39
|
+
|
|
39
40
|
const isDynamic = {};
|
|
40
41
|
// A. Build Data (with dynamic check)
|
|
41
42
|
await buildStaticPage(reqPath, isDynamic);
|
|
@@ -76,4 +77,4 @@ function generatingISG(reqPath, isDynamicFromServer) {
|
|
|
76
77
|
})();
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
export default { generatingISG };
|