htmltoadf 0.1.6 → 0.1.7

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 CHANGED
@@ -28,23 +28,48 @@ https://wouterken.github.io/htmltoadf/
28
28
 
29
29
  ## CLI
30
30
  ### Binaries
31
+
32
+ The htmltoadf tool includes an html2adf binary.
33
+
34
+ #### Usage
35
+
36
+ ```bash
37
+ $ html2adf -h
38
+ ```
39
+
40
+ ```
41
+ htmltoadf 0.1.7
42
+ An HTML to Atlassian Document Format (ADF) converter
43
+
44
+ USAGE:
45
+ html2adf [OPTIONS] [INPATH]
46
+
47
+ ARGS:
48
+ <INPATH> The path to the file to read
49
+
50
+ OPTIONS:
51
+ -h, --help Print help information
52
+ -o, --outpath <OUTPATH>
53
+ -V, --version Print version information
54
+ ```
55
+
31
56
  ### Install Binary from Crates.io with `cargo install`
32
57
  ```
33
58
  $ cargo install htmltoadf
34
- installing htmltoadf v0.1.6 (/usr/src/html2adf)
59
+ installing htmltoadf v0.1.7 (/usr/src/html2adf)
35
60
  Updating crates.io index
36
61
  Downloading crates ...
37
62
  Downloaded lock_api v0.4.6
38
63
  --snip--
39
- Compiling htmltoadf v0.1.6
64
+ Compiling htmltoadf v0.1.7
40
65
  Finished release [optimized] target(s) in 1m 42s
41
66
  Installing ~/.cargo/bin/htmltoadf
42
- Installed package `htmltoadf v0.1.6` (executable `html2adf`)
67
+ Installed package `htmltoadf v0.1.7` (executable `html2adf`)
43
68
  ```
44
69
 
45
70
  ### Download Binary file from Github
46
71
  Pre-built binaries can be downloaded from here:
47
- https://github.com/wouterken/htmltoadf/releases/tag/0.1.6
72
+ https://github.com/wouterken/htmltoadf/releases/tag/0.1.7
48
73
 
49
74
  ### Docker Image
50
75
  **Docker Repo:**
@@ -54,10 +79,10 @@ https://hub.docker.com/r/wouterken/html2adf
54
79
  **Usage**
55
80
 
56
81
  ```bash
57
- $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.6
82
+ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.7
58
83
  {"version":1,"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"type":"text","text":"Hello world"},{"type":"text","text":"Test"}]}]}
59
84
 
60
- $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.6 | jq
85
+ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.7 | jq
61
86
  {
62
87
  "version": 1,
63
88
  "type": "doc",
@@ -90,7 +115,7 @@ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf
90
115
 
91
116
  ```toml
92
117
  [dependencies]
