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