@croct/plug 0.18.1 → 0.19.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/README.md +2 -1
- package/api/fetchContent.d.cts +1 -2
- package/api/fetchContent.d.ts +1 -2
- package/api/index.d.cts +1 -2
- package/api/index.d.ts +1 -2
- package/component.d.cts +1 -1
- package/component.d.ts +1 -1
- package/constants.cjs +1 -1
- package/constants.d.cts +1 -1
- package/constants.d.ts +1 -1
- package/constants.js +1 -1
- package/global.d.cjs +0 -0
- package/global.d.d.cts +30 -0
- package/global.d.d.ts +30 -0
- package/global.d.js +0 -0
- package/index.d.cts +2 -3
- package/index.d.ts +2 -3
- package/package.json +15 -2
- package/plug-Cf6SnDp4.d.cts +110 -0
- package/plug-DjUeWnq0.d.ts +110 -0
- package/plug.cjs +7 -4
- package/plug.d.cts +11 -77
- package/plug.d.ts +11 -77
- package/plug.js +7 -4
- package/plugin.d.cts +19 -39
- package/plugin.d.ts +19 -39
- package/plugins/autoTracking/index.cjs +148 -0
- package/plugins/autoTracking/index.d.cts +50 -0
- package/plugins/autoTracking/index.d.ts +50 -0
- package/plugins/autoTracking/index.js +124 -0
- package/plugins/autoTracking/structuredData.cjs +379 -0
- package/plugins/autoTracking/structuredData.d.cts +42 -0
- package/plugins/autoTracking/structuredData.d.ts +42 -0
- package/plugins/autoTracking/structuredData.js +353 -0
- package/plugins/globalVariable/index.cjs +64 -0
- package/plugins/globalVariable/index.d.cts +36 -0
- package/plugins/globalVariable/index.d.ts +36 -0
- package/plugins/globalVariable/index.js +40 -0
- package/{preview.cjs → plugins/preview/index.cjs} +2 -2
- package/{preview.d.ts → plugins/preview/index.d.cts} +14 -5
- package/{preview.d.cts → plugins/preview/index.d.ts} +14 -5
- package/{preview.js → plugins/preview/index.js} +2 -2
- package/sdk/index.d.cts +1 -1
- package/sdk/index.d.ts +1 -1
- package/playground.cjs +0 -166
- package/playground.d.cts +0 -64
- package/playground.d.ts +0 -64
- package/playground.js +0 -142
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
<p align="center">
|
|
20
20
|
<a href="https://www.npmjs.com/package/@croct/plug"><img alt="Version" src="https://img.shields.io/npm/v/@croct/plug"/></a>
|
|
21
21
|
<img alt="Gzipped bundle size" src="https://img.badgesize.io/https:/cdn.croct.io/js/v1/lib/plug.js?style=flat&compression=gzip" />
|
|
22
|
-
<a href="https://
|
|
22
|
+
<a href="https://qlty.sh/gh/croct-tech/projects/plug-js"><img src="https://qlty.sh/badges/116cbaf6-8bd6-4ae9-b755-75a6ece12f91/coverage.svg" alt="Code Coverage" /></a>
|
|
23
|
+
<a href="https://qlty.sh/gh/croct-tech/projects/plug-js"><img src="https://qlty.sh/badges/116cbaf6-8bd6-4ae9-b755-75a6ece12f91/maintainability.svg" alt="Maintainability" /></a>
|
|
23
24
|
</p>
|
|
24
25
|
|
|
25
26
|
## Introduction
|
package/api/fetchContent.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { DynamicContentOptions as DynamicContentOptions$1, StaticContentOptions
|
|
|
2
2
|
import { ApiKey } from '@croct/sdk/apiKey';
|
|
3
3
|
import { Logger } from '@croct/sdk/logging';
|
|
4
4
|
import { JsonObject, JsonValue } from '@croct/json/mutable';
|
|
5
|
-
import { FetchResponse } from '../plug.cjs';
|
|
5
|
+
import { F as FetchResponse } from '../plug-Cf6SnDp4.cjs';
|
|
6
6
|
import { SlotContent, VersionedSlotId } from '../slot.cjs';
|
|
7
7
|
import '@croct/sdk/facade/sessionFacade';
|
|
8
8
|
import '@croct/sdk/facade/userFacade';
|
|
@@ -12,7 +12,6 @@ import '@croct/sdk/facade/sdkFacade';
|
|
|
12
12
|
import '@croct/sdk/utilityTypes';
|
|
13
13
|
import '@croct/sdk/trackingEvents';
|
|
14
14
|
import '@croct/sdk/facade/contentFetcherFacade';
|
|
15
|
-
import '../plugin.cjs';
|
|
16
15
|
import '@croct/sdk/token';
|
|
17
16
|
import '../sdk/index.cjs';
|
|
18
17
|
import '@croct/sdk/eventManager';
|
package/api/fetchContent.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { DynamicContentOptions as DynamicContentOptions$1, StaticContentOptions
|
|
|
2
2
|
import { ApiKey } from '@croct/sdk/apiKey';
|
|
3
3
|
import { Logger } from '@croct/sdk/logging';
|
|
4
4
|
import { JsonObject, JsonValue } from '@croct/json/mutable';
|
|
5
|
-
import { FetchResponse } from '../plug.js';
|
|
5
|
+
import { F as FetchResponse } from '../plug-DjUeWnq0.js';
|
|
6
6
|
import { SlotContent, VersionedSlotId } from '../slot.js';
|
|
7
7
|
import '@croct/sdk/facade/sessionFacade';
|
|
8
8
|
import '@croct/sdk/facade/userFacade';
|
|
@@ -12,7 +12,6 @@ import '@croct/sdk/facade/sdkFacade';
|
|
|
12
12
|
import '@croct/sdk/utilityTypes';
|
|
13
13
|
import '@croct/sdk/trackingEvents';
|
|
14
14
|
import '@croct/sdk/facade/contentFetcherFacade';
|
|
15
|
-
import '../plugin.js';
|
|
16
15
|
import '@croct/sdk/token';
|
|
17
16
|
import '../sdk/index.js';
|
|
18
17
|
import '@croct/sdk/eventManager';
|
package/api/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { EvaluationOptions, evaluate } from './evaluate.cjs';
|
|
2
2
|
export { DynamicContentOptions, FetchOptions, StaticContentOptions, fetchContent } from './fetchContent.cjs';
|
|
3
|
-
export { FetchResponse } from '../plug.cjs';
|
|
3
|
+
export { F as FetchResponse } from '../plug-Cf6SnDp4.cjs';
|
|
4
4
|
import '@croct/sdk/evaluator';
|
|
5
5
|
import '@croct/sdk/apiKey';
|
|
6
6
|
import '@croct/sdk/logging';
|
|
@@ -18,7 +18,6 @@ import '@croct/sdk/facade/sdkFacade';
|
|
|
18
18
|
import '@croct/sdk/utilityTypes';
|
|
19
19
|
import '@croct/sdk/trackingEvents';
|
|
20
20
|
import '@croct/sdk/facade/contentFetcherFacade';
|
|
21
|
-
import '../plugin.cjs';
|
|
22
21
|
import '@croct/sdk/token';
|
|
23
22
|
import '../sdk/index.cjs';
|
|
24
23
|
import '@croct/sdk/eventManager';
|
package/api/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { EvaluationOptions, evaluate } from './evaluate.js';
|
|
2
2
|
export { DynamicContentOptions, FetchOptions, StaticContentOptions, fetchContent } from './fetchContent.js';
|
|
3
|
-
export { FetchResponse } from '../plug.js';
|
|
3
|
+
export { F as FetchResponse } from '../plug-DjUeWnq0.js';
|
|
4
4
|
import '@croct/sdk/evaluator';
|
|
5
5
|
import '@croct/sdk/apiKey';
|
|
6
6
|
import '@croct/sdk/logging';
|
|
@@ -18,7 +18,6 @@ import '@croct/sdk/facade/sdkFacade';
|
|
|
18
18
|
import '@croct/sdk/utilityTypes';
|
|
19
19
|
import '@croct/sdk/trackingEvents';
|
|
20
20
|
import '@croct/sdk/facade/contentFetcherFacade';
|
|
21
|
-
import '../plugin.js';
|
|
22
21
|
import '@croct/sdk/token';
|
|
23
22
|
import '../sdk/index.js';
|
|
24
23
|
import '@croct/sdk/eventManager';
|
package/component.d.cts
CHANGED
package/component.d.ts
CHANGED
package/constants.cjs
CHANGED
|
@@ -28,7 +28,7 @@ const CDN_URL = "https://cdn.croct.io/js/v1/lib/plug.js";
|
|
|
28
28
|
const PLAYGROUND_ORIGIN = "https://play.croct.com";
|
|
29
29
|
const PLAYGROUND_CONNECT_URL = "https://play.croct.com/connect.html";
|
|
30
30
|
const PREVIEW_WIDGET_ORIGIN = "https://cdn.croct.io";
|
|
31
|
-
const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.
|
|
31
|
+
const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.19.0.html";
|
|
32
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
33
|
0 && (module.exports = {
|
|
34
34
|
CDN_URL,
|
package/constants.d.cts
CHANGED
|
@@ -2,6 +2,6 @@ declare const CDN_URL = "https://cdn.croct.io/js/v1/lib/plug.js";
|
|
|
2
2
|
declare const PLAYGROUND_ORIGIN = "https://play.croct.com";
|
|
3
3
|
declare const PLAYGROUND_CONNECT_URL = "https://play.croct.com/connect.html";
|
|
4
4
|
declare const PREVIEW_WIDGET_ORIGIN = "https://cdn.croct.io";
|
|
5
|
-
declare const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.
|
|
5
|
+
declare const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.19.0.html";
|
|
6
6
|
|
|
7
7
|
export { CDN_URL, PLAYGROUND_CONNECT_URL, PLAYGROUND_ORIGIN, PREVIEW_WIDGET_ORIGIN, PREVIEW_WIDGET_URL };
|
package/constants.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ declare const CDN_URL = "https://cdn.croct.io/js/v1/lib/plug.js";
|
|
|
2
2
|
declare const PLAYGROUND_ORIGIN = "https://play.croct.com";
|
|
3
3
|
declare const PLAYGROUND_CONNECT_URL = "https://play.croct.com/connect.html";
|
|
4
4
|
declare const PREVIEW_WIDGET_ORIGIN = "https://cdn.croct.io";
|
|
5
|
-
declare const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.
|
|
5
|
+
declare const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.19.0.html";
|
|
6
6
|
|
|
7
7
|
export { CDN_URL, PLAYGROUND_CONNECT_URL, PLAYGROUND_ORIGIN, PREVIEW_WIDGET_ORIGIN, PREVIEW_WIDGET_URL };
|
package/constants.js
CHANGED
|
@@ -2,7 +2,7 @@ const CDN_URL = "https://cdn.croct.io/js/v1/lib/plug.js";
|
|
|
2
2
|
const PLAYGROUND_ORIGIN = "https://play.croct.com";
|
|
3
3
|
const PLAYGROUND_CONNECT_URL = "https://play.croct.com/connect.html";
|
|
4
4
|
const PREVIEW_WIDGET_ORIGIN = "https://cdn.croct.io";
|
|
5
|
-
const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.
|
|
5
|
+
const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.19.0.html";
|
|
6
6
|
export {
|
|
7
7
|
CDN_URL,
|
|
8
8
|
PLAYGROUND_CONNECT_URL,
|
package/global.d.cjs
ADDED
|
File without changes
|
package/global.d.d.cts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { P as Plug } from './plug-Cf6SnDp4.cjs';
|
|
2
|
+
import '@croct/sdk/facade/sessionFacade';
|
|
3
|
+
import '@croct/sdk/facade/userFacade';
|
|
4
|
+
import '@croct/sdk/facade/trackerFacade';
|
|
5
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
6
|
+
import '@croct/sdk/facade/sdkFacade';
|
|
7
|
+
import '@croct/sdk/utilityTypes';
|
|
8
|
+
import '@croct/sdk/trackingEvents';
|
|
9
|
+
import '@croct/sdk/facade/contentFetcherFacade';
|
|
10
|
+
import '@croct/sdk/token';
|
|
11
|
+
import './sdk/index.cjs';
|
|
12
|
+
import '@croct/sdk/eventManager';
|
|
13
|
+
import '@croct/sdk/sdkEvents';
|
|
14
|
+
import '@croct/sdk/logging';
|
|
15
|
+
import '@croct/sdk/tab';
|
|
16
|
+
import '@croct/sdk/cid';
|
|
17
|
+
import './slot.cjs';
|
|
18
|
+
import '@croct/json';
|
|
19
|
+
import './versioning.cjs';
|
|
20
|
+
import './component.cjs';
|
|
21
|
+
import '@croct/json/mutable';
|
|
22
|
+
|
|
23
|
+
declare global {
|
|
24
|
+
type CroctCallback = (instance: Plug) => void;
|
|
25
|
+
|
|
26
|
+
interface Window {
|
|
27
|
+
croct?: Plug;
|
|
28
|
+
onCroctLoad: CroctCallback | undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/global.d.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { P as Plug } from './plug-DjUeWnq0.js';
|
|
2
|
+
import '@croct/sdk/facade/sessionFacade';
|
|
3
|
+
import '@croct/sdk/facade/userFacade';
|
|
4
|
+
import '@croct/sdk/facade/trackerFacade';
|
|
5
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
6
|
+
import '@croct/sdk/facade/sdkFacade';
|
|
7
|
+
import '@croct/sdk/utilityTypes';
|
|
8
|
+
import '@croct/sdk/trackingEvents';
|
|
9
|
+
import '@croct/sdk/facade/contentFetcherFacade';
|
|
10
|
+
import '@croct/sdk/token';
|
|
11
|
+
import './sdk/index.js';
|
|
12
|
+
import '@croct/sdk/eventManager';
|
|
13
|
+
import '@croct/sdk/sdkEvents';
|
|
14
|
+
import '@croct/sdk/logging';
|
|
15
|
+
import '@croct/sdk/tab';
|
|
16
|
+
import '@croct/sdk/cid';
|
|
17
|
+
import './slot.js';
|
|
18
|
+
import '@croct/json';
|
|
19
|
+
import './versioning.js';
|
|
20
|
+
import './component.js';
|
|
21
|
+
import '@croct/json/mutable';
|
|
22
|
+
|
|
23
|
+
declare global {
|
|
24
|
+
type CroctCallback = (instance: Plug) => void;
|
|
25
|
+
|
|
26
|
+
interface Window {
|
|
27
|
+
croct?: Plug;
|
|
28
|
+
onCroctLoad: CroctCallback | undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/global.d.js
ADDED
|
File without changes
|
package/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GlobalPlug } from './plug.cjs';
|
|
2
|
-
export { Configuration, Plug } from './plug.cjs';
|
|
1
|
+
import { G as GlobalPlug } from './plug-Cf6SnDp4.cjs';
|
|
2
|
+
export { C as Configuration, P as Plug } from './plug-Cf6SnDp4.cjs';
|
|
3
3
|
import '@croct/sdk/facade/sessionFacade';
|
|
4
4
|
import '@croct/sdk/facade/userFacade';
|
|
5
5
|
import '@croct/sdk/facade/trackerFacade';
|
|
@@ -8,7 +8,6 @@ import '@croct/sdk/facade/sdkFacade';
|
|
|
8
8
|
import '@croct/sdk/utilityTypes';
|
|
9
9
|
import '@croct/sdk/trackingEvents';
|
|
10
10
|
import '@croct/sdk/facade/contentFetcherFacade';
|
|
11
|
-
import './plugin.cjs';
|
|
12
11
|
import '@croct/sdk/token';
|
|
13
12
|
import './sdk/index.cjs';
|
|
14
13
|
import '@croct/sdk/eventManager';
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GlobalPlug } from './plug.js';
|
|
2
|
-
export { Configuration, Plug } from './plug.js';
|
|
1
|
+
import { G as GlobalPlug } from './plug-DjUeWnq0.js';
|
|
2
|
+
export { C as Configuration, P as Plug } from './plug-DjUeWnq0.js';
|
|
3
3
|
import '@croct/sdk/facade/sessionFacade';
|
|
4
4
|
import '@croct/sdk/facade/userFacade';
|
|
5
5
|
import '@croct/sdk/facade/trackerFacade';
|
|
@@ -8,7 +8,6 @@ import '@croct/sdk/facade/sdkFacade';
|
|
|
8
8
|
import '@croct/sdk/utilityTypes';
|
|
9
9
|
import '@croct/sdk/trackingEvents';
|
|
10
10
|
import '@croct/sdk/facade/contentFetcherFacade';
|
|
11
|
-
import './plugin.js';
|
|
12
11
|
import '@croct/sdk/token';
|
|
13
12
|
import './sdk/index.js';
|
|
14
13
|
import '@croct/sdk/eventManager';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@croct/plug",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "A fully-featured devkit for building natively personalized applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,6 +31,18 @@
|
|
|
31
31
|
"import": "./index.js",
|
|
32
32
|
"require": "./index.cjs"
|
|
33
33
|
},
|
|
34
|
+
"./plugins/autoTracking": {
|
|
35
|
+
"import": "./plugins/autoTracking/index.js",
|
|
36
|
+
"require": "./plugins/autoTracking/index.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./plugins/globalVariable": {
|
|
39
|
+
"import": "./plugins/globalVariable/index.js",
|
|
40
|
+
"require": "./plugins/globalVariable/index.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./plugins/preview": {
|
|
43
|
+
"import": "./plugins/preview/index.js",
|
|
44
|
+
"require": "./plugins/preview/index.cjs"
|
|
45
|
+
},
|
|
34
46
|
"./sdk": {
|
|
35
47
|
"import": "./sdk/index.js",
|
|
36
48
|
"require": "./sdk/index.cjs"
|
|
@@ -72,8 +84,9 @@
|
|
|
72
84
|
"jest": "^29.3.1",
|
|
73
85
|
"jest-environment-jsdom": "^29.3.1",
|
|
74
86
|
"rollup": "^4.0.0",
|
|
87
|
+
"schema-dts": "^1.1.5",
|
|
75
88
|
"ts-jest": "^29.0.3",
|
|
76
|
-
"ts-node": "^10.9.
|
|
89
|
+
"ts-node": "^10.9.2",
|
|
77
90
|
"tsup": "^8.4.0",
|
|
78
91
|
"typescript": "^5.0.0"
|
|
79
92
|
},
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { SessionFacade } from '@croct/sdk/facade/sessionFacade';
|
|
2
|
+
import { UserFacade } from '@croct/sdk/facade/userFacade';
|
|
3
|
+
import { TrackerFacade } from '@croct/sdk/facade/trackerFacade';
|
|
4
|
+
import { EvaluatorFacade, EvaluationOptions } from '@croct/sdk/facade/evaluatorFacade';
|
|
5
|
+
import { Configuration as Configuration$1 } from '@croct/sdk/facade/sdkFacade';
|
|
6
|
+
import { Optional } from '@croct/sdk/utilityTypes';
|
|
7
|
+
import { ExternalTrackingEventType, ExternalTrackingEventPayload, ExternalTrackingEvent } from '@croct/sdk/trackingEvents';
|
|
8
|
+
import { FetchOptions as FetchOptions$1 } from '@croct/sdk/facade/contentFetcherFacade';
|
|
9
|
+
import { TokenStore } from '@croct/sdk/token';
|
|
10
|
+
import { SdkEventManager } from './sdk/index.cjs';
|
|
11
|
+
import { VersionedSlotId, SlotContent } from './slot.cjs';
|
|
12
|
+
import { JsonValue, JsonObject } from '@croct/json/mutable';
|
|
13
|
+
import { Tab } from '@croct/sdk/tab';
|
|
14
|
+
import { CidAssigner } from '@croct/sdk/cid';
|
|
15
|
+
import { Logger } from '@croct/sdk/logging';
|
|
16
|
+
|
|
17
|
+
interface PluginSdk {
|
|
18
|
+
readonly version: string;
|
|
19
|
+
readonly appId: string;
|
|
20
|
+
readonly plug: Plug;
|
|
21
|
+
readonly tracker: TrackerFacade;
|
|
22
|
+
readonly evaluator: EvaluatorFacade;
|
|
23
|
+
readonly user: UserFacade;
|
|
24
|
+
readonly session: SessionFacade;
|
|
25
|
+
readonly tab: Tab;
|
|
26
|
+
readonly userTokenStore: TokenStore;
|
|
27
|
+
readonly previewTokenStore: TokenStore;
|
|
28
|
+
readonly cidAssigner: CidAssigner;
|
|
29
|
+
readonly eventManager: SdkEventManager;
|
|
30
|
+
getLogger(...namespace: string[]): Logger;
|
|
31
|
+
getTabStorage(...namespace: string[]): Storage;
|
|
32
|
+
getBrowserStorage(...namespace: string[]): Storage;
|
|
33
|
+
}
|
|
34
|
+
interface PluginArguments<T = any> {
|
|
35
|
+
options: T;
|
|
36
|
+
sdk: PluginSdk;
|
|
37
|
+
}
|
|
38
|
+
interface PluginFactory<T = any> {
|
|
39
|
+
(args: PluginArguments<T>): Plugin;
|
|
40
|
+
}
|
|
41
|
+
interface Plugin {
|
|
42
|
+
enable(): Promise<void> | void;
|
|
43
|
+
disable?(): Promise<void> | void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface PluginConfigurations {
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
49
|
+
type Configuration = Optional<Configuration$1, 'appId'> & {
|
|
50
|
+
plugins?: PluginConfigurations;
|
|
51
|
+
};
|
|
52
|
+
type FetchOptions<T> = Omit<FetchOptions$1, 'version'> & {
|
|
53
|
+
fallback?: T;
|
|
54
|
+
};
|
|
55
|
+
type FetchResponse<I extends VersionedSlotId, C extends JsonObject = JsonObject, F = never> = {
|
|
56
|
+
content: SlotContent<I, C> | F;
|
|
57
|
+
};
|
|
58
|
+
interface Plug {
|
|
59
|
+
readonly tracker: TrackerFacade;
|
|
60
|
+
readonly user: UserFacade;
|
|
61
|
+
readonly session: SessionFacade;
|
|
62
|
+
readonly initialized: boolean;
|
|
63
|
+
readonly flushed: Promise<this>;
|
|
64
|
+
readonly plugged: Promise<this>;
|
|
65
|
+
plug(configuration: Configuration): void;
|
|
66
|
+
isAnonymous(): boolean;
|
|
67
|
+
getUserId(): string | null;
|
|
68
|
+
identify(userId: string): void;
|
|
69
|
+
anonymize(): void;
|
|
70
|
+
setToken(token: string): void;
|
|
71
|
+
unsetToken(): void;
|
|
72
|
+
track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
|
|
73
|
+
evaluate<T extends JsonValue>(expression: string, options?: EvaluationOptions): Promise<T>;
|
|
74
|
+
fetch<I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I>>): Promise<FetchResponse<I>>;
|
|
75
|
+
fetch<F, I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F>>;
|
|
76
|
+
unplug(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
declare class GlobalPlug implements Plug {
|
|
79
|
+
static readonly GLOBAL: GlobalPlug;
|
|
80
|
+
private pluginFactories;
|
|
81
|
+
private instance?;
|
|
82
|
+
private plugins;
|
|
83
|
+
private initialize;
|
|
84
|
+
private ready;
|
|
85
|
+
constructor();
|
|
86
|
+
extend(name: string, plugin: PluginFactory): void;
|
|
87
|
+
plug(configuration?: Configuration): void;
|
|
88
|
+
get initialized(): boolean;
|
|
89
|
+
get plugged(): Promise<this>;
|
|
90
|
+
get flushed(): Promise<this>;
|
|
91
|
+
private get sdk();
|
|
92
|
+
get tracker(): TrackerFacade;
|
|
93
|
+
get evaluator(): EvaluatorFacade;
|
|
94
|
+
get user(): UserFacade;
|
|
95
|
+
get session(): SessionFacade;
|
|
96
|
+
isAnonymous(): boolean;
|
|
97
|
+
getUserId(): string | null;
|
|
98
|
+
identify(userId: string): void;
|
|
99
|
+
anonymize(): void;
|
|
100
|
+
setToken(token: string): void;
|
|
101
|
+
unsetToken(): void;
|
|
102
|
+
track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
|
|
103
|
+
evaluate<T extends JsonValue>(query: string, options?: EvaluationOptions): Promise<T>;
|
|
104
|
+
test(expression: string, options?: EvaluationOptions): Promise<boolean>;
|
|
105
|
+
fetch<I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I>>): Promise<FetchResponse<I>>;
|
|
106
|
+
fetch<F, I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F>>;
|
|
107
|
+
unplug(): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { type Configuration as C, type FetchResponse as F, GlobalPlug as G, type Plug as P, type Plugin as a, type PluginArguments as b, type PluginFactory as c, type PluginSdk as d, type PluginConfigurations as e, type FetchOptions as f };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { SessionFacade } from '@croct/sdk/facade/sessionFacade';
|
|
2
|
+
import { UserFacade } from '@croct/sdk/facade/userFacade';
|
|
3
|
+
import { TrackerFacade } from '@croct/sdk/facade/trackerFacade';
|
|
4
|
+
import { EvaluatorFacade, EvaluationOptions } from '@croct/sdk/facade/evaluatorFacade';
|
|
5
|
+
import { Configuration as Configuration$1 } from '@croct/sdk/facade/sdkFacade';
|
|
6
|
+
import { Optional } from '@croct/sdk/utilityTypes';
|
|
7
|
+
import { ExternalTrackingEventType, ExternalTrackingEventPayload, ExternalTrackingEvent } from '@croct/sdk/trackingEvents';
|
|
8
|
+
import { FetchOptions as FetchOptions$1 } from '@croct/sdk/facade/contentFetcherFacade';
|
|
9
|
+
import { TokenStore } from '@croct/sdk/token';
|
|
10
|
+
import { SdkEventManager } from './sdk/index.js';
|
|
11
|
+
import { VersionedSlotId, SlotContent } from './slot.js';
|
|
12
|
+
import { JsonValue, JsonObject } from '@croct/json/mutable';
|
|
13
|
+
import { Tab } from '@croct/sdk/tab';
|
|
14
|
+
import { CidAssigner } from '@croct/sdk/cid';
|
|
15
|
+
import { Logger } from '@croct/sdk/logging';
|
|
16
|
+
|
|
17
|
+
interface PluginSdk {
|
|
18
|
+
readonly version: string;
|
|
19
|
+
readonly appId: string;
|
|
20
|
+
readonly plug: Plug;
|
|
21
|
+
readonly tracker: TrackerFacade;
|
|
22
|
+
readonly evaluator: EvaluatorFacade;
|
|
23
|
+
readonly user: UserFacade;
|
|
24
|
+
readonly session: SessionFacade;
|
|
25
|
+
readonly tab: Tab;
|
|
26
|
+
readonly userTokenStore: TokenStore;
|
|
27
|
+
readonly previewTokenStore: TokenStore;
|
|
28
|
+
readonly cidAssigner: CidAssigner;
|
|
29
|
+
readonly eventManager: SdkEventManager;
|
|
30
|
+
getLogger(...namespace: string[]): Logger;
|
|
31
|
+
getTabStorage(...namespace: string[]): Storage;
|
|
32
|
+
getBrowserStorage(...namespace: string[]): Storage;
|
|
33
|
+
}
|
|
34
|
+
interface PluginArguments<T = any> {
|
|
35
|
+
options: T;
|
|
36
|
+
sdk: PluginSdk;
|
|
37
|
+
}
|
|
38
|
+
interface PluginFactory<T = any> {
|
|
39
|
+
(args: PluginArguments<T>): Plugin;
|
|
40
|
+
}
|
|
41
|
+
interface Plugin {
|
|
42
|
+
enable(): Promise<void> | void;
|
|
43
|
+
disable?(): Promise<void> | void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface PluginConfigurations {
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
49
|
+
type Configuration = Optional<Configuration$1, 'appId'> & {
|
|
50
|
+
plugins?: PluginConfigurations;
|
|
51
|
+
};
|
|
52
|
+
type FetchOptions<T> = Omit<FetchOptions$1, 'version'> & {
|
|
53
|
+
fallback?: T;
|
|
54
|
+
};
|
|
55
|
+
type FetchResponse<I extends VersionedSlotId, C extends JsonObject = JsonObject, F = never> = {
|
|
56
|
+
content: SlotContent<I, C> | F;
|
|
57
|
+
};
|
|
58
|
+
interface Plug {
|
|
59
|
+
readonly tracker: TrackerFacade;
|
|
60
|
+
readonly user: UserFacade;
|
|
61
|
+
readonly session: SessionFacade;
|
|
62
|
+
readonly initialized: boolean;
|
|
63
|
+
readonly flushed: Promise<this>;
|
|
64
|
+
readonly plugged: Promise<this>;
|
|
65
|
+
plug(configuration: Configuration): void;
|
|
66
|
+
isAnonymous(): boolean;
|
|
67
|
+
getUserId(): string | null;
|
|
68
|
+
identify(userId: string): void;
|
|
69
|
+
anonymize(): void;
|
|
70
|
+
setToken(token: string): void;
|
|
71
|
+
unsetToken(): void;
|
|
72
|
+
track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
|
|
73
|
+
evaluate<T extends JsonValue>(expression: string, options?: EvaluationOptions): Promise<T>;
|
|
74
|
+
fetch<I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I>>): Promise<FetchResponse<I>>;
|
|
75
|
+
fetch<F, I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F>>;
|
|
76
|
+
unplug(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
declare class GlobalPlug implements Plug {
|
|
79
|
+
static readonly GLOBAL: GlobalPlug;
|
|
80
|
+
private pluginFactories;
|
|
81
|
+
private instance?;
|
|
82
|
+
private plugins;
|
|
83
|
+
private initialize;
|
|
84
|
+
private ready;
|
|
85
|
+
constructor();
|
|
86
|
+
extend(name: string, plugin: PluginFactory): void;
|
|
87
|
+
plug(configuration?: Configuration): void;
|
|
88
|
+
get initialized(): boolean;
|
|
89
|
+
get plugged(): Promise<this>;
|
|
90
|
+
get flushed(): Promise<this>;
|
|
91
|
+
private get sdk();
|
|
92
|
+
get tracker(): TrackerFacade;
|
|
93
|
+
get evaluator(): EvaluatorFacade;
|
|
94
|
+
get user(): UserFacade;
|
|
95
|
+
get session(): SessionFacade;
|
|
96
|
+
isAnonymous(): boolean;
|
|
97
|
+
getUserId(): string | null;
|
|
98
|
+
identify(userId: string): void;
|
|
99
|
+
anonymize(): void;
|
|
100
|
+
setToken(token: string): void;
|
|
101
|
+
unsetToken(): void;
|
|
102
|
+
track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
|
|
103
|
+
evaluate<T extends JsonValue>(query: string, options?: EvaluationOptions): Promise<T>;
|
|
104
|
+
test(expression: string, options?: EvaluationOptions): Promise<boolean>;
|
|
105
|
+
fetch<I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I>>): Promise<FetchResponse<I>>;
|
|
106
|
+
fetch<F, I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F>>;
|
|
107
|
+
unplug(): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { type Configuration as C, type FetchResponse as F, GlobalPlug as G, type Plug as P, type Plugin as a, type PluginArguments as b, type PluginFactory as c, type PluginSdk as d, type PluginConfigurations as e, type FetchOptions as f };
|
package/plug.cjs
CHANGED
|
@@ -27,8 +27,9 @@ var import_token = require("@croct/sdk/token");
|
|
|
27
27
|
var import_sdk = require("@croct/sdk");
|
|
28
28
|
var import_content = require("@croct/content");
|
|
29
29
|
var import_constants = require('./constants.cjs');
|
|
30
|
-
var
|
|
31
|
-
var
|
|
30
|
+
var import_preview = require('./plugins/preview/index.cjs');
|
|
31
|
+
var import_autoTracking = require('./plugins/autoTracking/index.cjs');
|
|
32
|
+
var import_globalVariable = require('./plugins/globalVariable/index.cjs');
|
|
32
33
|
const PLUGIN_NAMESPACE = "Plugin";
|
|
33
34
|
function detectAppId() {
|
|
34
35
|
const script = window.document.querySelector(`script[src^='${import_constants.CDN_URL}']`);
|
|
@@ -40,8 +41,9 @@ function detectAppId() {
|
|
|
40
41
|
const _GlobalPlug = class _GlobalPlug {
|
|
41
42
|
constructor() {
|
|
42
43
|
this.pluginFactories = {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
preview: import_preview.factory,
|
|
45
|
+
globalVariable: import_globalVariable.factory,
|
|
46
|
+
autoTracking: import_autoTracking.factory
|
|
45
47
|
};
|
|
46
48
|
this.plugins = {};
|
|
47
49
|
this.ready = new Promise((resolve) => {
|
|
@@ -115,6 +117,7 @@ const _GlobalPlug = class _GlobalPlug {
|
|
|
115
117
|
sdk: {
|
|
116
118
|
version: import_sdk.VERSION,
|
|
117
119
|
appId,
|
|
120
|
+
plug: this,
|
|
118
121
|
tracker: sdk.tracker,
|
|
119
122
|
evaluator: sdk.evaluator,
|
|
120
123
|
user: sdk.user,
|
package/plug.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
import
|
|
1
|
+
import '@croct/sdk/facade/sessionFacade';
|
|
2
|
+
import '@croct/sdk/facade/userFacade';
|
|
3
|
+
import '@croct/sdk/facade/trackerFacade';
|
|
4
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
5
|
+
import '@croct/sdk/facade/sdkFacade';
|
|
6
|
+
import '@croct/sdk/utilityTypes';
|
|
7
|
+
import '@croct/sdk/trackingEvents';
|
|
8
|
+
import '@croct/sdk/facade/contentFetcherFacade';
|
|
9
|
+
export { C as Configuration, f as FetchOptions, F as FetchResponse, G as GlobalPlug, P as Plug, e as PluginConfigurations } from './plug-Cf6SnDp4.cjs';
|
|
10
|
+
import './slot.cjs';
|
|
11
|
+
import '@croct/json/mutable';
|
|
12
12
|
import '@croct/sdk/token';
|
|
13
13
|
import './sdk/index.cjs';
|
|
14
14
|
import '@croct/sdk/eventManager';
|
|
@@ -19,69 +19,3 @@ import '@croct/sdk/cid';
|
|
|
19
19
|
import '@croct/json';
|
|
20
20
|
import './versioning.cjs';
|
|
21
21
|
import './component.cjs';
|
|
22
|
-
|
|
23
|
-
interface PluginConfigurations {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
}
|
|
26
|
-
type Configuration = Optional<Configuration$1, 'appId'> & {
|
|
27
|
-
plugins?: PluginConfigurations;
|
|
28
|
-
};
|
|
29
|
-
type FetchOptions<T> = Omit<FetchOptions$1, 'version'> & {
|
|
30
|
-
fallback?: T;
|
|
31
|
-
};
|
|
32
|
-
type FetchResponse<I extends VersionedSlotId, C extends JsonObject = JsonObject, F = never> = {
|
|
33
|
-
content: SlotContent<I, C> | F;
|
|
34
|
-
};
|
|
35
|
-
interface Plug {
|
|
36
|
-
readonly tracker: TrackerFacade;
|
|
37
|
-
readonly user: UserFacade;
|
|
38
|
-
readonly session: SessionFacade;
|
|
39
|
-
readonly initialized: boolean;
|
|
40
|
-
readonly flushed: Promise<this>;
|
|
41
|
-
readonly plugged: Promise<this>;
|
|
42
|
-
plug(configuration: Configuration): void;
|
|
43
|
-
isAnonymous(): boolean;
|
|
44
|
-
getUserId(): string | null;
|
|
45
|
-
identify(userId: string): void;
|
|
46
|
-
anonymize(): void;
|
|
47
|
-
setToken(token: string): void;
|
|
48
|
-
unsetToken(): void;
|
|
49
|
-
track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
|
|
50
|
-
evaluate<T extends JsonValue>(expression: string, options?: EvaluationOptions): Promise<T>;
|
|
51
|
-
fetch<I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I>>): Promise<FetchResponse<I>>;
|
|
52
|
-
fetch<F, I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F>>;
|
|
53
|
-
unplug(): Promise<void>;
|
|
54
|
-
}
|
|
55
|
-
declare class GlobalPlug implements Plug {
|
|
56
|
-
static readonly GLOBAL: GlobalPlug;
|
|
57
|
-
private pluginFactories;
|
|
58
|
-
private instance?;
|
|
59
|
-
private plugins;
|
|
60
|
-
private initialize;
|
|
61
|
-
private ready;
|
|
62
|
-
constructor();
|
|
63
|
-
extend(name: string, plugin: PluginFactory): void;
|
|
64
|
-
plug(configuration?: Configuration): void;
|
|
65
|
-
get initialized(): boolean;
|
|
66
|
-
get plugged(): Promise<this>;
|
|
67
|
-
get flushed(): Promise<this>;
|
|
68
|
-
private get sdk();
|
|
69
|
-
get tracker(): TrackerFacade;
|
|
70
|
-
get evaluator(): EvaluatorFacade;
|
|
71
|
-
get user(): UserFacade;
|
|
72
|
-
get session(): SessionFacade;
|
|
73
|
-
isAnonymous(): boolean;
|
|
74
|
-
getUserId(): string | null;
|
|
75
|
-
identify(userId: string): void;
|
|
76
|
-
anonymize(): void;
|
|
77
|
-
setToken(token: string): void;
|
|
78
|
-
unsetToken(): void;
|
|
79
|
-
track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
|
|
80
|
-
evaluate<T extends JsonValue>(query: string, options?: EvaluationOptions): Promise<T>;
|
|
81
|
-
test(expression: string, options?: EvaluationOptions): Promise<boolean>;
|
|
82
|
-
fetch<I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I>>): Promise<FetchResponse<I>>;
|
|
83
|
-
fetch<F, I extends VersionedSlotId>(slotId: I, options?: FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F>>;
|
|
84
|
-
unplug(): Promise<void>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { type Configuration, type FetchOptions, type FetchResponse, GlobalPlug, type Plug, type PluginConfigurations };
|