@lvce-editor/editor-worker 19.80.0 → 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 +58 -18
- package/dist/editorWorkerMain.js +57 -18
- package/package.json +1 -1
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
|
-
|
|
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 &&
|
|
27485
|
+
const isMonospaceFont = !editorPreferences.disableMonospaceOptimizations && isFiraCode;
|
|
27468
27486
|
const editorWithUpdatedSettings = {
|
|
27469
27487
|
...state,
|
|
27470
27488
|
...editorPreferences,
|
|
@@ -27510,6 +27528,20 @@ const applyTabCompletion = (editor, result) => {
|
|
|
27510
27528
|
return editorSnippet(editor, result);
|
|
27511
27529
|
};
|
|
27512
27530
|
|
|
27531
|
+
// State and undo history belong in this worker. Rendering reads changes separately.
|
|
27532
|
+
const wrapCommand = (fn, preservesTypingCoalescing = false) => {
|
|
27533
|
+
return wrapCommand$1(fn, preservesTypingCoalescing, false);
|
|
27534
|
+
};
|
|
27535
|
+
const wrapFocusCommand = fn => {
|
|
27536
|
+
return wrapFocusCommand$1(fn, false);
|
|
27537
|
+
};
|
|
27538
|
+
const wrapDeferredCommand = fn => {
|
|
27539
|
+
return wrapDeferredCommand$1(fn, false);
|
|
27540
|
+
};
|
|
27541
|
+
const wrapLatestCommand = fn => {
|
|
27542
|
+
return wrapLatestCommand$1(fn, false);
|
|
27543
|
+
};
|
|
27544
|
+
|
|
27513
27545
|
const insertTab = editor => {
|
|
27514
27546
|
return type(editor, getIndentString(editor));
|
|
27515
27547
|
};
|
|
@@ -27556,6 +27588,28 @@ const handleTab = async editor => {
|
|
|
27556
27588
|
return insertTab(editor);
|
|
27557
27589
|
}
|
|
27558
27590
|
};
|
|
27591
|
+
const createHandleTabCommand = () => {
|
|
27592
|
+
const handleTabFallback = wrapCommand(handleTab);
|
|
27593
|
+
const command = async uid => {
|
|
27594
|
+
// Deferred completion rendering can keep the editor's existing keyboard context.
|
|
27595
|
+
const editor = get$a(uid)?.newState;
|
|
27596
|
+
const widget = editor?.widgets.find(candidate => candidate.id === Completion);
|
|
27597
|
+
if (widget) {
|
|
27598
|
+
const hasItems = await invoke$4('Completions.hasItems', widget.newState.uid);
|
|
27599
|
+
if (!isCurrent$1(editor, get$a(uid)?.newState)) {
|
|
27600
|
+
return;
|
|
27601
|
+
}
|
|
27602
|
+
if (hasItems) {
|
|
27603
|
+
// Selecting a completion calls back into the editor's edit queue.
|
|
27604
|
+
await selectCurrent$1(uid);
|
|
27605
|
+
return;
|
|
27606
|
+
}
|
|
27607
|
+
}
|
|
27608
|
+
await handleTabFallback(uid);
|
|
27609
|
+
};
|
|
27610
|
+
registerStateCommand(command);
|
|
27611
|
+
return command;
|
|
27612
|
+
};
|
|
27559
27613
|
|
|
27560
27614
|
const relaunchWorkers = async () => {
|
|
27561
27615
|
await dispose();
|
|
@@ -28686,20 +28740,6 @@ const updateDebugInfo = async debugId => {
|
|
|
28686
28740
|
await RendererWorker.invoke('Editor.rerender', key);
|
|
28687
28741
|
};
|
|
28688
28742
|
|
|
28689
|
-
// State and undo history belong in this worker. Rendering reads changes separately.
|
|
28690
|
-
const wrapCommand = (fn, preservesTypingCoalescing = false) => {
|
|
28691
|
-
return wrapCommand$1(fn, preservesTypingCoalescing, false);
|
|
28692
|
-
};
|
|
28693
|
-
const wrapFocusCommand = fn => {
|
|
28694
|
-
return wrapFocusCommand$1(fn, false);
|
|
28695
|
-
};
|
|
28696
|
-
const wrapDeferredCommand = fn => {
|
|
28697
|
-
return wrapDeferredCommand$1(fn, false);
|
|
28698
|
-
};
|
|
28699
|
-
const wrapLatestCommand = fn => {
|
|
28700
|
-
return wrapLatestCommand$1(fn, false);
|
|
28701
|
-
};
|
|
28702
|
-
|
|
28703
28743
|
const handleMouseDownAndRender = (uid, ...args) => {
|
|
28704
28744
|
return executeAndRender(commandMap['Editor.handleMouseDown'], uid, args);
|
|
28705
28745
|
};
|
|
@@ -28887,7 +28927,7 @@ const commandMap = {
|
|
|
28887
28927
|
'Editor.handleSettingsChanged': wrapCommand(handleSettingsChanged),
|
|
28888
28928
|
'Editor.handleSingleClick': wrapCommand(handleSingleClick),
|
|
28889
28929
|
'Editor.handleSourceActionClick': selectItem,
|
|
28890
|
-
'Editor.handleTab':
|
|
28930
|
+
'Editor.handleTab': createHandleTabCommand(),
|
|
28891
28931
|
'Editor.handleTouchEnd': wrapCommand(handleTouchEnd),
|
|
28892
28932
|
'Editor.handleTouchMove': wrapCommand(handleTouchMove),
|
|
28893
28933
|
'Editor.handleTouchStart': wrapCommand(handleTouchStart),
|
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1817,7 +1817,8 @@ const activateByEvent = async (event, assetDir, platform) => {
|
|
|
1817
1817
|
await invoke$h('Extensions.activateByEvent', event);
|
|
1818
1818
|
};
|
|
1819
1819
|
|
|
1820
|
-
|
|
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 &&
|
|
27936
|
+
const isMonospaceFont = !editorPreferences.disableMonospaceOptimizations && isFiraCode;
|
|
27919
27937
|
const editorWithUpdatedSettings = {
|
|
27920
27938
|
...state,
|
|
27921
27939
|
...editorPreferences,
|
|
@@ -27961,6 +27979,20 @@ const applyTabCompletion = (editor, result) => {
|
|
|
27961
27979
|
return editorSnippet(editor, result);
|
|
27962
27980
|
};
|
|
27963
27981
|
|
|
27982
|
+
// State and undo history belong in this worker. Rendering reads changes separately.
|
|
27983
|
+
const wrapCommand = (fn, preservesTypingCoalescing = false) => {
|
|
27984
|
+
return wrapCommand$1(fn, preservesTypingCoalescing, false);
|
|
27985
|
+
};
|
|
27986
|
+
const wrapFocusCommand = fn => {
|
|
27987
|
+
return wrapFocusCommand$1(fn, false);
|
|
27988
|
+
};
|
|
27989
|
+
const wrapDeferredCommand = fn => {
|
|
27990
|
+
return wrapDeferredCommand$1(fn, false);
|
|
27991
|
+
};
|
|
27992
|
+
const wrapLatestCommand = fn => {
|
|
27993
|
+
return wrapLatestCommand$1(fn, false);
|
|
27994
|
+
};
|
|
27995
|
+
|
|
27964
27996
|
const insertTab = editor => {
|
|
27965
27997
|
return type(editor, getIndentString(editor));
|
|
27966
27998
|
};
|
|
@@ -28007,6 +28039,27 @@ const handleTab = async editor => {
|
|
|
28007
28039
|
return insertTab(editor);
|
|
28008
28040
|
}
|
|
28009
28041
|
};
|
|
28042
|
+
const createHandleTabCommand = () => {
|
|
28043
|
+
const handleTabFallback = wrapCommand(handleTab);
|
|
28044
|
+
const command = async uid => {
|
|
28045
|
+
// Deferred completion rendering can keep the editor's existing keyboard context.
|
|
28046
|
+
const editor = get$9(uid)?.newState;
|
|
28047
|
+
const widget = editor?.widgets.find(candidate => candidate.id === Completion);
|
|
28048
|
+
if (widget) {
|
|
28049
|
+
const hasItems = await invoke$4('Completions.hasItems', widget.newState.uid);
|
|
28050
|
+
if (!isCurrent$1(editor, get$9(uid)?.newState)) {
|
|
28051
|
+
return;
|
|
28052
|
+
}
|
|
28053
|
+
if (hasItems) {
|
|
28054
|
+
// Selecting a completion calls back into the editor's edit queue.
|
|
28055
|
+
await selectCurrent$1(uid);
|
|
28056
|
+
return;
|
|
28057
|
+
}
|
|
28058
|
+
}
|
|
28059
|
+
await handleTabFallback(uid);
|
|
28060
|
+
};
|
|
28061
|
+
return command;
|
|
28062
|
+
};
|
|
28010
28063
|
|
|
28011
28064
|
const relaunchWorkers = async () => {
|
|
28012
28065
|
await dispose();
|
|
@@ -29137,20 +29190,6 @@ const updateDebugInfo = async debugId => {
|
|
|
29137
29190
|
await invoke$e('Editor.rerender', key);
|
|
29138
29191
|
};
|
|
29139
29192
|
|
|
29140
|
-
// State and undo history belong in this worker. Rendering reads changes separately.
|
|
29141
|
-
const wrapCommand = (fn, preservesTypingCoalescing = false) => {
|
|
29142
|
-
return wrapCommand$1(fn, preservesTypingCoalescing, false);
|
|
29143
|
-
};
|
|
29144
|
-
const wrapFocusCommand = fn => {
|
|
29145
|
-
return wrapFocusCommand$1(fn, false);
|
|
29146
|
-
};
|
|
29147
|
-
const wrapDeferredCommand = fn => {
|
|
29148
|
-
return wrapDeferredCommand$1(fn, false);
|
|
29149
|
-
};
|
|
29150
|
-
const wrapLatestCommand = fn => {
|
|
29151
|
-
return wrapLatestCommand$1(fn, false);
|
|
29152
|
-
};
|
|
29153
|
-
|
|
29154
29193
|
const handleMouseDownAndRender = (uid, ...args) => {
|
|
29155
29194
|
return executeAndRender(commandMap['Editor.handleMouseDown'], uid, args);
|
|
29156
29195
|
};
|
|
@@ -29335,7 +29374,7 @@ const commandMap = {
|
|
|
29335
29374
|
'Editor.handleSettingsChanged': wrapCommand(handleSettingsChanged),
|
|
29336
29375
|
'Editor.handleSingleClick': wrapCommand(handleSingleClick),
|
|
29337
29376
|
'Editor.handleSourceActionClick': selectItem,
|
|
29338
|
-
'Editor.handleTab':
|
|
29377
|
+
'Editor.handleTab': createHandleTabCommand(),
|
|
29339
29378
|
'Editor.handleTouchEnd': wrapCommand(handleTouchEnd),
|
|
29340
29379
|
'Editor.handleTouchMove': wrapCommand(handleTouchMove),
|
|
29341
29380
|
'Editor.handleTouchStart': wrapCommand(handleTouchStart),
|