@lvce-editor/shared-process 0.126.26 → 0.127.1

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.126.26",
3
+ "version": "0.127.1",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -23,7 +23,7 @@
23
23
  "@lvce-editor/json-rpc": "8.9.2",
24
24
  "@lvce-editor/jsonc-parser": "1.6.0",
25
25
  "@lvce-editor/pretty-error": "2.2.0",
26
- "@lvce-editor/process-explorer": "3.37.3",
26
+ "@lvce-editor/process-explorer": "3.37.4",
27
27
  "@lvce-editor/rpc-registry": "9.66.5",
28
28
  "@lvce-editor/verror": "1.7.0",
29
29
  "is-object": "^1.0.2",
@@ -31,7 +31,7 @@
31
31
  "xdg-basedir": "^5.1.0"
32
32
  },
33
33
  "optionalDependencies": {
34
- "@lvce-editor/auth-process": "1.18.0",
34
+ "@lvce-editor/auth-process": "1.19.0",
35
35
  "@lvce-editor/cookie-import-view": "0.3.2",
36
36
  "@lvce-editor/embeds-process": "4.26.0",
37
37
  "@lvce-editor/file-system-process": "5.18.0",
@@ -1,15 +1,82 @@
1
+ import { randomUUID } from 'node:crypto'
2
+ import * as HandleIpc from '../HandleIpc/HandleIpc.js'
3
+ import * as JsonRpc from '../JsonRpc/JsonRpc.js'
1
4
  import * as LaunchAuthProcess from '../LaunchAuthProcess/LaunchAuthProcess.js'
2
5
 
3
- export const state = {
4
- /**
5
- * @type {any}
6
- */
7
- ipc: undefined,
6
+
7
+
8
+
9
+
10
+
11
+ let current
12
+ const connections = new Map ()
13
+
14
+ const forget = (generation) => {
15
+ if (current === generation) {
16
+ current = undefined
17
+ }
18
+ for (const id of generation.connections) {
19
+ connections.delete(id)
20
+ }
21
+ generation.connections.clear()
22
+ }
23
+
24
+ const getGeneration = () => {
25
+ if (!current) {
26
+ const generation = { connections: new Set(), ipc: LaunchAuthProcess.launchAuthProcess() }
27
+ current = generation
28
+ void generation.ipc.then(
29
+ (ipc) => {
30
+ const handleClose = () => {
31
+ forget(generation)
32
+ HandleIpc.unhandleIpc(ipc)
33
+ }
34
+ if (ipc.addEventListener) {
35
+ ipc.addEventListener('close', handleClose, { once: true })
36
+ } else {
37
+ ipc.on('close', handleClose)
38
+ }
39
+ },
40
+ () => forget(generation),
41
+ )
42
+ }
43
+ return current
44
+ }
45
+
46
+ export const acquire = async () => {
47
+ const generation = getGeneration()
48
+ const connectionId = randomUUID()
49
+ generation.connections.add(connectionId)
50
+ connections.set(connectionId, generation)
51
+ try {
52
+ const ipc = await generation.ipc
53
+ if (!generation.connections.has(connectionId)) {
54
+ throw new Error('Auth process closed while connecting')
55
+ }
56
+ return { connectionId, ipc }
57
+ } catch (error) {
58
+ release(connectionId)
59
+ throw error
60
+ }
8
61
  }
9
62
 
10
- export const getOrCreate = async () => {
11
- if (!state.ipc) {
12
- state.ipc = LaunchAuthProcess.launchAuthProcess()
63
+ export const release = (connectionId) => {
64
+ const generation = connections.get(connectionId)
65
+ if (!generation) {
66
+ return
67
+ }
68
+ connections.delete(connectionId)
69
+ generation.connections.delete(connectionId)
70
+ if (generation.connections.size > 0) {
71
+ return
72
+ }
73
+ if (current === generation) {
74
+ current = undefined
13
75
  }
14
- return state.ipc
76
+ // Let the close notification's response reach the child before terminating it.
77
+ setTimeout(() => {
78
+ // Address the old process through its own channel. Name-based utility-process
79
+ // disposal could kill a replacement that starts during shutdown.
80
+ void generation.ipc.then((ipc) => JsonRpc.send(ipc, 'AuthProcess.dispose')).catch(console.error)
81
+ }, 0)
15
82
  }
@@ -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', '4b0536a', 'extensions')
6
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '6d1b29a', 'extensions')
7
7
  return builtinExtensionsPath
8
8
  }
@@ -1,13 +1,20 @@
1
1
  import * as AuthProcess from '../AuthProcess/AuthProcess.js'
2
+ import * as JsonRpc from '../JsonRpc/JsonRpc.js'
2
3
 
3
- export const targetMessagePort = () => {
4
- return AuthProcess.getOrCreate()
5
- }
6
-
7
- export const upgradeMessagePort = (port, message) => {
8
- return {
9
- method: 'HandleMessagePort.handleMessagePort',
10
- params: [port, message.ipcId],
11
- type: 'send',
4
+ export const connectMessagePort = async (port, message) => {
5
+ let connectionId
6
+ try {
7
+ const connection = await AuthProcess.acquire()
8
+ connectionId = connection.connectionId
9
+ const { ipc } = connection
10
+ await JsonRpc.invokeAndTransfer(ipc, 'HandleMessagePort.handleMessagePort', port, message.ipcId, connectionId)
11
+ // Keep the parent channel handled so subsequent close notifications are received.
12
+ return { response: { type: 'handle' }, target: ipc }
13
+ } catch (error) {
14
+ if (connectionId) {
15
+ AuthProcess.release(connectionId)
16
+ }
17
+ port.close()
18
+ throw error
12
19
  }
13
20
  }
@@ -1,22 +1,11 @@
1
1
  import * as AuthProcess from '../AuthProcess/AuthProcess.js'
2
- import * as AuthProcessState from '../AuthProcessState/AuthProcessState.js'
3
2
  import * as HandleIncomingIpc from '../HandleIncomingIpc/HandleIncomingIpc.js'
4
3
  import * as IpcId from '../IpcId/IpcId.js'
5
4
 
6
5
  export const handleMessagePortForAuthProcess = (port, ipcId) => {
7
- AuthProcessState.increment()
8
- return HandleIncomingIpc.handleIncomingIpc(IpcId.AuthProcess, port, {
9
- ipcId,
10
- })
6
+ return HandleIncomingIpc.handleIncomingIpc(IpcId.AuthProcess, port, { ipcId })
11
7
  }
12
8
 
13
- export const handleAuthProcessIpcClosed = async () => {
14
- AuthProcessState.decrement()
15
- if (AuthProcessState.hasRef()) {
16
- return
17
- }
18
- const promise = AuthProcess.state.ipc
19
- AuthProcess.state.ipc = undefined
20
- const ipc = await promise
21
- ipc.dispose()
9
+ export const handleAuthProcessIpcClosed = (connectionId) => {
10
+ AuthProcess.release(connectionId)
22
11
  }
@@ -56,11 +56,11 @@ export const getSetupName = () => {
56
56
  return 'Lvce-Setup'
57
57
  }
58
58
 
59
- export const version = '0.126.26'
59
+ export const version = '0.127.1'
60
60
 
61
- export const commit = '4b0536a'
61
+ export const commit = '6d1b29a'
62
62
 
63
- export const date = '2026-10-29T23:27:11.000Z'
63
+ export const date = '2026-10-30T01:32:46.000Z'
64
64
 
65
65
  export const getVersion = () => {
66
66
  return version
@@ -48,7 +48,8 @@ export const getDefaultPreferences = async () => {
48
48
  export const getOverrides = () => {
49
49
  const argvSliced = Process.argv.slice(2)
50
50
  const overrides = {}
51
- for (const argv of argvSliced) {
51
+ for (let index = 0; index < argvSliced.length; index++) {
52
+ const argv = argvSliced[index]
52
53
  if (argv.startsWith('--theme=')) {
53
54
  overrides['workbench.colorTheme'] = argv.slice('--theme='.length)
54
55
  } else if (argv.startsWith('--process-explorer=')) {
@@ -59,6 +60,10 @@ export const getOverrides = () => {
59
60
  overrides['develop.processExplorerWorkerPath'] = argv.slice('--process-explorer-worker='.length)
60
61
  } else if (argv.startsWith('--activity-bar-worker=')) {
61
62
  overrides['develop.activityBarWorkerPath'] = argv.slice('--activity-bar-worker='.length)
63
+ } else if (argv === '--auth-worker-path' && argvSliced[index + 1]) {
64
+ overrides['develop.authWorkerPath'] = argvSliced[++index]
65
+ } else if (argv.startsWith('--auth-worker-path=')) {
66
+ overrides['develop.authWorkerPath'] = argv.slice('--auth-worker-path='.length)
62
67
  }
63
68
  }
64
69
  return overrides
@@ -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', '4b0536a', 'packages', 'preload', 'dist', 'index.js')
5
+ return join(Root.root, 'static', '6d1b29a', 'packages', 'preload', 'dist', 'index.js')
6
6
  }
@@ -1,15 +0,0 @@
1
- const state = {
2
- ref: 0,
3
- }
4
-
5
- export const increment = () => {
6
- state.ref++
7
- }
8
-
9
- export const hasRef = () => {
10
- return state.ref > 0
11
- }
12
-
13
- export const decrement = async () => {
14
- state.ref--
15
- }