@getodk/xforms-engine 0.12.0 → 0.14.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 (95) hide show
  1. package/dist/client/BaseItem.d.ts +6 -0
  2. package/dist/client/GroupNode.d.ts +4 -4
  3. package/dist/client/MarkdownNode.d.ts +33 -0
  4. package/dist/client/RankNode.d.ts +2 -4
  5. package/dist/client/SelectNode.d.ts +2 -5
  6. package/dist/client/TextRange.d.ts +2 -11
  7. package/dist/client/hierarchy.d.ts +1 -2
  8. package/dist/client/index.d.ts +1 -1
  9. package/dist/client/node-types.d.ts +1 -1
  10. package/dist/index.js +10543 -332
  11. package/dist/index.js.map +1 -1
  12. package/dist/instance/RankControl.d.ts +3 -2
  13. package/dist/instance/SelectControl.d.ts +3 -2
  14. package/dist/instance/hierarchy.d.ts +5 -6
  15. package/dist/instance/markdown/MarkdownNode.d.ts +75 -0
  16. package/dist/instance/text/TextChunk.d.ts +0 -1
  17. package/dist/instance/text/TextRange.d.ts +2 -1
  18. package/dist/instance/text/markdownFormat.d.ts +3 -0
  19. package/dist/lib/reactivity/createItemCollection.d.ts +5 -7
  20. package/dist/parse/body/BodyDefinition.d.ts +2 -8
  21. package/dist/parse/body/GroupElementDefinition.d.ts +22 -0
  22. package/dist/parse/body/control/ItemsetDefinition.d.ts +4 -1
  23. package/dist/parse/expression/BindComputationExpression.d.ts +1 -1
  24. package/dist/parse/expression/ItemPropertyExpression.d.ts +6 -0
  25. package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -2
  26. package/dist/parse/expression/TextChunkExpression.d.ts +9 -7
  27. package/dist/parse/expression/abstract/DependentExpression.d.ts +1 -15
  28. package/dist/parse/model/{SubtreeDefinition.d.ts → GroupDefinition.d.ts} +4 -3
  29. package/dist/parse/model/ModelDefinition.d.ts +6 -1
  30. package/dist/parse/model/NodeDefinition.d.ts +7 -8
  31. package/dist/parse/model/RepeatDefinition.d.ts +1 -1
  32. package/dist/parse/model/RootDefinition.d.ts +1 -1
  33. package/dist/parse/model/generateItextChunks.d.ts +5 -0
  34. package/dist/parse/text/LabelDefinition.d.ts +4 -5
  35. package/dist/parse/xpath/semantic-analysis.d.ts +1 -0
  36. package/dist/solid.js +10543 -332
  37. package/dist/solid.js.map +1 -1
  38. package/package.json +3 -2
  39. package/src/client/BaseItem.ts +7 -0
  40. package/src/client/GroupNode.ts +4 -10
  41. package/src/client/MarkdownNode.ts +53 -0
  42. package/src/client/RankNode.ts +2 -5
  43. package/src/client/SelectNode.ts +2 -6
  44. package/src/client/TextRange.ts +2 -11
  45. package/src/client/hierarchy.ts +0 -2
  46. package/src/client/index.ts +1 -1
  47. package/src/client/node-types.ts +0 -1
  48. package/src/instance/Group.ts +1 -1
  49. package/src/instance/RankControl.ts +8 -2
  50. package/src/instance/SelectControl.ts +8 -2
  51. package/src/instance/children/buildChildren.ts +1 -17
  52. package/src/instance/children/normalizeChildInitOptions.ts +44 -59
  53. package/src/instance/hierarchy.ts +0 -6
  54. package/src/instance/markdown/MarkdownNode.ts +115 -0
  55. package/src/instance/text/TextChunk.ts +0 -5
  56. package/src/instance/text/TextRange.ts +5 -3
  57. package/src/instance/text/markdownFormat.ts +214 -0
  58. package/src/integration/xpath/adapter/names.ts +0 -1
  59. package/src/lib/reactivity/createItemCollection.ts +25 -9
  60. package/src/lib/reactivity/text/createTextRange.ts +30 -30
  61. package/src/parse/body/BodyDefinition.ts +7 -34
  62. package/src/parse/body/GroupElementDefinition.ts +47 -0
  63. package/src/parse/body/control/ItemsetDefinition.ts +9 -2
  64. package/src/parse/expression/BindComputationExpression.ts +2 -7
  65. package/src/parse/expression/ItemPropertyExpression.ts +12 -0
  66. package/src/parse/expression/ItemsetNodesetExpression.ts +2 -3
  67. package/src/parse/expression/ItemsetValueExpression.ts +1 -1
  68. package/src/parse/expression/RepeatCountControlExpression.ts +4 -4
  69. package/src/parse/expression/TextChunkExpression.ts +25 -35
  70. package/src/parse/expression/abstract/DependentExpression.ts +2 -38
  71. package/src/parse/model/{SubtreeDefinition.ts → GroupDefinition.ts} +6 -8
  72. package/src/parse/model/ModelDefinition.ts +13 -0
  73. package/src/parse/model/NodeDefinition.ts +8 -9
  74. package/src/parse/model/RepeatDefinition.ts +2 -2
  75. package/src/parse/model/RootDefinition.ts +2 -2
  76. package/src/parse/model/generateItextChunks.ts +61 -0
  77. package/src/parse/text/ItemsetLabelDefinition.ts +4 -4
  78. package/src/parse/text/LabelDefinition.ts +4 -9
  79. package/src/parse/text/MessageDefinition.ts +4 -4
  80. package/src/parse/text/abstract/TextElementDefinition.ts +6 -7
  81. package/src/parse/xpath/semantic-analysis.ts +37 -8
  82. package/dist/client/SubtreeNode.d.ts +0 -56
  83. package/dist/instance/Subtree.d.ts +0 -38
  84. package/dist/instance/text/FormattedTextStub.d.ts +0 -1
  85. package/dist/parse/body/group/BaseGroupDefinition.d.ts +0 -40
  86. package/dist/parse/body/group/LogicalGroupDefinition.d.ts +0 -6
  87. package/dist/parse/body/group/PresentationGroupDefinition.d.ts +0 -11
  88. package/dist/parse/body/group/StructuralGroupDefinition.d.ts +0 -6
  89. package/src/client/SubtreeNode.ts +0 -61
  90. package/src/instance/Subtree.ts +0 -102
  91. package/src/instance/text/FormattedTextStub.ts +0 -8
  92. package/src/parse/body/group/BaseGroupDefinition.ts +0 -89
  93. package/src/parse/body/group/LogicalGroupDefinition.ts +0 -11
  94. package/src/parse/body/group/PresentationGroupDefinition.ts +0 -28
  95. package/src/parse/body/group/StructuralGroupDefinition.ts +0 -11
