vite-plugin-opencode-assistant 1.1.9 → 1.1.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/es/core/api.d.ts CHANGED
@@ -7,6 +7,8 @@ export declare class OpenCodeAPI {
7
7
  private warmupChromeMcpConfig;
8
8
  private chromeDevtoolsPort;
9
9
  constructor(hostname: string, getPort: () => number, getProxyPort: () => number, warmupChromeMcpConfig?: boolean, chromeDevtoolsPort?: number);
10
+ /** 构建代理 iframe URL(旧版格式:/{base64(projectDir)}/session/{id}) */
11
+ private buildSessionProxyUrl;
10
12
  private createHttpRequest;
11
13
  getSessions(projectDir: string, retries?: number): Promise<SessionInfo[]>;
12
14
  createSession(projectDir: string, retries?: number, title?: string): Promise<SessionInfo>;
package/es/core/api.mjs CHANGED
@@ -60,6 +60,10 @@ class OpenCodeAPI {
60
60
  __publicField(this, "warmupChromeMcpConfig", warmupChromeMcpConfig);
61
61
  __publicField(this, "chromeDevtoolsPort", chromeDevtoolsPort);
62
62
  }
63
+ /** 构建代理 iframe URL(旧版格式:/{base64(projectDir)}/session/{id}) */
64
+ buildSessionProxyUrl(projectDir, sessionId) {
65
+ return `http://${this.hostname}:${this.getProxyPort()}/${base64Encode(projectDir)}/session/${sessionId}`;
66
+ }
63
67
  createHttpRequest(options, body, timeout) {
64
68
  const timer = new PerformanceTimer("HTTP Request", {
65
69
  operation: `${options.method || "GET"} ${options.path}`
@@ -107,7 +111,7 @@ class OpenCodeAPI {
107
111
  path: `/session?directory=${encodeURIComponent(projectDir)}`
108
112
  });
109
113
  const sessionsWithUrl = sessions.map((s) => __spreadProps(__spreadValues({}, s), {
110
- url: s.directory ? `http://${this.hostname}:${this.getProxyPort()}/${base64Encode(s.directory)}/session/${s.id}` : ""
114
+ url: s.directory && s.id ? this.buildSessionProxyUrl(s.directory, s.id) : ""
111
115
  }));
112
116
  timer.end(`Found ${sessions.length} sessions`);
113
117
  return sessionsWithUrl;
@@ -151,7 +155,7 @@ class OpenCodeAPI {
151
155
  requestBody
152
156
  );
153
157
  const sessionWithUrl = __spreadProps(__spreadValues({}, session), {
154
- url: `http://${this.hostname}:${this.getProxyPort()}/${base64Encode(projectDir)}/session/${session.id}`
158
+ url: this.buildSessionProxyUrl(projectDir, session.id)
155
159
  });
156
160
  timer.end(`Created session: ${session.id}`);
157
161
  return sessionWithUrl;
@@ -450,13 +454,13 @@ class OpenCodeAPI {
450
454
  });
451
455
  const matchingSession = sessions.find((s) => s.directory === projectDir);
452
456
  if (matchingSession) {
453
- const url2 = `http://${this.hostname}:${this.getProxyPort()}/${base64Encode(projectDir)}/session/${matchingSession.id}`;
457
+ const url2 = this.buildSessionProxyUrl(projectDir, matchingSession.id);
454
458
  timer.end(`Using existing session: ${matchingSession.id}`);
455
459
  return url2;
456
460
  }
457
461
  log.debug("Creating new session...", { projectDir });
458
462
  const newSession = yield this.createSession(projectDir);
459
- const url = `http://${this.hostname}:${this.getProxyPort()}/${base64Encode(projectDir)}/session/${newSession.id}`;
463
+ const url = this.buildSessionProxyUrl(projectDir, newSession.id);
460
464
  timer.end(`Created new session: ${newSession.id}`);
461
465
  return url;
462
466
  });
