@gmb/bitmark-parser 6.11.0 → 7.0.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 +311 -51
  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 +696 -312
  5. package/dist/browser/cjs/index.cjs.map +1 -1
  6. package/dist/browser/cjs/index.d.cts +487 -74
  7. package/dist/browser/esm/index.d.ts +487 -74
  8. package/dist/browser/esm/index.js +693 -311
  9. package/dist/browser/esm/index.js.map +1 -1
  10. package/dist/browser/esm/worker-entry.js +578 -210
  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 +119 -107
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +487 -74
  18. package/dist/index.d.ts +487 -74
  19. package/dist/index.js +116 -106
  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 +496 -139
  31. package/wasm/bitmark_wasm.d.ts +47 -20
  32. package/wasm/bitmark_wasm.js +262 -96
  33. package/wasm/bitmark_wasm_bg.wasm +0 -0
  34. package/wasm/bitmark_wasm_bg.wasm.d.ts +4 -2
  35. package/wasm/package.json +1 -1
  36. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +26 -11
  37. package/wasm-bitmark-json/bitmark_json_wasm.js +195 -65
  38. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  39. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +2 -1
  40. package/wasm-bitmark-json/package.json +1 -1
  41. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +47 -20
  42. package/wasm-browser-full/bitmark_browser_full_wasm.js +262 -96
  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 +4 -2
  45. package/wasm-browser-full/package.json +1 -1
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { createRequire } from "module";
10
10
  // src/generated/package_info.ts
