@gmb/bitmark-parser 6.11.1 → 7.1.0

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.
Files changed (45) hide show
  1. package/README.md +361 -57
  2. package/dist/browser/bitmark-parser.min.js +4 -4
  3. package/dist/browser/bitmark-parser.min.js.map +1 -1
  4. package/dist/browser/cjs/index.cjs +966 -372
  5. package/dist/browser/cjs/index.cjs.map +1 -1
  6. package/dist/browser/cjs/index.d.cts +642 -70
  7. package/dist/browser/esm/index.d.ts +642 -70
  8. package/dist/browser/esm/index.js +958 -371
  9. package/dist/browser/esm/index.js.map +1 -1
  10. package/dist/browser/esm/worker-entry.js +790 -247
  11. package/dist/browser/esm/worker-entry.js.map +1 -1
  12. package/dist/browser/wasm/bitmark_browser_full_wasm_bg.wasm +0 -0
  13. package/dist/browser/wasm/bitmark_json_wasm_bg.wasm +0 -0
  14. package/dist/browser/wasm/bitmark_wasm_bg.wasm +0 -0
  15. package/dist/index.cjs +163 -124
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +637 -70
  18. package/dist/index.d.ts +637 -70
  19. package/dist/index.js +155 -123
  20. package/dist/index.js.map +1 -1
  21. package/dist/legacy.cjs +8 -30
  22. package/dist/legacy.cjs.map +1 -1
  23. package/dist/legacy.d.cts +0 -2
  24. package/dist/legacy.d.ts +0 -2
  25. package/dist/legacy.js +8 -30
  26. package/dist/legacy.js.map +1 -1
  27. package/dist/worker-entry.cjs +1 -5
  28. package/dist/worker-entry.cjs.map +1 -1
  29. package/package.json +7 -7
  30. package/schema/bitmark.schema.json +507 -141
  31. package/wasm/bitmark_wasm.d.ts +65 -26
  32. package/wasm/bitmark_wasm.js +348 -116
  33. package/wasm/bitmark_wasm_bg.wasm +0 -0
  34. package/wasm/bitmark_wasm_bg.wasm.d.ts +6 -3
  35. package/wasm/package.json +1 -1
  36. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +56 -15
  37. package/wasm-bitmark-json/bitmark_json_wasm.js +321 -77
  38. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  39. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +5 -2
  40. package/wasm-bitmark-json/package.json +1 -1
  41. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +65 -26
  42. package/wasm-browser-full/bitmark_browser_full_wasm.js +348 -116
  43. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
  44. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm.d.ts +6 -3
  45. package/wasm-browser-full/package.json +1 -1
@@ -1,14 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Lex bitmark input text, returning one line per token in the same format as
5
- * the Rust CLI: `{kind:?} {span:?} "{text}"`.
6
- *
7
- * `stage` selects the lexer pipeline:
8
- * - `"lex"` — combined (default)
9
- * - `"lex-json"` — combined, JSON array output
10
- */
11
- export function lex(input: string, stage: string): string;
12
3
  /**
13
4
  * Breakscape text (escape bitmark special characters).
14
5
  *
@@ -41,6 +32,13 @@ export function unbreakscape_text(input: string, format: string, location: strin
41
32
  * several (adds a `titles` map), `"all"` for every resolvable language
42
33
  */
43
34
  export function info(info_type: string, format: string, bit: string, pretty: boolean, indent: number, include_deprecated: boolean, only_deprecated: boolean, full: boolean, language: string): string;
35
+ /**
36
+ * Whether this build can render `info` as TEXT (PLAN-192 D6). The export is
37
+ * ABSENT when it cannot — the same "presence is the capability" signal
38
+ * `diff` uses, so a caller tests for the function rather than for a
39
+ * variant name.
40
+ */
41
+ export function info_text_supported(): boolean;
44
42
  /**
45
43
  * Convert a standalone bitmark text fragment ↔ TextAst (ProseMirror JSON).
46
44
  *
@@ -48,28 +46,35 @@ export function info(info_type: string, format: string, bit: string, pretty: boo
48
46
  * `format`: a bitmark text format (`"bitmark++"`, `"bitmark+"`) parses
49
47
  * inline marks; anything else is treated as plain text (textToAst only).
50
48
  * `location`: `"body"` (default) or `"tag"`.
51
- * Returns the converted fragment, or `error: …`.
49
+ * Returns the converted fragment; throws on failure.
52
50
  */
