@lvce-editor/shared-process 0.39.0 → 0.40.1

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.39.0",
3
+ "version": "0.40.1",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -18,24 +18,24 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@lvce-editor/assert": "^1.3.0",
21
- "@lvce-editor/extension-host-helper-process": "0.39.0",
22
- "@lvce-editor/ipc": "^11.3.0",
21
+ "@lvce-editor/extension-host-helper-process": "0.40.1",
22
+ "@lvce-editor/ipc": "^11.6.0",
23
23
  "@lvce-editor/json-rpc": "^5.2.0",
24
24
  "@lvce-editor/jsonc-parser": "^1.5.0",
25
25
  "@lvce-editor/pretty-error": "^1.6.0",
26
26
  "@lvce-editor/verror": "^1.6.0",
27
- "debug": "^4.3.7",
27
+ "debug": "^4.4.0",
28
28
  "is-object": "^1.0.2",
29
29
  "xdg-basedir": "^5.1.0"
30
30
  },
31
31
  "optionalDependencies": {
32
- "@lvce-editor/embeds-process": "^1.5.0",
32
+ "@lvce-editor/embeds-process": "^1.6.0",
33
33
  "@lvce-editor/network-process": "^2.1.0",
34
34
  "@lvce-editor/preload": "^1.4.0",
35
35
  "@lvce-editor/preview-process": "^3.11.0",
36
36
  "@lvce-editor/pty-host": "^3.0.0",
37
- "@lvce-editor/search-process": "^3.3.0",
38
- "@lvce-editor/typescript-compile-process": "^1.6.0",
37
+ "@lvce-editor/search-process": "^4.0.1",
38
+ "@lvce-editor/typescript-compile-process": "^2.1.0",
39
39
  "open": "^10.1.0",
40
40
  "tail": "^2.2.6",
41
41
  "tmp-promise": "^3.0.3",
@@ -0,0 +1,7 @@
1
+ import { join } from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ export const getBuiltinExtensionsPath = () => {
4
+ const staticServerPath = fileURLToPath(import.meta.resolve('@lvce-editor/static-server'));
5
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '21f6893', 'extensions');
6
+ return builtinExtensionsPath;
7
+ };
@@ -371,6 +371,18 @@ const resolveServerStaticPath = (root) => {
371
371
  if (existsSync(guessThree)) {
372
372
  return guessThree;
373
373
  }
374
+ const guessFour = Path.join(root, 'packages', 'build', 'node_modules', '@lvce-editor', 'static-server', 'static');
375
+ if (existsSync(guessFour)) {
376
+ return guessFour;
377
+ }
378
+ const guessFive = Path.join(root, 'node_modules', '@lvce-editor', 'static-server', 'static');
379
+ if (existsSync(guessFive)) {
380
+ return guessFive;
381
+ }
382
+ const guessSix = Path.join(root, 'packages', 'server', 'node_modules', '@lvce-editor', 'static-server', 'static');
383
+ if (existsSync(guessSix)) {
384
+ return guessSix;
385
+ }
374
386
  throw new Error(`server static path not found`);
375
387
  };
