@nldd/design-system 0.11.0 → 0.12.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 (142) hide show
  1. package/custom-elements.json +2188 -621
  2. package/dist/components/components.js +2475 -1602
  3. package/dist/components/content/code-viewer/code-viewer.d.ts +14 -1
  4. package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
  5. package/dist/components/content/code-viewer/code-viewer.diff.d.ts +40 -0
  6. package/dist/components/content/code-viewer/code-viewer.diff.d.ts.map +1 -0
  7. package/dist/components/content/code-viewer/code-viewer.diff.js +261 -0
  8. package/dist/components/content/code-viewer/code-viewer.diff.js.map +1 -0
  9. package/dist/components/content/code-viewer/code-viewer.i18n.d.ts +5 -0
  10. package/dist/components/content/code-viewer/code-viewer.i18n.d.ts.map +1 -1
  11. package/dist/components/content/code-viewer/code-viewer.i18n.js +9 -0
  12. package/dist/components/content/code-viewer/code-viewer.i18n.js.map +1 -1
  13. package/dist/components/content/code-viewer/code-viewer.js +98 -6
  14. package/dist/components/content/code-viewer/code-viewer.js.map +1 -1
  15. package/dist/components/content/code-viewer/code-viewer.styles.d.ts.map +1 -1
  16. package/dist/components/content/code-viewer/code-viewer.styles.js +134 -1
  17. package/dist/components/content/code-viewer/code-viewer.styles.js.map +1 -1
  18. package/dist/components/content/code-viewer/code-viewer.template.d.ts.map +1 -1
  19. package/dist/components/content/code-viewer/code-viewer.template.js +5 -4
  20. package/dist/components/content/code-viewer/code-viewer.template.js.map +1 -1
  21. package/dist/components/content/icon/icon-aliases.d.ts.map +1 -1
  22. package/dist/components/content/icon/icon-aliases.js +13 -4
  23. package/dist/components/content/icon/icon-aliases.js.map +1 -1
  24. package/dist/components/content/icon/icon-gallery-status.d.ts.map +1 -1
  25. package/dist/components/content/icon/icon-gallery-status.js +9 -0
  26. package/dist/components/content/icon/icon-gallery-status.js.map +1 -1
  27. package/dist/components/content/icon/icon-registry.d.ts.map +1 -1
  28. package/dist/components/content/icon/icon-registry.js +9 -2
  29. package/dist/components/content/icon/icon-registry.js.map +1 -1
  30. package/dist/components/content/rich-text/rich-text.d.ts +10 -0
  31. package/dist/components/content/rich-text/rich-text.d.ts.map +1 -1
  32. package/dist/components/content/rich-text/rich-text.js +10 -0
  33. package/dist/components/content/rich-text/rich-text.js.map +1 -1
  34. package/dist/components/{dist-Bo5Jeyfn.js → dist-B5E3q-ea.js} +2 -1
  35. package/dist/components/{dist-DbNhCpS5.js → dist-BFw_yEMS.js} +2 -1
  36. package/dist/components/{dist-DnZmcpbQ.js → dist-BNLAXAyO.js} +2 -1
  37. package/dist/components/{dist-DkqAbJH8.js → dist-BOVSVPSz.js} +1 -1
  38. package/dist/components/{dist-Ch3gNAuT.js → dist-BPB3rWnd.js} +2 -1
  39. package/dist/components/{dist-Bud_7w5g.js → dist-BWlUmyq3.js} +34 -2869
  40. package/dist/components/dist-CC8oiVtm.js +366 -0
  41. package/dist/components/dist-COKR0tYU.js +2860 -0
  42. package/dist/components/{dist-CaxHkqR2.js → dist-Co-tsc9S.js} +4 -3
  43. package/dist/components/{dist-iC2RTM0V.js → dist-D_9ZyZ5v.js} +3 -2
  44. package/dist/components/{dist-BB5mlo7D.js → dist-Dn9pjiud.js} +3 -2
  45. package/dist/components/{dist-B2QcygzG.js → dist-Dz28se9B.js} +2 -1
  46. package/dist/components/{dist-CA0yDFIt.js → dist-IPm8ilWf.js} +3 -2
  47. package/dist/components/{icon-zNX9A6d3.js → icon-DFhgRf3P.js} +18 -6
  48. package/dist/components/{icon-button-Cntrg4_E.js → icon-button-Sxkh5cVr.js} +1 -1
  49. package/dist/components/inputs/code-editor/code-editor.d.ts +4 -54
  50. package/dist/components/inputs/code-editor/code-editor.d.ts.map +1 -1
  51. package/dist/components/inputs/code-editor/code-editor.js +22 -262
  52. package/dist/components/inputs/code-editor/code-editor.js.map +1 -1
  53. package/dist/components/inputs/code-editor/code-editor.styles.d.ts.map +1 -1
  54. package/dist/components/inputs/code-editor/code-editor.styles.js +7 -0
  55. package/dist/components/inputs/code-editor/code-editor.styles.js.map +1 -1
  56. package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.d.ts.map +1 -1
  57. package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js +9 -7
  58. package/dist/components/inputs/text-editor/text-editor.annotation-sentinels.js.map +1 -1
  59. package/dist/components/inputs/text-editor/text-editor.annotations.js +1 -1
  60. package/dist/components/inputs/text-editor/text-editor.annotations.js.map +1 -1
  61. package/dist/components/inputs/text-editor/text-editor.clipboard.d.ts +16 -0
  62. package/dist/components/inputs/text-editor/text-editor.clipboard.d.ts.map +1 -0
  63. package/dist/components/inputs/text-editor/text-editor.clipboard.js +50 -0
  64. package/dist/components/inputs/text-editor/text-editor.clipboard.js.map +1 -0
  65. package/dist/components/inputs/text-editor/text-editor.commands.d.ts.map +1 -1
  66. package/dist/components/inputs/text-editor/text-editor.commands.js +31 -58
  67. package/dist/components/inputs/text-editor/text-editor.commands.js.map +1 -1
  68. package/dist/components/inputs/text-editor/text-editor.d.ts +17 -64
  69. package/dist/components/inputs/text-editor/text-editor.d.ts.map +1 -1
  70. package/dist/components/inputs/text-editor/text-editor.drag.d.ts.map +1 -1
  71. package/dist/components/inputs/text-editor/text-editor.drag.js +2 -1
  72. package/dist/components/inputs/text-editor/text-editor.drag.js.map +1 -1
  73. package/dist/components/inputs/text-editor/text-editor.focus-selection.d.ts +3 -0
  74. package/dist/components/inputs/text-editor/text-editor.focus-selection.d.ts.map +1 -0
  75. package/dist/components/inputs/text-editor/text-editor.focus-selection.js +55 -0
  76. package/dist/components/inputs/text-editor/text-editor.focus-selection.js.map +1 -0
  77. package/dist/components/inputs/text-editor/text-editor.hidden-syntax.d.ts +6 -0
  78. package/dist/components/inputs/text-editor/text-editor.hidden-syntax.d.ts.map +1 -0
  79. package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js +257 -0
  80. package/dist/components/inputs/text-editor/text-editor.hidden-syntax.js.map +1 -0
  81. package/dist/components/inputs/text-editor/text-editor.js +93 -313
  82. package/dist/components/inputs/text-editor/text-editor.js.map +1 -1
  83. package/dist/components/inputs/text-editor/text-editor.keymap.d.ts +6 -0
  84. package/dist/components/inputs/text-editor/text-editor.keymap.d.ts.map +1 -0
  85. package/dist/components/inputs/text-editor/text-editor.keymap.js +38 -0
  86. package/dist/components/inputs/text-editor/text-editor.keymap.js.map +1 -0
  87. package/dist/components/inputs/text-editor/text-editor.links.d.ts.map +1 -1
  88. package/dist/components/inputs/text-editor/text-editor.links.js +11 -9
  89. package/dist/components/inputs/text-editor/text-editor.links.js.map +1 -1
  90. package/dist/components/inputs/text-editor/text-editor.markdown.d.ts +1 -17
  91. package/dist/components/inputs/text-editor/text-editor.markdown.d.ts.map +1 -1
  92. package/dist/components/inputs/text-editor/text-editor.markdown.js +26 -186
  93. package/dist/components/inputs/text-editor/text-editor.markdown.js.map +1 -1
  94. package/dist/components/inputs/text-editor/text-editor.mention.d.ts +52 -0
  95. package/dist/components/inputs/text-editor/text-editor.mention.d.ts.map +1 -0
  96. package/dist/components/inputs/text-editor/text-editor.mention.js +186 -0
  97. package/dist/components/inputs/text-editor/text-editor.mention.js.map +1 -0
  98. package/dist/components/inputs/text-editor/text-editor.mentions.d.ts +0 -16
  99. package/dist/components/inputs/text-editor/text-editor.mentions.d.ts.map +1 -1
  100. package/dist/components/inputs/text-editor/text-editor.mentions.js +1 -41
  101. package/dist/components/inputs/text-editor/text-editor.mentions.js.map +1 -1
  102. package/dist/components/inputs/text-editor/text-editor.selection.d.ts +13 -0
  103. package/dist/components/inputs/text-editor/text-editor.selection.d.ts.map +1 -0
  104. package/dist/components/inputs/text-editor/text-editor.selection.js +62 -0
  105. package/dist/components/inputs/text-editor/text-editor.selection.js.map +1 -0
  106. package/dist/components/inputs/text-editor/text-editor.spellcheck.d.ts.map +1 -1
  107. package/dist/components/inputs/text-editor/text-editor.spellcheck.js +4 -6
  108. package/dist/components/inputs/text-editor/text-editor.spellcheck.js.map +1 -1
  109. package/dist/components/inputs/text-editor/text-editor.styles.d.ts.map +1 -1
  110. package/dist/components/inputs/text-editor/text-editor.styles.js +172 -54
  111. package/dist/components/inputs/text-editor/text-editor.styles.js.map +1 -1
  112. package/dist/components/inputs/text-editor/text-editor.syntax.d.ts +22 -0
  113. package/dist/components/inputs/text-editor/text-editor.syntax.d.ts.map +1 -1
  114. package/dist/components/inputs/text-editor/text-editor.syntax.js +44 -0
  115. package/dist/components/inputs/text-editor/text-editor.syntax.js.map +1 -1
  116. package/dist/components/status-and-feedback/notification/notification.d.ts +2 -1
  117. package/dist/components/status-and-feedback/notification/notification.d.ts.map +1 -1
  118. package/dist/components/status-and-feedback/notification/notification.js +5 -2
  119. package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
  120. package/dist/components/status-and-feedback/notification/notification.styles.d.ts.map +1 -1
  121. package/dist/components/status-and-feedback/notification/notification.styles.js +18 -0
  122. package/dist/components/status-and-feedback/notification/notification.styles.js.map +1 -1
  123. package/dist/components/status-and-feedback/notification/notifications-area.d.ts.map +1 -1
  124. package/dist/components/status-and-feedback/notification/notifications-area.js +14 -0
  125. package/dist/components/status-and-feedback/notification/notifications-area.js.map +1 -1
  126. package/dist/css/rich-text.css +61 -1
  127. package/dist/css/themes/donkergeel.css +7 -3
  128. package/dist/css/themes/geel.css +7 -3
  129. package/dist/css/themes.css +14 -6
  130. package/dist/css/variables.css +10 -4
  131. package/dist/nldd.min.js +853 -557
  132. package/dist/translations/en-US.d.ts.map +1 -1
  133. package/dist/translations/en-US.js +5 -0
  134. package/dist/translations/en-US.js.map +1 -1
  135. package/dist/translations/nl.generated.d.ts +5 -0
  136. package/dist/translations/nl.generated.d.ts.map +1 -1
  137. package/dist/types/vue.d.ts +34 -30
  138. package/dist/utilities/codemirror/codemirror-input.d.ts +90 -0
  139. package/dist/utilities/codemirror/codemirror-input.d.ts.map +1 -0
  140. package/dist/utilities/codemirror/codemirror-input.js +250 -0
  141. package/dist/utilities/codemirror/codemirror-input.js.map +1 -0
  142. package/package.json +2 -1
@@ -1,3 +1,4 @@
1
+ import { a as tags, c as NodeProp, f as Parser, g as StyleModule, i as tagHighlighter, l as NodeSet, m as TreeFragment, n as highlightTree, o as DefaultBufferLength, p as Tree, r as styleTags, s as IterMode, u as NodeType } from "./dist-COKR0tYU.js";
1
2
  //#region node_modules/@marijn/find-cluster-break/src/index.js
2
3
  var rangeFrom = [];
3
4
  var rangeTo = [];
@@ -1444,7 +1445,7 @@ var Facet = class Facet {
1444
1445
  Define a new facet.
1445
1446
  */
1446
1447
  static define(config = {}) {
1447
- return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray$1 : (a, b) => a === b), !!config.static, config.enables);
1448
+ return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray : (a, b) => a === b), !!config.static, config.enables);
1448
1449
  }
1449
1450
  /**
1450
1451
  Returns an extension that adds the given value to this facet.
@@ -1478,7 +1479,7 @@ var Facet = class Facet {
1478
1479
  return this.compute([field], (state) => get(state.field(field)));
1479
1480
  }
1480
1481
  };
1481
- function sameArray$1(a, b) {
1482
+ function sameArray(a, b) {
1482
1483
  return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
1483
1484
  }
1484
1485
  var FacetProvider = class {
@@ -1573,7 +1574,7 @@ function dynamicFacetSlot(addresses, facet, providers) {
1573
1574
  reconfigure(state, oldState) {
1574
1575
  let depChanged = ensureAll(state, providerAddrs);
1575
1576
  let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);
1576
- if (oldProviders && !depChanged && sameArray$1(providers, oldProviders)) {
1577
+ if (oldProviders && !depChanged && sameArray(providers, oldProviders)) {
1577
1578
  state.values[idx] = oldValue;
1578
1579
  return 0;
1579
1580
  }
@@ -1799,7 +1800,7 @@ var Configuration = class Configuration {
1799
1800
  let oldProviders = oldFacets && oldFacets[id] || [];
1800
1801
  if (providers.every((p) => p.type == 0)) {
1801
1802
  address[facet.id] = staticValues.length << 1 | 1;
1802
- if (sameArray$1(oldProviders, providers)) staticValues.push(oldState.facet(facet));
1803
+ if (sameArray(oldProviders, providers)) staticValues.push(oldState.facet(facet));
1803
1804
  else {
1804
1805
  let value = facet.combine(providers.map((p) => p.value));
1805
1806
  staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);
@@ -2739,7 +2740,7 @@ var RangeValue = class {
2739
2740
  Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
2740
2741
  */
2741
2742
  range(from, to = from) {
2742
- return Range$1.create(from, to, this);
2743
+ return Range.create(from, to, this);
2743
2744
  }
2744
2745
  };
2745
2746
  RangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;
