@bcts/envelope-pattern 1.0.0-alpha.15 → 1.0.0-alpha.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +485 -485
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +93 -29
  5. package/dist/index.d.cts.map +1 -1
  6. package/dist/index.d.mts +93 -29
  7. package/dist/index.d.mts.map +1 -1
  8. package/dist/index.iife.js +485 -485
  9. package/dist/index.iife.js.map +1 -1
  10. package/dist/index.mjs +504 -504
  11. package/dist/index.mjs.map +1 -1
  12. package/package.json +9 -9
  13. package/src/format.ts +9 -9
  14. package/src/parse/token.ts +55 -55
  15. package/src/pattern/leaf/array-pattern.ts +25 -25
  16. package/src/pattern/leaf/bool-pattern.ts +11 -11
  17. package/src/pattern/leaf/byte-string-pattern.ts +14 -14
  18. package/src/pattern/leaf/cbor-pattern.ts +29 -29
  19. package/src/pattern/leaf/date-pattern.ts +8 -8
  20. package/src/pattern/leaf/known-value-pattern.ts +17 -17
  21. package/src/pattern/leaf/map-pattern.ts +13 -13
  22. package/src/pattern/leaf/null-pattern.ts +7 -7
  23. package/src/pattern/leaf/number-pattern.ts +19 -19
  24. package/src/pattern/leaf/tagged-pattern.ts +20 -20
  25. package/src/pattern/leaf/text-pattern.ts +13 -13
  26. package/src/pattern/meta/and-pattern.ts +11 -11
  27. package/src/pattern/meta/capture-pattern.ts +14 -14
  28. package/src/pattern/meta/group-pattern.ts +13 -13
  29. package/src/pattern/meta/not-pattern.ts +7 -7
  30. package/src/pattern/meta/or-pattern.ts +15 -15
  31. package/src/pattern/meta/search-pattern.ts +15 -15
  32. package/src/pattern/meta/traverse-pattern.ts +15 -15
  33. package/src/pattern/structure/assertions-pattern.ts +28 -28
  34. package/src/pattern/structure/digest-pattern.ts +23 -23
  35. package/src/pattern/structure/node-pattern.ts +17 -17
  36. package/src/pattern/structure/object-pattern.ts +13 -13
  37. package/src/pattern/structure/obscured-pattern.ts +7 -7
  38. package/src/pattern/structure/predicate-pattern.ts +13 -13
  39. package/src/pattern/structure/subject-pattern.ts +15 -15
  40. package/src/pattern/structure/wrapped-pattern.ts +15 -15
