@domql/utils 2.25.3 → 2.27.0

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/array.js CHANGED
@@ -29,7 +29,7 @@ export const removeFromArray = (arr, index) => {
29
29
  }
30
30
 
31
31
  export const swapItemsInArray = (arr, i, j) => {
32
- [arr[i], arr[j]] = [arr[j], arr[i]]
32
+ ;[arr[i], arr[j]] = [arr[j], arr[i]]
33
33
  }
34
34
 
35
35
  export const joinArrays = (...arrays) => {
@@ -40,7 +40,10 @@ export const joinArrays = (...arrays) => {
40
40
  * Merges array extendtypes
41
41
  */
42
42
  export const mergeArray = (arr, exclude = []) => {
43
- return arr.reduce((a, c) => deepMerge(a, deepClone(c, { exclude }), exclude), {})
43
+ return arr.reduce(
44
+ (a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
45
+ {}
46
+ )
44
47
  }
45
48
 
46
49
  /**
@@ -105,7 +108,10 @@ export const reorderArrayByValues = (array, valueToMove, insertBeforeValue) => {
105
108
  const indexToInsertBefore = newArray.indexOf(insertBeforeValue) // Find the index to insert before
106
109
  if (indexToMove !== -1 && indexToInsertBefore !== -1) {
107
110
  const removedItem = newArray.splice(indexToMove, 1)[0] // Remove the item to move
108
- const insertIndex = indexToInsertBefore < indexToMove ? indexToInsertBefore : indexToInsertBefore + 1 // Adjust insert index
111
+ const insertIndex =
112
+ indexToInsertBefore < indexToMove
113
+ ? indexToInsertBefore
114
+ : indexToInsertBefore + 1 // Adjust insert index
109
115
  newArray.splice(insertIndex, 0, removedItem) // Insert the removed item before the specified value
110
116
  }
111
117
  return newArray
package/component.js CHANGED
@@ -6,14 +6,14 @@ import { isArray, isFunction, isObject, isString } from './types.js'
6
6
 
7
7
  const ENV = process.env.NODE_ENV
8
8
 
9
- export const checkIfKeyIsComponent = (key) => {
9
+ export const checkIfKeyIsComponent = key => {
10
10
  const isFirstKeyString = isString(key)
11
11
  if (!isFirstKeyString) return
12
12
  const firstCharKey = key.slice(0, 1)
13
13
  return /^[A-Z]*$/.test(firstCharKey)
14
14
  }
15
15
 
16
- export const checkIfKeyIsProperty = (key) => {
16
+ export const checkIfKeyIsProperty = key => {
17
17
  const isFirstKeyString = isString(key)
18
18
  if (!isFirstKeyString) return
19
19
  const firstCharKey = key.slice(0, 1)
@@ -43,22 +43,40 @@ export const checkIfSugar = (element, parent, key) => {
43
43
  $stateCollection,
44
44
  $propsCollection
45
45
  } = element
46
- const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection
47
- if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
46
+ const hasComponentAttrs =
47
+ extend ||
48
+ childExtend ||
49
+ props ||
50
+ on ||
51
+ $collection ||
52
+ $stateCollection ||
53
+ $propsCollection
54
+ if (
55
+ hasComponentAttrs &&
56
+ (childProps || extendProps || children || childExtends)
57
+ ) {
48
58
  const logErr = (parent || element)?.error
49
- if (logErr) logErr.call(parent, element, 'Sugar component includes params for builtin components', { verbose: true })
59
+ if (logErr)
60
+ logErr.call(
61
+ parent,
62
+ element,
63
+ 'Sugar component includes params for builtin components',
64
+ { verbose: true }
65
+ )
50
66
  }
51
- return !hasComponentAttrs || childProps || extendProps || children || childExtends
67
+ return (
68
+ !hasComponentAttrs || childProps || extendProps || children || childExtends
69
+ )
52
70
  }
53
71
 
54
- export const extractComponentKeyFromKey = (key) => {
72
+ export const extractComponentKeyFromKey = key => {
55
73
  return key.includes('+')
56
74
  ? key.split('+') // get array of componentKeys
57
75
  : key.includes('_')
58
- ? [key.split('_')[0]] // get component key split _
59
- : key.includes('.') && !checkIfKeyIsComponent(key.split('.')[1])
60
- ? [key.split('.')[0]] // get component key split .
61
- : [key]
76
+ ? [key.split('_')[0]] // get component key split _
77
+ : key.includes('.') && !checkIfKeyIsComponent(key.split('.')[1])
78
+ ? [key.split('.')[0]] // get component key split .
79
+ : [key]
62
80
  }
63
81
 
64
82
  export const extendizeByKey = (element, parent, key) => {
@@ -122,7 +140,7 @@ export const addChildrenIfNotInOriginal = (element, parent, key) => {
122
140
  const childElem = element[childKey]
123
141
  const newChild = element.props[childKey]
124
142
 
125
- const assignChild = (val) => {
143
+ const assignChild = val => {
126
144
  element[childKey] = val
127
145
  delete element.props[childKey]
128
146
  }
@@ -154,7 +172,8 @@ export const applyComponentFromContext = (element, parent, options) => {
154
172
  const { extend } = element
155
173
  const execExtend = exec(extend, element)
156
174
  if (isString(execExtend)) {
157
- const componentExists = components[execExtend] || components['smbls.' + execExtend]
175
+ const componentExists =
176
+ components[execExtend] || components['smbls.' + execExtend]
158
177
  if (componentExists) element.extend = componentExists
159
178
  else {
160
179
  if ((ENV === 'testing' || ENV === 'development') && options.verbose) {
@@ -166,14 +185,14 @@ export const applyComponentFromContext = (element, parent, options) => {
166
185
  }
167
186
  }
168
187
 
169
- export const isVariant = (param) => {
188
+ export const isVariant = param => {
170
189
  if (!isString(param)) return
171
190
  const firstCharKey = param.slice(0, 1)
172
191
  // return (firstCharKey === '.' || firstCharKey === '$')
173
- return (firstCharKey === '.')
192
+ return firstCharKey === '.'
174
193
  }
175
194
 
176
- export const hasVariantProp = (element) => {
195
+ export const hasVariantProp = element => {
177
196
  const { props } = element
178
197
  if (isObject(props) && isString(props.variant)) return true
179
198
  }
@@ -187,19 +206,23 @@ export const getChildrenComponentsByKey = (key, el) => {
187
206
  if (el.extend) {
188
207
  // Add the value of the extend key to the result array
189
208
  const foundString = isString(el.extend) && el.extend === key
190
- const foundInArray = isArray(el.extend) && el.extend.filter(v => v === key).length
209
+ const foundInArray =
210
+ isArray(el.extend) && el.extend.filter(v => v === key).length
191
211
  if (foundString || foundInArray) return el
192
212
  }
193
213
 
194
214
  if (el.parent && el.parent.childExtend) {
195
215
  // Add the value of the extend key to the result array
196
- const foundString = isString(el.parent.childExtend) && el.parent.childExtend === key
197
- const foundInArray = isArray(el.parent.childExtend) && el.parent.childExtend.filter(v => v === key).length
216
+ const foundString =
217
+ isString(el.parent.childExtend) && el.parent.childExtend === key
218
+ const foundInArray =
219
+ isArray(el.parent.childExtend) &&
220
+ el.parent.childExtend.filter(v => v === key).length
198
221
  if (foundString || foundInArray) return el
199
222
  }
200
223
  }
201
224
 
202
- export const getExtendsInElement = (obj) => {
225
+ export const getExtendsInElement = obj => {
203
226
  let result = []
204
227
 
205
228
  function traverse (o) {
@@ -235,7 +258,11 @@ export const getExtendsInElement = (obj) => {
235
258
  export const setContentKey = (el, opts = {}) => {
236
259
  const { __ref: ref } = el
237
260
  const contentElementKey = opts.contentElementKey
238
- if ((contentElementKey !== 'content' && contentElementKey !== ref.contentElementKey) || !ref.contentElementKey) {
261
+ if (
262
+ (contentElementKey !== 'content' &&
263
+ contentElementKey !== ref.contentElementKey) ||
264
+ !ref.contentElementKey
265
+ ) {
239
266
  ref.contentElementKey = contentElementKey || 'content'
240
267
  } else ref.contentElementKey = 'content'
241
268
  if (contentElementKey !== 'content') opts.contentElementKey = 'content'
package/cookie.js CHANGED
@@ -3,19 +3,18 @@
3
3
  import { isUndefined } from './types.js'
4
4
  import { document } from './globals.js'
5
5
 
6
- export const isMobile = (() => typeof navigator === 'undefined'
7
- ? false
8
- : /Mobi/.test(navigator.userAgent))()
6
+ export const isMobile = (() =>
7
+ typeof navigator === 'undefined' ? false : /Mobi/.test(navigator.userAgent))()
9
8
 
10
9
  export const setCookie = (cname, cvalue, exdays = 365) => {
11
10
  if (isUndefined(document) || isUndefined(document.cookie)) return
12
11
  const d = new Date()
13
- d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000))
12
+ d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000)
14
13
  const expires = `expires=${d.toUTCString()}`
15
14
  document.cookie = `${cname}=${cvalue};${expires};path=/`
16
15
  }
17
16
 
18
- export const getCookie = (cname) => {
17
+ export const getCookie = cname => {
19
18
  if (isUndefined(document) || isUndefined(document.cookie)) return
20
19
  const name = `${cname}=`
21
20
  const decodedCookie = decodeURIComponent(document.cookie)
@@ -28,16 +27,16 @@ export const getCookie = (cname) => {
28
27
  return ''
29
28
  }
30
29
 
31
- export const removeCookie = (cname) => {
30
+ export const removeCookie = cname => {
32
31
  if (isUndefined(document) || isUndefined(document.cookie)) return
33
32
  document.cookie = cname + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'
34
33
  }
35
34
 
36
35
  /**
37
- * Load item from the localStorage
38
- *
39
- * @param key -- string to identify the storage item
40
- */
36
+ * Load item from the localStorage
37
+ *
38
+ * @param key -- string to identify the storage item
39
+ */
41
40
  export function getLocalStorage (key) {
42
41
  let savedJSON
43
42
 
package/dist/cjs/array.js CHANGED
@@ -62,13 +62,17 @@ const removeFromArray = (arr, index) => {
62
62
  return arr;
63
63
  };
64
64
  const swapItemsInArray = (arr, i, j) => {
65
+ ;
65
66
  [arr[i], arr[j]] = [arr[j], arr[i]];
66
67
  };
67
68
  const joinArrays = (...arrays) => {
68
69
  return [].concat(...arrays);
69
70
  };
70
71
  const mergeArray = (arr, exclude = []) => {
71
- return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepClone)(c, { exclude }), exclude), {});
72
+ return arr.reduce(
73
+ (a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepClone)(c, { exclude }), exclude),
74
+ {}
75
+ );
72
76
  };
