@lvce-editor/api 8.28.0 → 8.29.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.
|
@@ -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
|
};
|