@getodk/xpath 0.2.1 → 0.3.0
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/.vite/manifest.json +4 -4
- package/dist/adapter/WHAT/WHATNode.d.ts +30 -0
- package/dist/adapter/WHAT/kind.d.ts +11 -0
- package/dist/adapter/WHAT/names.d.ts +6 -0
- package/dist/adapter/WHAT/optimizations.d.ts +37 -0
- package/dist/adapter/WHAT/platform.d.ts +6 -0
- package/dist/adapter/WHAT/traversal.d.ts +14 -0
- package/dist/adapter/WHAT/values.d.ts +2 -0
- package/dist/adapter/WHAT/whatDOMAdapter.d.ts +5 -0
- package/dist/adapter/defaults.d.ts +26 -0
- package/dist/adapter/interface/XPathCustomUnwrappableNode.d.ts +55 -0
- package/dist/adapter/interface/XPathDOMAdapter.d.ts +16 -0
- package/dist/adapter/interface/XPathDOMOptimizableOperations.d.ts +13 -0
- package/dist/adapter/interface/XPathNameAdapter.d.ts +23 -0
- package/dist/adapter/interface/XPathNode.d.ts +164 -0
- package/dist/adapter/interface/XPathNodeKindAdapter.d.ts +15 -0
- package/dist/adapter/interface/XPathTraversalAdapter.d.ts +38 -0
- package/dist/adapter/interface/XPathValueAdapter.d.ts +9 -0
- package/dist/adapter/xpathDOMProvider.d.ts +80 -0
- package/dist/context/Context.d.ts +12 -9
- package/dist/context/EvaluationContext.d.ts +18 -28
- package/dist/error/IncompatibleRuntimeEnvironmentError.d.ts +2 -0
- package/dist/evaluations/BooleanEvaluation.d.ts +4 -3
- package/dist/evaluations/DateTimeLikeEvaluation.d.ts +4 -3
- package/dist/evaluations/Evaluation.d.ts +12 -11
- package/dist/evaluations/EvaluationType.d.ts +5 -3
- package/dist/evaluations/LocationPathEvaluation.d.ts +44 -67
- package/dist/evaluations/NodeEvaluation.d.ts +6 -5
- package/dist/evaluations/NumberEvaluation.d.ts +4 -3
- package/dist/evaluations/StringEvaluation.d.ts +4 -3
- package/dist/evaluations/ValueEvaluation.d.ts +11 -10
- package/dist/evaluator/DefaultEvaluator.d.ts +16 -0
- package/dist/evaluator/Evaluator.d.ts +32 -25
- package/dist/evaluator/NamespaceResolver.d.ts +16 -9
- package/dist/evaluator/expression/BinaryExpressionEvaluator.d.ts +2 -1
- package/dist/evaluator/expression/BooleanBinaryExpressionEvaluator.d.ts +5 -4
- package/dist/evaluator/expression/ExpressionEvaluator.d.ts +2 -1
- package/dist/evaluator/expression/FilterPathExpressionEvaluator.d.ts +2 -1
- package/dist/evaluator/expression/FunctionCallExpressionEvaluator.d.ts +2 -1
- package/dist/evaluator/expression/LocationPathEvaluator.d.ts +2 -1
- package/dist/evaluator/expression/LocationPathExpressionEvaluator.d.ts +3 -2
- package/dist/evaluator/expression/NumberExpressionEvaluator.d.ts +3 -2
- package/dist/evaluator/expression/NumericBinaryExpressionEvaluator.d.ts +2 -1
- package/dist/evaluator/expression/StringExpressionEvaluator.d.ts +3 -2
- package/dist/evaluator/expression/UnaryExpressionEvaluator.d.ts +2 -1
- package/dist/evaluator/expression/UnionExpressionEvaluator.d.ts +2 -1
- package/dist/evaluator/functions/BooleanFunction.d.ts +2 -2
- package/dist/evaluator/functions/FunctionAlias.d.ts +2 -2
- package/dist/evaluator/functions/FunctionImplementation.d.ts +14 -13
- package/dist/evaluator/functions/FunctionLibrary.d.ts +6 -5
- package/dist/evaluator/functions/FunctionLibraryCollection.d.ts +3 -2
- package/dist/evaluator/functions/NodeSetFunction.d.ts +4 -3
- package/dist/evaluator/functions/NumberFunction.d.ts +2 -2
- package/dist/evaluator/functions/StringFunction.d.ts +2 -2
- package/dist/evaluator/functions/TypedFunctionImplementation.d.ts +5 -3
- package/dist/evaluator/result/BaseResult.d.ts +13 -9
- package/dist/evaluator/result/BooleanResult.d.ts +5 -5
- package/dist/evaluator/result/NodeSetResult.d.ts +28 -32
- package/dist/evaluator/result/NumberResult.d.ts +5 -5
- package/dist/evaluator/result/PrimitiveResult.d.ts +7 -7
- package/dist/evaluator/result/StringResult.d.ts +5 -5
- package/dist/evaluator/result/XPathEvaluationResult.d.ts +61 -0
- package/dist/evaluator/result/toXPathEvaluationResult.d.ts +5 -0
- package/dist/evaluator/step/Step.d.ts +1 -1
- package/dist/{expressionParser-BVz9yCmv.js → expressionParser-DpqfmhIO.js} +1 -4
- package/dist/{expressionParser-BVz9yCmv.js.map → expressionParser-DpqfmhIO.js.map} +1 -1
- package/dist/expressionParser.js +1 -1
- package/dist/functions/_shared/number.d.ts +5 -4
- package/dist/functions/_shared/string.d.ts +2 -1
- package/dist/functions/fn/boolean.d.ts +5 -5
- package/dist/functions/fn/node-set.d.ts +8 -8
- package/dist/functions/fn/number.d.ts +5 -5
- package/dist/functions/fn/string.d.ts +10 -10
- package/dist/functions/javarosa/string.d.ts +8 -1
- package/dist/functions/xforms/boolean.d.ts +4 -4
- package/dist/functions/xforms/datetime.d.ts +7 -7
- package/dist/functions/xforms/geo.d.ts +2 -2
- package/dist/functions/xforms/node-set.d.ts +16 -6
- package/dist/functions/xforms/number.d.ts +21 -21
- package/dist/functions/xforms/select.d.ts +3 -3
- package/dist/functions/xforms/string.d.ts +8 -8
- package/dist/index.d.ts +44 -1
- package/dist/index.js +1310 -879
- package/dist/index.js.map +1 -1
- package/dist/xforms/XFormsElementRepresentation.d.ts +15 -0
- package/dist/xforms/XFormsItextTranslations.d.ts +75 -23
- package/dist/xforms/XFormsSecondaryInstances.d.ts +4 -0
- package/dist/xforms/XFormsXPathEvaluator.d.ts +35 -14
- package/package.json +5 -3
- package/dist/evaluator/result/ResultType.d.ts +0 -13
- package/dist/evaluator/result/index.d.ts +0 -7
- package/dist/lib/dom/assertions.d.ts +0 -4
- package/dist/lib/dom/predicates.d.ts +0 -11
- package/dist/lib/dom/sort.d.ts +0 -1
- package/dist/lib/dom/traversal.d.ts +0 -21
- package/dist/lib/dom/types.d.ts +0 -21
- package/dist/lib/dom/xml.d.ts +0 -1
- package/dist/shared/constants.d.ts +0 -13
- package/dist/shared/index.d.ts +0 -2
- package/dist/shared/interface.d.ts +0 -33
|
@@ -1,48 +1,38 @@
|
|
|
1
1
|
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
3
|
+
import { AdapterDocument, AdapterParentNode } from '../adapter/interface/XPathNodeKindAdapter.ts';
|
|
4
|
+
import { XPathDOMProvider } from '../adapter/xpathDOMProvider.ts';
|
|
2
5
|
import { LocationPathEvaluation } from '../evaluations/LocationPathEvaluation.ts';
|
|
3
6
|
import { Evaluator } from '../evaluator/Evaluator.ts';
|
|
7
|
+
import { NamespaceResolver } from '../evaluator/NamespaceResolver.ts';
|
|
4
8
|
import { FunctionLibraryCollection } from '../evaluator/functions/FunctionLibraryCollection.ts';
|
|
5
|
-
import { FilteredTreeWalker, FilteredTreeWalkers } from '../lib/dom/traversal.ts';
|
|
6
|
-
import { ContextDocument, ContextNode, ContextParentNode } from '../lib/dom/types.ts';
|
|
7
|
-
import { XPathNamespaceResolverObject } from '../shared/interface.ts';
|
|
8
9
|
import { Context } from './Context.ts';
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
readonly COMMENT: FilteredTreeWalker<'COMMENT'>;
|
|
12
|
-
readonly ELEMENT: FilteredTreeWalker<'ELEMENT'>;
|
|
13
|
-
readonly PROCESSING_INSTRUCTION: FilteredTreeWalker<'PROCESSING_INSTRUCTION'>;
|
|
14
|
-
readonly TEXT: FilteredTreeWalker<'TEXT'>;
|
|
15
|
-
constructor(contextDocument: ContextDocument, rootNode: ContextParentNode);
|
|
16
|
-
}
|
|
17
|
-
export type { EvaluationContextTreeWalkers };
|
|
18
|
-
export interface EvaluationContextOptions {
|
|
19
|
-
readonly document: ContextDocument;
|
|
20
|
-
readonly rootNode: ContextParentNode;
|
|
10
|
+
export interface EvaluationContextOptions<T extends XPathNode> {
|
|
11
|
+
readonly rootNode: AdapterParentNode<T> | null;
|
|
21
12
|
readonly functions: FunctionLibraryCollection;
|
|
22
|
-
readonly namespaceResolver:
|
|
13
|
+
readonly namespaceResolver: XPathNSResolver | null;
|
|
23
14
|
readonly timeZone: Temporal.TimeZone;
|
|
24
|
-
readonly treeWalkers: EvaluationContextTreeWalkers;
|
|
25
15
|
}
|
|
26
16
|
/**
|
|
27
17
|
* The context in which an XPath expression (**not** a sub-expression)
|
|
28
18
|
* is evaluated.
|
|
29
19
|
*/
|
|
30
|
-
export declare class EvaluationContext implements Context {
|
|
31
|
-
readonly evaluator: Evaluator
|
|
20
|
+
export declare class EvaluationContext<T extends XPathNode> implements Context<T> {
|
|
21
|
+
readonly evaluator: Evaluator<T>;
|
|
22
|
+
readonly domProvider: XPathDOMProvider<T>;
|
|
32
23
|
/**
|
|
33
24
|
* @see {@link Context.evaluationContextNode}
|
|
34
25
|
*/
|
|
35
|
-
readonly evaluationContextNode:
|
|
36
|
-
readonly contextDocument:
|
|
37
|
-
readonly rootNode:
|
|
38
|
-
readonly contextNodes: Iterable<
|
|
26
|
+
readonly evaluationContextNode: T;
|
|
27
|
+
readonly contextDocument: AdapterDocument<T>;
|
|
28
|
+
readonly rootNode: AdapterParentNode<T>;
|
|
29
|
+
readonly contextNodes: Iterable<T>;
|
|
39
30
|
readonly functions: FunctionLibraryCollection;
|
|
40
|
-
readonly namespaceResolver:
|
|
31
|
+
readonly namespaceResolver: NamespaceResolver<T>;
|
|
41
32
|
readonly timeZone: Temporal.TimeZone;
|
|
42
|
-
|
|
43
|
-
constructor(evaluator: Evaluator, contextNode: ContextNode, options?: Partial<EvaluationContextOptions>);
|
|
33
|
+
constructor(evaluator: Evaluator<T>, contextNode: T, options?: Partial<EvaluationContextOptions<T>>);
|
|
44
34
|
contextPosition(): number;
|
|
45
35
|
contextSize(): number;
|
|
46
|
-
currentContext(): LocationPathEvaluation
|
|
47
|
-
rootContext(): LocationPathEvaluation
|
|
36
|
+
currentContext<U extends XPathNode>(this: EvaluationContext<U>): LocationPathEvaluation<U>;
|
|
37
|
+
rootContext<U extends XPathNode>(this: EvaluationContext<U>): LocationPathEvaluation<U>;
|
|
48
38
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { LocationPathEvaluation } from './LocationPathEvaluation.ts';
|
|
2
3
|
import { ValueEvaluation } from './ValueEvaluation.ts';
|
|
3
|
-
export declare class BooleanEvaluation extends ValueEvaluation<'BOOLEAN'> {
|
|
4
|
-
readonly context: LocationPathEvaluation
|
|
4
|
+
export declare class BooleanEvaluation<T extends XPathNode> extends ValueEvaluation<T, 'BOOLEAN'> {
|
|
5
|
+
readonly context: LocationPathEvaluation<T>;
|
|
5
6
|
readonly value: boolean;
|
|
6
7
|
readonly type = "BOOLEAN";
|
|
7
8
|
readonly nodes: null;
|
|
8
9
|
protected readonly booleanValue: boolean;
|
|
9
10
|
protected readonly numberValue: number;
|
|
10
11
|
protected readonly stringValue: string;
|
|
11
|
-
constructor(context: LocationPathEvaluation
|
|
12
|
+
constructor(context: LocationPathEvaluation<T>, value: boolean);
|
|
12
13
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
2
3
|
import { LocationPathEvaluation } from './LocationPathEvaluation.ts';
|
|
3
4
|
import { ValueEvaluation } from './ValueEvaluation.ts';
|
|
4
5
|
interface PrecomputedXPathValues {
|
|
@@ -6,8 +7,8 @@ interface PrecomputedXPathValues {
|
|
|
6
7
|
readonly numberValue?: number;
|
|
7
8
|
readonly stringValue?: string;
|
|
8
9
|
}
|
|
9
|
-
export declare class DateTimeLikeEvaluation extends ValueEvaluation<'NUMBER'> {
|
|
10
|
-
readonly context: LocationPathEvaluation
|
|
10
|
+
export declare class DateTimeLikeEvaluation<T extends XPathNode> extends ValueEvaluation<T, 'NUMBER'> {
|
|
11
|
+
readonly context: LocationPathEvaluation<T>;
|
|
11
12
|
protected dateTime: Temporal.ZonedDateTime | null;
|
|
12
13
|
readonly type = "NUMBER";
|
|
13
14
|
readonly nodes: null;
|
|
@@ -18,6 +19,6 @@ export declare class DateTimeLikeEvaluation extends ValueEvaluation<'NUMBER'> {
|
|
|
18
19
|
protected readonly milliseconds: number;
|
|
19
20
|
protected readonly dateString: string;
|
|
20
21
|
protected readonly dateTimeString: string;
|
|
21
|
-
constructor(context: LocationPathEvaluation
|
|
22
|
+
constructor(context: LocationPathEvaluation<T>, dateTime: Temporal.ZonedDateTime | null, precomputedValues?: PrecomputedXPathValues);
|
|
22
23
|
}
|
|
23
24
|
export {};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { EvaluationType } from './EvaluationType.ts';
|
|
2
3
|
import { LocationPathEvaluation } from './LocationPathEvaluation.ts';
|
|
3
|
-
export interface Evaluation<Type extends EvaluationType = EvaluationType> extends Iterable<Evaluation<Type>> {
|
|
4
|
-
readonly context: LocationPathEvaluation
|
|
4
|
+
export interface Evaluation<T extends XPathNode, Type extends EvaluationType = EvaluationType> extends Iterable<Evaluation<T, Type>> {
|
|
5
|
+
readonly context: LocationPathEvaluation<T>;
|
|
5
6
|
readonly type: Type;
|
|
6
|
-
first(): Evaluation<Type> | null;
|
|
7
|
-
values(): Iterable<Evaluation<Type>>;
|
|
8
|
-
eq(operand: Evaluation): boolean;
|
|
9
|
-
ne(operand: Evaluation): boolean;
|
|
10
|
-
lt(operand: Evaluation): boolean;
|
|
11
|
-
lte(operand: Evaluation): boolean;
|
|
12
|
-
gt(operand: Evaluation): boolean;
|
|
13
|
-
gte(operand: Evaluation): boolean;
|
|
7
|
+
first(): Evaluation<T, Type> | null;
|
|
8
|
+
values(): Iterable<Evaluation<T, Type>>;
|
|
9
|
+
eq(operand: Evaluation<T>): boolean;
|
|
10
|
+
ne(operand: Evaluation<T>): boolean;
|
|
11
|
+
lt(operand: Evaluation<T>): boolean;
|
|
12
|
+
lte(operand: Evaluation<T>): boolean;
|
|
13
|
+
gt(operand: Evaluation<T>): boolean;
|
|
14
|
+
gte(operand: Evaluation<T>): boolean;
|
|
14
15
|
toBoolean(): boolean;
|
|
15
16
|
toNumber(): number;
|
|
16
17
|
toString(): string;
|
|
17
|
-
readonly nodes: Type extends 'NODE' ? Iterable<
|
|
18
|
+
readonly nodes: Type extends 'NODE' ? Iterable<T> : null;
|
|
18
19
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
2
|
+
export interface EvaluationTypes<T extends XPathNode> {
|
|
2
3
|
readonly BOOLEAN: boolean;
|
|
3
|
-
readonly NODE:
|
|
4
|
+
readonly NODE: T;
|
|
4
5
|
readonly NUMBER: number;
|
|
5
6
|
readonly STRING: string;
|
|
6
7
|
}
|
|
7
|
-
export type
|
|
8
|
+
export type PrimitiveEvaluationType = 'BOOLEAN' | 'NUMBER' | 'STRING';
|
|
9
|
+
export type EvaluationType = PrimitiveEvaluationType | 'NODE';
|
|
@@ -1,60 +1,51 @@
|
|
|
1
1
|
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
3
|
+
import { AdapterDocument, AdapterParentNode } from '../adapter/interface/XPathNodeKindAdapter.ts';
|
|
4
|
+
import { XPathDOMProvider } from '../adapter/xpathDOMProvider.ts';
|
|
2
5
|
import { Context } from '../context/Context.ts';
|
|
3
|
-
import { EvaluationContext
|
|
6
|
+
import { EvaluationContext } from '../context/EvaluationContext.ts';
|
|
4
7
|
import { Evaluator } from '../evaluator/Evaluator.ts';
|
|
8
|
+
import { NamespaceResolver } from '../evaluator/NamespaceResolver.ts';
|
|
5
9
|
import { FilterPathExpressionEvaluator } from '../evaluator/expression/FilterPathExpressionEvaluator.ts';
|
|
6
10
|
import { LocationPathEvaluator } from '../evaluator/expression/LocationPathEvaluator.ts';
|
|
7
11
|
import { LocationPathExpressionEvaluator } from '../evaluator/expression/LocationPathExpressionEvaluator.ts';
|
|
8
12
|
import { FunctionLibraryCollection } from '../evaluator/functions/FunctionLibraryCollection.ts';
|
|
9
13
|
import { NodeSetFunction } from '../evaluator/functions/NodeSetFunction.ts';
|
|
10
14
|
import { AnyStep } from '../evaluator/step/Step.ts';
|
|
11
|
-
import { ContextDocument, ContextNode, ContextParentNode } from '../lib/dom/types.ts';
|
|
12
15
|
import { Reiterable } from '../lib/iterators/Reiterable.ts';
|
|
13
|
-
import { XPathNamespaceResolverObject } from '../shared/interface.ts';
|
|
14
16
|
import { Evaluation } from './Evaluation.ts';
|
|
15
17
|
import { NodeEvaluation } from './NodeEvaluation.ts';
|
|
16
|
-
type LocationPathParentContext = EvaluationContext | LocationPathEvaluation
|
|
17
|
-
type EvaluationComparator = (lhs: Evaluation
|
|
18
|
-
export declare enum AxisName {
|
|
19
|
-
ANCESTOR = "ancestor",
|
|
20
|
-
ANCESTOR_OR_SELF = "ancestor-or-self",
|
|
21
|
-
ATTRIBUTE = "attribute",
|
|
22
|
-
CHILD = "child",
|
|
23
|
-
DESCENDANT = "descendant",
|
|
24
|
-
DESCENDANT_OR_SELF = "descendant-or-self",
|
|
25
|
-
FOLLOWING = "following",
|
|
26
|
-
FOLLOWING_SIBLING = "following-sibling",
|
|
27
|
-
NAMESPACE = "namespace",
|
|
28
|
-
PARENT = "parent",
|
|
29
|
-
PRECEDING = "preceding",
|
|
30
|
-
PRECEDING_SIBLING = "preceding-sibling",
|
|
31
|
-
SELF = "self"
|
|
32
|
-
}
|
|
18
|
+
type LocationPathParentContext<T extends XPathNode> = EvaluationContext<T> | LocationPathEvaluation<T>;
|
|
19
|
+
type EvaluationComparator<T extends XPathNode> = (lhs: Evaluation<T>, rhs: Evaluation<T>) => boolean;
|
|
33
20
|
interface LocationPathEvaluationOptions {
|
|
34
21
|
readonly contextPosition?: number;
|
|
35
22
|
contextSize?: () => number;
|
|
36
23
|
}
|
|
37
|
-
type ArbitraryNodesTemporaryCallee = FilterPathExpressionEvaluator | LocationPathEvaluator | NodeSetFunction
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
type ArbitraryNodesTemporaryCallee = FilterPathExpressionEvaluator | LocationPathEvaluator | NodeSetFunction;
|
|
25
|
+
type AssertLocationPathEvaluationInstance = <T extends XPathNode>(context: EvaluationContext<T>, value: unknown, message?: string) => asserts value is LocationPathEvaluation<T>;
|
|
26
|
+
export declare class LocationPathEvaluation<T extends XPathNode> implements Evaluation<T, 'NODE'>, Context<T>, EvaluationContext<T>, Iterable<LocationPathEvaluation<T>> {
|
|
27
|
+
readonly parentContext: LocationPathParentContext<T>;
|
|
28
|
+
protected static isInstance<T extends XPathNode>(context: Context<T>, value: unknown): value is LocationPathEvaluation<T>;
|
|
29
|
+
static readonly assertInstance: AssertLocationPathEvaluationInstance;
|
|
30
|
+
readonly domProvider: XPathDOMProvider<T>;
|
|
40
31
|
readonly type = "NODE";
|
|
41
|
-
protected readonly nodeEvaluations: Reiterable<NodeEvaluation
|
|
42
|
-
readonly evaluator: Evaluator
|
|
43
|
-
readonly context: LocationPathEvaluation
|
|
32
|
+
protected readonly nodeEvaluations: Reiterable<NodeEvaluation<T>>;
|
|
33
|
+
readonly evaluator: Evaluator<T>;
|
|
34
|
+
readonly context: LocationPathEvaluation<T>;
|
|
44
35
|
/**
|
|
45
36
|
* @see {@link Context.evaluationContextNode}
|
|
46
37
|
*/
|
|
47
|
-
readonly evaluationContextNode:
|
|
48
|
-
readonly contextDocument:
|
|
49
|
-
readonly rootNode:
|
|
50
|
-
|
|
51
|
-
get
|
|
38
|
+
readonly evaluationContextNode: T;
|
|
39
|
+
readonly contextDocument: AdapterDocument<T>;
|
|
40
|
+
readonly rootNode: AdapterParentNode<T>;
|
|
41
|
+
private _nodes;
|
|
42
|
+
get nodes(): Iterable<T>;
|
|
43
|
+
get contextNodes(): IterableIterator<T>;
|
|
52
44
|
protected computedContextSize: number | null;
|
|
53
45
|
protected readonly optionsContextSize?: () => number;
|
|
54
46
|
protected readonly initializedContextPosition: number;
|
|
55
47
|
readonly functions: FunctionLibraryCollection;
|
|
56
|
-
readonly namespaceResolver:
|
|
57
|
-
readonly treeWalkers: EvaluationContextTreeWalkers;
|
|
48
|
+
readonly namespaceResolver: NamespaceResolver<T>;
|
|
58
49
|
readonly timeZone: Temporal.TimeZone;
|
|
59
50
|
/**
|
|
60
51
|
* TODO: this is a temporary accommodation for these cases which are presently
|
|
@@ -66,48 +57,34 @@ export declare class LocationPathEvaluation implements Evaluation<'NODE'>, Conte
|
|
|
66
57
|
* - Nodes filtered by predicate in {@link LocationPathExpression}. Such
|
|
67
58
|
* filtering almost certainly should be performed here, in {@link step}.
|
|
68
59
|
*/
|
|
69
|
-
static fromArbitraryNodes(currentContext: LocationPathParentContext
|
|
70
|
-
static fromCurrentContext(evaluationContext: EvaluationContext): LocationPathEvaluation
|
|
71
|
-
static fromRoot(parentContext: LocationPathParentContext): LocationPathEvaluation
|
|
72
|
-
protected constructor(parentContext: LocationPathParentContext
|
|
60
|
+
static fromArbitraryNodes<T extends XPathNode>(currentContext: LocationPathParentContext<T>, nodes: Iterable<T>, _temporaryCallee: ArbitraryNodesTemporaryCallee): LocationPathEvaluation<T>;
|
|
61
|
+
static fromCurrentContext<T extends XPathNode>(evaluationContext: EvaluationContext<T>): LocationPathEvaluation<T>;
|
|
62
|
+
static fromRoot<T extends XPathNode>(parentContext: LocationPathParentContext<T>): LocationPathEvaluation<T>;
|
|
63
|
+
protected constructor(parentContext: LocationPathParentContext<T>, contextNodes: Iterable<T>, options?: LocationPathEvaluationOptions);
|
|
73
64
|
[Symbol.iterator](): {
|
|
74
|
-
next: () => IteratorResult<LocationPathEvaluation
|
|
65
|
+
next: () => IteratorResult<LocationPathEvaluation<T>>;
|
|
75
66
|
};
|
|
76
|
-
values(): Iterable<NodeEvaluation
|
|
67
|
+
values(): Iterable<NodeEvaluation<T>>;
|
|
77
68
|
contextPosition(): number;
|
|
78
69
|
contextSize(): number;
|
|
79
|
-
currentContext(): LocationPathEvaluation
|
|
80
|
-
rootContext(): LocationPathEvaluation
|
|
81
|
-
protected _first?: NodeEvaluation | null;
|
|
82
|
-
first(): NodeEvaluation | null;
|
|
70
|
+
currentContext<U extends XPathNode>(this: LocationPathEvaluation<U>): LocationPathEvaluation<U>;
|
|
71
|
+
rootContext<U extends XPathNode>(this: LocationPathEvaluation<U>): LocationPathEvaluation<U>;
|
|
72
|
+
protected _first?: NodeEvaluation<T> | null;
|
|
73
|
+
first(): NodeEvaluation<T> | null;
|
|
83
74
|
protected _isEmpty: boolean | null;
|
|
84
75
|
protected isEmpty(): boolean;
|
|
85
|
-
some(predicate: (evaluation: NodeEvaluation) => boolean): boolean;
|
|
76
|
+
some(predicate: (evaluation: NodeEvaluation<T>) => boolean): boolean;
|
|
86
77
|
toBoolean(): boolean;
|
|
87
78
|
toNumber(): number;
|
|
88
79
|
toString(): string;
|
|
89
|
-
protected compare(comparator: EvaluationComparator
|
|
90
|
-
eq(operand: Evaluation): boolean;
|
|
91
|
-
ne(operand: Evaluation): boolean;
|
|
92
|
-
lt(operand: Evaluation): boolean;
|
|
93
|
-
lte(operand: Evaluation): boolean;
|
|
94
|
-
gt(operand: Evaluation): boolean;
|
|
95
|
-
gte(operand: Evaluation): boolean;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
protected ancestorOrSelf(step: AnyStep): Iterable<ContextNode>;
|
|
99
|
-
protected attribute(): Iterable<ContextNode>;
|
|
100
|
-
protected child(step: AnyStep): Iterable<ContextNode>;
|
|
101
|
-
protected descendant(step: AnyStep): Iterable<ContextNode>;
|
|
102
|
-
protected descendantOrSelf(step: AnyStep): Iterable<ContextNode>;
|
|
103
|
-
protected following(step: AnyStep): Iterable<ContextNode>;
|
|
104
|
-
protected followingSibling(step: AnyStep): Iterable<ContextNode>;
|
|
105
|
-
protected namespace(): Iterable<ContextNode>;
|
|
106
|
-
protected parent(step: AnyStep): Iterable<ContextNode>;
|
|
107
|
-
protected preceding(step: AnyStep): Iterable<ContextNode>;
|
|
108
|
-
protected precedingSibling(step: AnyStep): Iterable<ContextNode>;
|
|
109
|
-
protected self(): Iterable<ContextNode>;
|
|
110
|
-
step(step: AnyStep): LocationPathEvaluation;
|
|
111
|
-
evaluateLocationPathExpression(expression: LocationPathExpressionEvaluator): LocationPathEvaluation;
|
|
80
|
+
protected compare(comparator: EvaluationComparator<T>, operand: Evaluation<T>): boolean;
|
|
81
|
+
eq(operand: Evaluation<T>): boolean;
|
|
82
|
+
ne(operand: Evaluation<T>): boolean;
|
|
83
|
+
lt(operand: Evaluation<T>): boolean;
|
|
84
|
+
lte(operand: Evaluation<T>): boolean;
|
|
85
|
+
gt(operand: Evaluation<T>): boolean;
|
|
86
|
+
gte(operand: Evaluation<T>): boolean;
|
|
87
|
+
step(step: AnyStep): LocationPathEvaluation<T>;
|
|
88
|
+
evaluateLocationPathExpression(expression: LocationPathExpressionEvaluator): LocationPathEvaluation<T>;
|
|
112
89
|
}
|
|
113
90
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { LocationPathEvaluation } from './LocationPathEvaluation.ts';
|
|
2
3
|
import { ValueEvaluation } from './ValueEvaluation.ts';
|
|
3
4
|
interface NodeEvaluationComputedValues {
|
|
@@ -6,17 +7,17 @@ interface NodeEvaluationComputedValues {
|
|
|
6
7
|
readonly numberValue: number;
|
|
7
8
|
readonly stringValue: string;
|
|
8
9
|
}
|
|
9
|
-
export declare class NodeEvaluation extends ValueEvaluation<'NODE'> {
|
|
10
|
-
readonly context: LocationPathEvaluation
|
|
11
|
-
readonly value:
|
|
10
|
+
export declare class NodeEvaluation<T extends XPathNode> extends ValueEvaluation<T, 'NODE'> {
|
|
11
|
+
readonly context: LocationPathEvaluation<T>;
|
|
12
|
+
readonly value: T;
|
|
12
13
|
readonly type = "NODE";
|
|
13
|
-
readonly nodes: Iterable<
|
|
14
|
+
readonly nodes: Iterable<T>;
|
|
14
15
|
protected computedValues: NodeEvaluationComputedValues | null;
|
|
15
16
|
protected get booleanValue(): boolean;
|
|
16
17
|
protected get numberValue(): number;
|
|
17
18
|
protected get stringValue(): string;
|
|
18
19
|
get isEmpty(): boolean;
|
|
19
|
-
constructor(context: LocationPathEvaluation
|
|
20
|
+
constructor(context: LocationPathEvaluation<T>, value: T);
|
|
20
21
|
protected computeValues(): NodeEvaluationComputedValues;
|
|
21
22
|
}
|
|
22
23
|
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { LocationPathEvaluation } from './LocationPathEvaluation.ts';
|
|
2
3
|
import { ValueEvaluation } from './ValueEvaluation.ts';
|
|
3
|
-
export declare class NumberEvaluation extends ValueEvaluation<'NUMBER'> {
|
|
4
|
-
readonly context: LocationPathEvaluation
|
|
4
|
+
export declare class NumberEvaluation<T extends XPathNode> extends ValueEvaluation<T, 'NUMBER'> {
|
|
5
|
+
readonly context: LocationPathEvaluation<T>;
|
|
5
6
|
readonly value: number;
|
|
6
7
|
readonly type = "NUMBER";
|
|
7
8
|
readonly nodes: null;
|
|
8
9
|
protected readonly booleanValue: boolean;
|
|
9
10
|
protected readonly numberValue: number;
|
|
10
11
|
protected readonly stringValue: string;
|
|
11
|
-
constructor(context: LocationPathEvaluation
|
|
12
|
+
constructor(context: LocationPathEvaluation<T>, value: number);
|
|
12
13
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { LocationPathEvaluation } from './LocationPathEvaluation.ts';
|
|
2
3
|
import { ValueEvaluation } from './ValueEvaluation.ts';
|
|
3
|
-
export declare class StringEvaluation extends ValueEvaluation<'STRING'> {
|
|
4
|
-
readonly context: LocationPathEvaluation
|
|
4
|
+
export declare class StringEvaluation<T extends XPathNode> extends ValueEvaluation<T, 'STRING'> {
|
|
5
|
+
readonly context: LocationPathEvaluation<T>;
|
|
5
6
|
readonly value: string;
|
|
6
7
|
readonly isEmpty: boolean;
|
|
7
8
|
readonly type = "STRING";
|
|
@@ -9,5 +10,5 @@ export declare class StringEvaluation extends ValueEvaluation<'STRING'> {
|
|
|
9
10
|
protected readonly booleanValue: boolean;
|
|
10
11
|
protected readonly numberValue: number;
|
|
11
12
|
protected readonly stringValue: string;
|
|
12
|
-
constructor(context: LocationPathEvaluation
|
|
13
|
+
constructor(context: LocationPathEvaluation<T>, value: string, isEmpty?: boolean);
|
|
13
14
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { Evaluation } from './Evaluation.ts';
|
|
2
3
|
import { EvaluationType, EvaluationTypes } from './EvaluationType.ts';
|
|
3
4
|
import { LocationPathEvaluation } from './LocationPathEvaluation.ts';
|
|
4
|
-
export declare abstract class ValueEvaluation<Type extends EvaluationType> implements Evaluation<Type> {
|
|
5
|
-
abstract readonly context: LocationPathEvaluation
|
|
5
|
+
export declare abstract class ValueEvaluation<T extends XPathNode, Type extends EvaluationType> implements Evaluation<T, Type> {
|
|
6
|
+
abstract readonly context: LocationPathEvaluation<T>;
|
|
6
7
|
abstract readonly type: Type;
|
|
7
|
-
abstract readonly value: EvaluationTypes[Type];
|
|
8
|
-
abstract readonly nodes: Type extends 'NODE' ? Iterable<
|
|
8
|
+
abstract readonly value: EvaluationTypes<T>[Type];
|
|
9
|
+
abstract readonly nodes: Type extends 'NODE' ? Iterable<T> : null;
|
|
9
10
|
protected abstract readonly booleanValue: boolean;
|
|
10
11
|
protected abstract readonly numberValue: number;
|
|
11
12
|
protected abstract readonly stringValue: string;
|
|
@@ -15,10 +16,10 @@ export declare abstract class ValueEvaluation<Type extends EvaluationType> imple
|
|
|
15
16
|
toBoolean(): boolean;
|
|
16
17
|
toNumber(): number;
|
|
17
18
|
toString(): string;
|
|
18
|
-
eq(operand: Evaluation): boolean;
|
|
19
|
-
ne(operand: Evaluation): boolean;
|
|
20
|
-
lt(operand: Evaluation): boolean;
|
|
21
|
-
lte(operand: Evaluation): boolean;
|
|
22
|
-
gt(operand: Evaluation): boolean;
|
|
23
|
-
gte(operand: Evaluation): boolean;
|
|
19
|
+
eq(operand: Evaluation<T>): boolean;
|
|
20
|
+
ne(operand: Evaluation<T>): boolean;
|
|
21
|
+
lt(operand: Evaluation<T>): boolean;
|
|
22
|
+
lte(operand: Evaluation<T>): boolean;
|
|
23
|
+
gt(operand: Evaluation<T>): boolean;
|
|
24
|
+
gte(operand: Evaluation<T>): boolean;
|
|
24
25
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DefaultDOMAdapterNode } from '../adapter/defaults.ts';
|
|
2
|
+
import { EvaluatorOptions, Evaluator } from './Evaluator.ts';
|
|
3
|
+
export interface DefaultEvaluatorOptions extends Omit<EvaluatorOptions<DefaultDOMAdapterNode>, 'domAdapter'> {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The default {@link Evaluator} implementation is suitable for use in a browser
|
|
7
|
+
* runtime, or in a browser DOM compatibility environment.
|
|
8
|
+
*
|
|
9
|
+
* @todo Give this a more descriptive name? Make {@link Evaluator} the actual
|
|
10
|
+
* default, and give {@link Evaluator} itself a more descriptive name? I.e.
|
|
11
|
+
* describing the fact that it supports—and requires—an explicit
|
|
12
|
+
* {@link XPathDOMAdapter} option.
|
|
13
|
+
*/
|
|
14
|
+
export declare class DefaultEvaluator extends Evaluator<DefaultDOMAdapterNode> {
|
|
15
|
+
constructor(options?: DefaultEvaluatorOptions);
|
|
16
|
+
}
|
|
@@ -1,41 +1,48 @@
|
|
|
1
1
|
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { UnwrapAdapterNode } from '../adapter/interface/XPathCustomUnwrappableNode.ts';
|
|
3
|
+
import { XPathDOMAdapter } from '../adapter/interface/XPathDOMAdapter.ts';
|
|
4
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
5
|
+
import { AdapterElement, AdapterParentNode } from '../adapter/interface/XPathNodeKindAdapter.ts';
|
|
6
|
+
import { XPathDOMProvider } from '../adapter/xpathDOMProvider.ts';
|
|
7
|
+
import { EvaluationContext } from '../context/EvaluationContext.ts';
|
|
5
8
|
import { ExpressionParser, ParseOptions } from '../static/grammar/ExpressionParser.ts';
|
|
6
9
|
import { FunctionLibraryCollection } from './functions/FunctionLibraryCollection.ts';
|
|
7
|
-
import {
|
|
8
|
-
|
|
10
|
+
import { XPathEvaluationResult, XPathEvaluationResultType } from './result/XPathEvaluationResult.ts';
|
|
11
|
+
type EvaluatorRootNodeOption<T extends XPathNode> = AdapterParentNode<T> | UnwrapAdapterNode<AdapterParentNode<T>>;
|
|
12
|
+
export interface EvaluatorOptions<T extends XPathNode> {
|
|
13
|
+
readonly domAdapter: XPathDOMAdapter<T>;
|
|
9
14
|
readonly functions?: FunctionLibraryCollection;
|
|
10
15
|
readonly parseOptions?: ParseOptions;
|
|
11
|
-
readonly rootNode?:
|
|
16
|
+
readonly rootNode?: EvaluatorRootNodeOption<T> | null | undefined;
|
|
12
17
|
readonly timeZoneId?: string | undefined;
|
|
13
18
|
}
|
|
14
|
-
export interface EvaluatorConvenienceMethodOptions {
|
|
15
|
-
readonly contextNode?:
|
|
19
|
+
export interface EvaluatorConvenienceMethodOptions<T extends XPathNode> {
|
|
20
|
+
readonly contextNode?: T | UnwrapAdapterNode<T>;
|
|
16
21
|
}
|
|
17
|
-
export interface EvaluatorNodeConvenienceMethodOptions<AssertExists extends boolean = false> extends EvaluatorConvenienceMethodOptions {
|
|
22
|
+
export interface EvaluatorNodeConvenienceMethodOptions<T extends XPathNode, AssertExists extends boolean = false> extends EvaluatorConvenienceMethodOptions<T> {
|
|
18
23
|
readonly assertExists?: AssertExists;
|
|
19
24
|
}
|
|
20
|
-
type EvaluatedNode<
|
|
21
|
-
export declare class Evaluator
|
|
25
|
+
type EvaluatedNode<T extends XPathNode, U extends T | UnwrapAdapterNode<T>, AssertExists extends boolean> = AssertExists extends true ? U : U | null;
|
|
26
|
+
export declare class Evaluator<T extends XPathNode> {
|
|
27
|
+
readonly domProvider: XPathDOMProvider<T>;
|
|
22
28
|
protected readonly parser: ExpressionParser;
|
|
23
29
|
readonly functions: FunctionLibraryCollection;
|
|
24
30
|
readonly parseOptions: ParseOptions;
|
|
25
|
-
readonly
|
|
26
|
-
readonly rootNodeDocument: Document | XMLDocument | null;
|
|
27
|
-
readonly rootNode: AnyParentNode | null;
|
|
28
|
-
readonly sharedContextOptions: Partial<EvaluationContextOptions>;
|
|
31
|
+
readonly rootNode: AdapterParentNode<T> | null;
|
|
29
32
|
readonly timeZone: Temporal.TimeZone;
|
|
30
|
-
constructor(options
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
constructor(options: EvaluatorOptions<T>);
|
|
34
|
+
/**
|
|
35
|
+
* @package - exposed for testing
|
|
36
|
+
*/
|
|
37
|
+
getEvaluationContext(contextNode: T | UnwrapAdapterNode<T>, namespaceResolver: Extract<T, XPathNSResolver> | XPathNSResolver | null): EvaluationContext<T>;
|
|
38
|
+
evaluate(expression: string, contextNode: T | UnwrapAdapterNode<T>, namespaceResolver: XPathNSResolver | null, resultType: XPathEvaluationResultType | null): XPathEvaluationResult<T>;
|
|
39
|
+
protected getContextNode(options: EvaluatorConvenienceMethodOptions<T>): T;
|
|
40
|
+
evaluateBoolean(expression: string, options?: EvaluatorConvenienceMethodOptions<T>): boolean;
|
|
41
|
+
evaluateNumber(expression: string, options?: EvaluatorConvenienceMethodOptions<T>): number;
|
|
42
|
+
evaluateString(expression: string, options?: EvaluatorConvenienceMethodOptions<T>): string;
|
|
43
|
+
evaluateNode<U extends T | UnwrapAdapterNode<T> = T, AssertExists extends boolean = false>(expression: string, options?: EvaluatorNodeConvenienceMethodOptions<T, AssertExists>): EvaluatedNode<T, U, AssertExists>;
|
|
44
|
+
evaluateElement<U extends AdapterElement<T> | UnwrapAdapterNode<AdapterElement<T>> = AdapterElement<T>, AssertExists extends boolean = false>(expression: string, options?: EvaluatorNodeConvenienceMethodOptions<T, AssertExists>): EvaluatedNode<T, U, AssertExists>;
|
|
45
|
+
evaluateNonNullElement<U extends AdapterElement<T> | UnwrapAdapterNode<AdapterElement<T>> = AdapterElement<T>>(expression: string, options?: Omit<EvaluatorNodeConvenienceMethodOptions<T, true>, 'assertExists'>): U;
|
|
46
|
+
evaluateNodes<U extends T | UnwrapAdapterNode<T>>(expression: string, options?: EvaluatorNodeConvenienceMethodOptions<T>): U[];
|
|
40
47
|
}
|
|
41
48
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ENKETO_NAMESPACE_URI, ENKETO_PREFIX, FN_NAMESPACE_URI, FN_PREFIX, HTML_NAMESPACE_URI, HTML_PREFIX, JAVAROSA_NAMESPACE_URI, JAVAROSA_PREFIX, ODK_NAMESPACE_URI, ODK_PREFIX, OPENROSA_XFORMS_NAMESPACE_URI, OPENROSA_XFORMS_PREFIX, XFORMS_NAMESPACE_URI, XFORMS_PREFIX, XHTML_NAMESPACE_URI, XML_NAMESPACE_URI, XML_PREFIX, XMLNS_NAMESPACE_URI, XMLNS_PREFIX } from '../../../common/src/constants/xmlns.ts';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { UnwrapAdapterNode } from '../adapter/interface/XPathCustomUnwrappableNode.ts';
|
|
3
|
+
import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
4
|
+
import { AdapterParentNode } from '../adapter/interface/XPathNodeKindAdapter.ts';
|
|
5
|
+
import { XPathDOMProvider } from '../adapter/xpathDOMProvider.ts';
|
|
4
6
|
export { ENKETO_NAMESPACE_URI, ENKETO_PREFIX, FN_NAMESPACE_URI, FN_PREFIX, HTML_NAMESPACE_URI, HTML_PREFIX, JAVAROSA_NAMESPACE_URI, JAVAROSA_PREFIX, ODK_NAMESPACE_URI, ODK_PREFIX, OPENROSA_XFORMS_NAMESPACE_URI, OPENROSA_XFORMS_PREFIX, XFORMS_NAMESPACE_URI, XFORMS_PREFIX, XHTML_NAMESPACE_URI, XML_NAMESPACE_URI, XML_PREFIX, XMLNS_NAMESPACE_URI, XMLNS_PREFIX, };
|
|
5
7
|
export interface StaticNamespaces<DefaultPrefix extends string, DefaultURI extends string, Mapping extends Record<string, string>> {
|
|
6
8
|
get<Key extends string | null>(key: Key): Key extends null ? DefaultURI : Key extends DefaultPrefix ? DefaultURI : Key extends keyof Mapping ? Mapping[Key] : undefined;
|
|
@@ -29,13 +31,18 @@ export declare const staticNamespaces: StaticNamespaces<"xf", "http://www.w3.org
|
|
|
29
31
|
readonly xml: "http://www.w3.org/XML/1998/namespace";
|
|
30
32
|
readonly xmlns: "http://www.w3.org/2000/xmlns/";
|
|
31
33
|
}>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
protected
|
|
38
|
-
protected
|
|
34
|
+
type XPathNSResolverFunction = (prefix: string | null) => string | null;
|
|
35
|
+
interface XPathNSResolverObject {
|
|
36
|
+
readonly lookupNamespaceURI: XPathNSResolverFunction;
|
|
37
|
+
}
|
|
38
|
+
export declare class NamespaceResolver<T extends XPathNode> implements XPathNSResolverObject {
|
|
39
|
+
protected readonly domProvider: XPathDOMProvider<T>;
|
|
40
|
+
protected readonly rootNode: AdapterParentNode<T>;
|
|
41
|
+
protected readonly referenceNode?: (T | null) | undefined;
|
|
42
|
+
private static isInstance;
|
|
43
|
+
static from<T extends XPathNode>(domProvider: XPathDOMProvider<T>, rootNode: AdapterParentNode<T> | UnwrapAdapterNode<AdapterParentNode<T>>, referenceNode?: T | UnwrapAdapterNode<T> | null, contextResolver?: XPathNSResolver | null): NamespaceResolver<T>;
|
|
44
|
+
protected readonly contextResolver: XPathNSResolverFunction;
|
|
45
|
+
private constructor();
|
|
39
46
|
/**
|
|
40
47
|
* Note: while it is likely consistent with the **spec** to resolve a `null`
|
|
41
48
|
* prefix, it's not typical in a browser environment for the resolver to be
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { XPathNode } from '../../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { EvaluationContext } from '../../context/EvaluationContext.ts';
|
|
2
3
|
import { Evaluation } from '../../evaluations/Evaluation.ts';
|
|
3
4
|
import { AnyBinaryExprNode } from '../../static/grammar/SyntaxNode.ts';
|
|
@@ -7,5 +8,5 @@ export declare abstract class BinaryExpressionEvaluator<Node extends AnyBinaryEx
|
|
|
7
8
|
readonly lhs: ExpressionEvaluator;
|
|
8
9
|
readonly rhs: ExpressionEvaluator;
|
|
9
10
|
constructor(syntaxNode: Node);
|
|
10
|
-
abstract evaluate(context: EvaluationContext): Evaluation
|
|
11
|
+
abstract evaluate<T extends XPathNode>(context: EvaluationContext<T>): Evaluation<T>;
|
|
11
12
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { XPathNode } from '../../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { EvaluationContext } from '../../context/EvaluationContext.ts';
|
|
2
3
|
import { BooleanEvaluation } from '../../evaluations/BooleanEvaluation.ts';
|
|
3
4
|
import { Evaluation } from '../../evaluations/Evaluation.ts';
|
|
@@ -9,9 +10,9 @@ type CompareOperator = 'eq' | 'gt' | 'gte' | 'lt' | 'lte' | 'ne';
|
|
|
9
10
|
export declare class BooleanBinaryExpressionEvaluator<Node extends BooleanBinaryExprNode> extends BinaryExpressionEvaluator<Node> {
|
|
10
11
|
readonly operator: BooleanOperator<Node>;
|
|
11
12
|
constructor(syntaxNode: Node);
|
|
12
|
-
protected and(context: EvaluationContext): Evaluation
|
|
13
|
-
protected or(context: EvaluationContext): Evaluation
|
|
14
|
-
protected compare(context: EvaluationContext
|
|
15
|
-
evaluate(context: EvaluationContext): Evaluation
|
|
13
|
+
protected and<T extends XPathNode>(context: EvaluationContext<T>): Evaluation<T>;
|
|
14
|
+
protected or<T extends XPathNode>(context: EvaluationContext<T>): Evaluation<T>;
|
|
15
|
+
protected compare<T extends XPathNode>(context: EvaluationContext<T>, operator: CompareOperator): BooleanEvaluation<T>;
|
|
16
|
+
evaluate<T extends XPathNode>(context: EvaluationContext<T>): Evaluation<T>;
|
|
16
17
|
}
|
|
17
18
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { XPathNode } from '../../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { EvaluationContext } from '../../context/EvaluationContext.ts';
|
|
2
3
|
import { Evaluation } from '../../evaluations/Evaluation.ts';
|
|
3
4
|
import { AbsoluteLocationPathNode, AnyExprNode, FilterPathExprNode, RelativeLocationPathNode } from '../../static/grammar/SyntaxNode.ts';
|
|
4
5
|
export type ExpressionNode = AbsoluteLocationPathNode | AnyExprNode | FilterPathExprNode | RelativeLocationPathNode;
|
|
5
6
|
export interface ExpressionEvaluator {
|
|
6
7
|
readonly syntaxNode: ExpressionNode;
|
|
7
|
-
evaluate(context: EvaluationContext): Evaluation
|
|
8
|
+
evaluate<T extends XPathNode>(context: EvaluationContext<T>): Evaluation<T>;
|
|
8
9
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { XPathNode } from '../../adapter/interface/XPathNode.ts';
|
|
1
2
|
import { EvaluationContext } from '../../context/EvaluationContext.ts';
|
|
2
3
|
import { FilterPathExprNode } from '../../static/grammar/SyntaxNode.ts';
|
|
3
4
|
import { ExpressionEvaluator } from './ExpressionEvaluator.ts';
|
|
@@ -8,5 +9,5 @@ export declare class FilterPathExpressionEvaluator extends LocationPathEvaluator
|
|
|
8
9
|
readonly filterExpression: LocationPathExpressionEvaluator;
|
|
9
10
|
readonly hasSteps: boolean;
|
|
10
11
|
constructor(syntaxNode: FilterPathExprNode);
|
|
11
|
-
evaluateNodes(context: EvaluationContext): Iterable<
|
|
12
|
+
evaluateNodes<T extends XPathNode>(context: EvaluationContext<T>): Iterable<T>;
|
|
12
13
|
}
|