convert-buddy-js 0.9.4 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +417 -10
  2. package/dist/src/browser.d.ts +174 -0
  3. package/dist/src/browser.js +204 -0
  4. package/dist/src/browser.js.map +1 -0
  5. package/dist/src/index.d.ts +133 -3
  6. package/dist/src/index.js +427 -26
  7. package/dist/src/index.js.map +1 -1
  8. package/dist/src/node.d.ts +111 -3
  9. package/dist/src/node.js +284 -2
  10. package/dist/src/node.js.map +1 -1
  11. package/dist/tests/edge-cases/control-features.test.d.ts +2 -0
  12. package/dist/tests/edge-cases/control-features.test.js +87 -0
  13. package/dist/tests/edge-cases/control-features.test.js.map +1 -0
  14. package/dist/tests/edge-cases/csv-edge-cases.test.d.ts +2 -0
  15. package/dist/tests/edge-cases/csv-edge-cases.test.js +547 -0
  16. package/dist/tests/edge-cases/csv-edge-cases.test.js.map +1 -0
  17. package/dist/tests/edge-cases/detection.test.d.ts +2 -0
  18. package/dist/tests/edge-cases/detection.test.js +129 -0
  19. package/dist/tests/edge-cases/detection.test.js.map +1 -0
  20. package/dist/tests/edge-cases/error-handling.test.d.ts +2 -0
  21. package/dist/tests/edge-cases/error-handling.test.js +448 -0
  22. package/dist/tests/edge-cases/error-handling.test.js.map +1 -0
  23. package/dist/tests/edge-cases/ndjson-edge-cases.test.d.ts +2 -0
  24. package/dist/tests/edge-cases/ndjson-edge-cases.test.js +539 -0
  25. package/dist/tests/edge-cases/ndjson-edge-cases.test.js.map +1 -0
  26. package/dist/tests/edge-cases/node-helpers.test.d.ts +2 -0
  27. package/dist/tests/edge-cases/node-helpers.test.js +114 -0
  28. package/dist/tests/edge-cases/node-helpers.test.js.map +1 -0
  29. package/dist/wasm/nodejs/convert_buddy.d.ts +9 -5
  30. package/dist/wasm/nodejs/convert_buddy.js +28 -19
  31. package/dist/wasm/nodejs/convert_buddy_bg.wasm +0 -0
  32. package/dist/wasm/nodejs/convert_buddy_bg.wasm.d.ts +1 -0
  33. package/dist/wasm/web/convert_buddy.d.ts +10 -5
  34. package/dist/wasm/web/convert_buddy.js +28 -19
  35. package/dist/wasm/web/convert_buddy_bg.wasm +0 -0
  36. package/dist/wasm/web/convert_buddy_bg.wasm.d.ts +1 -0
  37. package/package.json +6 -2
package/README.md CHANGED
@@ -1,31 +1,289 @@
1
+ > ⚠️ **In Development** - This project is currently under active development and subject to breaking changes. Experimental state, could change heavily.
2
+
1
3
  # convert-buddy-js
2
4
 
3
5
  A high-performance, streaming-first parser and converter for CSV, XML, NDJSON, and JSON. `convert-buddy-js` is a TypeScript wrapper around a Rust/WASM core, offering fast parsing and multiple usage styles for Node.js and browsers.
4
6
 
