@bcts/envelope-pattern 1.0.0-alpha.22 → 1.0.0-alpha.23

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.mjs CHANGED
@@ -3,7 +3,6 @@ import { UNIT } from "@bcts/known-values";
3
3
  import { Envelope } from "@bcts/envelope";
4
4
  import { CborDate, asCborArray, asCborMap, bytesToHex, cbor } from "@bcts/dcbor";
5
5
  import { parseDcborItemPartial } from "@bcts/dcbor-parse";
6
-
7
6
  //#region src/error.ts
8
7
  /**
9
8
  * Creates a successful result.
@@ -218,7 +217,6 @@ function dcborPatternError(error) {
218
217
  error
219
218
  };
220
219
  }
221
-
222
220
  //#endregion
223
221
  //#region src/format.ts
224
222
  /**
@@ -477,19 +475,27 @@ function formatPathsOpt(paths, opts = defaultFormatPathsOpts()) {
477
475
  function formatPaths(paths) {
478
476
  return formatPathsOpt(paths, defaultFormatPathsOpts());
479
477
  }
480
-
481
478
  //#endregion
482
479
  //#region src/pattern/matcher.ts
483
480
  /**
484
481
  * Default implementations for Matcher methods.
485
482
  */
486
483
  const MatcherDefaults = {
484
+ /**
485
+ * Default implementation of paths() - calls pathsWithCaptures and discards captures.
486
+ */
487
487
  paths(matcher, haystack) {
488
488
  return matcher.pathsWithCaptures(haystack)[0];
489
489
  },
490
+ /**
491
+ * Default implementation of matches() - checks if paths() returns any results.
492
+ */
490
493
  matches(matcher, haystack) {
491
494
  return matcher.paths(haystack).length > 0;
492
495
  },
496
+ /**
497
+ * Default implementation of isComplex() - returns false.
498
+ */
493
499
  isComplex() {
494
500
  return false;
495
501
  }
@@ -577,7 +583,6 @@ function dispatchPatternToString(pattern) {
577
583
  if (patternToStringFn === void 0) throw new Error("Pattern dispatch functions not registered");
578
584
  return patternToStringFn(pattern);
579
585
  }
580
-
581
586
  //#endregion
582
587
  //#region src/pattern/leaf/bool-pattern.ts
583
588
  let createLeafBoolPattern;
@@ -661,7 +666,6 @@ var BoolPattern = class BoolPattern {
661
666
  return hash;
662
667
  }
663
668
  };
664
-
665
669
  //#endregion
666
670
  //#region src/pattern/leaf/null-pattern.ts
667
671
  let createLeafNullPattern;
@@ -730,7 +734,6 @@ var NullPattern = class NullPattern {
730
734
  return 0;
731
735
  }
732
736
  };
733
-
734
737
  //#endregion
735
738
  //#region src/pattern/leaf/number-pattern.ts
736
739
  let createLeafNumberPattern;
@@ -903,7 +906,6 @@ var NumberPattern = class NumberPattern {
903
906
  return hash;
904
907
  }
905
908
  };
906
-
907
909
  //#endregion
908
910
  //#region src/pattern/leaf/text-pattern.ts
909
911
  let createLeafTextPattern;
@@ -1008,7 +1010,6 @@ var TextPattern = class TextPattern {
1008
1010
  return hash;
1009
1011
  }
1010
1012
  };
1011
-
1012
1013
  //#endregion
1013
1014
  //#region src/pattern/leaf/byte-string-pattern.ts
1014
1015
  let createLeafByteStringPattern;
@@ -1119,7 +1120,6 @@ var ByteStringPattern = class ByteStringPattern {
1119
1120
  return hash;
1120
1121
  }
1121
1122
  };
1122
-
1123
1123
  //#endregion
1124
1124
  //#region src/pattern/leaf/date-pattern.ts
1125
1125
  let createLeafDatePattern;
@@ -1234,7 +1234,6 @@ var DatePattern = class DatePattern {
1234
1234
  return hash;
1235
1235
  }
1236
1236
  };
1237
-
1238
1237
  //#endregion
1239
1238
  //#region src/pattern/leaf/array-pattern.ts
