convert-buddy-js 0.10.18 → 0.11.1

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 +49 -4
  2. package/dist/browser-stream-controller.d.ts +107 -0
  3. package/dist/browser-stream-controller.js +226 -0
  4. package/dist/browser-stream-controller.js.map +1 -0
  5. package/dist/browser.d.ts +16 -195
  6. package/dist/browser.js +78 -339
  7. package/dist/browser.js.map +1 -1
  8. package/dist/index-BpUN6Tdz.d.ts +440 -0
  9. package/dist/index.d.ts +1 -271
  10. package/dist/index.js +34 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/node-stream-controller.d.ts +133 -0
  13. package/dist/node-stream-controller.js +274 -0
  14. package/dist/node-stream-controller.js.map +1 -0
  15. package/dist/node.d.ts +3 -2
  16. package/dist/node.js +2 -0
  17. package/dist/node.js.map +1 -1
  18. package/dist/stream-controller.d.ts +1 -0
  19. package/dist/stream-controller.js +277 -0
  20. package/dist/stream-controller.js.map +1 -0
  21. package/dist/streaming-worker.js +1 -1
  22. package/dist/streaming-worker.js.map +1 -1
  23. package/dist/tests/stream-controller.test.js +237 -0
  24. package/dist/tests/stream-controller.test.js.map +1 -0
  25. package/dist/wasm/nodejs/convert_buddy.d.ts +6 -0
  26. package/dist/wasm/nodejs/convert_buddy.js +58 -28
  27. package/dist/wasm/nodejs/convert_buddy_bg.wasm +0 -0
  28. package/dist/wasm/nodejs/convert_buddy_bg.wasm.d.ts +4 -3
  29. package/dist/wasm/web/convert_buddy.d.ts +10 -3
  30. package/dist/wasm/web/convert_buddy.js +55 -27
  31. package/dist/wasm/web/convert_buddy_bg.wasm +0 -0
  32. package/dist/wasm/web/convert_buddy_bg.wasm.d.ts +4 -3
  33. package/package.json +3 -5
  34. package/dist/browser-core.d.ts +0 -196
  35. package/dist/browser-core.js +0 -787
  36. package/dist/browser-core.js.map +0 -1
  37. package/dist/wasm/nodejs/convert_buddy.cjs +0 -712
@@ -2,26 +2,9 @@
2
2
  let imports = {};
3
3
  imports['__wbindgen_placeholder__'] = module.exports;
4
4
  let wasm;
5
- const { TextDecoder, TextEncoder } = require(`util`);
5
+ const { TextEncoder, TextDecoder } = require(`util`);
6
6
 
7
- function addToExternrefTable0(obj) {
8
- const idx = wasm.__externref_table_alloc();
9
- wasm.__wbindgen_export_2.set(idx, obj);
10
- return idx;
11
- }
12
-
13
- function handleError(f, args) {
14
- try {
15
- return f.apply(this, args);
16
- } catch (e) {
17
- const idx = addToExternrefTable0(e);
18
- wasm.__wbindgen_exn_store(idx);
19
- }
20
- }
21
-
22
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
23
-
24
- cachedTextDecoder.decode();
7
+ let WASM_VECTOR_LEN = 0;
25
8
 
26
9
  let cachedUint8ArrayMemory0 = null;
27
10
 
@@ -32,13 +15,6 @@ function getUint8ArrayMemory0() {
32
15
  return cachedUint8ArrayMemory0;
33
16
  }
34
17
 
35
- function getStringFromWasm0(ptr, len) {
36
- ptr = ptr >>> 0;
37
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
38
- }
39
-
40
- let WASM_VECTOR_LEN = 0;
41
-
42
18
  let cachedTextEncoder = new TextEncoder('utf-8');
43
19
 
44
20
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -102,6 +78,30 @@ function getDataViewMemory0() {
102
78
  return cachedDataViewMemory0;
103
79
  }
104
80
 
