@lvce-editor/shared-process 0.43.4 → 0.44.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 +2 -2
- package/src/parts/BuiltinExtensionsPath/BuiltinExtensionsPath.js +1 -1
- package/src/parts/ExportStatic/ExportStatic.js +2 -2
- package/src/parts/ExtensionManagement/ExtensionManagement.ipc.js +1 -0
- package/src/parts/ExtensionManagement/ExtensionManagement.js +24 -0
- package/src/parts/ExtensionManagement/ExtensionManagementLanguages.js +1 -3
- package/src/parts/GetEtagFromStats/GetEtagFromStats.js +10 -0
- package/src/parts/GetExtensionEtags/GetExtensionEtags.js +51 -0
- package/src/parts/GetTestRequestResponse/GetTestRequestResponse.js +2 -0
- package/src/parts/HandleRequestTest/HandleRequestTest.js +1 -1
- package/src/parts/HttpServerResponse/HttpServerResponse.js +5 -1
- package/src/parts/ModuleMap/ModuleMap.js +1 -0
- package/src/parts/Platform/Platform.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
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.
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.44.0",
|
|
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",
|
|
@@ -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', 'ee6de50', 'extensions');
|
|
6
6
|
return builtinExtensionsPath;
|
|
7
7
|
};
|
|
@@ -95,13 +95,13 @@ const applyOverrides = async ({ root, commitHash, pathPrefix, serverStaticPath }
|
|
|
95
95
|
await applyOverridesRendererProcess({ root, commitHash, pathPrefix });
|
|
96
96
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), 'platform = Remote;', 'platform = Web$1;');
|
|
97
97
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
|
|
98
|
-
await replace(Path.join(root, 'dist', commitHash, 'packages', '
|
|
98
|
+
await replace(Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'), `return \`\${assetDir}/extensions/builtin.theme-\${colorThemeId}/color-theme.json\``, `return \`\${assetDir}/themes/\${colorThemeId}.json\``);
|
|
99
99
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
|
|
100
100
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'), `const platform = Remote`, `const platform = Web`);
|
|
101
101
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'iframe-worker', 'dist', 'iframeWorkerMain.js'), `const platform = Remote`, `const platform = Web`);
|
|
102
102
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'iframe-worker', 'dist', 'iframeWorkerMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
|
|
103
103
|
await replace(Path.join(root, 'dist', commitHash, 'packages', 'file-search-worker', 'dist', 'fileSearchWorkerMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
|
|
104
|
-
await replace(Path.join(root, 'dist', commitHash, 'packages', '
|
|
104
|
+
await replace(Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'), `return \`\${assetDir}/extensions/builtin.\${iconThemeId}/icon-theme.json\``, `return \`\${assetDir}/icon-themes/\${iconThemeId}.json\``);
|
|
105
105
|
const extensionDirents = await FileSystem.readDir(Path.join(serverStaticPath, commitHash, 'extensions'));
|
|
106
106
|
const languageBasicsDirents = extensionDirents.filter(isLanguageBasics);
|
|
107
107
|
const themeDirents = extensionDirents.filter(isTheme);
|
|
@@ -16,4 +16,5 @@ export const Commands = {
|
|
|
16
16
|
'ExtensionManagement.getAllExtensions': ExtensionManagement.getExtensions,
|
|
17
17
|
'ExtensionManagement.getExtensions': ExtensionManagement.getExtensions,
|
|
18
18
|
'ExtensionManagement.uninstall': ExtensionManagement.uninstall,
|
|
19
|
+
'ExtensionManagement.getExtensionsEtag': ExtensionManagement.getExtensionsEtag,
|
|
19
20
|
};
|
|
@@ -5,6 +5,8 @@ import * as ExtensionManifests from '../ExtensionManifests/ExtensionManifests.js
|
|
|
5
5
|
import * as Path from '../Path/Path.js';
|
|
6
6
|
import * as BuiltinExtensionsPath from '../BuiltinExtensionsPath/BuiltinExtensionsPath.js';
|
|
7
7
|
import * as PlatformPaths from '../PlatformPaths/PlatformPaths.js';
|
|
8
|
+
import * as GetExtensionEtags from '../GetExtensionEtags/GetExtensionEtags.js';
|
|
9
|
+
import * as GetEtagFromStats from '../GetEtagFromStats/GetEtagFromStats.js';
|
|
8
10
|
import { VError } from '../VError/VError.js';
|
|
9
11
|
export const enable = async (id) => {
|
|
10
12
|
try {
|
|
@@ -66,6 +68,28 @@ export const getExtensions = () => {
|
|
|
66
68
|
},
|
|
67
69
|
], BuiltinExtensionsPath.getBuiltinExtensionsPath());
|
|
68
70
|
};
|
|
71
|
+
export const getExtensionsEtag = async () => {
|
|
72
|
+
const stats = await GetExtensionEtags.getExtensionEtags([
|
|
73
|
+
{
|
|
74
|
+
type: ExtensionManifestInputType.OnlyExtension,
|
|
75
|
+
path: PlatformPaths.getOnlyExtensionPath(),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: ExtensionManifestInputType.Folder,
|
|
79
|
+
path: PlatformPaths.getLinkedExtensionsPath(),
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: ExtensionManifestInputType.Folder,
|
|
83
|
+
path: PlatformPaths.getExtensionsPath(),
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: ExtensionManifestInputType.Folder,
|
|
87
|
+
path: BuiltinExtensionsPath.getBuiltinExtensionsPath(),
|
|
88
|
+
},
|
|
89
|
+
]);
|
|
90
|
+
const etag = GetEtagFromStats.getEtagFromStats(stats);
|
|
91
|
+
return etag;
|
|
92
|
+
};
|
|
69
93
|
export const getDisabledExtensions = () => {
|
|
70
94
|
return ExtensionManifests.getAll([
|
|
71
95
|
{
|
|
@@ -35,9 +35,7 @@ const getLanguagesFromExtensions = (extensions) => {
|
|
|
35
35
|
return extensions.flatMap(getLanguagesFromExtension);
|
|
36
36
|
};
|
|
37
37
|
export const getLanguages = async () => {
|
|
38
|
-
|
|
39
|
-
const languages = getLanguagesFromExtensions(extensions);
|
|
40
|
-
return languages;
|
|
38
|
+
throw new Error('deprecated');
|
|
41
39
|
};
|
|
42
40
|
export const getWebViews = async () => {
|
|
43
41
|
const extensions = await ExtensionManagement.getExtensions();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
export const getEtagFromStats = (stats) => {
|
|
3
|
+
const hash = createHash('sha1');
|
|
4
|
+
for (const stat of stats) {
|
|
5
|
+
hash.update(`${stat.mtime}`);
|
|
6
|
+
hash.update(`${stat.size}`);
|
|
7
|
+
}
|
|
8
|
+
const finalHash = hash.digest('hex');
|
|
9
|
+
return finalHash;
|
|
10
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import * as ExtensionManifestInputType from '../ExtensionManifestInputType/ExtensionManifestInputType.js';
|
|
4
|
+
import * as IsEnoentError from '../IsEnoentError/IsEnoentError.js';
|
|
5
|
+
const serializeStats = (stats) => {
|
|
6
|
+
const { mtime, size } = stats;
|
|
7
|
+
return {
|
|
8
|
+
mtime,
|
|
9
|
+
size,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const getOnly = async (path) => {
|
|
13
|
+
if (!path) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const absolutePath = join(path, 'extension.json');
|
|
17
|
+
const stats = await stat(absolutePath);
|
|
18
|
+
return [serializeStats(stats)];
|
|
19
|
+
};
|
|
20
|
+
const getFolder = async (path) => {
|
|
21
|
+
try {
|
|
22
|
+
const dirents = await readdir(path);
|
|
23
|
+
const stats = await Promise.all(dirents.map(async (dirent) => {
|
|
24
|
+
const extensionManifestPath = join(path, dirent, 'extension.json');
|
|
25
|
+
const direntStats = await stat(extensionManifestPath);
|
|
26
|
+
return serializeStats(direntStats);
|
|
27
|
+
}));
|
|
28
|
+
return stats;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (IsEnoentError.isEnoentError(error)) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const get = (input) => {
|
|
37
|
+
switch (input.type) {
|
|
38
|
+
case ExtensionManifestInputType.Folder:
|
|
39
|
+
case ExtensionManifestInputType.LinkedExtensionsFolder:
|
|
40
|
+
return getFolder(input.path);
|
|
41
|
+
case ExtensionManifestInputType.OnlyExtension:
|
|
42
|
+
return getOnly(input.path);
|
|
43
|
+
default:
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export const getExtensionEtags = async (inputs) => {
|
|
48
|
+
const stats = await Promise.all(inputs.map(get));
|
|
49
|
+
const flatStats = stats.flat(1);
|
|
50
|
+
return flatStats;
|
|
51
|
+
};
|
|
@@ -10,6 +10,7 @@ import * as GetContentResponse from '../GetContentResponse/GetContentResponse.js
|
|
|
10
10
|
import * as GetMultipleChoiceResponse from '../GetMultipleChoiceResponse/GetMultipleChoiceResponse.js';
|
|
11
11
|
import * as GetPathName from '../GetPathName/GetPathName.js';
|
|
12
12
|
import * as GetTestPath from '../GetTestPath/GetTestPath.js';
|
|
13
|
+
import * as GetNotFoundResponse from '../GetNotFoundResponse/GetNotFoundResponse.js';
|
|
13
14
|
import * as HttpHeader from '../HttpHeader/HttpHeader.js';
|
|
14
15
|
import * as HttpStatusCode from '../HttpStatusCode/HttpStatusCode.js';
|
|
15
16
|
import * as Logger from '../Logger/Logger.js';
|
|
@@ -38,6 +39,7 @@ export const getTestRequestResponse = async (request, indexHtmlPath) => {
|
|
|
38
39
|
};
|
|
39
40
|
return GetMultipleChoiceResponse.getMultipleChoiceResponse(body, headers);
|
|
40
41
|
}
|
|
42
|
+
return GetNotFoundResponse.getNotFoundResponse();
|
|
41
43
|
}
|
|
42
44
|
catch (error) {
|
|
43
45
|
Logger.error(error);
|
|
@@ -6,5 +6,5 @@ export const handleRequestTest = async (socket, request, indexHtmlPath) => {
|
|
|
6
6
|
Assert.object(request);
|
|
7
7
|
Assert.string(indexHtmlPath);
|
|
8
8
|
const result = await GetTestRequestResponse.getTestRequestResponse(request, indexHtmlPath);
|
|
9
|
-
HttpServerResponse.send(request, socket, result);
|
|
9
|
+
await HttpServerResponse.send(request, socket, result);
|
|
10
10
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServerResponse } from 'node:http';
|
|
2
2
|
import * as Assert from '../Assert/Assert.js';
|
|
3
3
|
import * as SetHeaders from '../SetHeaders/SetHeaders.js';
|
|
4
|
-
export const send = (request, socket, result) => {
|
|
4
|
+
export const send = async (request, socket, result) => {
|
|
5
5
|
Assert.object(request);
|
|
6
6
|
Assert.object(socket);
|
|
7
7
|
Assert.object(result);
|
|
@@ -12,5 +12,9 @@ export const send = (request, socket, result) => {
|
|
|
12
12
|
...result.init.headers,
|
|
13
13
|
Connection: 'close',
|
|
14
14
|
});
|
|
15
|
+
// TODO use promises if possible
|
|
16
|
+
socket.on('error', (error) => {
|
|
17
|
+
console.error(`[shared-process] Failed to send response ${error}`);
|
|
18
|
+
});
|
|
15
19
|
response.end(result.body);
|
|
16
20
|
};
|
|
@@ -129,6 +129,7 @@ export const getModuleId = (commandId) => {
|
|
|
129
129
|
case 'ExtensionManagement.getExtensions':
|
|
130
130
|
case 'ExtensionManagement.install':
|
|
131
131
|
case 'ExtensionManagement.uninstall':
|
|
132
|
+
case 'ExtensionManagement.getExtensionsEtag':
|
|
132
133
|
return ModuleId.ExtensionManagement;
|
|
133
134
|
case 'FileSystem.chmod':
|
|
134
135
|
case 'FileSystem.copy':
|
|
@@ -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 = '2025-01-
|
|
44
|
+
export const version = '0.44.0';
|
|
45
|
+
export const commit = 'ee6de50';
|
|
46
|
+
export const date = '2025-01-05T12:49:34.000Z';
|
|
47
47
|
export const getVersion = () => {
|
|
48
48
|
return version;
|
|
49
49
|
};
|