@gmb/bitmark-parser 7.7.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 (40) hide show
  1. package/README.md +26 -17
  2. package/config/bitmark.json +2 -2
  3. package/dist/browser/bitmark-parser.min.js +4 -4
  4. package/dist/browser/bitmark-parser.min.js.map +1 -1
  5. package/dist/browser/cjs/index.cjs +16 -10
  6. package/dist/browser/cjs/index.cjs.map +1 -1
  7. package/dist/browser/cjs/index.d.cts +30 -17
  8. package/dist/browser/esm/index.d.ts +30 -17
  9. package/dist/browser/esm/index.js +16 -10
  10. package/dist/browser/esm/index.js.map +1 -1
  11. package/dist/browser/esm/worker-entry.js +6 -6
  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 +10 -4
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +30 -17
  19. package/dist/index.d.ts +30 -17
  20. package/dist/index.js +10 -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 +6 -6
  28. package/schema/bitmark.schema.json +1 -1
  29. package/wasm/bitmark_wasm.d.ts +2 -2
  30. package/wasm/bitmark_wasm.js +2 -2
  31. package/wasm/bitmark_wasm_bg.wasm +0 -0
  32. package/wasm/package.json +1 -1
  33. package/wasm-bitmark-json/bitmark_json_wasm.d.ts +2 -2
  34. package/wasm-bitmark-json/bitmark_json_wasm.js +2 -2
  35. package/wasm-bitmark-json/bitmark_json_wasm_bg.wasm +0 -0
  36. package/wasm-bitmark-json/package.json +1 -1
  37. package/wasm-browser-full/bitmark_browser_full_wasm.d.ts +2 -2
  38. package/wasm-browser-full/bitmark_browser_full_wasm.js +2 -2
  39. package/wasm-browser-full/bitmark_browser_full_wasm_bg.wasm +0 -0
  40. package/wasm-browser-full/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -14799,30 +14799,42 @@ interface SemanticTokensOptions {
14799
14799
  tokensLayout?: TokensLayout;
14800
14800
  }
14801
14801
 
14802
- /** Where one top-level bit's text is in an output. */
14802
+ /** Where one top-level bit's text is in the input and in the output. */
14803
14803
  interface BitSpan {
14804
14804
  /**
14805
14805
  * The bit's position in the INPUT: its {@link splitBits} index for bitmark
14806
- * input, its entry index in the top-level array for JSON input. An entry
14807
- * that is not a bit gets no span, so the indexes can have gaps.
14806
+ * input, its entry index in the top-level array for JSON input, its
14807
+ * position among the bits the import finds for markup input. An entry that
14808
+ * is not a bit gets no span, so the indexes can have gaps.
14808
14809
  */
14809
14810
  index: number;
14811
+ /**
14812
+ * Offset of the bit's first character in the input: for bitmark, its
14813
+ * {@link splitBits} `start`; for JSON, the start of its top-level entry;
14814
+ * for markup, the start of the element it was read from.
14815
+ */
14816
+ inputStart: number;
14817
+ /**
14818
+ * Offset just past its last character in the input. A markup element that
14819
+ * holds the next bit's element ends where that element starts.
14820
+ */
14821
+ inputEnd: number;
14810
14822
  /** Offset of the bit's first character in the output. */
14811
- start: number;
14823
+ outputStart: number;
14812
14824
  /**
14813
- * Offset just past its last character. A bit that produced no output
14814
- * (e.g. an empty bit in `"text"` output) has `end === start`, at the point
14815
- * where its output would begin.
14825
+ * Offset just past its last character in the output. A bit that produced
14826
+ * no output (e.g. an empty bit in `"text"` output) has
14827
+ * `outputEnd === outputStart`, at the point where its output would begin.
14816
14828
  */
14817
- end: number;
14829
+ outputEnd: number;
14818
14830
  }
14819
14831
  /**
14820
- * The bit spans of one output, in the encoding their offsets are counted in
14832
+ * The bit spans of one conversion, in the encoding their offsets are counted in
14821
14833
  * — echoed, as {@link Diagnostics} and {@link SemanticTokens} echo theirs.
14822
14834
  */
14823
14835
  interface BitSpans {
14824
14836
  positionEncoding: PositionEncoding;
14825
- /** In output order; they never overlap. */
14837
+ /** In output order; they never overlap, on either side. */
14826
14838
  spans: BitSpan[];
14827
14839
  }
14828
14840
  /** Options for {@link convertWithDetails}: {@link ConvertOptions} plus one
@@ -14841,7 +14853,7 @@ interface ConvertResult {
14841
14853
  /** The converted output — exactly what {@link convert} returns. */
