@lvce-editor/editor-worker 18.19.0 → 18.20.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.
@@ -9348,9 +9348,25 @@ const EditorFindWidget = {
9348
9348
  toggleUseRegularExpression
9349
9349
  };
9350
9350
 
9351
+ const getTextDocument = editor => {
9352
+ return {
9353
+ documentId: editor.id || editor.uid,
9354
+ languageId: editor.languageId,
9355
+ text: getText$1(editor),
9356
+ uri: editor.uri
9357
+ };
9358
+ };
9359
+ const executeIsolatedHoverProvider = async (editor, offset) => {
9360
+ const textDocument = getTextDocument(editor);
9361
+ return invoke$e('Extensions.executeHoverProvider', textDocument, offset);
9362
+ };
9351
9363
  const executeHoverProvider = async (editor, offset) => {
9352
9364
  object(editor);
9353
9365
  number(offset);
9366
+ const isolatedHover = await executeIsolatedHoverProvider(editor, offset);
9367
+ if (isolatedHover) {
9368
+ return isolatedHover;
9369
+ }
9354
9370
  return execute({
9355
9371
  args: [offset],
9356
9372
  editor,
@@ -11250,11 +11266,78 @@ const treeToArray = node => {
11250
11266
  return result;
11251
11267
  };
11252
11268
 
11269
+ const navigateToChild = (patches, currentChildIndex, index) => {
11270
+ if (currentChildIndex === -1) {
11271
+ patches.push({
11272
+ type: NavigateChild,
11273
+ index
11274
+ });
11275
+ return index;
11276
+ }
11277
+ if (currentChildIndex !== index) {
11278
+ patches.push({
11279
+ type: NavigateSibling,
11280
+ index
11281
+ });
11282
+ }
11283
+ return index;
11284
+ };
11285
+ const navigateToParent = (patches, currentChildIndex) => {
11286
+ if (currentChildIndex >= 0) {
11287
+ patches.push({
11288
+ type: NavigateParent
11289
+ });
11290
+ }
11291
+ return -1;
11292
+ };
11293
+ const addTree = (newNode, patches) => {
11294
+ patches.push({
11295
+ type: Add,
11296
+ nodes: treeToArray(newNode)
11297
+ });
11298
+ };
11299
+ const replaceTree = (newNode, patches) => {
11300
+ patches.push({
11301
+ type: Replace,
11302
+ nodes: treeToArray(newNode)
11303
+ });
11304
+ };
11305
+ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
11306
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
11307
+ if (nodePatches === null) {
11308
+ const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
11309
+ replaceTree(newNode, patches);
11310
+ return nextChildIndex;
11311
+ }
11312
+ const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
11313
+ if (nodePatches.length === 0 && !hasChildrenToCompare) {
11314
+ return currentChildIndex;
11315
+ }
11316
+ const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
11317
+ if (nodePatches.length > 0) {
11318
+ patches.push(...nodePatches);
11319
+ }
11320
+ if (hasChildrenToCompare) {
11321
+ diffChildren(oldNode.children, newNode.children, patches);
11322
+ }
11323
+ return nextChildIndex;
11324
+ };
11325
+ const diffRootNode = (oldNode, newNode, patches) => {
11326
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
11327
+ if (nodePatches === null) {
11328
+ replaceTree(newNode, patches);
11329
+ return;
11330
+ }
11331
+ if (nodePatches.length > 0) {
11332
+ patches.push(...nodePatches);
11333
+ }
11334
+ if (oldNode.children.length > 0 || newNode.children.length > 0) {
11335
+ diffChildren(oldNode.children, newNode.children, patches);
11336
+ }
11337
+ };
11253
11338
  const diffChildren = (oldChildren, newChildren, patches) => {
11254
11339
  const maxLength = Math.max(oldChildren.length, newChildren.length);
11255
- // Track where we are: -1 means at parent, >= 0 means at child index
11256
11340
  let currentChildIndex = -1;
11257
- // Collect indices of children to remove (we'll add these patches at the end in reverse order)
11258
11341
  const indicesToRemove = [];
11259
11342
  for (let i = 0; i < maxLength; i++) {
11260
11343
  const oldNode = oldChildren[i];
@@ -11263,88 +11346,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
11263
11346
  continue;
11264
11347
  }
11265
11348
  if (!oldNode) {
11266
- // Add new node - we should be at the parent
11267
- if (currentChildIndex >= 0) {
11268
- // Navigate back to parent
11269
- patches.push({
11270
- type: NavigateParent
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
11349
+ currentChildIndex = navigateToParent(patches, currentChildIndex);
11350
+ addTree(newNode, patches);
11351
+ continue;
11352
+ }
11353
+ if (!newNode) {
11337
11354
  indicesToRemove.push(i);
11355
+ continue;
11338
11356
  }
11357
+ currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
11339
11358
  }
11340
- // Navigate back to parent if we ended at a child
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
11359
+ navigateToParent(patches, currentChildIndex);
11348
11360
  for (let j = indicesToRemove.length - 1; j >= 0; j--) {
11349
11361
  patches.push({
11350
11362
  type: RemoveChild,
@@ -11353,33 +11365,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
11353
11365
  }
11354
11366
  };
11355
11367
  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
11368
  if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
11359
- const oldNode = oldTree[0];
11360
- const newNode = newTree[0];
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);
11369
+ diffRootNode(oldTree[0], newTree[0], patches);
11370
+ return;
11382
11371
  }
11372
+ diffChildren(oldTree, newTree, patches);
11383
11373
  };
11384
11374
 
11385
11375
  const removeTrailingNavigationPatches = patches => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "18.19.0",
3
+ "version": "18.20.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"