@uniformdev/next-app-router 20.80.2 → 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.
Files changed (48) hide show
  1. package/dist/{UniformComposition-DBO-oo7J.d.ts → UniformComposition-ChDH4dMd.d.ts} +12 -31
  2. package/dist/{UniformComposition-le6UEB_r.d.mts → UniformComposition-Doa1kKRm.d.mts} +12 -31
  3. package/dist/cache.d.mts +24 -6
  4. package/dist/cache.d.ts +24 -6
  5. package/dist/cache.js +396 -832
  6. package/dist/cache.mjs +391 -830
  7. package/dist/compat.d.mts +2 -4
  8. package/dist/compat.d.ts +2 -4
  9. package/dist/component.d.mts +10 -1
  10. package/dist/component.d.ts +10 -1
  11. package/dist/component.js +113 -617
  12. package/dist/component.mjs +112 -640
  13. package/dist/composition-CGU7iH-k.d.mts +37 -0
  14. package/dist/composition-CGU7iH-k.d.ts +37 -0
  15. package/dist/config/default.js +0 -1
  16. package/dist/config/default.mjs +0 -1
  17. package/dist/createCachedManifestProvider-2-2u3PYd.d.mts +84 -0
  18. package/dist/createCachedManifestProvider-BoorKD15.d.ts +84 -0
  19. package/dist/edge.d.mts +80 -0
  20. package/dist/edge.d.ts +80 -0
  21. package/dist/edge.js +1225 -0
  22. package/dist/edge.mjs +1191 -0
  23. package/dist/handler.d.mts +15 -2
  24. package/dist/handler.d.ts +15 -2
  25. package/dist/handler.js +134 -628
  26. package/dist/handler.mjs +132 -626
  27. package/dist/index.d.mts +81 -41
  28. package/dist/index.d.ts +81 -41
  29. package/dist/index.esm.js +2051 -5614
  30. package/dist/index.js +2092 -5651
  31. package/dist/index.mjs +2051 -5614
  32. package/dist/middleware.d.mts +60 -13
  33. package/dist/middleware.d.ts +60 -13
  34. package/dist/middleware.js +415 -5746
  35. package/dist/middleware.mjs +422 -5776
  36. package/dist/models-C8OdCO44.d.mts +72 -0
  37. package/dist/models-C8OdCO44.d.ts +72 -0
  38. package/dist/resolveRouteFromPath-CnfnaxY2.d.ts +80 -0
  39. package/dist/resolveRouteFromPath-_rauUskz.d.mts +80 -0
  40. package/dist/vercel.d.mts +37 -0
  41. package/dist/vercel.d.ts +37 -0
  42. package/dist/vercel.js +788 -0
  43. package/dist/vercel.mjs +759 -0
  44. package/package.json +37 -9
  45. package/dist/client-BElN_CWD.d.mts +0 -786
  46. package/dist/client-BElN_CWD.d.ts +0 -786
  47. package/dist/resolveRouteFromCode-BOvjIvM2.d.ts +0 -18
  48. package/dist/resolveRouteFromCode-CuJ4JHeb.d.mts +0 -18
@@ -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 that was generated from the evaluated composition.
8
+ * The code the middleware generated for the request.
11
9
  */
12
10
  code: string;
13
11
  /**
14
- * The page state that was generated from the evaluated composition.
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
- * If provided, the middleware will only precompute the runnables for the paths that match the patterns.
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
- pathPatternsWithVariations?: string[];
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,63 @@ type HandleOptions = {
62
59
  */
63
60
  locale?: string;
64
61
  };
62
+ type ResolveUniformRequestOptions = HandleOptions & {
63
+ request: NextRequest;
64
+ /**
65
+ * Decides whether a published page renders its personalizations and tests for the edge to
66
+ * choose from. The answer is stored as `edgeMode` in the page state before the code is built.
67
+ * Not called for draft requests, which never use edge mode.
68
+ */
69
+ edgeMode?: (options: {
70
+ pageState: PageState;
71
+ }) => boolean | Promise<boolean>;
72
+ };
73
+ type ResolveUniformRequestResult = {
74
+ /** The request is answered directly, such as a playground request without an id. */
75
+ type: 'response';
76
+ response: NextResponse;
77
+ } | {
78
+ /** The request should be rewritten to `destination`. */
79
+ type: 'rewrite';
80
+ /** Path to rewrite to, relative to the request origin, for example `/uniform/{code}`. */
81
+ destination: string;
82
+ pageState: PageState;
83
+ /** The serialized page state, the `[code]` path segment. */
84
+ code: string;
85
+ /** Headers to add to the response, such as the `ufqc` quirk cookie. */
86
+ headers: Headers;
87
+ /** Whether Next.js draft mode is on for this request. */
88
+ draftModeEnabled: boolean;
89
+ /**
90
+ * Creates the visitor's Context from the given manifest, updated with the request URL,
91
+ * cookies and quirks.
92
+ */
93
+ createContext: (options: {
94
+ manifest: ManifestV2;
95
+ }) => Promise<Context>;
96
+ };
97
+ /**
98
+ * Returns middleware that rewrites each request to `/uniform/{code}`, where the page resolves the
99
+ * route. Personalizations, tests and visibility rules are evaluated in the browser.
100
+ */
65
101
  declare const uniformMiddleware: (options?: HandleOptions) => (request: NextRequest) => Promise<NextResponse<unknown>>;
