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/server.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Revalidates the cache for a specific route path (both its layout segment, if present, and its page).
|
|
3
|
+
* Supports both absolute paths (`"/blog"`) and relative paths (`"./"`, `"../dashboard"`) inside Server Functions.
|
|
3
4
|
* Child routes sharing the layout have their `index.html` lazily re-composed on demand (preserving their cached `page.rsc` payloads) to ensure 0 hydration mismatch.
|
|
4
|
-
* @param path The path of the route to revalidate (e.g. "/blog" or "
|
|
5
|
+
* @param path The path of the route to revalidate (e.g. `"/blog"`, `"./"`, or `"../dashboard"`).
|
|
5
6
|
*/
|
|
6
7
|
export declare function revalidatePath(path: string): Promise<void>;
|
|
7
8
|
/**
|
|
@@ -17,14 +18,16 @@ export declare function revalidatePath(
|
|
|
17
18
|
/**
|
|
18
19
|
* Revalidates only the page component (`page.rsc`) and its HTML (`index.html`) for a specific route path,
|
|
19
20
|
* composing with the cached layout without re-executing `layout.tsx`.
|
|
20
|
-
*
|
|
21
|
+
* Supports both absolute paths (`"/dashboard/analytics"`) and relative paths (`"./"`, `"../overview"`) inside Server Functions.
|
|
22
|
+
* @param path The path of the page to revalidate (e.g. `"/dashboard/analytics"` or `"./"`).
|
|
21
23
|
*/
|
|
22
24
|
export declare function revalidatePage(path: string): Promise<void>;
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Revalidates only the layout shell (`layout.rsc` and `layout.metadata.json`) for a specific route path,
|
|
26
28
|
* without re-rendering child pages. Affected `index.html` files are lazily re-composed on demand.
|
|
27
|
-
*
|
|
29
|
+
* Supports both absolute paths (`"/dashboard"`) and relative paths (`"./"`, `".."`) inside Server Functions.
|
|
30
|
+
* @param path The path of the layout segment to revalidate (e.g. `"/dashboard"` or `"./"`).
|
|
28
31
|
*/
|
|
29
32
|
export declare function revalidateLayout(path: string): Promise<boolean>;
|
|
30
33
|
|
|
@@ -44,15 +47,21 @@ export declare function revalidateTag(
|
|
|
44
47
|
options?: { cascade?: boolean } | "layout"
|
|
45
48
|
): Promise<void>;
|
|
46
49
|
|
|
47
|
-
import type {
|
|
50
|
+
import type { ReactNode } from "react";
|
|
51
|
+
import type { RequestContextStore } from "./index.js";
|
|
48
52
|
|
|
49
53
|
export type {
|
|
50
54
|
PPRConfig,
|
|
51
55
|
RouteSegmentConfig,
|
|
52
56
|
PageFunctions,
|
|
53
57
|
LayoutFunctions,
|
|
58
|
+
AllowUndefinedStaticPath,
|
|
59
|
+
ToStaticPathParamValue,
|
|
60
|
+
ToStaticPathParams,
|
|
61
|
+
StaticPathParams,
|
|
54
62
|
StaticPathItem,
|
|
55
63
|
StaticPathsResult,
|
|
64
|
+
DinouEnv,
|
|
56
65
|
RequestContextStore,
|
|
57
66
|
ResponseProxy,
|
|
58
67
|
CookieOptions,
|
|
@@ -63,24 +72,101 @@ export type {
|
|
|
63
72
|
DinouPlugin,
|
|
64
73
|
ServerHookContext,
|
|
65
74
|
NodeMiddleware,
|
|
75
|
+
NavigationOptions,
|
|
76
|
+
LinkProps,
|
|
66
77
|
PageProps,
|
|
67
78
|
LayoutProps,
|
|
79
|
+
SlotProps,
|
|
68
80
|
ErrorProps,
|
|
81
|
+
NotFoundProps,
|
|
69
82
|
RouteParams,
|
|
83
|
+
LayoutParams,
|
|
84
|
+
LayoutSlots,
|
|
85
|
+
SlotParams,
|
|
86
|
+
ErrorParams,
|
|
70
87
|
DinouRoutePattern,
|
|
88
|
+
DinouLayoutPattern,
|
|
89
|
+
DinouSlotPattern,
|
|
90
|
+
DinouRegisteredSlotPattern,
|
|
91
|
+
DinouErrorPattern,
|
|
92
|
+
DinouNotFoundPattern,
|
|
93
|
+
DinouSegmentPattern,
|
|
71
94
|
DinouRoute,
|
|
95
|
+
DinouLinkTarget,
|
|
96
|
+
DinouNavigableRoutePatternMap,
|
|
97
|
+
DinouNavigableRouteKey,
|
|
98
|
+
DinouDynamicRoutePattern,
|
|
99
|
+
DinouDynamicRouteWithSuffix,
|
|
100
|
+
BuildDirectoryPrefixes,
|
|
101
|
+
ExtractParentDirectories,
|
|
102
|
+
PeelOptionalRouteSegments,
|
|
103
|
+
DinouEffectiveRoutePattern,
|
|
104
|
+
DinouFromSlashRoute,
|
|
105
|
+
DinouFromRoute,
|
|
106
|
+
SplitRouteSegments,
|
|
107
|
+
StripCommonPrefix,
|
|
108
|
+
HasVariableLengthSegment,
|
|
109
|
+
HasDynamicSegment,
|
|
110
|
+
ToDotDotSegments,
|
|
111
|
+
JoinSlash,
|
|
112
|
+
SegmentToTemplate,
|
|
113
|
+
MapSegmentsToTemplate,
|
|
114
|
+
SharesFirstSegment,
|
|
115
|
+
ComputeRelativeCompletionSingle,
|
|
116
|
+
ComputeRelativeAllPatternsSingle,
|
|
117
|
+
ComputeRelativeTemplateSingle,
|
|
118
|
+
DistributeRelativeCompletions,
|
|
119
|
+
DistributeAllRelativePatterns,
|
|
120
|
+
DistributeRelativeTemplates,
|
|
121
|
+
DinouRelativeDynamicPattern,
|
|
122
|
+
DinouRelativeLinkTarget,
|
|
123
|
+
DinouLinkTargetForFrom,
|
|
124
|
+
DinouScopedLinkTarget,
|
|
125
|
+
ScopedLinkTargetForFrom,
|
|
72
126
|
DinouRouter,
|
|
73
127
|
CleanRoutePath,
|
|
74
128
|
ExtractRouteParams,
|
|
75
129
|
ExtractSegmentParam,
|
|
76
|
-
|
|
130
|
+
ExtractNavigableRouteParams,
|
|
131
|
+
ExtractNavigableSegmentParam,
|
|
132
|
+
SimplifyParams,
|
|
133
|
+
FallbackRouteParams,
|
|
134
|
+
FallbackNavigableParams,
|
|
135
|
+
FormatPatternKeys,
|
|
136
|
+
FormatOptionalPatternKeys,
|
|
137
|
+
IsUnion,
|
|
138
|
+
LookupSingleSegmentParams,
|
|
139
|
+
LookupSegmentParams,
|
|
140
|
+
ToLinkInputParamValue,
|
|
141
|
+
ToLinkInputParams,
|
|
142
|
+
StripUrlSuffix,
|
|
143
|
+
IsExternalLinkHref,
|
|
144
|
+
IsInternalBracketPattern,
|
|
145
|
+
ValidatedLinkHref,
|
|
146
|
+
HasInvalidBracketPatternForFrom,
|
|
147
|
+
HasInvalidBracketPattern,
|
|
148
|
+
HasBracketPattern,
|
|
149
|
+
UnionToIntersection,
|
|
150
|
+
ResolveSingleLinkParams,
|
|
151
|
+
ResolveLinkParams,
|
|
152
|
+
LinkParamsPropsForFrom,
|
|
153
|
+
LinkParamsProps,
|
|
154
|
+
RouterNavigationArgs,
|
|
155
|
+
RouterRelativeNavigationOptions,
|
|
156
|
+
DinouRouterNavigateFn,
|
|
157
|
+
ScopedRouterNavigationArgs,
|
|
158
|
+
ScopedDinouRouterNavigateFn,
|
|
159
|
+
ScopedUseRouterHook,
|
|
160
|
+
ScopedLinkProps,
|
|
161
|
+
ScopedLinkComponent,
|
|
162
|
+
} from "./index.js";
|
|
77
163
|
|
|
78
164
|
export interface DinouCacheSlotProps {
|
|
79
165
|
id?: string;
|
|
80
166
|
tag?: string;
|
|
81
167
|
tags?: string[];
|
|
82
|
-
revalidate?: number;
|
|
83
|
-
children:
|
|
168
|
+
revalidate?: number | false;
|
|
169
|
+
children: ReactNode | (() => ReactNode | Promise<ReactNode>);
|
|
84
170
|
}
|
|
85
171
|
|
|
86
172
|
/**
|
|
@@ -88,7 +174,7 @@ export interface DinouCacheSlotProps {
|
|
|
88
174
|
* Caches and invalidates component sub-trees inside a page via revalidate and revalidateTag,
|
|
89
175
|
* without re-evaluating the parent page or re-fetching unneeded database queries.
|
|
90
176
|
*/
|
|
91
|
-
export declare function DinouCacheSlot(props: DinouCacheSlotProps): Promise<
|
|
177
|
+
export declare function DinouCacheSlot(props: DinouCacheSlotProps): Promise<ReactNode>;
|
|
92
178
|
|
|
93
179
|
/**
|
|
94
180
|
* Opts the enclosing `<Suspense>` boundary out of becoming a Dynamic PPR Hole
|
|
@@ -101,11 +187,12 @@ export declare function DinouCacheSlot(props: DinouCacheSlotProps): Promise<any>
|
|
|
101
187
|
export declare function noDynamic(): void;
|
|
102
188
|
|
|
103
189
|
/**
|
|
104
|
-
* Gets the current request context (req
|
|
105
|
-
*
|
|
106
|
-
*
|
|
190
|
+
* Gets the current server request context (`req`, `res`, `env`, `ctx`) synchronously.
|
|
191
|
+
* Safe to call inside Server Components, `page_functions.ts` / `layout_functions.ts`,
|
|
192
|
+
* `plugin.onRequest`, and `"use server"` Server Functions across all runtimes.
|
|
193
|
+
* @returns The active request context store (with `env` always populated on the server).
|
|
107
194
|
*/
|
|
108
|
-
export declare function getContext(): RequestContextStore
|
|
195
|
+
export declare function getContext(): RequestContextStore;
|
|
109
196
|
|
|
110
197
|
// ====================================================================
|
|
111
198
|
// STORAGE ADAPTER TYPES (ISR / CACHE)
|
|
@@ -113,22 +200,41 @@ export declare function getContext(): RequestContextStore | undefined;
|
|
|
113
200
|
|
|
114
201
|
export interface StorageItem {
|
|
115
202
|
content: string;
|
|
116
|
-
metadata?: any;
|
|
203
|
+
metadata?: Record<string, any> | null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface MemoryStorageOptions {
|
|
207
|
+
hydrateFromDisk?: boolean;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface RedisStorageOptions {
|
|
211
|
+
prefix?: string;
|
|
212
|
+
hydrateFromDisk?: boolean;
|
|
117
213
|
}
|
|
118
214
|
|
|
119
215
|
export abstract class StorageAdapter {
|
|
216
|
+
hydrateFromDisk: boolean;
|
|
120
217
|
abstract get(key: string): Promise<StorageItem | null>;
|
|
121
218
|
abstract set(key: string, content: string, metadata?: any): Promise<void>;
|
|
122
219
|
abstract has(key: string): Promise<boolean>;
|
|
123
220
|
abstract delete(key: string): Promise<void>;
|
|
221
|
+
keys?(prefix?: string): Promise<string[]> | string[];
|
|
222
|
+
isDeleted(key: string): boolean;
|
|
223
|
+
isKeyDeleted(key: string): Promise<boolean>;
|
|
224
|
+
markTagInvalidated(tag: string): void;
|
|
225
|
+
markTagInvalidatedAsync(tag: string): Promise<void>;
|
|
226
|
+
getTagInvalidatedAt(tag: string): number;
|
|
227
|
+
getTagInvalidatedAtAsync(tag: string): Promise<number>;
|
|
124
228
|
}
|
|
125
229
|
|
|
126
230
|
export class FileSystemStorage extends StorageAdapter {
|
|
231
|
+
baseDir: string;
|
|
127
232
|
constructor(baseDir?: string);
|
|
128
233
|
get(key: string): Promise<StorageItem | null>;
|
|
129
234
|
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
130
235
|
has(key: string): Promise<boolean>;
|
|
131
236
|
delete(key: string): Promise<void>;
|
|
237
|
+
keys(prefix?: string): Promise<string[]>;
|
|
132
238
|
}
|
|
133
239
|
|
|
134
240
|
export class CloudflareKVStorage extends StorageAdapter {
|
|
@@ -137,6 +243,7 @@ export class CloudflareKVStorage extends StorageAdapter {
|
|
|
137
243
|
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
138
244
|
has(key: string): Promise<boolean>;
|
|
139
245
|
delete(key: string): Promise<void>;
|
|
246
|
+
keys(prefix?: string): Promise<string[]>;
|
|
140
247
|
}
|
|
141
248
|
|
|
142
249
|
export class DenoKVStorage extends StorageAdapter {
|
|
@@ -145,22 +252,26 @@ export class DenoKVStorage extends StorageAdapter {
|
|
|
145
252
|
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
146
253
|
has(key: string): Promise<boolean>;
|
|
147
254
|
delete(key: string): Promise<void>;
|
|
255
|
+
keys(prefix?: string): Promise<string[]>;
|
|
148
256
|
}
|
|
149
257
|
|
|
150
258
|
export class MemoryStorage extends StorageAdapter {
|
|
151
|
-
constructor();
|
|
259
|
+
constructor(options?: MemoryStorageOptions);
|
|
152
260
|
get(key: string): Promise<StorageItem | null>;
|
|
153
261
|
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
154
262
|
has(key: string): Promise<boolean>;
|
|
155
263
|
delete(key: string): Promise<void>;
|
|
264
|
+
keys(prefix?: string): string[];
|
|
156
265
|
}
|
|
157
266
|
|
|
158
267
|
export class RedisStorage extends StorageAdapter {
|
|
159
|
-
|
|
268
|
+
prefix: string;
|
|
269
|
+
constructor(redisClient: any, prefixOrOptions?: string | RedisStorageOptions);
|
|
160
270
|
get(key: string): Promise<StorageItem | null>;
|
|
161
271
|
set(key: string, content: string, metadata?: any): Promise<void>;
|
|
162
272
|
has(key: string): Promise<boolean>;
|
|
163
273
|
delete(key: string): Promise<void>;
|
|
274
|
+
keys(prefix?: string): Promise<string[]>;
|
|
164
275
|
}
|
|
165
276
|
|
|
166
277
|
export function getStorageAdapter(): StorageAdapter;
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import
|
|
3
|
+
import globModule from "#fast-glob";
|
|
4
|
+
|
|
5
|
+
const glob = globModule?.default || globModule;
|
|
4
6
|
import { pathToFileURL } from "node:url";
|
|
5
7
|
import parser from "#babel/parser";
|
|
6
8
|
import _traverseRaw from "#babel/traverse";
|
|
7
9
|
import crypto from "node:crypto";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
+
import {
|
|
11
|
+
getAssetExtensionsInfo,
|
|
12
|
+
resolveAssetImport,
|
|
13
|
+
} from "../../core/asset-extensions.js";
|
|
14
|
+
import {
|
|
15
|
+
getAbsPathWithExt,
|
|
16
|
+
resolveStyleImportFromCode,
|
|
17
|
+
} from "../../core/get-abs-path-with-ext.js";
|
|
10
18
|
import { useClientRegex, useServerRegex } from "../../constants.js";
|
|
11
19
|
import { hasServerFunctions } from "../../core/transform-server-functions.js";
|
|
20
|
+
import { normalizePathCase } from "../../core/path-utils.js";
|
|
12
21
|
|
|
13
22
|
const traverse = typeof _traverseRaw === "function" ? _traverseRaw : (_traverseRaw.default || _traverseRaw);
|
|
14
23
|
|
|
15
24
|
const normalizePath = (p) => p.split(path.sep).join(path.posix.sep);
|
|
25
|
+
const normalizeServerFilePath = (p) => normalizePathCase(path.resolve(p)).replace(/\\/g, "/");
|
|
16
26
|
|
|
17
27
|
function hashFilePath(absPath) {
|
|
18
28
|
return crypto.createHash("sha1").update(absPath).digest("hex").slice(0, 8);
|
|
@@ -20,11 +30,16 @@ function hashFilePath(absPath) {
|
|
|
20
30
|
|
|
21
31
|
async function getCSSEntries({
|
|
22
32
|
srcDir = path.resolve("src"),
|
|
23
|
-
assetInclude =
|
|
33
|
+
assetInclude = null,
|
|
34
|
+
dinouConfig = null,
|
|
24
35
|
manifest = {},
|
|
25
36
|
} = {}) {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
37
|
+
const projectRoot = path.dirname(path.resolve(srcDir));
|
|
38
|
+
const activeAssetInclude =
|
|
39
|
+
assetInclude || getAssetExtensionsInfo(dinouConfig, projectRoot).regex;
|
|
40
|
+
const clientEntryMap = new Map();
|
|
41
|
+
const cssEntryMap = new Map();
|
|
42
|
+
const assetEntryMap = new Map();
|
|
28
43
|
|
|
29
44
|
async function getImportsAndAssetsAndCsss(
|
|
30
45
|
code,
|
|
@@ -56,16 +71,43 @@ async function getCSSEntries({
|
|
|
56
71
|
for (const nodePath of importNodes) {
|
|
57
72
|
const source = nodePath.node.source.value;
|
|
58
73
|
|
|
59
|
-
// Resolve
|
|
60
|
-
const absImportPathWithExt =
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
// Resolve local/aliased imports, bare stylesheet imports, or bare asset imports from node_modules
|
|
75
|
+
const absImportPathWithExt =
|
|
76
|
+
getAbsPathWithExt(source, {
|
|
77
|
+
parentURL: pathToFileURL(baseFilePath).href,
|
|
78
|
+
cwd: projectRoot,
|
|
79
|
+
}) ||
|
|
80
|
+
resolveStyleImportFromCode(source, baseFilePath, projectRoot) ||
|
|
81
|
+
resolveAssetImport(source, {
|
|
82
|
+
importer: baseFilePath,
|
|
83
|
+
projectRoot,
|
|
84
|
+
assetRegex: activeAssetInclude,
|
|
85
|
+
});
|
|
63
86
|
|
|
64
87
|
if (!absImportPathWithExt) {
|
|
65
88
|
// unresolved - skip
|
|
66
89
|
continue;
|
|
67
90
|
}
|
|
68
91
|
|
|
92
|
+
if (
|
|
93
|
+
absImportPathWithExt.endsWith(".css") ||
|
|
94
|
+
absImportPathWithExt.endsWith(".scss") ||
|
|
95
|
+
absImportPathWithExt.endsWith(".less")
|
|
96
|
+
) {
|
|
97
|
+
csss.add(absImportPathWithExt);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (activeAssetInclude.test(absImportPathWithExt)) {
|
|
102
|
+
assets.add(absImportPathWithExt);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (absImportPathWithExt.endsWith(".json")) {
|
|
107
|
+
imports.add(absImportPathWithExt);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
|
|
69
111
|
// Read the file ONLY once
|
|
70
112
|
let importedCode;
|
|
71
113
|
try {
|
|
@@ -89,37 +131,22 @@ async function getCSSEntries({
|
|
|
89
131
|
|
|
90
132
|
const isImportedFileServer = useServerRegex.test(importedCode.trim());
|
|
91
133
|
if (isImportedFileServer) {
|
|
92
|
-
serverFiles.add(
|
|
134
|
+
serverFiles.add(normalizeServerFilePath(absImportPathWithExt));
|
|
93
135
|
continue;
|
|
94
136
|
} else if (hasServerFunctions(importedCode)) {
|
|
95
|
-
serverFiles.add(
|
|
137
|
+
serverFiles.add(normalizeServerFilePath(absImportPathWithExt));
|
|
96
138
|
}
|
|
97
139
|
} else {
|
|
98
140
|
const isImportedFileServer = useServerRegex.test(importedCode.trim());
|
|
99
141
|
|
|
100
142
|
if (isImportedFileServer) {
|
|
101
|
-
serverFiles.add(
|
|
143
|
+
serverFiles.add(normalizeServerFilePath(absImportPathWithExt));
|
|
102
144
|
continue;
|
|
103
145
|
} else if (hasServerFunctions(importedCode)) {
|
|
104
|
-
serverFiles.add(
|
|
146
|
+
serverFiles.add(normalizeServerFilePath(absImportPathWithExt));
|
|
105
147
|
}
|
|
106
148
|
}
|
|
107
149
|
|
|
108
|
-
// For non-client modules, process normally
|
|
109
|
-
if (
|
|
110
|
-
absImportPathWithExt.endsWith(".css") ||
|
|
111
|
-
absImportPathWithExt.endsWith(".scss") ||
|
|
112
|
-
absImportPathWithExt.endsWith(".less")
|
|
113
|
-
) {
|
|
114
|
-
csss.add(absImportPathWithExt);
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (assetInclude.test(absImportPathWithExt)) {
|
|
119
|
-
assets.add(absImportPathWithExt);
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
150
|
imports.add(absImportPathWithExt);
|
|
124
151
|
|
|
125
152
|
// Process imports recursively for non-client modules
|
|
@@ -153,6 +180,8 @@ async function getCSSEntries({
|
|
|
153
180
|
return (
|
|
154
181
|
fileName.startsWith("page.") ||
|
|
155
182
|
fileName.startsWith("layout.") ||
|
|
183
|
+
fileName.startsWith("error.") ||
|
|
184
|
+
fileName.startsWith("not_found.") ||
|
|
156
185
|
fileName.startsWith("page_functions.") ||
|
|
157
186
|
fileName.startsWith("layout_functions.")
|
|
158
187
|
);
|
|
@@ -162,6 +191,7 @@ async function getCSSEntries({
|
|
|
162
191
|
const files = await glob(["**/*.{js,jsx,ts,tsx}"], {
|
|
163
192
|
cwd: srcDir,
|
|
164
193
|
absolute: true,
|
|
194
|
+
ignore: ["_*/**", "**/_*/**"],
|
|
165
195
|
});
|
|
166
196
|
|
|
167
197
|
const serverFiles = new Set();
|
|
@@ -180,7 +210,7 @@ async function getCSSEntries({
|
|
|
180
210
|
if (isClientModule) {
|
|
181
211
|
const name = path.basename(absPath, path.extname(absPath));
|
|
182
212
|
|
|
183
|
-
|
|
213
|
+
clientEntryMap.set(normalizedPath.toLowerCase(), {
|
|
184
214
|
absPath: normalizedPath,
|
|
185
215
|
name,
|
|
186
216
|
});
|
|
@@ -189,18 +219,25 @@ async function getCSSEntries({
|
|
|
189
219
|
} catch (err) {}
|
|
190
220
|
} else if (isPageOrLayout(absPath)) {
|
|
191
221
|
if (hasServerFunctions(code)) {
|
|
192
|
-
serverFiles.add(
|
|
222
|
+
serverFiles.add(normalizeServerFilePath(absPath));
|
|
193
223
|
}
|
|
194
224
|
try {
|
|
195
|
-
const { csss } = await getImportsAndAssetsAndCsss(code, absPath);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
225
|
+
const { assets, csss } = await getImportsAndAssetsAndCsss(code, absPath);
|
|
226
|
+
|
|
227
|
+
for (const cssPath of csss) {
|
|
228
|
+
const normCss = normalizePath(cssPath);
|
|
229
|
+
cssEntryMap.set(normCss.toLowerCase(), {
|
|
230
|
+
absPath: normCss,
|
|
231
|
+
name: path.basename(cssPath, path.extname(cssPath)),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
for (const assetPath of assets) {
|
|
236
|
+
const normAsset = normalizePath(assetPath);
|
|
237
|
+
assetEntryMap.set(normAsset.toLowerCase(), {
|
|
238
|
+
absPath: normAsset,
|
|
239
|
+
name: path.basename(assetPath, path.extname(assetPath)),
|
|
240
|
+
});
|
|
204
241
|
}
|
|
205
242
|
} catch (err) {
|
|
206
243
|
/* ignore */
|
|
@@ -208,6 +245,10 @@ async function getCSSEntries({
|
|
|
208
245
|
}
|
|
209
246
|
} // end for files
|
|
210
247
|
|
|
248
|
+
const detectedClientEntries = new Set(clientEntryMap.values());
|
|
249
|
+
const detectedCSSEntries = new Set(cssEntryMap.values());
|
|
250
|
+
const detectedAssetEntries = new Set(assetEntryMap.values());
|
|
251
|
+
|
|
211
252
|
for (const dCE of detectedClientEntries) {
|
|
212
253
|
const hash = hashFilePath(dCE.absPath);
|
|
213
254
|
const outfileName = `${dCE.name}-${hash}`;
|
|
@@ -222,7 +263,12 @@ async function getCSSEntries({
|
|
|
222
263
|
dCSSE.outfileName = outfileName;
|
|
223
264
|
}
|
|
224
265
|
|
|
225
|
-
return [
|
|
266
|
+
return [
|
|
267
|
+
detectedCSSEntries,
|
|
268
|
+
detectedClientEntries,
|
|
269
|
+
serverFiles,
|
|
270
|
+
detectedAssetEntries,
|
|
271
|
+
];
|
|
226
272
|
}
|
|
227
273
|
|
|
228
274
|
export { getCSSEntries };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import module, { createRequire } from "node:module";
|
|
2
4
|
|
|
3
5
|
// Compatibility shim for Webpack 5.112+ internal file reorganization with react-server-dom-webpack
|
|
4
6
|
const originalResolveFilename = module._resolveFilename;
|
|
@@ -33,3 +35,93 @@ if (originalResolveFilename) {
|
|
|
33
35
|
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
34
36
|
};
|
|
35
37
|
}
|
|
38
|
+
|
|
39
|
+
let cachedPlugin = null;
|
|
40
|
+
|
|
41
|
+
export function loadReactServerWebpackPlugin() {
|
|
42
|
+
if (cachedPlugin) return cachedPlugin;
|
|
43
|
+
|
|
44
|
+
const dinouReq = createRequire(import.meta.url);
|
|
45
|
+
let baseReq = dinouReq;
|
|
46
|
+
let pluginEntry = null;
|
|
47
|
+
try {
|
|
48
|
+
pluginEntry = dinouReq.resolve("react-server-dom-webpack/plugin");
|
|
49
|
+
} catch {
|
|
50
|
+
baseReq = createRequire(path.resolve(process.cwd(), "package.json"));
|
|
51
|
+
pluginEntry = baseReq.resolve("react-server-dom-webpack/plugin");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const isBunRuntime =
|
|
55
|
+
typeof Bun !== "undefined" || Boolean(process.versions?.bun);
|
|
56
|
+
|
|
57
|
+
if (!isBunRuntime) {
|
|
58
|
+
try {
|
|
59
|
+
const loaded = baseReq(pluginEntry);
|
|
60
|
+
cachedPlugin = loaded?.default || loaded;
|
|
61
|
+
return cachedPlugin;
|
|
62
|
+
} catch {
|
|
63
|
+
// Fallback to scoped CJS evaluator below
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Bun's native Zig CJS loader bypasses `module._resolveFilename`, so evaluate
|
|
68
|
+
// `react-server-dom-webpack-plugin.js` with a scoped `require` shim that maps
|
|
69
|
+
// Webpack 5.112+ relocated internal module paths cleanly in memory.
|
|
70
|
+
const implPath = path.resolve(
|
|
71
|
+
path.dirname(pluginEntry),
|
|
72
|
+
"cjs/react-server-dom-webpack-plugin.js"
|
|
73
|
+
);
|
|
74
|
+
const implReq = createRequire(implPath);
|
|
75
|
+
const resolveWebpackInternal = (id, fallbackId) => {
|
|
76
|
+
try {
|
|
77
|
+
return implReq(id);
|
|
78
|
+
} catch {
|
|
79
|
+
try {
|
|
80
|
+
return implReq(fallbackId);
|
|
81
|
+
} catch {
|
|
82
|
+
return baseReq(fallbackId);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const scopedRequire = (id) => {
|
|
88
|
+
if (id === "webpack/lib/dependencies/ModuleDependency") {
|
|
89
|
+
return resolveWebpackInternal(
|
|
90
|
+
id,
|
|
91
|
+
"webpack/lib/dependencies/core/ModuleDependency"
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (id === "webpack/lib/Template") {
|
|
95
|
+
return resolveWebpackInternal(id, "webpack/lib/template/Template");
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
return implReq(id);
|
|
99
|
+
} catch {
|
|
100
|
+
return baseReq(id);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
Object.assign(scopedRequire, implReq);
|
|
104
|
+
|
|
105
|
+
const mod = { exports: {} };
|
|
106
|
+
const source = fs.readFileSync(implPath, "utf8");
|
|
107
|
+
const wrapperFn = new Function(
|
|
108
|
+
"exports",
|
|
109
|
+
"require",
|
|
110
|
+
"module",
|
|
111
|
+
"__filename",
|
|
112
|
+
"__dirname",
|
|
113
|
+
source
|
|
114
|
+
);
|
|
115
|
+
wrapperFn(
|
|
116
|
+
mod.exports,
|
|
117
|
+
scopedRequire,
|
|
118
|
+
mod,
|
|
119
|
+
implPath,
|
|
120
|
+
path.dirname(implPath)
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
cachedPlugin = mod.exports?.default || mod.exports;
|
|
124
|
+
return cachedPlugin;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default { loadReactServerWebpackPlugin };
|
|
@@ -12,7 +12,7 @@ export default function (source) {
|
|
|
12
12
|
return source;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const norm = path.resolve(this.resourcePath).replace(/\\/g, "/")
|
|
15
|
+
const norm = normalizePathCase(path.resolve(this.resourcePath)).replace(/\\/g, "/");
|
|
16
16
|
|
|
17
17
|
const isModuleLevel = useServerRegex.test(trimmed);
|
|
18
18
|
const hasBodyUseServer = !isModuleLevel && hasServerFunctions(source);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// manifest-generator-plugin.js
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
2
5
|
class ManifestGeneratorPlugin {
|
|
3
6
|
constructor() {
|
|
4
7
|
this.manifestData = {}; // same as in Rollup
|
|
@@ -16,7 +19,7 @@ class ManifestGeneratorPlugin {
|
|
|
16
19
|
name: pluginName,
|
|
17
20
|
stage: Compilation.PROCESS_ASSETS_STAGE_ANALYSE,
|
|
18
21
|
},
|
|
19
|
-
(
|
|
22
|
+
() => {
|
|
20
23
|
this.manifestData = {};
|
|
21
24
|
// Traverse chunks to generate manifest
|
|
22
25
|
for (const chunk of compilation.chunks) {
|
|
@@ -30,13 +33,30 @@ class ManifestGeneratorPlugin {
|
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
if (typeof globalThis !== "undefined") {
|
|
37
|
+
globalThis.__DINOU_RAW_ASSET_MANIFEST__ = { ...this.manifestData };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const isDev =
|
|
41
|
+
process.env.NODE_ENV !== "production" ||
|
|
42
|
+
process.env.DINOU_DEV === "true";
|
|
43
|
+
const shouldWriteToDisk =
|
|
44
|
+
process.env.DINOU_WRITE_TO_DISK === "false"
|
|
45
|
+
? false
|
|
46
|
+
: process.env.DINOU_WRITE_TO_DISK === "true" || !isDev;
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
if (shouldWriteToDisk) {
|
|
49
|
+
const targetDir = path.resolve(
|
|
50
|
+
process.cwd(),
|
|
51
|
+
isDev ? ".dinou/node-dev" : ".dinou/dist1"
|
|
52
|
+
);
|
|
53
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
54
|
+
fs.writeFileSync(
|
|
55
|
+
path.join(targetDir, "manifest.json"),
|
|
56
|
+
JSON.stringify(this.manifestData, null, 2),
|
|
57
|
+
"utf8"
|
|
58
|
+
);
|
|
59
|
+
}
|
|
40
60
|
}
|
|
41
61
|
);
|
|
42
62
|
});
|