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.
Files changed (166) hide show
  1. package/CHANGELOG.md +196 -0
  2. package/README.md +157 -132
  3. package/dinou/adapters/bun.js +34 -5
  4. package/dinou/adapters/cloudflare.js +110 -17
  5. package/dinou/adapters/deno.js +46 -8
  6. package/dinou/adapters/netlify.js +86 -50
  7. package/dinou/adapters/node.js +8 -0
  8. package/dinou/assets.d.ts +32 -5
  9. package/dinou/bun/build.js +190 -106
  10. package/dinou/cli.js +992 -532
  11. package/dinou/cloudflare/build.js +187 -106
  12. package/dinou/compiled/autoprefixer/index.js +509 -517
  13. package/dinou/compiled/babel-core/index.js +738 -716
  14. package/dinou/compiled/babel-generator/index.js +341 -299
  15. package/dinou/compiled/babel-loader/index.js +766 -744
  16. package/dinou/compiled/babel-parser/index.js +2 -2
  17. package/dinou/compiled/babel-plugin-react-compiler/index.js +178 -178
  18. package/dinou/compiled/babel-plugin-syntax-import-meta/index.js +4 -4
  19. package/dinou/compiled/babel-preset-react/index.js +752 -730
  20. package/dinou/compiled/babel-preset-typescript/index.js +738 -716
  21. package/dinou/compiled/babel-traverse/index.js +463 -433
  22. package/dinou/compiled/babel-types/index.js +176 -176
  23. package/dinou/compiled/chokidar/index.js +4 -4
  24. package/dinou/compiled/commander/index.js +15 -15
  25. package/dinou/compiled/copy-webpack-plugin/index.js +433 -425
  26. package/dinou/compiled/css-loader/index.js +289 -289
  27. package/dinou/compiled/css-loader/runtime/api.js +85 -0
  28. package/dinou/compiled/css-loader/runtime/getUrl.js +26 -0
  29. package/dinou/compiled/css-loader/runtime/noSourceMaps.js +5 -0
  30. package/dinou/compiled/css-loader/runtime/package.json +3 -0
  31. package/dinou/compiled/css-loader/runtime/sourceMaps.js +16 -0
  32. package/dinou/compiled/fast-glob/index.js +5810 -0
  33. package/dinou/compiled/generic-names/index.js +16 -16
  34. package/dinou/compiled/mini-css-extract-plugin/{chunk-YYEJWYXE.js → chunk-R6DP5ZYM.js} +36 -36
  35. package/dinou/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +253 -0
  36. package/dinou/compiled/mini-css-extract-plugin/hmr/normalize-url.js +39 -0
  37. package/dinou/compiled/mini-css-extract-plugin/hmr/package.json +3 -0
  38. package/dinou/compiled/mini-css-extract-plugin/index.js +1 -1
  39. package/dinou/compiled/mini-css-extract-plugin/loader.js +5 -5
  40. package/dinou/compiled/postcss/index.js +83 -83
  41. package/dinou/compiled/postcss-import/index.js +147 -117
  42. package/dinou/compiled/postcss-modules/index.js +216 -216
  43. package/dinou/compiled/resolve/index.js +1224 -0
  44. package/dinou/compiled/rollup-plugin-babel/index.js +753 -731
  45. package/dinou/compiled/rollup-plugin-commonjs/index.js +43 -38
  46. package/dinou/compiled/rollup-plugin-delete/index.js +615 -253
  47. package/dinou/compiled/rollup-plugin-json/index.js +22 -18
  48. package/dinou/compiled/rollup-plugin-node-resolve/index.js +130 -100
  49. package/dinou/compiled/rollup-plugin-postcss/index.js +3299 -3277
  50. package/dinou/compiled/rollup-plugin-replace/index.js +34 -29
  51. package/dinou/compiled/tailwindcss-postcss/index.js +214 -211
  52. package/dinou/compiled/vendors-manifest.json +59 -83
  53. package/dinou/core/asset-extensions.js +482 -33
  54. package/dinou/core/bailout-proxy.js +21 -2
  55. package/dinou/core/build-static-pages.js +523 -371
  56. package/dinou/core/builtin-asset-extensions.js +63 -0
  57. package/dinou/core/cache-revalidate.js +449 -256
  58. package/dinou/core/cache-slot.js +289 -79
  59. package/dinou/core/client-webpack.jsx +470 -39
  60. package/dinou/core/client.jsx +402 -39
  61. package/dinou/core/config.js +3 -0
  62. package/dinou/core/copy-static-dirs.js +98 -0
  63. package/dinou/core/createScopedName.js +22 -4
  64. package/dinou/core/dinou-paths.js +1 -1
  65. package/dinou/core/discover-layouts.js +200 -0
  66. package/dinou/core/edge-ssr.js +1 -1
  67. package/dinou/core/ensure-vendor-mode.js +78 -19
  68. package/dinou/core/env.js +544 -0
  69. package/dinou/core/export-static.js +41 -9
  70. package/dinou/core/generate-route-types.js +989 -95
  71. package/dinou/core/generate-static-rsc.js +5 -6
  72. package/dinou/core/generate-static.js +45 -6
  73. package/dinou/core/get-abs-path-with-ext.js +217 -75
  74. package/dinou/core/get-asset-from-manifest.js +19 -8
  75. package/dinou/core/get-error-jsx.js +4 -5
  76. package/dinou/core/get-file-path-and-dynamic-params.js +561 -338
  77. package/dinou/core/get-jsx.js +220 -53
  78. package/dinou/core/handler.js +1647 -466
  79. package/dinou/core/import-module.js +7 -0
  80. package/dinou/core/layout-functions.js +72 -13
  81. package/dinou/core/link.jsx +34 -6
  82. package/dinou/core/load-dinou-config.js +520 -89
  83. package/dinou/core/manifest-provider.js +4 -14
  84. package/dinou/core/navigation-utils.js +141 -3
  85. package/dinou/core/navigation.js +134 -50
  86. package/dinou/core/node-middleware-runner.js +165 -0
  87. package/dinou/core/postcss-pipeline.js +236 -0
  88. package/dinou/core/ppr-context.js +114 -22
  89. package/dinou/core/ppr-runtime.js +391 -127
  90. package/dinou/core/redirect.jsx +1 -1
  91. package/dinou/core/render-jsx-to-client-jsx.js +216 -48
  92. package/dinou/core/request-context.js +59 -3
  93. package/dinou/core/resolve-contextual-dinou.js +523 -0
  94. package/dinou/core/resolve-setup-files.js +85 -27
  95. package/dinou/core/revalidating.js +10 -2
  96. package/dinou/core/route-generator.js +6 -2
  97. package/dinou/core/rsc-renderer.js +4 -1
  98. package/dinou/core/run-ssg.js +6 -0
  99. package/dinou/core/runtime-env.js +265 -0
  100. package/dinou/core/server-css-modules-plugin.js +155 -0
  101. package/dinou/core/server-function-proxy-webpack.js +27 -2
  102. package/dinou/core/server-function-proxy.js +27 -2
  103. package/dinou/core/slot.js +47 -2
  104. package/dinou/core/static-assets.js +503 -0
  105. package/dinou/core/storage-adapter.js +452 -24
  106. package/dinou/core/transform-server-functions.js +272 -24
  107. package/dinou/core/tsconfig-aliases.js +964 -0
  108. package/dinou/core/uneject.js +640 -0
  109. package/dinou/core/url-resolver.js +1 -1
  110. package/dinou/core/vfs.js +11 -2
  111. package/dinou/css.d.ts +4 -1
  112. package/dinou/deno/build.js +205 -153
  113. package/dinou/deno/seed-kv.js +4 -0
  114. package/dinou/env.d.ts +22 -2
  115. package/dinou/esbuild/build.js +40 -50
  116. package/dinou/esbuild/dev.js +33 -7
  117. package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.js +41 -16
  118. package/dinou/esbuild/helpers-esbuild/get-config-esbuild.js +51 -49
  119. package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.js +73 -60
  120. package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +35 -16
  121. package/dinou/esbuild/helpers-esbuild/write.js +13 -3
  122. package/dinou/esbuild/plugins-esbuild/assets-plugin.js +100 -238
  123. package/dinou/esbuild/plugins-esbuild/babel-react-compiler-plugin.js +73 -29
  124. package/dinou/esbuild/plugins-esbuild/css-processor-plugin.js +283 -91
  125. package/dinou/esbuild/plugins-esbuild/manifest-generator-plugin.js +3 -5
  126. package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.js +9 -3
  127. package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +4 -3
  128. package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.js +10 -1
  129. package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +84 -21
  130. package/dinou/esbuild/react-refresh/esm-hmr/client.js +31 -10
  131. package/dinou/esbuild/react-refresh/esm-hmr-plugin.js +48 -18
  132. package/dinou/esbuild/react-refresh/is-react-refresh-boundary.js +9 -1
  133. package/dinou/esbuild/react-refresh/react-refresh-runtime.js +13 -7
  134. package/dinou/index.d.ts +1028 -88
  135. package/dinou/node/build.js +138 -74
  136. package/dinou/node/bundle-dual-engine.js +393 -131
  137. package/dinou/node/dev.js +1005 -275
  138. package/dinou/package.json +11 -34
  139. package/dinou/rollup/postcss.config.js +3 -4
  140. package/dinou/rollup/react-refresh/esm-hmr/client.js +31 -10
  141. package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +16 -13
  142. package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +53 -7
  143. package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +58 -20
  144. package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +16 -7
  145. package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +118 -42
  146. package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +48 -36
  147. package/dinou/rollup/rollup.config.js +174 -101
  148. package/dinou/scripts/build-vendors.js +123 -33
  149. package/dinou/server.d.ts +126 -15
  150. package/dinou/webpack/helpers/get-webpack-entries.js +87 -41
  151. package/dinou/webpack/helpers/patch-webpack-internals.js +93 -1
  152. package/dinou/webpack/loaders/server-functions-loader.js +1 -1
  153. package/dinou/webpack/plugins/manifest-generator-plugin.js +27 -7
  154. package/dinou/webpack/plugins/server-functions-plugin.js +39 -12
  155. package/dinou/webpack/plugins/webpack-memory-plugin.js +25 -12
  156. package/dinou/webpack/postcss.config.js +3 -4
  157. package/dinou/webpack/webpack.config.js +408 -132
  158. package/eject.js +6 -224
  159. package/package.json +7 -9
  160. package/dinou/compiled/cross-env/index.js +0 -661
  161. package/dinou/compiled/dotenv/index.js +0 -375
  162. package/dinou/compiled/esbuild-copy-static-files/index.js +0 -63
  163. package/dinou/compiled/esbuild-tsconfig-paths/index.js +0 -1314
  164. package/dinou/compiled/rollup-plugin-copy/index.js +0 -12066
  165. package/dinou/compiled/rollup-plugin-tsconfig-paths/index.js +0 -569
  166. package/dinou/compiled/tsconfig-paths-webpack-plugin/index.js +0 -3956
