@uniformdev/canvas-next-rsc-client 19.198.3-alpha.5 → 19.199.1-alpha.10

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/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
- import { ManifestV2, TestEvent, ContextOptions, Quirks, ScoreVector } from '@uniformdev/context';
1
+ import { ManifestV2, TestEvent, Quirks, ScoreVector } from '@uniformdev/context';
2
2
  import { PersonalizationEvent } from '@uniformdev/context/*';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { PureContextualEditingComponentWrapperProps } from '@uniformdev/canvas-react/core';
5
5
  import * as react from 'react';
6
6
  import { PropsWithChildren } from 'react';
7
7
  import * as _uniformdev_canvas_next_rsc_shared from '@uniformdev/canvas-next-rsc-shared';
8
- import { AppDirectoryContextState, PersonalizeProps, ComponentProps, TestProps, AppDirectoryContext } from '@uniformdev/canvas-next-rsc-shared';
9
- import { VisibilityParameterValue } from '@uniformdev/canvas';
8
+ import { AppDirectoryContextState, PersonalizeProps, ComponentProps, TestProps, CreateUniformContextOptions, AppDirectoryContext } from '@uniformdev/canvas-next-rsc-shared';
9
+ import { VisibilityParameterValue, ComponentInstance, UpdateContextualEditingStateInternalMessage } from '@uniformdev/canvas';
10
10
 
11
11
  type ClientContextComponentProps = {
12
12
  /**
@@ -21,6 +21,11 @@ type ClientContextComponentProps = {
21
21
  * The default consent value
22
22
  */
23
23
  defaultConsent: boolean;
24
+ /**
25
+ * @deprecated
26
+ * Whether or not to enable the experimental quirk serialization
27
+ */
28
+ experimentalQuirkSerialization: boolean;
24
29
  };
25
30
  type ClientContextComponent = (props: ClientContextComponentProps) => JSX.Element | null;
26
31
 
@@ -49,8 +54,10 @@ declare const DefaultUniformClientContext: ClientContextComponent;
49
54
 
50
55
  type PersonalizeClientProps = PersonalizeProps & {
51
56
  indexes: number[];
57
+ slots: ComponentProps['slots'];
58
+ component: ComponentProps['component'];
52
59
  };