66
- declare const handleUniformRoute: ({ request, dataClient, ...options }: HandleOptions & {
102
+ /**
103
+ * Rewrites the request to the page for its code, or answers it directly when
104
+ * {@link resolveUniformRequest} returns a response.
105
+ */
106
+ declare const handleUniformRoute: (options: HandleOptions & {
67
107
  request: NextRequest;
68
108
  }) => Promise<NextResponse<unknown>>;
109
+ /**
110
+ * Builds the code for the request without producing the final response, so other middleware
111
+ * (such as the edge middleware) can decide how to serve the rewrite. Makes no network requests:
112
+ * the code carries the route path and state, and the page resolves the route, including redirects
113
+ * and not found. Every visitor of a route gets the same code.
114
+ */
115
+ declare const resolveUniformRequest: ({ request, edgeMode, ...options }: ResolveUniformRequestOptions) => Promise<ResolveUniformRequestResult>;
69
116
  declare const determinePreviewMode: ({ searchParams, isDraftModeEnabled, }: {
70
117
  searchParams: URLSearchParams;
71
118
  isDraftModeEnabled: boolean;
72
119
  }) => "preview" | "editor" | undefined;
73
120
 
74
- export { type HandleOptions, type RequestInfo, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, uniformMiddleware };
121
+ export { type HandleOptions, type RequestInfo, type ResolveUniformRequestOptions, type ResolveUniformRequestResult, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, resolveUniformRequest, uniformMiddleware };
@@ -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 that was generated from the evaluated composition.
8
+ * The code the middleware generated for the request.
11
9
  */
12
10
  code: string;
13
11
  /**
14
- * The page state that was generated from the evaluated composition.
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
- * If provided, the middleware will only precompute the runnables for the paths that match the patterns.
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
- pathPatternsWithVariations?: string[];
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,63 @@ type HandleOptions = {
62
59
  */
63
60
  locale?: string;
64
61
  };
62
+ type ResolveUniformRequestOptions = HandleOptions & {
63
+ request: NextRequest;
64
+ /**
65
+ * Decides whether a published page renders its personalizations and tests for the edge to
66
+ * choose from. The answer is stored as `edgeMode` in the page state before the code is built.
67
+ * Not called for draft requests, which never use edge mode.
68
+ */
69
+ edgeMode?: (options: {
70
+ pageState: PageState;
71
+ }) => boolean | Promise<boolean>;
72
+ };
73
+ type ResolveUniformRequestResult = {
74
+ /** The request is answered directly, such as a playground request without an id. */
75
+ type: 'response';
76
+ response: NextResponse;
77
+ } | {
78
+ /** The request should be rewritten to `destination`. */
79
+ type: 'rewrite';
80
+ /** Path to rewrite to, relative to the request origin, for example `/uniform/{code}`. */
81
+ destination: string;
82
+ pageState: PageState;
83
+ /** The serialized page state, the `[code]` path segment. */
84
+ code: string;
85
+ /** Headers to add to the response, such as the `ufqc` quirk cookie. */
86
+ headers: Headers;
87
+ /** Whether Next.js draft mode is on for this request. */
88
+ draftModeEnabled: boolean;
89
+ /**
90
+ * Creates the visitor's Context from the given manifest, updated with the request URL,
91
+ * cookies and quirks.
92
+ */
93
+ createContext: (options: {
94
+ manifest: ManifestV2;
95
+ }) => Promise<Context>;
96
+ };
97
+ /**
98
+ * Returns middleware that rewrites each request to `/uniform/{code}`, where the page resolves the
99
+ * route. Personalizations, tests and visibility rules are evaluated in the browser.
100
+ */
65
101
  declare const uniformMiddleware: (options?: HandleOptions) => (request: NextRequest) => Promise<NextResponse<unknown>>;
66
- declare const handleUniformRoute: ({ request, dataClient, ...options }: HandleOptions & {
102
+ /**
103
+ * Rewrites the request to the page for its code, or answers it directly when
104
+ * {@link resolveUniformRequest} returns a response.
105
+ */
106
+ declare const handleUniformRoute: (options: HandleOptions & {
67
107
  request: NextRequest;
68
108
  }) => Promise<NextResponse<unknown>>;
109
+ /**
110
+ * Builds the code for the request without producing the final response, so other middleware
111
+ * (such as the edge middleware) can decide how to serve the rewrite. Makes no network requests:
112
+ * the code carries the route path and state, and the page resolves the route, including redirects
113
+ * and not found. Every visitor of a route gets the same code.
114
+ */
115
+ declare const resolveUniformRequest: ({ request, edgeMode, ...options }: ResolveUniformRequestOptions) => Promise<ResolveUniformRequestResult>;
69
116
  declare const determinePreviewMode: ({ searchParams, isDraftModeEnabled, }: {
70
117
  searchParams: URLSearchParams;
71
118
  isDraftModeEnabled: boolean;
72
119
  }) => "preview" | "editor" | undefined;
73
120
 
74
- export { type HandleOptions, type RequestInfo, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, uniformMiddleware };
121
+ export { type HandleOptions, type RequestInfo, type ResolveUniformRequestOptions, type ResolveUniformRequestResult, type RewriteOptions, type RewriteRequestPathOptions, determinePreviewMode, handleUniformRoute, resolveUniformRequest, uniformMiddleware };