@lvce-editor/shared-process 0.125.12 → 0.125.14

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 CHANGED
@@ -22,10 +22,10 @@ const toAbsoluteExtensionPath = (root, extensionPath) => {
22
22
  }
23
23
 
24
24
  /**
25
- * @param {{extensionPath?: string, extensionPaths?: string[] | string, onLoadCommands?: readonly unknown[], testPath?: string, root?: string}} [options]
25
+ * @param {{extensionPath?: string, extensionPaths?: string[] | string, onLoadCommands?: readonly unknown[], cspOptions?: {allowExternalConnections?: boolean}, testPath?: string, root?: string}} [options]
26
26
  */
27
27
  export const exportStatic = async (options = {}) => {
28
- const { extensionPath, extensionPaths = [], onLoadCommands = [], root = '', testPath = '' } = options
28
+ const { cspOptions, extensionPath, extensionPaths = [], onLoadCommands = [], root = '', testPath = '' } = options
29
29
  if (!root) {
30
30
  throw new Error(`root argument is required`)
31
31
  }
@@ -35,5 +35,13 @@ export const exportStatic = async (options = {}) => {
35
35
  const absoluteExtensionPath = toAbsoluteExtensionPath(root, defaultExtensionPath)
36
36
  const absoluteExtensionPaths = extensionPathList.map((extensionPath) => toAbsoluteExtensionPath(root, extensionPath))
37
37
  const pathPrefix = process.env.PATH_PREFIX || ''
38
- return fn.exportStatic({ extensionPath: absoluteExtensionPath, extensionPaths: absoluteExtensionPaths, onLoadCommands, pathPrefix, root, testPath })
38
+ return fn.exportStatic({
39
+ cspOptions,
40
+ extensionPath: absoluteExtensionPath,
41
+ extensionPaths: absoluteExtensionPaths,
42
+ onLoadCommands,
43
+ pathPrefix,
44
+ root,
45
+ testPath,
46
+ })
39
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.125.12",
3
+ "version": "0.125.14",
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', '91ce78b', 'extensions')
6
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '3f6689e', 'extensions')
7
7
  return builtinExtensionsPath
8
8
  }
@@ -16,17 +16,20 @@ const dynamicImportTsRegex = /(import\(\s*['"][^'"]+)\.ts(['"]\s*\))/g
16
16
  const runtimeConfigScriptRegex = /<script id="Config" type="application\/json">([\s\S]*?)<\/script>/
17
17
  const whitespaceOnlyRegex = /^\s*$/
18
18
 
19
- const staticContentSecurityPolicy = GetContentSecurityPolicy.getContentSecurityPolicy([
20
- `default-src 'none'`,
21
- `connect-src 'self' https: wss: http://127.0.0.1:* http://localhost:* ws://127.0.0.1:* ws://localhost:*`,
22
- `font-src 'self'`,
23
- `img-src 'self' https: data: blob:`, // TODO maybe disallow https and data images
24
- `manifest-src 'self'`,
25
- `media-src 'self' blob:`,
26
- `script-src 'self'`,
27
- `style-src 'self' 'unsafe-inline'`,
28
- `frame-src 'self' blob:`,
29
- ])
19
+ export const getStaticContentSecurityPolicy = ({ allowExternalConnections = false } = {}) =>
20
+ GetContentSecurityPolicy.getContentSecurityPolicy([
21
+ `default-src 'none'`,
22
+ allowExternalConnections
23
+ ? `connect-src 'self' https: wss: http://127.0.0.1:* http://localhost:* ws://127.0.0.1:* ws://localhost:*`
24
+ : `connect-src 'self'`,
25
+ `font-src 'self'`,
26
+ `img-src 'self' https: data: blob:`, // TODO maybe disallow https and data images
27
+ `manifest-src 'self'`,
28
+ `media-src 'self' blob:`,
29
+ `script-src 'self'`,
30
+ `style-src 'self' 'unsafe-inline'`,
31
+ `frame-src 'self' blob:`,
32
+ ])
30
33
 
31
34
  const readExtensionManifest = async (path) => {
32
35
  const json = await JsonFile.readJson(path)
@@ -175,7 +178,7 @@ const applyRuntimeConfigOverrides = async ({ root } ) => {
175
178
  await writeFile(indexHtmlPath, newContent)
176
179
  }
177
180
 
178
- const applyOverrides = async ({ commitHash, pathPrefix, root, serverStaticPath } ) => {
181
+ const applyOverrides = async ({ commitHash, cspOptions, pathPrefix, root, serverStaticPath } ) => {
179
182
  await applyRuntimeConfigOverrides({ root })
180
183
  const extensionDirents = await FileSystem.readDir(Path.join(serverStaticPath, commitHash, 'extensions'))
181
184
 
@@ -253,7 +256,7 @@ const applyOverrides = async ({ commitHash, pathPrefix, root, serverStaticPath }
253
256
  indexHtmlPath,
254
257
  '#282e2f" />',
255
258
  `#282e2f" />
256
- <meta http-equiv="Content-Security-Policy" content="${staticContentSecurityPolicy}">`,
259
+ <meta http-equiv="Content-Security-Policy" content="${getStaticContentSecurityPolicy(cspOptions)}">`,
257
260
  )
258
261
 
259
262
  if (pathPrefix) {
@@ -753,9 +756,10 @@ const getExtensionPaths = (extensionPath, extensionPaths) => {
753
756
 
754
757
  /**
755
758
  *
756
- * @param {{root:string, pathPrefix:string, extensionPath:string, extensionPaths?:string[], onLoadCommands?:readonly unknown[], testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string }} param0
759
+ * @param {{root:string, pathPrefix:string, extensionPath:string, extensionPaths?:string[], onLoadCommands?:readonly unknown[], cspOptions?: {allowExternalConnections?: boolean}, testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string }} param0
757
760
  */
758
761
  export const exportStatic = async ({
762
+ cspOptions = {},
759
763
  extensionPath,
760
764
  extensionPaths,
761
765
  onLoadCommands = [],
@@ -802,6 +806,7 @@ export const exportStatic = async ({
802
806
  console.time('applyOverrides')
803
807
  await applyOverrides({
804
808
  commitHash,
809
+ cspOptions,
805
810
  pathPrefix,
806
811
  root,
807
812
  serverStaticPath,
@@ -56,11 +56,11 @@ export const getSetupName = () => {
56
56
  return 'Lvce-Setup'
57
57
  }
58
58
 
59
- export const version = '0.125.12'
59
+ export const version = '0.125.14'
60
60
 
61
- export const commit = '91ce78b'
61
+ export const commit = '3f6689e'
62
62
 
63
- export const date = '2026-10-23T18:40:21.000Z'
63
+ export const date = '2026-10-23T21:25:45.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', '91ce78b', 'packages', 'preload', 'dist', 'index.js')
5
+ return join(Root.root, 'static', '3f6689e', 'packages', 'preload', 'dist', 'index.js')
6
6
  }