@contentful/optimization-core 0.1.0-alpha
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 +21 -0
- package/README.md +408 -0
- package/dist/Consent.d.ts +44 -0
- package/dist/Consent.d.ts.map +1 -0
- package/dist/Consent.js +2 -0
- package/dist/Consent.js.map +1 -0
- package/dist/CoreBase.d.ts +161 -0
- package/dist/CoreBase.d.ts.map +1 -0
- package/dist/CoreBase.js +151 -0
- package/dist/CoreBase.js.map +1 -0
- package/dist/CoreStateful.d.ts +142 -0
- package/dist/CoreStateful.d.ts.map +1 -0
- package/dist/CoreStateful.js +137 -0
- package/dist/CoreStateful.js.map +1 -0
- package/dist/CoreStateless.d.ts +53 -0
- package/dist/CoreStateless.d.ts.map +1 -0
- package/dist/CoreStateless.js +43 -0
- package/dist/CoreStateless.js.map +1 -0
- package/dist/ProductBase.d.ts +83 -0
- package/dist/ProductBase.d.ts.map +1 -0
- package/dist/ProductBase.js +50 -0
- package/dist/ProductBase.js.map +1 -0
- package/dist/analytics/AnalyticsBase.d.ts +35 -0
- package/dist/analytics/AnalyticsBase.d.ts.map +1 -0
- package/dist/analytics/AnalyticsBase.js +13 -0
- package/dist/analytics/AnalyticsBase.js.map +1 -0
- package/dist/analytics/AnalyticsStateful.d.ts +138 -0
- package/dist/analytics/AnalyticsStateful.d.ts.map +1 -0
- package/dist/analytics/AnalyticsStateful.js +179 -0
- package/dist/analytics/AnalyticsStateful.js.map +1 -0
- package/dist/analytics/AnalyticsStateless.d.ts +48 -0
- package/dist/analytics/AnalyticsStateless.d.ts.map +1 -0
- package/dist/analytics/AnalyticsStateless.js +61 -0
- package/dist/analytics/AnalyticsStateless.js.map +1 -0
- package/dist/analytics/index.d.ts +5 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +5 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/global-constants.d.ts +18 -0
- package/dist/global-constants.d.ts.map +1 -0
- package/dist/global-constants.js +18 -0
- package/dist/global-constants.js.map +1 -0
- package/dist/index.cjs +1808 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1535 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/decorators/guardedBy.d.ts +113 -0
- package/dist/lib/decorators/guardedBy.d.ts.map +1 -0
- package/dist/lib/decorators/guardedBy.js +143 -0
- package/dist/lib/decorators/guardedBy.js.map +1 -0
- package/dist/lib/decorators/index.d.ts +2 -0
- package/dist/lib/decorators/index.d.ts.map +1 -0
- package/dist/lib/decorators/index.js +2 -0
- package/dist/lib/decorators/index.js.map +1 -0
- package/dist/lib/interceptor/InterceptorManager.d.ts +127 -0
- package/dist/lib/interceptor/InterceptorManager.d.ts.map +1 -0
- package/dist/lib/interceptor/InterceptorManager.js +125 -0
- package/dist/lib/interceptor/InterceptorManager.js.map +1 -0
- package/dist/lib/interceptor/index.d.ts +2 -0
- package/dist/lib/interceptor/index.d.ts.map +1 -0
- package/dist/lib/interceptor/index.js +2 -0
- package/dist/lib/interceptor/index.js.map +1 -0
- package/dist/lib/value-presence/ValuePresence.d.ts +123 -0
- package/dist/lib/value-presence/ValuePresence.d.ts.map +1 -0
- package/dist/lib/value-presence/ValuePresence.js +141 -0
- package/dist/lib/value-presence/ValuePresence.js.map +1 -0
- package/dist/lib/value-presence/index.d.ts +2 -0
- package/dist/lib/value-presence/index.d.ts.map +1 -0
- package/dist/lib/value-presence/index.js +2 -0
- package/dist/lib/value-presence/index.js.map +1 -0
- package/dist/personalization/PersonalizationBase.d.ts +184 -0
- package/dist/personalization/PersonalizationBase.d.ts.map +1 -0
- package/dist/personalization/PersonalizationBase.js +76 -0
- package/dist/personalization/PersonalizationBase.js.map +1 -0
- package/dist/personalization/PersonalizationStateful.d.ts +226 -0
- package/dist/personalization/PersonalizationStateful.d.ts.map +1 -0
- package/dist/personalization/PersonalizationStateful.js +297 -0
- package/dist/personalization/PersonalizationStateful.js.map +1 -0
- package/dist/personalization/PersonalizationStateless.d.ts +74 -0
- package/dist/personalization/PersonalizationStateless.d.ts.map +1 -0
- package/dist/personalization/PersonalizationStateless.js +98 -0
- package/dist/personalization/PersonalizationStateless.js.map +1 -0
- package/dist/personalization/index.d.ts +6 -0
- package/dist/personalization/index.d.ts.map +1 -0
- package/dist/personalization/index.js +6 -0
- package/dist/personalization/index.js.map +1 -0
- package/dist/personalization/resolvers/FlagsResolver.d.ts +35 -0
- package/dist/personalization/resolvers/FlagsResolver.d.ts.map +1 -0
- package/dist/personalization/resolvers/FlagsResolver.js +47 -0
- package/dist/personalization/resolvers/FlagsResolver.js.map +1 -0
- package/dist/personalization/resolvers/MergeTagValueResolver.d.ts +74 -0
- package/dist/personalization/resolvers/MergeTagValueResolver.d.ts.map +1 -0
- package/dist/personalization/resolvers/MergeTagValueResolver.js +109 -0
- package/dist/personalization/resolvers/MergeTagValueResolver.js.map +1 -0
- package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts +142 -0
- package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts.map +1 -0
- package/dist/personalization/resolvers/PersonalizedEntryResolver.js +196 -0
- package/dist/personalization/resolvers/PersonalizedEntryResolver.js.map +1 -0
- package/dist/personalization/resolvers/index.d.ts +7 -0
- package/dist/personalization/resolvers/index.d.ts.map +1 -0
- package/dist/personalization/resolvers/index.js +7 -0
- package/dist/personalization/resolvers/index.js.map +1 -0
- package/dist/signals.d.ts +35 -0
- package/dist/signals.d.ts.map +1 -0
- package/dist/signals.js +30 -0
- package/dist/signals.js.map +1 -0
- package/package.json +29 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1808 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./src/CoreBase.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
4
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
5
|
+
A: ()=>__rspack_default_export
|
|
6
|
+
});
|
|
7
|
+
var _contentful_optimization_api_client__rspack_import_0 = __webpack_require__("@contentful/optimization-api-client");
|
|
8
|
+
var logger__rspack_import_1 = __webpack_require__("../../lib/logger/dist/index.mjs");
|
|
9
|
+
var _global_constants__rspack_import_3 = __webpack_require__("./src/global-constants.ts");
|
|
10
|
+
var _lib_interceptor__rspack_import_2 = __webpack_require__("./src/lib/interceptor/InterceptorManager.ts");
|
|
11
|
+
class CoreBase {
|
|
12
|
+
api;
|
|
13
|
+
eventBuilder;
|
|
14
|
+
config;
|
|
15
|
+
interceptors = {
|
|
16
|
+
event: new _lib_interceptor__rspack_import_2.v(),
|
|
17
|
+
state: new _lib_interceptor__rspack_import_2.v()
|
|
18
|
+
};
|
|
19
|
+
constructor(config){
|
|
20
|
+
this.config = config;
|
|
21
|
+
const { analytics, personalization, eventBuilder, logLevel, environment, clientId } = config;
|
|
22
|
+
logger__rspack_import_1.vF.addSink(new logger__rspack_import_1.vg(logLevel));
|
|
23
|
+
const apiConfig = {
|
|
24
|
+
...analytics,
|
|
25
|
+
...personalization,
|
|
26
|
+
clientId,
|
|
27
|
+
environment
|
|
28
|
+
};
|
|
29
|
+
this.api = new _contentful_optimization_api_client__rspack_import_0.ApiClient(apiConfig);
|
|
30
|
+
this.eventBuilder = new _contentful_optimization_api_client__rspack_import_0.EventBuilder(eventBuilder ?? {
|
|
31
|
+
channel: 'server',
|
|
32
|
+
library: {
|
|
33
|
+
name: 'Optimization Core',
|
|
34
|
+
version: _global_constants__rspack_import_3.E
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
getCustomFlag(name, changes) {
|
|
39
|
+
return this.personalization.getCustomFlag(name, changes);
|
|
40
|
+
}
|
|
41
|
+
personalizeEntry(entry, personalizations) {
|
|
42
|
+
return this.personalization.personalizeEntry(entry, personalizations);
|
|
43
|
+
}
|
|
44
|
+
getMergeTagValue(embeddedEntryNodeTarget, profile) {
|
|
45
|
+
return this.personalization.getMergeTagValue(embeddedEntryNodeTarget, profile);
|
|
46
|
+
}
|
|
47
|
+
async identify(payload) {
|
|
48
|
+
return await this.personalization.identify(payload);
|
|
49
|
+
}
|
|
50
|
+
async page(payload) {
|
|
51
|
+
return await this.personalization.page(payload);
|
|
52
|
+
}
|
|
53
|
+
async screen(payload) {
|
|
54
|
+
return await this.personalization.screen(payload);
|
|
55
|
+
}
|
|
56
|
+
async track(payload) {
|
|
57
|
+
return await this.personalization.track(payload);
|
|
58
|
+
}
|
|
59
|
+
async trackComponentView(payload, duplicationScope) {
|
|
60
|
+
if (payload.sticky) return await this.personalization.trackComponentView(payload, duplicationScope);
|
|
61
|
+
await this.analytics.trackComponentView(payload, duplicationScope);
|
|
62
|
+
}
|
|
63
|
+
async trackFlagView(payload, duplicationScope) {
|
|
64
|
+
await this.analytics.trackFlagView(payload, duplicationScope);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const __rspack_default_export = CoreBase;
|
|
68
|
+
},
|
|
69
|
+
"./src/CoreStateful.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
70
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
71
|
+
A: ()=>__rspack_default_export
|
|
72
|
+
});
|
|
73
|
+
var _analytics__rspack_import_0 = __webpack_require__("./src/analytics/index.ts");
|
|
74
|
+
var _CoreBase__rspack_import_1 = __webpack_require__("./src/CoreBase.ts");
|
|
75
|
+
var _personalization__rspack_import_2 = __webpack_require__("./src/personalization/index.ts");
|
|
76
|
+
var _signals__rspack_import_3 = __webpack_require__("./src/signals.ts");
|
|
77
|
+
class CoreStateful extends _CoreBase__rspack_import_1.A {
|
|
78
|
+
analytics;
|
|
79
|
+
personalization;
|
|
80
|
+
constructor(config){
|
|
81
|
+
super(config);
|
|
82
|
+
const { allowedEventTypes, defaults, getAnonymousId, preventedComponentEvents } = config;
|
|
83
|
+
if (defaults?.consent !== void 0) {
|
|
84
|
+
const { consent: defaultConsent } = defaults;
|
|
85
|
+
_signals__rspack_import_3.vJ.value = defaultConsent;
|
|
86
|
+
}
|
|
87
|
+
this.analytics = new _analytics__rspack_import_0.R({
|
|
88
|
+
api: this.api,
|
|
89
|
+
builder: this.eventBuilder,
|
|
90
|
+
config: {
|
|
91
|
+
allowedEventTypes,
|
|
92
|
+
preventedComponentEvents,
|
|
93
|
+
defaults: {
|
|
94
|
+
consent: defaults?.consent,
|
|
95
|
+
profile: defaults?.profile
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
interceptors: this.interceptors
|
|
99
|
+
});
|
|
100
|
+
this.personalization = new _personalization__rspack_import_2.$C({
|
|
101
|
+
api: this.api,
|
|
102
|
+
builder: this.eventBuilder,
|
|
103
|
+
config: {
|
|
104
|
+
allowedEventTypes,
|
|
105
|
+
getAnonymousId,
|
|
106
|
+
preventedComponentEvents,
|
|
107
|
+
defaults: {
|
|
108
|
+
consent: defaults?.consent,
|
|
109
|
+
changes: defaults?.changes,
|
|
110
|
+
profile: defaults?.profile,
|
|
111
|
+
personalizations: defaults?.personalizations
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
interceptors: this.interceptors
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
get states() {
|
|
118
|
+
return {
|
|
119
|
+
consent: (0, _signals__rspack_import_3.br)(_signals__rspack_import_3.vJ),
|
|
120
|
+
eventStream: (0, _signals__rspack_import_3.br)(_signals__rspack_import_3.f0),
|
|
121
|
+
flags: (0, _signals__rspack_import_3.br)(_signals__rspack_import_3.Mv),
|
|
122
|
+
personalizations: (0, _signals__rspack_import_3.br)(_signals__rspack_import_3.wh),
|
|
123
|
+
profile: (0, _signals__rspack_import_3.br)(_signals__rspack_import_3.ME)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
reset() {
|
|
127
|
+
(0, _signals__rspack_import_3.vA)(()=>{
|
|
128
|
+
_signals__rspack_import_3.f0.value = void 0;
|
|
129
|
+
_signals__rspack_import_3.Ao.value = void 0;
|
|
130
|
+
_signals__rspack_import_3.ME.value = void 0;
|
|
131
|
+
_signals__rspack_import_3.wh.value = void 0;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async flush() {
|
|
135
|
+
await this.analytics.flush();
|
|
136
|
+
await this.personalization.flush();
|
|
137
|
+
}
|
|
138
|
+
consent(accept) {
|
|
139
|
+
_signals__rspack_import_3.vJ.value = accept;
|
|
140
|
+
}
|
|
141
|
+
online(isOnline) {
|
|
142
|
+
_signals__rspack_import_3.WD.value = isOnline;
|
|
143
|
+
}
|
|
144
|
+
registerPreviewPanel(previewPanel) {
|
|
145
|
+
previewPanel.signals = _signals__rspack_import_3.QO;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const __rspack_default_export = CoreStateful;
|
|
149
|
+
},
|
|
150
|
+
"./src/CoreStateless.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
151
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
152
|
+
A: ()=>__rspack_default_export
|
|
153
|
+
});
|
|
154
|
+
var _analytics__rspack_import_0 = __webpack_require__("./src/analytics/index.ts");
|
|
155
|
+
var _CoreBase__rspack_import_1 = __webpack_require__("./src/CoreBase.ts");
|
|
156
|
+
var _personalization__rspack_import_2 = __webpack_require__("./src/personalization/index.ts");
|
|
157
|
+
class CoreStateless extends _CoreBase__rspack_import_1.A {
|
|
158
|
+
analytics;
|
|
159
|
+
personalization;
|
|
160
|
+
constructor(config){
|
|
161
|
+
super(config);
|
|
162
|
+
this.analytics = new _analytics__rspack_import_0.v({
|
|
163
|
+
api: this.api,
|
|
164
|
+
builder: this.eventBuilder,
|
|
165
|
+
interceptors: this.interceptors
|
|
166
|
+
});
|
|
167
|
+
this.personalization = new _personalization__rspack_import_2.jL({
|
|
168
|
+
api: this.api,
|
|
169
|
+
builder: this.eventBuilder,
|
|
170
|
+
interceptors: this.interceptors
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const __rspack_default_export = CoreStateless;
|
|
175
|
+
},
|
|
176
|
+
"./src/ProductBase.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
177
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
178
|
+
A: ()=>__rspack_default_export
|
|
179
|
+
});
|
|
180
|
+
var _lib_value_presence_ValuePresence__rspack_import_0 = __webpack_require__("./src/lib/value-presence/ValuePresence.ts");
|
|
181
|
+
const defaultAllowedEvents = [
|
|
182
|
+
'page',
|
|
183
|
+
'identify'
|
|
184
|
+
];
|
|
185
|
+
class ProductBase {
|
|
186
|
+
allowedEventTypes;
|
|
187
|
+
builder;
|
|
188
|
+
api;
|
|
189
|
+
duplicationDetector;
|
|
190
|
+
interceptors;
|
|
191
|
+
constructor(options){
|
|
192
|
+
const { api, builder, config, interceptors } = options;
|
|
193
|
+
this.allowedEventTypes = config?.allowedEventTypes ?? defaultAllowedEvents;
|
|
194
|
+
this.api = api;
|
|
195
|
+
this.builder = builder;
|
|
196
|
+
this.duplicationDetector = new _lib_value_presence_ValuePresence__rspack_import_0.A(config?.preventedComponentEvents);
|
|
197
|
+
this.interceptors = interceptors;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const __rspack_default_export = ProductBase;
|
|
201
|
+
},
|
|
202
|
+
"./src/analytics/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
203
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
204
|
+
R: ()=>analytics_AnalyticsStateful,
|
|
205
|
+
v: ()=>analytics_AnalyticsStateless
|
|
206
|
+
});
|
|
207
|
+
var optimization_api_client_ = __webpack_require__("@contentful/optimization-api-client");
|
|
208
|
+
var dist = __webpack_require__("../../lib/logger/dist/index.mjs");
|
|
209
|
+
var guardedBy = __webpack_require__("./src/lib/decorators/guardedBy.ts");
|
|
210
|
+
var signals = __webpack_require__("./src/signals.ts");
|
|
211
|
+
var ProductBase = __webpack_require__("./src/ProductBase.ts");
|
|
212
|
+
class AnalyticsBase extends ProductBase.A {
|
|
213
|
+
}
|
|
214
|
+
const analytics_AnalyticsBase = AnalyticsBase;
|
|
215
|
+
function applyDecs2203RFactory() {
|
|
216
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
217
|
+
return function(initializer) {
|
|
218
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
219
|
+
assertCallable(initializer, "An initializer");
|
|
220
|
+
initializers.push(initializer);
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
224
|
+
var kindStr;
|
|
225
|
+
switch(kind){
|
|
226
|
+
case 1:
|
|
227
|
+
kindStr = "accessor";
|
|
228
|
+
break;
|
|
229
|
+
case 2:
|
|
230
|
+
kindStr = "method";
|
|
231
|
+
break;
|
|
232
|
+
case 3:
|
|
233
|
+
kindStr = "getter";
|
|
234
|
+
break;
|
|
235
|
+
case 4:
|
|
236
|
+
kindStr = "setter";
|
|
237
|
+
break;
|
|
238
|
+
default:
|
|
239
|
+
kindStr = "field";
|
|
240
|
+
}
|
|
241
|
+
var ctx = {
|
|
242
|
+
kind: kindStr,
|
|
243
|
+
name: isPrivate ? "#" + name : name,
|
|
244
|
+
static: isStatic,
|
|
245
|
+
private: isPrivate,
|
|
246
|
+
metadata: metadata
|
|
247
|
+
};
|
|
248
|
+
var decoratorFinishedRef = {
|
|
249
|
+
v: false
|
|
250
|
+
};
|
|
251
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
252
|
+
var get, set;
|
|
253
|
+
if (0 === kind) if (isPrivate) {
|
|
254
|
+
get = desc.get;
|
|
255
|
+
set = desc.set;
|
|
256
|
+
} else {
|
|
257
|
+
get = function() {
|
|
258
|
+
return this[name];
|
|
259
|
+
};
|
|
260
|
+
set = function(v) {
|
|
261
|
+
this[name] = v;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
else if (2 === kind) get = function() {
|
|
265
|
+
return desc.value;
|
|
266
|
+
};
|
|
267
|
+
else {
|
|
268
|
+
if (1 === kind || 3 === kind) get = function() {
|
|
269
|
+
return desc.get.call(this);
|
|
270
|
+
};
|
|
271
|
+
if (1 === kind || 4 === kind) set = function(v) {
|
|
272
|
+
desc.set.call(this, v);
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
ctx.access = get && set ? {
|
|
276
|
+
get: get,
|
|
277
|
+
set: set
|
|
278
|
+
} : get ? {
|
|
279
|
+
get: get
|
|
280
|
+
} : {
|
|
281
|
+
set: set
|
|
282
|
+
};
|
|
283
|
+
try {
|
|
284
|
+
return dec(value, ctx);
|
|
285
|
+
} finally{
|
|
286
|
+
decoratorFinishedRef.v = true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
290
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
291
|
+
}
|
|
292
|
+
function assertCallable(fn, hint) {
|
|
293
|
+
if ("function" != typeof fn) throw new TypeError(hint + " must be a function");
|
|
294
|
+
}
|
|
295
|
+
function assertValidReturnValue(kind, value) {
|
|
296
|
+
var type = typeof value;
|
|
297
|
+
if (1 === kind) {
|
|
298
|
+
if ("object" !== type || null === value) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
299
|
+
if (void 0 !== value.get) assertCallable(value.get, "accessor.get");
|
|
300
|
+
if (void 0 !== value.set) assertCallable(value.set, "accessor.set");
|
|
301
|
+
if (void 0 !== value.init) assertCallable(value.init, "accessor.init");
|
|
302
|
+
} else if ("function" !== type) {
|
|
303
|
+
var hint;
|
|
304
|
+
hint = 0 === kind ? "field" : 10 === kind ? "class" : "method";
|
|
305
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
309
|
+
var decs = decInfo[0];
|
|
310
|
+
var desc, init, value;
|
|
311
|
+
if (isPrivate) desc = 0 === kind || 1 === kind ? {
|
|
312
|
+
get: decInfo[3],
|
|
313
|
+
set: decInfo[4]
|
|
314
|
+
} : 3 === kind ? {
|
|
315
|
+
get: decInfo[3]
|
|
316
|
+
} : 4 === kind ? {
|
|
317
|
+
set: decInfo[3]
|
|
318
|
+
} : {
|
|
319
|
+
value: decInfo[3]
|
|
320
|
+
};
|
|
321
|
+
else if (0 !== kind) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
322
|
+
if (1 === kind) value = {
|
|
323
|
+
get: desc.get,
|
|
324
|
+
set: desc.set
|
|
325
|
+
};
|
|
326
|
+
else if (2 === kind) value = desc.value;
|
|
327
|
+
else if (3 === kind) value = desc.get;
|
|
328
|
+
else if (4 === kind) value = desc.set;
|
|
329
|
+
var newValue, get, set;
|
|
330
|
+
if ("function" == typeof decs) {
|
|
331
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
332
|
+
if (void 0 !== newValue) {
|
|
333
|
+
assertValidReturnValue(kind, newValue);
|
|
334
|
+
if (0 === kind) init = newValue;
|
|
335
|
+
else if (1 === kind) {
|
|
336
|
+
init = newValue.init;
|
|
337
|
+
get = newValue.get || value.get;
|
|
338
|
+
set = newValue.set || value.set;
|
|
339
|
+
value = {
|
|
340
|
+
get: get,
|
|
341
|
+
set: set
|
|
342
|
+
};
|
|
343
|
+
} else value = newValue;
|
|
344
|
+
}
|
|
345
|
+
} else for(var i = decs.length - 1; i >= 0; i--){
|
|
346
|
+
var dec = decs[i];
|
|
347
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
348
|
+
if (void 0 !== newValue) {
|
|
349
|
+
assertValidReturnValue(kind, newValue);
|
|
350
|
+
var newInit;
|
|
351
|
+
if (0 === kind) newInit = newValue;
|
|
352
|
+
else if (1 === kind) {
|
|
353
|
+
newInit = newValue.init;
|
|
354
|
+
get = newValue.get || value.get;
|
|
355
|
+
set = newValue.set || value.set;
|
|
356
|
+
value = {
|
|
357
|
+
get: get,
|
|
358
|
+
set: set
|
|
359
|
+
};
|
|
360
|
+
} else value = newValue;
|
|
361
|
+
if (void 0 !== newInit) if (void 0 === init) init = newInit;
|
|
362
|
+
else if ("function" == typeof init) init = [
|
|
363
|
+
init,
|
|
364
|
+
newInit
|
|
365
|
+
];
|
|
366
|
+
else init.push(newInit);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (0 === kind || 1 === kind) {
|
|
370
|
+
if (void 0 === init) init = function(instance, init) {
|
|
371
|
+
return init;
|
|
372
|
+
};
|
|
373
|
+
else if ("function" != typeof init) {
|
|
374
|
+
var ownInitializers = init;
|
|
375
|
+
init = function(instance, init) {
|
|
376
|
+
var value = init;
|
|
377
|
+
for(var i = 0; i < ownInitializers.length; i++)value = ownInitializers[i].call(instance, value);
|
|
378
|
+
return value;
|
|
379
|
+
};
|
|
380
|
+
} else {
|
|
381
|
+
var originalInitializer = init;
|
|
382
|
+
init = function(instance, init) {
|
|
383
|
+
return originalInitializer.call(instance, init);
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
ret.push(init);
|
|
387
|
+
}
|
|
388
|
+
if (0 !== kind) {
|
|
389
|
+
if (1 === kind) {
|
|
390
|
+
desc.get = value.get;
|
|
391
|
+
desc.set = value.set;
|
|
392
|
+
} else if (2 === kind) desc.value = value;
|
|
393
|
+
else if (3 === kind) desc.get = value;
|
|
394
|
+
else if (4 === kind) desc.set = value;
|
|
395
|
+
if (isPrivate) if (1 === kind) {
|
|
396
|
+
ret.push(function(instance, args) {
|
|
397
|
+
return value.get.call(instance, args);
|
|
398
|
+
});
|
|
399
|
+
ret.push(function(instance, args) {
|
|
400
|
+
return value.set.call(instance, args);
|
|
401
|
+
});
|
|
402
|
+
} else if (2 === kind) ret.push(value);
|
|
403
|
+
else ret.push(function(instance, args) {
|
|
404
|
+
return value.call(instance, args);
|
|
405
|
+
});
|
|
406
|
+
else Object.defineProperty(base, name, desc);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
410
|
+
var ret = [];
|
|
411
|
+
var protoInitializers;
|
|
412
|
+
var staticInitializers;
|
|
413
|
+
var existingProtoNonFields = new Map();
|
|
414
|
+
var existingStaticNonFields = new Map();
|
|
415
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
416
|
+
var decInfo = decInfos[i];
|
|
417
|
+
if (Array.isArray(decInfo)) {
|
|
418
|
+
var kind = decInfo[1];
|
|
419
|
+
var name = decInfo[2];
|
|
420
|
+
var isPrivate = decInfo.length > 3;
|
|
421
|
+
var isStatic = kind >= 5;
|
|
422
|
+
var base;
|
|
423
|
+
var initializers;
|
|
424
|
+
if (isStatic) {
|
|
425
|
+
base = Class;
|
|
426
|
+
kind -= 5;
|
|
427
|
+
staticInitializers = staticInitializers || [];
|
|
428
|
+
initializers = staticInitializers;
|
|
429
|
+
} else {
|
|
430
|
+
base = Class.prototype;
|
|
431
|
+
protoInitializers = protoInitializers || [];
|
|
432
|
+
initializers = protoInitializers;
|
|
433
|
+
}
|
|
434
|
+
if (0 !== kind && !isPrivate) {
|
|
435
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
436
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
437
|
+
if (true === existingKind || 3 === existingKind && 4 !== kind || 4 === existingKind && 3 !== kind) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
438
|
+
if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
439
|
+
else existingNonFields.set(name, true);
|
|
440
|
+
}
|
|
441
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
pushInitializers(ret, protoInitializers);
|
|
445
|
+
pushInitializers(ret, staticInitializers);
|
|
446
|
+
return ret;
|
|
447
|
+
}
|
|
448
|
+
function pushInitializers(ret, initializers) {
|
|
449
|
+
if (initializers) ret.push(function(instance) {
|
|
450
|
+
for(var i = 0; i < initializers.length; i++)initializers[i].call(instance);
|
|
451
|
+
return instance;
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
455
|
+
if (classDecs.length > 0) {
|
|
456
|
+
var initializers = [];
|
|
457
|
+
var newClass = targetClass;
|
|
458
|
+
var name = targetClass.name;
|
|
459
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
460
|
+
var decoratorFinishedRef = {
|
|
461
|
+
v: false
|
|
462
|
+
};
|
|
463
|
+
try {
|
|
464
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
465
|
+
kind: "class",
|
|
466
|
+
name: name,
|
|
467
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
468
|
+
metadata
|
|
469
|
+
});
|
|
470
|
+
} finally{
|
|
471
|
+
decoratorFinishedRef.v = true;
|
|
472
|
+
}
|
|
473
|
+
if (void 0 !== nextNewClass) {
|
|
474
|
+
assertValidReturnValue(10, nextNewClass);
|
|
475
|
+
newClass = nextNewClass;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return [
|
|
479
|
+
defineMetadata(newClass, metadata),
|
|
480
|
+
function() {
|
|
481
|
+
for(var i = 0; i < initializers.length; i++)initializers[i].call(newClass);
|
|
482
|
+
}
|
|
483
|
+
];
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
function defineMetadata(Class, metadata) {
|
|
487
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
488
|
+
configurable: true,
|
|
489
|
+
enumerable: true,
|
|
490
|
+
value: metadata
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
return function(targetClass, memberDecs, classDecs, parentClass) {
|
|
494
|
+
if (void 0 !== parentClass) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
495
|
+
var metadata = Object.create(void 0 === parentMetadata ? null : parentMetadata);
|
|
496
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
497
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
498
|
+
return {
|
|
499
|
+
e: e,
|
|
500
|
+
get c () {
|
|
501
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
507
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
508
|
+
}
|
|
509
|
+
var _dec, _dec1, _dec2, _dec3, _initProto;
|
|
510
|
+
const logger = (0, dist.zP)('Analytics');
|
|
511
|
+
const MAX_QUEUED_EVENTS = 25;
|
|
512
|
+
_dec = (0, guardedBy.i)('isNotDuplicated', {
|
|
513
|
+
onBlocked: 'onBlockedByDuplication'
|
|
514
|
+
}), _dec1 = (0, guardedBy.i)('hasConsent', {
|
|
515
|
+
onBlocked: 'onBlockedByConsent'
|
|
516
|
+
}), _dec2 = (0, guardedBy.i)('isNotDuplicated', {
|
|
517
|
+
onBlocked: 'onBlockedByDuplication'
|
|
518
|
+
}), _dec3 = (0, guardedBy.i)('hasConsent', {
|
|
519
|
+
onBlocked: 'onBlockedByConsent'
|
|
520
|
+
});
|
|
521
|
+
class AnalyticsStateful extends analytics_AnalyticsBase {
|
|
522
|
+
static{
|
|
523
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
524
|
+
[
|
|
525
|
+
[
|
|
526
|
+
_dec,
|
|
527
|
+
_dec1
|
|
528
|
+
],
|
|
529
|
+
2,
|
|
530
|
+
"trackComponentView"
|
|
531
|
+
],
|
|
532
|
+
[
|
|
533
|
+
[
|
|
534
|
+
_dec2,
|
|
535
|
+
_dec3
|
|
536
|
+
],
|
|
537
|
+
2,
|
|
538
|
+
"trackFlagView"
|
|
539
|
+
]
|
|
540
|
+
], []));
|
|
541
|
+
}
|
|
542
|
+
queue = (_initProto(this), new Map());
|
|
543
|
+
states = {
|
|
544
|
+
eventStream: (0, signals.br)(signals.f0),
|
|
545
|
+
profile: (0, signals.br)(signals.ME)
|
|
546
|
+
};
|
|
547
|
+
constructor(options){
|
|
548
|
+
const { api, builder, config, interceptors } = options;
|
|
549
|
+
super({
|
|
550
|
+
api,
|
|
551
|
+
builder,
|
|
552
|
+
config,
|
|
553
|
+
interceptors
|
|
554
|
+
});
|
|
555
|
+
const { defaults } = config ?? {};
|
|
556
|
+
if (defaults?.profile !== void 0) {
|
|
557
|
+
const { profile: defaultProfile } = defaults;
|
|
558
|
+
signals.ME.value = defaultProfile;
|
|
559
|
+
}
|
|
560
|
+
(0, signals.QZ)(()=>{
|
|
561
|
+
const id = signals.ME.value?.id;
|
|
562
|
+
logger.info(`Analytics ${signals.vJ.value ? 'will' : 'will not'} be collected due to consent (${signals.vJ.value})`);
|
|
563
|
+
logger.debug(`Profile ${id && `with ID ${id}`} has been ${id ? 'set' : 'cleared'}`);
|
|
564
|
+
});
|
|
565
|
+
(0, signals.QZ)(()=>{
|
|
566
|
+
if (signals.WD.value) this.flush();
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
reset() {
|
|
570
|
+
(0, signals.vA)(()=>{
|
|
571
|
+
signals.f0.value = void 0;
|
|
572
|
+
signals.ME.value = void 0;
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
hasConsent(name) {
|
|
576
|
+
return !!signals.vJ.value || (this.allowedEventTypes ?? []).includes('trackComponentView' === name || 'trackFlagView' === name ? 'component' : name);
|
|
577
|
+
}
|
|
578
|
+
onBlockedByConsent(name, payload) {
|
|
579
|
+
logger.warn(`Event "${name}" was blocked due to lack of consent; payload: ${JSON.stringify(payload)}`);
|
|
580
|
+
}
|
|
581
|
+
isNotDuplicated(_name, payload) {
|
|
582
|
+
const [{ componentId: value }, duplicationScope] = payload;
|
|
583
|
+
const isDuplicated = this.duplicationDetector.isPresent(duplicationScope, value);
|
|
584
|
+
if (!isDuplicated) this.duplicationDetector.addValue(duplicationScope, value);
|
|
585
|
+
return !isDuplicated;
|
|
586
|
+
}
|
|
587
|
+
onBlockedByDuplication(name, payload) {
|
|
588
|
+
const componentType = 'trackFlagView' === name ? 'flag' : 'component';
|
|
589
|
+
logger.debug(`Duplicate "${componentType} view" event detected, skipping; payload: ${JSON.stringify(payload)}`);
|
|
590
|
+
}
|
|
591
|
+
async trackComponentView(payload, _duplicationScope = '') {
|
|
592
|
+
logger.info(`Processing "component view" event for ${payload.componentId}`);
|
|
593
|
+
await this.enqueueEvent(this.builder.buildComponentView(payload));
|
|
594
|
+
}
|
|
595
|
+
async trackFlagView(payload, _duplicationScope = '') {
|
|
596
|
+
logger.debug(`Processing "flag view" event for ${payload.componentId}`);
|
|
597
|
+
await this.enqueueEvent(this.builder.buildFlagView(payload));
|
|
598
|
+
}
|
|
599
|
+
async enqueueEvent(event) {
|
|
600
|
+
const { value: profile } = signals.ME;
|
|
601
|
+
if (!profile) return void logger.warn('Attempting to emit an event without an Optimization profile');
|
|
602
|
+
const intercepted = await this.interceptors.event.run(event);
|
|
603
|
+
const validEvent = optimization_api_client_.InsightsEvent.parse(intercepted);
|
|
604
|
+
logger.debug(`Queueing ${validEvent.type} event for profile ${profile.id}`, validEvent);
|
|
605
|
+
const profileEventQueue = this.queue.get(profile);
|
|
606
|
+
signals.f0.value = validEvent;
|
|
607
|
+
if (profileEventQueue) profileEventQueue.push(validEvent);
|
|
608
|
+
else this.queue.set(profile, [
|
|
609
|
+
validEvent
|
|
610
|
+
]);
|
|
611
|
+
await this.flushMaxEvents();
|
|
612
|
+
}
|
|
613
|
+
async flushMaxEvents() {
|
|
614
|
+
if (this.queue.values().toArray().flat().length >= MAX_QUEUED_EVENTS) await this.flush();
|
|
615
|
+
}
|
|
616
|
+
async flush() {
|
|
617
|
+
logger.debug('Flushing event queue');
|
|
618
|
+
const batches = [];
|
|
619
|
+
this.queue.forEach((events, profile)=>batches.push({
|
|
620
|
+
profile,
|
|
621
|
+
events
|
|
622
|
+
}));
|
|
623
|
+
if (!batches.length) return;
|
|
624
|
+
const sendSuccess = await this.api.insights.sendBatchEvents(batches);
|
|
625
|
+
if (sendSuccess) this.queue.clear();
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
const analytics_AnalyticsStateful = AnalyticsStateful;
|
|
629
|
+
const AnalyticsStateless_logger = (0, dist.zP)('Analytics');
|
|
630
|
+
class AnalyticsStateless extends analytics_AnalyticsBase {
|
|
631
|
+
async trackComponentView(args) {
|
|
632
|
+
AnalyticsStateless_logger.info('Processing "component view" event');
|
|
633
|
+
const { profile, ...builderArgs } = args;
|
|
634
|
+
const event = this.builder.buildComponentView(builderArgs);
|
|
635
|
+
const intercepted = await this.interceptors.event.run(event);
|
|
636
|
+
const parsed = optimization_api_client_.ComponentViewEvent.parse(intercepted);
|
|
637
|
+
await this.sendBatchEvent(parsed, profile);
|
|
638
|
+
}
|
|
639
|
+
async trackFlagView(args) {
|
|
640
|
+
AnalyticsStateless_logger.debug('Processing "flag view" event');
|
|
641
|
+
const { profile, ...builderArgs } = args;
|
|
642
|
+
const event = this.builder.buildFlagView(builderArgs);
|
|
643
|
+
const intercepted = await this.interceptors.event.run(event);
|
|
644
|
+
const parsed = optimization_api_client_.ComponentViewEvent.parse(intercepted);
|
|
645
|
+
await this.sendBatchEvent(parsed, profile);
|
|
646
|
+
}
|
|
647
|
+
async sendBatchEvent(event, profile) {
|
|
648
|
+
const batchEvent = optimization_api_client_.BatchInsightsEventArray.parse([
|
|
649
|
+
{
|
|
650
|
+
profile,
|
|
651
|
+
events: [
|
|
652
|
+
event
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
]);
|
|
656
|
+
await this.api.insights.sendBatchEvents(batchEvent);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
const analytics_AnalyticsStateless = AnalyticsStateless;
|
|
660
|
+
},
|
|
661
|
+
"./src/global-constants.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
662
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
663
|
+
E: ()=>OPTIMIZATION_CORE_SDK_VERSION,
|
|
664
|
+
T: ()=>ANONYMOUS_ID_COOKIE
|
|
665
|
+
});
|
|
666
|
+
const OPTIMIZATION_CORE_SDK_VERSION = "0.1.0-alpha";
|
|
667
|
+
const ANONYMOUS_ID_COOKIE = 'ctfl-opt-aid';
|
|
668
|
+
},
|
|
669
|
+
"./src/lib/decorators/guardedBy.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
670
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
671
|
+
i: ()=>guardedBy
|
|
672
|
+
});
|
|
673
|
+
const isFunction = (v)=>'function' == typeof v;
|
|
674
|
+
const nameToString = (name)=>'string' == typeof name ? name : 'symbol' == typeof name ? name.description ?? String(name) : String(name);
|
|
675
|
+
const isOnBlockedKey = (v)=>'string' == typeof v || 'symbol' == typeof v;
|
|
676
|
+
const isAsyncFunction = (fn)=>'[object AsyncFunction]' === Object.prototype.toString.call(fn);
|
|
677
|
+
function guardedBy(predicateName, opts) {
|
|
678
|
+
return function(_value, context) {
|
|
679
|
+
const decoratedName = nameToString(context.name);
|
|
680
|
+
context.addInitializer(function() {
|
|
681
|
+
const originalUnknown = Reflect.get(this, context.name);
|
|
682
|
+
if (!isFunction(originalUnknown)) return;
|
|
683
|
+
const original = originalUnknown;
|
|
684
|
+
const originalIsAsync = isAsyncFunction(original);
|
|
685
|
+
const resolvePredicate = (self)=>{
|
|
686
|
+
const { [predicateName]: cand } = self;
|
|
687
|
+
if (!isFunction(cand)) throw new TypeError(`@guardedBy expects predicate "${String(predicateName)}" to be a synchronous function.`);
|
|
688
|
+
return cand;
|
|
689
|
+
};
|
|
690
|
+
const computeAllowed = (self, args)=>{
|
|
691
|
+
const pred = resolvePredicate(self);
|
|
692
|
+
const ok = Boolean(pred.call(self, decoratedName, args));
|
|
693
|
+
return opts?.invert === true ? !ok : ok;
|
|
694
|
+
};
|
|
695
|
+
const runOnBlocked = (self, args)=>{
|
|
696
|
+
const { onBlocked } = opts ?? {};
|
|
697
|
+
if (void 0 === onBlocked) return;
|
|
698
|
+
if (isFunction(onBlocked)) return void onBlocked.call(self, decoratedName, args);
|
|
699
|
+
if (isOnBlockedKey(onBlocked)) {
|
|
700
|
+
const { [onBlocked]: handlerCandidate } = self;
|
|
701
|
+
if (isFunction(handlerCandidate)) handlerCandidate.call(self, decoratedName, args);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
const blockedReturn = ()=>originalIsAsync ? Promise.resolve(void 0) : void 0;
|
|
705
|
+
const wrapped = function(...args) {
|
|
706
|
+
if (!computeAllowed(this, args)) {
|
|
707
|
+
runOnBlocked(this, args);
|
|
708
|
+
return blockedReturn();
|
|
709
|
+
}
|
|
710
|
+
return original.call(this, ...args);
|
|
711
|
+
};
|
|
712
|
+
Reflect.set(this, context.name, wrapped);
|
|
713
|
+
});
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
"./src/lib/decorators/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
718
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
719
|
+
i: ()=>_guardedBy__rspack_import_0.i
|
|
720
|
+
});
|
|
721
|
+
var _guardedBy__rspack_import_0 = __webpack_require__("./src/lib/decorators/guardedBy.ts");
|
|
722
|
+
},
|
|
723
|
+
"./src/lib/interceptor/InterceptorManager.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
724
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
725
|
+
v: ()=>InterceptorManager
|
|
726
|
+
});
|
|
727
|
+
class InterceptorManager {
|
|
728
|
+
interceptors = new Map();
|
|
729
|
+
nextId = 0;
|
|
730
|
+
add(interceptor) {
|
|
731
|
+
const { nextId: id } = this;
|
|
732
|
+
this.nextId += 1;
|
|
733
|
+
this.interceptors.set(id, interceptor);
|
|
734
|
+
return id;
|
|
735
|
+
}
|
|
736
|
+
remove(id) {
|
|
737
|
+
return this.interceptors.delete(id);
|
|
738
|
+
}
|
|
739
|
+
clear() {
|
|
740
|
+
this.interceptors.clear();
|
|
741
|
+
}
|
|
742
|
+
count() {
|
|
743
|
+
return this.interceptors.size;
|
|
744
|
+
}
|
|
745
|
+
async run(input) {
|
|
746
|
+
const fns = Array.from(this.interceptors.values());
|
|
747
|
+
let acc = input;
|
|
748
|
+
for (const fn of fns)acc = await fn(acc);
|
|
749
|
+
return acc;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
},
|
|
753
|
+
"./src/lib/interceptor/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
754
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
755
|
+
v: ()=>_InterceptorManager__rspack_import_0.v
|
|
756
|
+
});
|
|
757
|
+
var _InterceptorManager__rspack_import_0 = __webpack_require__("./src/lib/interceptor/InterceptorManager.ts");
|
|
758
|
+
},
|
|
759
|
+
"./src/lib/value-presence/ValuePresence.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
760
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
761
|
+
A: ()=>__rspack_default_export
|
|
762
|
+
});
|
|
763
|
+
class ValuePresence {
|
|
764
|
+
#map;
|
|
765
|
+
constructor(defaultMap){
|
|
766
|
+
const map = new Map();
|
|
767
|
+
if (defaultMap) Object.entries(defaultMap).map(([scope, values])=>map.set(scope.length ? scope : void 0, new Set(values)));
|
|
768
|
+
this.#map = map;
|
|
769
|
+
}
|
|
770
|
+
isPresent(scope, value) {
|
|
771
|
+
return this.#map.get(scope)?.has(value) ?? false;
|
|
772
|
+
}
|
|
773
|
+
addValue(scope, value) {
|
|
774
|
+
const values = this.#map.get(scope);
|
|
775
|
+
if (values) values.add(value);
|
|
776
|
+
else this.#map.set(scope, new Set([
|
|
777
|
+
value
|
|
778
|
+
]));
|
|
779
|
+
}
|
|
780
|
+
removeValue(scope, value) {
|
|
781
|
+
this.#map.get(scope)?.delete(value);
|
|
782
|
+
}
|
|
783
|
+
reset(scope) {
|
|
784
|
+
if (void 0 !== scope) this.#map.get(scope)?.clear();
|
|
785
|
+
else this.#map.clear();
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
const __rspack_default_export = ValuePresence;
|
|
789
|
+
},
|
|
790
|
+
"./src/lib/value-presence/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
791
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
792
|
+
n: ()=>_ValuePresence__rspack_import_0.A
|
|
793
|
+
});
|
|
794
|
+
var _ValuePresence__rspack_import_0 = __webpack_require__("./src/lib/value-presence/ValuePresence.ts");
|
|
795
|
+
},
|
|
796
|
+
"./src/personalization/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
797
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
798
|
+
OR: ()=>resolvers.OR,
|
|
799
|
+
$C: ()=>personalization_PersonalizationStateful,
|
|
800
|
+
jL: ()=>personalization_PersonalizationStateless,
|
|
801
|
+
cv: ()=>resolvers.cv,
|
|
802
|
+
z8: ()=>resolvers.z8
|
|
803
|
+
});
|
|
804
|
+
var resolvers = __webpack_require__("./src/personalization/resolvers/index.ts");
|
|
805
|
+
var optimization_api_client_ = __webpack_require__("@contentful/optimization-api-client");
|
|
806
|
+
const external_es_toolkit_namespaceObject = require("es-toolkit");
|
|
807
|
+
var dist = __webpack_require__("../../lib/logger/dist/index.mjs");
|
|
808
|
+
var guardedBy = __webpack_require__("./src/lib/decorators/guardedBy.ts");
|
|
809
|
+
var signals = __webpack_require__("./src/signals.ts");
|
|
810
|
+
var ProductBase = __webpack_require__("./src/ProductBase.ts");
|
|
811
|
+
class PersonalizationBase extends ProductBase.A {
|
|
812
|
+
flagsResolver = resolvers.OR;
|
|
813
|
+
mergeTagValueResolver = resolvers.cv;
|
|
814
|
+
personalizedEntryResolver = resolvers.z8;
|
|
815
|
+
getCustomFlag(name, changes) {
|
|
816
|
+
return resolvers.OR.resolve(changes)[name];
|
|
817
|
+
}
|
|
818
|
+
personalizeEntry(entry, personalizations) {
|
|
819
|
+
return resolvers.z8.resolve(entry, personalizations);
|
|
820
|
+
}
|
|
821
|
+
getMergeTagValue(embeddedEntryNodeTarget, profile) {
|
|
822
|
+
return resolvers.cv.resolve(embeddedEntryNodeTarget, profile);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
const personalization_PersonalizationBase = PersonalizationBase;
|
|
826
|
+
function applyDecs2203RFactory() {
|
|
827
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
828
|
+
return function(initializer) {
|
|
829
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
830
|
+
assertCallable(initializer, "An initializer");
|
|
831
|
+
initializers.push(initializer);
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
835
|
+
var kindStr;
|
|
836
|
+
switch(kind){
|
|
837
|
+
case 1:
|
|
838
|
+
kindStr = "accessor";
|
|
839
|
+
break;
|
|
840
|
+
case 2:
|
|
841
|
+
kindStr = "method";
|
|
842
|
+
break;
|
|
843
|
+
case 3:
|
|
844
|
+
kindStr = "getter";
|
|
845
|
+
break;
|
|
846
|
+
case 4:
|
|
847
|
+
kindStr = "setter";
|
|
848
|
+
break;
|
|
849
|
+
default:
|
|
850
|
+
kindStr = "field";
|
|
851
|
+
}
|
|
852
|
+
var ctx = {
|
|
853
|
+
kind: kindStr,
|
|
854
|
+
name: isPrivate ? "#" + name : name,
|
|
855
|
+
static: isStatic,
|
|
856
|
+
private: isPrivate,
|
|
857
|
+
metadata: metadata
|
|
858
|
+
};
|
|
859
|
+
var decoratorFinishedRef = {
|
|
860
|
+
v: false
|
|
861
|
+
};
|
|
862
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
863
|
+
var get, set;
|
|
864
|
+
if (0 === kind) if (isPrivate) {
|
|
865
|
+
get = desc.get;
|
|
866
|
+
set = desc.set;
|
|
867
|
+
} else {
|
|
868
|
+
get = function() {
|
|
869
|
+
return this[name];
|
|
870
|
+
};
|
|
871
|
+
set = function(v) {
|
|
872
|
+
this[name] = v;
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
else if (2 === kind) get = function() {
|
|
876
|
+
return desc.value;
|
|
877
|
+
};
|
|
878
|
+
else {
|
|
879
|
+
if (1 === kind || 3 === kind) get = function() {
|
|
880
|
+
return desc.get.call(this);
|
|
881
|
+
};
|
|
882
|
+
if (1 === kind || 4 === kind) set = function(v) {
|
|
883
|
+
desc.set.call(this, v);
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
ctx.access = get && set ? {
|
|
887
|
+
get: get,
|
|
888
|
+
set: set
|
|
889
|
+
} : get ? {
|
|
890
|
+
get: get
|
|
891
|
+
} : {
|
|
892
|
+
set: set
|
|
893
|
+
};
|
|
894
|
+
try {
|
|
895
|
+
return dec(value, ctx);
|
|
896
|
+
} finally{
|
|
897
|
+
decoratorFinishedRef.v = true;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
901
|
+
if (decoratorFinishedRef.v) throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
902
|
+
}
|
|
903
|
+
function assertCallable(fn, hint) {
|
|
904
|
+
if ("function" != typeof fn) throw new TypeError(hint + " must be a function");
|
|
905
|
+
}
|
|
906
|
+
function assertValidReturnValue(kind, value) {
|
|
907
|
+
var type = typeof value;
|
|
908
|
+
if (1 === kind) {
|
|
909
|
+
if ("object" !== type || null === value) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
910
|
+
if (void 0 !== value.get) assertCallable(value.get, "accessor.get");
|
|
911
|
+
if (void 0 !== value.set) assertCallable(value.set, "accessor.set");
|
|
912
|
+
if (void 0 !== value.init) assertCallable(value.init, "accessor.init");
|
|
913
|
+
} else if ("function" !== type) {
|
|
914
|
+
var hint;
|
|
915
|
+
hint = 0 === kind ? "field" : 10 === kind ? "class" : "method";
|
|
916
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
920
|
+
var decs = decInfo[0];
|
|
921
|
+
var desc, init, value;
|
|
922
|
+
if (isPrivate) desc = 0 === kind || 1 === kind ? {
|
|
923
|
+
get: decInfo[3],
|
|
924
|
+
set: decInfo[4]
|
|
925
|
+
} : 3 === kind ? {
|
|
926
|
+
get: decInfo[3]
|
|
927
|
+
} : 4 === kind ? {
|
|
928
|
+
set: decInfo[3]
|
|
929
|
+
} : {
|
|
930
|
+
value: decInfo[3]
|
|
931
|
+
};
|
|
932
|
+
else if (0 !== kind) desc = Object.getOwnPropertyDescriptor(base, name);
|
|
933
|
+
if (1 === kind) value = {
|
|
934
|
+
get: desc.get,
|
|
935
|
+
set: desc.set
|
|
936
|
+
};
|
|
937
|
+
else if (2 === kind) value = desc.value;
|
|
938
|
+
else if (3 === kind) value = desc.get;
|
|
939
|
+
else if (4 === kind) value = desc.set;
|
|
940
|
+
var newValue, get, set;
|
|
941
|
+
if ("function" == typeof decs) {
|
|
942
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
943
|
+
if (void 0 !== newValue) {
|
|
944
|
+
assertValidReturnValue(kind, newValue);
|
|
945
|
+
if (0 === kind) init = newValue;
|
|
946
|
+
else if (1 === kind) {
|
|
947
|
+
init = newValue.init;
|
|
948
|
+
get = newValue.get || value.get;
|
|
949
|
+
set = newValue.set || value.set;
|
|
950
|
+
value = {
|
|
951
|
+
get: get,
|
|
952
|
+
set: set
|
|
953
|
+
};
|
|
954
|
+
} else value = newValue;
|
|
955
|
+
}
|
|
956
|
+
} else for(var i = decs.length - 1; i >= 0; i--){
|
|
957
|
+
var dec = decs[i];
|
|
958
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
959
|
+
if (void 0 !== newValue) {
|
|
960
|
+
assertValidReturnValue(kind, newValue);
|
|
961
|
+
var newInit;
|
|
962
|
+
if (0 === kind) newInit = newValue;
|
|
963
|
+
else if (1 === kind) {
|
|
964
|
+
newInit = newValue.init;
|
|
965
|
+
get = newValue.get || value.get;
|
|
966
|
+
set = newValue.set || value.set;
|
|
967
|
+
value = {
|
|
968
|
+
get: get,
|
|
969
|
+
set: set
|
|
970
|
+
};
|
|
971
|
+
} else value = newValue;
|
|
972
|
+
if (void 0 !== newInit) if (void 0 === init) init = newInit;
|
|
973
|
+
else if ("function" == typeof init) init = [
|
|
974
|
+
init,
|
|
975
|
+
newInit
|
|
976
|
+
];
|
|
977
|
+
else init.push(newInit);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
if (0 === kind || 1 === kind) {
|
|
981
|
+
if (void 0 === init) init = function(instance, init) {
|
|
982
|
+
return init;
|
|
983
|
+
};
|
|
984
|
+
else if ("function" != typeof init) {
|
|
985
|
+
var ownInitializers = init;
|
|
986
|
+
init = function(instance, init) {
|
|
987
|
+
var value = init;
|
|
988
|
+
for(var i = 0; i < ownInitializers.length; i++)value = ownInitializers[i].call(instance, value);
|
|
989
|
+
return value;
|
|
990
|
+
};
|
|
991
|
+
} else {
|
|
992
|
+
var originalInitializer = init;
|
|
993
|
+
init = function(instance, init) {
|
|
994
|
+
return originalInitializer.call(instance, init);
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
ret.push(init);
|
|
998
|
+
}
|
|
999
|
+
if (0 !== kind) {
|
|
1000
|
+
if (1 === kind) {
|
|
1001
|
+
desc.get = value.get;
|
|
1002
|
+
desc.set = value.set;
|
|
1003
|
+
} else if (2 === kind) desc.value = value;
|
|
1004
|
+
else if (3 === kind) desc.get = value;
|
|
1005
|
+
else if (4 === kind) desc.set = value;
|
|
1006
|
+
if (isPrivate) if (1 === kind) {
|
|
1007
|
+
ret.push(function(instance, args) {
|
|
1008
|
+
return value.get.call(instance, args);
|
|
1009
|
+
});
|
|
1010
|
+
ret.push(function(instance, args) {
|
|
1011
|
+
return value.set.call(instance, args);
|
|
1012
|
+
});
|
|
1013
|
+
} else if (2 === kind) ret.push(value);
|
|
1014
|
+
else ret.push(function(instance, args) {
|
|
1015
|
+
return value.call(instance, args);
|
|
1016
|
+
});
|
|
1017
|
+
else Object.defineProperty(base, name, desc);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
1021
|
+
var ret = [];
|
|
1022
|
+
var protoInitializers;
|
|
1023
|
+
var staticInitializers;
|
|
1024
|
+
var existingProtoNonFields = new Map();
|
|
1025
|
+
var existingStaticNonFields = new Map();
|
|
1026
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
1027
|
+
var decInfo = decInfos[i];
|
|
1028
|
+
if (Array.isArray(decInfo)) {
|
|
1029
|
+
var kind = decInfo[1];
|
|
1030
|
+
var name = decInfo[2];
|
|
1031
|
+
var isPrivate = decInfo.length > 3;
|
|
1032
|
+
var isStatic = kind >= 5;
|
|
1033
|
+
var base;
|
|
1034
|
+
var initializers;
|
|
1035
|
+
if (isStatic) {
|
|
1036
|
+
base = Class;
|
|
1037
|
+
kind -= 5;
|
|
1038
|
+
staticInitializers = staticInitializers || [];
|
|
1039
|
+
initializers = staticInitializers;
|
|
1040
|
+
} else {
|
|
1041
|
+
base = Class.prototype;
|
|
1042
|
+
protoInitializers = protoInitializers || [];
|
|
1043
|
+
initializers = protoInitializers;
|
|
1044
|
+
}
|
|
1045
|
+
if (0 !== kind && !isPrivate) {
|
|
1046
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
1047
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
1048
|
+
if (true === existingKind || 3 === existingKind && 4 !== kind || 4 === existingKind && 3 !== kind) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
1049
|
+
if (!existingKind && kind > 2) existingNonFields.set(name, kind);
|
|
1050
|
+
else existingNonFields.set(name, true);
|
|
1051
|
+
}
|
|
1052
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
pushInitializers(ret, protoInitializers);
|
|
1056
|
+
pushInitializers(ret, staticInitializers);
|
|
1057
|
+
return ret;
|
|
1058
|
+
}
|
|
1059
|
+
function pushInitializers(ret, initializers) {
|
|
1060
|
+
if (initializers) ret.push(function(instance) {
|
|
1061
|
+
for(var i = 0; i < initializers.length; i++)initializers[i].call(instance);
|
|
1062
|
+
return instance;
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
1066
|
+
if (classDecs.length > 0) {
|
|
1067
|
+
var initializers = [];
|
|
1068
|
+
var newClass = targetClass;
|
|
1069
|
+
var name = targetClass.name;
|
|
1070
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
1071
|
+
var decoratorFinishedRef = {
|
|
1072
|
+
v: false
|
|
1073
|
+
};
|
|
1074
|
+
try {
|
|
1075
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
1076
|
+
kind: "class",
|
|
1077
|
+
name: name,
|
|
1078
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
1079
|
+
metadata
|
|
1080
|
+
});
|
|
1081
|
+
} finally{
|
|
1082
|
+
decoratorFinishedRef.v = true;
|
|
1083
|
+
}
|
|
1084
|
+
if (void 0 !== nextNewClass) {
|
|
1085
|
+
assertValidReturnValue(10, nextNewClass);
|
|
1086
|
+
newClass = nextNewClass;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return [
|
|
1090
|
+
defineMetadata(newClass, metadata),
|
|
1091
|
+
function() {
|
|
1092
|
+
for(var i = 0; i < initializers.length; i++)initializers[i].call(newClass);
|
|
1093
|
+
}
|
|
1094
|
+
];
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
function defineMetadata(Class, metadata) {
|
|
1098
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
1099
|
+
configurable: true,
|
|
1100
|
+
enumerable: true,
|
|
1101
|
+
value: metadata
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
return function(targetClass, memberDecs, classDecs, parentClass) {
|
|
1105
|
+
if (void 0 !== parentClass) var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
1106
|
+
var metadata = Object.create(void 0 === parentMetadata ? null : parentMetadata);
|
|
1107
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
1108
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
1109
|
+
return {
|
|
1110
|
+
e: e,
|
|
1111
|
+
get c () {
|
|
1112
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
1118
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
1119
|
+
}
|
|
1120
|
+
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _initProto;
|
|
1121
|
+
const logger = (0, dist.zP)('Personalization');
|
|
1122
|
+
_dec = (0, guardedBy.i)('hasConsent', {
|
|
1123
|
+
onBlocked: 'onBlockedByConsent'
|
|
1124
|
+
}), _dec1 = (0, guardedBy.i)('hasConsent', {
|
|
1125
|
+
onBlocked: 'onBlockedByConsent'
|
|
1126
|
+
}), _dec2 = (0, guardedBy.i)('hasConsent', {
|
|
1127
|
+
onBlocked: 'onBlockedByConsent'
|
|
1128
|
+
}), _dec3 = (0, guardedBy.i)('hasConsent', {
|
|
1129
|
+
onBlocked: 'onBlockedByConsent'
|
|
1130
|
+
}), _dec4 = (0, guardedBy.i)('isNotDuplicated', {
|
|
1131
|
+
onBlocked: 'onBlockedByDuplication'
|
|
1132
|
+
}), _dec5 = (0, guardedBy.i)('hasConsent', {
|
|
1133
|
+
onBlocked: 'onBlockedByConsent'
|
|
1134
|
+
});
|
|
1135
|
+
class PersonalizationStateful extends personalization_PersonalizationBase {
|
|
1136
|
+
static{
|
|
1137
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
1138
|
+
[
|
|
1139
|
+
_dec,
|
|
1140
|
+
2,
|
|
1141
|
+
"identify"
|
|
1142
|
+
],
|
|
1143
|
+
[
|
|
1144
|
+
_dec1,
|
|
1145
|
+
2,
|
|
1146
|
+
"page"
|
|
1147
|
+
],
|
|
1148
|
+
[
|
|
1149
|
+
_dec2,
|
|
1150
|
+
2,
|
|
1151
|
+
"screen"
|
|
1152
|
+
],
|
|
1153
|
+
[
|
|
1154
|
+
_dec3,
|
|
1155
|
+
2,
|
|
1156
|
+
"track"
|
|
1157
|
+
],
|
|
1158
|
+
[
|
|
1159
|
+
[
|
|
1160
|
+
_dec4,
|
|
1161
|
+
_dec5
|
|
1162
|
+
],
|
|
1163
|
+
2,
|
|
1164
|
+
"trackComponentView"
|
|
1165
|
+
]
|
|
1166
|
+
], []));
|
|
1167
|
+
}
|
|
1168
|
+
offlineQueue = (_initProto(this), new Set());
|
|
1169
|
+
states = {
|
|
1170
|
+
eventStream: (0, signals.br)(signals.f0),
|
|
1171
|
+
flags: (0, signals.br)(signals.Mv),
|
|
1172
|
+
profile: (0, signals.br)(signals.ME),
|
|
1173
|
+
personalizations: (0, signals.br)(signals.wh)
|
|
1174
|
+
};
|
|
1175
|
+
getAnonymousId;
|
|
1176
|
+
constructor(options){
|
|
1177
|
+
const { api, builder, config, interceptors } = options;
|
|
1178
|
+
super({
|
|
1179
|
+
api,
|
|
1180
|
+
builder,
|
|
1181
|
+
config,
|
|
1182
|
+
interceptors
|
|
1183
|
+
});
|
|
1184
|
+
const { defaults, getAnonymousId } = config ?? {};
|
|
1185
|
+
if (defaults) {
|
|
1186
|
+
const { changes: defaultChanges, personalizations: defaultPersonalizations, profile: defaultProfile } = defaults;
|
|
1187
|
+
(0, signals.vA)(()=>{
|
|
1188
|
+
signals.Ao.value = defaultChanges;
|
|
1189
|
+
signals.wh.value = defaultPersonalizations;
|
|
1190
|
+
signals.ME.value = defaultProfile;
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
if (defaults?.consent !== void 0) {
|
|
1194
|
+
const { consent: defaultConsent } = defaults;
|
|
1195
|
+
signals.vJ.value = defaultConsent;
|
|
1196
|
+
}
|
|
1197
|
+
this.getAnonymousId = getAnonymousId ?? (()=>void 0);
|
|
1198
|
+
(0, signals.QZ)(()=>{
|
|
1199
|
+
logger.debug(`Profile ${signals.ME.value && `with ID ${signals.ME.value.id}`} has been ${signals.ME.value ? 'set' : 'cleared'}`);
|
|
1200
|
+
});
|
|
1201
|
+
(0, signals.QZ)(()=>{
|
|
1202
|
+
logger.debug(`Variants have been ${signals.wh.value?.length ? 'populated' : 'cleared'}`);
|
|
1203
|
+
});
|
|
1204
|
+
(0, signals.QZ)(()=>{
|
|
1205
|
+
logger.info(`Personalization ${signals.vJ.value ? 'will' : 'will not'} take effect due to consent (${signals.vJ.value})`);
|
|
1206
|
+
});
|
|
1207
|
+
(0, signals.QZ)(()=>{
|
|
1208
|
+
if (signals.WD.value) this.flush();
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
reset() {
|
|
1212
|
+
(0, signals.vA)(()=>{
|
|
1213
|
+
signals.Ao.value = void 0;
|
|
1214
|
+
signals.f0.value = void 0;
|
|
1215
|
+
signals.ME.value = void 0;
|
|
1216
|
+
signals.wh.value = void 0;
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
getCustomFlag(name, changes = signals.Ao.value) {
|
|
1220
|
+
return super.getCustomFlag(name, changes);
|
|
1221
|
+
}
|
|
1222
|
+
personalizeEntry(entry, personalizations = signals.wh.value) {
|
|
1223
|
+
return super.personalizeEntry(entry, personalizations);
|
|
1224
|
+
}
|
|
1225
|
+
getMergeTagValue(embeddedEntryNodeTarget, profile = signals.ME.value) {
|
|
1226
|
+
return super.getMergeTagValue(embeddedEntryNodeTarget, profile);
|
|
1227
|
+
}
|
|
1228
|
+
hasConsent(name) {
|
|
1229
|
+
return !!signals.vJ.value || (this.allowedEventTypes ?? []).includes('trackComponentView' === name || 'trackFlagView' === name ? 'component' : name);
|
|
1230
|
+
}
|
|
1231
|
+
onBlockedByConsent(name, payload) {
|
|
1232
|
+
logger.warn(`Event "${name}" was blocked due to lack of consent; payload: ${JSON.stringify(payload)}`);
|
|
1233
|
+
}
|
|
1234
|
+
isNotDuplicated(_name, payload) {
|
|
1235
|
+
const [{ componentId: value }, duplicationScope] = payload;
|
|
1236
|
+
const isDuplicated = this.duplicationDetector.isPresent(duplicationScope, value);
|
|
1237
|
+
if (!isDuplicated) this.duplicationDetector.addValue(duplicationScope, value);
|
|
1238
|
+
return !isDuplicated;
|
|
1239
|
+
}
|
|
1240
|
+
onBlockedByDuplication(_name, payload) {
|
|
1241
|
+
logger.debug(`Duplicate "component view" event detected, skipping; payload: ${JSON.stringify(payload)}`);
|
|
1242
|
+
}
|
|
1243
|
+
async identify(payload) {
|
|
1244
|
+
logger.info('Sending "identify" event');
|
|
1245
|
+
const event = this.builder.buildIdentify(payload);
|
|
1246
|
+
return await this.sendOrEnqueueEvent(event);
|
|
1247
|
+
}
|
|
1248
|
+
async page(payload) {
|
|
1249
|
+
logger.info('Sending "page" event');
|
|
1250
|
+
const event = this.builder.buildPageView(payload);
|
|
1251
|
+
return await this.sendOrEnqueueEvent(event);
|
|
1252
|
+
}
|
|
1253
|
+
async screen(payload) {
|
|
1254
|
+
logger.info(`Sending "screen" event for "${payload.name}"`);
|
|
1255
|
+
const event = this.builder.buildScreenView(payload);
|
|
1256
|
+
return await this.sendOrEnqueueEvent(event);
|
|
1257
|
+
}
|
|
1258
|
+
async track(payload) {
|
|
1259
|
+
logger.info(`Sending "track" event "${payload.event}"`);
|
|
1260
|
+
const event = this.builder.buildTrack(payload);
|
|
1261
|
+
return await this.sendOrEnqueueEvent(event);
|
|
1262
|
+
}
|
|
1263
|
+
async trackComponentView(payload, _duplicationScope = '') {
|
|
1264
|
+
logger.info(`Sending "track personalization" event for ${payload.componentId}`);
|
|
1265
|
+
const event = this.builder.buildComponentView(payload);
|
|
1266
|
+
return await this.sendOrEnqueueEvent(event);
|
|
1267
|
+
}
|
|
1268
|
+
async sendOrEnqueueEvent(event) {
|
|
1269
|
+
const intercepted = await this.interceptors.event.run(event);
|
|
1270
|
+
const validEvent = optimization_api_client_.ExperienceEvent.parse(intercepted);
|
|
1271
|
+
signals.f0.value = validEvent;
|
|
1272
|
+
if (signals.WD.value) return await this.upsertProfile([
|
|
1273
|
+
validEvent
|
|
1274
|
+
]);
|
|
1275
|
+
logger.debug(`Queueing ${validEvent.type} event`, validEvent);
|
|
1276
|
+
this.offlineQueue.add(validEvent);
|
|
1277
|
+
}
|
|
1278
|
+
async flush() {
|
|
1279
|
+
if (0 === this.offlineQueue.size) return;
|
|
1280
|
+
logger.debug('Flushing offline event queue');
|
|
1281
|
+
await this.upsertProfile(Array.from(this.offlineQueue));
|
|
1282
|
+
this.offlineQueue.clear();
|
|
1283
|
+
}
|
|
1284
|
+
async upsertProfile(events) {
|
|
1285
|
+
const anonymousId = this.getAnonymousId();
|
|
1286
|
+
if (anonymousId) logger.debug(`Anonymous ID found: ${anonymousId}`);
|
|
1287
|
+
const data = await this.api.experience.upsertProfile({
|
|
1288
|
+
profileId: anonymousId ?? signals.ME.value?.id,
|
|
1289
|
+
events
|
|
1290
|
+
});
|
|
1291
|
+
await this.updateOutputSignals(data);
|
|
1292
|
+
return data;
|
|
1293
|
+
}
|
|
1294
|
+
async updateOutputSignals(data) {
|
|
1295
|
+
const intercepted = await this.interceptors.state.run(data);
|
|
1296
|
+
const { changes, personalizations, profile } = intercepted;
|
|
1297
|
+
(0, signals.vA)(()=>{
|
|
1298
|
+
if (!(0, external_es_toolkit_namespaceObject.isEqual)(signals.Ao.value, changes)) signals.Ao.value = changes;
|
|
1299
|
+
if (!(0, external_es_toolkit_namespaceObject.isEqual)(signals.ME.value, profile)) signals.ME.value = profile;
|
|
1300
|
+
if (!(0, external_es_toolkit_namespaceObject.isEqual)(signals.wh.value, personalizations)) signals.wh.value = personalizations;
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
const personalization_PersonalizationStateful = PersonalizationStateful;
|
|
1305
|
+
const PersonalizationStateless_logger = (0, dist.zP)('Personalization');
|
|
1306
|
+
class PersonalizationStateless extends personalization_PersonalizationBase {
|
|
1307
|
+
async identify(payload) {
|
|
1308
|
+
PersonalizationStateless_logger.info('Sending "identify" event');
|
|
1309
|
+
const { profile, ...builderArgs } = payload;
|
|
1310
|
+
const event = optimization_api_client_.IdentifyEvent.parse(this.builder.buildIdentify(builderArgs));
|
|
1311
|
+
return await this.upsertProfile(event, profile);
|
|
1312
|
+
}
|
|
1313
|
+
async page(payload) {
|
|
1314
|
+
PersonalizationStateless_logger.info('Sending "page" event');
|
|
1315
|
+
const { profile, ...builderArgs } = payload;
|
|
1316
|
+
const event = optimization_api_client_.PageViewEvent.parse(this.builder.buildPageView(builderArgs));
|
|
1317
|
+
return await this.upsertProfile(event, profile);
|
|
1318
|
+
}
|
|
1319
|
+
async screen(payload) {
|
|
1320
|
+
PersonalizationStateless_logger.info(`Sending "screen" event for "${payload.name}"`);
|
|
1321
|
+
const { profile, ...builderArgs } = payload;
|
|
1322
|
+
const event = optimization_api_client_.ScreenViewEvent.parse(this.builder.buildScreenView(builderArgs));
|
|
1323
|
+
return await this.upsertProfile(event, profile);
|
|
1324
|
+
}
|
|
1325
|
+
async track(payload) {
|
|
1326
|
+
PersonalizationStateless_logger.info(`Sending "track" event "${payload.event}"`);
|
|
1327
|
+
const { profile, ...builderArgs } = payload;
|
|
1328
|
+
const event = optimization_api_client_.TrackEvent.parse(this.builder.buildTrack(builderArgs));
|
|
1329
|
+
return await this.upsertProfile(event, profile);
|
|
1330
|
+
}
|
|
1331
|
+
async trackComponentView(payload) {
|
|
1332
|
+
PersonalizationStateless_logger.info('Sending "track personalization" event');
|
|
1333
|
+
const { profile, ...builderArgs } = payload;
|
|
1334
|
+
const event = optimization_api_client_.ComponentViewEvent.parse(this.builder.buildComponentView(builderArgs));
|
|
1335
|
+
return await this.upsertProfile(event, profile);
|
|
1336
|
+
}
|
|
1337
|
+
async upsertProfile(event, profile) {
|
|
1338
|
+
const intercepted = await this.interceptors.event.run(event);
|
|
1339
|
+
const data = await this.api.experience.upsertProfile({
|
|
1340
|
+
profileId: profile?.id,
|
|
1341
|
+
events: [
|
|
1342
|
+
intercepted
|
|
1343
|
+
]
|
|
1344
|
+
});
|
|
1345
|
+
return data;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
const personalization_PersonalizationStateless = PersonalizationStateless;
|
|
1349
|
+
},
|
|
1350
|
+
"./src/personalization/resolvers/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1351
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1352
|
+
OR: ()=>resolvers_FlagsResolver,
|
|
1353
|
+
cv: ()=>resolvers_MergeTagValueResolver,
|
|
1354
|
+
z8: ()=>resolvers_PersonalizedEntryResolver
|
|
1355
|
+
});
|
|
1356
|
+
const FlagsResolver = {
|
|
1357
|
+
resolve (changes) {
|
|
1358
|
+
if (!changes) return {};
|
|
1359
|
+
return changes.reduce((acc, { key, value })=>{
|
|
1360
|
+
const actualValue = 'object' == typeof value && null !== value && 'value' in value && 'object' == typeof value.value ? value.value : value;
|
|
1361
|
+
acc[key] = actualValue;
|
|
1362
|
+
return acc;
|
|
1363
|
+
}, {});
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1366
|
+
const resolvers_FlagsResolver = FlagsResolver;
|
|
1367
|
+
var optimization_api_client_ = __webpack_require__("@contentful/optimization-api-client");
|
|
1368
|
+
const compat_namespaceObject = require("es-toolkit/compat");
|
|
1369
|
+
var dist = __webpack_require__("../../lib/logger/dist/index.mjs");
|
|
1370
|
+
const logger = (0, dist.zP)('Personalization');
|
|
1371
|
+
const RESOLUTION_WARNING_BASE = 'Could not resolve Merge Tag value:';
|
|
1372
|
+
const MergeTagValueResolver = {
|
|
1373
|
+
isMergeTagEntry (embeddedEntryNodeTarget) {
|
|
1374
|
+
return optimization_api_client_.MergeTagEntry.safeParse(embeddedEntryNodeTarget).success;
|
|
1375
|
+
},
|
|
1376
|
+
normalizeSelectors (id) {
|
|
1377
|
+
return id.split('_').map((_path, index, paths)=>{
|
|
1378
|
+
const dotPath = paths.slice(0, index).join('.');
|
|
1379
|
+
const underScorePath = paths.slice(index).join('_');
|
|
1380
|
+
return [
|
|
1381
|
+
dotPath,
|
|
1382
|
+
underScorePath
|
|
1383
|
+
].filter((path)=>'' !== path).join('.');
|
|
1384
|
+
});
|
|
1385
|
+
},
|
|
1386
|
+
getValueFromProfile (id, profile) {
|
|
1387
|
+
const selectors = MergeTagValueResolver.normalizeSelectors(id);
|
|
1388
|
+
const matchingSelector = selectors.find((selector)=>(0, compat_namespaceObject.get)(profile, selector));
|
|
1389
|
+
if (!matchingSelector) return;
|
|
1390
|
+
const value = (0, compat_namespaceObject.get)(profile, matchingSelector);
|
|
1391
|
+
if (!value || 'string' != typeof value && 'number' != typeof value && 'boolean' != typeof value) return;
|
|
1392
|
+
return `${value}`;
|
|
1393
|
+
},
|
|
1394
|
+
resolve (mergeTagEntry, profile) {
|
|
1395
|
+
if (!MergeTagValueResolver.isMergeTagEntry(mergeTagEntry)) return void logger.warn(`${RESOLUTION_WARNING_BASE} supplied entry is not a Merge Tag entry`);
|
|
1396
|
+
const { fields: { nt_fallback: fallback } } = mergeTagEntry;
|
|
1397
|
+
if (!optimization_api_client_.Profile.safeParse(profile).success) {
|
|
1398
|
+
logger.warn(`${RESOLUTION_WARNING_BASE} no valid profile`);
|
|
1399
|
+
return fallback;
|
|
1400
|
+
}
|
|
1401
|
+
return MergeTagValueResolver.getValueFromProfile(mergeTagEntry.fields.nt_mergetag_id, profile) ?? fallback;
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
const resolvers_MergeTagValueResolver = MergeTagValueResolver;
|
|
1405
|
+
const PersonalizedEntryResolver_logger = (0, dist.zP)('Personalization');
|
|
1406
|
+
const PersonalizedEntryResolver_RESOLUTION_WARNING_BASE = 'Could not resolve personalized entry variant:';
|
|
1407
|
+
const PersonalizedEntryResolver = {
|
|
1408
|
+
getPersonalizationEntry ({ personalizedEntry, selectedPersonalizations }, skipValidation = false) {
|
|
1409
|
+
if (!skipValidation && (!selectedPersonalizations.length || !(0, optimization_api_client_.isPersonalizedEntry)(personalizedEntry))) return;
|
|
1410
|
+
const personalizationEntry = personalizedEntry.fields.nt_experiences.filter((maybePersonalization)=>(0, optimization_api_client_.isPersonalizationEntry)(maybePersonalization)).find((personalizationEntry)=>selectedPersonalizations.some(({ experienceId })=>experienceId === personalizationEntry.fields.nt_experience_id));
|
|
1411
|
+
return personalizationEntry;
|
|
1412
|
+
},
|
|
1413
|
+
getSelectedPersonalization ({ personalizationEntry, selectedPersonalizations }, skipValidation = false) {
|
|
1414
|
+
if (!skipValidation && (!selectedPersonalizations.length || !(0, optimization_api_client_.isPersonalizationEntry)(personalizationEntry))) return;
|
|
1415
|
+
const selectedPersonalization = selectedPersonalizations.find(({ experienceId })=>experienceId === personalizationEntry.fields.nt_experience_id);
|
|
1416
|
+
return selectedPersonalization;
|
|
1417
|
+
},
|
|
1418
|
+
getSelectedVariant ({ personalizedEntry, personalizationEntry, selectedVariantIndex }, skipValidation = false) {
|
|
1419
|
+
if (!skipValidation && (!(0, optimization_api_client_.isPersonalizedEntry)(personalizedEntry) || !(0, optimization_api_client_.isPersonalizationEntry)(personalizationEntry))) return;
|
|
1420
|
+
const relevantVariants = personalizationEntry.fields.nt_config?.components?.filter((component)=>(0, optimization_api_client_.isEntryReplacementComponent)(component) && !component.baseline.hidden).find((component)=>component.baseline.id === personalizedEntry.sys.id)?.variants;
|
|
1421
|
+
if (!relevantVariants?.length) return;
|
|
1422
|
+
return relevantVariants.at(selectedVariantIndex - 1);
|
|
1423
|
+
},
|
|
1424
|
+
getSelectedVariantEntry ({ personalizationEntry, selectedVariant }, skipValidation = false) {
|
|
1425
|
+
if (!skipValidation && (!(0, optimization_api_client_.isPersonalizationEntry)(personalizationEntry) || !(0, optimization_api_client_.isEntryReplacementVariant)(selectedVariant))) return;
|
|
1426
|
+
const selectedVariantEntry = personalizationEntry.fields.nt_variants?.find((variant)=>variant.sys.id === selectedVariant.id);
|
|
1427
|
+
return (0, optimization_api_client_.isEntry)(selectedVariantEntry) ? selectedVariantEntry : void 0;
|
|
1428
|
+
},
|
|
1429
|
+
resolve (entry, selectedPersonalizations) {
|
|
1430
|
+
PersonalizedEntryResolver_logger.debug(`Resolving personalized entry for baseline entry ${entry.sys.id}`);
|
|
1431
|
+
if (!selectedPersonalizations?.length) {
|
|
1432
|
+
PersonalizedEntryResolver_logger.warn(`${PersonalizedEntryResolver_RESOLUTION_WARNING_BASE} no selectedPersonalizations exist for the current profile`);
|
|
1433
|
+
return {
|
|
1434
|
+
entry
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
if (!(0, optimization_api_client_.isPersonalizedEntry)(entry)) {
|
|
1438
|
+
PersonalizedEntryResolver_logger.warn(`${PersonalizedEntryResolver_RESOLUTION_WARNING_BASE} entry ${entry.sys.id} is not personalized`);
|
|
1439
|
+
return {
|
|
1440
|
+
entry
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
const personalizationEntry = PersonalizedEntryResolver.getPersonalizationEntry({
|
|
1444
|
+
personalizedEntry: entry,
|
|
1445
|
+
selectedPersonalizations
|
|
1446
|
+
}, true);
|
|
1447
|
+
if (!personalizationEntry) {
|
|
1448
|
+
PersonalizedEntryResolver_logger.warn(`${PersonalizedEntryResolver_RESOLUTION_WARNING_BASE} could not find a personalization entry for ${entry.sys.id}`);
|
|
1449
|
+
return {
|
|
1450
|
+
entry
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
const selectedPersonalization = PersonalizedEntryResolver.getSelectedPersonalization({
|
|
1454
|
+
personalizationEntry,
|
|
1455
|
+
selectedPersonalizations
|
|
1456
|
+
}, true);
|
|
1457
|
+
const selectedVariantIndex = selectedPersonalization?.variantIndex ?? 0;
|
|
1458
|
+
if (0 === selectedVariantIndex) {
|
|
1459
|
+
PersonalizedEntryResolver_logger.debug(`Resolved personalization entry for entry ${entry.sys.id} is baseline`);
|
|
1460
|
+
return {
|
|
1461
|
+
entry
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
const selectedVariant = PersonalizedEntryResolver.getSelectedVariant({
|
|
1465
|
+
personalizedEntry: entry,
|
|
1466
|
+
personalizationEntry,
|
|
1467
|
+
selectedVariantIndex
|
|
1468
|
+
}, true);
|
|
1469
|
+
if (!selectedVariant) {
|
|
1470
|
+
PersonalizedEntryResolver_logger.warn(`${PersonalizedEntryResolver_RESOLUTION_WARNING_BASE} could not find a valid replacement variant entry for ${entry.sys.id}`);
|
|
1471
|
+
return {
|
|
1472
|
+
entry
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
const selectedVariantEntry = PersonalizedEntryResolver.getSelectedVariantEntry({
|
|
1476
|
+
personalizationEntry,
|
|
1477
|
+
selectedVariant
|
|
1478
|
+
}, true);
|
|
1479
|
+
if (selectedVariantEntry) PersonalizedEntryResolver_logger.debug(`Entry ${entry.sys.id} has been resolved to variant entry ${selectedVariantEntry.sys.id}`);
|
|
1480
|
+
else {
|
|
1481
|
+
PersonalizedEntryResolver_logger.warn(`${PersonalizedEntryResolver_RESOLUTION_WARNING_BASE} could not find a valid replacement variant entry for ${entry.sys.id}`);
|
|
1482
|
+
return {
|
|
1483
|
+
entry
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
return {
|
|
1487
|
+
entry: selectedVariantEntry,
|
|
1488
|
+
personalization: selectedPersonalization
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
const resolvers_PersonalizedEntryResolver = PersonalizedEntryResolver;
|
|
1493
|
+
},
|
|
1494
|
+
"./src/signals.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1495
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1496
|
+
WD: ()=>online,
|
|
1497
|
+
vA: ()=>signals_core_namespaceObject.batch,
|
|
1498
|
+
ME: ()=>profile,
|
|
1499
|
+
f0: ()=>signals_event,
|
|
1500
|
+
QO: ()=>signals,
|
|
1501
|
+
Mv: ()=>flags,
|
|
1502
|
+
br: ()=>toObservable,
|
|
1503
|
+
vJ: ()=>consent,
|
|
1504
|
+
Ao: ()=>changes,
|
|
1505
|
+
QZ: ()=>signals_core_namespaceObject.effect,
|
|
1506
|
+
wh: ()=>personalizations
|
|
1507
|
+
});
|
|
1508
|
+
const signals_core_namespaceObject = require("@preact/signals-core");
|
|
1509
|
+
var resolvers = __webpack_require__("./src/personalization/resolvers/index.ts");
|
|
1510
|
+
const changes = (0, signals_core_namespaceObject.signal)();
|
|
1511
|
+
const consent = (0, signals_core_namespaceObject.signal)();
|
|
1512
|
+
const signals_event = (0, signals_core_namespaceObject.signal)();
|
|
1513
|
+
const flags = (0, signals_core_namespaceObject.computed)(()=>resolvers.OR.resolve(changes.value ?? []));
|
|
1514
|
+
const online = (0, signals_core_namespaceObject.signal)(true);
|
|
1515
|
+
const personalizations = (0, signals_core_namespaceObject.signal)();
|
|
1516
|
+
const profile = (0, signals_core_namespaceObject.signal)();
|
|
1517
|
+
function toObservable(s) {
|
|
1518
|
+
return {
|
|
1519
|
+
subscribe (next) {
|
|
1520
|
+
const dispose = (0, signals_core_namespaceObject.effect)(()=>{
|
|
1521
|
+
next(s.value);
|
|
1522
|
+
});
|
|
1523
|
+
return {
|
|
1524
|
+
unsubscribe: dispose
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
const signals = {
|
|
1530
|
+
changes,
|
|
1531
|
+
consent,
|
|
1532
|
+
event: signals_event,
|
|
1533
|
+
flags,
|
|
1534
|
+
online,
|
|
1535
|
+
personalizations,
|
|
1536
|
+
profile
|
|
1537
|
+
};
|
|
1538
|
+
},
|
|
1539
|
+
"@contentful/optimization-api-client" (module) {
|
|
1540
|
+
module.exports = require("@contentful/optimization-api-client");
|
|
1541
|
+
},
|
|
1542
|
+
"../../lib/logger/dist/index.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1543
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1544
|
+
Vy: ()=>Logger,
|
|
1545
|
+
vF: ()=>logger,
|
|
1546
|
+
zP: ()=>createScopedLogger,
|
|
1547
|
+
vg: ()=>ConsoleLogSink,
|
|
1548
|
+
y$: ()=>src_LogSink
|
|
1549
|
+
});
|
|
1550
|
+
const external_diary_namespaceObject = require("diary");
|
|
1551
|
+
const utils_namespaceObject = require("diary/utils");
|
|
1552
|
+
class Logger {
|
|
1553
|
+
name = '@contentful/optimization';
|
|
1554
|
+
PREFIX_PARTS = [
|
|
1555
|
+
'Ctfl',
|
|
1556
|
+
'O10n'
|
|
1557
|
+
];
|
|
1558
|
+
DELIMITER = ':';
|
|
1559
|
+
diary;
|
|
1560
|
+
sinks = [];
|
|
1561
|
+
constructor(){
|
|
1562
|
+
this.diary = (0, external_diary_namespaceObject.diary)(this.name, this.onLogEvent.bind(this));
|
|
1563
|
+
(0, external_diary_namespaceObject.enable)(this.name);
|
|
1564
|
+
}
|
|
1565
|
+
assembleLocationPrefix(logLocation) {
|
|
1566
|
+
return `[${[
|
|
1567
|
+
...this.PREFIX_PARTS,
|
|
1568
|
+
logLocation
|
|
1569
|
+
].join(this.DELIMITER)}]`;
|
|
1570
|
+
}
|
|
1571
|
+
addSink(sink) {
|
|
1572
|
+
this.sinks = [
|
|
1573
|
+
...this.sinks.filter((existingSink)=>existingSink.name !== sink.name),
|
|
1574
|
+
sink
|
|
1575
|
+
];
|
|
1576
|
+
}
|
|
1577
|
+
removeSink(name) {
|
|
1578
|
+
this.sinks = this.sinks.filter((sink)=>sink.name !== name);
|
|
1579
|
+
}
|
|
1580
|
+
removeSinks() {
|
|
1581
|
+
this.sinks = [];
|
|
1582
|
+
}
|
|
1583
|
+
debug(logLocation, message, ...args) {
|
|
1584
|
+
this.diary.debug(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args);
|
|
1585
|
+
}
|
|
1586
|
+
info(logLocation, message, ...args) {
|
|
1587
|
+
this.diary.info(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args);
|
|
1588
|
+
}
|
|
1589
|
+
log(logLocation, message, ...args) {
|
|
1590
|
+
this.diary.log(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args);
|
|
1591
|
+
}
|
|
1592
|
+
warn(logLocation, message, ...args) {
|
|
1593
|
+
this.diary.warn(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args);
|
|
1594
|
+
}
|
|
1595
|
+
error(logLocation, message, ...args) {
|
|
1596
|
+
this.diary.error(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args);
|
|
1597
|
+
}
|
|
1598
|
+
fatal(logLocation, message, ...args) {
|
|
1599
|
+
this.diary.fatal(`${this.assembleLocationPrefix(logLocation)} ${message}`, ...args);
|
|
1600
|
+
}
|
|
1601
|
+
onLogEvent(event) {
|
|
1602
|
+
this.sinks.forEach((sink)=>{
|
|
1603
|
+
sink.ingest(event);
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
const logger = new Logger();
|
|
1608
|
+
function createScopedLogger(location) {
|
|
1609
|
+
return {
|
|
1610
|
+
debug: (message, ...args)=>{
|
|
1611
|
+
logger.debug(location, message, ...args);
|
|
1612
|
+
},
|
|
1613
|
+
info: (message, ...args)=>{
|
|
1614
|
+
logger.info(location, message, ...args);
|
|
1615
|
+
},
|
|
1616
|
+
log: (message, ...args)=>{
|
|
1617
|
+
logger.log(location, message, ...args);
|
|
1618
|
+
},
|
|
1619
|
+
warn: (message, ...args)=>{
|
|
1620
|
+
logger.warn(location, message, ...args);
|
|
1621
|
+
},
|
|
1622
|
+
error: (message, ...args)=>{
|
|
1623
|
+
logger.error(location, message, ...args);
|
|
1624
|
+
},
|
|
1625
|
+
fatal: (message, ...args)=>{
|
|
1626
|
+
logger.fatal(location, message, ...args);
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
class LogSink {
|
|
1631
|
+
}
|
|
1632
|
+
const src_LogSink = LogSink;
|
|
1633
|
+
const consoleMap = {
|
|
1634
|
+
debug: (...args)=>{
|
|
1635
|
+
console.debug(...args);
|
|
1636
|
+
},
|
|
1637
|
+
info: (...args)=>{
|
|
1638
|
+
console.info(...args);
|
|
1639
|
+
},
|
|
1640
|
+
log: (...args)=>{
|
|
1641
|
+
console.log(...args);
|
|
1642
|
+
},
|
|
1643
|
+
warn: (...args)=>{
|
|
1644
|
+
console.warn(...args);
|
|
1645
|
+
},
|
|
1646
|
+
error: (...args)=>{
|
|
1647
|
+
console.error(...args);
|
|
1648
|
+
},
|
|
1649
|
+
fatal: (...args)=>{
|
|
1650
|
+
console.error(...args);
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
const COMPARISON_EQUALITY = 0;
|
|
1654
|
+
class ConsoleLogSink extends src_LogSink {
|
|
1655
|
+
name = 'ConsoleLogSink';
|
|
1656
|
+
verbosity;
|
|
1657
|
+
constructor(verbosity){
|
|
1658
|
+
super();
|
|
1659
|
+
this.verbosity = verbosity ?? 'error';
|
|
1660
|
+
}
|
|
1661
|
+
ingest(event) {
|
|
1662
|
+
if ((0, utils_namespaceObject.compare)(this.verbosity, event.level) > COMPARISON_EQUALITY) return;
|
|
1663
|
+
consoleMap[event.level](...event.messages);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
};
|
|
1668
|
+
var __webpack_module_cache__ = {};
|
|
1669
|
+
function __webpack_require__(moduleId) {
|
|
1670
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
1671
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
1672
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
1673
|
+
exports: {}
|
|
1674
|
+
};
|
|
1675
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
1676
|
+
return module.exports;
|
|
1677
|
+
}
|
|
1678
|
+
(()=>{
|
|
1679
|
+
__webpack_require__.n = (module)=>{
|
|
1680
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
1681
|
+
__webpack_require__.d(getter, {
|
|
1682
|
+
a: getter
|
|
1683
|
+
});
|
|
1684
|
+
return getter;
|
|
1685
|
+
};
|
|
1686
|
+
})();
|
|
1687
|
+
(()=>{
|
|
1688
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
1689
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
1690
|
+
enumerable: true,
|
|
1691
|
+
get: definition[key]
|
|
1692
|
+
});
|
|
1693
|
+
};
|
|
1694
|
+
})();
|
|
1695
|
+
(()=>{
|
|
1696
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1697
|
+
})();
|
|
1698
|
+
(()=>{
|
|
1699
|
+
__webpack_require__.r = (exports1)=>{
|
|
1700
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
1701
|
+
value: 'Module'
|
|
1702
|
+
});
|
|
1703
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
1704
|
+
value: true
|
|
1705
|
+
});
|
|
1706
|
+
};
|
|
1707
|
+
})();
|
|
1708
|
+
var __webpack_exports__ = {};
|
|
1709
|
+
(()=>{
|
|
1710
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1711
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1712
|
+
ANONYMOUS_ID_COOKIE: ()=>_global_constants__rspack_import_7.T,
|
|
1713
|
+
AnalyticsStateful: ()=>_analytics__rspack_import_3.R,
|
|
1714
|
+
AnalyticsStateless: ()=>_analytics__rspack_import_3.v,
|
|
1715
|
+
ConsoleLogSink: ()=>logger__rspack_import_2.vg,
|
|
1716
|
+
CoreStateful: ()=>_CoreStateful__rspack_import_5.A,
|
|
1717
|
+
CoreStateless: ()=>_CoreStateless__rspack_import_6.A,
|
|
1718
|
+
FlagsResolver: ()=>_personalization__rspack_import_11.OR,
|
|
1719
|
+
InterceptorManager: ()=>_lib_interceptor__rspack_import_9.v,
|
|
1720
|
+
LogSink: ()=>logger__rspack_import_2.y$,
|
|
1721
|
+
Logger: ()=>logger__rspack_import_2.Vy,
|
|
1722
|
+
MergeTagValueResolver: ()=>_personalization__rspack_import_11.cv,
|
|
1723
|
+
OPTIMIZATION_CORE_SDK_VERSION: ()=>_global_constants__rspack_import_7.E,
|
|
1724
|
+
PersonalizationStateful: ()=>_personalization__rspack_import_11.$C,
|
|
1725
|
+
PersonalizationStateless: ()=>_personalization__rspack_import_11.jL,
|
|
1726
|
+
PersonalizedEntryResolver: ()=>_personalization__rspack_import_11.z8,
|
|
1727
|
+
ValuePresence: ()=>_lib_value_presence__rspack_import_10.n,
|
|
1728
|
+
batch: ()=>_signals__rspack_import_0.vA,
|
|
1729
|
+
createScopedLogger: ()=>logger__rspack_import_2.zP,
|
|
1730
|
+
effect: ()=>_signals__rspack_import_0.QZ,
|
|
1731
|
+
guardedBy: ()=>_lib_decorators__rspack_import_8.i,
|
|
1732
|
+
logger: ()=>logger__rspack_import_2.vF,
|
|
1733
|
+
signals: ()=>_signals__rspack_import_0.QO
|
|
1734
|
+
});
|
|
1735
|
+
var _signals__rspack_import_0 = __webpack_require__("./src/signals.ts");
|
|
1736
|
+
var _contentful_optimization_api_client__rspack_import_1 = __webpack_require__("@contentful/optimization-api-client");
|
|
1737
|
+
var __rspack_reexport = {};
|
|
1738
|
+
for(const __rspack_import_key in _contentful_optimization_api_client__rspack_import_1)if ([
|
|
1739
|
+
"CoreStateless",
|
|
1740
|
+
"signals",
|
|
1741
|
+
"CoreStateful",
|
|
1742
|
+
"default",
|
|
1743
|
+
"batch",
|
|
1744
|
+
"effect"
|
|
1745
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_contentful_optimization_api_client__rspack_import_1[__rspack_import_key];
|
|
1746
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
1747
|
+
var logger__rspack_import_2 = __webpack_require__("../../lib/logger/dist/index.mjs");
|
|
1748
|
+
var _analytics__rspack_import_3 = __webpack_require__("./src/analytics/index.ts");
|
|
1749
|
+
__webpack_require__("./src/CoreBase.ts");
|
|
1750
|
+
var _CoreStateful__rspack_import_5 = __webpack_require__("./src/CoreStateful.ts");
|
|
1751
|
+
var _CoreStateless__rspack_import_6 = __webpack_require__("./src/CoreStateless.ts");
|
|
1752
|
+
var _global_constants__rspack_import_7 = __webpack_require__("./src/global-constants.ts");
|
|
1753
|
+
var _lib_decorators__rspack_import_8 = __webpack_require__("./src/lib/decorators/index.ts");
|
|
1754
|
+
var _lib_interceptor__rspack_import_9 = __webpack_require__("./src/lib/interceptor/index.ts");
|
|
1755
|
+
var _lib_value_presence__rspack_import_10 = __webpack_require__("./src/lib/value-presence/index.ts");
|
|
1756
|
+
var _personalization__rspack_import_11 = __webpack_require__("./src/personalization/index.ts");
|
|
1757
|
+
})();
|
|
1758
|
+
exports.ANONYMOUS_ID_COOKIE = __webpack_exports__.ANONYMOUS_ID_COOKIE;
|
|
1759
|
+
exports.AnalyticsStateful = __webpack_exports__.AnalyticsStateful;
|
|
1760
|
+
exports.AnalyticsStateless = __webpack_exports__.AnalyticsStateless;
|
|
1761
|
+
exports.ConsoleLogSink = __webpack_exports__.ConsoleLogSink;
|
|
1762
|
+
exports.CoreStateful = __webpack_exports__.CoreStateful;
|
|
1763
|
+
exports.CoreStateless = __webpack_exports__.CoreStateless;
|
|
1764
|
+
exports.FlagsResolver = __webpack_exports__.FlagsResolver;
|
|
1765
|
+
exports.InterceptorManager = __webpack_exports__.InterceptorManager;
|
|
1766
|
+
exports.LogSink = __webpack_exports__.LogSink;
|
|
1767
|
+
exports.Logger = __webpack_exports__.Logger;
|
|
1768
|
+
exports.MergeTagValueResolver = __webpack_exports__.MergeTagValueResolver;
|
|
1769
|
+
exports.OPTIMIZATION_CORE_SDK_VERSION = __webpack_exports__.OPTIMIZATION_CORE_SDK_VERSION;
|
|
1770
|
+
exports.PersonalizationStateful = __webpack_exports__.PersonalizationStateful;
|
|
1771
|
+
exports.PersonalizationStateless = __webpack_exports__.PersonalizationStateless;
|
|
1772
|
+
exports.PersonalizedEntryResolver = __webpack_exports__.PersonalizedEntryResolver;
|
|
1773
|
+
exports.ValuePresence = __webpack_exports__.ValuePresence;
|
|
1774
|
+
exports.batch = __webpack_exports__.batch;
|
|
1775
|
+
exports.createScopedLogger = __webpack_exports__.createScopedLogger;
|
|
1776
|
+
exports.effect = __webpack_exports__.effect;
|
|
1777
|
+
exports.guardedBy = __webpack_exports__.guardedBy;
|
|
1778
|
+
exports.logger = __webpack_exports__.logger;
|
|
1779
|
+
exports.signals = __webpack_exports__.signals;
|
|
1780
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
1781
|
+
"ANONYMOUS_ID_COOKIE",
|
|
1782
|
+
"AnalyticsStateful",
|
|
1783
|
+
"AnalyticsStateless",
|
|
1784
|
+
"ConsoleLogSink",
|
|
1785
|
+
"CoreStateful",
|
|
1786
|
+
"CoreStateless",
|
|
1787
|
+
"FlagsResolver",
|
|
1788
|
+
"InterceptorManager",
|
|
1789
|
+
"LogSink",
|
|
1790
|
+
"Logger",
|
|
1791
|
+
"MergeTagValueResolver",
|
|
1792
|
+
"OPTIMIZATION_CORE_SDK_VERSION",
|
|
1793
|
+
"PersonalizationStateful",
|
|
1794
|
+
"PersonalizationStateless",
|
|
1795
|
+
"PersonalizedEntryResolver",
|
|
1796
|
+
"ValuePresence",
|
|
1797
|
+
"batch",
|
|
1798
|
+
"createScopedLogger",
|
|
1799
|
+
"effect",
|
|
1800
|
+
"guardedBy",
|
|
1801
|
+
"logger",
|
|
1802
|
+
"signals"
|
|
1803
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
1804
|
+
Object.defineProperty(exports, '__esModule', {
|
|
1805
|
+
value: true
|
|
1806
|
+
});
|
|
1807
|
+
|
|
1808
|
+
//# sourceMappingURL=index.cjs.map
|