@lvce-editor/shared-process 0.11.9 → 0.11.10

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.
Files changed (42) hide show
  1. package/config/defaultKeyBindings.json +25 -0
  2. package/config/defaultSettings.json +2 -7
  3. package/extensions/builtin.language-basics-coffeescript/src/tokenizeCoffeeScript.js +232 -3
  4. package/extensions/builtin.language-basics-cpp/src/tokenizeCpp.js +14 -0
  5. package/extensions/builtin.language-basics-css/src/tokenizeCss.js +8 -0
  6. package/extensions/builtin.language-basics-javascript/src/tokenizeJavaScript.js +52 -4
  7. package/extensions/builtin.language-basics-python/src/tokenizePython.js +1 -1
  8. package/extensions/builtin.language-basics-ruby/README.md +14 -0
  9. package/extensions/builtin.language-basics-ruby/extension.json +48 -0
  10. package/extensions/builtin.language-basics-ruby/src/tokenizeRuby.js +241 -0
  11. package/extensions/builtin.language-basics-scss/README.md +14 -0
  12. package/extensions/builtin.language-basics-scss/extension.json +12 -0
  13. package/extensions/builtin.language-basics-scss/src/tokenizeScss.js +28 -0
  14. package/extensions/builtin.language-basics-shellscript/extension.json +2 -1
  15. package/extensions/builtin.language-basics-shellscript/src/tokenizeShellScript.js +75 -23
  16. package/extensions/builtin.language-basics-toml/src/tokenizeToml.js +87 -13
  17. package/extensions/builtin.language-basics-xml/extension.json +2 -1
  18. package/extensions/builtin.language-basics-xml/src/tokenizeXml.js +7 -0
  19. package/extensions/builtin.language-basics-yaml/src/tokenizeYaml.js +8 -1
  20. package/extensions/builtin.theme-cobalt2/color-theme.json +4 -0
  21. package/extensions/builtin.theme-gruvbox/color-theme.json +4 -0
  22. package/extensions/builtin.theme-palenight/color-theme.json +4 -0
  23. package/extensions/builtin.theme-slime/color-theme.json +9 -1
  24. package/package.json +5 -5
  25. package/src/parts/Cli/Cli.js +2 -2
  26. package/src/parts/CliInstall/CliInstall.js +21 -6
  27. package/src/parts/CliList/CliList.js +3 -2
  28. package/src/parts/CliUnlink/CliUnlink.js +1 -1
  29. package/src/parts/DownloadAndExtract/DownloadAndExtract.js +18 -8
  30. package/src/parts/ErrorHandling/ErrorHandling.js +4 -9
  31. package/src/parts/ExportStatic/ExportStatic.js +57 -330
  32. package/src/parts/ExtensionHost/ExtensionHost.js +4 -7
  33. package/src/parts/ExtensionInstallFromGitHub/ExtensionInstallFromGitHub.js +1 -4
  34. package/src/parts/ExtensionManagement/ExtensionManagementColorTheme.js +3 -4
  35. package/src/parts/FileSystem/FileSystem.js +5 -15
  36. package/src/parts/GetResponse/GetResponse.js +10 -14
  37. package/src/parts/JsonRpc/JsonRpc.js +3 -6
  38. package/src/parts/JsonRpcErrorCode/JsonRpcErrorCode.js +2 -0
  39. package/src/parts/JsonRpcVersion/JsonRpcVersion.js +1 -0
  40. package/src/parts/OutputChannel/OutputChannel.ipc.js +3 -2
  41. package/src/parts/Terminal/Terminal.js +5 -4
  42. package/src/sharedProcessMain.js +2 -5
