@uniformdev/context 20.49.1 → 20.49.3-alpha.47
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 +33 -31
- package/dist/api/api.d.ts +33 -31
- package/dist/api/api.js +48 -11
- package/dist/api/api.mjs +44 -10
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.esm.js +17 -3
- package/dist/index.js +20 -6
- package/dist/index.mjs +17 -3
- package/dist/{types-HcKr1VVF.d.mts → types-C0Mthca3.d.mts} +453 -457
- package/dist/{types-HcKr1VVF.d.ts → types-C0Mthca3.d.ts} +453 -457
- package/package.json +9 -9
- package/dist/types-CKTfVAJs.d.mts +0 -1399
- package/dist/types-CKTfVAJs.d.ts +0 -1399
package/dist/api/api.mjs
CHANGED
|
@@ -12,21 +12,28 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
12
12
|
import pLimit from "p-limit";
|
|
13
13
|
var nullLimitPolicy = async (func) => await func();
|
|
14
14
|
var defaultLimitPolicy = pLimit(6);
|
|
15
|
+
var UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE = "Bearer token not valid or expired";
|
|
15
16
|
var ApiClientError = class _ApiClientError extends Error {
|
|
16
17
|
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
17
18
|
super(
|
|
18
19
|
`${errorMessage}
|
|
19
20
|
${statusCode}${statusText ? " " + statusText : ""} (${fetchMethod} ${fetchUri}${requestId ? ` Request ID: ${requestId}` : ""})`
|
|
20
21
|
);
|
|
21
|
-
this
|
|
22
|
-
this
|
|
23
|
-
this
|
|
24
|
-
this
|
|
25
|
-
this
|
|
26
|
-
this
|
|
22
|
+
__publicField(this, "errorMessage", errorMessage);
|
|
23
|
+
__publicField(this, "fetchMethod", fetchMethod);
|
|
24
|
+
__publicField(this, "fetchUri", fetchUri);
|
|
25
|
+
__publicField(this, "statusCode", statusCode);
|
|
26
|
+
__publicField(this, "statusText", statusText);
|
|
27
|
+
__publicField(this, "requestId", requestId);
|
|
27
28
|
Object.setPrototypeOf(this, _ApiClientError.prototype);
|
|
28
29
|
}
|
|
29
30
|
};
|
|
31
|
+
var BearerTokenNotValidOrExpiredError = class _BearerTokenNotValidOrExpiredError extends ApiClientError {
|
|
32
|
+
constructor(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId) {
|
|
33
|
+
super(errorMessage, fetchMethod, fetchUri, statusCode, statusText, requestId);
|
|
34
|
+
Object.setPrototypeOf(this, _BearerTokenNotValidOrExpiredError.prototype);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
30
37
|
|
|
31
38
|
// src/api/ApiClient.ts
|
|
32
39
|
var ApiClient = class _ApiClient {
|
|
@@ -62,7 +69,7 @@ var ApiClient = class _ApiClient {
|
|
|
62
69
|
}
|
|
63
70
|
async apiClientWithResponse(fetchUri, options) {
|
|
64
71
|
return this.options.limitPolicy(async () => {
|
|
65
|
-
var _a;
|
|
72
|
+
var _a, _b;
|
|
66
73
|
const coreHeaders = this.options.apiKey ? {
|
|
67
74
|
"x-api-key": this.options.apiKey
|
|
68
75
|
} : {
|
|
@@ -98,9 +105,19 @@ var ApiClient = class _ApiClient {
|
|
|
98
105
|
} catch (e) {
|
|
99
106
|
message = `General error`;
|
|
100
107
|
}
|
|
108
|
+
if (apiResponse.status === 401 && message === UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE) {
|
|
109
|
+
throw new BearerTokenNotValidOrExpiredError(
|
|
110
|
+
message,
|
|
111
|
+
(_a = options == null ? void 0 : options.method) != null ? _a : "GET",
|
|
112
|
+
fetchUri.toString(),
|
|
113
|
+
apiResponse.status,
|
|
114
|
+
apiResponse.statusText,
|
|
115
|
+
_ApiClient.getRequestId(apiResponse)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
101
118
|
throw new ApiClientError(
|
|
102
119
|
message,
|
|
103
|
-
(
|
|
120
|
+
(_b = options == null ? void 0 : options.method) != null ? _b : "GET",
|
|
104
121
|
fetchUri.toString(),
|
|
105
122
|
apiResponse.status,
|
|
106
123
|
apiResponse.statusText,
|
|
@@ -174,11 +191,25 @@ async function handleRateLimits(callApi) {
|
|
|
174
191
|
}
|
|
175
192
|
const base = Math.pow(2, backoffRetries - backoffRetriesLeft) * 333;
|
|
176
193
|
const backoffWait = base + Math.round(Math.random() * (base / 2)) * (Math.random() > 0.5 ? 1 : -1);
|
|
177
|
-
await new Promise((resolve) => setTimeout(resolve, resetWait + backoffWait));
|
|
194
|
+
await new Promise((resolve) => setTimeout(resolve, Math.max(0, resetWait + backoffWait)));
|
|
178
195
|
backoffRetriesLeft -= 1;
|
|
179
196
|
}
|
|
180
197
|
return response;
|
|
181
198
|
}
|
|
199
|
+
var isPlainObject = (obj) => typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
200
|
+
function rewriteFiltersForApi(filters) {
|
|
201
|
+
return Object.entries(filters != null ? filters : {}).reduce(
|
|
202
|
+
(acc, [key, value]) => {
|
|
203
|
+
const lhs = `filters.${key}` + (isPlainObject(value) ? `[${Object.keys(value)[0]}]` : "");
|
|
204
|
+
const rhs = isPlainObject(value) ? Object.values(value)[0] : value;
|
|
205
|
+
return {
|
|
206
|
+
...acc,
|
|
207
|
+
[lhs]: Array.isArray(rhs) ? rhs.map((v) => `${v}`.trim()).join(",") : `${rhs}`.trim()
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
{}
|
|
211
|
+
);
|
|
212
|
+
}
|
|
182
213
|
|
|
183
214
|
// src/api/AggregateClient.ts
|
|
184
215
|
var _url;
|
|
@@ -556,6 +587,7 @@ export {
|
|
|
556
587
|
AggregateClient,
|
|
557
588
|
ApiClient,
|
|
558
589
|
ApiClientError,
|
|
590
|
+
BearerTokenNotValidOrExpiredError,
|
|
559
591
|
CachedAggregateClient,
|
|
560
592
|
CachedContextClient,
|
|
561
593
|
CachedDimensionClient,
|
|
@@ -571,6 +603,7 @@ export {
|
|
|
571
603
|
QuirkClient,
|
|
572
604
|
SignalClient,
|
|
573
605
|
TestClient,
|
|
606
|
+
UNIFORM_BEARER_TOKEN_NOT_VALID_OR_EXPIRED_MESSAGE,
|
|
574
607
|
UncachedAggregateClient,
|
|
575
608
|
UncachedContextClient,
|
|
576
609
|
UncachedDimensionClient,
|
|
@@ -584,5 +617,6 @@ export {
|
|
|
584
617
|
computeDimensionDisplayName,
|
|
585
618
|
defaultLimitPolicy,
|
|
586
619
|
handleRateLimits,
|
|
587
|
-
nullLimitPolicy
|
|
620
|
+
nullLimitPolicy,
|
|
621
|
+
rewriteFiltersForApi
|
|
588
622
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +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, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, P as PersonalizedVariant, g as PersonalizeOptions, h as Context, i as PersonalizedResult, j as VariationMatchDimensionCriteria, k as PersonalizationSelectionAlgorithmOptions, l as DevToolsEvents } from './types-
|
|
2
|
-
export {
|
|
3
|
-
import Cookies from 'js-cookie';
|
|
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, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, P as PersonalizedVariant, g as PersonalizeOptions, h as Context, i as PersonalizedResult, j as VariationMatchDimensionCriteria, k as PersonalizationSelectionAlgorithmOptions, l as DevToolsEvents } from './types-C0Mthca3.mjs';
|
|
2
|
+
export { m as AggregateDimensionInput, B as BehaviorTag, n as CONTEXTUAL_EDITING_TEST_NAME, o as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, q as CompositionMetadata, r as ContextEvents, s as ContextInstance, t as ContextOptions, u as ContextState, v as ContextStateUpdate, w as CriteriaEvaluatorParameters, x as CriteriaEvaluatorResult, y as DecayOptions, z as DevToolsActions, E as DevToolsDataEvent, F as DevToolsEvent, G as DevToolsForgetEvent, H as DevToolsHelloEvent, I as DevToolsLogEvent, J as DevToolsRawCommandsEvent, K as DevToolsState, N as DevToolsUiVersion, R as DevToolsUpdateEvent, U as DimensionMatch, W as EnrichmentCategory, X as EnrichmentData, Y as EventData, Z as GoalStateUpdate, _ as Goals, $ as GroupCriteriaEvaluator, a0 as IdentifyCommand, a1 as LogMessageGroup, a2 as LogMessageSingle, a3 as LogMessages, a4 as ManifestInstance, M as ManifestV2, a5 as MessageCategory, a6 as MessageFunc, a7 as ModifyScoreCommand, a8 as ModifySessionScoreCommand, a9 as NumberMatch, aa as PersonalizationEvent, ab as PersonalizationEventVariantId, ac as PersonalizationManifest, ad as PersonalizationSelectionAlgorithm, ae as PersonalizationSelectionAlgorithms, af as PersonalizeControlVariant, ag as PersonalizeVariants, ah as QuirkMatch, ai as SERVER_STATE_ID, aj as ServerToClientTransitionState, ak as SetConsentCommand, al as SetControlGroupCommand, am as SetGoalCommand, an as SetPersonalizeVariantControlCommand, ao as SetQuirkCommand, ap as SetTestCommand, aq as Severity, ar as Signal, as as SignalCriteria, at as SignalCriteriaGroup, au as SignalData, av as StorageCommand, aw as TestDefinition, ax as TestEvent, ay as TestOptions, az as TestResult, aA as TestVariant, aB as Tests, aC as TransitionDataStoreEvents, aD as VariationMatchMetadata, aE as VisitorDataStore, aF as VisitorDataStoreEvents, aG as VisitorDataStoreOptions, aH as areCommandsEqual, aI as emptyVisitorData, aJ as testVariations } from './types-C0Mthca3.mjs';
|
|
4
3
|
import 'mitt';
|
|
5
4
|
|
|
6
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +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, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, P as PersonalizedVariant, g as PersonalizeOptions, h as Context, i as PersonalizedResult, j as VariationMatchDimensionCriteria, k as PersonalizationSelectionAlgorithmOptions, l as DevToolsEvents } from './types-
|
|
2
|
-
export {
|
|
3
|
-
import Cookies from 'js-cookie';
|
|
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, Q as Quirks, b as TransitionDataStoreOptions, D as DecayFunction, c as CriteriaEvaluator, d as StringMatch, e as VariantMatchCriteria, f as LogMessage, P as PersonalizedVariant, g as PersonalizeOptions, h as Context, i as PersonalizedResult, j as VariationMatchDimensionCriteria, k as PersonalizationSelectionAlgorithmOptions, l as DevToolsEvents } from './types-C0Mthca3.js';
|
|
2
|
+
export { m as AggregateDimensionInput, B as BehaviorTag, n as CONTEXTUAL_EDITING_TEST_NAME, o as CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID, q as CompositionMetadata, r as ContextEvents, s as ContextInstance, t as ContextOptions, u as ContextState, v as ContextStateUpdate, w as CriteriaEvaluatorParameters, x as CriteriaEvaluatorResult, y as DecayOptions, z as DevToolsActions, E as DevToolsDataEvent, F as DevToolsEvent, G as DevToolsForgetEvent, H as DevToolsHelloEvent, I as DevToolsLogEvent, J as DevToolsRawCommandsEvent, K as DevToolsState, N as DevToolsUiVersion, R as DevToolsUpdateEvent, U as DimensionMatch, W as EnrichmentCategory, X as EnrichmentData, Y as EventData, Z as GoalStateUpdate, _ as Goals, $ as GroupCriteriaEvaluator, a0 as IdentifyCommand, a1 as LogMessageGroup, a2 as LogMessageSingle, a3 as LogMessages, a4 as ManifestInstance, M as ManifestV2, a5 as MessageCategory, a6 as MessageFunc, a7 as ModifyScoreCommand, a8 as ModifySessionScoreCommand, a9 as NumberMatch, aa as PersonalizationEvent, ab as PersonalizationEventVariantId, ac as PersonalizationManifest, ad as PersonalizationSelectionAlgorithm, ae as PersonalizationSelectionAlgorithms, af as PersonalizeControlVariant, ag as PersonalizeVariants, ah as QuirkMatch, ai as SERVER_STATE_ID, aj as ServerToClientTransitionState, ak as SetConsentCommand, al as SetControlGroupCommand, am as SetGoalCommand, an as SetPersonalizeVariantControlCommand, ao as SetQuirkCommand, ap as SetTestCommand, aq as Severity, ar as Signal, as as SignalCriteria, at as SignalCriteriaGroup, au as SignalData, av as StorageCommand, aw as TestDefinition, ax as TestEvent, ay as TestOptions, az as TestResult, aA as TestVariant, aB as Tests, aC as TransitionDataStoreEvents, aD as VariationMatchMetadata, aE as VisitorDataStore, aF as VisitorDataStoreEvents, aG as VisitorDataStoreOptions, aH as areCommandsEqual, aI as emptyVisitorData, aJ as testVariations } from './types-C0Mthca3.js';
|
|
4
3
|
import 'mitt';
|
|
5
4
|
|
|
6
5
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -143,7 +143,6 @@ var ManifestInstance = class {
|
|
|
143
143
|
constructor({
|
|
144
144
|
manifest,
|
|
145
145
|
evaluator = new GroupCriteriaEvaluator({}),
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
147
146
|
onLogMessage = () => {
|
|
148
147
|
}
|
|
149
148
|
}) {
|
|
@@ -1414,7 +1413,7 @@ function applyCommandsToData(commands, state) {
|
|
|
1414
1413
|
var _LocalStorage_instances, key_fn;
|
|
1415
1414
|
var LocalStorage = class {
|
|
1416
1415
|
constructor(partitionKey) {
|
|
1417
|
-
this
|
|
1416
|
+
__publicField(this, "partitionKey", partitionKey);
|
|
1418
1417
|
__privateAdd(this, _LocalStorage_instances);
|
|
1419
1418
|
__publicField(this, "inMemoryFallback", {});
|
|
1420
1419
|
// deno implements localStorage in netlify edge workers, must also check if document is present.
|
|
@@ -2183,10 +2182,20 @@ calculateScores_fn = function(newData) {
|
|
|
2183
2182
|
|
|
2184
2183
|
// src/devTools/enableContextDevTools.ts
|
|
2185
2184
|
var isBrowser = typeof top !== "undefined";
|
|
2185
|
+
function isInCrossOriginIframe() {
|
|
2186
|
+
if (!isBrowser) {
|
|
2187
|
+
return false;
|
|
2188
|
+
}
|
|
2189
|
+
try {
|
|
2190
|
+
return top !== window && !(top == null ? void 0 : top.location.href);
|
|
2191
|
+
} catch (e) {
|
|
2192
|
+
return true;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2186
2195
|
function enableContextDevTools(options) {
|
|
2187
2196
|
return {
|
|
2188
2197
|
logDrain: (message) => {
|
|
2189
|
-
if (!isBrowser) {
|
|
2198
|
+
if (!isBrowser || isInCrossOriginIframe()) {
|
|
2190
2199
|
return;
|
|
2191
2200
|
}
|
|
2192
2201
|
top == null ? void 0 : top.postMessage(
|
|
@@ -2198,6 +2207,11 @@ function enableContextDevTools(options) {
|
|
|
2198
2207
|
);
|
|
2199
2208
|
},
|
|
2200
2209
|
init: (context) => {
|
|
2210
|
+
if (isInCrossOriginIframe()) {
|
|
2211
|
+
console.info("Uniform Context DevTools disabled in cross-origin iframe");
|
|
2212
|
+
return () => {
|
|
2213
|
+
};
|
|
2214
|
+
}
|
|
2201
2215
|
const personalizations = [];
|
|
2202
2216
|
const tests = [];
|
|
2203
2217
|
const onContextDataUpdated = () => {
|
package/dist/index.js
CHANGED
|
@@ -38,8 +38,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
38
38
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
39
39
|
|
|
40
40
|
// src/index.ts
|
|
41
|
-
var
|
|
42
|
-
__export(
|
|
41
|
+
var index_exports = {};
|
|
42
|
+
__export(index_exports, {
|
|
43
43
|
CONTEXTUAL_EDITING_TEST_NAME: () => CONTEXTUAL_EDITING_TEST_NAME,
|
|
44
44
|
CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID: () => CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID,
|
|
45
45
|
Context: () => Context,
|
|
@@ -101,7 +101,7 @@ __export(src_exports, {
|
|
|
101
101
|
testVariations: () => testVariations,
|
|
102
102
|
topDownCriteriaPersonalizationSelectionAlgorithm: () => topDownCriteriaPersonalizationSelectionAlgorithm
|
|
103
103
|
});
|
|
104
|
-
module.exports = __toCommonJS(
|
|
104
|
+
module.exports = __toCommonJS(index_exports);
|
|
105
105
|
|
|
106
106
|
// src/manifest/aggregates/computeAggregateDimensions.ts
|
|
107
107
|
function computeAggregateDimensions(primitiveScores, aggregates) {
|
|
@@ -236,7 +236,6 @@ var ManifestInstance = class {
|
|
|
236
236
|
constructor({
|
|
237
237
|
manifest,
|
|
238
238
|
evaluator = new GroupCriteriaEvaluator({}),
|
|
239
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
240
239
|
onLogMessage = () => {
|
|
241
240
|
}
|
|
242
241
|
}) {
|
|
@@ -1507,7 +1506,7 @@ function applyCommandsToData(commands, state) {
|
|
|
1507
1506
|
var _LocalStorage_instances, key_fn;
|
|
1508
1507
|
var LocalStorage = class {
|
|
1509
1508
|
constructor(partitionKey) {
|
|
1510
|
-
this
|
|
1509
|
+
__publicField(this, "partitionKey", partitionKey);
|
|
1511
1510
|
__privateAdd(this, _LocalStorage_instances);
|
|
1512
1511
|
__publicField(this, "inMemoryFallback", {});
|
|
1513
1512
|
// deno implements localStorage in netlify edge workers, must also check if document is present.
|
|
@@ -2276,10 +2275,20 @@ calculateScores_fn = function(newData) {
|
|
|
2276
2275
|
|
|
2277
2276
|
// src/devTools/enableContextDevTools.ts
|
|
2278
2277
|
var isBrowser = typeof top !== "undefined";
|
|
2278
|
+
function isInCrossOriginIframe() {
|
|
2279
|
+
if (!isBrowser) {
|
|
2280
|
+
return false;
|
|
2281
|
+
}
|
|
2282
|
+
try {
|
|
2283
|
+
return top !== window && !(top == null ? void 0 : top.location.href);
|
|
2284
|
+
} catch (e) {
|
|
2285
|
+
return true;
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2279
2288
|
function enableContextDevTools(options) {
|
|
2280
2289
|
return {
|
|
2281
2290
|
logDrain: (message) => {
|
|
2282
|
-
if (!isBrowser) {
|
|
2291
|
+
if (!isBrowser || isInCrossOriginIframe()) {
|
|
2283
2292
|
return;
|
|
2284
2293
|
}
|
|
2285
2294
|
top == null ? void 0 : top.postMessage(
|
|
@@ -2291,6 +2300,11 @@ function enableContextDevTools(options) {
|
|
|
2291
2300
|
);
|
|
2292
2301
|
},
|
|
2293
2302
|
init: (context) => {
|
|
2303
|
+
if (isInCrossOriginIframe()) {
|
|
2304
|
+
console.info("Uniform Context DevTools disabled in cross-origin iframe");
|
|
2305
|
+
return () => {
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2294
2308
|
const personalizations = [];
|
|
2295
2309
|
const tests = [];
|
|
2296
2310
|
const onContextDataUpdated = () => {
|
package/dist/index.mjs
CHANGED
|
@@ -143,7 +143,6 @@ var ManifestInstance = class {
|
|
|
143
143
|
constructor({
|
|
144
144
|
manifest,
|
|
145
145
|
evaluator = new GroupCriteriaEvaluator({}),
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
147
146
|
onLogMessage = () => {
|
|
148
147
|
}
|
|
149
148
|
}) {
|
|
@@ -1414,7 +1413,7 @@ function applyCommandsToData(commands, state) {
|
|
|
1414
1413
|
var _LocalStorage_instances, key_fn;
|
|
1415
1414
|
var LocalStorage = class {
|
|
1416
1415
|
constructor(partitionKey) {
|
|
1417
|
-
this
|
|
1416
|
+
__publicField(this, "partitionKey", partitionKey);
|
|
1418
1417
|
__privateAdd(this, _LocalStorage_instances);
|
|
1419
1418
|
__publicField(this, "inMemoryFallback", {});
|
|
1420
1419
|
// deno implements localStorage in netlify edge workers, must also check if document is present.
|
|
@@ -2183,10 +2182,20 @@ calculateScores_fn = function(newData) {
|
|
|
2183
2182
|
|
|
2184
2183
|
// src/devTools/enableContextDevTools.ts
|
|
2185
2184
|
var isBrowser = typeof top !== "undefined";
|
|
2185
|
+
function isInCrossOriginIframe() {
|
|
2186
|
+
if (!isBrowser) {
|
|
2187
|
+
return false;
|
|
2188
|
+
}
|
|
2189
|
+
try {
|
|
2190
|
+
return top !== window && !(top == null ? void 0 : top.location.href);
|
|
2191
|
+
} catch (e) {
|
|
2192
|
+
return true;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2186
2195
|
function enableContextDevTools(options) {
|
|
2187
2196
|
return {
|
|
2188
2197
|
logDrain: (message) => {
|
|
2189
|
-
if (!isBrowser) {
|
|
2198
|
+
if (!isBrowser || isInCrossOriginIframe()) {
|
|
2190
2199
|
return;
|
|
2191
2200
|
}
|
|
2192
2201
|
top == null ? void 0 : top.postMessage(
|
|
@@ -2198,6 +2207,11 @@ function enableContextDevTools(options) {
|
|
|
2198
2207
|
);
|
|
2199
2208
|
},
|
|
2200
2209
|
init: (context) => {
|
|
2210
|
+
if (isInCrossOriginIframe()) {
|
|
2211
|
+
console.info("Uniform Context DevTools disabled in cross-origin iframe");
|
|
2212
|
+
return () => {
|
|
2213
|
+
};
|
|
2214
|
+
}
|
|
2201
2215
|
const personalizations = [];
|
|
2202
2216
|
const tests = [];
|
|
2203
2217
|
const onContextDataUpdated = () => {
|