@symbo.ls/scratch 2.11.442 → 2.11.450

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.
@@ -633,6 +633,7 @@ var require_object = __commonJS({
633
633
  deepDiff: () => deepDiff,
634
634
  deepMerge: () => deepMerge2,
635
635
  deepStringify: () => deepStringify,
636
+ deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
636
637
  detachFunctionsFromObject: () => detachFunctionsFromObject,
637
638
  detectInfiniteLoop: () => detectInfiniteLoop,
638
639
  diff: () => diff,
@@ -641,6 +642,7 @@ var require_object = __commonJS({
641
642
  exec: () => exec,
642
643
  flattenRecursive: () => flattenRecursive,
643
644
  hasOwnProperty: () => hasOwnProperty,
645
+ isCyclic: () => isCyclic,
644
646
  isEmpty: () => isEmpty,
645
647
  isEmptyObject: () => isEmptyObject,
646
648
  isEqualDeep: () => isEqualDeep,
@@ -666,7 +668,8 @@ var require_object = __commonJS({
666
668
  var ENV2 = "development";
667
669
  var exec = (param, element, state, context) => {
668
670
  if ((0, import_types.isFunction)(param)) {
669
- return param(
671
+ return param.call(
672
+ element,
670
673
  element,
671
674
  state || element.state,
672
675
  context || element.context
@@ -765,24 +768,37 @@ var require_object = __commonJS({
765
768
  }
766
769
  return clone2;
767
770
  };
768
- var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
771
+ var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}, visited = /* @__PURE__ */ new WeakSet()) => {
772
+ if ((0, import_types.isObjectLike)(obj)) {
773
+ if (visited.has(obj)) {
774
+ return obj;
775
+ }
776
+ visited.add(obj);
777
+ }
769
778
  const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
770
779
  for (const prop in obj) {
771
780
  if (!Object.prototype.hasOwnProperty.call(obj, prop))
772
781
  continue;
773
782
  const objProp = obj[prop];
774
- if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
783
+ if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
775
784
  continue;
785
+ }
776
786
  if ((0, import_types.isObjectLike)(objProp)) {
777
- o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
787
+ o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
778
788
  } else if ((0, import_types.isFunction)(objProp) && options.window) {
779
789
  o[prop] = (options.window || import_globals2.window).eval("(" + objProp.toString() + ")");
780
- } else
790
+ } else {
781
791
  o[prop] = objProp;
792
+ }
782
793
  }
783
794
  return o;
784
795
  };
785
796
  var deepStringify = (obj, stringified = {}) => {
797
+ var _a;
798
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
799
+ console.warn("Trying to clone element or state at", obj);
800
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
801
+ }
786
802
  for (const prop in obj) {
787
803
  const objProp = obj[prop];
788
804
  if ((0, import_types.isFunction)(objProp)) {
@@ -808,6 +824,39 @@ var require_object = __commonJS({
808
824
  }
809
825
  return stringified;
810
826
  };
827
+ var MAX_DEPTH = 100;
828
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
829
+ if (depth > MAX_DEPTH) {
830
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
831
+ return "[MAX_DEPTH_EXCEEDED]";
832
+ }
833
+ for (const prop in obj) {
834
+ const currentPath = path ? `${path}.${prop}` : prop;
835
+ const objProp = obj[prop];
836
+ if ((0, import_types.isFunction)(objProp)) {
837
+ stringified[prop] = objProp.toString();
838
+ } else if ((0, import_types.isObject)(objProp)) {
839
+ stringified[prop] = {};
840
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
841
+ } else if ((0, import_types.isArray)(objProp)) {
842
+ stringified[prop] = [];
843
+ objProp.forEach((v, i) => {
844
+ const itemPath = `${currentPath}[${i}]`;
845
+ if ((0, import_types.isObject)(v)) {
846
+ stringified[prop][i] = {};
847
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
848
+ } else if ((0, import_types.isFunction)(v)) {
849
+ stringified[prop][i] = v.toString();
850
+ } else {
851
+ stringified[prop][i] = v;
852
+ }
853
+ });
854
+ } else {
855
+ stringified[prop] = objProp;
856
+ }
857
+ }
858
+ return stringified;
859
+ };
811
860
  var objectToString = (obj = {}, indent = 0) => {
812
861
  const spaces = " ".repeat(indent);
813
862
  let str = "{\n";
@@ -1199,6 +1248,25 @@ var require_object = __commonJS({
1199
1248
  }
1200
1249
  }
1201
1250
  };
1251
+ var isCyclic = (obj) => {
1252
+ const seenObjects = [];
1253
+ function detect(obj2) {
1254
+ if (obj2 && typeof obj2 === "object") {
1255
+ if (seenObjects.indexOf(obj2) !== -1) {
1256
+ return true;
1257
+ }
1258
+ seenObjects.push(obj2);
1259
+ for (const key in obj2) {
1260
+ if (Object.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
1261
+ console.log(obj2, "cycle at " + key);
1262
+ return true;
1263
+ }
1264
+ }
1265
+ }
1266
+ return false;
1267
+ }
1268
+ return detect(obj);
1269
+ };
1202
1270
  }
1203
1271
  });
1204
1272
 
@@ -1355,6 +1423,7 @@ var require_cookie = __commonJS({
1355
1423
  __export2(cookie_exports, {
1356
1424
  getCookie: () => getCookie,
1357
1425
  isMobile: () => isMobile,
1426
+ removeCookie: () => removeCookie,
1358
1427
  setCookie: () => setCookie
1359
1428
  });
1360
1429
  module2.exports = __toCommonJS2(cookie_exports);
@@ -1384,6 +1453,11 @@ var require_cookie = __commonJS({
1384
1453
  }
1385
1454
  return "";
1386
1455
  };
1456
+ var removeCookie = (cname) => {
1457
+ if ((0, import_types.isUndefined)(import_utils7.document) || (0, import_types.isUndefined)(import_utils7.document.cookie))
1458
+ return;
1459
+ import_utils7.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
1460
+ };
1387
1461
  }
1388
1462
  });
1389
1463
 
@@ -1423,10 +1497,13 @@ var require_tags = __commonJS({
1423
1497
  "title",
1424
1498
  "base",
1425
1499
  "meta",
1426
- "style"
1500
+ "style",
1501
+ "noscript",
1502
+ "script"
1427
1503
  ],
1428
1504
  body: [
1429
1505
  "string",
1506
+ "style",
1430
1507
  "fragment",
1431
1508
  "a",
1432
1509
  "abbr",
@@ -1579,6 +1656,7 @@ var require_component = __commonJS({
1579
1656
  var component_exports = {};
1580
1657
  __export2(component_exports, {
1581
1658
  addAdditionalExtend: () => addAdditionalExtend,
1659
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
1582
1660
  applyComponentFromContext: () => applyComponentFromContext,
1583
1661
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
1584
1662
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -1587,7 +1665,8 @@ var require_component = __commonJS({
1587
1665
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1588
1666
  getExtendsInElement: () => getExtendsInElement,
1589
1667
  hasVariantProp: () => hasVariantProp,
1590
- isVariant: () => isVariant
1668
+ isVariant: () => isVariant,
1669
+ setContentKey: () => setContentKey
1591
1670
  });
1592
1671
  module2.exports = __toCommonJS2(component_exports);
1593
1672
  var import__ = require_cjs2();
@@ -1613,20 +1692,28 @@ var require_component = __commonJS({
1613
1692
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
1614
1693
  return { ...element, extend };
1615
1694
  };
1695
+ var checkIfSugar = (element, parent, key) => {
1696
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
1697
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
1698
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
1699
+ };
1616
1700
  var extendizeByKey = (element, parent, key) => {
1617
1701
  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;
1702
+ const { tag, extend, childrenExtends } = element;
1703
+ const isSugar = checkIfSugar(element);
1620
1704
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1621
1705
  const isExtendKeyComponent = context && context.components[extendFromKey];
1622
1706
  if (element === isExtendKeyComponent)
1623
1707
  return element;
1624
- else if (!hasComponentAttrs || childProps) {
1625
- return {
1708
+ else if (isSugar) {
1709
+ const newElem = {
1626
1710
  extend: extendFromKey,
1627
1711
  tag,
1628
1712
  props: { ...element }
1629
1713
  };
1714
+ if (childrenExtends)
1715
+ newElem.childExtend = childrenExtends;
1716
+ return newElem;
1630
1717
  } else if (!extend || extend === true) {
1631
1718
  return {
1632
1719
  ...element,
@@ -1643,6 +1730,37 @@ var require_component = __commonJS({
1643
1730
  };
1644
1731
  }
1645
1732
  };
1733
+ function getCapitalCaseKeys(obj) {
1734
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
1735
+ }
1736
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
1737
+ const childElems = getCapitalCaseKeys(element.props);
1738
+ if (!childElems.length)
1739
+ return element;
1740
+ for (const i in childElems) {
1741
+ const childKey = childElems[i];
1742
+ const childElem = element[childKey];
1743
+ const newChild = element.props[childKey];
1744
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
1745
+ continue;
1746
+ if (!childElem)
1747
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
1748
+ else {
1749
+ const isSugar = checkIfSugar(childElem);
1750
+ if (!isSugar)
1751
+ continue;
1752
+ const inheritedChildElem = element[childKey].props;
1753
+ if ((0, import__.isObjectLike)(newChild)) {
1754
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
1755
+ } else if ((0, import__.isFunction)(newChild)) {
1756
+ element[childKey] = {
1757
+ extend: element[childKey],
1758
+ props: newChild
1759
+ };
1760
+ }
1761
+ }
1762
+ }
1763
+ };
1646
1764
  var applyKeyComponentAsExtend = (element, parent, key) => {
1647
1765
  return extendizeByKey(element, parent, key) || element;
1648
1766
  };
@@ -1718,6 +1836,17 @@ var require_component = __commonJS({
1718
1836
  traverse(obj);
1719
1837
  return result;
1720
1838
  };
1839
+ var setContentKey = (el, opts = {}) => {
1840
+ const { __ref: ref } = el;
1841
+ const contentElementKey = opts.contentElementKey;
1842
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
1843
+ ref.contentElementKey = contentElementKey || "content";
1844
+ } else
1845
+ ref.contentElementKey = "content";
1846
+ if (contentElementKey !== "content")
1847
+ opts.contentElementKey = "content";
1848
+ return ref.contentElementKey;
1849
+ };
1721
1850
  }
1722
1851
  });
1723
1852
 
@@ -2343,6 +2472,7 @@ var require_cjs3 = __commonJS({
2343
2472
  deepDiff: () => deepDiff,
2344
2473
  deepMerge: () => deepMerge2,
2345
2474
  deepStringify: () => deepStringify,
2475
+ deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
2346
2476
  detachFunctionsFromObject: () => detachFunctionsFromObject,
2347
2477
  detectInfiniteLoop: () => detectInfiniteLoop,
2348
2478
  diff: () => diff,
@@ -2376,7 +2506,8 @@ var require_cjs3 = __commonJS({
2376
2506
  var ENV2 = "development";
2377
2507
  var exec = (param, element, state, context) => {
2378
2508
  if ((0, import_types.isFunction)(param)) {
2379
- return param(
2509
+ return param.call(
2510
+ element,
2380
2511
  element,
2381
2512
  state || element.state,
2382
2513
  context || element.context
@@ -2493,6 +2624,11 @@ var require_cjs3 = __commonJS({
2493
2624
  return o;
2494
2625
  };
2495
2626
  var deepStringify = (obj, stringified = {}) => {
2627
+ var _a;
2628
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
2629
+ console.warn("Trying to clone element or state at", obj);
2630
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
2631
+ }
2496
2632
  for (const prop in obj) {
2497
2633
  const objProp = obj[prop];
2498
2634
  if ((0, import_types.isFunction)(objProp)) {
@@ -2518,6 +2654,39 @@ var require_cjs3 = __commonJS({
2518
2654
  }
2519
2655
  return stringified;
2520
2656
  };
2657
+ var MAX_DEPTH = 100;
2658
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
2659
+ if (depth > MAX_DEPTH) {
2660
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
2661
+ return "[MAX_DEPTH_EXCEEDED]";
2662
+ }
2663
+ for (const prop in obj) {
2664
+ const currentPath = path ? `${path}.${prop}` : prop;
2665
+ const objProp = obj[prop];
2666
+ if ((0, import_types.isFunction)(objProp)) {
2667
+ stringified[prop] = objProp.toString();
2668
+ } else if ((0, import_types.isObject)(objProp)) {
2669
+ stringified[prop] = {};
2670
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
2671
+ } else if ((0, import_types.isArray)(objProp)) {
2672
+ stringified[prop] = [];
2673
+ objProp.forEach((v, i) => {
2674
+ const itemPath = `${currentPath}[${i}]`;
2675
+ if ((0, import_types.isObject)(v)) {
2676
+ stringified[prop][i] = {};
2677
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
2678
+ } else if ((0, import_types.isFunction)(v)) {
2679
+ stringified[prop][i] = v.toString();
2680
+ } else {
2681
+ stringified[prop][i] = v;
2682
+ }
2683
+ });
2684
+ } else {
2685
+ stringified[prop] = objProp;
2686
+ }
2687
+ }
2688
+ return stringified;
2689
+ };
2521
2690
  var objectToString = (obj = {}, indent = 0) => {
2522
2691
  const spaces = " ".repeat(indent);
2523
2692
  let str = "{\n";
@@ -3059,6 +3228,7 @@ var require_cjs3 = __commonJS({
3059
3228
  __export22(cookie_exports, {
3060
3229
  getCookie: () => getCookie,
3061
3230
  isMobile: () => isMobile,
3231
+ removeCookie: () => removeCookie,
3062
3232
  setCookie: () => setCookie
3063
3233
  });
3064
3234
  module22.exports = __toCommonJS22(cookie_exports);
@@ -3088,6 +3258,11 @@ var require_cjs3 = __commonJS({
3088
3258
  }
3089
3259
  return "";
3090
3260
  };
3261
+ var removeCookie = (cname) => {
3262
+ if ((0, import_types.isUndefined)(import_utils32.document) || (0, import_types.isUndefined)(import_utils32.document.cookie))
3263
+ return;
3264
+ import_utils32.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
3265
+ };
3091
3266
  }
3092
3267
  });
3093
3268
  var require_tags2 = __commonJS2({
@@ -3125,10 +3300,13 @@ var require_cjs3 = __commonJS({
3125
3300
  "title",
3126
3301
  "base",
3127
3302
  "meta",
3128
- "style"
3303
+ "style",
3304
+ "noscript",
3305
+ "script"
3129
3306
  ],
3130
3307
  body: [
3131
3308
  "string",
3309
+ "style",
3132
3310
  "fragment",
3133
3311
  "a",
3134
3312
  "abbr",
@@ -3279,6 +3457,7 @@ var require_cjs3 = __commonJS({
3279
3457
  var component_exports = {};
3280
3458
  __export22(component_exports, {
3281
3459
  addAdditionalExtend: () => addAdditionalExtend,
3460
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
3282
3461
  applyComponentFromContext: () => applyComponentFromContext,
3283
3462
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
3284
3463
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -3287,7 +3466,8 @@ var require_cjs3 = __commonJS({
3287
3466
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
3288
3467
  getExtendsInElement: () => getExtendsInElement,
3289
3468
  hasVariantProp: () => hasVariantProp,
3290
- isVariant: () => isVariant
3469
+ isVariant: () => isVariant,
3470
+ setContentKey: () => setContentKey
3291
3471
  });
3292
3472
  module22.exports = __toCommonJS22(component_exports);
3293
3473
  var import__ = require_cjs4();
@@ -3313,20 +3493,28 @@ var require_cjs3 = __commonJS({
3313
3493
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
3314
3494
  return { ...element, extend };
3315
3495
  };
3496
+ var checkIfSugar = (element, parent, key) => {
3497
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
3498
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
3499
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
3500
+ };
3316
3501
  var extendizeByKey = (element, parent, key) => {
3317
3502
  const { context } = parent;
3318
- const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
3319
- const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
3503
+ const { tag, extend, childrenExtends } = element;
3504
+ const isSugar = checkIfSugar(element);
3320
3505
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
3321
3506
  const isExtendKeyComponent = context && context.components[extendFromKey];
3322
3507
  if (element === isExtendKeyComponent)
3323
3508
  return element;
3324
- else if (!hasComponentAttrs || childProps) {
3325
- return {
3509
+ else if (isSugar) {
3510
+ const newElem = {
3326
3511
  extend: extendFromKey,
3327
3512
  tag,
3328
3513
  props: { ...element }
3329
3514
  };
3515
+ if (childrenExtends)
3516
+ newElem.childExtend = childrenExtends;
3517
+ return newElem;
3330
3518
  } else if (!extend || extend === true) {
3331
3519
  return {
3332
3520
  ...element,
@@ -3343,6 +3531,37 @@ var require_cjs3 = __commonJS({
3343
3531
  };
3344
3532
  }
3345
3533
  };
3534
+ function getCapitalCaseKeys(obj) {
3535
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
3536
+ }
3537
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
3538
+ const childElems = getCapitalCaseKeys(element.props);
3539
+ if (!childElems.length)
3540
+ return element;
3541
+ for (const i in childElems) {
3542
+ const childKey = childElems[i];
3543
+ const childElem = element[childKey];
3544
+ const newChild = element.props[childKey];
3545
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
3546
+ continue;
3547
+ if (!childElem)
3548
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
3549
+ else {
3550
+ const isSugar = checkIfSugar(childElem);
3551
+ if (!isSugar)
3552
+ continue;
3553
+ const inheritedChildElem = element[childKey].props;
3554
+ if ((0, import__.isObjectLike)(newChild)) {
3555
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
3556
+ } else if ((0, import__.isFunction)(newChild)) {
3557
+ element[childKey] = {
3558
+ extend: element[childKey],
3559
+ props: newChild
3560
+ };
3561
+ }
3562
+ }
3563
+ }
3564
+ };
3346
3565
  var applyKeyComponentAsExtend = (element, parent, key) => {
3347
3566
  return extendizeByKey(element, parent, key) || element;
3348
3567
  };
@@ -3418,6 +3637,17 @@ var require_cjs3 = __commonJS({
3418
3637
  traverse(obj);
3419
3638
  return result;
3420
3639
  };
3640
+ var setContentKey = (el, opts = {}) => {
3641
+ const { __ref: ref } = el;
3642
+ const contentElementKey = opts.contentElementKey;
3643
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
3644
+ ref.contentElementKey = contentElementKey || "content";
3645
+ } else
3646
+ ref.contentElementKey = "content";
3647
+ if (contentElementKey !== "content")
3648
+ opts.contentElementKey = "content";
3649
+ return ref.contentElementKey;
3650
+ };
3421
3651
  }
3422
3652
  });
3423
3653
  var require_cjs4 = __commonJS2({