@domql/utils 2.5.126 → 2.5.134

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/component.js ADDED
@@ -0,0 +1,159 @@
1
+ 'use strict'
2
+
3
+ import { exec, isArray, isFunction, isObject, isString, joinArrays } from '.'
4
+ const ENV = process.env.NODE_ENV
5
+
6
+ export const checkIfKeyIsComponent = (key) => {
7
+ const isFirstKeyString = isString(key)
8
+ if (!isFirstKeyString) return
9
+ const firstCharKey = key.slice(0, 1)
10
+ return /^[A-Z]*$/.test(firstCharKey)
11
+ }
12
+
13
+ export const checkIfKeyIsProperty = (key) => {
14
+ const isFirstKeyString = isString(key)
15
+ if (!isFirstKeyString) return
16
+ const firstCharKey = key.slice(0, 1)
17
+ return /^[a-z]*$/.test(firstCharKey)
18
+ }
19
+
20
+ export const addAdditionalExtend = (newExtend, element) => {
21
+ const { extend: elementExtend } = element
22
+ const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend]
23
+ const receivedArray = isArray(newExtend) ? newExtend : [newExtend]
24
+ const extend = joinArrays(receivedArray, originalArray)
25
+ return { ...element, extend }
26
+ }
27
+
28
+ export const extendizeByKey = (element, parent, key) => {
29
+ const { context } = parent
30
+ const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element
31
+ const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data
32
+
33
+ const extendFromKey = key.includes('+')
34
+ ? key.split('+') // get array of componentKeys
35
+ : key.includes('_')
36
+ ? [key.split('_')[0]] // get component key split _
37
+ : key.includes('.') && !checkIfKeyIsComponent(key.split('.')[1])
38
+ ? [key.split('.')[0]] // get component key split .
39
+ : [key]
40
+
41
+ // console.log(extendFromKey)
42
+ // console.log(context, context?.components)
43
+ // console.log(element)
44
+ const isExtendKeyComponent = context && context.components[extendFromKey]
45
+
46
+ if (element === isExtendKeyComponent) return element
47
+ else if (!hasComponentAttrs || childProps) {
48
+ return {
49
+ extend: extendFromKey,
50
+ tag,
51
+ props: { ...element }
52
+ }
53
+ } else if (!extend || extend === true) {
54
+ return {
55
+ ...element,
56
+ tag,
57
+ extend: extendFromKey
58
+ }
59
+ } else if (extend) {
60
+ return addAdditionalExtend(extendFromKey, element)
61
+ } else if (isFunction(element)) {
62
+ return {
63
+ extend: extendFromKey,
64
+ tag,
65
+ props: { ...exec(element, parent) }
66
+ }
67
+ }
68
+ }
69
+
70
+ export const applyKeyComponentAsExtend = (element, parent, key) => {
71
+ return extendizeByKey(element, parent, key) || element
72
+ }
73
+
74
+ export const applyComponentFromContext = (element, parent, options) => {
75
+ const { context } = element
76
+
77
+ if (!context || !context.components) return
78
+
79
+ const { components } = context
80
+ const { extend } = element
81
+ const execExtend = exec(extend, element)
82
+ if (isString(execExtend)) {
83
+ const componentExists = components[execExtend] || components['smbls.' + execExtend]
84
+ if (componentExists) element.extend = componentExists
85
+ else {
86
+ if ((ENV === 'test' || ENV === 'development') && options.verbose) {
87
+ console.warn(execExtend, 'is not in library', components, element)
88
+ console.warn('replacing with ', {})
89
+ }
90
+ element.extend = {}
91
+ }
92
+ }
93
+ }
94
+
95
+ export const isVariant = (param) => {
96
+ if (!isString(param)) return
97
+ const firstCharKey = param.slice(0, 1)
98
+ // return (firstCharKey === '.' || firstCharKey === '$')
99
+ return (firstCharKey === '.')
100
+ }
101
+
102
+ export const hasVariantProp = (element) => {
103
+ const { props } = element
104
+ if (isObject(props) && isString(props.variant)) return true
105
+ }
106
+
107
+ export const getChildrenComponentsByKey = (key, el) => {
108
+ if (key === el.key || el.__ref.__componentKey === key) {
109
+ return el
110
+ }
111
+
112
+ // Check if the prop is "extend" and it's either a string or an array
113
+ if (el.extend) {
114
+ // Add the value of the extend key to the result array
115
+ const foundString = isString(el.extend) && el.extend === key
116
+ const foundInArray = isArray(el.extend) && el.extend.filter(v => v === key).length
117
+ if (foundString || foundInArray) return el
118
+ }
119
+
120
+ if (el.parent && el.parent.childExtend) {
121
+ // Add the value of the extend key to the result array
122
+ const foundString = isString(el.parent.childExtend) && el.parent.childExtend === key
123
+ const foundInArray = isArray(el.parent.childExtend) && el.parent.childExtend.filter(v => v === key).length
124
+ if (foundString || foundInArray) return el
125
+ }
126
+ }
127
+
128
+ export const getExtendsInElement = (obj) => {
129
+ let result = []
130
+
131
+ function traverse (o) {
132
+ for (const key in o) {
133
+ if (Object.hasOwnProperty.call(o, key)) {
134
+ // Check if the key starts with a capital letter and exclude keys like @mobileL, $propsCollection
135
+ if (checkIfKeyIsComponent(key)) {
136
+ result.push(key)
137
+ }
138
+
139
+ // Check if the key is "extend" and it's either a string or an array
140
+ if (key === 'extend') {
141
+ // Add the value of the extend key to the result array
142
+ if (typeof o[key] === 'string') {
143
+ result.push(o[key])
144
+ } else if (Array.isArray(o[key])) {
145
+ result = result.concat(o[key])
146
+ }
147
+ }
148
+
149
+ // If the property is an object, traverse it
150
+ if (typeof o[key] === 'object' && o[key] !== null) {
151
+ traverse(o[key])
152
+ }
153
+ }
154
+ }
155
+ }
156
+
157
+ traverse(obj)
158
+ return result
159
+ }
package/cookie.js CHANGED
@@ -27,3 +27,8 @@ export const getCookie = (cname) => {
27
27
  }
