@uniformdev/next-app-router 20.77.0 → 20.77.1-alpha.10.sha-3381091ae6

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.
@@ -63,6 +63,11 @@ type UniformCompositionProps = {
63
63
  resolveComponent: ResolveComponentFunction;
64
64
  /**
65
65
  * If provided, the composition will use the data client to retrieve data.
66
+ *
67
+ * Pass the same client here that you pass to `handleUniformRoute`. Without it, this component
68
+ * falls back to `DefaultDataClient` for the route it resolves and, on draft requests,
69
+ * for the manifest it evaluates personalization against - so a custom manifest source
70
+ * configured only on the middleware would not apply while the page renders.
66
71
  */
67
72
  dataClient?: DataClient;
68
73
  /**
@@ -63,6 +63,11 @@ type UniformCompositionProps = {
63
63
  resolveComponent: ResolveComponentFunction;
64
64
  /**
65
65
  * If provided, the composition will use the data client to retrieve data.
66
+ *
67
+ * Pass the same client here that you pass to `handleUniformRoute`. Without it, this component
68
+ * falls back to `DefaultDataClient` for the route it resolves and, on draft requests,
69
+ * for the manifest it evaluates personalization against - so a custom manifest source
70
+ * configured only on the middleware would not apply while the page renders.
66
71
  */
67
72
  dataClient?: DataClient;
68
73
  /**
package/dist/cache.js CHANGED
@@ -2039,7 +2039,9 @@ var DefaultDataClient = class {
2039
2039
  source: "middleware",
2040
2040
  route: options.route,
2041
2041
  routeClient,
2042
- enableRuntimeCache: options.route.state === CANVAS_PUBLISHED_STATE && getMiddlewareRuntimeCache(),
2042
+ // The runtime cache is keyed on the route path. Development bypasses it so an author sees
2043
+ // an edit right away, the same way the fetch cache is bypassed for development.
2044
+ enableRuntimeCache: options.route.state === CANVAS_PUBLISHED_STATE && getMiddlewareRuntimeCache() && !isDevelopmentEnvironment(),
2043
2045
  disableSwrCache: getDisableSwrMiddlewareCache()
2044
2046
  });
2045
2047
  if (resolvedRoute.type === "composition") {
package/dist/cache.mjs CHANGED
@@ -2026,7 +2026,9 @@ var DefaultDataClient = class {
2026
2026
  source: "middleware",
2027
2027
  route: options.route,
2028
2028
  routeClient,
2029
- enableRuntimeCache: options.route.state === CANVAS_PUBLISHED_STATE && getMiddlewareRuntimeCache(),
2029
+ // The runtime cache is keyed on the route path. Development bypasses it so an author sees
2030
+ // an edit right away, the same way the fetch cache is bypassed for development.
2031
+ enableRuntimeCache: options.route.state === CANVAS_PUBLISHED_STATE && getMiddlewareRuntimeCache() && !isDevelopmentEnvironment(),
2030
2032
  disableSwrCache: getDisableSwrMiddlewareCache()
2031
2033
  });
2032
2034
  if (resolvedRoute.type === "composition") {
package/dist/compat.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, { ComponentType } from 'react';
2
2
  import { ComponentProps as ComponentProps$1, ComponentParameter } from '@uniformdev/next-app-router-shared';
3
3
  import { U as UniformTextProps$1 } from './UniformText-ChMwHBw4.mjs';
4
- import { R as ResolveComponentResult, a as ResolveComponentFunction } from './UniformComposition-Bo6UsTDC.mjs';
4
+ import { R as ResolveComponentResult, a as ResolveComponentFunction } from './UniformComposition-CpEVJ-SR.mjs';
5
5
  import '@uniformdev/next-app-router-client';
6
6
  import '@uniformdev/canvas';
7
7
  import './client-DRMp2gpi.mjs';
package/dist/compat.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, { ComponentType } from 'react';
2
2
  import { ComponentProps as ComponentProps$1, ComponentParameter } from '@uniformdev/next-app-router-shared';
3
3
  import { U as UniformTextProps$1 } from './UniformText-ChMwHBw4.js';
4
- import { R as ResolveComponentResult, a as ResolveComponentFunction } from './UniformComposition-BWxMuY7i.js';
4
+ import { R as ResolveComponentResult, a as ResolveComponentFunction } from './UniformComposition-Ck7mRTp-.js';
5
5
  import '@uniformdev/next-app-router-client';
6
6
  import '@uniformdev/canvas';
7
7
  import './client-DRMp2gpi.js';
package/dist/handler.js CHANGED
@@ -1679,10 +1679,13 @@ _url22 = /* @__PURE__ */ new WeakMap();
1679
1679
  _projectsUrl = /* @__PURE__ */ new WeakMap();
1680
1680
  __privateAdd3(_ProjectClient, _url22, "/api/v1/project");
1681
1681
  __privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
1682
+ var ALLOWED_REFERRER_ORIGIN = /^https:\/\/([\w-]+\.)*(uniform\.(app|wtf)|uniformcode\.ai)$|^https?:\/\/localhost:\d{4}$/;
1682
1683
  var isAllowedReferrer = (referrer) => {
1683
- return Boolean(
1684
- referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|uniformcode.ai|localhost:\d{4})\//)
1685
- );
1684
+ try {
1685
+ return ALLOWED_REFERRER_ORIGIN.test(new URL(referrer != null ? referrer : "").origin);
1686
+ } catch (e) {
1687
+ return false;
1688
+ }
1686
1689
  };
