@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.
@@ -1456,6 +1456,7 @@ var defaultProps = {
1456
1456
  h1Matches: 6,
1457
1457
  lineHeight: 1.5,
1458
1458
  subSequence: true,
1459
+ mediaRegenerate: false,
1459
1460
  unit: "em",
1460
1461
  templates: {},
1461
1462
  sequence: {},
@@ -1511,6 +1512,7 @@ var defaultProps2 = {
1511
1512
  ratio: SEQUENCE.phi,
1512
1513
  range: [-5, 15],
1513
1514
  subSequence: true,
1515
+ mediaRegenerate: false,
1514
1516
  unit: "em",
1515
1517
  sequence: {},
1516
1518
  scales: {},
@@ -1538,6 +1540,7 @@ var defaultProps3 = {
1538
1540
  type: "timing",
1539
1541
  ratio: SEQUENCE["perfect-fourth"],
1540
1542
  range: [-3, 12],
1543
+ mediaRegenerate: false,
1541
1544
  unit: "ms",
1542
1545
  sequence: {},
1543
1546
  scales: {},
@@ -1787,45 +1790,77 @@ var numToLetterMap = {
1787
1790
  19: "T"
1788
1791
  };
1789
1792
  var setSequenceValue = (props, sequenceProps) => {
1790
- const { key, variable, value, scaling, index } = props;
1793
+ const { key, variable, value, scaling, index, scalingVariable } = props;
1791
1794
  sequenceProps.sequence[key] = {
1792
1795
  key,
1793
1796
  decimal: ~~(value * 100) / 100,
1794
1797
  val: ~~value,
1795
1798
  scaling,
1796
1799
  index,
1800
+ scalingVariable,
1797
1801
  variable
1798
1802
  };
1799
1803
  sequenceProps.scales[key] = scaling;
1800
1804
  sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1801
1805
  };
1806
+ var setScalingVar = (key, sequenceProps) => {
1807
+ const { type } = sequenceProps;
1808
+ if (key === 0)
1809
+ return "1em";
1810
+ const prefix = "--" + (type && type.replace(".", "-"));
1811
+ const ratioVar = `${prefix}-ratio`;
1812
+ if (key > 0) {
1813
+ const prevLetterKey = numToLetterMap[key - 1];
1814
+ return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
1815
+ }
1816
+ if (key < 0) {
1817
+ const nextLetterKey = numToLetterMap[key + 1];
1818
+ return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1819
+ }
1820
+ };
1821
+ var setSubScalingVar = (index, arr, variable, sequenceProps) => {
1822
+ const { type } = sequenceProps;
1823
+ const skipMiddle = index === 2 && arr.length === 2;
1824
+ const indexMapWithLength = skipMiddle ? index + 1 : index;
1825
+ const prefix = "--" + (type && type.replace(".", "-"));
1826
+ const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1827
+ return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1828
+ };
1829
+ var getSubratioDifference = (base, ratio) => {
1830
+ const diff = base * ratio - base;
1831
+ const subRatio = diff / 1.618;
1832
+ const first = base * ratio - subRatio;
1833
+ const second = base + subRatio;
1834
+ const middle = (first + second) / 2;
1835
+ return [first, middle, second];
1836
+ };
1837
+ var getSubratio = (base, ratio) => {
1838
+ return getSubratioDifference(base, ratio).map((v) => v / base);
1839
+ };
1802
1840
  var generateSubSequence = (props, sequenceProps) => {
1803
1841
  const { key, base, value, ratio, variable, index } = props;
1804
1842
  const next = value * ratio;
1805
- const diff = next - value;
1806
- const smallscale = diff / 1.618;
1807
- const valueRounded = ~~value;
1808
- const nextRounded = ~~next;
1809
- const diffRounded = nextRounded - valueRounded;
1810
- let arr = [];
1811
- const first = next - smallscale;
1812
- const second = value + smallscale;
1813
- const middle = (first + second) / 2;
1843
+ const diffRounded = ~~next - ~~value;
1844
+ let arr;
1845
+ const [first, middle, second] = getSubratioDifference(value, ratio);
1814
1846
  if (diffRounded > 16)
1815
1847
  arr = [first, middle, second];
1816
1848
  else
1817
1849
  arr = [first, second];
1818
- arr.map((v, k) => {
1850
+ arr.forEach((v, k) => {
1819
1851
  const scaling = ~~(v / base * 1e3) / 1e3;
1820
1852
  const newVar = variable + (k + 1);
1853
+ const newIndex = index + (k + 1) / 10;
1854
+ const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
1821
1855
  const props2 = {
1822
1856
  key: key + (k + 1),
1823
1857
  variable: newVar,
1824
1858
  value: v,
1825
1859
  scaling,
1826
- index: index + (k + 1) / 10
1860
+ scalingVariable,
1861
+ index: newIndex
1827
1862
  };
1828
- return setSequenceValue(props2, sequenceProps);
1863
+ setSequenceValue(props2, sequenceProps);
1829
1864
  });
1830
1865
  };
1831
1866
  var switchSequenceOnNegative = (key, base, ratio) => {
@@ -1841,12 +1876,14 @@ var generateSequence = (sequenceProps) => {
1841
1876
  const value = switchSequenceOnNegative(key, base, ratio);
1842
1877
  const scaling = ~~(value / base * 100) / 100;
1843
1878
  const variable = prefix + letterKey;
1879
+ const scalingVariable = setScalingVar(key, sequenceProps);
1844
1880
  const props = {
1845
1881
  key: letterKey,
1846
1882
  variable,
1847
1883
  value,
1848
1884
  base,
1849
1885
  scaling,
1886
+ scalingVariable,
1850
1887
  ratio,
1851
1888
  index: key
1852
1889
  };
@@ -1930,35 +1967,75 @@ var findHeadings = (propertyNames) => {
1930
1967
 
1931
1968
  // src/utils/var.js
1932
1969
  var import_utils7 = __toESM(require_cjs(), 1);
1933
- var applySequenceVars = (props, mediaName, options = {}) => {
1970
+ var applyGlobalVars = (vars, obj, options) => {
1934
1971
  const CONFIG2 = getActiveConfig();
1935
- const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1936
- const unit = props.unit || UNIT2.default;
1937
- const { sequence, scales } = props;
1972
+ const { UNIT: UNIT2 } = CONFIG2;
1973
+ const unit = obj.unit || UNIT2.default;
1974
+ const { base, ratio, type } = obj;
1975
+ const prefix = "--" + (type && type.replace(".", "-"));
1976
+ vars[`${prefix}-base`] = base;
1977
+ vars[`${prefix}-unit`] = unit;
1978
+ const ratioVar = `${prefix}-ratio`;
1979
+ vars[ratioVar] = ratio;
1980
+ const [first, middle, second] = getSubratio(base, ratio);
1981
+ vars[`${prefix}-sub-ratio-1`] = first;
1982
+ vars[`${prefix}-sub-ratio-2`] = middle;
1983
+ vars[`${prefix}-sub-ratio-3`] = second;
1984
+ };
1985
+ var applySequenceVars = (FACTORY2, options = {}) => {
1986
+ const CONFIG2 = getActiveConfig();
1987
+ const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1988
+ const unit = FACTORY2.unit || UNIT2.default;
1989
+ const { mediaRegenerate, sequence, scales } = FACTORY2;
1990
+ if (!mediaRegenerate) {
1991
+ applyGlobalVars(CSS_VARS2, FACTORY2, options);
1992
+ }
1938
1993
  for (const key in sequence) {
1939
1994
  const item = sequence[key];
1940
- const value = (props.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1941
- if (mediaName) {
1942
- const query = MEDIA2[mediaName];
1943
- if (!query) {
1944
- if (CONFIG2.verbose)
1945
- console.warn("Can't find query ", query);
1946
- }
1947
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
1948
- if (!underMediaQuery)
1949
- underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1950
- underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
1951
- CSS_VARS2[item.variable + "_" + mediaName] = value;
1995
+ const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1996
+ if (!mediaRegenerate) {
1997
+ CSS_VARS2[item.variable + "_default"] = value;
1998
+ CSS_VARS2[item.variable] = item.scalingVariable;
1999
+ continue;
2000
+ }
2001
+ if (options.useDefault === false) {
2002
+ CSS_VARS2[item.variable] = value;
1952
2003
  } else {
1953
- if (options.useDefault === false) {
1954
- CSS_VARS2[item.variable] = value;
1955
- } else {
1956
- CSS_VARS2[item.variable + "_default"] = value;
1957
- CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1958
- }
2004
+ CSS_VARS2[item.variable + "_default"] = value;
2005
+ CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1959
2006
  }
1960
2007
  }
1961
2008
  };
2009
+ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
2010
+ const CONFIG2 = getActiveConfig();
2011
+ const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
2012
+ const mediaName = media.slice(1);
2013
+ const unit = FACTORY2.unit || UNIT2.default;
2014
+ const { mediaRegenerate } = FACTORY2;
2015
+ const { sequence, scales } = FACTORY2[media];
2016
+ const query = MEDIA2[mediaName];
2017
+ if (!query && CONFIG2.verbose)
2018
+ console.warn("Can't find media query ", query);
2019
+ if (!mediaRegenerate) {
2020
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
2021
+ if (!underMediaQuery)
2022
+ underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
2023
+ applyGlobalVars(underMediaQuery, FACTORY2[media], options);
2024
+ return;
2025
+ }
2026
+ for (const key in sequence) {
2027
+ const item = sequence[key];
2028
+ const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
2029
+ if (!query && CONFIG2.verbose)
2030
+ console.warn("Can't find query ", query);
2031
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
2032
+ if (!underMediaQuery)
2033
+ underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
2034
+ underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
2035
+ CSS_VARS2[item.variable + "_" + mediaName] = value;
2036
+ }
2037
+ console.log(CSS_VARS2);
2038
+ };
1962
2039
 
1963
2040
  // src/utils/sprite.js
1964
2041
  var import_utils8 = __toESM(require_cjs(), 1);
@@ -2401,34 +2478,48 @@ var setFontFamily = (val, key) => {
2401
2478
 
2402
2479
  // src/system/typography.js
2403
2480
  var import_utils15 = __toESM(require_cjs(), 1);
2404
- var runThroughMedia = (props) => {
2481
+ var runThroughMedia = (FACTORY2) => {
2405
2482
  const CONFIG2 = getActiveConfig();
2406
2483
  const { TYPOGRAPHY: TYPOGRAPHY2, MEDIA: MEDIA2 } = CONFIG2;
2407
- for (const prop in props) {
2408
- const mediaProps = props[prop];
2409
- if (prop.slice(0, 1) === "@") {
2410
- const { type, base, ratio, range, subSequence, h1Matches, unit } = props;
2411
- (0, import_utils15.merge)(mediaProps, {
2412
- type,
2413
- base,
2414
- ratio,
2415
- range,
2416
- subSequence,
2417
- h1Matches,
2418
- unit,
2419
- sequence: {},
2420
- scales: {},
2421
- templates: {},
2422
- vars: {}
2423
- });
2424
- generateSequence(mediaProps);
2425
- const mediaName = prop.slice(1);
2426
- applySequenceVars(mediaProps, mediaName);
2427
- const query = MEDIA2[mediaName];
2428
- TYPOGRAPHY2.templates[`@media screen and ${query}`] = {
2429
- fontSize: mediaProps.base / TYPOGRAPHY2.browserDefault + unit
2430
- };
2484
+ for (const prop in FACTORY2) {
2485
+ const isPropMedia = prop.slice(0, 1) === "@";
2486
+ const mediaValue = FACTORY2[prop];
2487
+ if (!isPropMedia)
2488
+ continue;
2489
+ const { mediaRegenerate } = FACTORY2;
2490
+ const mediaName = prop.slice(1);
2491
+ const {
2492
+ type,
2493
+ base,
2494
+ ratio,
2495
+ range,
2496
+ subSequence,
2497
+ h1Matches,
2498
+ unit
2499
+ } = FACTORY2;
2500
+ (0, import_utils15.merge)(mediaValue, {
2501
+ type,
2502
+ base,
2503
+ ratio,
2504
+ range,
2505
+ subSequence,
2506
+ h1Matches,
2507
+ unit,
2508
+ sequence: {},
2509
+ scales: {},
2510
+ templates: {},
2511
+ vars: {}
2512
+ });
2513
+ const query = MEDIA2[mediaName];
2514
+ TYPOGRAPHY2.templates[`@media screen and ${query}`] = {
2515
+ fontSize: mediaValue.base / TYPOGRAPHY2.browserDefault + unit
2516
+ };
2517
+ if (!mediaRegenerate) {
2518
+ applyMediaSequenceVars(FACTORY2, prop);
2519
+ continue;
2431
2520
  }
2521
+ generateSequence(mediaValue);
2522
+ applyMediaSequenceVars(FACTORY2, prop);
2432
2523
  }
2433
2524
  };
2434
2525
  var applyHeadings = (props) => {
@@ -2470,28 +2561,36 @@ var getFontSizeByKey = (value) => {
2470
2561
 
2471
2562
  // src/system/spacing.js
2472
2563
  var import_utils18 = __toESM(require_cjs(), 1);
2473
- var runThroughMedia2 = (sequenceProps) => {
2474
- for (const prop in sequenceProps) {
2475
- const mediaProps = sequenceProps[prop];
2476
- if (prop.slice(0, 1) === "@") {
2477
- const { type, base, ratio, range, subSequence, h1Matches, unit } = sequenceProps;
2478
- (0, import_utils18.merge)(mediaProps, {
2479
- type,
2480
- base,
2481
- ratio,
2482
- range,
2483
- subSequence,
2484
- h1Matches,
2485
- unit,
2486
- sequence: {},
2487
- scales: {},
2488
- templates: {},
2489
- vars: {}
2490
- });
2491
- generateSequence(mediaProps);
2492
- const mediaName = prop.slice(1);
2493
- applySequenceVars(mediaProps, mediaName);
2494
- }
2564
+ var runThroughMedia2 = (FACTORY2) => {
2565
+ for (const prop in FACTORY2) {
2566
+ const mediaProps = FACTORY2[prop];
2567
+ const isMediaName = prop.slice(0, 1) === "@";
2568
+ if (!isMediaName)
2569
+ continue;
2570
+ const {
2571
+ type,
2572
+ base,
2573
+ ratio,
2574
+ range,
2575
+ subSequence,
2576
+ h1Matches,
2577
+ unit
2578
+ } = FACTORY2;
2579
+ (0, import_utils18.merge)(mediaProps, {
2580
+ type,
2581
+ base,
2582
+ ratio,
2583
+ range,
2584
+ subSequence,
2585
+ h1Matches,
2586
+ unit,
2587
+ sequence: {},
2588
+ scales: {},
2589
+ templates: {},
2590
+ vars: {}
2591
+ });
2592
+ generateSequence(mediaProps);
2593
+ applyMediaSequenceVars(FACTORY2, prop);
2495
2594
  }
2496
2595
  };
2497
2596
  var applySpacingSequence = () => {
@@ -2566,7 +2665,7 @@ var getSpacingBasedOnRatio = (props, propertyName, val) => {
2566
2665
  unit: SPACING2.unit
2567
2666
  });
2568
2667
  }
2569
- applySequenceVars(sequenceProps, null, { useDefault: false });
2668
+ applySequenceVars(sequenceProps, { useDefault: false });
2570
2669
  return getSpacingByKey(value, propertyName, sequenceProps);
2571
2670
  }
2572
2671
  return getSpacingByKey(value, propertyName);
@@ -1426,6 +1426,7 @@ var defaultProps = {
1426
1426
  h1Matches: 6,
1427
1427
  lineHeight: 1.5,
1428
1428
  subSequence: true,
1429
+ mediaRegenerate: false,
1429
1430
  unit: "em",
1430
1431
  templates: {},
1431
1432
  sequence: {},
@@ -1481,6 +1482,7 @@ var defaultProps2 = {
1481
1482
  ratio: SEQUENCE.phi,
1482
1483
  range: [-5, 15],
1483
1484
  subSequence: true,
1485
+ mediaRegenerate: false,
1484
1486
  unit: "em",
1485
1487
  sequence: {},
1486
1488
  scales: {},
@@ -1508,6 +1510,7 @@ var defaultProps3 = {
1508
1510
  type: "timing",
1509
1511
  ratio: SEQUENCE["perfect-fourth"],
1510
1512
  range: [-3, 12],
1513
+ mediaRegenerate: false,
1511
1514
  unit: "ms",
1512
1515
  sequence: {},
1513
1516
  scales: {},
@@ -1426,6 +1426,7 @@ var defaultProps = {
1426
1426
  h1Matches: 6,
1427
1427
  lineHeight: 1.5,
1428
1428
  subSequence: true,
1429
+ mediaRegenerate: false,
1429
1430
  unit: "em",
1430
1431
  templates: {},
1431
1432
  sequence: {},
@@ -1481,6 +1482,7 @@ var defaultProps2 = {
1481
1482
  ratio: SEQUENCE.phi,
1482
1483
  range: [-5, 15],
1483
1484
  subSequence: true,
1485
+ mediaRegenerate: false,
1484
1486
  unit: "em",
1485
1487
  sequence: {},
1486
1488
  scales: {},
@@ -1508,6 +1510,7 @@ var defaultProps3 = {
1508
1510
  type: "timing",
1509
1511
  ratio: SEQUENCE["perfect-fourth"],
1510
1512
  range: [-3, 12],
1513
+ mediaRegenerate: false,
1511
1514
  unit: "ms",
1512
1515
  sequence: {},
1513
1516
  scales: {},
@@ -1729,45 +1732,74 @@ var numToLetterMap = {
1729
1732
  19: "T"
1730
1733
  };
1731
1734
  var setSequenceValue = (props, sequenceProps) => {
1732
- const { key, variable, value, scaling, index } = props;
1735
+ const { key, variable, value, scaling, index, scalingVariable } = props;
1733
1736
  sequenceProps.sequence[key] = {
1734
1737
  key,
1735
1738
  decimal: ~~(value * 100) / 100,
1736
1739
  val: ~~value,
1737
1740
  scaling,
1738
1741
  index,
1742
+ scalingVariable,
1739
1743
  variable
1740
1744
  };
1741
1745
  sequenceProps.scales[key] = scaling;
1742
1746
  sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1743
1747
  };
1748
+ var setScalingVar = (key, sequenceProps) => {
1749
+ const { type } = sequenceProps;
1750
+ if (key === 0)
1751
+ return "1em";
1752
+ const prefix = "--" + (type && type.replace(".", "-"));
1753
+ const ratioVar = `${prefix}-ratio`;
1754
+ if (key > 0) {
1755
+ const prevLetterKey = numToLetterMap[key - 1];
1756
+ return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
1757
+ }
1758
+ if (key < 0) {
1759
+ const nextLetterKey = numToLetterMap[key + 1];
1760
+ return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1761
+ }
1762
+ };
1763
+ var setSubScalingVar = (index, arr, variable, sequenceProps) => {
1764
+ const { type } = sequenceProps;
1765
+ const skipMiddle = index === 2 && arr.length === 2;
1766
+ const indexMapWithLength = skipMiddle ? index + 1 : index;
1767
+ const prefix = "--" + (type && type.replace(".", "-"));
1768
+ const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1769
+ return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1770
+ };
1771
+ var getSubratioDifference = (base, ratio) => {
1772
+ const diff = base * ratio - base;
1773
+ const subRatio = diff / 1.618;
1774
+ const first = base * ratio - subRatio;
1775
+ const second = base + subRatio;
1776
+ const middle = (first + second) / 2;
1777
+ return [first, middle, second];
1778
+ };
1744
1779
  var generateSubSequence = (props, sequenceProps) => {
1745
1780
  const { key, base, value, ratio, variable, index } = props;
1746
1781
  const next = value * ratio;
1747
- const diff = next - value;
1748
- const smallscale = diff / 1.618;
1749
- const valueRounded = ~~value;
1750
- const nextRounded = ~~next;
1751
- const diffRounded = nextRounded - valueRounded;
1752
- let arr = [];
1753
- const first = next - smallscale;
1754
- const second = value + smallscale;
1755
- const middle = (first + second) / 2;
1782
+ const diffRounded = ~~next - ~~value;
1783
+ let arr;
1784
+ const [first, middle, second] = getSubratioDifference(value, ratio);
1756
1785
  if (diffRounded > 16)
1757
1786
  arr = [first, middle, second];
1758
1787
  else
1759
1788
  arr = [first, second];
1760
- arr.map((v, k) => {
1789
+ arr.forEach((v, k) => {
1761
1790
  const scaling = ~~(v / base * 1e3) / 1e3;
1762
1791
  const newVar = variable + (k + 1);
1792
+ const newIndex = index + (k + 1) / 10;
1793
+ const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
1763
1794
  const props2 = {
1764
1795
  key: key + (k + 1),
1765
1796
  variable: newVar,
1766
1797
  value: v,
1767
1798
  scaling,
1768
- index: index + (k + 1) / 10
1799
+ scalingVariable,
1800
+ index: newIndex
1769
1801
  };
1770
- return setSequenceValue(props2, sequenceProps);
1802
+ setSequenceValue(props2, sequenceProps);
1771
1803
  });
1772
1804
  };
1773
1805
  var switchSequenceOnNegative = (key, base, ratio) => {
@@ -1783,12 +1815,14 @@ var generateSequence = (sequenceProps) => {
1783
1815
  const value = switchSequenceOnNegative(key, base, ratio);
1784
1816
  const scaling = ~~(value / base * 100) / 100;
1785
1817
  const variable = prefix + letterKey;
1818
+ const scalingVariable = setScalingVar(key, sequenceProps);
1786
1819
  const props = {
1787
1820
  key: letterKey,
1788
1821
  variable,
1789
1822
  value,
1790
1823
  base,
1791
1824
  scaling,
1825
+ scalingVariable,
1792
1826
  ratio,
1793
1827
  index: key
1794
1828
  };