@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/cli.js CHANGED
@@ -6,25 +6,34 @@ import { dirname } from 'path';
6
6
 
7
7
  // src/generated/package_info.ts
8
8
  var PACKAGE_INFO = {
9
- "version": "3.0.1-alpha.3"};
9
+ "version": "3.0.1-alpha.5"};
10
10
  var require2 = createRequire(import.meta.url);
11
11
  var wasm = require2("../wasm/bitmark_wasm.js");
12
- function lex(input, optionsJson = "{}") {
13
- return wasm.lex(input, optionsJson);
12
+ function lex(input, options = {}) {
13
+ return wasm.lex(input, options.stage ?? "lex");
14
14
  }
15
- function parse(input, optionsJson = "{}") {
16
- return wasm.parse(input, optionsJson);
15
+ function parse(input, options = {}) {
16
+ return wasm.parse(input, options.mode ?? "optimized");
17
17
  }
18
- function convert(input, optionsJson = "{}") {
19
- return wasm.convert(input, optionsJson);
18
+ function convert(input, options = {}) {
19
+ return wasm.convert(input, options.mode ?? "optimized", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);
20
20
  }
21
- function breakscapeText(input, format = "bitmark++", location = "body") {
21
+ function breakscapeText(input, options = {}) {
22
+ const format = options.format ?? "bitmark++";
23
+ const location = options.location ?? "body";
22
24
  return wasm.breakscape_text(input, format, location);
23
25
  }
24
- function unbreakscapeText(input, format = "bitmark++", location = "body") {
26
+ function unbreakscapeText(input, options = {}) {
27
+ const format = options.format ?? "bitmark++";
28
+ const location = options.location ?? "body";
25
29
  return wasm.unbreakscape_text(input, format, location);
26
30
  }
27
- function info(infoType = "list", format = "text", bit = "", pretty = false, indent = 2) {
31
+ function info(options = {}) {
32
+ const infoType = options.infoType ?? "list";
33
+ const format = options.format ?? "text";
34
+ const bit = options.bit ?? "";
35
+ const pretty = options.pretty ?? false;
36
+ const indent = options.indent ?? 2;
28
37
  return wasm.info(infoType, format, bit, pretty, indent);
29
38
  }
30
39
  function readInputs(inputs) {
@@ -72,11 +81,9 @@ function registerParseCommand(program2) {
72
81
  const content = readInputs(inputs);
73
82
  let result;
74
83
  if (options.stage === "lex" || options.stage === "lex-bitmark" || options.stage === "lex-text") {
75
- const lexOptionsJson = JSON.stringify({ stage: options.stage });
76
- result = lex(content, lexOptionsJson);
84
+ result = lex(content, { stage: options.stage });
77
85
  } else {
78
- const optionsJson = JSON.stringify({ mode: options.mode });
79
- result = parse(content, optionsJson);
86
+ result = parse(content, { mode: options.mode });
80
87
  }
81
88
  writeOutput(result, options.output, options.append);
82
89
  });
@@ -95,14 +102,13 @@ function registerConvertCommand(program2) {
95
102
  program2.command("convert").description("Auto-detect input format and convert between bitmark and JSON").argument("[INPUT...]", "Input: file paths, bitmark/JSON strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("-w, --warnings", "Enable validation warnings in output", false).option("-p, --pretty", "Prettify JSON output", false).option("--indent <n>", "Indent size for pretty JSON", "2").option("--mode <MODE>", "JSON output mode: optimized or full", "optimized").option("--plain-text", "Output text as plain text (debug)", false).action(
96
103
  (inputs, options) => {
97
104
  const content = readInputs(inputs);
98
- const optionsJson = JSON.stringify({
105
+ const result = convert(content, {
99
106
  mode: options.mode,
100
107
  warnings: options.warnings,
101
108
  plainText: options.plainText,
102
109
  pretty: options.pretty,
103
110
  indent: parseInt(options.indent, 10)
104
111
  });
105
- const result = convert(content, optionsJson);
106
112
  writeOutput(result, options.output, options.append);
107
113
  }
108
114
  );
@@ -112,7 +118,10 @@ function registerConvertCommand(program2) {
112
118
  function registerBreakscapeCommand(program2) {
113
119
  program2.command("breakscape").description("Breakscape text (escape bitmark special characters)").argument("[INPUT...]", "Input: file paths, text strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("--format <FORMAT>", "Text format: bitmark++ or plainText", "bitmark++").option("--location <LOCATION>", "Text location: body or tag", "body").action((inputs, options) => {
114
120
  const content = readInputs(inputs);
115
- const result = breakscapeText(content, options.format, options.location);
121
+ const result = breakscapeText(content, {
122
+ format: options.format,
123
+ location: options.location
124
+ });
116
125
  writeOutput(result, options.output, options.append);
117
126
  });
118
127
  }
@@ -121,7 +130,10 @@ function registerBreakscapeCommand(program2) {
121
130
  function registerUnbreakscapeCommand(program2) {
122
131
  program2.command("unbreakscape").description("Unbreakscape text (unescape bitmark special characters)").argument("[INPUT...]", "Input: file paths, text strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("--format <FORMAT>", "Text format: bitmark++ or plainText", "bitmark++").option("--location <LOCATION>", "Text location: body or tag", "body").action((inputs, options) => {
123
132
  const content = readInputs(inputs);
124
- const result = unbreakscapeText(content, options.format, options.location);
133
+ const result = unbreakscapeText(content, {
134
+ format: options.format,
135
+ location: options.location
136
+ });
125
137
  writeOutput(result, options.output, options.append);
126
138
  });
127
139
  }
@@ -130,7 +142,13 @@ function registerUnbreakscapeCommand(program2) {
130
142
  function registerInfoCommand(program2) {
131
143
  program2.command("info").description("Show information about supported bit types").argument("[INFO]", "Info type: list, bit, all, deprecated", "list").option("-f, --format <FORMAT>", "Output format: text or json", "text").option("--all", "Include deprecated bits", false).option("--bit <NAME>", "Filter to specific bit type").option("--deprecated", "Show only deprecated bits", false).option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("-p, --pretty", "Prettify JSON output", false).option("--indent <n>", "Indent size for pretty JSON", "2").action(
132
144
  (infoType, options) => {
133
- const result = info(infoType, options.format, options.bit ?? "", options.pretty, parseInt(options.indent, 10));
145
+ const result = info({
146
+ infoType,
147
+ format: options.format,
148
+ bit: options.bit,
149
+ pretty: options.pretty,
150
+ indent: parseInt(options.indent, 10)
151
+ });
134
152
  writeOutput(result, options.output, options.append);
135
153
  }
136
154
  );
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/generated/package_info.ts","../src/index.ts","../src/utils/io.ts","../src/commands/parse.ts","../src/commands/generate.ts","../src/commands/convert.ts","../src/commands/breakscape.ts","../src/commands/unbreakscape.ts","../src/commands/info.ts","../src/cli.ts"],"names":["require","program"],"mappings":";;;;;;;AAIO,IAAM,YAAA,GAAe;AAAA,EAE1B,SAAA,EAAW,eAIb,CAAA;ACNA,IAAMA,QAAAA,GAAU,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAC7C,IAAM,IAAA,GAAOA,SAAQ,yBAAyB,CAAA;AAkBvC,SAAS,GAAA,CAAI,KAAA,EAAe,WAAA,GAAsB,IAAA,EAAc;AACrE,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,WAAW,CAAA;AACpC;AASO,SAAS,KAAA,CAAM,KAAA,EAAe,WAAA,GAAsB,IAAA,EAAc;AACvE,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,KAAA,EAAO,WAAW,CAAA;AACtC;AASO,SAAS,OAAA,CAAQ,KAAA,EAAe,WAAA,GAAsB,IAAA,EAAc;AACzE,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,WAAW,CAAA;AACxC;AAUO,SAAS,cAAA,CAAe,KAAA,EAAe,MAAA,GAAiB,WAAA,EAAa,WAAmB,MAAA,EAAgB;AAC7G,EAAA,OAAO,IAAA,CAAK,eAAA,CAAgB,KAAA,EAAO,MAAA,EAAQ,QAAQ,CAAA;AACrD;AAUO,SAAS,gBAAA,CAAiB,KAAA,EAAe,MAAA,GAAiB,WAAA,EAAa,WAAmB,MAAA,EAAgB;AAC/G,EAAA,OAAO,IAAA,CAAK,iBAAA,CAAkB,KAAA,EAAO,MAAA,EAAQ,QAAQ,CAAA;AACvD;AAYO,SAAS,IAAA,CAAK,QAAA,GAAmB,MAAA,EAAQ,MAAA,GAAiB,MAAA,EAAQ,MAAc,EAAA,EAAI,MAAA,GAAkB,KAAA,EAAO,MAAA,GAAiB,CAAA,EAAW;AAC9I,EAAA,O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OAAA,GAAU,IAAI,OAAA,EAAQ;AAE5B,OAAA,CAAQ,IAAA,CAAK,gBAAgB,CAAA,CAAE,WAAA,CAAY,iCAAiC,CAAA,CAAE,OAAA,CAAQ,aAAa,OAAO,CAAA;AAE1G,oBAAA,CAAqB,OAAO,CAAA;AAC5B,uBAAA,CAAwB,OAAO,CAAA;AAC/B,sBAAA,CAAuB,OAAO,CAAA;AAC9B,yBAAA,CAA0B,OAAO,CAAA;AACjC,2BAAA,CAA4B,OAAO,CAAA;AACnC,mBAAA,CAAoB,OAAO,CAAA;AAE3B,OAAA,CAAQ,KAAA,EAAM","file":"cli.js","sourcesContent":["// 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.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","// @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 optionsJson - JSON string with options: stage.\n * @returns Token dump string (one token per line).\n */\nexport function lex(input: string, optionsJson: string = \"{}\"): string {\n return wasm.lex(input, optionsJson);\n}\n\n/**\n * Parse bitmark input text and return the reference JSON format.\n *\n * @param input - The bitmark source text.\n * @param optionsJson - JSON string with options: mode.\n * @returns JSON string of the parsed bitmark document.\n */\nexport function parse(input: string, optionsJson: string = \"{}\"): string {\n return wasm.parse(input, optionsJson);\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 optionsJson - JSON string with options: mode, warnings, plainText.\n * @returns Converted output string.\n */\nexport function convert(input: string, optionsJson: string = \"{}\"): string {\n return wasm.convert(input, optionsJson);\n}\n\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * @param input - The text to breakscape.\n * @param format - Text format: `\"bitmark++\"` (default) or `\"plainText\"`.\n * @param location - Text location: `\"body\"` (default) or `\"tag\"`.\n * @returns Breakscaped text.\n */\nexport function breakscapeText(input: string, format: string = \"bitmark++\", location: string = \"body\"): string {\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 format - Text format: `\"bitmark++\"` (default) or `\"plainText\"`.\n * @param location - Text location: `\"body\"` (default) or `\"tag\"`.\n * @returns Unbreakscaped text.\n */\nexport function unbreakscapeText(input: string, format: string = \"bitmark++\", location: string = \"body\"): string {\n return wasm.unbreakscape_text(input, format, location);\n}\n\n/**\n * Query information about supported bit types.\n *\n * @param infoType - Info type: `\"list\"`, `\"bit\"`, `\"all\"`, or `\"deprecated\"`.\n * @param format - Output format: `\"text\"` (default) or `\"json\"`.\n * @param bit - Bit name (required when `infoType` is `\"bit\"`).\n * @param pretty - Whether to pretty-print JSON output.\n * @param indent - Indent size for pretty-printing (default: 2).\n * @returns Information string.\n */\nexport function info(infoType: string = \"list\", format: string = \"text\", bit: string = \"\", pretty: boolean = false, indent: number = 2): string {\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","// @zen-component: CLI-SharedIO\n//! Shared I/O utilities for the TS CLI.\n\nimport { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\n/**\n * Resolve multiple inputs into a single concatenated string.\n *\n * If the array is empty, reads from stdin.\n * Multiple inputs are concatenated with `\\n` — valid for bitmark\n * because bits are `\\n`-delimited.\n */\nexport function readInputs(inputs: string[]): string {\n if (inputs.length === 0) {\n return readStdin();\n }\n if (inputs.length === 1) {\n return readSingle(inputs[0]);\n }\n return inputs.map(readSingle).join(\"\\n\");\n}\n\n/**\n * Resolve a single input string (file path or literal).\n */\nfunction readSingle(input: string): string {\n if (existsSync(input)) {\n return readFileSync(input, \"utf-8\");\n }\n return input;\n}\n\n/**\n * Read all of stdin synchronously.\n */\nfunction readStdin(): string {\n const buf = readFileSync(0, \"utf-8\") as string;\n if (!buf) {\n console.error(\"No input provided. Pass a file path, literal string, or pipe via stdin.\");\n process.exit(1);\n }\n return buf;\n}\n\n/**\n * Write output to stdout or a file.\n *\n * - If `outputPath` is undefined → write to stdout\n * - If `append` is true → append to file\n * - Otherwise → overwrite file\n */\nexport function writeOutput(content: string, outputPath: string | undefined, append: boolean): void {\n if (outputPath === undefined) {\n process.stdout.write(content);\n return;\n }\n\n // Ensure parent directory exists\n const dir = dirname(outputPath);\n if (dir && !existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n if (append) {\n appendFileSync(outputPath, content, \"utf-8\");\n } else {\n writeFileSync(outputPath, content, \"utf-8\");\n }\n}\n","// @zen-component: WASM-TSBindings\n\nimport type { Command } from \"commander\";\nimport { lex, parse } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerParseCommand(program: Command): void {\n program\n .command(\"parse\")\n .description(\"Parse a bitmark file to JSON\")\n .argument(\"[INPUT...]\", \"Input: bitmark files, literal strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"--stage <STAGE>\", \"Stage to run: all, lex, lex-bitmark, lex-text\", \"all\")\n .option(\"--mode <MODE>\", \"JSON output mode: optimized or full\", \"optimized\")\n .action((inputs: string[], options: { output?: string; append: boolean; stage: string; mode: string }) => {\n const content = readInputs(inputs);\n let result: string;\n\n if (options.stage === \"lex\" || options.stage === \"lex-bitmark\" || options.stage === \"lex-text\") {\n const lexOptionsJson = JSON.stringify({ stage: options.stage });\n result = lex(content, lexOptionsJson);\n } else {\n const optionsJson = JSON.stringify({ mode: options.mode });\n result = parse(content, optionsJson);\n }\n\n writeOutput(result, options.output, options.append);\n });\n}\n","// @zen-component: WASM-TSBindings\n\nimport type { Command } from \"commander\";\n\nexport function registerGenerateCommand(program: Command): void {\n program\n .command(\"generate\")\n .description(\"Generate bitmark text from JSON\")\n .argument(\"<INPUT>\", \"Input JSON file\")\n .argument(\"<OUTPUT>\", \"Output bitmark file\")\n .action((_input: string, _output: string) => {\n console.error(\"generate not yet implemented\");\n process.exit(1);\n });\n}\n","// @zen-component: CLI-Convert\n\nimport type { Command } from \"commander\";\nimport { convert } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerConvertCommand(program: Command): void {\n program\n .command(\"convert\")\n .description(\"Auto-detect input format and convert between bitmark and JSON\")\n .argument(\"[INPUT...]\", \"Input: file paths, bitmark/JSON strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"-w, --warnings\", \"Enable validation warnings in output\", false)\n .option(\"-p, --pretty\", \"Prettify JSON output\", false)\n .option(\"--indent <n>\", \"Indent size for pretty JSON\", \"2\")\n .option(\"--mode <MODE>\", \"JSON output mode: optimized or full\", \"optimized\")\n .option(\"--plain-text\", \"Output text as plain text (debug)\", false)\n .action(\n (\n inputs: string[],\n options: {\n output?: string;\n append: boolean;\n warnings: boolean;\n pretty: boolean;\n indent: string;\n mode: string;\n plainText: boolean;\n },\n ) => {\n const content = readInputs(inputs);\n const optionsJson = JSON.stringify({\n mode: options.mode,\n warnings: options.warnings,\n plainText: options.plainText,\n pretty: options.pretty,\n indent: parseInt(options.indent, 10),\n });\n const result = convert(content, optionsJson);\n writeOutput(result, options.output, options.append);\n },\n );\n}\n","// @zen-component: CLI-Breakscape\n\nimport type { Command } from \"commander\";\nimport { breakscapeText } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerBreakscapeCommand(program: Command): void {\n program\n .command(\"breakscape\")\n .description(\"Breakscape text (escape bitmark special characters)\")\n .argument(\"[INPUT...]\", \"Input: file paths, text strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"--format <FORMAT>\", \"Text format: bitmark++ or plainText\", \"bitmark++\")\n .option(\"--location <LOCATION>\", \"Text location: body or tag\", \"body\")\n .action((inputs: string[], options: { output?: string; append: boolean; format: string; location: string }) => {\n const content = readInputs(inputs);\n const result = breakscapeText(content, options.format, options.location);\n writeOutput(result, options.output, options.append);\n });\n}\n","// @zen-component: CLI-Breakscape\n\nimport type { Command } from \"commander\";\nimport { unbreakscapeText } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerUnbreakscapeCommand(program: Command): void {\n program\n .command(\"unbreakscape\")\n .description(\"Unbreakscape text (unescape bitmark special characters)\")\n .argument(\"[INPUT...]\", \"Input: file paths, text strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"--format <FORMAT>\", \"Text format: bitmark++ or plainText\", \"bitmark++\")\n .option(\"--location <LOCATION>\", \"Text location: body or tag\", \"body\")\n .action((inputs: string[], options: { output?: string; append: boolean; format: string; location: string }) => {\n const content = readInputs(inputs);\n const result = unbreakscapeText(content, options.format, options.location);\n writeOutput(result, options.output, options.append);\n });\n}\n","// @zen-component: CLI-Info\n\nimport type { Command } from \"commander\";\nimport { info } from \"../index.js\";\nimport { writeOutput } from \"../utils/io.js\";\n\nexport function registerInfoCommand(program: Command): void {\n program\n .command(\"info\")\n .description(\"Show information about supported bit types\")\n .argument(\"[INFO]\", \"Info type: list, bit, all, deprecated\", \"list\")\n .option(\"-f, --format <FORMAT>\", \"Output format: text or json\", \"text\")\n .option(\"--all\", \"Include deprecated bits\", false)\n .option(\"--bit <NAME>\", \"Filter to specific bit type\")\n .option(\"--deprecated\", \"Show only deprecated bits\", false)\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"-p, --pretty\", \"Prettify JSON output\", false)\n .option(\"--indent <n>\", \"Indent size for pretty JSON\", \"2\")\n .action(\n (\n infoType: string,\n options: {\n format: string;\n all: boolean;\n bit?: string;\n deprecated: boolean;\n output?: string;\n append: boolean;\n pretty: boolean;\n indent: string;\n },\n ) => {\n const result = info(infoType, options.format, options.bit ?? \"\", options.pretty, parseInt(options.indent, 10));\n writeOutput(result, options.output, options.append);\n },\n );\n}\n","#!/usr/bin/env node\n// @zen-component: WASM-TSBindings\n\nimport { Command } from \"commander\";\nimport { PACKAGE_INFO } from \"./generated/package_info.js\";\nimport { registerParseCommand } from \"./commands/parse.js\";\nimport { registerGenerateCommand } from \"./commands/generate.js\";\nimport { registerConvertCommand } from \"./commands/convert.js\";\nimport { registerBreakscapeCommand } from \"./commands/breakscape.js\";\nimport { registerUnbreakscapeCommand } from \"./commands/unbreakscape.js\";\nimport { registerInfoCommand } from \"./commands/info.js\";\n\nconst program = new Command();\n\nprogram.name(\"bitmark-parser\").description(\"Parse and generate bitmark text\").version(PACKAGE_INFO.version);\n\nregisterParseCommand(program);\nregisterGenerateCommand(program);\nregisterConvertCommand(program);\nregisterBreakscapeCommand(program);\nregisterUnbreakscapeCommand(program);\nregisterInfoCommand(program);\n\nprogram.parse();\n"]}
1
+ {"version":3,"sources":["../src/generated/package_info.ts","../src/index.ts","../src/utils/io.ts","../src/commands/parse.ts","../src/commands/generate.ts","../src/commands/convert.ts","../src/commands/breakscape.ts","../src/commands/unbreakscape.ts","../src/commands/info.ts","../src/cli.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AACH,MAAA,MAAM,SAAS,IAAA,CAAK;AAAA,QAClB,QAAA;AAAA,QACA,QAAQ,OAAA,CAAQ,MAAA;AAAA,QAChB,KAAK,OAAA,CAAQ,GAAA;AAAA,QACb,QAAQ,OAAA,CAAQ,MAAA;AAAA,QAChB,MAAA,EAAQ,QAAA,CAAS,OAAA,CAAQ,MAAA,EAAQ,EAAE;AAAA,OACpC,CAAA;AACD,MAAA,WAAA,CAAY,MAAA,EAAQ,OAAA,CAAQ,MAAA,EAAQ,OAAA,CAAQ,MAAM,CAAA;AAAA,IACpD;AAAA,GACF;AACJ;;;AC/BA,IAAM,OAAA,GAAU,IAAI,OAAA,EAAQ;AAE5B,OAAA,CAAQ,IAAA,CAAK,gBAAgB,CAAA,CAAE,WAAA,CAAY,iCAAiC,CAAA,CAAE,OAAA,CAAQ,aAAa,OAAO,CAAA;AAE1G,oBAAA,CAAqB,OAAO,CAAA;AAC5B,uBAAA,CAAwB,OAAO,CAAA;AAC/B,sBAAA,CAAuB,OAAO,CAAA;AAC9B,yBAAA,CAA0B,OAAO,CAAA;AACjC,2BAAA,CAA4B,OAAO,CAAA;AACnC,mBAAA,CAAoB,OAAO,CAAA;AAE3B,OAAA,CAAQ,KAAA,EAAM","file":"cli.js","sourcesContent":["// 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","// @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","// @zen-component: CLI-SharedIO\n//! Shared I/O utilities for the TS CLI.\n\nimport { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\n/**\n * Resolve multiple inputs into a single concatenated string.\n *\n * If the array is empty, reads from stdin.\n * Multiple inputs are concatenated with `\\n` — valid for bitmark\n * because bits are `\\n`-delimited.\n */\nexport function readInputs(inputs: string[]): string {\n if (inputs.length === 0) {\n return readStdin();\n }\n if (inputs.length === 1) {\n return readSingle(inputs[0]);\n }\n return inputs.map(readSingle).join(\"\\n\");\n}\n\n/**\n * Resolve a single input string (file path or literal).\n */\nfunction readSingle(input: string): string {\n if (existsSync(input)) {\n return readFileSync(input, \"utf-8\");\n }\n return input;\n}\n\n/**\n * Read all of stdin synchronously.\n */\nfunction readStdin(): string {\n const buf = readFileSync(0, \"utf-8\") as string;\n if (!buf) {\n console.error(\"No input provided. Pass a file path, literal string, or pipe via stdin.\");\n process.exit(1);\n }\n return buf;\n}\n\n/**\n * Write output to stdout or a file.\n *\n * - If `outputPath` is undefined → write to stdout\n * - If `append` is true → append to file\n * - Otherwise → overwrite file\n */\nexport function writeOutput(content: string, outputPath: string | undefined, append: boolean): void {\n if (outputPath === undefined) {\n process.stdout.write(content);\n return;\n }\n\n // Ensure parent directory exists\n const dir = dirname(outputPath);\n if (dir && !existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n\n if (append) {\n appendFileSync(outputPath, content, \"utf-8\");\n } else {\n writeFileSync(outputPath, content, \"utf-8\");\n }\n}\n","// @zen-component: WASM-TSBindings\n\nimport type { Command } from \"commander\";\nimport { lex, parse } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerParseCommand(program: Command): void {\n program\n .command(\"parse\")\n .description(\"Parse a bitmark file to JSON\")\n .argument(\"[INPUT...]\", \"Input: bitmark files, literal strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"--stage <STAGE>\", \"Stage to run: all, lex, lex-bitmark, lex-text\", \"all\")\n .option(\"--mode <MODE>\", \"JSON output mode: optimized or full\", \"optimized\")\n .action((inputs: string[], options: { output?: string; append: boolean; stage: string; mode: string }) => {\n const content = readInputs(inputs);\n let result: string;\n\n if (options.stage === \"lex\" || options.stage === \"lex-bitmark\" || options.stage === \"lex-text\") {\n result = lex(content, { stage: options.stage });\n } else {\n result = parse(content, { mode: options.mode as \"optimized\" | \"full\" });\n }\n\n writeOutput(result, options.output, options.append);\n });\n}\n","// @zen-component: WASM-TSBindings\n\nimport type { Command } from \"commander\";\n\nexport function registerGenerateCommand(program: Command): void {\n program\n .command(\"generate\")\n .description(\"Generate bitmark text from JSON\")\n .argument(\"<INPUT>\", \"Input JSON file\")\n .argument(\"<OUTPUT>\", \"Output bitmark file\")\n .action((_input: string, _output: string) => {\n console.error(\"generate not yet implemented\");\n process.exit(1);\n });\n}\n","// @zen-component: CLI-Convert\n\nimport type { Command } from \"commander\";\nimport { convert } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerConvertCommand(program: Command): void {\n program\n .command(\"convert\")\n .description(\"Auto-detect input format and convert between bitmark and JSON\")\n .argument(\"[INPUT...]\", \"Input: file paths, bitmark/JSON strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"-w, --warnings\", \"Enable validation warnings in output\", false)\n .option(\"-p, --pretty\", \"Prettify JSON output\", false)\n .option(\"--indent <n>\", \"Indent size for pretty JSON\", \"2\")\n .option(\"--mode <MODE>\", \"JSON output mode: optimized or full\", \"optimized\")\n .option(\"--plain-text\", \"Output text as plain text (debug)\", false)\n .action(\n (\n inputs: string[],\n options: {\n output?: string;\n append: boolean;\n warnings: boolean;\n pretty: boolean;\n indent: string;\n mode: string;\n plainText: boolean;\n },\n ) => {\n const content = readInputs(inputs);\n const result = convert(content, {\n mode: options.mode as \"optimized\" | \"full\",\n warnings: options.warnings,\n plainText: options.plainText,\n pretty: options.pretty,\n indent: parseInt(options.indent, 10),\n });\n writeOutput(result, options.output, options.append);\n },\n );\n}\n","// @zen-component: CLI-Breakscape\n\nimport type { Command } from \"commander\";\nimport { breakscapeText } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerBreakscapeCommand(program: Command): void {\n program\n .command(\"breakscape\")\n .description(\"Breakscape text (escape bitmark special characters)\")\n .argument(\"[INPUT...]\", \"Input: file paths, text strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"--format <FORMAT>\", \"Text format: bitmark++ or plainText\", \"bitmark++\")\n .option(\"--location <LOCATION>\", \"Text location: body or tag\", \"body\")\n .action((inputs: string[], options: { output?: string; append: boolean; format: string; location: string }) => {\n const content = readInputs(inputs);\n const result = breakscapeText(content, {\n format: options.format as \"bitmark++\" | \"plainText\",\n location: options.location as \"body\" | \"tag\",\n });\n writeOutput(result, options.output, options.append);\n });\n}\n","// @zen-component: CLI-Breakscape\n\nimport type { Command } from \"commander\";\nimport { unbreakscapeText } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerUnbreakscapeCommand(program: Command): void {\n program\n .command(\"unbreakscape\")\n .description(\"Unbreakscape text (unescape bitmark special characters)\")\n .argument(\"[INPUT...]\", \"Input: file paths, text strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"--format <FORMAT>\", \"Text format: bitmark++ or plainText\", \"bitmark++\")\n .option(\"--location <LOCATION>\", \"Text location: body or tag\", \"body\")\n .action((inputs: string[], options: { output?: string; append: boolean; format: string; location: string }) => {\n const content = readInputs(inputs);\n const result = unbreakscapeText(content, {\n format: options.format as \"bitmark++\" | \"plainText\",\n location: options.location as \"body\" | \"tag\",\n });\n writeOutput(result, options.output, options.append);\n });\n}\n","// @zen-component: CLI-Info\n\nimport type { Command } from \"commander\";\nimport { info } from \"../index.js\";\nimport { writeOutput } from \"../utils/io.js\";\n\nexport function registerInfoCommand(program: Command): void {\n program\n .command(\"info\")\n .description(\"Show information about supported bit types\")\n .argument(\"[INFO]\", \"Info type: list, bit, all, deprecated\", \"list\")\n .option(\"-f, --format <FORMAT>\", \"Output format: text or json\", \"text\")\n .option(\"--all\", \"Include deprecated bits\", false)\n .option(\"--bit <NAME>\", \"Filter to specific bit type\")\n .option(\"--deprecated\", \"Show only deprecated bits\", false)\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"-p, --pretty\", \"Prettify JSON output\", false)\n .option(\"--indent <n>\", \"Indent size for pretty JSON\", \"2\")\n .action(\n (\n infoType: string,\n options: {\n format: string;\n all: boolean;\n bit?: string;\n deprecated: boolean;\n output?: string;\n append: boolean;\n pretty: boolean;\n indent: string;\n },\n ) => {\n const result = info({\n infoType: infoType as \"list\" | \"bit\" | \"all\" | \"deprecated\",\n format: options.format as \"text\" | \"json\",\n bit: options.bit,\n pretty: options.pretty,\n indent: parseInt(options.indent, 10),\n });\n writeOutput(result, options.output, options.append);\n },\n );\n}\n","#!/usr/bin/env node\n// @zen-component: WASM-TSBindings\n\nimport { Command } from \"commander\";\nimport { PACKAGE_INFO } from \"./generated/package_info.js\";\nimport { registerParseCommand } from \"./commands/parse.js\";\nimport { registerGenerateCommand } from \"./commands/generate.js\";\nimport { registerConvertCommand } from \"./commands/convert.js\";\nimport { registerBreakscapeCommand } from \"./commands/breakscape.js\";\nimport { registerUnbreakscapeCommand } from \"./commands/unbreakscape.js\";\nimport { registerInfoCommand } from \"./commands/info.js\";\n\nconst program = new Command();\n\nprogram.name(\"bitmark-parser\").description(\"Parse and generate bitmark text\").version(PACKAGE_INFO.version);\n\nregisterParseCommand(program);\nregisterGenerateCommand(program);\nregisterConvertCommand(program);\nregisterBreakscapeCommand(program);\nregisterUnbreakscapeCommand(program);\nregisterInfoCommand(program);\n\nprogram.parse();\n"]}
package/dist/index.cjs CHANGED
@@ -41,7 +41,7 @@ var import_node_module = require("module");
41
41
  // src/generated/package_info.ts
42
42
  var PACKAGE_INFO = {
43
43
  "name": "@gmb/bitmark-parser",
44
- "version": "3.0.1-alpha.3",
44
+ "version": "3.0.1-alpha.5",
45
45
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
46
46
  "license": "ISC",
47
47
  "description": "A parser for bitmark text, powered by WebAssembly."
@@ -53,22 +53,31 @@ var wasm = require2("../wasm/bitmark_wasm.js");
53
53
  function version() {
54
54
  return PACKAGE_INFO.version;
55
55
  }
56
- function lex(input, optionsJson = "{}") {
57
- return wasm.lex(input, optionsJson);
56
+ function lex(input, options = {}) {
57
+ return wasm.lex(input, options.stage ?? "lex");
58
58
  }
59
- function parse(input, optionsJson = "{}") {
60
- return wasm.parse(input, optionsJson);
59
+ function parse(input, options = {}) {
60
+ return wasm.parse(input, options.mode ?? "optimized");
61
61
  }
62
- function convert(input, optionsJson = "{}") {
63
- return wasm.convert(input, optionsJson);
62
+ function convert(input, options = {}) {
63
+ return wasm.convert(input, options.mode ?? "optimized", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);
64
64
  }
65
- function breakscapeText(input, format = "bitmark++", location = "body") {
65
+ function breakscapeText(input, options = {}) {
66
+ const format = options.format ?? "bitmark++";
67
+ const location = options.location ?? "body";
66
68
  return wasm.breakscape_text(input, format, location);
67
69
  }
68
- function unbreakscapeText(input, format = "bitmark++", location = "body") {
70
+ function unbreakscapeText(input, options = {}) {
71
+ const format = options.format ?? "bitmark++";
72
+ const location = options.location ?? "body";
69
73
  return wasm.unbreakscape_text(input, format, location);
70
74
  }
71
- function info(infoType = "list", format = "text", bit = "", pretty = false, indent = 2) {
75
+ function info(options = {}) {
76
+ const infoType = options.infoType ?? "list";
77
+ const format = options.format ?? "text";
78
+ const bit = options.bit ?? "";
79
+ const pretty = options.pretty ?? false;
80
+ const indent = options.indent ?? 2;
72
81
  return wasm.info(infoType, format, bit, pretty, indent);
73
82
  }
74
83
  function generate(_json) {
@@ -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\";\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 optionsJson - JSON string with options: stage.\n * @returns Token dump string (one token per line).\n */\nexport function lex(input: string, optionsJson: string = \"{}\"): string {\n return wasm.lex(input, optionsJson);\n}\n\n/**\n * Parse bitmark input text and return the reference JSON format.\n *\n * @param input - The bitmark source text.\n * @param optionsJson - JSON string with options: mode.\n * @returns JSON string of the parsed bitmark document.\n */\nexport function parse(input: string, optionsJson: string = \"{}\"): string {\n return wasm.parse(input, optionsJson);\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 optionsJson - JSON string with options: mode, warnings, plainText.\n * @returns Converted output string.\n */\nexport function convert(input: string, optionsJson: string = \"{}\"): string {\n return wasm.convert(input, optionsJson);\n}\n\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * @param input - The text to breakscape.\n * @param format - Text format: `\"bitmark++\"` (default) or `\"plainText\"`.\n * @param location - Text location: `\"body\"` (default) or `\"tag\"`.\n * @returns Breakscaped text.\n */\nexport function breakscapeText(input: string, format: string = \"bitmark++\", location: string = \"body\"): string {\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 format - Text format: `\"bitmark++\"` (default) or `\"plainText\"`.\n * @param location - Text location: `\"body\"` (default) or `\"tag\"`.\n * @returns Unbreakscaped text.\n */\nexport function unbreakscapeText(input: string, format: string = \"bitmark++\", location: string = \"body\"): string {\n return wasm.unbreakscape_text(input, format, location);\n}\n\n/**\n * Query information about supported bit types.\n *\n * @param infoType - Info type: `\"list\"`, `\"bit\"`, `\"all\"`, or `\"deprecated\"`.\n * @param format - Output format: `\"text\"` (default) or `\"json\"`.\n * @param bit - Bit name (required when `infoType` is `\"bit\"`).\n * @param pretty - Whether to pretty-print JSON output.\n * @param indent - Indent size for pretty-printing (default: 2).\n * @returns Information string.\n */\nexport function info(infoType: string = \"list\", format: string = \"text\", bit: string = \"\", pretty: boolean = false, indent: number = 2): string {\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.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;;;AFNA,IAAMA,eAAU,kCAAc,aAAe;AAC7C,IAAM,OAAOA,SAAQ,yBAAyB;AAOvC,SAAS,UAAkB;AAChC,SAAO,aAAa;AACtB;AASO,SAAS,IAAI,OAAe,cAAsB,MAAc;AACrE,SAAO,KAAK,IAAI,OAAO,WAAW;AACpC;AASO,SAAS,MAAM,OAAe,cAAsB,MAAc;AACvE,SAAO,KAAK,MAAM,OAAO,WAAW;AACtC;AASO,SAAS,QAAQ,OAAe,cAAsB,MAAc;AACzE,SAAO,KAAK,QAAQ,OAAO,WAAW;AACxC;AAUO,SAAS,eAAe,OAAe,SAAiB,aAAa,WAAmB,QAAgB;AAC7G,SAAO,KAAK,gBAAgB,OAAO,QAAQ,QAAQ;AACrD;AAUO,SAAS,iBAAiB,OAAe,SAAiB,aAAa,WAAmB,QAAgB;AAC/G,SAAO,KAAK,kBAAkB,OAAO,QAAQ,QAAQ;AACvD;AAYO,SAAS,KAAK,WAAmB,QAAQ,SAAiB,QAAQ,MAAc,IAAI,SAAkB,OAAO,SAAiB,GAAW;AAC9I,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-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"]}
package/dist/index.d.cts CHANGED
@@ -1,3 +1,73 @@
1
+ /**
2
+ * Output mode for JSON serialization.
3
+ *
4
+ * - `"optimized"` — omit keys whose values match their natural defaults.
5
+ * - `"full"` — include all keys enumerated from the bitmark configuration.
6
+ */
7
+ type OutputMode = "optimized" | "full";
8
+ /**
9
+ * Lexer stage selector.
10
+ *
11
+ * - `"lex"` — combined lexer, text output (default).
12
+ * - `"lex-bitmark"` — bitmark-level only, text output.
13
+ * - `"lex-text"` — text-level only, text output.
14
+ * - `"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
+ */
18
+ type LexStage = "lex" | "lex-bitmark" | "lex-text" | "lex-json" | "lex-bitmark-json" | "lex-text-json";
19
+ /** Options for the {@link lex} function. */
20
+ interface LexOptions {
21
+ /** Selects the lexer pipeline stage (default: `"lex"`). */
22
+ stage?: LexStage;
23
+ }
24
+ /** Options for the {@link parse} function. */
25
+ interface ParseOptions {
26
+ /** JSON output mode (default: `"optimized"`). */
27
+ mode?: OutputMode;
28
+ }
29
+ /** Options for the {@link convert} function. */
30
+ interface ConvertOptions {
31
+ /** JSON output mode (default: `"optimized"`). */
32
+ mode?: OutputMode;
33
+ /** Include validation warnings in output (default: `false`). */
34
+ warnings?: boolean;
35
+ /** Output text as plain text — debug mode (default: `false`). */
36
+ plainText?: boolean;
37
+ /** Prettify JSON output (default: `false`). */
38
+ pretty?: boolean;
39
+ /** Indent size for pretty-printing (default: `2`). */
40
+ indent?: number;
41
+ }
42
+ /** Text format for breakscape / unbreakscape operations. */
43
+ type TextFormat = "bitmark++" | "plainText";
44
+ /** Text location for breakscape / unbreakscape operations. */
45
+ type TextLocation = "body" | "tag";
46
+ /** Options for the {@link breakscapeText} and {@link unbreakscapeText} functions. */
47
+ interface BreakscapeOptions {
48
+ /** Text format (default: `"bitmark++"`). */
49
+ format?: TextFormat;
50
+ /** Text location (default: `"body"`). */
51
+ location?: TextLocation;
52
+ }
53
+ /** Info query type for the {@link info} function. */
54
+ type InfoType = "list" | "bit" | "all" | "deprecated";
55
+ /** Output format for the {@link info} function. */
56
+ type InfoFormat = "text" | "json";
57
+ /** Options for the {@link info} function. */
58
+ interface InfoOptions {
59
+ /** Info query type (default: `"list"`). */
60
+ infoType?: InfoType;
61
+ /** Output format (default: `"text"`). */
62
+ format?: InfoFormat;
63
+ /** Bit name — required when `infoType` is `"bit"`. */
64
+ bit?: string;
65
+ /** Whether to pretty-print JSON output (default: `false`). */
66
+ pretty?: boolean;
67
+ /** Indent size for pretty-printing (default: `2`). */
68
+ indent?: number;
69
+ }
70
+
1
71
  /**
2
72
  * Get the version of the @gmb/bitmark-parser library.
3
73
  *
@@ -8,55 +78,49 @@ declare function version(): string;
8
78
  * Lex bitmark input text, returning one line per token.
9
79
  *
10
80
  * @param input - The bitmark source text.
11
- * @param optionsJson - JSON string with options: stage.
81
+ * @param options - Lex options (e.g. `{ stage: "lex-bitmark" }`).
12
82
  * @returns Token dump string (one token per line).
13
83
  */
14
- declare function lex(input: string, optionsJson?: string): string;
84
+ declare function lex(input: string, options?: LexOptions): string;
15
85
  /**
16
86
  * Parse bitmark input text and return the reference JSON format.
17
87
  *
18
88
  * @param input - The bitmark source text.
19
- * @param optionsJson - JSON string with options: mode.
89
+ * @param options - Parse options (e.g. `{ mode: "full" }`).
20
90
  * @returns JSON string of the parsed bitmark document.
21
91
  */
22
- declare function parse(input: string, optionsJson?: string): string;
92
+ declare function parse(input: string, options?: ParseOptions): string;
23
93
  /**
24
94
  * Auto-detect input format and convert between bitmark and JSON.
25
95
  *
26
96
  * @param input - Bitmark or JSON input text.
27
- * @param optionsJson - JSON string with options: mode, warnings, plainText.
97
+ * @param options - Convert options (e.g. `{ mode: "full", warnings: true }`).
28
98
  * @returns Converted output string.
29
99
  */
30
- declare function convert(input: string, optionsJson?: string): string;
100
+ declare function convert(input: string, options?: ConvertOptions): string;
31
101
  /**
32
102
  * Breakscape text (escape bitmark special characters).
33
103
  *
34
104
  * @param input - The text to breakscape.
35
- * @param format - Text format: `"bitmark++"` (default) or `"plainText"`.
36
- * @param location - Text location: `"body"` (default) or `"tag"`.
105
+ * @param options - Breakscape options (e.g. `{ format: "plainText", location: "tag" }`).
37
106
  * @returns Breakscaped text.
38
107
  */
39
- declare function breakscapeText(input: string, format?: string, location?: string): string;
108
+ declare function breakscapeText(input: string, options?: BreakscapeOptions): string;
40
109
  /**
41
110
  * Unbreakscape text (unescape bitmark special characters).
42
111
  *
43
112
  * @param input - The text to unbreakscape.
44
- * @param format - Text format: `"bitmark++"` (default) or `"plainText"`.
45
- * @param location - Text location: `"body"` (default) or `"tag"`.
113
+ * @param options - Unbreakscape options (e.g. `{ format: "plainText", location: "tag" }`).
46
114
  * @returns Unbreakscaped text.
47
115
  */
48
- declare function unbreakscapeText(input: string, format?: string, location?: string): string;
116
+ declare function unbreakscapeText(input: string, options?: BreakscapeOptions): string;
49
117
  /**
50
118
  * Query information about supported bit types.
51
119
  *
52
- * @param infoType - Info type: `"list"`, `"bit"`, `"all"`, or `"deprecated"`.
53
- * @param format - Output format: `"text"` (default) or `"json"`.
54
- * @param bit - Bit name (required when `infoType` is `"bit"`).
55
- * @param pretty - Whether to pretty-print JSON output.
56
- * @param indent - Indent size for pretty-printing (default: 2).
120
+ * @param options - Info options (e.g. `{ infoType: "bit", format: "json", bit: "cloze" }`).
57
121
  * @returns Information string.
58
122
  */
59
- declare function info(infoType?: string, format?: string, bit?: string, pretty?: boolean, indent?: number): string;
123
+ declare function info(options?: InfoOptions): string;
60
124
  /**
61
125
  * Generate bitmark text from a JSON AST.
62
126
  *
@@ -65,4 +129,4 @@ declare function info(infoType?: string, format?: string, bit?: string, pretty?:
65
129
  */
66
130
  declare function generate(_json: string): string;
67
131
 
68
- export { breakscapeText, convert, generate, info, lex, parse, unbreakscapeText, version };
132
+ export { type BreakscapeOptions, type ConvertOptions, type InfoFormat, type InfoOptions, type InfoType, type LexOptions, type LexStage, type OutputMode, type ParseOptions, type TextFormat, type TextLocation, breakscapeText, convert, generate, info, lex, parse, unbreakscapeText, version };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,73 @@
1
+ /**
2
+ * Output mode for JSON serialization.
3
+ *
4
+ * - `"optimized"` — omit keys whose values match their natural defaults.
5
+ * - `"full"` — include all keys enumerated from the bitmark configuration.
6
+ */
7
+ type OutputMode = "optimized" | "full";
8
+ /**
9
+ * Lexer stage selector.
10
+ *
11
+ * - `"lex"` — combined lexer, text output (default).
12
+ * - `"lex-bitmark"` — bitmark-level only, text output.
13
+ * - `"lex-text"` — text-level only, text output.
14
+ * - `"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
+ */
18
+ type LexStage = "lex" | "lex-bitmark" | "lex-text" | "lex-json" | "lex-bitmark-json" | "lex-text-json";
19
+ /** Options for the {@link lex} function. */
20
+ interface LexOptions {
21
+ /** Selects the lexer pipeline stage (default: `"lex"`). */
22
+ stage?: LexStage;
23
+ }
24
+ /** Options for the {@link parse} function. */
25
+ interface ParseOptions {
26
+ /** JSON output mode (default: `"optimized"`). */
27
+ mode?: OutputMode;
28
+ }
29
+ /** Options for the {@link convert} function. */
30
+ interface ConvertOptions {
31
+ /** JSON output mode (default: `"optimized"`). */
32
+ mode?: OutputMode;
33
+ /** Include validation warnings in output (default: `false`). */
34
+ warnings?: boolean;
35
+ /** Output text as plain text — debug mode (default: `false`). */
36
+ plainText?: boolean;
37
+ /** Prettify JSON output (default: `false`). */
38
+ pretty?: boolean;
39
+ /** Indent size for pretty-printing (default: `2`). */
40
+ indent?: number;
41
+ }
42
+ /** Text format for breakscape / unbreakscape operations. */
43
+ type TextFormat = "bitmark++" | "plainText";
44
+ /** Text location for breakscape / unbreakscape operations. */
45
+ type TextLocation = "body" | "tag";
46
+ /** Options for the {@link breakscapeText} and {@link unbreakscapeText} functions. */
47
+ interface BreakscapeOptions {
48
+ /** Text format (default: `"bitmark++"`). */
49
+ format?: TextFormat;
50
+ /** Text location (default: `"body"`). */
51
+ location?: TextLocation;
52
+ }
53
+ /** Info query type for the {@link info} function. */
54
+ type InfoType = "list" | "bit" | "all" | "deprecated";
55
+ /** Output format for the {@link info} function. */
56
+ type InfoFormat = "text" | "json";
57
+ /** Options for the {@link info} function. */
58
+ interface InfoOptions {
59
+ /** Info query type (default: `"list"`). */
60
+ infoType?: InfoType;
61
+ /** Output format (default: `"text"`). */
62
+ format?: InfoFormat;
63
+ /** Bit name — required when `infoType` is `"bit"`. */
64
+ bit?: string;
65
+ /** Whether to pretty-print JSON output (default: `false`). */
66
+ pretty?: boolean;
67
+ /** Indent size for pretty-printing (default: `2`). */
68
+ indent?: number;
69
+ }
70
+
1
71
  /**
2
72
  * Get the version of the @gmb/bitmark-parser library.
3
73
  *
@@ -8,55 +78,49 @@ declare function version(): string;
8
78
  * Lex bitmark input text, returning one line per token.
9
79
  *
10
80
  * @param input - The bitmark source text.
11
- * @param optionsJson - JSON string with options: stage.
81
+ * @param options - Lex options (e.g. `{ stage: "lex-bitmark" }`).
12
82
  * @returns Token dump string (one token per line).
13
83
  */
14
- declare function lex(input: string, optionsJson?: string): string;
84
+ declare function lex(input: string, options?: LexOptions): string;
15
85
  /**
16
86
  * Parse bitmark input text and return the reference JSON format.
17
87
  *
18
88
  * @param input - The bitmark source text.
19
- * @param optionsJson - JSON string with options: mode.
89
+ * @param options - Parse options (e.g. `{ mode: "full" }`).
20
90
  * @returns JSON string of the parsed bitmark document.
21
91
  */
22
- declare function parse(input: string, optionsJson?: string): string;
92
+ declare function parse(input: string, options?: ParseOptions): string;
23
93
  /**
24
94
  * Auto-detect input format and convert between bitmark and JSON.
25
95
  *
26
96
  * @param input - Bitmark or JSON input text.
27
- * @param optionsJson - JSON string with options: mode, warnings, plainText.
97
+ * @param options - Convert options (e.g. `{ mode: "full", warnings: true }`).
28
98
  * @returns Converted output string.
29
99
  */
30
- declare function convert(input: string, optionsJson?: string): string;
100
+ declare function convert(input: string, options?: ConvertOptions): string;
31
101
  /**
32
102
  * Breakscape text (escape bitmark special characters).
33
103
  *
34
104
  * @param input - The text to breakscape.
35
- * @param format - Text format: `"bitmark++"` (default) or `"plainText"`.
36
- * @param location - Text location: `"body"` (default) or `"tag"`.
105
+ * @param options - Breakscape options (e.g. `{ format: "plainText", location: "tag" }`).
37
106
  * @returns Breakscaped text.
38
107
  */
39
- declare function breakscapeText(input: string, format?: string, location?: string): string;
108
+ declare function breakscapeText(input: string, options?: BreakscapeOptions): string;
40
109
  /**
41
110
  * Unbreakscape text (unescape bitmark special characters).
42
111
  *
43
112
  * @param input - The text to unbreakscape.
44
- * @param format - Text format: `"bitmark++"` (default) or `"plainText"`.
45
- * @param location - Text location: `"body"` (default) or `"tag"`.
113
+ * @param options - Unbreakscape options (e.g. `{ format: "plainText", location: "tag" }`).
46
114
  * @returns Unbreakscaped text.
47
115
  */
48
- declare function unbreakscapeText(input: string, format?: string, location?: string): string;
116
+ declare function unbreakscapeText(input: string, options?: BreakscapeOptions): string;
49
117
  /**
50
118
  * Query information about supported bit types.
51
119
  *
52
- * @param infoType - Info type: `"list"`, `"bit"`, `"all"`, or `"deprecated"`.
53
- * @param format - Output format: `"text"` (default) or `"json"`.
54
- * @param bit - Bit name (required when `infoType` is `"bit"`).
55
- * @param pretty - Whether to pretty-print JSON output.
56
- * @param indent - Indent size for pretty-printing (default: 2).
120
+ * @param options - Info options (e.g. `{ infoType: "bit", format: "json", bit: "cloze" }`).
57
121
  * @returns Information string.
58
122
  */
59
- declare function info(infoType?: string, format?: string, bit?: string, pretty?: boolean, indent?: number): string;
123
+ declare function info(options?: InfoOptions): string;
60
124
  /**
61
125
  * Generate bitmark text from a JSON AST.
62
126
  *
@@ -65,4 +129,4 @@ declare function info(infoType?: string, format?: string, bit?: string, pretty?:
65
129
  */
66
130
  declare function generate(_json: string): string;
67
131
 
68
- export { breakscapeText, convert, generate, info, lex, parse, unbreakscapeText, version };
132
+ export { type BreakscapeOptions, type ConvertOptions, type InfoFormat, type InfoOptions, type InfoType, type LexOptions, type LexStage, type OutputMode, type ParseOptions, type TextFormat, type TextLocation, breakscapeText, convert, generate, info, lex, parse, unbreakscapeText, version };