@gmb/bitmark-parser 3.0.1-alpha.5 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -21
- package/dist/browser/bitmark-parser.min.js +1 -1
- package/dist/browser/bitmark-parser.min.js.map +1 -1
- package/dist/browser/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/cjs/index.cjs +31 -31
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +9 -10
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +9 -10
- package/dist/browser/esm/index.js +31 -31
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/cli.js +6 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -10
- package/dist/index.d.ts +9 -10
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/wasm/bitmark_wasm.d.ts +20 -24
- package/wasm/bitmark_wasm.js +58 -62
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/package.json +1 -1
|
@@ -46,13 +46,9 @@ type OutputMode = "optimized" | "full";
|
|
|
46
46
|
* Lexer stage selector.
|
|
47
47
|
*
|
|
48
48
|
* - `"lex"` — combined lexer, text output (default).
|
|
49
|
-
* - `"lex-bitmark"` — bitmark-level only, text output.
|
|
50
|
-
* - `"lex-text"` — text-level only, text output.
|
|
51
49
|
* - `"lex-json"` — combined lexer, JSON array output.
|
|
52
|
-
* - `"lex-bitmark-json"` — bitmark-level only, JSON array output.
|
|
53
|
-
* - `"lex-text-json"` — text-level only, JSON array output.
|
|
54
50
|
*/
|
|
55
|
-
type LexStage = "lex" | "lex-
|
|
51
|
+
type LexStage = "lex" | "lex-json";
|
|
56
52
|
/** Options for the {@link lex} function. */
|
|
57
53
|
interface LexOptions {
|
|
58
54
|
/** Selects the lexer pipeline stage (default: `"lex"`). */
|
|
@@ -67,7 +63,7 @@ interface ParseOptions {
|
|
|
67
63
|
interface ConvertOptions {
|
|
68
64
|
/** JSON output mode (default: `"optimized"`). */
|
|
69
65
|
mode?: OutputMode;
|
|
70
|
-
/** Include validation warnings in output (default: `false`). */
|
|
66
|
+
/** Include validation warnings in `parser.warnings` output (default: `false`). */
|
|
71
67
|
warnings?: boolean;
|
|
72
68
|
/** Output text as plain text — debug mode (default: `false`). */
|
|
73
69
|
plainText?: boolean;
|
|
@@ -115,16 +111,18 @@ declare function version(): string;
|
|
|
115
111
|
* Lex bitmark input text, returning one line per token.
|
|
116
112
|
*
|
|
117
113
|
* @param input - The bitmark source text.
|
|
118
|
-
* @param options - Lex options (e.g. `{ stage: "lex
|
|
114
|
+
* @param options - Lex options (e.g. `{ stage: "lex" }`).
|
|
119
115
|
* @returns Token dump string (one token per line).
|
|
120
116
|
*/
|
|
121
117
|
declare function lex(input: string, options?: LexOptions): string;
|
|
122
118
|
/**
|
|
123
|
-
* Parse bitmark input text and return
|
|
119
|
+
* Parse bitmark input text and return structured JSON entries.
|
|
120
|
+
*
|
|
121
|
+
* Each entry contains `bit`, `parser`, and `bitmark` fields.
|
|
124
122
|
*
|
|
125
123
|
* @param input - The bitmark source text.
|
|
126
124
|
* @param options - Parse options (e.g. `{ mode: "full" }`).
|
|
127
|
-
* @returns JSON string of
|
|
125
|
+
* @returns JSON string array of structured parsed entries.
|
|
128
126
|
*/
|
|
129
127
|
declare function parse(input: string, options?: ParseOptions): string;
|
|
130
128
|
/**
|
|
@@ -132,7 +130,8 @@ declare function parse(input: string, options?: ParseOptions): string;
|
|
|
132
130
|
*
|
|
133
131
|
* @param input - Bitmark or JSON input text.
|
|
134
132
|
* @param options - Convert options (e.g. `{ mode: "full", warnings: true }`).
|
|
135
|
-
* @returns Converted output string.
|
|
133
|
+
* @returns Converted output string. For bitmark input, this is a JSON string
|
|
134
|
+
* array of structured parsed entries (`bit`, `parser`, `bitmark`).
|
|
136
135
|
*/
|
|
137
136
|
declare function convert(input: string, options?: ConvertOptions): string;
|
|
138
137
|
/**
|
|
Binary file
|
|
@@ -46,13 +46,9 @@ type OutputMode = "optimized" | "full";
|
|
|
46
46
|
* Lexer stage selector.
|
|
47
47
|
*
|
|
48
48
|
* - `"lex"` — combined lexer, text output (default).
|
|
49
|
-
* - `"lex-bitmark"` — bitmark-level only, text output.
|
|
50
|
-
* - `"lex-text"` — text-level only, text output.
|
|
51
49
|
* - `"lex-json"` — combined lexer, JSON array output.
|
|
52
|
-
* - `"lex-bitmark-json"` — bitmark-level only, JSON array output.
|
|
53
|
-
* - `"lex-text-json"` — text-level only, JSON array output.
|
|
54
50
|
*/
|
|
55
|
-
type LexStage = "lex" | "lex-
|
|
51
|
+
type LexStage = "lex" | "lex-json";
|
|
56
52
|
/** Options for the {@link lex} function. */
|
|
57
53
|
interface LexOptions {
|
|
58
54
|
/** Selects the lexer pipeline stage (default: `"lex"`). */
|
|
@@ -67,7 +63,7 @@ interface ParseOptions {
|
|
|
67
63
|
interface ConvertOptions {
|
|
68
64
|
/** JSON output mode (default: `"optimized"`). */
|
|
69
65
|
mode?: OutputMode;
|
|
70
|
-
/** Include validation warnings in output (default: `false`). */
|
|
66
|
+
/** Include validation warnings in `parser.warnings` output (default: `false`). */
|
|
71
67
|
warnings?: boolean;
|
|
72
68
|
/** Output text as plain text — debug mode (default: `false`). */
|
|
73
69
|
plainText?: boolean;
|
|
@@ -115,16 +111,18 @@ declare function version(): string;
|
|
|
115
111
|
* Lex bitmark input text, returning one line per token.
|
|
116
112
|
*
|
|
117
113
|
* @param input - The bitmark source text.
|
|
118
|
-
* @param options - Lex options (e.g. `{ stage: "lex
|
|
114
|
+
* @param options - Lex options (e.g. `{ stage: "lex" }`).
|
|
119
115
|
* @returns Token dump string (one token per line).
|
|
120
116
|
*/
|
|
121
117
|
declare function lex(input: string, options?: LexOptions): string;
|
|
122
118
|
/**
|
|
123
|
-
* Parse bitmark input text and return
|
|
119
|
+
* Parse bitmark input text and return structured JSON entries.
|
|
120
|
+
*
|
|
121
|
+
* Each entry contains `bit`, `parser`, and `bitmark` fields.
|
|
124
122
|
*
|
|
125
123
|
* @param input - The bitmark source text.
|
|
126
124
|
* @param options - Parse options (e.g. `{ mode: "full" }`).
|
|
127
|
-
* @returns JSON string of
|
|
125
|
+
* @returns JSON string array of structured parsed entries.
|
|
128
126
|
*/
|
|
129
127
|
declare function parse(input: string, options?: ParseOptions): string;
|
|
130
128
|
/**
|
|
@@ -132,7 +130,8 @@ declare function parse(input: string, options?: ParseOptions): string;
|
|
|
132
130
|
*
|
|
133
131
|
* @param input - Bitmark or JSON input text.
|
|
134
132
|
* @param options - Convert options (e.g. `{ mode: "full", warnings: true }`).
|
|
135
|
-
* @returns Converted output string.
|
|
133
|
+
* @returns Converted output string. For bitmark input, this is a JSON string
|
|
134
|
+
* array of structured parsed entries (`bit`, `parser`, `bitmark`).
|
|
136
135
|
*/
|
|
137
136
|
declare function convert(input: string, options?: ConvertOptions): string;
|
|
138
137
|
/**
|
|
@@ -68,29 +68,27 @@ function getStringFromWasm0(ptr, len) {
|
|
|
68
68
|
ptr = ptr >>> 0;
|
|
69
69
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
let
|
|
73
|
-
let
|
|
71
|
+
function lex(input, stage) {
|
|
72
|
+
let deferred3_0;
|
|
73
|
+
let deferred3_1;
|
|
74
74
|
try {
|
|
75
75
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
76
76
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
77
77
|
const len0 = WASM_VECTOR_LEN;
|
|
78
|
-
const ptr1 = passStringToWasm0(
|
|
78
|
+
const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
79
79
|
const len1 = WASM_VECTOR_LEN;
|
|
80
|
-
|
|
81
|
-
const len2 = WASM_VECTOR_LEN;
|
|
82
|
-
wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
80
|
+
wasm.lex(retptr, ptr0, len0, ptr1, len1);
|
|
83
81
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
84
82
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
deferred3_0 = r0;
|
|
84
|
+
deferred3_1 = r1;
|
|
87
85
|
return getStringFromWasm0(r0, r1);
|
|
88
86
|
} finally {
|
|
89
87
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
90
|
-
wasm.__wbindgen_export_2(
|
|
88
|
+
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
function
|
|
91
|
+
function breakscape_text(input, format, location) {
|
|
94
92
|
let deferred4_0;
|
|
95
93
|
let deferred4_1;
|
|
96
94
|
try {
|
|
@@ -101,7 +99,7 @@ function unbreakscape_text(input, format, location) {
|
|
|
101
99
|
const len1 = WASM_VECTOR_LEN;
|
|
102
100
|
const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
103
101
|
const len2 = WASM_VECTOR_LEN;
|
|
104
|
-
wasm.
|
|
102
|
+
wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
105
103
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
106
104
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
107
105
|
deferred4_0 = r0;
|
|
@@ -112,7 +110,7 @@ function unbreakscape_text(input, format, location) {
|
|
|
112
110
|
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
|
-
function
|
|
113
|
+
function convert(input, mode, warnings, plain_text, pretty, indent) {
|
|
116
114
|
let deferred3_0;
|
|
117
115
|
let deferred3_1;
|
|
118
116
|
try {
|
|
@@ -121,7 +119,7 @@ function parse(input, mode) {
|
|
|
121
119
|
const len0 = WASM_VECTOR_LEN;
|
|
122
120
|
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
123
121
|
const len1 = WASM_VECTOR_LEN;
|
|
124
|
-
wasm.
|
|
122
|
+
wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);
|
|
125
123
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
126
124
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
127
125
|
deferred3_0 = r0;
|
|
@@ -132,38 +130,40 @@ function parse(input, mode) {
|
|
|
132
130
|
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
133
131
|
}
|
|
134
132
|
}
|
|
135
|
-
function
|
|
136
|
-
let
|
|
137
|
-
let
|
|
133
|
+
function info(info_type, format, bit, pretty, indent) {
|
|
134
|
+
let deferred4_0;
|
|
135
|
+
let deferred4_1;
|
|
138
136
|
try {
|
|
139
137
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
140
|
-
const ptr0 = passStringToWasm0(
|
|
138
|
+
const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
141
139
|
const len0 = WASM_VECTOR_LEN;
|
|
142
|
-
const ptr1 = passStringToWasm0(
|
|
140
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
143
141
|
const len1 = WASM_VECTOR_LEN;
|
|
144
|
-
|
|
142
|
+
const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
143
|
+
const len2 = WASM_VECTOR_LEN;
|
|
144
|
+
wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
|
|
145
145
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
146
146
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
deferred4_0 = r0;
|
|
148
|
+
deferred4_1 = r1;
|
|
149
149
|
return getStringFromWasm0(r0, r1);
|
|
150
150
|
} finally {
|
|
151
151
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
152
|
-
wasm.__wbindgen_export_2(
|
|
152
|
+
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function unbreakscape_text(input, format, location) {
|
|
156
156
|
let deferred4_0;
|
|
157
157
|
let deferred4_1;
|
|
158
158
|
try {
|
|
159
159
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
160
|
-
const ptr0 = passStringToWasm0(
|
|
160
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
161
161
|
const len0 = WASM_VECTOR_LEN;
|
|
162
162
|
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
163
163
|
const len1 = WASM_VECTOR_LEN;
|
|
164
|
-
const ptr2 = passStringToWasm0(
|
|
164
|
+
const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
165
165
|
const len2 = WASM_VECTOR_LEN;
|
|
166
|
-
wasm.
|
|
166
|
+
wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
167
167
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
168
168
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
169
169
|
deferred4_0 = r0;
|
|
@@ -174,16 +174,16 @@ function info(info_type, format, bit, pretty, indent) {
|
|
|
174
174
|
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function parse(input, mode) {
|
|
178
178
|
let deferred3_0;
|
|
179
179
|
let deferred3_1;
|
|
180
180
|
try {
|
|
181
181
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
182
182
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
183
183
|
const len0 = WASM_VECTOR_LEN;
|
|
184
|
-
const ptr1 = passStringToWasm0(
|
|
184
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
185
185
|
const len1 = WASM_VECTOR_LEN;
|
|
186
|
-
wasm.
|
|
186
|
+
wasm.parse(retptr, ptr0, len0, ptr1, len1);
|
|
187
187
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
188
188
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
189
189
|
deferred3_0 = r0;
|
|
@@ -274,7 +274,7 @@ var bitmark_wasm_default = __wbg_init;
|
|
|
274
274
|
// src/generated/package_info.ts
|
|
275
275
|
var PACKAGE_INFO = {
|
|
276
276
|
"name": "@gmb/bitmark-parser",
|
|
277
|
-
"version": "3.0.
|
|
277
|
+
"version": "3.0.2",
|
|
278
278
|
"author": "Get More Brain Ltd <info@getmorebrain.com>",
|
|
279
279
|
"license": "ISC",
|
|
280
280
|
"description": "A parser for bitmark text, powered by WebAssembly."
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../wasm-web/bitmark_wasm.js","../../../src/generated/package_info.ts","../../../src/browser/index.ts"],"sourcesContent":["let wasm;\n\nlet WASM_VECTOR_LEN = 0;\n\nlet cachedUint8ArrayMemory0 = null;\n\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nconst cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachedDataViewMemory0 = null;\n\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nconst cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );\n\nif (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * `format`: `\"bitmark++\"` (default) or `\"plainText\"`\n * `location`: `\"body\"` (default) or `\"tag\"`\n * @param {string} input\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function breakscape_text(input, format, location) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Unbreakscape text (unescape bitmark special characters).\n *\n * `format`: `\"bitmark++\"` (default) or `\"plainText\"`\n * `location`: `\"body\"` (default) or `\"tag\"`\n * @param {string} input\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function unbreakscape_text(input, format, location) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Parse bitmark input text and return the reference JSON format.\n *\n * Uses the full pipeline: parse → validate → serialize.\n *\n * `mode`: `\"optimized\"` (default) or `\"full\"`\n * @param {string} input\n * @param {string} mode\n * @returns {string}\n */\nexport function parse(input, mode) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.parse(retptr, ptr0, len0, ptr1, len1);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Auto-detect input format and convert between bitmark and JSON.\n *\n * `mode`: `\"optimized\"` (default) or `\"full\"`\n * `warnings`: whether to include validation warnings (default: false)\n * `plain_text`: output text as plain text — debug mode (default: false)\n * `pretty`: prettify JSON output (default: false)\n * `indent`: indent size for pretty-printing (default: 2)\n *\n * Returns JSON if input is bitmark, or an error message if input is JSON\n * (generator not yet implemented).\n * @param {string} input\n * @param {string} mode\n * @param {boolean} warnings\n * @param {boolean} plain_text\n * @param {boolean} pretty\n * @param {number} indent\n * @returns {string}\n */\nexport function convert(input, mode, warnings, plain_text, pretty, indent) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Query information about supported bit types.\n *\n * `info_type`: `\"list\"`, `\"bit\"`, `\"all\"`, or `\"deprecated\"`\n * `format`: `\"text\"` or `\"json\"`\n * `bit`: bit name (required when `info_type` is `\"bit\"`)\n * `pretty`: whether to pretty-print JSON output\n * `indent`: indent size for pretty-printing (default: 2)\n * @param {string} info_type\n * @param {string} format\n * @param {string} bit\n * @param {boolean} pretty\n * @param {number} indent\n * @returns {string}\n */\nexport function info(info_type, format, bit, pretty, indent) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Lex bitmark input text, returning one line per token in the same format as\n * the Rust CLI: `{kind:?} {span:?} \"{text}\"`.\n *\n * `stage` selects the lexer pipeline:\n * - `\"lex\"` — combined (default)\n * - `\"lex-bitmark\"` — bitmark-level only\n * - `\"lex-text\"` — text-level only\n * - `\"lex-json\"` — combined, JSON array output\n * - `\"lex-bitmark-json\"` — bitmark-level, JSON array output\n * - `\"lex-text-json\"` — text-level, JSON array output\n * @param {string} input\n * @param {string} stage\n * @returns {string}\n */\nexport function lex(input, stage) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.lex(retptr, ptr0, len0, ptr1, len1);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nfunction __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n\n return imports;\n}\n\nfunction __wbg_init_memory(imports, memory) {\n\n}\n\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n __wbg_init.__wbindgen_wasm_module = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n\n\n\n return wasm;\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module !== 'undefined') {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n\n __wbg_init_memory(imports);\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module_or_path !== 'undefined') {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (typeof module_or_path === 'undefined') {\n module_or_path = new URL('bitmark_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n __wbg_init_memory(imports);\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync };\nexport default __wbg_init;\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","// This is a browser entry point that wraps the wasm-web bindings.\n// It re-exports all WASM functions so browser consumers can use:\n// import { parse, convert, ... } from '@gmb/bitmark-parser/browser'\n\nimport * as wasm from \"../../wasm-web/bitmark_wasm.js\";\nimport { PACKAGE_INFO } from \"../generated/package_info.js\";\n\nexport { default as init, initSync } from \"../../wasm-web/bitmark_wasm.js\";\n\nexport type { LexOptions, LexStage, ParseOptions, ConvertOptions, OutputMode, BreakscapeOptions, TextFormat, TextLocation, InfoOptions, InfoType, InfoFormat } from \"../types.js\";\nimport type { LexOptions, ParseOptions, ConvertOptions, BreakscapeOptions, InfoOptions } 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"],"mappings":";AAAA,IAAI;AAEJ,IAA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,QAAQ,QAAQ;AACrD;AASO,SAAS,iBAAiB,OAAe,UAA6B,CAAC,GAAW;AACvF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAY,kBAAkB,OAAO,QAAQ,QAAQ;AACvD;AAQO,SAASC,MAAK,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,SAAY,KAAK,UAAU,QAAQ,KAAK,QAAQ,MAAM;AACxD;","names":["ptr","lex","parse","convert","info"]}
|
|
1
|
+
{"version":3,"sources":["../../../wasm-web/bitmark_wasm.js","../../../src/generated/package_info.ts","../../../src/browser/index.ts"],"sourcesContent":["let wasm;\n\nlet WASM_VECTOR_LEN = 0;\n\nlet cachedUint8ArrayMemory0 = null;\n\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nconst cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );\n\nconst encodeString = (typeof cachedTextEncoder.encodeInto === 'function'\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n}\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n});\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = encodeString(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachedDataViewMemory0 = null;\n\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nconst cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );\n\nif (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n/**\n * Lex bitmark input text, returning one line per token in the same format as\n * the Rust CLI: `{kind:?} {span:?} \"{text}\"`.\n *\n * `stage` selects the lexer pipeline:\n * - `\"lex\"` — combined (default)\n * - `\"lex-json\"` — combined, JSON array output\n * @param {string} input\n * @param {string} stage\n * @returns {string}\n */\nexport function lex(input, stage) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.lex(retptr, ptr0, len0, ptr1, len1);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * `format`: `\"bitmark++\"` (default) or `\"plainText\"`\n * `location`: `\"body\"` (default) or `\"tag\"`\n * @param {string} input\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function breakscape_text(input, format, location) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Auto-detect input format and convert between bitmark and JSON.\n *\n * `mode`: `\"optimized\"` (default) or `\"full\"`\n * `warnings`: whether to include validation warnings (default: false)\n * `plain_text`: output text as plain text — debug mode (default: false)\n * `pretty`: prettify JSON output (default: false)\n * `indent`: indent size for pretty-printing (default: 2)\n *\n * Returns JSON if input is bitmark, or an error message if input is JSON\n * (generator not yet implemented).\n * @param {string} input\n * @param {string} mode\n * @param {boolean} warnings\n * @param {boolean} plain_text\n * @param {boolean} pretty\n * @param {number} indent\n * @returns {string}\n */\nexport function convert(input, mode, warnings, plain_text, pretty, indent) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Query information about supported bit types.\n *\n * `info_type`: `\"list\"`, `\"bit\"`, `\"all\"`, or `\"deprecated\"`\n * `format`: `\"text\"` or `\"json\"`\n * `bit`: bit name (required when `info_type` is `\"bit\"`)\n * `pretty`: whether to pretty-print JSON output\n * `indent`: indent size for pretty-printing (default: 2)\n * @param {string} info_type\n * @param {string} format\n * @param {string} bit\n * @param {boolean} pretty\n * @param {number} indent\n * @returns {string}\n */\nexport function info(info_type, format, bit, pretty, indent) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Unbreakscape text (unescape bitmark special characters).\n *\n * `format`: `\"bitmark++\"` (default) or `\"plainText\"`\n * `location`: `\"body\"` (default) or `\"tag\"`\n * @param {string} input\n * @param {string} format\n * @param {string} location\n * @returns {string}\n */\nexport function unbreakscape_text(input, format, location) {\n let deferred4_0;\n let deferred4_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len2 = WASM_VECTOR_LEN;\n wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred4_0 = r0;\n deferred4_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);\n }\n}\n\n/**\n * Parse bitmark input text and return the reference JSON format.\n *\n * Uses the full pipeline: parse → validate → serialize.\n *\n * `mode`: `\"optimized\"` (default) or `\"full\"`\n * @param {string} input\n * @param {string} mode\n * @returns {string}\n */\nexport function parse(input, mode) {\n let deferred3_0;\n let deferred3_1;\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.parse(retptr, ptr0, len0, ptr1, len1);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred3_0 = r0;\n deferred3_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);\n }\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nfunction __wbg_get_imports() {\n const imports = {};\n imports.wbg = {};\n\n return imports;\n}\n\nfunction __wbg_init_memory(imports, memory) {\n\n}\n\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n __wbg_init.__wbindgen_wasm_module = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n\n\n\n return wasm;\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module !== 'undefined') {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n\n __wbg_init_memory(imports);\n\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n\n const instance = new WebAssembly.Instance(module, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (typeof module_or_path !== 'undefined') {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (typeof module_or_path === 'undefined') {\n module_or_path = new URL('bitmark_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n __wbg_init_memory(imports);\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync };\nexport default __wbg_init;\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.2\",\n \"author\": \"Get More Brain Ltd <info@getmorebrain.com>\",\n \"license\": \"ISC\",\n \"description\": \"A parser for bitmark text, powered by WebAssembly.\"\n};\n","// This is a browser entry point that wraps the wasm-web bindings.\n// It re-exports all WASM functions so browser consumers can use:\n// import { parse, convert, ... } from '@gmb/bitmark-parser/browser'\n\nimport * as wasm from \"../../wasm-web/bitmark_wasm.js\";\nimport { PACKAGE_INFO } from \"../generated/package_info.js\";\n\nexport { default as init, initSync } from \"../../wasm-web/bitmark_wasm.js\";\n\nexport type { LexOptions, LexStage, ParseOptions, ConvertOptions, OutputMode, BreakscapeOptions, TextFormat, TextLocation, InfoOptions, InfoType, InfoFormat } from \"../types.js\";\nimport type { LexOptions, ParseOptions, ConvertOptions, BreakscapeOptions, InfoOptions } from \"../types.js\";\n\n/**\n * Get the version of the @gmb/bitmark-parser library.\n *\n * @returns Version string (e.g. \"3.0.0\").\n */\nexport function version(): string {\n return PACKAGE_INFO.version;\n}\n\n/**\n * Lex bitmark input text, returning one line per token.\n *\n * @param input - The bitmark source text.\n * @param options - Lex options (e.g. `{ stage: \"lex\" }`).\n * @returns Token dump string (one token per line).\n */\nexport function lex(input: string, options: LexOptions = {}): string {\n return wasm.lex(input, options.stage ?? \"lex\");\n}\n\n/**\n * Parse bitmark input text and return structured JSON entries.\n *\n * Each entry contains `bit`, `parser`, and `bitmark` fields.\n *\n * @param input - The bitmark source text.\n * @param options - Parse options (e.g. `{ mode: \"full\" }`).\n * @returns JSON string array of structured parsed entries.\n */\nexport function parse(input: string, options: ParseOptions = {}): string {\n return wasm.parse(input, options.mode ?? \"optimized\");\n}\n\n/**\n * Auto-detect input format and convert between bitmark and JSON.\n *\n * @param input - Bitmark or JSON input text.\n * @param options - Convert options (e.g. `{ mode: \"full\", warnings: true }`).\n * @returns Converted output string. For bitmark input, this is a JSON string\n * array of structured parsed entries (`bit`, `parser`, `bitmark`).\n */\nexport function convert(input: string, options: ConvertOptions = {}): string {\n return wasm.convert(input, options.mode ?? \"optimized\", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);\n}\n\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * @param input - The text to breakscape.\n * @param options - Breakscape options (e.g. `{ format: \"plainText\", location: \"tag\" }`).\n * @returns Breakscaped text.\n */\nexport function breakscapeText(input: string, options: BreakscapeOptions = {}): string {\n const format = options.format ?? \"bitmark++\";\n const location = options.location ?? \"body\";\n return wasm.breakscape_text(input, format, location);\n}\n\n/**\n * Unbreakscape text (unescape bitmark special characters).\n *\n * @param input - The text to unbreakscape.\n * @param options - Unbreakscape options (e.g. `{ format: \"plainText\", location: \"tag\" }`).\n * @returns Unbreakscaped text.\n */\nexport function unbreakscapeText(input: string, options: BreakscapeOptions = {}): string {\n const format = options.format ?? \"bitmark++\";\n const location = options.location ?? \"body\";\n return wasm.unbreakscape_text(input, format, location);\n}\n\n/**\n * Query information about supported bit types.\n *\n * @param options - Info options (e.g. `{ infoType: \"bit\", format: \"json\", bit: \"cloze\" }`).\n * @returns Information string.\n */\nexport function info(options: InfoOptions = {}): string {\n const infoType = options.infoType ?? \"list\";\n const format = options.format ?? \"text\";\n const bit = options.bit ?? \"\";\n const pretty = options.pretty ?? false;\n const indent = options.indent ?? 2;\n return wasm.info(infoType, format, bit, pretty, indent);\n}\n"],"mappings":";AAAA,IAAI;AAEJ,IAAI,kBAAkB;AAEtB,IAAI,0BAA0B;AAE9B,SAAS,uBAAuB;AAC5B,MAAI,4BAA4B,QAAQ,wBAAwB,eAAe,GAAG;AAC9E,8BAA0B,IAAI,WAAW,KAAK,OAAO,MAAM;AAAA,EAC/D;AACA,SAAO;AACX;AAEA,IAAM,oBAAqB,OAAO,gBAAgB,cAAc,IAAI,YAAY,OAAO,IAAI,EAAE,QAAQ,MAAM;AAAE,QAAM,MAAM,2BAA2B;AAAE,EAAE;AAExJ,IAAM,eAAgB,OAAO,kBAAkB,eAAe,aACxD,SAAU,KAAK,MAAM;AACvB,SAAO,kBAAkB,WAAW,KAAK,IAAI;AACjD,IACM,SAAU,KAAK,MAAM;AACvB,QAAM,MAAM,kBAAkB,OAAO,GAAG;AACxC,OAAK,IAAI,GAAG;AACZ,SAAO;AAAA,IACH,MAAM,IAAI;AAAA,IACV,SAAS,IAAI;AAAA,EACjB;AACJ;AAEA,SAAS,kBAAkB,KAAK,QAAQ,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
|
|
9
|
+
"version": "3.0.2"};
|
|
10
10
|
var require2 = createRequire(import.meta.url);
|
|
11
11
|
var wasm = require2("../wasm/bitmark_wasm.js");
|
|
12
12
|
function lex(input, options = {}) {
|
|
@@ -77,14 +77,17 @@ function writeOutput(content, outputPath, append) {
|
|
|
77
77
|
|
|
78
78
|
// src/commands/parse.ts
|
|
79
79
|
function registerParseCommand(program2) {
|
|
80
|
-
program2.command("parse").description("Parse a bitmark file to JSON").argument("[INPUT...]", "Input: bitmark files, literal strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("--stage <STAGE>", "Stage to run: all, lex
|
|
80
|
+
program2.command("parse").description("Parse a bitmark file to JSON").argument("[INPUT...]", "Input: bitmark files, literal strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("--stage <STAGE>", "Stage to run: all, lex", "all").option("--mode <MODE>", "JSON output mode: optimized or full", "optimized").option("-p, --pretty", "Prettify JSON output", false).option("--indent <SIZE>", "Indent size for pretty JSON", "2").action((inputs, options) => {
|
|
81
81
|
const content = readInputs(inputs);
|
|
82
82
|
let result;
|
|
83
|
-
if (options.stage === "lex"
|
|
83
|
+
if (options.stage === "lex") {
|
|
84
84
|
result = lex(content, { stage: options.stage });
|
|
85
85
|
} else {
|
|
86
86
|
result = parse(content, { mode: options.mode });
|
|
87
87
|
}
|
|
88
|
+
if (options.pretty && options.stage === "all") {
|
|
89
|
+
result = JSON.stringify(JSON.parse(result), null, Number(options.indent));
|
|
90
|
+
}
|
|
88
91
|
writeOutput(result, options.output, options.append);
|
|
89
92
|
});
|
|
90
93
|
}
|
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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AUG;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"]}
|
|
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,OAIb,CAAA;ACLA,IAAMA,QAAAA,GAAU,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAC7C,IAAM,IAAA,GAAOA,SAAQ,yBAAyB,CAAA;AAoBvC,SAAS,GAAA,CAAI,KAAA,EAAe,OAAA,GAAsB,EAAC,EAAW;AACnE,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,OAAA,CAAQ,SAAS,KAAK,CAAA;AAC/C;AAWO,SAAS,KAAA,CAAM,KAAA,EAAe,OAAA,GAAwB,EAAC,EAAW;AACvE,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,KAAA,EAAO,OAAA,CAAQ,QAAQ,WAA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,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.2\",\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\" }`).\n * @returns Token dump string (one token per line).\n */\nexport function lex(input: string, options: LexOptions = {}): string {\n return wasm.lex(input, options.stage ?? \"lex\");\n}\n\n/**\n * Parse bitmark input text and return structured JSON entries.\n *\n * Each entry contains `bit`, `parser`, and `bitmark` fields.\n *\n * @param input - The bitmark source text.\n * @param options - Parse options (e.g. `{ mode: \"full\" }`).\n * @returns JSON string array of structured parsed entries.\n */\nexport function parse(input: string, options: ParseOptions = {}): string {\n return wasm.parse(input, options.mode ?? \"optimized\");\n}\n\n/**\n * Auto-detect input format and convert between bitmark and JSON.\n *\n * @param input - Bitmark or JSON input text.\n * @param options - Convert options (e.g. `{ mode: \"full\", warnings: true }`).\n * @returns Converted output string. For bitmark input, this is a JSON string\n * array of structured parsed entries (`bit`, `parser`, `bitmark`).\n */\nexport function convert(input: string, options: ConvertOptions = {}): string {\n return wasm.convert(input, options.mode ?? \"optimized\", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);\n}\n\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * @param input - The text to breakscape.\n * @param options - Breakscape options (e.g. `{ format: \"plainText\", location: \"tag\" }`).\n * @returns Breakscaped text.\n */\nexport function breakscapeText(input: string, options: BreakscapeOptions = {}): string {\n const format = options.format ?? \"bitmark++\";\n const location = options.location ?? \"body\";\n return wasm.breakscape_text(input, format, location);\n}\n\n/**\n * Unbreakscape text (unescape bitmark special characters).\n *\n * @param input - The text to unbreakscape.\n * @param options - Unbreakscape options (e.g. `{ format: \"plainText\", location: \"tag\" }`).\n * @returns Unbreakscaped text.\n */\nexport function unbreakscapeText(input: string, options: BreakscapeOptions = {}): string {\n const format = options.format ?? \"bitmark++\";\n const location = options.location ?? \"body\";\n return wasm.unbreakscape_text(input, format, location);\n}\n\n/**\n * Query information about supported bit types.\n *\n * @param options - Info options (e.g. `{ infoType: \"bit\", format: \"json\", bit: \"cloze\" }`).\n * @returns Information string.\n */\nexport function info(options: InfoOptions = {}): string {\n const infoType = options.infoType ?? \"list\";\n const format = options.format ?? \"text\";\n const bit = options.bit ?? \"\";\n const pretty = options.pretty ?? false;\n const indent = options.indent ?? 2;\n return wasm.info(infoType, format, bit, pretty, indent);\n}\n\n/**\n * Generate bitmark text from a JSON AST.\n *\n * @param _json - JSON string of the AST.\n * @throws Always throws — not yet implemented.\n */\nexport function generate(_json: string): string {\n throw new Error(\"generate is not yet implemented\");\n}\n","// @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\", \"all\")\n .option(\"--mode <MODE>\", \"JSON output mode: optimized or full\", \"optimized\")\n .option(\"-p, --pretty\", \"Prettify JSON output\", false)\n .option(\"--indent <SIZE>\", \"Indent size for pretty JSON\", \"2\")\n .action((inputs: string[], options: { output?: string; append: boolean; stage: string; mode: string; pretty: boolean; indent: string }) => {\n const content = readInputs(inputs);\n let result: string;\n\n if (options.stage === \"lex\") {\n result = lex(content, { stage: options.stage });\n } else {\n result = parse(content, { mode: options.mode as \"optimized\" | \"full\" });\n }\n\n if (options.pretty && options.stage === \"all\") {\n result = JSON.stringify(JSON.parse(result), null, Number(options.indent));\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.
|
|
44
|
+
"version": "3.0.2",
|
|
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."
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../../../node_modules/tsup/assets/cjs_shims.js","../src/generated/package_info.ts"],"sourcesContent":["// @zen-component: WASM-TSBindings\n\nimport { createRequire } from \"node:module\";\nimport { PACKAGE_INFO } from \"./generated/package_info.js\";\nimport type { LexOptions, ParseOptions, ConvertOptions, BreakscapeOptions, InfoOptions } from \"./types.js\";\nconst require = createRequire(import.meta.url);\nconst wasm = require(\"../wasm/bitmark_wasm.js\") as typeof import(\"../wasm/bitmark_wasm.js\");\n\nexport type { LexOptions, LexStage, ParseOptions, ConvertOptions, OutputMode, BreakscapeOptions, TextFormat, TextLocation, InfoOptions, InfoType, InfoFormat } from \"./types.js\";\n\n/**\n * Get the version of the @gmb/bitmark-parser library.\n *\n * @returns Version string (e.g. \"3.0.0\").\n */\nexport function version(): string {\n return PACKAGE_INFO.version;\n}\n\n/**\n * Lex bitmark input text, returning one line per token.\n *\n * @param input - The bitmark source text.\n * @param options - Lex options (e.g. `{ stage: \"lex
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../../../node_modules/tsup/assets/cjs_shims.js","../src/generated/package_info.ts"],"sourcesContent":["// @zen-component: WASM-TSBindings\n\nimport { createRequire } from \"node:module\";\nimport { PACKAGE_INFO } from \"./generated/package_info.js\";\nimport type { LexOptions, ParseOptions, ConvertOptions, BreakscapeOptions, InfoOptions } from \"./types.js\";\nconst require = createRequire(import.meta.url);\nconst wasm = require(\"../wasm/bitmark_wasm.js\") as typeof import(\"../wasm/bitmark_wasm.js\");\n\nexport type { LexOptions, LexStage, ParseOptions, ConvertOptions, OutputMode, BreakscapeOptions, TextFormat, TextLocation, InfoOptions, InfoType, InfoFormat } from \"./types.js\";\n\n/**\n * Get the version of the @gmb/bitmark-parser library.\n *\n * @returns Version string (e.g. \"3.0.0\").\n */\nexport function version(): string {\n return PACKAGE_INFO.version;\n}\n\n/**\n * Lex bitmark input text, returning one line per token.\n *\n * @param input - The bitmark source text.\n * @param options - Lex options (e.g. `{ stage: \"lex\" }`).\n * @returns Token dump string (one token per line).\n */\nexport function lex(input: string, options: LexOptions = {}): string {\n return wasm.lex(input, options.stage ?? \"lex\");\n}\n\n/**\n * Parse bitmark input text and return structured JSON entries.\n *\n * Each entry contains `bit`, `parser`, and `bitmark` fields.\n *\n * @param input - The bitmark source text.\n * @param options - Parse options (e.g. `{ mode: \"full\" }`).\n * @returns JSON string array of structured parsed entries.\n */\nexport function parse(input: string, options: ParseOptions = {}): string {\n return wasm.parse(input, options.mode ?? \"optimized\");\n}\n\n/**\n * Auto-detect input format and convert between bitmark and JSON.\n *\n * @param input - Bitmark or JSON input text.\n * @param options - Convert options (e.g. `{ mode: \"full\", warnings: true }`).\n * @returns Converted output string. For bitmark input, this is a JSON string\n * array of structured parsed entries (`bit`, `parser`, `bitmark`).\n */\nexport function convert(input: string, options: ConvertOptions = {}): string {\n return wasm.convert(input, options.mode ?? \"optimized\", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);\n}\n\n/**\n * Breakscape text (escape bitmark special characters).\n *\n * @param input - The text to breakscape.\n * @param options - Breakscape options (e.g. `{ format: \"plainText\", location: \"tag\" }`).\n * @returns Breakscaped text.\n */\nexport function breakscapeText(input: string, options: BreakscapeOptions = {}): string {\n const format = options.format ?? \"bitmark++\";\n const location = options.location ?? \"body\";\n return wasm.breakscape_text(input, format, location);\n}\n\n/**\n * Unbreakscape text (unescape bitmark special characters).\n *\n * @param input - The text to unbreakscape.\n * @param options - Unbreakscape options (e.g. `{ format: \"plainText\", location: \"tag\" }`).\n * @returns Unbreakscaped text.\n */\nexport function unbreakscapeText(input: string, options: BreakscapeOptions = {}): string {\n const format = options.format ?? \"bitmark++\";\n const location = options.location ?? \"body\";\n return wasm.unbreakscape_text(input, format, location);\n}\n\n/**\n * Query information about supported bit types.\n *\n * @param options - Info options (e.g. `{ infoType: \"bit\", format: \"json\", bit: \"cloze\" }`).\n * @returns Information string.\n */\nexport function info(options: InfoOptions = {}): string {\n const infoType = options.infoType ?? \"list\";\n const format = options.format ?? \"text\";\n const bit = options.bit ?? \"\";\n const pretty = options.pretty ?? false;\n const indent = options.indent ?? 2;\n return wasm.info(infoType, format, bit, pretty, indent);\n}\n\n/**\n * Generate bitmark text from a JSON AST.\n *\n * @param _json - JSON string of the AST.\n * @throws Always throws — not yet implemented.\n */\nexport function generate(_json: string): string {\n throw new Error(\"generate is not yet implemented\");\n}\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","// This file is automatically generated. DO NOT EDIT.\n\n/* eslint-disable */\n\nexport const PACKAGE_INFO = {\n \"name\": \"@gmb/bitmark-parser\",\n \"version\": \"3.0.2\",\n \"author\": \"Get More Brain Ltd <info@getmorebrain.com>\",\n \"license\": \"ISC\",\n \"description\": \"A parser for bitmark text, powered by WebAssembly.\"\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ADV9D,yBAA8B;;;AEEvB,IAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,eAAe;AACjB;;;AFLA,IAAMA,eAAU,kCAAc,aAAe;AAC7C,IAAM,OAAOA,SAAQ,yBAAyB;AASvC,SAAS,UAAkB;AAChC,SAAO,aAAa;AACtB;AASO,SAAS,IAAI,OAAe,UAAsB,CAAC,GAAW;AACnE,SAAO,KAAK,IAAI,OAAO,QAAQ,SAAS,KAAK;AAC/C;AAWO,SAAS,MAAM,OAAe,UAAwB,CAAC,GAAW;AACvE,SAAO,KAAK,MAAM,OAAO,QAAQ,QAAQ,WAAW;AACtD;AAUO,SAAS,QAAQ,OAAe,UAA0B,CAAC,GAAW;AAC3E,SAAO,KAAK,QAAQ,OAAO,QAAQ,QAAQ,aAA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