@lvce-editor/shared-process 0.127.22 → 0.127.24

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.127.22",
3
+ "version": "0.127.24",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -3,6 +3,6 @@ import { fileURLToPath } from 'url'
3
3
 
4
4
  export const getBuiltinExtensionsPath = () => {
5
5
  const staticServerPath = fileURLToPath(import.meta.resolve('@lvce-editor/static-server'))
6
- const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '2298993', 'extensions')
6
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', 'ea3b952', 'extensions')
7
7
  return builtinExtensionsPath
8
8
  }
@@ -0,0 +1,12 @@
1
+ import * as HttpStatusCode from '../HttpStatusCode/HttpStatusCode.js'
2
+
3
+ export const getBadRequestResponse = () => {
4
+ return {
5
+ body: 'bad-request',
6
+ init: {
7
+ headers: {},
8
+ status: HttpStatusCode.BadRequest,
9
+ statusText: 'bad-request',
10
+ },
11
+ }
12
+ }
@@ -1,4 +1,5 @@
1
1
  import { pathToFileURL } from 'node:url'
2
+ import * as GetBadRequestResponse from '../GetBadRequestResponse/GetBadRequestResponse.js'
2
3
  import * as GetByteRange from '../GetByteRange/GetByteRange.js'
3
4
  import * as GetContentResponse from '../GetContentResponse/GetContentResponse.js'
4
5
  import * as GetElectronFileResponseAbsolutePath from '../GetElectronFileResponseAbsolutePath/GetElectronFileResponseAbsolutePath.js'
@@ -73,6 +74,9 @@ export const getElectronFileResponse = async (url, request) => {
73
74
  headers[HttpHeader.CacheControl] = 'public, max-age=0, must-revalidate'
74
75
  return GetContentResponse.getContentResponse(content, headers)
75
76
  } catch (error) {
77
+ if (GetElectronFileResponseAbsolutePath.isInvalidRemotePathError(error)) {
78
+ return GetBadRequestResponse.getBadRequestResponse()
79
+ }
76
80
  if (IsEnoentError.isEnoentError(error)) {
77
81
  return GetNotFoundResponse.getNotFoundResponse()
78
82
  }
@@ -8,6 +8,17 @@ import * as StaticPath from '../StaticPath/StaticPath.js'
8
8
 
9
9
  const invalidIconsPath = Path.join(Root.root, 'static', '__missing_vscode_icon__.svg')
10
10
 
11
+ export class InvalidRemotePathError extends Error {
12
+ constructor(pathName) {
13
+ super(`Invalid remote path: ${pathName}`)
14
+ this.name = 'InvalidRemotePathError'
15
+ }
16
+ }
17
+
18
+ export const isInvalidRemotePathError = (error) => {
19
+ return error instanceof InvalidRemotePathError
20
+ }
21
+
11
22
  const getIconAbsolutePath = (pathName) => {
12
23
  const relativePath = pathName.startsWith('/static/icons/') ? pathName.slice('/static/icons/'.length) : pathName.slice('/icons/'.length)
13
24
  if (!relativePath || relativePath.includes('/') || relativePath.includes('\\') || relativePath.includes('..')) {
@@ -24,6 +35,25 @@ const getIconAbsolutePath = (pathName) => {
24
35
  return invalidIconsPath
25
36
  }
26
37
 
38
+ const driveLetterWithoutSlashPath = /^\/?[A-Za-z]:[^/]/
39
+ const driveLetterPath = /^\/?[A-Za-z]:\//
40
+
41
+ const getRemoteAbsolutePath = (pathName) => {
42
+ const uri = pathName.slice('/remote'.length)
43
+ if (!uri) {
44
+ throw new InvalidRemotePathError(pathName)
45
+ }
46
+ const normalized = uri.replaceAll('\\', '/')
47
+ if (driveLetterWithoutSlashPath.test(normalized)) {
48
+ throw new InvalidRemotePathError(pathName)
49
+ }
50
+ const normalizedUri = normalized.startsWith('/') ? normalized : `/${normalized}`
51
+ if (driveLetterPath.test(normalized)) {
52
+ return fileURLToPath(`file://` + normalizedUri)
53
+ }
54
+ return decodeURIComponent(normalized)
55
+ }
56
+
27
57
  // TODO clean up this code
28
58
  export const getElectronFileResponseAbsolutePath = (pathName) => {
29
59
  // TODO remove if/else in prod (use replacement)
@@ -45,8 +75,7 @@ export const getElectronFileResponseAbsolutePath = (pathName) => {
45
75
  }
46
76
  // TODO maybe have a separate protocol for remote, e.g. vscode has vscode-remote
47
77
  if (pathName.startsWith(`/remote`)) {
48
- const uri = pathName.slice('/remote'.length)
49
- return fileURLToPath(`file://` + uri)
78
+ return getRemoteAbsolutePath(pathName)
50
79
  }
51
80
  if (pathName.startsWith('/process-explorer/process-explorer-theme.css')) {
52
81
  const processExplorerThemeCss = join(tmpdir(), 'process-explorer-theme.css')
@@ -1,6 +1,6 @@
1
1
  import { pathToFileURL } from 'node:url'
2
2
 
3
3
  export const getRemoteUrl = (path) => {
4
- const url = pathToFileURL(path).toString().slice(8)
5
- return `/remote/${url}`
4
+ const url = pathToFileURL(path).toString().slice('file://'.length)
5
+ return `/remote${url}`
6
6
  }
@@ -8,3 +8,4 @@ export const NotModifed = 304
8
8
  export const MultipleChoices = 300
9
9
  export const PermanentRedirect = 308
10
10
  export const RangeNotSatisfiable = 416
11
+ export const BadRequest = 400
@@ -56,11 +56,11 @@ export const getSetupName = () => {
56
56
  return 'Lvce-Setup'
57
57
  }
58
58
 
59
- export const version = '0.127.22'
59
+ export const version = '0.127.24'
60
60
 
61
- export const commit = '2298993'
61
+ export const commit = 'ea3b952'
62
62
 
63
- export const date = '2026-11-10T10:54:54.000Z'
63
+ export const date = '2026-11-10T14:10:30.000Z'
64
64
 
65
65
  export const getVersion = () => {
66
66
  return version
@@ -2,5 +2,5 @@ import { join } from 'node:path'
2
2
  import * as Root from '../Root/Root.js'
3
3
 
4
4
  export const getPreloadUrl = () => {
5
- return join(Root.root, 'static', '2298993', 'packages', 'preload', 'dist', 'index.js')
5
+ return join(Root.root, 'static', 'ea3b952', 'packages', 'preload', 'dist', 'index.js')
6
6
  }
@@ -1323,7 +1323,7 @@
1323
1323
  "name": "Panel.loadContent",
1324
1324
  "parameters": [
1325
1325
  { "source": "state", "name": "uid" },
1326
- { "source": "literal", "value": {} },
1326
+ { "source": "argument", "name": "savedState" },
1327
1327
  { "source": "context", "name": "workspaceUri" }
1328
1328
  ]
1329
1329
  },