@croct/plug 0.16.4 → 0.17.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/api/evaluate.cjs +45 -0
- package/api/evaluate.d.cts +23 -0
- package/api/evaluate.d.ts +9 -7
- package/api/evaluate.js +20 -22
- package/api/fetchContent.cjs +53 -0
- package/api/fetchContent.d.cts +45 -0
- package/api/fetchContent.d.ts +31 -11
- package/api/fetchContent.js +29 -21
- package/api/index.cjs +23 -0
- package/api/index.d.cts +27 -0
- package/api/index.d.ts +27 -2
- package/api/index.js +2 -6
- package/component.cjs +15 -0
- package/component.d.cts +19 -0
- package/component.d.ts +12 -9
- package/component.js +0 -3
- package/constants.cjs +39 -0
- package/constants.d.cts +7 -0
- package/constants.d.ts +7 -5
- package/constants.js +12 -9
- package/index.cjs +24 -0
- package/index.d.cts +27 -0
- package/index.d.ts +26 -3
- package/index.js +5 -6
- package/package.json +33 -6
- package/playground.cjs +166 -0
- package/playground.d.cts +64 -0
- package/playground.d.ts +18 -8
- package/playground.js +130 -138
- package/plug.cjs +271 -0
- package/plug.d.cts +86 -0
- package/plug.d.ts +34 -17
- package/plug.js +243 -256
- package/plugin.cjs +15 -0
- package/plugin.d.cts +41 -0
- package/plugin.d.ts +18 -8
- package/plugin.js +0 -3
- package/preview.cjs +180 -0
- package/preview.d.cts +35 -0
- package/preview.d.ts +18 -6
- package/preview.js +143 -152
- package/sdk/apiKey.cjs +21 -0
- package/sdk/apiKey.js +1 -5
- package/sdk/evaluation.cjs +34 -0
- package/sdk/evaluation.d.cts +2 -0
- package/sdk/evaluation.d.ts +1 -1
- package/sdk/evaluation.js +8 -10
- package/sdk/index.cjs +33 -0
- package/sdk/index.d.cts +15 -0
- package/sdk/index.d.ts +9 -6
- package/sdk/index.js +8 -10
- package/sdk/json.cjs +15 -0
- package/sdk/json.d.cts +6 -0
- package/sdk/json.d.ts +4 -1
- package/sdk/json.js +0 -5
- package/sdk/sdkEvents.cjs +15 -0
- package/sdk/sdkEvents.d.cts +1 -0
- package/sdk/sdkEvents.js +0 -3
- package/sdk/token.cjs +27 -0
- package/sdk/token.d.cts +7 -0
- package/sdk/token.d.ts +7 -1
- package/sdk/token.js +4 -6
- package/sdk/tracking.cjs +27 -0
- package/sdk/tracking.d.cts +9 -0
- package/sdk/tracking.d.ts +8 -5
- package/sdk/tracking.js +4 -6
- package/sdk/validation.cjs +23 -0
- package/sdk/validation.js +2 -6
- package/slot.cjs +15 -0
- package/slot.d.cts +42 -0
- package/slot.d.ts +14 -12
- package/slot.js +0 -3
- package/versioning.cjs +15 -0
- package/versioning.d.cts +26 -0
- package/versioning.d.ts +8 -6
- package/versioning.js +0 -3
- package/api/evaluate.js.map +0 -1
- package/api/fetchContent.js.map +0 -1
- package/api/index.js.map +0 -1
- package/component.js.map +0 -1
- package/constants.js.map +0 -1
- package/index.js.map +0 -1
- package/playground.js.map +0 -1
- package/plug.js.map +0 -1
- package/plugin.js.map +0 -1
- package/preview.js.map +0 -1
- package/sdk/apiKey.js.map +0 -1
- package/sdk/evaluation.js.map +0 -1
- package/sdk/index.js.map +0 -1
- package/sdk/json.js.map +0 -1
- package/sdk/sdkEvents.js.map +0 -1
- package/sdk/token.js.map +0 -1
- package/sdk/tracking.js.map +0 -1
- package/sdk/validation.js.map +0 -1
- package/slot.js.map +0 -1
- package/src/api/evaluate.ts +0 -50
- package/src/api/fetchContent.ts +0 -70
- package/src/api/index.ts +0 -2
- package/src/component.ts +0 -19
- package/src/constants.ts +0 -5
- package/src/index.ts +0 -6
- package/src/playground.ts +0 -247
- package/src/plug.ts +0 -429
- package/src/plugin.ts +0 -39
- package/src/preview.ts +0 -226
- package/src/sdk/evaluation.ts +0 -2
- package/src/sdk/index.ts +0 -14
- package/src/sdk/json.ts +0 -4
- package/src/sdk/sdkEvents.ts +0 -1
- package/src/sdk/token.ts +0 -1
- package/src/sdk/tracking.ts +0 -14
- package/src/slot.ts +0 -48
- package/src/versioning.ts +0 -38
- package/versioning.js.map +0 -1
- /package/{src/sdk/apiKey.ts → sdk/apiKey.d.cts} +0 -0
- /package/{src/sdk/validation.ts → sdk/validation.d.cts} +0 -0
package/api/evaluate.cjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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 evaluate_exports = {};
|
|
19
|
+
__export(evaluate_exports, {
|
|
20
|
+
evaluate: () => evaluate
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(evaluate_exports);
|
|
23
|
+
var import_evaluator = require("@croct/sdk/evaluator");
|
|
24
|
+
var import_error = require("@croct/sdk/error");
|
|
25
|
+
function evaluate(query, options) {
|
|
26
|
+
const { baseEndpointUrl, fallback, apiKey, appId, logger, ...evaluation } = options;
|
|
27
|
+
const auth = apiKey !== void 0 ? { apiKey } : { appId };
|
|
28
|
+
const promise = new import_evaluator.Evaluator({ ...auth, baseEndpointUrl }).evaluate(query, evaluation);
|
|
29
|
+
if (fallback !== void 0) {
|
|
30
|
+
return promise.catch(
|
|
31
|
+
(error) => {
|
|
32
|
+
if (logger !== void 0) {
|
|
33
|
+
const reference = query.length > 20 ? `${query.slice(0, 20)}...` : query;
|
|
34
|
+
logger.error(`Failed to evaluate query "${reference}": ${(0, import_error.formatCause)(error)}`);
|
|
35
|
+
}
|
|
36
|
+
return fallback;
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return promise;
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
evaluate
|
|
45
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EvaluationOptions as EvaluationOptions$1 } from '@croct/sdk/evaluator';
|
|
2
|
+
import { ApiKey } from '@croct/sdk/apiKey';
|
|
3
|
+
import { Logger } from '@croct/sdk/logging';
|
|
4
|
+
import { JsonValue } from '@croct/json/mutable';
|
|
5
|
+
|
|
6
|
+
type EvaluationOptions<T extends JsonValue = JsonValue> = EvaluationOptions$1 & AuthOptions & FetchingOptions<T>;
|
|
7
|
+
type FetchingOptions<T extends JsonValue> = {
|
|
8
|
+
baseEndpointUrl?: string;
|
|
9
|
+
fallback?: T;
|
|
10
|
+
logger?: Logger;
|
|
11
|
+
};
|
|
12
|
+
type AuthOptions = ServerSideAuthOptions | ClientSideAuthOptions;
|
|
13
|
+
type ServerSideAuthOptions = {
|
|
14
|
+
apiKey: string | ApiKey;
|
|
15
|
+
appId?: never;
|
|
16
|
+
};
|
|
17
|
+
type ClientSideAuthOptions = {
|
|
18
|
+
appId: string;
|
|
19
|
+
apiKey?: never;
|
|
20
|
+
};
|
|
21
|
+
declare function evaluate<T extends JsonValue>(query: string, options: EvaluationOptions<T>): Promise<T>;
|
|
22
|
+
|
|
23
|
+
export { type EvaluationOptions, evaluate };
|
package/api/evaluate.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { EvaluationOptions as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { JsonValue } from '
|
|
5
|
-
|
|
1
|
+
import { EvaluationOptions as EvaluationOptions$1 } from '@croct/sdk/evaluator';
|
|
2
|
+
import { ApiKey } from '@croct/sdk/apiKey';
|
|
3
|
+
import { Logger } from '@croct/sdk/logging';
|
|
4
|
+
import { JsonValue } from '@croct/json/mutable';
|
|
5
|
+
|
|
6
|
+
type EvaluationOptions<T extends JsonValue = JsonValue> = EvaluationOptions$1 & AuthOptions & FetchingOptions<T>;
|
|
6
7
|
type FetchingOptions<T extends JsonValue> = {
|
|
7
8
|
baseEndpointUrl?: string;
|
|
8
9
|
fallback?: T;
|
|
@@ -17,5 +18,6 @@ type ClientSideAuthOptions = {
|
|
|
17
18
|
appId: string;
|
|
18
19
|
apiKey?: never;
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
declare function evaluate<T extends JsonValue>(query: string, options: EvaluationOptions<T>): Promise<T>;
|
|
22
|
+
|
|
23
|
+
export { type EvaluationOptions, evaluate };
|
package/api/evaluate.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.evaluate = evaluate;
|
|
4
|
-
const evaluator_1 = require("@croct/sdk/evaluator");
|
|
5
|
-
const error_1 = require("@croct/sdk/error");
|
|
1
|
+
import { Evaluator } from "@croct/sdk/evaluator";
|
|
2
|
+
import { formatCause } from "@croct/sdk/error";
|
|
6
3
|
function evaluate(query, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return promise;
|
|
4
|
+
const { baseEndpointUrl, fallback, apiKey, appId, logger, ...evaluation } = options;
|
|
5
|
+
const auth = apiKey !== void 0 ? { apiKey } : { appId };
|
|
6
|
+
const promise = new Evaluator({ ...auth, baseEndpointUrl }).evaluate(query, evaluation);
|
|
7
|
+
if (fallback !== void 0) {
|
|
8
|
+
return promise.catch(
|
|
9
|
+
(error) => {
|
|
10
|
+
if (logger !== void 0) {
|
|
11
|
+
const reference = query.length > 20 ? `${query.slice(0, 20)}...` : query;
|
|
12
|
+
logger.error(`Failed to evaluate query "${reference}": ${formatCause(error)}`);
|
|
13
|
+
}
|
|
14
|
+
return fallback;
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return promise;
|
|
23
19
|
}
|
|
24
|
-
|
|
20
|
+
export {
|
|
21
|
+
evaluate
|
|
22
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
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 fetchContent_exports = {};
|
|
19
|
+
__export(fetchContent_exports, {
|
|
20
|
+
fetchContent: () => fetchContent
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(fetchContent_exports);
|
|
23
|
+
var import_contentFetcher = require("@croct/sdk/contentFetcher");
|
|
24
|
+
var import_error = require("@croct/sdk/error");
|
|
25
|
+
var import_content = require("@croct/content");
|
|
26
|
+
function fetchContent(slotId, options) {
|
|
27
|
+
const { apiKey, appId, fallback, baseEndpointUrl, logger, ...fetchOptions } = options ?? {};
|
|
28
|
+
const auth = { appId, apiKey };
|
|
29
|
+
const [id, version = "latest"] = slotId.split("@");
|
|
30
|
+
const promise = new import_contentFetcher.ContentFetcher({ ...auth, baseEndpointUrl }).fetch(
|
|
31
|
+
id,
|
|
32
|
+
version === "latest" ? fetchOptions : { ...fetchOptions, version }
|
|
33
|
+
);
|
|
34
|
+
return promise.catch(
|
|
35
|
+
async (error) => {
|
|
36
|
+
if (logger !== void 0) {
|
|
37
|
+
logger.error(`Failed to fetch content for slot "${id}@${version}": ${(0, import_error.formatCause)(error)}`);
|
|
38
|
+
}
|
|
39
|
+
if (fallback !== void 0) {
|
|
40
|
+
return { content: fallback };
|
|
41
|
+
}
|
|
42
|
+
const staticContent = await (0, import_content.loadSlotContent)(id, fetchOptions.preferredLocale);
|
|
43
|
+
if (staticContent === null) {
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
return { content: staticContent };
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
fetchContent
|
|
53
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DynamicContentOptions as DynamicContentOptions$1, StaticContentOptions as StaticContentOptions$1 } from '@croct/sdk/contentFetcher';
|
|
2
|
+
import { ApiKey } from '@croct/sdk/apiKey';
|
|
3
|
+
import { Logger } from '@croct/sdk/logging';
|
|
4
|
+
import { JsonObject, JsonValue } from '@croct/json/mutable';
|
|
5
|
+
import { FetchResponse } from '../plug.cjs';
|
|
6
|
+
import { SlotContent, VersionedSlotId } from '../slot.cjs';
|
|
7
|
+
import '@croct/sdk/facade/sessionFacade';
|
|
8
|
+
import '@croct/sdk/facade/userFacade';
|
|
9
|
+
import '@croct/sdk/facade/trackerFacade';
|
|
10
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
11
|
+
import '@croct/sdk/facade/sdkFacade';
|
|
12
|
+
import '@croct/sdk/utilityTypes';
|
|
13
|
+
import '@croct/sdk/trackingEvents';
|
|
14
|
+
import '@croct/sdk/facade/contentFetcherFacade';
|
|
15
|
+
import '../plugin.cjs';
|
|
16
|
+
import '@croct/sdk/token';
|
|
17
|
+
import '../sdk/index.cjs';
|
|
18
|
+
import '@croct/sdk/eventManager';
|
|
19
|
+
import '@croct/sdk/sdkEvents';
|
|
20
|
+
import '@croct/sdk/tab';
|
|
21
|
+
import '@croct/sdk/cid';
|
|
22
|
+
import '@croct/json';
|
|
23
|
+
import '../versioning.cjs';
|
|
24
|
+
import '../component.cjs';
|
|
25
|
+
|
|
26
|
+
type FetchingOptions<T extends JsonValue> = {
|
|
27
|
+
baseEndpointUrl?: string;
|
|
28
|
+
fallback?: T;
|
|
29
|
+
logger?: Logger;
|
|
30
|
+
};
|
|
31
|
+
type AuthOptions = ServerSideAuthOptions | ClientSideAuthOptions;
|
|
32
|
+
type ServerSideAuthOptions = {
|
|
33
|
+
apiKey: string | ApiKey;
|
|
34
|
+
appId?: never;
|
|
35
|
+
};
|
|
36
|
+
type ClientSideAuthOptions = {
|
|
37
|
+
appId: string;
|
|
38
|
+
apiKey?: never;
|
|
39
|
+
};
|
|
40
|
+
type DynamicContentOptions<T extends JsonObject = JsonObject> = Omit<DynamicContentOptions$1, 'version'> & FetchingOptions<T> & AuthOptions;
|
|
41
|
+
type StaticContentOptions<T extends JsonObject = JsonObject> = Omit<StaticContentOptions$1, 'version'> & FetchingOptions<T> & ServerSideAuthOptions;
|
|
42
|
+
type FetchOptions<T extends JsonObject = SlotContent> = DynamicContentOptions<T> | StaticContentOptions<T>;
|
|
43
|
+
declare function fetchContent<I extends VersionedSlotId, C extends JsonObject>(slotId: I, options?: FetchOptions<SlotContent<I, C>>): Promise<Omit<FetchResponse<I, C>, 'payload'>>;
|
|
44
|
+
|
|
45
|
+
export { type DynamicContentOptions, type FetchOptions, FetchResponse, type StaticContentOptions, fetchContent };
|
package/api/fetchContent.d.ts
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import { DynamicContentOptions as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { JsonObject, JsonValue } from '
|
|
5
|
-
import { FetchResponse } from '../plug';
|
|
6
|
-
import { SlotContent, VersionedSlotId } from '../slot';
|
|
7
|
-
|
|
1
|
+
import { DynamicContentOptions as DynamicContentOptions$1, StaticContentOptions as StaticContentOptions$1 } from '@croct/sdk/contentFetcher';
|
|
2
|
+
import { ApiKey } from '@croct/sdk/apiKey';
|
|
3
|
+
import { Logger } from '@croct/sdk/logging';
|
|
4
|
+
import { JsonObject, JsonValue } from '@croct/json/mutable';
|
|
5
|
+
import { FetchResponse } from '../plug.js';
|
|
6
|
+
import { SlotContent, VersionedSlotId } from '../slot.js';
|
|
7
|
+
import '@croct/sdk/facade/sessionFacade';
|
|
8
|
+
import '@croct/sdk/facade/userFacade';
|
|
9
|
+
import '@croct/sdk/facade/trackerFacade';
|
|
10
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
11
|
+
import '@croct/sdk/facade/sdkFacade';
|
|
12
|
+
import '@croct/sdk/utilityTypes';
|
|
13
|
+
import '@croct/sdk/trackingEvents';
|
|
14
|
+
import '@croct/sdk/facade/contentFetcherFacade';
|
|
15
|
+
import '../plugin.js';
|
|
16
|
+
import '@croct/sdk/token';
|
|
17
|
+
import '../sdk/index.js';
|
|
18
|
+
import '@croct/sdk/eventManager';
|
|
19
|
+
import '@croct/sdk/sdkEvents';
|
|
20
|
+
import '@croct/sdk/tab';
|
|
21
|
+
import '@croct/sdk/cid';
|
|
22
|
+
import '@croct/json';
|
|
23
|
+
import '../versioning.js';
|
|
24
|
+
import '../component.js';
|
|
25
|
+
|
|
8
26
|
type FetchingOptions<T extends JsonValue> = {
|
|
9
27
|
baseEndpointUrl?: string;
|
|
10
28
|
fallback?: T;
|
|
@@ -19,7 +37,9 @@ type ClientSideAuthOptions = {
|
|
|
19
37
|
appId: string;
|
|
20
38
|
apiKey?: never;
|
|
21
39
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
40
|
+
type DynamicContentOptions<T extends JsonObject = JsonObject> = Omit<DynamicContentOptions$1, 'version'> & FetchingOptions<T> & AuthOptions;
|
|
41
|
+
type StaticContentOptions<T extends JsonObject = JsonObject> = Omit<StaticContentOptions$1, 'version'> & FetchingOptions<T> & ServerSideAuthOptions;
|
|
42
|
+
type FetchOptions<T extends JsonObject = SlotContent> = DynamicContentOptions<T> | StaticContentOptions<T>;
|
|
43
|
+
declare function fetchContent<I extends VersionedSlotId, C extends JsonObject>(slotId: I, options?: FetchOptions<SlotContent<I, C>>): Promise<Omit<FetchResponse<I, C>, 'payload'>>;
|
|
44
|
+
|
|
45
|
+
export { type DynamicContentOptions, type FetchOptions, FetchResponse, type StaticContentOptions, fetchContent };
|
package/api/fetchContent.js
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
ContentFetcher
|
|
3
|
+
} from "@croct/sdk/contentFetcher";
|
|
4
|
+
import { formatCause } from "@croct/sdk/error";
|
|
5
|
+
import { loadSlotContent } from "@croct/content";
|
|
6
6
|
function fetchContent(slotId, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
7
|
+
const { apiKey, appId, fallback, baseEndpointUrl, logger, ...fetchOptions } = options ?? {};
|
|
8
|
+
const auth = { appId, apiKey };
|
|
9
|
+
const [id, version = "latest"] = slotId.split("@");
|
|
10
|
+
const promise = new ContentFetcher({ ...auth, baseEndpointUrl }).fetch(
|
|
11
|
+
id,
|
|
12
|
+
version === "latest" ? fetchOptions : { ...fetchOptions, version }
|
|
13
|
+
);
|
|
14
|
+
return promise.catch(
|
|
15
|
+
async (error) => {
|
|
16
|
+
if (logger !== void 0) {
|
|
17
|
+
logger.error(`Failed to fetch content for slot "${id}@${version}": ${formatCause(error)}`);
|
|
18
|
+
}
|
|
19
|
+
if (fallback !== void 0) {
|
|
20
|
+
return { content: fallback };
|
|
21
|
+
}
|
|
22
|
+
const staticContent = await loadSlotContent(id, fetchOptions.preferredLocale);
|
|
23
|
+
if (staticContent === null) {
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
return { content: staticContent };
|
|
21
27
|
}
|
|
22
|
-
|
|
28
|
+
);
|
|
23
29
|
}
|
|
24
|
-
|
|
30
|
+
export {
|
|
31
|
+
fetchContent
|
|
32
|
+
};
|
package/api/index.cjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var api_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(api_exports);
|
|
17
|
+
__reExport(api_exports, require('./evaluate.cjs'), module.exports);
|
|
18
|
+
__reExport(api_exports, require('./fetchContent.cjs'), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require('./evaluate.cjs'),
|
|
22
|
+
...require('./fetchContent.cjs')
|
|
23
|
+
});
|
package/api/index.d.cts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { EvaluationOptions, evaluate } from './evaluate.cjs';
|
|
2
|
+
export { DynamicContentOptions, FetchOptions, StaticContentOptions, fetchContent } from './fetchContent.cjs';
|
|
3
|
+
export { FetchResponse } from '../plug.cjs';
|
|
4
|
+
import '@croct/sdk/evaluator';
|
|
5
|
+
import '@croct/sdk/apiKey';
|
|
6
|
+
import '@croct/sdk/logging';
|
|
7
|
+
import '@croct/json/mutable';
|
|
8
|
+
import '@croct/sdk/contentFetcher';
|
|
9
|
+
import '../slot.cjs';
|
|
10
|
+
import '@croct/json';
|
|
11
|
+
import '../versioning.cjs';
|
|
12
|
+
import '../component.cjs';
|
|
13
|
+
import '@croct/sdk/facade/sessionFacade';
|
|
14
|
+
import '@croct/sdk/facade/userFacade';
|
|
15
|
+
import '@croct/sdk/facade/trackerFacade';
|
|
16
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
17
|
+
import '@croct/sdk/facade/sdkFacade';
|
|
18
|
+
import '@croct/sdk/utilityTypes';
|
|
19
|
+
import '@croct/sdk/trackingEvents';
|
|
20
|
+
import '@croct/sdk/facade/contentFetcherFacade';
|
|
21
|
+
import '../plugin.cjs';
|
|
22
|
+
import '@croct/sdk/token';
|
|
23
|
+
import '../sdk/index.cjs';
|
|
24
|
+
import '@croct/sdk/eventManager';
|
|
25
|
+
import '@croct/sdk/sdkEvents';
|
|
26
|
+
import '@croct/sdk/tab';
|
|
27
|
+
import '@croct/sdk/cid';
|
package/api/index.d.ts
CHANGED
|
@@ -1,2 +1,27 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { EvaluationOptions, evaluate } from './evaluate.js';
|
|
2
|
+
export { DynamicContentOptions, FetchOptions, StaticContentOptions, fetchContent } from './fetchContent.js';
|
|
3
|
+
export { FetchResponse } from '../plug.js';
|
|
4
|
+
import '@croct/sdk/evaluator';
|
|
5
|
+
import '@croct/sdk/apiKey';
|
|
6
|
+
import '@croct/sdk/logging';
|
|
7
|
+
import '@croct/json/mutable';
|
|
8
|
+
import '@croct/sdk/contentFetcher';
|
|
9
|
+
import '../slot.js';
|
|
10
|
+
import '@croct/json';
|
|
11
|
+
import '../versioning.js';
|
|
12
|
+
import '../component.js';
|
|
13
|
+
import '@croct/sdk/facade/sessionFacade';
|
|
14
|
+
import '@croct/sdk/facade/userFacade';
|
|
15
|
+
import '@croct/sdk/facade/trackerFacade';
|
|
16
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
17
|
+
import '@croct/sdk/facade/sdkFacade';
|
|
18
|
+
import '@croct/sdk/utilityTypes';
|
|
19
|
+
import '@croct/sdk/trackingEvents';
|
|
20
|
+
import '@croct/sdk/facade/contentFetcherFacade';
|
|
21
|
+
import '../plugin.js';
|
|
22
|
+
import '@croct/sdk/token';
|
|
23
|
+
import '../sdk/index.js';
|
|
24
|
+
import '@croct/sdk/eventManager';
|
|
25
|
+
import '@croct/sdk/sdkEvents';
|
|
26
|
+
import '@croct/sdk/tab';
|
|
27
|
+
import '@croct/sdk/cid';
|
package/api/index.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./evaluate"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./fetchContent"), exports);
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./evaluate.js";
|
|
2
|
+
export * from "./fetchContent.js";
|
package/component.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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 component_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(component_exports);
|
package/component.d.cts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Version, CanonicalVersionId, VersionedId, Versioned } from './versioning.cjs';
|
|
2
|
+
import '@croct/json';
|
|
3
|
+
|
|
4
|
+
interface ComponentMap {
|
|
5
|
+
}
|
|
6
|
+
type LatestComponentVersionMap = {
|
|
7
|
+
[K in keyof ComponentMap]: {
|
|
8
|
+
latest: ComponentMap[K];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
interface VersionedComponentMap extends LatestComponentVersionMap {
|
|
12
|
+
}
|
|
13
|
+
type ComponentId = keyof VersionedComponentMap extends never ? string : keyof VersionedComponentMap;
|
|
14
|
+
type ComponentVersion<I extends ComponentId> = Version<VersionedComponentMap, I>;
|
|
15
|
+
type ComponentVersionId<I extends ComponentId = ComponentId> = CanonicalVersionId<I, VersionedComponentMap>;
|
|
16
|
+
type VersionedComponentId<I extends ComponentId = ComponentId> = VersionedId<I, VersionedComponentMap>;
|
|
17
|
+
type ComponentContent<I extends VersionedComponentId> = Versioned<I, VersionedComponentMap>;
|
|
18
|
+
|
|
19
|
+
export type { ComponentContent, ComponentId, ComponentMap, ComponentVersion, ComponentVersionId, VersionedComponentId, VersionedComponentMap };
|
package/component.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { CanonicalVersionId,
|
|
2
|
-
|
|
1
|
+
import { Version, CanonicalVersionId, VersionedId, Versioned } from './versioning.js';
|
|
2
|
+
import '@croct/json';
|
|
3
|
+
|
|
4
|
+
interface ComponentMap {
|
|
3
5
|
}
|
|
4
6
|
type LatestComponentVersionMap = {
|
|
5
7
|
[K in keyof ComponentMap]: {
|
|
6
8
|
latest: ComponentMap[K];
|
|
7
9
|
};
|
|
8
10
|
};
|
|
9
|
-
|
|
11
|
+
interface VersionedComponentMap extends LatestComponentVersionMap {
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
type ComponentId = keyof VersionedComponentMap extends never ? string : keyof VersionedComponentMap;
|
|
14
|
+
type ComponentVersion<I extends ComponentId> = Version<VersionedComponentMap, I>;
|
|
15
|
+
type ComponentVersionId<I extends ComponentId = ComponentId> = CanonicalVersionId<I, VersionedComponentMap>;
|
|
16
|
+
type VersionedComponentId<I extends ComponentId = ComponentId> = VersionedId<I, VersionedComponentMap>;
|
|
17
|
+
type ComponentContent<I extends VersionedComponentId> = Versioned<I, VersionedComponentMap>;
|
|
18
|
+
|
|
19
|
+
export type { ComponentContent, ComponentId, ComponentMap, ComponentVersion, ComponentVersionId, VersionedComponentId, VersionedComponentMap };
|
package/component.js
CHANGED
package/constants.cjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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 constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
CDN_URL: () => CDN_URL,
|
|
21
|
+
PLAYGROUND_CONNECT_URL: () => PLAYGROUND_CONNECT_URL,
|
|
22
|
+
PLAYGROUND_ORIGIN: () => PLAYGROUND_ORIGIN,
|
|
23
|
+
PREVIEW_WIDGET_ORIGIN: () => PREVIEW_WIDGET_ORIGIN,
|
|
24
|
+
PREVIEW_WIDGET_URL: () => PREVIEW_WIDGET_URL
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(constants_exports);
|
|
27
|
+
const CDN_URL = "https://cdn.croct.io/js/v1/lib/plug.js";
|
|
28
|
+
const PLAYGROUND_ORIGIN = "https://play.croct.com";
|
|
29
|
+
const PLAYGROUND_CONNECT_URL = "https://play.croct.com/connect.html";
|
|
30
|
+
const PREVIEW_WIDGET_ORIGIN = "https://cdn.croct.io";
|
|
31
|
+
const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.17.0.html";
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
CDN_URL,
|
|
35
|
+
PLAYGROUND_CONNECT_URL,
|
|
36
|
+
PLAYGROUND_ORIGIN,
|
|
37
|
+
PREVIEW_WIDGET_ORIGIN,
|
|
38
|
+
PREVIEW_WIDGET_URL
|
|
39
|
+
});
|
package/constants.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const CDN_URL = "https://cdn.croct.io/js/v1/lib/plug.js";
|
|
2
|
+
declare const PLAYGROUND_ORIGIN = "https://play.croct.com";
|
|
3
|
+
declare const PLAYGROUND_CONNECT_URL = "https://play.croct.com/connect.html";
|
|
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.17.0.html";
|
|
6
|
+
|
|
7
|
+
export { CDN_URL, PLAYGROUND_CONNECT_URL, PLAYGROUND_ORIGIN, PREVIEW_WIDGET_ORIGIN, PREVIEW_WIDGET_URL };
|
package/constants.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
declare const CDN_URL = "https://cdn.croct.io/js/v1/lib/plug.js";
|
|
2
|
+
declare const PLAYGROUND_ORIGIN = "https://play.croct.com";
|
|
3
|
+
declare const PLAYGROUND_CONNECT_URL = "https://play.croct.com/connect.html";
|
|
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.17.0.html";
|
|
6
|
+
|
|
7
|
+
export { CDN_URL, PLAYGROUND_CONNECT_URL, PLAYGROUND_ORIGIN, PREVIEW_WIDGET_ORIGIN, PREVIEW_WIDGET_URL };
|
package/constants.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
const CDN_URL = "https://cdn.croct.io/js/v1/lib/plug.js";
|
|
2
|
+
const PLAYGROUND_ORIGIN = "https://play.croct.com";
|
|
3
|
+
const PLAYGROUND_CONNECT_URL = "https://play.croct.com/connect.html";
|
|
4
|
+
const PREVIEW_WIDGET_ORIGIN = "https://cdn.croct.io";
|
|
5
|
+
const PREVIEW_WIDGET_URL = "https://cdn.croct.io/js/v1/lib/plug/widget-0.17.0.html";
|
|
6
|
+
export {
|
|
7
|
+
CDN_URL,
|
|
8
|
+
PLAYGROUND_CONNECT_URL,
|
|
9
|
+
PLAYGROUND_ORIGIN,
|
|
10
|
+
PREVIEW_WIDGET_ORIGIN,
|
|
11
|
+
PREVIEW_WIDGET_URL
|
|
12
|
+
};
|
package/index.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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 index_exports = {};
|
|
19
|
+
__export(index_exports, {
|
|
20
|
+
default: () => index_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(index_exports);
|
|
23
|
+
var import_plug = require('./plug.cjs');
|
|
24
|
+
var index_default = new import_plug.GlobalPlug();
|