@lvce-editor/shared-process 0.44.4 → 0.44.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.44.4",
3
+ "version": "0.44.6",
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.44.4",
21
+ "@lvce-editor/extension-host-helper-process": "0.44.6",
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', 'c858a2b', 'extensions');
5
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '75e0a3f', 'extensions');
6
6
  return builtinExtensionsPath;
7
7
  };
@@ -256,20 +256,21 @@ const addExtensionLanguages = async ({ root, extensionPath, extensionJson, commi
256
256
  await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'fileMap.json'), fileMap);
257
257
  }
258
258
  };
259
+ const updateExtensionsJson = async ({ root, commitHash, pathPrefix, extraExtensions }) => {
260
+ const dirents = await FileSystem.readDir(Path.join(root, 'dist', commitHash, 'extensions'));
261
+ const manifests = await Promise.all(dirents.map(async (dirent) => {
262
+ const json = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'extensions', dirent, 'extension.json'));
263
+ const webExtensionPath = `${pathPrefix}/${commitHash}/extensions/${dirent}`;
264
+ return {
265
+ ...json,
266
+ path: webExtensionPath,
267
+ };
268
+ }));
269
+ const newExtensions = [...manifests, ...extraExtensions];
270
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'extensions.json'), newExtensions);
271
+ };
259
272
  const addExtensionWebExtension = async ({ root, extensionPath, commitHash, extensionJson, pathPrefix, useSimpleWebExtensionFile }) => {
260
- {
261
- const dirents = await FileSystem.readDir(Path.join(root, 'dist', commitHash, 'extensions'));
262
- const manifests = await Promise.all(dirents.map(async (dirent) => {
263
- const json = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'extensions', dirent, 'extension.json'));
264
- const webExtensionPath = `${pathPrefix}/${commitHash}/extensions/${dirent}`;
265
- return {
266
- ...json,
267
- path: webExtensionPath,
268
- };
269
- }));
270
- const newExtensions = [...manifests, extensionJson];
271
- await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'extensions.json'), newExtensions);
272
- }
273
+ await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [extensionJson] });
273
274
  if (!extensionJson.browser) {
274
275
  return;
275
276
  }
@@ -434,6 +435,7 @@ export const exportStatic = async ({ root, pathPrefix, extensionPath, testPath,
434
435
  serverStaticPath,
435
436
  });
436
437
  console.timeEnd('applyOverrides');
438
+ await updateExtensionsJson({ root, commitHash, pathPrefix, extraExtensions: [] });
437
439
  if (extensionPath) {
438
440
  console.time('addExtension');
439
441
  await addExtension({
@@ -2,6 +2,7 @@ import * as ExtensionHostIconTheme from '../ExtensionManagement/ExtensionManagem
2
2
  import * as ExtensionManagement from './ExtensionManagement.js';
3
3
  import * as ExtensionHostColorTheme from './ExtensionManagementColorTheme.js';
4
4
  import * as ExtensionHostLanguages from './ExtensionManagementLanguages.js';
5
+ import * as WatchForHotReload from '../WatchForHotReload/WatchForHotReload.js';
5
6
  // prettier-ignore
6
7
  export const Commands = {
7
8
  'ExtensionHost.getColorThemeJson': ExtensionHostColorTheme.getColorThemeJson,
@@ -17,4 +18,5 @@ export const Commands = {
17
18
  'ExtensionManagement.getExtensions': ExtensionManagement.getExtensions,
18
19
  'ExtensionManagement.uninstall': ExtensionManagement.uninstall,
19
20
  'ExtensionManagement.getExtensionsEtag': ExtensionManagement.getExtensionsEtag,
21
+ 'ExtensionHost.watchForHotReload': WatchForHotReload.watchForHotReload,
20
22
  };
@@ -130,6 +130,7 @@ export const getModuleId = (commandId) => {
130
130
  case 'ExtensionManagement.install':
131
131
  case 'ExtensionManagement.uninstall':
132
132
  case 'ExtensionManagement.getExtensionsEtag':
133
+ case 'ExtensionHost.watchForHotReload':
133
134
  return ModuleId.ExtensionManagement;
134
135
  case 'FileSystem.chmod':
135
136
  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.44.4';
45
- export const commit = 'c858a2b';
46
- export const date = '2025-01-09T00:47:57.000Z';
44
+ export const version = '0.44.6';
45
+ export const commit = '75e0a3f';
46
+ export const date = '2025-01-09T23:14:15.000Z';
47
47
  export const getVersion = () => {
48
48
  return version;
49
49
  };
@@ -7,6 +7,7 @@ const METHODS_THAT_REQUIRE_SOCKET = new Set([
7
7
  'ExtensionHost.start',
8
8
  'ExtensionHost.send',
9
9
  'ExtensionHost.watchColorTheme',
10
+ 'ExtensionHost.watchForHotReload',
10
11
  'Terminal.create',
11
12
  'IncrementalTextSearch.start',
12
13
  'ElectronApplicationMenu.setItems',
@@ -0,0 +1,17 @@
1
+ import * as JsonRpcVersion from '../JsonRpcVersion/JsonRpcVersion.js';
2
+ import * as FileSystemWatch from '../WatchFile/WatchFile.js';
3
+ const hasWatcher = new WeakSet();
4
+ export const watchForHotReload = async (socket, configs) => {
5
+ if (hasWatcher.has(socket)) {
6
+ return;
7
+ }
8
+ hasWatcher.add(socket);
9
+ // TODO when socket closes, dispose file watcher?
10
+ // or keep file watcher and broadcast to all sockets?
11
+ await Promise.all(configs.map(async (config) => {
12
+ const callback = () => {
13
+ socket.send({ jsonrpc: JsonRpcVersion.Two, method: config.command, params: [] });
14
+ };
15
+ await FileSystemWatch.watchFile(config.path, callback);
16
+ }));
17
+ };