@domql/utils 2.5.200 → 2.5.203

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 CHANGED
@@ -157,7 +157,7 @@ export const applyComponentFromContext = (element, parent, options) => {
157
157
  const componentExists = components[execExtend] || components['smbls.' + execExtend]
158
158
  if (componentExists) element.extend = componentExists
159
159
  else {
160
- if ((ENV === 'test' || ENV === 'development') && options.verbose) {
160
+ if ((ENV === 'testing' || ENV === 'development') && options.verbose) {
161
161
  console.warn(execExtend, 'is not in library', components, element)
162
162
  console.warn('replacing with ', {})
163
163
  }
package/dist/cjs/array.js CHANGED
@@ -48,7 +48,8 @@ const getFrequencyInArray = (arr, value) => {
48
48
  }, 0);
49
49
  };
50
50
  const removeFromArray = (arr, index) => {
51
- if ((0, import_types.isString)(index)) index = parseInt(index);
51
+ if ((0, import_types.isString)(index))
52
+ index = parseInt(index);
52
53
  if ((0, import_types.isNumber)(index)) {
53
54
  if (index < 0 || index >= arr.length || isNaN(index)) {
54
55
  throw new Error("Invalid index");
@@ -81,7 +82,8 @@ const cutArrayBeforeValue = (arr, value) => {
81
82
  return arr;
82
83
  };
83
84
  const cutArrayAfterValue = (arr, value) => {
84
- if (!(0, import_types.isArray)(arr)) return;
85
+ if (!(0, import_types.isArray)(arr))
86
+ return;
85
87
  const index = arr.indexOf(value);
86
88
  if (index !== -1) {
87
89
  return arr.slice(index + 1);
@@ -140,6 +142,7 @@ const filterArraysFast = (sourceArr, excludeArr) => {
140
142
  return sourceArr.filter((item) => !excludeSet.has(item));
141
143
  };
142
144
  const checkIfStringIsInArray = (string, arr) => {
143
- if (!string) return;
145
+ if (!string)
146
+ return;
144
147
  return arr.filter((v) => string.includes(v)).length;
145
148
  };
@@ -41,18 +41,21 @@ var import_types = require("./types.js");
41
41
  const ENV = "development";
42
42
  const checkIfKeyIsComponent = (key) => {
43
43
  const isFirstKeyString = (0, import_types.isString)(key);
44
- if (!isFirstKeyString) return;
44
+ if (!isFirstKeyString)
45
+ return;
45
46
  const firstCharKey = key.slice(0, 1);
46
47
  return /^[A-Z]*$/.test(firstCharKey);
47
48
  };
48
49
  const checkIfKeyIsProperty = (key) => {
49
50
  const isFirstKeyString = (0, import_types.isString)(key);
50
- if (!isFirstKeyString) return;
51
+ if (!isFirstKeyString)
52
+ return;
51
53
  const firstCharKey = key.slice(0, 1);
52
54
  return /^[a-z]*$/.test(firstCharKey);
53
55
  };
54
56
  const addAdditionalExtend = (newExtend, element) => {
55
- if (!newExtend) return element;
57
+ if (!newExtend)
58
+ return element;
56
59
  const { extend: elementExtend } = element;
57
60
  const originalArray = (0, import_types.isArray)(elementExtend) ? elementExtend : [elementExtend];
58
61
  const receivedArray = (0, import_types.isArray)(newExtend) ? newExtend : [newExtend];
@@ -77,7 +80,8 @@ const checkIfSugar = (element, parent, key) => {
77
80
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
78
81
  if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
79
82
  const logErr = (_a = parent || element) == null ? void 0 : _a.error;
80
- if (logErr) logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
83
+ if (logErr)
84
+ logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
81
85
  }
82
86
  return !hasComponentAttrs || childProps || extendProps || children || childExtends;
83
87
  };
@@ -90,7 +94,8 @@ const extendizeByKey = (element, parent, key) => {
90
94
  const isSugar = checkIfSugar(element, parent, key);
91
95
  const extendFromKey = extractComponentKeyFromKey(key);
92
96
  const isExtendKeyComponent = context && context.components[extendFromKey];
93
- if (element === isExtendKeyComponent) return element;
97
+ if (element === isExtendKeyComponent)
98
+ return element;
94
99
  else if (isSugar) {
95
100
  const newElem = addAdditionalExtend(element.extends, {
96
101
  extend: extendFromKey,
@@ -113,7 +118,8 @@ const extendizeByKey = (element, parent, key) => {
113
118
  newElem.if = newElem.props.if;
114
119
  delete newElem.props.if;
115
120
  }
116
- if (childExtends) newElem.childExtend = childExtends;
121
+ if (childExtends)
122
+ newElem.childExtend = childExtends;
117
123
  return newElem;
118
124
  } else if (!extend || extend === true) {
119
125
  return {
@@ -136,7 +142,8 @@ function getCapitalCaseKeys(obj) {
136
142
  }
137
143
  const addChildrenIfNotInOriginal = (element, parent, key) => {
138
144
  const childElems = getCapitalCaseKeys(element.props);
139
- if (!childElems.length) return element;
145
+ if (!childElems.length)
146
+ return element;
140
147
  for (const i in childElems) {
141
148
  const childKey = childElems[i];
142
149
  const childElem = element[childKey];
@@ -145,12 +152,16 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
145
152
  element[childKey] = val;
146
153
  delete element.props[childKey];
147
154
  };
148
- if (newChild == null ? void 0 : newChild.ignoreExtend) continue;
149
- if (newChild === null) assignChild(null);
150
- else if (!childElem) assignChild((0, import_object.deepClone)(newChild));
155
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
156
+ continue;
157
+ if (newChild === null)
158
+ assignChild(null);
159
+ else if (!childElem)
160
+ assignChild((0, import_object.deepClone)(newChild));
151
161
  else {
152
162
  const isSugarChildElem = checkIfSugar(childElem, parent, key);
153
- if (isSugarChildElem) continue;
163
+ if (isSugarChildElem)
164
+ continue;
154
165
  assignChild({
155
166
  extend: element[childKey],
156
167
  props: newChild
@@ -163,15 +174,17 @@ const applyKeyComponentAsExtend = (element, parent, key) => {
163
174
  };
164
175
  const applyComponentFromContext = (element, parent, options) => {
165
176
  const { context } = element;
166
- if (!context || !context.components) return;
177
+ if (!context || !context.components)
178
+ return;
167
179
  const { components } = context;
168
180
  const { extend } = element;
169
181
  const execExtend = (0, import_object.exec)(extend, element);
170
182
  if ((0, import_types.isString)(execExtend)) {
171
183
  const componentExists = components[execExtend] || components["smbls." + execExtend];
172
- if (componentExists) element.extend = componentExists;
184
+ if (componentExists)
185
+ element.extend = componentExists;
173
186
  else {
174
- if ((ENV === "test" || ENV === "development") && options.verbose) {
187
+ if ((ENV === "testing" || ENV === "development") && options.verbose) {
175
188
  console.warn(execExtend, "is not in library", components, element);
176
189
  console.warn("replacing with ", {});
177
190
  }
@@ -180,13 +193,15 @@ const applyComponentFromContext = (element, parent, options) => {
180
193
  }
181
194
  };
182
195
  const isVariant = (param) => {
183
- if (!(0, import_types.isString)(param)) return;
196
+ if (!(0, import_types.isString)(param))
197
+ return;
184
198
  const firstCharKey = param.slice(0, 1);
185
199
  return firstCharKey === ".";
186
200
  };
187
201
  const hasVariantProp = (element) => {
188
202
  const { props } = element;
189
- if ((0, import_types.isObject)(props) && (0, import_types.isString)(props.variant)) return true;
203
+ if ((0, import_types.isObject)(props) && (0, import_types.isString)(props.variant))
204
+ return true;
190
205
  };
191
206
  const getChildrenComponentsByKey = (key, el) => {
192
207
  if (key === el.key || el.__ref.__componentKey === key) {
@@ -195,12 +210,14 @@ const getChildrenComponentsByKey = (key, el) => {
195
210
  if (el.extend) {
196
211
  const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
197
212
  const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
198
- if (foundString || foundInArray) return el;
213
+ if (foundString || foundInArray)
214
+ return el;
199
215
  }
200
216
  if (el.parent && el.parent.childExtend) {
201
217
  const foundString = (0, import_types.isString)(el.parent.childExtend) && el.parent.childExtend === key;
202
218
  const foundInArray = (0, import_types.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
203
- if (foundString || foundInArray) return el;
219
+ if (foundString || foundInArray)
220
+ return el;
204
221
  }
205
222
  };
206
223
  const getExtendsInElement = (obj) => {
@@ -232,7 +249,9 @@ const setContentKey = (el, opts = {}) => {
232
249
  const contentElementKey = opts.contentElementKey;
233
250
  if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
234
251
  ref.contentElementKey = contentElementKey || "content";
235
- } else ref.contentElementKey = "content";
236
- if (contentElementKey !== "content") opts.contentElementKey = "content";
252
+ } else
253
+ ref.contentElementKey = "content";
254
+ if (contentElementKey !== "content")
255
+ opts.contentElementKey = "content";
237
256
  return ref.contentElementKey;
238
257
  };
@@ -30,26 +30,31 @@ var import_types = require("./types.js");
30
30
  var import_globals = require("./globals.js");
31
31
  const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
32
32
  const setCookie = (cname, cvalue, exdays = 365) => {
33
- if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie)) return;
33
+ if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie))
34
+ return;
34
35
  const d = /* @__PURE__ */ new Date();
35
36
  d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
36
37
  const expires = `expires=${d.toUTCString()}`;
37
38
  import_globals.document.cookie = `${cname}=${cvalue};${expires};path=/`;
38
39
  };
39
40
  const getCookie = (cname) => {
40
- if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie)) return;
41
+ if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie))
42
+ return;
41
43
  const name = `${cname}=`;
42
44
  const decodedCookie = decodeURIComponent(import_globals.document.cookie);
43
45
  const ca = decodedCookie.split(";");
44
46
  for (let i = 0; i < ca.length; i++) {
45
47
  let c = ca[i];
46
- while (c.charAt(0) === " ") c = c.substring(1);
47
- if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
48
+ while (c.charAt(0) === " ")
49
+ c = c.substring(1);
50
+ if (c.indexOf(name) === 0)
51
+ return c.substring(name.length, c.length);
48
52
  }
49
53
  return "";
50
54
  };
51
55
  const removeCookie = (cname) => {
52
- if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie)) return;
56
+ if ((0, import_types.isUndefined)(import_globals.document) || (0, import_types.isUndefined)(import_globals.document.cookie))
57
+ return;
53
58
  import_globals.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
54
59
  };
55
60
  function getLocalStorage(key) {
@@ -32,12 +32,14 @@ function debounce(func, wait, immediate) {
32
32
  const args = arguments;
33
33
  const later = function() {
34
34
  timeout = null;
35
- if (!immediate) func.apply(context, args);
35
+ if (!immediate)
36
+ func.apply(context, args);
36
37
  };
37
38
  const callNow = immediate && !timeout;
38
39
  clearTimeout(timeout);
39
40
  timeout = setTimeout(later, wait);
40
- if (callNow) func.apply(context, args);
41
+ if (callNow)
42
+ func.apply(context, args);
41
43
  };
42
44
  }
43
45
  const debounceOnContext = (element, func, timeout = 300) => {
package/dist/cjs/index.js CHANGED
@@ -13,18 +13,18 @@ var __copyProps = (to, from, except, desc) => {
13
13
  };
14
14
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var index_exports = {};
17
- module.exports = __toCommonJS(index_exports);
18
- __reExport(index_exports, require("./key.js"), module.exports);
19
- __reExport(index_exports, require("./env.js"), module.exports);
20
- __reExport(index_exports, require("./types.js"), module.exports);
21
- __reExport(index_exports, require("./object.js"), module.exports);
22
- __reExport(index_exports, require("./function.js"), module.exports);
23
- __reExport(index_exports, require("./array.js"), module.exports);
24
- __reExport(index_exports, require("./node.js"), module.exports);
25
- __reExport(index_exports, require("./log.js"), module.exports);
26
- __reExport(index_exports, require("./string.js"), module.exports);
27
- __reExport(index_exports, require("./globals.js"), module.exports);
28
- __reExport(index_exports, require("./cookie.js"), module.exports);
29
- __reExport(index_exports, require("./tags.js"), module.exports);
30
- __reExport(index_exports, require("./component.js"), module.exports);
16
+ var utils_exports = {};
17
+ module.exports = __toCommonJS(utils_exports);
18
+ __reExport(utils_exports, require("./key.js"), module.exports);
19
+ __reExport(utils_exports, require("./env.js"), module.exports);
20
+ __reExport(utils_exports, require("./types.js"), module.exports);
21
+ __reExport(utils_exports, require("./object.js"), module.exports);
22
+ __reExport(utils_exports, require("./function.js"), module.exports);
23
+ __reExport(utils_exports, require("./array.js"), module.exports);
24
+ __reExport(utils_exports, require("./node.js"), module.exports);
25
+ __reExport(utils_exports, require("./log.js"), module.exports);
26
+ __reExport(utils_exports, require("./string.js"), module.exports);
27
+ __reExport(utils_exports, require("./globals.js"), module.exports);
28
+ __reExport(utils_exports, require("./cookie.js"), module.exports);
29
+ __reExport(utils_exports, require("./tags.js"), module.exports);
30
+ __reExport(utils_exports, require("./component.js"), module.exports);
package/dist/cjs/key.js CHANGED
@@ -22,7 +22,7 @@ __export(key_exports, {
22
22
  generateKey: () => generateKey
23
23
  });
24
24
  module.exports = __toCommonJS(key_exports);
25
- const generateKey = /* @__PURE__ */ function() {
25
+ const generateKey = function() {
26
26
  let index = 0;
27
27
  function newId() {
28
28
  index++;
package/dist/cjs/log.js CHANGED
@@ -23,7 +23,8 @@ __export(log_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(log_exports);
25
25
  const logIf = (bool, ...arg) => {
26
- if (bool) arg.map((v) => console.log(v));
26
+ if (bool)
27
+ arg.map((v) => console.log(v));
27
28
  };
28
29
  const logGroupIf = (bool, key, ...arg) => {
29
30
  if (bool) {
@@ -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,7 +112,8 @@ 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;
@@ -136,10 +139,13 @@ const deepClone = (obj, options = {}) => {
136
139
  const clone2 = targetWindow ? (0, import_types.isArray)(obj) ? new targetWindow.Array() : new targetWindow.Object() : (0, import_types.isArray)(obj) ? [] : {};
137
140
  visited.set(obj, clone2);
138
141
  for (const key in obj) {
139
- if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
140
- if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") continue;
142
+ if (!Object.prototype.hasOwnProperty.call(obj, key))
143
+ continue;
144
+ if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
145
+ continue;
141
146
  const value = obj[key];
142
- if (cleanUndefined && (0, import_types.isUndefined)(value) || cleanNull && (0, import_types.isNull)(value)) continue;
147
+ if (cleanUndefined && (0, import_types.isUndefined)(value) || cleanNull && (0, import_types.isNull)(value))
148
+ continue;
143
149
  if ((0, import_node.isDOMNode)(value)) {
144
150
  clone2[key] = value;
145
151
  continue;
@@ -270,14 +276,16 @@ const objectToString = (obj = {}, indent = 0) => {
270
276
  const detachFunctionsFromObject = (obj, detached = {}) => {
271
277
  for (const prop in obj) {
272
278
  const objProp = obj[prop];
273
- if ((0, import_types.isFunction)(objProp)) continue;
279
+ if ((0, import_types.isFunction)(objProp))
280
+ continue;
274
281
  else if ((0, import_types.isObject)(objProp)) {
275
282
  detached[prop] = {};
276
283
  deepStringify(objProp, detached[prop]);
277
284
  } else if ((0, import_types.isArray)(objProp)) {
278
285
  detached[prop] = [];
279
286
  objProp.forEach((v, i) => {
280
- if ((0, import_types.isFunction)(v)) return;
287
+ if ((0, import_types.isFunction)(v))
288
+ return;
281
289
  if ((0, import_types.isObject)(v)) {
282
290
  detached[prop][i] = {};
283
291
  detachFunctionsFromObject(v, detached[prop][i]);
@@ -292,11 +300,15 @@ const detachFunctionsFromObject = (obj, detached = {}) => {
292
300
  return detached;
293
301
  };
294
302
  const hasFunction = (str) => {
295
- if (!str) return false;
303
+ if (!str)
304
+ return false;
296
305
  const trimmed = str.trim().replace(/\n\s*/g, " ").trim();
297
- if (trimmed === "") return false;
298
- if (trimmed === "{}") return false;
299
- if (trimmed === "[]") return false;
306
+ if (trimmed === "")
307
+ return false;
308
+ if (trimmed === "{}")
309
+ return false;
310
+ if (trimmed === "[]")
311
+ return false;
300
312
  const patterns = [
301
313
  /^\(\s*\{[^}]*\}\s*\)\s*=>/,
302
314
  /^(\([^)]*\)|[^=]*)\s*=>/,
@@ -314,7 +326,8 @@ const hasFunction = (str) => {
314
326
  const deepDestringify = (obj, destringified = {}) => {
315
327
  for (const prop in obj) {
316
328
  const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
317
- if (!hasOwnProperty2) continue;
329
+ if (!hasOwnProperty2)
330
+ continue;
318
331
  const objProp = obj[prop];
319
332
  if ((0, import_types.isString)(objProp)) {
320
333
  if (hasFunction(objProp)) {
@@ -322,7 +335,8 @@ const deepDestringify = (obj, destringified = {}) => {
322
335
  const evalProp = import_globals.window.eval(`(${objProp})`);
323
336
  destringified[prop] = evalProp;
324
337
  } catch (e) {
325
- if (e) destringified[prop] = objProp;
338
+ if (e)
339
+ destringified[prop] = objProp;
326
340
  }
327
341
  } else {
328
342
  destringified[prop] = objProp;
@@ -336,7 +350,8 @@ const deepDestringify = (obj, destringified = {}) => {
336
350
  const evalProp = import_globals.window.eval(`(${arrProp})`);
337
351
  destringified[prop].push(evalProp);
338
352
  } catch (e) {
339
- if (e) destringified[prop].push(arrProp);
353
+ if (e)
354
+ destringified[prop].push(arrProp);
340
355
  }
341
356
  } else {
342
357
  destringified[prop].push(arrProp);
@@ -359,12 +374,14 @@ const stringToObject = (str, opts = { verbose: true }) => {
359
374
  try {
360
375
  return str ? import_globals.window.eval("(" + str + ")") : {};
361
376
  } catch (e) {
362
- if (opts.verbose) console.warn(e);
377
+ if (opts.verbose)
378
+ console.warn(e);
363
379
  }
364
380
  };
365
381
  const diffObjects = (original, objToDiff, cache) => {
366
382
  for (const e in objToDiff) {
367
- if (e === "ref") continue;
383
+ if (e === "ref")
384
+ continue;
368
385
  const originalProp = original[e];
369
386
  const objToDiffProp = objToDiff[e];
370
387
  if ((0, import_types.isObject)(originalProp) && (0, import_types.isObject)(objToDiffProp)) {
@@ -407,8 +424,10 @@ const isEmpty = (o) => Object.keys(o).length === 0;
407
424
  const isEmptyObject = (o) => (0, import_types.isObject)(o) && isEmpty(o);
408
425
  const makeObjectWithoutPrototype = () => /* @__PURE__ */ Object.create(null);
409
426
  const deepDiff = (lhs, rhs) => {
410
- if (lhs === rhs) return {};
411
- if (!(0, import_types.isObjectLike)(lhs) || !(0, import_types.isObjectLike)(rhs)) return rhs;
427
+ if (lhs === rhs)
428
+ return {};
429
+ if (!(0, import_types.isObjectLike)(lhs) || !(0, import_types.isObjectLike)(rhs))
430
+ return rhs;
412
431
  const deletedValues = Object.keys(lhs).reduce((acc, key) => {
413
432
  if (!hasOwnProperty(rhs, key)) {
414
433
  acc[key] = void 0;
@@ -416,7 +435,8 @@ const deepDiff = (lhs, rhs) => {
416
435
  return acc;
417
436
  }, makeObjectWithoutPrototype());
418
437
  if ((0, import_types.isDate)(lhs) || (0, import_types.isDate)(rhs)) {
419
- if (lhs.valueOf() === rhs.valueOf()) return {};
438
+ if (lhs.valueOf() === rhs.valueOf())
439
+ return {};
420
440
  return rhs;
421
441
  }
422
442
  return Object.keys(rhs).reduce((acc, key) => {
@@ -438,7 +458,8 @@ const overwrite = (element, params, opts = {}) => {
438
458
  const allowUnderscore = opts.preventUnderscore;
439
459
  const preventCaching = opts.preventCaching;
440
460
  for (const e in params) {
441
- if (excl.includes(e) || !allowUnderscore && e.startsWith("__")) continue;
461
+ if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
462
+ continue;
442
463
  const elementProp = element[e];
443
464
  const paramsProp = params[e];
444
465
  if (paramsProp !== void 0) {
@@ -455,7 +476,8 @@ const overwrite = (element, params, opts = {}) => {
455
476
  };
456
477
  const overwriteShallow = (obj, params, excludeFrom = []) => {
457
478
  for (const e in params) {
458
- if (excludeFrom.includes(e) || e.startsWith("__")) continue;
479
+ if (excludeFrom.includes(e) || e.startsWith("__"))
480
+ continue;
459
481
  obj[e] = params[e];
460
482
  }
461
483
  return obj;
@@ -466,11 +488,14 @@ const overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new Wea
466
488
  if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
467
489
  return params;
468
490
  }
469
- if (visited.has(obj)) return visited.get(obj);
491
+ if (visited.has(obj))
492
+ return visited.get(obj);
470
493
  visited.set(obj, obj);
471
494
  for (const e in params) {
472
- if (!Object.hasOwnProperty.call(params, e)) continue;
473
- if (excl.includes(e) || forcedExclude && e.startsWith("__")) continue;
495
+ if (!Object.hasOwnProperty.call(params, e))
496
+ continue;
497
+ if (excl.includes(e) || forcedExclude && e.startsWith("__"))
498
+ continue;
474
499
  const objProp = obj[e];
475
500
  const paramsProp = params[e];
476
501
  if ((0, import_node.isDOMNode)(paramsProp)) {
@@ -484,14 +509,16 @@ const overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new Wea
484
509
  return obj;
485
510
  };
486
511
  const mergeIfExisted = (a, b) => {
487
- if ((0, import_types.isObjectLike)(a) && (0, import_types.isObjectLike)(b)) return deepMerge(a, b);
512
+ if ((0, import_types.isObjectLike)(a) && (0, import_types.isObjectLike)(b))
513
+ return deepMerge(a, b);
488
514
  return a || b;
489
515
  };
490
516
  const flattenRecursive = (param, prop, stack = []) => {
491
517
  const objectized = (0, import_array.mergeAndCloneIfArray)(param);
492
518
  stack.push(objectized);
493
519
  const extendOfExtend = objectized[prop];
494
- if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack);
520
+ if (extendOfExtend)
521
+ flattenRecursive(extendOfExtend, prop, stack);
495
522
  delete objectized[prop];
496
523
  return stack;
497
524
  };
@@ -522,24 +549,31 @@ const isEqualDeep = (param, element, visited = /* @__PURE__ */ new Set()) => {
522
549
  return true;
523
550
  };
524
551
  const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
525
- if (obj1 === obj2) return true;
526
- if (!(0, import_types.isObjectLike)(obj1) || !(0, import_types.isObjectLike)(obj2)) return false;
527
- if ((0, import_node.isDOMNode)(obj1) || (0, import_node.isDOMNode)(obj2)) return obj1 === obj2;
552
+ if (obj1 === obj2)
553
+ return true;
554
+ if (!(0, import_types.isObjectLike)(obj1) || !(0, import_types.isObjectLike)(obj2))
555
+ return false;
556
+ if ((0, import_node.isDOMNode)(obj1) || (0, import_node.isDOMNode)(obj2))
557
+ return obj1 === obj2;
528
558
  const stack = [[obj1, obj2]];
529
559
  const visited = /* @__PURE__ */ new WeakSet();
530
560
  while (stack.length > 0) {
531
561
  const [current1, current2] = stack.pop();
532
- if (visited.has(current1)) continue;
562
+ if (visited.has(current1))
563
+ continue;
533
564
  visited.add(current1);
534
565
  const keys1 = Object.keys(current1).filter((key) => !ignoredKeys.includes(key));
535
566
  const keys2 = Object.keys(current2).filter((key) => !ignoredKeys.includes(key));
536
- if (keys1.length !== keys2.length) return false;
567
+ if (keys1.length !== keys2.length)
568
+ return false;
537
569
  for (const key of keys1) {
538
- if (!Object.prototype.hasOwnProperty.call(current2, key)) return false;
570
+ if (!Object.prototype.hasOwnProperty.call(current2, key))
571
+ return false;
539
572
  const value1 = current1[key];
540
573
  const value2 = current2[key];
541
574
  if ((0, import_node.isDOMNode)(value1) || (0, import_node.isDOMNode)(value2)) {
542
- if (value1 !== value2) return false;
575
+ if (value1 !== value2)
576
+ return false;
543
577
  } else if ((0, import_types.isObjectLike)(value1) && (0, import_types.isObjectLike)(value2)) {
544
578
  if (value1 !== value2) {
545
579
  stack.push([value1, value2]);
@@ -552,7 +586,8 @@ const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
552
586
  return true;
553
587
  };
554
588
  const removeFromObject = (obj, props) => {
555
- if (props === void 0 || props === null) return obj;
589
+ if (props === void 0 || props === null)
590
+ return obj;
556
591
  if ((0, import_types.is)(props)("string", "number")) {
557
592
  delete obj[props];
558
593
  } else if ((0, import_types.isArray)(props)) {
@@ -649,7 +684,7 @@ const detectInfiniteLoop = (arr) => {
649
684
  repeatCount = 1;
650
685
  }
651
686
  if (repeatCount >= maxRepeats * 2) {
652
- if (ENV === "test" || ENV === "development") {
687
+ if (ENV === "testing" || ENV === "development") {
653
688
  console.warn("Warning: Potential infinite loop detected due to repeated sequence:", pattern);
654
689
  }
655
690
  return true;
@@ -47,7 +47,8 @@ const brackRegex = {
47
47
  3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
48
48
  };
49
49
  function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
50
- if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{")) return str;
50
+ if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
51
+ return str;
51
52
  const reg = brackRegex[options.bracketsLength || 2];
52
53
  const obj = forcedState || (this == null ? void 0 : this.state) || {};
53
54
  return str.replace(reg, (_, parentPath, variable) => {
package/dist/cjs/types.js CHANGED
@@ -36,7 +36,8 @@ __export(types_exports, {
36
36
  module.exports = __toCommonJS(types_exports);
37
37
  var import_node = require("./node.js");
38
38
  const isObject = (arg) => {
39
- if (arg === null) return false;
39
+ if (arg === null)
40
+ return false;
40
41
  return typeof arg === "object" && arg.constructor === Object;
41
42
  };
42
43
  const isString = (arg) => typeof arg === "string";
@@ -47,7 +48,8 @@ const isNull = (arg) => arg === null;
47
48
  const isArray = (arg) => Array.isArray(arg);
48
49
  const isDate = (d) => d instanceof Date;
49
50
  const isObjectLike = (arg) => {
50
- if (arg === null) return false;
51
+ if (arg === null)
52
+ return false;
51
53
  return typeof arg === "object";
52
54
  };
53
55
  const isDefined = (arg) => {
package/dist/esm/array.js CHANGED
@@ -9,7 +9,8 @@ const getFrequencyInArray = (arr, value) => {
9
9
  }, 0);
10
10
  };
11
11
  const removeFromArray = (arr, index) => {
12
- if (isString(index)) index = parseInt(index);
12
+ if (isString(index))
13
+ index = parseInt(index);
13
14
  if (isNumber(index)) {
14
15
  if (index < 0 || index >= arr.length || isNaN(index)) {
15
16
  throw new Error("Invalid index");
@@ -42,7 +43,8 @@ const cutArrayBeforeValue = (arr, value) => {
42
43
  return arr;
43
44
  };
44
45
  const cutArrayAfterValue = (arr, value) => {
45
- if (!isArray(arr)) return;
46
+ if (!isArray(arr))
47
+ return;
46
48
  const index = arr.indexOf(value);
47
49
  if (index !== -1) {
48
50
  return arr.slice(index + 1);
@@ -101,7 +103,8 @@ const filterArraysFast = (sourceArr, excludeArr) => {
101
103
  return sourceArr.filter((item) => !excludeSet.has(item));
102
104
  };
103
105
  const checkIfStringIsInArray = (string, arr) => {
104
- if (!string) return;
106
+ if (!string)
107
+ return;
105
108
  return arr.filter((v) => string.includes(v)).length;
106
109
  };
107
110
  export {
@@ -23,18 +23,21 @@ import { isArray, isFunction, isObject, isString } from "./types.js";
23
23
  const ENV = "development";
24
24
  const checkIfKeyIsComponent = (key) => {
25
25
  const isFirstKeyString = isString(key);
26
- if (!isFirstKeyString) return;
26
+ if (!isFirstKeyString)
27
+ return;
27
28
  const firstCharKey = key.slice(0, 1);
28
29
  return /^[A-Z]*$/.test(firstCharKey);
29
30
  };
30
31
  const checkIfKeyIsProperty = (key) => {
31
32
  const isFirstKeyString = isString(key);
32
- if (!isFirstKeyString) return;
33
+ if (!isFirstKeyString)
34
+ return;
33
35
  const firstCharKey = key.slice(0, 1);
34
36
  return /^[a-z]*$/.test(firstCharKey);
35
37
  };
36
38
  const addAdditionalExtend = (newExtend, element) => {
37
- if (!newExtend) return element;
39
+ if (!newExtend)
40
+ return element;
38
41
  const { extend: elementExtend } = element;
39
42
  const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend];
40
43
  const receivedArray = isArray(newExtend) ? newExtend : [newExtend];
@@ -59,7 +62,8 @@ const checkIfSugar = (element, parent, key) => {
59
62
  const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
60
63
  if (hasComponentAttrs && (childProps || extendProps || children || childExtends)) {
61
64
  const logErr = (_a = parent || element) == null ? void 0 : _a.error;
62
- if (logErr) logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
65
+ if (logErr)
66
+ logErr.call(element, "Sugar component includes params for builtin components", { verbose: true });
63
67
  }
64
68
  return !hasComponentAttrs || childProps || extendProps || children || childExtends;
65
69
  };
@@ -72,7 +76,8 @@ const extendizeByKey = (element, parent, key) => {
72
76
  const isSugar = checkIfSugar(element, parent, key);
73
77
  const extendFromKey = extractComponentKeyFromKey(key);
74
78
  const isExtendKeyComponent = context && context.components[extendFromKey];
75
- if (element === isExtendKeyComponent) return element;
79
+ if (element === isExtendKeyComponent)
80
+ return element;
76
81
  else if (isSugar) {
77
82
  const newElem = addAdditionalExtend(element.extends, {
78
83
  extend: extendFromKey,
@@ -95,7 +100,8 @@ const extendizeByKey = (element, parent, key) => {
95
100
  newElem.if = newElem.props.if;
96
101
  delete newElem.props.if;
97
102
  }
98
- if (childExtends) newElem.childExtend = childExtends;
103
+ if (childExtends)
104
+ newElem.childExtend = childExtends;
99
105
  return newElem;
100
106
  } else if (!extend || extend === true) {
101
107
  return __spreadProps(__spreadValues({}, element), {
@@ -117,7 +123,8 @@ function getCapitalCaseKeys(obj) {
117
123
  }
118
124
  const addChildrenIfNotInOriginal = (element, parent, key) => {
119
125
  const childElems = getCapitalCaseKeys(element.props);
120
- if (!childElems.length) return element;
126
+ if (!childElems.length)
127
+ return element;
121
128
  for (const i in childElems) {
122
129
  const childKey = childElems[i];
123
130
  const childElem = element[childKey];
@@ -126,12 +133,16 @@ const addChildrenIfNotInOriginal = (element, parent, key) => {
126
133
  element[childKey] = val;
127
134
  delete element.props[childKey];
128
135
  };
129
- if (newChild == null ? void 0 : newChild.ignoreExtend) continue;
130
- if (newChild === null) assignChild(null);
131
- else if (!childElem) assignChild(deepClone(newChild));
136
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
137
+ continue;
138
+ if (newChild === null)
139
+ assignChild(null);
140
+ else if (!childElem)
141
+ assignChild(deepClone(newChild));
132
142
  else {
133
143
  const isSugarChildElem = checkIfSugar(childElem, parent, key);
134
- if (isSugarChildElem) continue;
144
+ if (isSugarChildElem)
145
+ continue;
135
146
  assignChild({
136
147
  extend: element[childKey],
137
148
  props: newChild
@@ -144,15 +155,17 @@ const applyKeyComponentAsExtend = (element, parent, key) => {
144
155
  };
145
156
  const applyComponentFromContext = (element, parent, options) => {
146
157
  const { context } = element;
147
- if (!context || !context.components) return;
158
+ if (!context || !context.components)
159
+ return;
148
160
  const { components } = context;
149
161
  const { extend } = element;
150
162
  const execExtend = exec(extend, element);
151
163
  if (isString(execExtend)) {
152
164
  const componentExists = components[execExtend] || components["smbls." + execExtend];
153
- if (componentExists) element.extend = componentExists;
165
+ if (componentExists)
166
+ element.extend = componentExists;
154
167
  else {
155
- if ((ENV === "test" || ENV === "development") && options.verbose) {
168
+ if ((ENV === "testing" || ENV === "development") && options.verbose) {
156
169
  console.warn(execExtend, "is not in library", components, element);
157
170
  console.warn("replacing with ", {});
158
171
  }
@@ -161,13 +174,15 @@ const applyComponentFromContext = (element, parent, options) => {
161
174
  }
162
175
  };
163
176
  const isVariant = (param) => {
164
- if (!isString(param)) return;
177
+ if (!isString(param))
178
+ return;
165
179
  const firstCharKey = param.slice(0, 1);
166
180
  return firstCharKey === ".";
167
181
  };
168
182
  const hasVariantProp = (element) => {
169
183
  const { props } = element;
170
- if (isObject(props) && isString(props.variant)) return true;
184
+ if (isObject(props) && isString(props.variant))
185
+ return true;
171
186
  };
172
187
  const getChildrenComponentsByKey = (key, el) => {
173
188
  if (key === el.key || el.__ref.__componentKey === key) {
@@ -176,12 +191,14 @@ const getChildrenComponentsByKey = (key, el) => {
176
191
  if (el.extend) {
177
192
  const foundString = isString(el.extend) && el.extend === key;
178
193
  const foundInArray = isArray(el.extend) && el.extend.filter((v) => v === key).length;
179
- if (foundString || foundInArray) return el;
194
+ if (foundString || foundInArray)
195
+ return el;
180
196
  }
181
197
  if (el.parent && el.parent.childExtend) {
182
198
  const foundString = isString(el.parent.childExtend) && el.parent.childExtend === key;
183
199
  const foundInArray = isArray(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
184
- if (foundString || foundInArray) return el;
200
+ if (foundString || foundInArray)
201
+ return el;
185
202
  }
186
203
  };
187
204
  const getExtendsInElement = (obj) => {
@@ -213,8 +230,10 @@ const setContentKey = (el, opts = {}) => {
213
230
  const contentElementKey = opts.contentElementKey;
214
231
  if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
215
232
  ref.contentElementKey = contentElementKey || "content";
216
- } else ref.contentElementKey = "content";
217
- if (contentElementKey !== "content") opts.contentElementKey = "content";
233
+ } else
234
+ ref.contentElementKey = "content";
235
+ if (contentElementKey !== "content")
236
+ opts.contentElementKey = "content";
218
237
  return ref.contentElementKey;
219
238
  };
220
239
  export {
@@ -2,26 +2,31 @@ import { isUndefined } from "./types.js";
2
2
  import { document } from "./globals.js";
3
3
  const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
4
4
  const setCookie = (cname, cvalue, exdays = 365) => {
5
- if (isUndefined(document) || isUndefined(document.cookie)) return;
5
+ if (isUndefined(document) || isUndefined(document.cookie))
6
+ return;
6
7
  const d = /* @__PURE__ */ new Date();
7
8
  d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
8
9
  const expires = `expires=${d.toUTCString()}`;
9
10
  document.cookie = `${cname}=${cvalue};${expires};path=/`;
10
11
  };
11
12
  const getCookie = (cname) => {
12
- if (isUndefined(document) || isUndefined(document.cookie)) return;
13
+ if (isUndefined(document) || isUndefined(document.cookie))
14
+ return;
13
15
  const name = `${cname}=`;
14
16
  const decodedCookie = decodeURIComponent(document.cookie);
15
17
  const ca = decodedCookie.split(";");
16
18
  for (let i = 0; i < ca.length; i++) {
17
19
  let c = ca[i];
18
- while (c.charAt(0) === " ") c = c.substring(1);
19
- if (c.indexOf(name) === 0) return c.substring(name.length, c.length);
20
+ while (c.charAt(0) === " ")
21
+ c = c.substring(1);
22
+ if (c.indexOf(name) === 0)
23
+ return c.substring(name.length, c.length);
20
24
  }
21
25
  return "";
22
26
  };
23
27
  const removeCookie = (cname) => {
24
- if (isUndefined(document) || isUndefined(document.cookie)) return;
28
+ if (isUndefined(document) || isUndefined(document.cookie))
29
+ return;
25
30
  document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
26
31
  };
27
32
  function getLocalStorage(key) {
@@ -5,12 +5,14 @@ function debounce(func, wait, immediate) {
5
5
  const args = arguments;
6
6
  const later = function() {
7
7
  timeout = null;
8
- if (!immediate) func.apply(context, args);
8
+ if (!immediate)
9
+ func.apply(context, args);
9
10
  };
10
11
  const callNow = immediate && !timeout;
11
12
  clearTimeout(timeout);
12
13
  timeout = setTimeout(later, wait);
13
- if (callNow) func.apply(context, args);
14
+ if (callNow)
15
+ func.apply(context, args);
14
16
  };
15
17
  }
16
18
  const debounceOnContext = (element, func, timeout = 300) => {
package/dist/esm/key.js CHANGED
@@ -1,4 +1,4 @@
1
- const generateKey = /* @__PURE__ */ function() {
1
+ const generateKey = function() {
2
2
  let index = 0;
3
3
  function newId() {
4
4
  index++;
package/dist/esm/log.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const logIf = (bool, ...arg) => {
2
- if (bool) arg.map((v) => console.log(v));
2
+ if (bool)
3
+ arg.map((v) => console.log(v));
3
4
  };
4
5
  const logGroupIf = (bool, key, ...arg) => {
5
6
  if (bool) {
@@ -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,7 +81,8 @@ 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;
@@ -105,10 +108,13 @@ const deepClone = (obj, options = {}) => {
105
108
  const clone2 = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
106
109
  visited.set(obj, clone2);
107
110
  for (const key in obj) {
108
- if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
109
- if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") continue;
111
+ if (!Object.prototype.hasOwnProperty.call(obj, key))
112
+ continue;
113
+ if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
114
+ continue;
110
115
  const value = obj[key];
111
- if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) continue;
116
+ if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value))
117
+ continue;
112
118
  if (isDOMNode(value)) {
113
119
  clone2[key] = value;
114
120
  continue;
@@ -238,14 +244,16 @@ const objectToString = (obj = {}, indent = 0) => {
238
244
  const detachFunctionsFromObject = (obj, detached = {}) => {
239
245
  for (const prop in obj) {
240
246
  const objProp = obj[prop];
241
- if (isFunction(objProp)) continue;
247
+ if (isFunction(objProp))
248
+ continue;
242
249
  else if (isObject(objProp)) {
243
250
  detached[prop] = {};
244
251
  deepStringify(objProp, detached[prop]);
245
252
  } else if (isArray(objProp)) {
246
253
  detached[prop] = [];
247
254
  objProp.forEach((v, i) => {
248
- if (isFunction(v)) return;
255
+ if (isFunction(v))
256
+ return;
249
257
  if (isObject(v)) {
250
258
  detached[prop][i] = {};
251
259
  detachFunctionsFromObject(v, detached[prop][i]);
@@ -260,11 +268,15 @@ const detachFunctionsFromObject = (obj, detached = {}) => {
260
268
  return detached;
261
269
  };
262
270
  const hasFunction = (str) => {
263
- if (!str) return false;
271
+ if (!str)
272
+ return false;
264
273
  const trimmed = str.trim().replace(/\n\s*/g, " ").trim();
265
- if (trimmed === "") return false;
266
- if (trimmed === "{}") return false;
267
- if (trimmed === "[]") return false;
274
+ if (trimmed === "")
275
+ return false;
276
+ if (trimmed === "{}")
277
+ return false;
278
+ if (trimmed === "[]")
279
+ return false;
268
280
  const patterns = [
269
281
  /^\(\s*\{[^}]*\}\s*\)\s*=>/,
270
282
  /^(\([^)]*\)|[^=]*)\s*=>/,
@@ -282,7 +294,8 @@ const hasFunction = (str) => {
282
294
  const deepDestringify = (obj, destringified = {}) => {
283
295
  for (const prop in obj) {
284
296
  const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, prop);
285
- if (!hasOwnProperty2) continue;
297
+ if (!hasOwnProperty2)
298
+ continue;
286
299
  const objProp = obj[prop];
287
300
  if (isString(objProp)) {
288
301
  if (hasFunction(objProp)) {
@@ -290,7 +303,8 @@ const deepDestringify = (obj, destringified = {}) => {
290
303
  const evalProp = window.eval(`(${objProp})`);
291
304
  destringified[prop] = evalProp;
292
305
  } catch (e) {
293
- if (e) destringified[prop] = objProp;
306
+ if (e)
307
+ destringified[prop] = objProp;
294
308
  }
295
309
  } else {
296
310
  destringified[prop] = objProp;
@@ -304,7 +318,8 @@ const deepDestringify = (obj, destringified = {}) => {
304
318
  const evalProp = window.eval(`(${arrProp})`);
305
319
  destringified[prop].push(evalProp);
306
320
  } catch (e) {
307
- if (e) destringified[prop].push(arrProp);
321
+ if (e)
322
+ destringified[prop].push(arrProp);
308
323
  }
309
324
  } else {
310
325
  destringified[prop].push(arrProp);
@@ -327,12 +342,14 @@ const stringToObject = (str, opts = { verbose: true }) => {
327
342
  try {
328
343
  return str ? window.eval("(" + str + ")") : {};
329
344
  } catch (e) {
330
- if (opts.verbose) console.warn(e);
345
+ if (opts.verbose)
346
+ console.warn(e);
331
347
  }
332
348
  };
333
349
  const diffObjects = (original, objToDiff, cache) => {
334
350
  for (const e in objToDiff) {
335
- if (e === "ref") continue;
351
+ if (e === "ref")
352
+ continue;
336
353
  const originalProp = original[e];
337
354
  const objToDiffProp = objToDiff[e];
338
355
  if (isObject(originalProp) && isObject(objToDiffProp)) {
@@ -375,8 +392,10 @@ const isEmpty = (o) => Object.keys(o).length === 0;
375
392
  const isEmptyObject = (o) => isObject(o) && isEmpty(o);
376
393
  const makeObjectWithoutPrototype = () => /* @__PURE__ */ Object.create(null);
377
394
  const deepDiff = (lhs, rhs) => {
378
- if (lhs === rhs) return {};
379
- if (!isObjectLike(lhs) || !isObjectLike(rhs)) return rhs;
395
+ if (lhs === rhs)
396
+ return {};
397
+ if (!isObjectLike(lhs) || !isObjectLike(rhs))
398
+ return rhs;
380
399
  const deletedValues = Object.keys(lhs).reduce((acc, key) => {
381
400
  if (!hasOwnProperty(rhs, key)) {
382
401
  acc[key] = void 0;
@@ -384,7 +403,8 @@ const deepDiff = (lhs, rhs) => {
384
403
  return acc;
385
404
  }, makeObjectWithoutPrototype());
386
405
  if (isDate(lhs) || isDate(rhs)) {
387
- if (lhs.valueOf() === rhs.valueOf()) return {};
406
+ if (lhs.valueOf() === rhs.valueOf())
407
+ return {};
388
408
  return rhs;
389
409
  }
390
410
  return Object.keys(rhs).reduce((acc, key) => {
@@ -406,7 +426,8 @@ const overwrite = (element, params, opts = {}) => {
406
426
  const allowUnderscore = opts.preventUnderscore;
407
427
  const preventCaching = opts.preventCaching;
408
428
  for (const e in params) {
409
- if (excl.includes(e) || !allowUnderscore && e.startsWith("__")) continue;
429
+ if (excl.includes(e) || !allowUnderscore && e.startsWith("__"))
430
+ continue;
410
431
  const elementProp = element[e];
411
432
  const paramsProp = params[e];
412
433
  if (paramsProp !== void 0) {
@@ -423,7 +444,8 @@ const overwrite = (element, params, opts = {}) => {
423
444
  };
424
445
  const overwriteShallow = (obj, params, excludeFrom = []) => {
425
446
  for (const e in params) {
426
- if (excludeFrom.includes(e) || e.startsWith("__")) continue;
447
+ if (excludeFrom.includes(e) || e.startsWith("__"))
448
+ continue;
427
449
  obj[e] = params[e];
428
450
  }
429
451
  return obj;
@@ -434,11 +456,14 @@ const overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new Wea
434
456
  if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
435
457
  return params;
436
458
  }
437
- if (visited.has(obj)) return visited.get(obj);
459
+ if (visited.has(obj))
460
+ return visited.get(obj);
438
461
  visited.set(obj, obj);
439
462
  for (const e in params) {
440
- if (!Object.hasOwnProperty.call(params, e)) continue;
441
- if (excl.includes(e) || forcedExclude && e.startsWith("__")) continue;
463
+ if (!Object.hasOwnProperty.call(params, e))
464
+ continue;
465
+ if (excl.includes(e) || forcedExclude && e.startsWith("__"))
466
+ continue;
442
467
  const objProp = obj[e];
443
468
  const paramsProp = params[e];
444
469
  if (isDOMNode(paramsProp)) {
@@ -452,14 +477,16 @@ const overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new Wea
452
477
  return obj;
453
478
  };
454
479
  const mergeIfExisted = (a, b) => {
455
- if (isObjectLike(a) && isObjectLike(b)) return deepMerge(a, b);
480
+ if (isObjectLike(a) && isObjectLike(b))
481
+ return deepMerge(a, b);
456
482
  return a || b;
457
483
  };
458
484
  const flattenRecursive = (param, prop, stack = []) => {
459
485
  const objectized = mergeAndCloneIfArray(param);
460
486
  stack.push(objectized);
461
487
  const extendOfExtend = objectized[prop];
462
- if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack);
488
+ if (extendOfExtend)
489
+ flattenRecursive(extendOfExtend, prop, stack);
463
490
  delete objectized[prop];
464
491
  return stack;
465
492
  };
@@ -490,24 +517,31 @@ const isEqualDeep = (param, element, visited = /* @__PURE__ */ new Set()) => {
490
517
  return true;
491
518
  };
492
519
  const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
493
- if (obj1 === obj2) return true;
494
- if (!isObjectLike(obj1) || !isObjectLike(obj2)) return false;
495
- if (isDOMNode(obj1) || isDOMNode(obj2)) return obj1 === obj2;
520
+ if (obj1 === obj2)
521
+ return true;
522
+ if (!isObjectLike(obj1) || !isObjectLike(obj2))
523
+ return false;
524
+ if (isDOMNode(obj1) || isDOMNode(obj2))
525
+ return obj1 === obj2;
496
526
  const stack = [[obj1, obj2]];
497
527
  const visited = /* @__PURE__ */ new WeakSet();
498
528
  while (stack.length > 0) {
499
529
  const [current1, current2] = stack.pop();
500
- if (visited.has(current1)) continue;
530
+ if (visited.has(current1))
531
+ continue;
501
532
  visited.add(current1);
502
533
  const keys1 = Object.keys(current1).filter((key) => !ignoredKeys.includes(key));
503
534
  const keys2 = Object.keys(current2).filter((key) => !ignoredKeys.includes(key));
504
- if (keys1.length !== keys2.length) return false;
535
+ if (keys1.length !== keys2.length)
536
+ return false;
505
537
  for (const key of keys1) {
506
- if (!Object.prototype.hasOwnProperty.call(current2, key)) return false;
538
+ if (!Object.prototype.hasOwnProperty.call(current2, key))
539
+ return false;
507
540
  const value1 = current1[key];
508
541
  const value2 = current2[key];
509
542
  if (isDOMNode(value1) || isDOMNode(value2)) {
510
- if (value1 !== value2) return false;
543
+ if (value1 !== value2)
544
+ return false;
511
545
  } else if (isObjectLike(value1) && isObjectLike(value2)) {
512
546
  if (value1 !== value2) {
513
547
  stack.push([value1, value2]);
@@ -520,7 +554,8 @@ const deepContains = (obj1, obj2, ignoredKeys = ["node", "__ref"]) => {
520
554
  return true;
521
555
  };
522
556
  const removeFromObject = (obj, props) => {
523
- if (props === void 0 || props === null) return obj;
557
+ if (props === void 0 || props === null)
558
+ return obj;
524
559
  if (is(props)("string", "number")) {
525
560
  delete obj[props];
526
561
  } else if (isArray(props)) {
@@ -617,7 +652,7 @@ const detectInfiniteLoop = (arr) => {
617
652
  repeatCount = 1;
618
653
  }
619
654
  if (repeatCount >= maxRepeats * 2) {
620
- if (ENV === "test" || ENV === "development") {
655
+ if (ENV === "testing" || ENV === "development") {
621
656
  console.warn("Warning: Potential infinite loop detected due to repeated sequence:", pattern);
622
657
  }
623
658
  return true;
@@ -15,7 +15,8 @@ const brackRegex = {
15
15
  3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
16
16
  };
17
17
  function replaceLiteralsWithObjectFields(str, options = {}, forcedState) {
18
- if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{")) return str;
18
+ if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
19
+ return str;
19
20
  const reg = brackRegex[options.bracketsLength || 2];
20
21
  const obj = forcedState || (this == null ? void 0 : this.state) || {};
21
22
  return str.replace(reg, (_, parentPath, variable) => {
package/dist/esm/types.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { isHtmlElement, isNode } from "./node.js";
2
2
  const isObject = (arg) => {
3
- if (arg === null) return false;
3
+ if (arg === null)
4
+ return false;
4
5
  return typeof arg === "object" && arg.constructor === Object;
5
6
  };
6
7
  const isString = (arg) => typeof arg === "string";
@@ -11,7 +12,8 @@ const isNull = (arg) => arg === null;
11
12
  const isArray = (arg) => Array.isArray(arg);
12
13
  const isDate = (d) => d instanceof Date;
13
14
  const isObjectLike = (arg) => {
14
- if (arg === null) return false;
15
+ if (arg === null)
16
+ return false;
15
17
  return typeof arg === "object";
16
18
  };
17
19
  const isDefined = (arg) => {
package/object.js CHANGED
@@ -815,7 +815,7 @@ export const detectInfiniteLoop = arr => {
815
815
 
816
816
  // If the pattern repeats more than `maxRepeats`, throw a warning
817
817
  if (repeatCount >= maxRepeats * 2) {
818
- if (ENV === 'test' || ENV === 'development') {
818
+ if (ENV === 'testing' || ENV === 'development') {
819
819
  console.warn('Warning: Potential infinite loop detected due to repeated sequence:', pattern)
820
820
  }
821
821
  return true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.200",
3
+ "version": "2.5.203",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -21,10 +21,10 @@
21
21
  "copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
22
22
  "build:esm": "npx esbuild *.js --target=es2017 --format=esm --outdir=dist/esm",
23
23
  "build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
24
- "build": "rimraf -I dist; npm run build:cjs; npm run build:esm",
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": "0afb63ec375f0526f47ff300885de393138b01e8",
27
+ "gitHead": "f8c712416647ab3789253b7176eaa762627fc677",
28
28
  "devDependencies": {
29
29
  "@babel/core": "^7.12.0"
30
30
  }