dinou 9.3.0 → 10.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 +196 -0
- package/README.md +157 -132
- package/dinou/adapters/bun.js +34 -5
- package/dinou/adapters/cloudflare.js +110 -17
- package/dinou/adapters/deno.js +46 -8
- package/dinou/adapters/netlify.js +86 -50
- package/dinou/adapters/node.js +8 -0
- package/dinou/assets.d.ts +32 -5
- package/dinou/bun/build.js +190 -106
- package/dinou/cli.js +992 -532
- package/dinou/cloudflare/build.js +187 -106
- package/dinou/compiled/autoprefixer/index.js +509 -517
- package/dinou/compiled/babel-core/index.js +738 -716
- package/dinou/compiled/babel-generator/index.js +341 -299
- package/dinou/compiled/babel-loader/index.js +766 -744
- package/dinou/compiled/babel-parser/index.js +2 -2
- package/dinou/compiled/babel-plugin-react-compiler/index.js +178 -178
- package/dinou/compiled/babel-plugin-syntax-import-meta/index.js +4 -4
- package/dinou/compiled/babel-preset-react/index.js +752 -730
- package/dinou/compiled/babel-preset-typescript/index.js +738 -716
- package/dinou/compiled/babel-traverse/index.js +463 -433
- package/dinou/compiled/babel-types/index.js +176 -176
- package/dinou/compiled/chokidar/index.js +4 -4
- package/dinou/compiled/commander/index.js +15 -15
- package/dinou/compiled/copy-webpack-plugin/index.js +433 -425
- package/dinou/compiled/css-loader/index.js +289 -289
- package/dinou/compiled/css-loader/runtime/api.js +85 -0
- package/dinou/compiled/css-loader/runtime/getUrl.js +26 -0
- package/dinou/compiled/css-loader/runtime/noSourceMaps.js +5 -0
- package/dinou/compiled/css-loader/runtime/package.json +3 -0
- package/dinou/compiled/css-loader/runtime/sourceMaps.js +16 -0
- package/dinou/compiled/fast-glob/index.js +5810 -0
- package/dinou/compiled/generic-names/index.js +16 -16
- package/dinou/compiled/mini-css-extract-plugin/{chunk-YYEJWYXE.js → chunk-R6DP5ZYM.js} +36 -36
- package/dinou/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +253 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/normalize-url.js +39 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/package.json +3 -0
- package/dinou/compiled/mini-css-extract-plugin/index.js +1 -1
- package/dinou/compiled/mini-css-extract-plugin/loader.js +5 -5
- package/dinou/compiled/postcss/index.js +83 -83
- package/dinou/compiled/postcss-import/index.js +147 -117
- package/dinou/compiled/postcss-modules/index.js +216 -216
- package/dinou/compiled/resolve/index.js +1224 -0
- package/dinou/compiled/rollup-plugin-babel/index.js +753 -731
- package/dinou/compiled/rollup-plugin-commonjs/index.js +43 -38
- package/dinou/compiled/rollup-plugin-delete/index.js +615 -253
- package/dinou/compiled/rollup-plugin-json/index.js +22 -18
- package/dinou/compiled/rollup-plugin-node-resolve/index.js +130 -100
- package/dinou/compiled/rollup-plugin-postcss/index.js +3299 -3277
- package/dinou/compiled/rollup-plugin-replace/index.js +34 -29
- package/dinou/compiled/tailwindcss-postcss/index.js +214 -211
- package/dinou/compiled/vendors-manifest.json +59 -83
- package/dinou/core/asset-extensions.js +482 -33
- package/dinou/core/bailout-proxy.js +21 -2
- package/dinou/core/build-static-pages.js +523 -371
- package/dinou/core/builtin-asset-extensions.js +63 -0
- package/dinou/core/cache-revalidate.js +449 -256
- package/dinou/core/cache-slot.js +289 -79
- package/dinou/core/client-webpack.jsx +470 -39
- package/dinou/core/client.jsx +402 -39
- package/dinou/core/config.js +3 -0
- package/dinou/core/copy-static-dirs.js +98 -0
- package/dinou/core/createScopedName.js +22 -4
- package/dinou/core/dinou-paths.js +1 -1
- package/dinou/core/discover-layouts.js +200 -0
- package/dinou/core/edge-ssr.js +1 -1
- package/dinou/core/ensure-vendor-mode.js +78 -19
- package/dinou/core/env.js +544 -0
- package/dinou/core/export-static.js +41 -9
- package/dinou/core/generate-route-types.js +989 -95
- package/dinou/core/generate-static-rsc.js +5 -6
- package/dinou/core/generate-static.js +45 -6
- package/dinou/core/get-abs-path-with-ext.js +217 -75
- package/dinou/core/get-asset-from-manifest.js +19 -8
- package/dinou/core/get-error-jsx.js +4 -5
- package/dinou/core/get-file-path-and-dynamic-params.js +561 -338
- package/dinou/core/get-jsx.js +220 -53
- package/dinou/core/handler.js +1647 -466
- package/dinou/core/import-module.js +7 -0
- package/dinou/core/layout-functions.js +72 -13
- package/dinou/core/link.jsx +34 -6
- package/dinou/core/load-dinou-config.js +520 -89
- package/dinou/core/manifest-provider.js +4 -14
- package/dinou/core/navigation-utils.js +141 -3
- package/dinou/core/navigation.js +134 -50
- package/dinou/core/node-middleware-runner.js +165 -0
- package/dinou/core/postcss-pipeline.js +236 -0
- package/dinou/core/ppr-context.js +114 -22
- package/dinou/core/ppr-runtime.js +391 -127
- package/dinou/core/redirect.jsx +1 -1
- package/dinou/core/render-jsx-to-client-jsx.js +216 -48
- package/dinou/core/request-context.js +59 -3
- package/dinou/core/resolve-contextual-dinou.js +523 -0
- package/dinou/core/resolve-setup-files.js +85 -27
- package/dinou/core/revalidating.js +10 -2
- package/dinou/core/route-generator.js +6 -2
- package/dinou/core/rsc-renderer.js +4 -1
- package/dinou/core/run-ssg.js +6 -0
- package/dinou/core/runtime-env.js +265 -0
- package/dinou/core/server-css-modules-plugin.js +155 -0
- package/dinou/core/server-function-proxy-webpack.js +27 -2
- package/dinou/core/server-function-proxy.js +27 -2
- package/dinou/core/slot.js +47 -2
- package/dinou/core/static-assets.js +503 -0
- package/dinou/core/storage-adapter.js +452 -24
- package/dinou/core/transform-server-functions.js +272 -24
- package/dinou/core/tsconfig-aliases.js +964 -0
- package/dinou/core/uneject.js +640 -0
- package/dinou/core/url-resolver.js +1 -1
- package/dinou/core/vfs.js +11 -2
- package/dinou/css.d.ts +4 -1
- package/dinou/deno/build.js +205 -153
- package/dinou/deno/seed-kv.js +4 -0
- package/dinou/env.d.ts +22 -2
- package/dinou/esbuild/build.js +40 -50
- package/dinou/esbuild/dev.js +33 -7
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.js +41 -16
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild.js +51 -49
- package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.js +73 -60
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +35 -16
- package/dinou/esbuild/helpers-esbuild/write.js +13 -3
- package/dinou/esbuild/plugins-esbuild/assets-plugin.js +100 -238
- package/dinou/esbuild/plugins-esbuild/babel-react-compiler-plugin.js +73 -29
- package/dinou/esbuild/plugins-esbuild/css-processor-plugin.js +283 -91
- package/dinou/esbuild/plugins-esbuild/manifest-generator-plugin.js +3 -5
- package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.js +9 -3
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +4 -3
- package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.js +10 -1
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +84 -21
- package/dinou/esbuild/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.js +48 -18
- package/dinou/esbuild/react-refresh/is-react-refresh-boundary.js +9 -1
- package/dinou/esbuild/react-refresh/react-refresh-runtime.js +13 -7
- package/dinou/index.d.ts +1028 -88
- package/dinou/node/build.js +138 -74
- package/dinou/node/bundle-dual-engine.js +393 -131
- package/dinou/node/dev.js +1005 -275
- package/dinou/package.json +11 -34
- package/dinou/rollup/postcss.config.js +3 -4
- package/dinou/rollup/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +16 -13
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +53 -7
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +58 -20
- package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +16 -7
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +118 -42
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +48 -36
- package/dinou/rollup/rollup.config.js +174 -101
- package/dinou/scripts/build-vendors.js +123 -33
- package/dinou/server.d.ts +126 -15
- package/dinou/webpack/helpers/get-webpack-entries.js +87 -41
- package/dinou/webpack/helpers/patch-webpack-internals.js +93 -1
- package/dinou/webpack/loaders/server-functions-loader.js +1 -1
- package/dinou/webpack/plugins/manifest-generator-plugin.js +27 -7
- package/dinou/webpack/plugins/server-functions-plugin.js +39 -12
- package/dinou/webpack/plugins/webpack-memory-plugin.js +25 -12
- package/dinou/webpack/postcss.config.js +3 -4
- package/dinou/webpack/webpack.config.js +408 -132
- package/eject.js +6 -224
- package/package.json +7 -9
- package/dinou/compiled/cross-env/index.js +0 -661
- package/dinou/compiled/dotenv/index.js +0 -375
- package/dinou/compiled/esbuild-copy-static-files/index.js +0 -63
- package/dinou/compiled/esbuild-tsconfig-paths/index.js +0 -1314
- package/dinou/compiled/rollup-plugin-copy/index.js +0 -12066
- package/dinou/compiled/rollup-plugin-tsconfig-paths/index.js +0 -569
- package/dinou/compiled/tsconfig-paths-webpack-plugin/index.js +0 -3956
package/dinou/adapters/bun.js
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
// dinou/adapters/bun.js
|
|
2
|
-
// Native Bun Adapter for Dinou
|
|
2
|
+
// Native Bun Adapter for Dinou (Pre-bundled AOT).
|
|
3
3
|
// Serves the standalone pre-bundled server from .dinou/bun/server.js.
|
|
4
4
|
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
|
+
import { loadEnvFiles } from "../core/env.js";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
const cwd =
|
|
12
|
+
typeof process !== "undefined" && typeof process.cwd === "function"
|
|
13
|
+
? process.cwd()
|
|
14
|
+
: ".";
|
|
15
|
+
loadEnvFiles(cwd, { mode: "production" });
|
|
16
|
+
|
|
17
|
+
if (
|
|
18
|
+
typeof globalThis.AsyncLocalStorage === "undefined" &&
|
|
19
|
+
typeof AsyncLocalStorage !== "undefined"
|
|
20
|
+
) {
|
|
11
21
|
globalThis.AsyncLocalStorage = AsyncLocalStorage;
|
|
12
22
|
}
|
|
13
23
|
|
|
14
|
-
const
|
|
24
|
+
const isMain = Boolean(typeof import.meta !== "undefined" && import.meta.main);
|
|
15
25
|
const bundlePath = path.resolve(cwd, ".dinou/bun/server.js");
|
|
16
26
|
|
|
17
27
|
let bundleModule = null;
|
|
@@ -20,17 +30,30 @@ if (fs.existsSync(bundlePath)) {
|
|
|
20
30
|
bundleModule = await import(pathToFileURL(bundlePath).href);
|
|
21
31
|
} catch (e) {
|
|
22
32
|
console.error("[Dinou Bun Adapter] Failed to load .dinou/bun/server.js:", e);
|
|
33
|
+
if (isMain) {
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
23
36
|
}
|
|
37
|
+
} else if (isMain) {
|
|
38
|
+
console.error(
|
|
39
|
+
"❌ [Dinou Bun Adapter] .dinou/bun/server.js not found. Please run 'npm run build:bun' first."
|
|
40
|
+
);
|
|
41
|
+
process.exit(1);
|
|
24
42
|
}
|
|
25
43
|
|
|
26
44
|
const PORT = Number(process.env.PORT || 3000);
|
|
45
|
+
const HOST = process.env.HOST || undefined;
|
|
27
46
|
const IDLE_TIMEOUT = Number(process.env.IDLE_TIMEOUT || 120);
|
|
28
47
|
|
|
29
48
|
export async function fetch(req) {
|
|
30
49
|
if (bundleModule && typeof bundleModule.fetch === "function") {
|
|
31
50
|
return bundleModule.fetch(req);
|
|
32
51
|
}
|
|
33
|
-
if (
|
|
52
|
+
if (
|
|
53
|
+
bundleModule &&
|
|
54
|
+
bundleModule.default &&
|
|
55
|
+
typeof bundleModule.default.fetch === "function"
|
|
56
|
+
) {
|
|
34
57
|
return bundleModule.default.fetch(req);
|
|
35
58
|
}
|
|
36
59
|
return new Response(
|
|
@@ -42,8 +65,15 @@ export async function fetch(req) {
|
|
|
42
65
|
);
|
|
43
66
|
}
|
|
44
67
|
|
|
68
|
+
if (isMain && bundleModule) {
|
|
69
|
+
console.log(
|
|
70
|
+
`🚀 Dinou (Bun AOT Dual-Bundle) server running on http://${HOST || "localhost"}:${PORT}`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
45
74
|
export default {
|
|
46
75
|
port: PORT,
|
|
76
|
+
...(HOST ? { hostname: HOST } : {}),
|
|
47
77
|
fetch,
|
|
48
78
|
idleTimeout: IDLE_TIMEOUT,
|
|
49
79
|
};
|
|
@@ -59,4 +89,3 @@ if (typeof process !== "undefined") {
|
|
|
59
89
|
}
|
|
60
90
|
}
|
|
61
91
|
}
|
|
62
|
-
|
|
@@ -1,65 +1,158 @@
|
|
|
1
1
|
// dinou/adapters/cloudflare.js
|
|
2
|
-
// Cloudflare Workers Adapter for Dinou
|
|
3
|
-
//
|
|
2
|
+
// Cloudflare Workers Adapter for Dinou (AOT Dual-Bundle & Edge Fallback).
|
|
3
|
+
// Delegates to the pre-bundled .dinou/cloudflare/worker.js orchestrator when present,
|
|
4
|
+
// and preserves custom storage adapters + registered SSR renderers in direct edge usage.
|
|
4
5
|
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import { pathToFileURL } from "node:url";
|
|
5
9
|
import { handleRequest } from "../core/handler.js";
|
|
6
10
|
import {
|
|
7
|
-
getStorageAdapter,
|
|
8
11
|
setStorageAdapter,
|
|
12
|
+
hasExplicitStorageAdapter,
|
|
9
13
|
CloudflareKVStorage,
|
|
10
14
|
MemoryStorage,
|
|
11
15
|
} from "../core/storage-adapter.js";
|
|
16
|
+
import {
|
|
17
|
+
getStaticContentType,
|
|
18
|
+
isPublicStaticAssetRequest,
|
|
19
|
+
isReservedCloudflareDist2RequestPath,
|
|
20
|
+
} from "../core/static-assets.js";
|
|
12
21
|
|
|
13
|
-
// Ensure Edge runtime flag is set globally
|
|
14
22
|
if (typeof globalThis !== "undefined") {
|
|
15
23
|
globalThis.__DINOU_RUNTIME__ = "edge";
|
|
16
24
|
}
|
|
17
25
|
|
|
26
|
+
const workerCacheByPath = new Map();
|
|
27
|
+
|
|
28
|
+
async function getPrebuiltCloudflareWorker() {
|
|
29
|
+
try {
|
|
30
|
+
if (
|
|
31
|
+
typeof process === "undefined" ||
|
|
32
|
+
typeof process.cwd !== "function" ||
|
|
33
|
+
typeof fs.existsSync !== "function"
|
|
34
|
+
) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const workerPath = path.resolve(process.cwd(), ".dinou/cloudflare/worker.js");
|
|
38
|
+
if (!fs.existsSync(workerPath)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
let mtimeMs = 0;
|
|
42
|
+
try {
|
|
43
|
+
mtimeMs = fs.statSync(workerPath).mtimeMs;
|
|
44
|
+
} catch (e) {}
|
|
45
|
+
const cached = workerCacheByPath.get(workerPath);
|
|
46
|
+
if (cached && cached.mtimeMs === mtimeMs) {
|
|
47
|
+
return cached.promise;
|
|
48
|
+
}
|
|
49
|
+
const promise = import(pathToFileURL(workerPath).href).catch((err) => {
|
|
50
|
+
workerCacheByPath.delete(workerPath);
|
|
51
|
+
console.error("[Dinou Cloudflare Adapter] Failed to load .dinou/cloudflare/worker.js:", err);
|
|
52
|
+
return null;
|
|
53
|
+
});
|
|
54
|
+
workerCacheByPath.set(workerPath, { mtimeMs, promise });
|
|
55
|
+
return promise;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
18
61
|
let storageInitialized = false;
|
|
19
62
|
|
|
20
63
|
export default {
|
|
21
64
|
/**
|
|
22
65
|
* Cloudflare Workers fetch handler
|
|
23
|
-
* @param {Request} request
|
|
24
|
-
* @param {object} env Bindings (KV, D1, Environment variables)
|
|
66
|
+
* @param {Request} request
|
|
67
|
+
* @param {object} env Bindings (KV, D1, ASSETS, Environment variables)
|
|
25
68
|
* @param {object} ctx Execution context (waitUntil, passThroughOnException)
|
|
26
69
|
* @returns {Promise<Response>}
|
|
27
70
|
*/
|
|
28
71
|
async fetch(request, env, ctx) {
|
|
72
|
+
const prebuilt = await getPrebuiltCloudflareWorker();
|
|
73
|
+
const prebuiltFetch =
|
|
74
|
+
prebuilt?.default && typeof prebuilt.default.fetch === "function"
|
|
75
|
+
? prebuilt.default.fetch
|
|
76
|
+
: typeof prebuilt?.fetch === "function"
|
|
77
|
+
? prebuilt.fetch
|
|
78
|
+
: null;
|
|
79
|
+
if (prebuiltFetch) {
|
|
80
|
+
return prebuiltFetch(request, env, ctx);
|
|
81
|
+
}
|
|
82
|
+
|
|
29
83
|
const url = new URL(request.url);
|
|
30
|
-
if (
|
|
84
|
+
if (
|
|
85
|
+
url.pathname.startsWith("/cdn-cgi/") ||
|
|
86
|
+
isReservedCloudflareDist2RequestPath(url.pathname)
|
|
87
|
+
) {
|
|
31
88
|
return new Response(null, { status: 404 });
|
|
32
89
|
}
|
|
33
90
|
|
|
34
91
|
if (!storageInitialized) {
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
92
|
+
if (!hasExplicitStorageAdapter()) {
|
|
93
|
+
if (env && env.DINOU_CACHE) {
|
|
94
|
+
setStorageAdapter(new CloudflareKVStorage(env.DINOU_CACHE));
|
|
95
|
+
} else {
|
|
96
|
+
setStorageAdapter(new MemoryStorage());
|
|
97
|
+
}
|
|
39
98
|
}
|
|
40
99
|
storageInitialized = true;
|
|
41
100
|
}
|
|
42
101
|
|
|
43
102
|
const isRSCPayload = url.pathname.includes("____rsc_");
|
|
44
|
-
const isServerFunction =
|
|
103
|
+
const isServerFunction =
|
|
104
|
+
url.pathname.includes("____server_function____") ||
|
|
105
|
+
request.headers.get("x-server-function-call") === "1";
|
|
45
106
|
|
|
46
|
-
|
|
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/");
|
|
107
|
+
const isStaticAsset = isPublicStaticAssetRequest(url.pathname);
|
|
49
108
|
|
|
50
|
-
if (
|
|
109
|
+
if (
|
|
110
|
+
!isRSCPayload &&
|
|
111
|
+
!isServerFunction &&
|
|
112
|
+
isStaticAsset &&
|
|
113
|
+
env &&
|
|
114
|
+
env.ASSETS &&
|
|
115
|
+
(request.method === "GET" || request.method === "HEAD")
|
|
116
|
+
) {
|
|
51
117
|
try {
|
|
52
|
-
const assetRes = await env.ASSETS.fetch(
|
|
118
|
+
const assetRes = await env.ASSETS.fetch(
|
|
119
|
+
request.clone ? request.clone() : request
|
|
120
|
+
);
|
|
53
121
|
if (assetRes && assetRes.status < 400) {
|
|
122
|
+
const rawCt = (assetRes.headers.get("content-type") || "").trim();
|
|
123
|
+
const lowerCt = rawCt.toLowerCase();
|
|
124
|
+
const expectedCt = getStaticContentType(url.pathname);
|
|
125
|
+
const needsContentTypeFix =
|
|
126
|
+
!rawCt ||
|
|
127
|
+
(lowerCt === "application/octet-stream" &&
|
|
128
|
+
expectedCt !== "application/octet-stream") ||
|
|
129
|
+
(url.pathname.toLowerCase().endsWith("/apple-app-site-association") &&
|
|
130
|
+
!lowerCt.includes("json"));
|
|
131
|
+
if (needsContentTypeFix) {
|
|
132
|
+
const headers = new Headers(assetRes.headers);
|
|
133
|
+
headers.set("content-type", expectedCt);
|
|
134
|
+
return new Response(assetRes.body, {
|
|
135
|
+
status: assetRes.status,
|
|
136
|
+
statusText: assetRes.statusText,
|
|
137
|
+
headers,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
54
140
|
return assetRes;
|
|
55
141
|
}
|
|
56
142
|
} catch (e) {}
|
|
57
143
|
}
|
|
58
144
|
|
|
145
|
+
const registeredSsr =
|
|
146
|
+
typeof globalThis !== "undefined" &&
|
|
147
|
+
typeof globalThis.__DINOU_RENDER_HTML_STREAM__ === "function"
|
|
148
|
+
? globalThis.__DINOU_RENDER_HTML_STREAM__
|
|
149
|
+
: undefined;
|
|
150
|
+
|
|
59
151
|
return handleRequest(request, {
|
|
60
152
|
env,
|
|
61
153
|
ctx,
|
|
62
154
|
runtime: "edge",
|
|
155
|
+
...(registeredSsr ? { renderHtmlStream: registeredSsr } : {}),
|
|
63
156
|
});
|
|
64
157
|
},
|
|
65
158
|
};
|
package/dinou/adapters/deno.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
// dinou/adapters/deno.js
|
|
2
|
-
// Native Deno & Deno Deploy Adapter for Dinou
|
|
2
|
+
// Native Deno & Deno Deploy Adapter for Dinou (Pre-bundled AOT).
|
|
3
3
|
// Supports standalone containers, Deno CLI, and Deno Deploy Edge.
|
|
4
4
|
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
|
+
import { loadEnvFiles } from "../core/env.js";
|
|
9
10
|
|
|
10
|
-
if (
|
|
11
|
+
if (
|
|
12
|
+
typeof globalThis.AsyncLocalStorage === "undefined" &&
|
|
13
|
+
typeof AsyncLocalStorage !== "undefined"
|
|
14
|
+
) {
|
|
11
15
|
globalThis.AsyncLocalStorage = AsyncLocalStorage;
|
|
12
16
|
}
|
|
13
17
|
|
|
18
|
+
const isMain = Boolean(typeof import.meta !== "undefined" && import.meta.main);
|
|
14
19
|
const cwd = typeof Deno !== "undefined" ? Deno.cwd() : process.cwd();
|
|
20
|
+
try {
|
|
21
|
+
loadEnvFiles(cwd, { mode: "production" });
|
|
22
|
+
} catch (e) {}
|
|
15
23
|
const mainBundlePath = path.resolve(cwd, ".dinou/deno/main.js");
|
|
16
24
|
|
|
17
25
|
let mainModule = null;
|
|
@@ -20,29 +28,59 @@ if (fs.existsSync(mainBundlePath)) {
|
|
|
20
28
|
mainModule = await import(pathToFileURL(mainBundlePath).href);
|
|
21
29
|
} catch (e) {
|
|
22
30
|
console.error("[Dinou Deno Adapter] Failed to load .dinou/deno/main.js:", e);
|
|
31
|
+
if (isMain) {
|
|
32
|
+
if (typeof Deno !== "undefined" && typeof Deno.exit === "function") {
|
|
33
|
+
Deno.exit(1);
|
|
34
|
+
} else if (typeof process !== "undefined") {
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else if (isMain) {
|
|
40
|
+
console.error(
|
|
41
|
+
"❌ [Dinou Deno Adapter] .dinou/deno/main.js not found. Please run 'npm run build:deno' first."
|
|
42
|
+
);
|
|
43
|
+
if (typeof Deno !== "undefined" && typeof Deno.exit === "function") {
|
|
44
|
+
Deno.exit(1);
|
|
45
|
+
} else if (typeof process !== "undefined") {
|
|
46
|
+
process.exit(1);
|
|
23
47
|
}
|
|
24
48
|
}
|
|
25
49
|
|
|
26
50
|
const PORT = Number(
|
|
27
51
|
(typeof Deno !== "undefined" ? Deno.env.get("PORT") : process.env.PORT) || 3000
|
|
28
52
|
);
|
|
53
|
+
const HOST =
|
|
54
|
+
(typeof Deno !== "undefined" ? Deno.env.get("HOST") : process.env.HOST) ||
|
|
55
|
+
undefined;
|
|
29
56
|
|
|
30
57
|
export async function fetch(req) {
|
|
31
58
|
if (mainModule && typeof mainModule.fetch === "function") {
|
|
32
59
|
return mainModule.fetch(req);
|
|
33
60
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
61
|
+
if (
|
|
62
|
+
mainModule &&
|
|
63
|
+
mainModule.default &&
|
|
64
|
+
typeof mainModule.default.fetch === "function"
|
|
65
|
+
) {
|
|
66
|
+
return mainModule.default.fetch(req);
|
|
67
|
+
}
|
|
68
|
+
return new Response(
|
|
69
|
+
"Dinou bundle not found. Please run 'npm run build:deno' first.",
|
|
70
|
+
{
|
|
71
|
+
status: 500,
|
|
72
|
+
headers: { "content-type": "text/plain; charset=utf-8" },
|
|
73
|
+
}
|
|
74
|
+
);
|
|
38
75
|
}
|
|
39
76
|
|
|
40
77
|
// Start standalone server if run directly in Deno
|
|
41
|
-
if (typeof Deno !== "undefined" && typeof Deno.serve === "function" &&
|
|
42
|
-
Deno.serve({ port: PORT }, fetch);
|
|
78
|
+
if (typeof Deno !== "undefined" && typeof Deno.serve === "function" && isMain) {
|
|
79
|
+
Deno.serve(HOST ? { port: PORT, hostname: HOST } : { port: PORT }, fetch);
|
|
43
80
|
}
|
|
44
81
|
|
|
45
82
|
export default {
|
|
46
83
|
port: PORT,
|
|
84
|
+
...(HOST ? { hostname: HOST } : {}),
|
|
47
85
|
fetch,
|
|
48
86
|
};
|
|
@@ -1,74 +1,110 @@
|
|
|
1
1
|
// dinou/adapters/netlify.js
|
|
2
|
-
// Netlify Functions v2 Adapter for Dinou.
|
|
3
|
-
//
|
|
4
|
-
|
|
2
|
+
// Netlify Functions v2 Adapter for Dinou (Pre-bundled AOT Dual-Bundle).
|
|
3
|
+
// Delegates to the standalone AOT Dual-Bundle in .dinou/netlify/functions/ssr.mjs
|
|
4
|
+
// (or .dinou/dist1/server/netlify.js) so dynamic SSR, TypeScript/JSX routes,
|
|
5
|
+
// Server Functions, and read-only AWS Lambda filesystems work with zero runtime flags.
|
|
5
6
|
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import * as fs from "node:fs";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
|
+
import { loadEnvFiles } from "../core/env.js";
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
if (typeof process !== "undefined" && process.env && !process.env.NODE_ENV) {
|
|
14
|
+
process.env.NODE_ENV = "production";
|
|
15
|
+
}
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
if (
|
|
18
|
+
typeof globalThis.AsyncLocalStorage === "undefined" &&
|
|
19
|
+
typeof AsyncLocalStorage !== "undefined"
|
|
20
|
+
) {
|
|
21
|
+
globalThis.AsyncLocalStorage = AsyncLocalStorage;
|
|
22
|
+
}
|
|
13
23
|
|
|
14
|
-
|
|
15
|
-
const reactPkgJson = require.resolve("react/package.json");
|
|
16
|
-
reactServerPath = path.join(path.dirname(reactPkgJson), "react.react-server.js");
|
|
17
|
-
reactJsxRuntimePath = path.join(path.dirname(reactPkgJson), "jsx-runtime.react-server.js");
|
|
18
|
-
reactJsxDevRuntimePath = path.join(path.dirname(reactPkgJson), "jsx-dev-runtime.react-server.js");
|
|
24
|
+
const bundleCacheByCwd = new Map();
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
function resolveNetlifyBundlePath(cwd) {
|
|
27
|
+
const dedicated = path.resolve(cwd, ".dinou/netlify/functions/ssr.mjs");
|
|
28
|
+
if (fs.existsSync(dedicated)) {
|
|
29
|
+
return dedicated;
|
|
30
|
+
}
|
|
31
|
+
const dist1Fallback = path.resolve(cwd, ".dinou/dist1/server/netlify.js");
|
|
32
|
+
if (fs.existsSync(dist1Fallback)) {
|
|
33
|
+
return dist1Fallback;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
23
37
|
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
async function getNetlifyBundle(cwd) {
|
|
39
|
+
const resolvedCwd = path.resolve(cwd || ".");
|
|
40
|
+
const bundlePath = resolveNetlifyBundlePath(resolvedCwd);
|
|
41
|
+
if (!bundlePath) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
let mtimeMs = 0;
|
|
45
|
+
try {
|
|
46
|
+
mtimeMs = fs.statSync(bundlePath).mtimeMs;
|
|
47
|
+
} catch (e) {}
|
|
28
48
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
49
|
+
const cached = bundleCacheByCwd.get(bundlePath);
|
|
50
|
+
if (cached && cached.mtimeMs === mtimeMs) {
|
|
51
|
+
return cached.promise;
|
|
52
|
+
}
|
|
33
53
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (request === "react") {
|
|
38
|
-
return reactServerPath;
|
|
39
|
-
} else if (request === "react-dom") {
|
|
40
|
-
return reactDomServerPath;
|
|
41
|
-
} else if (request === "react/jsx-runtime") {
|
|
42
|
-
return reactJsxRuntimePath;
|
|
43
|
-
} else if (request === "react/jsx-dev-runtime") {
|
|
44
|
-
return reactJsxDevRuntimePath;
|
|
45
|
-
} else if (request === "@roggc/react-server-dom-esm/server" && roggcServerNodePath) {
|
|
46
|
-
return roggcServerNodePath;
|
|
47
|
-
} else if (request === "react-server-dom-webpack/server" && webpackServerNodePath) {
|
|
48
|
-
return webpackServerNodePath;
|
|
49
|
-
}
|
|
50
|
-
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
54
|
+
try {
|
|
55
|
+
loadEnvFiles(resolvedCwd, { mode: "production" });
|
|
56
|
+
} catch (e) {}
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
const loadPromise = import(pathToFileURL(bundlePath).href).catch((err) => {
|
|
59
|
+
bundleCacheByCwd.delete(bundlePath);
|
|
60
|
+
console.error(`[Dinou Netlify Adapter] Failed to load ${bundlePath}:`, err);
|
|
61
|
+
return null;
|
|
62
|
+
});
|
|
63
|
+
bundleCacheByCwd.set(bundlePath, { mtimeMs, promise: loadPromise });
|
|
64
|
+
return loadPromise;
|
|
56
65
|
}
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
const initialCwd =
|
|
68
|
+
typeof process !== "undefined" && typeof process.cwd === "function"
|
|
69
|
+
? process.cwd()
|
|
70
|
+
: ".";
|
|
71
|
+
if (resolveNetlifyBundlePath(initialCwd)) {
|
|
72
|
+
await getNetlifyBundle(initialCwd);
|
|
73
|
+
}
|
|
59
74
|
|
|
60
75
|
/**
|
|
61
76
|
* Netlify Function v2 handler
|
|
62
|
-
* @param {Request} request
|
|
63
|
-
* @param {object} context
|
|
77
|
+
* @param {Request} request
|
|
78
|
+
* @param {object} context
|
|
64
79
|
* @returns {Promise<Response>}
|
|
65
80
|
*/
|
|
66
81
|
export default async function netlifyHandler(request, context) {
|
|
67
|
-
|
|
82
|
+
const cwd =
|
|
83
|
+
typeof process !== "undefined" && typeof process.cwd === "function"
|
|
84
|
+
? process.cwd()
|
|
85
|
+
: initialCwd;
|
|
86
|
+
const mod = await getNetlifyBundle(cwd);
|
|
87
|
+
const fn =
|
|
88
|
+
mod && typeof mod.default === "function"
|
|
89
|
+
? mod.default
|
|
90
|
+
: mod && typeof mod.netlifyHandler === "function"
|
|
91
|
+
? mod.netlifyHandler
|
|
92
|
+
: null;
|
|
93
|
+
|
|
94
|
+
if (fn) {
|
|
95
|
+
return fn(request, context);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return new Response(
|
|
99
|
+
"Dinou Netlify bundle not found. Please run 'npm run build' or 'npx dinou build:netlify' first.",
|
|
100
|
+
{
|
|
101
|
+
status: 500,
|
|
102
|
+
headers: { "content-type": "text/plain; charset=utf-8" },
|
|
103
|
+
}
|
|
104
|
+
);
|
|
68
105
|
}
|
|
69
106
|
|
|
70
107
|
export const config = {
|
|
71
108
|
path: "/*",
|
|
72
109
|
preferStatic: true,
|
|
73
110
|
};
|
|
74
|
-
|
package/dinou/adapters/node.js
CHANGED
|
@@ -6,6 +6,14 @@ import * as path from "node:path";
|
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
|
+
import { loadEnvFiles } from "../core/env.js";
|
|
10
|
+
|
|
11
|
+
loadEnvFiles(
|
|
12
|
+
typeof process !== "undefined" && typeof process.cwd === "function"
|
|
13
|
+
? process.cwd()
|
|
14
|
+
: ".",
|
|
15
|
+
{ mode: "production" }
|
|
16
|
+
);
|
|
9
17
|
|
|
10
18
|
import ensureVendorMode from "../core/ensure-vendor-mode.js";
|
|
11
19
|
if (!ensureVendorMode()) {
|
package/dinou/assets.d.ts
CHANGED
|
@@ -50,11 +50,6 @@ declare module "*.webm" {
|
|
|
50
50
|
export default value;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
declare module "*.ogg" {
|
|
54
|
-
const value: string;
|
|
55
|
-
export default value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
53
|
declare module "*.mov" {
|
|
59
54
|
const value: string;
|
|
60
55
|
export default value;
|
|
@@ -81,6 +76,11 @@ declare module "*.mjpg" {
|
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
// Audio
|
|
79
|
+
declare module "*.ogg" {
|
|
80
|
+
const value: string;
|
|
81
|
+
export default value;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
84
|
declare module "*.mp3" {
|
|
85
85
|
const value: string;
|
|
86
86
|
export default value;
|
|
@@ -106,3 +106,30 @@ declare module "*.aac" {
|
|
|
106
106
|
export default value;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
// Fonts
|
|
110
|
+
declare module "*.woff" {
|
|
111
|
+
const value: string;
|
|
112
|
+
export default value;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare module "*.woff2" {
|
|
116
|
+
const value: string;
|
|
117
|
+
export default value;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare module "*.ttf" {
|
|
121
|
+
const value: string;
|
|
122
|
+
export default value;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare module "*.otf" {
|
|
126
|
+
const value: string;
|
|
127
|
+
export default value;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare module "*.eot" {
|
|
131
|
+
const value: string;
|
|
132
|
+
export default value;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|