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.
Files changed (135) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/README.md +9461 -1080
  3. package/cli.js +392 -169
  4. package/dinou/adapters/bun.js +62 -0
  5. package/dinou/adapters/cloudflare.js +65 -0
  6. package/dinou/adapters/deno.js +48 -0
  7. package/dinou/adapters/netlify.js +85 -0
  8. package/dinou/adapters/node.mjs +31 -0
  9. package/dinou/bun/build.mjs +1077 -0
  10. package/dinou/cloudflare/build.mjs +1121 -0
  11. package/dinou/cloudflare/shims/child_process.js +14 -0
  12. package/dinou/cloudflare/shims/empty.js +2 -0
  13. package/dinou/cloudflare/shims/fs.js +99 -0
  14. package/dinou/cloudflare/shims/os.js +29 -0
  15. package/dinou/config.js +1 -0
  16. package/dinou/config.mjs +2 -0
  17. package/dinou/constants.js +29 -4
  18. package/dinou/core/babel-esm-loader.js +66 -37
  19. package/dinou/core/bailout-proxy.js +61 -0
  20. package/dinou/core/build-static-pages.js +309 -157
  21. package/dinou/core/cache-revalidate.js +471 -144
  22. package/dinou/core/cache-slot.js +387 -0
  23. package/dinou/core/client-redirect.jsx +12 -7
  24. package/dinou/core/client-webpack.jsx +457 -82
  25. package/dinou/core/client.jsx +452 -82
  26. package/dinou/core/config.js +11 -0
  27. package/dinou/core/dinou-paths.js +52 -0
  28. package/dinou/core/edge-ssr.js +122 -0
  29. package/dinou/core/export-static.mjs +64 -0
  30. package/dinou/core/generate-route-types.js +252 -0
  31. package/dinou/core/generate-static-page.js +55 -94
  32. package/dinou/core/generate-static-rsc.js +47 -15
  33. package/dinou/core/generate-static.js +212 -10
  34. package/dinou/core/generating-isg.js +5 -0
  35. package/dinou/core/get-asset-from-manifest.js +9 -3
  36. package/dinou/core/get-error-jsx.js +221 -41
  37. package/dinou/core/get-file-path-and-dynamic-params.js +9 -13
  38. package/dinou/core/get-jsx.js +172 -95
  39. package/dinou/core/handler.js +2296 -0
  40. package/dinou/core/http-adapter.js +115 -0
  41. package/dinou/core/import-module.js +83 -53
  42. package/dinou/core/layout-functions.js +181 -0
  43. package/dinou/core/link.jsx +18 -6
  44. package/dinou/core/load-dinou-config.js +60 -0
  45. package/dinou/core/manifest-provider.js +261 -0
  46. package/dinou/core/navigation-utils.js +4 -0
  47. package/dinou/core/navigation.js +50 -39
  48. package/dinou/core/parse-exports.js +207 -2
  49. package/dinou/core/ppr-context.js +105 -0
  50. package/dinou/core/ppr-runtime.js +263 -0
  51. package/dinou/core/redirect.jsx +20 -19
  52. package/dinou/core/render-jsx-to-client-jsx.js +133 -15
  53. package/dinou/core/request-context.js +47 -13
  54. package/dinou/core/resolve-module-ppr.js +32 -0
  55. package/dinou/core/revalidating.js +28 -9
  56. package/dinou/core/route-generator.js +107 -0
  57. package/dinou/core/rsc-renderer.js +90 -0
  58. package/dinou/core/run-ssg.js +19 -0
  59. package/dinou/core/scan-dependency-components.js +218 -0
  60. package/dinou/core/server-function-proxy-webpack.js +3 -0
  61. package/dinou/core/server-function-proxy.js +3 -0
  62. package/dinou/core/slot.js +302 -0
  63. package/dinou/core/status-manifest.js +41 -1
  64. package/dinou/core/storage-adapter.js +522 -0
  65. package/dinou/core/url-resolver.js +16 -16
  66. package/dinou/core/vfs.js +139 -68
  67. package/dinou/deno/build.mjs +1112 -0
  68. package/dinou/deno/seed-kv.js +115 -0
  69. package/dinou/esbuild/build.mjs +51 -1
  70. package/dinou/esbuild/dev.mjs +290 -224
  71. package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.mjs +3 -2
  72. package/dinou/esbuild/helpers-esbuild/get-config-esbuild.mjs +104 -16
  73. package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.mjs +31 -19
  74. package/dinou/esbuild/helpers-esbuild/strip-namespace.mjs +9 -0
  75. package/dinou/esbuild/helpers-esbuild/swc-disk-cache.mjs +225 -0
  76. package/dinou/esbuild/helpers-esbuild/update-manifest-for-module.mjs +7 -0
  77. package/dinou/esbuild/helpers-esbuild/write.mjs +111 -2
  78. package/dinou/esbuild/plugins-esbuild/assets-plugin.mjs +236 -161
  79. package/dinou/esbuild/plugins-esbuild/css-processor-plugin.mjs +101 -5
  80. package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.mjs +63 -24
  81. package/dinou/esbuild/plugins-esbuild/server-functions-plugin.mjs +177 -56
  82. package/dinou/esbuild/plugins-esbuild/skip-missing-entry-points-plugin.mjs +3 -0
  83. package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.mjs +182 -137
  84. package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +38 -11
  85. package/dinou/esbuild/react-refresh/esm-hmr/client.mjs +55 -8
  86. package/dinou/esbuild/react-refresh/esm-hmr/server.js +1 -1
  87. package/dinou/esbuild/react-refresh/esm-hmr-plugin.mjs +238 -101
  88. package/dinou/esbuild/react-refresh/is-react-refresh-boundary.mjs +18 -4
  89. package/dinou/index.d.ts +315 -11
  90. package/dinou/index.js +12 -6
  91. package/dinou/index.mjs +9 -0
  92. package/dinou/node/build.mjs +195 -0
  93. package/dinou/node/bundle-dual-engine.mjs +1012 -0
  94. package/dinou/node/dev.mjs +2589 -0
  95. package/dinou/node/port-selector.mjs +164 -0
  96. package/dinou/node/terminal-status.mjs +345 -0
  97. package/dinou/package.json +16 -14
  98. package/dinou/rollup/react-refresh/esm-hmr/client.js +66 -10
  99. package/dinou/rollup/react-refresh/esm-hmr/server.js +1 -1
  100. package/dinou/rollup/react-refresh/is-react-refresh-boundary.js +24 -5
  101. package/dinou/rollup/react-refresh/react-refresh-runtime.js +13 -6
  102. package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +56 -11
  103. package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +176 -48
  104. package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +9 -5
  105. package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +66 -0
  106. package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +468 -123
  107. package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +44 -12
  108. package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +100 -0
  109. package/dinou/rollup/rollup.config.js +155 -43
  110. package/dinou/server.d.ts +114 -12
  111. package/dinou/server.js +35 -10
  112. package/dinou/server.mjs +30 -9
  113. package/dinou/webpack/helpers/get-webpack-entries.js +14 -19
  114. package/dinou/webpack/loaders/server-functions-loader.js +22 -1
  115. package/dinou/webpack/loaders/swc-loader.js +76 -0
  116. package/dinou/webpack/plugins/manifest-generator-plugin.js +1 -0
  117. package/dinou/webpack/plugins/server-functions-plugin.js +75 -19
  118. package/dinou/webpack/plugins/webpack-memory-plugin.js +66 -0
  119. package/dinou/webpack/webpack.config.js +227 -29
  120. package/eject.js +173 -94
  121. package/package.json +110 -108
  122. package/dinou/core/asset-require-hook.js +0 -58
  123. package/dinou/core/client-error-webpack.jsx +0 -432
  124. package/dinou/core/client-error.jsx +0 -432
  125. package/dinou/core/concurrency-manager.js +0 -48
  126. package/dinou/core/context-proxy.js +0 -68
  127. package/dinou/core/generate-static-pages.js +0 -130
  128. package/dinou/core/generate-static-rscs.js +0 -151
  129. package/dinou/core/get-ssg-metadata.js +0 -31
  130. package/dinou/core/register-loader.mjs +0 -11
  131. package/dinou/core/register-paths.js +0 -27
  132. package/dinou/core/render-app-to-html.js +0 -430
  133. package/dinou/core/render-html.js +0 -407
  134. package/dinou/core/server.js +0 -1542
  135. package/dinou/esbuild/plugins-esbuild/write-metafile-plugin.mjs +0 -16
