@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
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
declare 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
|
+
declare 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
|
+
declare 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
|
+
declare 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
|
+
declare 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
|
+
declare function lex(input: string, stage: string): string;
|
|
60
|
+
|
|
61
|
+
type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
62
|
+
|
|
63
|
+
interface InitOutput {
|
|
64
|
+
readonly memory: WebAssembly.Memory;
|
|
65
|
+
readonly breakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
66
|
+
readonly convert: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
67
|
+
readonly info: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
68
|
+
readonly lex: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
69
|
+
readonly parse: (a: number, b: number, c: number) => void;
|
|
70
|
+
readonly unbreakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
71
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
72
|
+
readonly __wbindgen_export_0: (a: number, b: number) => number;
|
|
73
|
+
readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
|
|
74
|
+
readonly __wbindgen_export_2: (a: number, b: number, c: number) => void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
78
|
+
/**
|
|
79
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
80
|
+
* a precompiled `WebAssembly.Module`.
|
|
81
|
+
*
|
|
82
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
83
|
+
*
|
|
84
|
+
* @returns {InitOutput}
|
|
85
|
+
*/
|
|
86
|
+
declare function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
90
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
91
|
+
*
|
|
92
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
93
|
+
*
|
|
94
|
+
* @returns {Promise<InitOutput>}
|
|
95
|
+
*/
|
|
96
|
+
declare function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
97
|
+
|
|
98
|
+
export { breakscape_text as breakscapeText, convert, info, __wbg_init as init, initSync, lex, parse, unbreakscape_text as unbreakscapeText };
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
// wasm-web/bitmark_wasm.js
|
|
2
|
+
var wasm;
|
|
3
|
+
var WASM_VECTOR_LEN = 0;
|
|
4
|
+
var cachedUint8ArrayMemory0 = null;
|
|
5
|
+
function getUint8ArrayMemory0() {
|
|
6
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
7
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
8
|
+
}
|
|
9
|
+
return cachedUint8ArrayMemory0;
|
|
10
|
+
}
|
|
11
|
+
var cachedTextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
|
|
12
|
+
throw Error("TextEncoder not available");
|
|
13
|
+
} };
|
|
14
|
+
var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
|
|
15
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
16
|
+
} : function(arg, view) {
|
|
17
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
18
|
+
view.set(buf);
|
|
19
|
+
return {
|
|
20
|
+
read: arg.length,
|
|
21
|
+
written: buf.length
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
25
|
+
if (realloc === void 0) {
|
|
26
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
27
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
28
|
+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
29
|
+
WASM_VECTOR_LEN = buf.length;
|
|
30
|
+
return ptr2;
|
|
31
|
+
}
|
|
32
|
+
let len = arg.length;
|
|
33
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
34
|
+
const mem = getUint8ArrayMemory0();
|
|
35
|
+
let offset = 0;
|
|
36
|
+
for (; offset < len; offset++) {
|
|
37
|
+
const code = arg.charCodeAt(offset);
|
|
38
|
+
if (code > 127) break;
|
|
39
|
+
mem[ptr + offset] = code;
|
|
40
|
+
}
|
|
41
|
+
if (offset !== len) {
|
|
42
|
+
if (offset !== 0) {
|
|
43
|
+
arg = arg.slice(offset);
|
|
44
|
+
}
|
|
45
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
46
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
47
|
+
const ret = encodeString(arg, view);
|
|
48
|
+
offset += ret.written;
|
|
49
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
50
|
+
}
|
|
51
|
+
WASM_VECTOR_LEN = offset;
|
|
52
|
+
return ptr;
|
|
53
|
+
}
|
|
54
|
+
var cachedDataViewMemory0 = null;
|
|
55
|
+
function getDataViewMemory0() {
|
|
56
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
57
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
58
|
+
}
|
|
59
|
+
return cachedDataViewMemory0;
|
|
60
|
+
}
|
|
61
|
+
var cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
|
|
62
|
+
throw Error("TextDecoder not available");
|
|
63
|
+
} };
|
|
64
|
+
if (typeof TextDecoder !== "undefined") {
|
|
65
|
+
cachedTextDecoder.decode();
|
|
66
|
+
}
|
|
67
|
+
function getStringFromWasm0(ptr, len) {
|
|
68
|
+
ptr = ptr >>> 0;
|
|
69
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
70
|
+
}
|
|
71
|
+
function convert(input, options_json) {
|
|
72
|
+
let deferred3_0;
|
|
73
|
+
let deferred3_1;
|
|
74
|
+
try {
|
|
75
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
76
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
77
|
+
const len0 = WASM_VECTOR_LEN;
|
|
78
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
79
|
+
const len1 = WASM_VECTOR_LEN;
|
|
80
|
+
wasm.convert(retptr, ptr0, len0, ptr1, len1);
|
|
81
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
82
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
83
|
+
deferred3_0 = r0;
|
|
84
|
+
deferred3_1 = r1;
|
|
85
|
+
return getStringFromWasm0(r0, r1);
|
|
86
|
+
} finally {
|
|
87
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
88
|
+
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function breakscape_text(input, format, location) {
|
|
92
|
+
let deferred4_0;
|
|
93
|
+
let deferred4_1;
|
|
94
|
+
try {
|
|
95
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
96
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
97
|
+
const len0 = WASM_VECTOR_LEN;
|
|
98
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
99
|
+
const len1 = WASM_VECTOR_LEN;
|
|
100
|
+
const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
101
|
+
const len2 = WASM_VECTOR_LEN;
|
|
102
|
+
wasm.breakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
103
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
104
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
105
|
+
deferred4_0 = r0;
|
|
106
|
+
deferred4_1 = r1;
|
|
107
|
+
return getStringFromWasm0(r0, r1);
|
|
108
|
+
} finally {
|
|
109
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
110
|
+
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function info(info_type, format, bit, pretty, indent) {
|
|
114
|
+
let deferred4_0;
|
|
115
|
+
let deferred4_1;
|
|
116
|
+
try {
|
|
117
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
118
|
+
const ptr0 = passStringToWasm0(info_type, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
119
|
+
const len0 = WASM_VECTOR_LEN;
|
|
120
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
121
|
+
const len1 = WASM_VECTOR_LEN;
|
|
122
|
+
const ptr2 = passStringToWasm0(bit, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
123
|
+
const len2 = WASM_VECTOR_LEN;
|
|
124
|
+
wasm.info(retptr, ptr0, len0, ptr1, len1, ptr2, len2, pretty, indent);
|
|
125
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
126
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
127
|
+
deferred4_0 = r0;
|
|
128
|
+
deferred4_1 = r1;
|
|
129
|
+
return getStringFromWasm0(r0, r1);
|
|
130
|
+
} finally {
|
|
131
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
132
|
+
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function unbreakscape_text(input, format, location) {
|
|
136
|
+
let deferred4_0;
|
|
137
|
+
let deferred4_1;
|
|
138
|
+
try {
|
|
139
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
140
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
141
|
+
const len0 = WASM_VECTOR_LEN;
|
|
142
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
143
|
+
const len1 = WASM_VECTOR_LEN;
|
|
144
|
+
const ptr2 = passStringToWasm0(location, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
145
|
+
const len2 = WASM_VECTOR_LEN;
|
|
146
|
+
wasm.unbreakscape_text(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
147
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
148
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
149
|
+
deferred4_0 = r0;
|
|
150
|
+
deferred4_1 = r1;
|
|
151
|
+
return getStringFromWasm0(r0, r1);
|
|
152
|
+
} finally {
|
|
153
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
154
|
+
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function parse(input) {
|
|
158
|
+
let deferred2_0;
|
|
159
|
+
let deferred2_1;
|
|
160
|
+
try {
|
|
161
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
162
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
163
|
+
const len0 = WASM_VECTOR_LEN;
|
|
164
|
+
wasm.parse(retptr, ptr0, len0);
|
|
165
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
166
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
167
|
+
deferred2_0 = r0;
|
|
168
|
+
deferred2_1 = r1;
|
|
169
|
+
return getStringFromWasm0(r0, r1);
|
|
170
|
+
} finally {
|
|
171
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
172
|
+
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function lex(input, stage) {
|
|
176
|
+
let deferred3_0;
|
|
177
|
+
let deferred3_1;
|
|
178
|
+
try {
|
|
179
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
180
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
181
|
+
const len0 = WASM_VECTOR_LEN;
|
|
182
|
+
const ptr1 = passStringToWasm0(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
183
|
+
const len1 = WASM_VECTOR_LEN;
|
|
184
|
+
wasm.lex(retptr, ptr0, len0, ptr1, len1);
|
|
185
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
186
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
187
|
+
deferred3_0 = r0;
|
|
188
|
+
deferred3_1 = r1;
|
|
189
|
+
return getStringFromWasm0(r0, r1);
|
|
190
|
+
} finally {
|
|
191
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
192
|
+
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function __wbg_load(module, imports) {
|
|
196
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
197
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
198
|
+
try {
|
|
199
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
200
|
+
} catch (e) {
|
|
201
|
+
if (module.headers.get("Content-Type") != "application/wasm") {
|
|
202
|
+
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);
|
|
203
|
+
} else {
|
|
204
|
+
throw e;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const bytes = await module.arrayBuffer();
|
|
209
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
210
|
+
} else {
|
|
211
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
212
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
213
|
+
return { instance, module };
|
|
214
|
+
} else {
|
|
215
|
+
return instance;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function __wbg_get_imports() {
|
|
220
|
+
const imports = {};
|
|
221
|
+
imports.wbg = {};
|
|
222
|
+
return imports;
|
|
223
|
+
}
|
|
224
|
+
function __wbg_init_memory(imports, memory) {
|
|
225
|
+
}
|
|
226
|
+
function __wbg_finalize_init(instance, module) {
|
|
227
|
+
wasm = instance.exports;
|
|
228
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
229
|
+
cachedDataViewMemory0 = null;
|
|
230
|
+
cachedUint8ArrayMemory0 = null;
|
|
231
|
+
return wasm;
|
|
232
|
+
}
|
|
233
|
+
function initSync(module) {
|
|
234
|
+
if (wasm !== void 0) return wasm;
|
|
235
|
+
if (typeof module !== "undefined") {
|
|
236
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
237
|
+
({ module } = module);
|
|
238
|
+
} else {
|
|
239
|
+
console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const imports = __wbg_get_imports();
|
|
243
|
+
__wbg_init_memory(imports);
|
|
244
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
245
|
+
module = new WebAssembly.Module(module);
|
|
246
|
+
}
|
|
247
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
248
|
+
return __wbg_finalize_init(instance, module);
|
|
249
|
+
}
|
|
250
|
+
async function __wbg_init(module_or_path) {
|
|
251
|
+
if (wasm !== void 0) return wasm;
|
|
252
|
+
if (typeof module_or_path !== "undefined") {
|
|
253
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
254
|
+
({ module_or_path } = module_or_path);
|
|
255
|
+
} else {
|
|
256
|
+
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (typeof module_or_path === "undefined") {
|
|
260
|
+
module_or_path = new URL("bitmark_wasm_bg.wasm", import.meta.url);
|
|
261
|
+
}
|
|
262
|
+
const imports = __wbg_get_imports();
|
|
263
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
264
|
+
module_or_path = fetch(module_or_path);
|
|
265
|
+
}
|
|
266
|
+
__wbg_init_memory(imports);
|
|
267
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
268
|
+
return __wbg_finalize_init(instance, module);
|
|
269
|
+
}
|
|
270
|
+
var bitmark_wasm_default = __wbg_init;
|
|
271
|
+
export {
|
|
272
|
+
breakscape_text as breakscapeText,
|
|
273
|
+
convert,
|
|
274
|
+
info,
|
|
275
|
+
bitmark_wasm_default as init,
|
|
276
|
+
initSync,
|
|
277
|
+
lex,
|
|
278
|
+
parse,
|
|
279
|
+
unbreakscape_text as unbreakscapeText
|
|
280
|
+
};
|
|
281
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../wasm-web/bitmark_wasm.js"],"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 * Auto-detect input format and convert between bitmark and JSON.\n *\n * `options_json` is a JSON string with optional fields:\n * - `\"mode\"`: `\"optimized\"` (default) or `\"full\"`\n * - `\"warnings\"`: `true` or `false` (default)\n * - `\"plainText\"`: `true` or `false` (default)\n * - `\"pretty\"`: `true` or `false` (default)\n * - `\"indent\"`: number (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} options_json\n * @returns {string}\n */\nexport function convert(input, options_json) {\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(options_json, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);\n const len1 = WASM_VECTOR_LEN;\n wasm.convert(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 * 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 with optimized mode.\n * @param {string} input\n * @returns {string}\n */\nexport function parse(input) {\n let deferred2_0;\n let deferred2_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 wasm.parse(retptr, ptr0, len0);\n var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);\n var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);\n deferred2_0 = r0;\n deferred2_1 = r1;\n return getStringFromWasm0(r0, r1);\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n wasm.__wbindgen_export_2(deferred2_0, deferred2_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"],"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,SAAS;AAE7C,MAAI,YAAY,QAAW;AACvB,UAAM,MAAM,kBAAkB,OAAO,GAAG;AACxC,UAAMA,OAAM,OAAO,IAAI,QAAQ,CAAC,MAAM;AACtC,yBAAqB,EAAE,SAASA,MAAKA,OAAM,IAAI,MAAM,EAAE,IAAI,GAAG;AAC9D,sBAAkB,IAAI;AACtB,WAAOA;AAAA,EACX;AAEA,MAAI,MAA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AE,kBAAkB,YAAY,SAAS;AACzC,aAAS,IAAI,YAAY,OAAO,MAAM;AAAA,EAC1C;AAEA,QAAM,WAAW,IAAI,YAAY,SAAS,QAAQ,OAAO;AAEzD,SAAO,oBAAoB,UAAU,MAAM;AAC/C;AAEA,eAAe,WAAW,gBAAgB;AACtC,MAAI,SAAS,OAAW,QAAO;AAG/B,MAAI,OAAO,mBAAmB,aAAa;AACvC,QAAI,OAAO,eAAe,cAAc,MAAM,OAAO,WAAW;AAC5D,OAAC,EAAC,eAAc,IAAI;AAAA,IACxB,OAAO;AACH,cAAQ,KAAK,2FAA2F;AAAA,IAC5G;AAAA,EACJ;AAEA,MAAI,OAAO,mBAAmB,aAAa;AACvC,qBAAiB,IAAI,IAAI,wBAAwB,YAAY,GAAG;AAAA,EACpE;AACA,QAAM,UAAU,kBAAkB;AAElC,MAAI,OAAO,mBAAmB,YAAa,OAAO,YAAY,cAAc,0BAA0B,WAAa,OAAO,QAAQ,cAAc,0BAA0B,KAAM;AAC5K,qBAAiB,MAAM,cAAc;AAAA,EACzC;AAEA,oBAAkB,OAAO;AAEzB,QAAM,EAAE,UAAU,OAAO,IAAI,MAAM,WAAW,MAAM,gBAAgB,OAAO;AAE3E,SAAO,oBAAoB,UAAU,MAAM;AAC/C;AAGA,IAAO,uBAAQ;","names":["ptr"]}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
import { existsSync, mkdirSync, appendFileSync, writeFileSync, readFileSync } from 'fs';
|
|
5
|
+
import { dirname } from 'path';
|
|
6
|
+
|
|
7
|
+
// src/generated/package_info.ts
|
|
8
|
+
var PACKAGE_INFO = {
|
|
9
|
+
"version": "3.0.0-alpha.1"};
|
|
10
|
+
var require2 = createRequire(import.meta.url);
|
|
11
|
+
var wasm = require2("../wasm/bitmark_wasm.js");
|
|
12
|
+
function lex(input, stage = "lex") {
|
|
13
|
+
return wasm.lex(input, stage);
|
|
14
|
+
}
|
|
15
|
+
function convert(input, optionsJson = "{}") {
|
|
16
|
+
return wasm.convert(input, optionsJson);
|
|
17
|
+
}
|
|
18
|
+
function breakscapeText(input, format = "bitmark++", location = "body") {
|
|
19
|
+
return wasm.breakscape_text(input, format, location);
|
|
20
|
+
}
|
|
21
|
+
function unbreakscapeText(input, format = "bitmark++", location = "body") {
|
|
22
|
+
return wasm.unbreakscape_text(input, format, location);
|
|
23
|
+
}
|
|
24
|
+
function info(infoType = "list", format = "text", bit = "", pretty = false, indent = 2) {
|
|
25
|
+
return wasm.info(infoType, format, bit, pretty, indent);
|
|
26
|
+
}
|
|
27
|
+
function readInputs(inputs) {
|
|
28
|
+
if (inputs.length === 0) {
|
|
29
|
+
return readStdin();
|
|
30
|
+
}
|
|
31
|
+
if (inputs.length === 1) {
|
|
32
|
+
return readSingle(inputs[0]);
|
|
33
|
+
}
|
|
34
|
+
return inputs.map(readSingle).join("\n");
|
|
35
|
+
}
|
|
36
|
+
function readSingle(input) {
|
|
37
|
+
if (existsSync(input)) {
|
|
38
|
+
return readFileSync(input, "utf-8");
|
|
39
|
+
}
|
|
40
|
+
return input;
|
|
41
|
+
}
|
|
42
|
+
function readStdin() {
|
|
43
|
+
const buf = readFileSync(0, "utf-8");
|
|
44
|
+
if (!buf) {
|
|
45
|
+
console.error("No input provided. Pass a file path, literal string, or pipe via stdin.");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
return buf;
|
|
49
|
+
}
|
|
50
|
+
function writeOutput(content, outputPath, append) {
|
|
51
|
+
if (outputPath === void 0) {
|
|
52
|
+
process.stdout.write(content);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const dir = dirname(outputPath);
|
|
56
|
+
if (dir && !existsSync(dir)) {
|
|
57
|
+
mkdirSync(dir, { recursive: true });
|
|
58
|
+
}
|
|
59
|
+
if (append) {
|
|
60
|
+
appendFileSync(outputPath, content, "utf-8");
|
|
61
|
+
} else {
|
|
62
|
+
writeFileSync(outputPath, content, "utf-8");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/commands/parse.ts
|
|
67
|
+
function registerParseCommand(program2) {
|
|
68
|
+
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, lex-bitmark, lex-text", "all").option("--mode <MODE>", "JSON output mode: optimized or full", "optimized").action((inputs, options) => {
|
|
69
|
+
const content = readInputs(inputs);
|
|
70
|
+
let result;
|
|
71
|
+
if (options.stage === "lex" || options.stage === "lex-bitmark" || options.stage === "lex-text") {
|
|
72
|
+
result = lex(content, options.stage);
|
|
73
|
+
} else {
|
|
74
|
+
const optionsJson = JSON.stringify({ mode: options.mode });
|
|
75
|
+
result = convert(content, optionsJson);
|
|
76
|
+
}
|
|
77
|
+
writeOutput(result, options.output, options.append);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/commands/generate.ts
|
|
82
|
+
function registerGenerateCommand(program2) {
|
|
83
|
+
program2.command("generate").description("Generate bitmark text from JSON").argument("<INPUT>", "Input JSON file").argument("<OUTPUT>", "Output bitmark file").action((_input, _output) => {
|
|
84
|
+
console.error("generate not yet implemented");
|
|
85
|
+
process.exit(1);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/commands/convert.ts
|
|
90
|
+
function registerConvertCommand(program2) {
|
|
91
|
+
program2.command("convert").description("Auto-detect input format and convert between bitmark and JSON").argument("[INPUT...]", "Input: file paths, bitmark/JSON strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("-w, --warnings", "Enable validation warnings in output", false).option("-p, --pretty", "Prettify JSON output", false).option("--indent <n>", "Indent size for pretty JSON", "2").option("--mode <MODE>", "JSON output mode: optimized or full", "optimized").option("--plain-text", "Output text as plain text (debug)", false).action(
|
|
92
|
+
(inputs, options) => {
|
|
93
|
+
const content = readInputs(inputs);
|
|
94
|
+
const optionsJson = JSON.stringify({
|
|
95
|
+
mode: options.mode,
|
|
96
|
+
warnings: options.warnings,
|
|
97
|
+
plainText: options.plainText,
|
|
98
|
+
pretty: options.pretty,
|
|
99
|
+
indent: parseInt(options.indent, 10)
|
|
100
|
+
});
|
|
101
|
+
const result = convert(content, optionsJson);
|
|
102
|
+
writeOutput(result, options.output, options.append);
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/commands/breakscape.ts
|
|
108
|
+
function registerBreakscapeCommand(program2) {
|
|
109
|
+
program2.command("breakscape").description("Breakscape text (escape bitmark special characters)").argument("[INPUT...]", "Input: file paths, text strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("--format <FORMAT>", "Text format: bitmark++ or plainText", "bitmark++").option("--location <LOCATION>", "Text location: body or tag", "body").action((inputs, options) => {
|
|
110
|
+
const content = readInputs(inputs);
|
|
111
|
+
const result = breakscapeText(content, options.format, options.location);
|
|
112
|
+
writeOutput(result, options.output, options.append);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/commands/unbreakscape.ts
|
|
117
|
+
function registerUnbreakscapeCommand(program2) {
|
|
118
|
+
program2.command("unbreakscape").description("Unbreakscape text (unescape bitmark special characters)").argument("[INPUT...]", "Input: file paths, text strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("--format <FORMAT>", "Text format: bitmark++ or plainText", "bitmark++").option("--location <LOCATION>", "Text location: body or tag", "body").action((inputs, options) => {
|
|
119
|
+
const content = readInputs(inputs);
|
|
120
|
+
const result = unbreakscapeText(content, options.format, options.location);
|
|
121
|
+
writeOutput(result, options.output, options.append);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/commands/info.ts
|
|
126
|
+
function registerInfoCommand(program2) {
|
|
127
|
+
program2.command("info").description("Show information about supported bit types").argument("[INFO]", "Info type: list, bit, all, deprecated", "list").option("-f, --format <FORMAT>", "Output format: text or json", "text").option("--all", "Include deprecated bits", false).option("--bit <NAME>", "Filter to specific bit type").option("--deprecated", "Show only deprecated bits", false).option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("-p, --pretty", "Prettify JSON output", false).option("--indent <n>", "Indent size for pretty JSON", "2").action(
|
|
128
|
+
(infoType, options) => {
|
|
129
|
+
const result = info(infoType, options.format, options.bit ?? "", options.pretty, parseInt(options.indent, 10));
|
|
130
|
+
writeOutput(result, options.output, options.append);
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/cli.ts
|
|
136
|
+
var program = new Command();
|
|
137
|
+
program.name("bitmark-parser").description("Parse and generate bitmark text").version(PACKAGE_INFO.version);
|
|
138
|
+
registerParseCommand(program);
|
|
139
|
+
registerGenerateCommand(program);
|
|
140
|
+
registerConvertCommand(program);
|
|
141
|
+
registerBreakscapeCommand(program);
|
|
142
|
+
registerUnbreakscapeCommand(program);
|
|
143
|
+
registerInfoCommand(program);
|
|
144
|
+
program.parse();
|
|
145
|
+
//! Shared I/O utilities for the TS CLI.
|
|
146
|
+
//# sourceMappingURL=cli.js.map
|
|
147
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generated/package_info.ts","../src/index.ts","../src/utils/io.ts","../src/commands/parse.ts","../src/commands/generate.ts","../src/commands/convert.ts","../src/commands/breakscape.ts","../src/commands/unbreakscape.ts","../src/commands/info.ts","../src/cli.ts"],"names":["require","program"],"mappings":";;;;;;;AAIO,IAAM,YAAA,GAAe;AAAA,EAE1B,SAAA,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.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.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","// @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","// @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, convert } 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, options.stage);\n } else {\n const optionsJson = JSON.stringify({ mode: options.mode });\n result = convert(content, optionsJson);\n }\n\n writeOutput(result, options.output, options.append);\n });\n}\n","// @zen-component: WASM-TSBindings\n\nimport type { Command } from \"commander\";\n\nexport function registerGenerateCommand(program: Command): void {\n program\n .command(\"generate\")\n .description(\"Generate bitmark text from JSON\")\n .argument(\"<INPUT>\", \"Input JSON file\")\n .argument(\"<OUTPUT>\", \"Output bitmark file\")\n .action((_input: string, _output: string) => {\n console.error(\"generate not yet implemented\");\n process.exit(1);\n });\n}\n","// @zen-component: CLI-Convert\n\nimport type { Command } from \"commander\";\nimport { convert } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerConvertCommand(program: Command): void {\n program\n .command(\"convert\")\n .description(\"Auto-detect input format and convert between bitmark and JSON\")\n .argument(\"[INPUT...]\", \"Input: file paths, bitmark/JSON strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"-w, --warnings\", \"Enable validation warnings in output\", false)\n .option(\"-p, --pretty\", \"Prettify JSON output\", false)\n .option(\"--indent <n>\", \"Indent size for pretty JSON\", \"2\")\n .option(\"--mode <MODE>\", \"JSON output mode: optimized or full\", \"optimized\")\n .option(\"--plain-text\", \"Output text as plain text (debug)\", false)\n .action(\n (\n inputs: string[],\n options: {\n output?: string;\n append: boolean;\n warnings: boolean;\n pretty: boolean;\n indent: string;\n mode: string;\n plainText: boolean;\n },\n ) => {\n const content = readInputs(inputs);\n const optionsJson = JSON.stringify({\n mode: options.mode,\n warnings: options.warnings,\n plainText: options.plainText,\n pretty: options.pretty,\n indent: parseInt(options.indent, 10),\n });\n const result = convert(content, optionsJson);\n writeOutput(result, options.output, options.append);\n },\n );\n}\n","// @zen-component: CLI-Breakscape\n\nimport type { Command } from \"commander\";\nimport { breakscapeText } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerBreakscapeCommand(program: Command): void {\n program\n .command(\"breakscape\")\n .description(\"Breakscape text (escape bitmark special characters)\")\n .argument(\"[INPUT...]\", \"Input: file paths, text strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"--format <FORMAT>\", \"Text format: bitmark++ or plainText\", \"bitmark++\")\n .option(\"--location <LOCATION>\", \"Text location: body or tag\", \"body\")\n .action((inputs: string[], options: { output?: string; append: boolean; format: string; location: string }) => {\n const content = readInputs(inputs);\n const result = breakscapeText(content, options.format, options.location);\n writeOutput(result, options.output, options.append);\n });\n}\n","// @zen-component: CLI-Breakscape\n\nimport type { Command } from \"commander\";\nimport { unbreakscapeText } from \"../index.js\";\nimport { readInputs, writeOutput } from \"../utils/io.js\";\n\nexport function registerUnbreakscapeCommand(program: Command): void {\n program\n .command(\"unbreakscape\")\n .description(\"Unbreakscape text (unescape bitmark special characters)\")\n .argument(\"[INPUT...]\", \"Input: file paths, text strings, or omit for stdin\")\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"--format <FORMAT>\", \"Text format: bitmark++ or plainText\", \"bitmark++\")\n .option(\"--location <LOCATION>\", \"Text location: body or tag\", \"body\")\n .action((inputs: string[], options: { output?: string; append: boolean; format: string; location: string }) => {\n const content = readInputs(inputs);\n const result = unbreakscapeText(content, options.format, options.location);\n writeOutput(result, options.output, options.append);\n });\n}\n","// @zen-component: CLI-Info\n\nimport type { Command } from \"commander\";\nimport { info } from \"../index.js\";\nimport { writeOutput } from \"../utils/io.js\";\n\nexport function registerInfoCommand(program: Command): void {\n program\n .command(\"info\")\n .description(\"Show information about supported bit types\")\n .argument(\"[INFO]\", \"Info type: list, bit, all, deprecated\", \"list\")\n .option(\"-f, --format <FORMAT>\", \"Output format: text or json\", \"text\")\n .option(\"--all\", \"Include deprecated bits\", false)\n .option(\"--bit <NAME>\", \"Filter to specific bit type\")\n .option(\"--deprecated\", \"Show only deprecated bits\", false)\n .option(\"-o, --output <file>\", \"Output file (default: stdout)\")\n .option(\"-a, --append\", \"Append to output file\", false)\n .option(\"-p, --pretty\", \"Prettify JSON output\", false)\n .option(\"--indent <n>\", \"Indent size for pretty JSON\", \"2\")\n .action(\n (\n infoType: string,\n options: {\n format: string;\n all: boolean;\n bit?: string;\n deprecated: boolean;\n output?: string;\n append: boolean;\n pretty: boolean;\n indent: string;\n },\n ) => {\n const result = info(infoType, options.format, options.bit ?? \"\", options.pretty, parseInt(options.indent, 10));\n writeOutput(result, options.output, options.append);\n },\n );\n}\n","#!/usr/bin/env node\n// @zen-component: WASM-TSBindings\n\nimport { Command } from \"commander\";\nimport { PACKAGE_INFO } from \"./generated/package_info.js\";\nimport { registerParseCommand } from \"./commands/parse.js\";\nimport { registerGenerateCommand } from \"./commands/generate.js\";\nimport { registerConvertCommand } from \"./commands/convert.js\";\nimport { registerBreakscapeCommand } from \"./commands/breakscape.js\";\nimport { registerUnbreakscapeCommand } from \"./commands/unbreakscape.js\";\nimport { registerInfoCommand } from \"./commands/info.js\";\n\nconst program = new Command();\n\nprogram.name(\"bitmark-parser\").description(\"Parse and generate bitmark text\").version(PACKAGE_INFO.version);\n\nregisterParseCommand(program);\nregisterGenerateCommand(program);\nregisterConvertCommand(program);\nregisterBreakscapeCommand(program);\nregisterUnbreakscapeCommand(program);\nregisterInfoCommand(program);\n\nprogram.parse();\n"]}
|