@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.
@@ -1 +1 @@
1
- {"version":3,"file":"useEditorState.d.ts","sourceRoot":"","sources":["../../src/hooks/useEditorState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAIlB,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAC;IACzC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,cAAc,CAAC,EAC7B,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,WAAW,GACZ,EAAE,qBAAqB;;;;;;;;;gCAsON,iBAAiB;;;;2CA3GxB,WAAW;8CAsBN,MAAM;8CA8BN,MAAM;2CAwF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AsLpC"}
package/dist/index.cjs CHANGED
@@ -473,24 +473,27 @@ function useEditorState({
473
473
  const handlePublish = react.useCallback(async () => {
474
474
  if (debounceRef.current) clearTimeout(debounceRef.current);
475
475
  setPublishing(true);
476
- const currentState = latestStateRef.current;
477
- const updatedPresets = publishActivePreset(currentState);
478
- const [calibrations, fontMetrics] = await Promise.all([
479
- measureFontCalibrations(currentState.typography?.fonts),
480
- lookupFontMetrics(currentState.typography?.fonts, manifestUrl)
481
- ]);
482
- const { error } = await persistence.onPublish({
483
- state: currentState,
484
- presets: updatedPresets,
485
- activePresetId,
486
- calibrations,
487
- fontMetrics
488
- });
489
- if (!error) {
490
- setSaveStatus("saved");
491
- setIsPublished(true);
476
+ try {
477
+ const currentState = latestStateRef.current;
478
+ const updatedPresets = publishActivePreset(currentState);
479
+ const [calibrations, fontMetrics] = await Promise.all([
480
+ measureFontCalibrations(currentState.typography?.fonts),
481
+ lookupFontMetrics(currentState.typography?.fonts, manifestUrl)
482
+ ]);
483
+ const { error } = await persistence.onPublish({
484
+ state: currentState,
485
+ presets: updatedPresets,
486
+ activePresetId,
487
+ calibrations,
488
+ fontMetrics
489
+ });
490
+ if (!error) {
491
+ setSaveStatus("saved");
492
+ setIsPublished(true);
493
+ }
494
+ } finally {
495
+ setPublishing(false);
492
496
  }
493
- setPublishing(false);
494
497
  }, [activePresetId, publishActivePreset, persistence, manifestUrl]);
495
498
  react.useEffect(() => {
496
499
  const handleBeforeUnload = (e) => {
@@ -2015,7 +2018,7 @@ function IconsSection({ state, dispatch }) {
2015
2018
  ] });
2016
2019
  }
2017
2020
 
2018
- // ../../../newtone-fonts/dist/index.js
2021
+ // ../../../newtone-fonts/dist/defaults.js
2019
2022
  var ROLE_DEFAULT_WEIGHTS = {
2020
2023
  headline: 700,
2021
2024
  title: 700,
@@ -2030,20 +2033,28 @@ var BREAKPOINT_ROLE_SCALE = {
2030
2033
  md: { headline: 0.83, title: 0.88, heading: 0.92, subheading: 0.95, body: 0.97, label: 0.98, caption: 1 },
2031
2034
  lg: { headline: 1, title: 1, heading: 1, subheading: 1, body: 1, label: 1, caption: 1 }
2032
2035
  };
2036
+
2037
+ // ../../../newtone-fonts/dist/scale/breakpoints.js
2033
2038
  function scaleRoleStep(step, scale) {
2034
2039
  return {
2035
2040
  fontSize: Math.round(step.fontSize * scale),
2036
2041
  lineHeight: Math.round(step.lineHeight * scale / 4) * 4
2037
2042
  };
2038
2043
  }
2044
+
2045
+ // ../../../newtone-fonts/dist/catalog.js
2039
2046
  var SYSTEM_FONTS = [
2040
2047
  { family: "system-ui", category: "sans-serif", fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' },
2041
2048
  { family: "ui-serif", category: "serif", fallback: '"Iowan Old Style", "Apple Garamond", Baskerville, Georgia, serif' },
2042
2049
  { family: "ui-monospace", category: "monospace", fallback: "SFMono-Regular, Menlo, Monaco, Consolas, monospace" }
2043
2050
  ];
2051
+
2052
+ // ../../../newtone-fonts/dist/responsive/scoring.js
2044
2053
  function scoreLineBreaks(lineWidths, containerWidth) {
2045
- if (lineWidths.length <= 1) return 1;
2046
- if (containerWidth <= 0) return 0;
2054
+ if (lineWidths.length <= 1)
2055
+ return 1;
2056
+ if (containerWidth <= 0)
2057
+ return 0;
2047
2058
  const lineCount = lineWidths.length;
2048
2059
  const lastLineWidth = lineWidths[lineCount - 1];
2049
2060
  const lastLineRatio = Math.max(0, Math.min(1, lastLineWidth / containerWidth));
@@ -2074,6 +2085,8 @@ function scoreLineBreaks(lineWidths, containerWidth) {
2074
2085
  const RAG_WEIGHT = 0.35;
2075
2086
  return WIDOW_WEIGHT * widowScore + RAG_WEIGHT * ragScore;
2076
2087
  }
2088
+
2089
+ // ../../../newtone-fonts/dist/responsive/resolve.js
2077
2090
  function estimateLineWidths(characterCount, containerWidth, fontSize, avgCharWidthRatio = 0.55) {
2078
2091
  const avgCharWidth = fontSize * avgCharWidthRatio;
2079
2092
  const totalWidth = characterCount * avgCharWidth;
@@ -2116,7 +2129,8 @@ function resolveResponsiveSize(config, roleScales, measurement, calibrations) {
2116
2129
  bestScore = score;
2117
2130
  bestFontSize = fs;
2118
2131
  }
2119
- if (score >= 0.95) break;
2132
+ if (score >= 0.95)
2133
+ break;
2120
2134
  }
2121
2135
  return {
2122
2136
  fontSize: bestFontSize,