vite-plugin-opencode-assistant 1.0.74 → 1.0.76
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/injector.mjs +6 -2
- package/es/core/proxy-server.mjs +19 -13
- package/es/endpoints/index.d.ts +1 -1
- package/es/endpoints/index.mjs +3 -2
- package/es/endpoints/logs.d.ts +0 -2
- package/es/endpoints/logs.mjs +4 -4
- package/es/endpoints/start.d.ts +2 -1
- package/es/endpoints/start.mjs +6 -2
- package/es/endpoints/types.d.ts +2 -0
- package/es/endpoints/warmup.mjs +2 -2
- package/es/endpoints/widget.mjs +1 -2
- package/es/env.d.ts +1 -0
- package/es/index.mjs +7 -1
- package/lib/client.js +3481 -3287
- package/lib/core/injector.cjs +1 -1
- package/lib/core/proxy-server.cjs +16 -12
- package/lib/endpoints/index.cjs +3 -2
- package/lib/endpoints/index.d.ts +1 -1
- package/lib/endpoints/logs.cjs +2 -5
- package/lib/endpoints/logs.d.ts +0 -2
- package/lib/endpoints/start.cjs +6 -2
- package/lib/endpoints/start.d.ts +2 -1
- package/lib/endpoints/types.d.ts +2 -0
- package/lib/endpoints/warmup.cjs +1 -1
- package/lib/endpoints/widget.cjs +2 -3
- package/lib/env.d.ts +1 -0
- package/lib/index.cjs +7 -1
- package/lib/style.css +1 -1
- package/package.json +8 -4
- package/es/client/App.vue.d.ts +0 -6
- package/es/client/App.vue.mjs +0 -394
- package/es/client/components/ChromeWarmupError-sfc.css +0 -1
- package/es/client/components/ChromeWarmupError.vue.d.ts +0 -19
- package/es/client/components/ChromeWarmupError.vue.mjs +0 -337
- package/es/client/components/LoadingContent.vue.d.ts +0 -5
- package/es/client/components/LoadingContent.vue.mjs +0 -39
- package/es/client/composables/index.d.ts +0 -10
- package/es/client/composables/index.mjs +0 -22
- package/es/client/composables/useContext.d.ts +0 -8
- package/es/client/composables/useContext.mjs +0 -63
- package/es/client/composables/useHotkey.d.ts +0 -12
- package/es/client/composables/useHotkey.mjs +0 -41
- package/es/client/composables/useOpencodeSSE.d.ts +0 -64
- package/es/client/composables/useOpencodeSSE.mjs +0 -29
- package/es/client/composables/useOpencodeSessionSSE.d.ts +0 -66
- package/es/client/composables/useOpencodeSessionSSE.mjs +0 -168
- package/es/client/composables/useSSE.d.ts +0 -87
- package/es/client/composables/useSSE.mjs +0 -118
- package/es/client/composables/useSelectedElements.d.ts +0 -19
- package/es/client/composables/useSelectedElements.mjs +0 -43
- package/es/client/composables/useServerSSE.d.ts +0 -53
- package/es/client/composables/useServerSSE.mjs +0 -36
- package/es/client/composables/useServiceStatus.d.ts +0 -11
- package/es/client/composables/useServiceStatus.mjs +0 -47
- package/es/client/composables/useSessions.d.ts +0 -45
- package/es/client/composables/useSessions.mjs +0 -147
- package/es/client/composables/useTheme.d.ts +0 -12
- package/es/client/composables/useTheme.mjs +0 -42
- package/es/client/index.d.ts +0 -1
- package/es/client/index.mjs +0 -32
- package/es/client/styles.css +0 -1
- package/lib/client/App.vue.cjs +0 -421
- package/lib/client/App.vue.d.ts +0 -6
- package/lib/client/components/ChromeWarmupError-sfc.css +0 -1
- package/lib/client/components/ChromeWarmupError.vue.cjs +0 -356
- package/lib/client/components/ChromeWarmupError.vue.d.ts +0 -19
- package/lib/client/components/LoadingContent.vue.cjs +0 -58
- package/lib/client/components/LoadingContent.vue.d.ts +0 -5
- package/lib/client/composables/index.cjs +0 -54
- package/lib/client/composables/index.d.ts +0 -10
- package/lib/client/composables/useContext.cjs +0 -86
- package/lib/client/composables/useContext.d.ts +0 -8
- package/lib/client/composables/useHotkey.cjs +0 -66
- package/lib/client/composables/useHotkey.d.ts +0 -12
- package/lib/client/composables/useOpencodeSSE.cjs +0 -52
- package/lib/client/composables/useOpencodeSSE.d.ts +0 -64
- package/lib/client/composables/useOpencodeSessionSSE.cjs +0 -187
- package/lib/client/composables/useOpencodeSessionSSE.d.ts +0 -66
- package/lib/client/composables/useSSE.cjs +0 -141
- package/lib/client/composables/useSSE.d.ts +0 -87
- package/lib/client/composables/useSelectedElements.cjs +0 -66
- package/lib/client/composables/useSelectedElements.d.ts +0 -19
- package/lib/client/composables/useServerSSE.cjs +0 -59
- package/lib/client/composables/useServerSSE.d.ts +0 -53
- package/lib/client/composables/useServiceStatus.cjs +0 -70
- package/lib/client/composables/useServiceStatus.d.ts +0 -11
- package/lib/client/composables/useSessions.cjs +0 -168
- package/lib/client/composables/useSessions.d.ts +0 -45
- package/lib/client/composables/useTheme.cjs +0 -65
- package/lib/client/composables/useTheme.d.ts +0 -12
- package/lib/client/index.cjs +0 -54
- package/lib/client/index.d.ts +0 -1
- package/lib/client/styles.css +0 -1
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type Ref } from "vue";
|
|
2
|
-
import type { OpenCodeWidgetSession } from "@vite-plugin-opencode-assistant/shared";
|
|
3
|
-
export interface UseSessionsOptions {
|
|
4
|
-
showNotification: (msg: string) => void;
|
|
5
|
-
/** Session 更新回调 (从 SSE 事件接收) */
|
|
6
|
-
onSessionUpdate?: Ref<((session: {
|
|
7
|
-
id: string;
|
|
8
|
-
title?: string;
|
|
9
|
-
time?: {
|
|
10
|
-
updated?: number;
|
|
11
|
-
};
|
|
12
|
-
}) => void) | undefined>;
|
|
13
|
-
}
|
|
14
|
-
export declare function useSessions(options: UseSessionsOptions): {
|
|
15
|
-
sessions: Ref<{
|
|
16
|
-
id: string;
|
|
17
|
-
title?: string | undefined;
|
|
18
|
-
updatedAt?: (string | number | Date) | undefined;
|
|
19
|
-
meta?: string | undefined;
|
|
20
|
-
directory?: string | undefined;
|
|
21
|
-
url?: string | undefined;
|
|
22
|
-
}[], OpenCodeWidgetSession[] | {
|
|
23
|
-
id: string;
|
|
24
|
-
title?: string | undefined;
|
|
25
|
-
updatedAt?: (string | number | Date) | undefined;
|
|
26
|
-
meta?: string | undefined;
|
|
27
|
-
directory?: string | undefined;
|
|
28
|
-
url?: string | undefined;
|
|
29
|
-
}[]>;
|
|
30
|
-
loadingSessionList: Ref<boolean | undefined, boolean | undefined>;
|
|
31
|
-
currentSessionId: Ref<string | null, string | null>;
|
|
32
|
-
iframeSrc: import("vue").ComputedRef<string>;
|
|
33
|
-
iframeLoading: Ref<boolean, boolean>;
|
|
34
|
-
loadSessions: () => Promise<void>;
|
|
35
|
-
createSession: () => Promise<void>;
|
|
36
|
-
deleteSession: (session: OpenCodeWidgetSession) => Promise<void>;
|
|
37
|
-
selectSession: (session: OpenCodeWidgetSession) => void;
|
|
38
|
-
updateSessionInfo: (sessionUpdate: {
|
|
39
|
-
id: string;
|
|
40
|
-
title?: string;
|
|
41
|
-
time?: {
|
|
42
|
-
updated?: number;
|
|
43
|
-
};
|
|
44
|
-
}) => void;
|
|
45
|
-
};
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
import { ref, computed } from "vue";
|
|
41
|
-
import { SESSIONS_API_PATH } from "@vite-plugin-opencode-assistant/shared";
|
|
42
|
-
function useSessions(options) {
|
|
43
|
-
const { showNotification } = options;
|
|
44
|
-
const sessions = ref([]);
|
|
45
|
-
const loadingSessionList = ref(void 0);
|
|
46
|
-
const currentSessionId = ref(null);
|
|
47
|
-
const iframeLoading = ref(false);
|
|
48
|
-
const iframeSrc = computed(() => {
|
|
49
|
-
var _a;
|
|
50
|
-
return currentSessionId.value ? ((_a = sessions.value.find((s) => s.id === currentSessionId.value)) == null ? void 0 : _a.url) || "" : "";
|
|
51
|
-
});
|
|
52
|
-
const loadSessions = () => __async(null, null, function* () {
|
|
53
|
-
var _a;
|
|
54
|
-
loadingSessionList.value = true;
|
|
55
|
-
try {
|
|
56
|
-
const response = yield fetch(SESSIONS_API_PATH);
|
|
57
|
-
const data = yield response.json();
|
|
58
|
-
sessions.value = data.filter((s) => {
|
|
59
|
-
var _a2;
|
|
60
|
-
if (s.title === "__chrome_mcp_warmup__") return false;
|
|
61
|
-
if (s.parentID) return false;
|
|
62
|
-
if ((_a2 = s.time) == null ? void 0 : _a2.archived) return false;
|
|
63
|
-
return true;
|
|
64
|
-
}).map((s) => {
|
|
65
|
-
var _a2;
|
|
66
|
-
return __spreadProps(__spreadValues({}, s), {
|
|
67
|
-
updatedAt: ((_a2 = s.time) == null ? void 0 : _a2.updated) || Date.now()
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
if (!sessions.value.length) {
|
|
71
|
-
createSession();
|
|
72
|
-
}
|
|
73
|
-
currentSessionId.value = ((_a = sessions.value[0]) == null ? void 0 : _a.id) || null;
|
|
74
|
-
} catch (e) {
|
|
75
|
-
console.error("[OpenCode] Failed to load sessions:", e);
|
|
76
|
-
} finally {
|
|
77
|
-
loadingSessionList.value = false;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const updateSessionInfo = (sessionUpdate) => {
|
|
81
|
-
var _a;
|
|
82
|
-
const index = sessions.value.findIndex((s) => s.id === sessionUpdate.id);
|
|
83
|
-
if (index === -1) return;
|
|
84
|
-
const session = sessions.value[index];
|
|
85
|
-
if (sessionUpdate.title && sessionUpdate.title !== session.title) {
|
|
86
|
-
sessions.value[index] = __spreadProps(__spreadValues({}, session), {
|
|
87
|
-
title: sessionUpdate.title,
|
|
88
|
-
updatedAt: ((_a = sessionUpdate.time) == null ? void 0 : _a.updated) || Date.now()
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const createSession = () => __async(null, null, function* () {
|
|
93
|
-
try {
|
|
94
|
-
const response = yield fetch(SESSIONS_API_PATH, { method: "POST" });
|
|
95
|
-
const newSession = yield response.json();
|
|
96
|
-
sessions.value.unshift({
|
|
97
|
-
id: newSession.id,
|
|
98
|
-
title: "\u65B0\u4F1A\u8BDD",
|
|
99
|
-
updatedAt: Date.now(),
|
|
100
|
-
url: newSession.url
|
|
101
|
-
});
|
|
102
|
-
currentSessionId.value = newSession.id;
|
|
103
|
-
iframeLoading.value = true;
|
|
104
|
-
loadSessions();
|
|
105
|
-
} catch (e) {
|
|
106
|
-
showNotification("\u521B\u5EFA\u4F1A\u8BDD\u5931\u8D25");
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
const deleteSession = (session) => __async(null, null, function* () {
|
|
110
|
-
try {
|
|
111
|
-
yield fetch(`${SESSIONS_API_PATH}?id=${session.id}`, { method: "DELETE" });
|
|
112
|
-
yield loadSessions();
|
|
113
|
-
showNotification("\u4F1A\u8BDD\u5DF2\u5220\u9664");
|
|
114
|
-
if (currentSessionId.value === session.id) {
|
|
115
|
-
if (sessions.value.length > 0) {
|
|
116
|
-
const nextSession = sessions.value[0];
|
|
117
|
-
currentSessionId.value = nextSession.id;
|
|
118
|
-
iframeLoading.value = true;
|
|
119
|
-
} else {
|
|
120
|
-
currentSessionId.value = null;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
} catch (e) {
|
|
124
|
-
showNotification("\u5220\u9664\u4F1A\u8BDD\u5931\u8D25");
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const selectSession = (session) => {
|
|
128
|
-
if (currentSessionId.value === session.id) return;
|
|
129
|
-
currentSessionId.value = session.id;
|
|
130
|
-
iframeLoading.value = true;
|
|
131
|
-
};
|
|
132
|
-
return {
|
|
133
|
-
sessions,
|
|
134
|
-
loadingSessionList,
|
|
135
|
-
currentSessionId,
|
|
136
|
-
iframeSrc,
|
|
137
|
-
iframeLoading,
|
|
138
|
-
loadSessions,
|
|
139
|
-
createSession,
|
|
140
|
-
deleteSession,
|
|
141
|
-
selectSession,
|
|
142
|
-
updateSessionInfo
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
export {
|
|
146
|
-
useSessions
|
|
147
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { OpenCodeWidgetTheme } from "@vite-plugin-opencode-assistant/shared";
|
|
2
|
-
interface WidgetRef {
|
|
3
|
-
sendMessageToIframe: (type: string, data?: Record<string, unknown>) => void;
|
|
4
|
-
}
|
|
5
|
-
export declare function useTheme(initialTheme: OpenCodeWidgetTheme, widgetRef: {
|
|
6
|
-
value: WidgetRef | null;
|
|
7
|
-
}): {
|
|
8
|
-
theme: import("vue").Ref<OpenCodeWidgetTheme, OpenCodeWidgetTheme>;
|
|
9
|
-
resolvedTheme: import("vue").ComputedRef<"light" | "dark">;
|
|
10
|
-
sendThemeToIframe: () => void;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ref, computed, watch, onMounted, onUnmounted } from "vue";
|
|
2
|
-
function useTheme(initialTheme, widgetRef) {
|
|
3
|
-
const theme = ref(initialTheme);
|
|
4
|
-
const resolvedTheme = computed(() => {
|
|
5
|
-
if (theme.value === "auto") {
|
|
6
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
7
|
-
}
|
|
8
|
-
return theme.value;
|
|
9
|
-
});
|
|
10
|
-
const sendThemeToIframe = () => {
|
|
11
|
-
var _a;
|
|
12
|
-
(_a = widgetRef.value) == null ? void 0 : _a.sendMessageToIframe("OPENCODE_SET_THEME", {
|
|
13
|
-
theme: resolvedTheme.value
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
let mediaQuery = null;
|
|
17
|
-
const handleSystemThemeChange = () => {
|
|
18
|
-
if (theme.value === "auto") {
|
|
19
|
-
sendThemeToIframe();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
onMounted(() => {
|
|
23
|
-
mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
24
|
-
mediaQuery.addEventListener("change", handleSystemThemeChange);
|
|
25
|
-
watch(resolvedTheme, () => {
|
|
26
|
-
sendThemeToIframe();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
onUnmounted(() => {
|
|
30
|
-
if (mediaQuery) {
|
|
31
|
-
mediaQuery.removeEventListener("change", handleSystemThemeChange);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return {
|
|
35
|
-
theme,
|
|
36
|
-
resolvedTheme,
|
|
37
|
-
sendThemeToIframe
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export {
|
|
41
|
-
useTheme
|
|
42
|
-
};
|
package/es/client/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./styles.css";
|
package/es/client/index.mjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createApp } from "vue";
|
|
2
|
-
import { CONFIG_DATA_ATTR } from "@vite-plugin-opencode-assistant/shared";
|
|
3
|
-
import App from "./App.vue.mjs";
|
|
4
|
-
import "./styles.css";
|
|
5
|
-
let config = {};
|
|
6
|
-
const scriptTag = document.querySelector(`script[${CONFIG_DATA_ATTR}]`);
|
|
7
|
-
if (scriptTag) {
|
|
8
|
-
const configBase64 = scriptTag.getAttribute(CONFIG_DATA_ATTR);
|
|
9
|
-
if (configBase64) {
|
|
10
|
-
try {
|
|
11
|
-
const decoded = new TextDecoder().decode(
|
|
12
|
-
Uint8Array.from(atob(configBase64), (c) => c.charCodeAt(0))
|
|
13
|
-
);
|
|
14
|
-
config = JSON.parse(decoded);
|
|
15
|
-
} catch (e) {
|
|
16
|
-
console.error("[OpenCode] Failed to parse config:", e);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const INIT_MARKER = "__OPENCODE_INITIALIZED__";
|
|
21
|
-
if (!window[INIT_MARKER]) {
|
|
22
|
-
window[INIT_MARKER] = true;
|
|
23
|
-
const container = document.createElement("div");
|
|
24
|
-
document.body.appendChild(container);
|
|
25
|
-
const app = createApp(App, { config });
|
|
26
|
-
app.mount(container);
|
|
27
|
-
window.__OPENCODE_CLEANUP__ = () => {
|
|
28
|
-
app.unmount();
|
|
29
|
-
container.remove();
|
|
30
|
-
window[INIT_MARKER] = false;
|
|
31
|
-
};
|
|
32
|
-
}
|
package/es/client/styles.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.opencode-custom-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:20px}.opencode-loading-spinner{width:32px;height:32px;border:3px solid var(--oc-border-primary);border-top-color:var(--oc-primary);border-radius:50%;animation:opencode-spin .8s linear infinite}@keyframes opencode-spin{to{transform:rotate(360deg)}}.opencode-loading-text{margin-top:12px;color:var(--oc-text-secondary);font-size:14px}.opencode-chrome-warmup-failed{position:absolute;inset:0;background:var(--oc-bg-secondary);display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:15}.opencode-chrome-warmup-failed-icon{color:var(--oc-warning, #f59e0b);margin-bottom:16px}.opencode-chrome-warmup-failed-title{color:var(--oc-text-primary);font-size:18px;font-weight:600;margin-bottom:8px}.opencode-chrome-warmup-failed-text{color:var(--oc-text-secondary);font-size:14px;text-align:left;max-width:400px;line-height:1.6;text-align:center}.opencode-chrome-warmup-failed-text p{margin:0 0 12px;font-weight:500;color:var(--oc-text-primary)}.opencode-chrome-warmup-steps{margin:0}.opencode-chrome-warmup-steps div{margin-bottom:8px;color:var(--oc-text-secondary);font-size:13px;line-height:1.5}.opencode-chrome-warmup-steps div:last-child{margin-bottom:0}.opencode-chrome-warmup-code{display:inline-block;background:var(--oc-bg-tertiary);color:var(--oc-primary);padding:2px 6px;border-radius:4px;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:12px;font-weight:500;word-break:break-all;margin:0 2px}.opencode-chrome-warmup-failed-actions{display:flex;gap:12px}.opencode-chrome-warmup-failed-btn{padding:10px 24px;border-radius:8px;border:none;font-size:14px;font-weight:500;cursor:pointer;transition:all .2s}.opencode-chrome-warmup-failed-btn.primary{background:var(--oc-primary);color:#fff;box-shadow:var(--oc-shadow-primary)}.opencode-chrome-warmup-failed-btn.primary:hover:not(:disabled){background:var(--oc-primary-hover);transform:translateY(-1px);box-shadow:var(--oc-shadow-primary-hover)}.opencode-chrome-warmup-failed-btn.primary:active:not(:disabled){transform:translateY(0)}.opencode-chrome-warmup-failed-btn.primary:disabled{opacity:.6;cursor:not-allowed}
|