@iyulab/unhwp 0.5.3 → 0.7.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/package.json +1 -1
- package/unhwp_wasm.d.ts +31 -0
- package/unhwp_wasm_bg.js +136 -0
- package/unhwp_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/unhwp_wasm.d.ts
CHANGED
|
@@ -11,6 +11,37 @@ export class HwpDocument {
|
|
|
11
11
|
paragraphCount(): number;
|
|
12
12
|
toJson(): string;
|
|
13
13
|
toText(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the document's embedded images as an array of [`HwpImage`],
|
|
16
|
+
* sorted by resource ID for deterministic ordering.
|
|
17
|
+
*/
|
|
18
|
+
toImages(): HwpImage[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class HwpImage {
|
|
22
|
+
private constructor();
|
|
23
|
+
free(): void;
|
|
24
|
+
[Symbol.dispose](): void;
|
|
25
|
+
/**
|
|
26
|
+
* Resource identifier (matches markdown image references).
|
|
27
|
+
*/
|
|
28
|
+
readonly id: string;
|
|
29
|
+
/**
|
|
30
|
+
* Raw image bytes (`Uint8Array` in JS).
|
|
31
|
+
*/
|
|
32
|
+
readonly bytes: Uint8Array;
|
|
33
|
+
/**
|
|
34
|
+
* Image bytes encoded as standard base64 (for `data:` URLs).
|
|
35
|
+
*/
|
|
36
|
+
readonly base64: string;
|
|
37
|
+
/**
|
|
38
|
+
* Original filename, if known.
|
|
39
|
+
*/
|
|
40
|
+
readonly filename: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* MIME type, if known.
|
|
43
|
+
*/
|
|
44
|
+
readonly mimeType: string | undefined;
|
|
14
45
|
}
|
|
15
46
|
|
|
16
47
|
export class ParseOptions {
|
package/unhwp_wasm_bg.js
CHANGED
|
@@ -9,6 +9,30 @@ function _assertClass(instance, klass) {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
13
|
+
ptr = ptr >>> 0;
|
|
14
|
+
const mem = getDataViewMemory0();
|
|
15
|
+
const result = [];
|
|
16
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
17
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
18
|
+
}
|
|
19
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
24
|
+
ptr = ptr >>> 0;
|
|
25
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let cachedDataViewMemory0 = null;
|
|
29
|
+
function getDataViewMemory0() {
|
|
30
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
31
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
32
|
+
}
|
|
33
|
+
return cachedDataViewMemory0;
|
|
34
|
+
}
|
|
35
|
+
|
|
12
36
|
function getStringFromWasm0(ptr, len) {
|
|
13
37
|
ptr = ptr >>> 0;
|
|
14
38
|
return decodeText(ptr, len);
|
|
@@ -55,6 +79,10 @@ const HwpDocumentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
55
79
|
? { register: () => {}, unregister: () => {} }
|
|
56
80
|
: new FinalizationRegistry(ptr => wasm.__wbg_hwpdocument_free(ptr >>> 0, 1));
|
|
57
81
|
|
|
82
|
+
const HwpImageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
83
|
+
? { register: () => {}, unregister: () => {} }
|
|
84
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_hwpimage_free(ptr >>> 0, 1));
|
|
85
|
+
|
|
58
86
|
const ParseOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
59
87
|
? { register: () => {}, unregister: () => {} }
|
|
60
88
|
: new FinalizationRegistry(ptr => wasm.__wbg_parseoptions_free(ptr >>> 0, 1));
|
|
@@ -161,9 +189,112 @@ export class HwpDocument {
|
|
|
161
189
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
162
190
|
}
|
|
163
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Returns the document's embedded images as an array of [`HwpImage`],
|
|
194
|
+
* sorted by resource ID for deterministic ordering.
|
|
195
|
+
* @returns {HwpImage[]}
|
|
196
|
+
*/
|
|
197
|
+
toImages() {
|
|
198
|
+
const ret = wasm.hwpdocument_toImages(this.__wbg_ptr);
|
|
199
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
200
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
201
|
+
return v1;
|
|
202
|
+
}
|
|
164
203
|
}
|
|
165
204
|
if (Symbol.dispose) HwpDocument.prototype[Symbol.dispose] = HwpDocument.prototype.free;
|
|
166
205
|
|
|
206
|
+
/**
|
|
207
|
+
* An embedded image extracted from a document.
|
|
208
|
+
*/
|
|
209
|
+
export class HwpImage {
|
|
210
|
+
static __wrap(ptr) {
|
|
211
|
+
ptr = ptr >>> 0;
|
|
212
|
+
const obj = Object.create(HwpImage.prototype);
|
|
213
|
+
obj.__wbg_ptr = ptr;
|
|
214
|
+
HwpImageFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
215
|
+
return obj;
|
|
216
|
+
}
|
|
217
|
+
__destroy_into_raw() {
|
|
218
|
+
const ptr = this.__wbg_ptr;
|
|
219
|
+
this.__wbg_ptr = 0;
|
|
220
|
+
HwpImageFinalization.unregister(this);
|
|
221
|
+
return ptr;
|
|
222
|
+
}
|
|
223
|
+
free() {
|
|
224
|
+
const ptr = this.__destroy_into_raw();
|
|
225
|
+
wasm.__wbg_hwpimage_free(ptr, 0);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Resource identifier (matches markdown image references).
|
|
229
|
+
* @returns {string}
|
|
230
|
+
*/
|
|
231
|
+
get id() {
|
|
232
|
+
let deferred1_0;
|
|
233
|
+
let deferred1_1;
|
|
234
|
+
try {
|
|
235
|
+
const ret = wasm.hwpimage_id(this.__wbg_ptr);
|
|
236
|
+
deferred1_0 = ret[0];
|
|
237
|
+
deferred1_1 = ret[1];
|
|
238
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
239
|
+
} finally {
|
|
240
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Raw image bytes (`Uint8Array` in JS).
|
|
245
|
+
* @returns {Uint8Array}
|
|
246
|
+
*/
|
|
247
|
+
get bytes() {
|
|
248
|
+
const ret = wasm.hwpimage_bytes(this.__wbg_ptr);
|
|
249
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
250
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
251
|
+
return v1;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Image bytes encoded as standard base64 (for `data:` URLs).
|
|
255
|
+
* @returns {string}
|
|
256
|
+
*/
|
|
257
|
+
get base64() {
|
|
258
|
+
let deferred1_0;
|
|
259
|
+
let deferred1_1;
|
|
260
|
+
try {
|
|
261
|
+
const ret = wasm.hwpimage_base64(this.__wbg_ptr);
|
|
262
|
+
deferred1_0 = ret[0];
|
|
263
|
+
deferred1_1 = ret[1];
|
|
264
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
265
|
+
} finally {
|
|
266
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Original filename, if known.
|
|
271
|
+
* @returns {string | undefined}
|
|
272
|
+
*/
|
|
273
|
+
get filename() {
|
|
274
|
+
const ret = wasm.hwpimage_filename(this.__wbg_ptr);
|
|
275
|
+
let v1;
|
|
276
|
+
if (ret[0] !== 0) {
|
|
277
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
278
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
279
|
+
}
|
|
280
|
+
return v1;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* MIME type, if known.
|
|
284
|
+
* @returns {string | undefined}
|
|
285
|
+
*/
|
|
286
|
+
get mimeType() {
|
|
287
|
+
const ret = wasm.hwpimage_mimeType(this.__wbg_ptr);
|
|
288
|
+
let v1;
|
|
289
|
+
if (ret[0] !== 0) {
|
|
290
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
291
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
292
|
+
}
|
|
293
|
+
return v1;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (Symbol.dispose) HwpImage.prototype[Symbol.dispose] = HwpImage.prototype.free;
|
|
297
|
+
|
|
167
298
|
export class ParseOptions {
|
|
168
299
|
static __wrap(ptr) {
|
|
169
300
|
ptr = ptr >>> 0;
|
|
@@ -242,6 +373,11 @@ export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
|
|
|
242
373
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
243
374
|
};
|
|
244
375
|
|
|
376
|
+
export function __wbg_hwpimage_new(arg0) {
|
|
377
|
+
const ret = HwpImage.__wrap(arg0);
|
|
378
|
+
return ret;
|
|
379
|
+
};
|
|
380
|
+
|
|
245
381
|
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
246
382
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
247
383
|
const ret = getStringFromWasm0(arg0, arg1);
|
package/unhwp_wasm_bg.wasm
CHANGED
|
Binary file
|