@lvce-editor/editor-worker 1.4.0 → 1.5.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 +49 -14
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -5246,12 +5246,12 @@ const isPending = languageId => {
|
|
|
5246
5246
|
return languageId in state$1.pending;
|
|
5247
5247
|
};
|
|
5248
5248
|
|
|
5249
|
-
let enabled = false;
|
|
5250
|
-
const setEnabled = value => {
|
|
5251
|
-
enabled = value;
|
|
5249
|
+
let enabled$1 = false;
|
|
5250
|
+
const setEnabled$1 = value => {
|
|
5251
|
+
enabled$1 = value;
|
|
5252
5252
|
};
|
|
5253
|
-
const getEnabled = () => {
|
|
5254
|
-
return enabled;
|
|
5253
|
+
const getEnabled$1 = () => {
|
|
5254
|
+
return enabled$1;
|
|
5255
5255
|
};
|
|
5256
5256
|
|
|
5257
5257
|
const {
|
|
@@ -5272,7 +5272,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
5272
5272
|
if (!tokenizePath) {
|
|
5273
5273
|
return;
|
|
5274
5274
|
}
|
|
5275
|
-
if (getEnabled()) {
|
|
5275
|
+
if (getEnabled$1()) {
|
|
5276
5276
|
const tokenMap = await invoke$1('Tokenizer.load', languageId, tokenizePath);
|
|
5277
5277
|
set$1(languageId, tokenMap);
|
|
5278
5278
|
return;
|
|
@@ -6618,12 +6618,23 @@ const handleBeforeInput = (editor, inputType, data) => {
|
|
|
6618
6618
|
}
|
|
6619
6619
|
};
|
|
6620
6620
|
|
|
6621
|
-
|
|
6621
|
+
let enabled = false;
|
|
6622
|
+
const setEnabled = value => {
|
|
6623
|
+
enabled = value;
|
|
6624
|
+
};
|
|
6625
|
+
const getEnabled = () => {
|
|
6626
|
+
return enabled;
|
|
6627
|
+
};
|
|
6628
|
+
|
|
6629
|
+
const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
6622
6630
|
await listen$5();
|
|
6623
6631
|
if (syntaxHighlightingEnabled) {
|
|
6624
|
-
setEnabled(true);
|
|
6632
|
+
setEnabled$1(true);
|
|
6625
6633
|
await listen$6();
|
|
6626
6634
|
}
|
|
6635
|
+
if (syncIncremental) {
|
|
6636
|
+
setEnabled(true);
|
|
6637
|
+
}
|
|
6627
6638
|
await listen$7();
|
|
6628
6639
|
};
|
|
6629
6640
|
|
|
@@ -6883,11 +6894,34 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
|
|
|
6883
6894
|
};
|
|
6884
6895
|
};
|
|
6885
6896
|
|
|
6897
|
+
const sentLines = Object.create(null);
|
|
6898
|
+
|
|
6886
6899
|
// TODO only send changed lines to renderer process instead of all lines in viewport
|
|
6887
|
-
const getTokensViewport2 = (editor, startLineIndex, endLineIndex) => {
|
|
6888
|
-
if (getEnabled()) {
|
|
6900
|
+
const getTokensViewport2 = (editor, startLineIndex, endLineIndex, syncIncremental) => {
|
|
6901
|
+
if (getEnabled$1()) {
|
|
6902
|
+
if (syncIncremental) {
|
|
6903
|
+
const {
|
|
6904
|
+
invalidStartIndex,
|
|
6905
|
+
lines,
|
|
6906
|
+
languageId,
|
|
6907
|
+
id
|
|
6908
|
+
} = editor;
|
|
6909
|
+
let hasLinesToSend = true;
|
|
6910
|
+
let linesToSend = lines;
|
|
6911
|
+
if (sentLines[id] === lines) {
|
|
6912
|
+
hasLinesToSend = false;
|
|
6913
|
+
linesToSend = [];
|
|
6914
|
+
} else {
|
|
6915
|
+
sentLines[id] = lines;
|
|
6916
|
+
}
|
|
6917
|
+
const slimEditor = {
|
|
6918
|
+
languageId,
|
|
6919
|
+
invalidStartIndex
|
|
6920
|
+
};
|
|
6921
|
+
return invoke$1('GetTokensViewport.getTokensViewport', slimEditor, startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
|
|
6922
|
+
}
|
|
6889
6923
|
// TODO only send needed lines of text
|
|
6890
|
-
return invoke$1('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex);
|
|
6924
|
+
return invoke$1('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
|
|
6891
6925
|
}
|
|
6892
6926
|
return getTokensViewport(editor, startLineIndex, endLineIndex);
|
|
6893
6927
|
};
|
|
@@ -7099,7 +7133,7 @@ const getLineInfosViewport = (editor, tokens, embeddedResults, minLineY, maxLine
|
|
|
7099
7133
|
differences
|
|
7100
7134
|
};
|
|
7101
7135
|
};
|
|
7102
|
-
const getVisible = async editor => {
|
|
7136
|
+
const getVisible = async (editor, syncIncremental) => {
|
|
7103
7137
|
// console.log({ editor })
|
|
7104
7138
|
// TODO should separate rendering from business logic somehow
|
|
7105
7139
|
// currently hard to test because need to mock editor height, top, left,
|
|
@@ -7123,7 +7157,7 @@ const getVisible = async editor => {
|
|
|
7123
7157
|
tokens,
|
|
7124
7158
|
tokenizersToLoad,
|
|
7125
7159
|
embeddedResults
|
|
7126
|
-
} = await getTokensViewport2(editor, minLineY, maxLineY);
|
|
7160
|
+
} = await getTokensViewport2(editor, minLineY, maxLineY, syncIncremental);
|
|
7127
7161
|
const minLineOffset = offsetAtSync(editor, minLineY, 0);
|
|
7128
7162
|
const averageCharWidth = charWidth;
|
|
7129
7163
|
const {
|
|
@@ -7323,10 +7357,11 @@ const renderLines = {
|
|
|
7323
7357
|
if (incrementalEdits) {
|
|
7324
7358
|
return [/* method */'setIncrementalEdits', /* incrementalEdits */incrementalEdits];
|
|
7325
7359
|
}
|
|
7360
|
+
const syncIncremental = getEnabled();
|
|
7326
7361
|
const {
|
|
7327
7362
|
textInfos,
|
|
7328
7363
|
differences
|
|
7329
|
-
} = await getVisible(newState);
|
|
7364
|
+
} = await getVisible(newState, syncIncremental);
|
|
7330
7365
|
newState.differences = differences;
|
|
7331
7366
|
const dom = getEditorRowsVirtualDom(textInfos, differences);
|
|
7332
7367
|
return [/* method */'setText', dom];
|