@startinblox/boilerplate 3.0.0 → 3.0.2

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/index.js CHANGED
@@ -261,7 +261,7 @@ E.elementStyles = [], E.shadowRootOptions = { mode: "open" }, E[T("elementProper
261
261
  * SPDX-License-Identifier: BSD-3-Clause
262
262
  */
263
263
  const it = globalThis, q = it.trustedTypes, pt = q ? q.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, Rt = "$lit$", y = `lit$${Math.random().toFixed(9).slice(2)}$`, Tt = "?" + y, Yt = `<${Tt}>`, w = document, x = () => w.createComment(""), O = (s) => s === null || typeof s != "object" && typeof s != "function", rt = Array.isArray, te = (s) => rt(s) || typeof s?.[Symbol.iterator] == "function", K = `[
264
- \f\r]`, R = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ft = /-->/g, _t = />/g, b = RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^
264
+ \f\r]`, R = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, ft = /-->/g, _t = />/g, m = RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^
265
265
  \f\r"'\`<>=]|("|')|))|$)`, "g"), $t = /'/g, gt = /"/g, xt = /^(?:script|style|textarea|title)$/i, ee = (s) => (t, ...e) => ({ _$litType$: s, strings: t, values: e }), j = ee(1), P = Symbol.for("lit-noChange"), c = Symbol.for("lit-nothing"), yt = /* @__PURE__ */ new WeakMap(), A = w.createTreeWalker(w, 129);
