@lvce-editor/shared-process 0.21.4 → 0.21.5

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.21.4",
3
+ "version": "0.21.5",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -19,12 +19,12 @@
19
19
  "dependencies": {
20
20
  "@babel/code-frame": "^7.23.5",
21
21
  "@lvce-editor/assert": "^1.0.1",
22
- "@lvce-editor/extension-host": "0.21.4",
23
- "@lvce-editor/extension-host-helper-process": "0.21.4",
22
+ "@lvce-editor/extension-host": "0.21.5",
23
+ "@lvce-editor/extension-host-helper-process": "0.21.5",
24
24
  "@lvce-editor/json-rpc": "^0.4.0",
25
25
  "@lvce-editor/jsonc-parser": "^1.1.0",
26
26
  "@lvce-editor/pretty-error": "^1.3.0",
27
- "@lvce-editor/pty-host": "0.21.4",
27
+ "@lvce-editor/pty-host": "0.21.5",
28
28
  "@lvce-editor/verror": "^1.1.2",
29
29
  "debug": "^4.3.4",
30
30
  "execa": "^8.0.1",
@@ -41,7 +41,7 @@
41
41
  "optionalDependencies": {
42
42
  "@lvce-editor/ripgrep": "^1.0.1",
43
43
  "extract-zip": "^2.0.1",
44
- "open": "^9.1.0",
44
+ "open": "^10.0.0",
45
45
  "symlink-dir": "^5.2.0",
46
46
  "tail": "^2.2.6",
47
47
  "tmp-promise": "^3.0.3",
@@ -0,0 +1,5 @@
1
+ import * as Character from '../Character/Character.js'
2
+
3
+ export const addSemicolon = (line) => {
4
+ return line + Character.SemiColon
5
+ }
@@ -1,5 +1,6 @@
1
1
  import * as DefaultUrl from '../DefaultUrl/DefaultUrl.js'
2
2
  import * as GetAppWindowOptions from '../GetAppWindowOptions/GetAppWindowOptions.js'
3
+ import * as GetTitleBarItems from '../GetTitleBarItems/GetTitleBarItems.js'
3
4
  import * as ParentIpc from '../ParentIpc/ParentIpc.js'
4
5
  import * as Preferences from '../Preferences/Preferences.js'
5
6
  import * as Screen from '../Screen/Screen.js'
@@ -7,7 +8,8 @@ import * as Screen from '../Screen/Screen.js'
7
8
  export const createAppWindow = async (preferences, parsedArgs, workingDirectory, url = DefaultUrl.defaultUrl) => {
8
9
  const { width, height } = await Screen.getBounds()
9
10
  const windowOptions = GetAppWindowOptions.getAppWindowOptions(preferences, width, height)
10
- return ParentIpc.invoke('AppWindow.createAppWindow2', windowOptions, parsedArgs, workingDirectory, url)
11
+ const titleBarItems = GetTitleBarItems.getTitleBarItems()
12
+ return ParentIpc.invoke('AppWindow.createAppWindow2', windowOptions, parsedArgs, workingDirectory, titleBarItems, url)
11
13
  }
12
14
 
13
15
  export const openNew = async (url) => {
@@ -9,3 +9,4 @@ export const Space = ' '
9
9
  export const Tab = '\t'
10
10
  export const Underline = '_'
11
11
  export const T = 't'
12
+ export const SemiColon = ';'
@@ -0,0 +1,16 @@
1
+ import * as Character from '../Character/Character.js'
2
+ import * as AddSemiColon from '../AddSemiColon/AddSemiColon.js'
3
+
4
+ export const key = 'Content-Security-Policy'
5
+
6
+ export const value = [
7
+ `default-src 'none'`,
8
+ `font-src 'self'`,
9
+ `frame-src *`,
10
+ `img-src 'self' https: data:`,
11
+ `script-src 'self'`,
12
+ `media-src 'self'`,
13
+ `style-src 'self'`,
14
+ ]
15
+ .map(AddSemiColon.addSemicolon)
16
+ .join(Character.Space)
@@ -0,0 +1,14 @@
1
+ import * as Character from '../Character/Character.js'
2
+ import * as AddSemiColon from '../AddSemiColon/AddSemiColon.js'
3
+
4
+ export const key = 'Content-Security-Policy'
5
+
6
+ // prettier-ignore
7
+ export const value = [
8
+ `default-src 'none'`,
9
+ `connect-src 'self'`,
10
+ `script-src 'self'`,
11
+ `font-src 'self'`,
12
+ ]
13
+ .map(AddSemiColon.addSemicolon)
14
+ .join(Character.Space)
@@ -0,0 +1,2 @@
1
+ export const key = 'Cross-Origin-Embedder-Policy'
2
+ export const value = 'require-corp'
@@ -0,0 +1,2 @@
1
+ export const key = 'Cross-Origin-Opener-Policy'
2
+ export const value = 'same-origin'
@@ -185,7 +185,7 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
185
185
  )
186
186
  }
187
187
  await replace(Path.join(root, 'dist', 'index.html'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
188
- await replace(Path.join(root, 'dist', 'index.html'), `/manifest.json`, `${pathPrefix}/manifest.json`)
188
+ await replace(Path.join(root, 'dist', 'index.html'), `/${commitHash}/manifest.json`, `${pathPrefix}/${commitHash}/manifest.json`)
189
189
 
190
190
  if (pathPrefix) {
191
191
  await replace(
@@ -203,18 +203,18 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
203
203
  )
204
204
  }
205
205
  if (pathPrefix) {
206
- await replace(Path.join(root, 'dist', 'manifest.json'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
207
- await replace(Path.join(root, 'dist', 'manifest.json'), `"start_url": "/"`, `"start_url": "${pathPrefix}"`)
206
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
207
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"start_url": "/"`, `"start_url": "${pathPrefix}"`)
208
208
  await replace(Path.join(root, 'dist', commitHash, 'css', 'App.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
209
209
  await replace(Path.join(root, 'dist', commitHash, 'css', 'parts', 'Symbol.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
210
210
  }
211
211
  }
212
212
 
213
- const addExtensionSeo = async ({ root, name, description }) => {
213
+ const addExtensionSeo = async ({ root, name, description, commitHash }) => {
214
214
  await replace(Path.join(root, 'dist', 'index.html'), '<title>Code Editor</title>', `<title>${name}</title>`)
215
- await replace(Path.join(root, 'dist', 'manifest.json'), `"name": "Code Editor Web - OSS"`, `"name": "${name}"`)
216
- await replace(Path.join(root, 'dist', 'manifest.json'), `"short_name": "Web - OSS"`, `"short_name": "${name}"`)
217
- await replace(Path.join(root, 'dist', 'manifest.json'), `"description": "Web Code Editor."`, `"description": "${description}"`)
215
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"name": "Code Editor Web - OSS"`, `"name": "${name}"`)
216
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"short_name": "Web - OSS"`, `"short_name": "${name}"`)
217
+ await replace(Path.join(root, 'dist', commitHash, 'manifest.json'), `"description": "Web Code Editor."`, `"description": "${description}"`)
218
218
  await replace(
219
219
  Path.join(root, 'dist', 'index.html'),
220
220
  '<meta name="description" content="Online Code Editor" />',
@@ -340,6 +340,7 @@ const addExtension = async ({ root, extensionPath, commitHash, pathPrefix }) =>
340
340
  const description = extensionJson.description || ''
341
341
  await addExtensionSeo({
342
342
  root,
343
+ commitHash,
343
344
  name,
344
345
  description,
345
346
  })
@@ -0,0 +1,7 @@
1
+ import * as GetElectronFileResponse from './GetElectronFileResponse.js'
2
+
3
+ export const name = 'GetElectronFileResponse'
4
+
5
+ export const Commands = {
6
+ getElectronFileResponse: GetElectronFileResponse.getElectronFileResponse,
7
+ }
@@ -0,0 +1,23 @@
1
+ import { readFile } from 'fs/promises'
2
+ import * as GetElectronFileResponseAbsolutePath from '../GetElectronFileResponseAbsolutePath/GetElectronFileResponseAbsolutePath.js'
3
+ import * as GetElectronFileResponseRelativePath from '../GetElectronFileResponseRelativePath/GetElectronFileResponseRelativePath.js'
4
+ import * as GetHeaders from '../GetHeaders/GetHeaders.js'
5
+ import * as Platform from '../Platform/Platform.js'
6
+
7
+ export const getElectronFileResponse = async (url) => {
8
+ const pathName = GetElectronFileResponseRelativePath.getElectronFileResponseRelativePath(url)
9
+ const absolutePath = GetElectronFileResponseAbsolutePath.getElectronFileResponseAbsolutePath(pathName)
10
+ let content = await readFile(absolutePath)
11
+ if (!Platform.isProduction && url === `${Platform.scheme}://-/`) {
12
+ // @ts-ignore
13
+ content = content.toString().replace(' <link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />\n', '')
14
+ }
15
+ const headers = GetHeaders.getHeaders(absolutePath)
16
+ return {
17
+ body: content,
18
+ init: {
19
+ status: 200,
20
+ headers,
21
+ },
22
+ }
23
+ }
@@ -0,0 +1,35 @@
1
+ import { tmpdir } from 'node:os'
2
+ import { join } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+ import * as Path from '../Path/Path.js'
5
+ import * as Platform from '../Platform/Platform.js'
6
+ import * as Root from '../Root/Root.js'
7
+
8
+ export const getElectronFileResponseAbsolutePath = (pathName) => {
9
+ // TODO remove if/else in prod (use replacement)
10
+ if (pathName === `/` || pathName.startsWith(`/?`)) {
11
+ return Path.join(Root.root, 'static', 'index.html')
12
+ }
13
+ if (pathName.startsWith(`/packages`)) {
14
+ return Path.join(Root.root, pathName)
15
+ }
16
+ if (pathName.startsWith(`/static`)) {
17
+ return Path.join(Root.root, pathName)
18
+ }
19
+ if (pathName.startsWith(`/extensions`)) {
20
+ return Path.join(Root.root, pathName)
21
+ }
22
+ // TODO maybe have a separate protocol for remote, e.g. vscode has vscode-remote
23
+ if (pathName.startsWith(`/remote`)) {
24
+ const uri = pathName.slice('/remote'.length)
25
+ if (Platform.isWindows) {
26
+ return fileURLToPath(`file://` + uri)
27
+ }
28
+ return uri
29
+ }
30
+ if (pathName.startsWith('/process-explorer/process-explorer-theme.css')) {
31
+ const processExplorerThemeCss = join(tmpdir(), 'process-explorer-theme.css')
32
+ return processExplorerThemeCss
33
+ }
34
+ return Path.join(Root.root, 'static', pathName)
35
+ }
@@ -0,0 +1,8 @@
1
+ import * as Platform from '../Platform/Platform.js'
2
+
3
+ export const getElectronFileResponseRelativePath = (requestUrl) => {
4
+ const decoded = decodeURI(requestUrl)
5
+ const { scheme } = Platform
6
+ const pathName = decoded.slice(`${scheme}://-`.length)
7
+ return pathName
8
+ }
@@ -0,0 +1,52 @@
1
+ import { extname } from 'path'
2
+ import * as ContentSecurityPolicy from '../ContentSecurityPolicy/ContentSecurityPolicy.js'
3
+ import * as ContentSecurityPolicyWorker from '../ContentSecurityPolicyWorker/ContentSecurityPolicyWorker.js'
4
+ import * as CrossOriginEmbedderPolicy from '../CrossOriginEmbedderPolicy/CrossOriginEmbedderPolicy.js'
5
+ import * as CrossOriginOpenerPolicy from '../CrossOriginOpenerPolicy/CrossOriginOpenerPolicy.js'
6
+ import * as GetMimeType from '../GetMimeType/GetMimeType.js'
7
+
8
+ const getHeadersMainFrame = () => {
9
+ return {
10
+ [ContentSecurityPolicy.key]: ContentSecurityPolicy.value,
11
+ [CrossOriginOpenerPolicy.key]: CrossOriginOpenerPolicy.value,
12
+ [CrossOriginEmbedderPolicy.key]: CrossOriginEmbedderPolicy.value,
13
+ }
14
+ }
15
+
16
+ const getHeadersWorker = () => {
17
+ return {
18
+ [CrossOriginEmbedderPolicy.key]: CrossOriginEmbedderPolicy.value,
19
+ [ContentSecurityPolicyWorker.key]: ContentSecurityPolicyWorker.value,
20
+ }
21
+ }
22
+
23
+ const getHeadersDefault = () => {
24
+ return {}
25
+ }
26
+
27
+ const getExtraHeaders = (url, fileExtension) => {
28
+ switch (fileExtension) {
29
+ case '.html':
30
+ return getHeadersMainFrame()
31
+ case '.js':
32
+ if (url.endsWith('WorkerMain.js')) {
33
+ return getHeadersWorker()
34
+ }
35
+ return getHeadersDefault()
36
+ default:
37
+ return getHeadersDefault()
38
+ }
39
+ }
40
+
41
+ export const getHeaders = (absolutePath) => {
42
+ const extension = extname(absolutePath)
43
+ const mime = GetMimeType.getMimeType(extension)
44
+ const headers = {
45
+ 'Content-Type': mime,
46
+ }
47
+ const extraHeaders = getExtraHeaders(absolutePath, extension)
48
+ return {
49
+ ...headers,
50
+ ...extraHeaders,
51
+ }
52
+ }
@@ -0,0 +1,23 @@
1
+ import * as MimeType from '../MimeType/MimeType.js'
2
+
3
+ export const getMimeType = (fileExtension) => {
4
+ switch (fileExtension) {
5
+ case '.html':
6
+ return MimeType.TextHtml
7
+ case '.css':
8
+ return MimeType.TextCss
9
+ case '.ttf':
10
+ return MimeType.FontTtf
11
+ case '.js':
12
+ return MimeType.TextJavaScript
13
+ case '.svg':
14
+ return MimeType.ImageSvgXml
15
+ case '.png':
16
+ return MimeType.ImagePng
17
+ case '.json':
18
+ return MimeType.ApplicationJson
19
+ default:
20
+ console.warn(`unsupported file extension: ${fileExtension}`)
21
+ return ''
22
+ }
23
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @enum {string}
3
+ */
4
+ const UiStrings = {
5
+ File: 'File',
6
+ Edit: 'Edit',
7
+ Selection: 'Selection',
8
+ View: 'View',
9
+ Go: 'Go',
10
+ Run: 'Run',
11
+ Terminal: 'Terminal',
12
+ Window: 'Window',
13
+ Help: 'Help',
14
+ }
15
+
16
+ export const getTitleBarItems = () => {
17
+ return [
18
+ {
19
+ label: UiStrings.File,
20
+ },
21
+ {
22
+ label: UiStrings.Edit,
23
+ },
24
+ {
25
+ label: UiStrings.Selection,
26
+ },
27
+ {
28
+ label: UiStrings.View,
29
+ },
30
+ {
31
+ label: UiStrings.Go,
32
+ },
33
+ {
34
+ label: UiStrings.Run,
35
+ },
36
+ {
37
+ label: UiStrings.Terminal,
38
+ },
39
+ {
40
+ label: UiStrings.Window,
41
+ },
42
+ {
43
+ label: UiStrings.Help,
44
+ },
45
+ ]
46
+ }
@@ -0,0 +1 @@
1
+ export const ContentType = 'Content-Type'
@@ -0,0 +1,37 @@
1
+ export const ApplicationFontWoff = 'application/font-woff'
2
+ export const ApplicationJson = 'aplication/json'
3
+ export const AudioMidi = 'audio/midi'
4
+ export const AudioMpeg = 'audio/mpeg'
5
+ export const AudioOgg = 'audio/ogg'
6
+ export const AudioOpus = 'audio/opus'
7
+ export const AudioXaac = 'audio/x-aac'
8
+ export const AudioXMsWma = 'audio/x-ms-wma'
9
+ export const AudioXWav = 'audio/x-wav'
10
+ export const FontTtf = 'font/ttf'
11
+ export const ImageAvif = 'image/avif'
12
+ export const ImageBmp = 'image/bmp'
13
+ export const ImageGif = 'image/gif'
14
+ export const ImageJpg = 'image/jpg'
15
+ export const ImagePng = 'image/png'
16
+ export const ImageSvgXml = 'image/svg+xml'
17
+ export const ImageTiff = 'image/tiff'
18
+ export const ImageVndAdobePhotoShop = 'image/vnd.adobe.photoshop'
19
+ export const ImageWebp = 'image/webp'
20
+ export const ImageXIcon = 'image/x-icon'
21
+ export const ImageXTga = 'image/x-tga'
22
+ export const TextCalendar = 'text/calendar'
23
+ export const TextCss = 'text/css'
24
+ export const TextCvs = 'text/csv'
25
+ export const TextHtml = 'text/html'
26
+ export const TextJavaScript = 'text/javascript'
27
+ export const TextPlain = 'text/plain'
28
+ export const TextXml = 'text/xml'
29
+ export const VideoMp4 = 'video/mp4'
30
+ export const VideoMpeg = 'video/mpeg'
31
+ export const VideoQuickTime = 'video/quicktime'
32
+ export const VideoWebm = 'video/webm'
33
+ export const VideoXFlv = 'video/x-flv'
34
+ export const VideoXMatroska = 'video/x-matroska'
35
+ export const VideoXMsVideo = 'video/x-msvideo'
36
+ export const VideoXMsWmv = 'video/x-ms-wmv'
37
+ export const VideoXSgiMovie = 'video/x-sgi-movie'
@@ -134,6 +134,8 @@ export const load = (moduleId) => {
134
134
  return import('../HandleMessagePortForTerminalProcess/HandleMessagePortForTerminalProcess.ipc.js')
135
135
  case ModuleId.TemporaryMessagePort:
136
136
  return import('../TemporaryMessagePort/TemporaryMessagePort.ipc.js')
137
+ case ModuleId.GetElectronFileResponse:
138
+ return import('../GetElectronFileResponse/GetElectronFileResponse.ipc.js')
137
139
  default:
138
140
  throw new Error(`module ${moduleId} not found`)
139
141
  }
@@ -66,3 +66,4 @@ export const HandleElectronReady = 59
66
66
  export const HandleWindowAllClosed = 60
67
67
  export const HandleMessagePortForTerminalProcess = 61
68
68
  export const TemporaryMessagePort = 62
69
+ export const GetElectronFileResponse = 63
@@ -289,6 +289,8 @@ export const getModuleId = (commandId) => {
289
289
  return ModuleId.HandleMessagePortForTerminalProcess
290
290
  case 'TemporaryMessagePort.handlePort':
291
291
  return ModuleId.TemporaryMessagePort
292
+ case 'GetElectronFileResponse.getElectronFileResponse':
293
+ return ModuleId.GetElectronFileResponse
292
294
  default:
293
295
  throw new CommandNotFoundError(commandId)
294
296
  }
@@ -61,11 +61,11 @@ export const getSetupName = () => {
61
61
  return 'Lvce-Setup'
62
62
  }
63
63
 
64
- export const version = '0.21.4'
64
+ export const version = '0.21.5'
65
65
 
66
- export const commit = 'f091269'
66
+ export const commit = 'ce18293'
67
67
 
68
- export const date = '2023-12-18T23:35:44.000Z'
68
+ export const date = '2023-12-22T15:56:21.000Z'
69
69
 
70
70
  export const getVersion = () => {
71
71
  return version