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