@lvce-editor/shared-process 0.115.15 → 0.115.17

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.115.15",
3
+ "version": "0.115.17",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -3,4 +3,7 @@ import * as AutoUpdater from './AutoUpdater.js'
3
3
  export const Commands = {
4
4
  'AutoUpdater.getAutoUpdateType': AutoUpdater.getAutoUpdateType,
5
5
  'AutoUpdater.getLatestVersion': AutoUpdater.getLatestVersion,
6
+ 'AutoUpdater.getPlatform': AutoUpdater.getPlatform,
7
+ 'AutoUpdater.restartMacUpdate': AutoUpdater.restartMacUpdate,
8
+ 'AutoUpdater.stageMacUpdate': AutoUpdater.stageMacUpdate,
6
9
  }
@@ -1,7 +1,9 @@
1
+ import { fileURLToPath } from 'node:url'
1
2
  import * as AutoUpdateType from '../AutoUpdateType/AutoUpdateType.js'
2
3
  import * as CompareVersion from '../CompareVersion/CompareVersion.js'
3
4
  import * as GetLatestReleaseVersion from '../GetLatestReleaseVersion/GetLatestReleaseVersion.js'
4
5
  import * as IsAppImage from '../IsAppImage/IsAppImage.js'
6
+ import * as MainProcess from '../MainProcess/MainProcess.js'
5
7
  import * as Platform from '../Platform/Platform.js'
6
8
  import { VError } from '../VError/VError.js'
7
9
 
@@ -34,3 +36,12 @@ export const getLatestVersion = async () => {
34
36
  console.log('not update is available')
35
37
  }
36
38
  }
39
+
40
+ export const getPlatform = () => process.platform
41
+
42
+ export const stageMacUpdate = (diskPath, version) => {
43
+ const path = fileURLToPath(diskPath)
44
+ return MainProcess.invoke('ElectronMacUpdater.stage', path, version)
45
+ }
46
+
47
+ export const restartMacUpdate = () => MainProcess.invoke('ElectronMacUpdater.restart')
@@ -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', 'ffe336a', 'extensions')
6
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', 'deaa156', 'extensions')
7
7
  return builtinExtensionsPath
8
8
  }
@@ -9,7 +9,7 @@ export const getTerminalSpawnOptions = () => {
9
9
  }
10
10
  if (Platform.isMacOs) {
11
11
  return {
12
- args: ['-i'],
12
+ args: ['-il'],
13
13
  command: 'zsh',
14
14
  }
15
15
  }