@@ -2751,7 +2752,7 @@ function cmpVal(a, b) {
2751
2752
  /**
2752
2753
  A range associates a value with a range of positions.
2753
2754
  */
2754
- var Range$1 = class Range$1 {
2755
+ var Range = class Range {
2755
2756
  constructor(from, to, value) {
2756
2757
  this.from = from;
2757
2758
  this.to = to;
@@ -2761,7 +2762,7 @@ var Range$1 = class Range$1 {
2761
2762
  @internal
2762
2763
  */
2763
2764
  static create(from, to, value) {
2764
- return new Range$1(from, to, value);
2765
+ return new Range(from, to, value);
2765
2766
  }
2766
2767
  };
2767
2768
  function cmpRange(a, b) {
@@ -2900,7 +2901,7 @@ var RangeSet = class RangeSet {
2900
2901
  } else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length && (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) && (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) && builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) cur.nextChunk();
2901
2902
  else {
2902
2903
  if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {
2903
- if (!builder.addInner(cur.from, cur.to, cur.value, false)) spill.push(Range$1.create(cur.from, cur.to, cur.value));
2904
+ if (!builder.addInner(cur.from, cur.to, cur.value, false)) spill.push(Range.create(cur.from, cur.to, cur.value));
2904
2905
  }
2905
2906
  cur.next();
2906
2907
  }
@@ -3044,7 +3045,7 @@ var RangeSet = class RangeSet {
3044
3045
  */
3045
3046
  static of(ranges, sort = false) {
3046
3047
  let build = new RangeSetBuilder();
3047
- for (let range of ranges instanceof Range$1 ? [ranges] : sort ? lazySort(ranges) : ranges) build.add(range.from, range.to, range.value);
3048
+ for (let range of ranges instanceof Range ? [ranges] : sort ? lazySort(ranges) : ranges) build.add(range.from, range.to, range.value);
3048
3049
  return build.finish();
3049
3050
  }
3050
3051
  /**
@@ -3483,98 +3484,6 @@ function findColumn(string, col, tabSize, strict) {
3483
3484
  return strict === true ? -1 : string.length;
3484
3485
  }
3485
3486
  //#endregion
3486
- //#region node_modules/style-mod/src/style-mod.js
3487
- var C = "ͼ";
3488
- var COUNT = typeof Symbol == "undefined" ? "__ͼ" : Symbol.for(C);
3489
- var SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
3490
- var top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {};
3491
- var StyleModule = class {
3492
- constructor(spec, options) {
3493
- this.rules = [];
3494
- let { finish } = options || {};
3495
- function splitSelector(selector) {
3496
- return /^@/.test(selector) ? [selector] : selector.split(/,\s*/);
3497
- }
3498
- function render(selectors, spec, target, isKeyframes) {
3499
- let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes";
3500
- if (isAt && spec == null) return target.push(selectors[0] + ";");
3501
- for (let prop in spec) {
3502
- let value = spec[prop];
3503
- if (/&/.test(prop)) render(prop.split(/,\s*/).map((part) => selectors.map((sel) => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)), value, target);
3504
- else if (value && typeof value == "object") {
3505
- if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.");
3506
- render(splitSelector(prop), value, local, keyframes);
3507
- } else if (value != null) local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, (l) => "-" + l.toLowerCase()) + ": " + value + ";");
3508
- }
3509
- if (local.length || keyframes) target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") + " {" + local.join(" ") + "}");
3510
- }
3511
- for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules);
3512
- }
3513
- getRules() {
3514
- return this.rules.join("\n");
3515
- }
3516
- static newName() {
3517
- let id = top[COUNT] || 1;
3518
- top[COUNT] = id + 1;
3519
- return C + id.toString(36);
3520
- }
3521
- static mount(root, modules, options) {
3522
- let set = root[SET], nonce = options && options.nonce;
3523
- if (!set) set = new StyleSet(root, nonce);
3524
- else if (nonce) set.setNonce(nonce);
3525
- set.mount(Array.isArray(modules) ? modules : [modules], root);
3526
- }
3527
- };
3528
- var adoptedSet = /* @__PURE__ */ new Map();
3529
- var StyleSet = class {
3530
- constructor(root, nonce) {
3531
- let doc = root.ownerDocument || root, win = doc.defaultView;
3532
- if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
3533
- let adopted = adoptedSet.get(doc);
3534
- if (adopted) return root[SET] = adopted;
3535
- this.sheet = new win.CSSStyleSheet();
3536
- adoptedSet.set(doc, this);
3537
- } else {
3538
- this.styleTag = doc.createElement("style");
3539
- if (nonce) this.styleTag.setAttribute("nonce", nonce);
3540
- }
3541
- this.modules = [];
3542
- root[SET] = this;
3543
- }
3544
- mount(modules, root) {
3545
- let sheet = this.sheet;
3546
- let pos = 0, j = 0;
3547
- for (let i = 0; i < modules.length; i++) {
3548
- let mod = modules[i], index = this.modules.indexOf(mod);
3549
- if (index < j && index > -1) {
3550
- this.modules.splice(index, 1);
3551
- j--;
3552
- index = -1;
3553
- }
3554
- if (index == -1) {
3555
- this.modules.splice(j++, 0, mod);
3556
- if (sheet) for (let k = 0; k < mod.rules.length; k++) sheet.insertRule(mod.rules[k], pos++);
3557
- } else {
3558
- while (j < index) pos += this.modules[j++].rules.length;
3559
- pos += mod.rules.length;
3560
- j++;
3561
- }
3562
- }
3563
- if (sheet) {
3564
- if (root.adoptedStyleSheets.indexOf(this.sheet) < 0) root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets];
3565
- } else {
3566
- let text = "";
3567
- for (let i = 0; i < this.modules.length; i++) text += this.modules[i].getRules() + "\n";
3568
- this.styleTag.textContent = text;
3569
- let target = root.head || root;
3570
- if (this.styleTag.parentNode != target) target.insertBefore(this.styleTag, target.firstChild);
3571
- }
3572
- }
3573
- setNonce(nonce) {
3574
- if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce) this.styleTag.setAttribute("nonce", nonce);
3575
- }
3576
- };
3577
- //#endregion
3578
3487
  //#region node_modules/w3c-keyname/index.js
