@cdk8s/awscdk-resolver 0.0.535 → 0.0.537

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 (108) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/package.json +34 -34
  4. package/node_modules/@aws-sdk/core/dist-cjs/index.js +6 -6
  5. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +6 -6
  6. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeSerializer.js +6 -6
  7. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonShapeSerializer.d.ts +2 -2
  8. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonShapeSerializer.d.ts +1 -1
  9. package/node_modules/@aws-sdk/core/package.json +11 -11
  10. package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
  11. package/node_modules/@aws-sdk/credential-provider-http/package.json +10 -10
  12. package/node_modules/@aws-sdk/credential-provider-ini/package.json +14 -14
  13. package/node_modules/@aws-sdk/credential-provider-login/package.json +8 -8
  14. package/node_modules/@aws-sdk/credential-provider-node/package.json +12 -12
  15. package/node_modules/@aws-sdk/credential-provider-process/package.json +6 -6
  16. package/node_modules/@aws-sdk/credential-provider-sso/package.json +8 -8
  17. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -7
  18. package/node_modules/@aws-sdk/middleware-host-header/package.json +4 -4
  19. package/node_modules/@aws-sdk/middleware-logger/package.json +3 -3
  20. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +4 -4
  21. package/node_modules/@aws-sdk/middleware-user-agent/package.json +8 -8
  22. package/node_modules/@aws-sdk/nested-clients/package.json +32 -32
  23. package/node_modules/@aws-sdk/region-config-resolver/package.json +5 -5
  24. package/node_modules/@aws-sdk/token-providers/package.json +7 -7
  25. package/node_modules/@aws-sdk/types/package.json +2 -2
  26. package/node_modules/@aws-sdk/util-endpoints/package.json +5 -5
  27. package/node_modules/@aws-sdk/util-user-agent-browser/package.json +3 -3
  28. package/node_modules/@aws-sdk/util-user-agent-node/package.json +5 -5
  29. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  30. package/node_modules/@smithy/config-resolver/package.json +5 -5
  31. package/node_modules/@smithy/core/package.json +7 -7
  32. package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
  33. package/node_modules/@smithy/fetch-http-handler/package.json +5 -5
  34. package/node_modules/@smithy/hash-node/package.json +2 -2
  35. package/node_modules/@smithy/invalid-dependency/package.json +2 -2
  36. package/node_modules/@smithy/middleware-content-length/package.json +3 -3
  37. package/node_modules/@smithy/middleware-endpoint/package.json +8 -8
  38. package/node_modules/@smithy/middleware-retry/package.json +9 -9
  39. package/node_modules/@smithy/middleware-serde/package.json +4 -4
  40. package/node_modules/@smithy/middleware-stack/package.json +2 -2
  41. package/node_modules/@smithy/node-config-provider/package.json +4 -4
  42. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +6 -6
  43. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +1 -1
  44. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +5 -5
  45. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +14 -1
  46. package/node_modules/@smithy/node-http-handler/package.json +5 -5
  47. package/node_modules/@smithy/property-provider/package.json +2 -2
  48. package/node_modules/@smithy/protocol-http/package.json +2 -2
  49. package/node_modules/@smithy/querystring-builder/package.json +2 -2
  50. package/node_modules/@smithy/querystring-parser/package.json +2 -2
  51. package/node_modules/@smithy/service-error-classification/package.json +2 -2
  52. package/node_modules/@smithy/shared-ini-file-loader/package.json +2 -2
  53. package/node_modules/@smithy/signature-v4/dist-cjs/index.js +11 -5
  54. package/node_modules/@smithy/signature-v4/dist-es/SignatureV4.js +11 -5
  55. package/node_modules/@smithy/signature-v4/dist-types/SignatureV4.d.ts +3 -3
  56. package/node_modules/@smithy/signature-v4/package.json +4 -4
  57. package/node_modules/@smithy/smithy-client/dist-cjs/index.js +8 -1
  58. package/node_modules/@smithy/smithy-client/dist-es/command.js +8 -1
  59. package/node_modules/@smithy/smithy-client/package.json +7 -7
  60. package/node_modules/@smithy/types/dist-types/connection/config.d.ts +5 -0
  61. package/node_modules/@smithy/types/dist-types/signature.d.ts +20 -3
  62. package/node_modules/@smithy/types/package.json +1 -1
  63. package/node_modules/@smithy/url-parser/package.json +3 -3
  64. package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
  65. package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
  66. package/node_modules/@smithy/util-endpoints/dist-cjs/index.js +165 -76
  67. package/node_modules/@smithy/util-endpoints/dist-es/bdd/BinaryDecisionDiagram.js +15 -0
  68. package/node_modules/@smithy/util-endpoints/dist-es/decideEndpoint.js +42 -0
  69. package/node_modules/@smithy/util-endpoints/dist-es/index.js +2 -0
  70. package/node_modules/@smithy/util-endpoints/dist-es/lib/coalesce.js +8 -0
  71. package/node_modules/@smithy/util-endpoints/dist-es/lib/getAttr.js +2 -1
  72. package/node_modules/@smithy/util-endpoints/dist-es/lib/index.js +3 -0
  73. package/node_modules/@smithy/util-endpoints/dist-es/lib/ite.js +3 -0
  74. package/node_modules/@smithy/util-endpoints/dist-es/lib/split.js +13 -0
  75. package/node_modules/@smithy/util-endpoints/dist-es/lib/substring.js +1 -1
  76. package/node_modules/@smithy/util-endpoints/dist-es/resolveEndpoint.js +8 -13
  77. package/node_modules/@smithy/util-endpoints/dist-es/utils/endpointFunctions.js +4 -1
  78. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateExpression.js +20 -5
  79. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateTemplate.js +3 -6
  80. package/node_modules/@smithy/util-endpoints/dist-es/utils/getEndpointHeaders.js +1 -1
  81. package/node_modules/@smithy/util-endpoints/dist-es/utils/getReferenceValue.js +1 -5
  82. package/node_modules/@smithy/util-endpoints/dist-types/bdd/BinaryDecisionDiagram.d.ts +22 -0
  83. package/node_modules/@smithy/util-endpoints/dist-types/decideEndpoint.d.ts +7 -0
  84. package/node_modules/@smithy/util-endpoints/dist-types/index.d.ts +2 -0
  85. package/node_modules/@smithy/util-endpoints/dist-types/lib/coalesce.d.ts +7 -0
  86. package/node_modules/@smithy/util-endpoints/dist-types/lib/index.d.ts +3 -0
  87. package/node_modules/@smithy/util-endpoints/dist-types/lib/ite.d.ts +6 -0
  88. package/node_modules/@smithy/util-endpoints/dist-types/lib/split.d.ts +11 -0
  89. package/node_modules/@smithy/util-endpoints/dist-types/utils/endpointFunctions.d.ts +4 -0
  90. package/node_modules/@smithy/util-endpoints/dist-types/utils/getReferenceValue.d.ts +3 -1
  91. package/node_modules/@smithy/util-endpoints/package.json +3 -3
  92. package/node_modules/@smithy/util-middleware/package.json +2 -2
  93. package/node_modules/@smithy/util-retry/dist-cjs/index.js +6 -0
  94. package/node_modules/@smithy/util-retry/dist-es/AdaptiveRetryStrategy.js +3 -0
  95. package/node_modules/@smithy/util-retry/dist-es/StandardRetryStrategy.js +3 -0
  96. package/node_modules/@smithy/util-retry/dist-types/AdaptiveRetryStrategy.d.ts +5 -0
  97. package/node_modules/@smithy/util-retry/dist-types/StandardRetryStrategy.d.ts +5 -0
  98. package/node_modules/@smithy/util-retry/package.json +3 -3
  99. package/node_modules/@smithy/util-stream/package.json +4 -4
  100. package/node_modules/@smithy/util-waiter/package.json +3 -3
  101. package/node_modules/path-expression-matcher/README.md +41 -54
  102. package/node_modules/path-expression-matcher/lib/pem.cjs +1 -1
  103. package/node_modules/path-expression-matcher/lib/pem.min.js +1 -1
  104. package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -1
  105. package/node_modules/path-expression-matcher/package.json +1 -1
  106. package/node_modules/path-expression-matcher/src/Matcher.js +223 -195
  107. package/node_modules/path-expression-matcher/src/index.d.ts +64 -247
  108. package/package.json +7 -7
