@gmb/bitmark-parser 3.0.1-alpha.3 → 3.0.1-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +42 -13
- package/dist/browser/cjs/index.cjs.map +1 -1
- package/dist/browser/cjs/index.d.cts +120 -66
- package/dist/browser/esm/bitmark_wasm_bg.wasm +0 -0
- package/dist/browser/esm/index.d.ts +120 -66
- package/dist/browser/esm/index.js +42 -13
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/cli.js +37 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +19 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +83 -19
- package/dist/index.d.ts +83 -19
- package/dist/index.js +19 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/wasm/bitmark_wasm.d.ts +10 -13
- package/wasm/bitmark_wasm.js +21 -20
- package/wasm/bitmark_wasm_bg.wasm +0 -0
- package/wasm/bitmark_wasm_bg.wasm.d.ts +1 -1
|
@@ -1,73 +1,9 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
* Breakscape text (escape bitmark special characters).
|
|
5
|
-
*
|
|
6
|
-
* `format`: `"bitmark++"` (default) or `"plainText"`
|
|
7
|
-
* `location`: `"body"` (default) or `"tag"`
|
|
8
|
-
*/
|
|
9
|
-
declare function breakscape_text(input: string, format: string, location: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Unbreakscape text (unescape bitmark special characters).
|
|
12
|
-
*
|
|
13
|
-
* `format`: `"bitmark++"` (default) or `"plainText"`
|
|
14
|
-
* `location`: `"body"` (default) or `"tag"`
|
|
15
|
-
*/
|
|
16
|
-
declare function unbreakscape_text(input: string, format: string, location: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Parse bitmark input text and return the reference JSON format.
|
|
19
|
-
*
|
|
20
|
-
* Uses the full pipeline: parse → validate → serialize.
|
|
21
|
-
*
|
|
22
|
-
* `options_json` is a JSON string with optional fields:
|
|
23
|
-
* - `"mode"`: `"optimized"` (default) or `"full"`
|
|
24
|
-
*/
|
|
25
|
-
declare function parse(input: string, options_json: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Auto-detect input format and convert between bitmark and JSON.
|
|
28
|
-
*
|
|
29
|
-
* `options_json` is a JSON string with optional fields:
|
|
30
|
-
* - `"mode"`: `"optimized"` (default) or `"full"`
|
|
31
|
-
* - `"warnings"`: `true` or `false` (default)
|
|
32
|
-
* - `"plainText"`: `true` or `false` (default)
|
|
33
|
-
* - `"pretty"`: `true` or `false` (default)
|
|
34
|
-
* - `"indent"`: number (default: 2)
|
|
35
|
-
*
|
|
36
|
-
* Returns JSON if input is bitmark, or an error message if input is JSON
|
|
37
|
-
* (generator not yet implemented).
|
|
38
|
-
*/
|
|
39
|
-
declare function convert(input: string, options_json: string): string;
|
|
40
|
-
/**
|
|
41
|
-
* Query information about supported bit types.
|
|
42
|
-
*
|
|
43
|
-
* `info_type`: `"list"`, `"bit"`, `"all"`, or `"deprecated"`
|
|
44
|
-
* `format`: `"text"` or `"json"`
|
|
45
|
-
* `bit`: bit name (required when `info_type` is `"bit"`)
|
|
46
|
-
* `pretty`: whether to pretty-print JSON output
|
|
47
|
-
* `indent`: indent size for pretty-printing (default: 2)
|
|
48
|
-
*/
|
|
49
|
-
declare function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number): string;
|
|
50
|
-
/**
|
|
51
|
-
* Lex bitmark input text, returning one line per token in the same format as
|
|
52
|
-
* the Rust CLI: `{kind:?} {span:?} "{text}"`.
|
|
53
|
-
*
|
|
54
|
-
* `options_json` is a JSON string with optional fields:
|
|
55
|
-
* - `"stage"`: selects the lexer pipeline:
|
|
56
|
-
* - `"lex"` — combined (default)
|
|
57
|
-
* - `"lex-bitmark"` — bitmark-level only
|
|
58
|
-
* - `"lex-text"` — text-level only
|
|
59
|
-
* - `"lex-json"` — combined, JSON array output
|
|
60
|
-
* - `"lex-bitmark-json"` — bitmark-level, JSON array output
|
|
61
|
-
* - `"lex-text-json"` — text-level, JSON array output
|
|
62
|
-
*/
|
|
63
|
-
declare function lex(input: string, options_json: string): string;
|
|
64
|
-
|
|
65
1
|
type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
66
2
|
|
|
67
3
|
interface InitOutput {
|
|
68
4
|
readonly memory: WebAssembly.Memory;
|
|
69
5
|
readonly breakscape_text: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
70
|
-
readonly convert: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
6
|
+
readonly convert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
71
7
|
readonly info: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
72
8
|
readonly lex: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
73
9
|
readonly parse: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
@@ -99,4 +35,122 @@ declare function initSync(module: { module: SyncInitInput } | SyncInitInput): In
|
|
|
99
35
|
*/
|
|
100
36
|
declare function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
101
37
|
|
|
102
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Output mode for JSON serialization.
|
|
40
|
+
*
|
|
41
|
+
* - `"optimized"` — omit keys whose values match their natural defaults.
|
|
42
|
+
* - `"full"` — include all keys enumerated from the bitmark configuration.
|
|
43
|
+
*/
|
|
44
|
+
type OutputMode = "optimized" | "full";
|
|
45
|
+
/**
|
|
46
|
+
* Lexer stage selector.
|
|
47
|
+
*
|
|
48
|
+
* - `"lex"` — combined lexer, text output (default).
|
|
49
|
+
* - `"lex-bitmark"` — bitmark-level only, text output.
|
|
50
|
+
* - `"lex-text"` — text-level only, text output.
|
|
51
|
+
* - `"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
|
+
*/
|
|
55
|
+
type LexStage = "lex" | "lex-bitmark" | "lex-text" | "lex-json" | "lex-bitmark-json" | "lex-text-json";
|
|
56
|
+
/** Options for the {@link lex} function. */
|
|
57
|
+
interface LexOptions {
|
|
58
|
+
/** Selects the lexer pipeline stage (default: `"lex"`). */
|
|
59
|
+
stage?: LexStage;
|
|
60
|
+
}
|
|
61
|
+
/** Options for the {@link parse} function. */
|
|
62
|
+
interface ParseOptions {
|
|
63
|
+
/** JSON output mode (default: `"optimized"`). */
|
|
64
|
+
mode?: OutputMode;
|
|
65
|
+
}
|
|
66
|
+
/** Options for the {@link convert} function. */
|
|
67
|
+
interface ConvertOptions {
|
|
68
|
+
/** JSON output mode (default: `"optimized"`). */
|
|
69
|
+
mode?: OutputMode;
|
|
70
|
+
/** Include validation warnings in output (default: `false`). */
|
|
71
|
+
warnings?: boolean;
|
|
72
|
+
/** Output text as plain text — debug mode (default: `false`). */
|
|
73
|
+
plainText?: boolean;
|
|
74
|
+
/** Prettify JSON output (default: `false`). */
|
|
75
|
+
pretty?: boolean;
|
|
76
|
+
/** Indent size for pretty-printing (default: `2`). */
|
|
77
|
+
indent?: number;
|
|
78
|
+
}
|
|
79
|
+
/** Text format for breakscape / unbreakscape operations. */
|
|
80
|
+
type TextFormat = "bitmark++" | "plainText";
|
|
81
|
+
/** Text location for breakscape / unbreakscape operations. */
|
|
82
|
+
type TextLocation = "body" | "tag";
|
|
83
|
+
/** Options for the {@link breakscapeText} and {@link unbreakscapeText} functions. */
|
|
84
|
+
interface BreakscapeOptions {
|
|
85
|
+
/** Text format (default: `"bitmark++"`). */
|
|
86
|
+
format?: TextFormat;
|
|
87
|
+
/** Text location (default: `"body"`). */
|
|
88
|
+
location?: TextLocation;
|
|
89
|
+
}
|
|
90
|
+
/** Info query type for the {@link info} function. */
|
|
91
|
+
type InfoType = "list" | "bit" | "all" | "deprecated";
|
|
92
|
+
/** Output format for the {@link info} function. */
|
|
93
|
+
type InfoFormat = "text" | "json";
|
|
94
|
+
/** Options for the {@link info} function. */
|
|
95
|
+
interface InfoOptions {
|
|
96
|
+
/** Info query type (default: `"list"`). */
|
|
97
|
+
infoType?: InfoType;
|
|
98
|
+
/** Output format (default: `"text"`). */
|
|
99
|
+
format?: InfoFormat;
|
|
100
|
+
/** Bit name — required when `infoType` is `"bit"`. */
|
|
101
|
+
bit?: string;
|
|
102
|
+
/** Whether to pretty-print JSON output (default: `false`). */
|
|
103
|
+
pretty?: boolean;
|
|
104
|
+
/** Indent size for pretty-printing (default: `2`). */
|
|
105
|
+
indent?: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Lex bitmark input text, returning one line per token.
|
|
110
|
+
*
|
|
111
|
+
* @param input - The bitmark source text.
|
|
112
|
+
* @param options - Lex options (e.g. `{ stage: "lex-bitmark" }`).
|
|
113
|
+
* @returns Token dump string (one token per line).
|
|
114
|
+
*/
|
|
115
|
+
declare function lex(input: string, options?: LexOptions): string;
|
|
116
|
+
/**
|
|
117
|
+
* Parse bitmark input text and return the reference JSON format.
|
|
118
|
+
*
|
|
119
|
+
* @param input - The bitmark source text.
|
|
120
|
+
* @param options - Parse options (e.g. `{ mode: "full" }`).
|
|
121
|
+
* @returns JSON string of the parsed bitmark document.
|
|
122
|
+
*/
|
|
123
|
+
declare function parse(input: string, options?: ParseOptions): string;
|
|
124
|
+
/**
|
|
125
|
+
* Auto-detect input format and convert between bitmark and JSON.
|
|
126
|
+
*
|
|
127
|
+
* @param input - Bitmark or JSON input text.
|
|
128
|
+
* @param options - Convert options (e.g. `{ mode: "full", warnings: true }`).
|
|
129
|
+
* @returns Converted output string.
|
|
130
|
+
*/
|
|
131
|
+
declare function convert(input: string, options?: ConvertOptions): string;
|
|
132
|
+
/**
|
|
133
|
+
* Breakscape text (escape bitmark special characters).
|
|
134
|
+
*
|
|
135
|
+
* @param input - The text to breakscape.
|
|
136
|
+
* @param options - Breakscape options (e.g. `{ format: "plainText", location: "tag" }`).
|
|
137
|
+
* @returns Breakscaped text.
|
|
138
|
+
*/
|
|
139
|
+
declare function breakscapeText(input: string, options?: BreakscapeOptions): string;
|
|
140
|
+
/**
|
|
141
|
+
* Unbreakscape text (unescape bitmark special characters).
|
|
142
|
+
*
|
|
143
|
+
* @param input - The text to unbreakscape.
|
|
144
|
+
* @param options - Unbreakscape options (e.g. `{ format: "plainText", location: "tag" }`).
|
|
145
|
+
* @returns Unbreakscaped text.
|
|
146
|
+
*/
|
|
147
|
+
declare function unbreakscapeText(input: string, options?: BreakscapeOptions): string;
|
|
148
|
+
/**
|
|
149
|
+
* Query information about supported bit types.
|
|
150
|
+
*
|
|
151
|
+
* @param options - Info options (e.g. `{ infoType: "bit", format: "json", bit: "cloze" }`).
|
|
152
|
+
* @returns Information string.
|
|
153
|
+
*/
|
|
154
|
+
declare function info(options?: InfoOptions): string;
|
|
155
|
+
|
|
156
|
+
export { type BreakscapeOptions, type ConvertOptions, type InfoFormat, type InfoOptions, type InfoType, type LexOptions, type LexStage, type OutputMode, type ParseOptions, type TextFormat, type TextLocation, breakscapeText, convert, info, __wbg_init as init, initSync, lex, parse, unbreakscapeText };
|
|
@@ -112,14 +112,14 @@ function unbreakscape_text(input, format, location) {
|
|
|
112
112
|
wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function parse(input,
|
|
115
|
+
function parse(input, mode) {
|
|
116
116
|
let deferred3_0;
|
|
117
117
|
let deferred3_1;
|
|
118
118
|
try {
|
|
119
119
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
120
120
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
121
121
|
const len0 = WASM_VECTOR_LEN;
|
|
122
|
-
const ptr1 = passStringToWasm0(
|
|
122
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
123
123
|
const len1 = WASM_VECTOR_LEN;
|
|
124
124
|
wasm.parse(retptr, ptr0, len0, ptr1, len1);
|
|
125
125
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
@@ -132,16 +132,16 @@ function parse(input, options_json) {
|
|
|
132
132
|
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
function convert(input,
|
|
135
|
+
function convert(input, mode, warnings, plain_text, pretty, indent) {
|
|
136
136
|
let deferred3_0;
|
|
137
137
|
let deferred3_1;
|
|
138
138
|
try {
|
|
139
139
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
140
140
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
141
141
|
const len0 = WASM_VECTOR_LEN;
|
|
142
|
-
const ptr1 = passStringToWasm0(
|
|
142
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
143
143
|
const len1 = WASM_VECTOR_LEN;
|
|
144
|
-
wasm.convert(retptr, ptr0, len0, ptr1, len1);
|
|
144
|
+
wasm.convert(retptr, ptr0, len0, ptr1, len1, warnings, plain_text, pretty, indent);
|
|
145
145
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
146
146
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
147
147
|
deferred3_0 = r0;
|
|
@@ -174,14 +174,14 @@ 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 lex(input,
|
|
177
|
+
function lex(input, stage) {
|
|
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(stage, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
185
185
|
const len1 = WASM_VECTOR_LEN;
|
|
186
186
|
wasm.lex(retptr, ptr0, len0, ptr1, len1);
|
|
187
187
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
@@ -270,14 +270,43 @@ async function __wbg_init(module_or_path) {
|
|
|
270
270
|
return __wbg_finalize_init(instance, module);
|
|
271
271
|
}
|
|
272
272
|
var bitmark_wasm_default = __wbg_init;
|
|
273
|
+
|
|
274
|
+
// src/browser/index.ts
|
|
275
|
+
function lex2(input, options = {}) {
|
|
276
|
+
return lex(input, options.stage ?? "lex");
|
|
277
|
+
}
|
|
278
|
+
function parse2(input, options = {}) {
|
|
279
|
+
return parse(input, options.mode ?? "optimized");
|
|
280
|
+
}
|
|
281
|
+
function convert2(input, options = {}) {
|
|
282
|
+
return convert(input, options.mode ?? "optimized", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);
|
|
283
|
+
}
|
|
284
|
+
function breakscapeText(input, options = {}) {
|
|
285
|
+
const format = options.format ?? "bitmark++";
|
|
286
|
+
const location = options.location ?? "body";
|
|
287
|
+
return breakscape_text(input, format, location);
|
|
288
|
+
}
|
|
289
|
+
function unbreakscapeText(input, options = {}) {
|
|
290
|
+
const format = options.format ?? "bitmark++";
|
|
291
|
+
const location = options.location ?? "body";
|
|
292
|
+
return unbreakscape_text(input, format, location);
|
|
293
|
+
}
|
|
294
|
+
function info2(options = {}) {
|
|
295
|
+
const infoType = options.infoType ?? "list";
|
|
296
|
+
const format = options.format ?? "text";
|
|
297
|
+
const bit = options.bit ?? "";
|
|
298
|
+
const pretty = options.pretty ?? false;
|
|
299
|
+
const indent = options.indent ?? 2;
|
|
300
|
+
return info(infoType, format, bit, pretty, indent);
|
|
301
|
+
}
|
|
273
302
|
export {
|
|
274
|
-
|
|
275
|
-
convert,
|
|
276
|
-
info,
|
|
303
|
+
breakscapeText,
|
|
304
|
+
convert2 as convert,
|
|
305
|
+
info2 as info,
|
|
277
306
|
bitmark_wasm_default as init,
|
|
278
307
|
initSync,
|
|
279
|
-
lex,
|
|
280
|
-
parse,
|
|
281
|
-
|
|
308
|
+
lex2 as lex,
|
|
309
|
+
parse2 as parse,
|
|
310
|
+
unbreakscapeText
|
|
282
311
|
};
|
|
283
312
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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 * 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 * `options_json` is a JSON string with optional fields:\n * - `\"mode\"`: `\"optimized\"` (default) or `\"full\"`\n * @param {string} input\n * @param {string} options_json\n * @returns {string}\n */\nexport function parse(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.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 * `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 * 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 * `options_json` is a JSON string with optional fields:\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} options_json\n * @returns {string}\n */\nexport function lex(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.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;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AAC,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"]}
|
|
1
|
+
{"version":3,"sources":["../../../wasm-web/bitmark_wasm.js","../../../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 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\";\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 * 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,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,MAAM,IAAI;AACd,MAAI,M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O,QAAQ,aAAa,OAAO,QAAQ,UAAU,OAAO,QAAQ,UAAU,CAAC;AAC7J;AASO,SAAS,eAAe,OAAe,UAA6B,CAAC,GAAW;AACrF,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,YAAY;AACrC,SAAY,gBAAgB,OAAO,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"]}
|
package/dist/cli.js
CHANGED
|
@@ -6,25 +6,34 @@ import { dirname } from 'path';
|
|
|
6
6
|
|
|
7
7
|
// src/generated/package_info.ts
|
|
8
8
|
var PACKAGE_INFO = {
|
|
9
|
-
"version": "3.0.1-alpha.
|
|
9
|
+
"version": "3.0.1-alpha.4"};
|
|
10
10
|
var require2 = createRequire(import.meta.url);
|
|
11
11
|
var wasm = require2("../wasm/bitmark_wasm.js");
|
|
12
|
-
function lex(input,
|
|
13
|
-
return wasm.lex(input,
|
|
12
|
+
function lex(input, options = {}) {
|
|
13
|
+
return wasm.lex(input, options.stage ?? "lex");
|
|
14
14
|
}
|
|
15
|
-
function parse(input,
|
|
16
|
-
return wasm.parse(input,
|
|
15
|
+
function parse(input, options = {}) {
|
|
16
|
+
return wasm.parse(input, options.mode ?? "optimized");
|
|
17
17
|
}
|
|
18
|
-
function convert(input,
|
|
19
|
-
return wasm.convert(input,
|
|
18
|
+
function convert(input, options = {}) {
|
|
19
|
+
return wasm.convert(input, options.mode ?? "optimized", options.warnings ?? false, options.plainText ?? false, options.pretty ?? false, options.indent ?? 2);
|
|
20
20
|
}
|
|
21
|
-
function breakscapeText(input,
|
|
21
|
+
function breakscapeText(input, options = {}) {
|
|
22
|
+
const format = options.format ?? "bitmark++";
|
|
23
|
+
const location = options.location ?? "body";
|
|
22
24
|
return wasm.breakscape_text(input, format, location);
|
|
23
25
|
}
|
|
24
|
-
function unbreakscapeText(input,
|
|
26
|
+
function unbreakscapeText(input, options = {}) {
|
|
27
|
+
const format = options.format ?? "bitmark++";
|
|
28
|
+
const location = options.location ?? "body";
|
|
25
29
|
return wasm.unbreakscape_text(input, format, location);
|
|
26
30
|
}
|
|
27
|
-
function info(
|
|
31
|
+
function info(options = {}) {
|
|
32
|
+
const infoType = options.infoType ?? "list";
|
|
33
|
+
const format = options.format ?? "text";
|
|
34
|
+
const bit = options.bit ?? "";
|
|
35
|
+
const pretty = options.pretty ?? false;
|
|
36
|
+
const indent = options.indent ?? 2;
|
|
28
37
|
return wasm.info(infoType, format, bit, pretty, indent);
|
|
29
38
|
}
|
|
30
39
|
function readInputs(inputs) {
|
|
@@ -72,11 +81,9 @@ function registerParseCommand(program2) {
|
|
|
72
81
|
const content = readInputs(inputs);
|
|
73
82
|
let result;
|
|
74
83
|
if (options.stage === "lex" || options.stage === "lex-bitmark" || options.stage === "lex-text") {
|
|
75
|
-
|
|
76
|
-
result = lex(content, lexOptionsJson);
|
|
84
|
+
result = lex(content, { stage: options.stage });
|
|
77
85
|
} else {
|
|
78
|
-
|
|
79
|
-
result = parse(content, optionsJson);
|
|
86
|
+
result = parse(content, { mode: options.mode });
|
|
80
87
|
}
|
|
81
88
|
writeOutput(result, options.output, options.append);
|
|
82
89
|
});
|
|
@@ -95,14 +102,13 @@ function registerConvertCommand(program2) {
|
|
|
95
102
|
program2.command("convert").description("Auto-detect input format and convert between bitmark and JSON").argument("[INPUT...]", "Input: file paths, bitmark/JSON strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("-w, --warnings", "Enable validation warnings in output", false).option("-p, --pretty", "Prettify JSON output", false).option("--indent <n>", "Indent size for pretty JSON", "2").option("--mode <MODE>", "JSON output mode: optimized or full", "optimized").option("--plain-text", "Output text as plain text (debug)", false).action(
|
|
96
103
|
(inputs, options) => {
|
|
97
104
|
const content = readInputs(inputs);
|
|
98
|
-
const
|
|
105
|
+
const result = convert(content, {
|
|
99
106
|
mode: options.mode,
|
|
100
107
|
warnings: options.warnings,
|
|
101
108
|
plainText: options.plainText,
|
|
102
109
|
pretty: options.pretty,
|
|
103
110
|
indent: parseInt(options.indent, 10)
|
|
104
111
|
});
|
|
105
|
-
const result = convert(content, optionsJson);
|
|
106
112
|
writeOutput(result, options.output, options.append);
|
|
107
113
|
}
|
|
108
114
|
);
|
|
@@ -112,7 +118,10 @@ function registerConvertCommand(program2) {
|
|
|
112
118
|
function registerBreakscapeCommand(program2) {
|
|
113
119
|
program2.command("breakscape").description("Breakscape text (escape bitmark special characters)").argument("[INPUT...]", "Input: file paths, text strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("--format <FORMAT>", "Text format: bitmark++ or plainText", "bitmark++").option("--location <LOCATION>", "Text location: body or tag", "body").action((inputs, options) => {
|
|
114
120
|
const content = readInputs(inputs);
|
|
115
|
-
const result = breakscapeText(content,
|
|
121
|
+
const result = breakscapeText(content, {
|
|
122
|
+
format: options.format,
|
|
123
|
+
location: options.location
|
|
124
|
+
});
|
|
116
125
|
writeOutput(result, options.output, options.append);
|
|
117
126
|
});
|
|
118
127
|
}
|
|
@@ -121,7 +130,10 @@ function registerBreakscapeCommand(program2) {
|
|
|
121
130
|
function registerUnbreakscapeCommand(program2) {
|
|
122
131
|
program2.command("unbreakscape").description("Unbreakscape text (unescape bitmark special characters)").argument("[INPUT...]", "Input: file paths, text strings, or omit for stdin").option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("--format <FORMAT>", "Text format: bitmark++ or plainText", "bitmark++").option("--location <LOCATION>", "Text location: body or tag", "body").action((inputs, options) => {
|
|
123
132
|
const content = readInputs(inputs);
|
|
124
|
-
const result = unbreakscapeText(content,
|
|
133
|
+
const result = unbreakscapeText(content, {
|
|
134
|
+
format: options.format,
|
|
135
|
+
location: options.location
|
|
136
|
+
});
|
|
125
137
|
writeOutput(result, options.output, options.append);
|
|
126
138
|
});
|
|
127
139
|
}
|
|
@@ -130,7 +142,13 @@ function registerUnbreakscapeCommand(program2) {
|
|
|
130
142
|
function registerInfoCommand(program2) {
|
|
131
143
|
program2.command("info").description("Show information about supported bit types").argument("[INFO]", "Info type: list, bit, all, deprecated", "list").option("-f, --format <FORMAT>", "Output format: text or json", "text").option("--all", "Include deprecated bits", false).option("--bit <NAME>", "Filter to specific bit type").option("--deprecated", "Show only deprecated bits", false).option("-o, --output <file>", "Output file (default: stdout)").option("-a, --append", "Append to output file", false).option("-p, --pretty", "Prettify JSON output", false).option("--indent <n>", "Indent size for pretty JSON", "2").action(
|
|
132
144
|
(infoType, options) => {
|
|
133
|
-
const result = info(
|
|
145
|
+
const result = info({
|
|
146
|
+
infoType,
|
|
147
|
+
format: options.format,
|
|
148
|
+
bit: options.bit,
|
|
149
|
+
pretty: options.pretty,
|
|
150
|
+
indent: parseInt(options.indent, 10)
|
|
151
|
+
});
|
|
134
152
|
writeOutput(result, options.output, options.append);
|
|
135
153
|
}
|
|
136
154
|
);
|