@uniformdev/canvas-next-rsc 20.6.2-alpha.11 → 20.7.1-alpha.102

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/LICENSE.txt CHANGED
@@ -1,2 +1,2 @@
1
- © 2024 Uniform Systems, Inc. All Rights Reserved.
1
+ © 2025 Uniform Systems, Inc. All Rights Reserved.
2
2
  See details of Uniform Systems, Inc. Master Subscription Agreement here: https://uniform.dev/eula
package/dist/config.d.mts CHANGED
@@ -1,6 +1,13 @@
1
1
  import { NextConfig } from 'next';
2
2
  export { UniformServerConfig } from '@uniformdev/canvas-next-rsc-shared';
3
3
 
4
+ /**
5
+ * Wraps the Next.js config to set up the Uniform server config alias.
6
+ * This enables the `uniform.server.config` import to resolve to the project's config file.
7
+ *
8
+ * @param nextConfig - The Next.js configuration object
9
+ * @returns The modified Next.js configuration with Uniform config alias set up
10
+ */
4
11
  declare const withUniformConfig: (nextConfig: NextConfig) => NextConfig;
5
12
 
6
13
  export { withUniformConfig };
package/dist/config.d.ts CHANGED
@@ -1,6 +1,13 @@
1
1
  import { NextConfig } from 'next';
2
2
  export { UniformServerConfig } from '@uniformdev/canvas-next-rsc-shared';
3
3
 
4
+ /**
5
+ * Wraps the Next.js config to set up the Uniform server config alias.
6
+ * This enables the `uniform.server.config` import to resolve to the project's config file.
7
+ *
8
+ * @param nextConfig - The Next.js configuration object
9
+ * @returns The modified Next.js configuration with Uniform config alias set up
10
+ */
4
11
  declare const withUniformConfig: (nextConfig: NextConfig) => NextConfig;
5
12
 
6
13
  export { withUniformConfig };
package/dist/config.js CHANGED
@@ -47,34 +47,28 @@ var getConfigPath = () => {
47
47
  };
48
48
  };
