@vite-plugin-opencode-assistant/components 1.0.23 → 1.0.24
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/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/open-code-widget/composables/use-widget.d.ts +0 -1
- package/es/open-code-widget/composables/use-widget.js +0 -1
- package/es/open-code-widget/src/components/FloatingBubble/FloatingBubble-sfc.css +1 -0
- package/es/open-code-widget/src/components/FloatingBubble/FloatingBubble.vue.d.ts +44 -0
- package/es/open-code-widget/src/components/FloatingBubble/FloatingBubble.vue.js +290 -0
- package/es/open-code-widget/src/components/FloatingBubble/index.d.ts +3 -0
- package/es/open-code-widget/src/components/FloatingBubble/index.js +5 -0
- package/es/open-code-widget/src/components/FloatingBubble/types.d.ts +24 -0
- package/es/open-code-widget/src/components/FloatingBubble/types.js +0 -0
- package/es/open-code-widget/src/components/Trigger-sfc.css +1 -1
- package/es/open-code-widget/src/components/Trigger.vue.d.ts +21 -3
- package/es/open-code-widget/src/components/Trigger.vue.js +127 -48
- package/es/open-code-widget/src/index-sfc.css +1 -1
- package/es/open-code-widget/src/index.vue.d.ts +10 -11
- package/es/open-code-widget/src/index.vue.js +82 -17
- package/es/open-code-widget/src/types.d.ts +1 -2
- package/lib/@vite-plugin-opencode-assistant/components.cjs.js +543 -99
- package/lib/@vite-plugin-opencode-assistant/components.es.js +540 -96
- package/lib/components.css +3 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/open-code-widget/composables/use-widget.d.ts +0 -1
- package/lib/open-code-widget/composables/use-widget.js +0 -1
- package/lib/open-code-widget/src/components/FloatingBubble/FloatingBubble-sfc.css +1 -0
- package/lib/open-code-widget/src/components/FloatingBubble/FloatingBubble.vue.d.ts +44 -0
- package/lib/open-code-widget/src/components/FloatingBubble/FloatingBubble.vue.js +307 -0
- package/lib/open-code-widget/src/components/FloatingBubble/index.d.ts +3 -0
- package/lib/open-code-widget/src/components/FloatingBubble/index.js +35 -0
- package/lib/open-code-widget/src/components/FloatingBubble/types.d.ts +24 -0
- package/lib/open-code-widget/src/components/FloatingBubble/types.js +15 -0
- package/lib/open-code-widget/src/components/Trigger-sfc.css +1 -1
- package/lib/open-code-widget/src/components/Trigger.vue.d.ts +21 -3
- package/lib/open-code-widget/src/components/Trigger.vue.js +137 -48
- package/lib/open-code-widget/src/index-sfc.css +1 -1
- package/lib/open-code-widget/src/index.vue.d.ts +10 -11
- package/lib/open-code-widget/src/index.vue.js +80 -15
- package/lib/open-code-widget/src/types.d.ts +1 -2
- package/lib/web-types.json +1 -1
- package/package.json +2 -2
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OpenCodeWidget from './open-code-widget';
|
|
2
2
|
import type { App } from 'vue';
|
|
3
|
-
declare const version = "1.0.
|
|
3
|
+
declare const version = "1.0.24";
|
|
4
4
|
declare function install(app: App<any>, options?: any): void;
|
|
5
5
|
export { install, version, OpenCodeWidget };
|
|
6
6
|
export default install;
|
package/es/index.js
CHANGED
|
@@ -30,7 +30,6 @@ function useWidget(options) {
|
|
|
30
30
|
});
|
|
31
31
|
const containerClasses = computed(() => [
|
|
32
32
|
"opencode-widget",
|
|
33
|
-
options.position.value,
|
|
34
33
|
`opencode-theme-${resolvedTheme.value}`
|
|
35
34
|
]);
|
|
36
35
|
const buttonActive = computed(() => !!(options.open.value || options.selectMode.value));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.floating-bubble{position:fixed;top:0;left:0;z-index:999999;cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none;touch-action:none;visibility:hidden;will-change:transform}.floating-bubble[style*=translate3d]{visibility:visible}.floating-bubble:active{cursor:grabbing}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { FloatingBubbleAxis, FloatingBubbleMagnetic, FloatingBubbleOffset, FloatingBubbleGap } from "./types";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
offset?: FloatingBubbleOffset;
|
|
4
|
+
axis?: FloatingBubbleAxis;
|
|
5
|
+
magnetic?: FloatingBubbleMagnetic;
|
|
6
|
+
gap?: number | FloatingBubbleGap;
|
|
7
|
+
teleport?: string | Element;
|
|
8
|
+
};
|
|
9
|
+
declare var __VLS_5: {};
|
|
10
|
+
type __VLS_Slots = {} & {
|
|
11
|
+
default?: (props: typeof __VLS_5) => any;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
|
|
14
|
+
isOnRightSide: import("vue").ComputedRef<boolean>;
|
|
15
|
+
offset: import("vue").ComputedRef<{
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}>;
|
|
19
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
20
|
+
click: (event: MouseEvent) => any;
|
|
21
|
+
"update:offset": (value: FloatingBubbleOffset) => any;
|
|
22
|
+
"offset-change": (offset: FloatingBubbleOffset) => any;
|
|
23
|
+
"drag-start": () => any;
|
|
24
|
+
"drag-end": () => any;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
26
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
27
|
+
"onUpdate:offset"?: ((value: FloatingBubbleOffset) => any) | undefined;
|
|
28
|
+
"onOffset-change"?: ((offset: FloatingBubbleOffset) => any) | undefined;
|
|
29
|
+
"onDrag-start"?: (() => any) | undefined;
|
|
30
|
+
"onDrag-end"?: (() => any) | undefined;
|
|
31
|
+
}>, {
|
|
32
|
+
offset: FloatingBubbleOffset;
|
|
33
|
+
axis: FloatingBubbleAxis;
|
|
34
|
+
magnetic: FloatingBubbleMagnetic;
|
|
35
|
+
gap: number | FloatingBubbleGap;
|
|
36
|
+
teleport: string | Element;
|
|
37
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
38
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
39
|
+
export default _default;
|
|
40
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
41
|
+
new (): {
|
|
42
|
+
$slots: S;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import "./FloatingBubble-sfc.css";
|
|
21
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
22
|
+
import { ref, computed, watch, onMounted, onUnmounted, nextTick } from "vue";
|
|
23
|
+
const __vue_sfc__ = /* @__PURE__ */ _defineComponent(__spreadProps(__spreadValues({}, {
|
|
24
|
+
name: "FloatingBubble"
|
|
25
|
+
}), {
|
|
26
|
+
__name: "FloatingBubble",
|
|
27
|
+
props: {
|
|
28
|
+
offset: { type: Object, required: false, default: void 0 },
|
|
29
|
+
axis: { type: String, required: false, default: "xy" },
|
|
30
|
+
magnetic: { type: String, required: false, default: void 0 },
|
|
31
|
+
gap: { type: [Number, Object], required: false, default: 24 },
|
|
32
|
+
teleport: { type: null, required: false, default: "body" }
|
|
33
|
+
},
|
|
34
|
+
emits: ["update:offset", "click", "offset-change", "drag-start", "drag-end"],
|
|
35
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
36
|
+
const props = __props;
|
|
37
|
+
const emit = __emit;
|
|
38
|
+
const rootRef = ref(null);
|
|
39
|
+
const state = ref({
|
|
40
|
+
x: 0,
|
|
41
|
+
y: 0,
|
|
42
|
+
width: 0,
|
|
43
|
+
height: 0
|
|
44
|
+
});
|
|
45
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
46
|
+
const gapX = computed(
|
|
47
|
+
() => isObject(props.gap) ? props.gap.x : props.gap
|
|
48
|
+
);
|
|
49
|
+
const gapY = computed(
|
|
50
|
+
() => isObject(props.gap) ? props.gap.y : props.gap
|
|
51
|
+
);
|
|
52
|
+
const windowWidth = ref(typeof window !== "undefined" ? window.innerWidth : 0);
|
|
53
|
+
const windowHeight = ref(typeof window !== "undefined" ? window.innerHeight : 0);
|
|
54
|
+
const boundary = computed(() => ({
|
|
55
|
+
top: gapY.value,
|
|
56
|
+
right: windowWidth.value - state.value.width - gapX.value,
|
|
57
|
+
bottom: windowHeight.value - state.value.height - gapY.value,
|
|
58
|
+
left: gapX.value
|
|
59
|
+
}));
|
|
60
|
+
const dragging = ref(false);
|
|
61
|
+
const initialized = ref(false);
|
|
62
|
+
const rootStyle = computed(() => {
|
|
63
|
+
const style = {};
|
|
64
|
+
const x = `${state.value.x}px`;
|
|
65
|
+
const y = `${state.value.y}px`;
|
|
66
|
+
style.transform = `translate3d(${x}, ${y}, 0)`;
|
|
67
|
+
if (dragging.value || !initialized.value) {
|
|
68
|
+
style.transition = "none";
|
|
69
|
+
} else {
|
|
70
|
+
style.transition = "transform 0.3s ease";
|
|
71
|
+
}
|
|
72
|
+
return style;
|
|
73
|
+
});
|
|
74
|
+
const show = ref(true);
|
|
75
|
+
const updateState = () => {
|
|
76
|
+
if (!show.value || !rootRef.value || typeof window === "undefined") return;
|
|
77
|
+
const rect = rootRef.value.getBoundingClientRect();
|
|
78
|
+
const { offset } = props;
|
|
79
|
+
let x = offset ? offset.x : windowWidth.value - rect.width - gapX.value;
|
|
80
|
+
let y = offset ? offset.y : windowHeight.value - rect.height - gapY.value;
|
|
81
|
+
const maxX = windowWidth.value - rect.width - gapX.value;
|
|
82
|
+
const maxY = windowHeight.value - rect.height - gapY.value;
|
|
83
|
+
if (x < gapX.value) x = gapX.value;
|
|
84
|
+
if (x > maxX) x = maxX;
|
|
85
|
+
if (y < gapY.value) y = gapY.value;
|
|
86
|
+
if (y > maxY) y = maxY;
|
|
87
|
+
state.value = {
|
|
88
|
+
x,
|
|
89
|
+
y,
|
|
90
|
+
width: rect.width,
|
|
91
|
+
height: rect.height
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
const touch = {
|
|
95
|
+
startX: ref(0),
|
|
96
|
+
startY: ref(0),
|
|
97
|
+
deltaX: ref(0),
|
|
98
|
+
deltaY: ref(0),
|
|
99
|
+
offsetX: ref(0),
|
|
100
|
+
offsetY: ref(0),
|
|
101
|
+
isTap: ref(true),
|
|
102
|
+
start(e) {
|
|
103
|
+
this.startX.value = "touches" in e ? e.touches[0].clientX : e.clientX;
|
|
104
|
+
this.startY.value = "touches" in e ? e.touches[0].clientY : e.clientY;
|
|
105
|
+
this.deltaX.value = 0;
|
|
106
|
+
this.deltaY.value = 0;
|
|
107
|
+
this.offsetX.value = 0;
|
|
108
|
+
this.offsetY.value = 0;
|
|
109
|
+
this.isTap.value = true;
|
|
110
|
+
},
|
|
111
|
+
move(e) {
|
|
112
|
+
const clientX = "touches" in e ? e.touches[0].clientX : e.clientX;
|
|
113
|
+
const clientY = "touches" in e ? e.touches[0].clientY : e.clientY;
|
|
114
|
+
this.deltaX.value = clientX - this.startX.value;
|
|
115
|
+
this.deltaY.value = clientY - this.startY.value;
|
|
116
|
+
this.offsetX.value = Math.abs(this.deltaX.value);
|
|
117
|
+
this.offsetY.value = Math.abs(this.deltaY.value);
|
|
118
|
+
const TAP_OFFSET = 5;
|
|
119
|
+
if (this.isTap.value && (this.offsetX.value > TAP_OFFSET || this.offsetY.value > TAP_OFFSET)) {
|
|
120
|
+
this.isTap.value = false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
let prevX = 0;
|
|
125
|
+
let prevY = 0;
|
|
126
|
+
const onTouchStart = (e) => {
|
|
127
|
+
touch.start(e);
|
|
128
|
+
dragging.value = true;
|
|
129
|
+
prevX = state.value.x;
|
|
130
|
+
prevY = state.value.y;
|
|
131
|
+
if (!("touches" in e)) {
|
|
132
|
+
window.addEventListener("mousemove", onTouchMove, { passive: false });
|
|
133
|
+
window.addEventListener("mouseup", onTouchEnd);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const onTouchMove = (e) => {
|
|
137
|
+
if (e.cancelable) {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
}
|
|
140
|
+
const wasTap = touch.isTap.value;
|
|
141
|
+
touch.move(e);
|
|
142
|
+
if (wasTap && !touch.isTap.value) {
|
|
143
|
+
emit("drag-start");
|
|
144
|
+
}
|
|
145
|
+
if (props.axis === "lock") return;
|
|
146
|
+
if (!touch.isTap.value) {
|
|
147
|
+
if (props.axis === "x" || props.axis === "xy") {
|
|
148
|
+
let nextX = prevX + touch.deltaX.value;
|
|
149
|
+
if (nextX < boundary.value.left) nextX = boundary.value.left;
|
|
150
|
+
if (nextX > boundary.value.right) nextX = boundary.value.right;
|
|
151
|
+
state.value.x = nextX;
|
|
152
|
+
}
|
|
153
|
+
if (props.axis === "y" || props.axis === "xy") {
|
|
154
|
+
let nextY = prevY + touch.deltaY.value;
|
|
155
|
+
if (nextY < boundary.value.top) nextY = boundary.value.top;
|
|
156
|
+
if (nextY > boundary.value.bottom) nextY = boundary.value.bottom;
|
|
157
|
+
state.value.y = nextY;
|
|
158
|
+
}
|
|
159
|
+
const offset = { x: state.value.x, y: state.value.y };
|
|
160
|
+
emit("update:offset", offset);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const closest = (arr, target) => {
|
|
164
|
+
return arr.reduce(
|
|
165
|
+
(pre, cur) => Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
const onTouchEnd = (e) => {
|
|
169
|
+
dragging.value = false;
|
|
170
|
+
if (e && !("touches" in e) && e.type === "mouseup") {
|
|
171
|
+
window.removeEventListener("mousemove", onTouchMove);
|
|
172
|
+
window.removeEventListener("mouseup", onTouchEnd);
|
|
173
|
+
}
|
|
174
|
+
requestAnimationFrame(() => {
|
|
175
|
+
if (props.magnetic === "x") {
|
|
176
|
+
const nextX = closest(
|
|
177
|
+
[boundary.value.left, boundary.value.right],
|
|
178
|
+
state.value.x
|
|
179
|
+
);
|
|
180
|
+
state.value.x = nextX;
|
|
181
|
+
}
|
|
182
|
+
if (props.magnetic === "y") {
|
|
183
|
+
const nextY = closest(
|
|
184
|
+
[boundary.value.top, boundary.value.bottom],
|
|
185
|
+
state.value.y
|
|
186
|
+
);
|
|
187
|
+
state.value.y = nextY;
|
|
188
|
+
}
|
|
189
|
+
if (!touch.isTap.value) {
|
|
190
|
+
emit("drag-end");
|
|
191
|
+
const offset = { x: state.value.x, y: state.value.y };
|
|
192
|
+
emit("update:offset", offset);
|
|
193
|
+
if (prevX !== offset.x || prevY !== offset.y) {
|
|
194
|
+
emit("offset-change", offset);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
const onClick = (e) => {
|
|
200
|
+
if (touch.isTap.value) {
|
|
201
|
+
emit("click", e);
|
|
202
|
+
} else {
|
|
203
|
+
e.stopPropagation();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const handleResize = () => {
|
|
207
|
+
if (typeof window !== "undefined") {
|
|
208
|
+
windowWidth.value = window.innerWidth;
|
|
209
|
+
windowHeight.value = window.innerHeight;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
onMounted(() => {
|
|
213
|
+
updateState();
|
|
214
|
+
nextTick(() => {
|
|
215
|
+
initialized.value = true;
|
|
216
|
+
});
|
|
217
|
+
if (typeof window !== "undefined") {
|
|
218
|
+
window.addEventListener("resize", handleResize);
|
|
219
|
+
}
|
|
220
|
+
if (rootRef.value) {
|
|
221
|
+
rootRef.value.addEventListener("touchmove", onTouchMove, {
|
|
222
|
+
passive: false
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
onUnmounted(() => {
|
|
227
|
+
if (typeof window !== "undefined") {
|
|
228
|
+
window.removeEventListener("resize", handleResize);
|
|
229
|
+
window.removeEventListener("mousemove", onTouchMove);
|
|
230
|
+
window.removeEventListener("mouseup", onTouchEnd);
|
|
231
|
+
}
|
|
232
|
+
if (rootRef.value) {
|
|
233
|
+
rootRef.value.removeEventListener("touchmove", onTouchMove);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
watch(
|
|
237
|
+
[windowWidth, windowHeight, gapX, gapY, () => props.offset],
|
|
238
|
+
updateState,
|
|
239
|
+
{ deep: true }
|
|
240
|
+
);
|
|
241
|
+
const isOnRightSide = computed(() => {
|
|
242
|
+
return state.value.x > windowWidth.value / 2;
|
|
243
|
+
});
|
|
244
|
+
__expose({
|
|
245
|
+
isOnRightSide,
|
|
246
|
+
offset: computed(() => ({ x: state.value.x, y: state.value.y }))
|
|
247
|
+
});
|
|
248
|
+
const __returned__ = { props, emit, rootRef, state, isObject, gapX, gapY, windowWidth, windowHeight, boundary, dragging, initialized, rootStyle, show, updateState, touch, get prevX() {
|
|
249
|
+
return prevX;
|
|
250
|
+
}, set prevX(v) {
|
|
251
|
+
prevX = v;
|
|
252
|
+
}, get prevY() {
|
|
253
|
+
return prevY;
|
|
254
|
+
}, set prevY(v) {
|
|
255
|
+
prevY = v;
|
|
256
|
+
}, onTouchStart, onTouchMove, closest, onTouchEnd, onClick, handleResize, isOnRightSide };
|
|
257
|
+
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
258
|
+
return __returned__;
|
|
259
|
+
}
|
|
260
|
+
}));
|
|
261
|
+
import { renderSlot as _renderSlot, vShow as _vShow, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, withDirectives as _withDirectives, Teleport as _Teleport, openBlock as _openBlock, createBlock as _createBlock } from "vue";
|
|
262
|
+
function __vue_render__(_ctx, _cache, $props, $setup, $data, $options) {
|
|
263
|
+
return _openBlock(), _createBlock(_Teleport, { to: $props.teleport }, [
|
|
264
|
+
_withDirectives(_createElementVNode(
|
|
265
|
+
"div",
|
|
266
|
+
{
|
|
267
|
+
ref: "rootRef",
|
|
268
|
+
class: "floating-bubble",
|
|
269
|
+
style: _normalizeStyle($setup.rootStyle),
|
|
270
|
+
onTouchstartPassive: $setup.onTouchStart,
|
|
271
|
+
onTouchend: $setup.onTouchEnd,
|
|
272
|
+
onTouchcancel: $setup.onTouchEnd,
|
|
273
|
+
onMousedown: $setup.onTouchStart,
|
|
274
|
+
onClickCapture: $setup.onClick
|
|
275
|
+
},
|
|
276
|
+
[
|
|
277
|
+
_renderSlot(_ctx.$slots, "default")
|
|
278
|
+
],
|
|
279
|
+
36
|
|
280
|
+
/* STYLE, NEED_HYDRATION */
|
|
281
|
+
), [
|
|
282
|
+
[_vShow, $setup.show]
|
|
283
|
+
])
|
|
284
|
+
], 8, ["to"]);
|
|
285
|
+
}
|
|
286
|
+
__vue_sfc__.render = __vue_render__;
|
|
287
|
+
var FloatingBubble_vue_default = __vue_sfc__;
|
|
288
|
+
export {
|
|
289
|
+
FloatingBubble_vue_default as default
|
|
290
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type FloatingBubbleAxis = "x" | "y" | "xy" | "lock";
|
|
2
|
+
export type FloatingBubbleMagnetic = "x" | "y";
|
|
3
|
+
export interface FloatingBubbleOffset {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
export interface FloatingBubbleGap {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}
|
|
11
|
+
export interface FloatingBubbleProps {
|
|
12
|
+
offset?: FloatingBubbleOffset;
|
|
13
|
+
axis?: FloatingBubbleAxis;
|
|
14
|
+
magnetic?: FloatingBubbleMagnetic;
|
|
15
|
+
gap?: number | FloatingBubbleGap;
|
|
16
|
+
teleport?: string | Element;
|
|
17
|
+
}
|
|
18
|
+
export type FloatingBubbleEmits = {
|
|
19
|
+
(e: "update:offset", value: FloatingBubbleOffset): void;
|
|
20
|
+
(e: "click", event: MouseEvent): void;
|
|
21
|
+
(e: "offset-change", offset: FloatingBubbleOffset): void;
|
|
22
|
+
(e: "drag-start"): void;
|
|
23
|
+
(e: "drag-end"): void;
|
|
24
|
+
};
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.opencode-button{width:
|
|
1
|
+
.opencode-button{width:42px;height:42px;border-radius:50%;background:#fff;border:none;cursor:pointer;box-shadow:0 4px 12px rgba(102,126,234,.4);transition:all .3s ease;display:flex;align-items:center;justify-content:center;padding:0;position:relative}.opencode-button svg{transform:rotate(180deg) scale(1.1);transition:transform .3s ease;width:100%;height:100%;display:block}.opencode-button:hover svg{transform:rotate(180deg) scale(1.1)}.opencode-button:hover{transform:scale(1.1);box-shadow:0 6px 16px rgba(102,126,234,.5)}.opencode-button.thinking{background:linear-gradient(135deg,#667eea,#764ba2);animation:thinking-glow 1.5s ease-in-out infinite,thinking-pulse 1.5s ease-in-out infinite;box-shadow:0 0 20px rgba(102,126,234,.6),0 0 40px rgba(118,75,162,.4),0 0 60px rgba(102,126,234,.2)}.opencode-button.thinking svg path{fill:#fff}.opencode-button.thinking:before{content:"";position:absolute;top:-2px;right:-2px;bottom:-2px;left:-2px;border-radius:50%;background:linear-gradient(135deg,#8b9cf5,#9d6bc7);z-index:-1}.opencode-button.thinking:after{content:"";position:absolute;top:-3px;right:-3px;bottom:-3px;left:-3px;border-radius:50%;background:conic-gradient(from 180deg,transparent,rgba(102,126,234,.3),transparent,rgba(118,75,162,.3),transparent);z-index:-2;animation:thinking-rotate 2s linear infinite reverse;filter:blur(8px)}@keyframes thinking-glow{0%,to{box-shadow:0 0 20px rgba(102,126,234,.6),0 0 40px rgba(118,75,162,.4),0 0 60px rgba(102,126,234,.2)}50%{box-shadow:0 0 30px rgba(102,126,234,.8),0 0 60px rgba(118,75,162,.6),0 0 90px rgba(102,126,234,.3)}}@keyframes thinking-rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes thinking-pulse{0%,to{transform:scale(1)}50%{transform:scale(.95)}}.opencode-button.opencode-theme-dark{background:linear-gradient(135deg,#667eea,#764ba2);box-shadow:0 4px 12px rgba(102,126,234,.3)}.opencode-button.opencode-theme-dark:before{content:"";position:absolute;top:-2px;right:-2px;bottom:-2px;left:-2px;border-radius:50%;background:linear-gradient(135deg,#8b9cf5,#9d6bc7);z-index:-1}.opencode-button.opencode-theme-dark:hover{box-shadow:0 6px 16px rgba(102,126,234,.4)}.opencode-button.opencode-theme-dark svg path{fill:#fff}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
import type { FloatingBubbleOffset } from "./FloatingBubble/types";
|
|
2
|
+
declare var __VLS_13: {};
|
|
2
3
|
type __VLS_Slots = {} & {
|
|
3
|
-
default?: (props: typeof
|
|
4
|
+
default?: (props: typeof __VLS_13) => any;
|
|
4
5
|
};
|
|
5
|
-
declare const __VLS_component: import("vue").DefineComponent<{}, {
|
|
6
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {
|
|
7
|
+
isOnRightSide: import("vue").ComputedRef<boolean>;
|
|
8
|
+
offset: import("vue").Ref<{
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}, FloatingBubbleOffset | {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}>;
|
|
15
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
16
|
+
"offset-change": (offset: FloatingBubbleOffset) => any;
|
|
17
|
+
"drag-start": () => any;
|
|
18
|
+
"drag-end": () => any;
|
|
19
|
+
}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
|
|
20
|
+
"onOffset-change"?: ((offset: FloatingBubbleOffset) => any) | undefined;
|
|
21
|
+
"onDrag-start"?: (() => any) | undefined;
|
|
22
|
+
"onDrag-end"?: (() => any) | undefined;
|
|
23
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
24
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
7
25
|
export default _default;
|
|
8
26
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,69 +1,148 @@
|
|
|
1
1
|
import "./Trigger-sfc.css";
|
|
2
2
|
import { defineComponent as _defineComponent } from "vue";
|
|
3
|
+
import { ref, computed, onMounted } from "vue";
|
|
3
4
|
import { useOpenCodeWidgetContext } from "../context";
|
|
5
|
+
import FloatingBubble from "./FloatingBubble/FloatingBubble.vue.js";
|
|
6
|
+
const STORAGE_KEY = "opencode-bubble-offset";
|
|
4
7
|
const __vue_sfc__ = /* @__PURE__ */ _defineComponent({
|
|
5
8
|
__name: "Trigger",
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
emits: ["offset-change", "drag-start", "drag-end"],
|
|
10
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
8
11
|
const {
|
|
9
12
|
buttonActive: active,
|
|
10
13
|
open,
|
|
11
14
|
hotkeyLabel,
|
|
12
15
|
thinking,
|
|
16
|
+
resolvedTheme,
|
|
13
17
|
handleToggle
|
|
14
18
|
} = useOpenCodeWidgetContext();
|
|
15
|
-
const
|
|
19
|
+
const loadOffset = () => {
|
|
20
|
+
try {
|
|
21
|
+
const saved = localStorage.getItem(STORAGE_KEY);
|
|
22
|
+
if (saved) {
|
|
23
|
+
const parsed = JSON.parse(saved);
|
|
24
|
+
if (parsed && (parsed.x !== 0 || parsed.y !== 0)) {
|
|
25
|
+
return parsed;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
}
|
|
30
|
+
return { x: 0, y: 0 };
|
|
31
|
+
};
|
|
32
|
+
const offset = ref(loadOffset());
|
|
33
|
+
const emit = __emit;
|
|
34
|
+
const saveOffset = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const handleOffsetChange = (value) => {
|
|
41
|
+
offset.value = value;
|
|
42
|
+
saveOffset(value);
|
|
43
|
+
emit("offset-change", value);
|
|
44
|
+
};
|
|
45
|
+
const bubbleRef = ref(null);
|
|
46
|
+
const isOnRightSide = computed(() => {
|
|
47
|
+
if (typeof window === "undefined") return true;
|
|
48
|
+
const centerX = window.innerWidth / 2;
|
|
49
|
+
return offset.value.x > centerX;
|
|
50
|
+
});
|
|
51
|
+
onMounted(() => {
|
|
52
|
+
if (offset.value.x !== 0 || offset.value.y !== 0) {
|
|
53
|
+
emit("offset-change", offset.value);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
__expose({
|
|
57
|
+
isOnRightSide,
|
|
58
|
+
offset
|
|
59
|
+
});
|
|
60
|
+
const __returned__ = { active, open, hotkeyLabel, thinking, resolvedTheme, handleToggle, STORAGE_KEY, loadOffset, offset, emit, saveOffset, handleOffsetChange, bubbleRef, isOnRightSide, FloatingBubble };
|
|
16
61
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
17
62
|
return __returned__;
|
|
18
63
|
}
|
|
19
64
|
});
|
|
20
|
-
import { renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, openBlock as _openBlock,
|
|
65
|
+
import { renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock } from "vue";
|
|
21
66
|
const _hoisted_1 = ["aria-expanded", "title"];
|
|
22
67
|
function __vue_render__(_ctx, _cache, $props, $setup, $data, $options) {
|
|
23
|
-
return _openBlock(),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
return _openBlock(), _createBlock($setup["FloatingBubble"], {
|
|
69
|
+
ref: "bubbleRef",
|
|
70
|
+
offset: $setup.offset,
|
|
71
|
+
"onUpdate:offset": _cache[0] || (_cache[0] = ($event) => $setup.offset = $event),
|
|
72
|
+
axis: "xy",
|
|
73
|
+
magnetic: "x",
|
|
74
|
+
gap: 24,
|
|
75
|
+
onClick: $setup.handleToggle,
|
|
76
|
+
onOffsetChange: $setup.handleOffsetChange,
|
|
77
|
+
onDragStart: _cache[1] || (_cache[1] = ($event) => $setup.emit("drag-start")),
|
|
78
|
+
onDragEnd: _cache[2] || (_cache[2] = ($event) => $setup.emit("drag-end"))
|
|
79
|
+
}, {
|
|
80
|
+
default: _withCtx(() => [
|
|
81
|
+
_createElementVNode("button", {
|
|
82
|
+
class: _normalizeClass(["opencode-button", { active: $setup.active, thinking: $setup.thinking, "opencode-theme-dark": $setup.resolvedTheme === "dark" }]),
|
|
83
|
+
type: "button",
|
|
84
|
+
"aria-expanded": $setup.open,
|
|
85
|
+
"aria-label": "\u6253\u5F00 AI \u52A9\u624B",
|
|
86
|
+
title: `AI \u52A9\u624B (${$setup.hotkeyLabel})`
|
|
87
|
+
}, [
|
|
88
|
+
_renderSlot(_ctx.$slots, "default", {}, () => [
|
|
89
|
+
_cache[3] || (_cache[3] = _createElementVNode(
|
|
90
|
+
"svg",
|
|
91
|
+
{
|
|
92
|
+
t: "1775402599580",
|
|
93
|
+
class: "icon",
|
|
94
|
+
viewBox: "0 0 1024 1024",
|
|
95
|
+
version: "1.1",
|
|
96
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
97
|
+
"p-id": "5390",
|
|
98
|
+
"xmlns:xlink": "http://www.w3.org/1999/xlink",
|
|
99
|
+
width: "100%",
|
|
100
|
+
height: "100%"
|
|
101
|
+
},
|
|
102
|
+
[
|
|
103
|
+
_createElementVNode("defs", null, [
|
|
104
|
+
_createElementVNode("linearGradient", {
|
|
105
|
+
id: "opencode-logo-gradient",
|
|
106
|
+
x1: "0%",
|
|
107
|
+
y1: "0%",
|
|
108
|
+
x2: "100%",
|
|
109
|
+
y2: "100%"
|
|
110
|
+
}, [
|
|
111
|
+
_createElementVNode("stop", {
|
|
112
|
+
offset: "0%",
|
|
113
|
+
style: { "stop-color": "#667eea" }
|
|
114
|
+
}),
|
|
115
|
+
_createElementVNode("stop", {
|
|
116
|
+
offset: "100%",
|
|
117
|
+
style: { "stop-color": "#764ba2" }
|
|
118
|
+
})
|
|
119
|
+
])
|
|
120
|
+
]),
|
|
121
|
+
_createElementVNode("path", {
|
|
122
|
+
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",
|
|
123
|
+
fill: "url(#opencode-logo-gradient)",
|
|
124
|
+
"p-id": "5391"
|
|
125
|
+
}),
|
|
126
|
+
_createElementVNode("path", {
|
|
127
|
+
d: "M384 448m-64 0a64 64 0 1 0 128 0 64 64 0 1 0 -128 0Z",
|
|
128
|
+
fill: "url(#opencode-logo-gradient)",
|
|
129
|
+
"p-id": "5392"
|
|
130
|
+
}),
|
|
131
|
+
_createElementVNode("path", {
|
|
132
|
+
d: "M640 448m-64 0a64 64 0 1 0 128 0 64 64 0 1 0 -128 0Z",
|
|
133
|
+
fill: "url(#opencode-logo-gradient)",
|
|
134
|
+
"p-id": "5393"
|
|
135
|
+
})
|
|
136
|
+
],
|
|
137
|
+
-1
|
|
138
|
+
/* CACHED */
|
|
139
|
+
))
|
|
140
|
+
])
|
|
141
|
+
], 10, _hoisted_1)
|
|
142
|
+
]),
|
|
143
|
+
_: 3
|
|
144
|
+
/* FORWARDED */
|
|
145
|
+
}, 8, ["offset", "onClick"]);
|
|
67
146
|
}
|
|
68
147
|
__vue_sfc__.render = __vue_render__;
|
|
69
148
|
var Trigger_vue_default = __vue_sfc__;
|