@syncshio/kano-plugin-output-gallery 0.0.0-stage → 1.0.0

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/dist/entry.js ADDED
@@ -0,0 +1,854 @@
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createSlots as o, createVNode as s, defineComponent as c, h as l, isRef as u, nextTick as d, normalizeClass as f, normalizeStyle as p, onBeforeUnmount as ee, onMounted as m, openBlock as h, ref as g, renderList as _, renderSlot as v, resolveDynamicComponent as y, shallowRef as b, toDisplayString as x, unref as S, watch as C, withCtx as w, withModifiers as T } from "vue";
2
+ import { BreadcrumbBar as E, Button as D, ConfirmDialog as O, CopyButton as k, Dialog as A, EmptyState as j, FilterBar as M, KanoBadge as te, PageShell as N, SearchInput as P, SegmentedControl as F, Select as I, SkeletonCard as ne, VirtualModelGrid as re, resolvePath as ie } from "@syncshio/kano-plugin-sdk/host";
3
+ //#region ../kano-plugin-sdk/src/helpers/define-plugin.ts
4
+ function ae(e) {
5
+ return e;
6
+ }
7
+ //#endregion
8
+ //#region packages/plugins/output-gallery/output-gallery.ts
9
+ async function oe(e, t, n = !1) {
10
+ let r = await e.listDir(t).catch(async (r) => {
11
+ if (n && !await e.exists(t)) return [];
12
+ throw r;
13
+ }), i = r.filter((e) => e.is_dir).map((e) => e.name).sort((e, t) => e.localeCompare(t)), a = r.filter((e) => !e.is_dir && /\.(png|webp|jpe?g|gif|avif|mp4|webm)$/i.test(e.name)).map((e) => ({
14
+ name: e.name,
15
+ path: ie(t, e.name),
16
+ size: e.size,
17
+ modified: e.mod_time,
18
+ kind: /\.(mp4|webm)$/i.test(e.name) ? "video" : "image"
19
+ })), o = (e) => Date.parse(e.modified ?? "") || 0;
20
+ return a.sort((e, t) => o(t) - o(e) || e.name.localeCompare(t.name)), {
21
+ folders: i,
22
+ files: a
23
+ };
24
+ }
25
+ //#endregion
26
+ //#region packages/MediaViewport.vue?vue&type=script&setup=true&lang.ts
27
+ var se = { class: "flex min-h-0 min-w-0 flex-col gap-2" }, L = {
28
+ class: "flex shrink-0 flex-wrap items-center gap-1",
29
+ role: "group",
30
+ "aria-label": "媒体预览工具"
31
+ }, ce = ["disabled"], le = ["disabled"], ue = ["disabled"], de = { class: "ml-auto flex flex-wrap items-center gap-x-3 gap-y-1 text-xs tabular-nums text-text-secondary" }, R = { key: 0 }, z = { class: "media-viewport-frame relative min-h-0 overflow-hidden rounded-lg border border-border-light bg-surface-subtle" }, B = ["tabindex", "aria-label"], V = { class: "grid h-max min-h-full w-max min-w-full place-items-center" }, H = ["src", "alt"], U = ["src", "aria-label"], fe = {
32
+ key: 0,
33
+ role: "alert",
34
+ class: "text-danger"
35
+ }, W = /*@__PURE__*/ c({
36
+ __name: "MediaViewport",
37
+ props: {
38
+ source: {},
39
+ label: {},
40
+ kind: { default: "image" }
41
+ },
42
+ setup(e) {
43
+ let n = e, o = g(), s = g(), c = g({
44
+ width: 0,
45
+ height: 0
46
+ }), l = g({
47
+ width: 0,
48
+ height: 0
49
+ }), _ = g(!1), y = t(() => l.value.width > 0 && l.value.height > 0 && c.value.width > 0 && c.value.height > 0 && !_.value), b = t(() => y.value ? Math.min(c.value.width / l.value.width, c.value.height / l.value.height) : 1), S = g(), w = t(() => S.value ?? b.value), E = t(() => Math.min(b.value, .25)), D = t(() => Math.max(b.value, 4)), O = t(() => y.value && w.value > b.value), k = t(() => y.value ? {
50
+ width: l.value.width * w.value + "px",
51
+ height: l.value.height * w.value + "px"
52
+ } : void 0), A;
53
+ m(() => {
54
+ let e = o.value, t = () => {
55
+ c.value = {
56
+ width: e.clientWidth,
57
+ height: e.clientHeight
58
+ };
59
+ };
60
+ t(), typeof ResizeObserver < "u" && (A = new ResizeObserver(t), A.observe(e));
61
+ }), ee(() => A?.disconnect());
62
+ function j() {
63
+ let e = s.value;
64
+ e && (l.value = "naturalWidth" in e ? {
65
+ width: e.naturalWidth,
66
+ height: e.naturalHeight
67
+ } : {
68
+ width: e.videoWidth,
69
+ height: e.videoHeight
70
+ });
71
+ }
72
+ C(() => n.source, () => {
73
+ l.value = {
74
+ width: 0,
75
+ height: 0
76
+ }, _.value = !1, S.value = void 0, N = void 0;
77
+ });
78
+ async function M(e, t) {
79
+ let n = o.value, r = s.value;
80
+ if (!n || !r || !y.value) return;
81
+ let i = n.getBoundingClientRect(), a = r.getBoundingClientRect(), c = t?.clientX ?? i.left + i.width / 2, l = t?.clientY ?? i.top + i.height / 2, u = (c - a.left) / a.width, f = (l - a.top) / a.height;
82
+ if (S.value = e === void 0 ? void 0 : Math.max(E.value, Math.min(D.value, e)), await d(), r !== s.value) return;
83
+ let p = r.getBoundingClientRect();
84
+ n.scrollLeft += p.left + u * p.width - c, n.scrollTop += p.top + f * p.height - l;
85
+ }
86
+ function te(e) {
87
+ let t = e.deltaY * (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? c.value.height : 1);
88
+ M(w.value * Math.exp(-Math.min(300, Math.max(-300, t)) * .002), e);
89
+ }
90
+ let N;
91
+ function P(e) {
92
+ let t = o.value;
93
+ t && O.value && e.isPrimary && e.button === 0 && (n.kind === "video" && s.value && e.clientY >= s.value.getBoundingClientRect().bottom - 48 || (N = {
94
+ id: e.pointerId,
95
+ x: e.clientX,
96
+ y: e.clientY,
97
+ left: t.scrollLeft,
98
+ top: t.scrollTop
99
+ }, t.setPointerCapture(e.pointerId)));
100
+ }
101
+ function F(e) {
102
+ N && N.id === e.pointerId && o.value && (o.value.scrollLeft = N.left + N.x - e.clientX, o.value.scrollTop = N.top + N.y - e.clientY);
103
+ }
104
+ function I(e) {
105
+ let t = o.value;
106
+ if (O.value && t) {
107
+ switch (e.key) {
108
+ case "ArrowLeft":
109
+ t.scrollLeft -= 48;
110
+ break;
111
+ case "ArrowRight":
112
+ t.scrollLeft += 48;
113
+ break;
114
+ case "ArrowUp":
115
+ t.scrollTop -= 48;
116
+ break;
117
+ case "ArrowDown":
118
+ t.scrollTop += 48;
119
+ break;
120
+ default: return;
121
+ }
122
+ e.preventDefault();
123
+ }
124
+ }
125
+ return (t, n) => (h(), i("div", se, [
126
+ a("div", L, [
127
+ a("button", {
128
+ type: "button",
129
+ class: "kano-btn kano-btn-ghost kano-btn-xs kano-icon-button",
130
+ "aria-label": "缩小",
131
+ title: "缩小",
132
+ disabled: !y.value || w.value <= E.value,
133
+ onClick: n[0] ||= (e) => M(w.value / 1.25)
134
+ }, [...n[9] ||= [a("span", {
135
+ class: "i-lucide-zoom-out size-4",
136
+ "aria-hidden": "true"
137
+ }, null, -1)]], 8, ce),
138
+ a("button", {
139
+ type: "button",
140
+ "aria-label": "适应画布",
141
+ title: "适应画布",
142
+ class: "kano-btn kano-btn-ghost kano-btn-xs min-w-[3.5rem] justify-center tabular-nums",
143
+ disabled: !y.value,
144
+ onClick: n[1] ||= (e) => M()
145
+ }, x(y.value ? Math.round(w.value * 100) + "%" : "适应"), 9, le),
146
+ a("button", {
147
+ type: "button",
148
+ class: "kano-btn kano-btn-ghost kano-btn-xs kano-icon-button",
149
+ "aria-label": "放大",
150
+ title: "放大",
151
+ disabled: !y.value || w.value >= D.value,
152
+ onClick: n[2] ||= (e) => M(w.value * 1.25)
153
+ }, [...n[10] ||= [a("span", {
154
+ class: "i-lucide-zoom-in size-4",
155
+ "aria-hidden": "true"
156
+ }, null, -1)]], 8, ue),
157
+ a("span", de, [l.value.width ? (h(), i("span", R, x(l.value.width) + " × " + x(l.value.height), 1)) : r("", !0), v(t.$slots, "metadata", {}, void 0, !0)])
158
+ ]),
159
+ a("div", z, [a("div", {
160
+ ref_key: "viewport",
161
+ ref: o,
162
+ class: f(["absolute inset-0 overflow-hidden", { "touch-none cursor-grab active:cursor-grabbing": O.value }]),
163
+ tabindex: O.value ? 0 : void 0,
164
+ role: "group",
165
+ "aria-label": e.label + " 预览画布",
166
+ onKeydown: T(I, ["self"]),
167
+ onWheel: T(te, ["prevent"]),
168
+ onDblclick: n[5] ||= T((e) => M(w.value === 1 ? void 0 : 1, e), ["prevent"]),
169
+ onPointerdown: P,
170
+ onPointermove: F,
171
+ onPointerup: n[6] ||= (e) => u(N) ? N.value = void 0 : N = void 0,
172
+ onPointercancel: n[7] ||= (e) => u(N) ? N.value = void 0 : N = void 0,
173
+ onLostpointercapture: n[8] ||= (e) => u(N) ? N.value = void 0 : N = void 0
174
+ }, [a("div", V, [e.kind === "image" ? (h(), i("img", {
175
+ key: e.source,
176
+ ref_key: "media",
177
+ ref: s,
178
+ src: e.source,
179
+ alt: e.label,
180
+ draggable: "false",
181
+ class: "kano-media-checkerboard block max-w-none select-none",
182
+ style: p(k.value),
183
+ onLoad: j,
184
+ onError: n[3] ||= (e) => e.currentTarget === s.value && (_.value = !0)
185
+ }, null, 44, H)) : (h(), i("video", {
186
+ key: e.source,
187
+ ref_key: "media",
188
+ ref: s,
189
+ src: e.source,
190
+ controls: "",
191
+ preload: "metadata",
192
+ "aria-label": e.label,
193
+ class: "block max-w-none",
194
+ style: p(k.value),
195
+ onLoadedmetadata: j,
196
+ onError: n[4] ||= (e) => e.currentTarget === s.value && (_.value = !0)
197
+ }, null, 44, U))])], 42, B), v(t.$slots, "overlay", {}, void 0, !0)]),
198
+ _.value ? (h(), i("p", fe, "无法载入媒体,请检查文件或编码。")) : r("", !0)
199
+ ]));
200
+ }
201
+ }), G = (e, t) => {
202
+ let n = e.__vccOpts || e;
203
+ for (let [e, r] of t) n[e] = r;
204
+ return n;
205
+ }, pe = /*#__PURE__*/ G(W, [["__scopeId", "data-v-b09f18d7"]]), me = [
206
+ "B",
207
+ "KiB",
208
+ "MiB",
209
+ "GiB",
210
+ "TiB",
211
+ "PiB"
212
+ ], K = new Intl.NumberFormat("zh-CN", { maximumFractionDigits: 1 });
213
+ function q(e) {
214
+ let t = e, n = 0;
215
+ for (; t >= 1024 && n < me.length - 1;) t /= 1024, n++;
216
+ return `${K.format(t)} ${me[n]}`;
217
+ }
218
+ //#endregion
219
+ //#region packages/plugins/output-gallery/OutputMedia.vue
220
+ var he = /*#__PURE__*/ G(/* @__PURE__ */ c({
221
+ __name: "OutputMedia",
222
+ props: {
223
+ item: {},
224
+ source: {},
225
+ hasPrevious: { type: Boolean },
226
+ hasNext: { type: Boolean },
227
+ busy: { type: Boolean }
228
+ },
229
+ emits: ["move"],
230
+ setup(e, { emit: t }) {
231
+ let i = t;
232
+ return (t, o) => (h(), n(pe, {
233
+ class: "output-media",
234
+ source: e.source,
235
+ kind: e.item.kind,
236
+ label: e.item.name
237
+ }, {
238
+ metadata: w(() => [a("span", null, x(S(q)(e.item.size)), 1)]),
239
+ overlay: w(() => [e.hasPrevious ? (h(), n(S(D), {
240
+ key: 0,
241
+ rounded: "",
242
+ severity: "secondary",
243
+ icon: "i-lucide-chevron-left",
244
+ class: "!absolute left-2 top-1/2 -translate-y-1/2 rounded-full !border !border-border/80 !bg-surface-overlay/90 shadow-sm backdrop-blur-md",
245
+ "aria-label": "上一项",
246
+ title: "上一项(←)",
247
+ disabled: e.busy,
248
+ onClick: o[0] ||= (e) => i("move", -1)
249
+ }, null, 8, ["disabled"])) : r("", !0), e.hasNext ? (h(), n(S(D), {
250
+ key: 1,
251
+ rounded: "",
252
+ severity: "secondary",
253
+ icon: "i-lucide-chevron-right",
254
+ class: "!absolute right-2 top-1/2 -translate-y-1/2 rounded-full !border !border-border/80 !bg-surface-overlay/90 shadow-sm backdrop-blur-md",
255
+ "aria-label": "下一项",
256
+ title: "下一项(→)",
257
+ disabled: e.busy,
258
+ onClick: o[1] ||= (e) => i("move", 1)
259
+ }, null, 8, ["disabled"])) : r("", !0)]),
260
+ _: 1
261
+ }, 8, [
262
+ "source",
263
+ "kind",
264
+ "label"
265
+ ]));
266
+ }
267
+ }), [["__scopeId", "data-v-db8204b5"]]), J = { class: "output-preview grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]" }, Y = {
268
+ class: "output-info min-h-0 min-w-0 space-y-4 overflow-auto lg:max-h-[calc(54vh+2.25rem)]",
269
+ "aria-label": "产出物信息"
270
+ }, X = {
271
+ key: 0,
272
+ role: "status",
273
+ class: "kano-field-hint"
274
+ }, Z = {
275
+ key: 1,
276
+ role: "alert",
277
+ class: "break-words text-sm text-danger"
278
+ }, Q = {
279
+ key: 0,
280
+ class: "rounded-lg bg-surface-subtle p-3"
281
+ }, $ = { class: "flex items-center justify-between gap-2" }, ge = { class: "kano-field-label" }, _e = {
282
+ tabindex: "0",
283
+ class: "mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words text-sm"
284
+ }, ve = { class: "kano-field-label" }, ye = { class: "mt-2 grid grid-cols-2 gap-1.5 text-sm" }, be = { class: "text-xs text-text-secondary" }, xe = { class: "break-all font-mono text-xs tabular-nums" }, Se = { key: 2 }, Ce = { class: "mt-2 flex flex-wrap gap-1.5" }, we = {
285
+ key: 3,
286
+ class: "text-sm"
287
+ }, Te = { class: "mt-2 flex items-start gap-2" }, Ee = { class: "min-w-0 flex-1 whitespace-pre-wrap break-words" }, De = {
288
+ key: 4,
289
+ class: "kano-field-hint"
290
+ }, Oe = { class: "flex w-full flex-wrap justify-end gap-2" }, ke = /*#__PURE__*/ G(/* @__PURE__ */ c({
291
+ __name: "OutputPreview",
292
+ props: {
293
+ api: {},
294
+ instanceId: {},
295
+ gallerySource: {},
296
+ item: {},
297
+ hasPrevious: { type: Boolean },
298
+ hasNext: { type: Boolean }
299
+ },
300
+ emits: [
301
+ "close",
302
+ "move",
303
+ "removed"
304
+ ],
305
+ setup(o, { emit: c }) {
306
+ let l = o, u = c, d = t(() => l.api.fs.mediaFileUrl(l.item.path, l.item.modified)), f = b(), p = g(!1), v = g(!1), T = g(""), E = g(!1), j = g(""), M = l.api.meta.isRemoteServer(), N = l.api.ui.toast, P = !0;
307
+ ee(() => {
308
+ P = !1;
309
+ }), C([() => l.instanceId, d], async (e, t, n) => {
310
+ let r = new AbortController();
311
+ if (n(() => r.abort()), f.value = void 0, T.value = "", p.value = !1, v.value = !1, E.value = !1, !/\.png$/i.test(l.item.name)) return;
312
+ if (l.item.size > 33554432) {
313
+ T.value = "PNG 元数据预览支持 32 MiB 以内的文件";
314
+ return;
315
+ }
316
+ let { item: i, api: a } = l;
317
+ E.value = !0;
318
+ try {
319
+ let e = await a.fs.readPngMetadata(i.path, i.modified, r.signal);
320
+ r.signal.aborted || (f.value = l.gallerySource.describe(e, i.name));
321
+ } catch (e) {
322
+ r.signal.aborted || (T.value = String(e));
323
+ } finally {
324
+ r.signal.aborted || (E.value = !1);
325
+ }
326
+ }, { immediate: !0 });
327
+ function F(e) {
328
+ j.value || p.value || v.value || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.target instanceof Element && e.target.closest("input,textarea,select,video,[contenteditable=true]") || (e.key === "ArrowLeft" || e.key === "ArrowRight") && (e.preventDefault(), u("move", e.key === "ArrowLeft" ? -1 : 1));
329
+ }
330
+ m(() => window.addEventListener("keydown", F)), ee(() => window.removeEventListener("keydown", F));
331
+ async function I(e) {
332
+ if (j.value) return;
333
+ let { api: t, instanceId: n, item: r } = l, i = () => P && l.item.path === r.path && l.instanceId === n;
334
+ j.value = e;
335
+ try {
336
+ if (e === "trash") v.value = !1, await t.fs.trash(r.path), N.success("已移至回收站", r.name), i() && u("removed", r.path);
337
+ else {
338
+ let e = await t.fs.downloadToLocal(r.path);
339
+ e && N.success("已下载到本机", e);
340
+ }
341
+ } catch (t) {
342
+ N.exception(e === "trash" ? "移至回收站失败" : "下载失败", t);
343
+ } finally {
344
+ j.value = "";
345
+ }
346
+ }
347
+ return (t, c) => (h(), i(e, null, [s(S(A), {
348
+ visible: "",
349
+ modal: "",
350
+ maximizable: "",
351
+ header: o.item.name,
352
+ class: "w-[min(84rem,95vw)]",
353
+ "onUpdate:visible": c[5] ||= (e) => !e && !j.value && !p.value && u("close")
354
+ }, {
355
+ footer: w(() => [a("div", Oe, [
356
+ s(S(D), {
357
+ class: "mr-auto",
358
+ severity: "danger",
359
+ text: "",
360
+ icon: "i-lucide-trash-2",
361
+ label: "移至回收站",
362
+ disabled: !!j.value || p.value,
363
+ onClick: c[1] ||= (e) => v.value = !0
364
+ }, null, 8, ["disabled"]),
365
+ S(M) ? (h(), n(S(D), {
366
+ key: 0,
367
+ severity: "secondary",
368
+ label: "下载到本机",
369
+ loading: j.value === "download",
370
+ disabled: !!j.value || p.value,
371
+ onClick: c[2] ||= (e) => I("download")
372
+ }, null, 8, ["loading", "disabled"])) : r("", !0),
373
+ f.value?.actions ? (h(), n(y(f.value.actions), {
374
+ key: 1,
375
+ disabled: !!j.value || v.value,
376
+ onActive: c[3] ||= (e) => p.value = e,
377
+ onClose: c[4] ||= (e) => u("close")
378
+ }, null, 40, ["disabled"])) : r("", !0)
379
+ ])]),
380
+ default: w(() => [a("div", J, [s(he, {
381
+ item: o.item,
382
+ source: d.value,
383
+ "has-previous": o.hasPrevious,
384
+ "has-next": o.hasNext,
385
+ busy: !!j.value || p.value,
386
+ onMove: c[0] ||= (e) => u("move", e)
387
+ }, null, 8, [
388
+ "item",
389
+ "source",
390
+ "has-previous",
391
+ "has-next",
392
+ "busy"
393
+ ]), a("aside", Y, [
394
+ E.value ? (h(), i("p", X, "正在读取 PNG 参数…")) : r("", !0),
395
+ T.value ? (h(), i("p", Z, x(T.value), 1)) : r("", !0),
396
+ (h(), i(e, null, _(["positive", "negative"], (t) => (h(), i(e, { key: t }, [f.value?.[t] ? (h(), i("section", Q, [a("div", $, [a("h3", ge, x(t === "positive" ? "正向提示词" : "负向提示词"), 1), s(S(k), {
397
+ label: t === "positive" ? "复制正向提示词" : "复制负向提示词",
398
+ text: f.value[t]
399
+ }, null, 8, ["label", "text"])]), a("p", _e, x(f.value[t]), 1)])) : r("", !0)], 64))), 64)),
400
+ (h(!0), i(e, null, _(f.value?.samples, (t) => (h(), i("div", { key: t.title }, [a("h3", ve, x(t.title), 1), a("dl", ye, [(h(!0), i(e, null, _(t.values, (e) => (h(), i("div", {
401
+ key: e.label,
402
+ class: "min-w-0 rounded-md bg-surface-subtle px-2 py-1.5"
403
+ }, [a("dt", be, x(e.label), 1), a("dd", xe, x(e.value), 1)]))), 128))])]))), 128)),
404
+ f.value?.models?.length ? (h(), i("div", Se, [c[8] ||= a("h3", { class: "kano-field-label" }, "引用模型", -1), a("ul", Ce, [(h(!0), i(e, null, _(f.value.models, (e) => (h(), i("li", {
405
+ key: e,
406
+ class: "inline-flex min-w-0 max-w-full items-center gap-1"
407
+ }, [s(S(te), {
408
+ label: e,
409
+ title: e,
410
+ class: "min-w-0"
411
+ }, null, 8, ["label", "title"]), s(S(k), {
412
+ label: "复制模型路径 " + e,
413
+ text: e,
414
+ class: "shrink-0"
415
+ }, null, 8, ["label", "text"])]))), 128))])])) : r("", !0),
416
+ f.value?.raw ? (h(), i("details", we, [c[9] ||= a("summary", { class: "cursor-pointer text-text-secondary" }, "原始生成参数", -1), a("div", Te, [a("p", Ee, x(f.value.raw), 1), s(S(k), {
417
+ label: "复制原始生成参数",
418
+ text: f.value.raw,
419
+ class: "-mt-1 shrink-0"
420
+ }, null, 8, ["text"])])])) : r("", !0),
421
+ !E.value && !T.value && !f.value?.positive && !f.value?.negative && !f.value?.samples?.length && !f.value?.models?.length && !f.value?.actions && !f.value?.raw ? (h(), i("p", De, " 此文件没有可读取的生成参数。 ")) : r("", !0)
422
+ ])])]),
423
+ _: 1
424
+ }, 8, ["header"]), s(S(O), {
425
+ visible: v.value,
426
+ "onUpdate:visible": c[6] ||= (e) => v.value = e,
427
+ title: "移至回收站",
428
+ message: o.item.name + "\n\n可从执行机器的回收站恢复。",
429
+ "confirm-text": "移至回收站",
430
+ type: "danger",
431
+ onConfirm: c[7] ||= (e) => I("trash")
432
+ }, null, 8, ["visible", "message"])], 64));
433
+ }
434
+ }), [["__scopeId", "data-v-f407bb9f"]]), Ae = {
435
+ key: 0,
436
+ class: "flex flex-wrap gap-2"
437
+ }, je = {
438
+ key: 1,
439
+ role: "alert",
440
+ class: "break-words text-danger"
441
+ }, Me = {
442
+ key: 2,
443
+ role: "alert",
444
+ class: "break-words text-danger"
445
+ }, Ne = {
446
+ key: 3,
447
+ role: "status",
448
+ "aria-label": "正在读取输出目录",
449
+ class: "grid grid-cols-[repeat(auto-fill,minmax(min(100%,220px),1fr))] gap-3"
450
+ }, Pe = ["src"], Fe = {
451
+ key: 1,
452
+ class: "absolute inset-0 grid place-items-center bg-surface-subtle"
453
+ }, Ie = {
454
+ key: 0,
455
+ class: "i-lucide-check size-3.5"
456
+ }, Le = { class: "absolute inset-x-0 bottom-0 truncate border-t border-border-light/60 bg-surface-workspace/90 px-2.5 py-1.5 text-xs text-text-base backdrop-blur-sm" }, Re = { class: "mr-auto text-sm tabular-nums" }, ze = /* @__PURE__ */ c({
457
+ __name: "OutputGallery",
458
+ props: {
459
+ instanceId: {},
460
+ source: {},
461
+ api: {}
462
+ },
463
+ setup(c) {
464
+ let l = re, u = c, d = b([]), p = t(() => [{
465
+ label: "输出目录",
466
+ path: u.source.root
467
+ }, ...d.value]), m = g(""), v = t(() => m.value || u.source.root), y = g([]), T = t(() => y.value.reduce((e, t) => ie(e, t), v.value)), O = g(""), k = g("all"), A = g("comfortable"), ae = [
468
+ {
469
+ value: "all",
470
+ label: "全部"
471
+ },
472
+ {
473
+ value: "image",
474
+ label: "图片"
475
+ },
476
+ {
477
+ value: "video",
478
+ label: "视频"
479
+ }
480
+ ], se = [{
481
+ value: "compact",
482
+ label: "紧凑"
483
+ }, {
484
+ value: "comfortable",
485
+ label: "舒适"
486
+ }], L = g("latest"), ce = [
487
+ {
488
+ label: "最新修改",
489
+ value: "latest"
490
+ },
491
+ {
492
+ label: "最早修改",
493
+ value: "oldest"
494
+ },
495
+ {
496
+ label: "文件大小",
497
+ value: "size"
498
+ },
499
+ {
500
+ label: "文件名",
501
+ value: "name"
502
+ }
503
+ ], le = t(() => [p.value.find((e) => e.path === v.value) ?? p.value[0], ...y.value.map((e, t) => ({
504
+ label: e,
505
+ path: y.value.slice(0, t + 1).reduce((e, t) => ie(e, t), v.value)
506
+ }))]), ue = g(), de = t(() => {
507
+ let e = ue.value;
508
+ if (e) return (typeof e.closest == "function" ? e.closest(".overflow-auto, .overflow-y-auto") : null) ?? e.parentElement ?? void 0;
509
+ }), R = g(!1), z = g(/* @__PURE__ */ new Set()), B = g(!1), V = g([]), H = b([]), U = t(() => !!O.value.trim() || k.value !== "all"), fe = new Intl.Collator("zh-CN", { numeric: !0 }), W = t(() => {
510
+ let e = O.value.trim().toLowerCase(), t = H.value.filter((t) => (k.value === "all" || k.value === t.kind) && t.name.toLowerCase().includes(e)), n = (e) => Date.parse(e.modified ?? "") || 0;
511
+ return t.sort((e, t) => (L.value === "size" ? t.size - e.size : L.value === "oldest" ? n(e) - n(t) : L.value === "latest" ? n(t) - n(e) : 0) || fe.compare(e.name, t.name)).map((e) => ({
512
+ ...e,
513
+ id: e.path
514
+ }));
515
+ });
516
+ C(W, (e) => {
517
+ let t = new Set(e.map((e) => e.path));
518
+ z.value = new Set([...z.value].filter((e) => t.has(e)));
519
+ });
520
+ function G() {
521
+ R.value = !R.value, z.value.clear();
522
+ }
523
+ function pe(e) {
524
+ B.value || (R.value ? z.value.has(e) ? z.value.delete(e) : z.value.add(e) : K.value = e);
525
+ }
526
+ async function me() {
527
+ if (!z.value.size || B.value || J.value) return;
528
+ let e = [...z.value], t = Z, n = u.api;
529
+ B.value = !0;
530
+ try {
531
+ if (!await n.ui.confirm({
532
+ title: "将选中的文件移至回收站?",
533
+ message: "选中的 " + e.length + " 个输出文件将从此目录移除。",
534
+ type: "danger",
535
+ confirmText: "移至回收站"
536
+ }) || t !== Z) return;
537
+ X.value = "";
538
+ let r = /* @__PURE__ */ new Set(), i = [];
539
+ for (let a of e) {
540
+ if (t !== Z) return;
541
+ try {
542
+ await n.fs.trash(a), r.add(a);
543
+ } catch (e) {
544
+ i.push(a.split(/[\\/]/).pop() + ":" + String(e));
545
+ }
546
+ }
547
+ if (t !== Z) return;
548
+ H.value = H.value.filter((e) => !r.has(e.path));
549
+ for (let e of r) z.value.delete(e);
550
+ i.length ? X.value = "有 " + i.length + " 个文件未移至回收站。" + i.join(";") : R.value = !1;
551
+ } catch (e) {
552
+ t === Z && (X.value = String(e));
553
+ } finally {
554
+ t === Z && (B.value = !1);
555
+ }
556
+ }
557
+ let K = g(""), q = t(() => W.value.findIndex((e) => e.path === K.value)), he = t(() => W.value[q.value]), J = g(!1), Y = g(!1), X = g(""), Z = 0, Q = 0, $ = g("");
558
+ ee(() => {
559
+ Z++, Q++;
560
+ });
561
+ async function ge() {
562
+ let e = ++Q;
563
+ $.value = "";
564
+ try {
565
+ let t = await u.source.extraRoots?.() ?? [];
566
+ if (e !== Q) return;
567
+ d.value = t, t.some((e) => e.path === m.value) || (m.value = "");
568
+ } catch (t) {
569
+ e === Q && ($.value = String(t));
570
+ }
571
+ }
572
+ C([
573
+ () => u.instanceId,
574
+ () => u.source.root,
575
+ () => u.source.configPath
576
+ ], () => {
577
+ d.value = [], m.value = "", ge();
578
+ }, { immediate: !0 }), C([() => u.instanceId, v], () => {
579
+ y.value = [], ye(), K.value = "";
580
+ }, { flush: "sync" }), C([() => u.instanceId, T], () => {
581
+ K.value = "", R.value = !1, B.value = !1, z.value.clear(), H.value = [], V.value = [], Y.value = !1, ve();
582
+ }, { immediate: !0 });
583
+ function _e() {
584
+ ge(), ve();
585
+ }
586
+ async function ve() {
587
+ let e = ++Z, t = T.value;
588
+ J.value = !0, X.value = "";
589
+ try {
590
+ let n = await oe(u.api.fs, t, !y.value.length);
591
+ if (e !== Z) return;
592
+ V.value = n.folders, H.value = n.files, Y.value = !0;
593
+ } catch (t) {
594
+ e === Z && (X.value = String(t));
595
+ } finally {
596
+ e === Z && (J.value = !1);
597
+ }
598
+ }
599
+ function ye() {
600
+ O.value = "", k.value = "all";
601
+ }
602
+ function be(e) {
603
+ let t = W.value[q.value + e];
604
+ t && (K.value = t.path);
605
+ }
606
+ function xe(e) {
607
+ H.value = H.value.filter((t) => t.path !== e), K.value === e && (K.value = "");
608
+ }
609
+ return (t, u) => (h(), n(S(N), {
610
+ title: "输出图库",
611
+ "max-width": "fluid"
612
+ }, o({
613
+ actions: w(() => [H.value.length ? (h(), n(S(D), {
614
+ key: 0,
615
+ label: R.value ? "退出选择" : "批量选择",
616
+ severity: "secondary",
617
+ "aria-pressed": R.value,
618
+ disabled: B.value,
619
+ onClick: G
620
+ }, null, 8, [
621
+ "label",
622
+ "aria-pressed",
623
+ "disabled"
624
+ ])) : r("", !0), s(S(D), {
625
+ label: X.value || $.value ? "重新读取目录" : "刷新",
626
+ icon: "i-lucide-refresh-cw",
627
+ severity: "secondary",
628
+ disabled: B.value,
629
+ loading: J.value,
630
+ onClick: _e
631
+ }, null, 8, [
632
+ "label",
633
+ "disabled",
634
+ "loading"
635
+ ])]),
636
+ toolbar: w(() => [
637
+ d.value.length ? (h(), n(S(I), {
638
+ key: 0,
639
+ "model-value": v.value,
640
+ options: p.value,
641
+ "option-label": "label",
642
+ "option-value": "path",
643
+ "aria-label": "选择输出目录",
644
+ class: "kano-select-adaptive",
645
+ disabled: B.value,
646
+ "onUpdate:modelValue": u[0] ||= (e) => m.value = String(e)
647
+ }, null, 8, [
648
+ "model-value",
649
+ "options",
650
+ "disabled"
651
+ ])) : r("", !0),
652
+ s(S(E), {
653
+ items: le.value,
654
+ label: "输出子目录",
655
+ disabled: B.value,
656
+ onNavigate: u[1] ||= (e) => y.value = y.value.slice(0, le.value.findIndex((t) => t.path === e.path))
657
+ }, null, 8, ["items", "disabled"]),
658
+ s(S(M), null, {
659
+ leading: w(() => [s(S(P), {
660
+ modelValue: O.value,
661
+ "onUpdate:modelValue": u[2] ||= (e) => O.value = e,
662
+ width: "w-full",
663
+ class: "min-w-36 max-w-56 flex-1",
664
+ placeholder: "搜索文件名",
665
+ "aria-label": "搜索输出文件名",
666
+ disabled: B.value
667
+ }, null, 8, ["modelValue", "disabled"])]),
668
+ trailing: w(() => [s(S(I), {
669
+ modelValue: L.value,
670
+ "onUpdate:modelValue": u[4] ||= (e) => L.value = e,
671
+ options: ce,
672
+ "option-label": "label",
673
+ "option-value": "value",
674
+ "aria-label": "排序方式",
675
+ class: "kano-select-adaptive"
676
+ }, null, 8, ["modelValue"]), s(S(F), {
677
+ modelValue: A.value,
678
+ "onUpdate:modelValue": u[5] ||= (e) => A.value = e,
679
+ options: se,
680
+ variant: "inline",
681
+ label: "图库密度"
682
+ }, null, 8, ["modelValue"])]),
683
+ default: w(() => [s(S(F), {
684
+ modelValue: k.value,
685
+ "onUpdate:modelValue": u[3] ||= (e) => k.value = e,
686
+ options: ae,
687
+ label: "媒体类型",
688
+ variant: "inline",
689
+ disabled: B.value
690
+ }, null, 8, ["modelValue", "disabled"])]),
691
+ _: 1
692
+ })
693
+ ]),
694
+ default: w(() => [a("div", {
695
+ ref_key: "gridBlock",
696
+ ref: ue,
697
+ class: "space-y-3"
698
+ }, [
699
+ V.value.length ? (h(), i("div", Ae, [(h(!0), i(e, null, _(V.value, (e) => (h(), n(S(D), {
700
+ key: e,
701
+ label: e,
702
+ icon: "i-lucide-folder",
703
+ severity: "secondary",
704
+ class: "max-w-full",
705
+ pt: { label: { class: "truncate" } },
706
+ disabled: B.value,
707
+ onClick: (t) => y.value = [...y.value, e]
708
+ }, null, 8, [
709
+ "label",
710
+ "disabled",
711
+ "onClick"
712
+ ]))), 128))])) : r("", !0),
713
+ X.value ? (h(), i("p", je, x(X.value), 1)) : r("", !0),
714
+ $.value ? (h(), i("p", Me, x($.value), 1)) : r("", !0),
715
+ J.value && !Y.value ? (h(), i("div", Ne, [(h(), i(e, null, _(6, (e) => s(S(ne), {
716
+ key: e,
717
+ cover: "",
718
+ decorative: "",
719
+ lines: 0
720
+ })), 64))])) : W.value.length ? (h(), n(S(l), {
721
+ key: 4,
722
+ items: W.value,
723
+ "scroll-element": de.value,
724
+ "min-card-width": A.value === "compact" ? 144 : 220,
725
+ "aspect-ratio": 5 / 4,
726
+ active: "",
727
+ "loading-more": !1,
728
+ "has-more": !1,
729
+ "page-error": "",
730
+ "aria-label": "输出文件"
731
+ }, {
732
+ default: w(({ item: e }) => [s(S(D), {
733
+ unstyled: "",
734
+ "aria-label": e.name,
735
+ title: e.name,
736
+ "aria-pressed": R.value ? z.value.has(e.path) : void 0,
737
+ disabled: B.value,
738
+ class: f(["kano-card kano-card-hover relative block aspect-[4/5] w-full overflow-hidden text-left", R.value && z.value.has(e.path) && "border-[color:var(--kano-border-control-hover)] ring-2 ring-[color:var(--kano-border-control-hover)]"]),
739
+ onClick: (t) => pe(e.path)
740
+ }, {
741
+ default: w(() => [
742
+ e.kind === "image" ? (h(), i("img", {
743
+ key: 0,
744
+ src: c.api.fs.mediaFileUrl(e.path, e.modified),
745
+ alt: "",
746
+ loading: "lazy",
747
+ class: "absolute inset-0 size-full object-cover"
748
+ }, null, 8, Pe)) : (h(), i("div", Fe, [u[8] ||= a("span", {
749
+ class: "i-lucide-film size-9 text-text-muted",
750
+ "aria-hidden": "true"
751
+ }, null, -1), s(S(te), {
752
+ label: "视频",
753
+ variant: "overlay",
754
+ class: "absolute left-2 top-2"
755
+ })])),
756
+ R.value ? (h(), i("span", {
757
+ key: 2,
758
+ "aria-hidden": "true",
759
+ class: f(["absolute right-2 top-2 grid size-5 place-items-center rounded-md border shadow-sm transition-colors", z.value.has(e.path) ? "border-transparent bg-action-bg text-action-fg" : "border-border-control bg-surface-overlay/85"])
760
+ }, [z.value.has(e.path) ? (h(), i("span", Ie)) : r("", !0)], 2)) : r("", !0),
761
+ a("span", Le, x(e.name), 1)
762
+ ]),
763
+ _: 2
764
+ }, 1032, [
765
+ "aria-label",
766
+ "title",
767
+ "aria-pressed",
768
+ "disabled",
769
+ "class",
770
+ "onClick"
771
+ ])]),
772
+ _: 1
773
+ }, 8, [
774
+ "items",
775
+ "scroll-element",
776
+ "min-card-width"
777
+ ])) : !J.value && !X.value && (U.value || !V.value.length) ? (h(), n(S(j), {
778
+ key: 5,
779
+ icon: "i-lucide-images",
780
+ title: U.value ? "没有匹配的文件" : "此目录暂无图片或视频"
781
+ }, {
782
+ default: w(() => [U.value ? (h(), n(S(D), {
783
+ key: 0,
784
+ text: "",
785
+ severity: "secondary",
786
+ label: "清空筛选",
787
+ onClick: ye
788
+ })) : r("", !0)]),
789
+ _: 1
790
+ }, 8, ["title"])) : r("", !0)
791
+ ], 512), he.value ? (h(), n(ke, {
792
+ key: 0,
793
+ api: c.api,
794
+ "instance-id": c.instanceId,
795
+ "gallery-source": c.source,
796
+ item: he.value,
797
+ "has-previous": q.value > 0,
798
+ "has-next": q.value + 1 < W.value.length,
799
+ onMove: be,
800
+ onClose: u[7] ||= (e) => K.value = "",
801
+ onRemoved: xe
802
+ }, null, 8, [
803
+ "api",
804
+ "instance-id",
805
+ "gallery-source",
806
+ "item",
807
+ "has-previous",
808
+ "has-next"
809
+ ])) : r("", !0)]),
810
+ _: 2
811
+ }, [R.value ? {
812
+ name: "footer",
813
+ fn: w(() => [
814
+ a("span", Re, "已选 " + x(z.value.size) + " 个文件", 1),
815
+ s(S(D), {
816
+ severity: "secondary",
817
+ label: "全选当前结果",
818
+ disabled: B.value || !W.value.length,
819
+ onClick: u[6] ||= (e) => z.value = new Set(W.value.map((e) => e.path))
820
+ }, null, 8, ["disabled"]),
821
+ s(S(D), {
822
+ severity: "danger",
823
+ label: "移至回收站",
824
+ loading: B.value,
825
+ disabled: B.value || J.value || !z.value.size,
826
+ onClick: me
827
+ }, null, 8, ["loading", "disabled"])
828
+ ]),
829
+ key: "0"
830
+ } : void 0]), 1024));
831
+ }
832
+ }), Be = "kano:output-gallery", Ve = ae({
833
+ id: "output-gallery",
834
+ activate(e) {
835
+ e.services.provide(Be, { page: c({
836
+ props: {
837
+ instanceId: {
838
+ type: String,
839
+ required: !0
840
+ },
841
+ source: {
842
+ type: Object,
843
+ required: !0
844
+ }
845
+ },
846
+ setup: (t) => () => l(ze, {
847
+ ...t,
848
+ api: e
849
+ })
850
+ }) });
851
+ }
852
+ });
853
+ //#endregion
854
+ export { Ve as default };
package/dist/style.css ADDED
@@ -0,0 +1,2 @@
1
+ .media-viewport-frame[data-v-b09f18d7]{height:var(--media-viewport-height,64vh);flex:var(--media-viewport-flex,auto);min-height:12rem}.output-media[data-v-db8204b5]{--media-viewport-height:54vh}@media (min-width:64rem){.p-dialog-maximized{--media-viewport-height:0px;--media-viewport-flex:1 1 0;grid-template-rows:minmax(0,1fr);height:100%;max-height:none}}
2
+ /*$vite$:1*/
@@ -0,0 +1,5 @@
1
+ {
2
+ "payload": "eyJzY2hlbWEiOjEsInBhY2thZ2VOYW1lIjoiQHN5bmNzaGlvL2thbm8tcGx1Z2luLW91dHB1dC1nYWxsZXJ5IiwicGx1Z2luSWQiOiJvdXRwdXQtZ2FsbGVyeSIsInZlcnNpb24iOiIxLjAuMCIsImZpbGVzIjpbeyJwYXRoIjoicGFja2FnZS5qc29uIiwic2l6ZSI6NjExLCJzaGEyNTYiOiJhNjNjOWI1MmY2ZGQ5ZjA5MGVkODQ4ODdhZDIzNTJiMjNmNDM2YWFhNGMwYTBiYzllYTU5YmUyNDJhZjYzNWZkIn0seyJwYXRoIjoicGx1Z2luLmpzb24iLCJzaXplIjo1NzksInNoYTI1NiI6ImNhMjlmMGFhZDRiNGUzMmNiM2Y0OTNmNWZjNmFlN2ZkNWU1ODk4M2JiYjI5ZjExY2NhNzVlM2YwNTVkY2FkYmYifSx7InBhdGgiOiJkaXN0L2VudHJ5LmpzIiwic2l6ZSI6Mjk4NjMsInNoYTI1NiI6IjA5ZGZhNjZiYjhhYTZlMDNjOGIxNWM4NDJkY2Q5MWU1ODEzOWQ1ODkyZjIwYjhjMjdkNDRkZWQ4YzQ2MjE3MWYifSx7InBhdGgiOiJkaXN0L3N0eWxlLmNzcyIsInNpemUiOjM3MCwic2hhMjU2IjoiMGQ4MjBmNjc5NTFmY2FiY2NjZWI0M2MwN2M3MmU3OTE5YmViNGZlMDdkODkwNmI1M2UyZTZkMmM1MGI1ZTcxYyJ9XX0=",
3
+ "keyId": "release-1",
4
+ "signature": "a4sWXwb0UUeVEWEDRHqLNdoGMGCoe0YySLgXTugX2WmQh0exetL5TNBR4xJp4rQxsmjveNCnl37FWHotWwsdBQ=="
5
+ }
package/package.json CHANGED
@@ -1,6 +1,27 @@
1
1
  {
2
2
  "name": "@syncshio/kano-plugin-output-gallery",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "按应用实例浏览和整理生成的图片与视频",
6
+ "keywords": [
7
+ "kano-plugin"
8
+ ],
9
+ "files": [
10
+ "plugin.json",
11
+ "dist",
12
+ "kano-release.json"
13
+ ],
14
+ "kano": {
15
+ "manifest": "plugin.json"
16
+ },
17
+ "scripts": {
18
+ "build": "node ../../../scripts/build-plugins.mjs output-gallery"
19
+ },
20
+ "devDependencies": {
21
+ "@syncshio/kano-plugin-sdk": "file:../../../../kano-plugin-sdk"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org/"
26
+ }
27
+ }
package/plugin.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "manifestVersion": 2,
3
+ "id": "output-gallery",
4
+ "name": "输出图库",
5
+ "version": "1.0.0",
6
+ "description": "在应用工作区浏览生成的图片和视频,查看生成参数并整理输出文件",
7
+ "runtime": {
8
+ "entry": "dist/entry.js",
9
+ "style": "dist/style.css"
10
+ },
11
+ "permissions": {
12
+ "rpc": [
13
+ "fs.listDir",
14
+ "fs.exists",
15
+ "fs.mediaFileUrl",
16
+ "fs.readPngMetadata",
17
+ "fs.downloadToLocal",
18
+ "fs.trash"
19
+ ]
20
+ },
21
+ "engines": {
22
+ "kano": "^1.0.0",
23
+ "pluginSdk": "^4.0.0"
24
+ },
25
+ "keywords": [
26
+ "kano-plugin"
27
+ ]
28
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.