markstone 0.1.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Actos Authors
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/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # markstone
2
+
3
+ Unified Node.js and browser package for markstone: fast, safe Markdown-to-HTML and AST engine with Actos extensions.
4
+
5
+ Uses native napi-rs addon on Node.js and WebAssembly (`wasm-bindgen`) in browsers via conditional `exports`. Both paths produce byte-for-byte identical output.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install markstone
11
+ ```
12
+
13
+ Prebuilt addons ship for Linux (x64 and arm64, glibc 2.28+ and musl), macOS
14
+ (x64 and arm64) and Windows (x64 and arm64). On any other platform, Node
15
+ falls back to the WebAssembly build with no extra setup.
16
+
17
+ ## Usage
18
+
19
+ ### Node.js (Native Addon)
20
+
21
+ ```javascript
22
+ import markstone, { toHtml, toAst, actos } from 'markstone';
23
+
24
+ // Generic CommonMark + GFM
25
+ const html = toHtml('# Hello world');
26
+ const ast = toAst('# Hello world');
27
+
28
+ // Actos extensions (@mentions and #tags)
29
+ const actosHtml = actos.toHtml('Hello @alice and #rust');
30
+ const actosAst = actos.toAst('Hello @alice and #rust');
31
+ ```
32
+
33
+ ### Browser (WebAssembly)
34
+
35
+ ```javascript
36
+ import markstone, { init, toHtml, toAst, actos } from 'markstone';
37
+
38
+ // Initialize WASM binary once in browser
39
+ await init();
40
+
41
+ // Render
42
+ const html = toHtml('# Hello from the browser');
43
+ const actosHtml = actos.toHtml('Hello @alice and #rust');
44
+ ```
45
+
46
+ ## Security & Conformance
47
+
48
+ - No raw HTML or dangerous scripts pass through the AST sanitizer.
49
+ - Depth limit: 64 block levels (`DEPTH_EXCEEDED`).
50
+ - Input limit: 4 MiB (`INPUT_TOO_LARGE`).
51
+ - 100% byte-for-byte conformance parity between Node native and browser WASM.
package/browser.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ export * from './index.js';
2
+
3
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
4
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
5
+
6
+ /**
7
+ * Initializes the WebAssembly module asynchronously.
8
+ * In a browser, passing no arguments fetches the wasm binary relative to the module.
9
+ */
10
+ export function init(moduleOrPath?: InitInput | Promise<InitInput>): Promise<unknown>;
11
+
12
+ /**
13
+ * Synchronously initializes the WebAssembly module from bytes or compiled module.
14
+ */
15
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): unknown;
16
+
17
+ import markstone from './index.js';
18
+
19
+ export interface MarkstoneBrowserBinding extends typeof markstone {
20
+ init: typeof init;
21
+ initSync: typeof initSync;
22
+ }
23
+
24
+ declare const markstoneBrowser: MarkstoneBrowserBinding;
25
+ export default markstoneBrowser;
package/browser.js ADDED
@@ -0,0 +1,148 @@
1
+ import initWasm, {
2
+ initSync as wasmInitSync,
3
+ toHtml as wasmToHtml,
4
+ to_html as wasm_to_html,
5
+ toAst as wasmToAst,
6
+ to_ast as wasm_to_ast,
7
+ actosToHtml as wasmActosToHtml,
8
+ actos_to_html as wasm_actos_to_html,
9
+ actosToAst as wasmActosToAst,
10
+ actos_to_ast as wasm_actos_to_ast,
11
+ astSchemaVersion as wasmAstSchemaVersion,
12
+ ast_schema_version as wasm_ast_schema_version,
13
+ version as wasmVersion,
14
+ } from './wasm/markstone_wasm.js';
15
+
16
+ let isInitialized = false;
17
+
18
+ function ensureInitialized() {
19
+ if (isInitialized) return;
20
+ // If in Node.js, attempt synchronous auto-initialization from local wasm file
21
+ if (typeof process !== 'undefined' && process.versions && process.versions.node) {
22
+ try {
23
+ // In CommonJS or Node environments with require
24
+ const fs = typeof require !== 'undefined' ? require('node:fs') : null;
25
+ const path = typeof require !== 'undefined' ? require('node:path') : null;
26
+ if (fs && path) {
27
+ const wasmPath = path.join(__dirname, 'wasm', 'markstone_wasm_bg.wasm');
28
+ if (fs.existsSync(wasmPath)) {
29
+ wasmInitSync({ module: fs.readFileSync(wasmPath) });
30
+ isInitialized = true;
31
+ return;
32
+ }
33
+ }
34
+ } catch (_) {
35
+ // Fall through
36
+ }
37
+ }
38
+
39
+ // Check if wasm-bindgen already initialized wasm
40
+ try {
41
+ wasmVersion();
42
+ isInitialized = true;
43
+ return;
44
+ } catch (_) {
45
+ // Not yet initialized
46
+ }
47
+
48
+ throw new Error(
49
+ 'markstone WASM module is not initialized. Please call "await init()" before using markstone in the browser.'
50
+ );
51
+ }
52
+
53
+ function sanitizeInput(input) {
54
+ if (typeof input === 'string') {
55
+ return input;
56
+ }
57
+ if (
58
+ (typeof Buffer !== 'undefined' && Buffer.isBuffer(input)) ||
59
+ input instanceof Uint8Array
60
+ ) {
61
+ try {
62
+ const decoder = new TextDecoder('utf-8', { fatal: true });
63
+ return decoder.decode(input);
64
+ } catch (_) {
65
+ const err = new Error('invalid utf-8 byte sequence');
66
+ err.code = 'INVALID_UTF8';
67
+ throw err;
68
+ }
69
+ }
70
+ throw new TypeError('input must be a string or Buffer');
71
+ }
72
+
73
+ export function toHtml(input) {
74
+ ensureInitialized();
75
+ return wasmToHtml(sanitizeInput(input));
76
+ }
77
+
78
+ export function to_html(input) {
79
+ return toHtml(input);
80
+ }
81
+
82
+ export function toAst(input) {
83
+ ensureInitialized();
84
+ return wasmToAst(sanitizeInput(input));
85
+ }
86
+
87
+ export function to_ast(input) {
88
+ return toAst(input);
89
+ }
90
+
91
+ export function astSchemaVersion() {
92
+ ensureInitialized();
93
+ return wasmAstSchemaVersion();
94
+ }
95
+
96
+ export function ast_schema_version() {
97
+ return astSchemaVersion();
98
+ }
99
+
100
+ export const AST_SCHEMA_VERSION = 1;
101
+ export const version = '0.1.0';
102
+
103
+ export const actos = {
104
+ toHtml(input) {
105
+ ensureInitialized();
106
+ return wasmActosToHtml(sanitizeInput(input));
107
+ },
108
+ to_html(input) {
109
+ return actos.toHtml(input);
110
+ },
111
+ toAst(input) {
112
+ ensureInitialized();
113
+ return wasmActosToAst(sanitizeInput(input));
114
+ },
115
+ to_ast(input) {
116
+ return actos.toAst(input);
117
+ },
118
+ astSchemaVersion,
119
+ ast_schema_version,
120
+ AST_SCHEMA_VERSION,
121
+ version,
122
+ };
123
+
124
+ export async function init(moduleOrPath) {
125
+ const result = await initWasm(moduleOrPath);
126
+ isInitialized = true;
127
+ return result;
128
+ }
129
+
130
+ export function initSync(module) {
131
+ const result = wasmInitSync(module);
132
+ isInitialized = true;
133
+ return result;
134
+ }
135
+
136
+ export default {
137
+ toHtml,
138
+ to_html,
139
+ toAst,
140
+ to_ast,
141
+ astSchemaVersion,
142
+ ast_schema_version,
143
+ AST_SCHEMA_VERSION,
144
+ version,
145
+ actos,
146
+ init,
147
+ initSync,
148
+ };
package/fallback.js ADDED
@@ -0,0 +1,34 @@
1
+ // Entry point for Node and other non-browser runtimes: the native addon when
2
+ // this platform has one, the WebAssembly build otherwise.
3
+ let binding;
4
+
5
+ try {
6
+ binding = await import('./index.js');
7
+ } catch (_) {
8
+ // No addon for this platform, or it failed to load.
9
+ }
10
+
11
+ if (!binding) {
12
+ binding = await import('./browser.js');
13
+ if (typeof process !== 'undefined' && process.versions?.node) {
14
+ const { readFileSync } = await import('node:fs');
15
+ const wasm = readFileSync(new URL('./wasm/markstone_wasm_bg.wasm', import.meta.url));
16
+ binding.initSync({ module: wasm });
17
+ }
18
+ }
19
+
20
+ export const {
21
+ toHtml,
22
+ to_html,
23
+ toAst,
24
+ to_ast,
25
+ astSchemaVersion,
26
+ ast_schema_version,
27
+ AST_SCHEMA_VERSION,
28
+ version,
29
+ actos,
30
+ init,
31
+ initSync,
32
+ } = binding;
33
+
34
+ export default binding.default || binding;
package/index.d.ts ADDED
@@ -0,0 +1,247 @@
1
+ /**
2
+ * Position of a node in source markdown: [start_line, start_col, end_line, end_col], 1-based.
3
+ */
4
+ export type NodePosition = [number, number, number, number];
5
+
6
+ export type TableAlignment = 'none' | 'left' | 'center' | 'right';
7
+
8
+ export interface BaseAstNode {
9
+ type: string;
10
+ pos: NodePosition;
11
+ children?: AstNode[];
12
+ }
13
+
14
+ export interface DocumentNode extends BaseAstNode {
15
+ type: 'document';
16
+ children: AstNode[];
17
+ }
18
+
19
+ export interface ParagraphNode extends BaseAstNode {
20
+ type: 'paragraph';
21
+ children: AstNode[];
22
+ }
23
+
24
+ export interface HeadingNode extends BaseAstNode {
25
+ type: 'heading';
26
+ level: 1 | 2 | 3 | 4 | 5 | 6;
27
+ children: AstNode[];
28
+ }
29
+
30
+ export interface BlockQuoteNode extends BaseAstNode {
31
+ type: 'block_quote';
32
+ children: AstNode[];
33
+ }
34
+
35
+ export interface ListNode extends BaseAstNode {
36
+ type: 'list';
37
+ ordered: boolean;
38
+ start?: number;
39
+ tight: boolean;
40
+ children: AstNode[];
41
+ }
42
+
43
+ export interface ListItemNode extends BaseAstNode {
44
+ type: 'list_item';
45
+ children: AstNode[];
46
+ }
47
+
48
+ export interface TaskItemNode extends BaseAstNode {
49
+ type: 'task_item';
50
+ checked: boolean;
51
+ children: AstNode[];
52
+ }
53
+
54
+ export interface CodeBlockNode extends BaseAstNode {
55
+ type: 'code_block';
56
+ language?: string;
57
+ value: string;
58
+ }
59
+
60
+ export interface ThematicBreakNode extends BaseAstNode {
61
+ type: 'thematic_break';
62
+ }
63
+
64
+ export interface TableNode extends BaseAstNode {
65
+ type: 'table';
66
+ alignments: TableAlignment[];
67
+ children: AstNode[];
68
+ }
69
+
70
+ export interface TableRowNode extends BaseAstNode {
71
+ type: 'table_row';
72
+ header: boolean;
73
+ children: AstNode[];
74
+ }
75
+
76
+ export interface TableCellNode extends BaseAstNode {
77
+ type: 'table_cell';
78
+ children: AstNode[];
79
+ }
80
+
81
+ export interface TextNode extends BaseAstNode {
82
+ type: 'text';
83
+ value: string;
84
+ }
85
+
86
+ export interface EmphasisNode extends BaseAstNode {
87
+ type: 'emphasis';
88
+ children: AstNode[];
89
+ }
90
+
91
+ export interface StrongNode extends BaseAstNode {
92
+ type: 'strong';
93
+ children: AstNode[];
94
+ }
95
+
96
+ export interface StrikethroughNode extends BaseAstNode {
97
+ type: 'strikethrough';
98
+ children: AstNode[];
99
+ }
100
+
101
+ export interface CodeNode extends BaseAstNode {
102
+ type: 'code';
103
+ value: string;
104
+ }
105
+
106
+ export interface LinkNode extends BaseAstNode {
107
+ type: 'link';
108
+ url: string;
109
+ title?: string;
110
+ children: AstNode[];
111
+ }
112
+
113
+ export interface ImageNode extends BaseAstNode {
114
+ type: 'image';
115
+ url: string;
116
+ title?: string;
117
+ children: AstNode[];
118
+ }
119
+
120
+ export interface SoftBreakNode extends BaseAstNode {
121
+ type: 'soft_break';
122
+ }
123
+
124
+ export interface LineBreakNode extends BaseAstNode {
125
+ type: 'line_break';
126
+ }
127
+
128
+ export interface FootnoteDefinitionNode extends BaseAstNode {
129
+ type: 'footnote_definition';
130
+ name: string;
131
+ children: AstNode[];
132
+ }
133
+
134
+ export interface FootnoteReferenceNode extends BaseAstNode {
135
+ type: 'footnote_reference';
136
+ name: string;
137
+ }
138
+
139
+ export interface MentionNode extends BaseAstNode {
140
+ type: 'mention';
141
+ username: string;
142
+ text: string;
143
+ }
144
+
145
+ export interface TagNode extends BaseAstNode {
146
+ type: 'tag';
147
+ name: string;
148
+ text: string;
149
+ }
150
+
151
+ export type AstNode =
152
+ | DocumentNode
153
+ | ParagraphNode
154
+ | HeadingNode
155
+ | BlockQuoteNode
156
+ | ListNode
157
+ | ListItemNode
158
+ | TaskItemNode
159
+ | CodeBlockNode
160
+ | ThematicBreakNode
161
+ | TableNode
162
+ | TableRowNode
163
+ | TableCellNode
164
+ | TextNode
165
+ | EmphasisNode
166
+ | StrongNode
167
+ | StrikethroughNode
168
+ | CodeNode
169
+ | LinkNode
170
+ | ImageNode
171
+ | SoftBreakNode
172
+ | LineBreakNode
173
+ | FootnoteDefinitionNode
174
+ | FootnoteReferenceNode
175
+ | MentionNode
176
+ | TagNode;
177
+
178
+ export interface AstDocument {
179
+ schema: number;
180
+ root: DocumentNode;
181
+ }
182
+
183
+ /**
184
+ * Converts Markdown string or buffer to safe HTML using generic CommonMark + GFM pipeline.
185
+ */
186
+ export function toHtml(input: string | Uint8Array): string;
187
+ export function to_html(input: string | Uint8Array): string;
188
+
189
+ /**
190
+ * Converts Markdown string or buffer to AST JSON string using generic CommonMark + GFM pipeline.
191
+ */
192
+ export function toAst(input: string | Uint8Array): string;
193
+ export function to_ast(input: string | Uint8Array): string;
194
+
195
+ /**
196
+ * Returns the current AST schema version (currently 1).
197
+ */
198
+ export function astSchemaVersion(): number;
199
+ export function ast_schema_version(): number;
200
+
201
+ /**
202
+ * AST JSON schema version constant.
203
+ */
204
+ export const AST_SCHEMA_VERSION: number;
205
+
206
+ /**
207
+ * markstone package version.
208
+ */
209
+ export const version: string;
210
+
211
+ /**
212
+ * Actos-specific extensions (@mentions and #tags).
213
+ */
214
+ export namespace actos {
215
+ /**
216
+ * Converts Markdown string or buffer to safe HTML with Actos extensions (@mentions, #tags).
217
+ */
218
+ export function toHtml(input: string | Uint8Array): string;
219
+ export function to_html(input: string | Uint8Array): string;
220
+
221
+ /**
222
+ * Converts Markdown string or buffer to AST JSON string with Actos extensions (@mentions, #tags).
223
+ */
224
+ export function toAst(input: string | Uint8Array): string;
225
+ export function to_ast(input: string | Uint8Array): string;
226
+
227
+ export function astSchemaVersion(): number;
228
+ export function ast_schema_version(): number;
229
+
230
+ export const AST_SCHEMA_VERSION: number;
231
+ export const version: string;
232
+ }
233
+
234
+ export interface MarkstoneBinding {
235
+ toHtml: typeof toHtml;
236
+ to_html: typeof to_html;
237
+ toAst: typeof toAst;
238
+ to_ast: typeof to_ast;
239
+ astSchemaVersion: typeof astSchemaVersion;
240
+ ast_schema_version: typeof ast_schema_version;
241
+ AST_SCHEMA_VERSION: typeof AST_SCHEMA_VERSION;
242
+ version: typeof version;
243
+ actos: typeof actos;
244
+ }
245
+
246
+ declare const markstone: MarkstoneBinding;
247
+ export default markstone;
package/index.js ADDED
@@ -0,0 +1,121 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import path from 'node:path';
3
+ import fs from 'node:fs';
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+
7
+ // Published packages carry one prebuilt addon per platform, named after the
8
+ // platform tag below. `markstone.node` is a local build (`npm run
9
+ // build:native`) and wins when present.
10
+ function isMusl() {
11
+ if (process.platform !== 'linux') return false;
12
+ const report = process.report?.getReport?.();
13
+ const header = typeof report === 'string' ? JSON.parse(report).header : report?.header;
14
+ return !header?.glibcVersionRuntime;
15
+ }
16
+
17
+ function platformTag() {
18
+ const base = `${process.platform}-${process.arch}`;
19
+ if (process.platform !== 'linux') return base;
20
+ return `${base}-${isMusl() ? 'musl' : 'gnu'}`;
21
+ }
22
+
23
+ function loadNativeBinding() {
24
+ const tag = platformTag();
25
+ const candidates = [
26
+ path.join(__dirname, 'markstone.node'),
27
+ path.join(__dirname, `markstone.${tag}.node`),
28
+ ];
29
+
30
+ const failures = [];
31
+ for (const candidate of candidates) {
32
+ if (!fs.existsSync(candidate)) continue;
33
+ try {
34
+ const addon = { exports: {} };
35
+ process.dlopen(addon, candidate);
36
+ return addon.exports;
37
+ } catch (err) {
38
+ failures.push(`${path.basename(candidate)}: ${err.message}`);
39
+ }
40
+ }
41
+
42
+ const detail = failures.length > 0 ? ` (${failures.join('; ')})` : '';
43
+ throw new Error(`markstone has no native addon for ${tag}${detail}`);
44
+ }
45
+
46
+ const binding = loadNativeBinding();
47
+
48
+ function sanitizeInput(input) {
49
+ if (typeof input === 'string') {
50
+ return input;
51
+ }
52
+ if (Buffer.isBuffer(input) || input instanceof Uint8Array) {
53
+ try {
54
+ const decoder = new TextDecoder('utf-8', { fatal: true });
55
+ return decoder.decode(input);
56
+ } catch (_) {
57
+ const err = new Error('invalid utf-8 byte sequence');
58
+ err.code = 'INVALID_UTF8';
59
+ throw err;
60
+ }
61
+ }
62
+ throw new TypeError('input must be a string or Buffer');
63
+ }
64
+
65
+ export function toHtml(input) {
66
+ return binding.toHtml(sanitizeInput(input));
67
+ }
68
+
69
+ export function to_html(input) {
70
+ return toHtml(input);
71
+ }
72
+
73
+ export function toAst(input) {
74
+ return binding.toAst(sanitizeInput(input));
75
+ }
76
+
77
+ export function to_ast(input) {
78
+ return toAst(input);
79
+ }
80
+
81
+ export function astSchemaVersion() {
82
+ return binding.astSchemaVersion ? binding.astSchemaVersion() : binding.AST_SCHEMA_VERSION;
83
+ }
84
+
85
+ export function ast_schema_version() {
86
+ return astSchemaVersion();
87
+ }
88
+
89
+ export const AST_SCHEMA_VERSION = binding.AST_SCHEMA_VERSION ?? 1;
90
+ export const version = typeof binding.version === 'function' ? binding.version() : (binding.version || '0.1.0');
91
+
92
+ export const actos = {
93
+ toHtml(input) {
94
+ return binding.actos.toHtml(sanitizeInput(input));
95
+ },
96
+ to_html(input) {
97
+ return binding.actos.to_html(sanitizeInput(input));
98
+ },
99
+ toAst(input) {
100
+ return binding.actos.toAst(sanitizeInput(input));
101
+ },
102
+ to_ast(input) {
103
+ return binding.actos.to_ast(sanitizeInput(input));
104
+ },
105
+ astSchemaVersion,
106
+ ast_schema_version,
107
+ AST_SCHEMA_VERSION,
108
+ version,
109
+ };
110
+
111
+ export default {
112
+ toHtml,
113
+ to_html,
114
+ toAst,
115
+ to_ast,
116
+ astSchemaVersion,
117
+ ast_schema_version,
118
+ AST_SCHEMA_VERSION,
119
+ version,
120
+ actos,
121
+ };
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "markstone",
3
+ "version": "0.1.0",
4
+ "description": "Fast, safe Markdown-to-HTML and AST engine with Actos extensions for Node.js and the browser",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "browser": "browser.js",
8
+ "types": "index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "node": {
12
+ "types": "./index.d.ts",
13
+ "default": "./fallback.js"
14
+ },
15
+ "browser": {
16
+ "types": "./browser.d.ts",
17
+ "default": "./browser.js"
18
+ },
19
+ "default": {
20
+ "types": "./index.d.ts",
21
+ "default": "./fallback.js"
22
+ }
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "files": [
27
+ "index.js",
28
+ "index.d.ts",
29
+ "browser.js",
30
+ "browser.d.ts",
31
+ "fallback.js",
32
+ "markstone.*.node",
33
+ "wasm/markstone_wasm.js",
34
+ "wasm/markstone_wasm.d.ts",
35
+ "wasm/markstone_wasm_bg.wasm",
36
+ "wasm/markstone_wasm_bg.wasm.d.ts",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "scripts": {
41
+ "build:native": "cargo build --release -p markstone-node && cp ../../target/release/libmarkstone_node.so ./markstone.node",
42
+ "build:wasm": "npx wasm-pack build ../wasm --target web --out-dir ../node/wasm && rm -f wasm/.gitignore",
43
+ "build": "npm run build:native && npm run build:wasm",
44
+ "test": "node --test test/index.test.js",
45
+ "prepack": "node -e \"require('node:fs').copyFileSync('../../LICENSE', 'LICENSE')\""
46
+ },
47
+ "devDependencies": {
48
+ "@napi-rs/cli": "^3.0.0"
49
+ },
50
+ "engines": {
51
+ "node": ">=18"
52
+ },
53
+ "license": "MIT",
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/actos-dev/markstone.git",
57
+ "directory": "bindings/node"
58
+ },
59
+ "keywords": [
60
+ "markdown",
61
+ "commonmark",
62
+ "gfm",
63
+ "sanitizer",
64
+ "html",
65
+ "ast",
66
+ "actos"
67
+ ]
68
+ }
package/wasm/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # markstone-wasm
2
+
3
+ WebAssembly crate (`wasm-bindgen`) for markstone: fast, safe Markdown-to-HTML and AST engine with Actos extensions.
4
+
5
+ Compiled via `wasm-pack` and bundled into the unified `markstone` npm package under `bindings/node/wasm`.
@@ -0,0 +1,68 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function actosToAst(input: string): string;
5
+
6
+ export function actosToHtml(input: string): string;
7
+
8
+ export function actos_to_ast(input: string): string;
9
+
10
+ export function actos_to_html(input: string): string;
11
+
12
+ export function astSchemaVersion(): number;
13
+
14
+ export function ast_schema_version(): number;
15
+
16
+ export function toAst(input: string): string;
17
+
18
+ export function toHtml(input: string): string;
19
+
20
+ export function to_ast(input: string): string;
21
+
22
+ export function to_html(input: string): string;
23
+
24
+ export function version(): string;
25
+
26
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
27
+
28
+ export interface InitOutput {
29
+ readonly memory: WebAssembly.Memory;
30
+ readonly actosToAst: (a: number, b: number, c: number) => void;
31
+ readonly actosToHtml: (a: number, b: number, c: number) => void;
32
+ readonly actos_to_ast: (a: number, b: number, c: number) => void;
33
+ readonly actos_to_html: (a: number, b: number, c: number) => void;
34
+ readonly astSchemaVersion: () => number;
35
+ readonly ast_schema_version: () => number;
36
+ readonly toAst: (a: number, b: number, c: number) => void;
37
+ readonly toHtml: (a: number, b: number, c: number) => void;
38
+ readonly to_ast: (a: number, b: number, c: number) => void;
39
+ readonly to_html: (a: number, b: number, c: number) => void;
40
+ readonly version: (a: number) => void;
41
+ readonly __wbindgen_export: (a: number) => void;
42
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
43
+ readonly __wbindgen_export2: (a: number, b: number) => number;
44
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
45
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
46
+ }
47
+
48
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
49
+
50
+ /**
51
+ * Instantiates the given `module`, which can either be bytes or
52
+ * a precompiled `WebAssembly.Module`.
53
+ *
54
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
55
+ *
56
+ * @returns {InitOutput}
57
+ */
58
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
59
+
60
+ /**
61
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
62
+ * for everything else, calls `WebAssembly.instantiate` directly.
63
+ *
64
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
65
+ *
66
+ * @returns {Promise<InitOutput>}
67
+ */
68
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,532 @@
1
+ /* @ts-self-types="./markstone_wasm.d.ts" */
2
+
3
+ /**
4
+ * @param {string} input
5
+ * @returns {string}
6
+ */
7
+ export function actosToAst(input) {
8
+ let deferred3_0;
9
+ let deferred3_1;
10
+ try {
11
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
12
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
13
+ const len0 = WASM_VECTOR_LEN;
14
+ wasm.actosToAst(retptr, ptr0, len0);
15
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
16
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
17
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
18
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
19
+ var ptr2 = r0;
20
+ var len2 = r1;
21
+ if (r3) {
22
+ ptr2 = 0; len2 = 0;
23
+ throw takeObject(r2);
24
+ }
25
+ deferred3_0 = ptr2;
26
+ deferred3_1 = len2;
27
+ return getStringFromWasm0(ptr2, len2);
28
+ } finally {
29
+ wasm.__wbindgen_add_to_stack_pointer(16);
30
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * @param {string} input
36
+ * @returns {string}
37
+ */
38
+ export function actosToHtml(input) {
39
+ let deferred3_0;
40
+ let deferred3_1;
41
+ try {
42
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
43
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
44
+ const len0 = WASM_VECTOR_LEN;
45
+ wasm.actosToHtml(retptr, ptr0, len0);
46
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
47
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
48
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
49
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
50
+ var ptr2 = r0;
51
+ var len2 = r1;
52
+ if (r3) {
53
+ ptr2 = 0; len2 = 0;
54
+ throw takeObject(r2);
55
+ }
56
+ deferred3_0 = ptr2;
57
+ deferred3_1 = len2;
58
+ return getStringFromWasm0(ptr2, len2);
59
+ } finally {
60
+ wasm.__wbindgen_add_to_stack_pointer(16);
61
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
62
+ }
63
+ }
64
+
65
+ /**
66
+ * @param {string} input
67
+ * @returns {string}
68
+ */
69
+ export function actos_to_ast(input) {
70
+ let deferred3_0;
71
+ let deferred3_1;
72
+ try {
73
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
74
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
75
+ const len0 = WASM_VECTOR_LEN;
76
+ wasm.actos_to_ast(retptr, ptr0, len0);
77
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
78
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
79
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
80
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
81
+ var ptr2 = r0;
82
+ var len2 = r1;
83
+ if (r3) {
84
+ ptr2 = 0; len2 = 0;
85
+ throw takeObject(r2);
86
+ }
87
+ deferred3_0 = ptr2;
88
+ deferred3_1 = len2;
89
+ return getStringFromWasm0(ptr2, len2);
90
+ } finally {
91
+ wasm.__wbindgen_add_to_stack_pointer(16);
92
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
93
+ }
94
+ }
95
+
96
+ /**
97
+ * @param {string} input
98
+ * @returns {string}
99
+ */
100
+ export function actos_to_html(input) {
101
+ let deferred3_0;
102
+ let deferred3_1;
103
+ try {
104
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
105
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
106
+ const len0 = WASM_VECTOR_LEN;
107
+ wasm.actos_to_html(retptr, ptr0, len0);
108
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
109
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
110
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
111
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
112
+ var ptr2 = r0;
113
+ var len2 = r1;
114
+ if (r3) {
115
+ ptr2 = 0; len2 = 0;
116
+ throw takeObject(r2);
117
+ }
118
+ deferred3_0 = ptr2;
119
+ deferred3_1 = len2;
120
+ return getStringFromWasm0(ptr2, len2);
121
+ } finally {
122
+ wasm.__wbindgen_add_to_stack_pointer(16);
123
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
124
+ }
125
+ }
126
+
127
+ /**
128
+ * @returns {number}
129
+ */
130
+ export function astSchemaVersion() {
131
+ const ret = wasm.astSchemaVersion();
132
+ return ret >>> 0;
133
+ }
134
+
135
+ /**
136
+ * @returns {number}
137
+ */
138
+ export function ast_schema_version() {
139
+ const ret = wasm.ast_schema_version();
140
+ return ret >>> 0;
141
+ }
142
+
143
+ /**
144
+ * @param {string} input
145
+ * @returns {string}
146
+ */
147
+ export function toAst(input) {
148
+ let deferred3_0;
149
+ let deferred3_1;
150
+ try {
151
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
152
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
153
+ const len0 = WASM_VECTOR_LEN;
154
+ wasm.toAst(retptr, ptr0, len0);
155
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
156
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
157
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
158
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
159
+ var ptr2 = r0;
160
+ var len2 = r1;
161
+ if (r3) {
162
+ ptr2 = 0; len2 = 0;
163
+ throw takeObject(r2);
164
+ }
165
+ deferred3_0 = ptr2;
166
+ deferred3_1 = len2;
167
+ return getStringFromWasm0(ptr2, len2);
168
+ } finally {
169
+ wasm.__wbindgen_add_to_stack_pointer(16);
170
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
171
+ }
172
+ }
173
+
174
+ /**
175
+ * @param {string} input
176
+ * @returns {string}
177
+ */
178
+ export function toHtml(input) {
179
+ let deferred3_0;
180
+ let deferred3_1;
181
+ try {
182
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
183
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
184
+ const len0 = WASM_VECTOR_LEN;
185
+ wasm.toHtml(retptr, ptr0, len0);
186
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
187
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
188
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
189
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
190
+ var ptr2 = r0;
191
+ var len2 = r1;
192
+ if (r3) {
193
+ ptr2 = 0; len2 = 0;
194
+ throw takeObject(r2);
195
+ }
196
+ deferred3_0 = ptr2;
197
+ deferred3_1 = len2;
198
+ return getStringFromWasm0(ptr2, len2);
199
+ } finally {
200
+ wasm.__wbindgen_add_to_stack_pointer(16);
201
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
202
+ }
203
+ }
204
+
205
+ /**
206
+ * @param {string} input
207
+ * @returns {string}
208
+ */
209
+ export function to_ast(input) {
210
+ let deferred3_0;
211
+ let deferred3_1;
212
+ try {
213
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
214
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
215
+ const len0 = WASM_VECTOR_LEN;
216
+ wasm.to_ast(retptr, ptr0, len0);
217
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
218
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
219
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
220
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
221
+ var ptr2 = r0;
222
+ var len2 = r1;
223
+ if (r3) {
224
+ ptr2 = 0; len2 = 0;
225
+ throw takeObject(r2);
226
+ }
227
+ deferred3_0 = ptr2;
228
+ deferred3_1 = len2;
229
+ return getStringFromWasm0(ptr2, len2);
230
+ } finally {
231
+ wasm.__wbindgen_add_to_stack_pointer(16);
232
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
233
+ }
234
+ }
235
+
236
+ /**
237
+ * @param {string} input
238
+ * @returns {string}
239
+ */
240
+ export function to_html(input) {
241
+ let deferred3_0;
242
+ let deferred3_1;
243
+ try {
244
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
245
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
246
+ const len0 = WASM_VECTOR_LEN;
247
+ wasm.to_html(retptr, ptr0, len0);
248
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
249
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
250
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
251
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
252
+ var ptr2 = r0;
253
+ var len2 = r1;
254
+ if (r3) {
255
+ ptr2 = 0; len2 = 0;
256
+ throw takeObject(r2);
257
+ }
258
+ deferred3_0 = ptr2;
259
+ deferred3_1 = len2;
260
+ return getStringFromWasm0(ptr2, len2);
261
+ } finally {
262
+ wasm.__wbindgen_add_to_stack_pointer(16);
263
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
264
+ }
265
+ }
266
+
267
+ /**
268
+ * @returns {string}
269
+ */
270
+ export function version() {
271
+ let deferred1_0;
272
+ let deferred1_1;
273
+ try {
274
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
275
+ wasm.version(retptr);
276
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
277
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
278
+ deferred1_0 = r0;
279
+ deferred1_1 = r1;
280
+ return getStringFromWasm0(r0, r1);
281
+ } finally {
282
+ wasm.__wbindgen_add_to_stack_pointer(16);
283
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
284
+ }
285
+ }
286
+ function __wbg_get_imports() {
287
+ const import0 = {
288
+ __proto__: null,
289
+ __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
290
+ throw new Error(getStringFromWasm0(arg0, arg1));
291
+ },
292
+ __wbg_new_a32a1ab6c6655abe: function(arg0, arg1) {
293
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
294
+ return addHeapObject(ret);
295
+ },
296
+ __wbg_set_a377297433dfea63: function() { return handleError(function (arg0, arg1, arg2) {
297
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
298
+ return ret;
299
+ }, arguments); },
300
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
301
+ // Cast intrinsic for `Ref(String) -> Externref`.
302
+ const ret = getStringFromWasm0(arg0, arg1);
303
+ return addHeapObject(ret);
304
+ },
305
+ __wbindgen_object_drop_ref: function(arg0) {
306
+ takeObject(arg0);
307
+ },
308
+ };
309
+ return {
310
+ __proto__: null,
311
+ "./markstone_wasm_bg.js": import0,
312
+ };
313
+ }
314
+
315
+ function addHeapObject(obj) {
316
+ if (heap_next === heap.length) heap.push(heap.length + 1);
317
+ const idx = heap_next;
318
+ heap_next = heap[idx];
319
+
320
+ heap[idx] = obj;
321
+ return idx;
322
+ }
323
+
324
+ function dropObject(idx) {
325
+ if (idx < 1028) return;
326
+ heap[idx] = heap_next;
327
+ heap_next = idx;
328
+ }
329
+
330
+ let cachedDataViewMemory0 = null;
331
+ function getDataViewMemory0() {
332
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
333
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
334
+ }
335
+ return cachedDataViewMemory0;
336
+ }
337
+
338
+ function getStringFromWasm0(ptr, len) {
339
+ return decodeText(ptr >>> 0, len);
340
+ }
341
+
342
+ let cachedUint8ArrayMemory0 = null;
343
+ function getUint8ArrayMemory0() {
344
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
345
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
346
+ }
347
+ return cachedUint8ArrayMemory0;
348
+ }
349
+
350
+ function getObject(idx) { return heap[idx]; }
351
+
352
+ function handleError(f, args) {
353
+ try {
354
+ return f.apply(this, args);
355
+ } catch (e) {
356
+ wasm.__wbindgen_export(addHeapObject(e));
357
+ }
358
+ }
359
+
360
+ let heap = new Array(1024).fill(undefined);
361
+ heap.push(undefined, null, true, false);
362
+
363
+ let heap_next = heap.length;
364
+
365
+ function passStringToWasm0(arg, malloc, realloc) {
366
+ if (realloc === undefined) {
367
+ const buf = cachedTextEncoder.encode(arg);
368
+ const ptr = malloc(buf.length, 1) >>> 0;
369
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
370
+ WASM_VECTOR_LEN = buf.length;
371
+ return ptr;
372
+ }
373
+
374
+ let len = arg.length;
375
+ let ptr = malloc(len, 1) >>> 0;
376
+
377
+ const mem = getUint8ArrayMemory0();
378
+
379
+ let offset = 0;
380
+
381
+ for (; offset < len; offset++) {
382
+ const code = arg.charCodeAt(offset);
383
+ if (code > 0x7F) break;
384
+ mem[ptr + offset] = code;
385
+ }
386
+ if (offset !== len) {
387
+ if (offset !== 0) {
388
+ arg = arg.slice(offset);
389
+ }
390
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
391
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
392
+ const ret = cachedTextEncoder.encodeInto(arg, view);
393
+
394
+ offset += ret.written;
395
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
396
+ }
397
+
398
+ WASM_VECTOR_LEN = offset;
399
+ return ptr;
400
+ }
401
+
402
+ function takeObject(idx) {
403
+ const ret = getObject(idx);
404
+ dropObject(idx);
405
+ return ret;
406
+ }
407
+
408
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
409
+ cachedTextDecoder.decode();
410
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
411
+ let numBytesDecoded = 0;
412
+ function decodeText(ptr, len) {
413
+ numBytesDecoded += len;
414
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
415
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
416
+ cachedTextDecoder.decode();
417
+ numBytesDecoded = len;
418
+ }
419
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
420
+ }
421
+
422
+ const cachedTextEncoder = new TextEncoder();
423
+
424
+ if (!('encodeInto' in cachedTextEncoder)) {
425
+ cachedTextEncoder.encodeInto = function (arg, view) {
426
+ const buf = cachedTextEncoder.encode(arg);
427
+ view.set(buf);
428
+ return {
429
+ read: arg.length,
430
+ written: buf.length
431
+ };
432
+ };
433
+ }
434
+
435
+ let WASM_VECTOR_LEN = 0;
436
+
437
+ let wasmModule, wasmInstance, wasm;
438
+ function __wbg_finalize_init(instance, module) {
439
+ wasmInstance = instance;
440
+ wasm = instance.exports;
441
+ wasmModule = module;
442
+ cachedDataViewMemory0 = null;
443
+ cachedUint8ArrayMemory0 = null;
444
+ return wasm;
445
+ }
446
+
447
+ async function __wbg_load(module, imports) {
448
+ if (typeof Response === 'function' && module instanceof Response) {
449
+ if (!module.ok) {
450
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
451
+ }
452
+
453
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
454
+ try {
455
+ return await WebAssembly.instantiateStreaming(module, imports);
456
+ } catch (e) {
457
+ const validResponse = expectedResponseType(module.type);
458
+
459
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
460
+ 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);
461
+
462
+ } else { throw e; }
463
+ }
464
+ }
465
+
466
+ const bytes = await module.arrayBuffer();
467
+ return await WebAssembly.instantiate(bytes, imports);
468
+ } else {
469
+ const instance = await WebAssembly.instantiate(module, imports);
470
+
471
+ if (instance instanceof WebAssembly.Instance) {
472
+ return { instance, module };
473
+ } else {
474
+ return instance;
475
+ }
476
+ }
477
+
478
+ function expectedResponseType(type) {
479
+ switch (type) {
480
+ case 'basic': case 'cors': case 'default': return true;
481
+ }
482
+ return false;
483
+ }
484
+ }
485
+
486
+ function initSync(module) {
487
+ if (wasm !== undefined) return wasm;
488
+
489
+
490
+ if (module !== undefined) {
491
+ if (Object.getPrototypeOf(module) === Object.prototype) {
492
+ ({module} = module)
493
+ } else {
494
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
495
+ }
496
+ }
497
+
498
+ const imports = __wbg_get_imports();
499
+ if (!(module instanceof WebAssembly.Module)) {
500
+ module = new WebAssembly.Module(module);
501
+ }
502
+ const instance = new WebAssembly.Instance(module, imports);
503
+ return __wbg_finalize_init(instance, module);
504
+ }
505
+
506
+ async function __wbg_init(module_or_path) {
507
+ if (wasm !== undefined) return wasm;
508
+
509
+
510
+ if (module_or_path !== undefined) {
511
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
512
+ ({module_or_path} = module_or_path)
513
+ } else {
514
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
515
+ }
516
+ }
517
+
518
+ if (module_or_path === undefined) {
519
+ module_or_path = new URL('markstone_wasm_bg.wasm', import.meta.url);
520
+ }
521
+ const imports = __wbg_get_imports();
522
+
523
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
524
+ module_or_path = fetch(module_or_path);
525
+ }
526
+
527
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
528
+
529
+ return __wbg_finalize_init(instance, module);
530
+ }
531
+
532
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,19 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const actosToAst: (a: number, b: number, c: number) => void;
5
+ export const actosToHtml: (a: number, b: number, c: number) => void;
6
+ export const actos_to_ast: (a: number, b: number, c: number) => void;
7
+ export const actos_to_html: (a: number, b: number, c: number) => void;
8
+ export const astSchemaVersion: () => number;
9
+ export const ast_schema_version: () => number;
10
+ export const toAst: (a: number, b: number, c: number) => void;
11
+ export const toHtml: (a: number, b: number, c: number) => void;
12
+ export const to_ast: (a: number, b: number, c: number) => void;
13
+ export const to_html: (a: number, b: number, c: number) => void;
14
+ export const version: (a: number) => void;
15
+ export const __wbindgen_export: (a: number) => void;
16
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
17
+ export const __wbindgen_export2: (a: number, b: number) => number;
18
+ export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
19
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;