@symbo.ls/scratch 2.27.0 → 2.27.8

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.
@@ -51,8 +51,8 @@ var require_cjs = __commonJS({
51
51
  return to;
52
52
  };
53
53
  var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
54
- var src_exports = {};
55
- __export2(src_exports, {
54
+ var index_exports = {};
55
+ __export2(index_exports, {
56
56
  arrayzeValue: () => arrayzeValue,
57
57
  copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
58
58
  copyStringToClipboard: () => copyStringToClipboard,
@@ -73,12 +73,11 @@ var require_cjs = __commonJS({
73
73
  toTitleCase: () => toTitleCase,
74
74
  toggleFullscreen: () => toggleFullscreen
75
75
  });
76
- module2.exports = __toCommonJS2(src_exports);
76
+ module2.exports = __toCommonJS2(index_exports);
77
77
  var window22 = globalThis;
78
78
  var document22 = window22.document;
79
79
  var isObject2 = (arg) => {
80
- if (arg === null)
81
- return false;
80
+ if (arg === null) return false;
82
81
  return typeof arg === "object" && arg.constructor === Object;
83
82
  };
84
83
  var isString2 = (arg) => typeof arg === "string";
@@ -103,13 +102,11 @@ var require_cjs = __commonJS({
103
102
  };
104
103
  var findClosestNumberInFactory = (val, factory) => {
105
104
  val = parseFloat(val);
106
- if (isObject2(factory))
107
- factory = Object.values(factory);
105
+ if (isObject2(factory)) factory = Object.values(factory);
108
106
  return findClosestNumber(val, factory);
109
107
  };
110
108
  var formatDate = (timestamp) => {
111
- if (!timestamp)
112
- return "";
109
+ if (!timestamp) return "";
113
110
  const d = new Date(timestamp);
114
111
  const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
115
112
  const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
@@ -176,8 +173,7 @@ var require_cjs = __commonJS({
176
173
  scriptEle.type = type;
177
174
  scriptEle.text = xhr.responseText;
178
175
  doc.body.appendChild(scriptEle);
179
- if (typeof fallback === "function")
180
- fallback();
176
+ if (typeof fallback === "function") fallback();
181
177
  } else {
182
178
  throw new Error(`Failed to load the script ${FILE_URL}`);
183
179
  }
@@ -245,20 +241,15 @@ var require_cjs = __commonJS({
245
241
  );
246
242
  var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
247
243
  var toDescriptionCase = (str = "") => {
248
- if (typeof str !== "string")
249
- return;
244
+ if (typeof str !== "string") return;
250
245
  const result = str.replace(/([A-Z])/g, " $1");
251
246
  return result.charAt(0).toUpperCase() + result.slice(1);
252
247
  };
253
248
  var arrayzeValue = (val) => {
254
- if (isArray2(val))
255
- return val;
256
- if (isString2(val))
257
- return val.split(" ");
258
- if (isObject2(val))
259
- return Object.values(val);
260
- if (isNumber2(val))
261
- return [val];
249
+ if (isArray2(val)) return val;
250
+ if (isString2(val)) return val.split(" ");
251
+ if (isObject2(val)) return Object.values(val);
252
+ if (isNumber2(val)) return [val];
262
253
  };
263
254
  }
264
255
  });
@@ -288,8 +279,7 @@ var isFunction = (arg) => typeof arg === "function";
288
279
  var isNull = (arg) => arg === null;
289
280
  var isArray = (arg) => Array.isArray(arg);
290
281
  var isObjectLike = (arg) => {
291
- if (arg === null)
292
- return false;
282
+ if (arg === null) return false;
293
283
  return typeof arg === "object";
294
284
  };
295
285
  var isUndefined = (arg) => {
@@ -370,8 +360,7 @@ var deepClone = (obj, options = {}) => {
370
360
  const clone2 = targetWindow ? isArray(obj) ? new targetWindow.Array() : new targetWindow.Object() : isArray(obj) ? [] : {};
371
361
  visited.set(obj, clone2);
372
362
  for (const key in obj) {
373
- if (!Object.prototype.hasOwnProperty.call(obj, key))
374
- continue;
363
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
375
364
  if (exclude.includes(key) || key.startsWith("__") || key === "__proto__")
376
365
  continue;
377
366
  const value = obj[key];
@@ -676,8 +665,7 @@ var setSequenceValue = (props, sequenceProps) => {
676
665
  var setScalingVar = (key, sequenceProps) => {
677
666
  const { base, type, unit } = sequenceProps;
678
667
  const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
679
- if (key === 0)
680
- return defaultVal;
668
+ if (key === 0) return defaultVal;
681
669
  const prefix = "--" + (type && type.replace(".", "-"));
682
670
  const ratioVar = `${prefix}-ratio`;
683
671
  if (key > 0) {
@@ -714,10 +702,8 @@ var generateSubSequence = (props, sequenceProps) => {
714
702
  const diffRounded = ~~next - ~~value;
715
703
  let arr;
716
704
  const [first, middle, second] = getSubratioDifference(value, ratio);
717
- if (diffRounded > 16)
718
- arr = [first, middle, second];
719
- else
720
- arr = [first, second];
705
+ if (diffRounded > 16) arr = [first, middle, second];
706
+ else arr = [first, second];
721
707
  arr.forEach((v, k) => {
722
708
  const scaling = ~~(v / base * 1e3) / 1e3;
723
709
  const newVar = variable + (k + 1);
@@ -759,8 +745,7 @@ var generateSequence = (sequenceProps) => {
759
745
  index: key
760
746
  };
761
747
  setSequenceValue(props, sequenceProps);
762
- if (subSequence)
763
- generateSubSequence(props, sequenceProps);
748
+ if (subSequence) generateSubSequence(props, sequenceProps);
764
749
  }
765
750
  return sequenceProps;
766
751
  };
@@ -772,13 +757,11 @@ var getSequenceValue = (value = "A", sequenceProps) => {
772
757
  unit = UNIT2.default,
773
758
  useVariable
774
759
  } = sequenceProps;
775
- if (isString(value) && value.slice(0, 2) === "--")
776
- return `var(${value})`;
760
+ if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
777
761
  const prefix = `--${(0, import_utils4.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
778
762
  const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
779
763
  const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
780
- if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter)
781
- return value;
764
+ if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter) return value;
782
765
  const letterVal = value.toUpperCase();
783
766
  const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
784
767
  let absValue = isNegative ? letterVal.slice(1) : letterVal;
@@ -802,8 +785,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
802
785
  return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
803
786
  }
804
787
  if (!sequence[absValue] && absValue.length === 2) {
805
- if (CONFIG2.verbose)
806
- console.warn(absValue, "- value is not found because `subSequence` is set to false");
788
+ if (CONFIG2.verbose) console.warn(absValue, "- value is not found because `subSequence` is set to false");
807
789
  absValue = absValue.slice(0, 1);
808
790
  }
809
791
  if (useVariable || CONFIG2.useVariable) {
@@ -811,8 +793,7 @@ var getSequenceValue = (value = "A", sequenceProps) => {
811
793
  return isNegative ? `calc(${varValue2} * -1)` : varValue2;
812
794
  }
813
795
  const sequenceItem = sequence ? sequence[absValue] : null;
814
- if (!sequenceItem)
815
- return console.warn("can't find", sequence, absValue);
796
+ if (!sequenceItem) return console.warn("can't find", sequence, absValue);
816
797
  if (unit === "ms" || unit === "s") {
817
798
  return isNegative + sequenceItem.val + unit;
818
799
  }
@@ -821,12 +802,10 @@ var getSequenceValue = (value = "A", sequenceProps) => {
821
802
  var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
822
803
  if (typeof value !== "string") {
823
804
  const CONFIG2 = getActiveConfig();
824
- if (CONFIG2.verbose)
825
- console.warn(propertyName, value, "is not a string");
805
+ if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
826
806
  return { [propertyName]: value };
827
807
  }
828
- if (value === "-" || value === "")
829
- return {};
808
+ if (value === "-" || value === "") return {};
830
809
  return { [propertyName]: getSequenceValue(value, sequenceProps) };
831
810
  };
832
811
  var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
@@ -886,23 +865,19 @@ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
886
865
  const { mediaRegenerate } = FACTORY2;
887
866
  const { sequence, scales } = FACTORY2[media];
888
867
  const query = MEDIA2[mediaName];
889
- if (!query && CONFIG2.verbose)
890
- console.warn("Can't find media query ", query);
868
+ if (!query && CONFIG2.verbose) console.warn("Can't find media query ", query);
891
869
  if (!mediaRegenerate) {
892
870
  let underMediaQuery = CSS_VARS2[`@media ${query}`];
893
- if (!underMediaQuery)
894
- underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
871
+ if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
895
872
  applySequenceGlobalVars(underMediaQuery, FACTORY2[media], options);
896
873
  return;
897
874
  }
898
875
  for (const key in sequence) {
899
876
  const item = sequence[key];
900
877
  const value = (isScalingUnit(unit) ? scales[key] : sequence[key].val) + unit;
901
- if (!query && CONFIG2.verbose)
902
- console.warn("Can't find query ", query);
878
+ if (!query && CONFIG2.verbose) console.warn("Can't find query ", query);
903
879
  let underMediaQuery = CSS_VARS2[`@media ${query}`];
904
- if (!underMediaQuery)
905
- underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
880
+ if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
906
881
  underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
907
882
  CSS_VARS2[item.variable + "_" + mediaName] = value;
908
883
  }
@@ -915,19 +890,10 @@ var runThroughMedia = (FACTORY2) => {
915
890
  for (const prop in FACTORY2) {
916
891
  const isPropMedia = prop.slice(0, 1) === "@";
917
892
  const mediaValue = FACTORY2[prop];
918
- if (!isPropMedia)
919
- continue;
893
+ if (!isPropMedia) continue;
920
894
  const { mediaRegenerate } = FACTORY2;
921
895
  const mediaName = prop.slice(1);
922
- const {
923
- type,
924
- base,
925
- ratio,
926
- range,
927
- subSequence,
928
- h1Matches,
929
- unit
930
- } = FACTORY2;
896
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY2;
931
897
  merge(mediaValue, {
932
898
  type,
933
899
  base,
@@ -957,7 +923,7 @@ var runThroughMedia = (FACTORY2) => {
957
923
  }
958
924
  };
959
925
  var applyHeadings = (props) => {
960
- var _a;
926
+ var _a, _b;
961
927
  const CONFIG2 = getActiveConfig();
962
928
  if (props.h1Matches) {
963
929
  const unit = props.unit;
@@ -966,10 +932,8 @@ var applyHeadings = (props) => {
966
932
  for (const k in HEADINGS) {
967
933
  const headerName = `h${parseInt(k) + 1}`;
968
934
  const headerStyle = templates[headerName];
969
- if (!HEADINGS[k])
970
- continue;
971
935
  templates[headerName] = {
972
- fontSize: CONFIG2.useVariable ? `var(${(_a = HEADINGS[k]) == null ? void 0 : _a.variable})` : `${HEADINGS[k].scaling}${unit}`,
936
+ fontSize: CONFIG2.useVariable ? `var(${(_a = HEADINGS[k]) == null ? void 0 : _a.variable})` : `${(_b = HEADINGS[k]) == null ? void 0 : _b.scaling}${unit}`,
973
937
  margin: headerStyle ? headerStyle.margin : 0,
974
938
  lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
975
939
  letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
@@ -989,9 +953,5 @@ var applyTypographySequence = () => {
989
953
  var getFontSizeByKey = (value) => {
990
954
  const CONFIG2 = getActiveConfig();
991
955
  const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
992
- return getSequenceValuePropertyPair(
993
- value,
994
- "fontSize",
995
- TYPOGRAPHY2
996
- );
956
+ return getSequenceValuePropertyPair(value, "fontSize", TYPOGRAPHY2);
997
957
  };