@codemirror/language 0.20.0 → 0.20.1

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.20.1 (2022-05-18)
2
+
3
+ ### Bug fixes
4
+
5
+ Make sure `all` styles in the CSS generated for a `HighlightStyle` have a lower precedence than the other rules defined for the style. Use a shorthand property
6
+
1
7
  ## 0.20.0 (2022-04-20)
2
8
 
3
9
  ### Breaking changes
package/dist/index.cjs CHANGED
@@ -248,9 +248,6 @@ let currentContext = null;
248
248
  A parse context provided to parsers working on the editor content.
249
249
  */
250
250
  class ParseContext {
251
- /**
252
- @internal
253
- */
254
251
  constructor(parser,
255
252
  /**
256
253
  The current editor state.
@@ -301,6 +298,12 @@ class ParseContext {
301
298
  */
302
299
  this.tempSkipped = [];
303
300
  }
301
+ /**
302
+ @internal
303
+ */
304
+ static create(parser, state, viewport) {
305
+ return new ParseContext(parser, state, [], common.Tree.empty, 0, viewport, [], null);
306
+ }
304
307
  startParse() {
305
308
  return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
306
309
  }
@@ -506,7 +509,7 @@ class LanguageState {
506
509
  }
507
510
  static init(state) {
508
511
  let vpTo = Math.min(3000 /* InitViewport */, state.doc.length);
509
- let parseState = new ParseContext(state.facet(language).parser, state, [], common.Tree.empty, 0, { from: 0, to: vpTo }, [], null);
512
+ let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
510
513
  if (!parseState.work(20 /* Apply */, vpTo))
511
514
  parseState.takeTree();
512
515
  return new LanguageState(parseState);
@@ -934,7 +937,7 @@ function indentFrom(node, pos, base) {
934
937
  for (; node; node = node.parent) {
935
938
  let strategy = indentStrategy(node);
936
939
  if (strategy)
937
- return strategy(new TreeIndentContext(base, pos, node));
940
+ return strategy(TreeIndentContext.create(base, pos, node));
938
941
  }
939
942
  return null;
940
943
  }
@@ -944,9 +947,6 @@ Objects of this type provide context information and helper
944
947
  methods to indentation functions registered on syntax nodes.
945
948
  */
946
949
  class TreeIndentContext extends IndentContext {
947
- /**
948
- @internal
949
- */
950
950
  constructor(base,
951
951
  /**
952
952
  The position at which indentation is being computed.
@@ -963,6 +963,12 @@ class TreeIndentContext extends IndentContext {
963
963
  this.node = node;
964
964
  }
965
965
  /**
966
+ @internal
967
+ */
968
+ static create(base, pos, node) {
969
+ return new TreeIndentContext(base, pos, node);
970
+ }
971
+ /**
966
972
  Get the text directly after `this.pos`, either the entire line
967
973
  or the next 100 characters, whichever is shorter.
968
974
  */
@@ -1478,6 +1484,7 @@ class HighlightStyle {
1478
1484
  (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
1479
1485
  return cls;
1480
1486
  }
1487
+ const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
1481
1488
  const scopeOpt = options.scope;
1482
1489
  this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
1483
1490
  : scopeOpt ? (type) => type == scopeOpt : undefined;
@@ -1485,7 +1492,7 @@ class HighlightStyle {
1485
1492
  tag: style.tag,
1486
1493
  class: style.class || def(Object.assign({}, style, { tag: null }))
1487
1494
  })), {
1488
- all: typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined,
1495
+ all,
1489
1496
  }).style;
1490
1497
  this.module = modSpec ? new styleMod.StyleModule(modSpec) : null;
1491
1498
  this.themeType = options.themeType;
@@ -1804,7 +1811,7 @@ which uses it to tokenize the content.
1804
1811
  */
1805
1812
  class StringStream {
1806
1813
  /**
1807
- @internal
1814
+ Create a stream.
1808
1815
  */
1809
1816
  constructor(
1810
1817
  /**
package/dist/index.d.ts CHANGED
@@ -187,6 +187,7 @@ declare class ParseContext {
187
187
  to: number;
188
188
  };
189
189
  private parse;
190
+ private constructor();
190
191
  private startParse;
191
192
  private withContext;
192
193
  private withoutTempSkipped;
@@ -487,6 +488,7 @@ declare class TreeIndentContext extends IndentContext {
487
488
  applies.
488
489
  */
489
490
  readonly node: SyntaxNode;
491
+ private constructor();
490
492
  /**
491
493
  Get the text directly after `this.pos`, either the entire line
492
494
  or the next 100 characters, whichever is shorter.
@@ -900,6 +902,18 @@ declare class StringStream {
900
902
  private lastColumnPos;
901
903
  private lastColumnValue;
902
904
  /**
905
+ Create a stream.
906
+ */
907
+ constructor(
908
+ /**
909
+ The line.
910
+ */
911
+ string: string, tabSize: number,
912
+ /**
913
+ The current indent unit size.
914
+ */
915
+ indentUnit: number);
916
+ /**
903
917
  True if we are at the end of the line.
904
918
  */
905
919
  eol(): boolean;
package/dist/index.js CHANGED
@@ -244,9 +244,6 @@ let currentContext = null;
244
244
  A parse context provided to parsers working on the editor content.
245
245
  */
246
246
  class ParseContext {
247
- /**
248
- @internal
249
- */
250
247
  constructor(parser,
251
248
  /**
252
249
  The current editor state.
@@ -297,6 +294,12 @@ class ParseContext {
297
294
  */
298
295
  this.tempSkipped = [];
299
296
  }
297
+ /**
298
+ @internal
299
+ */
300
+ static create(parser, state, viewport) {
301
+ return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);
302
+ }
300
303
  startParse() {
301
304
  return this.parser.startParse(new DocInput(this.state.doc), this.fragments);
302
305
  }
@@ -502,7 +505,7 @@ class LanguageState {
502
505
  }
503
506
  static init(state) {
504
507
  let vpTo = Math.min(3000 /* InitViewport */, state.doc.length);
505
- let parseState = new ParseContext(state.facet(language).parser, state, [], Tree.empty, 0, { from: 0, to: vpTo }, [], null);
508
+ let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });
506
509
  if (!parseState.work(20 /* Apply */, vpTo))
507
510
  parseState.takeTree();
508
511
  return new LanguageState(parseState);
@@ -930,7 +933,7 @@ function indentFrom(node, pos, base) {
930
933
  for (; node; node = node.parent) {
931
934
  let strategy = indentStrategy(node);
932
935
  if (strategy)
933
- return strategy(new TreeIndentContext(base, pos, node));
936
+ return strategy(TreeIndentContext.create(base, pos, node));
934
937
  }
935
938
  return null;
936
939
  }
@@ -940,9 +943,6 @@ Objects of this type provide context information and helper
940
943
  methods to indentation functions registered on syntax nodes.
941
944
  */
942
945
  class TreeIndentContext extends IndentContext {
943
- /**
944
- @internal
945
- */
946
946
  constructor(base,
947
947
  /**
948
948
  The position at which indentation is being computed.
@@ -959,6 +959,12 @@ class TreeIndentContext extends IndentContext {
959
959
  this.node = node;
960
960
  }
961
961
  /**
962
+ @internal
963
+ */
964
+ static create(base, pos, node) {
965
+ return new TreeIndentContext(base, pos, node);
966
+ }
967
+ /**
962
968
  Get the text directly after `this.pos`, either the entire line
963
969
  or the next 100 characters, whichever is shorter.
964
970
  */
@@ -1474,6 +1480,7 @@ class HighlightStyle {
1474
1480
  (modSpec || (modSpec = Object.create(null)))["." + cls] = spec;
1475
1481
  return cls;
1476
1482
  }
1483
+ const all = typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined;
1477
1484
  const scopeOpt = options.scope;
1478
1485
  this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data
1479
1486
  : scopeOpt ? (type) => type == scopeOpt : undefined;
@@ -1481,7 +1488,7 @@ class HighlightStyle {
1481
1488
  tag: style.tag,
1482
1489
  class: style.class || def(Object.assign({}, style, { tag: null }))
1483
1490
  })), {
1484
- all: typeof options.all == "string" ? options.all : options.all ? def(options.all) : undefined,
1491
+ all,
1485
1492
  }).style;
1486
1493
  this.module = modSpec ? new StyleModule(modSpec) : null;
1487
1494
  this.themeType = options.themeType;
@@ -1800,7 +1807,7 @@ which uses it to tokenize the content.
1800
1807
  */
1801
1808
  class StringStream {
1802
1809
  /**
1803
- @internal
1810
+ Create a stream.
1804
1811
  */
1805
1812
  constructor(
1806
1813
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/language",
3
- "version": "0.20.0",
3
+ "version": "0.20.1",
4
4
  "description": "Language support infrastructure for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",