11
11
  var PACKAGE_INFO = {
12
12
  "name": "@gmb/bitmark-parser",
13
- "version": "6.11.0",
13
+ "version": "7.0.0",
14
14
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
15
15
  "license": "ISC",
16
16
  "description": "A parser for bitmark text, powered by WebAssembly."
@@ -49,8 +49,11 @@ function getActive() {
49
49
  }
50
50
  function setActive(feature, module) {
51
51
  for (const [type, data] of registrations) {
52
- const error = module.register(type, data);
53
- if (error) throw new RegisterError(error.replace(/^error:\s*/, ""));
52
+ try {
53
+ module.register(type, data);
54
+ } catch (e) {
55
+ throw new RegisterError(e instanceof Error ? e.message : String(e));
56
+ }
54
57
  }
55
58
  active = module;
56
59
  activeFeature = feature;
@@ -66,38 +69,24 @@ function variant() {
66
69
  }
67
70
 
68
71
  // src/core/hooked-transform.ts
69
- function isError(s) {
70
- return s.startsWith("error:");
71
- }
72
- function errorString(e) {
73
- const m = e instanceof Error ? e.message : String(e);
74
- return m.startsWith("error:") ? m : `error: ${m}`;
75
- }
76
72
  function stripArray(doc) {
77
73
  const t = doc.trim();
78
74
  return t.startsWith("[") && t.endsWith("]") ? t.slice(1, -1) : doc;
79
75
  }
80
- function normalisePatch(patch) {
81
- if (patch === void 0) return [];
82
- if (typeof patch === "string") {
83
- const trimmed = patch.trim();
84
- return trimmed === "" ? [] : JSON.parse(trimmed);
85
- }
86
- return patch;
76
+ function patchJsonOf(patch) {
77
+ if (patch === void 0) return "";
78
+ if (typeof patch === "string") return patch.trim();
79
+ return JSON.stringify(patch);
87
80
  }
88
81
  function buildUnits(wasm, input, inputIsBitmark) {
89
82
  if (inputIsBitmark) {
90
- const out2 = wasm.split_bits(input);
91
- if (isError(out2)) throw new Error(out2);
92
- const slices = JSON.parse(out2);
83
+ const slices = JSON.parse(wasm.split_bits(input));
93
84
  return slices.map((s) => ({
94
85
  view: { format: "bitmark", index: s.index, total: slices.length, source: s.source },
95
86
  source: s.source
96
87
  }));
97
88
  }
98
- const out = wasm.split_json_bits(input);
99
- if (isError(out)) throw new Error(out);
100
- const envelopes = JSON.parse(out);
89
+ const envelopes = JSON.parse(wasm.split_json_bits(input));
101
90
  return envelopes.map((env, index) => ({
102
91
  view: { format: "json", index, total: envelopes.length, bit: env.bit ?? {} },
103
92
  // Per-bit transform consumes a one-bit JSON document.
@@ -113,28 +102,54 @@ function planTransform(wasm, input, options) {
113
102
  const sel = options.inputFormat ?? "auto";
114
103
  const inputIsBitmark = sel === "bitmark" || sel !== "json" && wasm.is_bitmark(input);
115
104
  const inputFormat = inputIsBitmark ? "bitmark" : "json";
116
- const staticPatch = normalisePatch(options.patch);
117
105
  const units = buildUnits(wasm, input, inputIsBitmark);
118
106
  const total = units.length;
119
- const jobs = [];
120
- const views = [];
107
+ const hooked = [];
121
108
  for (let index = 0; index < total; index++) {
122
- const { view, source } = units[index];
109
+ const { view } = units[index];
123
110
  view.index = index;
124
111
  view.total = total;
125
112
  const result = options.preHook ? options.preHook(view) || {} : {};
126
- if (result.drop) continue;
127
- const patches = result.patches ? [...staticPatch, ...result.patches] : staticPatch;
128
- jobs.push({
129
- index,
130
- source,
131
- inputFormat,
132
- outputFormat: result.outputFormat ?? output,
133
- mode,
134
- patchJson: JSON.stringify(patches),
135
- spacesAroundValues
136
- });
137
- views.push(view);
113
+ hooked.push(result.drop ? null : { patches: result.patches ?? [], outputFormat: result.outputFormat ?? output });
114
+ }
115
+ const patchJson = patchJsonOf(options.patch);
116
+ let resolved;
117
+ if (patchJson === "") {
118
+ resolved = units.map((_, index) => ({ source: index, bit: null, patch: [] }));
119
+ } else {
120
+ resolved = JSON.parse(wasm.resolve_patch_document(input, patchJson));
121
+ }
122
+ const jobs = [];
123
+ const views = [];
124
+ for (const item of resolved) {
125
+ if (item.source !== null) {
126
+ const hook = hooked[item.source];
127
+ if (!hook) continue;
128
+ jobs.push({
129
+ index: item.source,
130
+ source: units[item.source].source,
131
+ inputFormat,
132
+ outputFormat: hook.outputFormat,
133
+ mode,
134
+ // The document's patches first, the hook's after (the hook contract).
135
+ patchJson: JSON.stringify([...item.patch, ...hook.patches]),
136
+ spacesAroundValues
137
+ });
138
+ views.push(units[item.source].view);
139
+ } else {
140
+ const bit = item.bit ?? {};
141
+ const index = jobs.length;
142
+ jobs.push({
143
+ index,
144
+ source: JSON.stringify([{ bit }]),
145
+ inputFormat: "json",
146
+ outputFormat: output,
147
+ mode,
148
+ patchJson: JSON.stringify(item.patch),
149
+ spacesAroundValues
150
+ });
151
+ views.push({ format: "json", index, total, bit });
152
+ }
138
153
  }
139
154
  return { jobs, views, output, pretty, indent };
140
155
  }
@@ -149,7 +164,6 @@ function computeBit(wasm, job) {
149
164
  2,
150
165
  job.spacesAroundValues
151
166
  );
152
- if (isError(out)) return out;
153
167
  return job.outputFormat === "json" ? stripArray(out) : out;
154
168
  }
155
169
  function recombine(wasm, elements, output, pretty, indent) {
@@ -158,16 +172,10 @@ function recombine(wasm, elements, output, pretty, indent) {
158
172
  return pretty ? wasm.prettify(arr, indent) : arr;
159
173
  }
160
174
  function runHookedTransform(wasm, input, options) {
161
- let plan;
162
- try {
163
- plan = planTransform(wasm, input, options);
164
- } catch (e) {
165
- return errorString(e);
166
- }
175
+ const plan = planTransform(wasm, input, options);
167
176
  const rendered = [];
168
177
  for (let i = 0; i < plan.jobs.length; i++) {
169
178
  const element = computeBit(wasm, plan.jobs[i]);
170
- if (isError(element)) return element;
171
179
  options.postHook?.(plan.views[i], element);
172
180
  rendered.push(element);
173
181
  }
@@ -176,20 +184,9 @@ function runHookedTransform(wasm, input, options) {
176
184
 
177
185
  // src/core/parallel.ts
178
186
  async function orchestrateParallel(wasm, input, options, runJobs) {
179
- let plan;
180
- try {
181
- plan = planTransform(wasm, input, options);
182
- } catch (e) {
183
- return errorString(e);
184
- }
185
- let elements;
186
- try {
187
- elements = await runJobs(plan.jobs, options.workers ?? 4);
188
- } catch (e) {
189
- return errorString(e);
190
- }
187
+ const plan = planTransform(wasm, input, options);
188
+ const elements = await runJobs(plan.jobs, options.workers ?? 4);
191
189
  for (let i = 0; i < elements.length; i++) {
192
- if (isError(elements[i])) return elements[i];
193
190
  options.postHook?.(plan.views[i], elements[i]);
194
191
  }
195
192
  return recombine(wasm, elements, plan.output, plan.pretty, plan.indent);
@@ -544,10 +541,7 @@ var Builder = class {
544
541
  }
545
542
  }
546
543
  this.parseStringTexts(bit);
547
- const out = wasm.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false, false);
548
- if (out.startsWith("error:")) {
549
- throw new Error(out.slice("error:".length).trim());
550
- }
544
+ const out = wasm.convert(JSON.stringify([{ bit }]), "json", "json", "optimized", false, 2, 1, false, false, "", "");
551
545
  const entries = JSON.parse(out);
552
546
  const built = entries[0]?.bit ?? bit;
553
547
  for (const [key, value] of Object.entries(bit)) {
@@ -684,8 +678,7 @@ var BitmarkParserGenerator = class {
684
678
  const emit = coreFormat === "bitmark" ? prettyIndent(bitmarkOptions.prettifyJson) : { pretty, indent };
685
679
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
686
680
  const includeUnknown = !jsonOptions.excludeUnknownProperties;
687
- const out = wasm.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown, false);
688
- this.throwOnError(out);
681
+ const out = wasm.convert(source, isBitmark ? "bitmark" : "json", coreFormat, "optimized", emit.pretty, emit.indent, spaces, includeUnknown, false, "", "");
689
682
  if (outputFormat === "bitmark" || outputFormat === "text") {
690
683
  return this.deliver(out, opts.outputFile, opts.fileOptions);
691
684
  }
@@ -719,7 +712,6 @@ var BitmarkParserGenerator = class {
719
712
  );
720
713
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
721
714
  const out = wasm.canonicalize(source, isBitmark ? "bitmark" : "json", "optimized", pretty, indent, spaces);
722
- this.throwOnError(out);
723
715
  if (isBitmark) return this.deliver(out, opts.outputFile, opts.fileOptions);
724
716
  if (opts.outputFile) return this.deliver(out, opts.outputFile, opts.fileOptions);
725
717
  if (pretty || jsonOptions.stringify) return out;
@@ -736,7 +728,6 @@ var BitmarkParserGenerator = class {
736
728
  const { pretty, indent } = prettyIndent(opts.prettify);
737
729
  const coreFormat = format === "pojo" ? "json" : format;
738
730
  const out = wasm.info(type, coreFormat, opts.bit ?? "", pretty, indent, false, false, true, "");
739
- this.throwOnError(out);
740
731
  if (format === "pojo") return JSON.parse(out);
741
732
  return out;
742
733
  }
@@ -768,8 +759,7 @@ var BitmarkParserGenerator = class {
768
759
  const isHtmlInput = opts.inputFormat === "html" || opts.inputFormat === void 0 && typeof input === "string" && /<table[\s>]/iu.test(inStr);
769
760
  if (!isHtmlInput) {
770
761
  const { source, isBitmark } = this.resolveInput(input, void 0);
771
- const out2 = wasm.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false, false);
772
- this.throwOnError(out2);
762
+ const out2 = wasm.convert(source, isBitmark ? "bitmark" : "json", "html", "optimized", false, 2, 1, false, false, "", "");
773
763
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
774
764
  }
775
765
  const bitType = opts.tableFormat === "table" ? "table" : "table-extended";
@@ -778,13 +768,11 @@ var BitmarkParserGenerator = class {
778
768
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
779
769
  const spaces = spacesAround(bitmarkOptions.spacesAroundValues);
780
770
  if (outputFormat === "html") {
781
- const out2 = wasm.convert(wrapped, "html", "html", "optimized", false, 2, 1, false, false);
782
- this.throwOnError(out2);
771
+ const out2 = wasm.convert(wrapped, "html", "html", "optimized", false, 2, 1, false, false, "", "");
783
772
  return this.deliver(extractHtmlTables(out2).join("\n"), opts.outputFile, opts.fileOptions);
784
773
  }
785
774
  const coreFormat = outputFormat === "ast" ? "json" : outputFormat;
786
- const out = wasm.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false, false);
787
- this.throwOnError(out);
775
+ const out = wasm.convert(wrapped, "html", coreFormat, "optimized", pretty, indent, spaces, false, false, "", "");
788
776
  if (outputFormat === "bitmark" || outputFormat === "text") {
789
777
  return this.deliver(out, opts.outputFile, opts.fileOptions);
790
778
  }
@@ -808,8 +796,7 @@ var BitmarkParserGenerator = class {
808
796
  const opts = Object.assign({}, options);
809
797
  const wasm = getLegacyWasm();
810
798
  const { source, isBitmark } = this.resolveInput(input, opts.inputFormat);
811
- const out = wasm.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true, false);
812
- this.throwOnError(out);
799
+ const out = wasm.convert(source, isBitmark ? "bitmark" : "json", "json", "optimized", false, 2, 1, true, false, "", "");
813
800
  return makePseudoAst(JSON.parse(out));
814
801
  }
815
802
  /**
@@ -861,11 +848,9 @@ var BitmarkParserGenerator = class {
861
848
  }
862
849
  if (ast !== void 0) {
863
850
  const out2 = isBitmarkText ? wasm.convert_text(JSON.stringify(ast), "astToText", "bitmark++", textLocation) : wasm.convert_text(JSON.stringify(ast), "astToPlainText", "plainText", textLocation);
864
- this.throwOnError(out2);
865
851
  return this.deliver(out2, opts.outputFile, opts.fileOptions);
866
852
  }
867
853
  const out = wasm.convert_text(inStr, "textToAst", isBitmarkText ? "bitmark++" : "plainText", "body");
868
- this.throwOnError(out);
869
854
  const { pretty, indent } = prettyIndent(jsonOptions.prettify);
870
855
  const outStr = pretty ? wasm.prettify(out, indent) : out;
871
856
  if (opts.outputFile) return this.deliver(outStr, opts.outputFile, opts.fileOptions);
@@ -883,7 +868,6 @@ var BitmarkParserGenerator = class {
883
868
  "bitmark++",
884
869
  "body"
885
870
  );
886
- this.throwOnError(out);
887
871
  return out;
888
872
  }
889
873
  /**
@@ -898,7 +882,6 @@ var BitmarkParserGenerator = class {
898
882
  if (inputFormat === "bitmarkText") {
899
883
  const ast = wasm.convert_text(String(input), "textToAst", "bitmark++", "body");
900
884
  const out2 = wasm.convert_text(ast, "astToPlainText", "bitmark++", "body");
901
- this.throwOnError(out2);
902
885
  return out2;
903
886
  }
904
887
  if (typeof input === "string" && this.parseTextAstString(input) === void 0 && !wasm.is_bitmark(input)) {
@@ -915,8 +898,7 @@ var BitmarkParserGenerator = class {
915
898
  }
916
899
  }
917
900
  const { source, isBitmark } = this.resolveInput(input, void 0);
918
- const out = wasm.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false, false);
919
- this.throwOnError(out);
901
+ const out = wasm.convert(source, isBitmark ? "bitmark" : "json", "text", "optimized", false, 2, 1, false, false, "", "");
920
902
  return out;
921
903
  }
922
904
  /** If `s` parses as a TextAst JSON array, return it. */
@@ -1020,12 +1002,6 @@ var BitmarkParserGenerator = class {
1020
1002
  encoding: fileOptions?.encoding ?? "utf8"
1021
1003
  });
1022
1004
  }
1023
- /** The core reports failures as `error:`-prefixed strings; bpg throws. */
1024
- throwOnError(out) {
1025
- if (out.startsWith("error:")) {
1026
- throw new Error(out.slice("error:".length).trim());
1027
- }
1028
- }
1029
1005
  };
1030
1006
  function extractHtmlTables(html) {
1031
1007
  const tables = [];
@@ -1062,7 +1038,6 @@ function extractHtmlTables(html) {
1062
1038
  }
1063
1039
  function bitmarkTextParse(text) {
1064
1040
  const out = getLegacyWasm().convert_text(text, "textToAst", "bitmark++", "body");
1065
- if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1066
1041
  return JSON.parse(out);
1067
1042
  }
1068
1043
 
@@ -1392,11 +1367,6 @@ function patchEntry(path2, op, value) {
1392
1367
  var ALL_LANGUAGES = "all";
1393
1368
 
1394
1369
  // src/core/api.ts
1395
- function lex(input, options = {}) {
1396
- const wasm = getActive();
1397
- if (typeof wasm.lex !== "function") throw new UnsupportedFeatureError("lex", variant());
1398
- return wasm.lex(input, options.stage ?? "lex");
1399
- }
1400
1370
  function bitmarkToObjects(input, options = {}) {
1401
1371
  const out = getActive().convert(
1402
1372
  input,
@@ -1407,9 +1377,10 @@ function bitmarkToObjects(input, options = {}) {
1407
1377
  2,
1408
1378
  1,
1409
1379
  options.includeUnknownProperties ?? false,
1410
- false
1380
+ false,
1381
+ "",
1382
+ ""
1411
1383
  );
1412
- if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1413
1384
  return JSON.parse(out);
1414
1385
  }
1415
1386
  function objectsToBitmark(bits, options = {}) {
@@ -1425,9 +1396,10 @@ function objectsToBitmark(bits, options = {}) {
1425
1396
  2,
1426
1397
  1,
1427
1398
  false,
1428
- false
1399
+ false,
1400
+ "",
1401
+ ""
1429
1402
  );
1430
- if (out.startsWith("error:")) throw new Error(out.slice("error:".length).trim());
1431
1403
  return out;
1432
1404
  }
1433
1405
  function convert(input, options = {}) {
@@ -1440,7 +1412,19 @@ function convert(input, options = {}) {
1440
1412
  options.indent ?? 2,
1441
1413
  options.spacesAroundValues ?? 1,
1442
1414
  options.includeUnknownProperties ?? false,
1443
- options.mappingReport ?? false
1415
+ options.mappingReport ?? false,
1416
+ options.positionEncoding ?? "",
1417
+ options.tokensLayout ?? ""
1418
+ );
1419
+ }
1420
+ function semanticTokens(input, options = {}) {
1421
+ return JSON.parse(
1422
+ convert(input, {
1423
+ inputFormat: "bitmark",
1424
+ outputFormat: "semantic-tokens",
1425
+ positionEncoding: options.positionEncoding,
1426
+ tokensLayout: options.tokensLayout
1427
+ })
1444
1428
  );
1445
1429
  }
1446
1430
  function canonicalize(input, options = {}) {
@@ -1454,9 +1438,7 @@ function canonicalize(input, options = {}) {
1454
1438
  );
1455
1439
  }
1456
1440
  function countBits(input) {
1457
- const out = getActive().count_bits(input);
1458
- if (out.startsWith("error:")) throw new Error(out);
1459
- return Number.parseInt(out, 10);
1441
+ return Number.parseInt(getActive().count_bits(input), 10);
1460
1442
  }
1461
1443
  function splitBits(input) {
1462
1444
  return JSON.parse(getActive().split_bits(input));
@@ -1478,6 +1460,25 @@ function transform(input, options = {}) {
1478
1460
  options.spacesAroundValues ?? 1
1479
1461
  );
1480
1462
  }
1463
+ function diff(a, b, options = {}) {
1464
+ const wasm = getActive();
1465
+ if (typeof wasm.diff !== "function") throw new UnsupportedFeatureError("diff", variant());
1466
+ const out = wasm.diff(
1467
+ a,
1468
+ b,
1469
+ options.inputFormat ?? "auto",
1470
+ options.outputFormat ?? "bitmark",
1471
+ options.context ?? 3,
1472
+ options.locate ?? false,
1473
+ options.similarity ?? 0.6,
1474
+ options.bboxTolerance ?? 8,
1475
+ options.spacesAroundValues ?? 0
1476
+ );
1477
+ return out;
1478
+ }
1479
+ function diffBits(a, b, options = {}) {
1480
+ return JSON.parse(diff(a, b, { ...options, outputFormat: "json" }));
1481
+ }
1481
1482
  function breakscapeText(input, options = {}) {
1482
1483
  const format = options.format ?? "bitmark++";
1483
1484
  const location = options.location ?? "body";
@@ -1498,7 +1499,11 @@ function info(options = {}) {
1498
1499
  const onlyDeprecated = options.onlyDeprecated ?? false;
1499
1500
  const full = options.full ?? false;
1500
1501
  const language = typeof options.language === "string" ? options.language : options.language?.join(",") ?? "";
1501
- return getActive().info(
1502
+ const wasm = getActive();
1503
+ if (format !== "json" && typeof wasm.info_text_supported !== "function") {
1504
+ throw new UnsupportedFeatureError('info (format: "text")', variant());
1505
+ }
1506
+ return wasm.info(
1502
1507
  infoType,
1503
1508
  format,
1504
1509
  bit,
@@ -1511,8 +1516,11 @@ function info(options = {}) {
1511
1516
  );
1512
1517
  }
1513
1518
  function register(options) {
1514
- const result = getActive().register(options.type, options.data);
1515
- if (result) throw new RegisterError(result.replace(/^error:\s*/, ""));
1519
+ try {
1520
+ getActive().register(options.type, options.data);
1521
+ } catch (e) {
1522
+ throw new RegisterError(e instanceof Error ? e.message : String(e));
1523
+ }
1516
1524
  rememberRegistration(options.type, options.data);
1517
1525
  }
1518
1526
 
@@ -1555,14 +1563,16 @@ export {
1555
1563
  canonicalize,
1556
1564
  convert,
1557
1565
  countBits,
1566
+ diff,
1567
+ diffBits,
1558
1568
  info,
1559
1569
  init,
1560
1570
  initSync,
1561
1571
  legacy_exports as legacy,
1562
- lex,
1563
1572
  objectsToBitmark,
1564
1573
  patchEntry,
1565
1574
  register,
1575
+ semanticTokens,
1566
1576
  splitBits,
1567
1577
  transform,
1568
1578
  transformParallel,