1687
1690
 
1688
1691
  // src/handler/createPreviewGETRouteHandler.ts
package/dist/handler.mjs CHANGED
@@ -1664,10 +1664,13 @@ _url22 = /* @__PURE__ */ new WeakMap();
1664
1664
  _projectsUrl = /* @__PURE__ */ new WeakMap();
1665
1665
  __privateAdd3(_ProjectClient, _url22, "/api/v1/project");
1666
1666
  __privateAdd3(_ProjectClient, _projectsUrl, "/api/v1/projects");
1667
+ var ALLOWED_REFERRER_ORIGIN = /^https:\/\/([\w-]+\.)*(uniform\.(app|wtf)|uniformcode\.ai)$|^https?:\/\/localhost:\d{4}$/;
1667
1668
  var isAllowedReferrer = (referrer) => {
1668
- return Boolean(
1669
- referrer == null ? void 0 : referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|uniformcode.ai|localhost:\d{4})\//)
1670
- );
1669
+ try {
1670
+ return ALLOWED_REFERRER_ORIGIN.test(new URL(referrer != null ? referrer : "").origin);
1671
+ } catch (e) {
1672
+ return false;
1673
+ }
1671
1674
  };
1672
1675
 
1673
1676
  // src/handler/createPreviewGETRouteHandler.ts
package/dist/index.d.mts CHANGED
@@ -2,8 +2,8 @@ import { CanvasClient, CompositionDeliveryClient, RouteClient, ComponentInstance
2
2
  import { CacheMode, CanvasCacheMode, ManifestCacheMode, ProjectMapCacheMode, RewriteRequestPathResult } from '@uniformdev/next-app-router-shared';
3
3
  import { ManifestClient } from '@uniformdev/context/api';
4
4
  import { ProjectMapClient } from '@uniformdev/project-map';
5
- import { U as UniformCompositionProps } from './UniformComposition-Bo6UsTDC.mjs';
6
- export { C as CompositionCache, a as ResolveComponentFunction, R as ResolveComponentResult, b as UniformComposition, c as createCompositionCache } from './UniformComposition-Bo6UsTDC.mjs';
5
+ import { U as UniformCompositionProps } from './UniformComposition-CpEVJ-SR.mjs';
6
+ export { C as CompositionCache, a as ResolveComponentFunction, R as ResolveComponentResult, b as UniformComposition, c as createCompositionCache } from './UniformComposition-CpEVJ-SR.mjs';
7
7
  import React from 'react';
8
8
  export { D as DataClient, a as DefaultDataClient, E as EnhanceRouteOptions, G as GetRouteFromMiddlewareOptions, b as GetRouteFromPageStateOptions, c as GetRouteOptions, R as RewriteRouteOptions, d as RewriteRouteResult, e as expireMiddlewareCacheTag } from './client-DRMp2gpi.mjs';
9
9
  import { a as ResolvedRouteResult } from './resolveRouteFromCode-C0dkUV2T.mjs';
package/dist/index.d.ts CHANGED
@@ -2,8 +2,8 @@ import { CanvasClient, CompositionDeliveryClient, RouteClient, ComponentInstance
2
2
  import { CacheMode, CanvasCacheMode, ManifestCacheMode, ProjectMapCacheMode, RewriteRequestPathResult } from '@uniformdev/next-app-router-shared';
3
3
  import { ManifestClient } from '@uniformdev/context/api';
4
4
  import { ProjectMapClient } from '@uniformdev/project-map';
5
- import { U as UniformCompositionProps } from './UniformComposition-BWxMuY7i.js';
6
- export { C as CompositionCache, a as ResolveComponentFunction, R as ResolveComponentResult, b as UniformComposition, c as createCompositionCache } from './UniformComposition-BWxMuY7i.js';
5
+ import { U as UniformCompositionProps } from './UniformComposition-Ck7mRTp-.js';
6
+ export { C as CompositionCache, a as ResolveComponentFunction, R as ResolveComponentResult, b as UniformComposition, c as createCompositionCache } from './UniformComposition-Ck7mRTp-.js';
7
7
  import React from 'react';
8
8
  export { D as DataClient, a as DefaultDataClient, E as EnhanceRouteOptions, G as GetRouteFromMiddlewareOptions, b as GetRouteFromPageStateOptions, c as GetRouteOptions, R as RewriteRouteOptions, d as RewriteRouteResult, e as expireMiddlewareCacheTag } from './client-DRMp2gpi.js';
9
9
  import { a as ResolvedRouteResult } from './resolveRouteFromCode-Bhz8EJBu.js';