@getodk/xforms-engine 0.12.0 → 0.13.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/client/TextRange.d.ts +0 -9
- package/dist/index.js +227 -100
- package/dist/index.js.map +1 -1
- package/dist/instance/RankControl.d.ts +3 -2
- package/dist/instance/SelectControl.d.ts +3 -2
- package/dist/parse/body/control/ItemsetDefinition.d.ts +1 -1
- package/dist/parse/expression/BindComputationExpression.d.ts +1 -1
- package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -2
- package/dist/parse/expression/TextChunkExpression.d.ts +9 -7
- package/dist/parse/expression/abstract/DependentExpression.d.ts +1 -15
- package/dist/parse/model/ModelDefinition.d.ts +6 -1
- package/dist/parse/model/generateItextChunks.d.ts +5 -0
- package/dist/parse/xpath/semantic-analysis.d.ts +1 -0
- package/dist/solid.js +227 -100
- package/dist/solid.js.map +1 -1
- package/package.json +2 -2
- package/src/client/TextRange.ts +0 -9
- package/src/instance/RankControl.ts +8 -2
- package/src/instance/SelectControl.ts +8 -2
- package/src/lib/reactivity/text/createTextRange.ts +30 -30
- package/src/parse/body/control/ItemsetDefinition.ts +2 -2
- package/src/parse/expression/BindComputationExpression.ts +2 -7
- package/src/parse/expression/ItemsetNodesetExpression.ts +2 -3
- package/src/parse/expression/ItemsetValueExpression.ts +1 -1
- package/src/parse/expression/RepeatCountControlExpression.ts +4 -4
- package/src/parse/expression/TextChunkExpression.ts +25 -35
- package/src/parse/expression/abstract/DependentExpression.ts +2 -38
- package/src/parse/model/ModelDefinition.ts +13 -0
- package/src/parse/model/generateItextChunks.ts +61 -0
- package/src/parse/text/ItemsetLabelDefinition.ts +4 -4
- package/src/parse/text/MessageDefinition.ts +4 -4
- package/src/parse/text/abstract/TextElementDefinition.ts +6 -7
- package/src/parse/xpath/semantic-analysis.ts +37 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
1
|
+
import { XPathChoiceNode, XPathNodeKindKey } from '@getodk/xpath';
|
|
2
2
|
import { Accessor } from 'solid-js';
|
|
3
3
|
import { RankDefinition, RankNode, RankValueOptions } from '../client/RankNode.ts';
|
|
4
4
|
import { TextRange } from '../client/TextRange.ts';
|
|
@@ -23,7 +23,7 @@ interface RankControlStateSpec extends ValueNodeStateSpec<readonly string[]> {
|
|
|
23
23
|
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
24
24
|
readonly valueOptions: Accessor<RankValueOptions>;
|
|
25
25
|
}
|
|
26
|
-
export declare class RankControl extends ValueNode<'string', RankDefinition<'string'>, readonly string[], readonly string[]> implements RankNode, XFormsXPathElement, EvaluationContext, ValidationContext, ClientReactiveSerializableValueNode {
|
|
26
|
+
export declare class RankControl extends ValueNode<'string', RankDefinition<'string'>, readonly string[], readonly string[]> implements RankNode, XFormsXPathElement, EvaluationContext, ValidationContext, ClientReactiveSerializableValueNode, XPathChoiceNode {
|
|
27
27
|
static from(parent: GeneralParentNode, instanceNode: StaticLeafElement | null, definition: RankDefinition): RankControl;
|
|
28
28
|
private readonly mapOptionsByValue;
|
|
29
29
|
protected readonly getInstanceValue: Accessor<string>;
|
|
@@ -37,5 +37,6 @@ export declare class RankControl extends ValueNode<'string', RankDefinition<'str
|
|
|
37
37
|
private constructor();
|
|
38
38
|
getValueLabel(value: string): TextRange<'item-label'> | null;
|
|
39
39
|
setValues(valuesInOrder: readonly string[]): Root;
|
|
40
|
+
getChoiceName(value: string): string | null;
|
|
40
41
|
}
|
|
41
42
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
1
|
+
import { XPathChoiceNode, XPathNodeKindKey } from '@getodk/xpath';
|
|
2
2
|
import { Accessor } from 'solid-js';
|
|
3
3
|
import { SelectDefinition, SelectItem, SelectNode, SelectNodeAppearances, SelectValueOptions } from '../client/SelectNode.ts';
|
|
4
4
|
import { TextRange } from '../client/TextRange.ts';
|
|
@@ -24,7 +24,7 @@ interface SelectControlStateSpec extends ValueNodeStateSpec<readonly string[]> {
|
|
|
24
24
|
readonly valueOptions: Accessor<SelectValueOptions>;
|
|
25
25
|
readonly isSelectWithImages: Accessor<boolean>;
|
|
26
26
|
}
|
|
27
|
-
export declare class SelectControl extends ValueNode<'string', SelectDefinition<'string'>, readonly string[], readonly string[]> implements SelectNode, XFormsXPathElement, EvaluationContext, ValidationContext, ClientReactiveSerializableValueNode {
|
|
27
|
+
export declare class SelectControl extends ValueNode<'string', SelectDefinition<'string'>, readonly string[], readonly string[]> implements SelectNode, XFormsXPathElement, EvaluationContext, ValidationContext, ClientReactiveSerializableValueNode, XPathChoiceNode {
|
|
28
28
|
static from(parent: GeneralParentNode, instanceNode: StaticLeafElement | null, definition: SelectDefinition): SelectControl;
|
|
29
29
|
private readonly mapOptionsByValue;
|
|
30
30
|
protected readonly getInstanceValue: Accessor<string>;
|
|
@@ -64,5 +64,6 @@ export declare class SelectControl extends ValueNode<'string', SelectDefinition<
|
|
|
64
64
|
isSelected(value: string): boolean;
|
|
65
65
|
selectValue(value: string | null): Root;
|
|
66
66
|
selectValues(values: readonly string[]): Root;
|
|
67
|
+
getChoiceName(value: string): string | null;
|
|
67
68
|
}
|
|
68
69
|
export {};
|
|
@@ -4,8 +4,8 @@ import { ItemsetValueExpression } from '../../expression/ItemsetValueExpression.
|
|
|
4
4
|
import { ItemsetLabelDefinition } from '../../text/ItemsetLabelDefinition.ts';
|
|
5
5
|
import { XFormDefinition } from '../../XFormDefinition.ts';
|
|
6
6
|
import { BodyElementDefinition } from '../BodyElementDefinition.ts';
|
|
7
|
-
import { AnySelectControlDefinition } from './SelectControlDefinition.ts';
|
|
8
7
|
import { RankControlDefinition } from './RankControlDefinition.ts';
|
|
8
|
+
import { AnySelectControlDefinition } from './SelectControlDefinition.ts';
|
|
9
9
|
export declare class ItemsetDefinition extends BodyElementDefinition<'itemset'> {
|
|
10
10
|
readonly parent: AnySelectControlDefinition | RankControlDefinition;
|
|
11
11
|
readonly category = "support";
|
|
@@ -25,6 +25,6 @@ export declare class BindComputationExpression<Computation extends BindComputati
|
|
|
25
25
|
readonly computation: Computation;
|
|
26
26
|
static forComputation<Type extends BindComputationType>(bind: BindDefinition, computation: Type): BindComputationFactoryResult<Type>;
|
|
27
27
|
readonly isDefaultExpression: boolean;
|
|
28
|
-
protected constructor(
|
|
28
|
+
protected constructor(computation: Computation, expression: string | null);
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ItemsetDefinition } from '../body/control/ItemsetDefinition.ts';
|
|
2
1
|
import { DependentExpression } from './abstract/DependentExpression.ts';
|
|
3
2
|
export declare class ItemsetNodesetExpression extends DependentExpression<'nodes'> {
|
|
4
|
-
constructor(
|
|
3
|
+
constructor(nodesetExpression: string);
|
|
5
4
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import { JRResourceURLString, ResourceType } from '../../../../common/src/jr-resources/JRResourceURL.ts';
|
|
1
2
|
import { TextChunkSource } from '../../client/TextRange.ts';
|
|
2
|
-
import { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
|
|
3
3
|
import { DependentExpression } from './abstract/DependentExpression.ts';
|
|
4
4
|
interface TextChunkExpressionOptions {
|
|
5
|
-
readonly
|
|
5
|
+
readonly type?: ResourceType;
|
|
6
6
|
}
|
|
7
7
|
export declare class TextChunkExpression<T extends 'nodes' | 'string'> extends DependentExpression<T> {
|
|
8
8
|
readonly source: TextChunkSource;
|
|
9
9
|
readonly stringValue: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static
|
|
13
|
-
static
|
|
14
|
-
static
|
|
10
|
+
readonly resourceType: ResourceType | null;
|
|
11
|
+
constructor(resultType: T, expression: string, source: TextChunkSource, literalValue?: string, options?: TextChunkExpressionOptions);
|
|
12
|
+
static fromLiteral(stringValue: string): TextChunkExpression<'string'>;
|
|
13
|
+
static fromReference(ref: string): TextChunkExpression<'string'>;
|
|
14
|
+
static fromOutput(element: Element): TextChunkExpression<'string'> | null;
|
|
15
|
+
static fromResource(url: JRResourceURLString, type: ResourceType): TextChunkExpression<'string'>;
|
|
16
|
+
static fromTranslation(maybeExpression: string): TextChunkExpression<'nodes'> | null;
|
|
15
17
|
}
|
|
16
18
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EngineXPathEvaluator } from '../../../integration/xpath/EngineXPathEvaluator.ts';
|
|
2
2
|
import { ConstantExpression, ConstantTruthyExpression } from '../../xpath/semantic-analysis.ts';
|
|
3
|
-
import { DependencyContext } from './DependencyContext.ts';
|
|
4
3
|
declare const evaluatorMethodsByResultType: {
|
|
5
4
|
readonly boolean: "evaluateBoolean";
|
|
6
5
|
readonly nodes: "evaluateNodes";
|
|
@@ -11,19 +10,6 @@ type EvaluatorMethodsByResultType = typeof evaluatorMethodsByResultType;
|
|
|
11
10
|
export type DependentExpressionResultType = keyof EvaluatorMethodsByResultType;
|
|
12
11
|
export type DependentExpressionEvaluatorMethod<Type extends DependentExpressionResultType> = EvaluatorMethodsByResultType[Type];
|
|
13
12
|
export type DependentExpressionResult<Type extends DependentExpressionResultType> = ReturnType<EngineXPathEvaluator[DependentExpressionEvaluatorMethod<Type>]>;
|
|
14
|
-
interface SemanticDependencyOptions {
|
|
15
|
-
/**
|
|
16
|
-
* @default false
|
|
17
|
-
*/
|
|
18
|
-
readonly translations?: boolean | undefined;
|
|
19
|
-
}
|
|
20
|
-
interface DependentExpressionOptions {
|
|
21
|
-
/**
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
readonly ignoreContextReference?: boolean;
|
|
25
|
-
readonly semanticDependencies?: SemanticDependencyOptions;
|
|
26
|
-
}
|
|
27
13
|
export interface ConstantDependentExpression<Type extends DependentExpressionResultType> extends DependentExpression<Type> {
|
|
28
14
|
readonly expression: ConstantExpression;
|
|
29
15
|
}
|
|
@@ -37,7 +23,7 @@ export declare abstract class DependentExpression<Type extends DependentExpressi
|
|
|
37
23
|
readonly evaluatorMethod: DependentExpressionEvaluatorMethod<Type>;
|
|
38
24
|
readonly constantExpression: ConstantExpression | null;
|
|
39
25
|
readonly constantTruthyExpression: ConstantTruthyExpression | null;
|
|
40
|
-
constructor(
|
|
26
|
+
constructor(resultType: Type, expression: string);
|
|
41
27
|
isConstantExpression(): this is ConstantDependentExpression<Type>;
|
|
42
28
|
isConstantTruthyExpression(): this is ConstantTruthyDependentExpression;
|
|
43
29
|
toString(): string | null;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { ActiveLanguage } from '../../client/FormLanguage.ts';
|
|
1
2
|
import { StaticDocument } from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
3
|
+
import { TextChunkExpression } from '../expression/TextChunkExpression.ts';
|
|
2
4
|
import { XFormDefinition } from '../XFormDefinition.ts';
|
|
5
|
+
import { ChunkExpressionsByItextId } from './generateItextChunks.ts';
|
|
3
6
|
import { ItextTranslationsDefinition } from './ItextTranslationsDefinition.ts';
|
|
4
7
|
import { ModelBindMap } from './ModelBindMap.ts';
|
|
5
8
|
import { AnyNodeDefinition } from './NodeDefinition.ts';
|
|
@@ -12,8 +15,10 @@ export declare class ModelDefinition {
|
|
|
12
15
|
readonly nodes: NodeDefinitionMap;
|
|
13
16
|
readonly instance: StaticDocument;
|
|
14
17
|
readonly itextTranslations: ItextTranslationsDefinition;
|
|
18
|
+
readonly itextChunks: Map<string, ChunkExpressionsByItextId>;
|
|
15
19
|
constructor(form: XFormDefinition);
|
|
16
20
|
getNodeDefinition(nodeset: string): AnyNodeDefinition;
|
|
17
21
|
getRootDefinition(instance: StaticDocument): RootDefinition;
|
|
18
|
-
toJSON(): Omit<this, "form" | "toJSON" | "getNodeDefinition" | "getRootDefinition">;
|
|
22
|
+
toJSON(): Omit<this, "form" | "toJSON" | "getNodeDefinition" | "getRootDefinition" | "getTranslationChunks">;
|
|
23
|
+
getTranslationChunks(itextId: string, activeLanguage: ActiveLanguage): ReadonlyArray<TextChunkExpression<'string'>>;
|
|
19
24
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TextChunkExpression } from '../expression/TextChunkExpression.ts';
|
|
2
|
+
import { DOMItextTranslationElement } from '../XFormDOM.ts';
|
|
3
|
+
export interface ChunkExpressionsByItextId extends Map<string, ReadonlyArray<TextChunkExpression<'string'>>> {
|
|
4
|
+
}
|
|
5
|
+
export declare const generateItextChunks: (translationElements: readonly DOMItextTranslationElement[]) => Map<string, ChunkExpressionsByItextId>;
|
|
@@ -11,6 +11,7 @@ export type TranslationExpression = LocalNamedFunctionCallLiteral<'itext'>;
|
|
|
11
11
|
* arbitrary expression may call `jr:itext`.
|
|
12
12
|
*/
|
|
13
13
|
export declare const isTranslationExpression: (expression: string) => expression is TranslationExpression;
|
|
14
|
+
export declare const getTranslationExpression: (expression: string) => string | null;
|
|
14
15
|
/**
|
|
15
16
|
* Predicate to determine if a FilterPathExpr (as currently produced by
|
|
16
17
|
* `tree-sitter-xpath`) is one of:
|