vfs-kit 1.0.1 → 1.0.2
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/LICENSE +21 -21
- package/README.md +145 -35
- package/dist/VfsAdapter-BWjniD9Y.d.mts +57 -0
- package/dist/VfsAdapter-DOBt_TyL.d.ts +57 -0
- package/dist/VfsEngine-B6nhgyjQ.d.mts +152 -0
- package/dist/VfsEngine-DLx0iUpi.d.ts +152 -0
- package/dist/VfsNode-D10gxL5W.d.mts +48 -0
- package/dist/VfsNode-D10gxL5W.d.ts +48 -0
- package/dist/adapters/index.d.mts +201 -0
- package/dist/adapters/index.d.ts +201 -0
- package/dist/adapters/index.js +1159 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/index.mjs +1159 -0
- package/dist/adapters/index.mjs.map +1 -0
- package/dist/chunk-2FEJBM4N.js +60 -0
- package/dist/chunk-2FEJBM4N.js.map +1 -0
- package/dist/chunk-7OQI6PNM.mjs +60 -0
- package/dist/chunk-7OQI6PNM.mjs.map +1 -0
- package/dist/chunk-ALWOZGZI.mjs +23 -0
- package/dist/chunk-ALWOZGZI.mjs.map +1 -0
- package/dist/chunk-POSVS4C7.mjs +531 -0
- package/dist/chunk-POSVS4C7.mjs.map +1 -0
- package/dist/chunk-R3ROYAMW.js +23 -0
- package/dist/chunk-R3ROYAMW.js.map +1 -0
- package/dist/chunk-SWRBVSS6.mjs +16 -0
- package/dist/chunk-SWRBVSS6.mjs.map +1 -0
- package/dist/chunk-U2CKTXY7.js +16 -0
- package/dist/chunk-U2CKTXY7.js.map +1 -0
- package/dist/chunk-WZVVI3HX.js +531 -0
- package/dist/chunk-WZVVI3HX.js.map +1 -0
- package/dist/components/index.d.mts +193 -0
- package/dist/components/index.d.ts +193 -0
- package/dist/components/index.js +1197 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +1197 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/hooks/index.d.mts +120 -0
- package/dist/hooks/index.d.ts +120 -0
- package/dist/hooks/index.js +51 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +51 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +42 -0
- package/dist/index.d.ts +38 -3
- package/dist/index.js +528 -13
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +530 -0
- package/dist/index.mjs.map +1 -0
- package/dist/useVfsTabs-ZHDaLrM1.d.mts +39 -0
- package/dist/useVfsTabs-ZHDaLrM1.d.ts +39 -0
- package/package.json +59 -61
- package/dist/index.cjs +0 -43
- package/dist/index.d.cts +0 -7
- package/index.js +0 -7
- package/src/components/TreeView.tsx +0 -5
- package/src/components/index.ts +0 -1
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useVfs.ts +0 -3
- package/src/index.ts +0 -2
- package/tsconfig.json +0 -44
- package/tsup.config.ts +0 -10
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
interface VfsBaseNode<TMeta = Record<string, unknown>> {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
parentId: string | null;
|
|
5
|
+
sortIndex: number | null;
|
|
6
|
+
lockedBy: string | null;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
updatedAt: number;
|
|
9
|
+
deletedAt: number | null;
|
|
10
|
+
meta: TMeta;
|
|
11
|
+
}
|
|
12
|
+
interface VfsNodeOrder {
|
|
13
|
+
parentId: string | null;
|
|
14
|
+
orderedIds: string[];
|
|
15
|
+
}
|
|
16
|
+
interface VfsFileNode<TMeta = Record<string, unknown>> extends VfsBaseNode<TMeta> {
|
|
17
|
+
kind: "file";
|
|
18
|
+
mimeType: string;
|
|
19
|
+
size: number;
|
|
20
|
+
}
|
|
21
|
+
interface VfsFolderNode<TMeta = Record<string, unknown>> extends VfsBaseNode<TMeta> {
|
|
22
|
+
kind: "folder";
|
|
23
|
+
}
|
|
24
|
+
type VfsNode<TMeta = Record<string, unknown>> = VfsFileNode<TMeta> | VfsFolderNode<TMeta>;
|
|
25
|
+
interface VfsFileSnapshot {
|
|
26
|
+
id: string;
|
|
27
|
+
fileId: string;
|
|
28
|
+
index: number;
|
|
29
|
+
content: Uint8Array;
|
|
30
|
+
createdAt: number;
|
|
31
|
+
label?: string;
|
|
32
|
+
}
|
|
33
|
+
type VfsOperation = "create" | "rename" | "delete" | "restore" | "purge" | "move" | "write" | "lock" | "unlock" | "reorder" | "snapshot";
|
|
34
|
+
interface VfsEngineConfig<TMeta = Record<string, unknown>> {
|
|
35
|
+
sessionId: string;
|
|
36
|
+
allowDuplicateNames: boolean;
|
|
37
|
+
duplicateResolution: "throw" | "auto-rename" | "allow";
|
|
38
|
+
checkPermission?: (node: VfsNode<TMeta>, op: VfsOperation) => boolean;
|
|
39
|
+
history?: {
|
|
40
|
+
maxSnapshots: number;
|
|
41
|
+
autosave?: {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
intervalMs: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type { VfsEngineConfig as V, VfsBaseNode as a, VfsFileNode as b, VfsFileSnapshot as c, VfsFolderNode as d, VfsNode as e, VfsNodeOrder as f, VfsOperation as g };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
interface VfsBaseNode<TMeta = Record<string, unknown>> {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
parentId: string | null;
|
|
5
|
+
sortIndex: number | null;
|
|
6
|
+
lockedBy: string | null;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
updatedAt: number;
|
|
9
|
+
deletedAt: number | null;
|
|
10
|
+
meta: TMeta;
|
|
11
|
+
}
|
|
12
|
+
interface VfsNodeOrder {
|
|
13
|
+
parentId: string | null;
|
|
14
|
+
orderedIds: string[];
|
|
15
|
+
}
|
|
16
|
+
interface VfsFileNode<TMeta = Record<string, unknown>> extends VfsBaseNode<TMeta> {
|
|
17
|
+
kind: "file";
|
|
18
|
+
mimeType: string;
|
|
19
|
+
size: number;
|
|
20
|
+
}
|
|
21
|
+
interface VfsFolderNode<TMeta = Record<string, unknown>> extends VfsBaseNode<TMeta> {
|
|
22
|
+
kind: "folder";
|
|
23
|
+
}
|
|
24
|
+
type VfsNode<TMeta = Record<string, unknown>> = VfsFileNode<TMeta> | VfsFolderNode<TMeta>;
|
|
25
|
+
interface VfsFileSnapshot {
|
|
26
|
+
id: string;
|
|
27
|
+
fileId: string;
|
|
28
|
+
index: number;
|
|
29
|
+
content: Uint8Array;
|
|
30
|
+
createdAt: number;
|
|
31
|
+
label?: string;
|
|
32
|
+
}
|
|
33
|
+
type VfsOperation = "create" | "rename" | "delete" | "restore" | "purge" | "move" | "write" | "lock" | "unlock" | "reorder" | "snapshot";
|
|
34
|
+
interface VfsEngineConfig<TMeta = Record<string, unknown>> {
|
|
35
|
+
sessionId: string;
|
|
36
|
+
allowDuplicateNames: boolean;
|
|
37
|
+
duplicateResolution: "throw" | "auto-rename" | "allow";
|
|
38
|
+
checkPermission?: (node: VfsNode<TMeta>, op: VfsOperation) => boolean;
|
|
39
|
+
history?: {
|
|
40
|
+
maxSnapshots: number;
|
|
41
|
+
autosave?: {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
intervalMs: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type { VfsEngineConfig as V, VfsBaseNode as a, VfsFileNode as b, VfsFileSnapshot as c, VfsFolderNode as d, VfsNode as e, VfsNodeOrder as f, VfsOperation as g };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { V as VfsAdapter, d as VfsSearchOptions, b as VfsCreateFileParams, c as VfsCreateFolderParams, a as VfsChange } from '../VfsAdapter-BWjniD9Y.mjs';
|
|
2
|
+
import { e as VfsNode, b as VfsFileNode, d as VfsFolderNode, f as VfsNodeOrder, c as VfsFileSnapshot } from '../VfsNode-D10gxL5W.mjs';
|
|
3
|
+
|
|
4
|
+
interface StoredFile<TMeta> {
|
|
5
|
+
node: VfsFileNode<TMeta>;
|
|
6
|
+
content: Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
interface StoredFolder<TMeta> {
|
|
9
|
+
node: VfsFolderNode<TMeta>;
|
|
10
|
+
}
|
|
11
|
+
type StoredEntry<TMeta> = StoredFile<TMeta> | StoredFolder<TMeta>;
|
|
12
|
+
declare class InMemoryAdapter<TMeta = Record<string, unknown>> extends VfsAdapter<TMeta> {
|
|
13
|
+
readonly supportsHistory = true;
|
|
14
|
+
private store;
|
|
15
|
+
private orders;
|
|
16
|
+
private snapshots;
|
|
17
|
+
private listeners;
|
|
18
|
+
generateId(): string;
|
|
19
|
+
private mutate;
|
|
20
|
+
private notifyChanged;
|
|
21
|
+
private makeFileNode;
|
|
22
|
+
private makeFolderNode;
|
|
23
|
+
getNodes(ids: string[]): Promise<VfsNode<TMeta>[]>;
|
|
24
|
+
getNodeById(id: string): Promise<VfsNode<TMeta> | null>;
|
|
25
|
+
getNodeByPath(path: string): Promise<VfsNode<TMeta> | null>;
|
|
26
|
+
getChildren(parentId: string | null, options?: {
|
|
27
|
+
includeTrashed?: boolean;
|
|
28
|
+
}): Promise<VfsNode<TMeta>[]>;
|
|
29
|
+
getTrashed(): Promise<VfsNode<TMeta>[]>;
|
|
30
|
+
search(query: string, options?: VfsSearchOptions): Promise<VfsNode<TMeta>[]>;
|
|
31
|
+
readFile(id: string): Promise<Uint8Array>;
|
|
32
|
+
writeFile(id: string, content: Uint8Array): Promise<void>;
|
|
33
|
+
createFile(params: VfsCreateFileParams): Promise<VfsFileNode<TMeta>>;
|
|
34
|
+
createFolder(params: VfsCreateFolderParams): Promise<VfsFolderNode<TMeta>>;
|
|
35
|
+
updateNode(id: string, updates: Partial<VfsNode<TMeta>>): Promise<VfsNode<TMeta>>;
|
|
36
|
+
deleteNode(id: string, permanent?: boolean): Promise<void>;
|
|
37
|
+
deleteNodes(ids: string[], permanent?: boolean): Promise<void>;
|
|
38
|
+
restoreNode(id: string): Promise<VfsNode<TMeta>>;
|
|
39
|
+
purgeNode(id: string): Promise<void>;
|
|
40
|
+
moveNode(id: string, newParentId: string | null): Promise<VfsNode<TMeta>>;
|
|
41
|
+
moveNodes(ids: string[], newParentId: string | null): Promise<VfsNode<TMeta>[]>;
|
|
42
|
+
lockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
43
|
+
unlockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
44
|
+
getOrder(parentId: string | null): Promise<VfsNodeOrder | null>;
|
|
45
|
+
setOrder(parentId: string | null, orderedIds: string[]): Promise<void>;
|
|
46
|
+
getSnapshots(fileId: string): Promise<VfsFileSnapshot[]>;
|
|
47
|
+
saveSnapshot(fileId: string, content: Uint8Array, label?: string): Promise<VfsFileSnapshot>;
|
|
48
|
+
restoreSnapshot(fileId: string, index: number): Promise<void>;
|
|
49
|
+
deleteSnapshot(fileId: string, index: number): Promise<void>;
|
|
50
|
+
onChanged(callback: (change: VfsChange) => void): () => void;
|
|
51
|
+
private deleteRecursive;
|
|
52
|
+
private isDescendantOf;
|
|
53
|
+
seed(nodes: Array<{
|
|
54
|
+
node: VfsNode<TMeta>;
|
|
55
|
+
content?: Uint8Array;
|
|
56
|
+
}>): void;
|
|
57
|
+
clear(): void;
|
|
58
|
+
snapshot(): Map<string, StoredEntry<TMeta>>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type IsolationMode = "private" | "shared";
|
|
62
|
+
interface IndexedDBAdapterOptions {
|
|
63
|
+
dbName: string;
|
|
64
|
+
dbVersion?: number;
|
|
65
|
+
isolation?: IsolationMode;
|
|
66
|
+
}
|
|
67
|
+
declare class IndexedDBAdapter<TMeta = Record<string, unknown>> extends VfsAdapter<TMeta> {
|
|
68
|
+
readonly supportsHistory = true;
|
|
69
|
+
private db;
|
|
70
|
+
private options;
|
|
71
|
+
private listeners;
|
|
72
|
+
private channel;
|
|
73
|
+
constructor(options: IndexedDBAdapterOptions);
|
|
74
|
+
open(): Promise<void>;
|
|
75
|
+
close(): void;
|
|
76
|
+
private get idb();
|
|
77
|
+
generateId(): string;
|
|
78
|
+
private mutate;
|
|
79
|
+
private notifyListeners;
|
|
80
|
+
private makeFileNode;
|
|
81
|
+
private makeFolderNode;
|
|
82
|
+
getNodes(ids: string[]): Promise<VfsNode<TMeta>[]>;
|
|
83
|
+
getNodeById(id: string): Promise<VfsNode<TMeta> | null>;
|
|
84
|
+
getNodeByPath(path: string): Promise<VfsNode<TMeta> | null>;
|
|
85
|
+
getChildren(parentId: string | null, options?: {
|
|
86
|
+
includeTrashed?: boolean;
|
|
87
|
+
}): Promise<VfsNode<TMeta>[]>;
|
|
88
|
+
getTrashed(): Promise<VfsNode<TMeta>[]>;
|
|
89
|
+
search(query: string, options?: VfsSearchOptions): Promise<VfsNode<TMeta>[]>;
|
|
90
|
+
readFile(id: string): Promise<Uint8Array>;
|
|
91
|
+
writeFile(id: string, content: Uint8Array): Promise<void>;
|
|
92
|
+
createFile(params: VfsCreateFileParams): Promise<VfsFileNode<TMeta>>;
|
|
93
|
+
createFolder(params: VfsCreateFolderParams): Promise<VfsFolderNode<TMeta>>;
|
|
94
|
+
updateNode(id: string, updates: Partial<VfsNode<TMeta>>): Promise<VfsNode<TMeta>>;
|
|
95
|
+
deleteNode(id: string, permanent?: boolean): Promise<void>;
|
|
96
|
+
deleteNodes(ids: string[], permanent?: boolean): Promise<void>;
|
|
97
|
+
restoreNode(id: string): Promise<VfsNode<TMeta>>;
|
|
98
|
+
purgeNode(id: string): Promise<void>;
|
|
99
|
+
moveNode(id: string, newParentId: string | null): Promise<VfsNode<TMeta>>;
|
|
100
|
+
moveNodes(ids: string[], newParentId: string | null): Promise<VfsNode<TMeta>[]>;
|
|
101
|
+
lockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
102
|
+
unlockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
103
|
+
getOrder(parentId: string | null): Promise<VfsNodeOrder | null>;
|
|
104
|
+
setOrder(parentId: string | null, orderedIds: string[]): Promise<void>;
|
|
105
|
+
getSnapshots(fileId: string): Promise<VfsFileSnapshot[]>;
|
|
106
|
+
saveSnapshot(fileId: string, content: Uint8Array, label?: string): Promise<VfsFileSnapshot>;
|
|
107
|
+
restoreSnapshot(fileId: string, index: number): Promise<void>;
|
|
108
|
+
deleteSnapshot(fileId: string, index: number): Promise<void>;
|
|
109
|
+
onChanged(callback: (change: VfsChange) => void): () => void;
|
|
110
|
+
private deleteRecursive;
|
|
111
|
+
private isDescendantOf;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type VfsFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
115
|
+
interface VfsEndpointMap {
|
|
116
|
+
getNode: (id: string) => string;
|
|
117
|
+
getNodes: (ids: string[]) => string;
|
|
118
|
+
getNodeByPath: (path: string) => string;
|
|
119
|
+
getChildren: (parentId: string | null) => string;
|
|
120
|
+
getTrashed: () => string;
|
|
121
|
+
search: (query: string) => string;
|
|
122
|
+
readFile: (id: string) => string;
|
|
123
|
+
writeFile: (id: string) => string;
|
|
124
|
+
createFile: () => string;
|
|
125
|
+
createFolder: () => string;
|
|
126
|
+
updateNode: (id: string) => string;
|
|
127
|
+
deleteNode: (id: string) => string;
|
|
128
|
+
deleteNodes: () => string;
|
|
129
|
+
restoreNode: (id: string) => string;
|
|
130
|
+
purgeNode: (id: string) => string;
|
|
131
|
+
moveNode: (id: string) => string;
|
|
132
|
+
moveNodes: () => string;
|
|
133
|
+
lockNode: (id: string) => string;
|
|
134
|
+
unlockNode: (id: string) => string;
|
|
135
|
+
getOrder: (parentId: string | null) => string;
|
|
136
|
+
setOrder: (parentId: string | null) => string;
|
|
137
|
+
getSnapshots: (fileId: string) => string;
|
|
138
|
+
saveSnapshot: (fileId: string) => string;
|
|
139
|
+
restoreSnapshot: (fileId: string, index: number) => string;
|
|
140
|
+
deleteSnapshot: (fileId: string, index: number) => string;
|
|
141
|
+
subscribe: () => string;
|
|
142
|
+
}
|
|
143
|
+
type RealtimeFallback = (onMessage: (change: VfsChange) => void, onError: (err: Error) => void) => () => void;
|
|
144
|
+
interface RestAdapterOptions {
|
|
145
|
+
baseUrl: string;
|
|
146
|
+
fetch?: VfsFetch;
|
|
147
|
+
endpoints?: Partial<VfsEndpointMap>;
|
|
148
|
+
realtimeFallback?: RealtimeFallback;
|
|
149
|
+
supportsHistory?: boolean;
|
|
150
|
+
}
|
|
151
|
+
declare class RestAdapter<TMeta = Record<string, unknown>> extends VfsAdapter<TMeta> {
|
|
152
|
+
readonly supportsHistory: boolean;
|
|
153
|
+
private fetch;
|
|
154
|
+
private endpoints;
|
|
155
|
+
private options;
|
|
156
|
+
private listeners;
|
|
157
|
+
private eventSource;
|
|
158
|
+
constructor(options: RestAdapterOptions);
|
|
159
|
+
open(): Promise<void>;
|
|
160
|
+
close(): void;
|
|
161
|
+
private connectRealtime;
|
|
162
|
+
private fallbackRealtime;
|
|
163
|
+
private notifyListeners;
|
|
164
|
+
generateId(): string;
|
|
165
|
+
private get;
|
|
166
|
+
private post;
|
|
167
|
+
private patch;
|
|
168
|
+
private delete;
|
|
169
|
+
private postBinary;
|
|
170
|
+
private mutate;
|
|
171
|
+
getNodes(ids: string[]): Promise<VfsNode<TMeta>[]>;
|
|
172
|
+
getNodeById(id: string): Promise<VfsNode<TMeta> | null>;
|
|
173
|
+
getNodeByPath(path: string): Promise<VfsNode<TMeta> | null>;
|
|
174
|
+
getChildren(parentId: string | null, options?: {
|
|
175
|
+
includeTrashed?: boolean;
|
|
176
|
+
}): Promise<VfsNode<TMeta>[]>;
|
|
177
|
+
getTrashed(): Promise<VfsNode<TMeta>[]>;
|
|
178
|
+
search(query: string, options?: VfsSearchOptions): Promise<VfsNode<TMeta>[]>;
|
|
179
|
+
readFile(id: string): Promise<Uint8Array>;
|
|
180
|
+
writeFile(id: string, content: Uint8Array): Promise<void>;
|
|
181
|
+
createFile(params: VfsCreateFileParams): Promise<VfsFileNode<TMeta>>;
|
|
182
|
+
createFolder(params: VfsCreateFolderParams): Promise<VfsFolderNode<TMeta>>;
|
|
183
|
+
updateNode(id: string, updates: Partial<VfsNode<TMeta>>): Promise<VfsNode<TMeta>>;
|
|
184
|
+
deleteNode(id: string, permanent?: boolean): Promise<void>;
|
|
185
|
+
deleteNodes(ids: string[], permanent?: boolean): Promise<void>;
|
|
186
|
+
restoreNode(id: string): Promise<VfsNode<TMeta>>;
|
|
187
|
+
purgeNode(id: string): Promise<void>;
|
|
188
|
+
moveNode(id: string, newParentId: string | null): Promise<VfsNode<TMeta>>;
|
|
189
|
+
moveNodes(ids: string[], newParentId: string | null): Promise<VfsNode<TMeta>[]>;
|
|
190
|
+
lockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
191
|
+
unlockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
192
|
+
getOrder(parentId: string | null): Promise<VfsNodeOrder | null>;
|
|
193
|
+
setOrder(parentId: string | null, orderedIds: string[]): Promise<void>;
|
|
194
|
+
getSnapshots(fileId: string): Promise<VfsFileSnapshot[]>;
|
|
195
|
+
saveSnapshot(fileId: string, content: Uint8Array, label?: string): Promise<VfsFileSnapshot>;
|
|
196
|
+
restoreSnapshot(fileId: string, index: number): Promise<void>;
|
|
197
|
+
deleteSnapshot(fileId: string, index: number): Promise<void>;
|
|
198
|
+
onChanged(callback: (change: VfsChange) => void): () => void;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { InMemoryAdapter, IndexedDBAdapter, type IndexedDBAdapterOptions, type IsolationMode, type RealtimeFallback, RestAdapter, type RestAdapterOptions, type VfsEndpointMap, type VfsFetch };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { V as VfsAdapter, d as VfsSearchOptions, b as VfsCreateFileParams, c as VfsCreateFolderParams, a as VfsChange } from '../VfsAdapter-DOBt_TyL.js';
|
|
2
|
+
import { e as VfsNode, b as VfsFileNode, d as VfsFolderNode, f as VfsNodeOrder, c as VfsFileSnapshot } from '../VfsNode-D10gxL5W.js';
|
|
3
|
+
|
|
4
|
+
interface StoredFile<TMeta> {
|
|
5
|
+
node: VfsFileNode<TMeta>;
|
|
6
|
+
content: Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
interface StoredFolder<TMeta> {
|
|
9
|
+
node: VfsFolderNode<TMeta>;
|
|
10
|
+
}
|
|
11
|
+
type StoredEntry<TMeta> = StoredFile<TMeta> | StoredFolder<TMeta>;
|
|
12
|
+
declare class InMemoryAdapter<TMeta = Record<string, unknown>> extends VfsAdapter<TMeta> {
|
|
13
|
+
readonly supportsHistory = true;
|
|
14
|
+
private store;
|
|
15
|
+
private orders;
|
|
16
|
+
private snapshots;
|
|
17
|
+
private listeners;
|
|
18
|
+
generateId(): string;
|
|
19
|
+
private mutate;
|
|
20
|
+
private notifyChanged;
|
|
21
|
+
private makeFileNode;
|
|
22
|
+
private makeFolderNode;
|
|
23
|
+
getNodes(ids: string[]): Promise<VfsNode<TMeta>[]>;
|
|
24
|
+
getNodeById(id: string): Promise<VfsNode<TMeta> | null>;
|
|
25
|
+
getNodeByPath(path: string): Promise<VfsNode<TMeta> | null>;
|
|
26
|
+
getChildren(parentId: string | null, options?: {
|
|
27
|
+
includeTrashed?: boolean;
|
|
28
|
+
}): Promise<VfsNode<TMeta>[]>;
|
|
29
|
+
getTrashed(): Promise<VfsNode<TMeta>[]>;
|
|
30
|
+
search(query: string, options?: VfsSearchOptions): Promise<VfsNode<TMeta>[]>;
|
|
31
|
+
readFile(id: string): Promise<Uint8Array>;
|
|
32
|
+
writeFile(id: string, content: Uint8Array): Promise<void>;
|
|
33
|
+
createFile(params: VfsCreateFileParams): Promise<VfsFileNode<TMeta>>;
|
|
34
|
+
createFolder(params: VfsCreateFolderParams): Promise<VfsFolderNode<TMeta>>;
|
|
35
|
+
updateNode(id: string, updates: Partial<VfsNode<TMeta>>): Promise<VfsNode<TMeta>>;
|
|
36
|
+
deleteNode(id: string, permanent?: boolean): Promise<void>;
|
|
37
|
+
deleteNodes(ids: string[], permanent?: boolean): Promise<void>;
|
|
38
|
+
restoreNode(id: string): Promise<VfsNode<TMeta>>;
|
|
39
|
+
purgeNode(id: string): Promise<void>;
|
|
40
|
+
moveNode(id: string, newParentId: string | null): Promise<VfsNode<TMeta>>;
|
|
41
|
+
moveNodes(ids: string[], newParentId: string | null): Promise<VfsNode<TMeta>[]>;
|
|
42
|
+
lockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
43
|
+
unlockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
44
|
+
getOrder(parentId: string | null): Promise<VfsNodeOrder | null>;
|
|
45
|
+
setOrder(parentId: string | null, orderedIds: string[]): Promise<void>;
|
|
46
|
+
getSnapshots(fileId: string): Promise<VfsFileSnapshot[]>;
|
|
47
|
+
saveSnapshot(fileId: string, content: Uint8Array, label?: string): Promise<VfsFileSnapshot>;
|
|
48
|
+
restoreSnapshot(fileId: string, index: number): Promise<void>;
|
|
49
|
+
deleteSnapshot(fileId: string, index: number): Promise<void>;
|
|
50
|
+
onChanged(callback: (change: VfsChange) => void): () => void;
|
|
51
|
+
private deleteRecursive;
|
|
52
|
+
private isDescendantOf;
|
|
53
|
+
seed(nodes: Array<{
|
|
54
|
+
node: VfsNode<TMeta>;
|
|
55
|
+
content?: Uint8Array;
|
|
56
|
+
}>): void;
|
|
57
|
+
clear(): void;
|
|
58
|
+
snapshot(): Map<string, StoredEntry<TMeta>>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type IsolationMode = "private" | "shared";
|
|
62
|
+
interface IndexedDBAdapterOptions {
|
|
63
|
+
dbName: string;
|
|
64
|
+
dbVersion?: number;
|
|
65
|
+
isolation?: IsolationMode;
|
|
66
|
+
}
|
|
67
|
+
declare class IndexedDBAdapter<TMeta = Record<string, unknown>> extends VfsAdapter<TMeta> {
|
|
68
|
+
readonly supportsHistory = true;
|
|
69
|
+
private db;
|
|
70
|
+
private options;
|
|
71
|
+
private listeners;
|
|
72
|
+
private channel;
|
|
73
|
+
constructor(options: IndexedDBAdapterOptions);
|
|
74
|
+
open(): Promise<void>;
|
|
75
|
+
close(): void;
|
|
76
|
+
private get idb();
|
|
77
|
+
generateId(): string;
|
|
78
|
+
private mutate;
|
|
79
|
+
private notifyListeners;
|
|
80
|
+
private makeFileNode;
|
|
81
|
+
private makeFolderNode;
|
|
82
|
+
getNodes(ids: string[]): Promise<VfsNode<TMeta>[]>;
|
|
83
|
+
getNodeById(id: string): Promise<VfsNode<TMeta> | null>;
|
|
84
|
+
getNodeByPath(path: string): Promise<VfsNode<TMeta> | null>;
|
|
85
|
+
getChildren(parentId: string | null, options?: {
|
|
86
|
+
includeTrashed?: boolean;
|
|
87
|
+
}): Promise<VfsNode<TMeta>[]>;
|
|
88
|
+
getTrashed(): Promise<VfsNode<TMeta>[]>;
|
|
89
|
+
search(query: string, options?: VfsSearchOptions): Promise<VfsNode<TMeta>[]>;
|
|
90
|
+
readFile(id: string): Promise<Uint8Array>;
|
|
91
|
+
writeFile(id: string, content: Uint8Array): Promise<void>;
|
|
92
|
+
createFile(params: VfsCreateFileParams): Promise<VfsFileNode<TMeta>>;
|
|
93
|
+
createFolder(params: VfsCreateFolderParams): Promise<VfsFolderNode<TMeta>>;
|
|
94
|
+
updateNode(id: string, updates: Partial<VfsNode<TMeta>>): Promise<VfsNode<TMeta>>;
|
|
95
|
+
deleteNode(id: string, permanent?: boolean): Promise<void>;
|
|
96
|
+
deleteNodes(ids: string[], permanent?: boolean): Promise<void>;
|
|
97
|
+
restoreNode(id: string): Promise<VfsNode<TMeta>>;
|
|
98
|
+
purgeNode(id: string): Promise<void>;
|
|
99
|
+
moveNode(id: string, newParentId: string | null): Promise<VfsNode<TMeta>>;
|
|
100
|
+
moveNodes(ids: string[], newParentId: string | null): Promise<VfsNode<TMeta>[]>;
|
|
101
|
+
lockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
102
|
+
unlockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
103
|
+
getOrder(parentId: string | null): Promise<VfsNodeOrder | null>;
|
|
104
|
+
setOrder(parentId: string | null, orderedIds: string[]): Promise<void>;
|
|
105
|
+
getSnapshots(fileId: string): Promise<VfsFileSnapshot[]>;
|
|
106
|
+
saveSnapshot(fileId: string, content: Uint8Array, label?: string): Promise<VfsFileSnapshot>;
|
|
107
|
+
restoreSnapshot(fileId: string, index: number): Promise<void>;
|
|
108
|
+
deleteSnapshot(fileId: string, index: number): Promise<void>;
|
|
109
|
+
onChanged(callback: (change: VfsChange) => void): () => void;
|
|
110
|
+
private deleteRecursive;
|
|
111
|
+
private isDescendantOf;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type VfsFetch = (url: string, init?: RequestInit) => Promise<Response>;
|
|
115
|
+
interface VfsEndpointMap {
|
|
116
|
+
getNode: (id: string) => string;
|
|
117
|
+
getNodes: (ids: string[]) => string;
|
|
118
|
+
getNodeByPath: (path: string) => string;
|
|
119
|
+
getChildren: (parentId: string | null) => string;
|
|
120
|
+
getTrashed: () => string;
|
|
121
|
+
search: (query: string) => string;
|
|
122
|
+
readFile: (id: string) => string;
|
|
123
|
+
writeFile: (id: string) => string;
|
|
124
|
+
createFile: () => string;
|
|
125
|
+
createFolder: () => string;
|
|
126
|
+
updateNode: (id: string) => string;
|
|
127
|
+
deleteNode: (id: string) => string;
|
|
128
|
+
deleteNodes: () => string;
|
|
129
|
+
restoreNode: (id: string) => string;
|
|
130
|
+
purgeNode: (id: string) => string;
|
|
131
|
+
moveNode: (id: string) => string;
|
|
132
|
+
moveNodes: () => string;
|
|
133
|
+
lockNode: (id: string) => string;
|
|
134
|
+
unlockNode: (id: string) => string;
|
|
135
|
+
getOrder: (parentId: string | null) => string;
|
|
136
|
+
setOrder: (parentId: string | null) => string;
|
|
137
|
+
getSnapshots: (fileId: string) => string;
|
|
138
|
+
saveSnapshot: (fileId: string) => string;
|
|
139
|
+
restoreSnapshot: (fileId: string, index: number) => string;
|
|
140
|
+
deleteSnapshot: (fileId: string, index: number) => string;
|
|
141
|
+
subscribe: () => string;
|
|
142
|
+
}
|
|
143
|
+
type RealtimeFallback = (onMessage: (change: VfsChange) => void, onError: (err: Error) => void) => () => void;
|
|
144
|
+
interface RestAdapterOptions {
|
|
145
|
+
baseUrl: string;
|
|
146
|
+
fetch?: VfsFetch;
|
|
147
|
+
endpoints?: Partial<VfsEndpointMap>;
|
|
148
|
+
realtimeFallback?: RealtimeFallback;
|
|
149
|
+
supportsHistory?: boolean;
|
|
150
|
+
}
|
|
151
|
+
declare class RestAdapter<TMeta = Record<string, unknown>> extends VfsAdapter<TMeta> {
|
|
152
|
+
readonly supportsHistory: boolean;
|
|
153
|
+
private fetch;
|
|
154
|
+
private endpoints;
|
|
155
|
+
private options;
|
|
156
|
+
private listeners;
|
|
157
|
+
private eventSource;
|
|
158
|
+
constructor(options: RestAdapterOptions);
|
|
159
|
+
open(): Promise<void>;
|
|
160
|
+
close(): void;
|
|
161
|
+
private connectRealtime;
|
|
162
|
+
private fallbackRealtime;
|
|
163
|
+
private notifyListeners;
|
|
164
|
+
generateId(): string;
|
|
165
|
+
private get;
|
|
166
|
+
private post;
|
|
167
|
+
private patch;
|
|
168
|
+
private delete;
|
|
169
|
+
private postBinary;
|
|
170
|
+
private mutate;
|
|
171
|
+
getNodes(ids: string[]): Promise<VfsNode<TMeta>[]>;
|
|
172
|
+
getNodeById(id: string): Promise<VfsNode<TMeta> | null>;
|
|
173
|
+
getNodeByPath(path: string): Promise<VfsNode<TMeta> | null>;
|
|
174
|
+
getChildren(parentId: string | null, options?: {
|
|
175
|
+
includeTrashed?: boolean;
|
|
176
|
+
}): Promise<VfsNode<TMeta>[]>;
|
|
177
|
+
getTrashed(): Promise<VfsNode<TMeta>[]>;
|
|
178
|
+
search(query: string, options?: VfsSearchOptions): Promise<VfsNode<TMeta>[]>;
|
|
179
|
+
readFile(id: string): Promise<Uint8Array>;
|
|
180
|
+
writeFile(id: string, content: Uint8Array): Promise<void>;
|
|
181
|
+
createFile(params: VfsCreateFileParams): Promise<VfsFileNode<TMeta>>;
|
|
182
|
+
createFolder(params: VfsCreateFolderParams): Promise<VfsFolderNode<TMeta>>;
|
|
183
|
+
updateNode(id: string, updates: Partial<VfsNode<TMeta>>): Promise<VfsNode<TMeta>>;
|
|
184
|
+
deleteNode(id: string, permanent?: boolean): Promise<void>;
|
|
185
|
+
deleteNodes(ids: string[], permanent?: boolean): Promise<void>;
|
|
186
|
+
restoreNode(id: string): Promise<VfsNode<TMeta>>;
|
|
187
|
+
purgeNode(id: string): Promise<void>;
|
|
188
|
+
moveNode(id: string, newParentId: string | null): Promise<VfsNode<TMeta>>;
|
|
189
|
+
moveNodes(ids: string[], newParentId: string | null): Promise<VfsNode<TMeta>[]>;
|
|
190
|
+
lockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
191
|
+
unlockNode(id: string, sessionId: string): Promise<VfsNode<TMeta>>;
|
|
192
|
+
getOrder(parentId: string | null): Promise<VfsNodeOrder | null>;
|
|
193
|
+
setOrder(parentId: string | null, orderedIds: string[]): Promise<void>;
|
|
194
|
+
getSnapshots(fileId: string): Promise<VfsFileSnapshot[]>;
|
|
195
|
+
saveSnapshot(fileId: string, content: Uint8Array, label?: string): Promise<VfsFileSnapshot>;
|
|
196
|
+
restoreSnapshot(fileId: string, index: number): Promise<void>;
|
|
197
|
+
deleteSnapshot(fileId: string, index: number): Promise<void>;
|
|
198
|
+
onChanged(callback: (change: VfsChange) => void): () => void;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { InMemoryAdapter, IndexedDBAdapter, type IndexedDBAdapterOptions, type IsolationMode, type RealtimeFallback, RestAdapter, type RestAdapterOptions, type VfsEndpointMap, type VfsFetch };
|