@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.
Files changed (100) hide show
  1. package/dist/.vite/manifest.json +4 -4
  2. package/dist/adapter/WHAT/WHATNode.d.ts +30 -0
  3. package/dist/adapter/WHAT/kind.d.ts +11 -0
  4. package/dist/adapter/WHAT/names.d.ts +6 -0
  5. package/dist/adapter/WHAT/optimizations.d.ts +37 -0
  6. package/dist/adapter/WHAT/platform.d.ts +6 -0
  7. package/dist/adapter/WHAT/traversal.d.ts +14 -0
  8. package/dist/adapter/WHAT/values.d.ts +2 -0
  9. package/dist/adapter/WHAT/whatDOMAdapter.d.ts +5 -0
  10. package/dist/adapter/defaults.d.ts +26 -0
  11. package/dist/adapter/interface/XPathCustomUnwrappableNode.d.ts +55 -0
  12. package/dist/adapter/interface/XPathDOMAdapter.d.ts +16 -0
  13. package/dist/adapter/interface/XPathDOMOptimizableOperations.d.ts +13 -0
  14. package/dist/adapter/interface/XPathNameAdapter.d.ts +23 -0
  15. package/dist/adapter/interface/XPathNode.d.ts +164 -0
  16. package/dist/adapter/interface/XPathNodeKindAdapter.d.ts +15 -0
  17. package/dist/adapter/interface/XPathTraversalAdapter.d.ts +38 -0
  18. package/dist/adapter/interface/XPathValueAdapter.d.ts +9 -0
  19. package/dist/adapter/xpathDOMProvider.d.ts +80 -0
  20. package/dist/context/Context.d.ts +12 -9
  21. package/dist/context/EvaluationContext.d.ts +18 -28
  22. package/dist/error/IncompatibleRuntimeEnvironmentError.d.ts +2 -0
  23. package/dist/evaluations/BooleanEvaluation.d.ts +4 -3
  24. package/dist/evaluations/DateTimeLikeEvaluation.d.ts +4 -3
  25. package/dist/evaluations/Evaluation.d.ts +12 -11
  26. package/dist/evaluations/EvaluationType.d.ts +5 -3
  27. package/dist/evaluations/LocationPathEvaluation.d.ts +44 -67
  28. package/dist/evaluations/NodeEvaluation.d.ts +6 -5
  29. package/dist/evaluations/NumberEvaluation.d.ts +4 -3
  30. package/dist/evaluations/StringEvaluation.d.ts +4 -3
  31. package/dist/evaluations/ValueEvaluation.d.ts +11 -10
  32. package/dist/evaluator/DefaultEvaluator.d.ts +16 -0
  33. package/dist/evaluator/Evaluator.d.ts +32 -25
  34. package/dist/evaluator/NamespaceResolver.d.ts +16 -9
  35. package/dist/evaluator/expression/BinaryExpressionEvaluator.d.ts +2 -1
  36. package/dist/evaluator/expression/BooleanBinaryExpressionEvaluator.d.ts +5 -4
  37. package/dist/evaluator/expression/ExpressionEvaluator.d.ts +2 -1
  38. package/dist/evaluator/expression/FilterPathExpressionEvaluator.d.ts +2 -1
  39. package/dist/evaluator/expression/FunctionCallExpressionEvaluator.d.ts +2 -1
  40. package/dist/evaluator/expression/LocationPathEvaluator.d.ts +2 -1
  41. package/dist/evaluator/expression/LocationPathExpressionEvaluator.d.ts +3 -2
  42. package/dist/evaluator/expression/NumberExpressionEvaluator.d.ts +3 -2
  43. package/dist/evaluator/expression/NumericBinaryExpressionEvaluator.d.ts +2 -1
  44. package/dist/evaluator/expression/StringExpressionEvaluator.d.ts +3 -2
  45. package/dist/evaluator/expression/UnaryExpressionEvaluator.d.ts +2 -1
  46. package/dist/evaluator/expression/UnionExpressionEvaluator.d.ts +2 -1
  47. package/dist/evaluator/functions/BooleanFunction.d.ts +2 -2
  48. package/dist/evaluator/functions/FunctionAlias.d.ts +2 -2
  49. package/dist/evaluator/functions/FunctionImplementation.d.ts +14 -13
  50. package/dist/evaluator/functions/FunctionLibrary.d.ts +6 -5
  51. package/dist/evaluator/functions/FunctionLibraryCollection.d.ts +3 -2
  52. package/dist/evaluator/functions/NodeSetFunction.d.ts +4 -3
  53. package/dist/evaluator/functions/NumberFunction.d.ts +2 -2
  54. package/dist/evaluator/functions/StringFunction.d.ts +2 -2
  55. package/dist/evaluator/functions/TypedFunctionImplementation.d.ts +5 -3
  56. package/dist/evaluator/result/BaseResult.d.ts +13 -9
  57. package/dist/evaluator/result/BooleanResult.d.ts +5 -5
  58. package/dist/evaluator/result/NodeSetResult.d.ts +28 -32
  59. package/dist/evaluator/result/NumberResult.d.ts +5 -5
  60. package/dist/evaluator/result/PrimitiveResult.d.ts +7 -7
  61. package/dist/evaluator/result/StringResult.d.ts +5 -5
  62. package/dist/evaluator/result/XPathEvaluationResult.d.ts +61 -0
  63. package/dist/evaluator/result/toXPathEvaluationResult.d.ts +5 -0
  64. package/dist/evaluator/step/Step.d.ts +1 -1
  65. package/dist/{expressionParser-BVz9yCmv.js → expressionParser-DpqfmhIO.js} +1 -4
  66. package/dist/{expressionParser-BVz9yCmv.js.map → expressionParser-DpqfmhIO.js.map} +1 -1
  67. package/dist/expressionParser.js +1 -1
  68. package/dist/functions/_shared/number.d.ts +5 -4
  69. package/dist/functions/_shared/string.d.ts +2 -1
  70. package/dist/functions/fn/boolean.d.ts +5 -5
  71. package/dist/functions/fn/node-set.d.ts +8 -8
  72. package/dist/functions/fn/number.d.ts +5 -5
  73. package/dist/functions/fn/string.d.ts +10 -10
  74. package/dist/functions/javarosa/string.d.ts +8 -1
  75. package/dist/functions/xforms/boolean.d.ts +4 -4
  76. package/dist/functions/xforms/datetime.d.ts +7 -7
  77. package/dist/functions/xforms/geo.d.ts +2 -2
  78. package/dist/functions/xforms/node-set.d.ts +16 -6
  79. package/dist/functions/xforms/number.d.ts +21 -21
  80. package/dist/functions/xforms/select.d.ts +3 -3
  81. package/dist/functions/xforms/string.d.ts +8 -8
  82. package/dist/index.d.ts +44 -1
  83. package/dist/index.js +1310 -879
  84. package/dist/index.js.map +1 -1
  85. package/dist/xforms/XFormsElementRepresentation.d.ts +15 -0
  86. package/dist/xforms/XFormsItextTranslations.d.ts +75 -23
  87. package/dist/xforms/XFormsSecondaryInstances.d.ts +4 -0
  88. package/dist/xforms/XFormsXPathEvaluator.d.ts +35 -14
  89. package/package.json +5 -3
  90. package/dist/evaluator/result/ResultType.d.ts +0 -13
  91. package/dist/evaluator/result/index.d.ts +0 -7
  92. package/dist/lib/dom/assertions.d.ts +0 -4
  93. package/dist/lib/dom/predicates.d.ts +0 -11
  94. package/dist/lib/dom/sort.d.ts +0 -1
  95. package/dist/lib/dom/traversal.d.ts +0 -21
  96. package/dist/lib/dom/types.d.ts +0 -21
  97. package/dist/lib/dom/xml.d.ts +0 -1
  98. package/dist/shared/constants.d.ts +0 -13
  99. package/dist/shared/index.d.ts +0 -2
  100. package/dist/shared/interface.d.ts +0 -33