@@ -88,88 +88,37 @@ const clean = async (root) => {
88
88
  * @param {string} root
89
89
  */
90
90
  const copyStaticFiles = async (root, commitHash) => {
91
- await FileSystem.copy(
92
- Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static'),
93
- Path.join(root, 'dist')
94
- )
91
+ await FileSystem.copy(Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static'), Path.join(root, 'dist'))
95
92
  }
96
93
 
97
94
  const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
98
95
  await replace(
99
- Path.join(
100
- root,
101
- 'dist',
102
- commitHash,
103
- 'packages',
104
- 'renderer-process',
105
- 'dist',
106
- 'rendererProcessMain.js'
107
- ),
96
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'),
108
97
  'platform = getPlatform();',
109
98
  'platform = "web"'
110
99
  )
111
100
  await replace(
112
- Path.join(
113
- root,
114
- 'dist',
115
- commitHash,
116
- 'packages',
117
- 'renderer-process',
118
- 'dist',
119
- 'rendererProcessMain.js'
120
- ),
101
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'),
121
102
  `return "/${commitHash}";`,
122
103
  `return "${pathPrefix}/${commitHash}";`
123
104
  )
124
105
  await replace(
125
- Path.join(
126
- root,
127
- 'dist',
128
- commitHash,
129
- 'packages',
130
- 'renderer-worker',
131
- 'dist',
132
- 'rendererWorkerMain.js'
133
- ),
106
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
134
107
  'platform = getPlatform();',
135
108
  'platform = "web"'
136
109
  )
137
110
  await replace(
138
- Path.join(
139
- root,
140
- 'dist',
141
- commitHash,
142
- 'packages',
143
- 'renderer-worker',
144
- 'dist',
145
- 'rendererWorkerMain.js'
146
- ),
111
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
147
112
  `platform2 = "remote";`,
148
113
  'platform2 = "web";'
149
114
  )
150
115
  await replace(
151
- Path.join(
152
- root,
153
- 'dist',
154
- commitHash,
155
- 'packages',
156
- 'renderer-worker',
157
- 'dist',
158
- 'rendererWorkerMain.js'
159
- ),
116
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
160
117
  `return "/${commitHash}";`,
161
118
  `return "${pathPrefix}/${commitHash}";`
162
119
  )
163
120
  await replace(
164
- Path.join(
165
- root,
166
- 'dist',
167
- commitHash,
168
- 'packages',
169
- 'renderer-worker',
170
- 'dist',
171
- 'rendererWorkerMain.js'
172
- ),
121
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
173
122
  `getColorThemeUrlWeb = (colorThemeId) => {
174
123
  return \`/extensions/builtin.theme-\${colorThemeId}/color-theme.json\`;
175
124
  };`,
@@ -179,15 +128,7 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
179
128
  }`
180
129
  )
181
130
  await replace(
182
- Path.join(
183
- root,
184
- 'dist',
185
- commitHash,
186
- 'packages',
187
- 'renderer-worker',
188
- 'dist',
189
- 'rendererWorkerMain.js'
190
- ),
131
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
191
132
  `getIconThemeUrl = (iconThemeId) => {
192
133
  return \`/extensions/builtin.\${iconThemeId}/icon-theme.json\`;
193
134
  }`,
@@ -197,43 +138,19 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
197
138
  }`
198
139
  )
199
140
  await replace(
200
- Path.join(
201
- root,
202
- 'dist',
203
- commitHash,
204
- 'packages',
205
- 'renderer-worker',
206
- 'dist',
207
- 'rendererWorkerMain.js'
208
- ),
141
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
209
142
  `return \`\${extensionPath}\${value}\``,
210
143
  `return \`${pathPrefix}/${commitHash}/file-icons/\${value.slice(7)}\``
211
144
  )
212
145
 
213
146
  // workaround for firefox bug
214
147
  await replace(
215
- Path.join(
216
- root,
217
- 'dist',
218
- commitHash,
219
- 'packages',
220
- 'renderer-worker',
221
- 'dist',
222
- 'rendererWorkerMain.js'
223
- ),
148
+ Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
224
149
  `//# sourceMappingURL`,
225
150
  `export {}
226
151
  //# sourceMappingURL`
227
152
  )
228
- const extensionDirents = await FileSystem.readDir(
229
- Path.join(
230
- root,
231
- 'node_modules',
232
- '@lvce-editor',
233
- 'shared-process',
234
- 'extensions'
235
- )
236
- )
153
+ const extensionDirents = await FileSystem.readDir(Path.join(root, 'node_modules', '@lvce-editor', 'shared-process', 'extensions'))
237
154
 
238
155
  const languageBasicsDirents = extensionDirents.filter(isLanguageBasics)
239
156
  const themeDirents = extensionDirents.filter(isTheme)
@@ -254,35 +171,17 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
254
171
  * @param {string} dirent
255
172
  */
256
173
  const getManifestPath = (dirent) => {
257
- return Path.join(
258
- root,
259
- 'node_modules',
260
- '@lvce-editor',
261
- 'shared-process',
262
- 'extensions',
263
- dirent,
264
- 'extension.json'
265
- )
174
+ return Path.join(root, 'node_modules', '@lvce-editor', 'shared-process', 'extensions', dirent, 'extension.json')
266
175
  }
267
176
 
268
177
  const manifestPaths = languageBasicsDirents.map(getManifestPath)
269
178
  const manifests = await Promise.all(manifestPaths.map(readExtensionManifest))
270
179
  const languages = manifests.flatMap(getLanguages)
271
- await JsonFile.writeJson(
272
- Path.join(root, 'dist', commitHash, 'config', 'languages.json'),
273
- languages
274
- )
180
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'), languages)
275
181
 
276
182
  for (const languageBasicsDirent of languageBasicsDirents) {
277
183
  await FileSystem.copy(
278
- Path.join(
279
- root,
280
- 'node_modules',
281
- '@lvce-editor',
282
- 'shared-process',
283
- 'extensions',
284
- languageBasicsDirent
285
- ),
184
+ Path.join(root, 'node_modules', '@lvce-editor', 'shared-process', 'extensions', languageBasicsDirent),
286
185
  Path.join(root, 'dist', commitHash, 'extensions', languageBasicsDirent)
287
186
  )
288
187
  }
@@ -290,62 +189,30 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
290
189
  for (const themeDirent of themeDirents) {
291
190
  const themeId = getThemeName(themeDirent)
292
191
  await FileSystem.copy(
293
- Path.join(
294
- root,
295
- 'node_modules',
296
- '@lvce-editor',
297
- 'shared-process',
298
- 'extensions',
299
- themeDirent,
300
- 'color-theme.json'
301
- ),
192
+ Path.join(root, 'node_modules', '@lvce-editor', 'shared-process', 'extensions', themeDirent, 'color-theme.json'),
302
193
  Path.join(root, 'dist', commitHash, 'themes', `${themeId}.json`)
303
194
  )
304
195
  }
305
196
 
306
197
  const themeIds = mergeThemes(themeDirents.map(getThemeName), [])
307
- await JsonFile.writeJson(
308
- Path.join(root, 'dist', commitHash, 'config', 'themes.json'),
309
- themeIds
310
- )
198
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'), themeIds)
311
199
 
312
200
  for (const iconThemeDirent of iconThemeDirents) {
313
201
  const iconThemeId = iconThemeDirent.slice('builtin.'.length)
314
202
  await FileSystem.copy(
315
- Path.join(
316
- root,
317
- 'node_modules',
318
- '@lvce-editor',
319
- 'shared-process',
320
- 'extensions',
321
- iconThemeDirent,
322
- 'icon-theme.json'
323
- ),
203
+ Path.join(root, 'node_modules', '@lvce-editor', 'shared-process', 'extensions', iconThemeDirent, 'icon-theme.json'),
324
204
  Path.join(root, 'dist', commitHash, 'icon-themes', `${iconThemeId}.json`)
325
205
  )
326
206
  await FileSystem.copy(
327
- Path.join(
328
- root,
329
- 'node_modules',
330
- '@lvce-editor',
331
- 'shared-process',
332
- 'extensions',
333
- iconThemeDirent,
334
- 'icons'
335
- ),
207
+ Path.join(root, 'node_modules', '@lvce-editor', 'shared-process', 'extensions', iconThemeDirent, 'icons'),
336
208
  Path.join(root, 'dist', commitHash, 'file-icons')
337
209
  )
338
210
  }
339
- await replace(
340
- Path.join(root, 'dist', 'index.html'),
341
- `/${commitHash}`,
342
- `${pathPrefix}/${commitHash}`
343
- )
344
- await replace(
345
- Path.join(root, 'dist', 'index.html'),
346
- `/manifest.json`,
347
- `${pathPrefix}/manifest.json`
348
- )
211
+ if (pathPrefix) {
212
+ await replace(Path.join(root, 'dist', 'index.html'), `favicon.ico`, `${pathPrefix}/favicon.ico`)
213
+ }
214
+ await replace(Path.join(root, 'dist', 'index.html'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
215
+ await replace(Path.join(root, 'dist', 'index.html'), `/manifest.json`, `${pathPrefix}/manifest.json`)
349
216
 
350
217
  await replace(
351
218
  Path.join(root, 'dist', 'index.html'),
@@ -353,46 +220,15 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
353
220
  `</title>
354
221
  <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">`
355
222
  )
356
- await replace(
357
- Path.join(root, 'dist', 'manifest.json'),
358
- `/${commitHash}`,
359
- `${pathPrefix}/${commitHash}`
360
- )
361
- await replace(
362
- Path.join(
363
- root,
364
- 'dist',
365
- commitHash,
366
- 'css',
367
- 'parts',
368
- 'ViewletTitleBarButtons.css'
369
- ),
370
- `/${commitHash}`,
371
- `${pathPrefix}/${commitHash}`
372
- )
223
+ await replace(Path.join(root, 'dist', 'manifest.json'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
224
+ await replace(Path.join(root, 'dist', commitHash, 'css', 'parts', 'ViewletTitleBarButtons.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
373
225
  }
374
226
 
375
227
  const addExtensionSeo = async ({ root, name, description }) => {
376
- await replace(
377
- Path.join(root, 'dist', 'index.html'),
378
- '<title>Code Editor</title>',
379
- `<title>${name}</title>`
380
- )
381
- await replace(
382
- Path.join(root, 'dist', 'manifest.json'),
383
- `"name": "Code Editor Web - OSS"`,
384
- `"name": "${name}"`
385
- )
386
- await replace(
387
- Path.join(root, 'dist', 'manifest.json'),
388
- `"short_name": "Web - OSS"`,
389
- `"short_name": "${name}"`
390
- )
391
- await replace(
392
- Path.join(root, 'dist', 'manifest.json'),
393
- `"description": "Web Code Editor."`,
394
- `"description": "${description}"`
395
- )
228
+ await replace(Path.join(root, 'dist', 'index.html'), '<title>Code Editor</title>', `<title>${name}</title>`)
229
+ await replace(Path.join(root, 'dist', 'manifest.json'), `"name": "Code Editor Web - OSS"`, `"name": "${name}"`)
230
+ await replace(Path.join(root, 'dist', 'manifest.json'), `"short_name": "Web - OSS"`, `"short_name": "${name}"`)
231
+ await replace(Path.join(root, 'dist', 'manifest.json'), `"description": "Web Code Editor."`, `"description": "${description}"`)
396
232
  await replace(
397
233
  Path.join(root, 'dist', 'index.html'),
398
234
  '<meta name="description" content="Online Code Editor" />',
@@ -404,73 +240,34 @@ const getId = (object) => {
404
240
  return object.id
405
241
  }
406
242
 
407
- const addExtensionThemes = async ({
408
- root,
409
- extensionPath,
410
- extensionJson,
411
- commitHash,
412
- }) => {
243
+ const addExtensionThemes = async ({ root, extensionPath, extensionJson, commitHash }) => {
413
244
  const colorThemes = extensionJson.colorThemes || []
414
245
  if (colorThemes.length === 0) {
415
246
  return
416
247
  }
417
248
  for (const colorTheme of colorThemes) {
418
249
  const { id, path } = colorTheme
419
- await FileSystem.mkdir(
420
- Path.join(root, 'dist', commitHash, 'extensions', `builtin.theme-${id}`)
421
- )
422
- await FileSystem.copy(
423
- Path.join(extensionPath, path),
424
- Path.join(root, 'dist', commitHash, 'themes', `${id}.json`)
425
- )
250
+ await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', `builtin.theme-${id}`))
251
+ await FileSystem.copy(Path.join(extensionPath, path), Path.join(root, 'dist', commitHash, 'themes', `${id}.json`))
426
252
  await replace(
427
253
  Path.join(root, 'dist', commitHash, 'config', 'defaultSettings.json'),
428
254
  `"workbench.colorTheme": "slime"`,
429
255
  `"workbench.colorTheme": "${id}"`
430
256
  )
431
- await FileSystem.copyFile(
432
- Path.join(root, 'README.md'),
433
- Path.join(
434
- root,
435
- 'dist',
436
- commitHash,
437
- 'extensions',
438
- `builtin.theme-${id}`,
439
- 'README.md'
440
- )
441
- )
257
+ await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', `builtin.theme-${id}`, 'README.md'))
442
258
  await FileSystem.copyFile(
443
259
  Path.join(extensionPath, 'extension.json'),
444
- Path.join(
445
- root,
446
- 'dist',
447
- commitHash,
448
- 'extensions',
449
- `builtin.theme-${id}`,
450
- 'extension.json'
451
- )
260
+ Path.join(root, 'dist', commitHash, 'extensions', `builtin.theme-${id}`, 'extension.json')
452
261
  )
453
262
  await FileSystem.copyFile(
454
263
  Path.join(extensionPath, 'color-theme.json'),
455
- Path.join(
456
- root,
457
- 'dist',
458
- commitHash,
459
- 'extensions',
460
- `builtin.theme-${id}`,
461
- 'color-theme.json'
462
- )
264
+ Path.join(root, 'dist', commitHash, 'extensions', `builtin.theme-${id}`, 'color-theme.json')
463
265
  )
464
266
  }
465
- const themesJson = await JsonFile.readJson(
466
- Path.join(root, 'dist', commitHash, 'config', 'themes.json')
467
- )
267
+ const themesJson = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'))
468
268
  const ids = colorThemes.map(getId)
469
269
  const mergedThemes = mergeThemes(themesJson, ids)
470
- await JsonFile.writeJson(
471
- Path.join(root, 'dist', commitHash, 'config', 'themes.json'),
472
- mergedThemes
473
- )
270
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'), mergedThemes)
474
271
  }
475
272
 
476
273
  const compareId = (a, b) => {
@@ -498,34 +295,18 @@ const toPlaygroundFile = (file) => {
498
295
  return `/playground/${file}`
499
296
  }
500
297
 
501
- const addExtensionLanguages = async ({
502
- root,
503
- extensionPath,
504
- extensionJson,
505
- commitHash,
506
- pathPrefix,
507
- }) => {
298
+ const addExtensionLanguages = async ({ root, extensionPath, extensionJson, commitHash, pathPrefix }) => {
508
299
  const languages = extensionJson.languages || []
509
300
  if (languages.length === 0) {
510
301
  return
511
302
  }
512
303
  const extensionId = extensionJson.id
513
- await FileSystem.remove(
514
- Path.join(root, 'dist', commitHash, 'extensions', extensionId)
515
- )
516
- await FileSystem.mkdir(
517
- Path.join(root, 'dist', commitHash, 'extensions', extensionId)
518
- )
519
- await FileSystem.copyFile(
520
- Path.join(root, 'README.md'),
521
- Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md')
522
- )
304
+ await FileSystem.remove(Path.join(root, 'dist', commitHash, 'extensions', extensionId))
305
+ await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId))
306
+ await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'))
523
307
  for (const file of ['src', 'data', 'extension.json']) {
524
308
  if (await FileSystem.exists(Path.join(extensionPath, file))) {
525
- await FileSystem.copy(
526
- Path.join(extensionPath, file),
527
- Path.join(root, 'dist', commitHash, 'extensions', extensionId, file)
528
- )
309
+ await FileSystem.copy(Path.join(extensionPath, file), Path.join(root, 'dist', commitHash, 'extensions', extensionId, file))
529
310
  }
530
311
  }
531
312
  const extensionLanguages = []
@@ -538,38 +319,19 @@ const addExtensionLanguages = async ({
538
319
  tokenize: `${pathPrefix}/${commitHash}/extensions/${extensionId}/${language.tokenize}`,
539
320
  })
540
321
  }
541
- const builtinLanguages = await JsonFile.readJson(
542
- Path.join(root, 'dist', commitHash, 'config', 'languages.json')
543
- )
322
+ const builtinLanguages = await JsonFile.readJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'))
544
323
  const mergedLanguages = mergeLanguages(builtinLanguages, extensionLanguages)
545
- await JsonFile.writeJson(
546
- Path.join(root, 'dist', commitHash, 'config', 'languages.json'),
547
- mergedLanguages
548
- )
324
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'), mergedLanguages)
549
325
  if (await FileSystem.exists(Path.join(extensionPath, 'test', 'cases'))) {
550
326
  await FileSystem.remove(Path.join(root, 'dist', commitHash, 'playground'))
551
- await FileSystem.copy(
552
- Path.join(extensionPath, 'test', 'cases'),
553
- Path.join(root, 'dist', commitHash, 'playground')
554
- )
555
- const testFiles = await FileSystem.readDir(
556
- Path.join(extensionPath, 'test', 'cases')
557
- )
327
+ await FileSystem.copy(Path.join(extensionPath, 'test', 'cases'), Path.join(root, 'dist', commitHash, 'playground'))
328
+ const testFiles = await FileSystem.readDir(Path.join(extensionPath, 'test', 'cases'))
558
329
  const fileMap = testFiles.map(toPlaygroundFile)
559
- await JsonFile.writeJson(
560
- Path.join(root, 'dist', commitHash, 'config', 'fileMap.json'),
561
- fileMap
562
- )
330
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'fileMap.json'), fileMap)
563
331
  }
564
332
  }
565
333
 
566
- const addExtensionWebExtension = async ({
567
- root,
568
- extensionPath,
569
- commitHash,
570
- extensionJson,
571
- pathPrefix,
572
- }) => {
334
+ const addExtensionWebExtension = async ({ root, extensionPath, commitHash, extensionJson, pathPrefix }) => {
573
335
  if (!extensionJson.browser) {
574
336
  return
575
337
  }
@@ -580,34 +342,14 @@ const addExtensionWebExtension = async ({
580
342
  path: `${pathPrefix}/${commitHash}/extensions/${extensionJson.id}`,
581
343
  },
582
344
  ]
583
- await JsonFile.writeJson(
584
- Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'),
585
- webExtensions
586
- )
345
+ await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webExtensions.json'), webExtensions)
587
346
  for (const dirent of ['src', 'extension.json']) {
588
- await FileSystem.copy(
589
- Path.join(extensionPath, dirent),
590
- Path.join(
591
- root,
592
- 'dist',
593
- commitHash,
594
- 'extensions',
595
- extensionJson.id,
596
- dirent
597
- )
598
- )
347
+ await FileSystem.copy(Path.join(extensionPath, dirent), Path.join(root, 'dist', commitHash, 'extensions', extensionJson.id, dirent))
599
348
  }
600
349
  }
601
350
 
602
- const addExtension = async ({
603
- root,
604
- extensionPath,
605
- commitHash,
606
- pathPrefix,
607
- }) => {
608
- const extensionJson = await readExtensionManifest(
609
- Path.join(extensionPath, 'extension.json')
610
- )
351
+ const addExtension = async ({ root, extensionPath, commitHash, pathPrefix }) => {
352
+ const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'))
611
353
  const name = extensionJson.name || extensionJson.id || ''
612
354
  const description = extensionJson.description || ''
613
355
  await addExtensionSeo({
@@ -678,20 +420,14 @@ const getTestFiles = (testFilesRaw) => {
678
420
  }
679
421
 
680
422
  const addTestFiles = async ({ testPath, commitHash, root, pathPrefix }) => {
681
- await FileSystem.copy(
682
- `${root}/${testPath}/src`,
683
- `${root}/dist/${commitHash}/packages/extension-host-worker-tests/src`
684
- )
423
+ await FileSystem.copy(`${root}/${testPath}/src`, `${root}/dist/${commitHash}/packages/extension-host-worker-tests/src`)
685
424
  const testFilesRaw = await FileSystem.readDir(`${root}/${testPath}/src`)
686
425
  const testFiles = getTestFiles(testFilesRaw)
687
426
  await FileSystem.mkdir(`${root}/dist/${commitHash}/tests`)
688
427
  await FileSystem.mkdir(`${root}/dist/tests`)
689
428
  console.log({ testFiles })
690
429
  for (const testFile of testFiles) {
691
- await FileSystem.copyFile(
692
- `${root}/dist/index.html`,
693
- `${root}/dist/tests/${testFile}.html`
694
- )
430
+ await FileSystem.copyFile(`${root}/dist/index.html`, `${root}/dist/tests/${testFile}.html`)
695
431
  }
696
432
  const testOverviewHtml = generateTestOverviewHtml(testFiles)
697
433
  await FileSystem.writeFile(`${root}/dist/tests/index.html`, testOverviewHtml)
@@ -701,23 +437,14 @@ const addTestFiles = async ({ testPath, commitHash, root, pathPrefix }) => {
701
437
  *
702
438
  * @param {{root:string, pathPrefix:string , extensionPath:string, testPath:string }} param0
703
439
  */
704
- export const exportStatic = async ({
705
- root,
706
- pathPrefix,
707
- extensionPath,
708
- testPath,
709
- }) => {
440
+ export const exportStatic = async ({ root, pathPrefix, extensionPath, testPath }) => {
710
441
  if (pathPrefix === 'auto') {
711
- const extensionJson = await readExtensionManifest(
712
- Path.join(extensionPath, 'extension.json')
713
- )
442
+ const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'))
714
443
  const id = extensionJson.id
715
444
  const [author, name] = id.split('.')
716
445
  pathPrefix = `/${name}`
717
446
  }
718
- const dirents = await FileSystem.readDir(
719
- Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static')
720
- )
447
+ const dirents = await FileSystem.readDir(Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static'))
721
448
  const commitHash = dirents.find(isCommitHash) || ''
722
449
 
723
450
  console.time('clean')
@@ -4,6 +4,7 @@ import * as Callback from '../Callback/Callback.js'
4
4
  import * as ExtensionHostIpc from '../ExtensionHostIpc/ExtensionHostIpc.js'
5
5
  import * as ExtensionHostRpc from '../ExtensionHostRpc/ExtensionHostRpc.js'
6
6
  import * as JsonRpc from '../JsonRpc/JsonRpc.js'
7
+ import * as JsonRpcVersion from '../JsonRpcVersion/JsonRpcVersion.js'
7
8
 
8
9
  // TODO maybe rename to extension host management for clarity
9
10
 
@@ -54,20 +55,16 @@ export const send = async (socket, id, message) => {
54
55
  throw new VError(`no extension host with id ${id} found`)
55
56
  }
56
57
  try {
57
- const result = await JsonRpc.invoke(
58
- extensionHost,
59
- message.method,
60
- ...message.params
61
- )
58
+ const result = await JsonRpc.invoke(extensionHost, message.method, ...message.params)
62
59
  socket.send({
63
- jsonrpc: '2.0',
60
+ jsonrpc: JsonRpcVersion.Two,
64
61
  id: message.id,
65
62
  result,
66
63
  })
67
64
  } catch (error) {
68
65
  // console.log({ error })
69
66
  socket.send({
70
- jsonrpc: '2.0',
67
+ jsonrpc: JsonRpcVersion.Two,
71
68
  id: message.id,
72
69
  error,
73
70
  })
@@ -9,10 +9,7 @@ export const install = async ({ user, repo, branch }) => {
9
9
  try {
10
10
  const cachedExtensionsPath = Platform.getCachedExtensionsPath()
11
11
  const url = `https://codeload.github.com/${user}/${repo}/tar.gz/${branch}`
12
- const cachedExtensionPath = Path.join(
13
- cachedExtensionsPath,
14
- `github-${user}-${repo}-${branch}`
15
- )
12
+ const cachedExtensionPath = Path.join(cachedExtensionsPath, `github-${user}-${repo}-${branch}`)
16
13
  await DownloadAndExtract.downloadAndExtractTarGz({
17
14
  url,
18
15
  outDir: cachedExtensionPath,
@@ -5,6 +5,7 @@ import * as FileSystemWatch from '../FileSystemWatch/FileSystemWatch.js'
5
5
  import * as ReadJson from '../JsonFile/JsonFile.js'
6
6
  import * as Path from '../Path/Path.js'
7
7
  import * as ExtensionManagement from './ExtensionManagement.js'
8
+ import * as JsonRpcVersion from '../JsonRpcVersion/JsonRpcVersion.js'
8
9
 
9
10
  // TODO test this function
10
11
  // TODO very similar with getIconTheme
@@ -74,12 +75,10 @@ export const watch = async (socket, colorThemeId) => {
74
75
  const colorThemePath = await getColorThemePath(extensions, colorThemeId)
75
76
  const verbose = process.argv.includes('--verbose')
76
77
  if (verbose) {
77
- console.info(
78
- `[shared-process] starting to watch color theme ${colorThemeId} at ${colorThemePath}`
79
- )
78
+ console.info(`[shared-process] starting to watch color theme ${colorThemeId} at ${colorThemePath}`)
80
79
  }
81
80
  const watcher = FileSystemWatch.watchFile(colorThemePath)
82
81
  for await (const event of watcher) {
83
- socket.send({ jsonrpc: '2.0', method: 'ColorTheme.reload', params: [] })
82
+ socket.send({ jsonrpc: JsonRpcVersion.Two, method: 'ColorTheme.reload', params: [] })
84
83
  }
85
84
  }