@@ -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 {};
@@ -10,13 +10,12 @@ import { RepeatRangeControlled } from './repeat/RepeatRangeControlled.ts';
10
10
  import { RepeatRangeUncontrolled } from './repeat/RepeatRangeUncontrolled.ts';
11
11
  import { Root } from './Root.ts';
12
12
  import { SelectControl } from './SelectControl.ts';
13
- import { Subtree } from './Subtree.ts';
14
13
  import { TriggerControl } from './TriggerControl.ts';
15
14
  import { UploadControl } from './UploadControl.ts';
16
15
  export type RepeatRange = RepeatRangeControlled | RepeatRangeUncontrolled;
17
- export type AnyNode = PrimaryInstance | Root | Group | Subtree | RepeatRange | RepeatInstance | AnyNote | AnyModelValue | AnyInputControl | AnyRangeControl | RankControl | SelectControl | TriggerControl | UploadControl;
18
- export type AnyParentNode = PrimaryInstance | Root | Group | Subtree | RepeatRange | RepeatInstance;
19
- export type GeneralParentNode = Root | Group | Subtree | RepeatInstance;
20
- export type AnyChildNode = Root | Group | Subtree | RepeatRange | RepeatInstance | AnyModelValue | AnyNote | AnyInputControl | AnyRangeControl | RankControl | SelectControl | TriggerControl | UploadControl;
21
- export type GeneralChildNode = Group | Subtree | RepeatRange | AnyModelValue | AnyNote | AnyInputControl | AnyRangeControl | RankControl | SelectControl | TriggerControl | UploadControl;
16
+ export type AnyNode = PrimaryInstance | Root | Group | RepeatRange | RepeatInstance | AnyNote | AnyModelValue | AnyInputControl | AnyRangeControl | RankControl | SelectControl | TriggerControl | UploadControl;
17
+ export type AnyParentNode = PrimaryInstance | Root | Group | RepeatRange | RepeatInstance;
18
+ export type GeneralParentNode = Root | Group | RepeatInstance;
19
+ export type AnyChildNode = Root | Group | RepeatRange | RepeatInstance | AnyModelValue | AnyNote | AnyInputControl | AnyRangeControl | RankControl | SelectControl | TriggerControl | UploadControl;
20
+ export type GeneralChildNode = Group | RepeatRange | AnyModelValue | AnyNote | AnyInputControl | AnyRangeControl | RankControl | SelectControl | TriggerControl | UploadControl;
22
21
  export type AnyValueNode = AnyModelValue | AnyNote | AnyInputControl | AnyRangeControl | RankControl | SelectControl | TriggerControl | UploadControl;