81
+ function addToExternrefTable0(obj) {
82
+ const idx = wasm.__externref_table_alloc();
83
+ wasm.__wbindgen_export_4.set(idx, obj);
84
+ return idx;
85
+ }
86
+
87
+ function handleError(f, args) {
88
+ try {
89
+ return f.apply(this, args);
90
+ } catch (e) {
91
+ const idx = addToExternrefTable0(e);
92
+ wasm.__wbindgen_exn_store(idx);
93
+ }
94
+ }
95
+
96
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
97
+
98
+ cachedTextDecoder.decode();
99
+
100
+ function getStringFromWasm0(ptr, len) {
101
+ ptr = ptr >>> 0;
102
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
103
+ }
104
+
105
105
  function isLikeNone(x) {
106
106
  return x === undefined || x === null;
107
107
  }
@@ -291,7 +291,7 @@ module.exports.get_threading_support_info = function() {
291
291
  };
292
292
 
293
293
  function takeFromExternrefTable0(idx) {
294
- const value = wasm.__wbindgen_export_2.get(idx);
294
+ const value = wasm.__wbindgen_export_4.get(idx);
295
295
  wasm.__externref_table_dealloc(idx);
296
296
  return value;
297
297
  }
@@ -352,6 +352,23 @@ class Converter {
352
352
  }
353
353
  return Converter.__wrap(ret[0]);
354
354
  }
355
+ /**
356
+ * Push a chunk of bytes and optionally get pre-parsed records.
357
+ * When include_records is true, returns { output: Uint8Array, records: Array }
358
+ * When false, returns just the Uint8Array (for backward compatibility and performance).
359
+ * @param {Uint8Array} chunk
360
+ * @param {boolean} include_records
361
+ * @returns {any}
362
+ */
363
+ pushWithRecords(chunk, include_records) {
364
+ const ptr0 = passArray8ToWasm0(chunk, wasm.__wbindgen_malloc);
365
+ const len0 = WASM_VECTOR_LEN;
366
+ const ret = wasm.converter_pushWithRecords(this.__wbg_ptr, ptr0, len0, include_records);
367
+ if (ret[2]) {
368
+ throw takeFromExternrefTable0(ret[1]);
369
+ }
370
+ return takeFromExternrefTable0(ret[0]);
371
+ }
355
372
  /**
356
373
  * @param {boolean} debug
357
374
  */
@@ -501,6 +518,14 @@ class Stats {
501
518
  }
502
519
  module.exports.Stats = Stats;
503
520
 
