@lvce-editor/shared-process 0.35.8 → 0.35.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.35.8",
3
+ "version": "0.35.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.35.8",
21
+ "@lvce-editor/extension-host-helper-process": "0.35.10",
22
22
  "@lvce-editor/ipc": "^11.0.1",
23
23
  "@lvce-editor/json-rpc": "^4.1.0",
24
24
  "@lvce-editor/jsonc-parser": "^1.4.0",
@@ -2,7 +2,7 @@ import { pathToFileURL } from 'node:url';
2
2
  import * as Platform from '../Platform/Platform.js';
3
3
  import * as Preferences from '../Preferences/Preferences.js';
4
4
  const getRemoteUrl = (path) => {
5
- '/remote' + pathToFileURL(path).toString().slice(7);
5
+ return '/remote' + pathToFileURL(path).toString().slice(7);
6
6
  };
7
7
  export const addCustomPathsToIndexHtml = async (content) => {
8
8
  if (Platform.isProduction) {
@@ -0,0 +1,15 @@
1
+ export const deduplicateExtensions = (extensions, builtinExtensionsPath) => {
2
+ const seen = Object.create(null);
3
+ const uniqueExtensions = [];
4
+ for (const extension of extensions) {
5
+ if (extension.id in seen) {
6
+ continue;
7
+ }
8
+ seen[extension.id] = true;
9
+ if (extension.path.startsWith(builtinExtensionsPath)) {
10
+ extension.builtin = true;
11
+ }
12
+ uniqueExtensions.push(extension);
13
+ }
14
+ return uniqueExtensions;
15
+ };
@@ -1,4 +1,5 @@
1
1
  import isObject from 'is-object';
2
+ import { pathToFileURL } from 'node:url';
2
3
  import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js';
3
4
  import * as ExtensionManifestStatus from '../ExtensionManifestStatus/ExtensionManifestStatus.js';
4
5
  import * as InferExtensionId from '../InferExtensionId/InferExtensionId.js';
@@ -15,9 +16,11 @@ export const get = async (path) => {
15
16
  // TODO should include stack of extension json file here
16
17
  throw new VError('Invalid manifest file: Not an JSON object.');
17
18
  }
19
+ const uri = pathToFileURL(path).toString();
18
20
  return {
19
21
  ...json,
20
22
  path,
23
+ uri,
21
24
  status: ExtensionManifestStatus.Resolved,
22
25
  };
23
26
  }
@@ -32,9 +35,12 @@ export const get = async (path) => {
32
35
  // TODO should include stack of extension json file here
33
36
  throw new VError('Invalid manifest file: Not an JSON object.');
34
37
  }
38
+ const extensionPath = Path.join(path, 'packages', 'extension');
39
+ const uri = pathToFileURL(extensionPath).toString();
35
40
  return {
36
41
  ...json,
37
- path: Path.join(path, 'packages', 'extension'),
42
+ path: extensionPath,
43
+ uri,
38
44
  status: ExtensionManifestStatus.Resolved,
39
45
  };
40
46
  }
@@ -1,3 +1,4 @@
1
+ import * as DeduplicateExtensions from '../DeduplicateExtensions/DeduplicateExtensions.js';
1
2
  import * as ExtensionManifestInputType from '../ExtensionManifestInputType/ExtensionManifestInputType.js';
2
3
  import * as ExtensionManifestsGetFromFolder from './ExtensionManifestsFromFolder.js';
3
4
  import * as ExtensionManifestsGetFromLinkedExtensionsFolder from './ExtensionManifestsFromLinkedExtensionsFolder.js';
@@ -18,24 +19,9 @@ const get = (input) => {
18
19
  const module = getModule(input.type);
19
20
  return module.getExtensionManifests(input.path);
20
21
  };
21
- const deduplicateExtensions = (extensions, builtinExtensionsPath) => {
22
- const seen = Object.create(null);
23
- const uniqueExtensions = [];
24
- for (const extension of extensions) {
25
- if (extension.id in seen) {
26
- continue;
27
- }
28
- seen[extension.id] = true;
29
- if (extension.path.startsWith(builtinExtensionsPath)) {
30
- extension.builtin = true;
31
- }
32
- uniqueExtensions.push(extension);
33
- }
34
- return uniqueExtensions;
35
- };
36
22
  export const getAll = async (inputs, builtinExtensionsPath) => {
37
23
  const manifests = await Promise.all(inputs.map(get));
38
24
  const flatManifests = manifests.flat(1);
39
- const uniqueExtensions = deduplicateExtensions(flatManifests, builtinExtensionsPath);
25
+ const uniqueExtensions = DeduplicateExtensions.deduplicateExtensions(flatManifests, builtinExtensionsPath);
40
26
  return uniqueExtensions;
41
27
  };
@@ -25,6 +25,7 @@ export const Commands = {
25
25
  readDirWithFileTypes: FileSystem.readDirWithFileTypes,
26
26
  readFile: FileSystem.readFile,
27
27
  readFileAsBuffer: FileSystem.readFileAsBuffer,
28
+ readJson: FileSystem.readJson,
28
29
  remove: FileSystem.remove,
29
30
  rename: FileSystem.rename,
30
31
  stat: FileSystem.stat,
@@ -51,6 +51,20 @@ export const readFile = async (path, encoding = EncodingType.Utf8) => {
51
51
  throw new VError(error, `Failed to read file "${path}"`);
52
52
  }
53
53
  };
54
+ export const readJson = async (path) => {
55
+ try {
56
+ Assert.string(path);
57
+ const content = await fs.readFile(path, 'utf8');
58
+ const parsed = JSON.parse(content);
59
+ return parsed;
60
+ }
61
+ catch (error) {
62
+ if (IsEnoentError.isEnoentError(error)) {
63
+ throw new FileNotFoundError(path);
64
+ }
65
+ throw new VError(error, `Failed to read file as json "${path}"`);
66
+ }
67
+ };
54
68
  export const readFileAsBuffer = async (path) => {
55
69
  try {
56
70
  Assert.string(path);
@@ -141,6 +141,7 @@ export const getModuleId = (commandId) => {
141
141
  case 'FileSystem.readFile':
142
142
  case 'FileSystem.readFileAsBuffer':
143
143
  case 'FileSystem.remove':
144
+ case 'FileSystem.readJson':
144
145
  case 'FileSystem.rename':
145
146
  case 'FileSystem.writeFile':
146
147
  return ModuleId.FileSystem;
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
41
41
  export const getSetupName = () => {
42
42
  return 'Lvce-Setup';
43
43
  };
44
- export const version = '0.35.8';
45
- export const commit = '0ee9cba';
46
- export const date = '2024-10-06T07:57:33.000Z';
44
+ export const version = '0.35.10';
45
+ export const commit = '5d1ba9a';
46
+ export const date = '2024-10-06T17:53:48.000Z';
47
47
  export const getVersion = () => {
48
48
  return version;
49
49
  };