vite-plugin-opencode-assistant 1.0.15 → 1.0.17

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.
Files changed (79) hide show
  1. package/es/client/App.vue.d.ts +6 -0
  2. package/es/client/App.vue.js +317 -0
  3. package/es/client/components/ChromeWarmupError-sfc.css +1 -0
  4. package/es/client/components/ChromeWarmupError.vue.d.ts +11 -0
  5. package/es/client/components/ChromeWarmupError.vue.js +196 -0
  6. package/es/client/components/LoadingContent.vue.d.ts +5 -0
  7. package/es/client/components/LoadingContent.vue.js +39 -0
  8. package/es/client/composables/useContext.d.ts +8 -0
  9. package/es/client/composables/useContext.js +63 -0
  10. package/es/client/composables/useHotkey.d.ts +12 -0
  11. package/es/client/composables/useHotkey.js +41 -0
  12. package/es/client/composables/useSSE.d.ts +20 -0
  13. package/es/client/composables/useSSE.js +61 -0
  14. package/es/client/composables/useSelectedElements.d.ts +19 -0
  15. package/es/client/composables/useSelectedElements.js +43 -0
  16. package/es/client/composables/useServiceStatus.d.ts +13 -0
  17. package/es/client/composables/useServiceStatus.js +53 -0
  18. package/es/client/composables/useSessions.d.ts +26 -0
  19. package/es/client/composables/useSessions.js +127 -0
  20. package/es/client/composables/useTheme.d.ts +12 -0
  21. package/es/client/composables/useTheme.js +42 -0
  22. package/es/client/index.d.ts +1 -1
  23. package/es/client/index.js +5 -675
  24. package/es/client/styles.css +1 -0
  25. package/es/core/api.d.ts +18 -6
  26. package/es/core/api.js +345 -89
  27. package/es/core/proxy-server.js +266 -2
  28. package/es/core/service.d.ts +9 -2
  29. package/es/core/service.js +35 -31
  30. package/es/endpoints/index.js +1 -1
  31. package/es/endpoints/sse.js +0 -3
  32. package/es/endpoints/start.d.ts +1 -2
  33. package/es/endpoints/start.js +2 -2
  34. package/es/endpoints/types.d.ts +5 -2
  35. package/es/endpoints/warmup.js +15 -3
  36. package/es/index.js +8 -12
  37. package/es/utils/system.d.ts +1 -0
  38. package/es/utils/system.js +28 -0
  39. package/lib/client/App.vue.d.ts +6 -0
  40. package/lib/client/App.vue.js +344 -0
  41. package/lib/client/components/ChromeWarmupError-sfc.css +1 -0
  42. package/lib/client/components/ChromeWarmupError.vue.d.ts +11 -0
  43. package/lib/client/components/ChromeWarmupError.vue.js +215 -0
  44. package/lib/client/components/LoadingContent.vue.d.ts +5 -0
  45. package/lib/client/components/LoadingContent.vue.js +58 -0
  46. package/lib/client/composables/useContext.d.ts +8 -0
  47. package/lib/client/composables/useContext.js +86 -0
  48. package/lib/client/composables/useHotkey.d.ts +12 -0
  49. package/lib/client/composables/useHotkey.js +66 -0
  50. package/lib/client/composables/useSSE.d.ts +20 -0
  51. package/lib/client/composables/useSSE.js +84 -0
  52. package/lib/client/composables/useSelectedElements.d.ts +19 -0
  53. package/lib/client/composables/useSelectedElements.js +66 -0
  54. package/lib/client/composables/useServiceStatus.d.ts +13 -0
  55. package/lib/client/composables/useServiceStatus.js +76 -0
  56. package/lib/client/composables/useSessions.d.ts +26 -0
  57. package/lib/client/composables/useSessions.js +148 -0
  58. package/lib/client/composables/useTheme.d.ts +12 -0
  59. package/lib/client/composables/useTheme.js +65 -0
  60. package/lib/client/index.d.ts +1 -1
  61. package/lib/client/index.js +22 -667
  62. package/lib/client/styles.css +1 -0
  63. package/lib/client.js +3280 -3109
  64. package/lib/core/api.d.ts +18 -6
  65. package/lib/core/api.js +342 -94
  66. package/lib/core/proxy-server.js +266 -2
  67. package/lib/core/service.d.ts +9 -2
  68. package/lib/core/service.js +31 -30
  69. package/lib/endpoints/index.js +1 -1
  70. package/lib/endpoints/sse.js +0 -3
  71. package/lib/endpoints/start.d.ts +1 -2
  72. package/lib/endpoints/start.js +2 -2
  73. package/lib/endpoints/types.d.ts +5 -2
  74. package/lib/endpoints/warmup.js +15 -3
  75. package/lib/index.js +8 -12
  76. package/lib/style.css +1 -1
  77. package/lib/utils/system.d.ts +1 -0
  78. package/lib/utils/system.js +29 -0
  79. package/package.json +4 -4
