@lvce-editor/editor-worker 19.19.0 → 19.20.0
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/editorWorkerMain.js +126 -87
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -11215,6 +11215,104 @@ const handleMessagePort = async (port, rpcId) => {
|
|
|
11215
11215
|
}
|
|
11216
11216
|
};
|
|
11217
11217
|
|
|
11218
|
+
const kLineHeight = 'editor.lineHeight';
|
|
11219
|
+
const kFontSize = 'editor.fontSize';
|
|
11220
|
+
const kFontFamily = 'editor.fontFamily';
|
|
11221
|
+
const kLetterSpacing = 'editor.letterSpacing';
|
|
11222
|
+
const kTabSize = 'editor.tabSize';
|
|
11223
|
+
const kLineNumbers = 'editor.lineNumbers';
|
|
11224
|
+
const kDiagnostics = 'editor.diagnostics';
|
|
11225
|
+
const kQuickSuggestions = 'editor.quickSuggestions';
|
|
11226
|
+
const kAutoClosingQuotes = 'editor.autoClosingQuotes';
|
|
11227
|
+
const kAutoClosingBrackets = 'editor.autoclosingBrackets';
|
|
11228
|
+
const kFontWeight = 'editor.fontWeight';
|
|
11229
|
+
const isAutoClosingBracketsEnabled = async () => {
|
|
11230
|
+
return Boolean(await get$2(kAutoClosingBrackets));
|
|
11231
|
+
};
|
|
11232
|
+
const isAutoClosingQuotesEnabled = async () => {
|
|
11233
|
+
return Boolean(await get$2(kAutoClosingQuotes));
|
|
11234
|
+
};
|
|
11235
|
+
const isQuickSuggestionsEnabled = async () => {
|
|
11236
|
+
return Boolean(await get$2(kQuickSuggestions));
|
|
11237
|
+
};
|
|
11238
|
+
const isAutoClosingTagsEnabled = async () => {
|
|
11239
|
+
return true;
|
|
11240
|
+
};
|
|
11241
|
+
const getRowHeight = async () => {
|
|
11242
|
+
return (await get$2(kLineHeight)) || 20;
|
|
11243
|
+
};
|
|
11244
|
+
const getFontSize = async () => {
|
|
11245
|
+
return (await get$2(kFontSize)) || 15; // TODO find out if it is possible to use all numeric values for settings for efficiency, maybe settings could be an array
|
|
11246
|
+
};
|
|
11247
|
+
const getFontFamily = async () => {
|
|
11248
|
+
return (await get$2(kFontFamily)) || 'Fira Code';
|
|
11249
|
+
};
|
|
11250
|
+
const getLetterSpacing = async () => {
|
|
11251
|
+
// if (!false) {
|
|
11252
|
+
// return 0
|
|
11253
|
+
// }
|
|
11254
|
+
return (await get$2(kLetterSpacing)) ?? 0.5;
|
|
11255
|
+
};
|
|
11256
|
+
const getTabSize = async () => {
|
|
11257
|
+
return (await get$2(kTabSize)) || 2;
|
|
11258
|
+
};
|
|
11259
|
+
const getLineNumbers = async () => {
|
|
11260
|
+
return (await get$2(kLineNumbers)) ?? false;
|
|
11261
|
+
};
|
|
11262
|
+
const getCompletionTriggerCharacters = async () => {
|
|
11263
|
+
return ['.', '/'];
|
|
11264
|
+
};
|
|
11265
|
+
const diagnosticsEnabled = async () => {
|
|
11266
|
+
return (await get$2(kDiagnostics)) ?? false;
|
|
11267
|
+
};
|
|
11268
|
+
const getFontWeight = async () => {
|
|
11269
|
+
return (await get$2(kFontWeight)) ?? 400;
|
|
11270
|
+
};
|
|
11271
|
+
|
|
11272
|
+
const getEditorPreferences = async () => {
|
|
11273
|
+
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters()]);
|
|
11274
|
+
return {
|
|
11275
|
+
completionTriggerCharacters,
|
|
11276
|
+
diagnosticsEnabled: diagnosticsEnabled$1,
|
|
11277
|
+
fontFamily,
|
|
11278
|
+
fontSize,
|
|
11279
|
+
fontWeight,
|
|
11280
|
+
isAutoClosingBracketsEnabled: isAutoClosingBracketsEnabled$1,
|
|
11281
|
+
isAutoClosingQuotesEnabled: isAutoClosingQuotesEnabled$1,
|
|
11282
|
+
isAutoClosingTagsEnabled: isAutoClosingTagsEnabled$1,
|
|
11283
|
+
isQuickSuggestionsEnabled: isQuickSuggestionsEnabled$1,
|
|
11284
|
+
letterSpacing,
|
|
11285
|
+
lineNumbers,
|
|
11286
|
+
rowHeight,
|
|
11287
|
+
tabSize
|
|
11288
|
+
};
|
|
11289
|
+
};
|
|
11290
|
+
|
|
11291
|
+
const handleSettingsChanged = async state => {
|
|
11292
|
+
const editorPreferences = await getEditorPreferences();
|
|
11293
|
+
const {
|
|
11294
|
+
diagnosticsEnabled,
|
|
11295
|
+
fontFamily,
|
|
11296
|
+
fontSize,
|
|
11297
|
+
fontWeight,
|
|
11298
|
+
letterSpacing,
|
|
11299
|
+
rowHeight
|
|
11300
|
+
} = editorPreferences;
|
|
11301
|
+
const [charWidth, completionsOnTypeRaw] = await Promise.all([measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing), get$2('editor.completionsOnType')]);
|
|
11302
|
+
const isMonospaceFont = fontFamily === 'Fira Code' || fontFamily === "'Fira Code'";
|
|
11303
|
+
const editorWithUpdatedSettings = {
|
|
11304
|
+
...state,
|
|
11305
|
+
...editorPreferences,
|
|
11306
|
+
charWidth,
|
|
11307
|
+
completionsOnType: Boolean(completionsOnTypeRaw),
|
|
11308
|
+
diagnostics: diagnosticsEnabled ? state.diagnostics : [],
|
|
11309
|
+
isMonospaceFont,
|
|
11310
|
+
itemHeight: rowHeight,
|
|
11311
|
+
visualDecorations: diagnosticsEnabled ? state.visualDecorations : []
|
|
11312
|
+
};
|
|
11313
|
+
return resize(editorWithUpdatedSettings, {}, charWidth);
|
|
11314
|
+
};
|
|
11315
|
+
|
|
11218
11316
|
const applyTabCompletion = (editor, result) => {
|
|
11219
11317
|
return editorSnippet(editor, result);
|
|
11220
11318
|
};
|
|
@@ -11420,79 +11518,6 @@ const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
|
11420
11518
|
await initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental);
|
|
11421
11519
|
};
|
|
11422
11520
|
|
|
11423
|
-
const kLineHeight = 'editor.lineHeight';
|
|
11424
|
-
const kFontSize = 'editor.fontSize';
|
|
11425
|
-
const kFontFamily = 'editor.fontFamily';
|
|
11426
|
-
const kLetterSpacing = 'editor.letterSpacing';
|
|
11427
|
-
const kTabSize = 'editor.tabSize';
|
|
11428
|
-
const kLineNumbers = 'editor.lineNumbers';
|
|
11429
|
-
const kDiagnostics = 'editor.diagnostics';
|
|
11430
|
-
const kQuickSuggestions = 'editor.quickSuggestions';
|
|
11431
|
-
const kAutoClosingQuotes = 'editor.autoClosingQuotes';
|
|
11432
|
-
const kAutoClosingBrackets = 'editor.autoclosingBrackets';
|
|
11433
|
-
const kFontWeight = 'editor.fontWeight';
|
|
11434
|
-
const isAutoClosingBracketsEnabled = async () => {
|
|
11435
|
-
return Boolean(await get$2(kAutoClosingBrackets));
|
|
11436
|
-
};
|
|
11437
|
-
const isAutoClosingQuotesEnabled = async () => {
|
|
11438
|
-
return Boolean(await get$2(kAutoClosingQuotes));
|
|
11439
|
-
};
|
|
11440
|
-
const isQuickSuggestionsEnabled = async () => {
|
|
11441
|
-
return Boolean(await get$2(kQuickSuggestions));
|
|
11442
|
-
};
|
|
11443
|
-
const isAutoClosingTagsEnabled = async () => {
|
|
11444
|
-
return true;
|
|
11445
|
-
};
|
|
11446
|
-
const getRowHeight = async () => {
|
|
11447
|
-
return (await get$2(kLineHeight)) || 20;
|
|
11448
|
-
};
|
|
11449
|
-
const getFontSize = async () => {
|
|
11450
|
-
return (await get$2(kFontSize)) || 15; // TODO find out if it is possible to use all numeric values for settings for efficiency, maybe settings could be an array
|
|
11451
|
-
};
|
|
11452
|
-
const getFontFamily = async () => {
|
|
11453
|
-
return (await get$2(kFontFamily)) || 'Fira Code';
|
|
11454
|
-
};
|
|
11455
|
-
const getLetterSpacing = async () => {
|
|
11456
|
-
// if (!false) {
|
|
11457
|
-
// return 0
|
|
11458
|
-
// }
|
|
11459
|
-
return (await get$2(kLetterSpacing)) ?? 0.5;
|
|
11460
|
-
};
|
|
11461
|
-
const getTabSize = async () => {
|
|
11462
|
-
return (await get$2(kTabSize)) || 2;
|
|
11463
|
-
};
|
|
11464
|
-
const getLineNumbers = async () => {
|
|
11465
|
-
return (await get$2(kLineNumbers)) ?? false;
|
|
11466
|
-
};
|
|
11467
|
-
const getCompletionTriggerCharacters = async () => {
|
|
11468
|
-
return ['.', '/'];
|
|
11469
|
-
};
|
|
11470
|
-
const diagnosticsEnabled = async () => {
|
|
11471
|
-
return (await get$2(kDiagnostics)) ?? false;
|
|
11472
|
-
};
|
|
11473
|
-
const getFontWeight = async () => {
|
|
11474
|
-
return (await get$2(kFontWeight)) ?? 400;
|
|
11475
|
-
};
|
|
11476
|
-
|
|
11477
|
-
const getEditorPreferences = async () => {
|
|
11478
|
-
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters()]);
|
|
11479
|
-
return {
|
|
11480
|
-
completionTriggerCharacters,
|
|
11481
|
-
diagnosticsEnabled: diagnosticsEnabled$1,
|
|
11482
|
-
fontFamily,
|
|
11483
|
-
fontSize,
|
|
11484
|
-
fontWeight,
|
|
11485
|
-
isAutoClosingBracketsEnabled: isAutoClosingBracketsEnabled$1,
|
|
11486
|
-
isAutoClosingQuotesEnabled: isAutoClosingQuotesEnabled$1,
|
|
11487
|
-
isAutoClosingTagsEnabled: isAutoClosingTagsEnabled$1,
|
|
11488
|
-
isQuickSuggestionsEnabled: isQuickSuggestionsEnabled$1,
|
|
11489
|
-
letterSpacing,
|
|
11490
|
-
lineNumbers,
|
|
11491
|
-
rowHeight,
|
|
11492
|
-
tabSize
|
|
11493
|
-
};
|
|
11494
|
-
};
|
|
11495
|
-
|
|
11496
11521
|
const getTokenizePath = (languages, languageId) => {
|
|
11497
11522
|
for (const language of languages) {
|
|
11498
11523
|
if (language?.id === languageId && language.tokenize) {
|
|
@@ -12638,24 +12663,37 @@ const updateDebugInfo = async debugId => {
|
|
|
12638
12663
|
await invoke$b('Editor.rerender', key);
|
|
12639
12664
|
};
|
|
12640
12665
|
|
|
12666
|
+
const queues = [];
|
|
12667
|
+
|
|
12641
12668
|
// TODO wrap commands globally, not per editor
|
|
12642
12669
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
12643
12670
|
|
|
12644
|
-
const wrapCommand = fn => async (
|
|
12645
|
-
const
|
|
12646
|
-
const
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12671
|
+
const wrapCommand = fn => async (uid, ...args) => {
|
|
12672
|
+
const previous = queues[uid];
|
|
12673
|
+
const {
|
|
12674
|
+
promise: next,
|
|
12675
|
+
resolve
|
|
12676
|
+
} = Promise.withResolvers();
|
|
12677
|
+
queues[uid] = next;
|
|
12678
|
+
if (previous) {
|
|
12679
|
+
await previous;
|
|
12680
|
+
}
|
|
12681
|
+
try {
|
|
12682
|
+
const oldInstance = get$7(uid);
|
|
12683
|
+
const state = oldInstance.newState;
|
|
12684
|
+
const newEditor = await fn(state, ...args);
|
|
12685
|
+
if (state === newEditor) {
|
|
12686
|
+
return newEditor;
|
|
12687
|
+
}
|
|
12688
|
+
const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
|
|
12689
|
+
set$9(uid, state, newEditorWithDerivedState);
|
|
12690
|
+
return newEditorWithDerivedState;
|
|
12691
|
+
} finally {
|
|
12692
|
+
resolve();
|
|
12693
|
+
if (queues[uid] === next) {
|
|
12694
|
+
queues[uid] = undefined;
|
|
12695
|
+
}
|
|
12650
12696
|
}
|
|
12651
|
-
const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
|
|
12652
|
-
|
|
12653
|
-
// TODO if editor did not change, no need to update furthur
|
|
12654
|
-
|
|
12655
|
-
// TODO combine neweditor with latest editor?
|
|
12656
|
-
|
|
12657
|
-
set$9(editorUid, state, newEditorWithDerivedState);
|
|
12658
|
-
return newEditorWithDerivedState;
|
|
12659
12697
|
};
|
|
12660
12698
|
|
|
12661
12699
|
const commandMap = {
|
|
@@ -12766,6 +12804,7 @@ const commandMap = {
|
|
|
12766
12804
|
'Editor.handleScrollBarVerticalMove': wrapCommand(handleScrollBarVerticalPointerMove),
|
|
12767
12805
|
'Editor.handleScrollBarVerticalPointerDown': wrapCommand(handleScrollBarPointerDown),
|
|
12768
12806
|
'Editor.handleScrollBarVerticalPointerMove': wrapCommand(handleScrollBarVerticalPointerMove),
|
|
12807
|
+
'Editor.handleSettingsChanged': wrapCommand(handleSettingsChanged),
|
|
12769
12808
|
'Editor.handleSingleClick': wrapCommand(handleSingleClick),
|
|
12770
12809
|
'Editor.handleTab': wrapCommand(handleTab),
|
|
12771
12810
|
'Editor.handleTouchEnd': wrapCommand(handleTouchEnd),
|