@markup-carve/carve-wasm 0.1.4 → 0.1.6
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 +67 -689
- package/carve_wasm.d.ts +160 -276
- package/carve_wasm.js +1 -1
- package/carve_wasm_bg.js +112 -38
- package/carve_wasm_bg.wasm +0 -0
- package/docs/compatibility.md +89 -0
- package/docs/reference.md +785 -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 +105 -0
- package/node/carve_wasm.d.ts +740 -0
- package/node/carve_wasm.js +2362 -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 +105 -0
- package/render/carve_wasm.d.ts +339 -0
- package/render/carve_wasm.js +726 -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 +105 -0
- package/web/carve_wasm.d.ts +840 -0
- package/web/carve_wasm.js +2397 -0
- package/web/carve_wasm_bg.wasm.d.ts +75 -0
- package/web/package.json +22 -0
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
/* @ts-self-types="./carve_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Every extension name this build accepts, in registry order.
|
|
5
|
+
*
|
|
6
|
+
* Taken from the engine, so a new extension is reachable as soon as the pin
|
|
7
|
+
* moves. Nothing here lists names.
|
|
8
|
+
* @returns {string[]}
|
|
9
|
+
*/
|
|
10
|
+
export function extensions() {
|
|
11
|
+
const ret = wasm.extensions();
|
|
12
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
13
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
14
|
+
return v1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Parse the locator portion of a citation into `{ label, value, suffixText }`.
|
|
19
|
+
*
|
|
20
|
+
* A field the source did not carry is `null`. Same shape as carve-js
|
|
21
|
+
* `parseLocator`; pure, and never throws on bad input.
|
|
22
|
+
* @param {string} loc
|
|
23
|
+
* @returns {ParsedLocator}
|
|
24
|
+
*/
|
|
25
|
+
export function parseLocator(loc) {
|
|
26
|
+
const ptr0 = passStringToWasm0(loc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
27
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28
|
+
const ret = wasm.parseLocator(ptr0, len0);
|
|
29
|
+
if (ret[2]) {
|
|
30
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
31
|
+
}
|
|
32
|
+
return takeFromExternrefTable0(ret[0]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sanitize an SVG document, the helper a host embedding SVG would otherwise
|
|
37
|
+
* reimplement.
|
|
38
|
+
*
|
|
39
|
+
* `{ svg, ok }`. `ok` false means the input was not a single well-formed
|
|
40
|
+
* `<svg>` root, and a caller must then show the SOURCE rather than the input:
|
|
41
|
+
* `svg` carries nothing to display. Every option defaults to `false`, which is
|
|
42
|
+
* the strict setting.
|
|
43
|
+
* @param {string} source
|
|
44
|
+
* @param {object | null} [options]
|
|
45
|
+
* @returns {SanitizeResult}
|
|
46
|
+
*/
|
|
47
|
+
export function sanitizeSvg(source, options) {
|
|
48
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
49
|
+
const len0 = WASM_VECTOR_LEN;
|
|
50
|
+
const ret = wasm.sanitizeSvg(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
51
|
+
if (ret[2]) {
|
|
52
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
53
|
+
}
|
|
54
|
+
return takeFromExternrefTable0(ret[0]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} source
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
export function toHtml(source) {
|
|
62
|
+
let deferred2_0;
|
|
63
|
+
let deferred2_1;
|
|
64
|
+
try {
|
|
65
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
66
|
+
const len0 = WASM_VECTOR_LEN;
|
|
67
|
+
const ret = wasm.toHtml(ptr0, len0);
|
|
68
|
+
deferred2_0 = ret[0];
|
|
69
|
+
deferred2_1 = ret[1];
|
|
70
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
71
|
+
} finally {
|
|
72
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Render with the preview extension set enabled (`PREVIEW_EXTENSIONS`), so the
|
|
78
|
+
* WASM engine matches an extensions-on host such as the docs Playground rather
|
|
79
|
+
* than the core-only `toHtml`.
|
|
80
|
+
*
|
|
81
|
+
* The set is curated, not "everything the engine has": `heading-numbers` and
|
|
82
|
+
* `table-of-contents` rewrite a document that never asked for it, which is
|
|
83
|
+
* wrong for a preview. Callers who want an exact set pass `extensions` to
|
|
84
|
+
* `toHtmlWithOptions`, and `extensions()` reports what this build accepts.
|
|
85
|
+
*
|
|
86
|
+
* The optional second argument is the same **symbols map** as
|
|
87
|
+
* [`to_html_with_symbols`], with the same trusted-raw contract: mapped values
|
|
88
|
+
* are emitted UNESCAPED, so never feed it untrusted input.
|
|
89
|
+
* @param {string} source
|
|
90
|
+
* @param {object | null} [symbols]
|
|
91
|
+
* @returns {string}
|
|
92
|
+
*/
|
|
93
|
+
export function toHtmlFull(source, symbols) {
|
|
94
|
+
let deferred3_0;
|
|
95
|
+
let deferred3_1;
|
|
96
|
+
try {
|
|
97
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
98
|
+
const len0 = WASM_VECTOR_LEN;
|
|
99
|
+
const ret = wasm.toHtmlFull(ptr0, len0, isLikeNone(symbols) ? 0 : addToExternrefTable0(symbols));
|
|
100
|
+
var ptr2 = ret[0];
|
|
101
|
+
var len2 = ret[1];
|
|
102
|
+
if (ret[3]) {
|
|
103
|
+
ptr2 = 0; len2 = 0;
|
|
104
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
105
|
+
}
|
|
106
|
+
deferred3_0 = ptr2;
|
|
107
|
+
deferred3_1 = len2;
|
|
108
|
+
return getStringFromWasm0(ptr2, len2);
|
|
109
|
+
} finally {
|
|
110
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Render with an options object, the general form of the three shorthands
|
|
116
|
+
* above.
|
|
117
|
+
*
|
|
118
|
+
* ```js
|
|
119
|
+
* toHtmlWithOptions('# A\n\np\n', { sections: false })
|
|
120
|
+
* // '<h1 id="A">A</h1>\n<p>p</p>'
|
|
121
|
+
*
|
|
122
|
+
* toHtmlWithOptions(src, { sections: false, symbols: { rocket: '🚀' }, full: true })
|
|
123
|
+
*
|
|
124
|
+
* toHtmlWithOptions(untrusted, { rawHtml: false })
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* Every field is optional:
|
|
128
|
+
*
|
|
129
|
+
* * `sections` (default `true`) - wrap each top-level heading, and the content
|
|
130
|
+
* following it up to the next same-or-shallower heading, in a
|
|
131
|
+
* `<section id="…">` (spec PART 9 §13). `false` renders headings flat with
|
|
132
|
+
* the id back on the `<h*>` and the former section children as siblings.
|
|
133
|
+
* For a host whose CSS or JS assumes rendered blocks are direct children of
|
|
134
|
+
* the content container - the `.stack > * + *` spacing idiom,
|
|
135
|
+
* `:first-child`, `nth-child()` counting, `element.children` walks - the
|
|
136
|
+
* wrapper is the one output change a clean source migration still breaks.
|
|
137
|
+
* * `symbols` - the same map as [`to_html_with_symbols`], with the same
|
|
138
|
+
* TRUSTED-RAW contract: mapped values are emitted UNESCAPED, so never build
|
|
139
|
+
* it from untrusted input.
|
|
140
|
+
* * `extensions` - an array of extension names to enable, e.g.
|
|
141
|
+
* `["glossary", "table-of-contents"]`. `extensions()` reports what this
|
|
142
|
+
* build accepts. An unknown name throws: a silently ignored extension would
|
|
143
|
+
* render as missing behavior that looks like a Carve bug. Takes precedence
|
|
144
|
+
* over `full`.
|
|
145
|
+
* * `full` (default `false`) - enable the preview extension set instead of
|
|
146
|
+
* rendering core-only.
|
|
147
|
+
* * `rawHtml` (default `true`) - render an explicit passthrough - the `=html`
|
|
148
|
+
* raw block and the `` `…`{=html} `` inline raw span - as markup. `false`
|
|
149
|
+
* emits it as escaped text instead, the same switch carve-js spells
|
|
150
|
+
* `allowRawHtml`. A host that renders a document it did not author (a shared
|
|
151
|
+
* link, a comment field, anything a reader supplies) wants `false`: without
|
|
152
|
+
* it a passthrough is a way to run script on the host's origin.
|
|
153
|
+
* * `profile` - one of `"full"`, `"article"`, `"comment"`, `"minimal"`. The
|
|
154
|
+
* rest of the untrusted-input story: input length, denied constructs, link
|
|
155
|
+
* policy. A document the profile REJECTS throws a `ProfileViolationError`
|
|
156
|
+
* carrying `violations`, rather than resolving to an empty string.
|
|
157
|
+
* * `profileBaseHost` - the host counted as internal when the profile's link
|
|
158
|
+
* policy distinguishes internal from external links.
|
|
159
|
+
* * `mode` - `"interactive"` (default) or `"static"`, the self-contained form
|
|
160
|
+
* for print, PDF and archival: no client scripts.
|
|
161
|
+
* * `sourceLine` (default `false`) - stamp top-level blocks with
|
|
162
|
+
* `data-source-line`, for editor preview scroll-sync.
|
|
163
|
+
* * `positions` (default `false`) - keep source offsets on the nodes.
|
|
164
|
+
* * `labels` - override the engine-written strings (admonition names, the
|
|
165
|
+
* endnotes heading, backlink text) for a page that is not in English. These
|
|
166
|
+
* are TEXT and are escaped where they land, unlike `symbols`.
|
|
167
|
+
* * `smartTypography` - `"glyph"` (default) resolves `...` to an ellipsis,
|
|
168
|
+
* `"source"` keeps the author's run.
|
|
169
|
+
* * `lowercaseHeadingIds` (default `false`) and `asciiHeadingIds`
|
|
170
|
+
* (`"off"` (default), `"fold"`, `"strict"`) - the slug policy, for a host
|
|
171
|
+
* whose anchors have to match another generator's.
|
|
172
|
+
* * `mentionUrl` and `tagUrl` - URL templates for `@mention` and `#tag`.
|
|
173
|
+
* Without them both render as inert spans, which is why a host that wants
|
|
174
|
+
* them linked has to say where to. The token name is percent-encoded into
|
|
175
|
+
* `{name}` - `{user}` works too for a mention - and the result goes through
|
|
176
|
+
* the same URL sanitizer as an authored link. These are the HOST's
|
|
177
|
+
* configuration, not the document's: the template is trusted, the name
|
|
178
|
+
* substituted into it is not.
|
|
179
|
+
*
|
|
180
|
+
* An unrecognized key is ignored: the object is configuration, and a caller
|
|
181
|
+
* who mistypes one deserves the render to still work. A wrong TYPE on a key
|
|
182
|
+
* that is recognized does throw, because that changes behavior silently.
|
|
183
|
+
*
|
|
184
|
+
* `renderers` is the one recognized key this entry point refuses, because a
|
|
185
|
+
* render callback can fail and a bare string has nowhere to report that. Use
|
|
186
|
+
* [`to_html_with_renderers`].
|
|
187
|
+
*
|
|
188
|
+
* Turning sections off changes nothing else. Ids, collision dedup, `</#id>`
|
|
189
|
+
* crossrefs, implicit `[Heading][]` references and heading numbering all
|
|
190
|
+
* resolve against the slug rather than the element carrying it, and the
|
|
191
|
+
* endnotes `<section role="doc-endnotes">` is a separate construct that is
|
|
192
|
+
* still emitted.
|
|
193
|
+
* @param {string} source
|
|
194
|
+
* @param {RenderOptions | null} options
|
|
195
|
+
* @returns {string}
|
|
196
|
+
*/
|
|
197
|
+
export function toHtmlWithOptions(source, options) {
|
|
198
|
+
let deferred3_0;
|
|
199
|
+
let deferred3_1;
|
|
200
|
+
try {
|
|
201
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
202
|
+
const len0 = WASM_VECTOR_LEN;
|
|
203
|
+
const ret = wasm.toHtmlWithOptions(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
204
|
+
var ptr2 = ret[0];
|
|
205
|
+
var len2 = ret[1];
|
|
206
|
+
if (ret[3]) {
|
|
207
|
+
ptr2 = 0; len2 = 0;
|
|
208
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
209
|
+
}
|
|
210
|
+
deferred3_0 = ptr2;
|
|
211
|
+
deferred3_1 = len2;
|
|
212
|
+
return getStringFromWasm0(ptr2, len2);
|
|
213
|
+
} finally {
|
|
214
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Render with a build-time math renderer, the option `mode: "static"` needs.
|
|
220
|
+
*
|
|
221
|
+
* Static output carries no client scripts, so a formula it contains has to be
|
|
222
|
+
* rendered while the HTML is being written. `renderers.math` is the callback
|
|
223
|
+
* the engine calls for each ``` ```math ``` fence, with the TeX source and a
|
|
224
|
+
* display flag; KaTeX's `renderToString` has that exact shape.
|
|
225
|
+
*
|
|
226
|
+
* ```js
|
|
227
|
+
* toHtmlWithRenderers(src, {
|
|
228
|
+
* mode: 'static',
|
|
229
|
+
* extensions: ['math-block'],
|
|
230
|
+
* renderers: { math: (tex, display) => katex.renderToString(tex, { displayMode: display }) },
|
|
231
|
+
* })
|
|
232
|
+
* // { html: '…', rendererErrors: [] }
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* SECURITY: what the callback returns is inserted as **TRUSTED RAW HTML**, the
|
|
236
|
+
* same trust class as a `symbols` value. The difference worth stating: a symbol
|
|
237
|
+
* value is host configuration keyed by a NAME, while a renderer is host
|
|
238
|
+
* configuration that is HANDED DOCUMENT CONTENT and typically echoes some of it
|
|
239
|
+
* back. A host rendering documents it did not author is accepting whatever its
|
|
240
|
+
* renderer makes of that input, so the escaping is the renderer's job.
|
|
241
|
+
*
|
|
242
|
+
* The engine consults the renderer only under `mode: "static"`; interactive
|
|
243
|
+
* output keeps the `\[…\]` source for the client to typeset, and so does a
|
|
244
|
+
* static render with no renderer supplied.
|
|
245
|
+
*
|
|
246
|
+
* The callback must be SYNCHRONOUS. wasm-bindgen cannot await across it, so an
|
|
247
|
+
* `async` renderer returns a Promise the engine has no way to resolve; that is
|
|
248
|
+
* recorded as a failure rather than stringified into the document.
|
|
249
|
+
*
|
|
250
|
+
* `renderers.diagrams` is the same callback one level down, keyed by the
|
|
251
|
+
* fence's css class: `{ mermaid: (source) => html }`. A host that renders its
|
|
252
|
+
* diagrams beforehand passes the lookup in that one line -
|
|
253
|
+
* `(source) => prerendered.get(source)`. Mermaid itself cannot be passed,
|
|
254
|
+
* because its `render` returns a Promise from v10 on.
|
|
255
|
+
*
|
|
256
|
+
* ```js
|
|
257
|
+
* toHtmlWithRenderers(src, {
|
|
258
|
+
* mode: 'static',
|
|
259
|
+
* extensions: ['fenced-render'],
|
|
260
|
+
* renderers: { diagrams: { mermaid: (source) => prerendered.get(source) } },
|
|
261
|
+
* })
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* A diagram key the document never uses renders nothing and reports nothing.
|
|
265
|
+
* So does a fence whose class the caller did not configure: the engine
|
|
266
|
+
* degrades it to an escaped source block, and this binding never sees the
|
|
267
|
+
* node.
|
|
268
|
+
*
|
|
269
|
+
* A callback that throws, or returns anything other than a string, does not
|
|
270
|
+
* abort the render: the node it was called for emits nothing and the failure
|
|
271
|
+
* is reported in `rendererErrors`, with `renderer` naming the css class.
|
|
272
|
+
* This entry point exists because [`to_html_with_options`] returns a bare
|
|
273
|
+
* string with nowhere to put that, and so it rejects `renderers` rather than
|
|
274
|
+
* dropping the failures.
|
|
275
|
+
* @param {string} source
|
|
276
|
+
* @param {StaticRenderOptions | null} options
|
|
277
|
+
* @returns {any}
|
|
278
|
+
*/
|
|
279
|
+
export function toHtmlWithRenderers(source, options) {
|
|
280
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
281
|
+
const len0 = WASM_VECTOR_LEN;
|
|
282
|
+
const ret = wasm.toHtmlWithRenderers(ptr0, len0, isLikeNone(options) ? 0 : addToExternrefTable0(options));
|
|
283
|
+
if (ret[2]) {
|
|
284
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
285
|
+
}
|
|
286
|
+
return takeFromExternrefTable0(ret[0]);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Render with the core profile and a **symbols map**: `{ rocket: "🚀" }` (a
|
|
291
|
+
* plain object or a `Map`). A `:name:` symbol whose name is in the map renders
|
|
292
|
+
* the mapped value; an unmapped `:name:` stays literal `:name:` text, and the
|
|
293
|
+
* leading word-boundary guard still applies (`a:b:c`, `10:30:`,
|
|
294
|
+
* `me@example.com` never become symbols).
|
|
295
|
+
*
|
|
296
|
+
* Names and values must both be strings; a non-string value throws a JS
|
|
297
|
+
* `TypeError`.
|
|
298
|
+
*
|
|
299
|
+
* SECURITY: a mapped value is inserted as **TRUSTED RAW output in the target
|
|
300
|
+
* format** - it is NOT escaped, the same trust class as the static `renderers`
|
|
301
|
+
* map. So `{ b: "<b>x</b>" }` emits a real `<b>` element, not escaped text.
|
|
302
|
+
* This is deliberate: processor configuration is trusted. NEVER build a
|
|
303
|
+
* symbols map out of untrusted / user-supplied input.
|
|
304
|
+
* @param {string} source
|
|
305
|
+
* @param {object | null} [symbols]
|
|
306
|
+
* @returns {string}
|
|
307
|
+
*/
|
|
308
|
+
export function toHtmlWithSymbols(source, symbols) {
|
|
309
|
+
let deferred3_0;
|
|
310
|
+
let deferred3_1;
|
|
311
|
+
try {
|
|
312
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
313
|
+
const len0 = WASM_VECTOR_LEN;
|
|
314
|
+
const ret = wasm.toHtmlWithSymbols(ptr0, len0, isLikeNone(symbols) ? 0 : addToExternrefTable0(symbols));
|
|
315
|
+
var ptr2 = ret[0];
|
|
316
|
+
var len2 = ret[1];
|
|
317
|
+
if (ret[3]) {
|
|
318
|
+
ptr2 = 0; len2 = 0;
|
|
319
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
320
|
+
}
|
|
321
|
+
deferred3_0 = ptr2;
|
|
322
|
+
deferred3_1 = len2;
|
|
323
|
+
return getStringFromWasm0(ptr2, len2);
|
|
324
|
+
} finally {
|
|
325
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* @returns {string}
|
|
331
|
+
*/
|
|
332
|
+
export function version() {
|
|
333
|
+
let deferred1_0;
|
|
334
|
+
let deferred1_1;
|
|
335
|
+
try {
|
|
336
|
+
const ret = wasm.version();
|
|
337
|
+
deferred1_0 = ret[0];
|
|
338
|
+
deferred1_1 = ret[1];
|
|
339
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
340
|
+
} finally {
|
|
341
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function __wbg_get_imports() {
|
|
346
|
+
const import0 = {
|
|
347
|
+
__proto__: null,
|
|
348
|
+
__wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
|
|
349
|
+
const v = arg0;
|
|
350
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
351
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
352
|
+
},
|
|
353
|
+
__wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
|
|
354
|
+
const ret = typeof(arg0) === 'function';
|
|
355
|
+
return ret;
|
|
356
|
+
},
|
|
357
|
+
__wbg___wbindgen_is_null_344c8750a8525473: function(arg0) {
|
|
358
|
+
const ret = arg0 === null;
|
|
359
|
+
return ret;
|
|
360
|
+
},
|
|
361
|
+
__wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
|
|
362
|
+
const ret = arg0 === undefined;
|
|
363
|
+
return ret;
|
|
364
|
+
},
|
|
365
|
+
__wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
|
|
366
|
+
const obj = arg1;
|
|
367
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
368
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
369
|
+
var len1 = WASM_VECTOR_LEN;
|
|
370
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
371
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
372
|
+
},
|
|
373
|
+
__wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
|
|
374
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
375
|
+
},
|
|
376
|
+
__wbg___wbindgen_typeof_ec2e006152efc95c: function(arg0) {
|
|
377
|
+
const ret = typeof arg0;
|
|
378
|
+
return ret;
|
|
379
|
+
},
|
|
380
|
+
__wbg_call_368fa9c372d473ba: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
381
|
+
const ret = arg0.call(arg1, arg2, arg3);
|
|
382
|
+
return ret;
|
|
383
|
+
}, arguments); },
|
|
384
|
+
__wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
|
|
385
|
+
const ret = arg0.call(arg1, arg2);
|
|
386
|
+
return ret;
|
|
387
|
+
}, arguments); },
|
|
388
|
+
__wbg_entries_616b1a459b85be0b: function(arg0) {
|
|
389
|
+
const ret = Object.entries(arg0);
|
|
390
|
+
return ret;
|
|
391
|
+
},
|
|
392
|
+
__wbg_entries_7d89e479ff037f54: function(arg0) {
|
|
393
|
+
const ret = arg0.entries();
|
|
394
|
+
return ret;
|
|
395
|
+
},
|
|
396
|
+
__wbg_from_741da0f916ab74aa: function(arg0) {
|
|
397
|
+
const ret = Array.from(arg0);
|
|
398
|
+
return ret;
|
|
399
|
+
},
|
|
400
|
+
__wbg_get_4848e350b40afc16: function(arg0, arg1) {
|
|
401
|
+
const ret = arg0[arg1 >>> 0];
|
|
402
|
+
return ret;
|
|
403
|
+
},
|
|
404
|
+
__wbg_get_f96702c6245e4ef9: function() { return handleError(function (arg0, arg1) {
|
|
405
|
+
const ret = Reflect.get(arg0, arg1);
|
|
406
|
+
return ret;
|
|
407
|
+
}, arguments); },
|
|
408
|
+
__wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
|
|
409
|
+
const ret = arg0[arg1 >>> 0];
|
|
410
|
+
return ret;
|
|
411
|
+
},
|
|
412
|
+
__wbg_instanceof_Error_e3390d6805733dad: function(arg0) {
|
|
413
|
+
let result;
|
|
414
|
+
try {
|
|
415
|
+
result = arg0 instanceof Error;
|
|
416
|
+
} catch (_) {
|
|
417
|
+
result = false;
|
|
418
|
+
}
|
|
419
|
+
const ret = result;
|
|
420
|
+
return ret;
|
|
421
|
+
},
|
|
422
|
+
__wbg_instanceof_Map_a10a2795ef4bfe97: function(arg0) {
|
|
423
|
+
let result;
|
|
424
|
+
try {
|
|
425
|
+
result = arg0 instanceof Map;
|
|
426
|
+
} catch (_) {
|
|
427
|
+
result = false;
|
|
428
|
+
}
|
|
429
|
+
const ret = result;
|
|
430
|
+
return ret;
|
|
431
|
+
},
|
|
432
|
+
__wbg_instanceof_Object_72ee0c53dd8f0726: function(arg0) {
|
|
433
|
+
let result;
|
|
434
|
+
try {
|
|
435
|
+
result = arg0 instanceof Object;
|
|
436
|
+
} catch (_) {
|
|
437
|
+
result = false;
|
|
438
|
+
}
|
|
439
|
+
const ret = result;
|
|
440
|
+
return ret;
|
|
441
|
+
},
|
|
442
|
+
__wbg_instanceof_Promise_95d523058012a13d: function(arg0) {
|
|
443
|
+
let result;
|
|
444
|
+
try {
|
|
445
|
+
result = arg0 instanceof Promise;
|
|
446
|
+
} catch (_) {
|
|
447
|
+
result = false;
|
|
448
|
+
}
|
|
449
|
+
const ret = result;
|
|
450
|
+
return ret;
|
|
451
|
+
},
|
|
452
|
+
__wbg_isArray_db61795ad004c139: function(arg0) {
|
|
453
|
+
const ret = Array.isArray(arg0);
|
|
454
|
+
return ret;
|
|
455
|
+
},
|
|
456
|
+
__wbg_length_6e821edde497a532: function(arg0) {
|
|
457
|
+
const ret = arg0.length;
|
|
458
|
+
return ret;
|
|
459
|
+
},
|
|
460
|
+
__wbg_message_7367f8c7d0fa1589: function(arg0) {
|
|
461
|
+
const ret = arg0.message;
|
|
462
|
+
return ret;
|
|
463
|
+
},
|
|
464
|
+
__wbg_new_47dfee3855dec446: function(arg0, arg1) {
|
|
465
|
+
const ret = new TypeError(getStringFromWasm0(arg0, arg1));
|
|
466
|
+
return ret;
|
|
467
|
+
},
|
|
468
|
+
__wbg_new_4f9fafbb3909af72: function() {
|
|
469
|
+
const ret = new Object();
|
|
470
|
+
return ret;
|
|
471
|
+
},
|
|
472
|
+
__wbg_new_e3b04b4d53d1b593: function(arg0, arg1) {
|
|
473
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
474
|
+
return ret;
|
|
475
|
+
},
|
|
476
|
+
__wbg_new_f3c9df4f38f3f798: function() {
|
|
477
|
+
const ret = new Array();
|
|
478
|
+
return ret;
|
|
479
|
+
},
|
|
480
|
+
__wbg_push_6bdbc990be5ac37b: function(arg0, arg1) {
|
|
481
|
+
const ret = arg0.push(arg1);
|
|
482
|
+
return ret;
|
|
483
|
+
},
|
|
484
|
+
__wbg_set_8ee2d34facb8466e: function() { return handleError(function (arg0, arg1, arg2) {
|
|
485
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
486
|
+
return ret;
|
|
487
|
+
}, arguments); },
|
|
488
|
+
__wbg_set_name_ab9c98596fd7310a: function(arg0, arg1, arg2) {
|
|
489
|
+
arg0.name = getStringFromWasm0(arg1, arg2);
|
|
490
|
+
},
|
|
491
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
492
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
493
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
494
|
+
return ret;
|
|
495
|
+
},
|
|
496
|
+
__wbindgen_init_externref_table: function() {
|
|
497
|
+
const table = wasm.__wbindgen_externrefs;
|
|
498
|
+
const offset = table.grow(4);
|
|
499
|
+
table.set(0, undefined);
|
|
500
|
+
table.set(offset + 0, undefined);
|
|
501
|
+
table.set(offset + 1, null);
|
|
502
|
+
table.set(offset + 2, true);
|
|
503
|
+
table.set(offset + 3, false);
|
|
504
|
+
},
|
|
505
|
+
};
|
|
506
|
+
return {
|
|
507
|
+
__proto__: null,
|
|
508
|
+
"./carve_wasm_bg.js": import0,
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function addToExternrefTable0(obj) {
|
|
513
|
+
const idx = wasm.__externref_table_alloc();
|
|
514
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
515
|
+
return idx;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
519
|
+
ptr = ptr >>> 0;
|
|
520
|
+
const mem = getDataViewMemory0();
|
|
521
|
+
const result = [];
|
|
522
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
523
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
524
|
+
}
|
|
525
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
526
|
+
return result;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
let cachedDataViewMemory0 = null;
|
|
530
|
+
function getDataViewMemory0() {
|
|
531
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
532
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
533
|
+
}
|
|
534
|
+
return cachedDataViewMemory0;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function getStringFromWasm0(ptr, len) {
|
|
538
|
+
ptr = ptr >>> 0;
|
|
539
|
+
return decodeText(ptr, len);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
let cachedUint8ArrayMemory0 = null;
|
|
543
|
+
function getUint8ArrayMemory0() {
|
|
544
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
545
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
546
|
+
}
|
|
547
|
+
return cachedUint8ArrayMemory0;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function handleError(f, args) {
|
|
551
|
+
try {
|
|
552
|
+
return f.apply(this, args);
|
|
553
|
+
} catch (e) {
|
|
554
|
+
const idx = addToExternrefTable0(e);
|
|
555
|
+
wasm.__wbindgen_exn_store(idx);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function isLikeNone(x) {
|
|
560
|
+
return x === undefined || x === null;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
564
|
+
if (realloc === undefined) {
|
|
565
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
566
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
567
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
568
|
+
WASM_VECTOR_LEN = buf.length;
|
|
569
|
+
return ptr;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
let len = arg.length;
|
|
573
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
574
|
+
|
|
575
|
+
const mem = getUint8ArrayMemory0();
|
|
576
|
+
|
|
577
|
+
let offset = 0;
|
|
578
|
+
|
|
579
|
+
for (; offset < len; offset++) {
|
|
580
|
+
const code = arg.charCodeAt(offset);
|
|
581
|
+
if (code > 0x7F) break;
|
|
582
|
+
mem[ptr + offset] = code;
|
|
583
|
+
}
|
|
584
|
+
if (offset !== len) {
|
|
585
|
+
if (offset !== 0) {
|
|
586
|
+
arg = arg.slice(offset);
|
|
587
|
+
}
|
|
588
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
589
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
590
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
591
|
+
|
|
592
|
+
offset += ret.written;
|
|
593
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
WASM_VECTOR_LEN = offset;
|
|
597
|
+
return ptr;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function takeFromExternrefTable0(idx) {
|
|
601
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
602
|
+
wasm.__externref_table_dealloc(idx);
|
|
603
|
+
return value;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
607
|
+
cachedTextDecoder.decode();
|
|
608
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
609
|
+
let numBytesDecoded = 0;
|
|
610
|
+
function decodeText(ptr, len) {
|
|
611
|
+
numBytesDecoded += len;
|
|
612
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
613
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
614
|
+
cachedTextDecoder.decode();
|
|
615
|
+
numBytesDecoded = len;
|
|
616
|
+
}
|
|
617
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
const cachedTextEncoder = new TextEncoder();
|
|
621
|
+
|
|
622
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
623
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
624
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
625
|
+
view.set(buf);
|
|
626
|
+
return {
|
|
627
|
+
read: arg.length,
|
|
628
|
+
written: buf.length
|
|
629
|
+
};
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
let WASM_VECTOR_LEN = 0;
|
|
634
|
+
|
|
635
|
+
let wasmModule, wasm;
|
|
636
|
+
function __wbg_finalize_init(instance, module) {
|
|
637
|
+
wasm = instance.exports;
|
|
638
|
+
wasmModule = module;
|
|
639
|
+
cachedDataViewMemory0 = null;
|
|
640
|
+
cachedUint8ArrayMemory0 = null;
|
|
641
|
+
wasm.__wbindgen_start();
|
|
642
|
+
return wasm;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
async function __wbg_load(module, imports) {
|
|
646
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
647
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
648
|
+
try {
|
|
649
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
650
|
+
} catch (e) {
|
|
651
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
652
|
+
|
|
653
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
654
|
+
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);
|
|
655
|
+
|
|
656
|
+
} else { throw e; }
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
const bytes = await module.arrayBuffer();
|
|
661
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
662
|
+
} else {
|
|
663
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
664
|
+
|
|
665
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
666
|
+
return { instance, module };
|
|
667
|
+
} else {
|
|
668
|
+
return instance;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function expectedResponseType(type) {
|
|
673
|
+
switch (type) {
|
|
674
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
675
|
+
}
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function initSync(module) {
|
|
681
|
+
if (wasm !== undefined) return wasm;
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
if (module !== undefined) {
|
|
685
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
686
|
+
({module} = module)
|
|
687
|
+
} else {
|
|
688
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
const imports = __wbg_get_imports();
|
|
693
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
694
|
+
module = new WebAssembly.Module(module);
|
|
695
|
+
}
|
|
696
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
697
|
+
return __wbg_finalize_init(instance, module);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
async function __wbg_init(module_or_path) {
|
|
701
|
+
if (wasm !== undefined) return wasm;
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
if (module_or_path !== undefined) {
|
|
705
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
706
|
+
({module_or_path} = module_or_path)
|
|
707
|
+
} else {
|
|
708
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
if (module_or_path === undefined) {
|
|
713
|
+
module_or_path = new URL('carve_wasm_bg.wasm', import.meta.url);
|
|
714
|
+
}
|
|
715
|
+
const imports = __wbg_get_imports();
|
|
716
|
+
|
|
717
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
718
|
+
module_or_path = fetch(module_or_path);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
722
|
+
|
|
723
|
+
return __wbg_finalize_init(instance, module);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export { initSync, __wbg_init as default };
|