@iyulab/undoc 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 iyulab
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/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@iyulab/undoc",
3
+ "type": "module",
4
+ "description": "High-performance Office document extraction to Markdown (WebAssembly)",
5
+ "version": "0.5.2",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/iyulab/undoc"
10
+ },
11
+ "files": [
12
+ "undoc_wasm_bg.wasm",
13
+ "undoc_wasm.js",
14
+ "undoc_wasm_bg.js",
15
+ "undoc_wasm.d.ts"
16
+ ],
17
+ "main": "undoc_wasm.js",
18
+ "types": "undoc_wasm.d.ts",
19
+ "sideEffects": [
20
+ "./undoc_wasm.js",
21
+ "./snippets/*"
22
+ ],
23
+ "keywords": [
24
+ "docx",
25
+ "xlsx",
26
+ "pptx",
27
+ "wasm",
28
+ "webassembly"
29
+ ]
30
+ }
@@ -0,0 +1,16 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class OfficeDocument {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ format(): string;
9
+ static fromBytes(data: Uint8Array): OfficeDocument;
10
+ metadata(): string;
11
+ toJson(): string;
12
+ toMarkdown(): string;
13
+ toText(): string;
14
+ }
15
+
16
+ export function parse(data: Uint8Array): OfficeDocument;
package/undoc_wasm.js ADDED
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./undoc_wasm.d.ts" */
2
+ import * as wasm from "./undoc_wasm_bg.wasm";
3
+ import { __wbg_set_wasm } from "./undoc_wasm_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ OfficeDocument, parse
9
+ } from "./undoc_wasm_bg.js";
@@ -0,0 +1,212 @@
1
+ export class OfficeDocument {
2
+ static __wrap(ptr) {
3
+ const obj = Object.create(OfficeDocument.prototype);
4
+ obj.__wbg_ptr = ptr;
5
+ OfficeDocumentFinalization.register(obj, obj.__wbg_ptr, obj);
6
+ return obj;
7
+ }
8
+ __destroy_into_raw() {
9
+ const ptr = this.__wbg_ptr;
10
+ this.__wbg_ptr = 0;
11
+ OfficeDocumentFinalization.unregister(this);
12
+ return ptr;
13
+ }
14
+ free() {
15
+ const ptr = this.__destroy_into_raw();
16
+ wasm.__wbg_officedocument_free(ptr, 0);
17
+ }
18
+ /**
19
+ * @returns {string}
20
+ */
21
+ format() {
22
+ let deferred1_0;
23
+ let deferred1_1;
24
+ try {
25
+ const ret = wasm.officedocument_format(this.__wbg_ptr);
26
+ deferred1_0 = ret[0];
27
+ deferred1_1 = ret[1];
28
+ return getStringFromWasm0(ret[0], ret[1]);
29
+ } finally {
30
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
31
+ }
32
+ }
33
+ /**
34
+ * @param {Uint8Array} data
35
+ * @returns {OfficeDocument}
36
+ */
37
+ static fromBytes(data) {
38
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
39
+ const len0 = WASM_VECTOR_LEN;
40
+ const ret = wasm.officedocument_fromBytes(ptr0, len0);
41
+ if (ret[2]) {
42
+ throw takeFromExternrefTable0(ret[1]);
43
+ }
44
+ return OfficeDocument.__wrap(ret[0]);
45
+ }
46
+ /**
47
+ * @returns {string}
48
+ */
49
+ metadata() {
50
+ let deferred2_0;
51
+ let deferred2_1;
52
+ try {
53
+ const ret = wasm.officedocument_metadata(this.__wbg_ptr);
54
+ var ptr1 = ret[0];
55
+ var len1 = ret[1];
56
+ if (ret[3]) {
57
+ ptr1 = 0; len1 = 0;
58
+ throw takeFromExternrefTable0(ret[2]);
59
+ }
60
+ deferred2_0 = ptr1;
61
+ deferred2_1 = len1;
62
+ return getStringFromWasm0(ptr1, len1);
63
+ } finally {
64
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
65
+ }
66
+ }
67
+ /**
68
+ * @returns {string}
69
+ */
70
+ toJson() {
71
+ let deferred2_0;
72
+ let deferred2_1;
73
+ try {
74
+ const ret = wasm.officedocument_toJson(this.__wbg_ptr);
75
+ var ptr1 = ret[0];
76
+ var len1 = ret[1];
77
+ if (ret[3]) {
78
+ ptr1 = 0; len1 = 0;
79
+ throw takeFromExternrefTable0(ret[2]);
80
+ }
81
+ deferred2_0 = ptr1;
82
+ deferred2_1 = len1;
83
+ return getStringFromWasm0(ptr1, len1);
84
+ } finally {
85
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
86
+ }
87
+ }
88
+ /**
89
+ * @returns {string}
90
+ */
91
+ toMarkdown() {
92
+ let deferred2_0;
93
+ let deferred2_1;
94
+ try {
95
+ const ret = wasm.officedocument_toMarkdown(this.__wbg_ptr);
96
+ var ptr1 = ret[0];
97
+ var len1 = ret[1];
98
+ if (ret[3]) {
99
+ ptr1 = 0; len1 = 0;
100
+ throw takeFromExternrefTable0(ret[2]);
101
+ }
102
+ deferred2_0 = ptr1;
103
+ deferred2_1 = len1;
104
+ return getStringFromWasm0(ptr1, len1);
105
+ } finally {
106
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
107
+ }
108
+ }
109
+ /**
110
+ * @returns {string}
111
+ */
112
+ toText() {
113
+ let deferred2_0;
114
+ let deferred2_1;
115
+ try {
116
+ const ret = wasm.officedocument_toText(this.__wbg_ptr);
117
+ var ptr1 = ret[0];
118
+ var len1 = ret[1];
119
+ if (ret[3]) {
120
+ ptr1 = 0; len1 = 0;
121
+ throw takeFromExternrefTable0(ret[2]);
122
+ }
123
+ deferred2_0 = ptr1;
124
+ deferred2_1 = len1;
125
+ return getStringFromWasm0(ptr1, len1);
126
+ } finally {
127
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
128
+ }
129
+ }
130
+ }
131
+ if (Symbol.dispose) OfficeDocument.prototype[Symbol.dispose] = OfficeDocument.prototype.free;
132
+
133
+ /**
134
+ * @param {Uint8Array} data
135
+ * @returns {OfficeDocument}
136
+ */
137
+ export function parse(data) {
138
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
139
+ const len0 = WASM_VECTOR_LEN;
140
+ const ret = wasm.parse(ptr0, len0);
141
+ if (ret[2]) {
142
+ throw takeFromExternrefTable0(ret[1]);
143
+ }
144
+ return OfficeDocument.__wrap(ret[0]);
145
+ }
146
+ export function __wbg___wbindgen_throw_9c31b086c2b26051(arg0, arg1) {
147
+ throw new Error(getStringFromWasm0(arg0, arg1));
148
+ }
149
+ export function __wbindgen_cast_0000000000000001(arg0, arg1) {
150
+ // Cast intrinsic for `Ref(String) -> Externref`.
151
+ const ret = getStringFromWasm0(arg0, arg1);
152
+ return ret;
153
+ }
154
+ export function __wbindgen_init_externref_table() {
155
+ const table = wasm.__wbindgen_externrefs;
156
+ const offset = table.grow(4);
157
+ table.set(0, undefined);
158
+ table.set(offset + 0, undefined);
159
+ table.set(offset + 1, null);
160
+ table.set(offset + 2, true);
161
+ table.set(offset + 3, false);
162
+ }
163
+ const OfficeDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
164
+ ? { register: () => {}, unregister: () => {} }
165
+ : new FinalizationRegistry(ptr => wasm.__wbg_officedocument_free(ptr, 1));
166
+
167
+ function getStringFromWasm0(ptr, len) {
168
+ return decodeText(ptr >>> 0, len);
169
+ }
170
+
171
+ let cachedUint8ArrayMemory0 = null;
172
+ function getUint8ArrayMemory0() {
173
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
174
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
175
+ }
176
+ return cachedUint8ArrayMemory0;
177
+ }
178
+
179
+ function passArray8ToWasm0(arg, malloc) {
180
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
181
+ getUint8ArrayMemory0().set(arg, ptr / 1);
182
+ WASM_VECTOR_LEN = arg.length;
183
+ return ptr;
184
+ }
185
+
186
+ function takeFromExternrefTable0(idx) {
187
+ const value = wasm.__wbindgen_externrefs.get(idx);
188
+ wasm.__externref_table_dealloc(idx);
189
+ return value;
190
+ }
191
+
192
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
193
+ cachedTextDecoder.decode();
194
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
195
+ let numBytesDecoded = 0;
196
+ function decodeText(ptr, len) {
197
+ numBytesDecoded += len;
198
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
199
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
200
+ cachedTextDecoder.decode();
201
+ numBytesDecoded = len;
202
+ }
203
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
204
+ }
205
+
206
+ let WASM_VECTOR_LEN = 0;
207
+
208
+
209
+ let wasm;
210
+ export function __wbg_set_wasm(val) {
211
+ wasm = val;
212
+ }
Binary file