@getodk/xforms-engine 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/dist/client/BaseNode.d.ts +69 -4
  2. package/dist/client/EngineConfig.d.ts +0 -1
  3. package/dist/client/GroupNode.d.ts +4 -3
  4. package/dist/client/ModelValueNode.d.ts +36 -0
  5. package/dist/client/NodeAppearances.d.ts +1 -2
  6. package/dist/client/NoteNode.d.ts +52 -0
  7. package/dist/client/RootNode.d.ts +4 -3
  8. package/dist/client/SelectNode.d.ts +6 -5
  9. package/dist/client/StringNode.d.ts +6 -5
  10. package/dist/client/SubtreeNode.d.ts +3 -2
  11. package/dist/client/TextRange.d.ts +85 -3
  12. package/dist/client/TriggerNode.d.ts +25 -0
  13. package/dist/client/constants.d.ts +8 -0
  14. package/dist/client/hierarchy.d.ts +19 -10
  15. package/dist/client/index.d.ts +0 -1
  16. package/dist/client/node-types.d.ts +3 -1
  17. package/dist/client/{RepeatRangeNode.d.ts → repeat/BaseRepeatRangeNode.d.ts} +18 -18
  18. package/dist/client/{RepeatInstanceNode.d.ts → repeat/RepeatInstanceNode.d.ts} +9 -9
  19. package/dist/client/repeat/RepeatRangeControlledNode.d.ts +18 -0
  20. package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +19 -0
  21. package/dist/client/unsupported/RangeNode.d.ts +9 -0
  22. package/dist/client/unsupported/RankNode.d.ts +9 -0
  23. package/dist/client/unsupported/UnsupportedControlNode.d.ts +32 -0
  24. package/dist/client/unsupported/UploadNode.d.ts +9 -0
  25. package/dist/client/validation.d.ts +162 -0
  26. package/dist/index.d.ts +14 -6
  27. package/dist/index.js +39696 -36151
  28. package/dist/index.js.map +1 -1
  29. package/dist/instance/Group.d.ts +3 -2
  30. package/dist/instance/ModelValue.d.ts +39 -0
  31. package/dist/instance/Note.d.ts +41 -0
  32. package/dist/instance/Root.d.ts +5 -4
  33. package/dist/instance/SelectField.d.ts +11 -6
  34. package/dist/instance/StringField.d.ts +12 -7
  35. package/dist/instance/Subtree.d.ts +2 -1
  36. package/dist/instance/TriggerControl.d.ts +40 -0
  37. package/dist/instance/abstract/DescendantNode.d.ts +8 -10
  38. package/dist/instance/abstract/InstanceNode.d.ts +3 -2
  39. package/dist/instance/abstract/UnsupportedControl.d.ts +46 -0
  40. package/dist/instance/children.d.ts +0 -1
  41. package/dist/instance/hierarchy.d.ts +15 -6
  42. package/dist/instance/index.d.ts +0 -1
  43. package/dist/instance/internal-api/EvaluationContext.d.ts +0 -1
  44. package/dist/instance/internal-api/InstanceConfig.d.ts +0 -1
  45. package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -1
  46. package/dist/instance/internal-api/TranslationContext.d.ts +0 -1
  47. package/dist/instance/internal-api/ValidationContext.d.ts +28 -0
  48. package/dist/instance/internal-api/ValueContext.d.ts +3 -4
  49. package/dist/instance/{RepeatRange.d.ts → repeat/BaseRepeatRange.d.ts} +46 -46
  50. package/dist/instance/{RepeatInstance.d.ts → repeat/RepeatInstance.d.ts} +13 -13
  51. package/dist/instance/repeat/RepeatRangeControlled.d.ts +15 -0
  52. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +34 -0
  53. package/dist/instance/resource.d.ts +0 -1
  54. package/dist/instance/text/TextChunk.d.ts +0 -1
  55. package/dist/instance/text/TextRange.d.ts +4 -5
  56. package/dist/instance/unsupported/RangeControl.d.ts +4 -0
  57. package/dist/instance/unsupported/RankControl.d.ts +4 -0
  58. package/dist/instance/unsupported/UploadControl.d.ts +4 -0
  59. package/dist/lib/TokenListParser.d.ts +3 -3
  60. package/dist/lib/dom/query.d.ts +1 -2
  61. package/dist/lib/reactivity/createChildrenState.d.ts +0 -1
  62. package/dist/lib/reactivity/createComputedExpression.d.ts +7 -3
  63. package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +4 -0
  64. package/dist/lib/reactivity/createSelectItems.d.ts +0 -1
  65. package/dist/lib/reactivity/createValueState.d.ts +0 -1
  66. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +0 -1
  67. package/dist/lib/reactivity/node-state/createClientState.d.ts +0 -1
  68. package/dist/lib/reactivity/node-state/createCurrentState.d.ts +0 -1
  69. package/dist/lib/reactivity/node-state/createEngineState.d.ts +0 -1
  70. package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +1 -2
  71. package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +0 -1
  72. package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +1 -2
  73. package/dist/lib/reactivity/node-state/representations.d.ts +0 -1
  74. package/dist/lib/reactivity/scope.d.ts +0 -1
  75. package/dist/lib/reactivity/text/createFieldHint.d.ts +3 -4
  76. package/dist/lib/reactivity/text/createNodeLabel.d.ts +3 -4
  77. package/dist/lib/reactivity/text/createNoteText.d.ts +24 -0
  78. package/dist/lib/reactivity/text/createTextRange.d.ts +5 -8
  79. package/dist/lib/reactivity/types.d.ts +0 -1
  80. package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +8 -0
  81. package/dist/lib/reactivity/validation/createValidation.d.ts +17 -0
  82. package/dist/{XFormDOM.d.ts → parse/XFormDOM.d.ts} +1 -2
  83. package/dist/{XFormDataType.d.ts → parse/XFormDataType.d.ts} +2 -4
  84. package/dist/{XFormDefinition.d.ts → parse/XFormDefinition.d.ts} +2 -3
  85. package/dist/{body → parse/body}/BodyDefinition.d.ts +15 -10
  86. package/dist/{body → parse/body}/BodyElementDefinition.d.ts +8 -7
  87. package/dist/{body → parse/body}/RepeatElementDefinition.d.ts +4 -5
  88. package/dist/{body → parse/body}/UnsupportedBodyElementDefinition.d.ts +0 -1
  89. package/dist/{body → parse/body}/appearance/inputAppearanceParser.d.ts +1 -2
  90. package/dist/{body → parse/body}/appearance/selectAppearanceParser.d.ts +1 -2
  91. package/dist/{body → parse/body}/appearance/structureElementAppearanceParser.d.ts +1 -2
  92. package/dist/parse/body/appearance/unknownAppearanceParser.d.ts +3 -0
  93. package/dist/{body → parse/body}/control/ControlDefinition.d.ts +3 -4
  94. package/dist/{body → parse/body}/control/InputDefinition.d.ts +1 -2
  95. package/dist/parse/body/control/RangeControlDefinition.d.ts +11 -0
  96. package/dist/parse/body/control/RankControlDefinition.d.ts +11 -0
  97. package/dist/parse/body/control/TriggerControlDefinition.d.ts +11 -0
  98. package/dist/parse/body/control/UploadControlDefinition.d.ts +11 -0
  99. package/dist/{body → parse/body}/control/select/ItemDefinition.d.ts +3 -4
  100. package/dist/{body → parse/body}/control/select/ItemsetDefinition.d.ts +7 -7
  101. package/dist/{body → parse/body}/control/select/ItemsetNodesetContext.d.ts +2 -3
  102. package/dist/{body → parse/body}/control/select/SelectDefinition.d.ts +3 -12
  103. package/dist/{body → parse/body}/group/BaseGroupDefinition.d.ts +3 -5
  104. package/dist/{body → parse/body}/group/LogicalGroupDefinition.d.ts +0 -1
  105. package/dist/{body → parse/body}/group/PresentationGroupDefinition.d.ts +1 -2
  106. package/dist/{body → parse/body}/group/StructuralGroupDefinition.d.ts +0 -1
  107. package/dist/{model/BindComputation.d.ts → parse/expression/BindComputationExpression.d.ts} +5 -6
  108. package/dist/{body/control/select → parse/expression}/ItemsetNodesetExpression.d.ts +2 -3
  109. package/dist/{body/control/select → parse/expression}/ItemsetValueExpression.d.ts +2 -3
  110. package/dist/parse/expression/RepeatCountControlExpression.d.ts +18 -0
  111. package/dist/parse/expression/TextLiteralExpression.d.ts +9 -0
  112. package/dist/parse/expression/TextOutputExpression.d.ts +7 -0
  113. package/dist/parse/expression/TextReferenceExpression.d.ts +7 -0
  114. package/dist/parse/expression/TextTranslationExpression.d.ts +8 -0
  115. package/dist/{expression → parse/expression/abstract}/DependencyContext.d.ts +0 -1
  116. package/dist/{expression → parse/expression/abstract}/DependentExpression.d.ts +13 -10
  117. package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
  118. package/dist/parse/model/BindDefinition.d.ts +39 -0
  119. package/dist/{model → parse/model}/BindElement.d.ts +1 -0
  120. package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -1
  121. package/dist/{model/ValueNodeDefinition.d.ts → parse/model/LeafNodeDefinition.d.ts} +3 -4
  122. package/dist/{model → parse/model}/ModelBindMap.d.ts +0 -1
  123. package/dist/{model → parse/model}/ModelDefinition.d.ts +1 -2
  124. package/dist/{model → parse/model}/NodeDefinition.d.ts +8 -9
  125. package/dist/parse/model/NoteNodeDefinition.d.ts +30 -0
  126. package/dist/{model → parse/model}/RepeatInstanceDefinition.d.ts +3 -4
  127. package/dist/{model → parse/model}/RepeatRangeDefinition.d.ts +14 -5
  128. package/dist/{model → parse/model}/RepeatTemplateDefinition.d.ts +2 -3
  129. package/dist/{model → parse/model}/RootDefinition.d.ts +2 -3
  130. package/dist/{model → parse/model}/SubtreeDefinition.d.ts +1 -2
  131. package/dist/parse/text/HintDefinition.d.ts +8 -0
  132. package/dist/parse/text/ItemLabelDefinition.d.ts +8 -0
  133. package/dist/parse/text/ItemsetLabelDefinition.d.ts +12 -0
  134. package/dist/parse/text/LabelDefinition.d.ts +14 -0
  135. package/dist/parse/text/MessageDefinition.d.ts +14 -0
  136. package/dist/parse/text/abstract/TextElementDefinition.d.ts +22 -0
  137. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +34 -0
  138. package/dist/parse/xpath/dependency-analysis.d.ts +40 -0
  139. package/dist/parse/xpath/path-resolution.d.ts +69 -0
  140. package/dist/parse/xpath/predicate-analysis.d.ts +29 -0
  141. package/dist/parse/xpath/reference-parsing.d.ts +17 -0
  142. package/dist/parse/xpath/semantic-analysis.d.ts +97 -0
  143. package/dist/parse/xpath/syntax-traversal.d.ts +68 -0
  144. package/dist/solid.js +8745 -5186
  145. package/dist/solid.js.map +1 -1
  146. package/package.json +15 -16
  147. package/src/client/BaseNode.ts +74 -8
  148. package/src/client/GroupNode.ts +4 -2
  149. package/src/client/ModelValueNode.ts +40 -0
  150. package/src/client/NodeAppearances.ts +1 -1
  151. package/src/client/NoteNode.ts +74 -0
  152. package/src/client/README.md +1 -0
  153. package/src/client/RootNode.ts +4 -2
  154. package/src/client/SelectNode.ts +6 -4
  155. package/src/client/StringNode.ts +6 -4
  156. package/src/client/SubtreeNode.ts +3 -1
  157. package/src/client/TextRange.ts +98 -2
  158. package/src/client/TriggerNode.ts +29 -0
  159. package/src/client/constants.ts +10 -0
  160. package/src/client/hierarchy.ts +43 -15
  161. package/src/client/node-types.ts +17 -2
  162. package/src/client/{RepeatRangeNode.ts → repeat/BaseRepeatRangeNode.ts} +18 -19
  163. package/src/client/{RepeatInstanceNode.ts → repeat/RepeatInstanceNode.ts} +10 -8
  164. package/src/client/repeat/RepeatRangeControlledNode.ts +20 -0
  165. package/src/client/repeat/RepeatRangeUncontrolledNode.ts +21 -0
  166. package/src/client/unsupported/RangeNode.ts +14 -0
  167. package/src/client/unsupported/RankNode.ts +14 -0
  168. package/src/client/unsupported/UnsupportedControlNode.ts +40 -0
  169. package/src/client/unsupported/UploadNode.ts +14 -0
  170. package/src/client/validation.ts +199 -0
  171. package/src/index.ts +21 -9
  172. package/src/instance/Group.ts +10 -4
  173. package/src/instance/ModelValue.ts +104 -0
  174. package/src/instance/Note.ts +142 -0
  175. package/src/instance/Root.ts +16 -6
  176. package/src/instance/SelectField.ts +29 -7
  177. package/src/instance/StringField.ts +36 -10
  178. package/src/instance/Subtree.ts +9 -3
  179. package/src/instance/TriggerControl.ts +134 -0
  180. package/src/instance/abstract/DescendantNode.ts +9 -10
  181. package/src/instance/abstract/InstanceNode.ts +29 -7
  182. package/src/instance/abstract/UnsupportedControl.ts +151 -0
  183. package/src/instance/children.ts +113 -16
  184. package/src/instance/hierarchy.ts +42 -5
  185. package/src/instance/index.ts +1 -1
  186. package/src/instance/internal-api/EvaluationContext.ts +1 -1
  187. package/src/instance/internal-api/ValidationContext.ts +32 -0
  188. package/src/instance/internal-api/ValueContext.ts +3 -3
  189. package/src/instance/{RepeatRange.ts → repeat/BaseRepeatRange.ts} +114 -99
  190. package/src/instance/{RepeatInstance.ts → repeat/RepeatInstance.ts} +27 -22
  191. package/src/instance/repeat/RepeatRangeControlled.ts +82 -0
  192. package/src/instance/repeat/RepeatRangeUncontrolled.ts +67 -0
  193. package/src/instance/text/TextRange.ts +10 -4
  194. package/src/instance/unsupported/RangeControl.ts +5 -0
  195. package/src/instance/unsupported/RankControl.ts +5 -0
  196. package/src/instance/unsupported/UploadControl.ts +5 -0
  197. package/src/lib/TokenListParser.ts +11 -7
  198. package/src/lib/dom/query.ts +1 -1
  199. package/src/lib/reactivity/createComputedExpression.ts +25 -27
  200. package/src/lib/reactivity/createNoteReadonlyThunk.ts +33 -0
  201. package/src/lib/reactivity/createSelectItems.ts +23 -16
  202. package/src/lib/reactivity/createValueState.ts +3 -3
  203. package/src/lib/reactivity/node-state/createSharedNodeState.ts +1 -1
  204. package/src/lib/reactivity/node-state/createSpecifiedState.ts +1 -1
  205. package/src/lib/reactivity/text/createFieldHint.ts +9 -7
  206. package/src/lib/reactivity/text/createNodeLabel.ts +8 -6
  207. package/src/lib/reactivity/text/createNoteText.ts +72 -0
  208. package/src/lib/reactivity/text/createTextRange.ts +17 -90
  209. package/src/lib/reactivity/validation/createAggregatedViolations.ts +75 -0
  210. package/src/lib/reactivity/validation/createValidation.ts +196 -0
  211. package/src/{XFormDataType.ts → parse/XFormDataType.ts} +1 -3
  212. package/src/{XFormDefinition.ts → parse/XFormDefinition.ts} +2 -2
  213. package/src/{body → parse/body}/BodyDefinition.ts +44 -27
  214. package/src/{body → parse/body}/BodyElementDefinition.ts +13 -6
  215. package/src/{body → parse/body}/RepeatElementDefinition.ts +10 -20
  216. package/src/{body → parse/body}/appearance/inputAppearanceParser.ts +1 -1
  217. package/src/{body → parse/body}/appearance/selectAppearanceParser.ts +1 -1
  218. package/src/{body → parse/body}/appearance/structureElementAppearanceParser.ts +1 -1
  219. package/src/parse/body/appearance/unknownAppearanceParser.ts +5 -0
  220. package/src/{body → parse/body}/control/ControlDefinition.ts +5 -4
  221. package/src/parse/body/control/RangeControlDefinition.ts +26 -0
  222. package/src/parse/body/control/RankControlDefinition.ts +27 -0
  223. package/src/parse/body/control/TriggerControlDefinition.ts +26 -0
  224. package/src/parse/body/control/UploadControlDefinition.ts +26 -0
  225. package/src/{body → parse/body}/control/select/ItemDefinition.ts +4 -4
  226. package/src/parse/body/control/select/ItemsetDefinition.ts +53 -0
  227. package/src/{body → parse/body}/control/select/ItemsetNodesetContext.ts +2 -2
  228. package/src/{body → parse/body}/control/select/SelectDefinition.ts +3 -11
  229. package/src/{body → parse/body}/group/BaseGroupDefinition.ts +11 -21
  230. package/src/{body → parse/body}/group/PresentationGroupDefinition.ts +1 -1
  231. package/src/{model/BindComputation.ts → parse/expression/BindComputationExpression.ts} +8 -12
  232. package/src/parse/expression/ItemsetNodesetExpression.ts +8 -0
  233. package/src/{body/control/select → parse/expression}/ItemsetValueExpression.ts +2 -2
  234. package/src/parse/expression/RepeatCountControlExpression.ts +44 -0
  235. package/src/parse/expression/TextLiteralExpression.ts +19 -0
  236. package/src/parse/expression/TextOutputExpression.ts +25 -0
  237. package/src/parse/expression/TextReferenceExpression.ts +14 -0
  238. package/src/parse/expression/TextTranslationExpression.ts +38 -0
  239. package/src/{expression → parse/expression/abstract}/DependentExpression.ts +46 -28
  240. package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
  241. package/src/{model → parse/model}/BindDefinition.ts +30 -27
  242. package/src/{model → parse/model}/BindElement.ts +1 -0
  243. package/src/{model/ValueNodeDefinition.ts → parse/model/LeafNodeDefinition.ts} +4 -4
  244. package/src/{model → parse/model}/ModelBindMap.ts +4 -0
  245. package/src/{model → parse/model}/NodeDefinition.ts +12 -12
  246. package/src/parse/model/NoteNodeDefinition.ts +70 -0
  247. package/src/{model → parse/model}/RepeatInstanceDefinition.ts +2 -2
  248. package/src/parse/model/RepeatRangeDefinition.ts +94 -0
  249. package/src/{model → parse/model}/RootDefinition.ts +8 -4
  250. package/src/parse/text/HintDefinition.ts +25 -0
  251. package/src/parse/text/ItemLabelDefinition.ts +25 -0
  252. package/src/parse/text/ItemsetLabelDefinition.ts +44 -0
  253. package/src/parse/text/LabelDefinition.ts +61 -0
  254. package/src/parse/text/MessageDefinition.ts +49 -0
  255. package/src/parse/text/abstract/TextElementDefinition.ts +71 -0
  256. package/src/parse/text/abstract/TextRangeDefinition.ts +70 -0
  257. package/src/parse/xpath/dependency-analysis.ts +105 -0
  258. package/src/parse/xpath/path-resolution.ts +475 -0
  259. package/src/parse/xpath/predicate-analysis.ts +61 -0
  260. package/src/parse/xpath/reference-parsing.ts +90 -0
  261. package/src/parse/xpath/semantic-analysis.ts +466 -0
  262. package/src/parse/xpath/syntax-traversal.ts +129 -0
  263. package/dist/body/text/HintDefinition.d.ts +0 -11
  264. package/dist/body/text/LabelDefinition.d.ts +0 -22
  265. package/dist/body/text/TextElementDefinition.d.ts +0 -33
  266. package/dist/body/text/TextElementOutputPart.d.ts +0 -13
  267. package/dist/body/text/TextElementPart.d.ts +0 -13
  268. package/dist/body/text/TextElementReferencePart.d.ts +0 -7
  269. package/dist/body/text/TextElementStaticPart.d.ts +0 -7
  270. package/dist/lib/xpath/analysis.d.ts +0 -23
  271. package/dist/model/BindDefinition.d.ts +0 -32
  272. package/src/body/control/select/ItemsetDefinition.ts +0 -36
  273. package/src/body/control/select/ItemsetNodesetExpression.ts +0 -8
  274. package/src/body/text/HintDefinition.ts +0 -26
  275. package/src/body/text/LabelDefinition.ts +0 -68
  276. package/src/body/text/TextElementDefinition.ts +0 -97
  277. package/src/body/text/TextElementOutputPart.ts +0 -27
  278. package/src/body/text/TextElementPart.ts +0 -31
  279. package/src/body/text/TextElementReferencePart.ts +0 -21
  280. package/src/body/text/TextElementStaticPart.ts +0 -26
  281. package/src/lib/xpath/analysis.ts +0 -241
  282. package/src/model/RepeatRangeDefinition.ts +0 -53
  283. package/src/{XFormDOM.ts → parse/XFormDOM.ts} +0 -0
  284. package/src/{body → parse/body}/UnsupportedBodyElementDefinition.ts +0 -0
  285. package/src/{body → parse/body}/control/InputDefinition.ts +1 -1
  286. /package/src/{body → parse/body}/group/LogicalGroupDefinition.ts +0 -0
  287. /package/src/{body → parse/body}/group/StructuralGroupDefinition.ts +0 -0
  288. /package/src/{expression → parse/expression/abstract}/DependencyContext.ts +0 -0
  289. /package/src/{model → parse/model}/DescendentNodeDefinition.ts +0 -0
  290. /package/src/{model → parse/model}/ModelDefinition.ts +0 -0
  291. /package/src/{model → parse/model}/RepeatTemplateDefinition.ts +0 -0
  292. /package/src/{model → parse/model}/SubtreeDefinition.ts +0 -0
