@getodk/xpath 0.4.1 → 0.6.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/interface/XPathDOMOptimizableOperations.d.ts +1 -1
- package/dist/adapter/interface/XPathTraversalAdapter.d.ts +4 -4
- package/dist/adapter/xpathDOMProvider.d.ts +1 -16
- package/dist/context/Context.d.ts +3 -3
- package/dist/context/EvaluationContext.d.ts +4 -4
- package/dist/evaluations/DateTimeLikeEvaluation.d.ts +1 -1
- package/dist/evaluations/Evaluation.d.ts +2 -2
- package/dist/evaluations/LocationPathEvaluation.d.ts +10 -13
- package/dist/evaluations/NodeEvaluation.d.ts +1 -1
- package/dist/evaluations/ValueEvaluation.d.ts +4 -3
- package/dist/evaluator/Evaluator.d.ts +2 -2
- package/dist/evaluator/expression/FilterPathExpressionEvaluator.d.ts +1 -1
- package/dist/evaluator/expression/LocationPathEvaluator.d.ts +1 -1
- package/dist/evaluator/expression/LocationPathExpressionEvaluator.d.ts +1 -1
- package/dist/evaluator/expression/UnionExpressionEvaluator.d.ts +1 -1
- package/dist/evaluator/functions/FunctionLibraryCollection.d.ts +1 -1
- package/dist/evaluator/functions/NodeSetFunction.d.ts +1 -1
- package/dist/evaluator/result/BaseResult.d.ts +1 -1
- package/dist/evaluator/result/NodeSetResult.d.ts +5 -9
- package/dist/{expressionParser-3CFK02GG.js → expressionParser-BUM7qFCl.js} +29 -29
- package/dist/{expressionParser-3CFK02GG.js.map → expressionParser-BUM7qFCl.js.map} +1 -1
- package/dist/expressionParser.js +1 -1
- package/dist/functions/javarosa/node-set.d.ts +2 -0
- package/dist/index.js +4054 -22153
- package/dist/index.js.map +1 -1
- package/dist/lib/collections/sort.d.ts +1 -1
- package/dist/lib/datetime/coercion.d.ts +3 -3
- package/dist/lib/datetime/functions.d.ts +3 -3
- package/dist/xforms/XFormsItextTranslations.d.ts +17 -17
- package/dist/xforms/XFormsXPathEvaluator.d.ts +2 -2
- package/package.json +3 -4
- package/dist/functions/javarosa/string.d.ts +0 -9
- package/dist/lib/datetime/constants.d.ts +0 -6
- package/dist/lib/iterators/Reiterable.d.ts +0 -15
- package/dist/lib/iterators/common.d.ts +0 -17
- package/dist/lib/iterators/index.d.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const seededRandomize: <T>(values: readonly T[], seed?:
|
|
1
|
+
export declare const seededRandomize: <T>(values: readonly T[], seed?: bigint | number) => T[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Temporal } from '
|
|
1
|
+
import { Temporal } from 'temporal-polyfill';
|
|
2
2
|
export declare const tryParseDateString: (value: string) => Date | null;
|
|
3
|
-
export declare const dateTimeFromString: (timeZone: Temporal.
|
|
4
|
-
export declare const dateTimeFromNumber: (timeZone: Temporal.
|
|
3
|
+
export declare const dateTimeFromString: (timeZone: Temporal.TimeZoneLike, value: string) => Temporal.ZonedDateTime | null;
|
|
4
|
+
export declare const dateTimeFromNumber: (timeZone: Temporal.TimeZoneLike, milliseconds: number) => Temporal.ZonedDateTime | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Temporal } from '
|
|
2
|
-
export declare const currentLocalDateTimeString: (timeZone: Temporal.
|
|
1
|
+
import { Temporal } from 'temporal-polyfill';
|
|
2
|
+
export declare const currentLocalDateTimeString: (timeZone: Temporal.TimeZoneLike) => string;
|
|
3
3
|
export declare const localDateTimeString: (dateTime: Temporal.ZonedDateTime) => string;
|
|
4
4
|
export declare const localDateTimeOrDateString: (dateTime: Temporal.ZonedDateTime) => string;
|
|
5
|
-
export declare const now: (timeZone: Temporal.
|
|
5
|
+
export declare const now: (timeZone: Temporal.TimeZoneLike) => Temporal.ZonedDateTime;
|
|
@@ -3,6 +3,7 @@ import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
|
3
3
|
import { XPathDOMProvider } from '../adapter/xpathDOMProvider.ts';
|
|
4
4
|
import { XFormsElementRepresentation } from './XFormsElementRepresentation.ts';
|
|
5
5
|
type XFormsItextTextID = string;
|
|
6
|
+
export type XFormsItextTranslationValueElement<T extends XPathNode> = XFormsElementRepresentation<T, 'value', 'form'>;
|
|
6
7
|
type XFormsItextTranslationTextElement<T extends XPathNode> = XFormsElementRepresentation<T, 'text'>;
|
|
7
8
|
export type XFormsItextTranslationElement<T extends XPathNode> = XFormsElementRepresentation<T, 'translation', 'lang'>;
|
|
8
9
|
type XFormsItextTextMap<T extends XPathNode> = ReadonlyMap<XFormsItextTextID, XFormsItextTranslationTextElement<T>>;
|
|
@@ -42,35 +43,34 @@ export declare class XFormsItextTranslations<T extends XPathNode> implements XFo
|
|
|
42
43
|
private getTranslationMetadata;
|
|
43
44
|
private getTranslationTextElement;
|
|
44
45
|
/**
|
|
46
|
+
* Retrieves all translation value elements for a given Itext in the active language.
|
|
47
|
+
*
|
|
45
48
|
* @package
|
|
46
49
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
50
|
+
* This method fetches the `text` element matching `itextID` and returns its child `value` elements,
|
|
51
|
+
* which may have an optional `@form` attribute.
|
|
52
|
+
*
|
|
53
|
+
* The operation is conceptually similar to the following XPath query:
|
|
49
54
|
*
|
|
50
55
|
* ```xpath
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* xpath3-fn:environment-variable('activeLanguage')
|
|
54
|
-
* )
|
|
55
|
-
* /text[@id = $itextID]
|
|
56
|
-
* /value[not(@form)]
|
|
56
|
+
* imaginary:itext-translation(
|
|
57
|
+
* xpath3-fn:environment-variable('activeLanguage')
|
|
57
58
|
* )
|
|
59
|
+
* /text[@id = $itextID]
|
|
60
|
+
* /value
|
|
58
61
|
* ```
|
|
59
62
|
*
|
|
60
63
|
* Or alternately:
|
|
61
64
|
*
|
|
62
65
|
* ```xpath
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* /
|
|
66
|
-
* /
|
|
67
|
-
* /value[not(@form)]
|
|
68
|
-
* )
|
|
66
|
+
* imaginary:itext-root()
|
|
67
|
+
* /translation[@lang = xpath3-fn:environment-variable('activeLanguage')]
|
|
68
|
+
* /text[@id = $itextID]
|
|
69
|
+
* /value
|
|
69
70
|
* ```
|
|
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
|
|
71
|
+
* Returns an array of `XFormsItextTranslationValueElement<T>`
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
getTranslationValues(itextID: string): Array<XFormsItextTranslationValueElement<T>>;
|
|
74
74
|
getLanguages(): readonly XFormsItextTranslationLanguage[];
|
|
75
75
|
getActiveLanguage(): XFormsItextTranslationLanguage | null;
|
|
76
76
|
setActiveLanguage(language: XFormsItextTranslationLanguage | null): XFormsItextTranslationLanguage | null;
|
|
@@ -3,7 +3,7 @@ import { XPathNode } from '../adapter/interface/XPathNode.ts';
|
|
|
3
3
|
import { AdapterParentNode } from '../adapter/interface/XPathNodeKindAdapter.ts';
|
|
4
4
|
import { EvaluationContext } from '../context/EvaluationContext.ts';
|
|
5
5
|
import { EvaluatorOptions, Evaluator } from '../evaluator/Evaluator.ts';
|
|
6
|
-
import { XFormsItextTranslationLanguage, XFormsItextTranslationMap, XFormsItextTranslationsState } from './XFormsItextTranslations.ts';
|
|
6
|
+
import { XFormsItextTranslationLanguage, XFormsItextTranslationMap, XFormsItextTranslationsState, XFormsItextTranslationValueElement } from './XFormsItextTranslations.ts';
|
|
7
7
|
import { XFormsSecondaryInstanceElement, XFormsSecondaryInstanceMap } from './XFormsSecondaryInstances.ts';
|
|
8
8
|
/**
|
|
9
9
|
* @todo We accept an arbitrary parent node specifically for legacy WHATWG DOM
|
|
@@ -18,7 +18,7 @@ export interface XFormsXPathEvaluatorOptions<T extends XPathNode> extends Evalua
|
|
|
18
18
|
}
|
|
19
19
|
export declare class XFormsXPathEvaluator<T extends XPathNode> extends Evaluator<T> implements XFormsItextTranslationsState {
|
|
20
20
|
static getSecondaryInstance<T extends XPathNode>(context: EvaluationContext<T>, id: string): XFormsSecondaryInstanceElement<T> | null;
|
|
21
|
-
static
|
|
21
|
+
static getTranslationValues<T extends XPathNode>(context: EvaluationContext<T>, itextID: string): Array<XFormsItextTranslationValueElement<T>>;
|
|
22
22
|
readonly rootNode: AdapterParentNode<T>;
|
|
23
23
|
/**
|
|
24
24
|
* @package
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getodk/xpath",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "XPath implementation for ODK Web Forms",
|
|
6
6
|
"type": "module",
|
|
@@ -54,10 +54,9 @@
|
|
|
54
54
|
"test:types:test": "tsc --project ./test/tsconfig.json --emitDeclarationOnly false --noEmit"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@getodk/common": "0.
|
|
58
|
-
"@js-temporal/polyfill": "^0.4.4",
|
|
57
|
+
"@getodk/common": "0.6.1",
|
|
59
58
|
"crypto-js": "^4.2.0",
|
|
60
|
-
"
|
|
59
|
+
"temporal-polyfill": "^0.3.0"
|
|
61
60
|
},
|
|
62
61
|
"devDependencies": {
|
|
63
62
|
"@babel/core": "^7.26.10",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { StringFunction } from '../../evaluator/functions/StringFunction.ts';
|
|
2
|
-
/**
|
|
3
|
-
* @todo This could be a {@link NodeSetFunction}. If it were, that might be a
|
|
4
|
-
* good starting point for thinking about how we'll support:
|
|
5
|
-
*
|
|
6
|
-
* - `<output>` in itext translations
|
|
7
|
-
* - `<value form="...">` (short, guidance, various media types)
|
|
8
|
-
*/
|
|
9
|
-
export declare const itext: StringFunction;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const DAY_MILLISECONDS: number;
|
|
2
|
-
export declare const MILLISECOND_NANOSECONDS: bigint;
|
|
3
|
-
export declare const ISO_DATE_LIKE_PATTERN: RegExp;
|
|
4
|
-
export declare const ISO_TIME_LIKE_PATTERN: RegExp;
|
|
5
|
-
export declare const ISO_DATE_TIME_LIKE_PATTERN: RegExp;
|
|
6
|
-
export declare const ISO_DATE_OR_DATE_TIME_LIKE_PATTERN: RegExp;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type BooleanPredicate<T> = (value: T) => boolean;
|
|
2
|
-
export declare class Reiterable<T> implements Iterable<T> {
|
|
3
|
-
protected source: Iterable<T> | Iterator<T>;
|
|
4
|
-
static from<T>(source: Iterable<T> | Iterator<T>): Reiterable<T>;
|
|
5
|
-
protected active: IterableIterator<T>;
|
|
6
|
-
protected cache: T[];
|
|
7
|
-
protected constructor(source: Iterable<T> | Iterator<T>);
|
|
8
|
-
[Symbol.iterator](): Iterator<T>;
|
|
9
|
-
entries(): IterableIterator<readonly [key: number, value: T]>;
|
|
10
|
-
keys(): IterableIterator<number>;
|
|
11
|
-
values(): IterableIterator<T>;
|
|
12
|
-
first(): T | void;
|
|
13
|
-
some(predicate: BooleanPredicate<T>): boolean;
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
type Iter<T> = Iterable<T> | Iterator<T>;
|
|
2
|
-
export declare function toIterableIterator<T>(iter: Iter<T>): IterableIterator<T>;
|
|
3
|
-
type MapIterated<T, U> = (value: T) => U;
|
|
4
|
-
export type MapIterable<T, U> = (iterable: Iter<T>) => IterableIterator<U>;
|
|
5
|
-
export declare const map: <T, U>(fn: MapIterated<T, U>) => MapIterable<T, U>;
|
|
6
|
-
export declare const eager: <T>(iterable: Iter<T>) => IterableIterator<T>;
|
|
7
|
-
type TypedGuardIterated<T, U extends T> = (value: T) => value is U;
|
|
8
|
-
type PredicateGuardIterated<T> = (value: T) => boolean;
|
|
9
|
-
type GuardIterated<T, U extends T> = PredicateGuardIterated<T & U> | TypedGuardIterated<T, U>;
|
|
10
|
-
type UnguardedIterated<Guard extends GuardIterated<any, any>> = Guard extends TypedGuardIterated<infer T, any> ? T : Guard extends PredicateGuardIterated<infer T> ? T : never;
|
|
11
|
-
type GuardedIterated<Guard extends GuardIterated<any, any>> = Guard extends TypedGuardIterated<infer T, infer U> ? T & U : Guard extends PredicateGuardIterated<infer T> ? T : never;
|
|
12
|
-
type FilterIterable<Guard extends GuardIterated<any, any>> = MapIterable<UnguardedIterated<Guard>, GuardedIterated<Guard>>;
|
|
13
|
-
export declare const filter: <Guard extends GuardIterated<any, any>>(guard: Guard) => FilterIterable<Guard>;
|
|
14
|
-
export declare const distinct: <T>(iterable: Iterable<T>) => Generator<T, void, unknown>;
|
|
15
|
-
type TeeResult<T> = [IterableIterator<T>, IterableIterator<T>];
|
|
16
|
-
export declare const tee: <T>(input: Iterable<T> | Iterator<T>) => TeeResult<T>;
|
|
17
|
-
export {};
|