dinou 6.1.1 → 7.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 +94 -0
- package/README.md +9461 -1080
- package/cli.js +392 -169
- package/dinou/adapters/bun.js +62 -0
- package/dinou/adapters/cloudflare.js +65 -0
- package/dinou/adapters/deno.js +48 -0
- package/dinou/adapters/netlify.js +85 -0
- package/dinou/adapters/node.mjs +31 -0
- package/dinou/bun/build.mjs +1077 -0
- package/dinou/cloudflare/build.mjs +1121 -0
- package/dinou/cloudflare/shims/child_process.js +14 -0
- package/dinou/cloudflare/shims/empty.js +2 -0
- package/dinou/cloudflare/shims/fs.js +99 -0
- package/dinou/cloudflare/shims/os.js +29 -0
- package/dinou/config.js +1 -0
- package/dinou/config.mjs +2 -0
- package/dinou/constants.js +29 -4
- package/dinou/core/babel-esm-loader.js +66 -37
- package/dinou/core/bailout-proxy.js +61 -0
- package/dinou/core/build-static-pages.js +309 -157
- package/dinou/core/cache-revalidate.js +471 -144
- package/dinou/core/cache-slot.js +387 -0
- package/dinou/core/client-redirect.jsx +12 -7
- package/dinou/core/client-webpack.jsx +457 -82
- package/dinou/core/client.jsx +452 -82
- package/dinou/core/config.js +11 -0
- package/dinou/core/dinou-paths.js +52 -0
- package/dinou/core/edge-ssr.js +122 -0
- package/dinou/core/export-static.mjs +64 -0
- package/dinou/core/generate-route-types.js +252 -0
- package/dinou/core/generate-static-page.js +55 -94
- package/dinou/core/generate-static-rsc.js +47 -15
- package/dinou/core/generate-static.js +212 -10
- package/dinou/core/generating-isg.js +5 -0
- package/dinou/core/get-asset-from-manifest.js +9 -3
- package/dinou/core/get-error-jsx.js +221 -41
- package/dinou/core/get-file-path-and-dynamic-params.js +9 -13
- package/dinou/core/get-jsx.js +172 -95
- package/dinou/core/handler.js +2296 -0
- package/dinou/core/http-adapter.js +115 -0
- package/dinou/core/import-module.js +83 -53
- package/dinou/core/layout-functions.js +181 -0
- package/dinou/core/link.jsx +18 -6
- package/dinou/core/load-dinou-config.js +60 -0
- package/dinou/core/manifest-provider.js +261 -0
- package/dinou/core/navigation-utils.js +4 -0
- package/dinou/core/navigation.js +50 -39
- package/dinou/core/parse-exports.js +207 -2
- package/dinou/core/ppr-context.js +105 -0
- package/dinou/core/ppr-runtime.js +263 -0
- package/dinou/core/redirect.jsx +20 -19
- package/dinou/core/render-jsx-to-client-jsx.js +133 -15
- package/dinou/core/request-context.js +47 -13
- package/dinou/core/resolve-module-ppr.js +32 -0
- package/dinou/core/revalidating.js +28 -9
- package/dinou/core/route-generator.js +107 -0
- package/dinou/core/rsc-renderer.js +90 -0
- package/dinou/core/run-ssg.js +19 -0
- package/dinou/core/scan-dependency-components.js +218 -0
- package/dinou/core/server-function-proxy-webpack.js +3 -0
- package/dinou/core/server-function-proxy.js +3 -0
- package/dinou/core/slot.js +302 -0
- package/dinou/core/status-manifest.js +41 -1
- package/dinou/core/storage-adapter.js +522 -0
- package/dinou/core/url-resolver.js +16 -16
- package/dinou/core/vfs.js +139 -68
- package/dinou/deno/build.mjs +1112 -0
- package/dinou/deno/seed-kv.js +115 -0
- package/dinou/esbuild/build.mjs +51 -1
- package/dinou/esbuild/dev.mjs +290 -224
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.mjs +3 -2
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild.mjs +104 -16
- package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.mjs +31 -19
- package/dinou/esbuild/helpers-esbuild/strip-namespace.mjs +9 -0
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.mjs +225 -0
- package/dinou/esbuild/helpers-esbuild/update-manifest-for-module.mjs +7 -0
- package/dinou/esbuild/helpers-esbuild/write.mjs +111 -2
- package/dinou/esbuild/plugins-esbuild/assets-plugin.mjs +236 -161
- package/dinou/esbuild/plugins-esbuild/css-processor-plugin.mjs +101 -5
- package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.mjs +63 -24
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.mjs +177 -56
- package/dinou/esbuild/plugins-esbuild/skip-missing-entry-points-plugin.mjs +3 -0
- package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.mjs +182 -137
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +38 -11
- package/dinou/esbuild/react-refresh/esm-hmr/client.mjs +55 -8
- package/dinou/esbuild/react-refresh/esm-hmr/server.js +1 -1
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.mjs +238 -101
- package/dinou/esbuild/react-refresh/is-react-refresh-boundary.mjs +18 -4
- package/dinou/index.d.ts +315 -11
- package/dinou/index.js +12 -6
- package/dinou/index.mjs +9 -0
- package/dinou/node/build.mjs +195 -0
- package/dinou/node/bundle-dual-engine.mjs +1012 -0
- package/dinou/node/dev.mjs +2589 -0
- package/dinou/node/port-selector.mjs +164 -0
- package/dinou/node/terminal-status.mjs +345 -0
- package/dinou/package.json +16 -14
- package/dinou/rollup/react-refresh/esm-hmr/client.js +66 -10
- package/dinou/rollup/react-refresh/esm-hmr/server.js +1 -1
- package/dinou/rollup/react-refresh/is-react-refresh-boundary.js +24 -5
- package/dinou/rollup/react-refresh/react-refresh-runtime.js +13 -6
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +56 -11
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +176 -48
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +9 -5
- package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +66 -0
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +468 -123
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +44 -12
- package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +100 -0
- package/dinou/rollup/rollup.config.js +155 -43
- package/dinou/server.d.ts +114 -12
- package/dinou/server.js +35 -10
- package/dinou/server.mjs +30 -9
- package/dinou/webpack/helpers/get-webpack-entries.js +14 -19
- package/dinou/webpack/loaders/server-functions-loader.js +22 -1
- package/dinou/webpack/loaders/swc-loader.js +76 -0
- package/dinou/webpack/plugins/manifest-generator-plugin.js +1 -0
- package/dinou/webpack/plugins/server-functions-plugin.js +75 -19
- package/dinou/webpack/plugins/webpack-memory-plugin.js +66 -0
- package/dinou/webpack/webpack.config.js +227 -29
- package/eject.js +173 -94
- package/package.json +110 -108
- package/dinou/core/asset-require-hook.js +0 -58
- package/dinou/core/client-error-webpack.jsx +0 -432
- package/dinou/core/client-error.jsx +0 -432
- package/dinou/core/concurrency-manager.js +0 -48
- package/dinou/core/context-proxy.js +0 -68
- package/dinou/core/generate-static-pages.js +0 -130
- package/dinou/core/generate-static-rscs.js +0 -151
- package/dinou/core/get-ssg-metadata.js +0 -31
- package/dinou/core/register-loader.mjs +0 -11
- package/dinou/core/register-paths.js +0 -27
- package/dinou/core/render-app-to-html.js +0 -430
- package/dinou/core/render-html.js +0 -407
- package/dinou/core/server.js +0 -1542
- package/dinou/esbuild/plugins-esbuild/write-metafile-plugin.mjs +0 -16
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// dinou/adapters/cloudflare.js
|
|
2
|
+
// Cloudflare Workers Adapter for Dinou v7.
|
|
3
|
+
// Universal edge entry point with KV storage, route registry, and Web Streams.
|
|
4
|
+
|
|
5
|
+
import { handleRequest } from "../core/handler.js";
|
|
6
|
+
import {
|
|
7
|
+
getStorageAdapter,
|
|
8
|
+
setStorageAdapter,
|
|
9
|
+
CloudflareKVStorage,
|
|
10
|
+
MemoryStorage,
|
|
11
|
+
} from "../core/storage-adapter.js";
|
|
12
|
+
|
|
13
|
+
// Ensure Edge runtime flag is set globally
|
|
14
|
+
if (typeof globalThis !== "undefined") {
|
|
15
|
+
globalThis.__DINOU_RUNTIME__ = "edge";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let storageInitialized = false;
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
/**
|
|
22
|
+
* Cloudflare Workers fetch handler
|
|
23
|
+
* @param {Request} request
|
|
24
|
+
* @param {object} env Bindings (KV, D1, Environment variables)
|
|
25
|
+
* @param {object} ctx Execution context (waitUntil, passThroughOnException)
|
|
26
|
+
* @returns {Promise<Response>}
|
|
27
|
+
*/
|
|
28
|
+
async fetch(request, env, ctx) {
|
|
29
|
+
const url = new URL(request.url);
|
|
30
|
+
if (url.pathname.startsWith("/cdn-cgi/")) {
|
|
31
|
+
return new Response(null, { status: 404 });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!storageInitialized) {
|
|
35
|
+
if (env && env.DINOU_CACHE) {
|
|
36
|
+
setStorageAdapter(new CloudflareKVStorage(env.DINOU_CACHE));
|
|
37
|
+
} else {
|
|
38
|
+
setStorageAdapter(new MemoryStorage());
|
|
39
|
+
}
|
|
40
|
+
storageInitialized = true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const isRSCPayload = url.pathname.includes("____rsc_");
|
|
44
|
+
const isServerFunction = url.pathname.includes("____server_function____") || request.headers.get("x-server-function-call") === "1";
|
|
45
|
+
|
|
46
|
+
// Static assets: files with extensions like .js, .css, .png, etc. (excluding document .html and RSC/server-functions)
|
|
47
|
+
const staticExtRegex = /\.(js|mjs|cjs|css|png|jpg|jpeg|gif|svg|ico|webp|avif|woff|woff2|ttf|eot|otf|wasm|map|txt|webmanifest)$/i;
|
|
48
|
+
const isStaticAsset = staticExtRegex.test(url.pathname) || url.pathname.startsWith("/assets/") || url.pathname.startsWith("/_dinou/");
|
|
49
|
+
|
|
50
|
+
if (!isRSCPayload && !isServerFunction && isStaticAsset && env && env.ASSETS && (request.method === "GET" || request.method === "HEAD")) {
|
|
51
|
+
try {
|
|
52
|
+
const assetRes = await env.ASSETS.fetch(request.clone ? request.clone() : request);
|
|
53
|
+
if (assetRes && assetRes.status < 400) {
|
|
54
|
+
return assetRes;
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return handleRequest(request, {
|
|
60
|
+
env,
|
|
61
|
+
ctx,
|
|
62
|
+
runtime: "edge",
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// dinou/adapters/deno.js
|
|
2
|
+
// Native Deno & Deno Deploy Adapter for Dinou v7.
|
|
3
|
+
// Supports standalone containers, Deno CLI, and Deno Deploy Edge.
|
|
4
|
+
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
|
+
|
|
10
|
+
if (typeof globalThis.AsyncLocalStorage === "undefined" && typeof AsyncLocalStorage !== "undefined") {
|
|
11
|
+
globalThis.AsyncLocalStorage = AsyncLocalStorage;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const cwd = typeof Deno !== "undefined" ? Deno.cwd() : process.cwd();
|
|
15
|
+
const mainBundlePath = path.resolve(cwd, ".dinou/deno/main.js");
|
|
16
|
+
|
|
17
|
+
let mainModule = null;
|
|
18
|
+
if (fs.existsSync(mainBundlePath)) {
|
|
19
|
+
try {
|
|
20
|
+
mainModule = await import(pathToFileURL(mainBundlePath).href);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error("[Dinou Deno Adapter] Failed to load .dinou/deno/main.js:", e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const PORT = Number(
|
|
27
|
+
(typeof Deno !== "undefined" ? Deno.env.get("PORT") : process.env.PORT) || 3000
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export async function fetch(req) {
|
|
31
|
+
if (mainModule && typeof mainModule.fetch === "function") {
|
|
32
|
+
return mainModule.fetch(req);
|
|
33
|
+
}
|
|
34
|
+
return new Response("Dinou bundle not found. Please run 'npm run build:deno' first.", {
|
|
35
|
+
status: 500,
|
|
36
|
+
headers: { "content-type": "text/plain; charset=utf-8" },
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Start standalone server if run directly in Deno
|
|
41
|
+
if (typeof Deno !== "undefined" && typeof Deno.serve === "function" && import.meta.main) {
|
|
42
|
+
Deno.serve({ port: PORT }, fetch);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
port: PORT,
|
|
47
|
+
fetch,
|
|
48
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// dinou/adapters/netlify.js
|
|
2
|
+
// Netlify Functions v2 Adapter for Dinou.
|
|
3
|
+
// Automatically routes all requests to Dinou's universal Web Standards handler.
|
|
4
|
+
Object.assign(process.env, { NODE_ENV: "production" });
|
|
5
|
+
|
|
6
|
+
import { register } from "node:module";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import Module from "node:module";
|
|
10
|
+
|
|
11
|
+
import { dinouCoreDir } from "../core/dinou-paths.js";
|
|
12
|
+
|
|
13
|
+
if (typeof register === "function") {
|
|
14
|
+
try {
|
|
15
|
+
const loaderPath = path.join(dinouCoreDir, "babel-esm-loader.js");
|
|
16
|
+
register(pathToFileURL(loaderPath).href, pathToFileURL("./"));
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.error("[Dinou Adapter] Loader registration failed:", e);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let reactServerPath, reactDomServerPath, reactJsxRuntimePath, reactJsxDevRuntimePath;
|
|
23
|
+
let roggcServerNodePath, webpackServerNodePath;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const reactPkgJson = require.resolve("react/package.json");
|
|
27
|
+
reactServerPath = path.join(path.dirname(reactPkgJson), "react.react-server.js");
|
|
28
|
+
reactJsxRuntimePath = path.join(path.dirname(reactPkgJson), "jsx-runtime.react-server.js");
|
|
29
|
+
reactJsxDevRuntimePath = path.join(path.dirname(reactPkgJson), "jsx-dev-runtime.react-server.js");
|
|
30
|
+
|
|
31
|
+
const reactDomPkgJson = require.resolve("react-dom/package.json");
|
|
32
|
+
reactDomServerPath = path.join(path.dirname(reactDomPkgJson), "react-dom.react-server.js");
|
|
33
|
+
} catch (e) {}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const roggcPkgJson = require.resolve("@roggc/react-server-dom-esm/package.json");
|
|
37
|
+
roggcServerNodePath = path.join(path.dirname(roggcPkgJson), "server.node.js");
|
|
38
|
+
} catch (e) {}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const webpackPkgJson = require.resolve("react-server-dom-webpack/package.json");
|
|
42
|
+
webpackServerNodePath = path.join(path.dirname(webpackPkgJson), "server.node.js");
|
|
43
|
+
} catch (e) {}
|
|
44
|
+
|
|
45
|
+
if (Module && Module._resolveFilename) {
|
|
46
|
+
const originalResolveFilename = Module._resolveFilename;
|
|
47
|
+
Module._resolveFilename = function (request, parent, isMain, options) {
|
|
48
|
+
if (request === "react") {
|
|
49
|
+
return reactServerPath;
|
|
50
|
+
} else if (request === "react-dom") {
|
|
51
|
+
return reactDomServerPath;
|
|
52
|
+
} else if (request === "react/jsx-runtime") {
|
|
53
|
+
return reactJsxRuntimePath;
|
|
54
|
+
} else if (request === "react/jsx-dev-runtime") {
|
|
55
|
+
return reactJsxDevRuntimePath;
|
|
56
|
+
} else if (request === "@roggc/react-server-dom-esm/server" && roggcServerNodePath) {
|
|
57
|
+
return roggcServerNodePath;
|
|
58
|
+
} else if (request === "react-server-dom-webpack/server" && webpackServerNodePath) {
|
|
59
|
+
return webpackServerNodePath;
|
|
60
|
+
}
|
|
61
|
+
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (typeof require === "function") {
|
|
66
|
+
globalThis.__dinou_require__ = require;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
import { handleRequest } from "../core/handler.js";
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Netlify Function v2 handler
|
|
73
|
+
* @param {Request} request
|
|
74
|
+
* @param {object} context
|
|
75
|
+
* @returns {Promise<Response>}
|
|
76
|
+
*/
|
|
77
|
+
export default async function netlifyHandler(request, context) {
|
|
78
|
+
return handleRequest(request);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const config = {
|
|
82
|
+
path: "/*",
|
|
83
|
+
preferStatic: true,
|
|
84
|
+
};
|
|
85
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// dinou/adapters/node.mjs
|
|
2
|
+
// Native Node.js Pre-Bundled Adapter for Dinou v7.
|
|
3
|
+
// Serves the standalone pre-bundled server from .dinou/node/server.mjs.
|
|
4
|
+
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
|
+
|
|
10
|
+
if (typeof globalThis.AsyncLocalStorage === "undefined" && typeof AsyncLocalStorage !== "undefined") {
|
|
11
|
+
globalThis.AsyncLocalStorage = AsyncLocalStorage;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const cwd = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : ".";
|
|
15
|
+
const bundlePath = path.resolve(cwd, ".dinou/node/server.mjs");
|
|
16
|
+
|
|
17
|
+
if (!fs.existsSync(bundlePath)) {
|
|
18
|
+
console.error("❌ [Dinou Node Adapter] .dinou/node/server.mjs not found. Please run 'npm run build:node' first.");
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const serverModule = await import(pathToFileURL(bundlePath).href);
|
|
23
|
+
const PORT = Number(process.env.PORT || 3000);
|
|
24
|
+
|
|
25
|
+
if (typeof serverModule.startServer === "function") {
|
|
26
|
+
await serverModule.startServer(PORT);
|
|
27
|
+
} else if (serverModule.default && typeof serverModule.default.startServer === "function") {
|
|
28
|
+
await serverModule.default.startServer(PORT);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default serverModule.default || serverModule;
|