@kerebron/odt-wasm 0.6.0 → 0.6.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/lib/odt_parser.d.ts +22 -0
- package/lib/odt_parser.internal.js +406 -0
- package/lib/odt_parser.js +12 -0
- package/package.json +4 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @generated file from wasmbuild -- do not edit
|
|
2
|
+
// deno-lint-ignore-file
|
|
3
|
+
// deno-fmt-ignore-file
|
|
4
|
+
|
|
5
|
+
export class Greeter {
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
constructor(name: string);
|
|
9
|
+
greet(): string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function add(a: number, b: number): number;
|
|
13
|
+
|
|
14
|
+
export function echo(zip_data: Uint8Array): Uint8Array;
|
|
15
|
+
|
|
16
|
+
export function init_debug(): void;
|
|
17
|
+
|
|
18
|
+
export function parse_content(xml_bytes: Uint8Array): any;
|
|
19
|
+
|
|
20
|
+
export function parse_styles(xml_bytes: Uint8Array): any;
|
|
21
|
+
|
|
22
|
+
export function unzip(zip_data: Uint8Array): any;
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
// @generated file from wasmbuild -- do not edit
|
|
2
|
+
// @ts-nocheck: generated
|
|
3
|
+
// deno-lint-ignore-file
|
|
4
|
+
// deno-fmt-ignore-file
|
|
5
|
+
|
|
6
|
+
let wasm;
|
|
7
|
+
export function __wbg_set_wasm(val) {
|
|
8
|
+
wasm = val;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function debugString(val) {
|
|
12
|
+
// primitive types
|
|
13
|
+
const type = typeof val;
|
|
14
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
15
|
+
return `${val}`;
|
|
16
|
+
}
|
|
17
|
+
if (type == 'string') {
|
|
18
|
+
return `"${val}"`;
|
|
19
|
+
}
|
|
20
|
+
if (type == 'symbol') {
|
|
21
|
+
const description = val.description;
|
|
22
|
+
if (description == null) {
|
|
23
|
+
return 'Symbol';
|
|
24
|
+
} else {
|
|
25
|
+
return `Symbol(${description})`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (type == 'function') {
|
|
29
|
+
const name = val.name;
|
|
30
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
31
|
+
return `Function(${name})`;
|
|
32
|
+
} else {
|
|
33
|
+
return 'Function';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// objects
|
|
37
|
+
if (Array.isArray(val)) {
|
|
38
|
+
const length = val.length;
|
|
39
|
+
let debug = '[';
|
|
40
|
+
if (length > 0) {
|
|
41
|
+
debug += debugString(val[0]);
|
|
42
|
+
}
|
|
43
|
+
for (let i = 1; i < length; i++) {
|
|
44
|
+
debug += ', ' + debugString(val[i]);
|
|
45
|
+
}
|
|
46
|
+
debug += ']';
|
|
47
|
+
return debug;
|
|
48
|
+
}
|
|
49
|
+
// Test for built-in
|
|
50
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
51
|
+
let className;
|
|
52
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
53
|
+
className = builtInMatches[1];
|
|
54
|
+
} else {
|
|
55
|
+
// Failed to match the standard '[object ClassName]'
|
|
56
|
+
return toString.call(val);
|
|
57
|
+
}
|
|
58
|
+
if (className == 'Object') {
|
|
59
|
+
// we're a user defined class or Object
|
|
60
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
61
|
+
// easier than looping through ownProperties of `val`.
|
|
62
|
+
try {
|
|
63
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
64
|
+
} catch (_) {
|
|
65
|
+
return 'Object';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// errors
|
|
69
|
+
if (val instanceof Error) {
|
|
70
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
71
|
+
}
|
|
72
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
73
|
+
return className;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
77
|
+
ptr = ptr >>> 0;
|
|
78
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let cachedDataViewMemory0 = null;
|
|
82
|
+
function getDataViewMemory0() {
|
|
83
|
+
if (
|
|
84
|
+
cachedDataViewMemory0 === null ||
|
|
85
|
+
cachedDataViewMemory0.buffer.detached === true ||
|
|
86
|
+
(cachedDataViewMemory0.buffer.detached === undefined &&
|
|
87
|
+
cachedDataViewMemory0.buffer !== wasm.memory.buffer)
|
|
88
|
+
) {
|
|
89
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
90
|
+
}
|
|
91
|
+
return cachedDataViewMemory0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getStringFromWasm0(ptr, len) {
|
|
95
|
+
ptr = ptr >>> 0;
|
|
96
|
+
return decodeText(ptr, len);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let cachedUint8ArrayMemory0 = null;
|
|
100
|
+
function getUint8ArrayMemory0() {
|
|
101
|
+
if (
|
|
102
|
+
cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0
|
|
103
|
+
) {
|
|
104
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
105
|
+
}
|
|
106
|
+
return cachedUint8ArrayMemory0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
110
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
111
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
112
|
+
WASM_VECTOR_LEN = arg.length;
|
|
113
|
+
return ptr;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
117
|
+
if (realloc === undefined) {
|
|
118
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
119
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
120
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
121
|
+
WASM_VECTOR_LEN = buf.length;
|
|
122
|
+
return ptr;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let len = arg.length;
|
|
126
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
127
|
+
|
|
128
|
+
const mem = getUint8ArrayMemory0();
|
|
129
|
+
|
|
130
|
+
let offset = 0;
|
|
131
|
+
|
|
132
|
+
for (; offset < len; offset++) {
|
|
133
|
+
const code = arg.charCodeAt(offset);
|
|
134
|
+
if (code > 0x7F) break;
|
|
135
|
+
mem[ptr + offset] = code;
|
|
136
|
+
}
|
|
137
|
+
if (offset !== len) {
|
|
138
|
+
if (offset !== 0) {
|
|
139
|
+
arg = arg.slice(offset);
|
|
140
|
+
}
|
|
141
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
142
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
143
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
144
|
+
|
|
145
|
+
offset += ret.written;
|
|
146
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
WASM_VECTOR_LEN = offset;
|
|
150
|
+
return ptr;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let cachedTextDecoder = new TextDecoder('utf-8', {
|
|
154
|
+
ignoreBOM: true,
|
|
155
|
+
fatal: true,
|
|
156
|
+
});
|
|
157
|
+
cachedTextDecoder.decode();
|
|
158
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
159
|
+
let numBytesDecoded = 0;
|
|
160
|
+
function decodeText(ptr, len) {
|
|
161
|
+
numBytesDecoded += len;
|
|
162
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
163
|
+
cachedTextDecoder = new TextDecoder('utf-8', {
|
|
164
|
+
ignoreBOM: true,
|
|
165
|
+
fatal: true,
|
|
166
|
+
});
|
|
167
|
+
cachedTextDecoder.decode();
|
|
168
|
+
numBytesDecoded = len;
|
|
169
|
+
}
|
|
170
|
+
return cachedTextDecoder.decode(
|
|
171
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + len),
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const cachedTextEncoder = new TextEncoder();
|
|
176
|
+
|
|
177
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
178
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
179
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
180
|
+
view.set(buf);
|
|
181
|
+
return {
|
|
182
|
+
read: arg.length,
|
|
183
|
+
written: buf.length,
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let WASM_VECTOR_LEN = 0;
|
|
189
|
+
|
|
190
|
+
const GreeterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
191
|
+
? { register: () => {}, unregister: () => {} }
|
|
192
|
+
: new FinalizationRegistry((ptr) => wasm.__wbg_greeter_free(ptr >>> 0, 1));
|
|
193
|
+
|
|
194
|
+
export class Greeter {
|
|
195
|
+
__destroy_into_raw() {
|
|
196
|
+
const ptr = this.__wbg_ptr;
|
|
197
|
+
this.__wbg_ptr = 0;
|
|
198
|
+
GreeterFinalization.unregister(this);
|
|
199
|
+
return ptr;
|
|
200
|
+
}
|
|
201
|
+
free() {
|
|
202
|
+
const ptr = this.__destroy_into_raw();
|
|
203
|
+
wasm.__wbg_greeter_free(ptr, 0);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* @param {string} name
|
|
207
|
+
*/
|
|
208
|
+
constructor(name) {
|
|
209
|
+
const ptr0 = passStringToWasm0(
|
|
210
|
+
name,
|
|
211
|
+
wasm.__wbindgen_malloc,
|
|
212
|
+
wasm.__wbindgen_realloc,
|
|
213
|
+
);
|
|
214
|
+
const len0 = WASM_VECTOR_LEN;
|
|
215
|
+
const ret = wasm.greeter_new(ptr0, len0);
|
|
216
|
+
this.__wbg_ptr = ret >>> 0;
|
|
217
|
+
GreeterFinalization.register(this, this.__wbg_ptr, this);
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* @returns {string}
|
|
222
|
+
*/
|
|
223
|
+
greet() {
|
|
224
|
+
let deferred1_0;
|
|
225
|
+
let deferred1_1;
|
|
226
|
+
try {
|
|
227
|
+
const ret = wasm.greeter_greet(this.__wbg_ptr);
|
|
228
|
+
deferred1_0 = ret[0];
|
|
229
|
+
deferred1_1 = ret[1];
|
|
230
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
231
|
+
} finally {
|
|
232
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (Symbol.dispose) Greeter.prototype[Symbol.dispose] = Greeter.prototype.free;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @param {number} a
|
|
240
|
+
* @param {number} b
|
|
241
|
+
* @returns {number}
|
|
242
|
+
*/
|
|
243
|
+
export function add(a, b) {
|
|
244
|
+
const ret = wasm.add(a, b);
|
|
245
|
+
return ret;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @param {Uint8Array} zip_data
|
|
250
|
+
* @returns {Uint8Array}
|
|
251
|
+
*/
|
|
252
|
+
export function echo(zip_data) {
|
|
253
|
+
const ptr0 = passArray8ToWasm0(zip_data, wasm.__wbindgen_malloc);
|
|
254
|
+
const len0 = WASM_VECTOR_LEN;
|
|
255
|
+
const ret = wasm.echo(ptr0, len0);
|
|
256
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
257
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
258
|
+
return v2;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function init_debug() {
|
|
262
|
+
wasm.init_debug();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* @param {Uint8Array} xml_bytes
|
|
267
|
+
* @returns {any}
|
|
268
|
+
*/
|
|
269
|
+
export function parse_content(xml_bytes) {
|
|
270
|
+
const ptr0 = passArray8ToWasm0(xml_bytes, wasm.__wbindgen_malloc);
|
|
271
|
+
const len0 = WASM_VECTOR_LEN;
|
|
272
|
+
const ret = wasm.parse_content(ptr0, len0);
|
|
273
|
+
return ret;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @param {Uint8Array} xml_bytes
|
|
278
|
+
* @returns {any}
|
|
279
|
+
*/
|
|
280
|
+
export function parse_styles(xml_bytes) {
|
|
281
|
+
const ptr0 = passArray8ToWasm0(xml_bytes, wasm.__wbindgen_malloc);
|
|
282
|
+
const len0 = WASM_VECTOR_LEN;
|
|
283
|
+
const ret = wasm.parse_styles(ptr0, len0);
|
|
284
|
+
return ret;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* @param {Uint8Array} zip_data
|
|
289
|
+
* @returns {any}
|
|
290
|
+
*/
|
|
291
|
+
export function unzip(zip_data) {
|
|
292
|
+
const ptr0 = passArray8ToWasm0(zip_data, wasm.__wbindgen_malloc);
|
|
293
|
+
const len0 = WASM_VECTOR_LEN;
|
|
294
|
+
const ret = wasm.unzip(ptr0, len0);
|
|
295
|
+
return ret;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function __wbg_Error_52673b7de5a0ca89(arg0, arg1) {
|
|
299
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
300
|
+
return ret;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export function __wbg_Number_2d1dcfcf4ec51736(arg0) {
|
|
304
|
+
const ret = Number(arg0);
|
|
305
|
+
return ret;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function __wbg___wbindgen_debug_string_adfb662ae34724b6(arg0, arg1) {
|
|
309
|
+
const ret = debugString(arg1);
|
|
310
|
+
const ptr1 = passStringToWasm0(
|
|
311
|
+
ret,
|
|
312
|
+
wasm.__wbindgen_malloc,
|
|
313
|
+
wasm.__wbindgen_realloc,
|
|
314
|
+
);
|
|
315
|
+
const len1 = WASM_VECTOR_LEN;
|
|
316
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
317
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export function __wbg___wbindgen_is_string_704ef9c8fc131030(arg0) {
|
|
321
|
+
const ret = typeof arg0 === 'string';
|
|
322
|
+
return ret;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
|
|
326
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
|
|
330
|
+
let deferred0_0;
|
|
331
|
+
let deferred0_1;
|
|
332
|
+
try {
|
|
333
|
+
deferred0_0 = arg0;
|
|
334
|
+
deferred0_1 = arg1;
|
|
335
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
336
|
+
} finally {
|
|
337
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function __wbg_new_1ba21ce319a06297() {
|
|
342
|
+
const ret = new Object();
|
|
343
|
+
return ret;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export function __wbg_new_25f239778d6112b9() {
|
|
347
|
+
const ret = new Array();
|
|
348
|
+
return ret;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export function __wbg_new_8a6f238a6ece86ea() {
|
|
352
|
+
const ret = new Error();
|
|
353
|
+
return ret;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export function __wbg_new_b546ae120718850e() {
|
|
357
|
+
const ret = new Map();
|
|
358
|
+
return ret;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
|
|
362
|
+
arg0[arg1] = arg2;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export function __wbg_set_7df433eea03a5c14(arg0, arg1, arg2) {
|
|
366
|
+
arg0[arg1 >>> 0] = arg2;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export function __wbg_set_efaaf145b9377369(arg0, arg1, arg2) {
|
|
370
|
+
const ret = arg0.set(arg1, arg2);
|
|
371
|
+
return ret;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
|
|
375
|
+
const ret = arg1.stack;
|
|
376
|
+
const ptr1 = passStringToWasm0(
|
|
377
|
+
ret,
|
|
378
|
+
wasm.__wbindgen_malloc,
|
|
379
|
+
wasm.__wbindgen_realloc,
|
|
380
|
+
);
|
|
381
|
+
const len1 = WASM_VECTOR_LEN;
|
|
382
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
383
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
387
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
388
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
389
|
+
return ret;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
|
|
393
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
394
|
+
const ret = arg0;
|
|
395
|
+
return ret;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export function __wbindgen_init_externref_table() {
|
|
399
|
+
const table = wasm.__wbindgen_externrefs;
|
|
400
|
+
const offset = table.grow(4);
|
|
401
|
+
table.set(0, undefined);
|
|
402
|
+
table.set(offset + 0, undefined);
|
|
403
|
+
table.set(offset + 1, null);
|
|
404
|
+
table.set(offset + 2, true);
|
|
405
|
+
table.set(offset + 3, false);
|
|
406
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @generated file from wasmbuild -- do not edit
|
|
2
|
+
// @ts-nocheck: generated
|
|
3
|
+
// deno-lint-ignore-file
|
|
4
|
+
// deno-fmt-ignore-file
|
|
5
|
+
// @ts-self-types="./odt_parser.d.ts"
|
|
6
|
+
|
|
7
|
+
// source-hash: 13e2de63a051c61bc674ce525885b274d9a919e1
|
|
8
|
+
import * as wasm from "./odt_parser.wasm";
|
|
9
|
+
export * from "./odt_parser.internal.js";
|
|
10
|
+
import { __wbg_set_wasm } from "./odt_parser.internal.js";
|
|
11
|
+
__wbg_set_wasm(wasm);
|
|
12
|
+
wasm.__wbindgen_start();
|
package/package.json
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"main": "./lib.js",
|
|
5
5
|
"files": [
|
|
6
|
+
"lib/odt_parser.d.ts",
|
|
7
|
+
"lib/odt_parser.js",
|
|
8
|
+
"lib/odt_parser.internal.js",
|
|
6
9
|
"lib.js"
|
|
7
10
|
],
|
|
8
11
|
"exports": {
|
|
@@ -10,6 +13,6 @@
|
|
|
10
13
|
"import": "./lib.js"
|
|
11
14
|
}
|
|
12
15
|
},
|
|
13
|
-
"version": "0.6.
|
|
16
|
+
"version": "0.6.2",
|
|
14
17
|
"license": "MIT"
|
|
15
18
|
}
|