@lvce-editor/shared-process 0.77.9 → 0.77.11

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.77.9",
3
+ "version": "0.77.11",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@lvce-editor/assert": "1.5.1",
21
- "@lvce-editor/extension-host-helper-process": "0.77.9",
21
+ "@lvce-editor/extension-host-helper-process": "0.77.11",
22
22
  "@lvce-editor/ipc": "15.0.0",
23
23
  "@lvce-editor/json-rpc": "8.0.0",
24
24
  "@lvce-editor/jsonc-parser": "1.5.0",
@@ -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', '2c0fc7e', 'extensions');
5
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', 'c0b16fe', 'extensions');
6
6
  return builtinExtensionsPath;
7
7
  };
@@ -83,6 +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
88
  case ModuleId.OutputChannel:
87
89
  return import('../OutputChannel/OutputChannel.ipc.js');
88
90
  case ModuleId.Performance:
@@ -76,3 +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;
@@ -188,6 +188,10 @@ 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
195
  case 'PlatformPaths.getDisabledExtensionsJsonPath':
192
196
  case 'PlatformPaths.getDisabledExtensionsJsonUri':
193
197
  return ModuleId.PlatformPaths;
@@ -0,0 +1,7 @@
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
+ };
@@ -0,0 +1,151 @@
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
+ codeQueue: string[],
7
+ codePromise: Promise<string> | undefined,
8
+ resolveCode: ((value: string) => void) | undefined,
9
+ rejectCode: ((reason?: unknown) => void) | undefined,
10
+ }>} */
11
+ const states = Object.create(null);
12
+ const getOrCreateState = (id) => {
13
+ if (!states[id]) {
14
+ states[id] = {
15
+ server: undefined,
16
+ portPromise: undefined,
17
+ codeQueue: [],
18
+ codePromise: undefined,
19
+ resolveCode: undefined,
20
+ rejectCode: undefined,
21
+ };
22
+ }
23
+ return states[id];
24
+ };
25
+ const clearPendingCodePromise = (state) => {
26
+ state.codePromise = undefined;
27
+ state.resolveCode = undefined;
28
+ state.rejectCode = undefined;
29
+ };
30
+ const resolveCode = (state, code) => {
31
+ if (state.resolveCode) {
32
+ const { resolveCode } = state;
33
+ clearPendingCodePromise(state);
34
+ resolveCode(code);
35
+ return;
36
+ }
37
+ state.codeQueue.push(code);
38
+ };
39
+ const rejectPendingCode = (state, error) => {
40
+ if (!state.rejectCode) {
41
+ return;
42
+ }
43
+ const { rejectCode } = state;
44
+ clearPendingCodePromise(state);
45
+ rejectCode(error);
46
+ };
47
+ const getCodeFromRequest = (request) => {
48
+ if (!request.url) {
49
+ return undefined;
50
+ }
51
+ const url = new URL(request.url, 'http://localhost');
52
+ const code = url.searchParams.get('code');
53
+ return code || undefined;
54
+ };
55
+ const handleRequest = (id, request, response) => {
56
+ const state = states[id];
57
+ if (state) {
58
+ const code = getCodeFromRequest(request);
59
+ if (code) {
60
+ resolveCode(state, code);
61
+ }
62
+ }
63
+ response.writeHead(200, {
64
+ 'Content-Type': 'text/plain; charset=utf-8',
65
+ });
66
+ response.end('Authentication completed. You can close this window.');
67
+ };
68
+ const listen = (server) => {
69
+ const { promise, resolve, reject } = Promise.withResolvers();
70
+ const onError = (error) => {
71
+ server.off('listening', onListening);
72
+ reject(error);
73
+ };
74
+ const onListening = () => {
75
+ server.off('error', onError);
76
+ const address = server.address();
77
+ if (!address || typeof address === 'string') {
78
+ reject(new Error('failed to determine oauth server port'));
79
+ return;
80
+ }
81
+ resolve(address.port);
82
+ };
83
+ server.once('error', onError);
84
+ server.once('listening', onListening);
85
+ server.listen(0, 'localhost');
86
+ return promise;
87
+ };
88
+ const getOrCreateCodePromise = (state) => {
89
+ if (!state.codePromise) {
90
+ const { promise, resolve, reject } = Promise.withResolvers();
91
+ state.codePromise = promise;
92
+ state.resolveCode = resolve;
93
+ state.rejectCode = reject;
94
+ }
95
+ return state.codePromise;
96
+ };
97
+ export const create = async (id) => {
98
+ Assert.string(id);
99
+ const state = getOrCreateState(id);
100
+ if (state.portPromise) {
101
+ return state.portPromise;
102
+ }
103
+ const server = createServer((request, response) => {
104
+ handleRequest(id, request, response);
105
+ });
106
+ state.server = server;
107
+ state.portPromise = listen(server);
108
+ try {
109
+ return await state.portPromise;
110
+ }
111
+ catch (error) {
112
+ state.server = undefined;
113
+ state.portPromise = undefined;
114
+ delete states[id];
115
+ throw error;
116
+ }
117
+ };
118
+ export const getCode = async (id) => {
119
+ Assert.string(id);
120
+ const state = states[id];
121
+ if (!state || !state.server) {
122
+ throw new Error(`oauth server ${id} not found`);
123
+ }
124
+ if (state.codeQueue.length > 0) {
125
+ return state.codeQueue.shift();
126
+ }
127
+ return getOrCreateCodePromise(state);
128
+ };
129
+ export const dispose = async (id) => {
130
+ Assert.string(id);
131
+ const state = getOrCreateState(id);
132
+ if (!state.server) {
133
+ delete states[id];
134
+ return;
135
+ }
136
+ const { server } = state;
137
+ state.server = undefined;
138
+ state.portPromise = undefined;
139
+ state.codeQueue = [];
140
+ rejectPendingCode(state, new Error('oauth server disposed'));
141
+ const { promise, resolve, reject } = Promise.withResolvers();
142
+ server.close((error) => {
143
+ if (error) {
144
+ reject(error);
145
+ return;
146
+ }
147
+ resolve(undefined);
148
+ });
149
+ await promise;
150
+ delete states[id];
151
+ };
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
41
41
  export const getSetupName = () => {
42
42
  return 'Lvce-Setup';
43
43
  };
