@uniformdev/canvas-next-rsc-client 19.61.1-alpha.23 → 19.62.1-alpha.127
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 +1 -1
- package/dist/index.d.mts +29 -5
- package/dist/index.d.ts +29 -5
- package/dist/index.esm.js +885 -50
- package/dist/index.js +882 -57
- package/dist/index.mjs +885 -50
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -1,31 +1,240 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
11
|
-
var ClientContextualEditingComponentWrapper = (props) => {
|
|
12
|
-
return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ClientContextualEditingComponentWrapperInner, { ...props }) });
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
10
|
};
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const inContextMode = searchParams.get(IN_CONTEXT_EDITOR_QUERY_STRING_PARAM) === "true";
|
|
20
|
-
if (!inContextMode) {
|
|
21
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
16
|
}
|
|
23
|
-
return
|
|
17
|
+
return to;
|
|
24
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
25
27
|
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
// ../../node_modules/.pnpm/rfdc@1.3.1/node_modules/rfdc/index.js
|
|
29
|
+
var require_rfdc = __commonJS({
|
|
30
|
+
"../../node_modules/.pnpm/rfdc@1.3.1/node_modules/rfdc/index.js"(exports, module) {
|
|
31
|
+
"use strict";
|
|
32
|
+
module.exports = rfdc4;
|
|
33
|
+
function copyBuffer(cur) {
|
|
34
|
+
if (cur instanceof Buffer) {
|
|
35
|
+
return Buffer.from(cur);
|
|
36
|
+
}
|
|
37
|
+
return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length);
|
|
38
|
+
}
|
|
39
|
+
function rfdc4(opts) {
|
|
40
|
+
opts = opts || {};
|
|
41
|
+
if (opts.circles)
|
|
42
|
+
return rfdcCircles(opts);
|
|
43
|
+
return opts.proto ? cloneProto : clone2;
|
|
44
|
+
function cloneArray(a, fn) {
|
|
45
|
+
var keys = Object.keys(a);
|
|
46
|
+
var a2 = new Array(keys.length);
|
|
47
|
+
for (var i = 0; i < keys.length; i++) {
|
|
48
|
+
var k = keys[i];
|
|
49
|
+
var cur = a[k];
|
|
50
|
+
if (typeof cur !== "object" || cur === null) {
|
|
51
|
+
a2[k] = cur;
|
|
52
|
+
} else if (cur instanceof Date) {
|
|
53
|
+
a2[k] = new Date(cur);
|
|
54
|
+
} else if (ArrayBuffer.isView(cur)) {
|
|
55
|
+
a2[k] = copyBuffer(cur);
|
|
56
|
+
} else {
|
|
57
|
+
a2[k] = fn(cur);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return a2;
|
|
61
|
+
}
|
|
62
|
+
function clone2(o) {
|
|
63
|
+
if (typeof o !== "object" || o === null)
|
|
64
|
+
return o;
|
|
65
|
+
if (o instanceof Date)
|
|
66
|
+
return new Date(o);
|
|
67
|
+
if (Array.isArray(o))
|
|
68
|
+
return cloneArray(o, clone2);
|
|
69
|
+
if (o instanceof Map)
|
|
70
|
+
return new Map(cloneArray(Array.from(o), clone2));
|
|
71
|
+
if (o instanceof Set)
|
|
72
|
+
return new Set(cloneArray(Array.from(o), clone2));
|
|
73
|
+
var o2 = {};
|
|
74
|
+
for (var k in o) {
|
|
75
|
+
if (Object.hasOwnProperty.call(o, k) === false)
|
|
76
|
+
continue;
|
|
77
|
+
var cur = o[k];
|
|
78
|
+
if (typeof cur !== "object" || cur === null) {
|
|
79
|
+
o2[k] = cur;
|
|
80
|
+
} else if (cur instanceof Date) {
|
|
81
|
+
o2[k] = new Date(cur);
|
|
82
|
+
} else if (cur instanceof Map) {
|
|
83
|
+
o2[k] = new Map(cloneArray(Array.from(cur), clone2));
|
|
84
|
+
} else if (cur instanceof Set) {
|
|
85
|
+
o2[k] = new Set(cloneArray(Array.from(cur), clone2));
|
|
86
|
+
} else if (ArrayBuffer.isView(cur)) {
|
|
87
|
+
o2[k] = copyBuffer(cur);
|
|
88
|
+
} else {
|
|
89
|
+
o2[k] = clone2(cur);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return o2;
|
|
93
|
+
}
|
|
94
|
+
function cloneProto(o) {
|
|
95
|
+
if (typeof o !== "object" || o === null)
|
|
96
|
+
return o;
|
|
97
|
+
if (o instanceof Date)
|
|
98
|
+
return new Date(o);
|
|
99
|
+
if (Array.isArray(o))
|
|
100
|
+
return cloneArray(o, cloneProto);
|
|
101
|
+
if (o instanceof Map)
|
|
102
|
+
return new Map(cloneArray(Array.from(o), cloneProto));
|
|
103
|
+
if (o instanceof Set)
|
|
104
|
+
return new Set(cloneArray(Array.from(o), cloneProto));
|
|
105
|
+
var o2 = {};
|
|
106
|
+
for (var k in o) {
|
|
107
|
+
var cur = o[k];
|
|
108
|
+
if (typeof cur !== "object" || cur === null) {
|
|
109
|
+
o2[k] = cur;
|
|
110
|
+
} else if (cur instanceof Date) {
|
|
111
|
+
o2[k] = new Date(cur);
|
|
112
|
+
} else if (cur instanceof Map) {
|
|
113
|
+
o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
|
|
114
|
+
} else if (cur instanceof Set) {
|
|
115
|
+
o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
|
|
116
|
+
} else if (ArrayBuffer.isView(cur)) {
|
|
117
|
+
o2[k] = copyBuffer(cur);
|
|
118
|
+
} else {
|
|
119
|
+
o2[k] = cloneProto(cur);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return o2;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function rfdcCircles(opts) {
|
|
126
|
+
var refs = [];
|
|
127
|
+
var refsNew = [];
|
|
128
|
+
return opts.proto ? cloneProto : clone2;
|
|
129
|
+
function cloneArray(a, fn) {
|
|
130
|
+
var keys = Object.keys(a);
|
|
131
|
+
var a2 = new Array(keys.length);
|
|
132
|
+
for (var i = 0; i < keys.length; i++) {
|
|
133
|
+
var k = keys[i];
|
|
134
|
+
var cur = a[k];
|
|
135
|
+
if (typeof cur !== "object" || cur === null) {
|
|
136
|
+
a2[k] = cur;
|
|
137
|
+
} else if (cur instanceof Date) {
|
|
138
|
+
a2[k] = new Date(cur);
|
|
139
|
+
} else if (ArrayBuffer.isView(cur)) {
|
|
140
|
+
a2[k] = copyBuffer(cur);
|
|
141
|
+
} else {
|
|
142
|
+
var index = refs.indexOf(cur);
|
|
143
|
+
if (index !== -1) {
|
|
144
|
+
a2[k] = refsNew[index];
|
|
145
|
+
} else {
|
|
146
|
+
a2[k] = fn(cur);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return a2;
|
|
151
|
+
}
|
|
152
|
+
function clone2(o) {
|
|
153
|
+
if (typeof o !== "object" || o === null)
|
|
154
|
+
return o;
|
|
155
|
+
if (o instanceof Date)
|
|
156
|
+
return new Date(o);
|
|
157
|
+
if (Array.isArray(o))
|
|
158
|
+
return cloneArray(o, clone2);
|
|
159
|
+
if (o instanceof Map)
|
|
160
|
+
return new Map(cloneArray(Array.from(o), clone2));
|
|
161
|
+
if (o instanceof Set)
|
|
162
|
+
return new Set(cloneArray(Array.from(o), clone2));
|
|
163
|
+
var o2 = {};
|
|
164
|
+
refs.push(o);
|
|
165
|
+
refsNew.push(o2);
|
|
166
|
+
for (var k in o) {
|
|
167
|
+
if (Object.hasOwnProperty.call(o, k) === false)
|
|
168
|
+
continue;
|
|
169
|
+
var cur = o[k];
|
|
170
|
+
if (typeof cur !== "object" || cur === null) {
|
|
171
|
+
o2[k] = cur;
|
|
172
|
+
} else if (cur instanceof Date) {
|
|
173
|
+
o2[k] = new Date(cur);
|
|
174
|
+
} else if (cur instanceof Map) {
|
|
175
|
+
o2[k] = new Map(cloneArray(Array.from(cur), clone2));
|
|
176
|
+
} else if (cur instanceof Set) {
|
|
177
|
+
o2[k] = new Set(cloneArray(Array.from(cur), clone2));
|
|
178
|
+
} else if (ArrayBuffer.isView(cur)) {
|
|
179
|
+
o2[k] = copyBuffer(cur);
|
|
180
|
+
} else {
|
|
181
|
+
var i = refs.indexOf(cur);
|
|
182
|
+
if (i !== -1) {
|
|
183
|
+
o2[k] = refsNew[i];
|
|
184
|
+
} else {
|
|
185
|
+
o2[k] = clone2(cur);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
refs.pop();
|
|
190
|
+
refsNew.pop();
|
|
191
|
+
return o2;
|
|
192
|
+
}
|
|
193
|
+
function cloneProto(o) {
|
|
194
|
+
if (typeof o !== "object" || o === null)
|
|
195
|
+
return o;
|
|
196
|
+
if (o instanceof Date)
|
|
197
|
+
return new Date(o);
|
|
198
|
+
if (Array.isArray(o))
|
|
199
|
+
return cloneArray(o, cloneProto);
|
|
200
|
+
if (o instanceof Map)
|
|
201
|
+
return new Map(cloneArray(Array.from(o), cloneProto));
|
|
202
|
+
if (o instanceof Set)
|
|
203
|
+
return new Set(cloneArray(Array.from(o), cloneProto));
|
|
204
|
+
var o2 = {};
|
|
205
|
+
refs.push(o);
|
|
206
|
+
refsNew.push(o2);
|
|
207
|
+
for (var k in o) {
|
|
208
|
+
var cur = o[k];
|
|
209
|
+
if (typeof cur !== "object" || cur === null) {
|
|
210
|
+
o2[k] = cur;
|
|
211
|
+
} else if (cur instanceof Date) {
|
|
212
|
+
o2[k] = new Date(cur);
|
|
213
|
+
} else if (cur instanceof Map) {
|
|
214
|
+
o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
|
|
215
|
+
} else if (cur instanceof Set) {
|
|
216
|
+
o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
|
|
217
|
+
} else if (ArrayBuffer.isView(cur)) {
|
|
218
|
+
o2[k] = copyBuffer(cur);
|
|
219
|
+
} else {
|
|
220
|
+
var i = refs.indexOf(cur);
|
|
221
|
+
if (i !== -1) {
|
|
222
|
+
o2[k] = refsNew[i];
|
|
223
|
+
} else {
|
|
224
|
+
o2[k] = cloneProto(cur);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
refs.pop();
|
|
229
|
+
refsNew.pop();
|
|
230
|
+
return o2;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// src/components/ClientContextPersonalizationTransfer.tsx
|
|
237
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
29
238
|
|
|
30
239
|
// src/hooks/useUniformContext.ts
|
|
31
240
|
import { useEffect, useState } from "react";
|
|
@@ -47,37 +256,97 @@ var useUniformContext = () => {
|
|
|
47
256
|
};
|
|
48
257
|
};
|
|
49
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
|
+
|
|
293
|
+
// src/components/ClientContextualEditingComponentWrapper.tsx
|
|
294
|
+
import { IN_CONTEXT_EDITOR_QUERY_STRING_PARAM } from "@uniformdev/canvas";
|
|
295
|
+
import {
|
|
296
|
+
PureContextualEditingComponentWrapper
|
|
297
|
+
} from "@uniformdev/canvas-react/core";
|
|
298
|
+
import { useSearchParams } from "next/navigation";
|
|
299
|
+
import { Suspense } from "react";
|
|
300
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
301
|
+
var ClientContextualEditingComponentWrapper = (props) => {
|
|
302
|
+
return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ClientContextualEditingComponentWrapperInner, { ...props }) });
|
|
303
|
+
};
|
|
304
|
+
var ClientContextualEditingComponentWrapperInner = ({
|
|
305
|
+
children,
|
|
306
|
+
...rest
|
|
307
|
+
}) => {
|
|
308
|
+
const searchParams = useSearchParams();
|
|
309
|
+
const inContextMode = searchParams.get(IN_CONTEXT_EDITOR_QUERY_STRING_PARAM) === "true";
|
|
310
|
+
if (!inContextMode) {
|
|
311
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
312
|
+
}
|
|
313
|
+
return /* @__PURE__ */ jsx(PureContextualEditingComponentWrapper, { ...rest, children });
|
|
314
|
+
};
|
|
315
|
+
|
|
50
316
|
// src/components/ClientContextUpdate.tsx
|
|
317
|
+
import { useSearchParams as useSearchParams2 } from "next/navigation";
|
|
318
|
+
import { Suspense as Suspense2, useEffect as useEffect4 } from "react";
|
|
51
319
|
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
52
|
-
var ClientContextUpdate = () => {
|
|
53
|
-
return /* @__PURE__ */ jsx2(Suspense2, { children: /* @__PURE__ */ jsx2(ClientContextUpdateInner, {}) });
|
|
320
|
+
var ClientContextUpdate = ({ path }) => {
|
|
321
|
+
return /* @__PURE__ */ jsx2(Suspense2, { children: /* @__PURE__ */ jsx2(ClientContextUpdateInner, { path }) });
|
|
54
322
|
};
|
|
55
|
-
var ClientContextUpdateInner = () => {
|
|
56
|
-
const params = useParams();
|
|
323
|
+
var ClientContextUpdateInner = ({ path }) => {
|
|
57
324
|
const searchParams = useSearchParams2();
|
|
58
325
|
const { context } = useUniformContext();
|
|
59
|
-
|
|
326
|
+
useEffect4(() => {
|
|
60
327
|
if (!context || typeof window === "undefined") {
|
|
61
328
|
return;
|
|
62
329
|
}
|
|
63
330
|
const convertedSearchParams = Object.fromEntries(searchParams.entries());
|
|
64
331
|
context.update({
|
|
65
|
-
params
|
|
332
|
+
params: {
|
|
333
|
+
path: path.split("/").filter(Boolean)
|
|
334
|
+
},
|
|
66
335
|
searchParams: convertedSearchParams
|
|
67
336
|
});
|
|
68
|
-
}, [
|
|
337
|
+
}, [path, searchParams, context]);
|
|
69
338
|
return /* @__PURE__ */ jsx2(Fragment2, {});
|
|
70
339
|
};
|
|
71
340
|
|
|
72
341
|
// src/components/ContextUpdateTransferClient.tsx
|
|
73
|
-
import { useEffect as
|
|
342
|
+
import { useEffect as useEffect5, useState as useState4 } from "react";
|
|
74
343
|
var ContextUpdateTransferClient = ({
|
|
75
344
|
update,
|
|
76
345
|
ts
|
|
77
346
|
}) => {
|
|
78
347
|
const { context } = useUniformContext();
|
|
79
|
-
const [lastLogged, setLastLogged] =
|
|
80
|
-
|
|
348
|
+
const [lastLogged, setLastLogged] = useState4(void 0);
|
|
349
|
+
useEffect5(() => {
|
|
81
350
|
const shouldBeLogged = (!ts || lastLogged !== ts) && Object.keys(update).length > 0;
|
|
82
351
|
const hasContext = typeof context !== "undefined";
|
|
83
352
|
if (shouldBeLogged && hasContext) {
|
|
@@ -88,6 +357,548 @@ var ContextUpdateTransferClient = ({
|
|
|
88
357
|
return null;
|
|
89
358
|
};
|
|
90
359
|
|
|
360
|
+
// ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/lite/index.mjs
|
|
361
|
+
var has = Object.prototype.hasOwnProperty;
|
|
362
|
+
function dequal(foo, bar) {
|
|
363
|
+
var ctor, len;
|
|
364
|
+
if (foo === bar)
|
|
365
|
+
return true;
|
|
366
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
367
|
+
if (ctor === Date)
|
|
368
|
+
return foo.getTime() === bar.getTime();
|
|
369
|
+
if (ctor === RegExp)
|
|
370
|
+
return foo.toString() === bar.toString();
|
|
371
|
+
if (ctor === Array) {
|
|
372
|
+
if ((len = foo.length) === bar.length) {
|
|
373
|
+
while (len-- && dequal(foo[len], bar[len]))
|
|
374
|
+
;
|
|
375
|
+
}
|
|
376
|
+
return len === -1;
|
|
377
|
+
}
|
|
378
|
+
if (!ctor || typeof foo === "object") {
|
|
379
|
+
len = 0;
|
|
380
|
+
for (ctor in foo) {
|
|
381
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor))
|
|
382
|
+
return false;
|
|
383
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor]))
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return Object.keys(bar).length === len;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return foo !== foo && bar !== bar;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// ../../node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.mjs
|
|
393
|
+
function assign(target) {
|
|
394
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
395
|
+
var source = arguments[i];
|
|
396
|
+
for (var key in source) {
|
|
397
|
+
target[key] = source[key];
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return target;
|
|
401
|
+
}
|
|
402
|
+
var defaultConverter = {
|
|
403
|
+
read: function(value) {
|
|
404
|
+
if (value[0] === '"') {
|
|
405
|
+
value = value.slice(1, -1);
|
|
406
|
+
}
|
|
407
|
+
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
408
|
+
},
|
|
409
|
+
write: function(value) {
|
|
410
|
+
return encodeURIComponent(value).replace(
|
|
411
|
+
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
412
|
+
decodeURIComponent
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
function init(converter, defaultAttributes) {
|
|
417
|
+
function set(name, value, attributes) {
|
|
418
|
+
if (typeof document === "undefined") {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
attributes = assign({}, defaultAttributes, attributes);
|
|
422
|
+
if (typeof attributes.expires === "number") {
|
|
423
|
+
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
|
|
424
|
+
}
|
|
425
|
+
if (attributes.expires) {
|
|
426
|
+
attributes.expires = attributes.expires.toUTCString();
|
|
427
|
+
}
|
|
428
|
+
name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
429
|
+
var stringifiedAttributes = "";
|
|
430
|
+
for (var attributeName in attributes) {
|
|
431
|
+
if (!attributes[attributeName]) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
stringifiedAttributes += "; " + attributeName;
|
|
435
|
+
if (attributes[attributeName] === true) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
|
|
439
|
+
}
|
|
440
|
+
return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
|
|
441
|
+
}
|
|
442
|
+
function get(name) {
|
|
443
|
+
if (typeof document === "undefined" || arguments.length && !name) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
var cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
447
|
+
var jar = {};
|
|
448
|
+
for (var i = 0; i < cookies.length; i++) {
|
|
449
|
+
var parts = cookies[i].split("=");
|
|
450
|
+
var value = parts.slice(1).join("=");
|
|
451
|
+
try {
|
|
452
|
+
var found = decodeURIComponent(parts[0]);
|
|
453
|
+
jar[found] = converter.read(value, found);
|
|
454
|
+
if (name === found) {
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
} catch (e) {
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return name ? jar[name] : jar;
|
|
461
|
+
}
|
|
462
|
+
return Object.create(
|
|
463
|
+
{
|
|
464
|
+
set,
|
|
465
|
+
get,
|
|
466
|
+
remove: function(name, attributes) {
|
|
467
|
+
set(
|
|
468
|
+
name,
|
|
469
|
+
"",
|
|
470
|
+
assign({}, attributes, {
|
|
471
|
+
expires: -1
|
|
472
|
+
})
|
|
473
|
+
);
|
|
474
|
+
},
|
|
475
|
+
withAttributes: function(attributes) {
|
|
476
|
+
return init(this.converter, assign({}, this.attributes, attributes));
|
|
477
|
+
},
|
|
478
|
+
withConverter: function(converter2) {
|
|
479
|
+
return init(assign({}, this.converter, converter2), this.attributes);
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
attributes: { value: Object.freeze(defaultAttributes) },
|
|
484
|
+
converter: { value: Object.freeze(converter) }
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
var api = init(defaultConverter, { path: "/" });
|
|
489
|
+
|
|
490
|
+
// ../context/dist/index.mjs
|
|
491
|
+
var import_rfdc = __toESM(require_rfdc(), 1);
|
|
492
|
+
var import_rfdc2 = __toESM(require_rfdc(), 1);
|
|
493
|
+
var import_rfdc3 = __toESM(require_rfdc(), 1);
|
|
494
|
+
var __accessCheck = (obj, member, msg) => {
|
|
495
|
+
if (!member.has(obj))
|
|
496
|
+
throw TypeError("Cannot " + msg);
|
|
497
|
+
};
|
|
498
|
+
var __privateGet = (obj, member, getter) => {
|
|
499
|
+
__accessCheck(obj, member, "read from private field");
|
|
500
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
501
|
+
};
|
|
502
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
503
|
+
__accessCheck(obj, member, "write to private field");
|
|
504
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
505
|
+
return value;
|
|
506
|
+
};
|
|
507
|
+
var __privateMethod = (obj, member, method) => {
|
|
508
|
+
__accessCheck(obj, member, "access private method");
|
|
509
|
+
return method;
|
|
510
|
+
};
|
|
511
|
+
var ENR_SEPARATOR = "_";
|
|
512
|
+
var _evaluator;
|
|
513
|
+
var _onLogMessage;
|
|
514
|
+
_evaluator = /* @__PURE__ */ new WeakMap();
|
|
515
|
+
_onLogMessage = /* @__PURE__ */ new WeakMap();
|
|
516
|
+
var _mf;
|
|
517
|
+
var _signalInstances;
|
|
518
|
+
var _onLogMessage2;
|
|
519
|
+
_mf = /* @__PURE__ */ new WeakMap();
|
|
520
|
+
_signalInstances = /* @__PURE__ */ new WeakMap();
|
|
521
|
+
_onLogMessage2 = /* @__PURE__ */ new WeakMap();
|
|
522
|
+
function getEnrichmentVectorKey(category, value) {
|
|
523
|
+
return `${category}${ENR_SEPARATOR}${value}`;
|
|
524
|
+
}
|
|
525
|
+
function isNumberMatch(lhs, match) {
|
|
526
|
+
var _a;
|
|
527
|
+
if (typeof lhs === "undefined" || lhs === null) {
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
const lhsValue = Number(lhs);
|
|
531
|
+
if (isNaN(lhsValue)) {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
switch ((_a = match == null ? void 0 : match.op) != null ? _a : "=") {
|
|
535
|
+
case "=":
|
|
536
|
+
return lhsValue === match.rhs;
|
|
537
|
+
case "!=":
|
|
538
|
+
return lhsValue !== match.rhs;
|
|
539
|
+
case ">":
|
|
540
|
+
return lhsValue > match.rhs;
|
|
541
|
+
case "<":
|
|
542
|
+
return lhsValue < match.rhs;
|
|
543
|
+
default:
|
|
544
|
+
console.warn(`Unknown match type ${match.op} is false.`);
|
|
545
|
+
return false;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function explainNumberMatch(lhs, match) {
|
|
549
|
+
return `${lhs} ${explainNumberMatchCriteria(match)}`;
|
|
550
|
+
}
|
|
551
|
+
function explainNumberMatchCriteria(match) {
|
|
552
|
+
return `${match.op} ${match.rhs}`;
|
|
553
|
+
}
|
|
554
|
+
var pageViewCountDimension = getEnrichmentVectorKey("$pvc", "v");
|
|
555
|
+
var pageViewCountEvaluator = ({ update, criteria, commands, onLogMessage }) => {
|
|
556
|
+
var _a, _b;
|
|
557
|
+
if (criteria.type !== "PVC") {
|
|
558
|
+
return { result: false, changed: false };
|
|
559
|
+
}
|
|
560
|
+
const hasUrlChanged = Boolean(
|
|
561
|
+
update.state.url && (!update.previousState || ((_a = update.state.url) == null ? void 0 : _a.toString()) !== ((_b = update.previousState.url) == null ? void 0 : _b.toString()))
|
|
562
|
+
);
|
|
563
|
+
const existingValueNumber = update.visitor.sessionScores[pageViewCountDimension] || 0;
|
|
564
|
+
const updatedCount = existingValueNumber + 1;
|
|
565
|
+
const finalResult = { result: false, changed: hasUrlChanged };
|
|
566
|
+
const hasExistingPageViewIncrementCommand = commands.some(
|
|
567
|
+
(c) => c.type === "modscoreS" && c.data.dimension === pageViewCountDimension
|
|
568
|
+
);
|
|
569
|
+
if (hasUrlChanged && !hasExistingPageViewIncrementCommand) {
|
|
570
|
+
commands.push({
|
|
571
|
+
type: "modscoreS",
|
|
572
|
+
data: {
|
|
573
|
+
dimension: pageViewCountDimension,
|
|
574
|
+
delta: 1
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
if (isNumberMatch(updatedCount, criteria.match)) {
|
|
579
|
+
finalResult.result = true;
|
|
580
|
+
}
|
|
581
|
+
onLogMessage == null ? void 0 : onLogMessage([
|
|
582
|
+
"debug",
|
|
583
|
+
203,
|
|
584
|
+
{ criteria, result: finalResult, explanation: explainNumberMatch(updatedCount, criteria.match) }
|
|
585
|
+
]);
|
|
586
|
+
return finalResult;
|
|
587
|
+
};
|
|
588
|
+
pageViewCountEvaluator.alwaysExecute = true;
|
|
589
|
+
var _evaluators;
|
|
590
|
+
_evaluators = /* @__PURE__ */ new WeakMap();
|
|
591
|
+
var _data;
|
|
592
|
+
var _initialData;
|
|
593
|
+
var _mitt;
|
|
594
|
+
_data = /* @__PURE__ */ new WeakMap();
|
|
595
|
+
_initialData = /* @__PURE__ */ new WeakMap();
|
|
596
|
+
_mitt = /* @__PURE__ */ new WeakMap();
|
|
597
|
+
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
598
|
+
var b2s = alphabet.split("");
|
|
599
|
+
var s2b = new Array(123);
|
|
600
|
+
for (let i = 0; i < alphabet.length; i++) {
|
|
601
|
+
s2b[alphabet.charCodeAt(i)] = i;
|
|
602
|
+
}
|
|
603
|
+
var _cookieName;
|
|
604
|
+
var _cookieAttributes;
|
|
605
|
+
_cookieName = /* @__PURE__ */ new WeakMap();
|
|
606
|
+
_cookieAttributes = /* @__PURE__ */ new WeakMap();
|
|
607
|
+
var _fetchData;
|
|
608
|
+
var fetchData_fn;
|
|
609
|
+
_fetchData = /* @__PURE__ */ new WeakSet();
|
|
610
|
+
fetchData_fn = async function() {
|
|
611
|
+
const serviceData = await new Promise((resolve) => {
|
|
612
|
+
setTimeout(() => {
|
|
613
|
+
resolve(void 0);
|
|
614
|
+
}, 2e3);
|
|
615
|
+
});
|
|
616
|
+
if (serviceData) {
|
|
617
|
+
this.signalAsyncDataUpdate(serviceData);
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
var emptyVisitorData = () => ({
|
|
621
|
+
quirks: {},
|
|
622
|
+
scores: {},
|
|
623
|
+
sessionScores: {},
|
|
624
|
+
tests: {},
|
|
625
|
+
consent: false,
|
|
626
|
+
controlGroup: false,
|
|
627
|
+
personalizeVariants: {}
|
|
628
|
+
});
|
|
629
|
+
var clone = (0, import_rfdc.default)();
|
|
630
|
+
var STORAGE_KEY = "ufvisitor";
|
|
631
|
+
var _mitt2;
|
|
632
|
+
var _persist;
|
|
633
|
+
var _visitTimeout;
|
|
634
|
+
var _options;
|
|
635
|
+
var _currentData;
|
|
636
|
+
var currentData_get;
|
|
637
|
+
var _replaceData;
|
|
638
|
+
var replaceData_fn;
|
|
639
|
+
var _setVisitTimeout;
|
|
640
|
+
var setVisitTimeout_fn;
|
|
641
|
+
var _isExpired;
|
|
642
|
+
var isExpired_fn;
|
|
643
|
+
var _handleCaps;
|
|
644
|
+
var handleCaps_fn;
|
|
645
|
+
var _defaultData;
|
|
646
|
+
var defaultData_fn;
|
|
647
|
+
_mitt2 = /* @__PURE__ */ new WeakMap();
|
|
648
|
+
_persist = /* @__PURE__ */ new WeakMap();
|
|
649
|
+
_visitTimeout = /* @__PURE__ */ new WeakMap();
|
|
650
|
+
_options = /* @__PURE__ */ new WeakMap();
|
|
651
|
+
_currentData = /* @__PURE__ */ new WeakSet();
|
|
652
|
+
currentData_get = function() {
|
|
653
|
+
return __privateGet(this, _persist).get(STORAGE_KEY);
|
|
654
|
+
};
|
|
655
|
+
_replaceData = /* @__PURE__ */ new WeakSet();
|
|
656
|
+
replaceData_fn = function(data, quiet = false) {
|
|
657
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
658
|
+
const oldData = __privateGet(this, _currentData, currentData_get);
|
|
659
|
+
const now = Date.now();
|
|
660
|
+
if (data.controlGroup) {
|
|
661
|
+
data.scores = {};
|
|
662
|
+
data.sessionScores = {};
|
|
663
|
+
} else {
|
|
664
|
+
__privateMethod(this, _handleCaps, handleCaps_fn).call(this, data.scores);
|
|
665
|
+
__privateMethod(this, _handleCaps, handleCaps_fn).call(this, data.sessionScores);
|
|
666
|
+
(_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
|
|
667
|
+
now,
|
|
668
|
+
lastUpd: oldData == null ? void 0 : oldData.updated,
|
|
669
|
+
scores: data.scores,
|
|
670
|
+
sessionScores: data.sessionScores,
|
|
671
|
+
onLogMessage: __privateGet(this, _options).onLogMessage
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
const haveScoresChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.scores, data.scores);
|
|
675
|
+
const haveSessionScoresChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.sessionScores, data.sessionScores);
|
|
676
|
+
const haveQuirksChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.quirks, data.quirks);
|
|
677
|
+
const haveTestsChanged = !dequal(oldData == null ? void 0 : oldData.visitorData.tests, data.tests);
|
|
678
|
+
const updatedData = {
|
|
679
|
+
updated: now,
|
|
680
|
+
visitorData: data
|
|
681
|
+
};
|
|
682
|
+
__privateMethod(this, _setVisitTimeout, setVisitTimeout_fn).call(this);
|
|
683
|
+
__privateGet(this, _persist).set(STORAGE_KEY, updatedData, !!data.consent);
|
|
684
|
+
(_d = (_c = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _d.call(_c, ["debug", 102, data]);
|
|
685
|
+
if (!quiet) {
|
|
686
|
+
if (haveScoresChanged || haveSessionScoresChanged) {
|
|
687
|
+
__privateGet(this, _mitt2).emit("scoresUpdated", data);
|
|
688
|
+
}
|
|
689
|
+
if (haveQuirksChanged) {
|
|
690
|
+
__privateGet(this, _mitt2).emit("quirksUpdated", data);
|
|
691
|
+
}
|
|
692
|
+
if (haveTestsChanged) {
|
|
693
|
+
__privateGet(this, _mitt2).emit("testsUpdated", data);
|
|
694
|
+
}
|
|
695
|
+
if (((_e = oldData == null ? void 0 : oldData.visitorData) == null ? void 0 : _e.consent) !== data.consent) {
|
|
696
|
+
__privateGet(this, _mitt2).emit("consentUpdated", data);
|
|
697
|
+
}
|
|
698
|
+
if (((_f = oldData == null ? void 0 : oldData.visitorData) == null ? void 0 : _f.controlGroup) !== data.controlGroup) {
|
|
699
|
+
__privateGet(this, _mitt2).emit("controlGroupUpdated", data);
|
|
700
|
+
(_i = (_h = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _i.call(_h, ["debug", 104, (_g = data.controlGroup) != null ? _g : false]);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
_setVisitTimeout = /* @__PURE__ */ new WeakSet();
|
|
705
|
+
setVisitTimeout_fn = function() {
|
|
706
|
+
if (typeof document === "undefined" || !__privateGet(this, _options).visitLifespan) {
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (__privateGet(this, _visitTimeout)) {
|
|
710
|
+
window.clearTimeout(__privateGet(this, _visitTimeout));
|
|
711
|
+
}
|
|
712
|
+
__privateSet(this, _visitTimeout, window.setTimeout(() => {
|
|
713
|
+
this.data;
|
|
714
|
+
}, __privateGet(this, _options).visitLifespan + 50));
|
|
715
|
+
};
|
|
716
|
+
_isExpired = /* @__PURE__ */ new WeakSet();
|
|
717
|
+
isExpired_fn = function(data) {
|
|
718
|
+
const expires = __privateGet(this, _options).visitLifespan;
|
|
719
|
+
return expires ? data.updated + expires < Date.now() : false;
|
|
720
|
+
};
|
|
721
|
+
_handleCaps = /* @__PURE__ */ new WeakSet();
|
|
722
|
+
handleCaps_fn = function(scores) {
|
|
723
|
+
var _a, _b;
|
|
724
|
+
if (!__privateGet(this, _options).manifest) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
for (const dim in scores) {
|
|
728
|
+
const score = scores[dim];
|
|
729
|
+
const dimDef = __privateGet(this, _options).manifest.getDimensionByKey(dim);
|
|
730
|
+
if (!dimDef) {
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
if (score > dimDef.cap) {
|
|
734
|
+
(_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["debug", 110, { dim, score, cap: dimDef.cap }]);
|
|
735
|
+
scores[dim] = dimDef.cap;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
_defaultData = /* @__PURE__ */ new WeakSet();
|
|
740
|
+
defaultData_fn = function() {
|
|
741
|
+
var _a, _b, _c;
|
|
742
|
+
return {
|
|
743
|
+
...emptyVisitorData(),
|
|
744
|
+
consent: (_a = __privateGet(this, _options).defaultConsent) != null ? _a : false,
|
|
745
|
+
controlGroup: (_c = (_b = __privateGet(this, _options).manifest) == null ? void 0 : _b.rollForControlGroup()) != null ? _c : false
|
|
746
|
+
};
|
|
747
|
+
};
|
|
748
|
+
var _serverTransitionState;
|
|
749
|
+
var _scores;
|
|
750
|
+
var _state;
|
|
751
|
+
var _pzCache;
|
|
752
|
+
var _mitt3;
|
|
753
|
+
var _emitTest;
|
|
754
|
+
var emitTest_fn;
|
|
755
|
+
var _updateComputedScores;
|
|
756
|
+
var updateComputedScores_fn;
|
|
757
|
+
var _calculateScores;
|
|
758
|
+
var calculateScores_fn;
|
|
759
|
+
_serverTransitionState = /* @__PURE__ */ new WeakMap();
|
|
760
|
+
_scores = /* @__PURE__ */ new WeakMap();
|
|
761
|
+
_state = /* @__PURE__ */ new WeakMap();
|
|
762
|
+
_pzCache = /* @__PURE__ */ new WeakMap();
|
|
763
|
+
_mitt3 = /* @__PURE__ */ new WeakMap();
|
|
764
|
+
_emitTest = /* @__PURE__ */ new WeakSet();
|
|
765
|
+
emitTest_fn = function(event) {
|
|
766
|
+
__privateGet(this, _mitt3).emit("testResult", event);
|
|
767
|
+
};
|
|
768
|
+
_updateComputedScores = /* @__PURE__ */ new WeakSet();
|
|
769
|
+
updateComputedScores_fn = function(newData) {
|
|
770
|
+
const newScores = __privateMethod(this, _calculateScores, calculateScores_fn).call(this, newData);
|
|
771
|
+
const newScoresHaveChanged = !dequal(newScores, __privateGet(this, _scores));
|
|
772
|
+
if (newScoresHaveChanged) {
|
|
773
|
+
__privateSet(this, _scores, newScores);
|
|
774
|
+
__privateGet(this, _mitt3).emit("scoresUpdated", newScores);
|
|
775
|
+
__privateGet(this, _mitt3).emit("log", ["info", 3, newScores]);
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
_calculateScores = /* @__PURE__ */ new WeakSet();
|
|
779
|
+
calculateScores_fn = function(newData) {
|
|
780
|
+
var _a;
|
|
781
|
+
let newScores = { ...newData.scores };
|
|
782
|
+
for (const session in newData.sessionScores) {
|
|
783
|
+
newScores[session] = ((_a = newScores[session]) != null ? _a : 0) + newData.sessionScores[session];
|
|
784
|
+
}
|
|
785
|
+
newScores = this.manifest.computeAggregateDimensions(newScores);
|
|
786
|
+
return newScores;
|
|
787
|
+
};
|
|
788
|
+
var isBrowser = typeof top !== "undefined";
|
|
789
|
+
function enableContextDevTools(options) {
|
|
790
|
+
return {
|
|
791
|
+
logDrain: (message) => {
|
|
792
|
+
if (!isBrowser) {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
top == null ? void 0 : top.postMessage(
|
|
796
|
+
{
|
|
797
|
+
type: "uniform:context:log",
|
|
798
|
+
message
|
|
799
|
+
},
|
|
800
|
+
window.location.origin
|
|
801
|
+
);
|
|
802
|
+
},
|
|
803
|
+
init: (context) => {
|
|
804
|
+
const personalizations = [];
|
|
805
|
+
const tests = [];
|
|
806
|
+
const onContextDataUpdated = () => {
|
|
807
|
+
if (!isBrowser) {
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
top == null ? void 0 : top.postMessage(
|
|
811
|
+
{
|
|
812
|
+
type: "uniform:context:data",
|
|
813
|
+
data: {
|
|
814
|
+
scores: context.scores,
|
|
815
|
+
data: context.storage.data,
|
|
816
|
+
manifest: context.manifest.data,
|
|
817
|
+
personalizations,
|
|
818
|
+
tests
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
window.location.origin
|
|
822
|
+
);
|
|
823
|
+
};
|
|
824
|
+
const onPersonalizationResult = (e) => {
|
|
825
|
+
if (!e.changed)
|
|
826
|
+
return;
|
|
827
|
+
personalizations.push(e);
|
|
828
|
+
};
|
|
829
|
+
const onTestResult = (e) => {
|
|
830
|
+
if (!e.variantAssigned)
|
|
831
|
+
return;
|
|
832
|
+
tests.push(e);
|
|
833
|
+
};
|
|
834
|
+
if (isBrowser) {
|
|
835
|
+
window.__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__ = context;
|
|
836
|
+
try {
|
|
837
|
+
top == null ? void 0 : top.addEventListener("message", async (event) => {
|
|
838
|
+
if (!event.data) {
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
const message = event.data;
|
|
842
|
+
await handleMessageFromDevTools({
|
|
843
|
+
message,
|
|
844
|
+
context,
|
|
845
|
+
afterMessageReceived: options == null ? void 0 : options.onAfterMessageReceived
|
|
846
|
+
});
|
|
847
|
+
});
|
|
848
|
+
} catch (e) {
|
|
849
|
+
console.warn(
|
|
850
|
+
"Unable to initialize Uniform Context DevTools because it is in a cross-domain iframe.",
|
|
851
|
+
e
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
top == null ? void 0 : top.postMessage(
|
|
855
|
+
{
|
|
856
|
+
type: "uniform:context:hello",
|
|
857
|
+
uiVersion: 2
|
|
858
|
+
},
|
|
859
|
+
window.location.origin
|
|
860
|
+
);
|
|
861
|
+
onContextDataUpdated();
|
|
862
|
+
}
|
|
863
|
+
context.events.on("personalizationResult", onPersonalizationResult);
|
|
864
|
+
context.events.on("testResult", onTestResult);
|
|
865
|
+
context.events.on("scoresUpdated", onContextDataUpdated);
|
|
866
|
+
return () => {
|
|
867
|
+
context.events.off("scoresUpdated", onContextDataUpdated);
|
|
868
|
+
context.events.off("personalizationResult", onPersonalizationResult);
|
|
869
|
+
context.events.off("testResult", onTestResult);
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
async function handleMessageFromDevTools({
|
|
875
|
+
message,
|
|
876
|
+
context,
|
|
877
|
+
afterMessageReceived
|
|
878
|
+
}) {
|
|
879
|
+
let receivedUniformMessage = false;
|
|
880
|
+
if (message.type === "uniform-in:context:update" && message.newData) {
|
|
881
|
+
receivedUniformMessage = true;
|
|
882
|
+
await context.update(message.newData);
|
|
883
|
+
}
|
|
884
|
+
if (message.type === "uniform-in:context:commands" && message.commands && Array.isArray(message.commands)) {
|
|
885
|
+
receivedUniformMessage = true;
|
|
886
|
+
await context.storage.updateData(message.commands);
|
|
887
|
+
}
|
|
888
|
+
if (message.type === "uniform-in:context:forget") {
|
|
889
|
+
receivedUniformMessage = true;
|
|
890
|
+
await context.forget(false);
|
|
891
|
+
}
|
|
892
|
+
if (receivedUniformMessage && typeof afterMessageReceived === "function") {
|
|
893
|
+
afterMessageReceived(message);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
var dc = (0, import_rfdc2.default)();
|
|
897
|
+
var dc2 = (0, import_rfdc3.default)();
|
|
898
|
+
|
|
899
|
+
// src/components/DefaultUniformClientContext.tsx
|
|
900
|
+
import { useRouter } from "next/navigation";
|
|
901
|
+
|
|
91
902
|
// src/context/createClientUniformContext.ts
|
|
92
903
|
import { createUniformContext } from "@uniformdev/canvas-next-rsc-shared";
|
|
93
904
|
var createClientUniformContext = (options) => {
|
|
@@ -98,10 +909,10 @@ var createClientUniformContext = (options) => {
|
|
|
98
909
|
};
|
|
99
910
|
|
|
100
911
|
// src/hooks/useInitUniformContext.ts
|
|
101
|
-
import { useEffect as
|
|
912
|
+
import { useEffect as useEffect6, useState as useState5 } from "react";
|
|
102
913
|
var useInitUniformContext = (callback) => {
|
|
103
|
-
const [called, setCalled] =
|
|
104
|
-
|
|
914
|
+
const [called, setCalled] = useState5(false);
|
|
915
|
+
useEffect6(() => {
|
|
105
916
|
if (typeof window === "undefined" || called || typeof window.__UNIFORM_CONTEXT__ !== "undefined") {
|
|
106
917
|
return;
|
|
107
918
|
}
|
|
@@ -113,10 +924,27 @@ var useInitUniformContext = (callback) => {
|
|
|
113
924
|
};
|
|
114
925
|
|
|
115
926
|
// src/components/DefaultUniformClientContext.tsx
|
|
116
|
-
var DefaultUniformClientContext = ({
|
|
927
|
+
var DefaultUniformClientContext = ({
|
|
928
|
+
manifest,
|
|
929
|
+
disableDevTools,
|
|
930
|
+
defaultConsent
|
|
931
|
+
}) => {
|
|
932
|
+
const router = useRouter();
|
|
117
933
|
useInitUniformContext(() => {
|
|
934
|
+
const plugins = [];
|
|
935
|
+
if (!disableDevTools) {
|
|
936
|
+
plugins.push(
|
|
937
|
+
enableContextDevTools({
|
|
938
|
+
onAfterMessageReceived: () => {
|
|
939
|
+
router.refresh();
|
|
940
|
+
}
|
|
941
|
+
})
|
|
942
|
+
);
|
|
943
|
+
}
|
|
118
944
|
return createClientUniformContext({
|
|
119
|
-
manifest
|
|
945
|
+
manifest,
|
|
946
|
+
plugins,
|
|
947
|
+
defaultConsent
|
|
120
948
|
});
|
|
121
949
|
});
|
|
122
950
|
return null;
|
|
@@ -125,12 +953,12 @@ var DefaultUniformClientContext = ({ manifest }) => {
|
|
|
125
953
|
// src/components/PersonalizeClient.ts
|
|
126
954
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
127
955
|
import { runPersonalization } from "@uniformdev/canvas-next-rsc-shared";
|
|
128
|
-
import { createElement, Fragment as Fragment3, useEffect as
|
|
956
|
+
import { createElement, Fragment as Fragment3, useEffect as useEffect7, useState as useState6 } from "react";
|
|
129
957
|
var PersonalizeClient = (props) => {
|
|
130
958
|
const { slots } = props;
|
|
131
959
|
const { context } = useUniformContext();
|
|
132
|
-
const [indexesToShow, setIndexesToShow] =
|
|
133
|
-
|
|
960
|
+
const [indexesToShow, setIndexesToShow] = useState6(props.indexes);
|
|
961
|
+
useEffect7(() => {
|
|
134
962
|
const result = runPersonalization({
|
|
135
963
|
...props,
|
|
136
964
|
contextInstance: context
|
|
@@ -147,13 +975,13 @@ var PersonalizeClient = (props) => {
|
|
|
147
975
|
// src/components/TestClient.ts
|
|
148
976
|
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
149
977
|
import { runTest } from "@uniformdev/canvas-next-rsc-shared";
|
|
150
|
-
import { createElement as createElement2, Fragment as Fragment4, useEffect as
|
|
978
|
+
import { createElement as createElement2, Fragment as Fragment4, useEffect as useEffect8, useState as useState7 } from "react";
|
|
151
979
|
var TestClient = (props) => {
|
|
152
980
|
var _a;
|
|
153
981
|
const { slots } = props;
|
|
154
982
|
const { context } = useUniformContext();
|
|
155
|
-
const [index, setIndex] =
|
|
156
|
-
|
|
983
|
+
const [index, setIndex] = useState7(0);
|
|
984
|
+
useEffect8(() => {
|
|
157
985
|
const result = runTest({
|
|
158
986
|
...props,
|
|
159
987
|
contextInstance: context
|
|
@@ -172,11 +1000,11 @@ import {
|
|
|
172
1000
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM as IN_CONTEXT_EDITOR_QUERY_STRING_PARAM2,
|
|
173
1001
|
isAllowedReferrer
|
|
174
1002
|
} from "@uniformdev/canvas";
|
|
175
|
-
import { useRouter, useSearchParams as useSearchParams3 } from "next/navigation";
|
|
176
|
-
import { useEffect as
|
|
1003
|
+
import { useRouter as useRouter2, useSearchParams as useSearchParams3 } from "next/navigation";
|
|
1004
|
+
import { useEffect as useEffect9, useMemo, useRef } from "react";
|
|
177
1005
|
import { Fragment as Fragment5, jsx as jsx3 } from "react/jsx-runtime";
|
|
178
1006
|
var UniformScript = () => {
|
|
179
|
-
const router =
|
|
1007
|
+
const router = useRouter2();
|
|
180
1008
|
const params = useSearchParams3();
|
|
181
1009
|
const needsToRefreshRef = useRef(false);
|
|
182
1010
|
const enabled = params.get(IN_CONTEXT_EDITOR_QUERY_STRING_PARAM2) === "true";
|
|
@@ -191,7 +1019,7 @@ var UniformScript = () => {
|
|
|
191
1019
|
});
|
|
192
1020
|
return instance;
|
|
193
1021
|
}, []);
|
|
194
|
-
|
|
1022
|
+
useEffect9(() => {
|
|
195
1023
|
if (!channel) {
|
|
196
1024
|
return;
|
|
197
1025
|
}
|
|
@@ -208,7 +1036,7 @@ var UniformScript = () => {
|
|
|
208
1036
|
unsubscribeFromEditorUpdates();
|
|
209
1037
|
};
|
|
210
1038
|
}, [channel, router]);
|
|
211
|
-
|
|
1039
|
+
useEffect9(() => {
|
|
212
1040
|
if (typeof window === "undefined") {
|
|
213
1041
|
return;
|
|
214
1042
|
}
|
|
@@ -229,7 +1057,7 @@ var UniformScript = () => {
|
|
|
229
1057
|
existing.remove();
|
|
230
1058
|
}
|
|
231
1059
|
}, [enabled]);
|
|
232
|
-
|
|
1060
|
+
useEffect9(() => {
|
|
233
1061
|
const handleBlurChange = () => {
|
|
234
1062
|
if (needsToRefreshRef.current) {
|
|
235
1063
|
router.refresh();
|
|
@@ -244,6 +1072,8 @@ var UniformScript = () => {
|
|
|
244
1072
|
return /* @__PURE__ */ jsx3(Fragment5, {});
|
|
245
1073
|
};
|
|
246
1074
|
export {
|
|
1075
|
+
ClientContextPersonalizationTransfer,
|
|
1076
|
+
ClientContextTestTransfer,
|
|
247
1077
|
ClientContextUpdate,
|
|
248
1078
|
ClientContextualEditingComponentWrapper,
|
|
249
1079
|
ContextUpdateTransferClient,
|
|
@@ -255,3 +1085,8 @@ export {
|
|
|
255
1085
|
useInitUniformContext,
|
|
256
1086
|
useUniformContext
|
|
257
1087
|
};
|
|
1088
|
+
/*! Bundled license information:
|
|
1089
|
+
|
|
1090
|
+
js-cookie/dist/js.cookie.mjs:
|
|
1091
|
+
(*! js-cookie v3.0.5 | MIT *)
|
|
1092
|
+
*/
|