@uniformdev/context 20.22.1-alpha.0 → 20.23.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/index.d.mts +3 -9
- package/dist/index.d.ts +3 -9
- package/dist/index.esm.js +7 -18
- package/dist/index.js +7 -18
- package/dist/index.mjs +7 -18
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
@@ -56,12 +56,6 @@ type CookieTransitionDataStoreOptions = {
|
|
56
56
|
* local storage is the master copy. Defaults to SameSite=Lax.
|
57
57
|
*/
|
58
58
|
cookieAttributes?: Cookies.CookieAttributes;
|
59
|
-
/**
|
60
|
-
* Whether to omit dimensions with a score of zero from the transition store state.
|
61
|
-
* When enabled, dimensions with an explicit score of zero will not be included in the cookie.
|
62
|
-
* Defaults to false.
|
63
|
-
*/
|
64
|
-
omitZeroScores?: boolean;
|
65
59
|
};
|
66
60
|
declare const UNIFORM_DEFAULT_COOKIE_NAME = "ufvd";
|
67
61
|
declare const UNIFORM_DEFAULT_QUIRK_COOKIE_NAME = "ufvdqk";
|
@@ -71,7 +65,7 @@ declare const UNIFORM_DEFAULT_QUIRK_COOKIE_NAME = "ufvdqk";
|
|
71
65
|
*/
|
72
66
|
declare class CookieTransitionDataStore extends TransitionDataStore {
|
73
67
|
#private;
|
74
|
-
constructor({ serverCookieValue, experimental_quirksEnabled, quirkCookieValue, quirkCookieName, cookieName, cookieAttributes,
|
68
|
+
constructor({ serverCookieValue, experimental_quirksEnabled, quirkCookieValue, quirkCookieName, cookieName, cookieAttributes, }: CookieTransitionDataStoreOptions);
|
75
69
|
handleDelete(): Promise<void>;
|
76
70
|
handleUpdateData(_: StorageCommands[], computedValue: VisitorData): Promise<void>;
|
77
71
|
}
|
@@ -84,10 +78,10 @@ declare function parseQuirkCookie(quirkCookieValue: string): Quirks;
|
|
84
78
|
declare function parseCookieScores(type: string | undefined): Record<string, string>;
|
85
79
|
declare function parseCookieType(type: string | undefined): Record<string, string>;
|
86
80
|
declare function decodeCookieType(type: Record<string, string>): Record<string, number>;
|
87
|
-
declare function serializeCookie(data: VisitorData
|
81
|
+
declare function serializeCookie(data: VisitorData): string;
|
88
82
|
declare function serializePersonalizeVariants({ personalizeVariants, }: Pick<VisitorData, 'personalizeVariants'>): string;
|
89
83
|
declare function decodePersonalizeVariants(data: string | undefined): VisitorData['personalizeVariants'];
|
90
|
-
declare function encodeCookieType(type: Record<string, number
|
84
|
+
declare function encodeCookieType(type: Record<string, number>): Record<string, string>;
|
91
85
|
declare function serializeCookieType(type: Record<string, string>): string;
|
92
86
|
declare function serializeQuirks(quirks: Quirks): string;
|
93
87
|
|
package/dist/index.d.ts
CHANGED
@@ -56,12 +56,6 @@ type CookieTransitionDataStoreOptions = {
|
|
56
56
|
* local storage is the master copy. Defaults to SameSite=Lax.
|
57
57
|
*/
|
58
58
|
cookieAttributes?: Cookies.CookieAttributes;
|
59
|
-
/**
|
60
|
-
* Whether to omit dimensions with a score of zero from the transition store state.
|
61
|
-
* When enabled, dimensions with an explicit score of zero will not be included in the cookie.
|
62
|
-
* Defaults to false.
|
63
|
-
*/
|
64
|
-
omitZeroScores?: boolean;
|
65
59
|
};
|
66
60
|
declare const UNIFORM_DEFAULT_COOKIE_NAME = "ufvd";
|
67
61
|
declare const UNIFORM_DEFAULT_QUIRK_COOKIE_NAME = "ufvdqk";
|
@@ -71,7 +65,7 @@ declare const UNIFORM_DEFAULT_QUIRK_COOKIE_NAME = "ufvdqk";
|
|
71
65
|
*/
|
72
66
|
declare class CookieTransitionDataStore extends TransitionDataStore {
|
73
67
|
#private;
|
74
|
-
constructor({ serverCookieValue, experimental_quirksEnabled, quirkCookieValue, quirkCookieName, cookieName, cookieAttributes,
|
68
|
+
constructor({ serverCookieValue, experimental_quirksEnabled, quirkCookieValue, quirkCookieName, cookieName, cookieAttributes, }: CookieTransitionDataStoreOptions);
|
75
69
|
handleDelete(): Promise<void>;
|
76
70
|
handleUpdateData(_: StorageCommands[], computedValue: VisitorData): Promise<void>;
|
77
71
|
}
|
@@ -84,10 +78,10 @@ declare function parseQuirkCookie(quirkCookieValue: string): Quirks;
|
|
84
78
|
declare function parseCookieScores(type: string | undefined): Record<string, string>;
|
85
79
|
declare function parseCookieType(type: string | undefined): Record<string, string>;
|
86
80
|
declare function decodeCookieType(type: Record<string, string>): Record<string, number>;
|
87
|
-
declare function serializeCookie(data: VisitorData
|
81
|
+
declare function serializeCookie(data: VisitorData): string;
|
88
82
|
declare function serializePersonalizeVariants({ personalizeVariants, }: Pick<VisitorData, 'personalizeVariants'>): string;
|
89
83
|
declare function decodePersonalizeVariants(data: string | undefined): VisitorData['personalizeVariants'];
|
90
|
-
declare function encodeCookieType(type: Record<string, number
|
84
|
+
declare function encodeCookieType(type: Record<string, number>): Record<string, string>;
|
91
85
|
declare function serializeCookieType(type: Record<string, string>): string;
|
92
86
|
declare function serializeQuirks(quirks: Quirks): string;
|
93
87
|
|
package/dist/index.esm.js
CHANGED
@@ -1072,7 +1072,7 @@ var bton = (base64) => {
|
|
1072
1072
|
var ssr = typeof document === "undefined";
|
1073
1073
|
var UNIFORM_DEFAULT_COOKIE_NAME = "ufvd";
|
1074
1074
|
var UNIFORM_DEFAULT_QUIRK_COOKIE_NAME = `ufvdqk`;
|
1075
|
-
var _cookieName, _quirkCookieName, _cookieAttributes, _quirksEnabled
|
1075
|
+
var _cookieName, _quirkCookieName, _cookieAttributes, _quirksEnabled;
|
1076
1076
|
var CookieTransitionDataStore = class extends TransitionDataStore {
|
1077
1077
|
constructor({
|
1078
1078
|
serverCookieValue,
|
@@ -1080,8 +1080,7 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
|
|
1080
1080
|
quirkCookieValue,
|
1081
1081
|
quirkCookieName = UNIFORM_DEFAULT_QUIRK_COOKIE_NAME,
|
1082
1082
|
cookieName = UNIFORM_DEFAULT_COOKIE_NAME,
|
1083
|
-
cookieAttributes = { sameSite: "lax" }
|
1084
|
-
omitZeroScores = false
|
1083
|
+
cookieAttributes = { sameSite: "lax" }
|
1085
1084
|
}) {
|
1086
1085
|
super({
|
1087
1086
|
initialData: ssr ? parseScoreCookie(serverCookieValue, experimental_quirksEnabled ? quirkCookieValue : void 0) : void 0
|
@@ -1090,12 +1089,10 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
|
|
1090
1089
|
__privateAdd(this, _quirkCookieName);
|
1091
1090
|
__privateAdd(this, _cookieAttributes);
|
1092
1091
|
__privateAdd(this, _quirksEnabled);
|
1093
|
-
__privateAdd(this, _omitZeroScores);
|
1094
1092
|
__privateSet(this, _cookieName, cookieName);
|
1095
1093
|
__privateSet(this, _cookieAttributes, cookieAttributes);
|
1096
1094
|
__privateSet(this, _quirkCookieName, quirkCookieName);
|
1097
1095
|
__privateSet(this, _quirksEnabled, experimental_quirksEnabled || false);
|
1098
|
-
__privateSet(this, _omitZeroScores, omitZeroScores);
|
1099
1096
|
}
|
1100
1097
|
handleDelete() {
|
1101
1098
|
if (ssr) return Promise.resolve();
|
@@ -1105,11 +1102,7 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
|
|
1105
1102
|
async handleUpdateData(_, computedValue) {
|
1106
1103
|
if (ssr) return;
|
1107
1104
|
if (computedValue.consent) {
|
1108
|
-
Cookies.set(
|
1109
|
-
__privateGet(this, _cookieName),
|
1110
|
-
serializeCookie(computedValue, __privateGet(this, _omitZeroScores)),
|
1111
|
-
__privateGet(this, _cookieAttributes)
|
1112
|
-
);
|
1105
|
+
Cookies.set(__privateGet(this, _cookieName), serializeCookie(computedValue), __privateGet(this, _cookieAttributes));
|
1113
1106
|
if (__privateGet(this, _quirksEnabled) && Object.keys(computedValue.quirks || {}).length) {
|
1114
1107
|
const quirkCookieValue = serializeQuirks(computedValue.quirks || {});
|
1115
1108
|
Cookies.set(__privateGet(this, _quirkCookieName), quirkCookieValue, __privateGet(this, _cookieAttributes));
|
@@ -1126,7 +1119,6 @@ _cookieName = new WeakMap();
|
|
1126
1119
|
_quirkCookieName = new WeakMap();
|
1127
1120
|
_cookieAttributes = new WeakMap();
|
1128
1121
|
_quirksEnabled = new WeakMap();
|
1129
|
-
_omitZeroScores = new WeakMap();
|
1130
1122
|
var TYPE_SEP = "~";
|
1131
1123
|
var PAIR_SEP = "!";
|
1132
1124
|
var KV_SEP = "-";
|
@@ -1198,11 +1190,11 @@ function decodeCookieType(type) {
|
|
1198
1190
|
return acc;
|
1199
1191
|
}, {});
|
1200
1192
|
}
|
1201
|
-
function serializeCookie(data
|
1193
|
+
function serializeCookie(data) {
|
1202
1194
|
return [
|
1203
1195
|
serializeCookieType(data.tests),
|
1204
|
-
serializeCookieType(encodeCookieType(data.sessionScores
|
1205
|
-
serializeCookieType(encodeCookieType(data.scores
|
1196
|
+
serializeCookieType(encodeCookieType(data.sessionScores)),
|
1197
|
+
serializeCookieType(encodeCookieType(data.scores)),
|
1206
1198
|
data.controlGroup ? "1" : "0",
|
1207
1199
|
serializePersonalizeVariants(data)
|
1208
1200
|
].join(TYPE_SEP);
|
@@ -1244,11 +1236,8 @@ function decodePersonalizeVariants(data) {
|
|
1244
1236
|
});
|
1245
1237
|
return results;
|
1246
1238
|
}
|
1247
|
-
function encodeCookieType(type
|
1239
|
+
function encodeCookieType(type) {
|
1248
1240
|
return Object.entries(type).reduce((acc, [key, value]) => {
|
1249
|
-
if (omitZeroScores && value === 0) {
|
1250
|
-
return acc;
|
1251
|
-
}
|
1252
1241
|
acc[key] = ntob(value);
|
1253
1242
|
return acc;
|
1254
1243
|
}, {});
|
package/dist/index.js
CHANGED
@@ -1165,7 +1165,7 @@ var bton = (base64) => {
|
|
1165
1165
|
var ssr = typeof document === "undefined";
|
1166
1166
|
var UNIFORM_DEFAULT_COOKIE_NAME = "ufvd";
|
1167
1167
|
var UNIFORM_DEFAULT_QUIRK_COOKIE_NAME = `ufvdqk`;
|
1168
|
-
var _cookieName, _quirkCookieName, _cookieAttributes, _quirksEnabled
|
1168
|
+
var _cookieName, _quirkCookieName, _cookieAttributes, _quirksEnabled;
|
1169
1169
|
var CookieTransitionDataStore = class extends TransitionDataStore {
|
1170
1170
|
constructor({
|
1171
1171
|
serverCookieValue,
|
@@ -1173,8 +1173,7 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
|
|
1173
1173
|
quirkCookieValue,
|
1174
1174
|
quirkCookieName = UNIFORM_DEFAULT_QUIRK_COOKIE_NAME,
|
1175
1175
|
cookieName = UNIFORM_DEFAULT_COOKIE_NAME,
|
1176
|
-
cookieAttributes = { sameSite: "lax" }
|
1177
|
-
omitZeroScores = false
|
1176
|
+
cookieAttributes = { sameSite: "lax" }
|
1178
1177
|
}) {
|
1179
1178
|
super({
|
1180
1179
|
initialData: ssr ? parseScoreCookie(serverCookieValue, experimental_quirksEnabled ? quirkCookieValue : void 0) : void 0
|
@@ -1183,12 +1182,10 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
|
|
1183
1182
|
__privateAdd(this, _quirkCookieName);
|
1184
1183
|
__privateAdd(this, _cookieAttributes);
|
1185
1184
|
__privateAdd(this, _quirksEnabled);
|
1186
|
-
__privateAdd(this, _omitZeroScores);
|
1187
1185
|
__privateSet(this, _cookieName, cookieName);
|
1188
1186
|
__privateSet(this, _cookieAttributes, cookieAttributes);
|
1189
1187
|
__privateSet(this, _quirkCookieName, quirkCookieName);
|
1190
1188
|
__privateSet(this, _quirksEnabled, experimental_quirksEnabled || false);
|
1191
|
-
__privateSet(this, _omitZeroScores, omitZeroScores);
|
1192
1189
|
}
|
1193
1190
|
handleDelete() {
|
1194
1191
|
if (ssr) return Promise.resolve();
|
@@ -1198,11 +1195,7 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
|
|
1198
1195
|
async handleUpdateData(_, computedValue) {
|
1199
1196
|
if (ssr) return;
|
1200
1197
|
if (computedValue.consent) {
|
1201
|
-
import_js_cookie.default.set(
|
1202
|
-
__privateGet(this, _cookieName),
|
1203
|
-
serializeCookie(computedValue, __privateGet(this, _omitZeroScores)),
|
1204
|
-
__privateGet(this, _cookieAttributes)
|
1205
|
-
);
|
1198
|
+
import_js_cookie.default.set(__privateGet(this, _cookieName), serializeCookie(computedValue), __privateGet(this, _cookieAttributes));
|
1206
1199
|
if (__privateGet(this, _quirksEnabled) && Object.keys(computedValue.quirks || {}).length) {
|
1207
1200
|
const quirkCookieValue = serializeQuirks(computedValue.quirks || {});
|
1208
1201
|
import_js_cookie.default.set(__privateGet(this, _quirkCookieName), quirkCookieValue, __privateGet(this, _cookieAttributes));
|
@@ -1219,7 +1212,6 @@ _cookieName = new WeakMap();
|
|
1219
1212
|
_quirkCookieName = new WeakMap();
|
1220
1213
|
_cookieAttributes = new WeakMap();
|
1221
1214
|
_quirksEnabled = new WeakMap();
|
1222
|
-
_omitZeroScores = new WeakMap();
|
1223
1215
|
var TYPE_SEP = "~";
|
1224
1216
|
var PAIR_SEP = "!";
|
1225
1217
|
var KV_SEP = "-";
|
@@ -1291,11 +1283,11 @@ function decodeCookieType(type) {
|
|
1291
1283
|
return acc;
|
1292
1284
|
}, {});
|
1293
1285
|
}
|
1294
|
-
function serializeCookie(data
|
1286
|
+
function serializeCookie(data) {
|
1295
1287
|
return [
|
1296
1288
|
serializeCookieType(data.tests),
|
1297
|
-
serializeCookieType(encodeCookieType(data.sessionScores
|
1298
|
-
serializeCookieType(encodeCookieType(data.scores
|
1289
|
+
serializeCookieType(encodeCookieType(data.sessionScores)),
|
1290
|
+
serializeCookieType(encodeCookieType(data.scores)),
|
1299
1291
|
data.controlGroup ? "1" : "0",
|
1300
1292
|
serializePersonalizeVariants(data)
|
1301
1293
|
].join(TYPE_SEP);
|
@@ -1337,11 +1329,8 @@ function decodePersonalizeVariants(data) {
|
|
1337
1329
|
});
|
1338
1330
|
return results;
|
1339
1331
|
}
|
1340
|
-
function encodeCookieType(type
|
1332
|
+
function encodeCookieType(type) {
|
1341
1333
|
return Object.entries(type).reduce((acc, [key, value]) => {
|
1342
|
-
if (omitZeroScores && value === 0) {
|
1343
|
-
return acc;
|
1344
|
-
}
|
1345
1334
|
acc[key] = ntob(value);
|
1346
1335
|
return acc;
|
1347
1336
|
}, {});
|
package/dist/index.mjs
CHANGED
@@ -1072,7 +1072,7 @@ var bton = (base64) => {
|
|
1072
1072
|
var ssr = typeof document === "undefined";
|
1073
1073
|
var UNIFORM_DEFAULT_COOKIE_NAME = "ufvd";
|
1074
1074
|
var UNIFORM_DEFAULT_QUIRK_COOKIE_NAME = `ufvdqk`;
|
1075
|
-
var _cookieName, _quirkCookieName, _cookieAttributes, _quirksEnabled
|
1075
|
+
var _cookieName, _quirkCookieName, _cookieAttributes, _quirksEnabled;
|
1076
1076
|
var CookieTransitionDataStore = class extends TransitionDataStore {
|
1077
1077
|
constructor({
|
1078
1078
|
serverCookieValue,
|
@@ -1080,8 +1080,7 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
|
|
1080
1080
|
quirkCookieValue,
|
1081
1081
|
quirkCookieName = UNIFORM_DEFAULT_QUIRK_COOKIE_NAME,
|
1082
1082
|
cookieName = UNIFORM_DEFAULT_COOKIE_NAME,
|
1083
|
-
cookieAttributes = { sameSite: "lax" }
|
1084
|
-
omitZeroScores = false
|
1083
|
+
cookieAttributes = { sameSite: "lax" }
|
1085
1084
|
}) {
|
1086
1085
|
super({
|
1087
1086
|
initialData: ssr ? parseScoreCookie(serverCookieValue, experimental_quirksEnabled ? quirkCookieValue : void 0) : void 0
|
@@ -1090,12 +1089,10 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
|
|
1090
1089
|
__privateAdd(this, _quirkCookieName);
|
1091
1090
|
__privateAdd(this, _cookieAttributes);
|
1092
1091
|
__privateAdd(this, _quirksEnabled);
|
1093
|
-
__privateAdd(this, _omitZeroScores);
|
1094
1092
|
__privateSet(this, _cookieName, cookieName);
|
1095
1093
|
__privateSet(this, _cookieAttributes, cookieAttributes);
|
1096
1094
|
__privateSet(this, _quirkCookieName, quirkCookieName);
|
1097
1095
|
__privateSet(this, _quirksEnabled, experimental_quirksEnabled || false);
|
1098
|
-
__privateSet(this, _omitZeroScores, omitZeroScores);
|
1099
1096
|
}
|
1100
1097
|
handleDelete() {
|
1101
1098
|
if (ssr) return Promise.resolve();
|
@@ -1105,11 +1102,7 @@ var CookieTransitionDataStore = class extends TransitionDataStore {
|
|
1105
1102
|
async handleUpdateData(_, computedValue) {
|
1106
1103
|
if (ssr) return;
|
1107
1104
|
if (computedValue.consent) {
|
1108
|
-
Cookies.set(
|
1109
|
-
__privateGet(this, _cookieName),
|
1110
|
-
serializeCookie(computedValue, __privateGet(this, _omitZeroScores)),
|
1111
|
-
__privateGet(this, _cookieAttributes)
|
1112
|
-
);
|
1105
|
+
Cookies.set(__privateGet(this, _cookieName), serializeCookie(computedValue), __privateGet(this, _cookieAttributes));
|
1113
1106
|
if (__privateGet(this, _quirksEnabled) && Object.keys(computedValue.quirks || {}).length) {
|
1114
1107
|
const quirkCookieValue = serializeQuirks(computedValue.quirks || {});
|
1115
1108
|
Cookies.set(__privateGet(this, _quirkCookieName), quirkCookieValue, __privateGet(this, _cookieAttributes));
|
@@ -1126,7 +1119,6 @@ _cookieName = new WeakMap();
|
|
1126
1119
|
_quirkCookieName = new WeakMap();
|
1127
1120
|
_cookieAttributes = new WeakMap();
|
1128
1121
|
_quirksEnabled = new WeakMap();
|
1129
|
-
_omitZeroScores = new WeakMap();
|
1130
1122
|
var TYPE_SEP = "~";
|
1131
1123
|
var PAIR_SEP = "!";
|
1132
1124
|
var KV_SEP = "-";
|
@@ -1198,11 +1190,11 @@ function decodeCookieType(type) {
|
|
1198
1190
|
return acc;
|
1199
1191
|
}, {});
|
1200
1192
|
}
|
1201
|
-
function serializeCookie(data
|
1193
|
+
function serializeCookie(data) {
|
1202
1194
|
return [
|
1203
1195
|
serializeCookieType(data.tests),
|
1204
|
-
serializeCookieType(encodeCookieType(data.sessionScores
|
1205
|
-
serializeCookieType(encodeCookieType(data.scores
|
1196
|
+
serializeCookieType(encodeCookieType(data.sessionScores)),
|
1197
|
+
serializeCookieType(encodeCookieType(data.scores)),
|
1206
1198
|
data.controlGroup ? "1" : "0",
|
1207
1199
|
serializePersonalizeVariants(data)
|
1208
1200
|
].join(TYPE_SEP);
|
@@ -1244,11 +1236,8 @@ function decodePersonalizeVariants(data) {
|
|
1244
1236
|
});
|
1245
1237
|
return results;
|
1246
1238
|
}
|
1247
|
-
function encodeCookieType(type
|
1239
|
+
function encodeCookieType(type) {
|
1248
1240
|
return Object.entries(type).reduce((acc, [key, value]) => {
|
1249
|
-
if (omitZeroScores && value === 0) {
|
1250
|
-
return acc;
|
1251
|
-
}
|
1252
1241
|
acc[key] = ntob(value);
|
1253
1242
|
return acc;
|
1254
1243
|
}, {});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/context",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.23.0",
|
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": "cc8a0ba91f036c7dea8d3a2dffad3373dec9cf2b"
|
72
72
|
}
|