@newtonedev/editor 0.1.7 → 0.1.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.
package/dist/index.js CHANGED
@@ -471,24 +471,27 @@ function useEditorState({
471
471
  const handlePublish = useCallback(async () => {
472
472
  if (debounceRef.current) clearTimeout(debounceRef.current);
473
473
  setPublishing(true);
474
- const currentState = latestStateRef.current;
475
- const updatedPresets = publishActivePreset(currentState);
476
- const [calibrations, fontMetrics] = await Promise.all([
477
- measureFontCalibrations(currentState.typography?.fonts),
478
- lookupFontMetrics(currentState.typography?.fonts, manifestUrl)
479
- ]);
480
- const { error } = await persistence.onPublish({
481
- state: currentState,
482
- presets: updatedPresets,
483
- activePresetId,
484
- calibrations,
485
- fontMetrics
486
- });
487
- if (!error) {
488
- setSaveStatus("saved");
489
- setIsPublished(true);
474
+ try {
475
+ const currentState = latestStateRef.current;
476
+ const updatedPresets = publishActivePreset(currentState);
477
+ const [calibrations, fontMetrics] = await Promise.all([
478
+ measureFontCalibrations(currentState.typography?.fonts),
479
+ lookupFontMetrics(currentState.typography?.fonts, manifestUrl)
480
+ ]);
481
+ const { error } = await persistence.onPublish({
482
+ state: currentState,
483
+ presets: updatedPresets,
484
+ activePresetId,
485
+ calibrations,
486
+ fontMetrics
487
+ });
488
+ if (!error) {
489
+ setSaveStatus("saved");
490
+ setIsPublished(true);
491
+ }
492
+ } finally {
493
+ setPublishing(false);
490
494
  }
491
- setPublishing(false);
492
495
  }, [activePresetId, publishActivePreset, persistence, manifestUrl]);
493
496
  useEffect(() => {
494
497
  const handleBeforeUnload = (e) => {
@@ -2013,7 +2016,7 @@ function IconsSection({ state, dispatch }) {
2013
2016
  ] });
2014
2017
  }
2015
2018
 
2016
- // ../../../newtone-fonts/dist/index.js
2019
+ // ../../../newtone-fonts/dist/defaults.js
2017
2020
  var ROLE_DEFAULT_WEIGHTS = {
2018
2021
  headline: 700,
2019
2022
  title: 700,
@@ -2028,20 +2031,28 @@ var BREAKPOINT_ROLE_SCALE = {
2028
2031
  md: { headline: 0.83, title: 0.88, heading: 0.92, subheading: 0.95, body: 0.97, label: 0.98, caption: 1 },
2029
2032
  lg: { headline: 1, title: 1, heading: 1, subheading: 1, body: 1, label: 1, caption: 1 }
2030
2033
  };
2034
+
2035
+ // ../../../newtone-fonts/dist/scale/breakpoints.js
2031
2036
  function scaleRoleStep(step, scale) {
2032
2037
  return {
2033
2038
  fontSize: Math.round(step.fontSize * scale),
2034
2039
  lineHeight: Math.round(step.lineHeight * scale / 4) * 4
2035
2040
  };
2036
2041
  }
2042
+
2043
+ // ../../../newtone-fonts/dist/catalog.js
2037
2044
  var SYSTEM_FONTS = [
2038
2045
  { family: "system-ui", category: "sans-serif", fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' },
2039
2046
  { family: "ui-serif", category: "serif", fallback: '"Iowan Old Style", "Apple Garamond", Baskerville, Georgia, serif' },
2040
2047
  { family: "ui-monospace", category: "monospace", fallback: "SFMono-Regular, Menlo, Monaco, Consolas, monospace" }
2041
2048
  ];
2049
+
2050
+ // ../../../newtone-fonts/dist/responsive/scoring.js
2042
2051
  function scoreLineBreaks(lineWidths, containerWidth) {
2043
- if (lineWidths.length <= 1) return 1;
2044
- if (containerWidth <= 0) return 0;
2052
+ if (lineWidths.length <= 1)
2053
+ return 1;
2054
+ if (containerWidth <= 0)
2055
+ return 0;
2045
2056
  const lineCount = lineWidths.length;
2046
2057
  const lastLineWidth = lineWidths[lineCount - 1];
2047
2058
  const lastLineRatio = Math.max(0, Math.min(1, lastLineWidth / containerWidth));
@@ -2072,6 +2083,8 @@ function scoreLineBreaks(lineWidths, containerWidth) {
2072
2083
  const RAG_WEIGHT = 0.35;
2073
2084
  return WIDOW_WEIGHT * widowScore + RAG_WEIGHT * ragScore;
2074
2085
  }
2086
+
2087
+ // ../../../newtone-fonts/dist/responsive/resolve.js
2075
2088
  function estimateLineWidths(characterCount, containerWidth, fontSize, avgCharWidthRatio = 0.55) {
2076
2089
  const avgCharWidth = fontSize * avgCharWidthRatio;
2077
2090
  const totalWidth = characterCount * avgCharWidth;
@@ -2114,7 +2127,8 @@ function resolveResponsiveSize(config, roleScales, measurement, calibrations) {
2114
2127
  bestScore = score;
2115
2128
  bestFontSize = fs;
2116
2129
  }
2117
- if (score >= 0.95) break;
2130
+ if (score >= 0.95)
2131
+ break;
2118
2132
  }
2119
2133
  return {
2120
2134
  fontSize: bestFontSize,