@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.
@@ -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,
@@ -630,7 +631,8 @@ var require_object = __commonJS({
630
631
  var ENV = "development";
631
632
  var exec = (param, element, state, context) => {
632
633
  if ((0, import_types.isFunction)(param)) {
633
- return param(
634
+ return param.call(
635
+ element,
634
636
  element,
635
637
  state || element.state,
636
638
  context || element.context
@@ -747,6 +749,11 @@ var require_object = __commonJS({
747
749
  return o;
748
750
  };
749
751
  var deepStringify = (obj, stringified = {}) => {
752
+ var _a;
753
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
754
+ console.warn("Trying to clone element or state at", obj);
755
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
756
+ }
750
757
  for (const prop in obj) {
751
758
  const objProp = obj[prop];
752
759
  if ((0, import_types.isFunction)(objProp)) {
@@ -772,6 +779,39 @@ var require_object = __commonJS({
772
779
  }
773
780
  return stringified;
774
781
  };
782
+ var MAX_DEPTH = 100;
783
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
784
+ if (depth > MAX_DEPTH) {
785
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
786
+ return "[MAX_DEPTH_EXCEEDED]";
787
+ }
788
+ for (const prop in obj) {
789
+ const currentPath = path ? `${path}.${prop}` : prop;
790
+ const objProp = obj[prop];
791
+ if ((0, import_types.isFunction)(objProp)) {
792
+ stringified[prop] = objProp.toString();
793
+ } else if ((0, import_types.isObject)(objProp)) {
794
+ stringified[prop] = {};
795
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
796
+ } else if ((0, import_types.isArray)(objProp)) {
797
+ stringified[prop] = [];
798
+ objProp.forEach((v, i) => {
799
+ const itemPath = `${currentPath}[${i}]`;
800
+ if ((0, import_types.isObject)(v)) {
801
+ stringified[prop][i] = {};
802
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
803
+ } else if ((0, import_types.isFunction)(v)) {
804
+ stringified[prop][i] = v.toString();
805
+ } else {
806
+ stringified[prop][i] = v;
807
+ }
808
+ });
809
+ } else {
810
+ stringified[prop] = objProp;
811
+ }
812
+ }
813
+ return stringified;
814
+ };
775
815
  var objectToString = (obj = {}, indent = 0) => {
776
816
  const spaces = " ".repeat(indent);
777
817
  let str = "{\n";
@@ -1319,6 +1359,7 @@ var require_cookie = __commonJS({
1319
1359
  __export2(cookie_exports, {
1320
1360
  getCookie: () => getCookie,
1321
1361
  isMobile: () => isMobile,
1362
+ removeCookie: () => removeCookie,
1322
1363
  setCookie: () => setCookie
1323
1364
  });
1324
1365
  module2.exports = __toCommonJS2(cookie_exports);
@@ -1348,6 +1389,11 @@ var require_cookie = __commonJS({
1348
1389
  }
1349
1390
  return "";
1350
1391
  };
1392
+ var removeCookie = (cname) => {
1393
+ if ((0, import_types.isUndefined)(import_utils10.document) || (0, import_types.isUndefined)(import_utils10.document.cookie))
1394
+ return;
1395
+ import_utils10.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
1396
+ };
1351
1397
  }
1352
1398
  });
1353
1399
 
@@ -1387,10 +1433,13 @@ var require_tags = __commonJS({
1387
1433
  "title",
1388
1434
  "base",
1389
1435
  "meta",
1390
- "style"
1436
+ "style",
1437
+ "noscript",
1438
+ "script"
1391
1439
  ],
1392
1440
  body: [
1393
1441
  "string",
1442
+ "style",
1394
1443
  "fragment",
1395
1444
  "a",
1396
1445
  "abbr",
@@ -1543,6 +1592,7 @@ var require_component = __commonJS({
1543
1592
  var component_exports = {};
1544
1593
  __export2(component_exports, {
1545
1594
  addAdditionalExtend: () => addAdditionalExtend,
1595
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
1546
1596
  applyComponentFromContext: () => applyComponentFromContext,
1547
1597
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
1548
1598
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -1551,7 +1601,8 @@ var require_component = __commonJS({
1551
1601
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
1552
1602
  getExtendsInElement: () => getExtendsInElement,
1553
1603
  hasVariantProp: () => hasVariantProp,
1554
- isVariant: () => isVariant
1604
+ isVariant: () => isVariant,
1605
+ setContentKey: () => setContentKey
1555
1606
  });
1556
1607
  module2.exports = __toCommonJS2(component_exports);
1557
1608
  var import__ = require_cjs();
@@ -1577,20 +1628,28 @@ var require_component = __commonJS({
1577
1628
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
1578
1629
  return { ...element, extend };
1579
1630
  };
1631
+ var checkIfSugar = (element, parent, key) => {
1632
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
1633
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
1634
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
1635
+ };
1580
1636
  var extendizeByKey = (element, parent, key) => {
1581
1637
  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;
1638
+ const { tag, extend, childrenExtends } = element;
1639
+ const isSugar = checkIfSugar(element);
1584
1640
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
1585
1641
  const isExtendKeyComponent = context && context.components[extendFromKey];
1586
1642
  if (element === isExtendKeyComponent)
1587
1643
  return element;
1588
- else if (!hasComponentAttrs || childProps) {
1589
- return {
1644
+ else if (isSugar) {
1645
+ const newElem = {
1590
1646
  extend: extendFromKey,
1591
1647
  tag,
1592
1648
  props: { ...element }
1593
1649
  };
1650
+ if (childrenExtends)
1651
+ newElem.childExtend = childrenExtends;
1652
+ return newElem;
1594
1653
  } else if (!extend || extend === true) {
1595
1654
  return {
1596
1655
  ...element,
@@ -1607,6 +1666,37 @@ var require_component = __commonJS({
1607
1666
  };
1608
1667
  }
1609
1668
  };
1669
+ function getCapitalCaseKeys(obj) {
1670
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
1671
+ }
1672
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
1673
+ const childElems = getCapitalCaseKeys(element.props);
1674
+ if (!childElems.length)
1675
+ return element;
1676
+ for (const i in childElems) {
1677
+ const childKey = childElems[i];
1678
+ const childElem = element[childKey];
1679
+ const newChild = element.props[childKey];
1680
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
1681
+ continue;
1682
+ if (!childElem)
1683
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
1684
+ else {
1685
+ const isSugar = checkIfSugar(childElem);
1686
+ if (!isSugar)
1687
+ continue;
1688
+ const inheritedChildElem = element[childKey].props;
1689
+ if ((0, import__.isObjectLike)(newChild)) {
1690
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
1691
+ } else if ((0, import__.isFunction)(newChild)) {
1692
+ element[childKey] = {
1693
+ extend: element[childKey],
1694
+ props: newChild
1695
+ };
1696
+ }
1697
+ }
1698
+ }
1699
+ };
1610
1700
  var applyKeyComponentAsExtend = (element, parent, key) => {
1611
1701
  return extendizeByKey(element, parent, key) || element;
1612
1702
  };
@@ -1682,6 +1772,17 @@ var require_component = __commonJS({
1682
1772
  traverse(obj);
1683
1773
  return result;
1684
1774
  };
1775
+ var setContentKey = (el, opts = {}) => {
1776
+ const { __ref: ref } = el;
1777
+ const contentElementKey = opts.contentElementKey;
1778
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
1779
+ ref.contentElementKey = contentElementKey || "content";
1780
+ } else
1781
+ ref.contentElementKey = "content";
1782
+ if (contentElementKey !== "content")
1783
+ opts.contentElementKey = "content";
1784
+ return ref.contentElementKey;
1785
+ };
1685
1786
  }
1686
1787
  });
1687
1788
 
@@ -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({