@uniformdev/next-app-router 20.81.1-alpha.4.sha-de16ebeee7 → 20.81.1-alpha.41.sha-adcf82dedd
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-fq7Qfhvp.d.mts → UniformResolvedComposition-Ckhza3b7.d.mts} +25 -27
- package/dist/{UniformComposition-T7CRvU1H.d.ts → UniformResolvedComposition-Dr73WwIO.d.ts} +25 -27
- package/dist/akamai.d.mts +106 -0
- package/dist/akamai.d.ts +106 -0
- package/dist/akamai.js +1672 -0
- package/dist/akamai.mjs +1634 -0
- package/dist/cache.d.mts +26 -4
- package/dist/cache.d.ts +26 -4
- package/dist/cache.js +439 -89
- package/dist/cache.mjs +435 -88
- package/dist/cf-vinext.d.mts +69 -0
- package/dist/cf-vinext.d.ts +69 -0
- package/dist/cf-vinext.js +2083 -0
- package/dist/cf-vinext.mjs +2050 -0
- package/dist/compat.d.mts +2 -2
- package/dist/compat.d.ts +2 -2
- package/dist/component.d.mts +1 -10
- package/dist/component.d.ts +1 -10
- package/dist/component.js +39 -53
- package/dist/component.mjs +39 -52
- package/dist/composition-C7voY4YR.d.mts +37 -0
- package/dist/composition-C7voY4YR.d.ts +37 -0
- package/dist/createCachedManifestProvider-Bsx_in7t.d.mts +45 -0
- package/dist/createCachedManifestProvider-ChIWejZA.d.ts +45 -0
- package/dist/createEdgeRouteStore-B2ugix2E.d.ts +225 -0
- package/dist/createEdgeRouteStore-DaU9QjP2.d.mts +225 -0
- package/dist/createPreviewGETRouteHandler-ii7w-gAc.d.mts +25 -0
- package/dist/createPreviewGETRouteHandler-ii7w-gAc.d.ts +25 -0
- package/dist/edge.d.mts +45 -35
- package/dist/edge.d.ts +45 -35
- package/dist/edge.js +1462 -143
- package/dist/edge.mjs +1462 -149
- package/dist/handler.d.mts +16 -24
- package/dist/handler.d.ts +16 -24
- package/dist/handler.js +357 -130
- package/dist/handler.mjs +344 -117
- package/dist/index.d.mts +171 -19
- package/dist/index.d.ts +171 -19
- package/dist/index.esm.js +571 -278
- package/dist/index.js +587 -296
- package/dist/index.mjs +571 -278
- package/dist/learnedEdgeRouteFilter-DWg-puGg.d.mts +30 -0
- package/dist/learnedEdgeRouteFilter-i9hELx_t.d.ts +30 -0
- package/dist/middleware.d.mts +21 -2
- package/dist/middleware.d.ts +21 -2
- package/dist/middleware.js +118 -86
- package/dist/middleware.mjs +123 -92
- package/dist/models-kIvBB7Tv.d.mts +141 -0
- package/dist/models-kIvBB7Tv.d.ts +141 -0
- package/dist/resolveRouteFromPath-BpuMu5ZS.d.ts +81 -0
- package/dist/resolveRouteFromPath-DWNRjFHQ.d.mts +81 -0
- package/dist/vercel.d.mts +77 -0
- package/dist/vercel.d.ts +77 -0
- package/dist/vercel.js +2089 -0
- package/dist/vercel.mjs +2056 -0
- package/package.json +45 -13
- package/dist/resolveRouteFromCode-CId7aItt.d.mts +0 -48
- package/dist/resolveRouteFromCode-CId7aItt.d.ts +0 -48
package/dist/{UniformComposition-fq7Qfhvp.d.mts → UniformResolvedComposition-Ckhza3b7.d.mts}
RENAMED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { RootComponentInstance, ComponentInstance } from '@uniformdev/canvas';
|
|
2
2
|
import { ComponentProps } from '@uniformdev/next-app-router-shared';
|
|
3
3
|
import React, { ComponentType } from 'react';
|
|
4
|
-
import { a as ResolvedRouteResult
|
|
5
|
-
import { ClientContextComponent } from '@uniformdev/next-app-router-client';
|
|
4
|
+
import { a as ResolvedRouteResult } from './composition-C7voY4YR.mjs';
|
|
6
5
|
|
|
7
6
|
type CompositionCache = {
|
|
8
7
|
getUniformComposition: ({ id }: {
|
|
@@ -14,19 +13,12 @@ type CompositionCache = {
|
|
|
14
13
|
componentId: string;
|
|
15
14
|
}) => ComponentInstance | null;
|
|
16
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates a cache of the compositions rendered during a request, which components read with
|
|
18
|
+
* `getUniformComposition` and `getUniformComponent`. Each request starts empty.
|
|
19
|
+
*/
|
|
17
20
|
declare const createCompositionCache: () => CompositionCache;
|
|
18
21
|
|
|
19
|
-
type UniformContextProps = {
|
|
20
|
-
/**
|
|
21
|
-
* Component to initialize Uniform context on the client.
|
|
22
|
-
*/
|
|
23
|
-
clientContextComponent?: ClientContextComponent;
|
|
24
|
-
/**
|
|
25
|
-
* The result of the route resolution.
|
|
26
|
-
*/
|
|
27
|
-
result: ResolvedRouteResult | undefined;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
22
|
type ResolveComponentResult = {
|
|
31
23
|
component: ComponentType<ComponentProps<any, any>> | null;
|
|
32
24
|
includeContext?: boolean;
|
|
@@ -47,32 +39,38 @@ type ResolveComponentFunction = (options: {
|
|
|
47
39
|
component: ComponentInstance;
|
|
48
40
|
}) => ResolveComponentResult;
|
|
49
41
|
type ResolveEmptyPlaceholderFunction = (options: ResolveEmptyPlaceholderOptions) => ResolveEmptyPlaceholderResult;
|
|
50
|
-
type
|
|
42
|
+
type UniformResolvedCompositionProps = {
|
|
51
43
|
/**
|
|
52
|
-
* The
|
|
44
|
+
* The result of any resolver, passed as is. A composition renders; a redirect or not found
|
|
45
|
+
* renders nothing. To redirect or return a 404 instead, pass the result through
|
|
46
|
+
* `requireComposition` first.
|
|
53
47
|
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Function to resolve the route from the code.
|
|
57
|
-
*/
|
|
58
|
-
resolveRoute: ResolveRouteFunction;
|
|
48
|
+
result: ResolvedRouteResult;
|
|
59
49
|
/**
|
|
60
50
|
* Function to map composition components to React components.
|
|
61
51
|
*/
|
|
62
52
|
resolveComponent: ResolveComponentFunction;
|
|
63
|
-
/**
|
|
64
|
-
* Resolves the route for the code. Defaults to `DefaultDataClient`.
|
|
65
|
-
*/
|
|
66
|
-
dataClient?: DataClient;
|
|
67
53
|
/**
|
|
68
54
|
* Function to map empty placeholders to React components.
|
|
69
55
|
*/
|
|
70
56
|
resolveEmptyPlaceholder?: ResolveEmptyPlaceholderFunction;
|
|
57
|
+
/**
|
|
58
|
+
* Marks the page's primary composition. It sets the composition metadata of the visitor's
|
|
59
|
+
* context, which Uniform Insights attributes page hits and goals to, and the default consent
|
|
60
|
+
* from its page state. In the editor and draft states it also loads the contextual editing
|
|
61
|
+
* script. Set it on one composition per page.
|
|
62
|
+
*/
|
|
63
|
+
pageComposition?: boolean;
|
|
71
64
|
/**
|
|
72
65
|
* Composition cache, will be used to cache the composition.
|
|
73
66
|
*/
|
|
74
67
|
compositionCache?: CompositionCache;
|
|
75
|
-
}
|
|
76
|
-
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Renders a resolved composition, or nothing when the result is a redirect or not found. Render it
|
|
71
|
+
* before the root layout's `UniformContext`, and set `pageComposition` on the page's primary
|
|
72
|
+
* composition.
|
|
73
|
+
*/
|
|
74
|
+
declare function UniformResolvedComposition(props: UniformResolvedCompositionProps): React.JSX.Element;
|
|
77
75
|
|
|
78
|
-
export { type CompositionCache as C, type ResolveComponentResult as R, type
|
|
76
|
+
export { type CompositionCache as C, type ResolveComponentResult as R, type UniformResolvedCompositionProps as U, type ResolveComponentFunction as a, UniformResolvedComposition as b, createCompositionCache as c };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { RootComponentInstance, ComponentInstance } from '@uniformdev/canvas';
|
|
2
2
|
import { ComponentProps } from '@uniformdev/next-app-router-shared';
|
|
3
3
|
import React, { ComponentType } from 'react';
|
|
4
|
-
import { a as ResolvedRouteResult
|
|
5
|
-
import { ClientContextComponent } from '@uniformdev/next-app-router-client';
|
|
4
|
+
import { a as ResolvedRouteResult } from './composition-C7voY4YR.js';
|
|
6
5
|
|
|
7
6
|
type CompositionCache = {
|
|
8
7
|
getUniformComposition: ({ id }: {
|
|
@@ -14,19 +13,12 @@ type CompositionCache = {
|
|
|
14
13
|
componentId: string;
|
|
15
14
|
}) => ComponentInstance | null;
|
|
16
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates a cache of the compositions rendered during a request, which components read with
|
|
18
|
+
* `getUniformComposition` and `getUniformComponent`. Each request starts empty.
|
|
19
|
+
*/
|
|
17
20
|
declare const createCompositionCache: () => CompositionCache;
|
|
18
21
|
|
|
19
|
-
type UniformContextProps = {
|
|
20
|
-
/**
|
|
21
|
-
* Component to initialize Uniform context on the client.
|
|
22
|
-
*/
|
|
23
|
-
clientContextComponent?: ClientContextComponent;
|
|
24
|
-
/**
|
|
25
|
-
* The result of the route resolution.
|
|
26
|
-
*/
|
|
27
|
-
result: ResolvedRouteResult | undefined;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
22
|
type ResolveComponentResult = {
|
|
31
23
|
component: ComponentType<ComponentProps<any, any>> | null;
|
|
32
24
|
includeContext?: boolean;
|
|
@@ -47,32 +39,38 @@ type ResolveComponentFunction = (options: {
|
|
|
47
39
|
component: ComponentInstance;
|
|
48
40
|
}) => ResolveComponentResult;
|
|
49
41
|
type ResolveEmptyPlaceholderFunction = (options: ResolveEmptyPlaceholderOptions) => ResolveEmptyPlaceholderResult;
|
|
50
|
-
type
|
|
42
|
+
type UniformResolvedCompositionProps = {
|
|
51
43
|
/**
|
|
52
|
-
* The
|
|
44
|
+
* The result of any resolver, passed as is. A composition renders; a redirect or not found
|
|
45
|
+
* renders nothing. To redirect or return a 404 instead, pass the result through
|
|
46
|
+
* `requireComposition` first.
|
|
53
47
|
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Function to resolve the route from the code.
|
|
57
|
-
*/
|
|
58
|
-
resolveRoute: ResolveRouteFunction;
|
|
48
|
+
result: ResolvedRouteResult;
|
|
59
49
|
/**
|
|
60
50
|
* Function to map composition components to React components.
|
|
61
51
|
*/
|
|
62
52
|
resolveComponent: ResolveComponentFunction;
|
|
63
|
-
/**
|
|
64
|
-
* Resolves the route for the code. Defaults to `DefaultDataClient`.
|
|
65
|
-
*/
|
|
66
|
-
dataClient?: DataClient;
|
|
67
53
|
/**
|
|
68
54
|
* Function to map empty placeholders to React components.
|
|
69
55
|
*/
|
|
70
56
|
resolveEmptyPlaceholder?: ResolveEmptyPlaceholderFunction;
|
|
57
|
+
/**
|
|
58
|
+
* Marks the page's primary composition. It sets the composition metadata of the visitor's
|
|
59
|
+
* context, which Uniform Insights attributes page hits and goals to, and the default consent
|
|
60
|
+
* from its page state. In the editor and draft states it also loads the contextual editing
|
|
61
|
+
* script. Set it on one composition per page.
|
|
62
|
+
*/
|
|
63
|
+
pageComposition?: boolean;
|
|
71
64
|
/**
|
|
72
65
|
* Composition cache, will be used to cache the composition.
|
|
73
66
|
*/
|
|
74
67
|
compositionCache?: CompositionCache;
|
|
75
|
-
}
|
|
76
|
-
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Renders a resolved composition, or nothing when the result is a redirect or not found. Render it
|
|
71
|
+
* before the root layout's `UniformContext`, and set `pageComposition` on the page's primary
|
|
72
|
+
* composition.
|
|
73
|
+
*/
|
|
74
|
+
declare function UniformResolvedComposition(props: UniformResolvedCompositionProps): React.JSX.Element;
|
|
77
75
|
|
|
78
|
-
export { type CompositionCache as C, type ResolveComponentResult as R, type
|
|
76
|
+
export { type CompositionCache as C, type ResolveComponentResult as R, type UniformResolvedCompositionProps as U, type ResolveComponentFunction as a, UniformResolvedComposition as b, createCompositionCache as c };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Quirks } from '@uniformdev/context';
|
|
2
|
+
import { UniformServerConfig, RewriteRequestPathResult } from '@uniformdev/next-app-router-shared';
|
|
3
|
+
import { U as UniformEdgeMiddlewareOptions } from './createEdgeRouteStore-DaU9QjP2.mjs';
|
|
4
|
+
export { c as createEdgeRouteStore } from './createEdgeRouteStore-DaU9QjP2.mjs';
|
|
5
|
+
import { HandleOptions } from './middleware.mjs';
|
|
6
|
+
export { U as UNIFORM_EDGE_ORIGIN_HEADER, c as createStaticEdgeRouteFilter, l as learnedEdgeRouteFilter } from './learnedEdgeRouteFilter-DWg-puGg.mjs';
|
|
7
|
+
import 'next/server';
|
|
8
|
+
import './models-kIvBB7Tv.mjs';
|
|
9
|
+
import './createPreviewGETRouteHandler-ii7w-gAc.mjs';
|
|
10
|
+
|
|
11
|
+
/** The request an EdgeWorker event handler of `akamaiUniformEdgeWorker` receives. */
|
|
12
|
+
type AkamaiRequest = EW.IngressClientRequest | EW.ResponseProviderRequest | EW.EgressClientRequest;
|
|
13
|
+
|
|
14
|
+
/** Skips `responseProvider` for the request when `onClientRequest` sets it to `true`. */
|
|
15
|
+
declare const AKAMAI_BYPASS_RESPONSE_PROVIDER_VARIABLE = "PMUSER_BYPASS_EW_RP_EVENT";
|
|
16
|
+
type AkamaiUniformEdgeWorkerOptions = Pick<UniformEdgeMiddlewareOptions, 'manifest' | 'filter' | 'store' | 'etags'> & Pick<HandleOptions, 'rewriteDestinationPath' | 'queryStrings' | 'release' | 'quirks' | 'defaultConsent' | 'locale'> & {
|
|
17
|
+
/**
|
|
18
|
+
* The app's server config, the default export of `uniform.server.config.ts`. Pass the origin's
|
|
19
|
+
* config, so the worker builds the codes and the visitor's Context the way the app does.
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue the default config
|
|
22
|
+
*/
|
|
23
|
+
config?: UniformServerConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the route path, and the keys, to resolve for the request. The path includes the
|
|
26
|
+
* query string.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue the request path and query string
|
|
29
|
+
*/
|
|
30
|
+
rewriteRequestPath?: (options: {
|
|
31
|
+
request: AkamaiRequest;
|
|
32
|
+
path: string;
|
|
33
|
+
query: string;
|
|
34
|
+
}) => Promise<RewriteRequestPathResult | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Builds the quirks the visitor's Context and the browser get from the request. `quirks` are
|
|
37
|
+
* added on top.
|
|
38
|
+
*
|
|
39
|
+
* @defaultValue `buildAkamaiQuirks`, the visitor's Akamai location
|
|
40
|
+
*/
|
|
41
|
+
buildQuirks?: (request: AkamaiRequest) => Quirks;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the worker rewrites the request path. Other requests reach the origin untouched.
|
|
44
|
+
*
|
|
45
|
+
* @defaultValue every path except `/api`, `/_next/static`, `/_next/image`, `/favicon.ico`,
|
|
46
|
+
* `/sitemap.xml` and `/robots.txt`, like the Next.js middleware matcher of the Uniform examples
|
|
47
|
+
*/
|
|
48
|
+
matcher?: (path: string) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Called when the manifest provider throws, when processing fails before the response starts,
|
|
51
|
+
* and when the NESI transform fails. Without it, the last two are logged with the EdgeWorkers
|
|
52
|
+
* `logger`.
|
|
53
|
+
*
|
|
54
|
+
* A provider failure receives the error, and the worker chooses with an empty manifest:
|
|
55
|
+
* personalizations show their defaults, and the browser chooses tests after hydration.
|
|
56
|
+
*
|
|
57
|
+
* A failure before the response starts, such as the `filter` throwing or the fetch of the page
|
|
58
|
+
* failing, receives the error, and the visitor gets the page without edge mode, so the browser
|
|
59
|
+
* chooses the variants.
|
|
60
|
+
*
|
|
61
|
+
* A transform failure also receives the decoded HTML chunk that triggered it, when available,
|
|
62
|
+
* and the response ends at the point of failure.
|
|
63
|
+
*/
|
|
64
|
+
onError?: UniformEdgeMiddlewareOptions['onError'];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Returns the event handlers of an Akamai EdgeWorker in front of a Next.js app that uses Uniform.
|
|
68
|
+
* The worker does what `uniformEdgeMiddleware` does in the app: it rewrites each published route
|
|
69
|
+
* to its `/uniform/{code}` page, and keeps only the visitor's variants of pages in edge mode. Akamai
|
|
70
|
+
* caches each page once for every visitor.
|
|
71
|
+
*
|
|
72
|
+
* - `onClientRequest` rewrites client navigations, prefetches, other methods and pages the
|
|
73
|
+
* `filter` skips with `route()`, and leaves HTML document requests for pages in edge mode to
|
|
74
|
+
* `responseProvider`. Requests in draft mode, paths `matcher` excludes and the worker's own
|
|
75
|
+
* fetches reach the origin untouched, where the app's middleware handles them.
|
|
76
|
+
* - `responseProvider` fetches the page in edge mode through Akamai and streams it through the NESI
|
|
77
|
+
* transform, with the ETags `serveEdgePage` describes.
|
|
78
|
+
* - `onClientResponse` hands the quirks to the browser in the `ufqc` cookie.
|
|
79
|
+
*
|
|
80
|
+
* Export all three from the bundle's `main.js`. The property needs the user-defined variable
|
|
81
|
+
* `PMUSER_BYPASS_EW_RP_EVENT`, with `false` as its initial value, so `onClientRequest` can skip
|
|
82
|
+
* `responseProvider`. The app's middleware lets the rewritten requests through, since they carry
|
|
83
|
+
* `UNIFORM_EDGE_ORIGIN_HEADER`.
|
|
84
|
+
*
|
|
85
|
+
* Mark the EdgeWorkers modules `cookies`, `create-response`, `crypto`, `encoding`, `http-request`,
|
|
86
|
+
* `log`, `streams` and `url-search-params` external in the bundler. `encoding` and `crypto` also
|
|
87
|
+
* name an npm package and a Node module, which do not run on EdgeWorkers.
|
|
88
|
+
*
|
|
89
|
+
* EdgeWorkers has no `waitUntil`, so a `store` write that is still pending when the response ends
|
|
90
|
+
* may be lost. A manifest provider may only fetch from hosts Akamai serves; pass a manifest baked
|
|
91
|
+
* into the bundle to avoid fetching it.
|
|
92
|
+
*/
|
|
93
|
+
declare const akamaiUniformEdgeWorker: ({ config, manifest, filter, store, etags, onError, rewriteRequestPath, rewriteDestinationPath, queryStrings, release, quirks: customQuirks, defaultConsent: defaultConsentOption, locale, buildQuirks, matcher, }: AkamaiUniformEdgeWorkerOptions) => {
|
|
94
|
+
onClientRequest: (request: EW.IngressClientRequest) => Promise<void>;
|
|
95
|
+
responseProvider: (request: EW.ResponseProviderRequest) => Promise<object>;
|
|
96
|
+
onClientResponse: (request: EW.EgressClientRequest, response: EW.EgressClientResponse) => void;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Builds quirks from the visitor's Akamai location, named like those of
|
|
101
|
+
* `@uniformdev/context-edge-akamai`: `aka-loc-continent`, `aka-loc-country`, `aka-loc-region` and
|
|
102
|
+
* `aka-loc-city`. Locations Akamai cannot supply are left out.
|
|
103
|
+
*/
|
|
104
|
+
declare const buildAkamaiQuirks: (request: AkamaiRequest) => Quirks;
|
|
105
|
+
|
|
106
|
+
export { AKAMAI_BYPASS_RESPONSE_PROVIDER_VARIABLE, type AkamaiRequest, type AkamaiUniformEdgeWorkerOptions, akamaiUniformEdgeWorker, buildAkamaiQuirks };
|
package/dist/akamai.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Quirks } from '@uniformdev/context';
|
|
2
|
+
import { UniformServerConfig, RewriteRequestPathResult } from '@uniformdev/next-app-router-shared';
|
|
3
|
+
import { U as UniformEdgeMiddlewareOptions } from './createEdgeRouteStore-B2ugix2E.js';
|
|
4
|
+
export { c as createEdgeRouteStore } from './createEdgeRouteStore-B2ugix2E.js';
|
|
5
|
+
import { HandleOptions } from './middleware.js';
|
|
6
|
+
export { U as UNIFORM_EDGE_ORIGIN_HEADER, c as createStaticEdgeRouteFilter, l as learnedEdgeRouteFilter } from './learnedEdgeRouteFilter-i9hELx_t.js';
|
|
7
|
+
import 'next/server';
|
|
8
|
+
import './models-kIvBB7Tv.js';
|
|
9
|
+
import './createPreviewGETRouteHandler-ii7w-gAc.js';
|
|
10
|
+
|
|
11
|
+
/** The request an EdgeWorker event handler of `akamaiUniformEdgeWorker` receives. */
|
|
12
|
+
type AkamaiRequest = EW.IngressClientRequest | EW.ResponseProviderRequest | EW.EgressClientRequest;
|
|
13
|
+
|
|
14
|
+
/** Skips `responseProvider` for the request when `onClientRequest` sets it to `true`. */
|
|
15
|
+
declare const AKAMAI_BYPASS_RESPONSE_PROVIDER_VARIABLE = "PMUSER_BYPASS_EW_RP_EVENT";
|
|
16
|
+
type AkamaiUniformEdgeWorkerOptions = Pick<UniformEdgeMiddlewareOptions, 'manifest' | 'filter' | 'store' | 'etags'> & Pick<HandleOptions, 'rewriteDestinationPath' | 'queryStrings' | 'release' | 'quirks' | 'defaultConsent' | 'locale'> & {
|
|
17
|
+
/**
|
|
18
|
+
* The app's server config, the default export of `uniform.server.config.ts`. Pass the origin's
|
|
19
|
+
* config, so the worker builds the codes and the visitor's Context the way the app does.
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue the default config
|
|
22
|
+
*/
|
|
23
|
+
config?: UniformServerConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the route path, and the keys, to resolve for the request. The path includes the
|
|
26
|
+
* query string.
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue the request path and query string
|
|
29
|
+
*/
|
|
30
|
+
rewriteRequestPath?: (options: {
|
|
31
|
+
request: AkamaiRequest;
|
|
32
|
+
path: string;
|
|
33
|
+
query: string;
|
|
34
|
+
}) => Promise<RewriteRequestPathResult | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Builds the quirks the visitor's Context and the browser get from the request. `quirks` are
|
|
37
|
+
* added on top.
|
|
38
|
+
*
|
|
39
|
+
* @defaultValue `buildAkamaiQuirks`, the visitor's Akamai location
|
|
40
|
+
*/
|
|
41
|
+
buildQuirks?: (request: AkamaiRequest) => Quirks;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the worker rewrites the request path. Other requests reach the origin untouched.
|
|
44
|
+
*
|
|
45
|
+
* @defaultValue every path except `/api`, `/_next/static`, `/_next/image`, `/favicon.ico`,
|
|
46
|
+
* `/sitemap.xml` and `/robots.txt`, like the Next.js middleware matcher of the Uniform examples
|
|
47
|
+
*/
|
|
48
|
+
matcher?: (path: string) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Called when the manifest provider throws, when processing fails before the response starts,
|
|
51
|
+
* and when the NESI transform fails. Without it, the last two are logged with the EdgeWorkers
|
|
52
|
+
* `logger`.
|
|
53
|
+
*
|
|
54
|
+
* A provider failure receives the error, and the worker chooses with an empty manifest:
|
|
55
|
+
* personalizations show their defaults, and the browser chooses tests after hydration.
|
|
56
|
+
*
|
|
57
|
+
* A failure before the response starts, such as the `filter` throwing or the fetch of the page
|
|
58
|
+
* failing, receives the error, and the visitor gets the page without edge mode, so the browser
|
|
59
|
+
* chooses the variants.
|
|
60
|
+
*
|
|
61
|
+
* A transform failure also receives the decoded HTML chunk that triggered it, when available,
|
|
62
|
+
* and the response ends at the point of failure.
|
|
63
|
+
*/
|
|
64
|
+
onError?: UniformEdgeMiddlewareOptions['onError'];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Returns the event handlers of an Akamai EdgeWorker in front of a Next.js app that uses Uniform.
|
|
68
|
+
* The worker does what `uniformEdgeMiddleware` does in the app: it rewrites each published route
|
|
69
|
+
* to its `/uniform/{code}` page, and keeps only the visitor's variants of pages in edge mode. Akamai
|
|
70
|
+
* caches each page once for every visitor.
|
|
71
|
+
*
|
|
72
|
+
* - `onClientRequest` rewrites client navigations, prefetches, other methods and pages the
|
|
73
|
+
* `filter` skips with `route()`, and leaves HTML document requests for pages in edge mode to
|
|
74
|
+
* `responseProvider`. Requests in draft mode, paths `matcher` excludes and the worker's own
|
|
75
|
+
* fetches reach the origin untouched, where the app's middleware handles them.
|
|
76
|
+
* - `responseProvider` fetches the page in edge mode through Akamai and streams it through the NESI
|
|
77
|
+
* transform, with the ETags `serveEdgePage` describes.
|
|
78
|
+
* - `onClientResponse` hands the quirks to the browser in the `ufqc` cookie.
|
|
79
|
+
*
|
|
80
|
+
* Export all three from the bundle's `main.js`. The property needs the user-defined variable
|
|
81
|
+
* `PMUSER_BYPASS_EW_RP_EVENT`, with `false` as its initial value, so `onClientRequest` can skip
|
|
82
|
+
* `responseProvider`. The app's middleware lets the rewritten requests through, since they carry
|
|
83
|
+
* `UNIFORM_EDGE_ORIGIN_HEADER`.
|
|
84
|
+
*
|
|
85
|
+
* Mark the EdgeWorkers modules `cookies`, `create-response`, `crypto`, `encoding`, `http-request`,
|
|
86
|
+
* `log`, `streams` and `url-search-params` external in the bundler. `encoding` and `crypto` also
|
|
87
|
+
* name an npm package and a Node module, which do not run on EdgeWorkers.
|
|
88
|
+
*
|
|
89
|
+
* EdgeWorkers has no `waitUntil`, so a `store` write that is still pending when the response ends
|
|
90
|
+
* may be lost. A manifest provider may only fetch from hosts Akamai serves; pass a manifest baked
|
|
91
|
+
* into the bundle to avoid fetching it.
|
|
92
|
+
*/
|
|
93
|
+
declare const akamaiUniformEdgeWorker: ({ config, manifest, filter, store, etags, onError, rewriteRequestPath, rewriteDestinationPath, queryStrings, release, quirks: customQuirks, defaultConsent: defaultConsentOption, locale, buildQuirks, matcher, }: AkamaiUniformEdgeWorkerOptions) => {
|
|
94
|
+
onClientRequest: (request: EW.IngressClientRequest) => Promise<void>;
|
|
95
|
+
responseProvider: (request: EW.ResponseProviderRequest) => Promise<object>;
|
|
96
|
+
onClientResponse: (request: EW.EgressClientRequest, response: EW.EgressClientResponse) => void;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Builds quirks from the visitor's Akamai location, named like those of
|
|
101
|
+
* `@uniformdev/context-edge-akamai`: `aka-loc-continent`, `aka-loc-country`, `aka-loc-region` and
|
|
102
|
+
* `aka-loc-city`. Locations Akamai cannot supply are left out.
|
|
103
|
+
*/
|
|
104
|
+
declare const buildAkamaiQuirks: (request: AkamaiRequest) => Quirks;
|
|
105
|
+
|
|
106
|
+
export { AKAMAI_BYPASS_RESPONSE_PROVIDER_VARIABLE, type AkamaiRequest, type AkamaiUniformEdgeWorkerOptions, akamaiUniformEdgeWorker, buildAkamaiQuirks };
|