htmltoadf 0.1.9 → 0.1.11

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.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Wouter Coppieters
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
13
+ all 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
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -38,7 +38,7 @@ $ html2adf -h
38
38
  ```
39
39
 
40
40
  ```
41
- htmltoadf 0.1.9
41
+ htmltoadf 0.1.11
42
42
  An HTML to Atlassian Document Format (ADF) converter
43
43
 
44
44
  USAGE:
@@ -56,20 +56,20 @@ OPTIONS:
56
56
  ### Install Binary from Crates.io with `cargo install`
57
57
  ```
58
58
  $ cargo install htmltoadf
59
- installing htmltoadf v0.1.9 (/usr/src/html2adf)
59
+ installing htmltoadf v0.1.11 (/usr/src/html2adf)
60
60
  Updating crates.io index
61
61
  Downloading crates ...
62
62
  Downloaded lock_api v0.4.6
63
63
  --snip--
64
- Compiling htmltoadf v0.1.9
64
+ Compiling htmltoadf v0.1.11
65
65
  Finished release [optimized] target(s) in 1m 42s
66
66
  Installing ~/.cargo/bin/htmltoadf
67
- Installed package `htmltoadf v0.1.9` (executable `html2adf`)
67
+ Installed package `htmltoadf v0.1.11` (executable `html2adf`)
68
68
  ```
69
69
 
70
70
  ### Download Binary file from Github
71
71
  Pre-built binaries can be downloaded from here:
72
- https://github.com/wouterken/htmltoadf/releases/tag/0.1.9
72
+ https://github.com/wouterken/htmltoadf/releases/tag/0.1.11
73
73
 
74
74
  ### Docker Image
75
75
  **Docker Repo:**
@@ -79,10 +79,10 @@ https://hub.docker.com/r/wouterken/html2adf
79
79
  **Usage**
80
80
 
81
81
  ```bash
82
- $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.9
82
+ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.11
83
83
  {"version":1,"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"type":"text","text":"Hello world"},{"type":"text","text":"Test"}]}]}
84
84
 
85
- $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.9 | jq
85
+ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.11 | jq
86
86
  {
87
87
  "version": 1,
88
88
  "type": "doc",
@@ -115,7 +115,7 @@ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf
115
115
 
116
116
  ```toml
117
117
  [dependencies]
