@markup-carve/carve-wasm 0.1.5 → 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 +14 -14
- package/carve_wasm.d.ts +160 -276
- package/carve_wasm.js +1 -1
- package/carve_wasm_bg.js +131 -46
- package/carve_wasm_bg.wasm +0 -0
- package/docs/compatibility.md +90 -0
- package/docs/reference.md +788 -0
- package/examples/carve-worker.mjs +35 -0
- package/examples/offsets.d.ts +3 -0
- package/examples/offsets.mjs +18 -0
- package/node/LICENSE +21 -0
- package/node/README.md +106 -0
- package/node/carve_wasm.d.ts +740 -0
- package/node/carve_wasm.js +2373 -0
- package/node/carve_wasm_bg.wasm.d.ts +75 -0
- package/node/package.json +19 -0
- package/package.json +44 -3
- package/render/LICENSE +21 -0
- package/render/README.md +106 -0
- package/render/carve_wasm.d.ts +339 -0
- package/render/carve_wasm.js +736 -0
- package/render/carve_wasm_bg.wasm +0 -0
- package/render/carve_wasm_bg.wasm.d.ts +21 -0
- package/render/package.json +22 -0
- package/web/LICENSE +21 -0
- package/web/README.md +106 -0
- package/web/carve_wasm.d.ts +840 -0
- package/web/carve_wasm.js +2408 -0
- package/web/carve_wasm_bg.wasm.d.ts +75 -0
- package/web/package.json +22 -0
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const extensions: () => [number, number];
|
|
5
|
+
export const parseLocator: (a: number, b: number) => [number, number, number];
|
|
6
|
+
export const sanitizeSvg: (a: number, b: number, c: number) => [number, number, number];
|
|
7
|
+
export const toHtml: (a: number, b: number) => [number, number];
|
|
8
|
+
export const toHtmlFull: (a: number, b: number, c: number) => [number, number, number, number];
|
|
9
|
+
export const toHtmlWithOptions: (a: number, b: number, c: number) => [number, number, number, number];
|
|
10
|
+
export const toHtmlWithRenderers: (a: number, b: number, c: number) => [number, number, number];
|
|
11
|
+
export const toHtmlWithSymbols: (a: number, b: number, c: number) => [number, number, number, number];
|
|
12
|
+
export const version: () => [number, number];
|
|
13
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
14
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
15
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
16
|
+
export const __externref_table_alloc: () => number;
|
|
17
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
18
|
+
export const __externref_drop_slice: (a: number, b: number) => void;
|
|
19
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
20
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
21
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@markup-carve/carve-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "WASM bindings for the Carve parser and HTML renderer.",
|
|
5
|
+
"version": "0.1.7",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/markup-carve/carve-wasm"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"carve_wasm_bg.wasm",
|
|
13
|
+
"carve_wasm.js",
|
|
14
|
+
"carve_wasm.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"main": "carve_wasm.js",
|
|
17
|
+
"homepage": "https://markup-carve.github.io/carve/",
|
|
18
|
+
"types": "carve_wasm.d.ts",
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"./snippets/*"
|
|
21
|
+
]
|
|
22
|
+
}
|
package/web/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mark Scherer
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
package/web/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# carve-wasm
|
|
2
|
+
|
|
3
|
+
WebAssembly build of the [Carve](https://markup-carve.github.io/carve/) markup
|
|
4
|
+
renderer, compiled from
|
|
5
|
+
[carve-rs](https://github.com/markup-carve/carve-rs). It runs the Rust
|
|
6
|
+
implementation in browsers and powers the **Rust (WASM)** engine in the
|
|
7
|
+
[Carve playground](https://markup-carve.github.io/carve/playground).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @markup-carve/carve-wasm
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Render Carve
|
|
16
|
+
|
|
17
|
+
The package root selects synchronous Node bindings in Node and the bundler
|
|
18
|
+
build in browser bundles. The browser bundler must support native WASM imports
|
|
19
|
+
and top-level await. Vite 8.3.2 is tested. See the
|
|
20
|
+
[compatibility guide](docs/compatibility.md) for explicit browser, Node and
|
|
21
|
+
rendering-only imports.
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { toHtml, toHtmlFull, toHtmlWithOptions } from '@markup-carve/carve-wasm'
|
|
25
|
+
|
|
26
|
+
toHtml('# Hello, Carve!')
|
|
27
|
+
toHtmlFull('# Hello\n\n``` mermaid\ngraph TD; A-->B\n```\n')
|
|
28
|
+
toHtmlWithOptions(source, {
|
|
29
|
+
extensions: ['glossary', 'table-of-contents'],
|
|
30
|
+
rawHtml: false,
|
|
31
|
+
sections: true,
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`toHtml` uses the core renderer. `toHtmlFull` enables the extension set used
|
|
36
|
+
by the playground preview. `toHtmlWithOptions` lets the caller choose
|
|
37
|
+
extensions and rendering policy. Unknown extension names throw instead of
|
|
38
|
+
silently producing incomplete output.
|
|
39
|
+
|
|
40
|
+
Other core targets include `toMarkdown`, `toPlainText`, `toAnsi`, and
|
|
41
|
+
`toCarve`. Each has a `*WithOptions` form.
|
|
42
|
+
|
|
43
|
+
## Convert existing content
|
|
44
|
+
|
|
45
|
+
The package imports HTML, Markdown, Djot, and BBCode. `fromHtml`,
|
|
46
|
+
`fromMarkdown`, `migrateDjot`, and `migrateBbcode` return the converted value
|
|
47
|
+
with a fidelity report. The simpler `fromDjot` and `fromBbcode` helpers return
|
|
48
|
+
only the converted string.
|
|
49
|
+
|
|
50
|
+
Markdown reports assess supported constructs and report known losses. Inputs
|
|
51
|
+
outside that assessment receive `fidelity-unverified`. Djot and BBCode use the
|
|
52
|
+
conservative fallback except for verified literal text.
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import { fromHtml, fromMarkdown, htmlToAst, htmlToCarve } from '@markup-carve/carve-wasm'
|
|
56
|
+
|
|
57
|
+
const { value, report } = htmlToCarve('<p>Hello <strong>world</strong></p>', 'safe')
|
|
58
|
+
const { value: ast } = htmlToAst('<p>Hello <b>world</b></p>', 'safe')
|
|
59
|
+
|
|
60
|
+
fromHtml(html, 'semantic')
|
|
61
|
+
fromMarkdown(markdown)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
HTML modes are `safe` (the default), `semantic`, and trusted-only
|
|
65
|
+
`roundtrip`. `htmlToAst` returns the serialized Carve AST without passing it
|
|
66
|
+
through the source writer, so its report can differ from `htmlToCarve` when a
|
|
67
|
+
construct is representable in the tree but not in Carve source.
|
|
68
|
+
|
|
69
|
+
## Common host APIs
|
|
70
|
+
|
|
71
|
+
- `extensions()` returns the extension names supported by the bundled engine.
|
|
72
|
+
- `toCarvePatch()` and `applySourcePatch()` create and apply stale-safe UTF-8
|
|
73
|
+
byte edits.
|
|
74
|
+
- `toHtmlWithSymbols()` resolves configured `:name:` symbols. Symbol values
|
|
75
|
+
are trusted raw output and must not come from user input.
|
|
76
|
+
- `parseJson()`, `astJsonToHtml()`, and the other AST functions use the PART 12
|
|
77
|
+
AST JSON shared by Carve implementations.
|
|
78
|
+
- Include expansion calls a synchronous host resolver, records dependencies,
|
|
79
|
+
and enforces depth, byte, and call budgets. The resolver decides which paths
|
|
80
|
+
to refuse.
|
|
81
|
+
- `ParserSession` retains a document between edits and can reuse unchanged
|
|
82
|
+
plain paragraphs. Call `free()` when the editor closes. Tree patches,
|
|
83
|
+
three-way merge and ProseMirror helpers also support browser editors.
|
|
84
|
+
|
|
85
|
+
The [complete API and usage reference](docs/reference.md) documents these
|
|
86
|
+
APIs, renderer profiles, resource limits, includes, AST fields, and the
|
|
87
|
+
TypeScript declarations.
|
|
88
|
+
|
|
89
|
+
## Security
|
|
90
|
+
|
|
91
|
+
Use `rawHtml: false` with a restrictive profile such as `comment` for
|
|
92
|
+
untrusted documents. Symbols and static renderer callbacks are trusted
|
|
93
|
+
configuration and may emit unescaped HTML. Treat source patches as trusted
|
|
94
|
+
edit instructions, not as signed data. A profile rejection throws.
|
|
95
|
+
|
|
96
|
+
Carve also enforces URL-scheme and attribute hardening in the renderer. See
|
|
97
|
+
the language [security documentation](https://markup-carve.github.io/carve/security)
|
|
98
|
+
for the complete model.
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
Contributor documentation lives under `docs/`:
|
|
103
|
+
|
|
104
|
+
- [Building and testing](https://github.com/markup-carve/carve-wasm/blob/main/docs/building.md)
|
|
105
|
+
- [The carve-rs engine pin](https://github.com/markup-carve/carve-wasm/blob/main/docs/engine-pin.md)
|
|
106
|
+
- [Release process](https://github.com/markup-carve/carve-wasm/blob/main/docs/releasing.md)
|