dinou 6.1.1 → 7.1.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 +106 -0
- package/README.md +9352 -1081
- package/cli.js +314 -91
- 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 +322 -165
- 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 +175 -96
- package/dinou/core/handler.js +2303 -0
- package/dinou/core/http-adapter.js +115 -0
- package/dinou/core/import-module.js +83 -53
- package/dinou/core/layout-functions.js +183 -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 +252 -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 +91 -87
- package/dinou/core/request-context.js +47 -13
- package/dinou/core/resolve-module-ppr.js +34 -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 +113 -34
- package/package.json +18 -16
- 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,115 @@
|
|
|
1
|
+
// dinou/deno/seed-kv.js
|
|
2
|
+
// Pre-seeds Deno KV database (Local SQLite or Remote Deno Deploy KV) with static SSG pages.
|
|
3
|
+
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
|
|
7
|
+
const cwd = typeof Deno !== "undefined" && typeof Deno.cwd === "function" ? Deno.cwd() : process.cwd();
|
|
8
|
+
const kvUrl = typeof Deno !== "undefined" ? Deno.env.get("DENO_KV_URL") : process.env.DENO_KV_URL;
|
|
9
|
+
const dist2Dir = path.resolve(cwd, ".dinou/dist2");
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(dist2Dir)) {
|
|
12
|
+
console.log("ℹ️ [Deno KV Seed] No static files found at .dinou/dist2. Skipping KV pre-seed.");
|
|
13
|
+
if (typeof Deno !== "undefined") Deno.exit(0);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let kv;
|
|
17
|
+
if (kvUrl) {
|
|
18
|
+
console.log(`🌐 [Deno KV Seed] Connecting to remote Deno KV: ${kvUrl}...`);
|
|
19
|
+
kv = await Deno.openKv(kvUrl);
|
|
20
|
+
} else {
|
|
21
|
+
const defaultDbPath = path.resolve(cwd, ".dinou/kv.db");
|
|
22
|
+
const kvPath = (typeof Deno !== "undefined" ? Deno.env.get("DENO_KV_PATH") : process.env.DENO_KV_PATH) || defaultDbPath;
|
|
23
|
+
fs.mkdirSync(path.dirname(kvPath), { recursive: true });
|
|
24
|
+
try {
|
|
25
|
+
if (fs.existsSync(kvPath)) fs.unlinkSync(kvPath);
|
|
26
|
+
if (fs.existsSync(kvPath + "-wal")) fs.unlinkSync(kvPath + "-wal");
|
|
27
|
+
if (fs.existsSync(kvPath + "-shm")) fs.unlinkSync(kvPath + "-shm");
|
|
28
|
+
} catch (e) {}
|
|
29
|
+
console.log(`💾 [Deno KV Seed] Pre-seeding local Deno KV at ${kvPath}...`);
|
|
30
|
+
kv = await Deno.openKv(kvPath);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const KV_CHUNK_SIZE = 16384;
|
|
34
|
+
|
|
35
|
+
async function setKvCache(kvInstance, key, content, metadata = null) {
|
|
36
|
+
if (typeof content === "string" && content.length > KV_CHUNK_SIZE) {
|
|
37
|
+
const totalChunks = Math.ceil(content.length / KV_CHUNK_SIZE);
|
|
38
|
+
const atomic = kvInstance.atomic();
|
|
39
|
+
atomic.set(["dinou_cache", key], {
|
|
40
|
+
chunked: true,
|
|
41
|
+
totalChunks,
|
|
42
|
+
metadata,
|
|
43
|
+
});
|
|
44
|
+
for (let i = 0; i < totalChunks; i++) {
|
|
45
|
+
const chunk = content.slice(i * KV_CHUNK_SIZE, (i + 1) * KV_CHUNK_SIZE);
|
|
46
|
+
atomic.set(["dinou_cache_chunk", key, i], chunk);
|
|
47
|
+
}
|
|
48
|
+
await atomic.commit();
|
|
49
|
+
} else {
|
|
50
|
+
await kvInstance.set(["dinou_cache", key], {
|
|
51
|
+
chunked: false,
|
|
52
|
+
content,
|
|
53
|
+
metadata,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let seededCount = 0;
|
|
59
|
+
|
|
60
|
+
async function processDir(dir, relPrefix = "") {
|
|
61
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
const fullPath = path.join(dir, entry.name);
|
|
64
|
+
const relPath = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
|
|
65
|
+
const cleanRelPath = relPath.replace(/\\/g, "/");
|
|
66
|
+
|
|
67
|
+
if (entry.isDirectory()) {
|
|
68
|
+
await processDir(fullPath, cleanRelPath);
|
|
69
|
+
} else if (entry.name === "index.html") {
|
|
70
|
+
const html = fs.readFileSync(fullPath, "utf8");
|
|
71
|
+
let metadata = null;
|
|
72
|
+
const metaPath = path.join(dir, "metadata.json");
|
|
73
|
+
if (fs.existsSync(metaPath)) {
|
|
74
|
+
try {
|
|
75
|
+
metadata = JSON.parse(fs.readFileSync(metaPath, "utf8"));
|
|
76
|
+
} catch (e) {}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
await setKvCache(kv, cleanRelPath, html, metadata);
|
|
80
|
+
seededCount++;
|
|
81
|
+
if (process.env.DINOU_DEBUG) {
|
|
82
|
+
console.log(` ✅ Cached HTML: ${cleanRelPath}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (cleanRelPath.endsWith("/index.html")) {
|
|
86
|
+
const folderKey = cleanRelPath.slice(0, -11);
|
|
87
|
+
await setKvCache(kv, folderKey, html, metadata);
|
|
88
|
+
} else if (cleanRelPath === "index.html") {
|
|
89
|
+
await setKvCache(kv, "", html, metadata);
|
|
90
|
+
}
|
|
91
|
+
} else if (entry.name.endsWith("metadata.json")) {
|
|
92
|
+
const metaContent = fs.readFileSync(fullPath, "utf8");
|
|
93
|
+
let metadata = null;
|
|
94
|
+
try {
|
|
95
|
+
metadata = JSON.parse(metaContent);
|
|
96
|
+
} catch (e) {}
|
|
97
|
+
await setKvCache(kv, cleanRelPath, metaContent, metadata);
|
|
98
|
+
seededCount++;
|
|
99
|
+
if (process.env.DINOU_DEBUG) {
|
|
100
|
+
console.log(` ✅ Cached Meta: ${cleanRelPath}`);
|
|
101
|
+
}
|
|
102
|
+
} else if (entry.name.endsWith(".rsc")) {
|
|
103
|
+
const rsc = fs.readFileSync(fullPath, "utf8");
|
|
104
|
+
await setKvCache(kv, cleanRelPath, rsc, null);
|
|
105
|
+
seededCount++;
|
|
106
|
+
if (process.env.DINOU_DEBUG) {
|
|
107
|
+
console.log(` ✅ Cached RSC: ${cleanRelPath}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
await processDir(dist2Dir);
|
|
114
|
+
await kv.close();
|
|
115
|
+
console.log(`🎉 [Deno KV Seed] Finished successfully! ${seededCount} file(s) cached in KV.\n`);
|
package/dinou/esbuild/build.mjs
CHANGED
|
@@ -22,10 +22,13 @@ const absPathToLink = path.resolve(
|
|
|
22
22
|
__dirname,
|
|
23
23
|
"../core/link.jsx"
|
|
24
24
|
);
|
|
25
|
+
const absPathToSlot = path.resolve(
|
|
26
|
+
__dirname,
|
|
27
|
+
"../core/slot.js"
|
|
28
|
+
);
|
|
25
29
|
|
|
26
30
|
const frameworkEntryPoints = {
|
|
27
31
|
main: path.resolve(__dirname, "../core/client.jsx"),
|
|
28
|
-
error: path.resolve(__dirname, "../core/client-error.jsx"),
|
|
29
32
|
serverFunctionProxy: path.resolve(
|
|
30
33
|
__dirname,
|
|
31
34
|
"../core/server-function-proxy.js"
|
|
@@ -37,6 +40,7 @@ const frameworkEntryPoints = {
|
|
|
37
40
|
),
|
|
38
41
|
dinouClientRedirect: absPathToClientRedirect,
|
|
39
42
|
dinouLink: absPathToLink,
|
|
43
|
+
dinouSlot: absPathToSlot,
|
|
40
44
|
};
|
|
41
45
|
|
|
42
46
|
try {
|
|
@@ -57,6 +61,12 @@ try {
|
|
|
57
61
|
true,
|
|
58
62
|
manifest
|
|
59
63
|
);
|
|
64
|
+
updateManifestForModule(
|
|
65
|
+
absPathToSlot,
|
|
66
|
+
await fs.readFile(absPathToSlot, "utf8"),
|
|
67
|
+
true,
|
|
68
|
+
manifest
|
|
69
|
+
);
|
|
60
70
|
|
|
61
71
|
const componentEntryPoints = [...esbuildEntries].reduce(
|
|
62
72
|
(acc, dCE) => ({ ...acc, [dCE.outfileName]: dCE.absPath }),
|
|
@@ -87,6 +97,46 @@ try {
|
|
|
87
97
|
outdir,
|
|
88
98
|
})
|
|
89
99
|
);
|
|
100
|
+
|
|
101
|
+
// 🚀 Server & Adapter Pre-bundling with react-server condition
|
|
102
|
+
console.log("⚡ [esbuild] Pre-bundling server handler and adapters (conditions: ['react-server'])...");
|
|
103
|
+
await esbuild.build({
|
|
104
|
+
entryPoints: {
|
|
105
|
+
handler: path.resolve(__dirname, "../core/handler.js"),
|
|
106
|
+
netlify: path.resolve(__dirname, "../adapters/netlify.js"),
|
|
107
|
+
},
|
|
108
|
+
bundle: true,
|
|
109
|
+
platform: "node",
|
|
110
|
+
target: "node20",
|
|
111
|
+
format: "esm",
|
|
112
|
+
conditions: ["react-server", "node", "import"],
|
|
113
|
+
outdir: ".dinou/dist3/server",
|
|
114
|
+
external: [
|
|
115
|
+
"express",
|
|
116
|
+
"chokidar",
|
|
117
|
+
"dotenv",
|
|
118
|
+
"fsevents",
|
|
119
|
+
"@swc/core",
|
|
120
|
+
"@babel/core",
|
|
121
|
+
"esbuild",
|
|
122
|
+
],
|
|
123
|
+
banner: {
|
|
124
|
+
js: "import { createRequire as ___createRequire } from 'node:module'; import { fileURLToPath as ___fileURLToPath } from 'node:url'; import ___path from 'node:path'; const require = ___createRequire(import.meta.url || ___path.resolve(process.cwd(), 'package.json')); const __filename = import.meta.url ? ___fileURLToPath(import.meta.url) : ___path.resolve(process.cwd(), 'index.js'); const __dirname = ___path.dirname(__filename); process.env.NODE_ENV = process.env.NODE_ENV || 'production';",
|
|
125
|
+
},
|
|
126
|
+
sourcemap: true,
|
|
127
|
+
});
|
|
128
|
+
await fs.writeFile(
|
|
129
|
+
path.resolve(process.cwd(), ".dinou/dist3/server/package.json"),
|
|
130
|
+
JSON.stringify({ type: "module" }, null, 2)
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// 🏗️ Pre-render static pages (SSG) at build time
|
|
134
|
+
const { execSync } = await import("node:child_process");
|
|
135
|
+
execSync(`"${process.execPath}" --conditions=react-server "${path.resolve(__dirname, "../core/run-ssg.js")}"`, {
|
|
136
|
+
stdio: "inherit",
|
|
137
|
+
env: { ...process.env, NODE_ENV: "production" },
|
|
138
|
+
});
|
|
90
139
|
} catch (err) {
|
|
91
140
|
console.error("Error in build:", err);
|
|
141
|
+
process.exit(1);
|
|
92
142
|
}
|