@lvce-editor/shared-process 0.85.0 → 0.85.2

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 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
- export const exportStatic = async ({ extensionPath = process.cwd(), testPath = '', root = '' } = {}) => {
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
- if (extensionPath && extensionPath !== root && !isAbsolute(extensionPath)) {
13
- extensionPath = join(root, extensionPath)
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.0",
3
+ "version": "0.85.2",
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.0",
22
+ "@lvce-editor/extension-host-helper-process": "0.85.2",
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', '6759a60', 'extensions');
5
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '400933e', 'extensions');
6
6
  return builtinExtensionsPath;
7
7
  };
@@ -207,12 +207,14 @@ const addExtensionThemes = async ({ root, extensionPath, extensionJson, commitHa
207
207
  }
208
208
  for (const colorTheme of colorThemes) {
209
209
  const { id, path } = colorTheme;
210
- await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', `builtin.theme-${id}`));
210
+ const extensionId = `builtin.theme-${id}`;
211
+ await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
212
+ await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId));
211
213
  await FileSystem.copy(Path.join(extensionPath, path), Path.join(root, 'dist', commitHash, 'themes', `${id}.json`));
212
214
  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', `builtin.theme-${id}`, 'README.md'));
214
- await FileSystem.copyFile(Path.join(extensionPath, 'extension.json'), Path.join(root, 'dist', commitHash, 'extensions', `builtin.theme-${id}`, 'extension.json'));
215
- await FileSystem.copyFile(Path.join(extensionPath, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'extensions', `builtin.theme-${id}`, 'color-theme.json'));
215
+ await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'));
216
+ await FileSystem.copyFile(Path.join(extensionPath, 'extension.json'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'extension.json'));
217
+ await FileSystem.copyFile(Path.join(extensionPath, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'color-theme.json'));
216
218
  }
217
219
  const themesJson = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'));
218
220
  const ids = colorThemes.map(getId);
@@ -276,6 +278,28 @@ const addExtensionLanguages = async ({ root, extensionPath, extensionJson, commi
276
278
  await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'fileMap.json'), fileMap);
277
279
  }
278
280
  };
281
+ export const mergeExtensionManifests = (manifests, extraExtensions) => {
282
+ const replacements = Object.create(null);
283
+ for (const extension of extraExtensions) {
284
+ replacements[extension.id] = extension;
285
+ }
286
+ const used = Object.create(null);
287
+ const merged = manifests.map((manifest) => {
288
+ const replacement = replacements[manifest.id];
289
+ if (replacement) {
290
+ used[manifest.id] = true;
291
+ return replacement;
292
+ }
293
+ return manifest;
294
+ });
295
+ for (const extension of extraExtensions) {
296
+ if (used[extension.id]) {
297
+ continue;
298
+ }
299
+ merged.push(extension);
300
+ }
301
+ return merged;
302
+ };
279
303
  const updateExtensionsJson = async ({ root, commitHash, pathPrefix, extraExtensions }) => {
280
304
  const dirents = await FileSystem.readDir(Path.join(root, 'dist', commitHash, 'extensions'));
281
305
  const manifests = await Promise.all(dirents.map(async (dirent) => {
@@ -286,10 +310,13 @@ const updateExtensionsJson = async ({ root, commitHash, pathPrefix, extraExtensi
286
310
  path: webExtensionPath,
287
311
  };
288
312
  }));
289
- for (const extension of extraExtensions) {
290
- extension.path = `${pathPrefix}/${commitHash}/extensions/${extension.id}`;
291
- }
292
- const newExtensions = [...manifests, ...extraExtensions];
313
+ const localExtensions = extraExtensions.map((extension) => {
314
+ return {
315
+ ...extension,
316
+ path: `${pathPrefix}/${commitHash}/extensions/${extension.id}`,
317
+ };
318
+ });
319
+ const newExtensions = mergeExtensionManifests(manifests, localExtensions);
293
320
  await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'extensions.json'), newExtensions);
294
321
  };
