vinext 0.0.0 → 0.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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/build/static-export.d.ts +78 -0
- package/dist/build/static-export.d.ts.map +1 -0
- package/dist/build/static-export.js +553 -0
- package/dist/build/static-export.js.map +1 -0
- package/dist/check.d.ts +52 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +483 -0
- package/dist/check.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +565 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/entry.d.ts +2 -0
- package/dist/client/entry.d.ts.map +1 -0
- package/dist/client/entry.js +85 -0
- package/dist/client/entry.js.map +1 -0
- package/dist/cloudflare/index.d.ts +8 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +8 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/cloudflare/kv-cache-handler.d.ts +68 -0
- package/dist/cloudflare/kv-cache-handler.d.ts.map +1 -0
- package/dist/cloudflare/kv-cache-handler.js +304 -0
- package/dist/cloudflare/kv-cache-handler.js.map +1 -0
- package/dist/cloudflare/tpr.d.ts +78 -0
- package/dist/cloudflare/tpr.d.ts.map +1 -0
- package/dist/cloudflare/tpr.js +672 -0
- package/dist/cloudflare/tpr.js.map +1 -0
- package/dist/config/config-matchers.d.ts +106 -0
- package/dist/config/config-matchers.d.ts.map +1 -0
- package/dist/config/config-matchers.js +499 -0
- package/dist/config/config-matchers.js.map +1 -0
- package/dist/config/next-config.d.ts +153 -0
- package/dist/config/next-config.d.ts.map +1 -0
- package/dist/config/next-config.js +274 -0
- package/dist/config/next-config.js.map +1 -0
- package/dist/deploy.d.ts +87 -0
- package/dist/deploy.d.ts.map +1 -0
- package/dist/deploy.js +644 -0
- package/dist/deploy.js.map +1 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3287 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +55 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +201 -0
- package/dist/init.js.map +1 -0
- package/dist/routing/app-router.d.ts +96 -0
- package/dist/routing/app-router.d.ts.map +1 -0
- package/dist/routing/app-router.js +815 -0
- package/dist/routing/app-router.js.map +1 -0
- package/dist/routing/pages-router.d.ts +52 -0
- package/dist/routing/pages-router.d.ts.map +1 -0
- package/dist/routing/pages-router.js +239 -0
- package/dist/routing/pages-router.js.map +1 -0
- package/dist/server/api-handler.d.ts +18 -0
- package/dist/server/api-handler.d.ts.map +1 -0
- package/dist/server/api-handler.js +169 -0
- package/dist/server/api-handler.js.map +1 -0
- package/dist/server/app-dev-server.d.ts +42 -0
- package/dist/server/app-dev-server.d.ts.map +1 -0
- package/dist/server/app-dev-server.js +2718 -0
- package/dist/server/app-dev-server.js.map +1 -0
- package/dist/server/app-router-entry.d.ts +18 -0
- package/dist/server/app-router-entry.d.ts.map +1 -0
- package/dist/server/app-router-entry.js +34 -0
- package/dist/server/app-router-entry.js.map +1 -0
- package/dist/server/dev-server.d.ts +40 -0
- package/dist/server/dev-server.d.ts.map +1 -0
- package/dist/server/dev-server.js +758 -0
- package/dist/server/dev-server.js.map +1 -0
- package/dist/server/html.d.ts +22 -0
- package/dist/server/html.d.ts.map +1 -0
- package/dist/server/html.js +29 -0
- package/dist/server/html.js.map +1 -0
- package/dist/server/image-optimization.d.ts +56 -0
- package/dist/server/image-optimization.d.ts.map +1 -0
- package/dist/server/image-optimization.js +103 -0
- package/dist/server/image-optimization.js.map +1 -0
- package/dist/server/instrumentation.d.ts +68 -0
- package/dist/server/instrumentation.d.ts.map +1 -0
- package/dist/server/instrumentation.js +90 -0
- package/dist/server/instrumentation.js.map +1 -0
- package/dist/server/isr-cache.d.ts +61 -0
- package/dist/server/isr-cache.d.ts.map +1 -0
- package/dist/server/isr-cache.js +134 -0
- package/dist/server/isr-cache.js.map +1 -0
- package/dist/server/metadata-routes.d.ts +103 -0
- package/dist/server/metadata-routes.d.ts.map +1 -0
- package/dist/server/metadata-routes.js +270 -0
- package/dist/server/metadata-routes.js.map +1 -0
- package/dist/server/middleware.d.ts +77 -0
- package/dist/server/middleware.d.ts.map +1 -0
- package/dist/server/middleware.js +228 -0
- package/dist/server/middleware.js.map +1 -0
- package/dist/server/prod-server.d.ts +78 -0
- package/dist/server/prod-server.d.ts.map +1 -0
- package/dist/server/prod-server.js +712 -0
- package/dist/server/prod-server.js.map +1 -0
- package/dist/shims/amp.d.ts +17 -0
- package/dist/shims/amp.d.ts.map +1 -0
- package/dist/shims/amp.js +21 -0
- package/dist/shims/amp.js.map +1 -0
- package/dist/shims/app.d.ts +12 -0
- package/dist/shims/app.d.ts.map +1 -0
- package/dist/shims/app.js +2 -0
- package/dist/shims/app.js.map +1 -0
- package/dist/shims/cache-runtime.d.ts +68 -0
- package/dist/shims/cache-runtime.d.ts.map +1 -0
- package/dist/shims/cache-runtime.js +437 -0
- package/dist/shims/cache-runtime.js.map +1 -0
- package/dist/shims/cache.d.ts +243 -0
- package/dist/shims/cache.d.ts.map +1 -0
- package/dist/shims/cache.js +415 -0
- package/dist/shims/cache.js.map +1 -0
- package/dist/shims/client-only.d.ts +18 -0
- package/dist/shims/client-only.d.ts.map +1 -0
- package/dist/shims/client-only.js +18 -0
- package/dist/shims/client-only.js.map +1 -0
- package/dist/shims/config.d.ts +27 -0
- package/dist/shims/config.d.ts.map +1 -0
- package/dist/shims/config.js +30 -0
- package/dist/shims/config.js.map +1 -0
- package/dist/shims/constants.d.ts +13 -0
- package/dist/shims/constants.d.ts.map +1 -0
- package/dist/shims/constants.js +13 -0
- package/dist/shims/constants.js.map +1 -0
- package/dist/shims/document.d.ts +33 -0
- package/dist/shims/document.d.ts.map +1 -0
- package/dist/shims/document.js +32 -0
- package/dist/shims/document.js.map +1 -0
- package/dist/shims/dynamic.d.ts +33 -0
- package/dist/shims/dynamic.d.ts.map +1 -0
- package/dist/shims/dynamic.js +148 -0
- package/dist/shims/dynamic.js.map +1 -0
- package/dist/shims/error-boundary.d.ts +33 -0
- package/dist/shims/error-boundary.d.ts.map +1 -0
- package/dist/shims/error-boundary.js +88 -0
- package/dist/shims/error-boundary.js.map +1 -0
- package/dist/shims/error.d.ts +16 -0
- package/dist/shims/error.d.ts.map +1 -0
- package/dist/shims/error.js +45 -0
- package/dist/shims/error.js.map +1 -0
- package/dist/shims/fetch-cache.d.ts +61 -0
- package/dist/shims/fetch-cache.d.ts.map +1 -0
- package/dist/shims/fetch-cache.js +307 -0
- package/dist/shims/fetch-cache.js.map +1 -0
- package/dist/shims/font-google.d.ts +122 -0
- package/dist/shims/font-google.d.ts.map +1 -0
- package/dist/shims/font-google.js +387 -0
- package/dist/shims/font-google.js.map +1 -0
- package/dist/shims/font-local.d.ts +61 -0
- package/dist/shims/font-local.d.ts.map +1 -0
- package/dist/shims/font-local.js +303 -0
- package/dist/shims/font-local.js.map +1 -0
- package/dist/shims/form.d.ts +30 -0
- package/dist/shims/form.d.ts.map +1 -0
- package/dist/shims/form.js +78 -0
- package/dist/shims/form.js.map +1 -0
- package/dist/shims/head-state.d.ts +11 -0
- package/dist/shims/head-state.d.ts.map +1 -0
- package/dist/shims/head-state.js +47 -0
- package/dist/shims/head-state.js.map +1 -0
- package/dist/shims/head.d.ts +28 -0
- package/dist/shims/head.d.ts.map +1 -0
- package/dist/shims/head.js +148 -0
- package/dist/shims/head.js.map +1 -0
- package/dist/shims/headers.d.ts +150 -0
- package/dist/shims/headers.d.ts.map +1 -0
- package/dist/shims/headers.js +412 -0
- package/dist/shims/headers.js.map +1 -0
- package/dist/shims/image-config.d.ts +30 -0
- package/dist/shims/image-config.d.ts.map +1 -0
- package/dist/shims/image-config.js +91 -0
- package/dist/shims/image-config.js.map +1 -0
- package/dist/shims/image.d.ts +63 -0
- package/dist/shims/image.d.ts.map +1 -0
- package/dist/shims/image.js +284 -0
- package/dist/shims/image.js.map +1 -0
- package/dist/shims/internal/api-utils.d.ts +12 -0
- package/dist/shims/internal/api-utils.d.ts.map +1 -0
- package/dist/shims/internal/api-utils.js +7 -0
- package/dist/shims/internal/api-utils.js.map +1 -0
- package/dist/shims/internal/app-router-context.d.ts +21 -0
- package/dist/shims/internal/app-router-context.d.ts.map +1 -0
- package/dist/shims/internal/app-router-context.js +15 -0
- package/dist/shims/internal/app-router-context.js.map +1 -0
- package/dist/shims/internal/cookies.d.ts +9 -0
- package/dist/shims/internal/cookies.d.ts.map +1 -0
- package/dist/shims/internal/cookies.js +9 -0
- package/dist/shims/internal/cookies.js.map +1 -0
- package/dist/shims/internal/router-context.d.ts +2 -0
- package/dist/shims/internal/router-context.d.ts.map +1 -0
- package/dist/shims/internal/router-context.js +9 -0
- package/dist/shims/internal/router-context.js.map +1 -0
- package/dist/shims/internal/utils.d.ts +48 -0
- package/dist/shims/internal/utils.d.ts.map +1 -0
- package/dist/shims/internal/utils.js +35 -0
- package/dist/shims/internal/utils.js.map +1 -0
- package/dist/shims/internal/work-unit-async-storage.d.ts +12 -0
- package/dist/shims/internal/work-unit-async-storage.d.ts.map +1 -0
- package/dist/shims/internal/work-unit-async-storage.js +13 -0
- package/dist/shims/internal/work-unit-async-storage.js.map +1 -0
- package/dist/shims/layout-segment-context.d.ts +21 -0
- package/dist/shims/layout-segment-context.d.ts.map +1 -0
- package/dist/shims/layout-segment-context.js +27 -0
- package/dist/shims/layout-segment-context.js.map +1 -0
- package/dist/shims/legacy-image.d.ts +52 -0
- package/dist/shims/legacy-image.d.ts.map +1 -0
- package/dist/shims/legacy-image.js +46 -0
- package/dist/shims/legacy-image.js.map +1 -0
- package/dist/shims/link.d.ts +48 -0
- package/dist/shims/link.d.ts.map +1 -0
- package/dist/shims/link.js +395 -0
- package/dist/shims/link.js.map +1 -0
- package/dist/shims/metadata.d.ts +184 -0
- package/dist/shims/metadata.d.ts.map +1 -0
- package/dist/shims/metadata.js +472 -0
- package/dist/shims/metadata.js.map +1 -0
- package/dist/shims/navigation-state.d.ts +14 -0
- package/dist/shims/navigation-state.d.ts.map +1 -0
- package/dist/shims/navigation-state.js +77 -0
- package/dist/shims/navigation-state.js.map +1 -0
- package/dist/shims/navigation.d.ts +201 -0
- package/dist/shims/navigation.d.ts.map +1 -0
- package/dist/shims/navigation.js +672 -0
- package/dist/shims/navigation.js.map +1 -0
- package/dist/shims/og.d.ts +20 -0
- package/dist/shims/og.d.ts.map +1 -0
- package/dist/shims/og.js +19 -0
- package/dist/shims/og.js.map +1 -0
- package/dist/shims/router-state.d.ts +11 -0
- package/dist/shims/router-state.d.ts.map +1 -0
- package/dist/shims/router-state.js +56 -0
- package/dist/shims/router-state.js.map +1 -0
- package/dist/shims/router.d.ts +103 -0
- package/dist/shims/router.d.ts.map +1 -0
- package/dist/shims/router.js +536 -0
- package/dist/shims/router.js.map +1 -0
- package/dist/shims/script.d.ts +58 -0
- package/dist/shims/script.d.ts.map +1 -0
- package/dist/shims/script.js +163 -0
- package/dist/shims/script.js.map +1 -0
- package/dist/shims/server-only.d.ts +19 -0
- package/dist/shims/server-only.d.ts.map +1 -0
- package/dist/shims/server-only.js +19 -0
- package/dist/shims/server-only.js.map +1 -0
- package/dist/shims/server.d.ts +178 -0
- package/dist/shims/server.d.ts.map +1 -0
- package/dist/shims/server.js +377 -0
- package/dist/shims/server.js.map +1 -0
- package/dist/shims/web-vitals.d.ts +24 -0
- package/dist/shims/web-vitals.d.ts.map +1 -0
- package/dist/shims/web-vitals.js +17 -0
- package/dist/shims/web-vitals.js.map +1 -0
- package/dist/utils/hash.d.ts +6 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +20 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/project.d.ts +36 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +112 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/query.d.ts +10 -0
- package/dist/utils/query.d.ts.map +1 -0
- package/dist/utils/query.js +27 -0
- package/dist/utils/query.js.map +1 -0
- package/package.json +65 -7
- package/index.js +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* next/dynamic shim
|
|
3
|
+
*
|
|
4
|
+
* SSR-safe dynamic imports. On the server, uses React.lazy + Suspense so that
|
|
5
|
+
* renderToReadableStream suspends until the dynamically-imported component is
|
|
6
|
+
* available. On the client, also uses React.lazy for code splitting.
|
|
7
|
+
*
|
|
8
|
+
* Supports:
|
|
9
|
+
* - dynamic(() => import('./Component'))
|
|
10
|
+
* - dynamic(() => import('./Component'), { loading: () => <Spinner /> })
|
|
11
|
+
* - dynamic(() => import('./Component'), { ssr: false })
|
|
12
|
+
*/
|
|
13
|
+
import { type ComponentType } from "react";
|
|
14
|
+
interface DynamicOptions {
|
|
15
|
+
loading?: ComponentType<{
|
|
16
|
+
error?: Error | null;
|
|
17
|
+
isLoading?: boolean;
|
|
18
|
+
pastDelay?: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
ssr?: boolean;
|
|
21
|
+
}
|
|
22
|
+
type Loader<P> = () => Promise<{
|
|
23
|
+
default: ComponentType<P>;
|
|
24
|
+
} | ComponentType<P>>;
|
|
25
|
+
/**
|
|
26
|
+
* Wait for all pending dynamic() preloads to resolve, then clear the queue.
|
|
27
|
+
* Called by the Pages Router SSR handler before rendering.
|
|
28
|
+
* No-op for the App Router path which uses React.lazy + Suspense.
|
|
29
|
+
*/
|
|
30
|
+
export declare function flushPreloads(): Promise<void[]>;
|
|
31
|
+
declare function dynamic<P extends object = object>(loader: Loader<P>, options?: DynamicOptions): ComponentType<P>;
|
|
32
|
+
export default dynamic;
|
|
33
|
+
//# sourceMappingURL=dynamic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic.d.ts","sourceRoot":"","sources":["../../src/shims/dynamic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAc,EAAkB,KAAK,aAAa,EAAuB,MAAM,OAAO,CAAC;AAEvF,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,aAAa,CAAC;QAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC5F,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,KAAK,MAAM,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;CAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAgDjF;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAG/C;AAED,iBAAS,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACxC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,CAAC,EAAE,cAAc,GACvB,aAAa,CAAC,CAAC,CAAC,CAkGlB;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* next/dynamic shim
|
|
3
|
+
*
|
|
4
|
+
* SSR-safe dynamic imports. On the server, uses React.lazy + Suspense so that
|
|
5
|
+
* renderToReadableStream suspends until the dynamically-imported component is
|
|
6
|
+
* available. On the client, also uses React.lazy for code splitting.
|
|
7
|
+
*
|
|
8
|
+
* Supports:
|
|
9
|
+
* - dynamic(() => import('./Component'))
|
|
10
|
+
* - dynamic(() => import('./Component'), { loading: () => <Spinner /> })
|
|
11
|
+
* - dynamic(() => import('./Component'), { ssr: false })
|
|
12
|
+
*/
|
|
13
|
+
import React, { lazy, Suspense, useState, useEffect } from "react";
|
|
14
|
+
/**
|
|
15
|
+
* Lightweight error boundary that renders the loading component with the error
|
|
16
|
+
* when a dynamic() loader rejects. Without this, loader failures would propagate
|
|
17
|
+
* uncaught through React's rendering — this preserves the Next.js behavior where
|
|
18
|
+
* the `loading` component can display errors.
|
|
19
|
+
*
|
|
20
|
+
* Lazily created because React.Component is not available in the RSC environment
|
|
21
|
+
* (server components use a slimmed-down React that doesn't include class components).
|
|
22
|
+
*/
|
|
23
|
+
let DynamicErrorBoundary;
|
|
24
|
+
function getDynamicErrorBoundary() {
|
|
25
|
+
if (DynamicErrorBoundary)
|
|
26
|
+
return DynamicErrorBoundary;
|
|
27
|
+
if (!React.Component)
|
|
28
|
+
return null;
|
|
29
|
+
DynamicErrorBoundary = class extends React.Component {
|
|
30
|
+
constructor(props) {
|
|
31
|
+
super(props);
|
|
32
|
+
this.state = { error: null };
|
|
33
|
+
}
|
|
34
|
+
static getDerivedStateFromError(error) {
|
|
35
|
+
return { error: error instanceof Error ? error : new Error(String(error)) };
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
if (this.state.error) {
|
|
39
|
+
return React.createElement(this.props.fallback, {
|
|
40
|
+
isLoading: false,
|
|
41
|
+
pastDelay: true,
|
|
42
|
+
error: this.state.error,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return this.props.children;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return DynamicErrorBoundary;
|
|
49
|
+
}
|
|
50
|
+
// Detect server vs client
|
|
51
|
+
const isServer = typeof window === "undefined";
|
|
52
|
+
// Legacy preload queue — kept for backward compatibility with Pages Router
|
|
53
|
+
// which calls flushPreloads() before rendering. The App Router uses React.lazy
|
|
54
|
+
// + Suspense instead, so this queue is no longer populated.
|
|
55
|
+
const preloadQueue = [];
|
|
56
|
+
/**
|
|
57
|
+
* Wait for all pending dynamic() preloads to resolve, then clear the queue.
|
|
58
|
+
* Called by the Pages Router SSR handler before rendering.
|
|
59
|
+
* No-op for the App Router path which uses React.lazy + Suspense.
|
|
60
|
+
*/
|
|
61
|
+
export function flushPreloads() {
|
|
62
|
+
const pending = preloadQueue.splice(0);
|
|
63
|
+
return Promise.all(pending);
|
|
64
|
+
}
|
|
65
|
+
function dynamic(loader, options) {
|
|
66
|
+
const { loading: LoadingComponent, ssr = true } = options ?? {};
|
|
67
|
+
// ssr: false — render nothing on the server, lazy-load on client
|
|
68
|
+
if (!ssr) {
|
|
69
|
+
if (isServer) {
|
|
70
|
+
// On the server, just render the loading state or nothing
|
|
71
|
+
const SSRFalse = (_props) => {
|
|
72
|
+
return LoadingComponent
|
|
73
|
+
? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })
|
|
74
|
+
: null;
|
|
75
|
+
};
|
|
76
|
+
SSRFalse.displayName = "DynamicSSRFalse";
|
|
77
|
+
return SSRFalse;
|
|
78
|
+
}
|
|
79
|
+
// Client: use lazy with Suspense
|
|
80
|
+
const LazyComponent = lazy(async () => {
|
|
81
|
+
const mod = await loader();
|
|
82
|
+
if ("default" in mod)
|
|
83
|
+
return mod;
|
|
84
|
+
return { default: mod };
|
|
85
|
+
});
|
|
86
|
+
const ClientSSRFalse = (props) => {
|
|
87
|
+
const [mounted, setMounted] = useState(false);
|
|
88
|
+
useEffect(() => setMounted(true), []);
|
|
89
|
+
if (!mounted) {
|
|
90
|
+
return LoadingComponent
|
|
91
|
+
? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })
|
|
92
|
+
: null;
|
|
93
|
+
}
|
|
94
|
+
const fallback = LoadingComponent
|
|
95
|
+
? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })
|
|
96
|
+
: null;
|
|
97
|
+
return React.createElement(Suspense, { fallback }, React.createElement(LazyComponent, props));
|
|
98
|
+
};
|
|
99
|
+
ClientSSRFalse.displayName = "DynamicClientSSRFalse";
|
|
100
|
+
return ClientSSRFalse;
|
|
101
|
+
}
|
|
102
|
+
// SSR-enabled path
|
|
103
|
+
if (isServer) {
|
|
104
|
+
// Use React.lazy so that renderToReadableStream can suspend until the
|
|
105
|
+
// dynamically-imported component is available. The previous eager-load
|
|
106
|
+
// pattern relied on flushPreloads() being called before rendering, which
|
|
107
|
+
// works for the Pages Router but not the App Router where client modules
|
|
108
|
+
// are loaded lazily during RSC stream deserialization (issue #75).
|
|
109
|
+
const LazyServer = lazy(async () => {
|
|
110
|
+
const mod = await loader();
|
|
111
|
+
if ("default" in mod)
|
|
112
|
+
return mod;
|
|
113
|
+
return { default: mod };
|
|
114
|
+
});
|
|
115
|
+
const ServerDynamic = (props) => {
|
|
116
|
+
const fallback = LoadingComponent
|
|
117
|
+
? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })
|
|
118
|
+
: null;
|
|
119
|
+
const lazyElement = React.createElement(LazyServer, props);
|
|
120
|
+
// Wrap with error boundary so loader rejections render the loading
|
|
121
|
+
// component with the error instead of propagating uncaught.
|
|
122
|
+
const ErrorBoundary = LoadingComponent ? getDynamicErrorBoundary() : null;
|
|
123
|
+
const content = ErrorBoundary
|
|
124
|
+
? React.createElement(ErrorBoundary, { fallback: LoadingComponent }, lazyElement)
|
|
125
|
+
: lazyElement;
|
|
126
|
+
return React.createElement(Suspense, { fallback }, content);
|
|
127
|
+
};
|
|
128
|
+
ServerDynamic.displayName = "DynamicServer";
|
|
129
|
+
return ServerDynamic;
|
|
130
|
+
}
|
|
131
|
+
// Client path: standard React.lazy with Suspense
|
|
132
|
+
const LazyComponent = lazy(async () => {
|
|
133
|
+
const mod = await loader();
|
|
134
|
+
if ("default" in mod)
|
|
135
|
+
return mod;
|
|
136
|
+
return { default: mod };
|
|
137
|
+
});
|
|
138
|
+
const ClientDynamic = (props) => {
|
|
139
|
+
const fallback = LoadingComponent
|
|
140
|
+
? React.createElement(LoadingComponent, { isLoading: true, pastDelay: true, error: null })
|
|
141
|
+
: null;
|
|
142
|
+
return React.createElement(Suspense, { fallback }, React.createElement(LazyComponent, props));
|
|
143
|
+
};
|
|
144
|
+
ClientDynamic.displayName = "DynamicClient";
|
|
145
|
+
return ClientDynamic;
|
|
146
|
+
}
|
|
147
|
+
export default dynamic;
|
|
148
|
+
//# sourceMappingURL=dynamic.js.map
|
|
@@ -0,0 +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,EACR,EAAE,QAAQ,EAAE,EACZ,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,CAAC,CAC1C,CAAC;IACJ,CAAC,CAAC;IAEF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC;IAC5C,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ErrorBoundaryProps {
|
|
3
|
+
fallback: React.ComponentType<{
|
|
4
|
+
error: Error;
|
|
5
|
+
reset: () => void;
|
|
6
|
+
}>;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
interface ErrorBoundaryState {
|
|
10
|
+
error: Error | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generic ErrorBoundary used to wrap route segments with error.tsx.
|
|
14
|
+
* This must be a client component since error boundaries use
|
|
15
|
+
* componentDidCatch / getDerivedStateFromError.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
18
|
+
constructor(props: ErrorBoundaryProps);
|
|
19
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
20
|
+
reset: () => void;
|
|
21
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
22
|
+
}
|
|
23
|
+
interface NotFoundBoundaryProps {
|
|
24
|
+
fallback: React.ReactNode;
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wrapper that reads the current pathname and passes it to the inner class
|
|
29
|
+
* component. This enables automatic reset on client-side navigation.
|
|
30
|
+
*/
|
|
31
|
+
export declare function NotFoundBoundary({ fallback, children }: NotFoundBoundaryProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=error-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../src/shims/error-boundary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAC;IACnE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,UAAU,kBAAkB;IAC1B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,KAAK,CAAC,SAAS,CAChD,kBAAkB,EAClB,kBAAkB,CACnB;gBACa,KAAK,EAAE,kBAAkB;IAKrC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB;IAiBjE,KAAK,aAEH;IAEF,MAAM;CASP;AAMD,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AA8DD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,qBAAqB,2CAO7E"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- next/navigation is shimmed
|
|
5
|
+
import { usePathname } from "next/navigation";
|
|
6
|
+
/**
|
|
7
|
+
* Generic ErrorBoundary used to wrap route segments with error.tsx.
|
|
8
|
+
* This must be a client component since error boundaries use
|
|
9
|
+
* componentDidCatch / getDerivedStateFromError.
|
|
10
|
+
*/
|
|
11
|
+
export class ErrorBoundary extends React.Component {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.state = { error: null };
|
|
15
|
+
}
|
|
16
|
+
static getDerivedStateFromError(error) {
|
|
17
|
+
// notFound(), forbidden(), unauthorized(), and redirect() must propagate
|
|
18
|
+
// past error boundaries. Re-throw them so they bubble up to the
|
|
19
|
+
// framework's HTTP access fallback / redirect handler.
|
|
20
|
+
if (error && typeof error === "object" && "digest" in error) {
|
|
21
|
+
const digest = String(error.digest);
|
|
22
|
+
if (digest === "NEXT_NOT_FOUND" || // legacy compat
|
|
23
|
+
digest.startsWith("NEXT_HTTP_ERROR_FALLBACK;") ||
|
|
24
|
+
digest.startsWith("NEXT_REDIRECT;")) {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { error };
|
|
29
|
+
}
|
|
30
|
+
reset = () => {
|
|
31
|
+
this.setState({ error: null });
|
|
32
|
+
};
|
|
33
|
+
render() {
|
|
34
|
+
if (this.state.error) {
|
|
35
|
+
const FallbackComponent = this.props.fallback;
|
|
36
|
+
return (_jsx(FallbackComponent, { error: this.state.error, reset: this.reset }));
|
|
37
|
+
}
|
|
38
|
+
return this.props.children;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Inner class component that catches notFound() errors and renders the
|
|
43
|
+
* not-found.tsx fallback. Resets when the pathname changes (client navigation)
|
|
44
|
+
* so a previous notFound() doesn't permanently stick.
|
|
45
|
+
*
|
|
46
|
+
* The ErrorBoundary above re-throws notFound errors so they propagate up to this
|
|
47
|
+
* boundary. This must be placed above the ErrorBoundary in the component tree.
|
|
48
|
+
*/
|
|
49
|
+
class NotFoundBoundaryInner extends React.Component {
|
|
50
|
+
constructor(props) {
|
|
51
|
+
super(props);
|
|
52
|
+
this.state = { notFound: false, previousPathname: props.pathname };
|
|
53
|
+
}
|
|
54
|
+
static getDerivedStateFromProps(props, state) {
|
|
55
|
+
// Reset the boundary when the route changes so a previous notFound()
|
|
56
|
+
// doesn't permanently stick after client-side navigation.
|
|
57
|
+
if (props.pathname !== state.previousPathname && state.notFound) {
|
|
58
|
+
return { notFound: false, previousPathname: props.pathname };
|
|
59
|
+
}
|
|
60
|
+
return { notFound: state.notFound, previousPathname: props.pathname };
|
|
61
|
+
}
|
|
62
|
+
static getDerivedStateFromError(error) {
|
|
63
|
+
if (error && typeof error === "object" && "digest" in error) {
|
|
64
|
+
const digest = String(error.digest);
|
|
65
|
+
if (digest === "NEXT_NOT_FOUND" ||
|
|
66
|
+
digest.startsWith("NEXT_HTTP_ERROR_FALLBACK;404")) {
|
|
67
|
+
return { notFound: true };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Not a notFound error — re-throw so it reaches an ErrorBoundary or propagates
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
if (this.state.notFound) {
|
|
75
|
+
return this.props.fallback;
|
|
76
|
+
}
|
|
77
|
+
return this.props.children;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Wrapper that reads the current pathname and passes it to the inner class
|
|
82
|
+
* component. This enables automatic reset on client-side navigation.
|
|
83
|
+
*/
|
|
84
|
+
export function NotFoundBoundary({ fallback, children }) {
|
|
85
|
+
const pathname = usePathname();
|
|
86
|
+
return (_jsx(NotFoundBoundaryInner, { pathname: pathname, fallback: fallback, children: children }));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=error-boundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-boundary.js","sourceRoot":"","sources":["../../src/shims/error-boundary.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,+FAA+F;AAC/F,OAAO,EAAE,WAAW,EAAE,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AQ,EAAyB;IAC5E,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,OAAO,CACL,KAAC,qBAAqB,IAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,YAC1D,QAAQ,GACa,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* next/error shim
|
|
3
|
+
*
|
|
4
|
+
* Provides the default Next.js error page component.
|
|
5
|
+
* Used by apps that import `import Error from 'next/error'` for
|
|
6
|
+
* custom error handling in getServerSideProps or API routes.
|
|
7
|
+
*/
|
|
8
|
+
import React from "react";
|
|
9
|
+
interface ErrorProps {
|
|
10
|
+
statusCode: number;
|
|
11
|
+
title?: string;
|
|
12
|
+
withDarkMode?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare function ErrorComponent({ statusCode, title }: ErrorProps): React.ReactElement;
|
|
15
|
+
export default ErrorComponent;
|
|
16
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/shims/error.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,iBAAS,cAAc,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,UAAU,GAAG,KAAK,CAAC,YAAY,CA2D7E;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* next/error shim
|
|
3
|
+
*
|
|
4
|
+
* Provides the default Next.js error page component.
|
|
5
|
+
* Used by apps that import `import Error from 'next/error'` for
|
|
6
|
+
* custom error handling in getServerSideProps or API routes.
|
|
7
|
+
*/
|
|
8
|
+
import React from "react";
|
|
9
|
+
function ErrorComponent({ statusCode, title }) {
|
|
10
|
+
const defaultTitle = statusCode === 404
|
|
11
|
+
? "This page could not be found"
|
|
12
|
+
: "Internal Server Error";
|
|
13
|
+
const displayTitle = title ?? defaultTitle;
|
|
14
|
+
return React.createElement("div", {
|
|
15
|
+
style: {
|
|
16
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
17
|
+
height: "100vh",
|
|
18
|
+
textAlign: "center",
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
justifyContent: "center",
|
|
23
|
+
},
|
|
24
|
+
}, React.createElement("div", null, React.createElement("h1", {
|
|
25
|
+
style: {
|
|
26
|
+
display: "inline-block",
|
|
27
|
+
margin: "0 20px 0 0",
|
|
28
|
+
padding: "0 23px 0 0",
|
|
29
|
+
fontSize: 24,
|
|
30
|
+
fontWeight: 500,
|
|
31
|
+
verticalAlign: "top",
|
|
32
|
+
lineHeight: "49px",
|
|
33
|
+
borderRight: "1px solid rgba(0, 0, 0, .3)",
|
|
34
|
+
},
|
|
35
|
+
}, statusCode), React.createElement("div", { style: { display: "inline-block" } }, React.createElement("h2", {
|
|
36
|
+
style: {
|
|
37
|
+
fontSize: 14,
|
|
38
|
+
fontWeight: 400,
|
|
39
|
+
lineHeight: "49px",
|
|
40
|
+
margin: 0,
|
|
41
|
+
},
|
|
42
|
+
}, displayTitle + "."))));
|
|
43
|
+
}
|
|
44
|
+
export default ErrorComponent;
|
|
45
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/shims/error.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,SAAS,cAAc,CAAC,EAAE,UAAU,EAAE,KAAK,EAAc;IACvD,MAAM,YAAY,GAChB,UAAU,KAAK,GAAG;QAChB,CAAC,CAAC,8BAA8B;QAChC,CAAC,CAAC,uBAAuB,CAAC;IAE9B,MAAM,YAAY,GAAG,KAAK,IAAI,YAAY,CAAC;IAE3C,OAAO,KAAK,CAAC,aAAa,CACxB,KAAK,EACL;QACE,KAAK,EAAE;YACL,UAAU,EACR,4FAA4F;YAC9F,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,QAAiB;YAC5B,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,QAAiB;YAChC,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;SACzB;KACF,EACD,KAAK,CAAC,aAAa,CACjB,KAAK,EACL,IAAI,EACJ,KAAK,CAAC,aAAa,CACjB,IAAI,EACJ;QACE,KAAK,EAAE;YACL,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,YAAY;YACpB,OAAO,EAAE,YAAY;YACrB,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,GAAG;YACf,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,MAAM;YAClB,WAAW,EAAE,6BAA6B;SAC3C;KACF,EACD,UAAU,CACX,EACD,KAAK,CAAC,aAAa,CACjB,KAAK,EACL,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EACtC,KAAK,CAAC,aAAa,CACjB,IAAI,EACJ;QACE,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,MAAM;YAClB,MAAM,EAAE,CAAC;SACV;KACF,EACD,YAAY,GAAG,GAAG,CACnB,CACF,CACF,CACF,CAAC;AACJ,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extended fetch() with Next.js caching semantics.
|
|
3
|
+
*
|
|
4
|
+
* Patches `globalThis.fetch` during server rendering to support:
|
|
5
|
+
*
|
|
6
|
+
* fetch(url, { next: { revalidate: 60, tags: ['posts'] } })
|
|
7
|
+
* fetch(url, { cache: 'force-cache' })
|
|
8
|
+
* fetch(url, { cache: 'no-store' })
|
|
9
|
+
*
|
|
10
|
+
* Cached responses are stored via the pluggable CacheHandler, so
|
|
11
|
+
* revalidateTag() and revalidatePath() invalidate fetch-level caches.
|
|
12
|
+
*
|
|
13
|
+
* Usage (in server entry):
|
|
14
|
+
* import { withFetchCache, cleanupFetchCache } from './fetch-cache';
|
|
15
|
+
* const cleanup = withFetchCache();
|
|
16
|
+
* try { ... render ... } finally { cleanup(); }
|
|
17
|
+
*
|
|
18
|
+
* Or use the async helper:
|
|
19
|
+
* await runWithFetchCache(async () => { ... render ... });
|
|
20
|
+
*/
|
|
21
|
+
interface NextFetchOptions {
|
|
22
|
+
revalidate?: number | false;
|
|
23
|
+
tags?: string[];
|
|
24
|
+
}
|
|
25
|
+
declare global {
|
|
26
|
+
interface RequestInit {
|
|
27
|
+
next?: NextFetchOptions;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get tags collected during the current render pass.
|
|
32
|
+
* Useful for associating page-level cache entries with all the
|
|
33
|
+
* fetch tags used during rendering.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getCollectedFetchTags(): string[];
|
|
36
|
+
/**
|
|
37
|
+
* Install the patched fetch and reset per-request tag state.
|
|
38
|
+
* Returns a cleanup function that clears tags.
|
|
39
|
+
*
|
|
40
|
+
* In single-threaded contexts (dev server, tests) this is safe because
|
|
41
|
+
* requests are sequential. For concurrent environments, prefer
|
|
42
|
+
* `runWithFetchCache()` which uses `AsyncLocalStorage.run()`.
|
|
43
|
+
*
|
|
44
|
+
* Usage:
|
|
45
|
+
* const cleanup = withFetchCache();
|
|
46
|
+
* try { await render(); } finally { cleanup(); }
|
|
47
|
+
*/
|
|
48
|
+
export declare function withFetchCache(): () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Run an async function with patched fetch caching enabled.
|
|
51
|
+
* Uses `AsyncLocalStorage.run()` for proper per-request isolation
|
|
52
|
+
* of collected fetch tags in concurrent server environments.
|
|
53
|
+
*/
|
|
54
|
+
export declare function runWithFetchCache<T>(fn: () => Promise<T>): Promise<T>;
|
|
55
|
+
/**
|
|
56
|
+
* Get the original (unpatched) fetch function.
|
|
57
|
+
* Useful for internal code that should bypass caching.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getOriginalFetch(): typeof globalThis.fetch;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=fetch-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-cache.d.ts","sourceRoot":"","sources":["../../src/shims/fetch-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAgDH,UAAU,gBAAgB;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,WAAW;QACnB,IAAI,CAAC,EAAE,gBAAgB,CAAC;KACzB;CACF;AA0CD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD;AAyMD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,IAAI,MAAM,IAAI,CAO3C;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAG3E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,UAAU,CAAC,KAAK,CAE1D"}
|