@vite-plugin-opencode-assistant/components 1.0.5
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/env.d.ts +10 -0
- package/es/index.d.ts +6 -0
- package/es/index.js +21 -0
- package/es/open-code-widget/composables/use-inspector.d.ts +52 -0
- package/es/open-code-widget/composables/use-inspector.js +188 -0
- package/es/open-code-widget/composables/use-selection.d.ts +19 -0
- package/es/open-code-widget/composables/use-selection.js +142 -0
- package/es/open-code-widget/composables/use-session.d.ts +16 -0
- package/es/open-code-widget/composables/use-session.js +68 -0
- package/es/open-code-widget/composables/use-widget.d.ts +24 -0
- package/es/open-code-widget/composables/use-widget.js +44 -0
- package/es/open-code-widget/index.d.ts +3 -0
- package/es/open-code-widget/index.js +6 -0
- package/es/open-code-widget/src/components/Frame-sfc.css +1 -0
- package/es/open-code-widget/src/components/Frame.vue.d.ts +16 -0
- package/es/open-code-widget/src/components/Frame.vue.js +120 -0
- package/es/open-code-widget/src/components/Header-sfc.css +1 -0
- package/es/open-code-widget/src/components/Header.vue.d.ts +16 -0
- package/es/open-code-widget/src/components/Header.vue.js +140 -0
- package/es/open-code-widget/src/components/SelectHint-sfc.css +1 -0
- package/es/open-code-widget/src/components/SelectHint.vue.d.ts +2 -0
- package/es/open-code-widget/src/components/SelectHint.vue.js +46 -0
- package/es/open-code-widget/src/components/SelectedBubbles-sfc.css +1 -0
- package/es/open-code-widget/src/components/SelectedBubbles.vue.d.ts +2 -0
- package/es/open-code-widget/src/components/SelectedBubbles.vue.js +84 -0
- package/es/open-code-widget/src/components/SelectedNodes-sfc.css +1 -0
- package/es/open-code-widget/src/components/SelectedNodes.vue.d.ts +2 -0
- package/es/open-code-widget/src/components/SelectedNodes.vue.js +103 -0
- package/es/open-code-widget/src/components/SessionList-sfc.css +1 -0
- package/es/open-code-widget/src/components/SessionList.vue.d.ts +12 -0
- package/es/open-code-widget/src/components/SessionList.vue.js +209 -0
- package/es/open-code-widget/src/components/Trigger-sfc.css +1 -0
- package/es/open-code-widget/src/components/Trigger.vue.d.ts +12 -0
- package/es/open-code-widget/src/components/Trigger.vue.js +66 -0
- package/es/open-code-widget/src/context.d.ts +42 -0
- package/es/open-code-widget/src/context.js +16 -0
- package/es/open-code-widget/src/index-sfc.css +1 -0
- package/es/open-code-widget/src/index.vue.d.ts +83 -0
- package/es/open-code-widget/src/index.vue.js +464 -0
- package/es/open-code-widget/src/types.d.ts +74 -0
- package/es/open-code-widget/src/types.js +0 -0
- package/es/open-code-widget/style/index-pure.d.ts +0 -0
- package/es/open-code-widget/style/index-pure.js +0 -0
- package/es/open-code-widget/style/index.d.ts +0 -0
- package/es/open-code-widget/style/index.js +0 -0
- package/es/open-code-widget/style/less-pure.d.ts +0 -0
- package/es/open-code-widget/style/less-pure.js +0 -0
- package/es/open-code-widget/style/less.d.ts +0 -0
- package/es/open-code-widget/style/less.js +0 -0
- package/lib/@vite-plugin-opencode-assistant/components.cjs.js +1322 -0
- package/lib/@vite-plugin-opencode-assistant/components.es.js +1315 -0
- package/lib/components.css +9 -0
- package/lib/env.d.ts +10 -0
- package/lib/index.css +0 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +50 -0
- package/lib/index.less +0 -0
- package/lib/open-code-widget/composables/use-inspector.d.ts +52 -0
- package/lib/open-code-widget/composables/use-inspector.js +207 -0
- package/lib/open-code-widget/composables/use-selection.d.ts +19 -0
- package/lib/open-code-widget/composables/use-selection.js +161 -0
- package/lib/open-code-widget/composables/use-session.d.ts +16 -0
- package/lib/open-code-widget/composables/use-session.js +87 -0
- package/lib/open-code-widget/composables/use-widget.d.ts +24 -0
- package/lib/open-code-widget/composables/use-widget.js +63 -0
- package/lib/open-code-widget/index.d.ts +3 -0
- package/lib/open-code-widget/index.js +36 -0
- package/lib/open-code-widget/src/components/Frame-sfc.css +1 -0
- package/lib/open-code-widget/src/components/Frame.vue.d.ts +16 -0
- package/lib/open-code-widget/src/components/Frame.vue.js +139 -0
- package/lib/open-code-widget/src/components/Header-sfc.css +1 -0
- package/lib/open-code-widget/src/components/Header.vue.d.ts +16 -0
- package/lib/open-code-widget/src/components/Header.vue.js +159 -0
- package/lib/open-code-widget/src/components/SelectHint-sfc.css +1 -0
- package/lib/open-code-widget/src/components/SelectHint.vue.d.ts +2 -0
- package/lib/open-code-widget/src/components/SelectHint.vue.js +65 -0
- package/lib/open-code-widget/src/components/SelectedBubbles-sfc.css +1 -0
- package/lib/open-code-widget/src/components/SelectedBubbles.vue.d.ts +2 -0
- package/lib/open-code-widget/src/components/SelectedBubbles.vue.js +103 -0
- package/lib/open-code-widget/src/components/SelectedNodes-sfc.css +1 -0
- package/lib/open-code-widget/src/components/SelectedNodes.vue.d.ts +2 -0
- package/lib/open-code-widget/src/components/SelectedNodes.vue.js +122 -0
- package/lib/open-code-widget/src/components/SessionList-sfc.css +1 -0
- package/lib/open-code-widget/src/components/SessionList.vue.d.ts +12 -0
- package/lib/open-code-widget/src/components/SessionList.vue.js +228 -0
- package/lib/open-code-widget/src/components/Trigger-sfc.css +1 -0
- package/lib/open-code-widget/src/components/Trigger.vue.d.ts +12 -0
- package/lib/open-code-widget/src/components/Trigger.vue.js +85 -0
- package/lib/open-code-widget/src/context.d.ts +42 -0
- package/lib/open-code-widget/src/context.js +35 -0
- package/lib/open-code-widget/src/index-sfc.css +1 -0
- package/lib/open-code-widget/src/index.vue.d.ts +83 -0
- package/lib/open-code-widget/src/index.vue.js +491 -0
- package/lib/open-code-widget/src/types.d.ts +74 -0
- package/lib/open-code-widget/src/types.js +15 -0
- package/lib/open-code-widget/style/index-pure.d.ts +0 -0
- package/lib/open-code-widget/style/index-pure.js +0 -0
- package/lib/open-code-widget/style/index.d.ts +0 -0
- package/lib/open-code-widget/style/index.js +0 -0
- package/lib/open-code-widget/style/less-pure.d.ts +0 -0
- package/lib/open-code-widget/style/less-pure.js +0 -0
- package/lib/open-code-widget/style/less.d.ts +0 -0
- package/lib/open-code-widget/style/less.js +0 -0
- package/lib/web-types.json +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,1322 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
let vue = require("vue");
|
|
6
|
+
//#region es/open-code-widget/src/context.js
|
|
7
|
+
var CONTEXT_KEY = /* @__PURE__ */ Symbol("OpenCodeWidgetContext");
|
|
8
|
+
function provideOpenCodeWidgetContext(context) {
|
|
9
|
+
(0, vue.provide)(CONTEXT_KEY, context);
|
|
10
|
+
}
|
|
11
|
+
function useOpenCodeWidgetContext() {
|
|
12
|
+
const context = (0, vue.inject)(CONTEXT_KEY);
|
|
13
|
+
if (!context) throw new Error("useOpenCodeWidgetContext must be used within OpenCodeWidget");
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region es/open-code-widget/src/components/Frame.vue.js
|
|
18
|
+
var __vue_sfc__$7 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
19
|
+
__name: "Frame",
|
|
20
|
+
setup(__props, { expose: __expose }) {
|
|
21
|
+
__expose();
|
|
22
|
+
const { loading, showEmptyState, iframeSource: iframeSrc, emptyStateText, emptyStateActionText, handleEmptyAction } = useOpenCodeWidgetContext();
|
|
23
|
+
const __returned__ = {
|
|
24
|
+
loading,
|
|
25
|
+
showEmptyState,
|
|
26
|
+
iframeSrc,
|
|
27
|
+
emptyStateText,
|
|
28
|
+
emptyStateActionText,
|
|
29
|
+
handleEmptyAction
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
32
|
+
enumerable: false,
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
return __returned__;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
var _hoisted_1$7 = { class: "opencode-iframe-container" };
|
|
39
|
+
var _hoisted_2$5 = { class: "opencode-empty-state-text" };
|
|
40
|
+
var _hoisted_3$5 = ["src"];
|
|
41
|
+
function __vue_render__$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
42
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$7, [
|
|
43
|
+
(0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(["opencode-empty-state-overlay", { visible: $setup.showEmptyState }]) }, [(0, vue.renderSlot)(_ctx.$slots, "empty-state", {}, () => [
|
|
44
|
+
_cache[1] || (_cache[1] = (0, vue.createElementVNode)("div", { class: "opencode-empty-state-icon" }, [(0, vue.createElementVNode)("svg", {
|
|
45
|
+
viewBox: "0 0 24 24",
|
|
46
|
+
width: "48",
|
|
47
|
+
height: "48",
|
|
48
|
+
fill: "none",
|
|
49
|
+
stroke: "currentColor",
|
|
50
|
+
"stroke-width": "1.5",
|
|
51
|
+
"aria-hidden": "true"
|
|
52
|
+
}, [(0, vue.createElementVNode)("path", {
|
|
53
|
+
"stroke-linecap": "round",
|
|
54
|
+
"stroke-linejoin": "round",
|
|
55
|
+
d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 0 1-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"
|
|
56
|
+
})])], -1)),
|
|
57
|
+
(0, vue.createElementVNode)("div", _hoisted_2$5, (0, vue.toDisplayString)($setup.emptyStateText), 1),
|
|
58
|
+
(0, vue.createElementVNode)("button", {
|
|
59
|
+
class: "opencode-empty-state-btn",
|
|
60
|
+
type: "button",
|
|
61
|
+
onClick: _cache[0] || (_cache[0] = (...args) => $setup.handleEmptyAction && $setup.handleEmptyAction(...args))
|
|
62
|
+
}, (0, vue.toDisplayString)($setup.emptyStateActionText), 1)
|
|
63
|
+
])], 2),
|
|
64
|
+
(0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(["opencode-loading-overlay", { visible: $setup.loading }]) }, [(0, vue.renderSlot)(_ctx.$slots, "loading", {}, () => [_cache[2] || (_cache[2] = (0, vue.createElementVNode)("div", { class: "opencode-loading-spinner" }, null, -1)), _cache[3] || (_cache[3] = (0, vue.createElementVNode)("div", { class: "opencode-loading-text" }, "加载中...", -1))])], 2),
|
|
65
|
+
(0, vue.renderSlot)(_ctx.$slots, "content", {}, () => [(0, vue.createElementVNode)("iframe", {
|
|
66
|
+
class: "opencode-iframe",
|
|
67
|
+
src: $setup.iframeSrc,
|
|
68
|
+
allow: "clipboard-write; clipboard-read",
|
|
69
|
+
referrerpolicy: "origin"
|
|
70
|
+
}, null, 8, _hoisted_3$5)])
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
__vue_sfc__$7.render = __vue_render__$7;
|
|
74
|
+
var Frame_vue_default = __vue_sfc__$7;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region es/open-code-widget/src/components/Header.vue.js
|
|
77
|
+
var __vue_sfc__$6 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
78
|
+
__name: "Header",
|
|
79
|
+
setup(__props, { expose: __expose }) {
|
|
80
|
+
__expose();
|
|
81
|
+
const { title, sessionListTitle, sessionListCollapsed, selectMode, selectEnabled, handleToggleSessionList, handleToggleSelectMode, handleClose } = useOpenCodeWidgetContext();
|
|
82
|
+
const __returned__ = {
|
|
83
|
+
title,
|
|
84
|
+
sessionListTitle,
|
|
85
|
+
sessionListCollapsed,
|
|
86
|
+
selectMode,
|
|
87
|
+
selectEnabled,
|
|
88
|
+
handleToggleSessionList,
|
|
89
|
+
handleToggleSelectMode,
|
|
90
|
+
handleClose
|
|
91
|
+
};
|
|
92
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
93
|
+
enumerable: false,
|
|
94
|
+
value: true
|
|
95
|
+
});
|
|
96
|
+
return __returned__;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
var _hoisted_1$6 = { class: "opencode-chat-header" };
|
|
100
|
+
var _hoisted_2$4 = { class: "opencode-chat-header-left" };
|
|
101
|
+
var _hoisted_3$4 = [
|
|
102
|
+
"title",
|
|
103
|
+
"aria-label",
|
|
104
|
+
"aria-expanded"
|
|
105
|
+
];
|
|
106
|
+
var _hoisted_4$4 = ["aria-pressed", "disabled"];
|
|
107
|
+
var _hoisted_5$4 = { class: "opencode-chat-header-title" };
|
|
108
|
+
var _hoisted_6$3 = { class: "opencode-chat-header-actions" };
|
|
109
|
+
function __vue_render__$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
110
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$6, [
|
|
111
|
+
(0, vue.createElementVNode)("div", _hoisted_2$4, [(0, vue.createElementVNode)("button", {
|
|
112
|
+
class: "opencode-header-btn session-toggle",
|
|
113
|
+
type: "button",
|
|
114
|
+
title: $setup.sessionListTitle,
|
|
115
|
+
"aria-label": $setup.sessionListTitle,
|
|
116
|
+
"aria-expanded": !$setup.sessionListCollapsed,
|
|
117
|
+
onClick: _cache[0] || (_cache[0] = (...args) => $setup.handleToggleSessionList && $setup.handleToggleSessionList(...args))
|
|
118
|
+
}, [(0, vue.renderSlot)(_ctx.$slots, "session-toggle-icon", {}, () => [_cache[3] || (_cache[3] = (0, vue.createElementVNode)("svg", {
|
|
119
|
+
viewBox: "0 0 24 24",
|
|
120
|
+
width: "16",
|
|
121
|
+
height: "16",
|
|
122
|
+
fill: "none",
|
|
123
|
+
stroke: "currentColor",
|
|
124
|
+
"stroke-width": "2",
|
|
125
|
+
"aria-hidden": "true"
|
|
126
|
+
}, [(0, vue.createElementVNode)("path", {
|
|
127
|
+
d: "M4 6h16M4 12h16M4 18h16",
|
|
128
|
+
"stroke-linecap": "round"
|
|
129
|
+
})], -1))])], 8, _hoisted_3$4), (0, vue.createElementVNode)("button", {
|
|
130
|
+
class: (0, vue.normalizeClass)(["opencode-header-btn select-btn", { active: $setup.selectMode }]),
|
|
131
|
+
type: "button",
|
|
132
|
+
title: "选择页面元素 (Ctrl+P)",
|
|
133
|
+
"aria-label": "选择页面元素",
|
|
134
|
+
"aria-pressed": $setup.selectMode,
|
|
135
|
+
disabled: !$setup.selectEnabled,
|
|
136
|
+
onClick: _cache[1] || (_cache[1] = (...args) => $setup.handleToggleSelectMode && $setup.handleToggleSelectMode(...args))
|
|
137
|
+
}, [(0, vue.renderSlot)(_ctx.$slots, "select-icon", {}, () => [_cache[4] || (_cache[4] = (0, vue.createElementVNode)("svg", {
|
|
138
|
+
viewBox: "0 0 1024 1024",
|
|
139
|
+
width: "16",
|
|
140
|
+
height: "16",
|
|
141
|
+
"aria-hidden": "true"
|
|
142
|
+
}, [(0, vue.createElementVNode)("path", {
|
|
143
|
+
fill: "currentColor",
|
|
144
|
+
d: "M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"
|
|
145
|
+
}), (0, vue.createElementVNode)("path", {
|
|
146
|
+
fill: "currentColor",
|
|
147
|
+
d: "M512 96a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V128a32 32 0 0 1 32-32m0 576a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V704a32 32 0 0 1 32-32M96 512a32 32 0 0 1 32-32h192a32 32 0 0 1 0 64H128a32 32 0 0 1-32-32m576 0a32 32 0 0 1 32-32h192a32 32 0 1 1 0 64H704a32 32 0 0 1-32-32"
|
|
148
|
+
})], -1))])], 10, _hoisted_4$4)]),
|
|
149
|
+
(0, vue.createElementVNode)("span", _hoisted_5$4, (0, vue.toDisplayString)($setup.title), 1),
|
|
150
|
+
(0, vue.createElementVNode)("div", _hoisted_6$3, [(0, vue.createElementVNode)("button", {
|
|
151
|
+
class: "opencode-header-btn close",
|
|
152
|
+
type: "button",
|
|
153
|
+
title: "关闭",
|
|
154
|
+
"aria-label": "关闭面板",
|
|
155
|
+
onClick: _cache[2] || (_cache[2] = (...args) => $setup.handleClose && $setup.handleClose(...args))
|
|
156
|
+
}, [(0, vue.renderSlot)(_ctx.$slots, "close-icon", {}, () => [_cache[5] || (_cache[5] = (0, vue.createElementVNode)("svg", {
|
|
157
|
+
viewBox: "0 0 24 24",
|
|
158
|
+
width: "14",
|
|
159
|
+
height: "14",
|
|
160
|
+
fill: "none",
|
|
161
|
+
stroke: "currentColor",
|
|
162
|
+
"stroke-width": "2",
|
|
163
|
+
"aria-hidden": "true"
|
|
164
|
+
}, [(0, vue.createElementVNode)("path", { d: "M18 6L6 18M6 6l12 12" })], -1))])])])
|
|
165
|
+
]);
|
|
166
|
+
}
|
|
167
|
+
__vue_sfc__$6.render = __vue_render__$6;
|
|
168
|
+
var Header_vue_default = __vue_sfc__$6;
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region es/open-code-widget/src/components/SelectHint.vue.js
|
|
171
|
+
var __vue_sfc__$5 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
172
|
+
__name: "SelectHint",
|
|
173
|
+
setup(__props, { expose: __expose }) {
|
|
174
|
+
__expose();
|
|
175
|
+
const { selectMode: visible, selectShortcutLabel: shortcutLabel } = useOpenCodeWidgetContext();
|
|
176
|
+
const __returned__ = {
|
|
177
|
+
visible,
|
|
178
|
+
shortcutLabel
|
|
179
|
+
};
|
|
180
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
181
|
+
enumerable: false,
|
|
182
|
+
value: true
|
|
183
|
+
});
|
|
184
|
+
return __returned__;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
var _hoisted_1$5 = { class: "opencode-hint-shortcut" };
|
|
188
|
+
function __vue_render__$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
189
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", { class: (0, vue.normalizeClass)(["opencode-select-mode-hint", { visible: $setup.visible }]) }, [_cache[0] || (_cache[0] = (0, vue.createElementVNode)("span", null, "🎯 选择模式已开启 - 点击元素进行选择", -1)), (0, vue.createElementVNode)("span", _hoisted_1$5, (0, vue.toDisplayString)($setup.shortcutLabel), 1)], 2);
|
|
190
|
+
}
|
|
191
|
+
__vue_sfc__$5.render = __vue_render__$5;
|
|
192
|
+
var SelectHint_vue_default = __vue_sfc__$5;
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region es/open-code-widget/src/components/SelectedBubbles.vue.js
|
|
195
|
+
var __vue_sfc__$4 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
196
|
+
__name: "SelectedBubbles",
|
|
197
|
+
setup(__props, { expose: __expose }) {
|
|
198
|
+
__expose();
|
|
199
|
+
const { bubbleVisible: visible, selectedElementItems: items, handleClickSelectedNode, handleRemoveSelectedNode } = useOpenCodeWidgetContext();
|
|
200
|
+
const __returned__ = {
|
|
201
|
+
visible,
|
|
202
|
+
items,
|
|
203
|
+
handleClickSelectedNode,
|
|
204
|
+
handleRemoveSelectedNode
|
|
205
|
+
};
|
|
206
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
207
|
+
enumerable: false,
|
|
208
|
+
value: true
|
|
209
|
+
});
|
|
210
|
+
return __returned__;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
var _hoisted_1$4 = {
|
|
214
|
+
key: 0,
|
|
215
|
+
class: "opencode-bubble-empty"
|
|
216
|
+
};
|
|
217
|
+
var _hoisted_2$3 = ["onClick"];
|
|
218
|
+
var _hoisted_3$3 = { class: "opencode-bubble-text" };
|
|
219
|
+
var _hoisted_4$3 = {
|
|
220
|
+
key: 0,
|
|
221
|
+
class: "opencode-bubble-file"
|
|
222
|
+
};
|
|
223
|
+
var _hoisted_5$3 = ["aria-label", "onClick"];
|
|
224
|
+
function __vue_render__$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
225
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
226
|
+
class: (0, vue.normalizeClass)(["opencode-selected-bubbles", { visible: $setup.visible }]),
|
|
227
|
+
role: "list",
|
|
228
|
+
"aria-label": "已选元素列表"
|
|
229
|
+
}, [$setup.items.length === 0 ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$4, "暂无选中元素")) : ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, (0, vue.renderList)($setup.items, (item, index) => {
|
|
230
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
231
|
+
key: item.key,
|
|
232
|
+
class: "opencode-selected-bubble",
|
|
233
|
+
role: "listitem",
|
|
234
|
+
onClick: ($event) => $setup.handleClickSelectedNode(item)
|
|
235
|
+
}, [
|
|
236
|
+
(0, vue.createElementVNode)("span", _hoisted_3$3, (0, vue.toDisplayString)(item.description), 1),
|
|
237
|
+
item.bubbleFileText ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", _hoisted_4$3, (0, vue.toDisplayString)(item.bubbleFileText), 1)) : (0, vue.createCommentVNode)("v-if", true),
|
|
238
|
+
(0, vue.createElementVNode)("button", {
|
|
239
|
+
class: "opencode-bubble-remove",
|
|
240
|
+
type: "button",
|
|
241
|
+
"aria-label": `\u79FB\u9664\u5143\u7D20: ${item.description}`,
|
|
242
|
+
onClick: (0, vue.withModifiers)(($event) => $setup.handleRemoveSelectedNode({
|
|
243
|
+
item,
|
|
244
|
+
index,
|
|
245
|
+
source: "bubble"
|
|
246
|
+
}), ["stop"])
|
|
247
|
+
}, " × ", 8, _hoisted_5$3)
|
|
248
|
+
], 8, _hoisted_2$3);
|
|
249
|
+
}), 128))], 2);
|
|
250
|
+
}
|
|
251
|
+
__vue_sfc__$4.render = __vue_render__$4;
|
|
252
|
+
var SelectedBubbles_vue_default = __vue_sfc__$4;
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region es/open-code-widget/src/components/SelectedNodes.vue.js
|
|
255
|
+
var __vue_sfc__$3 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
256
|
+
__name: "SelectedNodes",
|
|
257
|
+
setup(__props, { expose: __expose }) {
|
|
258
|
+
__expose();
|
|
259
|
+
const { selectedElementItems: items, showClearAll, handleClickSelectedNode, handleRemoveSelectedNode, handleClearSelectedNodes } = useOpenCodeWidgetContext();
|
|
260
|
+
const __returned__ = {
|
|
261
|
+
items,
|
|
262
|
+
showClearAll,
|
|
263
|
+
handleClickSelectedNode,
|
|
264
|
+
handleRemoveSelectedNode,
|
|
265
|
+
handleClearSelectedNodes
|
|
266
|
+
};
|
|
267
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
268
|
+
enumerable: false,
|
|
269
|
+
value: true
|
|
270
|
+
});
|
|
271
|
+
return __returned__;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
var _hoisted_1$3 = {
|
|
275
|
+
class: "opencode-selected-nodes",
|
|
276
|
+
role: "list",
|
|
277
|
+
"aria-label": "已选元素列表"
|
|
278
|
+
};
|
|
279
|
+
var _hoisted_2$2 = ["onClick"];
|
|
280
|
+
var _hoisted_3$2 = { class: "opencode-node-content" };
|
|
281
|
+
var _hoisted_4$2 = { class: "opencode-node-text" };
|
|
282
|
+
var _hoisted_5$2 = { class: "opencode-node-file" };
|
|
283
|
+
var _hoisted_6$2 = ["aria-label", "onClick"];
|
|
284
|
+
function __vue_render__$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
285
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", { class: (0, vue.normalizeClass)(["opencode-right-toolbar", { collapsed: $setup.items.length === 0 }]) }, [
|
|
286
|
+
_cache[1] || (_cache[1] = (0, vue.createElementVNode)("div", { class: "opencode-selected-nodes-header" }, [(0, vue.createElementVNode)("div", { class: "opencode-selected-nodes-title" }, "已选节点"), (0, vue.createElementVNode)("div", { class: "opencode-selected-nodes-desc" }, "选中的节点会在对话时一起发送给助手")], -1)),
|
|
287
|
+
(0, vue.createElementVNode)("div", _hoisted_1$3, [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)($setup.items, (item, index) => {
|
|
288
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
289
|
+
key: item.key,
|
|
290
|
+
class: "opencode-selected-node",
|
|
291
|
+
role: "listitem",
|
|
292
|
+
onClick: ($event) => $setup.handleClickSelectedNode(item)
|
|
293
|
+
}, [(0, vue.createElementVNode)("div", _hoisted_3$2, [(0, vue.createElementVNode)("span", _hoisted_4$2, (0, vue.toDisplayString)(item.description), 1), (0, vue.createElementVNode)("span", _hoisted_5$2, (0, vue.toDisplayString)(item.panelFileText), 1)]), (0, vue.createElementVNode)("button", {
|
|
294
|
+
class: "opencode-node-remove",
|
|
295
|
+
type: "button",
|
|
296
|
+
"aria-label": `\u79FB\u9664\u5143\u7D20: ${item.description}`,
|
|
297
|
+
onClick: (0, vue.withModifiers)(($event) => $setup.handleRemoveSelectedNode({
|
|
298
|
+
item,
|
|
299
|
+
index,
|
|
300
|
+
source: "panel"
|
|
301
|
+
}), ["stop"])
|
|
302
|
+
}, " × ", 8, _hoisted_6$2)], 8, _hoisted_2$2);
|
|
303
|
+
}), 128))]),
|
|
304
|
+
$setup.showClearAll && $setup.items.length > 0 ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("button", {
|
|
305
|
+
key: 0,
|
|
306
|
+
class: "opencode-clear-all-btn",
|
|
307
|
+
type: "button",
|
|
308
|
+
"aria-label": "清空所有已选节点",
|
|
309
|
+
onClick: _cache[0] || (_cache[0] = (...args) => $setup.handleClearSelectedNodes && $setup.handleClearSelectedNodes(...args))
|
|
310
|
+
}, " 一键清空 ")) : (0, vue.createCommentVNode)("v-if", true)
|
|
311
|
+
], 2);
|
|
312
|
+
}
|
|
313
|
+
__vue_sfc__$3.render = __vue_render__$3;
|
|
314
|
+
var SelectedNodes_vue_default = __vue_sfc__$3;
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region es/open-code-widget/src/components/SessionList.vue.js
|
|
317
|
+
var __vue_sfc__$2 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
318
|
+
__name: "SessionList",
|
|
319
|
+
setup(__props, { expose: __expose }) {
|
|
320
|
+
__expose();
|
|
321
|
+
const { sessionListCollapsed: collapsed, sessionItems: sessions, loadingSessionList, handleCreateSession, handleSelectSession, handleDeleteSession } = useOpenCodeWidgetContext();
|
|
322
|
+
const isAnimating = (0, vue.ref)(false);
|
|
323
|
+
let animTimer = null;
|
|
324
|
+
(0, vue.watch)(collapsed, () => {
|
|
325
|
+
isAnimating.value = true;
|
|
326
|
+
if (animTimer) clearTimeout(animTimer);
|
|
327
|
+
animTimer = setTimeout(() => {
|
|
328
|
+
isAnimating.value = false;
|
|
329
|
+
}, 200);
|
|
330
|
+
});
|
|
331
|
+
const __returned__ = {
|
|
332
|
+
collapsed,
|
|
333
|
+
sessions,
|
|
334
|
+
loadingSessionList,
|
|
335
|
+
handleCreateSession,
|
|
336
|
+
handleSelectSession,
|
|
337
|
+
handleDeleteSession,
|
|
338
|
+
isAnimating,
|
|
339
|
+
get animTimer() {
|
|
340
|
+
return animTimer;
|
|
341
|
+
},
|
|
342
|
+
set animTimer(v) {
|
|
343
|
+
animTimer = v;
|
|
344
|
+
},
|
|
345
|
+
showSkeleton: (0, vue.computed)(() => {
|
|
346
|
+
if (isAnimating.value) return true;
|
|
347
|
+
return false;
|
|
348
|
+
})
|
|
349
|
+
};
|
|
350
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
351
|
+
enumerable: false,
|
|
352
|
+
value: true
|
|
353
|
+
});
|
|
354
|
+
return __returned__;
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
var _hoisted_1$2 = {
|
|
358
|
+
key: 0,
|
|
359
|
+
class: "opencode-session-list-header"
|
|
360
|
+
};
|
|
361
|
+
var _hoisted_2$1 = {
|
|
362
|
+
key: 2,
|
|
363
|
+
class: "opencode-session-skeleton visible"
|
|
364
|
+
};
|
|
365
|
+
var _hoisted_3$1 = {
|
|
366
|
+
class: "opencode-session-list-content",
|
|
367
|
+
role: "listbox",
|
|
368
|
+
"aria-labelledby": "opencode-session-list-title"
|
|
369
|
+
};
|
|
370
|
+
var _hoisted_4$1 = {
|
|
371
|
+
key: 0,
|
|
372
|
+
class: "opencode-session-list-loading-overlay"
|
|
373
|
+
};
|
|
374
|
+
var _hoisted_5$1 = ["aria-selected", "onClick"];
|
|
375
|
+
var _hoisted_6$1 = { class: "opencode-session-header" };
|
|
376
|
+
var _hoisted_7$1 = { class: "opencode-session-title" };
|
|
377
|
+
var _hoisted_8$1 = ["aria-label", "onClick"];
|
|
378
|
+
var _hoisted_9 = { class: "opencode-session-meta" };
|
|
379
|
+
function __vue_render__$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
380
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", { class: (0, vue.normalizeClass)(["opencode-session-list", { collapsed: $setup.collapsed }]) }, [
|
|
381
|
+
(0, vue.createCommentVNode)(" Header "),
|
|
382
|
+
!$setup.showSkeleton ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1$2, [_cache[1] || (_cache[1] = (0, vue.createElementVNode)("span", { id: "opencode-session-list-title" }, "会话列表", -1)), (0, vue.createElementVNode)("button", {
|
|
383
|
+
class: "opencode-new-session-btn",
|
|
384
|
+
type: "button",
|
|
385
|
+
title: "新建会话",
|
|
386
|
+
"aria-label": "新建会话",
|
|
387
|
+
onClick: _cache[0] || (_cache[0] = (...args) => $setup.handleCreateSession && $setup.handleCreateSession(...args))
|
|
388
|
+
}, " + ")])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, [(0, vue.createCommentVNode)(" Header Skeleton "), _cache[2] || (_cache[2] = (0, vue.createElementVNode)("div", { class: "opencode-session-header-skeleton visible" }, [(0, vue.createElementVNode)("div", { class: "opencode-skeleton-header-title" }), (0, vue.createElementVNode)("div", { class: "opencode-skeleton-header-btn" })], -1))], 2112)),
|
|
389
|
+
(0, vue.createCommentVNode)(" Content Skeleton "),
|
|
390
|
+
$setup.showSkeleton ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_2$1, [((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(5, (i) => {
|
|
391
|
+
return (0, vue.createElementVNode)("div", {
|
|
392
|
+
key: `skeleton-${i}`,
|
|
393
|
+
class: "opencode-skeleton-item"
|
|
394
|
+
}, [..._cache[3] || (_cache[3] = [(0, vue.createElementVNode)("div", { class: "opencode-skeleton-title" }, null, -1), (0, vue.createElementVNode)("div", { class: "opencode-skeleton-meta" }, null, -1)])]);
|
|
395
|
+
}), 64))])) : ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 3 }, [(0, vue.createCommentVNode)(" Content "), (0, vue.createElementVNode)("div", _hoisted_3$1, [$setup.loadingSessionList ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_4$1, [..._cache[4] || (_cache[4] = [(0, vue.createElementVNode)("div", { class: "opencode-loading-spinner small" }, null, -1)])])) : (0, vue.createCommentVNode)("v-if", true), $setup.sessions.length > 0 ? ((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, { key: 1 }, (0, vue.renderList)($setup.sessions, (item) => {
|
|
396
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
397
|
+
key: item.key,
|
|
398
|
+
class: (0, vue.normalizeClass)(["opencode-session-item", { active: item.active }]),
|
|
399
|
+
role: "option",
|
|
400
|
+
"aria-selected": item.active,
|
|
401
|
+
onClick: ($event) => $setup.handleSelectSession(item)
|
|
402
|
+
}, [(0, vue.createElementVNode)("div", _hoisted_6$1, [(0, vue.createElementVNode)("div", _hoisted_7$1, (0, vue.toDisplayString)(item.title), 1), (0, vue.createElementVNode)("button", {
|
|
403
|
+
class: "opencode-session-delete-btn",
|
|
404
|
+
type: "button",
|
|
405
|
+
"aria-label": `\u5220\u9664\u4F1A\u8BDD: ${item.title}`,
|
|
406
|
+
onClick: (0, vue.withModifiers)(($event) => $setup.handleDeleteSession(item), ["stop"])
|
|
407
|
+
}, " × ", 8, _hoisted_8$1)]), (0, vue.createElementVNode)("div", _hoisted_9, (0, vue.toDisplayString)(item.meta), 1)], 10, _hoisted_5$1);
|
|
408
|
+
}), 128)) : ((0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, { key: 2 }, [(0, vue.createCommentVNode)(" Empty State "), (0, vue.renderSlot)(_ctx.$slots, "empty")], 64))])], 2112))
|
|
409
|
+
], 2);
|
|
410
|
+
}
|
|
411
|
+
__vue_sfc__$2.render = __vue_render__$2;
|
|
412
|
+
var SessionList_vue_default = __vue_sfc__$2;
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region es/open-code-widget/src/components/Trigger.vue.js
|
|
415
|
+
var __vue_sfc__$1 = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
416
|
+
__name: "Trigger",
|
|
417
|
+
setup(__props, { expose: __expose }) {
|
|
418
|
+
__expose();
|
|
419
|
+
const { buttonActive: active, open, hotkeyLabel, handleToggle } = useOpenCodeWidgetContext();
|
|
420
|
+
const __returned__ = {
|
|
421
|
+
active,
|
|
422
|
+
open,
|
|
423
|
+
hotkeyLabel,
|
|
424
|
+
handleToggle
|
|
425
|
+
};
|
|
426
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
427
|
+
enumerable: false,
|
|
428
|
+
value: true
|
|
429
|
+
});
|
|
430
|
+
return __returned__;
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
var _hoisted_1$1 = ["aria-expanded", "title"];
|
|
434
|
+
function __vue_render__$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
435
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("button", {
|
|
436
|
+
class: (0, vue.normalizeClass)(["opencode-button", { active: $setup.active }]),
|
|
437
|
+
type: "button",
|
|
438
|
+
"aria-expanded": $setup.open,
|
|
439
|
+
"aria-label": "打开 AI 助手",
|
|
440
|
+
title: `AI \u52A9\u624B (${$setup.hotkeyLabel})`,
|
|
441
|
+
onClick: _cache[0] || (_cache[0] = (...args) => $setup.handleToggle && $setup.handleToggle(...args))
|
|
442
|
+
}, [(0, vue.renderSlot)(_ctx.$slots, "default", {}, () => [_cache[1] || (_cache[1] = (0, vue.createElementVNode)("svg", {
|
|
443
|
+
t: "1775402599580",
|
|
444
|
+
class: "icon",
|
|
445
|
+
viewBox: "0 0 1024 1024",
|
|
446
|
+
version: "1.1",
|
|
447
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
448
|
+
"p-id": "5390",
|
|
449
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
|
450
|
+
width: "100%",
|
|
451
|
+
height: "100%"
|
|
452
|
+
}, [
|
|
453
|
+
(0, vue.createElementVNode)("path", {
|
|
454
|
+
d: "M512 981.33H85.34c-15.85 0-30.38-8.77-37.77-22.81a42.624 42.624 0 0 1 2.6-44.02L135 791.08C75.25 710.5 42.67 612.6 42.67 512 42.67 253.21 253.21 42.67 512 42.67S981.34 253.21 981.34 512 770.8 981.33 512 981.33zM166.44 896H512c211.73 0 384-172.27 384-384S723.73 128 512 128 128 300.27 128 512c0 91.29 32.83 179.9 92.46 249.46 12.58 14.69 13.73 36 2.77 51.94L166.44 896z",
|
|
455
|
+
fill: "white",
|
|
456
|
+
"p-id": "5391"
|
|
457
|
+
}),
|
|
458
|
+
(0, vue.createElementVNode)("path", {
|
|
459
|
+
d: "M384 448m-64 0a64 64 0 1 0 128 0 64 64 0 1 0 -128 0Z",
|
|
460
|
+
fill: "white",
|
|
461
|
+
"p-id": "5392"
|
|
462
|
+
}),
|
|
463
|
+
(0, vue.createElementVNode)("path", {
|
|
464
|
+
d: "M640 448m-64 0a64 64 0 1 0 128 0 64 64 0 1 0 -128 0Z",
|
|
465
|
+
fill: "white",
|
|
466
|
+
"p-id": "5393"
|
|
467
|
+
})
|
|
468
|
+
], -1))])], 10, _hoisted_1$1);
|
|
469
|
+
}
|
|
470
|
+
__vue_sfc__$1.render = __vue_render__$1;
|
|
471
|
+
var Trigger_vue_default = __vue_sfc__$1;
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region es/open-code-widget/composables/use-selection.js
|
|
474
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
475
|
+
return new Promise((resolve, reject) => {
|
|
476
|
+
var fulfilled = (value) => {
|
|
477
|
+
try {
|
|
478
|
+
step(generator.next(value));
|
|
479
|
+
} catch (e) {
|
|
480
|
+
reject(e);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
var rejected = (value) => {
|
|
484
|
+
try {
|
|
485
|
+
step(generator.throw(value));
|
|
486
|
+
} catch (e) {
|
|
487
|
+
reject(e);
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
491
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
function truncate$1(value, maxLength) {
|
|
495
|
+
if (value.length <= maxLength) return value;
|
|
496
|
+
return `${value.slice(0, maxLength)}...`;
|
|
497
|
+
}
|
|
498
|
+
function getElementKey(element, index) {
|
|
499
|
+
var _a;
|
|
500
|
+
if (element.filePath && element.line) return `${element.filePath}:${element.line}:${(_a = element.column) != null ? _a : 0}`;
|
|
501
|
+
return `${element.description}-${index}`;
|
|
502
|
+
}
|
|
503
|
+
function getBubbleFileText(element) {
|
|
504
|
+
var _a;
|
|
505
|
+
return `${((_a = element.filePath) == null ? void 0 : _a.split("/").pop()) || ""}${element.line ? `:${element.line}${element.column ? `:${element.column}` : ""}` : ""}`;
|
|
506
|
+
}
|
|
507
|
+
function getPanelFileText(element) {
|
|
508
|
+
var _a, _b;
|
|
509
|
+
const fileName = ((_a = element.filePath) == null ? void 0 : _a.split("/").pop()) || "未知文件";
|
|
510
|
+
const lineInfo = element.line ? `:${element.line}${element.column ? `:${element.column}` : ""}` : "";
|
|
511
|
+
return `${((_b = element.innerText) == null ? void 0 : _b.trim()) ? `${truncate$1(element.innerText.trim(), 30)} \xB7 ` : ""}${fileName}${lineInfo}`;
|
|
512
|
+
}
|
|
513
|
+
function useSelection(options) {
|
|
514
|
+
const bubbleVisible = (0, vue.computed)(() => options.selectMode.value);
|
|
515
|
+
const selectedElementItems = (0, vue.computed)(() => (options.selectedElements.value || []).map((element, index) => ({
|
|
516
|
+
key: getElementKey(element, index),
|
|
517
|
+
description: element.description || "未知元素",
|
|
518
|
+
bubbleFileText: getBubbleFileText(element),
|
|
519
|
+
panelFileText: getPanelFileText(element),
|
|
520
|
+
element
|
|
521
|
+
})));
|
|
522
|
+
const hasSelectedElements = (0, vue.computed)(() => selectedElementItems.value.length > 0);
|
|
523
|
+
function handleToggleSelectMode() {
|
|
524
|
+
options.onToggleSelectMode(!options.selectMode.value);
|
|
525
|
+
}
|
|
526
|
+
function handleClickSelectedNode(item) {
|
|
527
|
+
const description = item.element.description;
|
|
528
|
+
if (!description) return;
|
|
529
|
+
let targetElement = null;
|
|
530
|
+
if (description.includes("#")) {
|
|
531
|
+
const idMatch = description.match(/#([^.[\s]+)/);
|
|
532
|
+
if (idMatch) targetElement = document.getElementById(idMatch[1]);
|
|
533
|
+
}
|
|
534
|
+
if (!targetElement && description.includes(".")) {
|
|
535
|
+
const classMatch = description.match(/^([a-z]+)\.([^[\s]+)/i);
|
|
536
|
+
if (classMatch) {
|
|
537
|
+
const selector = `${classMatch[1]}.${classMatch[2].split(".").filter(Boolean).join(".")}`;
|
|
538
|
+
targetElement = document.querySelector(selector);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (!targetElement) {
|
|
542
|
+
if (description.match(/^([a-z]+)/i)) {
|
|
543
|
+
const simpleSelector = description.split(/[.[\s]/)[0];
|
|
544
|
+
targetElement = document.querySelector(simpleSelector);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (targetElement) {
|
|
548
|
+
targetElement.scrollIntoView({
|
|
549
|
+
behavior: "smooth",
|
|
550
|
+
block: "center"
|
|
551
|
+
});
|
|
552
|
+
const highlightOverlay = document.createElement("div");
|
|
553
|
+
highlightOverlay.className = "opencode-element-highlight-temp";
|
|
554
|
+
const widget = document.querySelector(".opencode-widget");
|
|
555
|
+
let primary = "#3b82f6";
|
|
556
|
+
let primaryBg = "rgba(59, 130, 246, 0.1)";
|
|
557
|
+
if (widget) {
|
|
558
|
+
const style = getComputedStyle(widget);
|
|
559
|
+
primary = style.getPropertyValue("--oc-primary").trim() || primary;
|
|
560
|
+
primaryBg = style.getPropertyValue("--oc-primary-bg").trim() || primaryBg;
|
|
561
|
+
}
|
|
562
|
+
highlightOverlay.style.border = `2px solid ${primary}`;
|
|
563
|
+
highlightOverlay.style.background = primaryBg;
|
|
564
|
+
const rect = targetElement.getBoundingClientRect();
|
|
565
|
+
highlightOverlay.style.top = `${rect.top + window.scrollY}px`;
|
|
566
|
+
highlightOverlay.style.left = `${rect.left + window.scrollX}px`;
|
|
567
|
+
highlightOverlay.style.width = `${rect.width}px`;
|
|
568
|
+
highlightOverlay.style.height = `${rect.height}px`;
|
|
569
|
+
document.body.appendChild(highlightOverlay);
|
|
570
|
+
setTimeout(() => {
|
|
571
|
+
highlightOverlay.remove();
|
|
572
|
+
}, 2e3);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
function handleRemoveSelectedNode(item, index, source) {
|
|
576
|
+
options.onRemoveSelectedNode({
|
|
577
|
+
element: item.element,
|
|
578
|
+
index,
|
|
579
|
+
source
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
function handleClearSelectedNodes() {
|
|
583
|
+
return __async$1(this, null, function* () {
|
|
584
|
+
if (!options.selectedElements.value || options.selectedElements.value.length === 0) return;
|
|
585
|
+
if (yield options.showConfirmDialog(`\u786E\u5B9A\u8981\u6E05\u7A7A\u6240\u6709 ${options.selectedElements.value.length} \u4E2A\u5DF2\u9009\u8282\u70B9\u5417\uFF1F`)) options.onClearSelectedNodes();
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
return {
|
|
589
|
+
bubbleVisible,
|
|
590
|
+
hasSelectedElements,
|
|
591
|
+
selectedElementItems,
|
|
592
|
+
handleClearSelectedNodes,
|
|
593
|
+
handleClickSelectedNode,
|
|
594
|
+
handleRemoveSelectedNode,
|
|
595
|
+
handleToggleSelectMode
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
//#endregion
|
|
599
|
+
//#region es/open-code-widget/composables/use-session.js
|
|
600
|
+
var __async = (__this, __arguments, generator) => {
|
|
601
|
+
return new Promise((resolve, reject) => {
|
|
602
|
+
var fulfilled = (value) => {
|
|
603
|
+
try {
|
|
604
|
+
step(generator.next(value));
|
|
605
|
+
} catch (e) {
|
|
606
|
+
reject(e);
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
var rejected = (value) => {
|
|
610
|
+
try {
|
|
611
|
+
step(generator.throw(value));
|
|
612
|
+
} catch (e) {
|
|
613
|
+
reject(e);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
617
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
618
|
+
});
|
|
619
|
+
};
|
|
620
|
+
function formatSessionMeta(session) {
|
|
621
|
+
if (session.meta) return session.meta;
|
|
622
|
+
if (!session.updatedAt) return "";
|
|
623
|
+
const date = new Date(session.updatedAt);
|
|
624
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
625
|
+
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
|
626
|
+
}
|
|
627
|
+
function useSession(options) {
|
|
628
|
+
const sessionItems = (0, vue.computed)(() => (options.sessions.value || []).map((session) => ({
|
|
629
|
+
key: session.id,
|
|
630
|
+
title: session.title || "新会话",
|
|
631
|
+
meta: formatSessionMeta(session),
|
|
632
|
+
active: session.id === options.currentSessionId.value,
|
|
633
|
+
session
|
|
634
|
+
})));
|
|
635
|
+
function handleCreateSession() {
|
|
636
|
+
options.onCreateSession();
|
|
637
|
+
}
|
|
638
|
+
function handleSelectSession(item) {
|
|
639
|
+
options.onSelectSession(item.session);
|
|
640
|
+
}
|
|
641
|
+
function handleDeleteSession(item) {
|
|
642
|
+
return __async(this, null, function* () {
|
|
643
|
+
if (yield options.showConfirmDialog(`\u786E\u5B9A\u8981\u5220\u9664\u4F1A\u8BDD "${item.title}" \u5417\uFF1F`)) options.onDeleteSession(item.session);
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
return {
|
|
647
|
+
sessionItems,
|
|
648
|
+
handleCreateSession,
|
|
649
|
+
handleDeleteSession,
|
|
650
|
+
handleSelectSession
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
//#endregion
|
|
654
|
+
//#region es/open-code-widget/composables/use-widget.js
|
|
655
|
+
function useWidget(options) {
|
|
656
|
+
const containerClasses = (0, vue.computed)(() => [
|
|
657
|
+
"opencode-widget",
|
|
658
|
+
options.position.value,
|
|
659
|
+
`opencode-theme-${options.theme.value}`
|
|
660
|
+
]);
|
|
661
|
+
const buttonActive = (0, vue.computed)(() => !!(options.open.value || options.selectMode.value));
|
|
662
|
+
const iframeSource = (0, vue.computed)(() => options.iframeSrc.value || "about:blank");
|
|
663
|
+
const sessionListTitle = (0, vue.computed)(() => options.sessionListCollapsed.value ? "展开会话列表" : "折叠会话列表");
|
|
664
|
+
function handleToggle() {
|
|
665
|
+
var _a;
|
|
666
|
+
if (options.selectMode.value) {
|
|
667
|
+
(_a = options.onToggleSelectMode) == null || _a.call(options, false);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
const nextOpen = !options.open.value;
|
|
671
|
+
options.onToggle(nextOpen);
|
|
672
|
+
}
|
|
673
|
+
function handleClose() {
|
|
674
|
+
options.onClose();
|
|
675
|
+
}
|
|
676
|
+
function handleToggleSessionList() {
|
|
677
|
+
options.onToggleSessionList(!options.sessionListCollapsed.value);
|
|
678
|
+
}
|
|
679
|
+
function handleEmptyAction() {
|
|
680
|
+
options.onEmptyAction();
|
|
681
|
+
}
|
|
682
|
+
return {
|
|
683
|
+
buttonActive,
|
|
684
|
+
containerClasses,
|
|
685
|
+
iframeSource,
|
|
686
|
+
sessionListTitle,
|
|
687
|
+
handleClose,
|
|
688
|
+
handleEmptyAction,
|
|
689
|
+
handleToggle,
|
|
690
|
+
handleToggleSessionList
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
//#endregion
|
|
694
|
+
//#region es/open-code-widget/composables/use-inspector.js
|
|
695
|
+
function truncate(str, maxLength) {
|
|
696
|
+
if (!str) return "";
|
|
697
|
+
return str.length > maxLength ? str.substring(0, maxLength) + "..." : str;
|
|
698
|
+
}
|
|
699
|
+
function getDirectText(element) {
|
|
700
|
+
let text = "";
|
|
701
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
702
|
+
const child = element.childNodes[i];
|
|
703
|
+
if (child.nodeType === Node.TEXT_NODE) text += child.textContent || "";
|
|
704
|
+
}
|
|
705
|
+
return text.trim();
|
|
706
|
+
}
|
|
707
|
+
function getElementDescription(element) {
|
|
708
|
+
const parts = [element.tagName.toLowerCase()];
|
|
709
|
+
const id = element.id;
|
|
710
|
+
if (id) parts.push(`#${id}`);
|
|
711
|
+
if (typeof element.className === "string") {
|
|
712
|
+
const className = element.className.trim().split(/\s+/).filter(Boolean).slice(0, 2).join(".");
|
|
713
|
+
if (className) parts.push(`.${className}`);
|
|
714
|
+
}
|
|
715
|
+
const name = element.getAttribute("name");
|
|
716
|
+
if (name) parts.push(`[name="${name}"]`);
|
|
717
|
+
const placeholder = element.getAttribute("placeholder");
|
|
718
|
+
if (placeholder) parts.push(`[placeholder="${placeholder.substring(0, 20)}"]`);
|
|
719
|
+
if (element.getAttribute("src")) parts.push(`[src]`);
|
|
720
|
+
const href = element.getAttribute("href");
|
|
721
|
+
if (href && href !== "#") parts.push(`[href]`);
|
|
722
|
+
return parts.join("");
|
|
723
|
+
}
|
|
724
|
+
function useInspector(options) {
|
|
725
|
+
const highlightVisible = (0, vue.ref)(false);
|
|
726
|
+
const highlightStyle = (0, vue.ref)({
|
|
727
|
+
top: "0px",
|
|
728
|
+
left: "0px",
|
|
729
|
+
width: "0px",
|
|
730
|
+
height: "0px"
|
|
731
|
+
});
|
|
732
|
+
const tooltipVisible = (0, vue.ref)(false);
|
|
733
|
+
const tooltipStyle = (0, vue.ref)({
|
|
734
|
+
top: "0px",
|
|
735
|
+
left: "0px"
|
|
736
|
+
});
|
|
737
|
+
const tooltipContent = (0, vue.ref)({
|
|
738
|
+
description: "",
|
|
739
|
+
fileInfo: ""
|
|
740
|
+
});
|
|
741
|
+
const INSPECTOR_CHECK_INTERVAL = 500;
|
|
742
|
+
let inspectorCheckTimer = null;
|
|
743
|
+
function handleMouseMove(e) {
|
|
744
|
+
if (!options.selectMode.value) return;
|
|
745
|
+
const inspector = window.__VUE_INSPECTOR__;
|
|
746
|
+
if (!inspector) return;
|
|
747
|
+
const { targetNode, params } = inspector.getTargetNode(e);
|
|
748
|
+
if (targetNode && params) {
|
|
749
|
+
const rect = targetNode.getBoundingClientRect();
|
|
750
|
+
const widget = document.querySelector(".opencode-widget");
|
|
751
|
+
let primary = "#3b82f6";
|
|
752
|
+
let primaryBg = "rgba(59, 130, 246, 0.1)";
|
|
753
|
+
if (widget) {
|
|
754
|
+
const style = getComputedStyle(widget);
|
|
755
|
+
primary = style.getPropertyValue("--oc-primary").trim() || primary;
|
|
756
|
+
primaryBg = style.getPropertyValue("--oc-primary-bg").trim() || primaryBg;
|
|
757
|
+
}
|
|
758
|
+
highlightVisible.value = true;
|
|
759
|
+
highlightStyle.value = {
|
|
760
|
+
top: `${rect.top}px`,
|
|
761
|
+
left: `${rect.left}px`,
|
|
762
|
+
width: `${rect.width}px`,
|
|
763
|
+
height: `${rect.height}px`,
|
|
764
|
+
border: `2px solid ${primary}`,
|
|
765
|
+
background: primaryBg
|
|
766
|
+
};
|
|
767
|
+
const description = getElementDescription(targetNode);
|
|
768
|
+
const fileName = params.file ? params.file.split("/").pop() : "";
|
|
769
|
+
let lineInfo = "";
|
|
770
|
+
if (params.line) {
|
|
771
|
+
lineInfo = `:${params.line}`;
|
|
772
|
+
if (params.column) lineInfo += `:${params.column}`;
|
|
773
|
+
}
|
|
774
|
+
tooltipContent.value = {
|
|
775
|
+
description,
|
|
776
|
+
fileInfo: fileName ? `${fileName}${lineInfo}` : ""
|
|
777
|
+
};
|
|
778
|
+
tooltipVisible.value = true;
|
|
779
|
+
const tooltipHeight = 50;
|
|
780
|
+
const tooltipWidth = 200;
|
|
781
|
+
let tooltipTop = rect.top - tooltipHeight - 8;
|
|
782
|
+
let tooltipLeft = rect.left;
|
|
783
|
+
if (tooltipTop < 10) tooltipTop = rect.bottom + 8;
|
|
784
|
+
if (tooltipLeft + tooltipWidth > window.innerWidth - 10) tooltipLeft = window.innerWidth - tooltipWidth - 10;
|
|
785
|
+
tooltipStyle.value = {
|
|
786
|
+
top: `${tooltipTop}px`,
|
|
787
|
+
left: `${tooltipLeft}px`
|
|
788
|
+
};
|
|
789
|
+
} else {
|
|
790
|
+
highlightVisible.value = false;
|
|
791
|
+
tooltipVisible.value = false;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
function setupInspectorHook() {
|
|
795
|
+
const inspector = window.__VUE_INSPECTOR__;
|
|
796
|
+
if (!inspector || inspector.__opencode_hooked) return;
|
|
797
|
+
const originalHandleClick = inspector.handleClick.bind(inspector);
|
|
798
|
+
inspector.handleClick = function(e) {
|
|
799
|
+
var _a, _b, _c;
|
|
800
|
+
if (options.selectMode.value) {
|
|
801
|
+
const { targetNode, params } = inspector.getTargetNode(e);
|
|
802
|
+
if (targetNode && params) {
|
|
803
|
+
const innerText = getDirectText(targetNode);
|
|
804
|
+
const description = getElementDescription(targetNode);
|
|
805
|
+
const elementInfo = {
|
|
806
|
+
filePath: (_a = params.file) != null ? _a : null,
|
|
807
|
+
line: (_b = params.line) != null ? _b : null,
|
|
808
|
+
column: (_c = params.column) != null ? _c : null,
|
|
809
|
+
innerText: truncate(innerText, 200),
|
|
810
|
+
description
|
|
811
|
+
};
|
|
812
|
+
options.onAddSelectedNode(elementInfo);
|
|
813
|
+
}
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
return originalHandleClick.call(inspector, e);
|
|
817
|
+
};
|
|
818
|
+
inspector.__opencode_hooked = true;
|
|
819
|
+
}
|
|
820
|
+
function handleKeydown(e) {
|
|
821
|
+
if (e.key === "Escape" && options.selectMode.value) {
|
|
822
|
+
e.preventDefault();
|
|
823
|
+
e.stopPropagation();
|
|
824
|
+
options.onExitSelectMode();
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
(0, vue.watch)(options.selectMode, (newVal) => {
|
|
828
|
+
const inspector = window.__VUE_INSPECTOR__;
|
|
829
|
+
if (newVal) {
|
|
830
|
+
if (inspector) inspector.enable();
|
|
831
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
832
|
+
document.addEventListener("keydown", handleKeydown, true);
|
|
833
|
+
} else {
|
|
834
|
+
if (inspector) inspector.disable();
|
|
835
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
836
|
+
document.removeEventListener("keydown", handleKeydown, true);
|
|
837
|
+
highlightVisible.value = false;
|
|
838
|
+
tooltipVisible.value = false;
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
(0, vue.onMounted)(() => {
|
|
842
|
+
if (window.__VUE_INSPECTOR__) setupInspectorHook();
|
|
843
|
+
else inspectorCheckTimer = window.setInterval(() => {
|
|
844
|
+
if (window.__VUE_INSPECTOR__) {
|
|
845
|
+
setupInspectorHook();
|
|
846
|
+
if (inspectorCheckTimer) {
|
|
847
|
+
window.clearInterval(inspectorCheckTimer);
|
|
848
|
+
inspectorCheckTimer = null;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}, INSPECTOR_CHECK_INTERVAL);
|
|
852
|
+
});
|
|
853
|
+
(0, vue.onUnmounted)(() => {
|
|
854
|
+
if (inspectorCheckTimer) window.clearInterval(inspectorCheckTimer);
|
|
855
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
856
|
+
document.removeEventListener("keydown", handleKeydown, true);
|
|
857
|
+
});
|
|
858
|
+
return {
|
|
859
|
+
highlightVisible,
|
|
860
|
+
highlightStyle,
|
|
861
|
+
tooltipVisible,
|
|
862
|
+
tooltipStyle,
|
|
863
|
+
tooltipContent
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
//#endregion
|
|
867
|
+
//#region es/open-code-widget/src/index.vue.js
|
|
868
|
+
var __defProp = Object.defineProperty;
|
|
869
|
+
var __defProps = Object.defineProperties;
|
|
870
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
871
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
872
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
873
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
874
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
875
|
+
enumerable: true,
|
|
876
|
+
configurable: true,
|
|
877
|
+
writable: true,
|
|
878
|
+
value
|
|
879
|
+
}) : obj[key] = value;
|
|
880
|
+
var __spreadValues = (a, b) => {
|
|
881
|
+
for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
882
|
+
if (__getOwnPropSymbols) {
|
|
883
|
+
for (var prop of __getOwnPropSymbols(b)) if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
884
|
+
}
|
|
885
|
+
return a;
|
|
886
|
+
};
|
|
887
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
888
|
+
var __vue_sfc__ = /* @__PURE__ */ (0, vue.defineComponent)(__spreadProps(__spreadValues({}, { name: "OpencodeWidget" }), {
|
|
889
|
+
__name: "index",
|
|
890
|
+
props: {
|
|
891
|
+
position: {
|
|
892
|
+
type: String,
|
|
893
|
+
required: false,
|
|
894
|
+
default: "bottom-right"
|
|
895
|
+
},
|
|
896
|
+
open: {
|
|
897
|
+
type: Boolean,
|
|
898
|
+
required: false,
|
|
899
|
+
default: false
|
|
900
|
+
},
|
|
901
|
+
theme: {
|
|
902
|
+
type: String,
|
|
903
|
+
required: false,
|
|
904
|
+
default: "light"
|
|
905
|
+
},
|
|
906
|
+
title: {
|
|
907
|
+
type: String,
|
|
908
|
+
required: false,
|
|
909
|
+
default: "AI 助手"
|
|
910
|
+
},
|
|
911
|
+
hotkeyLabel: {
|
|
912
|
+
type: String,
|
|
913
|
+
required: false,
|
|
914
|
+
default: "Ctrl+K"
|
|
915
|
+
},
|
|
916
|
+
selectShortcutLabel: {
|
|
917
|
+
type: String,
|
|
918
|
+
required: false,
|
|
919
|
+
default: "按 ESC 或 Ctrl+P 退出"
|
|
920
|
+
},
|
|
921
|
+
selectMode: {
|
|
922
|
+
type: Boolean,
|
|
923
|
+
required: false,
|
|
924
|
+
default: false
|
|
925
|
+
},
|
|
926
|
+
sessionListCollapsed: {
|
|
927
|
+
type: Boolean,
|
|
928
|
+
required: false,
|
|
929
|
+
default: true
|
|
930
|
+
},
|
|
931
|
+
loading: {
|
|
932
|
+
type: Boolean,
|
|
933
|
+
required: false,
|
|
934
|
+
default: false
|
|
935
|
+
},
|
|
936
|
+
loadingSessionList: {
|
|
937
|
+
type: Boolean,
|
|
938
|
+
required: false
|
|
939
|
+
},
|
|
940
|
+
showEmptyState: {
|
|
941
|
+
type: Boolean,
|
|
942
|
+
required: false,
|
|
943
|
+
default: false
|
|
944
|
+
},
|
|
945
|
+
iframeSrc: {
|
|
946
|
+
type: String,
|
|
947
|
+
required: false,
|
|
948
|
+
default: ""
|
|
949
|
+
},
|
|
950
|
+
sessions: {
|
|
951
|
+
type: Array,
|
|
952
|
+
required: false,
|
|
953
|
+
default: () => []
|
|
954
|
+
},
|
|
955
|
+
currentSessionId: {
|
|
956
|
+
type: [String, null],
|
|
957
|
+
required: false,
|
|
958
|
+
default: null
|
|
959
|
+
},
|
|
960
|
+
selectedElements: {
|
|
961
|
+
type: Array,
|
|
962
|
+
required: false,
|
|
963
|
+
default: () => []
|
|
964
|
+
},
|
|
965
|
+
showClearAll: {
|
|
966
|
+
type: Boolean,
|
|
967
|
+
required: false,
|
|
968
|
+
default: true
|
|
969
|
+
},
|
|
970
|
+
selectEnabled: {
|
|
971
|
+
type: Boolean,
|
|
972
|
+
required: false,
|
|
973
|
+
default: true
|
|
974
|
+
},
|
|
975
|
+
emptyStateText: {
|
|
976
|
+
type: String,
|
|
977
|
+
required: false,
|
|
978
|
+
default: "当前项目暂无会话"
|
|
979
|
+
},
|
|
980
|
+
emptyStateActionText: {
|
|
981
|
+
type: String,
|
|
982
|
+
required: false,
|
|
983
|
+
default: "立即创建"
|
|
984
|
+
}
|
|
985
|
+
},
|
|
986
|
+
emits: [
|
|
987
|
+
"update:open",
|
|
988
|
+
"update:selectMode",
|
|
989
|
+
"update:sessionListCollapsed",
|
|
990
|
+
"update:currentSessionId",
|
|
991
|
+
"update:selectedElements",
|
|
992
|
+
"toggle",
|
|
993
|
+
"close",
|
|
994
|
+
"toggle-session-list",
|
|
995
|
+
"toggle-select-mode",
|
|
996
|
+
"create-session",
|
|
997
|
+
"select-session",
|
|
998
|
+
"delete-session",
|
|
999
|
+
"click-selected-node",
|
|
1000
|
+
"remove-selected-node",
|
|
1001
|
+
"clear-selected-nodes",
|
|
1002
|
+
"empty-action"
|
|
1003
|
+
],
|
|
1004
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1005
|
+
const props = __props;
|
|
1006
|
+
const emit = __emit;
|
|
1007
|
+
const slots = (0, vue.useSlots)();
|
|
1008
|
+
const notificationMessage = (0, vue.ref)("");
|
|
1009
|
+
const notificationVisible = (0, vue.ref)(false);
|
|
1010
|
+
let notificationTimer = null;
|
|
1011
|
+
const showNotification = (message, duration = 3e3) => {
|
|
1012
|
+
notificationMessage.value = message;
|
|
1013
|
+
notificationVisible.value = true;
|
|
1014
|
+
if (notificationTimer) clearTimeout(notificationTimer);
|
|
1015
|
+
notificationTimer = setTimeout(() => {
|
|
1016
|
+
notificationVisible.value = false;
|
|
1017
|
+
}, duration);
|
|
1018
|
+
};
|
|
1019
|
+
const dialogVisible = (0, vue.ref)(false);
|
|
1020
|
+
const dialogMessage = (0, vue.ref)("");
|
|
1021
|
+
let dialogResolve = null;
|
|
1022
|
+
const showConfirmDialog = (message) => {
|
|
1023
|
+
dialogMessage.value = message;
|
|
1024
|
+
dialogVisible.value = true;
|
|
1025
|
+
return new Promise((resolve) => {
|
|
1026
|
+
dialogResolve = resolve;
|
|
1027
|
+
});
|
|
1028
|
+
};
|
|
1029
|
+
const handleDialogConfirm = () => {
|
|
1030
|
+
dialogVisible.value = false;
|
|
1031
|
+
if (dialogResolve) dialogResolve(true);
|
|
1032
|
+
};
|
|
1033
|
+
const handleDialogCancel = () => {
|
|
1034
|
+
dialogVisible.value = false;
|
|
1035
|
+
if (dialogResolve) dialogResolve(false);
|
|
1036
|
+
};
|
|
1037
|
+
__expose({
|
|
1038
|
+
showNotification,
|
|
1039
|
+
showConfirmDialog
|
|
1040
|
+
});
|
|
1041
|
+
const localSessionListCollapsed = (0, vue.ref)(props.sessionListCollapsed);
|
|
1042
|
+
(0, vue.watch)(() => props.sessionListCollapsed, (val) => {
|
|
1043
|
+
localSessionListCollapsed.value = val;
|
|
1044
|
+
});
|
|
1045
|
+
const { buttonActive, containerClasses, iframeSource, sessionListTitle, handleClose, handleEmptyAction, handleToggle, handleToggleSessionList } = useWidget({
|
|
1046
|
+
position: (0, vue.toRef)(props, "position"),
|
|
1047
|
+
theme: (0, vue.toRef)(props, "theme"),
|
|
1048
|
+
open: (0, vue.toRef)(props, "open"),
|
|
1049
|
+
selectMode: (0, vue.toRef)(props, "selectMode"),
|
|
1050
|
+
iframeSrc: (0, vue.toRef)(props, "iframeSrc"),
|
|
1051
|
+
sessionListCollapsed: localSessionListCollapsed,
|
|
1052
|
+
onToggle: (nextOpen) => {
|
|
1053
|
+
emit("update:open", nextOpen);
|
|
1054
|
+
emit("toggle", nextOpen);
|
|
1055
|
+
},
|
|
1056
|
+
onToggleSelectMode: (mode) => {
|
|
1057
|
+
emit("update:selectMode", mode);
|
|
1058
|
+
emit("toggle-select-mode", mode);
|
|
1059
|
+
},
|
|
1060
|
+
onClose: () => {
|
|
1061
|
+
emit("update:open", false);
|
|
1062
|
+
emit("close");
|
|
1063
|
+
},
|
|
1064
|
+
onToggleSessionList: (collapsed) => {
|
|
1065
|
+
localSessionListCollapsed.value = collapsed;
|
|
1066
|
+
emit("update:sessionListCollapsed", collapsed);
|
|
1067
|
+
emit("toggle-session-list", collapsed);
|
|
1068
|
+
},
|
|
1069
|
+
onEmptyAction: () => {
|
|
1070
|
+
emit("empty-action");
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
const { sessionItems, handleCreateSession, handleDeleteSession, handleSelectSession } = useSession({
|
|
1074
|
+
sessions: (0, vue.toRef)(props, "sessions"),
|
|
1075
|
+
currentSessionId: (0, vue.toRef)(props, "currentSessionId"),
|
|
1076
|
+
onCreateSession: () => emit("create-session"),
|
|
1077
|
+
onSelectSession: (session) => {
|
|
1078
|
+
emit("update:currentSessionId", session.id);
|
|
1079
|
+
emit("select-session", session);
|
|
1080
|
+
},
|
|
1081
|
+
onDeleteSession: (session) => emit("delete-session", session),
|
|
1082
|
+
showConfirmDialog
|
|
1083
|
+
});
|
|
1084
|
+
const { bubbleVisible, hasSelectedElements, selectedElementItems, handleClearSelectedNodes, handleClickSelectedNode, handleRemoveSelectedNode, handleToggleSelectMode } = useSelection({
|
|
1085
|
+
selectMode: (0, vue.toRef)(props, "selectMode"),
|
|
1086
|
+
selectedElements: (0, vue.toRef)(props, "selectedElements"),
|
|
1087
|
+
onToggleSelectMode: (mode) => {
|
|
1088
|
+
emit("update:selectMode", mode);
|
|
1089
|
+
emit("toggle-select-mode", mode);
|
|
1090
|
+
},
|
|
1091
|
+
onRemoveSelectedNode: (payload) => {
|
|
1092
|
+
emit("remove-selected-node", payload);
|
|
1093
|
+
const newElements = [...props.selectedElements];
|
|
1094
|
+
newElements.splice(payload.index, 1);
|
|
1095
|
+
emit("update:selectedElements", newElements);
|
|
1096
|
+
},
|
|
1097
|
+
onClearSelectedNodes: () => {
|
|
1098
|
+
emit("clear-selected-nodes");
|
|
1099
|
+
emit("update:selectedElements", []);
|
|
1100
|
+
},
|
|
1101
|
+
showConfirmDialog
|
|
1102
|
+
});
|
|
1103
|
+
const { highlightVisible, highlightStyle, tooltipVisible, tooltipStyle, tooltipContent } = useInspector({
|
|
1104
|
+
selectMode: (0, vue.toRef)(props, "selectMode"),
|
|
1105
|
+
onAddSelectedNode: (element) => {
|
|
1106
|
+
emit("click-selected-node", element);
|
|
1107
|
+
},
|
|
1108
|
+
onExitSelectMode: () => {
|
|
1109
|
+
emit("update:selectMode", false);
|
|
1110
|
+
emit("toggle-select-mode", false);
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
provideOpenCodeWidgetContext({
|
|
1114
|
+
theme: (0, vue.toRef)(props, "theme"),
|
|
1115
|
+
title: (0, vue.toRef)(props, "title"),
|
|
1116
|
+
hotkeyLabel: (0, vue.toRef)(props, "hotkeyLabel"),
|
|
1117
|
+
selectShortcutLabel: (0, vue.toRef)(props, "selectShortcutLabel"),
|
|
1118
|
+
selectMode: (0, vue.toRef)(props, "selectMode"),
|
|
1119
|
+
selectEnabled: (0, vue.toRef)(props, "selectEnabled"),
|
|
1120
|
+
sessionListCollapsed: localSessionListCollapsed,
|
|
1121
|
+
loading: (0, vue.toRef)(props, "loading"),
|
|
1122
|
+
loadingSessionList: (0, vue.toRef)(props, "loadingSessionList"),
|
|
1123
|
+
showEmptyState: (0, vue.toRef)(props, "showEmptyState"),
|
|
1124
|
+
emptyStateText: (0, vue.toRef)(props, "emptyStateText"),
|
|
1125
|
+
emptyStateActionText: (0, vue.toRef)(props, "emptyStateActionText"),
|
|
1126
|
+
showClearAll: (0, vue.toRef)(props, "showClearAll"),
|
|
1127
|
+
open: (0, vue.toRef)(props, "open"),
|
|
1128
|
+
iframeSource,
|
|
1129
|
+
buttonActive,
|
|
1130
|
+
sessionListTitle,
|
|
1131
|
+
bubbleVisible,
|
|
1132
|
+
hasSelectedElements,
|
|
1133
|
+
sessionItems,
|
|
1134
|
+
selectedElementItems,
|
|
1135
|
+
handleToggle,
|
|
1136
|
+
handleClose,
|
|
1137
|
+
handleToggleSessionList,
|
|
1138
|
+
handleEmptyAction,
|
|
1139
|
+
handleCreateSession,
|
|
1140
|
+
handleSelectSession,
|
|
1141
|
+
handleDeleteSession,
|
|
1142
|
+
handleToggleSelectMode,
|
|
1143
|
+
handleClickSelectedNode,
|
|
1144
|
+
handleRemoveSelectedNode: (payload) => handleRemoveSelectedNode(payload.item, payload.index, payload.source),
|
|
1145
|
+
handleClearSelectedNodes
|
|
1146
|
+
});
|
|
1147
|
+
const __returned__ = {
|
|
1148
|
+
props,
|
|
1149
|
+
emit,
|
|
1150
|
+
slots,
|
|
1151
|
+
notificationMessage,
|
|
1152
|
+
notificationVisible,
|
|
1153
|
+
get notificationTimer() {
|
|
1154
|
+
return notificationTimer;
|
|
1155
|
+
},
|
|
1156
|
+
set notificationTimer(v) {
|
|
1157
|
+
notificationTimer = v;
|
|
1158
|
+
},
|
|
1159
|
+
showNotification,
|
|
1160
|
+
dialogVisible,
|
|
1161
|
+
dialogMessage,
|
|
1162
|
+
get dialogResolve() {
|
|
1163
|
+
return dialogResolve;
|
|
1164
|
+
},
|
|
1165
|
+
set dialogResolve(v) {
|
|
1166
|
+
dialogResolve = v;
|
|
1167
|
+
},
|
|
1168
|
+
showConfirmDialog,
|
|
1169
|
+
handleDialogConfirm,
|
|
1170
|
+
handleDialogCancel,
|
|
1171
|
+
localSessionListCollapsed,
|
|
1172
|
+
buttonActive,
|
|
1173
|
+
containerClasses,
|
|
1174
|
+
iframeSource,
|
|
1175
|
+
sessionListTitle,
|
|
1176
|
+
handleClose,
|
|
1177
|
+
handleEmptyAction,
|
|
1178
|
+
handleToggle,
|
|
1179
|
+
handleToggleSessionList,
|
|
1180
|
+
sessionItems,
|
|
1181
|
+
handleCreateSession,
|
|
1182
|
+
handleDeleteSession,
|
|
1183
|
+
handleSelectSession,
|
|
1184
|
+
bubbleVisible,
|
|
1185
|
+
hasSelectedElements,
|
|
1186
|
+
selectedElementItems,
|
|
1187
|
+
handleClearSelectedNodes,
|
|
1188
|
+
handleClickSelectedNode,
|
|
1189
|
+
handleRemoveSelectedNode,
|
|
1190
|
+
handleToggleSelectMode,
|
|
1191
|
+
highlightVisible,
|
|
1192
|
+
highlightStyle,
|
|
1193
|
+
tooltipVisible,
|
|
1194
|
+
tooltipStyle,
|
|
1195
|
+
tooltipContent,
|
|
1196
|
+
Frame: Frame_vue_default,
|
|
1197
|
+
Header: Header_vue_default,
|
|
1198
|
+
SelectHint: SelectHint_vue_default,
|
|
1199
|
+
SelectedBubbles: SelectedBubbles_vue_default,
|
|
1200
|
+
SelectedNodes: SelectedNodes_vue_default,
|
|
1201
|
+
SessionList: SessionList_vue_default,
|
|
1202
|
+
Trigger: Trigger_vue_default
|
|
1203
|
+
};
|
|
1204
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
1205
|
+
enumerable: false,
|
|
1206
|
+
value: true
|
|
1207
|
+
});
|
|
1208
|
+
return __returned__;
|
|
1209
|
+
}
|
|
1210
|
+
}));
|
|
1211
|
+
var _hoisted_1 = {
|
|
1212
|
+
key: 0,
|
|
1213
|
+
class: "opencode-notification",
|
|
1214
|
+
role: "alert"
|
|
1215
|
+
};
|
|
1216
|
+
var _hoisted_2 = { class: "opencode-chat-content" };
|
|
1217
|
+
var _hoisted_3 = { class: "opencode-tooltip-tag" };
|
|
1218
|
+
var _hoisted_4 = { class: "opencode-tooltip-file" };
|
|
1219
|
+
var _hoisted_5 = {
|
|
1220
|
+
key: 1,
|
|
1221
|
+
class: "opencode-dialog-overlay"
|
|
1222
|
+
};
|
|
1223
|
+
var _hoisted_6 = {
|
|
1224
|
+
class: "opencode-dialog",
|
|
1225
|
+
role: "alertdialog",
|
|
1226
|
+
"aria-modal": "true"
|
|
1227
|
+
};
|
|
1228
|
+
var _hoisted_7 = { class: "opencode-dialog-content" };
|
|
1229
|
+
var _hoisted_8 = { class: "opencode-dialog-message" };
|
|
1230
|
+
function __vue_render__(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1231
|
+
return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", { class: (0, vue.normalizeClass)($setup.containerClasses) }, [
|
|
1232
|
+
(0, vue.createVNode)($setup["Trigger"], null, (0, vue.createSlots)({ _: 2 }, [$setup.slots["button-icon"] ? {
|
|
1233
|
+
name: "default",
|
|
1234
|
+
fn: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "button-icon")]),
|
|
1235
|
+
key: "0"
|
|
1236
|
+
} : void 0]), 1024),
|
|
1237
|
+
$setup.bubbleVisible ? ((0, vue.openBlock)(), (0, vue.createBlock)($setup["SelectedBubbles"], { key: 0 })) : (0, vue.createCommentVNode)("v-if", true),
|
|
1238
|
+
(0, vue.withDirectives)((0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)(["opencode-chat", { open: $props.open }]) }, [
|
|
1239
|
+
(0, vue.createVNode)($setup["Header"], null, (0, vue.createSlots)({ _: 2 }, [
|
|
1240
|
+
$setup.slots["session-toggle-icon"] ? {
|
|
1241
|
+
name: "session-toggle-icon",
|
|
1242
|
+
fn: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "session-toggle-icon")]),
|
|
1243
|
+
key: "0"
|
|
1244
|
+
} : void 0,
|
|
1245
|
+
$setup.slots["select-icon"] ? {
|
|
1246
|
+
name: "select-icon",
|
|
1247
|
+
fn: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "select-icon")]),
|
|
1248
|
+
key: "1"
|
|
1249
|
+
} : void 0,
|
|
1250
|
+
$setup.slots["close-icon"] ? {
|
|
1251
|
+
name: "close-icon",
|
|
1252
|
+
fn: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "close-icon")]),
|
|
1253
|
+
key: "2"
|
|
1254
|
+
} : void 0
|
|
1255
|
+
]), 1024),
|
|
1256
|
+
(0, vue.createCommentVNode)(" Notification "),
|
|
1257
|
+
$setup.notificationVisible ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_1, (0, vue.toDisplayString)($setup.notificationMessage), 1)) : (0, vue.createCommentVNode)("v-if", true),
|
|
1258
|
+
(0, vue.createElementVNode)("div", _hoisted_2, [
|
|
1259
|
+
(0, vue.createVNode)($setup["SessionList"], null, {
|
|
1260
|
+
empty: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "sessions-empty", {}, () => [_cache[0] || (_cache[0] = (0, vue.createElementVNode)("div", { class: "opencode-session-empty" }, "暂无会话", -1))])]),
|
|
1261
|
+
_: 3
|
|
1262
|
+
}),
|
|
1263
|
+
(0, vue.createVNode)($setup["Frame"], null, (0, vue.createSlots)({ _: 2 }, [
|
|
1264
|
+
$setup.slots["empty-state"] ? {
|
|
1265
|
+
name: "empty-state",
|
|
1266
|
+
fn: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "empty-state")]),
|
|
1267
|
+
key: "0"
|
|
1268
|
+
} : void 0,
|
|
1269
|
+
$setup.slots.loading ? {
|
|
1270
|
+
name: "loading",
|
|
1271
|
+
fn: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "loading")]),
|
|
1272
|
+
key: "1"
|
|
1273
|
+
} : void 0,
|
|
1274
|
+
$setup.slots.content ? {
|
|
1275
|
+
name: "content",
|
|
1276
|
+
fn: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "content")]),
|
|
1277
|
+
key: "2"
|
|
1278
|
+
} : void 0
|
|
1279
|
+
]), 1024),
|
|
1280
|
+
(0, vue.createVNode)($setup["SelectedNodes"])
|
|
1281
|
+
])
|
|
1282
|
+
], 2), [[vue.vShow, !$props.selectMode]]),
|
|
1283
|
+
(0, vue.createVNode)($setup["SelectHint"]),
|
|
1284
|
+
(0, vue.createCommentVNode)(" Inspector Highlight "),
|
|
1285
|
+
(0, vue.withDirectives)((0, vue.createElementVNode)("div", {
|
|
1286
|
+
class: "opencode-element-highlight",
|
|
1287
|
+
style: (0, vue.normalizeStyle)(__spreadValues({ display: $setup.highlightVisible ? "block" : "none" }, $setup.highlightStyle))
|
|
1288
|
+
}, null, 4), [[vue.vShow, $setup.highlightVisible]]),
|
|
1289
|
+
(0, vue.createCommentVNode)(" Inspector Tooltip "),
|
|
1290
|
+
(0, vue.withDirectives)((0, vue.createElementVNode)("div", {
|
|
1291
|
+
class: "opencode-element-tooltip",
|
|
1292
|
+
style: (0, vue.normalizeStyle)(__spreadValues({ display: $setup.tooltipVisible ? "block" : "none" }, $setup.tooltipStyle))
|
|
1293
|
+
}, [(0, vue.createElementVNode)("div", _hoisted_3, (0, vue.toDisplayString)($setup.tooltipContent.description), 1), (0, vue.createElementVNode)("div", _hoisted_4, (0, vue.toDisplayString)($setup.tooltipContent.fileInfo), 1)], 4), [[vue.vShow, $setup.tooltipVisible]]),
|
|
1294
|
+
(0, vue.createCommentVNode)(" Dialog "),
|
|
1295
|
+
$setup.dialogVisible ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", _hoisted_5, [(0, vue.createElementVNode)("div", _hoisted_6, [(0, vue.createElementVNode)("div", _hoisted_7, [(0, vue.createElementVNode)("div", _hoisted_8, (0, vue.toDisplayString)($setup.dialogMessage), 1)]), (0, vue.createElementVNode)("div", { class: "opencode-dialog-actions" }, [(0, vue.createElementVNode)("button", {
|
|
1296
|
+
class: "opencode-dialog-btn cancel",
|
|
1297
|
+
onClick: $setup.handleDialogCancel
|
|
1298
|
+
}, "取消"), (0, vue.createElementVNode)("button", {
|
|
1299
|
+
class: "opencode-dialog-btn confirm",
|
|
1300
|
+
onClick: $setup.handleDialogConfirm
|
|
1301
|
+
}, "确认")])])])) : (0, vue.createCommentVNode)("v-if", true)
|
|
1302
|
+
], 2);
|
|
1303
|
+
}
|
|
1304
|
+
__vue_sfc__.render = __vue_render__;
|
|
1305
|
+
//#endregion
|
|
1306
|
+
//#region es/open-code-widget/index.js
|
|
1307
|
+
var open_code_widget_default = __vue_sfc__;
|
|
1308
|
+
//#endregion
|
|
1309
|
+
//#region es/index.js
|
|
1310
|
+
var version = "1.0.5";
|
|
1311
|
+
function install(app, options) {
|
|
1312
|
+
[open_code_widget_default].forEach((item) => {
|
|
1313
|
+
if (item.install) app.use(item, options);
|
|
1314
|
+
else if (item.name) app.component(item.name, item);
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
var es_default = install;
|
|
1318
|
+
//#endregion
|
|
1319
|
+
exports.OpenCodeWidget = open_code_widget_default;
|
|
1320
|
+
exports.default = es_default;
|
|
1321
|
+
exports.install = install;
|
|
1322
|
+
exports.version = version;
|