@getodk/xforms-engine 0.1.1 → 0.3.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 (228) hide show
  1. package/dist/body/BodyDefinition.d.ts +24 -7
  2. package/dist/body/BodyElementDefinition.d.ts +4 -3
  3. package/dist/body/RepeatElementDefinition.d.ts +19 -0
  4. package/dist/body/appearance/inputAppearanceParser.d.ts +4 -0
  5. package/dist/body/appearance/selectAppearanceParser.d.ts +4 -0
  6. package/dist/body/appearance/structureElementAppearanceParser.d.ts +4 -0
  7. package/dist/body/control/ControlDefinition.d.ts +4 -2
  8. package/dist/body/control/InputDefinition.d.ts +5 -0
  9. package/dist/body/control/select/ItemDefinition.d.ts +2 -2
  10. package/dist/body/control/select/ItemsetDefinition.d.ts +5 -4
  11. package/dist/body/control/select/SelectDefinition.d.ts +11 -1
  12. package/dist/body/group/BaseGroupDefinition.d.ts +4 -9
  13. package/dist/body/group/PresentationGroupDefinition.d.ts +1 -1
  14. package/dist/client/BaseNode.d.ts +74 -3
  15. package/dist/client/GroupNode.d.ts +7 -2
  16. package/dist/client/ModelValueNode.d.ts +37 -0
  17. package/dist/client/NodeAppearances.d.ts +15 -0
  18. package/dist/client/NoteNode.d.ts +53 -0
  19. package/dist/client/RootNode.d.ts +21 -0
  20. package/dist/client/SelectNode.d.ts +8 -3
  21. package/dist/client/StringNode.d.ts +8 -3
  22. package/dist/client/SubtreeNode.d.ts +3 -0
  23. package/dist/client/TextRange.d.ts +85 -2
  24. package/dist/client/constants.d.ts +9 -0
  25. package/dist/client/hierarchy.d.ts +14 -9
  26. package/dist/client/node-types.d.ts +2 -1
  27. package/dist/client/{RepeatRangeNode.d.ts → repeat/BaseRepeatRangeNode.d.ts} +19 -15
  28. package/dist/client/{RepeatInstanceNode.d.ts → repeat/RepeatInstanceNode.d.ts} +11 -7
  29. package/dist/client/repeat/RepeatRangeControlledNode.d.ts +19 -0
  30. package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +20 -0
  31. package/dist/client/validation.d.ts +163 -0
  32. package/dist/expression/DependentExpression.d.ts +12 -8
  33. package/dist/index.d.ts +9 -4
  34. package/dist/index.js +3173 -960
  35. package/dist/index.js.map +1 -1
  36. package/dist/instance/Group.d.ts +6 -4
  37. package/dist/instance/ModelValue.d.ts +40 -0
  38. package/dist/instance/Note.d.ts +42 -0
  39. package/dist/instance/Root.d.ts +10 -23
  40. package/dist/instance/SelectField.d.ts +12 -6
  41. package/dist/instance/StringField.d.ts +13 -7
  42. package/dist/instance/Subtree.d.ts +3 -1
  43. package/dist/instance/abstract/DescendantNode.d.ts +16 -9
  44. package/dist/instance/abstract/InstanceNode.d.ts +28 -29
  45. package/dist/instance/hierarchy.d.ts +10 -5
  46. package/dist/instance/internal-api/EvaluationContext.d.ts +5 -4
  47. package/dist/instance/internal-api/ValidationContext.d.ts +21 -0
  48. package/dist/instance/internal-api/ValueContext.d.ts +2 -2
  49. package/dist/instance/repeat/BaseRepeatRange.d.ts +160 -0
  50. package/dist/instance/{RepeatInstance.d.ts → repeat/RepeatInstance.d.ts} +38 -13
  51. package/dist/instance/repeat/RepeatRangeControlled.d.ts +16 -0
  52. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +35 -0
  53. package/dist/instance/text/TextRange.d.ts +4 -4
  54. package/dist/lib/TokenListParser.d.ts +84 -0
  55. package/dist/lib/dom/query.d.ts +5 -0
  56. package/dist/lib/reactivity/createComputedExpression.d.ts +6 -1
  57. package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +5 -0
  58. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +2 -1
  59. package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +1 -1
  60. package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +1 -1
  61. package/dist/lib/reactivity/text/createFieldHint.d.ts +3 -3
  62. package/dist/lib/reactivity/text/createNodeLabel.d.ts +2 -2
  63. package/dist/lib/reactivity/text/createNoteText.d.ts +25 -0
  64. package/dist/lib/reactivity/text/createTextRange.d.ts +5 -7
  65. package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +9 -0
  66. package/dist/lib/reactivity/validation/createValidation.d.ts +18 -0
  67. package/dist/model/BindDefinition.d.ts +4 -2
  68. package/dist/model/BindElement.d.ts +1 -0
  69. package/dist/model/DescendentNodeDefinition.d.ts +1 -2
  70. package/dist/model/{ValueNodeDefinition.d.ts → LeafNodeDefinition.d.ts} +3 -4
  71. package/dist/model/NodeDefinition.d.ts +16 -16
  72. package/dist/model/RepeatInstanceDefinition.d.ts +5 -6
  73. package/dist/model/RepeatRangeDefinition.d.ts +30 -0
  74. package/dist/model/RepeatTemplateDefinition.d.ts +6 -7
  75. package/dist/model/RootDefinition.d.ts +3 -1
  76. package/dist/model/SubtreeDefinition.d.ts +2 -2
  77. package/dist/parse/NoteNodeDefinition.d.ts +31 -0
  78. package/dist/parse/expression/RepeatCountControlExpression.d.ts +19 -0
  79. package/dist/parse/text/HintDefinition.d.ts +9 -0
  80. package/dist/parse/text/ItemLabelDefinition.d.ts +9 -0
  81. package/dist/parse/text/ItemsetLabelDefinition.d.ts +13 -0
  82. package/dist/parse/text/LabelDefinition.d.ts +15 -0
  83. package/dist/parse/text/MessageDefinition.d.ts +15 -0
  84. package/dist/parse/text/OutputChunkDefinition.d.ts +8 -0
  85. package/dist/parse/text/ReferenceChunkDefinition.d.ts +8 -0
  86. package/dist/parse/text/StaticTextChunkDefinition.d.ts +10 -0
  87. package/dist/parse/text/TranslationChunkDefinition.d.ts +9 -0
  88. package/dist/parse/text/abstract/TextChunkDefinition.d.ts +18 -0
  89. package/dist/parse/text/abstract/TextElementDefinition.d.ts +23 -0
  90. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +35 -0
  91. package/dist/parse/xpath/dependency-analysis.d.ts +40 -0
  92. package/dist/parse/xpath/path-resolution.d.ts +70 -0
  93. package/dist/parse/xpath/predicate-analysis.d.ts +30 -0
  94. package/dist/parse/xpath/reference-parsing.d.ts +18 -0
  95. package/dist/parse/xpath/semantic-analysis.d.ts +98 -0
  96. package/dist/parse/xpath/syntax-traversal.d.ts +69 -0
  97. package/dist/solid.js +3174 -961
  98. package/dist/solid.js.map +1 -1
  99. package/package.json +14 -15
  100. package/src/XFormDOM.ts +81 -8
  101. package/src/body/BodyDefinition.ts +38 -23
  102. package/src/body/BodyElementDefinition.ts +4 -3
  103. package/src/body/RepeatElementDefinition.ts +58 -0
  104. package/src/body/appearance/inputAppearanceParser.ts +39 -0
  105. package/src/body/appearance/selectAppearanceParser.ts +38 -0
  106. package/src/body/appearance/structureElementAppearanceParser.ts +7 -0
  107. package/src/body/control/ControlDefinition.ts +8 -3
  108. package/src/body/control/InputDefinition.ts +13 -0
  109. package/src/body/control/select/ItemDefinition.ts +3 -3
  110. package/src/body/control/select/ItemsetDefinition.ts +29 -12
  111. package/src/body/control/select/ItemsetNodesetExpression.ts +1 -1
  112. package/src/body/control/select/SelectDefinition.ts +14 -5
  113. package/src/body/group/BaseGroupDefinition.ts +14 -51
  114. package/src/body/group/PresentationGroupDefinition.ts +1 -1
  115. package/src/client/BaseNode.ts +82 -8
  116. package/src/client/GroupNode.ts +8 -2
  117. package/src/client/ModelValueNode.ts +40 -0
  118. package/src/client/NodeAppearances.ts +22 -0
  119. package/src/client/NoteNode.ts +74 -0
  120. package/src/client/README.md +1 -0
  121. package/src/client/RootNode.ts +24 -0
  122. package/src/client/SelectNode.ts +9 -3
  123. package/src/client/StringNode.ts +9 -3
  124. package/src/client/SubtreeNode.ts +3 -0
  125. package/src/client/TextRange.ts +99 -2
  126. package/src/client/constants.ts +10 -0
  127. package/src/client/hierarchy.ts +30 -14
  128. package/src/client/node-types.ts +8 -1
  129. package/src/client/{RepeatRangeNode.ts → repeat/BaseRepeatRangeNode.ts} +20 -17
  130. package/src/client/{RepeatInstanceNode.ts → repeat/RepeatInstanceNode.ts} +13 -7
  131. package/src/client/repeat/RepeatRangeControlledNode.ts +20 -0
  132. package/src/client/repeat/RepeatRangeUncontrolledNode.ts +21 -0
  133. package/src/client/validation.ts +199 -0
  134. package/src/expression/DependentExpression.ts +45 -27
  135. package/src/index.ts +15 -8
  136. package/src/instance/Group.ts +24 -13
  137. package/src/instance/ModelValue.ts +104 -0
  138. package/src/instance/Note.ts +142 -0
  139. package/src/instance/Root.ts +29 -67
  140. package/src/instance/SelectField.ts +35 -13
  141. package/src/instance/StringField.ts +40 -13
  142. package/src/instance/Subtree.ts +19 -10
  143. package/src/instance/abstract/DescendantNode.ts +50 -49
  144. package/src/instance/abstract/InstanceNode.ts +89 -92
  145. package/src/instance/children.ts +47 -10
  146. package/src/instance/hierarchy.ts +21 -2
  147. package/src/instance/index.ts +1 -1
  148. package/src/instance/internal-api/EvaluationContext.ts +5 -6
  149. package/src/instance/internal-api/ValidationContext.ts +23 -0
  150. package/src/instance/internal-api/ValueContext.ts +2 -2
  151. package/src/instance/repeat/BaseRepeatRange.ts +347 -0
  152. package/src/instance/{RepeatInstance.ts → repeat/RepeatInstance.ts} +85 -36
  153. package/src/instance/repeat/RepeatRangeControlled.ts +82 -0
  154. package/src/instance/repeat/RepeatRangeUncontrolled.ts +67 -0
  155. package/src/instance/text/TextRange.ts +10 -4
  156. package/src/lib/TokenListParser.ts +156 -0
  157. package/src/lib/dom/query.ts +13 -0
  158. package/src/lib/reactivity/createChildrenState.ts +51 -6
  159. package/src/lib/reactivity/createComputedExpression.ts +23 -25
  160. package/src/lib/reactivity/createNoteReadonlyThunk.ts +33 -0
  161. package/src/lib/reactivity/createSelectItems.ts +25 -20
  162. package/src/lib/reactivity/createValueState.ts +6 -6
  163. package/src/lib/reactivity/materializeCurrentStateChildren.ts +3 -1
  164. package/src/lib/reactivity/node-state/createSharedNodeState.ts +1 -1
  165. package/src/lib/reactivity/text/createFieldHint.ts +9 -7
  166. package/src/lib/reactivity/text/createNodeLabel.ts +7 -5
  167. package/src/lib/reactivity/text/createNoteText.ts +72 -0
  168. package/src/lib/reactivity/text/createTextRange.ts +17 -90
  169. package/src/lib/reactivity/validation/createAggregatedViolations.ts +70 -0
  170. package/src/lib/reactivity/validation/createValidation.ts +196 -0
  171. package/src/model/BindComputation.ts +0 -4
  172. package/src/model/BindDefinition.ts +8 -6
  173. package/src/model/BindElement.ts +1 -0
  174. package/src/model/DescendentNodeDefinition.ts +1 -2
  175. package/src/model/{ValueNodeDefinition.ts → LeafNodeDefinition.ts} +5 -6
  176. package/src/model/ModelBindMap.ts +4 -0
  177. package/src/model/ModelDefinition.ts +1 -1
  178. package/src/model/NodeDefinition.ts +21 -21
  179. package/src/model/RepeatInstanceDefinition.ts +8 -13
  180. package/src/model/RepeatRangeDefinition.ts +94 -0
  181. package/src/model/RepeatTemplateDefinition.ts +10 -15
  182. package/src/model/RootDefinition.ts +12 -14
  183. package/src/model/SubtreeDefinition.ts +3 -3
  184. package/src/parse/NoteNodeDefinition.ts +70 -0
  185. package/src/parse/TODO.md +3 -0
  186. package/src/parse/expression/RepeatCountControlExpression.ts +44 -0
  187. package/src/parse/text/HintDefinition.ts +25 -0
  188. package/src/parse/text/ItemLabelDefinition.ts +25 -0
  189. package/src/parse/text/ItemsetLabelDefinition.ts +44 -0
  190. package/src/parse/text/LabelDefinition.ts +61 -0
  191. package/src/parse/text/MessageDefinition.ts +49 -0
  192. package/src/parse/text/OutputChunkDefinition.ts +25 -0
  193. package/src/parse/text/ReferenceChunkDefinition.ts +14 -0
  194. package/src/parse/text/StaticTextChunkDefinition.ts +19 -0
  195. package/src/parse/text/TranslationChunkDefinition.ts +38 -0
  196. package/src/parse/text/abstract/TextChunkDefinition.ts +38 -0
  197. package/src/parse/text/abstract/TextElementDefinition.ts +71 -0
  198. package/src/parse/text/abstract/TextRangeDefinition.ts +70 -0
  199. package/src/parse/xpath/dependency-analysis.ts +105 -0
  200. package/src/parse/xpath/path-resolution.ts +475 -0
  201. package/src/parse/xpath/predicate-analysis.ts +61 -0
  202. package/src/parse/xpath/reference-parsing.ts +90 -0
  203. package/src/parse/xpath/semantic-analysis.ts +466 -0
  204. package/src/parse/xpath/syntax-traversal.ts +129 -0
  205. package/dist/body/RepeatDefinition.d.ts +0 -16
  206. package/dist/body/group/RepeatGroupDefinition.d.ts +0 -13
  207. package/dist/body/text/HintDefinition.d.ts +0 -11
  208. package/dist/body/text/LabelDefinition.d.ts +0 -20
  209. package/dist/body/text/TextElementDefinition.d.ts +0 -33
  210. package/dist/body/text/TextElementOutputPart.d.ts +0 -13
  211. package/dist/body/text/TextElementPart.d.ts +0 -13
  212. package/dist/body/text/TextElementReferencePart.d.ts +0 -7
  213. package/dist/body/text/TextElementStaticPart.d.ts +0 -7
  214. package/dist/instance/RepeatRange.d.ts +0 -80
  215. package/dist/lib/xpath/analysis.d.ts +0 -23
  216. package/dist/model/RepeatSequenceDefinition.d.ts +0 -20
  217. package/src/body/RepeatDefinition.ts +0 -54
  218. package/src/body/group/RepeatGroupDefinition.ts +0 -91
  219. package/src/body/text/HintDefinition.ts +0 -26
  220. package/src/body/text/LabelDefinition.ts +0 -54
  221. package/src/body/text/TextElementDefinition.ts +0 -97
  222. package/src/body/text/TextElementOutputPart.ts +0 -27
  223. package/src/body/text/TextElementPart.ts +0 -31
  224. package/src/body/text/TextElementReferencePart.ts +0 -21
  225. package/src/body/text/TextElementStaticPart.ts +0 -26
  226. package/src/instance/RepeatRange.ts +0 -214
  227. package/src/lib/xpath/analysis.ts +0 -241
  228. package/src/model/RepeatSequenceDefinition.ts +0 -53
