@lvce-editor/extension-host-worker 8.24.0 → 8.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension-api/index.js +560 -9
- package/dist/extension-api/parts/CommandRegistry/CommandRegistry.js +3 -1
- package/dist/extension-api/parts/CompletionProviderRegistry/CompletionProviderRegistry.js +29 -2
- package/dist/extension-api/parts/DiagnosticProviderRegistry/DiagnosticProviderRegistry.js +4 -1
- package/dist/extension-api/parts/ExtensionApiCommandMap/ExtensionApiCommandMap.js +13 -2
- package/dist/extension-api/parts/FormattingProviderRegistry/FormattingProviderRegistry.js +4 -1
- package/dist/extension-api/parts/HoverProviderRegistry/HoverProviderRegistry.js +4 -1
- package/dist/extension-api/parts/StatusBarItemProviderRegistry/StatusBarItemProviderRegistry.js +3 -1
- package/dist/extension-api/parts/ViewRegistry/ViewRegistry.js +95 -2
- package/extension-api/dist/index.d.ts +2 -2
- package/extension-api/dist/index.js +1 -1
- package/extension-api/dist/parts/CommandMap/CommandMap.d.ts +4 -0
- package/extension-api/dist/parts/CommandRegistry/CommandRegistry.js +3 -1
- package/extension-api/dist/parts/CommandRegistrySnapshot/CommandRegistrySnapshot.d.ts +3 -2
- package/extension-api/dist/parts/CompletionProviderRegistry/CompletionProviderRegistry.js +30 -2
- package/extension-api/dist/parts/CompletionProviderRegistrySnapshot/CompletionProviderRegistrySnapshot.d.ts +4 -2
- package/extension-api/dist/parts/DiagnosticProviderRegistry/DiagnosticProviderRegistry.js +4 -1
- package/extension-api/dist/parts/DiagnosticProviderRegistrySnapshot/DiagnosticProviderRegistrySnapshot.d.ts +4 -2
- package/extension-api/dist/parts/ExtensionApiCommandMap/ExtensionApiCommandMap.d.ts +4 -0
- package/extension-api/dist/parts/ExtensionApiCommandMap/ExtensionApiCommandMap.js +5 -1
- package/extension-api/dist/parts/ExtensionApiWorkerCommandMap/ExtensionApiWorkerCommandMap.d.ts +4 -0
- package/extension-api/dist/parts/FormattingProviderRegistry/FormattingProviderRegistry.js +4 -1
- package/extension-api/dist/parts/FormattingProviderRegistrySnapshot/FormattingProviderRegistrySnapshot.d.ts +4 -2
- package/extension-api/dist/parts/HoverProviderRegistry/HoverProviderRegistry.js +4 -1
- package/extension-api/dist/parts/HoverProviderRegistrySnapshot/HoverProviderRegistrySnapshot.d.ts +4 -2
- package/extension-api/dist/parts/StatusBarItemProviderRegistry/StatusBarItemProviderRegistry.js +3 -1
- package/extension-api/dist/parts/StatusBarItemProviderRegistrySnapshot/StatusBarItemProviderRegistrySnapshot.d.ts +3 -2
- package/extension-api/dist/parts/View/View.d.ts +30 -1
- package/extension-api/dist/parts/ViewRegistry/ViewRegistry.d.ts +5 -1
- package/extension-api/dist/parts/ViewRegistry/ViewRegistry.js +90 -1
- package/extension-api/package.json +3 -2
- package/extension-api/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -997,6 +997,175 @@ var create7 = (rpcId) => {
|
|
|
997
997
|
};
|
|
998
998
|
};
|
|
999
999
|
|
|
1000
|
+
// packages/extension-api/node_modules/@lvce-editor/constants/dist/parts/VirtualDomElements/VirtualDomElements.js
|
|
1001
|
+
var VirtualDomElements_exports = {};
|
|
1002
|
+
__export(VirtualDomElements_exports, {
|
|
1003
|
+
A: () => A,
|
|
1004
|
+
Abbr: () => Abbr,
|
|
1005
|
+
Article: () => Article,
|
|
1006
|
+
Aside: () => Aside,
|
|
1007
|
+
Audio: () => Audio,
|
|
1008
|
+
BlockQuote: () => BlockQuote,
|
|
1009
|
+
Br: () => Br,
|
|
1010
|
+
Button: () => Button,
|
|
1011
|
+
Canvas: () => Canvas,
|
|
1012
|
+
Circle: () => Circle,
|
|
1013
|
+
Cite: () => Cite,
|
|
1014
|
+
Code: () => Code,
|
|
1015
|
+
Col: () => Col,
|
|
1016
|
+
ColGroup: () => ColGroup,
|
|
1017
|
+
Data: () => Data,
|
|
1018
|
+
Dd: () => Dd,
|
|
1019
|
+
Defs: () => Defs,
|
|
1020
|
+
Del: () => Del,
|
|
1021
|
+
Div: () => Div,
|
|
1022
|
+
Dl: () => Dl,
|
|
1023
|
+
Dt: () => Dt,
|
|
1024
|
+
Ellipse: () => Ellipse,
|
|
1025
|
+
Em: () => Em,
|
|
1026
|
+
Figcaption: () => Figcaption,
|
|
1027
|
+
Figure: () => Figure,
|
|
1028
|
+
Footer: () => Footer,
|
|
1029
|
+
Form: () => Form,
|
|
1030
|
+
G: () => G,
|
|
1031
|
+
H1: () => H1,
|
|
1032
|
+
H2: () => H2,
|
|
1033
|
+
H3: () => H3,
|
|
1034
|
+
H4: () => H4,
|
|
1035
|
+
H5: () => H5,
|
|
1036
|
+
H6: () => H6,
|
|
1037
|
+
Head: () => Head,
|
|
1038
|
+
Header: () => Header,
|
|
1039
|
+
Hr: () => Hr,
|
|
1040
|
+
Html: () => Html,
|
|
1041
|
+
I: () => I,
|
|
1042
|
+
Iframe: () => Iframe,
|
|
1043
|
+
Img: () => Img,
|
|
1044
|
+
Input: () => Input,
|
|
1045
|
+
Ins: () => Ins,
|
|
1046
|
+
Kbd: () => Kbd,
|
|
1047
|
+
Label: () => Label,
|
|
1048
|
+
Li: () => Li,
|
|
1049
|
+
Line: () => Line,
|
|
1050
|
+
Main: () => Main,
|
|
1051
|
+
Meta: () => Meta,
|
|
1052
|
+
Nav: () => Nav,
|
|
1053
|
+
Ol: () => Ol,
|
|
1054
|
+
Option: () => Option,
|
|
1055
|
+
P: () => P,
|
|
1056
|
+
Path: () => Path,
|
|
1057
|
+
Polygon: () => Polygon,
|
|
1058
|
+
Polyline: () => Polyline,
|
|
1059
|
+
Pre: () => Pre,
|
|
1060
|
+
Quote: () => Quote,
|
|
1061
|
+
Rect: () => Rect,
|
|
1062
|
+
Reference: () => Reference,
|
|
1063
|
+
Root: () => Root,
|
|
1064
|
+
Search: () => Search,
|
|
1065
|
+
Section: () => Section,
|
|
1066
|
+
Select: () => Select,
|
|
1067
|
+
Span: () => Span,
|
|
1068
|
+
Strong: () => Strong,
|
|
1069
|
+
Style: () => Style,
|
|
1070
|
+
Svg: () => Svg,
|
|
1071
|
+
TBody: () => TBody,
|
|
1072
|
+
THead: () => THead,
|
|
1073
|
+
Table: () => Table,
|
|
1074
|
+
Td: () => Td,
|
|
1075
|
+
Text: () => Text,
|
|
1076
|
+
TextArea: () => TextArea,
|
|
1077
|
+
Tfoot: () => Tfoot,
|
|
1078
|
+
Th: () => Th,
|
|
1079
|
+
Time: () => Time,
|
|
1080
|
+
Title: () => Title,
|
|
1081
|
+
Tr: () => Tr,
|
|
1082
|
+
Ul: () => Ul,
|
|
1083
|
+
Use: () => Use,
|
|
1084
|
+
Video: () => Video
|
|
1085
|
+
});
|
|
1086
|
+
var Audio = 0;
|
|
1087
|
+
var Button = 1;
|
|
1088
|
+
var Col = 2;
|
|
1089
|
+
var ColGroup = 3;
|
|
1090
|
+
var Div = 4;
|
|
1091
|
+
var H1 = 5;
|
|
1092
|
+
var Input = 6;
|
|
1093
|
+
var Kbd = 7;
|
|
1094
|
+
var Span = 8;
|
|
1095
|
+
var Table = 9;
|
|
1096
|
+
var TBody = 10;
|
|
1097
|
+
var Td = 11;
|
|
1098
|
+
var Text = 12;
|
|
1099
|
+
var Th = 13;
|
|
1100
|
+
var THead = 14;
|
|
1101
|
+
var Tr = 15;
|
|
1102
|
+
var I = 16;
|
|
1103
|
+
var Img = 17;
|
|
1104
|
+
var Root = 0;
|
|
1105
|
+
var Ins = 20;
|
|
1106
|
+
var Del = 21;
|
|
1107
|
+
var H2 = 22;
|
|
1108
|
+
var H3 = 23;
|
|
1109
|
+
var H4 = 24;
|
|
1110
|
+
var H5 = 25;
|
|
1111
|
+
var H6 = 26;
|
|
1112
|
+
var Article = 27;
|
|
1113
|
+
var Aside = 28;
|
|
1114
|
+
var Footer = 29;
|
|
1115
|
+
var Header = 30;
|
|
1116
|
+
var Nav = 40;
|
|
1117
|
+
var Section = 41;
|
|
1118
|
+
var Search = 42;
|
|
1119
|
+
var Dd = 43;
|
|
1120
|
+
var Dl = 44;
|
|
1121
|
+
var Figcaption = 45;
|
|
1122
|
+
var Figure = 46;
|
|
1123
|
+
var Hr = 47;
|
|
1124
|
+
var Li = 48;
|
|
1125
|
+
var Ol = 49;
|
|
1126
|
+
var P = 50;
|
|
1127
|
+
var Pre = 51;
|
|
1128
|
+
var A = 53;
|
|
1129
|
+
var Abbr = 54;
|
|
1130
|
+
var Br = 55;
|
|
1131
|
+
var Cite = 56;
|
|
1132
|
+
var Data = 57;
|
|
1133
|
+
var Time = 58;
|
|
1134
|
+
var Tfoot = 59;
|
|
1135
|
+
var Ul = 60;
|
|
1136
|
+
var Video = 61;
|
|
1137
|
+
var TextArea = 62;
|
|
1138
|
+
var Select = 63;
|
|
1139
|
+
var Option = 64;
|
|
1140
|
+
var Code = 65;
|
|
1141
|
+
var Label = 66;
|
|
1142
|
+
var Dt = 67;
|
|
1143
|
+
var Iframe = 68;
|
|
1144
|
+
var Main = 69;
|
|
1145
|
+
var Strong = 70;
|
|
1146
|
+
var Em = 71;
|
|
1147
|
+
var Style = 72;
|
|
1148
|
+
var Html = 73;
|
|
1149
|
+
var Head = 74;
|
|
1150
|
+
var Title = 75;
|
|
1151
|
+
var Meta = 76;
|
|
1152
|
+
var Canvas = 77;
|
|
1153
|
+
var Form = 78;
|
|
1154
|
+
var BlockQuote = 79;
|
|
1155
|
+
var Quote = 80;
|
|
1156
|
+
var Circle = 81;
|
|
1157
|
+
var Defs = 82;
|
|
1158
|
+
var Ellipse = 83;
|
|
1159
|
+
var G = 84;
|
|
1160
|
+
var Line = 85;
|
|
1161
|
+
var Path = 86;
|
|
1162
|
+
var Polygon = 87;
|
|
1163
|
+
var Polyline = 88;
|
|
1164
|
+
var Rect = 89;
|
|
1165
|
+
var Svg = 90;
|
|
1166
|
+
var Use = 91;
|
|
1167
|
+
var Reference = 100;
|
|
1168
|
+
|
|
1000
1169
|
// packages/extension-api/node_modules/@lvce-editor/constants/dist/parts/RpcId/RpcId.js
|
|
1001
1170
|
var RpcId_exports = {};
|
|
1002
1171
|
__export(RpcId_exports, {
|
|
@@ -1215,7 +1384,9 @@ var registerCommand = (command) => {
|
|
|
1215
1384
|
};
|
|
1216
1385
|
var getCommandRegistrySnapshot = () => {
|
|
1217
1386
|
return {
|
|
1218
|
-
commands: Object.values(commands2)
|
|
1387
|
+
commands: Object.values(commands2).map((command) => ({
|
|
1388
|
+
id: command.id
|
|
1389
|
+
}))
|
|
1219
1390
|
};
|
|
1220
1391
|
};
|
|
1221
1392
|
var executeCommand = async (id2, ...args) => {
|
|
@@ -1329,16 +1500,40 @@ var getType = (value) => {
|
|
|
1329
1500
|
}
|
|
1330
1501
|
return typeof value;
|
|
1331
1502
|
};
|
|
1503
|
+
var sanitizeCompletionItem = (item) => {
|
|
1504
|
+
const sanitizedItem = {};
|
|
1505
|
+
for (const [key, value] of Object.entries(item)) {
|
|
1506
|
+
if (typeof value !== "function") {
|
|
1507
|
+
sanitizedItem[key] = value;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
const { kind: itemKind, type } = item;
|
|
1511
|
+
let kind = 0;
|
|
1512
|
+
if (typeof itemKind === "number") {
|
|
1513
|
+
kind = itemKind;
|
|
1514
|
+
} else if (typeof type === "number") {
|
|
1515
|
+
kind = type;
|
|
1516
|
+
}
|
|
1517
|
+
return {
|
|
1518
|
+
...sanitizedItem,
|
|
1519
|
+
flags: typeof item.flags === "number" ? item.flags : 0,
|
|
1520
|
+
kind,
|
|
1521
|
+
label: typeof item.label === "string" ? item.label : "",
|
|
1522
|
+
matches: Array.isArray(item.matches) ? item.matches : []
|
|
1523
|
+
};
|
|
1524
|
+
};
|
|
1332
1525
|
var validateCompletionResult = (completion) => {
|
|
1333
1526
|
if (!Array.isArray(completion)) {
|
|
1334
1527
|
throw new ExtensionApiError(`invalid completion result: completion must be of type array but is ${getType(completion)}`);
|
|
1335
1528
|
}
|
|
1529
|
+
const completionItems = [];
|
|
1336
1530
|
for (const item of completion) {
|
|
1337
1531
|
if (!item || typeof item !== "object" || Array.isArray(item)) {
|
|
1338
1532
|
throw new ExtensionApiError(`invalid completion result: expected completion item to be of type object but was of type ${getType(item)}`);
|
|
1339
1533
|
}
|
|
1534
|
+
completionItems.push(sanitizeCompletionItem(item));
|
|
1340
1535
|
}
|
|
1341
|
-
return
|
|
1536
|
+
return completionItems;
|
|
1342
1537
|
};
|
|
1343
1538
|
var registry = createProviderRegistry({
|
|
1344
1539
|
mapProvider(provider) {
|
|
@@ -1383,7 +1578,10 @@ var executeResolveCompletionItemProvider = async (textDocument, offset, name, co
|
|
|
1383
1578
|
var getCompletionProviders = registry.getProviders;
|
|
1384
1579
|
var getCompletionProviderRegistrySnapshot = () => {
|
|
1385
1580
|
return {
|
|
1386
|
-
providers: registry.getProviders()
|
|
1581
|
+
providers: registry.getProviders().map((provider) => ({
|
|
1582
|
+
id: provider.id,
|
|
1583
|
+
languageId: provider.languageId
|
|
1584
|
+
}))
|
|
1387
1585
|
};
|
|
1388
1586
|
};
|
|
1389
1587
|
var resetCompletionProviderRegistry = registry.reset;
|
|
@@ -1441,7 +1639,10 @@ var executeDiagnosticProvider = async (textDocument, ...args) => {
|
|
|
1441
1639
|
var getDiagnosticProviders = registry2.getProviders;
|
|
1442
1640
|
var getDiagnosticProviderRegistrySnapshot = () => {
|
|
1443
1641
|
return {
|
|
1444
|
-
providers: registry2.getProviders()
|
|
1642
|
+
providers: registry2.getProviders().map((provider) => ({
|
|
1643
|
+
id: provider.id,
|
|
1644
|
+
languageId: provider.languageId
|
|
1645
|
+
}))
|
|
1445
1646
|
};
|
|
1446
1647
|
};
|
|
1447
1648
|
var resetDiagnosticProviderRegistry = registry2.reset;
|
|
@@ -1476,7 +1677,10 @@ var executeFormattingProvider = async (textDocument, ...args) => {
|
|
|
1476
1677
|
var getFormattingProviders = registry3.getProviders;
|
|
1477
1678
|
var getFormattingProviderRegistrySnapshot = () => {
|
|
1478
1679
|
return {
|
|
1479
|
-
providers: registry3.getProviders()
|
|
1680
|
+
providers: registry3.getProviders().map((provider) => ({
|
|
1681
|
+
id: provider.id,
|
|
1682
|
+
languageId: provider.languageId
|
|
1683
|
+
}))
|
|
1480
1684
|
};
|
|
1481
1685
|
};
|
|
1482
1686
|
var resetFormattingProviderRegistry = registry3.reset;
|
|
@@ -1525,7 +1729,9 @@ var getStatusBarItems = () => {
|
|
|
1525
1729
|
};
|
|
1526
1730
|
var getStatusBarItemProviderRegistrySnapshot = () => {
|
|
1527
1731
|
return {
|
|
1528
|
-
providers: registry4.getProviders()
|
|
1732
|
+
providers: registry4.getProviders().map((provider) => ({
|
|
1733
|
+
id: provider.id
|
|
1734
|
+
}))
|
|
1529
1735
|
};
|
|
1530
1736
|
};
|
|
1531
1737
|
var resetStatusBarItemProviderRegistry = registry4.reset;
|
|
@@ -1581,7 +1787,10 @@ var executeHoverProvider = async (textDocument, offset, ...args) => {
|
|
|
1581
1787
|
var getHoverProviders = registry5.getProviders;
|
|
1582
1788
|
var getHoverProviderRegistrySnapshot = () => {
|
|
1583
1789
|
return {
|
|
1584
|
-
providers: registry5.getProviders()
|
|
1790
|
+
providers: registry5.getProviders().map((provider) => ({
|
|
1791
|
+
id: provider.id,
|
|
1792
|
+
languageId: provider.languageId
|
|
1793
|
+
}))
|
|
1585
1794
|
};
|
|
1586
1795
|
};
|
|
1587
1796
|
var resetHoverProviderRegistry = registry5.reset;
|
|
@@ -1651,8 +1860,256 @@ var resetOutputChannelRegistry = () => {
|
|
|
1651
1860
|
isActivated = false;
|
|
1652
1861
|
};
|
|
1653
1862
|
|
|
1863
|
+
// packages/extension-api/node_modules/@lvce-editor/virtual-dom-worker/dist/parts/PatchType/PatchType.js
|
|
1864
|
+
var SetText = 1;
|
|
1865
|
+
var Replace = 2;
|
|
1866
|
+
var SetAttribute = 3;
|
|
1867
|
+
var RemoveAttribute = 4;
|
|
1868
|
+
var Add = 6;
|
|
1869
|
+
var NavigateChild = 7;
|
|
1870
|
+
var NavigateParent = 8;
|
|
1871
|
+
var RemoveChild = 9;
|
|
1872
|
+
var NavigateSibling = 10;
|
|
1873
|
+
var SetReferenceNodeUid = 11;
|
|
1874
|
+
|
|
1875
|
+
// packages/extension-api/node_modules/@lvce-editor/virtual-dom-worker/dist/parts/IsKey/IsKey.js
|
|
1876
|
+
var isKey = (key) => {
|
|
1877
|
+
return key !== "type" && key !== "childCount";
|
|
1878
|
+
};
|
|
1879
|
+
|
|
1880
|
+
// packages/extension-api/node_modules/@lvce-editor/virtual-dom-worker/dist/parts/GetKeys/GetKeys.js
|
|
1881
|
+
var getKeys = (node) => {
|
|
1882
|
+
const keys = Object.keys(node).filter(isKey);
|
|
1883
|
+
return keys;
|
|
1884
|
+
};
|
|
1885
|
+
|
|
1886
|
+
// packages/extension-api/node_modules/@lvce-editor/virtual-dom-worker/dist/parts/VirtualDomTree/VirtualDomTree.js
|
|
1887
|
+
var arrayToTree = (nodes) => {
|
|
1888
|
+
const result = [];
|
|
1889
|
+
let i = 0;
|
|
1890
|
+
while (i < nodes.length) {
|
|
1891
|
+
const node = nodes[i];
|
|
1892
|
+
const { children, nodesConsumed } = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
1893
|
+
result.push({
|
|
1894
|
+
node,
|
|
1895
|
+
children
|
|
1896
|
+
});
|
|
1897
|
+
i += 1 + nodesConsumed;
|
|
1898
|
+
}
|
|
1899
|
+
return result;
|
|
1900
|
+
};
|
|
1901
|
+
var getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
1902
|
+
if (childCount === 0) {
|
|
1903
|
+
return { children: [], nodesConsumed: 0 };
|
|
1904
|
+
}
|
|
1905
|
+
const children = [];
|
|
1906
|
+
let i = startIndex;
|
|
1907
|
+
let remaining = childCount;
|
|
1908
|
+
let totalConsumed = 0;
|
|
1909
|
+
while (remaining > 0 && i < nodes.length) {
|
|
1910
|
+
const node = nodes[i];
|
|
1911
|
+
const nodeChildCount = node.childCount || 0;
|
|
1912
|
+
const { children: nodeChildren, nodesConsumed } = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
1913
|
+
children.push({
|
|
1914
|
+
node,
|
|
1915
|
+
children: nodeChildren
|
|
1916
|
+
});
|
|
1917
|
+
const nodeSize = 1 + nodesConsumed;
|
|
1918
|
+
i += nodeSize;
|
|
1919
|
+
totalConsumed += nodeSize;
|
|
1920
|
+
remaining--;
|
|
1921
|
+
}
|
|
1922
|
+
return { children, nodesConsumed: totalConsumed };
|
|
1923
|
+
};
|
|
1924
|
+
|
|
1925
|
+
// packages/extension-api/node_modules/@lvce-editor/virtual-dom-worker/dist/parts/VirtualDomDiffTree/CompareNodes.js
|
|
1926
|
+
var compareNodes = (oldNode, newNode) => {
|
|
1927
|
+
if (oldNode.type !== newNode.type) {
|
|
1928
|
+
return null;
|
|
1929
|
+
}
|
|
1930
|
+
const patches = [];
|
|
1931
|
+
if (oldNode.type === VirtualDomElements_exports.Reference) {
|
|
1932
|
+
if (oldNode.uid !== newNode.uid) {
|
|
1933
|
+
patches.push({
|
|
1934
|
+
type: SetReferenceNodeUid,
|
|
1935
|
+
uid: newNode.uid
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
return patches;
|
|
1939
|
+
}
|
|
1940
|
+
if (oldNode.type === VirtualDomElements_exports.Text && newNode.type === VirtualDomElements_exports.Text) {
|
|
1941
|
+
if (oldNode.text !== newNode.text) {
|
|
1942
|
+
patches.push({
|
|
1943
|
+
type: SetText,
|
|
1944
|
+
value: newNode.text
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
return patches;
|
|
1948
|
+
}
|
|
1949
|
+
const oldKeys = getKeys(oldNode);
|
|
1950
|
+
const newKeys = getKeys(newNode);
|
|
1951
|
+
for (const key of newKeys) {
|
|
1952
|
+
if (oldNode[key] !== newNode[key]) {
|
|
1953
|
+
patches.push({
|
|
1954
|
+
type: SetAttribute,
|
|
1955
|
+
key,
|
|
1956
|
+
value: newNode[key]
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
for (const key of oldKeys) {
|
|
1961
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
1962
|
+
patches.push({
|
|
1963
|
+
type: RemoveAttribute,
|
|
1964
|
+
key
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
return patches;
|
|
1969
|
+
};
|
|
1970
|
+
|
|
1971
|
+
// packages/extension-api/node_modules/@lvce-editor/virtual-dom-worker/dist/parts/VirtualDomDiffTree/TreeToArray.js
|
|
1972
|
+
var treeToArray = (node) => {
|
|
1973
|
+
const result = [node.node];
|
|
1974
|
+
for (const child of node.children) {
|
|
1975
|
+
result.push(...treeToArray(child));
|
|
1976
|
+
}
|
|
1977
|
+
return result;
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
// packages/extension-api/node_modules/@lvce-editor/virtual-dom-worker/dist/parts/VirtualDomDiffTree/DiffTrees.js
|
|
1981
|
+
var navigateToChild = (patches, currentChildIndex, index) => {
|
|
1982
|
+
if (currentChildIndex === -1) {
|
|
1983
|
+
patches.push({
|
|
1984
|
+
type: NavigateChild,
|
|
1985
|
+
index
|
|
1986
|
+
});
|
|
1987
|
+
return index;
|
|
1988
|
+
}
|
|
1989
|
+
if (currentChildIndex !== index) {
|
|
1990
|
+
patches.push({
|
|
1991
|
+
type: NavigateSibling,
|
|
1992
|
+
index
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
return index;
|
|
1996
|
+
};
|
|
1997
|
+
var navigateToParent = (patches, currentChildIndex) => {
|
|
1998
|
+
if (currentChildIndex >= 0) {
|
|
1999
|
+
patches.push({
|
|
2000
|
+
type: NavigateParent
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
return -1;
|
|
2004
|
+
};
|
|
2005
|
+
var addTree = (newNode, patches) => {
|
|
2006
|
+
patches.push({
|
|
2007
|
+
type: Add,
|
|
2008
|
+
nodes: treeToArray(newNode)
|
|
2009
|
+
});
|
|
2010
|
+
};
|
|
2011
|
+
var replaceTree = (newNode, patches) => {
|
|
2012
|
+
patches.push({
|
|
2013
|
+
type: Replace,
|
|
2014
|
+
nodes: treeToArray(newNode)
|
|
2015
|
+
});
|
|
2016
|
+
};
|
|
2017
|
+
var diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
2018
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2019
|
+
if (nodePatches === null) {
|
|
2020
|
+
const nextChildIndex2 = navigateToChild(patches, currentChildIndex, index);
|
|
2021
|
+
replaceTree(newNode, patches);
|
|
2022
|
+
return nextChildIndex2;
|
|
2023
|
+
}
|
|
2024
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2025
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
2026
|
+
return currentChildIndex;
|
|
2027
|
+
}
|
|
2028
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2029
|
+
if (nodePatches.length > 0) {
|
|
2030
|
+
patches.push(...nodePatches);
|
|
2031
|
+
}
|
|
2032
|
+
if (hasChildrenToCompare) {
|
|
2033
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2034
|
+
}
|
|
2035
|
+
return nextChildIndex;
|
|
2036
|
+
};
|
|
2037
|
+
var diffRootNode = (oldNode, newNode, patches) => {
|
|
2038
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2039
|
+
if (nodePatches === null) {
|
|
2040
|
+
replaceTree(newNode, patches);
|
|
2041
|
+
return;
|
|
2042
|
+
}
|
|
2043
|
+
if (nodePatches.length > 0) {
|
|
2044
|
+
patches.push(...nodePatches);
|
|
2045
|
+
}
|
|
2046
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2047
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
var diffChildren = (oldChildren, newChildren, patches) => {
|
|
2051
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
2052
|
+
let currentChildIndex = -1;
|
|
2053
|
+
const indicesToRemove = [];
|
|
2054
|
+
for (let i = 0; i < maxLength; i++) {
|
|
2055
|
+
const oldNode = oldChildren[i];
|
|
2056
|
+
const newNode = newChildren[i];
|
|
2057
|
+
if (!oldNode && !newNode) {
|
|
2058
|
+
continue;
|
|
2059
|
+
}
|
|
2060
|
+
if (!oldNode) {
|
|
2061
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
2062
|
+
addTree(newNode, patches);
|
|
2063
|
+
continue;
|
|
2064
|
+
}
|
|
2065
|
+
if (!newNode) {
|
|
2066
|
+
indicesToRemove.push(i);
|
|
2067
|
+
continue;
|
|
2068
|
+
}
|
|
2069
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
2070
|
+
}
|
|
2071
|
+
navigateToParent(patches, currentChildIndex);
|
|
2072
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
2073
|
+
patches.push({
|
|
2074
|
+
type: RemoveChild,
|
|
2075
|
+
index: indicesToRemove[j]
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
var diffTrees = (oldTree, newTree, patches, path) => {
|
|
2080
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
2081
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
2082
|
+
return;
|
|
2083
|
+
}
|
|
2084
|
+
diffChildren(oldTree, newTree, patches);
|
|
2085
|
+
};
|
|
2086
|
+
|
|
2087
|
+
// packages/extension-api/node_modules/@lvce-editor/virtual-dom-worker/dist/parts/VirtualDomDiffTree/RemoveTrailingNavigationPatches.js
|
|
2088
|
+
var removeTrailingNavigationPatches = (patches) => {
|
|
2089
|
+
let lastNonNavigationIndex = -1;
|
|
2090
|
+
for (let i = patches.length - 1; i >= 0; i--) {
|
|
2091
|
+
const patch = patches[i];
|
|
2092
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
2093
|
+
lastNonNavigationIndex = i;
|
|
2094
|
+
break;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
|
|
2098
|
+
};
|
|
2099
|
+
|
|
2100
|
+
// packages/extension-api/node_modules/@lvce-editor/virtual-dom-worker/dist/parts/VirtualDomDiffTree/VirtualDomDiffTree.js
|
|
2101
|
+
var diffTree = (oldNodes, newNodes) => {
|
|
2102
|
+
const oldTree = arrayToTree(oldNodes);
|
|
2103
|
+
const newTree = arrayToTree(newNodes);
|
|
2104
|
+
const patches = [];
|
|
2105
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
2106
|
+
return removeTrailingNavigationPatches(patches);
|
|
2107
|
+
};
|
|
2108
|
+
|
|
1654
2109
|
// packages/extension-api/src/parts/ViewRegistry/ViewRegistry.ts
|
|
1655
2110
|
var views = /* @__PURE__ */ Object.create(null);
|
|
2111
|
+
var instances = /* @__PURE__ */ Object.create(null);
|
|
2112
|
+
var renderedDoms = /* @__PURE__ */ Object.create(null);
|
|
1656
2113
|
var assertView = (view) => {
|
|
1657
2114
|
if (!view) {
|
|
1658
2115
|
throw new ExtensionApiError("view is not defined");
|
|
@@ -1668,11 +2125,18 @@ var assertView = (view) => {
|
|
|
1668
2125
|
}
|
|
1669
2126
|
};
|
|
1670
2127
|
var toRegisteredView = (view) => {
|
|
1671
|
-
|
|
2128
|
+
const registeredView = {
|
|
1672
2129
|
icon: view.icon,
|
|
1673
2130
|
id: view.id,
|
|
1674
2131
|
title: view.title
|
|
1675
2132
|
};
|
|
2133
|
+
if (view.kind) {
|
|
2134
|
+
return {
|
|
2135
|
+
...registeredView,
|
|
2136
|
+
kind: view.kind
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
return registeredView;
|
|
1676
2140
|
};
|
|
1677
2141
|
var registerView = (view) => {
|
|
1678
2142
|
assertView(view);
|
|
@@ -1690,6 +2154,79 @@ var executeViewProvider = (id2) => {
|
|
|
1690
2154
|
}
|
|
1691
2155
|
return view.create();
|
|
1692
2156
|
};
|
|
2157
|
+
var assertVirtualDomViewInstance = (id2, instance) => {
|
|
2158
|
+
if (!instance || typeof instance !== "object") {
|
|
2159
|
+
throw new ExtensionApiError(`view ${id2} did not return a view instance`);
|
|
2160
|
+
}
|
|
2161
|
+
if (typeof instance.render !== "function") {
|
|
2162
|
+
throw new ExtensionApiError(`view ${id2} instance is missing render function`);
|
|
2163
|
+
}
|
|
2164
|
+
};
|
|
2165
|
+
var getVirtualDomInstance = (uid) => {
|
|
2166
|
+
const instance = instances[uid];
|
|
2167
|
+
if (!instance) {
|
|
2168
|
+
throw new ExtensionApiError(`view instance ${uid} not found`);
|
|
2169
|
+
}
|
|
2170
|
+
return instance;
|
|
2171
|
+
};
|
|
2172
|
+
var renderDom = async (instance) => {
|
|
2173
|
+
const dom = await instance.render();
|
|
2174
|
+
if (!Array.isArray(dom)) {
|
|
2175
|
+
throw new ExtensionApiError("view render result must be an array");
|
|
2176
|
+
}
|
|
2177
|
+
return dom;
|
|
2178
|
+
};
|
|
2179
|
+
var createViewInstance = async (viewId, uid, context) => {
|
|
2180
|
+
const view = views[viewId];
|
|
2181
|
+
if (!view) {
|
|
2182
|
+
throw new ExtensionApiError(`view ${viewId} not found`);
|
|
2183
|
+
}
|
|
2184
|
+
if (view.kind !== "virtualDom") {
|
|
2185
|
+
throw new ExtensionApiError(`view ${viewId} is not a virtual dom view`);
|
|
2186
|
+
}
|
|
2187
|
+
const instance = await view.create({
|
|
2188
|
+
...context,
|
|
2189
|
+
uid,
|
|
2190
|
+
viewId
|
|
2191
|
+
});
|
|
2192
|
+
assertVirtualDomViewInstance(viewId, instance);
|
|
2193
|
+
instances[uid] = instance;
|
|
2194
|
+
const dom = await renderDom(instance);
|
|
2195
|
+
renderedDoms[uid] = dom;
|
|
2196
|
+
return {
|
|
2197
|
+
dom,
|
|
2198
|
+
type: "setDom"
|
|
2199
|
+
};
|
|
2200
|
+
};
|
|
2201
|
+
var dispatchViewEvent = async (uid, event) => {
|
|
2202
|
+
const instance = getVirtualDomInstance(uid);
|
|
2203
|
+
if (typeof instance.handleEvent === "function") {
|
|
2204
|
+
await instance.handleEvent(event);
|
|
2205
|
+
}
|
|
2206
|
+
const oldDom = renderedDoms[uid] || [];
|
|
2207
|
+
const newDom = await renderDom(instance);
|
|
2208
|
+
renderedDoms[uid] = newDom;
|
|
2209
|
+
const patches = diffTree(oldDom, newDom);
|
|
2210
|
+
return {
|
|
2211
|
+
patches,
|
|
2212
|
+
type: "setPatches"
|
|
2213
|
+
};
|
|
2214
|
+
};
|
|
2215
|
+
var disposeViewInstance = async (uid) => {
|
|
2216
|
+
const instance = instances[uid];
|
|
2217
|
+
if (instance && typeof instance.dispose === "function") {
|
|
2218
|
+
await instance.dispose();
|
|
2219
|
+
}
|
|
2220
|
+
delete instances[uid];
|
|
2221
|
+
delete renderedDoms[uid];
|
|
2222
|
+
};
|
|
2223
|
+
var saveViewInstanceState = async (uid) => {
|
|
2224
|
+
const instance = getVirtualDomInstance(uid);
|
|
2225
|
+
if (typeof instance.saveState !== "function") {
|
|
2226
|
+
return void 0;
|
|
2227
|
+
}
|
|
2228
|
+
return instance.saveState();
|
|
2229
|
+
};
|
|
1693
2230
|
var getViewRegistrySnapshot = () => {
|
|
1694
2231
|
return {
|
|
1695
2232
|
views: Object.values(views).map(toRegisteredView)
|
|
@@ -1699,10 +2236,19 @@ var resetViewRegistry = () => {
|
|
|
1699
2236
|
for (const id2 of Object.keys(views)) {
|
|
1700
2237
|
delete views[id2];
|
|
1701
2238
|
}
|
|
2239
|
+
for (const uid of Object.keys(instances)) {
|
|
2240
|
+
delete instances[Number(uid)];
|
|
2241
|
+
}
|
|
2242
|
+
for (const uid of Object.keys(renderedDoms)) {
|
|
2243
|
+
delete renderedDoms[Number(uid)];
|
|
2244
|
+
}
|
|
1702
2245
|
};
|
|
1703
2246
|
|
|
1704
2247
|
// packages/extension-api/src/parts/ExtensionApiCommandMap/ExtensionApiCommandMap.ts
|
|
1705
2248
|
var commandMap = {
|
|
2249
|
+
"ExtensionApi.createViewInstance": createViewInstance,
|
|
2250
|
+
"ExtensionApi.dispatchViewEvent": dispatchViewEvent,
|
|
2251
|
+
"ExtensionApi.disposeViewInstance": disposeViewInstance,
|
|
1706
2252
|
"ExtensionApi.executeCommand": executeCommand,
|
|
1707
2253
|
"ExtensionApi.executeCompletionProvider": executeCompletionProvider,
|
|
1708
2254
|
"ExtensionApi.executeDiagnosticProvider": executeDiagnosticProvider,
|
|
@@ -1717,7 +2263,8 @@ var commandMap = {
|
|
|
1717
2263
|
"ExtensionApi.getHoverProviderRegistrySnapshot": getHoverProviderRegistrySnapshot,
|
|
1718
2264
|
"ExtensionApi.getOutputChannelRegistrySnapshot": getOutputChannelRegistrySnapshot,
|
|
1719
2265
|
"ExtensionApi.getStatusBarItems": getStatusBarItems,
|
|
1720
|
-
"ExtensionApi.getViewRegistrySnapshot": getViewRegistrySnapshot
|
|
2266
|
+
"ExtensionApi.getViewRegistrySnapshot": getViewRegistrySnapshot,
|
|
2267
|
+
"ExtensionApi.saveViewInstanceState": saveViewInstanceState
|
|
1721
2268
|
};
|
|
1722
2269
|
|
|
1723
2270
|
// packages/extension-api/src/parts/ExtensionApiWorkerHandleMessagePort/ExtensionApiWorkerHandleMessagePort.ts
|
|
@@ -1807,6 +2354,9 @@ var handleExtensionManagementMessagePort2 = async ({
|
|
|
1807
2354
|
export {
|
|
1808
2355
|
activate,
|
|
1809
2356
|
createOutputChannel,
|
|
2357
|
+
createViewInstance,
|
|
2358
|
+
dispatchViewEvent,
|
|
2359
|
+
disposeViewInstance,
|
|
1810
2360
|
executeCommand2 as executeCommand,
|
|
1811
2361
|
executeCompletionProvider,
|
|
1812
2362
|
executeDiagnosticProvider,
|
|
@@ -1836,5 +2386,6 @@ export {
|
|
|
1836
2386
|
resetOutputChannelRegistry,
|
|
1837
2387
|
resetStatusBarItemProviderRegistry,
|
|
1838
2388
|
resetViewRegistry,
|
|
2389
|
+
saveViewInstanceState,
|
|
1839
2390
|
showQuickPick
|
|
1840
2391
|
};
|
|
@@ -30,7 +30,9 @@ const registerCommand = (command) => {
|
|
|
30
30
|
};
|
|
31
31
|
const getCommandRegistrySnapshot = () => {
|
|
32
32
|
return {
|
|
33
|
-
commands: Object.values(commands)
|
|
33
|
+
commands: Object.values(commands).map((command) => ({
|
|
34
|
+
id: command.id
|
|
35
|
+
}))
|
|
34
36
|
};
|
|
35
37
|
};
|
|
36
38
|
const executeCommand = async (id, ...args) => {
|