@@ -2,14 +2,13 @@ import { AnyBodyElementDefinition, ControlElementDefinition } from '../body/Body
2
2
  import { BindDefinition } from './BindDefinition.ts';
3
3
  import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
4
4
  import { NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
5
-
6
- export declare class ValueNodeDefinition extends DescendentNodeDefinition<'value-node', ControlElementDefinition | null> implements NodeDefinition<'value-node'> {
5
+ export declare class LeafNodeDefinition extends DescendentNodeDefinition<'leaf-node', ControlElementDefinition | null> implements NodeDefinition<'leaf-node'> {
7
6
  readonly node: Element;
8
- readonly type = "value-node";
7
+ readonly type = "leaf-node";
9
8
  readonly nodeName: string;
10
9
  readonly children: null;
11
10
  readonly instances: null;
12
11
  readonly defaultValue: string;
13
12
  constructor(parent: ParentNodeDefinition, bind: BindDefinition, bodyElement: AnyBodyElementDefinition | null, node: Element);
14
- toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement">;
13
+ toJSON(): Omit<this, "parent" | "toJSON" | "bind" | "root" | "bodyElement">;
15
14
  }
@@ -2,7 +2,6 @@ import { XFormDefinition } from '../XFormDefinition.ts';
2
2
  import { BindDefinition } from './BindDefinition.ts';
3
3
  import { BindNodeset } from './BindElement.ts';
4
4
  import { ModelDefinition } from './ModelDefinition.ts';
5
-
6
5
  type TopologicalSortIndex = number;
7
6
  export type SortedNodesetIndexes = ReadonlyMap<BindNodeset, TopologicalSortIndex>;
8
7
  export declare class ModelBindMap extends Map<BindNodeset, BindDefinition> {
@@ -1,11 +1,10 @@
1
1
  import { XFormDefinition } from '../XFormDefinition.ts';
2
2
  import { ModelBindMap } from './ModelBindMap.ts';
3
3
  import { RootDefinition } from './RootDefinition.ts';
4
-
5
4
  export declare class ModelDefinition {
6
5
  readonly form: XFormDefinition;
7
6
  readonly binds: ModelBindMap;
8
7
  readonly root: RootDefinition;
9
8
  constructor(form: XFormDefinition);
10
- toJSON(): Omit<this, "toJSON" | "form">;
9
+ toJSON(): Omit<this, "form" | "toJSON">;
11
10
  }
@@ -1,13 +1,12 @@
1
1
  import { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
2
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 { RepeatRangeDefinition } from './RepeatRangeDefinition.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
-
11
10
  /**
12
11
  * Corresponds to the model/entry DOM root node, i.e.:
13
12
  *
@@ -44,16 +43,16 @@ export type SubtreeNodeType = 'subtree';
44
43
  * - An element with no child elements
45
44
  * - Any attribute corresponding to a bind's `nodeset` expression
46
45
  */
47
- export type ValueNodeType = 'value-node';
48
- export type NodeDefinitionType = RootNodeType | RepeatRangeType | RepeatTemplateType | RepeatInstanceType | SubtreeNodeType | ValueNodeType;
46
+ export type LeafNodeType = 'leaf-node';
47
+ export type NodeDefinitionType = RootNodeType | RepeatRangeType | RepeatTemplateType | RepeatInstanceType | SubtreeNodeType | LeafNodeType;
49
48
  export type ParentNodeDefinition = RootDefinition | RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition;
50
- export type ChildNodeDefinition = RepeatRangeDefinition | SubtreeDefinition | ValueNodeDefinition;
51
- export type ChildNodeInstanceDefinition = RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition | ValueNodeDefinition;
49
+ export type ChildNodeDefinition = AnyRepeatRangeDefinition | LeafNodeDefinition | SubtreeDefinition;
50
+ export type ChildNodeInstanceDefinition = RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition | LeafNodeDefinition;
52
51
  export type NodeChildren<Type extends NodeDefinitionType> = Type extends ParentNodeDefinition['type'] ? readonly ChildNodeDefinition[] : null;
53
52
  export type NodeInstances<Type extends NodeDefinitionType> = Type extends 'repeat-range' ? readonly RepeatInstanceDefinition[] : null;
54
53
  export type NodeParent<Type extends NodeDefinitionType> = Type extends ChildNodeDefinition['type'] | ChildNodeInstanceDefinition['type'] ? ParentNodeDefinition : null;
55
54
  export type ModelNode<Type extends NodeDefinitionType> = Type extends 'repeat-range' ? null : Element;
56
- export type NodeDefaultValue<Type extends NodeDefinitionType> = Type extends 'value-node' ? string : null;
55
+ export type NodeDefaultValue<Type extends NodeDefinitionType> = Type extends 'leaf-node' ? string : null;
57
56
  export interface NodeDefinition<Type extends NodeDefinitionType> {
58
57
  readonly type: Type;
59
58
  readonly bind: BindDefinition;
@@ -69,7 +68,7 @@ export interface NodeDefinition<Type extends NodeDefinitionType> {
69
68
  readonly node: ModelNode<Type>;
70
69
  readonly defaultValue: NodeDefaultValue<Type>;
71
70
  }
72
- export type AnyNodeDefinition = RootDefinition | RepeatRangeDefinition | RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition | ValueNodeDefinition;
71
+ export type AnyNodeDefinition = RootDefinition | AnyRepeatRangeDefinition | RepeatTemplateDefinition | RepeatInstanceDefinition | SubtreeDefinition | LeafNodeDefinition;
73
72
  export type TypedNodeDefinition<Type> = Extract<AnyNodeDefinition, {
74
73
  readonly type: Type;
75
74
  }>;
@@ -0,0 +1,30 @@
1
+ import { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
2
+ import { InputDefinition } from '../body/control/InputDefinition.ts';
3
+ import { BindComputationExpression } from '../expression/BindComputationExpression.ts';
4
+ import { ConstantTruthyDependentExpression } from '../expression/abstract/DependentExpression.ts';
5
+ import { HintDefinition } from '../text/HintDefinition.ts';
6
+ import { LabelDefinition } from '../text/LabelDefinition.ts';
7
+ import { BindDefinition } from './BindDefinition.ts';
8
+ import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
9
+ import { ParentNodeDefinition } from './NodeDefinition.ts';
10
+ export type NoteReadonlyDefinition = BindComputationExpression<'readonly'> & ConstantTruthyDependentExpression;
11
+ export interface NoteBindDefinition extends BindDefinition {
12
+ readonly readonly: NoteReadonlyDefinition;
13
+ }
14
+ export type NoteTextDefinition = LabelDefinition | HintDefinition;
15
+ /**
16
+ * @package This class is used internally, both in static types and at runtime,
17
+ * to guard and guide the distinction between instance state nodes for 'note'
18
+ * and 'string' node types. It is intentionally package-private! The less
19
+ * specific {@link NoteNode.definition} type, if it has any client value at all,
20
+ * should be more than sufficient. Clients are otherwise expected to use other
21
+ * aspects of the node's interface (such as its {@link NoteNode.nodeType} and
22
+ * distinct {@link NoteNode.currentState} types) to handle note-specific logic.
23
+ */
24
+ export declare class NoteNodeDefinition extends LeafNodeDefinition {
25
+ readonly bind: NoteBindDefinition;
26
+ readonly bodyElement: InputDefinition;
27
+ readonly noteTextDefinition: NoteTextDefinition;
28
+ static from(parent: ParentNodeDefinition, bind: BindDefinition, bodyElement: AnyBodyElementDefinition | null, node: Element): NoteNodeDefinition | null;
29
+ constructor(parent: ParentNodeDefinition, bind: NoteBindDefinition, bodyElement: InputDefinition, noteTextDefinition: NoteTextDefinition, node: Element);
30
+ }
@@ -1,8 +1,7 @@
1
1
  import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
2
2
  import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
3
3
  import { ChildNodeDefinition, NodeDefinition } from './NodeDefinition.ts';
4
- import { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
5
-
4
+ import { AnyRepeatRangeDefinition } from './RepeatRangeDefinition.ts';
6
5
  export declare class RepeatInstanceDefinition extends DescendentNodeDefinition<'repeat-instance', RepeatElementDefinition> implements NodeDefinition<'repeat-instance'> {
7
6
  readonly node: Element;
8
7
  readonly type = "repeat-instance";
@@ -10,6 +9,6 @@ export declare class RepeatInstanceDefinition extends DescendentNodeDefinition<'
10
9
  readonly children: readonly ChildNodeDefinition[];
11
10
  readonly instances: null;
12
11
  readonly defaultValue: null;
13
- constructor(range: RepeatRangeDefinition, node: Element);
14
- toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement">;
12
+ constructor(range: AnyRepeatRangeDefinition, node: Element);
13
+ toJSON(): Omit<this, "parent" | "toJSON" | "bind" | "root" | "bodyElement">;
15
14
  }
@@ -1,20 +1,29 @@
1
1
  import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
2
+ import { RepeatCountControlExpression } from '../expression/RepeatCountControlExpression.ts';
2
3
  import { BindDefinition } from './BindDefinition.ts';
3
4
  import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
4
5
  import { NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
5
6
  import { RepeatInstanceDefinition } from './RepeatInstanceDefinition.ts';
6
7
  import { RepeatTemplateDefinition } from './RepeatTemplateDefinition.ts';
7
-
8
+ export interface ControlledRepeatRangeDefinition extends RepeatRangeDefinition {
9
+ readonly count: RepeatCountControlExpression;
10
+ }
11
+ export interface UncontrolledRepeatRangeDefinition extends RepeatRangeDefinition {
12
+ readonly count: null;
13
+ }
14
+ export type AnyRepeatRangeDefinition = ControlledRepeatRangeDefinition | UncontrolledRepeatRangeDefinition;
8
15
  export declare class RepeatRangeDefinition extends DescendentNodeDefinition<'repeat-range', RepeatElementDefinition> implements NodeDefinition<'repeat-range'> {
9
- static createTemplateElement(instanceElement: Element): Element;
10
- static createInstanceElement(templateElement: Element): Element;
16
+ static from(parent: ParentNodeDefinition, bind: BindDefinition, bodyElement: RepeatElementDefinition, modelNodes: readonly [Element, ...Element[]]): AnyRepeatRangeDefinition;
11
17
  readonly type = "repeat-range";
12
18
  readonly template: RepeatTemplateDefinition;
13
19
  readonly children: null;
14
20
  readonly instances: RepeatInstanceDefinition[];
21
+ readonly count: RepeatCountControlExpression | null;
15
22
  readonly node: null;
16
23
  readonly nodeName: string;
17
24
  readonly defaultValue: null;
18
- constructor(parent: ParentNodeDefinition, bind: BindDefinition, bodyElement: RepeatElementDefinition, modelNodes: readonly [Element, ...Element[]]);
19
- toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement">;
25
+ private constructor();
26
+ isControlled(): this is ControlledRepeatRangeDefinition;
27
+ isUncontrolled(): this is UncontrolledRepeatRangeDefinition;
28
+ toJSON(): Omit<this, "parent" | "toJSON" | "bind" | "root" | "bodyElement" | "isControlled" | "isUncontrolled">;
20
29
  }
@@ -1,9 +1,8 @@
1
- import { JAVAROSA_NAMESPACE_URI } from '../../../common/src/constants/xmlns.ts';
1
+ import { JAVAROSA_NAMESPACE_URI } from '../../../../common/src/constants/xmlns.ts';
2
2
  import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
3
3
  import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
4
4
  import { ChildNodeDefinition, NodeDefinition } from './NodeDefinition.ts';
5
5
  import { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
6
-
7
6
  interface ExplicitRepeatTemplateElement extends Element {
8
7
  getAttributeNS(namespaceURI: typeof JAVAROSA_NAMESPACE_URI, name: 'template'): string;
9
8
  getAttributeNS(namespaceURI: string | null, name: string): string | null;
@@ -24,6 +23,6 @@ export declare class RepeatTemplateDefinition extends DescendentNodeDefinition<'
24
23
  readonly instances: null;
25
24
  readonly defaultValue: null;
26
25
  protected constructor(range: RepeatRangeDefinition, templateNode: ExplicitRepeatTemplateElement);
27
- toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement">;
26
+ toJSON(): Omit<this, "parent" | "toJSON" | "bind" | "root" | "bodyElement">;
28
27
  }
29
28
  export {};
@@ -1,9 +1,8 @@
1
- import { XFormDefinition } from '../XFormDefinition.ts';
2
1
  import { BodyClassList } from '../body/BodyDefinition.ts';
2
+ import { XFormDefinition } from '../XFormDefinition.ts';
3
3
  import { BindDefinition } from './BindDefinition.ts';
4
4
  import { ModelDefinition } from './ModelDefinition.ts';
5
5
  import { ChildNodeDefinition, NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
6
-
7
6
  export declare class RootDefinition implements NodeDefinition<'root'> {
8
7
  protected readonly form: XFormDefinition;
9
8
  protected readonly model: ModelDefinition;
@@ -23,5 +22,5 @@ export declare class RootDefinition implements NodeDefinition<'root'> {
23
22
  readonly dependencyExpressions: ReadonlySet<string>;
24
23
  constructor(form: XFormDefinition, model: ModelDefinition, classes: BodyClassList);
25
24
  buildSubtree(parent: ParentNodeDefinition): readonly ChildNodeDefinition[];
26
- toJSON(): Omit<this, "model" | "toJSON" | "form" | "bind" | "root" | "bodyElement" | "buildSubtree">;
25
+ toJSON(): Omit<this, "form" | "toJSON" | "bind" | "model" | "root" | "bodyElement" | "buildSubtree">;
27
26
  }
@@ -2,7 +2,6 @@ import { AnyBodyElementDefinition, AnyGroupElementDefinition } from '../body/Bod
2
2
  import { BindDefinition } from './BindDefinition.ts';
3
3
  import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
4
4
  import { ChildNodeDefinition, NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
5
-
6
5
  export declare class SubtreeDefinition extends DescendentNodeDefinition<'subtree', AnyGroupElementDefinition | null> implements NodeDefinition<'subtree'> {
7
6
  readonly node: Element;
8
7
  readonly type = "subtree";
@@ -11,5 +10,5 @@ export declare class SubtreeDefinition extends DescendentNodeDefinition<'subtree
11
10
  readonly instances: null;
12
11
  readonly defaultValue: null;
13
12
  constructor(parent: ParentNodeDefinition, bind: BindDefinition, bodyElement: AnyBodyElementDefinition | null, node: Element);
14
- toJSON(): Omit<this, "toJSON" | "parent" | "bind" | "root" | "bodyElement">;
13
+ toJSON(): Omit<this, "parent" | "toJSON" | "bind" | "root" | "bodyElement">;
15
14
  }
@@ -0,0 +1,8 @@
1
+ import { XFormDefinition } from '../../parse/XFormDefinition.ts';
2
+ import { AnyControlDefinition } from '../body/control/ControlDefinition.ts';
3
+ import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
4
+ export declare class HintDefinition extends TextElementDefinition<'hint'> {
5
+ static forElement(form: XFormDefinition, owner: AnyControlDefinition): HintDefinition | null;
6
+ readonly role = "hint";
7
+ private constructor();
8
+ }
@@ -0,0 +1,8 @@
1
+ import { XFormDefinition } from '../../parse/XFormDefinition.ts';
2
+ import { ItemDefinition } from '../body/control/select/ItemDefinition.ts';
3
+ import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
4
+ export declare class ItemLabelDefinition extends TextElementDefinition<'item-label'> {
5
+ static from(form: XFormDefinition, owner: ItemDefinition): ItemLabelDefinition | null;
6
+ readonly role = "item-label";
7
+ private constructor();
8
+ }
@@ -0,0 +1,12 @@
1
+ import { XFormDefinition } from '../../parse/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
+ export type ItemLabelOwner = ItemDefinition | ItemsetDefinition;
7
+ export declare class ItemsetLabelDefinition extends TextRangeDefinition<'item-label'> {
8
+ static from(form: XFormDefinition, owner: ItemsetDefinition): ItemsetLabelDefinition | null;
9
+ readonly role = "item-label";
10
+ readonly chunks: readonly [RefAttributeChunk];
11
+ private constructor();
12
+ }
@@ -0,0 +1,14 @@
1
+ import { XFormDefinition } from '../../parse/XFormDefinition.ts';
2
+ import { AnyGroupElementDefinition } from '../../parse/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
+ export type LabelOwner = AnyControlDefinition | AnyGroupElementDefinition | RepeatElementDefinition;
8
+ export declare class LabelDefinition extends TextElementDefinition<'label'> {
9
+ static forControl(form: XFormDefinition, control: AnyControlDefinition): LabelDefinition | null;
10
+ static forRepeatGroup(form: XFormDefinition, repeat: RepeatElementDefinition): LabelDefinition | null;
11
+ static forGroup(form: XFormDefinition, group: BaseGroupDefinition<any>): LabelDefinition | null;
12
+ readonly role = "label";
13
+ private constructor();
14
+ }
@@ -0,0 +1,14 @@
1
+ import { TextLiteralExpression } from '../expression/TextLiteralExpression.ts';
2
+ import { TextTranslationExpression } from '../expression/TextTranslationExpression.ts';
3
+ import { BindDefinition } from '../model/BindDefinition.ts';
4
+ import { TextBindAttributeLocalName, TextSourceNode, TextRangeDefinition } from './abstract/TextRangeDefinition.ts';
5
+ export type MessageSourceNode = TextSourceNode<TextBindAttributeLocalName>;
6
+ type MessageChunk = TextLiteralExpression | TextTranslationExpression;
7
+ export declare class MessageDefinition<Type extends TextBindAttributeLocalName> extends TextRangeDefinition<Type> {
8
+ readonly role: Type;
9
+ static from<Type extends TextBindAttributeLocalName>(bind: BindDefinition, type: Type): MessageDefinition<Type> | null;
10
+ readonly chunks: readonly [MessageChunk];
11
+ private constructor();
12
+ }
13
+ export type AnyMessageDefinition = MessageDefinition<TextBindAttributeLocalName>;
14
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ElementTextRole } from '../../../client/TextRange.ts';
2
+ import { XFormDefinition } from '../../../parse/XFormDefinition.ts';
3
+ import { ItemDefinition } from '../../body/control/select/ItemDefinition.ts';
4
+ import { TextLiteralExpression } from '../../expression/TextLiteralExpression.ts';
5
+ import { TextOutputExpression } from '../../expression/TextOutputExpression.ts';
6
+ import { TextReferenceExpression } from '../../expression/TextReferenceExpression.ts';
7
+ import { TextTranslationExpression } from '../../expression/TextTranslationExpression.ts';
8
+ import { HintDefinition } from '../HintDefinition.ts';
9
+ import { ItemLabelDefinition } from '../ItemLabelDefinition.ts';
10
+ import { ItemsetLabelDefinition } from '../ItemsetLabelDefinition.ts';
11
+ import { LabelDefinition, LabelOwner } from '../LabelDefinition.ts';
12
+ import { TextSourceNode, TextRangeDefinition } from './TextRangeDefinition.ts';
13
+ export type RefAttributeChunk = TextReferenceExpression | TextTranslationExpression;
14
+ type TextElementChildChunk = TextOutputExpression | TextLiteralExpression;
15
+ type TextElementChunks = readonly [RefAttributeChunk] | readonly TextElementChildChunk[];
16
+ type TextElementOwner = ItemDefinition | LabelOwner;
17
+ export declare abstract class TextElementDefinition<Role extends ElementTextRole> extends TextRangeDefinition<Role> {
18
+ readonly chunks: TextElementChunks;
19
+ constructor(form: XFormDefinition, owner: TextElementOwner, sourceNode: TextSourceNode<Role>);
20
+ }
21
+ export type AnyTextElementDefinition = HintDefinition | ItemLabelDefinition | ItemsetLabelDefinition | LabelDefinition;
22
+ export {};
@@ -0,0 +1,34 @@
1
+ import { LocalNamedElement } from '../../../../../common/types/dom.ts';
2
+ import { TextRole } from '../../../client/TextRange.ts';
3
+ import { XFormDefinition } from '../../../parse/XFormDefinition.ts';
4
+ import { DependencyContext } from '../../expression/abstract/DependencyContext.ts';
5
+ import { AnyDependentExpression } from '../../expression/abstract/DependentExpression.ts';
6
+ import { AnyTextChunkExpression } from '../../expression/abstract/TextChunkExpression.ts';
7
+ import { AnyMessageDefinition } from '../MessageDefinition.ts';
8
+ import { AnyTextElementDefinition } from './TextElementDefinition.ts';
9
+ export type TextBindAttributeLocalName = 'constraintMsg' | 'requiredMsg';
10
+ export type TextBodyElementLocalName = 'hint' | 'label';
11
+ interface TextSourceNodes {
12
+ readonly constraintMsg: null;
13
+ readonly hint: LocalNamedElement<'hint'>;
14
+ readonly label: LocalNamedElement<'label'>;
15
+ readonly 'item-label': LocalNamedElement<'label'>;
16
+ readonly requiredMsg: null;
17
+ }
18
+ export type TextSourceNode<Type extends TextRole> = TextSourceNodes[Type];
19
+ export declare abstract class TextRangeDefinition<Role extends TextRole> extends DependencyContext {
20
+ readonly form: XFormDefinition;
21
+ readonly ownerContext: DependencyContext;
22
+ readonly sourceNode: TextSourceNode<Role>;
23
+ abstract readonly role: Role;
24
+ readonly parentReference: string | null;
25
+ readonly reference: string | null;
26
+ abstract readonly chunks: readonly AnyTextChunkExpression[];
27
+ get isTranslated(): boolean;
28
+ set isTranslated(value: true);
29
+ protected constructor(form: XFormDefinition, ownerContext: DependencyContext, sourceNode: TextSourceNode<Role>);
30
+ registerDependentExpression(expression: AnyDependentExpression): void;
31
+ toJSON(): object;
32
+ }
33
+ export type AnyTextRangeDefinition = AnyMessageDefinition | AnyTextElementDefinition;
34
+ 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,69 @@
1
+ import { AbsoluteRootLocationPathNode, FilterExprNode, RelativeStepSyntaxLiteralNode, StepNode } from '@getodk/xpath/static/grammar/SyntaxNode.js';
2
+ import { PathExpressionNode } from './semantic-analysis.ts';
3
+ type AbsolutePathHead =
4
+ /** / - as first character in LocationPath */
5
+ AbsoluteRootLocationPathNode
6
+ /** // - as first characters in LocationPath */
7
+ | RelativeStepSyntaxLiteralNode;
8
+ /**
9
+ * fn(...args) - as first (and potentially only) part of a path expression,
10
+ * where the function is either known to produce a node-set result, or where
11
+ * other aspects of the exression's syntax are inherently node-set producing.
12
+ */
13
+ type FilterPathExprHead = FilterExprNode;
14
+ type StepLikeNode =
15
+ /** // - shorthand for `/descendant-or-self::node()/` */
16
+ RelativeStepSyntaxLiteralNode
17
+ /** Any _actual_ Step in a LocationPath */
18
+ | StepNode;
19
+ type PathNodeListHead = AbsolutePathHead | FilterPathExprHead | StepLikeNode;
20
+ /**
21
+ * A path node list is a semi-flattened representation of...
22
+ *
23
+ * - Any XPath LocationPath expression:
24
+ * - AbsoluteLocationPath
25
+ * - RelativeLocationPath
26
+ *
27
+ * - Any expression beginning with a FilterExpr which is known to produce a
28
+ * node-set result
29
+ *
30
+ * The flattening of these syntax representations is used to perform various
31
+ * aspects of path resolution logic, accounting for complexities of XPath syntax
32
+ * and semantics in a roughly linear/list processing manner.
33
+ */
34
+ export type PathNodeList<Head extends PathNodeListHead = PathNodeListHead> = readonly [
35
+ head: Head,
36
+ ...tail: StepLikeNode[]
37
+ ];
38
+ export declare const resolvePath: (contextNode: PathExpressionNode | null, pathNode: PathExpressionNode) => PathNodeList;
39
+ /**
40
+ * Resolves the parsed path {@link predicatePathNode}, in the context of:
41
+ *
42
+ * - The {@link contextNode} context, representing the original expression's
43
+ * context (if one was available)
44
+ *
45
+ * - The {@link stepContextNodes} context, representing the cumulative portion
46
+ * of the source path where {@link predicatePathNode} was parsed from a
47
+ * Predicate sub-expression
48
+ *
49
+ * Both contexts are necessary for resolution to ensure that:
50
+ *
51
+ * - A `current()` call within the predicate's sub-expression is contextualized
52
+ * to the current `nodeset` reference associated with the original expression
53
+ *
54
+ * - A `.` self-reference within the predicate's sub-expression is
55
+ * contextualized to the Step in which it occurred
56
+ */
57
+ export declare const resolvePredicateReference: (contextNode: PathExpressionNode | null, stepContextNodes: PathNodeList, predicatePathNode: PathExpressionNode) => PathNodeList;
58
+ interface PathSerializationOptions {
59
+ /**
60
+ * @default false
61
+ */
62
+ readonly stripPredicates: boolean;
63
+ }
64
+ /**
65
+ * Serializes a resolved {@link PathNodeList} to its XPath expression
66
+ * representation, optionally stripping predicates.
67
+ */
68
+ export declare const serializeNodesetReference: (nodes: PathNodeList, options: PathSerializationOptions) => string;
69
+ export {};
@@ -0,0 +1,29 @@
1
+ import { PathNodeList } from './path-resolution.ts';
2
+ import { PathExpressionNode } from './semantic-analysis.ts';
3
+ /**
4
+ * Represents a pair of:
5
+ *
6
+ * - Path expression syntax referenced within a particular predicate, on any
7
+ * Step within a source LocationPath and/or FilterExpr path. This
8
+ * sub-expression is resolved as a member of the dependencies which may be
9
+ * referenced by any arbitrary form expression.
10
+ *
11
+ * - The cumulative set of path nodes, from the start of the source path
12
+ * expression, to the Step and Predicate where the sub-expression reference
13
+ * was identified. This representation is used as **part** of the context used
14
+ * to resolve the identified Predicate sub-expression for downstream
15
+ * dependency subscriptions. (Each predicate sub-expression is **further
16
+ * contextualized** by the original context in which the source path is
17
+ * defined.)
18
+ */
19
+ export interface PredicateReference {
20
+ readonly predicatePathNode: PathExpressionNode;
21
+ readonly stepContextNodes: PathNodeList;
22
+ }
23
+ /**
24
+ * Identifies path sub-expressions within any of a path's Predicates, along with
25
+ * the step context in which they are found.
26
+ *
27
+ * @see {@link PredicateReference} for details on the produced structures.
28
+ */
29
+ export declare const findPredicateReferences: (pathNodes: PathNodeList) => readonly PredicateReference[];
@@ -0,0 +1,17 @@
1
+ import { PartiallyKnownString } from '../../../../common/types/string/PartiallyKnownString.ts';
2
+ interface ReferenceParsingContext {
3
+ readonly reference: string | null;
4
+ readonly parent?: ReferenceParsingContext | null;
5
+ }
6
+ type ReferenceAttributeName = PartiallyKnownString<'nodeset' | 'ref'>;
7
+ interface KnownAttributeElement<AttributeName extends string> extends Element {
8
+ getAttribute(name: AttributeName): string;
9
+ getAttribute(name: string): string | null;
10
+ }
11
+ type ParsedReferenceAttribute<T extends Element, AttributeName extends string> = T extends KnownAttributeElement<AttributeName> ? string : string | null;
12
+ /**
13
+ * Parses a `nodeset` reference from an arbitrary form definition element, and
14
+ * resolves that (potentially relative) reference to the provided context.
15
+ */
16
+ export declare const parseNodesetReference: <const AttributeName extends ReferenceAttributeName, T extends Element | KnownAttributeElement<AttributeName>>(parentContext: ReferenceParsingContext, element: T, attributeName: AttributeName) => ParsedReferenceAttribute<T, AttributeName>;
17
+ export {};
@@ -0,0 +1,97 @@
1
+ import { AbsoluteLocationPathNode, AnySyntaxNode, FilterPathExprNode, RelativeLocationPathNode } from '@getodk/xpath/static/grammar/SyntaxNode.js';
2
+ type LocalNameLiteral<LocalName extends string> = LocalName | `${string}:${LocalName}`;
3
+ type LocalNamedFunctionCallLiteral<LocalName extends string> = `${LocalNameLiteral<LocalName>}(${string})`;
4
+ export type TranslationExpression = LocalNamedFunctionCallLiteral<'itext'>;
5
+ /**
6
+ * Determines if an arbitrary XPath expression is (in whole) a translation
7
+ * expression (i.e. a call to `jr:itext`).
8
+ *
9
+ * @todo We may also want a companion function: `hasTranslationExpression`,
10
+ * which could be used for `<label ref>`/`<hint ref>` or anywhere else that an
11
+ * arbitrary expression may call `jr:itext`.
12
+ */
13
+ export declare const isTranslationExpression: (expression: string) => expression is TranslationExpression;
14
+ /**
15
+ * Predicate to determine if a FilterPathExpr (as currently produced by
16
+ * `tree-sitter-xpath`) is one of:
17
+ *
18
+ * - `current()`
19
+ * - `current()/...` (where `...` represents additional steps)
20
+ * - `current()//...` (^)
21
+ *
22
+ * @todo XPath grammar technically also allows for FilterExpr[Predicate],
23
+ * and our `tree-sitter-xpath` grammar/parser also allow for this. But
24
+ * `@getodk/xpath` types do not currently acknowledge this possibility.
25
+ */
26
+ export declare const isCurrentPath: (syntaxNode: FilterPathExprNode) => boolean;
27
+ declare const FILTER_PATH_NODE: unique symbol;
28
+ /**
29
+ * Used to narrow types where a SyntaxNode with type 'filter_path_expr' is not
30
+ * **known to produce** a node-set result.
31
+ *
32
+ * This addresses some awkwardness in the XPath grammar (and our implementation
33
+ * parsing it) where FilterExpr _may be_ a FunctionCall, and one of the
34
+ * following _may also be true_:
35
+ *
36
+ * - The function call is known by name to produce a node-set result, **OR**
37
+ *
38
+ * - The function call is followed by one or more Steps (or the Step-like '//'
39
+ * shorthand), which must produce a node-set **OR**
40
+ *
41
+ * - The function call is followed by one or more Predicates, which must produce
42
+ * a node-set
43
+ *
44
+ * Any other FilterExpr (and thus our containing synthetic 'filter_path_expr'
45
+ * SyntaxNode) is treated as a non-path [sub-]expression, excluding it from
46
+ * analysis as such (and any downstream logic such as nodeset resolution).
47
+ */
48
+ export interface FilterPathNode extends FilterPathExprNode {
49
+ readonly [FILTER_PATH_NODE]: true;
50
+ }
51
+ /**
52
+ * Determines whether a given expression beginning with a FilterExpr is known to
53
+ * produce a node-set result. Used in downstream dependency analysis, as well as
54
+ * path resolution.
55
+ */
56
+ export declare const isNodeSetFilterPathExpression: (syntaxNode: FilterPathExprNode) => syntaxNode is FilterPathNode;
57
+ export type PathExpressionNode = AbsoluteLocationPathNode | FilterPathNode | RelativeLocationPathNode;
58
+ /**
59
+ * Locates sub-expression {@link PathExpressionNode}s within a parsed XPath
60
+ * expression (or any arbitrary sub-expression thereof).
61
+ */
62
+ export declare const findLocationPathSubExpressionNodes: (syntaxNode: AnySyntaxNode) => readonly PathExpressionNode[];
63
+ /**
64
+ * Gets the parsed representation of an XPath path expression, iff the complete
65
+ * expression is any {@link PathExpressionNode} syntax type.
66
+ */
67
+ export declare const getPathExpressionNode: (expression: string) => PathExpressionNode | null;
68
+ type BrandedExpression<Expression extends string, Brand extends symbol> = Expression & {
69
+ readonly [K in Brand]: true;
70
+ };
71
+ declare const CONSTANT_EXPRESSION: unique symbol;
72
+ type CONSTANT_EXPRESSION = typeof CONSTANT_EXPRESSION;
73
+ /**
74
+ * Represents an expression which produces a constant result:
75
+ *
76
+ * - Makes no reference to explicit dependencies
77
+ * - Does not depend on any known, implicit state
78
+ * - Evaluation does not depend in any way on context
79
+ * - Evaluation can be treated as referentially transparent
80
+ */
81
+ export type ConstantExpression = BrandedExpression<string, CONSTANT_EXPRESSION>;
82
+ /**
83
+ * @see {@link ConstantExpression}
84
+ */
85
+ export declare const isConstantExpression: (expression: string) => expression is ConstantExpression;
86
+ declare const CONSTANT_TRUTHY_EXPRESSION: unique symbol;
87
+ type CONSTANT_TRUTHY_EXPRESSION = typeof CONSTANT_TRUTHY_EXPRESSION;
88
+ /**
89
+ * Represents an expression which is {@link ConstantExpression | constant},
90
+ * and which will always produce `true` when evaluated as a boolean.
91
+ */
92
+ export type ConstantTruthyExpression = BrandedExpression<ConstantExpression, CONSTANT_TRUTHY_EXPRESSION>;
93
+ /**
94
+ * @see {@link ConstantTruthyExpression}
95
+ */
96
+ export declare const isConstantTruthyExpression: (expression: string) => expression is ConstantTruthyExpression;
97
+ export {};