53
51
  export function convert_text(input: string, direction: string, format: string, location: string): string;
54
52
  /**
55
53
  * Apply a patch (a JSON array of patch entries) to every bit and re-emit.
56
54
  *
57
55
  * `input_format_sel`: `"auto"` | `"bitmark"` | `"json"`.
58
- * `output_format_sel`: `"bitmark"` | `"json"` (default json).
56
+ * `output_format_sel`: the same vocabulary as `convert` — `"bitmark"` |
57
+ * `"json"` | `"text"` | a mapping id (`"html"`, …), `"auto"` (or empty) being
58
+ * the opposite of the resolved input format. The whole-document outputs
59
+ * (`lex`, `semantic-tokens`, `diagnostics`) are not per-bit formats; the
60
+ * pipeline refuses them and that refusal is what throws.
59
61
  * `patch_json`: the patch entry array (empty string = no patches, i.e. a
60
62
  * canonicalizing pass). Parallelism is a JS-side concern (web workers); this
61
- * runs sequentially. Returns the document text/JSON, or `error: …`.
63
+ * runs sequentially. Returns the document text/JSON; throws on failure.
62
64
  */
63
65
  export function transform(input: string, input_format_sel: string, output_format_sel: string, mode: string, patch_json: string, pretty: boolean, indent: number, spaces_around_values: number): string;
64
66
  /**
65
67
  * Resolve a patch document against `input` (bitmark or JSON) into the
66
68
  * ordered output items, so a JS per-bit planner (hooks, worker pool) can
67
69
  * reorder, drop and insert jobs from the one Rust implementation
68
- * (PLAN-179). Returns a JSON array of
70
+ * (PLAN-179). `input_format_sel` is the caller's input-format selector
71
+ * (`"auto"` | `"bitmark"` | `"json"`): the document is split under the SAME
72
+ * selection the planner already resolved, never re-sniffed (PLAN-187 D1).
73
+ * Returns a JSON array of
69
74
  * `{ "source": <original index> | null, "bit": <inner bit> | null,
70
- * "patch": [ … ] }`, or `error: …`.
75
+ * "patch": [ … ] }`; throws on failure.
71
76
  */
72
- export function resolve_patch_document(input: string, patch_json: string): string;
77
+ export function resolve_patch_document(input: string, input_format_sel: string, patch_json: string): string;
73
78
  /**
74
79
  * Semantic diff of two documents (PLAN-179). Flat arguments like every
75
80
  * other export:
@@ -80,10 +85,37 @@ export function resolve_patch_document(input: string, patch_json: string): strin
80
85
  * - `context`, `locate`, `similarity`, `bbox_tolerance`,
81
86
  * `spaces_around_values` as documented on `DiffOptions`.
82
87
  * Returns the diff (empty text / `[]` of unchanged bits / a patch document
83
- * with no entries when the documents are semantically equal), or
84
- * `error: …`.
88
+ * with no entries when the documents are semantically equal); throws on
89
+ * failure.
85
90
  */
86
91
  export function diff(a: string, b: string, input_format_sel: string, output_format_sel: string, context: number, locate: boolean, similarity: number, bbox_tolerance: number, spaces_around_values: number): string;
