@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: () => deepMerge2,
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_utils10.document) || (0, import_types.isUndefined)(import_utils10.document.cookie))
1422
+ return;
1423
+ import_utils10.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
 
@@ -2307,6 +2436,7 @@ var require_cjs2 = __commonJS({
2307
2436
  deepDiff: () => deepDiff,
2308
2437
  deepMerge: () => deepMerge2,
2309
2438
  deepStringify: () => deepStringify,
2439
+ deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
2310
2440
  detachFunctionsFromObject: () => detachFunctionsFromObject,
2311
2441
  detectInfiniteLoop: () => detectInfiniteLoop,
2312
2442
  diff: () => diff,
@@ -2340,7 +2470,8 @@ var require_cjs2 = __commonJS({
2340
2470
  var ENV = "development";
2341
2471
  var exec = (param, element, state, context) => {
2342
2472
  if ((0, import_types.isFunction)(param)) {
2343
- return param(
2473
+ return param.call(
2474
+ element,
2344
2475
  element,
2345
2476
  state || element.state,
2346
2477
  context || element.context
@@ -2457,6 +2588,11 @@ var require_cjs2 = __commonJS({
2457
2588
  return o;
2458
2589
  };
2459
2590
  var deepStringify = (obj, stringified = {}) => {
2591
+ var _a;
2592
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
2593
+ console.warn("Trying to clone element or state at", obj);
2594
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
2595
+ }
2460
2596
  for (const prop in obj) {
2461
2597
  const objProp = obj[prop];
2462
2598
  if ((0, import_types.isFunction)(objProp)) {
@@ -2482,6 +2618,39 @@ var require_cjs2 = __commonJS({
2482
2618
  }
2483
2619
  return stringified;
2484
2620
  };
2621
+ var MAX_DEPTH = 100;
2622
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
2623
+ if (depth > MAX_DEPTH) {
2624
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
2625
+ return "[MAX_DEPTH_EXCEEDED]";
2626
+ }
2627
+ for (const prop in obj) {
2628
+ const currentPath = path ? `${path}.${prop}` : prop;
2629
+ const objProp = obj[prop];
2630
+ if ((0, import_types.isFunction)(objProp)) {
2631
+ stringified[prop] = objProp.toString();
2632
+ } else if ((0, import_types.isObject)(objProp)) {
2633
+ stringified[prop] = {};
2634
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
2635
+ } else if ((0, import_types.isArray)(objProp)) {
2636
+ stringified[prop] = [];
2637
+ objProp.forEach((v, i) => {
2638
+ const itemPath = `${currentPath}[${i}]`;
2639
+ if ((0, import_types.isObject)(v)) {
2640
+ stringified[prop][i] = {};
2641
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
2642
+ } else if ((0, import_types.isFunction)(v)) {
2643
+ stringified[prop][i] = v.toString();
2644
+ } else {
2645
+ stringified[prop][i] = v;
2646
+ }
2647
+ });
2648
+ } else {
2649
+ stringified[prop] = objProp;
2650
+ }
2651
+ }
2652
+ return stringified;
2653
+ };
2485
2654
  var objectToString = (obj = {}, indent = 0) => {
2486
2655
  const spaces = " ".repeat(indent);
2487
2656
  let str = "{\n";
@@ -3023,6 +3192,7 @@ var require_cjs2 = __commonJS({
3023
3192
  __export22(cookie_exports, {
3024
3193
  getCookie: () => getCookie,
3025
3194
  isMobile: () => isMobile,
3195
+ removeCookie: () => removeCookie,
3026
3196
  setCookie: () => setCookie
3027
3197
  });
3028
3198
  module22.exports = __toCommonJS22(cookie_exports);
@@ -3052,6 +3222,11 @@ var require_cjs2 = __commonJS({
3052
3222
  }
3053
3223
  return "";
3054
3224
  };
3225
+ var removeCookie = (cname) => {
3226
+ if ((0, import_types.isUndefined)(import_utils32.document) || (0, import_types.isUndefined)(import_utils32.document.cookie))
3227
+ return;
3228
+ import_utils32.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
3229
+ };
3055
3230
  }
3056
3231
  });
3057
3232
  var require_tags2 = __commonJS2({
@@ -3089,10 +3264,13 @@ var require_cjs2 = __commonJS({
3089
3264
  "title",
3090
3265
  "base",
3091
3266
  "meta",
3092
- "style"
3267
+ "style",
3268
+ "noscript",
3269
+ "script"
3093
3270
  ],
3094
3271
  body: [
3095
3272
  "string",
3273
+ "style",
3096
3274
  "fragment",
3097
3275
  "a",
3098
3276
  "abbr",
@@ -3243,6 +3421,7 @@ var require_cjs2 = __commonJS({
3243
3421
  var component_exports = {};
3244
3422
  __export22(component_exports, {
3245
3423
  addAdditionalExtend: () => addAdditionalExtend,
3424
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
3246
3425
  applyComponentFromContext: () => applyComponentFromContext,
3247
3426
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
3248
3427
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -3251,7 +3430,8 @@ var require_cjs2 = __commonJS({
3251
3430
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
3252
3431
  getExtendsInElement: () => getExtendsInElement,
3253
3432
  hasVariantProp: () => hasVariantProp,
3254
- isVariant: () => isVariant
3433
+ isVariant: () => isVariant,
3434
+ setContentKey: () => setContentKey
3255
3435
  });
3256
3436
  module22.exports = __toCommonJS22(component_exports);
3257
3437
  var import__ = require_cjs4();
@@ -3277,20 +3457,28 @@ var require_cjs2 = __commonJS({
3277
3457
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
3278
3458
  return { ...element, extend };
3279
3459
  };
3460
+ var checkIfSugar = (element, parent, key) => {
3461
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
3462
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
3463
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
3464
+ };
3280
3465
  var extendizeByKey = (element, parent, key) => {
3281
3466
  const { context } = parent;
3282
- const { tag, extend, props, attr, state, childExtend, childProps, on, if: condition, data } = element;
3283
- const hasComponentAttrs = extend || childExtend || props || state || on || condition || attr || data;
3467
+ const { tag, extend, childrenExtends } = element;
3468
+ const isSugar = checkIfSugar(element);
3284
3469
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
3285
3470
  const isExtendKeyComponent = context && context.components[extendFromKey];
3286
3471
  if (element === isExtendKeyComponent)
3287
3472
  return element;
3288
- else if (!hasComponentAttrs || childProps) {
3289
- return {
3473
+ else if (isSugar) {
3474
+ const newElem = {
3290
3475
  extend: extendFromKey,
3291
3476
  tag,
3292
3477
  props: { ...element }
3293
3478
  };
3479
+ if (childrenExtends)
3480
+ newElem.childExtend = childrenExtends;
3481
+ return newElem;
3294
3482
  } else if (!extend || extend === true) {
3295
3483
  return {
3296
3484
  ...element,
@@ -3307,6 +3495,37 @@ var require_cjs2 = __commonJS({
3307
3495
  };
3308
3496
  }
3309
3497
  };
3498
+ function getCapitalCaseKeys(obj) {
3499
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
3500
+ }
3501
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
3502
+ const childElems = getCapitalCaseKeys(element.props);
3503
+ if (!childElems.length)
3504
+ return element;
3505
+ for (const i in childElems) {
3506
+ const childKey = childElems[i];
3507
+ const childElem = element[childKey];
3508
+ const newChild = element.props[childKey];
3509
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
3510
+ continue;
3511
+ if (!childElem)
3512
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
3513
+ else {
3514
+ const isSugar = checkIfSugar(childElem);
3515
+ if (!isSugar)
3516
+ continue;
3517
+ const inheritedChildElem = element[childKey].props;
3518
+ if ((0, import__.isObjectLike)(newChild)) {
3519
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
3520
+ } else if ((0, import__.isFunction)(newChild)) {
3521
+ element[childKey] = {
3522
+ extend: element[childKey],
3523
+ props: newChild
3524
+ };
3525
+ }
3526
+ }
3527
+ }
3528
+ };
3310
3529
  var applyKeyComponentAsExtend = (element, parent, key) => {
3311
3530
  return extendizeByKey(element, parent, key) || element;
3312
3531
  };
@@ -3382,6 +3601,17 @@ var require_cjs2 = __commonJS({
3382
3601
  traverse(obj);
3383
3602
  return result;
3384
3603
  };
3604
+ var setContentKey = (el, opts = {}) => {
3605
+ const { __ref: ref } = el;
3606
+ const contentElementKey = opts.contentElementKey;
3607
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
3608
+ ref.contentElementKey = contentElementKey || "content";
3609
+ } else
3610
+ ref.contentElementKey = "content";
3611
+ if (contentElementKey !== "content")
3612
+ opts.contentElementKey = "content";
3613
+ return ref.contentElementKey;
3614
+ };
3385
3615
  }
3386
3616
  });
3387
3617
  var require_cjs4 = __commonJS2({