@@ -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 { FunctionCallNode } from '../../static/grammar/SyntaxNode.ts';
@@ -11,6 +12,6 @@ export declare class FunctionCallExpressionEvaluator implements ExpressionEvalua
11
12
  readonly name: FunctionCallName;
12
13
  readonly argumentExpressions: readonly ExpressionEvaluator[];
13
14
  constructor(syntaxNode: FunctionCallNode);
14
- evaluate(context: EvaluationContext): Evaluation;
15
+ evaluate<T extends XPathNode>(context: EvaluationContext<T>): Evaluation<T>;
15
16
  }
16
17
  export {};
@@ -1,3 +1,4 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
1
2
  import { EvaluationContext } from '../../context/EvaluationContext.ts';
2
3
  import { AbsoluteLocationPathNode, FilterPathExprNode, RelativeLocationPathNode } from '../../static/grammar/SyntaxNode.ts';
3
4
  import { PathExprSteps } from '../step/Step.ts';
@@ -18,6 +19,6 @@ export declare class LocationPathEvaluator extends LocationPathExpressionEvaluat
18
19
  protected isSelf: boolean;
19
20
  protected steps: PathExprSteps;
20
21
  constructor(syntaxNode: LocationPathNode, options: LocationPathExpressionOptions);
21
- evaluateNodes(context: EvaluationContext): Iterable<Node>;
22
+ evaluateNodes<T extends XPathNode>(context: EvaluationContext<T>): Iterable<T>;
22
23
  }
23
24
  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 { ExpressionEvaluator, ExpressionNode } from './ExpressionEvaluator.ts';
4
5
  export declare abstract class LocationPathExpressionEvaluator implements ExpressionEvaluator {
5
6
  abstract readonly syntaxNode: ExpressionNode;
6
- abstract evaluateNodes(context: EvaluationContext): Iterable<Node>;
7
- evaluate(context: EvaluationContext): Evaluation<'NODE'>;
7
+ abstract evaluateNodes<T extends XPathNode>(context: EvaluationContext<T>): Iterable<T>;
8
+ evaluate<T extends XPathNode>(context: EvaluationContext<T>): Evaluation<T, 'NODE'>;
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 { NumberEvaluation } from '../../evaluations/NumberEvaluation.ts';
3
4
  import { ExpressionEvaluator, ExpressionNode } from './ExpressionEvaluator.ts';
@@ -5,6 +6,6 @@ export declare abstract class NumberExpressionEvaluator<ConstValue extends numbe
5
6
  protected readonly constValue: ConstValue;
6
7
  constructor(constValue: ConstValue);
7
8
  abstract readonly syntaxNode: ExpressionNode;
8
- abstract evaluateNumber(context: EvaluationContext): number;
9
- evaluate(context: EvaluationContext): NumberEvaluation;
9
+ abstract evaluateNumber<T extends XPathNode>(context: EvaluationContext<T>): number;
10
+ evaluate<T extends XPathNode>(context: EvaluationContext<T>): NumberEvaluation<T>;
10
11
  }
@@ -1,3 +1,4 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
1
2
  import { EvaluationContext } from '../../context/EvaluationContext.ts';
2
3
  import { NumberEvaluation } from '../../evaluations/NumberEvaluation.ts';
3
4
  import { AdditionExprNode, DivisionExprNode, ModuloExprNode, MultiplicationExprNode, SubtractionExprNode } from '../../static/grammar/SyntaxNode.ts';
