@lvce-editor/editor-worker 18.19.0 → 18.21.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 +122 -111
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1296,7 +1296,7 @@ const sendMessagePortToTextMeasurementWorker = async port => {
|
|
|
1296
1296
|
const command = 'TextMeasurement.handleMessagePort';
|
|
1297
1297
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1298
1298
|
};
|
|
1299
|
-
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
1299
|
+
const sendMessagePortToExtensionManagementWorker$1 = async (port, rpcId) => {
|
|
1300
1300
|
const command = 'Extensions.handleMessagePort';
|
|
1301
1301
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1302
1302
|
};
|
|
@@ -1321,7 +1321,7 @@ const RendererWorker = {
|
|
|
1321
1321
|
readClipBoardText,
|
|
1322
1322
|
readFile,
|
|
1323
1323
|
sendMessagePortToExtensionHostWorker,
|
|
1324
|
-
sendMessagePortToExtensionManagementWorker,
|
|
1324
|
+
sendMessagePortToExtensionManagementWorker: sendMessagePortToExtensionManagementWorker$1,
|
|
1325
1325
|
sendMessagePortToOpenerWorker,
|
|
1326
1326
|
sendMessagePortToSyntaxHighlightingWorker: sendMessagePortToSyntaxHighlightingWorker$1,
|
|
1327
1327
|
sendMessagePortToTextMeasurementWorker,
|
|
@@ -3794,7 +3794,23 @@ const execute = async ({
|
|
|
3794
3794
|
return result;
|
|
3795
3795
|
};
|
|
3796
3796
|
|
|
3797
|
-
const
|
|
3797
|
+
const getTextDocument$1 = editor => {
|
|
3798
|
+
return {
|
|
3799
|
+
documentId: editor.id || editor.uid,
|
|
3800
|
+
languageId: editor.languageId,
|
|
3801
|
+
text: getText$1(editor),
|
|
3802
|
+
uri: editor.uri
|
|
3803
|
+
};
|
|
3804
|
+
};
|
|
3805
|
+
const executeIsolatedDiagnosticProvider = async editor => {
|
|
3806
|
+
const textDocument = getTextDocument$1(editor);
|
|
3807
|
+
return invoke$e('Extensions.executeDiagnosticProvider', textDocument);
|
|
3808
|
+
};
|
|
3809
|
+
const executeDiagnosticProvider = async editor => {
|
|
3810
|
+
const isolatedDiagnostics = await executeIsolatedDiagnosticProvider(editor);
|
|
3811
|
+
if (isolatedDiagnostics.length > 0) {
|
|
3812
|
+
return isolatedDiagnostics;
|
|
3813
|
+
}
|
|
3798
3814
|
const {
|
|
3799
3815
|
assetDir,
|
|
3800
3816
|
platform
|
|
@@ -9348,9 +9364,25 @@ const EditorFindWidget = {
|
|
|
9348
9364
|
toggleUseRegularExpression
|
|
9349
9365
|
};
|
|
9350
9366
|
|
|
9367
|
+
const getTextDocument = editor => {
|
|
9368
|
+
return {
|
|
9369
|
+
documentId: editor.id || editor.uid,
|
|
9370
|
+
languageId: editor.languageId,
|
|
9371
|
+
text: getText$1(editor),
|
|
9372
|
+
uri: editor.uri
|
|
9373
|
+
};
|
|
9374
|
+
};
|
|
9375
|
+
const executeIsolatedHoverProvider = async (editor, offset) => {
|
|
9376
|
+
const textDocument = getTextDocument(editor);
|
|
9377
|
+
return invoke$e('Extensions.executeHoverProvider', textDocument, offset);
|
|
9378
|
+
};
|
|
9351
9379
|
const executeHoverProvider = async (editor, offset) => {
|
|
9352
9380
|
object(editor);
|
|
9353
9381
|
number(offset);
|
|
9382
|
+
const isolatedHover = await executeIsolatedHoverProvider(editor, offset);
|
|
9383
|
+
if (isolatedHover) {
|
|
9384
|
+
return isolatedHover;
|
|
9385
|
+
}
|
|
9354
9386
|
return execute({
|
|
9355
9387
|
args: [offset],
|
|
9356
9388
|
editor,
|
|
@@ -10757,7 +10789,7 @@ const createExtensionManagementWorkerRpc = async () => {
|
|
|
10757
10789
|
const rpc = await create$e({
|
|
10758
10790
|
commandMap: {},
|
|
10759
10791
|
async send(port) {
|
|
10760
|
-
await sendMessagePortToExtensionManagementWorker(port, EditorWorker);
|
|
10792
|
+
await sendMessagePortToExtensionManagementWorker$1(port, EditorWorker);
|
|
10761
10793
|
}
|
|
10762
10794
|
});
|
|
10763
10795
|
return rpc;
|
|
@@ -11250,11 +11282,78 @@ const treeToArray = node => {
|
|
|
11250
11282
|
return result;
|
|
11251
11283
|
};
|
|
11252
11284
|
|
|
11285
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
11286
|
+
if (currentChildIndex === -1) {
|
|
11287
|
+
patches.push({
|
|
11288
|
+
type: NavigateChild,
|
|
11289
|
+
index
|
|
11290
|
+
});
|
|
11291
|
+
return index;
|
|
11292
|
+
}
|
|
11293
|
+
if (currentChildIndex !== index) {
|
|
11294
|
+
patches.push({
|
|
11295
|
+
type: NavigateSibling,
|
|
11296
|
+
index
|
|
11297
|
+
});
|
|
11298
|
+
}
|
|
11299
|
+
return index;
|
|
11300
|
+
};
|
|
11301
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
11302
|
+
if (currentChildIndex >= 0) {
|
|
11303
|
+
patches.push({
|
|
11304
|
+
type: NavigateParent
|
|
11305
|
+
});
|
|
11306
|
+
}
|
|
11307
|
+
return -1;
|
|
11308
|
+
};
|
|
11309
|
+
const addTree = (newNode, patches) => {
|
|
11310
|
+
patches.push({
|
|
11311
|
+
type: Add,
|
|
11312
|
+
nodes: treeToArray(newNode)
|
|
11313
|
+
});
|
|
11314
|
+
};
|
|
11315
|
+
const replaceTree = (newNode, patches) => {
|
|
11316
|
+
patches.push({
|
|
11317
|
+
type: Replace,
|
|
11318
|
+
nodes: treeToArray(newNode)
|
|
11319
|
+
});
|
|
11320
|
+
};
|
|
11321
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
11322
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
11323
|
+
if (nodePatches === null) {
|
|
11324
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
11325
|
+
replaceTree(newNode, patches);
|
|
11326
|
+
return nextChildIndex;
|
|
11327
|
+
}
|
|
11328
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
11329
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
11330
|
+
return currentChildIndex;
|
|
11331
|
+
}
|
|
11332
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
11333
|
+
if (nodePatches.length > 0) {
|
|
11334
|
+
patches.push(...nodePatches);
|
|
11335
|
+
}
|
|
11336
|
+
if (hasChildrenToCompare) {
|
|
11337
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
11338
|
+
}
|
|
11339
|
+
return nextChildIndex;
|
|
11340
|
+
};
|
|
11341
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
11342
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
11343
|
+
if (nodePatches === null) {
|
|
11344
|
+
replaceTree(newNode, patches);
|
|
11345
|
+
return;
|
|
11346
|
+
}
|
|
11347
|
+
if (nodePatches.length > 0) {
|
|
11348
|
+
patches.push(...nodePatches);
|
|
11349
|
+
}
|
|
11350
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
11351
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
11352
|
+
}
|
|
11353
|
+
};
|
|
11253
11354
|
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
11254
11355
|
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
11255
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
11256
11356
|
let currentChildIndex = -1;
|
|
11257
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
11258
11357
|
const indicesToRemove = [];
|
|
11259
11358
|
for (let i = 0; i < maxLength; i++) {
|
|
11260
11359
|
const oldNode = oldChildren[i];
|
|
@@ -11263,88 +11362,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
11263
11362
|
continue;
|
|
11264
11363
|
}
|
|
11265
11364
|
if (!oldNode) {
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
});
|
|
11272
|
-
currentChildIndex = -1;
|
|
11273
|
-
}
|
|
11274
|
-
// Flatten the entire subtree so renderInternal can handle it
|
|
11275
|
-
const flatNodes = treeToArray(newNode);
|
|
11276
|
-
patches.push({
|
|
11277
|
-
type: Add,
|
|
11278
|
-
nodes: flatNodes
|
|
11279
|
-
});
|
|
11280
|
-
} else if (newNode) {
|
|
11281
|
-
// Compare nodes to see if we need any patches
|
|
11282
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
11283
|
-
// If nodePatches is null, the node types are incompatible - need to replace
|
|
11284
|
-
if (nodePatches === null) {
|
|
11285
|
-
// Navigate to this child
|
|
11286
|
-
if (currentChildIndex === -1) {
|
|
11287
|
-
patches.push({
|
|
11288
|
-
type: NavigateChild,
|
|
11289
|
-
index: i
|
|
11290
|
-
});
|
|
11291
|
-
currentChildIndex = i;
|
|
11292
|
-
} else if (currentChildIndex !== i) {
|
|
11293
|
-
patches.push({
|
|
11294
|
-
type: NavigateSibling,
|
|
11295
|
-
index: i
|
|
11296
|
-
});
|
|
11297
|
-
currentChildIndex = i;
|
|
11298
|
-
}
|
|
11299
|
-
// Replace the entire subtree
|
|
11300
|
-
const flatNodes = treeToArray(newNode);
|
|
11301
|
-
patches.push({
|
|
11302
|
-
type: Replace,
|
|
11303
|
-
nodes: flatNodes
|
|
11304
|
-
});
|
|
11305
|
-
// After replace, we're at the new element (same position)
|
|
11306
|
-
continue;
|
|
11307
|
-
}
|
|
11308
|
-
// Check if we need to recurse into children
|
|
11309
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
11310
|
-
// Only navigate to this element if we need to do something
|
|
11311
|
-
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
11312
|
-
// Navigate to this child if not already there
|
|
11313
|
-
if (currentChildIndex === -1) {
|
|
11314
|
-
patches.push({
|
|
11315
|
-
type: NavigateChild,
|
|
11316
|
-
index: i
|
|
11317
|
-
});
|
|
11318
|
-
currentChildIndex = i;
|
|
11319
|
-
} else if (currentChildIndex !== i) {
|
|
11320
|
-
patches.push({
|
|
11321
|
-
type: NavigateSibling,
|
|
11322
|
-
index: i
|
|
11323
|
-
});
|
|
11324
|
-
currentChildIndex = i;
|
|
11325
|
-
}
|
|
11326
|
-
// Apply node patches (these apply to the current element, not children)
|
|
11327
|
-
if (nodePatches.length > 0) {
|
|
11328
|
-
patches.push(...nodePatches);
|
|
11329
|
-
}
|
|
11330
|
-
// Compare children recursively
|
|
11331
|
-
if (hasChildrenToCompare) {
|
|
11332
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
11333
|
-
}
|
|
11334
|
-
}
|
|
11335
|
-
} else {
|
|
11336
|
-
// Remove old node - collect the index for later removal
|
|
11365
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
11366
|
+
addTree(newNode, patches);
|
|
11367
|
+
continue;
|
|
11368
|
+
}
|
|
11369
|
+
if (!newNode) {
|
|
11337
11370
|
indicesToRemove.push(i);
|
|
11371
|
+
continue;
|
|
11338
11372
|
}
|
|
11373
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
11339
11374
|
}
|
|
11340
|
-
|
|
11341
|
-
if (currentChildIndex >= 0) {
|
|
11342
|
-
patches.push({
|
|
11343
|
-
type: NavigateParent
|
|
11344
|
-
});
|
|
11345
|
-
}
|
|
11346
|
-
// Add remove patches in reverse order (highest index first)
|
|
11347
|
-
// This ensures indices remain valid as we remove
|
|
11375
|
+
navigateToParent(patches, currentChildIndex);
|
|
11348
11376
|
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
11349
11377
|
patches.push({
|
|
11350
11378
|
type: RemoveChild,
|
|
@@ -11353,33 +11381,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
11353
11381
|
}
|
|
11354
11382
|
};
|
|
11355
11383
|
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
11356
|
-
// At the root level (path.length === 0), we're already AT the element
|
|
11357
|
-
// So we compare the root node directly, then compare its children
|
|
11358
11384
|
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
11359
|
-
|
|
11360
|
-
|
|
11361
|
-
// Compare root nodes
|
|
11362
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
11363
|
-
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
11364
|
-
if (nodePatches === null) {
|
|
11365
|
-
const flatNodes = treeToArray(newNode);
|
|
11366
|
-
patches.push({
|
|
11367
|
-
type: Replace,
|
|
11368
|
-
nodes: flatNodes
|
|
11369
|
-
});
|
|
11370
|
-
return;
|
|
11371
|
-
}
|
|
11372
|
-
if (nodePatches.length > 0) {
|
|
11373
|
-
patches.push(...nodePatches);
|
|
11374
|
-
}
|
|
11375
|
-
// Compare children
|
|
11376
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
11377
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
11378
|
-
}
|
|
11379
|
-
} else {
|
|
11380
|
-
// Non-root level or multiple root elements - use the regular comparison
|
|
11381
|
-
diffChildren(oldTree, newTree, patches);
|
|
11385
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
11386
|
+
return;
|
|
11382
11387
|
}
|
|
11388
|
+
diffChildren(oldTree, newTree, patches);
|
|
11383
11389
|
};
|
|
11384
11390
|
|
|
11385
11391
|
const removeTrailingNavigationPatches = patches => {
|
|
@@ -12058,6 +12064,10 @@ const saveState = (state, savedState) => {
|
|
|
12058
12064
|
};
|
|
12059
12065
|
};
|
|
12060
12066
|
|
|
12067
|
+
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
12068
|
+
await sendMessagePortToExtensionManagementWorker$1(port, rpcId);
|
|
12069
|
+
};
|
|
12070
|
+
|
|
12061
12071
|
const setDebugEnabled = (state, enabled) => {
|
|
12062
12072
|
return state;
|
|
12063
12073
|
};
|
|
@@ -12381,7 +12391,8 @@ const commandMap = {
|
|
|
12381
12391
|
'Listener.register': registerListener,
|
|
12382
12392
|
'Listener.registerListener': registerListener$1,
|
|
12383
12393
|
'Listener.unregister': unregisterListener,
|
|
12384
|
-
'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker': sendMessagePortToExtensionHostWorker2
|
|
12394
|
+
'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker': sendMessagePortToExtensionHostWorker2,
|
|
12395
|
+
'SendMessagePortToExtensionManagementWorker.sendMessagePortToExtensionManagementWorker': sendMessagePortToExtensionManagementWorker
|
|
12385
12396
|
};
|
|
12386
12397
|
for (const [key, value] of Object.entries(commandMap)) {
|
|
12387
12398
|
if (key.startsWith('Editor.')) {
|