@getodk/xpath 0.3.0 → 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.
- package/dist/.vite/manifest.json +4 -4
- package/dist/error/JRCompatibleError.d.ts +7 -0
- package/dist/error/JRCompatibleGeoValueError.d.ts +6 -0
- package/dist/expressionParser-BYZuKGXg.js +3480 -0
- package/dist/expressionParser-BYZuKGXg.js.map +1 -0
- package/dist/expressionParser.js +1 -1
- package/dist/index.js +6443 -6554
- package/dist/index.js.map +1 -1
- package/dist/lib/collections/sort.d.ts +1 -1
- package/dist/lib/geo/EncodeGeoValueStubError.d.ts +4 -0
- package/dist/lib/geo/GeoValueCodec.d.ts +33 -0
- package/dist/lib/geo/Geopoint.d.ts +28 -0
- package/dist/lib/geo/Geotrace.d.ts +12 -0
- package/dist/lib/geo/GeotraceLine.d.ts +11 -0
- package/dist/lib/geo/encodeGeoValueStubFactory.d.ts +2 -0
- package/dist/lib/geo/geopointCodec.d.ts +4 -0
- package/package.json +14 -11
- package/dist/expressionParser-DpqfmhIO.js +0 -3479
- package/dist/expressionParser-DpqfmhIO.js.map +0 -1
|
@@ -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,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 {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getodk/xpath",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
34
|
+
"node": "^18.20.5 || ^20.18.1 || ^22.12.0",
|
|
35
35
|
"yarn": "1.22.22"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
@@ -54,24 +54,27 @@
|
|
|
54
54
|
"test:types:test": "tsc --project ./test/tsconfig.json --emitDeclarationOnly false --noEmit"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@getodk/common": "0.5.
|
|
57
|
+
"@getodk/common": "0.5.1",
|
|
58
58
|
"@js-temporal/polyfill": "^0.4.4",
|
|
59
59
|
"crypto-js": "^4.2.0",
|
|
60
60
|
"itertools-ts": "^1.27.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@babel/core": "^7.
|
|
63
|
+
"@babel/core": "^7.26.0",
|
|
64
64
|
"@getodk/tree-sitter-xpath": "0.1.2",
|
|
65
|
-
"@playwright/test": "^1.
|
|
65
|
+
"@playwright/test": "^1.49.1",
|
|
66
66
|
"@types/crypto-js": "^4.2.2",
|
|
67
|
-
"@vitest/browser": "^2.1.
|
|
67
|
+
"@vitest/browser": "^2.1.8",
|
|
68
68
|
"babel-plugin-transform-jsbi-to-bigint": "^1.4.0",
|
|
69
69
|
"jsdom": "^25.0.1",
|
|
70
|
-
"vite": "^5.4.
|
|
71
|
-
"vite-plugin-babel": "^1.
|
|
72
|
-
"vite-plugin-dts": "^4.
|
|
70
|
+
"vite": "^5.4.11",
|
|
71
|
+
"vite-plugin-babel": "^1.3.0",
|
|
72
|
+
"vite-plugin-dts": "^4.3.0",
|
|
73
73
|
"vite-plugin-no-bundle": "^4.0.0",
|
|
74
|
-
"vitest": "^2.1.
|
|
75
|
-
"web-tree-sitter": "0.
|
|
74
|
+
"vitest": "^2.1.8",
|
|
75
|
+
"web-tree-sitter": "0.24.5"
|
|
76
|
+
},
|
|
77
|
+
"publishConfig": {
|
|
78
|
+
"access": "public"
|
|
76
79
|
}
|
|
77
80
|
}
|