@gmb/bitmark-parser 3.0.1-alpha.3 → 3.0.1-alpha.5
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/dist/browser/bitmark-parser.min.js +1 -1
- package/dist/browser/bitmark-parser.min.js.map +1 -1
- package/dist/browser/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/index.cjs +57 -14
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +126 -66
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +126 -66
- package/dist/browser/esm/index.js +55 -13
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/cli.js +37 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +19 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +83 -19
- package/dist/index.d.ts +83 -19
- package/dist/index.js +19 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/wasm/bitmark_wasm.d.ts +10 -13
- package/wasm/bitmark_wasm.js +21 -20
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createRequire } from "module";
|
|
|
4
4
|
// src/generated/package_info.ts
|
|
5
5
|
var PACKAGE_INFO = {
|
|
6
6
|
"name": "@gmb/bitmark-parser",
|
|
7
|
-
"version": "3.0.1-alpha.
|
|
7
|
+
"version": "3.0.1-alpha.5",
|
|
8
8
|
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
@@ -16,22 +16,31 @@ var wasm = require2("../wasm/bitmark_wasm.js");
|
|
|
16
16
|
function version() {
|
|
17
17
|
return PACKAGE_INFO.version;
|
|
18
18
|
}
|
|
19
|
-
function lex(input,
|
|
20
|
-
return wasm.lex(input,
|
|
19
|
+
function lex(input, options = {}) {
|
|
20
|
+
return wasm.lex(input, options.stage ?? "lex");
|
|
21
21
|
}
|
|
22
|
-
function parse(input,
|
|
23
|
-
return wasm.parse(input,
|
|
22
|
+
function parse(input, options = {}) {
|
|
23
|
+
return wasm.parse(input, options.mode ?? "optimized");
|
|
24
24
|
}
|
|
25
|
-
function convert(input,
|
|
26
|
-
return wasm.convert(input,
|
|
25
|
+
function convert(input, options = {}) {
|
|
26
|
+
return wasm.convert(input, options.mode ?? "optimized", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);
|
|
27
27
|
}
|
|
28
|
-
function breakscapeText(input,
|
|
28
|
+
function breakscapeText(input, options = {}) {
|
|
29
|
+
const format = options.format ?? "bitmark++";
|
|
30
|
+
const location = options.location ?? "body";
|
|
29
31
|
return wasm.breakscape_text(input, format, location);
|
|
30
32
|
}
|
|
31
|
-
function unbreakscapeText(input,
|
|
33
|
+
function unbreakscapeText(input, options = {}) {
|
|
34
|
+
const format = options.format ?? "bitmark++";
|
|
35
|
+
const location = options.location ?? "body";
|
|
32
36
|
return wasm.unbreakscape_text(input, format, location);
|
|
33
37
|
}
|
|
34
|
-
function info(
|
|
38
|
+
function info(options = {}) {
|
|
39
|
+
const infoType = options.infoType ?? "list";
|
|
40
|
+
const format = options.format ?? "text";
|
|
41
|
+
const bit = options.bit ?? "";
|
|
42
|
+
const pretty = options.pretty ?? false;
|
|
43
|
+
const indent = options.indent ?? 2;
|
|
35
44
|
return wasm.info(infoType, format, bit, pretty, indent);
|
|
36
45
|
}
|
|
37
46
|
function generate(_json) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/generated/package_info.ts"],"sourcesContent":["// @zen-component: WASM-TSBindings\n\nimport { createRequire } from \"node:module\";\nimport { PACKAGE_INFO } from \"./generated/package_info.js\";\nconst require = createRequire(import.meta.url);\nconst wasm = require(\"../wasm/bitmark_wasm.js\") as typeof import(\"../wasm/bitmark_wasm.js\");\n\n/**\n * Get the version of the @gmb/bitmark-parser library.\n *\n * @returns Version string (e.g. \"3.0.0\").\n */\nexport function version(): string {\n return PACKAGE_INFO.version;\n}\n\n/**\n * Lex bitmark input text, returning one line per token.\n *\n * @param input - The bitmark source text.\n * @param
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/generated/package_info.ts"],"sourcesContent":["// @zen-component: WASM-TSBindings\n\nimport { createRequire } from \"node:module\";\nimport { PACKAGE_INFO } from \"./generated/package_info.js\";\nimport type { LexOptions, ParseOptions, ConvertOptions, BreakscapeOptions, InfoOptions } from \"./types.js\";\nconst require = createRequire(import.meta.url);\nconst wasm = require(\"../wasm/bitmark_wasm.js\") as typeof import(\"../wasm/bitmark_wasm.js\");\n\nexport type { LexOptions, LexStage, ParseOptions, ConvertOptions, OutputMode, BreakscapeOptions, TextFormat, TextLocation, InfoOptions, InfoType, InfoFormat } from \"./types.js\";\n\n/**\n * Get the version of the @gmb/bitmark-parser library.\n *\n * @returns Version string (e.g. \"3.0.0\").\n */\nexport function version(): string {\n return PACKAGE_INFO.version;\n}\n\n/**\n * Lex bitmark input text, returning one line per token.\n *\n * @param input - The bitmark source text.\n * @param options - Lex options (e.g. `{ stage: \"lex-bitmark\" }`).\n * @returns Token dump string (one token per line).\n */\nexport function lex(input: string, options: LexOptions = {}): string {\n return wasm.lex(input, options.stage ?? \"lex\");\n}\n\n/**\n * Parse bitmark input text and return the reference JSON format.\n *\n * @param input - The bitmark source text.\n * @param options - Parse options (e.g. `{ mode: \"full\" }`).\n * @returns JSON string of the parsed bitmark document.\n */\nexport function parse(input: string, options: ParseOptions = {}): string {\n return wasm.parse(input, options.mode ?? \"optimized\");\n}\n\n/**\n * Auto-detect input format and convert between bitmark and JSON.\n *\n * @param input - Bitmark or JSON input text.\n * @param options - Convert options (e.g. `{ mode: \"full\", warnings: true }`).\n * @returns Converted output string.\n */\nexport function convert(input: string, options: ConvertOptions = {}): string {\n return wasm.convert(input, options.mode ?? \"optimized\", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);\n}\n\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * @param input - The text to breakscape.\n * @param options - Breakscape options (e.g. `{ format: \"plainText\", location: \"tag\" }`).\n * @returns Breakscaped text.\n */\nexport function breakscapeText(input: string, options: BreakscapeOptions = {}): string {\n const format = options.format ?? \"bitmark++\";\n const location = options.location ?? \"body\";\n return wasm.breakscape_text(input, format, location);\n}\n\n/**\n * Unbreakscape text (unescape bitmark special characters).\n *\n * @param input - The text to unbreakscape.\n * @param options - Unbreakscape options (e.g. `{ format: \"plainText\", location: \"tag\" }`).\n * @returns Unbreakscaped text.\n */\nexport function unbreakscapeText(input: string, options: BreakscapeOptions = {}): string {\n const format = options.format ?? \"bitmark++\";\n const location = options.location ?? \"body\";\n return wasm.unbreakscape_text(input, format, location);\n}\n\n/**\n * Query information about supported bit types.\n *\n * @param options - Info options (e.g. `{ infoType: \"bit\", format: \"json\", bit: \"cloze\" }`).\n * @returns Information string.\n */\nexport function info(options: InfoOptions = {}): string {\n const infoType = options.infoType ?? \"list\";\n const format = options.format ?? \"text\";\n const bit = options.bit ?? \"\";\n const pretty = options.pretty ?? false;\n const indent = options.indent ?? 2;\n return wasm.info(infoType, format, bit, pretty, indent);\n}\n\n/**\n * Generate bitmark text from a JSON AST.\n *\n * @param _json - JSON string of the AST.\n * @throws Always throws — not yet implemented.\n */\nexport function generate(_json: string): string {\n throw new Error(\"generate is not yet implemented\");\n}\n","// This file is automatically generated. DO NOT EDIT.\n\n/* eslint-disable */\n\nexport const PACKAGE_INFO = {\n \"name\": \"@gmb/bitmark-parser\",\n \"version\": \"3.0.1-alpha.5\",\n \"author\": \"Get More Brain Ltd <info@getmorebrain.com>\",\n \"license\": \"ISC\",\n \"description\": \"A parser for bitmark text, powered by WebAssembly.\"\n};\n"],"mappings":";A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AAC9C,QAAM,IAAI,MAAM,iCAAiC;AACnD;","names":["require"]}
|
package/package.json
CHANGED
package/wasm/bitmark_wasm.d.ts
CHANGED
|
@@ -19,24 +19,22 @@ export function unbreakscape_text(input: string, format: string, location: strin
|
|
|
19
19
|
*
|
|
20
20
|
* Uses the full pipeline: parse → validate → serialize.
|
|
21
21
|
*
|
|
22
|
-
* `
|
|
23
|
-
* - `"mode"`: `"optimized"` (default) or `"full"`
|
|
22
|
+
* `mode`: `"optimized"` (default) or `"full"`
|
|
24
23
|
*/
|
|
25
|
-
export function parse(input: string,
|
|
24
|
+
export function parse(input: string, mode: string): string;
|
|
26
25
|
/**
|
|
27
26
|
* Auto-detect input format and convert between bitmark and JSON.
|
|
28
27
|
*
|
|
29
|
-
* `
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* - `"indent"`: number (default: 2)
|
|
28
|
+
* `mode`: `"optimized"` (default) or `"full"`
|
|
29
|
+
* `warnings`: whether to include validation warnings (default: false)
|
|
30
|
+
* `plain_text`: output text as plain text — debug mode (default: false)
|
|
31
|
+
* `pretty`: prettify JSON output (default: false)
|
|
32
|
+
* `indent`: indent size for pretty-printing (default: 2)
|
|
35
33
|
*
|
|
36
34
|
* Returns JSON if input is bitmark, or an error message if input is JSON
|
|
37
35
|
* (generator not yet implemented).
|
|
38
36
|
*/
|
|
39
|
-
export function convert(input: string,
|
|
37
|
+
export function convert(input: string, mode: string, warnings: boolean, plain_text: boolean, pretty: boolean, indent: number): string;
|
|
40
38
|
/**
|
|
41
39
|
* Query information about supported bit types.
|
|
42
40
|
*
|
|
@@ -51,8 +49,7 @@ export function info(info_type: string, format: string, bit: string, pretty: boo
|
|
|
51
49
|
* Lex bitmark input text, returning one line per token in the same format as
|
|
52
50
|
* the Rust CLI: `{kind:?} {span:?} "{text}"`.
|
|
53
51
|
*
|
|
54
|
-
* `
|
|
55
|
-
* - `"stage"`: selects the lexer pipeline:
|
|
52
|
+
* `stage` selects the lexer pipeline:
|
|
56
53
|
* - `"lex"` — combined (default)
|
|
57
54
|
* - `"lex-bitmark"` — bitmark-level only
|
|
58
55
|
* - `"lex-text"` — text-level only
|
|
@@ -60,4 +57,4 @@ export function info(info_type: string, format: string, bit: string, pretty: boo
|
|
|
60
57
|
* - `"lex-bitmark-json"` — bitmark-level, JSON array output
|
|
61
58
|
* - `"lex-text-json"` — text-level, JSON array output
|
|
62
59
|
*/
|
|
63
|
-
export function lex(input: string,
|
|
60
|
+
export function lex(input: string, stage: string): string;
|
package/wasm/bitmark_wasm.js
CHANGED
|
@@ -156,20 +156,19 @@ module.exports.unbreakscape_text = function(input, format, location) {
|
|
|
156
156
|
*
|
|
157
157
|
* Uses the full pipeline: parse → validate → serialize.
|
|
158
158
|
*
|
|
159
|
-
* `
|
|
160
|
-
* - `"mode"`: `"optimized"` (default) or `"full"`
|
|
159
|
+
* `mode`: `"optimized"` (default) or `"full"`
|
|
161
160
|
* @param {string} input
|
|
162
|
-
* @param {string}
|
|
161
|
+
* @param {string} mode
|
|
163
162
|
* @returns {string}
|
|
164
163
|
*/
|
|
165
|
-
module.exports.parse = function(input,
|
|
164
|
+
module.exports.parse = function(input, mode) {
|
|
166
165
|
let deferred3_0;
|
|
167
166
|
let deferred3_1;
|
|
168
167
|
try {
|
|
169
168
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
170
169
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
171
170
|
const len0 = WASM_VECTOR_LEN;
|
|
172
|
-
const ptr1 = passStringToWasm0(
|
|
171
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
173
172
|
const len1 = WASM_VECTOR_LEN;
|
|
174
173
|
wasm.parse(retptr, ptr0, len0, ptr1, len1);
|
|
175
174
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
@@ -186,29 +185,32 @@ module.exports.parse = function(input, options_json) {
|
|
|
186
185
|
/**
|
|
187
186
|
* Auto-detect input format and convert between bitmark and JSON.
|
|
188
187
|
*
|
|
189
|
-
* `
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* - `"indent"`: number (default: 2)
|
|
188
|
+
* `mode`: `"optimized"` (default) or `"full"`
|
|
189
|
+
* `warnings`: whether to include validation warnings (default: false)
|
|
190
|
+
* `plain_text`: output text as plain text — debug mode (default: false)
|
|
191
|
+
* `pretty`: prettify JSON output (default: false)
|
|
192
|
+
* `indent`: indent size for pretty-printing (default: 2)
|
|
195
193
|
*
|
|
196
194
|
* Returns JSON if input is bitmark, or an error message if input is JSON
|
|
197
195
|
* (generator not yet implemented).
|
|
198
196
|
* @param {string} input
|
|
199
|
-
* @param {string}
|
|
197
|
+
* @param {string} mode
|
|
198
|
+
* @param {boolean} warnings
|
|
199
|
+
* @param {boolean} plain_text
|
|
200
|
+
* @param {boolean} pretty
|
|
201
|
+
* @param {number} indent
|
|
200
202
|
* @returns {string}
|
|
201
203
|
*/
|
|
202
|
-
module.exports.convert = function(input,
|
|
204
|
+
module.exports.convert = function(input, mode, warnings, plain_text, pretty, indent) {
|
|
203
205
|
let deferred3_0;
|
|
204
206
|
let deferred3_1;
|
|
205
207
|
try {
|
|
206
208
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
207
209
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
208
210
|
const len0 = WASM_VECTOR_LEN;
|
|
209
|
-
const ptr1 = passStringToWasm0(
|
|
211
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
210
212
|
const len1 = WASM_VECTOR_LEN;
|
|
211
|
-
wasm.convert(retptr, ptr0, len0, ptr1, len1);
|
|
213
|
+
wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);
|
|
212
214
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
213
215
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
214
216
|
deferred3_0 = r0;
|
|
@@ -262,8 +264,7 @@ module.exports.info = function(info_type, format, bit, pretty, indent) {
|
|
|
262
264
|
* Lex bitmark input text, returning one line per token in the same format as
|
|
263
265
|
* the Rust CLI: `{kind:?} {span:?} "{text}"`.
|
|
264
266
|
*
|
|
265
|
-
* `
|
|
266
|
-
* - `"stage"`: selects the lexer pipeline:
|
|
267
|
+
* `stage` selects the lexer pipeline:
|
|
267
268
|
* - `"lex"` — combined (default)
|
|
268
269
|
* - `"lex-bitmark"` — bitmark-level only
|
|
269
270
|
* - `"lex-text"` — text-level only
|
|
@@ -271,17 +272,17 @@ module.exports.info = function(info_type, format, bit, pretty, indent) {
|
|
|
271
272
|
* - `"lex-bitmark-json"` — bitmark-level, JSON array output
|
|
272
273
|
* - `"lex-text-json"` — text-level, JSON array output
|
|
273
274
|
* @param {string} input
|
|
274
|
-
* @param {string}
|
|
275
|
+
* @param {string} stage
|
|
275
276
|
* @returns {string}
|
|
276
277
|
*/
|
|
277
|
-
module.exports.lex = function(input,
|
|
278
|
+
module.exports.lex = function(input, stage) {
|
|
278
279
|
let deferred3_0;
|
|
279
280
|
let deferred3_1;
|
|
280
281
|
try {
|
|
281
282
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
282
283
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
283
284
|
const len0 = WASM_VECTOR_LEN;
|
|
284
|
-
const ptr1 = passStringToWasm0(
|
|
285
|
+
const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
285
286
|
const len1 = WASM_VECTOR_LEN;
|
|
286
287
|
wasm.lex(retptr, ptr0, len0, ptr1, len1);
|
|
287
288
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
Binary file
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const breakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
5
|
-
export const convert: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
5
|
+
export const convert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
6
6
|
export const info: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
7
7
|
export const lex: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
8
|
export const parse: (a: number, b: number, c: number, d: number, e: number) => void;
|