vite-plugin-opencode-assistant 1.0.7 → 1.0.9

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.
@@ -41,13 +41,21 @@ import { createApp, ref, watch, onMounted, h, computed } from "vue";
41
41
  import { OpenCodeWidget } from "@vite-plugin-opencode-assistant/components";
42
42
  import "@vite-plugin-opencode-assistant/components/style.css";
43
43
  import { CONFIG_DATA_ATTR } from "@vite-plugin-opencode-assistant/shared";
44
+ function utf8ToBase64(str) {
45
+ const bytes = new TextEncoder().encode(str);
46
+ const binString = Array.from(bytes, (byte) => String.fromCodePoint(byte)).join("");
47
+ return btoa(binString);
48
+ }
44
49
  let config = {};
45
50
  const scriptTag = document.querySelector(`script[${CONFIG_DATA_ATTR}]`);
46
51
  if (scriptTag) {
47
52
  const configBase64 = scriptTag.getAttribute(CONFIG_DATA_ATTR);
48
53
  if (configBase64) {
49
54
  try {
50
- config = JSON.parse(atob(configBase64));
55
+ const decoded = new TextDecoder().decode(
56
+ Uint8Array.from(atob(configBase64), (c) => c.charCodeAt(0))
57
+ );
58
+ config = JSON.parse(decoded);
51
59
  } catch (e) {
52
60
  console.error("[OpenCode] Failed to parse config:", e);
53
61
  }
@@ -128,7 +136,7 @@ const App = {
128
136
  const newSession = yield response.json();
129
137
  yield loadSessions();
130
138
  currentSessionId.value = newSession.id;
131
- iframeSrc.value = `${webUrl}/${btoa(cwd)}/session/${newSession.id}`;
139
+ iframeSrc.value = `${webUrl}/${utf8ToBase64(cwd)}/session/${newSession.id}`;
132
140
  } catch (e) {
133
141
  showNotification("\u521B\u5EFA\u4F1A\u8BDD\u5931\u8D25");
134
142
  }
@@ -142,7 +150,7 @@ const App = {
142
150
  if (sessions.value.length > 0) {
143
151
  const nextSession = sessions.value[0];
144
152
  currentSessionId.value = nextSession.id;
145
- iframeSrc.value = `${webUrl}/${btoa(cwd)}/session/${nextSession.id}`;
153
+ iframeSrc.value = `${webUrl}/${utf8ToBase64(cwd)}/session/${nextSession.id}`;
146
154
  } else {
147
155
  currentSessionId.value = null;
148
156
  iframeSrc.value = "";
@@ -156,7 +164,7 @@ const App = {
156
164
  if (currentSessionId.value === session.id) return;
157
165
  currentSessionId.value = session.id;
158
166
  loading.value = true;
159
- iframeSrc.value = `${webUrl}/${btoa(cwd)}/session/${session.id}`;
167
+ iframeSrc.value = `${webUrl}/${utf8ToBase64(cwd)}/session/${session.id}`;
160
168
  setTimeout(() => {
161
169
  loading.value = false;
162
170
  }, 500);
@@ -296,6 +304,7 @@ const App = {
296
304
  iframeSrc: iframeSrc.value,
297
305
  currentSessionId: currentSessionId.value,
298
306
  sessions: sessions.value,
307
+ sessionKey: "id",
299
308
  selectedElements: selectedElements.value,
300
309
  hotkeyLabel: hotkey,
301
310
  "onUpdate:open": handleToggle,
@@ -41,13 +41,21 @@ var import_vue = require("vue");
41
41
  var import_components = require("@vite-plugin-opencode-assistant/components");
42
42
  var import_style = require("@vite-plugin-opencode-assistant/components/style.css");
43
43
  var import_shared = require("@vite-plugin-opencode-assistant/shared");
44
+ function utf8ToBase64(str) {
45
+ const bytes = new TextEncoder().encode(str);
46
+ const binString = Array.from(bytes, (byte) => String.fromCodePoint(byte)).join("");
47
+ return btoa(binString);
48
+ }
44
49
  let config = {};
45
50
  const scriptTag = document.querySelector(`script[${import_shared.CONFIG_DATA_ATTR}]`);
46
51
  if (scriptTag) {
47
52
  const configBase64 = scriptTag.getAttribute(import_shared.CONFIG_DATA_ATTR);
48
53
  if (configBase64) {
49
54
  try {
50
- config = JSON.parse(atob(configBase64));
55
+ const decoded = new TextDecoder().decode(
56
+ Uint8Array.from(atob(configBase64), (c) => c.charCodeAt(0))
57
+ );
58
+ config = JSON.parse(decoded);
51
59
  } catch (e) {
52
60
  console.error("[OpenCode] Failed to parse config:", e);
53
61
  }
@@ -128,7 +136,7 @@ const App = {
128
136
  const newSession = yield response.json();
129
137
  yield loadSessions();
130
138
  currentSessionId.value = newSession.id;
131
- iframeSrc.value = `${webUrl}/${btoa(cwd)}/session/${newSession.id}`;
139
+ iframeSrc.value = `${webUrl}/${utf8ToBase64(cwd)}/session/${newSession.id}`;
132
140
  } catch (e) {
133
141
  showNotification("\u521B\u5EFA\u4F1A\u8BDD\u5931\u8D25");
134
142
  }
@@ -142,7 +150,7 @@ const App = {
142
150
  if (sessions.value.length > 0) {
143
151
  const nextSession = sessions.value[0];
144
152
  currentSessionId.value = nextSession.id;
145
- iframeSrc.value = `${webUrl}/${btoa(cwd)}/session/${nextSession.id}`;
153
+ iframeSrc.value = `${webUrl}/${utf8ToBase64(cwd)}/session/${nextSession.id}`;
146
154
  } else {
147
155
  currentSessionId.value = null;
148
156
  iframeSrc.value = "";
@@ -156,7 +164,7 @@ const App = {
156
164
  if (currentSessionId.value === session.id) return;
157
165
  currentSessionId.value = session.id;
158
166
  loading.value = true;
159
- iframeSrc.value = `${webUrl}/${btoa(cwd)}/session/${session.id}`;
167
+ iframeSrc.value = `${webUrl}/${utf8ToBase64(cwd)}/session/${session.id}`;
160
168
  setTimeout(() => {
161
169
  loading.value = false;
162
170
  }, 500);
@@ -296,6 +304,7 @@ const App = {
296
304
  iframeSrc: iframeSrc.value,
297
305
  currentSessionId: currentSessionId.value,
298
306
  sessions: sessions.value,
307
+ sessionKey: "id",
299
308
  selectedElements: selectedElements.value,
300
309
  hotkeyLabel: hotkey,
301
310
  "onUpdate:open": handleToggle,