@lvce-editor/extension-host-worker 8.28.0 → 8.30.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 +31 -5
- package/dist/extension-api/parts/FileSystem/FileSystem.js +8 -1
- package/dist/extension-api/parts/OutputChannel/OutputChannel.js +14 -6
- package/dist/extension-api/parts/Preferences/Preferences.js +11 -0
- package/dist/extensionHostWorkerMain.js +347 -0
- package/extension-api/dist/index.d.ts +1 -0
- package/extension-api/dist/index.js +1 -0
- package/extension-api/dist/parts/FileSystem/FileSystem.js +8 -1
- package/extension-api/dist/parts/OutputChannel/OutputChannel.js +13 -5
- package/extension-api/dist/parts/OutputChannelHandle/OutputChannelHandle.d.ts +1 -0
- package/extension-api/dist/parts/Preferences/Preferences.d.ts +2 -0
- package/extension-api/dist/parts/Preferences/Preferences.js +7 -0
- package/extension-api/package.json +1 -1
- package/extension-api/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -2
|
@@ -1931,6 +1931,7 @@ var resetHoverProviderRegistry = registry5.reset;
|
|
|
1931
1931
|
|
|
1932
1932
|
// packages/extension-api/src/parts/OutputChannel/OutputChannel.ts
|
|
1933
1933
|
var outputChannels = /* @__PURE__ */ Object.create(null);
|
|
1934
|
+
var outputChannelLogs = /* @__PURE__ */ Object.create(null);
|
|
1934
1935
|
var isActivated = false;
|
|
1935
1936
|
var RE_DASH_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
1936
1937
|
var assertOutputChannelId = (id2) => {
|
|
@@ -1953,20 +1954,24 @@ var ExtensionOutputChannel = class {
|
|
|
1953
1954
|
}
|
|
1954
1955
|
async append(text) {
|
|
1955
1956
|
assertCanWrite(this.#id);
|
|
1956
|
-
|
|
1957
|
+
outputChannelLogs[this.#id] += text;
|
|
1957
1958
|
}
|
|
1958
1959
|
async appendLine(text) {
|
|
1959
1960
|
assertCanWrite(this.#id);
|
|
1960
|
-
|
|
1961
|
-
|
|
1961
|
+
outputChannelLogs[this.#id] += `${text}
|
|
1962
|
+
`;
|
|
1962
1963
|
}
|
|
1963
1964
|
async clear() {
|
|
1964
1965
|
assertCanWrite(this.#id);
|
|
1965
|
-
|
|
1966
|
+
outputChannelLogs[this.#id] = "";
|
|
1967
|
+
}
|
|
1968
|
+
async getLogs() {
|
|
1969
|
+
assertCanWrite(this.#id);
|
|
1970
|
+
return outputChannelLogs[this.#id];
|
|
1966
1971
|
}
|
|
1967
1972
|
async replace(text) {
|
|
1968
1973
|
assertCanWrite(this.#id);
|
|
1969
|
-
|
|
1974
|
+
outputChannelLogs[this.#id] = text;
|
|
1970
1975
|
}
|
|
1971
1976
|
};
|
|
1972
1977
|
var activateOutputChannels = () => {
|
|
@@ -1980,6 +1985,7 @@ var createOutputChannel = (id2) => {
|
|
|
1980
1985
|
outputChannels[id2] = {
|
|
1981
1986
|
id: id2
|
|
1982
1987
|
};
|
|
1988
|
+
outputChannelLogs[id2] = "";
|
|
1983
1989
|
return new ExtensionOutputChannel(id2);
|
|
1984
1990
|
};
|
|
1985
1991
|
var getOutputChannelRegistrySnapshot = () => {
|
|
@@ -1991,6 +1997,9 @@ var resetOutputChannelRegistry = () => {
|
|
|
1991
1997
|
for (const id2 of Object.keys(outputChannels)) {
|
|
1992
1998
|
delete outputChannels[id2];
|
|
1993
1999
|
}
|
|
2000
|
+
for (const id2 of Object.keys(outputChannelLogs)) {
|
|
2001
|
+
delete outputChannelLogs[id2];
|
|
2002
|
+
}
|
|
1994
2003
|
isActivated = false;
|
|
1995
2004
|
};
|
|
1996
2005
|
|
|
@@ -2479,7 +2488,19 @@ var showQuickPick = async (options) => {
|
|
|
2479
2488
|
return ExtensionManagementWorker_exports.invoke("ExtensionHostQuickPick.showQuickPick", options);
|
|
2480
2489
|
};
|
|
2481
2490
|
|
|
2491
|
+
// packages/extension-api/src/parts/Preferences/Preferences.ts
|
|
2492
|
+
var getPreference = async (key) => {
|
|
2493
|
+
return ExtensionManagementWorker_exports.invoke("Extensions.getPreference", key);
|
|
2494
|
+
};
|
|
2495
|
+
var setPreference = async (key, value) => {
|
|
2496
|
+
await ExtensionManagementWorker_exports.invoke("Extensions.setPreference", key, value);
|
|
2497
|
+
};
|
|
2498
|
+
|
|
2482
2499
|
// packages/extension-api/src/parts/FileSystem/FileSystem.ts
|
|
2500
|
+
var MemfsPrefix = "memfs://";
|
|
2501
|
+
var isMemory = (uri) => {
|
|
2502
|
+
return uri.startsWith(MemfsPrefix);
|
|
2503
|
+
};
|
|
2483
2504
|
var exists2 = async (uri) => {
|
|
2484
2505
|
return FileSystemWorker_exports.exists(uri);
|
|
2485
2506
|
};
|
|
@@ -2487,6 +2508,9 @@ var readDirWithFileTypes2 = async (uri) => {
|
|
|
2487
2508
|
return FileSystemWorker_exports.readDirWithFileTypes(uri);
|
|
2488
2509
|
};
|
|
2489
2510
|
var readFile2 = async (uri) => {
|
|
2511
|
+
if (isMemory(uri)) {
|
|
2512
|
+
return ExtensionManagementWorker_exports.invoke("ExtensionApi.readFile", uri);
|
|
2513
|
+
}
|
|
2490
2514
|
return FileSystemWorker_exports.readFile(uri);
|
|
2491
2515
|
};
|
|
2492
2516
|
var mkdir2 = async (uri) => {
|
|
@@ -2543,6 +2567,7 @@ export {
|
|
|
2543
2567
|
getFormattingProviderRegistrySnapshot,
|
|
2544
2568
|
getHoverProviderRegistrySnapshot,
|
|
2545
2569
|
getOutputChannelRegistrySnapshot,
|
|
2570
|
+
getPreference,
|
|
2546
2571
|
getStatusBarItemProviderRegistrySnapshot,
|
|
2547
2572
|
getViewRegistrySnapshot,
|
|
2548
2573
|
handleExtensionManagementMessagePort2 as handleExtensionManagementMessagePort,
|
|
@@ -2565,6 +2590,7 @@ export {
|
|
|
2565
2590
|
resetStatusBarItemProviderRegistry,
|
|
2566
2591
|
resetViewRegistry,
|
|
2567
2592
|
saveViewInstanceState,
|
|
2593
|
+
setPreference,
|
|
2568
2594
|
showQuickPick,
|
|
2569
2595
|
writeFile2 as writeFile
|
|
2570
2596
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { FileSystemWorker } from "@lvce-editor/rpc-registry";
|
|
1
|
+
import { ExtensionManagementWorker, FileSystemWorker } from "@lvce-editor/rpc-registry";
|
|
2
|
+
const MemfsPrefix = "memfs://";
|
|
3
|
+
const isMemory = (uri) => {
|
|
4
|
+
return uri.startsWith(MemfsPrefix);
|
|
5
|
+
};
|
|
2
6
|
const exists = async (uri) => {
|
|
3
7
|
return FileSystemWorker.exists(uri);
|
|
4
8
|
};
|
|
@@ -6,6 +10,9 @@ const readDirWithFileTypes = async (uri) => {
|
|
|
6
10
|
return FileSystemWorker.readDirWithFileTypes(uri);
|
|
7
11
|
};
|
|
8
12
|
const readFile = async (uri) => {
|
|
13
|
+
if (isMemory(uri)) {
|
|
14
|
+
return ExtensionManagementWorker.invoke("ExtensionApi.readFile", uri);
|
|
15
|
+
}
|
|
9
16
|
return FileSystemWorker.readFile(uri);
|
|
10
17
|
};
|
|
11
18
|
const mkdir = async (uri) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExtensionManagementWorker } from "@lvce-editor/rpc-registry";
|
|
2
1
|
import { ExtensionApiError } from "../ExtensionApiError/ExtensionApiError.js";
|
|
3
2
|
const outputChannels = /* @__PURE__ */ Object.create(null);
|
|
3
|
+
const outputChannelLogs = /* @__PURE__ */ Object.create(null);
|
|
4
4
|
let isActivated = false;
|
|
5
5
|
const RE_DASH_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
6
6
|
const assertOutputChannelId = (id) => {
|
|
@@ -23,20 +23,24 @@ class ExtensionOutputChannel {
|
|
|
23
23
|
}
|
|
24
24
|
async append(text) {
|
|
25
25
|
assertCanWrite(this.#id);
|
|
26
|
-
|
|
26
|
+
outputChannelLogs[this.#id] += text;
|
|
27
27
|
}
|
|
28
28
|
async appendLine(text) {
|
|
29
29
|
assertCanWrite(this.#id);
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
outputChannelLogs[this.#id] += `${text}
|
|
31
|
+
`;
|
|
32
32
|
}
|
|
33
33
|
async clear() {
|
|
34
34
|
assertCanWrite(this.#id);
|
|
35
|
-
|
|
35
|
+
outputChannelLogs[this.#id] = "";
|
|
36
|
+
}
|
|
37
|
+
async getLogs() {
|
|
38
|
+
assertCanWrite(this.#id);
|
|
39
|
+
return outputChannelLogs[this.#id];
|
|
36
40
|
}
|
|
37
41
|
async replace(text) {
|
|
38
42
|
assertCanWrite(this.#id);
|
|
39
|
-
|
|
43
|
+
outputChannelLogs[this.#id] = text;
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
const activateOutputChannels = () => {
|
|
@@ -50,6 +54,7 @@ const createOutputChannel = (id) => {
|
|
|
50
54
|
outputChannels[id] = {
|
|
51
55
|
id
|
|
52
56
|
};
|
|
57
|
+
outputChannelLogs[id] = "";
|
|
53
58
|
return new ExtensionOutputChannel(id);
|
|
54
59
|
};
|
|
55
60
|
const getOutputChannelRegistrySnapshot = () => {
|
|
@@ -61,6 +66,9 @@ const resetOutputChannelRegistry = () => {
|
|
|
61
66
|
for (const id of Object.keys(outputChannels)) {
|
|
62
67
|
delete outputChannels[id];
|
|
63
68
|
}
|
|
69
|
+
for (const id of Object.keys(outputChannelLogs)) {
|
|
70
|
+
delete outputChannelLogs[id];
|
|
71
|
+
}
|
|
64
72
|
isActivated = false;
|
|
65
73
|
};
|
|
66
74
|
export {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExtensionManagementWorker } from "@lvce-editor/rpc-registry";
|
|
2
|
+
const getPreference = async (key) => {
|
|
3
|
+
return ExtensionManagementWorker.invoke("Extensions.getPreference", key);
|
|
4
|
+
};
|
|
5
|
+
const setPreference = async (key, value) => {
|
|
6
|
+
await ExtensionManagementWorker.invoke("Extensions.setPreference", key, value);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
getPreference,
|
|
10
|
+
setPreference
|
|
11
|
+
};
|
|
@@ -1320,6 +1320,9 @@ const create$7 = rpcId => {
|
|
|
1320
1320
|
};
|
|
1321
1321
|
};
|
|
1322
1322
|
|
|
1323
|
+
const Text = 12;
|
|
1324
|
+
const Reference = 100;
|
|
1325
|
+
|
|
1323
1326
|
const DebugWorker$1 = 55;
|
|
1324
1327
|
const ExtensionManagementWorker = 9006;
|
|
1325
1328
|
const RendererWorker$1 = 1;
|
|
@@ -3510,7 +3513,270 @@ const {
|
|
|
3510
3513
|
}
|
|
3511
3514
|
});
|
|
3512
3515
|
|
|
3516
|
+
const SetText = 1;
|
|
3517
|
+
const Replace = 2;
|
|
3518
|
+
const SetAttribute = 3;
|
|
3519
|
+
const RemoveAttribute = 4;
|
|
3520
|
+
const Add = 6;
|
|
3521
|
+
const NavigateChild = 7;
|
|
3522
|
+
const NavigateParent = 8;
|
|
3523
|
+
const RemoveChild = 9;
|
|
3524
|
+
const NavigateSibling = 10;
|
|
3525
|
+
const SetReferenceNodeUid = 11;
|
|
3526
|
+
|
|
3527
|
+
const isKey = key => {
|
|
3528
|
+
return key !== 'type' && key !== 'childCount';
|
|
3529
|
+
};
|
|
3530
|
+
|
|
3531
|
+
const getKeys = node => {
|
|
3532
|
+
const keys = Object.keys(node).filter(isKey);
|
|
3533
|
+
return keys;
|
|
3534
|
+
};
|
|
3535
|
+
|
|
3536
|
+
const arrayToTree = nodes => {
|
|
3537
|
+
const result = [];
|
|
3538
|
+
let i = 0;
|
|
3539
|
+
while (i < nodes.length) {
|
|
3540
|
+
const node = nodes[i];
|
|
3541
|
+
const {
|
|
3542
|
+
children,
|
|
3543
|
+
nodesConsumed
|
|
3544
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
3545
|
+
result.push({
|
|
3546
|
+
node,
|
|
3547
|
+
children
|
|
3548
|
+
});
|
|
3549
|
+
i += 1 + nodesConsumed;
|
|
3550
|
+
}
|
|
3551
|
+
return result;
|
|
3552
|
+
};
|
|
3553
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
3554
|
+
if (childCount === 0) {
|
|
3555
|
+
return {
|
|
3556
|
+
children: [],
|
|
3557
|
+
nodesConsumed: 0
|
|
3558
|
+
};
|
|
3559
|
+
}
|
|
3560
|
+
const children = [];
|
|
3561
|
+
let i = startIndex;
|
|
3562
|
+
let remaining = childCount;
|
|
3563
|
+
let totalConsumed = 0;
|
|
3564
|
+
while (remaining > 0 && i < nodes.length) {
|
|
3565
|
+
const node = nodes[i];
|
|
3566
|
+
const nodeChildCount = node.childCount || 0;
|
|
3567
|
+
const {
|
|
3568
|
+
children: nodeChildren,
|
|
3569
|
+
nodesConsumed
|
|
3570
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
3571
|
+
children.push({
|
|
3572
|
+
node,
|
|
3573
|
+
children: nodeChildren
|
|
3574
|
+
});
|
|
3575
|
+
const nodeSize = 1 + nodesConsumed;
|
|
3576
|
+
i += nodeSize;
|
|
3577
|
+
totalConsumed += nodeSize;
|
|
3578
|
+
remaining--;
|
|
3579
|
+
}
|
|
3580
|
+
return {
|
|
3581
|
+
children,
|
|
3582
|
+
nodesConsumed: totalConsumed
|
|
3583
|
+
};
|
|
3584
|
+
};
|
|
3585
|
+
|
|
3586
|
+
const compareNodes = (oldNode, newNode) => {
|
|
3587
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
3588
|
+
// (caller should handle this with a Replace operation)
|
|
3589
|
+
if (oldNode.type !== newNode.type) {
|
|
3590
|
+
return null;
|
|
3591
|
+
}
|
|
3592
|
+
const patches = [];
|
|
3593
|
+
// Handle reference nodes - special handling for uid changes
|
|
3594
|
+
if (oldNode.type === Reference) {
|
|
3595
|
+
if (oldNode.uid !== newNode.uid) {
|
|
3596
|
+
patches.push({
|
|
3597
|
+
type: SetReferenceNodeUid,
|
|
3598
|
+
uid: newNode.uid
|
|
3599
|
+
});
|
|
3600
|
+
}
|
|
3601
|
+
return patches;
|
|
3602
|
+
}
|
|
3603
|
+
// Handle text nodes
|
|
3604
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
3605
|
+
if (oldNode.text !== newNode.text) {
|
|
3606
|
+
patches.push({
|
|
3607
|
+
type: SetText,
|
|
3608
|
+
value: newNode.text
|
|
3609
|
+
});
|
|
3610
|
+
}
|
|
3611
|
+
return patches;
|
|
3612
|
+
}
|
|
3613
|
+
// Compare attributes
|
|
3614
|
+
const oldKeys = getKeys(oldNode);
|
|
3615
|
+
const newKeys = getKeys(newNode);
|
|
3616
|
+
// Check for attribute changes
|
|
3617
|
+
for (const key of newKeys) {
|
|
3618
|
+
if (oldNode[key] !== newNode[key]) {
|
|
3619
|
+
patches.push({
|
|
3620
|
+
type: SetAttribute,
|
|
3621
|
+
key,
|
|
3622
|
+
value: newNode[key]
|
|
3623
|
+
});
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
// Check for removed attributes
|
|
3627
|
+
for (const key of oldKeys) {
|
|
3628
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
3629
|
+
patches.push({
|
|
3630
|
+
type: RemoveAttribute,
|
|
3631
|
+
key
|
|
3632
|
+
});
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
return patches;
|
|
3636
|
+
};
|
|
3637
|
+
|
|
3638
|
+
const treeToArray = node => {
|
|
3639
|
+
const result = [node.node];
|
|
3640
|
+
for (const child of node.children) {
|
|
3641
|
+
result.push(...treeToArray(child));
|
|
3642
|
+
}
|
|
3643
|
+
return result;
|
|
3644
|
+
};
|
|
3645
|
+
|
|
3646
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
3647
|
+
if (currentChildIndex === -1) {
|
|
3648
|
+
patches.push({
|
|
3649
|
+
type: NavigateChild,
|
|
3650
|
+
index
|
|
3651
|
+
});
|
|
3652
|
+
return index;
|
|
3653
|
+
}
|
|
3654
|
+
if (currentChildIndex !== index) {
|
|
3655
|
+
patches.push({
|
|
3656
|
+
type: NavigateSibling,
|
|
3657
|
+
index
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3660
|
+
return index;
|
|
3661
|
+
};
|
|
3662
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
3663
|
+
if (currentChildIndex >= 0) {
|
|
3664
|
+
patches.push({
|
|
3665
|
+
type: NavigateParent
|
|
3666
|
+
});
|
|
3667
|
+
}
|
|
3668
|
+
return -1;
|
|
3669
|
+
};
|
|
3670
|
+
const addTree = (newNode, patches) => {
|
|
3671
|
+
patches.push({
|
|
3672
|
+
type: Add,
|
|
3673
|
+
nodes: treeToArray(newNode)
|
|
3674
|
+
});
|
|
3675
|
+
};
|
|
3676
|
+
const replaceTree = (newNode, patches) => {
|
|
3677
|
+
patches.push({
|
|
3678
|
+
type: Replace,
|
|
3679
|
+
nodes: treeToArray(newNode)
|
|
3680
|
+
});
|
|
3681
|
+
};
|
|
3682
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
3683
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
3684
|
+
if (nodePatches === null) {
|
|
3685
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
3686
|
+
replaceTree(newNode, patches);
|
|
3687
|
+
return nextChildIndex;
|
|
3688
|
+
}
|
|
3689
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
3690
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
3691
|
+
return currentChildIndex;
|
|
3692
|
+
}
|
|
3693
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
3694
|
+
if (nodePatches.length > 0) {
|
|
3695
|
+
patches.push(...nodePatches);
|
|
3696
|
+
}
|
|
3697
|
+
if (hasChildrenToCompare) {
|
|
3698
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
3699
|
+
}
|
|
3700
|
+
return nextChildIndex;
|
|
3701
|
+
};
|
|
3702
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
3703
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
3704
|
+
if (nodePatches === null) {
|
|
3705
|
+
replaceTree(newNode, patches);
|
|
3706
|
+
return;
|
|
3707
|
+
}
|
|
3708
|
+
if (nodePatches.length > 0) {
|
|
3709
|
+
patches.push(...nodePatches);
|
|
3710
|
+
}
|
|
3711
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
3712
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
3713
|
+
}
|
|
3714
|
+
};
|
|
3715
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
3716
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
3717
|
+
let currentChildIndex = -1;
|
|
3718
|
+
const indicesToRemove = [];
|
|
3719
|
+
for (let i = 0; i < maxLength; i++) {
|
|
3720
|
+
const oldNode = oldChildren[i];
|
|
3721
|
+
const newNode = newChildren[i];
|
|
3722
|
+
if (!oldNode && !newNode) {
|
|
3723
|
+
continue;
|
|
3724
|
+
}
|
|
3725
|
+
if (!oldNode) {
|
|
3726
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
3727
|
+
addTree(newNode, patches);
|
|
3728
|
+
continue;
|
|
3729
|
+
}
|
|
3730
|
+
if (!newNode) {
|
|
3731
|
+
indicesToRemove.push(i);
|
|
3732
|
+
continue;
|
|
3733
|
+
}
|
|
3734
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
3735
|
+
}
|
|
3736
|
+
navigateToParent(patches, currentChildIndex);
|
|
3737
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
3738
|
+
patches.push({
|
|
3739
|
+
type: RemoveChild,
|
|
3740
|
+
index: indicesToRemove[j]
|
|
3741
|
+
});
|
|
3742
|
+
}
|
|
3743
|
+
};
|
|
3744
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
3745
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
3746
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
3747
|
+
return;
|
|
3748
|
+
}
|
|
3749
|
+
diffChildren(oldTree, newTree, patches);
|
|
3750
|
+
};
|
|
3751
|
+
|
|
3752
|
+
const removeTrailingNavigationPatches = patches => {
|
|
3753
|
+
// Find the last non-navigation patch
|
|
3754
|
+
let lastNonNavigationIndex = -1;
|
|
3755
|
+
for (let i = patches.length - 1; i >= 0; i--) {
|
|
3756
|
+
const patch = patches[i];
|
|
3757
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
3758
|
+
lastNonNavigationIndex = i;
|
|
3759
|
+
break;
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
// Return patches up to and including the last non-navigation patch
|
|
3763
|
+
return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
|
|
3764
|
+
};
|
|
3765
|
+
|
|
3766
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
3767
|
+
// Step 1: Convert flat arrays to tree structures
|
|
3768
|
+
const oldTree = arrayToTree(oldNodes);
|
|
3769
|
+
const newTree = arrayToTree(newNodes);
|
|
3770
|
+
// Step 3: Compare the trees
|
|
3771
|
+
const patches = [];
|
|
3772
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
3773
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
3774
|
+
return removeTrailingNavigationPatches(patches);
|
|
3775
|
+
};
|
|
3776
|
+
|
|
3513
3777
|
const state$6 = {
|
|
3778
|
+
instances: Object.create(null),
|
|
3779
|
+
renderedDoms: Object.create(null),
|
|
3514
3780
|
views: Object.create(null)
|
|
3515
3781
|
};
|
|
3516
3782
|
const getViewDisplay = view => {
|
|
@@ -3545,6 +3811,79 @@ const executeViewProvider = async id => {
|
|
|
3545
3811
|
}
|
|
3546
3812
|
return view.create();
|
|
3547
3813
|
};
|
|
3814
|
+
function assertVirtualDomViewInstance(id, instance) {
|
|
3815
|
+
if (!instance || typeof instance !== 'object') {
|
|
3816
|
+
throw new Error(`view ${id} did not return a view instance`);
|
|
3817
|
+
}
|
|
3818
|
+
if (typeof instance.render !== 'function') {
|
|
3819
|
+
throw new TypeError(`view ${id} instance is missing render function`);
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
const getVirtualDomInstance = uid => {
|
|
3823
|
+
const instance = state$6.instances[uid];
|
|
3824
|
+
if (!instance) {
|
|
3825
|
+
throw new Error(`view instance ${uid} not found`);
|
|
3826
|
+
}
|
|
3827
|
+
return instance;
|
|
3828
|
+
};
|
|
3829
|
+
const renderDom = async instance => {
|
|
3830
|
+
const dom = await instance.render();
|
|
3831
|
+
if (!Array.isArray(dom)) {
|
|
3832
|
+
throw new TypeError('view render result must be an array');
|
|
3833
|
+
}
|
|
3834
|
+
return dom;
|
|
3835
|
+
};
|
|
3836
|
+
const createViewInstance = async (viewId, uid, context) => {
|
|
3837
|
+
const view = state$6.views[viewId];
|
|
3838
|
+
if (!view) {
|
|
3839
|
+
throw new Error(`view ${viewId} not found`);
|
|
3840
|
+
}
|
|
3841
|
+
if (view.kind !== 'virtualDom') {
|
|
3842
|
+
throw new Error(`view ${viewId} is not a virtual dom view`);
|
|
3843
|
+
}
|
|
3844
|
+
const instance = await view.create({
|
|
3845
|
+
...context,
|
|
3846
|
+
uid,
|
|
3847
|
+
viewId
|
|
3848
|
+
});
|
|
3849
|
+
assertVirtualDomViewInstance(viewId, instance);
|
|
3850
|
+
state$6.instances[uid] = instance;
|
|
3851
|
+
const dom = await renderDom(instance);
|
|
3852
|
+
state$6.renderedDoms[uid] = dom;
|
|
3853
|
+
return {
|
|
3854
|
+
dom,
|
|
3855
|
+
type: 'setDom'
|
|
3856
|
+
};
|
|
3857
|
+
};
|
|
3858
|
+
const dispatchViewEvent = async (uid, event) => {
|
|
3859
|
+
const instance = getVirtualDomInstance(uid);
|
|
3860
|
+
if (typeof instance.handleEvent === 'function') {
|
|
3861
|
+
await instance.handleEvent(event);
|
|
3862
|
+
}
|
|
3863
|
+
const oldDom = state$6.renderedDoms[uid] || [];
|
|
3864
|
+
const newDom = await renderDom(instance);
|
|
3865
|
+
state$6.renderedDoms[uid] = newDom;
|
|
3866
|
+
const patches = diffTree(oldDom, newDom);
|
|
3867
|
+
return {
|
|
3868
|
+
patches,
|
|
3869
|
+
type: 'setPatches'
|
|
3870
|
+
};
|
|
3871
|
+
};
|
|
3872
|
+
const saveViewInstanceState = async uid => {
|
|
3873
|
+
const instance = getVirtualDomInstance(uid);
|
|
3874
|
+
if (typeof instance.saveState !== 'function') {
|
|
3875
|
+
return undefined;
|
|
3876
|
+
}
|
|
3877
|
+
return instance.saveState();
|
|
3878
|
+
};
|
|
3879
|
+
const disposeViewInstance = async uid => {
|
|
3880
|
+
const instance = state$6.instances[uid];
|
|
3881
|
+
if (instance && typeof instance.dispose === 'function') {
|
|
3882
|
+
await instance.dispose();
|
|
3883
|
+
}
|
|
3884
|
+
delete state$6.instances[uid];
|
|
3885
|
+
delete state$6.renderedDoms[uid];
|
|
3886
|
+
};
|
|
3548
3887
|
const getRegisteredViewIds$1 = () => {
|
|
3549
3888
|
return Object.values(state$6.views).map(view => view.id);
|
|
3550
3889
|
};
|
|
@@ -5393,7 +5732,11 @@ const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
|
5393
5732
|
const TextDocumentSyncIncremental = 'ExtensionHostTextDocument.syncIncremental';
|
|
5394
5733
|
const TextSearchExecuteTextSearchProvider = 'ExtensionHostTextSearch.executeTextSearchProvider';
|
|
5395
5734
|
const TypeDefinitionExecuteTypeDefinitionProvider = 'ExtensionHostTypeDefinition.executeTypeDefinitionProvider';
|
|
5735
|
+
const ViewCreateInstance = 'ExtensionHostView.createInstance';
|
|
5736
|
+
const ViewDispatchEvent = 'ExtensionHostView.dispatchEvent';
|
|
5737
|
+
const ViewDisposeInstance = 'ExtensionHostView.disposeInstance';
|
|
5396
5738
|
const ViewExecute = 'ExtensionHostView.execute';
|
|
5739
|
+
const ViewSaveInstanceState = 'ExtensionHostView.saveInstanceState';
|
|
5397
5740
|
const WorkspaceSetPath = 'Workspace.setWorkspacePath';
|
|
5398
5741
|
|
|
5399
5742
|
class ExecError extends Error {
|
|
@@ -6612,7 +6955,11 @@ const commandMap = {
|
|
|
6612
6955
|
[TextDocumentSyncIncremental]: syncIncremental,
|
|
6613
6956
|
[TextSearchExecuteTextSearchProvider]: executeTextSearchProvider,
|
|
6614
6957
|
[TypeDefinitionExecuteTypeDefinitionProvider]: executeTypeDefinitionProvider,
|
|
6958
|
+
[ViewCreateInstance]: createViewInstance,
|
|
6959
|
+
[ViewDispatchEvent]: dispatchViewEvent,
|
|
6960
|
+
[ViewDisposeInstance]: disposeViewInstance,
|
|
6615
6961
|
[ViewExecute]: executeViewProvider,
|
|
6962
|
+
[ViewSaveInstanceState]: saveViewInstanceState,
|
|
6616
6963
|
[WorkspaceSetPath]: setWorkspacePath,
|
|
6617
6964
|
'ExtensionHostDebug.evaluate': evaluate,
|
|
6618
6965
|
'ExtensionHostDebug.getCallStack': getCallStack,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { activate } from './parts/Activation/Activation.ts';
|
|
2
2
|
export { executeCommand } from './parts/ExecuteCommand/ExecuteCommand.ts';
|
|
3
3
|
export { showQuickPick } from './parts/QuickPick/QuickPick.ts';
|
|
4
|
+
export { getPreference, setPreference } from './parts/Preferences/Preferences.ts';
|
|
4
5
|
export { registerCommand } from './parts/CommandRegistry/CommandRegistry.ts';
|
|
5
6
|
export { executeCompletionProvider, executeResolveCompletionItemProvider, getCompletionProviderRegistrySnapshot, registerCompletionProvider, resetCompletionProviderRegistry, } from './parts/Completion/Completion.ts';
|
|
6
7
|
export { executeDiagnosticProvider, getDiagnosticProviderRegistrySnapshot, registerDiagnosticProvider, resetDiagnosticProviderRegistry, } from './parts/Diagnostic/Diagnostic.ts';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { activate } from "./parts/Activation/Activation.js";
|
|
2
2
|
export { executeCommand } from "./parts/ExecuteCommand/ExecuteCommand.js";
|
|
3
3
|
export { showQuickPick } from "./parts/QuickPick/QuickPick.js";
|
|
4
|
+
export { getPreference, setPreference } from "./parts/Preferences/Preferences.js";
|
|
4
5
|
export { registerCommand } from "./parts/CommandRegistry/CommandRegistry.js";
|
|
5
6
|
export { executeCompletionProvider, executeResolveCompletionItemProvider, getCompletionProviderRegistrySnapshot, registerCompletionProvider, resetCompletionProviderRegistry, } from "./parts/Completion/Completion.js";
|
|
6
7
|
export { executeDiagnosticProvider, getDiagnosticProviderRegistrySnapshot, registerDiagnosticProvider, resetDiagnosticProviderRegistry, } from "./parts/Diagnostic/Diagnostic.js";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { FileSystemWorker } from '@lvce-editor/rpc-registry';
|
|
1
|
+
import { ExtensionManagementWorker, FileSystemWorker } from '@lvce-editor/rpc-registry';
|
|
2
|
+
const MemfsPrefix = 'memfs://';
|
|
3
|
+
const isMemory = (uri) => {
|
|
4
|
+
return uri.startsWith(MemfsPrefix);
|
|
5
|
+
};
|
|
2
6
|
export const exists = async (uri) => {
|
|
3
7
|
return FileSystemWorker.exists(uri);
|
|
4
8
|
};
|
|
@@ -6,6 +10,9 @@ export const readDirWithFileTypes = async (uri) => {
|
|
|
6
10
|
return FileSystemWorker.readDirWithFileTypes(uri);
|
|
7
11
|
};
|
|
8
12
|
export const readFile = async (uri) => {
|
|
13
|
+
if (isMemory(uri)) {
|
|
14
|
+
return ExtensionManagementWorker.invoke('ExtensionApi.readFile', uri);
|
|
15
|
+
}
|
|
9
16
|
return FileSystemWorker.readFile(uri);
|
|
10
17
|
};
|
|
11
18
|
export const mkdir = async (uri) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExtensionManagementWorker } from '@lvce-editor/rpc-registry';
|
|
2
1
|
import { ExtensionApiError } from "../ExtensionApiError/ExtensionApiError.js";
|
|
3
2
|
const outputChannels = Object.create(null);
|
|
3
|
+
const outputChannelLogs = Object.create(null);
|
|
4
4
|
let isActivated = false;
|
|
5
5
|
const RE_DASH_CASE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
6
6
|
const assertOutputChannelId = (id) => {
|
|
@@ -23,19 +23,23 @@ class ExtensionOutputChannel {
|
|
|
23
23
|
}
|
|
24
24
|
async append(text) {
|
|
25
25
|
assertCanWrite(this.#id);
|
|
26
|
-
|
|
26
|
+
outputChannelLogs[this.#id] += text;
|
|
27
27
|
}
|
|
28
28
|
async appendLine(text) {
|
|
29
29
|
assertCanWrite(this.#id);
|
|
30
|
-
|
|
30
|
+
outputChannelLogs[this.#id] += `${text}\n`;
|
|
31
31
|
}
|
|
32
32
|
async clear() {
|
|
33
33
|
assertCanWrite(this.#id);
|
|
34
|
-
|
|
34
|
+
outputChannelLogs[this.#id] = '';
|
|
35
|
+
}
|
|
36
|
+
async getLogs() {
|
|
37
|
+
assertCanWrite(this.#id);
|
|
38
|
+
return outputChannelLogs[this.#id];
|
|
35
39
|
}
|
|
36
40
|
async replace(text) {
|
|
37
41
|
assertCanWrite(this.#id);
|
|
38
|
-
|
|
42
|
+
outputChannelLogs[this.#id] = text;
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
export const activateOutputChannels = () => {
|
|
@@ -49,6 +53,7 @@ export const createOutputChannel = (id) => {
|
|
|
49
53
|
outputChannels[id] = {
|
|
50
54
|
id,
|
|
51
55
|
};
|
|
56
|
+
outputChannelLogs[id] = '';
|
|
52
57
|
return new ExtensionOutputChannel(id);
|
|
53
58
|
};
|
|
54
59
|
export const getOutputChannelRegistrySnapshot = () => {
|
|
@@ -60,5 +65,8 @@ export const resetOutputChannelRegistry = () => {
|
|
|
60
65
|
for (const id of Object.keys(outputChannels)) {
|
|
61
66
|
delete outputChannels[id];
|
|
62
67
|
}
|
|
68
|
+
for (const id of Object.keys(outputChannelLogs)) {
|
|
69
|
+
delete outputChannelLogs[id];
|
|
70
|
+
}
|
|
63
71
|
isActivated = false;
|
|
64
72
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExtensionManagementWorker } from '@lvce-editor/rpc-registry';
|
|
2
|
+
export const getPreference = async (key) => {
|
|
3
|
+
return ExtensionManagementWorker.invoke('Extensions.getPreference', key);
|
|
4
|
+
};
|
|
5
|
+
export const setPreference = async (key, value) => {
|
|
6
|
+
await ExtensionManagementWorker.invoke('Extensions.setPreference', key, value);
|
|
7
|
+
};
|