521
+ module.exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
522
+ const ret = String(arg1);
523
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
524
+ const len1 = WASM_VECTOR_LEN;
525
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
526
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
527
+ };
528
+
504
529
  module.exports.__wbg_buffer_61b7ce01341d7f88 = function(arg0) {
505
530
  const ret = arg0.buffer;
506
531
  return ret;
@@ -647,6 +672,11 @@ module.exports.__wbg_new_bc96c6a1c0786643 = function() {
647
672
  return ret;
648
673
  };
649
674
 
675
+ module.exports.__wbg_newwithbyteoffsetandlength_ba35896968751d91 = function(arg0, arg1, arg2) {
676
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
677
+ return ret;
678
+ };
679
+
650
680
  module.exports.__wbg_next_01dd9234a5bf6d05 = function() { return handleError(function (arg0) {
651
681
  const ret = arg0.next();
652
682
  return ret;
@@ -748,7 +778,7 @@ module.exports.__wbindgen_in = function(arg0, arg1) {
748
778
  };
749
779
 
750
780
  module.exports.__wbindgen_init_externref_table = function() {
751
- const table = wasm.__wbindgen_export_2;
781
+ const table = wasm.__wbindgen_export_4;
752
782
  const offset = table.grow(4);
753
783
  table.set(0, undefined);
754
784
  table.set(offset + 0, undefined);
@@ -7,6 +7,7 @@ export const converter_finish: (a: number) => [number, number, number, number];
7
7
  export const converter_getStats: (a: number) => number;
8
8
  export const converter_new: (a: number) => number;
9
9
  export const converter_push: (a: number, b: number, c: number) => [number, number, number, number];
10
+ export const converter_pushWithRecords: (a: number, b: number, c: number, d: number) => [number, number, number];
10
11
  export const converter_withConfig: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any, i: any, j: any) => [number, number, number];
11
12
  export const detectCsvFields: (a: number, b: number) => any;
12
13
  export const detectFormat: (a: number, b: number) => [number, number];
@@ -28,11 +29,11 @@ export const stats_records_processed: (a: number) => number;
28
29
  export const stats_throughput_mb_per_sec: (a: number) => number;
29
30
  export const stats_transform_time_ms: (a: number) => number;
30
31
  export const stats_write_time_ms: (a: number) => number;
32
+ export const __wbindgen_malloc: (a: number, b: number) => number;
33
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
31
34
  export const __wbindgen_exn_store: (a: number) => void;
32
35
  export const __externref_table_alloc: () => number;
33
- export const __wbindgen_export_2: WebAssembly.Table;
36
+ export const __wbindgen_export_4: WebAssembly.Table;
34
37
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
35
- export const __wbindgen_malloc: (a: number, b: number) => number;
36
- export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
37
38
  export const __externref_table_dealloc: (a: number) => void;
38
39
  export const __wbindgen_start: () => void;
@@ -44,6 +44,12 @@ export class Converter {
44
44
  * Create a new converter with specific configuration
45
45
  */
46
46
  static withConfig(debug: boolean, input_format: string, output_format: string, chunk_target_bytes: number, enable_stats: boolean, csv_config: any, xml_config: any, transform_config: any): Converter;
47
+ /**
48
+ * Push a chunk of bytes and optionally get pre-parsed records.
49
+ * When include_records is true, returns { output: Uint8Array, records: Array }
50
+ * When false, returns just the Uint8Array (for backward compatibility and performance).
51
+ */
52
+ pushWithRecords(chunk: Uint8Array, include_records: boolean): any;
47
53
  constructor(debug: boolean);
48
54
  /**
49
55
  * Push a chunk of bytes. Returns converted output bytes for that chunk.
@@ -86,6 +92,7 @@ export interface InitOutput {
86
92
  readonly converter_getStats: (a: number) => number;
87
93
  readonly converter_new: (a: number) => number;
88
94
  readonly converter_push: (a: number, b: number, c: number) => [number, number, number, number];
95
+ readonly converter_pushWithRecords: (a: number, b: number, c: number, d: number) => [number, number, number];
89
96
  readonly converter_withConfig: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any, i: any, j: any) => [number, number, number];
90
97
  readonly detectCsvFields: (a: number, b: number) => any;
91
98
  readonly detectFormat: (a: number, b: number) => [number, number];
@@ -107,12 +114,12 @@ export interface InitOutput {
107
114
  readonly stats_throughput_mb_per_sec: (a: number) => number;
108
115
  readonly stats_transform_time_ms: (a: number) => number;
109
116
  readonly stats_write_time_ms: (a: number) => number;
117
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
118
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
110
119
  readonly __wbindgen_exn_store: (a: number) => void;
111
120
  readonly __externref_table_alloc: () => number;
112
- readonly __wbindgen_export_2: WebAssembly.Table;
121
+ readonly __wbindgen_export_4: WebAssembly.Table;
113
122
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
114
- readonly __wbindgen_malloc: (a: number, b: number) => number;
115
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
116
123
  readonly __externref_table_dealloc: (a: number) => void;
117
124
  readonly __wbindgen_start: () => void;
118
125
  }
@@ -1,23 +1,6 @@
1
1
  let wasm;
2
2
 
3
- function addToExternrefTable0(obj) {
4
- const idx = wasm.__externref_table_alloc();
5
- wasm.__wbindgen_export_2.set(idx, obj);
6
- return idx;
7
- }
8
-
9
- function handleError(f, args) {
10
- try {
11
- return f.apply(this, args);
12
- } catch (e) {
13
- const idx = addToExternrefTable0(e);
14
- wasm.__wbindgen_exn_store(idx);
15
- }
16
- }
17
-
18
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
19
-
20
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
3
+ let WASM_VECTOR_LEN = 0;
21
4
 
22
5
  let cachedUint8ArrayMemory0 = null;
23
6
 
@@ -28,13 +11,6 @@ function getUint8ArrayMemory0() {
28
11
  return cachedUint8ArrayMemory0;
29
12
  }
30
13
 
31
- function getStringFromWasm0(ptr, len) {
32
- ptr = ptr >>> 0;
33
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
34
- }
35
-
36
- let WASM_VECTOR_LEN = 0;
37
-
38
14
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
39
15
 
40
16
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -98,6 +74,30 @@ function getDataViewMemory0() {
98
74
  return cachedDataViewMemory0;
99
75
  }
100
76
 
77
+ function addToExternrefTable0(obj) {
78
+ const idx = wasm.__externref_table_alloc();
79
+ wasm.__wbindgen_export_4.set(idx, obj);
80
+ return idx;
81
+ }
82
+
83
+ function handleError(f, args) {
84
+ try {
85
+ return f.apply(this, args);
86
+ } catch (e) {
87
+ const idx = addToExternrefTable0(e);
88
+ wasm.__wbindgen_exn_store(idx);
89
+ }
90
+ }
91
+
92
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
93
+
94
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
95
+
96
+ function getStringFromWasm0(ptr, len) {
97
+ ptr = ptr >>> 0;
98
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
99
+ }
100
+
101
101
  function isLikeNone(x) {
102
102
  return x === undefined || x === null;
103
103
  }
@@ -287,7 +287,7 @@ export function get_threading_support_info() {
287
287
  }
288
288
 
289
289
  function takeFromExternrefTable0(idx) {
290
- const value = wasm.__wbindgen_export_2.get(idx);
290
+ const value = wasm.__wbindgen_export_4.get(idx);
291
291
  wasm.__externref_table_dealloc(idx);
292
292
  return value;
293
293
  }
@@ -348,6 +348,23 @@ export class Converter {
348
348
  }
349
349
  return Converter.__wrap(ret[0]);
350
350
  }
351
+ /**
352
+ * Push a chunk of bytes and optionally get pre-parsed records.
353
+ * When include_records is true, returns { output: Uint8Array, records: Array }
354
+ * When false, returns just the Uint8Array (for backward compatibility and performance).
355
+ * @param {Uint8Array} chunk
356
+ * @param {boolean} include_records
357
+ * @returns {any}
358
+ */
359
+ pushWithRecords(chunk, include_records) {
360
+ const ptr0 = passArray8ToWasm0(chunk, wasm.__wbindgen_malloc);
361
+ const len0 = WASM_VECTOR_LEN;
362
+ const ret = wasm.converter_pushWithRecords(this.__wbg_ptr, ptr0, len0, include_records);
363
+ if (ret[2]) {
364
+ throw takeFromExternrefTable0(ret[1]);
365
+ }
366
+ return takeFromExternrefTable0(ret[0]);
367
+ }
351
368
  /**
352
369
  * @param {boolean} debug
353
370
  */
@@ -529,6 +546,13 @@ async function __wbg_load(module, imports) {
529
546
  function __wbg_get_imports() {
530
547
  const imports = {};
531
548
  imports.wbg = {};
549
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
550
+ const ret = String(arg1);
551
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
552
+ const len1 = WASM_VECTOR_LEN;
553
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
554
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
555
+ };
532
556
  imports.wbg.__wbg_buffer_61b7ce01341d7f88 = function(arg0) {
533
557
  const ret = arg0.buffer;
534
558
  return ret;
@@ -650,6 +674,10 @@ function __wbg_get_imports() {
650
674
  const ret = new Map();
651
675
  return ret;
652
676
  };
677
+ imports.wbg.__wbg_newwithbyteoffsetandlength_ba35896968751d91 = function(arg0, arg1, arg2) {
678
+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
679
+ return ret;
680
+ };
653
681
  imports.wbg.__wbg_next_01dd9234a5bf6d05 = function() { return handleError(function (arg0) {
654
682
  const ret = arg0.next();
655
683
  return ret;
@@ -732,7 +760,7 @@ function __wbg_get_imports() {
732
760
  return ret;
733
761
  };
734
762
  imports.wbg.__wbindgen_init_externref_table = function() {
735
- const table = wasm.__wbindgen_export_2;
763
+ const table = wasm.__wbindgen_export_4;
736
764
  const offset = table.grow(4);
737
765
  table.set(0, undefined);
738
766
  table.set(offset + 0, undefined);
Binary file
@@ -7,6 +7,7 @@ export const converter_finish: (a: number) => [number, number, number, number];
7
7
  export const converter_getStats: (a: number) => number;
8
8
  export const converter_new: (a: number) => number;
9
9
  export const converter_push: (a: number, b: number, c: number) => [number, number, number, number];
10
+ export const converter_pushWithRecords: (a: number, b: number, c: number, d: number) => [number, number, number];
10
11
  export const converter_withConfig: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any, i: any, j: any) => [number, number, number];
11
12
  export const detectCsvFields: (a: number, b: number) => any;
12
13
  export const detectFormat: (a: number, b: number) => [number, number];
@@ -28,11 +29,11 @@ export const stats_records_processed: (a: number) => number;
28
29
  export const stats_throughput_mb_per_sec: (a: number) => number;
29
30
  export const stats_transform_time_ms: (a: number) => number;
30
31
  export const stats_write_time_ms: (a: number) => number;
32
+ export const __wbindgen_malloc: (a: number, b: number) => number;
33
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
31
34
  export const __wbindgen_exn_store: (a: number) => void;
32
35
  export const __externref_table_alloc: () => number;
33
- export const __wbindgen_export_2: WebAssembly.Table;
36
+ export const __wbindgen_export_4: WebAssembly.Table;
34
37
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
35
- export const __wbindgen_malloc: (a: number, b: number) => number;
36
- export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
37
38
  export const __externref_table_dealloc: (a: number) => void;
38
39
  export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "convert-buddy-js",
3
- "version": "0.10.18",
3
+ "version": "0.11.1",
4
4
  "description": "TypeScript wrapper for convert-buddy (Rust/WASM core)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,10 +27,6 @@
27
27
  "types": "./dist/browser.d.ts",
28
28
  "default": "./dist/browser.js"
29
29
  },
30
- "./browser-core": {
31
- "types": "./dist/browser-core.d.ts",
32
- "default": "./dist/browser-core.js"
33
- },
34
30
  "./wasm/web/convert_buddy.js": {
35
31
  "default": "./dist/wasm/web/convert_buddy.js"
36
32
  }
@@ -50,6 +46,8 @@
50
46
  "build": "npm run build:wasm && tsup && npm run sync:wasm",
51
47
  "check:wasm": "node ./scripts/check-wasm.mjs",
52
48
  "test": "npm run build && node --test ./dist/tests/edge-cases/*.test.js",
49
+ "test:stream-controller": "npm run build && node --test ./dist/tests/stream-controller.test.js",
50
+ "test:stream-quick": "npm run build && node ./test-stream-controller.js",
53
51
  "bench": "npm run build && node --expose-gc ./dist/bench/runner.js",
54
52
  "bench:single-thread": "npm run build && node --expose-gc ./scripts/run-single-thread.mjs",
55
53
  "bench:multi-thread": "npm run build && node --expose-gc ./dist/bench/multi-thread.js",
@@ -1,196 +0,0 @@
1
- /**
2
- * Browser-only core module for convert-buddy-js
3
- * This module contains ONLY browser-compatible code with NO Node.js dependencies.
4
- * It's designed to work in any browser environment including StackBlitz without WebContainers.
5
- */
6
- type Format = "csv" | "ndjson" | "json" | "xml";
7
- type DetectInput = Uint8Array | ArrayBuffer | string | ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;
8
- type CsvDetection = {
9
- delimiter: string;
10
- fields: string[];
11
- };
12
- type XmlDetection = {
13
- elements: string[];
14
- recordElement?: string;
15
- };
16
- type JsonDetection = {
17
- fields: string[];
18
- };
19
- type NdjsonDetection = {
20
- fields: string[];
21
- };
22
- type StructureDetection = {
23
- format: Format;
24
- fields: string[];
25
- delimiter?: string;
26
- recordElement?: string;
27
- };
28
- type DetectOptions = {
29
- maxBytes?: number;
30
- debug?: boolean;
31
- };
32
- type ProgressCallback = (stats: Stats) => void;
33
- type ConvertBuddyOptions = {
34
- debug?: boolean;
35
- profile?: boolean;
36
- inputFormat?: Format | "auto";
37
- outputFormat?: Format;
38
- chunkTargetBytes?: number;
39
- parallelism?: number;
40
- maxMemoryMB?: number;
41
- csvConfig?: CsvConfig;
42
- xmlConfig?: XmlConfig;
43
- transform?: TransformConfig;
44
- onProgress?: ProgressCallback;
45
- progressIntervalBytes?: number;
46
- };
47
- type ConvertOptions = {
48
- inputFormat?: Format | "auto";
49
- outputFormat: Format;
50
- csvConfig?: CsvConfig;
51
- xmlConfig?: XmlConfig;
52
- transform?: TransformConfig;
53
- onProgress?: ProgressCallback;
54
- };
55
- type CsvConfig = {
56
- delimiter?: string;
57
- quote?: string;
58
- hasHeaders?: boolean;
59
- trimWhitespace?: boolean;
60
- };
61
- type XmlConfig = {
62
- recordElement?: string;
63
- trimText?: boolean;
64
- includeAttributes?: boolean;
65
- expandEntities?: boolean;
66
- };
67
- type TransformMode = "replace" | "augment";
68
- type Coerce = {
69
- type: "string";
70
- } | {
71
- type: "i64";
72
- } | {
73
- type: "f64";
74
- } | {
75
- type: "bool";
76
- } | {
77
- type: "timestamp_ms";
78
- format?: "iso8601" | "unix_ms" | "unix_s";
79
- };
80
- type FieldMap = {
81
- targetFieldName: string;
82
- originFieldName?: string;
83
- required?: boolean;
84
- defaultValue?: string | number | boolean | null;
85
- coerce?: Coerce;
86
- compute?: string;
87
- };
88
- type TransformConfig = {
89
- mode?: TransformMode;
90
- fields: FieldMap[];
91
- onMissingField?: "error" | "null" | "drop";
92
- onMissingRequired?: "error" | "abort";
93
- onCoerceError?: "error" | "null" | "dropRecord";
94
- };
95
- type Stats = {
96
- bytesIn: number;
97
- bytesOut: number;
98
- chunksIn: number;
99
- recordsProcessed: number;
100
- parseTimeMs: number;
101
- transformTimeMs: number;
102
- writeTimeMs: number;
103
- maxBufferSize: number;
104
- currentPartialSize: number;
105
- throughputMbPerSec: number;
106
- };
107
- declare class ConvertBuddy {
108
- private converter;
109
- private debug;
110
- private profile;
111
- private aborted;
112
- private paused;
113
- private onProgress?;
114
- private progressIntervalBytes;
115
- private lastProgressBytes;
116
- private globalConfig;
117
- private initialized;
118
- simd: boolean;
119
- constructor(opts?: ConvertBuddyOptions);
120
- /**
121
- * Create and initialize a ConvertBuddy instance
122
- */
123
- static create(opts?: ConvertBuddyOptions): Promise<ConvertBuddy>;
124
- /**
125
- * Push a chunk of data through the converter
126
- */
127
- push(chunk: Uint8Array): Uint8Array;
128
- /**
129
- * Finish the conversion and get any remaining output
130
- */
131
- finish(): Uint8Array;
132
- /**
133
- * Get conversion statistics
134
- */
135
- stats(): Stats;
136
- /**
137
- * Abort the conversion
138
- */
139
- abort(): void;
140
- /**
141
- * Check if the conversion was aborted
142
- */
143
- isAborted(): boolean;
144
- /**
145
- * Pause the conversion
146
- */
147
- pause(): void;
148
- /**
149
- * Resume the conversion
150
- */
151
- resume(): void;
152
- /**
153
- * Check if the conversion is paused
154
- */
155
- isPaused(): boolean;
156
- /**
157
- * Simple convert method for single-shot conversions
158
- */
159
- convert(input: string | Uint8Array | File | Blob | ReadableStream<Uint8Array>, opts: ConvertOptions): Promise<Uint8Array>;
160
- private convertFromUrl;
161
- private convertFromString;
162
- private convertFromBuffer;
163
- private convertFromFile;
164
- private convertFromBlob;
165
- private convertFromStream;
166
- }
167
- declare function detectFormat(sample: Uint8Array | ArrayBuffer | string, opts?: DetectOptions): Promise<Format | "unknown">;
168
- declare function detectStructure(sample: Uint8Array | ArrayBuffer | string, opts?: DetectOptions): Promise<StructureDetection | null>;
169
- declare function detectCsvFieldsAndDelimiter(sample: Uint8Array | ArrayBuffer | string, opts?: DetectOptions): Promise<CsvDetection | null>;
170
- declare function detectXmlElements(sample: Uint8Array | ArrayBuffer | string, opts?: DetectOptions): Promise<XmlDetection | null>;
171
- declare function autoDetectConfig(sample: Uint8Array | ArrayBuffer | string, opts?: DetectOptions): Promise<{
172
- format: Format | "unknown";
173
- csvConfig?: CsvConfig;
174
- xmlConfig?: XmlConfig;
175
- }>;
176
- declare function convert(input: string | Uint8Array, opts: ConvertOptions): Promise<Uint8Array>;
177
- declare function convertToString(input: string | Uint8Array, opts: ConvertOptions): Promise<string>;
178
- declare function convertAny(input: string | Uint8Array | File | Blob | ReadableStream<Uint8Array>, opts: ConvertOptions): Promise<Uint8Array>;
179
- declare function convertAnyToString(input: string | Uint8Array | File | Blob | ReadableStream<Uint8Array>, opts: ConvertOptions): Promise<string>;
180
- declare function getMimeType(format: Format): string;
181
- declare function getExtension(format: Format): string;
182
- declare function getSuggestedFilename(originalName: string, outputFormat: Format, includeTimestamp?: boolean): string;
183
- declare function getFileTypeConfig(format: Format): Array<{
184
- description: string;
185
- accept: Record<string, string[]>;
186
- }>;
187
- declare class ConvertBuddyTransformStream extends TransformStream<Uint8Array, Uint8Array> {
188
- constructor(opts?: ConvertBuddyOptions);
189
- }
190
- /**
191
- * Backward compatibility alias for ConvertBuddy
192
- * @deprecated Use ConvertBuddy instead
193
- */
194
- declare const Converter: typeof ConvertBuddy;
195
-
196
- export { type Coerce, ConvertBuddy, type ConvertBuddyOptions, ConvertBuddyTransformStream, type ConvertOptions, Converter, type CsvConfig, type CsvDetection, type DetectInput, type DetectOptions, type FieldMap, type Format, type JsonDetection, type NdjsonDetection, type ProgressCallback, type Stats, type StructureDetection, type TransformConfig, type TransformMode, type XmlConfig, type XmlDetection, autoDetectConfig, convert, convertAny, convertAnyToString, convertToString, detectCsvFieldsAndDelimiter, detectFormat, detectStructure, detectXmlElements, getExtension, getFileTypeConfig, getMimeType, getSuggestedFilename };