@uniformdev/canvas-next-rsc-client 19.94.0 → 19.96.0
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 +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.esm.js +77 -40
- package/dist/index.js +86 -47
- package/dist/index.mjs +77 -40
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ManifestV2, ContextOptions } from '@uniformdev/context';
|
|
1
|
+
import { ManifestV2, PersonalizationEvent, TestEvent, ContextOptions } from '@uniformdev/context';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { PureContextualEditingComponentWrapperProps } from '@uniformdev/canvas-react/core';
|
|
4
4
|
import * as react from 'react';
|
|
@@ -18,6 +18,16 @@ type ClientContextComponentProps = {
|
|
|
18
18
|
};
|
|
19
19
|
type ClientContextComponent = (props: ClientContextComponentProps) => JSX.Element | null;
|
|
20
20
|
|
|
21
|
+
declare const ClientContextPersonalizationTransfer: ({ event, ts, }: {
|
|
22
|
+
event: PersonalizationEvent;
|
|
23
|
+
ts: number;
|
|
24
|
+
}) => null;
|
|
25
|
+
|
|
26
|
+
declare const ClientContextTestTransfer: ({ event, ts }: {
|
|
27
|
+
event: TestEvent;
|
|
28
|
+
ts: number;
|
|
29
|
+
}) => null;
|
|
30
|
+
|
|
21
31
|
declare const ClientContextualEditingComponentWrapper: (props: PropsWithChildren<PureContextualEditingComponentWrapperProps>) => react_jsx_runtime.JSX.Element;
|
|
22
32
|
|
|
23
33
|
declare const ClientContextUpdate: () => react_jsx_runtime.JSX.Element;
|
|
@@ -56,4 +66,4 @@ declare const useUniformContext: () => {
|
|
|
56
66
|
context: AppDirectoryContext | undefined;
|
|
57
67
|
};
|
|
58
68
|
|
|
59
|
-
export { type ClientContextComponent, type ClientContextComponentProps, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, type CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, type PersonalizeClientProps, TestClient, UniformScript, createClientUniformContext, useInitUniformContext, useUniformContext };
|
|
69
|
+
export { type ClientContextComponent, type ClientContextComponentProps, ClientContextPersonalizationTransfer, ClientContextTestTransfer, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, type CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, type PersonalizeClientProps, TestClient, UniformScript, createClientUniformContext, useInitUniformContext, useUniformContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ManifestV2, ContextOptions } from '@uniformdev/context';
|
|
1
|
+
import { ManifestV2, PersonalizationEvent, TestEvent, ContextOptions } from '@uniformdev/context';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { PureContextualEditingComponentWrapperProps } from '@uniformdev/canvas-react/core';
|
|
4
4
|
import * as react from 'react';
|
|
@@ -18,6 +18,16 @@ type ClientContextComponentProps = {
|
|
|
18
18
|
};
|
|
19
19
|
type ClientContextComponent = (props: ClientContextComponentProps) => JSX.Element | null;
|
|
20
20
|
|
|
21
|
+
declare const ClientContextPersonalizationTransfer: ({ event, ts, }: {
|
|
22
|
+
event: PersonalizationEvent;
|
|
23
|
+
ts: number;
|
|
24
|
+
}) => null;
|
|
25
|
+
|
|
26
|
+
declare const ClientContextTestTransfer: ({ event, ts }: {
|
|
27
|
+
event: TestEvent;
|
|
28
|
+
ts: number;
|
|
29
|
+
}) => null;
|
|
30
|
+
|
|
21
31
|
declare const ClientContextualEditingComponentWrapper: (props: PropsWithChildren<PureContextualEditingComponentWrapperProps>) => react_jsx_runtime.JSX.Element;
|
|
22
32
|
|
|
23
33
|
declare const ClientContextUpdate: () => react_jsx_runtime.JSX.Element;
|
|
@@ -56,4 +66,4 @@ declare const useUniformContext: () => {
|
|
|
56
66
|
context: AppDirectoryContext | undefined;
|
|
57
67
|
};
|
|
58
68
|
|
|
59
|
-
export { type ClientContextComponent, type ClientContextComponentProps, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, type CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, type PersonalizeClientProps, TestClient, UniformScript, createClientUniformContext, useInitUniformContext, useUniformContext };
|
|
69
|
+
export { type ClientContextComponent, type ClientContextComponentProps, ClientContextPersonalizationTransfer, ClientContextTestTransfer, ClientContextUpdate, ClientContextualEditingComponentWrapper, ContextUpdateTransferClient, type CreateClientUniformContextOptions, DefaultUniformClientContext, PersonalizeClient, type PersonalizeClientProps, TestClient, UniformScript, createClientUniformContext, useInitUniformContext, useUniformContext };
|
package/dist/index.esm.js
CHANGED
|
@@ -233,6 +233,63 @@ var require_rfdc = __commonJS({
|
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
|
|
236
|
+
// src/components/ClientContextPersonalizationTransfer.tsx
|
|
237
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
238
|
+
|
|
239
|
+
// src/hooks/useUniformContext.ts
|
|
240
|
+
import { useEffect, useState } from "react";
|
|
241
|
+
var useUniformContext = () => {
|
|
242
|
+
const [context, setContext] = useState(
|
|
243
|
+
typeof window !== "undefined" ? window.__UNIFORM_CONTEXT__ : void 0
|
|
244
|
+
);
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
const listener = () => {
|
|
247
|
+
setContext(window.__UNIFORM_CONTEXT__);
|
|
248
|
+
};
|
|
249
|
+
window.addEventListener("uniform.context.loaded", listener);
|
|
250
|
+
return () => {
|
|
251
|
+
window.removeEventListener("uniform.context.loaded", listener);
|
|
252
|
+
};
|
|
253
|
+
}, []);
|
|
254
|
+
return {
|
|
255
|
+
context
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// src/components/ClientContextPersonalizationTransfer.tsx
|
|
260
|
+
var ClientContextPersonalizationTransfer = ({
|
|
261
|
+
event,
|
|
262
|
+
ts
|
|
263
|
+
}) => {
|
|
264
|
+
const { context } = useUniformContext();
|
|
265
|
+
const [lastLogged, setLastLogged] = useState2(void 0);
|
|
266
|
+
useEffect2(() => {
|
|
267
|
+
const shouldBeLogged = !ts || lastLogged !== ts;
|
|
268
|
+
const hasContext = typeof context !== "undefined";
|
|
269
|
+
if (shouldBeLogged && hasContext) {
|
|
270
|
+
setLastLogged(ts);
|
|
271
|
+
context.internal_processPersonalizationEvent(event);
|
|
272
|
+
}
|
|
273
|
+
}, [context, event, lastLogged, ts]);
|
|
274
|
+
return null;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// src/components/ClientContextTestTransfer.tsx
|
|
278
|
+
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
279
|
+
var ClientContextTestTransfer = ({ event, ts }) => {
|
|
280
|
+
const { context } = useUniformContext();
|
|
281
|
+
const [lastLogged, setLastLogged] = useState3(void 0);
|
|
282
|
+
useEffect3(() => {
|
|
283
|
+
const shouldBeLogged = !ts || lastLogged !== ts;
|
|
284
|
+
const hasContext = typeof context !== "undefined";
|
|
285
|
+
if (shouldBeLogged && hasContext && event.variantId) {
|
|
286
|
+
setLastLogged(ts);
|
|
287
|
+
context.internal_processTestEvent(event);
|
|
288
|
+
}
|
|
289
|
+
}, [context, event, lastLogged, ts]);
|
|
290
|
+
return null;
|
|
291
|
+
};
|
|
292
|
+
|
|
236
293
|
// src/components/ClientContextualEditingComponentWrapper.tsx
|
|
237
294
|
import { IN_CONTEXT_EDITOR_QUERY_STRING_PARAM } from "@uniformdev/canvas";
|
|
238
295
|
import {
|
|
@@ -258,29 +315,7 @@ var ClientContextualEditingComponentWrapperInner = ({
|
|
|
258
315
|
|
|
259
316
|
// src/components/ClientContextUpdate.tsx
|
|
260
317
|
import { useParams, useSearchParams as useSearchParams2 } from "next/navigation";
|
|
261
|
-
import { Suspense as Suspense2, useEffect as
|
|
262
|
-
|
|
263
|
-
// src/hooks/useUniformContext.ts
|
|
264
|
-
import { useEffect, useState } from "react";
|
|
265
|
-
var useUniformContext = () => {
|
|
266
|
-
const [context, setContext] = useState(
|
|
267
|
-
typeof window !== "undefined" ? window.__UNIFORM_CONTEXT__ : void 0
|
|
268
|
-
);
|
|
269
|
-
useEffect(() => {
|
|
270
|
-
const listener = () => {
|
|
271
|
-
setContext(window.__UNIFORM_CONTEXT__);
|
|
272
|
-
};
|
|
273
|
-
window.addEventListener("uniform.context.loaded", listener);
|
|
274
|
-
return () => {
|
|
275
|
-
window.removeEventListener("uniform.context.loaded", listener);
|
|
276
|
-
};
|
|
277
|
-
}, []);
|
|
278
|
-
return {
|
|
279
|
-
context
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// src/components/ClientContextUpdate.tsx
|
|
318
|
+
import { Suspense as Suspense2, useEffect as useEffect4 } from "react";
|
|
284
319
|
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
285
320
|
var ClientContextUpdate = () => {
|
|
286
321
|
return /* @__PURE__ */ jsx2(Suspense2, { children: /* @__PURE__ */ jsx2(ClientContextUpdateInner, {}) });
|
|
@@ -289,7 +324,7 @@ var ClientContextUpdateInner = () => {
|
|
|
289
324
|
const params = useParams();
|
|
290
325
|
const searchParams = useSearchParams2();
|
|
291
326
|
const { context } = useUniformContext();
|
|
292
|
-
|
|
327
|
+
useEffect4(() => {
|
|
293
328
|
if (!context || typeof window === "undefined") {
|
|
294
329
|
return;
|
|
295
330
|
}
|
|
@@ -303,14 +338,14 @@ var ClientContextUpdateInner = () => {
|
|
|
303
338
|
};
|
|
304
339
|
|
|
305
340
|
// src/components/ContextUpdateTransferClient.tsx
|
|
306
|
-
import { useEffect as
|
|
341
|
+
import { useEffect as useEffect5, useState as useState4 } from "react";
|
|
307
342
|
var ContextUpdateTransferClient = ({
|
|
308
343
|
update,
|
|
309
344
|
ts
|
|
310
345
|
}) => {
|
|
311
346
|
const { context } = useUniformContext();
|
|
312
|
-
const [lastLogged, setLastLogged] =
|
|
313
|
-
|
|
347
|
+
const [lastLogged, setLastLogged] = useState4(void 0);
|
|
348
|
+
useEffect5(() => {
|
|
314
349
|
const shouldBeLogged = (!ts || lastLogged !== ts) && Object.keys(update).length > 0;
|
|
315
350
|
const hasContext = typeof context !== "undefined";
|
|
316
351
|
if (shouldBeLogged && hasContext) {
|
|
@@ -872,10 +907,10 @@ var createClientUniformContext = (options) => {
|
|
|
872
907
|
};
|
|
873
908
|
|
|
874
909
|
// src/hooks/useInitUniformContext.ts
|
|
875
|
-
import { useEffect as
|
|
910
|
+
import { useEffect as useEffect6, useState as useState5 } from "react";
|
|
876
911
|
var useInitUniformContext = (callback) => {
|
|
877
|
-
const [called, setCalled] =
|
|
878
|
-
|
|
912
|
+
const [called, setCalled] = useState5(false);
|
|
913
|
+
useEffect6(() => {
|
|
879
914
|
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
880
915
|
return;
|
|
881
916
|
}
|
|
@@ -911,12 +946,12 @@ var DefaultUniformClientContext = ({ manifest, disableDevTools }) => {
|
|
|
911
946
|
// src/components/PersonalizeClient.ts
|
|
912
947
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
913
948
|
import { runPersonalization } from "@uniformdev/canvas-next-rsc-shared";
|
|
914
|
-
import { createElement, Fragment as Fragment3, useEffect as
|
|
949
|
+
import { createElement, Fragment as Fragment3, useEffect as useEffect7, useState as useState6 } from "react";
|
|
915
950
|
var PersonalizeClient = (props) => {
|
|
916
951
|
const { slots } = props;
|
|
917
952
|
const { context } = useUniformContext();
|
|
918
|
-
const [indexesToShow, setIndexesToShow] =
|
|
919
|
-
|
|
953
|
+
const [indexesToShow, setIndexesToShow] = useState6(props.indexes);
|
|
954
|
+
useEffect7(() => {
|
|
920
955
|
const result = runPersonalization({
|
|
921
956
|
...props,
|
|
922
957
|
contextInstance: context
|
|
@@ -933,13 +968,13 @@ var PersonalizeClient = (props) => {
|
|
|
933
968
|
// src/components/TestClient.ts
|
|
934
969
|
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
935
970
|
import { runTest } from "@uniformdev/canvas-next-rsc-shared";
|
|
936
|
-
import { createElement as createElement2, Fragment as Fragment4, useEffect as
|
|
971
|
+
import { createElement as createElement2, Fragment as Fragment4, useEffect as useEffect8, useState as useState7 } from "react";
|
|
937
972
|
var TestClient = (props) => {
|
|
938
973
|
var _a;
|
|
939
974
|
const { slots } = props;
|
|
940
975
|
const { context } = useUniformContext();
|
|
941
|
-
const [index, setIndex] =
|
|
942
|
-
|
|
976
|
+
const [index, setIndex] = useState7(0);
|
|
977
|
+
useEffect8(() => {
|
|
943
978
|
const result = runTest({
|
|
944
979
|
...props,
|
|
945
980
|
contextInstance: context
|
|
@@ -959,7 +994,7 @@ import {
|
|
|
959
994
|
isAllowedReferrer
|
|
960
995
|
} from "@uniformdev/canvas";
|
|
961
996
|
import { useRouter as useRouter2, useSearchParams as useSearchParams3 } from "next/navigation";
|
|
962
|
-
import { useEffect as
|
|
997
|
+
import { useEffect as useEffect9, useMemo, useRef } from "react";
|
|
963
998
|
import { Fragment as Fragment5, jsx as jsx3 } from "react/jsx-runtime";
|
|
964
999
|
var UniformScript = () => {
|
|
965
1000
|
const router = useRouter2();
|
|
@@ -977,7 +1012,7 @@ var UniformScript = () => {
|
|
|
977
1012
|
});
|
|
978
1013
|
return instance;
|
|
979
1014
|
}, []);
|
|
980
|
-
|
|
1015
|
+
useEffect9(() => {
|
|
981
1016
|
if (!channel) {
|
|
982
1017
|
return;
|
|
983
1018
|
}
|
|
@@ -994,7 +1029,7 @@ var UniformScript = () => {
|
|
|
994
1029
|
unsubscribeFromEditorUpdates();
|
|
995
1030
|
};
|
|
996
1031
|
}, [channel, router]);
|
|
997
|
-
|
|
1032
|
+
useEffect9(() => {
|
|
998
1033
|
if (typeof window === "undefined") {
|
|
999
1034
|
return;
|
|
1000
1035
|
}
|
|
@@ -1015,7 +1050,7 @@ var UniformScript = () => {
|
|
|
1015
1050
|
existing.remove();
|
|
1016
1051
|
}
|
|
1017
1052
|
}, [enabled]);
|
|
1018
|
-
|
|
1053
|
+
useEffect9(() => {
|
|
1019
1054
|
const handleBlurChange = () => {
|
|
1020
1055
|
if (needsToRefreshRef.current) {
|
|
1021
1056
|
router.refresh();
|
|
@@ -1030,6 +1065,8 @@ var UniformScript = () => {
|
|
|
1030
1065
|
return /* @__PURE__ */ jsx3(Fragment5, {});
|
|
1031
1066
|
};
|
|
1032
1067
|
export {
|
|
1068
|
+
ClientContextPersonalizationTransfer,
|
|
1069
|
+
ClientContextTestTransfer,
|
|
1033
1070
|
ClientContextUpdate,
|
|
1034
1071
|
ClientContextualEditingComponentWrapper,
|
|
1035
1072
|
ContextUpdateTransferClient,
|
package/dist/index.js
CHANGED
|
@@ -242,6 +242,8 @@ var require_rfdc = __commonJS({
|
|
|
242
242
|
// src/index.ts
|
|
243
243
|
var src_exports = {};
|
|
244
244
|
__export(src_exports, {
|
|
245
|
+
ClientContextPersonalizationTransfer: () => ClientContextPersonalizationTransfer,
|
|
246
|
+
ClientContextTestTransfer: () => ClientContextTestTransfer,
|
|
245
247
|
ClientContextUpdate: () => ClientContextUpdate,
|
|
246
248
|
ClientContextualEditingComponentWrapper: () => ClientContextualEditingComponentWrapper,
|
|
247
249
|
ContextUpdateTransferClient: () => ContextUpdateTransferClient,
|
|
@@ -255,14 +257,71 @@ __export(src_exports, {
|
|
|
255
257
|
});
|
|
256
258
|
module.exports = __toCommonJS(src_exports);
|
|
257
259
|
|
|
260
|
+
// src/components/ClientContextPersonalizationTransfer.tsx
|
|
261
|
+
var import_react2 = require("react");
|
|
262
|
+
|
|
263
|
+
// src/hooks/useUniformContext.ts
|
|
264
|
+
var import_react = require("react");
|
|
265
|
+
var useUniformContext = () => {
|
|
266
|
+
const [context, setContext] = (0, import_react.useState)(
|
|
267
|
+
typeof window !== "undefined" ? window.__UNIFORM_CONTEXT__ : void 0
|
|
268
|
+
);
|
|
269
|
+
(0, import_react.useEffect)(() => {
|
|
270
|
+
const listener = () => {
|
|
271
|
+
setContext(window.__UNIFORM_CONTEXT__);
|
|
272
|
+
};
|
|
273
|
+
window.addEventListener("uniform.context.loaded", listener);
|
|
274
|
+
return () => {
|
|
275
|
+
window.removeEventListener("uniform.context.loaded", listener);
|
|
276
|
+
};
|
|
277
|
+
}, []);
|
|
278
|
+
return {
|
|
279
|
+
context
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/components/ClientContextPersonalizationTransfer.tsx
|
|
284
|
+
var ClientContextPersonalizationTransfer = ({
|
|
285
|
+
event,
|
|
286
|
+
ts
|
|
287
|
+
}) => {
|
|
288
|
+
const { context } = useUniformContext();
|
|
289
|
+
const [lastLogged, setLastLogged] = (0, import_react2.useState)(void 0);
|
|
290
|
+
(0, import_react2.useEffect)(() => {
|
|
291
|
+
const shouldBeLogged = !ts || lastLogged !== ts;
|
|
292
|
+
const hasContext = typeof context !== "undefined";
|
|
293
|
+
if (shouldBeLogged && hasContext) {
|
|
294
|
+
setLastLogged(ts);
|
|
295
|
+
context.internal_processPersonalizationEvent(event);
|
|
296
|
+
}
|
|
297
|
+
}, [context, event, lastLogged, ts]);
|
|
298
|
+
return null;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
// src/components/ClientContextTestTransfer.tsx
|
|
302
|
+
var import_react3 = require("react");
|
|
303
|
+
var ClientContextTestTransfer = ({ event, ts }) => {
|
|
304
|
+
const { context } = useUniformContext();
|
|
305
|
+
const [lastLogged, setLastLogged] = (0, import_react3.useState)(void 0);
|
|
306
|
+
(0, import_react3.useEffect)(() => {
|
|
307
|
+
const shouldBeLogged = !ts || lastLogged !== ts;
|
|
308
|
+
const hasContext = typeof context !== "undefined";
|
|
309
|
+
if (shouldBeLogged && hasContext && event.variantId) {
|
|
310
|
+
setLastLogged(ts);
|
|
311
|
+
context.internal_processTestEvent(event);
|
|
312
|
+
}
|
|
313
|
+
}, [context, event, lastLogged, ts]);
|
|
314
|
+
return null;
|
|
315
|
+
};
|
|
316
|
+
|
|
258
317
|
// src/components/ClientContextualEditingComponentWrapper.tsx
|
|
259
318
|
var import_canvas = require("@uniformdev/canvas");
|
|
260
319
|
var import_core = require("@uniformdev/canvas-react/core");
|
|
261
320
|
var import_navigation = require("next/navigation");
|
|
262
|
-
var
|
|
321
|
+
var import_react4 = require("react");
|
|
263
322
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
264
323
|
var ClientContextualEditingComponentWrapper = (props) => {
|
|
265
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react4.Suspense, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClientContextualEditingComponentWrapperInner, { ...props }) });
|
|
266
325
|
};
|
|
267
326
|
var ClientContextualEditingComponentWrapperInner = ({
|
|
268
327
|
children,
|
|
@@ -278,38 +337,16 @@ var ClientContextualEditingComponentWrapperInner = ({
|
|
|
278
337
|
|
|
279
338
|
// src/components/ClientContextUpdate.tsx
|
|
280
339
|
var import_navigation2 = require("next/navigation");
|
|
281
|
-
var
|
|
282
|
-
|
|
283
|
-
// src/hooks/useUniformContext.ts
|
|
284
|
-
var import_react2 = require("react");
|
|
285
|
-
var useUniformContext = () => {
|
|
286
|
-
const [context, setContext] = (0, import_react2.useState)(
|
|
287
|
-
typeof window !== "undefined" ? window.__UNIFORM_CONTEXT__ : void 0
|
|
288
|
-
);
|
|
289
|
-
(0, import_react2.useEffect)(() => {
|
|
290
|
-
const listener = () => {
|
|
291
|
-
setContext(window.__UNIFORM_CONTEXT__);
|
|
292
|
-
};
|
|
293
|
-
window.addEventListener("uniform.context.loaded", listener);
|
|
294
|
-
return () => {
|
|
295
|
-
window.removeEventListener("uniform.context.loaded", listener);
|
|
296
|
-
};
|
|
297
|
-
}, []);
|
|
298
|
-
return {
|
|
299
|
-
context
|
|
300
|
-
};
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
// src/components/ClientContextUpdate.tsx
|
|
340
|
+
var import_react5 = require("react");
|
|
304
341
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
305
342
|
var ClientContextUpdate = () => {
|
|
306
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react5.Suspense, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ClientContextUpdateInner, {}) });
|
|
307
344
|
};
|
|
308
345
|
var ClientContextUpdateInner = () => {
|
|
309
346
|
const params = (0, import_navigation2.useParams)();
|
|
310
347
|
const searchParams = (0, import_navigation2.useSearchParams)();
|
|
311
348
|
const { context } = useUniformContext();
|
|
312
|
-
(0,
|
|
349
|
+
(0, import_react5.useEffect)(() => {
|
|
313
350
|
if (!context || typeof window === "undefined") {
|
|
314
351
|
return;
|
|
315
352
|
}
|
|
@@ -323,14 +360,14 @@ var ClientContextUpdateInner = () => {
|
|
|
323
360
|
};
|
|
324
361
|
|
|
325
362
|
// src/components/ContextUpdateTransferClient.tsx
|
|
326
|
-
var
|
|
363
|
+
var import_react6 = require("react");
|
|
327
364
|
var ContextUpdateTransferClient = ({
|
|
328
365
|
update,
|
|
329
366
|
ts
|
|
330
367
|
}) => {
|
|
331
368
|
const { context } = useUniformContext();
|
|
332
|
-
const [lastLogged, setLastLogged] = (0,
|
|
333
|
-
(0,
|
|
369
|
+
const [lastLogged, setLastLogged] = (0, import_react6.useState)(void 0);
|
|
370
|
+
(0, import_react6.useEffect)(() => {
|
|
334
371
|
const shouldBeLogged = (!ts || lastLogged !== ts) && Object.keys(update).length > 0;
|
|
335
372
|
const hasContext = typeof context !== "undefined";
|
|
336
373
|
if (shouldBeLogged && hasContext) {
|
|
@@ -892,10 +929,10 @@ var createClientUniformContext = (options) => {
|
|
|
892
929
|
};
|
|
893
930
|
|
|
894
931
|
// src/hooks/useInitUniformContext.ts
|
|
895
|
-
var
|
|
932
|
+
var import_react7 = require("react");
|
|
896
933
|
var useInitUniformContext = (callback) => {
|
|
897
|
-
const [called, setCalled] = (0,
|
|
898
|
-
(0,
|
|
934
|
+
const [called, setCalled] = (0, import_react7.useState)(false);
|
|
935
|
+
(0, import_react7.useEffect)(() => {
|
|
899
936
|
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
900
937
|
return;
|
|
901
938
|
}
|
|
@@ -931,12 +968,12 @@ var DefaultUniformClientContext = ({ manifest, disableDevTools }) => {
|
|
|
931
968
|
// src/components/PersonalizeClient.ts
|
|
932
969
|
var import_canvas2 = require("@uniformdev/canvas");
|
|
933
970
|
var import_canvas_next_rsc_shared2 = require("@uniformdev/canvas-next-rsc-shared");
|
|
934
|
-
var
|
|
971
|
+
var import_react8 = require("react");
|
|
935
972
|
var PersonalizeClient = (props) => {
|
|
936
973
|
const { slots } = props;
|
|
937
974
|
const { context } = useUniformContext();
|
|
938
|
-
const [indexesToShow, setIndexesToShow] = (0,
|
|
939
|
-
(0,
|
|
975
|
+
const [indexesToShow, setIndexesToShow] = (0, import_react8.useState)(props.indexes);
|
|
976
|
+
(0, import_react8.useEffect)(() => {
|
|
940
977
|
const result = (0, import_canvas_next_rsc_shared2.runPersonalization)({
|
|
941
978
|
...props,
|
|
942
979
|
contextInstance: context
|
|
@@ -947,19 +984,19 @@ var PersonalizeClient = (props) => {
|
|
|
947
984
|
var _a;
|
|
948
985
|
return (_a = slots[import_canvas2.CANVAS_PERSONALIZE_SLOT]) == null ? void 0 : _a.items[key];
|
|
949
986
|
});
|
|
950
|
-
return (0,
|
|
987
|
+
return (0, import_react8.createElement)(import_react8.Fragment, void 0, slotsToShow);
|
|
951
988
|
};
|
|
952
989
|
|
|
953
990
|
// src/components/TestClient.ts
|
|
954
991
|
var import_canvas3 = require("@uniformdev/canvas");
|
|
955
992
|
var import_canvas_next_rsc_shared3 = require("@uniformdev/canvas-next-rsc-shared");
|
|
956
|
-
var
|
|
993
|
+
var import_react9 = require("react");
|
|
957
994
|
var TestClient = (props) => {
|
|
958
995
|
var _a;
|
|
959
996
|
const { slots } = props;
|
|
960
997
|
const { context } = useUniformContext();
|
|
961
|
-
const [index, setIndex] = (0,
|
|
962
|
-
(0,
|
|
998
|
+
const [index, setIndex] = (0, import_react9.useState)(0);
|
|
999
|
+
(0, import_react9.useEffect)(() => {
|
|
963
1000
|
const result = (0, import_canvas_next_rsc_shared3.runTest)({
|
|
964
1001
|
...props,
|
|
965
1002
|
contextInstance: context
|
|
@@ -969,20 +1006,20 @@ var TestClient = (props) => {
|
|
|
969
1006
|
if (typeof index !== "number") {
|
|
970
1007
|
return null;
|
|
971
1008
|
}
|
|
972
|
-
return (0,
|
|
1009
|
+
return (0, import_react9.createElement)(import_react9.Fragment, void 0, (_a = slots == null ? void 0 : slots[import_canvas3.CANVAS_TEST_SLOT]) == null ? void 0 : _a.items[index]);
|
|
973
1010
|
};
|
|
974
1011
|
|
|
975
1012
|
// src/components/UniformScriptClient.tsx
|
|
976
1013
|
var import_canvas4 = require("@uniformdev/canvas");
|
|
977
1014
|
var import_navigation4 = require("next/navigation");
|
|
978
|
-
var
|
|
1015
|
+
var import_react10 = require("react");
|
|
979
1016
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
980
1017
|
var UniformScript = () => {
|
|
981
1018
|
const router = (0, import_navigation4.useRouter)();
|
|
982
1019
|
const params = (0, import_navigation4.useSearchParams)();
|
|
983
|
-
const needsToRefreshRef = (0,
|
|
1020
|
+
const needsToRefreshRef = (0, import_react10.useRef)(false);
|
|
984
1021
|
const enabled = params.get(import_canvas4.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM) === "true";
|
|
985
|
-
const channel = (0,
|
|
1022
|
+
const channel = (0, import_react10.useMemo)(() => {
|
|
986
1023
|
var _a;
|
|
987
1024
|
if (typeof window === "undefined") {
|
|
988
1025
|
return;
|
|
@@ -993,7 +1030,7 @@ var UniformScript = () => {
|
|
|
993
1030
|
});
|
|
994
1031
|
return instance;
|
|
995
1032
|
}, []);
|
|
996
|
-
(0,
|
|
1033
|
+
(0, import_react10.useEffect)(() => {
|
|
997
1034
|
if (!channel) {
|
|
998
1035
|
return;
|
|
999
1036
|
}
|
|
@@ -1010,7 +1047,7 @@ var UniformScript = () => {
|
|
|
1010
1047
|
unsubscribeFromEditorUpdates();
|
|
1011
1048
|
};
|
|
1012
1049
|
}, [channel, router]);
|
|
1013
|
-
(0,
|
|
1050
|
+
(0, import_react10.useEffect)(() => {
|
|
1014
1051
|
if (typeof window === "undefined") {
|
|
1015
1052
|
return;
|
|
1016
1053
|
}
|
|
@@ -1031,7 +1068,7 @@ var UniformScript = () => {
|
|
|
1031
1068
|
existing.remove();
|
|
1032
1069
|
}
|
|
1033
1070
|
}, [enabled]);
|
|
1034
|
-
(0,
|
|
1071
|
+
(0, import_react10.useEffect)(() => {
|
|
1035
1072
|
const handleBlurChange = () => {
|
|
1036
1073
|
if (needsToRefreshRef.current) {
|
|
1037
1074
|
router.refresh();
|
|
@@ -1047,6 +1084,8 @@ var UniformScript = () => {
|
|
|
1047
1084
|
};
|
|
1048
1085
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1049
1086
|
0 && (module.exports = {
|
|
1087
|
+
ClientContextPersonalizationTransfer,
|
|
1088
|
+
ClientContextTestTransfer,
|
|
1050
1089
|
ClientContextUpdate,
|
|
1051
1090
|
ClientContextualEditingComponentWrapper,
|
|
1052
1091
|
ContextUpdateTransferClient,
|
package/dist/index.mjs
CHANGED
|
@@ -233,6 +233,63 @@ var require_rfdc = __commonJS({
|
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
235
|
|
|
236
|
+
// src/components/ClientContextPersonalizationTransfer.tsx
|
|
237
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
238
|
+
|
|
239
|
+
// src/hooks/useUniformContext.ts
|
|
240
|
+
import { useEffect, useState } from "react";
|
|
241
|
+
var useUniformContext = () => {
|
|
242
|
+
const [context, setContext] = useState(
|
|
243
|
+
typeof window !== "undefined" ? window.__UNIFORM_CONTEXT__ : void 0
|
|
244
|
+
);
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
const listener = () => {
|
|
247
|
+
setContext(window.__UNIFORM_CONTEXT__);
|
|
248
|
+
};
|
|
249
|
+
window.addEventListener("uniform.context.loaded", listener);
|
|
250
|
+
return () => {
|
|
251
|
+
window.removeEventListener("uniform.context.loaded", listener);
|
|
252
|
+
};
|
|
253
|
+
}, []);
|
|
254
|
+
return {
|
|
255
|
+
context
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// src/components/ClientContextPersonalizationTransfer.tsx
|
|
260
|
+
var ClientContextPersonalizationTransfer = ({
|
|
261
|
+
event,
|
|
262
|
+
ts
|
|
263
|
+
}) => {
|
|
264
|
+
const { context } = useUniformContext();
|
|
265
|
+
const [lastLogged, setLastLogged] = useState2(void 0);
|
|
266
|
+
useEffect2(() => {
|
|
267
|
+
const shouldBeLogged = !ts || lastLogged !== ts;
|
|
268
|
+
const hasContext = typeof context !== "undefined";
|
|
269
|
+
if (shouldBeLogged && hasContext) {
|
|
270
|
+
setLastLogged(ts);
|
|
271
|
+
context.internal_processPersonalizationEvent(event);
|
|
272
|
+
}
|
|
273
|
+
}, [context, event, lastLogged, ts]);
|
|
274
|
+
return null;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// src/components/ClientContextTestTransfer.tsx
|
|
278
|
+
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
279
|
+
var ClientContextTestTransfer = ({ event, ts }) => {
|
|
280
|
+
const { context } = useUniformContext();
|
|
281
|
+
const [lastLogged, setLastLogged] = useState3(void 0);
|
|
282
|
+
useEffect3(() => {
|
|
283
|
+
const shouldBeLogged = !ts || lastLogged !== ts;
|
|
284
|
+
const hasContext = typeof context !== "undefined";
|
|
285
|
+
if (shouldBeLogged && hasContext && event.variantId) {
|
|
286
|
+
setLastLogged(ts);
|
|
287
|
+
context.internal_processTestEvent(event);
|
|
288
|
+
}
|
|
289
|
+
}, [context, event, lastLogged, ts]);
|
|
290
|
+
return null;
|
|
291
|
+
};
|
|
292
|
+
|
|
236
293
|
// src/components/ClientContextualEditingComponentWrapper.tsx
|
|
237
294
|
import { IN_CONTEXT_EDITOR_QUERY_STRING_PARAM } from "@uniformdev/canvas";
|
|
238
295
|
import {
|
|
@@ -258,29 +315,7 @@ var ClientContextualEditingComponentWrapperInner = ({
|
|
|
258
315
|
|
|
259
316
|
// src/components/ClientContextUpdate.tsx
|
|
260
317
|
import { useParams, useSearchParams as useSearchParams2 } from "next/navigation";
|
|
261
|
-
import { Suspense as Suspense2, useEffect as
|
|
262
|
-
|
|
263
|
-
// src/hooks/useUniformContext.ts
|
|
264
|
-
import { useEffect, useState } from "react";
|
|
265
|
-
var useUniformContext = () => {
|
|
266
|
-
const [context, setContext] = useState(
|
|
267
|
-
typeof window !== "undefined" ? window.__UNIFORM_CONTEXT__ : void 0
|
|
268
|
-
);
|
|
269
|
-
useEffect(() => {
|
|
270
|
-
const listener = () => {
|
|
271
|
-
setContext(window.__UNIFORM_CONTEXT__);
|
|
272
|
-
};
|
|
273
|
-
window.addEventListener("uniform.context.loaded", listener);
|
|
274
|
-
return () => {
|
|
275
|
-
window.removeEventListener("uniform.context.loaded", listener);
|
|
276
|
-
};
|
|
277
|
-
}, []);
|
|
278
|
-
return {
|
|
279
|
-
context
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// src/components/ClientContextUpdate.tsx
|
|
318
|
+
import { Suspense as Suspense2, useEffect as useEffect4 } from "react";
|
|
284
319
|
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
285
320
|
var ClientContextUpdate = () => {
|
|
286
321
|
return /* @__PURE__ */ jsx2(Suspense2, { children: /* @__PURE__ */ jsx2(ClientContextUpdateInner, {}) });
|
|
@@ -289,7 +324,7 @@ var ClientContextUpdateInner = () => {
|
|
|
289
324
|
const params = useParams();
|
|
290
325
|
const searchParams = useSearchParams2();
|
|
291
326
|
const { context } = useUniformContext();
|
|
292
|
-
|
|
327
|
+
useEffect4(() => {
|
|
293
328
|
if (!context || typeof window === "undefined") {
|
|
294
329
|
return;
|
|
295
330
|
}
|
|
@@ -303,14 +338,14 @@ var ClientContextUpdateInner = () => {
|
|
|
303
338
|
};
|
|
304
339
|
|
|
305
340
|
// src/components/ContextUpdateTransferClient.tsx
|
|
306
|
-
import { useEffect as
|
|
341
|
+
import { useEffect as useEffect5, useState as useState4 } from "react";
|
|
307
342
|
var ContextUpdateTransferClient = ({
|
|
308
343
|
update,
|
|
309
344
|
ts
|
|
310
345
|
}) => {
|
|
311
346
|
const { context } = useUniformContext();
|
|
312
|
-
const [lastLogged, setLastLogged] =
|
|
313
|
-
|
|
347
|
+
const [lastLogged, setLastLogged] = useState4(void 0);
|
|
348
|
+
useEffect5(() => {
|
|
314
349
|
const shouldBeLogged = (!ts || lastLogged !== ts) && Object.keys(update).length > 0;
|
|
315
350
|
const hasContext = typeof context !== "undefined";
|
|
316
351
|
if (shouldBeLogged && hasContext) {
|
|
@@ -872,10 +907,10 @@ var createClientUniformContext = (options) => {
|
|
|
872
907
|
};
|
|
873
908
|
|
|
874
909
|
// src/hooks/useInitUniformContext.ts
|
|
875
|
-
import { useEffect as
|
|
910
|
+
import { useEffect as useEffect6, useState as useState5 } from "react";
|
|
876
911
|
var useInitUniformContext = (callback) => {
|
|
877
|
-
const [called, setCalled] =
|
|
878
|
-
|
|
912
|
+
const [called, setCalled] = useState5(false);
|
|
913
|
+
useEffect6(() => {
|
|
879
914
|
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
880
915
|
return;
|
|
881
916
|
}
|
|
@@ -911,12 +946,12 @@ var DefaultUniformClientContext = ({ manifest, disableDevTools }) => {
|
|
|
911
946
|
// src/components/PersonalizeClient.ts
|
|
912
947
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
913
948
|
import { runPersonalization } from "@uniformdev/canvas-next-rsc-shared";
|
|
914
|
-
import { createElement, Fragment as Fragment3, useEffect as
|
|
949
|
+
import { createElement, Fragment as Fragment3, useEffect as useEffect7, useState as useState6 } from "react";
|
|
915
950
|
var PersonalizeClient = (props) => {
|
|
916
951
|
const { slots } = props;
|
|
917
952
|
const { context } = useUniformContext();
|
|
918
|
-
const [indexesToShow, setIndexesToShow] =
|
|
919
|
-
|
|
953
|
+
const [indexesToShow, setIndexesToShow] = useState6(props.indexes);
|
|
954
|
+
useEffect7(() => {
|
|
920
955
|
const result = runPersonalization({
|
|
921
956
|
...props,
|
|
922
957
|
contextInstance: context
|
|
@@ -933,13 +968,13 @@ var PersonalizeClient = (props) => {
|
|
|
933
968
|
// src/components/TestClient.ts
|
|
934
969
|
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
935
970
|
import { runTest } from "@uniformdev/canvas-next-rsc-shared";
|
|
936
|
-
import { createElement as createElement2, Fragment as Fragment4, useEffect as
|
|
971
|
+
import { createElement as createElement2, Fragment as Fragment4, useEffect as useEffect8, useState as useState7 } from "react";
|
|
937
972
|
var TestClient = (props) => {
|
|
938
973
|
var _a;
|
|
939
974
|
const { slots } = props;
|
|
940
975
|
const { context } = useUniformContext();
|
|
941
|
-
const [index, setIndex] =
|
|
942
|
-
|
|
976
|
+
const [index, setIndex] = useState7(0);
|
|
977
|
+
useEffect8(() => {
|
|
943
978
|
const result = runTest({
|
|
944
979
|
...props,
|
|
945
980
|
contextInstance: context
|
|
@@ -959,7 +994,7 @@ import {
|
|
|
959
994
|
isAllowedReferrer
|
|
960
995
|
} from "@uniformdev/canvas";
|
|
961
996
|
import { useRouter as useRouter2, useSearchParams as useSearchParams3 } from "next/navigation";
|
|
962
|
-
import { useEffect as
|
|
997
|
+
import { useEffect as useEffect9, useMemo, useRef } from "react";
|
|
963
998
|
import { Fragment as Fragment5, jsx as jsx3 } from "react/jsx-runtime";
|
|
964
999
|
var UniformScript = () => {
|
|
965
1000
|
const router = useRouter2();
|
|
@@ -977,7 +1012,7 @@ var UniformScript = () => {
|
|
|
977
1012
|
});
|
|
978
1013
|
return instance;
|
|
979
1014
|
}, []);
|
|
980
|
-
|
|
1015
|
+
useEffect9(() => {
|
|
981
1016
|
if (!channel) {
|
|
982
1017
|
return;
|
|
983
1018
|
}
|
|
@@ -994,7 +1029,7 @@ var UniformScript = () => {
|
|
|
994
1029
|
unsubscribeFromEditorUpdates();
|
|
995
1030
|
};
|
|
996
1031
|
}, [channel, router]);
|
|
997
|
-
|
|
1032
|
+
useEffect9(() => {
|
|
998
1033
|
if (typeof window === "undefined") {
|
|
999
1034
|
return;
|
|
1000
1035
|
}
|
|
@@ -1015,7 +1050,7 @@ var UniformScript = () => {
|
|
|
1015
1050
|
existing.remove();
|
|
1016
1051
|
}
|
|
1017
1052
|
}, [enabled]);
|
|
1018
|
-
|
|
1053
|
+
useEffect9(() => {
|
|
1019
1054
|
const handleBlurChange = () => {
|
|
1020
1055
|
if (needsToRefreshRef.current) {
|
|
1021
1056
|
router.refresh();
|
|
@@ -1030,6 +1065,8 @@ var UniformScript = () => {
|
|
|
1030
1065
|
return /* @__PURE__ */ jsx3(Fragment5, {});
|
|
1031
1066
|
};
|
|
1032
1067
|
export {
|
|
1068
|
+
ClientContextPersonalizationTransfer,
|
|
1069
|
+
ClientContextTestTransfer,
|
|
1033
1070
|
ClientContextUpdate,
|
|
1034
1071
|
ClientContextualEditingComponentWrapper,
|
|
1035
1072
|
ContextUpdateTransferClient,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc-client",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.96.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"react-dom": "18.2.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@uniformdev/canvas": "19.
|
|
36
|
-
"@uniformdev/canvas-next-rsc-shared": "^19.
|
|
37
|
-
"@uniformdev/canvas-react": "^19.
|
|
35
|
+
"@uniformdev/canvas": "19.96.0",
|
|
36
|
+
"@uniformdev/canvas-next-rsc-shared": "^19.96.0",
|
|
37
|
+
"@uniformdev/canvas-react": "^19.96.0"
|
|
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": "1397d721ceca0b63b4439702fe0f587e4fe2420d"
|
|
51
51
|
}
|