@startinblox/boilerplate 4.2.0 → 4.2.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
@@ -691,13 +691,13 @@ class $ extends lt {
691
691
  } = {}) {
692
692
  super(), this.cherryPickedProperties = [], this.currentRoute = "";
693
693
  const i = () => {
694
- this._attach(t, e, r).then(
694
+ document.readyState === "complete" && this._attach(t, e, r).then(
695
695
  (o) => {
696
696
  o && this.requestUpdate();
697
697
  }
698
698
  );
699
699
  };
700
- document.readyState !== "complete" ? document.addEventListener("DOMContentLoaded", i) : i();
700
+ document.readyState === "complete" ? i() : document.addEventListener("readystatechange", i);
701
701
  }
702
702
  async _attach(t, e, r) {
703
703
  return !this.orbit && window.orbit && (this.orbit = window.orbit, e) ? (be({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/boilerplate",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "Startin'blox Boilerplate",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -23,18 +23,20 @@ export default class extends ComponentObjectsHandler {
23
23
  } = {}) {
24
24
  super();
25
25
  const attach = () => {
26
- this._attach(defaultRoute, setupSubscriptions, ignoreRouter).then(
27
- (attach: boolean) => {
28
- if (attach) {
29
- this.requestUpdate();
26
+ if (document.readyState === "complete") {
27
+ this._attach(defaultRoute, setupSubscriptions, ignoreRouter).then(
28
+ (attach: boolean) => {
29
+ if (attach) {
30
+ this.requestUpdate();
31
+ }
30
32
  }
31
- },
32
- );
33
+ );
34
+ }
33
35
  };
34
- if (document.readyState !== "complete") {
35
- document.addEventListener("DOMContentLoaded", attach);
36
- } else {
36
+ if (document.readyState === "complete") {
37
37
  attach();
38
+ } else {
39
+ document.addEventListener("readystatechange", attach);
38
40
  }
39
41
  }
40
42
 
@@ -65,7 +67,7 @@ export default class extends ComponentObjectsHandler {
65
67
  protected async _attach(
66
68
  defaultRoute: boolean,
67
69
  setupSubscriptions: boolean,
68
- ignoreRouter: boolean,
70
+ ignoreRouter: boolean
69
71
  ) {
70
72
  if (!this.orbit) {
71
73
  if (window.orbit) {
@@ -109,7 +111,7 @@ export default class extends ComponentObjectsHandler {
109
111
  const rdfType = navigator.getAttribute("navigation-rdf-type");
110
112
  if (rdfType) {
111
113
  const compatibleComponents = window.orbit?.components?.filter(
112
- (c) => c?.routeAttributes?.["rdf-type"] === rdfType,
114
+ (c) => c?.routeAttributes?.["rdf-type"] === rdfType
113
115
  );
114
116
  if (compatibleComponents) target = compatibleComponents[0]?.uniq;
115
117
  }
@@ -117,7 +119,7 @@ export default class extends ComponentObjectsHandler {
117
119
  requestNavigation(
118
120
  (window.orbit ? window.orbit.getRoute(target, true) : target) +
119
121
  (subrouter ? `-${subrouter}` : ""),
120
- resource,
122
+ resource
121
123
  );
122
124
  }
123
125
  e.preventDefault();
@@ -132,7 +134,7 @@ export default class extends ComponentObjectsHandler {
132
134
 
133
135
  async _expandContainer(
134
136
  value: Resource[],
135
- recursive = true,
137
+ recursive = true
136
138
  ): Promise<UnknownResource[]> {
137
139
  const expandedContainer: UnknownResource[] = [];
138
140
  for (const entry of value) {
@@ -145,7 +147,7 @@ export default class extends ComponentObjectsHandler {
145
147
  async _getProperties(
146
148
  resource: Resource,
147
149
  recursive = true,
148
- targetProperties: PropertiesPicker[] = this.cherryPickedProperties,
150
+ targetProperties: PropertiesPicker[] = this.cherryPickedProperties
149
151
  ) {
150
152
  const properties = await resource.properties;
151
153
  const response: Resource = {
@@ -161,7 +163,7 @@ export default class extends ComponentObjectsHandler {
161
163
  response[prop.value] = await this._getProxyValue(
162
164
  response[prop.value],
163
165
  recursive,
164
- targetProperties,
166
+ targetProperties
165
167
  );
166
168
  }
167
169
  if (prop.cast) {
@@ -178,7 +180,7 @@ export default class extends ComponentObjectsHandler {
178
180
  | Resource
179
181
  | ProxyValue<Resource | Container<ProxyValue<Resource> | Resource>>,
180
182
  recursive = true,
181
- targetProperties: PropertiesPicker[] = this.cherryPickedProperties,
183
+ targetProperties: PropertiesPicker[] = this.cherryPickedProperties
182
184
  ) {
183
185
  try {
184
186
  if (resource) {
@@ -190,7 +192,7 @@ export default class extends ComponentObjectsHandler {
190
192
  if (!resource.isFullResource?.()) {
191
193
  target = await window.sibStore.getData(
192
194
  resource["@id"],
193
- CLIENT_CONTEXT,
195
+ CLIENT_CONTEXT
194
196
  );
195
197
  }
196
198
  }