@getodk/xpath 0.5.0 → 0.7.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/README.md +0 -1
- package/dist/.vite/manifest.json +4 -4
- package/dist/{expressionParser-BUM7qFCl.js → expressionParser-DjyNe4Lw.js} +6 -2
- package/dist/{expressionParser-BUM7qFCl.js.map → expressionParser-DjyNe4Lw.js.map} +1 -1
- package/dist/expressionParser.js +1 -1
- package/dist/functions/javarosa/node-set.d.ts +2 -0
- package/dist/index.js +38 -43
- package/dist/index.js.map +1 -1
- package/dist/xforms/XFormsItextTranslations.d.ts +17 -17
- package/dist/xforms/XFormsXPathEvaluator.d.ts +2 -2
- package/package.json +12 -12
- package/dist/functions/javarosa/string.d.ts +0 -9
package/dist/expressionParser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { e as expressionParser } from './expressionParser-
|
|
1
|
+
export { e as expressionParser } from './expressionParser-DjyNe4Lw.js';
|
|
2
2
|
//# sourceMappingURL=expressionParser.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as UpsertableMap, e as expressionParser, g as getAugmentedNamespace, c as commonjsGlobal, a as getDefaultExportFromCjs } from './expressionParser-
|
|
1
|
+
import { U as UpsertableMap, e as expressionParser, g as getAugmentedNamespace, c as commonjsGlobal, a as getDefaultExportFromCjs } from './expressionParser-DjyNe4Lw.js';
|
|
2
2
|
|
|
3
3
|
function _mergeNamespaces(n, m) {
|
|
4
4
|
for (var i = 0; i < m.length; i++) {
|
|
@@ -400,7 +400,7 @@ function epochMilliToIso(e, n = 0, t = 0) {
|
|
|
400
400
|
return zipProps(Tr, [r.getUTCFullYear(), r.getUTCMonth() + 1, r.getUTCDate() + o, r.getUTCHours(), r.getUTCMinutes(), r.getUTCSeconds(), r.getUTCMilliseconds(), n, t]);
|
|
401
401
|
}
|
|
402
402
|
function hashIntlFormatParts(e, n) {
|
|
403
|
-
if (n < -
|
|
403
|
+
if (n < -Pr) {
|
|
404
404
|
throw new RangeError(Io);
|
|
405
405
|
}
|
|
406
406
|
const t = e.formatToParts(n),
|
|
@@ -1084,7 +1084,7 @@ function getSingleInstantFor(e, n, t = 0, o = e.I(n)) {
|
|
|
1084
1084
|
}
|
|
1085
1085
|
const r = isoToEpochNano(n),
|
|
1086
1086
|
i = ((e, n) => {
|
|
1087
|
-
const t = e.R(moveBigNano(n, -
|
|
1087
|
+
const t = e.R(moveBigNano(n, -Uo));
|
|
1088
1088
|
return (e => {
|
|
1089
1089
|
if (e > Uo) {
|
|
1090
1090
|
throw new RangeError(go);
|
|
@@ -1100,7 +1100,7 @@ function getStartOfDayInstantFor(e, n) {
|
|
|
1100
1100
|
if (t.length) {
|
|
1101
1101
|
return t[0];
|
|
1102
1102
|
}
|
|
1103
|
-
const o = moveBigNano(isoToEpochNano(n), -
|
|
1103
|
+
const o = moveBigNano(isoToEpochNano(n), -Uo);
|
|
1104
1104
|
return e.O(o, 1);
|
|
1105
1105
|
}
|
|
1106
1106
|
function Ye(e, n, t) {
|
|
@@ -1322,7 +1322,7 @@ function computeDurationSign(e, n = p) {
|
|
|
1322
1322
|
}
|
|
1323
1323
|
function checkDurationUnits(e) {
|
|
1324
1324
|
for (const n of dr) {
|
|
1325
|
-
clampEntity(n, e[n], -
|
|
1325
|
+
clampEntity(n, e[n], -di, di, 1);
|
|
1326
1326
|
}
|
|
1327
1327
|
return checkDurationTimeUnit(bigNanoToNumber(durationFieldsToBigNano(e), Ro)), e;
|
|
1328
1328
|
}
|
|
@@ -1981,7 +1981,7 @@ function createIntlYearDataCache(e) {
|
|
|
1981
1981
|
r += 400 * ko;
|
|
1982
1982
|
} while ((o = e(r)).year <= t);
|
|
1983
1983
|
do {
|
|
1984
|
-
if (r += (1 - o.day) * ko, o.year === t && (a.push(r), s.push(o.o)), r -= ko, ++i > 100 || r < -
|
|
1984
|
+
if (r += (1 - o.day) * ko, o.year === t && (a.push(r), s.push(o.o)), r -= ko, ++i > 100 || r < -Pr) {
|
|
1985
1985
|
throw new RangeError(fo);
|
|
1986
1986
|
}
|
|
1987
1987
|
} while ((o = e(r)).year >= t);
|
|
@@ -2774,7 +2774,7 @@ const expectedInteger = (e, n) => `Non-integer ${e}: ${n}`,
|
|
|
2774
2774
|
vr = 1e8,
|
|
2775
2775
|
Pr = vr * ko,
|
|
2776
2776
|
Er = [vr, 0],
|
|
2777
|
-
Sr = [-
|
|
2777
|
+
Sr = [-vr, 0],
|
|
2778
2778
|
Fr = 275760,
|
|
2779
2779
|
wr = -271821,
|
|
2780
2780
|
en = Intl.DateTimeFormat,
|
|
@@ -5609,7 +5609,7 @@ const substring = new StringFunction(
|
|
|
5609
5609
|
return string2.substring(start, end);
|
|
5610
5610
|
}
|
|
5611
5611
|
);
|
|
5612
|
-
const string$
|
|
5612
|
+
const string$1 = new StringFunction(
|
|
5613
5613
|
"string",
|
|
5614
5614
|
[{ arityType: "optional" }],
|
|
5615
5615
|
(context, [expression]) => (expression?.evaluate(context) ?? context).toString()
|
|
@@ -5642,13 +5642,13 @@ const translate = new StringFunction(
|
|
|
5642
5642
|
}
|
|
5643
5643
|
);
|
|
5644
5644
|
|
|
5645
|
-
const string$
|
|
5645
|
+
const string$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
5646
5646
|
__proto__: null,
|
|
5647
5647
|
concat: concat$1,
|
|
5648
5648
|
contains,
|
|
5649
5649
|
normalizeSpace,
|
|
5650
5650
|
startsWith,
|
|
5651
|
-
string: string$
|
|
5651
|
+
string: string$1,
|
|
5652
5652
|
stringLength,
|
|
5653
5653
|
substring,
|
|
5654
5654
|
substringAfter,
|
|
@@ -5660,7 +5660,7 @@ const fn = new FunctionLibrary(FN_NAMESPACE_URI, [
|
|
|
5660
5660
|
...Object.values(boolean$2),
|
|
5661
5661
|
...Object.values(nodeset$1),
|
|
5662
5662
|
...Object.values(number$3),
|
|
5663
|
-
...Object.values(string$
|
|
5663
|
+
...Object.values(string$2)
|
|
5664
5664
|
]);
|
|
5665
5665
|
|
|
5666
5666
|
class BaseStep {
|
|
@@ -7164,7 +7164,9 @@ const dateTimeFromString = (timeZone, value) => {
|
|
|
7164
7164
|
}
|
|
7165
7165
|
return Xn.PlainDateTime.from(value).toZonedDateTime(timeZone);
|
|
7166
7166
|
};
|
|
7167
|
-
const toNanoseconds = (milliseconds) =>
|
|
7167
|
+
const toNanoseconds = (milliseconds) => {
|
|
7168
|
+
return BigInt(Math.round(milliseconds)) * MILLISECOND_NANOSECONDS;
|
|
7169
|
+
};
|
|
7168
7170
|
const dateTimeFromNumber = (timeZone, milliseconds) => {
|
|
7169
7171
|
if (Number.isNaN(milliseconds)) {
|
|
7170
7172
|
return null;
|
|
@@ -7443,21 +7445,21 @@ const enk = new FunctionLibrary(ENKETO_NAMESPACE_URI, [
|
|
|
7443
7445
|
new FunctionAlias("format-date", formatDateTime)
|
|
7444
7446
|
]);
|
|
7445
7447
|
|
|
7446
|
-
const itext = new
|
|
7448
|
+
const itext = new NodeSetFunction(
|
|
7447
7449
|
"itext",
|
|
7448
7450
|
[{ arityType: "required", typeHint: "string" }],
|
|
7449
7451
|
(context, [itextIDExpression]) => {
|
|
7450
7452
|
const itextID = itextIDExpression.evaluate(context).toString();
|
|
7451
|
-
return XFormsXPathEvaluator.
|
|
7453
|
+
return XFormsXPathEvaluator.getTranslationValues(context, itextID) ?? [];
|
|
7452
7454
|
}
|
|
7453
7455
|
);
|
|
7454
7456
|
|
|
7455
|
-
const
|
|
7457
|
+
const nodeSet = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
7456
7458
|
__proto__: null,
|
|
7457
7459
|
itext
|
|
7458
7460
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
7459
7461
|
|
|
7460
|
-
const jr = new FunctionLibrary(JAVAROSA_NAMESPACE_URI, [...Object.values(
|
|
7462
|
+
const jr = new FunctionLibrary(JAVAROSA_NAMESPACE_URI, [...Object.values(nodeSet)]);
|
|
7461
7463
|
|
|
7462
7464
|
const booleanFromString = new BooleanFunction(
|
|
7463
7465
|
"boolean-from-string",
|
|
@@ -15160,46 +15162,39 @@ class XFormsItextTranslations {
|
|
|
15160
15162
|
return textMap.get(itextID) ?? null;
|
|
15161
15163
|
}
|
|
15162
15164
|
/**
|
|
15165
|
+
* Retrieves all translation value elements for a given Itext in the active language.
|
|
15166
|
+
*
|
|
15163
15167
|
* @package
|
|
15164
15168
|
*
|
|
15165
|
-
*
|
|
15166
|
-
*
|
|
15169
|
+
* This method fetches the `text` element matching `itextID` and returns its child `value` elements,
|
|
15170
|
+
* which may have an optional `@form` attribute.
|
|
15171
|
+
*
|
|
15172
|
+
* The operation is conceptually similar to the following XPath query:
|
|
15167
15173
|
*
|
|
15168
15174
|
* ```xpath
|
|
15169
|
-
*
|
|
15170
|
-
*
|
|
15171
|
-
* xpath3-fn:environment-variable('activeLanguage')
|
|
15172
|
-
* )
|
|
15173
|
-
* /text[@id = $itextID]
|
|
15174
|
-
* /value[not(@form)]
|
|
15175
|
+
* imaginary:itext-translation(
|
|
15176
|
+
* xpath3-fn:environment-variable('activeLanguage')
|
|
15175
15177
|
* )
|
|
15178
|
+
* /text[@id = $itextID]
|
|
15179
|
+
* /value
|
|
15176
15180
|
* ```
|
|
15177
15181
|
*
|
|
15178
15182
|
* Or alternately:
|
|
15179
15183
|
*
|
|
15180
15184
|
* ```xpath
|
|
15181
|
-
*
|
|
15182
|
-
*
|
|
15183
|
-
* /
|
|
15184
|
-
* /
|
|
15185
|
-
* /value[not(@form)]
|
|
15186
|
-
* )
|
|
15185
|
+
* imaginary:itext-root()
|
|
15186
|
+
* /translation[@lang = xpath3-fn:environment-variable('activeLanguage')]
|
|
15187
|
+
* /text[@id = $itextID]
|
|
15188
|
+
* /value
|
|
15187
15189
|
* ```
|
|
15188
|
-
*
|
|
15189
|
-
* @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
|
|
15190
|
+
* Returns an array of `XFormsItextTranslationValueElement<T>`
|
|
15190
15191
|
*/
|
|
15191
|
-
|
|
15192
|
+
getTranslationValues(itextID) {
|
|
15192
15193
|
const textElement = this.getTranslationTextElement(itextID);
|
|
15193
15194
|
if (textElement == null) {
|
|
15194
|
-
return
|
|
15195
|
-
}
|
|
15196
|
-
const { domProvider } = this;
|
|
15197
|
-
for (const valueElement of domProvider.getChildrenByLocalName(textElement, "value")) {
|
|
15198
|
-
if (!domProvider.hasLocalNamedAttribute(valueElement, "form")) {
|
|
15199
|
-
return domProvider.getNodeValue(valueElement);
|
|
15200
|
-
}
|
|
15195
|
+
return [];
|
|
15201
15196
|
}
|
|
15202
|
-
return "";
|
|
15197
|
+
return [...this.domProvider.getChildrenByLocalName(textElement, "value")];
|
|
15203
15198
|
}
|
|
15204
15199
|
getLanguages() {
|
|
15205
15200
|
return this.languages;
|
|
@@ -15236,9 +15231,9 @@ class XFormsXPathEvaluator extends Evaluator {
|
|
|
15236
15231
|
assertInternalXFormsXPathEvaluatorContext(context);
|
|
15237
15232
|
return context.evaluator.secondaryInstancesById.get(id) ?? null;
|
|
15238
15233
|
}
|
|
15239
|
-
static
|
|
15234
|
+
static getTranslationValues(context, itextID) {
|
|
15240
15235
|
assertInternalXFormsXPathEvaluatorContext(context);
|
|
15241
|
-
return context.evaluator.itextTranslations.
|
|
15236
|
+
return context.evaluator.itextTranslations.getTranslationValues(itextID);
|
|
15242
15237
|
}
|
|
15243
15238
|
rootNode;
|
|
15244
15239
|
/**
|