@getodk/xpath 0.2.1 → 0.4.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 (112) 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/error/JRCompatibleError.d.ts +7 -0
  24. package/dist/error/JRCompatibleGeoValueError.d.ts +6 -0
  25. package/dist/evaluations/BooleanEvaluation.d.ts +4 -3
  26. package/dist/evaluations/DateTimeLikeEvaluation.d.ts +4 -3
  27. package/dist/evaluations/Evaluation.d.ts +12 -11
  28. package/dist/evaluations/EvaluationType.d.ts +5 -3
  29. package/dist/evaluations/LocationPathEvaluation.d.ts +44 -67
  30. package/dist/evaluations/NodeEvaluation.d.ts +6 -5
  31. package/dist/evaluations/NumberEvaluation.d.ts +4 -3
  32. package/dist/evaluations/StringEvaluation.d.ts +4 -3
  33. package/dist/evaluations/ValueEvaluation.d.ts +11 -10
  34. package/dist/evaluator/DefaultEvaluator.d.ts +16 -0
  35. package/dist/evaluator/Evaluator.d.ts +32 -25
  36. package/dist/evaluator/NamespaceResolver.d.ts +16 -9
  37. package/dist/evaluator/expression/BinaryExpressionEvaluator.d.ts +2 -1
  38. package/dist/evaluator/expression/BooleanBinaryExpressionEvaluator.d.ts +5 -4
  39. package/dist/evaluator/expression/ExpressionEvaluator.d.ts +2 -1
  40. package/dist/evaluator/expression/FilterPathExpressionEvaluator.d.ts +2 -1
  41. package/dist/evaluator/expression/FunctionCallExpressionEvaluator.d.ts +2 -1
  42. package/dist/evaluator/expression/LocationPathEvaluator.d.ts +2 -1
  43. package/dist/evaluator/expression/LocationPathExpressionEvaluator.d.ts +3 -2
  44. package/dist/evaluator/expression/NumberExpressionEvaluator.d.ts +3 -2
  45. package/dist/evaluator/expression/NumericBinaryExpressionEvaluator.d.ts +2 -1
  46. package/dist/evaluator/expression/StringExpressionEvaluator.d.ts +3 -2
  47. package/dist/evaluator/expression/UnaryExpressionEvaluator.d.ts +2 -1
  48. package/dist/evaluator/expression/UnionExpressionEvaluator.d.ts +2 -1
  49. package/dist/evaluator/functions/BooleanFunction.d.ts +2 -2
  50. package/dist/evaluator/functions/FunctionAlias.d.ts +2 -2
  51. package/dist/evaluator/functions/FunctionImplementation.d.ts +14 -13
  52. package/dist/evaluator/functions/FunctionLibrary.d.ts +6 -5
  53. package/dist/evaluator/functions/FunctionLibraryCollection.d.ts +3 -2
  54. package/dist/evaluator/functions/NodeSetFunction.d.ts +4 -3
  55. package/dist/evaluator/functions/NumberFunction.d.ts +2 -2
  56. package/dist/evaluator/functions/StringFunction.d.ts +2 -2
  57. package/dist/evaluator/functions/TypedFunctionImplementation.d.ts +5 -3
  58. package/dist/evaluator/result/BaseResult.d.ts +13 -9
  59. package/dist/evaluator/result/BooleanResult.d.ts +5 -5
  60. package/dist/evaluator/result/NodeSetResult.d.ts +28 -32
  61. package/dist/evaluator/result/NumberResult.d.ts +5 -5
  62. package/dist/evaluator/result/PrimitiveResult.d.ts +7 -7
  63. package/dist/evaluator/result/StringResult.d.ts +5 -5
  64. package/dist/evaluator/result/XPathEvaluationResult.d.ts +61 -0
  65. package/dist/evaluator/result/toXPathEvaluationResult.d.ts +5 -0
  66. package/dist/evaluator/step/Step.d.ts +1 -1
  67. package/dist/expressionParser-BYZuKGXg.js +3480 -0
  68. package/dist/expressionParser-BYZuKGXg.js.map +1 -0
  69. package/dist/expressionParser.js +1 -1
  70. package/dist/functions/_shared/number.d.ts +5 -4
  71. package/dist/functions/_shared/string.d.ts +2 -1
  72. package/dist/functions/fn/boolean.d.ts +5 -5
  73. package/dist/functions/fn/node-set.d.ts +8 -8
  74. package/dist/functions/fn/number.d.ts +5 -5
  75. package/dist/functions/fn/string.d.ts +10 -10
  76. package/dist/functions/javarosa/string.d.ts +8 -1
  77. package/dist/functions/xforms/boolean.d.ts +4 -4
  78. package/dist/functions/xforms/datetime.d.ts +7 -7
  79. package/dist/functions/xforms/geo.d.ts +2 -2
  80. package/dist/functions/xforms/node-set.d.ts +16 -6
  81. package/dist/functions/xforms/number.d.ts +21 -21
  82. package/dist/functions/xforms/select.d.ts +3 -3
  83. package/dist/functions/xforms/string.d.ts +8 -8
  84. package/dist/index.d.ts +44 -1
  85. package/dist/index.js +9964 -9644
  86. package/dist/index.js.map +1 -1
  87. package/dist/lib/collections/sort.d.ts +1 -1
  88. package/dist/lib/geo/EncodeGeoValueStubError.d.ts +4 -0
  89. package/dist/lib/geo/GeoValueCodec.d.ts +33 -0
  90. package/dist/lib/geo/Geopoint.d.ts +28 -0
  91. package/dist/lib/geo/Geotrace.d.ts +12 -0
  92. package/dist/lib/geo/GeotraceLine.d.ts +11 -0
  93. package/dist/lib/geo/encodeGeoValueStubFactory.d.ts +2 -0
  94. package/dist/lib/geo/geopointCodec.d.ts +4 -0
  95. package/dist/xforms/XFormsElementRepresentation.d.ts +15 -0
  96. package/dist/xforms/XFormsItextTranslations.d.ts +75 -23
  97. package/dist/xforms/XFormsSecondaryInstances.d.ts +4 -0
  98. package/dist/xforms/XFormsXPathEvaluator.d.ts +35 -14
  99. package/package.json +17 -12
  100. package/dist/evaluator/result/ResultType.d.ts +0 -13
  101. package/dist/evaluator/result/index.d.ts +0 -7
  102. package/dist/expressionParser-BVz9yCmv.js +0 -3482
  103. package/dist/expressionParser-BVz9yCmv.js.map +0 -1
  104. package/dist/lib/dom/assertions.d.ts +0 -4
  105. package/dist/lib/dom/predicates.d.ts +0 -11
  106. package/dist/lib/dom/sort.d.ts +0 -1
  107. package/dist/lib/dom/traversal.d.ts +0 -21
  108. package/dist/lib/dom/types.d.ts +0 -21
  109. package/dist/lib/dom/xml.d.ts +0 -1
  110. package/dist/shared/constants.d.ts +0 -13
  111. package/dist/shared/index.d.ts +0 -2
  112. package/dist/shared/interface.d.ts +0 -33
