dserver-client 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue.js ADDED
@@ -0,0 +1,307 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let vue = require("vue");
3
+ const require_client = require("./client.js");
4
+ // src/vue.ts
5
+ /**
6
+ * Vue 3 composables for dserver client
7
+ *
8
+ * These composables provide reactive wrappers around the DServerClient
9
+ * for easy integration with Vue applications.
10
+ */
11
+ /**
12
+ * Composable for managing a DServerClient instance
13
+ */
14
+ function useDServerClient(config) {
15
+ return { client: (0, vue.computed)(() => {
16
+ const cfg = "value" in config ? config.value : config;
17
+ return new require_client.DServerClient(cfg);
18
+ }) };
19
+ }
20
+ /**
21
+ * Composable for downloading dataset items
22
+ */
23
+ function useDatasetDownload(client) {
24
+ const loading = (0, vue.ref)(false);
25
+ const error = (0, vue.shallowRef)(null);
26
+ const urls = (0, vue.shallowRef)(null);
27
+ const manifest = (0, vue.shallowRef)(null);
28
+ const adminMetadata = (0, vue.shallowRef)(null);
29
+ const readme = (0, vue.ref)(null);
30
+ const progress = (0, vue.ref)({
31
+ loaded: 0,
32
+ total: 0
33
+ });
34
+ /**
35
+ * Load signed URLs for a dataset
36
+ */
37
+ async function loadDataset(uri) {
38
+ loading.value = true;
39
+ error.value = null;
40
+ try {
41
+ urls.value = await client.value.getDatasetSignedUrls(uri);
42
+ } catch (e) {
43
+ error.value = e;
44
+ throw e;
45
+ } finally {
46
+ loading.value = false;
47
+ }
48
+ }
49
+ /**
50
+ * Load the manifest for the current dataset
51
+ */
52
+ async function loadManifest() {
53
+ if (!urls.value) throw new Error("No dataset loaded. Call loadDataset first.");
54
+ loading.value = true;
55
+ error.value = null;
56
+ try {
57
+ manifest.value = await client.value.downloadManifest(urls.value);
58
+ return manifest.value;
59
+ } catch (e) {
60
+ error.value = e;
61
+ throw e;
62
+ } finally {
63
+ loading.value = false;
64
+ }
65
+ }
66
+ /**
67
+ * Load the admin metadata for the current dataset
68
+ */
69
+ async function loadAdminMetadata() {
70
+ if (!urls.value) throw new Error("No dataset loaded. Call loadDataset first.");
71
+ loading.value = true;
72
+ error.value = null;
73
+ try {
74
+ adminMetadata.value = await client.value.downloadAdminMetadata(urls.value);
75
+ return adminMetadata.value;
76
+ } catch (e) {
77
+ error.value = e;
78
+ throw e;
79
+ } finally {
80
+ loading.value = false;
81
+ }
82
+ }
83
+ /**
84
+ * Load the README for the current dataset
85
+ */
86
+ async function loadReadme() {
87
+ if (!urls.value) throw new Error("No dataset loaded. Call loadDataset first.");
88
+ loading.value = true;
89
+ error.value = null;
90
+ try {
91
+ readme.value = await client.value.downloadReadme(urls.value);
92
+ return readme.value;
93
+ } catch (e) {
94
+ error.value = e;
95
+ throw e;
96
+ } finally {
97
+ loading.value = false;
98
+ }
99
+ }
100
+ /**
101
+ * Download a specific item
102
+ */
103
+ async function downloadItem(identifier, options) {
104
+ if (!urls.value) throw new Error("No dataset loaded. Call loadDataset first.");
105
+ loading.value = true;
106
+ error.value = null;
107
+ progress.value = {
108
+ loaded: 0,
109
+ total: 0,
110
+ item: identifier
111
+ };
112
+ try {
113
+ return await client.value.downloadItem(urls.value, identifier, {
114
+ ...options,
115
+ onProgress: (loaded, total, item) => {
116
+ progress.value = {
117
+ loaded,
118
+ total,
119
+ item
120
+ };
121
+ options?.onProgress?.(loaded, total, item);
122
+ }
123
+ });
124
+ } catch (e) {
125
+ error.value = e;
126
+ throw e;
127
+ } finally {
128
+ loading.value = false;
129
+ }
130
+ }
131
+ /**
132
+ * Download an item as a Blob for file saving
133
+ */
134
+ async function downloadItemAsBlob(identifier, mimeType, options) {
135
+ const content = await downloadItem(identifier, options);
136
+ return new Blob([content], { type: mimeType });
137
+ }
138
+ /**
139
+ * Download an item and trigger browser download
140
+ */
141
+ async function downloadItemToFile(identifier, filename, mimeType, options) {
142
+ const blob = await downloadItemAsBlob(identifier, mimeType, options);
143
+ const url = URL.createObjectURL(blob);
144
+ const a = document.createElement("a");
145
+ a.href = url;
146
+ a.download = filename;
147
+ document.body.appendChild(a);
148
+ a.click();
149
+ document.body.removeChild(a);
150
+ URL.revokeObjectURL(url);
151
+ }
152
+ /**
153
+ * Get item details from manifest
154
+ */
155
+ function getItemDetails(identifier) {
156
+ if (!manifest.value) return null;
157
+ return manifest.value.items[identifier] || null;
158
+ }
159
+ return {
160
+ loading,
161
+ error,
162
+ urls,
163
+ manifest,
164
+ adminMetadata,
165
+ readme,
166
+ progress,
167
+ items: (0, vue.computed)(() => {
168
+ if (!manifest.value) return [];
169
+ return Object.entries(manifest.value.items).map(([id, item]) => ({
170
+ identifier: id,
171
+ ...item
172
+ }));
173
+ }),
174
+ loadDataset,
175
+ loadManifest,
176
+ loadAdminMetadata,
177
+ loadReadme,
178
+ downloadItem,
179
+ downloadItemAsBlob,
180
+ downloadItemToFile,
181
+ getItemDetails
182
+ };
183
+ }
184
+ /**
185
+ * Composable for uploading datasets
186
+ */
187
+ function useDatasetUpload(client) {
188
+ const loading = (0, vue.ref)(false);
189
+ const error = (0, vue.shallowRef)(null);
190
+ const progress = (0, vue.ref)({
191
+ uploaded: 0,
192
+ total: 0,
193
+ phase: "preparing"
194
+ });
195
+ const result = (0, vue.shallowRef)(null);
196
+ /**
197
+ * Upload a new dataset
198
+ */
199
+ async function uploadDataset(baseUri, name, files, options) {
200
+ loading.value = true;
201
+ error.value = null;
202
+ result.value = null;
203
+ progress.value = {
204
+ uploaded: 0,
205
+ total: 0,
206
+ phase: "preparing"
207
+ };
208
+ try {
209
+ progress.value.phase = "uploading";
210
+ const uploadResult = await client.value.createDataset(baseUri, name, files, {
211
+ ...options,
212
+ onProgress: (uploaded, total, currentFile) => {
213
+ progress.value = {
214
+ uploaded,
215
+ total,
216
+ currentFile,
217
+ phase: "uploading"
218
+ };
219
+ options?.onProgress?.(uploaded, total, currentFile);
220
+ }
221
+ });
222
+ progress.value.phase = "complete";
223
+ result.value = uploadResult;
224
+ return uploadResult;
225
+ } catch (e) {
226
+ progress.value.phase = "error";
227
+ error.value = e;
228
+ throw e;
229
+ } finally {
230
+ loading.value = false;
231
+ }
232
+ }
233
+ /**
234
+ * Upload files from a FileList (e.g., from file input)
235
+ */
236
+ async function uploadFromFileList(baseUri, name, fileList, basePath = "", options) {
237
+ return uploadDataset(baseUri, name, Array.from(fileList).map((file) => ({
238
+ relpath: basePath ? `${basePath}/${file.name}` : file.name,
239
+ content: file,
240
+ contentType: file.type || void 0
241
+ })), options);
242
+ }
243
+ /**
244
+ * Upload files with drag-and-drop support
245
+ */
246
+ async function uploadFromDataTransfer(baseUri, name, dataTransfer, options) {
247
+ const files = [];
248
+ if (dataTransfer.items) {
249
+ for (const item of Array.from(dataTransfer.items)) if (item.kind === "file") {
250
+ const entry = item.webkitGetAsEntry?.();
251
+ if (entry) await collectFiles(entry, "", files);
252
+ else {
253
+ const file = item.getAsFile();
254
+ if (file) files.push({
255
+ relpath: file.name,
256
+ content: file,
257
+ contentType: file.type || void 0
258
+ });
259
+ }
260
+ }
261
+ } else for (const file of Array.from(dataTransfer.files)) files.push({
262
+ relpath: file.name,
263
+ content: file,
264
+ contentType: file.type || void 0
265
+ });
266
+ return uploadDataset(baseUri, name, files, options);
267
+ }
268
+ /**
269
+ * Recursively collect files from a FileSystemEntry
270
+ */
271
+ async function collectFiles(entry, basePath, files) {
272
+ if (entry.isFile) {
273
+ const fileEntry = entry;
274
+ const file = await new Promise((resolve, reject) => {
275
+ fileEntry.file(resolve, reject);
276
+ });
277
+ files.push({
278
+ relpath: basePath ? `${basePath}/${file.name}` : file.name,
279
+ content: file,
280
+ contentType: file.type || void 0
281
+ });
282
+ } else if (entry.isDirectory) {
283
+ const reader = entry.createReader();
284
+ const entries = await new Promise((resolve, reject) => {
285
+ reader.readEntries(resolve, reject);
286
+ });
287
+ const newBasePath = basePath ? `${basePath}/${entry.name}` : entry.name;
288
+ for (const childEntry of entries) await collectFiles(childEntry, newBasePath, files);
289
+ }
290
+ }
291
+ return {
292
+ loading,
293
+ error,
294
+ progress,
295
+ progressPercent: (0, vue.computed)(() => {
296
+ if (progress.value.total === 0) return 0;
297
+ return Math.round(progress.value.uploaded / progress.value.total * 100);
298
+ }),
299
+ result,
300
+ uploadDataset,
301
+ uploadFromFileList,
302
+ uploadFromDataTransfer
303
+ };
304
+ }
305
+ exports.useDServerClient = useDServerClient;
306
+ exports.useDatasetDownload = useDatasetDownload;
307
+ exports.useDatasetUpload = useDatasetUpload;
package/dist/vue.mjs ADDED
@@ -0,0 +1,306 @@
1
+ import { computed, ref, shallowRef } from "vue";
2
+ import { t as DServerClient } from "./client.mjs";
3
+ // src/vue.ts
4
+ /**
5
+ * Vue 3 composables for dserver client
6
+ *
7
+ * These composables provide reactive wrappers around the DServerClient
8
+ * for easy integration with Vue applications.
9
+ */
10
+ /**
11
+ * Composable for managing a DServerClient instance
12
+ */
13
+ function useDServerClient(config) {
14
+ return { client: computed(() => {
15
+ const cfg = "value" in config ? config.value : config;
16
+ return new DServerClient(cfg);
17
+ }) };
18
+ }
19
+ /**
20
+ * Composable for downloading dataset items
21
+ */
22
+ function useDatasetDownload(client) {
23
+ const loading = ref(false);
24
+ const error = shallowRef(null);
25
+ const urls = shallowRef(null);
26
+ const manifest = shallowRef(null);
27
+ const adminMetadata = shallowRef(null);
28
+ const readme = ref(null);
29
+ const progress = ref({
30
+ loaded: 0,
31
+ total: 0
32
+ });
33
+ /**
34
+ * Load signed URLs for a dataset
35
+ */
36
+ async function loadDataset(uri) {
37
+ loading.value = true;
38
+ error.value = null;
39
+ try {
40
+ urls.value = await client.value.getDatasetSignedUrls(uri);
41
+ } catch (e) {
42
+ error.value = e;
43
+ throw e;
44
+ } finally {
45
+ loading.value = false;
46
+ }
47
+ }
48
+ /**
49
+ * Load the manifest for the current dataset
50
+ */
51
+ async function loadManifest() {
52
+ if (!urls.value) throw new Error("No dataset loaded. Call loadDataset first.");
53
+ loading.value = true;
54
+ error.value = null;
55
+ try {
56
+ manifest.value = await client.value.downloadManifest(urls.value);
57
+ return manifest.value;
58
+ } catch (e) {
59
+ error.value = e;
60
+ throw e;
61
+ } finally {
62
+ loading.value = false;
63
+ }
64
+ }
65
+ /**
66
+ * Load the admin metadata for the current dataset
67
+ */
68
+ async function loadAdminMetadata() {
69
+ if (!urls.value) throw new Error("No dataset loaded. Call loadDataset first.");
70
+ loading.value = true;
71
+ error.value = null;
72
+ try {
73
+ adminMetadata.value = await client.value.downloadAdminMetadata(urls.value);
74
+ return adminMetadata.value;
75
+ } catch (e) {
76
+ error.value = e;
77
+ throw e;
78
+ } finally {
79
+ loading.value = false;
80
+ }
81
+ }
82
+ /**
83
+ * Load the README for the current dataset
84
+ */
85
+ async function loadReadme() {
86
+ if (!urls.value) throw new Error("No dataset loaded. Call loadDataset first.");
87
+ loading.value = true;
88
+ error.value = null;
89
+ try {
90
+ readme.value = await client.value.downloadReadme(urls.value);
91
+ return readme.value;
92
+ } catch (e) {
93
+ error.value = e;
94
+ throw e;
95
+ } finally {
96
+ loading.value = false;
97
+ }
98
+ }
99
+ /**
100
+ * Download a specific item
101
+ */
102
+ async function downloadItem(identifier, options) {
103
+ if (!urls.value) throw new Error("No dataset loaded. Call loadDataset first.");
104
+ loading.value = true;
105
+ error.value = null;
106
+ progress.value = {
107
+ loaded: 0,
108
+ total: 0,
109
+ item: identifier
110
+ };
111
+ try {
112
+ return await client.value.downloadItem(urls.value, identifier, {
113
+ ...options,
114
+ onProgress: (loaded, total, item) => {
115
+ progress.value = {
116
+ loaded,
117
+ total,
118
+ item
119
+ };
120
+ options?.onProgress?.(loaded, total, item);
121
+ }
122
+ });
123
+ } catch (e) {
124
+ error.value = e;
125
+ throw e;
126
+ } finally {
127
+ loading.value = false;
128
+ }
129
+ }
130
+ /**
131
+ * Download an item as a Blob for file saving
132
+ */
133
+ async function downloadItemAsBlob(identifier, mimeType, options) {
134
+ const content = await downloadItem(identifier, options);
135
+ return new Blob([content], { type: mimeType });
136
+ }
137
+ /**
138
+ * Download an item and trigger browser download
139
+ */
140
+ async function downloadItemToFile(identifier, filename, mimeType, options) {
141
+ const blob = await downloadItemAsBlob(identifier, mimeType, options);
142
+ const url = URL.createObjectURL(blob);
143
+ const a = document.createElement("a");
144
+ a.href = url;
145
+ a.download = filename;
146
+ document.body.appendChild(a);
147
+ a.click();
148
+ document.body.removeChild(a);
149
+ URL.revokeObjectURL(url);
150
+ }
151
+ /**
152
+ * Get item details from manifest
153
+ */
154
+ function getItemDetails(identifier) {
155
+ if (!manifest.value) return null;
156
+ return manifest.value.items[identifier] || null;
157
+ }
158
+ return {
159
+ loading,
160
+ error,
161
+ urls,
162
+ manifest,
163
+ adminMetadata,
164
+ readme,
165
+ progress,
166
+ items: computed(() => {
167
+ if (!manifest.value) return [];
168
+ return Object.entries(manifest.value.items).map(([id, item]) => ({
169
+ identifier: id,
170
+ ...item
171
+ }));
172
+ }),
173
+ loadDataset,
174
+ loadManifest,
175
+ loadAdminMetadata,
176
+ loadReadme,
177
+ downloadItem,
178
+ downloadItemAsBlob,
179
+ downloadItemToFile,
180
+ getItemDetails
181
+ };
182
+ }
183
+ /**
184
+ * Composable for uploading datasets
185
+ */
186
+ function useDatasetUpload(client) {
187
+ const loading = ref(false);
188
+ const error = shallowRef(null);
189
+ const progress = ref({
190
+ uploaded: 0,
191
+ total: 0,
192
+ phase: "preparing"
193
+ });
194
+ const result = shallowRef(null);
195
+ /**
196
+ * Upload a new dataset
197
+ */
198
+ async function uploadDataset(baseUri, name, files, options) {
199
+ loading.value = true;
200
+ error.value = null;
201
+ result.value = null;
202
+ progress.value = {
203
+ uploaded: 0,
204
+ total: 0,
205
+ phase: "preparing"
206
+ };
207
+ try {
208
+ progress.value.phase = "uploading";
209
+ const uploadResult = await client.value.createDataset(baseUri, name, files, {
210
+ ...options,
211
+ onProgress: (uploaded, total, currentFile) => {
212
+ progress.value = {
213
+ uploaded,
214
+ total,
215
+ currentFile,
216
+ phase: "uploading"
217
+ };
218
+ options?.onProgress?.(uploaded, total, currentFile);
219
+ }
220
+ });
221
+ progress.value.phase = "complete";
222
+ result.value = uploadResult;
223
+ return uploadResult;
224
+ } catch (e) {
225
+ progress.value.phase = "error";
226
+ error.value = e;
227
+ throw e;
228
+ } finally {
229
+ loading.value = false;
230
+ }
231
+ }
232
+ /**
233
+ * Upload files from a FileList (e.g., from file input)
234
+ */
235
+ async function uploadFromFileList(baseUri, name, fileList, basePath = "", options) {
236
+ return uploadDataset(baseUri, name, Array.from(fileList).map((file) => ({
237
+ relpath: basePath ? `${basePath}/${file.name}` : file.name,
238
+ content: file,
239
+ contentType: file.type || void 0
240
+ })), options);
241
+ }
242
+ /**
243
+ * Upload files with drag-and-drop support
244
+ */
245
+ async function uploadFromDataTransfer(baseUri, name, dataTransfer, options) {
246
+ const files = [];
247
+ if (dataTransfer.items) {
248
+ for (const item of Array.from(dataTransfer.items)) if (item.kind === "file") {
249
+ const entry = item.webkitGetAsEntry?.();
250
+ if (entry) await collectFiles(entry, "", files);
251
+ else {
252
+ const file = item.getAsFile();
253
+ if (file) files.push({
254
+ relpath: file.name,
255
+ content: file,
256
+ contentType: file.type || void 0
257
+ });
258
+ }
259
+ }
260
+ } else for (const file of Array.from(dataTransfer.files)) files.push({
261
+ relpath: file.name,
262
+ content: file,
263
+ contentType: file.type || void 0
264
+ });
265
+ return uploadDataset(baseUri, name, files, options);
266
+ }
267
+ /**
268
+ * Recursively collect files from a FileSystemEntry
269
+ */
270
+ async function collectFiles(entry, basePath, files) {
271
+ if (entry.isFile) {
272
+ const fileEntry = entry;
273
+ const file = await new Promise((resolve, reject) => {
274
+ fileEntry.file(resolve, reject);
275
+ });
276
+ files.push({
277
+ relpath: basePath ? `${basePath}/${file.name}` : file.name,
278
+ content: file,
279
+ contentType: file.type || void 0
280
+ });
281
+ } else if (entry.isDirectory) {
282
+ const reader = entry.createReader();
283
+ const entries = await new Promise((resolve, reject) => {
284
+ reader.readEntries(resolve, reject);
285
+ });
286
+ const newBasePath = basePath ? `${basePath}/${entry.name}` : entry.name;
287
+ for (const childEntry of entries) await collectFiles(childEntry, newBasePath, files);
288
+ }
289
+ }
290
+ return {
291
+ loading,
292
+ error,
293
+ progress,
294
+ progressPercent: computed(() => {
295
+ if (progress.value.total === 0) return 0;
296
+ return Math.round(progress.value.uploaded / progress.value.total * 100);
297
+ }),
298
+ result,
299
+ uploadDataset,
300
+ uploadFromFileList,
301
+ uploadFromDataTransfer
302
+ };
303
+ }
304
+ export { useDServerClient, useDatasetDownload, useDatasetUpload };
305
+
306
+ //# sourceMappingURL=vue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vue.mjs","names":["dirEntry"],"sources":["../src/vue.ts"],"sourcesContent":["/**\n * Vue 3 composables for dserver client\n *\n * These composables provide reactive wrappers around the DServerClient\n * for easy integration with Vue applications.\n */\n\nimport { ref, computed, Ref, shallowRef } from \"vue\";\nimport { DServerClient } from \"./client\";\nimport {\n DServerClientConfig,\n DatasetSignedURLsResponse,\n Manifest,\n AdminMetadata,\n UploadCompleteResponse,\n FileToUpload,\n UploadOptions,\n DownloadOptions,\n} from \"./types\";\n\n/**\n * Composable for managing a DServerClient instance\n */\nexport function useDServerClient(config: Ref<DServerClientConfig> | DServerClientConfig) {\n const client = computed(() => {\n const cfg = \"value\" in config ? config.value : config;\n return new DServerClient(cfg);\n });\n\n return { client };\n}\n\n/**\n * Composable for downloading dataset items\n */\nexport function useDatasetDownload(client: Ref<DServerClient>) {\n const loading = ref(false);\n const error = shallowRef<Error | null>(null);\n const urls = shallowRef<DatasetSignedURLsResponse | null>(null);\n const manifest = shallowRef<Manifest | null>(null);\n const adminMetadata = shallowRef<AdminMetadata | null>(null);\n const readme = ref<string | null>(null);\n\n const progress = ref<{ loaded: number; total: number; item?: string }>({\n loaded: 0,\n total: 0,\n });\n\n /**\n * Load signed URLs for a dataset\n */\n async function loadDataset(uri: string): Promise<void> {\n loading.value = true;\n error.value = null;\n\n try {\n urls.value = await client.value.getDatasetSignedUrls(uri);\n } catch (e) {\n error.value = e as Error;\n throw e;\n } finally {\n loading.value = false;\n }\n }\n\n /**\n * Load the manifest for the current dataset\n */\n async function loadManifest(): Promise<Manifest | null> {\n if (!urls.value) {\n throw new Error(\"No dataset loaded. Call loadDataset first.\");\n }\n\n loading.value = true;\n error.value = null;\n\n try {\n manifest.value = await client.value.downloadManifest(urls.value);\n return manifest.value;\n } catch (e) {\n error.value = e as Error;\n throw e;\n } finally {\n loading.value = false;\n }\n }\n\n /**\n * Load the admin metadata for the current dataset\n */\n async function loadAdminMetadata(): Promise<AdminMetadata | null> {\n if (!urls.value) {\n throw new Error(\"No dataset loaded. Call loadDataset first.\");\n }\n\n loading.value = true;\n error.value = null;\n\n try {\n adminMetadata.value = await client.value.downloadAdminMetadata(urls.value);\n return adminMetadata.value;\n } catch (e) {\n error.value = e as Error;\n throw e;\n } finally {\n loading.value = false;\n }\n }\n\n /**\n * Load the README for the current dataset\n */\n async function loadReadme(): Promise<string | null> {\n if (!urls.value) {\n throw new Error(\"No dataset loaded. Call loadDataset first.\");\n }\n\n loading.value = true;\n error.value = null;\n\n try {\n readme.value = await client.value.downloadReadme(urls.value);\n return readme.value;\n } catch (e) {\n error.value = e as Error;\n throw e;\n } finally {\n loading.value = false;\n }\n }\n\n /**\n * Download a specific item\n */\n async function downloadItem(\n identifier: string,\n options?: DownloadOptions\n ): Promise<ArrayBuffer> {\n if (!urls.value) {\n throw new Error(\"No dataset loaded. Call loadDataset first.\");\n }\n\n loading.value = true;\n error.value = null;\n progress.value = { loaded: 0, total: 0, item: identifier };\n\n try {\n const result = await client.value.downloadItem(urls.value, identifier, {\n ...options,\n onProgress: (loaded, total, item) => {\n progress.value = { loaded, total, item };\n options?.onProgress?.(loaded, total, item);\n },\n });\n return result;\n } catch (e) {\n error.value = e as Error;\n throw e;\n } finally {\n loading.value = false;\n }\n }\n\n /**\n * Download an item as a Blob for file saving\n */\n async function downloadItemAsBlob(\n identifier: string,\n mimeType?: string,\n options?: DownloadOptions\n ): Promise<Blob> {\n const content = await downloadItem(identifier, options);\n return new Blob([content], { type: mimeType });\n }\n\n /**\n * Download an item and trigger browser download\n */\n async function downloadItemToFile(\n identifier: string,\n filename: string,\n mimeType?: string,\n options?: DownloadOptions\n ): Promise<void> {\n const blob = await downloadItemAsBlob(identifier, mimeType, options);\n const url = URL.createObjectURL(blob);\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = filename;\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n URL.revokeObjectURL(url);\n }\n\n /**\n * Get item details from manifest\n */\n function getItemDetails(identifier: string) {\n if (!manifest.value) return null;\n return manifest.value.items[identifier] || null;\n }\n\n /**\n * List all items\n */\n const items = computed(() => {\n if (!manifest.value) return [];\n return Object.entries(manifest.value.items).map(([id, item]) => ({\n identifier: id,\n ...item,\n }));\n });\n\n return {\n // State\n loading,\n error,\n urls,\n manifest,\n adminMetadata,\n readme,\n progress,\n items,\n\n // Actions\n loadDataset,\n loadManifest,\n loadAdminMetadata,\n loadReadme,\n downloadItem,\n downloadItemAsBlob,\n downloadItemToFile,\n getItemDetails,\n };\n}\n\n/**\n * Composable for uploading datasets\n */\nexport function useDatasetUpload(client: Ref<DServerClient>) {\n const loading = ref(false);\n const error = shallowRef<Error | null>(null);\n const progress = ref<{\n uploaded: number;\n total: number;\n currentFile?: string;\n phase: \"preparing\" | \"uploading\" | \"finalizing\" | \"complete\" | \"error\";\n }>({\n uploaded: 0,\n total: 0,\n phase: \"preparing\",\n });\n\n const result = shallowRef<UploadCompleteResponse | null>(null);\n\n /**\n * Upload a new dataset\n */\n async function uploadDataset(\n baseUri: string,\n name: string,\n files: FileToUpload[],\n options?: UploadOptions\n ): Promise<UploadCompleteResponse> {\n loading.value = true;\n error.value = null;\n result.value = null;\n progress.value = { uploaded: 0, total: 0, phase: \"preparing\" };\n\n try {\n progress.value.phase = \"uploading\";\n\n const uploadResult = await client.value.createDataset(\n baseUri,\n name,\n files,\n {\n ...options,\n onProgress: (uploaded, total, currentFile) => {\n progress.value = {\n uploaded,\n total,\n currentFile,\n phase: \"uploading\",\n };\n options?.onProgress?.(uploaded, total, currentFile);\n },\n }\n );\n\n progress.value.phase = \"complete\";\n result.value = uploadResult;\n return uploadResult;\n } catch (e) {\n progress.value.phase = \"error\";\n error.value = e as Error;\n throw e;\n } finally {\n loading.value = false;\n }\n }\n\n /**\n * Upload files from a FileList (e.g., from file input)\n */\n async function uploadFromFileList(\n baseUri: string,\n name: string,\n fileList: FileList,\n basePath: string = \"\",\n options?: UploadOptions\n ): Promise<UploadCompleteResponse> {\n const files: FileToUpload[] = Array.from(fileList).map((file) => ({\n relpath: basePath ? `${basePath}/${file.name}` : file.name,\n content: file,\n contentType: file.type || undefined,\n }));\n\n return uploadDataset(baseUri, name, files, options);\n }\n\n /**\n * Upload files with drag-and-drop support\n */\n async function uploadFromDataTransfer(\n baseUri: string,\n name: string,\n dataTransfer: DataTransfer,\n options?: UploadOptions\n ): Promise<UploadCompleteResponse> {\n const files: FileToUpload[] = [];\n\n // Handle both files and directory entries\n if (dataTransfer.items) {\n for (const item of Array.from(dataTransfer.items)) {\n if (item.kind === \"file\") {\n const entry = item.webkitGetAsEntry?.();\n if (entry) {\n await collectFiles(entry, \"\", files);\n } else {\n const file = item.getAsFile();\n if (file) {\n files.push({\n relpath: file.name,\n content: file,\n contentType: file.type || undefined,\n });\n }\n }\n }\n }\n } else {\n // Fallback for browsers without items API\n for (const file of Array.from(dataTransfer.files)) {\n files.push({\n relpath: file.name,\n content: file,\n contentType: file.type || undefined,\n });\n }\n }\n\n return uploadDataset(baseUri, name, files, options);\n }\n\n /**\n * Recursively collect files from a FileSystemEntry\n */\n async function collectFiles(\n entry: FileSystemEntry,\n basePath: string,\n files: FileToUpload[]\n ): Promise<void> {\n if (entry.isFile) {\n const fileEntry = entry as FileSystemFileEntry;\n const file = await new Promise<File>((resolve, reject) => {\n fileEntry.file(resolve, reject);\n });\n files.push({\n relpath: basePath ? `${basePath}/${file.name}` : file.name,\n content: file,\n contentType: file.type || undefined,\n });\n } else if (entry.isDirectory) {\n const dirEntry = entry as FileSystemDirectoryEntry;\n const reader = dirEntry.createReader();\n const entries = await new Promise<FileSystemEntry[]>((resolve, reject) => {\n reader.readEntries(resolve, reject);\n });\n const newBasePath = basePath ? `${basePath}/${entry.name}` : entry.name;\n for (const childEntry of entries) {\n await collectFiles(childEntry, newBasePath, files);\n }\n }\n }\n\n const progressPercent = computed(() => {\n if (progress.value.total === 0) return 0;\n return Math.round((progress.value.uploaded / progress.value.total) * 100);\n });\n\n return {\n // State\n loading,\n error,\n progress,\n progressPercent,\n result,\n\n // Actions\n uploadDataset,\n uploadFromFileList,\n uploadFromDataTransfer,\n };\n}\n\n// Type declarations for FileSystem API\ninterface FileSystemEntry {\n isFile: boolean;\n isDirectory: boolean;\n name: string;\n}\n\ninterface FileSystemFileEntry extends FileSystemEntry {\n file(successCallback: (file: File) => void, errorCallback?: (error: Error) => void): void;\n}\n\ninterface FileSystemDirectoryEntry extends FileSystemEntry {\n createReader(): FileSystemDirectoryReader;\n}\n\ninterface FileSystemDirectoryReader {\n readEntries(\n successCallback: (entries: FileSystemEntry[]) => void,\n errorCallback?: (error: Error) => void\n ): void;\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAgB,iBAAiB,QAAwD;CAMvF,OAAO,EAAE,QALM,eAAe;EAC5B,MAAM,MAAM,WAAW,SAAS,OAAO,QAAQ;EAC/C,OAAO,IAAI,cAAc,GAAG;CAC9B,CAEc,EAAE;AAClB;;;;AAKA,SAAgB,mBAAmB,QAA4B;CAC7D,MAAM,UAAU,IAAI,KAAK;CACzB,MAAM,QAAQ,WAAyB,IAAI;CAC3C,MAAM,OAAO,WAA6C,IAAI;CAC9D,MAAM,WAAW,WAA4B,IAAI;CACjD,MAAM,gBAAgB,WAAiC,IAAI;CAC3D,MAAM,SAAS,IAAmB,IAAI;CAEtC,MAAM,WAAW,IAAsD;EACrE,QAAQ;EACR,OAAO;CACT,CAAC;;;;CAKD,eAAe,YAAY,KAA4B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