koishi-plugin-chatluna-toolbox 0.0.20 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +101 -97
  2. package/lib/index.js +4 -11
  3. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { openBlock as y, createElementBlock as _, createElementVNode as w, defineComponent as b, Fragment as E, renderList as N, normalizeClass as m, toDisplayString as z, reactive as I, computed as f, onUnmounted as L, ref as T, onMounted as B, normalizeStyle as A, unref as k, createVNode as x, withModifiers as D, inject as K, createBlock as X, createCommentVNode as O } from "vue";
2
- const M = (s, o) => {
3
- const r = s.__vccOpts || s;
4
- for (const [c, t] of o)
1
+ import { openBlock as y, createElementBlock as k, createElementVNode as _, defineComponent as b, Fragment as E, renderList as N, normalizeClass as v, toDisplayString as z, reactive as I, computed as f, onUnmounted as L, ref as T, onMounted as B, normalizeStyle as A, createVNode as x, withModifiers as D, unref as $, inject as K, createBlock as X, createCommentVNode as O } from "vue";
2
+ const S = (n, e) => {
3
+ const r = n.__vccOpts || n;
4
+ for (const [c, t] of e)
5
5
  r[c] = t;
6
6
  return r;
7
7
  }, V = {}, Y = {
@@ -10,40 +10,40 @@ const M = (s, o) => {
10
10
  width: "20",
11
11
  height: "20"
12
12
  };
13
- function q(s, o) {
14
- return y(), _("svg", Y, [...o[0] || (o[0] = [
15
- w("path", {
13
+ function q(n, e) {
14
+ return y(), k("svg", Y, [...e[0] || (e[0] = [
15
+ _("path", {
16
16
  d: "M288 224c0-35.3 28.7-64 64-64s64 28.7 64 64-28.7 64-64 64-64-28.7-64-64zm320 0c0-35.3 28.7-64 64-64s64 28.7 64 64-28.7 64-64 64-64-28.7-64-64zM288 512c0-35.3 28.7-64 64-64s64 28.7 64 64-28.7 64-64 64-64-28.7-64-64zm320 0c0-35.3 28.7-64 64-64s64 28.7 64 64-28.7 64-64 64-64-28.7-64-64zM352 864c-35.3 0-64-28.7-64-64s28.7-64 64-64 64 28.7 64 64-28.7 64-64 64zm320 0c-35.3 0-64-28.7-64-64s28.7-64 64-64 64 28.7 64 64-28.7 64-64 64z",
17
17
  fill: "currentColor"
18
18
  }, null, -1)
19
19
  ])]);
20
20
  }
21
- const P = /* @__PURE__ */ M(V, [["render", q]]), W = {}, j = {
21
+ const P = /* @__PURE__ */ S(V, [["render", q]]), W = {}, j = {
22
22
  viewBox: "0 0 1024 1024",
23
23
  xmlns: "http://www.w3.org/2000/svg",
24
24
  width: "20",
25
25
  height: "20"
26
26
  };
27
- function U(s, o) {
28
- return y(), _("svg", j, [...o[0] || (o[0] = [
29
- w("path", {
27
+ function U(n, e) {
28
+ return y(), k("svg", j, [...e[0] || (e[0] = [
29
+ _("path", {
30
30
  d: "M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z",
31
31
  fill: "currentColor"
32
32
  }, null, -1)
33
33
  ])]);
34
34
  }
35
- const F = /* @__PURE__ */ M(W, [["render", U]]), G = ["onClick"], H = /* @__PURE__ */ b({
35
+ const F = /* @__PURE__ */ S(W, [["render", U]]), G = ["onClick"], H = /* @__PURE__ */ b({
36
36
  __name: "NavSection",
37
37
  props: {
38
38
  sections: {},
39
39
  activeKey: {}
40
40
  },
41
41
  emits: ["select"],
42
- setup(s) {
43
- return (o, r) => (y(!0), _(E, null, N(s.sections, (c) => (y(), _("div", {
42
+ setup(n) {
43
+ return (e, r) => (y(!0), k(E, null, N(n.sections, (c) => (y(), k("div", {
44
44
  key: c.key,
45
- class: m([o.$style.item, s.activeKey === c.key ? o.$style.active : ""]),
46
- onClick: (t) => o.$emit("select", c)
45
+ class: v([e.$style.item, n.activeKey === c.key ? e.$style.active : ""]),
46
+ onClick: (t) => e.$emit("select", c)
47
47
  }, z(c.title), 11, G))), 128));
48
48
  }
49
49
  }), J = "_item_1m2kp_1", Q = "_active_1m2kp_16", Z = {
@@ -51,24 +51,24 @@ const F = /* @__PURE__ */ M(W, [["render", U]]), G = ["onClick"], H = /* @__PURE
51
51
  active: Q
52
52
  }, tt = {
53
53
  $style: Z
54
- }, et = /* @__PURE__ */ M(H, [["__cssModules", tt]]);
55
- function R(s) {
56
- return s instanceof TouchEvent ? {
57
- x: s.touches[0].clientX,
58
- y: s.touches[0].clientY
54
+ }, et = /* @__PURE__ */ S(H, [["__cssModules", tt]]);
55
+ function R(n) {
56
+ return n instanceof TouchEvent ? {
57
+ x: n.touches[0].clientX,
58
+ y: n.touches[0].clientY
59
59
  } : {
60
- x: s.clientX,
61
- y: s.clientY
60
+ x: n.clientX,
61
+ y: n.clientY
62
62
  };
63
63
  }
64
- function ot(s = {}) {
64
+ function ot(n = {}) {
65
65
  const {
66
- initialTop: o = 100,
66
+ initialTop: e = 100,
67
67
  initialRight: r = 20,
68
68
  boundarySelector: c = ".plugin-view"
69
- } = s, t = I({
69
+ } = n, t = I({
70
70
  isDragging: !1,
71
- top: o,
71
+ top: e,
72
72
  right: r,
73
73
  startTop: 0,
74
74
  startRight: 0,
@@ -79,16 +79,16 @@ function ot(s = {}) {
79
79
  }), g = f(() => ({
80
80
  top: `${t.top}px`,
81
81
  right: `${t.right}px`
82
- })), i = (d) => {
82
+ })), i = (h) => {
83
83
  var C;
84
84
  if (!t.isDragging)
85
85
  return;
86
- const a = R(d), l = t.startTop + (a.y - t.startY), e = t.startRight - (a.x - t.startX), n = (C = document.querySelector(c)) == null ? void 0 : C.getBoundingClientRect();
87
- let h = 0, v = window.innerHeight - t.height, S = 0, $ = window.innerWidth - t.width;
88
- n && (h = n.top, v = n.bottom - t.height, S = window.innerWidth - n.right, $ = window.innerWidth - n.left - t.width), t.top = Math.max(h, Math.min(v, l)), t.right = Math.max(S, Math.min($, e));
89
- }, p = (d, a) => {
90
- const l = R(d), e = a == null ? void 0 : a.getBoundingClientRect();
91
- e && (t.width = e.width, t.height = e.height), t.startTop = t.top, t.startRight = t.right, t.startX = l.x, t.startY = l.y, t.isDragging = !0;
86
+ const d = R(h), l = t.startTop + (d.y - t.startY), a = t.startRight - (d.x - t.startX), o = (C = document.querySelector(c)) == null ? void 0 : C.getBoundingClientRect();
87
+ let s = 0, m = window.innerHeight - t.height, w = 0, M = window.innerWidth - t.width;
88
+ o && (s = o.top, m = o.bottom - t.height, w = window.innerWidth - o.right, M = window.innerWidth - o.left - t.width), t.top = Math.max(s, Math.min(m, l)), t.right = Math.max(w, Math.min(M, a));
89
+ }, p = (h, d) => {
90
+ const l = R(h), a = d == null ? void 0 : d.getBoundingClientRect();
91
+ a && (t.width = a.width, t.height = a.height), t.startTop = t.top, t.startRight = t.right, t.startX = l.x, t.startY = l.y, t.isDragging = !0;
92
92
  }, u = () => {
93
93
  t.isDragging = !1;
94
94
  };
@@ -99,22 +99,22 @@ function ot(s = {}) {
99
99
  startDrag: p
100
100
  };
101
101
  }
102
- function nt(s) {
102
+ function nt(n) {
103
103
  const {
104
- titleToKeyMap: o,
104
+ titleToKeyMap: e,
105
105
  headerSelector: r = ".k-schema-header",
106
106
  rootMargin: c = "-20% 0px -60% 0px",
107
107
  threshold: t = 0
108
- } = s, g = T("");
108
+ } = n, g = T("");
109
109
  let i = null;
110
110
  const p = /* @__PURE__ */ new Map(), u = () => {
111
111
  i == null || i.disconnect(), p.clear(), i = new IntersectionObserver(
112
112
  (l) => {
113
- for (const e of l) {
114
- if (!e.isIntersecting)
113
+ for (const a of l) {
114
+ if (!a.isIntersecting)
115
115
  continue;
116
- const n = p.get(e.target);
117
- n && (g.value = n);
116
+ const o = p.get(a.target);
117
+ o && (g.value = o);
118
118
  }
119
119
  },
120
120
  {
@@ -123,21 +123,21 @@ function nt(s) {
123
123
  threshold: t
124
124
  }
125
125
  ), document.querySelectorAll(r).forEach((l) => {
126
- const e = l.textContent || "";
127
- for (const [n, h] of Object.entries(o))
128
- if (e.includes(n)) {
129
- i == null || i.observe(l), p.set(l, h);
126
+ const a = l.textContent || "";
127
+ for (const [o, s] of Object.entries(e))
128
+ if (a.includes(o)) {
129
+ i == null || i.observe(l), p.set(l, s);
130
130
  break;
131
131
  }
132
132
  });
133
- }, d = () => {
133
+ }, h = () => {
134
134
  setTimeout(u, 500);
135
135
  };
136
- return B(d), L(() => {
136
+ return B(h), L(() => {
137
137
  i == null || i.disconnect();
138
138
  }), {
139
139
  activeSection: g,
140
- refresh: d
140
+ refresh: h
141
141
  };
142
142
  }
143
143
  const st = /* @__PURE__ */ b({
@@ -148,76 +148,80 @@ const st = /* @__PURE__ */ b({
148
148
  boundarySelector: { default: ".plugin-view" },
149
149
  initialTop: { default: 100 },
150
150
  initialRight: { default: 20 },
151
+ width: {},
151
152
  rootMargin: { default: "-20% 0px -60% 0px" },
152
153
  threshold: { default: 0 }
153
154
  },
154
- setup(s) {
155
- const o = s, r = T(!1), c = T(null), t = f(
156
- () => o.sections.reduce(
157
- (e, n) => (e[n.matchText ?? n.title] = n.key, e),
155
+ setup(n) {
156
+ const e = n, r = T(!1), c = T(null), t = f(
157
+ () => e.sections.reduce(
158
+ (o, s) => (o[s.matchText ?? s.title] = s.key, o),
158
159
  {}
159
160
  )
160
161
  ), g = f(
161
- () => o.sections.reduce(
162
- (e, n) => (e[n.key] = n.matchText ?? n.title, e),
162
+ () => e.sections.reduce(
163
+ (o, s) => (o[s.key] = s.matchText ?? s.title, o),
163
164
  {}
164
165
  )
165
- ), i = (e) => {
166
- e.stopPropagation(), r.value = !r.value;
166
+ ), i = (o) => {
167
+ o.stopPropagation(), r.value = !r.value;
167
168
  }, { position: p, startDrag: u } = ot({
168
- initialTop: o.initialTop,
169
- initialRight: o.initialRight,
170
- boundarySelector: o.boundarySelector
171
- }), d = (e) => {
172
- u(e, c.value);
173
- }, { activeSection: a } = nt({
169
+ initialTop: e.initialTop,
170
+ initialRight: e.initialRight,
171
+ boundarySelector: e.boundarySelector
172
+ }), h = f(() => ({
173
+ ...p.value,
174
+ ...e.width ? { width: `${e.width}px` } : {}
175
+ })), d = (o) => {
176
+ u(o, c.value);
177
+ }, { activeSection: l } = nt({
174
178
  titleToKeyMap: t.value,
175
- headerSelector: o.headerSelector,
176
- rootMargin: o.rootMargin,
177
- threshold: o.threshold
178
- }), l = (e) => {
179
- a.value = e.key;
180
- const n = document.querySelectorAll(o.headerSelector);
181
- for (let h = 0; h < n.length; h += 1) {
182
- const v = n[h];
183
- if ((v.textContent || "").includes(g.value[e.key])) {
184
- v.scrollIntoView({ behavior: "smooth", block: "start" });
179
+ headerSelector: e.headerSelector,
180
+ rootMargin: e.rootMargin,
181
+ threshold: e.threshold
182
+ }), a = (o) => {
183
+ l.value = o.key;
184
+ const s = document.querySelectorAll(e.headerSelector);
185
+ for (let m = 0; m < s.length; m += 1) {
186
+ const w = s[m];
187
+ if ((w.textContent || "").includes(g.value[o.key])) {
188
+ w.scrollIntoView({ behavior: "smooth", block: "start" });
185
189
  return;
186
190
  }
187
191
  }
188
192
  };
189
- return (e, n) => (y(), _("div", {
193
+ return (o, s) => (y(), k("div", {
190
194
  ref_key: "containerRef",
191
195
  ref: c,
192
- class: m([e.$style.container, r.value ? e.$style.collapsed : ""]),
193
- style: A(k(p))
196
+ class: v([o.$style.container, r.value ? o.$style.collapsed : ""]),
197
+ style: A(h.value)
194
198
  }, [
195
- w("div", {
196
- class: m(e.$style.header),
199
+ _("div", {
200
+ class: v(o.$style.header),
197
201
  onMousedown: d,
198
202
  onTouchstart: d
199
203
  }, [
200
204
  x(P, {
201
- class: m(e.$style.move)
205
+ class: v(o.$style.move)
202
206
  }, null, 8, ["class"]),
203
- w("div", {
204
- class: m(e.$style.toggle),
207
+ _("div", {
208
+ class: v(o.$style.toggle),
205
209
  onClick: i,
206
- onMousedown: n[0] || (n[0] = D(() => {
210
+ onMousedown: s[0] || (s[0] = D(() => {
207
211
  }, ["stop"])),
208
- onTouchstart: n[1] || (n[1] = D(() => {
212
+ onTouchstart: s[1] || (s[1] = D(() => {
209
213
  }, ["stop"]))
210
214
  }, [
211
215
  x(F)
212
216
  ], 34)
213
217
  ], 34),
214
- w("div", {
215
- class: m(e.$style.body)
218
+ _("div", {
219
+ class: v(o.$style.body)
216
220
  }, [
217
221
  x(et, {
218
- sections: s.sections,
219
- "active-key": k(a),
220
- onSelect: l
222
+ sections: n.sections,
223
+ "active-key": $(l),
224
+ onSelect: a
221
225
  }, null, 8, ["sections", "active-key"])
222
226
  ], 2)
223
227
  ], 6));
@@ -231,7 +235,7 @@ const st = /* @__PURE__ */ b({
231
235
  collapsed: dt
232
236
  }, ht = {
233
237
  $style: ut
234
- }, gt = /* @__PURE__ */ M(st, [["__cssModules", ht]]), pt = [
238
+ }, gt = /* @__PURE__ */ S(st, [["__cssModules", ht]]), pt = [
235
239
  { title: "基础设置", key: "basic" },
236
240
  { title: "原生工具", key: "nativeTools" },
237
241
  { title: "Character XML 工具", key: "xmlTools" },
@@ -240,22 +244,22 @@ const st = /* @__PURE__ */ b({
240
244
  ], mt = [
241
245
  "chatluna-toolbox",
242
246
  "koishi-plugin-chatluna-toolbox"
243
- ], yt = /* @__PURE__ */ b({
247
+ ], vt = /* @__PURE__ */ b({
244
248
  __name: "ToolboxDetailsLoader",
245
- setup(s) {
246
- const o = K("plugin:name"), r = pt, c = f(() => {
247
- const t = (o == null ? void 0 : o.value) || "";
249
+ setup(n) {
250
+ const e = K("plugin:name"), r = pt, c = f(() => {
251
+ const t = (e == null ? void 0 : e.value) || "";
248
252
  return mt.includes(t);
249
253
  });
250
- return (t, g) => c.value ? (y(), X(k(gt), {
254
+ return (t, g) => c.value ? (y(), X($(gt), {
251
255
  key: 0,
252
- sections: k(r)
256
+ sections: $(r)
253
257
  }, null, 8, ["sections"])) : O("", !0);
254
258
  }
255
- }), wt = (s) => {
256
- s.slot({
259
+ }), wt = (n) => {
260
+ n.slot({
257
261
  type: "plugin-details",
258
- component: yt,
262
+ component: vt,
259
263
  order: -999
260
264
  });
261
265
  };
package/lib/index.js CHANGED
@@ -501,10 +501,9 @@ var EnabledNativeToolsSchema = import_koishi2.Schema.array(
501
501
  import_koishi2.Schema.const("setMsgEmoji").description("\u6D88\u606F\u8868\u60C5"),
502
502
  import_koishi2.Schema.const("deleteMessage").description("\u64A4\u56DE\u6D88\u606F")
503
503
  ])
504
- ).role("checkbox").extra("default", void 0).description(
505
- "\u9009\u62E9\u8981\u6CE8\u518C\u5230 ChatLuna \u7684\u539F\u751F\u5DE5\u5177\uFF0C\u5DE5\u5177\u540D\u79F0\u548C\u63CF\u8FF0\u901A\u5E38\u65E0\u9700\u4FEE\u6539\uFF0C\u53EF\u5728\u4E0B\u65B9\u9AD8\u7EA7\u8BBE\u7F6E\u4E2D\u8C03\u6574"
506
- );
507
- var NativeToolAdvancedSettingsSchema = import_koishi2.Schema.object({
504
+ ).role("checkbox").extra("default", void 0).description("\u9009\u62E9\u8981\u6CE8\u518C\u5230 ChatLuna \u7684\u539F\u751F\u5DE5\u5177");
505
+ var NativeToolsSchema = import_koishi2.Schema.object({
506
+ enabledNativeTools: EnabledNativeToolsSchema,
508
507
  poke: import_koishi2.Schema.object({
509
508
  enabled: import_koishi2.Schema.boolean().default(false).hidden(),
510
509
  toolName: import_koishi2.Schema.string().default("poke_user").description("\u5DE5\u5177\u540D\u79F0"),
@@ -560,13 +559,7 @@ var NativeToolAdvancedSettingsSchema = import_koishi2.Schema.object({
560
559
  toolName: import_koishi2.Schema.string().default("delete_msg").description("\u5DE5\u5177\u540D\u79F0"),
561
560
  description: import_koishi2.Schema.string().default(DEFAULT_DELETE_MESSAGE_TOOL_DESCRIPTION).description("\u5DE5\u5177\u63CF\u8FF0")
562
561
  }).description("\u64A4\u56DE\u6D88\u606F\u5DE5\u5177").collapse()
563
- }).description("\u9AD8\u7EA7\u8BBE\u7F6E").collapse();
564
- var NativeToolsSchema = import_koishi2.Schema.intersect([
565
- import_koishi2.Schema.object({
566
- enabledNativeTools: EnabledNativeToolsSchema
567
- }).description(""),
568
- NativeToolAdvancedSettingsSchema
569
- ]).description("\u539F\u751F\u5DE5\u5177");
562
+ }).description("\u539F\u751F\u5DE5\u5177");
570
563
 
571
564
  // src/schema/xml-tools.ts
572
565
  var import_koishi3 = require("koishi");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-chatluna-toolbox",
3
3
  "description": "为 ChatLuna 提供更多原生工具、Character XML 工具与变量,仅支持 onebot 平台。",
4
- "version": "0.0.20",
4
+ "version": "0.0.21",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "files": [
@@ -49,12 +49,12 @@
49
49
  "@types/node": "^22.10.1",
50
50
  "@vitejs/plugin-vue": "^6.0.2",
51
51
  "sass": "^1.77.0",
52
- "shared-chatluna-xmltools": "0.0.1",
53
- "shared-nav": "0.0.1",
52
+ "shared-chatluna-xmltools": "workspace:*",
53
+ "shared-nav": "workspace:*",
54
54
  "tsup": "^8.0.0",
55
55
  "typescript": "^5.7.2",
56
56
  "vite": "^6.0.0",
57
57
  "vitest": "^3.2.4",
58
58
  "vue": "^3.5.21"
59
59
  }
60
- }
60
+ }