vinext 0.1.4 → 0.1.5
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/dist/build/css-url-assets.d.ts +1 -1
- package/dist/build/css-url-assets.js +9 -7
- package/dist/build/prerender.js +2 -1
- package/dist/cache/cache-adapters-virtual.js +1 -1
- package/dist/cloudflare/src/cache/kv-data-adapter.runtime.d.ts +1 -1
- package/dist/entries/app-rsc-entry.js +24 -20
- package/dist/entries/pages-server-entry.js +2 -1
- package/dist/index.js +187 -146
- package/dist/plugins/css-data-url.js +30 -26
- package/dist/plugins/extensionless-dynamic-import.js +27 -24
- package/dist/plugins/import-meta-url.js +21 -15
- package/dist/plugins/instrumentation-client.js +1 -1
- package/dist/plugins/middleware-server-only.js +7 -6
- package/dist/plugins/og-assets.js +48 -46
- package/dist/plugins/optimize-imports.js +9 -3
- package/dist/plugins/remove-console.d.ts +7 -1
- package/dist/plugins/remove-console.js +4 -1
- package/dist/plugins/require-context.js +21 -20
- package/dist/plugins/strip-server-exports.d.ts +7 -1
- package/dist/plugins/strip-server-exports.js +4 -1
- package/dist/server/app-bfcache-identity.d.ts +26 -0
- package/dist/server/app-bfcache-identity.js +127 -0
- package/dist/server/app-browser-entry.js +14 -11
- package/dist/server/app-browser-navigation-controller.js +1 -1
- package/dist/server/app-browser-state.d.ts +2 -21
- package/dist/server/app-browser-state.js +4 -128
- package/dist/server/app-browser-stream.js +1 -1
- package/dist/server/app-browser-visible-commit.js +3 -2
- package/dist/server/app-fallback-renderer.d.ts +1 -1
- package/dist/server/app-layout-param-observation.d.ts +1 -1
- package/dist/server/app-layout-param-observation.js +1 -1
- package/dist/server/app-middleware.js +2 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -1
- package/dist/server/app-page-boundary.js +1 -1
- package/dist/server/app-page-cache-finalizer.d.ts +62 -0
- package/dist/server/app-page-cache-finalizer.js +122 -0
- package/dist/server/app-page-cache-render.d.ts +2 -2
- package/dist/server/app-page-cache-render.js +1 -1
- package/dist/server/app-page-cache.d.ts +2 -53
- package/dist/server/app-page-cache.js +5 -131
- package/dist/server/app-page-dispatch.d.ts +2 -2
- package/dist/server/app-page-dispatch.js +10 -8
- package/dist/server/app-page-probe.js +3 -2
- package/dist/server/app-page-render-observation.js +2 -2
- package/dist/server/app-page-render.d.ts +3 -3
- package/dist/server/app-page-render.js +3 -2
- package/dist/server/app-page-stream.d.ts +2 -9
- package/dist/server/app-page-stream.js +1 -35
- package/dist/server/app-request-context.d.ts +1 -2
- package/dist/server/app-request-context.js +2 -1
- package/dist/server/app-route-handler-dispatch.js +3 -2
- package/dist/server/app-route-handler-execution.d.ts +1 -1
- package/dist/server/app-route-handler-execution.js +1 -1
- package/dist/server/app-route-handler-response.d.ts +1 -1
- package/dist/server/app-router-entry.js +2 -1
- package/dist/server/app-rsc-handler.js +22 -16
- package/dist/server/app-rsc-response-finalizer.js +1 -1
- package/dist/server/app-server-action-execution.d.ts +1 -1
- package/dist/server/app-server-action-execution.js +5 -4
- package/dist/server/app-ssr-entry.d.ts +1 -1
- package/dist/server/app-ssr-entry.js +11 -9
- package/dist/server/app-ssr-router-instance.d.ts +6 -0
- package/dist/server/app-ssr-router-instance.js +24 -0
- package/dist/server/app-ssr-stream.js +1 -1
- package/dist/server/artifact-compatibility.js +1 -1
- package/dist/server/client-reuse-manifest.js +1 -1
- package/dist/server/defer-until-stream-consumed.d.ts +7 -0
- package/dist/server/defer-until-stream-consumed.js +34 -0
- package/dist/server/dev-server.js +1 -1
- package/dist/server/instrumentation.js +1 -1
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +1 -1
- package/dist/server/isr-decision.d.ts +1 -1
- package/dist/server/middleware-matcher.js +8 -6
- package/dist/server/middleware-runtime.js +2 -2
- package/dist/server/open-redirect.d.ts +12 -0
- package/dist/server/open-redirect.js +21 -0
- package/dist/server/pages-page-data.d.ts +1 -1
- package/dist/server/pages-page-response.d.ts +1 -1
- package/dist/server/pages-page-response.js +2 -2
- package/dist/server/prod-server.js +2 -1
- package/dist/server/request-pipeline.d.ts +1 -24
- package/dist/server/request-pipeline.js +1 -33
- package/dist/server/seed-cache.d.ts +1 -1
- package/dist/shims/cache-handler.d.ts +106 -0
- package/dist/shims/cache-handler.js +176 -0
- package/dist/shims/cache-request-state.d.ts +47 -0
- package/dist/shims/cache-request-state.js +126 -0
- package/dist/shims/cache-runtime.d.ts +2 -2
- package/dist/shims/cache-runtime.js +3 -14
- package/dist/shims/cache.d.ts +3 -231
- package/dist/shims/cache.js +17 -383
- package/dist/shims/cdn-cache.d.ts +1 -1
- package/dist/shims/cdn-cache.js +1 -1
- package/dist/shims/error-boundary-navigation.d.ts +7 -0
- package/dist/shims/error-boundary-navigation.js +44 -0
- package/dist/shims/error-boundary.js +10 -8
- package/dist/shims/error.js +2 -1
- package/dist/shims/fetch-cache.js +1 -1
- package/dist/shims/form.js +1 -1
- package/dist/shims/image.js +67 -9
- package/dist/shims/internal/app-page-props-cache-key.d.ts +5 -0
- package/dist/shims/internal/app-page-props-cache-key.js +16 -0
- package/dist/shims/internal/navigation-untracked.js +2 -1
- package/dist/shims/layout-segment-context.d.ts +1 -1
- package/dist/shims/layout-segment-context.js +2 -1
- package/dist/shims/link.js +2 -2
- package/dist/shims/navigation-context-state.d.ts +40 -0
- package/dist/shims/navigation-context-state.js +116 -0
- package/dist/shims/navigation-errors.d.ts +55 -0
- package/dist/shims/navigation-errors.js +110 -0
- package/dist/shims/navigation-server.d.ts +3 -0
- package/dist/shims/navigation-server.js +3 -0
- package/dist/shims/navigation-state.d.ts +1 -2
- package/dist/shims/navigation-state.js +2 -1
- package/dist/shims/navigation.d.ts +3 -291
- package/dist/shims/navigation.js +14 -445
- package/dist/shims/navigation.react-server.d.ts +2 -2
- package/dist/shims/navigation.react-server.js +3 -1
- package/dist/shims/request-state-types.d.ts +3 -3
- package/dist/shims/script.js +1 -1
- package/dist/shims/slot.js +3 -1
- package/dist/shims/unified-request-context.d.ts +2 -2
- package/dist/utils/virtual-module.d.ts +5 -0
- package/dist/utils/virtual-module.js +0 -0
- package/package.json +5 -1
|
@@ -10,7 +10,7 @@ type EmitRestoredCssUrlAsset = (asset: {
|
|
|
10
10
|
/**
|
|
11
11
|
* Append the private provenance marker to each relative asset `url()` in a CSS
|
|
12
12
|
* source. Idempotent and side-effect free (only adds a query param), so it is
|
|
13
|
-
* safe to run on every
|
|
13
|
+
* safe to run on every build-environment stylesheet, vendored CSS included.
|
|
14
14
|
*/
|
|
15
15
|
declare function markCssUrlAssetReferences(code: string, id: string): string | null;
|
|
16
16
|
/**
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
* vitejs/vite#8632). The one native escape hatch is `this.emitFile({ fileName })`:
|
|
13
13
|
* assets emitted with an explicit `fileName` are *never* deduped. So we:
|
|
14
14
|
*
|
|
15
|
-
* 1. mark — during
|
|
16
|
-
* with a private `?vinext_css_url_asset=<source-basename>` query.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
15
|
+
* 1. mark — during every production CSS transform, tag each relative asset
|
|
16
|
+
* `url()` with a private `?vinext_css_url_asset=<source-basename>` query.
|
|
17
|
+
* Using identical transformed CSS in server and client environments is
|
|
18
|
+
* required because the default CSS Modules scoped name hashes the full CSS
|
|
19
|
+
* text. The marker is also the only durable carrier of per-reference
|
|
20
|
+
* provenance: once Rolldown dedupes, the emitted bundle cannot tell which
|
|
21
|
+
* `url()` came from which source, and bundle metadata records the source
|
|
22
|
+
* set but not the mapping per reference.
|
|
21
23
|
*
|
|
22
24
|
* 2. restore — at `generateBundle`, read each marked reference's source
|
|
23
25
|
* basename back out. When it differs from the deduped output's basename,
|
|
@@ -109,7 +111,7 @@ function rewriteCssUrls(code, replace) {
|
|
|
109
111
|
/**
|
|
110
112
|
* Append the private provenance marker to each relative asset `url()` in a CSS
|
|
111
113
|
* source. Idempotent and side-effect free (only adds a query param), so it is
|
|
112
|
-
* safe to run on every
|
|
114
|
+
* safe to run on every build-environment stylesheet, vendored CSS included.
|
|
113
115
|
*/
|
|
114
116
|
function markCssUrlAssetReferences(code, id) {
|
|
115
117
|
if (!isCssRequest(id) || !code.includes("url(")) return null;
|
package/dist/build/prerender.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createValidFileMatcher, findFileWithExtensions } from "../routing/file-matcher.js";
|
|
2
2
|
import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER } from "../server/headers.js";
|
|
3
3
|
import { normalizeStaticPathsEntry } from "../routing/route-pattern.js";
|
|
4
|
+
import { NoOpCacheHandler, getCacheHandler, setCacheHandler } from "../shims/cache-handler.js";
|
|
4
5
|
import { headersContextFromRequest, runWithHeadersContext } from "../shims/headers.js";
|
|
5
|
-
import {
|
|
6
|
+
import { _consumeRequestScopedCacheLife } from "../shims/cache-request-state.js";
|
|
6
7
|
import { classifyAppRoute, classifyPagesRoute, getAppRouteRenderEntryPath } from "./report.js";
|
|
7
8
|
import { BLOCKED_PAGES } from "../shims/constants.js";
|
|
8
9
|
import { concatUint8Arrays, decodeRscEmbeddedChunk } from "../server/app-rsc-embedded-chunks.js";
|
|
@@ -29,7 +29,7 @@ function generateCacheAdaptersModule(cache) {
|
|
|
29
29
|
const lines = ["// vinext: generated from the `cache` option in your vinext() plugin config."];
|
|
30
30
|
if (data?.adapter) {
|
|
31
31
|
lines.push(`import __vinextDataAdapterFactory from ${JSON.stringify(data.adapter)};`);
|
|
32
|
-
lines.push(`import { setDataCacheHandler } from "vinext/shims/cache";`);
|
|
32
|
+
lines.push(`import { setDataCacheHandler } from "vinext/shims/cache-handler";`);
|
|
33
33
|
}
|
|
34
34
|
if (cdn?.adapter) {
|
|
35
35
|
lines.push(`import __vinextCdnAdapterFactory from ${JSON.stringify(cdn.adapter)};`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { CacheHandler, CacheHandlerValue, IncrementalCacheValue } from "../../../shims/cache-handler.js";
|
|
1
2
|
import { ExecutionContextLike } from "../../../shims/request-context.js";
|
|
2
|
-
import { CacheHandler, CacheHandlerValue, IncrementalCacheValue } from "../../../shims/cache.js";
|
|
3
3
|
|
|
4
4
|
//#region ../cloudflare/src/cache/kv-data-adapter.runtime.d.ts
|
|
5
5
|
type KVNamespace = {
|
|
@@ -18,7 +18,6 @@ const DEFAULT_EXPIRE_TIME = 31536e3;
|
|
|
18
18
|
const DEFAULT_REACT_MAX_HEADERS_LENGTH = 6e3;
|
|
19
19
|
const middlewareRequestHeadersPath = resolveEntryPath("../server/middleware-request-headers.js", import.meta.url);
|
|
20
20
|
const normalizePathModulePath = resolveEntryPath("../server/normalize-path.js", import.meta.url);
|
|
21
|
-
const appRscHandlerPath = resolveEntryPath("../server/app-rsc-handler.js", import.meta.url);
|
|
22
21
|
const appRouteHandlerDispatchPath = resolveEntryPath("../server/app-route-handler-dispatch.js", import.meta.url);
|
|
23
22
|
const appRouteHandlerResponsePath = resolveEntryPath("../server/app-route-handler-response.js", import.meta.url);
|
|
24
23
|
const appServerActionExecutionPath = resolveEntryPath("../server/app-server-action-execution.js", import.meta.url);
|
|
@@ -110,29 +109,21 @@ const prerenderToReadableStream = createRscPrerenderer(async (model, options) =>
|
|
|
110
109
|
);
|
|
111
110
|
import { createElement } from "react";
|
|
112
111
|
import { getNavigationContext as _getNavigationContext } from "next/navigation";
|
|
113
|
-
import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "
|
|
112
|
+
import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
|
|
114
113
|
import { headersContextFromRequest, getDraftModeCookieHeader, getAndClearPendingCookies, consumeDynamicUsage, consumeInvalidDynamicUsageError, setHeadersAccessPhase } from "next/headers";
|
|
115
114
|
import { mergeMetadata, resolveModuleMetadata, mergeViewport, resolveModuleViewport } from "vinext/metadata";
|
|
116
115
|
${middlewarePath ? `import * as middlewareModule from ${JSON.stringify(normalizePathSeparators(middlewarePath))};` : ""}
|
|
117
116
|
${instrumentationPath ? `import * as _instrumentation from ${JSON.stringify(normalizePathSeparators(instrumentationPath))};
|
|
118
117
|
import { ensureInstrumentationRegistered as __ensureInstrumentationRegistered } from ${JSON.stringify(instrumentationRuntimePath)};` : ""}
|
|
119
|
-
import { createAppRscHandler
|
|
118
|
+
import { createAppRscHandler } from "vinext/server/app-rsc-handler";
|
|
120
119
|
import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
121
120
|
import { decodePathParams as __decodePathParams } from ${JSON.stringify(normalizePathModulePath)};
|
|
122
121
|
import { buildRequestHeadersFromMiddlewareResponse as __buildRequestHeadersFromMiddlewareResponse } from ${JSON.stringify(middlewareRequestHeadersPath)};
|
|
123
|
-
import {
|
|
124
|
-
dispatchAppRouteHandler as __dispatchAppRouteHandler,
|
|
125
|
-
} from ${JSON.stringify(appRouteHandlerDispatchPath)};
|
|
126
|
-
import {
|
|
122
|
+
${hasPagesDir ? `import {
|
|
127
123
|
applyRouteHandlerMiddlewareContext as __applyRouteHandlerMiddlewareContext,
|
|
128
|
-
} from ${JSON.stringify(appRouteHandlerResponsePath)}
|
|
129
|
-
import
|
|
130
|
-
|
|
131
|
-
handleServerActionRscRequest as __handleServerActionRscRequest,
|
|
132
|
-
isProgressiveServerActionRequest as __isProgressiveServerActionRequest,
|
|
133
|
-
readActionBodyWithLimit as __readBodyWithLimit,
|
|
134
|
-
readActionFormDataWithLimit as __readFormDataWithLimit,
|
|
135
|
-
} from ${JSON.stringify(appServerActionExecutionPath)};
|
|
124
|
+
} from ${JSON.stringify(appRouteHandlerResponsePath)};` : ""}
|
|
125
|
+
const __loadAppRouteHandlerDispatch = () => import(${JSON.stringify(appRouteHandlerDispatchPath)});
|
|
126
|
+
const __loadAppServerActionExecution = () => import(${JSON.stringify(appServerActionExecutionPath)});
|
|
136
127
|
import {
|
|
137
128
|
sanitizeErrorForClient as __sanitizeErrorForClient,
|
|
138
129
|
} from ${JSON.stringify(appRscErrorsPath)};
|
|
@@ -198,7 +189,6 @@ import { clearAppRequestContext as __clearRequestContext, setAppNavigationContex
|
|
|
198
189
|
__configureMemoryCacheHandler({ cacheMaxMemorySize: ${JSON.stringify(cacheMaxMemorySize)} });
|
|
199
190
|
import { createAppPrerenderStaticParamsResolver as __createAppPrerenderStaticParamsResolver } from ${JSON.stringify(appPrerenderStaticParamsPath)};
|
|
200
191
|
import { ensureAppRouteModulesLoaded as __ensureRouteLoaded } from ${JSON.stringify(appRouteModuleLoaderPath)};
|
|
201
|
-
import { seedMemoryCacheFromPrerender as __seedMemoryCacheFromPrerender } from ${JSON.stringify(seedCachePath)};
|
|
202
192
|
import {
|
|
203
193
|
getRenderedConcreteUrlPathsForRoute as __getRenderedConcreteUrlPathsForRoute,
|
|
204
194
|
initPregeneratedPathsFromGlobals as __initPregeneratedPathsFromGlobals,
|
|
@@ -408,7 +398,9 @@ export const __hasPagesDir = ${JSON.stringify(hasPagesDir)};
|
|
|
408
398
|
export const getRenderedConcreteUrlPathsForRoute = __getRenderedConcreteUrlPathsForRoute;
|
|
409
399
|
const __cacheComponents = ${JSON.stringify(cacheComponents)};
|
|
410
400
|
|
|
411
|
-
export function seedMemoryCacheFromPrerender(serverDir) {
|
|
401
|
+
export async function seedMemoryCacheFromPrerender(serverDir) {
|
|
402
|
+
const { seedMemoryCacheFromPrerender: __seedMemoryCacheFromPrerender } =
|
|
403
|
+
await import(${JSON.stringify(seedCachePath)});
|
|
412
404
|
return __seedMemoryCacheFromPrerender(serverDir, {
|
|
413
405
|
buildAppPageHtmlKey(pathname) {
|
|
414
406
|
return __isrHtmlKey(pathname);
|
|
@@ -450,7 +442,7 @@ const rootParamNamesMap = {
|
|
|
450
442
|
${rootParamNameEntries.join("\n")}
|
|
451
443
|
};
|
|
452
444
|
|
|
453
|
-
export default
|
|
445
|
+
export default createAppRscHandler({
|
|
454
446
|
basePath: __basePath,
|
|
455
447
|
buildId: process.env.__VINEXT_BUILD_ID ?? null,
|
|
456
448
|
ensureRouteLoaded: __ensureRouteLoaded,
|
|
@@ -652,7 +644,7 @@ export default __createAppRscHandler({
|
|
|
652
644
|
renderMode,
|
|
653
645
|
});
|
|
654
646
|
},
|
|
655
|
-
dispatchMatchedRouteHandler({
|
|
647
|
+
async dispatchMatchedRouteHandler({
|
|
656
648
|
cleanPathname,
|
|
657
649
|
middlewareContext,
|
|
658
650
|
params,
|
|
@@ -660,6 +652,8 @@ export default __createAppRscHandler({
|
|
|
660
652
|
route,
|
|
661
653
|
searchParams,
|
|
662
654
|
}) {
|
|
655
|
+
const { dispatchAppRouteHandler: __dispatchAppRouteHandler } =
|
|
656
|
+
await __loadAppRouteHandlerDispatch();
|
|
663
657
|
return __dispatchAppRouteHandler({
|
|
664
658
|
basePath: __basePath,
|
|
665
659
|
cleanPathname,
|
|
@@ -689,13 +683,18 @@ export default __createAppRscHandler({
|
|
|
689
683
|
${instrumentationPath ? `ensureInstrumentation() {
|
|
690
684
|
return __ensureInstrumentationRegistered(_instrumentation);
|
|
691
685
|
},` : ""}
|
|
692
|
-
handleProgressiveActionRequest({
|
|
686
|
+
async handleProgressiveActionRequest({
|
|
693
687
|
actionId,
|
|
694
688
|
cleanPathname,
|
|
695
689
|
contentType,
|
|
696
690
|
middlewareContext,
|
|
697
691
|
request,
|
|
698
692
|
}) {
|
|
693
|
+
const {
|
|
694
|
+
handleProgressiveServerActionRequest: __handleProgressiveServerActionRequest,
|
|
695
|
+
isProgressiveServerActionRequest: __isProgressiveServerActionRequest,
|
|
696
|
+
readActionFormDataWithLimit: __readFormDataWithLimit,
|
|
697
|
+
} = await __loadAppServerActionExecution();
|
|
699
698
|
// A multipart form POST to a page is always a server-action attempt, so a
|
|
700
699
|
// body that decodes to no action must surface as 404 action-not-found
|
|
701
700
|
// (#1340). Route handlers run after this dispatch and accept raw multipart
|
|
@@ -749,6 +748,11 @@ export default __createAppRscHandler({
|
|
|
749
748
|
request,
|
|
750
749
|
searchParams,
|
|
751
750
|
}) {
|
|
751
|
+
const {
|
|
752
|
+
handleServerActionRscRequest: __handleServerActionRscRequest,
|
|
753
|
+
readActionBodyWithLimit: __readBodyWithLimit,
|
|
754
|
+
readActionFormDataWithLimit: __readFormDataWithLimit,
|
|
755
|
+
} = await __loadAppServerActionExecution();
|
|
752
756
|
const __actionMatch = matchRoute(cleanPathname);
|
|
753
757
|
if (__actionMatch) await __ensureRouteLoaded(__actionMatch.route);
|
|
754
758
|
const __actionIsEdgeRuntime = __actionMatch
|
|
@@ -123,7 +123,8 @@ import { renderToReadableStream } from "react-dom/server.edge";
|
|
|
123
123
|
import { resetSSRHead, getSSRHeadHTML, setDocumentInitialHead } from "next/head";
|
|
124
124
|
import { flushPreloads } from "next/dynamic";
|
|
125
125
|
import Router, { setSSRContext, wrapWithRouterContext, getPagesNavigationIsReadyFromSerializedState } from "next/router";
|
|
126
|
-
import { _runWithCacheState
|
|
126
|
+
import { _runWithCacheState } from "vinext/shims/cache-request-state";
|
|
127
|
+
import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler";
|
|
127
128
|
import { registerConfiguredCacheAdapters as __registerConfiguredCacheAdapters } from "virtual:vinext-cache-adapters";
|
|
128
129
|
import { runWithPrivateCache } from "vinext/cache-runtime";
|
|
129
130
|
import { ensureFetchPatch, runWithFetchCache } from "vinext/fetch-cache";
|