@lvce-editor/editor-worker 19.80.1 → 19.80.2

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/diff-sdk.js CHANGED
@@ -417,7 +417,8 @@ const activateByEvent = async (event, assetDir, platform) => {
417
417
  await ExtensionManagementWorker.invoke('Extensions.activateByEvent', event);
418
418
  };
419
419
 
420
- const cacheName$1 = 'lvce-editor-character-widths-v1';
420
+ // Older entries may have been measured before the bundled font was loaded.
421
+ const cacheName$1 = 'lvce-editor-character-widths-v2';
421
422
  const character = 'a';
422
423
  const getKey$2 = (fontWeight, fontSize, fontFamily, letterSpacing) => {
423
424
  return `https://cache.invalid/character-width/${encodeURIComponent(JSON.stringify([character, fontWeight, fontSize, fontFamily, letterSpacing]))}`;
@@ -16353,7 +16354,19 @@ const getLanguages = async (platform, assetDir, applicationId) => {
16353
16354
  return invoke$9(applicationId, 'Extensions.getLanguages', platform, assetDir);
16354
16355
  };
16355
16356
 
16357
+ const loaded = Object.create(null);
16358
+ const setLoaded = id => {
16359
+ loaded[id] = true;
16360
+ };
16361
+ const isLoaded = id => {
16362
+ return loaded[id];
16363
+ };
16364
+
16356
16365
  const measureCharacterWidth = async (fontWeight, fontSize, fontFamily, letterSpacing) => {
16366
+ const isFiraCode = fontFamily === 'Fira Code' || fontFamily === "'Fira Code'";
16367
+ if (isFiraCode && !isLoaded('Fira Code')) {
16368
+ return measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
16369
+ }
16357
16370
  try {
16358
16371
  const cachedWidth = await get$b(fontWeight, fontSize, fontFamily, letterSpacing);
16359
16372
  if (cachedWidth !== undefined) {
@@ -26515,6 +26528,7 @@ const getDiagnostics = async editorUid => {
26515
26528
 
26516
26529
  const ensure = async (fontName, fontUrl) => {
26517
26530
  await TextMeasurementWorker.invoke('TextMeasurement.ensureFont', fontName, fontUrl);
26531
+ setLoaded(fontName);
26518
26532
  };
26519
26533
 
26520
26534
  const getComponentState = uid => {
@@ -27448,7 +27462,7 @@ const updateFindWidget = async state => {
27448
27462
  commands
27449
27463
  });
27450
27464
  };
27451
- const handleSettingsChanged = async state => {
27465
+ const handleSettingsChanged = async (state, firaCodeFontUrl) => {
27452
27466
  const editorPreferences = {
27453
27467
  ...(await getEditorPreferences(state.applicationId)),
27454
27468
  ...(state.largeFile && getLargeFilePreferences())
@@ -27463,8 +27477,12 @@ const handleSettingsChanged = async state => {
27463
27477
  minimapEnabled,
27464
27478
  rowHeight
27465
27479
  } = editorPreferences;
27480
+ const isFiraCode = fontFamily === 'Fira Code' || fontFamily === "'Fira Code'";
27481
+ if (isFiraCode && firaCodeFontUrl) {
27482
+ await ensure('Fira Code', firaCodeFontUrl);
27483
+ }
27466
27484
  const [charWidth, completionsOnTypeRaw] = await Promise.all([measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing), state.applicationId === undefined ? get$2('editor.completionsOnType') : get$2('editor.completionsOnType', state.applicationId)]);
27467
- const isMonospaceFont = !editorPreferences.disableMonospaceOptimizations && (fontFamily === 'Fira Code' || fontFamily === "'Fira Code'");
27485
+ const isMonospaceFont = !editorPreferences.disableMonospaceOptimizations && isFiraCode;
27468
27486
  const editorWithUpdatedSettings = {
27469
27487
  ...state,
27470
27488
  ...editorPreferences,
@@ -1817,7 +1817,8 @@ const activateByEvent = async (event, assetDir, platform) => {
1817
1817
  await invoke$h('Extensions.activateByEvent', event);
1818
1818
  };
1819
1819
 
1820
- const cacheName$1 = 'lvce-editor-character-widths-v1';
1820
+ // Older entries may have been measured before the bundled font was loaded.
1821
+ const cacheName$1 = 'lvce-editor-character-widths-v2';
1821
1822
  const character = 'a';
1822
1823
  const getKey$2 = (fontWeight, fontSize, fontFamily, letterSpacing) => {
1823
1824
  return `https://cache.invalid/character-width/${encodeURIComponent(JSON.stringify([character, fontWeight, fontSize, fontFamily, letterSpacing]))}`;
@@ -16804,7 +16805,19 @@ const getLanguages = async (platform, assetDir, applicationId) => {
16804
16805
  return invoke$9(applicationId, 'Extensions.getLanguages', platform, assetDir);
16805
16806
  };
16806
16807
 
16808
+ const loaded = Object.create(null);
16809
+ const setLoaded = id => {
16810
+ loaded[id] = true;
16811
+ };
16812
+ const isLoaded = id => {
16813
+ return loaded[id];
16814
+ };
16815
+
16807
16816
  const measureCharacterWidth = async (fontWeight, fontSize, fontFamily, letterSpacing) => {
16817
+ const isFiraCode = fontFamily === 'Fira Code' || fontFamily === "'Fira Code'";
16818
+ if (isFiraCode && !isLoaded('Fira Code')) {
16819
+ return measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
16820
+ }
16808
16821
  try {
16809
16822
  const cachedWidth = await get$a(fontWeight, fontSize, fontFamily, letterSpacing);
16810
16823
  if (cachedWidth !== undefined) {
@@ -26966,6 +26979,7 @@ const getDiagnostics = async editorUid => {
26966
26979
 
26967
26980
  const ensure = async (fontName, fontUrl) => {
26968
26981
  await invoke$f('TextMeasurement.ensureFont', fontName, fontUrl);
26982
+ setLoaded(fontName);
26969
26983
  };
26970
26984
 
26971
26985
  const getComponentState = uid => {
@@ -27899,7 +27913,7 @@ const updateFindWidget = async state => {
27899
27913
  commands
27900
27914
  });
27901
27915
  };
27902
- const handleSettingsChanged = async state => {
27916
+ const handleSettingsChanged = async (state, firaCodeFontUrl) => {
27903
27917
  const editorPreferences = {
27904
27918
  ...(await getEditorPreferences(state.applicationId)),
27905
27919
  ...(state.largeFile && getLargeFilePreferences())
@@ -27914,8 +27928,12 @@ const handleSettingsChanged = async state => {
27914
27928
  minimapEnabled,
27915
27929
  rowHeight
27916
27930
  } = editorPreferences;
27931
+ const isFiraCode = fontFamily === 'Fira Code' || fontFamily === "'Fira Code'";
27932
+ if (isFiraCode && firaCodeFontUrl) {
27933
+ await ensure('Fira Code', firaCodeFontUrl);
27934
+ }
27917
27935
  const [charWidth, completionsOnTypeRaw] = await Promise.all([measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing), state.applicationId === undefined ? get$2('editor.completionsOnType') : get$2('editor.completionsOnType', state.applicationId)]);
27918
- const isMonospaceFont = !editorPreferences.disableMonospaceOptimizations && (fontFamily === 'Fira Code' || fontFamily === "'Fira Code'");
27936
+ const isMonospaceFont = !editorPreferences.disableMonospaceOptimizations && isFiraCode;
27919
27937
  const editorWithUpdatedSettings = {
27920
27938
  ...state,
27921
27939
  ...editorPreferences,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.80.1",
3
+ "version": "19.80.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"