ai-ax 0.8.0 → 0.10.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/README.md +1 -1
- package/dist/{react.d.ts → client/react.d.ts} +2 -2
- package/dist/{react.js → client/react.js} +1 -1
- package/dist/client/ui.d.ts +656 -0
- package/dist/client/ui.js +7 -0
- package/dist/client.d.ts +6 -6
- package/dist/client.js +2 -2
- package/dist/hono/d1.d.ts +137 -0
- package/dist/hono/d1.js +1 -0
- package/dist/hono/r2.d.ts +194 -0
- package/dist/hono/r2.js +1 -0
- package/dist/hono.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/package.json +33 -5
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as e,useEffect as t,useState as n}from"react";const r=e=>({value:e,listeners:new Set}),i=(e,t)=>{typeof t==`function`&&(t=t(e.value)),e.value=t,e.listeners.forEach(e=>e(t))},a=e=>{let[r,i]=n(()=>e.value);return t(()=>{let t=e=>i(e);return e.listeners.add(t),r!==e.value&&i(e.value),()=>void e.listeners.delete(t)},[e]),r},o=t=>[a(t),e(e=>i(t,e),[t])],s=({atom:e,children:t})=>t(a(e)),c=(e,r)=>{let[,i]=n(0);return t(()=>{import(
|
|
1
|
+
import{useCallback as e,useEffect as t,useState as n}from"react";const r=e=>({value:e,listeners:new Set}),i=(e,t)=>{typeof t==`function`&&(t=t(e.value)),e.value=t,e.listeners.forEach(e=>e(t))},a=e=>{let[r,i]=n(()=>e.value);return t(()=>{let t=e=>i(e);return e.listeners.add(t),r!==e.value&&i(e.value),()=>void e.listeners.delete(t)},[e]),r},o=t=>[a(t),e(e=>i(t,e),[t])],s=({atom:e,children:t})=>t(a(e)),c=(e,r)=>{let[,i]=n(0);return t(()=>{import(`../client.js`).then(({client:t})=>t(e,r));let t=e.data(),n=()=>i(e=>e+1);return t.observe(n),()=>t.unobserve(n)},[e]),e},l=({ai:e,route:t,children:n})=>n(c(e,t));export{s as AtomValue,l as Client,r as atom,i as setAtom,o as useAtom,a as useAtomValue,c as useClient};
|
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/client/ui/share/icon.d.ts
|
|
3
|
+
interface IconProps {
|
|
4
|
+
name: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const Icon: ({ name, size, color, className }: IconProps) => import("react").JSX.Element;
|
|
10
|
+
declare const stop: <T extends {
|
|
11
|
+
stopPropagation: () => void;
|
|
12
|
+
}>(e: T) => void;
|
|
13
|
+
declare const prev: <T extends {
|
|
14
|
+
preventDefault: () => void;
|
|
15
|
+
}>(e: T) => void;
|
|
16
|
+
declare const Slot: ({ show, children }: {
|
|
17
|
+
show?: boolean;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}) => import("react").JSX.Element | null;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/client/ui/share/types.d.ts
|
|
22
|
+
interface Item {
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
icon?: string;
|
|
26
|
+
color?: string;
|
|
27
|
+
desc?: string;
|
|
28
|
+
top?: boolean;
|
|
29
|
+
}
|
|
30
|
+
interface Point {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
}
|
|
34
|
+
interface Placed {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
h: number;
|
|
38
|
+
}
|
|
39
|
+
interface PlaceInput {
|
|
40
|
+
align?: 'left' | 'right';
|
|
41
|
+
point?: Point | null;
|
|
42
|
+
gap?: number;
|
|
43
|
+
margin?: number;
|
|
44
|
+
}
|
|
45
|
+
interface Service {
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
noun: string;
|
|
49
|
+
icon: string;
|
|
50
|
+
color: string;
|
|
51
|
+
}
|
|
52
|
+
interface Storage {
|
|
53
|
+
used: number;
|
|
54
|
+
total: number;
|
|
55
|
+
text: string;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/client/ui/share/client.d.ts
|
|
59
|
+
interface PopProps {
|
|
60
|
+
items?: Item[];
|
|
61
|
+
value?: string;
|
|
62
|
+
pick?: (item: Item) => void;
|
|
63
|
+
align?: 'left' | 'right';
|
|
64
|
+
cls?: string;
|
|
65
|
+
point?: Point | null;
|
|
66
|
+
check?: string;
|
|
67
|
+
children?: ReactNode;
|
|
68
|
+
}
|
|
69
|
+
declare const Pop: ({ cls, items, value, pick, style, check, children }: PopProps & {
|
|
70
|
+
style?: any;
|
|
71
|
+
}) => import("react").JSX.Element;
|
|
72
|
+
declare const Drop: ({ items, value, pick, align, cls, point, check, children }: PopProps) => import("react").JSX.Element;
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/client/ui/share/place.d.ts
|
|
75
|
+
declare const place: (anchorEl?: Element | null, boxEl?: Element | null, input?: PlaceInput) => Placed | null;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/client/ui/share/date.d.ts
|
|
78
|
+
declare const stamp: (iso: string | number | Date) => string;
|
|
79
|
+
declare const sizeOf: (bytes: number) => string;
|
|
80
|
+
declare const usageOf: (bytes: number) => string;
|
|
81
|
+
declare const ago: (at: string | number) => string;
|
|
82
|
+
declare const unique: (name: string, taken: Set<string>) => string;
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/client/ui/share/const.d.ts
|
|
85
|
+
declare const ink = "#1f1f21";
|
|
86
|
+
declare const mute = "#8b8b8b";
|
|
87
|
+
declare const line = "#ececec";
|
|
88
|
+
declare const edge = "#d9d9d9";
|
|
89
|
+
declare const pale = "#fafafa";
|
|
90
|
+
declare const band = "#f1f1f1";
|
|
91
|
+
declare const fill = "#202020";
|
|
92
|
+
declare const blue = "#4185f4";
|
|
93
|
+
declare const side: {
|
|
94
|
+
row: number;
|
|
95
|
+
indent: number;
|
|
96
|
+
slot: number;
|
|
97
|
+
icon: number;
|
|
98
|
+
gap: number;
|
|
99
|
+
brand: number;
|
|
100
|
+
width: number;
|
|
101
|
+
};
|
|
102
|
+
declare const grid: {
|
|
103
|
+
card: number;
|
|
104
|
+
suggest: number;
|
|
105
|
+
};
|
|
106
|
+
declare const quota = 15360;
|
|
107
|
+
declare const uploadMax = 104857600;
|
|
108
|
+
declare const uploadAlert = "ファイルサイズが大きすぎます (上限 100 MB)";
|
|
109
|
+
declare const SP_BREAK = 768;
|
|
110
|
+
declare const GB = 1073741824;
|
|
111
|
+
declare const MB = 1048576;
|
|
112
|
+
declare const KB = 1024;
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/client/ui/gesture/drag/drop.d.ts
|
|
115
|
+
declare const createFileDrag: (onDrop: (id: string, drop: string) => void) => (id: string, zone?: string) => (el: Element | null) => undefined;
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/client/ui/gesture/drop/files.d.ts
|
|
118
|
+
interface Dropped {
|
|
119
|
+
path: string;
|
|
120
|
+
file: File | null;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/client/ui/gesture/drop/drop.d.ts
|
|
124
|
+
declare const createFileDrop: (zone: string, onDrop: (items: Dropped[], drop: string) => void, canDrop?: () => boolean) => (el: Element | null) => void;
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/client/ui/gesture/utils/utils.d.ts
|
|
127
|
+
declare const vec2: (x?: number, y?: number, out?: any[] | Float32Array<ArrayBuffer>) => Vec2;
|
|
128
|
+
type Vec2 = [x: number, y: number];
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/client/ui/gesture/utils/drag.d.ts
|
|
131
|
+
declare const dragEvent: <El extends Element = Element>(onDrag?: () => void, canStart?: (event: Event) => boolean) => any;
|
|
132
|
+
type DragState = ReturnType<typeof dragEvent>;
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/client/ui/gesture/utils/drop.d.ts
|
|
135
|
+
declare const dropEvent: <El extends Element = Element>(onDrop?: () => void, canStart?: (event: DragEvent) => boolean) => any;
|
|
136
|
+
type DropState = ReturnType<typeof dropEvent>;
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/client/ui/gesture/over/utils.d.ts
|
|
139
|
+
type Skip = (el: Element, drop: string) => boolean;
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/client/ui/gesture/over/over.d.ts
|
|
142
|
+
declare const createOver: () => {
|
|
143
|
+
begin(zone: string, skip?: Skip): void;
|
|
144
|
+
move(x: number, y: number): void;
|
|
145
|
+
read(): string | null;
|
|
146
|
+
end(): void;
|
|
147
|
+
};
|
|
148
|
+
type Over = ReturnType<typeof createOver>;
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/client/ui/gesture/drag/ghost.d.ts
|
|
151
|
+
declare const createGhost: () => {
|
|
152
|
+
start(source: Element | null, x?: number, y?: number): void;
|
|
153
|
+
move(x: number, y: number): void;
|
|
154
|
+
end(): void;
|
|
155
|
+
};
|
|
156
|
+
type Ghost = ReturnType<typeof createGhost>;
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/client/ui/gesture/drag/grab.d.ts
|
|
159
|
+
declare const createGrab: (id: string, zone: string, ghost: Ghost, over: Over, done: (drop: string) => void) => (el: Element | null) => undefined;
|
|
160
|
+
type Grab = ReturnType<typeof createGrab>;
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/client/ui/shell/atoms/band.d.ts
|
|
163
|
+
interface CardItem extends Item {
|
|
164
|
+
menu?: boolean;
|
|
165
|
+
}
|
|
166
|
+
interface BandProps {
|
|
167
|
+
cards: CardItem[];
|
|
168
|
+
click: (card: CardItem) => (e: any) => void;
|
|
169
|
+
popup: (card: CardItem) => ReactNode;
|
|
170
|
+
count?: number;
|
|
171
|
+
}
|
|
172
|
+
declare const Strip: ({ count, min, cls, children }: {
|
|
173
|
+
count: number;
|
|
174
|
+
min: number;
|
|
175
|
+
cls?: string;
|
|
176
|
+
children: ReactNode;
|
|
177
|
+
}) => import("react").JSX.Element;
|
|
178
|
+
declare const Cards: ({ cards, click, popup, count }: BandProps) => import("react").JSX.Element;
|
|
179
|
+
declare const Band: (props: BandProps) => import("react").JSX.Element;
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/client/ui/shell/atoms/head.d.ts
|
|
182
|
+
interface SpHeadProps {
|
|
183
|
+
icon: string;
|
|
184
|
+
color: string;
|
|
185
|
+
label: string;
|
|
186
|
+
home: () => void;
|
|
187
|
+
actions: ReactNode;
|
|
188
|
+
drawer: (e: any) => void;
|
|
189
|
+
}
|
|
190
|
+
interface MainHeadProps {
|
|
191
|
+
bar: boolean;
|
|
192
|
+
open: () => void;
|
|
193
|
+
title: ReactNode;
|
|
194
|
+
back?: () => void;
|
|
195
|
+
expand?: {
|
|
196
|
+
label: string;
|
|
197
|
+
icon: string;
|
|
198
|
+
on: boolean;
|
|
199
|
+
click: () => void;
|
|
200
|
+
};
|
|
201
|
+
actions: ReactNode;
|
|
202
|
+
}
|
|
203
|
+
declare const SpHead: ({ icon, color, label, home, actions, drawer }: SpHeadProps) => import("react").JSX.Element;
|
|
204
|
+
declare const MainHead: ({ bar, open, title, back, expand, actions }: MainHeadProps) => import("react").JSX.Element;
|
|
205
|
+
declare const HeadBtn: ({ icon, size, click, children }: {
|
|
206
|
+
icon: string;
|
|
207
|
+
size?: number;
|
|
208
|
+
click: (e: any) => void;
|
|
209
|
+
children?: ReactNode;
|
|
210
|
+
}) => import("react").JSX.Element;
|
|
211
|
+
declare const SpBtn: ({ icon, size, click, children }: {
|
|
212
|
+
icon: string;
|
|
213
|
+
size?: number;
|
|
214
|
+
click: (e: any) => void;
|
|
215
|
+
children?: ReactNode;
|
|
216
|
+
}) => import("react").JSX.Element;
|
|
217
|
+
declare const MoreIcon: string;
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/client/ui/shell/atoms/main.d.ts
|
|
220
|
+
interface AppProps {
|
|
221
|
+
drawer: boolean;
|
|
222
|
+
close: () => void;
|
|
223
|
+
dropRef?: any;
|
|
224
|
+
children: ReactNode;
|
|
225
|
+
}
|
|
226
|
+
declare const Frame: ({ drawer, close, dropRef, children }: AppProps) => import("react").JSX.Element;
|
|
227
|
+
declare const Main: ({ drop, from, children }: {
|
|
228
|
+
drop?: string;
|
|
229
|
+
from?: string;
|
|
230
|
+
children: ReactNode;
|
|
231
|
+
}) => import("react").JSX.Element;
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/client/ui/shell/atoms/row.d.ts
|
|
234
|
+
interface RowProps {
|
|
235
|
+
depth?: number;
|
|
236
|
+
on?: boolean;
|
|
237
|
+
open?: boolean;
|
|
238
|
+
turn?: (e: any) => void;
|
|
239
|
+
icon: string;
|
|
240
|
+
color?: string;
|
|
241
|
+
label: ReactNode;
|
|
242
|
+
drop?: string;
|
|
243
|
+
mark?: string;
|
|
244
|
+
from?: string;
|
|
245
|
+
click?: (e: any) => void;
|
|
246
|
+
dclick?: (e: any) => void;
|
|
247
|
+
rclick?: (e: any) => void;
|
|
248
|
+
dragRef?: any;
|
|
249
|
+
children?: ReactNode;
|
|
250
|
+
}
|
|
251
|
+
declare const rowCls: (on: boolean) => string;
|
|
252
|
+
declare const Fold: ({ open, turn }: {
|
|
253
|
+
open?: boolean;
|
|
254
|
+
turn?: (e: any) => void;
|
|
255
|
+
}) => import("react").JSX.Element;
|
|
256
|
+
declare const Row: ({ depth, on, open, turn, icon, color, label, drop, mark, from, click, dclick, rclick, dragRef, children }: RowProps) => import("react").JSX.Element;
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/client/ui/shell/atoms/side.d.ts
|
|
259
|
+
interface BrandProps {
|
|
260
|
+
icon: string;
|
|
261
|
+
color: string;
|
|
262
|
+
label: string;
|
|
263
|
+
click: () => void;
|
|
264
|
+
}
|
|
265
|
+
interface SideProps {
|
|
266
|
+
brand: BrandProps;
|
|
267
|
+
bar: boolean;
|
|
268
|
+
drawer: boolean;
|
|
269
|
+
fold: () => void;
|
|
270
|
+
close: () => void;
|
|
271
|
+
press: (e: any) => void;
|
|
272
|
+
storage: Storage;
|
|
273
|
+
upgrade: () => void;
|
|
274
|
+
menu?: ReactNode;
|
|
275
|
+
more: (e: any) => void;
|
|
276
|
+
children: ReactNode;
|
|
277
|
+
}
|
|
278
|
+
declare const Brand: ({ icon, color, label, click }: BrandProps) => import("react").JSX.Element;
|
|
279
|
+
declare const Storage_: ({ storage, upgrade, menu, more }: Pick<SideProps, 'storage' | 'upgrade' | 'menu' | 'more'>) => import("react").JSX.Element;
|
|
280
|
+
declare const Side: ({ brand, bar, drawer, fold, close, press, storage, upgrade, menu, more, children }: SideProps) => import("react").JSX.Element;
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/client/ui/drive/types.d.ts
|
|
283
|
+
interface Obj {
|
|
284
|
+
path: string;
|
|
285
|
+
size: number;
|
|
286
|
+
date: string;
|
|
287
|
+
kind?: string;
|
|
288
|
+
etag?: string;
|
|
289
|
+
}
|
|
290
|
+
interface Entry {
|
|
291
|
+
id: string;
|
|
292
|
+
name: string;
|
|
293
|
+
kind: string;
|
|
294
|
+
owner: string;
|
|
295
|
+
date: string;
|
|
296
|
+
iso: string;
|
|
297
|
+
size: string;
|
|
298
|
+
bytes: number;
|
|
299
|
+
parent: string;
|
|
300
|
+
pinned?: boolean;
|
|
301
|
+
trashed?: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface DriveConfig {
|
|
304
|
+
base: string;
|
|
305
|
+
trash: string;
|
|
306
|
+
editors: string[];
|
|
307
|
+
}
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/client/ui/shell/atoms/tree.d.ts
|
|
310
|
+
interface TreeProps {
|
|
311
|
+
files: Entry[];
|
|
312
|
+
parent: string;
|
|
313
|
+
depth: number;
|
|
314
|
+
expand: string[];
|
|
315
|
+
active: string;
|
|
316
|
+
kinds: Record<string, {
|
|
317
|
+
icon: string;
|
|
318
|
+
color: string;
|
|
319
|
+
}>;
|
|
320
|
+
fold: (id: string) => (e: any) => void;
|
|
321
|
+
enter: (id: string) => (e: any) => void;
|
|
322
|
+
open: (e: Entry) => (ev: any) => void;
|
|
323
|
+
menu: (e: Entry) => ReactNode;
|
|
324
|
+
rclick: (e: Entry) => (ev: any) => void;
|
|
325
|
+
drag: (id: string, zone?: string) => any;
|
|
326
|
+
}
|
|
327
|
+
declare const DriveTree: (props: TreeProps) => any;
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/client/ui/shell/atoms.d.ts
|
|
330
|
+
declare const drawerAtom: {
|
|
331
|
+
value: boolean;
|
|
332
|
+
listeners: Set<(v: boolean) => void>;
|
|
333
|
+
};
|
|
334
|
+
declare const pointAtom: {
|
|
335
|
+
value: Point | null;
|
|
336
|
+
listeners: Set<(v: Point | null) => void>;
|
|
337
|
+
};
|
|
338
|
+
declare const isDrawerOpen: () => boolean;
|
|
339
|
+
declare const useDrawer: () => boolean;
|
|
340
|
+
declare const usePoint: () => Point | null;
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/client/ui/shell/clicks.d.ts
|
|
343
|
+
declare const openDrawer: (e: any) => void;
|
|
344
|
+
declare const closeDrawer: () => void;
|
|
345
|
+
declare const atPoint: (e: any) => void;
|
|
346
|
+
declare const noPoint: () => void;
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/client/ui/shell/const.d.ts
|
|
349
|
+
declare const storageName = "STORAGE";
|
|
350
|
+
declare const upgradeLabel = "アップグレード";
|
|
351
|
+
declare const upgradeUrl = "https://stripe.com";
|
|
352
|
+
declare const emptyTrashAsk = "ゴミ箱を空にしますか?中のアイテムは完全に削除されます";
|
|
353
|
+
declare const storageMenu: Item[];
|
|
354
|
+
declare const pageMenu: Item[];
|
|
355
|
+
declare const spMenu: Item[];
|
|
356
|
+
declare const bandIcon: string;
|
|
357
|
+
declare const moreItems: (on: boolean, label: string, items: Item[]) => Item[];
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/client/ui/shell/icons.d.ts
|
|
360
|
+
declare const icons: {
|
|
361
|
+
add: string;
|
|
362
|
+
arrowBack: string;
|
|
363
|
+
arrowDropDown: string;
|
|
364
|
+
check: string;
|
|
365
|
+
chevronRight: string;
|
|
366
|
+
closeIcon: string;
|
|
367
|
+
cloud: string;
|
|
368
|
+
deleteIcon: string;
|
|
369
|
+
folder: string;
|
|
370
|
+
home: string;
|
|
371
|
+
keep: string;
|
|
372
|
+
keepFill: string;
|
|
373
|
+
leftPanelClose: string;
|
|
374
|
+
leftPanelOpen: string;
|
|
375
|
+
menuIcon: string;
|
|
376
|
+
moreVert: string;
|
|
377
|
+
redoIcon: string;
|
|
378
|
+
schedule: string;
|
|
379
|
+
searchIcon: string;
|
|
380
|
+
settings: string;
|
|
381
|
+
help: string;
|
|
382
|
+
keyboard: string;
|
|
383
|
+
sync: string;
|
|
384
|
+
undoIcon: string;
|
|
385
|
+
unfoldMore: string;
|
|
386
|
+
visibilityOff: string;
|
|
387
|
+
createNewFolder: string;
|
|
388
|
+
uploadFile: string;
|
|
389
|
+
driveFolderUpload: string;
|
|
390
|
+
edit: string;
|
|
391
|
+
download: string;
|
|
392
|
+
info: string;
|
|
393
|
+
openInNew: string;
|
|
394
|
+
restoreFromTrash: string;
|
|
395
|
+
description: string;
|
|
396
|
+
};
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/client/ui/drive/config.d.ts
|
|
399
|
+
declare const config$1: DriveConfig;
|
|
400
|
+
declare const configure$1: (next: Partial<DriveConfig>) => undefined;
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/client/ui/drive/client.d.ts
|
|
403
|
+
declare const url: (path: string) => string;
|
|
404
|
+
declare const r2: {
|
|
405
|
+
list(prefix?: string): Promise<Obj[]>;
|
|
406
|
+
get(path: string): Promise<Response>;
|
|
407
|
+
put(path: string, body: any, meta?: {
|
|
408
|
+
kind?: string;
|
|
409
|
+
site?: string;
|
|
410
|
+
type?: string;
|
|
411
|
+
}): Promise<Obj>;
|
|
412
|
+
move(from: string, to: string): Promise<Response>;
|
|
413
|
+
remove(path: string): Promise<Response>;
|
|
414
|
+
};
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/client/ui/drive/path.d.ts
|
|
417
|
+
declare const pathname: (name: string, parent: string) => string;
|
|
418
|
+
declare const parentOf: (id: string) => string;
|
|
419
|
+
declare const idOf: (o: Obj) => string;
|
|
420
|
+
declare const ancestors: (id: string) => string[];
|
|
421
|
+
declare const extOf: (name: string) => string;
|
|
422
|
+
declare const kindOf: (name: string) => "file" | "jpg" | "mp4" | "pdf" | "xlsx";
|
|
423
|
+
declare const entryOf: (o: Obj, prev?: Entry) => Entry;
|
|
424
|
+
declare const freeName: (name: string, rows: Entry[], parent: string, trashed?: boolean) => string;
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/client/ui/drive/tree.d.ts
|
|
427
|
+
declare const isFolder: (e: Entry) => boolean;
|
|
428
|
+
declare const treeOf: (files: Entry[], parent: string) => Entry[];
|
|
429
|
+
declare const kindRows: (files: Entry[], kind: string) => Entry[];
|
|
430
|
+
declare const recentRows: (files: Entry[]) => Entry[];
|
|
431
|
+
declare const trashRows: (files: Entry[]) => Entry[];
|
|
432
|
+
declare const storageRows: (files: Entry[]) => Entry[];
|
|
433
|
+
declare const folderRows: (files: Entry[], folder: string) => Entry[];
|
|
434
|
+
declare const crumbSegs: (path: string) => {
|
|
435
|
+
name: string;
|
|
436
|
+
path: string;
|
|
437
|
+
}[];
|
|
438
|
+
declare const usedOf: (files: Entry[]) => number;
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/client/ui/drive/acts.d.ts
|
|
441
|
+
declare const mirrorFile: (ai: any, o: any) => Entry;
|
|
442
|
+
declare const saveFile: (ai: any, kind: string, name: string, parent: string, body: any, site?: string) => Promise<Entry>;
|
|
443
|
+
declare const mkdirp: (ai: any, path: string, base?: string) => Promise<string>;
|
|
444
|
+
declare const storeFiles: (ai: any, items: {
|
|
445
|
+
path: string;
|
|
446
|
+
file: File | null;
|
|
447
|
+
}[], base: string) => Promise<void>;
|
|
448
|
+
declare const syncFiles: (_input: any, ai: any) => Promise<string>;
|
|
449
|
+
declare const moveFile: ({ id, dir }: {
|
|
450
|
+
id: string;
|
|
451
|
+
dir: string;
|
|
452
|
+
}, ai: any) => Promise<string>;
|
|
453
|
+
declare const removeFile: ({ id }: {
|
|
454
|
+
id: string;
|
|
455
|
+
}, ai: any) => Promise<string>;
|
|
456
|
+
declare const restoreFile: ({ id }: {
|
|
457
|
+
id: string;
|
|
458
|
+
}, ai: any) => Promise<string>;
|
|
459
|
+
declare const renameFile: ({ id, name }: {
|
|
460
|
+
id: string;
|
|
461
|
+
name: string;
|
|
462
|
+
}, ai: any) => Promise<string>;
|
|
463
|
+
declare const emptyTrash: (_input: any, ai: any) => Promise<string>;
|
|
464
|
+
declare const usedBytes: (ai: any) => number;
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/client/ui/chat/client.d.ts
|
|
467
|
+
declare const AiChatButton: () => import("react").JSX.Element;
|
|
468
|
+
declare const AiChat: () => import("react").JSX.Element | null;
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/client/ui/chat/clicks.d.ts
|
|
471
|
+
declare const openChat: () => void;
|
|
472
|
+
declare const closeChat: () => void;
|
|
473
|
+
declare const toggleChat: () => void;
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region src/client/ui/chat/types.d.ts
|
|
476
|
+
interface ChatTool {
|
|
477
|
+
icon?: string;
|
|
478
|
+
label: string;
|
|
479
|
+
}
|
|
480
|
+
interface ChatMsg {
|
|
481
|
+
role: 'agent' | 'user';
|
|
482
|
+
text: string;
|
|
483
|
+
tools?: ChatTool[];
|
|
484
|
+
}
|
|
485
|
+
interface ChatPrompt {
|
|
486
|
+
icon?: string;
|
|
487
|
+
color?: string;
|
|
488
|
+
label: string;
|
|
489
|
+
prompt?: string;
|
|
490
|
+
}
|
|
491
|
+
interface ChatHello {
|
|
492
|
+
greet: string;
|
|
493
|
+
title: string;
|
|
494
|
+
desc: string;
|
|
495
|
+
prompts: ChatPrompt[];
|
|
496
|
+
}
|
|
497
|
+
interface ChatMenu {
|
|
498
|
+
useOpen: () => string;
|
|
499
|
+
flip: (id: string) => (e: any) => void;
|
|
500
|
+
close: () => void;
|
|
501
|
+
}
|
|
502
|
+
interface ChatCommand {
|
|
503
|
+
name: string;
|
|
504
|
+
desc: string;
|
|
505
|
+
label?: string;
|
|
506
|
+
run: () => any;
|
|
507
|
+
}
|
|
508
|
+
interface ChatStreamTool {
|
|
509
|
+
server: string;
|
|
510
|
+
name: string;
|
|
511
|
+
}
|
|
512
|
+
interface ChatStreamItem {
|
|
513
|
+
text: string;
|
|
514
|
+
tools: ChatStreamTool[];
|
|
515
|
+
error?: boolean;
|
|
516
|
+
}
|
|
517
|
+
interface ChatStreamSend {
|
|
518
|
+
prompt: string;
|
|
519
|
+
path?: string;
|
|
520
|
+
model?: string;
|
|
521
|
+
messages?: any[];
|
|
522
|
+
headers?: Record<string, string>;
|
|
523
|
+
}
|
|
524
|
+
interface ChatStreamUpdate {
|
|
525
|
+
items: ChatStreamItem[];
|
|
526
|
+
delta: string;
|
|
527
|
+
raw: string;
|
|
528
|
+
}
|
|
529
|
+
interface ChatStream {
|
|
530
|
+
parse: (raw: string) => ChatStreamItem[];
|
|
531
|
+
send: (input: ChatStreamSend, update?: (u: ChatStreamUpdate) => void) => Promise<ChatStreamItem[]>;
|
|
532
|
+
}
|
|
533
|
+
interface ChatConfig {
|
|
534
|
+
send: (input: {
|
|
535
|
+
prompt: string;
|
|
536
|
+
}) => Promise<string>;
|
|
537
|
+
stream: ChatStream;
|
|
538
|
+
icon: string;
|
|
539
|
+
path: string;
|
|
540
|
+
headers: Record<string, string>;
|
|
541
|
+
hello: () => ChatHello;
|
|
542
|
+
menu: ChatMenu;
|
|
543
|
+
commands: () => ChatCommand[];
|
|
544
|
+
hints: (msgs: ChatMsg[]) => ChatCommand[];
|
|
545
|
+
}
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/client/ui/chat/config.d.ts
|
|
548
|
+
declare const config: ChatConfig;
|
|
549
|
+
declare const configure: (next: Partial<ChatConfig>) => undefined;
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/client/ui/chat/stream.d.ts
|
|
552
|
+
declare const toMsg: (it: ChatStreamItem) => ChatMsg;
|
|
553
|
+
declare const restoreChat: (talks: {
|
|
554
|
+
prompt: string;
|
|
555
|
+
reply: string;
|
|
556
|
+
tools: string[];
|
|
557
|
+
}[]) => void;
|
|
558
|
+
declare const runChat: (prompt: string) => Promise<string>;
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region src/client/ui/chat/utils/commands/types.d.ts
|
|
561
|
+
interface Command {
|
|
562
|
+
name: string;
|
|
563
|
+
desc: string;
|
|
564
|
+
label?: string;
|
|
565
|
+
run: () => any;
|
|
566
|
+
}
|
|
567
|
+
interface Habit {
|
|
568
|
+
name: string;
|
|
569
|
+
part: number;
|
|
570
|
+
after: string;
|
|
571
|
+
count: number;
|
|
572
|
+
}
|
|
573
|
+
interface CommandConfig {
|
|
574
|
+
store: {
|
|
575
|
+
list: () => Promise<Habit[]>;
|
|
576
|
+
save: (habit: {
|
|
577
|
+
name: string;
|
|
578
|
+
part: number;
|
|
579
|
+
after: string;
|
|
580
|
+
}) => any;
|
|
581
|
+
};
|
|
582
|
+
deck: Command[];
|
|
583
|
+
greet: {
|
|
584
|
+
greet: string;
|
|
585
|
+
title: string;
|
|
586
|
+
desc: string;
|
|
587
|
+
};
|
|
588
|
+
starters: () => string[];
|
|
589
|
+
pinned: () => string[];
|
|
590
|
+
hinted: (msgs: any[]) => string[];
|
|
591
|
+
}
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/client/ui/chat/utils/commands/index.d.ts
|
|
594
|
+
declare const createCommands: (config: CommandConfig) => {
|
|
595
|
+
commands: () => Command[];
|
|
596
|
+
hello: () => {
|
|
597
|
+
greet: string;
|
|
598
|
+
title: string;
|
|
599
|
+
desc: string;
|
|
600
|
+
prompts: {
|
|
601
|
+
label: string;
|
|
602
|
+
prompt: string;
|
|
603
|
+
}[];
|
|
604
|
+
};
|
|
605
|
+
hints: (msgs: any[]) => Command[];
|
|
606
|
+
prime: () => Promise<void>;
|
|
607
|
+
};
|
|
608
|
+
//#endregion
|
|
609
|
+
//#region src/client/ui/chat/utils/history/types.d.ts
|
|
610
|
+
interface HistoryTalk {
|
|
611
|
+
prompt: string;
|
|
612
|
+
reply: string;
|
|
613
|
+
tools: string[];
|
|
614
|
+
}
|
|
615
|
+
interface HistoryStore {
|
|
616
|
+
list: () => Promise<any[]>;
|
|
617
|
+
load: (chatId: string) => Promise<{
|
|
618
|
+
talks: any[];
|
|
619
|
+
tools: any[];
|
|
620
|
+
}>;
|
|
621
|
+
save: (chatId: string, body: any) => any;
|
|
622
|
+
}
|
|
623
|
+
interface HistoryConfig {
|
|
624
|
+
store: HistoryStore;
|
|
625
|
+
show: (talks: HistoryTalk[]) => void;
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region src/client/ui/chat/utils/history/index.d.ts
|
|
629
|
+
declare const createHistory: (config: HistoryConfig) => {
|
|
630
|
+
wrap: <T extends {
|
|
631
|
+
send: any;
|
|
632
|
+
}>(base: T) => T;
|
|
633
|
+
reset: () => void;
|
|
634
|
+
load: (id: string) => Promise<void>;
|
|
635
|
+
list: () => Promise<any[]>;
|
|
636
|
+
};
|
|
637
|
+
type History = ReturnType<typeof createHistory>;
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/client/ui/chat/utils/markdown.d.ts
|
|
640
|
+
declare const markdown: {
|
|
641
|
+
render: (text: string) => string;
|
|
642
|
+
plain: (text: string) => string;
|
|
643
|
+
};
|
|
644
|
+
//#endregion
|
|
645
|
+
//#region src/client/ui/chat/atoms.d.ts
|
|
646
|
+
declare const isChatBusy: () => boolean;
|
|
647
|
+
declare const useChatBusy: () => boolean;
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/client/ui/chat/const.d.ts
|
|
650
|
+
declare const models: {
|
|
651
|
+
id: string;
|
|
652
|
+
label: string;
|
|
653
|
+
desc: string;
|
|
654
|
+
}[];
|
|
655
|
+
//#endregion
|
|
656
|
+
export { AiChat, AiChatButton, AppProps, Band, BandProps, Brand, BrandProps, CardItem, Cards, type ChatCommand, type ChatConfig, type ChatHello, type ChatMsg, type ChatPrompt, type ChatTool, type Command, type CommandConfig, type DragState, type DriveConfig, DriveTree, Drop, type DropState, type Dropped, type Entry, Fold, Frame, GB, type Grab, type Habit, HeadBtn, type History, type HistoryConfig, type HistoryStore, type HistoryTalk, Icon, type Item, KB, MB, Main, MainHead, MainHeadProps, MoreIcon, type Obj, type Over, type PlaceInput, type Placed, type Point, Pop, Row, RowProps, SP_BREAK, type Service, Side, SideProps, type Skip, Slot, SpBtn, SpHead, SpHeadProps, type Storage, Storage_, Strip, TreeProps, ago, ancestors, atPoint, band, bandIcon, blue, config as chatConfig, closeChat, closeDrawer, configure as configureChat, configure$1 as configureDrive, createCommands, createFileDrag, createFileDrop, createHistory, createOver, crumbSegs, dragEvent, drawerAtom, config$1 as driveConfig, dropEvent, edge, emptyTrash, emptyTrashAsk, entryOf, extOf, fill, folderRows, freeName, grid, icons, idOf, ink, isChatBusy, isDrawerOpen, isFolder, kindOf, kindRows, line, markdown, mirrorFile, mkdirp, models, moreItems, moveFile, mute, noPoint, openChat, openDrawer, pageMenu, pale, parentOf, pathname, place, pointAtom, prev, quota, r2, recentRows, removeFile, renameFile, restoreChat, restoreFile, rowCls, runChat, saveFile, side, sizeOf, spMenu, stamp, stop, storageMenu, storageName, storageRows, storeFiles, syncFiles, toMsg, toggleChat, trashRows, treeOf, unique, upgradeLabel, upgradeUrl, uploadAlert, uploadMax, url, usageOf, useChatBusy, useDrawer, usePoint, usedBytes, usedOf, vec2 };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{atom as e,setAtom as t,useAtomValue as n}from"./react.js";import{useEffect as r,useLayoutEffect as i,useRef as a,useState as o}from"react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import u from"@material-symbols/svg-400/outlined/add.svg?raw";import d from"@material-symbols/svg-400/outlined/arrow_back.svg?raw";import f from"@material-symbols/svg-400/outlined/arrow_drop_down.svg?raw";import p,{default as m}from"@material-symbols/svg-400/outlined/check.svg?raw";import h from"@material-symbols/svg-400/outlined/chevron_right.svg?raw";import g,{default as ee}from"@material-symbols/svg-400/outlined/close.svg?raw";import te from"@material-symbols/svg-400/outlined/cloud.svg?raw";import ne from"@material-symbols/svg-400/outlined/delete.svg?raw";import re from"@material-symbols/svg-400/outlined/folder.svg?raw";import ie from"@material-symbols/svg-400/outlined/home.svg?raw";import ae from"@material-symbols/svg-400/outlined/keep.svg?raw";import oe from"@material-symbols/svg-400/outlined/keep-fill.svg?raw";import se from"@material-symbols/svg-400/outlined/left_panel_close.svg?raw";import ce from"@material-symbols/svg-400/outlined/left_panel_open.svg?raw";import le from"@material-symbols/svg-400/outlined/menu.svg?raw";import ue from"@material-symbols/svg-400/outlined/more_vert.svg?raw";import de from"@material-symbols/svg-400/outlined/redo.svg?raw";import fe from"@material-symbols/svg-400/outlined/schedule.svg?raw";import pe,{default as me}from"@material-symbols/svg-400/outlined/search.svg?raw";import he from"@material-symbols/svg-400/outlined/settings.svg?raw";import ge from"@material-symbols/svg-400/outlined/help.svg?raw";import _e from"@material-symbols/svg-400/outlined/keyboard.svg?raw";import ve from"@material-symbols/svg-400/outlined/sync.svg?raw";import ye from"@material-symbols/svg-400/outlined/undo.svg?raw";import be from"@material-symbols/svg-400/outlined/unfold_more.svg?raw";import xe from"@material-symbols/svg-400/outlined/visibility_off.svg?raw";import Se from"@material-symbols/svg-400/outlined/create_new_folder.svg?raw";import Ce from"@material-symbols/svg-400/outlined/upload_file.svg?raw";import we from"@material-symbols/svg-400/outlined/drive_folder_upload.svg?raw";import Te from"@material-symbols/svg-400/outlined/edit.svg?raw";import Ee from"@material-symbols/svg-400/outlined/download.svg?raw";import De from"@material-symbols/svg-400/outlined/info.svg?raw";import Oe from"@material-symbols/svg-400/outlined/open_in_new.svg?raw";import ke from"@material-symbols/svg-400/outlined/restore_from_trash.svg?raw";import Ae from"@material-symbols/svg-400/outlined/description.svg?raw";import je from"@material-symbols/svg-400/outlined/support_agent.svg?raw";import Me from"@material-symbols/svg-400/outlined/drag_indicator.svg?raw";import Ne from"@material-symbols/svg-400/outlined/mic.svg?raw";import Pe from"@material-symbols/svg-400/outlined/send.svg?raw";import Fe from"@material-symbols/svg-400/outlined/stop_circle.svg?raw";import Ie from"@material-symbols/svg-400/outlined/graphic_eq.svg?raw";import Le from"@material-symbols/svg-400/outlined/attach_file_add.svg?raw";import Re from"@material-symbols/svg-400/outlined/keyboard_arrow_down.svg?raw";import ze from"@material-symbols/svg-400/outlined/more_horiz.svg?raw";import Be from"markdown-it";const _=({name:e,size:t=20,color:n,className:r=``})=>c(`span`,{className:`inline-block shrink-0 [&>svg]:h-full [&>svg]:w-full [&>svg]:fill-current ${r}`,style:{width:t,height:t,color:n},dangerouslySetInnerHTML:{__html:e}}),Ve=e=>e.stopPropagation(),He=e=>e.preventDefault(),Ue=({show:e,children:t})=>e?c(s,{children:t}):null,We=(e,t,n={})=>{let{align:r=`right`,point:i=null,gap:a=4,margin:o=8}=n,s=e?.getBoundingClientRect(),c=t?.getBoundingClientRect(),l=i?{left:i.x,right:i.x,top:i.y,bottom:i.y}:s;if(!l||!c)return null;let u=window.innerWidth,d=window.innerHeight,f=Math.min(c.height,d-o*2),p=i||r===`left`?l.left:l.right-c.width,m=Math.min(Math.max(o,p),Math.max(o,u-c.width-o)),h=l.bottom+a;return{x:m,y:h+f>d-o?Math.max(o,l.top-f-a):h,h:f}},Ge=({m:e,value:t,check:n})=>l(s,{children:[l(`span`,{className:`flex min-w-0 flex-1 flex-col items-start`,children:[c(`span`,{className:`truncate`,children:e.label}),c(`span`,{className:`truncate text-[12px] text-mute`,children:e.desc})]}),t===e.id&&c(_,{name:n,size:18,color:`#4185f4`})]}),Ke=({m:e,value:t,check:n})=>l(s,{children:[t===e.id&&c(_,{name:n,size:18}),t!==e.id&&e.icon&&c(_,{name:e.icon,size:18,color:e.color,className:e.color?``:`text-mute`}),t!==e.id&&!e.icon&&c(`span`,{className:`w-[18px] shrink-0`}),c(`span`,{className:`truncate`,children:e.label})]}),qe=({cls:e=``,items:t=[],value:n,pick:r,style:i,check:a=``,children:o})=>c(`div`,{className:`absolute z-50 rounded-xl border border-line bg-white py-2 shadow-[0_8px_24px_rgba(0,0,0,0.12)] ${e}`,style:i,onClick:Ve,children:o??t.map(e=>c(`div`,{className:e.top?`mt-2 border-t border-line pt-2`:``,children:c(`button`,{onClick:()=>r?.(e),className:`flex w-full items-center gap-3 px-4 text-left hover:bg-pale ${e.desc?`py-2`:`h-11`}`,children:e.desc?c(Ge,{m:e,value:n,check:a}):c(Ke,{m:e,value:n,check:a})})},e.id))}),Je=({items:e,value:t,pick:n,align:r=`right`,cls:u=`w-72`,point:d,check:f,children:p})=>{let m=a(null),h=a(null),[g,ee]=o(null);return i(()=>ee(We(m.current?.parentElement,h.current?.firstElementChild,{align:r,point:d})),[]),l(s,{children:[c(`span`,{ref:m,className:`absolute h-0 w-0`}),c(`div`,{ref:h,className:`fixed z-50`,style:g?{left:g.x,top:g.y}:{left:0,top:0,visibility:`hidden`},children:c(qe,{cls:`left-0 top-0 overflow-y-auto ${u}`,style:{maxHeight:g?.h??window.innerHeight-16},items:e,value:t,pick:n,check:f,children:p})})]})},Ye=`#1f1f21`,Xe=`#8b8b8b`,Ze=`#ececec`,Qe=`#d9d9d9`,$e=`#fafafa`,et=`#f1f1f1`,tt=`#202020`,nt=`#4185f4`,v={row:36,indent:20,slot:20,icon:20,gap:8,brand:22,width:233},rt={card:200,suggest:264},it=15360,at=104857600,ot=`ファイルサイズが大きすぎます (上限 100 MB)`,st=768,ct=1073741824,lt=1048576,ut=1024,dt=e=>String(e).padStart(2,`0`),ft=e=>{let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${t.getHours()}:${dt(t.getMinutes())}`:t.getFullYear()===n.getFullYear()?`${t.getMonth()+1}月${t.getDate()}日`:`${t.getFullYear()}/${dt(t.getMonth()+1)}/${dt(t.getDate())}`},pt=e=>e>=1048576?`${(e/lt).toFixed(1)} MB`:e>=1024?`${Math.round(e/ut)} KB`:`${e} B`,mt=e=>e>=1073741824?`${(e/ct).toFixed(2)} GB`:`${Math.round(e/lt)} MB`,ht=e=>{let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?`たった今`:t<3600?`${Math.floor(t/60)} 分前`:t<86400?`${Math.floor(t/3600)} 時間前`:`${Math.floor(t/86400)} 日前`},gt=(e,t)=>{if(!t.has(e))return e;let n=e.lastIndexOf(`.`),r=n>0?e.slice(0,n):e,i=n>0?e.slice(n):``,a=1;for(;t.has(`${r}(${a})${i}`);)a++;return`${r}(${a})${i}`},_t={position:`fixed`,left:`0`,top:`0`,zIndex:`60`,overflow:`hidden`,pointerEvents:`none`,background:`#fff`,transition:`width 0.16s ease, height 0.16s ease, left 0.16s ease, top 0.16s ease`},vt={width:`100%`,height:`100%`},yt={width:`264px`,height:`62px`,borderRadius:`12px`,boxShadow:`0 8px 24px rgba(0, 0, 0, 0.12)`},bt={display:`flex`,alignItems:`center`,padding:`12px`,border:`1px solid ${Qe}`,borderRadius:`12px`,background:`#fff`},y=(e,t)=>Object.assign(e.style,t),xt=()=>{let e=null,t=0,n=0;return{start(r,i,a){if(!r||e)return;let o=r.getBoundingClientRect(),s=r.cloneNode(!0);t=i??o.left,n=a??o.top,e=document.createElement(`div`),y(e,_t),y(s,vt),e.appendChild(s),e.style.left=`${o.left}px`,e.style.top=`${o.top}px`,e.style.width=`${o.width}px`,e.style.height=`${o.height}px`,document.body.appendChild(e),requestAnimationFrame(()=>{e&&(y(e,yt),y(s,bt),s.querySelectorAll(`[data-ghost-hide]`).forEach(e=>y(e,{display:`none`})),e.style.left=`${t}px`,e.style.top=`${n}px`)})},move(r,i){e&&(e.style.transform=`translate(${r-t}px, ${i-n}px)`)},end(){e?.remove(),e=null}}},St=(e,t)=>{let n=e.getAttribute(`data-drop-from`);return n===null||n.split(` `).includes(t)},Ct=(e,t,n,r)=>{let i=document.elementFromPoint(e,t),a=i?.closest(`[data-drop]`),o=a?.getAttribute(`data-drop`);return!i||!a||typeof o!=`string`||!St(a,n)||r(i,o)?null:a},wt=e=>{let t=e.closest(`[data-drop-scope]`)??document,n=Array.from(t.querySelectorAll(`[data-drop-mark="${CSS.escape(e.getAttribute(`data-drop`))}"]`));return n.length>0?n:e.hasAttribute(`data-drop-scope`)?[]:[e]},Tt=[`outline-2`,`-outline-offset-2`,`rounded-lg`,`outline-ink`],Et=()=>{let e=``,t=()=>!1,n=null,r=[];return{begin(n,r=()=>!1){e=n,t=r},move(i,a){let o=Ct(i,a,e,t);o!==n&&(r.forEach(e=>e.classList.remove(...Tt)),n=o,r=o?wt(o):[],r.forEach(e=>e.classList.add(...Tt)))},read(){return n?.getAttribute(`data-drop`)??null},end(){r.forEach(e=>e.classList.remove(...Tt)),r=[],n=null}}},Dt=typeof Float32Array<`u`?Float32Array:Array,b=(e=0,t=0,n=new Dt(2))=>(n[0]=e,n[1]=t,n),Ot=(e,t,n=b())=>(n[0]=e[0]+t[0],n[1]=e[1]+t[1],n),kt=(e,t,n=b())=>(n[0]=e[0]-t[0],n[1]=e[1]-t[1],n),At=(e,t=b())=>(t[0]=e[0],t[1]=e[1],t),x=typeof window<`u`&&!!window.document&&!!window.document.createElement,jt=()=>x&&`ontouchstart`in window,Mt=()=>jt()||x&&window.navigator.maxTouchPoints>1,Nt=()=>x&&`onpointerdown`in window,Pt=()=>x&&`exitPointerLock`in window.document,Ft=()=>{try{return`constructor`in GestureEvent}catch{return!1}},S={isBrowser:x,get gesture(){return S._gesture??=Ft()},get touch(){return S._touch??=jt()},get touchscreen(){return S._touchscreen??=Mt()},get pointer(){return S._pointer??=Nt()},get pointerLock(){return S._pointerLock??=Pt()}},It=(e=!1)=>e&&S.pointerLock?`mouse`:S.pointer?`pointer`:S.touch?`touch`:`mouse`,Lt=(e,t,n)=>{if(t!==`touch`)return b(e.clientX,e.clientY,n);let[r]=e.changedTouches;return b(r.clientX,r.clientY,n)},Rt={touch:{start:`touchstart`,move:`touchmove`,end:`touchend`,up:`touchcancel`},pointer:{start:`pointerdown`,move:`pointermove`,end:`pointerup`,up:`pointercancel`},mouse:{start:`mousedown`,move:`mousemove`,end:`mouseup`,up:`mousecancel`}};let C=null;const zt=(e,t=()=>!0)=>{let n=()=>{b(0,0,r.value),b(0,0,r._value),b(0,0,r.delta),b(0,0,r.movement)},r={_active:!1,active:!1,pointerId:null,device:It(),_value:b(0,0),value:b(0,0),delta:b(0,0),offset:b(0,0),movement:b(0,0),target:null,event:null,memo:{},isDragStart:!1,isDragging:!1,isDragEnd:!1,drag:()=>{let t=r._active;r.isDragStart=r.active&&!t,r.isDragging=r.active&&t,r.isDragEnd=!r.active&&t,e?.(),r._active=r.active},dragStart:e=>{r.active||C&&C!==r||t(e)&&(e.stopPropagation(),C=r,r.pointerId=e.pointerId??null,r.event=e,r._active=!1,r.active=!0,n(),Lt(e,r.device,r.value),r.target.setPointerCapture&&`pointerId`in e&&r.target.setPointerCapture(e.pointerId),r.drag(r))},dragging:e=>{r.event=e,!(r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId)&&(r.active&&e.cancelable&&e.preventDefault(),r.active&&e.stopPropagation(),At(r.value,r._value),Lt(e,r.device,r.value),r.active&&(kt(r.value,r._value,r.delta),Ot(r.offset,r.delta,r.offset),Ot(r.movement,r.delta,r.movement)),r.drag(r))},dragEnd:e=>{r.active&&r.pointerId!==null&&e.pointerId!==r.pointerId||(C===r&&(C=null),r.event=e,r.active=!1,n(),r.pointerId=null,r.target.releasePointerCapture&&`pointerId`in e&&r.target.releasePointerCapture(e.pointerId),r.drag(r))},mount:e=>{r.target=e;let{start:t,move:n,end:i,up:a}=Rt[r.device];e.addEventListener(t,r.dragStart),e.addEventListener(n,r.dragging,{passive:!1}),e.addEventListener(i,r.dragEnd),e.addEventListener(a,r.dragEnd)},clean:()=>{let e=r.target;if(!e)return;let{start:t,move:n,end:i,up:a}=Rt[r.device];e.removeEventListener(t,r.dragStart),e.removeEventListener(n,r.dragging),e.removeEventListener(i,r.dragEnd),e.removeEventListener(a,r.dragEnd),C===r&&(C=null)},ref:e=>{e?r.mount(e):r.clean(null)}};return r},Bt=[`select-none`,`cursor-grabbing`],Vt=e=>{e.preventDefault(),e.stopPropagation()},Ht=(e,t,n,r,i)=>{let a=()=>{u.memo.moved=!0,navigator.vibrate?.(15),document.body.classList.add(...Bt),n.start(u.target,u.value[0],u.value[1]),r.begin(t,(t,n)=>u.target.contains(t)||n===e||n.startsWith(`${e}/`))},o=()=>{clearTimeout(u.memo.timer),u.memo.moved=!1,u.memo.touch=u.event?.pointerType===`touch`,u.memo.touch&&(u.memo.timer=setTimeout(()=>{u.active&&a()},300))},s=()=>{let e=Math.hypot(u.movement[0],u.movement[1])>8;if(u.memo.touch&&!u.memo.moved){e&&clearTimeout(u.memo.timer);return}!u.memo.moved&&!e||(u.memo.moved||a(),n.move(u.value[0],u.value[1]),r.move(u.value[0],u.value[1]))},c=()=>{let e=u.memo.moved?r.read():null;r.end(),n.end(),document.body.classList.remove(...Bt),u.memo.moved&&(window.addEventListener(`click`,Vt,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,Vt,{capture:!0}),0)),e!==null&&i(e)},l=e=>{if(u.active){if(e.type===`contextmenu`&&u.memo.touch)return Vt(e);u.memo.moved&&e.preventDefault()}},u=zt(()=>{u.isDragStart&&o(),u.isDragging&&s(),u.isDragEnd&&c()},e=>e.button===0&&!e.target?.closest?.(`button, a, input, label`));return e=>{if(!e){clearTimeout(u.memo.timer),u.clean();return}u.mount(e),e.addEventListener(`contextmenu`,l),e.addEventListener(`touchmove`,l,{passive:!1})}},Ut=e=>{let t=xt(),n=Et(),r=new Map;return(i,a=``)=>{let o=`${a}:${i}`;return r.has(o)||r.set(o,Ht(i,a,t,n,t=>e(i,t))),r.get(o)}},Wt={start:`dragenter`,move:`dragover`,leave:`dragleave`,end:`drop`},Gt=(e,t=()=>!0)=>{let n={_active:!1,active:!1,depth:0,value:b(0,0),target:null,event:null,memo:{},isDropStart:!1,isDropping:!1,isDropEnd:!1,drop:()=>{let t=n._active;n.isDropStart=n.active&&!t,n.isDropping=n.active&&t,n.isDropEnd=!n.active&&t,e?.(),n._active=n.active},dropStart:e=>{n.depth++,!n.active&&t(e)&&(e.preventDefault(),n.event=e,n._active=!1,n.active=!0,b(e.clientX,e.clientY,n.value),n.drop(n))},dropping:e=>{n.active&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),n.event=e,b(e.clientX,e.clientY,n.value),n.drop(n))},dropLeave:e=>{n.depth>0&&n.depth--,!(n.depth>0||!n.active)&&(n.event=e,n.active=!1,n.drop(n))},dropEnd:e=>{n.depth=0,n.active&&(e.preventDefault(),n.event=e,n.active=!1,b(e.clientX,e.clientY,n.value),n.drop(n))},mount:e=>{n.target=e;let{start:t,move:r,leave:i,end:a}=Wt;e.addEventListener(t,n.dropStart),e.addEventListener(r,n.dropping),e.addEventListener(i,n.dropLeave),e.addEventListener(a,n.dropEnd)},clean:()=>{let e=n.target;if(!e)return;let{start:t,move:r,leave:i,end:a}=Wt;e.removeEventListener(t,n.dropStart),e.removeEventListener(r,n.dropping),e.removeEventListener(i,n.dropLeave),e.removeEventListener(a,n.dropEnd),n.depth=0,n.active=!1},ref:e=>{if(e)return void n.mount(e);n.clean()}};return n},Kt=e=>!!e.dataTransfer?.types.includes(`Files`),qt=e=>new Promise(t=>e.readEntries(t)),Jt=async e=>{let t=e.createReader(),n=[],r=await qt(t);for(;r.length>0;)n.push(...r),r=await qt(t);return n},Yt=e=>new Promise(t=>e.file(t)),Xt=async(e,t,n)=>{let r=t===``?e.name:`${t}/${e.name}`;if(e.isFile)return void n.push({path:r,file:await Yt(e)});n.push({path:r,file:null});for(let t of await Jt(e))await Xt(t,r,n)},Zt=async e=>{let t=Array.from(e?.items??[]).map(e=>e.webkitGetAsEntry()).filter(e=>!!e),n=[];for(let e of t)await Xt(e,``,n);return n},Qt=(e,t,n=()=>!0)=>{let r=Et(),i=()=>r.begin(e,()=>!n()),a=()=>r.move(s.value[0],s.value[1]),o=()=>{let e=s.event.type===`drop`?r.read():null;r.end(),e!==null&&Zt(s.event.dataTransfer).then(n=>t(n,e))},s=Gt(()=>{s.isDropStart&&i(),s.isDropping&&a(),s.isDropEnd&&o()},Kt);return s.ref},w={add:u,arrowBack:d,arrowDropDown:f,check:p,chevronRight:h,closeIcon:g,cloud:te,deleteIcon:ne,folder:re,home:ie,keep:ae,keepFill:oe,leftPanelClose:se,leftPanelOpen:ce,menuIcon:le,moreVert:ue,redoIcon:de,schedule:fe,searchIcon:pe,settings:he,help:ge,keyboard:_e,sync:ve,undoIcon:ye,unfoldMore:be,visibilityOff:xe,createNewFolder:Se,uploadFile:Ce,driveFolderUpload:we,edit:Te,download:Ee,info:De,openInNew:Oe,restoreFromTrash:ke,description:Ae},$t=({count:e,min:t,cls:n=``,children:r})=>c(`div`,{className:`grid gap-4 overflow-x-auto ${n}`,style:{gridTemplateColumns:`repeat(${e}, minmax(${t}px, 1fr))`},children:r}),en=({c:e,click:t})=>l(`button`,{onClick:t,className:`relative flex h-full w-full cursor-pointer flex-col items-start rounded-xl border border-edge bg-white p-3 text-left hover:bg-pale`,children:[c(`span`,{className:`flex h-[30px] w-[30px] items-center justify-center rounded-md bg-band`,children:c(_,{name:e.icon??``,size:18,color:e.color})}),c(_,{name:w.add,size:16,className:`absolute right-3 top-3 text-mute`}),c(`span`,{className:`mt-2 w-full truncate text-[14px] leading-[17px]`,children:e.label})]}),tn=({c:e,click:t})=>l(`button`,{onClick:t,className:`flex h-12 w-full cursor-pointer items-center gap-3 rounded-xl border border-edge bg-white px-4 text-left hover:bg-pale`,children:[c(_,{name:e.icon??``,size:18,color:e.color}),c(`span`,{className:`truncate`,children:e.label}),c(_,{name:w.add,size:16,className:`ml-auto shrink-0 text-mute`})]}),nn=({cards:e,click:t,popup:n,count:r=4})=>l(s,{children:[c($t,{count:r,min:rt.card,cls:`hidden md:grid`,children:e.map(e=>l(`div`,{className:`relative`,children:[c(en,{c:e,click:t(e)}),n(e)]},e.id))}),c(`div`,{className:`flex flex-col gap-2 md:hidden`,children:e.map(e=>l(`div`,{className:`relative`,children:[c(tn,{c:e,click:t(e)}),n(e)]},e.id))})]}),rn=e=>c(`section`,{className:`relative shrink-0 px-4 pt-3 md:pl-7 md:pr-9`,children:c(nn,{...e})}),an=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,on=`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,sn=({icon:e,color:t,label:n,home:r,actions:i,drawer:a})=>l(`header`,{className:`fixed inset-x-0 top-0 z-20 flex h-14 items-center gap-1 bg-white pl-4 pr-3 md:hidden`,children:[l(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[c(_,{name:e,size:24,color:t}),c(`span`,{className:`truncate text-sm font-bold`,children:n})]}),l(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[i,c(`button`,{onClick:a,className:an,children:c(_,{name:w.menuIcon,size:22})})]})]}),cn=({bar:e,open:t,title:n,back:r,expand:i,actions:a})=>l(`div`,{className:`mt-2.5 flex h-8 shrink-0 items-center gap-2 px-4 md:pl-7 md:pr-9`,children:[!e&&c(`button`,{onClick:t,className:`${on} hidden md:flex`,children:c(_,{name:w.leftPanelOpen,size:20})}),!r&&c(`h1`,{className:`min-w-0 truncate font-bold`,children:n}),r&&l(`button`,{onClick:r,className:`flex min-w-0 cursor-pointer items-center gap-2 font-bold`,children:[c(_,{name:w.arrowBack,size:20,className:`text-mute`}),c(`span`,{className:`truncate`,children:n})]}),l(`div`,{className:`relative ml-auto flex shrink-0 items-center gap-1`,children:[i&&l(`button`,{onClick:i.click,className:`flex h-8 cursor-pointer items-center gap-1 rounded-lg px-2 hover:bg-band ${i.on?`text-ink`:`text-mute`}`,children:[c(`span`,{className:`hidden md:inline`,children:i.label}),c(_,{name:i.icon||w.unfoldMore,size:18})]}),a]})]}),ln=({icon:e,size:t=20,click:n,children:r})=>l(`span`,{className:`relative hidden md:flex`,children:[c(`button`,{onClick:n,className:on,children:c(_,{name:e,size:t})}),r]}),un=({icon:e,size:t=20,click:n,children:r})=>l(`span`,{className:`relative flex`,children:[c(`button`,{onClick:n,className:an,children:c(_,{name:e,size:t})}),r]}),dn=w.moreVert,fn=({drawer:e,close:t,dropRef:n,children:r})=>l(`div`,{ref:n,onClick:t,className:`flex h-dvh overflow-hidden bg-white font-medium text-ink`,children:[e&&c(`div`,{className:`fixed inset-0 z-30 bg-black/30 md:hidden`,onClick:t}),r]}),pn=({drop:e,from:t,children:n})=>c(`main`,{"data-drop":e,"data-drop-from":t,"data-drop-scope":``,className:`flex min-w-0 flex-1 flex-col overflow-y-auto pt-14 md:pt-0`,children:n}),mn=e=>`flex w-full cursor-pointer items-center rounded-lg text-left text-[14px] text-mute ${e?`bg-band`:`hover:bg-band`}`,hn=({open:e,turn:t})=>t?c(`button`,{onClick:t,className:`flex shrink-0 items-center justify-center`,style:{width:v.slot,height:v.slot},children:c(_,{name:w.chevronRight,size:v.slot,className:e?`rotate-90`:``})}):c(`span`,{className:`shrink-0`,style:{width:v.slot}}),gn=({depth:e=0,on:t=!1,open:n,turn:r,icon:i,color:a,label:o,drop:s,mark:u,from:d,click:f,dclick:p,rclick:m,dragRef:h,children:g})=>l(`div`,{ref:h,"data-drop":s,"data-drop-mark":u,"data-drop-from":d,onClick:e=>(f?.(e),r?.(e)),onDoubleClick:p,onContextMenu:m,className:mn(t),style:{height:v.row,paddingLeft:e*v.indent},children:[c(hn,{open:n,turn:r}),c(_,{name:i,size:v.icon,color:a}),c(`span`,{className:`min-w-0 flex-1 truncate ${t?`text-ink`:``}`,style:{marginLeft:v.gap},children:o}),g]}),_n=`STORAGE`,vn=`アップグレード`,yn=`https://stripe.com`,bn=`ゴミ箱を空にしますか?中のアイテムは完全に削除されます`,xn=[{id:`manage`,icon:w.cloud,label:`保存容量を管理`},{id:`empty`,icon:w.deleteIcon,label:`ゴミ箱を空にする`},{id:`refresh`,icon:w.sync,label:`使用状況を更新`}],Sn=[{id:`undo`,icon:w.undoIcon,label:`直前の操作を元に戻す`},{id:`redo`,icon:w.redoIcon,label:`最後に元に戻した操作をやり直す`},{id:`settings`,icon:w.settings,label:`設定`,top:!0},{id:`help`,icon:w.help,label:`ヘルプ`},{id:`shortcuts`,icon:w.keyboard,label:`キーボードショートカット`}],Cn=Sn.slice(2).map(e=>({...e,top:!1})),wn=w.visibilityOff,Tn=(e,t,n)=>[{id:`band`,icon:wn,label:e?`すべての${t}を非表示`:`すべての${t}を表示`},...n.map((e,t)=>t===0?{...e,top:!0}:e)],En=`flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,Dn=({icon:e,color:t,label:n,click:r})=>l(`button`,{onClick:r,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-3`,children:[c(_,{name:e,size:24,color:t}),c(`span`,{className:`truncate text-sm font-bold`,children:n})]}),On=({storage:e,upgrade:t,menu:n,more:r})=>l(`div`,{className:`relative shrink-0 border-t border-line px-4 pb-4 pt-3`,children:[l(`div`,{className:`flex h-6 items-center gap-2 text-mute`,children:[c(_,{name:w.cloud,size:18}),c(`span`,{className:`tracking-wider`,children:_n}),l(`span`,{className:`relative ml-auto flex`,children:[c(`button`,{onClick:r,className:`flex h-6 w-6 items-center justify-center rounded-full text-mute hover:bg-band`,children:c(_,{name:w.moreVert,size:16})}),n]})]}),c(`div`,{className:`mt-1.5 h-2 overflow-hidden rounded-full bg-line`,children:c(`div`,{className:`h-full rounded-full bg-fill`,style:{width:`${Math.min(100,e.used/e.total*100)}%`}})}),c(`p`,{className:`mt-1.5`,children:e.text}),c(`button`,{onClick:t,className:`mt-2.5 h-9 w-full cursor-pointer rounded-full border border-ink font-bold hover:bg-band`,children:vn})]}),kn=({brand:e,bar:t,drawer:n,fold:r,close:i,press:a,storage:o,upgrade:s,menu:u,more:d,children:f})=>l(`nav`,{"data-drop-scope":``,onClick:a,className:`fixed inset-y-0 left-0 z-40 flex shrink-0 flex-col border-r border-line bg-pale transition-transform md:static md:translate-x-0 ${n?`translate-x-0`:`-translate-x-full`} ${t?``:`md:hidden`}`,style:{width:v.width},children:[l(`div`,{className:`flex h-15 shrink-0 items-center gap-1 pr-2 text-[14px]`,style:{paddingLeft:v.brand},children:[c(Dn,{...e}),c(`button`,{onClick:r,className:`${En} hidden md:flex`,children:c(_,{name:w.leftPanelClose,size:20})}),c(`button`,{onClick:i,className:`${En} md:hidden`,children:c(_,{name:w.leftPanelClose,size:20})})]}),c(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-4`,children:f}),c(On,{storage:o,upgrade:s,menu:u,more:d})]}),T={base:`/api/v1/storage`,trash:`.trash`,editors:[]},An=e=>void Object.assign(T,e),E=e=>e.kind.startsWith(`folder`),jn=(e,t)=>e.name.localeCompare(t.name),Mn=(e,t)=>t.iso.localeCompare(e.iso),Nn=(e,t)=>{let n=e.filter(e=>e.parent===t&&!e.trashed);return[...n.filter(E).sort(jn),...n.filter(e=>!E(e)).sort(jn)]},Pn=(e,t)=>e.filter(e=>!e.trashed&&e.kind===t).sort(Mn),Fn=e=>e.filter(e=>!e.trashed&&!E(e)).sort(Mn).slice(0,12),In=e=>e.filter(e=>e.trashed),Ln=e=>e.filter(e=>!e.trashed&&!E(e)).sort((e,t)=>t.bytes-e.bytes),Rn=(e,t)=>e.filter(e=>!e.trashed&&e.parent===t),zn=e=>{let t=e.split(`/`).filter(Boolean);return t.map((e,n)=>({name:n===0&&e===T.trash?`ゴミ箱`:e,path:t.slice(0,n+1).join(`/`)}))},Bn=e=>e.filter(e=>!E(e)).reduce((e,t)=>e+t.bytes,0),Vn=e=>{let{files:t,parent:n,depth:r,expand:i,active:a,kinds:o,fold:u,enter:d,open:f,menu:p,rclick:m,drag:h}=e;return c(s,{children:Nn(t,n).map(t=>{let n=(o[t.kind]??o.file).icon;return E(t)?l(`div`,{children:[c(gn,{depth:r,on:a===t.id,open:i.includes(t.id),turn:u(t.id),icon:o.folder.icon,label:t.name,drop:t.id,mark:t.id,click:d(t.id),rclick:m(t),dragRef:h(t.id,`tree`),children:p(t)}),i.includes(t.id)&&c(Vn,{...e,parent:t.id,depth:r+1})]},t.id):c(gn,{depth:r,icon:n,label:t.name,drop:t.parent,click:d(t.parent),dclick:f(t),rclick:m(t),dragRef:h(t.id,`tree`),children:p(t)},t.id)})})},D=e(!1),O=e(null),Hn=()=>D.value,Un=()=>n(D),Wn=()=>n(O),Gn=e=>{e.stopPropagation(),t(D,!0)},Kn=()=>t(D,!1),qn=e=>t(O,{x:e.clientX,y:e.clientY}),Jn=()=>t(O,null),Yn=e=>e.split(`/`).map(encodeURIComponent).join(`/`),Xn=(e,t)=>e.then(e=>e.ok?e.json():t).catch(()=>t),k=e=>`${T.base}/${Yn(e)}`,A={list(e=``){return Xn(fetch(`${T.base}?prefix=${encodeURIComponent(e)}`),[])},get(e){return fetch(k(e))},put(e,t,n={}){let r=`?kind=${encodeURIComponent(n.kind??``)}&site=${encodeURIComponent(n.site??``)}`;return Xn(fetch(k(e)+r,{method:`POST`,headers:n.type?{"Content-Type":n.type}:void 0,body:t}),{path:e,size:0,date:new Date().toISOString()})},move(e,t){return fetch(`${k(e)}?to=${encodeURIComponent(t)}`,{method:`PUT`})},remove(e){return fetch(k(e),{method:`DELETE`})}},j=(e,t)=>t===``?e:`${t}/${e}`,Zn=e=>e.split(`/`).slice(0,-1).join(`/`),Qn=e=>e.path.endsWith(`/`)?e.path.slice(0,-1):e.path,$n=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`)).filter(e=>e!==T.trash),er=e=>e.includes(`.`)?(e.split(`.`).pop()??``).toLowerCase():``,tr=e=>{let t=er(e);return t===`pdf`?`pdf`:t===`mp4`||t===`mov`||t===`webm`?`mp4`:t===`jpg`||t===`jpeg`||t===`png`||t===`gif`?`jpg`:t===`xlsx`||t===`xls`||t===`csv`?`xlsx`:`file`},nr=(e,t)=>{let n=Qn(e),r=n.startsWith(`${T.trash}/`),i=r?n.slice(T.trash.length+1):n,a=i.split(`/`).pop(),o=e.kind??t?.kind??(e.path.endsWith(`/`)?`folder`:tr(a)),s=o.startsWith(`folder`)?`—`:pt(e.size);return{owner:`自分`,...t,id:n,name:a,kind:o,date:ft(e.date),iso:e.date,size:s,bytes:e.size,parent:Zn(i),trashed:r}},M=(e,t,n,r=!1)=>gt(e,new Set(t.filter(e=>e.parent===n&&!!e.trashed===r).map(e=>e.name))),N=e=>e.scan(`files/`),rr=(e,t)=>{let n=nr(t,e[`files/${Qn(t)}`]);return e[`files/${n.id}`]=n,$n(n.id).forEach(n=>{e[`files/${n}`]||(e[`files/${n}`]=nr({path:`${n}/`,size:0,date:t.date}))}),n},ir=async(e,t,n,r,i,a)=>{let o=M(n.replace(/^\.+/,``)||`無題のファイル`,N(e),r),s=j(o,r),c={path:t.startsWith(`folder`)?`${s}/`:s,size:i?.size??0,date:new Date().toISOString(),kind:t};return rr(e,c),rr(e,await A.put(c.path,i,{kind:t,site:a,type:i?.type}))},P=async(e,t,n=``)=>{let r=n;for(let n of t.split(`/`).filter(Boolean)){let t=e[`files/${j(n,r)}`];r=t?.kind.startsWith(`folder`)?t.id:(await ir(e,`folder`,n,r,``)).id}return r},ar=async(e,t,n)=>{for(let{path:r,file:i}of t){let t=r.split(`/`).filter(Boolean),a=t.pop(),o=await P(e,t.join(`/`),n);i||await P(e,a,o),i&&await ir(e,tr(a),a,o,i)}},or=async(e,t)=>{let n=await A.list(),r=new Set;for(let e of n){let n=rr(t,e);r.add(n.id),$n(n.id).forEach(e=>r.add(e))}N(t).forEach(e=>!r.has(e.id)&&delete t[`files/${e.id}`]);let i=n.reduce((e,t)=>e+t.size,0);return t.storage={used:i/1048576,total:it,text:`15 GB 中 ${mt(i)} を使用`},`synced ${n.length} objects`},sr=async({id:e,dir:t},n)=>{let r=n[`files/${e}`];if(!r||r.trashed)return`not found: ${e}`;if(r.parent===t)return`already in ${t===``?`root`:t}`;if(r.kind.startsWith(`folder`)&&(t===e||t.startsWith(`${e}/`)))return`cannot move ${r.name} into itself`;let i=M(r.name,N(n),t),a=j(i,t);return await A.move(e,a),delete n[`files/${e}`],n[`files/${a}`]={...r,id:a,name:i,parent:t},N(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:a+t.id.slice(e.length),parent:a+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`moved ${i} to ${t===``?`root`:t}`},cr=async({id:e},t)=>{let n=t[`files/${e}`];if(!n)return`not found: ${e}`;if(n.trashed)return delete t[`files/${e}`],N(t).forEach(n=>n.id.startsWith(`${e}/`)&&delete t[`files/${n.id}`]),await A.remove(e),`deleted ${n.name}`;let r=M(n.name,N(t),n.parent,!0),i=j(r,n.parent);return await A.move(e,`${T.trash}/${i}`),delete t[`files/${e}`],t[`files/${T.trash}/${i}`]={...n,id:`${T.trash}/${i}`,name:r,trashed:!0},N(t).forEach(n=>{if(!n.id.startsWith(`${e}/`))return;delete t[`files/${n.id}`];let r={...n,id:`${T.trash}/${i}${n.id.slice(e.length)}`,parent:i+n.parent.slice(e.length),trashed:!0};t[`files/${r.id}`]=r}),`trashed ${n.name}`},lr=async({id:e},t)=>{let n=t[`files/${e}`];if(!n?.trashed)return`not trashed: ${e}`;let r=await P(t,n.parent),i=M(n.name,N(t),r),a=j(i,r);await A.move(e,a),delete t[`files/${e}`];let o={...n,id:a,name:i,parent:r};return delete o.trashed,t[`files/${a}`]=o,`restored ${i}`},ur=async({id:e,name:t},n)=>{let r=n[`files/${e}`];if(!r)return`not found: ${e}`;let i=t.replace(/^\.+/,``)||r.name,a=M(i,N(n),r.parent),o=j(a,r.parent);return await A.move(e,o),delete n[`files/${e}`],n[`files/${o}`]={...r,id:o,name:a},N(n).forEach(t=>{if(!t.id.startsWith(`${e}/`))return;delete n[`files/${t.id}`];let r={...t,id:o+t.id.slice(e.length),parent:o+t.parent.slice(e.length)};n[`files/${r.id}`]=r}),`renamed to ${a}`},dr=async(e,t)=>{let n=N(t).filter(e=>e.trashed);n.forEach(e=>delete t[`files/${e.id}`]);let r=await A.list(`${T.trash}/`);return await Promise.all(r.map(e=>A.remove(e.path))),`emptied ${n.length} items`},fr=e=>Bn(N(e)),F={ask:`Ask me anything...`,brand:`Claude`,voice:`音声モード`,file:`ファイル`},I=[{id:`claude-fable-5`,label:`Fable 5`,desc:`最も困難な課題に`},{id:`claude-opus-5`,label:`Opus 5`,desc:`複雑なタスク向け`},{id:`claude-sonnet-5`,label:`Sonnet 5`,desc:`日常のタスクに最適`},{id:`claude-haiku-4-5`,label:`Haiku 4.5`,desc:`素早い回答に最適`}],L={w:376,left:12,top:12,bottom:16,minH:180},R=e(``),z={send:async()=>``,stream:{parse:()=>[],send:async()=>[]},icon:``,path:``,headers:{},hello:()=>({greet:``,title:``,desc:``,prompts:[]}),commands:()=>[],hints:()=>[],menu:{useOpen:()=>n(R),flip:e=>n=>{n.stopPropagation(),t(R,R.value===e?``:e)},close:()=>t(R,``)}},pr=e=>void Object.assign(z,e),mr=(e,t=20,n=6)=>{let r=a(null);return i(()=>{let e=r.current;if(!e)return;e.style.height=`${t}px`;let i=Math.max(1,Math.round(e.scrollHeight/t));e.style.height=`${Math.min(i,n)*t}px`},[e]),r},hr=(()=>{let e=new Be({linkify:!0,breaks:!0}),t=t=>e.render(t);return{render:t,plain:e=>{let n=document.createElement(`div`);return n.innerHTML=t(e),n.textContent?.trim()??``}}})(),B=e(!1),V=e([]),H=e(``),U=e([0,0]),gr=e(I[0].id),W=e(!1),G=e(!1),_r=()=>W.value,vr=()=>n(W),K=e(!1);let q=null;const yr=()=>{let e=window.SpeechRecognition??window.webkitSpeechRecognition;if(!e)return null;let n=new e;return n.lang=`ja-JP`,n.continuous=!0,n.interimResults=!1,n.onresult=e=>{let n=``;for(let t=e.resultIndex;t<e.results.length;t++)e.results[t].isFinal&&(n+=e.results[t][0].transcript);n!==``&&t(H,H.value+n)},n.onend=()=>t(K,!1),n},br=()=>{if(K.value)return void q?.stop();q??=yr(),q&&(q.start(),t(K,!0))};let J=[0,0,28,28];const xr=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n)),Sr=()=>{let[e,t]=U.value,n=Y.target.getBoundingClientRect();J=[n.left-e,n.top-t,n.width,n.height]},Cr=()=>{let e=xr(Y.offset[0],-J[0],window.innerWidth-J[2]-J[0]),n=xr(Y.offset[1],-J[1],window.innerHeight-J[3]-J[1]);b(e,n,Y.offset),t(U,[e,n])},Y=zt(()=>{Y.isDragStart&&Sr(),Cr()}),wr=()=>{b(0,0,Y.offset),t(U,[0,0])},Tr=()=>{let e=Y.target;!e||!e.isConnected||(Sr(),Cr())},Er=()=>{r(()=>(Tr(),window.addEventListener(`resize`,Tr),()=>window.removeEventListener(`resize`,Tr)),[])},Dr=e=>`calc(max(${L.left}px, 100vw - ${L.w+L.left}px) + ${e}px)`,Or=e=>L.top+e,kr=e=>`max(${L.minH}px, min(calc(100dvh - ${L.top+L.left}px), calc(100dvh - ${L.top+L.bottom+e}px)))`,X=e(null),Z=e(0),Ar=(e,t)=>{if(t)return t;if(!e.startsWith(`/`))return[];let n=e.slice(1).trim().toLowerCase();return z.commands().filter(e=>e.name.toLowerCase().startsWith(n))},jr=()=>{t(X,null),t(Z,0)},Q=async e=>{t(H,``),jr();let n=await e.run();Array.isArray(n)&&t(X,n)},Mr=e=>{if(!e.startsWith(`/`))return;let t=e.slice(1).trim().toLowerCase();return z.commands().find(e=>e.name.toLowerCase()===t)??Ar(e,null)[0]},Nr=e=>{if(e.nativeEvent?.isComposing)return!1;let n=Ar(H.value,X.value);if(n.length===0)return!1;let r=Z.value%n.length;return e.key===`ArrowDown`?(e.preventDefault(),t(Z,(r+1)%n.length),!0):e.key===`ArrowUp`?(e.preventDefault(),t(Z,(r-1+n.length)%n.length),!0):e.key===`Escape`?(e.preventDefault(),t(H,``),jr(),!0):e.key===`Enter`&&(e.preventDefault(),Q(n[r]),!0)},Pr=(()=>{let e=e=>e.replace(/[^0-9A-Za-zぁ-んァ-ヴー一-龠々\s]/g,` `).replace(/\s+/g,` `).trim(),t=e=>{let t=document.createElement(`div`);return t.innerHTML=hr.render(e),t.querySelectorAll(`pre`).forEach(e=>e.remove()),t.textContent??``};return{lines:n=>t(n).split(`
|
|
2
|
+
`).map(e).filter(e=>e!==``)}})();let $=0,Fr=[];const Ir=[`Kyoko`,`O-Ren`,`Nanami`,`Ayumi`,`Haruka`,`Sayaka`,`Samantha`,`Zira`,`Aria`,`Jenny`,`Ava`,`Sonia`,`Google 日本語`,`Google US English`],Lr=[`Otoya`,`Ichiro`,`Keita`,`David`,`Mark`,`Guy`,`Alex`,`Daniel`,`Fred`,`Andrew`,`Brian`],Rr=()=>Fr=speechSynthesis.getVoices(),zr=e=>{Fr.length===0&&Rr();let t=Fr.filter(t=>t.lang.replace(`_`,`-`).startsWith(e.slice(0,2)));return t.find(e=>Ir.some(t=>e.name.includes(t)))??t.find(e=>!Lr.some(t=>e.name.includes(t)))??t[0]??null},Br=e=>{(e.match(/[A-Za-z][0-9A-Za-z]*(?: (?:[0-9]+ )*[A-Za-z][0-9A-Za-z]*)*|(?:(?![A-Za-z]).)+/g)??[]).forEach(e=>{if(e.trim()===``)return;let t=new SpeechSynthesisUtterance(e);t.lang=/^[A-Za-z]/.test(e)?`en-US`:`ja-JP`,t.voice=zr(t.lang),speechSynthesis.speak(t)})};speechSynthesis.addEventListener(`voiceschanged`,Rr);const Vr=e=>{if(!G.value)return;let t=e.split(`
|
|
3
|
+
`).slice(0,-1).join(`
|
|
4
|
+
`),n=Pr.lines(t);n.slice($).forEach(Br),$=n.length},Hr=e=>{G.value&&Pr.lines(e).slice($).forEach(Br),$=0},Ur=()=>{$=0,speechSynthesis.cancel()},Wr=()=>t(B,!0),Gr=()=>{wr(),Ur(),jr(),t(B,!1)},Kr=()=>{if(B.value)return Gr();Wr()},qr=e=>{jr(),t(H,e.target.value)},Jr=()=>{let e=H.value.trim();if(e===``||W.value)return;let n=Mr(e);if(n)return void Q(n);t(H,``),z.send({prompt:e})},Yr=e=>{Nr(e)||e.key!==`Enter`||e.nativeEvent?.isComposing||e.shiftKey||(e.preventDefault(),Jr())},Xr=e=>()=>{let t=Mr(e);if(t)return void Q(t);z.send({prompt:e})},Zr=()=>{G.value&&Ur(),t(G,!G.value)},Qr=e=>{z.menu.close(),t(gr,e.id)},$r=()=>l(`div`,{className:`flex shrink-0 items-start justify-between px-2`,children:[c(_,{name:je,size:50,className:`text-mute`}),l(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{ref:Y.ref,className:`flex h-7 w-7 cursor-grab touch-none select-none items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink active:cursor-grabbing`,children:c(_,{name:Me,size:20})}),c(`button`,{onClick:Gr,className:`flex h-7 w-7 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,children:c(_,{name:ee,size:20})})]})]}),ei=()=>{let e=z.hello();return l(`div`,{className:`flex h-full flex-col items-center justify-center px-3 text-center`,children:[c(_,{name:je,size:56,className:`mb-5 text-mute`}),c(`p`,{className:`text-mute`,children:e.greet}),c(`p`,{className:`mt-1 font-bold leading-[26px]`,children:e.title}),c(`p`,{className:`mt-3 text-mute`,children:e.desc}),c(`div`,{className:`-mx-6 mt-6 flex flex-wrap justify-center gap-1.5`,children:e.prompts.map(e=>l(`button`,{onClick:Xr(e.prompt??e.label),className:`flex cursor-pointer items-center gap-1 whitespace-nowrap rounded-full border border-edge bg-white px-2.5 py-1 text-[12px] leading-[16px] hover:bg-pale`,children:[e.icon&&c(_,{name:e.icon,size:14,color:e.color}),e.label]},e.label))})]})},ti=({t:e})=>l(`div`,{className:`-mt-4 ml-3 flex max-w-full items-center rounded-lg border border-edge bg-band p-2`,children:[e.icon&&c(_,{name:e.icon,size:16}),c(`span`,{className:`mx-2 truncate text-[12px]`,children:e.label}),c(`button`,{className:`hidden ml-1 flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-line`,children:c(_,{name:ze,size:16})})]}),ni=({m:e})=>l(`div`,{className:`mr-7 flex flex-col items-start ${e.tools?.length?`mb-6`:``}`,children:[c(`div`,{className:`chat-md w-full rounded-xl border border-edge bg-white p-3 ${e.tools?.length?`pb-5`:``}`,dangerouslySetInnerHTML:{__html:hr.render(e.text)}}),e.tools?.map((e,t)=>c(ti,{t:e},t))]}),ri=({m:e})=>c(`div`,{className:`ml-7 min-w-0 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-2xl border border-edge bg-band p-3`,children:e.text}),ii=()=>c(`div`,{className:`flex w-fit items-center rounded-lg border border-edge bg-white px-2 py-1 text-mute`,children:c(_,{name:ze,size:20,className:`animate-pulse`})}),ai=()=>{let e=n(V),t=n(W),i=a(null);return r(()=>void i.current?.scrollTo(0,9e9),[e]),c(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:l(`div`,{ref:i,className:`flex h-full flex-col gap-5 overflow-y-auto px-2 pb-4 pt-10 text-[14px] leading-[22px]`,children:[e.length===0&&c(ei,{}),e.map((e,t)=>e.role===`user`?c(ri,{m:e},t):c(ni,{m:e},t)),t&&e[e.length-1]?.role===`user`&&c(ii,{})]})})},oi=()=>{let e=n(H);return n(K)?c(`button`,{onClick:br,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-[#EA4335]`,children:c(_,{name:Fe,size:20})}):e.trim()===``?c(`button`,{onClick:br,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-mute hover:text-ink`,children:c(_,{name:Ne,size:20})}):c(`button`,{onClick:Jr,className:`flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center text-ink hover:text-[#4185F4]`,children:c(_,{name:Pe,size:20})})},si=()=>{let e=n(H),t=n(X),r=n(Z),i=Ar(e,t);return i.length===0?null:c(`div`,{className:`absolute inset-x-0 bottom-full z-10 mb-2 max-h-56 overflow-y-auto rounded-xl border border-edge bg-white py-1 shadow-[0_8px_24px_rgba(0,0,0,0.12)]`,children:i.map((e,n)=>l(`button`,{onClick:()=>void Q(e),className:`flex w-full cursor-pointer items-center gap-3 px-3 py-1.5 text-left text-[12px] leading-[16px] ${n===r%i.length?`bg-band`:`hover:bg-pale`}`,children:[c(`span`,{className:`shrink-0 font-bold`,children:t?e.label??e.name:`/${e.name}`}),c(`span`,{className:`min-w-0 flex-1 truncate text-right text-mute`,children:e.desc})]},`${e.name}-${n}`))})},ci=()=>{let e=n(V),t=n(W)?[]:z.hints(e);return t.length===0?null:c(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1.5 pb-2`,children:t.map(e=>c(`button`,{onClick:()=>void Q(e),className:`cursor-pointer rounded-full border border-edge bg-white px-2.5 py-1 text-[12px] leading-[16px] hover:bg-pale`,children:e.label??e.name},e.name))})},li=()=>{let e=n(H),t=n(gr),r=n(G),i=z.menu.useOpen(),a=mr(e),o=I.find(e=>e.id===t)??I[0];return l(`div`,{className:`relative shrink-0 rounded-xl border border-edge`,children:[c(si,{}),l(`label`,{className:`flex items-start gap-2 px-3 pb-7 pt-3`,children:[c(_,{name:me,size:20,className:`text-mute`}),c(`textarea`,{ref:a,rows:1,value:e,onChange:qr,onKeyDown:Yr,placeholder:F.ask,className:`min-w-0 flex-1 resize-none overflow-y-auto bg-transparent text-[14px] leading-[20px] outline-none placeholder:text-mute`}),c(oi,{})]}),l(`div`,{className:`flex h-9 items-center border-t border-line px-3 text-[12px]`,children:[l(`span`,{className:`relative flex`,children:[l(`button`,{onClick:z.menu.flip(`chat-model`),className:`flex cursor-pointer items-center gap-1`,children:[F.brand,` `,o.label,c(_,{name:Re,size:16,className:`text-mute`})]}),i===`chat-model`&&c(Je,{align:`left`,cls:`w-64`,items:I,value:t,pick:Qr,check:m})]}),l(`div`,{className:`ml-auto flex items-center gap-3`,children:[l(`button`,{onClick:Zr,className:`flex cursor-pointer items-center gap-1 ${r?`text-[#4185F4]`:``}`,children:[c(_,{name:Ie,size:18}),F.voice]}),l(`button`,{className:`flex cursor-pointer items-center gap-1`,children:[c(_,{name:Le,size:18}),F.file]})]})]})]})},ui=()=>c(`button`,{onClick:Kr,className:`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full text-mute hover:bg-band hover:text-ink`,children:c(_,{name:je,size:22})}),di=()=>{Er();let[e,t]=n(U);return l(`div`,{className:`fixed z-50 flex w-[376px] max-w-[calc(100vw-24px)] flex-col rounded-2xl border border-line bg-white p-3 text-ink shadow-[0_8px_24px_rgba(0,0,0,0.12)]`,style:{left:Dr(e),top:Or(t),height:kr(t)},children:[c($r,{}),c(ai,{}),c(ci,{}),c(li,{})]})},fi=()=>n(B)?c(di,{}):null,pi=e=>({role:`agent`,text:e.text,tools:e.tools.map(e=>({icon:z.icon,label:`${e.server?`${e.server} - `:``}${e.name} (MCP)`}))}),mi=e=>t(V,e.flatMap(e=>[{role:`user`,text:e.prompt},pi({text:e.reply,tools:e.tools.map(e=>({server:``,name:e}))})])),hi=e=>e.map(e=>e.tools.length?`${e.text}\n`:e.text).join(`
|
|
5
|
+
`),gi=async e=>{if(W.value)return`busy: previous chat is still running`;let n=[...V.value,{role:`user`,text:e}];Ur(),t(V,n),t(W,!0);let r=await z.stream.send({prompt:e,path:z.path,model:gr.value,headers:z.headers},e=>{t(V,[...n,...e.items.map(pi)]),Vr(hi(e.items))});return Hr(hi(r)),t(W,!1),`chat sent: ${e}`},_i=e=>{let t=[],n=``,r=[],i=()=>Math.floor(new Date().getHours()/6),a=r=>{let a=i(),o=n,s=t.find(e=>e.name===r&&e.part===a&&e.after===o);s&&(s.count+=1),s||t.push({name:r,part:a,after:o,count:1}),n=r,e.store.save({name:r,part:a,after:o})},o=e=>t.reduce((t,r)=>r.name===e?t+r.count*(r.part===i()?2:1)*(r.after===n?2:1):t,0),s=e=>[...e].sort((e,t)=>o(t.name)-o(e.name)),c=()=>(r.length===0&&(r=e.deck.map(e=>({...e,run:()=>(a(e.name),e.run())}))),s(r));return{commands:c,hello:()=>{let t=c(),n=t.filter(t=>e.starters().includes(t.name)),r=[...new Set([...e.pinned(),...n.map(e=>e.name)])].flatMap(e=>t.filter(t=>t.name===e));return{...e.greet,prompts:r.map(e=>({label:e.label??e.name,prompt:`/${e.name}`}))}},hints:t=>e.hinted(t).flatMap(e=>c().filter(t=>t.name===e)),prime:async()=>{t=await e.store.list()}}},vi=(e,t)=>e.map((n,r)=>{let i=e[r+1]?.seq??1/0;return{...n,names:t.filter(e=>e.seq>n.seq&&e.seq<i).map(e=>e.name)}}),yi=e=>e.replace(/\s+/g,` `).trim().slice(0,40),bi=e=>{let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return t<60?`たった今`:t<3600?`${Math.floor(t/60)} 分前`:t<86400?`${Math.floor(t/3600)} 時間前`:`${Math.floor(t/86400)} 日前`},xi=e=>{let t=crypto.randomUUID(),n=0,r=[],i=()=>{t=crypto.randomUUID(),n=0,r=[],e.show([])},a=async()=>(await e.store.list()).map(e=>({...e,when:bi(e.updatedAt)})),o=async i=>{let a=await e.store.load(i),o=vi(a.talks,a.tools).map(e=>({prompt:e.prompt,reply:e.reply,tools:e.names}));t=i,n=[...a.talks,...a.tools].reduce((e,t)=>Math.max(e,t.seq),0),r=o.flatMap(e=>[{role:`user`,content:e.prompt},{role:`assistant`,content:e.reply}]),e.show(o)},s=(i,a,o=``)=>{let s=a.filter(e=>!e.error),c=s.map(e=>e.text).filter(e=>e!==``).join(`
|
|
6
|
+
|
|
7
|
+
`);if(c===``)return;let l=s.flatMap(e=>e.tools.map(e=>e.name));r=[...r,{role:`user`,content:i},{role:`assistant`,content:c}];let u=n+1;n=u+l.length,e.store.save(t,{title:yi(i),seq:u,prompt:i,reply:c,model:o,tools:l.map((e,t)=>({seq:u+1+t,name:e}))})};return{wrap:e=>({...e,send:async(t,n)=>{let i=await e.send({...t,messages:r.slice(-40)},n);return s(t.prompt,i,t.model),i}}),reset:i,load:o,list:a}};export{fi as AiChat,ui as AiChatButton,rn as Band,Dn as Brand,nn as Cards,Vn as DriveTree,Je as Drop,hn as Fold,fn as Frame,ct as GB,ln as HeadBtn,_ as Icon,ut as KB,lt as MB,pn as Main,cn as MainHead,dn as MoreIcon,qe as Pop,gn as Row,st as SP_BREAK,kn as Side,Ue as Slot,un as SpBtn,sn as SpHead,On as Storage_,$t as Strip,ht as ago,$n as ancestors,qn as atPoint,et as band,wn as bandIcon,nt as blue,z as chatConfig,Gr as closeChat,Kn as closeDrawer,pr as configureChat,An as configureDrive,_i as createCommands,Ut as createFileDrag,Qt as createFileDrop,xi as createHistory,Et as createOver,zn as crumbSegs,zt as dragEvent,D as drawerAtom,T as driveConfig,Gt as dropEvent,Qe as edge,dr as emptyTrash,bn as emptyTrashAsk,nr as entryOf,er as extOf,tt as fill,Rn as folderRows,M as freeName,rt as grid,w as icons,Qn as idOf,Ye as ink,_r as isChatBusy,Hn as isDrawerOpen,E as isFolder,tr as kindOf,Pn as kindRows,Ze as line,hr as markdown,rr as mirrorFile,P as mkdirp,I as models,Tn as moreItems,sr as moveFile,Xe as mute,Jn as noPoint,Wr as openChat,Gn as openDrawer,Sn as pageMenu,$e as pale,Zn as parentOf,j as pathname,We as place,O as pointAtom,He as prev,it as quota,A as r2,Fn as recentRows,cr as removeFile,ur as renameFile,mi as restoreChat,lr as restoreFile,mn as rowCls,gi as runChat,ir as saveFile,v as side,pt as sizeOf,Cn as spMenu,ft as stamp,Ve as stop,xn as storageMenu,_n as storageName,Ln as storageRows,ar as storeFiles,or as syncFiles,pi as toMsg,Kr as toggleChat,In as trashRows,Nn as treeOf,gt as unique,vn as upgradeLabel,yn as upgradeUrl,ot as uploadAlert,at as uploadMax,k as url,mt as usageOf,vr as useChatBusy,Un as useDrawer,Wn as usePoint,fr as usedBytes,Bn as usedOf,b as vec2};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { Route } from "./types.js";
|
|
1
|
+
import { ActionDef, Ai, Config, Define, Grant, Own, Peer, Route, Saved, Side } from "./types.js";
|
|
2
|
+
//#region src/client/sync.d.ts
|
|
3
|
+
declare const client: <T extends object>(ai: T, route?: Route) => T;
|
|
4
|
+
declare const hydrate: <T extends object>(ai: T, entries: Record<string, any>, wake?: (key: string, value: any) => any) => T;
|
|
5
|
+
//#endregion
|
|
2
6
|
//#region src/client/stream.d.ts
|
|
3
7
|
interface StreamTool {
|
|
4
8
|
server: string;
|
|
@@ -26,8 +30,4 @@ declare const createStream: (endpoint?: string) => {
|
|
|
26
30
|
send: (input: StreamSend, update?: (u: StreamUpdate) => void) => Promise<StreamItem[]>;
|
|
27
31
|
};
|
|
28
32
|
//#endregion
|
|
29
|
-
|
|
30
|
-
declare const client: <T extends object>(ai: T, route?: Route) => T;
|
|
31
|
-
declare const hydrate: <T extends object>(ai: T, entries: Record<string, any>, wake?: (key: string, value: any) => any) => T;
|
|
32
|
-
//#endregion
|
|
33
|
-
export { type Route, type StreamItem, type StreamSend, type StreamTool, type StreamUpdate, client, createStream, hydrate };
|
|
33
|
+
export { type ActionDef, type Ai, type Config, type Define, type Grant, type Own, type Peer, type Route, type Saved, type Side, type StreamItem, type StreamSend, type StreamTool, type StreamUpdate, client, createStream, hydrate };
|
package/dist/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ALIAS as e,LLM_PATH as t}from"./const.js";import n from"y-partyserver/provider";const r=/^\[tool\] (?:(\S+) )?(\S+)$/,
|
|
2
|
-
`)){if(
|
|
1
|
+
import{ALIAS as e,LLM_PATH as t}from"./const.js";import n from"y-partyserver/provider";const r=new WeakSet,i=(t,i={})=>{if(r.has(t))return t;r.add(t);let{room:a=e,path:o=``,host:s=location.host,party:c=`v1`,synced:l}=i,u=t.open().data().doc,d=a?new n(s,a,u,{party:c,params:{path:o}}):null;return l&&(!d||d.synced?l():d.once(`synced`,()=>l())),t},a=(e,t,n=(e,t)=>t)=>{if(r.has(e))return e;r.add(e);let i=e;return i.open().tx(()=>Object.entries(t).forEach(([e,t])=>i[e]=n(e,t))),e},o=/^\[tool\] (?:(\S+) )?(\S+)$/,s=(e=t)=>{let n=e=>{let t=[{text:``,tools:[]}],n=!1;for(let r of e.split(`
|
|
2
|
+
`)){if(r.startsWith(`[usage]`))continue;let e=o.exec(r),i=t[t.length-1];if(e){i.tools.push({server:e[1]??``,name:e[2]}),n=!0;continue}if(!(n&&r.trim()===``)){if(n){t.push({text:r,tools:[]}),n=!1;continue}i.text=i.text===``?r:`${i.text}\n${r}`}}return t.map(e=>({...e,text:e.text.trim()})).filter(e=>e.text!==``||e.tools.length>0)};return{parse:n,send:async(t,r)=>{let{headers:i={},...a}=t,o=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`,...i},body:JSON.stringify(a)});if(!o.ok){let e=(await o.text()).replace(/\n/g,` `),t=[{text:e,tools:[],error:!0}];return r?.({items:t,delta:e,raw:e}),t}let s=o.body.getReader(),c=new TextDecoder,l=``;for(;;){let{done:e,value:t}=await s.read();if(e)break;let i=c.decode(t,{stream:!0});l+=i,r?.({items:n(l),delta:i,raw:l})}return n(l)}}};export{i as client,s as createStream,a as hydrate};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
//#region src/hono/d1/types.d.ts
|
|
2
|
+
interface ChatTables {
|
|
3
|
+
chats: any;
|
|
4
|
+
talks: any;
|
|
5
|
+
tools: any;
|
|
6
|
+
habits: any;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/hono/d1/routes.d.ts
|
|
10
|
+
type D1Database$1 = any;
|
|
11
|
+
interface ChatRouteInput {
|
|
12
|
+
db: (env: any) => D1Database$1;
|
|
13
|
+
sub: (c: any) => Promise<string> | string;
|
|
14
|
+
tables: ChatTables;
|
|
15
|
+
}
|
|
16
|
+
declare const chatLog: ({ db, sub, tables }: ChatRouteInput) => import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, {
|
|
17
|
+
"/chats": {
|
|
18
|
+
$get: {
|
|
19
|
+
output: null;
|
|
20
|
+
outputFormat: "json";
|
|
21
|
+
status: 401;
|
|
22
|
+
input: {};
|
|
23
|
+
} | {
|
|
24
|
+
output: {
|
|
25
|
+
[x: string]: any;
|
|
26
|
+
}[];
|
|
27
|
+
outputFormat: "json";
|
|
28
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
29
|
+
input: {};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
} & {
|
|
33
|
+
"/chats/:chatId": {
|
|
34
|
+
$get: {
|
|
35
|
+
output: null;
|
|
36
|
+
outputFormat: "json";
|
|
37
|
+
status: 401;
|
|
38
|
+
input: {
|
|
39
|
+
param: {
|
|
40
|
+
chatId: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
output: {
|
|
45
|
+
talks: {
|
|
46
|
+
[x: string]: any;
|
|
47
|
+
}[];
|
|
48
|
+
tools: {
|
|
49
|
+
[x: string]: any;
|
|
50
|
+
}[];
|
|
51
|
+
};
|
|
52
|
+
outputFormat: "json";
|
|
53
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
54
|
+
input: {
|
|
55
|
+
param: {
|
|
56
|
+
chatId: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
} & {
|
|
62
|
+
"/chats/:chatId": {
|
|
63
|
+
$post: {
|
|
64
|
+
output: null;
|
|
65
|
+
outputFormat: "json";
|
|
66
|
+
status: 401;
|
|
67
|
+
input: {
|
|
68
|
+
param: {
|
|
69
|
+
chatId: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
} | {
|
|
73
|
+
output: {
|
|
74
|
+
ok: true;
|
|
75
|
+
};
|
|
76
|
+
outputFormat: "json";
|
|
77
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
78
|
+
input: {
|
|
79
|
+
param: {
|
|
80
|
+
chatId: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
} & {
|
|
86
|
+
"/habits": {
|
|
87
|
+
$get: {
|
|
88
|
+
output: null;
|
|
89
|
+
outputFormat: "json";
|
|
90
|
+
status: 401;
|
|
91
|
+
input: {};
|
|
92
|
+
} | {
|
|
93
|
+
output: {
|
|
94
|
+
[x: string]: any;
|
|
95
|
+
}[];
|
|
96
|
+
outputFormat: "json";
|
|
97
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
98
|
+
input: {};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
} & {
|
|
102
|
+
"/habits": {
|
|
103
|
+
$post: {
|
|
104
|
+
output: null;
|
|
105
|
+
outputFormat: "json";
|
|
106
|
+
status: 401;
|
|
107
|
+
input: {};
|
|
108
|
+
} | {
|
|
109
|
+
output: {
|
|
110
|
+
ok: true;
|
|
111
|
+
};
|
|
112
|
+
outputFormat: "json";
|
|
113
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
114
|
+
input: {};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}, "/", "/habits">;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/hono/d1/queries.d.ts
|
|
120
|
+
type D1Database = any;
|
|
121
|
+
declare const createChatLog: (t: ChatTables) => {
|
|
122
|
+
listChats: (DB: D1Database, userId: string) => Omit<import("drizzle-orm/sqlite-core").SQLiteSelectBase<any, "async", any, any, "single", Record<any, "not-null"> | {}, false, "limit" | "orderBy" | "where", {
|
|
123
|
+
[x: string]: any;
|
|
124
|
+
}[], any>, "limit" | "orderBy" | "where">;
|
|
125
|
+
getChatLog: (DB: D1Database, userId: string, chatId: string) => Promise<[{
|
|
126
|
+
[x: string]: any;
|
|
127
|
+
}[], {
|
|
128
|
+
[x: string]: any;
|
|
129
|
+
}[]]>;
|
|
130
|
+
saveTalk: (DB: D1Database, userId: string, chatId: string, body: any) => Promise<any[]>;
|
|
131
|
+
listHabits: (DB: D1Database, userId: string) => Omit<import("drizzle-orm/sqlite-core").SQLiteSelectBase<any, "async", any, any, "single", Record<any, "not-null"> | {}, false, "where", {
|
|
132
|
+
[x: string]: any;
|
|
133
|
+
}[], any>, "where">;
|
|
134
|
+
bumpHabit: (DB: D1Database, userId: string, body: any) => import("drizzle-orm/sqlite-core").SQLiteInsertBase<any, "async", D1Result, undefined, false, never>;
|
|
135
|
+
};
|
|
136
|
+
//#endregion
|
|
137
|
+
export { type ChatRouteInput, type ChatTables, chatLog, createChatLog };
|
package/dist/hono/d1.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Hono as e}from"hono";import{drizzle as t}from"drizzle-orm/d1";import{and as n,desc as r,eq as i,sql as a}from"drizzle-orm";const o=e=>({listChats:(n,a)=>t(n).select().from(e.chats).where(i(e.chats.userId,a)).orderBy(r(e.chats.updatedAt)).limit(30),getChatLog:(r,a,o)=>{let s=t(r);return s.batch([s.select().from(e.talks).where(n(i(e.talks.userId,a),i(e.talks.chatId,o))).orderBy(e.talks.seq),s.select().from(e.tools).where(n(i(e.tools.userId,a),i(e.tools.chatId,o))).orderBy(e.tools.seq)])},saveTalk:(n,r,i,a)=>{let o=t(n),s=(a.tools??[]).map(e=>({userId:r,chatId:i,seq:e.seq,name:e.name}));return o.batch([o.insert(e.chats).values({userId:r,chatId:i,title:a.title}).onConflictDoUpdate({target:[e.chats.userId,e.chats.chatId],set:{updatedAt:new Date}}),o.insert(e.talks).values({userId:r,chatId:i,seq:a.seq,prompt:a.prompt,reply:a.reply,model:a.model}).onConflictDoNothing(),...s.length?[o.insert(e.tools).values(s).onConflictDoNothing()]:[]])},listHabits:(n,r)=>t(n).select().from(e.habits).where(i(e.habits.userId,r)),bumpHabit:(n,r,i)=>t(n).insert(e.habits).values({userId:r,name:i.name,part:i.part,after:i.after}).onConflictDoUpdate({target:[e.habits.userId,e.habits.name,e.habits.part,e.habits.after],set:{count:a`${e.habits.count} + 1`,updatedAt:new Date}})}),s=({db:t,sub:n,tables:r})=>{let i=o(r);return new e().get(`/chats`,async e=>{let r=await n(e);return r?e.json(await i.listChats(t(e.env),r)):e.json(null,401)}).get(`/chats/:chatId`,async e=>{let r=await n(e);if(!r)return e.json(null,401);let[a,o]=await i.getChatLog(t(e.env),r,e.req.param(`chatId`));return e.json({talks:a,tools:o})}).post(`/chats/:chatId`,async e=>{let r=await n(e);return r?(await i.saveTalk(t(e.env),r,e.req.param(`chatId`),await e.req.json()),e.json({ok:!0})):e.json(null,401)}).get(`/habits`,async e=>{let r=await n(e);return r?e.json(await i.listHabits(t(e.env),r)):e.json(null,401)}).post(`/habits`,async e=>{let r=await n(e);return r?(await i.bumpHabit(t(e.env),r,await e.req.json()),e.json({ok:!0})):e.json(null,401)})};export{s as chatLog,o as createChatLog};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
//#region src/hono/r2/store.d.ts
|
|
2
|
+
interface Obj {
|
|
3
|
+
path: string;
|
|
4
|
+
size: number;
|
|
5
|
+
date: string;
|
|
6
|
+
kind?: string;
|
|
7
|
+
etag?: string;
|
|
8
|
+
}
|
|
9
|
+
type R2Bucket$2 = any;
|
|
10
|
+
declare const createR2: (bucket: R2Bucket$2) => {
|
|
11
|
+
list: (sub: string, prefix?: string, cursor?: string) => Promise<Obj[]>;
|
|
12
|
+
get: (sub: string, path: string) => any;
|
|
13
|
+
head: (sub: string, path: string) => any;
|
|
14
|
+
put(sub: string, path: string, body: any, meta?: any): Promise<Obj>;
|
|
15
|
+
move(sub: string, from: string, to: string): Promise<void>;
|
|
16
|
+
remove(sub: string, path: string): Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
type Store = ReturnType<typeof createR2>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/hono/r2/routes.d.ts
|
|
21
|
+
type R2Bucket$1 = any;
|
|
22
|
+
interface RouteInput {
|
|
23
|
+
bucket: (env: any) => R2Bucket$1;
|
|
24
|
+
sub: (c: any) => Promise<string> | string;
|
|
25
|
+
}
|
|
26
|
+
declare const storage: ({ bucket, sub }: RouteInput) => import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, {
|
|
27
|
+
"/": {
|
|
28
|
+
$get: {
|
|
29
|
+
output: null;
|
|
30
|
+
outputFormat: "json";
|
|
31
|
+
status: 401;
|
|
32
|
+
input: {
|
|
33
|
+
query: {
|
|
34
|
+
prefix: string | string[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
output: {
|
|
39
|
+
path: string;
|
|
40
|
+
size: number;
|
|
41
|
+
date: string;
|
|
42
|
+
kind?: string;
|
|
43
|
+
etag?: string;
|
|
44
|
+
}[];
|
|
45
|
+
outputFormat: "json";
|
|
46
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
47
|
+
input: {
|
|
48
|
+
query: {
|
|
49
|
+
prefix: string | string[];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
} & {
|
|
55
|
+
"/:path{.+}": {
|
|
56
|
+
$get: {
|
|
57
|
+
output: {};
|
|
58
|
+
outputFormat: "body";
|
|
59
|
+
status: 200;
|
|
60
|
+
input: {
|
|
61
|
+
param: {
|
|
62
|
+
path: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
output: null;
|
|
67
|
+
outputFormat: "json";
|
|
68
|
+
status: 401;
|
|
69
|
+
input: {
|
|
70
|
+
param: {
|
|
71
|
+
path: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
} | {
|
|
75
|
+
output: "Not Found";
|
|
76
|
+
outputFormat: "text";
|
|
77
|
+
status: 404;
|
|
78
|
+
input: {
|
|
79
|
+
param: {
|
|
80
|
+
path: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
} & {
|
|
86
|
+
"/:path{.+}": {
|
|
87
|
+
$post: {
|
|
88
|
+
output: null;
|
|
89
|
+
outputFormat: "json";
|
|
90
|
+
status: 401;
|
|
91
|
+
input: {
|
|
92
|
+
query: {
|
|
93
|
+
kind: string | string[];
|
|
94
|
+
site: string | string[];
|
|
95
|
+
};
|
|
96
|
+
} & {
|
|
97
|
+
param: {
|
|
98
|
+
path: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
} | {
|
|
102
|
+
output: {
|
|
103
|
+
path: string;
|
|
104
|
+
size: number;
|
|
105
|
+
date: string;
|
|
106
|
+
kind?: string;
|
|
107
|
+
etag?: string;
|
|
108
|
+
};
|
|
109
|
+
outputFormat: "json";
|
|
110
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
111
|
+
input: {
|
|
112
|
+
query: {
|
|
113
|
+
kind: string | string[];
|
|
114
|
+
site: string | string[];
|
|
115
|
+
};
|
|
116
|
+
} & {
|
|
117
|
+
param: {
|
|
118
|
+
path: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
} & {
|
|
124
|
+
"/:path{.+}": {
|
|
125
|
+
$put: {
|
|
126
|
+
output: null;
|
|
127
|
+
outputFormat: "json";
|
|
128
|
+
status: 401;
|
|
129
|
+
input: {
|
|
130
|
+
query: {
|
|
131
|
+
to: string | string[];
|
|
132
|
+
};
|
|
133
|
+
} & {
|
|
134
|
+
param: {
|
|
135
|
+
path: string;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
} | {
|
|
139
|
+
output: {
|
|
140
|
+
ok: true;
|
|
141
|
+
};
|
|
142
|
+
outputFormat: "json";
|
|
143
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
144
|
+
input: {
|
|
145
|
+
query: {
|
|
146
|
+
to: string | string[];
|
|
147
|
+
};
|
|
148
|
+
} & {
|
|
149
|
+
param: {
|
|
150
|
+
path: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
} & {
|
|
156
|
+
"/:path{.+}": {
|
|
157
|
+
$delete: {
|
|
158
|
+
output: null;
|
|
159
|
+
outputFormat: "json";
|
|
160
|
+
status: 401;
|
|
161
|
+
input: {
|
|
162
|
+
param: {
|
|
163
|
+
path: string;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
} | {
|
|
167
|
+
output: {
|
|
168
|
+
ok: true;
|
|
169
|
+
};
|
|
170
|
+
outputFormat: "json";
|
|
171
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
172
|
+
input: {
|
|
173
|
+
param: {
|
|
174
|
+
path: string;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
}, "/", "/:path{.+}">;
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/hono/r2/utils.d.ts
|
|
182
|
+
declare const MAX_PATH = 512;
|
|
183
|
+
declare const MAX_WRITE = 5242880;
|
|
184
|
+
type R2Bucket = any;
|
|
185
|
+
declare const normalize: (path: string) => string;
|
|
186
|
+
declare const binary: (text: string) => boolean;
|
|
187
|
+
declare const mime: (path: string) => string;
|
|
188
|
+
declare const putObject: (bucket: R2Bucket, key: string, body: any, meta?: {
|
|
189
|
+
type?: string;
|
|
190
|
+
kind?: string;
|
|
191
|
+
site?: string;
|
|
192
|
+
}) => any;
|
|
193
|
+
//#endregion
|
|
194
|
+
export { MAX_PATH, MAX_WRITE, type Obj, type RouteInput, type Store, binary, createR2, mime, normalize, putObject, storage };
|
package/dist/hono/r2.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Hono as e}from"hono";import{validator as t}from"hono/validator";const n=512,r=5242880,i=e=>Array.from(e).some(e=>e.charCodeAt(0)<32),a=e=>e===`..`||e.startsWith(`.`)||i(e),o=e=>{if(typeof e!=`string`||e.length>512)return``;let t=e.split(`/`).filter(e=>e!==``&&e!==`.`);return t.length===0||t.some(a)?``:t.join(`/`)},s=e=>Array.from(e.slice(0,4096)).some(e=>e.charCodeAt(0)===0),c={html:`text/html;charset=utf-8`,htm:`text/html;charset=utf-8`,svg:`image/svg+xml;charset=utf-8`,css:`text/css;charset=utf-8`,js:`text/javascript;charset=utf-8`,mjs:`text/javascript;charset=utf-8`,json:`application/json;charset=utf-8`,md:`text/markdown;charset=utf-8`,csv:`text/csv;charset=utf-8`,xml:`application/xml;charset=utf-8`,yaml:`text/yaml;charset=utf-8`,yml:`text/yaml;charset=utf-8`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,pdf:`application/pdf`,wasm:`application/wasm`},l=e=>c[(e.split(`.`).pop()??``).toLowerCase()]??`text/plain;charset=utf-8`,u=(e,t,n,r={})=>{let i={};return r.kind&&(i.kind=r.kind),r.site&&(i.site=r.site),e.put(t,n,{httpMetadata:r.type?{contentType:r.type}:void 0,customMetadata:Object.keys(i).length?i:void 0})},d=e=>{let t=(e,t)=>`${e}/${t}`,n=(e,t)=>({path:t.key.slice(e.length+1),size:t.size,date:t.uploaded.toISOString(),kind:t.customMetadata?.kind,etag:t.etag}),r=async(i,a=``,o)=>{let s=await e.list({prefix:t(i,a),include:[`customMetadata`],cursor:o}),c=s.objects.map(e=>n(i,e));return s.truncated?[...c,...await r(i,a,s.cursor)]:c};return{list:r,get:(n,r)=>e.get(t(n,r)),head:(n,r)=>e.head(t(n,r)),async put(r,i,a,o={}){return n(r,await u(e,t(r,i),a,o))},async move(n,i,a){let o=(await r(n,i)).filter(e=>e.path===i||e.path.startsWith(`${i}/`));for(let r of o){let o=await e.get(t(n,r.path));o&&(await e.put(t(n,a+r.path.slice(i.length)),o.body,{httpMetadata:o.httpMetadata,customMetadata:o.customMetadata}),await e.delete(t(n,r.path)))}},async remove(n,i){let a=(await r(n,i)).filter(e=>e.path===i||e.path.startsWith(`${i}/`));await Promise.all(a.map(r=>e.delete(t(n,r.path))))}}},f=e=>typeof e==`string`?e:``,p=({bucket:n,sub:r})=>new e().get(`/`,t(`query`,e=>({prefix:f(e.prefix)})),async e=>{let t=await r(e);return t?e.json(await d(n(e.env)).list(t,e.req.valid(`query`).prefix)):e.json(null,401)}).get(`/:path{.+}`,async e=>{let t=await r(e);if(!t)return e.json(null,401);let i=await d(n(e.env)).get(t,e.req.param(`path`));return i?e.body(i.body,200,{"Content-Type":i.httpMetadata?.contentType??`application/octet-stream`}):e.text(`Not Found`,404)}).post(`/:path{.+}`,t(`query`,e=>({kind:f(e.kind),site:f(e.site)})),async e=>{let t=await r(e);if(!t)return e.json(null,401);let{kind:i,site:a}=e.req.valid(`query`);return e.json(await d(n(e.env)).put(t,e.req.param(`path`),await e.req.arrayBuffer(),{type:e.req.header(`Content-Type`),kind:i,site:a}))}).put(`/:path{.+}`,t(`query`,e=>({to:f(e.to)})),async e=>{let t=await r(e);return t?(await d(n(e.env)).move(t,e.req.param(`path`),e.req.valid(`query`).to),e.json({ok:!0})):e.json(null,401)}).delete(`/:path{.+}`,async e=>{let t=await r(e);return t?(await d(n(e.env)).remove(t,e.req.param(`path`)),e.json({ok:!0})):e.json(null,401)});export{n as MAX_PATH,r as MAX_WRITE,s as binary,d as createR2,l as mime,o as normalize,u as putObject,p as storage};
|
package/dist/hono.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ActionDef, Ai, Config, Define, Grant, Own, Peer, Saved, Side } from "./types.js";
|
|
2
|
-
//#region src/index.d.ts
|
|
1
|
+
import { ActionDef, Ai, Config, Define, Grant, Own, Peer, Route, Saved, Side } from "./types.js";
|
|
2
|
+
//#region src/core/index.d.ts
|
|
3
3
|
declare const side: Side;
|
|
4
4
|
declare function x<P extends object>(params: P, config?: Config): Ai<P>;
|
|
5
5
|
declare function x<P extends object = {}>(params?: Partial<P>, config?: Config): Ai<P>;
|
|
6
6
|
//#endregion
|
|
7
|
-
export { type ActionDef, type Ai, type Config, type Define, type Grant, type Own, type Peer, type Saved, type Side, side, x };
|
|
7
|
+
export { type ActionDef, type Ai, type Config, type Define, type Grant, type Own, type Peer, type Route, type Saved, type Side, side, x };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-ax",
|
|
3
3
|
"author": "tseijp",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "AI Agent Experience (AI/AX) library for Hono + Cloudflare. One act surface for both human UI/UX and LLM MCP tools, with authentication, authorization, realtime sync and Claude API relay.",
|
|
7
7
|
"keywords": [
|
|
@@ -34,6 +34,14 @@
|
|
|
34
34
|
"types": "./dist/client.d.ts",
|
|
35
35
|
"default": "./dist/client.js"
|
|
36
36
|
},
|
|
37
|
+
"./client/react": {
|
|
38
|
+
"types": "./dist/client/react.d.ts",
|
|
39
|
+
"default": "./dist/client/react.js"
|
|
40
|
+
},
|
|
41
|
+
"./client/ui": {
|
|
42
|
+
"types": "./dist/client/ui.d.ts",
|
|
43
|
+
"default": "./dist/client/ui.js"
|
|
44
|
+
},
|
|
37
45
|
"./const": {
|
|
38
46
|
"types": "./dist/const.d.ts",
|
|
39
47
|
"default": "./dist/const.js"
|
|
@@ -42,9 +50,13 @@
|
|
|
42
50
|
"types": "./dist/hono.d.ts",
|
|
43
51
|
"default": "./dist/hono.js"
|
|
44
52
|
},
|
|
45
|
-
"./
|
|
46
|
-
"types": "./dist/
|
|
47
|
-
"default": "./dist/
|
|
53
|
+
"./hono/r2": {
|
|
54
|
+
"types": "./dist/hono/r2.d.ts",
|
|
55
|
+
"default": "./dist/hono/r2.js"
|
|
56
|
+
},
|
|
57
|
+
"./hono/d1": {
|
|
58
|
+
"types": "./dist/hono/d1.d.ts",
|
|
59
|
+
"default": "./dist/hono/d1.js"
|
|
48
60
|
},
|
|
49
61
|
"./server": {
|
|
50
62
|
"types": "./dist/server.d.ts",
|
|
@@ -69,16 +81,20 @@
|
|
|
69
81
|
"README.md"
|
|
70
82
|
],
|
|
71
83
|
"scripts": {
|
|
72
|
-
"build": "tsdown --config ../../tsdown.config.ts
|
|
84
|
+
"build": "tsdown --config ../../tsdown.config.ts",
|
|
73
85
|
"mmd": "for f in concept stack grant; do mmdc -i media/$f.mmd -o media/$f.svg; done"
|
|
74
86
|
},
|
|
75
87
|
"devDependencies": {
|
|
76
88
|
"@auth/core": "0.34.3",
|
|
77
89
|
"@hono/auth-js": "1.1.1",
|
|
78
90
|
"@hono/mcp": "0.3.1",
|
|
91
|
+
"@material-symbols/svg-400": "^0.45.8",
|
|
79
92
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
93
|
+
"@types/markdown-it": "^14.2.0",
|
|
80
94
|
"@types/react": "^19.2.17",
|
|
95
|
+
"drizzle-orm": "^0.45.2",
|
|
81
96
|
"hono": "4.12.30",
|
|
97
|
+
"markdown-it": "^14.2.0",
|
|
82
98
|
"partyserver": "0.5.8",
|
|
83
99
|
"react": "^19.2.7",
|
|
84
100
|
"y-partyserver": "2.2.0",
|
|
@@ -89,8 +105,11 @@
|
|
|
89
105
|
"@auth/core": ">=0.34.0",
|
|
90
106
|
"@hono/auth-js": ">=1.0.0",
|
|
91
107
|
"@hono/mcp": ">=0.3.0",
|
|
108
|
+
"@material-symbols/svg-400": ">=0.45.0",
|
|
92
109
|
"@modelcontextprotocol/sdk": ">=1.0.0",
|
|
110
|
+
"drizzle-orm": ">=0.44.0",
|
|
93
111
|
"hono": ">=4.0.0",
|
|
112
|
+
"markdown-it": ">=14.0.0",
|
|
94
113
|
"partyserver": ">=0.5.0",
|
|
95
114
|
"react": ">=18.0.0",
|
|
96
115
|
"y-partyserver": ">=2.0.0",
|
|
@@ -104,6 +123,9 @@
|
|
|
104
123
|
"@hono/mcp": {
|
|
105
124
|
"optional": true
|
|
106
125
|
},
|
|
126
|
+
"@material-symbols/svg-400": {
|
|
127
|
+
"optional": true
|
|
128
|
+
},
|
|
107
129
|
"@modelcontextprotocol/sdk": {
|
|
108
130
|
"optional": true
|
|
109
131
|
},
|
|
@@ -112,6 +134,12 @@
|
|
|
112
134
|
},
|
|
113
135
|
"react": {
|
|
114
136
|
"optional": true
|
|
137
|
+
},
|
|
138
|
+
"markdown-it": {
|
|
139
|
+
"optional": true
|
|
140
|
+
},
|
|
141
|
+
"drizzle-orm": {
|
|
142
|
+
"optional": true
|
|
115
143
|
}
|
|
116
144
|
}
|
|
117
145
|
}
|