92
+ /**
93
+ * The constructs valid at a position, as an LSP `CompletionList` (PLAN-196
94
+ * D7; contract `API-EDT-editor-services.tsp`). `line` / `character` are
95
+ * 0-based, `character` in `position_encoding` units (`"utf-16"`, the
96
+ * default, or `"utf-8"`); `include_deprecated` offers deprecated bits too;
97
+ * `trigger_character` is the character the editor sent as the trigger (LSP
98
+ * `CompletionContext.triggerCharacter`; empty when invoked explicitly) — a
99
+ * trigger that opens nothing where the cursor is answers the empty list
100
+ * (PLAN-203 D1). ABSENT on a variant built without `editor` — the same
101
+ * "presence is the capability" signal `diff` uses. Throws when the line is
102
+ * past the text.
103
+ */
104
+ export function complete(input: string, line: number, character: number, position_encoding: string, include_deprecated: boolean, trigger_character: string): string;
105
+ /**
106
+ * One item of the list `complete` returns at this position, its Markdown
107
+ * `documentation` filled in — LSP `completionItem/resolve` (PLAN-202):
108
+ * `complete` ships no documentation, an editor asks for the one item it is
109
+ * about to show. `label` and `kind` (the LSP `CompletionItemKind` number)
110
+ * name the item; the JSON `null` when the list has no such item. Arguments
111
+ * otherwise as `complete`.
112
+ */
113
+ export function resolve(input: string, line: number, character: number, position_encoding: string, include_deprecated: boolean, label: string, kind: number): string;
114
+ /**
115
+ * The construct at a position, as an LSP `Hover` — or the JSON `null` when
116
+ * there is nothing to show (PLAN-196 D8). Arguments as `complete`.
117
+ */
118
+ export function hover(input: string, line: number, character: number, position_encoding: string): string;
87
119
  /**
88
120
  * Register data with the parser process (PLAN-173 P12).
89
121
  *
@@ -92,24 +124,31 @@ export function diff(a: string, b: string, input_format_sel: string, output_form
92
124
  *
93
125
  * `data` is the file's own text. Semantics are REPLACE: a second call
94
126
  * supersedes the first entirely, and the built-in table (where the variant
95
- * bakes one) stays underneath. Returns `""` on success, or an
96
- * `error:`-prefixed message — matching the other string-returning exports.
127
+ * bakes one) stays underneath. Throws on bad data — like every other
128
+ * fallible export (PLAN-192 D1).
97
129
  *
98
130
  * Available in EVERY variant, including those that bake nothing: that is
99
131
  * exactly where a consumer must supply the file themselves.
100
132
  */
101
- export function register(data_type: string, data: string): string;
133
+ export function register(data_type: string, data: string): void;
102
134
  /**
103
135
  * Convert between bitmark and JSON with explicit input/output formats + mode.
104
136
  *
105
- * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"`.
106
- * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"`.
137
+ * `input_format`: `"auto"` (default) | `"bitmark"` | `"json"` | a mapping id.
138
+ * `output_format`: `"auto"` (opposite of input) | `"bitmark"` | `"json"` |
139
+ * `"text"` | `"lex"` (the token stream as JSON) | `"semantic-tokens"` |
140
+ * `"diagnostics"` (the last three bitmark input only) | a mapping id.
107
141
  * `mode`: `"optimized"` (default) | `"full"`.
108
142
  * `mapping_report`: replace the output with a human-readable report of the
109
143
  * input→output mappings, including inputs that are NOT mapped (PLAN-147).
110
- * Returns the converted text/JSON, or a string prefixed `error:` on failure.
144
+ * `position_encoding`: `"utf-16"` (default) | `"utf-8"` — the
145
+ * `semantic-tokens` and `diagnostics` outputs' encoding (PLAN-193 /
146
+ * PLAN-196) — and `tokens_layout`: `"lsp"` (default) | `"absolute"` — the
147
+ * `semantic-tokens` layout; `""` means the default, and every other output
148
+ * format ignores them.
149
+ * Returns the converted text/JSON; throws on failure.
111
150
  */
112
- export function convert(input: string, input_format_sel: string, output_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number, include_unknown_properties: boolean, mapping_report: boolean): string;
151
+ export function convert(input: string, input_format_sel: string, output_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number, include_unknown_properties: boolean, mapping_report: boolean, position_encoding: string, tokens_layout: string): string;
113
152
  /**
114
153
  * Re-emit input in its own format in canonical form at `mode`.
115
154
  *
@@ -119,7 +158,7 @@ export function convert(input: string, input_format_sel: string, output_format_s
119
158
  export function canonicalize(input: string, input_format_sel: string, mode: string, pretty: boolean, indent: number, spaces_around_values: number): string;
120
159
  /**
121
160
  * Count the bits in `input` (auto-detecting bitmark vs JSON).
122
- * Returns the count as a decimal string, or `error: …`.
161
+ * Returns the count as a decimal string; throws on failure.
123
162
  */
124
163
  export function count_bits(input: string): string;
125
164
  /**
@@ -138,7 +177,7 @@ export function is_bitmark(input: string): boolean;
138
177
  * Split a JSON document (a top-level array of bit envelopes) into its per-bit
139
178
  * envelope objects, returned as a JSON array string. Lets a JS caller iterate
140
179
  * JSON-input bits for per-bit hooks (the JSON counterpart of [`split_bits`]).
141
- * Returns `error: …` if the input is not a JSON array of bits.
180
+ * Throws if the input is not a JSON array of bits.
142
181
  */
143
182
  export function split_json_bits(input: string): string;
144
183
  /**