@startinblox/core 2.0.0-beta.14 → 2.0.0-beta.15

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/dist/store.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b, s } from "./store-CVms1LLP.js";
1
+ import { b, s } from "./store-DiyQ_yIK.js";
2
2
  export {
3
3
  b as baseContext,
4
4
  s as store
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "2.0.0-beta.14",
3
+ "version": "2.0.0-beta.15",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -84,7 +84,7 @@
84
84
  "express": "^4.21.2",
85
85
  "find-free-port": "^2.0.0",
86
86
  "jsonld": "^8.3.3",
87
- "jsonld-context-parser": "^1.3.4",
87
+ "jsonld-context-parser": "^3.0.0",
88
88
  "markdown-it": "^14.1.0",
89
89
  "markdown-it-link-attributes": "4.0.1",
90
90
  "pubsub-js": "^1.9.5",
@@ -1,373 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __typeError = (msg) => {
3
- throw TypeError(msg);
4
- };
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _values, _resolve, _AsyncIterableBuilder_instances, createIterable_fn, next_fn, nextPromise_fn;
13
- function uniqID() {
14
- return `_${(Math.random() * 36 ** 20).toString(36).slice(0, 10)}`;
15
- }
16
- function stringToDom(html) {
17
- const template = document.createElement("template");
18
- template.innerHTML = html;
19
- return template.content;
20
- }
21
- const AsyncFunction = Object.getPrototypeOf(async () => {
22
- }).constructor;
23
- async function evalTemplateString(str, variables = {}) {
24
- const keys = Object.keys(variables);
25
- const values = keys.map((key) => variables[key]);
26
- try {
27
- const func = AsyncFunction.call(null, ...keys, `return \`${str}\``);
28
- return await func(...values);
29
- } catch (e) {
30
- console.log(e);
31
- throw new SyntaxError(`\`${str}\``);
32
- }
33
- }
34
- function importCSS(...stylesheets) {
35
- const linksElements = [];
36
- for (let url of stylesheets) {
37
- url = relativeSource(url);
38
- let link = Array.from(document.head.querySelectorAll("link")).find(
39
- (link2) => link2.href === url
40
- );
41
- if (link) return link;
42
- link = document.createElement("link");
43
- link.rel = "stylesheet";
44
- link.href = url;
45
- document.head.appendChild(link);
46
- linksElements.push(link);
47
- }
48
- return linksElements;
49
- }
50
- function importInlineCSS(id, importer) {
51
- id = `sib-inline-css-${id}`;
52
- let style = document.head.querySelector(`style#${id}`);
53
- if (style) return style;
54
- style = document.createElement("style");
55
- style.id = id;
56
- document.head.appendChild(style);
57
- (async () => {
58
- let textContent;
59
- if (typeof importer === "string") textContent = importer;
60
- else {
61
- const imported = await importer();
62
- if (typeof imported === "string") textContent = imported;
63
- else textContent = imported.default || "";
64
- }
65
- style.textContent = textContent;
66
- })();
67
- return style;
68
- }
69
- function importJS(...plugins) {
70
- return plugins.map((url) => {
71
- url = new URL(url, document.baseURI).href;
72
- let script = Array.from(document.querySelectorAll("script")).find(
73
- (script2) => script2.src === url
74
- );
75
- if (script) return script;
76
- script = document.createElement("script");
77
- script.src = url;
78
- document.head.appendChild(script);
79
- return script;
80
- });
81
- }
82
- function relativeSource(source) {
83
- if (!source.match(/^\..?\//)) return new URL(source, document.baseURI).href;
84
- const e = new Error();
85
- if (!e.stack) return source;
86
- const f2 = e.stack.split("\n").filter((l) => l.includes(":"))[2];
87
- const line = f2.match(/[a-z]+:.*$/);
88
- if (!line) return source;
89
- const calledFile = line[0].replace(/(\:[0-9]+){2}\)?$/, "");
90
- source = new URL(source, calledFile).href;
91
- return source;
92
- }
93
- function loadScript(source) {
94
- source = relativeSource(source);
95
- return new Promise((resolve) => {
96
- const script = document.createElement("script");
97
- const head = document.querySelector("head");
98
- script.async = true;
99
- script.onload = () => setTimeout(resolve, 0);
100
- script.src = source;
101
- if (head) head.appendChild(script);
102
- });
103
- }
104
- function domIsReady() {
105
- return new Promise((resolve) => {
106
- if (document.readyState === "complete") {
107
- resolve();
108
- } else {
109
- document.addEventListener("DOMContentLoaded", () => resolve());
110
- }
111
- });
112
- }
113
- function setDeepProperty(obj, path, value) {
114
- const name = path.shift();
115
- if (name) {
116
- if (!(name in obj)) obj[name] = {};
117
- if (path.length > 0) setDeepProperty(obj[name], path, value);
118
- else obj[name] = value;
119
- }
120
- }
121
- function parseFieldsString(fields) {
122
- if (!fields) return [];
123
- while (fields.indexOf("(") > 0) {
124
- const firstBracket = fields.indexOf("(");
125
- const noset = fields.substring(
126
- firstBracket,
127
- findClosingBracketMatchIndex(fields, firstBracket) + 1
128
- );
129
- fields = fields.replace(noset, "");
130
- }
131
- const re = /((^\s*|,)\s*)(("(\\"|[^"])*")|('(\\'|[^'])*')|[^,]*)/gm;
132
- const fieldsArray = fields.match(re) || [];
133
- if (!fieldsArray) return [];
134
- return fieldsArray.map((a) => a.replace(/^[\s,]+/, ""));
135
- }
136
- function findClosingBracketMatchIndex(str, pos) {
137
- if (str[pos] !== "(") throw new Error(`No '(' at index ${pos}`);
138
- let depth = 1;
139
- for (let i = pos + 1; i < str.length; i++) {
140
- switch (str[i]) {
141
- case "(":
142
- depth++;
143
- break;
144
- case ")":
145
- if (--depth === 0) return i;
146
- break;
147
- }
148
- }
149
- return -1;
150
- }
151
- function defineComponent(tagName, componentClass) {
152
- if (!customElements.get(tagName)) {
153
- customElements.define(tagName, componentClass);
154
- } else {
155
- console.warn(
156
- `Warning: the component "${tagName}" has already been loaded in another version of sib-core.`
157
- );
158
- }
159
- }
160
- function fuzzyCompare(subject, search) {
161
- return compareTransform(subject).includes(compareTransform(String(search)));
162
- }
163
- function compareTransform(str) {
164
- return str.normalize("NFD").replaceAll(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase().replaceAll("œ", "oe").replaceAll("æ", "ae").replaceAll(/[ ,.!?;:-`"]+/g, " ").trim();
165
- }
166
- const compare = {
167
- string(subject, query) {
168
- if (typeof subject !== "string" || typeof query !== "string")
169
- throw new TypeError("not a string");
170
- if (query === "") return true;
171
- return fuzzyCompare(subject, String(query));
172
- },
173
- boolean(subject, query) {
174
- if (!query) return true;
175
- return subject;
176
- },
177
- number(subject, query) {
178
- return subject === query;
179
- },
180
- list(subject, list) {
181
- return list.includes(subject);
182
- },
183
- range(subject, range) {
184
- return (range[0] == null || range[0] === "" || subject >= range[0]) && (range[1] == null || range[1] === "" || subject <= range[1]);
185
- },
186
- resource(subject, query) {
187
- if (query === "") return true;
188
- if (!query["@id"]) return false;
189
- const ret = subject["@id"] === query["@id"];
190
- return ret;
191
- }
192
- };
193
- function generalComparator(a, b, order = "asc") {
194
- if (order === "desc") return generalComparator(b, a);
195
- if (a == null && b == null) return 0;
196
- if (a === b || Object.is(a, b)) return 0;
197
- if (typeof a === "boolean" && typeof b === "boolean") {
198
- return a === b ? 0 : a ? 1 : -1;
199
- }
200
- if (!Number.isNaN(Number(a)) && !Number.isNaN(Number(b))) {
201
- return Number(a) - Number(b);
202
- }
203
- if (Array.isArray(a) && Array.isArray(b)) {
204
- return a.length - b.length;
205
- }
206
- const dateA = Date.parse(String(a));
207
- const dateB = Date.parse(String(b));
208
- if (!Number.isNaN(dateA) && !Number.isNaN(dateB)) {
209
- return dateA - dateB;
210
- }
211
- if (a && b && typeof a === "object" && typeof b === "object") {
212
- const aKeys = Object.keys(a);
213
- const bKeys = Object.keys(b);
214
- return aKeys.length - bKeys.length;
215
- }
216
- if (a == null) return -1;
217
- if (b == null) return 1;
218
- return String(a).localeCompare(String(b));
219
- }
220
- function transformArrayToContainer(resource) {
221
- const newValue = { ...resource };
222
- for (const predicate of Object.keys(newValue)) {
223
- const predicateValue = newValue[predicate];
224
- if (!predicateValue || typeof predicateValue !== "object") continue;
225
- if (["permissions", "@context"].includes(predicate)) continue;
226
- if (!Array.isArray(predicateValue) && predicateValue["@id"]) {
227
- newValue[predicate] = transformArrayToContainer(resource[predicate]);
228
- }
229
- if (Array.isArray(predicateValue) && predicateValue["@id"]) {
230
- newValue[predicate] = {
231
- "@id": predicateValue["@id"],
232
- "ldp:contains": [...predicateValue]
233
- // ???? why only ldp:contains?
234
- };
235
- newValue[predicate]["ldp:contains"].forEach(
236
- (childPredicate, index) => {
237
- newValue[predicate]["ldp:contains"][index] = transformArrayToContainer(childPredicate);
238
- }
239
- );
240
- }
241
- }
242
- return newValue;
243
- }
244
- function doesResourceContainList(resource) {
245
- const predicates = ["ldp:contains", "dcat:dataset"];
246
- return predicates.some(
247
- (predicate) => typeof resource === "object" ? predicate in resource : typeof resource === "string" && resource.includes(predicate)
248
- );
249
- }
250
- class AsyncIterableBuilder {
251
- constructor() {
252
- __privateAdd(this, _AsyncIterableBuilder_instances);
253
- __privateAdd(this, _values, []);
254
- __privateAdd(this, _resolve);
255
- __publicField(this, "iterable");
256
- __publicField(this, "next");
257
- __privateMethod(this, _AsyncIterableBuilder_instances, nextPromise_fn).call(this);
258
- this.iterable = __privateMethod(this, _AsyncIterableBuilder_instances, createIterable_fn).call(this);
259
- this.next = __privateMethod(this, _AsyncIterableBuilder_instances, next_fn).bind(this);
260
- }
261
- }
262
- _values = new WeakMap();
263
- _resolve = new WeakMap();
264
- _AsyncIterableBuilder_instances = new WeakSet();
265
- createIterable_fn = async function* () {
266
- for (let index = 0; ; index++) {
267
- const { value, done } = await __privateGet(this, _values)[index];
268
- delete __privateGet(this, _values)[index];
269
- yield value;
270
- if (done) return;
271
- }
272
- };
273
- next_fn = function(value, done = false) {
274
- __privateGet(this, _resolve).call(this, { value, done });
275
- __privateMethod(this, _AsyncIterableBuilder_instances, nextPromise_fn).call(this);
276
- };
277
- nextPromise_fn = function() {
278
- __privateGet(this, _values).push(
279
- new Promise((resolve) => {
280
- __privateSet(this, _resolve, resolve);
281
- })
282
- );
283
- };
284
- const asyncQuerySelector = (selector, parent = document) => new Promise((resolve) => {
285
- const element = parent.querySelector(selector);
286
- if (element) return resolve(element);
287
- const observer = new MutationObserver(() => {
288
- const element2 = parent.querySelector(selector);
289
- if (!element2) return;
290
- observer.disconnect();
291
- return resolve(element2);
292
- });
293
- observer.observe(parent, {
294
- subtree: true,
295
- childList: true,
296
- attributes: true
297
- });
298
- });
299
- function isUrlOrRelativePath(value) {
300
- if (typeof value !== "string") return false;
301
- if (value.startsWith("_:")) return false;
302
- if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(value)) return true;
303
- if (value.startsWith("/")) return true;
304
- return false;
305
- }
306
- const asyncQuerySelectorAll = (selector, parent = document) => {
307
- const delivered = /* @__PURE__ */ new WeakSet();
308
- const { next, iterable } = new AsyncIterableBuilder();
309
- function checkNewElement() {
310
- for (const element of parent.querySelectorAll(selector)) {
311
- if (delivered.has(element)) continue;
312
- delivered.add(element);
313
- next(element);
314
- }
315
- }
316
- checkNewElement();
317
- const observer = new MutationObserver(checkNewElement);
318
- observer.observe(parent, {
319
- subtree: true,
320
- childList: true,
321
- attributes: true
322
- });
323
- return iterable;
324
- };
325
- const helpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
326
- __proto__: null,
327
- AsyncIterableBuilder,
328
- asyncQuerySelector,
329
- asyncQuerySelectorAll,
330
- compare,
331
- default: AsyncIterableBuilder,
332
- defineComponent,
333
- doesResourceContainList,
334
- domIsReady,
335
- evalTemplateString,
336
- findClosingBracketMatchIndex,
337
- fuzzyCompare,
338
- generalComparator,
339
- importCSS,
340
- importInlineCSS,
341
- importJS,
342
- isUrlOrRelativePath,
343
- loadScript,
344
- parseFieldsString,
345
- setDeepProperty,
346
- stringToDom,
347
- transformArrayToContainer,
348
- uniqID
349
- }, Symbol.toStringTag, { value: "Module" }));
350
- export {
351
- AsyncIterableBuilder as A,
352
- doesResourceContainList as a,
353
- fuzzyCompare as b,
354
- compare as c,
355
- defineComponent as d,
356
- evalTemplateString as e,
357
- findClosingBracketMatchIndex as f,
358
- generalComparator as g,
359
- asyncQuerySelector as h,
360
- importInlineCSS as i,
361
- importCSS as j,
362
- helpers as k,
363
- isUrlOrRelativePath as l,
364
- stringToDom as m,
365
- importJS as n,
366
- loadScript as o,
367
- parseFieldsString as p,
368
- domIsReady as q,
369
- asyncQuerySelectorAll as r,
370
- setDeepProperty as s,
371
- transformArrayToContainer as t,
372
- uniqID as u
373
- };