@lvce-editor/shared-process 0.45.8 → 0.45.10
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 +3 -2
- package/src/parts/BuiltinExtensionsPath/BuiltinExtensionsPath.js +1 -1
- package/src/parts/FileWatcher/FileWatcher.ipc.js +1 -0
- package/src/parts/FileWatcher/FileWatcher.js +18 -23
- package/src/parts/FileWatcherProcess/FileWatcherProcess.js +18 -0
- package/src/parts/FileWatcherProcessPath/FileWatcherProcessPath.js +3 -0
- package/src/parts/LaunchFileWatcherProcess/LaunchFileWatcherProcess.js +17 -0
- package/src/parts/ModuleMap/ModuleMap.js +2 -0
- package/src/parts/Platform/Platform.ipc.js +1 -0
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/PlatformPaths/PlatformPaths.js +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.10",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lvce-editor/assert": "1.3.0",
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.45.
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.45.10",
|
|
22
22
|
"@lvce-editor/ipc": "13.7.0",
|
|
23
23
|
"@lvce-editor/json-rpc": "5.4.0",
|
|
24
24
|
"@lvce-editor/jsonc-parser": "1.5.0",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"@lvce-editor/preview-process": "7.22.0",
|
|
36
36
|
"@lvce-editor/pty-host": "3.1.0",
|
|
37
37
|
"@lvce-editor/search-process": "4.1.0",
|
|
38
|
+
"@lvce-editor/file-watcher-process": "1.4.0",
|
|
38
39
|
"@lvce-editor/typescript-compile-process": "2.3.0",
|
|
39
40
|
"open": "^10.1.0",
|
|
40
41
|
"tail": "^2.2.6",
|
|
@@ -2,6 +2,6 @@ import { join } from 'path';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
export const getBuiltinExtensionsPath = () => {
|
|
4
4
|
const staticServerPath = fileURLToPath(import.meta.resolve('@lvce-editor/static-server'));
|
|
5
|
-
const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '
|
|
5
|
+
const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', 'b53ee00', 'extensions');
|
|
6
6
|
return builtinExtensionsPath;
|
|
7
7
|
};
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as FileWatcherProcess from '../FileWatcherProcess/FileWatcherProcess.js';
|
|
2
|
+
import * as Id from '../Id/Id.js';
|
|
2
3
|
import * as JsonRpc from '../JsonRpc/JsonRpc.js';
|
|
3
|
-
const handleEvents =
|
|
4
|
-
|
|
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
|
-
}
|
|
4
|
+
const handleEvents = (id, ipc, event) => {
|
|
5
|
+
JsonRpc.send(ipc, 'FileWatcher.handleEvent', id, event);
|
|
13
6
|
};
|
|
14
|
-
//
|
|
7
|
+
// handle the case when multiple windows create a file watcher with same id, ids should not collide
|
|
8
|
+
// TODO remove ipc and dispose file watcher when socket / messageport closes
|
|
9
|
+
const internalIdMap = Object.create(null);
|
|
15
10
|
export const watch = async (ipc, id, { roots, exclude }) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
const internalId = Id.create();
|
|
12
|
+
internalIdMap[internalId] = { id, ipc };
|
|
13
|
+
await FileWatcherProcess.invoke('FileWatcher.watchFolders', {
|
|
14
|
+
id: internalId,
|
|
15
|
+
roots,
|
|
16
|
+
exclude,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export const handleChange = (event) => {
|
|
20
|
+
const ref = internalIdMap[event.id];
|
|
21
|
+
handleEvents(ref.id, ref.ipc, event);
|
|
27
22
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as JsonRpc from '../JsonRpc/JsonRpc.js';
|
|
2
|
+
import * as LaunchFileWatcherProcess from '../LaunchFileWatcherProcess/LaunchFileWatcherProcess.js';
|
|
3
|
+
export const state = {
|
|
4
|
+
/**
|
|
5
|
+
* @type {any}
|
|
6
|
+
*/
|
|
7
|
+
ipc: undefined,
|
|
8
|
+
};
|
|
9
|
+
export const getOrCreate = async () => {
|
|
10
|
+
if (!state.ipc) {
|
|
11
|
+
state.ipc = LaunchFileWatcherProcess.launchFileWatcherProcess();
|
|
12
|
+
}
|
|
13
|
+
return state.ipc;
|
|
14
|
+
};
|
|
15
|
+
export const invoke = async (method, ...params) => {
|
|
16
|
+
const ipc = await getOrCreate();
|
|
17
|
+
return JsonRpc.invoke(ipc, method, ...params);
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as FileWatcherProcessPath from '../FileWatcherProcessPath/FileWatcherProcessPath.js';
|
|
2
|
+
import * as HandleIpc from '../HandleIpc/HandleIpc.js';
|
|
3
|
+
import * as IpcParent from '../IpcParent/IpcParent.js';
|
|
4
|
+
import * as IpcParentType from '../IpcParentType/IpcParentType.js';
|
|
5
|
+
import * as IsElectron from '../IsElectron/IsElectron.js';
|
|
6
|
+
export const launchFileWatcherProcess = async () => {
|
|
7
|
+
const method = IsElectron.isElectron ? IpcParentType.ElectronUtilityProcess : IpcParentType.NodeForkedProcess;
|
|
8
|
+
const ipc = await IpcParent.create({
|
|
9
|
+
method,
|
|
10
|
+
path: FileWatcherProcessPath.fileWatcherProcessPath,
|
|
11
|
+
argv: [],
|
|
12
|
+
stdio: 'inherit',
|
|
13
|
+
name: 'File Watcher Process',
|
|
14
|
+
});
|
|
15
|
+
HandleIpc.handleIpc(ipc);
|
|
16
|
+
return ipc;
|
|
17
|
+
};
|
|
@@ -192,6 +192,7 @@ export const getModuleId = (commandId) => {
|
|
|
192
192
|
case 'Platform.getCacheDir':
|
|
193
193
|
case 'Platform.getCommit':
|
|
194
194
|
case 'Platform.getRoot':
|
|
195
|
+
case 'Platform.getRootUri':
|
|
195
196
|
case 'Platform.getConfigDir':
|
|
196
197
|
case 'Platform.getDataDir':
|
|
197
198
|
case 'Platform.getDate':
|
|
@@ -281,6 +282,7 @@ export const getModuleId = (commandId) => {
|
|
|
281
282
|
case 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess':
|
|
282
283
|
return ModuleId.HandleMessagePortForSearchProcess;
|
|
283
284
|
case 'FileWatcher.watch':
|
|
285
|
+
case 'FileWatcher.handleChange':
|
|
284
286
|
return ModuleId.FileWatcher;
|
|
285
287
|
case 'Transferrable.transfer':
|
|
286
288
|
return ModuleId.Transferrable;
|
|
@@ -12,6 +12,7 @@ export const Commands = {
|
|
|
12
12
|
getDataDir: PlatformPaths.getDataDir,
|
|
13
13
|
getDate: Platform.getDate,
|
|
14
14
|
getRoot: PlatformPaths.getRoot,
|
|
15
|
+
getRootUri: PlatformPaths.getRootUri,
|
|
15
16
|
getDisabledExtensionsPath: PlatformPaths.getDisabledExtensionsPath,
|
|
16
17
|
getDownloadDir: PlatformPaths.getDownloadDir,
|
|
17
18
|
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.
|
|
45
|
-
export const commit = '
|
|
46
|
-
export const date = '2025-
|
|
44
|
+
export const version = '0.45.10';
|
|
45
|
+
export const commit = 'b53ee00';
|
|
46
|
+
export const date = '2025-02-05T18:37:35.000Z';
|
|
47
47
|
export const getVersion = () => {
|
|
48
48
|
return version;
|
|
49
49
|
};
|
|
@@ -107,6 +107,12 @@ export const getDownloadDir = () => {
|
|
|
107
107
|
export const getRepository = () => {
|
|
108
108
|
return `lvce-editor/lvce-editor`;
|
|
109
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* @deprecated use getRootUri instead
|
|
112
|
+
*/
|
|
110
113
|
export const getRoot = () => {
|
|
111
114
|
return Root.root;
|
|
112
115
|
};
|
|
116
|
+
export const getRootUri = () => {
|
|
117
|
+
return pathToFileURL(Root.root).toString();
|
|
118
|
+
};
|