@absmartly/sdk-plugins 1.1.2 → 1.2.1

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.
Files changed (98) hide show
  1. package/dist/absmartly-dom-changes-core.min.js +1 -1
  2. package/dist/absmartly-dom-changes-lite.min.js +1 -1
  3. package/dist/absmartly-overrides-full.min.js +1 -1
  4. package/dist/absmartly-overrides-lite.min.js +1 -1
  5. package/dist/absmartly-sdk-plugins.min.js +1 -1
  6. package/es/core/DOMChangesPluginLite.js +192 -220
  7. package/es/core/DOMChangesPluginLite.js.map +1 -1
  8. package/es/core/DOMManipulatorLite.js +66 -9
  9. package/es/core/DOMManipulatorLite.js.map +1 -1
  10. package/es/core/ExposureTracker.js +136 -11
  11. package/es/core/ExposureTracker.js.map +1 -1
  12. package/es/entries/dom-with-overrides-lite.js +3 -0
  13. package/es/entries/dom-with-overrides-lite.js.map +1 -1
  14. package/es/index.js +9 -2
  15. package/es/index.js.map +1 -1
  16. package/es/overrides/OverridesPlugin.js +2 -2
  17. package/es/overrides/OverridesPlugin.js.map +1 -1
  18. package/es/overrides/OverridesPluginLite.js +29 -1
  19. package/es/overrides/OverridesPluginLite.js.map +1 -1
  20. package/es/overrides/overridesUtils.js +27 -18
  21. package/es/overrides/overridesUtils.js.map +1 -1
  22. package/es/parsers/VariantExtractor.js +14 -7
  23. package/es/parsers/VariantExtractor.js.map +1 -1
  24. package/es/url-redirect/URLRedirectExtractor.js +185 -0
  25. package/es/url-redirect/URLRedirectExtractor.js.map +1 -0
  26. package/es/url-redirect/URLRedirectMatcher.js +115 -0
  27. package/es/url-redirect/URLRedirectMatcher.js.map +1 -0
  28. package/es/url-redirect/URLRedirectPlugin.js +350 -0
  29. package/es/url-redirect/URLRedirectPlugin.js.map +1 -0
  30. package/es/url-redirect/index.js +5 -0
  31. package/es/url-redirect/index.js.map +1 -0
  32. package/es/url-redirect/types.js +2 -0
  33. package/es/url-redirect/types.js.map +1 -0
  34. package/es/utils/persistence.js +278 -0
  35. package/es/utils/persistence.js.map +1 -0
  36. package/es/utils/plugin-registry.js +47 -0
  37. package/es/utils/plugin-registry.js.map +1 -0
  38. package/lib/core/DOMChangesPluginLite.d.ts +10 -7
  39. package/lib/core/DOMChangesPluginLite.js +192 -220
  40. package/lib/core/DOMChangesPluginLite.js.map +1 -1
  41. package/lib/core/DOMManipulatorLite.js +66 -9
  42. package/lib/core/DOMManipulatorLite.js.map +1 -1
  43. package/lib/core/ExposureTracker.d.ts +6 -0
  44. package/lib/core/ExposureTracker.js +136 -11
  45. package/lib/core/ExposureTracker.js.map +1 -1
  46. package/lib/entries/dom-with-overrides-lite.d.ts +2 -0
  47. package/lib/entries/dom-with-overrides-lite.js +3 -1
  48. package/lib/entries/dom-with-overrides-lite.js.map +1 -1
  49. package/lib/index.d.ts +8 -2
  50. package/lib/index.js +17 -1
  51. package/lib/index.js.map +1 -1
  52. package/lib/overrides/OverridesPlugin.js +2 -2
  53. package/lib/overrides/OverridesPlugin.js.map +1 -1
  54. package/lib/overrides/OverridesPluginLite.d.ts +8 -0
  55. package/lib/overrides/OverridesPluginLite.js +29 -1
  56. package/lib/overrides/OverridesPluginLite.js.map +1 -1
  57. package/lib/overrides/overridesUtils.d.ts +10 -5
  58. package/lib/overrides/overridesUtils.js +28 -18
  59. package/lib/overrides/overridesUtils.js.map +1 -1
  60. package/lib/parsers/VariantExtractor.js +14 -7
  61. package/lib/parsers/VariantExtractor.js.map +1 -1
  62. package/lib/types/index.d.ts +1 -0
  63. package/lib/url-redirect/URLRedirectExtractor.d.ts +16 -0
  64. package/lib/url-redirect/URLRedirectExtractor.js +188 -0
  65. package/lib/url-redirect/URLRedirectExtractor.js.map +1 -0
  66. package/lib/url-redirect/URLRedirectMatcher.d.ts +8 -0
  67. package/lib/url-redirect/URLRedirectMatcher.js +118 -0
  68. package/lib/url-redirect/URLRedirectMatcher.js.map +1 -0
  69. package/lib/url-redirect/URLRedirectPlugin.d.ts +21 -0
  70. package/lib/url-redirect/URLRedirectPlugin.js +353 -0
  71. package/lib/url-redirect/URLRedirectPlugin.js.map +1 -0
  72. package/lib/url-redirect/index.d.ts +4 -0
  73. package/lib/url-redirect/index.js +25 -0
  74. package/lib/url-redirect/index.js.map +1 -0
  75. package/lib/url-redirect/types.d.ts +29 -0
  76. package/lib/url-redirect/types.js +3 -0
  77. package/lib/url-redirect/types.js.map +1 -0
  78. package/lib/utils/persistence.d.ts +23 -0
  79. package/lib/utils/persistence.js +281 -0
  80. package/lib/utils/persistence.js.map +1 -0
  81. package/lib/utils/plugin-registry.d.ts +40 -0
  82. package/lib/utils/plugin-registry.js +53 -0
  83. package/lib/utils/plugin-registry.js.map +1 -0
  84. package/package.json +59 -3
  85. package/types/core/DOMChangesPluginLite.d.ts +10 -7
  86. package/types/core/ExposureTracker.d.ts +6 -0
  87. package/types/entries/dom-with-overrides-lite.d.ts +2 -0
  88. package/types/index.d.ts +8 -2
  89. package/types/overrides/OverridesPluginLite.d.ts +8 -0
  90. package/types/overrides/overridesUtils.d.ts +10 -5
  91. package/types/types/index.d.ts +1 -0
  92. package/types/url-redirect/URLRedirectExtractor.d.ts +16 -0
  93. package/types/url-redirect/URLRedirectMatcher.d.ts +8 -0
  94. package/types/url-redirect/URLRedirectPlugin.d.ts +21 -0
  95. package/types/url-redirect/index.d.ts +4 -0
  96. package/types/url-redirect/types.d.ts +29 -0
  97. package/types/utils/persistence.d.ts +23 -0
  98. package/types/utils/plugin-registry.d.ts +40 -0
