@symbo.ls/scratch 2.11.442 → 2.11.446

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.
@@ -616,6 +616,7 @@ var require_cjs = __commonJS({
616
616
  deepDiff: () => deepDiff,
617
617
  deepMerge: () => deepMerge2,
618
618
  deepStringify: () => deepStringify,
619
+ deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
619
620
  detachFunctionsFromObject: () => detachFunctionsFromObject,
620
621
  detectInfiniteLoop: () => detectInfiniteLoop,
621
622
  diff: () => diff,
@@ -649,7 +650,8 @@ var require_cjs = __commonJS({
649
650
  var ENV = "development";
650
651
  var exec = (param, element, state, context) => {
651
652
  if ((0, import_types.isFunction)(param)) {
652
- return param(
653
+ return param.call(
654
+ element,
653
655
  element,
654
656
  state || element.state,
655
657
  context || element.context
@@ -766,6 +768,11 @@ var require_cjs = __commonJS({
766
768
  return o;
767
769
  };
768
770
  var deepStringify = (obj, stringified = {}) => {
771
+ var _a;
772
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
773
+ console.warn("Trying to clone element or state at", obj);
774
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
775
+ }
769
776
  for (const prop in obj) {
770
777
  const objProp = obj[prop];
771
778
  if ((0, import_types.isFunction)(objProp)) {
@@ -791,6 +798,39 @@ var require_cjs = __commonJS({
791
798
  }
792
799
  return stringified;
793
800
  };
801
+ var MAX_DEPTH = 100;
802
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
803
+ if (depth > MAX_DEPTH) {
804
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
805
+ return "[MAX_DEPTH_EXCEEDED]";
806
+ }
807
+ for (const prop in obj) {
808
+ const currentPath = path ? `${path}.${prop}` : prop;
809
+ const objProp = obj[prop];
810
+ if ((0, import_types.isFunction)(objProp)) {
811
+ stringified[prop] = objProp.toString();
812
+ } else if ((0, import_types.isObject)(objProp)) {
813
+ stringified[prop] = {};
814
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
815
+ } else if ((0, import_types.isArray)(objProp)) {
816
+ stringified[prop] = [];
817
+ objProp.forEach((v, i) => {
818
+ const itemPath = `${currentPath}[${i}]`;
819
+ if ((0, import_types.isObject)(v)) {
820
+ stringified[prop][i] = {};
821
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
822
+ } else if ((0, import_types.isFunction)(v)) {
823
+ stringified[prop][i] = v.toString();
824
+ } else {
825
+ stringified[prop][i] = v;
826
+ }
827
+ });
828
+ } else {
829
+ stringified[prop] = objProp;
830
+ }
831
+ }
832
+ return stringified;
833
+ };
794
834
  var objectToString = (obj = {}, indent = 0) => {
795
835
  const spaces = " ".repeat(indent);
796
836
  let str = "{\n";
@@ -1332,6 +1372,7 @@ var require_cjs = __commonJS({
1332
1372
  __export22(cookie_exports, {
1333
1373
  getCookie: () => getCookie,
1334
1374
  isMobile: () => isMobile,
1375
+ removeCookie: () => removeCookie,
1335
1376
  setCookie: () => setCookie
1336
1377
  });
1337
1378
  module22.exports = __toCommonJS22(cookie_exports);
@@ -1361,6 +1402,11 @@ var require_cjs = __commonJS({
1361
1402
  }
1362
1403
  return "";
1363
1404
  };
1405
+ var removeCookie = (cname) => {
1406
+ if ((0, import_types.isUndefined)(import_utils32.document) || (0, import_types.isUndefined)(import_utils32.document.cookie))
1407
+ return;
1408
+ import_utils32.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
1409
+ };
1364
1410
  }
1365
1411
  });
1366
1412
  var require_tags2 = __commonJS2({
@@ -1398,10 +1444,13 @@ var require_cjs = __commonJS({
1398
1444
  "title",
1399
1445
  "base",
1400
1446
  "meta",
1401
- "style"
1447
+ "style",
1448
+ "noscript",
1449
+ "script"
1402
1450
  ],
1403
1451
  body: [
1404
1452
  "string",
1453
+ "style",
1405
1454
  "fragment",
1406
1455
  "a",
1407
1456
  "abbr",
@@ -1552,6 +1601,7 @@ var require_cjs = __commonJS({
1552
1601
  var component_exports = {};
1553
1602
  __export22(component_exports, {
1554
1603
  addAdditionalExtend: () => addAdditionalExtend,
1604
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
1555
1605
  applyComponentFromContext: () => applyComponentFromContext,
1556
1606
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
1557
1607
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -1560,7 +1610,8 @@ var require_cjs = __commonJS({
1560
1610
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1561
1611
  getExtendsInElement: () => getExtendsInElement,
1562
1612
  hasVariantProp: () => hasVariantProp,
1563
- isVariant: () => isVariant
1613
+ isVariant: () => isVariant,
1614
+ setContentKey: () => setContentKey
1564
1615
  });
1565
1616
  module22.exports = __toCommonJS22(component_exports);
1566
1617
  var import__ = require_cjs4();
@@ -1586,20 +1637,28 @@ var require_cjs = __commonJS({
1586
1637
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
1587
1638
  return { ...element, extend };
1588
1639
  };
1640
+ var checkIfSugar = (element, parent, key) => {
1641
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
1642
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
1643
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
1644
+ };
1589
1645
  var extendizeByKey = (element, parent, key) => {
1590
1646
  const { context } = parent;
1591
- const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
1592
- const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
1647
+ const { tag, extend, childrenExtends } = element;
1648
+ const isSugar = checkIfSugar(element);
1593
1649
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1594
1650
  const isExtendKeyComponent = context && context.components[extendFromKey];
1595
1651
  if (element === isExtendKeyComponent)
1596
1652
  return element;
1597
- else if (!hasComponentAttrs || childProps) {
1598
- return {
1653
+ else if (isSugar) {
1654
+ const newElem = {
1599
1655
  extend: extendFromKey,
1600
1656
  tag,
1601
1657
  props: { ...element }
1602
1658
  };
1659
+ if (childrenExtends)
1660
+ newElem.childExtend = childrenExtends;
1661
+ return newElem;
1603
1662
  } else if (!extend || extend === true) {
1604
1663
  return {
1605
1664
  ...element,
@@ -1616,6 +1675,37 @@ var require_cjs = __commonJS({
1616
1675
  };
1617
1676
  }
1618
1677
  };
1678
+ function getCapitalCaseKeys(obj) {
1679
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
1680
+ }
1681
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
1682
+ const childElems = getCapitalCaseKeys(element.props);
1683
+ if (!childElems.length)
1684
+ return element;
1685
+ for (const i in childElems) {
1686
+ const childKey = childElems[i];
1687
+ const childElem = element[childKey];
1688
+ const newChild = element.props[childKey];
1689
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
1690
+ continue;
1691
+ if (!childElem)
1692
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
1693
+ else {
1694
+ const isSugar = checkIfSugar(childElem);
1695
+ if (!isSugar)
1696
+ continue;
1697
+ const inheritedChildElem = element[childKey].props;
1698
+ if ((0, import__.isObjectLike)(newChild)) {
1699
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
1700
+ } else if ((0, import__.isFunction)(newChild)) {
1701
+ element[childKey] = {
1702
+ extend: element[childKey],
1703
+ props: newChild
1704
+ };
1705
+ }
1706
+ }
1707
+ }
1708
+ };
1619
1709
  var applyKeyComponentAsExtend = (element, parent, key) => {
1620
1710
  return extendizeByKey(element, parent, key) || element;
1621
1711
  };
@@ -1691,6 +1781,17 @@ var require_cjs = __commonJS({
1691
1781
  traverse(obj);
1692
1782
  return result;
1693
1783
  };
1784
+ var setContentKey = (el, opts = {}) => {
1785
+ const { __ref: ref } = el;
1786
+ const contentElementKey = opts.contentElementKey;
1787
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
1788
+ ref.contentElementKey = contentElementKey || "content";
1789
+ } else
1790
+ ref.contentElementKey = "content";
1791
+ if (contentElementKey !== "content")
1792
+ opts.contentElementKey = "content";
1793
+ return ref.contentElementKey;
1794
+ };
1694
1795
  }
1695
1796
  });
1696
1797
  var require_cjs4 = __commonJS2({
@@ -2505,6 +2606,7 @@ var require_object = __commonJS({
2505
2606
  deepDiff: () => deepDiff,
2506
2607
  deepMerge: () => deepMerge2,
2507
2608
  deepStringify: () => deepStringify,
2609
+ deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
2508
2610
  detachFunctionsFromObject: () => detachFunctionsFromObject,
2509
2611
  detectInfiniteLoop: () => detectInfiniteLoop,
2510
2612
  diff: () => diff,
@@ -2538,7 +2640,8 @@ var require_object = __commonJS({
2538
2640
  var ENV = "development";
2539
2641
  var exec = (param, element, state, context) => {
2540
2642
  if ((0, import_types.isFunction)(param)) {
2541
- return param(
2643
+ return param.call(
2644
+ element,
2542
2645
  element,
2543
2646
  state || element.state,
2544
2647
  context || element.context
@@ -2655,6 +2758,11 @@ var require_object = __commonJS({
2655
2758
  return o;
2656
2759
  };
2657
2760
  var deepStringify = (obj, stringified = {}) => {
2761
+ var _a;
2762
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
2763
+ console.warn("Trying to clone element or state at", obj);
2764
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
2765
+ }
2658
2766
  for (const prop in obj) {
2659
2767
  const objProp = obj[prop];
2660
2768
  if ((0, import_types.isFunction)(objProp)) {
@@ -2680,6 +2788,39 @@ var require_object = __commonJS({
2680
2788
  }
2681
2789
  return stringified;
2682
2790
  };
2791
+ var MAX_DEPTH = 100;
2792
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
2793
+ if (depth > MAX_DEPTH) {
2794
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
2795
+ return "[MAX_DEPTH_EXCEEDED]";
2796
+ }
2797
+ for (const prop in obj) {
2798
+ const currentPath = path ? `${path}.${prop}` : prop;
2799
+ const objProp = obj[prop];
2800
+ if ((0, import_types.isFunction)(objProp)) {
2801
+ stringified[prop] = objProp.toString();
2802
+ } else if ((0, import_types.isObject)(objProp)) {
2803
+ stringified[prop] = {};
2804
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
2805
+ } else if ((0, import_types.isArray)(objProp)) {
2806
+ stringified[prop] = [];
2807
+ objProp.forEach((v, i) => {
2808
+ const itemPath = `${currentPath}[${i}]`;
2809
+ if ((0, import_types.isObject)(v)) {
2810
+ stringified[prop][i] = {};
2811
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
2812
+ } else if ((0, import_types.isFunction)(v)) {
2813
+ stringified[prop][i] = v.toString();
2814
+ } else {
2815
+ stringified[prop][i] = v;
2816
+ }
2817
+ });
2818
+ } else {
2819
+ stringified[prop] = objProp;
2820
+ }
2821
+ }
2822
+ return stringified;
2823
+ };
2683
2824
  var objectToString = (obj = {}, indent = 0) => {
2684
2825
  const spaces = " ".repeat(indent);
2685
2826
  let str = "{\n";
@@ -3227,6 +3368,7 @@ var require_cookie = __commonJS({
3227
3368
  __export2(cookie_exports, {
3228
3369
  getCookie: () => getCookie,
3229
3370
  isMobile: () => isMobile,
3371
+ removeCookie: () => removeCookie,
3230
3372
  setCookie: () => setCookie
3231
3373
  });
3232
3374
  module2.exports = __toCommonJS2(cookie_exports);
@@ -3256,6 +3398,11 @@ var require_cookie = __commonJS({
3256
3398
  }
3257
3399
  return "";
3258
3400
  };
3401
+ var removeCookie = (cname) => {
3402
+ if ((0, import_types.isUndefined)(import_utils10.document) || (0, import_types.isUndefined)(import_utils10.document.cookie))
3403
+ return;
3404
+ import_utils10.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
3405
+ };
3259
3406
  }
3260
3407
  });
3261
3408
 
@@ -3295,10 +3442,13 @@ var require_tags = __commonJS({
3295
3442
  "title",
3296
3443
  "base",
3297
3444
  "meta",
3298
- "style"
3445
+ "style",
3446
+ "noscript",
3447
+ "script"
3299
3448
  ],
3300
3449
  body: [
3301
3450
  "string",
3451
+ "style",
3302
3452
  "fragment",
3303
3453
  "a",
3304
3454
  "abbr",
@@ -3451,6 +3601,7 @@ var require_component = __commonJS({
3451
3601
  var component_exports = {};
3452
3602
  __export2(component_exports, {
3453
3603
  addAdditionalExtend: () => addAdditionalExtend,
3604
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
3454
3605
  applyComponentFromContext: () => applyComponentFromContext,
3455
3606
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
3456
3607
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -3459,7 +3610,8 @@ var require_component = __commonJS({
3459
3610
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
3460
3611
  getExtendsInElement: () => getExtendsInElement,
3461
3612
  hasVariantProp: () => hasVariantProp,
3462
- isVariant: () => isVariant
3613
+ isVariant: () => isVariant,
3614
+ setContentKey: () => setContentKey
3463
3615
  });
3464
3616
  module2.exports = __toCommonJS2(component_exports);
3465
3617
  var import__ = require_cjs2();
@@ -3485,20 +3637,28 @@ var require_component = __commonJS({
3485
3637
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
3486
3638
  return { ...element, extend };
3487
3639
  };
3640
+ var checkIfSugar = (element, parent, key) => {
3641
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
3642
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
3643
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
3644
+ };
3488
3645
  var extendizeByKey = (element, parent, key) => {
3489
3646
  const { context } = parent;
3490
- const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
3491
- const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
3647
+ const { tag, extend, childrenExtends } = element;
3648
+ const isSugar = checkIfSugar(element);
3492
3649
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
3493
3650
  const isExtendKeyComponent = context && context.components[extendFromKey];
3494
3651
  if (element === isExtendKeyComponent)
3495
3652
  return element;
3496
- else if (!hasComponentAttrs || childProps) {
3497
- return {
3653
+ else if (isSugar) {
3654
+ const newElem = {
3498
3655
  extend: extendFromKey,
3499
3656
  tag,
3500
3657
  props: { ...element }
3501
3658
  };
3659
+ if (childrenExtends)
3660
+ newElem.childExtend = childrenExtends;
3661
+ return newElem;
3502
3662
  } else if (!extend || extend === true) {
3503
3663
  return {
3504
3664
  ...element,
@@ -3515,6 +3675,37 @@ var require_component = __commonJS({
3515
3675
  };
3516
3676
  }
3517
3677
  };
3678
+ function getCapitalCaseKeys(obj) {
3679
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
3680
+ }
3681
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
3682
+ const childElems = getCapitalCaseKeys(element.props);
3683
+ if (!childElems.length)
3684
+ return element;
3685
+ for (const i in childElems) {
3686
+ const childKey = childElems[i];
3687
+ const childElem = element[childKey];
3688
+ const newChild = element.props[childKey];
3689
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
3690
+ continue;
3691
+ if (!childElem)
3692
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
3693
+ else {
3694
+ const isSugar = checkIfSugar(childElem);
3695
+ if (!isSugar)
3696
+ continue;
3697
+ const inheritedChildElem = element[childKey].props;
3698
+ if ((0, import__.isObjectLike)(newChild)) {
3699
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
3700
+ } else if ((0, import__.isFunction)(newChild)) {
3701
+ element[childKey] = {
3702
+ extend: element[childKey],
3703
+ props: newChild
3704
+ };
3705
+ }
3706
+ }
3707
+ }
3708
+ };
3518
3709
  var applyKeyComponentAsExtend = (element, parent, key) => {
3519
3710
  return extendizeByKey(element, parent, key) || element;
3520
3711
  };
@@ -3590,6 +3781,17 @@ var require_component = __commonJS({
3590
3781
  traverse(obj);
3591
3782
  return result;
3592
3783
  };
3784
+ var setContentKey = (el, opts = {}) => {
3785
+ const { __ref: ref } = el;
3786
+ const contentElementKey = opts.contentElementKey;
3787
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
3788
+ ref.contentElementKey = contentElementKey || "content";
3789
+ } else
3790
+ ref.contentElementKey = "content";
3791
+ if (contentElementKey !== "content")
3792
+ opts.contentElementKey = "content";
3793
+ return ref.contentElementKey;
3794
+ };
3593
3795
  }
3594
3796
  });
3595
3797