@getodk/xforms-engine 0.4.0 → 0.5.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 (285) hide show
  1. package/dist/client/BaseNode.d.ts +14 -3
  2. package/dist/client/BaseValueNode.d.ts +32 -0
  3. package/dist/client/EngineConfig.d.ts +49 -48
  4. package/dist/client/InputNode.d.ts +53 -0
  5. package/dist/client/ModelValueNode.d.ts +12 -7
  6. package/dist/client/NoteNode.d.ts +2 -2
  7. package/dist/client/RootNode.d.ts +34 -7
  8. package/dist/client/SelectNode.d.ts +2 -2
  9. package/dist/client/ValueType.d.ts +3 -0
  10. package/dist/client/constants.d.ts +50 -0
  11. package/dist/client/hierarchy.d.ts +4 -4
  12. package/dist/client/identity.d.ts +14 -0
  13. package/dist/client/node-types.d.ts +2 -1
  14. package/dist/client/resources.d.ts +93 -0
  15. package/dist/client/submission/SubmissionData.d.ts +7 -0
  16. package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
  17. package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
  18. package/dist/client/submission/SubmissionOptions.d.ts +23 -0
  19. package/dist/client/submission/SubmissionResult.d.ts +91 -0
  20. package/dist/client/submission/SubmissionState.d.ts +12 -0
  21. package/dist/client/validation.d.ts +2 -2
  22. package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
  23. package/dist/error/ValueTypeInvariantError.d.ts +17 -0
  24. package/dist/error/XPathFunctionalityError.d.ts +14 -0
  25. package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
  26. package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
  27. package/dist/index.d.ts +10 -1
  28. package/dist/index.js +10856 -8585
  29. package/dist/index.js.map +1 -1
  30. package/dist/instance/Group.d.ts +9 -4
  31. package/dist/instance/InputControl.d.ts +36 -0
  32. package/dist/instance/ModelValue.d.ts +16 -26
  33. package/dist/instance/Note.d.ts +10 -3
  34. package/dist/instance/PrimaryInstance.d.ts +84 -0
  35. package/dist/instance/Root.d.ts +29 -25
  36. package/dist/instance/SelectField.d.ts +10 -2
  37. package/dist/instance/Subtree.d.ts +10 -5
  38. package/dist/instance/TriggerControl.d.ts +10 -3
  39. package/dist/instance/abstract/DescendantNode.d.ts +31 -23
  40. package/dist/instance/abstract/InstanceNode.d.ts +49 -29
  41. package/dist/instance/abstract/UnsupportedControl.d.ts +10 -3
  42. package/dist/instance/abstract/ValueNode.d.ts +48 -0
  43. package/dist/instance/hierarchy.d.ts +9 -8
  44. package/dist/instance/identity.d.ts +2 -7
  45. package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
  46. package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
  47. package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
  48. package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
  49. package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
  50. package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
  51. package/dist/instance/internal-api/ValueContext.d.ts +2 -1
  52. package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
  53. package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +31 -0
  54. package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +18 -0
  55. package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +17 -0
  56. package/dist/instance/repeat/BaseRepeatRange.d.ts +39 -83
  57. package/dist/instance/repeat/RepeatInstance.d.ts +11 -29
  58. package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
  59. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
  60. package/dist/instance/resource.d.ts +1 -1
  61. package/dist/instance/text/TextRange.d.ts +1 -1
  62. package/dist/instance/unsupported/RangeControl.d.ts +3 -1
  63. package/dist/instance/unsupported/RankControl.d.ts +3 -1
  64. package/dist/instance/unsupported/UploadControl.d.ts +3 -1
  65. package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
  66. package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
  67. package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
  68. package/dist/integration/xpath/adapter/kind.d.ts +32 -0
  69. package/dist/integration/xpath/adapter/names.d.ts +16 -0
  70. package/dist/integration/xpath/adapter/traversal.d.ts +25 -0
  71. package/dist/integration/xpath/adapter/values.d.ts +2 -0
  72. package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +19 -0
  73. package/dist/integration/xpath/static-dom/StaticDocument.d.ts +16 -0
  74. package/dist/integration/xpath/static-dom/StaticElement.d.ts +40 -0
  75. package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +17 -0
  76. package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
  77. package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
  78. package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
  79. package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
  80. package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
  81. package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
  82. package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
  83. package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
  84. package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
  85. package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
  86. package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
  87. package/dist/lib/codecs/ValueCodec.d.ts +30 -0
  88. package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
  89. package/dist/lib/codecs/getSharedValueCodec.d.ts +47 -0
  90. package/dist/lib/dom/query.d.ts +3 -0
  91. package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
  92. package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
  93. package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
  94. package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
  95. package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
  96. package/dist/lib/reactivity/createValueState.d.ts +6 -10
  97. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
  98. package/dist/lib/xml-serialization.d.ts +41 -0
  99. package/dist/parse/XFormDOM.d.ts +18 -7
  100. package/dist/parse/XFormDefinition.d.ts +1 -2
  101. package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
  102. package/dist/parse/body/BodyDefinition.d.ts +3 -3
  103. package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
  104. package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
  105. package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +1 -1
  106. package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -2
  107. package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
  108. package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
  109. package/dist/parse/model/BindDefinition.d.ts +4 -5
  110. package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
  111. package/dist/parse/model/DescendentNodeDefinition.d.ts +0 -1
  112. package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
  113. package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
  114. package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +8 -0
  115. package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
  116. package/dist/parse/model/LeafNodeDefinition.d.ts +3 -1
  117. package/dist/parse/model/ModelBindMap.d.ts +1 -1
  118. package/dist/parse/model/ModelDefinition.d.ts +2 -0
  119. package/dist/parse/model/NodeDefinition.d.ts +0 -1
  120. package/dist/parse/model/NoteNodeDefinition.d.ts +4 -4
  121. package/dist/parse/model/RootDefinition.d.ts +3 -2
  122. package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
  123. package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
  124. package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
  125. package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
  126. package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
  127. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
  128. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
  129. package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
  130. package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
  131. package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
  132. package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
  133. package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
  134. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
  135. package/dist/parse/xpath/semantic-analysis.d.ts +5 -0
  136. package/dist/solid.js +8174 -5921
  137. package/dist/solid.js.map +1 -1
  138. package/package.json +13 -11
  139. package/src/client/BaseNode.ts +16 -6
  140. package/src/client/BaseValueNode.ts +35 -0
  141. package/src/client/EngineConfig.ts +52 -51
  142. package/src/client/InputNode.ts +77 -0
  143. package/src/client/ModelValueNode.ts +30 -7
  144. package/src/client/NoteNode.ts +2 -2
  145. package/src/client/RootNode.ts +37 -7
  146. package/src/client/SelectNode.ts +3 -3
  147. package/src/client/ValueType.ts +4 -0
  148. package/src/client/constants.ts +67 -0
  149. package/src/client/hierarchy.ts +5 -5
  150. package/src/client/identity.ts +16 -0
  151. package/src/client/node-types.ts +12 -6
  152. package/src/client/resources.ts +118 -0
  153. package/src/client/submission/SubmissionData.ts +12 -0
  154. package/src/client/submission/SubmissionDefinition.ts +16 -0
  155. package/src/client/submission/SubmissionInstanceFile.ts +9 -0
  156. package/src/client/submission/SubmissionOptions.ts +28 -0
  157. package/src/client/submission/SubmissionResult.ts +124 -0
  158. package/src/client/submission/SubmissionState.ts +14 -0
  159. package/src/client/validation.ts +2 -2
  160. package/src/error/ErrorProductionDesignPendingError.ts +6 -0
  161. package/src/error/ValueTypeInvariantError.ts +22 -0
  162. package/src/error/XPathFunctionalityError.ts +26 -0
  163. package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
  164. package/src/error/XPathFunctionalityPendingError.ts +18 -0
  165. package/src/index.ts +10 -1
  166. package/src/instance/Group.ts +17 -5
  167. package/src/instance/InputControl.ts +119 -0
  168. package/src/instance/ModelValue.ts +47 -54
  169. package/src/instance/Note.ts +24 -8
  170. package/src/instance/PrimaryInstance.ts +244 -0
  171. package/src/instance/Root.ts +62 -134
  172. package/src/instance/SelectField.ts +56 -19
  173. package/src/instance/Subtree.ts +19 -7
  174. package/src/instance/TriggerControl.ts +23 -6
  175. package/src/instance/abstract/DescendantNode.ts +90 -45
  176. package/src/instance/abstract/InstanceNode.ts +103 -105
  177. package/src/instance/abstract/UnsupportedControl.ts +28 -5
  178. package/src/instance/abstract/ValueNode.ts +127 -0
  179. package/src/instance/children.ts +9 -10
  180. package/src/instance/hierarchy.ts +19 -15
  181. package/src/instance/identity.ts +3 -9
  182. package/src/instance/index.ts +25 -7
  183. package/src/instance/internal-api/EvaluationContext.ts +60 -13
  184. package/src/instance/internal-api/InstanceConfig.ts +9 -2
  185. package/src/instance/internal-api/InstanceValueContext.ts +24 -0
  186. package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
  187. package/src/instance/internal-api/TranslationContext.ts +3 -2
  188. package/src/instance/internal-api/ValidationContext.ts +3 -4
  189. package/src/instance/internal-api/ValueContext.ts +2 -1
  190. package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
  191. package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +42 -0
  192. package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +25 -0
  193. package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +23 -0
  194. package/src/instance/repeat/BaseRepeatRange.ts +50 -131
  195. package/src/instance/repeat/RepeatInstance.ts +20 -46
  196. package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
  197. package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
  198. package/src/instance/resource.ts +1 -1
  199. package/src/instance/text/TextChunk.ts +1 -1
  200. package/src/instance/unsupported/RangeControl.ts +5 -1
  201. package/src/instance/unsupported/RankControl.ts +5 -1
  202. package/src/instance/unsupported/UploadControl.ts +5 -1
  203. package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
  204. package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
  205. package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
  206. package/src/integration/xpath/adapter/kind.ts +114 -0
  207. package/src/integration/xpath/adapter/names.ts +99 -0
  208. package/src/integration/xpath/adapter/traversal.ts +228 -0
  209. package/src/integration/xpath/adapter/values.ts +5 -0
  210. package/src/integration/xpath/static-dom/StaticAttribute.ts +33 -0
  211. package/src/integration/xpath/static-dom/StaticDocument.ts +38 -0
  212. package/src/integration/xpath/static-dom/StaticElement.ts +106 -0
  213. package/src/integration/xpath/static-dom/StaticNamedNode.ts +45 -0
  214. package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
  215. package/src/integration/xpath/static-dom/StaticText.ts +28 -0
  216. package/src/lib/client-reactivity/README.md +0 -0
  217. package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
  218. package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
  219. package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
  220. package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
  221. package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
  222. package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
  223. package/src/lib/codecs/DecimalValueCodec.ts +46 -0
  224. package/src/lib/codecs/IntValueCodec.ts +100 -0
  225. package/src/lib/codecs/StringValueCodec.ts +11 -0
  226. package/src/lib/codecs/ValueCodec.ts +106 -0
  227. package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
  228. package/src/lib/codecs/getSharedValueCodec.ts +77 -0
  229. package/src/lib/dom/query.ts +7 -0
  230. package/src/lib/reactivity/createChildrenState.ts +8 -6
  231. package/src/lib/reactivity/createComputedExpression.ts +57 -34
  232. package/src/lib/reactivity/createInstanceValueState.ts +166 -0
  233. package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
  234. package/src/lib/reactivity/createSelectItems.ts +21 -21
  235. package/src/lib/reactivity/createTranslationState.ts +61 -0
  236. package/src/lib/reactivity/createValueState.ts +62 -120
  237. package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
  238. package/src/lib/reactivity/text/createTextRange.ts +4 -3
  239. package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
  240. package/src/lib/reactivity/validation/createValidation.ts +2 -3
  241. package/src/lib/xml-serialization.ts +96 -0
  242. package/src/parse/XFormDOM.ts +110 -75
  243. package/src/parse/XFormDefinition.ts +1 -6
  244. package/src/parse/attachments/FormAttachmentResource.ts +40 -0
  245. package/src/parse/body/BodyDefinition.ts +3 -3
  246. package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
  247. package/src/parse/body/control/{InputDefinition.ts → InputControlDefinition.ts} +3 -5
  248. package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -5
  249. package/src/parse/expression/abstract/DependencyContext.ts +0 -26
  250. package/src/parse/expression/abstract/DependentExpression.ts +2 -13
  251. package/src/parse/model/BindDefinition.ts +5 -8
  252. package/src/parse/model/BindTypeDefinition.ts +175 -0
  253. package/src/parse/model/DescendentNodeDefinition.ts +0 -6
  254. package/src/parse/model/FormSubmissionDefinition.ts +44 -0
  255. package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
  256. package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +41 -0
  257. package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
  258. package/src/parse/model/LeafNodeDefinition.ts +4 -1
  259. package/src/parse/model/ModelBindMap.ts +6 -8
  260. package/src/parse/model/ModelDefinition.ts +6 -1
  261. package/src/parse/model/NodeDefinition.ts +0 -3
  262. package/src/parse/model/NoteNodeDefinition.ts +3 -3
  263. package/src/parse/model/RootDefinition.ts +2 -1
  264. package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
  265. package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
  266. package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
  267. package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
  268. package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
  269. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
  270. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
  271. package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +414 -0
  272. package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
  273. package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
  274. package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
  275. package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
  276. package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
  277. package/src/parse/xpath/semantic-analysis.ts +29 -0
  278. package/dist/client/StringNode.d.ts +0 -46
  279. package/dist/instance/StringField.d.ts +0 -44
  280. package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
  281. package/dist/parse/XFormDataType.d.ts +0 -25
  282. package/src/client/StringNode.ts +0 -52
  283. package/src/instance/StringField.ts +0 -120
  284. package/src/instance/internal-api/SubscribableDependency.ts +0 -61
  285. package/src/parse/XFormDataType.ts +0 -62
