@uniformdev/next-app-router 20.80.2 → 20.81.1-alpha.4.sha-de16ebeee7

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.
@@ -26,7 +26,6 @@ module.exports = __toCommonJS(default_exports);
26
26
  var config = {
27
27
  defaultConsent: true,
28
28
  quirkSerialization: true,
29
- middlewareRuntimeCache: true,
30
29
  playgroundPath: "/uniform/playground"
31
30
  };
32
31
  var default_default = config;
@@ -2,7 +2,6 @@
2
2
  var config = {
3
3
  defaultConsent: true,
4
4
  quirkSerialization: true,
5
- middlewareRuntimeCache: true,
6
5
  playgroundPath: "/uniform/playground"
7
6
  };
8
7
  var default_default = config;
@@ -0,0 +1,44 @@
1
+ import { ManifestV2 } from '@uniformdev/context';
2
+ import { TransformEdgeStreamOptions } from '@uniformdev/context-edge';
3
+ import { NextRequest } from 'next/server';
4
+ import { HandleOptions } from './middleware.mjs';
5
+ import '@uniformdev/next-app-router-shared';
6
+
7
+ /**
8
+ * Marks the edge middleware's own fetch of the rendered page, so the middleware lets it through
9
+ * when the matcher also covers the rewrite destination.
10
+ */
11
+ declare const UNIFORM_EDGE_ORIGIN_HEADER = "x-uniform-edge-origin";
12
+ type UniformEdgeMiddlewareOptions = HandleOptions & {
13
+ /**
14
+ * The project's Context manifest, which chooses the visitor's variants. Bake it into the build
15
+ * (for example with `uniform context manifest download`) so the middleware makes no network
16
+ * calls. Variants for signals published after the build are chosen in the browser.
17
+ */
18
+ manifest: ManifestV2;
19
+ /**
20
+ * Called when the NESI transform fails. Receives the error and, when available, the decoded
21
+ * HTML chunk that triggered it. The response keeps streaming the untransformed HTML.
22
+ */
23
+ onError?: TransformEdgeStreamOptions['onError'];
24
+ };
25
+ /**
26
+ * Returns middleware that rewrites each request to its Uniform code like `uniformMiddleware`, and
27
+ * processes the NESI tags in the page at the edge. HTML document requests fetch the page rendered
28
+ * for the route's code and keep only the visitor's variants from the tags it contains, which
29
+ * `UniformComposition` renders for published personalizations and tests when `edgeMode` is enabled
30
+ * in `uniform.server.config`. Client navigations, prefetches and draft requests are rewritten, and
31
+ * their variants are chosen in the browser.
32
+ *
33
+ * Requires the optional peer dependency `@uniformdev/context-edge`.
34
+ */
35
+ declare const uniformEdgeMiddleware: (options: UniformEdgeMiddlewareOptions) => (request: NextRequest) => Promise<Response>;
36
+ /**
37
+ * Handles one request the way {@link uniformEdgeMiddleware} does. The transformed response is
38
+ * personalized, so it is marked `private, no-store`.
39
+ */
40
+ declare const handleUniformEdgeRoute: ({ request, manifest, onError, ...options }: UniformEdgeMiddlewareOptions & {
41
+ request: NextRequest;
42
+ }) => Promise<Response>;
43
+
44
+ export { UNIFORM_EDGE_ORIGIN_HEADER, type UniformEdgeMiddlewareOptions, handleUniformEdgeRoute, uniformEdgeMiddleware };
package/dist/edge.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ import { ManifestV2 } from '@uniformdev/context';
2
+ import { TransformEdgeStreamOptions } from '@uniformdev/context-edge';
3
+ import { NextRequest } from 'next/server';
4
+ import { HandleOptions } from './middleware.js';
5
+ import '@uniformdev/next-app-router-shared';
6
+
7
+ /**
8
+ * Marks the edge middleware's own fetch of the rendered page, so the middleware lets it through
9
+ * when the matcher also covers the rewrite destination.
10
+ */
11
+ declare const UNIFORM_EDGE_ORIGIN_HEADER = "x-uniform-edge-origin";
12
+ type UniformEdgeMiddlewareOptions = HandleOptions & {
13
+ /**
14
+ * The project's Context manifest, which chooses the visitor's variants. Bake it into the build
15
+ * (for example with `uniform context manifest download`) so the middleware makes no network
16
+ * calls. Variants for signals published after the build are chosen in the browser.
17
+ */
18
+ manifest: ManifestV2;
19
+ /**
20
+ * Called when the NESI transform fails. Receives the error and, when available, the decoded
21
+ * HTML chunk that triggered it. The response keeps streaming the untransformed HTML.
22
+ */
23
+ onError?: TransformEdgeStreamOptions['onError'];
24
+ };
25
+ /**
26
+ * Returns middleware that rewrites each request to its Uniform code like `uniformMiddleware`, and
27
+ * processes the NESI tags in the page at the edge. HTML document requests fetch the page rendered
28
+ * for the route's code and keep only the visitor's variants from the tags it contains, which
29
+ * `UniformComposition` renders for published personalizations and tests when `edgeMode` is enabled
30
+ * in `uniform.server.config`. Client navigations, prefetches and draft requests are rewritten, and
31
+ * their variants are chosen in the browser.
32
+ *
33
+ * Requires the optional peer dependency `@uniformdev/context-edge`.
34
+ */
35
+ declare const uniformEdgeMiddleware: (options: UniformEdgeMiddlewareOptions) => (request: NextRequest) => Promise<Response>;
36
+ /**
37
+ * Handles one request the way {@link uniformEdgeMiddleware} does. The transformed response is
38
+ * personalized, so it is marked `private, no-store`.
39
+ */
40
+ declare const handleUniformEdgeRoute: ({ request, manifest, onError, ...options }: UniformEdgeMiddlewareOptions & {
41
+ request: NextRequest;
42
+ }) => Promise<Response>;
43
+
44
+ export { UNIFORM_EDGE_ORIGIN_HEADER, type UniformEdgeMiddlewareOptions, handleUniformEdgeRoute, uniformEdgeMiddleware };