@lvce-editor/shared-process 0.85.1 → 0.85.3
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/index.js +27 -5
- package/package.json +2 -2
- package/src/parts/AppWindow/AppWindow.js +1 -1
- package/src/parts/BuiltinExtensionsPath/BuiltinExtensionsPath.js +1 -1
- package/src/parts/ElectronWindow/ElectronWindow.js +1 -1
- package/src/parts/ExportStatic/ExportStatic.js +73 -22
- package/src/parts/GetAppWindowOptions/GetAppWindowOptions.js +32 -4
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/PreloadUrl/PreloadUrl.js +1 -1
package/index.js
CHANGED
|
@@ -4,14 +4,36 @@ const __dirname = import.meta.dirname
|
|
|
4
4
|
|
|
5
5
|
export const sharedProcessPath = join(__dirname, 'src', 'sharedProcessMain.js')
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const toArray = (value) => {
|
|
8
|
+
if (!value) {
|
|
9
|
+
return []
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
return value
|
|
13
|
+
}
|
|
14
|
+
return [value]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const toAbsoluteExtensionPath = (root, extensionPath) => {
|
|
18
|
+
if (extensionPath && extensionPath !== root && !isAbsolute(extensionPath)) {
|
|
19
|
+
return join(root, extensionPath)
|
|
20
|
+
}
|
|
21
|
+
return extensionPath
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {{extensionPath?: string, extensionPaths?: string[] | string, testPath?: string, root?: string}} [options]
|
|
26
|
+
*/
|
|
27
|
+
export const exportStatic = async (options = {}) => {
|
|
28
|
+
const { extensionPath, extensionPaths = [], testPath = '', root = '' } = options
|
|
8
29
|
if (!root) {
|
|
9
30
|
throw new Error(`root argument is required`)
|
|
10
31
|
}
|
|
11
32
|
const fn = await import('./src/parts/ExportStatic/ExportStatic.js')
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
const extensionPathList = toArray(extensionPaths)
|
|
34
|
+
const defaultExtensionPath = extensionPath === undefined && extensionPathList.length === 0 ? process.cwd() : extensionPath
|
|
35
|
+
const absoluteExtensionPath = toAbsoluteExtensionPath(root, defaultExtensionPath)
|
|
36
|
+
const absoluteExtensionPaths = extensionPathList.map((extensionPath) => toAbsoluteExtensionPath(root, extensionPath))
|
|
15
37
|
const pathPrefix = process.env.PATH_PREFIX || ''
|
|
16
|
-
return fn.exportStatic({ root, pathPrefix, extensionPath, testPath })
|
|
38
|
+
return fn.exportStatic({ root, pathPrefix, extensionPath: absoluteExtensionPath, extensionPaths: absoluteExtensionPaths, testPath })
|
|
17
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.85.
|
|
3
|
+
"version": "0.85.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lvce-editor/assert": "1.6.0",
|
|
21
21
|
"@lvce-editor/auth-process": "1.6.0",
|
|
22
|
-
"@lvce-editor/extension-host-helper-process": "0.85.
|
|
22
|
+
"@lvce-editor/extension-host-helper-process": "0.85.3",
|
|
23
23
|
"@lvce-editor/ipc": "16.1.0",
|
|
24
24
|
"@lvce-editor/json-rpc": "8.1.0",
|
|
25
25
|
"@lvce-editor/jsonc-parser": "1.5.0",
|
|
@@ -7,7 +7,7 @@ import * as PreloadUrl from '../PreloadUrl/PreloadUrl.js';
|
|
|
7
7
|
import * as Screen from '../Screen/Screen.js';
|
|
8
8
|
export const createAppWindow = async ({ preferences, parsedArgs, workingDirectory, url = DefaultUrl.defaultUrl, preloadUrl }) => {
|
|
9
9
|
const { width, height } = await Screen.getBounds();
|
|
10
|
-
const windowOptions = GetAppWindowOptions.getAppWindowOptions({
|
|
10
|
+
const windowOptions = await GetAppWindowOptions.getAppWindowOptions({
|
|
11
11
|
preferences,
|
|
12
12
|
screenWidth: width,
|
|
13
13
|
screenHeight: height,
|
|
@@ -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', 'bbc1fd1', 'extensions');
|
|
6
6
|
return builtinExtensionsPath;
|
|
7
7
|
};
|
|
@@ -11,7 +11,7 @@ export const minimize = (windowId) => {
|
|
|
11
11
|
};
|
|
12
12
|
export const toggleDevtools = (windowId) => {
|
|
13
13
|
Assert.number(windowId);
|
|
14
|
-
return ParentIpc.invoke('ElectronWindow.
|
|
14
|
+
return ParentIpc.invoke('ElectronWindow.executeWindowFunction', windowId, 'toggleDevtools');
|
|
15
15
|
};
|
|
16
16
|
export const maximize = (windowId) => {
|
|
17
17
|
Assert.number(windowId);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
+
import { stripTypeScriptTypes } from 'node:module';
|
|
2
3
|
import { isAbsolute, join } from 'node:path';
|
|
3
4
|
import * as FileSystem from '../FileSystem/FileSystem.js';
|
|
4
5
|
import * as GetContentSecurityPolicy from '../GetContentSecurityPolicy/GetContentSecurityPolicy.js';
|
|
@@ -207,12 +208,14 @@ const addExtensionThemes = async ({ root, extensionPath, extensionJson, commitHa
|
|
|
207
208
|
}
|
|
208
209
|
for (const colorTheme of colorThemes) {
|
|
209
210
|
const { id, path } = colorTheme;
|
|
210
|
-
|
|
211
|
+
const extensionId = `builtin.theme-${id}`;
|
|
212
|
+
await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
|
|
213
|
+
await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
|
|
211
214
|
await FileSystem.copy(Path.join(extensionPath, path), Path.join(root, 'dist', commitHash, 'themes', `${id}.json`));
|
|
212
215
|
await replace(Path.join(root, 'dist', commitHash, 'config', 'defaultSettings.json'), `"workbench.colorTheme": "slime"`, `"workbench.colorTheme": "${id}"`);
|
|
213
|
-
await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions',
|
|
214
|
-
await FileSystem.copyFile(Path.join(extensionPath, 'extension.json'), Path.join(root, 'dist', commitHash, 'extensions',
|
|
215
|
-
await FileSystem.copyFile(Path.join(extensionPath, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'extensions',
|
|
216
|
+
await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'));
|
|
217
|
+
await FileSystem.copyFile(Path.join(extensionPath, 'extension.json'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'extension.json'));
|
|
218
|
+
await FileSystem.copyFile(Path.join(extensionPath, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'color-theme.json'));
|
|
216
219
|
}
|
|
217
220
|
const themesJson = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'));
|
|
218
221
|
const ids = colorThemes.map(getId);
|
|
@@ -276,6 +279,28 @@ const addExtensionLanguages = async ({ root, extensionPath, extensionJson, commi
|
|
|
276
279
|
await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'fileMap.json'), fileMap);
|
|
277
280
|
}
|
|
278
281
|
};
|
|
282
|
+
export const mergeExtensionManifests = (manifests, extraExtensions) => {
|
|
283
|
+
const replacements = Object.create(null);
|
|
284
|
+
for (const extension of extraExtensions) {
|
|
285
|
+
replacements[extension.id] = extension;
|
|
286
|
+
}
|
|
287
|
+
const used = Object.create(null);
|
|
288
|
+
const merged = manifests.map((manifest) => {
|
|
289
|
+
const replacement = replacements[manifest.id];
|
|
290
|
+
if (replacement) {
|
|
291
|
+
used[manifest.id] = true;
|
|
292
|
+
return replacement;
|
|
293
|
+
}
|
|
294
|
+
return manifest;
|
|
295
|
+
});
|
|
296
|
+
for (const extension of extraExtensions) {
|
|
297
|
+
if (used[extension.id]) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
merged.push(extension);
|
|
301
|
+
}
|
|
302
|
+
return merged;
|
|
303
|
+
};
|
|
279
304
|
const updateExtensionsJson = async ({ root, commitHash, pathPrefix, extraExtensions }) => {
|
|
280
305
|
const dirents = await FileSystem.readDir(Path.join(root, 'dist', commitHash, 'extensions'));
|
|
281
306
|
const manifests = await Promise.all(dirents.map(async (dirent) => {
|
|
@@ -286,10 +311,13 @@ const updateExtensionsJson = async ({ root, commitHash, pathPrefix, extraExtensi
|
|
|
286
311
|
path: webExtensionPath,
|
|
287
312
|
};
|
|
288
313
|
}));
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
314
|
+
const localExtensions = extraExtensions.map((extension) => {
|
|
315
|
+
return {
|
|
316
|
+
...extension,
|
|
317
|
+
path: `${pathPrefix}/${commitHash}/extensions/${extension.id}`,
|
|
318
|
+
};
|
|
319
|
+
});
|
|
320
|
+
const newExtensions = mergeExtensionManifests(manifests, localExtensions);
|
|
293
321
|
await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'extensions.json'), newExtensions);
|
|
294
322
|
};
|
|
295
323
|
const addExtensionWebExtension = async ({ root, extensionPath, commitHash, extensionJson, pathPrefix, useSimpleWebExtensionFile }) => {
|
|
@@ -311,6 +339,7 @@ const addExtensionWebExtension = async ({ root, extensionPath, commitHash, exten
|
|
|
311
339
|
},
|
|
312
340
|
];
|
|
313
341
|
await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'), webExtensions);
|
|
342
|
+
await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id));
|
|
314
343
|
for (const dirent of ['src', 'extension.json']) {
|
|
315
344
|
await FileSystem.copy(Path.join(extensionPath, dirent), Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id, dirent));
|
|
316
345
|
}
|
|
@@ -385,21 +414,15 @@ const isTestFile = (file) => {
|
|
|
385
414
|
const getTestFiles = (testFilesRaw) => {
|
|
386
415
|
return testFilesRaw.filter(isTestFile).map(getName);
|
|
387
416
|
};
|
|
388
|
-
const transpileFile = (
|
|
389
|
-
|
|
390
|
-
compilerOptions: {
|
|
391
|
-
target: 'esnext',
|
|
392
|
-
},
|
|
393
|
-
});
|
|
394
|
-
return result.outputText;
|
|
417
|
+
export const transpileFile = (content) => {
|
|
418
|
+
return stripTypeScriptTypes(content);
|
|
395
419
|
};
|
|
396
420
|
const transpileFiles = async (folder) => {
|
|
397
|
-
const typescript = await import('typescript');
|
|
398
421
|
const dirents = await readdir(folder);
|
|
399
422
|
for (const dirent of dirents) {
|
|
400
423
|
if (dirent.endsWith('.ts')) {
|
|
401
424
|
const content = await readFile(join(folder, dirent), 'utf-8');
|
|
402
|
-
const js = transpileFile(
|
|
425
|
+
const js = transpileFile(content);
|
|
403
426
|
await writeFile(join(folder, dirent.slice(0, -2) + 'js'), js);
|
|
404
427
|
}
|
|
405
428
|
}
|
|
@@ -499,21 +522,49 @@ const resolveServerStaticPath = (root) => {
|
|
|
499
522
|
}
|
|
500
523
|
throw new Error(`server static path not found`);
|
|
501
524
|
};
|
|
525
|
+
const toArray = (value) => {
|
|
526
|
+
if (!value) {
|
|
527
|
+
return [];
|
|
528
|
+
}
|
|
529
|
+
if (Array.isArray(value)) {
|
|
530
|
+
return value;
|
|
531
|
+
}
|
|
532
|
+
return [value];
|
|
533
|
+
};
|
|
534
|
+
const getExtensionPaths = (extensionPath, extensionPaths) => {
|
|
535
|
+
const seen = Object.create(null);
|
|
536
|
+
const allExtensionPaths = [];
|
|
537
|
+
for (const path of [...toArray(extensionPath), ...toArray(extensionPaths)]) {
|
|
538
|
+
if (!path || seen[path]) {
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
seen[path] = true;
|
|
542
|
+
allExtensionPaths.push(path);
|
|
543
|
+
}
|
|
544
|
+
return allExtensionPaths;
|
|
545
|
+
};
|
|
502
546
|
/**
|
|
503
547
|
*
|
|
504
|
-
* @param {{root:string, pathPrefix:string , extensionPath:string, testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string }} param0
|
|
548
|
+
* @param {{root:string, pathPrefix:string , extensionPath:string, extensionPaths?:string[], testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string }} param0
|
|
505
549
|
*/
|
|
506
|
-
export const exportStatic = async ({ root, pathPrefix, extensionPath, testPath, useSimpleWebExtensionFile, serverStaticPath }) => {
|
|
550
|
+
export const exportStatic = async ({ root, pathPrefix, extensionPath, extensionPaths, testPath, useSimpleWebExtensionFile, serverStaticPath }) => {
|
|
507
551
|
if (!existsSync(root)) {
|
|
508
552
|
throw new Error(`root path does not exist: ${root}`);
|
|
509
553
|
}
|
|
510
|
-
|
|
511
|
-
|
|
554
|
+
const allExtensionPaths = getExtensionPaths(extensionPath, extensionPaths);
|
|
555
|
+
for (const extensionPath of allExtensionPaths) {
|
|
556
|
+
if (!existsSync(extensionPath)) {
|
|
557
|
+
throw new Error(`extension path does not exist: ${extensionPath}`);
|
|
558
|
+
}
|
|
512
559
|
}
|
|
513
560
|
if (!serverStaticPath) {
|
|
514
561
|
serverStaticPath = resolveServerStaticPath(root);
|
|
515
562
|
}
|
|
516
563
|
if (pathPrefix === 'auto') {
|
|
564
|
+
if (allExtensionPaths.length === 0) {
|
|
565
|
+
throw new Error(`extension path is required when path prefix is auto`);
|
|
566
|
+
}
|
|
567
|
+
const [extensionPath] = allExtensionPaths;
|
|
517
568
|
const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'));
|
|
518
569
|
const { id } = extensionJson;
|
|
519
570
|
const [author, name] = id.split('.');
|
|
@@ -536,7 +587,7 @@ export const exportStatic = async ({ root, pathPrefix, extensionPath, testPath,
|
|
|
536
587
|
});
|
|
537
588
|
console.timeEnd('applyOverrides');
|
|
538
589
|
await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [] });
|
|
539
|
-
|
|
590
|
+
for (const extensionPath of allExtensionPaths) {
|
|
540
591
|
console.time('addExtension');
|
|
541
592
|
await addExtension({
|
|
542
593
|
extensionPath,
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import * as GetBrowserWindowOptions from '../GetBrowserWindowOptions/GetBrowserWindowOptions.js';
|
|
2
|
+
import * as ExtensionManagementColorTheme from '../ExtensionManagement/ExtensionManagementColorTheme.js';
|
|
2
3
|
import * as Platform from '../Platform/Platform.js';
|
|
3
|
-
|
|
4
|
+
const fallbackBackground = '#1e2324';
|
|
5
|
+
const fallbackSymbolColor = '#74b1be';
|
|
6
|
+
const getColor = (colors, keys, fallback) => {
|
|
7
|
+
for (const key of keys) {
|
|
8
|
+
if (colors[key]) {
|
|
9
|
+
return colors[key];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return fallback;
|
|
13
|
+
};
|
|
14
|
+
const getColorThemeJson = async (preferences) => {
|
|
15
|
+
const colorThemeId = preferences['workbench.colorTheme'];
|
|
16
|
+
if (!colorThemeId) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return await ExtensionManagementColorTheme.getColorThemeJson(colorThemeId);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const getAppWindowOptions = async ({ preferences, screenWidth, screenHeight, preloadUrl }) => {
|
|
27
|
+
const colorThemeJson = await getColorThemeJson(preferences);
|
|
28
|
+
const colors = colorThemeJson.colors && typeof colorThemeJson.colors === 'object' ? colorThemeJson.colors : {};
|
|
29
|
+
const background = getColor(colors, ['MainBackground'], fallbackBackground);
|
|
30
|
+
const titleBarBackground = getColor(colors, ['TitleBarActiveBackground', 'TitleBarBackground', 'MainBackground'], fallbackBackground);
|
|
31
|
+
const titleBarSymbolColor = getColor(colors, ['TitleBarForegroundActive', 'TitleBarForeground', 'TitleBarColor', 'TitleBarColorInactive'], fallbackSymbolColor);
|
|
4
32
|
const titleBarPreference = preferences['window.titleBarStyle'];
|
|
5
33
|
const frame = titleBarPreference !== 'custom';
|
|
6
34
|
const titleBarStyle = titleBarPreference === 'custom' ? 'hidden' : undefined;
|
|
@@ -9,8 +37,8 @@ export const getAppWindowOptions = ({ preferences, screenWidth, screenHeight, pr
|
|
|
9
37
|
const windowControlsOverlayPreference = (Platform.isWindows || Platform.isMacOs || Platform.isLinux) && preferences['window.controlsOverlay.enabled'];
|
|
10
38
|
const titleBarOverlay = windowControlsOverlayPreference
|
|
11
39
|
? {
|
|
12
|
-
color:
|
|
13
|
-
symbolColor:
|
|
40
|
+
color: titleBarBackground,
|
|
41
|
+
symbolColor: titleBarSymbolColor,
|
|
14
42
|
height: 29,
|
|
15
43
|
}
|
|
16
44
|
: undefined;
|
|
@@ -19,7 +47,7 @@ export const getAppWindowOptions = ({ preferences, screenWidth, screenHeight, pr
|
|
|
19
47
|
x: screenWidth - 800,
|
|
20
48
|
width: 800,
|
|
21
49
|
height: screenHeight,
|
|
22
|
-
background
|
|
50
|
+
background,
|
|
23
51
|
titleBarStyle,
|
|
24
52
|
frame,
|
|
25
53
|
titleBarOverlay,
|
|
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
|
|
|
41
41
|
export const getSetupName = () => {
|
|
42
42
|
return 'Lvce-Setup';
|
|
43
43
|
};
|
|
44
|
-
export const version = '0.85.
|
|
45
|
-
export const commit = '
|
|
46
|
-
export const date = '2026-07-
|
|
44
|
+
export const version = '0.85.3';
|
|
45
|
+
export const commit = 'bbc1fd1';
|
|
46
|
+
export const date = '2026-07-09T05:12:11.000Z';
|
|
47
47
|
export const getVersion = () => {
|
|
48
48
|
return version;
|
|
49
49
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import * as Root from '../Root/Root.js';
|
|
3
3
|
export const getPreloadUrl = () => {
|
|
4
|
-
return join(Root.root, 'static', '
|
|
4
|
+
return join(Root.root, 'static', 'bbc1fd1', 'packages', 'preload', 'dist', 'index.js');
|
|
5
5
|
};
|