93
- htmltoadf = "0.1.6"
118
+ htmltoadf = "0.1.7"
94
119
  ```
95
120
 
96
121
  **Code**
@@ -143,6 +168,8 @@ cargo build --lib --release
143
168
 
144
169
  Then you can link to the library dynamic from any environment that supports a FFI.
145
170
  **It is important to copy the dynamic library from the release directory, and provide a relative link to the library file from the FFI**
171
+
172
+
146
173
  E.g.
147
174
 
148
175
  #### Ruby
package/htmltoadf.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {string} html
5
+ * @returns {string}
6
+ */
7
+ export function convert(html: string): string;
8
+
9
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
10
+
11
+ export interface InitOutput {
12
+ readonly memory: WebAssembly.Memory;
13
+ readonly convert: (a: number, b: number, c: number) => void;
14
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
15
+ readonly __wbindgen_malloc: (a: number) => number;
16
+ readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
17
+ readonly __wbindgen_free: (a: number, b: number) => void;
18
+ }
19
+
20
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
21
+ /**
22
+ * Instantiates the given `module`, which can either be bytes or
23
+ * a precompiled `WebAssembly.Module`.
24
+ *
25
+ * @param {SyncInitInput} module
26
+ *
27
+ * @returns {InitOutput}
28
+ */
29
+ export function initSync(module: SyncInitInput): InitOutput;
30
+
31
+ /**
32
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
33
+ * for everything else, calls `WebAssembly.instantiate` directly.
34
+ *
35
+ * @param {InitInput | Promise<InitInput>} module_or_path
36
+ *
37
+ * @returns {Promise<InitOutput>}
38
+ */
39
+ export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
package/htmltoadf.js CHANGED
@@ -1,25 +1,17 @@
1
-
2
1
  let wasm;
3
2
 
4
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
3
+ let WASM_VECTOR_LEN = 0;
5
4
 
6
- cachedTextDecoder.decode();
5
+ let cachedUint8Memory0 = null;
7
6
 
8
- let cachegetUint8Memory0 = null;
9
7
  function getUint8Memory0() {
10
- if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
11
- cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
8
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
9
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
12
10
  }
13
- return cachegetUint8Memory0;
11
+ return cachedUint8Memory0;
14
12
  }
15
13
 
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');
14
+ const cachedTextEncoder = new TextEncoder('utf-8');
23
15
 
24
16
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
25
17
  ? function (arg, view) {
@@ -36,8 +28,6 @@ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
36
28
 
37
29
  function passStringToWasm0(arg, malloc, realloc) {
38
30
 
39
- if (typeof(arg) !== 'string') throw new Error('expected a string argument');
40
-
41
31
  if (realloc === undefined) {
42
32
  const buf = cachedTextEncoder.encode(arg);
43
33
  const ptr = malloc(buf.length);
@@ -66,7 +56,7 @@ function passStringToWasm0(arg, malloc, realloc) {
66
56
  ptr = realloc(ptr, len, len = offset + arg.length * 3);
67
57
  const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
68
58
  const ret = encodeString(arg, view);
69
- if (ret.read !== arg.length) throw new Error('failed to pass whole string');
59
+
70
60
  offset += ret.written;
71
61
  }
72
62
 
@@ -74,12 +64,21 @@ function passStringToWasm0(arg, malloc, realloc) {
74
64
  return ptr;
75
65
  }
76
66
 
77
- let cachegetInt32Memory0 = null;
67
+ let cachedInt32Memory0 = null;
68
+
78
69
  function getInt32Memory0() {
79
- if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
80
- cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
70
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
71
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
81
72
  }
82
- return cachegetInt32Memory0;
73
+ return cachedInt32Memory0;
74
+ }
75
+
76
+ const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
77
+
78
+ cachedTextDecoder.decode();
79
+
80
+ function getStringFromWasm0(ptr, len) {
81
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
83
82
  }
84
83
  /**
85
84
  * @param {string} html
@@ -88,8 +87,8 @@ function getInt32Memory0() {
88
87
  export function convert(html) {
89
88
  try {
90
89
  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;
90
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
+ const len0 = WASM_VECTOR_LEN;
93
92
  wasm.convert(retptr, ptr0, len0);
94
93
  var r0 = getInt32Memory0()[retptr / 4 + 0];
95
94
  var r1 = getInt32Memory0()[retptr / 4 + 1];
@@ -131,29 +130,57 @@ async function load(module, imports) {
131
130
  }
132
131
  }
133
132
 
133
+ function getImports() {
134
+ const imports = {};
135
+ imports.wbg = {};
136
+
137
+ return imports;
138
+ }
139
+
140
+ function initMemory(imports, maybe_memory) {
141
+
142
+ }
143
+
144
+ function finalizeInit(instance, module) {
145
+ wasm = instance.exports;
146
+ init.__wbindgen_wasm_module = module;
147
+ cachedInt32Memory0 = null;
148
+ cachedUint8Memory0 = null;
149
+
150
+
151
+ return wasm;
152
+ }
153
+
154
+ function initSync(module) {
155
+ const imports = getImports();
156
+
157
+ initMemory(imports);
158
+
159
+ if (!(module instanceof WebAssembly.Module)) {
160
+ module = new WebAssembly.Module(module);
161
+ }
162
+
163
+ const instance = new WebAssembly.Instance(module, imports);
164
+
165
+ return finalizeInit(instance, module);
166
+ }
167
+
134
168
  async function init(input) {
135
169
  if (typeof input === 'undefined') {
136
170
  input = new URL('htmltoadf_bg.wasm', import.meta.url);
137
171
  }
138
- const imports = {};
139
- imports.wbg = {};
140
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
141
- throw new Error(getStringFromWasm0(arg0, arg1));
142
- };
172
+ const imports = getImports();
143
173
 
144
174
  if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
145
175
  input = fetch(input);
146
176
  }
147
177
 
148
-
178
+ initMemory(imports);
149
179
 
150
180
  const { instance, module } = await load(await input, imports);
151
181
 
152
- wasm = instance.exports;
153
- init.__wbindgen_wasm_module = module;
154
-
155
- return wasm;
182
+ return finalizeInit(instance, module);
156
183
  }
157
184
 
185
+ export { initSync }
158
186
  export default init;
159
-
package/htmltoadf_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "htmltoadf",
3
+ "collaborators": [
4
+ "Wouter Coppieters"
5
+ ],
3
6
  "description": "An HTML to Atlassian Document Format (ADF) converter",
4
- "version": "0.1.6",
7
+ "version": "0.1.7",
5
8
  "license": "MIT",
6
9
  "repository": {
7
10
  "type": "git",
@@ -9,10 +12,12 @@
9
12
  },
10
13
  "files": [
11
14
  "htmltoadf_bg.wasm",
12
- "htmltoadf.js"
15
+ "htmltoadf.js",
16
+ "htmltoadf.d.ts"
13
17
  ],
14
18
  "module": "htmltoadf.js",
15
19
  "homepage": "https://github.com/wouterken/htmltoadf",
20
+ "types": "htmltoadf.d.ts",
16
21
  "sideEffects": false,
17
22
  "keywords": [
18
23
  "html",