@@ -0,0 +1,75 @@
1
+ import { AnchorMarkdownNode, ChildMarkdownNode as ClientChildMarkdownNode, HtmlMarkdownNode as ClientHtmlMarkdownNode, ParentMarkdownNode as ClientParentMarkdownNode, StyledMarkdownNode as ClientStyledMarkdownNode, ElementName, MarkdownNode, MarkdownProperty } from '../../client';
2
+ declare abstract class ParentMarkdownNode implements ClientParentMarkdownNode {
3
+ readonly children: MarkdownNode[];
4
+ readonly role = "parent";
5
+ abstract elementName: ElementName;
6
+ constructor(children: MarkdownNode[]);
7
+ }
8
+ export declare class Heading1 extends ParentMarkdownNode {
9
+ readonly elementName = "h1";
10
+ }
11
+ export declare class Heading2 extends ParentMarkdownNode {
12
+ readonly elementName = "h2";
13
+ }
14
+ export declare class Heading3 extends ParentMarkdownNode {
15
+ readonly elementName = "h3";
16
+ }
17
+ export declare class Heading4 extends ParentMarkdownNode {
18
+ readonly elementName = "h4";
19
+ }
20
+ export declare class Heading5 extends ParentMarkdownNode {
21
+ readonly elementName = "h5";
22
+ }
23
+ export declare class Heading6 extends ParentMarkdownNode {
24
+ readonly elementName = "h6";
25
+ }
26
+ export declare class Strong extends ParentMarkdownNode {
27
+ readonly elementName = "strong";
28
+ }
29
+ export declare class Underline extends ParentMarkdownNode {
30
+ readonly elementName = "u";
31
+ }
32
+ export declare class Emphasis extends ParentMarkdownNode {
33
+ readonly elementName = "em";
34
+ }
35
+ export declare class OrderedList extends ParentMarkdownNode {
36
+ readonly elementName = "ol";
37
+ }
38
+ export declare class UnorderedList extends ParentMarkdownNode {
39
+ readonly elementName = "ul";
40
+ }
41
+ export declare class ListItem extends ParentMarkdownNode {
42
+ readonly elementName = "li";
43
+ }
44
+ export declare class Anchor extends ParentMarkdownNode implements AnchorMarkdownNode {
45
+ readonly elementName = "a";
46
+ readonly url: string;
47
+ constructor(children: MarkdownNode[], url: string);
48
+ }
49
+ declare abstract class StyledMarkdownNode implements ClientParentMarkdownNode {
50
+ readonly children: MarkdownNode[];
51
+ readonly role = "parent";
52
+ abstract elementName: ElementName;
53
+ readonly properties: MarkdownProperty | undefined;
54
+ constructor(children: MarkdownNode[], properties: MarkdownProperty | undefined);
55
+ }
56
+ export declare class Paragraph extends StyledMarkdownNode implements ClientStyledMarkdownNode {
57
+ readonly elementName = "p";
58
+ }
59
+ export declare class Span extends StyledMarkdownNode implements ClientStyledMarkdownNode {
60
+ readonly elementName = "span";
61
+ }
62
+ export declare class Div extends StyledMarkdownNode implements ClientStyledMarkdownNode {
63
+ readonly elementName = "div";
64
+ }
65
+ export declare class ChildMarkdownNode implements ClientChildMarkdownNode {
66
+ readonly role = "child";
67
+ readonly value: string;
68
+ constructor(value: string);
69
+ }
70
+ export declare class Html implements ClientHtmlMarkdownNode {
71
+ readonly role = "html";
72
+ readonly unsafeHtml: string;
73
+ constructor(unsafeHtml: string);
74
+ }
75
+ export {};
@@ -5,7 +5,6 @@ export declare class TextChunk implements ClientTextChunk {
5
5
  readonly context: TranslationContext;
6
6
  readonly source: TextChunkSource;
7
7
  readonly asString: string;
8
- get formatted(): Record<PropertyKey, unknown>;
9
8
  get language(): ActiveLanguage;
10
9
  constructor(context: TranslationContext, source: TextChunkSource, asString: string);
11
10
  }
