fast-xml-parser 5.5.8 → 5.5.9
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/CHANGELOG.md +16 -0
- package/lib/fxp.d.cts +143 -3
- package/package.json +3 -3
- package/src/fxp.d.ts +141 -1
- package/lib/pem.d.cts +0 -148
- package/src/pem.d.ts +0 -135
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Note: Due to some last quick changes on v4, detail of v4.5.3 & v4.5.4 are not updated here. v4.5.4x is the last tag of v4 in github repository. I'm extremely sorry for the confusion
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
**5.5.9 / 2026-03-23**
|
|
7
|
+
- combine typing files
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
**4.5.5 / 2026-03-22**
|
|
11
|
+
|
|
12
|
+
apply fixes from v5 (legacy maintenance branch v4-maintenance)
|
|
13
|
+
|
|
14
|
+
- support maxEntityCount
|
|
15
|
+
- support onDangerousProperty
|
|
16
|
+
- support maxNestedTags
|
|
17
|
+
- handle prototype pollution
|
|
18
|
+
- fix incorrect entity name replacement
|
|
19
|
+
- fix incorrect condition for entity expansion
|
|
20
|
+
|
|
5
21
|
**5.5.8 / 2026-03-20**
|
|
6
22
|
- pass read only matcher in callback
|
|
7
23
|
|
package/lib/fxp.d.cts
CHANGED
|
@@ -1,6 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Types copied from path-expression-matcher
|
|
3
|
+
* @version <version>
|
|
4
|
+
* @updated <date>
|
|
5
|
+
*
|
|
6
|
+
* Update this file when path-expression-matcher releases a new version.
|
|
7
|
+
* Source: https://github.com/NaturalIntelligence/path-expression-matcher
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Options for creating an Expression
|
|
12
|
+
*/
|
|
13
|
+
interface ExpressionOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Path separator character
|
|
16
|
+
* @default '.'
|
|
17
|
+
*/
|
|
18
|
+
separator?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Parsed segment from an expression pattern
|
|
23
|
+
*/
|
|
24
|
+
interface Segment {
|
|
25
|
+
type: 'tag' | 'deep-wildcard';
|
|
26
|
+
tag?: string;
|
|
27
|
+
namespace?: string;
|
|
28
|
+
attrName?: string;
|
|
29
|
+
attrValue?: string;
|
|
30
|
+
position?: 'first' | 'last' | 'odd' | 'even' | 'nth';
|
|
31
|
+
positionValue?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Expression - Parses and stores a tag pattern expression.
|
|
36
|
+
* Patterns are parsed once and stored in an optimized structure for fast matching.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const expr = new Expression("root.users.user");
|
|
41
|
+
* const expr2 = new Expression("..user[id]:first");
|
|
42
|
+
* const expr3 = new Expression("root/users/user", { separator: '/' });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Pattern Syntax:
|
|
46
|
+
* - `root.users.user` — Match exact path
|
|
47
|
+
* - `..user` — Match "user" at any depth (deep wildcard)
|
|
48
|
+
* - `user[id]` — Match user tag with "id" attribute
|
|
49
|
+
* - `user[id=123]` — Match user tag where id="123"
|
|
50
|
+
* - `user:first` — Match first occurrence of user tag
|
|
51
|
+
* - `ns::user` — Match user tag with namespace "ns"
|
|
52
|
+
* - `ns::user[id]:first` — Combine namespace, attribute, and position
|
|
53
|
+
*/
|
|
54
|
+
declare class Expression {
|
|
55
|
+
readonly pattern: string;
|
|
56
|
+
readonly separator: string;
|
|
57
|
+
readonly segments: Segment[];
|
|
58
|
+
|
|
59
|
+
constructor(pattern: string, options?: ExpressionOptions);
|
|
60
|
+
|
|
61
|
+
get length(): number;
|
|
62
|
+
hasDeepWildcard(): boolean;
|
|
63
|
+
hasAttributeCondition(): boolean;
|
|
64
|
+
hasPositionSelector(): boolean;
|
|
65
|
+
toString(): string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// ReadonlyMatcher
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A live read-only view of a Matcher instance, returned by Matcher.readOnly().
|
|
74
|
+
*
|
|
75
|
+
* All query and inspection methods work normally and always reflect the current
|
|
76
|
+
* state of the underlying matcher. State-mutating methods (`push`, `pop`,
|
|
77
|
+
* `reset`, `updateCurrent`, `restore`) are not present — calling them on the
|
|
78
|
+
* underlying Proxy throws a `TypeError` at runtime.
|
|
79
|
+
*
|
|
80
|
+
* This is the type received by all FXP user callbacks when `jPath: false`.
|
|
81
|
+
*/
|
|
82
|
+
interface ReadonlyMatcher {
|
|
83
|
+
readonly separator: string;
|
|
84
|
+
|
|
85
|
+
/** Check if current path matches an Expression. */
|
|
86
|
+
matches(expression: Expression): boolean;
|
|
87
|
+
|
|
88
|
+
/** Get current tag name, or `undefined` if path is empty. */
|
|
89
|
+
getCurrentTag(): string | undefined;
|
|
90
|
+
|
|
91
|
+
/** Get current namespace, or `undefined` if not present. */
|
|
92
|
+
getCurrentNamespace(): string | undefined;
|
|
93
|
+
|
|
94
|
+
/** Get attribute value of the current node. */
|
|
95
|
+
getAttrValue(attrName: string): any;
|
|
96
|
+
|
|
97
|
+
/** Check if the current node has a given attribute. */
|
|
98
|
+
hasAttr(attrName: string): boolean;
|
|
99
|
+
|
|
100
|
+
/** Sibling position of the current node (child index in parent). */
|
|
101
|
+
getPosition(): number;
|
|
102
|
+
|
|
103
|
+
/** Occurrence counter of the current tag name at this level. */
|
|
104
|
+
getCounter(): number;
|
|
105
|
+
|
|
106
|
+
/** Number of nodes in the current path. */
|
|
107
|
+
getDepth(): number;
|
|
108
|
+
|
|
109
|
+
/** Current path as a string (e.g. `"root.users.user"`). */
|
|
110
|
+
toString(separator?: string, includeNamespace?: boolean): string;
|
|
111
|
+
|
|
112
|
+
/** Current path as an array of tag names. */
|
|
113
|
+
toArray(): string[];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create a snapshot of the current state.
|
|
117
|
+
* The snapshot can be passed to the real Matcher.restore() if needed.
|
|
118
|
+
*/
|
|
119
|
+
snapshot(): MatcherSnapshot;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Internal node structure — exposed via snapshot only. */
|
|
123
|
+
interface PathNode {
|
|
124
|
+
tag: string;
|
|
125
|
+
namespace?: string;
|
|
126
|
+
position: number;
|
|
127
|
+
counter: number;
|
|
128
|
+
values?: Record<string, any>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Snapshot of matcher state returned by `snapshot()` and `readOnly().snapshot()`. */
|
|
132
|
+
interface MatcherSnapshot {
|
|
133
|
+
path: PathNode[];
|
|
134
|
+
siblingStacks: Map<string, number>[];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**********************************************************************
|
|
138
|
+
*
|
|
139
|
+
* END of path-expression-matcher relevant typings
|
|
140
|
+
*
|
|
141
|
+
**********************************************************************/
|
|
142
|
+
|
|
143
|
+
|
|
4
144
|
|
|
5
145
|
// jPath: true → string
|
|
6
146
|
// jPath: false → ReadonlyMatcher
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-xml-parser",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.9",
|
|
4
4
|
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
|
|
5
5
|
"main": "./lib/fxp.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -89,6 +89,6 @@
|
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"fast-xml-builder": "^1.1.4",
|
|
91
91
|
"path-expression-matcher": "^1.2.0",
|
|
92
|
-
"strnum": "^2.2.
|
|
92
|
+
"strnum": "^2.2.2"
|
|
93
93
|
}
|
|
94
|
-
}
|
|
94
|
+
}
|
package/src/fxp.d.ts
CHANGED
|
@@ -1,4 +1,144 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Types copied from path-expression-matcher
|
|
3
|
+
* @version <version>
|
|
4
|
+
* @updated <date>
|
|
5
|
+
*
|
|
6
|
+
* Update this file when path-expression-matcher releases a new version.
|
|
7
|
+
* Source: https://github.com/NaturalIntelligence/path-expression-matcher
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Options for creating an Expression
|
|
12
|
+
*/
|
|
13
|
+
export interface ExpressionOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Path separator character
|
|
16
|
+
* @default '.'
|
|
17
|
+
*/
|
|
18
|
+
separator?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Parsed segment from an expression pattern
|
|
23
|
+
*/
|
|
24
|
+
export interface Segment {
|
|
25
|
+
type: 'tag' | 'deep-wildcard';
|
|
26
|
+
tag?: string;
|
|
27
|
+
namespace?: string;
|
|
28
|
+
attrName?: string;
|
|
29
|
+
attrValue?: string;
|
|
30
|
+
position?: 'first' | 'last' | 'odd' | 'even' | 'nth';
|
|
31
|
+
positionValue?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Expression - Parses and stores a tag pattern expression.
|
|
36
|
+
* Patterns are parsed once and stored in an optimized structure for fast matching.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const expr = new Expression("root.users.user");
|
|
41
|
+
* const expr2 = new Expression("..user[id]:first");
|
|
42
|
+
* const expr3 = new Expression("root/users/user", { separator: '/' });
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Pattern Syntax:
|
|
46
|
+
* - `root.users.user` — Match exact path
|
|
47
|
+
* - `..user` — Match "user" at any depth (deep wildcard)
|
|
48
|
+
* - `user[id]` — Match user tag with "id" attribute
|
|
49
|
+
* - `user[id=123]` — Match user tag where id="123"
|
|
50
|
+
* - `user:first` — Match first occurrence of user tag
|
|
51
|
+
* - `ns::user` — Match user tag with namespace "ns"
|
|
52
|
+
* - `ns::user[id]:first` — Combine namespace, attribute, and position
|
|
53
|
+
*/
|
|
54
|
+
export class Expression {
|
|
55
|
+
readonly pattern: string;
|
|
56
|
+
readonly separator: string;
|
|
57
|
+
readonly segments: Segment[];
|
|
58
|
+
|
|
59
|
+
constructor(pattern: string, options?: ExpressionOptions);
|
|
60
|
+
|
|
61
|
+
get length(): number;
|
|
62
|
+
hasDeepWildcard(): boolean;
|
|
63
|
+
hasAttributeCondition(): boolean;
|
|
64
|
+
hasPositionSelector(): boolean;
|
|
65
|
+
toString(): string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// ReadonlyMatcher
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A live read-only view of a Matcher instance, returned by Matcher.readOnly.
|
|
74
|
+
*
|
|
75
|
+
* All query and inspection methods work normally and always reflect the current
|
|
76
|
+
* state of the underlying matcher. State-mutating methods (`push`, `pop`,
|
|
77
|
+
* `reset`, `updateCurrent`, `restore`) are not present — calling them on the
|
|
78
|
+
* underlying Proxy throws a `TypeError` at runtime.
|
|
79
|
+
*
|
|
80
|
+
* This is the type received by all FXP user callbacks when `jPath: false`.
|
|
81
|
+
*/
|
|
82
|
+
export interface ReadonlyMatcher {
|
|
83
|
+
readonly separator: string;
|
|
84
|
+
|
|
85
|
+
/** Check if current path matches an Expression. */
|
|
86
|
+
matches(expression: Expression): boolean;
|
|
87
|
+
|
|
88
|
+
/** Get current tag name, or `undefined` if path is empty. */
|
|
89
|
+
getCurrentTag(): string | undefined;
|
|
90
|
+
|
|
91
|
+
/** Get current namespace, or `undefined` if not present. */
|
|
92
|
+
getCurrentNamespace(): string | undefined;
|
|
93
|
+
|
|
94
|
+
/** Get attribute value of the current node. */
|
|
95
|
+
getAttrValue(attrName: string): any;
|
|
96
|
+
|
|
97
|
+
/** Check if the current node has a given attribute. */
|
|
98
|
+
hasAttr(attrName: string): boolean;
|
|
99
|
+
|
|
100
|
+
/** Sibling position of the current node (child index in parent). */
|
|
101
|
+
getPosition(): number;
|
|
102
|
+
|
|
103
|
+
/** Occurrence counter of the current tag name at this level. */
|
|
104
|
+
getCounter(): number;
|
|
105
|
+
|
|
106
|
+
/** Number of nodes in the current path. */
|
|
107
|
+
getDepth(): number;
|
|
108
|
+
|
|
109
|
+
/** Current path as a string (e.g. `"root.users.user"`). */
|
|
110
|
+
toString(separator?: string, includeNamespace?: boolean): string;
|
|
111
|
+
|
|
112
|
+
/** Current path as an array of tag names. */
|
|
113
|
+
toArray(): string[];
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create a snapshot of the current state.
|
|
117
|
+
* The snapshot can be passed to the real Matcher.restore if needed.
|
|
118
|
+
*/
|
|
119
|
+
snapshot(): MatcherSnapshot;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Internal node structure — exposed via snapshot only. */
|
|
123
|
+
export interface PathNode {
|
|
124
|
+
tag: string;
|
|
125
|
+
namespace?: string;
|
|
126
|
+
position: number;
|
|
127
|
+
counter: number;
|
|
128
|
+
values?: Record<string, any>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Snapshot of matcher state returned by `snapshot()` and `readOnly().snapshot()`. */
|
|
132
|
+
export interface MatcherSnapshot {
|
|
133
|
+
path: PathNode[];
|
|
134
|
+
siblingStacks: Map<string, number>[];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**********************************************************************
|
|
138
|
+
*
|
|
139
|
+
* END of path-expression-matcher relevant typings
|
|
140
|
+
*
|
|
141
|
+
**********************************************************************/
|
|
2
142
|
|
|
3
143
|
// jPath: true → string
|
|
4
144
|
// jPath: false → ReadonlyMatcher
|
package/lib/pem.d.cts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types copied from path-expression-matcher
|
|
3
|
-
* @version <version>
|
|
4
|
-
* @updated <date>
|
|
5
|
-
*
|
|
6
|
-
* Update this file when path-expression-matcher releases a new version.
|
|
7
|
-
* Source: https://github.com/NaturalIntelligence/path-expression-matcher
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Options for creating an Expression
|
|
12
|
-
*/
|
|
13
|
-
interface ExpressionOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Path separator character
|
|
16
|
-
* @default '.'
|
|
17
|
-
*/
|
|
18
|
-
separator?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Parsed segment from an expression pattern
|
|
23
|
-
*/
|
|
24
|
-
interface Segment {
|
|
25
|
-
type: 'tag' | 'deep-wildcard';
|
|
26
|
-
tag?: string;
|
|
27
|
-
namespace?: string;
|
|
28
|
-
attrName?: string;
|
|
29
|
-
attrValue?: string;
|
|
30
|
-
position?: 'first' | 'last' | 'odd' | 'even' | 'nth';
|
|
31
|
-
positionValue?: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Expression - Parses and stores a tag pattern expression.
|
|
36
|
-
* Patterns are parsed once and stored in an optimized structure for fast matching.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const expr = new Expression("root.users.user");
|
|
41
|
-
* const expr2 = new Expression("..user[id]:first");
|
|
42
|
-
* const expr3 = new Expression("root/users/user", { separator: '/' });
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* Pattern Syntax:
|
|
46
|
-
* - `root.users.user` — Match exact path
|
|
47
|
-
* - `..user` — Match "user" at any depth (deep wildcard)
|
|
48
|
-
* - `user[id]` — Match user tag with "id" attribute
|
|
49
|
-
* - `user[id=123]` — Match user tag where id="123"
|
|
50
|
-
* - `user:first` — Match first occurrence of user tag
|
|
51
|
-
* - `ns::user` — Match user tag with namespace "ns"
|
|
52
|
-
* - `ns::user[id]:first` — Combine namespace, attribute, and position
|
|
53
|
-
*/
|
|
54
|
-
declare class Expression {
|
|
55
|
-
readonly pattern: string;
|
|
56
|
-
readonly separator: string;
|
|
57
|
-
readonly segments: Segment[];
|
|
58
|
-
|
|
59
|
-
constructor(pattern: string, options?: ExpressionOptions);
|
|
60
|
-
|
|
61
|
-
get length(): number;
|
|
62
|
-
hasDeepWildcard(): boolean;
|
|
63
|
-
hasAttributeCondition(): boolean;
|
|
64
|
-
hasPositionSelector(): boolean;
|
|
65
|
-
toString(): string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ---------------------------------------------------------------------------
|
|
69
|
-
// ReadonlyMatcher
|
|
70
|
-
// ---------------------------------------------------------------------------
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* A live read-only view of a Matcher instance, returned by Matcher.readOnly().
|
|
74
|
-
*
|
|
75
|
-
* All query and inspection methods work normally and always reflect the current
|
|
76
|
-
* state of the underlying matcher. State-mutating methods (`push`, `pop`,
|
|
77
|
-
* `reset`, `updateCurrent`, `restore`) are not present — calling them on the
|
|
78
|
-
* underlying Proxy throws a `TypeError` at runtime.
|
|
79
|
-
*
|
|
80
|
-
* This is the type received by all FXP user callbacks when `jPath: false`.
|
|
81
|
-
*/
|
|
82
|
-
interface ReadonlyMatcher {
|
|
83
|
-
readonly separator: string;
|
|
84
|
-
|
|
85
|
-
/** Check if current path matches an Expression. */
|
|
86
|
-
matches(expression: Expression): boolean;
|
|
87
|
-
|
|
88
|
-
/** Get current tag name, or `undefined` if path is empty. */
|
|
89
|
-
getCurrentTag(): string | undefined;
|
|
90
|
-
|
|
91
|
-
/** Get current namespace, or `undefined` if not present. */
|
|
92
|
-
getCurrentNamespace(): string | undefined;
|
|
93
|
-
|
|
94
|
-
/** Get attribute value of the current node. */
|
|
95
|
-
getAttrValue(attrName: string): any;
|
|
96
|
-
|
|
97
|
-
/** Check if the current node has a given attribute. */
|
|
98
|
-
hasAttr(attrName: string): boolean;
|
|
99
|
-
|
|
100
|
-
/** Sibling position of the current node (child index in parent). */
|
|
101
|
-
getPosition(): number;
|
|
102
|
-
|
|
103
|
-
/** Occurrence counter of the current tag name at this level. */
|
|
104
|
-
getCounter(): number;
|
|
105
|
-
|
|
106
|
-
/** Number of nodes in the current path. */
|
|
107
|
-
getDepth(): number;
|
|
108
|
-
|
|
109
|
-
/** Current path as a string (e.g. `"root.users.user"`). */
|
|
110
|
-
toString(separator?: string, includeNamespace?: boolean): string;
|
|
111
|
-
|
|
112
|
-
/** Current path as an array of tag names. */
|
|
113
|
-
toArray(): string[];
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Create a snapshot of the current state.
|
|
117
|
-
* The snapshot can be passed to the real Matcher.restore() if needed.
|
|
118
|
-
*/
|
|
119
|
-
snapshot(): MatcherSnapshot;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** Internal node structure — exposed via snapshot only. */
|
|
123
|
-
interface PathNode {
|
|
124
|
-
tag: string;
|
|
125
|
-
namespace?: string;
|
|
126
|
-
position: number;
|
|
127
|
-
counter: number;
|
|
128
|
-
values?: Record<string, any>;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** Snapshot of matcher state returned by `snapshot()` and `readOnly().snapshot()`. */
|
|
132
|
-
interface MatcherSnapshot {
|
|
133
|
-
path: PathNode[];
|
|
134
|
-
siblingStacks: Map<string, number>[];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
declare namespace pem {
|
|
138
|
-
export {
|
|
139
|
-
Expression,
|
|
140
|
-
ExpressionOptions,
|
|
141
|
-
Segment,
|
|
142
|
-
ReadonlyMatcher,
|
|
143
|
-
PathNode,
|
|
144
|
-
MatcherSnapshot,
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export = pem;
|
package/src/pem.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types copied from path-expression-matcher
|
|
3
|
-
* @version <version>
|
|
4
|
-
* @updated <date>
|
|
5
|
-
*
|
|
6
|
-
* Update this file when path-expression-matcher releases a new version.
|
|
7
|
-
* Source: https://github.com/NaturalIntelligence/path-expression-matcher
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Options for creating an Expression
|
|
12
|
-
*/
|
|
13
|
-
export interface ExpressionOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Path separator character
|
|
16
|
-
* @default '.'
|
|
17
|
-
*/
|
|
18
|
-
separator?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Parsed segment from an expression pattern
|
|
23
|
-
*/
|
|
24
|
-
export interface Segment {
|
|
25
|
-
type: 'tag' | 'deep-wildcard';
|
|
26
|
-
tag?: string;
|
|
27
|
-
namespace?: string;
|
|
28
|
-
attrName?: string;
|
|
29
|
-
attrValue?: string;
|
|
30
|
-
position?: 'first' | 'last' | 'odd' | 'even' | 'nth';
|
|
31
|
-
positionValue?: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Expression - Parses and stores a tag pattern expression.
|
|
36
|
-
* Patterns are parsed once and stored in an optimized structure for fast matching.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const expr = new Expression("root.users.user");
|
|
41
|
-
* const expr2 = new Expression("..user[id]:first");
|
|
42
|
-
* const expr3 = new Expression("root/users/user", { separator: '/' });
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* Pattern Syntax:
|
|
46
|
-
* - `root.users.user` — Match exact path
|
|
47
|
-
* - `..user` — Match "user" at any depth (deep wildcard)
|
|
48
|
-
* - `user[id]` — Match user tag with "id" attribute
|
|
49
|
-
* - `user[id=123]` — Match user tag where id="123"
|
|
50
|
-
* - `user:first` — Match first occurrence of user tag
|
|
51
|
-
* - `ns::user` — Match user tag with namespace "ns"
|
|
52
|
-
* - `ns::user[id]:first` — Combine namespace, attribute, and position
|
|
53
|
-
*/
|
|
54
|
-
export class Expression {
|
|
55
|
-
readonly pattern: string;
|
|
56
|
-
readonly separator: string;
|
|
57
|
-
readonly segments: Segment[];
|
|
58
|
-
|
|
59
|
-
constructor(pattern: string, options?: ExpressionOptions);
|
|
60
|
-
|
|
61
|
-
get length(): number;
|
|
62
|
-
hasDeepWildcard(): boolean;
|
|
63
|
-
hasAttributeCondition(): boolean;
|
|
64
|
-
hasPositionSelector(): boolean;
|
|
65
|
-
toString(): string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ---------------------------------------------------------------------------
|
|
69
|
-
// ReadonlyMatcher
|
|
70
|
-
// ---------------------------------------------------------------------------
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* A live read-only view of a {@link Matcher} instance, returned by {@link Matcher.readOnly}.
|
|
74
|
-
*
|
|
75
|
-
* All query and inspection methods work normally and always reflect the current
|
|
76
|
-
* state of the underlying matcher. State-mutating methods (`push`, `pop`,
|
|
77
|
-
* `reset`, `updateCurrent`, `restore`) are not present — calling them on the
|
|
78
|
-
* underlying Proxy throws a `TypeError` at runtime.
|
|
79
|
-
*
|
|
80
|
-
* This is the type received by all FXP user callbacks when `jPath: false`.
|
|
81
|
-
*/
|
|
82
|
-
export interface ReadonlyMatcher {
|
|
83
|
-
readonly separator: string;
|
|
84
|
-
|
|
85
|
-
/** Check if current path matches an Expression. */
|
|
86
|
-
matches(expression: Expression): boolean;
|
|
87
|
-
|
|
88
|
-
/** Get current tag name, or `undefined` if path is empty. */
|
|
89
|
-
getCurrentTag(): string | undefined;
|
|
90
|
-
|
|
91
|
-
/** Get current namespace, or `undefined` if not present. */
|
|
92
|
-
getCurrentNamespace(): string | undefined;
|
|
93
|
-
|
|
94
|
-
/** Get attribute value of the current node. */
|
|
95
|
-
getAttrValue(attrName: string): any;
|
|
96
|
-
|
|
97
|
-
/** Check if the current node has a given attribute. */
|
|
98
|
-
hasAttr(attrName: string): boolean;
|
|
99
|
-
|
|
100
|
-
/** Sibling position of the current node (child index in parent). */
|
|
101
|
-
getPosition(): number;
|
|
102
|
-
|
|
103
|
-
/** Occurrence counter of the current tag name at this level. */
|
|
104
|
-
getCounter(): number;
|
|
105
|
-
|
|
106
|
-
/** Number of nodes in the current path. */
|
|
107
|
-
getDepth(): number;
|
|
108
|
-
|
|
109
|
-
/** Current path as a string (e.g. `"root.users.user"`). */
|
|
110
|
-
toString(separator?: string, includeNamespace?: boolean): string;
|
|
111
|
-
|
|
112
|
-
/** Current path as an array of tag names. */
|
|
113
|
-
toArray(): string[];
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Create a snapshot of the current state.
|
|
117
|
-
* The snapshot can be passed to the real {@link Matcher.restore} if needed.
|
|
118
|
-
*/
|
|
119
|
-
snapshot(): MatcherSnapshot;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** Internal node structure — exposed via snapshot only. */
|
|
123
|
-
export interface PathNode {
|
|
124
|
-
tag: string;
|
|
125
|
-
namespace?: string;
|
|
126
|
-
position: number;
|
|
127
|
-
counter: number;
|
|
128
|
-
values?: Record<string, any>;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** Snapshot of matcher state returned by `snapshot()` and `readOnly().snapshot()`. */
|
|
132
|
-
export interface MatcherSnapshot {
|
|
133
|
-
path: PathNode[];
|
|
134
|
-
siblingStacks: Map<string, number>[];
|
|
135
|
-
}
|