@lvce-editor/shared-process 0.127.21 → 0.127.23
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 +1 -1
- package/src/parts/BuiltinExtensionsPath/BuiltinExtensionsPath.js +1 -1
- package/src/parts/GetBadRequestResponse/GetBadRequestResponse.js +12 -0
- package/src/parts/GetElectronFileResponse/GetElectronFileResponse.js +4 -0
- package/src/parts/GetElectronFileResponseAbsolutePath/GetElectronFileResponseAbsolutePath.js +31 -2
- package/src/parts/GetRemoteUrl/GetRemoteUrl.js +2 -2
- package/src/parts/HttpStatusCode/HttpStatusCode.js +1 -0
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/PreloadUrl/PreloadUrl.js +1 -1
package/package.json
CHANGED
|
@@ -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', '
|
|
6
|
+
const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', 'd7c6ef4', '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
|
}
|
package/src/parts/GetElectronFileResponseAbsolutePath/GetElectronFileResponseAbsolutePath.js
CHANGED
|
@@ -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
|
-
|
|
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')
|
|
@@ -56,11 +56,11 @@ export const getSetupName = () => {
|
|
|
56
56
|
return 'Lvce-Setup'
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
export const version = '0.127.
|
|
59
|
+
export const version = '0.127.23'
|
|
60
60
|
|
|
61
|
-
export const commit = '
|
|
61
|
+
export const commit = 'd7c6ef4'
|
|
62
62
|
|
|
63
|
-
export const date = '2026-11-
|
|
63
|
+
export const date = '2026-11-10T13:06:10.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', '
|
|
5
|
+
return join(Root.root, 'static', 'd7c6ef4', 'packages', 'preload', 'dist', 'index.js')
|
|
6
6
|
}
|