@symbo.ls/utils 2.11.405 → 2.11.411

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.
@@ -133,13 +133,13 @@ var require_globals = __commonJS({
133
133
  document: () => document2,
134
134
  global: () => global,
135
135
  self: () => self,
136
- window: () => window
136
+ window: () => window2
137
137
  });
138
138
  module2.exports = __toCommonJS2(globals_exports);
139
139
  var global = globalThis;
140
140
  var self = globalThis;
141
- var window = globalThis;
142
- var document2 = window.document;
141
+ var window2 = globalThis;
142
+ var document2 = window2.document;
143
143
  }
144
144
  });
145
145
 
@@ -607,8 +607,9 @@ var require_object = __commonJS({
607
607
  diffArrays: () => diffArrays,
608
608
  diffObjects: () => diffObjects,
609
609
  exec: () => exec,
610
- findExtendsInElement: () => findExtendsInElement,
611
610
  flattenRecursive: () => flattenRecursive,
611
+ getChildrenComponentsByKey: () => getChildrenComponentsByKey,
612
+ getExtendsInElement: () => getExtendsInElement,
612
613
  hasOwnProperty: () => hasOwnProperty,
613
614
  isEmpty: () => isEmpty,
614
615
  isEmptyObject: () => isEmptyObject,
@@ -1097,7 +1098,18 @@ var require_object = __commonJS({
1097
1098
  const firstCharKey = key.slice(0, 1);
1098
1099
  return /^[A-Z]*$/.test(firstCharKey);
1099
1100
  };
1100
- var findExtendsInElement = (obj) => {
1101
+ var getChildrenComponentsByKey = (key, el) => {
1102
+ if (key === el.key || el.__ref.__componentKey === key) {
1103
+ return el;
1104
+ }
1105
+ if (el.extend) {
1106
+ const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
1107
+ const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
1108
+ if (foundString || foundInArray)
1109
+ return el;
1110
+ }
1111
+ };
1112
+ var getExtendsInElement = (obj) => {
1101
1113
  let result = [];
1102
1114
  function traverse(o) {
1103
1115
  for (const key in o) {
package/dist/cjs/index.js CHANGED
@@ -133,13 +133,13 @@ var require_globals = __commonJS({
133
133
  document: () => document2,
134
134
  global: () => global,
135
135
  self: () => self,
136
- window: () => window
136
+ window: () => window2
137
137
  });
138
138
  module2.exports = __toCommonJS2(globals_exports);
139
139
  var global = globalThis;
140
140
  var self = globalThis;
141
- var window = globalThis;
142
- var document2 = window.document;
141
+ var window2 = globalThis;
142
+ var document2 = window2.document;
143
143
  }
144
144
  });
145
145
 
@@ -607,8 +607,9 @@ var require_object = __commonJS({
607
607
  diffArrays: () => diffArrays,
608
608
  diffObjects: () => diffObjects,
609
609
  exec: () => exec,
610
- findExtendsInElement: () => findExtendsInElement,
611
610
  flattenRecursive: () => flattenRecursive,
611
+ getChildrenComponentsByKey: () => getChildrenComponentsByKey,
612
+ getExtendsInElement: () => getExtendsInElement,
612
613
  hasOwnProperty: () => hasOwnProperty,
613
614
  isEmpty: () => isEmpty,
614
615
  isEmptyObject: () => isEmptyObject,
@@ -1097,7 +1098,18 @@ var require_object = __commonJS({
1097
1098
  const firstCharKey = key.slice(0, 1);
1098
1099
  return /^[A-Z]*$/.test(firstCharKey);
1099
1100
  };
1100
- var findExtendsInElement = (obj) => {
1101
+ var getChildrenComponentsByKey = (key, el) => {
1102
+ if (key === el.key || el.__ref.__componentKey === key) {
1103
+ return el;
1104
+ }
1105
+ if (el.extend) {
1106
+ const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
1107
+ const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
1108
+ if (foundString || foundInArray)
1109
+ return el;
1110
+ }
1111
+ };
1112
+ var getExtendsInElement = (obj) => {
1101
1113
  let result = [];
1102
1114
  function traverse(o) {
1103
1115
  for (const key in o) {
@@ -1513,6 +1525,7 @@ __export(src_exports, {
1513
1525
  loadCssFile: () => loadCssFile,
1514
1526
  loadJavascript: () => loadJavascript,
1515
1527
  loadJavascriptFile: () => loadJavascriptFile,
1528
+ loadJavascriptFileSync: () => loadJavascriptFileSync,
1516
1529
  removeChars: () => removeChars,
1517
1530
  toCamelCase: () => toCamelCase,
1518
1531
  toDashCase: () => toDashCase,
@@ -1582,10 +1595,10 @@ var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/
1582
1595
  });
1583
1596
  });
1584
1597
  scriptEle.addEventListener("error", (ev) => {
1585
- reject({
1598
+ reject(new Error({
1586
1599
  status: false,
1587
1600
  message: `Failed to load the script ${FILE_URL}`
1588
- });
1601
+ }));
1589
1602
  });
1590
1603
  doc.body.appendChild(scriptEle);
1591
1604
  } catch (error) {
@@ -1593,6 +1606,19 @@ var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/
1593
1606
  }
1594
1607
  });
1595
1608
  };
1609
+ var loadJavascriptFileSync = (FILE_URL, doc = document, type = "text/javascript") => {
1610
+ const xhr = new window.XMLHttpRequest();
1611
+ xhr.open("GET", FILE_URL, false);
1612
+ xhr.send();
1613
+ if (xhr.status === 200) {
1614
+ const scriptEle = doc.createElement("script");
1615
+ scriptEle.type = type;
1616
+ scriptEle.text = xhr.responseText;
1617
+ doc.body.appendChild(scriptEle);
1618
+ } else {
1619
+ throw new Error(`Failed to load the script ${FILE_URL}`);
1620
+ }
1621
+ };
1596
1622
  var loadCssFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
1597
1623
  return new Promise((resolve, reject) => {
1598
1624
  try {
package/dist/cjs/load.js CHANGED
@@ -22,7 +22,8 @@ var load_exports = {};
22
22
  __export(load_exports, {
23
23
  loadCssFile: () => loadCssFile,
24
24
  loadJavascript: () => loadJavascript,
25
- loadJavascriptFile: () => loadJavascriptFile
25
+ loadJavascriptFile: () => loadJavascriptFile,
26
+ loadJavascriptFileSync: () => loadJavascriptFileSync
26
27
  });
27
28
  module.exports = __toCommonJS(load_exports);
28
29
  var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
@@ -38,10 +39,10 @@ var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/
38
39
  });
39
40
  });
40
41
  scriptEle.addEventListener("error", (ev) => {
41
- reject({
42
+ reject(new Error({
42
43
  status: false,
43
44
  message: `Failed to load the script ${FILE_URL}`
44
- });
45
+ }));
45
46
  });
46
47
  doc.body.appendChild(scriptEle);
47
48
  } catch (error) {
@@ -49,6 +50,19 @@ var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/
49
50
  }
50
51
  });
51
52
  };
