@bcts/envelope-pattern 1.0.0-alpha.16 → 1.0.0-alpha.18
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/README.md +1 -1
- package/dist/index.cjs +1992 -1714
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +147 -31
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +147 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +1984 -1707
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +1966 -1698
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
- package/src/format.ts +32 -13
- package/src/parse/index.ts +138 -5
- package/src/parse/token.ts +59 -58
- package/src/pattern/index.ts +110 -2
- package/src/pattern/leaf/array-pattern.ts +26 -26
- package/src/pattern/leaf/bool-pattern.ts +12 -12
- package/src/pattern/leaf/byte-string-pattern.ts +15 -15
- package/src/pattern/leaf/cbor-pattern.ts +31 -31
- package/src/pattern/leaf/date-pattern.ts +9 -9
- package/src/pattern/leaf/index.ts +1 -2
- package/src/pattern/leaf/known-value-pattern.ts +21 -20
- package/src/pattern/leaf/map-pattern.ts +14 -14
- package/src/pattern/leaf/null-pattern.ts +8 -8
- package/src/pattern/leaf/number-pattern.ts +20 -20
- package/src/pattern/leaf/tagged-pattern.ts +20 -20
- package/src/pattern/leaf/text-pattern.ts +14 -14
- package/src/pattern/matcher.ts +88 -3
- package/src/pattern/meta/and-pattern.ts +19 -18
- package/src/pattern/meta/capture-pattern.ts +16 -17
- package/src/pattern/meta/group-pattern.ts +20 -17
- package/src/pattern/meta/not-pattern.ts +9 -8
- package/src/pattern/meta/or-pattern.ts +30 -25
- package/src/pattern/meta/search-pattern.ts +17 -17
- package/src/pattern/meta/traverse-pattern.ts +42 -18
- package/src/pattern/structure/assertions-pattern.ts +31 -32
- package/src/pattern/structure/digest-pattern.ts +23 -23
- package/src/pattern/structure/index.ts +1 -0
- package/src/pattern/structure/node-pattern.ts +17 -17
- package/src/pattern/structure/object-pattern.ts +14 -15
- package/src/pattern/structure/obscured-pattern.ts +7 -7
- package/src/pattern/structure/predicate-pattern.ts +14 -15
- package/src/pattern/structure/subject-pattern.ts +16 -17
- package/src/pattern/structure/wrapped-pattern.ts +40 -19
- package/src/pattern/vm.ts +12 -11
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,6 @@ import { Cbor, CborDate, CborInput, Tag } from "@bcts/dcbor";
|
|
|
4
4
|
import { KnownValue } from "@bcts/known-values";
|
|
5
5
|
|
|
6
6
|
//#region src/parse/token.d.ts
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Token types for the Gordian Envelope pattern syntax.
|
|
10
9
|
*
|
|
@@ -152,12 +151,18 @@ type Token = {
|
|
|
152
151
|
} | {
|
|
153
152
|
readonly type: "SingleQuotedRegex";
|
|
154
153
|
readonly value: Result<string>;
|
|
154
|
+
} | {
|
|
155
|
+
readonly type: "Identifier";
|
|
156
|
+
readonly value: string;
|
|
155
157
|
};
|
|
156
158
|
/**
|
|
157
159
|
* Lexer for Gordian Envelope pattern syntax.
|
|
158
160
|
*/
|
|
159
161
|
declare class Lexer {
|
|
160
|
-
|
|
162
|
+
private readonly _source;
|
|
163
|
+
private _position;
|
|
164
|
+
private _tokenStart;
|
|
165
|
+
private _peekedToken;
|
|
161
166
|
constructor(source: string);
|
|
162
167
|
/**
|
|
163
168
|
* Gets the current position in the source.
|
|
@@ -190,6 +195,46 @@ declare class Lexer {
|
|
|
190
195
|
* Advances the position by n characters.
|
|
191
196
|
*/
|
|
192
197
|
bump(n?: number): void;
|
|
198
|
+
/**
|
|
199
|
+
* Skips whitespace.
|
|
200
|
+
*/
|
|
201
|
+
private _skipWhitespace;
|
|
202
|
+
/**
|
|
203
|
+
* Parses a string literal (after the opening quote).
|
|
204
|
+
*/
|
|
205
|
+
private _parseStringLiteral;
|
|
206
|
+
/**
|
|
207
|
+
* Parses a regex pattern (after the opening slash).
|
|
208
|
+
*/
|
|
209
|
+
private _parseRegex;
|
|
210
|
+
/**
|
|
211
|
+
* Parses a hex pattern (after h').
|
|
212
|
+
*/
|
|
213
|
+
private _parseHexPattern;
|
|
214
|
+
/**
|
|
215
|
+
* Parses a hex binary regex (after h'/).
|
|
216
|
+
*/
|
|
217
|
+
private _parseHexBinaryRegex;
|
|
218
|
+
/**
|
|
219
|
+
* Parses a date pattern (after date').
|
|
220
|
+
*/
|
|
221
|
+
private _parseDatePattern;
|
|
222
|
+
/**
|
|
223
|
+
* Parses a range pattern (after {).
|
|
224
|
+
*/
|
|
225
|
+
private _parseRange;
|
|
226
|
+
/**
|
|
227
|
+
* Parses a single quoted pattern (after ').
|
|
228
|
+
*/
|
|
229
|
+
private _parseSingleQuotedPattern;
|
|
230
|
+
/**
|
|
231
|
+
* Parses a single quoted regex (after '/).
|
|
232
|
+
*/
|
|
233
|
+
private _parseSingleQuotedRegex;
|
|
234
|
+
/**
|
|
235
|
+
* Parses a number (integer or float).
|
|
236
|
+
*/
|
|
237
|
+
private _parseNumber;
|
|
193
238
|
/**
|
|
194
239
|
* Gets the next token from the input.
|
|
195
240
|
*/
|
|
@@ -431,7 +476,9 @@ declare function defaultFormatPathsOpts(): FormatPathsOpts;
|
|
|
431
476
|
* Builder for FormatPathsOpts.
|
|
432
477
|
*/
|
|
433
478
|
declare class FormatPathsOptsBuilder {
|
|
434
|
-
|
|
479
|
+
private _indent;
|
|
480
|
+
private _elementFormat;
|
|
481
|
+
private _lastElementOnly;
|
|
435
482
|
/**
|
|
436
483
|
* Sets whether to indent each path element.
|
|
437
484
|
*/
|
|
@@ -657,11 +704,42 @@ declare function compileAsAtomic(pat: Pattern, code: Instr[], literals: Pattern[
|
|
|
657
704
|
* Called from index.ts after all patterns are defined.
|
|
658
705
|
*/
|
|
659
706
|
declare function registerPatternMatchFn(fn: (pattern: Pattern, haystack: Envelope) => boolean): void;
|
|
707
|
+
/**
|
|
708
|
+
* Registers all pattern dispatch functions.
|
|
709
|
+
* Called from index.ts after all patterns are defined.
|
|
710
|
+
*/
|
|
711
|
+
declare function registerPatternDispatchFns(fns: {
|
|
712
|
+
pathsWithCaptures: (pattern: Pattern, haystack: Envelope) => [Path[], Map<string, Path[]>];
|
|
713
|
+
paths: (pattern: Pattern, haystack: Envelope) => Path[];
|
|
714
|
+
compile: (pattern: Pattern, code: Instr[], literals: Pattern[], captures: string[]) => void;
|
|
715
|
+
isComplex: (pattern: Pattern) => boolean;
|
|
716
|
+
toString: (pattern: Pattern) => string;
|
|
717
|
+
}): void;
|
|
660
718
|
/**
|
|
661
719
|
* Match a pattern against an envelope using the registered match function.
|
|
662
720
|
* Used by meta patterns to match child patterns.
|
|
663
721
|
*/
|
|
664
722
|
declare function matchPattern(pattern: Pattern, haystack: Envelope): boolean;
|
|
723
|
+
/**
|
|
724
|
+
* Dispatch pathsWithCaptures on a Pattern.
|
|
725
|
+
*/
|
|
726
|
+
declare function dispatchPathsWithCaptures(pattern: Pattern, haystack: Envelope): [Path[], Map<string, Path[]>];
|
|
727
|
+
/**
|
|
728
|
+
* Dispatch paths on a Pattern.
|
|
729
|
+
*/
|
|
730
|
+
declare function dispatchPaths(pattern: Pattern, haystack: Envelope): Path[];
|
|
731
|
+
/**
|
|
732
|
+
* Dispatch compile on a Pattern.
|
|
733
|
+
*/
|
|
734
|
+
declare function dispatchCompile(pattern: Pattern, code: Instr[], literals: Pattern[], captures: string[]): void;
|
|
735
|
+
/**
|
|
736
|
+
* Dispatch isComplex on a Pattern.
|
|
737
|
+
*/
|
|
738
|
+
declare function dispatchIsComplex(pattern: Pattern): boolean;
|
|
739
|
+
/**
|
|
740
|
+
* Dispatch toString on a Pattern.
|
|
741
|
+
*/
|
|
742
|
+
declare function dispatchPatternToString(pattern: Pattern): string;
|
|
665
743
|
//#endregion
|
|
666
744
|
//#region src/pattern/leaf/bool-pattern.d.ts
|
|
667
745
|
declare function registerBoolPatternFactory(factory: (pattern: BoolPattern) => Pattern): void;
|
|
@@ -674,7 +752,7 @@ declare function registerBoolPatternFactory(factory: (pattern: BoolPattern) => P
|
|
|
674
752
|
* Corresponds to the Rust `BoolPattern` struct in bool_pattern.rs
|
|
675
753
|
*/
|
|
676
754
|
declare class BoolPattern implements Matcher {
|
|
677
|
-
|
|
755
|
+
private readonly _inner;
|
|
678
756
|
private constructor();
|
|
679
757
|
/**
|
|
680
758
|
* Creates a new BoolPattern that matches any boolean value.
|
|
@@ -719,7 +797,8 @@ declare function registerNullPatternFactory(factory: (pattern: NullPattern) => P
|
|
|
719
797
|
* Corresponds to the Rust `NullPattern` struct in null_pattern.rs
|
|
720
798
|
*/
|
|
721
799
|
declare class NullPattern implements Matcher {
|
|
722
|
-
|
|
800
|
+
private readonly _inner;
|
|
801
|
+
private static readonly _instance;
|
|
723
802
|
private constructor();
|
|
724
803
|
/**
|
|
725
804
|
* Creates a new NullPattern (returns singleton).
|
|
@@ -756,7 +835,7 @@ declare function registerNumberPatternFactory(factory: (pattern: NumberPattern)
|
|
|
756
835
|
* Corresponds to the Rust `NumberPattern` struct in number_pattern.rs
|
|
757
836
|
*/
|
|
758
837
|
declare class NumberPattern implements Matcher {
|
|
759
|
-
|
|
838
|
+
private readonly _inner;
|
|
760
839
|
private constructor();
|
|
761
840
|
/**
|
|
762
841
|
* Creates a new NumberPattern that matches any number.
|
|
@@ -833,7 +912,7 @@ declare function registerTextPatternFactory(factory: (pattern: TextPattern) => P
|
|
|
833
912
|
* Corresponds to the Rust `TextPattern` struct in text_pattern.rs
|
|
834
913
|
*/
|
|
835
914
|
declare class TextPattern implements Matcher {
|
|
836
|
-
|
|
915
|
+
private readonly _inner;
|
|
837
916
|
private constructor();
|
|
838
917
|
/**
|
|
839
918
|
* Creates a new TextPattern that matches any text.
|
|
@@ -882,7 +961,7 @@ declare function registerByteStringPatternFactory(factory: (pattern: ByteStringP
|
|
|
882
961
|
* Corresponds to the Rust `ByteStringPattern` struct in byte_string_pattern.rs
|
|
883
962
|
*/
|
|
884
963
|
declare class ByteStringPattern implements Matcher {
|
|
885
|
-
|
|
964
|
+
private readonly _inner;
|
|
886
965
|
private constructor();
|
|
887
966
|
/**
|
|
888
967
|
* Creates a new ByteStringPattern that matches any byte string.
|
|
@@ -931,7 +1010,7 @@ declare function registerDatePatternFactory(factory: (pattern: DatePattern) => P
|
|
|
931
1010
|
* Corresponds to the Rust `DatePattern` struct in date_pattern.rs
|
|
932
1011
|
*/
|
|
933
1012
|
declare class DatePattern implements Matcher {
|
|
934
|
-
|
|
1013
|
+
private readonly _inner;
|
|
935
1014
|
private constructor();
|
|
936
1015
|
/**
|
|
937
1016
|
* Creates a new DatePattern that matches any date.
|
|
@@ -1011,7 +1090,7 @@ type ArrayPatternType = {
|
|
|
1011
1090
|
* Corresponds to the Rust `ArrayPattern` struct in array_pattern.rs
|
|
1012
1091
|
*/
|
|
1013
1092
|
declare class ArrayPattern implements Matcher {
|
|
1014
|
-
|
|
1093
|
+
private readonly _pattern;
|
|
1015
1094
|
private constructor();
|
|
1016
1095
|
/**
|
|
1017
1096
|
* Creates a new ArrayPattern that matches any array.
|
|
@@ -1072,7 +1151,7 @@ type MapPatternType = {
|
|
|
1072
1151
|
* Corresponds to the Rust `MapPattern` struct in map_pattern.rs
|
|
1073
1152
|
*/
|
|
1074
1153
|
declare class MapPattern implements Matcher {
|
|
1075
|
-
|
|
1154
|
+
private readonly _pattern;
|
|
1076
1155
|
private constructor();
|
|
1077
1156
|
/**
|
|
1078
1157
|
* Creates a new MapPattern that matches any map.
|
|
@@ -1113,7 +1192,7 @@ declare function registerKnownValuePatternFactory(factory: (pattern: KnownValueP
|
|
|
1113
1192
|
* Corresponds to the Rust `KnownValuePattern` struct in known_value_pattern.rs
|
|
1114
1193
|
*/
|
|
1115
1194
|
declare class KnownValuePattern implements Matcher {
|
|
1116
|
-
|
|
1195
|
+
private readonly _inner;
|
|
1117
1196
|
private constructor();
|
|
1118
1197
|
/**
|
|
1119
1198
|
* Creates a new KnownValuePattern that matches any known value.
|
|
@@ -1166,7 +1245,7 @@ declare function registerTaggedPatternFactory(factory: (pattern: TaggedPattern)
|
|
|
1166
1245
|
* Corresponds to the Rust `TaggedPattern` struct in tagged_pattern.rs
|
|
1167
1246
|
*/
|
|
1168
1247
|
declare class TaggedPattern implements Matcher {
|
|
1169
|
-
|
|
1248
|
+
private readonly _inner;
|
|
1170
1249
|
private constructor();
|
|
1171
1250
|
/**
|
|
1172
1251
|
* Creates a new TaggedPattern that matches any tagged value.
|
|
@@ -1230,7 +1309,7 @@ type CBORPatternType = {
|
|
|
1230
1309
|
* Corresponds to the Rust `CBORPattern` enum in cbor_pattern.rs
|
|
1231
1310
|
*/
|
|
1232
1311
|
declare class CBORPattern implements Matcher {
|
|
1233
|
-
|
|
1312
|
+
private readonly _pattern;
|
|
1234
1313
|
private constructor();
|
|
1235
1314
|
/**
|
|
1236
1315
|
* Creates a new CBORPattern that matches any CBOR value.
|
|
@@ -1252,6 +1331,18 @@ declare class CBORPattern implements Matcher {
|
|
|
1252
1331
|
* Gets the pattern type.
|
|
1253
1332
|
*/
|
|
1254
1333
|
get pattern(): CBORPatternType;
|
|
1334
|
+
/**
|
|
1335
|
+
* Convert dcbor captures to envelope captures.
|
|
1336
|
+
*/
|
|
1337
|
+
private _convertDcborCapturesToEnvelopeCaptures;
|
|
1338
|
+
/**
|
|
1339
|
+
* Convert a single dcbor path to an envelope path.
|
|
1340
|
+
*/
|
|
1341
|
+
private _convertDcborPathToEnvelopePath;
|
|
1342
|
+
/**
|
|
1343
|
+
* Collect capture names from a dcbor pattern.
|
|
1344
|
+
*/
|
|
1345
|
+
private _collectDcborCaptureNames;
|
|
1255
1346
|
pathsWithCaptures(haystack: Envelope): [Path[], Map<string, Path[]>];
|
|
1256
1347
|
paths(haystack: Envelope): Path[];
|
|
1257
1348
|
matches(haystack: Envelope): boolean;
|
|
@@ -1421,7 +1512,7 @@ type SubjectPatternType = {
|
|
|
1421
1512
|
* Corresponds to the Rust `SubjectPattern` enum in subject_pattern.rs
|
|
1422
1513
|
*/
|
|
1423
1514
|
declare class SubjectPattern implements Matcher {
|
|
1424
|
-
|
|
1515
|
+
private readonly _pattern;
|
|
1425
1516
|
private constructor();
|
|
1426
1517
|
/**
|
|
1427
1518
|
* Creates a new SubjectPattern that matches any subject.
|
|
@@ -1474,7 +1565,7 @@ type PredicatePatternType = {
|
|
|
1474
1565
|
* Corresponds to the Rust `PredicatePattern` enum in predicate_pattern.rs
|
|
1475
1566
|
*/
|
|
1476
1567
|
declare class PredicatePattern implements Matcher {
|
|
1477
|
-
|
|
1568
|
+
private readonly _pattern;
|
|
1478
1569
|
private constructor();
|
|
1479
1570
|
/**
|
|
1480
1571
|
* Creates a new PredicatePattern that matches any predicate.
|
|
@@ -1527,7 +1618,7 @@ type ObjectPatternType = {
|
|
|
1527
1618
|
* Corresponds to the Rust `ObjectPattern` enum in object_pattern.rs
|
|
1528
1619
|
*/
|
|
1529
1620
|
declare class ObjectPattern implements Matcher {
|
|
1530
|
-
|
|
1621
|
+
private readonly _pattern;
|
|
1531
1622
|
private constructor();
|
|
1532
1623
|
/**
|
|
1533
1624
|
* Creates a new ObjectPattern that matches any object.
|
|
@@ -1587,7 +1678,7 @@ type AssertionsPatternType = {
|
|
|
1587
1678
|
* Corresponds to the Rust `AssertionsPattern` enum in assertions_pattern.rs
|
|
1588
1679
|
*/
|
|
1589
1680
|
declare class AssertionsPattern implements Matcher {
|
|
1590
|
-
|
|
1681
|
+
private readonly _pattern;
|
|
1591
1682
|
private constructor();
|
|
1592
1683
|
/**
|
|
1593
1684
|
* Creates a new AssertionsPattern that matches any assertion.
|
|
@@ -1661,7 +1752,7 @@ type DigestPatternType = {
|
|
|
1661
1752
|
* Corresponds to the Rust `DigestPattern` enum in digest_pattern.rs
|
|
1662
1753
|
*/
|
|
1663
1754
|
declare class DigestPattern implements Matcher {
|
|
1664
|
-
|
|
1755
|
+
private readonly _pattern;
|
|
1665
1756
|
private constructor();
|
|
1666
1757
|
/**
|
|
1667
1758
|
* Creates a new DigestPattern that matches any digest.
|
|
@@ -1721,7 +1812,7 @@ type NodePatternType = {
|
|
|
1721
1812
|
* Corresponds to the Rust `NodePattern` enum in node_pattern.rs
|
|
1722
1813
|
*/
|
|
1723
1814
|
declare class NodePattern implements Matcher {
|
|
1724
|
-
|
|
1815
|
+
private readonly _pattern;
|
|
1725
1816
|
private constructor();
|
|
1726
1817
|
/**
|
|
1727
1818
|
* Creates a new NodePattern that matches any node.
|
|
@@ -1789,7 +1880,7 @@ type ObscuredPatternType = {
|
|
|
1789
1880
|
* Corresponds to the Rust `ObscuredPattern` enum in obscured_pattern.rs
|
|
1790
1881
|
*/
|
|
1791
1882
|
declare class ObscuredPattern implements Matcher {
|
|
1792
|
-
|
|
1883
|
+
private readonly _pattern;
|
|
1793
1884
|
private constructor();
|
|
1794
1885
|
/**
|
|
1795
1886
|
* Creates a new ObscuredPattern that matches any obscured element.
|
|
@@ -1829,6 +1920,11 @@ declare class ObscuredPattern implements Matcher {
|
|
|
1829
1920
|
//#endregion
|
|
1830
1921
|
//#region src/pattern/structure/wrapped-pattern.d.ts
|
|
1831
1922
|
declare function registerWrappedPatternFactory(factory: (pattern: WrappedPattern) => Pattern): void;
|
|
1923
|
+
declare function registerWrappedPatternDispatch(dispatch: {
|
|
1924
|
+
pathsWithCaptures: (pattern: Pattern, haystack: Envelope) => [Path[], Map<string, Path[]>];
|
|
1925
|
+
compile: (pattern: Pattern, code: Instr[], literals: Pattern[], captures: string[]) => void;
|
|
1926
|
+
toString: (pattern: Pattern) => string;
|
|
1927
|
+
}): void;
|
|
1832
1928
|
/**
|
|
1833
1929
|
* Pattern type for wrapped pattern matching.
|
|
1834
1930
|
*
|
|
@@ -1846,7 +1942,7 @@ type WrappedPatternType = {
|
|
|
1846
1942
|
* Corresponds to the Rust `WrappedPattern` enum in wrapped_pattern.rs
|
|
1847
1943
|
*/
|
|
1848
1944
|
declare class WrappedPattern implements Matcher {
|
|
1849
|
-
|
|
1945
|
+
private readonly _pattern;
|
|
1850
1946
|
private constructor();
|
|
1851
1947
|
/**
|
|
1852
1948
|
* Creates a new WrappedPattern that matches any wrapped envelope without descending.
|
|
@@ -2014,7 +2110,7 @@ declare function registerAndPatternFactory(factory: (pattern: AndPattern) => Pat
|
|
|
2014
2110
|
* Corresponds to the Rust `AndPattern` struct in and_pattern.rs
|
|
2015
2111
|
*/
|
|
2016
2112
|
declare class AndPattern implements Matcher {
|
|
2017
|
-
|
|
2113
|
+
private readonly _patterns;
|
|
2018
2114
|
private constructor();
|
|
2019
2115
|
/**
|
|
2020
2116
|
* Creates a new AndPattern with the given patterns.
|
|
@@ -2048,7 +2144,7 @@ declare function registerOrPatternFactory(factory: (pattern: OrPattern) => Patte
|
|
|
2048
2144
|
* Corresponds to the Rust `OrPattern` struct in or_pattern.rs
|
|
2049
2145
|
*/
|
|
2050
2146
|
declare class OrPattern implements Matcher {
|
|
2051
|
-
|
|
2147
|
+
private readonly _patterns;
|
|
2052
2148
|
private constructor();
|
|
2053
2149
|
/**
|
|
2054
2150
|
* Creates a new OrPattern with the given patterns.
|
|
@@ -2082,7 +2178,7 @@ declare function registerNotPatternFactory(factory: (pattern: NotPattern) => Pat
|
|
|
2082
2178
|
* Corresponds to the Rust `NotPattern` struct in not_pattern.rs
|
|
2083
2179
|
*/
|
|
2084
2180
|
declare class NotPattern implements Matcher {
|
|
2085
|
-
|
|
2181
|
+
private readonly _pattern;
|
|
2086
2182
|
private constructor();
|
|
2087
2183
|
/**
|
|
2088
2184
|
* Creates a new NotPattern with the given pattern.
|
|
@@ -2116,7 +2212,8 @@ declare function registerCapturePatternFactory(factory: (pattern: CapturePattern
|
|
|
2116
2212
|
* Corresponds to the Rust `CapturePattern` struct in capture_pattern.rs
|
|
2117
2213
|
*/
|
|
2118
2214
|
declare class CapturePattern implements Matcher {
|
|
2119
|
-
|
|
2215
|
+
private readonly _name;
|
|
2216
|
+
private readonly _pattern;
|
|
2120
2217
|
private constructor();
|
|
2121
2218
|
/**
|
|
2122
2219
|
* Creates a new CapturePattern with the given name and pattern.
|
|
@@ -2154,7 +2251,7 @@ declare function registerSearchPatternFactory(factory: (pattern: SearchPattern)
|
|
|
2154
2251
|
* Corresponds to the Rust `SearchPattern` struct in search_pattern.rs
|
|
2155
2252
|
*/
|
|
2156
2253
|
declare class SearchPattern implements Matcher {
|
|
2157
|
-
|
|
2254
|
+
private readonly _pattern;
|
|
2158
2255
|
private constructor();
|
|
2159
2256
|
/**
|
|
2160
2257
|
* Creates a new SearchPattern with the given pattern.
|
|
@@ -2165,6 +2262,10 @@ declare class SearchPattern implements Matcher {
|
|
|
2165
2262
|
*/
|
|
2166
2263
|
pattern(): Pattern;
|
|
2167
2264
|
pathsWithCaptures(haystack: Envelope): [Path[], Map<string, Path[]>];
|
|
2265
|
+
/**
|
|
2266
|
+
* Walk the envelope tree recursively.
|
|
2267
|
+
*/
|
|
2268
|
+
private _walkEnvelope;
|
|
2168
2269
|
paths(haystack: Envelope): Path[];
|
|
2169
2270
|
matches(haystack: Envelope): boolean;
|
|
2170
2271
|
compile(code: Instr[], literals: Pattern[], captures: string[]): void;
|
|
@@ -2188,7 +2289,8 @@ declare function registerTraversePatternFactory(factory: (pattern: TraversePatte
|
|
|
2188
2289
|
* Corresponds to the Rust `TraversePattern` struct in traverse_pattern.rs
|
|
2189
2290
|
*/
|
|
2190
2291
|
declare class TraversePattern implements Matcher {
|
|
2191
|
-
|
|
2292
|
+
private readonly _first;
|
|
2293
|
+
private readonly _rest;
|
|
2192
2294
|
private constructor();
|
|
2193
2295
|
/**
|
|
2194
2296
|
* Creates a new TraversePattern with the given patterns.
|
|
@@ -2222,7 +2324,8 @@ declare function registerGroupPatternFactory(factory: (pattern: GroupPattern) =>
|
|
|
2222
2324
|
* Corresponds to the Rust `GroupPattern` struct in repeat_pattern.rs
|
|
2223
2325
|
*/
|
|
2224
2326
|
declare class GroupPattern implements Matcher {
|
|
2225
|
-
|
|
2327
|
+
private readonly _pattern;
|
|
2328
|
+
private readonly _quantifier;
|
|
2226
2329
|
private constructor();
|
|
2227
2330
|
/**
|
|
2228
2331
|
* Creates a new GroupPattern with the specified sub-pattern and quantifier.
|
|
@@ -2240,7 +2343,7 @@ declare class GroupPattern implements Matcher {
|
|
|
2240
2343
|
* Gets the quantifier of this group pattern.
|
|
2241
2344
|
*/
|
|
2242
2345
|
quantifier(): Quantifier$1;
|
|
2243
|
-
pathsWithCaptures(
|
|
2346
|
+
pathsWithCaptures(haystack: Envelope): [Path[], Map<string, Path[]>];
|
|
2244
2347
|
paths(haystack: Envelope): Path[];
|
|
2245
2348
|
matches(haystack: Envelope): boolean;
|
|
2246
2349
|
compile(code: Instr[], literals: Pattern[], _captures: string[]): void;
|
|
@@ -2382,6 +2485,7 @@ declare function patternStructure(structure: StructurePattern): Pattern;
|
|
|
2382
2485
|
declare function patternMeta(meta: MetaPattern): Pattern;
|
|
2383
2486
|
/**
|
|
2384
2487
|
* Gets paths with captures for a pattern.
|
|
2488
|
+
* Routes through the VM for complex patterns that require compilation.
|
|
2385
2489
|
*/
|
|
2386
2490
|
declare function patternPathsWithCaptures(pattern: Pattern, haystack: Envelope): [Path[], Map<string, Path[]>];
|
|
2387
2491
|
/**
|
|
@@ -2452,6 +2556,18 @@ declare function date(d: CborDate): Pattern;
|
|
|
2452
2556
|
* Creates a new Pattern that matches Date values within a specified range.
|
|
2453
2557
|
*/
|
|
2454
2558
|
declare function dateRange(earliest: CborDate, latest: CborDate): Pattern;
|
|
2559
|
+
/**
|
|
2560
|
+
* Creates a new Pattern that matches Date values on or after the specified date.
|
|
2561
|
+
*/
|
|
2562
|
+
declare function dateEarliest(d: CborDate): Pattern;
|
|
2563
|
+
/**
|
|
2564
|
+
* Creates a new Pattern that matches Date values on or before the specified date.
|
|
2565
|
+
*/
|
|
2566
|
+
declare function dateLatest(d: CborDate): Pattern;
|
|
2567
|
+
/**
|
|
2568
|
+
* Creates a new Pattern that matches Date values whose ISO-8601 string matches the regex.
|
|
2569
|
+
*/
|
|
2570
|
+
declare function dateRegex(pattern: RegExp): Pattern;
|
|
2455
2571
|
/**
|
|
2456
2572
|
* Creates a new Pattern that matches any number value.
|
|
2457
2573
|
*/
|
|
@@ -2646,5 +2762,5 @@ declare function parsePartial(input: string): Result<[Pattern, number]>;
|
|
|
2646
2762
|
*/
|
|
2647
2763
|
declare const VERSION = "1.0.0-alpha.11";
|
|
2648
2764
|
//#endregion
|
|
2649
|
-
export { AndPattern, AnyPattern, ArrayPattern, type ArrayPatternType, AssertionsPattern, type AssertionsPatternType, Axis, BoolPattern, ByteStringPattern, CBORPattern, type CBORPatternType, CapturePattern, DatePattern, DigestPattern, type DigestPatternType, EdgeType, EnvelopePatternError, FormatPathsOpts, FormatPathsOptsBuilder, GroupPattern, Instr, Interval, KnownValuePattern, LeafPattern, LeafStructurePattern, Lexer, MapPattern, type MapPatternType, Matcher, MatcherDefaults, MetaPattern, NodePattern, type NodePatternType, NotPattern, NullPattern, NumberPattern, ObjectPattern, type ObjectPatternType, ObscuredPattern, type ObscuredPatternType, OrPattern, Path, PathElementFormat, Pattern, PredicatePattern, type PredicatePatternType, Program, Quantifier, Reluctance, Result, SearchPattern, Span, StructurePattern, SubjectPattern, type SubjectPatternType, TaggedPattern, TextPattern, type Token, TraversePattern, VERSION, WrappedPattern, type WrappedPatternType, and, any, anyArray, anyAssertion, anyBool, anyByteString, anyCbor, anyDate, anyKnownValue, anyMap, anyNode, anyNumber, anyObject, anyPredicate, anySubject, anyTag, anyText, assertionWithObject, assertionWithPredicate, axisChildren, bool, byteString, capture, cborPattern, cborValue, compile, compileAsAtomic, compressed, convertDcborPatternToEnvelopePattern, date, dateRange, dcborPatternError, defaultFormatPathsOpts, defaultPathElementFormat, digest, digestPrefix, digestURFormat, elided, emptyInput, encrypted, envelopeSummary, envelopeURFormat, err, expectedCloseBracket, expectedCloseParen, expectedOpenBracket, expectedOpenParen, expectedPattern, extraData, formatError, formatPath, formatPathOpt, formatPaths, formatPathsOpt, formatPathsOpts, formatPathsWithCaptures, formatPathsWithCapturesOpt, group, invalidCaptureGroupName, invalidDateFormat, invalidHexString, invalidNumberFormat, invalidPattern, invalidRange, invalidRegex, invalidUr, isErr, isOk, knownValue, leaf, leafArray, leafBool, leafByteString, leafCbor, leafDate, leafKnownValue, leafMap, leafNull, leafNumber, leafPatternCompile, leafPatternIsComplex, leafPatternPaths, leafPatternPathsWithCaptures, leafPatternToString, leafTag, leafText, map, matchPattern, metaAnd, metaAny, metaCapture, metaGroup, metaNot, metaOr, metaPatternCollectCaptureNames, metaPatternCompile, metaPatternIsComplex, metaPatternPathsWithCaptures, metaPatternToString, metaSearch, metaTraverse, notMatching, nullPattern, number, numberGreaterThan, numberLessThan, numberRange, object, obscured, ok, or, parse, parsePartial, patternCollectCaptureNames, patternCompile, patternIsComplex, patternLeaf, patternMatches, patternMeta, patternPaths, patternPathsWithCaptures, patternStructure, patternToString, predicate, registerAndPatternFactory, registerAnyPatternFactory, registerArrayPatternFactory, registerAssertionsPatternFactory, registerBoolPatternFactory, registerByteStringPatternFactory, registerCBORPatternFactory, registerCapturePatternFactory, registerDatePatternFactory, registerDigestPatternFactory, registerGroupPatternFactory, registerKnownValuePatternFactory, registerLeafStructurePatternFactory, registerMapPatternFactory, registerNodePatternFactory, registerNotPatternFactory, registerNullPatternFactory, registerNumberPatternFactory, registerObjectPatternFactory, registerObscuredPatternFactory, registerOrPatternFactory, registerPatternMatchFn, registerPredicatePatternFactory, registerSearchPatternFactory, registerSubjectPatternFactory, registerTaggedPatternFactory, registerTextPatternFactory, registerTraversePatternFactory, registerVMPatternFunctions, registerWrappedPatternFactory, repeat, run, search, structureAssertions, structureDigest, structureLeaf, structureNode, structureObject, structureObscured, structurePatternCompile, structurePatternIsComplex, structurePatternPaths, structurePatternPathsWithCaptures, structurePatternToString, structurePredicate, structureSubject, structureWrapped, subject, summaryFormat, tagged, text, textRegex, traverse, unexpectedEndOfInput, unexpectedToken, unit, unknown, unmatchedBraces, unmatchedParentheses, unrecognizedToken, unterminatedRegex, unwrap, unwrapEnvelope, unwrapMatching, unwrapOr, wrapped };
|
|
2765
|
+
export { AndPattern, AnyPattern, ArrayPattern, type ArrayPatternType, AssertionsPattern, type AssertionsPatternType, Axis, BoolPattern, ByteStringPattern, CBORPattern, type CBORPatternType, CapturePattern, DatePattern, DigestPattern, type DigestPatternType, EdgeType, EnvelopePatternError, FormatPathsOpts, FormatPathsOptsBuilder, GroupPattern, Instr, Interval, KnownValuePattern, LeafPattern, LeafStructurePattern, Lexer, MapPattern, type MapPatternType, Matcher, MatcherDefaults, MetaPattern, NodePattern, type NodePatternType, NotPattern, NullPattern, NumberPattern, ObjectPattern, type ObjectPatternType, ObscuredPattern, type ObscuredPatternType, OrPattern, Path, PathElementFormat, Pattern, PredicatePattern, type PredicatePatternType, Program, Quantifier, Reluctance, Result, SearchPattern, Span, StructurePattern, SubjectPattern, type SubjectPatternType, TaggedPattern, TextPattern, type Token, TraversePattern, VERSION, WrappedPattern, type WrappedPatternType, and, any, anyArray, anyAssertion, anyBool, anyByteString, anyCbor, anyDate, anyKnownValue, anyMap, anyNode, anyNumber, anyObject, anyPredicate, anySubject, anyTag, anyText, assertionWithObject, assertionWithPredicate, axisChildren, bool, byteString, capture, cborPattern, cborValue, compile, compileAsAtomic, compressed, convertDcborPatternToEnvelopePattern, date, dateEarliest, dateLatest, dateRange, dateRegex, dcborPatternError, defaultFormatPathsOpts, defaultPathElementFormat, digest, digestPrefix, digestURFormat, dispatchCompile, dispatchIsComplex, dispatchPaths, dispatchPathsWithCaptures, dispatchPatternToString, elided, emptyInput, encrypted, envelopeSummary, envelopeURFormat, err, expectedCloseBracket, expectedCloseParen, expectedOpenBracket, expectedOpenParen, expectedPattern, extraData, formatError, formatPath, formatPathOpt, formatPaths, formatPathsOpt, formatPathsOpts, formatPathsWithCaptures, formatPathsWithCapturesOpt, group, invalidCaptureGroupName, invalidDateFormat, invalidHexString, invalidNumberFormat, invalidPattern, invalidRange, invalidRegex, invalidUr, isErr, isOk, knownValue, leaf, leafArray, leafBool, leafByteString, leafCbor, leafDate, leafKnownValue, leafMap, leafNull, leafNumber, leafPatternCompile, leafPatternIsComplex, leafPatternPaths, leafPatternPathsWithCaptures, leafPatternToString, leafTag, leafText, map, matchPattern, metaAnd, metaAny, metaCapture, metaGroup, metaNot, metaOr, metaPatternCollectCaptureNames, metaPatternCompile, metaPatternIsComplex, metaPatternPathsWithCaptures, metaPatternToString, metaSearch, metaTraverse, notMatching, nullPattern, number, numberGreaterThan, numberLessThan, numberRange, object, obscured, ok, or, parse, parsePartial, patternCollectCaptureNames, patternCompile, patternIsComplex, patternLeaf, patternMatches, patternMeta, patternPaths, patternPathsWithCaptures, patternStructure, patternToString, predicate, registerAndPatternFactory, registerAnyPatternFactory, registerArrayPatternFactory, registerAssertionsPatternFactory, registerBoolPatternFactory, registerByteStringPatternFactory, registerCBORPatternFactory, registerCapturePatternFactory, registerDatePatternFactory, registerDigestPatternFactory, registerGroupPatternFactory, registerKnownValuePatternFactory, registerLeafStructurePatternFactory, registerMapPatternFactory, registerNodePatternFactory, registerNotPatternFactory, registerNullPatternFactory, registerNumberPatternFactory, registerObjectPatternFactory, registerObscuredPatternFactory, registerOrPatternFactory, registerPatternDispatchFns, registerPatternMatchFn, registerPredicatePatternFactory, registerSearchPatternFactory, registerSubjectPatternFactory, registerTaggedPatternFactory, registerTextPatternFactory, registerTraversePatternFactory, registerVMPatternFunctions, registerWrappedPatternDispatch, registerWrappedPatternFactory, repeat, run, search, structureAssertions, structureDigest, structureLeaf, structureNode, structureObject, structureObscured, structurePatternCompile, structurePatternIsComplex, structurePatternPaths, structurePatternPathsWithCaptures, structurePatternToString, structurePredicate, structureSubject, structureWrapped, subject, summaryFormat, tagged, text, textRegex, traverse, unexpectedEndOfInput, unexpectedToken, unit, unknown, unmatchedBraces, unmatchedParentheses, unrecognizedToken, unterminatedRegex, unwrap, unwrapEnvelope, unwrapMatching, unwrapOr, wrapped };
|
|
2650
2766
|
//# sourceMappingURL=index.d.cts.map
|