@markup-carve/carve-wasm 0.1.0 → 0.1.1
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 +28 -0
- package/carve_wasm.d.ts +22 -0
- package/carve_wasm.js +1 -1
- package/carve_wasm_bg.js +205 -1
- package/carve_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,10 @@ import policy and canonical writer as carve-rs. Modes are `safe` (default),
|
|
|
27
27
|
const { value, report } = htmlToCarve('<p>Hello <strong>world</strong></p>', 'safe')
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
Portable migration code can use `fromHtml(html, mode)` and
|
|
31
|
+
`fromMarkdown(markdown)`. Both return `{ value, report }`; Markdown carries an
|
|
32
|
+
empty diagnostics list because the engine migrates the document whole.
|
|
33
|
+
|
|
30
34
|
### Core renderer
|
|
31
35
|
|
|
32
36
|
Renders Carve markup to HTML with no extensions enabled.
|
|
@@ -38,6 +42,8 @@ call.
|
|
|
38
42
|
```js
|
|
39
43
|
import { toHtml } from '@markup-carve/carve-wasm'
|
|
40
44
|
|
|
45
|
+
// The other core targets are toMarkdown, toPlainText, toAnsi, and toCarve.
|
|
46
|
+
|
|
41
47
|
const html = toHtml('# Hello, Carve!')
|
|
42
48
|
document.body.innerHTML = html
|
|
43
49
|
```
|
|
@@ -168,6 +174,11 @@ const html: string = toHtml('_Hello_')
|
|
|
168
174
|
| `toHtmlWithSymbols` | `(source: string, symbols?: object \| null) => string` | Core renderer + a `:name:` -> value symbols map (values are raw, see above) |
|
|
169
175
|
| `toHtmlFull` | `(source: string, symbols?: object \| null) => string` | Core + common extensions (matches playground), optional symbols map |
|
|
170
176
|
| `toHtmlWithOptions` | `(source: string, options?: object \| null) => string` | General form: `{ sections?, symbols?, full? }`, every field optional |
|
|
177
|
+
| `toHtmlWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | HTML plus bounded `raw-format-dropped` losses; strict mode throws `RenderLossError` |
|
|
178
|
+
| `toMarkdownWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked Markdown render |
|
|
179
|
+
| `toPlainTextWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked plain-text render |
|
|
180
|
+
| `toAnsiWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked ANSI render |
|
|
181
|
+
| `toCarveWithReport` | `(source: string, strict?: boolean, maximum?: number) => RenderResult` | Checked canonical Carve render (lossless) |
|
|
171
182
|
| `parseJson` | `(source: string) => string` | The parsed AST as JSON (PART 12 exchange shape) |
|
|
172
183
|
| `version` | `() => string` | Returns the carve-wasm package version |
|
|
173
184
|
|
|
@@ -232,6 +243,23 @@ cargo test && wasm-pack build --target nodejs && node tests/smoke.mjs
|
|
|
232
243
|
CARVE_SPEC_CORPUS=/path/to/carve/tests/corpus node tests/corpus.mjs
|
|
233
244
|
```
|
|
234
245
|
|
|
246
|
+
`scripts/check-engine-floor.py` is what notices a pin left behind. CI runs it
|
|
247
|
+
against the revision carve-rb embeds:
|
|
248
|
+
|
|
249
|
+
```sh
|
|
250
|
+
python3 scripts/check-engine-floor.py \
|
|
251
|
+
--engine <carve-rs checkout> --manifest Cargo.toml --lock Cargo.lock \
|
|
252
|
+
--sibling-name carve-rb --sibling-manifest <carve-rb>/ext/carve/Cargo.toml \
|
|
253
|
+
--changelog CHANGELOG.md
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
It fails when this pin is a strict ancestor of the sibling's, and it also fails
|
|
257
|
+
when the `[Unreleased]` changelog section names a revision the build does not
|
|
258
|
+
embed - a revision quoted in prose is a second copy of the pin, and the second
|
|
259
|
+
copy is the one nothing else reads. A floor rather than a leash: it is
|
|
260
|
+
deliberately not a distance check against carve-rs `main`, which merges
|
|
261
|
+
continuously and would be red from the moment any pull request opens there.
|
|
262
|
+
|
|
235
263
|
That last line is the one that can tell a drifted pin from a current one.
|
|
236
264
|
`smoke.mjs` asserts hand-written expectations, which a stale engine satisfies
|
|
237
265
|
happily; `corpus.mjs` renders all ~530 mandatory spec documents through the
|
package/carve_wasm.d.ts
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export function extensions(): string[];
|
|
11
11
|
|
|
12
|
+
export function fromHtml(source: string, mode?: string | null): any;
|
|
13
|
+
|
|
14
|
+
export function fromMarkdown(source: string): any;
|
|
15
|
+
|
|
12
16
|
/**
|
|
13
17
|
* Import HTML through the Rust HTML5 DOM and canonical Carve writer.
|
|
14
18
|
*
|
|
@@ -37,6 +41,14 @@ export function htmlToCarve(source: string, mode?: string | null): any;
|
|
|
37
41
|
*/
|
|
38
42
|
export function parseJson(source: string): string;
|
|
39
43
|
|
|
44
|
+
export function toAnsi(source: string): string;
|
|
45
|
+
|
|
46
|
+
export function toAnsiWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
47
|
+
|
|
48
|
+
export function toCarve(source: string): string;
|
|
49
|
+
|
|
50
|
+
export function toCarveWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
51
|
+
|
|
40
52
|
export function toHtml(source: string): string;
|
|
41
53
|
|
|
42
54
|
/**
|
|
@@ -99,6 +111,8 @@ export function toHtmlFull(source: string, symbols?: object | null): string;
|
|
|
99
111
|
*/
|
|
100
112
|
export function toHtmlWithOptions(source: string, options?: object | null): string;
|
|
101
113
|
|
|
114
|
+
export function toHtmlWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
115
|
+
|
|
102
116
|
/**
|
|
103
117
|
* Render with the core profile and a **symbols map**: `{ rocket: "🚀" }` (a
|
|
104
118
|
* plain object or a `Map`). A `:name:` symbol whose name is in the map renders
|
|
@@ -117,4 +131,12 @@ export function toHtmlWithOptions(source: string, options?: object | null): stri
|
|
|
117
131
|
*/
|
|
118
132
|
export function toHtmlWithSymbols(source: string, symbols?: object | null): string;
|
|
119
133
|
|
|
134
|
+
export function toMarkdown(source: string): string;
|
|
135
|
+
|
|
136
|
+
export function toMarkdownWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
137
|
+
|
|
138
|
+
export function toPlainText(source: string): string;
|
|
139
|
+
|
|
140
|
+
export function toPlainTextWithReport(source: string, strict?: boolean | null, maximum?: number | null): any;
|
|
141
|
+
|
|
120
142
|
export function version(): string;
|
package/carve_wasm.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./carve_wasm_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
extensions, htmlToCarve, parseJson, toHtml, toHtmlFull, toHtmlWithOptions, toHtmlWithSymbols, version
|
|
8
|
+
extensions, fromHtml, fromMarkdown, htmlToCarve, parseJson, toAnsi, toAnsiWithReport, toCarve, toCarveWithReport, toHtml, toHtmlFull, toHtmlWithOptions, toHtmlWithReport, toHtmlWithSymbols, toMarkdown, toMarkdownWithReport, toPlainText, toPlainTextWithReport, version
|
|
9
9
|
} from "./carve_wasm_bg.js";
|
package/carve_wasm_bg.js
CHANGED
|
@@ -12,6 +12,37 @@ export function extensions() {
|
|
|
12
12
|
return v1;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} source
|
|
17
|
+
* @param {string | null} [mode]
|
|
18
|
+
* @returns {any}
|
|
19
|
+
*/
|
|
20
|
+
export function fromHtml(source, mode) {
|
|
21
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22
|
+
const len0 = WASM_VECTOR_LEN;
|
|
23
|
+
var ptr1 = isLikeNone(mode) ? 0 : passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
24
|
+
var len1 = WASM_VECTOR_LEN;
|
|
25
|
+
const ret = wasm.fromHtml(ptr0, len0, ptr1, len1);
|
|
26
|
+
if (ret[2]) {
|
|
27
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
28
|
+
}
|
|
29
|
+
return takeFromExternrefTable0(ret[0]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {string} source
|
|
34
|
+
* @returns {any}
|
|
35
|
+
*/
|
|
36
|
+
export function fromMarkdown(source) {
|
|
37
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
const ret = wasm.fromMarkdown(ptr0, len0);
|
|
40
|
+
if (ret[2]) {
|
|
41
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
42
|
+
}
|
|
43
|
+
return takeFromExternrefTable0(ret[0]);
|
|
44
|
+
}
|
|
45
|
+
|
|
15
46
|
/**
|
|
16
47
|
* Import HTML through the Rust HTML5 DOM and canonical Carve writer.
|
|
17
48
|
*
|
|
@@ -68,6 +99,76 @@ export function parseJson(source) {
|
|
|
68
99
|
}
|
|
69
100
|
}
|
|
70
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} source
|
|
104
|
+
* @returns {string}
|
|
105
|
+
*/
|
|
106
|
+
export function toAnsi(source) {
|
|
107
|
+
let deferred2_0;
|
|
108
|
+
let deferred2_1;
|
|
109
|
+
try {
|
|
110
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
111
|
+
const len0 = WASM_VECTOR_LEN;
|
|
112
|
+
const ret = wasm.toAnsi(ptr0, len0);
|
|
113
|
+
deferred2_0 = ret[0];
|
|
114
|
+
deferred2_1 = ret[1];
|
|
115
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
116
|
+
} finally {
|
|
117
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param {string} source
|
|
123
|
+
* @param {boolean | null} [strict]
|
|
124
|
+
* @param {number | null} [maximum]
|
|
125
|
+
* @returns {any}
|
|
126
|
+
*/
|
|
127
|
+
export function toAnsiWithReport(source, strict, maximum) {
|
|
128
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
129
|
+
const len0 = WASM_VECTOR_LEN;
|
|
130
|
+
const ret = wasm.toAnsiWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
131
|
+
if (ret[2]) {
|
|
132
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
133
|
+
}
|
|
134
|
+
return takeFromExternrefTable0(ret[0]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param {string} source
|
|
139
|
+
* @returns {string}
|
|
140
|
+
*/
|
|
141
|
+
export function toCarve(source) {
|
|
142
|
+
let deferred2_0;
|
|
143
|
+
let deferred2_1;
|
|
144
|
+
try {
|
|
145
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
146
|
+
const len0 = WASM_VECTOR_LEN;
|
|
147
|
+
const ret = wasm.toCarve(ptr0, len0);
|
|
148
|
+
deferred2_0 = ret[0];
|
|
149
|
+
deferred2_1 = ret[1];
|
|
150
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
151
|
+
} finally {
|
|
152
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @param {string} source
|
|
158
|
+
* @param {boolean | null} [strict]
|
|
159
|
+
* @param {number | null} [maximum]
|
|
160
|
+
* @returns {any}
|
|
161
|
+
*/
|
|
162
|
+
export function toCarveWithReport(source, strict, maximum) {
|
|
163
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
164
|
+
const len0 = WASM_VECTOR_LEN;
|
|
165
|
+
const ret = wasm.toCarveWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
166
|
+
if (ret[2]) {
|
|
167
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
168
|
+
}
|
|
169
|
+
return takeFromExternrefTable0(ret[0]);
|
|
170
|
+
}
|
|
171
|
+
|
|
71
172
|
/**
|
|
72
173
|
* @param {string} source
|
|
73
174
|
* @returns {string}
|
|
@@ -191,6 +292,22 @@ export function toHtmlWithOptions(source, options) {
|
|
|
191
292
|
}
|
|
192
293
|
}
|
|
193
294
|
|
|
295
|
+
/**
|
|
296
|
+
* @param {string} source
|
|
297
|
+
* @param {boolean | null} [strict]
|
|
298
|
+
* @param {number | null} [maximum]
|
|
299
|
+
* @returns {any}
|
|
300
|
+
*/
|
|
301
|
+
export function toHtmlWithReport(source, strict, maximum) {
|
|
302
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
303
|
+
const len0 = WASM_VECTOR_LEN;
|
|
304
|
+
const ret = wasm.toHtmlWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
305
|
+
if (ret[2]) {
|
|
306
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
307
|
+
}
|
|
308
|
+
return takeFromExternrefTable0(ret[0]);
|
|
309
|
+
}
|
|
310
|
+
|
|
194
311
|
/**
|
|
195
312
|
* Render with the core profile and a **symbols map**: `{ rocket: "🚀" }` (a
|
|
196
313
|
* plain object or a `Map`). A `:name:` symbol whose name is in the map renders
|
|
@@ -231,6 +348,76 @@ export function toHtmlWithSymbols(source, symbols) {
|
|
|
231
348
|
}
|
|
232
349
|
}
|
|
233
350
|
|
|
351
|
+
/**
|
|
352
|
+
* @param {string} source
|
|
353
|
+
* @returns {string}
|
|
354
|
+
*/
|
|
355
|
+
export function toMarkdown(source) {
|
|
356
|
+
let deferred2_0;
|
|
357
|
+
let deferred2_1;
|
|
358
|
+
try {
|
|
359
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
360
|
+
const len0 = WASM_VECTOR_LEN;
|
|
361
|
+
const ret = wasm.toMarkdown(ptr0, len0);
|
|
362
|
+
deferred2_0 = ret[0];
|
|
363
|
+
deferred2_1 = ret[1];
|
|
364
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
365
|
+
} finally {
|
|
366
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* @param {string} source
|
|
372
|
+
* @param {boolean | null} [strict]
|
|
373
|
+
* @param {number | null} [maximum]
|
|
374
|
+
* @returns {any}
|
|
375
|
+
*/
|
|
376
|
+
export function toMarkdownWithReport(source, strict, maximum) {
|
|
377
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
378
|
+
const len0 = WASM_VECTOR_LEN;
|
|
379
|
+
const ret = wasm.toMarkdownWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
380
|
+
if (ret[2]) {
|
|
381
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
382
|
+
}
|
|
383
|
+
return takeFromExternrefTable0(ret[0]);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @param {string} source
|
|
388
|
+
* @returns {string}
|
|
389
|
+
*/
|
|
390
|
+
export function toPlainText(source) {
|
|
391
|
+
let deferred2_0;
|
|
392
|
+
let deferred2_1;
|
|
393
|
+
try {
|
|
394
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
395
|
+
const len0 = WASM_VECTOR_LEN;
|
|
396
|
+
const ret = wasm.toPlainText(ptr0, len0);
|
|
397
|
+
deferred2_0 = ret[0];
|
|
398
|
+
deferred2_1 = ret[1];
|
|
399
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
400
|
+
} finally {
|
|
401
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* @param {string} source
|
|
407
|
+
* @param {boolean | null} [strict]
|
|
408
|
+
* @param {number | null} [maximum]
|
|
409
|
+
* @returns {any}
|
|
410
|
+
*/
|
|
411
|
+
export function toPlainTextWithReport(source, strict, maximum) {
|
|
412
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
413
|
+
const len0 = WASM_VECTOR_LEN;
|
|
414
|
+
const ret = wasm.toPlainTextWithReport(ptr0, len0, isLikeNone(strict) ? 0xFFFFFF : strict ? 1 : 0, isLikeNone(maximum) ? 0x100000001 : (maximum) >>> 0);
|
|
415
|
+
if (ret[2]) {
|
|
416
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
417
|
+
}
|
|
418
|
+
return takeFromExternrefTable0(ret[0]);
|
|
419
|
+
}
|
|
420
|
+
|
|
234
421
|
/**
|
|
235
422
|
* @returns {string}
|
|
236
423
|
*/
|
|
@@ -330,15 +517,32 @@ export function __wbg_new_4f9fafbb3909af72() {
|
|
|
330
517
|
const ret = new Object();
|
|
331
518
|
return ret;
|
|
332
519
|
}
|
|
520
|
+
export function __wbg_new_e3b04b4d53d1b593(arg0, arg1) {
|
|
521
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
522
|
+
return ret;
|
|
523
|
+
}
|
|
524
|
+
export function __wbg_new_f3c9df4f38f3f798() {
|
|
525
|
+
const ret = new Array();
|
|
526
|
+
return ret;
|
|
527
|
+
}
|
|
333
528
|
export function __wbg_parse_545d11396395fbbd() { return handleError(function (arg0, arg1) {
|
|
334
529
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
335
530
|
return ret;
|
|
336
531
|
}, arguments); }
|
|
532
|
+
export function __wbg_push_6bdbc990be5ac37b(arg0, arg1) {
|
|
533
|
+
const ret = arg0.push(arg1);
|
|
534
|
+
return ret;
|
|
535
|
+
}
|
|
337
536
|
export function __wbg_set_8ee2d34facb8466e() { return handleError(function (arg0, arg1, arg2) {
|
|
338
537
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
339
538
|
return ret;
|
|
340
539
|
}, arguments); }
|
|
341
|
-
export function __wbindgen_cast_0000000000000001(arg0
|
|
540
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
541
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
542
|
+
const ret = arg0;
|
|
543
|
+
return ret;
|
|
544
|
+
}
|
|
545
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
342
546
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
343
547
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
344
548
|
return ret;
|
package/carve_wasm_bg.wasm
CHANGED
|
Binary file
|