@lvce-editor/editor-worker 19.55.3 → 19.55.4

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.
@@ -1198,175 +1198,9 @@ const create$a = rpcId => {
1198
1198
  };
1199
1199
  };
1200
1200
 
1201
- const Audio = 0;
1202
- const Button$3 = 1;
1203
- const Col = 2;
1204
- const ColGroup = 3;
1205
- const Div$1 = 4;
1206
- const H1 = 5;
1207
- const Input$1 = 6;
1208
- const Kbd = 7;
1209
- const Span$1 = 8;
1210
- const Table = 9;
1211
- const TBody = 10;
1212
- const Td = 11;
1213
- const Text$1 = 12;
1214
- const Th = 13;
1215
- const THead = 14;
1216
- const Tr = 15;
1217
- const I = 16;
1218
- const Img = 17;
1219
- const Root = 0;
1220
- const Ins = 20;
1221
- const Del = 21;
1222
- const H2 = 22;
1223
- const H3 = 23;
1224
- const H4 = 24;
1225
- const H5 = 25;
1226
- const H6 = 26;
1227
- const Article = 27;
1228
- const Aside = 28;
1229
- const Footer = 29;
1230
- const Header = 30;
1231
- const Nav$1 = 40;
1232
- const Section = 41;
1233
- const Search = 42;
1234
- const Dd = 43;
1235
- const Dl = 44;
1236
- const Figcaption = 45;
1237
- const Figure = 46;
1238
- const Hr = 47;
1239
- const Li = 48;
1240
- const Ol = 49;
1241
- const P = 50;
1242
- const Pre = 51;
1243
- const A = 53;
1244
- const Abbr = 54;
1245
- const Br = 55;
1246
- const Cite = 56;
1247
- const Data = 57;
1248
- const Time = 58;
1249
- const Tfoot = 59;
1250
- const Ul = 60;
1251
- const Video = 61;
1252
- const TextArea$1 = 62;
1253
- const Select = 63;
1254
- const Option = 64;
1255
- const Code$1 = 65;
1256
- const Label = 66;
1257
- const Dt = 67;
1258
- const Iframe = 68;
1259
- const Main = 69;
1260
- const Strong = 70;
1261
- const Em = 71;
1262
- const Style = 72;
1263
- const Html = 73;
1264
- const Head = 74;
1265
- const Title = 75;
1266
- const Meta = 76;
1267
- const Canvas = 77;
1268
- const Form = 78;
1269
- const BlockQuote = 79;
1270
- const Quote = 80;
1271
- const Circle = 81;
1272
- const Defs = 82;
1273
- const Ellipse = 83;
1274
- const G = 84;
1275
- const Line = 85;
1276
- const Path = 86;
1277
- const Polygon = 87;
1278
- const Polyline = 88;
1279
- const Rect = 89;
1280
- const Svg = 90;
1281
- const Use = 91;
1201
+ const Text = 12;
1282
1202
  const Reference = 100;
1283
1203
 
1284
- const VirtualDomElements = {
1285
- __proto__: null,
1286
- A,
1287
- Abbr,
1288
- Article,
1289
- Aside,
1290
- Audio,
1291
- BlockQuote,
1292
- Br,
1293
- Button: Button$3,
1294
- Canvas,
1295
- Circle,
1296
- Cite,
1297
- Code: Code$1,
1298
- Col,
1299
- ColGroup,
1300
- Data,
1301
- Dd,
1302
- Defs,
1303
- Del,
1304
- Div: Div$1,
1305
- Dl,
1306
- Dt,
1307
- Ellipse,
1308
- Em,
1309
- Figcaption,
1310
- Figure,
1311
- Footer,
1312
- Form,
1313
- G,
1314
- H1,
1315
- H2,
1316
- H3,
1317
- H4,
1318
- H5,
1319
- H6,
1320
- Head,
1321
- Header,
1322
- Hr,
1323
- Html,
1324
- I,
1325
- Iframe,
1326
- Img,
1327
- Input: Input$1,
1328
- Ins,
1329
- Kbd,
1330
- Label,
1331
- Li,
1332
- Line,
1333
- Main,
1334
- Meta,
1335
- Nav: Nav$1,
1336
- Ol,
1337
- Option,
1338
- P,
1339
- Path,
1340
- Polygon,
1341
- Polyline,
1342
- Pre,
1343
- Quote,
1344
- Rect,
1345
- Reference,
1346
- Root,
1347
- Search,
1348
- Section,
1349
- Select,
1350
- Span: Span$1,
1351
- Strong,
1352
- Style,
1353
- Svg,
1354
- TBody,
1355
- THead,
1356
- Table,
1357
- Td,
1358
- Text: Text$1,
1359
- TextArea: TextArea$1,
1360
- Tfoot,
1361
- Th,
1362
- Time,
1363
- Title,
1364
- Tr,
1365
- Ul,
1366
- Use,
1367
- Video
1368
- };
1369
-
1370
1204
  const AltKey = 'event.altKey';