@@ -0,0 +1,350 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var __values = (this && this.__values) || function(o) {
38
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
39
+ if (m) return m.call(o);
40
+ if (o && typeof o.length === "number") return {
41
+ next: function () {
42
+ if (o && i >= o.length) o = void 0;
43
+ return { value: o && o[i++], done: !o };
44
+ }
45
+ };
46
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
47
+ };
48
+ var __read = (this && this.__read) || function (o, n) {
49
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
50
+ if (!m) return o;
51
+ var i = m.call(o), r, ar = [], e;
52
+ try {
53
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
54
+ }
55
+ catch (error) { e = { error: error }; }
56
+ finally {
57
+ try {
58
+ if (r && !r.done && (m = i["return"])) m.call(i);
59
+ }
60
+ finally { if (e) throw e.error; }
61
+ }
62
+ return ar;
63
+ };
64
+ import { URLRedirectExtractor } from './URLRedirectExtractor';
65
+ import { URLRedirectMatcher } from './URLRedirectMatcher';
66
+ import { URLMatcher } from '../utils/URLMatcher';
67
+ import { logDebug } from '../utils/debug';
68
+ var URLRedirectPlugin = /** @class */ (function () {
69
+ function URLRedirectPlugin(config) {
70
+ var _this = this;
71
+ var _a, _b, _c, _d;
72
+ this.initialized = false;
73
+ this.config = {
74
+ context: config.context,
75
+ variableName: (_a = config.variableName) !== null && _a !== void 0 ? _a : '__url_redirect',
76
+ debug: (_b = config.debug) !== null && _b !== void 0 ? _b : false,
77
+ autoApply: (_c = config.autoApply) !== null && _c !== void 0 ? _c : true,
78
+ useBeacon: (_d = config.useBeacon) !== null && _d !== void 0 ? _d : true,
79
+ onBeforeRedirect: config.onBeforeRedirect,
80
+ };
81
+ if (!this.config.context) {
82
+ throw new Error('[ABsmartly URLRedirect] Context is required');
83
+ }
84
+ console.log("[ABsmartly] URLRedirectPlugin v".concat(URLRedirectPlugin.VERSION, " initialized"));
85
+ this.extractor = new URLRedirectExtractor(this.config.context, this.config.variableName, this.config.debug);
86
+ this.readyPromise = this.config.context
87
+ .ready()
88
+ .then(function () {
89
+ logDebug('[URLRedirectPlugin] Context is ready, checking for redirects');
90
+ return _this.initialize();
91
+ })
92
+ .catch(function (error) {
93
+ logDebug('[URLRedirectPlugin] ERROR during initialization:', error);
94
+ throw error;
95
+ });
96
+ }
97
+ URLRedirectPlugin.prototype.ready = function () {
98
+ return __awaiter(this, void 0, void 0, function () {
99
+ return __generator(this, function (_a) {
100
+ return [2 /*return*/, this.readyPromise];
101
+ });
102
+ });
103
+ };
104
+ URLRedirectPlugin.prototype.initialize = function () {
105
+ return __awaiter(this, void 0, void 0, function () {
106
+ var currentUrl, match;
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0:
110
+ if (this.initialized) {
111
+ logDebug('[URLRedirectPlugin] Already initialized');
112
+ return [2 /*return*/, null];
113
+ }
114
+ currentUrl = typeof window !== 'undefined' ? window.location.href : '';
115
+ if (!currentUrl) {
116
+ logDebug('[URLRedirectPlugin] No window.location available (server-side?)');
117
+ this.initialized = true;
118
+ return [2 /*return*/, null];
119
+ }
120
+ if (this.config.debug) {
121
+ logDebug('[URLRedirectPlugin] Initializing', {
122
+ version: URLRedirectPlugin.VERSION,
123
+ currentUrl: currentUrl,
124
+ autoApply: this.config.autoApply,
125
+ useBeacon: this.config.useBeacon,
126
+ });
127
+ }
128
+ match = this.findRedirectMatch(currentUrl);
129
+ this.initialized = true;
130
+ this.registerWithContext();
131
+ if (!(match && this.config.autoApply)) return [3 /*break*/, 2];
132
+ return [4 /*yield*/, this.executeRedirect(match)];
133
+ case 1:
134
+ _a.sent();
135
+ _a.label = 2;
136
+ case 2: return [2 /*return*/, match];
137
+ }
138
+ });
139
+ });
140
+ };
141
+ URLRedirectPlugin.prototype.findRedirectMatch = function (url) {
142
+ var e_1, _a;
143
+ if (url === void 0) { url = window.location.href; }
144
+ var allConfigs = this.extractor.extractAllConfigs();
145
+ if (this.config.debug) {
146
+ logDebug('[URLRedirectPlugin] Checking redirects for URL:', url);
147
+ logDebug('[URLRedirectPlugin] Experiments with redirect configs:', Array.from(allConfigs.keys()));
148
+ }
149
+ try {
150
+ for (var allConfigs_1 = __values(allConfigs), allConfigs_1_1 = allConfigs_1.next(); !allConfigs_1_1.done; allConfigs_1_1 = allConfigs_1.next()) {
151
+ var _b = __read(allConfigs_1_1.value, 2), experimentName = _b[0], variantConfigs = _b[1];
152
+ var currentVariant = this.config.context.peek(experimentName);
153
+ if (currentVariant === undefined || currentVariant === null) {
154
+ continue;
155
+ }
156
+ var config = variantConfigs.get(currentVariant);
157
+ if (!config) {
158
+ if (currentVariant === 0) {
159
+ var anyConfig = this.getAnyConfig(variantConfigs);
160
+ if ((anyConfig === null || anyConfig === void 0 ? void 0 : anyConfig.controlBehavior) === 'redirect-same') {
161
+ if (this.config.debug) {
162
+ logDebug("[URLRedirectPlugin] Control variant with redirect-same behavior for ".concat(experimentName));
163
+ }
164
+ return {
165
+ redirect: { from: url, to: url, type: 'page', preservePath: true },
166
+ targetUrl: url,
167
+ experimentName: experimentName,
168
+ variant: 0,
169
+ isControl: true,
170
+ };
171
+ }
172
+ }
173
+ continue;
174
+ }
175
+ if (config.urlFilter && !URLMatcher.matches(config.urlFilter, url)) {
176
+ if (this.config.debug) {
177
+ logDebug("[URLRedirectPlugin] URL doesn't match filter for ".concat(experimentName));
178
+ }
179
+ continue;
180
+ }
181
+ var match = URLRedirectMatcher.findMatch(url, config.redirects, experimentName, currentVariant);
182
+ if (match) {
183
+ if (this.config.debug) {
184
+ logDebug('[URLRedirectPlugin] Found redirect match:', {
185
+ experimentName: experimentName,
186
+ variant: currentVariant,
187
+ from: match.redirect.from,
188
+ to: match.redirect.to,
189
+ targetUrl: match.targetUrl,
190
+ });
191
+ }
192
+ return match;
193
+ }
194
+ }
195
+ }
196
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
197
+ finally {
198
+ try {
199
+ if (allConfigs_1_1 && !allConfigs_1_1.done && (_a = allConfigs_1.return)) _a.call(allConfigs_1);
200
+ }
201
+ finally { if (e_1) throw e_1.error; }
202
+ }
203
+ return null;
204
+ };
205
+ URLRedirectPlugin.prototype.getAnyConfig = function (configs) {
206
+ var e_2, _a;
207
+ try {
208
+ for (var _b = __values(configs.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
209
+ var config = _c.value;
210
+ return config;
211
+ }
212
+ }
213
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
214
+ finally {
215
+ try {
216
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
217
+ }
218
+ finally { if (e_2) throw e_2.error; }
219
+ }
220
+ return null;
221
+ };
222
+ URLRedirectPlugin.prototype.executeRedirect = function (match) {
223
+ return __awaiter(this, void 0, void 0, function () {
224
+ var error_1;
225
+ return __generator(this, function (_a) {
226
+ switch (_a.label) {
227
+ case 0:
228
+ if (this.config.debug) {
229
+ logDebug('[URLRedirectPlugin] Executing redirect:', {
230
+ experimentName: match.experimentName,
231
+ targetUrl: match.targetUrl,
232
+ isControl: match.isControl,
233
+ });
234
+ }
235
+ if (!this.config.onBeforeRedirect) return [3 /*break*/, 2];
236
+ return [4 /*yield*/, this.config.onBeforeRedirect(match)];
237
+ case 1:
238
+ _a.sent();
239
+ _a.label = 2;
240
+ case 2:
241
+ this.config.context.treatment(match.experimentName);
242
+ _a.label = 3;
243
+ case 3:
244
+ _a.trys.push([3, 8, , 9]);
245
+ if (!this.config.useBeacon) return [3 /*break*/, 5];
246
+ return [4 /*yield*/, this.publishViaBeacon()];
247
+ case 4:
248
+ _a.sent();
249
+ return [3 /*break*/, 7];
250
+ case 5: return [4 /*yield*/, this.config.context.publish()];
251
+ case 6:
252
+ _a.sent();
253
+ _a.label = 7;
254
+ case 7: return [3 /*break*/, 9];
255
+ case 8:
256
+ error_1 = _a.sent();
257
+ logDebug('[URLRedirectPlugin] Failed to publish exposure:', error_1);
258
+ return [3 /*break*/, 9];
259
+ case 9:
260
+ if (match.targetUrl !== window.location.href) {
261
+ if (this.config.debug) {
262
+ logDebug('[URLRedirectPlugin] Redirecting to:', match.targetUrl);
263
+ }
264
+ window.location.href = match.targetUrl;
265
+ }
266
+ else if (this.config.debug) {
267
+ logDebug('[URLRedirectPlugin] Target URL same as current, skipping redirect');
268
+ }
269
+ return [2 /*return*/];
270
+ }
271
+ });
272
+ });
273
+ };
274
+ URLRedirectPlugin.prototype.publishViaBeacon = function () {
275
+ return __awaiter(this, void 0, void 0, function () {
276
+ var context, error_2;
277
+ return __generator(this, function (_a) {
278
+ switch (_a.label) {
279
+ case 0:
280
+ context = this.config.context;
281
+ if (!(typeof context.publish === 'function')) return [3 /*break*/, 5];
282
+ _a.label = 1;
283
+ case 1:
284
+ _a.trys.push([1, 3, , 5]);
285
+ return [4 /*yield*/, context.publish({ useBeacon: true })];
286
+ case 2:
287
+ _a.sent();
288
+ return [3 /*break*/, 5];
289
+ case 3:
290
+ error_2 = _a.sent();
291
+ logDebug('[URLRedirectPlugin] Beacon publish failed, falling back to regular publish');
292
+ return [4 /*yield*/, context.publish()];
293
+ case 4:
294
+ _a.sent();
295
+ return [3 /*break*/, 5];
296
+ case 5: return [2 /*return*/];
297
+ }
298
+ });
299
+ });
300
+ };
301
+ URLRedirectPlugin.prototype.getExtractor = function () {
302
+ return this.extractor;
303
+ };
304
+ URLRedirectPlugin.prototype.refreshExperiments = function () {
305
+ this.extractor.clearCache();
306
+ if (this.config.debug) {
307
+ logDebug('[URLRedirectPlugin] Cache cleared');
308
+ }
309
+ };
310
+ URLRedirectPlugin.prototype.destroy = function () {
311
+ this.unregisterFromContext();
312
+ this.initialized = false;
313
+ if (this.config.debug) {
314
+ logDebug('[URLRedirectPlugin] Destroyed');
315
+ }
316
+ };
317
+ URLRedirectPlugin.prototype.registerWithContext = function () {
318
+ var context = this.config.context;
319
+ if (context) {
320
+ if (!context.__plugins) {
321
+ context.__plugins = {};
322
+ }
323
+ context.__plugins.urlRedirectPlugin = {
324
+ name: 'URLRedirectPlugin',
325
+ version: URLRedirectPlugin.VERSION,
326
+ initialized: true,
327
+ capabilities: ['redirect', 'domain-redirect', 'page-redirect'],
328
+ instance: this,
329
+ timestamp: Date.now(),
330
+ };
331
+ if (this.config.debug) {
332
+ logDebug('[URLRedirectPlugin] Registered with context at __plugins.urlRedirectPlugin');
333
+ }
334
+ }
335
+ };
336
+ URLRedirectPlugin.prototype.unregisterFromContext = function () {
337
+ var _a;
338
+ var context = this.config.context;
339
+ if ((_a = context === null || context === void 0 ? void 0 : context.__plugins) === null || _a === void 0 ? void 0 : _a.urlRedirectPlugin) {
340
+ delete context.__plugins.urlRedirectPlugin;
341
+ if (this.config.debug) {
342
+ logDebug('[URLRedirectPlugin] Unregistered from context');
343
+ }
344
+ }
345
+ };
346
+ URLRedirectPlugin.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : '1.0.0';
347
+ return URLRedirectPlugin;
348
+ }());
349
+ export { URLRedirectPlugin };
350
+ //# sourceMappingURL=URLRedirectPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"URLRedirectPlugin.js","sourceRoot":"","sources":["../../src/url-redirect/URLRedirectPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C;IAWE,2BAAY,MAA+B;QAA3C,iBAgCC;;QAnCO,gBAAW,GAAG,KAAK,CAAC;QAI1B,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,YAAY,EAAE,MAAA,MAAM,CAAC,YAAY,mCAAI,gBAAgB;YACrD,KAAK,EAAE,MAAA,MAAM,CAAC,KAAK,mCAAI,KAAK;YAC5B,SAAS,EAAE,MAAA,MAAM,CAAC,SAAS,mCAAI,IAAI;YACnC,SAAS,EAAE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C;IArQsB,yBAAO,GAC5B,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,AAD9B,CAC+B;IAqQ/D,wBAAC;CAAA,AAvQD,IAuQC;SAvQY,iBAAiB"}
@@ -0,0 +1,5 @@
1
+ export * from './types';
2
+ export { URLRedirectPlugin } from './URLRedirectPlugin';
3
+ export { URLRedirectExtractor } from './URLRedirectExtractor';
4
+ export { URLRedirectMatcher } from './URLRedirectMatcher';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/url-redirect/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/url-redirect/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,278 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ import { logDebug } from './debug';
29
+ var DOMPersistenceManager = /** @class */ (function () {
30
+ function DOMPersistenceManager(config) {
31
+ this.watchedElements = new WeakMap();
32
+ this.persistenceObserver = null;
33
+ this.reapplyingElements = new Set();
34
+ this.reapplyLogThrottle = new Map();
35
+ this.appliedChanges = new Map();
36
+ this.config = config;
37
+ }
38
+ DOMPersistenceManager.prototype.watchElement = function (element, experimentName, change) {
39
+ var experiments = this.watchedElements.get(element);
40
+ if (!experiments) {
41
+ experiments = new Set();
42
+ this.watchedElements.set(element, experiments);
43
+ }
44
+ experiments.add(experimentName);
45
+ if (!this.appliedChanges.has(experimentName)) {
46
+ this.appliedChanges.set(experimentName, []);
47
+ }
48
+ var changes = this.appliedChanges.get(experimentName);
49
+ var isNewWatch = !changes.includes(change);
50
+ if (isNewWatch) {
51
+ changes.push(change);
52
+ if (this.config.debug) {
53
+ var currentStyles_1 = {};
54
+ if (change.value && typeof change.value === 'object') {
55
+ Object.keys(change.value).forEach(function (prop) {
56
+ var cssProp = prop.replace(/([A-Z])/g, '-$1').toLowerCase();
57
+ currentStyles_1[cssProp] = element.style.getPropertyValue(cssProp);
58
+ });
59
+ }
60
+ logDebug('[WATCH-ELEMENT] Started watching element for persistence', {
61
+ experimentName: experimentName,
62
+ selector: change.selector,
63
+ element: element.tagName,
64
+ changeType: change.type,
65
+ value: change.value,
66
+ currentStyles: change.type === 'style' ? currentStyles_1 : undefined,
67
+ timestamp: Date.now(),
68
+ });
69
+ }
70
+ }
71
+ if (!this.persistenceObserver) {
72
+ this.setupPersistenceObserver();
73
+ }
74
+ };
75
+ DOMPersistenceManager.prototype.unwatchElement = function (element, experimentName) {
76
+ var experiments = this.watchedElements.get(element);
77
+ if (experiments) {
78
+ experiments.delete(experimentName);
79
+ if (experiments.size === 0) {
80
+ this.watchedElements.delete(element);
81
+ }
82
+ }
83
+ };
84
+ DOMPersistenceManager.prototype.unwatchExperiment = function (experimentName) {
85
+ this.appliedChanges.delete(experimentName);
86
+ };
87
+ DOMPersistenceManager.prototype.getAppliedChanges = function () {
88
+ return this.appliedChanges;
89
+ };
90
+ DOMPersistenceManager.prototype.clearAll = function () {
91
+ this.appliedChanges.clear();
92
+ };
93
+ DOMPersistenceManager.prototype.destroy = function () {
94
+ if (this.persistenceObserver) {
95
+ this.persistenceObserver.disconnect();
96
+ this.persistenceObserver = null;
97
+ }
98
+ this.appliedChanges.clear();
99
+ this.reapplyingElements.clear();
100
+ this.reapplyLogThrottle.clear();
101
+ };
102
+ DOMPersistenceManager.prototype.setupPersistenceObserver = function () {
103
+ var _this = this;
104
+ if (this.persistenceObserver)
105
+ return;
106
+ if (this.config.debug) {
107
+ logDebug('[PERSISTENCE-OBSERVER] Setting up persistence observer', {
108
+ timestamp: Date.now(),
109
+ });
110
+ }
111
+ this.persistenceObserver = new MutationObserver(function (mutations) {
112
+ if (_this.config.debug) {
113
+ logDebug('[MUTATION-DETECTED] Persistence observer detected mutations', {
114
+ mutationCount: mutations.length,
115
+ timestamp: Date.now(),
116
+ });
117
+ }
118
+ mutations.forEach(function (mutation) {
119
+ var element = mutation.target;
120
+ if (_this.reapplyingElements.has(element)) {
121
+ if (_this.config.debug) {
122
+ logDebug('[MUTATION-SKIP] Skipping mutation - currently reapplying', {
123
+ element: element.tagName,
124
+ });
125
+ }
126
+ return;
127
+ }
128
+ var experiments = _this.watchedElements.get(element);
129
+ if (experiments) {
130
+ if (_this.config.debug) {
131
+ var elementKey = "mutation:".concat(element.tagName, ":").concat(element.getAttribute('name') || element.className);
132
+ var now = Date.now();
133
+ var lastLogged = _this.reapplyLogThrottle.get(elementKey) || 0;
134
+ if (now - lastLogged > 5000) {
135
+ logDebug('[MUTATION-ON-WATCHED] Mutation detected on watched element', {
136
+ element: element.tagName,
137
+ attributeName: mutation.attributeName,
138
+ oldValue: mutation.oldValue,
139
+ experiments: Array.from(experiments),
140
+ });
141
+ _this.reapplyLogThrottle.set(elementKey, now);
142
+ }
143
+ }
144
+ experiments.forEach(function (experimentName) {
145
+ var appliedChanges = _this.appliedChanges.get(experimentName);
146
+ if (appliedChanges) {
147
+ appliedChanges.forEach(function (change) {
148
+ var e_1, _a, e_2, _b;
149
+ var needsReapply = false;
150
+ if (change.type === 'style' &&
151
+ mutation.attributeName === 'style' &&
152
+ change.persistStyle !== false) {
153
+ needsReapply = _this.checkStyleOverwritten(element, change.value);
154
+ }
155
+ else if (change.type === 'attribute' && change.persistAttribute !== false) {
156
+ if (change.value && typeof change.value === 'object') {
157
+ try {
158
+ for (var _c = __values(Object.keys(change.value)), _d = _c.next(); !_d.done; _d = _c.next()) {
159
+ var attrName = _d.value;
160
+ if (mutation.attributeName === attrName) {
161
+ needsReapply = _this.checkAttributeOverwritten(element, change.value);
162
+ break;
163
+ }
164
+ }
165
+ }
166
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
167
+ finally {
168
+ try {
169
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
170
+ }
171
+ finally { if (e_1) throw e_1.error; }
172
+ }
173
+ }
174
+ }
175
+ if (needsReapply) {
176
+ _this.reapplyingElements.add(element);
177
+ var logKey = "".concat(experimentName, "-").concat(change.selector);
178
+ var now = Date.now();
179
+ var lastLogged = _this.reapplyLogThrottle.get(logKey) || 0;
180
+ if (_this.config.debug && now - lastLogged > 5000) {
181
+ logDebug('[REAPPLY-TRIGGERED] Reapplying after mutation (React/framework conflict detected)', {
182
+ experimentName: experimentName,
183
+ selector: change.selector,
184
+ element: element.tagName,
185
+ changeType: change.type,
186
+ timestamp: now,
187
+ });
188
+ _this.reapplyLogThrottle.set(logKey, now);
189
+ if (_this.reapplyLogThrottle.size > 100) {
190
+ var oldestAllowed = now - 60000;
191
+ try {
192
+ for (var _e = __values(_this.reapplyLogThrottle.entries()), _f = _e.next(); !_f.done; _f = _e.next()) {
193
+ var _g = __read(_f.value, 2), key = _g[0], time = _g[1];
194
+ if (time < oldestAllowed) {
195
+ _this.reapplyLogThrottle.delete(key);
196
+ }
197
+ }
198
+ }
199
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
200
+ finally {
201
+ try {
202
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
203
+ }
204
+ finally { if (e_2) throw e_2.error; }
205
+ }
206
+ }
207
+ }
208
+ _this.config.onReapply(change, experimentName);
209
+ setTimeout(function () {
210
+ _this.reapplyingElements.delete(element);
211
+ }, 0);
212
+ }
213
+ });
214
+ }
215
+ });
216
+ }
217
+ });
218
+ });
219
+ this.persistenceObserver.observe(document.body, {
220
+ attributes: true,
221
+ subtree: true,
222
+ attributeOldValue: true,
223
+ });
224
+ if (this.config.debug) {
225
+ logDebug('[PERSISTENCE-OBSERVER] Setup complete - now observing mutations', {
226
+ target: 'document.body',
227
+ attributeFilter: ['style', 'class'],
228
+ subtree: true,
229
+ timestamp: Date.now(),
230
+ });
231
+ }
232
+ };
233
+ DOMPersistenceManager.prototype.checkStyleOverwritten = function (element, expectedStyles) {
234
+ var e_3, _a;
235
+ try {
236
+ for (var _b = __values(Object.entries(expectedStyles)), _c = _b.next(); !_c.done; _c = _b.next()) {
237
+ var _d = __read(_c.value, 2), prop = _d[0], value = _d[1];
238
+ var cssProp = prop.replace(/([A-Z])/g, '-$1').toLowerCase();
239
+ var currentValue = element.style.getPropertyValue(cssProp);
240
+ var currentPriority = element.style.getPropertyPriority(cssProp);
241
+ if (currentValue !== value || (value.includes('!important') && !currentPriority)) {
242
+ return true;
243
+ }
244
+ }
245
+ }
246
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
247
+ finally {
248
+ try {
249
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
250
+ }
251
+ finally { if (e_3) throw e_3.error; }
252
+ }
253
+ return false;
254
+ };
255
+ DOMPersistenceManager.prototype.checkAttributeOverwritten = function (element, expectedAttributes) {
256
+ var e_4, _a;
257
+ try {
258
+ for (var _b = __values(Object.entries(expectedAttributes)), _c = _b.next(); !_c.done; _c = _b.next()) {
259
+ var _d = __read(_c.value, 2), attr = _d[0], value = _d[1];
260
+ var currentValue = element.getAttribute(attr);
261
+ if (currentValue !== value) {
262
+ return true;
263
+ }
264
+ }
265
+ }
266
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
267
+ finally {
268
+ try {
269
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
270
+ }
271
+ finally { if (e_4) throw e_4.error; }
272
+ }
273
+ return false;
274
+ };
275
+ return DOMPersistenceManager;
276
+ }());
277
+ export { DOMPersistenceManager };
278
+ //# sourceMappingURL=persistence.js.map