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
package/dist/shims/cache.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { getOrCreateAls } from "./internal/als-registry.js";
|
|
2
|
-
import { getRequestContext, isInsideUnifiedScope
|
|
2
|
+
import { getRequestContext, isInsideUnifiedScope } from "./unified-request-context.js";
|
|
3
3
|
import { getRequestExecutionContext, runWithExecutionContext } from "./request-context.js";
|
|
4
|
+
import { MemoryCacheHandler, NoOpCacheHandler, configureMemoryCacheHandler, getCacheHandler, getDataCacheHandler, setCacheHandler, setDataCacheHandler } from "./cache-handler.js";
|
|
5
|
+
import { getCdnCacheAdapter } from "./cdn-cache.js";
|
|
6
|
+
import { fnv1a64 } from "../utils/hash.js";
|
|
4
7
|
import { makeHangingPromise } from "./internal/make-hanging-promise.js";
|
|
5
8
|
import { getHeadersAccessPhase, markDynamicUsage } from "./headers.js";
|
|
6
|
-
import {
|
|
7
|
-
import { workUnitAsyncStorage } from "./internal/work-unit-async-storage.js";
|
|
8
|
-
import { readCacheControlNumberField } from "../utils/cache-control-metadata.js";
|
|
9
|
+
import { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLifeProfiles, getAndClearActionRevalidationKind, getRegisteredCacheContext, markActionRevalidation, recordUnstableCacheObservation, shouldServeStaleUnstableCacheEntry } from "./cache-request-state.js";
|
|
9
10
|
import { encodeCacheTag, encodeCacheTags } from "../utils/encode-cache-tag.js";
|
|
10
|
-
import {
|
|
11
|
+
import { workUnitAsyncStorage } from "./internal/work-unit-async-storage.js";
|
|
11
12
|
//#region src/shims/cache.ts
|
|
12
13
|
/**
|
|
13
14
|
* next/cache shim
|
|
@@ -29,239 +30,7 @@ import { getCdnCacheAdapter } from "./cdn-cache.js";
|
|
|
29
30
|
* deprecated for consumers and retained only as the internal registration
|
|
30
31
|
* target used by the generated cache-adapter module.
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
-
let _getCacheContextFn = null;
|
|
34
|
-
/**
|
|
35
|
-
* Register the cache context accessor. Called by cache-runtime.ts on load.
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
function _registerCacheContextAccessor(fn) {
|
|
39
|
-
_getCacheContextFn = fn;
|
|
40
|
-
}
|
|
41
|
-
var NoOpCacheHandler = class {
|
|
42
|
-
async get(_key, _ctx) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
async set(_key, _data, _ctx) {}
|
|
46
|
-
async revalidateTag(_tags, _durations) {}
|
|
47
|
-
};
|
|
48
|
-
const DEFAULT_MEMORY_CACHE_MAX_SIZE = 50 * 1024 * 1024;
|
|
49
|
-
const MAX_REVALIDATED_TAG_ENTRIES = 1e4;
|
|
50
|
-
function estimateStringMapSize(map) {
|
|
51
|
-
if (!map) return 0;
|
|
52
|
-
let size = 0;
|
|
53
|
-
for (const [key, value] of Object.entries(map)) {
|
|
54
|
-
size += key.length;
|
|
55
|
-
if (Array.isArray(value)) for (const item of value) size += item.length;
|
|
56
|
-
else size += value.length;
|
|
57
|
-
}
|
|
58
|
-
return size;
|
|
59
|
-
}
|
|
60
|
-
function estimateIncrementalCacheValueSize(value) {
|
|
61
|
-
if (value === null) return 25;
|
|
62
|
-
switch (value.kind) {
|
|
63
|
-
case "FETCH": return JSON.stringify(value.data ?? "").length;
|
|
64
|
-
case "PAGES": return value.html.length + JSON.stringify(value.pageData ?? {}).length + estimateStringMapSize(value.headers);
|
|
65
|
-
case "APP_PAGE": return value.html.length + (value.rscData?.byteLength ?? 0) + (value.postponed?.length ?? 0) + estimateStringMapSize(value.headers);
|
|
66
|
-
case "APP_ROUTE": return value.body.byteLength + estimateStringMapSize(value.headers);
|
|
67
|
-
case "REDIRECT": return JSON.stringify(value.props ?? {}).length;
|
|
68
|
-
case "IMAGE": return value.buffer.byteLength + value.extension.length + value.etag.length;
|
|
69
|
-
default: return JSON.stringify(value).length;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function resolveMemoryCacheMaxSize(options) {
|
|
73
|
-
if (typeof options === "number") return options;
|
|
74
|
-
if (typeof options?.cacheMaxMemorySize === "number") return options.cacheMaxMemorySize;
|
|
75
|
-
if (typeof options?.maxMemoryCacheSize === "number") return options.maxMemoryCacheSize;
|
|
76
|
-
return DEFAULT_MEMORY_CACHE_MAX_SIZE;
|
|
77
|
-
}
|
|
78
|
-
function readStringArrayField(ctx, field) {
|
|
79
|
-
const value = ctx?.[field];
|
|
80
|
-
if (!Array.isArray(value)) return [];
|
|
81
|
-
return value.filter((item) => typeof item === "string");
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* In-memory data cache handler. This is the built-in default — vinext installs
|
|
85
|
-
* it automatically, so consumers should not construct or register it by hand.
|
|
86
|
-
*
|
|
87
|
-
* @deprecated Consumers should not instantiate cache handlers directly.
|
|
88
|
-
* Configure caching declaratively via the `cache` option on the `vinext()`
|
|
89
|
-
* plugin (see {@link setDataCacheHandler}); the in-memory handler is the
|
|
90
|
-
* default when nothing is configured, and its size is tuned via the
|
|
91
|
-
* `cacheMaxMemorySize` plugin option.
|
|
92
|
-
*/
|
|
93
|
-
var MemoryCacheHandler = class {
|
|
94
|
-
store = /* @__PURE__ */ new Map();
|
|
95
|
-
tagRevalidatedAt = /* @__PURE__ */ new Map();
|
|
96
|
-
maxMemoryCacheSize;
|
|
97
|
-
currentMemoryCacheSize = 0;
|
|
98
|
-
constructor(options) {
|
|
99
|
-
this.maxMemoryCacheSize = resolveMemoryCacheMaxSize(options);
|
|
100
|
-
}
|
|
101
|
-
estimateEntrySize(entry) {
|
|
102
|
-
return estimateIncrementalCacheValueSize(entry.value) + entry.tags.reduce((sum, tag) => sum + tag.length, 0) + 64;
|
|
103
|
-
}
|
|
104
|
-
deleteEntry(key) {
|
|
105
|
-
const existing = this.store.get(key);
|
|
106
|
-
if (!existing) return;
|
|
107
|
-
this.currentMemoryCacheSize -= this.estimateEntrySize(existing);
|
|
108
|
-
this.store.delete(key);
|
|
109
|
-
}
|
|
110
|
-
touchEntry(key, entry) {
|
|
111
|
-
this.store.delete(key);
|
|
112
|
-
this.store.set(key, entry);
|
|
113
|
-
}
|
|
114
|
-
evictLeastRecentlyUsed() {
|
|
115
|
-
while (this.maxMemoryCacheSize > 0 && this.currentMemoryCacheSize > this.maxMemoryCacheSize) {
|
|
116
|
-
const oldestKey = this.store.keys().next().value;
|
|
117
|
-
if (oldestKey === void 0) return;
|
|
118
|
-
this.deleteEntry(oldestKey);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async get(key, _ctx) {
|
|
122
|
-
const entry = this.store.get(key);
|
|
123
|
-
if (!entry) return null;
|
|
124
|
-
for (const tag of entry.tags) {
|
|
125
|
-
const revalidatedAt = this.tagRevalidatedAt.get(tag);
|
|
126
|
-
if (revalidatedAt && revalidatedAt >= entry.lastModified) {
|
|
127
|
-
this.deleteEntry(key);
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
for (const tag of readStringArrayField(_ctx, "softTags")) {
|
|
132
|
-
const revalidatedAt = this.tagRevalidatedAt.get(tag);
|
|
133
|
-
if (revalidatedAt && revalidatedAt >= entry.lastModified) return null;
|
|
134
|
-
}
|
|
135
|
-
if (entry.expireAt !== null && Date.now() > entry.expireAt) {
|
|
136
|
-
this.deleteEntry(key);
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
this.touchEntry(key, entry);
|
|
140
|
-
if (entry.revalidateAt !== null && Date.now() > entry.revalidateAt) return {
|
|
141
|
-
lastModified: entry.lastModified,
|
|
142
|
-
value: entry.value,
|
|
143
|
-
cacheState: "stale",
|
|
144
|
-
cacheControl: entry.cacheControl
|
|
145
|
-
};
|
|
146
|
-
return {
|
|
147
|
-
lastModified: entry.lastModified,
|
|
148
|
-
value: entry.value,
|
|
149
|
-
cacheControl: entry.cacheControl
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
async set(key, data, ctx) {
|
|
153
|
-
const tagSet = /* @__PURE__ */ new Set();
|
|
154
|
-
if (data && "tags" in data && Array.isArray(data.tags)) for (const t of data.tags) tagSet.add(t);
|
|
155
|
-
for (const t of readStringArrayField(ctx, "tags")) tagSet.add(t);
|
|
156
|
-
const tags = [...tagSet];
|
|
157
|
-
let effectiveRevalidate;
|
|
158
|
-
let effectiveExpire;
|
|
159
|
-
effectiveRevalidate = readCacheControlNumberField(ctx, "revalidate");
|
|
160
|
-
effectiveExpire = readCacheControlNumberField(ctx, "expire");
|
|
161
|
-
if (data && "revalidate" in data && typeof data.revalidate === "number") effectiveRevalidate = data.revalidate;
|
|
162
|
-
if (effectiveRevalidate === 0) return;
|
|
163
|
-
const now = Date.now();
|
|
164
|
-
const revalidateAt = typeof effectiveRevalidate === "number" && effectiveRevalidate > 0 ? now + effectiveRevalidate * 1e3 : null;
|
|
165
|
-
const expireAt = typeof effectiveExpire === "number" && effectiveExpire > 0 ? now + effectiveExpire * 1e3 : null;
|
|
166
|
-
const cacheControl = typeof effectiveRevalidate === "number" ? effectiveExpire === void 0 ? { revalidate: effectiveRevalidate } : {
|
|
167
|
-
revalidate: effectiveRevalidate,
|
|
168
|
-
expire: effectiveExpire
|
|
169
|
-
} : void 0;
|
|
170
|
-
if (this.maxMemoryCacheSize === 0) return;
|
|
171
|
-
const entry = {
|
|
172
|
-
value: data,
|
|
173
|
-
tags,
|
|
174
|
-
lastModified: now,
|
|
175
|
-
revalidateAt,
|
|
176
|
-
expireAt,
|
|
177
|
-
cacheControl
|
|
178
|
-
};
|
|
179
|
-
const entrySize = this.estimateEntrySize(entry);
|
|
180
|
-
if (entrySize > this.maxMemoryCacheSize) {
|
|
181
|
-
this.deleteEntry(key);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
this.deleteEntry(key);
|
|
185
|
-
this.store.set(key, entry);
|
|
186
|
-
this.currentMemoryCacheSize += entrySize;
|
|
187
|
-
this.evictLeastRecentlyUsed();
|
|
188
|
-
}
|
|
189
|
-
async revalidateTag(tags, _durations) {
|
|
190
|
-
const tagList = Array.isArray(tags) ? tags : [tags];
|
|
191
|
-
const now = Date.now();
|
|
192
|
-
for (const tag of tagList) {
|
|
193
|
-
this.tagRevalidatedAt.set(tag, now);
|
|
194
|
-
while (this.tagRevalidatedAt.size > MAX_REVALIDATED_TAG_ENTRIES) {
|
|
195
|
-
const oldest = this.tagRevalidatedAt.keys().next().value;
|
|
196
|
-
if (oldest === void 0) break;
|
|
197
|
-
this.tagRevalidatedAt.delete(oldest);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
resetRequestCache() {}
|
|
202
|
-
};
|
|
203
|
-
const _HANDLER_KEY = Symbol.for("vinext.cacheHandler");
|
|
204
|
-
const _gHandler = globalThis;
|
|
205
|
-
function _getActiveHandler() {
|
|
206
|
-
return _gHandler[_HANDLER_KEY] ?? (_gHandler[_HANDLER_KEY] = new MemoryCacheHandler());
|
|
207
|
-
}
|
|
208
|
-
function configureMemoryCacheHandler(options) {
|
|
209
|
-
const current = _gHandler[_HANDLER_KEY];
|
|
210
|
-
if (current && !(current instanceof MemoryCacheHandler)) return;
|
|
211
|
-
_gHandler[_HANDLER_KEY] = new MemoryCacheHandler(options);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Set the **data cache** handler. This backs all data-cache concerns —
|
|
215
|
-
* `fetch` caching, `"use cache"`, `unstable_cache` — and is also the default
|
|
216
|
-
* underlying store for page-level ISR (via the default CDN cache adapter).
|
|
217
|
-
*
|
|
218
|
-
* The handler must implement the CacheHandler interface (same shape as
|
|
219
|
-
* Next.js 16's CacheHandler class).
|
|
220
|
-
*
|
|
221
|
-
* @deprecated Don't wire up the data cache imperatively. Configure it
|
|
222
|
-
* declaratively via the `cache.data` option on the `vinext()` plugin in your
|
|
223
|
-
* `vite.config.ts`, using a config-time adapter builder. On Cloudflare Workers:
|
|
224
|
-
*
|
|
225
|
-
* ```ts
|
|
226
|
-
* import { vinext } from "vinext";
|
|
227
|
-
* import { kvDataAdapter } from "@vinext/cloudflare/cache/kv-data-adapter";
|
|
228
|
-
*
|
|
229
|
-
* export default defineConfig({
|
|
230
|
-
* plugins: [vinext({ cache: { data: kvDataAdapter({ binding: "VINEXT_KV_CACHE" }) } })],
|
|
231
|
-
* });
|
|
232
|
-
* ```
|
|
233
|
-
*
|
|
234
|
-
* The plugin defers instantiation to the first request and registers the
|
|
235
|
-
* handler across every runtime/router entry, so you don't have to call this
|
|
236
|
-
* from a worker entry. This setter remains as the internal registration target
|
|
237
|
-
* and for backwards compatibility, but is not the recommended consumer API.
|
|
238
|
-
*/
|
|
239
|
-
function setDataCacheHandler(handler) {
|
|
240
|
-
_gHandler[_HANDLER_KEY] = handler;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Get the active data cache handler (for internal use or testing).
|
|
244
|
-
*/
|
|
245
|
-
function getDataCacheHandler() {
|
|
246
|
-
return _getActiveHandler();
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* @deprecated Don't wire up the data cache imperatively. Configure it
|
|
250
|
-
* declaratively via the `cache.data` option on the `vinext()` plugin (e.g.
|
|
251
|
-
* `kvDataAdapter()` from `@vinext/cloudflare/cache/kv-data-adapter`). See
|
|
252
|
-
* {@link setDataCacheHandler} for the migration example. Retained as a
|
|
253
|
-
* backwards-compatible alias — `setCacheHandler` has always configured the
|
|
254
|
-
* data cache handler.
|
|
255
|
-
*/
|
|
256
|
-
function setCacheHandler(handler) {
|
|
257
|
-
setDataCacheHandler(handler);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* @deprecated Prefer {@link getDataCacheHandler}.
|
|
261
|
-
*/
|
|
262
|
-
function getCacheHandler() {
|
|
263
|
-
return getDataCacheHandler();
|
|
264
|
-
}
|
|
33
|
+
const _g = globalThis;
|
|
265
34
|
/**
|
|
266
35
|
* Revalidate cached data associated with a specific cache tag.
|
|
267
36
|
*
|
|
@@ -281,7 +50,7 @@ async function revalidateTag(tag, profile) {
|
|
|
281
50
|
const resolved = cacheLifeProfiles[profile];
|
|
282
51
|
if (resolved) durations = { expire: resolved.expire };
|
|
283
52
|
} else if (profile && typeof profile === "object") durations = profile;
|
|
284
|
-
if (!profile || !durations || durations.expire === 0) markActionRevalidation(
|
|
53
|
+
if (!profile || !durations || durations.expire === 0) markActionRevalidation(1);
|
|
285
54
|
await _invalidateEncodedTag(encodeCacheTag(tag), durations);
|
|
286
55
|
}
|
|
287
56
|
/**
|
|
@@ -294,7 +63,7 @@ async function revalidateTag(tag, profile) {
|
|
|
294
63
|
* let the edge re-fetch and re-cache stale data.
|
|
295
64
|
*/
|
|
296
65
|
async function _invalidateEncodedTag(encoded, durations) {
|
|
297
|
-
await
|
|
66
|
+
await getDataCacheHandler().revalidateTag(encoded, durations);
|
|
298
67
|
await getCdnCacheAdapter().revalidateTag(encoded, durations);
|
|
299
68
|
}
|
|
300
69
|
/**
|
|
@@ -313,7 +82,7 @@ async function _invalidateEncodedTag(encoded, durations) {
|
|
|
313
82
|
* layout/page hierarchy tags, so only no-type invalidation applies there.
|
|
314
83
|
*/
|
|
315
84
|
async function revalidatePath(path, type) {
|
|
316
|
-
markActionRevalidation(
|
|
85
|
+
markActionRevalidation(1);
|
|
317
86
|
const stem = path.endsWith("/") ? path.slice(0, -1) : path;
|
|
318
87
|
await _invalidateEncodedTag(encodeCacheTag(type ? `_N_T_${stem}/${type}` : `_N_T_${stem || "/"}`));
|
|
319
88
|
}
|
|
@@ -326,7 +95,7 @@ async function revalidatePath(path, type) {
|
|
|
326
95
|
* response header that the client router already understands.
|
|
327
96
|
*/
|
|
328
97
|
function refresh() {
|
|
329
|
-
markActionRevalidation(
|
|
98
|
+
markActionRevalidation(2);
|
|
330
99
|
}
|
|
331
100
|
/**
|
|
332
101
|
* Expire a cache tag immediately (Next.js 16).
|
|
@@ -343,7 +112,7 @@ function refresh() {
|
|
|
343
112
|
*/
|
|
344
113
|
async function updateTag(tag) {
|
|
345
114
|
if (getHeadersAccessPhase() !== "action") throw new Error("updateTag can only be called from within a Server Action. To invalidate cache tags in Route Handlers or other contexts, use revalidateTag instead. See more info here: https://nextjs.org/docs/app/api-reference/functions/updateTag");
|
|
346
|
-
markActionRevalidation(
|
|
115
|
+
markActionRevalidation(1);
|
|
347
116
|
await _invalidateEncodedTag(encodeCacheTag(tag));
|
|
348
117
|
}
|
|
349
118
|
/**
|
|
@@ -419,138 +188,6 @@ function unstable_io() {
|
|
|
419
188
|
return io();
|
|
420
189
|
}
|
|
421
190
|
let _unstableIoWarned = false;
|
|
422
|
-
const _FALLBACK_KEY = Symbol.for("vinext.cache.fallback");
|
|
423
|
-
const _g = globalThis;
|
|
424
|
-
const _cacheAls = getOrCreateAls("vinext.cache.als");
|
|
425
|
-
const _cacheFallbackState = _g[_FALLBACK_KEY] ??= {
|
|
426
|
-
actionRevalidationKind: 0,
|
|
427
|
-
requestScopedCacheLife: null,
|
|
428
|
-
unstableCacheObservations: /* @__PURE__ */ new Map(),
|
|
429
|
-
unstableCacheRevalidation: "foreground"
|
|
430
|
-
};
|
|
431
|
-
const ACTION_DID_NOT_REVALIDATE = 0;
|
|
432
|
-
const ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC = 1;
|
|
433
|
-
const ACTION_DID_REVALIDATE_DYNAMIC_ONLY = 2;
|
|
434
|
-
function _getCacheState() {
|
|
435
|
-
if (isInsideUnifiedScope()) return getRequestContext();
|
|
436
|
-
return _cacheAls.getStore() ?? _cacheFallbackState;
|
|
437
|
-
}
|
|
438
|
-
function _runWithCacheState(fn) {
|
|
439
|
-
if (isInsideUnifiedScope()) return runWithUnifiedStateMutation((uCtx) => {
|
|
440
|
-
uCtx.actionRevalidationKind = ACTION_DID_NOT_REVALIDATE;
|
|
441
|
-
uCtx.requestScopedCacheLife = null;
|
|
442
|
-
uCtx.unstableCacheObservations = /* @__PURE__ */ new Map();
|
|
443
|
-
uCtx.unstableCacheRevalidation = "foreground";
|
|
444
|
-
}, fn);
|
|
445
|
-
const state = {
|
|
446
|
-
actionRevalidationKind: ACTION_DID_NOT_REVALIDATE,
|
|
447
|
-
requestScopedCacheLife: null,
|
|
448
|
-
unstableCacheObservations: /* @__PURE__ */ new Map(),
|
|
449
|
-
unstableCacheRevalidation: "foreground"
|
|
450
|
-
};
|
|
451
|
-
return _cacheAls.run(state, fn);
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Initialize cache ALS for a new request. Call at request entry.
|
|
455
|
-
* Only needed when not using _runWithCacheState() (legacy path).
|
|
456
|
-
* @internal
|
|
457
|
-
*/
|
|
458
|
-
function _initRequestScopedCacheState() {
|
|
459
|
-
const state = _getCacheState();
|
|
460
|
-
state.actionRevalidationKind = ACTION_DID_NOT_REVALIDATE;
|
|
461
|
-
state.requestScopedCacheLife = null;
|
|
462
|
-
state.unstableCacheObservations = /* @__PURE__ */ new Map();
|
|
463
|
-
}
|
|
464
|
-
function markActionRevalidation(kind) {
|
|
465
|
-
if (getHeadersAccessPhase() !== "action") return;
|
|
466
|
-
const state = _getCacheState();
|
|
467
|
-
state.actionRevalidationKind = state.actionRevalidationKind === ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC ? ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC : kind;
|
|
468
|
-
}
|
|
469
|
-
function getAndClearActionRevalidationKind() {
|
|
470
|
-
const state = _getCacheState();
|
|
471
|
-
const kind = state.actionRevalidationKind;
|
|
472
|
-
state.actionRevalidationKind = ACTION_DID_NOT_REVALIDATE;
|
|
473
|
-
return kind;
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Set a request-scoped cache life config. Called by cacheLife() so the route
|
|
477
|
-
* render can inherit cache policy from file-level and nested "use cache" work.
|
|
478
|
-
* @internal
|
|
479
|
-
*/
|
|
480
|
-
function _setRequestScopedCacheLife(config) {
|
|
481
|
-
const state = _getCacheState();
|
|
482
|
-
if (state.requestScopedCacheLife === null) state.requestScopedCacheLife = { ...config };
|
|
483
|
-
else {
|
|
484
|
-
if (config.stale !== void 0) state.requestScopedCacheLife.stale = state.requestScopedCacheLife.stale !== void 0 ? Math.min(state.requestScopedCacheLife.stale, config.stale) : config.stale;
|
|
485
|
-
if (config.revalidate !== void 0) state.requestScopedCacheLife.revalidate = state.requestScopedCacheLife.revalidate !== void 0 ? Math.min(state.requestScopedCacheLife.revalidate, config.revalidate) : config.revalidate;
|
|
486
|
-
if (config.expire !== void 0) state.requestScopedCacheLife.expire = state.requestScopedCacheLife.expire !== void 0 ? Math.min(state.requestScopedCacheLife.expire, config.expire) : config.expire;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Read the request-scoped cache life without clearing it. Prerender response
|
|
491
|
-
* shaping needs the metadata before the manifest writer consumes it after the
|
|
492
|
-
* body has been fully rendered.
|
|
493
|
-
* @internal
|
|
494
|
-
*/
|
|
495
|
-
function _peekRequestScopedCacheLife() {
|
|
496
|
-
const config = _getCacheState().requestScopedCacheLife;
|
|
497
|
-
return config === null ? null : { ...config };
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Consume and reset the request-scoped cache life. Returns null if none was set.
|
|
501
|
-
* @internal
|
|
502
|
-
*/
|
|
503
|
-
function _consumeRequestScopedCacheLife() {
|
|
504
|
-
const state = _getCacheState();
|
|
505
|
-
const config = state.requestScopedCacheLife;
|
|
506
|
-
state.requestScopedCacheLife = null;
|
|
507
|
-
return config;
|
|
508
|
-
}
|
|
509
|
-
function recordUnstableCacheObservation(observation) {
|
|
510
|
-
_getCacheState().unstableCacheObservations.set(observation.keyHash, observation);
|
|
511
|
-
}
|
|
512
|
-
function _peekUnstableCacheObservations() {
|
|
513
|
-
return [..._getCacheState().unstableCacheObservations.values()].sort((a, b) => a.keyHash.localeCompare(b.keyHash));
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Built-in cache life profiles matching Next.js 16.
|
|
517
|
-
*/
|
|
518
|
-
const cacheLifeProfiles = {
|
|
519
|
-
default: {
|
|
520
|
-
revalidate: 900,
|
|
521
|
-
expire: 4294967294
|
|
522
|
-
},
|
|
523
|
-
seconds: {
|
|
524
|
-
stale: 30,
|
|
525
|
-
revalidate: 1,
|
|
526
|
-
expire: 60
|
|
527
|
-
},
|
|
528
|
-
minutes: {
|
|
529
|
-
stale: 300,
|
|
530
|
-
revalidate: 60,
|
|
531
|
-
expire: 3600
|
|
532
|
-
},
|
|
533
|
-
hours: {
|
|
534
|
-
stale: 300,
|
|
535
|
-
revalidate: 3600,
|
|
536
|
-
expire: 86400
|
|
537
|
-
},
|
|
538
|
-
days: {
|
|
539
|
-
stale: 300,
|
|
540
|
-
revalidate: 86400,
|
|
541
|
-
expire: 604800
|
|
542
|
-
},
|
|
543
|
-
weeks: {
|
|
544
|
-
stale: 300,
|
|
545
|
-
revalidate: 604800,
|
|
546
|
-
expire: 2592e3
|
|
547
|
-
},
|
|
548
|
-
max: {
|
|
549
|
-
stale: 300,
|
|
550
|
-
revalidate: 2592e3,
|
|
551
|
-
expire: 31536e3
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
191
|
/**
|
|
555
192
|
* Set the cache lifetime for a "use cache" function.
|
|
556
193
|
*
|
|
@@ -579,7 +216,7 @@ function cacheLife(profile) {
|
|
|
579
216
|
};
|
|
580
217
|
} else return;
|
|
581
218
|
try {
|
|
582
|
-
const ctx =
|
|
219
|
+
const ctx = getRegisteredCacheContext();
|
|
583
220
|
if (ctx) {
|
|
584
221
|
ctx.lifeConfigs.push(resolvedConfig);
|
|
585
222
|
if (resolvedConfig.revalidate !== void 0) ctx.hasExplicitRevalidate = true;
|
|
@@ -603,7 +240,7 @@ function cacheLife(profile) {
|
|
|
603
240
|
*/
|
|
604
241
|
function cacheTag(...tags) {
|
|
605
242
|
try {
|
|
606
|
-
const ctx =
|
|
243
|
+
const ctx = getRegisteredCacheContext();
|
|
607
244
|
if (ctx) ctx.tags.push(...encodeCacheTags(tags));
|
|
608
245
|
} catch {}
|
|
609
246
|
}
|
|
@@ -690,9 +327,6 @@ function getPendingUnstableCacheRevalidations() {
|
|
|
690
327
|
_g[_UNSTABLE_CACHE_PENDING_REVALIDATIONS_KEY] = pending;
|
|
691
328
|
return pending;
|
|
692
329
|
}
|
|
693
|
-
function shouldServeStaleUnstableCacheEntry() {
|
|
694
|
-
return _getCacheState().unstableCacheRevalidation === "background";
|
|
695
|
-
}
|
|
696
330
|
function waitUntilUnstableCacheRevalidation(promise) {
|
|
697
331
|
if (!isInsideUnifiedScope()) return;
|
|
698
332
|
getRequestContext().executionContext?.waitUntil(promise);
|
|
@@ -720,7 +354,7 @@ async function refreshUnstableCacheResult(fn, args, cacheKey, tags, revalidateSe
|
|
|
720
354
|
tags,
|
|
721
355
|
revalidate: typeof revalidateSeconds === "number" ? revalidateSeconds : false
|
|
722
356
|
};
|
|
723
|
-
await
|
|
357
|
+
await getDataCacheHandler().set(cacheKey, cacheValue, {
|
|
724
358
|
fetchCache: true,
|
|
725
359
|
tags,
|
|
726
360
|
revalidate: revalidateSeconds
|
|
@@ -746,7 +380,7 @@ function unstable_cache(fn, keyParts, options) {
|
|
|
746
380
|
tagCount: tags.length,
|
|
747
381
|
tagHash: tags.length > 0 ? fnv1a64(JSON.stringify(tags)) : null
|
|
748
382
|
});
|
|
749
|
-
const existing = await
|
|
383
|
+
const existing = await getDataCacheHandler().get(cacheKey, {
|
|
750
384
|
kind: "FETCH",
|
|
751
385
|
tags
|
|
752
386
|
});
|
|
@@ -764,4 +398,4 @@ function unstable_cache(fn, keyParts, options) {
|
|
|
764
398
|
return cachedFn;
|
|
765
399
|
}
|
|
766
400
|
//#endregion
|
|
767
|
-
export { MemoryCacheHandler, NoOpCacheHandler, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLife, cacheLifeProfiles, cacheTag, configureMemoryCacheHandler, getAndClearActionRevalidationKind, getCacheHandler, getDataCacheHandler, getRequestExecutionContext, io, isInsideUnstableCacheScope, unstable_noStore as noStore, unstable_noStore, refresh, revalidatePath, revalidateTag, runWithExecutionContext, setCacheHandler, setDataCacheHandler, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_io, updateTag };
|
|
401
|
+
export { ACTION_DID_REVALIDATE_DYNAMIC_ONLY, ACTION_DID_REVALIDATE_STATIC_AND_DYNAMIC, MemoryCacheHandler, NoOpCacheHandler, _consumeRequestScopedCacheLife, _initRequestScopedCacheState, _peekRequestScopedCacheLife, _peekUnstableCacheObservations, _registerCacheContextAccessor, _runWithCacheState, _setRequestScopedCacheLife, cacheLife, cacheLifeProfiles, cacheTag, configureMemoryCacheHandler, getAndClearActionRevalidationKind, getCacheHandler, getDataCacheHandler, getRegisteredCacheContext, getRequestExecutionContext, io, isInsideUnstableCacheScope, markActionRevalidation, unstable_noStore as noStore, unstable_noStore, recordUnstableCacheObservation, refresh, revalidatePath, revalidateTag, runWithExecutionContext, setCacheHandler, setDataCacheHandler, shouldServeStaleUnstableCacheEntry, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_io, updateTag };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CacheHandlerValue, IncrementalCacheValue } from "./cache.js";
|
|
1
|
+
import { CacheHandlerValue, IncrementalCacheValue } from "./cache-handler.js";
|
|
2
2
|
|
|
3
3
|
//#region src/shims/cdn-cache.d.ts
|
|
4
4
|
/** A map of response header name -> value the adapter wants applied or removed. */
|
package/dist/shims/cdn-cache.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getRequestExecutionContext } from "./request-context.js";
|
|
2
|
-
import { getDataCacheHandler } from "./cache.js";
|
|
2
|
+
import { getDataCacheHandler } from "./cache-handler.js";
|
|
3
3
|
import { CloudflareCdnCacheAdapter } from "../cloudflare/src/cache/cdn-adapter.runtime.js";
|
|
4
4
|
//#region src/shims/cdn-cache.ts
|
|
5
5
|
/**
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AppRouterInstance } from "./internal/app-router-context.js";
|
|
2
|
+
|
|
3
|
+
//#region src/shims/error-boundary-navigation.d.ts
|
|
4
|
+
declare function useErrorBoundaryPathname(): string;
|
|
5
|
+
declare function useErrorBoundaryRouter(): AppRouterInstance;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { useErrorBoundaryPathname, useErrorBoundaryRouter };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { stripBasePath } from "../utils/base-path.js";
|
|
2
|
+
import { markPprFallbackShellDynamicBoundary } from "./ppr-fallback-shell.js";
|
|
3
|
+
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
4
|
+
import { getNavigationContext } from "./navigation-context-state.js";
|
|
5
|
+
import "./navigation-server.js";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
//#region src/shims/error-boundary-navigation.ts
|
|
8
|
+
const CLIENT_NAVIGATION_STATE_KEY = Symbol.for("vinext.clientNavigationState");
|
|
9
|
+
const CLIENT_NAVIGATION_RENDER_CONTEXT_KEY = Symbol.for("vinext.clientNavigationRenderContext");
|
|
10
|
+
const BASE_PATH = process.env.__NEXT_ROUTER_BASEPATH ?? "";
|
|
11
|
+
function getClientNavigationState() {
|
|
12
|
+
return globalThis[CLIENT_NAVIGATION_STATE_KEY];
|
|
13
|
+
}
|
|
14
|
+
function getClientPathnameSnapshot() {
|
|
15
|
+
return getClientNavigationState()?.cachedPathname ?? stripBasePath(window.location.pathname, BASE_PATH);
|
|
16
|
+
}
|
|
17
|
+
function getServerPathnameSnapshot() {
|
|
18
|
+
return getNavigationContext()?.pathname ?? "/";
|
|
19
|
+
}
|
|
20
|
+
function subscribeToCommittedPathname(listener) {
|
|
21
|
+
const state = getClientNavigationState();
|
|
22
|
+
if (!state) return () => {};
|
|
23
|
+
state.listeners.add(listener);
|
|
24
|
+
return () => state.listeners.delete(listener);
|
|
25
|
+
}
|
|
26
|
+
function getClientNavigationRenderContext() {
|
|
27
|
+
const globalState = globalThis;
|
|
28
|
+
return globalState[CLIENT_NAVIGATION_RENDER_CONTEXT_KEY] ??= React$1.createContext(null);
|
|
29
|
+
}
|
|
30
|
+
function useErrorBoundaryPathname() {
|
|
31
|
+
if (typeof window === "undefined") markPprFallbackShellDynamicBoundary();
|
|
32
|
+
const renderSnapshot = React$1.useContext(getClientNavigationRenderContext());
|
|
33
|
+
const committedPathname = React$1.useSyncExternalStore(subscribeToCommittedPathname, getClientPathnameSnapshot, getServerPathnameSnapshot);
|
|
34
|
+
if (renderSnapshot && (getClientNavigationState()?.navigationSnapshotActiveCount ?? 0) > 0) return renderSnapshot.pathname;
|
|
35
|
+
return committedPathname;
|
|
36
|
+
}
|
|
37
|
+
function useErrorBoundaryRouter() {
|
|
38
|
+
if (!AppRouterContext || typeof React$1.useContext !== "function") throw new Error("invariant expected app router to be mounted");
|
|
39
|
+
const router = React$1.useContext(AppRouterContext);
|
|
40
|
+
if (router === null) throw new Error("invariant expected app router to be mounted");
|
|
41
|
+
return router;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { useErrorBoundaryPathname, useErrorBoundaryRouter };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { decodeRedirectError, isRedirectError } from "./navigation-errors.js";
|
|
3
|
+
import "./navigation-server.js";
|
|
4
|
+
import { useErrorBoundaryPathname, useErrorBoundaryRouter } from "./error-boundary-navigation.js";
|
|
4
5
|
import DefaultGlobalError from "./default-global-error.js";
|
|
6
|
+
import { handleAppNavigationFailure } from "../client/app-nav-failure-handler.js";
|
|
5
7
|
import { VINEXT_DEV_ERROR_RECOVERY_EVENT } from "../utils/dev-error-recovery-event.js";
|
|
6
8
|
import { isNavigationSignalError } from "../utils/navigation-signal.js";
|
|
7
9
|
import React from "react";
|
|
@@ -31,7 +33,7 @@ function removeDevErrorRecoveryListener(listener) {
|
|
|
31
33
|
window.removeEventListener(VINEXT_DEV_ERROR_RECOVERY_EVENT, listener);
|
|
32
34
|
}
|
|
33
35
|
function HandleRedirect({ redirect, redirectType, reset }) {
|
|
34
|
-
const router =
|
|
36
|
+
const router = useErrorBoundaryRouter();
|
|
35
37
|
React.useEffect(() => {
|
|
36
38
|
React.startTransition(() => {
|
|
37
39
|
if (redirectType === "push") router.push(redirect);
|
|
@@ -146,7 +148,7 @@ var ErrorBoundaryInner = class extends React.Component {
|
|
|
146
148
|
};
|
|
147
149
|
function ErrorBoundary({ fallback, children, resetKey }) {
|
|
148
150
|
return /* @__PURE__ */ jsx(ErrorBoundaryInner, {
|
|
149
|
-
pathname:
|
|
151
|
+
pathname: useErrorBoundaryPathname(),
|
|
150
152
|
resetKey,
|
|
151
153
|
fallback,
|
|
152
154
|
children
|
|
@@ -154,7 +156,7 @@ function ErrorBoundary({ fallback, children, resetKey }) {
|
|
|
154
156
|
}
|
|
155
157
|
function GlobalErrorBoundary({ fallback, children }) {
|
|
156
158
|
return /* @__PURE__ */ jsx(ErrorBoundaryInner, {
|
|
157
|
-
pathname:
|
|
159
|
+
pathname: useErrorBoundaryPathname(),
|
|
158
160
|
fallback,
|
|
159
161
|
isImplicitRootErrorBoundary: fallback === DefaultGlobalError,
|
|
160
162
|
children
|
|
@@ -208,7 +210,7 @@ var NotFoundBoundaryInner = class extends React.Component {
|
|
|
208
210
|
*/
|
|
209
211
|
function NotFoundBoundary({ fallback, children, resetKey }) {
|
|
210
212
|
return /* @__PURE__ */ jsx(NotFoundBoundaryInner, {
|
|
211
|
-
pathname:
|
|
213
|
+
pathname: useErrorBoundaryPathname(),
|
|
212
214
|
resetKey,
|
|
213
215
|
fallback,
|
|
214
216
|
children
|
|
@@ -249,7 +251,7 @@ var ForbiddenBoundaryInner = class extends React.Component {
|
|
|
249
251
|
};
|
|
250
252
|
function ForbiddenBoundary({ fallback, children, resetKey }) {
|
|
251
253
|
return /* @__PURE__ */ jsx(ForbiddenBoundaryInner, {
|
|
252
|
-
pathname:
|
|
254
|
+
pathname: useErrorBoundaryPathname(),
|
|
253
255
|
resetKey,
|
|
254
256
|
fallback,
|
|
255
257
|
children
|
|
@@ -290,7 +292,7 @@ var UnauthorizedBoundaryInner = class extends React.Component {
|
|
|
290
292
|
};
|
|
291
293
|
function UnauthorizedBoundary({ fallback, children, resetKey }) {
|
|
292
294
|
return /* @__PURE__ */ jsx(UnauthorizedBoundaryInner, {
|
|
293
|
-
pathname:
|
|
295
|
+
pathname: useErrorBoundaryPathname(),
|
|
294
296
|
resetKey,
|
|
295
297
|
fallback,
|
|
296
298
|
children
|
package/dist/shims/error.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AppRouterContext } from "./internal/app-router-context.js";
|
|
2
2
|
import { RouterContext } from "./internal/router-context.js";
|
|
3
|
-
import { isNextRouterError } from "./navigation.js";
|
|
3
|
+
import { isNextRouterError } from "./navigation-errors.js";
|
|
4
|
+
import "./navigation.js";
|
|
4
5
|
import { useUntrackedPathname } from "./internal/navigation-untracked.js";
|
|
5
6
|
import React from "react";
|
|
6
7
|
//#region src/shims/error.tsx
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getOrCreateAls } from "./internal/als-registry.js";
|
|
2
2
|
import { getRequestContext, isInsideUnifiedScope, runWithUnifiedStateMutation } from "./unified-request-context.js";
|
|
3
3
|
import { getRequestExecutionContext } from "./request-context.js";
|
|
4
|
+
import { getDataCacheHandler } from "./cache-handler.js";
|
|
4
5
|
import { markDynamicUsage } from "./headers.js";
|
|
5
6
|
import { encodeCacheTags } from "../utils/encode-cache-tag.js";
|
|
6
|
-
import { getDataCacheHandler } from "./cache.js";
|
|
7
7
|
//#region src/shims/fetch-cache.ts
|
|
8
8
|
/**
|
|
9
9
|
* Extended fetch() with Next.js caching semantics.
|
package/dist/shims/form.js
CHANGED
|
@@ -4,8 +4,8 @@ import { isDangerousScheme } from "./url-safety.js";
|
|
|
4
4
|
import { AppElementsWire } from "../server/app-elements-wire.js";
|
|
5
5
|
import "../server/app-elements.js";
|
|
6
6
|
import { toSameOriginPath, withBasePath } from "./url-utils.js";
|
|
7
|
-
import { hasAppNavigationRuntime } from "../client/navigation-runtime.js";
|
|
8
7
|
import { createRscRequestHeaders, createRscRequestUrl } from "../server/app-rsc-cache-busting.js";
|
|
8
|
+
import { hasAppNavigationRuntime } from "../client/navigation-runtime.js";
|
|
9
9
|
import { getMountedSlotsHeader, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, navigateClientSide, prefetchRscResponse } from "./navigation.js";
|
|
10
10
|
import { useMergedRef } from "./use-merged-ref.js";
|
|
11
11
|
import { forwardRef, useActionState, useCallback, useEffect, useRef } from "react";
|