49
49
  var withUniformConfig = (nextConfig) => {
50
- var _a, _b, _c;
51
- const { fileName: uniformConfigFileName } = getConfigPath() || {};
52
- const turboResolveAliases = {
53
- ...((_b = (_a = nextConfig.experimental) == null ? void 0 : _a.turbo) == null ? void 0 : _b.resolveAlias) || {}
50
+ var _a;
51
+ const { fileName: uniformConfigFileName, filePath: uniformConfigFilePath } = getConfigPath() || {};
52
+ const turbopackResolveAlias = {
53
+ ...(_a = nextConfig.turbopack) == null ? void 0 : _a.resolveAlias
54
54
  };
55
55
  if (uniformConfigFileName) {
56
- console.log("(Turbo) Using Uniform config from", uniformConfigFileName);
57
- turboResolveAliases["uniform.server.config"] = `./${uniformConfigFileName}`;
56
+ console.log("(Turbopack) Using Uniform config from", uniformConfigFileName);
57
+ turbopackResolveAlias["uniform.server.config"] = `./${uniformConfigFileName}`;
58
58
  }
59
59
  return {
60
60
  ...nextConfig,
61
- experimental: {
62
- ...nextConfig.experimental || {},
63
- turbo: {
64
- ...((_c = nextConfig.experimental) == null ? void 0 : _c.turbo) || {},
65
- resolveAlias: turboResolveAliases
66
- }
61
+ turbopack: {
62
+ ...nextConfig.turbopack,
63
+ resolveAlias: turbopackResolveAlias
67
64
  },
68
65
  webpack: (config, context) => {
69
66
  if (nextConfig.webpack) {
70
67
  nextConfig.webpack(config, context);
71
68
  }
72
- if (context.isServer) {
73
- const { filePath: uniformConfigPath } = getConfigPath() || {};
74
- if (uniformConfigPath) {
75
- console.log("Using Uniform config from", uniformConfigPath);
76
- config.resolve.alias["uniform.server.config"] = (0, import_path.resolve)(config.context, uniformConfigPath);
77
- }
69
+ if (context.isServer && uniformConfigFilePath) {
70
+ console.log("(Webpack) Using Uniform config from", uniformConfigFilePath);
71
+ config.resolve.alias["uniform.server.config"] = (0, import_path.resolve)(config.context, uniformConfigFilePath);
78
72
  }
79
73
  return config;
80
74
  }
package/dist/config.mjs CHANGED
@@ -23,34 +23,28 @@ var getConfigPath = () => {
23
23
  };
24
24
  };
25
25
  var withUniformConfig = (nextConfig) => {
26
- var _a, _b, _c;
27
- const { fileName: uniformConfigFileName } = getConfigPath() || {};
28
- const turboResolveAliases = {
29
- ...((_b = (_a = nextConfig.experimental) == null ? void 0 : _a.turbo) == null ? void 0 : _b.resolveAlias) || {}
26
+ var _a;
27
+ const { fileName: uniformConfigFileName, filePath: uniformConfigFilePath } = getConfigPath() || {};
28
+ const turbopackResolveAlias = {
29
+ ...(_a = nextConfig.turbopack) == null ? void 0 : _a.resolveAlias
30
30
  };
31
31
  if (uniformConfigFileName) {
32
- console.log("(Turbo) Using Uniform config from", uniformConfigFileName);
33
- turboResolveAliases["uniform.server.config"] = `./${uniformConfigFileName}`;
32
+ console.log("(Turbopack) Using Uniform config from", uniformConfigFileName);
33
+ turbopackResolveAlias["uniform.server.config"] = `./${uniformConfigFileName}`;
34
34
  }
35
35
  return {
36
36
  ...nextConfig,
37
- experimental: {
38
- ...nextConfig.experimental || {},
39
- turbo: {
40
- ...((_c = nextConfig.experimental) == null ? void 0 : _c.turbo) || {},
41
- resolveAlias: turboResolveAliases
42
- }
37
+ turbopack: {
38
+ ...nextConfig.turbopack,
39
+ resolveAlias: turbopackResolveAlias
43
40
  },
44
41
  webpack: (config, context) => {
45
42
  if (nextConfig.webpack) {
46
43
  nextConfig.webpack(config, context);
47
44
  }
48
- if (context.isServer) {
49
- const { filePath: uniformConfigPath } = getConfigPath() || {};
50
- if (uniformConfigPath) {
51
- console.log("Using Uniform config from", uniformConfigPath);
52
- config.resolve.alias["uniform.server.config"] = resolve(config.context, uniformConfigPath);
53
- }
45
+ if (context.isServer && uniformConfigFilePath) {
46
+ console.log("(Webpack) Using Uniform config from", uniformConfigFilePath);
47
+ config.resolve.alias["uniform.server.config"] = resolve(config.context, uniformConfigFilePath);
54
48
  }
55
49
  return config;
56
50
  }
package/dist/handler.js CHANGED
@@ -204,9 +204,18 @@ var env = {
204
204
  };
205
205
 
206
206
  // src/utils/tag.ts
207
+ var encodePathForTag = (path) => {
208
+ return path.split("/").map((segment) => {
209
+ if (/[^\x00-\x7F]/.test(segment)) {
210
+ return encodeURIComponent(segment);
211
+ }
212
+ return segment;
213
+ }).join("/");
214
+ };
207
215
  var buildPathTag = (path) => {
208
216
  const actualPath = path.startsWith("/") ? path : `/${path}`;
209
- return `path:${actualPath}`.toLowerCase();
217
+ const encodedPath = encodePathForTag(actualPath);
218
+ return `path:${encodedPath}`.toLowerCase();
210
219
  };
211
220
  var buildCompositionTag = (compositionId) => {
212
221
  return `composition:${compositionId}`.toLowerCase();
package/dist/handler.mjs CHANGED
@@ -171,9 +171,18 @@ var env = {
171
171
  };
172
172
 
173
173
  // src/utils/tag.ts
174
+ var encodePathForTag = (path) => {
175
+ return path.split("/").map((segment) => {
176
+ if (/[^\x00-\x7F]/.test(segment)) {
177
+ return encodeURIComponent(segment);
178
+ }
179
+ return segment;
180
+ }).join("/");
181
+ };
174
182
  var buildPathTag = (path) => {
175
183
  const actualPath = path.startsWith("/") ? path : `/${path}`;
176
- return `path:${actualPath}`.toLowerCase();
184
+ const encodedPath = encodePathForTag(actualPath);
185
+ return `path:${encodedPath}`.toLowerCase();
177
186
  };
178
187
  var buildCompositionTag = (compositionId) => {
179
188
  return `composition:${compositionId}`.toLowerCase();
package/dist/index.d.mts CHANGED
@@ -37,7 +37,7 @@ declare const getManifest: (options: Pick<CompositionContext, "searchParams">) =
37
37
  clauses: ({
38
38
  type: "G";
39
39
  op?: "&" | "|";
40
- clauses: (any | ({
40
+ clauses: (/*elided*/ any | ({
41
41
  type: "CK";
42
42
  cookieName: string;
43
43
  match: {
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ declare const getManifest: (options: Pick<CompositionContext, "searchParams">) =
37
37
  clauses: ({
38
38
  type: "G";
39
39
  op?: "&" | "|";
40
- clauses: (any | ({
40
+ clauses: (/*elided*/ any | ({
41
41
  type: "CK";
42
42
  cookieName: string;
43
43
  match: {
package/dist/index.esm.js CHANGED
@@ -24,13 +24,12 @@ var isDraftModeEnabled = async ({
24
24
  draftModeEnabled = (await draftMode()).isEnabled;
25
25
  } catch (e) {
26
26
  }
27
- return draftModeEnabled || isIncontextEditingEnabled({ searchParams });
27
+ return draftModeEnabled;
28
28
  };
29
29
  var isIncontextEditingEnabled = ({
30
30
  searchParams
31
31
  }) => {
32
- const containsKey = typeof (searchParams == null ? void 0 : searchParams[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) !== "undefined";
33
- return containsKey;
32
+ return (searchParams == null ? void 0 : searchParams[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) === "true";
34
33
  };
35
34
  var determinePreviewMode = ({
36
35
  searchParams
@@ -67,9 +66,6 @@ var shouldCacheBeDisabled = async (options) => {
67
66
  if (await isDraftModeEnabled(options)) {
68
67
  return { disabled: true, reason: "DRAFT" };
69
68
  }
70
- if (isIncontextEditingEnabled(options)) {
71
- return { disabled: true, reason: "INCONTEXT" };
72
- }
73
69
  if (isDevelopmentEnvironment()) {
74
70
  return { disabled: true, reason: "DEV" };
75
71
  }
@@ -154,9 +150,18 @@ var env = {
154
150
  };
155
151
 
156
152
  // src/utils/tag.ts
153
+ var encodePathForTag = (path) => {
154
+ return path.split("/").map((segment) => {
155
+ if (/[^\x00-\x7F]/.test(segment)) {
156
+ return encodeURIComponent(segment);
157
+ }
158
+ return segment;
159
+ }).join("/");
160
+ };
157
161
  var buildPathTag = (path) => {
158
162
  const actualPath = path.startsWith("/") ? path : `/${path}`;
159
- return `path:${actualPath}`.toLowerCase();
163
+ const encodedPath = encodePathForTag(actualPath);
164
+ return `path:${encodedPath}`.toLowerCase();
160
165
  };
161
166
  var buildCompositionTag = (compositionId) => {
162
167
  return `composition:${compositionId}`.toLowerCase();
@@ -529,10 +534,17 @@ var retrieveRoute = async ({ params, searchParams: providedSearchParams, skipPre
529
534
  let result;
530
535
  for (let i = 0; i < states.length; i++) {
531
536
  const state = states[i];
532
- const releaseId = determineReleaseId({
537
+ const releaseIdFromSearchParams = await determineReleaseId({
533
538
  searchParams,
534
539
  state
535
540
  });
541
+ const releaseIdFromFetchOptions = fetchOptions == null ? void 0 : fetchOptions.releaseId;
542
+ if (releaseIdFromSearchParams && releaseIdFromFetchOptions && releaseIdFromSearchParams !== releaseIdFromFetchOptions) {
543
+ console.warn(
544
+ "retrieveRoute: releaseId provided in both searchParams and fetchOptions, using fetchOptions"
545
+ );
546
+ }
547
+ const releaseId = releaseIdFromFetchOptions != null ? releaseIdFromFetchOptions : releaseIdFromSearchParams;
536
548
  try {
537
549
  result = await retrieveRouteByPath({
538
550
  path: value,
@@ -597,23 +609,16 @@ var determineState = async ({ searchParams }) => {
597
609
  searchParams
598
610
  });
599
611
  const previewEnvironment = isOnVercelPreviewEnvironment();
600
- const isDevelopment = isDevelopmentEnvironment();
601
612
  const isCanvasEditing = isIncontextEditingEnabled({
602
613
  searchParams
603
614
  });
604
- let states;
605
- if (isCanvasEditing) {
606
- states = [CANVAS_EDITOR_STATE, CANVAS_DRAFT_STATE];
607
- } else {
608
- states = isDraftMode || previewEnvironment || isDevelopment ? [CANVAS_DRAFT_STATE] : [CANVAS_PUBLISHED_STATE];
609
- }
610
- return states;
615
+ return isDraftMode || previewEnvironment ? (isCanvasEditing ? [CANVAS_EDITOR_STATE] : []).concat([CANVAS_DRAFT_STATE]) : [CANVAS_PUBLISHED_STATE];
611
616
  };
612
- var determineReleaseId = ({
617
+ var determineReleaseId = async ({
613
618
  searchParams,
614
619
  state
615
620
  }) => {
616
- const draftMode2 = isDraftModeEnabled({
621
+ const draftMode2 = await isDraftModeEnabled({
617
622
  searchParams
618
623
  });
619
624
  if (!draftMode2 || state === CANVAS_PUBLISHED_STATE) {
@@ -632,18 +637,11 @@ var ContextUpdateTrigger = ({ path }) => {
632
637
  // src/components/PersonalizeClientWrapper.tsx
633
638
  import { PersonalizeClient } from "@uniformdev/canvas-next-rsc-client";
634
639
  import React3 from "react";
635
- var PersonalizeClientWrapper = (props) => {
636
- return /* @__PURE__ */ React3.createElement(
637
- PersonalizeClient,
638
- {
639
- component: props.component,
640
- count: props.count,
641
- slots: props.slots,
642
- trackingEventName: props.trackingEventName,
643
- algorithm: props.algorithm,
644
- indexes: []
645
- }
646
- );
640
+ var PersonalizeClientWrapper = ({
641
+ contextInstance,
642
+ ...props
643
+ }) => {
644
+ return /* @__PURE__ */ React3.createElement(PersonalizeClient, { ...props, indexes: [] });
647
645
  };
648
646
 
649
647
  // src/components/PersonalizeServer.ts
@@ -682,19 +680,12 @@ var PersonalizeServer = (props) => {
682
680
  import { PersonalizeClient as PersonalizeClient2 } from "@uniformdev/canvas-next-rsc-client";
683
681
  import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
684
682
  import React5 from "react";
685
- var PersonalizeServerHybrid = (props) => {
686
- const { indexes } = runPersonalization2(props);
687
- return /* @__PURE__ */ React5.createElement(
688
- PersonalizeClient2,
689
- {
690
- component: props.component,
691
- count: props.count,
692
- slots: props.slots,
693
- trackingEventName: props.trackingEventName,
694
- algorithm: props.algorithm,
695
- indexes
696
- }
697
- );
683
+ var PersonalizeServerHybrid = ({
684
+ contextInstance,
685
+ ...props
686
+ }) => {
687
+ const { indexes } = runPersonalization2({ ...props, contextInstance });
688
+ return /* @__PURE__ */ React5.createElement(PersonalizeClient2, { ...props, indexes });
698
689
  };
699
690
 
700
691
  // src/components/TestServer.ts
@@ -757,6 +748,7 @@ var UniformComposition = async ({
757
748
  route,
758
749
  ...props
759
750
  }) => {
751
+ var _a;
760
752
  let searchParams;
761
753
  let serverContext = void 0;
762
754
  if (props.mode === "static") {
@@ -781,10 +773,10 @@ var UniformComposition = async ({
781
773
  const state = route.compositionApiResponse.state;
782
774
  if (state === CANVAS_DRAFT_STATE2 || state === CANVAS_EDITOR_STATE2) {
783
775
  walkNodeTree(route.compositionApiResponse.composition, (node) => {
784
- var _a, _b;
776
+ var _a2, _b;
785
777
  if (node.type === "component" && node.node.parameters) {
786
778
  const contextualEditing = node.node.parameters[CANVAS_CONTEXTUAL_EDITING_PARAM];
787
- const editableFields = (_b = (_a = contextualEditing == null ? void 0 : contextualEditing.value) == null ? void 0 : _a.editableParameters) != null ? _b : [];
779
+ const editableFields = (_b = (_a2 = contextualEditing == null ? void 0 : contextualEditing.value) == null ? void 0 : _a2.editableParameters) != null ? _b : [];
788
780
  Object.keys(node.node.parameters).forEach((key) => {
789
781
  const parameter = node.node.parameters[key];
790
782
  if (parameter.type === "text") {
@@ -801,7 +793,8 @@ var UniformComposition = async ({
801
793
  composition: route.compositionApiResponse.composition,
802
794
  matchedRoute: route.matchedRoute,
803
795
  searchParams,
804
- dynamicInputs: route.dynamicInputs,
796
+ // provide default non-undefined values to avoid serialization issues
797
+ dynamicInputs: (_a = route.dynamicInputs) != null ? _a : {},
805
798
  type: "composition",
806
799
  isContextualEditing: isIncontextEditingEnabled({ searchParams }),
807
800
  isDraftMode: await isDraftModeEnabled({ searchParams }),
@@ -833,6 +826,11 @@ var UniformComposition = async ({
833
826
  },
834
827
  {}
835
828
  ),
829
+ compositionMetadata: {
830
+ compositionId: route.compositionApiResponse.composition._id,
831
+ matchedRoute: route.matchedRoute,
832
+ dynamicInputs: route.dynamicInputs
833
+ },
836
834
  quirks: {
837
835
  "vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
838
836
  "vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
@@ -1152,7 +1150,8 @@ import { notFound as notFound2 } from "next/navigation";
1152
1150
  import React10 from "react";
1153
1151
  var UniformPlayground = async ({ searchParams, ...rest }) => {
1154
1152
  const awaitedSearchParams = await searchParams;
1155
- if (!isDraftModeEnabled({ searchParams: awaitedSearchParams })) {
1153
+ const isDraftMode = await isDraftModeEnabled({ searchParams: awaitedSearchParams });
1154
+ if (!isDraftMode) {
1156
1155
  return /* @__PURE__ */ React10.createElement("div", null, /* @__PURE__ */ React10.createElement("h1", null, "Playground is only available in draft mode"));
1157
1156
  }
1158
1157
  const id = awaitedSearchParams["id"];
package/dist/index.js CHANGED
@@ -77,13 +77,12 @@ var isDraftModeEnabled = async ({
77
77
  draftModeEnabled = (await (0, import_headers.draftMode)()).isEnabled;
78
78
  } catch (e) {
79
79
  }
80
- return draftModeEnabled || isIncontextEditingEnabled({ searchParams });
80
+ return draftModeEnabled;
81
81
  };
82
82
  var isIncontextEditingEnabled = ({
83
83
  searchParams
84
84
  }) => {
85
- const containsKey = typeof (searchParams == null ? void 0 : searchParams[import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) !== "undefined";
86
- return containsKey;
85
+ return (searchParams == null ? void 0 : searchParams[import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) === "true";
87
86
  };
88
87
  var determinePreviewMode = ({
89
88
  searchParams
@@ -120,9 +119,6 @@ var shouldCacheBeDisabled = async (options) => {
120
119
  if (await isDraftModeEnabled(options)) {
121
120
  return { disabled: true, reason: "DRAFT" };
122
121
  }
123
- if (isIncontextEditingEnabled(options)) {
124
- return { disabled: true, reason: "INCONTEXT" };
125
- }
126
122
  if (isDevelopmentEnvironment()) {
127
123
  return { disabled: true, reason: "DEV" };
128
124
  }
@@ -207,9 +203,18 @@ var env = {
207
203
  };
208
204
 
209
205
  // src/utils/tag.ts
206
+ var encodePathForTag = (path) => {
207
+ return path.split("/").map((segment) => {
208
+ if (/[^\x00-\x7F]/.test(segment)) {
209
+ return encodeURIComponent(segment);
210
+ }
211
+ return segment;
212
+ }).join("/");
213
+ };
210
214
  var buildPathTag = (path) => {
211
215
  const actualPath = path.startsWith("/") ? path : `/${path}`;
212
- return `path:${actualPath}`.toLowerCase();
216
+ const encodedPath = encodePathForTag(actualPath);
217
+ return `path:${encodedPath}`.toLowerCase();
213
218
  };
214
219
  var buildCompositionTag = (compositionId) => {
215
220
  return `composition:${compositionId}`.toLowerCase();
@@ -557,10 +562,17 @@ var retrieveRoute = async ({ params, searchParams: providedSearchParams, skipPre
557
562
  let result;
558
563
  for (let i = 0; i < states.length; i++) {
559
564
  const state = states[i];
560
- const releaseId = determineReleaseId({
565
+ const releaseIdFromSearchParams = await determineReleaseId({
561
566
  searchParams,
562
567
  state
563
568
  });
569
+ const releaseIdFromFetchOptions = fetchOptions == null ? void 0 : fetchOptions.releaseId;
570
+ if (releaseIdFromSearchParams && releaseIdFromFetchOptions && releaseIdFromSearchParams !== releaseIdFromFetchOptions) {
571
+ console.warn(
572
+ "retrieveRoute: releaseId provided in both searchParams and fetchOptions, using fetchOptions"
573
+ );
574
+ }
575
+ const releaseId = releaseIdFromFetchOptions != null ? releaseIdFromFetchOptions : releaseIdFromSearchParams;
564
576
  try {
565
577
  result = await retrieveRouteByPath({
566
578
  path: value,
@@ -625,23 +637,16 @@ var determineState = async ({ searchParams }) => {
625
637
  searchParams
626
638
  });
627
639
  const previewEnvironment = isOnVercelPreviewEnvironment();
628
- const isDevelopment = isDevelopmentEnvironment();
629
640
  const isCanvasEditing = isIncontextEditingEnabled({
630
641
  searchParams
631
642
  });
632
- let states;
633
- if (isCanvasEditing) {
634
- states = [import_canvas4.CANVAS_EDITOR_STATE, import_canvas4.CANVAS_DRAFT_STATE];
635
- } else {
636
- states = isDraftMode || previewEnvironment || isDevelopment ? [import_canvas4.CANVAS_DRAFT_STATE] : [import_canvas4.CANVAS_PUBLISHED_STATE];
637
- }
638
- return states;
643
+ return isDraftMode || previewEnvironment ? (isCanvasEditing ? [import_canvas4.CANVAS_EDITOR_STATE] : []).concat([import_canvas4.CANVAS_DRAFT_STATE]) : [import_canvas4.CANVAS_PUBLISHED_STATE];
639
644
  };
640
- var determineReleaseId = ({
645
+ var determineReleaseId = async ({
641
646
  searchParams,
642
647
  state
643
648
  }) => {
644
- const draftMode2 = isDraftModeEnabled({
649
+ const draftMode2 = await isDraftModeEnabled({
645
650
  searchParams
646
651
  });
647
652
  if (!draftMode2 || state === import_canvas4.CANVAS_PUBLISHED_STATE) {
@@ -660,18 +665,11 @@ var ContextUpdateTrigger = ({ path }) => {
660
665
  // src/components/PersonalizeClientWrapper.tsx
661
666
  var import_canvas_next_rsc_client3 = require("@uniformdev/canvas-next-rsc-client");
662
667
  var import_react3 = __toESM(require("react"));
663
- var PersonalizeClientWrapper = (props) => {
664
- return /* @__PURE__ */ import_react3.default.createElement(
665
- import_canvas_next_rsc_client3.PersonalizeClient,
666
- {
667
- component: props.component,
668
- count: props.count,
669
- slots: props.slots,
670
- trackingEventName: props.trackingEventName,
671
- algorithm: props.algorithm,
672
- indexes: []
673
- }
674
- );
668
+ var PersonalizeClientWrapper = ({
669
+ contextInstance,
670
+ ...props
671
+ }) => {
672
+ return /* @__PURE__ */ import_react3.default.createElement(import_canvas_next_rsc_client3.PersonalizeClient, { ...props, indexes: [] });
675
673
  };
676
674
 
677
675
  // src/components/PersonalizeServer.ts
@@ -710,19 +708,12 @@ var PersonalizeServer = (props) => {
710
708
  var import_canvas_next_rsc_client5 = require("@uniformdev/canvas-next-rsc-client");
711
709
  var import_canvas_next_rsc_shared4 = require("@uniformdev/canvas-next-rsc-shared");
712
710
  var import_react6 = __toESM(require("react"));
713
- var PersonalizeServerHybrid = (props) => {
714
- const { indexes } = (0, import_canvas_next_rsc_shared4.runPersonalization)(props);
715
- return /* @__PURE__ */ import_react6.default.createElement(
716
- import_canvas_next_rsc_client5.PersonalizeClient,
717
- {
718
- component: props.component,
719
- count: props.count,
720
- slots: props.slots,
721
- trackingEventName: props.trackingEventName,
722
- algorithm: props.algorithm,
723
- indexes
724
- }
725
- );
711
+ var PersonalizeServerHybrid = ({
712
+ contextInstance,
713
+ ...props
714
+ }) => {
715
+ const { indexes } = (0, import_canvas_next_rsc_shared4.runPersonalization)({ ...props, contextInstance });
716
+ return /* @__PURE__ */ import_react6.default.createElement(import_canvas_next_rsc_client5.PersonalizeClient, { ...props, indexes });
726
717
  };
727
718
 
728
719
  // src/components/TestServer.ts
@@ -780,6 +771,7 @@ var UniformComposition = async ({
780
771
  route,
781
772
  ...props
782
773
  }) => {
774
+ var _a;
783
775
  let searchParams;
784
776
  let serverContext = void 0;
785
777
  if (props.mode === "static") {
@@ -804,10 +796,10 @@ var UniformComposition = async ({
804
796
  const state = route.compositionApiResponse.state;
805
797
  if (state === import_canvas8.CANVAS_DRAFT_STATE || state === import_canvas8.CANVAS_EDITOR_STATE) {
806
798
  (0, import_canvas8.walkNodeTree)(route.compositionApiResponse.composition, (node) => {
807
- var _a, _b;
799
+ var _a2, _b;
808
800
  if (node.type === "component" && node.node.parameters) {
809
801
  const contextualEditing = node.node.parameters[import_canvas8.CANVAS_CONTEXTUAL_EDITING_PARAM];
810
- const editableFields = (_b = (_a = contextualEditing == null ? void 0 : contextualEditing.value) == null ? void 0 : _a.editableParameters) != null ? _b : [];
802
+ const editableFields = (_b = (_a2 = contextualEditing == null ? void 0 : contextualEditing.value) == null ? void 0 : _a2.editableParameters) != null ? _b : [];
811
803
  Object.keys(node.node.parameters).forEach((key) => {
812
804
  const parameter = node.node.parameters[key];
813
805
  if (parameter.type === "text") {
@@ -824,7 +816,8 @@ var UniformComposition = async ({
824
816
  composition: route.compositionApiResponse.composition,
825
817
  matchedRoute: route.matchedRoute,
826
818
  searchParams,
827
- dynamicInputs: route.dynamicInputs,
819
+ // provide default non-undefined values to avoid serialization issues
820
+ dynamicInputs: (_a = route.dynamicInputs) != null ? _a : {},
828
821
  type: "composition",
829
822
  isContextualEditing: isIncontextEditingEnabled({ searchParams }),
830
823
  isDraftMode: await isDraftModeEnabled({ searchParams }),
@@ -856,6 +849,11 @@ var UniformComposition = async ({
856
849
  },
857
850
  {}
858
851
  ),
852
+ compositionMetadata: {
853
+ compositionId: route.compositionApiResponse.composition._id,
854
+ matchedRoute: route.matchedRoute,
855
+ dynamicInputs: route.dynamicInputs
856
+ },
859
857
  quirks: {
860
858
  "vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
861
859
  "vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
@@ -1172,7 +1170,8 @@ var import_navigation2 = require("next/navigation");
1172
1170
  var import_react13 = __toESM(require("react"));
1173
1171
  var UniformPlayground = async ({ searchParams, ...rest }) => {
1174
1172
  const awaitedSearchParams = await searchParams;
1175
- if (!isDraftModeEnabled({ searchParams: awaitedSearchParams })) {
1173
+ const isDraftMode = await isDraftModeEnabled({ searchParams: awaitedSearchParams });
1174
+ if (!isDraftMode) {
1176
1175
  return /* @__PURE__ */ import_react13.default.createElement("div", null, /* @__PURE__ */ import_react13.default.createElement("h1", null, "Playground is only available in draft mode"));
1177
1176
  }
1178
1177
  const id = awaitedSearchParams["id"];
package/dist/index.mjs CHANGED
@@ -24,13 +24,12 @@ var isDraftModeEnabled = async ({
24
24
  draftModeEnabled = (await draftMode()).isEnabled;
25
25
  } catch (e) {
26
26
  }
27
- return draftModeEnabled || isIncontextEditingEnabled({ searchParams });
27
+ return draftModeEnabled;
28
28
  };
29
29
  var isIncontextEditingEnabled = ({
30
30
  searchParams
31
31
  }) => {
32
- const containsKey = typeof (searchParams == null ? void 0 : searchParams[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) !== "undefined";
33
- return containsKey;
32
+ return (searchParams == null ? void 0 : searchParams[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM]) === "true";
34
33
  };
35
34
  var determinePreviewMode = ({
36
35
  searchParams
@@ -67,9 +66,6 @@ var shouldCacheBeDisabled = async (options) => {
67
66
  if (await isDraftModeEnabled(options)) {
68
67
  return { disabled: true, reason: "DRAFT" };
69
68
  }
70
- if (isIncontextEditingEnabled(options)) {
71
- return { disabled: true, reason: "INCONTEXT" };
72
- }
73
69
  if (isDevelopmentEnvironment()) {
74
70
  return { disabled: true, reason: "DEV" };
75
71
  }
@@ -154,9 +150,18 @@ var env = {
154
150
  };
155
151
 
156
152
  // src/utils/tag.ts
153
+ var encodePathForTag = (path) => {
154
+ return path.split("/").map((segment) => {
155
+ if (/[^\x00-\x7F]/.test(segment)) {
156
+ return encodeURIComponent(segment);
157
+ }
158
+ return segment;
159
+ }).join("/");
160
+ };
157
161
  var buildPathTag = (path) => {
158
162
  const actualPath = path.startsWith("/") ? path : `/${path}`;
159
- return `path:${actualPath}`.toLowerCase();
163
+ const encodedPath = encodePathForTag(actualPath);
164
+ return `path:${encodedPath}`.toLowerCase();
160
165
  };
161
166
  var buildCompositionTag = (compositionId) => {
162
167
  return `composition:${compositionId}`.toLowerCase();
@@ -529,10 +534,17 @@ var retrieveRoute = async ({ params, searchParams: providedSearchParams, skipPre
529
534
  let result;
530
535
  for (let i = 0; i < states.length; i++) {
531
536
  const state = states[i];
532
- const releaseId = determineReleaseId({
537
+ const releaseIdFromSearchParams = await determineReleaseId({
533
538
  searchParams,
534
539
  state
535
540
  });
541
+ const releaseIdFromFetchOptions = fetchOptions == null ? void 0 : fetchOptions.releaseId;
542
+ if (releaseIdFromSearchParams && releaseIdFromFetchOptions && releaseIdFromSearchParams !== releaseIdFromFetchOptions) {
543
+ console.warn(
544
+ "retrieveRoute: releaseId provided in both searchParams and fetchOptions, using fetchOptions"
545
+ );
546
+ }
547
+ const releaseId = releaseIdFromFetchOptions != null ? releaseIdFromFetchOptions : releaseIdFromSearchParams;
536
548
  try {
537
549
  result = await retrieveRouteByPath({
538
550
  path: value,
@@ -597,23 +609,16 @@ var determineState = async ({ searchParams }) => {
597
609
  searchParams
598
610
  });
599
611
  const previewEnvironment = isOnVercelPreviewEnvironment();
600
- const isDevelopment = isDevelopmentEnvironment();
601
612
  const isCanvasEditing = isIncontextEditingEnabled({
602
613
  searchParams
603
614
  });
604
- let states;
605
- if (isCanvasEditing) {
606
- states = [CANVAS_EDITOR_STATE, CANVAS_DRAFT_STATE];
607
- } else {
608
- states = isDraftMode || previewEnvironment || isDevelopment ? [CANVAS_DRAFT_STATE] : [CANVAS_PUBLISHED_STATE];
609
- }
610
- return states;
615
+ return isDraftMode || previewEnvironment ? (isCanvasEditing ? [CANVAS_EDITOR_STATE] : []).concat([CANVAS_DRAFT_STATE]) : [CANVAS_PUBLISHED_STATE];
611
616
  };
612
- var determineReleaseId = ({
617
+ var determineReleaseId = async ({
613
618
  searchParams,
614
619
  state
615
620
  }) => {
616
- const draftMode2 = isDraftModeEnabled({
621
+ const draftMode2 = await isDraftModeEnabled({
617
622
  searchParams
618
623
  });
619
624
  if (!draftMode2 || state === CANVAS_PUBLISHED_STATE) {
@@ -632,18 +637,11 @@ var ContextUpdateTrigger = ({ path }) => {
632
637
  // src/components/PersonalizeClientWrapper.tsx
633
638
  import { PersonalizeClient } from "@uniformdev/canvas-next-rsc-client";
634
639
  import React3 from "react";
635
- var PersonalizeClientWrapper = (props) => {
636
- return /* @__PURE__ */ React3.createElement(
637
- PersonalizeClient,
638
- {
639
- component: props.component,
640
- count: props.count,
641
- slots: props.slots,
642
- trackingEventName: props.trackingEventName,
643
- algorithm: props.algorithm,
644
- indexes: []
645
- }
646
- );
640
+ var PersonalizeClientWrapper = ({
641
+ contextInstance,
642
+ ...props
643
+ }) => {
644
+ return /* @__PURE__ */ React3.createElement(PersonalizeClient, { ...props, indexes: [] });
647
645
  };
648
646
 
649
647
  // src/components/PersonalizeServer.ts
@@ -682,19 +680,12 @@ var PersonalizeServer = (props) => {
682
680
  import { PersonalizeClient as PersonalizeClient2 } from "@uniformdev/canvas-next-rsc-client";
683
681
  import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
684
682
  import React5 from "react";
685
- var PersonalizeServerHybrid = (props) => {
686
- const { indexes } = runPersonalization2(props);
687
- return /* @__PURE__ */ React5.createElement(
688
- PersonalizeClient2,
689
- {
690
- component: props.component,
691
- count: props.count,
692
- slots: props.slots,
693
- trackingEventName: props.trackingEventName,
694
- algorithm: props.algorithm,
695
- indexes
696
- }
697
- );
683
+ var PersonalizeServerHybrid = ({
684
+ contextInstance,
685
+ ...props
686
+ }) => {
687
+ const { indexes } = runPersonalization2({ ...props, contextInstance });
688
+ return /* @__PURE__ */ React5.createElement(PersonalizeClient2, { ...props, indexes });
698
689
  };
699
690
 
700
691
  // src/components/TestServer.ts
@@ -757,6 +748,7 @@ var UniformComposition = async ({
757
748
  route,
758
749
  ...props
759
750
  }) => {
751
+ var _a;
760
752
  let searchParams;
761
753
  let serverContext = void 0;
762
754
  if (props.mode === "static") {
@@ -781,10 +773,10 @@ var UniformComposition = async ({
781
773
  const state = route.compositionApiResponse.state;
782
774
  if (state === CANVAS_DRAFT_STATE2 || state === CANVAS_EDITOR_STATE2) {
783
775
  walkNodeTree(route.compositionApiResponse.composition, (node) => {
784
- var _a, _b;
776
+ var _a2, _b;
785
777
  if (node.type === "component" && node.node.parameters) {
786
778
  const contextualEditing = node.node.parameters[CANVAS_CONTEXTUAL_EDITING_PARAM];
787
- const editableFields = (_b = (_a = contextualEditing == null ? void 0 : contextualEditing.value) == null ? void 0 : _a.editableParameters) != null ? _b : [];
779
+ const editableFields = (_b = (_a2 = contextualEditing == null ? void 0 : contextualEditing.value) == null ? void 0 : _a2.editableParameters) != null ? _b : [];
788
780
  Object.keys(node.node.parameters).forEach((key) => {
789
781
  const parameter = node.node.parameters[key];
790
782
  if (parameter.type === "text") {
@@ -801,7 +793,8 @@ var UniformComposition = async ({
801
793
  composition: route.compositionApiResponse.composition,
802
794
  matchedRoute: route.matchedRoute,
803
795
  searchParams,
804
- dynamicInputs: route.dynamicInputs,
796
+ // provide default non-undefined values to avoid serialization issues
797
+ dynamicInputs: (_a = route.dynamicInputs) != null ? _a : {},
805
798
  type: "composition",
806
799
  isContextualEditing: isIncontextEditingEnabled({ searchParams }),
807
800
  isDraftMode: await isDraftModeEnabled({ searchParams }),
@@ -833,6 +826,11 @@ var UniformComposition = async ({
833
826
  },
834
827
  {}
835
828
  ),
829
+ compositionMetadata: {
830
+ compositionId: route.compositionApiResponse.composition._id,
831
+ matchedRoute: route.matchedRoute,
832
+ dynamicInputs: route.dynamicInputs
833
+ },
836
834
  quirks: {
837
835
  "vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
838
836
  "vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
@@ -1152,7 +1150,8 @@ import { notFound as notFound2 } from "next/navigation";
1152
1150
  import React10 from "react";
1153
1151
  var UniformPlayground = async ({ searchParams, ...rest }) => {
1154
1152
  const awaitedSearchParams = await searchParams;
1155
- if (!isDraftModeEnabled({ searchParams: awaitedSearchParams })) {
1153
+ const isDraftMode = await isDraftModeEnabled({ searchParams: awaitedSearchParams });
1154
+ if (!isDraftMode) {
1156
1155
  return /* @__PURE__ */ React10.createElement("div", null, /* @__PURE__ */ React10.createElement("h1", null, "Playground is only available in draft mode"));
1157
1156
  }
1158
1157
  const id = awaitedSearchParams["id"];
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc",
3
- "version": "20.6.2-alpha.11+af78064791",
3
+ "version": "20.7.1-alpha.102+d621aa22b2",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
7
7
  "dev": "tsup --watch",
8
8
  "lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
9
- "test": "jest --maxWorkers=1 --passWithNoTests"
9
+ "test": "jest --maxWorkers=1 --passWithNoTests",
10
+ "document": "api-extractor run --local"
10
11
  },
11
12
  "sideEffects": false,
12
13
  "main": "dist/index.js",
@@ -18,9 +19,9 @@
18
19
  "import": "./dist/index.esm.js"
19
20
  },
20
21
  "./handler": {
22
+ "types": "./dist/handler.d.ts",
21
23
  "require": "./dist/handler.js",
22
- "import": "./dist/handler.mjs",
23
- "types": "./dist/handler.d.ts"
24
+ "import": "./dist/handler.mjs"
24
25
  },
25
26
  "./config": {
26
27
  "types": "./dist/config.d.ts",
@@ -53,23 +54,22 @@
53
54
  "/dist"
54
55
  ],
55
56
  "devDependencies": {
56
- "@types/node": "22.7.8",
57
- "@types/react": "18.3.11",
58
- "eslint": "9.9.0",
59
- "next": "15.1.0",
57
+ "@types/node": "24.3.1",
58
+ "@types/react": "18.3.24",
59
+ "next": "15.2.5",
60
60
  "react": "18.3.1",
61
61
  "react-dom": "18.3.1"
62
62
  },
63
63
  "dependencies": {
64
- "@uniformdev/canvas": "20.6.2-alpha.11+af78064791",
65
- "@uniformdev/canvas-next-rsc-client": "^20.6.2-alpha.11+af78064791",
66
- "@uniformdev/canvas-next-rsc-shared": "^20.6.2-alpha.11+af78064791",
67
- "@uniformdev/canvas-react": "20.6.2-alpha.11+af78064791",
68
- "@uniformdev/context": "20.6.2-alpha.11+af78064791",
69
- "@uniformdev/project-map": "20.6.2-alpha.11+af78064791",
70
- "@uniformdev/redirect": "20.6.2-alpha.11+af78064791",
71
- "@uniformdev/richtext": "20.6.2-alpha.11+af78064791",
72
- "@uniformdev/webhooks": "20.6.2-alpha.11+af78064791",
64
+ "@uniformdev/canvas": "20.7.1-alpha.102+d621aa22b2",
65
+ "@uniformdev/canvas-next-rsc-client": "^20.7.1-alpha.102+d621aa22b2",
66
+ "@uniformdev/canvas-next-rsc-shared": "^20.7.1-alpha.102+d621aa22b2",
67
+ "@uniformdev/canvas-react": "20.7.1-alpha.102+d621aa22b2",
68
+ "@uniformdev/context": "20.7.1-alpha.102+d621aa22b2",
69
+ "@uniformdev/project-map": "20.7.1-alpha.102+d621aa22b2",
70
+ "@uniformdev/redirect": "20.7.1-alpha.102+d621aa22b2",
71
+ "@uniformdev/richtext": "20.7.1-alpha.102+d621aa22b2",
72
+ "@uniformdev/webhooks": "20.7.1-alpha.102+d621aa22b2",
73
73
  "@vercel/edge-config": "^0.4.0",
74
74
  "encoding": "^0.1.13",
75
75
  "server-only": "^0.0.1",
@@ -79,12 +79,12 @@
79
79
  "node": "^18.18.0 || ^19.8.0 || >= 20.0.0"
80
80
  },
81
81
  "peerDependencies": {
82
- "next": ">=15.1.0",
82
+ "next": ">=15.2.3",
83
83
  "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
84
84
  "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0"
85
85
  },
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "af78064791c47044f8ba447bbe1221f672f6de3e"
89
+ "gitHead": "d621aa22b220347565e307b064fb1eda8963abbe"
90
90
  }