@lvce-editor/editor-worker 17.1.0 → 18.1.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 +160 -15
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1123,7 +1123,7 @@ const LeftArrow = 13;
|
|
|
1123
1123
|
const UpArrow = 14;
|
|
1124
1124
|
const RightArrow = 15;
|
|
1125
1125
|
const DownArrow = 16;
|
|
1126
|
-
const Delete = 18;
|
|
1126
|
+
const Delete$1 = 18;
|
|
1127
1127
|
const KeyA = 29;
|
|
1128
1128
|
const KeyC = 31;
|
|
1129
1129
|
const KeyD = 32;
|
|
@@ -1335,6 +1335,10 @@ const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
|
1335
1335
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1336
1336
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
1337
1337
|
};
|
|
1338
|
+
const sendMessagePortToClipBoardWorker = async (port, rpcId) => {
|
|
1339
|
+
const command = 'ClipBoard.handleMessagePort';
|
|
1340
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToClipBoardWorker', port, command, rpcId);
|
|
1341
|
+
};
|
|
1338
1342
|
const sendMessagePortToOpenerWorker = async (port, rpcId) => {
|
|
1339
1343
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1340
1344
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
|
|
@@ -1641,6 +1645,7 @@ const RendererWorker = {
|
|
|
1641
1645
|
searchFileFetch,
|
|
1642
1646
|
searchFileHtml,
|
|
1643
1647
|
searchFileMemory,
|
|
1648
|
+
sendMessagePortToClipBoardWorker,
|
|
1644
1649
|
sendMessagePortToEditorWorker,
|
|
1645
1650
|
sendMessagePortToErrorWorker,
|
|
1646
1651
|
sendMessagePortToExtensionHostWorker,
|
|
@@ -1806,6 +1811,7 @@ const loadContent$2 = async (state, parentUid) => {
|
|
|
1806
1811
|
// TODO use numeric enum
|
|
1807
1812
|
const CompositionUpdate = 'compositionUpdate';
|
|
1808
1813
|
const ContentEditableInput = 'contentEditableInput';
|
|
1814
|
+
const Delete = 'delete';
|
|
1809
1815
|
const DeleteHorizontalRight = 'deleteHorizontalRight';
|
|
1810
1816
|
const DeleteLeft = 'deleteLeft';
|
|
1811
1817
|
const EditorCut = 'editorCut';
|
|
@@ -1991,7 +1997,7 @@ const getInitialLineState = initialLineState => {
|
|
|
1991
1997
|
return deepCopy(initialLineState);
|
|
1992
1998
|
};
|
|
1993
1999
|
|
|
1994
|
-
const state$
|
|
2000
|
+
const state$8 = {
|
|
1995
2001
|
warned: []
|
|
1996
2002
|
};
|
|
1997
2003
|
const flattenTokensArray = tokens => {
|
|
@@ -2003,10 +2009,10 @@ const flattenTokensArray = tokens => {
|
|
|
2003
2009
|
return flattened;
|
|
2004
2010
|
};
|
|
2005
2011
|
const warnDeprecatedArrayReturn = (languageId, fn) => {
|
|
2006
|
-
if (state$
|
|
2012
|
+
if (state$8.warned.includes(fn)) {
|
|
2007
2013
|
return;
|
|
2008
2014
|
}
|
|
2009
|
-
state$
|
|
2015
|
+
state$8.warned.push(fn);
|
|
2010
2016
|
console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
|
|
2011
2017
|
};
|
|
2012
2018
|
const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
|
|
@@ -2080,21 +2086,21 @@ const {
|
|
|
2080
2086
|
set: set$5
|
|
2081
2087
|
} = SyntaxHighlightingWorker;
|
|
2082
2088
|
|
|
2083
|
-
const state$
|
|
2089
|
+
const state$7 = {
|
|
2084
2090
|
pending: Object.create(null),
|
|
2085
2091
|
tokenizers: Object.create(null)
|
|
2086
2092
|
};
|
|
2087
2093
|
const has = languageId => {
|
|
2088
|
-
return languageId in state$
|
|
2094
|
+
return languageId in state$7.tokenizers;
|
|
2089
2095
|
};
|
|
2090
2096
|
const set$4 = (languageId, tokenizer) => {
|
|
2091
|
-
state$
|
|
2097
|
+
state$7.tokenizers[languageId] = tokenizer;
|
|
2092
2098
|
};
|
|
2093
2099
|
const get$4 = languageId => {
|
|
2094
|
-
return state$
|
|
2100
|
+
return state$7.tokenizers[languageId];
|
|
2095
2101
|
};
|
|
2096
2102
|
const isPending = languageId => {
|
|
2097
|
-
return languageId in state$
|
|
2103
|
+
return languageId in state$7.pending;
|
|
2098
2104
|
};
|
|
2099
2105
|
|
|
2100
2106
|
const tokenMaps = Object.create(null);
|
|
@@ -3116,6 +3122,81 @@ const getUrlAtOffset = (editor, offset) => {
|
|
|
3116
3122
|
return undefined;
|
|
3117
3123
|
};
|
|
3118
3124
|
|
|
3125
|
+
const EditorChange = 1;
|
|
3126
|
+
|
|
3127
|
+
const state$6 = Object.create(null);
|
|
3128
|
+
|
|
3129
|
+
/**
|
|
3130
|
+
* Register a listener for a specific event type
|
|
3131
|
+
* @param listenerType - The type of event to listen for
|
|
3132
|
+
* @param rpcId - The RPC ID of the listener
|
|
3133
|
+
*/
|
|
3134
|
+
const registerListener$1 = (listenerType, rpcId) => {
|
|
3135
|
+
number(listenerType);
|
|
3136
|
+
number(rpcId);
|
|
3137
|
+
if (!state$6[listenerType]) {
|
|
3138
|
+
state$6[listenerType] = [];
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
// Avoid duplicate registrations
|
|
3142
|
+
if (!state$6[listenerType].includes(rpcId)) {
|
|
3143
|
+
state$6[listenerType].push(rpcId);
|
|
3144
|
+
}
|
|
3145
|
+
};
|
|
3146
|
+
|
|
3147
|
+
/**
|
|
3148
|
+
* Unregister a listener for a specific event type
|
|
3149
|
+
* @param listenerType - The type of event to listen for
|
|
3150
|
+
* @param rpcId - The RPC ID of the listener
|
|
3151
|
+
*/
|
|
3152
|
+
const unregisterListener$1 = (listenerType, rpcId) => {
|
|
3153
|
+
number(listenerType);
|
|
3154
|
+
number(rpcId);
|
|
3155
|
+
if (state$6[listenerType]) {
|
|
3156
|
+
const index = state$6[listenerType].indexOf(rpcId);
|
|
3157
|
+
if (index !== -1) {
|
|
3158
|
+
state$6[listenerType].splice(index, 1);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
};
|
|
3162
|
+
|
|
3163
|
+
/**
|
|
3164
|
+
* Get all registered listeners for a specific event type
|
|
3165
|
+
* @param listenerType - The type of event
|
|
3166
|
+
* @returns Array of RPC IDs
|
|
3167
|
+
*/
|
|
3168
|
+
const getListeners = listenerType => {
|
|
3169
|
+
number(listenerType);
|
|
3170
|
+
return state$6[listenerType] || [];
|
|
3171
|
+
};
|
|
3172
|
+
|
|
3173
|
+
/**
|
|
3174
|
+
* Notify all registered listeners of a specific event type
|
|
3175
|
+
* @param listenerType - The type of event that occurred
|
|
3176
|
+
* @param method - The method name to invoke on the listener
|
|
3177
|
+
* @param params - Parameters to pass to the listener method
|
|
3178
|
+
*/
|
|
3179
|
+
const notifyListeners = async (listenerType, method, ...params) => {
|
|
3180
|
+
number(listenerType);
|
|
3181
|
+
string(method);
|
|
3182
|
+
const rpcIds = getListeners(listenerType);
|
|
3183
|
+
|
|
3184
|
+
// Notify all listeners in parallel
|
|
3185
|
+
const notifications = rpcIds.map(async rpcId => {
|
|
3186
|
+
try {
|
|
3187
|
+
const rpc = get$7(rpcId);
|
|
3188
|
+
if (rpc) {
|
|
3189
|
+
await rpc.invoke(method, ...params);
|
|
3190
|
+
}
|
|
3191
|
+
} catch (error) {
|
|
3192
|
+
// Silently ignore errors from individual listeners
|
|
3193
|
+
// to prevent one failing listener from affecting others
|
|
3194
|
+
console.warn(`Failed to notify listener ${rpcId}:`, error);
|
|
3195
|
+
}
|
|
3196
|
+
});
|
|
3197
|
+
await Promise.all(notifications);
|
|
3198
|
+
};
|
|
3199
|
+
|
|
3119
3200
|
const splitLines = lines => {
|
|
3120
3201
|
if (!lines) {
|
|
3121
3202
|
return [''];
|
|
@@ -3555,6 +3636,12 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
|
|
|
3555
3636
|
if (!editor.modified) {
|
|
3556
3637
|
await notifyTabModifiedStatusChange(editor.uri);
|
|
3557
3638
|
}
|
|
3639
|
+
|
|
3640
|
+
// Notify registered listeners about editor changes
|
|
3641
|
+
notifyListeners(EditorChange, 'handleEditorChanged', editor.uid, editor.uri, changes).catch(error => {
|
|
3642
|
+
// Silently ignore notification errors to not interrupt the edit flow
|
|
3643
|
+
console.warn('Failed to notify editor change listeners:', error);
|
|
3644
|
+
});
|
|
3558
3645
|
const incrementalEdits = await getIncrementalEdits(editor, newEditorWithDecorations);
|
|
3559
3646
|
const editorWithNewWidgets = await applyWidgetChanges(newEditorWithDecorations, changes);
|
|
3560
3647
|
const newEditor2 = {
|
|
@@ -3698,7 +3785,7 @@ const setBounds = (editor, x, y, width, height, columnWidth) => {
|
|
|
3698
3785
|
y
|
|
3699
3786
|
};
|
|
3700
3787
|
};
|
|
3701
|
-
const setText = (editor, text) => {
|
|
3788
|
+
const setText$1 = (editor, text) => {
|
|
3702
3789
|
const lines = splitLines(text);
|
|
3703
3790
|
const {
|
|
3704
3791
|
itemHeight,
|
|
@@ -4096,7 +4183,7 @@ const createEditor = async ({
|
|
|
4096
4183
|
|
|
4097
4184
|
// TODO avoid creating intermediate editors here
|
|
4098
4185
|
const newEditor1 = setBounds(editor, x, y, width, height, 9);
|
|
4099
|
-
const newEditor2 = setText(newEditor1, content);
|
|
4186
|
+
const newEditor2 = setText$1(newEditor1, content);
|
|
4100
4187
|
let newEditor3;
|
|
4101
4188
|
if (lineToReveal && columnToReveal) {
|
|
4102
4189
|
const delta = lineToReveal * rowHeight;
|
|
@@ -5319,6 +5406,33 @@ const cut$1 = async editor => {
|
|
|
5319
5406
|
return cutSelectedText(editor);
|
|
5320
5407
|
};
|
|
5321
5408
|
|
|
5409
|
+
const deleteAll = editor => {
|
|
5410
|
+
const {
|
|
5411
|
+
lines
|
|
5412
|
+
} = editor;
|
|
5413
|
+
const endRowIndex = lines.length - 1;
|
|
5414
|
+
const endColumnIndex = lines.at(-1).length;
|
|
5415
|
+
const start = {
|
|
5416
|
+
columnIndex: 0,
|
|
5417
|
+
rowIndex: 0
|
|
5418
|
+
};
|
|
5419
|
+
const end = {
|
|
5420
|
+
columnIndex: endColumnIndex,
|
|
5421
|
+
rowIndex: endRowIndex
|
|
5422
|
+
};
|
|
5423
|
+
const changes = [{
|
|
5424
|
+
deleted: getSelectionText(editor, {
|
|
5425
|
+
end,
|
|
5426
|
+
start
|
|
5427
|
+
}),
|
|
5428
|
+
end,
|
|
5429
|
+
inserted: [''],
|
|
5430
|
+
origin: Delete,
|
|
5431
|
+
start
|
|
5432
|
+
}];
|
|
5433
|
+
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
5434
|
+
};
|
|
5435
|
+
|
|
5322
5436
|
// TODO optimize this function by profiling and not allocating too many objects
|
|
5323
5437
|
// @ts-ignore
|
|
5324
5438
|
const getChanges$5 = (lines, selections, getDelta) => {
|
|
@@ -8043,6 +8157,11 @@ const setSelections = (editor, selections) => {
|
|
|
8043
8157
|
};
|
|
8044
8158
|
};
|
|
8045
8159
|
|
|
8160
|
+
const setText = (editor, text) => {
|
|
8161
|
+
string(text);
|
|
8162
|
+
return setText$1(editor, text);
|
|
8163
|
+
};
|
|
8164
|
+
|
|
8046
8165
|
const create$1 = () => {
|
|
8047
8166
|
const uid = create$7();
|
|
8048
8167
|
const widget = {
|
|
@@ -10120,7 +10239,7 @@ const getKeyBindings = () => {
|
|
|
10120
10239
|
when: FocusEditorText
|
|
10121
10240
|
}, {
|
|
10122
10241
|
command: 'Editor.deleteWordPartRight',
|
|
10123
|
-
key: Alt$1 | Delete,
|
|
10242
|
+
key: Alt$1 | Delete$1,
|
|
10124
10243
|
when: FocusEditorText
|
|
10125
10244
|
}, {
|
|
10126
10245
|
command: 'Editor.deleteWordLeft',
|
|
@@ -10128,7 +10247,7 @@ const getKeyBindings = () => {
|
|
|
10128
10247
|
when: FocusEditorText
|
|
10129
10248
|
}, {
|
|
10130
10249
|
command: 'Editor.deleteWordRight',
|
|
10131
|
-
key: CtrlCmd | Delete,
|
|
10250
|
+
key: CtrlCmd | Delete$1,
|
|
10132
10251
|
when: FocusEditorText
|
|
10133
10252
|
}, {
|
|
10134
10253
|
command: 'Editor.selectNextOccurrence',
|
|
@@ -10204,7 +10323,7 @@ const getKeyBindings = () => {
|
|
|
10204
10323
|
when: FocusEditorText
|
|
10205
10324
|
}, {
|
|
10206
10325
|
command: 'Editor.deleteAllRight',
|
|
10207
|
-
key: CtrlCmd | Shift | Delete,
|
|
10326
|
+
key: CtrlCmd | Shift | Delete$1,
|
|
10208
10327
|
when: FocusEditorText
|
|
10209
10328
|
}, {
|
|
10210
10329
|
command: 'Editor.cancelSelection',
|
|
@@ -10236,7 +10355,7 @@ const getKeyBindings = () => {
|
|
|
10236
10355
|
when: FocusEditorText
|
|
10237
10356
|
}, {
|
|
10238
10357
|
command: 'Editor.deleteRight',
|
|
10239
|
-
key: Delete,
|
|
10358
|
+
key: Delete$1,
|
|
10240
10359
|
when: FocusEditorText
|
|
10241
10360
|
}, {
|
|
10242
10361
|
command: 'Editor.insertLineBreak',
|
|
@@ -10830,6 +10949,17 @@ const moveLineUp = editor => {
|
|
|
10830
10949
|
return editor;
|
|
10831
10950
|
};
|
|
10832
10951
|
|
|
10952
|
+
/**
|
|
10953
|
+
* Register a listener for editor events
|
|
10954
|
+
* @param listenerType - The type of event to listen for (from ListenerType enum)
|
|
10955
|
+
* @param rpcId - The RPC ID of the listener that will be notified
|
|
10956
|
+
*/
|
|
10957
|
+
const registerListener = (listenerType, rpcId) => {
|
|
10958
|
+
number(listenerType);
|
|
10959
|
+
number(rpcId);
|
|
10960
|
+
registerListener$1(listenerType, rpcId);
|
|
10961
|
+
};
|
|
10962
|
+
|
|
10833
10963
|
const getCursorsVirtualDom = cursors => {
|
|
10834
10964
|
const dom = [];
|
|
10835
10965
|
for (const translate of cursors) {
|
|
@@ -11207,6 +11337,17 @@ const setDebugEnabled = (state, enabled) => {
|
|
|
11207
11337
|
return state;
|
|
11208
11338
|
};
|
|
11209
11339
|
|
|
11340
|
+
/**
|
|
11341
|
+
* Unregister a listener for editor events
|
|
11342
|
+
* @param listenerType - The type of event to stop listening for
|
|
11343
|
+
* @param rpcId - The RPC ID of the listener to unregister
|
|
11344
|
+
*/
|
|
11345
|
+
const unregisterListener = (listenerType, rpcId) => {
|
|
11346
|
+
number(listenerType);
|
|
11347
|
+
number(rpcId);
|
|
11348
|
+
unregisterListener$1(listenerType, rpcId);
|
|
11349
|
+
};
|
|
11350
|
+
|
|
11210
11351
|
const invoke = async (method, ...params) => {
|
|
11211
11352
|
const worker = get$7(DebugWorker);
|
|
11212
11353
|
return worker.invoke(method, ...params);
|
|
@@ -11303,6 +11444,7 @@ const commandMap = {
|
|
|
11303
11444
|
'Editor.cursorWordPartRight': wrapCommand(cursorWordPartRight),
|
|
11304
11445
|
'Editor.cursorWordRight': wrapCommand(cursorWordRight),
|
|
11305
11446
|
'Editor.cut': wrapCommand(cut$1),
|
|
11447
|
+
'Editor.deleteAll': wrapCommand(deleteAll),
|
|
11306
11448
|
'Editor.deleteAllLeft': wrapCommand(deleteAllLeft),
|
|
11307
11449
|
'Editor.deleteAllRight': wrapCommand(deleteAllRight),
|
|
11308
11450
|
'Editor.deleteCharacterLeft': wrapCommand(deleteCharacterLeft),
|
|
@@ -11415,6 +11557,7 @@ const commandMap = {
|
|
|
11415
11557
|
'Editor.setLanguageId': wrapCommand(setLanguageId),
|
|
11416
11558
|
'Editor.setSelections': wrapCommand(setSelections),
|
|
11417
11559
|
'Editor.setSelections2': setSelections2,
|
|
11560
|
+
'Editor.setText': wrapCommand(setText),
|
|
11418
11561
|
'Editor.showHover': showHover,
|
|
11419
11562
|
'Editor.showHover2': showHover3,
|
|
11420
11563
|
'Editor.showSourceActions': showSourceActions,
|
|
@@ -11500,6 +11643,8 @@ const commandMap = {
|
|
|
11500
11643
|
'Hover.loadContent': loadContent,
|
|
11501
11644
|
'Hover.render': renderHover,
|
|
11502
11645
|
'Initialize.initialize': intialize,
|
|
11646
|
+
'Listener.register': registerListener,
|
|
11647
|
+
'Listener.unregister': unregisterListener,
|
|
11503
11648
|
'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker': sendMessagePortToExtensionHostWorker2
|
|
11504
11649
|
};
|
|
11505
11650
|
|