1371
1205
  const Button$2 = 'event.button';
1372
1206
  const ClientX = 'event.clientX';
@@ -1645,7 +1479,8 @@ const create$9 = () => {
1645
1479
  const commandQueues = new Map();
1646
1480
  const generations = Object.create(null);
1647
1481
  const states = Object.create(null);
1648
- const commandMapRef = {};
1482
+ const commandMapRef = Object.create(null);
1483
+ const commandsById = Object.create(null);
1649
1484
  const getGeneration = uid => generations[uid] || 0;
1650
1485
  const isCurrentGeneration = (uid, generation) => {
1651
1486
  return states[uid] !== undefined && getGeneration(uid) === generation;
@@ -1707,6 +1542,18 @@ const create$9 = () => {
1707
1542
  delete states[key];
1708
1543
  }
1709
1544
  },
1545
+ createDirectEventCommandMap(requestRender) {
1546
+ return {
1547
+ async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
1548
+ const fn = commandsById[command];
1549
+ if (!fn) {
1550
+ throw new Error(`Viewlet command not found: ${command}`);
1551
+ }
1552
+ await fn(uid, ...args);
1553
+ await requestRender(uid);
1554
+ }
1555
+ };
1556
+ },
1710
1557
  diff(uid, modules, numbers) {
1711
1558
  const {
1712
1559
  oldState,
@@ -1738,6 +1585,9 @@ const create$9 = () => {
1738
1585
  },
1739
1586
  registerCommands(commandMap) {
1740
1587
  Object.assign(commandMapRef, commandMap);
1588
+ for (const [key, fn] of Object.entries(commandMap)) {
1589
+ commandsById[toCommandId(key)] = fn;
1590
+ }
1741
1591
  },
1742
1592
  set(uid, oldState, newState, scheduledState) {
1743
1593
  const current = states[uid];
@@ -12822,7 +12672,6 @@ const Button$1 = 1;
12822
12672
  const Div = 4;
12823
12673
  const Input = 6;
12824
12674
  const Span = 8;
12825
- const Text = 12;
12826
12675
  const Nav = 40;
12827
12676
  const TextArea = 62;
12828
12677
 
@@ -12834,145 +12683,405 @@ const text = data => {
12834
12683
  };
12835
12684
  };
12836
12685
 
12837
- const getLineInfoVirtualDom = lineInfo => {
12838
- const dom = [{
12839
- childCount: lineInfo.length / 2,
12840
- className: HoverEditorRow,
12841
- type: Div
12842
- }];
12843
- for (let i = 0; i < lineInfo.length; i += 2) {
12844
- const tokenText = lineInfo[i];
12845
- const tokenClass = lineInfo[i + 1];
12846
- dom.push({
12847
- childCount: 1,
12848
- className: tokenClass,
12849
- type: Span
12850
- }, text(tokenText));
12851
- }
12852
- return dom;
12853
- };
12854
- const getLineInfosVirtualDom = lineInfos => {
12855
- const dom = lineInfos.flatMap(getLineInfoVirtualDom);
12856
- return dom;
12857
- };
12686
+ const SetText = 1;
12687
+ const Replace = 2;
12688
+ const SetAttribute = 3;
12689
+ const RemoveAttribute = 4;
12690
+ const Add = 6;
12691
+ const NavigateChild = 7;
12692
+ const NavigateParent = 8;
12693
+ const RemoveChild = 9;
12694
+ const NavigateSibling = 10;
12695
+ const SetReferenceNodeUid = 11;
12858
12696
 
12859
- const mergeClassNames = (...classNames) => {
12860
- return classNames.filter(Boolean).join(' ');
12697
+ const isKey = key => {
12698
+ return key !== 'type' && key !== 'childCount';
12861
12699
  };
12862
12700
 
12863
- const hoverProblemMessage = {
12864
- childCount: 1,
12865
- className: HoverProblemMessage,
12866
- type: Span
12867
- };
12868
- const hoverProblemDetail = {
12869
- childCount: 1,
12870
- className: HoverProblemDetail,
12871
- type: Span
12872
- };
12873
- const hoverDocumentationNode = {
12874
- childCount: 1,
12875
- className: HoverDocumentation,
12876
- type: Div
12877
- };
12878
- const hoverSashNode = {
12879
- childCount: 0,
12880
- className: mergeClassNames('Sash', 'SashVertical', 'SashResize'),
12881
- onPointerDown: HandleSashPointerDown,
12882
- type: Div
12701
+ const getKeys$1 = node => {
12702
+ const keys = Object.keys(node).filter(isKey);
12703
+ return keys;
12883
12704
  };
12884
- const getChildCount = (lineInfos, documentation, diagnostics) => {
12885
- const documentationCount = documentation ? 1 : 0;
12886
- const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
12887
- return lineInfos.length + documentationCount + diagnosticsCount;
12705
+
12706
+ const arrayToTree = nodes => {
12707
+ const result = [];
12708
+ let i = 0;
12709
+ while (i < nodes.length) {
12710
+ const node = nodes[i];
12711
+ const {
12712
+ children,
12713
+ nodesConsumed
12714
+ } = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
12715
+ result.push({
12716
+ node,
12717
+ children
12718
+ });
12719
+ i += 1 + nodesConsumed;
12720
+ }
12721
+ return result;
12888
12722
  };
12889
- const getEditorHoverClassName = (lineInfos, documentation, diagnostics) => {
12890
- const isDiagnosticOnly = diagnostics?.length === 1 && lineInfos.length === 0 && !documentation;
12891
- return mergeClassNames('Viewlet', 'EditorHover', isDiagnosticOnly ? EditorHoverDiagnosticOnly : '');
12723
+ const getChildrenWithCount = (nodes, startIndex, childCount) => {
12724
+ if (childCount === 0) {
12725
+ return {
12726
+ children: [],
12727
+ nodesConsumed: 0
12728
+ };
12729
+ }
12730
+ const children = [];
12731
+ let i = startIndex;
12732
+ let remaining = childCount;
12733
+ let totalConsumed = 0;
12734
+ while (remaining > 0 && i < nodes.length) {
12735
+ const node = nodes[i];
12736
+ const nodeChildCount = node.childCount || 0;
12737
+ const {
12738
+ children: nodeChildren,
12739
+ nodesConsumed
12740
+ } = getChildrenWithCount(nodes, i + 1, nodeChildCount);
12741
+ children.push({
12742
+ node,
12743
+ children: nodeChildren
12744
+ });
12745
+ const nodeSize = 1 + nodesConsumed;
12746
+ i += nodeSize;
12747
+ totalConsumed += nodeSize;
12748
+ remaining--;
12749
+ }
12750
+ return {
12751
+ children,
12752
+ nodesConsumed: totalConsumed
12753
+ };
12892
12754
  };
12893
- const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
12894
- const dom = [];
12895
- dom.push({
12896
- childCount: getChildCount(lineInfos, documentation, diagnostics) + 1,
12897
- className: getEditorHoverClassName(lineInfos, documentation, diagnostics),
12898
- type: Div
12899
- });
12900
- if (diagnostics && diagnostics.length > 0) {
12901
- dom.push({
12902
- childCount: diagnostics.length * 2,
12903
- className: mergeClassNames(HoverDisplayString, HoverProblem),
12904
- type: Div
12755
+
12756
+ const compareNodes = (oldNode, newNode) => {
12757
+ // Check if node type changed - return null to signal incompatible nodes
12758
+ // (caller should handle this with a Replace operation)
12759
+ if (oldNode.type !== newNode.type) {
12760
+ return null;
12761
+ }
12762
+ const patches = [];
12763
+ // Handle reference nodes - special handling for uid changes
12764
+ if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
12765
+ patches.push({
12766
+ type: SetReferenceNodeUid,
12767
+ uid: newNode.uid
12905
12768
  });
12906
- for (const diagnostic of diagnostics) {
12907
- dom.push(hoverProblemMessage, text(diagnostic.message), hoverProblemDetail, text(getDiagnosticHoverDetail(diagnostic)));
12769
+ }
12770
+ // Handle text nodes
12771
+ if (oldNode.type === Text && newNode.type === Text) {
12772
+ if (oldNode.text !== newNode.text) {
12773
+ patches.push({
12774
+ type: SetText,
12775
+ value: newNode.text
12776
+ });
12908
12777
  }
12778
+ return patches;
12909
12779
  }
12910
- if (lineInfos.length > 0) {
12911
- const lineInfosDom = getLineInfosVirtualDom(lineInfos);
12912
- dom.push({
12913
- childCount: lineInfos.length,
12914
- className: HoverDisplayString,
12915
- type: Div
12916
- }, ...lineInfosDom);
12780
+ // Compare attributes
12781
+ const oldKeys = getKeys$1(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
12782
+ const newKeys = getKeys$1(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
12783
+ // Check for attribute changes
12784
+ for (const key of newKeys) {
12785
+ if (oldNode[key] !== newNode[key]) {
12786
+ patches.push({
12787
+ type: SetAttribute,
12788
+ key,
12789
+ value: newNode[key]
12790
+ });
12791
+ }
12917
12792
  }
12918
- if (documentation) {
12919
- dom.push(hoverDocumentationNode, text(documentation));
12793
+ // Check for removed attributes
12794
+ for (const key of oldKeys) {
12795
+ if (!Object.hasOwn(newNode, key)) {
12796
+ patches.push({
12797
+ type: RemoveAttribute,
12798
+ key
12799
+ });
12800
+ }
12920
12801
  }
12921
- dom.push(hoverSashNode);
12922
- return dom;
12802
+ return patches;
12923
12803
  };
12924
12804
 
12925
- const renderHoverDom = {
12926
- apply(oldState, newState) {
12927
- const dom = getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics);
12928
- return [/* method */SetDom2, dom];
12929
- },
12930
- isEqual: (oldState, newState) => oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics
12931
- };
12932
- const renderBounds$2 = {
12933
- apply(oldState, newState) {
12934
- const {
12935
- height,
12936
- width,
12937
- x,
12938
- y
12939
- } = newState;
12940
- return [SetBounds, x, y, width, height];
12941
- },
12942
- isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y
12943
- };
12944
- const render$a = [renderHoverDom, renderBounds$2];
12945
- const renderHover = (oldState, newState) => {
12946
- const commands = [];
12947
- for (const item of render$a) {
12948
- if (!item.isEqual(oldState, newState)) {
12949
- commands.push(item.apply(oldState, newState));
12805
+ const treeToArray = node => {
12806
+ const result = [];
12807
+ const stack = [node];
12808
+ while (stack.length > 0) {
12809
+ const current = stack.pop();
12810
+ result.push(current.node);
12811
+ for (let i = current.children.length - 1; i >= 0; i--) {
12812
+ stack.push(current.children[i]);
12950
12813
  }
12951
12814
  }
12952
- return commands;
12815
+ return result;
12953
12816
  };
12954
12817
 
12955
- const commandsToForward$3 = [SetDom2, SetCss, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
12956
- const render$9 = widget => {
12957
- const commands = renderFull$3(widget.oldState, widget.newState);
12958
- const wrappedCommands = [];
12959
- const {
12960
- uid
12961
- } = widget.newState;
12962
- for (const command of commands) {
12963
- if (commandsToForward$3.includes(command[0])) {
12964
- wrappedCommands.push(command);
12965
- } else {
12966
- wrappedCommands.push(['Viewlet.send', uid, ...command]);
12967
- }
12818
+ const navigateToChild = (patches, currentChildIndex, index) => {
12819
+ if (currentChildIndex === -1) {
12820
+ patches.push({
12821
+ type: NavigateChild,
12822
+ index
12823
+ });
12824
+ return index;
12968
12825
  }
12969
- return wrappedCommands;
12970
- };
12971
- const add$6 = widget => {
12972
- return addWidget(widget, 'EditorRename', render$9);
12826
+ if (currentChildIndex !== index) {
12827
+ patches.push({
12828
+ type: NavigateSibling,
12829
+ index
12830
+ });
12831
+ }
12832
+ return index;
12973
12833
  };
12974
- const remove$5 = widget => {
12975
- return [];
12834
+ const navigateToParent = (patches, currentChildIndex) => {
12835
+ if (currentChildIndex >= 0) {
12836
+ patches.push({
12837
+ type: NavigateParent
12838
+ });
12839
+ }
12840
+ return -1;
12841
+ };
12842
+ const addTree = (newNode, patches) => {
12843
+ patches.push({
12844
+ type: Add,
12845
+ nodes: treeToArray(newNode)
12846
+ });
12847
+ };
12848
+ const replaceTree = (newNode, patches) => {
12849
+ patches.push({
12850
+ type: Replace,
12851
+ nodes: treeToArray(newNode)
12852
+ });
12853
+ };
12854
+ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
12855
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
12856
+ if (nodePatches === null) {
12857
+ const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
12858
+ replaceTree(newNode, patches);
12859
+ return nextChildIndex;
12860
+ }
12861
+ const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
12862
+ if (nodePatches.length === 0 && !hasChildrenToCompare) {
12863
+ return currentChildIndex;
12864
+ }
12865
+ const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
12866
+ if (nodePatches.length > 0) {
12867
+ patches.push(...nodePatches);
12868
+ }
12869
+ if (hasChildrenToCompare) {
12870
+ diffChildren(oldNode.children, newNode.children, patches);
12871
+ }
12872
+ return nextChildIndex;
12873
+ };
12874
+ const diffRootNode = (oldNode, newNode, patches) => {
12875
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
12876
+ if (nodePatches === null) {
12877
+ replaceTree(newNode, patches);
12878
+ return;
12879
+ }
12880
+ if (nodePatches.length > 0) {
12881
+ patches.push(...nodePatches);
12882
+ }
12883
+ if (oldNode.children.length > 0 || newNode.children.length > 0) {
12884
+ diffChildren(oldNode.children, newNode.children, patches);
12885
+ }
12886
+ };
12887
+ const diffChildren = (oldChildren, newChildren, patches) => {
12888
+ const maxLength = Math.max(oldChildren.length, newChildren.length);
12889
+ let currentChildIndex = -1;
12890
+ const indicesToRemove = [];
12891
+ for (let i = 0; i < maxLength; i++) {
12892
+ const oldNode = oldChildren[i];
12893
+ const newNode = newChildren[i];
12894
+ if (!oldNode && !newNode) {
12895
+ continue;
12896
+ }
12897
+ if (!oldNode) {
12898
+ currentChildIndex = navigateToParent(patches, currentChildIndex);
12899
+ addTree(newNode, patches);
12900
+ continue;
12901
+ }
12902
+ if (!newNode) {
12903
+ indicesToRemove.push(i);
12904
+ continue;
12905
+ }
12906
+ currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
12907
+ }
12908
+ navigateToParent(patches, currentChildIndex);
12909
+ for (let j = indicesToRemove.length - 1; j >= 0; j--) {
12910
+ patches.push({
12911
+ type: RemoveChild,
12912
+ index: indicesToRemove[j]
12913
+ });
12914
+ }
12915
+ };
12916
+ const diffTrees = (oldTree, newTree, patches, path) => {
12917
+ if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
12918
+ diffRootNode(oldTree[0], newTree[0], patches);
12919
+ return;
12920
+ }
12921
+ diffChildren(oldTree, newTree, patches);
12922
+ };
12923
+
12924
+ const removeTrailingNavigationPatches = patches => {
12925
+ while (patches.length > 0) {
12926
+ const patch = patches.at(-1);
12927
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
12928
+ break;
12929
+ }
12930
+ patches.pop();
12931
+ }
12932
+ return patches;
12933
+ };
12934
+
12935
+ const diffTree = (oldNodes, newNodes) => {
12936
+ // Step 1: Convert flat arrays to tree structures
12937
+ const oldTree = arrayToTree(oldNodes);
12938
+ const newTree = arrayToTree(newNodes);
12939
+ // Step 3: Compare the trees
12940
+ const patches = [];
12941
+ diffTrees(oldTree, newTree, patches, []);
12942
+ // Remove trailing navigation patches since they serve no purpose
12943
+ return removeTrailingNavigationPatches(patches);
12944
+ };
12945
+
12946
+ const getLineInfoVirtualDom = lineInfo => {
12947
+ const dom = [{
12948
+ childCount: lineInfo.length / 2,
12949
+ className: HoverEditorRow,
12950
+ type: Div
12951
+ }];
12952
+ for (let i = 0; i < lineInfo.length; i += 2) {
12953
+ const tokenText = lineInfo[i];
12954
+ const tokenClass = lineInfo[i + 1];
12955
+ dom.push({
12956
+ childCount: 1,
12957
+ className: tokenClass,
12958
+ type: Span
12959
+ }, text(tokenText));
12960
+ }
12961
+ return dom;
12962
+ };
12963
+ const getLineInfosVirtualDom = lineInfos => {
12964
+ const dom = lineInfos.flatMap(getLineInfoVirtualDom);
12965
+ return dom;
12966
+ };
12967
+
12968
+ const mergeClassNames = (...classNames) => {
12969
+ return classNames.filter(Boolean).join(' ');
12970
+ };
12971
+
12972
+ const hoverProblemMessage = {
12973
+ childCount: 1,
12974
+ className: HoverProblemMessage,
12975
+ type: Span
12976
+ };
12977
+ const hoverProblemDetail = {
12978
+ childCount: 1,
12979
+ className: HoverProblemDetail,
12980
+ type: Span
12981
+ };
12982
+ const hoverDocumentationNode = {
12983
+ childCount: 1,
12984
+ className: HoverDocumentation,
12985
+ type: Div
12986
+ };
12987
+ const hoverSashNode = {
12988
+ childCount: 0,
12989
+ className: mergeClassNames('Sash', 'SashVertical', 'SashResize'),
12990
+ onPointerDown: HandleSashPointerDown,
12991
+ type: Div
12992
+ };
12993
+ const getChildCount = (lineInfos, documentation, diagnostics) => {
12994
+ const documentationCount = documentation ? 1 : 0;
12995
+ const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
12996
+ return lineInfos.length + documentationCount + diagnosticsCount;
12997
+ };
12998
+ const getEditorHoverClassName = (lineInfos, documentation, diagnostics) => {
12999
+ const isDiagnosticOnly = diagnostics?.length === 1 && lineInfos.length === 0 && !documentation;
13000
+ return mergeClassNames('Viewlet', 'EditorHover', isDiagnosticOnly ? EditorHoverDiagnosticOnly : '');
13001
+ };
13002
+ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
13003
+ const dom = [];
13004
+ dom.push({
13005
+ childCount: getChildCount(lineInfos, documentation, diagnostics) + 1,
13006
+ className: getEditorHoverClassName(lineInfos, documentation, diagnostics),
13007
+ type: Div
13008
+ });
13009
+ if (diagnostics && diagnostics.length > 0) {
13010
+ dom.push({
13011
+ childCount: diagnostics.length * 2,
13012
+ className: mergeClassNames(HoverDisplayString, HoverProblem),
13013
+ type: Div
13014
+ });
13015
+ for (const diagnostic of diagnostics) {
13016
+ dom.push(hoverProblemMessage, text(diagnostic.message), hoverProblemDetail, text(getDiagnosticHoverDetail(diagnostic)));
13017
+ }
13018
+ }
13019
+ if (lineInfos.length > 0) {
13020
+ const lineInfosDom = getLineInfosVirtualDom(lineInfos);
13021
+ dom.push({
13022
+ childCount: lineInfos.length,
13023
+ className: HoverDisplayString,
13024
+ type: Div
13025
+ }, ...lineInfosDom);
13026
+ }
13027
+ if (documentation) {
13028
+ dom.push(hoverDocumentationNode, text(documentation));
13029
+ }
13030
+ dom.push(hoverSashNode);
13031
+ return dom;
13032
+ };
13033
+
13034
+ const renderHoverDom = {
13035
+ apply(oldState, newState) {
13036
+ const dom = getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics);
13037
+ return [/* method */SetDom2, dom];
13038
+ },
13039
+ isEqual: (oldState, newState) => oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics
13040
+ };
13041
+ const renderBounds$2 = {
13042
+ apply(oldState, newState) {
13043
+ const {
13044
+ height,
13045
+ width,
13046
+ x,
13047
+ y
13048
+ } = newState;
13049
+ return [SetBounds, x, y, width, height];
13050
+ },
13051
+ isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y
13052
+ };
13053
+ const render$a = [renderHoverDom, renderBounds$2];
13054
+ const renderHover = (oldState, newState) => {
13055
+ const commands = [];
13056
+ for (const item of render$a) {
13057
+ if (!item.isEqual(oldState, newState)) {
13058
+ commands.push(item.apply(oldState, newState));
13059
+ }
13060
+ }
13061
+ return commands;
13062
+ };
13063
+
13064
+ const commandsToForward$3 = [SetDom2, SetCss, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
13065
+ const render$9 = widget => {
13066
+ const commands = renderFull$3(widget.oldState, widget.newState);
13067
+ const wrappedCommands = [];
13068
+ const {
13069
+ uid
13070
+ } = widget.newState;
13071
+ for (const command of commands) {
13072
+ if (commandsToForward$3.includes(command[0])) {
13073
+ wrappedCommands.push(command);
13074
+ } else {
13075
+ wrappedCommands.push(['Viewlet.send', uid, ...command]);
13076
+ }
13077
+ }
13078
+ return wrappedCommands;
13079
+ };
13080
+ const add$6 = widget => {
13081
+ return addWidget(widget, 'EditorRename', render$9);
13082
+ };
13083
+ const remove$5 = widget => {
13084
+ return [];
12976
13085
  };
12977
13086
  const {
12978
13087
  accept,
@@ -13218,6 +13327,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
13218
13327
  const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
13219
13328
  const newEditor = {
13220
13329
  ...editor,
13330
+ additionalFocus: unsetAdditionalFocus$1 ? 0 : editor.additionalFocus,
13221
13331
  decorations: widgetId === Rename$1 ? editor.decorations.slice(0, -4) : editor.decorations,
13222
13332
  focused: true,
13223
13333
  widgetRevision,
@@ -13663,7 +13773,7 @@ const getKeyBindings = () => {
13663
13773
  }];
13664
13774
  };
13665
13775
 
13666
- const getKeys$1 = () => {
13776
+ const getKeys = () => {
13667
13777
  return getKeys$2();
13668
13778
  };
13669
13779
 
@@ -14725,268 +14835,6 @@ const renderFocusContext$1 = (oldState, newState) => {
14725
14835
  return [SetFocusContext$1, newState.uid, newState.focus];
14726
14836
  };
14727
14837
 
14728
- new Set(Object.values(VirtualDomElements));
14729
-
14730
- const SetText = 1;
14731
- const Replace = 2;
14732
- const SetAttribute = 3;
14733
- const RemoveAttribute = 4;
14734
- const Add = 6;
14735
- const NavigateChild = 7;
14736
- const NavigateParent = 8;
14737
- const RemoveChild = 9;
14738
- const NavigateSibling = 10;
14739
- const SetReferenceNodeUid = 11;
14740
-
14741
- const isKey = key => {
14742
- return key !== 'type' && key !== 'childCount';
14743
- };
14744
-
14745
- const getKeys = node => {
14746
- const keys = Object.keys(node).filter(isKey);
14747
- return keys;
14748
- };
14749
-
14750
- const arrayToTree = nodes => {
14751
- const result = [];
14752
- let i = 0;
14753
- while (i < nodes.length) {
14754
- const node = nodes[i];
14755
- const {
14756
- children,
14757
- nodesConsumed
14758
- } = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
14759
- result.push({
14760
- node,
14761
- children
14762
- });
14763
- i += 1 + nodesConsumed;
14764
- }
14765
- return result;
14766
- };
14767
- const getChildrenWithCount = (nodes, startIndex, childCount) => {
14768
- if (childCount === 0) {
14769
- return {
14770
- children: [],
14771
- nodesConsumed: 0
14772
- };
14773
- }
14774
- const children = [];
14775
- let i = startIndex;
14776
- let remaining = childCount;
14777
- let totalConsumed = 0;
14778
- while (remaining > 0 && i < nodes.length) {
14779
- const node = nodes[i];
14780
- const nodeChildCount = node.childCount || 0;
14781
- const {
14782
- children: nodeChildren,
14783
- nodesConsumed
14784
- } = getChildrenWithCount(nodes, i + 1, nodeChildCount);
14785
- children.push({
14786
- node,
14787
- children: nodeChildren
14788
- });
14789
- const nodeSize = 1 + nodesConsumed;
14790
- i += nodeSize;
14791
- totalConsumed += nodeSize;
14792
- remaining--;
14793
- }
14794
- return {
14795
- children,
14796
- nodesConsumed: totalConsumed
14797
- };
14798
- };
14799
-
14800
- const compareNodes = (oldNode, newNode) => {
14801
- // Check if node type changed - return null to signal incompatible nodes
14802
- // (caller should handle this with a Replace operation)
14803
- if (oldNode.type !== newNode.type) {
14804
- return null;
14805
- }
14806
- const patches = [];
14807
- // Handle reference nodes - special handling for uid changes
14808
- if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
14809
- patches.push({
14810
- type: SetReferenceNodeUid,
14811
- uid: newNode.uid
14812
- });
14813
- }
14814
- // Handle text nodes
14815
- if (oldNode.type === Text$1 && newNode.type === Text$1) {
14816
- if (oldNode.text !== newNode.text) {
14817
- patches.push({
14818
- type: SetText,
14819
- value: newNode.text
14820
- });
14821
- }
14822
- return patches;
14823
- }
14824
- // Compare attributes
14825
- const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
14826
- const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
14827
- // Check for attribute changes
14828
- for (const key of newKeys) {
14829
- if (oldNode[key] !== newNode[key]) {
14830
- patches.push({
14831
- type: SetAttribute,
14832
- key,
14833
- value: newNode[key]
14834
- });
14835
- }
14836
- }
14837
- // Check for removed attributes
14838
- for (const key of oldKeys) {
14839
- if (!Object.hasOwn(newNode, key)) {
14840
- patches.push({
14841
- type: RemoveAttribute,
14842
- key
14843
- });
14844
- }
14845
- }
14846
- return patches;
14847
- };
14848
-
14849
- const treeToArray = node => {
14850
- const result = [];
14851
- const stack = [node];
14852
- while (stack.length > 0) {
14853
- const current = stack.pop();
14854
- result.push(current.node);
14855
- for (let i = current.children.length - 1; i >= 0; i--) {
14856
- stack.push(current.children[i]);
14857
- }
14858
- }
14859
- return result;
14860
- };
14861
-
14862
- const navigateToChild = (patches, currentChildIndex, index) => {
14863
- if (currentChildIndex === -1) {
14864
- patches.push({
14865
- type: NavigateChild,
14866
- index
14867
- });
14868
- return index;
14869
- }
14870
- if (currentChildIndex !== index) {
14871
- patches.push({
14872
- type: NavigateSibling,
14873
- index
14874
- });
14875
- }
14876
- return index;
14877
- };
14878
- const navigateToParent = (patches, currentChildIndex) => {
14879
- if (currentChildIndex >= 0) {
14880
- patches.push({
14881
- type: NavigateParent
14882
- });
14883
- }
14884
- return -1;
14885
- };
14886
- const addTree = (newNode, patches) => {
14887
- patches.push({
14888
- type: Add,
14889
- nodes: treeToArray(newNode)
14890
- });
14891
- };
14892
- const replaceTree = (newNode, patches) => {
14893
- patches.push({
14894
- type: Replace,
14895
- nodes: treeToArray(newNode)
14896
- });
14897
- };
14898
- const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
14899
- const nodePatches = compareNodes(oldNode.node, newNode.node);
14900
- if (nodePatches === null) {
14901
- const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
14902
- replaceTree(newNode, patches);
14903
- return nextChildIndex;
14904
- }
14905
- const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
14906
- if (nodePatches.length === 0 && !hasChildrenToCompare) {
14907
- return currentChildIndex;
14908
- }
14909
- const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
14910
- if (nodePatches.length > 0) {
14911
- patches.push(...nodePatches);
14912
- }
14913
- if (hasChildrenToCompare) {
14914
- diffChildren(oldNode.children, newNode.children, patches);
14915
- }
14916
- return nextChildIndex;
14917
- };
14918
- const diffRootNode = (oldNode, newNode, patches) => {
14919
- const nodePatches = compareNodes(oldNode.node, newNode.node);
14920
- if (nodePatches === null) {
14921
- replaceTree(newNode, patches);
14922
- return;
14923
- }
14924
- if (nodePatches.length > 0) {
14925
- patches.push(...nodePatches);
14926
- }
14927
- if (oldNode.children.length > 0 || newNode.children.length > 0) {
14928
- diffChildren(oldNode.children, newNode.children, patches);
14929
- }
14930
- };
14931
- const diffChildren = (oldChildren, newChildren, patches) => {
14932
- const maxLength = Math.max(oldChildren.length, newChildren.length);
14933
- let currentChildIndex = -1;
14934
- const indicesToRemove = [];
14935
- for (let i = 0; i < maxLength; i++) {
14936
- const oldNode = oldChildren[i];
14937
- const newNode = newChildren[i];
14938
- if (!oldNode && !newNode) {
14939
- continue;
14940
- }
14941
- if (!oldNode) {
14942
- currentChildIndex = navigateToParent(patches, currentChildIndex);
14943
- addTree(newNode, patches);
14944
- continue;
14945
- }
14946
- if (!newNode) {
14947
- indicesToRemove.push(i);
14948
- continue;
14949
- }
14950
- currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
14951
- }
14952
- navigateToParent(patches, currentChildIndex);
14953
- for (let j = indicesToRemove.length - 1; j >= 0; j--) {
14954
- patches.push({
14955
- type: RemoveChild,
14956
- index: indicesToRemove[j]
14957
- });
14958
- }
14959
- };
14960
- const diffTrees = (oldTree, newTree, patches, path) => {
14961
- if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
14962
- diffRootNode(oldTree[0], newTree[0], patches);
14963
- return;
14964
- }
14965
- diffChildren(oldTree, newTree, patches);
14966
- };
14967
-
14968
- const removeTrailingNavigationPatches = patches => {
14969
- while (patches.length > 0) {
14970
- const patch = patches.at(-1);
14971
- if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
14972
- break;
14973
- }
14974
- patches.pop();
14975
- }
14976
- return patches;
14977
- };
14978
-
14979
- const diffTree = (oldNodes, newNodes) => {
14980
- // Step 1: Convert flat arrays to tree structures
14981
- const oldTree = arrayToTree(oldNodes);
14982
- const newTree = arrayToTree(newNodes);
14983
- // Step 3: Compare the trees
14984
- const patches = [];
14985
- diffTrees(oldTree, newTree, patches, []);
14986
- // Remove trailing navigation patches since they serve no purpose
14987
- return removeTrailingNavigationPatches(patches);
14988
- };
14989
-
14990
14838
  const True = 'true';
14991
14839
 
14992
14840
  const Button = 'button';
@@ -14994,11 +14842,7 @@ const Code = 'code';
14994
14842
  const TextBox = 'textbox';
14995
14843
 
14996
14844
  const getPathname = uri => {
14997
- try {
14998
- return decodeURIComponent(new URL(uri).pathname);
14999
- } catch {
15000
- return decodeURIComponent(uri);
15001
- }
14845
+ return decodeURIComponent(URL.canParse(uri) ? new URL(uri).pathname : uri);
15002
14846
  };
15003
14847
  const getFileBreadcrumbs = (uri, workspaceUri) => {
15004
14848
  const path = getPathname(uri);
@@ -16412,7 +16256,7 @@ const commandMap = {
16412
16256
  'Editor.getCommandIds': getCommandIds,
16413
16257
  'Editor.getDiagnostics': getDiagnostics$1,
16414
16258
  'Editor.getKeyBindings': getKeyBindings,
16415
- 'Editor.getKeys': getKeys$1,
16259
+ 'Editor.getKeys': getKeys,
16416
16260
  'Editor.getLanguageId': getLanguageId,
16417
16261
  'Editor.getLines2': getLines2,
16418
16262
  'Editor.getMenuEntries': getMenuEntries,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.55.3",
3
+ "version": "19.55.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"