@gmb/bitmark-parser 3.0.1-alpha.2 → 3.0.1-alpha.4
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 +92 -11
- 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 +47 -16
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +121 -63
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +121 -63
- package/dist/browser/esm/index.js +47 -16
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/cli.js +38 -16
- 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 -18
- package/dist/index.d.ts +83 -18
- package/dist/index.js +19 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/wasm/bitmark_wasm.d.ts +16 -15
- package/wasm/bitmark_wasm.js +32 -24
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +2 -2
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.4",
|
|
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, stage);
|
|
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.4\",\n \"author\": \"Get More Brain Ltd <info@getmorebrain.com>\",\n \"license\": \"ISC\",\n \"description\": \"A parser for bitmark text, powered by WebAssembly.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SAAS,SAAS,OAAuB;AAC9C,QAAM,IAAI,MAAM,iCAAiC;AACnD;","names":["require"]}
|
package/package.json
CHANGED
package/wasm/bitmark_wasm.d.ts
CHANGED
|
@@ -17,23 +17,24 @@ export function unbreakscape_text(input: string, format: string, location: strin
|
|
|
17
17
|
/**
|
|
18
18
|
* Parse bitmark input text and return the reference JSON format.
|
|
19
19
|
*
|
|
20
|
-
* Uses the full pipeline: parse → validate → serialize
|
|
20
|
+
* Uses the full pipeline: parse → validate → serialize.
|
|
21
|
+
*
|
|
22
|
+
* `mode`: `"optimized"` (default) or `"full"`
|
|
21
23
|
*/
|
|
22
|
-
export function parse(input: string): string;
|
|
24
|
+
export function parse(input: string, mode: string): string;
|
|
23
25
|
/**
|
|
24
26
|
* Auto-detect input format and convert between bitmark and JSON.
|
|
25
27
|
*
|
|
26
|
-
* `
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* - `"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)
|
|
32
33
|
*
|
|
33
34
|
* Returns JSON if input is bitmark, or an error message if input is JSON
|
|
34
35
|
* (generator not yet implemented).
|
|
35
36
|
*/
|
|
36
|
-
export function convert(input: string,
|
|
37
|
+
export function convert(input: string, mode: string, warnings: boolean, plain_text: boolean, pretty: boolean, indent: number): string;
|
|
37
38
|
/**
|
|
38
39
|
* Query information about supported bit types.
|
|
39
40
|
*
|
|
@@ -49,11 +50,11 @@ export function info(info_type: string, format: string, bit: string, pretty: boo
|
|
|
49
50
|
* the Rust CLI: `{kind:?} {span:?} "{text}"`.
|
|
50
51
|
*
|
|
51
52
|
* `stage` selects the lexer pipeline:
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
53
|
+
* - `"lex"` — combined (default)
|
|
54
|
+
* - `"lex-bitmark"` — bitmark-level only
|
|
55
|
+
* - `"lex-text"` — text-level only
|
|
56
|
+
* - `"lex-json"` — combined, JSON array output
|
|
57
|
+
* - `"lex-bitmark-json"` — bitmark-level, JSON array output
|
|
58
|
+
* - `"lex-text-json"` — text-level, JSON array output
|
|
58
59
|
*/
|
|
59
60
|
export function lex(input: string, stage: string): string;
|
package/wasm/bitmark_wasm.js
CHANGED
|
@@ -154,55 +154,63 @@ module.exports.unbreakscape_text = function(input, format, location) {
|
|
|
154
154
|
/**
|
|
155
155
|
* Parse bitmark input text and return the reference JSON format.
|
|
156
156
|
*
|
|
157
|
-
* Uses the full pipeline: parse → validate → serialize
|
|
157
|
+
* Uses the full pipeline: parse → validate → serialize.
|
|
158
|
+
*
|
|
159
|
+
* `mode`: `"optimized"` (default) or `"full"`
|
|
158
160
|
* @param {string} input
|
|
161
|
+
* @param {string} mode
|
|
159
162
|
* @returns {string}
|
|
160
163
|
*/
|
|
161
|
-
module.exports.parse = function(input) {
|
|
162
|
-
let
|
|
163
|
-
let
|
|
164
|
+
module.exports.parse = function(input, mode) {
|
|
165
|
+
let deferred3_0;
|
|
166
|
+
let deferred3_1;
|
|
164
167
|
try {
|
|
165
168
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
166
169
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
167
170
|
const len0 = WASM_VECTOR_LEN;
|
|
168
|
-
|
|
171
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
172
|
+
const len1 = WASM_VECTOR_LEN;
|
|
173
|
+
wasm.parse(retptr, ptr0, len0, ptr1, len1);
|
|
169
174
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
170
175
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
deferred3_0 = r0;
|
|
177
|
+
deferred3_1 = r1;
|
|
173
178
|
return getStringFromWasm0(r0, r1);
|
|
174
179
|
} finally {
|
|
175
180
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
176
|
-
wasm.__wbindgen_export_2(
|
|
181
|
+
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
177
182
|
}
|
|
178
183
|
};
|
|
179
184
|
|
|
180
185
|
/**
|
|
181
186
|
* Auto-detect input format and convert between bitmark and JSON.
|
|
182
187
|
*
|
|
183
|
-
* `
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* - `"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)
|
|
189
193
|
*
|
|
190
194
|
* Returns JSON if input is bitmark, or an error message if input is JSON
|
|
191
195
|
* (generator not yet implemented).
|
|
192
196
|
* @param {string} input
|
|
193
|
-
* @param {string}
|
|
197
|
+
* @param {string} mode
|
|
198
|
+
* @param {boolean} warnings
|
|
199
|
+
* @param {boolean} plain_text
|
|
200
|
+
* @param {boolean} pretty
|
|
201
|
+
* @param {number} indent
|
|
194
202
|
* @returns {string}
|
|
195
203
|
*/
|
|
196
|
-
module.exports.convert = function(input,
|
|
204
|
+
module.exports.convert = function(input, mode, warnings, plain_text, pretty, indent) {
|
|
197
205
|
let deferred3_0;
|
|
198
206
|
let deferred3_1;
|
|
199
207
|
try {
|
|
200
208
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
201
209
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
202
210
|
const len0 = WASM_VECTOR_LEN;
|
|
203
|
-
const ptr1 = passStringToWasm0(
|
|
211
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
204
212
|
const len1 = WASM_VECTOR_LEN;
|
|
205
|
-
wasm.convert(retptr, ptr0, len0, ptr1, len1);
|
|
213
|
+
wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);
|
|
206
214
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
207
215
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
208
216
|
deferred3_0 = r0;
|
|
@@ -257,12 +265,12 @@ module.exports.info = function(info_type, format, bit, pretty, indent) {
|
|
|
257
265
|
* the Rust CLI: `{kind:?} {span:?} "{text}"`.
|
|
258
266
|
*
|
|
259
267
|
* `stage` selects the lexer pipeline:
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
268
|
+
* - `"lex"` — combined (default)
|
|
269
|
+
* - `"lex-bitmark"` — bitmark-level only
|
|
270
|
+
* - `"lex-text"` — text-level only
|
|
271
|
+
* - `"lex-json"` — combined, JSON array output
|
|
272
|
+
* - `"lex-bitmark-json"` — bitmark-level, JSON array output
|
|
273
|
+
* - `"lex-text-json"` — text-level, JSON array output
|
|
266
274
|
* @param {string} input
|
|
267
275
|
* @param {string} stage
|
|
268
276
|
* @returns {string}
|
|
Binary file
|
|
@@ -2,10 +2,10 @@
|
|
|
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
|
-
export const parse: (a: number, b: number, c: number) => void;
|
|
8
|
+
export const parse: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
9
9
|
export const unbreakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
10
10
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
11
11
|
export const __wbindgen_export_0: (a: number, b: number) => number;
|