@@ -7,6 +8,6 @@ type NumericOperation<Node extends NumericBinaryExprNode> = Node extends Additio
7
8
  export declare class NumericBinaryExpressionEvaluator<Node extends NumericBinaryExprNode> extends BinaryExpressionEvaluator<Node> {
8
9
  readonly operation: NumericOperation<Node>;
9
10
  constructor(node: Node);
10
- evaluate(context: EvaluationContext): NumberEvaluation;
11
+ evaluate<T extends XPathNode>(context: EvaluationContext<T>): NumberEvaluation<T>;
11
12
  }
12
13
  export {};
@@ -1,3 +1,4 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
1
2
  import { EvaluationContext } from '../../context/EvaluationContext.ts';
2
3
  import { StringEvaluation } from '../../evaluations/StringEvaluation.ts';
3
4
  import { ExpressionEvaluator, ExpressionNode } from './ExpressionEvaluator.ts';
@@ -5,6 +6,6 @@ export declare abstract class StringExpressionEvaluator<ConstValue extends strin
5
6
  protected readonly constValue: ConstValue;
6
7
  constructor(constValue: ConstValue);
7
8
  abstract readonly syntaxNode: ExpressionNode;
8
- abstract evaluateString(context: EvaluationContext): string;
9
- evaluate(context: EvaluationContext): StringEvaluation;
9
+ abstract evaluateString<T extends XPathNode>(context: EvaluationContext<T>): string;
10
+ evaluate<T extends XPathNode>(context: EvaluationContext<T>): StringEvaluation<T>;
10
11
  }
@@ -1,3 +1,4 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
1
2
  import { EvaluationContext } from '../../context/EvaluationContext.ts';
2
3
  import { UnaryExprNode } from '../../static/grammar/SyntaxNode.ts';
3
4
  import { ExpressionEvaluator } from './ExpressionEvaluator.ts';
@@ -6,5 +7,5 @@ export declare class UnaryExpressionEvaluator extends NumberExpressionEvaluator
6
7
  readonly syntaxNode: UnaryExprNode;
7
8
  readonly operand: ExpressionEvaluator;
8
9
  constructor(syntaxNode: UnaryExprNode);
9
- evaluateNumber(context: EvaluationContext): number;
10
+ evaluateNumber<T extends XPathNode>(context: EvaluationContext<T>): number;
10
11
  }
@@ -1,3 +1,4 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
1
2
  import { EvaluationContext } from '../../context/EvaluationContext.ts';
2
3
  import { UnionExprNode } from '../../static/grammar/SyntaxNode.ts';
3
4
  import { ExpressionEvaluator } from './ExpressionEvaluator.ts';
@@ -7,5 +8,5 @@ export declare class UnionExpressionEvaluator extends LocationPathExpressionEval
7
8
  readonly lhs: ExpressionEvaluator;
8
9
  readonly rhs: ExpressionEvaluator;
9
10
  constructor(syntaxNode: UnionExprNode);
10
- evaluateNodes(context: EvaluationContext): Iterable<Node>;
11
+ evaluateNodes<T extends XPathNode>(context: EvaluationContext<T>): Iterable<T>;
11
12
  }
@@ -1,5 +1,5 @@
1
1
  import { FunctionSignature } from './FunctionImplementation.ts';
2
2
  import { TypedFunctionCallable, TypedFunctionImplementation } from './TypedFunctionImplementation.ts';