295
322
  const addExtensionWebExtension = async ({ root, extensionPath, commitHash, extensionJson, pathPrefix, useSimpleWebExtensionFile }) => {
@@ -311,6 +338,7 @@ const addExtensionWebExtension = async ({ root, extensionPath, commitHash, exten
311
338
  },
312
339
  ];
313
340
  await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'), webExtensions);
341
+ await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id));
314
342
  for (const dirent of ['src', 'extension.json']) {
315
343
  await FileSystem.copy(Path.join(extensionPath, dirent), Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id, dirent));
316
344
  }
@@ -499,21 +527,49 @@ const resolveServerStaticPath = (root) => {
499
527
  }
500
528
  throw new Error(`server static path not found`);
501
529
  };
530
+ const toArray = (value) => {
531
+ if (!value) {
532
+ return [];
533
+ }
534
+ if (Array.isArray(value)) {
535
+ return value;
536
+ }
537
+ return [value];
538
+ };
539
+ const getExtensionPaths = (extensionPath, extensionPaths) => {
540
+ const seen = Object.create(null);
541
+ const allExtensionPaths = [];
542
+ for (const path of [...toArray(extensionPath), ...toArray(extensionPaths)]) {
543
+ if (!path || seen[path]) {
544
+ continue;
545
+ }
546
+ seen[path] = true;
547
+ allExtensionPaths.push(path);
548
+ }
549
+ return allExtensionPaths;
550
+ };
502
551
  /**
503
552
  *
504
- * @param {{root:string, pathPrefix:string , extensionPath:string, testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string }} param0
553
+ * @param {{root:string, pathPrefix:string , extensionPath:string, extensionPaths?:string[], testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string }} param0
505
554
  */
506
- export const exportStatic = async ({ root, pathPrefix, extensionPath, testPath, useSimpleWebExtensionFile, serverStaticPath }) => {
555
+ export const exportStatic = async ({ root, pathPrefix, extensionPath, extensionPaths, testPath, useSimpleWebExtensionFile, serverStaticPath }) => {
507
556
  if (!existsSync(root)) {
508
557
  throw new Error(`root path does not exist: ${root}`);
509
558
  }
510
- if (extensionPath && !existsSync(extensionPath)) {
511
- throw new Error(`extension path does not exist: ${extensionPath}`);
559
+ const allExtensionPaths = getExtensionPaths(extensionPath, extensionPaths);
560
+ for (const extensionPath of allExtensionPaths) {
561
+ if (!existsSync(extensionPath)) {
562
+ throw new Error(`extension path does not exist: ${extensionPath}`);
563
+ }
512
564
  }
513
565
  if (!serverStaticPath) {
514
566
  serverStaticPath = resolveServerStaticPath(root);
515
567
  }
516
568
  if (pathPrefix === 'auto') {
569
+ if (allExtensionPaths.length === 0) {
570
+ throw new Error(`extension path is required when path prefix is auto`);
571
+ }
572
+ const [extensionPath] = allExtensionPaths;
517
573
  const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'));
518
574
  const { id } = extensionJson;
519
575
  const [author, name] = id.split('.');
@@ -536,7 +592,7 @@ export const exportStatic = async ({ root, pathPrefix, extensionPath, testPath,
536
592
  });
537
593
  console.timeEnd('applyOverrides');
538
594
  await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [] });
539
- if (extensionPath) {
595
+ for (const extensionPath of allExtensionPaths) {
540
596
  console.time('addExtension');
541
597
  await addExtension({
542
598
  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
- export const getAppWindowOptions = ({ preferences, screenWidth, screenHeight, preloadUrl }) => {
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: '#1e2324',
13
- symbolColor: '#74b1be',
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: '#1e2324',
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.0';
45
- export const commit = '6759a60';
46
- export const date = '2026-07-07T05:04:22.000Z';
44
+ export const version = '0.85.2';
45
+ export const commit = '400933e';
46
+ export const date = '2026-07-08T16:43:36.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', '6759a60', 'packages', 'preload', 'dist', 'index.js');
4
+ return join(Root.root, 'static', '400933e', 'packages', 'preload', 'dist', 'index.js');
5
5
  };