@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
@@ -0,0 +1,72 @@
1
+ import { PageState } from '@uniformdev/next-app-router-shared';
2
+ import { ManifestV2 } from '@uniformdev/context';
3
+
4
+ type ManifestProviderOptions = {
5
+ /**
6
+ * Extends the request's lifetime until the promise settles, for work like writing the manifest
7
+ * to a cache after the response is sent. The edge middleware passes the proxy's
8
+ * `event.waitUntil`.
9
+ */
10
+ waitUntil: (promise: Promise<unknown>) => void;
11
+ };
12
+ /**
13
+ * Loads the Context manifest the edge middleware chooses variants with. Called once per HTML
14
+ * document request. Resolves to the manifest or throws.
15
+ */
16
+ type ManifestProvider = (options: ManifestProviderOptions) => Promise<ManifestV2>;
17
+ /**
18
+ * A platform's shared cache, which a cached manifest provider stores the manifest in between
19
+ * instances. Vercel's runtime cache from `getCache()` in `@vercel/functions` matches this shape.
20
+ */
21
+ type ManifestCache = {
22
+ /** Resolves to the stored value, or `null` or `undefined` when there is none. */
23
+ get: (key: string) => Promise<unknown>;
24
+ set: (key: string, value: ManifestV2, options: {
25
+ ttl: number;
26
+ tags: string[];
27
+ }) => Promise<void>;
28
+ };
29
+
30
+ type EdgeRouteFilterOptions = {
31
+ /** The page state of the published request, before `edgeMode` is set on it. */
32
+ pageState: PageState;
33
+ /**
34
+ * Extends the request's lifetime until the promise settles, for work like writing to a cache
35
+ * after the response is sent. The edge middleware passes the proxy's `event.waitUntil`.
36
+ */
37
+ waitUntil: ManifestProviderOptions['waitUntil'];
38
+ };
39
+ /**
40
+ * Decides which published pages `uniformEdgeMiddleware` fetches and transforms at the edge. A page
41
+ * the filter skips is rewritten to its code without `edgeMode`, so it stays cacheable by the CDN
42
+ * and its personalizations and tests are chosen in the browser.
43
+ */
44
+ type EdgeRouteFilter = {
45
+ /** Whether the page may contain personalization or test placements to process at the edge. */
46
+ shouldProcess: (options: EdgeRouteFilterOptions) => boolean | Promise<boolean>;
47
+ /**
48
+ * Called after the edge middleware transformed a page that answered 200, with whether the page
49
+ * contained placements. Not called when the transform failed or the visitor disconnected.
50
+ */
51
+ observe?: (options: EdgeRouteFilterOptions & {
52
+ hasPlacements: boolean;
53
+ }) => void;
54
+ };
55
+ /** What a learned edge route filter remembers about a page. */
56
+ type EdgeRouteRecord = {
57
+ hasPlacements: boolean;
58
+ };
59
+ /**
60
+ * A platform's shared cache, which a learned edge route filter stores its records in between
61
+ * instances. Vercel's runtime cache from `getCache()` in `@vercel/functions` matches this shape.
62
+ */
63
+ type EdgeRouteFilterCache = {
64
+ /** Resolves to the stored value, or `null` or `undefined` when there is none. */
65
+ get: (key: string) => Promise<unknown>;
66
+ set: (key: string, value: EdgeRouteRecord, options: {
67
+ ttl: number;
68
+ tags: string[];
69
+ }) => Promise<void>;
70
+ };
71
+
72
+ export type { EdgeRouteFilter as E, ManifestProvider as M, ManifestProviderOptions as a, EdgeRouteFilterCache as b, EdgeRouteFilterOptions as c, EdgeRouteRecord as d, ManifestCache as e };
@@ -0,0 +1,72 @@
1
+ import { PageState } from '@uniformdev/next-app-router-shared';
2
+ import { ManifestV2 } from '@uniformdev/context';
3
+
4
+ type ManifestProviderOptions = {
5
+ /**
6
+ * Extends the request's lifetime until the promise settles, for work like writing the manifest
7
+ * to a cache after the response is sent. The edge middleware passes the proxy's
8
+ * `event.waitUntil`.
9
+ */
10
+ waitUntil: (promise: Promise<unknown>) => void;
11
+ };
12
+ /**
13
+ * Loads the Context manifest the edge middleware chooses variants with. Called once per HTML
14
+ * document request. Resolves to the manifest or throws.
15
+ */
16
+ type ManifestProvider = (options: ManifestProviderOptions) => Promise<ManifestV2>;
17
+ /**
18
+ * A platform's shared cache, which a cached manifest provider stores the manifest in between
19
+ * instances. Vercel's runtime cache from `getCache()` in `@vercel/functions` matches this shape.
20
+ */
21
+ type ManifestCache = {
22
+ /** Resolves to the stored value, or `null` or `undefined` when there is none. */
23
+ get: (key: string) => Promise<unknown>;
24
+ set: (key: string, value: ManifestV2, options: {
25
+ ttl: number;
26
+ tags: string[];
27
+ }) => Promise<void>;
28
+ };
29
+
30
+ type EdgeRouteFilterOptions = {
31
+ /** The page state of the published request, before `edgeMode` is set on it. */
32
+ pageState: PageState;
33
+ /**
34
+ * Extends the request's lifetime until the promise settles, for work like writing to a cache
35
+ * after the response is sent. The edge middleware passes the proxy's `event.waitUntil`.
36
+ */
37
+ waitUntil: ManifestProviderOptions['waitUntil'];
38
+ };
39
+ /**
40
+ * Decides which published pages `uniformEdgeMiddleware` fetches and transforms at the edge. A page
41
+ * the filter skips is rewritten to its code without `edgeMode`, so it stays cacheable by the CDN
42
+ * and its personalizations and tests are chosen in the browser.
43
+ */
44
+ type EdgeRouteFilter = {
45
+ /** Whether the page may contain personalization or test placements to process at the edge. */
46
+ shouldProcess: (options: EdgeRouteFilterOptions) => boolean | Promise<boolean>;
47
+ /**
48
+ * Called after the edge middleware transformed a page that answered 200, with whether the page
49
+ * contained placements. Not called when the transform failed or the visitor disconnected.
50
+ */
51
+ observe?: (options: EdgeRouteFilterOptions & {
52
+ hasPlacements: boolean;
53
+ }) => void;
54
+ };
55
+ /** What a learned edge route filter remembers about a page. */
56
+ type EdgeRouteRecord = {
57
+ hasPlacements: boolean;
58
+ };
59
+ /**
60
+ * A platform's shared cache, which a learned edge route filter stores its records in between
61
+ * instances. Vercel's runtime cache from `getCache()` in `@vercel/functions` matches this shape.
62
+ */
63
+ type EdgeRouteFilterCache = {
64
+ /** Resolves to the stored value, or `null` or `undefined` when there is none. */
65
+ get: (key: string) => Promise<unknown>;
66
+ set: (key: string, value: EdgeRouteRecord, options: {
67
+ ttl: number;
68
+ tags: string[];
69
+ }) => Promise<void>;
70
+ };
71
+
72
+ export type { EdgeRouteFilter as E, ManifestProvider as M, ManifestProviderOptions as a, EdgeRouteFilterCache as b, EdgeRouteFilterOptions as c, EdgeRouteRecord as d, ManifestCache as e };
@@ -0,0 +1,80 @@
1
+ import { R as ResolvedCompositionResult, a as ResolvedRouteResult } from './composition-CGU7iH-k.js';
2
+ import { PageState } from '@uniformdev/next-app-router-shared';
3
+
4
+ /**
5
+ * The page state a resolver runs for, which sets the composition state, release and locale. Pass
6
+ * the page's `code` path segment, or a page state from `deserializePageState` or an earlier
7
+ * resolver's result.
8
+ */
9
+ type PageStateSource = {
10
+ code: string;
11
+ pageState?: never;
12
+ } | {
13
+ pageState: PageState;
14
+ code?: never;
15
+ };
16
+
17
+ type ResolveCompositionByIdOptions = PageStateSource & {
18
+ compositionId: string;
19
+ /**
20
+ * Reported to analytics as the composition's matched route.
21
+ *
22
+ * @defaultValue the page state's `routePath`
23
+ */
24
+ matchedRoute?: string;
25
+ };
26
+ /**
27
+ * Resolves a composition by id for a page state or a page's code, without the Route API. The
28
+ * editor state falls back to the draft state, and the returned page state carries the state that
29
+ * resolved. `route` is undefined when no composition has the id.
30
+ */
31
+ declare const resolveCompositionById: ({ compositionId, matchedRoute, ...source }: ResolveCompositionByIdOptions) => Promise<ResolvedCompositionResult>;
32
+
33
+ type ResolveCompositionBySlugOptions = PageStateSource & {
34
+ slug: string;
35
+ /**
36
+ * Reported to analytics as the composition's matched route.
37
+ *
38
+ * @defaultValue the page state's `routePath`
39
+ */
40
+ matchedRoute?: string;
41
+ };
42
+ /**
43
+ * Resolves a composition by slug for a page state or a page's code, without the Route API. The
44
+ * editor state falls back to the draft state, and the returned page state carries the state that
45
+ * resolved. `route` is undefined when no composition has the slug. Publishing a composition
46
+ * revalidates its current slug, so a renamed slug serves the cached composition until it expires.
47
+ */
48
+ declare const resolveCompositionBySlug: ({ slug, matchedRoute, ...source }: ResolveCompositionBySlugOptions) => Promise<ResolvedCompositionResult>;
49
+
50
+ type ResolveRouteFunction = (options: ResolveRouteFromCodeOptions) => Promise<ResolvedRouteResult>;
51
+ type ResolveRouteFromCodeOptions = {
52
+ code: string;
53
+ };
54
+ /**
55
+ * Resolves the route of a `[code]` path segment through the Route API, returning a composition, a
56
+ * redirect, or no `route` when the path matches neither. Pass the result to `requireComposition`
57
+ * to apply redirects and not found. A code in the editor state falls back to the draft state when
58
+ * the composition has no editor state, and the returned page state carries the state that
59
+ * resolved.
60
+ */
61
+ declare const resolveRouteFromCode: ResolveRouteFunction;
62
+
63
+ type ResolveRouteFromPathOptions = PageStateSource & {
64
+ /**
65
+ * Project map path to resolve, for example `/site-settings` or `/en/404`. Replaces the page
66
+ * state's route path on the result.
67
+ */
68
+ path: string;
69
+ };
70
+ /**
71
+ * Resolves a project map path through the Route API for a page state or a page's code, returning
72
+ * a composition, a redirect, or no `route` when the path matches neither. Unlike
73
+ * `resolveCompositionBySlug` and `resolveCompositionById`, it evaluates redirects, resolves dynamic
74
+ * segments into `dynamicInputs` and matches the locale against the project map. The editor state
75
+ * falls back to the draft state, and the returned page state carries the path and the state that
76
+ * resolved.
77
+ */
78
+ declare const resolveRouteFromPath: ({ path, ...source }: ResolveRouteFromPathOptions) => Promise<ResolvedRouteResult>;
79
+
80
+ export { type PageStateSource as P, type ResolveCompositionByIdOptions as R, type ResolveCompositionBySlugOptions as a, type ResolveRouteFromCodeOptions as b, type ResolveRouteFromPathOptions as c, type ResolveRouteFunction as d, resolveCompositionBySlug as e, resolveRouteFromCode as f, resolveRouteFromPath as g, resolveCompositionById as r };
@@ -0,0 +1,80 @@
1
+ import { R as ResolvedCompositionResult, a as ResolvedRouteResult } from './composition-CGU7iH-k.mjs';
2
+ import { PageState } from '@uniformdev/next-app-router-shared';
3
+
4
+ /**
5
+ * The page state a resolver runs for, which sets the composition state, release and locale. Pass
6
+ * the page's `code` path segment, or a page state from `deserializePageState` or an earlier
7
+ * resolver's result.
8
+ */
9
+ type PageStateSource = {
10
+ code: string;
11
+ pageState?: never;
12
+ } | {
13
+ pageState: PageState;
14
+ code?: never;
15
+ };
16
+
17
+ type ResolveCompositionByIdOptions = PageStateSource & {
18
+ compositionId: string;
19
+ /**
20
+ * Reported to analytics as the composition's matched route.
21
+ *
22
+ * @defaultValue the page state's `routePath`
23
+ */
24
+ matchedRoute?: string;
25
+ };
26
+ /**
27
+ * Resolves a composition by id for a page state or a page's code, without the Route API. The
28
+ * editor state falls back to the draft state, and the returned page state carries the state that
29
+ * resolved. `route` is undefined when no composition has the id.
30
+ */
31
+ declare const resolveCompositionById: ({ compositionId, matchedRoute, ...source }: ResolveCompositionByIdOptions) => Promise<ResolvedCompositionResult>;
32
+
33
+ type ResolveCompositionBySlugOptions = PageStateSource & {
34
+ slug: string;
35
+ /**
36
+ * Reported to analytics as the composition's matched route.
37
+ *
38
+ * @defaultValue the page state's `routePath`
39
+ */
40
+ matchedRoute?: string;
41
+ };
42
+ /**
43
+ * Resolves a composition by slug for a page state or a page's code, without the Route API. The
44
+ * editor state falls back to the draft state, and the returned page state carries the state that
45
+ * resolved. `route` is undefined when no composition has the slug. Publishing a composition
46
+ * revalidates its current slug, so a renamed slug serves the cached composition until it expires.
47
+ */
48
+ declare const resolveCompositionBySlug: ({ slug, matchedRoute, ...source }: ResolveCompositionBySlugOptions) => Promise<ResolvedCompositionResult>;
49
+
50
+ type ResolveRouteFunction = (options: ResolveRouteFromCodeOptions) => Promise<ResolvedRouteResult>;
51
+ type ResolveRouteFromCodeOptions = {
52
+ code: string;
53
+ };
54
+ /**
55
+ * Resolves the route of a `[code]` path segment through the Route API, returning a composition, a
56
+ * redirect, or no `route` when the path matches neither. Pass the result to `requireComposition`
57
+ * to apply redirects and not found. A code in the editor state falls back to the draft state when
58
+ * the composition has no editor state, and the returned page state carries the state that
59
+ * resolved.
60
+ */
61
+ declare const resolveRouteFromCode: ResolveRouteFunction;
62
+
63
+ type ResolveRouteFromPathOptions = PageStateSource & {
64
+ /**
65
+ * Project map path to resolve, for example `/site-settings` or `/en/404`. Replaces the page
66
+ * state's route path on the result.
67
+ */
68
+ path: string;
69
+ };
70
+ /**
71
+ * Resolves a project map path through the Route API for a page state or a page's code, returning
72
+ * a composition, a redirect, or no `route` when the path matches neither. Unlike
73
+ * `resolveCompositionBySlug` and `resolveCompositionById`, it evaluates redirects, resolves dynamic
74
+ * segments into `dynamicInputs` and matches the locale against the project map. The editor state
75
+ * falls back to the draft state, and the returned page state carries the path and the state that
76
+ * resolved.
77
+ */
78
+ declare const resolveRouteFromPath: ({ path, ...source }: ResolveRouteFromPathOptions) => Promise<ResolvedRouteResult>;
79
+
80
+ export { type PageStateSource as P, type ResolveCompositionByIdOptions as R, type ResolveCompositionBySlugOptions as a, type ResolveRouteFromCodeOptions as b, type ResolveRouteFromPathOptions as c, type ResolveRouteFunction as d, resolveCompositionBySlug as e, resolveRouteFromCode as f, resolveRouteFromPath as g, resolveCompositionById as r };
@@ -0,0 +1,37 @@
1
+ import { a as CreateLearnedEdgeRouteFilterOptions, C as CreateCachedManifestProviderOptions } from './createCachedManifestProvider-2-2u3PYd.mjs';
2
+ import { E as EdgeRouteFilter, M as ManifestProvider } from './models-C8OdCO44.mjs';
3
+ import '@uniformdev/context';
4
+ import '@uniformdev/next-app-router-shared';
5
+
6
+ /**
7
+ * Expires Vercel runtime cache entries with any of the given tags. Pass it as `onRevalidateTags`
8
+ * to `createPreviewPOSTRouteHandler`, so publishing the manifest expires the copy
9
+ * `vercelManifestProvider` stored. Does nothing under `next dev` without `RUNTIME_CACHE_ENDPOINT`.
10
+ *
11
+ * Requires the optional peer dependency `@vercel/functions`.
12
+ */
13
+ declare const expireVercelRuntimeCacheTags: (tags: string[]) => Promise<void>;
14
+
15
+ /**
16
+ * Creates a learned edge route filter for `uniformEdgeMiddleware` that stores what it learns in
17
+ * Vercel's runtime cache, tagged with each page's `path:` tag. Pair it with
18
+ * `expireVercelRuntimeCacheTags` in the preview route handler so publishing a composition or
19
+ * changing the project map expires the records of its paths. Under `next dev` without
20
+ * `RUNTIME_CACHE_ENDPOINT`, each instance remembers on its own.
21
+ *
22
+ * Requires the optional peer dependency `@vercel/functions`.
23
+ */
24
+ declare const vercelEdgeRouteFilter: (options?: Omit<CreateLearnedEdgeRouteFilterOptions, "cache">) => EdgeRouteFilter;
25
+
26
+ /**
27
+ * Creates a manifest provider for `uniformEdgeMiddleware` that stores the published manifest in
28
+ * Vercel's runtime cache, tagged `manifest`, and loads it from the Uniform API on a miss. Pair it
29
+ * with `expireVercelRuntimeCacheTags` in the preview route handler so publishing the manifest
30
+ * expires the cached copy. Under `next dev` without `RUNTIME_CACHE_ENDPOINT`, it skips the
31
+ * runtime cache and loads from the API.
32
+ *
33
+ * Requires the optional peer dependency `@vercel/functions`.
34
+ */
35
+ declare const vercelManifestProvider: (options?: Omit<CreateCachedManifestProviderOptions, "cache">) => ManifestProvider;
36
+
37
+ export { expireVercelRuntimeCacheTags, vercelEdgeRouteFilter, vercelManifestProvider };
@@ -0,0 +1,37 @@
1
+ import { a as CreateLearnedEdgeRouteFilterOptions, C as CreateCachedManifestProviderOptions } from './createCachedManifestProvider-BoorKD15.js';
2
+ import { E as EdgeRouteFilter, M as ManifestProvider } from './models-C8OdCO44.js';
3
+ import '@uniformdev/context';
4
+ import '@uniformdev/next-app-router-shared';
5
+
6
+ /**
7
+ * Expires Vercel runtime cache entries with any of the given tags. Pass it as `onRevalidateTags`
8
+ * to `createPreviewPOSTRouteHandler`, so publishing the manifest expires the copy
9
+ * `vercelManifestProvider` stored. Does nothing under `next dev` without `RUNTIME_CACHE_ENDPOINT`.
10
+ *
11
+ * Requires the optional peer dependency `@vercel/functions`.
12
+ */
13
+ declare const expireVercelRuntimeCacheTags: (tags: string[]) => Promise<void>;
14
+
15
+ /**
16
+ * Creates a learned edge route filter for `uniformEdgeMiddleware` that stores what it learns in
17
+ * Vercel's runtime cache, tagged with each page's `path:` tag. Pair it with
18
+ * `expireVercelRuntimeCacheTags` in the preview route handler so publishing a composition or
19
+ * changing the project map expires the records of its paths. Under `next dev` without
20
+ * `RUNTIME_CACHE_ENDPOINT`, each instance remembers on its own.
21
+ *
22
+ * Requires the optional peer dependency `@vercel/functions`.
23
+ */
24
+ declare const vercelEdgeRouteFilter: (options?: Omit<CreateLearnedEdgeRouteFilterOptions, "cache">) => EdgeRouteFilter;
25
+
26
+ /**
27
+ * Creates a manifest provider for `uniformEdgeMiddleware` that stores the published manifest in
28
+ * Vercel's runtime cache, tagged `manifest`, and loads it from the Uniform API on a miss. Pair it
29
+ * with `expireVercelRuntimeCacheTags` in the preview route handler so publishing the manifest
30
+ * expires the cached copy. Under `next dev` without `RUNTIME_CACHE_ENDPOINT`, it skips the
31
+ * runtime cache and loads from the API.
32
+ *
33
+ * Requires the optional peer dependency `@vercel/functions`.
34
+ */
35
+ declare const vercelManifestProvider: (options?: Omit<CreateCachedManifestProviderOptions, "cache">) => ManifestProvider;
36
+
37
+ export { expireVercelRuntimeCacheTags, vercelEdgeRouteFilter, vercelManifestProvider };