53
+ var loadJavascriptFileSync = (FILE_URL, doc = document, type = "text/javascript") => {
54
+ const xhr = new window.XMLHttpRequest();
55
+ xhr.open("GET", FILE_URL, false);
56
+ xhr.send();
57
+ if (xhr.status === 200) {
58
+ const scriptEle = doc.createElement("script");
59
+ scriptEle.type = type;
60
+ scriptEle.text = xhr.responseText;
61
+ doc.body.appendChild(scriptEle);
62
+ } else {
63
+ throw new Error(`Failed to load the script ${FILE_URL}`);
64
+ }
65
+ };
52
66
  var loadCssFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
53
67
  return new Promise((resolve, reject) => {
54
68
  try {
@@ -607,8 +607,9 @@ var require_object = __commonJS({
607
607
  diffArrays: () => diffArrays,
608
608
  diffObjects: () => diffObjects,
609
609
  exec: () => exec,
610
- findExtendsInElement: () => findExtendsInElement,
611
610
  flattenRecursive: () => flattenRecursive,
611
+ getChildrenComponentsByKey: () => getChildrenComponentsByKey,
612
+ getExtendsInElement: () => getExtendsInElement,
612
613
  hasOwnProperty: () => hasOwnProperty,
613
614
  isEmpty: () => isEmpty,
614
615
  isEmptyObject: () => isEmptyObject,
@@ -1097,7 +1098,18 @@ var require_object = __commonJS({
1097
1098
  const firstCharKey = key.slice(0, 1);
1098
1099
  return /^[A-Z]*$/.test(firstCharKey);
1099
1100
  };
1100
- var findExtendsInElement = (obj) => {
1101
+ var getChildrenComponentsByKey = (key, el) => {
1102
+ if (key === el.key || el.__ref.__componentKey === key) {
1103
+ return el;
1104
+ }
1105
+ if (el.extend) {
1106
+ const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
1107
+ const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
1108
+ if (foundString || foundInArray)
1109
+ return el;
1110
+ }
1111
+ };
1112
+ var getExtendsInElement = (obj) => {
1101
1113
  let result = [];
1102
1114
  function traverse(o) {
1103
1115
  for (const key in o) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "2.11.405",
3
+ "version": "2.11.411",
4
4
  "author": "symbo.ls",
5
5
  "files": [
6
6
  "src",
@@ -26,5 +26,5 @@
26
26
  "dependencies": {
27
27
  "@domql/utils": "latest"
28
28
  },
29
- "gitHead": "a30570ff792bb87f8e4851a094f891545881de43"
29
+ "gitHead": "e45830a80e83324329963be4d39dc5b0aa50d43d"
30
30
  }
package/src/load.js CHANGED
@@ -15,10 +15,10 @@ export const loadJavascriptFile = (FILE_URL, async = false, doc = document, type
15
15
  })
16
16
 
17
17
  scriptEle.addEventListener('error', (ev) => {
18
- reject({
18
+ reject(new Error({
19
19
  status: false,
20
20
  message: `Failed to load the script ${FILE_URL}`
21
- })
21
+ }))
22
22
  })
23
23
 
24
24
  doc.body.appendChild(scriptEle)
@@ -28,6 +28,21 @@ export const loadJavascriptFile = (FILE_URL, async = false, doc = document, type
28
28
  })
29
29
  }
30
30
 
31
+ export const loadJavascriptFileSync = (FILE_URL, doc = document, type = 'text/javascript') => {
32
+ const xhr = new window.XMLHttpRequest()
33
+ xhr.open('GET', FILE_URL, false) // false makes the request synchronous
34
+ xhr.send()
35
+
36
+ if (xhr.status === 200) {
37
+ const scriptEle = doc.createElement('script')
38
+ scriptEle.type = type
39
+ scriptEle.text = xhr.responseText
40
+ doc.body.appendChild(scriptEle)
41
+ } else {
42
+ throw new Error(`Failed to load the script ${FILE_URL}`)
43
+ }
44
+ }
45
+
31
46
  export const loadCssFile = (FILE_URL, async = false, doc = document, type = 'text/javascript') => {
32
47
  return new Promise((resolve, reject) => {
33
48
  try {