@lvce-editor/editor-worker 19.55.3 → 19.55.5
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 +403 -558
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1198,175 +1198,9 @@ const create$a = rpcId => {
|
|
|
1198
1198
|
};
|
|
1199
1199
|
};
|
|
1200
1200
|
|
|
1201
|
-
const
|
|
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];
|
|
@@ -6364,10 +6214,11 @@ const x = (editor, rowIndex, columnIndex) => {
|
|
|
6364
6214
|
};
|
|
6365
6215
|
const y = (editor, rowIndex) => {
|
|
6366
6216
|
const {
|
|
6217
|
+
deltaY = 0,
|
|
6367
6218
|
rowHeight,
|
|
6368
6219
|
y
|
|
6369
6220
|
} = editor;
|
|
6370
|
-
const offsetY = (rowIndex + 1) * rowHeight + y;
|
|
6221
|
+
const offsetY = (rowIndex + 1) * rowHeight + y - deltaY;
|
|
6371
6222
|
return offsetY;
|
|
6372
6223
|
};
|
|
6373
6224
|
|
|
@@ -12822,7 +12673,6 @@ const Button$1 = 1;
|
|
|
12822
12673
|
const Div = 4;
|
|
12823
12674
|
const Input = 6;
|
|
12824
12675
|
const Span = 8;
|
|
12825
|
-
const Text = 12;
|
|
12826
12676
|
const Nav = 40;
|
|
12827
12677
|
const TextArea = 62;
|
|
12828
12678
|
|
|
@@ -12834,144 +12684,404 @@ const text = data => {
|
|
|
12834
12684
|
};
|
|
12835
12685
|
};
|
|
12836
12686
|
|
|
12837
|
-
const
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
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
|
-
};
|
|
12687
|
+
const SetText = 1;
|
|
12688
|
+
const Replace = 2;
|
|
12689
|
+
const SetAttribute = 3;
|
|
12690
|
+
const RemoveAttribute = 4;
|
|
12691
|
+
const Add = 6;
|
|
12692
|
+
const NavigateChild = 7;
|
|
12693
|
+
const NavigateParent = 8;
|
|
12694
|
+
const RemoveChild = 9;
|
|
12695
|
+
const NavigateSibling = 10;
|
|
12696
|
+
const SetReferenceNodeUid = 11;
|
|
12858
12697
|
|
|
12859
|
-
const
|
|
12860
|
-
return
|
|
12698
|
+
const isKey = key => {
|
|
12699
|
+
return key !== 'type' && key !== 'childCount';
|
|
12861
12700
|
};
|
|
12862
12701
|
|
|
12863
|
-
const
|
|
12864
|
-
|
|
12865
|
-
|
|
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
|
|
12702
|
+
const getKeys$1 = node => {
|
|
12703
|
+
const keys = Object.keys(node).filter(isKey);
|
|
12704
|
+
return keys;
|
|
12883
12705
|
};
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
const
|
|
12887
|
-
|
|
12706
|
+
|
|
12707
|
+
const arrayToTree = nodes => {
|
|
12708
|
+
const result = [];
|
|
12709
|
+
let i = 0;
|
|
12710
|
+
while (i < nodes.length) {
|
|
12711
|
+
const node = nodes[i];
|
|
12712
|
+
const {
|
|
12713
|
+
children,
|
|
12714
|
+
nodesConsumed
|
|
12715
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
12716
|
+
result.push({
|
|
12717
|
+
node,
|
|
12718
|
+
children
|
|
12719
|
+
});
|
|
12720
|
+
i += 1 + nodesConsumed;
|
|
12721
|
+
}
|
|
12722
|
+
return result;
|
|
12888
12723
|
};
|
|
12889
|
-
const
|
|
12890
|
-
|
|
12891
|
-
|
|
12724
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
12725
|
+
if (childCount === 0) {
|
|
12726
|
+
return {
|
|
12727
|
+
children: [],
|
|
12728
|
+
nodesConsumed: 0
|
|
12729
|
+
};
|
|
12730
|
+
}
|
|
12731
|
+
const children = [];
|
|
12732
|
+
let i = startIndex;
|
|
12733
|
+
let remaining = childCount;
|
|
12734
|
+
let totalConsumed = 0;
|
|
12735
|
+
while (remaining > 0 && i < nodes.length) {
|
|
12736
|
+
const node = nodes[i];
|
|
12737
|
+
const nodeChildCount = node.childCount || 0;
|
|
12738
|
+
const {
|
|
12739
|
+
children: nodeChildren,
|
|
12740
|
+
nodesConsumed
|
|
12741
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
12742
|
+
children.push({
|
|
12743
|
+
node,
|
|
12744
|
+
children: nodeChildren
|
|
12745
|
+
});
|
|
12746
|
+
const nodeSize = 1 + nodesConsumed;
|
|
12747
|
+
i += nodeSize;
|
|
12748
|
+
totalConsumed += nodeSize;
|
|
12749
|
+
remaining--;
|
|
12750
|
+
}
|
|
12751
|
+
return {
|
|
12752
|
+
children,
|
|
12753
|
+
nodesConsumed: totalConsumed
|
|
12754
|
+
};
|
|
12892
12755
|
};
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
}
|
|
12900
|
-
|
|
12901
|
-
|
|
12902
|
-
|
|
12903
|
-
|
|
12904
|
-
type:
|
|
12756
|
+
|
|
12757
|
+
const compareNodes = (oldNode, newNode) => {
|
|
12758
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
12759
|
+
// (caller should handle this with a Replace operation)
|
|
12760
|
+
if (oldNode.type !== newNode.type) {
|
|
12761
|
+
return null;
|
|
12762
|
+
}
|
|
12763
|
+
const patches = [];
|
|
12764
|
+
// Handle reference nodes - special handling for uid changes
|
|
12765
|
+
if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
|
|
12766
|
+
patches.push({
|
|
12767
|
+
type: SetReferenceNodeUid,
|
|
12768
|
+
uid: newNode.uid
|
|
12905
12769
|
});
|
|
12906
|
-
|
|
12907
|
-
|
|
12770
|
+
}
|
|
12771
|
+
// Handle text nodes
|
|
12772
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
12773
|
+
if (oldNode.text !== newNode.text) {
|
|
12774
|
+
patches.push({
|
|
12775
|
+
type: SetText,
|
|
12776
|
+
value: newNode.text
|
|
12777
|
+
});
|
|
12908
12778
|
}
|
|
12779
|
+
return patches;
|
|
12909
12780
|
}
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12781
|
+
// Compare attributes
|
|
12782
|
+
const oldKeys = getKeys$1(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
|
|
12783
|
+
const newKeys = getKeys$1(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
|
|
12784
|
+
// Check for attribute changes
|
|
12785
|
+
for (const key of newKeys) {
|
|
12786
|
+
if (oldNode[key] !== newNode[key]) {
|
|
12787
|
+
patches.push({
|
|
12788
|
+
type: SetAttribute,
|
|
12789
|
+
key,
|
|
12790
|
+
value: newNode[key]
|
|
12791
|
+
});
|
|
12792
|
+
}
|
|
12917
12793
|
}
|
|
12918
|
-
|
|
12919
|
-
|
|
12794
|
+
// Check for removed attributes
|
|
12795
|
+
for (const key of oldKeys) {
|
|
12796
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
12797
|
+
patches.push({
|
|
12798
|
+
type: RemoveAttribute,
|
|
12799
|
+
key
|
|
12800
|
+
});
|
|
12801
|
+
}
|
|
12920
12802
|
}
|
|
12921
|
-
|
|
12922
|
-
return dom;
|
|
12803
|
+
return patches;
|
|
12923
12804
|
};
|
|
12924
12805
|
|
|
12925
|
-
const
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
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));
|
|
12806
|
+
const treeToArray = node => {
|
|
12807
|
+
const result = [];
|
|
12808
|
+
const stack = [node];
|
|
12809
|
+
while (stack.length > 0) {
|
|
12810
|
+
const current = stack.pop();
|
|
12811
|
+
result.push(current.node);
|
|
12812
|
+
for (let i = current.children.length - 1; i >= 0; i--) {
|
|
12813
|
+
stack.push(current.children[i]);
|
|
12950
12814
|
}
|
|
12951
12815
|
}
|
|
12952
|
-
return
|
|
12816
|
+
return result;
|
|
12953
12817
|
};
|
|
12954
12818
|
|
|
12955
|
-
const
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
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
|
-
}
|
|
12819
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
12820
|
+
if (currentChildIndex === -1) {
|
|
12821
|
+
patches.push({
|
|
12822
|
+
type: NavigateChild,
|
|
12823
|
+
index
|
|
12824
|
+
});
|
|
12825
|
+
return index;
|
|
12968
12826
|
}
|
|
12969
|
-
|
|
12970
|
-
|
|
12971
|
-
|
|
12972
|
-
|
|
12827
|
+
if (currentChildIndex !== index) {
|
|
12828
|
+
patches.push({
|
|
12829
|
+
type: NavigateSibling,
|
|
12830
|
+
index
|
|
12831
|
+
});
|
|
12832
|
+
}
|
|
12833
|
+
return index;
|
|
12973
12834
|
};
|
|
12974
|
-
const
|
|
12835
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
12836
|
+
if (currentChildIndex >= 0) {
|
|
12837
|
+
patches.push({
|
|
12838
|
+
type: NavigateParent
|
|
12839
|
+
});
|
|
12840
|
+
}
|
|
12841
|
+
return -1;
|
|
12842
|
+
};
|
|
12843
|
+
const addTree = (newNode, patches) => {
|
|
12844
|
+
patches.push({
|
|
12845
|
+
type: Add,
|
|
12846
|
+
nodes: treeToArray(newNode)
|
|
12847
|
+
});
|
|
12848
|
+
};
|
|
12849
|
+
const replaceTree = (newNode, patches) => {
|
|
12850
|
+
patches.push({
|
|
12851
|
+
type: Replace,
|
|
12852
|
+
nodes: treeToArray(newNode)
|
|
12853
|
+
});
|
|
12854
|
+
};
|
|
12855
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
12856
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
12857
|
+
if (nodePatches === null) {
|
|
12858
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
12859
|
+
replaceTree(newNode, patches);
|
|
12860
|
+
return nextChildIndex;
|
|
12861
|
+
}
|
|
12862
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
12863
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
12864
|
+
return currentChildIndex;
|
|
12865
|
+
}
|
|
12866
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
12867
|
+
if (nodePatches.length > 0) {
|
|
12868
|
+
patches.push(...nodePatches);
|
|
12869
|
+
}
|
|
12870
|
+
if (hasChildrenToCompare) {
|
|
12871
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
12872
|
+
}
|
|
12873
|
+
return nextChildIndex;
|
|
12874
|
+
};
|
|
12875
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
12876
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
12877
|
+
if (nodePatches === null) {
|
|
12878
|
+
replaceTree(newNode, patches);
|
|
12879
|
+
return;
|
|
12880
|
+
}
|
|
12881
|
+
if (nodePatches.length > 0) {
|
|
12882
|
+
patches.push(...nodePatches);
|
|
12883
|
+
}
|
|
12884
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
12885
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
12886
|
+
}
|
|
12887
|
+
};
|
|
12888
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
12889
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
12890
|
+
let currentChildIndex = -1;
|
|
12891
|
+
const indicesToRemove = [];
|
|
12892
|
+
for (let i = 0; i < maxLength; i++) {
|
|
12893
|
+
const oldNode = oldChildren[i];
|
|
12894
|
+
const newNode = newChildren[i];
|
|
12895
|
+
if (!oldNode && !newNode) {
|
|
12896
|
+
continue;
|
|
12897
|
+
}
|
|
12898
|
+
if (!oldNode) {
|
|
12899
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
12900
|
+
addTree(newNode, patches);
|
|
12901
|
+
continue;
|
|
12902
|
+
}
|
|
12903
|
+
if (!newNode) {
|
|
12904
|
+
indicesToRemove.push(i);
|
|
12905
|
+
continue;
|
|
12906
|
+
}
|
|
12907
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
12908
|
+
}
|
|
12909
|
+
navigateToParent(patches, currentChildIndex);
|
|
12910
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
12911
|
+
patches.push({
|
|
12912
|
+
type: RemoveChild,
|
|
12913
|
+
index: indicesToRemove[j]
|
|
12914
|
+
});
|
|
12915
|
+
}
|
|
12916
|
+
};
|
|
12917
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
12918
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
12919
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
12920
|
+
return;
|
|
12921
|
+
}
|
|
12922
|
+
diffChildren(oldTree, newTree, patches);
|
|
12923
|
+
};
|
|
12924
|
+
|
|
12925
|
+
const removeTrailingNavigationPatches = patches => {
|
|
12926
|
+
while (patches.length > 0) {
|
|
12927
|
+
const patch = patches.at(-1);
|
|
12928
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
12929
|
+
break;
|
|
12930
|
+
}
|
|
12931
|
+
patches.pop();
|
|
12932
|
+
}
|
|
12933
|
+
return patches;
|
|
12934
|
+
};
|
|
12935
|
+
|
|
12936
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
12937
|
+
// Step 1: Convert flat arrays to tree structures
|
|
12938
|
+
const oldTree = arrayToTree(oldNodes);
|
|
12939
|
+
const newTree = arrayToTree(newNodes);
|
|
12940
|
+
// Step 3: Compare the trees
|
|
12941
|
+
const patches = [];
|
|
12942
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
12943
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
12944
|
+
return removeTrailingNavigationPatches(patches);
|
|
12945
|
+
};
|
|
12946
|
+
|
|
12947
|
+
const getLineInfoVirtualDom = lineInfo => {
|
|
12948
|
+
const dom = [{
|
|
12949
|
+
childCount: lineInfo.length / 2,
|
|
12950
|
+
className: HoverEditorRow,
|
|
12951
|
+
type: Div
|
|
12952
|
+
}];
|
|
12953
|
+
for (let i = 0; i < lineInfo.length; i += 2) {
|
|
12954
|
+
const tokenText = lineInfo[i];
|
|
12955
|
+
const tokenClass = lineInfo[i + 1];
|
|
12956
|
+
dom.push({
|
|
12957
|
+
childCount: 1,
|
|
12958
|
+
className: tokenClass,
|
|
12959
|
+
type: Span
|
|
12960
|
+
}, text(tokenText));
|
|
12961
|
+
}
|
|
12962
|
+
return dom;
|
|
12963
|
+
};
|
|
12964
|
+
const getLineInfosVirtualDom = lineInfos => {
|
|
12965
|
+
const dom = lineInfos.flatMap(getLineInfoVirtualDom);
|
|
12966
|
+
return dom;
|
|
12967
|
+
};
|
|
12968
|
+
|
|
12969
|
+
const mergeClassNames = (...classNames) => {
|
|
12970
|
+
return classNames.filter(Boolean).join(' ');
|
|
12971
|
+
};
|
|
12972
|
+
|
|
12973
|
+
const hoverProblemMessage = {
|
|
12974
|
+
childCount: 1,
|
|
12975
|
+
className: HoverProblemMessage,
|
|
12976
|
+
type: Span
|
|
12977
|
+
};
|
|
12978
|
+
const hoverProblemDetail = {
|
|
12979
|
+
childCount: 1,
|
|
12980
|
+
className: HoverProblemDetail,
|
|
12981
|
+
type: Span
|
|
12982
|
+
};
|
|
12983
|
+
const hoverDocumentationNode = {
|
|
12984
|
+
childCount: 1,
|
|
12985
|
+
className: HoverDocumentation,
|
|
12986
|
+
type: Div
|
|
12987
|
+
};
|
|
12988
|
+
const hoverSashNode = {
|
|
12989
|
+
childCount: 0,
|
|
12990
|
+
className: mergeClassNames('Sash', 'SashVertical', 'SashResize'),
|
|
12991
|
+
onPointerDown: HandleSashPointerDown,
|
|
12992
|
+
type: Div
|
|
12993
|
+
};
|
|
12994
|
+
const getChildCount = (lineInfos, documentation, diagnostics) => {
|
|
12995
|
+
const documentationCount = documentation ? 1 : 0;
|
|
12996
|
+
const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
|
|
12997
|
+
return lineInfos.length + documentationCount + diagnosticsCount;
|
|
12998
|
+
};
|
|
12999
|
+
const getEditorHoverClassName = (lineInfos, documentation, diagnostics) => {
|
|
13000
|
+
const isDiagnosticOnly = diagnostics?.length === 1 && lineInfos.length === 0 && !documentation;
|
|
13001
|
+
return mergeClassNames('Viewlet', 'EditorHover', isDiagnosticOnly ? EditorHoverDiagnosticOnly : '');
|
|
13002
|
+
};
|
|
13003
|
+
const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
|
|
13004
|
+
const dom = [];
|
|
13005
|
+
dom.push({
|
|
13006
|
+
childCount: getChildCount(lineInfos, documentation, diagnostics) + 1,
|
|
13007
|
+
className: getEditorHoverClassName(lineInfos, documentation, diagnostics),
|
|
13008
|
+
type: Div
|
|
13009
|
+
});
|
|
13010
|
+
if (diagnostics && diagnostics.length > 0) {
|
|
13011
|
+
dom.push({
|
|
13012
|
+
childCount: diagnostics.length * 2,
|
|
13013
|
+
className: mergeClassNames(HoverDisplayString, HoverProblem),
|
|
13014
|
+
type: Div
|
|
13015
|
+
});
|
|
13016
|
+
for (const diagnostic of diagnostics) {
|
|
13017
|
+
dom.push(hoverProblemMessage, text(diagnostic.message), hoverProblemDetail, text(getDiagnosticHoverDetail(diagnostic)));
|
|
13018
|
+
}
|
|
13019
|
+
}
|
|
13020
|
+
if (lineInfos.length > 0) {
|
|
13021
|
+
const lineInfosDom = getLineInfosVirtualDom(lineInfos);
|
|
13022
|
+
dom.push({
|
|
13023
|
+
childCount: lineInfos.length,
|
|
13024
|
+
className: HoverDisplayString,
|
|
13025
|
+
type: Div
|
|
13026
|
+
}, ...lineInfosDom);
|
|
13027
|
+
}
|
|
13028
|
+
if (documentation) {
|
|
13029
|
+
dom.push(hoverDocumentationNode, text(documentation));
|
|
13030
|
+
}
|
|
13031
|
+
dom.push(hoverSashNode);
|
|
13032
|
+
return dom;
|
|
13033
|
+
};
|
|
13034
|
+
|
|
13035
|
+
const renderHoverDom = {
|
|
13036
|
+
apply(oldState, newState) {
|
|
13037
|
+
const dom = getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics);
|
|
13038
|
+
return [/* method */SetDom2, dom];
|
|
13039
|
+
},
|
|
13040
|
+
isEqual: (oldState, newState) => oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics
|
|
13041
|
+
};
|
|
13042
|
+
const renderBounds$2 = {
|
|
13043
|
+
apply(oldState, newState) {
|
|
13044
|
+
const {
|
|
13045
|
+
height,
|
|
13046
|
+
width,
|
|
13047
|
+
x,
|
|
13048
|
+
y
|
|
13049
|
+
} = newState;
|
|
13050
|
+
return [SetBounds, x, y, width, height];
|
|
13051
|
+
},
|
|
13052
|
+
isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y
|
|
13053
|
+
};
|
|
13054
|
+
const render$a = [renderHoverDom, renderBounds$2];
|
|
13055
|
+
const renderHover = (oldState, newState) => {
|
|
13056
|
+
const commands = [];
|
|
13057
|
+
for (const item of render$a) {
|
|
13058
|
+
if (!item.isEqual(oldState, newState)) {
|
|
13059
|
+
commands.push(item.apply(oldState, newState));
|
|
13060
|
+
}
|
|
13061
|
+
}
|
|
13062
|
+
return commands;
|
|
13063
|
+
};
|
|
13064
|
+
|
|
13065
|
+
const commandsToForward$3 = [SetDom2, SetCss, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
|
|
13066
|
+
const render$9 = widget => {
|
|
13067
|
+
const commands = renderFull$3(widget.oldState, widget.newState);
|
|
13068
|
+
const wrappedCommands = [];
|
|
13069
|
+
const {
|
|
13070
|
+
uid
|
|
13071
|
+
} = widget.newState;
|
|
13072
|
+
for (const command of commands) {
|
|
13073
|
+
if (commandsToForward$3.includes(command[0])) {
|
|
13074
|
+
wrappedCommands.push(command);
|
|
13075
|
+
} else {
|
|
13076
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
13077
|
+
}
|
|
13078
|
+
}
|
|
13079
|
+
return wrappedCommands;
|
|
13080
|
+
};
|
|
13081
|
+
const add$6 = widget => {
|
|
13082
|
+
return addWidget(widget, 'EditorRename', render$9);
|
|
13083
|
+
};
|
|
13084
|
+
const remove$5 = widget => {
|
|
12975
13085
|
return [];
|
|
12976
13086
|
};
|
|
12977
13087
|
const {
|
|
@@ -13218,6 +13328,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
|
|
|
13218
13328
|
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
13219
13329
|
const newEditor = {
|
|
13220
13330
|
...editor,
|
|
13331
|
+
additionalFocus: unsetAdditionalFocus$1 ? 0 : editor.additionalFocus,
|
|
13221
13332
|
decorations: widgetId === Rename$1 ? editor.decorations.slice(0, -4) : editor.decorations,
|
|
13222
13333
|
focused: true,
|
|
13223
13334
|
widgetRevision,
|
|
@@ -13663,7 +13774,7 @@ const getKeyBindings = () => {
|
|
|
13663
13774
|
}];
|
|
13664
13775
|
};
|
|
13665
13776
|
|
|
13666
|
-
const getKeys
|
|
13777
|
+
const getKeys = () => {
|
|
13667
13778
|
return getKeys$2();
|
|
13668
13779
|
};
|
|
13669
13780
|
|
|
@@ -14725,268 +14836,6 @@ const renderFocusContext$1 = (oldState, newState) => {
|
|
|
14725
14836
|
return [SetFocusContext$1, newState.uid, newState.focus];
|
|
14726
14837
|
};
|
|
14727
14838
|
|
|
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
14839
|
const True = 'true';
|
|
14991
14840
|
|
|
14992
14841
|
const Button = 'button';
|
|
@@ -14994,11 +14843,7 @@ const Code = 'code';
|
|
|
14994
14843
|
const TextBox = 'textbox';
|
|
14995
14844
|
|
|
14996
14845
|
const getPathname = uri => {
|
|
14997
|
-
|
|
14998
|
-
return decodeURIComponent(new URL(uri).pathname);
|
|
14999
|
-
} catch {
|
|
15000
|
-
return decodeURIComponent(uri);
|
|
15001
|
-
}
|
|
14846
|
+
return decodeURIComponent(URL.canParse(uri) ? new URL(uri).pathname : uri);
|
|
15002
14847
|
};
|
|
15003
14848
|
const getFileBreadcrumbs = (uri, workspaceUri) => {
|
|
15004
14849
|
const path = getPathname(uri);
|
|
@@ -16412,7 +16257,7 @@ const commandMap = {
|
|
|
16412
16257
|
'Editor.getCommandIds': getCommandIds,
|
|
16413
16258
|
'Editor.getDiagnostics': getDiagnostics$1,
|
|
16414
16259
|
'Editor.getKeyBindings': getKeyBindings,
|
|
16415
|
-
'Editor.getKeys': getKeys
|
|
16260
|
+
'Editor.getKeys': getKeys,
|
|
16416
16261
|
'Editor.getLanguageId': getLanguageId,
|
|
16417
16262
|
'Editor.getLines2': getLines2,
|
|
16418
16263
|
'Editor.getMenuEntries': getMenuEntries,
|