vite-plugin-opencode-assistant 1.0.74 → 1.0.75
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,19 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
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 useServerSSE_exports = {};
|
|
19
|
-
__export(useServerSSE_exports, {
|
|
20
|
-
useServerSSE: () => useServerSSE
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(useServerSSE_exports);
|
|
23
|
-
var import_useSSE = require("./useSSE.cjs");
|
|
24
|
-
function useServerSSE(options = {}) {
|
|
25
|
-
const { onStatusSync, onTaskUpdate, onClearElements, onConnected } = options;
|
|
26
|
-
const { status, isConnected, connect, disconnect } = (0, import_useSSE.useSSE)({
|
|
27
|
-
endpoint: "/__opencode_events__",
|
|
28
|
-
autoConnect: false,
|
|
29
|
-
onMessage: (data) => {
|
|
30
|
-
const message = data;
|
|
31
|
-
switch (message.type) {
|
|
32
|
-
case "CONNECTED":
|
|
33
|
-
onConnected == null ? void 0 : onConnected();
|
|
34
|
-
break;
|
|
35
|
-
case "STATUS_SYNC":
|
|
36
|
-
onStatusSync == null ? void 0 : onStatusSync(message);
|
|
37
|
-
break;
|
|
38
|
-
case "TASK_UPDATE":
|
|
39
|
-
onTaskUpdate == null ? void 0 : onTaskUpdate(message);
|
|
40
|
-
break;
|
|
41
|
-
case "CLEAR_ELEMENTS":
|
|
42
|
-
onClearElements == null ? void 0 : onClearElements();
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
// 状态
|
|
49
|
-
status,
|
|
50
|
-
isConnected,
|
|
51
|
-
// 方法
|
|
52
|
-
connect,
|
|
53
|
-
disconnect
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
-
0 && (module.exports = {
|
|
58
|
-
useServerSSE
|
|
59
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { ServiceStartupTask } from "@vite-plugin-opencode-assistant/shared";
|
|
2
|
-
/**
|
|
3
|
-
* Server SSE 状态同步数据
|
|
4
|
-
*/
|
|
5
|
-
export interface ServerSSEStatusSyncData {
|
|
6
|
-
type: "STATUS_SYNC";
|
|
7
|
-
isStarted?: boolean;
|
|
8
|
-
task: ServiceStartupTask;
|
|
9
|
-
errorType?: string;
|
|
10
|
-
errorMessage?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Server SSE 任务更新数据
|
|
14
|
-
*/
|
|
15
|
-
export interface ServerSSETaskUpdateData {
|
|
16
|
-
type: "TASK_UPDATE";
|
|
17
|
-
task: ServiceStartupTask;
|
|
18
|
-
errorType?: string;
|
|
19
|
-
errorMessage?: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Server SSE 消息类型
|
|
23
|
-
*/
|
|
24
|
-
export type ServerSSEMessage = {
|
|
25
|
-
type: "CONNECTED";
|
|
26
|
-
} | ServerSSEStatusSyncData | ServerSSETaskUpdateData | {
|
|
27
|
-
type: "CLEAR_ELEMENTS";
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Server SSE 配置选项
|
|
31
|
-
*/
|
|
32
|
-
export interface ServerSSEOptions {
|
|
33
|
-
/** 状态同步回调 */
|
|
34
|
-
onStatusSync?: (data: ServerSSEStatusSyncData) => void;
|
|
35
|
-
/** 任务更新回调 */
|
|
36
|
-
onTaskUpdate?: (data: ServerSSETaskUpdateData) => void;
|
|
37
|
-
/** 清除元素回调 */
|
|
38
|
-
onClearElements?: () => void;
|
|
39
|
-
/** 连接成功回调 */
|
|
40
|
-
onConnected?: () => void;
|
|
41
|
-
/** 是否启用 */
|
|
42
|
-
enabled?: boolean;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* 监听 Vite Server SSE 事件
|
|
46
|
-
* 端点: /__opencode_events__
|
|
47
|
-
*/
|
|
48
|
-
export declare function useServerSSE(options?: ServerSSEOptions): {
|
|
49
|
-
status: import("vue").Ref<import("./useSSE").SSEConnectionStatus, import("./useSSE").SSEConnectionStatus>;
|
|
50
|
-
isConnected: import("vue").ComputedRef<boolean>;
|
|
51
|
-
connect: () => void;
|
|
52
|
-
disconnect: () => void;
|
|
53
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
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 loadingText = (0, import_vue.computed)(() => {
|
|
32
|
-
if (!currentTask.value) return "\u52A0\u8F7D\u4E2D...";
|
|
33
|
-
return import_shared.SERVICE_STARTUP_TASKS[currentTask.value] || "\u52A0\u8F7D\u4E2D...";
|
|
34
|
-
});
|
|
35
|
-
const updateStatusFromTask = (task, errorType, errorMessage) => {
|
|
36
|
-
currentTask.value = task;
|
|
37
|
-
if (task === "ready") {
|
|
38
|
-
serviceStatus.value = "ready";
|
|
39
|
-
chromeMcpFailed.value = false;
|
|
40
|
-
chromeMcpErrorType.value = void 0;
|
|
41
|
-
chromeMcpErrorMessage.value = void 0;
|
|
42
|
-
} else if (task === "chrome_mcp_failed") {
|
|
43
|
-
serviceStatus.value = "partial";
|
|
44
|
-
chromeMcpFailed.value = true;
|
|
45
|
-
chromeMcpErrorType.value = errorType;
|
|
46
|
-
chromeMcpErrorMessage.value = errorMessage;
|
|
47
|
-
} else if (task === "session_creation_failed" || task === "opencode_not_installed" || task === "web_start_timeout") {
|
|
48
|
-
serviceStatus.value = "failed";
|
|
49
|
-
} else if (serviceStatus.value === "idle" && task) {
|
|
50
|
-
serviceStatus.value = "starting";
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const setStarting = () => {
|
|
54
|
-
serviceStatus.value = "starting";
|
|
55
|
-
};
|
|
56
|
-
return {
|
|
57
|
-
currentTask,
|
|
58
|
-
serviceStatus,
|
|
59
|
-
chromeMcpFailed,
|
|
60
|
-
chromeMcpErrorType,
|
|
61
|
-
chromeMcpErrorMessage,
|
|
62
|
-
loadingText,
|
|
63
|
-
updateStatusFromTask,
|
|
64
|
-
setStarting
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
-
0 && (module.exports = {
|
|
69
|
-
useServiceStatus
|
|
70
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
loadingText: import("vue").ComputedRef<string>;
|
|
9
|
-
updateStatusFromTask: (task: ServiceStartupTask | "", errorType?: string, errorMessage?: string) => void;
|
|
10
|
-
setStarting: () => void;
|
|
11
|
-
};
|
|
@@ -1,168 +0,0 @@
|
|
|
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(options) {
|
|
63
|
-
const { showNotification } = options;
|
|
64
|
-
const sessions = (0, import_vue.ref)([]);
|
|
65
|
-
const loadingSessionList = (0, import_vue.ref)(void 0);
|
|
66
|
-
const currentSessionId = (0, import_vue.ref)(null);
|
|
67
|
-
const iframeLoading = (0, import_vue.ref)(false);
|
|
68
|
-
const iframeSrc = (0, import_vue.computed)(() => {
|
|
69
|
-
var _a;
|
|
70
|
-
return currentSessionId.value ? ((_a = sessions.value.find((s) => s.id === currentSessionId.value)) == null ? void 0 : _a.url) || "" : "";
|
|
71
|
-
});
|
|
72
|
-
const loadSessions = () => __async(null, null, function* () {
|
|
73
|
-
var _a;
|
|
74
|
-
loadingSessionList.value = true;
|
|
75
|
-
try {
|
|
76
|
-
const response = yield fetch(import_shared.SESSIONS_API_PATH);
|
|
77
|
-
const data = yield response.json();
|
|
78
|
-
sessions.value = data.filter((s) => {
|
|
79
|
-
var _a2;
|
|
80
|
-
if (s.title === "__chrome_mcp_warmup__") return false;
|
|
81
|
-
if (s.parentID) return false;
|
|
82
|
-
if ((_a2 = s.time) == null ? void 0 : _a2.archived) return false;
|
|
83
|
-
return true;
|
|
84
|
-
}).map((s) => {
|
|
85
|
-
var _a2;
|
|
86
|
-
return __spreadProps(__spreadValues({}, s), {
|
|
87
|
-
updatedAt: ((_a2 = s.time) == null ? void 0 : _a2.updated) || Date.now()
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
if (!sessions.value.length) {
|
|
91
|
-
createSession();
|
|
92
|
-
}
|
|
93
|
-
currentSessionId.value = ((_a = sessions.value[0]) == null ? void 0 : _a.id) || null;
|
|
94
|
-
} catch (e) {
|
|
95
|
-
console.error("[OpenCode] Failed to load sessions:", e);
|
|
96
|
-
} finally {
|
|
97
|
-
loadingSessionList.value = false;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
const updateSessionInfo = (sessionUpdate) => {
|
|
101
|
-
var _a;
|
|
102
|
-
const index = sessions.value.findIndex((s) => s.id === sessionUpdate.id);
|
|
103
|
-
if (index === -1) return;
|
|
104
|
-
const session = sessions.value[index];
|
|
105
|
-
if (sessionUpdate.title && sessionUpdate.title !== session.title) {
|
|
106
|
-
sessions.value[index] = __spreadProps(__spreadValues({}, session), {
|
|
107
|
-
title: sessionUpdate.title,
|
|
108
|
-
updatedAt: ((_a = sessionUpdate.time) == null ? void 0 : _a.updated) || Date.now()
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
const createSession = () => __async(null, null, function* () {
|
|
113
|
-
try {
|
|
114
|
-
const response = yield fetch(import_shared.SESSIONS_API_PATH, { method: "POST" });
|
|
115
|
-
const newSession = yield response.json();
|
|
116
|
-
sessions.value.unshift({
|
|
117
|
-
id: newSession.id,
|
|
118
|
-
title: "\u65B0\u4F1A\u8BDD",
|
|
119
|
-
updatedAt: Date.now(),
|
|
120
|
-
url: newSession.url
|
|
121
|
-
});
|
|
122
|
-
currentSessionId.value = newSession.id;
|
|
123
|
-
iframeLoading.value = true;
|
|
124
|
-
loadSessions();
|
|
125
|
-
} catch (e) {
|
|
126
|
-
showNotification("\u521B\u5EFA\u4F1A\u8BDD\u5931\u8D25");
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
const deleteSession = (session) => __async(null, null, function* () {
|
|
130
|
-
try {
|
|
131
|
-
yield fetch(`${import_shared.SESSIONS_API_PATH}?id=${session.id}`, { method: "DELETE" });
|
|
132
|
-
yield loadSessions();
|
|
133
|
-
showNotification("\u4F1A\u8BDD\u5DF2\u5220\u9664");
|
|
134
|
-
if (currentSessionId.value === session.id) {
|
|
135
|
-
if (sessions.value.length > 0) {
|
|
136
|
-
const nextSession = sessions.value[0];
|
|
137
|
-
currentSessionId.value = nextSession.id;
|
|
138
|
-
iframeLoading.value = true;
|
|
139
|
-
} else {
|
|
140
|
-
currentSessionId.value = null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
} catch (e) {
|
|
144
|
-
showNotification("\u5220\u9664\u4F1A\u8BDD\u5931\u8D25");
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
const selectSession = (session) => {
|
|
148
|
-
if (currentSessionId.value === session.id) return;
|
|
149
|
-
currentSessionId.value = session.id;
|
|
150
|
-
iframeLoading.value = true;
|
|
151
|
-
};
|
|
152
|
-
return {
|
|
153
|
-
sessions,
|
|
154
|
-
loadingSessionList,
|
|
155
|
-
currentSessionId,
|
|
156
|
-
iframeSrc,
|
|
157
|
-
iframeLoading,
|
|
158
|
-
loadSessions,
|
|
159
|
-
createSession,
|
|
160
|
-
deleteSession,
|
|
161
|
-
selectSession,
|
|
162
|
-
updateSessionInfo
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
166
|
-
0 && (module.exports = {
|
|
167
|
-
useSessions
|
|
168
|
-
});
|
|
@@ -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,65 +0,0 @@
|
|
|
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 useTheme_exports = {};
|
|
19
|
-
__export(useTheme_exports, {
|
|
20
|
-
useTheme: () => useTheme
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(useTheme_exports);
|
|
23
|
-
var import_vue = require("vue");
|
|
24
|
-
function useTheme(initialTheme, widgetRef) {
|
|
25
|
-
const theme = (0, import_vue.ref)(initialTheme);
|
|
26
|
-
const resolvedTheme = (0, import_vue.computed)(() => {
|
|
27
|
-
if (theme.value === "auto") {
|
|
28
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
29
|
-
}
|
|
30
|
-
return theme.value;
|
|
31
|
-
});
|
|
32
|
-
const sendThemeToIframe = () => {
|
|
33
|
-
var _a;
|
|
34
|
-
(_a = widgetRef.value) == null ? void 0 : _a.sendMessageToIframe("OPENCODE_SET_THEME", {
|
|
35
|
-
theme: resolvedTheme.value
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
let mediaQuery = null;
|
|
39
|
-
const handleSystemThemeChange = () => {
|
|
40
|
-
if (theme.value === "auto") {
|
|
41
|
-
sendThemeToIframe();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
(0, import_vue.onMounted)(() => {
|
|
45
|
-
mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
46
|
-
mediaQuery.addEventListener("change", handleSystemThemeChange);
|
|
47
|
-
(0, import_vue.watch)(resolvedTheme, () => {
|
|
48
|
-
sendThemeToIframe();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
(0, import_vue.onUnmounted)(() => {
|
|
52
|
-
if (mediaQuery) {
|
|
53
|
-
mediaQuery.removeEventListener("change", handleSystemThemeChange);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return {
|
|
57
|
-
theme,
|
|
58
|
-
resolvedTheme,
|
|
59
|
-
sendThemeToIframe
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
-
0 && (module.exports = {
|
|
64
|
-
useTheme
|
|
65
|
-
});
|
|
@@ -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 {};
|
package/lib/client/index.cjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
-
for (let key of __getOwnPropNames(from))
|
|
10
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
}
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
23
|
-
var import_vue = require("vue");
|
|
24
|
-
var import_shared = require("@vite-plugin-opencode-assistant/shared");
|
|
25
|
-
var import_App_vue = __toESM(require("./App.vue.cjs"));
|
|
26
|
-
var import_styles = require("./styles.css");
|
|
27
|
-
let config = {};
|
|
28
|
-
const scriptTag = document.querySelector(`script[${import_shared.CONFIG_DATA_ATTR}]`);
|
|
29
|
-
if (scriptTag) {
|
|
30
|
-
const configBase64 = scriptTag.getAttribute(import_shared.CONFIG_DATA_ATTR);
|
|
31
|
-
if (configBase64) {
|
|
32
|
-
try {
|
|
33
|
-
const decoded = new TextDecoder().decode(
|
|
34
|
-
Uint8Array.from(atob(configBase64), (c) => c.charCodeAt(0))
|
|
35
|
-
);
|
|
36
|
-
config = JSON.parse(decoded);
|
|
37
|
-
} catch (e) {
|
|
38
|
-
console.error("[OpenCode] Failed to parse config:", e);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const INIT_MARKER = "__OPENCODE_INITIALIZED__";
|
|
43
|
-
if (!window[INIT_MARKER]) {
|
|
44
|
-
window[INIT_MARKER] = true;
|
|
45
|
-
const container = document.createElement("div");
|
|
46
|
-
document.body.appendChild(container);
|
|
47
|
-
const app = (0, import_vue.createApp)(import_App_vue.default, { config });
|
|
48
|
-
app.mount(container);
|
|
49
|
-
window.__OPENCODE_CLEANUP__ = () => {
|
|
50
|
-
app.unmount();
|
|
51
|
-
container.remove();
|
|
52
|
-
window[INIT_MARKER] = false;
|
|
53
|
-
};
|
|
54
|
-
}
|
package/lib/client/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./styles.css";
|
package/lib/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}
|