@lvce-editor/editor-worker 17.0.0 → 18.0.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 +121 -9
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1177,6 +1177,8 @@ const OpenerWorker = 4561;
|
|
|
1177
1177
|
const RendererWorker$1 = 1;
|
|
1178
1178
|
const TextMeasurementWorker = 7011;
|
|
1179
1179
|
|
|
1180
|
+
const SetFocusContext$1 = 'Viewlet.setFocusContext';
|
|
1181
|
+
|
|
1180
1182
|
const FocusEditorText$1 = 12;
|
|
1181
1183
|
|
|
1182
1184
|
const rpcs = Object.create(null);
|
|
@@ -1333,6 +1335,10 @@ const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
|
1333
1335
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1334
1336
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
1335
1337
|
};
|
|
1338
|
+
const sendMessagePortToClipBoardWorker = async (port, rpcId) => {
|
|
1339
|
+
const command = 'ClipBoard.handleMessagePort';
|
|
1340
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToClipBoardWorker', port, command, rpcId);
|
|
1341
|
+
};
|
|
1336
1342
|
const sendMessagePortToOpenerWorker = async (port, rpcId) => {
|
|
1337
1343
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1338
1344
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
|
|
@@ -1639,6 +1645,7 @@ const RendererWorker = {
|
|
|
1639
1645
|
searchFileFetch,
|
|
1640
1646
|
searchFileHtml,
|
|
1641
1647
|
searchFileMemory,
|
|
1648
|
+
sendMessagePortToClipBoardWorker,
|
|
1642
1649
|
sendMessagePortToEditorWorker,
|
|
1643
1650
|
sendMessagePortToErrorWorker,
|
|
1644
1651
|
sendMessagePortToExtensionHostWorker,
|
|
@@ -1989,7 +1996,7 @@ const getInitialLineState = initialLineState => {
|
|
|
1989
1996
|
return deepCopy(initialLineState);
|
|
1990
1997
|
};
|
|
1991
1998
|
|
|
1992
|
-
const state$
|
|
1999
|
+
const state$8 = {
|
|
1993
2000
|
warned: []
|
|
1994
2001
|
};
|
|
1995
2002
|
const flattenTokensArray = tokens => {
|
|
@@ -2001,10 +2008,10 @@ const flattenTokensArray = tokens => {
|
|
|
2001
2008
|
return flattened;
|
|
2002
2009
|
};
|
|
2003
2010
|
const warnDeprecatedArrayReturn = (languageId, fn) => {
|
|
2004
|
-
if (state$
|
|
2011
|
+
if (state$8.warned.includes(fn)) {
|
|
2005
2012
|
return;
|
|
2006
2013
|
}
|
|
2007
|
-
state$
|
|
2014
|
+
state$8.warned.push(fn);
|
|
2008
2015
|
console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
|
|
2009
2016
|
};
|
|
2010
2017
|
const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
|
|
@@ -2078,21 +2085,21 @@ const {
|
|
|
2078
2085
|
set: set$5
|
|
2079
2086
|
} = SyntaxHighlightingWorker;
|
|
2080
2087
|
|
|
2081
|
-
const state$
|
|
2088
|
+
const state$7 = {
|
|
2082
2089
|
pending: Object.create(null),
|
|
2083
2090
|
tokenizers: Object.create(null)
|
|
2084
2091
|
};
|
|
2085
2092
|
const has = languageId => {
|
|
2086
|
-
return languageId in state$
|
|
2093
|
+
return languageId in state$7.tokenizers;
|
|
2087
2094
|
};
|
|
2088
2095
|
const set$4 = (languageId, tokenizer) => {
|
|
2089
|
-
state$
|
|
2096
|
+
state$7.tokenizers[languageId] = tokenizer;
|
|
2090
2097
|
};
|
|
2091
2098
|
const get$4 = languageId => {
|
|
2092
|
-
return state$
|
|
2099
|
+
return state$7.tokenizers[languageId];
|
|
2093
2100
|
};
|
|
2094
2101
|
const isPending = languageId => {
|
|
2095
|
-
return languageId in state$
|
|
2102
|
+
return languageId in state$7.pending;
|
|
2096
2103
|
};
|
|
2097
2104
|
|
|
2098
2105
|
const tokenMaps = Object.create(null);
|
|
@@ -3114,6 +3121,81 @@ const getUrlAtOffset = (editor, offset) => {
|
|
|
3114
3121
|
return undefined;
|
|
3115
3122
|
};
|
|
3116
3123
|
|
|
3124
|
+
const EditorChange = 1;
|
|
3125
|
+
|
|
3126
|
+
const state$6 = Object.create(null);
|
|
3127
|
+
|
|
3128
|
+
/**
|
|
3129
|
+
* Register a listener for a specific event type
|
|
3130
|
+
* @param listenerType - The type of event to listen for
|
|
3131
|
+
* @param rpcId - The RPC ID of the listener
|
|
3132
|
+
*/
|
|
3133
|
+
const registerListener$1 = (listenerType, rpcId) => {
|
|
3134
|
+
number(listenerType);
|
|
3135
|
+
number(rpcId);
|
|
3136
|
+
if (!state$6[listenerType]) {
|
|
3137
|
+
state$6[listenerType] = [];
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
// Avoid duplicate registrations
|
|
3141
|
+
if (!state$6[listenerType].includes(rpcId)) {
|
|
3142
|
+
state$6[listenerType].push(rpcId);
|
|
3143
|
+
}
|
|
3144
|
+
};
|
|
3145
|
+
|
|
3146
|
+
/**
|
|
3147
|
+
* Unregister a listener for a specific event type
|
|
3148
|
+
* @param listenerType - The type of event to listen for
|
|
3149
|
+
* @param rpcId - The RPC ID of the listener
|
|
3150
|
+
*/
|
|
3151
|
+
const unregisterListener$1 = (listenerType, rpcId) => {
|
|
3152
|
+
number(listenerType);
|
|
3153
|
+
number(rpcId);
|
|
3154
|
+
if (state$6[listenerType]) {
|
|
3155
|
+
const index = state$6[listenerType].indexOf(rpcId);
|
|
3156
|
+
if (index !== -1) {
|
|
3157
|
+
state$6[listenerType].splice(index, 1);
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
};
|
|
3161
|
+
|
|
3162
|
+
/**
|
|
3163
|
+
* Get all registered listeners for a specific event type
|
|
3164
|
+
* @param listenerType - The type of event
|
|
3165
|
+
* @returns Array of RPC IDs
|
|
3166
|
+
*/
|
|
3167
|
+
const getListeners = listenerType => {
|
|
3168
|
+
number(listenerType);
|
|
3169
|
+
return state$6[listenerType] || [];
|
|
3170
|
+
};
|
|
3171
|
+
|
|
3172
|
+
/**
|
|
3173
|
+
* Notify all registered listeners of a specific event type
|
|
3174
|
+
* @param listenerType - The type of event that occurred
|
|
3175
|
+
* @param method - The method name to invoke on the listener
|
|
3176
|
+
* @param params - Parameters to pass to the listener method
|
|
3177
|
+
*/
|
|
3178
|
+
const notifyListeners = async (listenerType, method, ...params) => {
|
|
3179
|
+
number(listenerType);
|
|
3180
|
+
string(method);
|
|
3181
|
+
const rpcIds = getListeners(listenerType);
|
|
3182
|
+
|
|
3183
|
+
// Notify all listeners in parallel
|
|
3184
|
+
const notifications = rpcIds.map(async rpcId => {
|
|
3185
|
+
try {
|
|
3186
|
+
const rpc = get$7(rpcId);
|
|
3187
|
+
if (rpc) {
|
|
3188
|
+
await rpc.invoke(method, ...params);
|
|
3189
|
+
}
|
|
3190
|
+
} catch (error) {
|
|
3191
|
+
// Silently ignore errors from individual listeners
|
|
3192
|
+
// to prevent one failing listener from affecting others
|
|
3193
|
+
console.warn(`Failed to notify listener ${rpcId}:`, error);
|
|
3194
|
+
}
|
|
3195
|
+
});
|
|
3196
|
+
await Promise.all(notifications);
|
|
3197
|
+
};
|
|
3198
|
+
|
|
3117
3199
|
const splitLines = lines => {
|
|
3118
3200
|
if (!lines) {
|
|
3119
3201
|
return [''];
|
|
@@ -3553,6 +3635,12 @@ const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionCh
|
|
|
3553
3635
|
if (!editor.modified) {
|
|
3554
3636
|
await notifyTabModifiedStatusChange(editor.uri);
|
|
3555
3637
|
}
|
|
3638
|
+
|
|
3639
|
+
// Notify registered listeners about editor changes
|
|
3640
|
+
notifyListeners(EditorChange, 'handleEditorChanged', editor.uid, editor.uri, changes).catch(error => {
|
|
3641
|
+
// Silently ignore notification errors to not interrupt the edit flow
|
|
3642
|
+
console.warn('Failed to notify editor change listeners:', error);
|
|
3643
|
+
});
|
|
3556
3644
|
const incrementalEdits = await getIncrementalEdits(editor, newEditorWithDecorations);
|
|
3557
3645
|
const editorWithNewWidgets = await applyWidgetChanges(newEditorWithDecorations, changes);
|
|
3558
3646
|
const newEditor2 = {
|
|
@@ -10828,6 +10916,17 @@ const moveLineUp = editor => {
|
|
|
10828
10916
|
return editor;
|
|
10829
10917
|
};
|
|
10830
10918
|
|
|
10919
|
+
/**
|
|
10920
|
+
* Register a listener for editor events
|
|
10921
|
+
* @param listenerType - The type of event to listen for (from ListenerType enum)
|
|
10922
|
+
* @param rpcId - The RPC ID of the listener that will be notified
|
|
10923
|
+
*/
|
|
10924
|
+
const registerListener = (listenerType, rpcId) => {
|
|
10925
|
+
number(listenerType);
|
|
10926
|
+
number(rpcId);
|
|
10927
|
+
registerListener$1(listenerType, rpcId);
|
|
10928
|
+
};
|
|
10929
|
+
|
|
10831
10930
|
const getCursorsVirtualDom = cursors => {
|
|
10832
10931
|
const dom = [];
|
|
10833
10932
|
for (const translate of cursors) {
|
|
@@ -11035,7 +11134,7 @@ const renderFocus$1 = {
|
|
|
11035
11134
|
};
|
|
11036
11135
|
const renderFocusContext = {
|
|
11037
11136
|
apply(oldState, newState) {
|
|
11038
|
-
return [
|
|
11137
|
+
return [SetFocusContext$1, newState.uid, newState.focus, 0, newState.uid, 'Editor'];
|
|
11039
11138
|
},
|
|
11040
11139
|
isEqual(oldState, newState) {
|
|
11041
11140
|
return oldState.focus === newState.focus;
|
|
@@ -11205,6 +11304,17 @@ const setDebugEnabled = (state, enabled) => {
|
|
|
11205
11304
|
return state;
|
|
11206
11305
|
};
|
|
11207
11306
|
|
|
11307
|
+
/**
|
|
11308
|
+
* Unregister a listener for editor events
|
|
11309
|
+
* @param listenerType - The type of event to stop listening for
|
|
11310
|
+
* @param rpcId - The RPC ID of the listener to unregister
|
|
11311
|
+
*/
|
|
11312
|
+
const unregisterListener = (listenerType, rpcId) => {
|
|
11313
|
+
number(listenerType);
|
|
11314
|
+
number(rpcId);
|
|
11315
|
+
unregisterListener$1(listenerType, rpcId);
|
|
11316
|
+
};
|
|
11317
|
+
|
|
11208
11318
|
const invoke = async (method, ...params) => {
|
|
11209
11319
|
const worker = get$7(DebugWorker);
|
|
11210
11320
|
return worker.invoke(method, ...params);
|
|
@@ -11498,6 +11608,8 @@ const commandMap = {
|
|
|
11498
11608
|
'Hover.loadContent': loadContent,
|
|
11499
11609
|
'Hover.render': renderHover,
|
|
11500
11610
|
'Initialize.initialize': intialize,
|
|
11611
|
+
'Listener.register': registerListener,
|
|
11612
|
+
'Listener.unregister': unregisterListener,
|
|
11501
11613
|
'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker': sendMessagePortToExtensionHostWorker2
|
|
11502
11614
|
};
|
|
11503
11615
|
|