14842
14854
  output: string;
14843
14855
  /**
14844
- * Where each top-level bit landed in `output`. Present whenever `bitSpans`
14856
+ * Where each top-level bit is in the input and in `output`. Present whenever `bitSpans`
14845
14857
  * was asked for; `spans` is empty for an output that is not a document
14846
14858
  * (`"lex"`, `"ast"`, `"semantic-tokens"`, `"diagnostics"`, a mapping
14847
14859
  * report).
@@ -17580,15 +17592,16 @@ declare function objectsToBitmark(bits: readonly (Bit | AnyBit | BitEntry)[], op
17580
17592
  declare function convert(input: string, options?: ConvertOptions$1): string;
17581
17593
  /**
17582
17594
  * {@link convert}, returning the output together with the extras asked for
17583
- * (PLAN-221) — today `bitSpans`: where each top-level bit's text landed in
17584
- * the output, for linking a source pane to an output pane bit by bit. The
17595
+ * (PLAN-221) — today `bitSpans`: where each top-level bit's text is in the
17596
+ * input and in the output (PLAN-223), for linking the panes that show them
17597
+ * bit by bit. The
17585
17598
  * conversion runs once; `output` is exactly what {@link convert} returns for
17586
17599
  * the same input and options, and it throws exactly as {@link convert} does.
17587
17600
  *
17588
17601
  * Spans are reported for the document outputs — `"bitmark"`, `"json"`
17589
17602
  * (compact or pretty), `"text"` and the markup formats (`"html"`, `"xml"`,
17590
- * …). A span covers the bit's text only: never the separators between bits,
17591
- * nor the JSON array's `[` / `]`.
17603
+ * …), from any input format. A span covers the bit's text only, on either
17604
+ * side: never the separators between bits, nor the JSON array's `[` / `]`.
17592
17605
  *
17593
17606
  * @example
17594
17607
  * const { output, bitSpans } = convertWithDetails(source, {
@@ -17596,8 +17609,8 @@ declare function convert(input: string, options?: ConvertOptions$1): string;
17596
17609
  * outputFormat: "html",
17597
17610
  * bitSpans: true,
17598
17611
  * });
17599
- * for (const { index, start, end } of bitSpans!.spans) {
17600
- * console.log(index, output.slice(start, end));
17612
+ * for (const { index, inputStart, inputEnd, outputStart, outputEnd } of bitSpans!.spans) {
17613
+ * console.log(index, source.slice(inputStart, inputEnd), output.slice(outputStart, outputEnd));
17601
17614
  * }
17602
17615
  *
17603
17616
  * @param input - Bitmark, JSON, or mapped-format input text.
package/dist/index.d.ts CHANGED
@@ -14799,30 +14799,42 @@ interface SemanticTokensOptions {
14799
14799
  tokensLayout?: TokensLayout;
14800
14800
  }
14801
14801
 
14802
- /** Where one top-level bit's text is in an output. */
14802
+ /** Where one top-level bit's text is in the input and in the output. */
14803
14803
  interface BitSpan {
14804
14804
  /**
14805
14805
  * The bit's position in the INPUT: its {@link splitBits} index for bitmark
14806
- * input, its entry index in the top-level array for JSON input. An entry
14807
- * that is not a bit gets no span, so the indexes can have gaps.
14806
+ * input, its entry index in the top-level array for JSON input, its
14807
+ * position among the bits the import finds for markup input. An entry that
14808
+ * is not a bit gets no span, so the indexes can have gaps.
14808
14809
  */
14809
14810
  index: number;
14811
+ /**
14812
+ * Offset of the bit's first character in the input: for bitmark, its
14813
+ * {@link splitBits} `start`; for JSON, the start of its top-level entry;
14814
+ * for markup, the start of the element it was read from.
14815
+ */
14816
+ inputStart: number;
14817
+ /**
14818
+ * Offset just past its last character in the input. A markup element that
14819
+ * holds the next bit's element ends where that element starts.
14820
+ */
14821
+ inputEnd: number;
14810
14822
  /** Offset of the bit's first character in the output. */
14811
- start: number;
14823
+ outputStart: number;
14812
14824
  /**
14813
- * Offset just past its last character. A bit that produced no output
14814
- * (e.g. an empty bit in `"text"` output) has `end === start`, at the point
14815
- * where its output would begin.
14825
+ * Offset just past its last character in the output. A bit that produced
14826
+ * no output (e.g. an empty bit in `"text"` output) has
14827
+ * `outputEnd === outputStart`, at the point where its output would begin.
14816
14828
  */
14817
- end: number;
14829
+ outputEnd: number;
14818
14830
  }