@@ -150,6 +150,8 @@ export const load = (moduleId) => {
150
150
  return import('../Screen/Screen.ipc.js')
151
151
  case ModuleId.SendMessagePortToMainProcess:
152
152
  return import('../SendMessagePortToMainProcess/SendMessagePortToMainProcess.ipc.js')
153
+ case ModuleId.ShellCommand:
154
+ return import('../ShellCommand/ShellCommand.ipc.js')
153
155
  case ModuleId.TemporaryMessagePort:
154
156
  return import('../TemporaryMessagePort/TemporaryMessagePort.ipc.js')
155
157
  case ModuleId.Terminal:
@@ -82,3 +82,4 @@ export const FileWatcherExplorer = 94
82
82
  export const HandleMessagePortForFileWatcherExplorer = 95
83
83
  export const RemoteCli = 96
84
84
  export const BrowserFind = 97
85
+ export const ShellCommand = 98
@@ -9,6 +9,9 @@ export const getModuleId = (commandId) => {
9
9
  return ModuleId.AttachDebugger
10
10
  case 'AutoUpdater.getAutoUpdateType':
11
11
  case 'AutoUpdater.getLatestVersion':
12
+ case 'AutoUpdater.getPlatform':
13
+ case 'AutoUpdater.restartMacUpdate':
14
+ case 'AutoUpdater.stageMacUpdate':
12
15
  return ModuleId.AutoUpdater
13
16
  case 'AutoUpdaterAppImage.downloadUpdate':
14
17
  case 'AutoUpdaterAppImage.installAndRestart':
@@ -294,6 +297,9 @@ export const getModuleId = (commandId) => {
294
297
  return ModuleId.Screen
295
298
  case 'SendMessagePortToMainProcess.sendMessagePortToMainProcess':
296
299
  return ModuleId.SendMessagePortToMainProcess
300
+ case 'ShellCommand.getMenuEntries':
301
+ case 'ShellCommand.install':
302
+ return ModuleId.ShellCommand
297
303
  case 'TemporaryMessagePort.getPortTuple2':
298
304
  case 'TemporaryMessagePort.getPortTuple3':
299
305
  case 'TemporaryMessagePort.handlePorts':
@@ -56,11 +56,11 @@ export const getSetupName = () => {
56
56
  return 'Lvce-Setup'
57
57
  }
58
58
 
59
- export const version = '0.115.15'
59
+ export const version = '0.115.17'
60
60
 
61
- export const commit = 'ffe336a'
61
+ export const commit = 'deaa156'
62
62
 
63
- export const date = '2026-09-15T22:03:38.000Z'
63
+ export const date = '2026-09-16T12:58:51.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', 'ffe336a', 'packages', 'preload', 'dist', 'index.js')
5
+ return join(Root.root, 'static', 'deaa156', 'packages', 'preload', 'dist', 'index.js')
6
6
  }
@@ -0,0 +1,8 @@
1
+ import * as ShellCommand from './ShellCommand.js'
2
+
3
+ export const name = 'ShellCommand'
4
+
5
+ export const Commands = {
6
+ getMenuEntries: ShellCommand.getMenuEntries,
7
+ install: ShellCommand.install,
8
+ }
@@ -0,0 +1,66 @@
1
+ import { execFile } from 'node:child_process'
2
+ import { constants } from 'node:fs'
3
+ import { access, lstat, mkdir, readlink, symlink } from 'node:fs/promises'
4
+ import { dirname, join, resolve } from 'node:path'
5
+ import { promisify } from 'node:util'
6
+ import * as IsElectron from '../IsElectron/IsElectron.js'
7
+ import * as Platform from '../Platform/Platform.js'
8
+ import * as Root from '../Root/Root.js'
9
+
10
+ const execFileAsync = promisify(execFile)
11
+
12
+ export const getMenuEntries = () => {
13
+ if (!Platform.isMacOs || !IsElectron.isElectron) {
14
+ return []
15
+ }
16
+ return [{ id: 'ShellCommand.install', label: `Shell Command: Install '${Platform.applicationName}' command in PATH` }]
17
+ }
18
+
19
+ const shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`
20
+
21
+ export const getInstallScript = (source, destination) => {
22
+ return `/bin/mkdir -p ${shellQuote(dirname(destination))} && /bin/ln -s ${shellQuote(source)} ${shellQuote(destination)}`
23
+ }
24
+
25
+ const elevate = async (script) => {
26
+ await execFileAsync('/usr/bin/osascript', ['-e', 'on run argv\n do shell script (item 1 of argv) with administrator privileges\nend run', script])
27
+ }
28
+
29
+ export const installLink = async (source, destination, runElevated = elevate) => {
30
+ // Check the packaged launcher before creating directories or prompting for privileges.
31
+ await access(source, constants.X_OK)
32
+ const existing = await lstat(destination).catch((error) => {
33
+ if (error.code === 'ENOENT') {
34
+ return undefined
35
+ }
36
+ throw error
37
+ })
38
+ if (existing) {
39
+ if (existing.isSymbolicLink() && resolve(dirname(destination), await readlink(destination)) === source) {
40
+ return destination
41
+ }
42
+ throw new Error(`Cannot install shell command: ${destination} already exists. Move or remove it first.`)
43
+ }
44
+ try {
45
+ await mkdir(dirname(destination), { recursive: true })
46
+ await symlink(source, destination)
47
+ } catch (error) {
48
+ if (error.code !== 'EACCES' && error.code !== 'EPERM') {
49
+ throw error
50
+ }
51
+ // ln deliberately has no force flag, including after the privilege prompt.
52
+ await runElevated(getInstallScript(source, destination))
53
+ }
54
+ return destination
55
+ }
56
+
57
+ export const install = async () => {
58
+ if (!Platform.isMacOs || !IsElectron.isElectron) {
59
+ throw new Error('Installing the shell command is only supported in the macOS desktop app.')
60
+ }
61
+ const source = join(Root.root, 'bin', Platform.applicationName)
62
+ if (source.startsWith('/Volumes/') || source.includes('/AppTranslocation/')) {
63
+ throw new Error('Move the application to Applications and reopen it before installing the shell command.')
64
+ }
65
+ return installLink(source, join('/usr/local/bin', Platform.applicationName))
66
+ }