@gmb/bitmark-parser 3.0.1-alpha.5 → 3.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../../../node_modules/tsup/assets/cjs_shims.js","../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","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ADV9D,yBAA8B;;;AEEvB,IAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,eAAe;AACjB;;;AFLA,IAAMA,eAAU,kCAAc,aAAe;AAC7C,IAAM,OAAOA,SAAQ,yBAAyB;AASvC,SAAS,UAAkB;AAChC,SAAO,aAAa;AACtB;AASO,SAAS,IAAI,OAAe,UAAsB,CAAC,GAAW;AACnE,SAAO,KAAK,IAAI,OAAO,QAAQ,SAAS,KAAK;AAC/C;AASO,SAAS,MAAM,OAAe,UAAwB,CAAC,GAAW;AACvE,SAAO,KAAK,MAAM,OAAO,QAAQ,QAAQ,WAAW;AACtD;AASO,SAAS,QAAQ,OAAe,UAA0B,CAAC,GAAW;AAC3E,SAAO,KAAK,QAAQ,OAAO,QAAQ,QAAQ,aAAa,QAAQ,YAAY,OAAO,QAAQ,aAAa,OAAO,QAAQ,UAAU,OAAO,QAAQ,UAAU,CAAC;AAC7J;AASO,SAAS,eAAe,OAAe,UAA6B,CAAC,GAAW;AACrF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAO,KAAK,gBAAgB,OAAO,QAAQ,QAAQ;AACrD;AASO,SAAS,iBAAiB,OAAe,UAA6B,CAAC,GAAW;AACvF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAO,KAAK,kBAAkB,OAAO,QAAQ,QAAQ;AACvD;AAQO,SAAS,KAAK,UAAuB,CAAC,GAAW;AACtD,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,MAAM,QAAQ,OAAO;AAC3B,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,SAAS,QAAQ,UAAU;AACjC,SAAO,KAAK,KAAK,UAAU,QAAQ,KAAK,QAAQ,MAAM;AACxD;AAQO,SAAS,SAAS,OAAuB;AAC9C,QAAM,IAAI,MAAM,iCAAiC;AACnD;","names":["require"]}
1
+ {"version":3,"sources":["../src/index.ts","../../../node_modules/tsup/assets/cjs_shims.js","../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\" }`).\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 structured JSON entries.\n *\n * Each entry contains `bit`, `parser`, and `bitmark` fields.\n *\n * @param input - The bitmark source text.\n * @param options - Parse options (e.g. `{ mode: \"full\" }`).\n * @returns JSON string array of structured parsed entries.\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. For bitmark input, this is a JSON string\n * array of structured parsed entries (`bit`, `parser`, `bitmark`).\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","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\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.3\",\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ADV9D,yBAA8B;;;AEEvB,IAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,eAAe;AACjB;;;AFLA,IAAMA,eAAU,kCAAc,aAAe;AAC7C,IAAM,OAAOA,SAAQ,yBAAyB;AASvC,SAAS,UAAkB;AAChC,SAAO,aAAa;AACtB;AASO,SAAS,IAAI,OAAe,UAAsB,CAAC,GAAW;AACnE,SAAO,KAAK,IAAI,OAAO,QAAQ,SAAS,KAAK;AAC/C;AAWO,SAAS,MAAM,OAAe,UAAwB,CAAC,GAAW;AACvE,SAAO,KAAK,MAAM,OAAO,QAAQ,QAAQ,WAAW;AACtD;AAUO,SAAS,QAAQ,OAAe,UAA0B,CAAC,GAAW;AAC3E,SAAO,KAAK,QAAQ,OAAO,QAAQ,QAAQ,aAAa,QAAQ,YAAY,OAAO,QAAQ,aAAa,OAAO,QAAQ,UAAU,OAAO,QAAQ,UAAU,CAAC;AAC7J;AASO,SAAS,eAAe,OAAe,UAA6B,CAAC,GAAW;AACrF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAO,KAAK,gBAAgB,OAAO,QAAQ,QAAQ;AACrD;AASO,SAAS,iBAAiB,OAAe,UAA6B,CAAC,GAAW;AACvF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAO,KAAK,kBAAkB,OAAO,QAAQ,QAAQ;AACvD;AAQO,SAAS,KAAK,UAAuB,CAAC,GAAW;AACtD,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,MAAM,QAAQ,OAAO;AAC3B,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,SAAS,QAAQ,UAAU;AACjC,SAAO,KAAK,KAAK,UAAU,QAAQ,KAAK,QAAQ,MAAM;AACxD;AAQO,SAAS,SAAS,OAAuB;AAC9C,QAAM,IAAI,MAAM,iCAAiC;AACnD;","names":["require"]}
package/dist/index.d.cts CHANGED
@@ -9,13 +9,9 @@ type OutputMode = "optimized" | "full";
9
9
  * Lexer stage selector.
10
10
  *
11
11
  * - `"lex"` — combined lexer, text output (default).
12
- * - `"lex-bitmark"` — bitmark-level only, text output.
13
- * - `"lex-text"` — text-level only, text output.
14
12
  * - `"lex-json"` — combined lexer, JSON array output.
15
- * - `"lex-bitmark-json"` — bitmark-level only, JSON array output.
16
- * - `"lex-text-json"` — text-level only, JSON array output.
17
13
  */
18
- type LexStage = "lex" | "lex-bitmark" | "lex-text" | "lex-json" | "lex-bitmark-json" | "lex-text-json";
14
+ type LexStage = "lex" | "lex-json";
19
15
  /** Options for the {@link lex} function. */
20
16
  interface LexOptions {
21
17
  /** Selects the lexer pipeline stage (default: `"lex"`). */
@@ -30,7 +26,7 @@ interface ParseOptions {
30
26
  interface ConvertOptions {
31
27
  /** JSON output mode (default: `"optimized"`). */
32
28
  mode?: OutputMode;
33
- /** Include validation warnings in output (default: `false`). */
29
+ /** Include validation warnings in `parser.warnings` output (default: `false`). */
34
30
  warnings?: boolean;
35
31
  /** Output text as plain text — debug mode (default: `false`). */
36
32
  plainText?: boolean;
@@ -78,16 +74,18 @@ declare function version(): string;
78
74
  * Lex bitmark input text, returning one line per token.
79
75
  *
80
76
  * @param input - The bitmark source text.
81
- * @param options - Lex options (e.g. `{ stage: "lex-bitmark" }`).
77
+ * @param options - Lex options (e.g. `{ stage: "lex" }`).
82
78
  * @returns Token dump string (one token per line).
83
79
  */
84
80
  declare function lex(input: string, options?: LexOptions): string;
85
81
  /**
86
- * Parse bitmark input text and return the reference JSON format.
82
+ * Parse bitmark input text and return structured JSON entries.
83
+ *
84
+ * Each entry contains `bit`, `parser`, and `bitmark` fields.
87
85
  *
88
86
  * @param input - The bitmark source text.
89
87
  * @param options - Parse options (e.g. `{ mode: "full" }`).
90
- * @returns JSON string of the parsed bitmark document.
88
+ * @returns JSON string array of structured parsed entries.
91
89
  */
92
90
  declare function parse(input: string, options?: ParseOptions): string;
93
91
  /**
@@ -95,7 +93,8 @@ declare function parse(input: string, options?: ParseOptions): string;
95
93
  *
96
94
  * @param input - Bitmark or JSON input text.
97
95
  * @param options - Convert options (e.g. `{ mode: "full", warnings: true }`).
98
- * @returns Converted output string.
96
+ * @returns Converted output string. For bitmark input, this is a JSON string
97
+ * array of structured parsed entries (`bit`, `parser`, `bitmark`).
99
98
  */
100
99
  declare function convert(input: string, options?: ConvertOptions): string;
101
100
  /**
package/dist/index.d.ts CHANGED
@@ -9,13 +9,9 @@ type OutputMode = "optimized" | "full";
9
9
  * Lexer stage selector.
10
10
  *
11
11
  * - `"lex"` — combined lexer, text output (default).
12
- * - `"lex-bitmark"` — bitmark-level only, text output.
13
- * - `"lex-text"` — text-level only, text output.
14
12
  * - `"lex-json"` — combined lexer, JSON array output.
15
- * - `"lex-bitmark-json"` — bitmark-level only, JSON array output.
16
- * - `"lex-text-json"` — text-level only, JSON array output.
17
13
  */
18
- type LexStage = "lex" | "lex-bitmark" | "lex-text" | "lex-json" | "lex-bitmark-json" | "lex-text-json";
14
+ type LexStage = "lex" | "lex-json";
19
15
  /** Options for the {@link lex} function. */
20
16
  interface LexOptions {
21
17
  /** Selects the lexer pipeline stage (default: `"lex"`). */
@@ -30,7 +26,7 @@ interface ParseOptions {
30
26
  interface ConvertOptions {
31
27
  /** JSON output mode (default: `"optimized"`). */
32
28
  mode?: OutputMode;
33
- /** Include validation warnings in output (default: `false`). */
29
+ /** Include validation warnings in `parser.warnings` output (default: `false`). */
34
30
  warnings?: boolean;
35
31
  /** Output text as plain text — debug mode (default: `false`). */
36
32
  plainText?: boolean;
@@ -78,16 +74,18 @@ declare function version(): string;
78
74
  * Lex bitmark input text, returning one line per token.
79
75
  *
80
76
  * @param input - The bitmark source text.
81
- * @param options - Lex options (e.g. `{ stage: "lex-bitmark" }`).
77
+ * @param options - Lex options (e.g. `{ stage: "lex" }`).
82
78
  * @returns Token dump string (one token per line).
83
79
  */
84
80
  declare function lex(input: string, options?: LexOptions): string;
85
81
  /**
86
- * Parse bitmark input text and return the reference JSON format.
82
+ * Parse bitmark input text and return structured JSON entries.
83
+ *
84
+ * Each entry contains `bit`, `parser`, and `bitmark` fields.
87
85
  *
88
86
  * @param input - The bitmark source text.
89
87
  * @param options - Parse options (e.g. `{ mode: "full" }`).
90
- * @returns JSON string of the parsed bitmark document.
88
+ * @returns JSON string array of structured parsed entries.
91
89
  */
92
90
  declare function parse(input: string, options?: ParseOptions): string;
93
91
  /**
@@ -95,7 +93,8 @@ declare function parse(input: string, options?: ParseOptions): string;
95
93
  *
96
94
  * @param input - Bitmark or JSON input text.
97
95
  * @param options - Convert options (e.g. `{ mode: "full", warnings: true }`).
98
- * @returns Converted output string.
96
+ * @returns Converted output string. For bitmark input, this is a JSON string
97
+ * array of structured parsed entries (`bit`, `parser`, `bitmark`).
99
98
  */
100
99
  declare function convert(input: string, options?: ConvertOptions): string;
101
100
  /**
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.5",
7
+ "version": "3.0.3",
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."
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\";\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":";AAEA,SAAS,qBAAqB;;;ACEvB,IAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,eAAe;AACjB;;;ADLA,IAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,OAAOA,SAAQ,yBAAyB;AASvC,SAAS,UAAkB;AAChC,SAAO,aAAa;AACtB;AASO,SAAS,IAAI,OAAe,UAAsB,CAAC,GAAW;AACnE,SAAO,KAAK,IAAI,OAAO,QAAQ,SAAS,KAAK;AAC/C;AASO,SAAS,MAAM,OAAe,UAAwB,CAAC,GAAW;AACvE,SAAO,KAAK,MAAM,OAAO,QAAQ,QAAQ,WAAW;AACtD;AASO,SAAS,QAAQ,OAAe,UAA0B,CAAC,GAAW;AAC3E,SAAO,KAAK,QAAQ,OAAO,QAAQ,QAAQ,aAAa,QAAQ,YAAY,OAAO,QAAQ,aAAa,OAAO,QAAQ,UAAU,OAAO,QAAQ,UAAU,CAAC;AAC7J;AASO,SAAS,eAAe,OAAe,UAA6B,CAAC,GAAW;AACrF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAO,KAAK,gBAAgB,OAAO,QAAQ,QAAQ;AACrD;AASO,SAAS,iBAAiB,OAAe,UAA6B,CAAC,GAAW;AACvF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAO,KAAK,kBAAkB,OAAO,QAAQ,QAAQ;AACvD;AAQO,SAAS,KAAK,UAAuB,CAAC,GAAW;AACtD,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,MAAM,QAAQ,OAAO;AAC3B,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,SAAS,QAAQ,UAAU;AACjC,SAAO,KAAK,KAAK,UAAU,QAAQ,KAAK,QAAQ,MAAM;AACxD;AAQO,SAAS,SAAS,OAAuB;AAC9C,QAAM,IAAI,MAAM,iCAAiC;AACnD;","names":["require"]}
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\" }`).\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 structured JSON entries.\n *\n * Each entry contains `bit`, `parser`, and `bitmark` fields.\n *\n * @param input - The bitmark source text.\n * @param options - Parse options (e.g. `{ mode: \"full\" }`).\n * @returns JSON string array of structured parsed entries.\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. For bitmark input, this is a JSON string\n * array of structured parsed entries (`bit`, `parser`, `bitmark`).\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.3\",\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":";AAEA,SAAS,qBAAqB;;;ACEvB,IAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,eAAe;AACjB;;;ADLA,IAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,OAAOA,SAAQ,yBAAyB;AASvC,SAAS,UAAkB;AAChC,SAAO,aAAa;AACtB;AASO,SAAS,IAAI,OAAe,UAAsB,CAAC,GAAW;AACnE,SAAO,KAAK,IAAI,OAAO,QAAQ,SAAS,KAAK;AAC/C;AAWO,SAAS,MAAM,OAAe,UAAwB,CAAC,GAAW;AACvE,SAAO,KAAK,MAAM,OAAO,QAAQ,QAAQ,WAAW;AACtD;AAUO,SAAS,QAAQ,OAAe,UAA0B,CAAC,GAAW;AAC3E,SAAO,KAAK,QAAQ,OAAO,QAAQ,QAAQ,aAAa,QAAQ,YAAY,OAAO,QAAQ,aAAa,OAAO,QAAQ,UAAU,OAAO,QAAQ,UAAU,CAAC;AAC7J;AASO,SAAS,eAAe,OAAe,UAA6B,CAAC,GAAW;AACrF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAO,KAAK,gBAAgB,OAAO,QAAQ,QAAQ;AACrD;AASO,SAAS,iBAAiB,OAAe,UAA6B,CAAC,GAAW;AACvF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAO,KAAK,kBAAkB,OAAO,QAAQ,QAAQ;AACvD;AAQO,SAAS,KAAK,UAAuB,CAAC,GAAW;AACtD,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,MAAM,QAAQ,OAAO;AAC3B,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,SAAS,QAAQ,UAAU;AACjC,SAAO,KAAK,KAAK,UAAU,QAAQ,KAAK,QAAQ,MAAM;AACxD;AAQO,SAAS,SAAS,OAAuB;AAC9C,QAAM,IAAI,MAAM,iCAAiC;AACnD;","names":["require"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmb/bitmark-parser",
3
- "version": "3.0.1-alpha.5",
3
+ "version": "3.0.3",
4
4
  "description": "A parser for bitmark text, powered by WebAssembly.",
5
5
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
6
6
  "license": "ISC",
@@ -8,12 +8,15 @@
8
8
  */
9
9
  export function breakscape_text(input: string, format: string, location: string): string;
10
10
  /**
11
- * Unbreakscape text (unescape bitmark special characters).
11
+ * Query information about supported bit types.
12
12
  *
13
- * `format`: `"bitmark++"` (default) or `"plainText"`
14
- * `location`: `"body"` (default) or `"tag"`
13
+ * `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
14
+ * `format`: `"text"` or `"json"`
15
+ * `bit`: bit name (required when `info_type` is `"bit"`)
16
+ * `pretty`: whether to pretty-print JSON output
17
+ * `indent`: indent size for pretty-printing (default: 2)
15
18
  */
16
- export function unbreakscape_text(input: string, format: string, location: string): string;
19
+ export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number): string;
17
20
  /**
18
21
  * Parse bitmark input text and return the reference JSON format.
19
22
  *
@@ -22,6 +25,22 @@ export function unbreakscape_text(input: string, format: string, location: strin
22
25
  * `mode`: `"optimized"` (default) or `"full"`
23
26
  */
24
27
  export function parse(input: string, mode: string): string;
28
+ /**
29
+ * Lex bitmark input text, returning one line per token in the same format as
30
+ * the Rust CLI: `{kind:?} {span:?} "{text}"`.
31
+ *
32
+ * `stage` selects the lexer pipeline:
33
+ * - `"lex"` — combined (default)
34
+ * - `"lex-json"` — combined, JSON array output
35
+ */
36
+ export function lex(input: string, stage: string): string;
37
+ /**
38
+ * Unbreakscape text (unescape bitmark special characters).
39
+ *
40
+ * `format`: `"bitmark++"` (default) or `"plainText"`
41
+ * `location`: `"body"` (default) or `"tag"`
42
+ */
43
+ export function unbreakscape_text(input: string, format: string, location: string): string;
25
44
  /**
26
45
  * Auto-detect input format and convert between bitmark and JSON.
27
46
  *
@@ -35,26 +54,3 @@ export function parse(input: string, mode: string): string;
35
54
  * (generator not yet implemented).
36
55
  */
37
56
  export function convert(input: string, mode: string, warnings: boolean, plain_text: boolean, pretty: boolean, indent: number): string;
38
- /**
39
- * Query information about supported bit types.
40
- *
41
- * `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
42
- * `format`: `"text"` or `"json"`
43
- * `bit`: bit name (required when `info_type` is `"bit"`)
44
- * `pretty`: whether to pretty-print JSON output
45
- * `indent`: indent size for pretty-printing (default: 2)
46
- */
47
- export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number): string;
48
- /**
49
- * Lex bitmark input text, returning one line per token in the same format as
50
- * the Rust CLI: `{kind:?} {span:?} "{text}"`.
51
- *
52
- * `stage` selects the lexer pipeline:
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
59
- */
60
- export function lex(input: string, stage: string): string;
@@ -119,27 +119,32 @@ module.exports.breakscape_text = function(input, format, location) {
119
119
  };
120
120
 
121
121
  /**
122
- * Unbreakscape text (unescape bitmark special characters).
122
+ * Query information about supported bit types.
123
123
  *
124
- * `format`: `"bitmark++"` (default) or `"plainText"`
125
- * `location`: `"body"` (default) or `"tag"`
126
- * @param {string} input
124
+ * `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
125
+ * `format`: `"text"` or `"json"`
126
+ * `bit`: bit name (required when `info_type` is `"bit"`)
127
+ * `pretty`: whether to pretty-print JSON output
128
+ * `indent`: indent size for pretty-printing (default: 2)
129
+ * @param {string} info_type
127
130
  * @param {string} format
128
- * @param {string} location
131
+ * @param {string} bit
132
+ * @param {boolean} pretty
133
+ * @param {number} indent
129
134
  * @returns {string}
130
135
  */
131
- module.exports.unbreakscape_text = function(input, format, location) {
136
+ module.exports.info = function(info_type, format, bit, pretty, indent) {
132
137
  let deferred4_0;
133
138
  let deferred4_1;
134
139
  try {
135
140
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
136
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
141
+ const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
137
142
  const len0 = WASM_VECTOR_LEN;
138
143
  const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
139
144
  const len1 = WASM_VECTOR_LEN;
140
- const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
145
+ const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
141
146
  const len2 = WASM_VECTOR_LEN;
142
- wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
147
+ wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
143
148
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
144
149
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
145
150
  deferred4_0 = r0;
@@ -183,34 +188,26 @@ module.exports.parse = function(input, mode) {
183
188
  };
184
189
 
185
190
  /**
186
- * Auto-detect input format and convert between bitmark and JSON.
187
- *
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)
191
+ * Lex bitmark input text, returning one line per token in the same format as
192
+ * the Rust CLI: `{kind:?} {span:?} "{text}"`.
193
193
  *
194
- * Returns JSON if input is bitmark, or an error message if input is JSON
195
- * (generator not yet implemented).
194
+ * `stage` selects the lexer pipeline:
195
+ * - `"lex"` — combined (default)
196
+ * - `"lex-json"` — combined, JSON array output
196
197
  * @param {string} input
197
- * @param {string} mode
198
- * @param {boolean} warnings
199
- * @param {boolean} plain_text
200
- * @param {boolean} pretty
201
- * @param {number} indent
198
+ * @param {string} stage
202
199
  * @returns {string}
203
200
  */
204
- module.exports.convert = function(input, mode, warnings, plain_text, pretty, indent) {
201
+ module.exports.lex = function(input, stage) {
205
202
  let deferred3_0;
206
203
  let deferred3_1;
207
204
  try {
208
205
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
209
206
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
210
207
  const len0 = WASM_VECTOR_LEN;
211
- const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
208
+ const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
212
209
  const len1 = WASM_VECTOR_LEN;
213
- wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);
210
+ wasm.lex(retptr, ptr0, len0, ptr1, len1);
214
211
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
215
212
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
216
213
  deferred3_0 = r0;
@@ -223,32 +220,27 @@ module.exports.convert = function(input, mode, warnings, plain_text, pretty, ind
223
220
  };
224
221
 
225
222
  /**
226
- * Query information about supported bit types.
223
+ * Unbreakscape text (unescape bitmark special characters).
227
224
  *
228
- * `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
229
- * `format`: `"text"` or `"json"`
230
- * `bit`: bit name (required when `info_type` is `"bit"`)
231
- * `pretty`: whether to pretty-print JSON output
232
- * `indent`: indent size for pretty-printing (default: 2)
233
- * @param {string} info_type
225
+ * `format`: `"bitmark++"` (default) or `"plainText"`
226
+ * `location`: `"body"` (default) or `"tag"`
227
+ * @param {string} input
234
228
  * @param {string} format
235
- * @param {string} bit
236
- * @param {boolean} pretty
237
- * @param {number} indent
229
+ * @param {string} location
238
230
  * @returns {string}
239
231
  */
240
- module.exports.info = function(info_type, format, bit, pretty, indent) {
232
+ module.exports.unbreakscape_text = function(input, format, location) {
241
233
  let deferred4_0;
242
234
  let deferred4_1;
243
235
  try {
244
236
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
245
- const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
237
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
246
238
  const len0 = WASM_VECTOR_LEN;
247
239
  const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
248
240
  const len1 = WASM_VECTOR_LEN;
249
- const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
241
+ const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
250
242
  const len2 = WASM_VECTOR_LEN;
251
- wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
243
+ wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
252
244
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
253
245
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
254
246
  deferred4_0 = r0;
@@ -261,30 +253,34 @@ module.exports.info = function(info_type, format, bit, pretty, indent) {
261
253
  };
262
254
 
263
255
  /**
264
- * Lex bitmark input text, returning one line per token in the same format as
265
- * the Rust CLI: `{kind:?} {span:?} "{text}"`.
256
+ * Auto-detect input format and convert between bitmark and JSON.
266
257
  *
267
- * `stage` selects the lexer pipeline:
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
258
+ * `mode`: `"optimized"` (default) or `"full"`
259
+ * `warnings`: whether to include validation warnings (default: false)
260
+ * `plain_text`: output text as plain text — debug mode (default: false)
261
+ * `pretty`: prettify JSON output (default: false)
262
+ * `indent`: indent size for pretty-printing (default: 2)
263
+ *
264
+ * Returns JSON if input is bitmark, or an error message if input is JSON
265
+ * (generator not yet implemented).
274
266
  * @param {string} input
275
- * @param {string} stage
267
+ * @param {string} mode
268
+ * @param {boolean} warnings
269
+ * @param {boolean} plain_text
270
+ * @param {boolean} pretty
271
+ * @param {number} indent
276
272
  * @returns {string}
277
273
  */
278
- module.exports.lex = function(input, stage) {
274
+ module.exports.convert = function(input, mode, warnings, plain_text, pretty, indent) {
279
275
  let deferred3_0;
280
276
  let deferred3_1;
281
277
  try {
282
278
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
283
279
  const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
284
280
  const len0 = WASM_VECTOR_LEN;
285
- const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
281
+ const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
286
282
  const len1 = WASM_VECTOR_LEN;
287
- wasm.lex(retptr, ptr0, len0, ptr1, len1);
283
+ wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);
288
284
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
289
285
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
290
286
  deferred3_0 = r0;
Binary file
package/wasm/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "Get More Brain Ltd <info@getmorebrain.com>"
5
5
  ],
6
6
  "description": "WebAssembly bindings for the bitmark parser",
7
- "version": "3.0.1",
7
+ "version": "3.0.3",
8
8
  "license": "ISC",
9
9
  "repository": {
10
10
  "type": "git",