@@ -54,6 +54,13 @@ async function importModule(modulePath) {
54
54
  return typeof loader === "function" ? await loader() : loader;
55
55
  }
56
56
  }
57
+ const lowerAlternates = new Set(alternateKeys.map((a) => a.toLowerCase()));
58
+ for (const regKey of Object.keys(registry)) {
59
+ if (lowerAlternates.has(regKey.toLowerCase())) {
60
+ const loader = registry[regKey];
61
+ return typeof loader === "function" ? await loader() : loader;
62
+ }
63
+ }
57
64
  }
58
65
 
59
66
  const absPath = path.isAbsolute(modulePath)
@@ -3,6 +3,7 @@ import { existsSync } from "./vfs.js";
3
3
  import importModule from "./import-module.js";
4
4
  import { resolveModulePpr } from "./resolve-module-ppr.js";
5
5
  import { getFilePathAndDynamicParams } from "./get-file-path-and-dynamic-params.js";
6
+ import { getDinouConfig } from "./load-dinou-config.js";
6
7
 
7
8
  const LAYOUT_FUNCTIONS_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
8
9
  const LAYOUT_FUNCTIONS_NAMES = ["layout_functions", "layout.functions"];
@@ -74,8 +75,14 @@ async function getLayoutProps(layoutPath, dParams = {}) {
74
75
  * @returns {Promise<object>}
75
76
  */
76
77
  async function resolveLayoutFunctionsConfig(layoutPath, dParams = {}) {
78
+ const globalCfg = await getDinouConfig();
79
+ const defaultAllowISG =
80
+ globalCfg?.allowISG !== undefined && globalCfg?.allowISG !== null
81
+ ? Boolean(globalCfg.allowISG)
82
+ : true;
83
+
77
84
  const defaultConfig = {
78
- allowISG: true,
85
+ allowISG: defaultAllowISG,
79
86
  staticPathsSet: null,
80
87
  validateParams: null,
81
88
  isDynamic: false,
@@ -109,12 +116,12 @@ async function resolveLayoutFunctionsConfig(layoutPath, dParams = {}) {
109
116
  }
110
117
  }
111
118
  const defaultExport = mod.default?.default ? mod.default.default : mod.default;
119
+ const rawAllowISG =
120
+ mod.allowISG !== undefined ? mod.allowISG : defaultExport?.allowISG;
112
121
  const resolvedAllowISG =
113
- typeof mod.allowISG === "function"
114
- ? await mod.allowISG()
115
- : typeof defaultExport?.allowISG === "function"
116
- ? await defaultExport.allowISG()
117
- : (mod.allowISG ?? defaultExport?.allowISG ?? true);
122
+ typeof rawAllowISG === "function"
123
+ ? await rawAllowISG()
124
+ : (rawAllowISG ?? defaultAllowISG);
118
125
 
119
126
  const getStaticPathsFn = mod.getStaticPaths || defaultExport?.getStaticPaths;
120
127
  let staticPathsSet = null;
@@ -124,21 +131,33 @@ async function resolveLayoutFunctionsConfig(layoutPath, dParams = {}) {
124
131
  staticPathsSet = new Set(
125
132
  paths.map((p) => {
126
133
  if (typeof p === "object" && p !== null && !Array.isArray(p)) {
127
- const sorted = Object.entries(p).sort((a, b) => a[0].localeCompare(b[0]));
134
+ const sorted = Object.entries(p)
135
+ .sort((a, b) => a[0].localeCompare(b[0]))
136
+ .map(([k, v]) => [
137
+ k,
138
+ Array.isArray(v)
139
+ ? v.join(",")
140
+ : v === undefined || v === null
141
+ ? ""
142
+ : String(v),
143
+ ]);
128
144
  return JSON.stringify(sorted);
129
145
  }
130
- return String(p);
146
+ if (Array.isArray(p)) {
147
+ return p.join(",");
148
+ }
149
+ return p === undefined || p === null ? "" : String(p);
131
150
  })
132
151
  );
133
152
  }
134
153
  }
135
154
 
155
+ const rawRevalidate =
156
+ mod.revalidate !== undefined ? mod.revalidate : defaultExport?.revalidate;
136
157
  const revalidateVal =
137
- typeof mod.revalidate === "function"
138
- ? await mod.revalidate()
139
- : typeof defaultExport?.revalidate === "function"
140
- ? await defaultExport.revalidate()
141
- : (mod.revalidate ?? defaultExport?.revalidate);
158
+ typeof rawRevalidate === "function"
159
+ ? await rawRevalidate()
160
+ : rawRevalidate;
142
161
 
143
162
  const isDynamic = typeof revalidateVal === "number" && revalidateVal < 1;
144
163
 
@@ -275,15 +294,55 @@ function getActiveLayoutChain(
275
294
  return activeChain;
276
295
  }
277
296
 
297
+ /**
298
+ * Resolves the effective PPR boolean for each active layout in the chain (from outermost to innermost).
299
+ * Each layout segment uses its own explicit `ppr` config in `layout_functions`, or falls back to
300
+ * the global default `ppr` from `dinou.config.js` (`false` if omitted). No parent-to-child inheritance.
301
+ */
302
+ async function resolveLayoutChainPpr(
303
+ reqSegments,
304
+ queryObj = {},
305
+ srcFolder = path.resolve(process.cwd(), "src"),
306
+ options = {}
307
+ ) {
308
+ const globalCfg = await getDinouConfig();
309
+ const defaultPpr = Boolean(globalCfg?.ppr);
310
+ const activeChain = getActiveLayoutChain(reqSegments, queryObj, srcFolder, options);
311
+ const layoutPprMap = new Map();
312
+
313
+ for (let i = activeChain.length - 1; i >= 0; i--) {
314
+ const entry = activeChain[i];
315
+ const lConfig = await resolveLayoutFunctionsConfig(entry.layoutPath, entry.dParams);
316
+ const segmentPpr =
317
+ lConfig && lConfig.ppr !== null && lConfig.ppr !== undefined
318
+ ? Boolean(lConfig.ppr)
319
+ : defaultPpr;
320
+ entry.effectivePpr = segmentPpr;
321
+ layoutPprMap.set(entry.layoutPath, segmentPpr);
322
+ layoutPprMap.set(path.normalize(entry.layoutPath), segmentPpr);
323
+ layoutPprMap.set(entry.layoutPath.replace(/\\/g, "/"), segmentPpr);
324
+ }
325
+
326
+ const anyLayoutPpr = activeChain.some((entry) => Boolean(entry.effectivePpr));
327
+ return {
328
+ activeChain,
329
+ layoutPprMap,
330
+ defaultPpr,
331
+ anyLayoutPpr,
332
+ };
333
+ }
334
+
278
335
  export {
279
336
  getLayoutFunctionsPath,
280
337
  getLayoutProps,
281
338
  resolveLayoutFunctionsConfig,
282
339
  getActiveLayoutChain,
340
+ resolveLayoutChainPpr,
283
341
  };
284
342
  export default {
285
343
  getLayoutFunctionsPath,
286
344
  getLayoutProps,
287
345
  resolveLayoutFunctionsConfig,
288
346
  getActiveLayoutChain,
347
+ resolveLayoutChainPpr,
289
348
  };
@@ -1,24 +1,41 @@
1
1
  "use client";
2
2
 
3
3
  import { useRouter, usePathname } from "./navigation.js";
4
- import { resolveUrl, isExternalUrl } from "./navigation-utils.js";
4
+ import {
5
+ resolveUrl,
6
+ isExternalUrl,
7
+ interpolateRouteParams,
8
+ } from "./navigation-utils.js";
5
9
 
6
10
  export function Link({
7
11
  href,
8
12
  to,
13
+ from,
14
+ params,
9
15
  children,
10
16
  prefetch = true,
11
17
  fresh = false,
12
18
  onClick,
13
19
  ...props
14
20
  }) {
15
- const targetHref = href || to || "";
21
+ const targetHref = interpolateRouteParams(href || to || "", params);
16
22
  const { push } = useRouter();
17
23
  const pathname = usePathname();
18
- const resolvedHref = resolveUrl(targetHref, pathname);
24
+ const resolvedHref = resolveUrl(targetHref, pathname, from);
25
+ const isNonSelfTarget = Boolean(props.target && props.target !== "_self");
26
+ const isDownload = props.download !== undefined && props.download !== false;
19
27
 
20
28
  const handlePrefetch = () => {
21
- if (!prefetch || !targetHref || fresh || isExternalUrl(targetHref)) return;
29
+ if (
30
+ !prefetch ||
31
+ !targetHref ||
32
+ fresh ||
33
+ isNonSelfTarget ||
34
+ isDownload ||
35
+ isExternalUrl(targetHref)
36
+ ) {
37
+ return;
38
+ }
22
39
  if (window.__DINOU_PREFETCH__) {
23
40
  window.__DINOU_PREFETCH__(resolvedHref);
24
41
  }
@@ -30,11 +47,22 @@ export function Link({
30
47
  }
31
48
 
32
49
  if (e.defaultPrevented) return;
33
- if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || isExternalUrl(targetHref)) return;
50
+ if (
51
+ e.button !== 0 ||
52
+ e.metaKey ||
53
+ e.ctrlKey ||
54
+ e.shiftKey ||
55
+ e.altKey ||
56
+ isNonSelfTarget ||
57
+ isDownload ||
58
+ isExternalUrl(targetHref)
59
+ ) {
60
+ return;
61
+ }
34
62
 
35
63
  e.preventDefault();
36
64
  if (targetHref) {
37
- push(targetHref, { fresh });
65
+ push(resolvedHref || targetHref, { fresh });
38
66
  }
39
67
  };
40
68