@lvce-editor/editor-worker 19.55.2 → 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.
- package/dist/editorWorkerMain.js +424 -565
- 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];
|
|
@@ -5750,10 +5600,14 @@ const diff = (oldState, newState) => {
|
|
|
5750
5600
|
};
|
|
5751
5601
|
|
|
5752
5602
|
const diff2 = uid => {
|
|
5603
|
+
const editor = get$8(uid);
|
|
5604
|
+
if (!editor) {
|
|
5605
|
+
return [];
|
|
5606
|
+
}
|
|
5753
5607
|
const {
|
|
5754
5608
|
newState,
|
|
5755
5609
|
oldState
|
|
5756
|
-
} =
|
|
5610
|
+
} = editor;
|
|
5757
5611
|
const result = diff(oldState, newState);
|
|
5758
5612
|
return result;
|
|
5759
5613
|
};
|
|
@@ -12818,7 +12672,6 @@ const Button$1 = 1;
|
|
|
12818
12672
|
const Div = 4;
|
|
12819
12673
|
const Input = 6;
|
|
12820
12674
|
const Span = 8;
|
|
12821
|
-
const Text = 12;
|
|
12822
12675
|
const Nav = 40;
|
|
12823
12676
|
const TextArea = 62;
|
|
12824
12677
|
|
|
@@ -12830,141 +12683,401 @@ const text = data => {
|
|
|
12830
12683
|
};
|
|
12831
12684
|
};
|
|
12832
12685
|
|
|
12833
|
-
const
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
childCount: 1,
|
|
12844
|
-
className: tokenClass,
|
|
12845
|
-
type: Span
|
|
12846
|
-
}, text(tokenText));
|
|
12847
|
-
}
|
|
12848
|
-
return dom;
|
|
12849
|
-
};
|
|
12850
|
-
const getLineInfosVirtualDom = lineInfos => {
|
|
12851
|
-
const dom = lineInfos.flatMap(getLineInfoVirtualDom);
|
|
12852
|
-
return dom;
|
|
12853
|
-
};
|
|
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;
|
|
12854
12696
|
|
|
12855
|
-
const
|
|
12856
|
-
return
|
|
12697
|
+
const isKey = key => {
|
|
12698
|
+
return key !== 'type' && key !== 'childCount';
|
|
12857
12699
|
};
|
|
12858
12700
|
|
|
12859
|
-
const
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
type: Span
|
|
12863
|
-
};
|
|
12864
|
-
const hoverProblemDetail = {
|
|
12865
|
-
childCount: 1,
|
|
12866
|
-
className: HoverProblemDetail,
|
|
12867
|
-
type: Span
|
|
12868
|
-
};
|
|
12869
|
-
const hoverDocumentationNode = {
|
|
12870
|
-
childCount: 1,
|
|
12871
|
-
className: HoverDocumentation,
|
|
12872
|
-
type: Div
|
|
12873
|
-
};
|
|
12874
|
-
const hoverSashNode = {
|
|
12875
|
-
childCount: 0,
|
|
12876
|
-
className: mergeClassNames('Sash', 'SashVertical', 'SashResize'),
|
|
12877
|
-
onPointerDown: HandleSashPointerDown,
|
|
12878
|
-
type: Div
|
|
12701
|
+
const getKeys$1 = node => {
|
|
12702
|
+
const keys = Object.keys(node).filter(isKey);
|
|
12703
|
+
return keys;
|
|
12879
12704
|
};
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
const
|
|
12883
|
-
|
|
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;
|
|
12884
12722
|
};
|
|
12885
|
-
const
|
|
12886
|
-
|
|
12887
|
-
|
|
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
|
+
};
|
|
12888
12754
|
};
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
}
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12900
|
-
type:
|
|
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
|
|
12901
12768
|
});
|
|
12902
|
-
|
|
12903
|
-
|
|
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
|
+
});
|
|
12904
12777
|
}
|
|
12778
|
+
return patches;
|
|
12905
12779
|
}
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
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
|
+
}
|
|
12913
12792
|
}
|
|
12914
|
-
|
|
12915
|
-
|
|
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
|
+
}
|
|
12916
12801
|
}
|
|
12917
|
-
|
|
12918
|
-
return dom;
|
|
12802
|
+
return patches;
|
|
12919
12803
|
};
|
|
12920
12804
|
|
|
12921
|
-
const
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
|
|
12929
|
-
apply(oldState, newState) {
|
|
12930
|
-
const {
|
|
12931
|
-
height,
|
|
12932
|
-
width,
|
|
12933
|
-
x,
|
|
12934
|
-
y
|
|
12935
|
-
} = newState;
|
|
12936
|
-
return [SetBounds, x, y, width, height];
|
|
12937
|
-
},
|
|
12938
|
-
isEqual: (oldState, newState) => oldState.x === newState.x && oldState.y === newState.y
|
|
12939
|
-
};
|
|
12940
|
-
const render$a = [renderHoverDom, renderBounds$2];
|
|
12941
|
-
const renderHover = (oldState, newState) => {
|
|
12942
|
-
const commands = [];
|
|
12943
|
-
for (const item of render$a) {
|
|
12944
|
-
if (!item.isEqual(oldState, newState)) {
|
|
12945
|
-
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]);
|
|
12946
12813
|
}
|
|
12947
12814
|
}
|
|
12948
|
-
return
|
|
12815
|
+
return result;
|
|
12949
12816
|
};
|
|
12950
12817
|
|
|
12951
|
-
const
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
for (const command of commands) {
|
|
12959
|
-
if (commandsToForward$3.includes(command[0])) {
|
|
12960
|
-
wrappedCommands.push(command);
|
|
12961
|
-
} else {
|
|
12962
|
-
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
12963
|
-
}
|
|
12818
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
12819
|
+
if (currentChildIndex === -1) {
|
|
12820
|
+
patches.push({
|
|
12821
|
+
type: NavigateChild,
|
|
12822
|
+
index
|
|
12823
|
+
});
|
|
12824
|
+
return index;
|
|
12964
12825
|
}
|
|
12965
|
-
|
|
12826
|
+
if (currentChildIndex !== index) {
|
|
12827
|
+
patches.push({
|
|
12828
|
+
type: NavigateSibling,
|
|
12829
|
+
index
|
|
12830
|
+
});
|
|
12831
|
+
}
|
|
12832
|
+
return index;
|
|
12966
12833
|
};
|
|
12967
|
-
const
|
|
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 => {
|
|
12968
13081
|
return addWidget(widget, 'EditorRename', render$9);
|
|
12969
13082
|
};
|
|
12970
13083
|
const remove$5 = widget => {
|
|
@@ -13214,6 +13327,7 @@ const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocu
|
|
|
13214
13327
|
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
13215
13328
|
const newEditor = {
|
|
13216
13329
|
...editor,
|
|
13330
|
+
additionalFocus: unsetAdditionalFocus$1 ? 0 : editor.additionalFocus,
|
|
13217
13331
|
decorations: widgetId === Rename$1 ? editor.decorations.slice(0, -4) : editor.decorations,
|
|
13218
13332
|
focused: true,
|
|
13219
13333
|
widgetRevision,
|
|
@@ -13659,7 +13773,7 @@ const getKeyBindings = () => {
|
|
|
13659
13773
|
}];
|
|
13660
13774
|
};
|
|
13661
13775
|
|
|
13662
|
-
const getKeys
|
|
13776
|
+
const getKeys = () => {
|
|
13663
13777
|
return getKeys$2();
|
|
13664
13778
|
};
|
|
13665
13779
|
|
|
@@ -14721,280 +14835,14 @@ const renderFocusContext$1 = (oldState, newState) => {
|
|
|
14721
14835
|
return [SetFocusContext$1, newState.uid, newState.focus];
|
|
14722
14836
|
};
|
|
14723
14837
|
|
|
14724
|
-
|
|
14725
|
-
|
|
14726
|
-
const SetText = 1;
|
|
14727
|
-
const Replace = 2;
|
|
14728
|
-
const SetAttribute = 3;
|
|
14729
|
-
const RemoveAttribute = 4;
|
|
14730
|
-
const Add = 6;
|
|
14731
|
-
const NavigateChild = 7;
|
|
14732
|
-
const NavigateParent = 8;
|
|
14733
|
-
const RemoveChild = 9;
|
|
14734
|
-
const NavigateSibling = 10;
|
|
14735
|
-
const SetReferenceNodeUid = 11;
|
|
14736
|
-
|
|
14737
|
-
const isKey = key => {
|
|
14738
|
-
return key !== 'type' && key !== 'childCount';
|
|
14739
|
-
};
|
|
14740
|
-
|
|
14741
|
-
const getKeys = node => {
|
|
14742
|
-
const keys = Object.keys(node).filter(isKey);
|
|
14743
|
-
return keys;
|
|
14744
|
-
};
|
|
14745
|
-
|
|
14746
|
-
const arrayToTree = nodes => {
|
|
14747
|
-
const result = [];
|
|
14748
|
-
let i = 0;
|
|
14749
|
-
while (i < nodes.length) {
|
|
14750
|
-
const node = nodes[i];
|
|
14751
|
-
const {
|
|
14752
|
-
children,
|
|
14753
|
-
nodesConsumed
|
|
14754
|
-
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
14755
|
-
result.push({
|
|
14756
|
-
node,
|
|
14757
|
-
children
|
|
14758
|
-
});
|
|
14759
|
-
i += 1 + nodesConsumed;
|
|
14760
|
-
}
|
|
14761
|
-
return result;
|
|
14762
|
-
};
|
|
14763
|
-
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
14764
|
-
if (childCount === 0) {
|
|
14765
|
-
return {
|
|
14766
|
-
children: [],
|
|
14767
|
-
nodesConsumed: 0
|
|
14768
|
-
};
|
|
14769
|
-
}
|
|
14770
|
-
const children = [];
|
|
14771
|
-
let i = startIndex;
|
|
14772
|
-
let remaining = childCount;
|
|
14773
|
-
let totalConsumed = 0;
|
|
14774
|
-
while (remaining > 0 && i < nodes.length) {
|
|
14775
|
-
const node = nodes[i];
|
|
14776
|
-
const nodeChildCount = node.childCount || 0;
|
|
14777
|
-
const {
|
|
14778
|
-
children: nodeChildren,
|
|
14779
|
-
nodesConsumed
|
|
14780
|
-
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
14781
|
-
children.push({
|
|
14782
|
-
node,
|
|
14783
|
-
children: nodeChildren
|
|
14784
|
-
});
|
|
14785
|
-
const nodeSize = 1 + nodesConsumed;
|
|
14786
|
-
i += nodeSize;
|
|
14787
|
-
totalConsumed += nodeSize;
|
|
14788
|
-
remaining--;
|
|
14789
|
-
}
|
|
14790
|
-
return {
|
|
14791
|
-
children,
|
|
14792
|
-
nodesConsumed: totalConsumed
|
|
14793
|
-
};
|
|
14794
|
-
};
|
|
14795
|
-
|
|
14796
|
-
const compareNodes = (oldNode, newNode) => {
|
|
14797
|
-
// Check if node type changed - return null to signal incompatible nodes
|
|
14798
|
-
// (caller should handle this with a Replace operation)
|
|
14799
|
-
if (oldNode.type !== newNode.type) {
|
|
14800
|
-
return null;
|
|
14801
|
-
}
|
|
14802
|
-
const patches = [];
|
|
14803
|
-
// Handle reference nodes - special handling for uid changes
|
|
14804
|
-
if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
|
|
14805
|
-
patches.push({
|
|
14806
|
-
type: SetReferenceNodeUid,
|
|
14807
|
-
uid: newNode.uid
|
|
14808
|
-
});
|
|
14809
|
-
}
|
|
14810
|
-
// Handle text nodes
|
|
14811
|
-
if (oldNode.type === Text$1 && newNode.type === Text$1) {
|
|
14812
|
-
if (oldNode.text !== newNode.text) {
|
|
14813
|
-
patches.push({
|
|
14814
|
-
type: SetText,
|
|
14815
|
-
value: newNode.text
|
|
14816
|
-
});
|
|
14817
|
-
}
|
|
14818
|
-
return patches;
|
|
14819
|
-
}
|
|
14820
|
-
// Compare attributes
|
|
14821
|
-
const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
|
|
14822
|
-
const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
|
|
14823
|
-
// Check for attribute changes
|
|
14824
|
-
for (const key of newKeys) {
|
|
14825
|
-
if (oldNode[key] !== newNode[key]) {
|
|
14826
|
-
patches.push({
|
|
14827
|
-
type: SetAttribute,
|
|
14828
|
-
key,
|
|
14829
|
-
value: newNode[key]
|
|
14830
|
-
});
|
|
14831
|
-
}
|
|
14832
|
-
}
|
|
14833
|
-
// Check for removed attributes
|
|
14834
|
-
for (const key of oldKeys) {
|
|
14835
|
-
if (!Object.hasOwn(newNode, key)) {
|
|
14836
|
-
patches.push({
|
|
14837
|
-
type: RemoveAttribute,
|
|
14838
|
-
key
|
|
14839
|
-
});
|
|
14840
|
-
}
|
|
14841
|
-
}
|
|
14842
|
-
return patches;
|
|
14843
|
-
};
|
|
14844
|
-
|
|
14845
|
-
const treeToArray = node => {
|
|
14846
|
-
const result = [];
|
|
14847
|
-
const stack = [node];
|
|
14848
|
-
while (stack.length > 0) {
|
|
14849
|
-
const current = stack.pop();
|
|
14850
|
-
result.push(current.node);
|
|
14851
|
-
for (let i = current.children.length - 1; i >= 0; i--) {
|
|
14852
|
-
stack.push(current.children[i]);
|
|
14853
|
-
}
|
|
14854
|
-
}
|
|
14855
|
-
return result;
|
|
14856
|
-
};
|
|
14857
|
-
|
|
14858
|
-
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
14859
|
-
if (currentChildIndex === -1) {
|
|
14860
|
-
patches.push({
|
|
14861
|
-
type: NavigateChild,
|
|
14862
|
-
index
|
|
14863
|
-
});
|
|
14864
|
-
return index;
|
|
14865
|
-
}
|
|
14866
|
-
if (currentChildIndex !== index) {
|
|
14867
|
-
patches.push({
|
|
14868
|
-
type: NavigateSibling,
|
|
14869
|
-
index
|
|
14870
|
-
});
|
|
14871
|
-
}
|
|
14872
|
-
return index;
|
|
14873
|
-
};
|
|
14874
|
-
const navigateToParent = (patches, currentChildIndex) => {
|
|
14875
|
-
if (currentChildIndex >= 0) {
|
|
14876
|
-
patches.push({
|
|
14877
|
-
type: NavigateParent
|
|
14878
|
-
});
|
|
14879
|
-
}
|
|
14880
|
-
return -1;
|
|
14881
|
-
};
|
|
14882
|
-
const addTree = (newNode, patches) => {
|
|
14883
|
-
patches.push({
|
|
14884
|
-
type: Add,
|
|
14885
|
-
nodes: treeToArray(newNode)
|
|
14886
|
-
});
|
|
14887
|
-
};
|
|
14888
|
-
const replaceTree = (newNode, patches) => {
|
|
14889
|
-
patches.push({
|
|
14890
|
-
type: Replace,
|
|
14891
|
-
nodes: treeToArray(newNode)
|
|
14892
|
-
});
|
|
14893
|
-
};
|
|
14894
|
-
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
14895
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
14896
|
-
if (nodePatches === null) {
|
|
14897
|
-
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
14898
|
-
replaceTree(newNode, patches);
|
|
14899
|
-
return nextChildIndex;
|
|
14900
|
-
}
|
|
14901
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
14902
|
-
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
14903
|
-
return currentChildIndex;
|
|
14904
|
-
}
|
|
14905
|
-
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
14906
|
-
if (nodePatches.length > 0) {
|
|
14907
|
-
patches.push(...nodePatches);
|
|
14908
|
-
}
|
|
14909
|
-
if (hasChildrenToCompare) {
|
|
14910
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
14911
|
-
}
|
|
14912
|
-
return nextChildIndex;
|
|
14913
|
-
};
|
|
14914
|
-
const diffRootNode = (oldNode, newNode, patches) => {
|
|
14915
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
14916
|
-
if (nodePatches === null) {
|
|
14917
|
-
replaceTree(newNode, patches);
|
|
14918
|
-
return;
|
|
14919
|
-
}
|
|
14920
|
-
if (nodePatches.length > 0) {
|
|
14921
|
-
patches.push(...nodePatches);
|
|
14922
|
-
}
|
|
14923
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
14924
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
14925
|
-
}
|
|
14926
|
-
};
|
|
14927
|
-
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
14928
|
-
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
14929
|
-
let currentChildIndex = -1;
|
|
14930
|
-
const indicesToRemove = [];
|
|
14931
|
-
for (let i = 0; i < maxLength; i++) {
|
|
14932
|
-
const oldNode = oldChildren[i];
|
|
14933
|
-
const newNode = newChildren[i];
|
|
14934
|
-
if (!oldNode && !newNode) {
|
|
14935
|
-
continue;
|
|
14936
|
-
}
|
|
14937
|
-
if (!oldNode) {
|
|
14938
|
-
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
14939
|
-
addTree(newNode, patches);
|
|
14940
|
-
continue;
|
|
14941
|
-
}
|
|
14942
|
-
if (!newNode) {
|
|
14943
|
-
indicesToRemove.push(i);
|
|
14944
|
-
continue;
|
|
14945
|
-
}
|
|
14946
|
-
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
14947
|
-
}
|
|
14948
|
-
navigateToParent(patches, currentChildIndex);
|
|
14949
|
-
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
14950
|
-
patches.push({
|
|
14951
|
-
type: RemoveChild,
|
|
14952
|
-
index: indicesToRemove[j]
|
|
14953
|
-
});
|
|
14954
|
-
}
|
|
14955
|
-
};
|
|
14956
|
-
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
14957
|
-
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
14958
|
-
diffRootNode(oldTree[0], newTree[0], patches);
|
|
14959
|
-
return;
|
|
14960
|
-
}
|
|
14961
|
-
diffChildren(oldTree, newTree, patches);
|
|
14962
|
-
};
|
|
14963
|
-
|
|
14964
|
-
const removeTrailingNavigationPatches = patches => {
|
|
14965
|
-
while (patches.length > 0) {
|
|
14966
|
-
const patch = patches.at(-1);
|
|
14967
|
-
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
14968
|
-
break;
|
|
14969
|
-
}
|
|
14970
|
-
patches.pop();
|
|
14971
|
-
}
|
|
14972
|
-
return patches;
|
|
14973
|
-
};
|
|
14974
|
-
|
|
14975
|
-
const diffTree = (oldNodes, newNodes) => {
|
|
14976
|
-
// Step 1: Convert flat arrays to tree structures
|
|
14977
|
-
const oldTree = arrayToTree(oldNodes);
|
|
14978
|
-
const newTree = arrayToTree(newNodes);
|
|
14979
|
-
// Step 3: Compare the trees
|
|
14980
|
-
const patches = [];
|
|
14981
|
-
diffTrees(oldTree, newTree, patches, []);
|
|
14982
|
-
// Remove trailing navigation patches since they serve no purpose
|
|
14983
|
-
return removeTrailingNavigationPatches(patches);
|
|
14984
|
-
};
|
|
14985
|
-
|
|
14986
|
-
const True = 'true';
|
|
14838
|
+
const True = 'true';
|
|
14987
14839
|
|
|
14988
14840
|
const Button = 'button';
|
|
14989
14841
|
const Code = 'code';
|
|
14990
14842
|
const TextBox = 'textbox';
|
|
14991
14843
|
|
|
14992
14844
|
const getPathname = uri => {
|
|
14993
|
-
|
|
14994
|
-
return decodeURIComponent(new URL(uri).pathname);
|
|
14995
|
-
} catch {
|
|
14996
|
-
return decodeURIComponent(uri);
|
|
14997
|
-
}
|
|
14845
|
+
return decodeURIComponent(URL.canParse(uri) ? new URL(uri).pathname : uri);
|
|
14998
14846
|
};
|
|
14999
14847
|
const getFileBreadcrumbs = (uri, workspaceUri) => {
|
|
15000
14848
|
const path = getPathname(uri);
|
|
@@ -15769,10 +15617,14 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
15769
15617
|
};
|
|
15770
15618
|
|
|
15771
15619
|
const render2 = (uid, diffResult) => {
|
|
15620
|
+
const editor = get$8(uid);
|
|
15621
|
+
if (!editor) {
|
|
15622
|
+
return [];
|
|
15623
|
+
}
|
|
15772
15624
|
const {
|
|
15773
15625
|
newState,
|
|
15774
15626
|
oldState
|
|
15775
|
-
} =
|
|
15627
|
+
} = editor;
|
|
15776
15628
|
set$8(uid, newState, newState);
|
|
15777
15629
|
const commands = applyRender(oldState, newState, diffResult);
|
|
15778
15630
|
return commands;
|
|
@@ -16150,17 +16002,22 @@ const updateDiagnostics = async editor => {
|
|
|
16150
16002
|
try {
|
|
16151
16003
|
const diagnostics = await getDiagnostics(editor);
|
|
16152
16004
|
const latest = get$8(editor.id);
|
|
16153
|
-
if (!latest) {
|
|
16005
|
+
if (!latest || !latest.newState.diagnosticsEnabled || latest.newState.lines !== editor.lines || latest.newState.uri !== editor.uri) {
|
|
16154
16006
|
return editor;
|
|
16155
16007
|
}
|
|
16156
16008
|
const newEditor = await addDiagnostics(latest.newState, diagnostics);
|
|
16157
16009
|
set$8(editor.id, latest.oldState, newEditor);
|
|
16010
|
+
await invoke$7('Editor.renderPending', newEditor.id);
|
|
16158
16011
|
await notifyDiagnosticsChange(newEditor.uri);
|
|
16159
16012
|
return newEditor;
|
|
16160
16013
|
} catch (error) {
|
|
16161
16014
|
return handleError(error, editor);
|
|
16162
16015
|
}
|
|
16163
16016
|
};
|
|
16017
|
+
const requestDiagnostics = editor => {
|
|
16018
|
+
void updateDiagnostics(editor);
|
|
16019
|
+
return editor;
|
|
16020
|
+
};
|
|
16164
16021
|
const updateDiagnosticsAll = async () => {
|
|
16165
16022
|
for (const key of getKeys$2()) {
|
|
16166
16023
|
const editor = get$8(Number(key))?.newState;
|
|
@@ -16224,6 +16081,9 @@ const saveAfterDelay = async (uid, token) => {
|
|
|
16224
16081
|
|
|
16225
16082
|
const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...args) => {
|
|
16226
16083
|
const initialInstance = get$8(uid);
|
|
16084
|
+
if (!initialInstance) {
|
|
16085
|
+
return undefined;
|
|
16086
|
+
}
|
|
16227
16087
|
const queueKey = initialInstance?.newState.uri || uid;
|
|
16228
16088
|
const previous = queues[queueKey];
|
|
16229
16089
|
const {
|
|
@@ -16236,6 +16096,9 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
|
|
|
16236
16096
|
}
|
|
16237
16097
|
try {
|
|
16238
16098
|
const oldInstance = get$8(uid);
|
|
16099
|
+
if (!oldInstance) {
|
|
16100
|
+
return undefined;
|
|
16101
|
+
}
|
|
16239
16102
|
const state = oldInstance.newState;
|
|
16240
16103
|
const {
|
|
16241
16104
|
cursorUndoStack,
|
|
@@ -16272,14 +16135,10 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
|
|
|
16272
16135
|
}
|
|
16273
16136
|
const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
|
|
16274
16137
|
set$8(uid, state, newEditorWithDerivedState);
|
|
16275
|
-
let finalEditor = newEditorWithDerivedState;
|
|
16276
16138
|
if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
|
|
16277
|
-
|
|
16278
|
-
if (!get$8(uid)) {
|
|
16279
|
-
return finalEditor;
|
|
16280
|
-
}
|
|
16281
|
-
set$8(uid, state, finalEditor);
|
|
16139
|
+
void editorDiagnosticEffect.apply(newEditorWithDerivedState);
|
|
16282
16140
|
}
|
|
16141
|
+
const finalEditor = newEditorWithDerivedState;
|
|
16283
16142
|
await notifyEditorStatusChange(state, finalEditor);
|
|
16284
16143
|
if (!initial && uri === finalEditor.uri && (endOfLine !== finalEditor.endOfLine || insertSpaces !== finalEditor.insertSpaces || lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
16285
16144
|
for (const key of getKeys$2()) {
|
|
@@ -16397,7 +16256,7 @@ const commandMap = {
|
|
|
16397
16256
|
'Editor.getCommandIds': getCommandIds,
|
|
16398
16257
|
'Editor.getDiagnostics': getDiagnostics$1,
|
|
16399
16258
|
'Editor.getKeyBindings': getKeyBindings,
|
|
16400
|
-
'Editor.getKeys': getKeys
|
|
16259
|
+
'Editor.getKeys': getKeys,
|
|
16401
16260
|
'Editor.getLanguageId': getLanguageId,
|
|
16402
16261
|
'Editor.getLines2': getLines2,
|
|
16403
16262
|
'Editor.getMenuEntries': getMenuEntries,
|
|
@@ -16543,7 +16402,7 @@ const commandMap = {
|
|
|
16543
16402
|
'Editor.unIndent': wrapCommand(editorUnindent),
|
|
16544
16403
|
'Editor.updateColorPickerValue': wrapCommand(updateColorPickerValue$1),
|
|
16545
16404
|
'Editor.updateDebugInfo': updateDebugInfo,
|
|
16546
|
-
'Editor.updateDiagnostics': wrapCommand(
|
|
16405
|
+
'Editor.updateDiagnostics': wrapCommand(requestDiagnostics),
|
|
16547
16406
|
'Editor.updateDiagnosticsAll': updateDiagnosticsAll,
|
|
16548
16407
|
'EditorCompletion.close': close$3,
|
|
16549
16408
|
'EditorCompletion.closeDetails': closeDetails$1,
|