dinou 7.3.0 → 8.0.1
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 +27 -0
- package/README.md +1 -1
- package/cli.js +42 -39
- package/dinou/adapters/netlify.js +1 -0
- package/dinou/adapters/{node.mjs → node.js} +9 -3
- package/dinou/bun/{build.mjs → build.js} +12 -11
- package/dinou/cloudflare/{build.mjs → build.js} +15 -11
- 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/{export-static.mjs → export-static.js} +1 -1
- 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 -69
- 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} +12 -11
- 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.js +40 -19
- package/dinou/node/{build.mjs → build.js} +4 -4
- package/dinou/node/{bundle-dual-engine.mjs → bundle-dual-engine.js} +13 -12
- package/dinou/node/{dev.mjs → dev.js} +27 -22
- package/dinou/node/{terminal-status.mjs → terminal-status.js} +1 -1
- 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 +54 -47
- package/package.json +9 -8
- 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/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/core/handler.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// Universal Web Standards Request Handler for Dinou.
|
|
3
3
|
// Implements (Request) => Promise<Response> independently of Express.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { readFileSync, existsSync, readdirSync } from "node:fs";
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
+
import { PassThrough, Readable } from "node:stream";
|
|
9
|
+
|
|
9
10
|
const FormData = globalThis.FormData;
|
|
10
11
|
const Blob = globalThis.Blob;
|
|
11
12
|
|
|
@@ -16,30 +17,33 @@ const isDevelopment =
|
|
|
16
17
|
process.env.NODE_ENV !== "production";
|
|
17
18
|
const outputFolder = isDevelopment ? ".dinou/public" : ".dinou/dist3";
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
import { normalizePathCase } from "./path-utils.js";
|
|
21
|
+
import { resolveRelativeUrl } from "./url-resolver.js";
|
|
22
|
+
import { getFilePathAndDynamicParams } from "./get-file-path-and-dynamic-params.js";
|
|
23
|
+
import getJSX from "./get-jsx.js";
|
|
24
|
+
import { getErrorJSX } from "./get-error-jsx.js";
|
|
25
|
+
import importModule from "./import-module.js";
|
|
26
|
+
import { resolveLayoutFunctionsConfig } from "./layout-functions.js";
|
|
27
|
+
import { revalidating, regenerating, inFlightGenerations } from "./revalidating.js";
|
|
28
|
+
import { generatingISG } from "./generating-isg.js";
|
|
29
|
+
import { requestStorage, setCurrentContext } from "./request-context.js";
|
|
30
|
+
import { getStatus } from "./status-manifest.js";
|
|
31
|
+
|
|
32
|
+
import {
|
|
32
33
|
isManifestReady,
|
|
33
34
|
getClientManifest,
|
|
34
35
|
getServerFunctionsManifest,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
} from "./manifest-provider.js";
|
|
37
|
+
import { pipeRSC, renderRSCStream, isEdgeRuntime } from "./rsc-renderer.js";
|
|
38
|
+
import { getStorageAdapter, setStorageAdapter } from "./storage-adapter.js";
|
|
39
|
+
import { createBailoutProxy } from "./bailout-proxy.js";
|
|
40
|
+
import getAssetFromManifest from "./get-asset-from-manifest.js";
|
|
41
|
+
import { handlePprResume } from "./ppr-runtime.js";
|
|
42
|
+
import { resolveModulePpr } from "./resolve-module-ppr.js";
|
|
43
|
+
import { getDinouConfig as loadDinouConfig } from "./load-dinou-config.js";
|
|
44
|
+
import { getSlotJSX } from "./cache-slot.js";
|
|
45
|
+
import { runWithPprContext, getRegisteredHoles } from "./ppr-context.js";
|
|
46
|
+
import { asyncRenderJSXToClientJSX } from "./render-jsx-to-client-jsx.js";
|
|
43
47
|
|
|
44
48
|
// Load Dinou configuration and plugins
|
|
45
49
|
let dinouConfig = { plugins: [] };
|
|
@@ -420,7 +424,7 @@ function getDiscoveredLayouts() {
|
|
|
420
424
|
if (!existsSync(dir)) return;
|
|
421
425
|
let entries;
|
|
422
426
|
try {
|
|
423
|
-
entries =
|
|
427
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
424
428
|
} catch {
|
|
425
429
|
return;
|
|
426
430
|
}
|
|
@@ -1138,7 +1142,6 @@ async function handleRequest(request, platformContext = {}) {
|
|
|
1138
1142
|
const urlObj = new URL(request.url || `http://localhost${pathname}`);
|
|
1139
1143
|
const isFresh = urlObj.searchParams.get("fresh") === "1" || urlObj.searchParams.has("fresh");
|
|
1140
1144
|
|
|
1141
|
-
const { getSlotJSX } = require("./cache-slot.js");
|
|
1142
1145
|
const currentPath =
|
|
1143
1146
|
request.headers?.get?.("x-dinou-current-path") ||
|
|
1144
1147
|
simReq.headers?.["x-dinou-current-path"] ||
|
|
@@ -1385,7 +1388,27 @@ async function handleRequest(request, platformContext = {}) {
|
|
|
1385
1388
|
for (const [lPath, lParams] of layouts) {
|
|
1386
1389
|
const lConfig = await resolveLayoutFunctionsConfig(lPath, lParams);
|
|
1387
1390
|
if (!isDevelopment && lConfig.allowISG === false) {
|
|
1388
|
-
|
|
1391
|
+
let isPathAllowed = false;
|
|
1392
|
+
if (lConfig.staticPathsSet) {
|
|
1393
|
+
const sortedEntries = Object.entries(lParams || {})
|
|
1394
|
+
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
1395
|
+
.map(([k, v]) => {
|
|
1396
|
+
if (Array.isArray(v)) return [k, v.join(",")];
|
|
1397
|
+
return [k, String(v)];
|
|
1398
|
+
});
|
|
1399
|
+
const serializedQuery = JSON.stringify(sortedEntries);
|
|
1400
|
+
const singleVal = Object.values(lParams || {})[0];
|
|
1401
|
+
const singleValStr = Array.isArray(singleVal) ? singleVal.join(",") : String(singleVal);
|
|
1402
|
+
isPathAllowed = lConfig.staticPathsSet.has(serializedQuery) || lConfig.staticPathsSet.has(singleValStr);
|
|
1403
|
+
}
|
|
1404
|
+
if (!isPathAllowed) {
|
|
1405
|
+
const cleanReq = reqPath.replace(/^\//, "").replace(/\/$/, "");
|
|
1406
|
+
const rscPath = path.join(process.cwd(), ".dinou/dist2", cleanReq, "layout.rsc");
|
|
1407
|
+
if (!existsSync(rscPath)) {
|
|
1408
|
+
isPathBlocked = true;
|
|
1409
|
+
break;
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1389
1412
|
}
|
|
1390
1413
|
if (lConfig.validateParams) {
|
|
1391
1414
|
const isValid = await lConfig.validateParams(lParams);
|
|
@@ -1400,7 +1423,26 @@ async function handleRequest(request, platformContext = {}) {
|
|
|
1400
1423
|
layoutConfig = await resolveLayoutFunctionsConfig(layoutPath, layoutParams);
|
|
1401
1424
|
}
|
|
1402
1425
|
if (!isDevelopment && layoutConfig.allowISG === false) {
|
|
1403
|
-
|
|
1426
|
+
let isPathAllowed = false;
|
|
1427
|
+
if (layoutConfig.staticPathsSet) {
|
|
1428
|
+
const sortedEntries = Object.entries(layoutParams || {})
|
|
1429
|
+
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
1430
|
+
.map(([k, v]) => {
|
|
1431
|
+
if (Array.isArray(v)) return [k, v.join(",")];
|
|
1432
|
+
return [k, String(v)];
|
|
1433
|
+
});
|
|
1434
|
+
const serializedQuery = JSON.stringify(sortedEntries);
|
|
1435
|
+
const singleVal = Object.values(layoutParams || {})[0];
|
|
1436
|
+
const singleValStr = Array.isArray(singleVal) ? singleVal.join(",") : String(singleVal);
|
|
1437
|
+
isPathAllowed = layoutConfig.staticPathsSet.has(serializedQuery) || layoutConfig.staticPathsSet.has(singleValStr);
|
|
1438
|
+
}
|
|
1439
|
+
if (!isPathAllowed) {
|
|
1440
|
+
const cleanReq = reqPath.replace(/^\//, "").replace(/\/$/, "");
|
|
1441
|
+
const rscPath = path.join(process.cwd(), ".dinou/dist2", cleanReq, "layout.rsc");
|
|
1442
|
+
if (!existsSync(rscPath)) {
|
|
1443
|
+
isPathBlocked = true;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1404
1446
|
}
|
|
1405
1447
|
if (layoutConfig.validateParams) {
|
|
1406
1448
|
const isValid = await layoutConfig.validateParams(layoutParams);
|
|
@@ -1804,8 +1846,6 @@ async function handleRequest(request, platformContext = {}) {
|
|
|
1804
1846
|
try {
|
|
1805
1847
|
if (!isError) {
|
|
1806
1848
|
if (platformContext?.isSSG && isPprConfig) {
|
|
1807
|
-
const { runWithPprContext, getRegisteredHoles } = require("./ppr-context.js");
|
|
1808
|
-
const { asyncRenderJSXToClientJSX } = require("./render-jsx-to-client-jsx.js");
|
|
1809
1849
|
await requestStorage.run(context, async () => {
|
|
1810
1850
|
await runWithPprContext({ isPpr: true }, async () => {
|
|
1811
1851
|
jsx = await getJSX(reqPath, queryObj, isNotFound, isDevelopment, !pagePath);
|
|
@@ -2294,10 +2334,10 @@ async function handleRequest(request, platformContext = {}) {
|
|
|
2294
2334
|
return bridge.toResponse();
|
|
2295
2335
|
}
|
|
2296
2336
|
|
|
2297
|
-
|
|
2337
|
+
export {
|
|
2298
2338
|
handleRequest,
|
|
2299
2339
|
WebResponseBridge,
|
|
2300
2340
|
resolvePageFunctionsConfig,
|
|
2301
2341
|
};
|
|
2302
|
-
|
|
2342
|
+
export default handleRequest;
|
|
2303
2343
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Bidirectional adapter between Node.js HTTP (IncomingMessage/ServerResponse)
|
|
3
3
|
// and WHATWG Web Standards (Request/Response/ReadableStream).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { Readable } from "node:stream";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Converts a Node.js IncomingMessage / Express Request into a standard Web Request.
|
|
@@ -109,7 +109,11 @@ async function sendWebResponseToNode(webResponse, res) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
export {
|
|
113
|
+
nodeToWebRequest,
|
|
114
|
+
sendWebResponseToNode,
|
|
115
|
+
};
|
|
116
|
+
export default {
|
|
113
117
|
nodeToWebRequest,
|
|
114
118
|
sendWebResponseToNode,
|
|
115
119
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
|
|
5
5
|
function getMtimeParam(absPath) {
|
|
6
6
|
try {
|
|
@@ -80,4 +80,5 @@ function registerRouteModules(modulesMap) {
|
|
|
80
80
|
|
|
81
81
|
importModule.register = registerRouteModules;
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
export { importModule, registerRouteModules };
|
|
84
|
+
export default importModule;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { existsSync } from "./vfs.js";
|
|
3
|
+
import importModule from "./import-module.js";
|
|
4
|
+
import { resolveModulePpr } from "./resolve-module-ppr.js";
|
|
5
5
|
|
|
6
|
-
const LAYOUT_FUNCTIONS_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
|
|
6
|
+
const LAYOUT_FUNCTIONS_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
7
7
|
const LAYOUT_FUNCTIONS_NAMES = ["layout_functions", "layout.functions"];
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -175,7 +175,12 @@ async function resolveLayoutFunctionsConfig(layoutPath, dParams = {}) {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
export {
|
|
179
|
+
getLayoutFunctionsPath,
|
|
180
|
+
getLayoutProps,
|
|
181
|
+
resolveLayoutFunctionsConfig,
|
|
182
|
+
};
|
|
183
|
+
export default {
|
|
179
184
|
getLayoutFunctionsPath,
|
|
180
185
|
getLayoutProps,
|
|
181
186
|
resolveLayoutFunctionsConfig,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
4
7
|
|
|
5
8
|
let dinouConfig = { plugins: [] };
|
|
6
9
|
let dinouConfigPromise = null;
|
|
@@ -87,6 +90,9 @@ if (typeof globalThis !== "undefined" && globalThis.__DINOU_CONFIG__) {
|
|
|
87
90
|
dinouConfig = globalThis.__DINOU_CONFIG__;
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
|
|
93
|
+
export {
|
|
94
|
+
getDinouConfig,
|
|
95
|
+
};
|
|
96
|
+
export default {
|
|
91
97
|
getDinouConfig,
|
|
92
98
|
};
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Universal provider for RSC Client Manifest and Server Functions Manifest.
|
|
3
3
|
// Supports in-memory injection for Edge/Cloudflare Workers and disk fallback for Node.js.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
7
8
|
|
|
8
9
|
let cachedClientManifest = null;
|
|
9
10
|
let cachedServerFunctionsManifest = null;
|
|
@@ -149,7 +150,6 @@ function createDevClientManifestProxy(target) {
|
|
|
149
150
|
// 4. Fallback for client files in src/ during hot edits
|
|
150
151
|
if (baseUri.startsWith("file:///")) {
|
|
151
152
|
try {
|
|
152
|
-
const { fileURLToPath } = require("url");
|
|
153
153
|
const localPath = fileURLToPath(baseUri);
|
|
154
154
|
if (fs.existsSync(localPath)) {
|
|
155
155
|
const isWebpack = process.env.DINOU_BUILD_TOOL === "webpack";
|
|
@@ -252,7 +252,14 @@ function setServerFunctionsManifest(manifest) {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
export {
|
|
256
|
+
isManifestReady,
|
|
257
|
+
getClientManifest,
|
|
258
|
+
setClientManifest,
|
|
259
|
+
getServerFunctionsManifest,
|
|
260
|
+
setServerFunctionsManifest,
|
|
261
|
+
};
|
|
262
|
+
export default {
|
|
256
263
|
isManifestReady,
|
|
257
264
|
getClientManifest,
|
|
258
265
|
setClientManifest,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import parser from "@babel/parser";
|
|
2
|
+
import traverseModule from "@babel/traverse";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { resolveModulePpr } from "./resolve-module-ppr.js";
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const traverse = traverseModule?.default || traverseModule;
|
|
8
|
+
|
|
1
9
|
let swc = null;
|
|
2
10
|
try {
|
|
3
11
|
swc = require("@swc/core");
|
|
4
12
|
} catch (e) {}
|
|
5
13
|
|
|
6
|
-
const parser = require("@babel/parser");
|
|
7
|
-
const traverse = require("@babel/traverse");
|
|
8
|
-
|
|
9
14
|
function parseExportsWithBabel(code) {
|
|
10
15
|
const ast = parser.parse(code, {
|
|
11
16
|
sourceType: "module",
|
|
@@ -283,11 +288,11 @@ function parsePprConfig(code) {
|
|
|
283
288
|
return parsePprConfigWithBabel(code);
|
|
284
289
|
}
|
|
285
290
|
|
|
286
|
-
const { resolveModulePpr } = require("./resolve-module-ppr");
|
|
287
|
-
|
|
288
291
|
parseExports.parsePprConfig = parsePprConfig;
|
|
289
292
|
parseExports.hasPpr = (code) => parsePprConfig(code) === true;
|
|
290
293
|
parseExports.resolveModulePpr = resolveModulePpr;
|
|
291
294
|
|
|
292
|
-
|
|
295
|
+
export { parseExports, parsePprConfig, resolveModulePpr };
|
|
296
|
+
export const hasPpr = (code) => parsePprConfig(code) === true;
|
|
297
|
+
export default parseExports;
|
|
293
298
|
|
package/dinou/core/path-utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function normalizePathCase(p) {
|
|
1
|
+
export function normalizePathCase(p) {
|
|
2
2
|
if (process.platform === "win32" && typeof p === "string" && p[1] === ":") {
|
|
3
3
|
return p.charAt(0).toLowerCase() + p.slice(1);
|
|
4
4
|
}
|
|
5
5
|
return p;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export default {
|
|
9
9
|
normalizePathCase,
|
|
10
10
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// dinou/core/ppr-context.js
|
|
2
2
|
// PPR Pre-rendering Context and Suspense Hole Tracker for Dinou v7.2.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
|
|
6
6
|
const pprStorage = new AsyncLocalStorage();
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ const pprStorage = new AsyncLocalStorage();
|
|
|
11
11
|
* @param {Function} callback
|
|
12
12
|
* @returns {Promise<any>}
|
|
13
13
|
*/
|
|
14
|
-
function runWithPprContext(options, callback) {
|
|
14
|
+
export function runWithPprContext(options, callback) {
|
|
15
15
|
const store = {
|
|
16
16
|
isPpr: Boolean(options?.isPpr),
|
|
17
17
|
suspenseDepth: 0,
|
|
@@ -23,21 +23,21 @@ function runWithPprContext(options, callback) {
|
|
|
23
23
|
return pprStorage.run(store, callback);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function getPprStore() {
|
|
26
|
+
export function getPprStore() {
|
|
27
27
|
return pprStorage.getStore() || null;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function isPprBuildActive() {
|
|
30
|
+
export function isPprBuildActive() {
|
|
31
31
|
const store = getPprStore();
|
|
32
32
|
return Boolean(store && store.isPpr);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function isInsideSuspense() {
|
|
35
|
+
export function isInsideSuspense() {
|
|
36
36
|
const store = getPprStore();
|
|
37
37
|
return Boolean(store && store.suspenseDepth > 0);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function enterSuspense(holeId = null) {
|
|
40
|
+
export function enterSuspense(holeId = null) {
|
|
41
41
|
const store = getPprStore();
|
|
42
42
|
if (store) {
|
|
43
43
|
store.suspenseDepth++;
|
|
@@ -51,7 +51,7 @@ function enterSuspense(holeId = null) {
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
function exitSuspense() {
|
|
54
|
+
export function exitSuspense() {
|
|
55
55
|
const store = getPprStore();
|
|
56
56
|
if (store) {
|
|
57
57
|
store.suspenseDepth = Math.max(0, store.suspenseDepth - 1);
|
|
@@ -61,7 +61,7 @@ function exitSuspense() {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
function markDynamicAccess(type = "dynamic") {
|
|
64
|
+
export function markDynamicAccess(type = "dynamic") {
|
|
65
65
|
const store = getPprStore();
|
|
66
66
|
if (store && store.isPpr && store.suspenseDepth > 0) {
|
|
67
67
|
const holeId = store.currentHoleId || `ppr-hole-${store.nextHoleIndex}`;
|
|
@@ -73,7 +73,7 @@ function markDynamicAccess(type = "dynamic") {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
function registerHole(holeId, meta = {}) {
|
|
76
|
+
export function registerHole(holeId, meta = {}) {
|
|
77
77
|
const store = getPprStore();
|
|
78
78
|
if (store) {
|
|
79
79
|
store.holes.set(holeId, {
|
|
@@ -84,7 +84,7 @@ function registerHole(holeId, meta = {}) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
function getRegisteredHoles() {
|
|
87
|
+
export function getRegisteredHoles() {
|
|
88
88
|
const store = getPprStore();
|
|
89
89
|
if (store) {
|
|
90
90
|
return Array.from(store.holes.keys());
|
|
@@ -92,7 +92,7 @@ function getRegisteredHoles() {
|
|
|
92
92
|
return [];
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
export default {
|
|
96
96
|
runWithPprContext,
|
|
97
97
|
getPprStore,
|
|
98
98
|
isPprBuildActive,
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
// streams dynamic Suspense holes as they resolve over the same HTTP connection.
|
|
5
5
|
// Designed for the Dual-Bundle architecture (Pass A: RSC, Pass B: SSR).
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { renderRSCStream } from "./rsc-renderer.js";
|
|
9
|
+
import { getClientManifest } from "./manifest-provider.js";
|
|
10
|
+
import { requestStorage, setCurrentContext } from "./request-context.js";
|
|
11
|
+
import getJSX from "./get-jsx.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Traverses a React JSX element tree to find Suspense boundaries,
|
|
@@ -257,7 +257,11 @@ async function handlePprResume({
|
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
export {
|
|
261
|
+
streamDynamicHoles,
|
|
262
|
+
handlePprResume,
|
|
263
|
+
};
|
|
264
|
+
export default {
|
|
261
265
|
streamDynamicHoles,
|
|
262
266
|
handlePprResume,
|
|
263
267
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
isPprBuildActive,
|
|
3
3
|
enterSuspense,
|
|
4
4
|
exitSuspense,
|
|
5
5
|
registerHole,
|
|
6
|
-
}
|
|
6
|
+
} from "./ppr-context.js";
|
|
7
7
|
|
|
8
8
|
// Function to check if a component is a client component
|
|
9
9
|
function isClientComponent(type) {
|
|
@@ -176,6 +176,9 @@ async function asyncRenderJSXToClientJSX(jsx, key = null) {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
export {
|
|
180
|
+
asyncRenderJSXToClientJSX,
|
|
181
|
+
};
|
|
182
|
+
export default {
|
|
180
183
|
asyncRenderJSXToClientJSX,
|
|
181
184
|
};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
// dinou/core/request-context.js
|
|
2
|
-
|
|
3
2
|
const DINOU_CONTEXT_KEY = Symbol.for("dinou.request.context.storage");
|
|
4
3
|
let requestStorage;
|
|
5
4
|
|
|
6
5
|
if (typeof window === "undefined") {
|
|
7
|
-
let AsyncLocalStorageClass
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
6
|
+
let AsyncLocalStorageClass =
|
|
7
|
+
typeof globalThis.AsyncLocalStorage !== "undefined"
|
|
8
|
+
? globalThis.AsyncLocalStorage
|
|
9
|
+
: undefined;
|
|
12
10
|
|
|
13
11
|
if (!AsyncLocalStorageClass) {
|
|
14
12
|
try {
|
|
@@ -69,7 +67,13 @@ function getContext() {
|
|
|
69
67
|
return store || getCurrentContext() || {};
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
|
|
70
|
+
export {
|
|
71
|
+
requestStorage,
|
|
72
|
+
getContext,
|
|
73
|
+
setCurrentContext,
|
|
74
|
+
getCurrentContext,
|
|
75
|
+
};
|
|
76
|
+
export default {
|
|
73
77
|
requestStorage,
|
|
74
78
|
getContext,
|
|
75
79
|
setCurrentContext,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Supports constants (export const ppr = true/false), sync functions (export function ppr()),
|
|
4
4
|
// and async functions (export async function ppr()).
|
|
5
5
|
|
|
6
|
-
async function resolveModulePpr(mod) {
|
|
6
|
+
export async function resolveModulePpr(mod) {
|
|
7
7
|
if (!mod) return null;
|
|
8
8
|
const raw =
|
|
9
9
|
mod.ppr !== undefined
|
|
@@ -29,6 +29,6 @@ async function resolveModulePpr(mod) {
|
|
|
29
29
|
return Boolean(raw);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
export default {
|
|
33
33
|
resolveModulePpr,
|
|
34
34
|
};
|