@lvce-editor/editor-worker 19.29.6 → 19.29.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/editorWorkerMain.js +105 -34
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1909,12 +1909,12 @@ const launchColorPickerWorker = async () => {
|
|
|
1909
1909
|
return launchWorker(name, url);
|
|
1910
1910
|
};
|
|
1911
1911
|
|
|
1912
|
-
const state$
|
|
1912
|
+
const state$d = {};
|
|
1913
1913
|
const getOrCreate$3 = () => {
|
|
1914
|
-
if (!state$
|
|
1915
|
-
state$
|
|
1914
|
+
if (!state$d.workerPromise) {
|
|
1915
|
+
state$d.workerPromise = launchColorPickerWorker();
|
|
1916
1916
|
}
|
|
1917
|
-
return state$
|
|
1917
|
+
return state$d.workerPromise;
|
|
1918
1918
|
};
|
|
1919
1919
|
const invoke$8 = async (method, ...params) => {
|
|
1920
1920
|
const worker = await getOrCreate$3();
|
|
@@ -1941,7 +1941,7 @@ const loadContent$3 = async (state, parentUid) => {
|
|
|
1941
1941
|
|
|
1942
1942
|
const editorStates = create$9();
|
|
1943
1943
|
const {
|
|
1944
|
-
dispose: dispose$
|
|
1944
|
+
dispose: dispose$3,
|
|
1945
1945
|
getCommandIds,
|
|
1946
1946
|
registerCommands,
|
|
1947
1947
|
wrapGetter
|
|
@@ -2476,7 +2476,7 @@ const getInitialLineState = initialLineState => {
|
|
|
2476
2476
|
return deepCopy(initialLineState);
|
|
2477
2477
|
};
|
|
2478
2478
|
|
|
2479
|
-
const state$
|
|
2479
|
+
const state$c = {
|
|
2480
2480
|
warned: []
|
|
2481
2481
|
};
|
|
2482
2482
|
const flattenTokensArray = tokens => {
|
|
@@ -2488,10 +2488,10 @@ const flattenTokensArray = tokens => {
|
|
|
2488
2488
|
return flattened;
|
|
2489
2489
|
};
|
|
2490
2490
|
const warnDeprecatedArrayReturn = (languageId, fn) => {
|
|
2491
|
-
if (state$
|
|
2491
|
+
if (state$c.warned.includes(fn)) {
|
|
2492
2492
|
return;
|
|
2493
2493
|
}
|
|
2494
|
-
state$
|
|
2494
|
+
state$c.warned.push(fn);
|
|
2495
2495
|
console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
|
|
2496
2496
|
};
|
|
2497
2497
|
const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
|
|
@@ -2552,14 +2552,14 @@ const TokenizePlainText = {
|
|
|
2552
2552
|
tokenizeLine
|
|
2553
2553
|
};
|
|
2554
2554
|
|
|
2555
|
-
const state$
|
|
2555
|
+
const state$b = {
|
|
2556
2556
|
enabled: false
|
|
2557
2557
|
};
|
|
2558
2558
|
const setEnabled$1 = value => {
|
|
2559
|
-
state$
|
|
2559
|
+
state$b.enabled = value;
|
|
2560
2560
|
};
|
|
2561
2561
|
const getEnabled$1 = () => {
|
|
2562
|
-
return state$
|
|
2562
|
+
return state$b.enabled;
|
|
2563
2563
|
};
|
|
2564
2564
|
|
|
2565
2565
|
const {
|
|
@@ -2567,25 +2567,25 @@ const {
|
|
|
2567
2567
|
set: set$6
|
|
2568
2568
|
} = SyntaxHighlightingWorker;
|
|
2569
2569
|
|
|
2570
|
-
const state$
|
|
2570
|
+
const state$a = {
|
|
2571
2571
|
pending: Object.create(null),
|
|
2572
2572
|
tokenizePaths: Object.create(null),
|
|
2573
2573
|
tokenizers: Object.create(null)
|
|
2574
2574
|
};
|
|
2575
2575
|
const has = languageId => {
|
|
2576
|
-
return Object.hasOwn(state$
|
|
2576
|
+
return Object.hasOwn(state$a.tokenizers, languageId);
|
|
2577
2577
|
};
|
|
2578
2578
|
const set$5 = (languageId, tokenizer) => {
|
|
2579
|
-
state$
|
|
2579
|
+
state$a.tokenizers[languageId] = tokenizer;
|
|
2580
2580
|
};
|
|
2581
2581
|
const get$6 = languageId => {
|
|
2582
|
-
return state$
|
|
2582
|
+
return state$a.tokenizers[languageId];
|
|
2583
2583
|
};
|
|
2584
2584
|
const setTokenizePath = (languageId, tokenizePath) => {
|
|
2585
|
-
state$
|
|
2585
|
+
state$a.tokenizePaths[languageId] = tokenizePath;
|
|
2586
2586
|
};
|
|
2587
2587
|
const getTokenizePath$1 = languageId => {
|
|
2588
|
-
return state$
|
|
2588
|
+
return state$a.tokenizePaths[languageId] || '';
|
|
2589
2589
|
};
|
|
2590
2590
|
const setTokenizePaths = languages => {
|
|
2591
2591
|
for (const language of languages) {
|
|
@@ -2595,7 +2595,7 @@ const setTokenizePaths = languages => {
|
|
|
2595
2595
|
}
|
|
2596
2596
|
};
|
|
2597
2597
|
const isPending = languageId => {
|
|
2598
|
-
return Object.hasOwn(state$
|
|
2598
|
+
return Object.hasOwn(state$a.pending, languageId);
|
|
2599
2599
|
};
|
|
2600
2600
|
|
|
2601
2601
|
const tokenMaps = Object.create(null);
|
|
@@ -3391,14 +3391,14 @@ const getVisible$1 = async (editor, syncIncremental) => {
|
|
|
3391
3391
|
};
|
|
3392
3392
|
};
|
|
3393
3393
|
|
|
3394
|
-
const state$
|
|
3394
|
+
const state$9 = {
|
|
3395
3395
|
enabled: false
|
|
3396
3396
|
};
|
|
3397
3397
|
const setEnabled = value => {
|
|
3398
|
-
state$
|
|
3398
|
+
state$9.enabled = value;
|
|
3399
3399
|
};
|
|
3400
3400
|
const getEnabled = () => {
|
|
3401
|
-
return state$
|
|
3401
|
+
return state$9.enabled;
|
|
3402
3402
|
};
|
|
3403
3403
|
|
|
3404
3404
|
// TODO this should be in a separate scrolling module
|
|
@@ -3623,7 +3623,7 @@ const getUrlAtOffset = (editor, offset) => {
|
|
|
3623
3623
|
|
|
3624
3624
|
const EditorChange = 1;
|
|
3625
3625
|
|
|
3626
|
-
const state$
|
|
3626
|
+
const state$8 = Object.create(null);
|
|
3627
3627
|
|
|
3628
3628
|
/**
|
|
3629
3629
|
* Register a listener for a specific event type
|
|
@@ -3633,13 +3633,13 @@ const state$7 = Object.create(null);
|
|
|
3633
3633
|
const registerListener$1 = (listenerType, rpcId) => {
|
|
3634
3634
|
number(listenerType);
|
|
3635
3635
|
number(rpcId);
|
|
3636
|
-
if (!Object.hasOwn(state$
|
|
3637
|
-
state$
|
|
3636
|
+
if (!Object.hasOwn(state$8, listenerType)) {
|
|
3637
|
+
state$8[listenerType] = [];
|
|
3638
3638
|
}
|
|
3639
3639
|
|
|
3640
3640
|
// Avoid duplicate registrations
|
|
3641
|
-
if (!state$
|
|
3642
|
-
state$
|
|
3641
|
+
if (!state$8[listenerType].includes(rpcId)) {
|
|
3642
|
+
state$8[listenerType].push(rpcId);
|
|
3643
3643
|
}
|
|
3644
3644
|
};
|
|
3645
3645
|
|
|
@@ -3651,10 +3651,10 @@ const registerListener$1 = (listenerType, rpcId) => {
|
|
|
3651
3651
|
const unregisterListener$1 = (listenerType, rpcId) => {
|
|
3652
3652
|
number(listenerType);
|
|
3653
3653
|
number(rpcId);
|
|
3654
|
-
if (Object.hasOwn(state$
|
|
3655
|
-
const index = state$
|
|
3654
|
+
if (Object.hasOwn(state$8, listenerType)) {
|
|
3655
|
+
const index = state$8[listenerType].indexOf(rpcId);
|
|
3656
3656
|
if (index !== -1) {
|
|
3657
|
-
state$
|
|
3657
|
+
state$8[listenerType].splice(index, 1);
|
|
3658
3658
|
}
|
|
3659
3659
|
}
|
|
3660
3660
|
};
|
|
@@ -3666,7 +3666,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
|
|
|
3666
3666
|
*/
|
|
3667
3667
|
const getListeners = listenerType => {
|
|
3668
3668
|
number(listenerType);
|
|
3669
|
-
return state$
|
|
3669
|
+
return state$8[listenerType] || [];
|
|
3670
3670
|
};
|
|
3671
3671
|
|
|
3672
3672
|
/**
|
|
@@ -4782,6 +4782,44 @@ const diff2 = uid => {
|
|
|
4782
4782
|
return result;
|
|
4783
4783
|
};
|
|
4784
4784
|
|
|
4785
|
+
const autoSaveDelay = 1000;
|
|
4786
|
+
const pendingSaves = new Map();
|
|
4787
|
+
const state$7 = {
|
|
4788
|
+
nextToken: 0
|
|
4789
|
+
};
|
|
4790
|
+
const run = async (uid, token, save) => {
|
|
4791
|
+
if (!isLatest(uid, token)) {
|
|
4792
|
+
return;
|
|
4793
|
+
}
|
|
4794
|
+
await save(token);
|
|
4795
|
+
};
|
|
4796
|
+
const schedule = (uid, save) => {
|
|
4797
|
+
dispose$2(uid);
|
|
4798
|
+
const token = ++state$7.nextToken;
|
|
4799
|
+
const timeout = setTimeout(run, autoSaveDelay, uid, token, save);
|
|
4800
|
+
pendingSaves.set(uid, {
|
|
4801
|
+
timeout,
|
|
4802
|
+
token
|
|
4803
|
+
});
|
|
4804
|
+
};
|
|
4805
|
+
const isLatest = (uid, token) => {
|
|
4806
|
+
return pendingSaves.get(uid)?.token === token;
|
|
4807
|
+
};
|
|
4808
|
+
const consume = (uid, token) => {
|
|
4809
|
+
if (!isLatest(uid, token)) {
|
|
4810
|
+
return;
|
|
4811
|
+
}
|
|
4812
|
+
dispose$2(uid);
|
|
4813
|
+
};
|
|
4814
|
+
const dispose$2 = uid => {
|
|
4815
|
+
const pendingSave = pendingSaves.get(uid);
|
|
4816
|
+
if (!pendingSave) {
|
|
4817
|
+
return;
|
|
4818
|
+
}
|
|
4819
|
+
clearTimeout(pendingSave.timeout);
|
|
4820
|
+
pendingSaves.delete(uid);
|
|
4821
|
+
};
|
|
4822
|
+
|
|
4785
4823
|
const addWidget$1 = widget => {
|
|
4786
4824
|
const module = get$7(widget.id);
|
|
4787
4825
|
if (!module) {
|
|
@@ -4874,6 +4912,7 @@ const disposeEditor = async editorUid => {
|
|
|
4874
4912
|
});
|
|
4875
4913
|
dispose$1(editorUid);
|
|
4876
4914
|
dispose$2(editorUid);
|
|
4915
|
+
dispose$3(editorUid);
|
|
4877
4916
|
return commands;
|
|
4878
4917
|
};
|
|
4879
4918
|
|
|
@@ -7048,16 +7087,19 @@ const goTo = async ({
|
|
|
7048
7087
|
return editor;
|
|
7049
7088
|
} catch (error) {
|
|
7050
7089
|
// TODO if editor is already disposed at this point, do nothing
|
|
7090
|
+
if (error === null || error === undefined) {
|
|
7091
|
+
const info = getWordAt$1(editor, rowIndex, columnIndex);
|
|
7092
|
+
const message = getNoLocationFoundMessage(info);
|
|
7093
|
+
return editorShowMessage(editor, rowIndex, columnIndex, message);
|
|
7094
|
+
}
|
|
7051
7095
|
if (isNoProviderFoundError(error)) {
|
|
7052
7096
|
const displayErrorMessage = getErrorMessage(error);
|
|
7053
|
-
|
|
7054
|
-
return editor;
|
|
7097
|
+
return editorShowMessage(editor, rowIndex, columnIndex, displayErrorMessage);
|
|
7055
7098
|
}
|
|
7056
7099
|
// @ts-ignore
|
|
7057
7100
|
// ErrorHandling.handleError(error, false)
|
|
7058
7101
|
const displayErrorMessage = getErrorMessage(error);
|
|
7059
|
-
|
|
7060
|
-
return editor;
|
|
7102
|
+
return editorShowMessage(editor, rowIndex, columnIndex, displayErrorMessage);
|
|
7061
7103
|
}
|
|
7062
7104
|
};
|
|
7063
7105
|
|
|
@@ -13653,6 +13695,30 @@ const editorDiagnosticEffect = {
|
|
|
13653
13695
|
};
|
|
13654
13696
|
|
|
13655
13697
|
const queues = {};
|
|
13698
|
+
const saveAfterDelay = async (uid, token) => {
|
|
13699
|
+
if (!get$8(uid)) {
|
|
13700
|
+
consume(uid, token);
|
|
13701
|
+
return;
|
|
13702
|
+
}
|
|
13703
|
+
let didSave = false;
|
|
13704
|
+
const save$1 = wrapCommand(async editor => {
|
|
13705
|
+
if (!isLatest(uid, token)) {
|
|
13706
|
+
return editor;
|
|
13707
|
+
}
|
|
13708
|
+
consume(uid, token);
|
|
13709
|
+
const autoSave = await get$3('files.autoSave');
|
|
13710
|
+
if (autoSave !== 'afterDelay') {
|
|
13711
|
+
return editor;
|
|
13712
|
+
}
|
|
13713
|
+
const savedEditor = await save(editor);
|
|
13714
|
+
didSave = savedEditor !== editor;
|
|
13715
|
+
return savedEditor;
|
|
13716
|
+
});
|
|
13717
|
+
await save$1(uid);
|
|
13718
|
+
if (didSave) {
|
|
13719
|
+
await invoke$a('Editor.renderPending', uid);
|
|
13720
|
+
}
|
|
13721
|
+
};
|
|
13656
13722
|
|
|
13657
13723
|
// TODO wrap commands globally, not per editor
|
|
13658
13724
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
@@ -13717,6 +13783,11 @@ const wrapCommand = fn => async (uid, ...args) => {
|
|
|
13717
13783
|
set$8(otherUid, instance.oldState, synchronizedEditor);
|
|
13718
13784
|
}
|
|
13719
13785
|
}
|
|
13786
|
+
if (lines !== finalEditor.lines) {
|
|
13787
|
+
schedule(uid, token => saveAfterDelay(uid, token));
|
|
13788
|
+
} else if (modified && !finalEditor.modified) {
|
|
13789
|
+
dispose$2(uid);
|
|
13790
|
+
}
|
|
13720
13791
|
return finalEditor;
|
|
13721
13792
|
} finally {
|
|
13722
13793
|
resolve();
|