@lvce-editor/editor-worker 19.26.0 → 19.26.1

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.
@@ -12379,14 +12379,11 @@ const compareNodes = (oldNode, newNode) => {
12379
12379
  }
12380
12380
  const patches = [];
12381
12381
  // Handle reference nodes - special handling for uid changes
12382
- if (oldNode.type === Reference) {
12383
- if (oldNode.uid !== newNode.uid) {
12384
- patches.push({
12385
- type: SetReferenceNodeUid,
12386
- uid: newNode.uid
12387
- });
12388
- }
12389
- return patches;
12382
+ if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
12383
+ patches.push({
12384
+ type: SetReferenceNodeUid,
12385
+ uid: newNode.uid
12386
+ });
12390
12387
  }
12391
12388
  // Handle text nodes
12392
12389
  if (oldNode.type === Text$1 && newNode.type === Text$1) {
@@ -12399,8 +12396,8 @@ const compareNodes = (oldNode, newNode) => {
12399
12396
  return patches;
12400
12397
  }
12401
12398
  // Compare attributes
12402
- const oldKeys = getKeys(oldNode);
12403
- const newKeys = getKeys(newNode);
12399
+ const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
12400
+ const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
12404
12401
  // Check for attribute changes
12405
12402
  for (const key of newKeys) {
12406
12403
  if (oldNode[key] !== newNode[key]) {
@@ -12424,9 +12421,14 @@ const compareNodes = (oldNode, newNode) => {
12424
12421
  };
12425
12422
 
12426
12423
  const treeToArray = node => {
12427
- const result = [node.node];
12428
- for (const child of node.children) {
12429
- result.push(...treeToArray(child));
12424
+ const result = [];
12425
+ const stack = [node];
12426
+ while (stack.length > 0) {
12427
+ const current = stack.pop();
12428
+ result.push(current.node);
12429
+ for (let i = current.children.length - 1; i >= 0; i--) {
12430
+ stack.push(current.children[i]);
12431
+ }
12430
12432
  }
12431
12433
  return result;
12432
12434
  };
@@ -12538,17 +12540,14 @@ const diffTrees = (oldTree, newTree, patches, path) => {
12538
12540
  };
12539
12541
 
12540
12542
  const removeTrailingNavigationPatches = patches => {
12541
- // Find the last non-navigation patch
12542
- let lastNonNavigationIndex = -1;
12543
- for (let i = patches.length - 1; i >= 0; i--) {
12544
- const patch = patches[i];
12543
+ while (patches.length > 0) {
12544
+ const patch = patches.at(-1);
12545
12545
  if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
12546
- lastNonNavigationIndex = i;
12547
12546
  break;
12548
12547
  }
12548
+ patches.pop();
12549
12549
  }
12550
- // Return patches up to and including the last non-navigation patch
12551
- return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
12550
+ return patches;
12552
12551
  };
12553
12552
 
12554
12553
  const diffTree = (oldNodes, newNodes) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.26.0",
3
+ "version": "19.26.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"