@croct/sdk 0.17.9 → 0.17.11
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/activeRecord.cjs +135 -0
- package/apiKey.cjs +178 -0
- package/base64Url.cjs +41 -0
- package/cache/cache.cjs +34 -0
- package/cache/cookieCache.cjs +85 -0
- package/cache/fallbackCache.cjs +47 -0
- package/cache/inMemoryCache.cjs +41 -0
- package/cache/index.cjs +37 -0
- package/cache/localStorageCache.cjs +81 -0
- package/channel/channel.cjs +48 -0
- package/channel/encodedChannel.cjs +39 -0
- package/channel/guaranteedChannel.cjs +105 -0
- package/channel/httpBeaconChannel.cjs +111 -0
- package/channel/index.cjs +46 -0
- package/channel/queuedChannel.cjs +122 -0
- package/channel/retryChannel.cjs +87 -0
- package/channel/sandboxChannel.cjs +63 -0
- package/cid/assigner.cjs +16 -0
- package/cid/cachedAssigner.cjs +66 -0
- package/cid/fixedAssigner.cjs +35 -0
- package/cid/index.cjs +37 -0
- package/cid/remoteAssigner.cjs +65 -0
- package/constants.cjs +37 -0
- package/constants.cjs.map +1 -1
- package/constants.d.ts +2 -2
- package/constants.js +1 -1
- package/constants.js.map +1 -1
- package/container.cjs +305 -0
- package/contentFetcher.cjs +193 -0
- package/context.cjs +114 -0
- package/error.cjs +52 -0
- package/evaluator.cjs +219 -0
- package/eventManager.cjs +53 -0
- package/eventSubjectProcessor.cjs +84 -0
- package/facade/contentFetcherFacade.cjs +61 -0
- package/facade/evaluatorFacade.cjs +94 -0
- package/facade/index.cjs +52 -0
- package/facade/sdkFacade.cjs +229 -0
- package/facade/sessionFacade.cjs +36 -0
- package/facade/sessionPatch.cjs +48 -0
- package/facade/trackerFacade.cjs +87 -0
- package/facade/userFacade.cjs +43 -0
- package/facade/userPatch.cjs +48 -0
- package/help.cjs +45 -0
- package/index.cjs +33 -0
- package/logging/consoleLogger.cjs +50 -0
- package/logging/filteredLogger.cjs +62 -0
- package/logging/index.cjs +40 -0
- package/logging/logger.cjs +16 -0
- package/logging/namespacedLogger.cjs +48 -0
- package/logging/nullLogger.cjs +37 -0
- package/namespacedStorage.cjs +77 -0
- package/package.json +7 -6
- package/patch.cjs +16 -0
- package/queue/capacityRestrictedQueue.cjs +57 -0
- package/queue/inMemoryQueue.cjs +58 -0
- package/queue/index.cjs +40 -0
- package/queue/monitoredQueue.cjs +141 -0
- package/queue/persistentQueue.cjs +78 -0
- package/queue/queue.cjs +16 -0
- package/retry/arbitraryPolicy.cjs +41 -0
- package/retry/backoffPolicy.cjs +81 -0
- package/retry/index.cjs +40 -0
- package/retry/maxAttemptsPolicy.cjs +45 -0
- package/retry/neverPolicy.cjs +35 -0
- package/retry/policy.cjs +16 -0
- package/schema/attributeSchema.cjs +32 -0
- package/schema/contentFetcherSchemas.cjs +49 -0
- package/schema/contentSchemas.cjs +70 -0
- package/schema/contextSchemas.cjs +31 -0
- package/schema/ecommerceSchemas.cjs +209 -0
- package/schema/evaluatorSchemas.cjs +64 -0
- package/schema/eventSchemas.cjs +162 -0
- package/schema/index.cjs +42 -0
- package/schema/loggerSchema.cjs +38 -0
- package/schema/operationSchemas.cjs +122 -0
- package/schema/sdkFacadeSchemas.cjs +82 -0
- package/schema/sdkSchemas.cjs +110 -0
- package/schema/tokenSchema.cjs +68 -0
- package/schema/userSchema.cjs +202 -0
- package/sdk.cjs +134 -0
- package/sdkEvents.cjs +16 -0
- package/sourceLocation.cjs +92 -0
- package/tab.cjs +122 -0
- package/token/cachedTokenStore.cjs +51 -0
- package/token/inMemoryTokenStore.cjs +38 -0
- package/token/index.cjs +37 -0
- package/token/replicatedTokenStore.cjs +40 -0
- package/token/token.cjs +239 -0
- package/tracker.cjs +358 -0
- package/trackingEvents.cjs +94 -0
- package/transformer.cjs +30 -0
- package/utilityTypes.cjs +16 -0
- package/uuid.cjs +55 -0
- package/validation/arrayType.cjs +75 -0
- package/validation/booleanType.cjs +46 -0
- package/validation/functionType.cjs +46 -0
- package/validation/index.cjs +66 -0
- package/validation/jsonType.cjs +142 -0
- package/validation/mixedSchema.cjs +31 -0
- package/validation/nullType.cjs +46 -0
- package/validation/numberType.cjs +69 -0
- package/validation/objectType.cjs +114 -0
- package/validation/schema.cjs +34 -0
- package/validation/stringType.cjs +106 -0
- package/validation/unionType.cjs +67 -0
- package/validation/violation.cjs +47 -0
- package/src/activeRecord.ts +0 -150
- package/src/apiKey.ts +0 -208
- package/src/base64Url.ts +0 -22
- package/src/cache/cache.ts +0 -22
- package/src/cache/cookieCache.ts +0 -88
- package/src/cache/fallbackCache.ts +0 -29
- package/src/cache/inMemoryCache.ts +0 -21
- package/src/cache/index.ts +0 -4
- package/src/cache/localStorageCache.ts +0 -85
- package/src/channel/channel.ts +0 -52
- package/src/channel/encodedChannel.ts +0 -21
- package/src/channel/guaranteedChannel.ts +0 -131
- package/src/channel/httpBeaconChannel.ts +0 -128
- package/src/channel/index.ts +0 -7
- package/src/channel/queuedChannel.ts +0 -143
- package/src/channel/retryChannel.ts +0 -94
- package/src/channel/sandboxChannel.ts +0 -47
- package/src/cid/assigner.ts +0 -3
- package/src/cid/cachedAssigner.ts +0 -68
- package/src/cid/fixedAssigner.ts +0 -13
- package/src/cid/index.ts +0 -4
- package/src/cid/remoteAssigner.ts +0 -57
- package/src/constants.ts +0 -4
- package/src/container.ts +0 -410
- package/src/contentFetcher.ts +0 -290
- package/src/context.ts +0 -139
- package/src/error.ts +0 -31
- package/src/evaluator.ts +0 -314
- package/src/eventManager.ts +0 -53
- package/src/eventSubjectProcessor.ts +0 -85
- package/src/facade/contentFetcherFacade.ts +0 -69
- package/src/facade/evaluatorFacade.ts +0 -111
- package/src/facade/index.ts +0 -7
- package/src/facade/sdkFacade.ts +0 -310
- package/src/facade/sessionFacade.ts +0 -14
- package/src/facade/sessionPatch.ts +0 -32
- package/src/facade/trackerFacade.ts +0 -98
- package/src/facade/userFacade.ts +0 -26
- package/src/facade/userPatch.ts +0 -32
- package/src/help.ts +0 -24
- package/src/index.ts +0 -4
- package/src/logging/consoleLogger.ts +0 -38
- package/src/logging/filteredLogger.ts +0 -57
- package/src/logging/index.ts +0 -5
- package/src/logging/logger.ts +0 -13
- package/src/logging/namespacedLogger.ts +0 -32
- package/src/logging/nullLogger.ts +0 -19
- package/src/namespacedStorage.ts +0 -69
- package/src/patch.ts +0 -64
- package/src/queue/capacityRestrictedQueue.ts +0 -44
- package/src/queue/inMemoryQueue.ts +0 -43
- package/src/queue/index.ts +0 -5
- package/src/queue/monitoredQueue.ts +0 -168
- package/src/queue/persistentQueue.ts +0 -73
- package/src/queue/queue.ts +0 -15
- package/src/retry/arbitraryPolicy.ts +0 -21
- package/src/retry/backoffPolicy.ts +0 -84
- package/src/retry/index.ts +0 -5
- package/src/retry/maxAttemptsPolicy.ts +0 -28
- package/src/retry/neverPolicy.ts +0 -11
- package/src/retry/policy.ts +0 -5
- package/src/schema/attributeSchema.ts +0 -6
- package/src/schema/contentFetcherSchemas.ts +0 -23
- package/src/schema/contentSchemas.ts +0 -44
- package/src/schema/contextSchemas.ts +0 -5
- package/src/schema/ecommerceSchemas.ts +0 -179
- package/src/schema/evaluatorSchemas.ts +0 -52
- package/src/schema/eventSchemas.ts +0 -134
- package/src/schema/index.ts +0 -11
- package/src/schema/loggerSchema.ts +0 -12
- package/src/schema/operationSchemas.ts +0 -102
- package/src/schema/sdkFacadeSchemas.ts +0 -64
- package/src/schema/sdkSchemas.ts +0 -82
- package/src/schema/tokenSchema.ts +0 -42
- package/src/schema/userSchema.ts +0 -184
- package/src/sdk.ts +0 -183
- package/src/sdkEvents.ts +0 -15
- package/src/sourceLocation.ts +0 -85
- package/src/tab.ts +0 -148
- package/src/token/cachedTokenStore.ts +0 -34
- package/src/token/inMemoryTokenStore.ts +0 -13
- package/src/token/index.ts +0 -4
- package/src/token/replicatedTokenStore.ts +0 -21
- package/src/token/token.ts +0 -301
- package/src/tracker.ts +0 -504
- package/src/trackingEvents.ts +0 -452
- package/src/transformer.ts +0 -7
- package/src/utilityTypes.ts +0 -3
- package/src/uuid.ts +0 -43
- package/src/validation/arrayType.ts +0 -71
- package/src/validation/booleanType.ts +0 -22
- package/src/validation/functionType.ts +0 -22
- package/src/validation/index.ts +0 -12
- package/src/validation/jsonType.ts +0 -156
- package/src/validation/mixedSchema.ts +0 -7
- package/src/validation/nullType.ts +0 -22
- package/src/validation/numberType.ts +0 -59
- package/src/validation/objectType.ts +0 -138
- package/src/validation/schema.ts +0 -21
- package/src/validation/stringType.ts +0 -118
- package/src/validation/unionType.ts +0 -53
- package/src/validation/violation.ts +0 -23
package/sdk.cjs
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var sdk_exports = {};
|
|
19
|
+
__export(sdk_exports, {
|
|
20
|
+
Sdk: () => Sdk
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(sdk_exports);
|
|
23
|
+
var import_container = require("./container");
|
|
24
|
+
var import_constants = require("./constants");
|
|
25
|
+
var import_schema = require("./schema");
|
|
26
|
+
var import_error = require("./error");
|
|
27
|
+
function validateConfiguration(configuration) {
|
|
28
|
+
if (typeof configuration !== "object" || configuration === null) {
|
|
29
|
+
throw new Error("The configuration must be a key-value map.");
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
import_schema.sdkConfigurationSchema.validate(configuration);
|
|
33
|
+
} catch (violation) {
|
|
34
|
+
throw new Error(`Invalid configuration: ${(0, import_error.formatCause)(violation)}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
class Sdk {
|
|
38
|
+
constructor(container) {
|
|
39
|
+
this.container = container;
|
|
40
|
+
}
|
|
41
|
+
static init(configuration) {
|
|
42
|
+
validateConfiguration(configuration);
|
|
43
|
+
const {
|
|
44
|
+
eventMetadata: customMetadata = {},
|
|
45
|
+
baseEndpointUrl = import_constants.BASE_ENDPOINT_URL,
|
|
46
|
+
cidAssignerEndpointUrl,
|
|
47
|
+
...containerConfiguration
|
|
48
|
+
} = configuration;
|
|
49
|
+
const eventMetadata = {
|
|
50
|
+
sdkVersion: import_constants.VERSION
|
|
51
|
+
};
|
|
52
|
+
for (const metadata of Object.keys(customMetadata)) {
|
|
53
|
+
eventMetadata[`custom_${metadata}`] = customMetadata[metadata];
|
|
54
|
+
}
|
|
55
|
+
const baseHttpEndpoint = baseEndpointUrl.replace(/\/+$/, "");
|
|
56
|
+
const container = new import_container.Container({
|
|
57
|
+
...containerConfiguration,
|
|
58
|
+
evaluationBaseEndpointUrl: baseHttpEndpoint,
|
|
59
|
+
contentBaseEndpointUrl: baseHttpEndpoint,
|
|
60
|
+
trackerEndpointUrl: `${baseHttpEndpoint}/client/web/track`,
|
|
61
|
+
cidAssignerEndpointUrl: cidAssignerEndpointUrl ?? `${baseHttpEndpoint}/client/web/cid`,
|
|
62
|
+
beaconQueueSize: containerConfiguration.beaconQueueSize ?? 100,
|
|
63
|
+
eventMetadata
|
|
64
|
+
});
|
|
65
|
+
const logger = container.getLogger();
|
|
66
|
+
const { appId, tokenScope } = container.getConfiguration();
|
|
67
|
+
logger.debug(
|
|
68
|
+
"\n\n \u2588\u2588\u2588\u2588\u2588\u2588\u2001\u2588\u2588\u2588\u2588\u2588\u2588\u2001 \u2588\u2588\u2588\u2588\u2588\u2588\u2001 \u2588\u2588\u2588\u2588\u2588\u2588\u2001\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2001\n\u2588\u2588\u2001\u2001\u2001\u2001\u2001\u2001\u2588\u2588\u2001\u2001\u2001\u2588\u2588\u2001\u2588\u2588\u2001\u2001\u2001\u2001\u2588\u2588\u2001\u2588\u2588\u2001\u2001\u2001\u2001\u2001\u2001\u2001\u2001\u2001\u2588\u2588\u2001\u2001\u2001\u2001\n\u2588\u2588\u2001 \u2588\u2588\u2588\u2588\u2588\u2588\u2001\u2001\u2588\u2588\u2001 \u2588\u2588\u2001\u2588\u2588\u2001 \u2588\u2588\u2001\u2001\u2001\u2001\n\u2588\u2588\u2001 \u2588\u2588\u2001\u2001\u2001\u2588\u2588\u2001\u2588\u2588\u2001 \u2588\u2588\u2001\u2588\u2588\u2001 \u2588\u2588\u2001\u2001\u2001\u2001\n \u2588\u2588\u2588\u2588\u2588\u2588\u2001\u2588\u2588\u2001 \u2588\u2588\u2001\u2001\u2588\u2588\u2588\u2588\u2588\u2588\u2001\u2001\u2001\u2588\u2588\u2588\u2588\u2588\u2588\u2001 \u2588\u2588\u2001\u2001\u2001\u2001\n\n"
|
|
69
|
+
);
|
|
70
|
+
logger.info(`Initializing SDK v${import_constants.VERSION}...`);
|
|
71
|
+
logger.debug(`App ID: ${appId}`);
|
|
72
|
+
const context = container.getContext();
|
|
73
|
+
const tab = context.getTab();
|
|
74
|
+
const user = context.getUser();
|
|
75
|
+
logger.debug(`${tab.isNew ? "New" : "Current"} tab: ${tab.id}`);
|
|
76
|
+
logger.debug(`Token scope: ${tokenScope}`);
|
|
77
|
+
logger.debug(`Current user: ${user !== null ? user : "anonymous"}`);
|
|
78
|
+
logger.debug(`Test mode: ${containerConfiguration.test}`);
|
|
79
|
+
logger.info("\u26A1 Croct SDK is ready!");
|
|
80
|
+
return new Sdk(container);
|
|
81
|
+
}
|
|
82
|
+
get appId() {
|
|
83
|
+
const { appId } = this.container.getConfiguration();
|
|
84
|
+
return appId;
|
|
85
|
+
}
|
|
86
|
+
get cidAssigner() {
|
|
87
|
+
return this.container.getCidAssigner();
|
|
88
|
+
}
|
|
89
|
+
get previewTokenStore() {
|
|
90
|
+
return this.container.getPreviewTokenStore();
|
|
91
|
+
}
|
|
92
|
+
get userTokenStore() {
|
|
93
|
+
return this.container.getUserTokenStore();
|
|
94
|
+
}
|
|
95
|
+
get context() {
|
|
96
|
+
return this.container.getContext();
|
|
97
|
+
}
|
|
98
|
+
get tracker() {
|
|
99
|
+
return this.container.getTracker();
|
|
100
|
+
}
|
|
101
|
+
get evaluator() {
|
|
102
|
+
return this.container.getEvaluator();
|
|
103
|
+
}
|
|
104
|
+
get contentFetcher() {
|
|
105
|
+
return this.container.getContentFetcher();
|
|
106
|
+
}
|
|
107
|
+
get eventManager() {
|
|
108
|
+
return this.container.getEventManager();
|
|
109
|
+
}
|
|
110
|
+
getLogger(...namespace) {
|
|
111
|
+
return this.container.getLogger(...namespace);
|
|
112
|
+
}
|
|
113
|
+
getTabStorage(namespace, ...subnamespace) {
|
|
114
|
+
return this.container.getTabStorage(namespace, ...subnamespace);
|
|
115
|
+
}
|
|
116
|
+
getBrowserStorage(namespace, ...subnamespace) {
|
|
117
|
+
return this.container.getBrowserStorage(namespace, ...subnamespace);
|
|
118
|
+
}
|
|
119
|
+
async close() {
|
|
120
|
+
if (this.closed) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const logger = this.getLogger();
|
|
124
|
+
logger.debug("Closing SDK...");
|
|
125
|
+
this.closed = true;
|
|
126
|
+
await this.container.dispose();
|
|
127
|
+
logger.info("SDK closed.");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
131
|
+
0 && (module.exports = {
|
|
132
|
+
Sdk
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=sdk.cjs.map
|
package/sdkEvents.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var sdkEvents_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(sdkEvents_exports);
|
|
16
|
+
//# sourceMappingURL=sdkEvents.cjs.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var sourceLocation_exports = {};
|
|
19
|
+
__export(sourceLocation_exports, {
|
|
20
|
+
getLength: () => getLength,
|
|
21
|
+
getLocation: () => getLocation,
|
|
22
|
+
getPosition: () => getPosition
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(sourceLocation_exports);
|
|
25
|
+
function getLength(input) {
|
|
26
|
+
return [...input].length;
|
|
27
|
+
}
|
|
28
|
+
function getLocation(input, startIndex, endIndex) {
|
|
29
|
+
if (startIndex < 0) {
|
|
30
|
+
throw Error("The start index cannot be negative.");
|
|
31
|
+
}
|
|
32
|
+
if (endIndex < startIndex) {
|
|
33
|
+
throw new Error("The end index must greater than or equal to the start index.");
|
|
34
|
+
}
|
|
35
|
+
let start;
|
|
36
|
+
let end;
|
|
37
|
+
const chars = [...input];
|
|
38
|
+
let line = 1;
|
|
39
|
+
let column = 0;
|
|
40
|
+
for (let offset = 0; offset < chars.length; offset++) {
|
|
41
|
+
const char = chars[offset];
|
|
42
|
+
if (offset === startIndex) {
|
|
43
|
+
start = {
|
|
44
|
+
index: offset,
|
|
45
|
+
line,
|
|
46
|
+
column
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (offset === endIndex) {
|
|
50
|
+
end = {
|
|
51
|
+
index: offset,
|
|
52
|
+
line,
|
|
53
|
+
column
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
if (char === "\n") {
|
|
58
|
+
line += 1;
|
|
59
|
+
column = 0;
|
|
60
|
+
} else {
|
|
61
|
+
column += 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (start === void 0) {
|
|
65
|
+
start = {
|
|
66
|
+
index: chars.length,
|
|
67
|
+
line,
|
|
68
|
+
column
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (end === void 0) {
|
|
72
|
+
end = {
|
|
73
|
+
index: chars.length,
|
|
74
|
+
line,
|
|
75
|
+
column
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
start,
|
|
80
|
+
end
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function getPosition(input, index) {
|
|
84
|
+
return getLocation(input, index, index).start;
|
|
85
|
+
}
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
getLength,
|
|
89
|
+
getLocation,
|
|
90
|
+
getPosition
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=sourceLocation.cjs.map
|
package/tab.cjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var tab_exports = {};
|
|
19
|
+
__export(tab_exports, {
|
|
20
|
+
Tab: () => Tab
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(tab_exports);
|
|
23
|
+
var import_eventManager = require("./eventManager");
|
|
24
|
+
const EventMap = {
|
|
25
|
+
focus: "focus",
|
|
26
|
+
blur: "blur",
|
|
27
|
+
beforeunload: "unload",
|
|
28
|
+
DOMContentLoaded: "load",
|
|
29
|
+
visibilitychange: "visibilityChange"
|
|
30
|
+
};
|
|
31
|
+
class Tab {
|
|
32
|
+
constructor(id, isNew, urlSanitizer) {
|
|
33
|
+
this.eventManager = new import_eventManager.SynchronousEventManager();
|
|
34
|
+
this.id = id;
|
|
35
|
+
this.isNew = isNew;
|
|
36
|
+
this.urlSanitizer = urlSanitizer;
|
|
37
|
+
this.initialize();
|
|
38
|
+
}
|
|
39
|
+
initialize() {
|
|
40
|
+
const listener = (event) => {
|
|
41
|
+
this.emit(EventMap[event.type], new CustomEvent(EventMap[event.type], { detail: { tab: this } }));
|
|
42
|
+
};
|
|
43
|
+
window.addEventListener("focus", listener, true);
|
|
44
|
+
window.addEventListener("blur", listener, true);
|
|
45
|
+
window.addEventListener("beforeunload", listener, true);
|
|
46
|
+
window.addEventListener("DOMContentLoaded", listener, true);
|
|
47
|
+
document.addEventListener(
|
|
48
|
+
"visibilitychange",
|
|
49
|
+
() => {
|
|
50
|
+
this.emit("visibilityChange", new CustomEvent("visibilityChange", {
|
|
51
|
+
detail: {
|
|
52
|
+
tab: this,
|
|
53
|
+
visible: this.isVisible
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
},
|
|
57
|
+
true
|
|
58
|
+
);
|
|
59
|
+
Tab.addUrlChangeListener((url) => {
|
|
60
|
+
this.emit("urlChange", new CustomEvent("urlChange", { detail: { tab: this, url: this.sanitizeUrl(url) } }));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
get url() {
|
|
64
|
+
return this.sanitizeUrl(window.location.href);
|
|
65
|
+
}
|
|
66
|
+
get title() {
|
|
67
|
+
return document.title;
|
|
68
|
+
}
|
|
69
|
+
get referrer() {
|
|
70
|
+
return document.referrer === "" ? "" : this.sanitizeUrl(document.referrer);
|
|
71
|
+
}
|
|
72
|
+
get isVisible() {
|
|
73
|
+
return document.visibilityState === "visible";
|
|
74
|
+
}
|
|
75
|
+
get document() {
|
|
76
|
+
return document;
|
|
77
|
+
}
|
|
78
|
+
addListener(type, listener) {
|
|
79
|
+
this.eventManager.addListener(type, listener);
|
|
80
|
+
}
|
|
81
|
+
removeListener(type, listener) {
|
|
82
|
+
this.eventManager.removeListener(type, listener);
|
|
83
|
+
}
|
|
84
|
+
sanitizeUrl(url) {
|
|
85
|
+
const normalized = window.encodeURI(window.decodeURI(url));
|
|
86
|
+
if (this.urlSanitizer !== void 0) {
|
|
87
|
+
return this.urlSanitizer(normalized).toString();
|
|
88
|
+
}
|
|
89
|
+
return normalized;
|
|
90
|
+
}
|
|
91
|
+
emit(type, event) {
|
|
92
|
+
this.eventManager.dispatch(type, event);
|
|
93
|
+
}
|
|
94
|
+
static addUrlChangeListener(listener) {
|
|
95
|
+
let url = window.location.href;
|
|
96
|
+
const updateUrl = () => {
|
|
97
|
+
const currentUrl = window.location.href;
|
|
98
|
+
if (url !== currentUrl) {
|
|
99
|
+
listener(currentUrl);
|
|
100
|
+
url = currentUrl;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const { pushState } = window.history;
|
|
104
|
+
window.history.pushState = function interceptPushState(...args) {
|
|
105
|
+
const result = pushState.apply(window.history, args);
|
|
106
|
+
updateUrl();
|
|
107
|
+
return result;
|
|
108
|
+
};
|
|
109
|
+
const { replaceState } = window.history;
|
|
110
|
+
window.history.replaceState = function interceptReplaceState(...args) {
|
|
111
|
+
const result = replaceState.apply(window.history, args);
|
|
112
|
+
updateUrl();
|
|
113
|
+
return result;
|
|
114
|
+
};
|
|
115
|
+
window.addEventListener("popstate", updateUrl, true);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
Tab
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=tab.cjs.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var cachedTokenStore_exports = {};
|
|
19
|
+
__export(cachedTokenStore_exports, {
|
|
20
|
+
CachedTokenStore: () => CachedTokenStore
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(cachedTokenStore_exports);
|
|
23
|
+
var import_token = require("./token");
|
|
24
|
+
class CachedTokenStore {
|
|
25
|
+
constructor(cache) {
|
|
26
|
+
this.cache = cache;
|
|
27
|
+
}
|
|
28
|
+
getToken() {
|
|
29
|
+
const data = this.cache.get();
|
|
30
|
+
if (data === null) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
return import_token.Token.parse(data);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
setToken(token) {
|
|
40
|
+
if (token === null) {
|
|
41
|
+
this.cache.clear();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.cache.put(token.toString());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
CachedTokenStore
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=cachedTokenStore.cjs.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var inMemoryTokenStore_exports = {};
|
|
19
|
+
__export(inMemoryTokenStore_exports, {
|
|
20
|
+
InMemoryTokenStore: () => InMemoryTokenStore
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(inMemoryTokenStore_exports);
|
|
23
|
+
class InMemoryTokenStore {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.token = null;
|
|
26
|
+
}
|
|
27
|
+
getToken() {
|
|
28
|
+
return this.token;
|
|
29
|
+
}
|
|
30
|
+
setToken(token) {
|
|
31
|
+
this.token = token;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
InMemoryTokenStore
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=inMemoryTokenStore.cjs.map
|
package/token/index.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var token_exports = {};
|
|
20
|
+
__export(token_exports, {
|
|
21
|
+
CachedTokenStore: () => import_cachedTokenStore.CachedTokenStore,
|
|
22
|
+
InMemoryTokenStore: () => import_inMemoryTokenStore.InMemoryTokenStore,
|
|
23
|
+
ReplicatedTokenStore: () => import_replicatedTokenStore.ReplicatedTokenStore
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(token_exports);
|
|
26
|
+
__reExport(token_exports, require("./token"), module.exports);
|
|
27
|
+
var import_cachedTokenStore = require("./cachedTokenStore");
|
|
28
|
+
var import_inMemoryTokenStore = require("./inMemoryTokenStore");
|
|
29
|
+
var import_replicatedTokenStore = require("./replicatedTokenStore");
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
CachedTokenStore,
|
|
33
|
+
InMemoryTokenStore,
|
|
34
|
+
ReplicatedTokenStore,
|
|
35
|
+
...require("./token")
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var replicatedTokenStore_exports = {};
|
|
19
|
+
__export(replicatedTokenStore_exports, {
|
|
20
|
+
ReplicatedTokenStore: () => ReplicatedTokenStore
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(replicatedTokenStore_exports);
|
|
23
|
+
class ReplicatedTokenStore {
|
|
24
|
+
constructor(primary, secondary) {
|
|
25
|
+
this.primary = primary;
|
|
26
|
+
this.secondary = secondary;
|
|
27
|
+
}
|
|
28
|
+
getToken() {
|
|
29
|
+
return this.primary.getToken();
|
|
30
|
+
}
|
|
31
|
+
setToken(token) {
|
|
32
|
+
this.primary.setToken(token);
|
|
33
|
+
this.secondary.setToken(token);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
ReplicatedTokenStore
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=replicatedTokenStore.cjs.map
|