1240
1239
  /**
@@ -1416,7 +1415,6 @@ function simpleStringHash$3(str) {
1416
1415
  }
1417
1416
  return hash;
1418
1417
  }
1419
-
1420
1418
  //#endregion
1421
1419
  //#region src/pattern/leaf/map-pattern.ts
1422
1420
  let createLeafMapPattern;
@@ -1507,7 +1505,6 @@ var MapPattern = class MapPattern {
1507
1505
  }
1508
1506
  }
1509
1507
  };
1510
-
1511
1508
  //#endregion
1512
1509
  //#region src/pattern/leaf/known-value-pattern.ts
1513
1510
  let createLeafKnownValuePattern;
@@ -1628,7 +1625,6 @@ function simpleStringHash$2(str) {
1628
1625
  }
1629
1626
  return hash;
1630
1627
  }
1631
-
1632
1628
  //#endregion
1633
1629
  //#region src/pattern/leaf/tagged-pattern.ts
1634
1630
  /**
@@ -1786,7 +1782,6 @@ function simpleStringHash$1(str) {
1786
1782
  }
1787
1783
  return hash;
1788
1784
  }
1789
-
1790
1785
  //#endregion
1791
1786
  //#region src/pattern/leaf/cbor-pattern.ts
1792
1787
  /**
@@ -1995,7 +1990,6 @@ function simpleStringHash(str) {
1995
1990
  }
1996
1991
  return hash;
1997
1992
  }
1998
-
1999
1993
  //#endregion
2000
1994
  //#region src/pattern/leaf/index.ts
2001
1995
  /**
@@ -2197,7 +2191,6 @@ function leafPatternToString(pattern) {
2197
2191
  case "KnownValue": return pattern.pattern.toString();
2198
2192
  }
2199
2193
  }
2200
-
2201
2194
  //#endregion
2202
2195
  //#region src/pattern/structure/leaf-structure-pattern.ts
2203
2196
  let createStructureLeafPattern;
@@ -2250,13 +2243,7 @@ var LeafStructurePattern = class LeafStructurePattern {
2250
2243
  return 0;
2251
2244
  }
2252
2245
  };
2253
-
2254
- //#endregion
2255
- //#region src/pattern/structure/subject-pattern.ts
2256
- let createStructureSubjectPattern;
2257
- function registerSubjectPatternFactory(factory) {
2258
- createStructureSubjectPattern = factory;
2259
- }
2246
+ function registerSubjectPatternFactory(factory) {}
2260
2247
  /**
2261
2248
  * Pattern for matching subjects in envelopes.
2262
2249
  *
@@ -2351,7 +2338,6 @@ var SubjectPattern = class SubjectPattern {
2351
2338
  return this._pattern.type === "Any" ? 0 : 1;
2352
2339
  }
2353
2340
  };
2354
-
2355
2341
  //#endregion
2356
2342
  //#region src/pattern/structure/predicate-pattern.ts
2357
2343
  let createStructurePredicatePattern;
@@ -2449,7 +2435,6 @@ var PredicatePattern = class PredicatePattern {
2449
2435
  return this._pattern.type === "Any" ? 0 : 1;
2450
2436
  }
2451
2437
  };
2452
-
2453
2438
  //#endregion
2454
2439
  //#region src/pattern/structure/object-pattern.ts
2455
2440
  let createStructureObjectPattern;
@@ -2547,7 +2532,6 @@ var ObjectPattern = class ObjectPattern {
2547
2532
  return this._pattern.type === "Any" ? 0 : 1;
2548
2533
  }
2549
2534
  };
2550
-
2551
2535
  //#endregion
2552
2536
  //#region src/pattern/structure/assertions-pattern.ts
2553
2537
  let createStructureAssertionsPattern;
@@ -2705,7 +2689,6 @@ var AssertionsPattern = class AssertionsPattern {
2705
2689
  }
2706
2690
  }
2707
2691
  };
2708
-
2709
2692
  //#endregion
2710
2693
  //#region src/pattern/structure/digest-pattern.ts
2711
2694
  let createStructureDigestPattern;
@@ -2863,7 +2846,6 @@ var DigestPattern = class DigestPattern {
2863
2846
  }
2864
2847
  }
2865
2848
  };
2866
-
2867
2849
  //#endregion
2868
2850
  //#region src/pattern/structure/node-pattern.ts
2869
2851
  let createStructureNodePattern;
@@ -2989,7 +2971,6 @@ var NodePattern = class NodePattern {
2989
2971
  }
2990
2972
  }
2991
2973
  };
2992
-
2993
2974
  //#endregion
2994
2975
  //#region src/pattern/structure/obscured-pattern.ts
2995
2976
  let createStructureObscuredPattern;
@@ -3093,7 +3074,6 @@ var ObscuredPattern = class ObscuredPattern {
3093
3074
  }
3094
3075
  }
3095
3076
  };
3096
-
3097
3077
  //#endregion
3098
3078
  //#region src/pattern/structure/wrapped-pattern.ts
3099
3079
  let createStructureWrappedPattern;
@@ -3236,7 +3216,6 @@ var WrappedPattern = class WrappedPattern {
3236
3216
  return this._pattern.type === "Any" ? 0 : 1;
3237
3217
  }
3238
3218
  };
3239
-
3240
3219
  //#endregion
3241
3220
  //#region src/pattern/structure/index.ts
3242
3221
  /**
@@ -3408,7 +3387,6 @@ function structurePatternToString(pattern) {
3408
3387
  case "Wrapped": return pattern.pattern.toString();
3409
3388
  }
3410
3389
  }
3411
-
3412
3390
  //#endregion
3413
3391
  //#region src/pattern/vm.ts
3414
3392
  let _patternPathsWithCaptures$1;
@@ -4055,7 +4033,6 @@ function compileMetaPattern(pattern, code, literals, captureNames) {
4055
4033
  }
4056
4034
  }
4057
4035
  }
4058
-
4059
4036
  //#endregion
4060
4037
  //#region src/pattern/meta/any-pattern.ts
4061
4038
  let createMetaAnyPattern;
@@ -4107,13 +4084,7 @@ var AnyPattern = class AnyPattern {
4107
4084
  return 0;
4108
4085
  }
4109
4086
  };
4110
-
4111
- //#endregion
4112
- //#region src/pattern/meta/and-pattern.ts
4113
- let createMetaAndPattern;
4114
- function registerAndPatternFactory(factory) {
4115
- createMetaAndPattern = factory;
4116
- }
4087
+ function registerAndPatternFactory(factory) {}
4117
4088
  /**
4118
4089
  * A pattern that matches if all contained patterns match.
4119
4090
  *
@@ -4169,13 +4140,7 @@ var AndPattern = class AndPattern {
4169
4140
  return this._patterns.length;
4170
4141
  }
4171
4142
  };
4172
-
4173
- //#endregion
4174
- //#region src/pattern/meta/or-pattern.ts
4175
- let createMetaOrPattern;
4176
- function registerOrPatternFactory(factory) {
4177
- createMetaOrPattern = factory;
4178
- }
4143
+ function registerOrPatternFactory(factory) {}
4179
4144
  /**
4180
4145
  * A pattern that matches if any contained pattern matches.
4181
4146
  *
@@ -4269,13 +4234,7 @@ var OrPattern = class OrPattern {
4269
4234
  return this._patterns.length;
4270
4235
  }
4271
4236
  };
4272
-
4273
- //#endregion
4274
- //#region src/pattern/meta/not-pattern.ts
4275
- let createMetaNotPattern;
4276
- function registerNotPatternFactory(factory) {
4277
- createMetaNotPattern = factory;
4278
- }
4237
+ function registerNotPatternFactory(factory) {}
4279
4238
  /**
4280
4239
  * A pattern that negates another pattern; matches when the inner pattern does not match.
4281
4240
  *
@@ -4334,13 +4293,7 @@ var NotPattern = class NotPattern {
4334
4293
  return 1;
4335
4294
  }
4336
4295
  };
4337
-
4338
- //#endregion
4339
- //#region src/pattern/meta/capture-pattern.ts
4340
- let createMetaCapturePattern;
4341
- function registerCapturePatternFactory(factory) {
4342
- createMetaCapturePattern = factory;
4343
- }
4296
+ function registerCapturePatternFactory(factory) {}
4344
4297
  /**
4345
4298
  * A pattern that captures a match with a name.
4346
4299
  *
@@ -4419,13 +4372,7 @@ var CapturePattern = class CapturePattern {
4419
4372
  return hash;
4420
4373
  }
4421
4374
  };
4422
-
4423
- //#endregion
4424
- //#region src/pattern/meta/search-pattern.ts
4425
- let createMetaSearchPattern;
4426
- function registerSearchPatternFactory(factory) {
4427
- createMetaSearchPattern = factory;
4428
- }
4375
+ function registerSearchPatternFactory(factory) {}
4429
4376
  /**
4430
4377
  * A pattern that searches the entire envelope tree for matches.
4431
4378
  *
@@ -4552,13 +4499,7 @@ function collectCaptureNames(pattern, out) {
4552
4499
  const p = pattern;
4553
4500
  if (p.collectCaptureNames !== void 0) p.collectCaptureNames(out);
4554
4501
  }
4555
-
4556
- //#endregion
4557
- //#region src/pattern/meta/traverse-pattern.ts
4558
- let createMetaTraversePattern;
4559
- function registerTraversePatternFactory(factory) {
4560
- createMetaTraversePattern = factory;
4561
- }
4502
+ function registerTraversePatternFactory(factory) {}
4562
4503
  let _patternPathsWithCaptures;
4563
4504
  let _patternCompile;
4564
4505
  let _patternIsComplex;
@@ -4652,13 +4593,7 @@ var TraversePattern = class TraversePattern {
4652
4593
  return this.patterns().length;
4653
4594
  }
4654
4595
  };
4655
-
4656
- //#endregion
4657
- //#region src/pattern/meta/group-pattern.ts
4658
- let createMetaGroupPattern;
4659
- function registerGroupPatternFactory(factory) {
4660
- createMetaGroupPattern = factory;
4661
- }
4596
+ function registerGroupPatternFactory(factory) {}
4662
4597
  /**
4663
4598
  * A pattern that matches with repetition.
4664
4599
  *
@@ -4734,7 +4669,6 @@ var GroupPattern = class GroupPattern {
4734
4669
  return this._quantifier.min() * 31 + (this._quantifier.max() ?? 0);
4735
4670
  }
4736
4671
  };
4737
-
4738
4672
  //#endregion
4739
4673
  //#region src/pattern/meta/index.ts
4740
4674
  /**
@@ -4924,7 +4858,6 @@ function collectCaptureNamesFromPattern(pattern, out) {
4924
4858
  const p = pattern;
4925
4859
  if (p.collectCaptureNames !== void 0) p.collectCaptureNames(out);
4926
4860
  }
4927
-
4928
4861
  //#endregion
4929
4862
  //#region src/pattern/dcbor-integration.ts
4930
4863
  /**
@@ -5057,7 +4990,6 @@ function convertMetaPatternToEnvelopePattern(metaPattern, originalPattern) {
5057
4990
  });
5058
4991
  }
5059
4992
  }
5060
-
5061
4993
  //#endregion
5062
4994
  //#region src/pattern/index.ts
5063
4995
  /**
@@ -5593,7 +5525,6 @@ registerPatternDispatchFns({
5593
5525
  toString: patternToString
5594
5526
  });
5595
5527
  registerTraverseDispatchFunctions(patternPathsWithCaptures, patternCompile, patternIsComplex);
5596
-
5597
5528
  //#endregion
5598
5529
  //#region src/parse/token.ts
5599
5530
  /**
@@ -6337,7 +6268,6 @@ var Lexer = class {
6337
6268
  }
6338
6269
  }
6339
6270
  };
6340
-
6341
6271
  //#endregion
6342
6272
  //#region src/parse/index.ts
6343
6273
  /**
@@ -6970,14 +6900,13 @@ function parseUnwrap(lexer) {
6970
6900
  });
6971
6901
  return ok(unwrapMatching(inner.value));
6972
6902
  }
6973
-
6974
6903
  //#endregion
6975
6904
  //#region src/index.ts
6976
6905
  /**
6977
6906
  * Package version.
6978
6907
  */
6979
6908
  const VERSION = "1.0.0-alpha.11";
6980
-
6981
6909
  //#endregion
6982
6910
  export { AndPattern, AnyPattern, ArrayPattern, AssertionsPattern, BoolPattern, ByteStringPattern, CBORPattern, CapturePattern, DatePattern, DigestPattern, FormatPathsOptsBuilder, GroupPattern, Interval, KnownValuePattern, LeafStructurePattern, Lexer, MapPattern, MatcherDefaults, NodePattern, NotPattern, NullPattern, NumberPattern, ObjectPattern, ObscuredPattern, OrPattern, PredicatePattern, Quantifier, Reluctance, SearchPattern, SubjectPattern, TaggedPattern, TextPattern, TraversePattern, VERSION, WrappedPattern, 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 };
6911
+
6983
6912
  //# sourceMappingURL=index.mjs.map