@uniformdev/next-app-router 20.81.0 → 20.81.1-alpha.10.sha-def425616f
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/{UniformComposition-DBO-oo7J.d.ts → UniformComposition-ChDH4dMd.d.ts} +12 -31
- package/dist/{UniformComposition-le6UEB_r.d.mts → UniformComposition-Doa1kKRm.d.mts} +12 -31
- package/dist/cache.d.mts +24 -6
- package/dist/cache.d.ts +24 -6
- package/dist/cache.js +396 -832
- package/dist/cache.mjs +391 -830
- package/dist/compat.d.mts +2 -4
- package/dist/compat.d.ts +2 -4
- package/dist/component.d.mts +10 -1
- package/dist/component.d.ts +10 -1
- package/dist/component.js +113 -617
- package/dist/component.mjs +112 -640
- package/dist/composition-CGU7iH-k.d.mts +37 -0
- package/dist/composition-CGU7iH-k.d.ts +37 -0
- package/dist/config/default.js +0 -1
- package/dist/config/default.mjs +0 -1
- package/dist/createCachedManifestProvider-2-2u3PYd.d.mts +84 -0
- package/dist/createCachedManifestProvider-BoorKD15.d.ts +84 -0
- package/dist/edge.d.mts +80 -0
- package/dist/edge.d.ts +80 -0
- package/dist/edge.js +1225 -0
- package/dist/edge.mjs +1191 -0
- package/dist/handler.d.mts +15 -2
- package/dist/handler.d.ts +15 -2
- package/dist/handler.js +134 -628
- package/dist/handler.mjs +132 -626
- package/dist/index.d.mts +81 -41
- package/dist/index.d.ts +81 -41
- package/dist/index.esm.js +2051 -5614
- package/dist/index.js +2092 -5651
- package/dist/index.mjs +2051 -5614
- package/dist/middleware.d.mts +60 -13
- package/dist/middleware.d.ts +60 -13
- package/dist/middleware.js +415 -5746
- package/dist/middleware.mjs +422 -5776
- package/dist/models-C8OdCO44.d.mts +72 -0
- package/dist/models-C8OdCO44.d.ts +72 -0
- package/dist/resolveRouteFromPath-CnfnaxY2.d.ts +80 -0
- package/dist/resolveRouteFromPath-_rauUskz.d.mts +80 -0
- package/dist/vercel.d.mts +37 -0
- package/dist/vercel.d.ts +37 -0
- package/dist/vercel.js +788 -0
- package/dist/vercel.mjs +759 -0
- package/package.json +37 -9
- package/dist/client-BElN_CWD.d.mts +0 -786
- package/dist/client-BElN_CWD.d.ts +0 -786
- package/dist/resolveRouteFromCode-BOvjIvM2.d.ts +0 -18
- package/dist/resolveRouteFromCode-CuJ4JHeb.d.mts +0 -18
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RouteGetResponseEdgehancedComposition, RouteGetResponseRedirect } from '@uniformdev/canvas';
|
|
2
|
+
import { PageState } from '@uniformdev/next-app-router-shared';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A composition resolved for a page, with the page state it was resolved for. `UniformComposition`
|
|
6
|
+
* renders it, and the same object can be reused by `generateMetadata`, layouts, or another
|
|
7
|
+
* resolver that should carry the page state through.
|
|
8
|
+
*/
|
|
9
|
+
type ResolvedComposition = {
|
|
10
|
+
pageState: PageState;
|
|
11
|
+
route: RouteGetResponseEdgehancedComposition;
|
|
12
|
+
};
|
|
13
|
+
/** A route that matched a redirect, with the page state it was resolved for. */
|
|
14
|
+
type ResolvedRedirect = {
|
|
15
|
+
pageState: PageState;
|
|
16
|
+
route: RouteGetResponseRedirect;
|
|
17
|
+
};
|
|
18
|
+
/** Nothing matched, with the page state the resolver ran for. */
|
|
19
|
+
type ResolvedNotFound = {
|
|
20
|
+
pageState: PageState;
|
|
21
|
+
route: undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* What `resolveCompositionById`, `resolveCompositionBySlug` and `resolvePlaygroundRoute` return: a
|
|
25
|
+
* {@link ResolvedComposition}, or {@link ResolvedNotFound} when no composition matched. They skip
|
|
26
|
+
* the Route API, so they never return a redirect.
|
|
27
|
+
*/
|
|
28
|
+
type ResolvedCompositionResult = ResolvedComposition | ResolvedNotFound;
|
|
29
|
+
/**
|
|
30
|
+
* What a Route API resolver returns: a {@link ResolvedComposition}, a {@link ResolvedRedirect}, or
|
|
31
|
+
* {@link ResolvedNotFound} when nothing matched. `UniformComposition` takes it as is and renders
|
|
32
|
+
* only a composition; `requireComposition` applies the redirect and not found cases with Next.js
|
|
33
|
+
* navigation.
|
|
34
|
+
*/
|
|
35
|
+
type ResolvedRouteResult = ResolvedComposition | ResolvedRedirect | ResolvedNotFound;
|
|
36
|
+
|
|
37
|
+
export type { ResolvedCompositionResult as R, ResolvedRouteResult as a, ResolvedComposition as b, ResolvedNotFound as c, ResolvedRedirect as d };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RouteGetResponseEdgehancedComposition, RouteGetResponseRedirect } from '@uniformdev/canvas';
|
|
2
|
+
import { PageState } from '@uniformdev/next-app-router-shared';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A composition resolved for a page, with the page state it was resolved for. `UniformComposition`
|
|
6
|
+
* renders it, and the same object can be reused by `generateMetadata`, layouts, or another
|
|
7
|
+
* resolver that should carry the page state through.
|
|
8
|
+
*/
|
|
9
|
+
type ResolvedComposition = {
|
|
10
|
+
pageState: PageState;
|
|
11
|
+
route: RouteGetResponseEdgehancedComposition;
|
|
12
|
+
};
|
|
13
|
+
/** A route that matched a redirect, with the page state it was resolved for. */
|
|
14
|
+
type ResolvedRedirect = {
|
|
15
|
+
pageState: PageState;
|
|
16
|
+
route: RouteGetResponseRedirect;
|
|
17
|
+
};
|
|
18
|
+
/** Nothing matched, with the page state the resolver ran for. */
|
|
19
|
+
type ResolvedNotFound = {
|
|
20
|
+
pageState: PageState;
|
|
21
|
+
route: undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* What `resolveCompositionById`, `resolveCompositionBySlug` and `resolvePlaygroundRoute` return: a
|
|
25
|
+
* {@link ResolvedComposition}, or {@link ResolvedNotFound} when no composition matched. They skip
|
|
26
|
+
* the Route API, so they never return a redirect.
|
|
27
|
+
*/
|
|
28
|
+
type ResolvedCompositionResult = ResolvedComposition | ResolvedNotFound;
|
|
29
|
+
/**
|
|
30
|
+
* What a Route API resolver returns: a {@link ResolvedComposition}, a {@link ResolvedRedirect}, or
|
|
31
|
+
* {@link ResolvedNotFound} when nothing matched. `UniformComposition` takes it as is and renders
|
|
32
|
+
* only a composition; `requireComposition` applies the redirect and not found cases with Next.js
|
|
33
|
+
* navigation.
|
|
34
|
+
*/
|
|
35
|
+
type ResolvedRouteResult = ResolvedComposition | ResolvedRedirect | ResolvedNotFound;
|
|
36
|
+
|
|
37
|
+
export type { ResolvedCompositionResult as R, ResolvedRouteResult as a, ResolvedComposition as b, ResolvedNotFound as c, ResolvedRedirect as d };
|
package/dist/config/default.js
CHANGED
package/dist/config/default.mjs
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { b as EdgeRouteFilterCache, E as EdgeRouteFilter, e as ManifestCache, M as ManifestProvider } from './models-C8OdCO44.mjs';
|
|
2
|
+
import { ManifestV2 } from '@uniformdev/context';
|
|
3
|
+
|
|
4
|
+
type CreateLearnedEdgeRouteFilterOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* The platform's shared cache. Without one, each instance learns on its own and forgets when it
|
|
7
|
+
* restarts.
|
|
8
|
+
*/
|
|
9
|
+
cache?: EdgeRouteFilterCache;
|
|
10
|
+
/**
|
|
11
|
+
* Seconds a record lives in `cache`. Publishing a composition or changing the project map
|
|
12
|
+
* expires its paths sooner when the preview route handler expires their `path:` tags in the same
|
|
13
|
+
* cache.
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue 3600
|
|
16
|
+
*/
|
|
17
|
+
ttl?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Seconds an instance reuses what it knows about a page before checking `cache` again. Bounds
|
|
20
|
+
* how long an instance keeps a record after it is expired.
|
|
21
|
+
*
|
|
22
|
+
* @defaultValue 10
|
|
23
|
+
*/
|
|
24
|
+
maxAge?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Pages an instance remembers. The least recently stored page is forgotten first.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue 1000
|
|
29
|
+
*/
|
|
30
|
+
maxEntries?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Creates an edge route filter that learns which pages have placements. A page it knows nothing
|
|
34
|
+
* about is processed, and the edge middleware reports whether the transform found placements.
|
|
35
|
+
* Pages without placements are then rewritten without processing until the record expires.
|
|
36
|
+
* Records live in memory for `maxAge`, then in the platform's shared `cache`, tagged with the
|
|
37
|
+
* page's `path:` tag.
|
|
38
|
+
*
|
|
39
|
+
* Publishing a pattern or entry does not expire the pages that use it. Until the record expires,
|
|
40
|
+
* a page that gained a placement that way has it chosen in the browser.
|
|
41
|
+
*/
|
|
42
|
+
declare const createLearnedEdgeRouteFilter: ({ cache, ttl, maxAge, maxEntries, }?: CreateLearnedEdgeRouteFilterOptions) => EdgeRouteFilter;
|
|
43
|
+
|
|
44
|
+
type CreateCachedManifestProviderOptions = {
|
|
45
|
+
/**
|
|
46
|
+
* The platform's shared cache. Without one, each instance loads the manifest from the API
|
|
47
|
+
* whenever its copy is older than `maxAge`.
|
|
48
|
+
*/
|
|
49
|
+
cache?: ManifestCache;
|
|
50
|
+
/**
|
|
51
|
+
* Returned when the manifest cannot be loaded and the instance has no earlier copy, for
|
|
52
|
+
* example a manifest baked into the build with `uniform context manifest download`.
|
|
53
|
+
*/
|
|
54
|
+
fallback?: ManifestV2;
|
|
55
|
+
/**
|
|
56
|
+
* Seconds an entry lives in `cache`. Publishing the manifest expires it sooner when the
|
|
57
|
+
* preview route handler expires the `manifest` tag in the same cache.
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue 3600
|
|
60
|
+
*/
|
|
61
|
+
ttl?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Seconds an instance reuses the manifest it loaded before checking `cache` again. Bounds how
|
|
64
|
+
* long an instance keeps serving a manifest after it is published.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue 10
|
|
67
|
+
*/
|
|
68
|
+
maxAge?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Loads the published manifest when `cache` has none.
|
|
71
|
+
*
|
|
72
|
+
* @defaultValue the Uniform API, with the project and key from the `UNIFORM_*` env vars
|
|
73
|
+
*/
|
|
74
|
+
fetchManifest?: () => Promise<ManifestV2>;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Creates a manifest provider that keeps the manifest in memory for `maxAge`, then reads it from
|
|
78
|
+
* the platform's shared `cache`, then from the Uniform API, writing what it fetched back to the
|
|
79
|
+
* cache. Concurrent requests share one load. When loading fails, it returns the last manifest it
|
|
80
|
+
* loaded, then `fallback`, and otherwise rethrows.
|
|
81
|
+
*/
|
|
82
|
+
declare const createCachedManifestProvider: ({ cache, fallback, ttl, maxAge, fetchManifest, }?: CreateCachedManifestProviderOptions) => ManifestProvider;
|
|
83
|
+
|
|
84
|
+
export { type CreateCachedManifestProviderOptions as C, type CreateLearnedEdgeRouteFilterOptions as a, createLearnedEdgeRouteFilter as b, createCachedManifestProvider as c };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { b as EdgeRouteFilterCache, E as EdgeRouteFilter, e as ManifestCache, M as ManifestProvider } from './models-C8OdCO44.js';
|
|
2
|
+
import { ManifestV2 } from '@uniformdev/context';
|
|
3
|
+
|
|
4
|
+
type CreateLearnedEdgeRouteFilterOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* The platform's shared cache. Without one, each instance learns on its own and forgets when it
|
|
7
|
+
* restarts.
|
|
8
|
+
*/
|
|
9
|
+
cache?: EdgeRouteFilterCache;
|
|
10
|
+
/**
|
|
11
|
+
* Seconds a record lives in `cache`. Publishing a composition or changing the project map
|
|
12
|
+
* expires its paths sooner when the preview route handler expires their `path:` tags in the same
|
|
13
|
+
* cache.
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue 3600
|
|
16
|
+
*/
|
|
17
|
+
ttl?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Seconds an instance reuses what it knows about a page before checking `cache` again. Bounds
|
|
20
|
+
* how long an instance keeps a record after it is expired.
|
|
21
|
+
*
|
|
22
|
+
* @defaultValue 10
|
|
23
|
+
*/
|
|
24
|
+
maxAge?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Pages an instance remembers. The least recently stored page is forgotten first.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue 1000
|
|
29
|
+
*/
|
|
30
|
+
maxEntries?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Creates an edge route filter that learns which pages have placements. A page it knows nothing
|
|
34
|
+
* about is processed, and the edge middleware reports whether the transform found placements.
|
|
35
|
+
* Pages without placements are then rewritten without processing until the record expires.
|
|
36
|
+
* Records live in memory for `maxAge`, then in the platform's shared `cache`, tagged with the
|
|
37
|
+
* page's `path:` tag.
|
|
38
|
+
*
|
|
39
|
+
* Publishing a pattern or entry does not expire the pages that use it. Until the record expires,
|
|
40
|
+
* a page that gained a placement that way has it chosen in the browser.
|
|
41
|
+
*/
|
|
42
|
+
declare const createLearnedEdgeRouteFilter: ({ cache, ttl, maxAge, maxEntries, }?: CreateLearnedEdgeRouteFilterOptions) => EdgeRouteFilter;
|
|
43
|
+
|
|
44
|
+
type CreateCachedManifestProviderOptions = {
|
|
45
|
+
/**
|
|
46
|
+
* The platform's shared cache. Without one, each instance loads the manifest from the API
|
|
47
|
+
* whenever its copy is older than `maxAge`.
|
|
48
|
+
*/
|
|
49
|
+
cache?: ManifestCache;
|
|
50
|
+
/**
|
|
51
|
+
* Returned when the manifest cannot be loaded and the instance has no earlier copy, for
|
|
52
|
+
* example a manifest baked into the build with `uniform context manifest download`.
|
|
53
|
+
*/
|
|
54
|
+
fallback?: ManifestV2;
|
|
55
|
+
/**
|
|
56
|
+
* Seconds an entry lives in `cache`. Publishing the manifest expires it sooner when the
|
|
57
|
+
* preview route handler expires the `manifest` tag in the same cache.
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue 3600
|
|
60
|
+
*/
|
|
61
|
+
ttl?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Seconds an instance reuses the manifest it loaded before checking `cache` again. Bounds how
|
|
64
|
+
* long an instance keeps serving a manifest after it is published.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue 10
|
|
67
|
+
*/
|
|
68
|
+
maxAge?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Loads the published manifest when `cache` has none.
|
|
71
|
+
*
|
|
72
|
+
* @defaultValue the Uniform API, with the project and key from the `UNIFORM_*` env vars
|
|
73
|
+
*/
|
|
74
|
+
fetchManifest?: () => Promise<ManifestV2>;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Creates a manifest provider that keeps the manifest in memory for `maxAge`, then reads it from
|
|
78
|
+
* the platform's shared `cache`, then from the Uniform API, writing what it fetched back to the
|
|
79
|
+
* cache. Concurrent requests share one load. When loading fails, it returns the last manifest it
|
|
80
|
+
* loaded, then `fallback`, and otherwise rethrows.
|
|
81
|
+
*/
|
|
82
|
+
declare const createCachedManifestProvider: ({ cache, fallback, ttl, maxAge, fetchManifest, }?: CreateCachedManifestProviderOptions) => ManifestProvider;
|
|
83
|
+
|
|
84
|
+
export { type CreateCachedManifestProviderOptions as C, type CreateLearnedEdgeRouteFilterOptions as a, createLearnedEdgeRouteFilter as b, createCachedManifestProvider as c };
|
package/dist/edge.d.mts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ManifestV2 } from '@uniformdev/context';
|
|
2
|
+
import { TransformEdgeStreamOptions } from '@uniformdev/context-edge';
|
|
3
|
+
import { NextRequest, NextFetchEvent } from 'next/server';
|
|
4
|
+
import { M as ManifestProvider, E as EdgeRouteFilter, a as ManifestProviderOptions } from './models-C8OdCO44.mjs';
|
|
5
|
+
export { b as EdgeRouteFilterCache, c as EdgeRouteFilterOptions, d as EdgeRouteRecord, e as ManifestCache } from './models-C8OdCO44.mjs';
|
|
6
|
+
import { HandleOptions } from './middleware.mjs';
|
|
7
|
+
export { C as CreateCachedManifestProviderOptions, a as CreateLearnedEdgeRouteFilterOptions, c as createCachedManifestProvider, b as createLearnedEdgeRouteFilter } from './createCachedManifestProvider-2-2u3PYd.mjs';
|
|
8
|
+
import '@uniformdev/next-app-router-shared';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Marks the edge middleware's own fetch of the rendered page, so the middleware lets it through
|
|
12
|
+
* when the matcher also covers the rewrite destination.
|
|
13
|
+
*/
|
|
14
|
+
declare const UNIFORM_EDGE_ORIGIN_HEADER = "x-uniform-edge-origin";
|
|
15
|
+
type UniformEdgeMiddlewareOptions = HandleOptions & {
|
|
16
|
+
/**
|
|
17
|
+
* The project's Context manifest, which chooses the visitor's variants.
|
|
18
|
+
*
|
|
19
|
+
* Pass a manifest baked into the build (for example with `uniform context manifest download`)
|
|
20
|
+
* so the middleware makes no network calls. Signals and tests published after the build are
|
|
21
|
+
* then out of date at the edge until the next build.
|
|
22
|
+
*
|
|
23
|
+
* Pass a provider, such as `vercelManifestProvider` from `@uniformdev/next-app-router/vercel`
|
|
24
|
+
* or one made with `createCachedManifestProvider`, to load the published manifest at runtime.
|
|
25
|
+
* It is called for HTML document requests only, alongside the fetch of the page.
|
|
26
|
+
*/
|
|
27
|
+
manifest: ManifestV2 | ManifestProvider;
|
|
28
|
+
/**
|
|
29
|
+
* Called when the manifest provider throws, and when the NESI transform fails. A provider
|
|
30
|
+
* failure receives the error, and the edge chooses with an empty manifest: personalizations
|
|
31
|
+
* show their defaults, and the browser chooses tests after hydration. A transform failure
|
|
32
|
+
* also receives the decoded HTML chunk that triggered it, when available, and the response
|
|
33
|
+
* ends at the point of failure.
|
|
34
|
+
*/
|
|
35
|
+
onError?: TransformEdgeStreamOptions['onError'];
|
|
36
|
+
/**
|
|
37
|
+
* Decides which published pages are processed at the edge, such as `vercelEdgeRouteFilter` from
|
|
38
|
+
* `@uniformdev/next-app-router/vercel`, `createLearnedEdgeRouteFilter` or
|
|
39
|
+
* `createStaticEdgeRouteFilter`. Pages it skips are rewritten without processing, stay cacheable
|
|
40
|
+
* by the CDN, and have their variants chosen in the browser.
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue every published page is processed
|
|
43
|
+
*/
|
|
44
|
+
filter?: EdgeRouteFilter;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Returns middleware that rewrites each request to its Uniform code like `uniformMiddleware`, and
|
|
48
|
+
* processes the NESI tags in the page at the edge. Published pages that the `filter` processes get
|
|
49
|
+
* `edgeMode` in their page state, so `UniformComposition` renders their personalizations and
|
|
50
|
+
* tests between NESI tags. HTML document requests for those pages fetch the page and keep only the
|
|
51
|
+
* visitor's variants. Client navigations, prefetches, draft requests and pages the filter skips
|
|
52
|
+
* are rewritten, and their variants are chosen in the browser.
|
|
53
|
+
*
|
|
54
|
+
* Requires the optional peer dependency `@uniformdev/context-edge`.
|
|
55
|
+
*/
|
|
56
|
+
declare const uniformEdgeMiddleware: (options: UniformEdgeMiddlewareOptions) => (request: NextRequest, event?: Pick<NextFetchEvent, "waitUntil">) => Promise<Response>;
|
|
57
|
+
/**
|
|
58
|
+
* Handles one request the way {@link uniformEdgeMiddleware} does. The transformed response is
|
|
59
|
+
* personalized, so it is marked `private, no-store`. `waitUntil` is handed to the manifest provider
|
|
60
|
+
* and the filter for background work, and defaults to letting the promise run unobserved.
|
|
61
|
+
*/
|
|
62
|
+
declare const handleUniformEdgeRoute: ({ request, manifest, onError, filter, waitUntil, ...options }: UniformEdgeMiddlewareOptions & {
|
|
63
|
+
request: NextRequest;
|
|
64
|
+
waitUntil?: ManifestProviderOptions["waitUntil"];
|
|
65
|
+
}) => Promise<Response>;
|
|
66
|
+
|
|
67
|
+
type CreateStaticEdgeRouteFilterOptions = {
|
|
68
|
+
/**
|
|
69
|
+
* Project map paths whose pages contain personalizations or tests, for example `/` or
|
|
70
|
+
* `/products/:slug`. A `:name` segment matches any single segment. Query strings are ignored.
|
|
71
|
+
*/
|
|
72
|
+
paths: string[];
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Creates an edge route filter that processes only the pages whose route path matches one of
|
|
76
|
+
* `paths`. Pages outside the list keep their personalizations and tests, which the browser chooses.
|
|
77
|
+
*/
|
|
78
|
+
declare const createStaticEdgeRouteFilter: ({ paths, }: CreateStaticEdgeRouteFilterOptions) => EdgeRouteFilter;
|
|
79
|
+
|
|
80
|
+
export { type CreateStaticEdgeRouteFilterOptions, EdgeRouteFilter, ManifestProvider, ManifestProviderOptions, UNIFORM_EDGE_ORIGIN_HEADER, type UniformEdgeMiddlewareOptions, createStaticEdgeRouteFilter, handleUniformEdgeRoute, uniformEdgeMiddleware };
|
package/dist/edge.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ManifestV2 } from '@uniformdev/context';
|
|
2
|
+
import { TransformEdgeStreamOptions } from '@uniformdev/context-edge';
|
|
3
|
+
import { NextRequest, NextFetchEvent } from 'next/server';
|
|
4
|
+
import { M as ManifestProvider, E as EdgeRouteFilter, a as ManifestProviderOptions } from './models-C8OdCO44.js';
|
|
5
|
+
export { b as EdgeRouteFilterCache, c as EdgeRouteFilterOptions, d as EdgeRouteRecord, e as ManifestCache } from './models-C8OdCO44.js';
|
|
6
|
+
import { HandleOptions } from './middleware.js';
|
|
7
|
+
export { C as CreateCachedManifestProviderOptions, a as CreateLearnedEdgeRouteFilterOptions, c as createCachedManifestProvider, b as createLearnedEdgeRouteFilter } from './createCachedManifestProvider-BoorKD15.js';
|
|
8
|
+
import '@uniformdev/next-app-router-shared';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Marks the edge middleware's own fetch of the rendered page, so the middleware lets it through
|
|
12
|
+
* when the matcher also covers the rewrite destination.
|
|
13
|
+
*/
|
|
14
|
+
declare const UNIFORM_EDGE_ORIGIN_HEADER = "x-uniform-edge-origin";
|
|
15
|
+
type UniformEdgeMiddlewareOptions = HandleOptions & {
|
|
16
|
+
/**
|
|
17
|
+
* The project's Context manifest, which chooses the visitor's variants.
|
|
18
|
+
*
|
|
19
|
+
* Pass a manifest baked into the build (for example with `uniform context manifest download`)
|
|
20
|
+
* so the middleware makes no network calls. Signals and tests published after the build are
|
|
21
|
+
* then out of date at the edge until the next build.
|
|
22
|
+
*
|
|
23
|
+
* Pass a provider, such as `vercelManifestProvider` from `@uniformdev/next-app-router/vercel`
|
|
24
|
+
* or one made with `createCachedManifestProvider`, to load the published manifest at runtime.
|
|
25
|
+
* It is called for HTML document requests only, alongside the fetch of the page.
|
|
26
|
+
*/
|
|
27
|
+
manifest: ManifestV2 | ManifestProvider;
|
|
28
|
+
/**
|
|
29
|
+
* Called when the manifest provider throws, and when the NESI transform fails. A provider
|
|
30
|
+
* failure receives the error, and the edge chooses with an empty manifest: personalizations
|
|
31
|
+
* show their defaults, and the browser chooses tests after hydration. A transform failure
|
|
32
|
+
* also receives the decoded HTML chunk that triggered it, when available, and the response
|
|
33
|
+
* ends at the point of failure.
|
|
34
|
+
*/
|
|
35
|
+
onError?: TransformEdgeStreamOptions['onError'];
|
|
36
|
+
/**
|
|
37
|
+
* Decides which published pages are processed at the edge, such as `vercelEdgeRouteFilter` from
|
|
38
|
+
* `@uniformdev/next-app-router/vercel`, `createLearnedEdgeRouteFilter` or
|
|
39
|
+
* `createStaticEdgeRouteFilter`. Pages it skips are rewritten without processing, stay cacheable
|
|
40
|
+
* by the CDN, and have their variants chosen in the browser.
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue every published page is processed
|
|
43
|
+
*/
|
|
44
|
+
filter?: EdgeRouteFilter;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Returns middleware that rewrites each request to its Uniform code like `uniformMiddleware`, and
|
|
48
|
+
* processes the NESI tags in the page at the edge. Published pages that the `filter` processes get
|
|
49
|
+
* `edgeMode` in their page state, so `UniformComposition` renders their personalizations and
|
|
50
|
+
* tests between NESI tags. HTML document requests for those pages fetch the page and keep only the
|
|
51
|
+
* visitor's variants. Client navigations, prefetches, draft requests and pages the filter skips
|
|
52
|
+
* are rewritten, and their variants are chosen in the browser.
|
|
53
|
+
*
|
|
54
|
+
* Requires the optional peer dependency `@uniformdev/context-edge`.
|
|
55
|
+
*/
|
|
56
|
+
declare const uniformEdgeMiddleware: (options: UniformEdgeMiddlewareOptions) => (request: NextRequest, event?: Pick<NextFetchEvent, "waitUntil">) => Promise<Response>;
|
|
57
|
+
/**
|
|
58
|
+
* Handles one request the way {@link uniformEdgeMiddleware} does. The transformed response is
|
|
59
|
+
* personalized, so it is marked `private, no-store`. `waitUntil` is handed to the manifest provider
|
|
60
|
+
* and the filter for background work, and defaults to letting the promise run unobserved.
|
|
61
|
+
*/
|
|
62
|
+
declare const handleUniformEdgeRoute: ({ request, manifest, onError, filter, waitUntil, ...options }: UniformEdgeMiddlewareOptions & {
|
|
63
|
+
request: NextRequest;
|
|
64
|
+
waitUntil?: ManifestProviderOptions["waitUntil"];
|
|
65
|
+
}) => Promise<Response>;
|
|
66
|
+
|
|
67
|
+
type CreateStaticEdgeRouteFilterOptions = {
|
|
68
|
+
/**
|
|
69
|
+
* Project map paths whose pages contain personalizations or tests, for example `/` or
|
|
70
|
+
* `/products/:slug`. A `:name` segment matches any single segment. Query strings are ignored.
|
|
71
|
+
*/
|
|
72
|
+
paths: string[];
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Creates an edge route filter that processes only the pages whose route path matches one of
|
|
76
|
+
* `paths`. Pages outside the list keep their personalizations and tests, which the browser chooses.
|
|
77
|
+
*/
|
|
78
|
+
declare const createStaticEdgeRouteFilter: ({ paths, }: CreateStaticEdgeRouteFilterOptions) => EdgeRouteFilter;
|
|
79
|
+
|
|
80
|
+
export { type CreateStaticEdgeRouteFilterOptions, EdgeRouteFilter, ManifestProvider, ManifestProviderOptions, UNIFORM_EDGE_ORIGIN_HEADER, type UniformEdgeMiddlewareOptions, createStaticEdgeRouteFilter, handleUniformEdgeRoute, uniformEdgeMiddleware };
|