44
- export const version = '0.77.9';
45
- export const commit = '2c0fc7e';
46
- export const date = '2026-04-02T06:38:17.000Z';
44
+ export const version = '0.77.11';
45
+ export const commit = 'c0b16fe';
46
+ export const date = '2026-04-06T17:04:59.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', '2c0fc7e', 'packages', 'preload', 'dist', 'index.js');
4
+ return join(Root.root, 'static', 'c0b16fe', 'packages', 'preload', 'dist', 'index.js');
5
5
  };
@@ -17,6 +17,15 @@
17
17
  "hotReloadCommand": "ActivityBar.hotReload",
18
18
  "contentSecurityPolicy": ["default-src 'none'", "sandbox allow-same-origin"]
19
19
  },
20
+ {
21
+ "id": "authWorker",
22
+ "fileName": "authWorkerMain.js",
23
+ "defaultPath": "/packages/renderer-worker/node_modules/@lvce-editor/auth-worker/dist/authWorkerMain.js",
24
+ "productionPath": "/packages/auth-worker/dist/authWorkerMain.js",
25
+ "settingName": "develop.authWorkerPath",
26
+ "hotReloadCommand": "",
27
+ "contentSecurityPolicy": ["default-src 'none'", "connect-src *"]
28
+ },
20
29
  {
21
30
  "id": "chatDebug",
22
31
  "fileName": "chatDebugViewWorkerMain.js",
@@ -87,7 +96,8 @@
87
96
  "productionPath": "/packages/chat-view/dist/chatViewWorkerMain.js",
88
97
  "settingName": "develop.chatViewWorkerPath",
89
98
  "hotReloadCommand": "Chat.hotReload",
90
- "contentSecurityPolicy": ["default-src 'none'", "connect-src https://openrouter.ai https://api.openai.com", "sandbox allow-same-origin"]
99
+ "contentSecurityPolicy": ["default-src 'none'", "connect-src *", "sandbox allow-same-origin"],
100
+ "comment": "TODO need to adjust csp for connect src. maybe use a separate worker for connections"
91
101
  },
92
102
  {
93
103
  "id": "chatCoordinator",