14819
14831
  /**
14820
- * The bit spans of one output, in the encoding their offsets are counted in
14832
+ * The bit spans of one conversion, in the encoding their offsets are counted in
14821
14833
  * — echoed, as {@link Diagnostics} and {@link SemanticTokens} echo theirs.
14822
14834
  */
14823
14835
  interface BitSpans {
14824
14836
  positionEncoding: PositionEncoding;
14825
- /** In output order; they never overlap. */
14837
+ /** In output order; they never overlap, on either side. */
14826
14838
  spans: BitSpan[];
14827
14839
  }
14828
14840
  /** Options for {@link convertWithDetails}: {@link ConvertOptions} plus one
@@ -14841,7 +14853,7 @@ interface ConvertResult {
14841
14853
  /** The converted output — exactly what {@link convert} returns. */
14842
14854
  output: string;
14843
14855
  /**
14844
- * Where each top-level bit landed in `output`. Present whenever `bitSpans`
14856
+ * Where each top-level bit is in the input and in `output`. Present whenever `bitSpans`
14845
14857
  * was asked for; `spans` is empty for an output that is not a document
14846
14858
  * (`"lex"`, `"ast"`, `"semantic-tokens"`, `"diagnostics"`, a mapping
14847
14859
  * report).
@@ -17580,15 +17592,16 @@ declare function objectsToBitmark(bits: readonly (Bit | AnyBit | BitEntry)[], op
17580
17592
  declare function convert(input: string, options?: ConvertOptions$1): string;
17581
17593
  /**
17582
17594
  * {@link convert}, returning the output together with the extras asked for
17583
- * (PLAN-221) — today `bitSpans`: where each top-level bit's text landed in
17584
- * the output, for linking a source pane to an output pane bit by bit. The
17595
+ * (PLAN-221) — today `bitSpans`: where each top-level bit's text is in the
17596
+ * input and in the output (PLAN-223), for linking the panes that show them
17597
+ * bit by bit. The
17585
17598
  * conversion runs once; `output` is exactly what {@link convert} returns for
17586
17599
  * the same input and options, and it throws exactly as {@link convert} does.
17587
17600
  *
17588
17601
  * Spans are reported for the document outputs — `"bitmark"`, `"json"`
17589
17602
  * (compact or pretty), `"text"` and the markup formats (`"html"`, `"xml"`,
17590
- * …). A span covers the bit's text only: never the separators between bits,
17591
- * nor the JSON array's `[` / `]`.
17603
+ * …), from any input format. A span covers the bit's text only, on either
17604
+ * side: never the separators between bits, nor the JSON array's `[` / `]`.
17592
17605
  *
17593
17606
  * @example
17594
17607
  * const { output, bitSpans } = convertWithDetails(source, {
@@ -17596,8 +17609,8 @@ declare function convert(input: string, options?: ConvertOptions$1): string;
17596
17609
  * outputFormat: "html",
17597
17610
  * bitSpans: true,
17598
17611
  * });
17599
- * for (const { index, start, end } of bitSpans!.spans) {
17600
- * console.log(index, output.slice(start, end));
17612
+ * for (const { index, inputStart, inputEnd, outputStart, outputEnd } of bitSpans!.spans) {
17613
+ * console.log(index, source.slice(inputStart, inputEnd), output.slice(outputStart, outputEnd));
17601
17614
  * }
17602
17615
  *
17603
17616
  * @param input - Bitmark, JSON, or mapped-format input text.
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": "7.7.0",
13
+ "version": "7.8.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."
@@ -1491,9 +1491,15 @@ function convertWithDetails(input, options = {}) {
1491
1491
  const result = { output: details.take_data() };
1492
1492
  const flat = details.bit_spans();
1493
1493
  if (flat !== void 0) {
1494
- const spans = new Array(flat.length / 3);
1495
- for (let i = 0, j = 0; j < flat.length; i++, j += 3) {
1496
- spans[i] = { index: flat[j], start: flat[j + 1], end: flat[j + 2] };
1494
+ const spans = new Array(flat.length / 5);
1495
+ for (let i = 0, j = 0; j < flat.length; i++, j += 5) {
1496
+ spans[i] = {
1497
+ index: flat[j],
1498
+ inputStart: flat[j + 1],
1499
+ inputEnd: flat[j + 2],
1500
+ outputStart: flat[j + 3],
1501
+ outputEnd: flat[j + 4]
1502
+ };
1497
1503
  }
1498
1504
  result.bitSpans = {
1499
1505
  positionEncoding: details.bit_spans_encoding(),