@symbo.ls/scratch 2.11.225 → 2.11.227

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.
@@ -1429,6 +1429,7 @@ var defaultProps = {
1429
1429
  h1Matches: 6,
1430
1430
  lineHeight: 1.5,
1431
1431
  subSequence: true,
1432
+ mediaRegenerate: false,
1432
1433
  unit: "em",
1433
1434
  templates: {},
1434
1435
  sequence: {},
@@ -1484,6 +1485,7 @@ var defaultProps2 = {
1484
1485
  ratio: SEQUENCE.phi,
1485
1486
  range: [-5, 15],
1486
1487
  subSequence: true,
1488
+ mediaRegenerate: false,
1487
1489
  unit: "em",
1488
1490
  sequence: {},
1489
1491
  scales: {},
@@ -1511,6 +1513,7 @@ var defaultProps3 = {
1511
1513
  type: "timing",
1512
1514
  ratio: SEQUENCE["perfect-fourth"],
1513
1515
  range: [-3, 12],
1516
+ mediaRegenerate: false,
1514
1517
  unit: "ms",
1515
1518
  sequence: {},
1516
1519
  scales: {},
@@ -1627,45 +1630,77 @@ var numToLetterMap = {
1627
1630
  19: "T"
1628
1631
  };
1629
1632
  var setSequenceValue = (props, sequenceProps) => {
1630
- const { key, variable, value, scaling, index } = props;
1633
+ const { key, variable, value, scaling, index, scalingVariable } = props;
1631
1634
  sequenceProps.sequence[key] = {
1632
1635
  key,
1633
1636
  decimal: ~~(value * 100) / 100,
1634
1637
  val: ~~value,
1635
1638
  scaling,
1636
1639
  index,
1640
+ scalingVariable,
1637
1641
  variable
1638
1642
  };
1639
1643
  sequenceProps.scales[key] = scaling;
1640
1644
  sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1641
1645
  };
1646
+ var setScalingVar = (key, sequenceProps) => {
1647
+ const { type } = sequenceProps;
1648
+ if (key === 0)
1649
+ return "1em";
1650
+ const prefix = "--" + (type && type.replace(".", "-"));
1651
+ const ratioVar = `${prefix}-ratio`;
1652
+ if (key > 0) {
1653
+ const prevLetterKey = numToLetterMap[key - 1];
1654
+ return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
1655
+ }
1656
+ if (key < 0) {
1657
+ const nextLetterKey = numToLetterMap[key + 1];
1658
+ return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1659
+ }
1660
+ };
1661
+ var setSubScalingVar = (index, arr, variable, sequenceProps) => {
1662
+ const { type } = sequenceProps;
1663
+ const skipMiddle = index === 2 && arr.length === 2;
1664
+ const indexMapWithLength = skipMiddle ? index + 1 : index;
1665
+ const prefix = "--" + (type && type.replace(".", "-"));
1666
+ const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1667
+ return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1668
+ };
1669
+ var getSubratioDifference = (base, ratio) => {
1670
+ const diff = base * ratio - base;
1671
+ const subRatio = diff / 1.618;
1672
+ const first = base * ratio - subRatio;
1673
+ const second = base + subRatio;
1674
+ const middle = (first + second) / 2;
1675
+ return [first, middle, second];
1676
+ };
1677
+ var getSubratio = (base, ratio) => {
1678
+ return getSubratioDifference(base, ratio).map((v) => v / base);
1679
+ };
1642
1680
  var generateSubSequence = (props, sequenceProps) => {
1643
1681
  const { key, base, value, ratio, variable, index } = props;
1644
1682
  const next = value * ratio;
1645
- const diff = next - value;
1646
- const smallscale = diff / 1.618;
1647
- const valueRounded = ~~value;
1648
- const nextRounded = ~~next;
1649
- const diffRounded = nextRounded - valueRounded;
1650
- let arr = [];
1651
- const first = next - smallscale;
1652
- const second = value + smallscale;
1653
- const middle = (first + second) / 2;
1683
+ const diffRounded = ~~next - ~~value;
1684
+ let arr;
1685
+ const [first, middle, second] = getSubratioDifference(value, ratio);
1654
1686
  if (diffRounded > 16)
1655
1687
  arr = [first, middle, second];
1656
1688
  else
1657
1689
  arr = [first, second];
1658
- arr.map((v, k) => {
1690
+ arr.forEach((v, k) => {
1659
1691
  const scaling = ~~(v / base * 1e3) / 1e3;
1660
1692
  const newVar = variable + (k + 1);
1693
+ const newIndex = index + (k + 1) / 10;
1694
+ const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
1661
1695
  const props2 = {
1662
1696
  key: key + (k + 1),
1663
1697
  variable: newVar,
1664
1698
  value: v,
1665
1699
  scaling,
1666
- index: index + (k + 1) / 10
1700
+ scalingVariable,
1701
+ index: newIndex
1667
1702
  };
1668
- return setSequenceValue(props2, sequenceProps);
1703
+ setSequenceValue(props2, sequenceProps);
1669
1704
  });
1670
1705
  };
1671
1706
  var switchSequenceOnNegative = (key, base, ratio) => {
@@ -1681,12 +1716,14 @@ var generateSequence = (sequenceProps) => {
1681
1716
  const value = switchSequenceOnNegative(key, base, ratio);
1682
1717
  const scaling = ~~(value / base * 100) / 100;
1683
1718
  const variable = prefix + letterKey;
1719
+ const scalingVariable = setScalingVar(key, sequenceProps);
1684
1720
  const props = {
1685
1721
  key: letterKey,
1686
1722
  variable,
1687
1723
  value,
1688
1724
  base,
1689
1725
  scaling,
1726
+ scalingVariable,
1690
1727
  ratio,
1691
1728
  index: key
1692
1729
  };
@@ -1770,68 +1807,122 @@ var findHeadings = (propertyNames) => {
1770
1807
 
1771
1808
  // src/utils/var.js
1772
1809
  var import_utils7 = __toESM(require_cjs(), 1);
1773
- var applySequenceVars = (props, mediaName, options = {}) => {
1810
+ var applyGlobalVars = (vars, obj, options) => {
1774
1811
  const CONFIG2 = getActiveConfig();
1775
- const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1776
- const unit = props.unit || UNIT2.default;
1777
- const { sequence, scales } = props;
1812
+ const { UNIT: UNIT2 } = CONFIG2;
1813
+ const unit = obj.unit || UNIT2.default;
1814
+ const { base, ratio, type } = obj;
1815
+ const prefix = "--" + (type && type.replace(".", "-"));
1816
+ vars[`${prefix}-base`] = base;
1817
+ vars[`${prefix}-unit`] = unit;
1818
+ const ratioVar = `${prefix}-ratio`;
1819
+ vars[ratioVar] = ratio;
1820
+ const [first, middle, second] = getSubratio(base, ratio);
1821
+ vars[`${prefix}-sub-ratio-1`] = first;
1822
+ vars[`${prefix}-sub-ratio-2`] = middle;
1823
+ vars[`${prefix}-sub-ratio-3`] = second;
1824
+ };
1825
+ var applySequenceVars = (FACTORY2, options = {}) => {
1826
+ const CONFIG2 = getActiveConfig();
1827
+ const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1828
+ const unit = FACTORY2.unit || UNIT2.default;
1829
+ const { mediaRegenerate, sequence, scales } = FACTORY2;
1830
+ if (!mediaRegenerate) {
1831
+ applyGlobalVars(CSS_VARS2, FACTORY2, options);
1832
+ }
1778
1833
  for (const key in sequence) {
1779
1834
  const item = sequence[key];
1780
- const value = (props.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1781
- if (mediaName) {
1782
- const query = MEDIA2[mediaName];
1783
- if (!query) {
1784
- if (CONFIG2.verbose)
1785
- console.warn("Can't find query ", query);
1786
- }
1787
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
1788
- if (!underMediaQuery)
1789
- underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1790
- underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
1791
- CSS_VARS2[item.variable + "_" + mediaName] = value;
1835
+ const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1836
+ if (!mediaRegenerate) {
1837
+ CSS_VARS2[item.variable + "_default"] = value;
1838
+ CSS_VARS2[item.variable] = item.scalingVariable;
1839
+ continue;
1840
+ }
1841
+ if (options.useDefault === false) {
1842
+ CSS_VARS2[item.variable] = value;
1792
1843
  } else {
1793
- if (options.useDefault === false) {
1794
- CSS_VARS2[item.variable] = value;
1795
- } else {
1796
- CSS_VARS2[item.variable + "_default"] = value;
1797
- CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1798
- }
1844
+ CSS_VARS2[item.variable + "_default"] = value;
1845
+ CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1799
1846
  }
1800
1847
  }
1801
1848
  };
1849
+ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
1850
+ const CONFIG2 = getActiveConfig();
1851
+ const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1852
+ const mediaName = media.slice(1);
1853
+ const unit = FACTORY2.unit || UNIT2.default;
1854
+ const { mediaRegenerate } = FACTORY2;
1855
+ const { sequence, scales } = FACTORY2[media];
1856
+ const query = MEDIA2[mediaName];
1857
+ if (!query && CONFIG2.verbose)
1858
+ console.warn("Can't find media query ", query);
1859
+ if (!mediaRegenerate) {
1860
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
1861
+ if (!underMediaQuery)
1862
+ underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1863
+ applyGlobalVars(underMediaQuery, FACTORY2[media], options);
1864
+ return;
1865
+ }
1866
+ for (const key in sequence) {
1867
+ const item = sequence[key];
1868
+ const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1869
+ if (!query && CONFIG2.verbose)
1870
+ console.warn("Can't find query ", query);
1871
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
1872
+ if (!underMediaQuery)
1873
+ underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1874
+ underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
1875
+ CSS_VARS2[item.variable + "_" + mediaName] = value;
1876
+ }
1877
+ console.log(CSS_VARS2);
1878
+ };
1802
1879
 
1803
1880
  // src/utils/sprite.js
1804
1881
  var import_utils8 = __toESM(require_cjs(), 1);
1805
1882
 
1806
1883
  // src/system/typography.js
1807
- var runThroughMedia = (props) => {
1884
+ var runThroughMedia = (FACTORY2) => {
1808
1885
  const CONFIG2 = getActiveConfig();
1809
1886
  const { TYPOGRAPHY: TYPOGRAPHY2, MEDIA: MEDIA2 } = CONFIG2;
1810
- for (const prop in props) {
1811
- const mediaProps = props[prop];
1812
- if (prop.slice(0, 1) === "@") {
1813
- const { type, base, ratio, range, subSequence, h1Matches, unit } = props;
1814
- (0, import_utils9.merge)(mediaProps, {
1815
- type,
1816
- base,
1817
- ratio,
1818
- range,
1819
- subSequence,
1820
- h1Matches,
1821
- unit,
1822
- sequence: {},
1823
- scales: {},
1824
- templates: {},
1825
- vars: {}
1826
- });
1827
- generateSequence(mediaProps);
1828
- const mediaName = prop.slice(1);
1829
- applySequenceVars(mediaProps, mediaName);
1830
- const query = MEDIA2[mediaName];
1831
- TYPOGRAPHY2.templates[`@media screen and ${query}`] = {
1832
- fontSize: mediaProps.base / TYPOGRAPHY2.browserDefault + unit
1833
- };
1887
+ for (const prop in FACTORY2) {
1888
+ const isPropMedia = prop.slice(0, 1) === "@";
1889
+ const mediaValue = FACTORY2[prop];
1890
+ if (!isPropMedia)
1891
+ continue;
1892
+ const { mediaRegenerate } = FACTORY2;
1893
+ const mediaName = prop.slice(1);
1894
+ const {
1895
+ type,
1896
+ base,
1897
+ ratio,
1898
+ range,
1899
+ subSequence,
1900
+ h1Matches,
1901
+ unit
1902
+ } = FACTORY2;
1903
+ (0, import_utils9.merge)(mediaValue, {
1904
+ type,
1905
+ base,
1906
+ ratio,
1907
+ range,
1908
+ subSequence,
1909
+ h1Matches,
1910
+ unit,
1911
+ sequence: {},
1912
+ scales: {},
1913
+ templates: {},
1914
+ vars: {}
1915
+ });
1916
+ const query = MEDIA2[mediaName];
1917
+ TYPOGRAPHY2.templates[`@media screen and ${query}`] = {
1918
+ fontSize: mediaValue.base / TYPOGRAPHY2.browserDefault + unit
1919
+ };
1920
+ if (!mediaRegenerate) {
1921
+ applyMediaSequenceVars(FACTORY2, prop);
1922
+ continue;
1834
1923
  }
1924
+ generateSequence(mediaValue);
1925
+ applyMediaSequenceVars(FACTORY2, prop);
1835
1926
  }
1836
1927
  };
1837
1928
  var applyHeadings = (props) => {
@@ -1434,6 +1434,7 @@ var defaultProps = {
1434
1434
  h1Matches: 6,
1435
1435
  lineHeight: 1.5,
1436
1436
  subSequence: true,
1437
+ mediaRegenerate: false,
1437
1438
  unit: "em",
1438
1439
  templates: {},
1439
1440
  sequence: {},
@@ -1489,6 +1490,7 @@ var defaultProps2 = {
1489
1490
  ratio: SEQUENCE.phi,
1490
1491
  range: [-5, 15],
1491
1492
  subSequence: true,
1493
+ mediaRegenerate: false,
1492
1494
  unit: "em",
1493
1495
  sequence: {},
1494
1496
  scales: {},
@@ -1516,6 +1518,7 @@ var defaultProps3 = {
1516
1518
  type: "timing",
1517
1519
  ratio: SEQUENCE["perfect-fourth"],
1518
1520
  range: [-3, 12],
1521
+ mediaRegenerate: false,
1519
1522
  unit: "ms",
1520
1523
  sequence: {},
1521
1524
  scales: {},
@@ -1742,45 +1745,74 @@ var numToLetterMap = {
1742
1745
  19: "T"
1743
1746
  };
1744
1747
  var setSequenceValue = (props, sequenceProps) => {
1745
- const { key, variable, value, scaling, index } = props;
1748
+ const { key, variable, value, scaling, index, scalingVariable } = props;
1746
1749
  sequenceProps.sequence[key] = {
1747
1750
  key,
1748
1751
  decimal: ~~(value * 100) / 100,
1749
1752
  val: ~~value,
1750
1753
  scaling,
1751
1754
  index,
1755
+ scalingVariable,
1752
1756
  variable
1753
1757
  };
1754
1758
  sequenceProps.scales[key] = scaling;
1755
1759
  sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1756
1760
  };
1761
+ var setScalingVar = (key, sequenceProps) => {
1762
+ const { type } = sequenceProps;
1763
+ if (key === 0)
1764
+ return "1em";
1765
+ const prefix = "--" + (type && type.replace(".", "-"));
1766
+ const ratioVar = `${prefix}-ratio`;
1767
+ if (key > 0) {
1768
+ const prevLetterKey = numToLetterMap[key - 1];
1769
+ return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
1770
+ }
1771
+ if (key < 0) {
1772
+ const nextLetterKey = numToLetterMap[key + 1];
1773
+ return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1774
+ }
1775
+ };
1776
+ var setSubScalingVar = (index, arr, variable, sequenceProps) => {
1777
+ const { type } = sequenceProps;
1778
+ const skipMiddle = index === 2 && arr.length === 2;
1779
+ const indexMapWithLength = skipMiddle ? index + 1 : index;
1780
+ const prefix = "--" + (type && type.replace(".", "-"));
1781
+ const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1782
+ return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1783
+ };
1784
+ var getSubratioDifference = (base, ratio) => {
1785
+ const diff = base * ratio - base;
1786
+ const subRatio = diff / 1.618;
1787
+ const first = base * ratio - subRatio;
1788
+ const second = base + subRatio;
1789
+ const middle = (first + second) / 2;
1790
+ return [first, middle, second];
1791
+ };
1757
1792
  var generateSubSequence = (props, sequenceProps) => {
1758
1793
  const { key, base, value, ratio, variable, index } = props;
1759
1794
  const next = value * ratio;
1760
- const diff = next - value;
1761
- const smallscale = diff / 1.618;
1762
- const valueRounded = ~~value;
1763
- const nextRounded = ~~next;
1764
- const diffRounded = nextRounded - valueRounded;
1765
- let arr = [];
1766
- const first = next - smallscale;
1767
- const second = value + smallscale;
1768
- const middle = (first + second) / 2;
1795
+ const diffRounded = ~~next - ~~value;
1796
+ let arr;
1797
+ const [first, middle, second] = getSubratioDifference(value, ratio);
1769
1798
  if (diffRounded > 16)
1770
1799
  arr = [first, middle, second];
1771
1800
  else
1772
1801
  arr = [first, second];
1773
- arr.map((v, k) => {
1802
+ arr.forEach((v, k) => {
1774
1803
  const scaling = ~~(v / base * 1e3) / 1e3;
1775
1804
  const newVar = variable + (k + 1);
1805
+ const newIndex = index + (k + 1) / 10;
1806
+ const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
1776
1807
  const props2 = {
1777
1808
  key: key + (k + 1),
1778
1809
  variable: newVar,
1779
1810
  value: v,
1780
1811
  scaling,
1781
- index: index + (k + 1) / 10
1812
+ scalingVariable,
1813
+ index: newIndex
1782
1814
  };
1783
- return setSequenceValue(props2, sequenceProps);
1815
+ setSequenceValue(props2, sequenceProps);
1784
1816
  });
1785
1817
  };
1786
1818
  var switchSequenceOnNegative = (key, base, ratio) => {
@@ -1796,12 +1828,14 @@ var generateSequence = (sequenceProps) => {
1796
1828
  const value = switchSequenceOnNegative(key, base, ratio);
1797
1829
  const scaling = ~~(value / base * 100) / 100;
1798
1830
  const variable = prefix + letterKey;
1831
+ const scalingVariable = setScalingVar(key, sequenceProps);
1799
1832
  const props = {
1800
1833
  key: letterKey,
1801
1834
  variable,
1802
1835
  value,
1803
1836
  base,
1804
1837
  scaling,
1838
+ scalingVariable,
1805
1839
  ratio,
1806
1840
  index: key
1807
1841
  };
@@ -2118,10 +2152,22 @@ var transformTextStroke = (stroke) => {
2118
2152
  return v;
2119
2153
  }).join(" ");
2120
2154
  };
2121
- var transformShadow = (sh, globalTheme) => {
2122
- return sh.split(",").map((shadow) => getShadow(shadow, globalTheme)).join(",");
2123
- };
2124
- var transformBoxShadow = (sh, globalTheme) => getShadow(sh, globalTheme);
2155
+ var transformShadow = (sh, globalTheme) => getShadow(sh, globalTheme);
2156
+ var transformBoxShadow = (shadows) => shadows.split("|").map((shadow) => {
2157
+ return shadow.split(", ").map((v) => {
2158
+ v = v.trim();
2159
+ if (v.slice(0, 2) === "--")
2160
+ return `var(${v})`;
2161
+ if (getColor(v).length > 2)
2162
+ return getColor(v);
2163
+ if (v.includes("px") || v.slice(-2) === "em")
2164
+ return v;
2165
+ const arr = v.split(" ");
2166
+ if (!arr.length)
2167
+ return v;
2168
+ return arr.map((v2) => getSpacingByKey(v2, "shadow").shadow).join(" ");
2169
+ }).join(" ");
2170
+ }).join(",");
2125
2171
  var transformBackgroundImage = (backgroundImage, globalTheme) => {
2126
2172
  const CONFIG2 = getActiveConfig();
2127
2173
  return backgroundImage.split(", ").map((v) => {