@uniformdev/canvas-next-rsc-client 19.202.0 → 19.202.1-alpha.9
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 +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.esm.js +66 -8
- package/dist/index.js +65 -9
- package/dist/index.mjs +66 -8
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ 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
8
|
import { AppDirectoryContextState, PersonalizeProps, ComponentProps, TestProps, CreateUniformContextOptions, AppDirectoryContext } from '@uniformdev/canvas-next-rsc-shared';
|
|
9
|
-
import { VisibilityParameterValue } from '@uniformdev/canvas';
|
|
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:
|
|
60
|
+
declare const PersonalizeClient: (props: PersonalizeClientProps) => react.FunctionComponentElement<{
|
|
54
61
|
children?: react.ReactNode | undefined;
|
|
55
62
|
}>;
|
|
56
63
|
|
|
@@ -91,4 +98,22 @@ declare const useUniformContext: () => {
|
|
|
91
98
|
context: AppDirectoryContext | undefined;
|
|
92
99
|
};
|
|
93
100
|
|
|
94
|
-
|
|
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
|
@@ -6,7 +6,7 @@ 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
8
|
import { AppDirectoryContextState, PersonalizeProps, ComponentProps, TestProps, CreateUniformContextOptions, AppDirectoryContext } from '@uniformdev/canvas-next-rsc-shared';
|
|
9
|
-
import { VisibilityParameterValue } from '@uniformdev/canvas';
|
|
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:
|
|
60
|
+
declare const PersonalizeClient: (props: PersonalizeClientProps) => react.FunctionComponentElement<{
|
|
54
61
|
children?: react.ReactNode | undefined;
|
|
55
62
|
}>;
|
|
56
63
|
|
|
@@ -91,4 +98,22 @@ declare const useUniformContext: () => {
|
|
|
91
98
|
context: AppDirectoryContext | undefined;
|
|
92
99
|
};
|
|
93
100
|
|
|
94
|
-
|
|
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();
|
|
@@ -909,7 +913,8 @@ var useInitUniformContext = (callback) => {
|
|
|
909
913
|
var DefaultUniformClientContext = ({
|
|
910
914
|
manifest,
|
|
911
915
|
disableDevTools,
|
|
912
|
-
defaultConsent
|
|
916
|
+
defaultConsent,
|
|
917
|
+
experimentalQuirkSerialization
|
|
913
918
|
}) => {
|
|
914
919
|
const router = useRouter();
|
|
915
920
|
useInitUniformContext(() => {
|
|
@@ -926,7 +931,8 @@ var DefaultUniformClientContext = ({
|
|
|
926
931
|
return createClientUniformContext({
|
|
927
932
|
manifest,
|
|
928
933
|
plugins,
|
|
929
|
-
defaultConsent
|
|
934
|
+
defaultConsent,
|
|
935
|
+
experimental_quirksEnabled: experimentalQuirkSerialization
|
|
930
936
|
});
|
|
931
937
|
});
|
|
932
938
|
return null;
|
|
@@ -941,11 +947,21 @@ var PersonalizeClient = (props) => {
|
|
|
941
947
|
const { context } = useUniformContext();
|
|
942
948
|
const [indexesToShow, setIndexesToShow] = useState6(props.indexes);
|
|
943
949
|
useEffect7(() => {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
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
|
+
};
|
|
949
965
|
}, [props, context]);
|
|
950
966
|
const slotsToShow = indexesToShow.map((key) => {
|
|
951
967
|
var _a;
|
|
@@ -1137,6 +1153,47 @@ function useScores() {
|
|
|
1137
1153
|
}, [context]);
|
|
1138
1154
|
return scores;
|
|
1139
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
|
+
};
|
|
1140
1197
|
export {
|
|
1141
1198
|
ClientContextPersonalizationTransfer,
|
|
1142
1199
|
ClientContextTestTransfer,
|
|
@@ -1152,7 +1209,8 @@ export {
|
|
|
1152
1209
|
useInitUniformContext,
|
|
1153
1210
|
useQuirks,
|
|
1154
1211
|
useScores,
|
|
1155
|
-
useUniformContext
|
|
1212
|
+
useUniformContext,
|
|
1213
|
+
useUniformContextualEditingState
|
|
1156
1214
|
};
|
|
1157
1215
|
/*! Bundled license information:
|
|
1158
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();
|
|
@@ -934,7 +939,8 @@ var useInitUniformContext = (callback) => {
|
|
|
934
939
|
var DefaultUniformClientContext = ({
|
|
935
940
|
manifest,
|
|
936
941
|
disableDevTools,
|
|
937
|
-
defaultConsent
|
|
942
|
+
defaultConsent,
|
|
943
|
+
experimentalQuirkSerialization
|
|
938
944
|
}) => {
|
|
939
945
|
const router = (0, import_navigation3.useRouter)();
|
|
940
946
|
useInitUniformContext(() => {
|
|
@@ -951,7 +957,8 @@ var DefaultUniformClientContext = ({
|
|
|
951
957
|
return createClientUniformContext({
|
|
952
958
|
manifest,
|
|
953
959
|
plugins,
|
|
954
|
-
defaultConsent
|
|
960
|
+
defaultConsent,
|
|
961
|
+
experimental_quirksEnabled: experimentalQuirkSerialization
|
|
955
962
|
});
|
|
956
963
|
});
|
|
957
964
|
return null;
|
|
@@ -966,11 +973,21 @@ var PersonalizeClient = (props) => {
|
|
|
966
973
|
const { context } = useUniformContext();
|
|
967
974
|
const [indexesToShow, setIndexesToShow] = (0, import_react8.useState)(props.indexes);
|
|
968
975
|
(0, import_react8.useEffect)(() => {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
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
|
+
};
|
|
974
991
|
}, [props, context]);
|
|
975
992
|
const slotsToShow = indexesToShow.map((key) => {
|
|
976
993
|
var _a;
|
|
@@ -1155,6 +1172,44 @@ function useScores() {
|
|
|
1155
1172
|
}, [context]);
|
|
1156
1173
|
return scores;
|
|
1157
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
|
+
};
|
|
1158
1213
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1159
1214
|
0 && (module.exports = {
|
|
1160
1215
|
ClientContextPersonalizationTransfer,
|
|
@@ -1171,7 +1226,8 @@ function useScores() {
|
|
|
1171
1226
|
useInitUniformContext,
|
|
1172
1227
|
useQuirks,
|
|
1173
1228
|
useScores,
|
|
1174
|
-
useUniformContext
|
|
1229
|
+
useUniformContext,
|
|
1230
|
+
useUniformContextualEditingState
|
|
1175
1231
|
});
|
|
1176
1232
|
/*! Bundled license information:
|
|
1177
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();
|
|
@@ -909,7 +913,8 @@ var useInitUniformContext = (callback) => {
|
|
|
909
913
|
var DefaultUniformClientContext = ({
|
|
910
914
|
manifest,
|
|
911
915
|
disableDevTools,
|
|
912
|
-
defaultConsent
|
|
916
|
+
defaultConsent,
|
|
917
|
+
experimentalQuirkSerialization
|
|
913
918
|
}) => {
|
|
914
919
|
const router = useRouter();
|
|
915
920
|
useInitUniformContext(() => {
|
|
@@ -926,7 +931,8 @@ var DefaultUniformClientContext = ({
|
|
|
926
931
|
return createClientUniformContext({
|
|
927
932
|
manifest,
|
|
928
933
|
plugins,
|
|
929
|
-
defaultConsent
|
|
934
|
+
defaultConsent,
|
|
935
|
+
experimental_quirksEnabled: experimentalQuirkSerialization
|
|
930
936
|
});
|
|
931
937
|
});
|
|
932
938
|
return null;
|
|
@@ -941,11 +947,21 @@ var PersonalizeClient = (props) => {
|
|
|
941
947
|
const { context } = useUniformContext();
|
|
942
948
|
const [indexesToShow, setIndexesToShow] = useState6(props.indexes);
|
|
943
949
|
useEffect7(() => {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
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
|
+
};
|
|
949
965
|
}, [props, context]);
|
|
950
966
|
const slotsToShow = indexesToShow.map((key) => {
|
|
951
967
|
var _a;
|
|
@@ -1137,6 +1153,47 @@ function useScores() {
|
|
|
1137
1153
|
}, [context]);
|
|
1138
1154
|
return scores;
|
|
1139
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
|
+
};
|
|
1140
1197
|
export {
|
|
1141
1198
|
ClientContextPersonalizationTransfer,
|
|
1142
1199
|
ClientContextTestTransfer,
|
|
@@ -1152,7 +1209,8 @@ export {
|
|
|
1152
1209
|
useInitUniformContext,
|
|
1153
1210
|
useQuirks,
|
|
1154
1211
|
useScores,
|
|
1155
|
-
useUniformContext
|
|
1212
|
+
useUniformContext,
|
|
1213
|
+
useUniformContextualEditingState
|
|
1156
1214
|
};
|
|
1157
1215
|
/*! Bundled license information:
|
|
1158
1216
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc-client",
|
|
3
|
-
"version": "19.202.
|
|
3
|
+
"version": "19.202.1-alpha.9+63c059770a",
|
|
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": "
|
|
28
|
-
"@types/react": "18.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.202.
|
|
36
|
-
"@uniformdev/canvas-next-rsc-shared": "^19.202.
|
|
37
|
-
"@uniformdev/canvas-react": "^19.202.
|
|
35
|
+
"@uniformdev/canvas": "19.202.1-alpha.9+63c059770a",
|
|
36
|
+
"@uniformdev/canvas-next-rsc-shared": "^19.202.1-alpha.9+63c059770a",
|
|
37
|
+
"@uniformdev/canvas-react": "^19.202.1-alpha.9+63c059770a"
|
|
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": "
|
|
50
|
+
"gitHead": "63c059770a54fc063a12af0f74eba059143e8074"
|
|
51
51
|
}
|