@@ -44,10 +44,10 @@ export function registerNumberPatternFactory(factory: (pattern: NumberPattern) =
44
44
  * Corresponds to the Rust `NumberPattern` struct in number_pattern.rs
45
45
  */
46
46
  export class NumberPattern implements Matcher {
47
- readonly #inner: DCBORNumberPattern;
47
+ private readonly _inner: DCBORNumberPattern;
48
48
 
49
49
  private constructor(inner: DCBORNumberPattern) {
50
- this.#inner = inner;
50
+ this._inner = inner;
51
51
  }
52
52
 
53
53
  /**
@@ -131,7 +131,7 @@ export class NumberPattern implements Matcher {
131
131
  * Gets the underlying dcbor-pattern NumberPattern.
132
132
  */
133
133
  get inner(): DCBORNumberPattern {
134
- return this.#inner;
134
+ return this._inner;
135
135
  }
136
136
 
137
137
  pathsWithCaptures(haystack: Envelope): [Path[], Map<string, Path[]>] {
@@ -139,7 +139,7 @@ export class NumberPattern implements Matcher {
139
139
  const cbor = haystack.asLeaf();
140
140
  if (cbor !== undefined) {
141
141
  // Delegate to dcbor-pattern for CBOR matching
142
- const dcborPaths = dcborNumberPatternPaths(this.#inner, cbor);
142
+ const dcborPaths = dcborNumberPatternPaths(this._inner, cbor);
143
143
 
144
144
  // For simple leaf patterns, if dcbor-pattern found matches, return the envelope
145
145
  if (dcborPaths.length > 0) {
@@ -171,7 +171,7 @@ export class NumberPattern implements Matcher {
171
171
  }
172
172
 
173
173
  toString(): string {
174
- return numberPatternDisplay(this.#inner);
174
+ return numberPatternDisplay(this._inner);
175
175
  }
176
176
 
177
177
  /**
@@ -179,10 +179,10 @@ export class NumberPattern implements Matcher {
179
179
  */
180
180
  equals(other: NumberPattern): boolean {
181
181
  // Compare by variant and values
182
- if (this.#inner.variant !== other.#inner.variant) {
182
+ if (this._inner.variant !== other._inner.variant) {
183
183
  return false;
184
184
  }
185
- switch (this.#inner.variant) {
185
+ switch (this._inner.variant) {
186
186
  case "Any":
187
187
  case "NaN":
188
188
  case "Infinity":
@@ -194,14 +194,14 @@ export class NumberPattern implements Matcher {
194
194
  case "LessThan":
195
195
  case "LessThanOrEqual":
196
196
  return (
197
- (this.#inner as { value: number }).value === (other.#inner as { value: number }).value
197
+ (this._inner as { value: number }).value === (other._inner as { value: number }).value
198
198
  );
199
199
  case "Range":
200
200
  return (
201
- (this.#inner as { min: number; max: number }).min ===
202
- (other.#inner as { min: number; max: number }).min &&
203
- (this.#inner as { min: number; max: number }).max ===
204
- (other.#inner as { min: number; max: number }).max
201
+ (this._inner as { min: number; max: number }).min ===
202
+ (other._inner as { min: number; max: number }).min &&
203
+ (this._inner as { min: number; max: number }).max ===
204
+ (other._inner as { min: number; max: number }).max
205
205
  );
206
206
  }
207
207
  }
@@ -211,27 +211,27 @@ export class NumberPattern implements Matcher {
211
211
  */
212
212
  hashCode(): number {
213
213
  let hash = 0;
214
- switch (this.#inner.variant) {
214
+ switch (this._inner.variant) {
215
215
  case "Any":
216
216
  hash = 1;
217
217
  break;
218
218
  case "Value":
219
- hash = 2 * 31 + (this.#inner as { value: number }).value;
219
+ hash = 2 * 31 + (this._inner as { value: number }).value;
220
220
  break;
221
221
  case "Range":
222
- hash = 3 * 31 + (this.#inner as { min: number }).min + (this.#inner as { max: number }).max;
222
+ hash = 3 * 31 + (this._inner as { min: number }).min + (this._inner as { max: number }).max;
223
223
  break;
224
224
  case "GreaterThan":
225
- hash = 4 * 31 + (this.#inner as { value: number }).value;
225
+ hash = 4 * 31 + (this._inner as { value: number }).value;
226
226
  break;
227
227
  case "GreaterThanOrEqual":
228
- hash = 5 * 31 + (this.#inner as { value: number }).value;
228
+ hash = 5 * 31 + (this._inner as { value: number }).value;
229
229
  break;
230
230
  case "LessThan":
231
- hash = 6 * 31 + (this.#inner as { value: number }).value;
231
+ hash = 6 * 31 + (this._inner as { value: number }).value;
232
232
  break;
233
233
  case "LessThanOrEqual":
234
- hash = 7 * 31 + (this.#inner as { value: number }).value;
234
+ hash = 7 * 31 + (this._inner as { value: number }).value;
235
235
  break;
236
236
  case "NaN":
237
237
  hash = 8;
@@ -41,10 +41,10 @@ export function registerTaggedPatternFactory(factory: (pattern: TaggedPattern) =
41
41
  * Corresponds to the Rust `TaggedPattern` struct in tagged_pattern.rs
42
42
  */
43
43
  export class TaggedPattern implements Matcher {
44
- readonly #inner: DCBORTaggedPattern;
44
+ private readonly _inner: DCBORTaggedPattern;
45
45
 
46
46
  private constructor(inner: DCBORTaggedPattern) {
47
- this.#inner = inner;
47
+ this._inner = inner;
48
48
  }
49
49
 
50
50
  /**
@@ -86,7 +86,7 @@ export class TaggedPattern implements Matcher {
86
86
  * Gets the underlying dcbor-pattern TaggedPattern.
87
87
  */
88
88
  get inner(): DCBORTaggedPattern {
89
- return this.#inner;
89
+ return this._inner;
90
90
  }
91
91
 
92
92
  pathsWithCaptures(haystack: Envelope): [Path[], Map<string, Path[]>] {
@@ -96,7 +96,7 @@ export class TaggedPattern implements Matcher {
96
96
 
97
97
  if (cbor !== undefined) {
98
98
  // Delegate to dcbor-pattern for CBOR matching
99
- const [dcborPaths, dcborCaptures] = taggedPatternPathsWithCaptures(this.#inner, cbor);
99
+ const [dcborPaths, dcborCaptures] = taggedPatternPathsWithCaptures(this._inner, cbor);
100
100
 
101
101
  if (dcborPaths.length > 0) {
102
102
  // Convert dcbor paths to envelope paths
@@ -155,7 +155,7 @@ export class TaggedPattern implements Matcher {
155
155
  }
156
156
 
157
157
  toString(): string {
158
- return taggedPatternDisplay(this.#inner, patternDisplay);
158
+ return taggedPatternDisplay(this._inner, patternDisplay);
159
159
  }
160
160
 
161
161
  /**
@@ -163,35 +163,35 @@ export class TaggedPattern implements Matcher {
163
163
  */
164
164
  equals(other: TaggedPattern): boolean {
165
165
  // Compare by variant type and values
166
- if (this.#inner.variant !== other.#inner.variant) {
166
+ if (this._inner.variant !== other._inner.variant) {
167
167
  return false;
168
168
  }
169
- switch (this.#inner.variant) {
169
+ switch (this._inner.variant) {
170
170
  case "Any":
171
171
  return true;
172
172
  case "Tag": {
173
- const otherTag = other.#inner as { variant: "Tag"; tag: Tag; pattern: DCBORPattern };
173
+ const otherTag = other._inner as { variant: "Tag"; tag: Tag; pattern: DCBORPattern };
174
174
  return (
175
- this.#inner.tag.value === otherTag.tag.value &&
176
- patternDisplay(this.#inner.pattern) === patternDisplay(otherTag.pattern)
175
+ this._inner.tag.value === otherTag.tag.value &&
176
+ patternDisplay(this._inner.pattern) === patternDisplay(otherTag.pattern)
177
177
  );
178
178
  }
179
179
  case "Name": {
180
- const otherName = other.#inner as { variant: "Name"; name: string; pattern: DCBORPattern };
180
+ const otherName = other._inner as { variant: "Name"; name: string; pattern: DCBORPattern };
181
181
  return (
182
- this.#inner.name === otherName.name &&
183
- patternDisplay(this.#inner.pattern) === patternDisplay(otherName.pattern)
182
+ this._inner.name === otherName.name &&
183
+ patternDisplay(this._inner.pattern) === patternDisplay(otherName.pattern)
184
184
  );
185
185
  }
186
186
  case "Regex": {
187
- const otherRegex = other.#inner as {
187
+ const otherRegex = other._inner as {
188
188
  variant: "Regex";
189
189
  regex: RegExp;
190
190
  pattern: DCBORPattern;
191
191
  };
192
192
  return (
193
- this.#inner.regex.source === otherRegex.regex.source &&
194
- patternDisplay(this.#inner.pattern) === patternDisplay(otherRegex.pattern)
193
+ this._inner.regex.source === otherRegex.regex.source &&
194
+ patternDisplay(this._inner.pattern) === patternDisplay(otherRegex.pattern)
195
195
  );
196
196
  }
197
197
  }
@@ -201,15 +201,15 @@ export class TaggedPattern implements Matcher {
201
201
  * Hash code for use in Maps/Sets.
202
202
  */
203
203
  hashCode(): number {
204
- switch (this.#inner.variant) {
204
+ switch (this._inner.variant) {
205
205
  case "Any":
206
206
  return 0;
207
207
  case "Tag":
208
- return Number(BigInt(this.#inner.tag.value) & BigInt(0xffffffff));
208
+ return Number(BigInt(this._inner.tag.value) & BigInt(0xffffffff));
209
209
  case "Name":
210
- return simpleStringHash(this.#inner.name);
210
+ return simpleStringHash(this._inner.name);
211
211
  case "Regex":
212
- return simpleStringHash(this.#inner.regex.source);
212
+ return simpleStringHash(this._inner.regex.source);
213
213
  }
214
214
  }
215
215
  }
@@ -37,10 +37,10 @@ export function registerTextPatternFactory(factory: (pattern: TextPattern) => Pa
37
37
  * Corresponds to the Rust `TextPattern` struct in text_pattern.rs
38
38
  */
39
39
  export class TextPattern implements Matcher {
40
- readonly #inner: DCBORTextPattern;
40
+ private readonly _inner: DCBORTextPattern;
41
41
 
42
42
  private constructor(inner: DCBORTextPattern) {
43
- this.#inner = inner;
43
+ this._inner = inner;
44
44
  }
45
45
 
46
46
  /**
@@ -75,7 +75,7 @@ export class TextPattern implements Matcher {
75
75
  * Gets the underlying dcbor-pattern TextPattern.
76
76
  */
77
77
  get inner(): DCBORTextPattern {
78
- return this.#inner;
78
+ return this._inner;
79
79
  }
80
80
 
81
81
  pathsWithCaptures(haystack: Envelope): [Path[], Map<string, Path[]>] {
@@ -83,7 +83,7 @@ export class TextPattern implements Matcher {
83
83
  const cbor = haystack.asLeaf();
84
84
  if (cbor !== undefined) {
85
85
  // Delegate to dcbor-pattern for CBOR matching
86
- const dcborPaths = dcborTextPatternPaths(this.#inner, cbor);
86
+ const dcborPaths = dcborTextPatternPaths(this._inner, cbor);
87
87
 
88
88
  // For simple leaf patterns, if dcbor-pattern found matches, return the envelope
89
89
  if (dcborPaths.length > 0) {
@@ -115,27 +115,27 @@ export class TextPattern implements Matcher {
115
115
  }
116
116
 
117
117
  toString(): string {
118
- return textPatternDisplay(this.#inner);
118
+ return textPatternDisplay(this._inner);
119
119
  }
120
120
 
121
121
  /**
122
122
  * Equality comparison.
123
123
  */
124
124
  equals(other: TextPattern): boolean {
125
- if (this.#inner.variant !== other.#inner.variant) {
125
+ if (this._inner.variant !== other._inner.variant) {
126
126
  return false;
127
127
  }
128
- switch (this.#inner.variant) {
128
+ switch (this._inner.variant) {
129
129
  case "Any":
130
130
  return true;
131
131
  case "Value":
132
132
  return (
133
- (this.#inner as { value: string }).value === (other.#inner as { value: string }).value
133
+ (this._inner as { value: string }).value === (other._inner as { value: string }).value
134
134
  );
135
135
  case "Regex":
136
136
  return (
137
- (this.#inner as { pattern: RegExp }).pattern.source ===
138
- (other.#inner as { pattern: RegExp }).pattern.source
137
+ (this._inner as { pattern: RegExp }).pattern.source ===
138
+ (other._inner as { pattern: RegExp }).pattern.source
139
139
  );
140
140
  }
141
141
  }
@@ -145,19 +145,19 @@ export class TextPattern implements Matcher {
145
145
  */
146
146
  hashCode(): number {
147
147
  let hash = 0;
148
- switch (this.#inner.variant) {
148
+ switch (this._inner.variant) {
149
149
  case "Any":
150
150
  hash = 1;
151
151
  break;
152
152
  case "Value": {
153
- const val = (this.#inner as { value: string }).value;
153
+ const val = (this._inner as { value: string }).value;
154
154
  for (let i = 0; i < val.length; i++) {
155
155
  hash = hash * 31 + val.charCodeAt(i);
156
156
  }
157
157
  break;
158
158
  }
159
159
  case "Regex":
160
- hash = 3 * 31 + (this.#inner as { pattern: RegExp }).pattern.source.length;
160
+ hash = 3 * 31 + (this._inner as { pattern: RegExp }).pattern.source.length;
161
161
  break;
162
162
  }
163
163
  return hash;
@@ -25,10 +25,10 @@ export function registerAndPatternFactory(factory: (pattern: AndPattern) => Patt
25
25
  * Corresponds to the Rust `AndPattern` struct in and_pattern.rs
26
26
  */
27
27
  export class AndPattern implements Matcher {
28
- readonly #patterns: Pattern[];
28
+ private readonly _patterns: Pattern[];
29
29
 
30
30
  private constructor(patterns: Pattern[]) {
31
- this.#patterns = patterns;
31
+ this._patterns = patterns;
32
32
  }
33
33
 
34
34
  /**
@@ -42,11 +42,11 @@ export class AndPattern implements Matcher {
42
42
  * Gets the patterns.
43
43
  */
44
44
  patterns(): Pattern[] {
45
- return this.#patterns;
45
+ return this._patterns;
46
46
  }
47
47
 
48
48
  pathsWithCaptures(haystack: Envelope): [Path[], Map<string, Path[]>] {
49
- const allMatch = this.#patterns.every((pattern) => matchPattern(pattern, haystack));
49
+ const allMatch = this._patterns.every((pattern) => matchPattern(pattern, haystack));
50
50
 
51
51
  const paths = allMatch ? [[haystack]] : [];
52
52
  return [paths, new Map<string, Path[]>()];
@@ -62,7 +62,7 @@ export class AndPattern implements Matcher {
62
62
 
63
63
  compile(code: Instr[], literals: Pattern[], captures: string[]): void {
64
64
  // Each pattern must match at this position
65
- for (const pattern of this.#patterns) {
65
+ for (const pattern of this._patterns) {
66
66
  const matcher = pattern as unknown as Matcher;
67
67
  matcher.compile(code, literals, captures);
68
68
  }
@@ -72,12 +72,12 @@ export class AndPattern implements Matcher {
72
72
  // The pattern is complex if it contains more than one pattern, or if
73
73
  // the one pattern is complex itself.
74
74
  return (
75
- this.#patterns.length > 1 || this.#patterns.some((p) => (p as unknown as Matcher).isComplex())
75
+ this._patterns.length > 1 || this._patterns.some((p) => (p as unknown as Matcher).isComplex())
76
76
  );
77
77
  }
78
78
 
79
79
  toString(): string {
80
- return this.#patterns
80
+ return this._patterns
81
81
  .map((p) => (p as unknown as { toString(): string }).toString())
82
82
  .join(" & ");
83
83
  }
@@ -86,11 +86,11 @@ export class AndPattern implements Matcher {
86
86
  * Equality comparison.
87
87
  */
88
88
  equals(other: AndPattern): boolean {
89
- if (this.#patterns.length !== other.#patterns.length) {
89
+ if (this._patterns.length !== other._patterns.length) {
90
90
  return false;
91
91
  }
92
- for (let i = 0; i < this.#patterns.length; i++) {
93
- if (this.#patterns[i] !== other.#patterns[i]) {
92
+ for (let i = 0; i < this._patterns.length; i++) {
93
+ if (this._patterns[i] !== other._patterns[i]) {
94
94
  return false;
95
95
  }
96
96
  }
@@ -101,6 +101,6 @@ export class AndPattern implements Matcher {
101
101
  * Hash code for use in Maps/Sets.
102
102
  */
103
103
  hashCode(): number {
104
- return this.#patterns.length;
104
+ return this._patterns.length;
105
105
  }
106
106
  }
@@ -25,12 +25,12 @@ export function registerCapturePatternFactory(factory: (pattern: CapturePattern)
25
25
  * Corresponds to the Rust `CapturePattern` struct in capture_pattern.rs
26
26
  */
27
27
  export class CapturePattern implements Matcher {
28
- readonly #name: string;
29
- readonly #pattern: Pattern;
28
+ private readonly _name: string;
29
+ private readonly _pattern: Pattern;
30
30
 
31
31
  private constructor(name: string, pattern: Pattern) {
32
- this.#name = name;
33
- this.#pattern = pattern;
32
+ this._name = name;
33
+ this._pattern = pattern;
34
34
  }
35
35
 
36
36
  /**
@@ -44,23 +44,23 @@ export class CapturePattern implements Matcher {
44
44
  * Gets the name of the capture.
45
45
  */
46
46
  name(): string {
47
- return this.#name;
47
+ return this._name;
48
48
  }
49
49
 
50
50
  /**
51
51
  * Gets the inner pattern.
52
52
  */
53
53
  pattern(): Pattern {
54
- return this.#pattern;
54
+ return this._pattern;
55
55
  }
56
56
 
57
57
  pathsWithCaptures(haystack: Envelope): [Path[], Map<string, Path[]>] {
58
- const matcher = this.#pattern as unknown as Matcher;
58
+ const matcher = this._pattern as unknown as Matcher;
59
59
  const [paths, caps] = matcher.pathsWithCaptures(haystack);
60
60
 
61
61
  if (paths.length > 0) {
62
- const existing = caps.get(this.#name) ?? [];
63
- caps.set(this.#name, [...existing, ...paths]);
62
+ const existing = caps.get(this._name) ?? [];
63
+ caps.set(this._name, [...existing, ...paths]);
64
64
  }
65
65
 
66
66
  return [paths, caps];
@@ -76,9 +76,9 @@ export class CapturePattern implements Matcher {
76
76
 
77
77
  compile(code: Instr[], literals: Pattern[], captures: string[]): void {
78
78
  const id = captures.length;
79
- captures.push(this.#name);
79
+ captures.push(this._name);
80
80
  code.push({ type: "CaptureStart", captureIndex: id });
81
- const matcher = this.#pattern as unknown as Matcher;
81
+ const matcher = this._pattern as unknown as Matcher;
82
82
  matcher.compile(code, literals, captures);
83
83
  code.push({ type: "CaptureEnd", captureIndex: id });
84
84
  }
@@ -88,14 +88,14 @@ export class CapturePattern implements Matcher {
88
88
  }
89
89
 
90
90
  toString(): string {
91
- return `@${this.#name}(${(this.#pattern as unknown as { toString(): string }).toString()})`;
91
+ return `@${this._name}(${(this._pattern as unknown as { toString(): string }).toString()})`;
92
92
  }
93
93
 
94
94
  /**
95
95
  * Equality comparison.
96
96
  */
97
97
  equals(other: CapturePattern): boolean {
98
- return this.#name === other.#name && this.#pattern === other.#pattern;
98
+ return this._name === other._name && this._pattern === other._pattern;
99
99
  }
100
100
 
101
101
  /**
@@ -103,7 +103,7 @@ export class CapturePattern implements Matcher {
103
103
  */
104
104
  hashCode(): number {
105
105
  let hash = 0;
106
- for (const char of this.#name) {
106
+ for (const char of this._name) {
107
107
  hash = (hash * 31 + char.charCodeAt(0)) | 0;
108
108
  }
109
109
  return hash;
@@ -26,12 +26,12 @@ export function registerGroupPatternFactory(factory: (pattern: GroupPattern) =>
26
26
  * Corresponds to the Rust `GroupPattern` struct in repeat_pattern.rs
27
27
  */
28
28
  export class GroupPattern implements Matcher {
29
- readonly #pattern: Pattern;
30
- readonly #quantifier: Quantifier;
29
+ private readonly _pattern: Pattern;
30
+ private readonly _quantifier: Quantifier;
31
31
 
32
32
  private constructor(pattern: Pattern, quantifier: Quantifier) {
33
- this.#pattern = pattern;
34
- this.#quantifier = quantifier;
33
+ this._pattern = pattern;
34
+ this._quantifier = quantifier;
35
35
  }
36
36
 
37
37
  /**
@@ -52,14 +52,14 @@ export class GroupPattern implements Matcher {
52
52
  * Gets the sub-pattern of this group pattern.
53
53
  */
54
54
  pattern(): Pattern {
55
- return this.#pattern;
55
+ return this._pattern;
56
56
  }
57
57
 
58
58
  /**
59
59
  * Gets the quantifier of this group pattern.
60
60
  */
61
61
  quantifier(): Quantifier {
62
- return this.#quantifier;
62
+ return this._quantifier;
63
63
  }
64
64
 
65
65
  pathsWithCaptures(_haystack: Envelope): [Path[], Map<string, Path[]>] {
@@ -74,14 +74,14 @@ export class GroupPattern implements Matcher {
74
74
 
75
75
  matches(haystack: Envelope): boolean {
76
76
  // GroupPattern needs VM execution
77
- const matcher = this.#pattern as unknown as Matcher;
77
+ const matcher = this._pattern as unknown as Matcher;
78
78
  return matcher.matches(haystack);
79
79
  }
80
80
 
81
81
  compile(code: Instr[], literals: Pattern[], _captures: string[]): void {
82
82
  const idx = literals.length;
83
- literals.push(this.#pattern);
84
- code.push({ type: "Repeat", patternIndex: idx, quantifier: this.#quantifier });
83
+ literals.push(this._pattern);
84
+ code.push({ type: "Repeat", patternIndex: idx, quantifier: this._quantifier });
85
85
  }
86
86
 
87
87
  isComplex(): boolean {
@@ -89,15 +89,15 @@ export class GroupPattern implements Matcher {
89
89
  }
90
90
 
91
91
  toString(): string {
92
- const formattedRange = this.#quantifier.toString();
93
- return `(${(this.#pattern as unknown as { toString(): string }).toString()})${formattedRange}`;
92
+ const formattedRange = this._quantifier.toString();
93
+ return `(${(this._pattern as unknown as { toString(): string }).toString()})${formattedRange}`;
94
94
  }
95
95
 
96
96
  /**
97
97
  * Equality comparison.
98
98
  */
99
99
  equals(other: GroupPattern): boolean {
100
- return this.#pattern === other.#pattern && this.#quantifier.equals(other.#quantifier);
100
+ return this._pattern === other._pattern && this._quantifier.equals(other._quantifier);
101
101
  }
102
102
 
103
103
  /**
@@ -105,6 +105,6 @@ export class GroupPattern implements Matcher {
105
105
  */
106
106
  hashCode(): number {
107
107
  // Simple hash based on quantifier min/max
108
- return this.#quantifier.min() * 31 + (this.#quantifier.max() ?? 0);
108
+ return this._quantifier.min() * 31 + (this._quantifier.max() ?? 0);
109
109
  }
110
110
  }
@@ -25,10 +25,10 @@ export function registerNotPatternFactory(factory: (pattern: NotPattern) => Patt
25
25
  * Corresponds to the Rust `NotPattern` struct in not_pattern.rs
26
26
  */
27
27
  export class NotPattern implements Matcher {
28
- readonly #pattern: Pattern;
28
+ private readonly _pattern: Pattern;
29
29
 
30
30
  private constructor(pattern: Pattern) {
31
- this.#pattern = pattern;
31
+ this._pattern = pattern;
32
32
  }
33
33
 
34
34
  /**
@@ -42,12 +42,12 @@ export class NotPattern implements Matcher {
42
42
  * Gets the inner pattern.
43
43
  */
44
44
  pattern(): Pattern {
45
- return this.#pattern;
45
+ return this._pattern;
46
46
  }
47
47
 
48
48
  pathsWithCaptures(haystack: Envelope): [Path[], Map<string, Path[]>] {
49
49
  // If the inner pattern doesn't match, then we return the current envelope as a match
50
- const paths = !matchPattern(this.#pattern, haystack) ? [[haystack]] : [];
50
+ const paths = !matchPattern(this._pattern, haystack) ? [[haystack]] : [];
51
51
  return [paths, new Map<string, Path[]>()];
52
52
  }
53
53
 
@@ -62,7 +62,7 @@ export class NotPattern implements Matcher {
62
62
  compile(code: Instr[], literals: Pattern[], _captures: string[]): void {
63
63
  // NOT = check that pattern doesn't match
64
64
  const idx = literals.length;
65
- literals.push(this.#pattern);
65
+ literals.push(this._pattern);
66
66
  code.push({ type: "NotMatch", patternIndex: idx });
67
67
  }
68
68
 
@@ -71,14 +71,14 @@ export class NotPattern implements Matcher {
71
71
  }
72
72
 
73
73
  toString(): string {
74
- return `!${(this.#pattern as unknown as { toString(): string }).toString()}`;
74
+ return `!${(this._pattern as unknown as { toString(): string }).toString()}`;
75
75
  }
76
76
 
77
77
  /**
78
78
  * Equality comparison.
79
79
  */
80
80
  equals(other: NotPattern): boolean {
81
- return this.#pattern === other.#pattern;
81
+ return this._pattern === other._pattern;
82
82
  }
83
83
 
84
84
  /**