118
- htmltoadf = "0.1.9"
118
+ htmltoadf = "0.1.11"
119
119
  ```
120
120
 
121
121
  **Code**
@@ -225,8 +225,14 @@ The following features are implemented:
225
225
 
226
226
  ## Release Process
227
227
  * Increment version number in .toml and README
228
+ * Update docs/index.html package version if needed
229
+ * Run fmt, clippy, and tests
228
230
  * Compile binaries and create release
229
- * Build and push Docker image
231
+ * Requires: `cargo-zigbuild`, `cargo-xwin`, `zig`, and nightly toolchain
232
+ * `./release.sh`
233
+ * Or run `scripts/release_checklist.sh <version>` for local checks + amd64 Docker build
234
+ * Build and push Docker images
235
+ * Multi-arch via buildx: `docker buildx build --platform linux/amd64,linux/arm64 -t wouterken/html2adf:<version> -t wouterken/html2adf:latest --push .`
230
236
  * Build and push WASM NPM package
231
237
  * Push crate
232
238
  * Update dependency in demo page
package/htmltoadf.d.ts CHANGED
@@ -1,39 +1,38 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * @param {string} html
5
- * @returns {string}
6
- */
3
+
7
4
  export function convert(html: string): string;
8
5
 
9
6
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
10
7
 
11
8
  export interface InitOutput {
12
9
  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;
10
+ readonly convert: (a: number, b: number) => [number, number];
11
+ readonly __wbindgen_externrefs: WebAssembly.Table;
12
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
13
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
14
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
15
+ readonly __wbindgen_start: () => void;
18
16
  }
19
17
 
20
18
  export type SyncInitInput = BufferSource | WebAssembly.Module;
19
+
21
20
  /**
22
21
  * Instantiates the given `module`, which can either be bytes or
23
22
  * a precompiled `WebAssembly.Module`.
24
23
  *
25
- * @param {SyncInitInput} module
24
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
26
25
  *
27
26
  * @returns {InitOutput}
28
27
  */
29
- export function initSync(module: SyncInitInput): InitOutput;
28
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
30
29
 
31
30
  /**
32
31
  * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
33
32
  * for everything else, calls `WebAssembly.instantiate` directly.
34
33
  *
35
- * @param {InitInput | Promise<InitInput>} module_or_path
34
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
36
35
  *
37
36
  * @returns {Promise<InitOutput>}
38
37
  */
39
- export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
38
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/htmltoadf.js CHANGED
@@ -1,45 +1,31 @@
1
1
  let wasm;
2
2
 
3
- let WASM_VECTOR_LEN = 0;
4
-
5
- let cachedUint8Memory0 = null;
6
-
7
- function getUint8Memory0() {
8
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
9
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
10
- }
11
- return cachedUint8Memory0;
3
+ function getStringFromWasm0(ptr, len) {
4
+ ptr = ptr >>> 0;
5
+ return decodeText(ptr, len);
12
6
  }
13
7
 
14
- const cachedTextEncoder = new TextEncoder('utf-8');
15
-
16
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
17
- ? function (arg, view) {
18
- return cachedTextEncoder.encodeInto(arg, view);
8
+ let cachedUint8ArrayMemory0 = null;
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
19
14
  }
20
- : function (arg, view) {
21
- const buf = cachedTextEncoder.encode(arg);
22
- view.set(buf);
23
- return {
24
- read: arg.length,
25
- written: buf.length
26
- };
27
- });
28
15
 
29
16
  function passStringToWasm0(arg, malloc, realloc) {
30
-
31
17
  if (realloc === undefined) {
32
18
  const buf = cachedTextEncoder.encode(arg);
33
- const ptr = malloc(buf.length);
34
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
19
+ const ptr = malloc(buf.length, 1) >>> 0;
20
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
35
21
  WASM_VECTOR_LEN = buf.length;
36
22
  return ptr;
37
23
  }
38
24
 
39
25
  let len = arg.length;
40
- let ptr = malloc(len);
26
+ let ptr = malloc(len, 1) >>> 0;
41
27
 
42
- const mem = getUint8Memory0();
28
+ const mem = getUint8ArrayMemory0();
43
29
 
44
30
  let offset = 0;
45
31
 
@@ -48,66 +34,82 @@ function passStringToWasm0(arg, malloc, realloc) {
48
34
  if (code > 0x7F) break;
49
35
  mem[ptr + offset] = code;
50
36
  }
51
-
52
37
  if (offset !== len) {
53
38
  if (offset !== 0) {
54
39
  arg = arg.slice(offset);
55
40
  }
56
- ptr = realloc(ptr, len, len = offset + arg.length * 3);
57
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
58
- const ret = encodeString(arg, view);
41
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
42
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
43
+ const ret = cachedTextEncoder.encodeInto(arg, view);
59
44
 
60
45
  offset += ret.written;
46
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
61
47
  }
62
48
 
63
49
  WASM_VECTOR_LEN = offset;
64
50
  return ptr;
65
51
  }
66
52
 
67
- let cachedInt32Memory0 = null;
68
-
69
- function getInt32Memory0() {
70
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
71
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
53
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
54
+ cachedTextDecoder.decode();
55
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
56
+ let numBytesDecoded = 0;
57
+ function decodeText(ptr, len) {
58
+ numBytesDecoded += len;
59
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
60
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
61
+ cachedTextDecoder.decode();
62
+ numBytesDecoded = len;
72
63
  }
73
- return cachedInt32Memory0;
64
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
74
65
  }
75
66
 
76
- const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
67
+ const cachedTextEncoder = new TextEncoder();
77
68
 
78
- cachedTextDecoder.decode();
79
-
80
- function getStringFromWasm0(ptr, len) {
81
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
69
+ if (!('encodeInto' in cachedTextEncoder)) {
70
+ cachedTextEncoder.encodeInto = function (arg, view) {
71
+ const buf = cachedTextEncoder.encode(arg);
72
+ view.set(buf);
73
+ return {
74
+ read: arg.length,
75
+ written: buf.length
76
+ };
77
+ }
82
78
  }
79
+
80
+ let WASM_VECTOR_LEN = 0;
81
+
83
82
  /**
84
- * @param {string} html
85
- * @returns {string}
86
- */
83
+ * @param {string} html
84
+ * @returns {string}
85
+ */
87
86
  export function convert(html) {
87
+ let deferred2_0;
88
+ let deferred2_1;
88
89
  try {
89
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
90
90
  const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
91
  const len0 = WASM_VECTOR_LEN;
92
- wasm.convert(retptr, ptr0, len0);
93
- var r0 = getInt32Memory0()[retptr / 4 + 0];
94
- var r1 = getInt32Memory0()[retptr / 4 + 1];
95
- return getStringFromWasm0(r0, r1);
92
+ const ret = wasm.convert(ptr0, len0);
93
+ deferred2_0 = ret[0];
94
+ deferred2_1 = ret[1];
95
+ return getStringFromWasm0(ret[0], ret[1]);
96
96
  } finally {
97
- wasm.__wbindgen_add_to_stack_pointer(16);
98
- wasm.__wbindgen_free(r0, r1);
97
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
99
98
  }
100
99
  }
101
100
 
102
- async function load(module, imports) {
101
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
102
+
103
+ async function __wbg_load(module, imports) {
103
104
  if (typeof Response === 'function' && module instanceof Response) {
104
105
  if (typeof WebAssembly.instantiateStreaming === 'function') {
105
106
  try {
106
107
  return await WebAssembly.instantiateStreaming(module, imports);
107
-
108
108
  } catch (e) {
109
- if (module.headers.get('Content-Type') != 'application/wasm') {
110
- 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);
109
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
110
+
111
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
112
+ 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);
111
113
 
112
114
  } else {
113
115
  throw e;
@@ -117,70 +119,88 @@ async function load(module, imports) {
117
119
 
118
120
  const bytes = await module.arrayBuffer();
119
121
  return await WebAssembly.instantiate(bytes, imports);
120
-
121
122
  } else {
122
123
  const instance = await WebAssembly.instantiate(module, imports);
123
124
 
124
125
  if (instance instanceof WebAssembly.Instance) {
125
126
  return { instance, module };
126
-
127
127
  } else {
128
128
  return instance;
129
129
  }
130
130
  }
131
131
  }
132
132
 
133
- function getImports() {
133
+ function __wbg_get_imports() {
134
134
  const imports = {};
135
135
  imports.wbg = {};
136
+ imports.wbg.__wbindgen_init_externref_table = function() {
137
+ const table = wasm.__wbindgen_externrefs;
138
+ const offset = table.grow(4);
139
+ table.set(0, undefined);
140
+ table.set(offset + 0, undefined);
141
+ table.set(offset + 1, null);
142
+ table.set(offset + 2, true);
143
+ table.set(offset + 3, false);
144
+ };
136
145
 
137
146
  return imports;
138
147
  }
139
148
 
140
- function initMemory(imports, maybe_memory) {
141
-
142
- }
143
-
144
- function finalizeInit(instance, module) {
149
+ function __wbg_finalize_init(instance, module) {
145
150
  wasm = instance.exports;
146
- init.__wbindgen_wasm_module = module;
147
- cachedInt32Memory0 = null;
148
- cachedUint8Memory0 = null;
151
+ __wbg_init.__wbindgen_wasm_module = module;
152
+ cachedUint8ArrayMemory0 = null;
149
153
 
150
154
 
155
+ wasm.__wbindgen_start();
151
156
  return wasm;
152
157
  }
153
158
 
154
159
  function initSync(module) {
155
- const imports = getImports();
160
+ if (wasm !== undefined) return wasm;
161
+
156
162
 
157
- initMemory(imports);
163
+ if (typeof module !== 'undefined') {
164
+ if (Object.getPrototypeOf(module) === Object.prototype) {
165
+ ({module} = module)
166
+ } else {
167
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
168
+ }
169
+ }
158
170
 
171
+ const imports = __wbg_get_imports();
159
172
  if (!(module instanceof WebAssembly.Module)) {
160
173
  module = new WebAssembly.Module(module);
161
174
  }
162
-
163
175
  const instance = new WebAssembly.Instance(module, imports);
164
-
165
- return finalizeInit(instance, module);
176
+ return __wbg_finalize_init(instance, module);
166
177
  }
167
178
 
168
- async function init(input) {
169
- if (typeof input === 'undefined') {
170
- input = new URL('htmltoadf_bg.wasm', import.meta.url);
179
+ async function __wbg_init(module_or_path) {
180
+ if (wasm !== undefined) return wasm;
181
+
182
+
183
+ if (typeof module_or_path !== 'undefined') {
184
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
185
+ ({module_or_path} = module_or_path)
186
+ } else {
187
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
188
+ }
171
189
  }
172
- const imports = getImports();
173
190
 
174
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
175
- input = fetch(input);
191
+ if (typeof module_or_path === 'undefined') {
192
+ module_or_path = new URL('htmltoadf_bg.wasm', import.meta.url);
176
193
  }
194
+ const imports = __wbg_get_imports();
177
195
 
178
- initMemory(imports);
196
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
197
+ module_or_path = fetch(module_or_path);
198
+ }
179
199
 
180
- const { instance, module } = await load(await input, imports);
200
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
181
201
 
182
- return finalizeInit(instance, module);
202
+ return __wbg_finalize_init(instance, module);
183
203
  }
184
204
 
185
- export { initSync }
186
- export default init;
205
+ export { initSync };
206
+ export default __wbg_init;
package/htmltoadf_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "htmltoadf",
3
+ "type": "module",
3
4
  "collaborators": [
4
5
  "Wouter Coppieters"
5
6
  ],
6
7
  "description": "An HTML to Atlassian Document Format (ADF) converter",
7
- "version": "0.1.9",
8
+ "version": "0.1.11",
8
9
  "license": "MIT",
9
10
  "repository": {
10
11
  "type": "git",
@@ -15,7 +16,7 @@
15
16
  "htmltoadf.js",
16
17
  "htmltoadf.d.ts"
17
18
  ],
18
- "module": "htmltoadf.js",
19
+ "main": "htmltoadf.js",
19
20
  "homepage": "https://github.com/wouterken/htmltoadf",
20
21
  "types": "htmltoadf.d.ts",
21
22
  "sideEffects": [