@@ -1,9 +1,12 @@
1
1
  export * from "./booleanEquals";
2
+ export * from "./coalesce";
2
3
  export * from "./getAttr";
3
4
  export * from "./isSet";
4
5
  export * from "./isValidHostLabel";
6
+ export * from "./ite";
5
7
  export * from "./not";
6
8
  export * from "./parseURL";
9
+ export * from "./split";
7
10
  export * from "./stringEquals";
8
11
  export * from "./substring";
9
12
  export * from "./uriEncode";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * An if-then-else function that returns one of two values based on a boolean condition.
3
+ *
4
+ * @internal
5
+ */
6
+ export declare function ite<T>(condition: boolean, trueValue: T | undefined, falseValue: T | undefined): T | undefined;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The split function divides a string into an array of substrings based on a non-empty delimiter.
3
+ * The behavior is controlled by the limit parameter:
4
+ *
5
+ * limit = 0: Split all occurrences (unlimited).
6
+ * limit = 1: No split performed (returns original string as single element array).
7
+ * limit > 1: Split into at most 'limit' parts (performs limit-1 splits).
8
+ *
9
+ * @internal
10
+ */
11
+ export declare function split(value: string, delimiter: string, limit: number): string[];
@@ -1,10 +1,14 @@
1
+ import { coalesce, ite, split } from "../lib";
1
2
  export declare const endpointFunctions: {
2
3
  booleanEquals: (value1: boolean, value2: boolean) => boolean;
4
+ coalesce: typeof coalesce;
3
5
  getAttr: (value: import("../lib").GetAttrValue, path: string) => import("../lib").GetAttrValue;
4
6
  isSet: (value: unknown) => value is {};
5
7
  isValidHostLabel: (value: string, allowSubDomains?: boolean) => boolean;
8
+ ite: typeof ite;
6
9
  not: (value: boolean) => boolean;
7
10
  parseURL: (value: string | URL | import("@smithy/types").Endpoint) => import("@smithy/types").EndpointURL | null;
11
+ split: typeof split;
8
12
  stringEquals: (value1: string, value2: string) => boolean;
9
13
  substring: (input: string, start: number, stop: number, reverse: boolean) => string | null;
10
14
  uriEncode: (value: string) => string;
@@ -1,2 +1,4 @@
1
1
  import type { EvaluateOptions, ReferenceObject } from "../types";
2
- export declare const getReferenceValue: ({ ref }: ReferenceObject, options: EvaluateOptions) => import("../types").FunctionReturn;
2
+ export declare const getReferenceValue: ({ ref }: ReferenceObject, options: EvaluateOptions) => string | number | boolean | import("@smithy/types").EndpointPartition | import("@smithy/types").EndpointARN | {
3
+ [key: string]: import("../types").FunctionReturn;
4
+ };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-endpoints",
3
- "version": "3.3.4",
3
+ "version": "3.4.1",
4
4
  "description": "Utilities to help with endpoint resolution.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -28,8 +28,8 @@
28
28
  "license": "Apache-2.0",
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
- "@smithy/node-config-provider": "^4.3.13",
32
- "@smithy/types": "^4.14.0",
31
+ "@smithy/node-config-provider": "^4.3.14",
32
+ "@smithy/types": "^4.14.1",
33
33
  "tslib": "^2.6.2"
34
34
  },