@@ -1,12 +1,12 @@
1
1
  import { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
2
- import { RepeatDefinition } from '../body/RepeatDefinition.ts';
2
+ import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
3
3
  import { BindDefinition } from './BindDefinition.ts';
4
+ import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
4
5
  import { RepeatInstanceDefinition } from './RepeatInstanceDefinition.ts';
5
- import { RepeatSequenceDefinition } from './RepeatSequenceDefinition.ts';
6
+ import { AnyRepeatRangeDefinition } from './RepeatRangeDefinition.ts';
6
7
  import { RepeatTemplateDefinition } from './RepeatTemplateDefinition.ts';
7
8
  import { RootDefinition } from './RootDefinition.ts';
8
9
  import { SubtreeDefinition } from './SubtreeDefinition.ts';
9
- import { ValueNodeDefinition } from './ValueNodeDefinition.ts';
10
10
 
11
11
  /**
12
12
  * Corresponds to the model/entry DOM root node, i.e.:
@@ -16,12 +16,12 @@ import { ValueNodeDefinition } from './ValueNodeDefinition.ts';
16
16
  */
17
17
  export type RootNodeType = 'root';
18
18
  /**
19
- * Corresponds to a sequence of model/entry DOM subtrees which in turn
19
+ * Corresponds to a range/sequence of model/entry DOM subtrees which in turn
20
20
  * corresponds to a <repeat> in the form body definition.
21
21
  */
22
- export type RepeatSequenceType = 'repeat-sequence';
22
+ export type RepeatRangeType = 'repeat-range';
23
23
  /**
24
- * Corresponds to a template definition for a repeat sequence, which either has
24
+ * Corresponds to a template definition for a repeat range, which either has
25
25
  * an explicit `jr:template=""` attribute in the form definition or is inferred
26
26
  * as a template from the form's first element matched by a <repeat nodeset>.
27
27
  */
@@ -29,7 +29,7 @@ export type RepeatTemplateType = 'repeat-template';
29
29
  /**
30
30
  * Corresponds to a single instance of a model/entry DOM subtree which
31
31
  * in turn corresponds to a <repeat> in the form body definition, and a
32
- * 'repeat-sequence' definition.
32
+ * 'repeat-range' definition.
33
33
  */
34
34
  export type RepeatInstanceType = 'repeat-instance';
35
35
  /**
@@ -44,22 +44,22 @@ export type SubtreeNodeType = 'subtree';
44
44
  * - An element with no child elements
45
45
  * - Any attribute corresponding to a bind's `nodeset` expression
46
46
  */
47
- export type ValueNodeType = 'value-node';
48
- export type NodeDefinitionType = RootNodeType | RepeatSequenceType | RepeatTemplateType | RepeatInstanceType | SubtreeNodeType | ValueNodeType;
47
+ export type LeafNodeType = 'leaf-node';
48
+ export type NodeDefinitionType = RootNodeType | RepeatRangeType | RepeatTemplateType | RepeatInstanceType | SubtreeNodeType | LeafNodeType;
49
49
  export type ParentNodeDefinition = RootDefinition | RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition;
50
- export type ChildNodeDefinition = RepeatSequenceDefinition | SubtreeDefinition | ValueNodeDefinition;
51
- export type ChildNodeInstanceDefinition = RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition | ValueNodeDefinition;
50
+ export type ChildNodeDefinition = AnyRepeatRangeDefinition | LeafNodeDefinition | SubtreeDefinition;
51
+ export type ChildNodeInstanceDefinition = RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition | LeafNodeDefinition;
52
52
  export type NodeChildren<Type extends NodeDefinitionType> = Type extends ParentNodeDefinition['type'] ? readonly ChildNodeDefinition[] : null;
53
- export type NodeInstances<Type extends NodeDefinitionType> = Type extends 'repeat-sequence' ? readonly RepeatInstanceDefinition[] : null;
53
+ export type NodeInstances<Type extends NodeDefinitionType> = Type extends 'repeat-range' ? readonly RepeatInstanceDefinition[] : null;
54
54
  export type NodeParent<Type extends NodeDefinitionType> = Type extends ChildNodeDefinition['type'] | ChildNodeInstanceDefinition['type'] ? ParentNodeDefinition : null;
55
- export type ModelNode<Type extends NodeDefinitionType> = Type extends 'repeat-sequence' ? null : Element;
56
- export type NodeDefaultValue<Type extends NodeDefinitionType> = Type extends 'value-node' ? string : null;
55
+ export type ModelNode<Type extends NodeDefinitionType> = Type extends 'repeat-range' ? null : Element;
56
+ export type NodeDefaultValue<Type extends NodeDefinitionType> = Type extends 'leaf-node' ? string : null;
57
57
  export interface NodeDefinition<Type extends NodeDefinitionType> {
58
58
  readonly type: Type;
59
59
  readonly bind: BindDefinition;
60
60
  readonly nodeset: string;
61
61
  readonly nodeName: string;
62
- readonly bodyElement: AnyBodyElementDefinition | RepeatDefinition | null;
62
+ readonly bodyElement: AnyBodyElementDefinition | RepeatElementDefinition | null;
63
63
  readonly isTranslated: boolean;
64
64
  readonly dependencyExpressions: ReadonlySet<string>;
65
65
  readonly root: RootDefinition;
@@ -69,7 +69,7 @@ export interface NodeDefinition<Type extends NodeDefinitionType> {
69
69
  readonly node: ModelNode<Type>;
70
70
  readonly defaultValue: NodeDefaultValue<Type>;
71
71
  }
72
- export type AnyNodeDefinition = RootDefinition | RepeatSequenceDefinition | RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition | ValueNodeDefinition;
72
+ export type AnyNodeDefinition = RootDefinition | AnyRepeatRangeDefinition | RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition | LeafNodeDefinition;
73
73
  export type TypedNodeDefinition<Type> = Extract<AnyNodeDefinition, {
74
74
  readonly type: Type;
75
75
  }>;
@@ -1,16 +1,15 @@
1
- import { RepeatDefinition } from '../body/RepeatDefinition.ts';
1
+ import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
2
2
  import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
3
3
  import { ChildNodeDefinition, NodeDefinition } from './NodeDefinition.ts';
4
- import { RepeatSequenceDefinition } from './RepeatSequenceDefinition.ts';
4
+ import { AnyRepeatRangeDefinition } from './RepeatRangeDefinition.ts';
5
5
 
6
- export declare class RepeatInstanceDefinition extends DescendentNodeDefinition<'repeat-instance', RepeatDefinition> implements NodeDefinition<'repeat-instance'> {
7
- protected readonly sequence: RepeatSequenceDefinition;
6
+ export declare class RepeatInstanceDefinition extends DescendentNodeDefinition<'repeat-instance', RepeatElementDefinition> implements NodeDefinition<'repeat-instance'> {
8
7
  readonly node: Element;
9
8
  readonly type = "repeat-instance";
10
9
  readonly nodeName: string;
11
10
  readonly children: readonly ChildNodeDefinition[];
12
11
  readonly instances: null;
13
12
  readonly defaultValue: null;
14
- constructor(sequence: RepeatSequenceDefinition, node: Element);
15
- toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement" | "sequence">;
13
+ constructor(range: AnyRepeatRangeDefinition, node: Element);
14
+ toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement">;
16
15
  }
@@ -0,0 +1,30 @@
1
+ import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
2
+ import { RepeatCountControlExpression } from '../parse/expression/RepeatCountControlExpression.ts';
3
+ import { BindDefinition } from './BindDefinition.ts';
4
+ import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
5
+ import { NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
6
+ import { RepeatInstanceDefinition } from './RepeatInstanceDefinition.ts';
7
+ import { RepeatTemplateDefinition } from './RepeatTemplateDefinition.ts';
8
+
9
+ export interface ControlledRepeatRangeDefinition extends RepeatRangeDefinition {
10
+ readonly count: RepeatCountControlExpression;
11
+ }
12
+ export interface UncontrolledRepeatRangeDefinition extends RepeatRangeDefinition {
13
+ readonly count: null;
14
+ }
15
+ export type AnyRepeatRangeDefinition = ControlledRepeatRangeDefinition | UncontrolledRepeatRangeDefinition;
16
+ export declare class RepeatRangeDefinition extends DescendentNodeDefinition<'repeat-range', RepeatElementDefinition> implements NodeDefinition<'repeat-range'> {
17
+ static from(parent: ParentNodeDefinition, bind: BindDefinition, bodyElement: RepeatElementDefinition, modelNodes: readonly [Element, ...Element[]]): AnyRepeatRangeDefinition;
18
+ readonly type = "repeat-range";
19
+ readonly template: RepeatTemplateDefinition;
20
+ readonly children: null;
21
+ readonly instances: RepeatInstanceDefinition[];
22
+ readonly count: RepeatCountControlExpression | null;
23
+ readonly node: null;
24
+ readonly nodeName: string;
25
+ readonly defaultValue: null;
26
+ private constructor();
27
+ isControlled(): this is ControlledRepeatRangeDefinition;
28
+ isUncontrolled(): this is UncontrolledRepeatRangeDefinition;
29
+ toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement" | "isControlled" | "isUncontrolled">;
30
+ }
@@ -1,8 +1,8 @@
1
1
  import { JAVAROSA_NAMESPACE_URI } from '../../../common/src/constants/xmlns.ts';
2
- import { RepeatDefinition } from '../body/RepeatDefinition.ts';
2
+ import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
3
3
  import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
4
4
  import { ChildNodeDefinition, NodeDefinition } from './NodeDefinition.ts';
5
- import { RepeatSequenceDefinition } from './RepeatSequenceDefinition.ts';
5
+ import { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
6
6
 
7
7
  interface ExplicitRepeatTemplateElement extends Element {
8
8
  getAttributeNS(namespaceURI: typeof JAVAROSA_NAMESPACE_URI, name: 'template'): string;
@@ -14,17 +14,16 @@ interface ParsedRepeatNodes {
14
14
  readonly template: RepeatTemplateDefinition;
15
15
  readonly instanceNodes: readonly Element[];
16
16
  }
17
- export declare class RepeatTemplateDefinition extends DescendentNodeDefinition<'repeat-template', RepeatDefinition> implements NodeDefinition<'repeat-template'> {
18
- protected readonly sequence: RepeatSequenceDefinition;
17
+ export declare class RepeatTemplateDefinition extends DescendentNodeDefinition<'repeat-template', RepeatElementDefinition> implements NodeDefinition<'repeat-template'> {
19
18
  protected readonly templateNode: ExplicitRepeatTemplateElement;
20
- static parseModelNodes(sequence: RepeatSequenceDefinition, modelNodes: readonly [Element, ...Element[]]): ParsedRepeatNodes;
19
+ static parseModelNodes(range: RepeatRangeDefinition, modelNodes: readonly [Element, ...Element[]]): ParsedRepeatNodes;
21
20
  readonly type = "repeat-template";
22
21
  readonly node: Element;
23
22
  readonly nodeName: string;
24
23
  readonly children: readonly ChildNodeDefinition[];
25
24
  readonly instances: null;
26
25
  readonly defaultValue: null;
27
- protected constructor(sequence: RepeatSequenceDefinition, templateNode: ExplicitRepeatTemplateElement);
28
- toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement" | "sequence">;
26
+ protected constructor(range: RepeatRangeDefinition, templateNode: ExplicitRepeatTemplateElement);
27
+ toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement">;
29
28
  }
30
29
  export {};
@@ -1,4 +1,5 @@
1
1
  import { XFormDefinition } from '../XFormDefinition.ts';
2
+ import { BodyClassList } from '../body/BodyDefinition.ts';
2
3
  import { BindDefinition } from './BindDefinition.ts';
3
4
  import { ModelDefinition } from './ModelDefinition.ts';
4
5
  import { ChildNodeDefinition, NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
@@ -6,6 +7,7 @@ import { ChildNodeDefinition, NodeDefinition, ParentNodeDefinition } from './Nod
6
7
  export declare class RootDefinition implements NodeDefinition<'root'> {
7
8
  protected readonly form: XFormDefinition;
8
9
  protected readonly model: ModelDefinition;
10
+ readonly classes: BodyClassList;
9
11
  readonly type = "root";
10
12
  readonly bind: BindDefinition;
11
13
  readonly nodeset: string;
@@ -19,7 +21,7 @@ export declare class RootDefinition implements NodeDefinition<'root'> {
19
21
  readonly defaultValue: null;
20
22
  readonly isTranslated = false;
21
23
  readonly dependencyExpressions: ReadonlySet<string>;
22
- constructor(form: XFormDefinition, model: ModelDefinition);
24
+ constructor(form: XFormDefinition, model: ModelDefinition, classes: BodyClassList);
23
25
  buildSubtree(parent: ParentNodeDefinition): readonly ChildNodeDefinition[];
24
26
  toJSON(): Omit<this, "model" | "toJSON" | "form" | "bind" | "root" | "bodyElement" | "buildSubtree">;
25
27
  }
@@ -1,9 +1,9 @@
1
- import { AnyBodyElementDefinition, NonRepeatGroupElementDefinition } from '../body/BodyDefinition.ts';
1
+ import { AnyBodyElementDefinition, AnyGroupElementDefinition } from '../body/BodyDefinition.ts';
2
2
  import { BindDefinition } from './BindDefinition.ts';
3
3
  import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
4
4
  import { ChildNodeDefinition, NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
5
5
 
6
- export declare class SubtreeDefinition extends DescendentNodeDefinition<'subtree', NonRepeatGroupElementDefinition | null> implements NodeDefinition<'subtree'> {
6
+ export declare class SubtreeDefinition extends DescendentNodeDefinition<'subtree', AnyGroupElementDefinition | null> implements NodeDefinition<'subtree'> {
7
7
  readonly node: Element;
8
8
  readonly type = "subtree";
9
9
  readonly nodeName: string;
@@ -0,0 +1,31 @@
1
+ import { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
2
+ import { InputDefinition } from '../body/control/InputDefinition.ts';
3
+ import { ConstantTruthyDependentExpression } from '../expression/DependentExpression.ts';
4
+ import { BindComputation } from '../model/BindComputation.ts';
5
+ import { BindDefinition } from '../model/BindDefinition.ts';
6
+ import { LeafNodeDefinition } from '../model/LeafNodeDefinition.ts';
7
+ import { ParentNodeDefinition } from '../model/NodeDefinition.ts';
8
+ import { HintDefinition } from './text/HintDefinition.ts';
9
+ import { LabelDefinition } from './text/LabelDefinition.ts';
10
+
11
+ export type NoteReadonlyDefinition = BindComputation<'readonly'> & ConstantTruthyDependentExpression;
12
+ export interface NoteBindDefinition extends BindDefinition {
13
+ readonly readonly: NoteReadonlyDefinition;
14
+ }
15
+ export type NoteTextDefinition = LabelDefinition | HintDefinition;
16
+ /**
17
+ * @package This class is used internally, both in static types and at runtime,
18
+ * to guard and guide the distinction between instance state nodes for 'note'
19
+ * and 'string' node types. It is intentionally package-private! The less
20
+ * specific {@link NoteNode.definition} type, if it has any client value at all,
21
+ * should be more than sufficient. Clients are otherwise expected to use other
22
+ * aspects of the node's interface (such as its {@link NoteNode.nodeType} and
23
+ * distinct {@link NoteNode.currentState} types) to handle note-specific logic.
24
+ */
25
+ export declare class NoteNodeDefinition extends LeafNodeDefinition {
26
+ readonly bind: NoteBindDefinition;
27
+ readonly bodyElement: InputDefinition;
28
+ readonly noteTextDefinition: NoteTextDefinition;
29
+ static from(parent: ParentNodeDefinition, bind: BindDefinition, bodyElement: AnyBodyElementDefinition | null, node: Element): NoteNodeDefinition | null;
30
+ constructor(parent: ParentNodeDefinition, bind: NoteBindDefinition, bodyElement: InputDefinition, noteTextDefinition: NoteTextDefinition, node: Element);
31
+ }
@@ -0,0 +1,19 @@
1
+ import { RepeatElementDefinition } from '../../body/RepeatElementDefinition.ts';
2
+ import { DependentExpression } from '../../expression/DependentExpression.ts';
3
+
4
+ /**
5
+ * Represents either of these
6
+ * {@link https://getodk.github.io/xforms-spec/#body-attributes | body attributes}:
7
+ *
8
+ * - `jr:count`
9
+ * - `jr:noAddRemove`
10
+ *
11
+ * In both cases, the downstream effect is that the engine is responsible for
12
+ * controlling the count of a repeat range's instances. Representing both cases
13
+ * should simplify client usage, as well as implementation of the internal
14
+ * representation of {@link RepeatRangeControlledNode}.
15
+ */
16
+ export declare class RepeatCountControlExpression extends DependentExpression<'number'> {
17
+ static from(bodyElement: RepeatElementDefinition, initialCount: number): RepeatCountControlExpression | null;
18
+ private constructor();
19
+ }
@@ -0,0 +1,9 @@
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { AnyControlDefinition } from '../../body/control/ControlDefinition.ts';
3
+ import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
4
+
5
+ export declare class HintDefinition extends TextElementDefinition<'hint'> {
6
+ static forElement(form: XFormDefinition, owner: AnyControlDefinition): HintDefinition | null;
7
+ readonly role = "hint";
8
+ private constructor();
9
+ }
@@ -0,0 +1,9 @@
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { ItemDefinition } from '../../body/control/select/ItemDefinition.ts';
3
+ import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
4
+
5
+ export declare class ItemLabelDefinition extends TextElementDefinition<'item-label'> {
6
+ static from(form: XFormDefinition, owner: ItemDefinition): ItemLabelDefinition | null;
7
+ readonly role = "item-label";
8
+ private constructor();
9
+ }
@@ -0,0 +1,13 @@
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { ItemDefinition } from '../../body/control/select/ItemDefinition.ts';
3
+ import { ItemsetDefinition } from '../../body/control/select/ItemsetDefinition.ts';
4
+ import { RefAttributeChunk } from './abstract/TextElementDefinition.ts';
5
+ import { TextRangeDefinition } from './abstract/TextRangeDefinition.ts';
6
+
7
+ export type ItemLabelOwner = ItemDefinition | ItemsetDefinition;
8
+ export declare class ItemsetLabelDefinition extends TextRangeDefinition<'item-label'> {
9
+ static from(form: XFormDefinition, owner: ItemsetDefinition): ItemsetLabelDefinition | null;
10
+ readonly role = "item-label";
11
+ readonly chunks: readonly [RefAttributeChunk];
12
+ private constructor();
13
+ }
@@ -0,0 +1,15 @@
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { AnyGroupElementDefinition } from '../../body/BodyDefinition.ts';
3
+ import { RepeatElementDefinition } from '../../body/RepeatElementDefinition.ts';
4
+ import { AnyControlDefinition } from '../../body/control/ControlDefinition.ts';
5
+ import { BaseGroupDefinition } from '../../body/group/BaseGroupDefinition.ts';
6
+ import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
7
+
8
+ export type LabelOwner = AnyControlDefinition | AnyGroupElementDefinition | RepeatElementDefinition;
9
+ export declare class LabelDefinition extends TextElementDefinition<'label'> {
10
+ static forControl(form: XFormDefinition, control: AnyControlDefinition): LabelDefinition | null;
11
+ static forRepeatGroup(form: XFormDefinition, repeat: RepeatElementDefinition): LabelDefinition | null;
12
+ static forGroup(form: XFormDefinition, group: BaseGroupDefinition<any>): LabelDefinition | null;
13
+ readonly role = "label";
14
+ private constructor();
15
+ }
@@ -0,0 +1,15 @@
1
+ import { BindDefinition } from '../../model/BindDefinition.ts';
2
+ import { StaticTextChunkDefinition } from './StaticTextChunkDefinition.ts';
3
+ import { TranslationChunkDefinition } from './TranslationChunkDefinition.ts';
4
+ import { TextBindAttributeLocalName, TextSourceNode, TextRangeDefinition } from './abstract/TextRangeDefinition.ts';
5
+
6
+ export type MessageSourceNode = TextSourceNode<TextBindAttributeLocalName>;
7
+ type MessageChunk = StaticTextChunkDefinition | TranslationChunkDefinition;
8
+ export declare class MessageDefinition<Type extends TextBindAttributeLocalName> extends TextRangeDefinition<Type> {
9
+ readonly role: Type;
10
+ static from<Type extends TextBindAttributeLocalName>(bind: BindDefinition, type: Type): MessageDefinition<Type> | null;
11
+ readonly chunks: readonly [MessageChunk];
12
+ private constructor();
13
+ }
14
+ export type AnyMessageDefinition = MessageDefinition<TextBindAttributeLocalName>;
15
+ export {};
@@ -0,0 +1,8 @@
1
+ import { TextChunkDefinition } from './abstract/TextChunkDefinition.ts';
2
+ import { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
3
+
4
+ export declare class OutputChunkDefinition extends TextChunkDefinition<'output'> {
5
+ static from(context: AnyTextRangeDefinition, element: Element): OutputChunkDefinition | null;
6
+ readonly source = "output";
7
+ private constructor();
8
+ }
@@ -0,0 +1,8 @@
1
+ import { TextChunkDefinition } from './abstract/TextChunkDefinition.ts';
2
+ import { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
3
+
4
+ export declare class ReferenceChunkDefinition extends TextChunkDefinition<'reference'> {
5
+ static from(context: AnyTextRangeDefinition, refExpression: string): ReferenceChunkDefinition;
6
+ readonly source = "reference";
7
+ private constructor();
8
+ }
@@ -0,0 +1,10 @@
1
+ import { TextChunkDefinition } from './abstract/TextChunkDefinition.ts';
2
+ import { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
3
+
4
+ export type StaticTextChunkSourceNode = Attr | Text;
5
+ export declare class StaticTextChunkDefinition extends TextChunkDefinition<'static'> {
6
+ readonly stringValue: string;
7
+ static from(context: AnyTextRangeDefinition, stringValue: string): StaticTextChunkDefinition;
8
+ readonly source = "static";
9
+ private constructor();
10
+ }
@@ -0,0 +1,9 @@
1
+ import { TextChunkDefinition } from './abstract/TextChunkDefinition.ts';
2
+ import { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
3
+
4
+ export declare class TranslationChunkDefinition extends TextChunkDefinition<'translation'> {
5
+ static fromMessage(context: AnyTextRangeDefinition, maybeExpression: string): TranslationChunkDefinition | null;
6
+ static from(context: AnyTextRangeDefinition, maybeExpression: string): TranslationChunkDefinition | null;
7
+ readonly source = "translation";
8
+ private constructor();
9
+ }
@@ -0,0 +1,18 @@
1
+ import { TextChunkSource } from '../../../client/TextRange.ts';
2
+ import { DependentExpression } from '../../../expression/DependentExpression.ts';
3
+ import { OutputChunkDefinition } from '../OutputChunkDefinition.ts';
4
+ import { ReferenceChunkDefinition } from '../ReferenceChunkDefinition.ts';
5
+ import { StaticTextChunkDefinition } from '../StaticTextChunkDefinition.ts';
6
+ import { TranslationChunkDefinition } from '../TranslationChunkDefinition.ts';
7
+ import { AnyTextRangeDefinition } from './TextRangeDefinition.ts';
8
+
9
+ interface TextChunkDefinitionOptions {
10
+ readonly isTranslated?: true;
11
+ }
12
+ export declare abstract class TextChunkDefinition<Source extends TextChunkSource> extends DependentExpression<'string'> {
13
+ abstract readonly source: Source;
14
+ readonly stringValue?: string;
15
+ constructor(context: AnyTextRangeDefinition, expression: string, options?: TextChunkDefinitionOptions);
16
+ }
17
+ export type AnyTextChunkDefinition = OutputChunkDefinition | ReferenceChunkDefinition | StaticTextChunkDefinition | TranslationChunkDefinition;
18
+ export {};
@@ -0,0 +1,23 @@
1
+ import { XFormDefinition } from '../../../XFormDefinition.ts';
2
+ import { ItemDefinition } from '../../../body/control/select/ItemDefinition.ts';
3
+ import { ElementTextRole } from '../../../client/TextRange.ts';
4
+ import { HintDefinition } from '../HintDefinition.ts';
5
+ import { ItemLabelDefinition } from '../ItemLabelDefinition.ts';
6
+ import { ItemsetLabelDefinition } from '../ItemsetLabelDefinition.ts';
7
+ import { LabelDefinition, LabelOwner } from '../LabelDefinition.ts';
8
+ import { OutputChunkDefinition } from '../OutputChunkDefinition.ts';
9
+ import { ReferenceChunkDefinition } from '../ReferenceChunkDefinition.ts';
10
+ import { StaticTextChunkDefinition } from '../StaticTextChunkDefinition.ts';
11
+ import { TranslationChunkDefinition } from '../TranslationChunkDefinition.ts';
12
+ import { TextSourceNode, TextRangeDefinition } from './TextRangeDefinition.ts';
13
+
14
+ export type RefAttributeChunk = ReferenceChunkDefinition | TranslationChunkDefinition;
15
+ type TextElementChildChunk = OutputChunkDefinition | StaticTextChunkDefinition;
16
+ type TextElementChunks = readonly [RefAttributeChunk] | readonly TextElementChildChunk[];
17
+ type TextElementOwner = ItemDefinition | LabelOwner;
18
+ export declare abstract class TextElementDefinition<Role extends ElementTextRole> extends TextRangeDefinition<Role> {
19
+ readonly chunks: TextElementChunks;
20
+ constructor(form: XFormDefinition, owner: TextElementOwner, sourceNode: TextSourceNode<Role>);
21
+ }
22
+ export type AnyTextElementDefinition = HintDefinition | ItemLabelDefinition | ItemsetLabelDefinition | LabelDefinition;
23
+ export {};
@@ -0,0 +1,35 @@
1
+ import { LocalNamedElement } from '../../../../../common/types/dom.ts';
2
+ import { XFormDefinition } from '../../../XFormDefinition.ts';
3
+ import { TextRole } from '../../../client/TextRange.ts';
4
+ import { DependencyContext } from '../../../expression/DependencyContext.ts';
5
+ import { AnyDependentExpression } from '../../../expression/DependentExpression.ts';
6
+ import { AnyMessageDefinition } from '../MessageDefinition.ts';
7
+ import { AnyTextChunkDefinition } from './TextChunkDefinition.ts';
8
+ import { AnyTextElementDefinition } from './TextElementDefinition.ts';
9
+
10
+ export type TextBindAttributeLocalName = 'constraintMsg' | 'requiredMsg';
11
+ export type TextBodyElementLocalName = 'hint' | 'label';
12
+ interface TextSourceNodes {
13
+ readonly constraintMsg: null;
14
+ readonly hint: LocalNamedElement<'hint'>;
15
+ readonly label: LocalNamedElement<'label'>;
16
+ readonly 'item-label': LocalNamedElement<'label'>;
17
+ readonly requiredMsg: null;
18
+ }
19
+ export type TextSourceNode<Type extends TextRole> = TextSourceNodes[Type];
20
+ export declare abstract class TextRangeDefinition<Role extends TextRole> extends DependencyContext {
21
+ readonly form: XFormDefinition;
22
+ readonly ownerContext: DependencyContext;
23
+ readonly sourceNode: TextSourceNode<Role>;
24
+ abstract readonly role: Role;
25
+ readonly parentReference: string | null;
26
+ readonly reference: string | null;
27
+ abstract readonly chunks: readonly AnyTextChunkDefinition[];
28
+ get isTranslated(): boolean;
29
+ set isTranslated(value: true);
30
+ protected constructor(form: XFormDefinition, ownerContext: DependencyContext, sourceNode: TextSourceNode<Role>);
31
+ registerDependentExpression(expression: AnyDependentExpression): void;
32
+ toJSON(): object;
33
+ }
34
+ export type AnyTextRangeDefinition = AnyMessageDefinition | AnyTextElementDefinition;
35
+ export {};
@@ -0,0 +1,40 @@
1
+ export interface PathResolutionOptions {
2
+ /**
3
+ * Excludes direct references to the nodeset specified as a context. This flag
4
+ * has earlier precedent as `ignoreContextReference` in similar internal APIs.
5
+ * The intent, in part, is to allow for certain in-spec exceptions to cycle
6
+ * analysis (which we previously did explicitly, and foresee reintroducing in
7
+ * some form relatively soon). As such, the default for this flag should be
8
+ * overridden when a computation is (A) not among the core `<bind>`
9
+ * computations or (B) is a computation which is explicitly expected to have
10
+ * self-references (such as `constraint`).
11
+ *
12
+ * @default false
13
+ *
14
+ * @todo It is highly likely we will eliminate this in the future. We
15
+ * considered removing its precursor (and existing code now referencing this)
16
+ * in {@link https://github.com/getodk/web-forms/pull/67}, but ran into issues
17
+ * with some of the reactive logic introduced there. It's likely that
18
+ * subsequent improvements have addressed those issues, but it's also likely
19
+ * that we will want similar special casing when we reintroduce explicit graph
20
+ * cycle analysis.
21
+ */
22
+ readonly ignoreReferenceToContextPath?: boolean;
23
+ }
24
+ /**
25
+ * Resolves XPath paths referenced by an arbitrary expression to XForms
26
+ * `nodeset` references:
27
+ *
28
+ * 1. The provided {@link expression} is analyzed to find path sub-expressions
29
+ * (LocationPaths, sub-expressions with a node-set producing FilterExpr).
30
+ *
31
+ * 2. When a {@link contextNodeset} is available, each sub-expression is
32
+ * resolved to that context. See {@link resolvePath} for additional
33
+ * detail.
34
+ *
35
+ * 3. Once resolved, each dependency path is further analyzed to identify
36
+ * sub-expressions in any of its predicates, resolving each to their
37
+ * respective predicates' Steps. See {@link resolvePredicateReference} for
38
+ * additional detail.
39
+ */
40
+ export declare const resolveDependencyNodesets: (contextNodeset: string | null, expression: string, options?: PathResolutionOptions) => readonly string[];
@@ -0,0 +1,70 @@
1
+ import { AbsoluteRootLocationPathNode, FilterExprNode, RelativeStepSyntaxLiteralNode, StepNode } from '@getodk/xpath/static/grammar/SyntaxNode.js';
2
+ import { PathExpressionNode } from './semantic-analysis.ts';
3
+
4
+ type AbsolutePathHead =
5
+ /** / - as first character in LocationPath */
6
+ AbsoluteRootLocationPathNode
7
+ /** // - as first characters in LocationPath */
8
+ | RelativeStepSyntaxLiteralNode;
9
+ /**
10
+ * fn(...args) - as first (and potentially only) part of a path expression,
11
+ * where the function is either known to produce a node-set result, or where
12
+ * other aspects of the exression's syntax are inherently node-set producing.
13
+ */
14
+ type FilterPathExprHead = FilterExprNode;
15
+ type StepLikeNode =
16
+ /** // - shorthand for `/descendant-or-self::node()/` */
17
+ RelativeStepSyntaxLiteralNode
18
+ /** Any _actual_ Step in a LocationPath */
19
+ | StepNode;
20
+ type PathNodeListHead = AbsolutePathHead | FilterPathExprHead | StepLikeNode;
21
+ /**
22
+ * A path node list is a semi-flattened representation of...
23
+ *
24
+ * - Any XPath LocationPath expression:
25
+ * - AbsoluteLocationPath
26
+ * - RelativeLocationPath
27
+ *
28
+ * - Any expression beginning with a FilterExpr which is known to produce a
29
+ * node-set result
30
+ *
31
+ * The flattening of these syntax representations is used to perform various
32
+ * aspects of path resolution logic, accounting for complexities of XPath syntax
33
+ * and semantics in a roughly linear/list processing manner.
34
+ */
35
+ export type PathNodeList<Head extends PathNodeListHead = PathNodeListHead> = readonly [
36
+ head: Head,
37
+ ...tail: StepLikeNode[]
38
+ ];
39
+ export declare const resolvePath: (contextNode: PathExpressionNode | null, pathNode: PathExpressionNode) => PathNodeList;
40
+ /**
41
+ * Resolves the parsed path {@link predicatePathNode}, in the context of:
42
+ *
43
+ * - The {@link contextNode} context, representing the original expression's
44
+ * context (if one was available)
45
+ *
46
+ * - The {@link stepContextNodes} context, representing the cumulative portion
47
+ * of the source path where {@link predicatePathNode} was parsed from a
48
+ * Predicate sub-expression
49
+ *
50
+ * Both contexts are necessary for resolution to ensure that:
51
+ *
52
+ * - A `current()` call within the predicate's sub-expression is contextualized
53
+ * to the current `nodeset` reference associated with the original expression
54
+ *
55
+ * - A `.` self-reference within the predicate's sub-expression is
56
+ * contextualized to the Step in which it occurred
57
+ */
58
+ export declare const resolvePredicateReference: (contextNode: PathExpressionNode | null, stepContextNodes: PathNodeList, predicatePathNode: PathExpressionNode) => PathNodeList;
59
+ interface PathSerializationOptions {
60
+ /**
61
+ * @default false
62
+ */
63
+ readonly stripPredicates: boolean;
64
+ }
65
+ /**
66
+ * Serializes a resolved {@link PathNodeList} to its XPath expression
67
+ * representation, optionally stripping predicates.
68
+ */
69
+ export declare const serializeNodesetReference: (nodes: PathNodeList, options: PathSerializationOptions) => string;
70
+ export {};
@@ -0,0 +1,30 @@
1
+ import { PathNodeList } from './path-resolution.ts';
2
+ import { PathExpressionNode } from './semantic-analysis.ts';
3
+
4
+ /**
5
+ * Represents a pair of:
6
+ *
7
+ * - Path expression syntax referenced within a particular predicate, on any
8
+ * Step within a source LocationPath and/or FilterExpr path. This
9
+ * sub-expression is resolved as a member of the dependencies which may be
10
+ * referenced by any arbitrary form expression.
11
+ *
12
+ * - The cumulative set of path nodes, from the start of the source path
13
+ * expression, to the Step and Predicate where the sub-expression reference
14
+ * was identified. This representation is used as **part** of the context used
15
+ * to resolve the identified Predicate sub-expression for downstream
16
+ * dependency subscriptions. (Each predicate sub-expression is **further
17
+ * contextualized** by the original context in which the source path is
18
+ * defined.)
19
+ */
20
+ export interface PredicateReference {
21
+ readonly predicatePathNode: PathExpressionNode;
22
+ readonly stepContextNodes: PathNodeList;
23
+ }
24
+ /**
25
+ * Identifies path sub-expressions within any of a path's Predicates, along with
26
+ * the step context in which they are found.
27
+ *
28
+ * @see {@link PredicateReference} for details on the produced structures.
29
+ */
30
+ export declare const findPredicateReferences: (pathNodes: PathNodeList) => readonly PredicateReference[];
@@ -0,0 +1,18 @@
1
+ import { PartiallyKnownString } from '../../../../common/types/string/PartiallyKnownString.ts';
2
+
3
+ interface ReferenceParsingContext {
4
+ readonly reference: string | null;
5
+ readonly parent?: ReferenceParsingContext | null;
6
+ }
7
+ type ReferenceAttributeName = PartiallyKnownString<'nodeset' | 'ref'>;
8
+ interface KnownAttributeElement<AttributeName extends string> extends Element {
9
+ getAttribute(name: AttributeName): string;
10
+ getAttribute(name: string): string | null;
11
+ }
12
+ type ParsedReferenceAttribute<T extends Element, AttributeName extends string> = T extends KnownAttributeElement<AttributeName> ? string : string | null;
13
+ /**
14
+ * Parses a `nodeset` reference from an arbitrary form definition element, and
15
+ * resolves that (potentially relative) reference to the provided context.
16
+ */
17
+ export declare const parseNodesetReference: <const AttributeName extends ReferenceAttributeName, T extends Element | KnownAttributeElement<AttributeName>>(parentContext: ReferenceParsingContext, element: T, attributeName: AttributeName) => ParsedReferenceAttribute<T, AttributeName>;
18
+ export {};