@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.
@@ -597,6 +597,7 @@ var require_object = __commonJS({
597
597
  deepDiff: () => deepDiff,
598
598
  deepMerge: () => deepMerge3,
599
599
  deepStringify: () => deepStringify,
600
+ deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
600
601
  detachFunctionsFromObject: () => detachFunctionsFromObject,
601
602
  detectInfiniteLoop: () => detectInfiniteLoop,
602
603
  diff: () => diff,
@@ -605,6 +606,7 @@ var require_object = __commonJS({
605
606
  exec: () => exec,
606
607
  flattenRecursive: () => flattenRecursive,
607
608
  hasOwnProperty: () => hasOwnProperty,
609
+ isCyclic: () => isCyclic,
608
610
  isEmpty: () => isEmpty,
609
611
  isEmptyObject: () => isEmptyObject,
610
612
  isEqualDeep: () => isEqualDeep,
@@ -630,7 +632,8 @@ var require_object = __commonJS({
630
632
  var ENV = "development";
631
633
  var exec = (param, element, state, context) => {
632
634
  if ((0, import_types.isFunction)(param)) {
633
- return param(
635
+ return param.call(
636
+ element,
634
637
  element,
635
638
  state || element.state,
636
639
  context || element.context
@@ -729,24 +732,37 @@ var require_object = __commonJS({
729
732
  }
730
733
  return clone2;
731
734
  };
732
- var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
735
+ var deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}, visited = /* @__PURE__ */ new WeakSet()) => {
736
+ if ((0, import_types.isObjectLike)(obj)) {
737
+ if (visited.has(obj)) {
738
+ return obj;
739
+ }
740
+ visited.add(obj);
741
+ }
733
742
  const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
734
743
  for (const prop in obj) {
735
744
  if (!Object.prototype.hasOwnProperty.call(obj, prop))
736
745
  continue;
737
746
  const objProp = obj[prop];
738
- if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
747
+ if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp)) {
739
748
  continue;
749
+ }
740
750
  if ((0, import_types.isObjectLike)(objProp)) {
741
- o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
751
+ o[prop] = deepCloneWithExtend(objProp, excludeFrom, options, visited);
742
752
  } else if ((0, import_types.isFunction)(objProp) && options.window) {
743
753
  o[prop] = (options.window || import_globals2.window).eval("(" + objProp.toString() + ")");
744
- } else
754
+ } else {
745
755
  o[prop] = objProp;
756
+ }
746
757
  }
747
758
  return o;
748
759
  };
749
760
  var deepStringify = (obj, stringified = {}) => {
761
+ var _a;
762
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
763
+ console.warn("Trying to clone element or state at", obj);
764
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
765
+ }
750
766
  for (const prop in obj) {
751
767
  const objProp = obj[prop];
752
768
  if ((0, import_types.isFunction)(objProp)) {
@@ -772,6 +788,39 @@ var require_object = __commonJS({
772
788
  }
773
789
  return stringified;
774
790
  };
791
+ var MAX_DEPTH = 100;
792
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
793
+ if (depth > MAX_DEPTH) {
794
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
795
+ return "[MAX_DEPTH_EXCEEDED]";
796
+ }
797
+ for (const prop in obj) {
798
+ const currentPath = path ? `${path}.${prop}` : prop;
799
+ const objProp = obj[prop];
800
+ if ((0, import_types.isFunction)(objProp)) {
801
+ stringified[prop] = objProp.toString();
802
+ } else if ((0, import_types.isObject)(objProp)) {
803
+ stringified[prop] = {};
804
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
805
+ } else if ((0, import_types.isArray)(objProp)) {
806
+ stringified[prop] = [];
807
+ objProp.forEach((v, i) => {
808
+ const itemPath = `${currentPath}[${i}]`;
809
+ if ((0, import_types.isObject)(v)) {
810
+ stringified[prop][i] = {};
811
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
812
+ } else if ((0, import_types.isFunction)(v)) {
813
+ stringified[prop][i] = v.toString();
814
+ } else {
815
+ stringified[prop][i] = v;
816
+ }
817
+ });
818
+ } else {
819
+ stringified[prop] = objProp;
820
+ }
821
+ }
822
+ return stringified;
823
+ };
775
824
  var objectToString = (obj = {}, indent = 0) => {
776
825
  const spaces = " ".repeat(indent);
777
826
  let str = "{\n";
@@ -1163,6 +1212,25 @@ var require_object = __commonJS({
1163
1212
  }
1164
1213
  }
1165
1214
  };
1215
+ var isCyclic = (obj) => {
1216
+ const seenObjects = [];
1217
+ function detect(obj2) {
1218
+ if (obj2 && typeof obj2 === "object") {
1219
+ if (seenObjects.indexOf(obj2) !== -1) {
1220
+ return true;
1221
+ }
1222
+ seenObjects.push(obj2);
1223
+ for (const key in obj2) {
1224
+ if (Object.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
1225
+ console.log(obj2, "cycle at " + key);
1226
+ return true;
1227
+ }
1228
+ }
1229
+ }
1230
+ return false;
1231
+ }
1232
+ return detect(obj);
1233
+ };
1166
1234
  }
1167
1235
  });
1168
1236
 
@@ -1319,6 +1387,7 @@ var require_cookie = __commonJS({
1319
1387
  __export2(cookie_exports, {
1320
1388
  getCookie: () => getCookie,
1321
1389
  isMobile: () => isMobile,
1390
+ removeCookie: () => removeCookie,
1322
1391
  setCookie: () => setCookie
1323
1392
  });
1324
1393
  module2.exports = __toCommonJS2(cookie_exports);
@@ -1348,6 +1417,11 @@ var require_cookie = __commonJS({
1348
1417
  }
1349
1418
  return "";
1350
1419
  };
1420
+ var removeCookie = (cname) => {
1421
+ if ((0, import_types.isUndefined)(import_utils11.document) || (0, import_types.isUndefined)(import_utils11.document.cookie))
1422
+ return;
1423
+ import_utils11.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
1424
+ };
1351
1425
  }
1352
1426
  });
1353
1427
 
@@ -1387,10 +1461,13 @@ var require_tags = __commonJS({
1387
1461
  "title",
1388
1462
  "base",
1389
1463
  "meta",
1390
- "style"
1464
+ "style",
1465
+ "noscript",
1466
+ "script"
1391
1467
  ],
1392
1468
  body: [
1393
1469
  "string",
1470
+ "style",
1394
1471
  "fragment",
1395
1472
  "a",
1396
1473
  "abbr",
@@ -1543,6 +1620,7 @@ var require_component = __commonJS({
1543
1620
  var component_exports = {};
1544
1621
  __export2(component_exports, {
1545
1622
  addAdditionalExtend: () => addAdditionalExtend,
1623
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
1546
1624
  applyComponentFromContext: () => applyComponentFromContext,
1547
1625
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
1548
1626
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -1551,7 +1629,8 @@ var require_component = __commonJS({
1551
1629
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1552
1630
  getExtendsInElement: () => getExtendsInElement,
1553
1631
  hasVariantProp: () => hasVariantProp,
1554
- isVariant: () => isVariant
1632
+ isVariant: () => isVariant,
1633
+ setContentKey: () => setContentKey
1555
1634
  });
1556
1635
  module2.exports = __toCommonJS2(component_exports);
1557
1636
  var import__ = require_cjs();
@@ -1577,20 +1656,28 @@ var require_component = __commonJS({
1577
1656
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
1578
1657
  return { ...element, extend };
1579
1658
  };
1659
+ var checkIfSugar = (element, parent, key) => {
1660
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
1661
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
1662
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
1663
+ };
1580
1664
  var extendizeByKey = (element, parent, key) => {
1581
1665
  const { context } = parent;
1582
- const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
1583
- const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
1666
+ const { tag, extend, childrenExtends } = element;
1667
+ const isSugar = checkIfSugar(element);
1584
1668
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1585
1669
  const isExtendKeyComponent = context && context.components[extendFromKey];
1586
1670
  if (element === isExtendKeyComponent)
1587
1671
  return element;
1588
- else if (!hasComponentAttrs || childProps) {
1589
- return {
1672
+ else if (isSugar) {
1673
+ const newElem = {
1590
1674
  extend: extendFromKey,
1591
1675
  tag,
1592
1676
  props: { ...element }
1593
1677
  };
1678
+ if (childrenExtends)
1679
+ newElem.childExtend = childrenExtends;
1680
+ return newElem;
1594
1681
  } else if (!extend || extend === true) {
1595
1682
  return {
1596
1683
  ...element,
@@ -1607,6 +1694,37 @@ var require_component = __commonJS({
1607
1694
  };
1608
1695
  }
1609
1696
  };
1697
+ function getCapitalCaseKeys(obj) {
1698
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
1699
+ }
1700
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
1701
+ const childElems = getCapitalCaseKeys(element.props);
1702
+ if (!childElems.length)
1703
+ return element;
1704
+ for (const i in childElems) {
1705
+ const childKey = childElems[i];
1706
+ const childElem = element[childKey];
1707
+ const newChild = element.props[childKey];
1708
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
1709
+ continue;
1710
+ if (!childElem)
1711
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
1712
+ else {
1713
+ const isSugar = checkIfSugar(childElem);
1714
+ if (!isSugar)
1715
+ continue;
1716
+ const inheritedChildElem = element[childKey].props;
1717
+ if ((0, import__.isObjectLike)(newChild)) {
1718
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
1719
+ } else if ((0, import__.isFunction)(newChild)) {
1720
+ element[childKey] = {
1721
+ extend: element[childKey],
1722
+ props: newChild
1723
+ };
1724
+ }
1725
+ }
1726
+ }
1727
+ };
1610
1728
  var applyKeyComponentAsExtend = (element, parent, key) => {
1611
1729
  return extendizeByKey(element, parent, key) || element;
1612
1730
  };
@@ -1682,6 +1800,17 @@ var require_component = __commonJS({
1682
1800
  traverse(obj);
1683
1801
  return result;
1684
1802
  };
1803
+ var setContentKey = (el, opts = {}) => {
1804
+ const { __ref: ref } = el;
1805
+ const contentElementKey = opts.contentElementKey;
1806
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
1807
+ ref.contentElementKey = contentElementKey || "content";
1808
+ } else
1809
+ ref.contentElementKey = "content";
1810
+ if (contentElementKey !== "content")
1811
+ opts.contentElementKey = "content";
1812
+ return ref.contentElementKey;
1813
+ };
1685
1814
  }
1686
1815
  });
1687
1816
 
@@ -2343,6 +2472,7 @@ var require_cjs3 = __commonJS({
2343
2472
  deepDiff: () => deepDiff,
2344
2473
  deepMerge: () => deepMerge3,
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 ENV = "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({