73
77
  const mergeAndCloneIfArray = (obj) => {
74
78
  return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.deepClone)(obj);
@@ -77,7 +77,13 @@ const checkIfSugar = (element, parent, key) => {
77
77
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
78
78
  if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
79
79
  const logErr = (_a = parent || element) == null ? void 0 : _a.error;
80
- if (logErr) logErr.call(parent, element, "Sugar component includes params for builtin components", { verbose: true });
80
+ if (logErr)
81
+ logErr.call(
82
+ parent,
83
+ element,
84
+ "Sugar component includes params for builtin components",
85
+ { verbose: true }
86
+ );
81
87
  }
82
88
  return !hasComponentAttrs || childProps || extendProps || children || childExtends;
83
89
  };
@@ -83,7 +83,8 @@ const map = (obj, extention, element) => {
83
83
  const merge = (element, obj, excludeFrom = []) => {
84
84
  for (const e in obj) {
85
85
  const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, e);
86
- if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) continue;
86
+ if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
87
+ continue;
87
88
  const elementProp = element[e];
88
89
  const objProp = obj[e];
89
90
  if (elementProp === void 0) {
@@ -95,7 +96,8 @@ const merge = (element, obj, excludeFrom = []) => {
95
96
  const deepMerge = (element, extend, excludeFrom = []) => {
96
97
  for (const e in extend) {
97
98
  const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
98
- if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) continue;
99
+ if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
100
+ continue;
99
101
  const elementProp = element[e];
100
102
  const extendProp = extend[e];
101
103
  if ((0, import_types.isObjectLike)(elementProp) && (0, import_types.isObjectLike)(extendProp)) {
@@ -110,13 +112,17 @@ const clone = (obj, excludeFrom = []) => {
110
112
  const o = {};
111
113
  for (const prop in obj) {
112
114
  const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
113
- if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__")) continue;
115
+ if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__"))
116
+ continue;
114
117
  o[prop] = obj[prop];
115
118
  }
116
119
  return o;
117
120
  };
118
121
  const mergeArrayExclude = (arr, exclude = []) => {
119
- return arr.reduce((acc, curr) => deepMerge(acc, deepClone(curr, { exclude })), {});
122
+ return arr.reduce(
123
+ (acc, curr) => deepMerge(acc, deepClone(curr, { exclude })),
124
+ {}
125
+ );
120
126
  };
121
127
  const deepClone = (obj, options = {}) => {
122
128
  const {
@@ -137,9 +143,11 @@ const deepClone = (obj, options = {}) => {
137
143
  visited.set(obj, clone2);
138
144
  for (const key in obj) {
139
145
  if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
140
- if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") continue;
146
+ if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
147
+ continue;
141
148
  const value = obj[key];
142
- if (cleanUndefined && (0, import_types.isUndefined)(value) || cleanNull && (0, import_types.isNull)(value)) continue;
149
+ if (cleanUndefined && (0, import_types.isUndefined)(value) || cleanNull && (0, import_types.isNull)(value))
150
+ continue;
143
151
  if ((0, import_node.isDOMNode)(value)) {
144
152
  clone2[key] = value;
145
153
  continue;
@@ -166,7 +174,11 @@ const deepClone = (obj, options = {}) => {
166
174
  const deepStringify = (obj, stringified = {}) => {
167
175
  var _a, _b;
168
176
  if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
169
- (obj.__element || ((_a = obj.parent) == null ? void 0 : _a.__element)).warn("Trying to clone element or state at", obj);
177
+ ;
178
+ (obj.__element || ((_a = obj.parent) == null ? void 0 : _a.__element)).warn(
179
+ "Trying to clone element or state at",
180
+ obj
181
+ );
170
182
  obj = (_b = obj.parse) == null ? void 0 : _b.call(obj);
171
183
  }
172
184
  for (const prop in obj) {
@@ -197,7 +209,9 @@ const deepStringify = (obj, stringified = {}) => {
197
209
  const MAX_DEPTH = 100;
198
210
  const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
199
211
  if (depth > MAX_DEPTH) {
200
- console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
212
+ console.warn(
213
+ `Maximum depth exceeded at path: ${path}. Possible circular reference.`
214
+ );
201
215
  return "[MAX_DEPTH_EXCEEDED]";
202
216
  }
203
217
  for (const prop in obj) {
@@ -207,14 +221,24 @@ const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "")
207
221
  stringified[prop] = objProp.toString();
208
222
  } else if ((0, import_types.isObject)(objProp)) {
209
223
  stringified[prop] = {};
210
- deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
224
+ deepStringifyWithMaxDepth(
225
+ objProp,
226
+ stringified[prop],
227
+ depth + 1,
228
+ currentPath
229
+ );
211
230
  } else if ((0, import_types.isArray)(objProp)) {
212
231
  stringified[prop] = [];
213
232
  objProp.forEach((v, i) => {
214
233
  const itemPath = `${currentPath}[${i}]`;
215
234
  if ((0, import_types.isObject)(v)) {
216
235
  stringified[prop][i] = {};
217
- deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
236
+ deepStringifyWithMaxDepth(
237
+ v,
238
+ stringified[prop][i],
239
+ depth + 1,
240
+ itemPath
241
+ );
218
242
  } else if ((0, import_types.isFunction)(v)) {
219
243
  stringified[prop][i] = v.toString();
220
244
  } else {
@@ -237,7 +261,22 @@ const objectToString = (obj = {}, indent = 0) => {
237
261
  const spaces = " ".repeat(indent);
238
262
  let str = "{\n";
239
263
  for (const [key, value] of Object.entries(obj)) {
240
- const keyNotAllowdChars = (0, import_string.stringIncludesAny)(key, ["&", "*", "-", ":", "%", "{", "}", ">", "<", "@", ".", "/", "!", " "]);
264
+ const keyNotAllowdChars = (0, import_string.stringIncludesAny)(key, [
265
+ "&",
266
+ "*",
267
+ "-",
268
+ ":",
269
+ "%",
270
+ "{",
271
+ "}",
272
+ ">",
273
+ "<",
274
+ "@",
275
+ ".",
276
+ "/",
277
+ "!",
278
+ " "
279
+ ]);
241
280
  const stringedKey = keyNotAllowdChars ? `'${key}'` : key;
242
281
  str += `${spaces} ${stringedKey}: `;
243
282
  if ((0, import_types.isArray)(value)) {
@@ -531,8 +570,12 @@ const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
531
570
  const [current1, current2] = stack.pop();
532
571
  if (visited.has(current1)) continue;
533
572
  visited.add(current1);
534
- const keys1 = Object.keys(current1).filter((key) => !ignoredKeys.includes(key));
535
- const keys2 = Object.keys(current2).filter((key) => !ignoredKeys.includes(key));
573
+ const keys1 = Object.keys(current1).filter(
574
+ (key) => !ignoredKeys.includes(key)
575
+ );
576
+ const keys2 = Object.keys(current2).filter(
577
+ (key) => !ignoredKeys.includes(key)
578
+ );
536
579
  if (keys1.length !== keys2.length) return false;
537
580
  for (const key of keys1) {
538
581
  if (!Object.prototype.hasOwnProperty.call(current2, key)) return false;
@@ -558,7 +601,9 @@ const removeFromObject = (obj, props) => {
558
601
  } else if ((0, import_types.isArray)(props)) {
559
602
  props.forEach((prop) => delete obj[prop]);
560
603
  } else {
561
- throw new Error("Invalid input: props must be a string or an array of strings");
604
+ throw new Error(
605
+ "Invalid input: props must be a string or an array of strings"
606
+ );
562
607
  }
563
608
  return obj;
564
609
  };
@@ -650,7 +695,10 @@ const detectInfiniteLoop = (arr) => {
650
695
  }
651
696
  if (repeatCount >= maxRepeats * 2) {
652
697
  if (ENV === "testing" || ENV === "development") {
653
- console.warn("Warning: Potential infinite loop detected due to repeated sequence:", pattern);
698
+ console.warn(
699
+ "Warning: Potential infinite loop detected due to repeated sequence:",
700
+ pattern
701
+ );
654
702
  }
655
703
  return true;
656
704
  }
@@ -52,7 +52,9 @@ function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
52
52
  const obj = forcedState || (this == null ? void 0 : this.state) || {};
53
53
  return str.replace(reg, (_, parentPath, variable) => {
54
54
  if (parentPath) {
55
- const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
55
+ const parentLevels = parentPath.match(
56
+ options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g
57
+ ).length;
56
58
  let parentState = obj;
57
59
  for (let i = 0; i < parentLevels; i++) {
58
60
  parentState = parentState.parent;
@@ -140,5 +142,8 @@ const customEncodeURIComponent = (str) => {
140
142
  }).join("");
141
143
  };
142
144
  const customDecodeURIComponent = (encodedStr) => {
143
- return encodedStr.replace(/%[0-9A-Fa-f]{2}/g, (match) => String.fromCharCode(parseInt(match.slice(1), 16)));
145
+ return encodedStr.replace(
146
+ /%[0-9A-Fa-f]{2}/g,
147
+ (match) => String.fromCharCode(parseInt(match.slice(1), 16))
148
+ );
144
149
  };
package/dist/cjs/tags.js CHANGED
@@ -23,18 +23,8 @@ __export(tags_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(tags_exports);
25
25
  const HTML_TAGS = {
26
- root: [
27
- "body",
28
- "html"
29
- ],
30
- head: [
31
- "title",
32
- "base",
33
- "meta",
34
- "style",
35
- "noscript",
36
- "script"
37
- ],
26
+ root: ["body", "html"],
27
+ head: ["title", "base", "meta", "style", "noscript", "script"],
38
28
  body: [
39
29
  "string",
40
30
  "style",
package/dist/esm/array.js CHANGED
@@ -23,13 +23,17 @@ const removeFromArray = (arr, index) => {
23
23
  return arr;
24
24
  };
25
25
  const swapItemsInArray = (arr, i, j) => {
26
+ ;
26
27
  [arr[i], arr[j]] = [arr[j], arr[i]];
27
28
  };
28
29
  const joinArrays = (...arrays) => {
29
30
  return [].concat(...arrays);
30
31
  };
31
32
  const mergeArray = (arr, exclude = []) => {
32
- return arr.reduce((a, c) => deepMerge(a, deepClone(c, { exclude }), exclude), {});
33
+ return arr.reduce(
34
+ (a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
35
+ {}
36
+ );
33
37
  };
34
38
  const mergeAndCloneIfArray = (obj) => {
35
39
  return isArray(obj) ? mergeArray(obj) : deepClone(obj);
@@ -59,7 +59,13 @@ const checkIfSugar = (element, parent, key) => {
59
59
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
60
60
  if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
61
61
  const logErr = (_a = parent || element) == null ? void 0 : _a.error;
62
- if (logErr) logErr.call(parent, element, "Sugar component includes params for builtin components", { verbose: true });
62
+ if (logErr)
63
+ logErr.call(
64
+ parent,
65
+ element,
66
+ "Sugar component includes params for builtin components",
67
+ { verbose: true }
68
+ );
63
69
  }
64
70
  return !hasComponentAttrs || childProps || extendProps || children || childExtends;
65
71
  };
@@ -52,7 +52,8 @@ const map = (obj, extention, element) => {
52
52
  const merge = (element, obj, excludeFrom = []) => {
53
53
  for (const e in obj) {
54
54
  const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, e);
55
- if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) continue;
55
+ if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
56
+ continue;
56
57
  const elementProp = element[e];
57
58
  const objProp = obj[e];
58
59
  if (elementProp === void 0) {
@@ -64,7 +65,8 @@ const merge = (element, obj, excludeFrom = []) => {
64
65
  const deepMerge = (element, extend, excludeFrom = []) => {
65
66
  for (const e in extend) {
66
67
  const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
67
- if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) continue;
68
+ if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__"))
69
+ continue;
68
70
  const elementProp = element[e];
69
71
  const extendProp = extend[e];
70
72
  if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
@@ -79,13 +81,17 @@ const clone = (obj, excludeFrom = []) => {
79
81
  const o = {};
80
82
  for (const prop in obj) {
81
83
  const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
82
- if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__")) continue;
84
+ if (!hasOwnProperty2 || excludeFrom.includes(prop) || prop.startsWith("__"))
85
+ continue;
83
86
  o[prop] = obj[prop];
84
87
  }
85
88
  return o;
86
89
  };
87
90
  const mergeArrayExclude = (arr, exclude = []) => {
88
- return arr.reduce((acc, curr) => deepMerge(acc, deepClone(curr, { exclude })), {});
91
+ return arr.reduce(
92
+ (acc, curr) => deepMerge(acc, deepClone(curr, { exclude })),
93
+ {}
94
+ );
89
95
  };
90
96
  const deepClone = (obj, options = {}) => {
91
97
  const {
@@ -106,9 +112,11 @@ const deepClone = (obj, options = {}) => {
106
112
  visited.set(obj, clone2);
107
113
  for (const key in obj) {
108
114
  if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
109
- if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") continue;
115
+ if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
116
+ continue;
110
117
  const value = obj[key];
111
- if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) continue;
118
+ if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value))
119
+ continue;
112
120
  if (isDOMNode(value)) {
113
121
  clone2[key] = value;
114
122
  continue;
@@ -134,7 +142,11 @@ const deepClone = (obj, options = {}) => {
134
142
  const deepStringify = (obj, stringified = {}) => {
135
143
  var _a, _b;
136
144
  if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
137
- (obj.__element || ((_a = obj.parent) == null ? void 0 : _a.__element)).warn("Trying to clone element or state at", obj);
145
+ ;
146
+ (obj.__element || ((_a = obj.parent) == null ? void 0 : _a.__element)).warn(
147
+ "Trying to clone element or state at",
148
+ obj
149
+ );
138
150
  obj = (_b = obj.parse) == null ? void 0 : _b.call(obj);
139
151
  }
140
152
  for (const prop in obj) {
@@ -165,7 +177,9 @@ const deepStringify = (obj, stringified = {}) => {
165
177
  const MAX_DEPTH = 100;
166
178
  const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
167
179
  if (depth > MAX_DEPTH) {
168
- console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
180
+ console.warn(
181
+ `Maximum depth exceeded at path: ${path}. Possible circular reference.`
182
+ );
169
183
  return "[MAX_DEPTH_EXCEEDED]";
170
184
  }
171
185
  for (const prop in obj) {
@@ -175,14 +189,24 @@ const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "")
175
189
  stringified[prop] = objProp.toString();
176
190
  } else if (isObject(objProp)) {
177
191
  stringified[prop] = {};
178
- deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
192
+ deepStringifyWithMaxDepth(
193
+ objProp,
194
+ stringified[prop],
195
+ depth + 1,
196
+ currentPath
197
+ );
179
198
  } else if (isArray(objProp)) {
180
199
  stringified[prop] = [];
181
200
  objProp.forEach((v, i) => {
182
201
  const itemPath = `${currentPath}[${i}]`;
183
202
  if (isObject(v)) {
184
203
  stringified[prop][i] = {};
185
- deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
204
+ deepStringifyWithMaxDepth(
205
+ v,
206
+ stringified[prop][i],
207
+ depth + 1,
208
+ itemPath
209
+ );
186
210
  } else if (isFunction(v)) {
187
211
  stringified[prop][i] = v.toString();
188
212
  } else {
@@ -205,7 +229,22 @@ const objectToString = (obj = {}, indent = 0) => {
205
229
  const spaces = " ".repeat(indent);
206
230
  let str = "{\n";
207
231
  for (const [key, value] of Object.entries(obj)) {
208
- const keyNotAllowdChars = stringIncludesAny(key, ["&", "*", "-", ":", "%", "{", "}", ">", "<", "@", ".", "/", "!", " "]);
232
+ const keyNotAllowdChars = stringIncludesAny(key, [
233
+ "&",
234
+ "*",
235
+ "-",
236
+ ":",
237
+ "%",
238
+ "{",
239
+ "}",
240
+ ">",
241
+ "<",
242
+ "@",
243
+ ".",
244
+ "/",
245
+ "!",
246
+ " "
247
+ ]);
209
248
  const stringedKey = keyNotAllowdChars ? `'${key}'` : key;
210
249
  str += `${spaces} ${stringedKey}: `;
211
250
  if (isArray(value)) {
@@ -499,8 +538,12 @@ const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
499
538
  const [current1, current2] = stack.pop();
500
539
  if (visited.has(current1)) continue;
501
540
  visited.add(current1);
502
- const keys1 = Object.keys(current1).filter((key) => !ignoredKeys.includes(key));
503
- const keys2 = Object.keys(current2).filter((key) => !ignoredKeys.includes(key));
541
+ const keys1 = Object.keys(current1).filter(
542
+ (key) => !ignoredKeys.includes(key)
543
+ );
544
+ const keys2 = Object.keys(current2).filter(
545
+ (key) => !ignoredKeys.includes(key)
546
+ );
504
547
  if (keys1.length !== keys2.length) return false;
505
548
  for (const key of keys1) {
506
549
  if (!Object.prototype.hasOwnProperty.call(current2, key)) return false;
@@ -526,7 +569,9 @@ const removeFromObject = (obj, props) => {
526
569
  } else if (isArray(props)) {
527
570
  props.forEach((prop) => delete obj[prop]);
528
571
  } else {
529
- throw new Error("Invalid input: props must be a string or an array of strings");
572
+ throw new Error(
573
+ "Invalid input: props must be a string or an array of strings"
574
+ );
530
575
  }
531
576
  return obj;
532
577
  };
@@ -618,7 +663,10 @@ const detectInfiniteLoop = (arr) => {
618
663
  }
619
664
  if (repeatCount >= maxRepeats * 2) {
620
665
  if (ENV === "testing" || ENV === "development") {
621
- console.warn("Warning: Potential infinite loop detected due to repeated sequence:", pattern);
666
+ console.warn(
667
+ "Warning: Potential infinite loop detected due to repeated sequence:",
668
+ pattern
669
+ );
622
670
  }
623
671
  return true;
624
672
  }
@@ -20,7 +20,9 @@ function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
20
20
  const obj = forcedState || (this == null ? void 0 : this.state) || {};
21
21
  return str.replace(reg, (_, parentPath, variable) => {
22
22
  if (parentPath) {
23
- const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
23
+ const parentLevels = parentPath.match(
24
+ options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g
25
+ ).length;
24
26
  let parentState = obj;
25
27
  for (let i = 0; i < parentLevels; i++) {
26
28
  parentState = parentState.parent;
@@ -108,7 +110,10 @@ const customEncodeURIComponent = (str) => {
108
110
  }).join("");
109
111
  };
110
112
  const customDecodeURIComponent = (encodedStr) => {
111
- return encodedStr.replace(/%[0-9A-Fa-f]{2}/g, (match) => String.fromCharCode(parseInt(match.slice(1), 16)));
113
+ return encodedStr.replace(
114
+ /%[0-9A-Fa-f]{2}/g,
115
+ (match) => String.fromCharCode(parseInt(match.slice(1), 16))
116
+ );
112
117
  };
113
118
  export {
114
119
  customDecodeURIComponent,
package/dist/esm/tags.js CHANGED
@@ -1,16 +1,6 @@
1
1
  const HTML_TAGS = {
2
- root: [
3
- "body",
4
- "html"
5
- ],
6
- head: [
7
- "title",
8
- "base",
9
- "meta",
10
- "style",
11
- "noscript",
12
- "script"
13
- ],
2
+ root: ["body", "html"],
3
+ head: ["title", "base", "meta", "style", "noscript", "script"],
14
4
  body: [
15
5
  "string",
16
6
  "style",
package/env.js CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  export const NODE_ENV = process.env.NODE_ENV
4
4
 
5
- export const isProduction = (env = NODE_ENV) => (env === 'production') ||
5
+ export const isProduction = (env = NODE_ENV) =>
6
+ env === 'production' ||
6
7
  (env !== 'development' && env !== 'dev' && env !== 'testing')
7
8
  export const isTest = (env = NODE_ENV) => env === 'testing'
8
- export const isDevelopment = (env = NODE_ENV) => env === 'development' || env === 'dev'
9
+ export const isDevelopment = (env = NODE_ENV) =>
10
+ env === 'development' || env === 'dev'
9
11
 
10
12
  export const getNev = (key, env = NODE_ENV) => env[key]
package/function.js CHANGED
@@ -16,7 +16,8 @@
16
16
  export function debounce (func, wait, immediate) {
17
17
  let timeout
18
18
  return function () {
19
- const context = this; const args = arguments
19
+ const context = this
20
+ const args = arguments
20
21
  const later = function () {
21
22
  timeout = null
22
23
  if (!immediate) func.apply(context, args)
@@ -46,11 +47,13 @@ export const debounceOnContext = (element, func, timeout = 300) => {
46
47
  let timer
47
48
  return (...args) => {
48
49
  clearTimeout(timer)
49
- timer = setTimeout(() => { func.apply(element, args) }, timeout)
50
+ timer = setTimeout(() => {
51
+ func.apply(element, args)
52
+ }, timeout)
50
53
  }
51
54
  }
52
55
 
53
- export const memoize = (fn) => {
56
+ export const memoize = fn => {
54
57
  const cache = {}
55
58
  return (...args) => {
56
59
  const n = args[0]
package/log.js CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict'
2
2
 
3
- export const logIf = (bool, ...arg) => { if (bool) arg.map(v => console.log(v)) }
3
+ export const logIf = (bool, ...arg) => {
4
+ if (bool) arg.map(v => console.log(v))
5
+ }
4
6
  export const logGroupIf = (bool, key, ...arg) => {
5
7
  if (bool) {
6
8
  console.group(key)
package/node.js CHANGED
@@ -2,28 +2,36 @@
2
2
 
3
3
  import { window } from './globals.js'
4
4
 
5
- export const isNode = (obj) => {
5
+ export const isNode = obj => {
6
6
  return (
7
- typeof Node === 'object'
7
+ (typeof Node === 'object'
8
8
  ? obj instanceof window.Node
9
- : obj && typeof obj === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string'
10
- ) || false
9
+ : obj &&
10
+ typeof obj === 'object' &&
11
+ typeof obj.nodeType === 'number' &&
12
+ typeof obj.nodeName === 'string') || false
13
+ )
11
14
  }
12
15
 
13
16
  // Returns true if it is a DOM element
14
17
  export const isHtmlElement = obj => {
15
18
  return (
16
- typeof HTMLElement === 'object'
19
+ (typeof HTMLElement === 'object'
17
20
  ? obj instanceof window.HTMLElement // DOM2
18
- : obj && typeof obj === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string'
19
- ) || false
21
+ : obj &&
22
+ typeof obj === 'object' &&
23
+ obj !== null &&
24
+ obj.nodeType === 1 &&
25
+ typeof obj.nodeName === 'string') || false
26
+ )
20
27
  }
21
28
 
22
- export const isDOMNode = (obj) => {
23
- return typeof window !== 'undefined' && (
24
- obj instanceof window.Node ||
25
- obj instanceof window.Window ||
26
- obj === window ||
27
- obj === document
29
+ export const isDOMNode = obj => {
30
+ return (
31
+ typeof window !== 'undefined' &&
32
+ (obj instanceof window.Node ||
33
+ obj instanceof window.Window ||
34
+ obj === window ||
35
+ obj === document)
28
36
  )
29
37
  }
package/object.js CHANGED
@@ -39,7 +39,8 @@ export const map = (obj, extention, element) => {
39
39
  export const merge = (element, obj, excludeFrom = []) => {
40
40
  for (const e in obj) {
41
41
  const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, e)
42
- if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) continue
42
+ if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__'))
43
+ continue
43
44
  const elementProp = element[e]
44
45
  const objProp = obj[e]
45
46
  if (elementProp === undefined) {
@@ -52,7 +53,8 @@ export const merge = (element, obj, excludeFrom = []) => {
52
53
  export const deepMerge = (element, extend, excludeFrom = []) => {
53
54
  for (const e in extend) {
54
55
  const hasOwnProperty = Object.prototype.hasOwnProperty.call(extend, e)
55
- if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__')) continue
56
+ if (!hasOwnProperty || excludeFrom.includes(e) || e.startsWith('__'))
57
+ continue
56
58
  const elementProp = element[e]
57
59
  const extendProp = extend[e]
58
60
  if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
@@ -68,7 +70,8 @@ export const clone = (obj, excludeFrom = []) => {
68
70
  const o = {}
69
71
  for (const prop in obj) {
70
72
  const hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, prop)
71
- if (!hasOwnProperty || excludeFrom.includes(prop) || prop.startsWith('__')) continue
73
+ if (!hasOwnProperty || excludeFrom.includes(prop) || prop.startsWith('__'))
74
+ continue
72
75
  o[prop] = obj[prop]
73
76
  }
74
77
  return o
@@ -76,7 +79,10 @@ export const clone = (obj, excludeFrom = []) => {
76
79
 
77
80
  // Merge array, but exclude keys listed in 'excl'z
78
81
  export const mergeArrayExclude = (arr, exclude = []) => {
79
- return arr.reduce((acc, curr) => deepMerge(acc, deepClone(curr, { exclude })), {})
82
+ return arr.reduce(
83
+ (acc, curr) => deepMerge(acc, deepClone(curr, { exclude })),
84
+ {}
85
+ )
80
86
  }
81
87
  /**
82
88
  * Enhanced deep clone function that combines features from multiple implementations
@@ -116,8 +122,8 @@ export const deepClone = (obj, options = {}) => {
116
122
  ? new targetWindow.Array()
117
123
  : new targetWindow.Object()
118
124
  : isArray(obj)
119
- ? []
120
- : {}
125
+ ? []
126
+ : {}
121
127
 
122
128
  // Store the clone to handle circular references
123
129
  visited.set(obj, clone)
@@ -127,12 +133,14 @@ export const deepClone = (obj, options = {}) => {
127
133
  if (!Object.prototype.hasOwnProperty.call(obj, key)) continue
128
134
 
129
135
  // Skip excluded properties
130
- if (exclude.includes(key) || key.startsWith('__') || key === '__proto__') continue
136
+ if (exclude.includes(key) || key.startsWith('__') || key === '__proto__')
137
+ continue
131
138
 
132
139
  const value = obj[key]
133
140
 
134
141
  // Skip based on cleanup options
135
- if ((cleanUndefined && isUndefined(value)) || (cleanNull && isNull(value))) continue
142
+ if ((cleanUndefined && isUndefined(value)) || (cleanNull && isNull(value)))
143
+ continue
136
144
 
137
145
  // Handle special cases
138
146
  if (isDOMNode(value)) {
@@ -171,7 +179,10 @@ export const deepClone = (obj, options = {}) => {
171
179
  */
172
180
  export const deepStringify = (obj, stringified = {}) => {
173
181
  if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
174
- (obj.__element || obj.parent?.__element).warn('Trying to clone element or state at', obj)
182
+ ;(obj.__element || obj.parent?.__element).warn(
183
+ 'Trying to clone element or state at',
184
+ obj
185
+ )
175
186
  obj = obj.parse?.()
176
187
  }
177
188
 
@@ -202,9 +213,16 @@ export const deepStringify = (obj, stringified = {}) => {
202
213
  }
203
214
 
204
215
  const MAX_DEPTH = 100 // Adjust this value as needed
205
- export const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = '') => {
216
+ export const deepStringifyWithMaxDepth = (
217
+ obj,
218
+ stringified = {},
219
+ depth = 0,
220
+ path = ''
221
+ ) => {
206
222
  if (depth > MAX_DEPTH) {
207
- console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`)
223
+ console.warn(
224
+ `Maximum depth exceeded at path: ${path}. Possible circular reference.`
225
+ )
208
226
  return '[MAX_DEPTH_EXCEEDED]'
209
227
  }
210
228
 
@@ -216,14 +234,24 @@ export const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path
216
234
  stringified[prop] = objProp.toString()
217
235
  } else if (isObject(objProp)) {
218
236
  stringified[prop] = {}
219
- deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath)
237
+ deepStringifyWithMaxDepth(
238
+ objProp,
239
+ stringified[prop],
240
+ depth + 1,
241
+ currentPath
242
+ )
220
243
  } else if (isArray(objProp)) {
221
244
  stringified[prop] = []
222
245
  objProp.forEach((v, i) => {
223
246
  const itemPath = `${currentPath}[${i}]`
224
247
  if (isObject(v)) {
225
248
  stringified[prop][i] = {}
226
- deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath)
249
+ deepStringifyWithMaxDepth(
250
+ v,
251
+ stringified[prop][i],
252
+ depth + 1,
253
+ itemPath
254
+ )
227
255
  } else if (isFunction(v)) {
228
256
  stringified[prop][i] = v.toString()
229
257
  } else {
@@ -252,7 +280,22 @@ export const objectToString = (obj = {}, indent = 0) => {
252
280
  let str = '{\n'
253
281
 
254
282
  for (const [key, value] of Object.entries(obj)) {
255
- const keyNotAllowdChars = stringIncludesAny(key, ['&', '*', '-', ':', '%', '{', '}', '>', '<', '@', '.', '/', '!', ' '])
283
+ const keyNotAllowdChars = stringIncludesAny(key, [
284
+ '&',
285
+ '*',
286
+ '-',
287
+ ':',
288
+ '%',
289
+ '{',
290
+ '}',
291
+ '>',
292
+ '<',
293
+ '@',
294
+ '.',
295
+ '/',
296
+ '!',
297
+ ' '
298
+ ])
256
299
  const stringedKey = keyNotAllowdChars ? `'${key}'` : key
257
300
  str += `${spaces} ${stringedKey}: `
258
301
 
@@ -271,7 +314,9 @@ export const objectToString = (obj = {}, indent = 0) => {
271
314
  } else if (isObjectLike(value)) {
272
315
  str += objectToString(value, indent + 1)
273
316
  } else if (isString(value)) {
274
- str += stringIncludesAny(value, ['\n', '\'']) ? `\`${value}\`` : `'${value}'`
317
+ str += stringIncludesAny(value, ['\n', "'"])
318
+ ? `\`${value}\``
319
+ : `'${value}'`
275
320
  } else {
276
321
  str += value
277
322
  }
@@ -311,7 +356,7 @@ export const detachFunctionsFromObject = (obj, detached = {}) => {
311
356
  return detached
312
357
  }
313
358
 
314
- export const hasFunction = (str) => {
359
+ export const hasFunction = str => {
315
360
  if (!str) return false
316
361
 
317
362
  const trimmed = str.trim().replace(/\n\s*/g, ' ').trim()
@@ -357,7 +402,7 @@ export const deepDestringify = (obj, destringified = {}) => {
357
402
  }
358
403
  } else if (isArray(objProp)) {
359
404
  destringified[prop] = []
360
- objProp.forEach((arrProp) => {
405
+ objProp.forEach(arrProp => {
361
406
  if (isString(arrProp)) {
362
407
  if (hasFunction(arrProp)) {
363
408
  try {
@@ -387,7 +432,9 @@ export const deepDestringify = (obj, destringified = {}) => {
387
432
  export const stringToObject = (str, opts = { verbose: true }) => {
388
433
  try {
389
434
  return str ? window.eval('(' + str + ')') : {} // eslint-disable-line
390
- } catch (e) { if (opts.verbose) console.warn(e) }
435
+ } catch (e) {
436
+ if (opts.verbose) console.warn(e)
437
+ }
391
438
  }
392
439
 
393
440
  export const diffObjects = (original, objToDiff, cache) => {
@@ -436,11 +483,12 @@ export const diff = (original, objToDiff, cache = {}) => {
436
483
  return cache
437
484
  }
438
485
 
439
- export const hasOwnProperty = (o, ...args) => Object.prototype.hasOwnProperty.call(o, ...args)
486
+ export const hasOwnProperty = (o, ...args) =>
487
+ Object.prototype.hasOwnProperty.call(o, ...args)
440
488
 
441
489
  export const isEmpty = o => Object.keys(o).length === 0
442
490
 
443
- export const isEmptyObject = (o) => isObject(o) && isEmpty(o)
491
+ export const isEmptyObject = o => isObject(o) && isEmpty(o)
444
492
 
445
493
  export const makeObjectWithoutPrototype = () => Object.create(null)
446
494
 
@@ -472,7 +520,11 @@ export const deepDiff = (lhs, rhs) => {
472
520
 
473
521
  const difference = diff(lhs[key], rhs[key])
474
522
 
475
- if (isEmptyObject(difference) && !isDate(difference) && (isEmptyObject(lhs[key]) || !isEmptyObject(rhs[key]))) {
523
+ if (
524
+ isEmptyObject(difference) &&
525
+ !isDate(difference) &&
526
+ (isEmptyObject(lhs[key]) || !isEmptyObject(rhs[key]))
527
+ ) {
476
528
  return acc
477
529
  }
478
530
 
@@ -521,11 +573,21 @@ export const overwriteShallow = (obj, params, excludeFrom = []) => {
521
573
  /**
522
574
  * Overwrites DEEPLY object properties with another
523
575
  */
524
- export const overwriteDeep = (obj, params, opts = {}, visited = new WeakMap()) => {
576
+ export const overwriteDeep = (
577
+ obj,
578
+ params,
579
+ opts = {},
580
+ visited = new WeakMap()
581
+ ) => {
525
582
  const excl = opts.exclude || []
526
583
  const forcedExclude = opts.preventForce ? [] : ['node', 'window']
527
584
 
528
- if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
585
+ if (
586
+ !isObjectLike(obj) ||
587
+ !isObjectLike(params) ||
588
+ isDOMNode(obj) ||
589
+ isDOMNode(params)
590
+ ) {
529
591
  return params
530
592
  }
531
593
 
@@ -610,7 +672,12 @@ export const flattenRecursive = (param, prop, stack = []) => {
610
672
  */
611
673
  export const isEqualDeep = (param, element, visited = new Set()) => {
612
674
  // Check if both values are non-null objects
613
- if (typeof param !== 'object' || typeof element !== 'object' || param === null || element === null) {
675
+ if (
676
+ typeof param !== 'object' ||
677
+ typeof element !== 'object' ||
678
+ param === null ||
679
+ element === null
680
+ ) {
614
681
  return param === element // Compare non-object values directly
615
682
  }
616
683
 
@@ -662,8 +729,12 @@ export const deepContains = (obj1, obj2, ignoredKeys = ['node', '__ref']) => {
662
729
  if (visited.has(current1)) continue
663
730
  visited.add(current1)
664
731
 
665
- const keys1 = Object.keys(current1).filter(key => !ignoredKeys.includes(key))
666
- const keys2 = Object.keys(current2).filter(key => !ignoredKeys.includes(key))
732
+ const keys1 = Object.keys(current1).filter(
733
+ key => !ignoredKeys.includes(key)
734
+ )
735
+ const keys2 = Object.keys(current2).filter(
736
+ key => !ignoredKeys.includes(key)
737
+ )
667
738
 
668
739
  if (keys1.length !== keys2.length) return false
669
740
 
@@ -695,12 +766,14 @@ export const removeFromObject = (obj, props) => {
695
766
  } else if (isArray(props)) {
696
767
  props.forEach(prop => delete obj[prop])
697
768
  } else {
698
- throw new Error('Invalid input: props must be a string or an array of strings')
769
+ throw new Error(
770
+ 'Invalid input: props must be a string or an array of strings'
771
+ )
699
772
  }
700
773
  return obj
701
774
  }
702
775
 
703
- export const createObjectWithoutPrototype = (obj) => {
776
+ export const createObjectWithoutPrototype = obj => {
704
777
  if (obj === null || typeof obj !== 'object') {
705
778
  return obj // Return the value if obj is not an object
706
779
  }
@@ -816,7 +889,10 @@ export const detectInfiniteLoop = arr => {
816
889
  // If the pattern repeats more than `maxRepeats`, throw a warning
817
890
  if (repeatCount >= maxRepeats * 2) {
818
891
  if (ENV === 'testing' || ENV === 'development') {
819
- console.warn('Warning: Potential infinite loop detected due to repeated sequence:', pattern)
892
+ console.warn(
893
+ 'Warning: Potential infinite loop detected due to repeated sequence:',
894
+ pattern
895
+ )
820
896
  }
821
897
  return true
822
898
  }
@@ -824,7 +900,7 @@ export const detectInfiniteLoop = arr => {
824
900
  }
825
901
  }
826
902
 
827
- export const isCyclic = (obj) => {
903
+ export const isCyclic = obj => {
828
904
  const seenObjects = []
829
905
 
830
906
  function detect (obj) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.25.3",
3
+ "version": "2.27.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -24,8 +24,8 @@
24
24
  "build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
25
25
  "prepublish": "npm run build; npm run copy:package:cjs"
26
26
  },
27
- "gitHead": "1e749ee3ef95b5a4a618c4eda1961f7c3011beff",
27
+ "gitHead": "40a924693178a7d7b9e94aac0282b9d31602eca7",
28
28
  "devDependencies": {
29
- "@babel/core": "^7.12.0"
29
+ "@babel/core": "^7.26.0"
30
30
  }
31
31
  }
package/string.js CHANGED
@@ -29,13 +29,19 @@ const brackRegex = {
29
29
  3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
30
30
  }
31
31
 
32
- export function replaceLiteralsWithObjectFields (str, options = {}, forcedState) {
32
+ export function replaceLiteralsWithObjectFields (
33
+ str,
34
+ options = {},
35
+ forcedState
36
+ ) {
33
37
  if (!str.includes(options.bracketsLength === 3 ? '{{{' : '{{')) return str
34
38
  const reg = brackRegex[options.bracketsLength || 2]
35
39
  const obj = forcedState || this?.state || {}
36
40
  return str.replace(reg, (_, parentPath, variable) => {
37
41
  if (parentPath) {
38
- const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length
42
+ const parentLevels = parentPath.match(
43
+ options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g
44
+ ).length
39
45
  let parentState = obj
40
46
  for (let i = 0; i < parentLevels; i++) {
41
47
  parentState = parentState.parent
@@ -52,7 +58,7 @@ export function replaceLiteralsWithObjectFields (str, options = {}, forcedState)
52
58
  })
53
59
  }
54
60
 
55
- export const lowercaseFirstLetter = (inputString) => {
61
+ export const lowercaseFirstLetter = inputString => {
56
62
  return `${inputString.charAt(0).toLowerCase()}${inputString.slice(1)}`
57
63
  }
58
64
 
@@ -98,7 +104,10 @@ export const findKeyPosition = (str, key) => {
98
104
  // If braceCount is 0 and we find the end of the object/array
99
105
  if (braceCount === 0) {
100
106
  endLineNumber = i + 1
101
- endColumn = lines[i].lastIndexOf('}') !== -1 ? lines[i].lastIndexOf('}') + 2 : lines[i].length + 1
107
+ endColumn =
108
+ lines[i].lastIndexOf('}') !== -1
109
+ ? lines[i].lastIndexOf('}') + 2
110
+ : lines[i].length + 1
102
111
  break
103
112
  }
104
113
  }
@@ -112,7 +121,7 @@ export const findKeyPosition = (str, key) => {
112
121
  }
113
122
  }
114
123
 
115
- export const replaceOctalEscapeSequences = (str) => {
124
+ export const replaceOctalEscapeSequences = str => {
116
125
  // Regex to match octal escape sequences
117
126
  const octalRegex = /\\([0-7]{1,3})/g
118
127
 
@@ -126,23 +135,40 @@ export const replaceOctalEscapeSequences = (str) => {
126
135
  })
127
136
  }
128
137
 
129
- export const encodeNewlines = (str) => {
130
- return str.split('\n').join('/////n').split('`').join('/////tilde').split('$').join('/////dlrsgn')
138
+ export const encodeNewlines = str => {
139
+ return str
140
+ .split('\n')
141
+ .join('/////n')
142
+ .split('`')
143
+ .join('/////tilde')
144
+ .split('$')
145
+ .join('/////dlrsgn')
131
146
  }
132
147
 
133
- export const decodeNewlines = (encodedStr) => {
134
- return encodedStr.split('/////n').join('\n').split('/////tilde').join('`').split('/////dlrsgn').join('$')
148
+ export const decodeNewlines = encodedStr => {
149
+ return encodedStr
150
+ .split('/////n')
151
+ .join('\n')
152
+ .split('/////tilde')
153
+ .join('`')
154
+ .split('/////dlrsgn')
155
+ .join('$')
135
156
  }
136
157
 
137
- export const customEncodeURIComponent = (str) => {
138
- return str.split('').map(char => {
139
- if (/[^a-zA-Z0-9\s]/.test(char)) {
140
- return '%' + char.charCodeAt(0).toString(16).toUpperCase()
141
- }
142
- return char
143
- }).join('')
158
+ export const customEncodeURIComponent = str => {
159
+ return str
160
+ .split('')
161
+ .map(char => {
162
+ if (/[^a-zA-Z0-9\s]/.test(char)) {
163
+ return '%' + char.charCodeAt(0).toString(16).toUpperCase()
164
+ }
165
+ return char
166
+ })
167
+ .join('')
144
168
  }
145
169
 
146
- export const customDecodeURIComponent = (encodedStr) => {
147
- return encodedStr.replace(/%[0-9A-Fa-f]{2}/g, match => String.fromCharCode(parseInt(match.slice(1), 16)))
170
+ export const customDecodeURIComponent = encodedStr => {
171
+ return encodedStr.replace(/%[0-9A-Fa-f]{2}/g, match =>
172
+ String.fromCharCode(parseInt(match.slice(1), 16))
173
+ )
148
174
  }
package/tags.js CHANGED
@@ -1,19 +1,9 @@
1
1
  'use strict'
2
2
 
3
3
  export const HTML_TAGS = {
4
- root: [
5
- 'body',
6
- 'html'
7
- ],
4
+ root: ['body', 'html'],
8
5
 
9
- head: [
10
- 'title',
11
- 'base',
12
- 'meta',
13
- 'style',
14
- 'noscript',
15
- 'script'
16
- ],
6
+ head: ['title', 'base', 'meta', 'style', 'noscript', 'script'],
17
7
 
18
8
  body: [
19
9
  'string',
package/types.js CHANGED
@@ -4,7 +4,7 @@ import { isHtmlElement, isNode } from './node.js'
4
4
 
5
5
  export const isObject = arg => {
6
6
  if (arg === null) return false
7
- return (typeof arg === 'object') && (arg.constructor === Object)
7
+ return typeof arg === 'object' && arg.constructor === Object
8
8
  }
9
9
 
10
10
  export const isString = arg => typeof arg === 'string'
@@ -24,11 +24,12 @@ export const isDate = d => d instanceof Date
24
24
  export const isObjectLike = arg => {
25
25
  if (arg === null) return false
26
26
  // if (isArray(arg)) return false
27
- return (typeof arg === 'object')
27
+ return typeof arg === 'object'
28
28
  }
29
29
 
30
30
  export const isDefined = arg => {
31
- return isObject(arg) ||
31
+ return (
32
+ isObject(arg) ||
32
33
  isObjectLike(arg) ||
33
34
  isString(arg) ||
34
35
  isNumber(arg) ||
@@ -38,6 +39,7 @@ export const isDefined = arg => {
38
39
  isBoolean(arg) ||
39
40
  isDate(arg) ||
40
41
  isNull(arg)
42
+ )
41
43
  }
42
44
 
43
45
  export const isUndefined = arg => {
@@ -59,13 +61,13 @@ export const TYPES = {
59
61
  defined: isDefined
60
62
  }
61
63
 
62
- export const is = (arg) => {
64
+ export const is = arg => {
63
65
  return (...args) => {
64
66
  return args.map(val => TYPES[val](arg)).filter(v => v).length > 0
65
67
  }
66
68
  }
67
69
 
68
- export const isNot = (arg) => {
70
+ export const isNot = arg => {
69
71
  return (...args) => {
70
72
  return args.map(val => TYPES[val](arg)).filter(v => v).length === 0
71
73
  }