package/dinou/core/vfs.js CHANGED
@@ -1,68 +1,139 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
-
4
- const isDevelopment = process.env.NODE_ENV !== "production";
5
- const vfs = {};
6
-
7
- function buildVfs(dir) {
8
- if (!fs.existsSync(dir)) return;
9
- const entries = fs.readdirSync(dir, { withFileTypes: true });
10
- const children = [];
11
-
12
- for (const entry of entries) {
13
- const fullPath = path.join(dir, entry.name);
14
- const isDirectory = entry.isDirectory();
15
- children.push({
16
- name: entry.name,
17
- isDirectory
18
- });
19
- if (isDirectory) {
20
- buildVfs(fullPath);
21
- } else {
22
- vfs[fullPath] = { type: "file" };
23
- }
24
- }
25
-
26
- vfs[dir] = {
27
- type: "directory",
28
- children
29
- };
30
- }
31
-
32
- if (!isDevelopment) {
33
- const srcDir = path.resolve(process.cwd(), "src");
34
- buildVfs(srcDir);
35
- }
36
-
37
- function existsSync(filePath) {
38
- if (isDevelopment) {
39
- return fs.existsSync(filePath);
40
- }
41
- const normalized = path.resolve(filePath);
42
- return !!vfs[normalized];
43
- }
44
-
45
- function readdirSync(dirPath, options) {
46
- if (isDevelopment) {
47
- return fs.readdirSync(dirPath, options);
48
- }
49
- const normalized = path.resolve(dirPath);
50
- const entry = vfs[normalized];
51
- if (!entry || entry.type !== "directory") {
52
- throw new Error(`ENOTDIR: not a directory, readdir '${dirPath}'`);
53
- }
54
-
55
- if (options && options.withFileTypes) {
56
- return entry.children.map(child => ({
57
- name: child.name,
58
- isDirectory: () => child.isDirectory,
59
- isFile: () => !child.isDirectory
60
- }));
61
- }
62
- return entry.children.map(child => child.name);
63
- }
64
-
65
- module.exports = {
66
- existsSync,
67
- readdirSync
68
- };
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const isDevelopment =
5
+ process.env.DINOU_DEV === "true" ||
6
+ (typeof globalThis !== "undefined" && Boolean(globalThis.__DINOU_DEV__)) ||
7
+ process.env.NODE_ENV !== "production";
8
+ const localVfs = {};
9
+
10
+ function getVfs() {
11
+ if (typeof globalThis !== "undefined" && globalThis.__DINOU_VFS__) {
12
+ return globalThis.__DINOU_VFS__;
13
+ }
14
+ return localVfs;
15
+ }
16
+
17
+ function normalizeKey(p) {
18
+ if (!p) return "";
19
+ let s = String(p).replace(/\\/g, "/");
20
+ if (s.length > 2 && s[1] === ":") s = s.slice(2);
21
+ return s;
22
+ }
23
+
24
+ function buildVfs(dir, baseDir = dir) {
25
+ const vfs = getVfs();
26
+ if (!fs.existsSync(dir)) return;
27
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
28
+ const children = [];
29
+
30
+ for (const entry of entries) {
31
+ const fullPath = path.join(dir, entry.name);
32
+ const isDirectory = entry.isDirectory();
33
+ children.push({
34
+ name: entry.name,
35
+ isDirectory
36
+ });
37
+ const slashPath = fullPath.replace(/\\/g, "/");
38
+ const relFromSrc = path.relative(baseDir, fullPath).replace(/\\/g, "/");
39
+ if (isDirectory) {
40
+ buildVfs(fullPath, baseDir);
41
+ } else {
42
+ vfs[normalizeKey(fullPath)] = { type: "file" };
43
+ vfs[slashPath] = { type: "file" };
44
+ vfs["src/" + relFromSrc] = { type: "file" };
45
+ vfs["/src/" + relFromSrc] = { type: "file" };
46
+ }
47
+ }
48
+
49
+ const slashDir = dir.replace(/\\/g, "/");
50
+ const relDir = path.relative(baseDir, dir).replace(/\\/g, "/");
51
+ const entry = { type: "directory", children };
52
+ vfs[normalizeKey(dir)] = entry;
53
+ vfs[slashDir] = entry;
54
+ vfs[relDir ? "src/" + relDir : "src"] = entry;
55
+ vfs[relDir ? "/src/" + relDir : "/src"] = entry;
56
+ }
57
+
58
+ if (!isDevelopment) {
59
+ try {
60
+ const srcDir = path.resolve(process.cwd(), "src");
61
+ if (Object.keys(getVfs()).length === 0 && fs.existsSync && fs.existsSync(srcDir)) {
62
+ buildVfs(srcDir, srcDir);
63
+ }
64
+ } catch (e) {}
65
+ }
66
+
67
+ function lookupVfs(vfs, p) {
68
+ if (!vfs || !p) return null;
69
+ if (vfs[p]) return vfs[p];
70
+
71
+ const s = String(p).split("\\").join("/");
72
+ if (vfs[s]) return vfs[s];
73
+
74
+ if (s.length > 2 && s[1] === ":") {
75
+ const noDrive = s.slice(2);
76
+ if (vfs[noDrive]) return vfs[noDrive];
77
+ }
78
+
79
+ const idx = s.indexOf("/src");
80
+ if (idx !== -1) {
81
+ const fromSlash = s.slice(idx);
82
+ if (vfs[fromSlash]) return vfs[fromSlash];
83
+ const noSlash = fromSlash.slice(1);
84
+ if (vfs[noSlash]) return vfs[noSlash];
85
+ } else if (s.startsWith("src/") || s === "src") {
86
+ if (vfs[s]) return vfs[s];
87
+ if (vfs["/" + s]) return vfs["/" + s];
88
+ }
89
+
90
+ const trimmed = s.replace(/^\/+/, "");
91
+ if (vfs[trimmed]) return vfs[trimmed];
92
+ if (vfs["/" + trimmed]) return vfs["/" + trimmed];
93
+
94
+ return null;
95
+ }
96
+
97
+ function existsSync(filePath) {
98
+ const vfs = getVfs();
99
+ if (lookupVfs(vfs, filePath) !== null) {
100
+ return true;
101
+ }
102
+ try {
103
+ if (typeof fs.existsSync === "function" && fs.existsSync(filePath)) {
104
+ return true;
105
+ }
106
+ } catch (e) {}
107
+ return false;
108
+ }
109
+
110
+ function readdirSync(dirPath, options) {
111
+ const vfs = getVfs();
112
+ const entry = lookupVfs(vfs, dirPath);
113
+
114
+ if (entry && entry.type === "directory" && Array.isArray(entry.children)) {
115
+ if (options && options.withFileTypes) {
116
+ return entry.children.map(child => ({
117
+ name: child.name,
118
+ isDirectory: () => child.isDirectory,
119
+ isFile: () => !child.isDirectory
120
+ }));
121
+ }
122
+ return entry.children.map(child => child.name);
123
+ }
124
+
125
+ try {
126
+ if (typeof fs.readdirSync === "function") {
127
+ const res = fs.readdirSync(dirPath, options);
128
+ if (res) return res;
129
+ }
130
+ } catch (e) {}
131
+ return [];
132
+ }
133
+
134
+ module.exports = {
135
+ existsSync,
136
+ readdirSync,
137
+ buildVfs,
138
+ getVfs,
139
+ };