@lezer/common 1.1.2 → 1.2.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/dist/index.cjs CHANGED
@@ -67,6 +67,22 @@ types that represent an expression could be tagged with an
67
67
  */
68
68
  NodeProp.group = new NodeProp({ deserialize: str => str.split(" ") });
69
69
  /**
70
+ Attached to nodes to indicate these should be
71
+ [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
72
+ in a bidirectional text isolate, so that direction-neutral
73
+ characters on their sides don't incorrectly get associated with
74
+ surrounding text. You'll generally want to set this for nodes
75
+ that contain arbitrary text, like strings and comments, and for
76
+ nodes that appear _inside_ arbitrary text, like HTML tags. When
77
+ not given a value, in a grammar declaration, defaults to
78
+ `"auto"`.
79
+ */
80
+ NodeProp.isolate = new NodeProp({ deserialize: value => {
81
+ if (value && value != "rtl" && value != "ltr" && value != "auto")
82
+ throw new RangeError("Invalid value for isolate: " + value);
83
+ return value || "auto";
84
+ } });
85
+ /**
70
86
  The hash of the [context](#lr.ContextTracker.constructor)
71
87
  that the node was parsed in, if any. Used to limit reuse of
72
88
  contextual nodes.
@@ -786,9 +802,11 @@ function getChildren(node, type, before, after) {
786
802
  if (!cur.firstChild())
787
803
  return result;
788
804
  if (before != null)
789
- while (!cur.type.is(before))
805
+ for (let found = false; !found;) {
806
+ found = cur.type.is(before);
790
807
  if (!cur.nextSibling())
791
808
  return result;
809
+ }
792
810
  for (;;) {
793
811
  if (after != null && cur.type.is(after))
794
812
  return result;
package/dist/index.d.cts CHANGED
@@ -284,6 +284,18 @@ declare class NodeProp<T> {
284
284
  */
285
285
  static group: NodeProp<readonly string[]>;
286
286
  /**
287
+ Attached to nodes to indicate these should be
288
+ [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
289
+ in a bidirectional text isolate, so that direction-neutral
290
+ characters on their sides don't incorrectly get associated with
291
+ surrounding text. You'll generally want to set this for nodes
292
+ that contain arbitrary text, like strings and comments, and for
293
+ nodes that appear _inside_ arbitrary text, like HTML tags. When
294
+ not given a value, in a grammar declaration, defaults to
295
+ `"auto"`.
296
+ */
297
+ static isolate: NodeProp<"rtl" | "ltr" | "auto">;
298
+ /**
287
299
  The hash of the [context](#lr.ContextTracker.constructor)
288
300
  that the node was parsed in, if any. Used to limit reuse of
289
301
  contextual nodes.
package/dist/index.d.ts CHANGED
@@ -284,6 +284,18 @@ declare class NodeProp<T> {
284
284
  */
285
285
  static group: NodeProp<readonly string[]>;
286
286
  /**
287
+ Attached to nodes to indicate these should be
288
+ [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
289
+ in a bidirectional text isolate, so that direction-neutral
290
+ characters on their sides don't incorrectly get associated with
291
+ surrounding text. You'll generally want to set this for nodes
292
+ that contain arbitrary text, like strings and comments, and for
293
+ nodes that appear _inside_ arbitrary text, like HTML tags. When
294
+ not given a value, in a grammar declaration, defaults to
295
+ `"auto"`.
296
+ */
297
+ static isolate: NodeProp<"rtl" | "ltr" | "auto">;
298
+ /**
287
299
  The hash of the [context](#lr.ContextTracker.constructor)
288
300
  that the node was parsed in, if any. Used to limit reuse of
289
301
  contextual nodes.
package/dist/index.js CHANGED
@@ -65,6 +65,22 @@ types that represent an expression could be tagged with an
65
65
  */
66
66
  NodeProp.group = new NodeProp({ deserialize: str => str.split(" ") });
67
67
  /**
68
+ Attached to nodes to indicate these should be
69
+ [displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
70
+ in a bidirectional text isolate, so that direction-neutral
71
+ characters on their sides don't incorrectly get associated with
72
+ surrounding text. You'll generally want to set this for nodes
73
+ that contain arbitrary text, like strings and comments, and for
74
+ nodes that appear _inside_ arbitrary text, like HTML tags. When
75
+ not given a value, in a grammar declaration, defaults to
76
+ `"auto"`.
77
+ */
78
+ NodeProp.isolate = new NodeProp({ deserialize: value => {
79
+ if (value && value != "rtl" && value != "ltr" && value != "auto")
80
+ throw new RangeError("Invalid value for isolate: " + value);
81
+ return value || "auto";
82
+ } });
83
+ /**
68
84
  The hash of the [context](#lr.ContextTracker.constructor)
69
85
  that the node was parsed in, if any. Used to limit reuse of
70
86
  contextual nodes.
@@ -784,9 +800,11 @@ function getChildren(node, type, before, after) {
784
800
  if (!cur.firstChild())
785
801
  return result;
786
802
  if (before != null)
787
- while (!cur.type.is(before))
803
+ for (let found = false; !found;) {
804
+ found = cur.type.is(before);
788
805
  if (!cur.nextSibling())
789
806
  return result;
807
+ }
790
808
  for (;;) {
791
809
  if (after != null && cur.type.is(after))
792
810
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lezer/common",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "Syntax tree data structure and parser interfaces for the lezer parser",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",