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
|
@@ -2,57 +2,12 @@ import { AppRouterScrollIntent } from "./app-router-scroll-state.js";
|
|
|
2
2
|
import { NavigationRuntimeVisibleCommitMode } from "../client/navigation-runtime.js";
|
|
3
3
|
import { AppRouterInstance, NavigateOptions, PrefetchOptions as PrefetchOptions$1 } from "./internal/app-router-context.js";
|
|
4
4
|
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
5
|
+
import { GLOBAL_ACCESSORS_KEY, NavigationContext, NavigationStateAccessors, SegmentMap, ServerInsertedHTMLContext, _registerStateAccessors, clearServerInsertedHTML, flushServerInsertedHTML, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getLayoutSegmentContext, getNavigationContext, renderServerInsertedHTML, setNavigationContext } from "./navigation-context-state.js";
|
|
6
|
+
import { BailoutToCSRError, DynamicServerError, HTTP_ERROR_FALLBACK_ERROR_CODE, RedirectType, decodeRedirectError, forbidden, getAccessFallbackHTTPStatus, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, notFound, permanentRedirect, redirect, unauthorized, unstable_rethrow } from "./navigation-errors.js";
|
|
5
7
|
import { UnrecognizedActionError, unstable_isUnrecognizedActionError } from "./unrecognized-action-error.js";
|
|
6
8
|
import * as React$1 from "react";
|
|
7
9
|
|
|
8
10
|
//#region src/shims/navigation.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* Map of parallel route key → child segments below the current layout.
|
|
11
|
-
* The "children" key is always present (the default parallel route).
|
|
12
|
-
* Named parallel routes add their own keys (e.g., "team", "analytics").
|
|
13
|
-
*
|
|
14
|
-
* Arrays are mutable (`string[]`) to match Next.js's public API return type
|
|
15
|
-
* without requiring `as` casts. The map itself is Readonly — no key addition.
|
|
16
|
-
*/
|
|
17
|
-
type SegmentMap = Readonly<Record<string, string[]>> & {
|
|
18
|
-
readonly children: string[];
|
|
19
|
-
};
|
|
20
|
-
declare const ServerInsertedHTMLContext: React$1.Context<((callback: () => unknown) => void) | null> | null;
|
|
21
|
-
/**
|
|
22
|
-
* Get or create the layout segment context.
|
|
23
|
-
* Returns null in the RSC environment (createContext unavailable).
|
|
24
|
-
*/
|
|
25
|
-
declare function getLayoutSegmentContext(): React$1.Context<SegmentMap> | null;
|
|
26
|
-
declare function getBfcacheIdMapContext(): React$1.Context<Readonly<Record<string, string>> | null> | null;
|
|
27
|
-
declare function getBfcacheSegmentIdContext(): React$1.Context<string | null> | null;
|
|
28
|
-
type NavigationContext = {
|
|
29
|
-
pathname: string;
|
|
30
|
-
searchParams: URLSearchParams;
|
|
31
|
-
params: Record<string, string | string[]>;
|
|
32
|
-
};
|
|
33
|
-
type _StateAccessors = {
|
|
34
|
-
getServerContext: () => NavigationContext | null;
|
|
35
|
-
setServerContext: (ctx: NavigationContext | null) => void;
|
|
36
|
-
getInsertedHTMLCallbacks: () => Array<() => unknown>;
|
|
37
|
-
clearInsertedHTMLCallbacks: () => void;
|
|
38
|
-
};
|
|
39
|
-
declare const GLOBAL_ACCESSORS_KEY: unique symbol;
|
|
40
|
-
/**
|
|
41
|
-
* Register ALS-backed state accessors. Called by navigation-state.ts on import.
|
|
42
|
-
* @internal
|
|
43
|
-
*/
|
|
44
|
-
declare function _registerStateAccessors(accessors: _StateAccessors): void;
|
|
45
|
-
/**
|
|
46
|
-
* Get the navigation context for the current SSR/RSC render.
|
|
47
|
-
* Reads from AsyncLocalStorage when available (concurrent-safe),
|
|
48
|
-
* otherwise falls back to module-level state.
|
|
49
|
-
*/
|
|
50
|
-
declare function getNavigationContext(): NavigationContext | null;
|
|
51
|
-
/**
|
|
52
|
-
* Set the navigation context for the current SSR/RSC render.
|
|
53
|
-
* Called by the framework entry before rendering each request.
|
|
54
|
-
*/
|
|
55
|
-
declare function setNavigationContext(ctx: NavigationContext | null): void;
|
|
56
11
|
/** basePath from next.config.js, injected by the plugin at build time */
|
|
57
12
|
declare const __basePath: string;
|
|
58
13
|
/** Maximum number of entries in the RSC prefetch cache. */
|
|
@@ -327,248 +282,5 @@ declare function useSelectedLayoutSegments(parallelRoutesKey?: string): string[]
|
|
|
327
282
|
* });
|
|
328
283
|
*/
|
|
329
284
|
declare function useServerInsertedHTML(callback: () => unknown): void;
|
|
330
|
-
/**
|
|
331
|
-
* Flush all collected useServerInsertedHTML callbacks.
|
|
332
|
-
* Returns an array of results (React elements or strings).
|
|
333
|
-
* Clears the callback list so the next render starts fresh.
|
|
334
|
-
*
|
|
335
|
-
* Called by the SSR entry after renderToReadableStream completes.
|
|
336
|
-
*/
|
|
337
|
-
declare function flushServerInsertedHTML(): unknown[];
|
|
338
|
-
/**
|
|
339
|
-
* Render collected useServerInsertedHTML callbacks without unregistering them.
|
|
340
|
-
*
|
|
341
|
-
* Streaming SSR needs to invoke the same style-registry callbacks after each
|
|
342
|
-
* Fizz flush. Libraries such as styled-components and Emotion clear their own
|
|
343
|
-
* per-flush buffers inside the callback; the registration itself must survive
|
|
344
|
-
* until the request stream is closed.
|
|
345
|
-
*/
|
|
346
|
-
declare function renderServerInsertedHTML(): unknown[];
|
|
347
|
-
/**
|
|
348
|
-
* Clear all collected useServerInsertedHTML callbacks without flushing.
|
|
349
|
-
* Used for cleanup between requests.
|
|
350
|
-
*/
|
|
351
|
-
declare function clearServerInsertedHTML(): void;
|
|
352
|
-
/**
|
|
353
|
-
* HTTP Access Fallback error code — shared prefix for notFound/forbidden/unauthorized.
|
|
354
|
-
* Matches Next.js 16's unified error handling approach.
|
|
355
|
-
*/
|
|
356
|
-
declare const HTTP_ERROR_FALLBACK_ERROR_CODE = "NEXT_HTTP_ERROR_FALLBACK";
|
|
357
|
-
/**
|
|
358
|
-
* Check if an error is an HTTP Access Fallback error (notFound, forbidden, unauthorized).
|
|
359
|
-
*/
|
|
360
|
-
declare function isHTTPAccessFallbackError(error: unknown): boolean;
|
|
361
|
-
/**
|
|
362
|
-
* Extract the HTTP status code from an HTTP Access Fallback error.
|
|
363
|
-
* Returns 404 for legacy NEXT_NOT_FOUND errors.
|
|
364
|
-
*/
|
|
365
|
-
declare function getAccessFallbackHTTPStatus(error: unknown): number;
|
|
366
|
-
/**
|
|
367
|
-
* Enum matching Next.js RedirectType for type-safe redirect calls.
|
|
368
|
-
*/
|
|
369
|
-
declare enum RedirectType {
|
|
370
|
-
push = "push",
|
|
371
|
-
replace = "replace"
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Throw a redirect. Caught by the framework to send a redirect response.
|
|
375
|
-
*
|
|
376
|
-
* When `type` is omitted, the digest carries an empty sentinel so the
|
|
377
|
-
* catch site can resolve the default based on context:
|
|
378
|
-
* - Server Action context → "push" (Back button works after form submission)
|
|
379
|
-
* - SSR render context → "replace"
|
|
380
|
-
*
|
|
381
|
-
* This matches Next.js behavior where `redirect()` checks
|
|
382
|
-
* `actionAsyncStorage.getStore()?.isAction` at call time.
|
|
383
|
-
*
|
|
384
|
-
* @see https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/redirect.ts
|
|
385
|
-
*/
|
|
386
|
-
declare function redirect(url: string, type?: "replace" | "push" | RedirectType): never;
|
|
387
|
-
/**
|
|
388
|
-
* Trigger a permanent redirect (308).
|
|
389
|
-
*
|
|
390
|
-
* Accepts an optional `type` parameter matching Next.js's signature.
|
|
391
|
-
* Defaults to "replace" (not context-dependent like `redirect()`).
|
|
392
|
-
*
|
|
393
|
-
* @see https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/redirect.ts
|
|
394
|
-
*/
|
|
395
|
-
declare function permanentRedirect(url: string, type?: "replace" | "push" | RedirectType): never;
|
|
396
|
-
/**
|
|
397
|
-
* Trigger a not-found response (404). Caught by the framework.
|
|
398
|
-
*/
|
|
399
|
-
declare function notFound(): never;
|
|
400
|
-
/**
|
|
401
|
-
* Trigger a forbidden response (403). Caught by the framework.
|
|
402
|
-
* In Next.js, this is gated behind experimental.authInterrupts — we
|
|
403
|
-
* support it unconditionally for maximum compatibility.
|
|
404
|
-
*/
|
|
405
|
-
declare function forbidden(): never;
|
|
406
|
-
/**
|
|
407
|
-
* Trigger an unauthorized response (401). Caught by the framework.
|
|
408
|
-
* In Next.js, this is gated behind experimental.authInterrupts — we
|
|
409
|
-
* support it unconditionally for maximum compatibility.
|
|
410
|
-
*/
|
|
411
|
-
declare function unauthorized(): never;
|
|
412
|
-
type _RedirectErrorShape = Error & {
|
|
413
|
-
digest: string;
|
|
414
|
-
};
|
|
415
|
-
/**
|
|
416
|
-
* Check whether an error was produced by `redirect()` or `permanentRedirect()`.
|
|
417
|
-
*
|
|
418
|
-
* **Note on vinext public surface:** Next.js does NOT expose `isRedirectError`
|
|
419
|
-
* from `next/navigation` — it's an internal predicate. vinext exposes it for
|
|
420
|
-
* symmetry with the already-public `isHTTPAccessFallbackError` and because
|
|
421
|
-
* `unstable_rethrow` consumers benefit from being able to narrow types.
|
|
422
|
-
* Treat it as a vinext-only extension.
|
|
423
|
-
*
|
|
424
|
-
* **Divergence from Next.js:** Next.js's internal `isRedirectError` performs
|
|
425
|
-
* full 4-segment validation — it splits the digest on `;`, checks `type` ∈
|
|
426
|
-
* {push, replace}, requires a non-empty destination, and validates the
|
|
427
|
-
* status code (303, 307, 308). See:
|
|
428
|
-
* https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/redirect-error.ts
|
|
429
|
-
*
|
|
430
|
-
* vinext instead uses a simple prefix check (`startsWith("NEXT_REDIRECT;")`).
|
|
431
|
-
* Reasons:
|
|
432
|
-
* 1. vinext emits two digest shapes — 3-part for `redirect()`
|
|
433
|
-
* (`NEXT_REDIRECT;{type};{encoded-url}`) and 4-part for
|
|
434
|
-
* `permanentRedirect()` (`NEXT_REDIRECT;{type};{encoded-url};308`).
|
|
435
|
-
* Strict validation would have to special-case both, and Next.js's
|
|
436
|
-
* validator (tuned to its 5-part canary digests) rejects them.
|
|
437
|
-
* 2. The `type` field is sometimes empty in vinext's redirect digests
|
|
438
|
-
* (context-dependent resolution; see `redirect()` above), which the
|
|
439
|
-
* strict check disallows.
|
|
440
|
-
*
|
|
441
|
-
* **Consequence:** A malformed digest such as `"NEXT_REDIRECT;garbage"`
|
|
442
|
-
* returns `true` here, whereas Next.js would return `false`. In practice,
|
|
443
|
-
* the only callers of this predicate are vinext-internal code paths
|
|
444
|
-
* (`unstable_rethrow`, `unstable_catchError`, the redirect error boundary)
|
|
445
|
-
* that see digests vinext itself emits — so the divergence does not surface
|
|
446
|
-
* in normal use. Maintainers extending the prefix logic should keep this
|
|
447
|
-
* predicate in lockstep with the corresponding `decode*` helpers in
|
|
448
|
-
* `shims/error-boundary.tsx`.
|
|
449
|
-
*/
|
|
450
|
-
declare function isRedirectError(error: unknown): error is _RedirectErrorShape;
|
|
451
|
-
/**
|
|
452
|
-
* Parse a redirect error digest into its URL and type components.
|
|
453
|
-
*
|
|
454
|
-
* Supports two formats:
|
|
455
|
-
* - vinext's 3-part: `NEXT_REDIRECT;{type};{encoded-url}`
|
|
456
|
-
* - Next.js's 5-part: `NEXT_REDIRECT;{type};{url};{status};{isClient}`
|
|
457
|
-
*
|
|
458
|
-
* The URL segment is always percent-encoded on the write side
|
|
459
|
-
* (encodeURIComponent is used), so re-joining with ";" for the 5-part
|
|
460
|
-
* format is defensive — it correctly handles any unencoded ";" that
|
|
461
|
-
* might appear in an externally-sourced digest.
|
|
462
|
-
*
|
|
463
|
-
* Returns null for malformed digests that have an empty URL segment, or
|
|
464
|
-
* when the URL contains invalid percent-encoding.
|
|
465
|
-
*/
|
|
466
|
-
declare function decodeRedirectError(digest: string): {
|
|
467
|
-
url: string;
|
|
468
|
-
type: "push" | "replace";
|
|
469
|
-
} | null;
|
|
470
|
-
/**
|
|
471
|
-
* Returns true if the error is a Next.js navigation signal — either a redirect
|
|
472
|
-
* or an HTTP access fallback (notFound / forbidden / unauthorized).
|
|
473
|
-
*
|
|
474
|
-
* **Note on vinext public surface:** Like `isRedirectError`, Next.js does NOT
|
|
475
|
-
* expose this from `next/navigation`. vinext exposes it for symmetry — treat
|
|
476
|
-
* it as a vinext-only extension.
|
|
477
|
-
*
|
|
478
|
-
* Ported from Next.js:
|
|
479
|
-
* https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/is-next-router-error.ts
|
|
480
|
-
*/
|
|
481
|
-
declare function isNextRouterError(error: unknown): boolean;
|
|
482
|
-
declare const _BAILOUT_TO_CSR_DIGEST = "BAILOUT_TO_CLIENT_SIDE_RENDERING";
|
|
483
|
-
/**
|
|
484
|
-
* Error thrown to bail out of server rendering and fall back to client-side
|
|
485
|
-
* rendering. Used by `next/dynamic` with `ssr: false`.
|
|
486
|
-
*
|
|
487
|
-
* vinext does not yet emit this error itself — it's exposed so user code and
|
|
488
|
-
* third-party libraries that mimic `next/dynamic`'s bailout semantics can
|
|
489
|
-
* construct an error with the canonical digest that `unstable_rethrow`
|
|
490
|
-
* recognises.
|
|
491
|
-
*
|
|
492
|
-
* Ported 1:1 from Next.js:
|
|
493
|
-
* https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/lazy-dynamic/bailout-to-csr.ts
|
|
494
|
-
*/
|
|
495
|
-
declare class BailoutToCSRError extends Error {
|
|
496
|
-
readonly digest: typeof _BAILOUT_TO_CSR_DIGEST;
|
|
497
|
-
readonly reason: string;
|
|
498
|
-
constructor(reason: string);
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Returns true if the error is a `BailoutToCSRError`. Matches Next.js's
|
|
502
|
-
* digest-based predicate, so any error from a foreign module instance of
|
|
503
|
-
* the class (or constructed manually with the canonical digest) is also
|
|
504
|
-
* detected.
|
|
505
|
-
*
|
|
506
|
-
* **Note on vinext public surface:** Next.js does NOT expose this from
|
|
507
|
-
* `next/navigation`. vinext exposes it for symmetry with `isRedirectError`
|
|
508
|
-
* — treat it as a vinext-only extension. The matching producer
|
|
509
|
-
* (`BailoutToCSRError`) is the public detection contract; Next.js exposes
|
|
510
|
-
* neither.
|
|
511
|
-
*
|
|
512
|
-
* Ported from Next.js:
|
|
513
|
-
* https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/lazy-dynamic/bailout-to-csr.ts
|
|
514
|
-
*/
|
|
515
|
-
declare function isBailoutToCSRError(error: unknown): error is BailoutToCSRError;
|
|
516
|
-
declare const _DYNAMIC_SERVER_USAGE_DIGEST = "DYNAMIC_SERVER_USAGE";
|
|
517
|
-
/**
|
|
518
|
-
* Error thrown when dynamic server APIs (`cookies()`, `headers()`, etc.) are
|
|
519
|
-
* used inside a static/prerender context. Carries the `DYNAMIC_SERVER_USAGE`
|
|
520
|
-
* digest so `unstable_rethrow` can recognise and propagate it.
|
|
521
|
-
*
|
|
522
|
-
* vinext does not construct this error itself — exposed for the same
|
|
523
|
-
* "stable detection contract" reason as `BailoutToCSRError` above.
|
|
524
|
-
*
|
|
525
|
-
* Ported 1:1 from Next.js:
|
|
526
|
-
* https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/hooks-server-context.ts
|
|
527
|
-
*/
|
|
528
|
-
declare class DynamicServerError extends Error {
|
|
529
|
-
readonly digest: typeof _DYNAMIC_SERVER_USAGE_DIGEST;
|
|
530
|
-
readonly description: string;
|
|
531
|
-
constructor(description: string);
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Returns true if the error is a `DynamicServerError` (or any error with the
|
|
535
|
-
* canonical `DYNAMIC_SERVER_USAGE` digest).
|
|
536
|
-
*
|
|
537
|
-
* **Note on vinext public surface:** Next.js does NOT expose this from
|
|
538
|
-
* `next/navigation`. vinext exposes it for symmetry — treat it as a
|
|
539
|
-
* vinext-only extension.
|
|
540
|
-
*
|
|
541
|
-
* Ported from Next.js:
|
|
542
|
-
* https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/hooks-server-context.ts
|
|
543
|
-
*/
|
|
544
|
-
declare function isDynamicServerError(error: unknown): error is DynamicServerError;
|
|
545
|
-
/**
|
|
546
|
-
* Rethrow internal Next.js errors so they're handled by the framework.
|
|
547
|
-
*
|
|
548
|
-
* When wrapping an API that uses errors for control flow (redirect, notFound,
|
|
549
|
-
* cookies in static render, `next/dynamic` SSR bailout, etc.), call this
|
|
550
|
-
* inside `catch` blocks before doing your own error handling. If the error
|
|
551
|
-
* is a Next.js internal error, it's rethrown; otherwise this is a no-op
|
|
552
|
-
* (apart from recursing through `error.cause`).
|
|
553
|
-
*
|
|
554
|
-
* Recognises (matches Next.js's browser build + the subset of the server
|
|
555
|
-
* build that vinext can realistically encounter):
|
|
556
|
-
* - `isNextRouterError`: redirect / notFound / forbidden / unauthorized
|
|
557
|
-
* - `isBailoutToCSRError`: `next/dynamic` `ssr: false` bailout
|
|
558
|
-
* - `isDynamicServerError`: dynamic API used in static render
|
|
559
|
-
*
|
|
560
|
-
* vinext does not yet recognise four additional server-only Next.js
|
|
561
|
-
* categories — `isDynamicPostpone`, `isPostpone`,
|
|
562
|
-
* `isHangingPromiseRejectionError`, `isPrerenderInterruptedError` — because
|
|
563
|
-
* they signal PPR / prerender-controller events that vinext's render
|
|
564
|
-
* pipeline does not generate. User code cannot construct these in normal
|
|
565
|
-
* use; they will be added if/when vinext grows PPR support.
|
|
566
|
-
*
|
|
567
|
-
* Ported from Next.js:
|
|
568
|
-
* https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/unstable-rethrow.ts
|
|
569
|
-
* https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/unstable-rethrow.server.ts
|
|
570
|
-
* https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/unstable-rethrow.browser.ts
|
|
571
|
-
*/
|
|
572
|
-
declare function unstable_rethrow(error: unknown): void;
|
|
573
285
|
//#endregion
|
|
574
|
-
export { BailoutToCSRError, CachedRscResponse, ClientNavigationRenderSnapshot, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, NavigationContext, PREFETCH_CACHE_TTL, PrefetchCacheEntry, PrefetchOptions, ReadonlyURLSearchParams, RedirectType, SegmentMap, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
286
|
+
export { BailoutToCSRError, CachedRscResponse, ClientNavigationRenderSnapshot, DynamicServerError, GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, type NavigationContext, type NavigationStateAccessors, PREFETCH_CACHE_TTL, PrefetchCacheEntry, PrefetchOptions, ReadonlyURLSearchParams, RedirectType, type SegmentMap, ServerInsertedHTMLContext, UnrecognizedActionError, __basePath, _registerStateAccessors, activateNavigationSnapshot, appRouterInstance, applyAppRouterScrollFallback, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, consumePrefetchResponseForNavigation, createCachedRscResponseSnapshot, createClientNavigationRenderSnapshot, createSnapshotPathAndSearch, decodeRedirectError, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getBfcacheIdMapContext, getBfcacheSegmentIdContext, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchInterceptionContext, getPrefetchedUrls, hasPrefetchCacheEntryForNavigation, invalidatePrefetchCache, isBailoutToCSRError, isDynamicServerError, isHTTPAccessFallbackError, isNextRouterError, isRedirectError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, renderServerInsertedHTML, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, resolveCachedRscResponseExpiresAt, resolveCachedRscResponseTtlMs, resolvePrefetchCacheEntryMountedSlotsHeader, restoreRscResponse, saveScrollPosition, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, unauthorized, unstable_isUnrecognizedActionError, unstable_rethrow, useClientNavigationRenderSnapshot, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|