@lvce-editor/shared-process 0.128.5 → 0.128.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/index.js +3 -2
- package/package.json +2 -2
- package/src/parts/AddCustomPathsToIndexHtml/AddCustomPathsToIndexHtml.js +4 -1
- package/src/parts/BuiltinExtensionsPath/BuiltinExtensionsPath.js +1 -1
- package/src/parts/ExportStatic/ExportStatic.js +21 -14
- package/src/parts/GetElectronFileResponseContent/GetElectronFileResponseContent.js +8 -2
- package/src/parts/PageWorkerPreloads/PageWorkerPreloads.js +10 -0
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/PreloadUrl/PreloadUrl.js +1 -1
package/index.js
CHANGED
|
@@ -22,10 +22,10 @@ const toAbsoluteExtensionPath = (root, extensionPath) => {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* @param {{bundleMode?: boolean, extensionPath?: string, extensionPaths?: string[] | string, onLoadCommands?: readonly unknown[], cspOptions?: {allowExternalConnections?: boolean}, testPath?: string, root?: string}} [options]
|
|
25
|
+
* @param {{bundleMode?: boolean, extensionPath?: string, extensionPaths?: string[] | string, onLoadCommands?: readonly unknown[], page?: 'chat' | 'board', cspOptions?: {allowExternalConnections?: boolean}, testPath?: string, root?: string}} [options]
|
|
26
26
|
*/
|
|
27
27
|
export const exportStatic = async (options = {}) => {
|
|
28
|
-
const { bundleMode = false, cspOptions, extensionPath, extensionPaths = [], onLoadCommands = [], root = '', testPath = '' } = options
|
|
28
|
+
const { bundleMode = false, cspOptions, extensionPath, extensionPaths = [], onLoadCommands = [], page, root = '', testPath = '' } = options
|
|
29
29
|
if (!root) {
|
|
30
30
|
throw new Error(`root argument is required`)
|
|
31
31
|
}
|
|
@@ -41,6 +41,7 @@ export const exportStatic = async (options = {}) => {
|
|
|
41
41
|
extensionPath: absoluteExtensionPath,
|
|
42
42
|
extensionPaths: absoluteExtensionPaths,
|
|
43
43
|
onLoadCommands,
|
|
44
|
+
page,
|
|
44
45
|
pathPrefix,
|
|
45
46
|
root,
|
|
46
47
|
testPath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.128.
|
|
3
|
+
"version": "0.128.6",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@lvce-editor/rpc-registry": "9.67.1",
|
|
28
28
|
"@lvce-editor/verror": "1.7.0",
|
|
29
29
|
"is-object": "^1.0.2",
|
|
30
|
-
"rollup": "^4.
|
|
30
|
+
"rollup": "^4.68.8",
|
|
31
31
|
"xdg-basedir": "^5.1.0"
|
|
32
32
|
},
|
|
33
33
|
"optionalDependencies": {
|
|
@@ -19,7 +19,10 @@ const serializeConfig = (config, indentation) => {
|
|
|
19
19
|
return `${contentIndentation}${json.replaceAll('\n', `\n${contentIndentation}`)}`
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export const addCustomPathsToIndexHtml = async (
|
|
22
|
+
export const addCustomPathsToIndexHtml = async (
|
|
23
|
+
content,
|
|
24
|
+
runtimeConfig = {},
|
|
25
|
+
) => {
|
|
23
26
|
let preferences = {}
|
|
24
27
|
if (!Platform.isProduction) {
|
|
25
28
|
preferences = await Preferences.getUserPreferences()
|
|
@@ -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', '17391d8', 'extensions')
|
|
7
7
|
return builtinExtensionsPath
|
|
8
8
|
}
|
|
@@ -6,6 +6,7 @@ import workers from '../Workers/Workers.json' with { type: 'json' }
|
|
|
6
6
|
import * as FileSystem from '../FileSystem/FileSystem.js'
|
|
7
7
|
import * as GetContentSecurityPolicy from '../GetContentSecurityPolicy/GetContentSecurityPolicy.js'
|
|
8
8
|
import * as JsonFile from '../JsonFile/JsonFile.js'
|
|
9
|
+
import { applicationPagePreloadWorkers, applicationPageRoutes } from '../PageWorkerPreloads/PageWorkerPreloads.js'
|
|
9
10
|
import * as Path from '../Path/Path.js'
|
|
10
11
|
|
|
11
12
|
const testFileExtensionRegex = /\.(js|ts)$/
|
|
@@ -155,15 +156,16 @@ export const validateRendererProcessArtifacts = ({ commitHash, root } ) => {
|
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
const
|
|
159
|
-
const indexHtmlPath = Path.join(root, 'dist', 'index.html')
|
|
160
|
-
const content = await readFile(indexHtmlPath, 'utf8')
|
|
159
|
+
const configureWebIndexHtml = (content, path, preloadWorkers) => {
|
|
161
160
|
const configElement = content.match(runtimeConfigScriptRegex)
|
|
162
161
|
if (!configElement) {
|
|
163
|
-
throw new Error(`runtime config not found in ${
|
|
162
|
+
throw new Error(`runtime config not found in ${path}`)
|
|
164
163
|
}
|
|
165
164
|
const config = JSON.parse(configElement[1])
|
|
166
165
|
config.platform = 'web'
|
|
166
|
+
if (preloadWorkers) {
|
|
167
|
+
config.preloadWorkers = preloadWorkers
|
|
168
|
+
}
|
|
167
169
|
const configIndex = content.indexOf(configElement[0])
|
|
168
170
|
const lineStart = content.lastIndexOf('\n', configIndex - 1) + 1
|
|
169
171
|
const lineIndentation = content.slice(lineStart, configIndex)
|
|
@@ -174,12 +176,13 @@ const applyRuntimeConfigOverrides = async ({ root } ) => {
|
|
|
174
176
|
.replaceAll('>', '\\u003e')
|
|
175
177
|
.replaceAll('&', '\\u0026')
|
|
176
178
|
.replaceAll('\n', `\n${contentIndentation}`)}`
|
|
177
|
-
|
|
178
|
-
await writeFile(indexHtmlPath, newContent)
|
|
179
|
+
return content.replace(configElement[0], () => `<script id="Config" type="application/json">\n${serializedConfig}\n${indentation}</script>`)
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
const applyOverrides = async ({ commitHash, cspOptions, pathPrefix, root, serverStaticPath } ) => {
|
|
182
|
-
|
|
182
|
+
const applyOverrides = async ({ commitHash, cspOptions, page, pathPrefix, root, serverStaticPath } ) => {
|
|
183
|
+
const indexHtmlPath = Path.join(root, 'dist', 'index.html')
|
|
184
|
+
const html = await readFile(indexHtmlPath, 'utf8')
|
|
185
|
+
await writeFile(indexHtmlPath, configureWebIndexHtml(html, indexHtmlPath, page ? applicationPagePreloadWorkers : undefined))
|
|
183
186
|
const extensionDirents = await FileSystem.readDir(Path.join(serverStaticPath, commitHash, 'extensions'))
|
|
184
187
|
|
|
185
188
|
const languageBasicsDirents = extensionDirents.filter(isLanguageBasics)
|
|
@@ -249,7 +252,6 @@ const applyOverrides = async ({ commitHash, cspOptions, pathPrefix, root, server
|
|
|
249
252
|
Path.join(root, 'dist', commitHash, 'icon-themes', `${iconThemeId}.json`),
|
|
250
253
|
)
|
|
251
254
|
}
|
|
252
|
-
const indexHtmlPath = Path.join(root, 'dist', 'index.html')
|
|
253
255
|
await replace(indexHtmlPath, `/${commitHash}`, `${pathPrefix}/${commitHash}`)
|
|
254
256
|
|
|
255
257
|
await replace(
|
|
@@ -771,7 +773,7 @@ const getExtensionPaths = (extensionPath, extensionPaths) => {
|
|
|
771
773
|
|
|
772
774
|
/**
|
|
773
775
|
*
|
|
774
|
-
* @param {{root:string, pathPrefix:string, extensionPath:string, extensionPaths?:string[], onLoadCommands?:readonly unknown[], cspOptions?: {allowExternalConnections?: boolean}, testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string, bundleMode?:boolean }} param0
|
|
776
|
+
* @param {{root:string, pathPrefix:string, extensionPath:string, extensionPaths?:string[], onLoadCommands?:readonly unknown[], page?: 'chat' | 'board', cspOptions?: {allowExternalConnections?: boolean}, testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string, bundleMode?:boolean }} param0
|
|
775
777
|
*/
|
|
776
778
|
export const exportStatic = async ({
|
|
777
779
|
bundleMode = false,
|
|
@@ -779,6 +781,7 @@ export const exportStatic = async ({
|
|
|
779
781
|
extensionPath,
|
|
780
782
|
extensionPaths,
|
|
781
783
|
onLoadCommands = [],
|
|
784
|
+
page,
|
|
782
785
|
pathPrefix,
|
|
783
786
|
root,
|
|
784
787
|
serverStaticPath,
|
|
@@ -823,6 +826,7 @@ export const exportStatic = async ({
|
|
|
823
826
|
await applyOverrides({
|
|
824
827
|
commitHash,
|
|
825
828
|
cspOptions,
|
|
829
|
+
page,
|
|
826
830
|
pathPrefix,
|
|
827
831
|
root,
|
|
828
832
|
serverStaticPath,
|
|
@@ -860,10 +864,13 @@ export const exportStatic = async ({
|
|
|
860
864
|
})
|
|
861
865
|
console.timeEnd('addTestFiles')
|
|
862
866
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
+
const indexHtmlPath = Path.join(root, 'dist', 'index.html')
|
|
868
|
+
const indexHtml = await readFile(indexHtmlPath, 'utf8')
|
|
869
|
+
const pageHtml = configureWebIndexHtml(indexHtml, indexHtmlPath, applicationPagePreloadWorkers)
|
|
870
|
+
for (const route of applicationPageRoutes) {
|
|
871
|
+
const pagePath = Path.join(root, 'dist', route)
|
|
872
|
+
await FileSystem.mkdir(pagePath)
|
|
873
|
+
await writeFile(Path.join(pagePath, 'index.html'), pageHtml)
|
|
867
874
|
}
|
|
868
875
|
return {
|
|
869
876
|
commitHash,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { open, readFile } from 'node:fs/promises'
|
|
2
2
|
|
|
3
3
|
import * as AddCustomPathsToIndexHtml from '../AddCustomPathsToIndexHtml/AddCustomPathsToIndexHtml.js'
|
|
4
|
+
import { applicationPagePreloadWorkers } from '../PageWorkerPreloads/PageWorkerPreloads.js'
|
|
4
5
|
import * as Platform from '../Platform/Platform.js'
|
|
5
6
|
import * as ShouldTranspileTypescript from '../ShouldTranspileTypescript/ShouldTranspileTypescript.js'
|
|
6
7
|
import * as TranspileTypeScript from '../TranspileTypeScript/TranspileTypeScript.js'
|
|
@@ -45,8 +46,13 @@ export const getElectronFileResponseContent = async (request, absolutePath, url,
|
|
|
45
46
|
let content = await readFile(absolutePath)
|
|
46
47
|
const baseUrl = `${Platform.scheme}://-/`
|
|
47
48
|
const indexUrl = typeof url === 'string' && URL.canParse(url, baseUrl) ? new URL(url, baseUrl) : undefined
|
|
48
|
-
const
|
|
49
|
-
const
|
|
49
|
+
const isApplicationPage = indexUrl && appRoutePattern.test(indexUrl.pathname)
|
|
50
|
+
const isAppIndex = indexUrl && (indexUrl.pathname === '/' || indexUrl.pathname === '/index.html' || isApplicationPage)
|
|
51
|
+
const runtimeConfig = {
|
|
52
|
+
platform: request?.platform === 'remote' ? 'remote' : 'electron',
|
|
53
|
+
workspaceUri: getWorkspaceUri(request?.url || url),
|
|
54
|
+
...(isApplicationPage ? { preloadWorkers: applicationPagePreloadWorkers } : {}),
|
|
55
|
+
}
|
|
50
56
|
if (!Platform.isProduction && isAppIndex) {
|
|
51
57
|
// @ts-ignore
|
|
52
58
|
content = content.toString().replace(' <link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />\n', '')
|
|
@@ -56,11 +56,11 @@ export const getSetupName = () => {
|
|
|
56
56
|
return 'Lvce-Setup'
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
export const version = '0.128.
|
|
59
|
+
export const version = '0.128.6'
|
|
60
60
|
|
|
61
|
-
export const commit = '
|
|
61
|
+
export const commit = '17391d8'
|
|
62
62
|
|
|
63
|
-
export const date = '2026-11-
|
|
63
|
+
export const date = '2026-11-23T10:05:24.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', '17391d8', 'packages', 'preload', 'dist', 'index.js')
|
|
6
6
|
}
|