handlemyfile 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HandleMyFile Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,245 @@
1
- # Temporary Holding Version
1
+ # HandleMyFile
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <div align="center">
4
+
5
+ [![Crates.io](https://img.shields.io/crates/v/handlemyfile.svg)](https://crates.io/crates/handlemyfile)
6
+ [![PyPI](https://img.shields.io/pypi/v/handlemyfile.svg)](https://pypi.org/project/handlemyfile/)
7
+ [![NPM](https://img.shields.io/npm/v/handlemyfile.svg)](https://www.npmjs.com/package/handlemyfile)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ **High-precision, edge-native PDF to DOCX converter engine in Pure Rust, WebAssembly, and Python.**
11
+
12
+ [Rust Guide](#1-rust-cratesio) • [Python Guide](#2-python-pypi) • [WebAssembly / JS](#3-javascript--typescript-npm) • [Known Limitations](#known-limitations-kekurangan-saat-ini) • [Architecture](#architecture)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ ## Overview
19
+
20
+ **HandleMyFile** is an edge-native, zero-egress document conversion engine. It converts raw Portable Document Format (PDF) files into cleanly structured, editable Microsoft Word (.docx) files using deep Document Layout Analysis (DLA).
21
+
22
+ ### Key Features
23
+ - **100% Client-Side & Zero-Egress**: Runs completely in-memory in pure Rust, WebAssembly (in-browser or Node.js), or Python without sending private documents to any remote cloud API.
24
+ - **Advanced Document Layout Analysis (DLA)**: Recursive spatial analysis (R-XY-Cut) coupled with 2D R*-Tree spatial indexing.
25
+ - **Planar Graph Table Reconstruction**: Detects contiguous ruling lines, intersections, and cells to rebuild true native OOXML `<w:tbl>` tables with dynamic cell margins and border styling.
26
+ - **Clean Document Flow**: Automatically detects chapter headings, hierarchical sub-sections, cover pages, and front matter without spurious page breaks.
27
+ - **Dynamic Header & Footer Detection**: Extracts headers, footers, and page numbers into native Word field codes (`<w:fldSimple w:instr="PAGE"/>`).
28
+
29
+ ---
30
+
31
+ ## Known Limitations (Kekurangan Saat Ini)
32
+
33
+ > [!WARNING]
34
+ > **Format Dua Kolom (Multi-Column Layouts) Merupakan Kekurangan Saat Ini**
35
+ >
36
+ > Saat ini, **dokumen dengan tata letak dua kolom (2-column layout)**—seperti paper IEEE/ACM dua kolom padat atau artikel koran—**merupakan limitasi/kekurangan yang sedang dalam tahap pengembangan aktif**.
37
+ >
38
+ > - **Rekomendasi Optimal**: Format 1-kolom (seperti skripsi, tesis, laporan magang/proyek, buku, panduan, faktur/invoice, formulir, dan dokumen resmi satu kolom) didukung dengan sangat presisi dan mengalir alami.
39
+ > - **Perilaku Dua Kolom**: Dokumen dua kolom yang memiliki teks melompat antar kolom, gambar melintang (*straddling figures/tables*), atau *split column* yang tidak seimbang dapat mengalami pemotongan teks atau urutan baca (*reading order*) yang belum 100% sempurna. Peningkatan algoritma R-XY-Cut untuk rekonstruksi multi-kolom yang lebih adaptif sedang disempurnakan pada rilis mendatang.
40
+
41
+ ---
42
+
43
+ ## 1. Rust (Crates.io)
44
+
45
+ ### Installation
46
+
47
+ Add `handlemyfile` to your `Cargo.toml`:
48
+
49
+ ```toml
50
+ [dependencies]
51
+ handlemyfile = "0.1.0"
52
+ ```
53
+
54
+ ### Usage
55
+
56
+ ```rust
57
+ use handlemyfile::ConverterEngine;
58
+ use std::fs;
59
+
60
+ fn main() -> Result<(), Box<dyn std::error::Error>> {
61
+ // Read PDF file
62
+ let pdf_bytes = fs::read("document.pdf")?;
63
+
64
+ // Initialize converter engine
65
+ let engine = ConverterEngine::new();
66
+
67
+ // Convert to DOCX bytes
68
+ let docx_bytes = engine.convert(&pdf_bytes)?;
69
+
70
+ // Save to disk
71
+ fs::write("output.docx", docx_bytes)?;
72
+ println!("Conversion successful!");
73
+
74
+ Ok(())
75
+ }
76
+ ```
77
+
78
+ ### Rust CLI
79
+
80
+ You can install the CLI directly with Cargo:
81
+
82
+ ```bash
83
+ cargo install handlemyfile
84
+ handlemyfile input.pdf output.docx
85
+ ```
86
+
87
+ ---
88
+
89
+ ## 2. Python (PyPI)
90
+
91
+ ### Installation
92
+
93
+ Install via `pip`:
94
+
95
+ ```bash
96
+ pip install handlemyfile
97
+ ```
98
+
99
+ ### Usage
100
+
101
+ ```python
102
+ import handlemyfile
103
+
104
+ # Option 1: File-to-file conversion
105
+ handlemyfile.convert_file("input.pdf", "output.docx")
106
+
107
+ # Option 2: In-memory byte conversion
108
+ with open("document.pdf", "rb") as f:
109
+ pdf_bytes = f.read()
110
+
111
+ docx_bytes = handlemyfile.convert(pdf_bytes)
112
+
113
+ with open("converted.docx", "wb") as f:
114
+ f.write(docx_bytes)
115
+ ```
116
+
117
+ ### Python CLI
118
+
119
+ Installing via pip also provides a standalone CLI command:
120
+
121
+ ```bash
122
+ handlemyfile input.pdf output.docx
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 3. JavaScript / TypeScript (NPM & WebAssembly)
128
+
129
+ The package compiles to WebAssembly with zero external dependencies, making it ideal for browser client-side execution or Node.js services.
130
+
131
+ ### Installation
132
+
133
+ ```bash
134
+ npm install handlemyfile
135
+ ```
136
+
137
+ ### Browser (ES Modules)
138
+
139
+ ```javascript
140
+ import init, { convert_pdf_to_docx } from 'handlemyfile';
141
+
142
+ async function convertFile(file) {
143
+ // Initialize WebAssembly runtime
144
+ await init();
145
+
146
+ const arrayBuffer = await file.arrayBuffer();
147
+ const pdfBytes = new Uint8Array(arrayBuffer);
148
+
149
+ // Convert PDF to Word DOCX
150
+ const docxBytes = convert_pdf_to_docx(pdfBytes);
151
+
152
+ // Create a download link for user
153
+ const blob = new Blob([docxBytes], {
154
+ type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
155
+ });
156
+ const url = URL.createObjectURL(blob);
157
+ const a = document.createElement('a');
158
+ a.href = url;
159
+ a.download = 'converted.docx';
160
+ a.click();
161
+ }
162
+ ```
163
+
164
+ ### Node.js Usage
165
+
166
+ ```javascript
167
+ import fs from 'fs';
168
+ import init, { convert_pdf_to_docx } from 'handlemyfile';
169
+
170
+ // Read wasm binary and initialize
171
+ const wasmBuffer = fs.readFileSync('./node_modules/handlemyfile/handlemyfile_bg.wasm');
172
+ await init(wasmBuffer);
173
+
174
+ const pdfData = fs.readFileSync('input.pdf');
175
+ const docxData = convert_pdf_to_docx(new Uint8Array(pdfData));
176
+
177
+ fs.writeFileSync('output.docx', Buffer.from(docxData));
178
+ console.log('Successfully generated output.docx');
179
+ ```
180
+
181
+ ---
182
+
183
+ ## Architecture
184
+
185
+ HandleMyFile is built with a multi-stage Document Layout Analysis pipeline:
186
+
187
+ ```
188
+ [Raw PDF Bytes]
189
+ │
190
+ ▼
191
+ [PDF Object & Stream Parser (lopdf / Flate2)]
192
+ │
193
+ ▼
194
+ [Text, Glyphs & Vector Graphic Extraction]
195
+ │
196
+ ▼
197
+ [2D R*-Tree Spatial Indexing & Graph Intersections]
198
+ │
199
+ ┌────┴───────────────────────────┐
200
+ │ │
201
+ ▼ ▼
202
+ [Planar Graph Table Detector] [Recursive R-XY-Cut & Classifier]
203
+ │ │
204
+ └────┬───────────────────────────┘
205
+ │
206
+ ▼
207
+ [OOXML Builder & Package Generator]
208
+ │
209
+ ▼
210
+ [Final .docx ZIP Container]
211
+ ```
212
+
213
+ 1. **Stream Decompression**: Parses PDF streams, xref tables, font dictionaries (ToUnicode CMaps, TrueType/Type0), and graphic states.
214
+ 2. **Document Layout Analysis (DLA)**: Analyzes spatial bounding boxes, baseline alignments, and gap thresholds to cluster text lines into coherent paragraphs and headings.
215
+ 3. **Table Structure Recognition (TSR)**: Extracts planar path segments, computes intersection points, and infers tabular grid geometry.
216
+ 4. **OOXML Generation**: Directly writes validated Office Open XML schemas (`word/document.xml`, `styles.xml`, `numbering.xml`, headers/footers) packaged into a standard ZIP archive.
217
+
218
+ ---
219
+
220
+ ## Development & Building
221
+
222
+ ### Prerequisites
223
+ - [Rust](https://www.rust-lang.org/) (edition 2021)
224
+ - [wasm-pack](https://rustwasm.github.io/wasm-pack/) (for WebAssembly builds)
225
+ - [Python](https://www.python.org/) 3.8+ and [maturin](https://www.maturin.rs/) (for Python builds)
226
+ - [Node.js](https://nodejs.org/) 18+ (for testing npm package)
227
+
228
+ ### Build Commands
229
+
230
+ ```bash
231
+ # 1. Build Rust Native CLI & Library
232
+ cargo build --release
233
+
234
+ # 2. Build WebAssembly (Web target)
235
+ wasm-pack build --target web --out-name handlemyfile
236
+
237
+ # 3. Build Python Wheels locally
238
+ maturin build --features python
239
+ ```
240
+
241
+ ---
242
+
243
+ ## License
244
+
245
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,54 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * WebAssembly entrypoint for JavaScript/Browser to convert PDF to DOCX
6
+ */
7
+ export function convert_pdf_to_docx(pdf_data: Uint8Array | number[]): Uint8Array;
8
+
9
+ /**
10
+ * WebAssembly entrypoint to inspect parsed spatial elements & structured layout
11
+ */
12
+ export function inspect_pdf_elements(pdf_data: Uint8Array | number[]): any;
13
+
14
+ /**
15
+ * WebAssembly entrypoint to inspect document structure tree and outlines (Step 6 verification)
16
+ */
17
+ export function inspect_pdf_structure(pdf_data: Uint8Array | number[]): any;
18
+
19
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
20
+
21
+ export interface InitOutput {
22
+ readonly memory: WebAssembly.Memory;
23
+ readonly convert_pdf_to_docx: (a: number, b: number) => [number, number, number, number];
24
+ readonly inspect_pdf_elements: (a: number, b: number) => [number, number, number];
25
+ readonly inspect_pdf_structure: (a: number, b: number) => [number, number, number];
26
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
27
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
29
+ readonly __wbindgen_externrefs: WebAssembly.Table;
30
+ readonly __externref_table_dealloc: (a: number) => void;
31
+ readonly __wbindgen_start: () => void;
32
+ }
33
+
34
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
35
+
36
+ /**
37
+ * Instantiates the given `module`, which can either be bytes or
38
+ * a precompiled `WebAssembly.Module`.
39
+ *
40
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
41
+ *
42
+ * @returns {InitOutput}
43
+ */
44
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
45
+
46
+ /**
47
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
48
+ * for everything else, calls `WebAssembly.instantiate` directly.
49
+ *
50
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
51
+ *
52
+ * @returns {Promise<InitOutput>}
53
+ */
54
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,331 @@
1
+ /* @ts-self-types="./handlemyfile.d.ts" */
2
+
3
+ /**
4
+ * WebAssembly entrypoint for JavaScript/Browser to convert PDF to DOCX
5
+ * @param {Uint8Array | number[]} pdf_data
6
+ * @returns {Uint8Array}
7
+ */
8
+ export function convert_pdf_to_docx(pdf_data) {
9
+ const ptr0 = passArray8ToWasm0(pdf_data, wasm.__wbindgen_malloc);
10
+ const len0 = WASM_VECTOR_LEN;
11
+ const ret = wasm.convert_pdf_to_docx(ptr0, len0);
12
+ if (ret[3]) {
13
+ throw takeFromExternrefTable0(ret[2]);
14
+ }
15
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
16
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
17
+ return v2;
18
+ }
19
+
20
+ /**
21
+ * WebAssembly entrypoint to inspect parsed spatial elements & structured layout
22
+ * @param {Uint8Array | number[]} pdf_data
23
+ * @returns {any}
24
+ */
25
+ export function inspect_pdf_elements(pdf_data) {
26
+ const ptr0 = passArray8ToWasm0(pdf_data, wasm.__wbindgen_malloc);
27
+ const len0 = WASM_VECTOR_LEN;
28
+ const ret = wasm.inspect_pdf_elements(ptr0, len0);
29
+ if (ret[2]) {
30
+ throw takeFromExternrefTable0(ret[1]);
31
+ }
32
+ return takeFromExternrefTable0(ret[0]);
33
+ }
34
+
35
+ /**
36
+ * WebAssembly entrypoint to inspect document structure tree and outlines (Step 6 verification)
37
+ * @param {Uint8Array | number[]} pdf_data
38
+ * @returns {any}
39
+ */
40
+ export function inspect_pdf_structure(pdf_data) {
41
+ const ptr0 = passArray8ToWasm0(pdf_data, wasm.__wbindgen_malloc);
42
+ const len0 = WASM_VECTOR_LEN;
43
+ const ret = wasm.inspect_pdf_structure(ptr0, len0);
44
+ if (ret[2]) {
45
+ throw takeFromExternrefTable0(ret[1]);
46
+ }
47
+ return takeFromExternrefTable0(ret[0]);
48
+ }
49
+ function __wbg_get_imports() {
50
+ const import0 = {
51
+ __proto__: null,
52
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
53
+ const ret = Error(getStringFromWasm0(arg0, arg1));
54
+ return ret;
55
+ },
56
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
57
+ const ret = String(arg1);
58
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
59
+ const len1 = WASM_VECTOR_LEN;
60
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
61
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
62
+ },
63
+ __wbg___wbindgen_is_string_fc456fee5d3317de: function(arg0) {
64
+ const ret = typeof(arg0) === 'string';
65
+ return ret;
66
+ },
67
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
68
+ throw new Error(getStringFromWasm0(arg0, arg1));
69
+ },
70
+ __wbg_new_37eb45aaf5eeb820: function() {
71
+ const ret = new Array();
72
+ return ret;
73
+ },
74
+ __wbg_new_7075786089b89c5e: function() {
75
+ const ret = new Map();
76
+ return ret;
77
+ },
78
+ __wbg_new_cd4348290afae586: function() {
79
+ const ret = new Object();
80
+ return ret;
81
+ },
82
+ __wbg_set_8282f7e0d2d01336: function(arg0, arg1, arg2) {
83
+ const ret = arg0.set(arg1, arg2);
84
+ return ret;
85
+ },
86
+ __wbg_set_d2d33b52458e984a: function(arg0, arg1, arg2) {
87
+ arg0[arg1 >>> 0] = arg2;
88
+ },
89
+ __wbg_set_e4b9a833d288759a: function(arg0, arg1, arg2) {
90
+ arg0[arg1] = arg2;
91
+ },
92
+ __wbindgen_generic_0000000000000001: function(arg0) {
93
+ // Cast intrinsic for `F64 -> Externref`.
94
+ const ret = arg0;
95
+ return ret;
96
+ },
97
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
98
+ // Cast intrinsic for `Ref(String) -> Externref`.
99
+ const ret = getStringFromWasm0(arg0, arg1);
100
+ return ret;
101
+ },
102
+ __wbindgen_generic_0000000000000003: function(arg0) {
103
+ // Cast intrinsic for `U64 -> Externref`.
104
+ const ret = BigInt.asUintN(64, arg0);
105
+ return ret;
106
+ },
107
+ __wbindgen_init_externref_table: function() {
108
+ const table = wasm.__wbindgen_externrefs;
109
+ table.set(0, undefined);
110
+ table.set(1024, undefined);
111
+ table.set(1025, null);
112
+ table.set(1026, true);
113
+ table.set(1027, false);
114
+ },
115
+ };
116
+ return {
117
+ __proto__: null,
118
+ "./handlemyfile_bg.js": import0,
119
+ };
120
+ }
121
+
122
+ function getArrayU8FromWasm0(ptr, len) {
123
+ ptr = ptr >>> 0;
124
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
125
+ }
126
+
127
+ let cachedDataViewMemory0 = null;
128
+ function getDataViewMemory0() {
129
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
130
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
131
+ }
132
+ return cachedDataViewMemory0;
133
+ }
134
+
135
+ function getStringFromWasm0(ptr, len) {
136
+ ptr = ptr >>> 0;
137
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
138
+ }
139
+
140
+ let cachedUint8ArrayMemory0 = null;
141
+ function getUint8ArrayMemory0() {
142
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
143
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
144
+ }
145
+ return cachedUint8ArrayMemory0;
146
+ }
147
+
148
+ function passArray8ToWasm0(arg, malloc) {
149
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
150
+ getUint8ArrayMemory0().set(arg, ptr / 1);
151
+ WASM_VECTOR_LEN = arg.length;
152
+ return ptr;
153
+ }
154
+
155
+ function passStringToWasm0(arg, malloc, realloc) {
156
+ if (realloc === undefined) {
157
+ const buf = cachedTextEncoder.encode(arg);
158
+ const ptr = malloc(buf.length, 1) >>> 0;
159
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
160
+ WASM_VECTOR_LEN = buf.length;
161
+ return ptr;
162
+ }
163
+
164
+ let len = arg.length;
165
+ let ptr = malloc(len, 1) >>> 0;
166
+
167
+ const mem = getUint8ArrayMemory0();
168
+
169
+ let offset = 0;
170
+
171
+ for (; offset < len; offset++) {
172
+ const code = arg.charCodeAt(offset);
173
+ if (code > 0x7F) break;
174
+ mem[ptr + offset] = code;
175
+ }
176
+ if (offset !== len) {
177
+ if (offset !== 0) {
178
+ arg = arg.slice(offset);
179
+ }
180
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
181
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
182
+ const ret = cachedTextEncoder.encodeInto(arg, view);
183
+
184
+ offset += ret.written;
185
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
186
+ }
187
+
188
+ WASM_VECTOR_LEN = offset;
189
+ return ptr;
190
+ }
191
+
192
+ function takeFromExternrefTable0(idx) {
193
+ const value = wasm.__wbindgen_externrefs.get(idx);
194
+ wasm.__externref_table_dealloc(idx);
195
+ return value;
196
+ }
197
+
198
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
199
+ cachedTextDecoder.decode();
200
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
201
+ let numBytesDecoded = 0;
202
+ function decodeText(bytes) {
203
+ numBytesDecoded += bytes.length;
204
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
205
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
206
+ cachedTextDecoder.decode();
207
+ numBytesDecoded = bytes.length;
208
+ }
209
+ return cachedTextDecoder.decode(bytes);
210
+ }
211
+
212
+ const cachedTextEncoder = new TextEncoder();
213
+
214
+ if (!('encodeInto' in cachedTextEncoder)) {
215
+ cachedTextEncoder.encodeInto = function (arg, view) {
216
+ const buf = cachedTextEncoder.encode(arg);
217
+ view.set(buf);
218
+ return {
219
+ read: arg.length,
220
+ written: buf.length
221
+ };
222
+ };
223
+ }
224
+
225
+ let WASM_VECTOR_LEN = 0;
226
+
227
+ let wasmModule, wasmInstance, wasm;
228
+ function __wbg_finalize_init(instance, module) {
229
+ wasmInstance = instance;
230
+ wasm = instance.exports;
231
+ wasmModule = module;
232
+ cachedDataViewMemory0 = null;
233
+ cachedUint8ArrayMemory0 = null;
234
+ wasm.__wbindgen_start();
235
+ return wasm;
236
+ }
237
+
238
+ async function __wbg_load(module, imports) {
239
+ if (typeof Response === 'function' && module instanceof Response) {
240
+ if (!module.ok) {
241
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
242
+ }
243
+
244
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
245
+ try {
246
+ return await WebAssembly.instantiateStreaming(module, imports);
247
+ } catch (e) {
248
+ const validResponse = expectedResponseType(module.type);
249
+
250
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
251
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
252
+
253
+ } else { throw e; }
254
+ }
255
+ }
256
+
257
+ const bytes = await module.arrayBuffer();
258
+ return await WebAssembly.instantiate(bytes, imports);
259
+ } else {
260
+ const instance = await WebAssembly.instantiate(module, imports);
261
+
262
+ if (instance instanceof WebAssembly.Instance) {
263
+ return { instance, module };
264
+ } else {
265
+ return instance;
266
+ }
267
+ }
268
+
269
+ function expectedResponseType(type) {
270
+ switch (type) {
271
+ case 'basic': case 'cors': case 'default': return true;
272
+ }
273
+ return false;
274
+ }
275
+ }
276
+
277
+ function initSync(module) {
278
+ if (wasm !== undefined) return wasm;
279
+
280
+
281
+ if (module !== undefined) {
282
+ if (Object.getPrototypeOf(module) === Object.prototype) {
283
+ ({module} = module)
284
+ } else {
285
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
286
+ }
287
+ }
288
+
289
+ const imports = __wbg_get_imports();
290
+ if (!(module instanceof WebAssembly.Module)) {
291
+ module = new WebAssembly.Module(module);
292
+ }
293
+ const instance = new WebAssembly.Instance(module, imports);
294
+ return __wbg_finalize_init(instance, module);
295
+ }
296
+
297
+ let __wbg_init_promise;
298
+ async function __wbg_init(module_or_path) {
299
+ if (wasm !== undefined) return wasm;
300
+ if (__wbg_init_promise === undefined) {
301
+ __wbg_init_promise = __wbg_init_once(module_or_path);
302
+ __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
303
+ }
304
+ return __wbg_init_promise;
305
+ }
306
+
307
+ async function __wbg_init_once(module_or_path) {
308
+
309
+ if (module_or_path !== undefined) {
310
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
311
+ ({module_or_path} = module_or_path)
312
+ } else {
313
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
314
+ }
315
+ }
316
+
317
+ if (module_or_path === undefined) {
318
+ module_or_path = new URL('handlemyfile_bg.wasm', import.meta.url);
319
+ }
320
+ const imports = __wbg_get_imports();
321
+
322
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
323
+ module_or_path = fetch(module_or_path);
324
+ }
325
+
326
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
327
+
328
+ return __wbg_finalize_init(instance, module);
329
+ }
330
+
331
+ export { initSync, __wbg_init as default };
Binary file
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "handlemyfile",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "type": "module",
4
+ "collaborators": [
5
+ "HandleMyFile Contributors"
6
+ ],
7
+ "description": "High-precision PDF to DOCX converter engine in Pure Rust, WebAssembly, and Python",
8
+ "version": "0.1.0",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/handlemyfile/handlemyfile"
13
+ },
14
+ "files": [
15
+ "handlemyfile_bg.wasm",
16
+ "handlemyfile.js",
17
+ "handlemyfile.d.ts"
18
+ ],
19
+ "main": "handlemyfile.js",
20
+ "types": "handlemyfile.d.ts",
21
+ "sideEffects": [
22
+ "./snippets/*"
23
+ ],
24
+ "keywords": [
25
+ "pdf",
26
+ "docx",
27
+ "converter",
28
+ "word",
29
+ "layout-analysis"
30
+ ]
6
31
  }