@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.
@@ -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,
@@ -666,7 +667,8 @@ var require_object = __commonJS({
666
667
  var ENV = "development";
667
668
  var exec = (param, element, state, context) => {
668
669
  if ((0, import_types.isFunction)(param)) {
669
- return param(
670
+ return param.call(
671
+ element,
670
672
  element,
671
673
  state || element.state,
672
674
  context || element.context
@@ -783,6 +785,11 @@ var require_object = __commonJS({
783
785
  return o;
784
786
  };
785
787
  var deepStringify = (obj, stringified = {}) => {
788
+ var _a;
789
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
790
+ console.warn("Trying to clone element or state at", obj);
791
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
792
+ }
786
793
  for (const prop in obj) {
787
794
  const objProp = obj[prop];
788
795
  if ((0, import_types.isFunction)(objProp)) {
@@ -808,6 +815,39 @@ var require_object = __commonJS({
808
815
  }
809
816
  return stringified;
810
817
  };
818
+ var MAX_DEPTH = 100;
819
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
820
+ if (depth > MAX_DEPTH) {
821
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
822
+ return "[MAX_DEPTH_EXCEEDED]";
823
+ }
824
+ for (const prop in obj) {
825
+ const currentPath = path ? `${path}.${prop}` : prop;
826
+ const objProp = obj[prop];
827
+ if ((0, import_types.isFunction)(objProp)) {
828
+ stringified[prop] = objProp.toString();
829
+ } else if ((0, import_types.isObject)(objProp)) {
830
+ stringified[prop] = {};
831
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
832
+ } else if ((0, import_types.isArray)(objProp)) {
833
+ stringified[prop] = [];
834
+ objProp.forEach((v, i) => {
835
+ const itemPath = `${currentPath}[${i}]`;
836
+ if ((0, import_types.isObject)(v)) {
837
+ stringified[prop][i] = {};
838
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
839
+ } else if ((0, import_types.isFunction)(v)) {
840
+ stringified[prop][i] = v.toString();
841
+ } else {
842
+ stringified[prop][i] = v;
843
+ }
844
+ });
845
+ } else {
846
+ stringified[prop] = objProp;
847
+ }
848
+ }
849
+ return stringified;
850
+ };
811
851
  var objectToString = (obj = {}, indent = 0) => {
812
852
  const spaces = " ".repeat(indent);
813
853
  let str = "{\n";
@@ -1355,6 +1395,7 @@ var require_cookie = __commonJS({
1355
1395
  __export2(cookie_exports, {
1356
1396
  getCookie: () => getCookie,
1357
1397
  isMobile: () => isMobile,
1398
+ removeCookie: () => removeCookie,
1358
1399
  setCookie: () => setCookie
1359
1400
  });
1360
1401
  module2.exports = __toCommonJS2(cookie_exports);
@@ -1384,6 +1425,11 @@ var require_cookie = __commonJS({
1384
1425
  }
1385
1426
  return "";
1386
1427
  };
1428
+ var removeCookie = (cname) => {
1429
+ if ((0, import_types.isUndefined)(import_utils8.document) || (0, import_types.isUndefined)(import_utils8.document.cookie))
1430
+ return;
1431
+ import_utils8.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
1432
+ };
1387
1433
  }
1388
1434
  });
1389
1435
 
@@ -1423,10 +1469,13 @@ var require_tags = __commonJS({
1423
1469
  "title",
1424
1470
  "base",
1425
1471
  "meta",
1426
- "style"
1472
+ "style",
1473
+ "noscript",
1474
+ "script"
1427
1475
  ],
1428
1476
  body: [
1429
1477
  "string",
1478
+ "style",
1430
1479
  "fragment",
1431
1480
  "a",
1432
1481
  "abbr",
@@ -1579,6 +1628,7 @@ var require_component = __commonJS({
1579
1628
  var component_exports = {};
1580
1629
  __export2(component_exports, {
1581
1630
  addAdditionalExtend: () => addAdditionalExtend,
1631
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
1582
1632
  applyComponentFromContext: () => applyComponentFromContext,
1583
1633
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
1584
1634
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -1587,7 +1637,8 @@ var require_component = __commonJS({
1587
1637
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1588
1638
  getExtendsInElement: () => getExtendsInElement,
1589
1639
  hasVariantProp: () => hasVariantProp,
1590
- isVariant: () => isVariant
1640
+ isVariant: () => isVariant,
1641
+ setContentKey: () => setContentKey
1591
1642
  });
1592
1643
  module2.exports = __toCommonJS2(component_exports);
1593
1644
  var import__ = require_cjs2();
@@ -1613,20 +1664,28 @@ var require_component = __commonJS({
1613
1664
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
1614
1665
  return { ...element, extend };
1615
1666
  };
1667
+ var checkIfSugar = (element, parent, key) => {
1668
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
1669
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
1670
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
1671
+ };
1616
1672
  var extendizeByKey = (element, parent, key) => {
1617
1673
  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;
1674
+ const { tag, extend, childrenExtends } = element;
1675
+ const isSugar = checkIfSugar(element);
1620
1676
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1621
1677
  const isExtendKeyComponent = context && context.components[extendFromKey];
1622
1678
  if (element === isExtendKeyComponent)
1623
1679
  return element;
1624
- else if (!hasComponentAttrs || childProps) {
1625
- return {
1680
+ else if (isSugar) {
1681
+ const newElem = {
1626
1682
  extend: extendFromKey,
1627
1683
  tag,
1628
1684
  props: { ...element }
1629
1685
  };
1686
+ if (childrenExtends)
1687
+ newElem.childExtend = childrenExtends;
1688
+ return newElem;
1630
1689
  } else if (!extend || extend === true) {
1631
1690
  return {
1632
1691
  ...element,
@@ -1643,6 +1702,37 @@ var require_component = __commonJS({
1643
1702
  };
1644
1703
  }
1645
1704
  };
1705
+ function getCapitalCaseKeys(obj) {
1706
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
1707
+ }
1708
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
1709
+ const childElems = getCapitalCaseKeys(element.props);
1710
+ if (!childElems.length)
1711
+ return element;
1712
+ for (const i in childElems) {
1713
+ const childKey = childElems[i];
1714
+ const childElem = element[childKey];
1715
+ const newChild = element.props[childKey];
1716
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
1717
+ continue;
1718
+ if (!childElem)
1719
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
1720
+ else {
1721
+ const isSugar = checkIfSugar(childElem);
1722
+ if (!isSugar)
1723
+ continue;
1724
+ const inheritedChildElem = element[childKey].props;
1725
+ if ((0, import__.isObjectLike)(newChild)) {
1726
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
1727
+ } else if ((0, import__.isFunction)(newChild)) {
1728
+ element[childKey] = {
1729
+ extend: element[childKey],
1730
+ props: newChild
1731
+ };
1732
+ }
1733
+ }
1734
+ }
1735
+ };
1646
1736
  var applyKeyComponentAsExtend = (element, parent, key) => {
1647
1737
  return extendizeByKey(element, parent, key) || element;
1648
1738
  };
@@ -1718,6 +1808,17 @@ var require_component = __commonJS({
1718
1808
  traverse(obj);
1719
1809
  return result;
1720
1810
  };
1811
+ var setContentKey = (el, opts = {}) => {
1812
+ const { __ref: ref } = el;
1813
+ const contentElementKey = opts.contentElementKey;
1814
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
1815
+ ref.contentElementKey = contentElementKey || "content";
1816
+ } else
1817
+ ref.contentElementKey = "content";
1818
+ if (contentElementKey !== "content")
1819
+ opts.contentElementKey = "content";
1820
+ return ref.contentElementKey;
1821
+ };
1721
1822
  }
1722
1823
  });
1723
1824
 
@@ -2343,6 +2444,7 @@ var require_cjs3 = __commonJS({
2343
2444
  deepDiff: () => deepDiff,
2344
2445
  deepMerge: () => deepMerge2,
2345
2446
  deepStringify: () => deepStringify,
2447
+ deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
2346
2448
  detachFunctionsFromObject: () => detachFunctionsFromObject,
2347
2449
  detectInfiniteLoop: () => detectInfiniteLoop,
2348
2450
  diff: () => diff,
@@ -2376,7 +2478,8 @@ var require_cjs3 = __commonJS({
2376
2478
  var ENV = "development";
2377
2479
  var exec = (param, element, state, context) => {
2378
2480
  if ((0, import_types.isFunction)(param)) {
2379
- return param(
2481
+ return param.call(
2482
+ element,
2380
2483
  element,
2381
2484
  state || element.state,
2382
2485
  context || element.context
@@ -2493,6 +2596,11 @@ var require_cjs3 = __commonJS({
2493
2596
  return o;
2494
2597
  };
2495
2598
  var deepStringify = (obj, stringified = {}) => {
2599
+ var _a;
2600
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
2601
+ console.warn("Trying to clone element or state at", obj);
2602
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
2603
+ }
2496
2604
  for (const prop in obj) {
2497
2605
  const objProp = obj[prop];
2498
2606
  if ((0, import_types.isFunction)(objProp)) {
@@ -2518,6 +2626,39 @@ var require_cjs3 = __commonJS({
2518
2626
  }
2519
2627
  return stringified;
2520
2628
  };
2629
+ var MAX_DEPTH = 100;
2630
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
2631
+ if (depth > MAX_DEPTH) {
2632
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
2633
+ return "[MAX_DEPTH_EXCEEDED]";
2634
+ }
2635
+ for (const prop in obj) {
2636
+ const currentPath = path ? `${path}.${prop}` : prop;
2637
+ const objProp = obj[prop];
2638
+ if ((0, import_types.isFunction)(objProp)) {
2639
+ stringified[prop] = objProp.toString();
2640
+ } else if ((0, import_types.isObject)(objProp)) {
2641
+ stringified[prop] = {};
2642
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
2643
+ } else if ((0, import_types.isArray)(objProp)) {
2644
+ stringified[prop] = [];
2645
+ objProp.forEach((v, i) => {
2646
+ const itemPath = `${currentPath}[${i}]`;
2647
+ if ((0, import_types.isObject)(v)) {
2648
+ stringified[prop][i] = {};
2649
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
2650
+ } else if ((0, import_types.isFunction)(v)) {
2651
+ stringified[prop][i] = v.toString();
2652
+ } else {
2653
+ stringified[prop][i] = v;
2654
+ }
2655
+ });
2656
+ } else {
2657
+ stringified[prop] = objProp;
2658
+ }
2659
+ }
2660
+ return stringified;
2661
+ };
2521
2662
  var objectToString = (obj = {}, indent = 0) => {
2522
2663
  const spaces = " ".repeat(indent);
2523
2664
  let str = "{\n";
@@ -3059,6 +3200,7 @@ var require_cjs3 = __commonJS({
3059
3200
  __export22(cookie_exports, {
3060
3201
  getCookie: () => getCookie,
3061
3202
  isMobile: () => isMobile,
3203
+ removeCookie: () => removeCookie,
3062
3204
  setCookie: () => setCookie
3063
3205
  });
3064
3206
  module22.exports = __toCommonJS22(cookie_exports);
@@ -3088,6 +3230,11 @@ var require_cjs3 = __commonJS({
3088
3230
  }
3089
3231
  return "";
3090
3232
  };
3233
+ var removeCookie = (cname) => {
3234
+ if ((0, import_types.isUndefined)(import_utils32.document) || (0, import_types.isUndefined)(import_utils32.document.cookie))
3235
+ return;
3236
+ import_utils32.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
3237
+ };
3091
3238
  }
3092
3239
  });
3093
3240
  var require_tags2 = __commonJS2({
@@ -3125,10 +3272,13 @@ var require_cjs3 = __commonJS({
3125
3272
  "title",
3126
3273
  "base",
3127
3274
  "meta",
3128
- "style"
3275
+ "style",
3276
+ "noscript",
3277
+ "script"
3129
3278
  ],
3130
3279
  body: [
3131
3280
  "string",
3281
+ "style",
3132
3282
  "fragment",
3133
3283
  "a",
3134
3284
  "abbr",
@@ -3279,6 +3429,7 @@ var require_cjs3 = __commonJS({
3279
3429
  var component_exports = {};
3280
3430
  __export22(component_exports, {
3281
3431
  addAdditionalExtend: () => addAdditionalExtend,
3432
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
3282
3433
  applyComponentFromContext: () => applyComponentFromContext,
3283
3434
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
3284
3435
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -3287,7 +3438,8 @@ var require_cjs3 = __commonJS({
3287
3438
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
3288
3439
  getExtendsInElement: () => getExtendsInElement,
3289
3440
  hasVariantProp: () => hasVariantProp,
3290
- isVariant: () => isVariant
3441
+ isVariant: () => isVariant,
3442
+ setContentKey: () => setContentKey
3291
3443
  });
3292
3444
  module22.exports = __toCommonJS22(component_exports);
3293
3445
  var import__ = require_cjs4();
@@ -3313,20 +3465,28 @@ var require_cjs3 = __commonJS({
3313
3465
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
3314
3466
  return { ...element, extend };
3315
3467
  };
3468
+ var checkIfSugar = (element, parent, key) => {
3469
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
3470
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
3471
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
3472
+ };
3316
3473
  var extendizeByKey = (element, parent, key) => {
3317
3474
  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;
3475
+ const { tag, extend, childrenExtends } = element;
3476
+ const isSugar = checkIfSugar(element);
3320
3477
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
3321
3478
  const isExtendKeyComponent = context && context.components[extendFromKey];
3322
3479
  if (element === isExtendKeyComponent)
3323
3480
  return element;
3324
- else if (!hasComponentAttrs || childProps) {
3325
- return {
3481
+ else if (isSugar) {
3482
+ const newElem = {
3326
3483
  extend: extendFromKey,
3327
3484
  tag,
3328
3485
  props: { ...element }
3329
3486
  };
3487
+ if (childrenExtends)
3488
+ newElem.childExtend = childrenExtends;
3489
+ return newElem;
3330
3490
  } else if (!extend || extend === true) {
3331
3491
  return {
3332
3492
  ...element,
@@ -3343,6 +3503,37 @@ var require_cjs3 = __commonJS({
3343
3503
  };
3344
3504
  }
3345
3505
  };
3506
+ function getCapitalCaseKeys(obj) {
3507
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
3508
+ }
3509
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
3510
+ const childElems = getCapitalCaseKeys(element.props);
3511
+ if (!childElems.length)
3512
+ return element;
3513
+ for (const i in childElems) {
3514
+ const childKey = childElems[i];
3515
+ const childElem = element[childKey];
3516
+ const newChild = element.props[childKey];
3517
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
3518
+ continue;
3519
+ if (!childElem)
3520
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
3521
+ else {
3522
+ const isSugar = checkIfSugar(childElem);
3523
+ if (!isSugar)
3524
+ continue;
3525
+ const inheritedChildElem = element[childKey].props;
3526
+ if ((0, import__.isObjectLike)(newChild)) {
3527
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
3528
+ } else if ((0, import__.isFunction)(newChild)) {
3529
+ element[childKey] = {
3530
+ extend: element[childKey],
3531
+ props: newChild
3532
+ };
3533
+ }
3534
+ }
3535
+ }
3536
+ };
3346
3537
  var applyKeyComponentAsExtend = (element, parent, key) => {
3347
3538
  return extendizeByKey(element, parent, key) || element;
3348
3539
  };
@@ -3418,6 +3609,17 @@ var require_cjs3 = __commonJS({
3418
3609
  traverse(obj);
3419
3610
  return result;
3420
3611
  };
3612
+ var setContentKey = (el, opts = {}) => {
3613
+ const { __ref: ref } = el;
3614
+ const contentElementKey = opts.contentElementKey;
3615
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
3616
+ ref.contentElementKey = contentElementKey || "content";
3617
+ } else
3618
+ ref.contentElementKey = "content";
3619
+ if (contentElementKey !== "content")
3620
+ opts.contentElementKey = "content";
3621
+ return ref.contentElementKey;
3622
+ };
3421
3623
  }
3422
3624
  });
3423
3625
  var require_cjs4 = __commonJS2({