@@ -1,4 +1,5 @@
1
1
  import { JRResourceURL } from '../../../../common/src/jr-resources/JRResourceURL.ts';
2
+ import { MarkdownNode } from '../../client/MarkdownNode.ts';
2
3
  import { TextRange as ClientTextRange, TextChunk, TextOrigin, TextRole } from '../../client/TextRange.ts';
3
4
  export interface MediaSources {
4
5
  image?: JRResourceURL;
@@ -11,7 +12,7 @@ export declare class TextRange<Role extends TextRole, Origin extends TextOrigin>
11
12
  protected readonly chunks: readonly TextChunk[];
12
13
  protected readonly mediaSources?: MediaSources | undefined;
13
14
  [Symbol.iterator](): Generator<TextChunk, void, unknown>;
14
- get formatted(): Record<PropertyKey, unknown>;
15
+ get formatted(): MarkdownNode[];
15
16
  get asString(): string;
16
17
  get imageSource(): JRResourceURL | undefined;
17
18
  get audioSource(): JRResourceURL | undefined;
@@ -0,0 +1,3 @@
1
+ import { MarkdownNode } from '../../client';
2
+ import { TextChunk } from '../../client/TextRange.ts';
3
+ export declare function format(chunks: readonly TextChunk[]): MarkdownNode[];
@@ -1,13 +1,11 @@
1
1
  import { Accessor } from 'solid-js';
2
- import { SelectItem } from '../../client/SelectNode.ts';
3
- import { RankItem } from '../../client/RankNode.ts';
4
- import { SelectControl } from '../../instance/SelectControl.ts';
2
+ import { BaseItem } from '../../client/BaseItem.ts';
5
3
  import { RankControl } from '../../instance/RankControl.ts';
6
- export type ItemCollectionControl = RankControl | SelectControl;
7
- type Item = RankItem | SelectItem;
4
+ import { SelectControl } from '../../instance/SelectControl.ts';
5
+ type ItemCollectionControl = RankControl | SelectControl;
8
6
  /**
9
7
  * Creates a reactive computation of a {@link ItemCollectionControl}'s
10
- * {@link Item}s, in support of the field's `valueOptions`.
8
+ * {@link BaseItem}s, in support of the field's `valueOptions`.
11
9
  *
12
10
  * - The control defined with static `<item>`s will compute to an corresponding
13
11
  * static list of items.
@@ -17,5 +15,5 @@ type Item = RankItem | SelectItem;
17
15
  * their appropriate dependencies (whether relative to the itemset item node,
18
16
  * referencing a form's `itext` translations, etc).
19
17
  */
20
- export declare const createItemCollection: (control: ItemCollectionControl) => Accessor<readonly Item[]>;
18
+ export declare const createItemCollection: (control: ItemCollectionControl) => Accessor<readonly BaseItem[]>;
21
19
  export {};
@@ -7,9 +7,7 @@ import { RankControlDefinition } from './control/RankControlDefinition.ts';
7
7
  import { AnySelectControlDefinition } from './control/SelectControlDefinition.ts';
8
8
  import { TriggerControlDefinition } from './control/TriggerControlDefinition.ts';
9
9
  import { UploadControlDefinition } from './control/UploadControlDefinition.ts';
10
- import { LogicalGroupDefinition } from './group/LogicalGroupDefinition.ts';
11
- import { PresentationGroupDefinition } from './group/PresentationGroupDefinition.ts';
12
- import { StructuralGroupDefinition } from './group/StructuralGroupDefinition.ts';
10
+ import { GroupElementDefinition } from './GroupElementDefinition.ts';
13
11
  import { RepeatElementDefinition } from './RepeatElementDefinition.ts';
14
12
  import { UnsupportedBodyElementDefinition } from './UnsupportedBodyElementDefinition.ts';
15
13
  export interface BodyElementParentContext {
@@ -18,14 +16,10 @@ export interface BodyElementParentContext {
18
16
  readonly element: Element;
19
17
  }
20
18
  export type ControlElementDefinition = AnySelectControlDefinition | InputControlDefinition | RangeControlDefinition | RankControlDefinition | TriggerControlDefinition | UploadControlDefinition;
21
- type SupportedBodyElementDefinition = RepeatElementDefinition | LogicalGroupDefinition | PresentationGroupDefinition | StructuralGroupDefinition | ControlElementDefinition;
19
+ type SupportedBodyElementDefinition = ControlElementDefinition | GroupElementDefinition | RepeatElementDefinition;
22
20
  export type AnyBodyElementDefinition = SupportedBodyElementDefinition | UnsupportedBodyElementDefinition;
23
21
  export type BodyElementDefinitionArray = readonly AnyBodyElementDefinition[];
24
22
  export type AnyBodyElementType = AnyBodyElementDefinition['type'];
25
- export type AnyGroupElementDefinition = Extract<AnyBodyElementDefinition, {
26
- readonly type: `${string}-group`;
27
- }>;
28
- export declare const groupElementDefinition: (element: AnyBodyElementDefinition) => AnyGroupElementDefinition | null;
29
23
  export type AnyControlElementDefinition = Extract<AnyBodyElementDefinition, {
30
24
  readonly category: 'control';
31
25
  }>;
@@ -0,0 +1,22 @@
1
+ import { LabelDefinition } from '../text/LabelDefinition.ts';
2
+ import { XFormDefinition } from '../XFormDefinition.ts';
3
+ import { StructureElementAppearanceDefinition } from './appearance/structureElementAppearanceParser.ts';
4
+ import { BodyElementDefinitionArray, BodyElementParentContext } from './BodyDefinition.ts';
5
+ import { BodyElementDefinition } from './BodyElementDefinition.ts';
6
+ /**
7
+ * As per the spec: https://getodk.github.io/xforms-spec/#groups
8
+ *
9
+ * A group combines elements together.
10
+ * The group can have a label, and if so is referred to as a "presentation group".
11
+ * The group can have a ref, and if so is referred to as a "logical group".
12
+ */
13
+ export declare class GroupElementDefinition extends BodyElementDefinition<'group'> {
14
+ readonly category = "structure";
15
+ readonly type = "group";
16
+ readonly children: BodyElementDefinitionArray;
17
+ readonly reference: string | null;
18
+ readonly appearances: StructureElementAppearanceDefinition;
19
+ readonly label: LabelDefinition | null;
20
+ static isCompatible(localName: string): boolean;
21
+ constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
22
+ }
@@ -1,11 +1,13 @@
1
+ import { StaticElement } from '../../../integration/xpath/static-dom/StaticElement.ts';
1
2
  import { ItemsetElement } from '../../../lib/dom/query.ts';
3
+ import { DependentExpression } from '../../expression/abstract/DependentExpression.ts';
2
4
  import { ItemsetNodesetExpression } from '../../expression/ItemsetNodesetExpression.ts';
3
5
  import { ItemsetValueExpression } from '../../expression/ItemsetValueExpression.ts';
4
6
  import { ItemsetLabelDefinition } from '../../text/ItemsetLabelDefinition.ts';
5
7
  import { XFormDefinition } from '../../XFormDefinition.ts';
6
8
  import { BodyElementDefinition } from '../BodyElementDefinition.ts';
7
- import { AnySelectControlDefinition } from './SelectControlDefinition.ts';
8
9
  import { RankControlDefinition } from './RankControlDefinition.ts';
10
+ import { AnySelectControlDefinition } from './SelectControlDefinition.ts';
9
11
  export declare class ItemsetDefinition extends BodyElementDefinition<'itemset'> {
10
12
  readonly parent: AnySelectControlDefinition | RankControlDefinition;
11
13
  readonly category = "support";
@@ -15,4 +17,5 @@ export declare class ItemsetDefinition extends BodyElementDefinition<'itemset'>
15
17
  readonly nodes: ItemsetNodesetExpression;
16
18
  readonly value: ItemsetValueExpression;
17
19
  constructor(form: XFormDefinition, parent: AnySelectControlDefinition | RankControlDefinition, element: ItemsetElement);
20
+ getPropertiesExpressions(propertiesNodes: StaticElement[]): Array<DependentExpression<'string'>>;
18
21
  }
@@ -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(bind: BindDefinition, computation: Computation, expression: string | null);
28
+ protected constructor(computation: Computation, expression: string | null);
29
29
  }
30
30
  export {};
@@ -0,0 +1,6 @@
1
+ import { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
2
+ import { DependentExpression } from './abstract/DependentExpression.ts';
3
+ export declare class ItemPropertyExpression extends DependentExpression<'string'> {
4
+ static from(propertiesNodes: StaticElement[]): ItemPropertyExpression[];
5
+ constructor(propertyName: string);
6
+ }
@@ -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(itemset: ItemsetDefinition, nodesetExpression: string);
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 isTranslated?: true;
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
- constructor(context: AnyTextRangeDefinition, resultType: T, expression: string, source: TextChunkSource, options?: TextChunkExpressionOptions, literalValue?: string);
11
- static fromLiteral(context: AnyTextRangeDefinition, stringValue: string): TextChunkExpression<'string'>;
12
- static fromReference(context: AnyTextRangeDefinition, ref: string): TextChunkExpression<'string'>;
13
- static fromOutput(context: AnyTextRangeDefinition, element: Element): TextChunkExpression<'string'> | null;
14
- static fromTranslation(context: AnyTextRangeDefinition, maybeExpression: string): TextChunkExpression<'nodes'> | null;
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(context: DependencyContext, resultType: Type, expression: string, options?: DependentExpressionOptions);
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,13 +1,14 @@
1
1
  import { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
2
2
  import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
3
3
  import { QualifiedName } from '../../lib/names/QualifiedName.ts';
4
- import { AnyBodyElementDefinition, AnyGroupElementDefinition } from '../body/BodyDefinition.ts';
4
+ import { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
5
+ import { GroupElementDefinition } from '../body/GroupElementDefinition.ts';
5
6
  import { BindDefinition } from './BindDefinition.ts';
6
7
  import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
7
8
  import { ChildNodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
8
- export declare class SubtreeDefinition extends DescendentNodeDefinition<'subtree', AnyGroupElementDefinition | null> {
9
+ export declare class GroupDefinition extends DescendentNodeDefinition<'group', GroupElementDefinition | null> {
9
10
  readonly template: StaticElement;
10
- readonly type = "subtree";
11
+ readonly type = "group";
11
12
  readonly namespaceDeclarations: NamespaceDeclarationMap;
12
13
  readonly qualifiedName: QualifiedName;
13
14
  readonly children: readonly ChildNodeDefinition[];
@@ -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
  }
@@ -4,10 +4,10 @@ import { QualifiedName } from '../../lib/names/QualifiedName.ts';
4
4
  import { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
5
5
  import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
6
6
  import { BindDefinition } from './BindDefinition.ts';
7
+ import { GroupDefinition } from './GroupDefinition.ts';
7
8
  import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
8
9
  import { AnyRepeatDefinition } from './RepeatDefinition.ts';
9
10
  import { RootDefinition } from './RootDefinition.ts';
10
- import { SubtreeDefinition } from './SubtreeDefinition.ts';
11
11
  /**
12
12
  * Corresponds to a model instance root node, i.e.:
13
13
  *
@@ -27,10 +27,9 @@ export type RootNodeType = 'root';
27
27
  export type RepeatType = 'repeat';
28
28
  /**
29
29
  * Corresponds to a model instance subtree which **does not** correspond to a
30
- * <repeat> in the form definition. This will typically correspond to a <group>,
31
- * but this is not strictly necessary per spec (hence the distinct name).
30
+ * <repeat> in the form definition.
32
31
  */
33
- export type SubtreeNodeType = 'subtree';
32
+ export type GroupNodeType = 'group';
34
33
  /**
35
34
  * Corresponds to a model instance leaf node, i.e. one of:
36
35
  *
@@ -38,9 +37,9 @@ export type SubtreeNodeType = 'subtree';
38
37
  * - Any attribute corresponding to a bind's `nodeset` expression
39
38
  */
40
39
  export type LeafNodeType = 'leaf-node';
41
- export type NodeDefinitionType = RootNodeType | RepeatType | SubtreeNodeType | LeafNodeType;
42
- export type ParentNodeDefinition = RootDefinition | AnyRepeatDefinition | SubtreeDefinition;
43
- export type ChildNodeDefinition = AnyRepeatDefinition | LeafNodeDefinition | SubtreeDefinition;
40
+ export type NodeDefinitionType = RootNodeType | RepeatType | GroupNodeType | LeafNodeType;
41
+ export type ParentNodeDefinition = RootDefinition | AnyRepeatDefinition | GroupDefinition;
42
+ export type ChildNodeDefinition = AnyRepeatDefinition | GroupDefinition | LeafNodeDefinition;
44
43
  export declare abstract class NodeDefinition<Type extends NodeDefinitionType> implements NamedSubtreeDefinition {
45
44
  readonly bind: BindDefinition;
46
45
  abstract readonly type: Type;
@@ -55,4 +54,4 @@ export declare abstract class NodeDefinition<Type extends NodeDefinitionType> im
55
54
  readonly nodeset: string;
56
55
  constructor(bind: BindDefinition);
57
56
  }
58
- export type AnyNodeDefinition = RootDefinition | AnyRepeatDefinition | SubtreeDefinition | LeafNodeDefinition;
57
+ export type AnyNodeDefinition = RootDefinition | AnyRepeatDefinition | GroupDefinition | LeafNodeDefinition;
@@ -18,7 +18,7 @@ export interface UncontrolledRepeatDefinition extends RepeatDefinition {
18
18
  * "repeat", as defined by a form, where those concepts include:
19
19
  *
20
20
  * - A {@link RepeatElementDefinition}—corresponding to a `<repeat>` {@link https://getodk.github.io/xforms-spec/#body-elements | body element}—which is associated with the nodeset referencing the "repeat template" and
21
- * all "repeat instances" (see below points describing both concepts in more detail). The presence of such a body element determines whether to produce a repeat definition (rather than e.g. a {@link SubtreeDefinition}).
21
+ * all "repeat instances" (see below points describing both concepts in more detail). The presence of such a body element determines whether to produce a repeat definition (rather than e.g. a {@link GroupDefinition}).
22
22
  *
23
23
  * - A "repeat template", defined by a form either
24
24
  * explicitly,
@@ -24,5 +24,5 @@ export declare class RootDefinition extends NodeDefinition<'root'> {
24
24
  readonly isTranslated = false;
25
25
  constructor(form: XFormDefinition, model: ModelDefinition, submission: SubmissionDefinition, classes: BodyClassList);
26
26
  buildSubtree(parent: ParentNodeDefinition, node: StaticElement): readonly ChildNodeDefinition[];
27
- toJSON(): Omit<this, "form" | "toJSON" | "bind" | "root" | "model" | "bodyElement" | "buildSubtree">;
27
+ toJSON(): Omit<this, "form" | "toJSON" | "bind" | "model" | "root" | "bodyElement" | "buildSubtree">;
28
28
  }
@@ -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>;
@@ -1,14 +1,13 @@
1
1
  import { XFormDefinition } from '../../parse/XFormDefinition.ts';
2
- import { AnyGroupElementDefinition } from '../../parse/body/BodyDefinition.ts';
3
- import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
4
2
  import { AnyControlDefinition } from '../body/control/ControlDefinition.ts';
5
- import { BaseGroupDefinition } from '../body/group/BaseGroupDefinition.ts';
3
+ import { GroupElementDefinition } from '../body/GroupElementDefinition.ts';
4
+ import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
6
5
  import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
7
- export type LabelOwner = AnyControlDefinition | AnyGroupElementDefinition | RepeatElementDefinition;
6
+ export type LabelOwner = AnyControlDefinition | GroupElementDefinition | RepeatElementDefinition;
8
7
  export declare class LabelDefinition extends TextElementDefinition<'label'> {
9
8
  static forControl(form: XFormDefinition, control: AnyControlDefinition): LabelDefinition | null;
10
9
  static forRepeatGroup(form: XFormDefinition, repeat: RepeatElementDefinition): LabelDefinition | null;
11
- static forGroup(form: XFormDefinition, group: BaseGroupDefinition<any>): LabelDefinition | null;
10
+ static forGroup(form: XFormDefinition, group: GroupElementDefinition): LabelDefinition | null;
12
11
  readonly role = "label";
13
12
  private constructor();
14
13
  }
@@ -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: