@uniformdev/context-vue 16.2.1-nuxt.249 → 16.2.1-nuxt.325
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.ts +2 -4
- package/dist/index.esm.js +612 -1
- package/dist/index.js +653 -1
- package/dist/index.mjs +612 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1 +1,653 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Personalize: () => Personalize_default,
|
|
24
|
+
PersonalizeEdge: () => PersonalizeEdge_default,
|
|
25
|
+
Test: () => Test_default,
|
|
26
|
+
Track: () => Track_default,
|
|
27
|
+
TrackSlot: () => TrackSlot_default,
|
|
28
|
+
UniformContextProvider: () => UniformContextProvider_default,
|
|
29
|
+
isUsingUniformContext: () => isUsingUniformContext,
|
|
30
|
+
onRouteChange: () => onRouteChange,
|
|
31
|
+
provideIsPersonalized: () => provideIsPersonalized,
|
|
32
|
+
provideUniformContext: () => provideUniformContext,
|
|
33
|
+
uniformContextInjectionKey: () => uniformContextInjectionKey,
|
|
34
|
+
useIsPersonalized: () => useIsPersonalized,
|
|
35
|
+
useQuirks: () => useQuirks,
|
|
36
|
+
useScores: () => useScores,
|
|
37
|
+
useUniformContext: () => useUniformContext
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(src_exports);
|
|
40
|
+
|
|
41
|
+
// src/components/Test/Test.ts
|
|
42
|
+
var import_vue_demi5 = require("vue-demi");
|
|
43
|
+
|
|
44
|
+
// ../canvas-vue/src/utils/vue-demi-h.ts
|
|
45
|
+
var import_vue_demi = require("vue-demi");
|
|
46
|
+
var RESERVED_PROP_NAMES = ["key", "ref", "slot", "class", "style"];
|
|
47
|
+
var DOM_PROP_NAMES = ["innerHTML"];
|
|
48
|
+
var h = (...args) => {
|
|
49
|
+
if (import_vue_demi.isVue3) {
|
|
50
|
+
return (0, import_vue_demi.h)(...args);
|
|
51
|
+
}
|
|
52
|
+
const [type, propsOrChildren, children] = args;
|
|
53
|
+
const isChildrenOnly = Array.isArray(propsOrChildren) || typeof propsOrChildren !== "object";
|
|
54
|
+
if (isChildrenOnly) {
|
|
55
|
+
return (0, import_vue_demi.h)(...args);
|
|
56
|
+
}
|
|
57
|
+
const propsAndFriends = propsOrChildren;
|
|
58
|
+
const groupedProps = groupPropsAndFriends(type, propsAndFriends);
|
|
59
|
+
console.log("groupedProps", groupedProps);
|
|
60
|
+
const scopedSlots = getScopedSlots(children);
|
|
61
|
+
return (0, import_vue_demi.h)(type, { ...groupedProps, scopedSlots }, children);
|
|
62
|
+
};
|
|
63
|
+
function groupPropsAndFriends(type, propsAndFriends) {
|
|
64
|
+
const groupedProps = Object.entries(propsAndFriends).reduce((object, [key, value]) => {
|
|
65
|
+
if (isReserved(key)) {
|
|
66
|
+
object[key] = value;
|
|
67
|
+
} else if (isProp(type, key)) {
|
|
68
|
+
object.props[key] = value;
|
|
69
|
+
} else if (isDomProp(key)) {
|
|
70
|
+
object.domProps[key] = value;
|
|
71
|
+
} else if (isEvent(key)) {
|
|
72
|
+
object.on[getEventName(key)] = value;
|
|
73
|
+
} else {
|
|
74
|
+
object.attrs[key] = value;
|
|
75
|
+
}
|
|
76
|
+
return object;
|
|
77
|
+
}, {
|
|
78
|
+
props: {},
|
|
79
|
+
attrs: {},
|
|
80
|
+
on: {},
|
|
81
|
+
domProps: {},
|
|
82
|
+
key: void 0,
|
|
83
|
+
class: void 0,
|
|
84
|
+
style: void 0,
|
|
85
|
+
ref: void 0,
|
|
86
|
+
slot: void 0
|
|
87
|
+
});
|
|
88
|
+
return groupedProps;
|
|
89
|
+
}
|
|
90
|
+
function isProp(type, propName) {
|
|
91
|
+
const isNativeElement = typeof type === "string";
|
|
92
|
+
if (isNativeElement) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return Boolean(type.props[propName]);
|
|
96
|
+
}
|
|
97
|
+
function isDomProp(propName) {
|
|
98
|
+
return DOM_PROP_NAMES.includes(propName);
|
|
99
|
+
}
|
|
100
|
+
function isEvent(propName) {
|
|
101
|
+
return /^on[A-Z]/.test(propName);
|
|
102
|
+
}
|
|
103
|
+
function getEventName(propName) {
|
|
104
|
+
return propName.replace(/^on/, "").toLowerCase();
|
|
105
|
+
}
|
|
106
|
+
function isReserved(propName) {
|
|
107
|
+
return RESERVED_PROP_NAMES.includes(propName);
|
|
108
|
+
}
|
|
109
|
+
function getScopedSlots(children) {
|
|
110
|
+
if (typeof children === "function") {
|
|
111
|
+
return { default: children };
|
|
112
|
+
}
|
|
113
|
+
if (typeof children === "object" && !Array.isArray(children)) {
|
|
114
|
+
return children;
|
|
115
|
+
}
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/utils/constants.ts
|
|
120
|
+
var isServer = typeof window === "undefined";
|
|
121
|
+
|
|
122
|
+
// src/components/Test/TestStandard.ts
|
|
123
|
+
var import_vue_demi3 = require("vue-demi");
|
|
124
|
+
|
|
125
|
+
// src/providers/useUniformContext.ts
|
|
126
|
+
var import_vue_demi2 = require("vue-demi");
|
|
127
|
+
var import_cookie_es = require("cookie-es");
|
|
128
|
+
var uniformContextInjectionKey = "uniformContextInjectionKey";
|
|
129
|
+
var provideUniformContext = ({
|
|
130
|
+
context,
|
|
131
|
+
outputType = "standard",
|
|
132
|
+
trackRouteOnRender = true,
|
|
133
|
+
vueAppInstance
|
|
134
|
+
}) => {
|
|
135
|
+
const payload = {
|
|
136
|
+
context,
|
|
137
|
+
outputType
|
|
138
|
+
};
|
|
139
|
+
if (vueAppInstance) {
|
|
140
|
+
vueAppInstance.provide(uniformContextInjectionKey, payload);
|
|
141
|
+
} else {
|
|
142
|
+
(0, import_vue_demi2.provide)(uniformContextInjectionKey, payload);
|
|
143
|
+
}
|
|
144
|
+
if (trackRouteOnRender) {
|
|
145
|
+
onRouteChange(context);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
function onRouteChange(context) {
|
|
149
|
+
if (isServer) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
context == null ? void 0 : context.update({
|
|
153
|
+
url: new URL(window.location.href),
|
|
154
|
+
cookies: (0, import_cookie_es.parse)(document.cookie)
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
var useUniformContext = () => {
|
|
158
|
+
const contextData = (0, import_vue_demi2.inject)(uniformContextInjectionKey);
|
|
159
|
+
if (!contextData) {
|
|
160
|
+
throw Error(`Could not inject Uniform's Context, make sure you're using <UniformContextProvider /> or the Uniform Nuxt module with a valid manifest.`);
|
|
161
|
+
}
|
|
162
|
+
return contextData;
|
|
163
|
+
};
|
|
164
|
+
function isUsingUniformContext() {
|
|
165
|
+
try {
|
|
166
|
+
return Boolean((0, import_vue_demi2.inject)(uniformContextInjectionKey, null));
|
|
167
|
+
} catch (e) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/components/Test/TestStandard.ts
|
|
173
|
+
var TestStandard = (0, import_vue_demi3.defineComponent)({
|
|
174
|
+
name: "TestStandard",
|
|
175
|
+
inheritAttrs: false,
|
|
176
|
+
props: {
|
|
177
|
+
name: {
|
|
178
|
+
type: String,
|
|
179
|
+
required: true
|
|
180
|
+
},
|
|
181
|
+
variations: {
|
|
182
|
+
type: Array,
|
|
183
|
+
required: true
|
|
184
|
+
},
|
|
185
|
+
component: {
|
|
186
|
+
type: [Object, Function],
|
|
187
|
+
required: true
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
setup(props) {
|
|
191
|
+
const { context: uniformContext } = useUniformContext();
|
|
192
|
+
const { result } = uniformContext.test({
|
|
193
|
+
name: (0, import_vue_demi3.toRaw)(props.name),
|
|
194
|
+
variations: (0, import_vue_demi3.toRaw)(props.variations)
|
|
195
|
+
});
|
|
196
|
+
if (!result) {
|
|
197
|
+
return () => null;
|
|
198
|
+
}
|
|
199
|
+
return () => h(props.component, { ...result });
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
var TestStandard_default = TestStandard;
|
|
203
|
+
|
|
204
|
+
// src/components/Test/TestEdge.ts
|
|
205
|
+
var import_vue_demi4 = require("vue-demi");
|
|
206
|
+
var import_context = require("@uniformdev/context");
|
|
207
|
+
var TestEdge = (0, import_vue_demi4.defineComponent)({
|
|
208
|
+
name: "TestEdge",
|
|
209
|
+
inheritAttrs: false,
|
|
210
|
+
props: {
|
|
211
|
+
name: {
|
|
212
|
+
type: String,
|
|
213
|
+
required: true
|
|
214
|
+
},
|
|
215
|
+
variations: {
|
|
216
|
+
type: Array,
|
|
217
|
+
required: true
|
|
218
|
+
},
|
|
219
|
+
component: {
|
|
220
|
+
type: [Object, Function],
|
|
221
|
+
required: true
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
setup(props) {
|
|
225
|
+
const options = {
|
|
226
|
+
name: props.name
|
|
227
|
+
};
|
|
228
|
+
return () => [
|
|
229
|
+
h(import_context.EdgeNodeTagName, { "data-type": import_context.ScriptType.TestStart, innerHTML: JSON.stringify(options) }),
|
|
230
|
+
props.variations.map((variation) => {
|
|
231
|
+
return [
|
|
232
|
+
h(import_context.EdgeNodeTagName, {
|
|
233
|
+
"data-type": import_context.ScriptType.ListItemSettings,
|
|
234
|
+
key: `LIS-${variation.id}`,
|
|
235
|
+
innerHTML: JSON.stringify({ id: variation.id })
|
|
236
|
+
}),
|
|
237
|
+
h(import_context.EdgeNodeTagName, { "data-type": import_context.ScriptType.ListItem, key: `LI-${variation.id}` }, h(props.component, { ...variation }))
|
|
238
|
+
];
|
|
239
|
+
}),
|
|
240
|
+
h(import_context.EdgeNodeTagName, { "data-type": import_context.ScriptType.TestEnd })
|
|
241
|
+
];
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
var TestEdge_default = TestEdge;
|
|
245
|
+
|
|
246
|
+
// src/components/Test/Test.ts
|
|
247
|
+
var Test = (0, import_vue_demi5.defineComponent)({
|
|
248
|
+
name: "Test",
|
|
249
|
+
inheritAttrs: false,
|
|
250
|
+
props: {
|
|
251
|
+
name: {
|
|
252
|
+
type: String,
|
|
253
|
+
required: true
|
|
254
|
+
},
|
|
255
|
+
variations: {
|
|
256
|
+
type: Array,
|
|
257
|
+
required: true
|
|
258
|
+
},
|
|
259
|
+
component: {
|
|
260
|
+
type: [Object, Function],
|
|
261
|
+
required: true
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
setup(props) {
|
|
265
|
+
const { outputType } = useUniformContext();
|
|
266
|
+
return () => !isServer || outputType === "standard" ? h(TestStandard_default, { ...props }) : h(TestEdge_default, { ...props });
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
var Test_default = Test;
|
|
270
|
+
|
|
271
|
+
// src/components/UniformContextProvider.ts
|
|
272
|
+
var import_vue_demi6 = require("vue-demi");
|
|
273
|
+
var import_context2 = require("@uniformdev/context");
|
|
274
|
+
var UniformContextProvider = (0, import_vue_demi6.defineComponent)({
|
|
275
|
+
name: "UniformContextProvider",
|
|
276
|
+
inheritAttrs: false,
|
|
277
|
+
props: {
|
|
278
|
+
context: {
|
|
279
|
+
type: Object,
|
|
280
|
+
required: true
|
|
281
|
+
},
|
|
282
|
+
outputType: {
|
|
283
|
+
type: String,
|
|
284
|
+
default: "standard"
|
|
285
|
+
},
|
|
286
|
+
trackRouteOnRender: {
|
|
287
|
+
type: Boolean,
|
|
288
|
+
default: true
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
setup(props, context) {
|
|
292
|
+
provideUniformContext(props);
|
|
293
|
+
return () => h("article", [context.slots.default(), TransferState(props.context)]);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
var UniformContextProvider_default = UniformContextProvider;
|
|
297
|
+
function TransferState(context) {
|
|
298
|
+
const state = context.getServerToClientTransitionState();
|
|
299
|
+
return h("script", { id: import_context2.SERVER_STATE_ID, type: "application/json", innerHTML: JSON.stringify(state) });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/components/personalize/Personalize.ts
|
|
303
|
+
var import_vue_demi12 = require("vue-demi");
|
|
304
|
+
|
|
305
|
+
// src/components/personalize/PersonalizeStandard.ts
|
|
306
|
+
var import_vue_demi10 = require("vue-demi");
|
|
307
|
+
|
|
308
|
+
// src/providers/useScores.ts
|
|
309
|
+
var import_vue_demi7 = require("vue-demi");
|
|
310
|
+
var import_lite = require("dequal/lite");
|
|
311
|
+
var useScores = () => {
|
|
312
|
+
const { context } = useUniformContext();
|
|
313
|
+
const scores = (0, import_vue_demi7.ref)(context.scores);
|
|
314
|
+
(0, import_vue_demi7.watchEffect)(() => {
|
|
315
|
+
const scoringChangeListener = (updatedScores) => scores.value = updatedScores;
|
|
316
|
+
const currentScores = context.scores;
|
|
317
|
+
if (!(0, import_lite.dequal)(scores.value, currentScores)) {
|
|
318
|
+
scores.value = currentScores;
|
|
319
|
+
}
|
|
320
|
+
context.events.on("scoresUpdated", scoringChangeListener);
|
|
321
|
+
return () => {
|
|
322
|
+
context.events.off("scoresUpdated", scoringChangeListener);
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
return scores;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// src/components/personalize/PersonalizeProvider.ts
|
|
329
|
+
var import_vue_demi9 = require("vue-demi");
|
|
330
|
+
|
|
331
|
+
// src/providers/useIsPersonalized.ts
|
|
332
|
+
var import_vue_demi8 = require("vue-demi");
|
|
333
|
+
var isPersonalizedSymbol = Symbol("uniformIsPersonalized");
|
|
334
|
+
var provideIsPersonalized = (isPersonalized) => {
|
|
335
|
+
(0, import_vue_demi8.provide)(isPersonalizedSymbol, isPersonalized);
|
|
336
|
+
};
|
|
337
|
+
var useIsPersonalized = () => {
|
|
338
|
+
return (0, import_vue_demi8.inject)(isPersonalizedSymbol, false);
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// src/components/personalize/PersonalizeProvider.ts
|
|
342
|
+
var PersonalizeProvider = (0, import_vue_demi9.defineComponent)({
|
|
343
|
+
name: "PersonalizeProvider",
|
|
344
|
+
inheritAttrs: false,
|
|
345
|
+
props: {
|
|
346
|
+
personalized: Boolean
|
|
347
|
+
},
|
|
348
|
+
setup(props, context) {
|
|
349
|
+
console.log("PersonalizeProvider props", JSON.stringify(props, null, 2));
|
|
350
|
+
console.log("PersonalizeProvider context", JSON.stringify(context, null, 2));
|
|
351
|
+
provideIsPersonalized(true);
|
|
352
|
+
return () => h(context.slots.default, {
|
|
353
|
+
...props
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
var PersonalizeProvider_default = PersonalizeProvider;
|
|
358
|
+
|
|
359
|
+
// src/components/personalize/PersonalizeStandard.ts
|
|
360
|
+
var PersonalizeStandard = (0, import_vue_demi10.defineComponent)({
|
|
361
|
+
name: "PersonalizeStandard",
|
|
362
|
+
inheritAttrs: false,
|
|
363
|
+
props: {
|
|
364
|
+
name: {
|
|
365
|
+
type: String,
|
|
366
|
+
required: true
|
|
367
|
+
},
|
|
368
|
+
variations: {
|
|
369
|
+
type: Array,
|
|
370
|
+
required: true
|
|
371
|
+
},
|
|
372
|
+
component: {
|
|
373
|
+
type: [Function, Object],
|
|
374
|
+
required: true
|
|
375
|
+
},
|
|
376
|
+
count: {
|
|
377
|
+
type: Number,
|
|
378
|
+
default: 1
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
setup(props) {
|
|
382
|
+
const { context: uniformContext } = useUniformContext();
|
|
383
|
+
const scores = useScores();
|
|
384
|
+
const personalize = () => {
|
|
385
|
+
var _a;
|
|
386
|
+
return uniformContext.personalize({
|
|
387
|
+
name: (0, import_vue_demi10.toRaw)(props.name),
|
|
388
|
+
variations: (0, import_vue_demi10.toRaw)(props.variations),
|
|
389
|
+
take: (_a = (0, import_vue_demi10.toRaw)(props.count)) != null ? _a : 1
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
const personalizedResult = (0, import_vue_demi10.ref)(personalize());
|
|
393
|
+
(0, import_vue_demi10.watch)([scores, () => props.name, () => props.variations, () => props.count], () => {
|
|
394
|
+
personalizedResult.value = personalize();
|
|
395
|
+
});
|
|
396
|
+
return () => h(PersonalizeProvider_default, { personalized: true }, () => {
|
|
397
|
+
var _a;
|
|
398
|
+
return (_a = personalizedResult.value) == null ? void 0 : _a.variations.map((variation) => {
|
|
399
|
+
return h(props.component, {
|
|
400
|
+
key: variation.id,
|
|
401
|
+
personalizationResult: {
|
|
402
|
+
variation,
|
|
403
|
+
personalizationOccurred: true
|
|
404
|
+
},
|
|
405
|
+
...variation
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
var PersonalizeStandard_default = PersonalizeStandard;
|
|
412
|
+
|
|
413
|
+
// src/components/personalize/PersonalizeEdge.ts
|
|
414
|
+
var import_context3 = require("@uniformdev/context");
|
|
415
|
+
var import_vue_demi11 = require("vue-demi");
|
|
416
|
+
var PersonalizeStandard2 = (0, import_vue_demi11.defineComponent)({
|
|
417
|
+
name: "PersonalizeStandard",
|
|
418
|
+
inheritAttrs: false,
|
|
419
|
+
props: {
|
|
420
|
+
name: {
|
|
421
|
+
type: String,
|
|
422
|
+
required: true
|
|
423
|
+
},
|
|
424
|
+
variations: {
|
|
425
|
+
type: Array,
|
|
426
|
+
required: true
|
|
427
|
+
},
|
|
428
|
+
component: {
|
|
429
|
+
type: [Function, Object],
|
|
430
|
+
required: true
|
|
431
|
+
},
|
|
432
|
+
count: {
|
|
433
|
+
type: Number,
|
|
434
|
+
default: 1
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
setup(props) {
|
|
438
|
+
var _a;
|
|
439
|
+
const options = {
|
|
440
|
+
count: (_a = props.count) != null ? _a : 1
|
|
441
|
+
};
|
|
442
|
+
return () => [
|
|
443
|
+
h(import_context3.EdgeNodeTagName, { "data-type": import_context3.ScriptType.ListStart, innerHTML: JSON.stringify(options) }),
|
|
444
|
+
props.variations.map((variant) => {
|
|
445
|
+
return [
|
|
446
|
+
h(import_context3.EdgeNodeTagName, {
|
|
447
|
+
"data-type": import_context3.ScriptType.ListItemSettings,
|
|
448
|
+
innerHTML: JSON.stringify({ id: variant.id, pz: variant.pz || null }),
|
|
449
|
+
key: `LIS-${variant.id}`
|
|
450
|
+
}),
|
|
451
|
+
h(import_context3.EdgeNodeTagName, { "data-type": import_context3.ScriptType.ListItem, key: `LI-${variant.id}` }, h(props.component, {
|
|
452
|
+
personalizationResult: { variation: variant, personalizationOccurred: false },
|
|
453
|
+
...variant
|
|
454
|
+
}))
|
|
455
|
+
];
|
|
456
|
+
}),
|
|
457
|
+
h(import_context3.EdgeNodeTagName, { "data-type": import_context3.ScriptType.ListEnd })
|
|
458
|
+
];
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
var PersonalizeEdge_default = PersonalizeStandard2;
|
|
462
|
+
|
|
463
|
+
// src/components/personalize/Personalize.ts
|
|
464
|
+
var Personalize = (0, import_vue_demi12.defineComponent)({
|
|
465
|
+
name: "Personalize",
|
|
466
|
+
inheritAttrs: false,
|
|
467
|
+
props: {
|
|
468
|
+
name: {
|
|
469
|
+
type: String,
|
|
470
|
+
required: true
|
|
471
|
+
},
|
|
472
|
+
variations: {
|
|
473
|
+
type: Array,
|
|
474
|
+
required: true
|
|
475
|
+
},
|
|
476
|
+
component: {
|
|
477
|
+
type: [Function, Object],
|
|
478
|
+
required: true
|
|
479
|
+
},
|
|
480
|
+
count: {
|
|
481
|
+
type: Number,
|
|
482
|
+
default: 1
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
setup(props) {
|
|
486
|
+
const { outputType } = useUniformContext();
|
|
487
|
+
return () => h(!isServer || outputType === "standard" ? PersonalizeStandard_default : PersonalizeEdge_default, { ...props });
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
var Personalize_default = Personalize;
|
|
491
|
+
|
|
492
|
+
// src/components/track/Track.ts
|
|
493
|
+
var import_vue_demi13 = require("vue-demi");
|
|
494
|
+
var Track = (0, import_vue_demi13.defineComponent)({
|
|
495
|
+
name: "Track",
|
|
496
|
+
inheritAttrs: false,
|
|
497
|
+
props: {
|
|
498
|
+
behavior: {
|
|
499
|
+
type: [Object, Array]
|
|
500
|
+
},
|
|
501
|
+
tagName: {
|
|
502
|
+
type: String,
|
|
503
|
+
default: "div"
|
|
504
|
+
},
|
|
505
|
+
disableVisibilityTrigger: {
|
|
506
|
+
type: Boolean,
|
|
507
|
+
default: typeof window === "undefined" || !("IntersectionObserver" in window)
|
|
508
|
+
},
|
|
509
|
+
threshold: {
|
|
510
|
+
type: [Number, Array],
|
|
511
|
+
default: 0.5
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
setup(props, context) {
|
|
515
|
+
const currentUrl = typeof document === "undefined" ? "__uniform_ssr_url" : document.location.href;
|
|
516
|
+
const { context: uniformContext } = useUniformContext();
|
|
517
|
+
const insidePersonalizeComponent = useIsPersonalized();
|
|
518
|
+
const lastUrl = (0, import_vue_demi13.ref)("");
|
|
519
|
+
const hasTracked = (0, import_vue_demi13.ref)(false);
|
|
520
|
+
const wrapperEl = (0, import_vue_demi13.ref)();
|
|
521
|
+
const disconnect = (0, import_vue_demi13.ref)();
|
|
522
|
+
(0, import_vue_demi13.watchEffect)(() => {
|
|
523
|
+
const urlHasChanged = lastUrl.value !== currentUrl;
|
|
524
|
+
if (urlHasChanged) {
|
|
525
|
+
lastUrl.value = currentUrl;
|
|
526
|
+
hasTracked.value = false;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
(0, import_vue_demi13.watchEffect)(() => {
|
|
530
|
+
var _a;
|
|
531
|
+
const hasNoBehaviorValue = !props.behavior || Array.isArray(props.behavior) && !props.behavior.length;
|
|
532
|
+
const cannotTrack = insidePersonalizeComponent || hasNoBehaviorValue;
|
|
533
|
+
if (cannotTrack || !wrapperEl.value) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
const enrichments = Array.isArray(props.behavior) ? props.behavior : [props.behavior];
|
|
537
|
+
const pushBehaviorEnrichment = () => {
|
|
538
|
+
var _a2;
|
|
539
|
+
if (hasTracked.value) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
uniformContext == null ? void 0 : uniformContext.update({
|
|
543
|
+
enrichments: (0, import_vue_demi13.toRaw)(enrichments)
|
|
544
|
+
});
|
|
545
|
+
hasTracked.value = false;
|
|
546
|
+
(_a2 = disconnect.value) == null ? void 0 : _a2.call(disconnect);
|
|
547
|
+
};
|
|
548
|
+
if (props.disableVisibilityTrigger) {
|
|
549
|
+
pushBehaviorEnrichment();
|
|
550
|
+
} else {
|
|
551
|
+
(_a = disconnect.value) == null ? void 0 : _a.call(disconnect);
|
|
552
|
+
const instance = new IntersectionObserver(([entry]) => {
|
|
553
|
+
if (entry.isIntersecting) {
|
|
554
|
+
pushBehaviorEnrichment();
|
|
555
|
+
}
|
|
556
|
+
}, {
|
|
557
|
+
threshold: props.threshold
|
|
558
|
+
});
|
|
559
|
+
instance.observe(wrapperEl.value);
|
|
560
|
+
disconnect.value = () => {
|
|
561
|
+
var _a2;
|
|
562
|
+
return (_a2 = instance.disconnect) == null ? void 0 : _a2.call(instance);
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
return () => {
|
|
566
|
+
var _a2;
|
|
567
|
+
(_a2 = disconnect.value) == null ? void 0 : _a2.call(disconnect);
|
|
568
|
+
};
|
|
569
|
+
});
|
|
570
|
+
return () => h(props.tagName, { ref: wrapperEl, ...context.attrs }, context.slots.default());
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
var Track_default = Track;
|
|
574
|
+
|
|
575
|
+
// src/components/track/TrackSlot.ts
|
|
576
|
+
var import_vue_demi14 = require("vue-demi");
|
|
577
|
+
var TrackSlot = (0, import_vue_demi14.defineComponent)({
|
|
578
|
+
name: "TrackSlot",
|
|
579
|
+
inheritAttrs: false,
|
|
580
|
+
props: {
|
|
581
|
+
behavior: {
|
|
582
|
+
type: [Object, Array]
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
setup(props, context) {
|
|
586
|
+
const currentUrl = typeof document === "undefined" ? "__uniform_ssr_url" : document.location.href;
|
|
587
|
+
const { context: uniformContext } = useUniformContext();
|
|
588
|
+
const insidePersonalizeComponent = useIsPersonalized();
|
|
589
|
+
const lastUrl = (0, import_vue_demi14.ref)();
|
|
590
|
+
const hasTracked = (0, import_vue_demi14.ref)(false);
|
|
591
|
+
(0, import_vue_demi14.watchEffect)(() => {
|
|
592
|
+
const urlHasChanged = lastUrl.value !== currentUrl;
|
|
593
|
+
if (urlHasChanged) {
|
|
594
|
+
lastUrl.value = currentUrl;
|
|
595
|
+
hasTracked.value = false;
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
(0, import_vue_demi14.watchEffect)(() => {
|
|
599
|
+
const hasNoBehaviorValue = !props.behavior || Array.isArray(props.behavior) && !props.behavior.length;
|
|
600
|
+
const cannotTrack = insidePersonalizeComponent || hasNoBehaviorValue;
|
|
601
|
+
if (cannotTrack)
|
|
602
|
+
return;
|
|
603
|
+
const pushBehaviorEnrichment = () => {
|
|
604
|
+
if (hasTracked.value) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
const enrichments = Array.isArray(props.behavior) ? props.behavior : [props.behavior];
|
|
608
|
+
uniformContext == null ? void 0 : uniformContext.update({
|
|
609
|
+
enrichments: (0, import_vue_demi14.toRaw)(enrichments)
|
|
610
|
+
});
|
|
611
|
+
hasTracked.value = true;
|
|
612
|
+
};
|
|
613
|
+
pushBehaviorEnrichment();
|
|
614
|
+
});
|
|
615
|
+
return () => h(context.slots.default, { ...context.attrs });
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
var TrackSlot_default = TrackSlot;
|
|
619
|
+
|
|
620
|
+
// src/providers/useQuirks.ts
|
|
621
|
+
var import_vue_demi15 = require("vue-demi");
|
|
622
|
+
var useQuirks = () => {
|
|
623
|
+
const { context } = useUniformContext();
|
|
624
|
+
const quirks = (0, import_vue_demi15.ref)(context.quirks);
|
|
625
|
+
const quirkChangeListener = (updateQuirks) => {
|
|
626
|
+
quirks.value = updateQuirks;
|
|
627
|
+
};
|
|
628
|
+
(0, import_vue_demi15.watch)(context, () => {
|
|
629
|
+
context.events.on("quirksUpdated", quirkChangeListener);
|
|
630
|
+
return () => {
|
|
631
|
+
context.events.off("quirksUpdated", quirkChangeListener);
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
return quirks;
|
|
635
|
+
};
|
|
636
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
637
|
+
0 && (module.exports = {
|
|
638
|
+
Personalize,
|
|
639
|
+
PersonalizeEdge,
|
|
640
|
+
Test,
|
|
641
|
+
Track,
|
|
642
|
+
TrackSlot,
|
|
643
|
+
UniformContextProvider,
|
|
644
|
+
isUsingUniformContext,
|
|
645
|
+
onRouteChange,
|
|
646
|
+
provideIsPersonalized,
|
|
647
|
+
provideUniformContext,
|
|
648
|
+
uniformContextInjectionKey,
|
|
649
|
+
useIsPersonalized,
|
|
650
|
+
useQuirks,
|
|
651
|
+
useScores,
|
|
652
|
+
useUniformContext
|
|
653
|
+
});
|