3579
3488
  var base = {
3580
3489
  8: "Backspace",
@@ -12252,7 +12161,30 @@ Facet used to add a class to all gutter elements next to a widget.
12252
12161
  Should not provide widgets with a `toDOM` method.
12253
12162
  */
12254
12163
  var gutterWidgetClass = /*@__PURE__*/ Facet.define();
12164
+ var defaults = {
12165
+ class: "",
12166
+ renderEmptyElements: false,
12167
+ elementStyle: "",
12168
+ markers: () => RangeSet.empty,
12169
+ lineMarker: () => null,
12170
+ widgetMarker: () => null,
12171
+ lineMarkerChange: null,
12172
+ initialSpacer: null,
12173
+ updateSpacer: null,
12174
+ domEventHandlers: {},
12175
+ side: "before"
12176
+ };
12255
12177
  var activeGutters = /*@__PURE__*/ Facet.define();
12178
+ /**
12179
+ Define an editor gutter. The order in which the gutters appear is
12180
+ determined by their extension priority.
12181
+ */
12182
+ function gutter(config) {
12183
+ return [gutters(), activeGutters.of({
12184
+ ...defaults,
12185
+ ...config
12186
+ })];
12187
+ }
12256
12188
  var unfixGutters = /*@__PURE__*/ Facet.define({ combine: (values) => values.some((x) => x) });
12257
12189
  /**
12258
12190
  The gutter-drawing plugin is automatically enabled when you add a
@@ -12617,2773 +12549,6 @@ function maxLineNumber(lines) {
12617
12549
  return last;
12618
12550
  }
12619
12551
  //#endregion
12620
- //#region node_modules/@lezer/common/dist/index.js
12621
- /**
12622
- The default maximum length of a `TreeBuffer` node.
12623
- */
12624
- var DefaultBufferLength = 1024;
12625
- var nextPropID = 0;
12626
- var Range = class {
12627
- constructor(from, to) {
12628
- this.from = from;
12629
- this.to = to;
12630
- }
12631
- };
12632
- /**
12633
- Each [node type](#common.NodeType) or [individual tree](#common.Tree)
12634
- can have metadata associated with it in props. Instances of this
12635
- class represent prop names.
12636
- */
12637
- var NodeProp = class {
12638
- /**
12639
- Create a new node prop type.
12640
- */
12641
- constructor(config = {}) {
12642
- this.id = nextPropID++;
12643
- this.perNode = !!config.perNode;
12644
- this.deserialize = config.deserialize || (() => {
12645
- throw new Error("This node type doesn't define a deserialize function");
12646
- });
12647
- this.combine = config.combine || null;
12648
- }
12649
- /**
12650
- This is meant to be used with
12651
- [`NodeSet.extend`](#common.NodeSet.extend) or
12652
- [`LRParser.configure`](#lr.ParserConfig.props) to compute
12653
- prop values for each node type in the set. Takes a [match
12654
- object](#common.NodeType^match) or function that returns undefined
12655
- if the node type doesn't get this prop, and the prop's value if
12656
- it does.
12657
- */
12658
- add(match) {
12659
- if (this.perNode) throw new RangeError("Can't add per-node props to node types");
12660
- if (typeof match != "function") match = NodeType.match(match);
12661
- return (type) => {
12662
- let result = match(type);
12663
- return result === void 0 ? null : [this, result];
12664
- };
12665
- }
12666
- };
12667
- /**
12668
- Prop that is used to describe matching delimiters. For opening
12669
- delimiters, this holds an array of node names (written as a
12670
- space-separated string when declaring this prop in a grammar)
12671
- for the node types of closing delimiters that match it.
12672
- */
12673
- NodeProp.closedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
12674
- /**
12675
- The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
12676
- attached to closing delimiters, holding an array of node names
12677
- of types of matching opening delimiters.
12678
- */
12679
- NodeProp.openedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
12680
- /**
12681
- Used to assign node types to groups (for example, all node
12682
- types that represent an expression could be tagged with an
12683
- `"Expression"` group).
12684
- */
12685
- NodeProp.group = new NodeProp({ deserialize: (str) => str.split(" ") });
12686
- /**
12687
- Attached to nodes to indicate these should be
12688
- [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
12689
- in a bidirectional text isolate, so that direction-neutral
12690
- characters on their sides don't incorrectly get associated with
12691
- surrounding text. You'll generally want to set this for nodes
12692
- that contain arbitrary text, like strings and comments, and for
12693
- nodes that appear _inside_ arbitrary text, like HTML tags. When
12694
- not given a value, in a grammar declaration, defaults to
12695
- `"auto"`.
12696
- */
12697
- NodeProp.isolate = new NodeProp({ deserialize: (value) => {
12698
- if (value && value != "rtl" && value != "ltr" && value != "auto") throw new RangeError("Invalid value for isolate: " + value);
12699
- return value || "auto";
12700
- } });
12701
- /**
12702
- The hash of the [context](#lr.ContextTracker.constructor)
12703
- that the node was parsed in, if any. Used to limit reuse of
12704
- contextual nodes.
12705
- */
12706
- NodeProp.contextHash = new NodeProp({ perNode: true });
12707
- /**
12708
- The distance beyond the end of the node that the tokenizer
12709
- looked ahead for any of the tokens inside the node. (The LR
12710
- parser only stores this when it is larger than 25, for
12711
- efficiency reasons.)
12712
- */
12713
- NodeProp.lookAhead = new NodeProp({ perNode: true });
12714
- /**
12715
- This per-node prop is used to replace a given node, or part of a
12716
- node, with another tree. This is useful to include trees from
12717
- different languages in mixed-language parsers.
12718
- */
12719
- NodeProp.mounted = new NodeProp({ perNode: true });
12720
- /**
12721
- A mounted tree, which can be [stored](#common.NodeProp^mounted) on
12722
- a tree node to indicate that parts of its content are
12723
- represented by another tree.
12724
- */
12725
- var MountedTree = class {
12726
- constructor(tree, overlay, parser, bracketed = false) {
12727
- this.tree = tree;
12728
- this.overlay = overlay;
12729
- this.parser = parser;
12730
- this.bracketed = bracketed;
12731
- }
12732
- /**
12733
- @internal
12734
- */
12735
- static get(tree) {
12736
- return tree && tree.props && tree.props[NodeProp.mounted.id];
12737
- }
12738
- };
12739
- var noProps = Object.create(null);
12740
- /**
12741
- Each node in a syntax tree has a node type associated with it.
12742
- */
12743
- var NodeType = class NodeType {
12744
- /**
12745
- @internal
12746
- */
12747
- constructor(name, props, id, flags = 0) {
12748
- this.name = name;
12749
- this.props = props;
12750
- this.id = id;
12751
- this.flags = flags;
12752
- }
12753
- /**
12754
- Define a node type.
12755
- */
12756
- static define(spec) {
12757
- let props = spec.props && spec.props.length ? Object.create(null) : noProps;
12758
- let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
12759
- let type = new NodeType(spec.name || "", props, spec.id, flags);
12760
- if (spec.props) for (let src of spec.props) {
12761
- if (!Array.isArray(src)) src = src(type);
12762
- if (src) {
12763
- if (src[0].perNode) throw new RangeError("Can't store a per-node prop on a node type");
12764
- props[src[0].id] = src[1];
12765
- }
12766
- }
12767
- return type;
12768
- }
12769
- /**
12770
- Retrieves a node prop for this type. Will return `undefined` if
12771
- the prop isn't present on this node.
12772
- */
12773
- prop(prop) {
12774
- return this.props[prop.id];
12775
- }
12776
- /**
12777
- True when this is the top node of a grammar.
12778
- */
12779
- get isTop() {
12780
- return (this.flags & 1) > 0;
12781
- }
12782
- /**
12783
- True when this node is produced by a skip rule.
12784
- */
12785
- get isSkipped() {
12786
- return (this.flags & 2) > 0;
12787
- }
12788
- /**
12789
- Indicates whether this is an error node.
12790
- */
12791
- get isError() {
12792
- return (this.flags & 4) > 0;
12793
- }
12794
- /**
12795
- When true, this node type doesn't correspond to a user-declared
12796
- named node, for example because it is used to cache repetition.
12797
- */
12798
- get isAnonymous() {
12799
- return (this.flags & 8) > 0;
12800
- }
12801
- /**
12802
- Returns true when this node's name or one of its
12803
- [groups](#common.NodeProp^group) matches the given string.
12804
- */
12805
- is(name) {
12806
- if (typeof name == "string") {
12807
- if (this.name == name) return true;
12808
- let group = this.prop(NodeProp.group);
12809
- return group ? group.indexOf(name) > -1 : false;
12810
- }
12811
- return this.id == name;
12812
- }
12813
- /**
12814
- Create a function from node types to arbitrary values by
12815
- specifying an object whose property names are node or
12816
- [group](#common.NodeProp^group) names. Often useful with
12817
- [`NodeProp.add`](#common.NodeProp.add). You can put multiple
12818
- names, separated by spaces, in a single property name to map
12819
- multiple node names to a single value.
12820
- */
12821
- static match(map) {
12822
- let direct = Object.create(null);
12823
- for (let prop in map) for (let name of prop.split(" ")) direct[name] = map[prop];
12824
- return (node) => {
12825
- for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
12826
- let found = direct[i < 0 ? node.name : groups[i]];
12827
- if (found) return found;
12828
- }
12829
- };
12830
- }
12831
- };
12832
- /**
12833
- An empty dummy node type to use when no actual type is available.
12834
- */
12835
- NodeType.none = new NodeType("", Object.create(null), 0, 8);
12836
- /**
12837
- A node set holds a collection of node types. It is used to
12838
- compactly represent trees by storing their type ids, rather than a
12839
- full pointer to the type object, in a numeric array. Each parser
12840
- [has](#lr.LRParser.nodeSet) a node set, and [tree
12841
- buffers](#common.TreeBuffer) can only store collections of nodes
12842
- from the same set. A set can have a maximum of 2**16 (65536) node
12843
- types in it, so that the ids fit into 16-bit typed array slots.
12844
- */
12845
- var NodeSet = class NodeSet {
12846
- /**
12847
- Create a set with the given types. The `id` property of each
12848
- type should correspond to its position within the array.
12849
- */
12850
- constructor(types) {
12851
- this.types = types;
12852
- for (let i = 0; i < types.length; i++) if (types[i].id != i) throw new RangeError("Node type ids should correspond to array positions when creating a node set");
12853
- }
12854
- /**
12855
- Create a copy of this set with some node properties added. The
12856
- arguments to this method can be created with
12857
- [`NodeProp.add`](#common.NodeProp.add).
12858
- */
12859
- extend(...props) {
12860
- let newTypes = [];
12861
- for (let type of this.types) {
12862
- let newProps = null;
12863
- for (let source of props) {
12864
- let add = source(type);
12865
- if (add) {
12866
- if (!newProps) newProps = Object.assign({}, type.props);
12867
- let value = add[1], prop = add[0];
12868
- if (prop.combine && prop.id in newProps) value = prop.combine(newProps[prop.id], value);
12869
- newProps[prop.id] = value;
12870
- }
12871
- }
12872
- newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
12873
- }
12874
- return new NodeSet(newTypes);
12875
- }
12876
- };
12877
- var CachedNode = /* @__PURE__ */ new WeakMap();
12878
- var CachedInnerNode = /* @__PURE__ */ new WeakMap();
12879
- /**
12880
- Options that control iteration. Can be combined with the `|`
12881
- operator to enable multiple ones.
12882
- */
12883
- var IterMode;
12884
- (function(IterMode) {
12885
- /**
12886
- When enabled, iteration will only visit [`Tree`](#common.Tree)
12887
- objects, not nodes packed into
12888
- [`TreeBuffer`](#common.TreeBuffer)s.
12889
- */
12890
- IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
12891
- /**
12892
- Enable this to make iteration include anonymous nodes (such as
12893
- the nodes that wrap repeated grammar constructs into a balanced
12894
- tree).
12895
- */
12896
- IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
12897
- /**
12898
- By default, regular [mounted](#common.NodeProp^mounted) nodes
12899
- replace their base node in iteration. Enable this to ignore them
12900
- instead.
12901
- */
12902
- IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
12903
- /**
12904
- This option only applies in
12905
- [`enter`](#common.SyntaxNode.enter)-style methods. It tells the
12906
- library to not enter mounted overlays if one covers the given
12907
- position.
12908
- */
12909
- IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
12910
- /**
12911
- When set, positions on the boundary of a mounted overlay tree
12912
- that has its [`bracketed`](#common.NestedParse.bracketed) flag
12913
- set will enter that tree regardless of side. Only supported in
12914
- [`enter`](#common.SyntaxNode.enter), not in cursors.
12915
- */
12916
- IterMode[IterMode["EnterBracketed"] = 16] = "EnterBracketed";
12917
- })(IterMode || (IterMode = {}));
12918
- /**
12919
- A piece of syntax tree. There are two ways to approach these
12920
- trees: the way they are actually stored in memory, and the
12921
- convenient way.
12922
-
12923
- Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
12924
- objects. By packing detail information into `TreeBuffer` leaf
12925
- nodes, the representation is made a lot more memory-efficient.
12926
-
12927
- However, when you want to actually work with tree nodes, this
12928
- representation is very awkward, so most client code will want to
12929
- use the [`TreeCursor`](#common.TreeCursor) or
12930
- [`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
12931
- a view on some part of this data structure, and can be used to
12932
- move around to adjacent nodes.
12933
- */
12934
- var Tree = class Tree {
12935
- /**
12936
- Construct a new tree. See also [`Tree.build`](#common.Tree^build).
12937
- */
12938
- constructor(type, children, positions, length, props) {
12939
- this.type = type;
12940
- this.children = children;
12941
- this.positions = positions;
12942
- this.length = length;
12943
- /**
12944
- @internal
12945
- */
12946
- this.props = null;
12947
- if (props && props.length) {
12948
- this.props = Object.create(null);
12949
- for (let [prop, value] of props) this.props[typeof prop == "number" ? prop : prop.id] = value;
12950
- }
12951
- }
12952
- /**
12953
- @internal
12954
- */
12955
- toString() {
12956
- let mounted = MountedTree.get(this);
12957
- if (mounted && !mounted.overlay) return mounted.tree.toString();
12958
- let children = "";
12959
- for (let ch of this.children) {
12960
- let str = ch.toString();
12961
- if (str) {
12962
- if (children) children += ",";
12963
- children += str;
12964
- }
12965
- }
12966
- return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
12967
- }
12968
- /**
12969
- Get a [tree cursor](#common.TreeCursor) positioned at the top of
12970
- the tree. Mode can be used to [control](#common.IterMode) which
12971
- nodes the cursor visits.
12972
- */
12973
- cursor(mode = 0) {
12974
- return new TreeCursor(this.topNode, mode);
12975
- }
12976
- /**
12977
- Get a [tree cursor](#common.TreeCursor) pointing into this tree
12978
- at the given position and side (see
12979
- [`moveTo`](#common.TreeCursor.moveTo).
12980
- */
12981
- cursorAt(pos, side = 0, mode = 0) {
12982
- let cursor = new TreeCursor(CachedNode.get(this) || this.topNode);
12983
- cursor.moveTo(pos, side);
12984
- CachedNode.set(this, cursor._tree);
12985
- return cursor;
12986
- }
12987
- /**
12988
- Get a [syntax node](#common.SyntaxNode) object for the top of the
12989
- tree.
12990
- */
12991
- get topNode() {
12992
- return new TreeNode(this, 0, 0, null);
12993
- }
12994
- /**
12995
- Get the [syntax node](#common.SyntaxNode) at the given position.
12996
- If `side` is -1, this will move into nodes that end at the
12997
- position. If 1, it'll move into nodes that start at the
12998
- position. With 0, it'll only enter nodes that cover the position
12999
- from both sides.
13000
-
13001
- Note that this will not enter
13002
- [overlays](#common.MountedTree.overlay), and you often want
13003
- [`resolveInner`](#common.Tree.resolveInner) instead.
13004
- */
13005
- resolve(pos, side = 0) {
13006
- let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
13007
- CachedNode.set(this, node);
13008
- return node;
13009
- }
13010
- /**
13011
- Like [`resolve`](#common.Tree.resolve), but will enter
13012
- [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
13013
- pointing into the innermost overlaid tree at the given position
13014
- (with parent links going through all parent structure, including
13015
- the host trees).
13016
- */
13017
- resolveInner(pos, side = 0) {
13018
- let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
13019
- CachedInnerNode.set(this, node);
13020
- return node;
13021
- }
13022
- /**
13023
- In some situations, it can be useful to iterate through all
13024
- nodes around a position, including those in overlays that don't
13025
- directly cover the position. This method gives you an iterator
13026
- that will produce all nodes, from small to big, around the given
13027
- position.
13028
- */
13029
- resolveStack(pos, side = 0) {
13030
- return stackIterator(this, pos, side);
13031
- }
13032
- /**
13033
- Iterate over the tree and its children, calling `enter` for any
13034
- node that touches the `from`/`to` region (if given) before
13035
- running over such a node's children, and `leave` (if given) when
13036
- leaving the node. When `enter` returns `false`, that node will
13037
- not have its children iterated over (or `leave` called).
13038
- */
13039
- iterate(spec) {
13040
- let { enter, leave, from = 0, to = this.length } = spec;
13041
- let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
13042
- for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {
13043
- let entered = false;
13044
- if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
13045
- if (c.firstChild()) continue;
13046
- entered = true;
13047
- }
13048
- for (;;) {
13049
- if (entered && leave && (anon || !c.type.isAnonymous)) leave(c);
13050
- if (c.nextSibling()) break;
13051
- if (!c.parent()) return;
13052
- entered = true;
13053
- }
13054
- }
13055
- }
13056
- /**
13057
- Get the value of the given [node prop](#common.NodeProp) for this
13058
- node. Works with both per-node and per-type props.
13059
- */
13060
- prop(prop) {
13061
- return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
13062
- }
13063
- /**
13064
- Returns the node's [per-node props](#common.NodeProp.perNode) in a
13065
- format that can be passed to the [`Tree`](#common.Tree)
13066
- constructor.
13067
- */
13068
- get propValues() {
13069
- let result = [];
13070
- if (this.props) for (let id in this.props) result.push([+id, this.props[id]]);
13071
- return result;
13072
- }
13073
- /**
13074
- Balance the direct children of this tree, producing a copy of
13075
- which may have children grouped into subtrees with type
13076
- [`NodeType.none`](#common.NodeType^none).
13077
- */
13078
- balance(config = {}) {
13079
- return this.children.length <= 8 ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));
13080
- }
13081
- /**
13082
- Build a tree from a postfix-ordered buffer of node information,
13083
- or a cursor over such a buffer.
13084
- */
13085
- static build(data) {
13086
- return buildTree(data);
13087
- }
13088
- };
13089
- /**
13090
- The empty tree
13091
- */
13092
- Tree.empty = new Tree(NodeType.none, [], [], 0);
13093
- var FlatBufferCursor = class FlatBufferCursor {
13094
- constructor(buffer, index) {
13095
- this.buffer = buffer;
13096
- this.index = index;
13097
- }
13098
- get id() {
13099
- return this.buffer[this.index - 4];
13100
- }
13101
- get start() {
13102
- return this.buffer[this.index - 3];
13103
- }
13104
- get end() {
13105
- return this.buffer[this.index - 2];
13106
- }
13107
- get size() {
13108
- return this.buffer[this.index - 1];
13109
- }
13110
- get pos() {
13111
- return this.index;
13112
- }
13113
- next() {
13114
- this.index -= 4;
13115
- }
13116
- fork() {
13117
- return new FlatBufferCursor(this.buffer, this.index);
13118
- }
13119
- };
13120
- /**
13121
- Tree buffers contain (type, start, end, endIndex) quads for each
13122
- node. In such a buffer, nodes are stored in prefix order (parents
13123
- before children, with the endIndex of the parent indicating which
13124
- children belong to it).
13125
- */
13126
- var TreeBuffer = class TreeBuffer {
13127
- /**
13128
- Create a tree buffer.
13129
- */
13130
- constructor(buffer, length, set) {
13131
- this.buffer = buffer;
13132
- this.length = length;
13133
- this.set = set;
13134
- }
13135
- /**
13136
- @internal
13137
- */
13138
- get type() {
13139
- return NodeType.none;
13140
- }
13141
- /**
13142
- @internal
13143
- */
13144
- toString() {
13145
- let result = [];
13146
- for (let index = 0; index < this.buffer.length;) {
13147
- result.push(this.childString(index));
13148
- index = this.buffer[index + 3];
13149
- }
13150
- return result.join(",");
13151
- }
13152
- /**
13153
- @internal
13154
- */
13155
- childString(index) {
13156
- let id = this.buffer[index], endIndex = this.buffer[index + 3];
13157
- let type = this.set.types[id], result = type.name;
13158
- if (/\W/.test(result) && !type.isError) result = JSON.stringify(result);
13159
- index += 4;
13160
- if (endIndex == index) return result;
13161
- let children = [];
13162
- while (index < endIndex) {
13163
- children.push(this.childString(index));
13164
- index = this.buffer[index + 3];
13165
- }
13166
- return result + "(" + children.join(",") + ")";
13167
- }
13168
- /**
13169
- @internal
13170
- */
13171
- findChild(startIndex, endIndex, dir, pos, side) {
13172
- let { buffer } = this, pick = -1;
13173
- for (let i = startIndex; i != endIndex; i = buffer[i + 3]) if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
13174
- pick = i;
13175
- if (dir > 0) break;
13176
- }
13177
- return pick;
13178
- }
13179
- /**
13180
- @internal
13181
- */
13182
- slice(startI, endI, from) {
13183
- let b = this.buffer;
13184
- let copy = new Uint16Array(endI - startI), len = 0;
13185
- for (let i = startI, j = 0; i < endI;) {
13186
- copy[j++] = b[i++];
13187
- copy[j++] = b[i++] - from;
13188
- let to = copy[j++] = b[i++] - from;
13189
- copy[j++] = b[i++] - startI;
13190
- len = Math.max(len, to);
13191
- }
13192
- return new TreeBuffer(copy, len, this.set);
13193
- }
13194
- };
13195
- function checkSide(side, pos, from, to) {
13196
- switch (side) {
13197
- case -2: return from < pos;
13198
- case -1: return to >= pos && from < pos;
13199
- case 0: return from < pos && to > pos;
13200
- case 1: return from <= pos && to > pos;
13201
- case 2: return to > pos;
13202
- case 4: return true;
13203
- }
13204
- }
13205
- function resolveNode(node, pos, side, overlays) {
13206
- var _a;
13207
- while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
13208
- let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
13209
- if (!parent) return node;
13210
- node = parent;
13211
- }
13212
- let mode = overlays ? 0 : IterMode.IgnoreOverlays;
13213
- if (overlays) {
13214
- for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from) node = parent;
13215
- }
13216
- for (;;) {
13217
- let inner = node.enter(pos, side, mode);
13218
- if (!inner) return node;
13219
- node = inner;
13220
- }
13221
- }
13222
- var BaseNode = class {
13223
- cursor(mode = 0) {
13224
- return new TreeCursor(this, mode);
13225
- }
13226
- getChild(type, before = null, after = null) {
13227
- let r = getChildren(this, type, before, after);
13228
- return r.length ? r[0] : null;
13229
- }
13230
- getChildren(type, before = null, after = null) {
13231
- return getChildren(this, type, before, after);
13232
- }
13233
- resolve(pos, side = 0) {
13234
- return resolveNode(this, pos, side, false);
13235
- }
13236
- resolveInner(pos, side = 0) {
13237
- return resolveNode(this, pos, side, true);
13238
- }
13239
- matchContext(context) {
13240
- return matchNodeContext(this.parent, context);
13241
- }
13242
- enterUnfinishedNodesBefore(pos) {
13243
- let scan = this.childBefore(pos), node = this;
13244
- while (scan) {
13245
- let last = scan.lastChild;
13246
- if (!last || last.to != scan.to) break;
13247
- if (last.type.isError && last.from == last.to) {
13248
- node = scan;
13249
- scan = last.prevSibling;
13250
- } else scan = last;
13251
- }
13252
- return node;
13253
- }
13254
- get node() {
13255
- return this;
13256
- }
13257
- get next() {
13258
- return this.parent;
13259
- }
13260
- };
13261
- var TreeNode = class TreeNode extends BaseNode {
13262
- constructor(_tree, from, index, _parent) {
13263
- super();
13264
- this._tree = _tree;
13265
- this.from = from;
13266
- this.index = index;
13267
- this._parent = _parent;
13268
- }
13269
- get type() {
13270
- return this._tree.type;
13271
- }
13272
- get name() {
13273
- return this._tree.type.name;
13274
- }
13275
- get to() {
13276
- return this.from + this._tree.length;
13277
- }
13278
- nextChild(i, dir, pos, side, mode = 0) {
13279
- for (let parent = this;;) {
13280
- for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
13281
- let next = children[i], start = positions[i] + parent.from, mounted;
13282
- if (!(mode & IterMode.EnterBracketed && next instanceof Tree && (mounted = MountedTree.get(next)) && !mounted.overlay && mounted.bracketed && pos >= start && pos <= start + next.length) && !checkSide(side, pos, start, start + next.length)) continue;
13283
- if (next instanceof TreeBuffer) {
13284
- if (mode & IterMode.ExcludeBuffers) continue;
13285
- let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
13286
- if (index > -1) return new BufferNode(new BufferContext(parent, next, i, start), null, index);
13287
- } else if (mode & IterMode.IncludeAnonymous || !next.type.isAnonymous || hasChild(next)) {
13288
- let mounted;
13289
- if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay) return new TreeNode(mounted.tree, start, i, parent);
13290
- let inner = new TreeNode(next, start, i, parent);
13291
- return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side, mode);
13292
- }
13293
- }
13294
- if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous) return null;
13295
- if (parent.index >= 0) i = parent.index + dir;
13296
- else i = dir < 0 ? -1 : parent._parent._tree.children.length;
13297
- parent = parent._parent;
13298
- if (!parent) return null;
13299
- }
13300
- }
13301
- get firstChild() {
13302
- return this.nextChild(0, 1, 0, 4);
13303
- }
13304
- get lastChild() {
13305
- return this.nextChild(this._tree.children.length - 1, -1, 0, 4);
13306
- }
13307
- childAfter(pos) {
13308
- return this.nextChild(0, 1, pos, 2);
13309
- }
13310
- childBefore(pos) {
13311
- return this.nextChild(this._tree.children.length - 1, -1, pos, -2);
13312
- }
13313
- prop(prop) {
13314
- return this._tree.prop(prop);
13315
- }
13316
- enter(pos, side, mode = 0) {
13317
- let mounted;
13318
- if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
13319
- let rPos = pos - this.from, enterBracketed = mode & IterMode.EnterBracketed && mounted.bracketed;
13320
- for (let { from, to } of mounted.overlay) if ((side > 0 || enterBracketed ? from <= rPos : from < rPos) && (side < 0 || enterBracketed ? to >= rPos : to > rPos)) return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
13321
- }
13322
- return this.nextChild(0, 1, pos, side, mode);
13323
- }
13324
- nextSignificantParent() {
13325
- let val = this;
13326
- while (val.type.isAnonymous && val._parent) val = val._parent;
13327
- return val;
13328
- }
13329
- get parent() {
13330
- return this._parent ? this._parent.nextSignificantParent() : null;
13331
- }
13332
- get nextSibling() {
13333
- return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4) : null;
13334
- }
13335
- get prevSibling() {
13336
- return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4) : null;
13337
- }
13338
- get tree() {
13339
- return this._tree;
13340
- }
13341
- toTree() {
13342
- return this._tree;
13343
- }
13344
- /**
13345
- @internal
13346
- */
13347
- toString() {
13348
- return this._tree.toString();
13349
- }
13350
- };
13351
- function getChildren(node, type, before, after) {
13352
- let cur = node.cursor(), result = [];
13353
- if (!cur.firstChild()) return result;
13354
- if (before != null) for (let found = false; !found;) {
13355
- found = cur.type.is(before);
13356
- if (!cur.nextSibling()) return result;
13357
- }
13358
- for (;;) {
13359
- if (after != null && cur.type.is(after)) return result;
13360
- if (cur.type.is(type)) result.push(cur.node);
13361
- if (!cur.nextSibling()) return after == null ? result : [];
13362
- }
13363
- }
13364
- function matchNodeContext(node, context, i = context.length - 1) {
13365
- for (let p = node; i >= 0; p = p.parent) {
13366
- if (!p) return false;
13367
- if (!p.type.isAnonymous) {
13368
- if (context[i] && context[i] != p.name) return false;
13369
- i--;
13370
- }
13371
- }
13372
- return true;
13373
- }
13374
- var BufferContext = class {
13375
- constructor(parent, buffer, index, start) {
13376
- this.parent = parent;
13377
- this.buffer = buffer;
13378
- this.index = index;
13379
- this.start = start;
13380
- }
13381
- };
13382
- var BufferNode = class BufferNode extends BaseNode {
13383
- get name() {
13384
- return this.type.name;
13385
- }
13386
- get from() {
13387
- return this.context.start + this.context.buffer.buffer[this.index + 1];
13388
- }
13389
- get to() {
13390
- return this.context.start + this.context.buffer.buffer[this.index + 2];
13391
- }
13392
- constructor(context, _parent, index) {
13393
- super();
13394
- this.context = context;
13395
- this._parent = _parent;
13396
- this.index = index;
13397
- this.type = context.buffer.set.types[context.buffer.buffer[index]];
13398
- }
13399
- child(dir, pos, side) {
13400
- let { buffer } = this.context;
13401
- let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
13402
- return index < 0 ? null : new BufferNode(this.context, this, index);
13403
- }
13404
- get firstChild() {
13405
- return this.child(1, 0, 4);
13406
- }
13407
- get lastChild() {
13408
- return this.child(-1, 0, 4);
13409
- }
13410
- childAfter(pos) {
13411
- return this.child(1, pos, 2);
13412
- }
13413
- childBefore(pos) {
13414
- return this.child(-1, pos, -2);
13415
- }
13416
- prop(prop) {
13417
- return this.type.prop(prop);
13418
- }
13419
- enter(pos, side, mode = 0) {
13420
- if (mode & IterMode.ExcludeBuffers) return null;
13421
- let { buffer } = this.context;
13422
- let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
13423
- return index < 0 ? null : new BufferNode(this.context, this, index);
13424
- }
13425
- get parent() {
13426
- return this._parent || this.context.parent.nextSignificantParent();
13427
- }
13428
- externalSibling(dir) {
13429
- return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4);
13430
- }
13431
- get nextSibling() {
13432
- let { buffer } = this.context;
13433
- let after = buffer.buffer[this.index + 3];
13434
- if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length)) return new BufferNode(this.context, this._parent, after);
13435
- return this.externalSibling(1);
13436
- }
13437
- get prevSibling() {
13438
- let { buffer } = this.context;
13439
- let parentStart = this._parent ? this._parent.index + 4 : 0;
13440
- if (this.index == parentStart) return this.externalSibling(-1);
13441
- return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4));
13442
- }
13443
- get tree() {
13444
- return null;
13445
- }
13446
- toTree() {
13447
- let children = [], positions = [];
13448
- let { buffer } = this.context;
13449
- let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
13450
- if (endI > startI) {
13451
- let from = buffer.buffer[this.index + 1];
13452
- children.push(buffer.slice(startI, endI, from));
13453
- positions.push(0);
13454
- }
13455
- return new Tree(this.type, children, positions, this.to - this.from);
13456
- }
13457
- /**
13458
- @internal
13459
- */
13460
- toString() {
13461
- return this.context.buffer.childString(this.index);
13462
- }
13463
- };
13464
- function iterStack(heads) {
13465
- if (!heads.length) return null;
13466
- let pick = 0, picked = heads[0];
13467
- for (let i = 1; i < heads.length; i++) {
13468
- let node = heads[i];
13469
- if (node.from > picked.from || node.to < picked.to) {
13470
- picked = node;
13471
- pick = i;
13472
- }
13473
- }
13474
- let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
13475
- let newHeads = heads.slice();
13476
- if (next) newHeads[pick] = next;
13477
- else newHeads.splice(pick, 1);
13478
- return new StackIterator(newHeads, picked);
13479
- }
13480
- var StackIterator = class {
13481
- constructor(heads, node) {
13482
- this.heads = heads;
13483
- this.node = node;
13484
- }
13485
- get next() {
13486
- return iterStack(this.heads);
13487
- }
13488
- };
13489
- function stackIterator(tree, pos, side) {
13490
- let inner = tree.resolveInner(pos, side), layers = null;
13491
- for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) if (scan.index < 0) {
13492
- let parent = scan.parent;
13493
- (layers || (layers = [inner])).push(parent.resolve(pos, side));
13494
- scan = parent;
13495
- } else {
13496
- let mount = MountedTree.get(scan.tree);
13497
- if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
13498
- let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
13499
- (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
13500
- }
13501
- }
13502
- return layers ? iterStack(layers) : inner;
13503
- }
13504
- /**
13505
- A tree cursor object focuses on a given node in a syntax tree, and
13506
- allows you to move to adjacent nodes.
13507
- */
13508
- var TreeCursor = class {
13509
- /**
13510
- Shorthand for `.type.name`.
13511
- */
13512
- get name() {
13513
- return this.type.name;
13514
- }
13515
- /**
13516
- @internal
13517
- */
13518
- constructor(node, mode = 0) {
13519
- /**
13520
- @internal
13521
- */
13522
- this.buffer = null;
13523
- this.stack = [];
13524
- /**
13525
- @internal
13526
- */
13527
- this.index = 0;
13528
- this.bufferNode = null;
13529
- this.mode = mode & ~IterMode.EnterBracketed;
13530
- if (node instanceof TreeNode) this.yieldNode(node);
13531
- else {
13532
- this._tree = node.context.parent;
13533
- this.buffer = node.context;
13534
- for (let n = node._parent; n; n = n._parent) this.stack.unshift(n.index);
13535
- this.bufferNode = node;
13536
- this.yieldBuf(node.index);
13537
- }
13538
- }
13539
- yieldNode(node) {
13540
- if (!node) return false;
13541
- this._tree = node;
13542
- this.type = node.type;
13543
- this.from = node.from;
13544
- this.to = node.to;
13545
- return true;
13546
- }
13547
- yieldBuf(index, type) {
13548
- this.index = index;
13549
- let { start, buffer } = this.buffer;
13550
- this.type = type || buffer.set.types[buffer.buffer[index]];
13551
- this.from = start + buffer.buffer[index + 1];
13552
- this.to = start + buffer.buffer[index + 2];
13553
- return true;
13554
- }
13555
- /**
13556
- @internal
13557
- */
13558
- yield(node) {
13559
- if (!node) return false;
13560
- if (node instanceof TreeNode) {
13561
- this.buffer = null;
13562
- return this.yieldNode(node);
13563
- }
13564
- this.buffer = node.context;
13565
- return this.yieldBuf(node.index, node.type);
13566
- }
13567
- /**
13568
- @internal
13569
- */
13570
- toString() {
13571
- return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
13572
- }
13573
- /**
13574
- @internal
13575
- */
13576
- enterChild(dir, pos, side) {
13577
- if (!this.buffer) return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
13578
- let { buffer } = this.buffer;
13579
- let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
13580
- if (index < 0) return false;
13581
- this.stack.push(this.index);
13582
- return this.yieldBuf(index);
13583
- }
13584
- /**
13585
- Move the cursor to this node's first child. When this returns
13586
- false, the node has no child, and the cursor has not been moved.
13587
- */
13588
- firstChild() {
13589
- return this.enterChild(1, 0, 4);
13590
- }
13591
- /**
13592
- Move the cursor to this node's last child.
13593
- */
13594
- lastChild() {
13595
- return this.enterChild(-1, 0, 4);
13596
- }
13597
- /**
13598
- Move the cursor to the first child that ends after `pos`.
13599
- */
13600
- childAfter(pos) {
13601
- return this.enterChild(1, pos, 2);
13602
- }
13603
- /**
13604
- Move to the last child that starts before `pos`.
13605
- */
13606
- childBefore(pos) {
13607
- return this.enterChild(-1, pos, -2);
13608
- }
13609
- /**
13610
- Move the cursor to the child around `pos`. If side is -1 the
13611
- child may end at that position, when 1 it may start there. This
13612
- will also enter [overlaid](#common.MountedTree.overlay)
13613
- [mounted](#common.NodeProp^mounted) trees unless `overlays` is
13614
- set to false.
13615
- */
13616
- enter(pos, side, mode = this.mode) {
13617
- if (!this.buffer) return this.yield(this._tree.enter(pos, side, mode));
13618
- return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
13619
- }
13620
- /**
13621
- Move to the node's parent node, if this isn't the top node.
13622
- */
13623
- parent() {
13624
- if (!this.buffer) return this.yieldNode(this.mode & IterMode.IncludeAnonymous ? this._tree._parent : this._tree.parent);
13625
- if (this.stack.length) return this.yieldBuf(this.stack.pop());
13626
- let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
13627
- this.buffer = null;
13628
- return this.yieldNode(parent);
13629
- }
13630
- /**
13631
- @internal
13632
- */
13633
- sibling(dir) {
13634
- if (!this.buffer) return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
13635
- let { buffer } = this.buffer, d = this.stack.length - 1;
13636
- if (dir < 0) {
13637
- let parentStart = d < 0 ? 0 : this.stack[d] + 4;
13638
- if (this.index != parentStart) return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4));
13639
- } else {
13640
- let after = buffer.buffer[this.index + 3];
13641
- if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3])) return this.yieldBuf(after);
13642
- }
13643
- return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
13644
- }
13645
- /**
13646
- Move to this node's next sibling, if any.
13647
- */
13648
- nextSibling() {
13649
- return this.sibling(1);
13650
- }
13651
- /**
13652
- Move to this node's previous sibling, if any.
13653
- */
13654
- prevSibling() {
13655
- return this.sibling(-1);
13656
- }
13657
- atLastNode(dir) {
13658
- let index, parent, { buffer } = this;
13659
- if (buffer) {
13660
- if (dir > 0) {
13661
- if (this.index < buffer.buffer.buffer.length) return false;
13662
- } else for (let i = 0; i < this.index; i++) if (buffer.buffer.buffer[i + 3] < this.index) return false;
13663
- ({index, parent} = buffer);
13664
- } else ({index, _parent: parent} = this._tree);
13665
- for (; parent; {index, _parent: parent} = parent) if (index > -1) for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
13666
- let child = parent._tree.children[i];
13667
- if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child)) return false;
13668
- }
13669
- return true;
13670
- }
13671
- move(dir, enter) {
13672
- if (enter && this.enterChild(dir, 0, 4)) return true;
13673
- for (;;) {
13674
- if (this.sibling(dir)) return true;
13675
- if (this.atLastNode(dir) || !this.parent()) return false;
13676
- }
13677
- }
13678
- /**
13679
- Move to the next node in a
13680
- [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
13681
- traversal, going from a node to its first child or, if the
13682
- current node is empty or `enter` is false, its next sibling or
13683
- the next sibling of the first parent node that has one.
13684
- */
13685
- next(enter = true) {
13686
- return this.move(1, enter);
13687
- }
13688
- /**
13689
- Move to the next node in a last-to-first pre-order traversal. A
13690
- node is followed by its last child or, if it has none, its
13691
- previous sibling or the previous sibling of the first parent
13692
- node that has one.
13693
- */
13694
- prev(enter = true) {
13695
- return this.move(-1, enter);
13696
- }
13697
- /**
13698
- Move the cursor to the innermost node that covers `pos`. If
13699
- `side` is -1, it will enter nodes that end at `pos`. If it is 1,
13700
- it will enter nodes that start at `pos`.
13701
- */
13702
- moveTo(pos, side = 0) {
13703
- while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos)) if (!this.parent()) break;
13704
- while (this.enterChild(1, pos, side));
13705
- return this;
13706
- }
13707
- /**
13708
- Get a [syntax node](#common.SyntaxNode) at the cursor's current
13709
- position.
13710
- */
13711
- get node() {
13712
- if (!this.buffer) return this._tree;
13713
- let cache = this.bufferNode, result = null, depth = 0;
13714
- if (cache && cache.context == this.buffer) scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
13715
- for (let c = cache; c; c = c._parent) if (c.index == index) {
13716
- if (index == this.index) return c;
13717
- result = c;
13718
- depth = d + 1;
13719
- break scan;
13720
- }
13721
- index = this.stack[--d];
13722
- }
13723
- for (let i = depth; i < this.stack.length; i++) result = new BufferNode(this.buffer, result, this.stack[i]);
13724
- return this.bufferNode = new BufferNode(this.buffer, result, this.index);
13725
- }
13726
- /**
13727
- Get the [tree](#common.Tree) that represents the current node, if
13728
- any. Will return null when the node is in a [tree
13729
- buffer](#common.TreeBuffer).
13730
- */
13731
- get tree() {
13732
- return this.buffer ? null : this._tree._tree;
13733
- }
13734
- /**
13735
- Iterate over the current node and all its descendants, calling
13736
- `enter` when entering a node and `leave`, if given, when leaving
13737
- one. When `enter` returns `false`, any children of that node are
13738
- skipped, and `leave` isn't called for it.
13739
- */
13740
- iterate(enter, leave) {
13741
- for (let depth = 0;;) {
13742
- let mustLeave = false;
13743
- if (this.type.isAnonymous || enter(this) !== false) {
13744
- if (this.firstChild()) {
13745
- depth++;
13746
- continue;
13747
- }
13748
- if (!this.type.isAnonymous) mustLeave = true;
13749
- }
13750
- for (;;) {
13751
- if (mustLeave && leave) leave(this);
13752
- mustLeave = this.type.isAnonymous;
13753
- if (!depth) return;
13754
- if (this.nextSibling()) break;
13755
- this.parent();
13756
- depth--;
13757
- mustLeave = true;
13758
- }
13759
- }
13760
- }
13761
- /**
13762
- Test whether the current node matches a given context—a sequence
13763
- of direct parent node names. Empty strings in the context array
13764
- are treated as wildcards.
13765
- */
13766
- matchContext(context) {
13767
- if (!this.buffer) return matchNodeContext(this.node.parent, context);
13768
- let { buffer } = this.buffer, { types } = buffer.set;
13769
- for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
13770
- if (d < 0) return matchNodeContext(this._tree, context, i);
13771
- let type = types[buffer.buffer[this.stack[d]]];
13772
- if (!type.isAnonymous) {
13773
- if (context[i] && context[i] != type.name) return false;
13774
- i--;
13775
- }
13776
- }
13777
- return true;
13778
- }
13779
- };
13780
- function hasChild(tree) {
13781
- return tree.children.some((ch) => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
13782
- }
13783
- function buildTree(data) {
13784
- var _a;
13785
- let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
13786
- let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
13787
- let types = nodeSet.types;
13788
- let contextHash = 0, lookAhead = 0;
13789
- function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {
13790
- let { id, start, end, size } = cursor;
13791
- let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
13792
- if (size < 0) {
13793
- cursor.next();
13794
- if (size == -1) {
13795
- let node = reused[id];
13796
- children.push(node);
13797
- positions.push(start - parentStart);
13798
- return;
13799
- } else if (size == -3) {
13800
- contextHash = id;
13801
- return;
13802
- } else if (size == -4) {
13803
- lookAhead = id;
13804
- return;
13805
- } else throw new RangeError(`Unrecognized record size: ${size}`);
13806
- }
13807
- let type = types[id], node, buffer;
13808
- let startPos = start - parentStart;
13809
- if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
13810
- let data = new Uint16Array(buffer.size - buffer.skip);
13811
- let endPos = cursor.pos - buffer.size, index = data.length;
13812
- while (cursor.pos > endPos) index = copyToBuffer(buffer.start, data, index);
13813
- node = new TreeBuffer(data, end - buffer.start, nodeSet);
13814
- startPos = buffer.start - parentStart;
13815
- } else {
13816
- let endPos = cursor.pos - size;
13817
- cursor.next();
13818
- let localChildren = [], localPositions = [];
13819
- let localInRepeat = id >= minRepeatType ? id : -1;
13820
- let lastGroup = 0, lastEnd = end;
13821
- while (cursor.pos > endPos) if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
13822
- if (cursor.end <= lastEnd - maxBufferLength) {
13823
- makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
13824
- lastGroup = localChildren.length;
13825
- lastEnd = cursor.end;
13826
- }
13827
- cursor.next();
13828
- } else if (depth > 2500) takeFlatNode(start, endPos, localChildren, localPositions);
13829
- else takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
13830
- if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length) makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
13831
- localChildren.reverse();
13832
- localPositions.reverse();
13833
- if (localInRepeat > -1 && lastGroup > 0) {
13834
- let make = makeBalanced(type, contextAtStart);
13835
- node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
13836
- } else node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
13837
- }
13838
- children.push(node);
13839
- positions.push(startPos);
13840
- }
13841
- function takeFlatNode(parentStart, minPos, children, positions) {
13842
- let nodes = [];
13843
- let nodeCount = 0, stopAt = -1;
13844
- while (cursor.pos > minPos) {
13845
- let { id, start, end, size } = cursor;
13846
- if (size > 4) cursor.next();
13847
- else if (stopAt > -1 && start < stopAt) break;
13848
- else {
13849
- if (stopAt < 0) stopAt = end - maxBufferLength;
13850
- nodes.push(id, start, end);
13851
- nodeCount++;
13852
- cursor.next();
13853
- }
13854
- }
13855
- if (nodeCount) {
13856
- let buffer = new Uint16Array(nodeCount * 4);
13857
- let start = nodes[nodes.length - 2];
13858
- for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {
13859
- buffer[j++] = nodes[i];
13860
- buffer[j++] = nodes[i + 1] - start;
13861
- buffer[j++] = nodes[i + 2] - start;
13862
- buffer[j++] = j;
13863
- }
13864
- children.push(new TreeBuffer(buffer, nodes[2] - start, nodeSet));
13865
- positions.push(start - parentStart);
13866
- }
13867
- }
13868
- function makeBalanced(type, contextHash) {
13869
- return (children, positions, length) => {
13870
- let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
13871
- if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {
13872
- if (!lastI && last.type == type && last.length == length) return last;
13873
- if (lookAheadProp = last.prop(NodeProp.lookAhead)) lookAhead = positions[lastI] + last.length + lookAheadProp;
13874
- }
13875
- return makeTree(type, children, positions, length, lookAhead, contextHash);
13876
- };
13877
- }
13878
- function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead, contextHash) {
13879
- let localChildren = [], localPositions = [];
13880
- while (children.length > i) {
13881
- localChildren.push(children.pop());
13882
- localPositions.push(positions.pop() + base - from);
13883
- }
13884
- children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to, contextHash));
13885
- positions.push(from - base);
13886
- }
13887
- function makeTree(type, children, positions, length, lookAhead, contextHash, props) {
13888
- if (contextHash) {
13889
- let pair = [NodeProp.contextHash, contextHash];
13890
- props = props ? [pair].concat(props) : [pair];
13891
- }
13892
- if (lookAhead > 25) {
13893
- let pair = [NodeProp.lookAhead, lookAhead];
13894
- props = props ? [pair].concat(props) : [pair];
13895
- }
13896
- return new Tree(type, children, positions, length, props);
13897
- }
13898
- function findBufferSize(maxSize, inRepeat) {
13899
- let fork = cursor.fork();
13900
- let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
13901
- let result = {
13902
- size: 0,
13903
- start: 0,
13904
- skip: 0
13905
- };
13906
- scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
13907
- let nodeSize = fork.size;
13908
- if (fork.id == inRepeat && nodeSize >= 0) {
13909
- result.size = size;
13910
- result.start = start;
13911
- result.skip = skip;
13912
- skip += 4;
13913
- size += 4;
13914
- fork.next();
13915
- continue;
13916
- }
13917
- let startPos = fork.pos - nodeSize;
13918
- if (nodeSize < 0 || startPos < minPos || fork.start < minStart) break;
13919
- let localSkipped = fork.id >= minRepeatType ? 4 : 0;
13920
- let nodeStart = fork.start;
13921
- fork.next();
13922
- while (fork.pos > startPos) {
13923
- if (fork.size < 0) {
13924
- if (fork.size == -3 || fork.size == -4) localSkipped += 4;
13925
- else break scan;
13926
- } else if (fork.id >= minRepeatType) localSkipped += 4;
13927
- fork.next();
13928
- }
13929
- start = nodeStart;
13930
- size += nodeSize;
13931
- skip += localSkipped;
13932
- }
13933
- if (inRepeat < 0 || size == maxSize) {
13934
- result.size = size;
13935
- result.start = start;
13936
- result.skip = skip;
13937
- }
13938
- return result.size > 4 ? result : void 0;
13939
- }
13940
- function copyToBuffer(bufferStart, buffer, index) {
13941
- let { id, start, end, size } = cursor;
13942
- cursor.next();
13943
- if (size >= 0 && id < minRepeatType) {
13944
- let startIndex = index;
13945
- if (size > 4) {
13946
- let endPos = cursor.pos - (size - 4);
13947
- while (cursor.pos > endPos) index = copyToBuffer(bufferStart, buffer, index);
13948
- }
13949
- buffer[--index] = startIndex;
13950
- buffer[--index] = end - bufferStart;
13951
- buffer[--index] = start - bufferStart;
13952
- buffer[--index] = id;
13953
- } else if (size == -3) contextHash = id;
13954
- else if (size == -4) lookAhead = id;
13955
- return index;
13956
- }
13957
- let children = [], positions = [];
13958
- while (cursor.pos > 0) takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
13959
- let length = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
13960
- return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
13961
- }
13962
- var nodeSizeCache = /* @__PURE__ */ new WeakMap();
13963
- function nodeSize(balanceType, node) {
13964
- if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType) return 1;
13965
- let size = nodeSizeCache.get(node);
13966
- if (size == null) {
13967
- size = 1;
13968
- for (let child of node.children) {
13969
- if (child.type != balanceType || !(child instanceof Tree)) {
13970
- size = 1;
13971
- break;
13972
- }
13973
- size += nodeSize(balanceType, child);
13974
- }
13975
- nodeSizeCache.set(node, size);
13976
- }
13977
- return size;
13978
- }
13979
- function balanceRange(balanceType, children, positions, from, to, start, length, mkTop, mkTree) {
13980
- let total = 0;
13981
- for (let i = from; i < to; i++) total += nodeSize(balanceType, children[i]);
13982
- let maxChild = Math.ceil(total * 1.5 / 8);
13983
- let localChildren = [], localPositions = [];
13984
- function divide(children, positions, from, to, offset) {
13985
- for (let i = from; i < to;) {
13986
- let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);
13987
- i++;
13988
- for (; i < to; i++) {
13989
- let nextSize = nodeSize(balanceType, children[i]);
13990
- if (groupSize + nextSize >= maxChild) break;
13991
- groupSize += nextSize;
13992
- }
13993
- if (i == groupFrom + 1) {
13994
- if (groupSize > maxChild) {
13995
- let only = children[groupFrom];
13996
- divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
13997
- continue;
13998
- }
13999
- localChildren.push(children[groupFrom]);
14000
- } else {
14001
- let length = positions[i - 1] + children[i - 1].length - groupStart;
14002
- localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
14003
- }
14004
- localPositions.push(groupStart + offset - start);
14005
- }
14006
- }
14007
- divide(children, positions, from, to, 0);
14008
- return (mkTop || mkTree)(localChildren, localPositions, length);
14009
- }
14010
- /**
14011
- Provides a way to associate values with pieces of trees. As long
14012
- as that part of the tree is reused, the associated values can be
14013
- retrieved from an updated tree.
14014
- */
14015
- var NodeWeakMap = class {
14016
- constructor() {
14017
- this.map = /* @__PURE__ */ new WeakMap();
14018
- }
14019
- setBuffer(buffer, index, value) {
14020
- let inner = this.map.get(buffer);
14021
- if (!inner) this.map.set(buffer, inner = /* @__PURE__ */ new Map());
14022
- inner.set(index, value);
14023
- }
14024
- getBuffer(buffer, index) {
14025
- let inner = this.map.get(buffer);
14026
- return inner && inner.get(index);
14027
- }
14028
- /**
14029
- Set the value for this syntax node.
14030
- */
14031
- set(node, value) {
14032
- if (node instanceof BufferNode) this.setBuffer(node.context.buffer, node.index, value);
14033
- else if (node instanceof TreeNode) this.map.set(node.tree, value);
14034
- }
14035
- /**
14036
- Retrieve value for this syntax node, if it exists in the map.
14037
- */
14038
- get(node) {
14039
- return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index) : node instanceof TreeNode ? this.map.get(node.tree) : void 0;
14040
- }
14041
- /**
14042
- Set the value for the node that a cursor currently points to.
14043
- */
14044
- cursorSet(cursor, value) {
14045
- if (cursor.buffer) this.setBuffer(cursor.buffer.buffer, cursor.index, value);
14046
- else this.map.set(cursor.tree, value);
14047
- }
14048
- /**
14049
- Retrieve the value for the node that a cursor currently points
14050
- to.
14051
- */
14052
- cursorGet(cursor) {
14053
- return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);
14054
- }
14055
- };
14056
- /**
14057
- Tree fragments are used during [incremental
14058
- parsing](#common.Parser.startParse) to track parts of old trees
14059
- that can be reused in a new parse. An array of fragments is used
14060
- to track regions of an old tree whose nodes might be reused in new
14061
- parses. Use the static
14062
- [`applyChanges`](#common.TreeFragment^applyChanges) method to
14063
- update fragments for document changes.
14064
- */
14065
- var TreeFragment = class TreeFragment {
14066
- /**
14067
- Construct a tree fragment. You'll usually want to use
14068
- [`addTree`](#common.TreeFragment^addTree) and
14069
- [`applyChanges`](#common.TreeFragment^applyChanges) instead of
14070
- calling this directly.
14071
- */
14072
- constructor(from, to, tree, offset, openStart = false, openEnd = false) {
14073
- this.from = from;
14074
- this.to = to;
14075
- this.tree = tree;
14076
- this.offset = offset;
14077
- this.open = (openStart ? 1 : 0) | (openEnd ? 2 : 0);
14078
- }
14079
- /**
14080
- Whether the start of the fragment represents the start of a
14081
- parse, or the end of a change. (In the second case, it may not
14082
- be safe to reuse some nodes at the start, depending on the
14083
- parsing algorithm.)
14084
- */
14085
- get openStart() {
14086
- return (this.open & 1) > 0;
14087
- }
14088
- /**
14089
- Whether the end of the fragment represents the end of a
14090
- full-document parse, or the start of a change.
14091
- */
14092
- get openEnd() {
14093
- return (this.open & 2) > 0;
14094
- }
14095
- /**
14096
- Create a set of fragments from a freshly parsed tree, or update
14097
- an existing set of fragments by replacing the ones that overlap
14098
- with a tree with content from the new tree. When `partial` is
14099
- true, the parse is treated as incomplete, and the resulting
14100
- fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
14101
- true.
14102
- */
14103
- static addTree(tree, fragments = [], partial = false) {
14104
- let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
14105
- for (let f of fragments) if (f.to > tree.length) result.push(f);
14106
- return result;
14107
- }
14108
- /**
14109
- Apply a set of edits to an array of fragments, removing or
14110
- splitting fragments as necessary to remove edited ranges, and
14111
- adjusting offsets for fragments that moved.
14112
- */
14113
- static applyChanges(fragments, changes, minGap = 128) {
14114
- if (!changes.length) return fragments;
14115
- let result = [];
14116
- let fI = 1, nextF = fragments.length ? fragments[0] : null;
14117
- for (let cI = 0, pos = 0, off = 0;; cI++) {
14118
- let nextC = cI < changes.length ? changes[cI] : null;
14119
- let nextPos = nextC ? nextC.fromA : 1e9;
14120
- if (nextPos - pos >= minGap) while (nextF && nextF.from < nextPos) {
14121
- let cut = nextF;
14122
- if (pos >= cut.from || nextPos <= cut.to || off) {
14123
- let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
14124
- cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
14125
- }
14126
- if (cut) result.push(cut);
14127
- if (nextF.to > nextPos) break;
14128
- nextF = fI < fragments.length ? fragments[fI++] : null;
14129
- }
14130
- if (!nextC) break;
14131
- pos = nextC.toA;
14132
- off = nextC.toA - nextC.toB;
14133
- }
14134
- return result;
14135
- }
14136
- };
14137
- /**
14138
- A superclass that parsers should extend.
14139
- */
14140
- var Parser = class {
14141
- /**
14142
- Start a parse, returning a [partial parse](#common.PartialParse)
14143
- object. [`fragments`](#common.TreeFragment) can be passed in to
14144
- make the parse incremental.
14145
-
14146
- By default, the entire input is parsed. You can pass `ranges`,
14147
- which should be a sorted array of non-empty, non-overlapping
14148
- ranges, to parse only those ranges. The tree returned in that
14149
- case will start at `ranges[0].from`.
14150
- */
14151
- startParse(input, fragments, ranges) {
14152
- if (typeof input == "string") input = new StringInput(input);
14153
- ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map((r) => new Range(r.from, r.to)) : [new Range(0, 0)];
14154
- return this.createParse(input, fragments || [], ranges);
14155
- }
14156
- /**
14157
- Run a full parse, returning the resulting tree.
14158
- */
14159
- parse(input, fragments, ranges) {
14160
- let parse = this.startParse(input, fragments, ranges);
14161
- for (;;) {
14162
- let done = parse.advance();
14163
- if (done) return done;
14164
- }
14165
- }
14166
- };
14167
- var StringInput = class {
14168
- constructor(string) {
14169
- this.string = string;
14170
- }
14171
- get length() {
14172
- return this.string.length;
14173
- }
14174
- chunk(from) {
14175
- return this.string.slice(from);
14176
- }
14177
- get lineChunks() {
14178
- return false;
14179
- }
14180
- read(from, to) {
14181
- return this.string.slice(from, to);
14182
- }
14183
- };
14184
- /**
14185
- Create a parse wrapper that, after the inner parse completes,
14186
- scans its tree for mixed language regions with the `nest`
14187
- function, runs the resulting [inner parses](#common.NestedParse),
14188
- and then [mounts](#common.NodeProp^mounted) their results onto the
14189
- tree.
14190
- */
14191
- function parseMixed(nest) {
14192
- return (parse, input, fragments, ranges) => new MixedParse(parse, nest, input, fragments, ranges);
14193
- }
14194
- var InnerParse = class {
14195
- constructor(parser, parse, overlay, bracketed, target, from) {
14196
- this.parser = parser;
14197
- this.parse = parse;
14198
- this.overlay = overlay;
14199
- this.bracketed = bracketed;
14200
- this.target = target;
14201
- this.from = from;
14202
- }
14203
- };
14204
- function checkRanges(ranges) {
14205
- if (!ranges.length || ranges.some((r) => r.from >= r.to)) throw new RangeError("Invalid inner parse ranges given: " + JSON.stringify(ranges));
14206
- }
14207
- var ActiveOverlay = class {
14208
- constructor(parser, predicate, mounts, index, start, bracketed, target, prev) {
14209
- this.parser = parser;
14210
- this.predicate = predicate;
14211
- this.mounts = mounts;
14212
- this.index = index;
14213
- this.start = start;
14214
- this.bracketed = bracketed;
14215
- this.target = target;
14216
- this.prev = prev;
14217
- this.depth = 0;
14218
- this.ranges = [];
14219
- }
14220
- };
14221
- var stoppedInner = new NodeProp({ perNode: true });
14222
- var MixedParse = class {
14223
- constructor(base, nest, input, fragments, ranges) {
14224
- this.nest = nest;
14225
- this.input = input;
14226
- this.fragments = fragments;
14227
- this.ranges = ranges;
14228
- this.inner = [];
14229
- this.innerDone = 0;
14230
- this.baseTree = null;
14231
- this.stoppedAt = null;
14232
- this.baseParse = base;
14233
- }
14234
- advance() {
14235
- if (this.baseParse) {
14236
- let done = this.baseParse.advance();
14237
- if (!done) return null;
14238
- this.baseParse = null;
14239
- this.baseTree = done;
14240
- this.startInner();
14241
- if (this.stoppedAt != null) for (let inner of this.inner) inner.parse.stopAt(this.stoppedAt);
14242
- }
14243
- if (this.innerDone == this.inner.length) {
14244
- let result = this.baseTree;
14245
- if (this.stoppedAt != null) result = new Tree(result.type, result.children, result.positions, result.length, result.propValues.concat([[stoppedInner, this.stoppedAt]]));
14246
- return result;
14247
- }
14248
- let inner = this.inner[this.innerDone], done = inner.parse.advance();
14249
- if (done) {
14250
- this.innerDone++;
14251
- let props = Object.assign(Object.create(null), inner.target.props);
14252
- props[NodeProp.mounted.id] = new MountedTree(done, inner.overlay, inner.parser, inner.bracketed);
14253
- inner.target.props = props;
14254
- }
14255
- return null;
14256
- }
14257
- get parsedPos() {
14258
- if (this.baseParse) return 0;
14259
- let pos = this.input.length;
14260
- for (let i = this.innerDone; i < this.inner.length; i++) if (this.inner[i].from < pos) pos = Math.min(pos, this.inner[i].parse.parsedPos);
14261
- return pos;
14262
- }
14263
- stopAt(pos) {
14264
- this.stoppedAt = pos;
14265
- if (this.baseParse) this.baseParse.stopAt(pos);
14266
- else for (let i = this.innerDone; i < this.inner.length; i++) this.inner[i].parse.stopAt(pos);
14267
- }
14268
- startInner() {
14269
- let fragmentCursor = new FragmentCursor$1(this.fragments);
14270
- let overlay = null;
14271
- let covered = null;
14272
- let cursor = new TreeCursor(new TreeNode(this.baseTree, this.ranges[0].from, 0, null), IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
14273
- scan: for (let nest, isCovered;;) {
14274
- let enter = true, range;
14275
- if (this.stoppedAt != null && cursor.from >= this.stoppedAt) enter = false;
14276
- else if (fragmentCursor.hasNode(cursor)) {
14277
- if (overlay) {
14278
- let match = overlay.mounts.find((m) => m.frag.from <= cursor.from && m.frag.to >= cursor.to && m.mount.overlay);
14279
- if (match) for (let r of match.mount.overlay) {
14280
- let from = r.from + match.pos, to = r.to + match.pos;
14281
- if (from >= cursor.from && to <= cursor.to && !overlay.ranges.some((r) => r.from < to && r.to > from)) overlay.ranges.push({
14282
- from,
14283
- to
14284
- });
14285
- }
14286
- }
14287
- enter = false;
14288
- } else if (covered && (isCovered = checkCover(covered.ranges, cursor.from, cursor.to))) enter = isCovered != 2;
14289
- else if (!cursor.type.isAnonymous && (nest = this.nest(cursor, this.input)) && (cursor.from < cursor.to || !nest.overlay)) {
14290
- if (!cursor.tree) {
14291
- materialize(cursor);
14292
- if (overlay) overlay.depth++;
14293
- if (covered) covered.depth++;
14294
- }
14295
- let oldMounts = fragmentCursor.findMounts(cursor.from, nest.parser);
14296
- if (typeof nest.overlay == "function") overlay = new ActiveOverlay(nest.parser, nest.overlay, oldMounts, this.inner.length, cursor.from, !!nest.bracketed, cursor.tree, overlay);
14297
- else {
14298
- let ranges = punchRanges(this.ranges, nest.overlay || (cursor.from < cursor.to ? [new Range(cursor.from, cursor.to)] : []));
14299
- if (ranges.length) checkRanges(ranges);
14300
- if (ranges.length || !nest.overlay) this.inner.push(new InnerParse(nest.parser, ranges.length ? nest.parser.startParse(this.input, enterFragments(oldMounts, ranges), ranges) : nest.parser.startParse(""), nest.overlay ? nest.overlay.map((r) => new Range(r.from - cursor.from, r.to - cursor.from)) : null, !!nest.bracketed, cursor.tree, ranges.length ? ranges[0].from : cursor.from));
14301
- if (!nest.overlay) enter = false;
14302
- else if (ranges.length) covered = {
14303
- ranges,
14304
- depth: 0,
14305
- prev: covered
14306
- };
14307
- }
14308
- } else if (overlay && (range = overlay.predicate(cursor))) {
14309
- if (range === true) range = new Range(cursor.from, cursor.to);
14310
- if (range.from < range.to) {
14311
- let last = overlay.ranges.length - 1;
14312
- if (last >= 0 && overlay.ranges[last].to == range.from) overlay.ranges[last] = {
14313
- from: overlay.ranges[last].from,
14314
- to: range.to
14315
- };
14316
- else overlay.ranges.push(range);
14317
- }
14318
- }
14319
- if (enter && cursor.firstChild()) {
14320
- if (overlay) overlay.depth++;
14321
- if (covered) covered.depth++;
14322
- } else for (;;) {
14323
- if (cursor.nextSibling()) break;
14324
- if (!cursor.parent()) break scan;
14325
- if (overlay && !--overlay.depth) {
14326
- let ranges = punchRanges(this.ranges, overlay.ranges);
14327
- if (ranges.length) {
14328
- checkRanges(ranges);
14329
- this.inner.splice(overlay.index, 0, new InnerParse(overlay.parser, overlay.parser.startParse(this.input, enterFragments(overlay.mounts, ranges), ranges), overlay.ranges.map((r) => new Range(r.from - overlay.start, r.to - overlay.start)), overlay.bracketed, overlay.target, ranges[0].from));
14330
- }
14331
- overlay = overlay.prev;
14332
- }
14333
- if (covered && !--covered.depth) covered = covered.prev;
14334
- }
14335
- }
14336
- }
14337
- };
14338
- function checkCover(covered, from, to) {
14339
- for (let range of covered) {
14340
- if (range.from >= to) break;
14341
- if (range.to > from) return range.from <= from && range.to >= to ? 2 : 1;
14342
- }
14343
- return 0;
14344
- }
14345
- function sliceBuf(buf, startI, endI, nodes, positions, off) {
14346
- if (startI < endI) {
14347
- let from = buf.buffer[startI + 1];
14348
- nodes.push(buf.slice(startI, endI, from));
14349
- positions.push(from - off);
14350
- }
14351
- }
14352
- function materialize(cursor) {
14353
- let { node } = cursor, stack = [];
14354
- let buffer = node.context.buffer;
14355
- do {
14356
- stack.push(cursor.index);
14357
- cursor.parent();
14358
- } while (!cursor.tree);
14359
- let base = cursor.tree, i = base.children.indexOf(buffer);
14360
- let buf = base.children[i], b = buf.buffer, newStack = [i];
14361
- function split(startI, endI, type, innerOffset, length, stackPos) {
14362
- let targetI = stack[stackPos];
14363
- let children = [], positions = [];
14364
- sliceBuf(buf, startI, targetI, children, positions, innerOffset);
14365
- let from = b[targetI + 1], to = b[targetI + 2];
14366
- newStack.push(children.length);
14367
- let child = stackPos ? split(targetI + 4, b[targetI + 3], buf.set.types[b[targetI]], from, to - from, stackPos - 1) : node.toTree();
14368
- children.push(child);
14369
- positions.push(from - innerOffset);
14370
- sliceBuf(buf, b[targetI + 3], endI, children, positions, innerOffset);
14371
- return new Tree(type, children, positions, length);
14372
- }
14373
- base.children[i] = split(0, b.length, NodeType.none, 0, buf.length, stack.length - 1);
14374
- for (let index of newStack) {
14375
- let tree = cursor.tree.children[index], pos = cursor.tree.positions[index];
14376
- cursor.yield(new TreeNode(tree, pos + cursor.from, index, cursor._tree));
14377
- }
14378
- }
14379
- var StructureCursor = class {
14380
- constructor(root, offset) {
14381
- this.offset = offset;
14382
- this.done = false;
14383
- this.cursor = root.cursor(IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
14384
- }
14385
- moveTo(pos) {
14386
- let { cursor } = this, p = pos - this.offset;
14387
- while (!this.done && cursor.from < p) if (cursor.to >= pos && cursor.enter(p, 1, IterMode.IgnoreOverlays | IterMode.ExcludeBuffers));
14388
- else if (cursor.to <= pos) {
14389
- if (!cursor.next(false)) this.done = true;
14390
- } else break;
14391
- }
14392
- hasNode(cursor) {
14393
- this.moveTo(cursor.from);
14394
- if (!this.done && this.cursor.from + this.offset == cursor.from && this.cursor.tree) for (let tree = this.cursor.tree;;) {
14395
- if (tree == cursor.tree) return true;
14396
- if (tree.children.length && tree.positions[0] == 0 && tree.children[0] instanceof Tree) tree = tree.children[0];
14397
- else break;
14398
- }
14399
- return false;
14400
- }
14401
- };
14402
- var FragmentCursor$1 = class {
14403
- constructor(fragments) {
14404
- var _a;
14405
- this.fragments = fragments;
14406
- this.curTo = 0;
14407
- this.fragI = 0;
14408
- if (fragments.length) {
14409
- let first = this.curFrag = fragments[0];
14410
- this.curTo = (_a = first.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : first.to;
14411
- this.inner = new StructureCursor(first.tree, -first.offset);
14412
- } else this.curFrag = this.inner = null;
14413
- }
14414
- hasNode(node) {
14415
- while (this.curFrag && node.from >= this.curTo) this.nextFrag();
14416
- return this.curFrag && this.curFrag.from <= node.from && this.curTo >= node.to && this.inner.hasNode(node);
14417
- }
14418
- nextFrag() {
14419
- var _a;
14420
- this.fragI++;
14421
- if (this.fragI == this.fragments.length) this.curFrag = this.inner = null;
14422
- else {
14423
- let frag = this.curFrag = this.fragments[this.fragI];
14424
- this.curTo = (_a = frag.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : frag.to;
14425
- this.inner = new StructureCursor(frag.tree, -frag.offset);
14426
- }
14427
- }
14428
- findMounts(pos, parser) {
14429
- var _a;
14430
- let result = [];
14431
- if (this.inner) {
14432
- this.inner.cursor.moveTo(pos, 1);
14433
- for (let pos = this.inner.cursor.node; pos; pos = pos.parent) {
14434
- let mount = (_a = pos.tree) === null || _a === void 0 ? void 0 : _a.prop(NodeProp.mounted);
14435
- if (mount && mount.parser == parser) for (let i = this.fragI; i < this.fragments.length; i++) {
14436
- let frag = this.fragments[i];
14437
- if (frag.from >= pos.to) break;
14438
- if (frag.tree == this.curFrag.tree) result.push({
14439
- frag,
14440
- pos: pos.from - frag.offset,
14441
- mount
14442
- });
14443
- }
14444
- }
14445
- }
14446
- return result;
14447
- }
14448
- };
14449
- function punchRanges(outer, ranges) {
14450
- let copy = null, current = ranges;
14451
- for (let i = 1, j = 0; i < outer.length; i++) {
14452
- let gapFrom = outer[i - 1].to, gapTo = outer[i].from;
14453
- for (; j < current.length; j++) {
14454
- let r = current[j];
14455
- if (r.from >= gapTo) break;
14456
- if (r.to <= gapFrom) continue;
14457
- if (!copy) current = copy = ranges.slice();
14458
- if (r.from < gapFrom) {
14459
- copy[j] = new Range(r.from, gapFrom);
14460
- if (r.to > gapTo) copy.splice(j + 1, 0, new Range(gapTo, r.to));
14461
- } else if (r.to > gapTo) copy[j--] = new Range(gapTo, r.to);
14462
- else copy.splice(j--, 1);
14463
- }
14464
- }
14465
- return current;
14466
- }
14467
- function findCoverChanges(a, b, from, to) {
14468
- let iA = 0, iB = 0, inA = false, inB = false, pos = -1e9;
14469
- let result = [];
14470
- for (;;) {
14471
- let nextA = iA == a.length ? 1e9 : inA ? a[iA].to : a[iA].from;
14472
- let nextB = iB == b.length ? 1e9 : inB ? b[iB].to : b[iB].from;
14473
- if (inA != inB) {
14474
- let start = Math.max(pos, from), end = Math.min(nextA, nextB, to);
14475
- if (start < end) result.push(new Range(start, end));
14476
- }
14477
- pos = Math.min(nextA, nextB);
14478
- if (pos == 1e9) break;
14479
- if (nextA == pos) {
14480
- if (!inA) inA = true;
14481
- else {
14482
- inA = false;
14483
- iA++;
14484
- }
14485
- }
14486
- if (nextB == pos) {
14487
- if (!inB) inB = true;
14488
- else {
14489
- inB = false;
14490
- iB++;
14491
- }
14492
- }
14493
- }
14494
- return result;
14495
- }
14496
- function enterFragments(mounts, ranges) {
14497
- let result = [];
14498
- for (let { pos, mount, frag } of mounts) {
14499
- let startPos = pos + (mount.overlay ? mount.overlay[0].from : 0), endPos = startPos + mount.tree.length;
14500
- let from = Math.max(frag.from, startPos), to = Math.min(frag.to, endPos);
14501
- if (mount.overlay) {
14502
- let changes = findCoverChanges(ranges, mount.overlay.map((r) => new Range(r.from + pos, r.to + pos)), from, to);
14503
- for (let i = 0, pos = from;; i++) {
14504
- let last = i == changes.length, end = last ? to : changes[i].from;
14505
- if (end > pos) result.push(new TreeFragment(pos, end, mount.tree, -startPos, frag.from >= pos || frag.openStart, frag.to <= end || frag.openEnd));
14506
- if (last) break;
14507
- pos = changes[i].to;
14508
- }
14509
- } else result.push(new TreeFragment(from, to, mount.tree, -startPos, frag.from >= startPos || frag.openStart, frag.to <= endPos || frag.openEnd));
14510
- }
14511
- return result;
14512
- }
14513
- //#endregion
14514
- //#region node_modules/@lezer/highlight/dist/index.js
14515
- var nextTagID = 0;
14516
- /**
14517
- Highlighting tags are markers that denote a highlighting category.
14518
- They are [associated](#highlight.styleTags) with parts of a syntax
14519
- tree by a language mode, and then mapped to an actual CSS style by
14520
- a [highlighter](#highlight.Highlighter).
14521
-
14522
- Because syntax tree node types and highlight styles have to be
14523
- able to talk the same language, CodeMirror uses a mostly _closed_
14524
- [vocabulary](#highlight.tags) of syntax tags (as opposed to
14525
- traditional open string-based systems, which make it hard for
14526
- highlighting themes to cover all the tokens produced by the
14527
- various languages).
14528
-
14529
- It _is_ possible to [define](#highlight.Tag^define) your own
14530
- highlighting tags for system-internal use (where you control both
14531
- the language package and the highlighter), but such tags will not
14532
- be picked up by regular highlighters (though you can derive them
14533
- from standard tags to allow highlighters to fall back to those).
14534
- */
14535
- var Tag = class Tag {
14536
- /**
14537
- @internal
14538
- */
14539
- constructor(name, set, base, modified) {
14540
- this.name = name;
14541
- this.set = set;
14542
- this.base = base;
14543
- this.modified = modified;
14544
- /**
14545
- @internal
14546
- */
14547
- this.id = nextTagID++;
14548
- }
14549
- toString() {
14550
- let { name } = this;
14551
- for (let mod of this.modified) if (mod.name) name = `${mod.name}(${name})`;
14552
- return name;
14553
- }
14554
- static define(nameOrParent, parent) {
14555
- let name = typeof nameOrParent == "string" ? nameOrParent : "?";
14556
- if (nameOrParent instanceof Tag) parent = nameOrParent;
14557
- if (parent === null || parent === void 0 ? void 0 : parent.base) throw new Error("Can not derive from a modified tag");
14558
- let tag = new Tag(name, [], null, []);
14559
- tag.set.push(tag);
14560
- if (parent) for (let t of parent.set) tag.set.push(t);
14561
- return tag;
14562
- }
14563
- /**
14564
- Define a tag _modifier_, which is a function that, given a tag,
14565
- will return a tag that is a subtag of the original. Applying the
14566
- same modifier to a twice tag will return the same value (`m1(t1)
14567
- == m1(t1)`) and applying multiple modifiers will, regardless or
14568
- order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
14569
-
14570
- When multiple modifiers are applied to a given base tag, each
14571
- smaller set of modifiers is registered as a parent, so that for
14572
- example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
14573
- `m1(m3(t1)`, and so on.
14574
- */
14575
- static defineModifier(name) {
14576
- let mod = new Modifier(name);
14577
- return (tag) => {
14578
- if (tag.modified.indexOf(mod) > -1) return tag;
14579
- return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
14580
- };
14581
- }
14582
- };
14583
- var nextModifierID = 0;
14584
- var Modifier = class Modifier {
14585
- constructor(name) {
14586
- this.name = name;
14587
- this.instances = [];
14588
- this.id = nextModifierID++;
14589
- }
14590
- static get(base, mods) {
14591
- if (!mods.length) return base;
14592
- let exists = mods[0].instances.find((t) => t.base == base && sameArray(mods, t.modified));
14593
- if (exists) return exists;
14594
- let set = [], tag = new Tag(base.name, set, base, mods);
14595
- for (let m of mods) m.instances.push(tag);
14596
- let configs = powerSet(mods);
14597
- for (let parent of base.set) if (!parent.modified.length) for (let config of configs) set.push(Modifier.get(parent, config));
14598
- return tag;
14599
- }
14600
- };
14601
- function sameArray(a, b) {
14602
- return a.length == b.length && a.every((x, i) => x == b[i]);
14603
- }
14604
- function powerSet(array) {
14605
- let sets = [[]];
14606
- for (let i = 0; i < array.length; i++) for (let j = 0, e = sets.length; j < e; j++) sets.push(sets[j].concat(array[i]));
14607
- return sets.sort((a, b) => b.length - a.length);
14608
- }
14609
- /**
14610
- This function is used to add a set of tags to a language syntax
14611
- via [`NodeSet.extend`](#common.NodeSet.extend) or
14612
- [`LRParser.configure`](#lr.LRParser.configure).
14613
-
14614
- The argument object maps node selectors to [highlighting
14615
- tags](#highlight.Tag) or arrays of tags.
14616
-
14617
- Node selectors may hold one or more (space-separated) node paths.
14618
- Such a path can be a [node name](#common.NodeType.name), or
14619
- multiple node names (or `*` wildcards) separated by slash
14620
- characters, as in `"Block/Declaration/VariableName"`. Such a path
14621
- matches the final node but only if its direct parent nodes are the
14622
- other nodes mentioned. A `*` in such a path matches any parent,
14623
- but only a single level—wildcards that match multiple parents
14624
- aren't supported, both for efficiency reasons and because Lezer
14625
- trees make it rather hard to reason about what they would match.)
14626
-
14627
- A path can be ended with `/...` to indicate that the tag assigned
14628
- to the node should also apply to all child nodes, even if they
14629
- match their own style (by default, only the innermost style is
14630
- used).
14631
-
14632
- When a path ends in `!`, as in `Attribute!`, no further matching
14633
- happens for the node's child nodes, and the entire node gets the
14634
- given style.
14635
-
14636
- In this notation, node names that contain `/`, `!`, `*`, or `...`
14637
- must be quoted as JSON strings.
14638
-
14639
- For example:
14640
-
14641
- ```javascript
14642
- parser.configure({props: [
14643
- styleTags({
14644
- // Style Number and BigNumber nodes
14645
- "Number BigNumber": tags.number,
14646
- // Style Escape nodes whose parent is String
14647
- "String/Escape": tags.escape,
14648
- // Style anything inside Attributes nodes
14649
- "Attributes!": tags.meta,
14650
- // Add a style to all content inside Italic nodes
14651
- "Italic/...": tags.emphasis,
14652
- // Style InvalidString nodes as both `string` and `invalid`
14653
- "InvalidString": [tags.string, tags.invalid],
14654
- // Style the node named "/" as punctuation
14655
- '"/"': tags.punctuation
14656
- })
14657
- ]})
14658
- ```
14659
- */
14660
- function styleTags(spec) {
14661
- let byName = Object.create(null);
14662
- for (let prop in spec) {
14663
- let tags = spec[prop];
14664
- if (!Array.isArray(tags)) tags = [tags];
14665
- for (let part of prop.split(" ")) if (part) {
14666
- let pieces = [], mode = 2, rest = part;
14667
- for (let pos = 0;;) {
14668
- if (rest == "..." && pos > 0 && pos + 3 == part.length) {
14669
- mode = 1;
14670
- break;
14671
- }
14672
- let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
14673
- if (!m) throw new RangeError("Invalid path: " + part);
14674
- pieces.push(m[0] == "*" ? "" : m[0][0] == "\"" ? JSON.parse(m[0]) : m[0]);
14675
- pos += m[0].length;
14676
- if (pos == part.length) break;
14677
- let next = part[pos++];
14678
- if (pos == part.length && next == "!") {
14679
- mode = 0;
14680
- break;
14681
- }
14682
- if (next != "/") throw new RangeError("Invalid path: " + part);
14683
- rest = part.slice(pos);
14684
- }
14685
- let last = pieces.length - 1, inner = pieces[last];
14686
- if (!inner) throw new RangeError("Invalid path: " + part);
14687
- byName[inner] = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null).sort(byName[inner]);
14688
- }
14689
- }
14690
- return ruleNodeProp.add(byName);
14691
- }
14692
- var ruleNodeProp = new NodeProp({ combine(a, b) {
14693
- let cur, root, take;
14694
- while (a || b) {
14695
- if (!a || b && a.depth <= b.depth) {
14696
- take = b;
14697
- b = b.next;
14698
- } else {
14699
- take = a;
14700
- a = a.next;
14701
- }
14702
- if (cur && cur.mode == take.mode && !take.context && !cur.context) continue;
14703
- let copy = new Rule(take.tags, take.mode, take.context);
14704
- if (cur) cur.next = copy;
14705
- else root = copy;
14706
- cur = copy;
14707
- }
14708
- return root;
14709
- } });
14710
- var Rule = class {
14711
- constructor(tags, mode, context, next) {
14712
- this.tags = tags;
14713
- this.mode = mode;
14714
- this.context = context;
14715
- this.next = next;
14716
- }
14717
- get opaque() {
14718
- return this.mode == 0;
14719
- }
14720
- get inherit() {
14721
- return this.mode == 1;
14722
- }
14723
- sort(other) {
14724
- if (!other || other.depth < this.depth) {
14725
- this.next = other;
14726
- return this;
14727
- }
14728
- other.next = this.sort(other.next);
14729
- return other;
14730
- }
14731
- get depth() {
14732
- return this.context ? this.context.length : 0;
14733
- }
14734
- };
14735
- Rule.empty = new Rule([], 2, null);
14736
- /**
14737
- Define a [highlighter](#highlight.Highlighter) from an array of
14738
- tag/class pairs. Classes associated with more specific tags will
14739
- take precedence.
14740
- */
14741
- function tagHighlighter(tags, options) {
14742
- let map = Object.create(null);
14743
- for (let style of tags) if (!Array.isArray(style.tag)) map[style.tag.id] = style.class;
14744
- else for (let tag of style.tag) map[tag.id] = style.class;
14745
- let { scope, all = null } = options || {};
14746
- return {
14747
- style: (tags) => {
14748
- let cls = all;
14749
- for (let tag of tags) for (let sub of tag.set) {
14750
- let tagClass = map[sub.id];
14751
- if (tagClass) {
14752
- cls = cls ? cls + " " + tagClass : tagClass;
14753
- break;
14754
- }
14755
- }
14756
- return cls;
14757
- },
14758
- scope
14759
- };
14760
- }
14761
- function highlightTags(highlighters, tags) {
14762
- let result = null;
14763
- for (let highlighter of highlighters) {
14764
- let value = highlighter.style(tags);
14765
- if (value) result = result ? result + " " + value : value;
14766
- }
14767
- return result;
14768
- }
14769
- /**
14770
- Highlight the given [tree](#common.Tree) with the given
14771
- [highlighter](#highlight.Highlighter). Often, the higher-level
14772
- [`highlightCode`](#highlight.highlightCode) function is easier to
14773
- use.
14774
- */
14775
- function highlightTree(tree, highlighter, putStyle, from = 0, to = tree.length) {
14776
- let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
14777
- builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
14778
- builder.flush(to);
14779
- }
14780
- var HighlightBuilder = class {
14781
- constructor(at, highlighters, span) {
14782
- this.at = at;
14783
- this.highlighters = highlighters;
14784
- this.span = span;
14785
- this.class = "";
14786
- }
14787
- startSpan(at, cls) {
14788
- if (cls != this.class) {
14789
- this.flush(at);
14790
- if (at > this.at) this.at = at;
14791
- this.class = cls;
14792
- }
14793
- }
14794
- flush(to) {
14795
- if (to > this.at && this.class) this.span(this.at, to, this.class);
14796
- }
14797
- highlightRange(cursor, from, to, inheritedClass, highlighters) {
14798
- let { type, from: start, to: end } = cursor;
14799
- if (start >= to || end <= from) return;
14800
- if (type.isTop) highlighters = this.highlighters.filter((h) => !h.scope || h.scope(type));
14801
- let cls = inheritedClass;
14802
- let rule = getStyleTags(cursor) || Rule.empty;
14803
- let tagCls = highlightTags(highlighters, rule.tags);
14804
- if (tagCls) {
14805
- if (cls) cls += " ";
14806
- cls += tagCls;
14807
- if (rule.mode == 1) inheritedClass += (inheritedClass ? " " : "") + tagCls;
14808
- }
14809
- this.startSpan(Math.max(from, start), cls);
14810
- if (rule.opaque) return;
14811
- let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);
14812
- if (mounted && mounted.overlay) {
14813
- let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
14814
- let innerHighlighters = this.highlighters.filter((h) => !h.scope || h.scope(mounted.tree.type));
14815
- let hasChild = cursor.firstChild();
14816
- for (let i = 0, pos = start;; i++) {
14817
- let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
14818
- let nextPos = next ? next.from + start : end;
14819
- let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
14820
- if (rangeFrom < rangeTo && hasChild) while (cursor.from < rangeTo) {
14821
- this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
14822
- this.startSpan(Math.min(rangeTo, cursor.to), cls);
14823
- if (cursor.to >= nextPos || !cursor.nextSibling()) break;
14824
- }
14825
- if (!next || nextPos > to) break;
14826
- pos = next.to + start;
14827
- if (pos > from) {
14828
- this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), "", innerHighlighters);
14829
- this.startSpan(Math.min(to, pos), cls);
14830
- }
14831
- }
14832
- if (hasChild) cursor.parent();
14833
- } else if (cursor.firstChild()) {
14834
- if (mounted) inheritedClass = "";
14835
- do {
14836
- if (cursor.to <= from) continue;
14837
- if (cursor.from >= to) break;
14838
- this.highlightRange(cursor, from, to, inheritedClass, highlighters);
14839
- this.startSpan(Math.min(to, cursor.to), cls);
14840
- } while (cursor.nextSibling());
14841
- cursor.parent();
14842
- }
14843
- }
14844
- };
14845
- /**
14846
- Match a syntax node's [highlight rules](#highlight.styleTags). If
14847
- there's a match, return its set of tags, and whether it is
14848
- opaque (uses a `!`) or applies to all child nodes (`/...`).
14849
- */
14850
- function getStyleTags(node) {
14851
- let rule = node.type.prop(ruleNodeProp);
14852
- while (rule && rule.context && !node.matchContext(rule.context)) rule = rule.next;
14853
- return rule || null;
14854
- }
14855
- var t = Tag.define;
14856
- var comment = t();
14857
- var name = t();
14858
- var typeName = t(name);
14859
- var propertyName = t(name);
14860
- var literal = t();
14861
- var string = t(literal);
14862
- var number = t(literal);
14863
- var content = t();
14864
- var heading = t(content);
14865
- var keyword = t();
14866
- var operator = t();
14867
- var punctuation = t();
14868
- var bracket = t(punctuation);
14869
- var meta = t();
14870
- /**
14871
- The default set of highlighting [tags](#highlight.Tag).
14872
-
14873
- This collection is heavily biased towards programming languages,
14874
- and necessarily incomplete. A full ontology of syntactic
14875
- constructs would fill a stack of books, and be impractical to
14876
- write themes for. So try to make do with this set. If all else
14877
- fails, [open an
14878
- issue](https://code.haverbeke.berlin/codemirror/dev/issues) to propose a
14879
- new tag, or [define](#highlight.Tag^define) a local custom tag for
14880
- your use case.
14881
-
14882
- Note that it is not obligatory to always attach the most specific
14883
- tag possible to an element—if your grammar can't easily
14884
- distinguish a certain type of element (such as a local variable),
14885
- it is okay to style it as its more general variant (a variable).
14886
-
14887
- For tags that extend some parent tag, the documentation links to
14888
- the parent.
14889
- */
14890
- var tags = {
14891
- /**
14892
- A comment.
14893
- */
14894
- comment,
14895
- /**
14896
- A line [comment](#highlight.tags.comment).
14897
- */
14898
- lineComment: t(comment),
14899
- /**
14900
- A block [comment](#highlight.tags.comment).
14901
- */
14902
- blockComment: t(comment),
14903
- /**
14904
- A documentation [comment](#highlight.tags.comment).
14905
- */
14906
- docComment: t(comment),
14907
- /**
14908
- Any kind of identifier.
14909
- */
14910
- name,
14911
- /**
14912
- The [name](#highlight.tags.name) of a variable.
14913
- */
14914
- variableName: t(name),
14915
- /**
14916
- A type [name](#highlight.tags.name).
14917
- */
14918
- typeName,
14919
- /**
14920
- A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
14921
- */
14922
- tagName: t(typeName),
14923
- /**
14924
- A property or field [name](#highlight.tags.name).
14925
- */
14926
- propertyName,
14927
- /**
14928
- An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
14929
- */
14930
- attributeName: t(propertyName),
14931
- /**
14932
- The [name](#highlight.tags.name) of a class.
14933
- */
14934
- className: t(name),
14935
- /**
14936
- A label [name](#highlight.tags.name).
14937
- */
14938
- labelName: t(name),
14939
- /**
14940
- A namespace [name](#highlight.tags.name).
14941
- */
14942
- namespace: t(name),
14943
- /**
14944
- The [name](#highlight.tags.name) of a macro.
14945
- */
14946
- macroName: t(name),
14947
- /**
14948
- A literal value.
14949
- */
14950
- literal,
14951
- /**
14952
- A string [literal](#highlight.tags.literal).
14953
- */
14954
- string,
14955
- /**
14956
- A documentation [string](#highlight.tags.string).
14957
- */
14958
- docString: t(string),
14959
- /**
14960
- A character literal (subtag of [string](#highlight.tags.string)).
14961
- */
14962
- character: t(string),
14963
- /**
14964
- An attribute value (subtag of [string](#highlight.tags.string)).
14965
- */
14966
- attributeValue: t(string),
14967
- /**
14968
- A number [literal](#highlight.tags.literal).
14969
- */
14970
- number,
14971
- /**
14972
- An integer [number](#highlight.tags.number) literal.
14973
- */
14974
- integer: t(number),
14975
- /**
14976
- A floating-point [number](#highlight.tags.number) literal.
14977
- */
14978
- float: t(number),
14979
- /**
14980
- A boolean [literal](#highlight.tags.literal).
14981
- */
14982
- bool: t(literal),
14983
- /**
14984
- Regular expression [literal](#highlight.tags.literal).
14985
- */
14986
- regexp: t(literal),
14987
- /**
14988
- An escape [literal](#highlight.tags.literal), for example a
14989
- backslash escape in a string.
14990
- */
14991
- escape: t(literal),
14992
- /**
14993
- A color [literal](#highlight.tags.literal).
14994
- */
14995
- color: t(literal),
14996
- /**
14997
- A URL [literal](#highlight.tags.literal).
14998
- */
14999
- url: t(literal),
15000
- /**
15001
- A language keyword.
15002
- */
15003
- keyword,
15004
- /**
15005
- The [keyword](#highlight.tags.keyword) for the self or this
15006
- object.
15007
- */
15008
- self: t(keyword),
15009
- /**
15010
- The [keyword](#highlight.tags.keyword) for null.
15011
- */
15012
- null: t(keyword),
15013
- /**
15014
- A [keyword](#highlight.tags.keyword) denoting some atomic value.
15015
- */
15016
- atom: t(keyword),
15017
- /**
15018
- A [keyword](#highlight.tags.keyword) that represents a unit.
15019
- */
15020
- unit: t(keyword),
15021
- /**
15022
- A modifier [keyword](#highlight.tags.keyword).
15023
- */
15024
- modifier: t(keyword),
15025
- /**
15026
- A [keyword](#highlight.tags.keyword) that acts as an operator.
15027
- */
15028
- operatorKeyword: t(keyword),
15029
- /**
15030
- A control-flow related [keyword](#highlight.tags.keyword).
15031
- */
15032
- controlKeyword: t(keyword),
15033
- /**
15034
- A [keyword](#highlight.tags.keyword) that defines something.
15035
- */
15036
- definitionKeyword: t(keyword),
15037
- /**
15038
- A [keyword](#highlight.tags.keyword) related to defining or
15039
- interfacing with modules.
15040
- */
15041
- moduleKeyword: t(keyword),
15042
- /**
15043
- An operator.
15044
- */
15045
- operator,
15046
- /**
15047
- An [operator](#highlight.tags.operator) that dereferences something.
15048
- */
15049
- derefOperator: t(operator),
15050
- /**
15051
- Arithmetic-related [operator](#highlight.tags.operator).
15052
- */
15053
- arithmeticOperator: t(operator),
15054
- /**
15055
- Logical [operator](#highlight.tags.operator).
15056
- */
15057
- logicOperator: t(operator),
15058
- /**
15059
- Bit [operator](#highlight.tags.operator).
15060
- */
15061
- bitwiseOperator: t(operator),
15062
- /**
15063
- Comparison [operator](#highlight.tags.operator).
15064
- */
15065
- compareOperator: t(operator),
15066
- /**
15067
- [Operator](#highlight.tags.operator) that updates its operand.
15068
- */
15069
- updateOperator: t(operator),
15070
- /**
15071
- [Operator](#highlight.tags.operator) that defines something.
15072
- */
15073
- definitionOperator: t(operator),
15074
- /**
15075
- Type-related [operator](#highlight.tags.operator).
15076
- */
15077
- typeOperator: t(operator),
15078
- /**
15079
- Control-flow [operator](#highlight.tags.operator).
15080
- */
15081
- controlOperator: t(operator),
15082
- /**
15083
- Program or markup punctuation.
15084
- */
15085
- punctuation,
15086
- /**
15087
- [Punctuation](#highlight.tags.punctuation) that separates
15088
- things.
15089
- */
15090
- separator: t(punctuation),
15091
- /**
15092
- Bracket-style [punctuation](#highlight.tags.punctuation).
15093
- */
15094
- bracket,
15095
- /**
15096
- Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
15097
- tokens).
15098
- */
15099
- angleBracket: t(bracket),
15100
- /**
15101
- Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
15102
- tokens).
15103
- */
15104
- squareBracket: t(bracket),
15105
- /**
15106
- Parentheses (usually `(` and `)` tokens). Subtag of
15107
- [bracket](#highlight.tags.bracket).
15108
- */
15109
- paren: t(bracket),
15110
- /**
15111
- Braces (usually `{` and `}` tokens). Subtag of
15112
- [bracket](#highlight.tags.bracket).
15113
- */
15114
- brace: t(bracket),
15115
- /**
15116
- Content, for example plain text in XML or markup documents.
15117
- */
15118
- content,
15119
- /**
15120
- [Content](#highlight.tags.content) that represents a heading.
15121
- */
15122
- heading,
15123
- /**
15124
- A level 1 [heading](#highlight.tags.heading).
15125
- */
15126
- heading1: t(heading),
15127
- /**
15128
- A level 2 [heading](#highlight.tags.heading).
15129
- */
15130
- heading2: t(heading),
15131
- /**
15132
- A level 3 [heading](#highlight.tags.heading).
15133
- */
15134
- heading3: t(heading),
15135
- /**
15136
- A level 4 [heading](#highlight.tags.heading).
15137
- */
15138
- heading4: t(heading),
15139
- /**
15140
- A level 5 [heading](#highlight.tags.heading).
15141
- */
15142
- heading5: t(heading),
15143
- /**
15144
- A level 6 [heading](#highlight.tags.heading).
15145
- */
15146
- heading6: t(heading),
15147
- /**
15148
- A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
15149
- */
15150
- contentSeparator: t(content),
15151
- /**
15152
- [Content](#highlight.tags.content) that represents a list.
15153
- */
15154
- list: t(content),
15155
- /**
15156
- [Content](#highlight.tags.content) that represents a quote.
15157
- */
15158
- quote: t(content),
15159
- /**
15160
- [Content](#highlight.tags.content) that is emphasized.
15161
- */
15162
- emphasis: t(content),
15163
- /**
15164
- [Content](#highlight.tags.content) that is styled strong.
15165
- */
15166
- strong: t(content),
15167
- /**
15168
- [Content](#highlight.tags.content) that is part of a link.
15169
- */
15170
- link: t(content),
15171
- /**
15172
- [Content](#highlight.tags.content) that is styled as code or
15173
- monospace.
15174
- */
15175
- monospace: t(content),
15176
- /**
15177
- [Content](#highlight.tags.content) that has a strike-through
15178
- style.
15179
- */
15180
- strikethrough: t(content),
15181
- /**
15182
- Inserted text in a change-tracking format.
15183
- */
15184
- inserted: t(),
15185
- /**
15186
- Deleted text.
15187
- */
15188
- deleted: t(),
15189
- /**
15190
- Changed text.
15191
- */
15192
- changed: t(),
15193
- /**
15194
- An invalid or unsyntactic element.
15195
- */
15196
- invalid: t(),
15197
- /**
15198
- Metadata or meta-instruction.
15199
- */
15200
- meta,
15201
- /**
15202
- [Metadata](#highlight.tags.meta) that applies to the entire
15203
- document.
15204
- */
15205
- documentMeta: t(meta),
15206
- /**
15207
- [Metadata](#highlight.tags.meta) that annotates or adds
15208
- attributes to a given syntactic element.
15209
- */
15210
- annotation: t(meta),
15211
- /**
15212
- Processing instruction or preprocessor directive. Subtag of
15213
- [meta](#highlight.tags.meta).
15214
- */
15215
- processingInstruction: t(meta),
15216
- /**
15217
- [Modifier](#highlight.Tag^defineModifier) that indicates that a
15218
- given element is being defined. Expected to be used with the
15219
- various [name](#highlight.tags.name) tags.
15220
- */
15221
- definition: Tag.defineModifier("definition"),
15222
- /**
15223
- [Modifier](#highlight.Tag^defineModifier) that indicates that
15224
- something is constant. Mostly expected to be used with
15225
- [variable names](#highlight.tags.variableName).
15226
- */
15227
- constant: Tag.defineModifier("constant"),
15228
- /**
15229
- [Modifier](#highlight.Tag^defineModifier) used to indicate that
15230
- a [variable](#highlight.tags.variableName) or [property
15231
- name](#highlight.tags.propertyName) is being called or defined
15232
- as a function.
15233
- */
15234
- function: Tag.defineModifier("function"),
15235
- /**
15236
- [Modifier](#highlight.Tag^defineModifier) that can be applied to
15237
- [names](#highlight.tags.name) to indicate that they belong to
15238
- the language's standard environment.
15239
- */
15240
- standard: Tag.defineModifier("standard"),
15241
- /**
15242
- [Modifier](#highlight.Tag^defineModifier) that indicates a given
15243
- [names](#highlight.tags.name) is local to some scope.
15244
- */
15245
- local: Tag.defineModifier("local"),
15246
- /**
15247
- A generic variant [modifier](#highlight.Tag^defineModifier) that
15248
- can be used to tag language-specific alternative variants of
15249
- some common tag. It is recommended for themes to define special
15250
- forms of at least the [string](#highlight.tags.string) and
15251
- [variable name](#highlight.tags.variableName) tags, since those
15252
- come up a lot.
15253
- */
15254
- special: Tag.defineModifier("special")
15255
- };
15256
- for (let name in tags) {
15257
- let val = tags[name];
15258
- if (val instanceof Tag) val.name = name;
15259
- }
15260
- tagHighlighter([
15261
- {
15262
- tag: tags.link,
15263
- class: "tok-link"
15264
- },
15265
- {
15266
- tag: tags.heading,
15267
- class: "tok-heading"
15268
- },
15269
- {
15270
- tag: tags.emphasis,
15271
- class: "tok-emphasis"
15272
- },
15273
- {
15274
- tag: tags.strong,
15275
- class: "tok-strong"
15276
- },
15277
- {
15278
- tag: tags.keyword,
15279
- class: "tok-keyword"
15280
- },
15281
- {
15282
- tag: tags.atom,
15283
- class: "tok-atom"
15284
- },
15285
- {
15286
- tag: tags.bool,
15287
- class: "tok-bool"
15288
- },
15289
- {
15290
- tag: tags.url,
15291
- class: "tok-url"
15292
- },
15293
- {
15294
- tag: tags.labelName,
15295
- class: "tok-labelName"
15296
- },
15297
- {
15298
- tag: tags.inserted,
15299
- class: "tok-inserted"
15300
- },
15301
- {
15302
- tag: tags.deleted,
15303
- class: "tok-deleted"
15304
- },
15305
- {
15306
- tag: tags.literal,
15307
- class: "tok-literal"
15308
- },
15309
- {
15310
- tag: tags.string,
15311
- class: "tok-string"
15312
- },
15313
- {
15314
- tag: tags.number,
15315
- class: "tok-number"
15316
- },
15317
- {
15318
- tag: [
15319
- tags.regexp,
15320
- tags.escape,
15321
- tags.special(tags.string)
15322
- ],
15323
- class: "tok-string2"
15324
- },
15325
- {
15326
- tag: tags.variableName,
15327
- class: "tok-variableName"
15328
- },
15329
- {
15330
- tag: tags.local(tags.variableName),
15331
- class: "tok-variableName tok-local"
15332
- },
15333
- {
15334
- tag: tags.definition(tags.variableName),
15335
- class: "tok-variableName tok-definition"
15336
- },
15337
- {
15338
- tag: tags.special(tags.variableName),
15339
- class: "tok-variableName2"
15340
- },
15341
- {
15342
- tag: tags.definition(tags.propertyName),
15343
- class: "tok-propertyName tok-definition"
15344
- },
15345
- {
15346
- tag: tags.typeName,
15347
- class: "tok-typeName"
15348
- },
15349
- {
15350
- tag: tags.namespace,
15351
- class: "tok-namespace"
15352
- },
15353
- {
15354
- tag: tags.className,
15355
- class: "tok-className"
15356
- },
15357
- {
15358
- tag: tags.macroName,
15359
- class: "tok-macroName"
15360
- },
15361
- {
15362
- tag: tags.propertyName,
15363
- class: "tok-propertyName"
15364
- },
15365
- {
15366
- tag: tags.operator,
15367
- class: "tok-operator"
15368
- },
15369
- {
15370
- tag: tags.comment,
15371
- class: "tok-comment"
15372
- },
15373
- {
15374
- tag: tags.meta,
15375
- class: "tok-meta"
15376
- },
15377
- {
15378
- tag: tags.invalid,
15379
- class: "tok-invalid"
15380
- },
15381
- {
15382
- tag: tags.punctuation,
15383
- class: "tok-punctuation"
15384
- }
15385
- ]);
15386
- //#endregion
15387
12552
  //#region node_modules/@codemirror/streamparser/dist/index.js
