@uniformdev/context 19.159.1-alpha.16 → 19.159.1-alpha.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/api.js CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
8
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
12
  var __export = (target, all) => {
10
13
  for (var name in all)
@@ -27,23 +30,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  mod
28
31
  ));
29
32
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __publicField = (obj, key, value) => {
31
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
- return value;
33
- };
34
- var __accessCheck = (obj, member, msg) => {
35
- if (!member.has(obj))
36
- throw TypeError("Cannot " + msg);
37
- };
38
- var __privateGet = (obj, member, getter) => {
39
- __accessCheck(obj, member, "read from private field");
40
- return getter ? getter.call(obj) : member.get(obj);
41
- };
42
- var __privateAdd = (obj, member, value) => {
43
- if (member.has(obj))
44
- throw TypeError("Cannot add the same private member more than once");
45
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
46
- };
33
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
34
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
35
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
36
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
47
37
 
48
38
  // src/api/api.ts
49
39
  var api_exports = {};
@@ -195,8 +185,7 @@ var ApiClient = class _ApiClient {
195
185
  return url;
196
186
  }
197
187
  ensureApiHost(apiHost) {
198
- if (!apiHost)
199
- return "https://uniform.app";
188
+ if (!apiHost) return "https://uniform.app";
200
189
  if (!(apiHost == null ? void 0 : apiHost.startsWith("http"))) {
201
190
  throw new Error('Your apiHost must start with "http"');
202
191
  }
package/dist/api/api.mjs CHANGED
@@ -1,22 +1,12 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- var __accessCheck = (obj, member, msg) => {
8
- if (!member.has(obj))
9
- throw TypeError("Cannot " + msg);
10
- };
11
- var __privateGet = (obj, member, getter) => {
12
- __accessCheck(obj, member, "read from private field");
13
- return getter ? getter.call(obj) : member.get(obj);
14
- };
15
- var __privateAdd = (obj, member, value) => {
16
- if (member.has(obj))
17
- throw TypeError("Cannot add the same private member more than once");
18
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
19
4
  };
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
20
10
 
21
11
  // src/api/apiClientUtils.ts
22
12
  import pLimit from "p-limit";
@@ -130,8 +120,7 @@ var ApiClient = class _ApiClient {
130
120
  return url;
131
121
  }
132
122
  ensureApiHost(apiHost) {
133
- if (!apiHost)
134
- return "https://uniform.app";
123
+ if (!apiHost) return "https://uniform.app";
135
124
  if (!(apiHost == null ? void 0 : apiHost.startsWith("http"))) {
136
125
  throw new Error('Your apiHost must start with "http"');
137
126
  }
package/dist/index.esm.js CHANGED
@@ -1,31 +1,14 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- var __accessCheck = (obj, member, msg) => {
8
- if (!member.has(obj))
9
- throw TypeError("Cannot " + msg);
10
- };
11
- var __privateGet = (obj, member, getter) => {
12
- __accessCheck(obj, member, "read from private field");
13
- return getter ? getter.call(obj) : member.get(obj);
14
- };
15
- var __privateAdd = (obj, member, value) => {
16
- if (member.has(obj))
17
- throw TypeError("Cannot add the same private member more than once");
18
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
19
- };
20
- var __privateSet = (obj, member, value, setter) => {
21
- __accessCheck(obj, member, "write to private field");
22
- setter ? setter.call(obj, value) : member.set(obj, value);
23
- return value;
24
- };
25
- var __privateMethod = (obj, member, method) => {
26
- __accessCheck(obj, member, "access private method");
27
- return method;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
28
4
  };
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
29
12
 
30
13
  // src/manifest/aggregates/computeAggregateDimensions.ts
31
14
  function computeAggregateDimensions(primitiveScores, aggregates) {
@@ -80,8 +63,8 @@ var ENR_SEPARATOR = "_";
80
63
  var _signal, _id;
81
64
  var SignalGoalEvaluator = class {
82
65
  constructor(options) {
83
- __privateAdd(this, _signal, void 0);
84
- __privateAdd(this, _id, void 0);
66
+ __privateAdd(this, _signal);
67
+ __privateAdd(this, _id);
85
68
  __privateSet(this, _id, options.id);
86
69
  __privateSet(this, _signal, options.signal);
87
70
  }
@@ -105,8 +88,8 @@ _id = new WeakMap();
105
88
  var _evaluator, _onLogMessage;
106
89
  var SignalInstance = class {
107
90
  constructor(data, evaluator, onLogMessage) {
108
- __privateAdd(this, _evaluator, void 0);
109
- __privateAdd(this, _onLogMessage, void 0);
91
+ __privateAdd(this, _evaluator);
92
+ __privateAdd(this, _onLogMessage);
110
93
  __publicField(this, "signal");
111
94
  this.signal = data;
112
95
  __privateSet(this, _evaluator, evaluator);
@@ -168,10 +151,10 @@ var ManifestInstance = class {
168
151
  }
169
152
  }) {
170
153
  __publicField(this, "data");
171
- __privateAdd(this, _mf, void 0);
172
- __privateAdd(this, _signalInstances, void 0);
154
+ __privateAdd(this, _mf);
155
+ __privateAdd(this, _signalInstances);
173
156
  __privateAdd(this, _goalEvaluators, []);
174
- __privateAdd(this, _onLogMessage2, void 0);
157
+ __privateAdd(this, _onLogMessage2);
175
158
  var _a, _b, _c, _d, _e;
176
159
  __privateSet(this, _mf, (_a = manifest.project) != null ? _a : {});
177
160
  this.data = manifest;
@@ -488,7 +471,7 @@ var quirkEvaluator = ({ update, criteria, signal, onLogMessage }) => {
488
471
  var _evaluators;
489
472
  var GroupCriteriaEvaluator = class {
490
473
  constructor(criteriaEvaluators) {
491
- __privateAdd(this, _evaluators, void 0);
474
+ __privateAdd(this, _evaluators);
492
475
  __privateSet(this, _evaluators, criteriaEvaluators);
493
476
  }
494
477
  evaluate(update, crit, commands, signal, onLogMessage) {
@@ -845,8 +828,8 @@ var SERVER_STATE_ID = "__UNIFORM_DATA__";
845
828
  var _data, _initialData, _mitt;
846
829
  var TransitionDataStore = class {
847
830
  constructor({ initialData }) {
848
- __privateAdd(this, _data, void 0);
849
- __privateAdd(this, _initialData, void 0);
831
+ __privateAdd(this, _data);
832
+ __privateAdd(this, _initialData);
850
833
  __privateAdd(this, _mitt, mitt());
851
834
  /**
852
835
  * Subscribe to events from the transition storage
@@ -917,8 +900,7 @@ for (let i = 0; i < alphabet.length; i++) {
917
900
  s2b[alphabet.charCodeAt(i)] = i;
918
901
  }
919
902
  var ntob = (number) => {
920
- if (number < 0)
921
- return `-${ntob(-number)}`;
903
+ if (number < 0) return `-${ntob(-number)}`;
922
904
  let lo = number >>> 0;
923
905
  let hi = number / 4294967296 >>> 0;
924
906
  let right = "";
@@ -957,20 +939,18 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
957
939
  super({
958
940
  initialData: ssr ? parseScoreCookie(serverCookieValue) : void 0
959
941
  });
960
- __privateAdd(this, _cookieName, void 0);
961
- __privateAdd(this, _cookieAttributes, void 0);
942
+ __privateAdd(this, _cookieName);
943
+ __privateAdd(this, _cookieAttributes);
962
944
  __privateSet(this, _cookieName, cookieName);
963
945
  __privateSet(this, _cookieAttributes, cookieAttributes);
964
946
  }
965
947
  handleDelete() {
966
- if (ssr)
967
- return Promise.resolve();
948
+ if (ssr) return Promise.resolve();
968
949
  Cookies.remove(__privateGet(this, _cookieName));
969
950
  return Promise.resolve();
970
951
  }
971
952
  async handleUpdateData(_, computedValue) {
972
- if (ssr)
973
- return;
953
+ if (ssr) return;
974
954
  if (computedValue.consent) {
975
955
  Cookies.set(__privateGet(this, _cookieName), serializeCookie(computedValue), __privateGet(this, _cookieAttributes));
976
956
  } else {
@@ -984,11 +964,9 @@ var TYPE_SEP = "~";
984
964
  var PAIR_SEP = "!";
985
965
  var KV_SEP = "-";
986
966
  function parseScoreCookie(cookieValue) {
987
- if (!cookieValue)
988
- return;
967
+ if (!cookieValue) return;
989
968
  const types = cookieValue.split(TYPE_SEP);
990
- if (types.length > 5)
991
- return;
969
+ if (types.length > 5) return;
992
970
  const [abTestData, sessionScores, visitorScores, controlGroup, personalizeVariants] = types;
993
971
  const data = {
994
972
  // this is true since we're reading a cookie, which wouldn't exist if consent wasn't given
@@ -1007,8 +985,7 @@ function parseCookieType(type) {
1007
985
  }
1008
986
  const pairs = type.split(PAIR_SEP).map((pair) => pair.split(KV_SEP));
1009
987
  return pairs.reduce((acc, cur) => {
1010
- if (cur.length < 2)
1011
- return acc;
988
+ if (cur.length < 2) return acc;
1012
989
  acc[cur[0]] = cur.slice(1).join("-");
1013
990
  return acc;
1014
991
  }, {});
@@ -1076,13 +1053,13 @@ function serializeCookieType(type) {
1076
1053
  }
1077
1054
 
1078
1055
  // src/storage/EdgeTransitionDataStore.ts
1079
- var _fetchData, fetchData_fn;
1056
+ var _EdgeTransitionDataStore_instances, fetchData_fn;
1080
1057
  var EdgeTransitionDataStore = class extends TransitionDataStore {
1081
1058
  constructor({ serverCookieValue, visitorIdCookieName = "ufvi", ...base }) {
1082
1059
  super(base);
1083
- __privateAdd(this, _fetchData);
1060
+ __privateAdd(this, _EdgeTransitionDataStore_instances);
1084
1061
  if (!base.initialData) {
1085
- __privateMethod(this, _fetchData, fetchData_fn).call(this).catch((err) => {
1062
+ __privateMethod(this, _EdgeTransitionDataStore_instances, fetchData_fn).call(this).catch((err) => {
1086
1063
  console.error(err);
1087
1064
  });
1088
1065
  }
@@ -1101,7 +1078,7 @@ var EdgeTransitionDataStore = class extends TransitionDataStore {
1101
1078
  }
1102
1079
  }
1103
1080
  };
1104
- _fetchData = new WeakSet();
1081
+ _EdgeTransitionDataStore_instances = new WeakSet();
1105
1082
  fetchData_fn = async function() {
1106
1083
  const serviceData = await new Promise((resolve) => {
1107
1084
  setTimeout(() => {
@@ -1179,8 +1156,7 @@ function applyCommandsToData(commands, state, inControlGroup) {
1179
1156
  newData.tests[command.data.test] = command.data.variant;
1180
1157
  break;
1181
1158
  case "modscore":
1182
- if (inControlGroup)
1183
- break;
1159
+ if (inControlGroup) break;
1184
1160
  const delta = Number(command.data.delta);
1185
1161
  if (isNaN(delta)) {
1186
1162
  throw new Error("Non-number delta received");
@@ -1189,8 +1165,7 @@ function applyCommandsToData(commands, state, inControlGroup) {
1189
1165
  newData.scores[command.data.dimension] = existing + delta;
1190
1166
  break;
1191
1167
  case "modscoreS":
1192
- if (inControlGroup)
1193
- break;
1168
+ if (inControlGroup) break;
1194
1169
  const deltaS = Number(command.data.delta);
1195
1170
  if (isNaN(deltaS)) {
1196
1171
  throw new Error("Non-number delta received");
@@ -1275,30 +1250,14 @@ var LocalStorage = class {
1275
1250
 
1276
1251
  // src/storage/VisitorDataStore.ts
1277
1252
  var STORAGE_KEY = "ufvisitor";
1278
- var _mitt2, _persist, _visitTimeout, _options, _currentData, currentData_get, _replaceData, replaceData_fn, _setVisitTimeout, setVisitTimeout_fn, _isExpired, isExpired_fn, _handleCaps, handleCaps_fn, _defaultData, defaultData_fn;
1253
+ var _mitt2, _persist, _visitTimeout, _options, _VisitorDataStore_instances, currentData_get, replaceData_fn, setVisitTimeout_fn, isExpired_fn, handleCaps_fn, defaultData_fn;
1279
1254
  var VisitorDataStore = class {
1280
1255
  constructor(options) {
1281
- /** Gets the current client-side storage data. This property is always up to date. */
1282
- __privateAdd(this, _currentData);
1283
- /**
1284
- * IMPORTANT: This function mutates the input data. This is done,
1285
- * because all the sources that call it have either already spread or cloned
1286
- * the data, so we can safely mutate it for better perf.
1287
- */
1288
- __privateAdd(this, _replaceData);
1289
- __privateAdd(this, _setVisitTimeout);
1290
- __privateAdd(this, _isExpired);
1291
- /**
1292
- * IMPORTANT: This function mutates the input data. This is done,
1293
- * because all the sources that call it have either already spread or cloned
1294
- * the data, so we can safely mutate it for better perf.
1295
- */
1296
- __privateAdd(this, _handleCaps);
1297
- __privateAdd(this, _defaultData);
1256
+ __privateAdd(this, _VisitorDataStore_instances);
1298
1257
  __privateAdd(this, _mitt2, mitt2());
1299
1258
  __privateAdd(this, _persist, new LocalStorage());
1300
- __privateAdd(this, _visitTimeout, void 0);
1301
- __privateAdd(this, _options, void 0);
1259
+ __privateAdd(this, _visitTimeout);
1260
+ __privateAdd(this, _options);
1302
1261
  /**
1303
1262
  * Subscribe to events from storage
1304
1263
  */
@@ -1307,8 +1266,8 @@ var VisitorDataStore = class {
1307
1266
  off: __privateGet(this, _mitt2).off
1308
1267
  });
1309
1268
  __privateSet(this, _options, options);
1310
- if (!__privateGet(this, _currentData, currentData_get)) {
1311
- __privateMethod(this, _replaceData, replaceData_fn).call(this, __privateMethod(this, _defaultData, defaultData_fn).call(this), true);
1269
+ if (!__privateGet(this, _VisitorDataStore_instances, currentData_get)) {
1270
+ __privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, __privateMethod(this, _VisitorDataStore_instances, defaultData_fn).call(this), true);
1312
1271
  }
1313
1272
  if (options.transitionStore) {
1314
1273
  const serverToClientTransitionState = options.transitionStore.getClientTransitionState();
@@ -1316,17 +1275,17 @@ var VisitorDataStore = class {
1316
1275
  options.onServerTransitionReceived(serverToClientTransitionState);
1317
1276
  }
1318
1277
  options.transitionStore.events.on("dataUpdatedAsync", (data) => {
1319
- __privateMethod(this, _replaceData, replaceData_fn).call(this, {
1320
- ...__privateGet(this, _currentData, currentData_get).visitorData,
1278
+ __privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, {
1279
+ ...__privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData,
1321
1280
  ...data
1322
1281
  });
1323
1282
  });
1324
1283
  const transitionData = options.transitionStore.data;
1325
1284
  if (transitionData) {
1326
- __privateMethod(this, _replaceData, replaceData_fn).call(
1285
+ __privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(
1327
1286
  this,
1328
1287
  // we know _currentData is not empty because we inited it above if it was
1329
- { ...__privateGet(this, _currentData, currentData_get).visitorData, ...transitionData },
1288
+ { ...__privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData, ...transitionData },
1330
1289
  true
1331
1290
  );
1332
1291
  }
@@ -1335,12 +1294,12 @@ var VisitorDataStore = class {
1335
1294
  /** Gets the current visitor data. This property is always up to date. */
1336
1295
  get data() {
1337
1296
  var _a, _b;
1338
- const data = __privateGet(this, _currentData, currentData_get);
1339
- if (__privateMethod(this, _isExpired, isExpired_fn).call(this, data)) {
1297
+ const data = __privateGet(this, _VisitorDataStore_instances, currentData_get);
1298
+ if (__privateMethod(this, _VisitorDataStore_instances, isExpired_fn).call(this, data)) {
1340
1299
  const { sessionScores, ...newData } = data.visitorData;
1341
- __privateMethod(this, _replaceData, replaceData_fn).call(this, { ...newData, sessionScores: {} });
1300
+ __privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, { ...newData, sessionScores: {} });
1342
1301
  (_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["info", 120]);
1343
- return __privateGet(this, _currentData, currentData_get).visitorData;
1302
+ return __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData;
1344
1303
  }
1345
1304
  return data.visitorData;
1346
1305
  }
@@ -1357,12 +1316,12 @@ var VisitorDataStore = class {
1357
1316
  return;
1358
1317
  }
1359
1318
  (_b = (_a = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _b.call(_a, ["debug", 101, commands]);
1360
- const newData = applyCommandsToData(commands, this.data, (_c = __privateGet(this, _currentData, currentData_get)) == null ? void 0 : _c.visitorData.controlGroup);
1319
+ const newData = applyCommandsToData(commands, this.data, (_c = __privateGet(this, _VisitorDataStore_instances, currentData_get)) == null ? void 0 : _c.visitorData.controlGroup);
1361
1320
  if (commands.some((c) => c.type === "consent" && !c.data)) {
1362
1321
  __privateGet(this, _persist).delete(STORAGE_KEY, true);
1363
1322
  }
1364
- __privateMethod(this, _replaceData, replaceData_fn).call(this, newData);
1365
- await ((_d = __privateGet(this, _options).transitionStore) == null ? void 0 : _d.updateData(commands, __privateGet(this, _currentData, currentData_get).visitorData));
1323
+ __privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
1324
+ await ((_d = __privateGet(this, _options).transitionStore) == null ? void 0 : _d.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
1366
1325
  }
1367
1326
  /**
1368
1327
  * Deletes visitor data (forgetting them)
@@ -1375,7 +1334,7 @@ var VisitorDataStore = class {
1375
1334
  try {
1376
1335
  __privateGet(this, _persist).delete(STORAGE_KEY, false);
1377
1336
  await ((_c = __privateGet(this, _options).transitionStore) == null ? void 0 : _c.delete(fromAllDevices));
1378
- __privateMethod(this, _replaceData, replaceData_fn).call(this, __privateMethod(this, _defaultData, defaultData_fn).call(this));
1337
+ __privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, __privateMethod(this, _VisitorDataStore_instances, defaultData_fn).call(this));
1379
1338
  } finally {
1380
1339
  (_e = (_d = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _e.call(_d, ["info", 103, "ENDGROUP"]);
1381
1340
  }
@@ -1385,21 +1344,25 @@ _mitt2 = new WeakMap();
1385
1344
  _persist = new WeakMap();
1386
1345
  _visitTimeout = new WeakMap();
1387
1346
  _options = new WeakMap();
1388
- _currentData = new WeakSet();
1347
+ _VisitorDataStore_instances = new WeakSet();
1389
1348
  currentData_get = function() {
1390
1349
  return __privateGet(this, _persist).get(STORAGE_KEY);
1391
1350
  };
1392
- _replaceData = new WeakSet();
1351
+ /**
1352
+ * IMPORTANT: This function mutates the input data. This is done,
1353
+ * because all the sources that call it have either already spread or cloned
1354
+ * the data, so we can safely mutate it for better perf.
1355
+ */
1393
1356
  replaceData_fn = function(data, quiet = false) {
1394
1357
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1395
- const oldData = __privateGet(this, _currentData, currentData_get);
1358
+ const oldData = __privateGet(this, _VisitorDataStore_instances, currentData_get);
1396
1359
  const now = Date.now();
1397
1360
  if (data.controlGroup) {
1398
1361
  data.scores = {};
1399
1362
  data.sessionScores = {};
1400
1363
  } else {
1401
- __privateMethod(this, _handleCaps, handleCaps_fn).call(this, data.scores);
1402
- __privateMethod(this, _handleCaps, handleCaps_fn).call(this, data.sessionScores);
1364
+ __privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.scores);
1365
+ __privateMethod(this, _VisitorDataStore_instances, handleCaps_fn).call(this, data.sessionScores);
1403
1366
  (_b = (_a = __privateGet(this, _options)).decay) == null ? void 0 : _b.call(_a, {
1404
1367
  now,
1405
1368
  lastUpd: oldData == null ? void 0 : oldData.updated,
@@ -1417,7 +1380,7 @@ replaceData_fn = function(data, quiet = false) {
1417
1380
  updated: now,
1418
1381
  visitorData: data
1419
1382
  };
1420
- __privateMethod(this, _setVisitTimeout, setVisitTimeout_fn).call(this);
1383
+ __privateMethod(this, _VisitorDataStore_instances, setVisitTimeout_fn).call(this);
1421
1384
  __privateGet(this, _persist).set(STORAGE_KEY, updatedData, !!data.consent);
1422
1385
  (_d = (_c = __privateGet(this, _options)).onLogMessage) == null ? void 0 : _d.call(_c, ["debug", 102, data]);
1423
1386
  if (!quiet) {
@@ -1448,7 +1411,6 @@ replaceData_fn = function(data, quiet = false) {
1448
1411
  }
1449
1412
  }
1450
1413
  };
1451
- _setVisitTimeout = new WeakSet();
1452
1414
  setVisitTimeout_fn = function() {
1453
1415
  if (typeof document === "undefined" || !__privateGet(this, _options).visitLifespan) {
1454
1416
  return;
@@ -1460,12 +1422,15 @@ setVisitTimeout_fn = function() {
1460
1422
  this.data;
1461
1423
  }, __privateGet(this, _options).visitLifespan + 50));
1462
1424
  };
1463
- _isExpired = new WeakSet();
1464
1425
  isExpired_fn = function(data) {
1465
1426
  const expires = __privateGet(this, _options).visitLifespan;
1466
1427
  return expires ? data.updated + expires < Date.now() : false;
1467
1428
  };
1468
- _handleCaps = new WeakSet();
1429
+ /**
1430
+ * IMPORTANT: This function mutates the input data. This is done,
1431
+ * because all the sources that call it have either already spread or cloned
1432
+ * the data, so we can safely mutate it for better perf.
1433
+ */
1469
1434
  handleCaps_fn = function(scores) {
1470
1435
  var _a, _b;
1471
1436
  if (!__privateGet(this, _options).manifest) {
@@ -1483,7 +1448,6 @@ handleCaps_fn = function(scores) {
1483
1448
  }
1484
1449
  }
1485
1450
  };
1486
- _defaultData = new WeakSet();
1487
1451
  defaultData_fn = function() {
1488
1452
  var _a, _b, _c;
1489
1453
  return {
@@ -1498,20 +1462,17 @@ import { dequal as dequal5 } from "dequal/lite";
1498
1462
  import mitt3 from "mitt";
1499
1463
  var CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
1500
1464
  var CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID = "contextual_editing_test_selected_variant";
1501
- var _serverTransitionState, _scores, _state, _pzCache, _plugins, _commands, _mitt3, _emitTest, emitTest_fn, _updateGoals, updateGoals_fn, _updateComputedScores, updateComputedScores_fn, _calculateScores, calculateScores_fn;
1465
+ var _serverTransitionState, _scores, _state, _pzCache, _plugins, _commands, _mitt3, _Context_instances, emitTest_fn, updateGoals_fn, updateComputedScores_fn, calculateScores_fn;
1502
1466
  var Context = class {
1503
1467
  constructor(options) {
1504
- __privateAdd(this, _emitTest);
1505
- __privateAdd(this, _updateGoals);
1506
- __privateAdd(this, _updateComputedScores);
1507
- __privateAdd(this, _calculateScores);
1468
+ __privateAdd(this, _Context_instances);
1508
1469
  __publicField(this, "manifest");
1509
- __privateAdd(this, _serverTransitionState, void 0);
1470
+ __privateAdd(this, _serverTransitionState);
1510
1471
  __privateAdd(this, _scores, {});
1511
- __privateAdd(this, _state, void 0);
1472
+ __privateAdd(this, _state);
1512
1473
  __privateAdd(this, _pzCache, {});
1513
- __privateAdd(this, _plugins, void 0);
1514
- __privateAdd(this, _commands, void 0);
1474
+ __privateAdd(this, _plugins);
1475
+ __privateAdd(this, _commands);
1515
1476
  __privateAdd(this, _mitt3, mitt3());
1516
1477
  /**
1517
1478
  * Subscribe to events
@@ -1560,9 +1521,9 @@ var Context = class {
1560
1521
  },
1561
1522
  onLogMessage: (message) => __privateGet(this, _mitt3).emit("log", message)
1562
1523
  });
1563
- this.storage.events.on("scoresUpdated", __privateMethod(this, _updateComputedScores, updateComputedScores_fn).bind(this));
1524
+ this.storage.events.on("scoresUpdated", __privateMethod(this, _Context_instances, updateComputedScores_fn).bind(this));
1564
1525
  if (!__privateGet(this, _serverTransitionState)) {
1565
- __privateMethod(this, _updateComputedScores, updateComputedScores_fn).call(this, this.storage.data);
1526
+ __privateMethod(this, _Context_instances, updateComputedScores_fn).call(this, this.storage.data);
1566
1527
  }
1567
1528
  this.storage.events.on("quirksUpdated", (quirks) => {
1568
1529
  const updates = this.manifest.computeSignals({
@@ -1571,7 +1532,7 @@ var Context = class {
1571
1532
  previousState: __privateGet(this, _state),
1572
1533
  visitor: this.storage.data
1573
1534
  });
1574
- __privateMethod(this, _updateGoals, updateGoals_fn).call(this, {
1535
+ __privateMethod(this, _Context_instances, updateGoals_fn).call(this, {
1575
1536
  quirks: quirks.quirks,
1576
1537
  scores: void 0
1577
1538
  });
@@ -1694,7 +1655,7 @@ var Context = class {
1694
1655
  // re-compute using scores from storage instead of the current scores since
1695
1656
  // server transition scores might have adjusted values already integrated into them,
1696
1657
  // which causes issues when you are near limits.
1697
- scores: __privateGet(this, _serverTransitionState) ? __privateMethod(this, _calculateScores, calculateScores_fn).call(this, this.storage.data) : __privateGet(this, _scores)
1658
+ scores: __privateGet(this, _serverTransitionState) ? __privateMethod(this, _Context_instances, calculateScores_fn).call(this, this.storage.data) : __privateGet(this, _scores)
1698
1659
  })
1699
1660
  );
1700
1661
  __privateSet(this, _state, {
@@ -1707,9 +1668,9 @@ var Context = class {
1707
1668
  serverCommands: __privateGet(this, _serverTransitionState).commands,
1708
1669
  commands
1709
1670
  });
1710
- __privateMethod(this, _updateComputedScores, updateComputedScores_fn).call(this, this.storage.data);
1671
+ __privateMethod(this, _Context_instances, updateComputedScores_fn).call(this, this.storage.data);
1711
1672
  Object.entries(newServerSideTests).forEach(([testName, testVariantId]) => {
1712
- __privateMethod(this, _emitTest, emitTest_fn).call(this, {
1673
+ __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
1713
1674
  name: testName,
1714
1675
  variantId: testVariantId,
1715
1676
  variantAssigned: true
@@ -1806,7 +1767,7 @@ var Context = class {
1806
1767
  context: this,
1807
1768
  onLogMessage: (message) => __privateGet(this, _mitt3).emit("log", message)
1808
1769
  });
1809
- __privateMethod(this, _emitTest, emitTest_fn).call(this, {
1770
+ __privateMethod(this, _Context_instances, emitTest_fn).call(this, {
1810
1771
  name: options.name,
1811
1772
  variantId: (_c = (_b = value.result) == null ? void 0 : _b.id) != null ? _c : void 0,
1812
1773
  variantAssigned: value.variantAssigned
@@ -1880,7 +1841,7 @@ var Context = class {
1880
1841
  internal_processTestEvent(event) {
1881
1842
  if (event.variantId) {
1882
1843
  this.setTestVariantId(event.name, event.variantId);
1883
- __privateMethod(this, _emitTest, emitTest_fn).call(this, event);
1844
+ __privateMethod(this, _Context_instances, emitTest_fn).call(this, event);
1884
1845
  }
1885
1846
  }
1886
1847
  /** @deprecated */
@@ -1896,24 +1857,22 @@ _pzCache = new WeakMap();
1896
1857
  _plugins = new WeakMap();
1897
1858
  _commands = new WeakMap();
1898
1859
  _mitt3 = new WeakMap();
1899
- _emitTest = new WeakSet();
1860
+ _Context_instances = new WeakSet();
1900
1861
  emitTest_fn = function(event) {
1901
1862
  __privateGet(this, _mitt3).emit("testResult", event);
1902
1863
  };
1903
- _updateGoals = new WeakSet();
1904
1864
  updateGoals_fn = async function(data) {
1905
1865
  const goalCommands = this.manifest.computeGoals(data);
1906
1866
  if (goalCommands.length !== 0) {
1907
1867
  await this.storage.updateData(goalCommands);
1908
1868
  }
1909
1869
  };
1910
- _updateComputedScores = new WeakSet();
1911
1870
  updateComputedScores_fn = function(newData) {
1912
- const newScores = __privateMethod(this, _calculateScores, calculateScores_fn).call(this, newData);
1871
+ const newScores = __privateMethod(this, _Context_instances, calculateScores_fn).call(this, newData);
1913
1872
  const newScoresHaveChanged = !dequal5(newScores, __privateGet(this, _scores));
1914
1873
  if (newScoresHaveChanged) {
1915
1874
  __privateSet(this, _scores, newScores);
1916
- __privateMethod(this, _updateGoals, updateGoals_fn).call(this, {
1875
+ __privateMethod(this, _Context_instances, updateGoals_fn).call(this, {
1917
1876
  scores: __privateGet(this, _scores),
1918
1877
  quirks: void 0
1919
1878
  });
@@ -1921,7 +1880,6 @@ updateComputedScores_fn = function(newData) {
1921
1880
  __privateGet(this, _mitt3).emit("log", ["info", 3, newScores]);
1922
1881
  }
1923
1882
  };
1924
- _calculateScores = new WeakSet();
1925
1883
  calculateScores_fn = function(newData) {
1926
1884
  var _a;
1927
1885
  let newScores = { ...newData.scores };
@@ -1970,13 +1928,11 @@ function enableContextDevTools(options) {
1970
1928
  );
1971
1929
  };
1972
1930
  const onPersonalizationResult = (e) => {
1973
- if (!e.changed)
1974
- return;
1931
+ if (!e.changed) return;
1975
1932
  personalizations.push(e);
1976
1933
  };
1977
1934
  const onTestResult = (e) => {
1978
- if (!e.variantAssigned)
1979
- return;
1935
+ if (!e.variantAssigned) return;
1980
1936
  tests.push(e);
1981
1937
  };
1982
1938
  if (isBrowser) {