@uniformdev/next-app-router 20.81.0 → 20.81.1-alpha.7.sha-91a5b13e0c
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-C00_YDOg.d.ts} +11 -31
- package/dist/{UniformComposition-le6UEB_r.d.mts → UniformComposition-DiArCpVQ.d.mts} +11 -31
- package/dist/cache.d.mts +24 -6
- package/dist/cache.d.ts +24 -6
- package/dist/cache.js +410 -831
- package/dist/cache.mjs +405 -829
- 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-BvOM-LIW.d.mts +28 -0
- package/dist/composition-BvOM-LIW.d.ts +28 -0
- package/dist/config/default.js +0 -1
- package/dist/config/default.mjs +0 -1
- package/dist/createCachedManifestProvider-C7faGJJ8.d.mts +69 -0
- package/dist/createCachedManifestProvider-C7faGJJ8.d.ts +69 -0
- package/dist/edge.d.mts +57 -0
- package/dist/edge.d.ts +57 -0
- package/dist/edge.js +1105 -0
- package/dist/edge.mjs +1073 -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 +73 -42
- package/dist/index.d.ts +73 -42
- package/dist/index.esm.js +2032 -5629
- package/dist/index.js +2068 -5661
- package/dist/index.mjs +2032 -5629
- package/dist/middleware.d.mts +52 -13
- package/dist/middleware.d.ts +52 -13
- package/dist/middleware.js +410 -5746
- package/dist/middleware.mjs +417 -5776
- package/dist/resolveRouteFromPath-BHJGOpBN.d.ts +82 -0
- package/dist/resolveRouteFromPath-BsZUVkRX.d.mts +82 -0
- package/dist/vercel.d.mts +24 -0
- package/dist/vercel.d.ts +24 -0
- package/dist/vercel.js +703 -0
- package/dist/vercel.mjs +675 -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
package/dist/middleware.d.mts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { Quirks } from '@uniformdev/context';
|
|
1
|
+
import { Quirks, ManifestV2, Context } 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';
|
|
6
4
|
|
|
7
5
|
type RewriteOptions = {
|
|
8
6
|
source: 'route' | 'playground';
|
|
9
7
|
/**
|
|
10
|
-
* The code
|
|
8
|
+
* The code the middleware generated for the request.
|
|
11
9
|
*/
|
|
12
10
|
code: string;
|
|
13
11
|
/**
|
|
14
|
-
* The page state
|
|
12
|
+
* The page state the code serializes.
|
|
15
13
|
*/
|
|
16
14
|
pageState: PageState;
|
|
17
15
|
};
|
|
@@ -32,13 +30,12 @@ type HandleOptions = {
|
|
|
32
30
|
*/
|
|
33
31
|
rewriteDestinationPath?: (options: RewriteOptions) => Promise<string>;
|
|
34
32
|
/**
|
|
35
|
-
*
|
|
33
|
+
* Query strings that belong in the route path, keyed by path pattern, for example
|
|
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.
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* If provided, the middleware will use the data client to retrieve data.
|
|
40
|
-
*/
|
|
41
|
-
dataClient?: DataClient;
|
|
38
|
+
queryStrings?: Record<string, string[]>;
|
|
42
39
|
/**
|
|
43
40
|
* Release ID to resolve the route from.
|
|
44
41
|
*/
|
|
@@ -62,13 +59,55 @@ type HandleOptions = {
|
|
|
62
59
|
*/
|
|
63
60
|
locale?: string;
|
|
64
61
|
};
|
|
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
|
+
*/
|
|
65
93
|
declare const uniformMiddleware: (options?: HandleOptions) => (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
66
|
-
|
|
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 & {
|
|
67
99
|
request: NextRequest;
|
|
68
100
|
}) => 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>;
|
|
69
108
|
declare const determinePreviewMode: ({ searchParams, isDraftModeEnabled, }: {
|
|
70
109
|
searchParams: URLSearchParams;
|
|
71
110
|
isDraftModeEnabled: boolean;
|
|
72
111
|
}) => "preview" | "editor" | undefined;
|
|
73
112
|
|
|
74
|
-
export { type HandleOptions, type RequestInfo, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, uniformMiddleware };
|
|
113
|
+
export { type HandleOptions, type RequestInfo, type ResolveUniformRequestOptions, type ResolveUniformRequestResult, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, resolveUniformRequest, uniformMiddleware };
|
package/dist/middleware.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { Quirks } from '@uniformdev/context';
|
|
1
|
+
import { Quirks, ManifestV2, Context } 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';
|
|
6
4
|
|
|
7
5
|
type RewriteOptions = {
|
|
8
6
|
source: 'route' | 'playground';
|
|
9
7
|
/**
|
|
10
|
-
* The code
|
|
8
|
+
* The code the middleware generated for the request.
|
|
11
9
|
*/
|
|
12
10
|
code: string;
|
|
13
11
|
/**
|
|
14
|
-
* The page state
|
|
12
|
+
* The page state the code serializes.
|
|
15
13
|
*/
|
|
16
14
|
pageState: PageState;
|
|
17
15
|
};
|
|
@@ -32,13 +30,12 @@ type HandleOptions = {
|
|
|
32
30
|
*/
|
|
33
31
|
rewriteDestinationPath?: (options: RewriteOptions) => Promise<string>;
|
|
34
32
|
/**
|
|
35
|
-
*
|
|
33
|
+
* Query strings that belong in the route path, keyed by path pattern, for example
|
|
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.
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* If provided, the middleware will use the data client to retrieve data.
|
|
40
|
-
*/
|
|
41
|
-
dataClient?: DataClient;
|
|
38
|
+
queryStrings?: Record<string, string[]>;
|
|
42
39
|
/**
|
|
43
40
|
* Release ID to resolve the route from.
|
|
44
41
|
*/
|
|
@@ -62,13 +59,55 @@ type HandleOptions = {
|
|
|
62
59
|
*/
|
|
63
60
|
locale?: string;
|
|
64
61
|
};
|
|
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
|
+
*/
|
|
65
93
|
declare const uniformMiddleware: (options?: HandleOptions) => (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
66
|
-
|
|
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 & {
|
|
67
99
|
request: NextRequest;
|
|
68
100
|
}) => 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>;
|
|
69
108
|
declare const determinePreviewMode: ({ searchParams, isDraftModeEnabled, }: {
|
|
70
109
|
searchParams: URLSearchParams;
|
|
71
110
|
isDraftModeEnabled: boolean;
|
|
72
111
|
}) => "preview" | "editor" | undefined;
|
|
73
112
|
|
|
74
|
-
export { type HandleOptions, type RequestInfo, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, uniformMiddleware };
|
|
113
|
+
export { type HandleOptions, type RequestInfo, type ResolveUniformRequestOptions, type ResolveUniformRequestResult, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, resolveUniformRequest, uniformMiddleware };
|