@lvce-editor/shared-process 0.29.7 → 0.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/package.json +6 -6
- package/src/parts/ExportStatic/ExportStatic.js +7 -4
- package/src/parts/FileWatcher/FileWatcher.ipc.js +5 -0
- package/src/parts/FileWatcher/FileWatcher.js +27 -0
- package/src/parts/HandleIpcFileWatcher/HandleIpcFileWatcher.js +24 -0
- package/src/parts/HandleWebSocket/HandleWebSocket.js +2 -2
- package/src/parts/HandleWebSocketModule/HandleWebSocketModule.js +10 -5
- package/src/parts/IsIgnoredError/IsIgnoredError.js +4 -0
- package/src/parts/LaunchTypeScriptCompileProcess/LaunchTypeScriptCompileProcess.js +4 -0
- package/src/parts/Module/Module.js +2 -0
- package/src/parts/ModuleId/ModuleId.js +1 -0
- package/src/parts/ModuleMap/ModuleMap.js +3 -0
- package/src/parts/Platform/Platform.ipc.js +1 -0
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/PlatformPaths/PlatformPaths.js +3 -0
- package/src/parts/RequiresSocket/RequiresSocket.js +1 -0
- package/src/parts/TypeScriptCompileProcessPath/TypeScriptCompileProcessPath.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lvce-editor/assert": "^1.2.0",
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.
|
|
22
|
-
"@lvce-editor/ipc": "^9.
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.30.0",
|
|
22
|
+
"@lvce-editor/ipc": "^9.2.0",
|
|
23
23
|
"@lvce-editor/json-rpc": "^1.3.0",
|
|
24
|
-
"@lvce-editor/jsonc-parser": "^1.
|
|
24
|
+
"@lvce-editor/jsonc-parser": "^1.4.0",
|
|
25
25
|
"@lvce-editor/pretty-error": "^1.5.0",
|
|
26
26
|
"@lvce-editor/verror": "^1.3.0",
|
|
27
27
|
"debug": "^4.3.5",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"@lvce-editor/network-process": "^1.2.0",
|
|
33
33
|
"@lvce-editor/preload": "^1.3.0",
|
|
34
34
|
"@lvce-editor/search-process": "^1.2.0",
|
|
35
|
+
"@lvce-editor/typescript-compile-process": "^1.2.0",
|
|
35
36
|
"@lvce-editor/pty-host": "^1.2.0",
|
|
36
37
|
"@lvce-editor/embeds-process": "^1.5.0",
|
|
37
38
|
"open": "^10.1.0",
|
|
38
39
|
"tail": "^2.2.6",
|
|
39
40
|
"tmp-promise": "^3.0.3",
|
|
40
|
-
"trash": "^8.1.1"
|
|
41
|
-
"@lvce-editor/typescript-compile-process": "0.29.7"
|
|
41
|
+
"trash": "^8.1.1"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -76,9 +76,12 @@ const clean = async (root) => {
|
|
|
76
76
|
const copyStaticFiles = async (root, commitHash) => {
|
|
77
77
|
await FileSystem.copy(Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static'), Path.join(root, 'dist'));
|
|
78
78
|
};
|
|
79
|
-
const
|
|
80
|
-
await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'), 'platform =
|
|
79
|
+
const applyOverridesRendererProcess = async ({ root, commitHash, pathPrefix }) => {
|
|
80
|
+
await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'), 'platform = Remote;', 'platform = Web');
|
|
81
81
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
|
|
82
|
+
};
|
|
83
|
+
const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
|
|
84
|
+
await applyOverridesRendererProcess({ root, commitHash, pathPrefix });
|
|
82
85
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), 'platform = Remote;', 'platform = Web$1;');
|
|
83
86
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
|
|
84
87
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), `return \`\${assetDir}/extensions/builtin.theme-\${colorThemeId}/color-theme.json\``, `return \`\${assetDir}/themes/\${colorThemeId}.json\``);
|
|
@@ -138,11 +141,11 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
|
|
|
138
141
|
}
|
|
139
142
|
};
|
|
140
143
|
const addExtensionSeo = async ({ root, name, description, commitHash }) => {
|
|
141
|
-
await replace(Path.join(root, 'dist', 'index.html'), '<title>
|
|
144
|
+
await replace(Path.join(root, 'dist', 'index.html'), '<title>Lvce Editor</title>', `<title>${name}</title>`);
|
|
142
145
|
await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"name": "Code Editor Web - OSS"`, `"name": "${name}"`);
|
|
143
146
|
await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"short_name": "Web - OSS"`, `"short_name": "${name}"`);
|
|
144
147
|
await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"description": "Web Code Editor."`, `"description": "${description}"`);
|
|
145
|
-
await replace(Path.join(root, 'dist', 'index.html'), '<meta name="description" content="
|
|
148
|
+
await replace(Path.join(root, 'dist', 'index.html'), '<meta name="description" content="VS Code inspired text editor that mostly runs in a webworker." />', `<meta name="description" content="${description}" />`);
|
|
146
149
|
};
|
|
147
150
|
const getId = (object) => {
|
|
148
151
|
return object.id;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as JsonRpc from '../JsonRpc/JsonRpc.js';
|
|
3
|
+
const handleEvents = async (watcher, id, ipc) => {
|
|
4
|
+
try {
|
|
5
|
+
for await (const event of watcher) {
|
|
6
|
+
JsonRpc.send(ipc, 'FileWatcher.handleEvent', id, event);
|
|
7
|
+
// ipc.send('FileWatcher.handleEvent', id, event)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
console.log('event error', error);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
// TODO run file watcher in a separate process to not crash application when file watcher crashes
|
|
15
|
+
export const watch = async (ipc, id, { roots, exclude }) => {
|
|
16
|
+
try {
|
|
17
|
+
for (const root of roots) {
|
|
18
|
+
const watcher = fs.watch(root, {
|
|
19
|
+
recursive: true,
|
|
20
|
+
});
|
|
21
|
+
handleEvents(watcher, id, ipc);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error(error);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as PtyHost from '../PtyHost/PtyHost.js';
|
|
2
|
+
import * as IpcParentType from '../IpcParentType/IpcParentType.js';
|
|
3
|
+
export const targetWebSocket = () => {
|
|
4
|
+
return PtyHost.getOrCreate(IpcParentType.NodeForkedProcess);
|
|
5
|
+
};
|
|
6
|
+
export const upgradeWebSocket = (handle, message) => {
|
|
7
|
+
return {
|
|
8
|
+
type: 'send',
|
|
9
|
+
method: 'HandleWebSocket.handleWebSocket',
|
|
10
|
+
params: [message],
|
|
11
|
+
transfer: handle,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export const targetMessagePort = () => {
|
|
15
|
+
return PtyHost.getOrCreate(IpcParentType.ElectronUtilityProcess);
|
|
16
|
+
};
|
|
17
|
+
export const upgradeMessagePort = (port) => {
|
|
18
|
+
return {
|
|
19
|
+
type: 'send',
|
|
20
|
+
method: 'HandleElectronMessagePort.handleElectronMessagePort',
|
|
21
|
+
params: [],
|
|
22
|
+
transfer: [port],
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -10,8 +10,8 @@ export const handleWebSocket = async (handle, message) => {
|
|
|
10
10
|
const { url } = message;
|
|
11
11
|
const type = GetTypeFromUrl.getTypeFromUrl(url);
|
|
12
12
|
handle.pause();
|
|
13
|
-
const module =
|
|
14
|
-
|
|
13
|
+
const module = HandleWebSocketModule.load(type);
|
|
14
|
+
module.handleWebSocket(message, handle, type);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
17
|
DestroyWebSocket.destroySocket(handle);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import * as HandleWebSocketForExtensionHostHelperProcess from '../HandleWebSocketForExtensionHostHelperProcess/HandleWebSocketForExtensionHostHelperProcess.js';
|
|
2
|
+
import * as HandleWebSocketForSearchProcess from '../HandleWebSocketForSearchProcess/HandleWebSocketForSearchProcess.js';
|
|
3
|
+
import * as HandleWebSocketForSharedProcess from '../HandleWebSocketForSharedProcess/HandleWebSocketForSharedProcess.js';
|
|
4
|
+
import * as HandleWebSocketForTerminalProcess from '../HandleWebSocketForTerminalProcess/HandleWebSocketForTerminalProcess.js';
|
|
5
|
+
import * as HandleWebSocketForUnknown from '../HandleWebSocketForUnknown/HandleWebSocketForUnknown.js';
|
|
1
6
|
import * as ProtocolType from '../ProtocolType/ProtocolType.js';
|
|
2
7
|
import { VError } from '../VError/VError.js';
|
|
3
8
|
export const load = (protocol) => {
|
|
@@ -6,14 +11,14 @@ export const load = (protocol) => {
|
|
|
6
11
|
}
|
|
7
12
|
switch (protocol) {
|
|
8
13
|
case ProtocolType.SharedProcess:
|
|
9
|
-
return
|
|
14
|
+
return HandleWebSocketForSharedProcess;
|
|
10
15
|
case ProtocolType.ExtensionHostHelperProcess:
|
|
11
|
-
return
|
|
16
|
+
return HandleWebSocketForExtensionHostHelperProcess;
|
|
12
17
|
case ProtocolType.TerminalProcess:
|
|
13
|
-
return
|
|
18
|
+
return HandleWebSocketForTerminalProcess;
|
|
14
19
|
case ProtocolType.SearchProcess:
|
|
15
|
-
return
|
|
20
|
+
return HandleWebSocketForSearchProcess;
|
|
16
21
|
default:
|
|
17
|
-
return
|
|
22
|
+
return HandleWebSocketForUnknown;
|
|
18
23
|
}
|
|
19
24
|
};
|
|
@@ -9,5 +9,9 @@ export const isIgnoredError = (error) => {
|
|
|
9
9
|
// parent process is disposed, ignore
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
12
|
+
if (error && error.code === ErrorCodes.ECONNRESET) {
|
|
13
|
+
// TODO investigate why this error occurs sometimes when reloading the page
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
12
16
|
return false;
|
|
13
17
|
};
|
|
@@ -2,6 +2,8 @@ import * as HandleIpc from '../HandleIpc/HandleIpc.js';
|
|
|
2
2
|
import * as IpcParent from '../IpcParent/IpcParent.js';
|
|
3
3
|
import * as IpcParentType from '../IpcParentType/IpcParentType.js';
|
|
4
4
|
import * as IsElectron from '../IsElectron/IsElectron.js';
|
|
5
|
+
import * as GetTypeScriptPath from '../GetTypeScriptPath/GetTypeScriptPath.js';
|
|
6
|
+
import * as JsonRpc from '../JsonRpc/JsonRpc.js';
|
|
5
7
|
export const launchTypeScriptCompileProcess = async () => {
|
|
6
8
|
const method = IsElectron.isElectron ? IpcParentType.ElectronUtilityProcess : IpcParentType.NodeForkedProcess;
|
|
7
9
|
const TypeScriptCompileProcessPath = await import('../TypeScriptCompileProcessPath/TypeScriptCompileProcessPath.js');
|
|
@@ -13,5 +15,7 @@ export const launchTypeScriptCompileProcess = async () => {
|
|
|
13
15
|
name: 'TypeScript Compile Process',
|
|
14
16
|
});
|
|
15
17
|
HandleIpc.handleIpc(typescriptCompileProcess);
|
|
18
|
+
const typeScriptPath = GetTypeScriptPath.getTypeScriptUri();
|
|
19
|
+
await JsonRpc.invoke(typescriptCompileProcess, 'TypeScript.setTypeScriptPath', typeScriptPath);
|
|
16
20
|
return typescriptCompileProcess;
|
|
17
21
|
};
|
|
@@ -127,6 +127,8 @@ export const load = (moduleId) => {
|
|
|
127
127
|
return import('../HandleMessagePortForProcessExplorer/HandleMessagePortForProcessExplorer.ipc.js');
|
|
128
128
|
case ModuleId.HandleMessagePortForSearchProcess:
|
|
129
129
|
return import('../HandleMessagePortForSearchProcess/HandleMessagePortForSearchProcess.ipc.js');
|
|
130
|
+
case ModuleId.FileWatcher:
|
|
131
|
+
return import('../FileWatcher/FileWatcher.ipc.js');
|
|
130
132
|
default:
|
|
131
133
|
throw new Error(`module ${moduleId} not found`);
|
|
132
134
|
}
|
|
@@ -185,6 +185,7 @@ export const getModuleId = (commandId) => {
|
|
|
185
185
|
case 'Platform.getCachedExtensionsPath':
|
|
186
186
|
case 'Platform.getCacheDir':
|
|
187
187
|
case 'Platform.getCommit':
|
|
188
|
+
case 'Platform.getRoot':
|
|
188
189
|
case 'Platform.getConfigDir':
|
|
189
190
|
case 'Platform.getDataDir':
|
|
190
191
|
case 'Platform.getDate':
|
|
@@ -273,6 +274,8 @@ export const getModuleId = (commandId) => {
|
|
|
273
274
|
return ModuleId.HandleMessagePortForProcessExplorer;
|
|
274
275
|
case 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess':
|
|
275
276
|
return ModuleId.HandleMessagePortForSearchProcess;
|
|
277
|
+
case 'FileWatcher.watch':
|
|
278
|
+
return ModuleId.FileWatcher;
|
|
276
279
|
default:
|
|
277
280
|
throw new CommandNotFoundError(commandId);
|
|
278
281
|
}
|
|
@@ -11,6 +11,7 @@ export const Commands = {
|
|
|
11
11
|
getConfigDir: PlatformPaths.getConfigDir,
|
|
12
12
|
getDataDir: PlatformPaths.getDataDir,
|
|
13
13
|
getDate: Platform.getDate,
|
|
14
|
+
getRoot: PlatformPaths.getRoot,
|
|
14
15
|
getDisabledExtensionsPath: PlatformPaths.getDisabledExtensionsPath,
|
|
15
16
|
getDownloadDir: PlatformPaths.getDownloadDir,
|
|
16
17
|
getExtensionsPath: PlatformPaths.getExtensionsPath,
|
|
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
|
|
|
41
41
|
export const getSetupName = () => {
|
|
42
42
|
return 'Lvce-Setup';
|
|
43
43
|
};
|
|
44
|
-
export const version = '0.
|
|
45
|
-
export const commit = '
|
|
46
|
-
export const date = '2024-
|
|
44
|
+
export const version = '0.30.0';
|
|
45
|
+
export const commit = '1d13af6';
|
|
46
|
+
export const date = '2024-06-13T18:16:21.000Z';
|
|
47
47
|
export const getVersion = () => {
|
|
48
48
|
return version;
|
|
49
49
|
};
|
|
@@ -13,6 +13,7 @@ const METHODS_THAT_REQUIRE_SOCKET = new Set([
|
|
|
13
13
|
'HandleMessagePortForExtensionHostHelperProcess.handleMessagePortForExtensionHostHelperProcess',
|
|
14
14
|
'ElectronBrowserView.createBrowserView',
|
|
15
15
|
'ElectronWebContentsView.createWebContentsView',
|
|
16
|
+
'FileWatcher.watch',
|
|
16
17
|
]);
|
|
17
18
|
export const requiresSocket = (method) => {
|
|
18
19
|
return METHODS_THAT_REQUIRE_SOCKET.has(method);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as ResolveBin from '../ResolveBin/ResolveBin.js';
|
|
2
|
+
export const typescriptCompileProcessPath = ResolveBin.resolveBin('@lvce-editor/typescript-compile-process');
|