vite-plugin-opencode-assistant 1.1.8 → 1.1.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.
|
@@ -9,6 +9,8 @@ export interface ProxyServerOptions {
|
|
|
9
9
|
settings?: OpenCodeSettings;
|
|
10
10
|
/** 绑定地址,需与端口检查使用的地址族一致,避免 IPv4/IPv6 不匹配 */
|
|
11
11
|
hostname?: string;
|
|
12
|
+
/** 项目目录,用于路径重写(代理 /session/* 请求时添加 base64 目录前缀) */
|
|
13
|
+
projectDir?: string;
|
|
12
14
|
}
|
|
13
15
|
export interface ProxyServerResult {
|
|
14
16
|
server: http.Server;
|
package/es/core/proxy-server.mjs
CHANGED
|
@@ -23,7 +23,8 @@ import {
|
|
|
23
23
|
DEFAULT_OPENCODE_SETTINGS,
|
|
24
24
|
OPENCODE_STORAGE_KEYS,
|
|
25
25
|
WIDGET_MSG,
|
|
26
|
-
BRIDGE_SCRIPT_PATH
|
|
26
|
+
BRIDGE_SCRIPT_PATH,
|
|
27
|
+
base64Encode
|
|
27
28
|
} from "@vite-plugin-opencode-assistant/shared";
|
|
28
29
|
const log = createLogger("ProxyServer");
|
|
29
30
|
function mergeSettings(defaultSettings, userSettings) {
|
|
@@ -679,6 +680,7 @@ function startProxyServer(targetUrl, port, options = {}) {
|
|
|
679
680
|
return new Promise((resolve, reject) => {
|
|
680
681
|
const target = new URL(targetUrl);
|
|
681
682
|
const bridgeScript = generateBridgeScript(options);
|
|
683
|
+
const base64Dir = options.projectDir ? base64Encode(options.projectDir) : "";
|
|
682
684
|
const server = http.createServer((req, res) => {
|
|
683
685
|
if (req.url === BRIDGE_SCRIPT_PATH) {
|
|
684
686
|
const body = bridgeScript;
|
|
@@ -690,10 +692,14 @@ function startProxyServer(targetUrl, port, options = {}) {
|
|
|
690
692
|
res.end(body);
|
|
691
693
|
return;
|
|
692
694
|
}
|
|
695
|
+
let reqPath = req.url || "/";
|
|
696
|
+
if (base64Dir && reqPath.startsWith("/session/") && !reqPath.startsWith(`/${base64Dir}/`)) {
|
|
697
|
+
reqPath = `/${base64Dir}${reqPath}`;
|
|
698
|
+
}
|
|
693
699
|
const requestOptions = {
|
|
694
700
|
hostname: target.hostname,
|
|
695
701
|
port: target.port,
|
|
696
|
-
path:
|
|
702
|
+
path: reqPath,
|
|
697
703
|
method: req.method,
|
|
698
704
|
headers: __spreadProps(__spreadValues({}, req.headers), {
|
|
699
705
|
host: target.host,
|
package/es/core/service.mjs
CHANGED
|
@@ -98,7 +98,7 @@ class OpenCodeService {
|
|
|
98
98
|
return this.startPromise;
|
|
99
99
|
}
|
|
100
100
|
this.startPromise = (() => __async(this, null, function* () {
|
|
101
|
-
var _a, _b, _c, _d, _e;
|
|
101
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
102
102
|
const timer = log.timer("startServices", {
|
|
103
103
|
corsOrigins,
|
|
104
104
|
contextApiUrl,
|
|
@@ -205,7 +205,8 @@ Please install OpenCode first:
|
|
|
205
205
|
theme: this.config.theme,
|
|
206
206
|
language: this.config.language,
|
|
207
207
|
settings: this.config.settings,
|
|
208
|
-
hostname: this.config.hostname
|
|
208
|
+
hostname: this.config.hostname,
|
|
209
|
+
projectDir: (_f = this.workspaceRoot) != null ? _f : void 0
|
|
209
210
|
});
|
|
210
211
|
this.proxyServer = result.server;
|
|
211
212
|
if (result.actualPort !== this.actualProxyPort) {
|
|
@@ -224,7 +225,8 @@ Please install OpenCode first:
|
|
|
224
225
|
theme: this.config.theme,
|
|
225
226
|
language: this.config.language,
|
|
226
227
|
settings: this.config.settings,
|
|
227
|
-
hostname: this.config.hostname
|
|
228
|
+
hostname: this.config.hostname,
|
|
229
|
+
projectDir: (_g = this.workspaceRoot) != null ? _g : void 0
|
|
228
230
|
});
|
|
229
231
|
this.proxyServer = result.server;
|
|
230
232
|
this.actualProxyPort = result.actualPort;
|
package/lib/client.js
CHANGED
|
@@ -5831,7 +5831,7 @@ var Ph = Object.defineProperty, Mh = Object.defineProperties, Ih = Object.getOwn
|
|
|
5831
5831
|
y: Math.max(10, Math.min(x.bubbleOffset.y, Kt))
|
|
5832
5832
|
};
|
|
5833
5833
|
}
|
|
5834
|
-
x.theme !== void 0 && x.theme !== r.theme && (s("update:theme", x.theme), s("toggle-theme", x.theme)), x.sessionListCollapsed !== void 0 && x.sessionListCollapsed !== r.sessionListCollapsed && (U.value = x.sessionListCollapsed, s("update:sessionListCollapsed", x.sessionListCollapsed)), x.promptDockVisible !== void 0 ? Y.value = x.promptDockVisible : B.value && (Y.value = !1), x.reviewPanelVisible !== void 0 && (le.value = x.reviewPanelVisible), x.splitPanelWidth !== void 0 && x.splitPanelWidth !== r.splitPanelWidth && ae(x.splitPanelWidth), x.displayMode !== void 0 && x.displayMode !== r.displayMode && (N.value = x.displayMode), x.splitPosition !== void 0 && (j.value = x.splitPosition), Mi(() => {
|
|
5834
|
+
x.theme !== void 0 && x.theme !== r.theme && (s("update:theme", x.theme), s("toggle-theme", x.theme)), x.sessionListCollapsed !== void 0 && x.sessionListCollapsed !== r.sessionListCollapsed && (U.value = x.sessionListCollapsed, s("update:sessionListCollapsed", x.sessionListCollapsed)), x.promptDockVisible !== void 0 ? Y.value = x.promptDockVisible : B.value && (Y.value = !1), x.reviewPanelVisible !== void 0 && (le.value = x.reviewPanelVisible), x.splitPanelWidth !== void 0 && x.splitPanelWidth !== r.splitPanelWidth && ae(x.splitPanelWidth), x.displayMode !== void 0 && x.displayMode !== r.displayMode && r.displayMode !== "extension" && r.displayMode !== "extension-selector" && (N.value = x.displayMode), x.splitPosition !== void 0 && (j.value = x.splitPosition), Mi(() => {
|
|
5835
5835
|
Q(), setTimeout(() => {
|
|
5836
5836
|
fe.value = !1;
|
|
5837
5837
|
}, 50);
|
|
@@ -703,6 +703,7 @@ function startProxyServer(targetUrl, port, options = {}) {
|
|
|
703
703
|
return new Promise((resolve, reject) => {
|
|
704
704
|
const target = new URL(targetUrl);
|
|
705
705
|
const bridgeScript = generateBridgeScript(options);
|
|
706
|
+
const base64Dir = options.projectDir ? (0, import_shared.base64Encode)(options.projectDir) : "";
|
|
706
707
|
const server = import_http.default.createServer((req, res) => {
|
|
707
708
|
if (req.url === import_shared.BRIDGE_SCRIPT_PATH) {
|
|
708
709
|
const body = bridgeScript;
|
|
@@ -714,10 +715,14 @@ function startProxyServer(targetUrl, port, options = {}) {
|
|
|
714
715
|
res.end(body);
|
|
715
716
|
return;
|
|
716
717
|
}
|
|
718
|
+
let reqPath = req.url || "/";
|
|
719
|
+
if (base64Dir && reqPath.startsWith("/session/") && !reqPath.startsWith(`/${base64Dir}/`)) {
|
|
720
|
+
reqPath = `/${base64Dir}${reqPath}`;
|
|
721
|
+
}
|
|
717
722
|
const requestOptions = {
|
|
718
723
|
hostname: target.hostname,
|
|
719
724
|
port: target.port,
|
|
720
|
-
path:
|
|
725
|
+
path: reqPath,
|
|
721
726
|
method: req.method,
|
|
722
727
|
headers: __spreadProps(__spreadValues({}, req.headers), {
|
|
723
728
|
host: target.host,
|
|
@@ -9,6 +9,8 @@ export interface ProxyServerOptions {
|
|
|
9
9
|
settings?: OpenCodeSettings;
|
|
10
10
|
/** 绑定地址,需与端口检查使用的地址族一致,避免 IPv4/IPv6 不匹配 */
|
|
11
11
|
hostname?: string;
|
|
12
|
+
/** 项目目录,用于路径重写(代理 /session/* 请求时添加 base64 目录前缀) */
|
|
13
|
+
projectDir?: string;
|
|
12
14
|
}
|
|
13
15
|
export interface ProxyServerResult {
|
|
14
16
|
server: http.Server;
|
package/lib/core/service.cjs
CHANGED
|
@@ -106,7 +106,7 @@ class OpenCodeService {
|
|
|
106
106
|
return this.startPromise;
|
|
107
107
|
}
|
|
108
108
|
this.startPromise = (() => __async(this, null, function* () {
|
|
109
|
-
var _a, _b, _c, _d, _e;
|
|
109
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
110
110
|
const timer = log.timer("startServices", {
|
|
111
111
|
corsOrigins,
|
|
112
112
|
contextApiUrl,
|
|
@@ -213,7 +213,8 @@ Please install OpenCode first:
|
|
|
213
213
|
theme: this.config.theme,
|
|
214
214
|
language: this.config.language,
|
|
215
215
|
settings: this.config.settings,
|
|
216
|
-
hostname: this.config.hostname
|
|
216
|
+
hostname: this.config.hostname,
|
|
217
|
+
projectDir: (_f = this.workspaceRoot) != null ? _f : void 0
|
|
217
218
|
});
|
|
218
219
|
this.proxyServer = result.server;
|
|
219
220
|
if (result.actualPort !== this.actualProxyPort) {
|
|
@@ -232,7 +233,8 @@ Please install OpenCode first:
|
|
|
232
233
|
theme: this.config.theme,
|
|
233
234
|
language: this.config.language,
|
|
234
235
|
settings: this.config.settings,
|
|
235
|
-
hostname: this.config.hostname
|
|
236
|
+
hostname: this.config.hostname,
|
|
237
|
+
projectDir: (_g = this.workspaceRoot) != null ? _g : void 0
|
|
236
238
|
});
|
|
237
239
|
this.proxyServer = result.server;
|
|
238
240
|
this.actualProxyPort = result.actualPort;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-opencode-assistant",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "Embed OpenCode Web UI in your Vite dev server for real-time code modification and preview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"unplugin-vue-inspector": "^3.0.0",
|
|
39
39
|
"execa": "^9.6.1",
|
|
40
|
-
"@vite-plugin-opencode-assistant/
|
|
41
|
-
"@vite-plugin-opencode-assistant/
|
|
42
|
-
"@vite-plugin-opencode-assistant/
|
|
40
|
+
"@vite-plugin-opencode-assistant/opencode": "1.1.10",
|
|
41
|
+
"@vite-plugin-opencode-assistant/shared": "1.1.10",
|
|
42
|
+
"@vite-plugin-opencode-assistant/components": "1.1.10"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vite": ">=5.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@vite-plugin-opencode-assistant/client": "1.1.
|
|
48
|
+
"@vite-plugin-opencode-assistant/client": "1.1.10"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "pagoda-cli build && vite build -c vite.client.config.ts",
|