376
388
  /**
@@ -3,6 +3,7 @@ import * as ExtensionManifestInputType from '../ExtensionManifestInputType/Exten
3
3
  import * as ExtensionManifestStatus from '../ExtensionManifestStatus/ExtensionManifestStatus.js';
4
4
  import * as ExtensionManifests from '../ExtensionManifests/ExtensionManifests.js';
5
5
  import * as PlatformPaths from '../PlatformPaths/PlatformPaths.js';
6
+ import * as BuiltinExtensionsPath from '../BuiltinExtensionsPath/BuiltinExtensionsPath.js';
6
7
  import { VError } from '../VError/VError.js';
7
8
  const getManifestVersion = (json) => {
8
9
  if (json && json.version && typeof json.version === 'string') {
@@ -52,7 +53,7 @@ export const list = async () => {
52
53
  },
53
54
  {
54
55
  type: ExtensionManifestInputType.Folder,
55
- path: PlatformPaths.getBuiltinExtensionsPath(),
56
+ path: BuiltinExtensionsPath.getBuiltinExtensionsPath(),
56
57
  },
57
58
  ]);
58
59
  const infos = getManifestInfos(manifests);
@@ -3,6 +3,7 @@ import * as Debug from '../Debug/Debug.js';
3
3
  import * as ExtensionManifestInputType from '../ExtensionManifestInputType/ExtensionManifestInputType.js';
4
4
  import * as ExtensionManifests from '../ExtensionManifests/ExtensionManifests.js';
5
5
  import * as Path from '../Path/Path.js';
6
+ import * as BuiltinExtensionsPath from '../BuiltinExtensionsPath/BuiltinExtensionsPath.js';
6
7
  import * as PlatformPaths from '../PlatformPaths/PlatformPaths.js';
7
8
  import { VError } from '../VError/VError.js';
8
9
  export const enable = async (id) => {
@@ -33,9 +34,9 @@ export const getBuiltinExtensions = () => {
33
34
  return ExtensionManifests.getAll([
34
35
  {
35
36
  type: ExtensionManifestInputType.Folder,
36
- path: PlatformPaths.getBuiltinExtensionsPath(),
37
+ path: BuiltinExtensionsPath.getBuiltinExtensionsPath(),
37
38
  },
38
- ], PlatformPaths.getBuiltinExtensionsPath());
39
+ ], BuiltinExtensionsPath.getBuiltinExtensionsPath());
39
40
  };
40
41
  export const getInstalledExtensions = () => {
41
42
  return ExtensionManifests.getAll([
@@ -43,7 +44,7 @@ export const getInstalledExtensions = () => {
43
44
  type: ExtensionManifestInputType.Folder,
44
45
  path: PlatformPaths.getExtensionsPath(),
45
46
  },
46
- ], PlatformPaths.getBuiltinExtensionsPath());
47
+ ], BuiltinExtensionsPath.getBuiltinExtensionsPath());
47
48
  };
48
49
  export const getExtensions = () => {
49
50
  return ExtensionManifests.getAll([
@@ -61,9 +62,9 @@ export const getExtensions = () => {
61
62
  },
62
63
  {
63
64
  type: ExtensionManifestInputType.Folder,
64
- path: PlatformPaths.getBuiltinExtensionsPath(),
65
+ path: BuiltinExtensionsPath.getBuiltinExtensionsPath(),
65
66
  },
66
- ], PlatformPaths.getBuiltinExtensionsPath());
67
+ ], BuiltinExtensionsPath.getBuiltinExtensionsPath());
67
68
  };
68
69
  export const getDisabledExtensions = () => {
69
70
  return ExtensionManifests.getAll([
@@ -71,6 +72,6 @@ export const getDisabledExtensions = () => {
71
72
  type: ExtensionManifestInputType.Folder,
72
73
  path: PlatformPaths.getDisabledExtensionsPath(),
73
74
  },
74
- ], PlatformPaths.getBuiltinExtensionsPath());
75
+ ], BuiltinExtensionsPath.getBuiltinExtensionsPath());
75
76
  };
76
77
  export * from '../ExtensionUninstall/ExtensionUninstall.js';
@@ -1,12 +1,11 @@
1
- import { stat } from 'node:fs/promises';
2
1
  import * as GetContentResponse from '../GetContentResponse/GetContentResponse.js';
3
2
  import * as GetElectronFileResponseAbsolutePath from '../GetElectronFileResponseAbsolutePath/GetElectronFileResponseAbsolutePath.js';
4
3
  import * as GetElectronFileResponseContent from '../GetElectronFileResponseContent/GetElectronFileResponseContent.js';
5
4
  import * as GetElectronFileResponseRelativePath from '../GetElectronFileResponseRelativePath/GetElectronFileResponseRelativePath.js';
6
- import * as GetEtag from '../GetEtag/GetEtag.js';
7
5
  import * as GetHeaders from '../GetHeaders/GetHeaders.js';
8
6
  import * as GetNotFoundResponse from '../GetNotFoundResponse/GetNotFoundResponse.js';
9
7
  import * as GetNotModifiedResponse from '../GetNotModifiedResponse/GetNotModifiedResponse.js';
8
+ import * as GetPathEtag from '../GetPathEtag/GetPathEtag.js';
10
9
  import * as GetServerErrorResponse from '../GetServerErrorResponse/GetServerErrorResponse.js';
11
10
  import * as HttpHeader from '../HttpHeader/HttpHeader.js';
12
11
  import * as IsEnoentError from '../IsEnoentError/IsEnoentError.js';
@@ -20,12 +19,7 @@ export const getElectronFileResponse = async (url, request) => {
20
19
  let etag;
21
20
  // TODO when is there no request?
22
21
  if (request) {
23
- let stats = await stat(absolutePath);
24
- if (stats.isDirectory()) {
25
- absolutePath += '/index.html';
26
- stats = await stat(absolutePath);
27
- }
28
- etag = GetEtag.getEtag(stats);
22
+ etag = await GetPathEtag.getPathEtag(absolutePath);
29
23
  if (request.headers[HttpHeader.IfNotMatch] === etag) {
30
24
  const headers = GetHeaders.getHeaders(absolutePath, pathName);
31
25
  return GetNotModifiedResponse.getNotModifiedResponse(headers);
@@ -0,0 +1,11 @@
1
+ import { stat } from 'node:fs/promises';
2
+ import * as GetEtag from '../GetEtag/GetEtag.js';
3
+ export const getPathEtag = async (absolutePath) => {
4
+ let stats = await stat(absolutePath);
5
+ if (stats.isDirectory()) {
6
+ absolutePath += '/index.html';
7
+ stats = await stat(absolutePath);
8
+ }
9
+ const etag = GetEtag.getEtag(stats);
10
+ return etag;
11
+ };
@@ -1,13 +1,13 @@
1
1
  import { join } from 'node:path';
2
2
  import { pathToFileURL } from 'node:url';
3
+ import * as BuiltinExtensionsPath from '../BuiltinExtensionsPath/BuiltinExtensionsPath.js';
3
4
  import * as IsBuiltServer from '../IsBuiltServer/IsBuiltServer.js';
4
5
  import * as IsProduction from '../IsProduction/IsProduction.js';
5
- import * as PlatformPaths from '../PlatformPaths/PlatformPaths.js';
6
6
  export const getTypeScriptUri = () => {
7
7
  if (!IsProduction.isProduction || IsBuiltServer.isBuiltServer) {
8
8
  return 'typescript';
9
9
  }
10
- const typescriptPath = join(PlatformPaths.getBuiltinExtensionsPath(), 'builtin.language-features-typescript', 'node', 'node_modules', 'typescript', 'lib', 'typescript.js');
10
+ const typescriptPath = join(BuiltinExtensionsPath.getBuiltinExtensionsPath(), 'builtin.language-features-typescript', 'node', 'node_modules', 'typescript', 'lib', 'typescript.js');
11
11
  const typescriptUri = pathToFileURL(typescriptPath).toString();
12
12
  return typescriptUri;
13
13
  };
@@ -0,0 +1,5 @@
1
+ import * as HandleRequestTest from './HandleRequest.js';
2
+ export const name = 'HandleRequest';
3
+ export const Commands = {
4
+ handleRequest: HandleRequestTest.handleRequest,
5
+ };
@@ -0,0 +1,9 @@
1
+ import * as Assert from '../Assert/Assert.js';
2
+ import * as HttpServerResponse from '../HttpServerResponse/HttpServerResponse.js';
3
+ import * as GetElectronFileResponse from '../GetElectronFileResponse/GetElectronFileResponse.js';
4
+ export const handleRequest = async (socket, request) => {
5
+ Assert.object(socket);
6
+ Assert.object(request);
7
+ const fileResponse = await GetElectronFileResponse.getElectronFileResponse(request.url, request);
8
+ HttpServerResponse.send(request, socket, fileResponse);
9
+ };
@@ -135,6 +135,8 @@ export const load = (moduleId) => {
135
135
  return import('../GetExtensions/GetExtensions.ipc.js');
136
136
  case ModuleId.FileSystemDisk:
137
137
  return import('../FileSystemDisk/FileSystemDisk.ipc.js');
138
+ case ModuleId.HandleRequest:
139
+ return import('../HandleRequest/HandleRequest.ipc.js');
138
140
  default:
139
141
  throw new Error(`module ${moduleId} not found`);
140
142
  }
@@ -71,3 +71,4 @@ export const WebViewServer = 76;
71
71
  export const Transferrable = 77;
72
72
  export const GetExtensions = 78;
73
73
  export const FileSystemDisk = 79;
74
+ export const HandleRequest = 80;
@@ -300,6 +300,8 @@ export const getModuleId = (commandId) => {
300
300
  case 'FileSystemDisk.readJson':
301
301
  case 'FileSystemDisk.writeFile':
302
302
  return ModuleId.FileSystemDisk;
303
+ case 'HandleRequest.handleRequest':
304
+ return ModuleId.HandleRequest;
303
305
  default:
304
306
  throw new CommandNotFoundError(commandId);
305
307
  }
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
41
41
  export const getSetupName = () => {
42
42
  return 'Lvce-Setup';
43
43
  };
44
- export const version = '0.39.0';
45
- export const commit = '95c7ea1';
46
- export const date = '2024-12-01T18:13:02.000Z';
44
+ export const version = '0.40.1';
45
+ export const commit = '21f6893';
46
+ export const date = '2024-12-08T16:28:13.000Z';
47
47
  export const getVersion = () => {
48
48
  return version;
49
49
  };
@@ -1,14 +1,12 @@
1
- import { dirname, join } from 'node:path';
1
+ import { join } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
2
3
  import * as IsBuiltServer from '../IsBuiltServer/IsBuiltServer.js';
3
4
  import * as Root from '../Root/Root.js';
4
- import { fileURLToPath } from 'node:url';
5
5
  export const getStaticPath = () => {
6
6
  if (IsBuiltServer.isBuiltServer) {
7
7
  // TODO maybe move static files to separate package
8
- const serverIndexUri = import.meta.resolve('@lvce-editor/server');
9
- const serverIndexPath = fileURLToPath(serverIndexUri);
10
- const serverPath = dirname(serverIndexPath);
11
- const staticPath = join(serverPath, 'static');
8
+ const staticServerUri = fileURLToPath(import.meta.resolve('@lvce-editor/static-server'));
9
+ const staticPath = join(staticServerUri, '..', '..', 'static');
12
10
  return staticPath;
13
11
  }
14
12
  return join(Root.root, 'static');