15388
12553
  function countCol(string, end, tabSize, startIndex = 0, startValue = 0) {
15389
12554
  if (end == null) {
@@ -18583,4 +15748,4 @@ function getSpecializer(spec) {
18583
15748
  return spec.get;
18584
15749
  }
18585
15750
  //#endregion
18586
- export { layer as $, syntaxTree as A, Tree as B, indentNodeProp as C, countColumn as Ct, matchBrackets as D, languageDataProp as E, NodeProp as F, RectangleMarker as G, Decoration as H, NodeSet as I, drawSelection as J, ViewPlugin as K, NodeType as L, styleTags as M, tags as N, sublanguageProp as O, IterMode as P, keymap as Q, NodeWeakMap as R, getIndentation as S, combineConfig as St, indentUnit as T, fromCodePoint as Tt, Direction as U, parseMixed as V, EditorView as W, getDrawSelectionConfig as X, dropCursor as Y, getTooltip as Z, flatIndent as _, StateField as _t, HighlightStyle as a, Annotation as at, foldService as b, codePointAt as bt, Language as c, Compartment as ct, ParseContext as d, Facet as dt, lineNumbers as et, StreamLanguage as f, MapMode as ft, delimitedIndent as g, StateEffect as gt, defineLanguageFacet as h, RangeValue as ht, LocalTokenGroup as i, tooltips as it, Tag as j, syntaxHighlighting as k, LanguageDescription as l, EditorSelection as lt, continuedIndent as m, RangeSetBuilder as mt, ExternalTokenizer as n, placeholder as nt, IndentContext as o, ChangeDesc as ot, bracketMatchingHandle as p, Prec as pt, WidgetType as q, LRParser as r, showTooltip as rt, LRLanguage as s, ChangeSet as st, ContextTracker as t, logException as tt, LanguageSupport as u, EditorState as ut, foldInside as v, Text as vt, indentString as w, findClusterBreak as wt, getIndentUnit as x, codePointSize as xt, foldNodeProp as y, Transaction as yt, Parser as z };
15751
+ export { ChangeSet as $, syntaxTree as A, getDrawSelectionConfig as B, indentNodeProp as C, matchBrackets as D, languageDataProp as E, RectangleMarker as F, layer as G, gutter as H, ViewPlugin as I, placeholder as J, lineNumbers as K, WidgetType as L, Direction as M, EditorView as N, sublanguageProp as O, GutterMarker as P, ChangeDesc as Q, drawSelection as R, getIndentation as S, indentUnit as T, gutterLineClass as U, getTooltip as V, keymap as W, tooltips as X, showTooltip as Y, Annotation as Z, flatIndent as _, findClusterBreak as _t, HighlightStyle as a, Prec as at, foldService as b, Language as c, RangeValue as ct, ParseContext as d, Text as dt, Compartment as et, StreamLanguage as f, Transaction as ft, delimitedIndent as g, countColumn as gt, defineLanguageFacet as h, combineConfig as ht, LocalTokenGroup as i, MapMode as it, Decoration as j, syntaxHighlighting as k, LanguageDescription as l, StateEffect as lt, continuedIndent as m, codePointSize as mt, ExternalTokenizer as n, EditorState as nt, IndentContext as o, RangeSet as ot, bracketMatchingHandle as p, codePointAt as pt, logException as q, LRParser as r, Facet as rt, LRLanguage as s, RangeSetBuilder as st, ContextTracker as t, EditorSelection as tt, LanguageSupport as u, StateField as ut, foldInside as v, fromCodePoint as vt, indentString as w, getIndentUnit as x, foldNodeProp as y, dropCursor as z };