@uniformdev/context 19.167.2-alpha.3 → 19.170.1-alpha.0
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.d.mts +1 -1
- package/dist/api/api.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +23 -8
- package/dist/index.js +23 -8
- package/dist/index.mjs +23 -8
- package/dist/{types-KWnn2ElZ.d.mts → types-4YSyIXmc.d.mts} +12 -0
- package/dist/{types-KWnn2ElZ.d.ts → types-4YSyIXmc.d.ts} +12 -0
- package/package.json +2 -2
package/dist/api/api.d.mts
CHANGED
package/dist/api/api.d.ts
CHANGED
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-
|
2
|
-
export { _ as AggregateDimensionInput, a4 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, an as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a1 as DimensionMatch, X as EnrichmentCategory, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ag as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ab as ModifyScoreCommand, ac as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, av as PersonalizeControlVariant, a2 as PersonalizeOptions, aw as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ar as Quirks, al as SERVER_STATE_ID, ak as ServerToClientTransitionState, ad as SetConsentCommand, ah as SetControlGroupCommand, aa as SetGoalCommand, ai as SetPersonalizeVariantControlCommand, ae as SetQuirkCommand, af as SetTestCommand, z as Severity, R as Signal, W as SignalCriteria, U as SignalCriteriaGroup, K as SignalData, a9 as StorageCommand, Z as TestDefinition, k as TestEvent, $ as TestOptions, a8 as TestResult, a7 as TestVariant, as as Tests, am as TransitionDataStoreEvents, aq as VisitorDataStore, ap as VisitorDataStoreEvents, ao as VisitorDataStoreOptions, aj as areCommandsEqual, ay as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-
|
1
|
+
import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-4YSyIXmc.mjs';
|
2
|
+
export { _ as AggregateDimensionInput, a4 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, an as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a1 as DimensionMatch, X as EnrichmentCategory, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ag as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ab as ModifyScoreCommand, ac as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, av as PersonalizeControlVariant, a2 as PersonalizeOptions, aw as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ar as Quirks, al as SERVER_STATE_ID, ak as ServerToClientTransitionState, ad as SetConsentCommand, ah as SetControlGroupCommand, aa as SetGoalCommand, ai as SetPersonalizeVariantControlCommand, ae as SetQuirkCommand, af as SetTestCommand, z as Severity, R as Signal, W as SignalCriteria, U as SignalCriteriaGroup, K as SignalData, a9 as StorageCommand, Z as TestDefinition, k as TestEvent, $ as TestOptions, a8 as TestResult, a7 as TestVariant, as as Tests, am as TransitionDataStoreEvents, aq as VisitorDataStore, ap as VisitorDataStoreEvents, ao as VisitorDataStoreOptions, aj as areCommandsEqual, ay as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-4YSyIXmc.mjs';
|
3
3
|
import Cookies from 'js-cookie';
|
4
4
|
import 'mitt';
|
5
5
|
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-
|
2
|
-
export { _ as AggregateDimensionInput, a4 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, an as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a1 as DimensionMatch, X as EnrichmentCategory, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ag as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ab as ModifyScoreCommand, ac as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, av as PersonalizeControlVariant, a2 as PersonalizeOptions, aw as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ar as Quirks, al as SERVER_STATE_ID, ak as ServerToClientTransitionState, ad as SetConsentCommand, ah as SetControlGroupCommand, aa as SetGoalCommand, ai as SetPersonalizeVariantControlCommand, ae as SetQuirkCommand, af as SetTestCommand, z as Severity, R as Signal, W as SignalCriteria, U as SignalCriteriaGroup, K as SignalData, a9 as StorageCommand, Z as TestDefinition, k as TestEvent, $ as TestOptions, a8 as TestResult, a7 as TestVariant, as as Tests, am as TransitionDataStoreEvents, aq as VisitorDataStore, ap as VisitorDataStoreEvents, ao as VisitorDataStoreOptions, aj as areCommandsEqual, ay as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-
|
1
|
+
import { O as OutputSeverity, L as LogDrain, C as ContextPlugin, S as ScoreVector, A as AggregateDimension, T as TransitionDataStore, a as StorageCommands, V as VisitorData, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, g as DevToolsEvents } from './types-4YSyIXmc.js';
|
2
|
+
export { _ as AggregateDimensionInput, a4 as BehaviorTag, h as CONTEXTUAL_EDITING_TEST_NAME, i as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, n as Context, l as ContextEvents, m as ContextInstance, j as ContextOptions, az as ContextState, aA as ContextStateUpdate, J as CriteriaEvaluatorParameters, I as CriteriaEvaluatorResult, an as DecayOptions, q as DevToolsActions, t as DevToolsDataEvent, r as DevToolsEvent, x as DevToolsForgetEvent, u as DevToolsHelloEvent, s as DevToolsLogEvent, w as DevToolsRawCommandsEvent, p as DevToolsState, o as DevToolsUiVersion, v as DevToolsUpdateEvent, a1 as DimensionMatch, X as EnrichmentCategory, au as EnrichmentData, ax as EventData, aB as GoalStateUpdate, at as Goals, H as GroupCriteriaEvaluator, ag as IdentifyCommand, F as LogMessageGroup, E as LogMessageSingle, y as LogMessages, G as ManifestInstance, N as ManifestV2, M as MessageCategory, B as MessageFunc, ab as ModifyScoreCommand, ac as ModifySessionScoreCommand, Y as NumberMatch, P as PersonalizationEvent, Q as PersonalizationManifest, av as PersonalizeControlVariant, a2 as PersonalizeOptions, aw as PersonalizeVariants, a6 as PersonalizedResult, a5 as PersonalizedVariant, ar as Quirks, al as SERVER_STATE_ID, ak as ServerToClientTransitionState, ad as SetConsentCommand, ah as SetControlGroupCommand, aa as SetGoalCommand, ai as SetPersonalizeVariantControlCommand, ae as SetQuirkCommand, af as SetTestCommand, z as Severity, R as Signal, W as SignalCriteria, U as SignalCriteriaGroup, K as SignalData, a9 as StorageCommand, Z as TestDefinition, k as TestEvent, $ as TestOptions, a8 as TestResult, a7 as TestVariant, as as Tests, am as TransitionDataStoreEvents, aq as VisitorDataStore, ap as VisitorDataStoreEvents, ao as VisitorDataStoreOptions, aj as areCommandsEqual, ay as emptyVisitorData, a3 as personalizeVariations, a0 as testVariations } from './types-4YSyIXmc.js';
|
3
3
|
import Cookies from 'js-cookie';
|
4
4
|
import 'mitt';
|
5
5
|
|
package/dist/index.esm.js
CHANGED
@@ -1209,44 +1209,54 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1209
1209
|
}
|
1210
1210
|
|
1211
1211
|
// src/storage/util/LocalStorage.ts
|
1212
|
+
var _LocalStorage_instances, key_fn;
|
1212
1213
|
var LocalStorage = class {
|
1213
|
-
constructor() {
|
1214
|
+
constructor(partitionKey) {
|
1215
|
+
this.partitionKey = partitionKey;
|
1216
|
+
__privateAdd(this, _LocalStorage_instances);
|
1214
1217
|
__publicField(this, "inMemoryFallback", {});
|
1215
1218
|
__publicField(this, "hasLocalStorageObject", typeof localStorage !== "undefined");
|
1216
1219
|
}
|
1217
1220
|
get(key) {
|
1218
|
-
const
|
1221
|
+
const keyValue = __privateMethod(this, _LocalStorage_instances, key_fn).call(this, key);
|
1222
|
+
const fallbackValue = this.inMemoryFallback[keyValue];
|
1219
1223
|
if (!this.hasLocalStorageObject || fallbackValue) {
|
1220
1224
|
return fallbackValue;
|
1221
1225
|
}
|
1222
1226
|
try {
|
1223
|
-
const value = localStorage.getItem(
|
1227
|
+
const value = localStorage.getItem(keyValue);
|
1224
1228
|
return value ? JSON.parse(value) : void 0;
|
1225
1229
|
} catch (e) {
|
1226
1230
|
return fallbackValue;
|
1227
1231
|
}
|
1228
1232
|
}
|
1229
1233
|
set(key, value, storageConsent) {
|
1230
|
-
this.
|
1234
|
+
const keyValue = __privateMethod(this, _LocalStorage_instances, key_fn).call(this, key);
|
1235
|
+
this.inMemoryFallback[keyValue] = value;
|
1231
1236
|
if (!this.hasLocalStorageObject || !storageConsent) {
|
1232
1237
|
return;
|
1233
1238
|
}
|
1234
1239
|
try {
|
1235
|
-
localStorage.setItem(
|
1240
|
+
localStorage.setItem(keyValue, JSON.stringify(value));
|
1236
1241
|
} catch (e) {
|
1237
1242
|
console.warn(e);
|
1238
1243
|
}
|
1239
1244
|
}
|
1240
1245
|
delete(key, leaveInMemory) {
|
1246
|
+
const keyValue = __privateMethod(this, _LocalStorage_instances, key_fn).call(this, key);
|
1241
1247
|
if (!leaveInMemory) {
|
1242
|
-
delete this.inMemoryFallback[
|
1248
|
+
delete this.inMemoryFallback[keyValue];
|
1243
1249
|
}
|
1244
1250
|
try {
|
1245
|
-
localStorage.removeItem(
|
1251
|
+
localStorage.removeItem(keyValue);
|
1246
1252
|
} catch (e) {
|
1247
1253
|
}
|
1248
1254
|
}
|
1249
1255
|
};
|
1256
|
+
_LocalStorage_instances = new WeakSet();
|
1257
|
+
key_fn = function(key) {
|
1258
|
+
return this.partitionKey ? `${this.partitionKey}.${key}` : key;
|
1259
|
+
};
|
1250
1260
|
|
1251
1261
|
// src/storage/VisitorDataStore.ts
|
1252
1262
|
var STORAGE_KEY = "ufvisitor";
|
@@ -1255,7 +1265,7 @@ var VisitorDataStore = class {
|
|
1255
1265
|
constructor(options) {
|
1256
1266
|
__privateAdd(this, _VisitorDataStore_instances);
|
1257
1267
|
__privateAdd(this, _mitt2, mitt2());
|
1258
|
-
__privateAdd(this, _persist
|
1268
|
+
__privateAdd(this, _persist);
|
1259
1269
|
__privateAdd(this, _visitTimeout);
|
1260
1270
|
__privateAdd(this, _options);
|
1261
1271
|
/**
|
@@ -1266,6 +1276,7 @@ var VisitorDataStore = class {
|
|
1266
1276
|
off: __privateGet(this, _mitt2).off
|
1267
1277
|
});
|
1268
1278
|
__privateSet(this, _options, options);
|
1279
|
+
__privateSet(this, _persist, new LocalStorage(options.partitionKey));
|
1269
1280
|
if (!__privateGet(this, _VisitorDataStore_instances, currentData_get)) {
|
1270
1281
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, __privateMethod(this, _VisitorDataStore_instances, defaultData_fn).call(this), true);
|
1271
1282
|
}
|
@@ -1322,6 +1333,7 @@ var VisitorDataStore = class {
|
|
1322
1333
|
}
|
1323
1334
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
|
1324
1335
|
await ((_d = __privateGet(this, _options).transitionStore) == null ? void 0 : _d.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
|
1336
|
+
__privateGet(this, _mitt2).emit("commandsExecuted", commands);
|
1325
1337
|
}
|
1326
1338
|
/**
|
1327
1339
|
* Deletes visitor data (forgetting them)
|
@@ -1549,6 +1561,9 @@ var Context = class {
|
|
1549
1561
|
} finally {
|
1550
1562
|
__privateGet(this, _mitt3).emit("log", ["info", 1, "ENDGROUP"]);
|
1551
1563
|
}
|
1564
|
+
if (typeof window !== "undefined") {
|
1565
|
+
window.__UNIFORM_CONTEXTUAL_EDITING_CONTEXT__ = this;
|
1566
|
+
}
|
1552
1567
|
}
|
1553
1568
|
/** Gets the current visitor's dimension score vector. */
|
1554
1569
|
get scores() {
|
package/dist/index.js
CHANGED
@@ -1281,44 +1281,54 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1281
1281
|
}
|
1282
1282
|
|
1283
1283
|
// src/storage/util/LocalStorage.ts
|
1284
|
+
var _LocalStorage_instances, key_fn;
|
1284
1285
|
var LocalStorage = class {
|
1285
|
-
constructor() {
|
1286
|
+
constructor(partitionKey) {
|
1287
|
+
this.partitionKey = partitionKey;
|
1288
|
+
__privateAdd(this, _LocalStorage_instances);
|
1286
1289
|
__publicField(this, "inMemoryFallback", {});
|
1287
1290
|
__publicField(this, "hasLocalStorageObject", typeof localStorage !== "undefined");
|
1288
1291
|
}
|
1289
1292
|
get(key) {
|
1290
|
-
const
|
1293
|
+
const keyValue = __privateMethod(this, _LocalStorage_instances, key_fn).call(this, key);
|
1294
|
+
const fallbackValue = this.inMemoryFallback[keyValue];
|
1291
1295
|
if (!this.hasLocalStorageObject || fallbackValue) {
|
1292
1296
|
return fallbackValue;
|
1293
1297
|
}
|
1294
1298
|
try {
|
1295
|
-
const value = localStorage.getItem(
|
1299
|
+
const value = localStorage.getItem(keyValue);
|
1296
1300
|
return value ? JSON.parse(value) : void 0;
|
1297
1301
|
} catch (e) {
|
1298
1302
|
return fallbackValue;
|
1299
1303
|
}
|
1300
1304
|
}
|
1301
1305
|
set(key, value, storageConsent) {
|
1302
|
-
this.
|
1306
|
+
const keyValue = __privateMethod(this, _LocalStorage_instances, key_fn).call(this, key);
|
1307
|
+
this.inMemoryFallback[keyValue] = value;
|
1303
1308
|
if (!this.hasLocalStorageObject || !storageConsent) {
|
1304
1309
|
return;
|
1305
1310
|
}
|
1306
1311
|
try {
|
1307
|
-
localStorage.setItem(
|
1312
|
+
localStorage.setItem(keyValue, JSON.stringify(value));
|
1308
1313
|
} catch (e) {
|
1309
1314
|
console.warn(e);
|
1310
1315
|
}
|
1311
1316
|
}
|
1312
1317
|
delete(key, leaveInMemory) {
|
1318
|
+
const keyValue = __privateMethod(this, _LocalStorage_instances, key_fn).call(this, key);
|
1313
1319
|
if (!leaveInMemory) {
|
1314
|
-
delete this.inMemoryFallback[
|
1320
|
+
delete this.inMemoryFallback[keyValue];
|
1315
1321
|
}
|
1316
1322
|
try {
|
1317
|
-
localStorage.removeItem(
|
1323
|
+
localStorage.removeItem(keyValue);
|
1318
1324
|
} catch (e) {
|
1319
1325
|
}
|
1320
1326
|
}
|
1321
1327
|
};
|
1328
|
+
_LocalStorage_instances = new WeakSet();
|
1329
|
+
key_fn = function(key) {
|
1330
|
+
return this.partitionKey ? `${this.partitionKey}.${key}` : key;
|
1331
|
+
};
|
1322
1332
|
|
1323
1333
|
// src/storage/VisitorDataStore.ts
|
1324
1334
|
var STORAGE_KEY = "ufvisitor";
|
@@ -1327,7 +1337,7 @@ var VisitorDataStore = class {
|
|
1327
1337
|
constructor(options) {
|
1328
1338
|
__privateAdd(this, _VisitorDataStore_instances);
|
1329
1339
|
__privateAdd(this, _mitt2, (0, import_mitt2.default)());
|
1330
|
-
__privateAdd(this, _persist
|
1340
|
+
__privateAdd(this, _persist);
|
1331
1341
|
__privateAdd(this, _visitTimeout);
|
1332
1342
|
__privateAdd(this, _options);
|
1333
1343
|
/**
|
@@ -1338,6 +1348,7 @@ var VisitorDataStore = class {
|
|
1338
1348
|
off: __privateGet(this, _mitt2).off
|
1339
1349
|
});
|
1340
1350
|
__privateSet(this, _options, options);
|
1351
|
+
__privateSet(this, _persist, new LocalStorage(options.partitionKey));
|
1341
1352
|
if (!__privateGet(this, _VisitorDataStore_instances, currentData_get)) {
|
1342
1353
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, __privateMethod(this, _VisitorDataStore_instances, defaultData_fn).call(this), true);
|
1343
1354
|
}
|
@@ -1394,6 +1405,7 @@ var VisitorDataStore = class {
|
|
1394
1405
|
}
|
1395
1406
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
|
1396
1407
|
await ((_d = __privateGet(this, _options).transitionStore) == null ? void 0 : _d.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
|
1408
|
+
__privateGet(this, _mitt2).emit("commandsExecuted", commands);
|
1397
1409
|
}
|
1398
1410
|
/**
|
1399
1411
|
* Deletes visitor data (forgetting them)
|
@@ -1621,6 +1633,9 @@ var Context = class {
|
|
1621
1633
|
} finally {
|
1622
1634
|
__privateGet(this, _mitt3).emit("log", ["info", 1, "ENDGROUP"]);
|
1623
1635
|
}
|
1636
|
+
if (typeof window !== "undefined") {
|
1637
|
+
window.__UNIFORM_CONTEXTUAL_EDITING_CONTEXT__ = this;
|
1638
|
+
}
|
1624
1639
|
}
|
1625
1640
|
/** Gets the current visitor's dimension score vector. */
|
1626
1641
|
get scores() {
|
package/dist/index.mjs
CHANGED
@@ -1209,44 +1209,54 @@ function applyCommandsToData(commands, state, inControlGroup) {
|
|
1209
1209
|
}
|
1210
1210
|
|
1211
1211
|
// src/storage/util/LocalStorage.ts
|
1212
|
+
var _LocalStorage_instances, key_fn;
|
1212
1213
|
var LocalStorage = class {
|
1213
|
-
constructor() {
|
1214
|
+
constructor(partitionKey) {
|
1215
|
+
this.partitionKey = partitionKey;
|
1216
|
+
__privateAdd(this, _LocalStorage_instances);
|
1214
1217
|
__publicField(this, "inMemoryFallback", {});
|
1215
1218
|
__publicField(this, "hasLocalStorageObject", typeof localStorage !== "undefined");
|
1216
1219
|
}
|
1217
1220
|
get(key) {
|
1218
|
-
const
|
1221
|
+
const keyValue = __privateMethod(this, _LocalStorage_instances, key_fn).call(this, key);
|
1222
|
+
const fallbackValue = this.inMemoryFallback[keyValue];
|
1219
1223
|
if (!this.hasLocalStorageObject || fallbackValue) {
|
1220
1224
|
return fallbackValue;
|
1221
1225
|
}
|
1222
1226
|
try {
|
1223
|
-
const value = localStorage.getItem(
|
1227
|
+
const value = localStorage.getItem(keyValue);
|
1224
1228
|
return value ? JSON.parse(value) : void 0;
|
1225
1229
|
} catch (e) {
|
1226
1230
|
return fallbackValue;
|
1227
1231
|
}
|
1228
1232
|
}
|
1229
1233
|
set(key, value, storageConsent) {
|
1230
|
-
this.
|
1234
|
+
const keyValue = __privateMethod(this, _LocalStorage_instances, key_fn).call(this, key);
|
1235
|
+
this.inMemoryFallback[keyValue] = value;
|
1231
1236
|
if (!this.hasLocalStorageObject || !storageConsent) {
|
1232
1237
|
return;
|
1233
1238
|
}
|
1234
1239
|
try {
|
1235
|
-
localStorage.setItem(
|
1240
|
+
localStorage.setItem(keyValue, JSON.stringify(value));
|
1236
1241
|
} catch (e) {
|
1237
1242
|
console.warn(e);
|
1238
1243
|
}
|
1239
1244
|
}
|
1240
1245
|
delete(key, leaveInMemory) {
|
1246
|
+
const keyValue = __privateMethod(this, _LocalStorage_instances, key_fn).call(this, key);
|
1241
1247
|
if (!leaveInMemory) {
|
1242
|
-
delete this.inMemoryFallback[
|
1248
|
+
delete this.inMemoryFallback[keyValue];
|
1243
1249
|
}
|
1244
1250
|
try {
|
1245
|
-
localStorage.removeItem(
|
1251
|
+
localStorage.removeItem(keyValue);
|
1246
1252
|
} catch (e) {
|
1247
1253
|
}
|
1248
1254
|
}
|
1249
1255
|
};
|
1256
|
+
_LocalStorage_instances = new WeakSet();
|
1257
|
+
key_fn = function(key) {
|
1258
|
+
return this.partitionKey ? `${this.partitionKey}.${key}` : key;
|
1259
|
+
};
|
1250
1260
|
|
1251
1261
|
// src/storage/VisitorDataStore.ts
|
1252
1262
|
var STORAGE_KEY = "ufvisitor";
|
@@ -1255,7 +1265,7 @@ var VisitorDataStore = class {
|
|
1255
1265
|
constructor(options) {
|
1256
1266
|
__privateAdd(this, _VisitorDataStore_instances);
|
1257
1267
|
__privateAdd(this, _mitt2, mitt2());
|
1258
|
-
__privateAdd(this, _persist
|
1268
|
+
__privateAdd(this, _persist);
|
1259
1269
|
__privateAdd(this, _visitTimeout);
|
1260
1270
|
__privateAdd(this, _options);
|
1261
1271
|
/**
|
@@ -1266,6 +1276,7 @@ var VisitorDataStore = class {
|
|
1266
1276
|
off: __privateGet(this, _mitt2).off
|
1267
1277
|
});
|
1268
1278
|
__privateSet(this, _options, options);
|
1279
|
+
__privateSet(this, _persist, new LocalStorage(options.partitionKey));
|
1269
1280
|
if (!__privateGet(this, _VisitorDataStore_instances, currentData_get)) {
|
1270
1281
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, __privateMethod(this, _VisitorDataStore_instances, defaultData_fn).call(this), true);
|
1271
1282
|
}
|
@@ -1322,6 +1333,7 @@ var VisitorDataStore = class {
|
|
1322
1333
|
}
|
1323
1334
|
__privateMethod(this, _VisitorDataStore_instances, replaceData_fn).call(this, newData);
|
1324
1335
|
await ((_d = __privateGet(this, _options).transitionStore) == null ? void 0 : _d.updateData(commands, __privateGet(this, _VisitorDataStore_instances, currentData_get).visitorData));
|
1336
|
+
__privateGet(this, _mitt2).emit("commandsExecuted", commands);
|
1325
1337
|
}
|
1326
1338
|
/**
|
1327
1339
|
* Deletes visitor data (forgetting them)
|
@@ -1549,6 +1561,9 @@ var Context = class {
|
|
1549
1561
|
} finally {
|
1550
1562
|
__privateGet(this, _mitt3).emit("log", ["info", 1, "ENDGROUP"]);
|
1551
1563
|
}
|
1564
|
+
if (typeof window !== "undefined") {
|
1565
|
+
window.__UNIFORM_CONTEXTUAL_EDITING_CONTEXT__ = this;
|
1566
|
+
}
|
1552
1567
|
}
|
1553
1568
|
/** Gets the current visitor's dimension score vector. */
|
1554
1569
|
get scores() {
|
@@ -282,6 +282,11 @@ type VisitorDataStoreOptions = {
|
|
282
282
|
onServerTransitionReceived?: (state: ServerToClientTransitionState) => void;
|
283
283
|
/** Called when a log message is emitted from the data store */
|
284
284
|
onLogMessage?: (message: LogMessage) => void;
|
285
|
+
/**
|
286
|
+
* Optionally specify a prefix for all storage keys.
|
287
|
+
* Only required if using multiple Context instances on the same domain and need to separate them.
|
288
|
+
*/
|
289
|
+
partitionKey?: string;
|
285
290
|
};
|
286
291
|
type VisitorDataStoreEvents = {
|
287
292
|
/**
|
@@ -314,6 +319,8 @@ type VisitorDataStoreEvents = {
|
|
314
319
|
goalConverted: {
|
315
320
|
goalId: string;
|
316
321
|
};
|
322
|
+
/** Fired when storage update commands are done executing */
|
323
|
+
commandsExecuted: StorageCommands[];
|
317
324
|
};
|
318
325
|
declare class VisitorDataStore {
|
319
326
|
#private;
|
@@ -1213,6 +1220,11 @@ declare global {
|
|
1213
1220
|
interface Window {
|
1214
1221
|
/** Window var set by enableContextDevTools() to enable embedded devtools to receive Context instance and attach events to it. */
|
1215
1222
|
__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__?: Context;
|
1223
|
+
/**
|
1224
|
+
* Window var set automatically that Uniform's contextual editing uses to respond to changes in the Context within its preview pane,
|
1225
|
+
* for example quirks being set from within the preview.
|
1226
|
+
*/
|
1227
|
+
__UNIFORM_CONTEXTUAL_EDITING_CONTEXT__?: Context;
|
1216
1228
|
}
|
1217
1229
|
}
|
1218
1230
|
|
@@ -282,6 +282,11 @@ type VisitorDataStoreOptions = {
|
|
282
282
|
onServerTransitionReceived?: (state: ServerToClientTransitionState) => void;
|
283
283
|
/** Called when a log message is emitted from the data store */
|
284
284
|
onLogMessage?: (message: LogMessage) => void;
|
285
|
+
/**
|
286
|
+
* Optionally specify a prefix for all storage keys.
|
287
|
+
* Only required if using multiple Context instances on the same domain and need to separate them.
|
288
|
+
*/
|
289
|
+
partitionKey?: string;
|
285
290
|
};
|
286
291
|
type VisitorDataStoreEvents = {
|
287
292
|
/**
|
@@ -314,6 +319,8 @@ type VisitorDataStoreEvents = {
|
|
314
319
|
goalConverted: {
|
315
320
|
goalId: string;
|
316
321
|
};
|
322
|
+
/** Fired when storage update commands are done executing */
|
323
|
+
commandsExecuted: StorageCommands[];
|
317
324
|
};
|
318
325
|
declare class VisitorDataStore {
|
319
326
|
#private;
|
@@ -1213,6 +1220,11 @@ declare global {
|
|
1213
1220
|
interface Window {
|
1214
1221
|
/** Window var set by enableContextDevTools() to enable embedded devtools to receive Context instance and attach events to it. */
|
1215
1222
|
__UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__?: Context;
|
1223
|
+
/**
|
1224
|
+
* Window var set automatically that Uniform's contextual editing uses to respond to changes in the Context within its preview pane,
|
1225
|
+
* for example quirks being set from within the preview.
|
1226
|
+
*/
|
1227
|
+
__UNIFORM_CONTEXTUAL_EDITING_CONTEXT__?: Context;
|
1216
1228
|
}
|
1217
1229
|
}
|
1218
1230
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/context",
|
3
|
-
"version": "19.
|
3
|
+
"version": "19.170.1-alpha.0+e3f11f9551",
|
4
4
|
"description": "Uniform Context core package",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -68,5 +68,5 @@
|
|
68
68
|
"publishConfig": {
|
69
69
|
"access": "public"
|
70
70
|
},
|
71
|
-
"gitHead": "
|
71
|
+
"gitHead": "e3f11f95516524a58965ae891f4843a559b9cfbb"
|
72
72
|
}
|