@@ -1 +1 @@
1
- export declare const seededRandomize: <T>(values: readonly T[], seed?: number) => T[];
1
+ export declare const seededRandomize: <T>(values: readonly T[], seed?: number | bigint) => T[];
@@ -0,0 +1,4 @@
1
+ import { GeoValueType } from './GeoValueCodec.ts';
2
+ export declare class EncodeGeoValueStubError extends Error {
3
+ constructor(valueType: GeoValueType);
4
+ }
@@ -0,0 +1,33 @@
1
+ export type GeoValueType = 'geopoint' | 'geoshape' | 'geotrace';
2
+ export type GeoValueEncoder<RuntimeInputValue> = (input: RuntimeInputValue) => string;
3
+ export type GeoValueDecoder<RuntimeValue> = (value: string) => RuntimeValue;
4
+ /**
5
+ * @todo This is based on the same concepts expressed by the extant
6
+ * `@getodk/xforms-engine` `ValueCodec` class. It has been stripped down a more
7
+ * minimal interface, which might form a basis for shared responsibilities for
8
+ * value type support between packages. Its introduction now anticipates an
9
+ * imminent opportunity for sharing logic for the following data types:
10
+ *
11
+ * - {@link https://getodk.github.io/xforms-spec/#data-type:geopoint | geopoint}
12
+ * - {@link https://getodk.github.io/xforms-spec/#data-type:geotrace | geotrace}
13
+ * - {@link https://getodk.github.io/xforms-spec/#data-type:geoshape | geoshape}
14
+ *
15
+ * It makes sense to consider how we share this responsibility as we expand the
16
+ * Web Forms project's support for geo-related features, as there are mutually
17
+ * dependent responsibilities for encoding/decoding between the `@getodk/xpath`
18
+ * and `@getodk/xforms-engine` packages.
19
+ *
20
+ * It's also worth considering how we might address similar shared
21
+ * responsibilities for:
22
+ *
23
+ * - non-geo data types, and potential nuances of how those types are expected
24
+ * to behave at the boundary between an ODK XForm's model, and the XPath
25
+ * expressions operating on that model's nodes
26
+ * - XPath casting semantics, and whether/how that responsiblity intersects with
27
+ * those ODK XForms data types
28
+ */
29
+ export interface GeoValueCodec<V extends GeoValueType, RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> {
30
+ readonly valueType: V;
31
+ readonly encodeValue: GeoValueEncoder<RuntimeInputValue>;
32
+ readonly decodeValue: GeoValueDecoder<RuntimeValue>;
33
+ }
@@ -0,0 +1,28 @@
1
+ export interface GeopointCoordinates {
2
+ readonly latitude: number;
3
+ readonly longitude: number;
4
+ }
5
+ /**
6
+ * @todo this is derived from an interface that was introduced _internally_, to
7
+ * support the initial implementation of these related geo functions:
8
+ *
9
+ * - {@link https://getodk.github.io/xforms-spec/#fn:area | area}
10
+ * - {@link https://getodk.github.io/xforms-spec/#fn:distance | distance}
11
+ *
12
+ * It has been extracted here as a class as a potential basis for sharing
13
+ * geo-related functionality between Web Forms packages.
14
+ *
15
+ * **IMPORTANT:** it's likely that we'll reconsider how we model a
16
+ * {@link https://getodk.github.io/xforms-spec/#data-type:geopoint | geopoint}
17
+ * value, as we consider several shared responsibilities between `@getodk/xpath`
18
+ * and `@getodk/xforms-engine`. Notably, the engine already has a conflicting
19
+ * structural runtime representation and encoding behavior, in its support for
20
+ * {@link https://getodk.github.io/xforms-spec/#secondary-instances---external | external secondary instances}
21
+ * with a {@link https://geojson.org/ | GeoJSON format}.
22
+ */
23
+ export declare class Geopoint implements GeopointCoordinates {
24
+ static fromNodeValue(nodeValue: string): Geopoint | null;
25
+ readonly latitude: number;
26
+ readonly longitude: number;
27
+ private constructor();
28
+ }
@@ -0,0 +1,12 @@
1
+ import { Geopoint } from './Geopoint.ts';
2
+ import { GeopointRuntimeValue } from './geopointCodec.ts';
3
+ import { GeotraceLine } from './GeotraceLine.ts';
4
+ export type GeotracePoints = readonly [Geopoint, Geopoint, ...Geopoint[]];
5
+ export declare class Geotrace {
6
+ readonly geopoints: GeotracePoints;
7
+ static fromEncodedGeotrace(encoded: string): Geotrace | null;
8
+ static fromEncodedValues(values: readonly string[]): Geotrace | null;
9
+ static fromGeopoints(geopoints: readonly GeopointRuntimeValue[]): Geotrace | null;
10
+ readonly lines: readonly GeotraceLine[];
11
+ private constructor();
12
+ }
@@ -0,0 +1,11 @@
1
+ import { Geopoint } from './Geopoint.ts';
2
+ interface GeotraceLinePoints {
3
+ readonly start: Geopoint;
4
+ readonly end: Geopoint;
5
+ }
6
+ export declare class GeotraceLine implements GeotraceLinePoints {
7
+ readonly start: Geopoint;
8
+ readonly end: Geopoint;
9
+ constructor(points: GeotraceLinePoints);
10
+ }
11
+ export {};
@@ -0,0 +1,2 @@
1
+ import { GeoValueEncoder, GeoValueType } from './GeoValueCodec.ts';
2
+ export declare const encodeValueStubFactory: <RuntimeInputValue>(valueType: GeoValueType) => GeoValueEncoder<RuntimeInputValue>;
@@ -0,0 +1,4 @@
1
+ import { Geopoint } from './Geopoint.ts';
2
+ import { GeoValueCodec } from './GeoValueCodec.ts';
3
+ export type GeopointRuntimeValue = Geopoint | null;
4
+ export declare const geopointCodec: GeoValueCodec<'geopoint', GeopointRuntimeValue>;
@@ -0,0 +1,15 @@
1
+ import { XPathNode } from '../adapter/interface/XPathNode.ts';
2
+ import { AdapterElement } from '../adapter/interface/XPathNodeKindAdapter.ts';
3
+ export declare const XFORMS_LOCAL_NAME: unique symbol;
4
+ export type XFORMS_LOCAL_NAME = typeof XFORMS_LOCAL_NAME;
5
+ export declare const XFORMS_KNOWN_ATTRIBUTE: unique symbol;
6
+ export type XFORMS_KNOWN_ATTRIBUTE = typeof XFORMS_KNOWN_ATTRIBUTE;
7
+ export type XFormsElementRepresentation<T extends XPathNode, LocalName extends string, KnownAttribute extends string = never> = AdapterElement<T> & {
8
+ readonly [XFORMS_LOCAL_NAME]: LocalName;
9
+ } & ([
10
+ KnownAttribute
11
+ ] extends [string] ? {
12
+ readonly [XFORMS_KNOWN_ATTRIBUTE]: KnownAttribute;
13
+ } : {
14
+ readonly [XFORMS_KNOWN_ATTRIBUTE]?: string;
15
+ });
@@ -1,26 +1,78 @@
1
- import { KnownAttributeLocalNamedElement, LocalNamedElement } from '../../../common/types/dom.ts';
2
- import { ModelElement, XFormsXPathEvaluator } from './XFormsXPathEvaluator.ts';
3
- export interface ItextRootElement extends LocalNamedElement<'itext'> {
1
+ import { UpsertableWeakMap } from '../../../common/src/lib/collections/UpsertableWeakMap.ts';
2
+ import { XPathNode } from '../adapter/interface/XPathNode.ts';
3
+ import { XPathDOMProvider } from '../adapter/xpathDOMProvider.ts';
4
+ import { XFormsElementRepresentation } from './XFormsElementRepresentation.ts';
5
+ type XFormsItextTextID = string;
6
+ type XFormsItextTranslationTextElement<T extends XPathNode> = XFormsElementRepresentation<T, 'text'>;
7
+ export type XFormsItextTranslationElement<T extends XPathNode> = XFormsElementRepresentation<T, 'translation', 'lang'>;
8
+ type XFormsItextTextMap<T extends XPathNode> = ReadonlyMap<XFormsItextTextID, XFormsItextTranslationTextElement<T>>;
9
+ type XFormsItextTranslationsCache<T extends XPathNode> = UpsertableWeakMap<XFormsItextTranslationElement<T>, XFormsItextTextMap<T>>;
10
+ export type XFormsItextTranslationLanguage = string;
11
+ export type XFormsItextTranslationMap<T extends XPathNode> = ReadonlyMap<XFormsItextTranslationLanguage, XFormsItextTranslationElement<T>>;
12
+ /**
13
+ * Public interface to an {@link XFormsXPathEvaluator}'s ODK XForms
14
+ * {@link https://getodk.github.io/xforms-spec/#languages | active language state}.
15
+ */
16
+ export interface XFormsItextTranslationsState {
17
+ getLanguages(): readonly XFormsItextTranslationLanguage[];
18
+ getActiveLanguage(): XFormsItextTranslationLanguage | null;
19
+ setActiveLanguage(language: XFormsItextTranslationLanguage | null): XFormsItextTranslationLanguage | null;
4
20
  }
5
- export declare const getItextRoot: (modelElement: ModelElement) => ItextRootElement | null;
6
- type TranslationLanguage = string;
7
- interface TranslationTextElement extends KnownAttributeLocalNamedElement<'text', 'id'> {
8
- }
9
- type ItextID = string;
10
- export declare const getTranslationTextByLanguage: (modelElement: ModelElement, language: TranslationLanguage, itextID: ItextID) => TranslationTextElement | null;
11
- interface DefaultTextValueElement extends LocalNamedElement<'value'> {
12
- getAttribute(name: 'form'): null;
13
- getAttribute(name: string): string | null;
14
- }
15
- export declare const getDefaultTextValueElement: (textElement: TranslationTextElement) => DefaultTextValueElement | null;
16
- export declare class XFormsItextTranslations {
17
- protected readonly evaluator: XFormsXPathEvaluator;
18
- protected readonly defaultLanguage: string | null;
19
- protected readonly languages: readonly string[];
20
- protected activeLanguage: string | null;
21
- constructor(evaluator: XFormsXPathEvaluator);
22
- getLanguages(): readonly string[];
23
- getActiveLanguage(): string | null;
24
- setActiveLanguage(language: string | null): string | null;
21
+ /**
22
+ * @package
23
+ *
24
+ * This is an internal implementation/API providing support for {@link itext}.
25
+ *
26
+ * As specified by
27
+ * {@link https://getodk.github.io/xforms-spec/#fn:jr:itext | ODK XForms `jr:itext`},
28
+ * the function depends on implicit "active language" state. The corresponding
29
+ * {@link XFormsItextTranslationsState} **public interface** exposes access to get
30
+ * and set that state for `@getodk/xpath` consumers.
31
+ *
32
+ * @see {@link XFormsItextTranslationsState} for the corresponding public interface.
33
+ */
34
+ export declare class XFormsItextTranslations<T extends XPathNode> implements XFormsItextTranslationsState {
35
+ readonly domProvider: XPathDOMProvider<T>;
36
+ readonly translationElementMap: XFormsItextTranslationMap<T>;
37
+ protected readonly defaultLanguage: XFormsItextTranslationLanguage | null;
38
+ protected readonly languages: readonly XFormsItextTranslationLanguage[];
39
+ protected activeLanguage: XFormsItextTranslationLanguage | null;
40
+ readonly translationsCache: XFormsItextTranslationsCache<T>;
41
+ constructor(domProvider: XPathDOMProvider<T>, translationElementMap: XFormsItextTranslationMap<T>);
42
+ private getTranslationMetadata;
43
+ private getTranslationTextElement;
44
+ /**
45
+ * @package
46
+ *
47
+ * Here, "default" is meant as more precise language than "regular" as
48
+ * {@link https://getodk.github.io/xforms-spec/#languages | specified by ODK XForms}. In other words, this is equivalent to the following hypothetical XPath pseudo-code (whitespace added to improve structural clarity):
49
+ *
50
+ * ```xpath
51
+ * string(
52
+ * imaginary:itext-translation(
53
+ * xpath3-fn:environment-variable('activeLanguage')
54
+ * )
55
+ * /text[@id = $itextID]
56
+ * /value[not(@form)]
57
+ * )
58
+ * ```
59
+ *
60
+ * Or alternately:
61
+ *
62
+ * ```xpath
63
+ * string(
64
+ * imaginary:itext-root()
65
+ * /translation[@lang = xpath3-fn:environment-variable('activeLanguage')]
66
+ * /text[@id = $itextID]
67
+ * /value[not(@form)]
68
+ * )
69
+ * ```
70
+ *
71
+ * @todo The above really feels like it adds some helpful clarity to how `jr:itext()` is designed to work, and the kinds of structures, state and input involved. Since there's already some discomfort around that API as specified, it's worth considering
72
+ */
73
+ getDefaultTranslationText(itextID: string): string;
74
+ getLanguages(): readonly XFormsItextTranslationLanguage[];
75
+ getActiveLanguage(): XFormsItextTranslationLanguage | null;
76
+ setActiveLanguage(language: XFormsItextTranslationLanguage | null): XFormsItextTranslationLanguage | null;
25
77
  }
26
78
  export {};
@@ -0,0 +1,4 @@
1
+ import { XPathNode } from '../adapter/interface/XPathNode.ts';
2
+ import { XFormsElementRepresentation } from './XFormsElementRepresentation.ts';
3
+ export type XFormsSecondaryInstanceElement<T extends XPathNode> = XFormsElementRepresentation<T, 'instance', 'id'>;
4
+ export type XFormsSecondaryInstanceMap<T extends XPathNode> = ReadonlyMap<string, XFormsSecondaryInstanceElement<T>>;
@@ -1,17 +1,38 @@
1
+ import { UnwrapAdapterNode } from '../adapter/interface/XPathCustomUnwrappableNode.ts';
2
+ import { XPathNode } from '../adapter/interface/XPathNode.ts';
3
+ import { AdapterParentNode } from '../adapter/interface/XPathNodeKindAdapter.ts';
4
+ import { EvaluationContext } from '../context/EvaluationContext.ts';
1
5
  import { EvaluatorOptions, Evaluator } from '../evaluator/Evaluator.ts';
2
- import { AnyParentNode } from '../lib/dom/types.ts';
3
- import { XFormsItextTranslations } from './XFormsItextTranslations.ts';
4
- export interface ModelElement extends Element {
5
- readonly localName: 'model';
6
+ import { XFormsItextTranslationLanguage, XFormsItextTranslationMap, XFormsItextTranslationsState } from './XFormsItextTranslations.ts';
7
+ import { XFormsSecondaryInstanceElement, XFormsSecondaryInstanceMap } from './XFormsSecondaryInstances.ts';
8
+ /**
9
+ * @todo We accept an arbitrary parent node specifically for legacy WHATWG DOM
10
+ * integration, which we will no longer be using _except in test_. We should
11
+ * consider narrowing this type to {@link AdapterDocument} for any other usage.
12
+ */
13
+ export type XFormsXPathRootNode<T extends XPathNode> = AdapterParentNode<T> | UnwrapAdapterNode<AdapterParentNode<T>>;
14
+ export interface XFormsXPathEvaluatorOptions<T extends XPathNode> extends EvaluatorOptions<T> {
15
+ readonly rootNode: XFormsXPathRootNode<T>;
16
+ readonly itextTranslationsByLanguage: XFormsItextTranslationMap<T>;
17
+ readonly secondaryInstancesById: XFormsSecondaryInstanceMap<T>;
6
18
  }
7
- interface XFormsXPathEvaluatorOptions extends EvaluatorOptions {
8
- readonly rootNode: AnyParentNode;
19
+ export declare class XFormsXPathEvaluator<T extends XPathNode> extends Evaluator<T> implements XFormsItextTranslationsState {
20
+ static getSecondaryInstance<T extends XPathNode>(context: EvaluationContext<T>, id: string): XFormsSecondaryInstanceElement<T> | null;
21
+ static getDefaultTranslationText<T extends XPathNode>(context: EvaluationContext<T>, itextID: string): string;
22
+ readonly rootNode: AdapterParentNode<T>;
23
+ /**
24
+ * @package
25
+ * @see {@link InternalXFormsXPathEvaluator}
26
+ */
27
+ protected readonly itextTranslations: XFormsItextTranslationsState;
28
+ /**
29
+ * @package
30
+ * @see {@link InternalXFormsXPathEvaluator}
31
+ */
32
+ protected readonly secondaryInstancesById: XFormsSecondaryInstanceMap<T>;
33
+ constructor(options: XFormsXPathEvaluatorOptions<T>);
34
+ getLanguages(): readonly XFormsItextTranslationLanguage[];
35
+ getActiveLanguage(): XFormsItextTranslationLanguage | null;
36
+ setActiveLanguage(language: XFormsItextTranslationLanguage | null): XFormsItextTranslationLanguage | null;
37
+ getSecondaryInstance(id: string): XFormsSecondaryInstanceElement<T> | undefined;
9
38
  }
10
- export declare class XFormsXPathEvaluator extends Evaluator {
11
- readonly rootNode: AnyParentNode;
12
- readonly rootNodeDocument: XMLDocument;
13
- readonly modelElement: ModelElement | null;
14
- readonly translations: XFormsItextTranslations;
15
- constructor(options: XFormsXPathEvaluatorOptions);
16
- }
17
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getodk/xpath",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "XPath implementation for ODK Web Forms",
6
6
  "type": "module",
@@ -31,7 +31,7 @@
31
31
  "README.md"
32
32
  ],
33
33
  "engines": {
34
- "node": "^18.20.4 || ^20.17.0 || ^22.9.0",
34
+ "node": "^18.20.5 || ^20.18.1 || ^22.12.0",
35
35
  "yarn": "1.22.22"
36
36
  },
37
37
  "scripts": {
@@ -49,27 +49,32 @@
49
49
  "test-watch:chromium": "BROWSER_NAME=chromium vitest",
50
50
  "test-watch:firefox": "BROWSER_NAME=firefox vitest",
51
51
  "test-watch:webkit": "BROWSER_NAME=webkit vitest",
52
- "test:types": "tsc --project ./tsconfig.json --emitDeclarationOnly false --noEmit"
52
+ "test:types": "npm-run-all -nl test:types:*",
53
+ "test:types:main": "tsc --project ./tsconfig.json --emitDeclarationOnly false --noEmit",
54
+ "test:types:test": "tsc --project ./test/tsconfig.json --emitDeclarationOnly false --noEmit"
53
55
  },
54
56
  "dependencies": {
55
- "@getodk/common": "0.4.0",
57
+ "@getodk/common": "0.5.1",
56
58
  "@js-temporal/polyfill": "^0.4.4",
57
59
  "crypto-js": "^4.2.0",
58
60
  "itertools-ts": "^1.27.1"
59
61
  },
60
62
  "devDependencies": {
61
- "@babel/core": "^7.25.2",
63
+ "@babel/core": "^7.26.0",
62
64
  "@getodk/tree-sitter-xpath": "0.1.2",
63
- "@playwright/test": "^1.47.2",
65
+ "@playwright/test": "^1.49.1",
64
66
  "@types/crypto-js": "^4.2.2",
65
- "@vitest/browser": "^2.1.1",
67
+ "@vitest/browser": "^2.1.8",
66
68
  "babel-plugin-transform-jsbi-to-bigint": "^1.4.0",
67
69
  "jsdom": "^25.0.1",
68
- "vite": "^5.4.8",
69
- "vite-plugin-babel": "^1.2.0",
70
- "vite-plugin-dts": "^4.2.2",
70
+ "vite": "^5.4.11",
71
+ "vite-plugin-babel": "^1.3.0",
72
+ "vite-plugin-dts": "^4.3.0",
71
73
  "vite-plugin-no-bundle": "^4.0.0",
72
- "vitest": "^2.1.1",
73
- "web-tree-sitter": "0.23.0"
74
+ "vitest": "^2.1.8",
75
+ "web-tree-sitter": "0.24.5"
76
+ },
77
+ "publishConfig": {
78
+ "access": "public"
74
79
  }
75
80
  }
@@ -1,13 +0,0 @@
1
- export declare const ResultTypes: {
2
- readonly BOOLEAN_TYPE: 3;
3
- readonly NUMBER_TYPE: 1;
4
- readonly STRING_TYPE: 2;
5
- readonly UNORDERED_NODE_ITERATOR_TYPE: 4;
6
- readonly ORDERED_NODE_ITERATOR_TYPE: 5;
7
- readonly UNORDERED_NODE_SNAPSHOT_TYPE: 6;
8
- readonly ORDERED_NODE_SNAPSHOT_TYPE: 7;
9
- readonly ANY_UNORDERED_NODE_TYPE: 8;
10
- readonly FIRST_ORDERED_NODE_TYPE: 9;
11
- };
12
- export type ResultTypes = typeof ResultTypes;
13
- export type ResultType = ResultTypes[keyof ResultTypes];
@@ -1,7 +0,0 @@
1
- import { Evaluation } from '../../evaluations/Evaluation.ts';
2
- import { XPathResultType } from '../../shared/index.ts';
3
- import { BooleanResult } from './BooleanResult';
4
- import { NodeSetIteratorResult, NodeSetSnapshotResult } from './NodeSetResult';
5
- import { NumberResult } from './NumberResult';
6
- import { StringResult } from './StringResult';
7
- export declare const toXPathResult: (resultType: XPathResultType, evaluation: Evaluation) => BooleanResult | NodeSetSnapshotResult | NodeSetIteratorResult | NumberResult | StringResult;