@@ -0,0 +1,86 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var useContext_exports = {};
19
+ __export(useContext_exports, {
20
+ useContext: () => useContext
21
+ });
22
+ module.exports = __toCommonJS(useContext_exports);
23
+ var import_vue = require("vue");
24
+ function useContext(serviceStatus, selectedElements) {
25
+ let currentPageUrl = "";
26
+ let currentPageTitle = "";
27
+ const updateContext = (force = false) => {
28
+ if (serviceStatus.value === "idle") return;
29
+ const newUrl = window.location.href;
30
+ const newTitle = document.title;
31
+ if (force || newUrl !== currentPageUrl || newTitle !== currentPageTitle) {
32
+ currentPageUrl = newUrl;
33
+ currentPageTitle = newTitle;
34
+ fetch("/__opencode_context__", {
35
+ method: "POST",
36
+ headers: { "Content-Type": "application/json" },
37
+ body: JSON.stringify({
38
+ url: newUrl,
39
+ title: newTitle,
40
+ selectedElements: selectedElements.value
41
+ })
42
+ }).catch(() => {
43
+ });
44
+ }
45
+ };
46
+ const scheduleContextUpdate = () => {
47
+ requestAnimationFrame(() => updateContext());
48
+ };
49
+ let titleObserver = null;
50
+ const originalPushState = history.pushState;
51
+ const originalReplaceState = history.replaceState;
52
+ (0, import_vue.onMounted)(() => {
53
+ history.pushState = function(...args) {
54
+ originalPushState.apply(this, args);
55
+ scheduleContextUpdate();
56
+ };
57
+ history.replaceState = function(...args) {
58
+ originalReplaceState.apply(this, args);
59
+ scheduleContextUpdate();
60
+ };
61
+ window.addEventListener("popstate", scheduleContextUpdate);
62
+ window.addEventListener("hashchange", scheduleContextUpdate);
63
+ titleObserver = new MutationObserver(() => {
64
+ if (document.title !== currentPageTitle) updateContext();
65
+ });
66
+ if (document.head) {
67
+ titleObserver.observe(document.head, { childList: true, subtree: true });
68
+ }
69
+ });
70
+ (0, import_vue.onUnmounted)(() => {
71
+ history.pushState = originalPushState;
72
+ history.replaceState = originalReplaceState;
73
+ window.removeEventListener("popstate", scheduleContextUpdate);
74
+ window.removeEventListener("hashchange", scheduleContextUpdate);
75
+ if (titleObserver) {
76
+ titleObserver.disconnect();
77
+ }
78
+ });
79
+ return {
80
+ updateContext
81
+ };
82
+ }
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ useContext
86
+ });
@@ -0,0 +1,12 @@
1
+ interface HotkeyConfig {
2
+ ctrl: boolean;
3
+ shift: boolean;
4
+ alt: boolean;
5
+ key: string;
6
+ }
7
+ export declare function parseHotkey(hotkeyStr: string): HotkeyConfig;
8
+ export declare function matchHotkey(e: KeyboardEvent, hotkeyConfig: HotkeyConfig): boolean;
9
+ export declare function useHotkey(hotkeyStr: string, callback: (event: KeyboardEvent) => void): {
10
+ hotkeyConfig: HotkeyConfig;
11
+ };
12
+ export {};
@@ -0,0 +1,66 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var useHotkey_exports = {};
19
+ __export(useHotkey_exports, {
20
+ matchHotkey: () => matchHotkey,
21
+ parseHotkey: () => parseHotkey,
22
+ useHotkey: () => useHotkey
23
+ });
24
+ module.exports = __toCommonJS(useHotkey_exports);
25
+ var import_vue = require("vue");
26
+ function parseHotkey(hotkeyStr) {
27
+ if (!hotkeyStr) return { ctrl: true, shift: false, alt: false, key: "k" };
28
+ const parts = hotkeyStr.toLowerCase().split("+");
29
+ const key = parts.pop();
30
+ return {
31
+ ctrl: parts.includes("ctrl") || parts.includes("cmd") || parts.includes("meta"),
32
+ shift: parts.includes("shift"),
33
+ alt: parts.includes("alt"),
34
+ key: key || "k"
35
+ };
36
+ }
37
+ function matchHotkey(e, hotkeyConfig) {
38
+ const ctrlMatch = hotkeyConfig.ctrl ? e.ctrlKey || e.metaKey : !(e.ctrlKey || e.metaKey);
39
+ const shiftMatch = hotkeyConfig.shift ? e.shiftKey : !e.shiftKey;
40
+ const altMatch = hotkeyConfig.alt ? e.altKey : !e.altKey;
41
+ const keyMatch = e.key.toLowerCase() === hotkeyConfig.key.toLowerCase();
42
+ return ctrlMatch && shiftMatch && altMatch && keyMatch;
43
+ }
44
+ function useHotkey(hotkeyStr, callback) {
45
+ const hotkeyConfig = parseHotkey(hotkeyStr);
46
+ const handleKeydown = (e) => {
47
+ if (matchHotkey(e, hotkeyConfig)) {
48
+ callback(e);
49
+ }
50
+ };
51
+ (0, import_vue.onMounted)(() => {
52
+ document.addEventListener("keydown", handleKeydown);
53
+ });
54
+ (0, import_vue.onUnmounted)(() => {
55
+ document.removeEventListener("keydown", handleKeydown);
56
+ });
57
+ return {
58
+ hotkeyConfig
59
+ };
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ matchHotkey,
64
+ parseHotkey,
65
+ useHotkey
66
+ });
@@ -0,0 +1,20 @@
1
+ import { ServiceStartupTask } from "@vite-plugin-opencode-assistant/shared";
2
+ interface SSEStatusSyncData {
3
+ type: "STATUS_SYNC";
4
+ isStarted?: boolean;
5
+ task: ServiceStartupTask;
6
+ errorType?: string;
7
+ errorMessage?: string;
8
+ }
9
+ interface SSETaskUpdateData {
10
+ type: "TASK_UPDATE";
11
+ task: ServiceStartupTask;
12
+ errorType?: string;
13
+ errorMessage?: string;
14
+ }
15
+ export declare function useSSE(onStatusSync: (data: SSEStatusSyncData) => void, onTaskUpdate: (data: SSETaskUpdateData) => void, onClearElements: () => void, onConnected: () => void): {
16
+ setupSSE: () => void;
17
+ closeSSE: () => void;
18
+ sseRetryCount: import("vue").Ref<number, number>;
19
+ };
20
+ export {};
@@ -0,0 +1,84 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var useSSE_exports = {};
19
+ __export(useSSE_exports, {
20
+ useSSE: () => useSSE
21
+ });
22
+ module.exports = __toCommonJS(useSSE_exports);
23
+ var import_vue = require("vue");
24
+ const MAX_SSE_RETRIES = 10;
25
+ const SSE_RETRY_DELAY = 1e3;
26
+ function useSSE(onStatusSync, onTaskUpdate, onClearElements, onConnected) {
27
+ const sseConnection = (0, import_vue.ref)(null);
28
+ const sseRetryCount = (0, import_vue.ref)(0);
29
+ const setupSSE = () => {
30
+ if (sseConnection.value) return;
31
+ try {
32
+ sseConnection.value = new EventSource("/__opencode_events__");
33
+ sseConnection.value.onmessage = (event) => {
34
+ try {
35
+ const data = JSON.parse(event.data);
36
+ if (data.type === "CONNECTED") {
37
+ onConnected();
38
+ sseRetryCount.value = 0;
39
+ } else if (data.type === "STATUS_SYNC") {
40
+ onStatusSync(data);
41
+ } else if (data.type === "TASK_UPDATE") {
42
+ onTaskUpdate(data);
43
+ } else if (data.type === "CLEAR_ELEMENTS") {
44
+ onClearElements();
45
+ }
46
+ } catch (e) {
47
+ }
48
+ };
49
+ sseConnection.value.onerror = () => {
50
+ var _a;
51
+ (_a = sseConnection.value) == null ? void 0 : _a.close();
52
+ sseConnection.value = null;
53
+ if (sseRetryCount.value < MAX_SSE_RETRIES) {
54
+ sseRetryCount.value++;
55
+ setTimeout(setupSSE, SSE_RETRY_DELAY * sseRetryCount.value);
56
+ }
57
+ };
58
+ } catch (e) {
59
+ sseConnection.value = null;
60
+ if (sseRetryCount.value < MAX_SSE_RETRIES) {
61
+ sseRetryCount.value++;
62
+ setTimeout(setupSSE, SSE_RETRY_DELAY * sseRetryCount.value);
63
+ }
64
+ }
65
+ };
66
+ const closeSSE = () => {
67
+ if (sseConnection.value) {
68
+ sseConnection.value.close();
69
+ sseConnection.value = null;
70
+ }
71
+ };
72
+ (0, import_vue.onUnmounted)(() => {
73
+ closeSSE();
74
+ });
75
+ return {
76
+ setupSSE,
77
+ closeSSE,
78
+ sseRetryCount
79
+ };
80
+ }
81
+ // Annotate the CommonJS export names for ESM import in node:
82
+ 0 && (module.exports = {
83
+ useSSE
84
+ });
@@ -0,0 +1,19 @@
1
+ import type { OpenCodeSelectedElement } from "@vite-plugin-opencode-assistant/shared";
2
+ export declare function useSelectedElements(): {
3
+ selectedElements: import("vue").Ref<{
4
+ filePath: string | null;
5
+ line: number | null;
6
+ column: number | null;
7
+ innerText: string;
8
+ description?: string | undefined;
9
+ }[], OpenCodeSelectedElement[] | {
10
+ filePath: string | null;
11
+ line: number | null;
12
+ column: number | null;
13
+ innerText: string;
14
+ description?: string | undefined;
15
+ }[]>;
16
+ addElement: (element: OpenCodeSelectedElement) => boolean;
17
+ removeElement: (index: number) => void;
18
+ clearElements: () => void;
19
+ };
@@ -0,0 +1,66 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var useSelectedElements_exports = {};
19
+ __export(useSelectedElements_exports, {
20
+ useSelectedElements: () => useSelectedElements
21
+ });
22
+ module.exports = __toCommonJS(useSelectedElements_exports);
23
+ var import_vue = require("vue");
24
+ function useSelectedElements() {
25
+ const selectedElements = (0, import_vue.ref)([]);
26
+ try {
27
+ const stored = sessionStorage.getItem("__opencode_selected_elements__");
28
+ if (stored) {
29
+ selectedElements.value = JSON.parse(stored);
30
+ }
31
+ } catch (e) {
32
+ }
33
+ (0, import_vue.watch)(
34
+ selectedElements,
35
+ (val) => {
36
+ sessionStorage.setItem("__opencode_selected_elements__", JSON.stringify(val));
37
+ },
38
+ { deep: true }
39
+ );
40
+ const addElement = (element) => {
41
+ const exists = selectedElements.value.some(
42
+ (el) => el.filePath === element.filePath && el.line === element.line
43
+ );
44
+ if (!exists) {
45
+ selectedElements.value.push(element);
46
+ return true;
47
+ }
48
+ return false;
49
+ };
50
+ const removeElement = (index) => {
51
+ selectedElements.value.splice(index, 1);
52
+ };
53
+ const clearElements = () => {
54
+ selectedElements.value = [];
55
+ };
56
+ return {
57
+ selectedElements,
58
+ addElement,
59
+ removeElement,
60
+ clearElements
61
+ };
62
+ }
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ useSelectedElements
66
+ });
@@ -0,0 +1,13 @@
1
+ import type { ServiceStartupTask, ServiceStatus } from "@vite-plugin-opencode-assistant/shared";
2
+ export declare function useServiceStatus(): {
3
+ currentTask: import("vue").Ref<"" | ServiceStartupTask, "" | ServiceStartupTask>;
4
+ serviceStatus: import("vue").Ref<ServiceStatus, ServiceStatus>;
5
+ chromeMcpFailed: import("vue").Ref<boolean, boolean>;
6
+ chromeMcpErrorType: import("vue").Ref<string | undefined, string | undefined>;
7
+ chromeMcpErrorMessage: import("vue").Ref<string | undefined, string | undefined>;
8
+ thinking: import("vue").Ref<boolean, boolean>;
9
+ loadingText: import("vue").ComputedRef<string>;
10
+ updateStatusFromTask: (task: ServiceStartupTask | "", errorType?: string, errorMessage?: string) => void;
11
+ setStarting: () => void;
12
+ setThinking: (value: boolean) => void;
13
+ };
@@ -0,0 +1,76 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var useServiceStatus_exports = {};
19
+ __export(useServiceStatus_exports, {
20
+ useServiceStatus: () => useServiceStatus
21
+ });
22
+ module.exports = __toCommonJS(useServiceStatus_exports);
23
+ var import_vue = require("vue");
24
+ var import_shared = require("@vite-plugin-opencode-assistant/shared");
25
+ function useServiceStatus() {
26
+ const currentTask = (0, import_vue.ref)("");
27
+ const serviceStatus = (0, import_vue.ref)("idle");
28
+ const chromeMcpFailed = (0, import_vue.ref)(false);
29
+ const chromeMcpErrorType = (0, import_vue.ref)(void 0);
30
+ const chromeMcpErrorMessage = (0, import_vue.ref)(void 0);
31
+ const thinking = (0, import_vue.ref)(false);
32
+ const loadingText = (0, import_vue.computed)(() => {
33
+ if (!currentTask.value) return "\u52A0\u8F7D\u4E2D...";
34
+ return import_shared.SERVICE_STARTUP_TASKS[currentTask.value] || "\u52A0\u8F7D\u4E2D...";
35
+ });
36
+ const updateStatusFromTask = (task, errorType, errorMessage) => {
37
+ currentTask.value = task;
38
+ if (task === "ready") {
39
+ serviceStatus.value = "ready";
40
+ chromeMcpFailed.value = false;
41
+ chromeMcpErrorType.value = void 0;
42
+ chromeMcpErrorMessage.value = void 0;
43
+ } else if (task === "chrome_mcp_failed") {
44
+ serviceStatus.value = "partial";
45
+ chromeMcpFailed.value = true;
46
+ chromeMcpErrorType.value = errorType;
47
+ chromeMcpErrorMessage.value = errorMessage;
48
+ } else if (task === "session_creation_failed" || task === "opencode_not_installed" || task === "web_start_timeout") {
49
+ serviceStatus.value = "failed";
50
+ } else if (serviceStatus.value === "idle" && task) {
51
+ serviceStatus.value = "starting";
52
+ }
53
+ };
54
+ const setStarting = () => {
55
+ serviceStatus.value = "starting";
56
+ };
57
+ const setThinking = (value) => {
58
+ thinking.value = value;
59
+ };
60
+ return {
61
+ currentTask,
62
+ serviceStatus,
63
+ chromeMcpFailed,
64
+ chromeMcpErrorType,
65
+ chromeMcpErrorMessage,
66
+ thinking,
67
+ loadingText,
68
+ updateStatusFromTask,
69
+ setStarting,
70
+ setThinking
71
+ };
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ useServiceStatus
76
+ });
@@ -0,0 +1,26 @@
1
+ import type { OpenCodeWidgetSession } from "@vite-plugin-opencode-assistant/shared";
2
+ export declare function useSessions(showNotification: (msg: string) => void): {
3
+ sessions: import("vue").Ref<{
4
+ id: string;
5
+ title?: string | undefined;
6
+ updatedAt?: (string | number | Date) | undefined;
7
+ meta?: string | undefined;
8
+ directory?: string | undefined;
9
+ url?: string | undefined;
10
+ }[], OpenCodeWidgetSession[] | {
11
+ id: string;
12
+ title?: string | undefined;
13
+ updatedAt?: (string | number | Date) | undefined;
14
+ meta?: string | undefined;
15
+ directory?: string | undefined;
16
+ url?: string | undefined;
17
+ }[]>;
18
+ loadingSessionList: import("vue").Ref<boolean | undefined, boolean | undefined>;
19
+ currentSessionId: import("vue").Ref<string | null, string | null>;
20
+ iframeSrc: import("vue").ComputedRef<string>;
21
+ iframeLoading: import("vue").Ref<boolean, boolean>;
22
+ loadSessions: () => Promise<void>;
23
+ createSession: () => Promise<void>;
24
+ deleteSession: (session: OpenCodeWidgetSession) => Promise<void>;
25
+ selectSession: (session: OpenCodeWidgetSession) => void;
26
+ };
@@ -0,0 +1,148 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+ var __async = (__this, __arguments, generator) => {
36
+ return new Promise((resolve, reject) => {
37
+ var fulfilled = (value) => {
38
+ try {
39
+ step(generator.next(value));
40
+ } catch (e) {
41
+ reject(e);
42
+ }
43
+ };
44
+ var rejected = (value) => {
45
+ try {
46
+ step(generator.throw(value));
47
+ } catch (e) {
48
+ reject(e);
49
+ }
50
+ };
51
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
52
+ step((generator = generator.apply(__this, __arguments)).next());
53
+ });
54
+ };
55
+ var useSessions_exports = {};
56
+ __export(useSessions_exports, {
57
+ useSessions: () => useSessions
58
+ });
59
+ module.exports = __toCommonJS(useSessions_exports);
60
+ var import_vue = require("vue");
61
+ var import_shared = require("@vite-plugin-opencode-assistant/shared");
62
+ function useSessions(showNotification) {
63
+ const sessions = (0, import_vue.ref)([]);
64
+ const loadingSessionList = (0, import_vue.ref)(void 0);
65
+ const currentSessionId = (0, import_vue.ref)(null);
66
+ const iframeLoading = (0, import_vue.ref)(false);
67
+ const iframeSrc = (0, import_vue.computed)(() => {
68
+ var _a;
69
+ return currentSessionId.value ? ((_a = sessions.value.find((s) => s.id === currentSessionId.value)) == null ? void 0 : _a.url) || "" : "";
70
+ });
71
+ const loadSessions = () => __async(null, null, function* () {
72
+ var _a;
73
+ loadingSessionList.value = true;
74
+ try {
75
+ const response = yield fetch(import_shared.SESSIONS_API_PATH);
76
+ const data = yield response.json();
77
+ sessions.value = data.filter((s) => s.title !== "__chrome_mcp_warmup__").map((s) => {
78
+ var _a2;
79
+ return __spreadProps(__spreadValues({}, s), {
80
+ updatedAt: ((_a2 = s.time) == null ? void 0 : _a2.updated) || Date.now()
81
+ });
82
+ });
83
+ if (!sessions.value.length) {
84
+ createSession();
85
+ }
86
+ currentSessionId.value = ((_a = sessions.value[0]) == null ? void 0 : _a.id) || null;
87
+ } catch (e) {
88
+ console.error("[OpenCode] Failed to load sessions:", e);
89
+ } finally {
90
+ loadingSessionList.value = false;
91
+ }
92
+ });
93
+ const createSession = () => __async(null, null, function* () {
94
+ try {
95
+ const response = yield fetch(import_shared.SESSIONS_API_PATH, { method: "POST" });
96
+ const newSession = yield response.json();
97
+ sessions.value.unshift({
98
+ id: newSession.id,
99
+ title: "\u65B0\u4F1A\u8BDD",
100
+ updatedAt: Date.now(),
101
+ url: newSession.url
102
+ });
103
+ currentSessionId.value = newSession.id;
104
+ iframeLoading.value = true;
105
+ loadSessions();
106
+ } catch (e) {
107
+ showNotification("\u521B\u5EFA\u4F1A\u8BDD\u5931\u8D25");
108
+ }
109
+ });
110
+ const deleteSession = (session) => __async(null, null, function* () {
111
+ try {
112
+ yield fetch(`${import_shared.SESSIONS_API_PATH}?id=${session.id}`, { method: "DELETE" });
113
+ yield loadSessions();
114
+ showNotification("\u4F1A\u8BDD\u5DF2\u5220\u9664");
115
+ if (currentSessionId.value === session.id) {
116
+ if (sessions.value.length > 0) {
117
+ const nextSession = sessions.value[0];
118
+ currentSessionId.value = nextSession.id;
119
+ iframeLoading.value = true;
120
+ } else {
121
+ currentSessionId.value = null;
122
+ }
123
+ }
124
+ } catch (e) {
125
+ showNotification("\u5220\u9664\u4F1A\u8BDD\u5931\u8D25");
126
+ }
127
+ });
128
+ const selectSession = (session) => {
129
+ if (currentSessionId.value === session.id) return;
130
+ currentSessionId.value = session.id;
131
+ iframeLoading.value = true;
132
+ };
133
+ return {
134
+ sessions,
135
+ loadingSessionList,
136
+ currentSessionId,
137
+ iframeSrc,
138
+ iframeLoading,
139
+ loadSessions,
140
+ createSession,
141
+ deleteSession,
142
+ selectSession
143
+ };
144
+ }
145
+ // Annotate the CommonJS export names for ESM import in node:
146
+ 0 && (module.exports = {
147
+ useSessions
148
+ });
@@ -0,0 +1,12 @@
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 {};