@@ -641,6 +641,25 @@ function generateBridgeScript(options) {
641
641
 
642
642
  // === \u5C31\u7EEA\u901A\u77E5 ===
643
643
  function init() {
644
+ // \u6E05\u7406\u6B8B\u7559\u7684 session tabs \u5B58\u50A8\uFF0C\u907F\u514D\u52A0\u8F7D\u5DF2\u8FC7\u671F\u7684 session \u4EA7\u751F 404
645
+ // localStorage \u6309 origin \u9694\u79BB\uFF0C\u6BCF\u6B21 iframe \u91CD\u65B0\u52A0\u8F7D\u65F6\u6E05\u6389\u65E7\u7684 tab \u8BB0\u5F55
646
+ (function cleanupTabsStorage() {
647
+ try {
648
+ var keysToRemove = [];
649
+ for (var i = 0; i < localStorage.length; i++) {
650
+ var key = localStorage.key(i);
651
+ if (key && (key.indexOf('opencode.window') === 0 || key.indexOf('opencode.workspace') === 0)) {
652
+ keysToRemove.push(key);
653
+ }
654
+ }
655
+ for (var j = 0; j < keysToRemove.length; j++) {
656
+ localStorage.removeItem(keysToRemove[j]);
657
+ }
658
+ } catch (e) {
659
+ // localStorage \u4E0D\u53EF\u7528\u65F6\u5FFD\u7565
660
+ }
661
+ })();
662
+
644
663
  injectMinimizeStyles();
645
664
  injectReviewPanelStyles();
646
665
  injectGeneralStyles();
package/lib/core/api.cjs CHANGED
@@ -81,6 +81,10 @@ class OpenCodeAPI {
81
81
  __publicField(this, "warmupChromeMcpConfig", warmupChromeMcpConfig);
82
82
  __publicField(this, "chromeDevtoolsPort", chromeDevtoolsPort);
83
83
  }
84
+ /** 构建代理 iframe URL(旧版格式:/{base64(projectDir)}/session/{id}) */
85
+ buildSessionProxyUrl(projectDir, sessionId) {
86
+ return `http://${this.hostname}:${this.getProxyPort()}/${(0, import_shared.base64Encode)(projectDir)}/session/${sessionId}`;
87
+ }
84
88
  createHttpRequest(options, body, timeout) {
85
89
  const timer = new import_node.PerformanceTimer("HTTP Request", {
86
90
  operation: `${options.method || "GET"} ${options.path}`
@@ -128,7 +132,7 @@ class OpenCodeAPI {
128
132
  path: `/session?directory=${encodeURIComponent(projectDir)}`
129
133
  });
130
134
  const sessionsWithUrl = sessions.map((s) => __spreadProps(__spreadValues({}, s), {
131
- url: s.directory ? `http://${this.hostname}:${this.getProxyPort()}/${(0, import_shared.base64Encode)(s.directory)}/session/${s.id}` : ""
135
+ url: s.directory && s.id ? this.buildSessionProxyUrl(s.directory, s.id) : ""
132
136
  }));
133
137
  timer.end(`Found ${sessions.length} sessions`);
134
138
  return sessionsWithUrl;
@@ -172,7 +176,7 @@ class OpenCodeAPI {
172
176
  requestBody
173
177
  );
174
178
  const sessionWithUrl = __spreadProps(__spreadValues({}, session), {
175
- url: `http://${this.hostname}:${this.getProxyPort()}/${(0, import_shared.base64Encode)(projectDir)}/session/${session.id}`
179
+ url: this.buildSessionProxyUrl(projectDir, session.id)
176
180
  });
177
181
  timer.end(`Created session: ${session.id}`);
178
182
  return sessionWithUrl;
@@ -471,13 +475,13 @@ class OpenCodeAPI {
471
475
  });
472
476
  const matchingSession = sessions.find((s) => s.directory === projectDir);
473
477
  if (matchingSession) {
474
- const url2 = `http://${this.hostname}:${this.getProxyPort()}/${(0, import_shared.base64Encode)(projectDir)}/session/${matchingSession.id}`;
478
+ const url2 = this.buildSessionProxyUrl(projectDir, matchingSession.id);
475
479
  timer.end(`Using existing session: ${matchingSession.id}`);
476
480
  return url2;
477
481
  }
478
482
  log.debug("Creating new session...", { projectDir });
479
483
  const newSession = yield this.createSession(projectDir);
480
- const url = `http://${this.hostname}:${this.getProxyPort()}/${(0, import_shared.base64Encode)(projectDir)}/session/${newSession.id}`;
484
+ const url = this.buildSessionProxyUrl(projectDir, newSession.id);
481
485
  timer.end(`Created new session: ${newSession.id}`);
482
486
  return url;
483
487
  });
package/lib/core/api.d.ts CHANGED
@@ -7,6 +7,8 @@ export declare class OpenCodeAPI {
7
7
  private warmupChromeMcpConfig;
8
8
  private chromeDevtoolsPort;
9
9
  constructor(hostname: string, getPort: () => number, getProxyPort: () => number, warmupChromeMcpConfig?: boolean, chromeDevtoolsPort?: number);
10
+ /** 构建代理 iframe URL(旧版格式:/{base64(projectDir)}/session/{id}) */
11
+ private buildSessionProxyUrl;
10
12
  private createHttpRequest;
11
13
  getSessions(projectDir: string, retries?: number): Promise<SessionInfo[]>;
12
14
  createSession(projectDir: string, retries?: number, title?: string): Promise<SessionInfo>;
@@ -665,6 +665,25 @@ function generateBridgeScript(options) {
665
665
 
666
666
  // === \u5C31\u7EEA\u901A\u77E5 ===
667
667
  function init() {
668
+ // \u6E05\u7406\u6B8B\u7559\u7684 session tabs \u5B58\u50A8\uFF0C\u907F\u514D\u52A0\u8F7D\u5DF2\u8FC7\u671F\u7684 session \u4EA7\u751F 404
669
+ // localStorage \u6309 origin \u9694\u79BB\uFF0C\u6BCF\u6B21 iframe \u91CD\u65B0\u52A0\u8F7D\u65F6\u6E05\u6389\u65E7\u7684 tab \u8BB0\u5F55
670
+ (function cleanupTabsStorage() {
671
+ try {
672
+ var keysToRemove = [];
673
+ for (var i = 0; i < localStorage.length; i++) {
674
+ var key = localStorage.key(i);
675
+ if (key && (key.indexOf('opencode.window') === 0 || key.indexOf('opencode.workspace') === 0)) {
676
+ keysToRemove.push(key);
677
+ }
678
+ }
679
+ for (var j = 0; j < keysToRemove.length; j++) {
680
+ localStorage.removeItem(keysToRemove[j]);
681
+ }
682
+ } catch (e) {
683
+ // localStorage \u4E0D\u53EF\u7528\u65F6\u5FFD\u7565
684
+ }
685
+ })();
686
+
668
687
  injectMinimizeStyles();
669
688
  injectReviewPanelStyles();
670
689
  injectGeneralStyles();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-opencode-assistant",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
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/opencode": "1.1.9",
41
- "@vite-plugin-opencode-assistant/shared": "1.1.9",
42
- "@vite-plugin-opencode-assistant/components": "1.1.9"
40
+ "@vite-plugin-opencode-assistant/opencode": "1.1.11",
41
+ "@vite-plugin-opencode-assistant/components": "1.1.11",
42
+ "@vite-plugin-opencode-assistant/shared": "1.1.11"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vite": ">=5.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@vite-plugin-opencode-assistant/client": "1.1.9"
48
+ "@vite-plugin-opencode-assistant/client": "1.1.11"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "pagoda-cli build && vite build -c vite.client.config.ts",