@croct/plug 0.18.0 → 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.cjs +2 -8
- package/index.d.cts +4 -5
- package/index.d.ts +4 -5
- package/index.js +2 -4
- package/package.json +15 -2
- package/plug-Cf6SnDp4.d.cts +110 -0
- package/plug-DjUeWnq0.d.ts +110 -0
- package/plug.cjs +11 -6
- package/plug.d.cts +11 -76
- package/plug.d.ts +11 -76
- package/plug.js +11 -6
- 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
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
const typeMap = {
|
|
2
|
+
post: /* @__PURE__ */ new Set([
|
|
3
|
+
"BlogPosting",
|
|
4
|
+
"LiveBlogPosting",
|
|
5
|
+
"NewsArticle",
|
|
6
|
+
"AnalysisNewsArticle",
|
|
7
|
+
"AskPublicNewsArticle",
|
|
8
|
+
"BackgroundNewsArticle",
|
|
9
|
+
"OpinionNewsArticle",
|
|
10
|
+
"ReportageNewsArticle",
|
|
11
|
+
"ReviewNewsArticle",
|
|
12
|
+
"SocialMediaPosting",
|
|
13
|
+
"BlogPosting",
|
|
14
|
+
"DiscussionForumPosting",
|
|
15
|
+
"LiveBlogPosting"
|
|
16
|
+
]),
|
|
17
|
+
article: /* @__PURE__ */ new Set([
|
|
18
|
+
"Article",
|
|
19
|
+
"TechArticle",
|
|
20
|
+
"APIReference",
|
|
21
|
+
"Report",
|
|
22
|
+
"AdvertiserContentArticle",
|
|
23
|
+
"SatiricalArticle",
|
|
24
|
+
"ScholarlyArticle",
|
|
25
|
+
"MedicalScholarlyArticle"
|
|
26
|
+
]),
|
|
27
|
+
product: /* @__PURE__ */ new Set([
|
|
28
|
+
"Product",
|
|
29
|
+
"ProductCollection",
|
|
30
|
+
"ProductModel",
|
|
31
|
+
"ProductGroup",
|
|
32
|
+
"SomeProducts",
|
|
33
|
+
"Vehicle",
|
|
34
|
+
"BusOrCoach",
|
|
35
|
+
"Car",
|
|
36
|
+
"Motorcycle",
|
|
37
|
+
"MotorizedBicycle",
|
|
38
|
+
"Car",
|
|
39
|
+
"Motorcycle",
|
|
40
|
+
"IndividualProduct",
|
|
41
|
+
"DietarySupplement",
|
|
42
|
+
"Drug"
|
|
43
|
+
]),
|
|
44
|
+
service: /* @__PURE__ */ new Set([
|
|
45
|
+
"Service",
|
|
46
|
+
"BroadcastService",
|
|
47
|
+
"CableOrSatelliteService",
|
|
48
|
+
"FinancialProduct",
|
|
49
|
+
"FoodService",
|
|
50
|
+
"GovernmentService",
|
|
51
|
+
"TaxiService",
|
|
52
|
+
"WebAPI"
|
|
53
|
+
])
|
|
54
|
+
};
|
|
55
|
+
function parseEntity(content) {
|
|
56
|
+
const data = parseJsonLd(content);
|
|
57
|
+
if (data === null) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return extractEntity(data);
|
|
61
|
+
}
|
|
62
|
+
function extractEntity(data) {
|
|
63
|
+
const type = getEntityType(data);
|
|
64
|
+
switch (type) {
|
|
65
|
+
case "article":
|
|
66
|
+
case "post": {
|
|
67
|
+
return {
|
|
68
|
+
type,
|
|
69
|
+
...extractArticle(data)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
case "product":
|
|
73
|
+
case "service": {
|
|
74
|
+
return {
|
|
75
|
+
type,
|
|
76
|
+
...extractProduct(data)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
function getEntityType(data) {
|
|
83
|
+
const type = getValue(data, "@type");
|
|
84
|
+
for (const [entityType, typeSet] of Object.entries(typeMap)) {
|
|
85
|
+
if (contains(typeSet, type)) {
|
|
86
|
+
return entityType;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
function extractArticle(data) {
|
|
92
|
+
const postId = getValue(data, "identifier");
|
|
93
|
+
const post = {};
|
|
94
|
+
if (typeof postId === "string") {
|
|
95
|
+
post.id = postId;
|
|
96
|
+
}
|
|
97
|
+
const title = getValue(data, "headline", "name");
|
|
98
|
+
if (typeof title === "string") {
|
|
99
|
+
post.title = title;
|
|
100
|
+
}
|
|
101
|
+
const datePublished = getValue(data, "datePublished", "dateCreated");
|
|
102
|
+
const dateModified = getValue(data, "dateModified");
|
|
103
|
+
const updateTime = parseTimestamp(dateModified);
|
|
104
|
+
const publishTime = parseTimestamp(datePublished) ?? updateTime;
|
|
105
|
+
if (publishTime !== null) {
|
|
106
|
+
post.publishTime = publishTime;
|
|
107
|
+
if (updateTime !== null && updateTime > publishTime) {
|
|
108
|
+
post.updateTime = updateTime;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const url = getValue(data, "url", "mainEntityOfPage");
|
|
112
|
+
if (typeof url === "string" && URL.canParse(url)) {
|
|
113
|
+
post.url = url;
|
|
114
|
+
} else if (isObject(url)) {
|
|
115
|
+
const urlValue = getValue(url, "url", "@id");
|
|
116
|
+
if (typeof urlValue === "string" && URL.canParse(urlValue)) {
|
|
117
|
+
post.url = urlValue;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const tags = [];
|
|
121
|
+
const keywords = getValue(data, "keywords");
|
|
122
|
+
if (typeof keywords === "string") {
|
|
123
|
+
tags.push(
|
|
124
|
+
...keywords.split(",").map((keyword) => keyword.trim()).filter((keyword) => keyword.length > 0)
|
|
125
|
+
);
|
|
126
|
+
} else if (Array.isArray(keywords)) {
|
|
127
|
+
for (const keyword of keywords) {
|
|
128
|
+
if (typeof keyword === "string") {
|
|
129
|
+
tags.push(keyword);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (tags.length > 0) {
|
|
134
|
+
post.tags = tags;
|
|
135
|
+
}
|
|
136
|
+
const categories = [];
|
|
137
|
+
for (const key of ["articleSection", "genre"]) {
|
|
138
|
+
const value = getValue(data, key);
|
|
139
|
+
if (typeof value === "string") {
|
|
140
|
+
categories.push(value);
|
|
141
|
+
} else if (Array.isArray(value)) {
|
|
142
|
+
for (const item of value) {
|
|
143
|
+
if (typeof item === "string") {
|
|
144
|
+
categories.push(item);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const about = getValue(data, "about");
|
|
150
|
+
if (isObject(about)) {
|
|
151
|
+
const aboutName = getValue(about, "name");
|
|
152
|
+
if (typeof aboutName === "string") {
|
|
153
|
+
categories.push(aboutName);
|
|
154
|
+
}
|
|
155
|
+
} else if (Array.isArray(about)) {
|
|
156
|
+
for (const item of about) {
|
|
157
|
+
if (isObject(item)) {
|
|
158
|
+
const itemName = getValue(item, "name");
|
|
159
|
+
if (typeof itemName === "string") {
|
|
160
|
+
categories.push(itemName);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (categories.length > 0) {
|
|
166
|
+
post.categories = categories;
|
|
167
|
+
}
|
|
168
|
+
const authors = [];
|
|
169
|
+
const authorData = getValue(data, "author", "creator");
|
|
170
|
+
const authorList = Array.isArray(authorData) ? authorData : [authorData];
|
|
171
|
+
for (const author of authorList) {
|
|
172
|
+
if (typeof author === "string") {
|
|
173
|
+
authors.push(author);
|
|
174
|
+
} else if (isObject(author)) {
|
|
175
|
+
const name = getValue(author, "name");
|
|
176
|
+
if (typeof name === "string") {
|
|
177
|
+
authors.push(name);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (authors.length > 0) {
|
|
182
|
+
post.authors = authors;
|
|
183
|
+
}
|
|
184
|
+
return post;
|
|
185
|
+
}
|
|
186
|
+
function extractProduct(data) {
|
|
187
|
+
const product = {};
|
|
188
|
+
const productId = getValue(data, "productID", "identifier");
|
|
189
|
+
if (typeof productId === "string") {
|
|
190
|
+
product.id = productId;
|
|
191
|
+
}
|
|
192
|
+
const productName = getValue(data, "name");
|
|
193
|
+
if (typeof productName === "string") {
|
|
194
|
+
product.name = productName;
|
|
195
|
+
}
|
|
196
|
+
const prices = [];
|
|
197
|
+
const urls = [];
|
|
198
|
+
const offersList = Array.isArray(data.offers) ? data.offers : [data.offers];
|
|
199
|
+
for (const offer of offersList) {
|
|
200
|
+
if (!isObject(offer)) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const url = getValue(offer, "url");
|
|
204
|
+
if (typeof url === "string") {
|
|
205
|
+
urls.push(url);
|
|
206
|
+
}
|
|
207
|
+
for (const key of ["price", "lowPrice", "highPrice"]) {
|
|
208
|
+
const value = parseNumber(getValue(offer, key));
|
|
209
|
+
if (value !== null && value >= 0) {
|
|
210
|
+
prices.push(value);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const specifications = getValue(offer, "priceSpecification");
|
|
214
|
+
const specList = Array.isArray(specifications) ? specifications : [specifications];
|
|
215
|
+
for (const specification of specList) {
|
|
216
|
+
if (!isObject(specification)) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
for (const key of ["price", "minPrice", "maxPrice"]) {
|
|
220
|
+
const value = parseNumber(getValue(specification, key));
|
|
221
|
+
if (value !== null && value >= 0) {
|
|
222
|
+
prices.push(value);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (prices.length > 0) {
|
|
228
|
+
const displayPrice = Math.min(...prices);
|
|
229
|
+
const originalPrice = Math.max(...prices);
|
|
230
|
+
product.displayPrice = displayPrice;
|
|
231
|
+
if (originalPrice > displayPrice) {
|
|
232
|
+
product.originalPrice = originalPrice;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const variant = [];
|
|
236
|
+
for (const key of ["color", "pattern", "size", "material", "model"]) {
|
|
237
|
+
const value = getValue(data, key);
|
|
238
|
+
if (typeof value === "string") {
|
|
239
|
+
variant.push(value);
|
|
240
|
+
} else if (isObject(value)) {
|
|
241
|
+
const name = getValue(value, "name");
|
|
242
|
+
if (typeof name === "string") {
|
|
243
|
+
variant.push(name);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (variant.length > 0) {
|
|
248
|
+
product.variant = variant.join(", ");
|
|
249
|
+
}
|
|
250
|
+
const productSku = getValue(data, "sku");
|
|
251
|
+
if (typeof productSku === "string") {
|
|
252
|
+
product.sku = productSku;
|
|
253
|
+
}
|
|
254
|
+
const category = getValue(data, "category");
|
|
255
|
+
if (typeof category === "string") {
|
|
256
|
+
product.category = category;
|
|
257
|
+
} else if (isObject(category)) {
|
|
258
|
+
const name = getValue(category, "name");
|
|
259
|
+
if (typeof name === "string") {
|
|
260
|
+
product.category = name;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const brand = getValue(data, "brand");
|
|
264
|
+
if (typeof brand === "string") {
|
|
265
|
+
product.brand = brand;
|
|
266
|
+
} else if (isObject(brand)) {
|
|
267
|
+
const name = getValue(brand, "name");
|
|
268
|
+
if (typeof name === "string") {
|
|
269
|
+
product.brand = name;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const productUrl = getValue(data, "url");
|
|
273
|
+
if (typeof productUrl === "string") {
|
|
274
|
+
urls.unshift(productUrl);
|
|
275
|
+
}
|
|
276
|
+
for (const url of urls) {
|
|
277
|
+
if (URL.canParse(url)) {
|
|
278
|
+
product.url = url;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const images = Array.isArray(data.image) ? data.image : [data.image];
|
|
283
|
+
for (const image of images) {
|
|
284
|
+
if (typeof image === "string" && URL.canParse(image)) {
|
|
285
|
+
product.imageUrl = image;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
if (isObject(image)) {
|
|
289
|
+
const imageUrl = getValue(image, "url");
|
|
290
|
+
if (typeof imageUrl === "string" && URL.canParse(imageUrl)) {
|
|
291
|
+
product.imageUrl = imageUrl;
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return product;
|
|
297
|
+
}
|
|
298
|
+
function parseJsonLd(content) {
|
|
299
|
+
try {
|
|
300
|
+
const data = JSON.parse(content);
|
|
301
|
+
if (isObject(data)) {
|
|
302
|
+
return data;
|
|
303
|
+
}
|
|
304
|
+
} catch {
|
|
305
|
+
}
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
function contains(set, value) {
|
|
309
|
+
if (typeof value === "string") {
|
|
310
|
+
return set.has(value);
|
|
311
|
+
}
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
function isObject(value) {
|
|
315
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
316
|
+
}
|
|
317
|
+
function parseTimestamp(value) {
|
|
318
|
+
if (typeof value === "string") {
|
|
319
|
+
const date = Date.parse(value);
|
|
320
|
+
if (!Number.isNaN(date)) {
|
|
321
|
+
return date;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
function parseNumber(value) {
|
|
327
|
+
if (typeof value === "number") {
|
|
328
|
+
return value;
|
|
329
|
+
}
|
|
330
|
+
if (typeof value === "string") {
|
|
331
|
+
const parsedValue = Number.parseFloat(value);
|
|
332
|
+
if (!Number.isNaN(parsedValue)) {
|
|
333
|
+
return parsedValue;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
function getValue(object, ...keys) {
|
|
339
|
+
for (const key of keys) {
|
|
340
|
+
const value = object[key];
|
|
341
|
+
if (value === void 0 || value === null || typeof value === "string" && value.trim() === "") {
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
return value;
|
|
345
|
+
}
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
export {
|
|
349
|
+
extractArticle,
|
|
350
|
+
extractEntity,
|
|
351
|
+
extractProduct,
|
|
352
|
+
parseEntity
|
|
353
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
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 globalVariable_exports = {};
|
|
19
|
+
__export(globalVariable_exports, {
|
|
20
|
+
GlobalVariablePlugin: () => GlobalVariablePlugin,
|
|
21
|
+
factory: () => factory
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(globalVariable_exports);
|
|
24
|
+
class GlobalVariablePlugin {
|
|
25
|
+
constructor(configuration) {
|
|
26
|
+
this.globallyAvailable = true;
|
|
27
|
+
this.plug = configuration.plug;
|
|
28
|
+
}
|
|
29
|
+
enable() {
|
|
30
|
+
if (window.croct === void 0) {
|
|
31
|
+
window.croct = this.plug;
|
|
32
|
+
this.globallyAvailable = false;
|
|
33
|
+
}
|
|
34
|
+
let callback = window.onCroctLoad;
|
|
35
|
+
Object.defineProperty(window, "onCroctLoad", {
|
|
36
|
+
configurable: true,
|
|
37
|
+
get: () => callback,
|
|
38
|
+
set: (listener) => {
|
|
39
|
+
this.notify(listener);
|
|
40
|
+
callback = listener;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
this.notify(callback);
|
|
44
|
+
}
|
|
45
|
+
disable() {
|
|
46
|
+
if (!this.globallyAvailable) {
|
|
47
|
+
delete window.croct;
|
|
48
|
+
}
|
|
49
|
+
const callback = window.onCroctLoad;
|
|
50
|
+
delete window.onCroctLoad;
|
|
51
|
+
window.onCroctLoad = callback;
|
|
52
|
+
}
|
|
53
|
+
notify(callback) {
|
|
54
|
+
if (typeof callback === "function") {
|
|
55
|
+
callback(this.plug);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const factory = (props) => new GlobalVariablePlugin({ plug: props.sdk.plug });
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
GlobalVariablePlugin,
|
|
63
|
+
factory
|
|
64
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { P as Plug, a as Plugin, b as PluginArguments } 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
|
+
type Configuration = {
|
|
24
|
+
plug: Plug;
|
|
25
|
+
};
|
|
26
|
+
declare class GlobalVariablePlugin implements Plugin {
|
|
27
|
+
private readonly plug;
|
|
28
|
+
private globallyAvailable;
|
|
29
|
+
constructor(configuration: Configuration);
|
|
30
|
+
enable(): void;
|
|
31
|
+
disable(): void;
|
|
32
|
+
private notify;
|
|
33
|
+
}
|
|
34
|
+
declare const factory: (props: PluginArguments<any>) => GlobalVariablePlugin;
|
|
35
|
+
|
|
36
|
+
export { type Configuration, GlobalVariablePlugin, factory };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { P as Plug, a as Plugin, b as PluginArguments } 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
|
+
type Configuration = {
|
|
24
|
+
plug: Plug;
|
|
25
|
+
};
|
|
26
|
+
declare class GlobalVariablePlugin implements Plugin {
|
|
27
|
+
private readonly plug;
|
|
28
|
+
private globallyAvailable;
|
|
29
|
+
constructor(configuration: Configuration);
|
|
30
|
+
enable(): void;
|
|
31
|
+
disable(): void;
|
|
32
|
+
private notify;
|
|
33
|
+
}
|
|
34
|
+
declare const factory: (props: PluginArguments<any>) => GlobalVariablePlugin;
|
|
35
|
+
|
|
36
|
+
export { type Configuration, GlobalVariablePlugin, factory };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
class GlobalVariablePlugin {
|
|
2
|
+
constructor(configuration) {
|
|
3
|
+
this.globallyAvailable = true;
|
|
4
|
+
this.plug = configuration.plug;
|
|
5
|
+
}
|
|
6
|
+
enable() {
|
|
7
|
+
if (window.croct === void 0) {
|
|
8
|
+
window.croct = this.plug;
|
|
9
|
+
this.globallyAvailable = false;
|
|
10
|
+
}
|
|
11
|
+
let callback = window.onCroctLoad;
|
|
12
|
+
Object.defineProperty(window, "onCroctLoad", {
|
|
13
|
+
configurable: true,
|
|
14
|
+
get: () => callback,
|
|
15
|
+
set: (listener) => {
|
|
16
|
+
this.notify(listener);
|
|
17
|
+
callback = listener;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
this.notify(callback);
|
|
21
|
+
}
|
|
22
|
+
disable() {
|
|
23
|
+
if (!this.globallyAvailable) {
|
|
24
|
+
delete window.croct;
|
|
25
|
+
}
|
|
26
|
+
const callback = window.onCroctLoad;
|
|
27
|
+
delete window.onCroctLoad;
|
|
28
|
+
window.onCroctLoad = callback;
|
|
29
|
+
}
|
|
30
|
+
notify(callback) {
|
|
31
|
+
if (typeof callback === "function") {
|
|
32
|
+
callback(this.plug);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const factory = (props) => new GlobalVariablePlugin({ plug: props.sdk.plug });
|
|
37
|
+
export {
|
|
38
|
+
GlobalVariablePlugin,
|
|
39
|
+
factory
|
|
40
|
+
};
|
|
@@ -22,8 +22,8 @@ __export(preview_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(preview_exports);
|
|
24
24
|
var import_error = require("@croct/sdk/error");
|
|
25
|
-
var import_token = require('
|
|
26
|
-
var import_constants = require('
|
|
25
|
+
var import_token = require('../../sdk/token.cjs');
|
|
26
|
+
var import_constants = require('../../constants.cjs');
|
|
27
27
|
const PREVIEW_PARAMETER = "croct-preview";
|
|
28
28
|
const PREVIEW_EXIT = "exit";
|
|
29
29
|
const _PreviewPlugin = class _PreviewPlugin {
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { Logger } from '@croct/sdk/logging';
|
|
2
|
-
import { Plugin, PluginFactory } from '
|
|
2
|
+
import { a as Plugin, c as PluginFactory } from '../../plug-Cf6SnDp4.cjs';
|
|
3
3
|
import { TokenStore } from '@croct/sdk/token';
|
|
4
|
-
import '@croct/sdk/facade/
|
|
4
|
+
import '@croct/sdk/facade/sessionFacade';
|
|
5
|
+
import '@croct/sdk/facade/userFacade';
|
|
5
6
|
import '@croct/sdk/facade/trackerFacade';
|
|
6
|
-
import '
|
|
7
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
8
|
+
import '@croct/sdk/facade/sdkFacade';
|
|
9
|
+
import '@croct/sdk/utilityTypes';
|
|
10
|
+
import '@croct/sdk/trackingEvents';
|
|
11
|
+
import '@croct/sdk/facade/contentFetcherFacade';
|
|
12
|
+
import '../../sdk/index.cjs';
|
|
7
13
|
import '@croct/sdk/eventManager';
|
|
8
14
|
import '@croct/sdk/sdkEvents';
|
|
9
|
-
import '@croct/sdk/facade/sessionFacade';
|
|
10
|
-
import '@croct/sdk/facade/userFacade';
|
|
11
15
|
import '@croct/sdk/tab';
|
|
12
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';
|
|
13
22
|
|
|
14
23
|
type Configuration = {
|
|
15
24
|
tokenStore: TokenStore;
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { Logger } from '@croct/sdk/logging';
|
|
2
|
-
import { Plugin, PluginFactory } from '
|
|
2
|
+
import { a as Plugin, c as PluginFactory } from '../../plug-DjUeWnq0.js';
|
|
3
3
|
import { TokenStore } from '@croct/sdk/token';
|
|
4
|
-
import '@croct/sdk/facade/
|
|
4
|
+
import '@croct/sdk/facade/sessionFacade';
|
|
5
|
+
import '@croct/sdk/facade/userFacade';
|
|
5
6
|
import '@croct/sdk/facade/trackerFacade';
|
|
6
|
-
import '
|
|
7
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
8
|
+
import '@croct/sdk/facade/sdkFacade';
|
|
9
|
+
import '@croct/sdk/utilityTypes';
|
|
10
|
+
import '@croct/sdk/trackingEvents';
|
|
11
|
+
import '@croct/sdk/facade/contentFetcherFacade';
|
|
12
|
+
import '../../sdk/index.js';
|
|
7
13
|
import '@croct/sdk/eventManager';
|
|
8
14
|
import '@croct/sdk/sdkEvents';
|
|
9
|
-
import '@croct/sdk/facade/sessionFacade';
|
|
10
|
-
import '@croct/sdk/facade/userFacade';
|
|
11
15
|
import '@croct/sdk/tab';
|
|
12
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';
|
|
13
22
|
|
|
14
23
|
type Configuration = {
|
|
15
24
|
tokenStore: TokenStore;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatCause } from "@croct/sdk/error";
|
|
2
|
-
import { Token } from "
|
|
3
|
-
import { PREVIEW_WIDGET_ORIGIN, PREVIEW_WIDGET_URL } from "
|
|
2
|
+
import { Token } from "../../sdk/token.js";
|
|
3
|
+
import { PREVIEW_WIDGET_ORIGIN, PREVIEW_WIDGET_URL } from "../../constants.js";
|
|
4
4
|
const PREVIEW_PARAMETER = "croct-preview";
|
|
5
5
|
const PREVIEW_EXIT = "exit";
|
|
6
6
|
const _PreviewPlugin = class _PreviewPlugin {
|
package/sdk/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventManager,
|
|
1
|
+
import { EventManager, EventListener, EventDispatcher, 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,
|
|
1
|
+
import { EventManager, EventListener, EventDispatcher, 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';
|