@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.
package/dist/cjs/set.js CHANGED
@@ -1428,6 +1428,7 @@ var defaultProps = {
1428
1428
  h1Matches: 6,
1429
1429
  lineHeight: 1.5,
1430
1430
  subSequence: true,
1431
+ mediaRegenerate: false,
1431
1432
  unit: "em",
1432
1433
  templates: {},
1433
1434
  sequence: {},
@@ -1483,6 +1484,7 @@ var defaultProps2 = {
1483
1484
  ratio: SEQUENCE.phi,
1484
1485
  range: [-5, 15],
1485
1486
  subSequence: true,
1487
+ mediaRegenerate: false,
1486
1488
  unit: "em",
1487
1489
  sequence: {},
1488
1490
  scales: {},
@@ -1510,6 +1512,7 @@ var defaultProps3 = {
1510
1512
  type: "timing",
1511
1513
  ratio: SEQUENCE["perfect-fourth"],
1512
1514
  range: [-3, 12],
1515
+ mediaRegenerate: false,
1513
1516
  unit: "ms",
1514
1517
  sequence: {},
1515
1518
  scales: {},
@@ -1764,45 +1767,77 @@ var numToLetterMap = {
1764
1767
  19: "T"
1765
1768
  };
1766
1769
  var setSequenceValue = (props, sequenceProps) => {
1767
- const { key, variable, value, scaling, index } = props;
1770
+ const { key, variable, value, scaling, index, scalingVariable } = props;
1768
1771
  sequenceProps.sequence[key] = {
1769
1772
  key,
1770
1773
  decimal: ~~(value * 100) / 100,
1771
1774
  val: ~~value,
1772
1775
  scaling,
1773
1776
  index,
1777
+ scalingVariable,
1774
1778
  variable
1775
1779
  };
1776
1780
  sequenceProps.scales[key] = scaling;
1777
1781
  sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1778
1782
  };
1783
+ var setScalingVar = (key, sequenceProps) => {
1784
+ const { type } = sequenceProps;
1785
+ if (key === 0)
1786
+ return "1em";
1787
+ const prefix = "--" + (type && type.replace(".", "-"));
1788
+ const ratioVar = `${prefix}-ratio`;
1789
+ if (key > 0) {
1790
+ const prevLetterKey = numToLetterMap[key - 1];
1791
+ return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
1792
+ }
1793
+ if (key < 0) {
1794
+ const nextLetterKey = numToLetterMap[key + 1];
1795
+ return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1796
+ }
1797
+ };
1798
+ var setSubScalingVar = (index, arr, variable, sequenceProps) => {
1799
+ const { type } = sequenceProps;
1800
+ const skipMiddle = index === 2 && arr.length === 2;
1801
+ const indexMapWithLength = skipMiddle ? index + 1 : index;
1802
+ const prefix = "--" + (type && type.replace(".", "-"));
1803
+ const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1804
+ return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1805
+ };
1806
+ var getSubratioDifference = (base, ratio) => {
1807
+ const diff = base * ratio - base;
1808
+ const subRatio = diff / 1.618;
1809
+ const first = base * ratio - subRatio;
1810
+ const second = base + subRatio;
1811
+ const middle = (first + second) / 2;
1812
+ return [first, middle, second];
1813
+ };
1814
+ var getSubratio = (base, ratio) => {
1815
+ return getSubratioDifference(base, ratio).map((v) => v / base);
1816
+ };
1779
1817
  var generateSubSequence = (props, sequenceProps) => {
1780
1818
  const { key, base, value, ratio, variable, index } = props;
1781
1819
  const next = value * ratio;
1782
- const diff = next - value;
1783
- const smallscale = diff / 1.618;
1784
- const valueRounded = ~~value;
1785
- const nextRounded = ~~next;
1786
- const diffRounded = nextRounded - valueRounded;
1787
- let arr = [];
1788
- const first = next - smallscale;
1789
- const second = value + smallscale;
1790
- const middle = (first + second) / 2;
1820
+ const diffRounded = ~~next - ~~value;
1821
+ let arr;
1822
+ const [first, middle, second] = getSubratioDifference(value, ratio);
1791
1823
  if (diffRounded > 16)
1792
1824
  arr = [first, middle, second];
1793
1825
  else
1794
1826
  arr = [first, second];
1795
- arr.map((v, k) => {
1827
+ arr.forEach((v, k) => {
1796
1828
  const scaling = ~~(v / base * 1e3) / 1e3;
1797
1829
  const newVar = variable + (k + 1);
1830
+ const newIndex = index + (k + 1) / 10;
1831
+ const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
1798
1832
  const props2 = {
1799
1833
  key: key + (k + 1),
1800
1834
  variable: newVar,
1801
1835
  value: v,
1802
1836
  scaling,
1803
- index: index + (k + 1) / 10
1837
+ scalingVariable,
1838
+ index: newIndex
1804
1839
  };
1805
- return setSequenceValue(props2, sequenceProps);
1840
+ setSequenceValue(props2, sequenceProps);
1806
1841
  });
1807
1842
  };
1808
1843
  var switchSequenceOnNegative = (key, base, ratio) => {
@@ -1818,12 +1853,14 @@ var generateSequence = (sequenceProps) => {
1818
1853
  const value = switchSequenceOnNegative(key, base, ratio);
1819
1854
  const scaling = ~~(value / base * 100) / 100;
1820
1855
  const variable = prefix + letterKey;
1856
+ const scalingVariable = setScalingVar(key, sequenceProps);
1821
1857
  const props = {
1822
1858
  key: letterKey,
1823
1859
  variable,
1824
1860
  value,
1825
1861
  base,
1826
1862
  scaling,
1863
+ scalingVariable,
1827
1864
  ratio,
1828
1865
  index: key
1829
1866
  };
@@ -1907,35 +1944,75 @@ var findHeadings = (propertyNames) => {
1907
1944
 
1908
1945
  // src/utils/var.js
1909
1946
  var import_utils7 = __toESM(require_cjs(), 1);
1910
- var applySequenceVars = (props, mediaName, options = {}) => {
1947
+ var applyGlobalVars = (vars, obj, options) => {
1911
1948
  const CONFIG2 = getActiveConfig();
1912
- const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1913
- const unit = props.unit || UNIT2.default;
1914
- const { sequence, scales } = props;
1949
+ const { UNIT: UNIT2 } = CONFIG2;
1950
+ const unit = obj.unit || UNIT2.default;
1951
+ const { base, ratio, type } = obj;
1952
+ const prefix = "--" + (type && type.replace(".", "-"));
1953
+ vars[`${prefix}-base`] = base;
1954
+ vars[`${prefix}-unit`] = unit;
1955
+ const ratioVar = `${prefix}-ratio`;
1956
+ vars[ratioVar] = ratio;
1957
+ const [first, middle, second] = getSubratio(base, ratio);
1958
+ vars[`${prefix}-sub-ratio-1`] = first;
1959
+ vars[`${prefix}-sub-ratio-2`] = middle;
1960
+ vars[`${prefix}-sub-ratio-3`] = second;
1961
+ };
1962
+ var applySequenceVars = (FACTORY2, options = {}) => {
1963
+ const CONFIG2 = getActiveConfig();
1964
+ const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1965
+ const unit = FACTORY2.unit || UNIT2.default;
1966
+ const { mediaRegenerate, sequence, scales } = FACTORY2;
1967
+ if (!mediaRegenerate) {
1968
+ applyGlobalVars(CSS_VARS2, FACTORY2, options);
1969
+ }
1915
1970
  for (const key in sequence) {
1916
1971
  const item = sequence[key];
1917
- const value = (props.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1918
- if (mediaName) {
1919
- const query = MEDIA2[mediaName];
1920
- if (!query) {
1921
- if (CONFIG2.verbose)
1922
- console.warn("Can't find query ", query);
1923
- }
1924
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
1925
- if (!underMediaQuery)
1926
- underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1927
- underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
1928
- CSS_VARS2[item.variable + "_" + mediaName] = value;
1972
+ const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1973
+ if (!mediaRegenerate) {
1974
+ CSS_VARS2[item.variable + "_default"] = value;
1975
+ CSS_VARS2[item.variable] = item.scalingVariable;
1976
+ continue;
1977
+ }
1978
+ if (options.useDefault === false) {
1979
+ CSS_VARS2[item.variable] = value;
1929
1980
  } else {
1930
- if (options.useDefault === false) {
1931
- CSS_VARS2[item.variable] = value;
1932
- } else {
1933
- CSS_VARS2[item.variable + "_default"] = value;
1934
- CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1935
- }
1981
+ CSS_VARS2[item.variable + "_default"] = value;
1982
+ CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1936
1983
  }
1937
1984
  }
1938
1985
  };
1986
+ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
1987
+ const CONFIG2 = getActiveConfig();
1988
+ const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1989
+ const mediaName = media.slice(1);
1990
+ const unit = FACTORY2.unit || UNIT2.default;
1991
+ const { mediaRegenerate } = FACTORY2;
1992
+ const { sequence, scales } = FACTORY2[media];
1993
+ const query = MEDIA2[mediaName];
1994
+ if (!query && CONFIG2.verbose)
1995
+ console.warn("Can't find media query ", query);
1996
+ if (!mediaRegenerate) {
1997
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
1998
+ if (!underMediaQuery)
1999
+ underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
2000
+ applyGlobalVars(underMediaQuery, FACTORY2[media], options);
2001
+ return;
2002
+ }
2003
+ for (const key in sequence) {
2004
+ const item = sequence[key];
2005
+ const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
2006
+ if (!query && CONFIG2.verbose)
2007
+ console.warn("Can't find query ", query);
2008
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
2009
+ if (!underMediaQuery)
2010
+ underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
2011
+ underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
2012
+ CSS_VARS2[item.variable + "_" + mediaName] = value;
2013
+ }
2014
+ console.log(CSS_VARS2);
2015
+ };
1939
2016
 
1940
2017
  // src/utils/sprite.js
1941
2018
  var import_utils8 = __toESM(require_cjs(), 1);
@@ -2326,34 +2403,48 @@ var setFontFamily = (val, key) => {
2326
2403
 
2327
2404
  // src/system/typography.js
2328
2405
  var import_utils15 = __toESM(require_cjs(), 1);
2329
- var runThroughMedia = (props) => {
2406
+ var runThroughMedia = (FACTORY2) => {
2330
2407
  const CONFIG2 = getActiveConfig();
2331
2408
  const { TYPOGRAPHY: TYPOGRAPHY2, MEDIA: MEDIA2 } = CONFIG2;
2332
- for (const prop in props) {
2333
- const mediaProps = props[prop];
2334
- if (prop.slice(0, 1) === "@") {
2335
- const { type, base, ratio, range, subSequence, h1Matches, unit } = props;
2336
- (0, import_utils15.merge)(mediaProps, {
2337
- type,
2338
- base,
2339
- ratio,
2340
- range,
2341
- subSequence,
2342
- h1Matches,
2343
- unit,
2344
- sequence: {},
2345
- scales: {},
2346
- templates: {},
2347
- vars: {}
2348
- });
2349
- generateSequence(mediaProps);
2350
- const mediaName = prop.slice(1);
2351
- applySequenceVars(mediaProps, mediaName);
2352
- const query = MEDIA2[mediaName];
2353
- TYPOGRAPHY2.templates[`@media screen and ${query}`] = {
2354
- fontSize: mediaProps.base / TYPOGRAPHY2.browserDefault + unit
2355
- };
2409
+ for (const prop in FACTORY2) {
2410
+ const isPropMedia = prop.slice(0, 1) === "@";
2411
+ const mediaValue = FACTORY2[prop];
2412
+ if (!isPropMedia)
2413
+ continue;
2414
+ const { mediaRegenerate } = FACTORY2;
2415
+ const mediaName = prop.slice(1);
2416
+ const {
2417
+ type,
2418
+ base,
2419
+ ratio,
2420
+ range,
2421
+ subSequence,
2422
+ h1Matches,
2423
+ unit
2424
+ } = FACTORY2;
2425
+ (0, import_utils15.merge)(mediaValue, {
2426
+ type,
2427
+ base,
2428
+ ratio,
2429
+ range,
2430
+ subSequence,
2431
+ h1Matches,
2432
+ unit,
2433
+ sequence: {},
2434
+ scales: {},
2435
+ templates: {},
2436
+ vars: {}
2437
+ });
2438
+ const query = MEDIA2[mediaName];
2439
+ TYPOGRAPHY2.templates[`@media screen and ${query}`] = {
2440
+ fontSize: mediaValue.base / TYPOGRAPHY2.browserDefault + unit
2441
+ };
2442
+ if (!mediaRegenerate) {
2443
+ applyMediaSequenceVars(FACTORY2, prop);
2444
+ continue;
2356
2445
  }
2446
+ generateSequence(mediaValue);
2447
+ applyMediaSequenceVars(FACTORY2, prop);
2357
2448
  }
2358
2449
  };
2359
2450
  var applyHeadings = (props) => {
@@ -2386,28 +2477,36 @@ var applyTypographySequence = () => {
2386
2477
 
2387
2478
  // src/system/spacing.js
2388
2479
  var import_utils18 = __toESM(require_cjs(), 1);
2389
- var runThroughMedia2 = (sequenceProps) => {
2390
- for (const prop in sequenceProps) {
2391
- const mediaProps = sequenceProps[prop];
2392
- if (prop.slice(0, 1) === "@") {
2393
- const { type, base, ratio, range, subSequence, h1Matches, unit } = sequenceProps;
2394
- (0, import_utils18.merge)(mediaProps, {
2395
- type,
2396
- base,
2397
- ratio,
2398
- range,
2399
- subSequence,
2400
- h1Matches,
2401
- unit,
2402
- sequence: {},
2403
- scales: {},
2404
- templates: {},
2405
- vars: {}
2406
- });
2407
- generateSequence(mediaProps);
2408
- const mediaName = prop.slice(1);
2409
- applySequenceVars(mediaProps, mediaName);
2410
- }
2480
+ var runThroughMedia2 = (FACTORY2) => {
2481
+ for (const prop in FACTORY2) {
2482
+ const mediaProps = FACTORY2[prop];
2483
+ const isMediaName = prop.slice(0, 1) === "@";
2484
+ if (!isMediaName)
2485
+ continue;
2486
+ const {
2487
+ type,
2488
+ base,
2489
+ ratio,
2490
+ range,
2491
+ subSequence,
2492
+ h1Matches,
2493
+ unit
2494
+ } = FACTORY2;
2495
+ (0, import_utils18.merge)(mediaProps, {
2496
+ type,
2497
+ base,
2498
+ ratio,
2499
+ range,
2500
+ subSequence,
2501
+ h1Matches,
2502
+ unit,
2503
+ sequence: {},
2504
+ scales: {},
2505
+ templates: {},
2506
+ vars: {}
2507
+ });
2508
+ generateSequence(mediaProps);
2509
+ applyMediaSequenceVars(FACTORY2, prop);
2411
2510
  }
2412
2511
  };
2413
2512
  var applySpacingSequence = () => {
@@ -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: {},
@@ -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: {},
@@ -1444,6 +1444,7 @@ var defaultProps = {
1444
1444
  h1Matches: 6,
1445
1445
  lineHeight: 1.5,
1446
1446
  subSequence: true,
1447
+ mediaRegenerate: false,
1447
1448
  unit: "em",
1448
1449
  templates: {},
1449
1450
  sequence: {},
@@ -1499,6 +1500,7 @@ var defaultProps2 = {
1499
1500
  ratio: SEQUENCE.phi,
1500
1501
  range: [-5, 15],
1501
1502
  subSequence: true,
1503
+ mediaRegenerate: false,
1502
1504
  unit: "em",
1503
1505
  sequence: {},
1504
1506
  scales: {},
@@ -1526,6 +1528,7 @@ var defaultProps3 = {
1526
1528
  type: "timing",
1527
1529
  ratio: SEQUENCE["perfect-fourth"],
1528
1530
  range: [-3, 12],
1531
+ mediaRegenerate: false,
1529
1532
  unit: "ms",
1530
1533
  sequence: {},
1531
1534
  scales: {},