3
- export declare class BooleanFunction<Length extends number> extends TypedFunctionImplementation<boolean, Length> {
4
- constructor(localName: string, signature: FunctionSignature<Length>, call: TypedFunctionCallable<boolean>);
3
+ export declare class BooleanFunction extends TypedFunctionImplementation<boolean> {
4
+ constructor(localName: string, signature: FunctionSignature, call: TypedFunctionCallable<boolean>);
5
5
  }
@@ -1,4 +1,4 @@
1
1
  import { FunctionImplementation } from './FunctionImplementation.ts';
2
- export declare class FunctionAlias<Length extends number> extends FunctionImplementation<Length> {
3
- constructor(localName: string, baseImplementation: FunctionImplementation<Length>);
2
+ export declare class FunctionAlias extends FunctionImplementation {
3
+ constructor(localName: string, baseImplementation: FunctionImplementation);
4
4
  }
@@ -1,7 +1,7 @@
1
- import { IterableReadonlyTuple } from '../../../../common/types/collections/IterableReadonlyTuple.ts';
2
- import { Context } from '../../context/Context.ts';
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
2
+ import { EvaluationContext } from '../../context/EvaluationContext.ts';
3
3
  import { Evaluation } from '../../evaluations/Evaluation.ts';
4
- import { EvaluationType } from '../../evaluations/EvaluationType.ts';
4
+ import { EvaluationType, PrimitiveEvaluationType } from '../../evaluations/EvaluationType.ts';
5
5
  import { LocationPathEvaluation } from '../../evaluations/LocationPathEvaluation.ts';
6
6
  export declare class UnknownFunctionError extends Error {
7
7
  constructor(functionName: string);
@@ -15,25 +15,26 @@ export interface Parameter {
15
15
  readonly arityType: ParameterArityType;
16
16
  readonly typeHint?: ParameterTypeHint;
17
17
  }
18
- export type FunctionSignature<Length extends number> = IterableReadonlyTuple<Parameter, Length>;
18
+ export type FunctionSignature = readonly Parameter[];
19
+ export type ArgumentEvaluation<T extends XPathNode> = Evaluation<any, PrimitiveEvaluationType> | Evaluation<T, EvaluationType>;
19
20
  export interface EvaluableArgument {
20
- evaluate(context: Context): Evaluation<EvaluationType>;
21
+ evaluate<T extends XPathNode>(context: EvaluationContext<T>): ArgumentEvaluation<T>;
21
22
  }
22
- export type ValidArguments<Arguments extends readonly EvaluableArgument[], IsValid extends boolean> = [true] extends [IsValid] ? Arguments : never;
23
+ type ValidArguments<Arguments extends readonly EvaluableArgument[], IsValid> = [
24
+ true
25
+ ] extends [IsValid] ? Arguments : never;
23
26
  interface FunctionArity {
24
27
  readonly min: number;
25
28
  readonly max: number;
26
29
  }
27
- export type FunctionCallable = <Arguments extends readonly EvaluableArgument[]>(context: LocationPathEvaluation, args: Arguments) => Evaluation;
28
- export declare class FunctionImplementation<Length extends number> {
30
+ export type FunctionCallable = <T extends XPathNode, Arguments extends readonly EvaluableArgument[]>(context: LocationPathEvaluation<T>, args: Arguments) => Evaluation<T>;
31
+ export declare class FunctionImplementation {
29
32
  readonly localName: string;
30
- readonly signature: FunctionSignature<Length>;
33
+ readonly signature: FunctionSignature;
31
34
  readonly arity: FunctionArity;
32
35
  protected readonly callable: FunctionCallable;
33
- constructor(localName: string, signature: FunctionSignature<Length>, runtimeImplementation: FunctionCallable | FunctionImplementation<any>);
34
- call(context: LocationPathEvaluation, args: readonly EvaluableArgument[]): Evaluation;
36
+ constructor(localName: string, signature: FunctionSignature, runtimeImplementation: FunctionCallable | FunctionImplementation);
37
+ call<T extends XPathNode, Args extends readonly EvaluableArgument[]>(context: LocationPathEvaluation<T>, args: Args): Evaluation<T>;
35
38
  protected validateArguments<Arguments extends readonly EvaluableArgument[]>(args: Arguments): asserts args is ValidArguments<Arguments, true>;
36
39
  }
37
- export interface AnyFunctionImplementation extends FunctionImplementation<number> {
38
- }
39
40
  export {};
@@ -1,21 +1,22 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
1
2
  import { Evaluation } from '../../evaluations/Evaluation.ts';
2
3
  import { LocationPathEvaluation } from '../../evaluations/LocationPathEvaluation.ts';
3
- import { AnyFunctionImplementation, EvaluableArgument, FunctionImplementation } from './FunctionImplementation.ts';
4
+ import { EvaluableArgument, FunctionImplementation } from './FunctionImplementation.ts';
4
5
  type NamespaceURI = string | null;
5
6
  type LocalName = string;
6
7
  interface QualifiedName {
7
8
  readonly namespaceURI: NamespaceURI;
8
9
  readonly localName: LocalName;
9
10
  }
10
- export interface LibraryFunction extends AnyFunctionImplementation {
11
+ export interface LibraryFunction extends FunctionImplementation {
11
12
  readonly qualifiedName: QualifiedName;
12
13
  }
13
14
  export declare class FunctionLibrary {
14
15
  readonly namespaceURI: string;
15
16
  protected readonly implementations: Map<LocalName, LibraryFunction>;
16
- constructor(namespaceURI: string, entries: readonly AnyFunctionImplementation[]);
17
+ constructor(namespaceURI: string, entries: readonly FunctionImplementation[]);
17
18
  has(localName: LocalName): boolean;
18
- call(localName: LocalName, context: LocationPathEvaluation, args: readonly EvaluableArgument[]): Evaluation;
19
- getImplementation(localName: LocalName): FunctionImplementation<number> | null;
19
+ call<T extends XPathNode>(localName: LocalName, context: LocationPathEvaluation<T>, args: readonly EvaluableArgument[]): Evaluation<T>;
20
+ getImplementation(localName: LocalName): FunctionImplementation | null;
20
21
  }
21
22
  export {};
@@ -1,3 +1,4 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
1
2
  import { Context } from '../../context/Context.ts';
2
3
  import { FunctionImplementation } from './FunctionImplementation.ts';
3
4
  import { FunctionLibrary } from './FunctionLibrary.ts';
@@ -35,7 +36,7 @@ export declare class FunctionLibraryCollection {
35
36
  protected readonly defaultFunctionLibraries: readonly FunctionLibrary[];
36
37
  protected readonly namespacedFunctionLibraries: ReadonlyMap<string, FunctionLibrary>;
37
38
  constructor(functionLibraries: Iterable<FunctionLibrary>, options?: FunctionLibraryCollectionOptions);
38
- getDefaultImplementation(localName: string): FunctionImplementation<number> | null;
39
- getImplementation(context: Context, name: FunctionNameLookup): FunctionImplementation<any> | null;
39
+ getDefaultImplementation(localName: string): FunctionImplementation | null;
40
+ getImplementation<T extends XPathNode>(context: Context<T>, name: FunctionNameLookup): FunctionImplementation | null;
40
41
  }
41
42
  export {};
@@ -1,6 +1,7 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
1
2
  import { LocationPathEvaluation } from '../../evaluations/LocationPathEvaluation.ts';
2
3
  import { EvaluableArgument, FunctionSignature, FunctionImplementation } from './FunctionImplementation.ts';
3
- export type NodeSetFunctionCallable = <Arguments extends readonly EvaluableArgument[]>(context: LocationPathEvaluation, args: Arguments) => Iterable<Node>;
4
- export declare class NodeSetFunction<Length extends number> extends FunctionImplementation<Length> {
5
- constructor(localName: string, signature: FunctionSignature<Length>, call: NodeSetFunctionCallable);
4
+ export type NodeSetFunctionCallable = <T extends XPathNode, Arguments extends readonly EvaluableArgument[]>(context: LocationPathEvaluation<T>, args: Arguments) => Iterable<T>;
5
+ export declare class NodeSetFunction extends FunctionImplementation {
6
+ constructor(localName: string, signature: FunctionSignature, call: NodeSetFunctionCallable);
6
7
  }
@@ -1,5 +1,5 @@
1
1
  import { FunctionSignature } from './FunctionImplementation.ts';
2
2
  import { TypedFunctionCallable, TypedFunctionImplementation } from './TypedFunctionImplementation.ts';
3
- export declare class NumberFunction<Length extends number> extends TypedFunctionImplementation<number, Length> {
4
- constructor(localName: string, signature: FunctionSignature<Length>, call: TypedFunctionCallable<number>);
3
+ export declare class NumberFunction extends TypedFunctionImplementation<number> {
4
+ constructor(localName: string, signature: FunctionSignature, call: TypedFunctionCallable<number>);
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import { FunctionSignature } from './FunctionImplementation.ts';
2
2
  import { TypedFunctionCallable, TypedFunctionImplementation } from './TypedFunctionImplementation.ts';
3
- export declare class StringFunction<Length extends number> extends TypedFunctionImplementation<string, Length> {
4
- constructor(localName: string, signature: FunctionSignature<Length>, call: TypedFunctionCallable<string>);
3
+ export declare class StringFunction extends TypedFunctionImplementation<string> {
4
+ constructor(localName: string, signature: FunctionSignature, call: TypedFunctionCallable<string>);
5
5
  }
@@ -1,7 +1,9 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
1
2
  import { Evaluation } from '../../evaluations/Evaluation';
2
3
  import { LocationPathEvaluation } from '../../evaluations/LocationPathEvaluation.ts';
3
4
  import { EvaluableArgument, FunctionSignature, FunctionImplementation } from './FunctionImplementation.ts';
4
- export type TypedFunctionCallable<Type> = <Arguments extends readonly EvaluableArgument[]>(context: LocationPathEvaluation, args: Arguments) => Type;
5
- export declare class TypedFunctionImplementation<Type, Length extends number> extends FunctionImplementation<Length> {
6
- protected constructor(localName: string, TypedResult: new (context: LocationPathEvaluation, value: Type) => Evaluation, signature: FunctionSignature<Length>, call: TypedFunctionCallable<Type>);
5
+ export type TypedFunctionCallable<R> = <T extends XPathNode, Arguments extends readonly EvaluableArgument[]>(context: LocationPathEvaluation<T>, args: Arguments) => R;
6
+ export type TypedFunctionResultFactory<R> = <T extends XPathNode>(context: LocationPathEvaluation<T>, value: R) => Evaluation<T>;
7
+ export declare abstract class TypedFunctionImplementation<R> extends FunctionImplementation {
8
+ protected constructor(localName: string, signature: FunctionSignature, call: TypedFunctionCallable<R>, resultFactory: TypedFunctionResultFactory<R>);
7
9
  }
@@ -1,11 +1,9 @@
1
- declare const NODE_SET_RESULT_TYPE = -1;
2
- export type NodeSetResultType = typeof NODE_SET_RESULT_TYPE;
3
- export type PrimitiveResultType = BaseResult['BOOLEAN_TYPE'] | BaseResult['NUMBER_TYPE'] | BaseResult['STRING_TYPE'];
4
- type BaseResultType = NodeSetResultType | PrimitiveResultType;
5
- export declare abstract class BaseResult {
6
- protected abstract readonly type: BaseResultType;
7
- protected abstract readonly nodes: Iterable<Node> | null;
8
- abstract readonly isIntermediateResult: boolean;
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
2
+ import { ANY_UNORDERED_NODE_TYPE, BOOLEAN_TYPE, FIRST_ORDERED_NODE_TYPE, NUMBER_TYPE, ORDERED_NODE_ITERATOR_TYPE, ORDERED_NODE_SNAPSHOT_TYPE, STRING_TYPE, UNORDERED_NODE_ITERATOR_TYPE, UNORDERED_NODE_SNAPSHOT_TYPE, XPathEvaluationResult, XPathEvaluationResultType } from './XPathEvaluationResult.ts';
3
+ export type PrimitiveResultType = BOOLEAN_TYPE | NUMBER_TYPE | STRING_TYPE;
4
+ export type NodeSetResultType = ANY_UNORDERED_NODE_TYPE | FIRST_ORDERED_NODE_TYPE | ORDERED_NODE_ITERATOR_TYPE | ORDERED_NODE_SNAPSHOT_TYPE | UNORDERED_NODE_ITERATOR_TYPE | UNORDERED_NODE_SNAPSHOT_TYPE;
5
+ declare const NUMBER_TYPE: 1, STRING_TYPE: 2, BOOLEAN_TYPE: 3, UNORDERED_NODE_ITERATOR_TYPE: 4, ORDERED_NODE_ITERATOR_TYPE: 5, UNORDERED_NODE_SNAPSHOT_TYPE: 6, ORDERED_NODE_SNAPSHOT_TYPE: 7, ANY_UNORDERED_NODE_TYPE: 8, FIRST_ORDERED_NODE_TYPE: 9;
6
+ export declare abstract class BaseResult<T extends XPathNode> implements XPathEvaluationResult<T> {
9
7
  static readonly ANY_TYPE: 0;
10
8
  static readonly NUMBER_TYPE: 1;
11
9
  static readonly STRING_TYPE: 2;
@@ -26,9 +24,15 @@ export declare abstract class BaseResult {
26
24
  readonly ORDERED_NODE_SNAPSHOT_TYPE: 7;
27
25
  readonly ANY_UNORDERED_NODE_TYPE: 8;
28
26
  readonly FIRST_ORDERED_NODE_TYPE: 9;
29
- protected static readonly NODE_SET_RESULT_TYPE = -1;
27
+ protected abstract readonly nodes: Iterable<T> | null;
28
+ abstract readonly resultType: XPathEvaluationResultType;
29
+ abstract readonly invalidIteratorState: boolean;
30
+ abstract readonly singleNodeValue: T | null;
31
+ abstract readonly snapshotLength: number;
30
32
  abstract readonly booleanValue: boolean;
31
33
  abstract readonly numberValue: number;
32
34
  abstract readonly stringValue: string;
35
+ abstract iterateNext(): T | null;
36
+ abstract snapshotItem(index: number): T | null;
33
37
  }
34
38
  export {};
@@ -1,12 +1,12 @@
1
- import { XPathResult } from '../../shared/index.ts';
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
2
2
  import { Evaluation } from '../../evaluations/Evaluation.ts';
3
3
  import { PrimitiveResult } from './PrimitiveResult.ts';
4
- export declare class BooleanResult extends PrimitiveResult implements XPathResult {
5
- readonly isIntermediateResult = false;
6
- protected readonly type: 3;
4
+ import { XPathEvaluationResult } from './XPathEvaluationResult.ts';
5
+ export declare class BooleanResult<T extends XPathNode> extends PrimitiveResult<T> implements XPathEvaluationResult<T> {
7
6
  protected readonly nodes: null;
7
+ readonly resultType: 3;
8
8
  readonly booleanValue: boolean;
9
9
  readonly numberValue: number;
10
10
  readonly stringValue: string;
11
- constructor(evaluation: Evaluation);
11
+ constructor(evaluation: Evaluation<T>);
12
12
  }
@@ -1,54 +1,50 @@
1
- import { XPathResult, XPathResultType } from '../../shared/index.ts';
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
2
+ import { XPathDOMProvider } from '../../adapter/xpathDOMProvider.ts';
2
3
  import { Reiterable } from '../../lib/iterators/index.ts';
3
4
  import { NodeSetResultType, BaseResult } from './BaseResult.ts';
5
+ import { XPathEvaluationResult } from './XPathEvaluationResult.ts';
4
6
  interface ComputedNodeSetResult {
5
7
  readonly computedBooleanValue: boolean;
6
8
  readonly computedNumberValue: number;
7
9
  readonly computedStringValue: string;
8
10
  }
9
- export declare abstract class NodeSetResult extends BaseResult implements XPathResult {
10
- protected readonly value: Iterable<Node>;
11
- readonly isIntermediateResult: boolean;
12
- protected readonly type: NodeSetResultType;
13
- protected readonly nodes: Iterable<Node>;
11
+ export declare abstract class NodeSetResult<T extends XPathNode> extends BaseResult<T> implements XPathEvaluationResult<T> {
12
+ protected readonly domProvider: XPathDOMProvider<T>;
13
+ protected readonly value: Iterable<T>;
14
+ protected readonly nodes: Iterable<T>;
14
15
  protected computedBooleanValue: boolean | null;
15
16
  protected computedNumberValue: number | null;
16
17
  protected computedStringValue: string | null;
17
18
  get booleanValue(): boolean;
18
19
  get numberValue(): number;
19
20
  get stringValue(): string;
20
- protected computedSnapshotValue: readonly Node[] | null;
21
- abstract readonly resultType: XPathResultType;
22
- abstract readonly invalidIteratorState: boolean;
23
- abstract readonly singleNodeValue: Node | null;
24
- abstract readonly snapshotLength: number;
25
- constructor(value: Iterable<Node>);
21
+ protected computedSnapshotValue: readonly T[] | null;
22
+ abstract readonly resultType: NodeSetResultType;
23
+ constructor(domProvider: XPathDOMProvider<T>, value: Iterable<T>);
26
24
  protected compute(): ComputedNodeSetResult;
27
- abstract iterateNext(): Node | null;
28
- abstract snapshotItem(index: number): Node | null;
29
25
  }
30
- export declare class NodeSetSnapshotResult extends NodeSetResult {
31
- readonly resultType: XPathResultType;
32
- readonly snapshot: readonly Node[];
33
- readonly snapshotIterator: IterableIterator<Node>;
26
+ export declare class NodeSetSnapshotResult<T extends XPathNode> extends NodeSetResult<T> implements XPathEvaluationResult<T> {
27
+ readonly resultType: NodeSetResultType;
28
+ readonly snapshot: readonly T[];
29
+ readonly snapshotIterator: IterableIterator<T>;
34
30
  readonly snapshotLength: number;
35
31
  readonly invalidIteratorState: boolean;
36
- readonly singleNodeValue: Node | null;
37
- constructor(resultType: XPathResultType, nodes: Iterable<Node>);
38
- iterateNext(): Node | null;
39
- snapshotItem(index: number): Node | null;
32
+ readonly singleNodeValue: T | null;
33
+ constructor(domProvider: XPathDOMProvider<T>, resultType: NodeSetResultType, nodes: Iterable<T>);
34
+ iterateNext(): T | null;
35
+ snapshotItem(index: number): T | null;
40
36
  }
41
- export declare class NodeSetIteratorResult extends NodeSetResult {
42
- readonly resultType: XPathResultType;
43
- protected activeIterator: IterableIterator<Node> | null;
44
- protected nodes: Reiterable<Node>;
37
+ export declare class NodeSetIteratorResult<T extends XPathNode> extends NodeSetResult<T> implements XPathEvaluationResult<T> {
38
+ readonly resultType: NodeSetResultType;
39
+ protected activeIterator: IterableIterator<T> | null;
40
+ protected nodes: Reiterable<T>;
45
41
  readonly invalidIteratorState: boolean;
46
- protected computedSingleNodeValue: Node | null | undefined;
47
- get singleNodeValue(): Node | null;
42
+ protected computedSingleNodeValue: T | null | undefined;
43
+ get singleNodeValue(): T | null;
48
44
  get snapshotLength(): number;
49
- constructor(resultType: XPathResultType, nodes: Iterable<Node>);
50
- protected activateIterator(): IterableIterator<Node>;
51
- iterateNext(): Node | null;
52
- snapshotItem(_index: number): Node | null;
45
+ constructor(domProvider: XPathDOMProvider<T>, resultType: NodeSetResultType, nodes: Iterable<T>);
46
+ protected activateIterator(): IterableIterator<T>;
47
+ iterateNext(): T | null;
48
+ snapshotItem(_index: number): T | null;
53
49
  }
54
50
  export {};
@@ -1,12 +1,12 @@
1
- import { XPathResult } from '../../shared/index.ts';
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
2
2
  import { Evaluation } from '../../evaluations/Evaluation.ts';
3
3
  import { PrimitiveResult } from './PrimitiveResult.ts';
4
- export declare class NumberResult extends PrimitiveResult implements XPathResult {
5
- readonly isIntermediateResult = false;
6
- protected readonly type: 1;
4
+ import { XPathEvaluationResult } from './XPathEvaluationResult.ts';
5
+ export declare class NumberResult<T extends XPathNode> extends PrimitiveResult<T> implements XPathEvaluationResult<T> {
7
6
  protected readonly nodes: null;
7
+ readonly resultType: 1;
8
8
  readonly booleanValue: boolean;
9
9
  readonly numberValue: number;
10
10
  readonly stringValue: string;
11
- constructor(evaluation: Evaluation);
11
+ constructor(evaluation: Evaluation<T>);
12
12
  }
@@ -1,11 +1,11 @@
1
- import { XPathResult, XPathResultType } from '../../shared/index.ts';
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
2
2
  import { PrimitiveResultType, BaseResult } from './BaseResult.ts';
3
- export declare abstract class PrimitiveResult extends BaseResult implements XPathResult {
4
- protected abstract readonly type: PrimitiveResultType;
5
- get resultType(): XPathResultType;
6
- get singleNodeValue(): Node | null;
3
+ import { XPathEvaluationResult } from './XPathEvaluationResult.ts';
4
+ export declare abstract class PrimitiveResult<T extends XPathNode> extends BaseResult<T> implements XPathEvaluationResult<T> {
5
+ abstract readonly resultType: PrimitiveResultType;
6
+ get singleNodeValue(): T | null;
7
7
  get snapshotLength(): number;
8
8
  readonly invalidIteratorState = true;
9
- iterateNext(): Node | null;
10
- snapshotItem(_index?: number): Node | null;
9
+ iterateNext(): T | null;
10
+ snapshotItem(_index?: number): T | null;
11
11
  }
@@ -1,12 +1,12 @@
1
- import { XPathResult } from '../../shared/index.ts';
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
2
2
  import { Evaluation } from '../../evaluations/Evaluation.ts';
3
3
  import { PrimitiveResult } from './PrimitiveResult.ts';
4
- export declare class StringResult extends PrimitiveResult implements XPathResult {
5
- readonly isIntermediateResult = false;
6
- protected readonly type: 2;
4
+ import { XPathEvaluationResult } from './XPathEvaluationResult.ts';
5
+ export declare class StringResult<T extends XPathNode> extends PrimitiveResult<T> implements XPathEvaluationResult<T> {
7
6
  protected readonly nodes: null;
7
+ readonly resultType: 2;
8
8
  readonly booleanValue: boolean;
9
9
  readonly numberValue: number;
10
10
  readonly stringValue: string;
11
- constructor(evaluation: Evaluation);
11
+ constructor(evaluation: Evaluation<T>);
12
12
  }
@@ -0,0 +1,61 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
2
+ declare const ANY_TYPE: XPathResult['ANY_TYPE'];
3
+ export type ANY_TYPE = typeof ANY_TYPE;
4
+ declare const NUMBER_TYPE: XPathResult['NUMBER_TYPE'];
5
+ export type NUMBER_TYPE = typeof NUMBER_TYPE;
6
+ declare const STRING_TYPE: XPathResult['STRING_TYPE'];
7
+ export type STRING_TYPE = typeof STRING_TYPE;
8
+ declare const BOOLEAN_TYPE: XPathResult['BOOLEAN_TYPE'];
9
+ export type BOOLEAN_TYPE = typeof BOOLEAN_TYPE;
10
+ declare const UNORDERED_NODE_ITERATOR_TYPE: XPathResult['UNORDERED_NODE_ITERATOR_TYPE'];
11
+ export type UNORDERED_NODE_ITERATOR_TYPE = typeof UNORDERED_NODE_ITERATOR_TYPE;
12
+ declare const ORDERED_NODE_ITERATOR_TYPE: XPathResult['ORDERED_NODE_ITERATOR_TYPE'];
13
+ export type ORDERED_NODE_ITERATOR_TYPE = typeof ORDERED_NODE_ITERATOR_TYPE;
14
+ declare const UNORDERED_NODE_SNAPSHOT_TYPE: XPathResult['UNORDERED_NODE_SNAPSHOT_TYPE'];
15
+ export type UNORDERED_NODE_SNAPSHOT_TYPE = typeof UNORDERED_NODE_SNAPSHOT_TYPE;
16
+ declare const ORDERED_NODE_SNAPSHOT_TYPE: XPathResult['ORDERED_NODE_SNAPSHOT_TYPE'];
17
+ export type ORDERED_NODE_SNAPSHOT_TYPE = typeof ORDERED_NODE_SNAPSHOT_TYPE;
18
+ declare const ANY_UNORDERED_NODE_TYPE: XPathResult['ANY_UNORDERED_NODE_TYPE'];
19
+ export type ANY_UNORDERED_NODE_TYPE = typeof ANY_UNORDERED_NODE_TYPE;
20
+ declare const FIRST_ORDERED_NODE_TYPE: XPathResult['FIRST_ORDERED_NODE_TYPE'];
21
+ export type FIRST_ORDERED_NODE_TYPE = typeof FIRST_ORDERED_NODE_TYPE;
22
+ export declare const XPATH_EVALUATION_RESULT: {
23
+ ANY_TYPE: 0;
24
+ ANY_UNORDERED_NODE_TYPE: 8;
25
+ BOOLEAN_TYPE: 3;
26
+ FIRST_ORDERED_NODE_TYPE: 9;
27
+ NUMBER_TYPE: 1;
28
+ ORDERED_NODE_ITERATOR_TYPE: 5;
29
+ ORDERED_NODE_SNAPSHOT_TYPE: 7;
30
+ STRING_TYPE: 2;
31
+ UNORDERED_NODE_ITERATOR_TYPE: 4;
32
+ UNORDERED_NODE_SNAPSHOT_TYPE: 6;
33
+ };
34
+ export type XPathEvaluationResultType = ANY_TYPE | ANY_UNORDERED_NODE_TYPE | BOOLEAN_TYPE | FIRST_ORDERED_NODE_TYPE | NUMBER_TYPE | ORDERED_NODE_ITERATOR_TYPE | ORDERED_NODE_SNAPSHOT_TYPE | STRING_TYPE | UNORDERED_NODE_ITERATOR_TYPE | UNORDERED_NODE_SNAPSHOT_TYPE;
35
+ /**
36
+ * Establishes baseline API compatibility with the WHAT Working Group DOM
37
+ * standard {@link XPathResult}, extended to support any
38
+ * {@link XPathDOMAdapter}'s arbitrary DOM implementation.
39
+ */
40
+ export interface XPathEvaluationResult<T extends XPathNode> {
41
+ readonly booleanValue: boolean;
42
+ readonly invalidIteratorState: boolean;
43
+ readonly numberValue: number;
44
+ readonly resultType: XPathEvaluationResultType;
45
+ readonly singleNodeValue: T | null;
46
+ readonly snapshotLength: number;
47
+ readonly stringValue: string;
48
+ readonly ANY_TYPE: ANY_TYPE;
49
+ readonly ANY_UNORDERED_NODE_TYPE: ANY_UNORDERED_NODE_TYPE;
50
+ readonly BOOLEAN_TYPE: BOOLEAN_TYPE;
51
+ readonly FIRST_ORDERED_NODE_TYPE: FIRST_ORDERED_NODE_TYPE;
52
+ readonly NUMBER_TYPE: NUMBER_TYPE;
53
+ readonly ORDERED_NODE_ITERATOR_TYPE: ORDERED_NODE_ITERATOR_TYPE;
54
+ readonly ORDERED_NODE_SNAPSHOT_TYPE: ORDERED_NODE_SNAPSHOT_TYPE;
55
+ readonly STRING_TYPE: STRING_TYPE;
56
+ readonly UNORDERED_NODE_ITERATOR_TYPE: UNORDERED_NODE_ITERATOR_TYPE;
57
+ readonly UNORDERED_NODE_SNAPSHOT_TYPE: UNORDERED_NODE_SNAPSHOT_TYPE;
58
+ iterateNext(): T | null;
59
+ snapshotItem(index: number): T | null;
60
+ }
61
+ export {};
@@ -0,0 +1,5 @@
1
+ import { XPathNode } from '../../adapter/interface/XPathNode.ts';
2
+ import { XPathDOMProvider } from '../../adapter/xpathDOMProvider.ts';
3
+ import { Evaluation } from '../../evaluations/Evaluation.ts';
4
+ import { XPathEvaluationResult, XPathEvaluationResultType } from './XPathEvaluationResult.ts';
5
+ export declare const toXPathEvaluationResult: <T extends XPathNode>(domProvider: XPathDOMProvider<T>, resultType: XPathEvaluationResultType, evaluation: Evaluation<T>) => XPathEvaluationResult<T>;
@@ -1,5 +1,5 @@
1
1
  import { AbsoluteLocationPathNode, FilterPathExprNode, PredicateNode, RelativeLocationPathNode } from '../../static/grammar/SyntaxNode.ts';
2
- type AxisType = 'ancestor-or-self' | 'ancestor' | 'attribute' | 'child' | 'descendant-or-self' | 'descendant' | 'following-sibling' | 'following' | 'namespace' | 'parent' | 'preceding-sibling' | 'preceding' | 'self';
2
+ export type AxisType = 'ancestor-or-self' | 'ancestor' | 'attribute' | 'child' | 'descendant-or-self' | 'descendant' | 'following-sibling' | 'following' | 'namespace' | 'parent' | 'preceding-sibling' | 'preceding' | 'self';
3
3
  type NodeType = '__NAMED__' | 'comment' | 'node' | 'processing-instruction' | 'text';
4
4
  type StepType = 'NodeTypeTest' | 'ProcessingInstructionNameTest' | 'QualifiedNameTest' | 'NodeNameTest' | 'QualifiedWildcardTest' | 'UnqualifiedWildcardTest';
5
5
  export declare abstract class BaseStep {
@@ -3468,9 +3468,6 @@ class ExpressionParser {
3468
3468
  return new SyntaxTree(parsed);
3469
3469
  });
3470
3470
  }
3471
- [Symbol.dispose]() {
3472
- this.cache.clear();
3473
- }
3474
3471
  }
3475
3472
 
3476
3473
  const expressionParser = await ExpressionParser.init({
@@ -3479,4 +3476,4 @@ const expressionParser = await ExpressionParser.init({
3479
3476
  });
3480
3477
 
3481
3478
  export { UpsertableMap as U, getDefaultExportFromCjs as a, commonjsGlobal as c, expressionParser as e, getAugmentedNamespace as g };
3482
- //# sourceMappingURL=expressionParser-BVz9yCmv.js.map
3479
+ //# sourceMappingURL=expressionParser-DpqfmhIO.js.map