@gmb/bitmark-parser 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +92 -0
- package/dist/browser/bitmark-parser.min.js +2 -0
- package/dist/browser/bitmark-parser.min.js.map +1 -0
- package/dist/browser/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/index.cjs +319 -0
- package/dist/browser/cjs/index.cjs.map +1 -0
- package/dist/browser/cjs/index.d.cts +98 -0
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +98 -0
- package/dist/browser/esm/index.js +281 -0
- package/dist/browser/esm/index.js.map +1 -0
- package/dist/cli.js +147 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +88 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +67 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/package.json +92 -0
- package/wasm/bitmark_wasm.d.ts +59 -0
- package/wasm/bitmark_wasm.js +298 -0
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +13 -0
- package/wasm/package.json +20 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
breakscapeText: () => breakscapeText,
|
|
24
|
+
convert: () => convert,
|
|
25
|
+
generate: () => generate,
|
|
26
|
+
info: () => info,
|
|
27
|
+
lex: () => lex,
|
|
28
|
+
parse: () => parse,
|
|
29
|
+
unbreakscapeText: () => unbreakscapeText,
|
|
30
|
+
version: () => version
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
|
+
|
|
34
|
+
// ../../node_modules/tsup/assets/cjs_shims.js
|
|
35
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
36
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
37
|
+
|
|
38
|
+
// src/index.ts
|
|
39
|
+
var import_node_module = require("module");
|
|
40
|
+
|
|
41
|
+
// src/generated/package_info.ts
|
|
42
|
+
var PACKAGE_INFO = {
|
|
43
|
+
"name": "@gmb/bitmark-parser",
|
|
44
|
+
"version": "3.0.0-alpha.1",
|
|
45
|
+
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
46
|
+
"license": "ISC",
|
|
47
|
+
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/index.ts
|
|
51
|
+
var require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
52
|
+
var wasm = require2("../wasm/bitmark_wasm.js");
|
|
53
|
+
function version() {
|
|
54
|
+
return PACKAGE_INFO.version;
|
|
55
|
+
}
|
|
56
|
+
function lex(input, stage = "lex") {
|
|
57
|
+
return wasm.lex(input, stage);
|
|
58
|
+
}
|
|
59
|
+
function parse(input) {
|
|
60
|
+
return wasm.parse(input);
|
|
61
|
+
}
|
|
62
|
+
function convert(input, optionsJson = "{}") {
|
|
63
|
+
return wasm.convert(input, optionsJson);
|
|
64
|
+
}
|
|
65
|
+
function breakscapeText(input, format = "bitmark++", location = "body") {
|
|
66
|
+
return wasm.breakscape_text(input, format, location);
|
|
67
|
+
}
|
|
68
|
+
function unbreakscapeText(input, format = "bitmark++", location = "body") {
|
|
69
|
+
return wasm.unbreakscape_text(input, format, location);
|
|
70
|
+
}
|
|
71
|
+
function info(infoType = "list", format = "text", bit = "", pretty = false, indent = 2) {
|
|
72
|
+
return wasm.info(infoType, format, bit, pretty, indent);
|
|
73
|
+
}
|
|
74
|
+
function generate(_json) {
|
|
75
|
+
throw new Error("generate is not yet implemented");
|
|
76
|
+
}
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
breakscapeText,
|
|
80
|
+
convert,
|
|
81
|
+
generate,
|
|
82
|
+
info,
|
|
83
|
+
lex,
|
|
84
|
+
parse,
|
|
85
|
+
unbreakscapeText,
|
|
86
|
+
version
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +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 stage - Lexer stage: `\"lex\"` (combined), `\"lex-bitmark\"`, or `\"lex-text\"`.\n * @returns Token dump string (one token per line).\n */\nexport function lex(input: string, stage: string = \"lex\"): string {\n return wasm.lex(input, stage);\n}\n\n/**\n * Parse bitmark input text and return the reference JSON format.\n *\n * @param input - The bitmark source text.\n * @returns JSON string of the parsed bitmark document.\n */\nexport function parse(input: string): string {\n return wasm.parse(input);\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.0-alpha.1\",\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,QAAgB,OAAe;AAChE,SAAO,KAAK,IAAI,OAAO,KAAK;AAC9B;AAQO,SAAS,MAAM,OAAuB;AAC3C,SAAO,KAAK,MAAM,KAAK;AACzB;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"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the version of the @gmb/bitmark-parser library.
|
|
3
|
+
*
|
|
4
|
+
* @returns Version string (e.g. "3.0.0").
|
|
5
|
+
*/
|
|
6
|
+
declare function version(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Lex bitmark input text, returning one line per token.
|
|
9
|
+
*
|
|
10
|
+
* @param input - The bitmark source text.
|
|
11
|
+
* @param stage - Lexer stage: `"lex"` (combined), `"lex-bitmark"`, or `"lex-text"`.
|
|
12
|
+
* @returns Token dump string (one token per line).
|
|
13
|
+
*/
|
|
14
|
+
declare function lex(input: string, stage?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Parse bitmark input text and return the reference JSON format.
|
|
17
|
+
*
|
|
18
|
+
* @param input - The bitmark source text.
|
|
19
|
+
* @returns JSON string of the parsed bitmark document.
|
|
20
|
+
*/
|
|
21
|
+
declare function parse(input: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Auto-detect input format and convert between bitmark and JSON.
|
|
24
|
+
*
|
|
25
|
+
* @param input - Bitmark or JSON input text.
|
|
26
|
+
* @param optionsJson - JSON string with options: mode, warnings, plainText.
|
|
27
|
+
* @returns Converted output string.
|
|
28
|
+
*/
|
|
29
|
+
declare function convert(input: string, optionsJson?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Breakscape text (escape bitmark special characters).
|
|
32
|
+
*
|
|
33
|
+
* @param input - The text to breakscape.
|
|
34
|
+
* @param format - Text format: `"bitmark++"` (default) or `"plainText"`.
|
|
35
|
+
* @param location - Text location: `"body"` (default) or `"tag"`.
|
|
36
|
+
* @returns Breakscaped text.
|
|
37
|
+
*/
|
|
38
|
+
declare function breakscapeText(input: string, format?: string, location?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Unbreakscape text (unescape bitmark special characters).
|
|
41
|
+
*
|
|
42
|
+
* @param input - The text to unbreakscape.
|
|
43
|
+
* @param format - Text format: `"bitmark++"` (default) or `"plainText"`.
|
|
44
|
+
* @param location - Text location: `"body"` (default) or `"tag"`.
|
|
45
|
+
* @returns Unbreakscaped text.
|
|
46
|
+
*/
|
|
47
|
+
declare function unbreakscapeText(input: string, format?: string, location?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Query information about supported bit types.
|
|
50
|
+
*
|
|
51
|
+
* @param infoType - Info type: `"list"`, `"bit"`, `"all"`, or `"deprecated"`.
|
|
52
|
+
* @param format - Output format: `"text"` (default) or `"json"`.
|
|
53
|
+
* @param bit - Bit name (required when `infoType` is `"bit"`).
|
|
54
|
+
* @param pretty - Whether to pretty-print JSON output.
|
|
55
|
+
* @param indent - Indent size for pretty-printing (default: 2).
|
|
56
|
+
* @returns Information string.
|
|
57
|
+
*/
|
|
58
|
+
declare function info(infoType?: string, format?: string, bit?: string, pretty?: boolean, indent?: number): string;
|
|
59
|
+
/**
|
|
60
|
+
* Generate bitmark text from a JSON AST.
|
|
61
|
+
*
|
|
62
|
+
* @param _json - JSON string of the AST.
|
|
63
|
+
* @throws Always throws — not yet implemented.
|
|
64
|
+
*/
|
|
65
|
+
declare function generate(_json: string): string;
|
|
66
|
+
|
|
67
|
+
export { breakscapeText, convert, generate, info, lex, parse, unbreakscapeText, version };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the version of the @gmb/bitmark-parser library.
|
|
3
|
+
*
|
|
4
|
+
* @returns Version string (e.g. "3.0.0").
|
|
5
|
+
*/
|
|
6
|
+
declare function version(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Lex bitmark input text, returning one line per token.
|
|
9
|
+
*
|
|
10
|
+
* @param input - The bitmark source text.
|
|
11
|
+
* @param stage - Lexer stage: `"lex"` (combined), `"lex-bitmark"`, or `"lex-text"`.
|
|
12
|
+
* @returns Token dump string (one token per line).
|
|
13
|
+
*/
|
|
14
|
+
declare function lex(input: string, stage?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Parse bitmark input text and return the reference JSON format.
|
|
17
|
+
*
|
|
18
|
+
* @param input - The bitmark source text.
|
|
19
|
+
* @returns JSON string of the parsed bitmark document.
|
|
20
|
+
*/
|
|
21
|
+
declare function parse(input: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Auto-detect input format and convert between bitmark and JSON.
|
|
24
|
+
*
|
|
25
|
+
* @param input - Bitmark or JSON input text.
|
|
26
|
+
* @param optionsJson - JSON string with options: mode, warnings, plainText.
|
|
27
|
+
* @returns Converted output string.
|
|
28
|
+
*/
|
|
29
|
+
declare function convert(input: string, optionsJson?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Breakscape text (escape bitmark special characters).
|
|
32
|
+
*
|
|
33
|
+
* @param input - The text to breakscape.
|
|
34
|
+
* @param format - Text format: `"bitmark++"` (default) or `"plainText"`.
|
|
35
|
+
* @param location - Text location: `"body"` (default) or `"tag"`.
|
|
36
|
+
* @returns Breakscaped text.
|
|
37
|
+
*/
|
|
38
|
+
declare function breakscapeText(input: string, format?: string, location?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Unbreakscape text (unescape bitmark special characters).
|
|
41
|
+
*
|
|
42
|
+
* @param input - The text to unbreakscape.
|
|
43
|
+
* @param format - Text format: `"bitmark++"` (default) or `"plainText"`.
|
|
44
|
+
* @param location - Text location: `"body"` (default) or `"tag"`.
|
|
45
|
+
* @returns Unbreakscaped text.
|
|
46
|
+
*/
|
|
47
|
+
declare function unbreakscapeText(input: string, format?: string, location?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Query information about supported bit types.
|
|
50
|
+
*
|
|
51
|
+
* @param infoType - Info type: `"list"`, `"bit"`, `"all"`, or `"deprecated"`.
|
|
52
|
+
* @param format - Output format: `"text"` (default) or `"json"`.
|
|
53
|
+
* @param bit - Bit name (required when `infoType` is `"bit"`).
|
|
54
|
+
* @param pretty - Whether to pretty-print JSON output.
|
|
55
|
+
* @param indent - Indent size for pretty-printing (default: 2).
|
|
56
|
+
* @returns Information string.
|
|
57
|
+
*/
|
|
58
|
+
declare function info(infoType?: string, format?: string, bit?: string, pretty?: boolean, indent?: number): string;
|
|
59
|
+
/**
|
|
60
|
+
* Generate bitmark text from a JSON AST.
|
|
61
|
+
*
|
|
62
|
+
* @param _json - JSON string of the AST.
|
|
63
|
+
* @throws Always throws — not yet implemented.
|
|
64
|
+
*/
|
|
65
|
+
declare function generate(_json: string): string;
|
|
66
|
+
|
|
67
|
+
export { breakscapeText, convert, generate, info, lex, parse, unbreakscapeText, version };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
|
|
4
|
+
// src/generated/package_info.ts
|
|
5
|
+
var PACKAGE_INFO = {
|
|
6
|
+
"name": "@gmb/bitmark-parser",
|
|
7
|
+
"version": "3.0.0-alpha.1",
|
|
8
|
+
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/index.ts
|
|
14
|
+
var require2 = createRequire(import.meta.url);
|
|
15
|
+
var wasm = require2("../wasm/bitmark_wasm.js");
|
|
16
|
+
function version() {
|
|
17
|
+
return PACKAGE_INFO.version;
|
|
18
|
+
}
|
|
19
|
+
function lex(input, stage = "lex") {
|
|
20
|
+
return wasm.lex(input, stage);
|
|
21
|
+
}
|
|
22
|
+
function parse(input) {
|
|
23
|
+
return wasm.parse(input);
|
|
24
|
+
}
|
|
25
|
+
function convert(input, optionsJson = "{}") {
|
|
26
|
+
return wasm.convert(input, optionsJson);
|
|
27
|
+
}
|
|
28
|
+
function breakscapeText(input, format = "bitmark++", location = "body") {
|
|
29
|
+
return wasm.breakscape_text(input, format, location);
|
|
30
|
+
}
|
|
31
|
+
function unbreakscapeText(input, format = "bitmark++", location = "body") {
|
|
32
|
+
return wasm.unbreakscape_text(input, format, location);
|
|
33
|
+
}
|
|
34
|
+
function info(infoType = "list", format = "text", bit = "", pretty = false, indent = 2) {
|
|
35
|
+
return wasm.info(infoType, format, bit, pretty, indent);
|
|
36
|
+
}
|
|
37
|
+
function generate(_json) {
|
|
38
|
+
throw new Error("generate is not yet implemented");
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
breakscapeText,
|
|
42
|
+
convert,
|
|
43
|
+
generate,
|
|
44
|
+
info,
|
|
45
|
+
lex,
|
|
46
|
+
parse,
|
|
47
|
+
unbreakscapeText,
|
|
48
|
+
version
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/generated/package_info.ts"],"sourcesContent":["// @zen-component: WASM-TSBindings\n\nimport { createRequire } from \"node:module\";\nimport { PACKAGE_INFO } from \"./generated/package_info.js\";\nconst require = createRequire(import.meta.url);\nconst wasm = require(\"../wasm/bitmark_wasm.js\") as typeof import(\"../wasm/bitmark_wasm.js\");\n\n/**\n * Get the version of the @gmb/bitmark-parser library.\n *\n * @returns Version string (e.g. \"3.0.0\").\n */\nexport function version(): string {\n return PACKAGE_INFO.version;\n}\n\n/**\n * Lex bitmark input text, returning one line per token.\n *\n * @param input - The bitmark source text.\n * @param stage - Lexer stage: `\"lex\"` (combined), `\"lex-bitmark\"`, or `\"lex-text\"`.\n * @returns Token dump string (one token per line).\n */\nexport function lex(input: string, stage: string = \"lex\"): string {\n return wasm.lex(input, stage);\n}\n\n/**\n * Parse bitmark input text and return the reference JSON format.\n *\n * @param input - The bitmark source text.\n * @returns JSON string of the parsed bitmark document.\n */\nexport function parse(input: string): string {\n return wasm.parse(input);\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","// 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.0-alpha.1\",\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;;;ADNA,IAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,OAAOA,SAAQ,yBAAyB;AAOvC,SAAS,UAAkB;AAChC,SAAO,aAAa;AACtB;AASO,SAAS,IAAI,OAAe,QAAgB,OAAe;AAChE,SAAO,KAAK,IAAI,OAAO,KAAK;AAC9B;AAQO,SAAS,MAAM,OAAuB;AAC3C,SAAO,KAAK,MAAM,KAAK;AACzB;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"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gmb/bitmark-parser",
|
|
3
|
+
"version": "3.0.0-alpha.1",
|
|
4
|
+
"description": "A parser for bitmark text, powered by WebAssembly.",
|
|
5
|
+
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"homepage": "https://github.com/getMoreBrain/bitmark-parser#readme",
|
|
8
|
+
"bin": {
|
|
9
|
+
"bitmark-parser-wasm": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"browser": "./dist/browser/esm/index.js",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
"./browser/cjs": {
|
|
18
|
+
"browser": "./dist/browser/cjs/index.cjs",
|
|
19
|
+
"import": "./dist/browser/cjs/index.cjs",
|
|
20
|
+
"require": "./dist/browser/cjs/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./browser/esm": {
|
|
23
|
+
"browser": "./dist/browser/esm/index.js",
|
|
24
|
+
"import": "./dist/browser/esm/index.js",
|
|
25
|
+
"require": "./dist/browser/esm/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./browser": {
|
|
28
|
+
"browser": "./dist/browser/esm/index.js",
|
|
29
|
+
"import": "./dist/browser/esm/index.js",
|
|
30
|
+
"require": "./dist/browser/cjs/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./cjs": {
|
|
33
|
+
"import": "./dist/index.cjs",
|
|
34
|
+
"require": "./dist/index.cjs"
|
|
35
|
+
},
|
|
36
|
+
"./esm": {
|
|
37
|
+
"import": "./dist/index.js",
|
|
38
|
+
"require": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"import": "./dist/index.js",
|
|
43
|
+
"require": "./dist/index.cjs",
|
|
44
|
+
"default": "./dist/index.js"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"wasm",
|
|
50
|
+
"README.md",
|
|
51
|
+
"LICENSE"
|
|
52
|
+
],
|
|
53
|
+
"scripts": {
|
|
54
|
+
"init": "npx tsx scripts/create-package-info.ts",
|
|
55
|
+
"build:wasm": "bash scripts/build-wasm.sh",
|
|
56
|
+
"build:ts": "npm run init && tsup",
|
|
57
|
+
"build": "npm run build:wasm && npm run build:ts",
|
|
58
|
+
"test": "node test/smoke.mjs && node --test test/cross-validate.mjs && node --test test/cli.test.mjs",
|
|
59
|
+
"test:browser-smoke": "bash scripts/launch-browser-smoke.sh",
|
|
60
|
+
"test:browser-perf": "bash scripts/launch-browser-perf.sh",
|
|
61
|
+
"test:cli-perf": "bash scripts/launch-cli-perf.sh",
|
|
62
|
+
"prepublishOnly": "npm run build && npm test"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"commander": "^14.0.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/node": "^25.2.2",
|
|
69
|
+
"tsup": "^8.5.1",
|
|
70
|
+
"tsx": "^4.21.0",
|
|
71
|
+
"typescript": "^5.8.0"
|
|
72
|
+
},
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": ">=20",
|
|
75
|
+
"npm": ">=10"
|
|
76
|
+
},
|
|
77
|
+
"keywords": [
|
|
78
|
+
"bitmark",
|
|
79
|
+
"parser",
|
|
80
|
+
"wasm",
|
|
81
|
+
"webassembly"
|
|
82
|
+
],
|
|
83
|
+
"repository": {
|
|
84
|
+
"type": "git",
|
|
85
|
+
"url": "git+https://github.com/getMoreBrain/bitmark-parser.git"
|
|
86
|
+
},
|
|
87
|
+
"jsdelivr": "dist/browser/bitmark-parser.min.js",
|
|
88
|
+
"unpkg": "dist/browser/bitmark-parser.min.js",
|
|
89
|
+
"contributors": [
|
|
90
|
+
"Richard Sewell (https://github.com/six5536)"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Auto-detect input format and convert between bitmark and JSON.
|
|
5
|
+
*
|
|
6
|
+
* `options_json` is a JSON string with optional fields:
|
|
7
|
+
* - `"mode"`: `"optimized"` (default) or `"full"`
|
|
8
|
+
* - `"warnings"`: `true` or `false` (default)
|
|
9
|
+
* - `"plainText"`: `true` or `false` (default)
|
|
10
|
+
* - `"pretty"`: `true` or `false` (default)
|
|
11
|
+
* - `"indent"`: number (default: 2)
|
|
12
|
+
*
|
|
13
|
+
* Returns JSON if input is bitmark, or an error message if input is JSON
|
|
14
|
+
* (generator not yet implemented).
|
|
15
|
+
*/
|
|
16
|
+
export function convert(input: string, options_json: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Breakscape text (escape bitmark special characters).
|
|
19
|
+
*
|
|
20
|
+
* `format`: `"bitmark++"` (default) or `"plainText"`
|
|
21
|
+
* `location`: `"body"` (default) or `"tag"`
|
|
22
|
+
*/
|
|
23
|
+
export function breakscape_text(input: string, format: string, location: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Query information about supported bit types.
|
|
26
|
+
*
|
|
27
|
+
* `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
|
|
28
|
+
* `format`: `"text"` or `"json"`
|
|
29
|
+
* `bit`: bit name (required when `info_type` is `"bit"`)
|
|
30
|
+
* `pretty`: whether to pretty-print JSON output
|
|
31
|
+
* `indent`: indent size for pretty-printing (default: 2)
|
|
32
|
+
*/
|
|
33
|
+
export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Unbreakscape text (unescape bitmark special characters).
|
|
36
|
+
*
|
|
37
|
+
* `format`: `"bitmark++"` (default) or `"plainText"`
|
|
38
|
+
* `location`: `"body"` (default) or `"tag"`
|
|
39
|
+
*/
|
|
40
|
+
export function unbreakscape_text(input: string, format: string, location: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Parse bitmark input text and return the reference JSON format.
|
|
43
|
+
*
|
|
44
|
+
* Uses the full pipeline: parse → validate → serialize with optimized mode.
|
|
45
|
+
*/
|
|
46
|
+
export function parse(input: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Lex bitmark input text, returning one line per token in the same format as
|
|
49
|
+
* the Rust CLI: `{kind:?} {span:?} "{text}"`.
|
|
50
|
+
*
|
|
51
|
+
* `stage` selects the lexer pipeline:
|
|
52
|
+
* - `"lex"` — combined (default)
|
|
53
|
+
* - `"lex-bitmark"` — bitmark-level only
|
|
54
|
+
* - `"lex-text"` — text-level only
|
|
55
|
+
* - `"lex-json"` — combined, JSON array output
|
|
56
|
+
* - `"lex-bitmark-json"` — bitmark-level, JSON array output
|
|
57
|
+
* - `"lex-text-json"` — text-level, JSON array output
|
|
58
|
+
*/
|
|
59
|
+
export function lex(input: string, stage: string): string;
|