28
28
  return ''
29
29
  }
30
+
31
+ export const removeCookie = (cname) => {
32
+ if (isUndefined(document) || isUndefined(document.cookie)) return
33
+ document.cookie = cname + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'
34
+ }
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var component_exports = {};
20
+ __export(component_exports, {
21
+ addAdditionalExtend: () => addAdditionalExtend,
22
+ applyComponentFromContext: () => applyComponentFromContext,
23
+ applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
24
+ checkIfKeyIsComponent: () => checkIfKeyIsComponent,
25
+ checkIfKeyIsProperty: () => checkIfKeyIsProperty,
26
+ extendizeByKey: () => extendizeByKey,
27
+ getChildrenComponentsByKey: () => getChildrenComponentsByKey,
28
+ getExtendsInElement: () => getExtendsInElement,
29
+ hasVariantProp: () => hasVariantProp,
30
+ isVariant: () => isVariant
31
+ });
32
+ module.exports = __toCommonJS(component_exports);
33
+ var import__ = require(".");
34
+ const ENV = "development";
35
+ const checkIfKeyIsComponent = (key) => {
36
+ const isFirstKeyString = (0, import__.isString)(key);
37
+ if (!isFirstKeyString)
38
+ return;
39
+ const firstCharKey = key.slice(0, 1);
40
+ return /^[A-Z]*$/.test(firstCharKey);
41
+ };
42
+ const checkIfKeyIsProperty = (key) => {
43
+ const isFirstKeyString = (0, import__.isString)(key);
44
+ if (!isFirstKeyString)
45
+ return;
46
+ const firstCharKey = key.slice(0, 1);
47
+ return /^[a-z]*$/.test(firstCharKey);
48
+ };
49
+ const addAdditionalExtend = (newExtend, element) => {
50
+ const { extend: elementExtend } = element;
51
+ const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
52
+ const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
53
+ const extend = (0, import__.joinArrays)(receivedArray, originalArray);
54
+ return { ...element, extend };
55
+ };
56
+ const extendizeByKey = (element, parent, key) => {
57
+ const { context } = parent;
58
+ const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
59
+ const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
60
+ const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
61
+ const isExtendKeyComponent = context && context.components[extendFromKey];
62
+ if (element === isExtendKeyComponent)
63
+ return element;
64
+ else if (!hasComponentAttrs || childProps) {
65
+ return {
66
+ extend: extendFromKey,
67
+ tag,
68
+ props: { ...element }
69
+ };
70
+ } else if (!extend || extend === true) {
71
+ return {
72
+ ...element,
73
+ tag,
74
+ extend: extendFromKey
75
+ };
76
+ } else if (extend) {
77
+ return addAdditionalExtend(extendFromKey, element);
78
+ } else if ((0, import__.isFunction)(element)) {
79
+ return {
80
+ extend: extendFromKey,
81
+ tag,
82
+ props: { ...(0, import__.exec)(element, parent) }
83
+ };
84
+ }
85
+ };
86
+ const applyKeyComponentAsExtend = (element, parent, key) => {
87
+ return extendizeByKey(element, parent, key) || element;
88
+ };
89
+ const applyComponentFromContext = (element, parent, options) => {
90
+ const { context } = element;
91
+ if (!context || !context.components)
92
+ return;
93
+ const { components } = context;
94
+ const { extend } = element;
95
+ const execExtend = (0, import__.exec)(extend, element);
96
+ if ((0, import__.isString)(execExtend)) {
97
+ const componentExists = components[execExtend] || components["smbls." + execExtend];
98
+ if (componentExists)
99
+ element.extend = componentExists;
100
+ else {
101
+ if ((ENV === "test" || ENV === "development") && options.verbose) {
102
+ console.warn(execExtend, "is not in library", components, element);
103
+ console.warn("replacing with ", {});
104
+ }
105
+ element.extend = {};
106
+ }
107
+ }
108
+ };
109
+ const isVariant = (param) => {
110
+ if (!(0, import__.isString)(param))
111
+ return;
112
+ const firstCharKey = param.slice(0, 1);
113
+ return firstCharKey === ".";
114
+ };
115
+ const hasVariantProp = (element) => {
116
+ const { props } = element;
117
+ if ((0, import__.isObject)(props) && (0, import__.isString)(props.variant))
118
+ return true;
119
+ };
120
+ const getChildrenComponentsByKey = (key, el) => {
121
+ if (key === el.key || el.__ref.__componentKey === key) {
122
+ return el;
123
+ }
124
+ if (el.extend) {
125
+ const foundString = (0, import__.isString)(el.extend) && el.extend === key;
126
+ const foundInArray = (0, import__.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
127
+ if (foundString || foundInArray)
128
+ return el;
129
+ }
130
+ if (el.parent && el.parent.childExtend) {
131
+ const foundString = (0, import__.isString)(el.parent.childExtend) && el.parent.childExtend === key;
132
+ const foundInArray = (0, import__.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
133
+ if (foundString || foundInArray)
134
+ return el;
135
+ }
136
+ };
137
+ const getExtendsInElement = (obj) => {
138
+ let result = [];
139
+ function traverse(o) {
140
+ for (const key in o) {
141
+ if (Object.hasOwnProperty.call(o, key)) {
142
+ if (checkIfKeyIsComponent(key)) {
143
+ result.push(key);
144
+ }
145
+ if (key === "extend") {
146
+ if (typeof o[key] === "string") {
147
+ result.push(o[key]);
148
+ } else if (Array.isArray(o[key])) {
149
+ result = result.concat(o[key]);
150
+ }
151
+ }
152
+ if (typeof o[key] === "object" && o[key] !== null) {
153
+ traverse(o[key]);
154
+ }
155
+ }
156
+ }
157
+ }
158
+ traverse(obj);
159
+ return result;
160
+ };
@@ -20,6 +20,7 @@ var cookie_exports = {};
20
20
  __export(cookie_exports, {
21
21
  getCookie: () => getCookie,
22
22
  isMobile: () => isMobile,
23
+ removeCookie: () => removeCookie,
23
24
  setCookie: () => setCookie
24
25
  });
25
26
  module.exports = __toCommonJS(cookie_exports);
@@ -49,3 +50,8 @@ const getCookie = (cname) => {
49
50
  }
50
51
  return "";
51
52
  };
53
+ const removeCookie = (cname) => {
54
+ if ((0, import_types.isUndefined)(import_utils.document) || (0, import_types.isUndefined)(import_utils.document.cookie))
55
+ return;
56
+ import_utils.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
57
+ };
package/dist/cjs/index.js CHANGED
@@ -27,3 +27,4 @@ __reExport(utils_exports, require("./string.js"), module.exports);
27
27
  __reExport(utils_exports, require("./globals.js"), module.exports);
28
28
  __reExport(utils_exports, require("./cookie.js"), module.exports);
29
29
  __reExport(utils_exports, require("./tags.js"), module.exports);
30
+ __reExport(utils_exports, require("./component.js"), module.exports);
@@ -18,7 +18,6 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var object_exports = {};
20
20
  __export(object_exports, {
21
- checkIfKeyIsComponent: () => checkIfKeyIsComponent,
22
21
  clone: () => clone,
23
22
  createNestedObject: () => createNestedObject,
24
23
  createObjectWithoutPrototype: () => createObjectWithoutPrototype,
@@ -30,6 +29,7 @@ __export(object_exports, {
30
29
  deepDiff: () => deepDiff,
31
30
  deepMerge: () => deepMerge,
32
31
  deepStringify: () => deepStringify,
32
+ deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
33
33
  detachFunctionsFromObject: () => detachFunctionsFromObject,
34
34
  detectInfiniteLoop: () => detectInfiniteLoop,
35
35
  diff: () => diff,
@@ -37,8 +37,6 @@ __export(object_exports, {
37
37
  diffObjects: () => diffObjects,
38
38
  exec: () => exec,
39
39
  flattenRecursive: () => flattenRecursive,
40
- getChildrenComponentsByKey: () => getChildrenComponentsByKey,
41
- getExtendsInElement: () => getExtendsInElement,
42
40
  hasOwnProperty: () => hasOwnProperty,
43
41
  isEmpty: () => isEmpty,
44
42
  isEmptyObject: () => isEmptyObject,
@@ -182,6 +180,11 @@ const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
182
180
  return o;
183
181
  };
184
182
  const deepStringify = (obj, stringified = {}) => {
183
+ var _a;
184
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
185
+ console.warn("Trying to clone element or state at", obj);
186
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
187
+ }
185
188
  for (const prop in obj) {
186
189
  const objProp = obj[prop];
187
190
  if ((0, import_types.isFunction)(objProp)) {
@@ -207,6 +210,39 @@ const deepStringify = (obj, stringified = {}) => {
207
210
  }
208
211
  return stringified;
209
212
  };
213
+ const MAX_DEPTH = 100;
214
+ const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
215
+ if (depth > MAX_DEPTH) {
216
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
217
+ return "[MAX_DEPTH_EXCEEDED]";
218
+ }
219
+ for (const prop in obj) {
220
+ const currentPath = path ? `${path}.${prop}` : prop;
221
+ const objProp = obj[prop];
222
+ if ((0, import_types.isFunction)(objProp)) {
223
+ stringified[prop] = objProp.toString();
224
+ } else if ((0, import_types.isObject)(objProp)) {
225
+ stringified[prop] = {};
226
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
227
+ } else if ((0, import_types.isArray)(objProp)) {
228
+ stringified[prop] = [];
229
+ objProp.forEach((v, i) => {
230
+ const itemPath = `${currentPath}[${i}]`;
231
+ if ((0, import_types.isObject)(v)) {
232
+ stringified[prop][i] = {};
233
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
234
+ } else if ((0, import_types.isFunction)(v)) {
235
+ stringified[prop][i] = v.toString();
236
+ } else {
237
+ stringified[prop][i] = v;
238
+ }
239
+ });
240
+ } else {
241
+ stringified[prop] = objProp;
242
+ }
243
+ }
244
+ return stringified;
245
+ };
210
246
  const objectToString = (obj = {}, indent = 0) => {
211
247
  const spaces = " ".repeat(indent);
212
248
  let str = "{\n";
@@ -543,54 +579,6 @@ const createObjectWithoutPrototype = (obj) => {
543
579
  }
544
580
  return newObj;
545
581
  };
546
- const checkIfKeyIsComponent = (key) => {
547
- const isFirstKeyString = (0, import_types.isString)(key);
548
- if (!isFirstKeyString)
549
- return;
550
- const firstCharKey = key.slice(0, 1);
551
- return /^[A-Z]*$/.test(firstCharKey);
552
- };
553
- const getChildrenComponentsByKey = (key, el) => {
554
- if (key === el.key || el.__ref.__componentKey === key) {
555
- return el;
556
- }
557
- if (el.extend) {
558
- const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
559
- const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
560
- if (foundString || foundInArray)
561
- return el;
562
- }
563
- if (el.parent && el.parent.childExtend) {
564
- const foundString = (0, import_types.isString)(el.parent.childExtend) && el.parent.childExtend === key;
565
- const foundInArray = (0, import_types.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
566
- if (foundString || foundInArray)
567
- return el;
568
- }
569
- };
570
- const getExtendsInElement = (obj) => {
571
- let result = [];
572
- function traverse(o) {
573
- for (const key in o) {
574
- if (Object.hasOwnProperty.call(o, key)) {
575
- if (checkIfKeyIsComponent(key)) {
576
- result.push(key);
577
- }
578
- if (key === "extend") {
579
- if (typeof o[key] === "string") {
580
- result.push(o[key]);
581
- } else if (Array.isArray(o[key])) {
582
- result = result.concat(o[key]);
583
- }
584
- }
585
- if (typeof o[key] === "object" && o[key] !== null) {
586
- traverse(o[key]);
587
- }
588
- }
589
- }
590
- }
591
- traverse(obj);
592
- return result;
593
- };
594
582
  const createNestedObject = (arr, lastValue) => {
595
583
  const nestedObject = {};
596
584
  if (arr.length === 0) {
package/index.js CHANGED
@@ -12,3 +12,4 @@ export * from './string.js'
12
12
  export * from './globals.js'
13
13
  export * from './cookie.js'
14
14
  export * from './tags.js'
15
+ export * from './component.js'
package/object.js CHANGED
@@ -199,6 +199,11 @@ export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}) =
199
199
  * Stringify object
200
200
  */
201
201
  export const deepStringify = (obj, stringified = {}) => {
202
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
203
+ console.warn('Trying to clone element or state at', obj)
204
+ obj = obj.parse?.()
205
+ }
206
+
202
207
  for (const prop in obj) {
203
208
  const objProp = obj[prop]
204
209
  if (isFunction(objProp)) {
@@ -225,6 +230,42 @@ export const deepStringify = (obj, stringified = {}) => {
225
230
  return stringified
226
231
  }
227
232
 
233
+ const MAX_DEPTH = 100 // Adjust this value as needed
234
+ export const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = '') => {
235
+ if (depth > MAX_DEPTH) {
236
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`)
237
+ return '[MAX_DEPTH_EXCEEDED]'
238
+ }
239
+
240
+ for (const prop in obj) {
241
+ const currentPath = path ? `${path}.${prop}` : prop
242
+ const objProp = obj[prop]
243
+
244
+ if (isFunction(objProp)) {
245
+ stringified[prop] = objProp.toString()
246
+ } else if (isObject(objProp)) {
247
+ stringified[prop] = {}
248
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath)
249
+ } else if (isArray(objProp)) {
250
+ stringified[prop] = []
251
+ objProp.forEach((v, i) => {
252
+ const itemPath = `${currentPath}[${i}]`
253
+ if (isObject(v)) {
254
+ stringified[prop][i] = {}
255
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath)
256
+ } else if (isFunction(v)) {
257
+ stringified[prop][i] = v.toString()
258
+ } else {
259
+ stringified[prop][i] = v
260
+ }
261
+ })
262
+ } else {
263
+ stringified[prop] = objProp
264
+ }
265
+ }
266
+ return stringified
267
+ }
268
+
228
269
  export const objectToString = (obj = {}, indent = 0) => {
229
270
  const spaces = ' '.repeat(indent)
230
271
  let str = '{\n'
@@ -668,67 +709,6 @@ export const createObjectWithoutPrototype = (obj) => {
668
709
  return newObj
669
710
  }
670
711
 
671
- export const checkIfKeyIsComponent = (key) => {
672
- const isFirstKeyString = isString(key)
673
- if (!isFirstKeyString) return
674
- const firstCharKey = key.slice(0, 1)
675
- return /^[A-Z]*$/.test(firstCharKey)
676
- }
677
-
678
- export const getChildrenComponentsByKey = (key, el) => {
679
- if (key === el.key || el.__ref.__componentKey === key) {
680
- return el
681
- }
682
-
683
- // Check if the prop is "extend" and it's either a string or an array
684
- if (el.extend) {
685
- // Add the value of the extend key to the result array
686
- const foundString = isString(el.extend) && el.extend === key
687
- const foundInArray = isArray(el.extend) && el.extend.filter(v => v === key).length
688
- if (foundString || foundInArray) return el
689
- }
690
-
691
- if (el.parent && el.parent.childExtend) {
692
- // Add the value of the extend key to the result array
693
- const foundString = isString(el.parent.childExtend) && el.parent.childExtend === key
694
- const foundInArray = isArray(el.parent.childExtend) && el.parent.childExtend.filter(v => v === key).length
695
- if (foundString || foundInArray) return el
696
- }
697
- }
698
-
699
- export const getExtendsInElement = (obj) => {
700
- let result = []
701
-
702
- function traverse (o) {
703
- for (const key in o) {
704
- if (Object.hasOwnProperty.call(o, key)) {
705
- // Check if the key starts with a capital letter and exclude keys like @mobileL, $propsCollection
706
- if (checkIfKeyIsComponent(key)) {
707
- result.push(key)
708
- }
709
-
710
- // Check if the key is "extend" and it's either a string or an array
711
- if (key === 'extend') {
712
- // Add the value of the extend key to the result array
713
- if (typeof o[key] === 'string') {
714
- result.push(o[key])
715
- } else if (Array.isArray(o[key])) {
716
- result = result.concat(o[key])
717
- }
718
- }
719
-
720
- // If the property is an object, traverse it
721
- if (typeof o[key] === 'object' && o[key] !== null) {
722
- traverse(o[key])
723
- }
724
- }
725
- }
726
- }
727
-
728
- traverse(obj)
729
- return result
730
- }
731
-
732
712
  export const createNestedObject = (arr, lastValue) => {
733
713
  const nestedObject = {}
734
714
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.126",
3
+ "version": "2.5.134",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -8,7 +8,9 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "kalduna": "./index.js",
11
- "default": "./dist/cjs/index.js"
11
+ "default": "./dist/cjs/index.js",
12
+ "import": "./index.js",
13
+ "require": "./dist/cjs/index.js"
12
14
  }
13
15
  },
14
16
  "source": "index.js",
@@ -23,7 +25,7 @@
23
25
  "build": "yarn build:cjs",
24
26
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
25
27
  },
26
- "gitHead": "e1ba05fba6c04b2379905d5e05d3d4fe17cb0978",
28
+ "gitHead": "20e65426dc742448bd6dc85211dea3a48ed74ae0",
27
29
  "devDependencies": {
28
30
  "@babel/core": "^7.12.0"
29
31
  }