@symbo.ls/scratch 2.11.439 → 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_utils5.document) || (0, import_types.isUndefined)(import_utils5.document.cookie))
1394
+ return;
1395
+ import_utils5.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
 
@@ -2307,6 +2408,7 @@ var require_cjs2 = __commonJS({
2307
2408
  deepDiff: () => deepDiff,
2308
2409
  deepMerge: () => deepMerge2,
2309
2410
  deepStringify: () => deepStringify,
2411
+ deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
2310
2412
  detachFunctionsFromObject: () => detachFunctionsFromObject,
2311
2413
  detectInfiniteLoop: () => detectInfiniteLoop,
2312
2414
  diff: () => diff,
@@ -2340,7 +2442,8 @@ var require_cjs2 = __commonJS({
2340
2442
  var ENV = "development";
2341
2443
  var exec = (param, element, state, context) => {
2342
2444
  if ((0, import_types.isFunction)(param)) {
2343
- return param(
2445
+ return param.call(
2446
+ element,
2344
2447
  element,
2345
2448
  state || element.state,
2346
2449
  context || element.context
@@ -2457,6 +2560,11 @@ var require_cjs2 = __commonJS({
2457
2560
  return o;
2458
2561
  };
2459
2562
  var deepStringify = (obj, stringified = {}) => {
2563
+ var _a;
2564
+ if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
2565
+ console.warn("Trying to clone element or state at", obj);
2566
+ obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
2567
+ }
2460
2568
  for (const prop in obj) {
2461
2569
  const objProp = obj[prop];
2462
2570
  if ((0, import_types.isFunction)(objProp)) {
@@ -2482,6 +2590,39 @@ var require_cjs2 = __commonJS({
2482
2590
  }
2483
2591
  return stringified;
2484
2592
  };
2593
+ var MAX_DEPTH = 100;
2594
+ var deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
2595
+ if (depth > MAX_DEPTH) {
2596
+ console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
2597
+ return "[MAX_DEPTH_EXCEEDED]";
2598
+ }
2599
+ for (const prop in obj) {
2600
+ const currentPath = path ? `${path}.${prop}` : prop;
2601
+ const objProp = obj[prop];
2602
+ if ((0, import_types.isFunction)(objProp)) {
2603
+ stringified[prop] = objProp.toString();
2604
+ } else if ((0, import_types.isObject)(objProp)) {
2605
+ stringified[prop] = {};
2606
+ deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
2607
+ } else if ((0, import_types.isArray)(objProp)) {
2608
+ stringified[prop] = [];
2609
+ objProp.forEach((v, i) => {
2610
+ const itemPath = `${currentPath}[${i}]`;
2611
+ if ((0, import_types.isObject)(v)) {
2612
+ stringified[prop][i] = {};
2613
+ deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
2614
+ } else if ((0, import_types.isFunction)(v)) {
2615
+ stringified[prop][i] = v.toString();
2616
+ } else {
2617
+ stringified[prop][i] = v;
2618
+ }
2619
+ });
2620
+ } else {
2621
+ stringified[prop] = objProp;
2622
+ }
2623
+ }
2624
+ return stringified;
2625
+ };
2485
2626
  var objectToString = (obj = {}, indent = 0) => {
2486
2627
  const spaces = " ".repeat(indent);
2487
2628
  let str = "{\n";
@@ -3023,6 +3164,7 @@ var require_cjs2 = __commonJS({
3023
3164
  __export22(cookie_exports, {
3024
3165
  getCookie: () => getCookie,
3025
3166
  isMobile: () => isMobile,
3167
+ removeCookie: () => removeCookie,
3026
3168
  setCookie: () => setCookie
3027
3169
  });
3028
3170
  module22.exports = __toCommonJS22(cookie_exports);
@@ -3052,6 +3194,11 @@ var require_cjs2 = __commonJS({
3052
3194
  }
3053
3195
  return "";
3054
3196
  };
3197
+ var removeCookie = (cname) => {
3198
+ if ((0, import_types.isUndefined)(import_utils32.document) || (0, import_types.isUndefined)(import_utils32.document.cookie))
3199
+ return;
3200
+ import_utils32.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
3201
+ };
3055
3202
  }
3056
3203
  });
3057
3204
  var require_tags2 = __commonJS2({
@@ -3089,10 +3236,13 @@ var require_cjs2 = __commonJS({
3089
3236
  "title",
3090
3237
  "base",
3091
3238
  "meta",
3092
- "style"
3239
+ "style",
3240
+ "noscript",
3241
+ "script"
3093
3242
  ],
3094
3243
  body: [
3095
3244
  "string",
3245
+ "style",
3096
3246
  "fragment",
3097
3247
  "a",
3098
3248
  "abbr",
@@ -3243,6 +3393,7 @@ var require_cjs2 = __commonJS({
3243
3393
  var component_exports = {};
3244
3394
  __export22(component_exports, {
3245
3395
  addAdditionalExtend: () => addAdditionalExtend,
3396
+ addChildrenIfNotInOriginal: () => addChildrenIfNotInOriginal,
3246
3397
  applyComponentFromContext: () => applyComponentFromContext,
3247
3398
  applyKeyComponentAsExtend: () => applyKeyComponentAsExtend,
3248
3399
  checkIfKeyIsComponent: () => checkIfKeyIsComponent,
@@ -3251,7 +3402,8 @@ var require_cjs2 = __commonJS({
3251
3402
  getChildrenComponentsByKey: () => getChildrenComponentsByKey,
3252
3403
  getExtendsInElement: () => getExtendsInElement,
3253
3404
  hasVariantProp: () => hasVariantProp,
3254
- isVariant: () => isVariant
3405
+ isVariant: () => isVariant,
3406
+ setContentKey: () => setContentKey
3255
3407
  });
3256
3408
  module22.exports = __toCommonJS22(component_exports);
3257
3409
  var import__ = require_cjs3();
@@ -3277,20 +3429,28 @@ var require_cjs2 = __commonJS({
3277
3429
  const extend = (0, import__.joinArrays)(receivedArray, originalArray);
3278
3430
  return { ...element, extend };
3279
3431
  };
3432
+ var checkIfSugar = (element, parent, key) => {
3433
+ const { extend, props, childExtend, extends: extendProps, childrenExtends, childProps, children, on, $collection, $stateCollection, $propsCollection } = element;
3434
+ const hasComponentAttrs = extend || childExtend || props || on || $collection || $stateCollection || $propsCollection;
3435
+ return !hasComponentAttrs || childProps || extendProps || children || childrenExtends;
3436
+ };
3280
3437
  var extendizeByKey = (element, parent, key) => {
3281
3438
  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;
3439
+ const { tag, extend, childrenExtends } = element;
3440
+ const isSugar = checkIfSugar(element);
3284
3441
  const extendFromKey = key.includes("+") ? key.split("+") : key.includes("_") ? [key.split("_")[0]] : key.includes(".") && !checkIfKeyIsComponent(key.split(".")[1]) ? [key.split(".")[0]] : [key];
3285
3442
  const isExtendKeyComponent = context && context.components[extendFromKey];
3286
3443
  if (element === isExtendKeyComponent)
3287
3444
  return element;
3288
- else if (!hasComponentAttrs || childProps) {
3289
- return {
3445
+ else if (isSugar) {
3446
+ const newElem = {
3290
3447
  extend: extendFromKey,
3291
3448
  tag,
3292
3449
  props: { ...element }
3293
3450
  };
3451
+ if (childrenExtends)
3452
+ newElem.childExtend = childrenExtends;
3453
+ return newElem;
3294
3454
  } else if (!extend || extend === true) {
3295
3455
  return {
3296
3456
  ...element,
@@ -3307,6 +3467,37 @@ var require_cjs2 = __commonJS({
3307
3467
  };
3308
3468
  }
3309
3469
  };
3470
+ function getCapitalCaseKeys(obj) {
3471
+ return Object.keys(obj).filter((key) => /^[A-Z]/.test(key));
3472
+ }
3473
+ var addChildrenIfNotInOriginal = (element, parent, key) => {
3474
+ const childElems = getCapitalCaseKeys(element.props);
3475
+ if (!childElems.length)
3476
+ return element;
3477
+ for (const i in childElems) {
3478
+ const childKey = childElems[i];
3479
+ const childElem = element[childKey];
3480
+ const newChild = element.props[childKey];
3481
+ if (newChild == null ? void 0 : newChild.ignoreExtend)
3482
+ continue;
3483
+ if (!childElem)
3484
+ element[childKey] = (0, import__.deepCloneWithExtend)(newChild);
3485
+ else {
3486
+ const isSugar = checkIfSugar(childElem);
3487
+ if (!isSugar)
3488
+ continue;
3489
+ const inheritedChildElem = element[childKey].props;
3490
+ if ((0, import__.isObjectLike)(newChild)) {
3491
+ (0, import__.overwriteDeep)(inheritedChildElem, newChild);
3492
+ } else if ((0, import__.isFunction)(newChild)) {
3493
+ element[childKey] = {
3494
+ extend: element[childKey],
3495
+ props: newChild
3496
+ };
3497
+ }
3498
+ }
3499
+ }
3500
+ };
3310
3501
  var applyKeyComponentAsExtend = (element, parent, key) => {
3311
3502
  return extendizeByKey(element, parent, key) || element;
3312
3503
  };
@@ -3382,6 +3573,17 @@ var require_cjs2 = __commonJS({
3382
3573
  traverse(obj);
3383
3574
  return result;
3384
3575
  };
3576
+ var setContentKey = (el, opts = {}) => {
3577
+ const { __ref: ref } = el;
3578
+ const contentElementKey = opts.contentElementKey;
3579
+ if (contentElementKey !== "content" && contentElementKey !== ref.contentElementKey || !ref.contentElementKey) {
3580
+ ref.contentElementKey = contentElementKey || "content";
3581
+ } else
3582
+ ref.contentElementKey = "content";
3583
+ if (contentElementKey !== "content")
3584
+ opts.contentElementKey = "content";
3585
+ return ref.contentElementKey;
3586
+ };
3385
3587
  }
3386
3588
  });
3387
3589
  var require_cjs3 = __commonJS2({
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "2.11.439",
5
+ "version": "2.11.446",
6
6
  "files": [
7
7
  "src",
8
8
  "dist"
@@ -25,10 +25,10 @@
25
25
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
26
26
  },
27
27
  "dependencies": {
28
- "@domql/globals": "latest",
29
- "@domql/utils": "latest",
30
- "@symbo.ls/utils": "latest",
28
+ "@domql/globals": "^2.5.0",
29
+ "@domql/utils": "^2.5.0",
30
+ "@symbo.ls/utils": "^2.11.446",
31
31
  "color-contrast-checker": "^1.5.0"
32
32
  },
33
- "gitHead": "b16ac3edce7fceb5e81d7cc7bbad51256e10b166"
33
+ "gitHead": "d042e0c4fc9379b0ca7584f6405cfa2e7c1301d4"
34
34
  }
@@ -74,7 +74,7 @@ export const transformBackgroundImage = (backgroundImage, globalTheme) => {
74
74
  return {
75
75
  backgroundImage: getMediaColor(backgroundImage, globalTheme || CONFIG.globalTheme)
76
76
  }
77
- } else if (v.includes('/') || v.includes('http')) return `url(${v})`
77
+ } else if (v.includes('/') || v.startsWith('http') || v.includes('.')) return `url(${v})`
78
78
  return v
79
79
  }).join(' ')
80
80
  }