@uniformdev/next-app-router 20.81.1-alpha.4.sha-de16ebeee7 → 20.81.1
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-T7CRvU1H.d.ts → UniformComposition-DBO-oo7J.d.ts} +8 -2
- package/dist/{UniformComposition-fq7Qfhvp.d.mts → UniformComposition-le6UEB_r.d.mts} +8 -2
- package/dist/cache.d.mts +3 -1
- package/dist/cache.d.ts +3 -1
- package/dist/cache.js +811 -127
- package/dist/cache.mjs +810 -126
- package/dist/client-BElN_CWD.d.mts +786 -0
- package/dist/client-BElN_CWD.d.ts +786 -0
- package/dist/compat.d.mts +4 -2
- package/dist/compat.d.ts +4 -2
- package/dist/component.d.mts +1 -10
- package/dist/component.d.ts +1 -10
- package/dist/component.js +617 -113
- package/dist/component.mjs +640 -112
- package/dist/config/default.js +1 -0
- package/dist/config/default.mjs +1 -0
- package/dist/handler.js +616 -87
- package/dist/handler.mjs +614 -85
- package/dist/index.d.mts +36 -15
- package/dist/index.d.ts +36 -15
- package/dist/index.esm.js +5825 -2175
- package/dist/index.js +5839 -2189
- package/dist/index.mjs +5825 -2175
- package/dist/middleware.d.mts +13 -52
- package/dist/middleware.d.ts +13 -52
- package/dist/middleware.js +5741 -405
- package/dist/middleware.mjs +5774 -415
- package/dist/resolveRouteFromCode-BOvjIvM2.d.ts +18 -0
- package/dist/resolveRouteFromCode-CuJ4JHeb.d.mts +18 -0
- package/package.json +9 -24
- package/dist/edge.d.mts +0 -44
- package/dist/edge.d.ts +0 -44
- package/dist/edge.js +0 -751
- package/dist/edge.mjs +0 -720
- package/dist/resolveRouteFromCode-CId7aItt.d.mts +0 -48
- package/dist/resolveRouteFromCode-CId7aItt.d.ts +0 -48
package/dist/middleware.d.mts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { Quirks
|
|
1
|
+
import { Quirks } from '@uniformdev/context';
|
|
2
2
|
import { RewriteRequestPathResult, PageState } from '@uniformdev/next-app-router-shared';
|
|
3
3
|
import { NextRequest, NextResponse } from 'next/server';
|
|
4
|
+
import { D as DataClient } from './client-BElN_CWD.mjs';
|
|
5
|
+
import '@uniformdev/canvas';
|
|
4
6
|
|
|
5
7
|
type RewriteOptions = {
|
|
6
8
|
source: 'route' | 'playground';
|
|
7
9
|
/**
|
|
8
|
-
* The code
|
|
10
|
+
* The code that was generated from the evaluated composition.
|
|
9
11
|
*/
|
|
10
12
|
code: string;
|
|
11
13
|
/**
|
|
12
|
-
* The page state the
|
|
14
|
+
* The page state that was generated from the evaluated composition.
|
|
13
15
|
*/
|
|
14
16
|
pageState: PageState;
|
|
15
17
|
};
|
|
@@ -30,12 +32,13 @@ type HandleOptions = {
|
|
|
30
32
|
*/
|
|
31
33
|
rewriteDestinationPath?: (options: RewriteOptions) => Promise<string>;
|
|
32
34
|
/**
|
|
33
|
-
*
|
|
34
|
-
* `{ '/products/:slug': ['color'] }`. The page resolves the route from the route path, so list
|
|
35
|
-
* the query strings your project map nodes declare. Other query strings are left out of the
|
|
36
|
-
* code, so marketing parameters like `utm_campaign` do not create a page per value.
|
|
35
|
+
* If provided, the middleware will only precompute the runnables for the paths that match the patterns.
|
|
37
36
|
*/
|
|
38
|
-
|
|
37
|
+
pathPatternsWithVariations?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* If provided, the middleware will use the data client to retrieve data.
|
|
40
|
+
*/
|
|
41
|
+
dataClient?: DataClient;
|
|
39
42
|
/**
|
|
40
43
|
* Release ID to resolve the route from.
|
|
41
44
|
*/
|
|
@@ -59,55 +62,13 @@ type HandleOptions = {
|
|
|
59
62
|
*/
|
|
60
63
|
locale?: string;
|
|
61
64
|
};
|
|
62
|
-
type ResolveUniformRequestOptions = HandleOptions & {
|
|
63
|
-
request: NextRequest;
|
|
64
|
-
};
|
|
65
|
-
type ResolveUniformRequestResult = {
|
|
66
|
-
/** The request is answered directly, such as a playground request without an id. */
|
|
67
|
-
type: 'response';
|
|
68
|
-
response: NextResponse;
|
|
69
|
-
} | {
|
|
70
|
-
/** The request should be rewritten to `destination`. */
|
|
71
|
-
type: 'rewrite';
|
|
72
|
-
/** Path to rewrite to, relative to the request origin, for example `/uniform/{code}`. */
|
|
73
|
-
destination: string;
|
|
74
|
-
pageState: PageState;
|
|
75
|
-
/** The serialized page state, the `[code]` path segment. */
|
|
76
|
-
code: string;
|
|
77
|
-
/** Headers to add to the response, such as the `ufqc` quirk cookie. */
|
|
78
|
-
headers: Headers;
|
|
79
|
-
/** Whether Next.js draft mode is on for this request. */
|
|
80
|
-
draftModeEnabled: boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Creates the visitor's Context from the given manifest, updated with the request URL,
|
|
83
|
-
* cookies and quirks.
|
|
84
|
-
*/
|
|
85
|
-
createContext: (options: {
|
|
86
|
-
manifest: ManifestV2;
|
|
87
|
-
}) => Promise<Context>;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Returns middleware that rewrites each request to `/uniform/{code}`, where the page resolves the
|
|
91
|
-
* route. Personalizations, tests and visibility rules are evaluated in the browser.
|
|
92
|
-
*/
|
|
93
65
|
declare const uniformMiddleware: (options?: HandleOptions) => (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
94
|
-
|
|
95
|
-
* Rewrites the request to the page for its code, or answers it directly when
|
|
96
|
-
* {@link resolveUniformRequest} returns a response.
|
|
97
|
-
*/
|
|
98
|
-
declare const handleUniformRoute: (options: HandleOptions & {
|
|
66
|
+
declare const handleUniformRoute: ({ request, dataClient, ...options }: HandleOptions & {
|
|
99
67
|
request: NextRequest;
|
|
100
68
|
}) => Promise<NextResponse<unknown>>;
|
|
101
|
-
/**
|
|
102
|
-
* Builds the code for the request without producing the final response, so other middleware
|
|
103
|
-
* (such as the edge middleware) can decide how to serve the rewrite. Makes no network requests:
|
|
104
|
-
* the code carries the route path and state, and the page resolves the route, including redirects
|
|
105
|
-
* and not found. Every visitor of a route gets the same code.
|
|
106
|
-
*/
|
|
107
|
-
declare const resolveUniformRequest: ({ request, ...options }: ResolveUniformRequestOptions) => Promise<ResolveUniformRequestResult>;
|
|
108
69
|
declare const determinePreviewMode: ({ searchParams, isDraftModeEnabled, }: {
|
|
109
70
|
searchParams: URLSearchParams;
|
|
110
71
|
isDraftModeEnabled: boolean;
|
|
111
72
|
}) => "preview" | "editor" | undefined;
|
|
112
73
|
|
|
113
|
-
export { type HandleOptions, type RequestInfo, type
|
|
74
|
+
export { type HandleOptions, type RequestInfo, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, uniformMiddleware };
|
package/dist/middleware.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { Quirks
|
|
1
|
+
import { Quirks } from '@uniformdev/context';
|
|
2
2
|
import { RewriteRequestPathResult, PageState } from '@uniformdev/next-app-router-shared';
|
|
3
3
|
import { NextRequest, NextResponse } from 'next/server';
|
|
4
|
+
import { D as DataClient } from './client-BElN_CWD.js';
|
|
5
|
+
import '@uniformdev/canvas';
|
|
4
6
|
|
|
5
7
|
type RewriteOptions = {
|
|
6
8
|
source: 'route' | 'playground';
|
|
7
9
|
/**
|
|
8
|
-
* The code
|
|
10
|
+
* The code that was generated from the evaluated composition.
|
|
9
11
|
*/
|
|
10
12
|
code: string;
|
|
11
13
|
/**
|
|
12
|
-
* The page state the
|
|
14
|
+
* The page state that was generated from the evaluated composition.
|
|
13
15
|
*/
|
|
14
16
|
pageState: PageState;
|
|
15
17
|
};
|
|
@@ -30,12 +32,13 @@ type HandleOptions = {
|
|
|
30
32
|
*/
|
|
31
33
|
rewriteDestinationPath?: (options: RewriteOptions) => Promise<string>;
|
|
32
34
|
/**
|
|
33
|
-
*
|
|
34
|
-
* `{ '/products/:slug': ['color'] }`. The page resolves the route from the route path, so list
|
|
35
|
-
* the query strings your project map nodes declare. Other query strings are left out of the
|
|
36
|
-
* code, so marketing parameters like `utm_campaign` do not create a page per value.
|
|
35
|
+
* If provided, the middleware will only precompute the runnables for the paths that match the patterns.
|
|
37
36
|
*/
|
|
38
|
-
|
|
37
|
+
pathPatternsWithVariations?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* If provided, the middleware will use the data client to retrieve data.
|
|
40
|
+
*/
|
|
41
|
+
dataClient?: DataClient;
|
|
39
42
|
/**
|
|
40
43
|
* Release ID to resolve the route from.
|
|
41
44
|
*/
|
|
@@ -59,55 +62,13 @@ type HandleOptions = {
|
|
|
59
62
|
*/
|
|
60
63
|
locale?: string;
|
|
61
64
|
};
|
|
62
|
-
type ResolveUniformRequestOptions = HandleOptions & {
|
|
63
|
-
request: NextRequest;
|
|
64
|
-
};
|
|
65
|
-
type ResolveUniformRequestResult = {
|
|
66
|
-
/** The request is answered directly, such as a playground request without an id. */
|
|
67
|
-
type: 'response';
|
|
68
|
-
response: NextResponse;
|
|
69
|
-
} | {
|
|
70
|
-
/** The request should be rewritten to `destination`. */
|
|
71
|
-
type: 'rewrite';
|
|
72
|
-
/** Path to rewrite to, relative to the request origin, for example `/uniform/{code}`. */
|
|
73
|
-
destination: string;
|
|
74
|
-
pageState: PageState;
|
|
75
|
-
/** The serialized page state, the `[code]` path segment. */
|
|
76
|
-
code: string;
|
|
77
|
-
/** Headers to add to the response, such as the `ufqc` quirk cookie. */
|
|
78
|
-
headers: Headers;
|
|
79
|
-
/** Whether Next.js draft mode is on for this request. */
|
|
80
|
-
draftModeEnabled: boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Creates the visitor's Context from the given manifest, updated with the request URL,
|
|
83
|
-
* cookies and quirks.
|
|
84
|
-
*/
|
|
85
|
-
createContext: (options: {
|
|
86
|
-
manifest: ManifestV2;
|
|
87
|
-
}) => Promise<Context>;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Returns middleware that rewrites each request to `/uniform/{code}`, where the page resolves the
|
|
91
|
-
* route. Personalizations, tests and visibility rules are evaluated in the browser.
|
|
92
|
-
*/
|
|
93
65
|
declare const uniformMiddleware: (options?: HandleOptions) => (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
94
|
-
|
|
95
|
-
* Rewrites the request to the page for its code, or answers it directly when
|
|
96
|
-
* {@link resolveUniformRequest} returns a response.
|
|
97
|
-
*/
|
|
98
|
-
declare const handleUniformRoute: (options: HandleOptions & {
|
|
66
|
+
declare const handleUniformRoute: ({ request, dataClient, ...options }: HandleOptions & {
|
|
99
67
|
request: NextRequest;
|
|
100
68
|
}) => Promise<NextResponse<unknown>>;
|
|
101
|
-
/**
|
|
102
|
-
* Builds the code for the request without producing the final response, so other middleware
|
|
103
|
-
* (such as the edge middleware) can decide how to serve the rewrite. Makes no network requests:
|
|
104
|
-
* the code carries the route path and state, and the page resolves the route, including redirects
|
|
105
|
-
* and not found. Every visitor of a route gets the same code.
|
|
106
|
-
*/
|
|
107
|
-
declare const resolveUniformRequest: ({ request, ...options }: ResolveUniformRequestOptions) => Promise<ResolveUniformRequestResult>;
|
|
108
69
|
declare const determinePreviewMode: ({ searchParams, isDraftModeEnabled, }: {
|
|
109
70
|
searchParams: URLSearchParams;
|
|
110
71
|
isDraftModeEnabled: boolean;
|
|
111
72
|
}) => "preview" | "editor" | undefined;
|
|
112
73
|
|
|
113
|
-
export { type HandleOptions, type RequestInfo, type
|
|
74
|
+
export { type HandleOptions, type RequestInfo, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, uniformMiddleware };
|