53
- declare const PersonalizeClient: (props: ComponentProps<PersonalizeClientProps>) => react.FunctionComponentElement<{
60
+ declare const PersonalizeClient: (props: PersonalizeClientProps) => react.FunctionComponentElement<{
54
61
  children?: react.ReactNode | undefined;
55
62
  }>;
56
63
 
@@ -65,7 +72,7 @@ declare const VisibilityRulesWrapperClient: ({ parameter, initialIsVisible, chil
65
72
  initialIsVisible: boolean | null;
66
73
  }>) => react_jsx_runtime.JSX.Element | null;
67
74
 
68
- type CreateClientUniformContextOptions = Omit<ContextOptions, 'transitionStore'>;
75
+ type CreateClientUniformContextOptions = Omit<CreateUniformContextOptions, 'serverCookieValue'>;
69
76
  declare const createClientUniformContext: (options: CreateClientUniformContextOptions) => _uniformdev_canvas_next_rsc_shared.AppDirectoryContextInstance;
70
77
 
71
78
  declare const useInitUniformContext: (callback: () => AppDirectoryContext) => void;
@@ -91,4 +98,22 @@ declare const useUniformContext: () => {
91
98
  context: AppDirectoryContext | undefined;
92
99
  };
93
100
 
94
- export { type ClientContextComponent, type ClientContextComponentProps, ClientContextPersonalizationTransfer, ClientContextTestTransfer, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, type CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, type PersonalizeClientProps, TestClient, UniformScript, VisibilityRulesWrapperClient, createClientUniformContext, useInitUniformContext, useQuirks, useScores, useUniformContext };
101
+ type UseUniformContextualEditingStateProps = {
102
+ /**
103
+ * When not set, the hook will return the global contextual state no matter where its used.
104
+ * When set, it will return only the state relevant to the component passed.
105
+ * @default undefined
106
+ **/
107
+ scope?: ComponentInstance;
108
+ };
109
+ type UseUniformContextualEditingStateReturnType = {
110
+ /**
111
+ * A reference to the currently selected component in Canvas editor.
112
+ * Returns `undefined` if the selected component is not part of the current React component.
113
+ * Set the `scope` option a component instance to limit the scope of selected compponents.
114
+ */
115
+ selectedComponentReference: UpdateContextualEditingStateInternalMessage['state']['selectedComponentReference'];
116
+ };
117
+ declare const useUniformContextualEditingState: ({ scope, }?: UseUniformContextualEditingStateProps) => UseUniformContextualEditingStateReturnType;
118
+
119
+ export { type ClientContextComponent, type ClientContextComponentProps, ClientContextPersonalizationTransfer, ClientContextTestTransfer, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, type CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, type PersonalizeClientProps, TestClient, UniformScript, type UseUniformContextualEditingStateProps, type UseUniformContextualEditingStateReturnType, VisibilityRulesWrapperClient, createClientUniformContext, useInitUniformContext, useQuirks, useScores, useUniformContext, useUniformContextualEditingState };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { ManifestV2, TestEvent, ContextOptions, Quirks, ScoreVector } from '@uniformdev/context';
1
+ import { ManifestV2, TestEvent, Quirks, ScoreVector } from '@uniformdev/context';
2
2
  import { PersonalizationEvent } from '@uniformdev/context/*';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { PureContextualEditingComponentWrapperProps } from '@uniformdev/canvas-react/core';
5
5
  import * as react from 'react';
6
6
  import { PropsWithChildren } from 'react';
7
7
  import * as _uniformdev_canvas_next_rsc_shared from '@uniformdev/canvas-next-rsc-shared';
8
- import { AppDirectoryContextState, PersonalizeProps, ComponentProps, TestProps, AppDirectoryContext } from '@uniformdev/canvas-next-rsc-shared';
9
- import { VisibilityParameterValue } from '@uniformdev/canvas';
8
+ import { AppDirectoryContextState, PersonalizeProps, ComponentProps, TestProps, CreateUniformContextOptions, AppDirectoryContext } from '@uniformdev/canvas-next-rsc-shared';
9
+ import { VisibilityParameterValue, ComponentInstance, UpdateContextualEditingStateInternalMessage } from '@uniformdev/canvas';
10
10
 
11
11
  type ClientContextComponentProps = {
12
12
  /**
@@ -21,6 +21,11 @@ type ClientContextComponentProps = {
21
21
  * The default consent value
22
22
  */
23
23
  defaultConsent: boolean;
24
+ /**
25
+ * @deprecated
26
+ * Whether or not to enable the experimental quirk serialization
27
+ */
28
+ experimentalQuirkSerialization: boolean;
24
29
  };
25
30
  type ClientContextComponent = (props: ClientContextComponentProps) => JSX.Element | null;
26
31
 
@@ -49,8 +54,10 @@ declare const DefaultUniformClientContext: ClientContextComponent;
49
54
 
50
55
  type PersonalizeClientProps = PersonalizeProps & {
51
56
  indexes: number[];
57
+ slots: ComponentProps['slots'];
58
+ component: ComponentProps['component'];
52
59
  };
53
- declare const PersonalizeClient: (props: ComponentProps<PersonalizeClientProps>) => react.FunctionComponentElement<{
60
+ declare const PersonalizeClient: (props: PersonalizeClientProps) => react.FunctionComponentElement<{
54
61
  children?: react.ReactNode | undefined;
55
62
  }>;
56
63
 
@@ -65,7 +72,7 @@ declare const VisibilityRulesWrapperClient: ({ parameter, initialIsVisible, chil
65
72
  initialIsVisible: boolean | null;
66
73
  }>) => react_jsx_runtime.JSX.Element | null;
67
74
 
68
- type CreateClientUniformContextOptions = Omit<ContextOptions, 'transitionStore'>;
75
+ type CreateClientUniformContextOptions = Omit<CreateUniformContextOptions, 'serverCookieValue'>;
69
76
  declare const createClientUniformContext: (options: CreateClientUniformContextOptions) => _uniformdev_canvas_next_rsc_shared.AppDirectoryContextInstance;
70
77
 
71
78
  declare const useInitUniformContext: (callback: () => AppDirectoryContext) => void;
@@ -91,4 +98,22 @@ declare const useUniformContext: () => {
91
98
  context: AppDirectoryContext | undefined;
92
99
  };
93
100
 
94
- export { type ClientContextComponent, type ClientContextComponentProps, ClientContextPersonalizationTransfer, ClientContextTestTransfer, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, type CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, type PersonalizeClientProps, TestClient, UniformScript, VisibilityRulesWrapperClient, createClientUniformContext, useInitUniformContext, useQuirks, useScores, useUniformContext };
101
+ type UseUniformContextualEditingStateProps = {
102
+ /**
103
+ * When not set, the hook will return the global contextual state no matter where its used.
104
+ * When set, it will return only the state relevant to the component passed.
105
+ * @default undefined
106
+ **/
107
+ scope?: ComponentInstance;
108
+ };
109
+ type UseUniformContextualEditingStateReturnType = {
110
+ /**
111
+ * A reference to the currently selected component in Canvas editor.
112
+ * Returns `undefined` if the selected component is not part of the current React component.
113
+ * Set the `scope` option a component instance to limit the scope of selected compponents.
114
+ */
115
+ selectedComponentReference: UpdateContextualEditingStateInternalMessage['state']['selectedComponentReference'];
116
+ };
117
+ declare const useUniformContextualEditingState: ({ scope, }?: UseUniformContextualEditingStateProps) => UseUniformContextualEditingStateReturnType;
118
+
119
+ export { type ClientContextComponent, type ClientContextComponentProps, ClientContextPersonalizationTransfer, ClientContextTestTransfer, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, type CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, type PersonalizeClientProps, TestClient, UniformScript, type UseUniformContextualEditingStateProps, type UseUniformContextualEditingStateReturnType, VisibilityRulesWrapperClient, createClientUniformContext, useInitUniformContext, useQuirks, useScores, useUniformContext, useUniformContextualEditingState };
package/dist/index.esm.js CHANGED
@@ -570,9 +570,13 @@ for (let i = 0; i < alphabet.length; i++) {
570
570
  s2b[alphabet.charCodeAt(i)] = i;
571
571
  }
572
572
  var _cookieName;
573
+ var _quirkCookieName;
573
574
  var _cookieAttributes;
575
+ var _quirksEnabled;
574
576
  _cookieName = /* @__PURE__ */ new WeakMap();
577
+ _quirkCookieName = /* @__PURE__ */ new WeakMap();
575
578
  _cookieAttributes = /* @__PURE__ */ new WeakMap();
579
+ _quirksEnabled = /* @__PURE__ */ new WeakMap();
576
580
  var _EdgeTransitionDataStore_instances;
577
581
  var fetchData_fn;
578
582
  _EdgeTransitionDataStore_instances = /* @__PURE__ */ new WeakSet();
@@ -722,6 +726,7 @@ var _state;
722
726
  var _pzCache;
723
727
  var _plugins;
724
728
  var _commands;
729
+ var _requireConsentForPersonalization;
725
730
  var _mitt3;
726
731
  var _Context_instances;
727
732
  var emitTest_fn;
@@ -734,6 +739,7 @@ _state = /* @__PURE__ */ new WeakMap();
734
739
  _pzCache = /* @__PURE__ */ new WeakMap();
735
740
  _plugins = /* @__PURE__ */ new WeakMap();
736
741
  _commands = /* @__PURE__ */ new WeakMap();
742
+ _requireConsentForPersonalization = /* @__PURE__ */ new WeakMap();
737
743
  _mitt3 = /* @__PURE__ */ new WeakMap();
738
744
  _Context_instances = /* @__PURE__ */ new WeakSet();
739
745
  emitTest_fn = function(event) {
@@ -907,7 +913,8 @@ var useInitUniformContext = (callback) => {
907
913
  var DefaultUniformClientContext = ({
908
914
  manifest,
909
915
  disableDevTools,
910
- defaultConsent
916
+ defaultConsent,
917
+ experimentalQuirkSerialization
911
918
  }) => {
912
919
  const router = useRouter();
913
920
  useInitUniformContext(() => {
@@ -924,7 +931,8 @@ var DefaultUniformClientContext = ({
924
931
  return createClientUniformContext({
925
932
  manifest,
926
933
  plugins,
927
- defaultConsent
934
+ defaultConsent,
935
+ experimental_quirksEnabled: experimentalQuirkSerialization
928
936
  });
929
937
  });
930
938
  return null;
@@ -939,11 +947,21 @@ var PersonalizeClient = (props) => {
939
947
  const { context } = useUniformContext();
940
948
  const [indexesToShow, setIndexesToShow] = useState6(props.indexes);
941
949
  useEffect7(() => {
942
- const result = runPersonalization({
943
- ...props,
944
- contextInstance: context
945
- });
946
- setIndexesToShow(result.indexes);
950
+ if (!context) {
951
+ return;
952
+ }
953
+ const handleRunPersonalization = () => {
954
+ const result = runPersonalization({
955
+ ...props,
956
+ contextInstance: context
957
+ });
958
+ setIndexesToShow(result.indexes);
959
+ };
960
+ context.events.on("scoresUpdated", handleRunPersonalization);
961
+ handleRunPersonalization();
962
+ return () => {
963
+ context.events.off("scoresUpdated", handleRunPersonalization);
964
+ };
947
965
  }, [props, context]);
948
966
  const slotsToShow = indexesToShow.map((key) => {
949
967
  var _a;
@@ -1135,6 +1153,47 @@ function useScores() {
1135
1153
  }, [context]);
1136
1154
  return scores;
1137
1155
  }
1156
+
1157
+ // src/hooks/useUniformContextualEditingState.ts
1158
+ import {
1159
+ createCanvasChannel as createCanvasChannel2,
1160
+ isUpdateContextualEditingStateInternalMessage
1161
+ } from "@uniformdev/canvas";
1162
+ import { useEffect as useEffect12, useMemo as useMemo4, useState as useState10 } from "react";
1163
+ var useUniformContextualEditingState = ({
1164
+ scope
1165
+ } = {}) => {
1166
+ const [selectedComponentReference, setSelectedComponentReference] = useState10();
1167
+ const channel = useMemo4(() => {
1168
+ const channel2 = createCanvasChannel2({
1169
+ broadcastTo: [window],
1170
+ listenTo: [window]
1171
+ });
1172
+ return channel2;
1173
+ }, []);
1174
+ useEffect12(() => {
1175
+ if (!channel) {
1176
+ return;
1177
+ }
1178
+ const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
1179
+ var _a;
1180
+ if (!isUpdateContextualEditingStateInternalMessage(message)) {
1181
+ return;
1182
+ }
1183
+ if (!!scope && (scope == null ? void 0 : scope._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
1184
+ setSelectedComponentReference(void 0);
1185
+ return;
1186
+ }
1187
+ setSelectedComponentReference(message.state.selectedComponentReference);
1188
+ });
1189
+ return () => {
1190
+ unsubscribe();
1191
+ };
1192
+ }, [scope, channel]);
1193
+ return {
1194
+ selectedComponentReference
1195
+ };
1196
+ };
1138
1197
  export {
1139
1198
  ClientContextPersonalizationTransfer,
1140
1199
  ClientContextTestTransfer,
@@ -1150,7 +1209,8 @@ export {
1150
1209
  useInitUniformContext,
1151
1210
  useQuirks,
1152
1211
  useScores,
1153
- useUniformContext
1212
+ useUniformContext,
1213
+ useUniformContextualEditingState
1154
1214
  };
1155
1215
  /*! Bundled license information:
1156
1216
 
package/dist/index.js CHANGED
@@ -237,7 +237,8 @@ __export(src_exports, {
237
237
  useInitUniformContext: () => useInitUniformContext,
238
238
  useQuirks: () => useQuirks,
239
239
  useScores: () => useScores,
240
- useUniformContext: () => useUniformContext
240
+ useUniformContext: () => useUniformContext,
241
+ useUniformContextualEditingState: () => useUniformContextualEditingState
241
242
  });
242
243
  module.exports = __toCommonJS(src_exports);
243
244
 
@@ -595,9 +596,13 @@ for (let i = 0; i < alphabet.length; i++) {
595
596
  s2b[alphabet.charCodeAt(i)] = i;
596
597
  }
597
598
  var _cookieName;
599
+ var _quirkCookieName;
598
600
  var _cookieAttributes;
601
+ var _quirksEnabled;
599
602
  _cookieName = /* @__PURE__ */ new WeakMap();
603
+ _quirkCookieName = /* @__PURE__ */ new WeakMap();
600
604
  _cookieAttributes = /* @__PURE__ */ new WeakMap();
605
+ _quirksEnabled = /* @__PURE__ */ new WeakMap();
601
606
  var _EdgeTransitionDataStore_instances;
602
607
  var fetchData_fn;
603
608
  _EdgeTransitionDataStore_instances = /* @__PURE__ */ new WeakSet();
@@ -747,6 +752,7 @@ var _state;
747
752
  var _pzCache;
748
753
  var _plugins;
749
754
  var _commands;
755
+ var _requireConsentForPersonalization;
750
756
  var _mitt3;
751
757
  var _Context_instances;
752
758
  var emitTest_fn;
@@ -759,6 +765,7 @@ _state = /* @__PURE__ */ new WeakMap();
759
765
  _pzCache = /* @__PURE__ */ new WeakMap();
760
766
  _plugins = /* @__PURE__ */ new WeakMap();
761
767
  _commands = /* @__PURE__ */ new WeakMap();
768
+ _requireConsentForPersonalization = /* @__PURE__ */ new WeakMap();
762
769
  _mitt3 = /* @__PURE__ */ new WeakMap();
763
770
  _Context_instances = /* @__PURE__ */ new WeakSet();
764
771
  emitTest_fn = function(event) {
@@ -932,7 +939,8 @@ var useInitUniformContext = (callback) => {
932
939
  var DefaultUniformClientContext = ({
933
940
  manifest,
934
941
  disableDevTools,
935
- defaultConsent
942
+ defaultConsent,
943
+ experimentalQuirkSerialization
936
944
  }) => {
937
945
  const router = (0, import_navigation3.useRouter)();
938
946
  useInitUniformContext(() => {
@@ -949,7 +957,8 @@ var DefaultUniformClientContext = ({
949
957
  return createClientUniformContext({
950
958
  manifest,
951
959
  plugins,
952
- defaultConsent
960
+ defaultConsent,
961
+ experimental_quirksEnabled: experimentalQuirkSerialization
953
962
  });
954
963
  });
955
964
  return null;
@@ -964,11 +973,21 @@ var PersonalizeClient = (props) => {
964
973
  const { context } = useUniformContext();
965
974
  const [indexesToShow, setIndexesToShow] = (0, import_react8.useState)(props.indexes);
966
975
  (0, import_react8.useEffect)(() => {
967
- const result = (0, import_canvas_next_rsc_shared2.runPersonalization)({
968
- ...props,
969
- contextInstance: context
970
- });
971
- setIndexesToShow(result.indexes);
976
+ if (!context) {
977
+ return;
978
+ }
979
+ const handleRunPersonalization = () => {
980
+ const result = (0, import_canvas_next_rsc_shared2.runPersonalization)({
981
+ ...props,
982
+ contextInstance: context
983
+ });
984
+ setIndexesToShow(result.indexes);
985
+ };
986
+ context.events.on("scoresUpdated", handleRunPersonalization);
987
+ handleRunPersonalization();
988
+ return () => {
989
+ context.events.off("scoresUpdated", handleRunPersonalization);
990
+ };
972
991
  }, [props, context]);
973
992
  const slotsToShow = indexesToShow.map((key) => {
974
993
  var _a;
@@ -1153,6 +1172,44 @@ function useScores() {
1153
1172
  }, [context]);
1154
1173
  return scores;
1155
1174
  }
1175
+
1176
+ // src/hooks/useUniformContextualEditingState.ts
1177
+ var import_canvas6 = require("@uniformdev/canvas");
1178
+ var import_react14 = require("react");
1179
+ var useUniformContextualEditingState = ({
1180
+ scope
1181
+ } = {}) => {
1182
+ const [selectedComponentReference, setSelectedComponentReference] = (0, import_react14.useState)();
1183
+ const channel = (0, import_react14.useMemo)(() => {
1184
+ const channel2 = (0, import_canvas6.createCanvasChannel)({
1185
+ broadcastTo: [window],
1186
+ listenTo: [window]
1187
+ });
1188
+ return channel2;
1189
+ }, []);
1190
+ (0, import_react14.useEffect)(() => {
1191
+ if (!channel) {
1192
+ return;
1193
+ }
1194
+ const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
1195
+ var _a;
1196
+ if (!(0, import_canvas6.isUpdateContextualEditingStateInternalMessage)(message)) {
1197
+ return;
1198
+ }
1199
+ if (!!scope && (scope == null ? void 0 : scope._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
1200
+ setSelectedComponentReference(void 0);
1201
+ return;
1202
+ }
1203
+ setSelectedComponentReference(message.state.selectedComponentReference);
1204
+ });
1205
+ return () => {
1206
+ unsubscribe();
1207
+ };
1208
+ }, [scope, channel]);
1209
+ return {
1210
+ selectedComponentReference
1211
+ };
1212
+ };
1156
1213
  // Annotate the CommonJS export names for ESM import in node:
1157
1214
  0 && (module.exports = {
1158
1215
  ClientContextPersonalizationTransfer,
@@ -1169,7 +1226,8 @@ function useScores() {
1169
1226
  useInitUniformContext,
1170
1227
  useQuirks,
1171
1228
  useScores,
1172
- useUniformContext
1229
+ useUniformContext,
1230
+ useUniformContextualEditingState
1173
1231
  });
1174
1232
  /*! Bundled license information:
1175
1233
 
package/dist/index.mjs CHANGED
@@ -570,9 +570,13 @@ for (let i = 0; i < alphabet.length; i++) {
570
570
  s2b[alphabet.charCodeAt(i)] = i;
571
571
  }
572
572
  var _cookieName;
573
+ var _quirkCookieName;
573
574
  var _cookieAttributes;
575
+ var _quirksEnabled;
574
576
  _cookieName = /* @__PURE__ */ new WeakMap();
577
+ _quirkCookieName = /* @__PURE__ */ new WeakMap();
575
578
  _cookieAttributes = /* @__PURE__ */ new WeakMap();
579
+ _quirksEnabled = /* @__PURE__ */ new WeakMap();
576
580
  var _EdgeTransitionDataStore_instances;
577
581
  var fetchData_fn;
578
582
  _EdgeTransitionDataStore_instances = /* @__PURE__ */ new WeakSet();
@@ -722,6 +726,7 @@ var _state;
722
726
  var _pzCache;
723
727
  var _plugins;
724
728
  var _commands;
729
+ var _requireConsentForPersonalization;
725
730
  var _mitt3;
726
731
  var _Context_instances;
727
732
  var emitTest_fn;
@@ -734,6 +739,7 @@ _state = /* @__PURE__ */ new WeakMap();
734
739
  _pzCache = /* @__PURE__ */ new WeakMap();
735
740
  _plugins = /* @__PURE__ */ new WeakMap();
736
741
  _commands = /* @__PURE__ */ new WeakMap();
742
+ _requireConsentForPersonalization = /* @__PURE__ */ new WeakMap();
737
743
  _mitt3 = /* @__PURE__ */ new WeakMap();
738
744
  _Context_instances = /* @__PURE__ */ new WeakSet();
739
745
  emitTest_fn = function(event) {
@@ -907,7 +913,8 @@ var useInitUniformContext = (callback) => {
907
913
  var DefaultUniformClientContext = ({
908
914
  manifest,
909
915
  disableDevTools,
910
- defaultConsent
916
+ defaultConsent,
917
+ experimentalQuirkSerialization
911
918
  }) => {
912
919
  const router = useRouter();
913
920
  useInitUniformContext(() => {
@@ -924,7 +931,8 @@ var DefaultUniformClientContext = ({
924
931
  return createClientUniformContext({
925
932
  manifest,
926
933
  plugins,
927
- defaultConsent
934
+ defaultConsent,
935
+ experimental_quirksEnabled: experimentalQuirkSerialization
928
936
  });
929
937
  });
930
938
  return null;
@@ -939,11 +947,21 @@ var PersonalizeClient = (props) => {
939
947
  const { context } = useUniformContext();
940
948
  const [indexesToShow, setIndexesToShow] = useState6(props.indexes);
941
949
  useEffect7(() => {
942
- const result = runPersonalization({
943
- ...props,
944
- contextInstance: context
945
- });
946
- setIndexesToShow(result.indexes);
950
+ if (!context) {
951
+ return;
952
+ }
953
+ const handleRunPersonalization = () => {
954
+ const result = runPersonalization({
955
+ ...props,
956
+ contextInstance: context
957
+ });
958
+ setIndexesToShow(result.indexes);
959
+ };
960
+ context.events.on("scoresUpdated", handleRunPersonalization);
961
+ handleRunPersonalization();
962
+ return () => {
963
+ context.events.off("scoresUpdated", handleRunPersonalization);
964
+ };
947
965
  }, [props, context]);
948
966
  const slotsToShow = indexesToShow.map((key) => {
949
967
  var _a;
@@ -1135,6 +1153,47 @@ function useScores() {
1135
1153
  }, [context]);
1136
1154
  return scores;
1137
1155
  }
1156
+
1157
+ // src/hooks/useUniformContextualEditingState.ts
1158
+ import {
1159
+ createCanvasChannel as createCanvasChannel2,
1160
+ isUpdateContextualEditingStateInternalMessage
1161
+ } from "@uniformdev/canvas";
1162
+ import { useEffect as useEffect12, useMemo as useMemo4, useState as useState10 } from "react";
1163
+ var useUniformContextualEditingState = ({
1164
+ scope
1165
+ } = {}) => {
1166
+ const [selectedComponentReference, setSelectedComponentReference] = useState10();
1167
+ const channel = useMemo4(() => {
1168
+ const channel2 = createCanvasChannel2({
1169
+ broadcastTo: [window],
1170
+ listenTo: [window]
1171
+ });
1172
+ return channel2;
1173
+ }, []);
1174
+ useEffect12(() => {
1175
+ if (!channel) {
1176
+ return;
1177
+ }
1178
+ const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
1179
+ var _a;
1180
+ if (!isUpdateContextualEditingStateInternalMessage(message)) {
1181
+ return;
1182
+ }
1183
+ if (!!scope && (scope == null ? void 0 : scope._id) !== ((_a = message.state.selectedComponentReference) == null ? void 0 : _a.parentId)) {
1184
+ setSelectedComponentReference(void 0);
1185
+ return;
1186
+ }
1187
+ setSelectedComponentReference(message.state.selectedComponentReference);
1188
+ });
1189
+ return () => {
1190
+ unsubscribe();
1191
+ };
1192
+ }, [scope, channel]);
1193
+ return {
1194
+ selectedComponentReference
1195
+ };
1196
+ };
1138
1197
  export {
1139
1198
  ClientContextPersonalizationTransfer,
1140
1199
  ClientContextTestTransfer,
@@ -1150,7 +1209,8 @@ export {
1150
1209
  useInitUniformContext,
1151
1210
  useQuirks,
1152
1211
  useScores,
1153
- useUniformContext
1212
+ useUniformContext,
1213
+ useUniformContextualEditingState
1154
1214
  };
1155
1215
  /*! Bundled license information:
1156
1216
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc-client",
3
- "version": "19.198.3-alpha.5+c37bbd4ef2",
3
+ "version": "19.199.1-alpha.10+7f62130189",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -24,17 +24,17 @@
24
24
  "/dist"
25
25
  ],
26
26
  "devDependencies": {
27
- "@types/node": "20.10.6",
28
- "@types/react": "18.3.3",
27
+ "@types/node": "22.7.8",
28
+ "@types/react": "18.3.11",
29
29
  "eslint": "9.9.0",
30
30
  "next": "^14.0.0",
31
31
  "react": "18.3.1",
32
32
  "react-dom": "18.3.1"
33
33
  },
34
34
  "dependencies": {
35
- "@uniformdev/canvas": "19.198.3-alpha.5+c37bbd4ef2",
36
- "@uniformdev/canvas-next-rsc-shared": "^19.198.3-alpha.5+c37bbd4ef2",
37
- "@uniformdev/canvas-react": "^19.198.3-alpha.5+c37bbd4ef2"
35
+ "@uniformdev/canvas": "19.199.1-alpha.10+7f62130189",
36
+ "@uniformdev/canvas-next-rsc-shared": "^19.199.1-alpha.10+7f62130189",
37
+ "@uniformdev/canvas-react": "^19.199.1-alpha.10+7f62130189"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=16.14.0"
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "c37bbd4ef2353582b4125b9dd21599634ecd5165"
50
+ "gitHead": "7f62130189d43f7ecaaed0a41c929e5c166860d2"
51
51
  }