@lvce-editor/shared-process 0.80.7 → 0.80.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.80.7",
3
+ "version": "0.80.10",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -18,19 +18,20 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@lvce-editor/assert": "1.5.1",
21
- "@lvce-editor/extension-host-helper-process": "0.80.7",
21
+ "@lvce-editor/auth-process": "1.6.0",
22
+ "@lvce-editor/extension-host-helper-process": "0.80.10",
22
23
  "@lvce-editor/ipc": "15.0.0",
23
24
  "@lvce-editor/json-rpc": "8.0.0",
24
25
  "@lvce-editor/jsonc-parser": "1.5.0",
25
26
  "@lvce-editor/pretty-error": "2.0.0",
26
- "@lvce-editor/rpc-registry": "9.20.0",
27
+ "@lvce-editor/rpc-registry": "9.22.0",
27
28
  "@lvce-editor/verror": "1.7.0",
28
29
  "is-object": "^1.0.2",
29
30
  "xdg-basedir": "^5.1.0"
30
31
  },
31
32
  "optionalDependencies": {
32
33
  "@lvce-editor/embeds-process": "4.4.0",
33
- "@lvce-editor/file-system-process": "5.0.0",
34
+ "@lvce-editor/file-system-process": "5.1.0",
34
35
  "@lvce-editor/file-watcher-process": "3.6.0",
35
36
  "@lvce-editor/network-process": "5.2.0",
36
37
  "@lvce-editor/preload": "1.5.0",
@@ -0,0 +1,13 @@
1
+ import * as LaunchAuthProcess from '../LaunchAuthProcess/LaunchAuthProcess.js';
2
+ export const state = {
3
+ /**
4
+ * @type {any}
5
+ */
6
+ ipc: undefined,
7
+ };
8
+ export const getOrCreate = async () => {
9
+ if (!state.ipc) {
10
+ state.ipc = LaunchAuthProcess.launchAuthProcess();
11
+ }
12
+ return state.ipc;
13
+ };
@@ -0,0 +1,3 @@
1
+ import * as Path from '../Path/Path.js';
2
+ import * as Root from '../Root/Root.js';
3
+ export const authProcessPath = Path.join(Root.root, 'packages', 'shared-process', 'node_modules', '@lvce-editor', 'auth-process', 'dist', 'index.js');
@@ -0,0 +1,12 @@
1
+ const state = {
2
+ ref: 0,
3
+ };
4
+ export const increment = () => {
5
+ state.ref++;
6
+ };
7
+ export const hasRef = () => {
8
+ return state.ref > 0;
9
+ };
10
+ export const decrement = async () => {
11
+ state.ref--;
12
+ };
@@ -2,6 +2,6 @@ import { join } from 'path';
2
2
  import { fileURLToPath } from 'url';
3
3
  export const getBuiltinExtensionsPath = () => {
4
4
  const staticServerPath = fileURLToPath(import.meta.resolve('@lvce-editor/static-server'));
5
- const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '28473cd', 'extensions');
5
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '27c0844', 'extensions');
6
6
  return builtinExtensionsPath;
7
7
  };
@@ -0,0 +1,11 @@
1
+ import * as AuthProcess from '../AuthProcess/AuthProcess.js';
2
+ export const targetMessagePort = () => {
3
+ return AuthProcess.getOrCreate();
4
+ };
5
+ export const upgradeMessagePort = (port, message) => {
6
+ return {
7
+ type: 'send',
8
+ method: 'HandleMessagePort.handleMessagePort',
9
+ params: [port, message.ipcId],
10
+ };
11
+ };
@@ -1,4 +1,5 @@
1
1
  import * as Assert from '../Assert/Assert.js';
2
+ import * as HandleIpcAuthProcess from '../HandleIpcAuthProcess/HandleIpcAuthProcess.js';
2
3
  import * as HandleIpcClipBoardProcess from '../HandleIpcClipBoardProcess/HandleIpcClipBoardProcess.js';
3
4
  import * as HandleIpcEmbedsProcess from '../HandleIpcEmbedsProcess/HandleIpcEmbedsProcess.js';