35
35
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-middleware",
3
- "version": "4.2.13",
3
+ "version": "4.2.14",
4
4
  "description": "Shared utilities for to be used in middleware packages.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -27,7 +27,7 @@
27
27
  "license": "Apache-2.0",
28
28
  "sideEffects": false,
29
29
  "dependencies": {
30
- "@smithy/types": "^4.14.0",
30
+ "@smithy/types": "^4.14.1",
31
31
  "tslib": "^2.6.2"
32
32
  },
33
33
  "devDependencies": {
@@ -261,6 +261,9 @@ class StandardRetryStrategy {
261
261
  isRetryableError(errorType) {
262
262
  return errorType === "THROTTLING" || errorType === "TRANSIENT";
263
263
  }
264
+ async maxAttempts() {
265
+ return this.maxAttemptsProvider();
266
+ }
264
267
  }
265
268
 
266
269
  class AdaptiveRetryStrategy {
@@ -289,6 +292,9 @@ class AdaptiveRetryStrategy {
289
292
  this.rateLimiter.updateClientSendingRate({});
290
293
  this.standardRetryStrategy.recordSuccess(token);
291
294
  }
295
+ async maxAttemptsProvider() {
296
+ return this.standardRetryStrategy.maxAttempts();
297
+ }
292
298
  }
293
299
 
294
300
  class ConfiguredRetryStrategy extends StandardRetryStrategy {
@@ -27,4 +27,7 @@ export class AdaptiveRetryStrategy {
27
27
  this.rateLimiter.updateClientSendingRate({});
28
28
  this.standardRetryStrategy.recordSuccess(token);
29
29
  }
30
+ async maxAttemptsProvider() {
31
+ return this.standardRetryStrategy.maxAttempts();
32
+ }
30
33
  }
@@ -77,4 +77,7 @@ export class StandardRetryStrategy {
77
77
  isRetryableError(errorType) {
78
78
  return errorType === "THROTTLING" || errorType === "TRANSIENT";
79
79
  }
80
+ async maxAttempts() {
81
+ return this.maxAttemptsProvider();
82
+ }
80
83
  }
@@ -30,4 +30,9 @@ export declare class AdaptiveRetryStrategy implements RetryStrategyV2 {
30
30
  acquireInitialRetryToken(retryTokenScope: string): Promise<RetryToken>;
31
31
  refreshRetryTokenForRetry(tokenToRenew: StandardRetryToken, errorInfo: RetryErrorInfo): Promise<RetryToken>;
32
32
  recordSuccess(token: StandardRetryToken): void;
33
+ /**
34
+ * There is an existing integration which accesses this field.
35
+ * @deprecated
36
+ */
37
+ maxAttemptsProvider(): Promise<number>;
33
38
  }
@@ -40,4 +40,9 @@ export declare class StandardRetryStrategy implements RetryStrategyV2 {
40
40
  private shouldRetry;
41
41
  private getCapacityCost;
42
42
  private isRetryableError;
43
+ /**
44
+ * There is an existing integration which accesses this field.
45
+ * @deprecated
46
+ */
47
+ maxAttempts(): Promise<number>;
43
48
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-retry",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "Shared retry utilities to be used in middleware packages.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -30,8 +30,8 @@
30
30
  "license": "Apache-2.0",
31
31
  "sideEffects": false,
32
32
  "dependencies": {
33
- "@smithy/service-error-classification": "^4.2.13",
34
- "@smithy/types": "^4.14.0",
33
+ "@smithy/service-error-classification": "^4.2.14",
34
+ "@smithy/types": "^4.14.1",
35
35
  "tslib": "^2.6.2"
36
36
  },
37
37
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-stream",
3
- "version": "4.5.22",
3
+ "version": "4.5.23",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
6
6
  "build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline util-stream",
@@ -28,9 +28,9 @@
28
28
  "license": "Apache-2.0",
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
- "@smithy/fetch-http-handler": "^5.3.16",
32
- "@smithy/node-http-handler": "^4.5.2",
33
- "@smithy/types": "^4.14.0",
31
+ "@smithy/fetch-http-handler": "^5.3.17",
32
+ "@smithy/node-http-handler": "^4.5.3",
33
+ "@smithy/types": "^4.14.1",
34
34
  "@smithy/util-base64": "^4.3.2",
35
35
  "@smithy/util-buffer-from": "^4.2.2",
36
36
  "@smithy/util-hex-encoding": "^4.2.2",
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@smithy/util-waiter",
3
- "version": "4.2.15",
3
+ "version": "4.2.16",
4
4
  "description": "Shared utilities for client waiters for the AWS SDK",
5
5
  "dependencies": {
6
- "@smithy/types": "^4.14.0",
6
+ "@smithy/types": "^4.14.1",
7
7
  "tslib": "^2.6.2"
8
8
  },
9
9
  "scripts": {
@@ -47,7 +47,7 @@
47
47
  "directory": "packages/util-waiter"
48
48
  },
49
49
  "devDependencies": {
50
- "@smithy/abort-controller": "^4.2.13",
50
+ "@smithy/abort-controller": "^4.2.14",
51
51
  "concurrently": "7.0.0",
52
52
  "downlevel-dts": "0.10.1",
53
53
  "premove": "4.0.0",
@@ -4,10 +4,11 @@ Efficient path tracking and pattern matching for XML, JSON, YAML or any other pa
4
4
 
5
5
  ## 🎯 Purpose
6
6
 
7
- `path-expression-matcher` provides two core classes for tracking and matching paths:
7
+ `path-expression-matcher` provides three core classes for tracking and matching paths:
8
8
 
9
9
  - **`Expression`**: Parses and stores pattern expressions (e.g., `"root.users.user[id]"`)
10
10
  - **`Matcher`**: Tracks current path during parsing and matches against expressions
11
+ - **`MatcherView`**: A lightweight read-only view of a `Matcher`, safe to pass to callbacks
11
12
 
12
13
  Compatible with [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) and similar tools.
13
14
 
@@ -368,51 +369,51 @@ matcher.restore(snapshot);
368
369
 
369
370
  ##### `readOnly()`
370
371
 
371
- Returns a **live, read-only proxy** of the matcher. All query and inspection methods work normally, but any attempt to call a state-mutating method (`push`, `pop`, `reset`, `updateCurrent`, `restore`) or to write/delete a property throws a `TypeError`.
372
+ Returns a **`MatcherView`** — a lightweight, live read-only view of the matcher. All query and inspection methods work normally and always reflect the current state of the underlying matcher. Mutation methods (`push`, `pop`, `reset`, `updateCurrent`, `restore`) simply don't exist on `MatcherView`, so misuse is caught at **compile time** by TypeScript rather than at runtime.
372
373
 
373
- This is the recommended way to share the matcher with external consumers — plugins, callbacks, event handlers that only need to inspect the current path without being able to corrupt parser state.
374
+ The **same instance** is returned on every call — no allocation occurs per invocation. This is the recommended way to share the matcher with callbacks, plugins, or any external code that only needs to inspect the current path.
374
375
 
375
376
  ```javascript
376
- const ro = matcher.readOnly();
377
+ const view = matcher.readOnly();
378
+ // Same reference every time — safe to cache
379
+ view === matcher.readOnly(); // true
377
380
  ```
378
381
 
379
- **What works on the read-only view:**
382
+ **What works on the view:**
380
383
 
381
384
  ```javascript
382
- ro.matches(expr) // ✓ pattern matching
383
- ro.getCurrentTag() // ✓ current tag name
384
- ro.getCurrentNamespace() // ✓ current namespace
385
- ro.getAttrValue("id") // ✓ attribute value
386
- ro.hasAttr("id") // ✓ attribute presence check
387
- ro.getPosition() // ✓ sibling position
388
- ro.getCounter() // ✓ occurrence counter
389
- ro.getDepth() // ✓ path depth
390
- ro.toString() // ✓ path as string
391
- ro.toArray() // ✓ path as array
392
- ro.snapshot() // ✓ snapshot (can be used to restore the real matcher)
385
+ view.matches(expr) // ✓ pattern matching
386
+ view.getCurrentTag() // ✓ current tag name
387
+ view.getCurrentNamespace() // ✓ current namespace
388
+ view.getAttrValue("id") // ✓ attribute value
389
+ view.hasAttr("id") // ✓ attribute presence check
390
+ view.getPosition() // ✓ sibling position
391
+ view.getCounter() // ✓ occurrence counter
392
+ view.getDepth() // ✓ path depth
393
+ view.toString() // ✓ path as string
394
+ view.toArray() // ✓ path as array
393
395
  ```
394
396
 
395
- **What throws a `TypeError`:**
397
+ **What doesn't exist (compile-time error in TypeScript):**
396
398
 
397
399
  ```javascript
398
- ro.push("child", {}) // ✗ TypeError: Cannot call 'push' on a read-only Matcher
399
- ro.pop() // ✗ TypeError: Cannot call 'pop' on a read-only Matcher
400
- ro.reset() // ✗ TypeError: Cannot call 'reset' on a read-only Matcher
401
- ro.updateCurrent({}) // ✗ TypeError: Cannot call 'updateCurrent' on a read-only Matcher
402
- ro.restore(snapshot) // ✗ TypeError: Cannot call 'restore' on a read-only Matcher
403
- ro.separator = '/' // ✗ TypeError: Cannot set property on a read-only Matcher
400
+ view.push("child", {}) // ✗ Property 'push' does not exist on type 'MatcherView'
401
+ view.pop() // ✗ Property 'pop' does not exist on type 'MatcherView'
402
+ view.reset() // ✗ Property 'reset' does not exist on type 'MatcherView'
403
+ view.updateCurrent({}) // ✗ Property 'updateCurrent' does not exist on type 'MatcherView'
404
+ view.restore(snapshot) // ✗ Property 'restore' does not exist on type 'MatcherView'
404
405
  ```
405
406
 
406
- **Important:** The read-only view is **live** — it always reflects the current state of the underlying matcher. If you need a frozen-in-time copy instead, use `snapshot()`.
407
+ **The view is live** — it always reflects the current state of the underlying matcher.
407
408
 
408
409
  ```javascript
409
410
  const matcher = new Matcher();
410
- const ro = matcher.readOnly();
411
+ const view = matcher.readOnly();
411
412
 
412
413
  matcher.push("root");
413
- ro.getDepth(); // 1 — immediately reflects the push
414
+ view.getDepth(); // 1 — immediately reflects the push
414
415
  matcher.push("users");
415
- ro.getDepth(); // 2 — still live
416
+ view.getDepth(); // 2 — still live
416
417
  ```
417
418
 
418
419
  ## 💡 Usage Examples
@@ -550,9 +551,9 @@ const expr = new Expression("root.item:first");
550
551
  console.log(matcher.matches(expr)); // false (counter=1, not 0)
551
552
  ```
552
553
 
553
- ### Example 8: Passing a Read-Only Matcher to External Consumers
554
+ ### Example 8: Passing a Read-Only View to External Consumers
554
555
 
555
- When passing the matcher into callbacks, plugins, or other code you don't control, use `readOnly()` to prevent accidental state corruption.
556
+ When passing the matcher into callbacks, plugins, or other code you don't control, use `readOnly()` to get a `MatcherView` — it can inspect but never mutate parser state.
556
557
 
557
558
  ```javascript
558
559
  import { Expression, Matcher } from 'path-expression-matcher';
@@ -564,40 +565,26 @@ const adminExpr = new Expression("..user[type=admin]");
564
565
  function parseTag(tagName, attrs, onTag) {
565
566
  matcher.push(tagName, attrs);
566
567
 
567
- // Pass a read-only view — consumer can inspect but not mutate
568
+ // Pass MatcherView — consumer can inspect but not mutate
568
569
  onTag(matcher.readOnly());
569
570
 
570
571
  matcher.pop();
571
572
  }
572
573
 
573
574
  // Safe consumer — can only read
574
- function myPlugin(ro) {
575
- if (ro.matches(adminExpr)) {
576
- console.log("Admin at path:", ro.toString());
577
- console.log("Depth:", ro.getDepth());
578
- console.log("ID:", ro.getAttrValue("id"));
575
+ function myPlugin(view) {
576
+ if (view.matches(adminExpr)) {
577
+ console.log("Admin at path:", view.toString());
578
+ console.log("Depth:", view.getDepth());
579
+ console.log("ID:", view.getAttrValue("id"));
579
580
  }
580
581
  }
581
582
 
582
- // ro.push(...) or ro.reset() here would throw TypeError,
583
- // so the parser's state is always safe.
583
+ // view.push(...) or view.reset() don't exist on MatcherView —
584
+ // TypeScript catches misuse at compile time.
584
585
  parseTag("user", { id: "1", type: "admin" }, myPlugin);
585
586
  ```
586
587
 
587
- **Combining with `snapshot()`:** A snapshot taken via the read-only view can still be used to restore the real matcher.
588
-
589
- ```javascript
590
- const matcher = new Matcher();
591
- matcher.push("root");
592
- matcher.push("users");
593
-
594
- const ro = matcher.readOnly();
595
- const snap = ro.snapshot(); // ✓ snapshot works on read-only view
596
-
597
- matcher.push("user"); // continue parsing...
598
- matcher.restore(snap); // restore to "root.users" using the snapshot
599
- ```
600
-
601
588
  ```javascript
602
589
  const matcher = new Matcher();
603
590
  const soapExpr = new Expression("soap::Envelope.soap::Body..ns::UserId");
@@ -799,7 +786,7 @@ Whether `seal()` has been called.
799
786
  ### `matchesAny(matcher)` → `boolean`
800
787
 
801
788
  Returns `true` if the matcher's current path matches **any** expression in the set.
802
- Accepts both a `Matcher` instance and a `ReadOnlyMatcher` view.
789
+ Accepts both a `Matcher` instance and a `MatcherView`.
803
790
 
804
791
  ```javascript
805
792
  if (stopNodes.matchesAny(matcher)) { /* ... */ }
@@ -818,7 +805,7 @@ In practice, deep-wildcard expressions are rare in configs, so the list stays sm
818
805
 
819
806
  ### `findMatch(matcher)` → `Expression`
820
807
 
821
- Returns the Expression instance that matched the current path. Accepts both a `Matcher` instance and a `ReadOnlyMatcher` view.
808
+ Returns the Expression instance that matched the current path. Accepts both a `Matcher` instance and a `MatcherView`.
822
809
 
823
810
  ```javascript
824
811
  const node = stopNodes.findMatch(matcher);
@@ -882,4 +869,4 @@ MIT
882
869
 
883
870
  ## 🤝 Contributing
884
871
 
885
- Issues and PRs welcome! This package is designed to be used by XML/JSON parsers like fast-xml-parser.
872
+ Issues and PRs welcome! This package is designed to be used by XML/JSON parsers like fast-xml-parser. But can be used with any formar parser.
@@ -1 +1 @@
1
- (()=>{"use strict";var t={d:(e,s)=>{for(var n in s)t.o(s,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:s[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Expression:()=>s,ExpressionSet:()=>r,Matcher:()=>i,default:()=>a});class s{constructor(t,e={},s){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=s,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let s=0,n="";for(;s<t.length;)t[s]===this.separator?s+1<t.length&&t[s+1]===this.separator?(n.trim()&&(e.push(this._parseSegment(n.trim())),n=""),e.push({type:"deep-wildcard"}),s+=2):(n.trim()&&e.push(this._parseSegment(n.trim())),n="",s++):(n+=t[s],s++);return n.trim()&&e.push(this._parseSegment(n.trim())),e}_parseSegment(t){const e={type:"tag"};let s=null,n=t;const i=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(n=i[1]+i[3],i[2])){const t=i[2].slice(1,-1);t&&(s=t)}let r,a,h=n;if(n.includes("::")){const e=n.indexOf("::");if(r=n.substring(0,e).trim(),h=n.substring(e+2).trim(),!r)throw new Error(`Invalid namespace in pattern: ${t}`)}let l=null;if(h.includes(":")){const t=h.lastIndexOf(":"),e=h.substring(0,t).trim(),s=h.substring(t+1).trim();["first","last","odd","even"].includes(s)||/^nth\(\d+\)$/.test(s)?(a=e,l=s):a=h}else a=h;if(!a)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=a,r&&(e.namespace=r),s)if(s.includes("=")){const t=s.indexOf("=");e.attrName=s.substring(0,t).trim(),e.attrValue=s.substring(t+1).trim()}else e.attrName=s.trim();if(l){const t=l.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=l}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}const n=new Set(["push","pop","reset","updateCurrent","restore"]);class i{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null}push(t,e=null,s=null){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const n=this.path.length;this.siblingStacks[n]||(this.siblingStacks[n]=new Map);const i=this.siblingStacks[n],r=s?`${s}:${t}`:t,a=i.get(r)||0;let h=0;for(const t of i.values())h+=t;i.set(r,a+1);const l={tag:t,position:h,counter:a};null!=s&&(l.namespace=s),null!=e&&(l.values=e),this.path.push(l)}pop(){if(0===this.path.length)return;this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t,this._frozenPathCache=null)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0===this.path.length)return;const e=this.path[this.path.length-1];return e.values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const s=t||this.separator;if(s===this.separator&&!0===e){if(null!==this._pathStringCache&&void 0!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++){const s=t[e],n=this.path[e],i=e===this.path.length-1;if(!this._matchSegment(s,n,i))return!1}return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,s=t.length-1;for(;s>=0&&e>=0;){const n=t[s];if("deep-wildcard"===n.type){if(s--,s<0)return!0;const n=t[s];let i=!1;for(let t=e;t>=0;t--){const r=t===this.path.length-1;if(this._matchSegment(n,this.path[t],r)){e=t-1,s--,i=!0;break}}if(!i)return!1}else{const t=e===this.path.length-1;if(!this._matchSegment(n,this.path[e],t))return!1;e--,s--}}return s<0}_matchSegment(t,e,s){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!s)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue){const s=e.values[t.attrName];if(String(s)!==String(t.attrValue))return!1}}if(void 0!==t.position){if(!s)return!1;const n=e.counter??0;if("first"===t.position&&0!==n)return!1;if("odd"===t.position&&n%2!=1)return!1;if("even"===t.position&&n%2!=0)return!1;if("nth"===t.position&&n!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return new Proxy(this,{get(t,e,s){if(n.has(e))return()=>{throw new TypeError(`Cannot call '${e}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};if("path"===e)return null===t._frozenPathCache&&(t._frozenPathCache=Object.freeze(t.path.map(t=>Object.freeze({...t})))),t._frozenPathCache;if("siblingStacks"===e)return null===t._frozenSiblingsCache&&(t._frozenSiblingsCache=Object.freeze(t.siblingStacks.map(t=>Object.freeze(new Map(t))))),t._frozenSiblingsCache;const i=Reflect.get(t,e,s);return"function"==typeof i?i.bind(t):i},set(t,e){throw new TypeError(`Cannot set property '${String(e)}' on a read-only Matcher.`)},deleteProperty(t,e){throw new TypeError(`Cannot delete property '${String(e)}' from a read-only Matcher.`)}})}}class r{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,s=t.segments[t.segments.length-1],n=s?.tag;if(n&&"*"!==n){const s=`${e}:${n}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),s=`${e}:${t.getCurrentTag()}`,n=this._byDepthAndTag.get(s);if(n)for(let e=0;e<n.length;e++)if(t.matches(n[e]))return n[e];const i=this._wildcardByDepth.get(e);if(i)for(let e=0;e<i.length;e++)if(t.matches(i[e]))return i[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const a={Expression:s,Matcher:i,ExpressionSet:r};module.exports=e})();
1
+ (()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Expression:()=>s,ExpressionSet:()=>n,Matcher:()=>h,default:()=>r});class s{constructor(t,e={},s){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=s,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let s=0,i="";for(;s<t.length;)t[s]===this.separator?s+1<t.length&&t[s+1]===this.separator?(i.trim()&&(e.push(this._parseSegment(i.trim())),i=""),e.push({type:"deep-wildcard"}),s+=2):(i.trim()&&e.push(this._parseSegment(i.trim())),i="",s++):(i+=t[s],s++);return i.trim()&&e.push(this._parseSegment(i.trim())),e}_parseSegment(t){const e={type:"tag"};let s=null,i=t;const h=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(h&&(i=h[1]+h[3],h[2])){const t=h[2].slice(1,-1);t&&(s=t)}let n,r,a=i;if(i.includes("::")){const e=i.indexOf("::");if(n=i.substring(0,e).trim(),a=i.substring(e+2).trim(),!n)throw new Error(`Invalid namespace in pattern: ${t}`)}let p=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),s=a.substring(t+1).trim();["first","last","odd","even"].includes(s)||/^nth\(\d+\)$/.test(s)?(r=e,p=s):r=a}else r=a;if(!r)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=r,n&&(e.namespace=n),s)if(s.includes("=")){const t=s.indexOf("=");e.attrName=s.substring(0,t).trim(),e.attrValue=s.substring(t+1).trim()}else e.attrName=s.trim();if(p){const t=p.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=p}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class i{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const s=e[e.length-1];return void 0!==s.values&&t in s.values}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class h{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new i(this)}push(t,e=null,s=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const h=this.siblingStacks[i],n=s?`${s}:${t}`:t,r=h.get(n)||0;let a=0;for(const t of h.values())a+=t;h.set(n,r+1);const p={tag:t,position:a,counter:r};null!=s&&(p.namespace=s),null!=e&&(p.values=e),this.path.push(p)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const s=t||this.separator;if(s===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,s=t.length-1;for(;s>=0&&e>=0;){const i=t[s];if("deep-wildcard"===i.type){if(s--,s<0)return!0;const i=t[s];let h=!1;for(let t=e;t>=0;t--)if(this._matchSegment(i,this.path[t],t===this.path.length-1)){e=t-1,s--,h=!0;break}if(!h)return!1}else{if(!this._matchSegment(i,this.path[e],e===this.path.length-1))return!1;e--,s--}}return s<0}_matchSegment(t,e,s){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!s)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!s)return!1;const i=e.counter??0;if("first"===t.position&&0!==i)return!1;if("odd"===t.position&&i%2!=1)return!1;if("even"===t.position&&i%2!=0)return!1;if("nth"===t.position&&i!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return this._view}}class n{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,s=t.segments[t.segments.length-1],i=s?.tag;if(i&&"*"!==i){const s=`${e}:${i}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),s=`${e}:${t.getCurrentTag()}`,i=this._byDepthAndTag.get(s);if(i)for(let e=0;e<i.length;e++)if(t.matches(i[e]))return i[e];const h=this._wildcardByDepth.get(e);if(h)for(let e=0;e<h.length;e++)if(t.matches(h[e]))return h[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const r={Expression:s,Matcher:h,ExpressionSet:n};module.exports=e})();
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.pem=e():t.pem=e()}(this,()=>(()=>{"use strict";var t={d:(e,s)=>{for(var n in s)t.o(s,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:s[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Expression:()=>s,ExpressionSet:()=>r,Matcher:()=>i,default:()=>a});class s{constructor(t,e={},s){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=s,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let s=0,n="";for(;s<t.length;)t[s]===this.separator?s+1<t.length&&t[s+1]===this.separator?(n.trim()&&(e.push(this._parseSegment(n.trim())),n=""),e.push({type:"deep-wildcard"}),s+=2):(n.trim()&&e.push(this._parseSegment(n.trim())),n="",s++):(n+=t[s],s++);return n.trim()&&e.push(this._parseSegment(n.trim())),e}_parseSegment(t){const e={type:"tag"};let s=null,n=t;const i=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(i&&(n=i[1]+i[3],i[2])){const t=i[2].slice(1,-1);t&&(s=t)}let r,a,h=n;if(n.includes("::")){const e=n.indexOf("::");if(r=n.substring(0,e).trim(),h=n.substring(e+2).trim(),!r)throw new Error(`Invalid namespace in pattern: ${t}`)}let o=null;if(h.includes(":")){const t=h.lastIndexOf(":"),e=h.substring(0,t).trim(),s=h.substring(t+1).trim();["first","last","odd","even"].includes(s)||/^nth\(\d+\)$/.test(s)?(a=e,o=s):a=h}else a=h;if(!a)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=a,r&&(e.namespace=r),s)if(s.includes("=")){const t=s.indexOf("=");e.attrName=s.substring(0,t).trim(),e.attrValue=s.substring(t+1).trim()}else e.attrName=s.trim();if(o){const t=o.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=o}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}const n=new Set(["push","pop","reset","updateCurrent","restore"]);class i{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null}push(t,e=null,s=null){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const n=this.path.length;this.siblingStacks[n]||(this.siblingStacks[n]=new Map);const i=this.siblingStacks[n],r=s?`${s}:${t}`:t,a=i.get(r)||0;let h=0;for(const t of i.values())h+=t;i.set(r,a+1);const o={tag:t,position:h,counter:a};null!=s&&(o.namespace=s),null!=e&&(o.values=e),this.path.push(o)}pop(){if(0===this.path.length)return;this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t,this._frozenPathCache=null)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0===this.path.length)return;const e=this.path[this.path.length-1];return e.values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const s=t||this.separator;if(s===this.separator&&!0===e){if(null!==this._pathStringCache&&void 0!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++){const s=t[e],n=this.path[e],i=e===this.path.length-1;if(!this._matchSegment(s,n,i))return!1}return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,s=t.length-1;for(;s>=0&&e>=0;){const n=t[s];if("deep-wildcard"===n.type){if(s--,s<0)return!0;const n=t[s];let i=!1;for(let t=e;t>=0;t--){const r=t===this.path.length-1;if(this._matchSegment(n,this.path[t],r)){e=t-1,s--,i=!0;break}}if(!i)return!1}else{const t=e===this.path.length-1;if(!this._matchSegment(n,this.path[e],t))return!1;e--,s--}}return s<0}_matchSegment(t,e,s){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!s)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue){const s=e.values[t.attrName];if(String(s)!==String(t.attrValue))return!1}}if(void 0!==t.position){if(!s)return!1;const n=e.counter??0;if("first"===t.position&&0!==n)return!1;if("odd"===t.position&&n%2!=1)return!1;if("even"===t.position&&n%2!=0)return!1;if("nth"===t.position&&n!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this._frozenPathCache=null,this._frozenSiblingsCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return new Proxy(this,{get(t,e,s){if(n.has(e))return()=>{throw new TypeError(`Cannot call '${e}' on a read-only Matcher. Obtain a writable instance to mutate state.`)};if("path"===e)return null===t._frozenPathCache&&(t._frozenPathCache=Object.freeze(t.path.map(t=>Object.freeze({...t})))),t._frozenPathCache;if("siblingStacks"===e)return null===t._frozenSiblingsCache&&(t._frozenSiblingsCache=Object.freeze(t.siblingStacks.map(t=>Object.freeze(new Map(t))))),t._frozenSiblingsCache;const i=Reflect.get(t,e,s);return"function"==typeof i?i.bind(t):i},set(t,e){throw new TypeError(`Cannot set property '${String(e)}' on a read-only Matcher.`)},deleteProperty(t,e){throw new TypeError(`Cannot delete property '${String(e)}' from a read-only Matcher.`)}})}}class r{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,s=t.segments[t.segments.length-1],n=s?.tag;if(n&&"*"!==n){const s=`${e}:${n}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),s=`${e}:${t.getCurrentTag()}`,n=this._byDepthAndTag.get(s);if(n)for(let e=0;e<n.length;e++)if(t.matches(n[e]))return n[e];const i=this._wildcardByDepth.get(e);if(i)for(let e=0;e<i.length;e++)if(t.matches(i[e]))return i[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const a={Expression:s,Matcher:i,ExpressionSet:r};return e})());
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.pem=e():t.pem=e()}(this,()=>(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Expression:()=>s,ExpressionSet:()=>r,Matcher:()=>n,default:()=>h});class s{constructor(t,e={},s){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=s,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let s=0,i="";for(;s<t.length;)t[s]===this.separator?s+1<t.length&&t[s+1]===this.separator?(i.trim()&&(e.push(this._parseSegment(i.trim())),i=""),e.push({type:"deep-wildcard"}),s+=2):(i.trim()&&e.push(this._parseSegment(i.trim())),i="",s++):(i+=t[s],s++);return i.trim()&&e.push(this._parseSegment(i.trim())),e}_parseSegment(t){const e={type:"tag"};let s=null,i=t;const n=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(n&&(i=n[1]+n[3],n[2])){const t=n[2].slice(1,-1);t&&(s=t)}let r,h,a=i;if(i.includes("::")){const e=i.indexOf("::");if(r=i.substring(0,e).trim(),a=i.substring(e+2).trim(),!r)throw new Error(`Invalid namespace in pattern: ${t}`)}let p=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),s=a.substring(t+1).trim();["first","last","odd","even"].includes(s)||/^nth\(\d+\)$/.test(s)?(h=e,p=s):h=a}else h=a;if(!h)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=h,r&&(e.namespace=r),s)if(s.includes("=")){const t=s.indexOf("=");e.attrName=s.substring(0,t).trim(),e.attrValue=s.substring(t+1).trim()}else e.attrName=s.trim();if(p){const t=p.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=p}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class i{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const s=e[e.length-1];return void 0!==s.values&&t in s.values}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class n{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new i(this)}push(t,e=null,s=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const n=this.siblingStacks[i],r=s?`${s}:${t}`:t,h=n.get(r)||0;let a=0;for(const t of n.values())a+=t;n.set(r,h+1);const p={tag:t,position:a,counter:h};null!=s&&(p.namespace=s),null!=e&&(p.values=e),this.path.push(p)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const s=t||this.separator;if(s===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,s=t.length-1;for(;s>=0&&e>=0;){const i=t[s];if("deep-wildcard"===i.type){if(s--,s<0)return!0;const i=t[s];let n=!1;for(let t=e;t>=0;t--)if(this._matchSegment(i,this.path[t],t===this.path.length-1)){e=t-1,s--,n=!0;break}if(!n)return!1}else{if(!this._matchSegment(i,this.path[e],e===this.path.length-1))return!1;e--,s--}}return s<0}_matchSegment(t,e,s){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!s)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!s)return!1;const i=e.counter??0;if("first"===t.position&&0!==i)return!1;if("odd"===t.position&&i%2!=1)return!1;if("even"===t.position&&i%2!=0)return!1;if("nth"===t.position&&i!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return this._view}}class r{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,s=t.segments[t.segments.length-1],i=s?.tag;if(i&&"*"!==i){const s=`${e}:${i}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),s=`${e}:${t.getCurrentTag()}`,i=this._byDepthAndTag.get(s);if(i)for(let e=0;e<i.length;e++)if(t.matches(i[e]))return i[e];const n=this._wildcardByDepth.get(e);if(n)for(let e=0;e<n.length;e++)if(t.matches(n[e]))return n[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const h={Expression:s,Matcher:n,ExpressionSet:r};return e})());
2
2
  //# sourceMappingURL=pem.min.js.map