@symbo.ls/scratch 2.11.226 → 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
  };
@@ -1346,6 +1346,8 @@ var require_cjs2 = __commonJS({
1346
1346
  // src/utils/index.js
1347
1347
  var utils_exports = {};
1348
1348
  __export(utils_exports, {
1349
+ applyGlobalVars: () => applyGlobalVars,
1350
+ applyMediaSequenceVars: () => applyMediaSequenceVars,
1349
1351
  applySequenceVars: () => applySequenceVars,
1350
1352
  changeLightness: () => changeLightness,
1351
1353
  colorStringToRgbaArray: () => colorStringToRgbaArray,
@@ -1365,6 +1367,8 @@ __export(utils_exports, {
1365
1367
  getRgbTone: () => getRgbTone,
1366
1368
  getSequenceValue: () => getSequenceValue,
1367
1369
  getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
1370
+ getSubratio: () => getSubratio,
1371
+ getSubratioDifference: () => getSubratioDifference,
1368
1372
  hexToRgb: () => hexToRgb,
1369
1373
  hexToRgbArray: () => hexToRgbArray,
1370
1374
  hexToRgba: () => hexToRgba,
@@ -1381,6 +1385,8 @@ __export(utils_exports, {
1381
1385
  setCustomFont: () => setCustomFont,
1382
1386
  setCustomFontMedia: () => setCustomFontMedia,
1383
1387
  setInCustomFontMedia: () => setInCustomFontMedia,
1388
+ setScalingVar: () => setScalingVar,
1389
+ setSubScalingVar: () => setSubScalingVar,
1384
1390
  setVariables: () => setVariables
1385
1391
  });
1386
1392
  module.exports = __toCommonJS(utils_exports);
@@ -1674,6 +1680,7 @@ var defaultProps = {
1674
1680
  h1Matches: 6,
1675
1681
  lineHeight: 1.5,
1676
1682
  subSequence: true,
1683
+ mediaRegenerate: false,
1677
1684
  unit: "em",
1678
1685
  templates: {},
1679
1686
  sequence: {},
@@ -1729,6 +1736,7 @@ var defaultProps2 = {
1729
1736
  ratio: SEQUENCE.phi,
1730
1737
  range: [-5, 15],
1731
1738
  subSequence: true,
1739
+ mediaRegenerate: false,
1732
1740
  unit: "em",
1733
1741
  sequence: {},
1734
1742
  scales: {},
@@ -1756,6 +1764,7 @@ var defaultProps3 = {
1756
1764
  type: "timing",
1757
1765
  ratio: SEQUENCE["perfect-fourth"],
1758
1766
  range: [-3, 12],
1767
+ mediaRegenerate: false,
1759
1768
  unit: "ms",
1760
1769
  sequence: {},
1761
1770
  scales: {},
@@ -1856,45 +1865,77 @@ var numToLetterMap = {
1856
1865
  19: "T"
1857
1866
  };
1858
1867
  var setSequenceValue = (props, sequenceProps) => {
1859
- const { key, variable, value, scaling, index } = props;
1868
+ const { key, variable, value, scaling, index, scalingVariable } = props;
1860
1869
  sequenceProps.sequence[key] = {
1861
1870
  key,
1862
1871
  decimal: ~~(value * 100) / 100,
1863
1872
  val: ~~value,
1864
1873
  scaling,
1865
1874
  index,
1875
+ scalingVariable,
1866
1876
  variable
1867
1877
  };
1868
1878
  sequenceProps.scales[key] = scaling;
1869
1879
  sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1870
1880
  };
1881
+ var setScalingVar = (key, sequenceProps) => {
1882
+ const { type } = sequenceProps;
1883
+ if (key === 0)
1884
+ return "1em";
1885
+ const prefix = "--" + (type && type.replace(".", "-"));
1886
+ const ratioVar = `${prefix}-ratio`;
1887
+ if (key > 0) {
1888
+ const prevLetterKey = numToLetterMap[key - 1];
1889
+ return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
1890
+ }
1891
+ if (key < 0) {
1892
+ const nextLetterKey = numToLetterMap[key + 1];
1893
+ return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1894
+ }
1895
+ };
1896
+ var setSubScalingVar = (index, arr, variable, sequenceProps) => {
1897
+ const { type } = sequenceProps;
1898
+ const skipMiddle = index === 2 && arr.length === 2;
1899
+ const indexMapWithLength = skipMiddle ? index + 1 : index;
1900
+ const prefix = "--" + (type && type.replace(".", "-"));
1901
+ const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1902
+ return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1903
+ };
1904
+ var getSubratioDifference = (base, ratio) => {
1905
+ const diff = base * ratio - base;
1906
+ const subRatio = diff / 1.618;
1907
+ const first = base * ratio - subRatio;
1908
+ const second = base + subRatio;
1909
+ const middle = (first + second) / 2;
1910
+ return [first, middle, second];
1911
+ };
1912
+ var getSubratio = (base, ratio) => {
1913
+ return getSubratioDifference(base, ratio).map((v) => v / base);
1914
+ };
1871
1915
  var generateSubSequence = (props, sequenceProps) => {
1872
1916
  const { key, base, value, ratio, variable, index } = props;
1873
1917
  const next = value * ratio;
1874
- const diff = next - value;
1875
- const smallscale = diff / 1.618;
1876
- const valueRounded = ~~value;
1877
- const nextRounded = ~~next;
1878
- const diffRounded = nextRounded - valueRounded;
1879
- let arr = [];
1880
- const first = next - smallscale;
1881
- const second = value + smallscale;
1882
- const middle = (first + second) / 2;
1918
+ const diffRounded = ~~next - ~~value;
1919
+ let arr;
1920
+ const [first, middle, second] = getSubratioDifference(value, ratio);
1883
1921
  if (diffRounded > 16)
1884
1922
  arr = [first, middle, second];
1885
1923
  else
1886
1924
  arr = [first, second];
1887
- arr.map((v, k) => {
1925
+ arr.forEach((v, k) => {
1888
1926
  const scaling = ~~(v / base * 1e3) / 1e3;
1889
1927
  const newVar = variable + (k + 1);
1928
+ const newIndex = index + (k + 1) / 10;
1929
+ const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
1890
1930
  const props2 = {
1891
1931
  key: key + (k + 1),
1892
1932
  variable: newVar,
1893
1933
  value: v,
1894
1934
  scaling,
1895
- index: index + (k + 1) / 10
1935
+ scalingVariable,
1936
+ index: newIndex
1896
1937
  };
1897
- return setSequenceValue(props2, sequenceProps);
1938
+ setSequenceValue(props2, sequenceProps);
1898
1939
  });
1899
1940
  };
1900
1941
  var switchSequenceOnNegative = (key, base, ratio) => {
@@ -1910,12 +1951,14 @@ var generateSequence = (sequenceProps) => {
1910
1951
  const value = switchSequenceOnNegative(key, base, ratio);
1911
1952
  const scaling = ~~(value / base * 100) / 100;
1912
1953
  const variable = prefix + letterKey;
1954
+ const scalingVariable = setScalingVar(key, sequenceProps);
1913
1955
  const props = {
1914
1956
  key: letterKey,
1915
1957
  variable,
1916
1958
  value,
1917
1959
  base,
1918
1960
  scaling,
1961
+ scalingVariable,
1919
1962
  ratio,
1920
1963
  index: key
1921
1964
  };
@@ -2007,35 +2050,75 @@ var setVariables = (result, key) => {
2007
2050
  CSS_VARS2[result.var] = result.value;
2008
2051
  }
2009
2052
  };
2010
- var applySequenceVars = (props, mediaName, options = {}) => {
2053
+ var applyGlobalVars = (vars, obj, options) => {
2011
2054
  const CONFIG2 = getActiveConfig();
2012
- const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
2013
- const unit = props.unit || UNIT2.default;
2014
- const { sequence, scales } = props;
2055
+ const { UNIT: UNIT2 } = CONFIG2;
2056
+ const unit = obj.unit || UNIT2.default;
2057
+ const { base, ratio, type } = obj;
2058
+ const prefix = "--" + (type && type.replace(".", "-"));
2059
+ vars[`${prefix}-base`] = base;
2060
+ vars[`${prefix}-unit`] = unit;
2061
+ const ratioVar = `${prefix}-ratio`;
2062
+ vars[ratioVar] = ratio;
2063
+ const [first, middle, second] = getSubratio(base, ratio);
2064
+ vars[`${prefix}-sub-ratio-1`] = first;
2065
+ vars[`${prefix}-sub-ratio-2`] = middle;
2066
+ vars[`${prefix}-sub-ratio-3`] = second;
2067
+ };
2068
+ var applySequenceVars = (FACTORY2, options = {}) => {
2069
+ const CONFIG2 = getActiveConfig();
2070
+ const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
2071
+ const unit = FACTORY2.unit || UNIT2.default;
2072
+ const { mediaRegenerate, sequence, scales } = FACTORY2;
2073
+ if (!mediaRegenerate) {
2074
+ applyGlobalVars(CSS_VARS2, FACTORY2, options);
2075
+ }
2015
2076
  for (const key in sequence) {
2016
2077
  const item = sequence[key];
2017
- const value = (props.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
2018
- if (mediaName) {
2019
- const query = MEDIA2[mediaName];
2020
- if (!query) {
2021
- if (CONFIG2.verbose)
2022
- console.warn("Can't find query ", query);
2023
- }
2024
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
2025
- if (!underMediaQuery)
2026
- underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
2027
- underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
2028
- CSS_VARS2[item.variable + "_" + mediaName] = value;
2078
+ const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
2079
+ if (!mediaRegenerate) {
2080
+ CSS_VARS2[item.variable + "_default"] = value;
2081
+ CSS_VARS2[item.variable] = item.scalingVariable;
2082
+ continue;
2083
+ }
2084
+ if (options.useDefault === false) {
2085
+ CSS_VARS2[item.variable] = value;
2029
2086
  } else {
2030
- if (options.useDefault === false) {
2031
- CSS_VARS2[item.variable] = value;
2032
- } else {
2033
- CSS_VARS2[item.variable + "_default"] = value;
2034
- CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
2035
- }
2087
+ CSS_VARS2[item.variable + "_default"] = value;
2088
+ CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
2036
2089
  }
2037
2090
  }
2038
2091
  };
2092
+ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
2093
+ const CONFIG2 = getActiveConfig();
2094
+ const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
2095
+ const mediaName = media.slice(1);
2096
+ const unit = FACTORY2.unit || UNIT2.default;
2097
+ const { mediaRegenerate } = FACTORY2;
2098
+ const { sequence, scales } = FACTORY2[media];
2099
+ const query = MEDIA2[mediaName];
2100
+ if (!query && CONFIG2.verbose)
2101
+ console.warn("Can't find media query ", query);
2102
+ if (!mediaRegenerate) {
2103
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
2104
+ if (!underMediaQuery)
2105
+ underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
2106
+ applyGlobalVars(underMediaQuery, FACTORY2[media], options);
2107
+ return;
2108
+ }
2109
+ for (const key in sequence) {
2110
+ const item = sequence[key];
2111
+ const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
2112
+ if (!query && CONFIG2.verbose)
2113
+ console.warn("Can't find query ", query);
2114
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
2115
+ if (!underMediaQuery)
2116
+ underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
2117
+ underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
2118
+ CSS_VARS2[item.variable + "_" + mediaName] = value;
2119
+ }
2120
+ console.log(CSS_VARS2);
2121
+ };
2039
2122
 
2040
2123
  // src/utils/sprite.js
2041
2124
  var import_utils8 = __toESM(require_cjs2(), 1);