266
266
  function Ot(s, t) {
267
267
  if (!rt(s) || !s.hasOwnProperty("raw")) throw Error("invalid template strings array");
@@ -273,8 +273,8 @@ const se = (s, t) => {
273
273
  for (let h = 0; h < e; h++) {
274
274
  const a = s[h];
275
275
  let l, d, u = -1, f = 0;
276
- for (; f < a.length && (n.lastIndex = f, d = n.exec(a), d !== null); ) f = n.lastIndex, n === R ? d[1] === "!--" ? n = ft : d[1] !== void 0 ? n = _t : d[2] !== void 0 ? (xt.test(d[2]) && (i = RegExp("</" + d[2], "g")), n = b) : d[3] !== void 0 && (n = b) : n === b ? d[0] === ">" ? (n = i ?? R, u = -1) : d[1] === void 0 ? u = -2 : (u = n.lastIndex - d[2].length, l = d[1], n = d[3] === void 0 ? b : d[3] === '"' ? gt : $t) : n === gt || n === $t ? n = b : n === ft || n === _t ? n = R : (n = b, i = void 0);
277
- const g = n === b && s[h + 1].startsWith("/>") ? " " : "";
276
+ for (; f < a.length && (n.lastIndex = f, d = n.exec(a), d !== null); ) f = n.lastIndex, n === R ? d[1] === "!--" ? n = ft : d[1] !== void 0 ? n = _t : d[2] !== void 0 ? (xt.test(d[2]) && (i = RegExp("</" + d[2], "g")), n = m) : d[3] !== void 0 && (n = m) : n === m ? d[0] === ">" ? (n = i ?? R, u = -1) : d[1] === void 0 ? u = -2 : (u = n.lastIndex - d[2].length, l = d[1], n = d[3] === void 0 ? m : d[3] === '"' ? gt : $t) : n === gt || n === $t ? n = m : n === ft || n === _t ? n = R : (n = m, i = void 0);
277
+ const g = n === m && s[h + 1].startsWith("/>") ? " " : "";
278
278
  o += n === R ? a + Yt : u >= 0 ? (r.push(l), a.slice(0, u) + Rt + a.slice(u) + y + g) : a + y + (u === -2 ? h : g);
279
279
  }
280
280
  return [Ot(s, o + (s[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
@@ -709,7 +709,7 @@ class $ extends at {
709
709
  }
710
710
  );
711
711
  };
712
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", i) : i();
712
+ document.readyState !== "complete" ? document.addEventListener("DOMContentLoaded", i) : i();
713
713
  }
714
714
  async _attach(t, e, r) {
715
715
  return !this.orbit && window.orbit && (this.orbit = window.orbit, e) ? (Ae({
@@ -767,9 +767,9 @@ class $ extends at {
767
767
  try {
768
768
  if (t) {
769
769
  let i = t;
770
- if (typeof t == "string" && (i = await window.sibStore.getData(t, mt)), typeof t != "string" && t.isFullResource && (t.isFullResource?.() || (i = await window.sibStore.getData(
770
+ if (typeof t == "string" && (i = await window.sibStore.getData(t, bt)), typeof t != "string" && t.isFullResource && (t.isFullResource?.() || (i = await window.sibStore.getData(
771
771
  t["@id"],
772
- mt
772
+ bt
773
773
  ))), typeof t != "string" && !t.isFullResource && (i.properties = Object.keys(i), i.get = (o) => i[o]), !i) return { _originalResource: i };
774
774
  if (typeof i == "object" && i !== null) {
775
775
  if (i["ldp:contains"]) {
@@ -815,17 +815,20 @@ v([
815
815
  v([
816
816
  jt()
817
817
  ], $.prototype, "currentRoute");
818
- const be = (s, { keywords: t = [], attributes: e = ["dataSrc"] } = {}) => {
819
- t && e && (s.caching === void 0 && (s.caching = 0), s.hasCachedDatas === void 0 && (s.hasCachedDatas = !1), s.cacheListener = (r) => {
820
- const i = r.detail.id || r.detail.resource["@id"];
821
- if (t.some((o) => i?.includes(o))) {
822
- for (const o of e)
823
- s[o] && i !== s[o] && window.sibStore.clearCache(s[o]);
824
- s.caching++, s.hasCachedDatas = !1, s.requestUpdate();
825
- }
826
- }, s._subscriptions.add(["save", s.cacheListener]), s._subscribe());
818
+ const me = (s, { keywords: t = [], attributes: e = ["dataSrc"] } = {}) => {
819
+ const r = () => {
820
+ t && e && (s.caching === void 0 && (s.caching = 0), s.hasCachedDatas === void 0 && (s.hasCachedDatas = !1), s.cacheListener = (i) => {
821
+ const o = i.detail.id || i.detail.resource["@id"];
822
+ if (t.some((n) => o?.includes(n))) {
823
+ for (const n of e)
824
+ s[n] && o !== s[n] && window.sibStore.clearCache(s[n]);
825
+ s.caching++, s.hasCachedDatas = !1, s.requestUpdate();
826
+ }
827
+ }, s._subscriptions.add(["save", s.cacheListener]), s._subscribe());
828
+ };
829
+ document.readyState !== "complete" ? document.addEventListener("DOMContentLoaded", r) : r();
827
830
  };
828
- function me() {
831
+ function be() {
829
832
  return Math.random().toString(16).slice(2);
830
833
  }
831
834
  const Ae = ({
@@ -833,7 +836,7 @@ const Ae = ({
833
836
  defaultRoute: t = !1,
834
837
  ignoreRouter: e = !1
835
838
  }) => {
836
- if (s.uniq || (s.uniq = me(), t && !s.route && !e && (s.route = t)), s._subscriptions = /* @__PURE__ */ new Set(), !e) {
839
+ if (s.uniq || (s.uniq = be(), t && !s.route && !e && (s.route = t)), s._subscriptions = /* @__PURE__ */ new Set(), !e) {
837
840
  s.route || (s.route = s.uniq, window.orbit && (s.route = window.orbit.getRoute(s.uniq))), s.noRouter = !0;
838
841
  let r = document.querySelector("solid-router");
839
842
  for (; r; )
@@ -897,14 +900,14 @@ class we extends S {
897
900
  ) ? e.call(this) : c;
898
901
  }
899
902
  }
900
- const bt = (s, t) => {
903
+ const mt = (s, t) => {
901
904
  let e = s;
902
905
  for (let r = 0; r < t.length && (e && t[r] in e); r++)
903
906
  e = e[t[r]];
904
907
  return e;
905
908
  }, Ee = (s, t, e = "asc") => s.sort((r, i) => {
906
909
  let o = r, n = i;
907
- Array.isArray(t) ? (o = bt(r, t), n = bt(i, t)) : (o = r[t], n = i[t]);
910
+ Array.isArray(t) ? (o = mt(r, t), n = mt(i, t)) : (o = r[t], n = i[t]);
908
911
  let h = 0;
909
912
  if (typeof o == "number" && typeof n == "number")
910
913
  h = o - n;
@@ -924,7 +927,7 @@ const bt = (s, t) => {
924
927
  }
925
928
  })
926
929
  );
927
- }, mt = {};
930
+ }, bt = {};
928
931
  var Pe = Object.getOwnPropertyDescriptor, Ce = (s, t, e, r) => {
929
932
  for (var i = r > 1 ? void 0 : r ? Pe(t, e) : t, o = s.length - 1, n; o >= 0; o--)
930
933
  (n = s[o]) && (i = n(i) || i);
@@ -948,7 +951,7 @@ let Z = class extends $ {
948
951
  });
949
952
  }
950
953
  async _afterAttach() {
951
- return be(this, {
954
+ return me(this, {
952
955
  keywords: ["some-keyword", "for-invalidating", "cache"]
953
956
  }), Promise.resolve();
954
957
  }
@@ -1117,32 +1120,32 @@ function ke(s) {
1117
1120
  function X(s) {
1118
1121
  window.dispatchEvent(new CustomEvent(G, { detail: s }));
1119
1122
  }
1120
- let I = "", J, Dt, k, Q, qt, m = new Ht();
1121
- m.resolve();
1123
+ let I = "", J, Dt, k, Q, qt, b = new Ht();
1124
+ b.resolve();
1122
1125
  let N = 0;
1123
1126
  const ze = (s) => (Oe((t, e) => Ie(qt, t, e)), I = Dt = s.sourceLocale, k = new Set(s.targetLocales), k.add(s.sourceLocale), Q = s.loadLocale, { getLocale: Ve, setLocale: We }), Ve = () => I, We = (s) => {
1124
1127
  if (s === (J ?? I))
1125
- return m.promise;
1128
+ return b.promise;
1126
1129
  if (!k || !Q)
1127
1130
  throw new Error("Internal error");
1128
1131
  if (!k.has(s))
1129
1132
  throw new Error("Invalid locale code");
1130
1133
  N++;
1131
1134
  const t = N;
1132
- return J = s, m.settled && (m = new Ht()), X({ status: "loading", loadingLocale: s }), (s === Dt ? (
1135
+ return J = s, b.settled && (b = new Ht()), X({ status: "loading", loadingLocale: s }), (s === Dt ? (
1133
1136
  // We could switch to the source locale synchronously, but we prefer to
1134
1137
  // queue it on a microtask so that switching locales is consistently
1135
1138
  // asynchronous.
1136
1139
  Promise.resolve({ templates: void 0 })
1137
1140
  ) : Q(s)).then((r) => {
1138
- N === t && (I = s, J = void 0, qt = r.templates, X({ status: "ready", readyLocale: s }), m.resolve());
1141
+ N === t && (I = s, J = void 0, qt = r.templates, X({ status: "ready", readyLocale: s }), b.resolve());
1139
1142
  }, (r) => {
1140
1143
  N === t && (X({
1141
1144
  status: "error",
1142
1145
  errorLocale: s,
1143
1146
  errorMessage: r.toString()
1144
- }), m.reject(r));
1145
- }), m.promise;
1147
+ }), b.reject(r));
1148
+ }), b.promise;
1146
1149
  }, It = ":host{background-color:pink;user-select:none}";
1147
1150
  var Be = Object.defineProperty, Fe = Object.getOwnPropertyDescriptor, kt = (s, t, e, r) => {
1148
1151
  for (var i = r > 1 ? void 0 : r ? Fe(t, e) : t, o = s.length - 1, n; o >= 0; o--)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/boilerplate",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Startin'blox Boilerplate",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -34,7 +34,7 @@ export default class extends ComponentObjectsHandler {
34
34
  },
35
35
  );
36
36
  };
37
- if (document.readyState === "loading") {
37
+ if (document.readyState !== "complete") {
38
38
  document.addEventListener("DOMContentLoaded", attach);
39
39
  } else {
40
40
  attach();
@@ -6,31 +6,38 @@ const setupCacheInvalidation = (
6
6
  component: any,
7
7
  { keywords = [] as string[], attributes = ["dataSrc"] } = {}
8
8
  ) => {
9
- if (keywords && attributes) {
10
- if (component.caching === undefined) {
11
- component.caching = 0;
12
- }
13
- if (component.hasCachedDatas === undefined) {
14
- component.hasCachedDatas = false;
15
- }
9
+ const setup = () => {
10
+ if (keywords && attributes) {
11
+ if (component.caching === undefined) {
12
+ component.caching = 0;
13
+ }
14
+ if (component.hasCachedDatas === undefined) {
15
+ component.hasCachedDatas = false;
16
+ }
16
17
 
17
- component.cacheListener = (e: Event) => {
18
- const resource = e.detail.id || e.detail.resource["@id"];
19
- if (keywords.some((keyword) => resource?.includes(keyword))) {
20
- for (const attribute of attributes) {
21
- if (component[attribute] && resource !== component[attribute]) {
22
- window.sibStore.clearCache(component[attribute]);
18
+ component.cacheListener = (e: Event) => {
19
+ const resource = e.detail.id || e.detail.resource["@id"];
20
+ if (keywords.some((keyword) => resource?.includes(keyword))) {
21
+ for (const attribute of attributes) {
22
+ if (component[attribute] && resource !== component[attribute]) {
23
+ window.sibStore.clearCache(component[attribute]);
24
+ }
23
25
  }
26
+ component.caching++;
27
+ component.hasCachedDatas = false;
28
+ component.requestUpdate();
24
29
  }
25
- component.caching++;
26
- component.hasCachedDatas = false;
27
- component.requestUpdate();
28
- }
29
- };
30
+ };
30
31
 
31
- component._subscriptions.add(["save", component.cacheListener]);
32
+ component._subscriptions.add(["save", component.cacheListener]);
32
33
 
33
- component._subscribe();
34
+ component._subscribe();
35
+ }
36
+ };
37
+ if (document.readyState !== "complete") {
38
+ document.addEventListener("DOMContentLoaded", setup);
39
+ } else {
40
+ setup();
34
41
  }
35
42
  };
36
43
 
@@ -3,29 +3,36 @@ Common code for components
3
3
  Handle cache invalidation based on keywords
4
4
  */
5
5
  const setupCacheOnResourceReady = (component: any, { keywords = [] } = {}) => {
6
- if (keywords) {
7
- if (component.caching === undefined) {
8
- component.caching = 0;
9
- }
10
- if (component.hasCachedDatas === undefined) {
11
- component.hasCachedDatas = false;
12
- }
13
-
14
- component.resourceCacheListener = (e: Event) => {
15
- const resource = e.detail.id || e.detail.resource["@id"];
16
- if (keywords.some((keyword) => resource?.includes(keyword))) {
17
- component.caching++;
6
+ const setup = () => {
7
+ if (keywords) {
8
+ if (component.caching === undefined) {
9
+ component.caching = 0;
10
+ }
11
+ if (component.hasCachedDatas === undefined) {
18
12
  component.hasCachedDatas = false;
19
- component.requestUpdate();
20
13
  }
21
- };
22
14
 
23
- component._subscriptions.add([
24
- "resourceReady",
25
- component.resourceCacheListener,
26
- ]);
15
+ component.resourceCacheListener = (e: Event) => {
16
+ const resource = e.detail.id || e.detail.resource["@id"];
17
+ if (keywords.some((keyword) => resource?.includes(keyword))) {
18
+ component.caching++;
19
+ component.hasCachedDatas = false;
20
+ component.requestUpdate();
21
+ }
22
+ };
23
+
24
+ component._subscriptions.add([
25
+ "resourceReady",
26
+ component.resourceCacheListener,
27
+ ]);
27
28
 
28
- component._subscribe();
29
+ component._subscribe();
30
+ }
31
+ };
32
+ if (document.readyState !== "complete") {
33
+ document.addEventListener("DOMContentLoaded", setup);
34
+ } else {
35
+ setup();
29
36
  }
30
37
  };
31
38