@uniformdev/context-vue 17.7.1-alpha.34 → 18.0.1-alpha.3
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.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.mjs
CHANGED
|
@@ -1 +1,554 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/personalize/Personalize.ts
|
|
2
|
+
import { defineComponent as defineComponent4, h as h4 } from "vue-demi";
|
|
3
|
+
|
|
4
|
+
// src/providers/useUniformContext.ts
|
|
5
|
+
import { parse as parseCookie } from "cookie-es";
|
|
6
|
+
import { getCurrentInstance, inject, provide } from "vue-demi";
|
|
7
|
+
|
|
8
|
+
// src/utils/constants.ts
|
|
9
|
+
var isServer = typeof window === "undefined";
|
|
10
|
+
|
|
11
|
+
// src/providers/useUniformContext.ts
|
|
12
|
+
var uniformContextInjectionKey = "uniformContextInjectionKey";
|
|
13
|
+
var provideUniformContext = ({
|
|
14
|
+
context,
|
|
15
|
+
outputType = "standard",
|
|
16
|
+
trackRouteOnRender = true,
|
|
17
|
+
vueAppInstance
|
|
18
|
+
}) => {
|
|
19
|
+
const payload = {
|
|
20
|
+
context,
|
|
21
|
+
outputType
|
|
22
|
+
};
|
|
23
|
+
if (vueAppInstance) {
|
|
24
|
+
vueAppInstance.provide(uniformContextInjectionKey, payload);
|
|
25
|
+
} else {
|
|
26
|
+
provide(uniformContextInjectionKey, payload);
|
|
27
|
+
}
|
|
28
|
+
if (trackRouteOnRender) {
|
|
29
|
+
onRouteChange(context);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function onRouteChange(context) {
|
|
33
|
+
if (isServer) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
context == null ? void 0 : context.update({
|
|
37
|
+
url: new URL(window.location.href),
|
|
38
|
+
cookies: parseCookie(document.cookie)
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
var useUniformContext = () => {
|
|
42
|
+
const contextData = inject(uniformContextInjectionKey);
|
|
43
|
+
if (!contextData) {
|
|
44
|
+
throw Error(
|
|
45
|
+
`Could not inject Uniform's Context, make sure you're using <UniformContextProvider /> or the Uniform Nuxt module with a valid manifest.`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return contextData;
|
|
49
|
+
};
|
|
50
|
+
function isUsingUniformContext() {
|
|
51
|
+
var _a;
|
|
52
|
+
const isUniformContextProvided = Boolean(
|
|
53
|
+
(_a = getCurrentInstance()) == null ? void 0 : _a.appContext.provides[uniformContextInjectionKey]
|
|
54
|
+
);
|
|
55
|
+
return isUniformContextProvided;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/components/personalize/PersonalizeEdge.ts
|
|
59
|
+
import { EdgeNodeTagName, ScriptType } from "@uniformdev/context";
|
|
60
|
+
import { defineComponent, h } from "vue-demi";
|
|
61
|
+
var PersonalizeStandard = defineComponent({
|
|
62
|
+
name: "PersonalizeStandard",
|
|
63
|
+
inheritAttrs: false,
|
|
64
|
+
props: {
|
|
65
|
+
name: {
|
|
66
|
+
type: String,
|
|
67
|
+
required: true
|
|
68
|
+
},
|
|
69
|
+
variations: {
|
|
70
|
+
type: Array,
|
|
71
|
+
required: true
|
|
72
|
+
},
|
|
73
|
+
component: {
|
|
74
|
+
type: [Function, Object],
|
|
75
|
+
required: true
|
|
76
|
+
},
|
|
77
|
+
count: {
|
|
78
|
+
type: Number,
|
|
79
|
+
default: 1
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
setup(props) {
|
|
83
|
+
var _a;
|
|
84
|
+
const options = {
|
|
85
|
+
name: props.name,
|
|
86
|
+
count: (_a = props.count) != null ? _a : 1
|
|
87
|
+
};
|
|
88
|
+
return () => [
|
|
89
|
+
h(EdgeNodeTagName, { "data-type": ScriptType.ListStart, innerHTML: JSON.stringify(options) }),
|
|
90
|
+
props.variations.map((variant) => {
|
|
91
|
+
return [
|
|
92
|
+
h(EdgeNodeTagName, {
|
|
93
|
+
"data-type": ScriptType.ListItemSettings,
|
|
94
|
+
innerHTML: JSON.stringify({ id: variant.id, pz: variant.pz || null }),
|
|
95
|
+
key: `LIS-${variant.id}`
|
|
96
|
+
}),
|
|
97
|
+
h(
|
|
98
|
+
EdgeNodeTagName,
|
|
99
|
+
{ "data-type": ScriptType.ListItem, key: `LI-${variant.id}` },
|
|
100
|
+
h(props.component, {
|
|
101
|
+
personalizationResult: { variation: variant, personalizationOccurred: false },
|
|
102
|
+
...variant
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
];
|
|
106
|
+
}),
|
|
107
|
+
h(EdgeNodeTagName, { "data-type": ScriptType.ListEnd })
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
var PersonalizeEdge_default = PersonalizeStandard;
|
|
112
|
+
|
|
113
|
+
// src/components/personalize/PersonalizeStandard.ts
|
|
114
|
+
import { defineComponent as defineComponent3, h as h3, ref as ref2, toRaw, watch } from "vue-demi";
|
|
115
|
+
|
|
116
|
+
// src/providers/useScores.ts
|
|
117
|
+
import { dequal } from "dequal/lite";
|
|
118
|
+
import { ref, watchEffect } from "vue-demi";
|
|
119
|
+
var useScores = () => {
|
|
120
|
+
const { context } = useUniformContext();
|
|
121
|
+
const scores = ref(context.scores);
|
|
122
|
+
watchEffect(() => {
|
|
123
|
+
const scoringChangeListener = (updatedScores) => scores.value = updatedScores;
|
|
124
|
+
const currentScores = context.scores;
|
|
125
|
+
if (!dequal(scores.value, currentScores)) {
|
|
126
|
+
scores.value = currentScores;
|
|
127
|
+
}
|
|
128
|
+
context.events.on("scoresUpdated", scoringChangeListener);
|
|
129
|
+
return () => {
|
|
130
|
+
context.events.off("scoresUpdated", scoringChangeListener);
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
return scores;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// src/components/personalize/PersonalizeProvider.ts
|
|
137
|
+
import { defineComponent as defineComponent2, h as h2 } from "vue-demi";
|
|
138
|
+
|
|
139
|
+
// src/providers/useIsPersonalized.ts
|
|
140
|
+
import { inject as inject2, provide as provide2 } from "vue-demi";
|
|
141
|
+
var isPersonalizedSymbol = Symbol("uniformIsPersonalized");
|
|
142
|
+
var provideIsPersonalized = (isPersonalized) => {
|
|
143
|
+
provide2(isPersonalizedSymbol, isPersonalized);
|
|
144
|
+
};
|
|
145
|
+
var useIsPersonalized = () => {
|
|
146
|
+
return inject2(isPersonalizedSymbol, false);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/components/personalize/PersonalizeProvider.ts
|
|
150
|
+
var PersonalizeProvider = defineComponent2({
|
|
151
|
+
name: "PersonalizeProvider",
|
|
152
|
+
inheritAttrs: false,
|
|
153
|
+
props: {
|
|
154
|
+
personalized: Boolean
|
|
155
|
+
},
|
|
156
|
+
setup(props, context) {
|
|
157
|
+
provideIsPersonalized(props.personalized);
|
|
158
|
+
return () => h2(context.slots.default, {
|
|
159
|
+
...props
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
var PersonalizeProvider_default = PersonalizeProvider;
|
|
164
|
+
|
|
165
|
+
// src/components/personalize/PersonalizeStandard.ts
|
|
166
|
+
var PersonalizeStandard2 = defineComponent3({
|
|
167
|
+
name: "PersonalizeStandard",
|
|
168
|
+
inheritAttrs: false,
|
|
169
|
+
props: {
|
|
170
|
+
name: {
|
|
171
|
+
type: String,
|
|
172
|
+
required: true
|
|
173
|
+
},
|
|
174
|
+
variations: {
|
|
175
|
+
type: Array,
|
|
176
|
+
required: true
|
|
177
|
+
},
|
|
178
|
+
component: {
|
|
179
|
+
type: [Function, Object],
|
|
180
|
+
required: true
|
|
181
|
+
},
|
|
182
|
+
count: {
|
|
183
|
+
type: Number,
|
|
184
|
+
default: 1
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
setup(props) {
|
|
188
|
+
const { context: uniformContext } = useUniformContext();
|
|
189
|
+
const scores = useScores();
|
|
190
|
+
const personalize = () => {
|
|
191
|
+
var _a;
|
|
192
|
+
return uniformContext.personalize({
|
|
193
|
+
name: toRaw(props.name),
|
|
194
|
+
variations: toRaw(props.variations),
|
|
195
|
+
take: (_a = toRaw(props.count)) != null ? _a : 1
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
const personalizedResult = ref2(personalize());
|
|
199
|
+
watch([scores, () => props.name, () => props.variations, () => props.count], () => {
|
|
200
|
+
personalizedResult.value = personalize();
|
|
201
|
+
});
|
|
202
|
+
return () => h3(
|
|
203
|
+
PersonalizeProvider_default,
|
|
204
|
+
{ personalized: true },
|
|
205
|
+
() => {
|
|
206
|
+
var _a;
|
|
207
|
+
return (_a = personalizedResult.value) == null ? void 0 : _a.variations.map((variation) => {
|
|
208
|
+
var _a2;
|
|
209
|
+
return h3(props.component, {
|
|
210
|
+
key: variation.id,
|
|
211
|
+
personalizationResult: {
|
|
212
|
+
variation,
|
|
213
|
+
personalizationOccurred: (_a2 = personalizedResult.value) == null ? void 0 : _a2.personalized
|
|
214
|
+
},
|
|
215
|
+
...variation
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
var PersonalizeStandard_default = PersonalizeStandard2;
|
|
223
|
+
|
|
224
|
+
// src/components/personalize/Personalize.ts
|
|
225
|
+
var Personalize = defineComponent4({
|
|
226
|
+
name: "Personalize",
|
|
227
|
+
inheritAttrs: false,
|
|
228
|
+
props: {
|
|
229
|
+
name: {
|
|
230
|
+
type: String,
|
|
231
|
+
required: true
|
|
232
|
+
},
|
|
233
|
+
variations: {
|
|
234
|
+
type: Array,
|
|
235
|
+
required: true
|
|
236
|
+
},
|
|
237
|
+
component: {
|
|
238
|
+
type: [Function, Object],
|
|
239
|
+
required: true
|
|
240
|
+
},
|
|
241
|
+
count: {
|
|
242
|
+
type: Number,
|
|
243
|
+
default: 1
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
setup(props) {
|
|
247
|
+
const { outputType } = useUniformContext();
|
|
248
|
+
return () => h4(!isServer || outputType === "standard" ? PersonalizeStandard_default : PersonalizeEdge_default, { ...props });
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
var Personalize_default = Personalize;
|
|
252
|
+
|
|
253
|
+
// src/components/Test/Test.ts
|
|
254
|
+
import { defineComponent as defineComponent7, h as h7 } from "vue-demi";
|
|
255
|
+
|
|
256
|
+
// src/components/Test/TestEdge.ts
|
|
257
|
+
import { EdgeNodeTagName as EdgeNodeTagName2, ScriptType as ScriptType2 } from "@uniformdev/context";
|
|
258
|
+
import { defineComponent as defineComponent5, h as h5 } from "vue-demi";
|
|
259
|
+
var TestEdge = defineComponent5({
|
|
260
|
+
name: "TestEdge",
|
|
261
|
+
inheritAttrs: false,
|
|
262
|
+
props: {
|
|
263
|
+
name: {
|
|
264
|
+
type: String,
|
|
265
|
+
required: true
|
|
266
|
+
},
|
|
267
|
+
variations: {
|
|
268
|
+
type: Array,
|
|
269
|
+
required: true
|
|
270
|
+
},
|
|
271
|
+
component: {
|
|
272
|
+
type: [Object, Function],
|
|
273
|
+
required: true
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
setup(props) {
|
|
277
|
+
const options = {
|
|
278
|
+
name: props.name
|
|
279
|
+
};
|
|
280
|
+
return () => [
|
|
281
|
+
h5(EdgeNodeTagName2, { "data-type": ScriptType2.TestStart, innerHTML: JSON.stringify(options) }),
|
|
282
|
+
props.variations.map((variation) => {
|
|
283
|
+
return [
|
|
284
|
+
h5(EdgeNodeTagName2, {
|
|
285
|
+
"data-type": ScriptType2.ListItemSettings,
|
|
286
|
+
key: `LIS-${variation.id}`,
|
|
287
|
+
innerHTML: JSON.stringify({ id: variation.id })
|
|
288
|
+
}),
|
|
289
|
+
h5(
|
|
290
|
+
EdgeNodeTagName2,
|
|
291
|
+
{ "data-type": ScriptType2.ListItem, key: `LI-${variation.id}` },
|
|
292
|
+
h5(props.component, { ...variation })
|
|
293
|
+
)
|
|
294
|
+
];
|
|
295
|
+
}),
|
|
296
|
+
h5(EdgeNodeTagName2, { "data-type": ScriptType2.TestEnd })
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
var TestEdge_default = TestEdge;
|
|
301
|
+
|
|
302
|
+
// src/components/Test/TestStandard.ts
|
|
303
|
+
import { defineComponent as defineComponent6, h as h6, toRaw as toRaw2 } from "vue-demi";
|
|
304
|
+
var TestStandard = defineComponent6({
|
|
305
|
+
name: "TestStandard",
|
|
306
|
+
inheritAttrs: false,
|
|
307
|
+
props: {
|
|
308
|
+
name: {
|
|
309
|
+
type: String,
|
|
310
|
+
required: true
|
|
311
|
+
},
|
|
312
|
+
variations: {
|
|
313
|
+
type: Array,
|
|
314
|
+
required: true
|
|
315
|
+
},
|
|
316
|
+
component: {
|
|
317
|
+
type: [Object, Function],
|
|
318
|
+
required: true
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
setup(props) {
|
|
322
|
+
const { context: uniformContext } = useUniformContext();
|
|
323
|
+
const { result } = uniformContext.test({
|
|
324
|
+
name: toRaw2(props.name),
|
|
325
|
+
variations: toRaw2(props.variations)
|
|
326
|
+
});
|
|
327
|
+
if (!result) {
|
|
328
|
+
return () => null;
|
|
329
|
+
}
|
|
330
|
+
return () => h6(props.component, { ...result });
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
var TestStandard_default = TestStandard;
|
|
334
|
+
|
|
335
|
+
// src/components/Test/Test.ts
|
|
336
|
+
var Test = defineComponent7({
|
|
337
|
+
name: "Test",
|
|
338
|
+
inheritAttrs: false,
|
|
339
|
+
props: {
|
|
340
|
+
name: {
|
|
341
|
+
type: String,
|
|
342
|
+
required: true
|
|
343
|
+
},
|
|
344
|
+
variations: {
|
|
345
|
+
type: Array,
|
|
346
|
+
required: true
|
|
347
|
+
},
|
|
348
|
+
component: {
|
|
349
|
+
type: [Object, Function],
|
|
350
|
+
required: true
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
setup(props) {
|
|
354
|
+
const { outputType } = useUniformContext();
|
|
355
|
+
return () => !isServer || outputType === "standard" ? h7(TestStandard_default, { ...props }) : h7(TestEdge_default, { ...props });
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
var Test_default = Test;
|
|
359
|
+
|
|
360
|
+
// src/components/track/Track.ts
|
|
361
|
+
import { defineComponent as defineComponent8, h as h8, ref as ref3, toRaw as toRaw3, watchEffect as watchEffect2 } from "vue-demi";
|
|
362
|
+
var Track = defineComponent8({
|
|
363
|
+
name: "Track",
|
|
364
|
+
inheritAttrs: false,
|
|
365
|
+
props: {
|
|
366
|
+
behavior: {
|
|
367
|
+
type: [Object, Array]
|
|
368
|
+
},
|
|
369
|
+
tagName: {
|
|
370
|
+
type: String,
|
|
371
|
+
default: "div"
|
|
372
|
+
},
|
|
373
|
+
disableVisibilityTrigger: {
|
|
374
|
+
type: Boolean,
|
|
375
|
+
default: typeof window === "undefined" || !("IntersectionObserver" in window)
|
|
376
|
+
},
|
|
377
|
+
threshold: {
|
|
378
|
+
type: [Number, Array],
|
|
379
|
+
default: 0.5
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
setup(props, context) {
|
|
383
|
+
const currentUrl = typeof document === "undefined" ? "__uniform_ssr_url" : document.location.href;
|
|
384
|
+
const { context: uniformContext } = useUniformContext();
|
|
385
|
+
const insidePersonalizeComponent = useIsPersonalized();
|
|
386
|
+
const lastUrl = ref3("");
|
|
387
|
+
const hasTracked = ref3(false);
|
|
388
|
+
const wrapperEl = ref3();
|
|
389
|
+
const disconnect = ref3();
|
|
390
|
+
watchEffect2(() => {
|
|
391
|
+
const urlHasChanged = lastUrl.value !== currentUrl;
|
|
392
|
+
if (urlHasChanged) {
|
|
393
|
+
lastUrl.value = currentUrl;
|
|
394
|
+
hasTracked.value = false;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
watchEffect2(() => {
|
|
398
|
+
var _a;
|
|
399
|
+
const hasNoBehaviorValue = !props.behavior || Array.isArray(props.behavior) && !props.behavior.length;
|
|
400
|
+
const cannotTrack = insidePersonalizeComponent || hasNoBehaviorValue;
|
|
401
|
+
if (cannotTrack || !wrapperEl.value) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
const enrichments = Array.isArray(props.behavior) ? props.behavior : [props.behavior];
|
|
405
|
+
const pushBehaviorEnrichment = () => {
|
|
406
|
+
var _a2;
|
|
407
|
+
if (hasTracked.value) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
uniformContext == null ? void 0 : uniformContext.update({
|
|
411
|
+
enrichments: toRaw3(enrichments)
|
|
412
|
+
});
|
|
413
|
+
hasTracked.value = false;
|
|
414
|
+
(_a2 = disconnect.value) == null ? void 0 : _a2.call(disconnect);
|
|
415
|
+
};
|
|
416
|
+
if (props.disableVisibilityTrigger) {
|
|
417
|
+
pushBehaviorEnrichment();
|
|
418
|
+
} else {
|
|
419
|
+
(_a = disconnect.value) == null ? void 0 : _a.call(disconnect);
|
|
420
|
+
const instance = new IntersectionObserver(
|
|
421
|
+
([entry]) => {
|
|
422
|
+
if (entry.isIntersecting) {
|
|
423
|
+
pushBehaviorEnrichment();
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
threshold: props.threshold
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
instance.observe(wrapperEl.value);
|
|
431
|
+
disconnect.value = () => {
|
|
432
|
+
var _a2;
|
|
433
|
+
return (_a2 = instance.disconnect) == null ? void 0 : _a2.call(instance);
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
return () => {
|
|
437
|
+
var _a2;
|
|
438
|
+
(_a2 = disconnect.value) == null ? void 0 : _a2.call(disconnect);
|
|
439
|
+
};
|
|
440
|
+
});
|
|
441
|
+
return () => h8(props.tagName, { ref: wrapperEl, ...context.attrs }, context.slots.default());
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
var Track_default = Track;
|
|
445
|
+
|
|
446
|
+
// src/components/track/TrackSlot.ts
|
|
447
|
+
import { defineComponent as defineComponent9, h as h9, ref as ref4, toRaw as toRaw4, watchEffect as watchEffect3 } from "vue-demi";
|
|
448
|
+
var TrackSlot = defineComponent9({
|
|
449
|
+
name: "TrackSlot",
|
|
450
|
+
inheritAttrs: false,
|
|
451
|
+
props: {
|
|
452
|
+
behavior: {
|
|
453
|
+
type: [Object, Array]
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
setup(props, context) {
|
|
457
|
+
const currentUrl = typeof document === "undefined" ? "__uniform_ssr_url" : document.location.href;
|
|
458
|
+
const { context: uniformContext } = useUniformContext();
|
|
459
|
+
const insidePersonalizeComponent = useIsPersonalized();
|
|
460
|
+
const lastUrl = ref4();
|
|
461
|
+
const hasTracked = ref4(false);
|
|
462
|
+
watchEffect3(() => {
|
|
463
|
+
const urlHasChanged = lastUrl.value !== currentUrl;
|
|
464
|
+
if (urlHasChanged) {
|
|
465
|
+
lastUrl.value = currentUrl;
|
|
466
|
+
hasTracked.value = false;
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
watchEffect3(() => {
|
|
470
|
+
const hasNoBehaviorValue = !props.behavior || Array.isArray(props.behavior) && !props.behavior.length;
|
|
471
|
+
const cannotTrack = insidePersonalizeComponent || hasNoBehaviorValue;
|
|
472
|
+
if (cannotTrack)
|
|
473
|
+
return;
|
|
474
|
+
const pushBehaviorEnrichment = () => {
|
|
475
|
+
if (hasTracked.value) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const enrichments = Array.isArray(props.behavior) ? props.behavior : [props.behavior];
|
|
479
|
+
uniformContext == null ? void 0 : uniformContext.update({
|
|
480
|
+
enrichments: toRaw4(enrichments)
|
|
481
|
+
});
|
|
482
|
+
hasTracked.value = true;
|
|
483
|
+
};
|
|
484
|
+
pushBehaviorEnrichment();
|
|
485
|
+
});
|
|
486
|
+
return () => h9(context.slots.default, { ...context.attrs });
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
var TrackSlot_default = TrackSlot;
|
|
490
|
+
|
|
491
|
+
// src/components/UniformContextProvider.ts
|
|
492
|
+
import { SERVER_STATE_ID } from "@uniformdev/context";
|
|
493
|
+
import { defineComponent as defineComponent10, h as h10 } from "vue-demi";
|
|
494
|
+
var UniformContextProvider = defineComponent10({
|
|
495
|
+
name: "UniformContextProvider",
|
|
496
|
+
inheritAttrs: false,
|
|
497
|
+
props: {
|
|
498
|
+
context: {
|
|
499
|
+
type: Object,
|
|
500
|
+
required: true
|
|
501
|
+
},
|
|
502
|
+
outputType: {
|
|
503
|
+
type: String,
|
|
504
|
+
default: "standard"
|
|
505
|
+
},
|
|
506
|
+
trackRouteOnRender: {
|
|
507
|
+
type: Boolean,
|
|
508
|
+
default: true
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
setup(props, context) {
|
|
512
|
+
provideUniformContext(props);
|
|
513
|
+
return () => [h10(context.slots.default), TransferState(props.context)];
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
var UniformContextProvider_default = UniformContextProvider;
|
|
517
|
+
function TransferState(context) {
|
|
518
|
+
const state = context.getServerToClientTransitionState();
|
|
519
|
+
return () => h10("script", { id: SERVER_STATE_ID, type: "application/json", innerHTML: JSON.stringify(state) });
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// src/providers/useQuirks.ts
|
|
523
|
+
import { ref as ref5, watch as watch2 } from "vue-demi";
|
|
524
|
+
var useQuirks = () => {
|
|
525
|
+
const { context } = useUniformContext();
|
|
526
|
+
const quirks = ref5(context.quirks);
|
|
527
|
+
const quirkChangeListener = (updateQuirks) => {
|
|
528
|
+
quirks.value = updateQuirks;
|
|
529
|
+
};
|
|
530
|
+
watch2(context, () => {
|
|
531
|
+
context.events.on("quirksUpdated", quirkChangeListener);
|
|
532
|
+
return () => {
|
|
533
|
+
context.events.off("quirksUpdated", quirkChangeListener);
|
|
534
|
+
};
|
|
535
|
+
});
|
|
536
|
+
return quirks;
|
|
537
|
+
};
|
|
538
|
+
export {
|
|
539
|
+
Personalize_default as Personalize,
|
|
540
|
+
PersonalizeEdge_default as PersonalizeEdge,
|
|
541
|
+
Test_default as Test,
|
|
542
|
+
Track_default as Track,
|
|
543
|
+
TrackSlot_default as TrackSlot,
|
|
544
|
+
UniformContextProvider_default as UniformContextProvider,
|
|
545
|
+
isUsingUniformContext,
|
|
546
|
+
onRouteChange,
|
|
547
|
+
provideIsPersonalized,
|
|
548
|
+
provideUniformContext,
|
|
549
|
+
uniformContextInjectionKey,
|
|
550
|
+
useIsPersonalized,
|
|
551
|
+
useQuirks,
|
|
552
|
+
useScores,
|
|
553
|
+
useUniformContext
|
|
554
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/context-vue",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.1-alpha.3+2267c1ac6",
|
|
4
4
|
"description": "Vue SDK for Uniform Context",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "tsup
|
|
17
|
+
"build": "tsup",
|
|
18
18
|
"dev": "tsup --watch",
|
|
19
19
|
"clean": "rimraf dist",
|
|
20
20
|
"test": "jest --maxWorkers=1 --passWithNoTests",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@uniformdev/context": "
|
|
25
|
+
"@uniformdev/context": "18.0.1-alpha.3+2267c1ac6",
|
|
26
26
|
"cookie-es": "^0.5.0",
|
|
27
27
|
"dequal": "^2.0.2",
|
|
28
28
|
"uuid": "9.0.0",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@testing-library/vue": "6.6.1",
|
|
42
|
-
"@types/uuid": "
|
|
42
|
+
"@types/uuid": "9.0.0",
|
|
43
43
|
"@vue/server-test-utils": "1.3.0",
|
|
44
|
-
"@vue/test-utils": "2.2.
|
|
44
|
+
"@vue/test-utils": "2.2.7",
|
|
45
45
|
"vue": "3.2.45",
|
|
46
46
|
"vue-server-renderer": "2.7.14",
|
|
47
47
|
"vue-template-compiler": "2.7.14"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"last 2 versions",
|
|
64
64
|
"not dead"
|
|
65
65
|
],
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "2267c1ac6f5f6929be6b12d0099905ab46848d0c"
|
|
67
67
|
}
|