7
+ ## Status & Quality
8
+
9
+ [![Known Vulnerabilities](https://snyk.io/test/github/brunohanss/convert-buddy/badge.svg)](https://snyk.io/test/github/brunohanss/convert-buddy)
10
+ [![CI/CD Pipeline](https://github.com/brunohanss/convert-buddy/actions/workflows/test.yml/badge.svg)](https://github.com/brunohanss/convert-buddy/actions)
11
+ [![Coverage Status](https://img.shields.io/codecov/c/github/brunohanss/convert-buddy?label=coverage)](https://codecov.io/gh/brunohanss/convert-buddy)
12
+ [![npm version](https://img.shields.io/npm/v/convert-buddy-js.svg)](https://www.npmjs.com/package/convert-buddy-js)
13
+ [![Bundle Size](https://img.shields.io/bundlephobia/minzip/convert-buddy-js.svg)](https://bundlephobia.com/package/convert-buddy-js)
14
+
5
15
  ## Install
6
16
 
7
17
  ```bash
8
18
  npm install convert-buddy-js
9
19
  ```
10
20
 
21
+ ## Quick Start
22
+
23
+ ### The Simplest Way - Auto-Detect Everything
24
+
25
+ ```ts
26
+ import { convert, convertToString } from "convert-buddy-js";
27
+
28
+ // From URL (auto-detects format)
29
+ const result = await convertToString("https://example.com/data.csv", {
30
+ outputFormat: "json"
31
+ });
32
+
33
+ // From File (browser)
34
+ const file = fileInput.files[0];
35
+ const json = await convertToString(file, { outputFormat: "json" });
36
+
37
+ // From string data
38
+ const csv = "name,age\nAda,36";
39
+ const ndjson = await convertToString(csv, { outputFormat: "ndjson" });
40
+
41
+ // Returns Uint8Array instead of string
42
+ const bytes = await convert(file, { outputFormat: "json" });
43
+ ```
44
+
45
+ ### Instance-Based API with Global Config
46
+
47
+ ```ts
48
+ import { ConvertBuddy } from "convert-buddy-js";
49
+
50
+ // Create a buddy with global settings
51
+ const buddy = new ConvertBuddy({
52
+ maxMemoryMB: 512,
53
+ debug: true,
54
+ onProgress: (stats) => console.log(`${stats.recordsProcessed} records`)
55
+ });
56
+
57
+ // Convert anything - URL, File, Buffer, string, stream
58
+ const result = await buddy.convert("https://example.com/data.csv", {
59
+ outputFormat: "json"
60
+ });
61
+
62
+ const result2 = await buddy.convert(file, {
63
+ inputFormat: "csv", // optional, auto-detected if omitted
64
+ outputFormat: "ndjson"
65
+ });
66
+ ```
67
+
68
+ ### Browser - Convert File Input
69
+
70
+ ```ts
71
+ import { convertFileToString } from "convert-buddy-js/browser";
72
+
73
+ const fileInput = document.querySelector('input[type="file"]');
74
+ fileInput.addEventListener('change', async (e) => {
75
+ const file = e.target.files[0];
76
+ const result = await convertFileToString(file, {
77
+ inputFormat: "auto",
78
+ outputFormat: "json"
79
+ });
80
+ console.log(result);
81
+ });
82
+ ```
83
+
84
+ ### Node.js - Convert File
85
+
86
+ ```ts
87
+ import { convert } from "convert-buddy-js/node";
88
+
89
+ // From file path (auto-detects format)
90
+ const result = await convert("input.csv", {
91
+ outputFormat: "json"
92
+ });
93
+
94
+ // From URL
95
+ const result2 = await convert("https://api.example.com/data.csv", {
96
+ outputFormat: "ndjson"
97
+ });
98
+ ```
99
+
11
100
  ## Usage
12
101
 
13
- ### Convert a full string or buffer
102
+ Convert Buddy offers three API styles, from simplest to most powerful:
103
+
104
+ ### 1. Ultra-Simple API (Recommended for Most Use Cases)
105
+
106
+ The easiest way to convert data. Just pass anything and specify the output format:
14
107
 
15
108
  ```ts
16
- import { convertToString } from "convert-buddy-js";
109
+ import { convert, convertToString } from "convert-buddy-js";
110
+ // Or platform-specific: "convert-buddy-js/browser" or "convert-buddy-js/node"
111
+
112
+ // Auto-detects input type AND format
113
+ const json = await convertToString(input, { outputFormat: "json" });
114
+
115
+ // Works with:
116
+ // - URLs: "https://example.com/data.csv"
117
+ // - Files: file from <input type="file">
118
+ // - Buffers: Uint8Array or Buffer
119
+ // - Strings: raw CSV, JSON, XML, NDJSON data
120
+ // - Streams: ReadableStream<Uint8Array>
121
+ // - File paths (Node.js): "path/to/data.csv"
122
+ ```
17
123
 
18
- const csv = `name,age\nAda,36\nLinus,54`;
124
+ **Examples:**
19
125
 
20
- const output = await convertToString(csv, {
21
- inputFormat: "csv",
126
+ ```ts
127
+ // From URL
128
+ const json = await convertToString("https://example.com/data.csv", {
129
+ outputFormat: "json"
130
+ });
131
+
132
+ // From file upload (browser)
133
+ const file = document.querySelector('input[type="file"]').files[0];
134
+ const ndjson = await convertToString(file, { outputFormat: "ndjson" });
135
+
136
+ // From file path (Node.js)
137
+ import { convertToString } from "convert-buddy-js/node";
138
+ const result = await convertToString("./data.csv", { outputFormat: "json" });
139
+
140
+ // From string data
141
+ const csvString = "name,age\nAda,36\nLinus,54";
142
+ const json = await convertToString(csvString, { outputFormat: "json" });
143
+ ```
144
+
145
+ ### 2. Instance-Based API (For Reusable Configuration)
146
+
147
+ Create a ConvertBuddy instance with global settings, then convert multiple inputs:
148
+
149
+ ```ts
150
+ import { ConvertBuddy } from "convert-buddy-js";
151
+
152
+ const buddy = new ConvertBuddy({
153
+ maxMemoryMB: 512, // Future: memory limits
154
+ debug: true, // Enable debug logging
155
+ profile: true, // Show performance stats
156
+ onProgress: (stats) => {
157
+ console.log(`${stats.recordsProcessed} records processed`);
158
+ console.log(`${stats.throughputMbPerSec.toFixed(2)} MB/s`);
159
+ }
160
+ });
161
+
162
+ // Convert different inputs with the same config
163
+ const result1 = await buddy.convert("https://example.com/data.csv", {
164
+ outputFormat: "json"
165
+ });
166
+
167
+ const result2 = await buddy.convert(file, {
22
168
  outputFormat: "ndjson",
169
+ csvConfig: { delimiter: ";" } // Override per-conversion
23
170
  });
24
171
 
25
- console.log(output);
172
+ // Decode to string
173
+ const jsonString = new TextDecoder().decode(result1);
26
174
  ```
27
175
 
28
- ### Manual streaming (chunked)
176
+ ### 3. High-Level API (Platform-Specific Helpers)
177
+
178
+ Platform-specific helpers for common use cases:
179
+
180
+ #### Browser Helpers
181
+
182
+ Simple file conversion without manual buffer handling:
183
+
184
+ ```ts
185
+ import {
186
+ convertFileToString,
187
+ convertFile,
188
+ convertFileToFile,
189
+ convertFileStream,
190
+ convertAndSave,
191
+ convertStreamToWritable,
192
+ autoConvertStream,
193
+ isFileSystemAccessSupported,
194
+ getMimeType,
195
+ getExtension,
196
+ getSuggestedFilename
197
+ } from "convert-buddy-js/browser";
198
+
199
+ // Convert to string
200
+ const json = await convertFileToString(file, {
201
+ inputFormat: "csv",
202
+ outputFormat: "json"
203
+ });
204
+
205
+ // Convert and download (legacy browser support)
206
+ await convertFileToFile(file, "output.json", {
207
+ inputFormat: "csv",
208
+ outputFormat: "json"
209
+ });
210
+
211
+ // Convert and save with File System Access API (better UX)
212
+ // User chooses save location, no automatic downloads
213
+ await convertAndSave(file, {
214
+ inputFormat: "csv",
215
+ outputFormat: "json",
216
+ suggestedName: "output.json"
217
+ });
218
+
219
+ // Auto-detect format and convert
220
+ const stream = await autoConvertStream(file, {
221
+ outputFormat: "json"
222
+ });
223
+
224
+ // Stream to File System Access API writable
225
+ if (isFileSystemAccessSupported()) {
226
+ const handle = await window.showSaveFilePicker({
227
+ suggestedName: "output.json"
228
+ });
229
+ const writable = await handle.createWritable();
230
+
231
+ await convertStreamToWritable(file, writable, {
232
+ inputFormat: "csv",
233
+ outputFormat: "json",
234
+ onProgress: (stats) => console.log(`${stats.bytesIn} bytes processed`)
235
+ });
236
+ }
237
+
238
+ // Get streaming API
239
+ const stream = await convertFileStream(file, {
240
+ inputFormat: "csv",
241
+ outputFormat: "ndjson"
242
+ });
243
+
244
+ // Format helpers
245
+ const mimeType = getMimeType("json"); // "application/json"
246
+ const extension = getExtension("csv"); // "csv"
247
+ const filename = getSuggestedFilename("data.csv", "json"); // "data.json"
248
+
249
+ ```
250
+
251
+ #### Node.js Helpers
252
+
253
+ Convenient file path and stream conversions:
254
+
255
+ ```ts
256
+ import {
257
+ convertFileToString,
258
+ convertFileToFile,
259
+ convertBuffer,
260
+ convertStream
261
+ } from "convert-buddy-js/node";
262
+
263
+ // File to string
264
+ const json = await convertFileToString("input.csv", {
265
+ inputFormat: "csv",
266
+ outputFormat: "json"
267
+ });
268
+
269
+ // File to file
270
+ await convertFileToFile("input.csv", "output.json", {
271
+ inputFormat: "csv",
272
+ outputFormat: "json"
273
+ });
274
+
275
+ // From stream (HTTP, stdin, etc.)
276
+ const result = await convertStream(inputStream, {
277
+ inputFormat: "auto",
278
+ outputFormat: "json"
279
+ });
280
+ ```
281
+
282
+ ### 4. Low-Level API (Advanced Use Cases)
283
+
284
+ For maximum control over the conversion process:
285
+
286
+ #### Manual streaming (chunked)
29
287
 
30
288
  ```ts
31
289
  import { ConvertBuddy } from "convert-buddy-js";
@@ -42,7 +300,7 @@ const finalOutput = buddy.finish();
42
300
  console.log(buddy.stats());
43
301
  ```
44
302
 
45
- ### Node.js Transform stream
303
+ #### Node.js Transform stream
46
304
 
47
305
  Use the Node-specific entrypoint so bundlers keep `node:stream` out of the browser bundle.
48
306
 
@@ -62,7 +320,7 @@ createReadStream("input.csv")
62
320
  .pipe(createWriteStream("output.ndjson"));
63
321
  ```
64
322
 
65
- ### Web Streams
323
+ #### Web Streams
66
324
 
67
325
  ```ts
68
326
  import { ConvertBuddyTransformStream } from "convert-buddy-js";
@@ -76,7 +334,156 @@ const response = await fetch("/data.csv");
76
334
  const outputStream = response.body?.pipeThrough(transform);
77
335
  ```
78
336
 
79
- ### Detect format and CSV fields/delimiter
337
+ ---
338
+
339
+ ### Additional Features
340
+
341
+ #### Progress Tracking & Control
342
+
343
+ Monitor long-running conversions and allow cancellation:
344
+
345
+ ```ts
346
+ import { ConvertBuddy } from "convert-buddy-js";
347
+
348
+ const buddy = new ConvertBuddy({
349
+ onProgress: (stats) => {
350
+ console.log(`${stats.recordsProcessed} records processed`);
351
+ console.log(`${stats.throughputMbPerSec.toFixed(2)} MB/s`);
352
+ },
353
+ progressIntervalBytes: 1024 * 1024 // Every 1MB
354
+ });
355
+
356
+ const result = await buddy.convert(largeFile, { outputFormat: "json" });
357
+
358
+ // Or with the low-level API
359
+ const converter = await ConvertBuddy.create({
360
+ inputFormat: "csv",
361
+ outputFormat: "json",
362
+ onProgress: (stats) => {
363
+ console.log(`${stats.recordsProcessed} records processed`);
364
+ console.log(`${stats.throughputMbPerSec.toFixed(2)} MB/s`);
365
+ },
366
+ progressIntervalBytes: 1024 * 1024
367
+ });
368
+
369
+ // User cancels
370
+ cancelButton.addEventListener('click', () => converter.abort());
371
+ ```
372
+
373
+ #### Format Utilities
374
+
375
+ Helper functions for working with file formats, MIME types, and extensions:
376
+
377
+ ```ts
378
+ import {
379
+ getMimeType,
380
+ getExtension,
381
+ getSuggestedFilename,
382
+ getFileTypeConfig
383
+ } from "convert-buddy-js";
384
+
385
+ // Get MIME type for a format
386
+ const mimeType = getMimeType("json"); // "application/json"
387
+
388
+ // Get file extension
389
+ const ext = getExtension("ndjson"); // "ndjson"
390
+
391
+ // Generate output filename
392
+ const filename = getSuggestedFilename("data.csv", "json");
393
+ // "data.json"
394
+
395
+ const timestamped = getSuggestedFilename("data.csv", "json", true);
396
+ // "data_converted_1234567890.json"
397
+
398
+ // Get File System Access API config
399
+ const types = getFileTypeConfig("json");
400
+ // [{ description: "JSON Files", accept: { "application/json": [".json"] } }]
401
+
402
+ const handle = await window.showSaveFilePicker({
403
+ suggestedName: "output.json",
404
+ types
405
+ });
406
+ ```
407
+
408
+ #### Advanced Browser Streaming
409
+
410
+ For maximum efficiency with large files, use streaming APIs to avoid loading entire files into memory:
411
+
412
+ ```ts
413
+ import {
414
+ convertStreamToWritable,
415
+ autoConvertStream,
416
+ isFileSystemAccessSupported
417
+ } from "convert-buddy-js/browser";
418
+
419
+ // Auto-detect and stream conversion
420
+ const outputStream = await autoConvertStream(file, {
421
+ outputFormat: "json",
422
+ onProgress: (stats) => {
423
+ console.log(`Progress: ${stats.bytesIn} bytes in, ${stats.bytesOut} bytes out`);
424
+ console.log(`Throughput: ${stats.throughputMbPerSec.toFixed(2)} MB/s`);
425
+ }
426
+ });
427
+
428
+ // Stream directly to File System Access API writable
429
+ if (isFileSystemAccessSupported()) {
430
+ const fileHandle = await window.showSaveFilePicker({
431
+ suggestedName: "output.json",
432
+ types: [{
433
+ description: "JSON Files",
434
+ accept: { "application/json": [".json"] }
435
+ }]
436
+ });
437
+
438
+ const writable = await fileHandle.createWritable();
439
+
440
+ await convertStreamToWritable(file, writable, {
441
+ inputFormat: "csv",
442
+ outputFormat: "json"
443
+ });
444
+
445
+ console.log("Conversion complete!");
446
+ }
447
+
448
+ // Or pipe to any WritableStream
449
+ const customWritable = new WritableStream({
450
+ write(chunk) {
451
+ // Process each output chunk
452
+ console.log("Received chunk:", chunk);
453
+ }
454
+ });
455
+
456
+ await convertStreamToWritable(file, customWritable, {
457
+ inputFormat: "auto",
458
+ outputFormat: "ndjson"
459
+ });
460
+ ```
461
+
462
+ #### Auto-Detection
463
+
464
+ Auto-detection is enabled by default with the new API. You can also use it explicitly:
465
+
466
+ ```ts
467
+ import { convert } from "convert-buddy-js";
468
+
469
+ // Automatic (default)
470
+ const result = await convert(input, { outputFormat: "json" });
471
+
472
+ // Explicit auto-detection
473
+ const result2 = await convert(input, {
474
+ inputFormat: "auto",
475
+ outputFormat: "json",
476
+ csvConfig: { delimiter: "," } // Optional: still apply config
477
+ });
478
+
479
+ // Or specify the format
480
+ const result3 = await convert(input, {
481
+ inputFormat: "csv",
482
+ outputFormat: "json"
483
+ });
484
+ ```
485
+
486
+ #### Detect format and CSV fields/delimiter
80
487
 
81
488
  Use streaming inputs to keep detection fast on large files.
82
489
 
@@ -0,0 +1,174 @@
1
+ import { ConvertBuddyOptions, ConvertOptions, Format } from './index.js';
2
+ export { ConvertBuddy, ConvertBuddyTransformStream, CsvConfig, CsvDetection, DetectInput, DetectOptions, ProgressCallback, Stats, XmlConfig, XmlDetection, autoDetectConfig, convertAny, convertAnyToString, detectCsvFieldsAndDelimiter, detectFormat, detectXmlElements, getExtension, getFileTypeConfig, getMimeType, getSuggestedFilename } from './index.js';
3
+
4
+ type BrowserConvertOptions = ConvertBuddyOptions & {};
5
+ /**
6
+ * Ultra-simple convert function for browser.
7
+ * Auto-detects input type (File, URL, string, etc.) and format.
8
+ *
9
+ * @example
10
+ * // From File
11
+ * const file = fileInput.files[0];
12
+ * const result = await convert(file, { outputFormat: "json" });
13
+ *
14
+ * @example
15
+ * // From URL
16
+ * const result = await convert("https://example.com/data.csv", { outputFormat: "json" });
17
+ *
18
+ * @example
19
+ * // From string
20
+ * const result = await convert(csvString, { outputFormat: "json" });
21
+ */
22
+ declare function convert(input: string | Uint8Array | File | Blob | ReadableStream<Uint8Array>, opts: ConvertOptions): Promise<Uint8Array>;
23
+ /**
24
+ * Ultra-simple convert function that returns a string.
25
+ *
26
+ * @example
27
+ * const json = await convertToString(file, { outputFormat: "json" });
28
+ * console.log(JSON.parse(json));
29
+ */
30
+ declare function convertToString(input: string | Uint8Array | File | Blob | ReadableStream<Uint8Array>, opts: ConvertOptions): Promise<string>;
31
+ /**
32
+ * Convert a browser File or Blob object to a string.
33
+ * Handles streaming internally using FileReader and web streams.
34
+ *
35
+ * @example
36
+ * // From file input
37
+ * const fileInput = document.querySelector('input[type="file"]');
38
+ * const file = fileInput.files[0];
39
+ * const result = await convertFileToString(file, {
40
+ * inputFormat: "csv",
41
+ * outputFormat: "json"
42
+ * });
43
+ *
44
+ * @example
45
+ * // With auto-detection
46
+ * const result = await convertFileToString(file, {
47
+ * inputFormat: "auto",
48
+ * outputFormat: "ndjson"
49
+ * });
50
+ */
51
+ declare function convertFileToString(file: File | Blob, opts?: BrowserConvertOptions): Promise<string>;
52
+ /**
53
+ * Convert a browser File or Blob object to a Uint8Array.
54
+ * Handles streaming internally using FileReader and web streams.
55
+ *
56
+ * @example
57
+ * const file = fileInput.files[0];
58
+ * const result = await convertFile(file, {
59
+ * inputFormat: "csv",
60
+ * outputFormat: "json",
61
+ * onProgress: (stats) => {
62
+ * console.log(`Progress: ${stats.bytesIn} bytes processed`);
63
+ * }
64
+ * });
65
+ */
66
+ declare function convertFile(file: File | Blob, opts?: BrowserConvertOptions): Promise<Uint8Array>;
67
+ /**
68
+ * Convert a browser File or Blob and download the result as a file.
69
+ *
70
+ * @example
71
+ * const fileInput = document.querySelector('input[type="file"]');
72
+ * const file = fileInput.files[0];
73
+ * await convertFileToFile(file, "output.json", {
74
+ * inputFormat: "csv",
75
+ * outputFormat: "json"
76
+ * });
77
+ */
78
+ declare function convertFileToFile(inputFile: File | Blob, outputFilename: string, opts?: BrowserConvertOptions): Promise<void>;
79
+ /**
80
+ * Create a ReadableStream that converts data on-the-fly from a File or Blob.
81
+ * Useful for piping through other stream processors.
82
+ *
83
+ * @example
84
+ * const file = fileInput.files[0];
85
+ * const stream = convertFileStream(file, {
86
+ * inputFormat: "csv",
87
+ * outputFormat: "ndjson"
88
+ * });
89
+ *
90
+ * const reader = stream.getReader();
91
+ * while (true) {
92
+ * const { done, value } = await reader.read();
93
+ * if (done) break;
94
+ * // Process each chunk as it's converted
95
+ * console.log(new TextDecoder().decode(value));
96
+ * }
97
+ */
98
+ declare function convertFileStream(file: File | Blob, opts?: BrowserConvertOptions): Promise<ReadableStream<Uint8Array>>;
99
+ /**
100
+ * Auto-detect format and create a ReadableStream for conversion.
101
+ * This is a convenience helper that combines format detection with streaming conversion.
102
+ *
103
+ * @example
104
+ * const file = fileInput.files[0];
105
+ * const stream = await autoConvertStream(file, { outputFormat: "json" });
106
+ *
107
+ * // Pipe to response
108
+ * return new Response(stream);
109
+ */
110
+ declare function autoConvertStream(file: File | Blob, opts: Omit<BrowserConvertOptions, "inputFormat"> & {
111
+ outputFormat: Format;
112
+ }): Promise<ReadableStream<Uint8Array>>;
113
+ /**
114
+ * Stream a file conversion directly to a writable destination.
115
+ * This is useful for streaming large conversions to disk using File System Access API
116
+ * or to other writable streams.
117
+ *
118
+ * @example
119
+ * // Using File System Access API
120
+ * const fileInput = document.querySelector('input[type="file"]');
121
+ * const file = fileInput.files[0];
122
+ *
123
+ * const fileHandle = await window.showSaveFilePicker({
124
+ * suggestedName: "output.json",
125
+ * types: [{ description: "JSON", accept: { "application/json": [".json"] } }]
126
+ * });
127
+ * const writable = await fileHandle.createWritable();
128
+ *
129
+ * await convertStreamToWritable(file, writable, {
130
+ * inputFormat: "csv",
131
+ * outputFormat: "json",
132
+ * onProgress: (stats) => console.log(`${stats.bytesIn} bytes processed`)
133
+ * });
134
+ *
135
+ * @example
136
+ * // With auto-detection
137
+ * await convertStreamToWritable(file, writable, {
138
+ * inputFormat: "auto",
139
+ * outputFormat: "ndjson"
140
+ * });
141
+ */
142
+ declare function convertStreamToWritable(file: File | Blob, writable: WritableStream<Uint8Array> | FileSystemWritableFileStream, opts?: BrowserConvertOptions): Promise<void>;
143
+ /**
144
+ * Check if File System Access API is supported in the current browser.
145
+ * Use this to determine if you can use File System Access API features.
146
+ *
147
+ * @example
148
+ * if (isFileSystemAccessSupported()) {
149
+ * // Use File System Access API
150
+ * const handle = await window.showSaveFilePicker();
151
+ * } else {
152
+ * // Fall back to download link
153
+ * await convertFileToFile(file, "output.json", opts);
154
+ * }
155
+ */
156
+ declare function isFileSystemAccessSupported(): boolean;
157
+ /**
158
+ * Convert a file and save it using File System Access API with a user-selected location.
159
+ * This provides a better UX than automatic downloads by letting users choose where to save.
160
+ * Falls back to regular download if File System Access API is not supported.
161
+ *
162
+ * @example
163
+ * const file = fileInput.files[0];
164
+ * await convertAndSave(file, {
165
+ * inputFormat: "csv",
166
+ * outputFormat: "json",
167
+ * suggestedName: "output.json"
168
+ * });
169
+ */
170
+ declare function convertAndSave(file: File | Blob, opts?: BrowserConvertOptions & {
171
+ suggestedName?: string;
172
+ }): Promise<void>;
173
+
174
+ export { type BrowserConvertOptions, ConvertBuddyOptions, ConvertOptions, Format, autoConvertStream, convert, convertAndSave, convertFile, convertFileStream, convertFileToFile, convertFileToString, convertStreamToWritable, convertToString, isFileSystemAccessSupported };