@symbo.ls/scratch 2.11.430 → 2.11.439

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.
@@ -56,13 +56,13 @@ var require_cjs = __commonJS({
56
56
  document: () => document3,
57
57
  global: () => global,
58
58
  self: () => self,
59
- window: () => window2
59
+ window: () => window3
60
60
  });
61
61
  module2.exports = __toCommonJS2(globals_exports);
62
62
  var global = globalThis;
63
63
  var self = globalThis;
64
- var window2 = globalThis;
65
- var document3 = window2.document;
64
+ var window3 = globalThis;
65
+ var document3 = window3.document;
66
66
  }
67
67
  });
68
68
 
@@ -169,13 +169,13 @@ var require_globals = __commonJS({
169
169
  document: () => document3,
170
170
  global: () => global,
171
171
  self: () => self,
172
- window: () => window2
172
+ window: () => window3
173
173
  });
174
174
  module2.exports = __toCommonJS2(globals_exports);
175
175
  var global = globalThis;
176
176
  var self = globalThis;
177
- var window2 = globalThis;
178
- var document3 = window2.document;
177
+ var window3 = globalThis;
178
+ var document3 = window3.document;
179
179
  }
180
180
  });
181
181
 
@@ -336,7 +336,6 @@ var require_array = __commonJS({
336
336
  addItemAfterEveryElement: () => addItemAfterEveryElement,
337
337
  arrayContainsOtherArray: () => arrayContainsOtherArray,
338
338
  arraysEqual: () => arraysEqual,
339
- createNestedObject: () => createNestedObject,
340
339
  cutArrayAfterValue: () => cutArrayAfterValue,
341
340
  cutArrayBeforeValue: () => cutArrayBeforeValue,
342
341
  getFrequencyInArray: () => getFrequencyInArray,
@@ -403,22 +402,6 @@ var require_array = __commonJS({
403
402
  }
404
403
  return arr;
405
404
  };
406
- var createNestedObject = (arr, lastValue) => {
407
- const nestedObject = {};
408
- if (arr.length === 0) {
409
- return lastValue;
410
- }
411
- arr.reduce((obj, value, index) => {
412
- if (!obj[value]) {
413
- obj[value] = {};
414
- }
415
- if (index === arr.length - 1 && lastValue) {
416
- obj[value] = lastValue;
417
- }
418
- return obj[value];
419
- }, nestedObject);
420
- return nestedObject;
421
- };
422
405
  var removeValueFromArray = (arr, value) => {
423
406
  const index = arr.indexOf(value);
424
407
  if (index > -1) {
@@ -639,8 +622,8 @@ var require_object = __commonJS({
639
622
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
640
623
  var object_exports = {};
641
624
  __export2(object_exports, {
642
- checkIfKeyIsComponent: () => checkIfKeyIsComponent,
643
625
  clone: () => clone,
626
+ createNestedObject: () => createNestedObject,
644
627
  createObjectWithoutPrototype: () => createObjectWithoutPrototype,
645
628
  deepClone: () => deepClone,
646
629
  deepCloneExclude: () => deepCloneExclude,
@@ -651,13 +634,12 @@ var require_object = __commonJS({
651
634
  deepMerge: () => deepMerge,
652
635
  deepStringify: () => deepStringify,
653
636
  detachFunctionsFromObject: () => detachFunctionsFromObject,
637
+ detectInfiniteLoop: () => detectInfiniteLoop,
654
638
  diff: () => diff,
655
639
  diffArrays: () => diffArrays,
656
640
  diffObjects: () => diffObjects,
657
641
  exec: () => exec,
658
642
  flattenRecursive: () => flattenRecursive,
659
- getChildrenComponentsByKey: () => getChildrenComponentsByKey,
660
- getExtendsInElement: () => getExtendsInElement,
661
643
  hasOwnProperty: () => hasOwnProperty,
662
644
  isEmpty: () => isEmpty,
663
645
  isEmptyObject: () => isEmptyObject,
@@ -672,6 +654,7 @@ var require_object = __commonJS({
672
654
  overwriteDeep: () => overwriteDeep,
673
655
  overwriteShallow: () => overwriteShallow,
674
656
  removeFromObject: () => removeFromObject,
657
+ removeNestedKeyByPath: () => removeNestedKeyByPath,
675
658
  stringToObject: () => stringToObject
676
659
  });
677
660
  module2.exports = __toCommonJS2(object_exports);
@@ -680,6 +663,7 @@ var require_object = __commonJS({
680
663
  var import_array = require_array();
681
664
  var import_string = require_string();
682
665
  var import_node = require_node();
666
+ var ENV2 = "development";
683
667
  var exec = (param, element, state, context) => {
684
668
  if ((0, import_types.isFunction)(param)) {
685
669
  return param(
@@ -791,6 +775,8 @@ var require_object = __commonJS({
791
775
  continue;
792
776
  if ((0, import_types.isObjectLike)(objProp)) {
793
777
  o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
778
+ } else if ((0, import_types.isFunction)(objProp) && options.window) {
779
+ o[prop] = (options.window || import_globals2.window).eval("(" + objProp.toString() + ")");
794
780
  } else
795
781
  o[prop] = objProp;
796
782
  }
@@ -1034,16 +1020,23 @@ var require_object = __commonJS({
1034
1020
  }
1035
1021
  return obj;
1036
1022
  };
1037
- var overwriteDeep = (obj, params, excludeFrom = []) => {
1023
+ var overwriteDeep = (obj, params, excludeFrom = [], visited = /* @__PURE__ */ new WeakMap()) => {
1024
+ if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
1025
+ return params;
1026
+ }
1027
+ if (visited.has(obj)) {
1028
+ return visited.get(obj);
1029
+ }
1030
+ visited.set(obj, obj);
1038
1031
  for (const e in params) {
1039
- if (e === "__ref")
1040
- continue;
1041
- if (excludeFrom.includes(e) || e.startsWith("__"))
1032
+ if (e === "__ref" || excludeFrom.includes(e) || e.startsWith("__"))
1042
1033
  continue;
1043
1034
  const objProp = obj[e];
1044
1035
  const paramsProp = params[e];
1045
- if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
1046
- overwriteDeep(objProp, paramsProp);
1036
+ if ((0, import_node.isDOMNode)(paramsProp)) {
1037
+ obj[e] = paramsProp;
1038
+ } else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
1039
+ obj[e] = overwriteDeep(objProp, paramsProp, excludeFrom, visited);
1047
1040
  } else if (paramsProp !== void 0) {
1048
1041
  obj[e] = paramsProp;
1049
1042
  }
@@ -1151,53 +1144,60 @@ var require_object = __commonJS({
1151
1144
  }
1152
1145
  return newObj;
1153
1146
  };
1154
- var checkIfKeyIsComponent = (key) => {
1155
- const isFirstKeyString = (0, import_types.isString)(key);
1156
- if (!isFirstKeyString)
1157
- return;
1158
- const firstCharKey = key.slice(0, 1);
1159
- return /^[A-Z]*$/.test(firstCharKey);
1147
+ var createNestedObject = (arr, lastValue) => {
1148
+ const nestedObject = {};
1149
+ if (arr.length === 0) {
1150
+ return lastValue;
1151
+ }
1152
+ arr.reduce((obj, value, index) => {
1153
+ if (!obj[value]) {
1154
+ obj[value] = {};
1155
+ }
1156
+ if (index === arr.length - 1 && lastValue) {
1157
+ obj[value] = lastValue;
1158
+ }
1159
+ return obj[value];
1160
+ }, nestedObject);
1161
+ return nestedObject;
1160
1162
  };
1161
- var getChildrenComponentsByKey = (key, el) => {
1162
- if (key === el.key || el.__ref.__componentKey === key) {
1163
- return el;
1163
+ var removeNestedKeyByPath = (obj, path) => {
1164
+ if (!Array.isArray(path)) {
1165
+ throw new Error("Path must be an array.");
1164
1166
  }
1165
- if (el.extend) {
1166
- const foundString = (0, import_types.isString)(el.extend) && el.extend === key;
1167
- const foundInArray = (0, import_types.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
1168
- if (foundString || foundInArray)
1169
- return el;
1167
+ let current = obj;
1168
+ for (let i = 0; i < path.length - 1; i++) {
1169
+ if (current[path[i]] === void 0) {
1170
+ return;
1171
+ }
1172
+ current = current[path[i]];
1170
1173
  }
1171
- if (el.parent && el.parent.childExtend) {
1172
- const foundString = (0, import_types.isString)(el.parent.childExtend) && el.parent.childExtend === key;
1173
- const foundInArray = (0, import_types.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
1174
- if (foundString || foundInArray)
1175
- return el;
1174
+ const lastKey = path[path.length - 1];
1175
+ if (current && Object.hasOwnProperty.call(current, lastKey)) {
1176
+ delete current[lastKey];
1176
1177
  }
1177
1178
  };
1178
- var getExtendsInElement = (obj) => {
1179
- let result = [];
1180
- function traverse(o) {
1181
- for (const key in o) {
1182
- if (Object.hasOwnProperty.call(o, key)) {
1183
- if (checkIfKeyIsComponent(key)) {
1184
- result.push(key);
1185
- }
1186
- if (key === "extend") {
1187
- if (typeof o[key] === "string") {
1188
- result.push(o[key]);
1189
- } else if (Array.isArray(o[key])) {
1190
- result = result.concat(o[key]);
1191
- }
1192
- }
1193
- if (typeof o[key] === "object" && o[key] !== null) {
1194
- traverse(o[key]);
1179
+ var detectInfiniteLoop = (arr) => {
1180
+ const maxRepeats = 10;
1181
+ let pattern = [];
1182
+ let repeatCount = 0;
1183
+ for (let i = 0; i < arr.length; i++) {
1184
+ if (pattern.length < 2) {
1185
+ pattern.push(arr[i]);
1186
+ } else {
1187
+ if (arr[i] === pattern[i % 2]) {
1188
+ repeatCount++;
1189
+ } else {
1190
+ pattern = [arr[i - 1], arr[i]];
1191
+ repeatCount = 1;
1192
+ }
1193
+ if (repeatCount >= maxRepeats * 2) {
1194
+ if (ENV2 === "test" || ENV2 === "development") {
1195
+ console.warn("Warning: Potential infinite loop detected due to repeated sequence:", pattern);
1195
1196
  }
1197
+ return true;
1196
1198
  }
1197
1199
  }
1198
1200
  }
1199
- traverse(obj);
1200
- return result;
1201
1201
  };
1202
1202
  }
1203
1203
  });
@@ -1225,6 +1225,7 @@ var require_function = __commonJS({
1225
1225
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
1226
1226
  var function_exports = {};
1227
1227
  __export2(function_exports, {
1228
+ cloneFunction: () => cloneFunction,
1228
1229
  debounce: () => debounce,
1229
1230
  debounceOnContext: () => debounceOnContext,
1230
1231
  isStringFunction: () => isStringFunction,
@@ -1274,6 +1275,17 @@ var require_function = __commonJS({
1274
1275
  const functionRegex = /^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/;
1275
1276
  return functionRegex.test(inputString);
1276
1277
  };
1278
+ function cloneFunction(fn, win = window) {
1279
+ const temp = function() {
1280
+ return fn.apply(win, arguments);
1281
+ };
1282
+ for (const key in fn) {
1283
+ if (Object.hasOwnProperty.call(fn, key)) {
1284
+ temp[key] = fn[key];
1285
+ }
1286
+ }
1287
+ return temp;
1288
+ }
1277
1289
  }
1278
1290
  });
1279
1291
 
@@ -1543,6 +1555,172 @@ var require_tags = __commonJS({
1543
1555
  }
1544
1556
  });
1545
1557
 
1558
+ // ../../../domql/packages/utils/dist/cjs/component.js
1559
+ var require_component = __commonJS({
1560
+ "../../../domql/packages/utils/dist/cjs/component.js"(exports, module2) {
1561
+ "use strict";
1562
+ var __defProp2 = Object.defineProperty;
1563
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
1564
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
1565
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
1566
+ var __export2 = (target, all) => {
1567
+ for (var name in all)
1568
+ __defProp2(target, name, { get: all[name], enumerable: true });
1569
+ };
1570
+ var __copyProps2 = (to, from, except, desc) => {
1571
+ if (from && typeof from === "object" || typeof from === "function") {
1572
+ for (let key of __getOwnPropNames2(from))
1573
+ if (!__hasOwnProp2.call(to, key) && key !== except)
1574
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
1575
+ }
1576
+ return to;
1577
+ };
1578
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
1579
+ var component_exports = {};
1580
+ __export2(component_exports, {
1581
+ addAdditionalExtend: () => addAdditionalExtend,
1582
+ applyComponentFromContext: () => applyComponentFromContext,
1583
+ applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
1584
+ checkIfKeyIsComponent: () => checkIfKeyIsComponent,
1585
+ checkIfKeyIsProperty: () => checkIfKeyIsProperty,
1586
+ extendizeByKey: () => extendizeByKey,
1587
+ getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1588
+ getExtendsInElement: () => getExtendsInElement,
1589
+ hasVariantProp: () => hasVariantProp,
1590
+ isVariant: () => isVariant
1591
+ });
1592
+ module2.exports = __toCommonJS2(component_exports);
1593
+ var import__ = require_cjs2();
1594
+ var ENV2 = "development";
1595
+ var checkIfKeyIsComponent = (key) => {
1596
+ const isFirstKeyString = (0, import__.isString)(key);
1597
+ if (!isFirstKeyString)
1598
+ return;
1599
+ const firstCharKey = key.slice(0, 1);
1600
+ return /^[A-Z]*$/.test(firstCharKey);
1601
+ };
1602
+ var checkIfKeyIsProperty = (key) => {
1603
+ const isFirstKeyString = (0, import__.isString)(key);
1604
+ if (!isFirstKeyString)
1605
+ return;
1606
+ const firstCharKey = key.slice(0, 1);
1607
+ return /^[a-z]*$/.test(firstCharKey);
1608
+ };
1609
+ var addAdditionalExtend = (newExtend, element) => {
1610
+ const { extend: elementExtend } = element;
1611
+ const originalArray = (0, import__.isArray)(elementExtend) ? elementExtend : [elementExtend];
1612
+ const receivedArray = (0, import__.isArray)(newExtend) ? newExtend : [newExtend];
1613
+ const extend = (0, import__.joinArrays)(receivedArray, originalArray);
1614
+ return { ...element, extend };
1615
+ };
1616
+ var extendizeByKey = (element, parent, key) => {
1617
+ const { context } = parent;
1618
+ const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
1619
+ const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
1620
+ const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1621
+ const isExtendKeyComponent = context && context.components[extendFromKey];
1622
+ if (element === isExtendKeyComponent)
1623
+ return element;
1624
+ else if (!hasComponentAttrs || childProps) {
1625
+ return {
1626
+ extend: extendFromKey,
1627
+ tag,
1628
+ props: { ...element }
1629
+ };
1630
+ } else if (!extend || extend === true) {
1631
+ return {
1632
+ ...element,
1633
+ tag,
1634
+ extend: extendFromKey
1635
+ };
1636
+ } else if (extend) {
1637
+ return addAdditionalExtend(extendFromKey, element);
1638
+ } else if ((0, import__.isFunction)(element)) {
1639
+ return {
1640
+ extend: extendFromKey,
1641
+ tag,
1642
+ props: { ...(0, import__.exec)(element, parent) }
1643
+ };
1644
+ }
1645
+ };
1646
+ var applyKeyComponentAsExtend = (element, parent, key) => {
1647
+ return extendizeByKey(element, parent, key) || element;
1648
+ };
1649
+ var applyComponentFromContext = (element, parent, options) => {
1650
+ const { context } = element;
1651
+ if (!context || !context.components)
1652
+ return;
1653
+ const { components } = context;
1654
+ const { extend } = element;
1655
+ const execExtend = (0, import__.exec)(extend, element);
1656
+ if ((0, import__.isString)(execExtend)) {
1657
+ const componentExists = components[execExtend] || components["smbls." + execExtend];
1658
+ if (componentExists)
1659
+ element.extend = componentExists;
1660
+ else {
1661
+ if ((ENV2 === "test" || ENV2 === "development") && options.verbose) {
1662
+ console.warn(execExtend, "is not in library", components, element);
1663
+ console.warn("replacing with ", {});
1664
+ }
1665
+ element.extend = {};
1666
+ }
1667
+ }
1668
+ };
1669
+ var isVariant = (param) => {
1670
+ if (!(0, import__.isString)(param))
1671
+ return;
1672
+ const firstCharKey = param.slice(0, 1);
1673
+ return firstCharKey === ".";
1674
+ };
1675
+ var hasVariantProp = (element) => {
1676
+ const { props } = element;
1677
+ if ((0, import__.isObject)(props) && (0, import__.isString)(props.variant))
1678
+ return true;
1679
+ };
1680
+ var getChildrenComponentsByKey = (key, el) => {
1681
+ if (key === el.key || el.__ref.__componentKey === key) {
1682
+ return el;
1683
+ }
1684
+ if (el.extend) {
1685
+ const foundString = (0, import__.isString)(el.extend) && el.extend === key;
1686
+ const foundInArray = (0, import__.isArray)(el.extend) && el.extend.filter((v) => v === key).length;
1687
+ if (foundString || foundInArray)
1688
+ return el;
1689
+ }
1690
+ if (el.parent && el.parent.childExtend) {
1691
+ const foundString = (0, import__.isString)(el.parent.childExtend) && el.parent.childExtend === key;
1692
+ const foundInArray = (0, import__.isArray)(el.parent.childExtend) && el.parent.childExtend.filter((v) => v === key).length;
1693
+ if (foundString || foundInArray)
1694
+ return el;
1695
+ }
1696
+ };
1697
+ var getExtendsInElement = (obj) => {
1698
+ let result = [];
1699
+ function traverse(o) {
1700
+ for (const key in o) {
1701
+ if (Object.hasOwnProperty.call(o, key)) {
1702
+ if (checkIfKeyIsComponent(key)) {
1703
+ result.push(key);
1704
+ }
1705
+ if (key === "extend") {
1706
+ if (typeof o[key] === "string") {
1707
+ result.push(o[key]);
1708
+ } else if (Array.isArray(o[key])) {
1709
+ result = result.concat(o[key]);
1710
+ }
1711
+ }
1712
+ if (typeof o[key] === "object" && o[key] !== null) {
1713
+ traverse(o[key]);
1714
+ }
1715
+ }
1716
+ }
1717
+ }
1718
+ traverse(obj);
1719
+ return result;
1720
+ };
1721
+ }
1722
+ });
1723
+
1546
1724
  // ../../../domql/packages/utils/dist/cjs/index.js
1547
1725
  var require_cjs2 = __commonJS({
1548
1726
  "../../../domql/packages/utils/dist/cjs/index.js"(exports, module2) {
@@ -1575,6 +1753,7 @@ var require_cjs2 = __commonJS({
1575
1753
  __reExport(utils_exports, require_globals(), module2.exports);
1576
1754
  __reExport(utils_exports, require_cookie(), module2.exports);
1577
1755
  __reExport(utils_exports, require_tags(), module2.exports);
1756
+ __reExport(utils_exports, require_component(), module2.exports);
1578
1757
  }
1579
1758
  });
1580
1759