4
5
  import * as HandleIpcExtensionHostHelperProcess from '../HandleIpcExtensionHostHelperProcess/HandleIpcExtensionHostHelperProcess.js';
@@ -11,6 +12,8 @@ import * as IpcId from '../IpcId/IpcId.js';
11
12
  export const getModule = (ipcId) => {
12
13
  Assert.number(ipcId);
13
14
  switch (ipcId) {
15
+ case IpcId.AuthProcess:
16
+ return HandleIpcAuthProcess;
14
17
  case IpcId.SharedProcess:
15
18
  return HandleIpcSharedProcess;
16
19
  case IpcId.EmbedsProcess:
@@ -0,0 +1,6 @@
1
+ import * as HandleMessagePortForAuthProcess from './HandleMessagePortForAuthProcess.js';
2
+ export const name = 'HandleMessagePortForAuthProcess';
3
+ export const Commands = {
4
+ handleMessagePortForAuthProcess: HandleMessagePortForAuthProcess.handleMessagePortForAuthProcess,
5
+ handleAuthProcessIpcClosed: HandleMessagePortForAuthProcess.handleAuthProcessIpcClosed,
6
+ };
@@ -0,0 +1,20 @@
1
+ import * as AuthProcess from '../AuthProcess/AuthProcess.js';
2
+ import * as AuthProcessState from '../AuthProcessState/AuthProcessState.js';
3
+ import * as HandleIncomingIpc from '../HandleIncomingIpc/HandleIncomingIpc.js';
4
+ import * as IpcId from '../IpcId/IpcId.js';
5
+ export const handleMessagePortForAuthProcess = (port, ipcId) => {
6
+ AuthProcessState.increment();
7
+ return HandleIncomingIpc.handleIncomingIpc(IpcId.AuthProcess, port, {
8
+ ipcId,
9
+ });
10
+ };
11
+ export const handleAuthProcessIpcClosed = async () => {
12
+ AuthProcessState.decrement();
13
+ if (AuthProcessState.hasRef()) {
14
+ return;
15
+ }
16
+ const promise = AuthProcess.state.ipc;
17
+ AuthProcess.state.ipc = undefined;
18
+ const ipc = await promise;
19
+ ipc.dispose();
20
+ };
@@ -1,4 +1,5 @@
1
1
  import { RpcId } from '@lvce-editor/rpc-registry';
2
+ export const AuthProcess = RpcId.AuthWorker;
2
3
  export const EmbedsProcess = RpcId.EmbedsProcess;
3
4
  export const EmbedsWorker = RpcId.EmbedsWorker;
4
5
  export const ExtensionHostHelperProcess = 3;
@@ -0,0 +1,14 @@
1
+ import * as AuthProcessPath from '../AuthProcessPath/AuthProcessPath.js';
2
+ import * as IpcId from '../IpcId/IpcId.js';
3
+ import * as IsElectron from '../IsElectron/IsElectron.js';
4
+ import * as LaunchProcess from '../LaunchProcess/LaunchProcess.js';
5
+ export const launchAuthProcess = async () => {
6
+ const ipc = await LaunchProcess.launchProcess({
7
+ name: 'Auth Process',
8
+ targetRpcId: IpcId.AuthProcess,
9
+ defaultPath: AuthProcessPath.authProcessPath,
10
+ isElectron: IsElectron.isElectron,
11
+ settingName: 'develop.authProcessPath',
12
+ });
13
+ return ipc;
14
+ };
@@ -83,8 +83,8 @@ export const load = (moduleId) => {
83
83
  return import('../Os/Os.ipc.js');
84
84
  case ModuleId.PlatformPaths:
85
85
  return import('../PlatformPaths/PlatformPaths.ipc.js');
86
- case ModuleId.OAuthServer:
87
- return import('../OAuthServer/OAuthServer.ipc.js');
86
+ case ModuleId.HandleMessagePortForAuthProcess:
87
+ return import('../HandleMessagePortForAuthProcess/HandleMessagePortForAuthProcess.ipc.js');
88
88
  case ModuleId.OutputChannel:
89
89
  return import('../OutputChannel/OutputChannel.ipc.js');
90
90
  case ModuleId.Performance:
@@ -76,4 +76,4 @@ export const HandleMessagePortForFileSystemProcess = 81;
76
76
  export const HandleMessagePortForClipBoardProcess = 82;
77
77
  export const Exec = 83;
78
78
  export const PlatformPaths = 84;
79
- export const OAuthServer = 85;
79
+ export const HandleMessagePortForAuthProcess = 86;
@@ -188,10 +188,9 @@ export const getModuleId = (commandId) => {
188
188
  return ModuleId.GetWindowId;
189
189
  case 'Exec.exec':
190
190
  return ModuleId.Exec;
191
- case 'OAuthServer.create':
192
- case 'OAuthServer.getCode':
193
- case 'OAuthServer.dispose':
194
- return ModuleId.OAuthServer;
191
+ case 'HandleMessagePortForAuthProcess.handleMessagePortForAuthProcess':
192
+ case 'HandleMessagePortForAuthProcess.handleAuthProcessIpcClosed':
193
+ return ModuleId.HandleMessagePortForAuthProcess;
195
194
  case 'PlatformPaths.getDisabledExtensionsJsonPath':
196
195
  case 'PlatformPaths.getDisabledExtensionsJsonUri':
197
196
  return ModuleId.PlatformPaths;
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
41
41
  export const getSetupName = () => {
42
42
  return 'Lvce-Setup';
43
43
  };
44
- export const version = '0.80.7';
45
- export const commit = '28473cd';
46
- export const date = '2026-04-22T19:34:14.000Z';
44
+ export const version = '0.80.10';
45
+ export const commit = '27c0844';
46
+ export const date = '2026-04-28T21:15:08.000Z';
47
47
  export const getVersion = () => {
48
48
  return version;
49
49
  };
@@ -1,5 +1,5 @@
1
1
  import { join } from 'node:path';
2
2
  import * as Root from '../Root/Root.js';
3
3
  export const getPreloadUrl = () => {
4
- return join(Root.root, 'static', '28473cd', 'packages', 'preload', 'dist', 'index.js');
4
+ return join(Root.root, 'static', '27c0844', 'packages', 'preload', 'dist', 'index.js');
5
5
  };
@@ -4,6 +4,7 @@ import * as IpcTransferState from '../IpcTransferState/IpcTransferState.js';
4
4
  import * as JsonRpc from '../JsonRpc/JsonRpc.js';
5
5
  const supportsPartialIpcHandling = (ipcId) => {
6
6
  switch (ipcId) {
7
+ case IpcId.AuthProcess:
7
8
  case IpcId.TerminalProcess:
8
9
  case IpcId.ProcessExplorer:
9
10
  case IpcId.EmbedsProcess:
@@ -1,7 +0,0 @@
1
- import * as OAuthServer from './OAuthServer.js';
2
- export const name = 'OAuthServer';
3
- export const Commands = {
4
- create: OAuthServer.create,
5
- getCode: OAuthServer.getCode,
6
- dispose: OAuthServer.dispose,
7
- };
@@ -1,165 +0,0 @@
1
- import { createServer } from 'node:http';
2
- import * as Assert from '../Assert/Assert.js';
3
- /** @type {Record<string, {
4
- server: import('node:http').Server | undefined,
5
- portPromise: Promise<number> | undefined,
6
- successHtml: string,
7
- errorHtml: string,
8
- codeQueue: string[],
9
- codePromise: Promise<string> | undefined,
10
- resolveCode: ((value: string) => void) | undefined,
11
- rejectCode: ((reason?: unknown) => void) | undefined,
12
- }>} */
13
- const states = Object.create(null);
14
- const getOrCreateState = (id) => {
15
- if (!states[id]) {
16
- states[id] = {
17
- server: undefined,
18
- portPromise: undefined,
19
- successHtml: '',
20
- errorHtml: '',
21
- codeQueue: [],
22
- codePromise: undefined,
23
- resolveCode: undefined,
24
- rejectCode: undefined,
25
- };
26
- }
27
- return states[id];
28
- };
29
- const clearPendingCodePromise = (state) => {
30
- state.codePromise = undefined;
31
- state.resolveCode = undefined;
32
- state.rejectCode = undefined;
33
- };
34
- const resolveCode = (state, code) => {
35
- if (state.resolveCode) {
36
- const { resolveCode } = state;
37
- clearPendingCodePromise(state);
38
- resolveCode(code);
39
- return;
40
- }
41
- state.codeQueue.push(code);
42
- };
43
- const rejectPendingCode = (state, error) => {
44
- if (!state.rejectCode) {
45
- return;
46
- }
47
- const { rejectCode } = state;
48
- clearPendingCodePromise(state);
49
- rejectCode(error);
50
- };
51
- const getCodeFromRequest = (request) => {
52
- if (!request.url) {
53
- return undefined;
54
- }
55
- const url = new URL(request.url, 'http://localhost');
56
- const code = url.searchParams.get('code');
57
- return code || undefined;
58
- };
59
- const handleRequest = (id, request, response) => {
60
- const state = states[id];
61
- let html = '';
62
- if (state) {
63
- const code = getCodeFromRequest(request);
64
- if (code) {
65
- resolveCode(state, code);
66
- html = state.successHtml;
67
- }
68
- else {
69
- html = state.errorHtml;
70
- }
71
- }
72
- response.writeHead(200, {
73
- 'Content-Type': 'text/html; charset=utf-8',
74
- 'Cache-Control': 'no-store',
75
- });
76
- response.end(html);
77
- };
78
- const listen = (server) => {
79
- const { promise, resolve, reject } = Promise.withResolvers();
80
- const onError = (error) => {
81
- server.off('listening', onListening);
82
- reject(error);
83
- };
84
- const onListening = () => {
85
- server.off('error', onError);
86
- const address = server.address();
87
- if (!address || typeof address === 'string') {
88
- reject(new Error('failed to determine oauth server port'));
89
- return;
90
- }
91
- resolve(address.port);
92
- };
93
- server.once('error', onError);
94
- server.once('listening', onListening);
95
- server.listen(0, 'localhost');
96
- return promise;
97
- };
98
- const getOrCreateCodePromise = (state) => {
99
- if (!state.codePromise) {
100
- const { promise, resolve, reject } = Promise.withResolvers();
101
- state.codePromise = promise;
102
- state.resolveCode = resolve;
103
- state.rejectCode = reject;
104
- }
105
- return state.codePromise;
106
- };
107
- export const create = async (id, successHtml, errorHtml) => {
108
- Assert.string(id);
109
- Assert.string(successHtml);
110
- Assert.string(errorHtml);
111
- const state = getOrCreateState(id);
112
- state.successHtml = successHtml;
113
- state.errorHtml = errorHtml;
114
- if (state.portPromise) {
115
- return state.portPromise;
116
- }
117
- const server = createServer((request, response) => {
118
- handleRequest(id, request, response);
119
- });
120
- state.server = server;
121
- state.portPromise = listen(server);
122
- try {
123
- return await state.portPromise;
124
- }
125
- catch (error) {
126
- state.server = undefined;
127
- state.portPromise = undefined;
128
- delete states[id];
129
- throw error;
130
- }
131
- };
132
- export const getCode = async (id) => {
133
- Assert.string(id);
134
- const state = states[id];
135
- if (!state || !state.server) {
136
- throw new Error(`oauth server ${id} not found`);
137
- }
138
- if (state.codeQueue.length > 0) {
139
- return state.codeQueue.shift();
140
- }
141
- return getOrCreateCodePromise(state);
142
- };
143
- export const dispose = async (id) => {
144
- Assert.string(id);
145
- const state = getOrCreateState(id);
146
- if (!state.server) {
147
- delete states[id];
148
- return;
149
- }
150
- const { server } = state;
151
- state.server = undefined;
152
- state.portPromise = undefined;
153
- state.codeQueue = [];
154
- rejectPendingCode(state, new Error('oauth server disposed'));
155
- const { promise, resolve, reject } = Promise.withResolvers();
156
- server.close((error) => {
157
- if (error) {
158
- reject(error);
159
- return;
160
- }
161
- resolve(undefined);
162
- });
163
- await promise;
164
- delete states[id];
165
- };