@gmb/bitmark-parser 7.6.0 → 7.8.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 (43) hide show
  1. package/README.md +63 -1
  2. package/config/bitmark.json +2 -2
  3. package/dist/browser/bitmark-parser.min.js +6 -6
  4. package/dist/browser/bitmark-parser.min.js.map +1 -1
  5. package/dist/browser/cjs/index.cjs +675 -241
  6. package/dist/browser/cjs/index.cjs.map +1 -1
  7. package/dist/browser/cjs/index.d.cts +117 -7
  8. package/dist/browser/esm/index.d.ts +117 -7
  9. package/dist/browser/esm/index.js +674 -241
  10. package/dist/browser/esm/index.js.map +1 -1
  11. package/dist/browser/esm/worker-entry.js +626 -233
  12. package/dist/browser/esm/worker-entry.js.map +1 -1
  13. package/dist/browser/wasm/bitmark_browser_full_wasm_bg.wasm +0 -0
  14. package/dist/browser/wasm/bitmark_json_wasm_bg.wasm +0 -0
  15. package/dist/browser/wasm/bitmark_wasm_bg.wasm +0 -0
  16. package/dist/index.cjs +45 -4
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +117 -7
  19. package/dist/index.d.ts +117 -7
  20. package/dist/index.js +44 -4
  21. package/dist/index.js.map +1 -1
  22. package/dist/legacy.cjs +1 -1
  23. package/dist/legacy.cjs.map +1 -1
  24. package/dist/legacy.js +1 -1
  25. package/dist/legacy.js.map +1 -1
  26. package/dist/worker-entry.cjs.map +1 -1
  27. package/package.json +7 -7
  28. package/schema/bitmark.schema.json +1 -1
  29. package/wasm/bitmark_wasm.d.ts +65 -31
  30. package/wasm/bitmark_wasm.js +288 -122
  31. package/wasm/bitmark_wasm_bg.wasm +0 -0
  32. package/wasm/bitmark_wasm_bg.wasm.d.ts +6 -1
  33. package/wasm/package.json +1 -1
  34. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +72 -38
  35. package/wasm-bitmark-json/bitmark_json_wasm.js +301 -135
  36. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  37. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm.d.ts +6 -1
  38. package/wasm-bitmark-json/package.json +1 -1
  39. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +65 -31
  40. package/wasm-browser-full/bitmark_browser_full_wasm.js +288 -122
  41. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
  42. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm.d.ts +6 -1
  43. package/wasm-browser-full/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -43,6 +43,7 @@ __export(src_exports, {
43
43
  canonicalize: () => canonicalize,
44
44
  complete: () => complete,
45
45
  convert: () => convert,
46
+ convertWithDetails: () => convertWithDetails,
46
47
  countBits: () => countBits,
47
48
  diagnostics: () => diagnostics,
48
49
  diff: () => diff,
@@ -76,7 +77,7 @@ var import_node_module = require("module");
76
77
  // src/generated/package_info.ts
77
78
  var PACKAGE_INFO = {
78
79
  "name": "@gmb/bitmark-parser",
79
- "version": "7.6.0",
80
+ "version": "7.8.0",
80
81
  "author": "Get More Brain Ltd <info@getmorebrain.com>",
81
82
  "license": "ISC",
82
83
  "description": "A parser for bitmark text, powered by WebAssembly."
@@ -158,7 +159,7 @@ function patchJsonOf(patch) {
158
159
  }
159
160
  function buildUnits(wasm, input, inputIsBitmark) {
160
161
  if (inputIsBitmark) {
161
- const slices = JSON.parse(wasm.split_bits(input));
162
+ const slices = JSON.parse(wasm.split_bits(input, "utf-8"));
162
163
  return slices.map((s) => ({
163
164
  view: { format: "bitmark", index: s.index, total: slices.length, source: s.source },
164
165
  source: s.source
@@ -1538,6 +1539,45 @@ function convert(input, options = {}) {
1538
1539
  options.tokensLayout ?? ""
1539
1540
  );
1540
1541
  }
1542
+ function convertWithDetails(input, options = {}) {
1543
+ const details = getActive().convert_with_details(
1544
+ input,
1545
+ options.inputFormat ?? "auto",
1546
+ options.outputFormat ?? "auto",
1547
+ options.mode ?? "optimized",
1548
+ options.pretty ?? false,
1549
+ options.indent ?? 2,
1550
+ options.spacesAroundValues ?? 1,
1551
+ options.includeUnknownProperties ?? false,
1552
+ options.mappingReport ?? false,
1553
+ options.positionEncoding ?? "",
1554
+ options.tokensLayout ?? "",
1555
+ options.bitSpans ?? false
1556
+ );
1557
+ try {
1558
+ const result = { output: details.take_data() };
1559
+ const flat = details.bit_spans();
1560
+ if (flat !== void 0) {
1561
+ const spans = new Array(flat.length / 5);
1562
+ for (let i = 0, j = 0; j < flat.length; i++, j += 5) {
1563
+ spans[i] = {
1564
+ index: flat[j],
1565
+ inputStart: flat[j + 1],
1566
+ inputEnd: flat[j + 2],
1567
+ outputStart: flat[j + 3],
1568
+ outputEnd: flat[j + 4]
1569
+ };
1570
+ }
1571
+ result.bitSpans = {
1572
+ positionEncoding: details.bit_spans_encoding(),
1573
+ spans
1574
+ };
1575
+ }
1576
+ return result;
1577
+ } finally {
1578
+ details.free();
1579
+ }
1580
+ }
1541
1581
  function semanticTokens(input, options = {}) {
1542
1582
  return JSON.parse(
1543
1583
  convert(input, {
@@ -1607,8 +1647,8 @@ function canonicalize(input, options = {}) {
1607
1647
  function countBits(input) {
1608
1648
  return Number.parseInt(getActive().count_bits(input), 10);
1609
1649
  }
1610
- function splitBits(input) {
1611
- return JSON.parse(getActive().split_bits(input));
1650
+ function splitBits(input, options = {}) {
1651
+ return JSON.parse(getActive().split_bits(input, options.positionEncoding ?? ""));
1612
1652
  }
1613
1653
  function transform(input, options = {}) {
1614
1654
  const wasm = getActive();
@@ -1741,6 +1781,7 @@ function transformParallel(input, options = {}) {
1741
1781
  canonicalize,
1742
1782
  complete,
1743
1783
  convert,
1784
+ convertWithDetails,
1744
1785
  countBits,
1745
1786
  diagnostics,
1746
1787
  diff,