htmltoadf 0.1.2 → 0.1.3
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/README.md +4 -4
- package/htmltoadf.js +159 -2
- package/htmltoadf_bg.wasm +0 -0
- package/package.json +3 -4
- package/htmltoadf_bg.js +0 -109
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ The library can be used in several different ways:
|
|
|
18
18
|
|
|
19
19
|
```toml
|
|
20
20
|
[dependencies]
|
|
21
|
-
htmltoadf = "0.1.
|
|
21
|
+
htmltoadf = "0.1.3"
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## CLI
|
|
@@ -26,15 +26,15 @@ htmltoadf = "0.1.2"
|
|
|
26
26
|
### Install Binary from Crates.io with `cargo install`
|
|
27
27
|
```
|
|
28
28
|
$ cargo install htmltoadf
|
|
29
|
-
installing htmltoadf v0.1.
|
|
29
|
+
installing htmltoadf v0.1.3 (/usr/src/html2adf)
|
|
30
30
|
Updating crates.io index
|
|
31
31
|
Downloading crates ...
|
|
32
32
|
Downloaded lock_api v0.4.6
|
|
33
33
|
--snip--
|
|
34
|
-
Compiling htmltoadf v0.1.
|
|
34
|
+
Compiling htmltoadf v0.1.3
|
|
35
35
|
Finished release [optimized] target(s) in 1m 42s
|
|
36
36
|
Installing ~/.cargo/bin/htmltoadf
|
|
37
|
-
Installed package `htmltoadf v0.1.
|
|
37
|
+
Installed package `htmltoadf v0.1.3` (executable `html2adf`)
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
### Download Binary file from Github
|
package/htmltoadf.js
CHANGED
|
@@ -1,2 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
let wasm;
|
|
3
|
+
|
|
4
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
5
|
+
|
|
6
|
+
cachedTextDecoder.decode();
|
|
7
|
+
|
|
8
|
+
let cachegetUint8Memory0 = null;
|
|
9
|
+
function getUint8Memory0() {
|
|
10
|
+
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
|
11
|
+
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
12
|
+
}
|
|
13
|
+
return cachegetUint8Memory0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getStringFromWasm0(ptr, len) {
|
|
17
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let WASM_VECTOR_LEN = 0;
|
|
21
|
+
|
|
22
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
23
|
+
|
|
24
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
25
|
+
? function (arg, view) {
|
|
26
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
27
|
+
}
|
|
28
|
+
: function (arg, view) {
|
|
29
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
30
|
+
view.set(buf);
|
|
31
|
+
return {
|
|
32
|
+
read: arg.length,
|
|
33
|
+
written: buf.length
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
38
|
+
|
|
39
|
+
if (typeof(arg) !== 'string') throw new Error('expected a string argument');
|
|
40
|
+
|
|
41
|
+
if (realloc === undefined) {
|
|
42
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
43
|
+
const ptr = malloc(buf.length);
|
|
44
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
45
|
+
WASM_VECTOR_LEN = buf.length;
|
|
46
|
+
return ptr;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let len = arg.length;
|
|
50
|
+
let ptr = malloc(len);
|
|
51
|
+
|
|
52
|
+
const mem = getUint8Memory0();
|
|
53
|
+
|
|
54
|
+
let offset = 0;
|
|
55
|
+
|
|
56
|
+
for (; offset < len; offset++) {
|
|
57
|
+
const code = arg.charCodeAt(offset);
|
|
58
|
+
if (code > 0x7F) break;
|
|
59
|
+
mem[ptr + offset] = code;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (offset !== len) {
|
|
63
|
+
if (offset !== 0) {
|
|
64
|
+
arg = arg.slice(offset);
|
|
65
|
+
}
|
|
66
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
|
67
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
68
|
+
const ret = encodeString(arg, view);
|
|
69
|
+
if (ret.read !== arg.length) throw new Error('failed to pass whole string');
|
|
70
|
+
offset += ret.written;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
WASM_VECTOR_LEN = offset;
|
|
74
|
+
return ptr;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
let cachegetInt32Memory0 = null;
|
|
78
|
+
function getInt32Memory0() {
|
|
79
|
+
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
80
|
+
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
81
|
+
}
|
|
82
|
+
return cachegetInt32Memory0;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @param {string} html
|
|
86
|
+
* @returns {string}
|
|
87
|
+
*/
|
|
88
|
+
export function convert(html) {
|
|
89
|
+
try {
|
|
90
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
91
|
+
var ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
92
|
+
var len0 = WASM_VECTOR_LEN;
|
|
93
|
+
wasm.convert(retptr, ptr0, len0);
|
|
94
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
95
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
96
|
+
return getStringFromWasm0(r0, r1);
|
|
97
|
+
} finally {
|
|
98
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
99
|
+
wasm.__wbindgen_free(r0, r1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function load(module, imports) {
|
|
104
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
105
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
106
|
+
try {
|
|
107
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
108
|
+
|
|
109
|
+
} catch (e) {
|
|
110
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
111
|
+
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);
|
|
112
|
+
|
|
113
|
+
} else {
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const bytes = await module.arrayBuffer();
|
|
120
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
121
|
+
|
|
122
|
+
} else {
|
|
123
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
124
|
+
|
|
125
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
126
|
+
return { instance, module };
|
|
127
|
+
|
|
128
|
+
} else {
|
|
129
|
+
return instance;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function init(input) {
|
|
135
|
+
if (typeof input === 'undefined') {
|
|
136
|
+
input = new URL('htmltoadf_bg.wasm', import.meta.url);
|
|
137
|
+
}
|
|
138
|
+
const imports = {};
|
|
139
|
+
imports.wbg = {};
|
|
140
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
141
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
145
|
+
input = fetch(input);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
const { instance, module } = await load(await input, imports);
|
|
151
|
+
|
|
152
|
+
wasm = instance.exports;
|
|
153
|
+
init.__wbindgen_wasm_module = module;
|
|
154
|
+
|
|
155
|
+
return wasm;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export default init;
|
|
159
|
+
|
package/htmltoadf_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "htmltoadf",
|
|
3
3
|
"description": "An HTML to Atlassian Document Format (ADF) converter",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"htmltoadf_bg.wasm",
|
|
12
|
-
"htmltoadf.js"
|
|
13
|
-
"htmltoadf_bg.js"
|
|
12
|
+
"htmltoadf.js"
|
|
14
13
|
],
|
|
15
14
|
"module": "htmltoadf.js",
|
|
16
15
|
"homepage": "https://github.com/wouterken/htmltoadf",
|
|
@@ -22,4 +21,4 @@
|
|
|
22
21
|
"converter",
|
|
23
22
|
"cli"
|
|
24
23
|
]
|
|
25
|
-
}
|
|
24
|
+
}
|
package/htmltoadf_bg.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import * as wasm from './htmltoadf_bg.wasm';
|
|
2
|
-
|
|
3
|
-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
4
|
-
|
|
5
|
-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
6
|
-
|
|
7
|
-
cachedTextDecoder.decode();
|
|
8
|
-
|
|
9
|
-
let cachegetUint8Memory0 = null;
|
|
10
|
-
function getUint8Memory0() {
|
|
11
|
-
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
|
12
|
-
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
13
|
-
}
|
|
14
|
-
return cachegetUint8Memory0;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getStringFromWasm0(ptr, len) {
|
|
18
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
let WASM_VECTOR_LEN = 0;
|
|
22
|
-
|
|
23
|
-
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
24
|
-
|
|
25
|
-
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
26
|
-
|
|
27
|
-
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
28
|
-
? function (arg, view) {
|
|
29
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
30
|
-
}
|
|
31
|
-
: function (arg, view) {
|
|
32
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
33
|
-
view.set(buf);
|
|
34
|
-
return {
|
|
35
|
-
read: arg.length,
|
|
36
|
-
written: buf.length
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
41
|
-
|
|
42
|
-
if (typeof(arg) !== 'string') throw new Error('expected a string argument');
|
|
43
|
-
|
|
44
|
-
if (realloc === undefined) {
|
|
45
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
46
|
-
const ptr = malloc(buf.length);
|
|
47
|
-
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
48
|
-
WASM_VECTOR_LEN = buf.length;
|
|
49
|
-
return ptr;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
let len = arg.length;
|
|
53
|
-
let ptr = malloc(len);
|
|
54
|
-
|
|
55
|
-
const mem = getUint8Memory0();
|
|
56
|
-
|
|
57
|
-
let offset = 0;
|
|
58
|
-
|
|
59
|
-
for (; offset < len; offset++) {
|
|
60
|
-
const code = arg.charCodeAt(offset);
|
|
61
|
-
if (code > 0x7F) break;
|
|
62
|
-
mem[ptr + offset] = code;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (offset !== len) {
|
|
66
|
-
if (offset !== 0) {
|
|
67
|
-
arg = arg.slice(offset);
|
|
68
|
-
}
|
|
69
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
|
70
|
-
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
71
|
-
const ret = encodeString(arg, view);
|
|
72
|
-
if (ret.read !== arg.length) throw new Error('failed to pass whole string');
|
|
73
|
-
offset += ret.written;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
WASM_VECTOR_LEN = offset;
|
|
77
|
-
return ptr;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
let cachegetInt32Memory0 = null;
|
|
81
|
-
function getInt32Memory0() {
|
|
82
|
-
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
83
|
-
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
84
|
-
}
|
|
85
|
-
return cachegetInt32Memory0;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @param {string} html
|
|
89
|
-
* @returns {string}
|
|
90
|
-
*/
|
|
91
|
-
export function convert(html) {
|
|
92
|
-
try {
|
|
93
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
94
|
-
var ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
95
|
-
var len0 = WASM_VECTOR_LEN;
|
|
96
|
-
wasm.convert(retptr, ptr0, len0);
|
|
97
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
98
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
99
|
-
return getStringFromWasm0(r0, r1);
|
|
100
|
-
} finally {
|
|
101
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
102
|
-
wasm.__wbindgen_free(r0, r1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function __wbindgen_throw(arg0, arg1) {
|
|
107
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
108
|
-
};
|
|
109
|
-
|