@@ -0,0 +1,33 @@
1
+ import { XPathNodeKindKey } from '@getodk/xpath';
2
+ import { XFormsXPathNode } from '../adapter/XFormsXPathNode.ts';
3
+ import { StaticAttribute } from './StaticAttribute.ts';
4
+ import { StaticDocument } from './StaticDocument.ts';
5
+ import { StaticElement } from './StaticElement.ts';
6
+ import { StaticText } from './StaticText.ts';
7
+ export type StaticNodeKind = 'document' | 'element' | 'attribute' | 'text';
8
+ export type StaticNodeType<Kind extends StaticNodeKind> = `static-${Kind}`;
9
+ export declare abstract class StaticNode<Kind extends StaticNodeKind> implements XFormsXPathNode {
10
+ abstract readonly [XPathNodeKindKey]: Kind;
11
+ abstract readonly nodeType: StaticNodeType<Kind>;
12
+ /**
13
+ * A concrete {@link StaticDocument} instance, representing the topmost node
14
+ * of a static document tree, containing all of:
15
+ *
16
+ * - {@link root}
17
+ * - {@link children}
18
+ * - any {@link StaticChildNode} descendants of either of the above
19
+ */
20
+ abstract readonly rootDocument: StaticDocument;
21
+ /**
22
+ * A concrete {@link StaticElement} instance, representing the single,
23
+ * immediate child of {@link rootDocument}, containing all other descendants
24
+ * of its document tree.
25
+ */
26
+ abstract readonly root: StaticElement;
27
+ abstract readonly children: readonly StaticChildNode[] | null;
28
+ getXPathChildNodes(): readonly StaticChildNode[];
29
+ abstract getXPathValue(): string;
30
+ }
31
+ export type AnyStaticNode = StaticDocument | StaticElement | StaticAttribute | StaticText;
32
+ export type StaticParentNode = StaticDocument | StaticElement;
33
+ export type StaticChildNode = StaticElement | StaticText;
@@ -0,0 +1,16 @@
1
+ import { XPathNodeKindKey } from '@getodk/xpath';
2
+ import { XFormsXPathText } from '../adapter/XFormsXPathNode.ts';
3
+ import { StaticDocument } from './StaticDocument.ts';
4
+ import { StaticElement } from './StaticElement.ts';
5
+ import { StaticNode } from './StaticNode.ts';
6
+ export declare class StaticText extends StaticNode<'text'> implements XFormsXPathText {
7
+ readonly parent: StaticElement;
8
+ readonly value: string;
9
+ readonly [XPathNodeKindKey] = "text";
10
+ readonly nodeType = "static-text";
11
+ readonly rootDocument: StaticDocument;
12
+ readonly root: StaticElement;
13
+ readonly children: null;
14
+ constructor(parent: StaticElement, value: string);
15
+ getXPathValue(): string;
16
+ }
@@ -0,0 +1,3 @@
1
+ import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
2
+ import { ClientReactiveSubmittableInstance } from '../../../instance/internal-api/submission/ClientReactiveSubmittableInstance.ts';
3
+ export declare const createInstanceSubmissionState: (node: ClientReactiveSubmittableInstance) => SubmissionState;
@@ -0,0 +1,3 @@
1
+ import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
2
+ import { ClientReactiveSubmittableLeafNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
3
+ export declare const createLeafNodeSubmissionState: <Value>(node: ClientReactiveSubmittableLeafNode<Value>) => SubmissionState;
@@ -0,0 +1,4 @@
1
+ import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
2
+ import { ClientReactiveSubmittableParentNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts';
3
+ import { RepeatInstance } from '../../../instance/repeat/RepeatInstance.ts';
4
+ export declare const createNodeRangeSubmissionState: (node: ClientReactiveSubmittableParentNode<RepeatInstance>) => SubmissionState;
@@ -0,0 +1,4 @@
1
+ import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
2
+ import { GeneralChildNode } from '../../../instance/hierarchy.ts';
3
+ import { ClientReactiveSubmittableParentNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts';
4
+ export declare const createParentNodeSubmissionState: (node: ClientReactiveSubmittableParentNode<GeneralChildNode>) => SubmissionState;
@@ -0,0 +1,3 @@
1
+ import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
2
+ import { ClientReactiveSubmittableValueNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts';
3
+ export declare const createValueNodeSubmissionState: (node: ClientReactiveSubmittableValueNode) => SubmissionState;
@@ -0,0 +1,8 @@
1
+ import { SubmissionChunkedType } from '../../../client/submission/SubmissionOptions.ts';
2
+ import { SubmissionResult } from '../../../client/submission/SubmissionResult.ts';
3
+ import { ClientReactiveSubmittableInstance } from '../../../instance/internal-api/submission/ClientReactiveSubmittableInstance.ts';
4
+ export interface PrepeareSubmissionOptions<ChunkedType extends SubmissionChunkedType> {
5
+ readonly chunked: ChunkedType;
6
+ readonly maxSize: number;
7
+ }
8
+ export declare const prepareSubmission: <ChunkedType extends SubmissionChunkedType>(instanceRoot: ClientReactiveSubmittableInstance, options: PrepeareSubmissionOptions<ChunkedType>) => SubmissionResult<ChunkedType>;
@@ -0,0 +1,6 @@
1
+ import { ValueCodec } from './ValueCodec.ts';
2
+ export type DecimalInputValue = bigint | number | string | null;
3
+ export type DecimalRuntimeValue = number | null;
4
+ export declare class DecimalValueCodec extends ValueCodec<'decimal', DecimalRuntimeValue, DecimalInputValue> {
5
+ constructor();
6
+ }
@@ -0,0 +1,6 @@
1
+ import { ValueCodec } from './ValueCodec.ts';
2
+ export type IntInputValue = bigint | number | string | null;
3
+ export type IntRuntimeValue = bigint | null;
4
+ export declare class IntValueCodec extends ValueCodec<'int', IntRuntimeValue, IntInputValue> {
5
+ constructor();
6
+ }
@@ -0,0 +1,4 @@
1
+ import { ValueCodec } from './ValueCodec.ts';
2
+ export declare class StringValueCodec extends ValueCodec<'string', string, string> {
3
+ constructor();
4
+ }
@@ -0,0 +1,30 @@
1
+ import { Accessor } from 'solid-js';
2
+ import { ValueType } from '../../client/ValueType.ts';
3
+ import { DecodeInstanceValue } from '../../instance/internal-api/InstanceValueContext.ts';
4
+ import { SimpleAtomicState } from '../reactivity/types.ts';
5
+ type CodecEncoder<RuntimeInputValue> = (input: RuntimeInputValue) => string;
6
+ type CodecDecoder<RuntimeValue> = (value: string) => RuntimeValue;
7
+ type RuntimeValueAccessor<RuntimeValue> = Accessor<RuntimeValue>;
8
+ export type RuntimeValueSetter<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = (input: RuntimeInputValue) => RuntimeValue;
9
+ export type RuntimeValueState<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = readonly [
10
+ get: RuntimeValueAccessor<RuntimeValue>,
11
+ set: RuntimeValueSetter<RuntimeValue, RuntimeInputValue>
12
+ ];
13
+ export type CreateRuntimeValueState<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = (instanceState: SimpleAtomicState<string>) => RuntimeValueState<RuntimeValue, RuntimeInputValue>;
14
+ type RuntimeValueStateFactory<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = (encodeValue: CodecEncoder<RuntimeInputValue>, decodeValue: CodecDecoder<RuntimeValue>) => CreateRuntimeValueState<RuntimeValue, RuntimeInputValue>;
15
+ type DecodeInstanceValueFactory<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = (encodeValue: CodecEncoder<RuntimeInputValue>, decodeValue: CodecDecoder<RuntimeValue>) => DecodeInstanceValue;
16
+ interface ValueCodecOptions<RuntimeValue extends RuntimeInputValue, RuntimeInputValue> {
17
+ readonly decodeInstanceValueFactory?: DecodeInstanceValueFactory<RuntimeValue, RuntimeInputValue>;
18
+ readonly runtimeValueStateFactory?: RuntimeValueStateFactory<RuntimeValue, RuntimeInputValue>;
19
+ }
20
+ export declare abstract class ValueCodec<V extends ValueType, RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> {
21
+ readonly valueType: V;
22
+ readonly encodeValue: CodecEncoder<RuntimeInputValue>;
23
+ readonly decodeValue: CodecDecoder<RuntimeValue>;
24
+ protected readonly defaultRuntimeValueStateFactory: RuntimeValueStateFactory<RuntimeValue, RuntimeInputValue>;
25
+ protected readonly defaultDecodeInstanceValueFactory: DecodeInstanceValueFactory<RuntimeValue, RuntimeInputValue>;
26
+ readonly decodeInstanceValue: DecodeInstanceValue;
27
+ readonly createRuntimeValueState: CreateRuntimeValueState<RuntimeValue, RuntimeInputValue>;
28
+ constructor(valueType: V, encodeValue: CodecEncoder<RuntimeInputValue>, decodeValue: CodecDecoder<RuntimeValue>, options?: ValueCodecOptions<RuntimeValue, RuntimeInputValue>);
29
+ }
30
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ValueType } from '../../client/ValueType.ts';
2
+ import { ValueCodec } from './ValueCodec.ts';
3
+ /**
4
+ * Provides fallback functionality where a {@link ValueCodec} is expected, for
5
+ * those {@link ValueType | value types} which are still pending implementation.
6
+ * This allows consistent use of the {@link ValueCodec} interface while
7
+ * maintaining the current behavior of treating those unimplemented value types
8
+ * as string values.
9
+ */
10
+ export declare class ValueTypePlaceholderCodec<V extends ValueType> extends ValueCodec<V, string, string> {
11
+ constructor(valueType: V);
12
+ }
@@ -0,0 +1,47 @@
1
+ import { ValueType } from '../../client/ValueType.ts';
2
+ import { DecimalInputValue, DecimalRuntimeValue } from './DecimalValueCodec.ts';
3
+ import { IntInputValue, IntRuntimeValue } from './IntValueCodec.ts';
4
+ import { ValueCodec } from './ValueCodec.ts';
5
+ interface RuntimeValuesByType {
6
+ readonly string: string;
7
+ readonly int: IntRuntimeValue;
8
+ readonly decimal: DecimalRuntimeValue;
9
+ readonly boolean: string;
10
+ readonly date: string;
11
+ readonly time: string;
12
+ readonly dateTime: string;
13
+ readonly geopoint: string;
14
+ readonly geotrace: string;
15
+ readonly geoshape: string;
16
+ readonly binary: string;
17
+ readonly barcode: string;
18
+ readonly intent: string;
19
+ }
20
+ export type RuntimeValue<V extends ValueType> = RuntimeValuesByType[V];
21
+ interface RuntimeInputValuesByType {
22
+ readonly string: string;
23
+ readonly int: IntInputValue;
24
+ readonly decimal: DecimalInputValue;
25
+ readonly boolean: string;
26
+ readonly date: string;
27
+ readonly time: string;
28
+ readonly dateTime: string;
29
+ readonly geopoint: string;
30
+ readonly geotrace: string;
31
+ readonly geoshape: string;
32
+ readonly binary: string;
33
+ readonly barcode: string;
34
+ readonly intent: string;
35
+ }
36
+ export type RuntimeInputValue<V extends ValueType> = RuntimeInputValuesByType[V];
37
+ type SharedValueCodecs = {
38
+ readonly [V in ValueType]: ValueCodec<V, RuntimeValue<V>, RuntimeInputValue<V>>;
39
+ };
40
+ export type SharedValueCodec<V extends ValueType> = SharedValueCodecs[V];
41
+ /**
42
+ * Provides codecs for each {@link ValueType | value type}, for nodes with a
43
+ * common representation of those value types.
44
+ */
45
+ export declare const sharedValueCodecs: SharedValueCodecs;
46
+ export declare const getSharedValueCodec: <V extends ValueType>(valueType: V) => SharedValueCodec<V>;
47
+ export {};
@@ -23,3 +23,6 @@ export declare const getLabelElement: (parent: Element) => LabelElement | null;
23
23
  export declare const getRepeatGroupLabelElement: (parent: Element) => RepeatGroupLabelElement | null;
24
24
  export declare const getRepeatElement: (parent: Element) => RepeatElement | null;
25
25
  export declare const getValueElement: (parent: ItemElement | ItemsetElement) => ValueElement | null;
26
+ export interface SubmissionElement extends LocalNamedElement<'submission'> {
27
+ }
28
+ export declare const getSubmissionElement: (parent: Element) => SubmissionElement | null;
@@ -1,17 +1,18 @@
1
1
  import { Accessor, Setter, Signal } from 'solid-js';
2
+ import { FormNodeID } from '../../client/identity.ts';
2
3
  import { AnyChildNode, AnyParentNode } from '../../instance/hierarchy.ts';
3
- import { NodeID } from '../../instance/identity.ts';
4
4
  export interface ChildrenState<Child extends AnyChildNode> {
5
5
  readonly children: Signal<readonly Child[]>;
6
6
  readonly getChildren: Accessor<readonly Child[]>;
7
7
  readonly setChildren: Setter<readonly Child[]>;
8
- readonly childIds: Accessor<readonly NodeID[]>;
8
+ readonly childIds: Accessor<readonly FormNodeID[]>;
9
9
  }
10
10
  /**
11
11
  * Creates a synchronized pair of:
12
12
  *
13
13
  * - Internal children state suitable for all parent node types
14
- * - The same children state computed as an array of each child's {@link NodeID}
14
+ * - The same children state computed as an array of each child's
15
+ * {@link FormNodeID}
15
16
  *
16
17
  * This state is used, in tandem with {@link materializeCurrentStateChildren},
17
18
  * to ensure children in **client-facing** state are not written into nested
@@ -26,11 +27,12 @@ export interface ChildrenState<Child extends AnyChildNode> {
26
27
  * The produced {@link ChildrenState.childIds} memo is intended to be used to
27
28
  * specify each parent node's `children` in an instance of {@link EngineState}.
28
29
  * In so doing, the node's corresponding (internal, synchronized)
29
- * {@link ClientState} will likewise store only the children's {@link NodeID}s.
30
+ * {@link ClientState} will likewise store only the children's
31
+ * {@link FormNodeID}s.
30
32
  *
31
33
  * As a client reacts to changes in a given parent node's `children` state, that
32
34
  * node's {@link CurrentState} should produce the child nodes corresponding to
33
- * those {@link NodeID}s with the aforementioned
35
+ * those {@link FormNodeID}s with the aforementioned
34
36
  * {@link materializeCurrentStateChildren}.
35
37
  */
36
38
  export declare const createChildrenState: <Parent extends AnyParentNode, Child extends AnyChildNode>(parent: Parent) => ChildrenState<Child>;
@@ -1,17 +1,30 @@
1
1
  import { Accessor } from 'solid-js';
2
2
  import { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
3
- import { SubscribableDependency } from '../../instance/internal-api/SubscribableDependency.ts';
3
+ import { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
4
4
  import { DependentExpression, DependentExpressionResultType } from '../../parse/expression/abstract/DependentExpression.ts';
5
5
  interface ComputedExpressionResults {
6
6
  readonly boolean: boolean;
7
- readonly nodes: Node[];
7
+ readonly nodes: EngineXPathNode[];
8
8
  readonly number: number;
9
9
  readonly string: string;
10
10
  }
11
11
  type EvaluatedExpression<Type extends DependentExpressionResultType> = ComputedExpressionResults[Type];
12
12
  type ComputedExpression<Type extends DependentExpressionResultType> = Accessor<EvaluatedExpression<Type>>;
13
- interface CreateComputedExpressionOptions {
14
- readonly arbitraryDependencies?: readonly SubscribableDependency[];
13
+ interface CreateComputedExpressionOptions<Type extends DependentExpressionResultType> {
14
+ /**
15
+ * If a default value is provided, {@link createComputedExpression} will
16
+ * produce this value for computations in a non-attached evaluation context,
17
+ * i.e. when evaluating an expression against a node which has not yet been
18
+ * appended to its parents children state (or which has since been removed
19
+ * from that state). A non-attached state is detected when
20
+ * {@link EvaluationContext.isAttached} returns false.
21
+ *
22
+ * If no default value is provided, an implicit default value is produced as
23
+ * appropriate for the expression's intrinsic result type.
24
+ *
25
+ * @see {@link defaultEvaluationsByType} for these implicit defaults.
26
+ */
27
+ readonly defaultValue?: EvaluatedExpression<Type>;
15
28
  }
16
- export declare const createComputedExpression: <Type extends DependentExpressionResultType>(context: EvaluationContext, dependentExpression: DependentExpression<Type>, options?: CreateComputedExpressionOptions) => ComputedExpression<Type>;
29
+ export declare const createComputedExpression: <Type extends DependentExpressionResultType>(context: EvaluationContext, dependentExpression: DependentExpression<Type>, options?: CreateComputedExpressionOptions<Type>) => ComputedExpression<Type>;
17
30
  export {};
@@ -0,0 +1,40 @@
1
+ import { InstanceValueContext } from '../../instance/internal-api/InstanceValueContext.ts';
2
+ import { SimpleAtomicState } from './types.ts';
3
+ type InitialValueSource = 'FORM_DEFAULT' | 'PRIMARY_INSTANCE';
4
+ export interface InstanceValueStateOptions {
5
+ /**
6
+ * Specifies the source of a {@link createInstanceValueState} signal's initial
7
+ * value state, where:
8
+ *
9
+ * - 'FORM_DEFAULT': Derives the initial state from the form's definition of
10
+ * the node itself. This is the default option, appropriate when
11
+ * initializing a form without additional primary instance data. In other
12
+ * words, this value should not be used for edits.
13
+ *
14
+ * - 'PRIMARY_INSTANCE': Derives the initial state from the current text
15
+ * content of the {@link ValueNode.contextNode}. This option should be
16
+ * specified when initializing a form with existing primary instance data,
17
+ * such as when editing a previous submission.
18
+ *
19
+ * @default 'FORM_DEFAULT'
20
+ *
21
+ * Specifies whether a {@link createInstanceValueState} signal's initial state
22
+ * should be derived from the current text content of the
23
+ * {@link ValueNode.contextNode | primary instance DOM state}.
24
+ */
25
+ readonly initialValueSource?: InitialValueSource;
26
+ }
27
+ export type InstanceValueState = SimpleAtomicState<string>;
28
+ /**
29
+ * Provides a consistent interface for value nodes of any type which:
30
+ *
31
+ * - derives initial state from either an existing instance (e.g. for edits) or
32
+ * the node's definition (e.g. initializing a new submission)
33
+ * - decodes current primary instance state into the value node's runtime type
34
+ * - encodes updated runtime values to store updated instance state
35
+ * - initializes reactive computation of `calculate` bind expressions for those
36
+ * nodes defined with one
37
+ * - prevents downstream writes to nodes in a readonly state
38
+ */
39
+ export declare const createInstanceValueState: (context: InstanceValueContext, options?: InstanceValueStateOptions) => InstanceValueState;
40
+ export {};
@@ -1,4 +1,4 @@
1
1
  import { Accessor } from 'solid-js';
2
2
  import { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
3
- import { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
4
- export declare const createNoteReadonlyThunk: (context: EvaluationContext, readonlyDefinition: BindComputationExpression<"readonly">) => Accessor<true>;
3
+ import { NoteNodeDefinition } from '../../parse/model/NoteNodeDefinition.ts';
4
+ export declare const createNoteReadonlyThunk: (context: EvaluationContext, definition: NoteNodeDefinition) => Accessor<true>;
@@ -0,0 +1,19 @@
1
+ import { Accessor } from 'solid-js';
2
+ import { ActiveLanguage, FormLanguage, FormLanguages } from '../../client/FormLanguage.ts';
3
+ import { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
4
+ import { ReactiveScope } from './scope.ts';
5
+ import { SimpleAtomicStateSetter } from './types.ts';
6
+ interface TranslationState {
7
+ readonly languages: FormLanguages;
8
+ readonly getActiveLanguage: Accessor<ActiveLanguage>;
9
+ readonly setActiveLanguage: SimpleAtomicStateSetter<FormLanguage>;
10
+ }
11
+ /**
12
+ * @todo It's been very silly all along that {@link XFormsXPathEvaluator} is
13
+ * responsible for parsing translation languages, and maintaining the active
14
+ * language state. It is especially silly now that we've moved _part of the
15
+ * parsing_ up to the constructor call site. Let's finish off that awkwardness
16
+ * in a subsequent refactor.
17
+ */
18
+ export declare const createTranslationState: (scope: ReactiveScope, evaluator: EngineXPathEvaluator) => TranslationState;
19
+ export {};
@@ -12,8 +12,7 @@ export interface ValueStateOptions {
12
12
  * other words, this value should not be used for edits.
13
13
  *
14
14
  * - 'PRIMARY_INSTANCE': Derives the initial state from the current text
15
- * content of the {@link ValueNode.contextNode} (currently an XML DOM
16
- * backing store/source of thruth for primary instance state). This option
15
+ * content of the {@link ValueNode.contextNode}. This option
17
16
  * should be specified when initializing a form with existing primary
18
17
  * instance data, such as when editing a previous submission.
19
18
  *
@@ -29,16 +28,13 @@ type ValueState<RuntimeValue> = SimpleAtomicState<RuntimeValue>;
29
28
  /**
30
29
  * Provides a consistent interface for value nodes of any type which:
31
30
  *
32
- * - derives initial state from either the existing primary instance state (e.g.
33
- * for edits) or the node's definition (e.g. initializing a new submission)
34
- * - decodes primary instance state into the value node's runtime type
35
- * - encodes and persists updated values to the primary instance
31
+ * - derives initial state from either an existing instance (e.g. for edits) or
32
+ * the node's definition (e.g. initializing a new submission)
33
+ * - decodes current primary instance state into the value node's runtime type
34
+ * - encodes updated runtime values to store updated instance state
36
35
  * - initializes reactive computation of `calculate` bind expressions for those
37
36
  * nodes defined with one
38
- * - ensures any downstream reactive dependencies are updated only after writes
39
- * (whether performed by a client, or by a reactive `calculate` computation)
40
- * are persisted, ensuring a consistent view of state when downstream
41
- * computations perform XPath evaluations against that primary instance state
37
+ * - prevents downstream writes to nodes in a readonly state
42
38
  */
43
39
  export declare const createValueState: <RuntimeValue>(context: ValueContext<RuntimeValue>, options?: ValueStateOptions) => ValueState<RuntimeValue>;
44
40
  export {};
@@ -1,9 +1,9 @@
1
+ import { FormNodeID } from '../../client/identity.ts';
1
2
  import { AnyChildNode } from '../../instance/hierarchy.ts';
2
- import { NodeID } from '../../instance/identity.ts';
3
3
  import { ChildrenState } from './createChildrenState.ts';
4
4
  import { ReactiveScope } from './scope.ts';
5
5
  export interface EncodedParentState {
6
- readonly children: readonly NodeID[];
6
+ readonly children: readonly FormNodeID[];
7
7
  }
8
8
  export type MaterializedChildren<BaseState extends EncodedParentState, Child extends AnyChildNode | null> = Omit<BaseState, 'children'> & {
9
9
  readonly children: readonly Child[];
@@ -11,8 +11,8 @@ export type MaterializedChildren<BaseState extends EncodedParentState, Child ext
11
11
  /**
12
12
  * Creates a wrapper proxy around a parent node's {@link CurrentState} to map
13
13
  * `children` state, which is written to the node's (internal, synchronized)
14
- * {@link ClientState} as an array of {@link NodeID}s, back to the node objects
15
- * corresponding to those IDs.
14
+ * {@link ClientState} as an array of {@link FormNodeID}s, back to the node
15
+ * objects corresponding to those IDs.
16
16
  *
17
17
  * @see {@link createChildrenState} for further detail.
18
18
  */
@@ -0,0 +1,41 @@
1
+ declare const ESCAPED_XML_TEXT_BRAND: unique symbol;
2
+ export type EscapedXMLText = string & {
3
+ readonly [ESCAPED_XML_TEXT_BRAND]: true;
4
+ };
5
+ /**
6
+ * This is based on the `escapeHTML` implementation in
7
+ * {@link https://github.com/ryansolid/dom-expressions} (Solid's JSX transform).
8
+ *
9
+ * @see {@link https://github.com/ryansolid/dom-expressions/pull/27} for
10
+ * motivation to derive this implementation approach.
11
+ *
12
+ * The intent is that this can be updated easily if the base implementation
13
+ * changes. As such, some aspects of this implementation differ from some of our
14
+ * typical code style preferences.
15
+ *
16
+ * Notable changes from the base implementation:
17
+ *
18
+ * - Formatting: automated only.
19
+ * - Naming: the {@link text} parameter is named `html` in the base
20
+ * implementation. That would be confusing if preserved.
21
+ * - Types:
22
+ * - Parameter types are added (of course)
23
+ * - Return type is branded as {@link EscapedXMLText}, to allow downstream
24
+ * checks that escaping has been performed. Return statements are cast
25
+ * accordingly.
26
+ * - {@link text} attempts to minimize risk of double-escaping by excluding
27
+ * that same branded type.
28
+ * - The '>' character is also escaped, necessary for producing valid XML.
29
+ *
30
+ * As with the base implementation, we leave some characters unescaped:
31
+ *
32
+ * - " (double quote): except when {@link attr} is `true`.
33
+ *
34
+ * - ' (single quote): on the assumption that attributes are always serialized
35
+ * in double quotes. If we ever move this to `@getodk/common`, we'd want to
36
+ * reconsider this assumption.
37
+ */
38
+ export declare const escapeXMLText: <Text extends string>(text: Exclude<Text, EscapedXMLText>, attr?: boolean) => EscapedXMLText;
39
+ export declare const serializeParentElementXML: (nodeName: string, serializedChildren: readonly string[]) => string;
40
+ export declare const serializeLeafElementXML: (nodeName: string, xmlValue: EscapedXMLText) => string;
41
+ export {};
@@ -1,24 +1,35 @@
1
- import { XFormsXPathEvaluator } from '@getodk/xpath';
2
- interface XFormDOMNormalizationOptions {
1
+ import { KnownAttributeLocalNamedElement } from '../../../common/types/dom.ts';
2
+ interface DOMBindElement extends KnownAttributeLocalNamedElement<'bind', 'nodeset'> {
3
+ }
4
+ export interface DOMItextTranslationElement extends KnownAttributeLocalNamedElement<'translation', 'lang'> {
5
+ }
6
+ export interface DOMSecondaryInstanceElement extends KnownAttributeLocalNamedElement<'instance', 'id'> {
7
+ }
8
+ interface XFormDOMOptions {
3
9
  readonly isNormalized: boolean;
4
10
  }
11
+ /**
12
+ * @todo **Everything** in this class should be cacheable. Maybe not worth it
13
+ * for small forms, but may make a pretty substantial difference for very large
14
+ * forms (in bytes) in sessions creating multiple instances of the same form.
15
+ */
5
16
  export declare class XFormDOM {
6
17
  protected readonly sourceXML: string;
7
18
  static from(sourceXML: string): XFormDOM;
8
19
  protected readonly normalizedXML: string;
9
- readonly rootEvaluator: XFormsXPathEvaluator;
10
- readonly primaryInstanceEvaluator: XFormsXPathEvaluator;
11
20
  readonly xformDocument: XMLDocument;
12
21
  readonly html: Element;
13
22
  readonly head: Element;
14
23
  readonly title: Element;
15
24
  readonly model: Element;
25
+ readonly binds: readonly DOMBindElement[];
16
26
  readonly primaryInstance: Element;
17
27
  readonly primaryInstanceRoot: Element;
28
+ readonly itextTranslationElements: readonly DOMItextTranslationElement[];
29
+ readonly secondaryInstanceElements: readonly DOMSecondaryInstanceElement[];
18
30
  readonly body: Element;
19
- protected constructor(sourceXML: string, options: XFormDOMNormalizationOptions);
20
- createInstance(): XFormDOM;
21
- toJSON(): Omit<this, "head" | "html" | "title" | "toJSON" | "model" | "primaryInstanceRoot" | "xformDocument" | "rootEvaluator" | "primaryInstanceEvaluator" | "primaryInstance" | "createInstance"> & {
31
+ protected constructor(sourceXML: string, options: XFormDOMOptions);
32
+ toJSON(): Omit<this, "head" | "html" | "title" | "toJSON" | "model" | "primaryInstanceRoot" | "primaryInstance" | "xformDocument"> & {
22
33
  xformDocument: string;
23
34
  html: string;
24
35
  head: string;
@@ -2,7 +2,6 @@ import { BodyDefinition } from '../parse/body/BodyDefinition.ts';
2
2
  import { ModelDefinition } from './model/ModelDefinition.ts';
3
3
  import { XFormDOM } from './XFormDOM.ts';
4
4
  export declare class XFormDefinition {
5
- readonly sourceXML: string;
6
5
  readonly xformDOM: XFormDOM;
7
6
  readonly xformDocument: XMLDocument;
8
7
  readonly id: string;
@@ -10,5 +9,5 @@ export declare class XFormDefinition {
10
9
  readonly rootReference: string;
11
10
  readonly body: BodyDefinition;
12
11
  readonly model: ModelDefinition;
13
- constructor(sourceXML: string);
12
+ constructor(xformDOM: XFormDOM);
14
13
  }
@@ -0,0 +1,27 @@
1
+ import { JRResourceURL } from '../../../../common/src/jr-resources/JRResourceURL.ts';
2
+ export type FormAttachmentDataType = 'media' | 'secondary-instance';
3
+ /**
4
+ * @todo This type anticipates work to support media form attachments, which
5
+ * will tend to be associated with binary data. The
6
+ * expectation is that:
7
+ *
8
+ * - {@link Blob} would be appropriate for representing data from attachment
9
+ * resources which are conventionally loaded to completion (where network
10
+ * conditions are favorable), such as images
11
+ *
12
+ * - {@link MediaSource} or {@link ReadableStream} may be more appropriate for
13
+ * representing data from resources which are conventionally streamed in a
14
+ * browser context (often regardless of network conditions), such as video and
15
+ * audio
16
+ */
17
+ export type FormAttachmentMediaData = Blob | MediaSource | ReadableStream<unknown>;
18
+ export type FormAttachmentSecondaryInstanceData = string;
19
+ type FormAttachmentData<DataType extends FormAttachmentDataType> = DataType extends 'media' ? FormAttachmentMediaData : FormAttachmentSecondaryInstanceData;
20
+ export declare abstract class FormAttachmentResource<DataType extends FormAttachmentDataType> {
21
+ readonly dataType: DataType;
22
+ readonly resourceURL: JRResourceURL;
23
+ readonly contentType: string;
24
+ readonly data: FormAttachmentData<DataType>;
25
+ protected constructor(dataType: DataType, resourceURL: JRResourceURL, contentType: string, data: FormAttachmentData<DataType>);
26
+ }
27
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { ParsedTokenList, TokenListParser } from '../../lib/TokenListParser.ts';
2
2
  import { XFormDefinition } from '../../parse/XFormDefinition.ts';
3
3
  import { DependencyContext } from '../expression/abstract/DependencyContext.ts';
4
- import { InputDefinition } from './control/InputDefinition.ts';
4
+ import { InputControlDefinition } from './control/InputControlDefinition.ts';
5
5
  import { RangeControlDefinition } from './control/RangeControlDefinition.ts';
6
6
  import { RankControlDefinition } from './control/RankControlDefinition.ts';
7
7
  import { AnySelectDefinition } from './control/select/SelectDefinition.ts';
@@ -17,7 +17,7 @@ export interface BodyElementParentContext {
17
17
  readonly reference: string | null;
18
18
  readonly element: Element;
19
19
  }
20
- export type ControlElementDefinition = AnySelectDefinition | InputDefinition | RangeControlDefinition | RankControlDefinition | TriggerControlDefinition | UploadControlDefinition;
20
+ export type ControlElementDefinition = AnySelectDefinition | InputControlDefinition | RangeControlDefinition | RankControlDefinition | TriggerControlDefinition | UploadControlDefinition;
21
21
  type SupportedBodyElementDefinition = RepeatElementDefinition | LogicalGroupDefinition | PresentationGroupDefinition | StructuralGroupDefinition | ControlElementDefinition;
22
22
  export type AnyBodyElementDefinition = SupportedBodyElementDefinition | UnsupportedBodyElementDefinition;
23
23
  export type BodyElementDefinitionArray = readonly AnyBodyElementDefinition[];
@@ -70,6 +70,6 @@ export declare class BodyDefinition extends DependencyContext implements BodyEle
70
70
  constructor(form: XFormDefinition);
71
71
  getBodyElement(reference: string): AnyBodyElementDefinition | null;
72
72
  getChildElementDefinitions(form: XFormDefinition, parent: BodyElementParentContext, parentElement: Element, children?: readonly Element[]): readonly AnyBodyElementDefinition[];
73
- toJSON(): Omit<this, "form" | "isTranslated" | "toJSON" | "dependencyExpressions" | "registerDependentExpression" | "getBodyElement" | "getChildElementDefinitions">;
73
+ toJSON(): Omit<this, "form" | "toJSON" | "isTranslated" | "getBodyElement" | "getChildElementDefinitions">;
74
74
  }
75
75
  export {};
@@ -14,5 +14,5 @@ export declare class RepeatElementDefinition extends BodyElementDefinition<'repe
14
14
  readonly noAddRemoveExpression: string | null;
15
15
  readonly children: BodyElementDefinitionArray;
16
16
  constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
17
- toJSON(): Omit<this, "parent" | "form" | "isTranslated" | "toJSON" | "dependencyExpressions" | "registerDependentExpression">;
17
+ toJSON(): Omit<this, "parent" | "form" | "toJSON" | "isTranslated">;
18
18
  }
@@ -1,3 +1,3 @@
1
1
  import { TokenListParser, ParsedTokenList } from '../../../lib/TokenListParser.ts';
2
- export declare const inputAppearanceParser: TokenListParser<"multiline" | "numbers" | "url" | "thousand-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked", "multiline" | "numbers" | "url" | "thousand-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked">;
2
+ export declare const inputAppearanceParser: TokenListParser<"multiline" | "numbers" | "url" | "thousands-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked", "multiline" | "numbers" | "url" | "thousands-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked">;
3
3
  export type InputAppearanceDefinition = ParsedTokenList<typeof inputAppearanceParser>;
@@ -2,7 +2,7 @@ import { XFormDefinition } from '../../XFormDefinition.ts';
2
2
  import { InputAppearanceDefinition } from '../appearance/inputAppearanceParser.ts';
3
3
  import { BodyElementParentContext } from '../BodyDefinition.ts';
4
4
  import { ControlDefinition } from './ControlDefinition.ts';
5
- export declare class InputDefinition extends ControlDefinition<'input'> {
5
+ export declare class InputControlDefinition extends ControlDefinition<'input'> {
6
6
  static isCompatible(localName: string): boolean;
7
7
  readonly type = "input";
8
8
  readonly appearances: InputAppearanceDefinition;
@@ -1,5 +1,4 @@
1
1
  import { DependencyContext } from '../../../expression/abstract/DependencyContext.ts';
2
- import { AnyDependentExpression } from '../../../expression/abstract/DependentExpression.ts';
3
2
  import { ItemsetDefinition } from './ItemsetDefinition.ts';
4
3
  export declare class ItemsetNodesetContext extends DependencyContext {
5
4
  protected readonly itemset: ItemsetDefinition;
@@ -7,5 +6,4 @@ export declare class ItemsetNodesetContext extends DependencyContext {
7
6
  readonly reference: string;
8
7
  constructor(itemset: ItemsetDefinition, nodesetExpression: string);
9
8
  set isTranslated(value: true);
10
- registerDependentExpression(expression: AnyDependentExpression): void;
11
9
  }