@croct/plug 0.20.1 → 0.21.1

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.
@@ -36,11 +36,12 @@ function fetchContent(slotId, options) {
36
36
  const auth = { appId, apiKey };
37
37
  const [id, version = "latest"] = slotId.split("@");
38
38
  const normalizedLocale = preferredLocale === "" ? void 0 : preferredLocale;
39
- const promise = new import_contentFetcher.ContentFetcher({ ...auth, baseEndpointUrl }).fetch(id, {
39
+ const resolvedOptions = {
40
40
  ...fetchOptions,
41
41
  ...normalizedLocale !== void 0 ? { preferredLocale: normalizedLocale } : {},
42
42
  ...version !== "latest" ? { version } : {}
43
- });
43
+ };
44
+ const promise = new import_contentFetcher.ContentFetcher({ ...auth, baseEndpointUrl }).fetch(id, resolvedOptions);
44
45
  return promise.catch(
45
46
  async (error) => {
46
47
  if (logger !== void 0) {
@@ -1,8 +1,8 @@
1
- import { DynamicContentOptions as DynamicContentOptions$1, StaticContentOptions as StaticContentOptions$1 } from '@croct/sdk/contentFetcher';
1
+ import { DynamicContentOptions as DynamicContentOptions$1, StaticContentOptions as StaticContentOptions$1, FetchResponseOptions } from '@croct/sdk/contentFetcher';
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 { F as FetchResponse } from '../plug-Cf6SnDp4.cjs';
5
+ import { F as FetchResponse } from '../plug-CPsFBGem.cjs';
6
6
  import { SlotContent, VersionedSlotId } from '../slot.cjs';
7
7
  import '@croct/sdk/facade/sessionFacade';
8
8
  import '@croct/sdk/facade/userFacade';
@@ -39,6 +39,6 @@ type ClientSideAuthOptions = {
39
39
  type DynamicContentOptions<T extends JsonObject = JsonObject> = Omit<DynamicContentOptions$1, 'version'> & FetchingOptions<T> & AuthOptions;
40
40
  type StaticContentOptions<T extends JsonObject = JsonObject> = Omit<StaticContentOptions$1, 'version'> & FetchingOptions<T> & ServerSideAuthOptions;
41
41
  type FetchOptions<T extends JsonObject = SlotContent> = DynamicContentOptions<T> | StaticContentOptions<T>;
42
- declare function fetchContent<I extends VersionedSlotId, C extends JsonObject>(slotId: I, options?: FetchOptions<SlotContent<I, C>>): Promise<Omit<FetchResponse<I, C>, 'payload'>>;
42
+ declare function fetchContent<I extends VersionedSlotId, C extends JsonObject, O extends FetchResponseOptions = FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I, C>>): Promise<FetchResponse<I, C, never, O>>;
43
43
 
44
44
  export { type DynamicContentOptions, type FetchOptions, FetchResponse, type StaticContentOptions, fetchContent };
@@ -1,8 +1,8 @@
1
- import { DynamicContentOptions as DynamicContentOptions$1, StaticContentOptions as StaticContentOptions$1 } from '@croct/sdk/contentFetcher';
1
+ import { DynamicContentOptions as DynamicContentOptions$1, StaticContentOptions as StaticContentOptions$1, FetchResponseOptions } from '@croct/sdk/contentFetcher';
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 { F as FetchResponse } from '../plug-DjUeWnq0.js';
5
+ import { F as FetchResponse } from '../plug-aoj2L27K.js';
6
6
  import { SlotContent, VersionedSlotId } from '../slot.js';
7
7
  import '@croct/sdk/facade/sessionFacade';
8
8
  import '@croct/sdk/facade/userFacade';
@@ -39,6 +39,6 @@ type ClientSideAuthOptions = {
39
39
  type DynamicContentOptions<T extends JsonObject = JsonObject> = Omit<DynamicContentOptions$1, 'version'> & FetchingOptions<T> & AuthOptions;
40
40
  type StaticContentOptions<T extends JsonObject = JsonObject> = Omit<StaticContentOptions$1, 'version'> & FetchingOptions<T> & ServerSideAuthOptions;
41
41
  type FetchOptions<T extends JsonObject = SlotContent> = DynamicContentOptions<T> | StaticContentOptions<T>;
42
- declare function fetchContent<I extends VersionedSlotId, C extends JsonObject>(slotId: I, options?: FetchOptions<SlotContent<I, C>>): Promise<Omit<FetchResponse<I, C>, 'payload'>>;
42
+ declare function fetchContent<I extends VersionedSlotId, C extends JsonObject, O extends FetchResponseOptions = FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I, C>>): Promise<FetchResponse<I, C, never, O>>;
43
43
 
44
44
  export { type DynamicContentOptions, type FetchOptions, FetchResponse, type StaticContentOptions, fetchContent };
@@ -1,6 +1,4 @@
1
- import {
2
- ContentFetcher
3
- } from "@croct/sdk/contentFetcher";
1
+ import { ContentFetcher } from "@croct/sdk/contentFetcher";
4
2
  import { formatCause } from "@croct/sdk/error";
5
3
  import { loadSlotContent } from "@croct/content";
6
4
  function fetchContent(slotId, options) {
@@ -16,11 +14,12 @@ function fetchContent(slotId, options) {
16
14
  const auth = { appId, apiKey };
17
15
  const [id, version = "latest"] = slotId.split("@");
18
16
  const normalizedLocale = preferredLocale === "" ? void 0 : preferredLocale;
19
- const promise = new ContentFetcher({ ...auth, baseEndpointUrl }).fetch(id, {
17
+ const resolvedOptions = {
20
18
  ...fetchOptions,
21
19
  ...normalizedLocale !== void 0 ? { preferredLocale: normalizedLocale } : {},
22
20
  ...version !== "latest" ? { version } : {}
23
- });
21
+ };
22
+ const promise = new ContentFetcher({ ...auth, baseEndpointUrl }).fetch(id, resolvedOptions);
24
23
  return promise.catch(
25
24
  async (error) => {
26
25
  if (logger !== void 0) {
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 { F as FetchResponse } from '../plug-Cf6SnDp4.cjs';
3
+ export { F as FetchResponse } from '../plug-CPsFBGem.cjs';
4
4
  import '@croct/sdk/evaluator';
5
5
  import '@croct/sdk/apiKey';
6
6
  import '@croct/sdk/logging';
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 { F as FetchResponse } from '../plug-DjUeWnq0.js';
3
+ export { F as FetchResponse } from '../plug-aoj2L27K.js';
4
4
  import '@croct/sdk/evaluator';
5
5
  import '@croct/sdk/apiKey';
6
6
  import '@croct/sdk/logging';
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.20.1.html";
31
+ const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.21.1.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.20.1.html";
5
+ declare const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.21.1.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.20.1.html";
5
+ declare const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.21.1.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.20.1.html";
5
+ const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.21.1.html";
6
6
  export {
7
7
  CDN_URL,
8
8
  PLAYGROUND_CONNECT_URL,
package/global.d.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as Plug } from './plug-Cf6SnDp4.cjs';
1
+ import { P as Plug } from './plug-CPsFBGem.cjs';
2
2
  import '@croct/sdk/facade/sessionFacade';
3
3
  import '@croct/sdk/facade/userFacade';
4
4
  import '@croct/sdk/facade/trackerFacade';
@@ -7,6 +7,7 @@ import '@croct/sdk/facade/sdkFacade';
7
7
  import '@croct/sdk/utilityTypes';
8
8
  import '@croct/sdk/trackingEvents';
9
9
  import '@croct/sdk/facade/contentFetcherFacade';
10
+ import '@croct/sdk/contentFetcher';
10
11
  import '@croct/sdk/token';
11
12
  import './sdk/index.cjs';
12
13
  import '@croct/sdk/eventManager';
package/global.d.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as Plug } from './plug-DjUeWnq0.js';
1
+ import { P as Plug } from './plug-aoj2L27K.js';
2
2
  import '@croct/sdk/facade/sessionFacade';
3
3
  import '@croct/sdk/facade/userFacade';
4
4
  import '@croct/sdk/facade/trackerFacade';
@@ -7,6 +7,7 @@ import '@croct/sdk/facade/sdkFacade';
7
7
  import '@croct/sdk/utilityTypes';
8
8
  import '@croct/sdk/trackingEvents';
9
9
  import '@croct/sdk/facade/contentFetcherFacade';
10
+ import '@croct/sdk/contentFetcher';
10
11
  import '@croct/sdk/token';
11
12
  import './sdk/index.js';
12
13
  import '@croct/sdk/eventManager';
package/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GlobalPlug } from './plug-Cf6SnDp4.cjs';
2
- export { C as Configuration, P as Plug } from './plug-Cf6SnDp4.cjs';
1
+ import { G as GlobalPlug } from './plug-CPsFBGem.cjs';
2
+ export { C as Configuration, F as FetchResponse, P as Plug } from './plug-CPsFBGem.cjs';
3
3
  import '@croct/sdk/facade/sessionFacade';
4
4
  import '@croct/sdk/facade/userFacade';
5
5
  import '@croct/sdk/facade/trackerFacade';
@@ -8,6 +8,7 @@ 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 '@croct/sdk/contentFetcher';
11
12
  import '@croct/sdk/token';
12
13
  import './sdk/index.cjs';
13
14
  import '@croct/sdk/eventManager';
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GlobalPlug } from './plug-DjUeWnq0.js';
2
- export { C as Configuration, P as Plug } from './plug-DjUeWnq0.js';
1
+ import { G as GlobalPlug } from './plug-aoj2L27K.js';
2
+ export { C as Configuration, F as FetchResponse, P as Plug } from './plug-aoj2L27K.js';
3
3
  import '@croct/sdk/facade/sessionFacade';
4
4
  import '@croct/sdk/facade/userFacade';
5
5
  import '@croct/sdk/facade/trackerFacade';
@@ -8,6 +8,7 @@ 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 '@croct/sdk/contentFetcher';
11
12
  import '@croct/sdk/token';
12
13
  import './sdk/index.js';
13
14
  import '@croct/sdk/eventManager';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croct/plug",
3
- "version": "0.20.1",
3
+ "version": "0.21.1",
4
4
  "description": "A fully-featured devkit for building natively personalized applications.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -67,20 +67,21 @@
67
67
  "dependencies": {
68
68
  "@croct/content": "^1.1.0",
69
69
  "@croct/json": "^2.1.0",
70
- "@croct/sdk": "^0.19.1",
70
+ "@croct/sdk": "^0.20.0",
71
71
  "tslib": "^2.7.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@croct/eslint-plugin": "^0.7.1",
74
+ "@croct/eslint-plugin": "^0.8.2",
75
+ "@eslint/eslintrc": "^3.3.3",
75
76
  "@rollup/plugin-commonjs": "^28.0.0",
76
77
  "@rollup/plugin-node-resolve": "^16.0.0",
77
78
  "@rollup/plugin-replace": "^6.0.0",
78
79
  "@rollup/plugin-terser": "^0.4.4",
79
80
  "@rollup/plugin-typescript": "^12.0.0",
80
81
  "@types/jest": "^29.5.12",
81
- "@typescript-eslint/parser": "^6.21.0",
82
+ "@typescript-eslint/parser": "^8.54.0",
82
83
  "esbuild-fix-imports-plugin": "^1.0.19",
83
- "eslint": "^8.27.0",
84
+ "eslint": "^9.39.2",
84
85
  "jest": "^29.3.1",
85
86
  "jest-environment-jsdom": "^29.3.1",
86
87
  "rollup": "^4.0.0",
@@ -6,6 +6,7 @@ import { Configuration as Configuration$1 } from '@croct/sdk/facade/sdkFacade';
6
6
  import { Optional } from '@croct/sdk/utilityTypes';
7
7
  import { ExternalTrackingEventType, ExternalTrackingEventPayload, ExternalTrackingEvent } from '@croct/sdk/trackingEvents';
8
8
  import { FetchOptions as FetchOptions$1 } from '@croct/sdk/facade/contentFetcherFacade';
9
+ import { FetchResponseOptions, FetchResponse as FetchResponse$1 } from '@croct/sdk/contentFetcher';
9
10
  import { TokenStore } from '@croct/sdk/token';
10
11
  import { SdkEventManager } from './sdk/index.cjs';
11
12
  import { VersionedSlotId, SlotContent } from './slot.cjs';
@@ -52,9 +53,7 @@ type Configuration = Optional<Configuration$1, 'appId'> & {
52
53
  type FetchOptions<T> = Omit<FetchOptions$1, 'version'> & {
53
54
  fallback?: T;
54
55
  };
55
- type FetchResponse<I extends VersionedSlotId, C extends JsonObject = JsonObject, F = never> = {
56
- content: SlotContent<I, C> | F;
57
- };
56
+ type FetchResponse<I extends VersionedSlotId, C extends JsonObject = JsonObject, F = never, O extends FetchResponseOptions = FetchResponseOptions> = Optional<FetchResponse$1<SlotContent<I, C> | F, O>, 'metadata'>;
58
57
  interface Plug {
59
58
  readonly tracker: TrackerFacade;
60
59
  readonly user: UserFacade;
@@ -71,8 +70,8 @@ interface Plug {
71
70
  unsetToken(): void;
72
71
  track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
73
72
  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>>;
73
+ fetch<I extends VersionedSlotId, O extends FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I>>): Promise<FetchResponse<I, JsonObject, never, O>>;
74
+ fetch<F, I extends VersionedSlotId, O extends FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F, O>>;
76
75
  unplug(): Promise<void>;
77
76
  }
78
77
  declare class GlobalPlug implements Plug {
@@ -102,9 +101,9 @@ declare class GlobalPlug implements Plug {
102
101
  track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
103
102
  evaluate<T extends JsonValue>(query: string, options?: EvaluationOptions): Promise<T>;
104
103
  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>>;
104
+ fetch<I extends VersionedSlotId, O extends FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I>>): Promise<FetchResponse<I, JsonObject, never, O>>;
105
+ fetch<F, I extends VersionedSlotId, O extends FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F, O>>;
107
106
  unplug(): Promise<void>;
108
107
  }
109
108
 
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 };
109
+ 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 FetchOptions as e, type PluginConfigurations as f };
@@ -6,6 +6,7 @@ import { Configuration as Configuration$1 } from '@croct/sdk/facade/sdkFacade';
6
6
  import { Optional } from '@croct/sdk/utilityTypes';
7
7
  import { ExternalTrackingEventType, ExternalTrackingEventPayload, ExternalTrackingEvent } from '@croct/sdk/trackingEvents';
8
8
  import { FetchOptions as FetchOptions$1 } from '@croct/sdk/facade/contentFetcherFacade';
9
+ import { FetchResponseOptions, FetchResponse as FetchResponse$1 } from '@croct/sdk/contentFetcher';
9
10
  import { TokenStore } from '@croct/sdk/token';
10
11
  import { SdkEventManager } from './sdk/index.js';
11
12
  import { VersionedSlotId, SlotContent } from './slot.js';
@@ -52,9 +53,7 @@ type Configuration = Optional<Configuration$1, 'appId'> & {
52
53
  type FetchOptions<T> = Omit<FetchOptions$1, 'version'> & {
53
54
  fallback?: T;
54
55
  };
55
- type FetchResponse<I extends VersionedSlotId, C extends JsonObject = JsonObject, F = never> = {
56
- content: SlotContent<I, C> | F;
57
- };
56
+ type FetchResponse<I extends VersionedSlotId, C extends JsonObject = JsonObject, F = never, O extends FetchResponseOptions = FetchResponseOptions> = Optional<FetchResponse$1<SlotContent<I, C> | F, O>, 'metadata'>;
58
57
  interface Plug {
59
58
  readonly tracker: TrackerFacade;
60
59
  readonly user: UserFacade;
@@ -71,8 +70,8 @@ interface Plug {
71
70
  unsetToken(): void;
72
71
  track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
73
72
  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>>;
73
+ fetch<I extends VersionedSlotId, O extends FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I>>): Promise<FetchResponse<I, JsonObject, never, O>>;
74
+ fetch<F, I extends VersionedSlotId, O extends FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F, O>>;
76
75
  unplug(): Promise<void>;
77
76
  }
78
77
  declare class GlobalPlug implements Plug {
@@ -102,9 +101,9 @@ declare class GlobalPlug implements Plug {
102
101
  track<T extends ExternalTrackingEventType>(type: T, payload: ExternalTrackingEventPayload<T>): Promise<ExternalTrackingEvent<T>>;
103
102
  evaluate<T extends JsonValue>(query: string, options?: EvaluationOptions): Promise<T>;
104
103
  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>>;
104
+ fetch<I extends VersionedSlotId, O extends FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I>>): Promise<FetchResponse<I, JsonObject, never, O>>;
105
+ fetch<F, I extends VersionedSlotId, O extends FetchResponseOptions>(slotId: I, options?: O & FetchOptions<SlotContent<I> | F>): Promise<FetchResponse<I, JsonObject, F, O>>;
107
106
  unplug(): Promise<void>;
108
107
  }
109
108
 
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 };
109
+ 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 FetchOptions as e, type PluginConfigurations as f };
package/plug.cjs CHANGED
@@ -239,7 +239,9 @@ const _GlobalPlug = class _GlobalPlug {
239
239
  if (resolvedFallback === void 0) {
240
240
  throw error;
241
241
  }
242
- return { content: resolvedFallback };
242
+ return {
243
+ content: resolvedFallback
244
+ };
243
245
  });
244
246
  }
245
247
  async unplug() {
package/plug.d.cts CHANGED
@@ -6,7 +6,8 @@ import '@croct/sdk/facade/sdkFacade';
6
6
  import '@croct/sdk/utilityTypes';
7
7
  import '@croct/sdk/trackingEvents';
8
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';
9
+ import '@croct/sdk/contentFetcher';
10
+ export { C as Configuration, e as FetchOptions, F as FetchResponse, G as GlobalPlug, P as Plug, f as PluginConfigurations } from './plug-CPsFBGem.cjs';
10
11
  import './slot.cjs';
11
12
  import '@croct/json/mutable';
12
13
  import '@croct/sdk/token';
package/plug.d.ts CHANGED
@@ -6,7 +6,8 @@ import '@croct/sdk/facade/sdkFacade';
6
6
  import '@croct/sdk/utilityTypes';
7
7
  import '@croct/sdk/trackingEvents';
8
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-DjUeWnq0.js';
9
+ import '@croct/sdk/contentFetcher';
10
+ export { C as Configuration, e as FetchOptions, F as FetchResponse, G as GlobalPlug, P as Plug, f as PluginConfigurations } from './plug-aoj2L27K.js';
10
11
  import './slot.js';
11
12
  import '@croct/json/mutable';
12
13
  import '@croct/sdk/token';
package/plug.js CHANGED
@@ -217,7 +217,9 @@ const _GlobalPlug = class _GlobalPlug {
217
217
  if (resolvedFallback === void 0) {
218
218
  throw error;
219
219
  }
220
- return { content: resolvedFallback };
220
+ return {
221
+ content: resolvedFallback
222
+ };
221
223
  });
222
224
  }
223
225
  async unplug() {
package/plugin.d.cts CHANGED
@@ -2,7 +2,7 @@ import '@croct/sdk/token';
2
2
  import '@croct/sdk/facade/evaluatorFacade';
3
3
  import '@croct/sdk/facade/trackerFacade';
4
4
  import './sdk/index.cjs';
5
- export { a as Plugin, b as PluginArguments, c as PluginFactory, d as PluginSdk } from './plug-Cf6SnDp4.cjs';
5
+ export { a as Plugin, b as PluginArguments, c as PluginFactory, d as PluginSdk } from './plug-CPsFBGem.cjs';
6
6
  import '@croct/sdk/facade/userFacade';
7
7
  import '@croct/sdk/facade/sessionFacade';
8
8
  import '@croct/sdk/tab';
@@ -14,6 +14,7 @@ import '@croct/sdk/facade/sdkFacade';
14
14
  import '@croct/sdk/utilityTypes';
15
15
  import '@croct/sdk/trackingEvents';
16
16
  import '@croct/sdk/facade/contentFetcherFacade';
17
+ import '@croct/sdk/contentFetcher';
17
18
  import './slot.cjs';
18
19
  import '@croct/json';
19
20
  import './versioning.cjs';
package/plugin.d.ts CHANGED
@@ -2,7 +2,7 @@ import '@croct/sdk/token';
2
2
  import '@croct/sdk/facade/evaluatorFacade';
3
3
  import '@croct/sdk/facade/trackerFacade';
4
4
  import './sdk/index.js';
5
- export { a as Plugin, b as PluginArguments, c as PluginFactory, d as PluginSdk } from './plug-DjUeWnq0.js';
5
+ export { a as Plugin, b as PluginArguments, c as PluginFactory, d as PluginSdk } from './plug-aoj2L27K.js';
6
6
  import '@croct/sdk/facade/userFacade';
7
7
  import '@croct/sdk/facade/sessionFacade';
8
8
  import '@croct/sdk/tab';
@@ -14,6 +14,7 @@ import '@croct/sdk/facade/sdkFacade';
14
14
  import '@croct/sdk/utilityTypes';
15
15
  import '@croct/sdk/trackingEvents';
16
16
  import '@croct/sdk/facade/contentFetcherFacade';
17
+ import '@croct/sdk/contentFetcher';
17
18
  import './slot.js';
18
19
  import '@croct/json';
19
20
  import './versioning.js';
@@ -24,11 +24,13 @@ module.exports = __toCommonJS(autoTracking_exports);
24
24
  var import_structuredData = require('./structuredData.cjs');
25
25
  class AutoTrackingPlugin {
26
26
  constructor(configuration) {
27
+ this.scanTimeout = null;
27
28
  this.tab = configuration.tab;
28
29
  this.tracker = configuration.tracker;
29
30
  this.options = configuration.options;
30
31
  this.trackStructuredData = this.trackStructuredData.bind(this);
31
32
  this.trackLinkOpened = this.trackLinkOpened.bind(this);
33
+ this.handleUrlChange = this.handleUrlChange.bind(this);
32
34
  }
33
35
  isDisabled() {
34
36
  return this.options?.disablePostViewed === true && this.options?.disableProductViewed === true && this.options?.disableLinkOpened === true;
@@ -38,15 +40,31 @@ class AutoTrackingPlugin {
38
40
  return;
39
41
  }
40
42
  this.trackStructuredData();
41
- this.tab.addListener("urlChange", this.trackStructuredData);
43
+ this.tab.addListener("urlChange", this.handleUrlChange);
42
44
  if (this.options?.disableLinkOpened !== true) {
43
45
  document.addEventListener("click", this.trackLinkOpened, true);
44
46
  }
45
47
  }
46
48
  disable() {
47
- this.tab.removeListener("urlChange", this.trackStructuredData);
49
+ if (this.scanTimeout !== null) {
50
+ clearTimeout(this.scanTimeout);
51
+ this.scanTimeout = null;
52
+ }
53
+ this.tab.removeListener("urlChange", this.handleUrlChange);
48
54
  document.removeEventListener("click", this.trackLinkOpened, true);
49
55
  }
56
+ handleUrlChange() {
57
+ if (this.scanTimeout !== null) {
58
+ clearTimeout(this.scanTimeout);
59
+ }
60
+ this.scanTimeout = setTimeout(
61
+ () => {
62
+ this.scanTimeout = null;
63
+ this.trackStructuredData();
64
+ },
65
+ 1e3
66
+ );
67
+ }
50
68
  trackStructuredData() {
51
69
  const structuredDataElements = document.querySelectorAll('script[type="application/ld+json"]');
52
70
  for (const element of structuredDataElements) {
@@ -136,11 +154,11 @@ class AutoTrackingPlugin {
136
154
  return result;
137
155
  }
138
156
  }
139
- const factory = (props) => new AutoTrackingPlugin({
157
+ const factory = ((props) => new AutoTrackingPlugin({
140
158
  tab: props.sdk.tab,
141
159
  tracker: props.sdk.tracker,
142
160
  options: props.options
143
- });
161
+ }));
144
162
  // Annotate the CommonJS export names for ESM import in node:
145
163
  0 && (module.exports = {
146
164
  AutoTrackingPlugin,
@@ -1,4 +1,4 @@
1
- import { a as Plugin, b as PluginArguments } from '../../plug-Cf6SnDp4.cjs';
1
+ import { a as Plugin, b as PluginArguments } from '../../plug-CPsFBGem.cjs';
2
2
  import { TrackerFacade } from '@croct/sdk/facade/trackerFacade';
3
3
  import { Tab } from '@croct/sdk/tab';
4
4
  import '@croct/sdk/facade/sessionFacade';
@@ -8,6 +8,7 @@ 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 '@croct/sdk/contentFetcher';
11
12
  import '@croct/sdk/token';
12
13
  import '../../sdk/index.cjs';
13
14
  import '@croct/sdk/eventManager';
@@ -34,10 +35,12 @@ declare class AutoTrackingPlugin implements Plugin {
34
35
  private readonly tab;
35
36
  private readonly tracker;
36
37
  private readonly options?;
38
+ private scanTimeout;
37
39
  constructor(configuration: Configuration);
38
40
  private isDisabled;
39
41
  enable(): void;
40
42
  disable(): void;
43
+ private handleUrlChange;
41
44
  private trackStructuredData;
42
45
  private trackPostViewed;
43
46
  private trackProductViewed;
@@ -1,4 +1,4 @@
1
- import { a as Plugin, b as PluginArguments } from '../../plug-DjUeWnq0.js';
1
+ import { a as Plugin, b as PluginArguments } from '../../plug-aoj2L27K.js';
2
2
  import { TrackerFacade } from '@croct/sdk/facade/trackerFacade';
3
3
  import { Tab } from '@croct/sdk/tab';
4
4
  import '@croct/sdk/facade/sessionFacade';
@@ -8,6 +8,7 @@ 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 '@croct/sdk/contentFetcher';
11
12
  import '@croct/sdk/token';
12
13
  import '../../sdk/index.js';
13
14
  import '@croct/sdk/eventManager';
@@ -34,10 +35,12 @@ declare class AutoTrackingPlugin implements Plugin {
34
35
  private readonly tab;
35
36
  private readonly tracker;
36
37
  private readonly options?;
38
+ private scanTimeout;
37
39
  constructor(configuration: Configuration);
38
40
  private isDisabled;
39
41
  enable(): void;
40
42
  disable(): void;
43
+ private handleUrlChange;
41
44
  private trackStructuredData;
42
45
  private trackPostViewed;
43
46
  private trackProductViewed;
@@ -1,11 +1,13 @@
1
1
  import { parseEntity } from "./structuredData.js";
2
2
  class AutoTrackingPlugin {
3
3
  constructor(configuration) {
4
+ this.scanTimeout = null;
4
5
  this.tab = configuration.tab;
5
6
  this.tracker = configuration.tracker;
6
7
  this.options = configuration.options;
7
8
  this.trackStructuredData = this.trackStructuredData.bind(this);
8
9
  this.trackLinkOpened = this.trackLinkOpened.bind(this);
10
+ this.handleUrlChange = this.handleUrlChange.bind(this);
9
11
  }
10
12
  isDisabled() {
11
13
  return this.options?.disablePostViewed === true && this.options?.disableProductViewed === true && this.options?.disableLinkOpened === true;
@@ -15,15 +17,31 @@ class AutoTrackingPlugin {
15
17
  return;
16
18
  }
17
19
  this.trackStructuredData();
18
- this.tab.addListener("urlChange", this.trackStructuredData);
20
+ this.tab.addListener("urlChange", this.handleUrlChange);
19
21
  if (this.options?.disableLinkOpened !== true) {
20
22
  document.addEventListener("click", this.trackLinkOpened, true);
21
23
  }
22
24
  }
23
25
  disable() {
24
- this.tab.removeListener("urlChange", this.trackStructuredData);
26
+ if (this.scanTimeout !== null) {
27
+ clearTimeout(this.scanTimeout);
28
+ this.scanTimeout = null;
29
+ }
30
+ this.tab.removeListener("urlChange", this.handleUrlChange);
25
31
  document.removeEventListener("click", this.trackLinkOpened, true);
26
32
  }
33
+ handleUrlChange() {
34
+ if (this.scanTimeout !== null) {
35
+ clearTimeout(this.scanTimeout);
36
+ }
37
+ this.scanTimeout = setTimeout(
38
+ () => {
39
+ this.scanTimeout = null;
40
+ this.trackStructuredData();
41
+ },
42
+ 1e3
43
+ );
44
+ }
27
45
  trackStructuredData() {
28
46
  const structuredDataElements = document.querySelectorAll('script[type="application/ld+json"]');
29
47
  for (const element of structuredDataElements) {
@@ -113,11 +131,11 @@ class AutoTrackingPlugin {
113
131
  return result;
114
132
  }
115
133
  }
116
- const factory = (props) => new AutoTrackingPlugin({
134
+ const factory = ((props) => new AutoTrackingPlugin({
117
135
  tab: props.sdk.tab,
118
136
  tracker: props.sdk.tracker,
119
137
  options: props.options
120
- });
138
+ }));
121
139
  export {
122
140
  AutoTrackingPlugin,
123
141
  factory
@@ -56,7 +56,7 @@ class GlobalVariablePlugin {
56
56
  }
57
57
  }
58
58
  }
59
- const factory = (props) => new GlobalVariablePlugin({ plug: props.sdk.plug });
59
+ const factory = ((props) => new GlobalVariablePlugin({ plug: props.sdk.plug }));
60
60
  // Annotate the CommonJS export names for ESM import in node:
61
61
  0 && (module.exports = {
62
62
  GlobalVariablePlugin,
@@ -1,4 +1,4 @@
1
- import { P as Plug, a as Plugin, b as PluginArguments } from '../../plug-Cf6SnDp4.cjs';
1
+ import { P as Plug, a as Plugin, b as PluginArguments } from '../../plug-CPsFBGem.cjs';
2
2
  import '@croct/sdk/facade/sessionFacade';
3
3
  import '@croct/sdk/facade/userFacade';
4
4
  import '@croct/sdk/facade/trackerFacade';
@@ -7,6 +7,7 @@ import '@croct/sdk/facade/sdkFacade';
7
7
  import '@croct/sdk/utilityTypes';
8
8
  import '@croct/sdk/trackingEvents';
9
9
  import '@croct/sdk/facade/contentFetcherFacade';
10
+ import '@croct/sdk/contentFetcher';
10
11
  import '@croct/sdk/token';
11
12
  import '../../sdk/index.cjs';
12
13
  import '@croct/sdk/eventManager';
@@ -1,4 +1,4 @@
1
- import { P as Plug, a as Plugin, b as PluginArguments } from '../../plug-DjUeWnq0.js';
1
+ import { P as Plug, a as Plugin, b as PluginArguments } from '../../plug-aoj2L27K.js';
2
2
  import '@croct/sdk/facade/sessionFacade';
3
3
  import '@croct/sdk/facade/userFacade';
4
4
  import '@croct/sdk/facade/trackerFacade';
@@ -7,6 +7,7 @@ import '@croct/sdk/facade/sdkFacade';
7
7
  import '@croct/sdk/utilityTypes';
8
8
  import '@croct/sdk/trackingEvents';
9
9
  import '@croct/sdk/facade/contentFetcherFacade';
10
+ import '@croct/sdk/contentFetcher';
10
11
  import '@croct/sdk/token';
11
12
  import '../../sdk/index.js';
12
13
  import '@croct/sdk/eventManager';
@@ -33,7 +33,7 @@ class GlobalVariablePlugin {
33
33
  }
34
34
  }
35
35
  }
36
- const factory = (props) => new GlobalVariablePlugin({ plug: props.sdk.plug });
36
+ const factory = ((props) => new GlobalVariablePlugin({ plug: props.sdk.plug }));
37
37
  export {
38
38
  GlobalVariablePlugin,
39
39
  factory
@@ -1,5 +1,5 @@
1
1
  import { Logger } from '@croct/sdk/logging';
2
- import { a as Plugin, c as PluginFactory } from '../../plug-Cf6SnDp4.cjs';
2
+ import { a as Plugin, c as PluginFactory } from '../../plug-CPsFBGem.cjs';
3
3
  import { TokenStore } from '@croct/sdk/token';
4
4
  import '@croct/sdk/facade/sessionFacade';
5
5
  import '@croct/sdk/facade/userFacade';
@@ -9,6 +9,7 @@ import '@croct/sdk/facade/sdkFacade';
9
9
  import '@croct/sdk/utilityTypes';
10
10
  import '@croct/sdk/trackingEvents';
11
11
  import '@croct/sdk/facade/contentFetcherFacade';
12
+ import '@croct/sdk/contentFetcher';
12
13
  import '../../sdk/index.cjs';
13
14
  import '@croct/sdk/eventManager';
14
15
  import '@croct/sdk/sdkEvents';
@@ -1,5 +1,5 @@
1
1
  import { Logger } from '@croct/sdk/logging';
2
- import { a as Plugin, c as PluginFactory } from '../../plug-DjUeWnq0.js';
2
+ import { a as Plugin, c as PluginFactory } from '../../plug-aoj2L27K.js';
3
3
  import { TokenStore } from '@croct/sdk/token';
4
4
  import '@croct/sdk/facade/sessionFacade';
5
5
  import '@croct/sdk/facade/userFacade';
@@ -9,6 +9,7 @@ import '@croct/sdk/facade/sdkFacade';
9
9
  import '@croct/sdk/utilityTypes';
10
10
  import '@croct/sdk/trackingEvents';
11
11
  import '@croct/sdk/facade/contentFetcherFacade';
12
+ import '@croct/sdk/contentFetcher';
12
13
  import '../../sdk/index.js';
13
14
  import '@croct/sdk/eventManager';
14
15
  import '@croct/sdk/sdkEvents';
package/sdk/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { EventManager, EventListener, EventDispatcher, EventSubscriber } from '@croct/sdk/eventManager';
1
+ import { EventManager, EventDispatcher, EventListener, EventSubscriber } from '@croct/sdk/eventManager';
2
2
  import { SdkEventMap, SdkEventType } from '@croct/sdk/sdkEvents';
3
3
  export { SdkEvent, SdkEventType } from '@croct/sdk/sdkEvents';
4
4
  export { Logger } from '@croct/sdk/logging';
package/sdk/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { EventManager, EventListener, EventDispatcher, EventSubscriber } from '@croct/sdk/eventManager';
1
+ import { EventManager, EventDispatcher, EventListener, EventSubscriber } from '@croct/sdk/eventManager';
2
2
  import { SdkEventMap, SdkEventType } from '@croct/sdk/sdkEvents';
3
3
  export { SdkEvent, SdkEventType } from '@croct/sdk/sdkEvents';
4
4
  export { Logger } from '@croct/sdk/logging';