@getodk/xforms-engine 0.1.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 (208) hide show
  1. package/README.md +44 -0
  2. package/dist/.vite/manifest.json +7 -0
  3. package/dist/XFormDOM.d.ts +31 -0
  4. package/dist/XFormDataType.d.ts +26 -0
  5. package/dist/XFormDefinition.d.ts +14 -0
  6. package/dist/body/BodyDefinition.d.ts +52 -0
  7. package/dist/body/BodyElementDefinition.d.ts +32 -0
  8. package/dist/body/RepeatDefinition.d.ts +15 -0
  9. package/dist/body/UnsupportedBodyElementDefinition.d.ts +10 -0
  10. package/dist/body/control/ControlDefinition.d.ts +16 -0
  11. package/dist/body/control/InputDefinition.d.ts +5 -0
  12. package/dist/body/control/select/ItemDefinition.d.ts +13 -0
  13. package/dist/body/control/select/ItemsetDefinition.d.ts +16 -0
  14. package/dist/body/control/select/ItemsetNodesetContext.d.ts +11 -0
  15. package/dist/body/control/select/ItemsetNodesetExpression.d.ts +5 -0
  16. package/dist/body/control/select/ItemsetValueExpression.d.ts +6 -0
  17. package/dist/body/control/select/SelectDefinition.d.ts +23 -0
  18. package/dist/body/group/BaseGroupDefinition.d.ts +46 -0
  19. package/dist/body/group/LogicalGroupDefinition.d.ts +6 -0
  20. package/dist/body/group/PresentationGroupDefinition.d.ts +11 -0
  21. package/dist/body/group/RepeatGroupDefinition.d.ts +12 -0
  22. package/dist/body/group/StructuralGroupDefinition.d.ts +6 -0
  23. package/dist/body/text/HintDefinition.d.ts +11 -0
  24. package/dist/body/text/LabelDefinition.d.ts +20 -0
  25. package/dist/body/text/TextElementDefinition.d.ts +32 -0
  26. package/dist/body/text/TextElementOutputPart.d.ts +12 -0
  27. package/dist/body/text/TextElementPart.d.ts +12 -0
  28. package/dist/body/text/TextElementReferencePart.d.ts +6 -0
  29. package/dist/body/text/TextElementStaticPart.d.ts +6 -0
  30. package/dist/client/BaseNode.d.ts +138 -0
  31. package/dist/client/EngineConfig.d.ts +78 -0
  32. package/dist/client/FormLanguage.d.ts +63 -0
  33. package/dist/client/GroupNode.d.ts +24 -0
  34. package/dist/client/OpaqueReactiveObjectFactory.d.ts +70 -0
  35. package/dist/client/RepeatInstanceNode.d.ts +28 -0
  36. package/dist/client/RepeatRangeNode.d.ts +94 -0
  37. package/dist/client/RootNode.d.ts +31 -0
  38. package/dist/client/SelectNode.d.ts +60 -0
  39. package/dist/client/StringNode.d.ts +41 -0
  40. package/dist/client/SubtreeNode.d.ts +52 -0
  41. package/dist/client/TextRange.d.ts +55 -0
  42. package/dist/client/hierarchy.d.ts +48 -0
  43. package/dist/client/index.d.ts +11 -0
  44. package/dist/client/node-types.d.ts +1 -0
  45. package/dist/expression/DependencyContext.d.ts +12 -0
  46. package/dist/expression/DependentExpression.d.ts +43 -0
  47. package/dist/index.d.ts +16 -0
  48. package/dist/index.js +37622 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/instance/Group.d.ts +31 -0
  51. package/dist/instance/RepeatInstance.d.ts +60 -0
  52. package/dist/instance/RepeatRange.d.ts +81 -0
  53. package/dist/instance/Root.d.ts +70 -0
  54. package/dist/instance/SelectField.d.ts +45 -0
  55. package/dist/instance/StringField.d.ts +39 -0
  56. package/dist/instance/Subtree.d.ts +30 -0
  57. package/dist/instance/abstract/DescendantNode.d.ts +76 -0
  58. package/dist/instance/abstract/InstanceNode.d.ts +107 -0
  59. package/dist/instance/children.d.ts +2 -0
  60. package/dist/instance/hierarchy.d.ts +12 -0
  61. package/dist/instance/identity.d.ts +7 -0
  62. package/dist/instance/index.d.ts +8 -0
  63. package/dist/instance/internal-api/EvaluationContext.d.ts +34 -0
  64. package/dist/instance/internal-api/InstanceConfig.d.ts +8 -0
  65. package/dist/instance/internal-api/SubscribableDependency.d.ts +59 -0
  66. package/dist/instance/internal-api/TranslationContext.d.ts +4 -0
  67. package/dist/instance/internal-api/ValueContext.d.ts +22 -0
  68. package/dist/instance/resource.d.ts +10 -0
  69. package/dist/instance/text/FormattedTextStub.d.ts +1 -0
  70. package/dist/instance/text/TextChunk.d.ts +11 -0
  71. package/dist/instance/text/TextRange.d.ts +10 -0
  72. package/dist/lib/dom/query.d.ts +20 -0
  73. package/dist/lib/reactivity/createChildrenState.d.ts +36 -0
  74. package/dist/lib/reactivity/createComputedExpression.d.ts +12 -0
  75. package/dist/lib/reactivity/createSelectItems.d.ts +16 -0
  76. package/dist/lib/reactivity/createValueState.d.ts +44 -0
  77. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +18 -0
  78. package/dist/lib/reactivity/node-state/createClientState.d.ts +9 -0
  79. package/dist/lib/reactivity/node-state/createCurrentState.d.ts +6 -0
  80. package/dist/lib/reactivity/node-state/createEngineState.d.ts +5 -0
  81. package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +22 -0
  82. package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +6 -0
  83. package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +139 -0
  84. package/dist/lib/reactivity/node-state/representations.d.ts +25 -0
  85. package/dist/lib/reactivity/scope.d.ts +23 -0
  86. package/dist/lib/reactivity/text/createFieldHint.d.ts +5 -0
  87. package/dist/lib/reactivity/text/createNodeLabel.d.ts +5 -0
  88. package/dist/lib/reactivity/text/createTextRange.d.ts +19 -0
  89. package/dist/lib/reactivity/types.d.ts +21 -0
  90. package/dist/lib/unique-id.d.ts +27 -0
  91. package/dist/lib/xpath/analysis.d.ts +22 -0
  92. package/dist/model/BindComputation.d.ts +30 -0
  93. package/dist/model/BindDefinition.d.ts +31 -0
  94. package/dist/model/BindElement.d.ts +6 -0
  95. package/dist/model/DescendentNodeDefinition.d.ts +25 -0
  96. package/dist/model/ModelBindMap.d.ts +15 -0
  97. package/dist/model/ModelDefinition.d.ts +10 -0
  98. package/dist/model/NodeDefinition.d.ts +74 -0
  99. package/dist/model/RepeatInstanceDefinition.d.ts +15 -0
  100. package/dist/model/RepeatSequenceDefinition.d.ts +19 -0
  101. package/dist/model/RepeatTemplateDefinition.d.ts +29 -0
  102. package/dist/model/RootDefinition.d.ts +24 -0
  103. package/dist/model/SubtreeDefinition.d.ts +14 -0
  104. package/dist/model/ValueNodeDefinition.d.ts +15 -0
  105. package/dist/solid.js +37273 -0
  106. package/dist/solid.js.map +1 -0
  107. package/package.json +87 -0
  108. package/src/XFormDOM.ts +224 -0
  109. package/src/XFormDataType.ts +64 -0
  110. package/src/XFormDefinition.ts +40 -0
  111. package/src/body/BodyDefinition.ts +202 -0
  112. package/src/body/BodyElementDefinition.ts +62 -0
  113. package/src/body/RepeatDefinition.ts +54 -0
  114. package/src/body/UnsupportedBodyElementDefinition.ts +17 -0
  115. package/src/body/control/ControlDefinition.ts +42 -0
  116. package/src/body/control/InputDefinition.ts +9 -0
  117. package/src/body/control/select/ItemDefinition.ts +31 -0
  118. package/src/body/control/select/ItemsetDefinition.ts +36 -0
  119. package/src/body/control/select/ItemsetNodesetContext.ts +26 -0
  120. package/src/body/control/select/ItemsetNodesetExpression.ts +8 -0
  121. package/src/body/control/select/ItemsetValueExpression.ts +11 -0
  122. package/src/body/control/select/SelectDefinition.ts +74 -0
  123. package/src/body/group/BaseGroupDefinition.ts +137 -0
  124. package/src/body/group/LogicalGroupDefinition.ts +11 -0
  125. package/src/body/group/PresentationGroupDefinition.ts +28 -0
  126. package/src/body/group/RepeatGroupDefinition.ts +91 -0
  127. package/src/body/group/StructuralGroupDefinition.ts +11 -0
  128. package/src/body/text/HintDefinition.ts +26 -0
  129. package/src/body/text/LabelDefinition.ts +54 -0
  130. package/src/body/text/TextElementDefinition.ts +97 -0
  131. package/src/body/text/TextElementOutputPart.ts +27 -0
  132. package/src/body/text/TextElementPart.ts +31 -0
  133. package/src/body/text/TextElementReferencePart.ts +21 -0
  134. package/src/body/text/TextElementStaticPart.ts +26 -0
  135. package/src/client/BaseNode.ts +180 -0
  136. package/src/client/EngineConfig.ts +83 -0
  137. package/src/client/FormLanguage.ts +77 -0
  138. package/src/client/GroupNode.ts +33 -0
  139. package/src/client/OpaqueReactiveObjectFactory.ts +100 -0
  140. package/src/client/README.md +39 -0
  141. package/src/client/RepeatInstanceNode.ts +41 -0
  142. package/src/client/RepeatRangeNode.ts +100 -0
  143. package/src/client/RootNode.ts +36 -0
  144. package/src/client/SelectNode.ts +69 -0
  145. package/src/client/StringNode.ts +46 -0
  146. package/src/client/SubtreeNode.ts +57 -0
  147. package/src/client/TextRange.ts +63 -0
  148. package/src/client/hierarchy.ts +63 -0
  149. package/src/client/index.ts +29 -0
  150. package/src/client/node-types.ts +10 -0
  151. package/src/expression/DependencyContext.ts +53 -0
  152. package/src/expression/DependentExpression.ts +102 -0
  153. package/src/index.ts +35 -0
  154. package/src/instance/Group.ts +82 -0
  155. package/src/instance/RepeatInstance.ts +164 -0
  156. package/src/instance/RepeatRange.ts +214 -0
  157. package/src/instance/Root.ts +264 -0
  158. package/src/instance/SelectField.ts +204 -0
  159. package/src/instance/StringField.ts +93 -0
  160. package/src/instance/Subtree.ts +79 -0
  161. package/src/instance/abstract/DescendantNode.ts +182 -0
  162. package/src/instance/abstract/InstanceNode.ts +257 -0
  163. package/src/instance/children.ts +52 -0
  164. package/src/instance/hierarchy.ts +54 -0
  165. package/src/instance/identity.ts +11 -0
  166. package/src/instance/index.ts +37 -0
  167. package/src/instance/internal-api/EvaluationContext.ts +41 -0
  168. package/src/instance/internal-api/InstanceConfig.ts +9 -0
  169. package/src/instance/internal-api/SubscribableDependency.ts +61 -0
  170. package/src/instance/internal-api/TranslationContext.ts +5 -0
  171. package/src/instance/internal-api/ValueContext.ts +27 -0
  172. package/src/instance/resource.ts +75 -0
  173. package/src/instance/text/FormattedTextStub.ts +8 -0
  174. package/src/instance/text/TextChunk.ts +20 -0
  175. package/src/instance/text/TextRange.ts +23 -0
  176. package/src/lib/dom/query.ts +49 -0
  177. package/src/lib/reactivity/createChildrenState.ts +60 -0
  178. package/src/lib/reactivity/createComputedExpression.ts +114 -0
  179. package/src/lib/reactivity/createSelectItems.ts +163 -0
  180. package/src/lib/reactivity/createValueState.ts +258 -0
  181. package/src/lib/reactivity/materializeCurrentStateChildren.ts +121 -0
  182. package/src/lib/reactivity/node-state/createClientState.ts +51 -0
  183. package/src/lib/reactivity/node-state/createCurrentState.ts +27 -0
  184. package/src/lib/reactivity/node-state/createEngineState.ts +18 -0
  185. package/src/lib/reactivity/node-state/createSharedNodeState.ts +79 -0
  186. package/src/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.ts +85 -0
  187. package/src/lib/reactivity/node-state/createSpecifiedState.ts +229 -0
  188. package/src/lib/reactivity/node-state/representations.ts +64 -0
  189. package/src/lib/reactivity/scope.ts +106 -0
  190. package/src/lib/reactivity/text/createFieldHint.ts +16 -0
  191. package/src/lib/reactivity/text/createNodeLabel.ts +16 -0
  192. package/src/lib/reactivity/text/createTextRange.ts +155 -0
  193. package/src/lib/reactivity/types.ts +27 -0
  194. package/src/lib/unique-id.ts +34 -0
  195. package/src/lib/xpath/analysis.ts +241 -0
  196. package/src/model/BindComputation.ts +88 -0
  197. package/src/model/BindDefinition.ts +104 -0
  198. package/src/model/BindElement.ts +8 -0
  199. package/src/model/DescendentNodeDefinition.ts +56 -0
  200. package/src/model/ModelBindMap.ts +71 -0
  201. package/src/model/ModelDefinition.ts +19 -0
  202. package/src/model/NodeDefinition.ts +146 -0
  203. package/src/model/RepeatInstanceDefinition.ts +39 -0
  204. package/src/model/RepeatSequenceDefinition.ts +53 -0
  205. package/src/model/RepeatTemplateDefinition.ts +150 -0
  206. package/src/model/RootDefinition.ts +121 -0
  207. package/src/model/SubtreeDefinition.ts +50 -0
  208. package/src/model/ValueNodeDefinition.ts +39 -0
@@ -0,0 +1,31 @@
1
+ import type { Accessor } from 'solid-js';
2
+ import type { GroupDefinition, GroupNode } from '../client/GroupNode.ts';
3
+ import type { TextRange } from '../index.ts';
4
+ import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
5
+ import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
+ import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
+ import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
+ import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
9
+ import { DescendantNode } from './abstract/DescendantNode.ts';
10
+ import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
11
+ import type { NodeID } from './identity.ts';
12
+ import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
13
+ import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
14
+ interface GroupStateSpec extends DescendantNodeSharedStateSpec {
15
+ readonly label: Accessor<TextRange<'label'> | null>;
16
+ readonly hint: null;
17
+ readonly children: Accessor<readonly NodeID[]>;
18
+ readonly valueOptions: null;
19
+ readonly value: null;
20
+ }
21
+ export declare class Group extends DescendantNode<GroupDefinition, GroupStateSpec, GeneralChildNode> implements GroupNode, EvaluationContext, SubscribableDependency {
22
+ private readonly childrenState;
23
+ protected readonly state: SharedNodeState<GroupStateSpec>;
24
+ protected engineState: EngineState<GroupStateSpec>;
25
+ readonly currentState: MaterializedChildren<CurrentState<GroupStateSpec>, GeneralChildNode>;
26
+ readonly nodeType = "group";
27
+ constructor(parent: GeneralParentNode, definition: GroupDefinition);
28
+ protected computeReference(parent: GeneralParentNode): string;
29
+ getChildren(): readonly GeneralChildNode[];
30
+ }
31
+ export {};
@@ -0,0 +1,60 @@
1
+ import type { Accessor } from 'solid-js';
2
+ import type { RepeatDefinition, RepeatInstanceNode } from '../client/RepeatInstanceNode.ts';
3
+ import type { TextRange } from '../index.ts';
4
+ import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
5
+ import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
+ import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
+ import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
+ import type { RepeatRange } from './RepeatRange.ts';
9
+ import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
10
+ import { DescendantNode } from './abstract/DescendantNode.ts';
11
+ import type { AnyChildNode, GeneralChildNode } from './hierarchy.ts';
12
+ import type { NodeID } from './identity.ts';
13
+ import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
14
+ import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
15
+ export type { RepeatDefinition };
16
+ interface RepeatInstanceStateSpec extends DescendantNodeSharedStateSpec {
17
+ readonly label: Accessor<TextRange<'label'> | null>;
18
+ readonly hint: null;
19
+ readonly children: Accessor<readonly NodeID[]>;
20
+ readonly valueOptions: null;
21
+ readonly value: null;
22
+ }
23
+ interface RepeatInstanceOptions {
24
+ readonly precedingPrimaryInstanceNode: Comment | Element;
25
+ readonly precedingInstance: RepeatInstance | null;
26
+ }
27
+ export declare class RepeatInstance extends DescendantNode<RepeatDefinition, RepeatInstanceStateSpec, GeneralChildNode> implements RepeatInstanceNode, EvaluationContext, SubscribableDependency {
28
+ readonly parent: RepeatRange;
29
+ private readonly childrenState;
30
+ private readonly currentIndex;
31
+ protected readonly state: SharedNodeState<RepeatInstanceStateSpec>;
32
+ protected engineState: EngineState<RepeatInstanceStateSpec>;
33
+ readonly nodeType = "repeat-instance";
34
+ readonly currentState: MaterializedChildren<CurrentState<RepeatInstanceStateSpec>, GeneralChildNode>;
35
+ constructor(parent: RepeatRange, definition: RepeatDefinition, options: RepeatInstanceOptions);
36
+ protected computeReference(parent: RepeatRange): string;
37
+ protected initializeContextNode(parentContextNode: Element, nodeName: string): Element;
38
+ subscribe(): void;
39
+ getChildren(): readonly GeneralChildNode[];
40
+ /**
41
+ * Performs repeat instance node-specific removal logic, then general node
42
+ * removal logic, in that order:
43
+ *
44
+ * 1. At present, before any reactive state change is performed, the repeat
45
+ * instance's {@link contextNode} is removed from the primary instance's
46
+ * XML DOM backing store (which also removes any descendant nodes from that
47
+ * store, as a side effect). This behavior may become unnecessary if/when
48
+ * we phase out use of this XML DOM backing store. This should be peformed
49
+ * first, so that any following reactive logic which evaluates affected
50
+ * XPath expressions will be performed against a state consistent with the
51
+ * repeat instance's removal (and that of its XML DOM descendants).
52
+ *
53
+ * 2. Performs any remaining removal logic as defined in
54
+ * {@link DescendantNode.remove}.
55
+ *
56
+ * These removal steps **must also** occur before any update to the parent
57
+ * {@link RepeatRange}'s reactive children state.
58
+ */
59
+ remove(this: AnyChildNode): void;
60
+ }
@@ -0,0 +1,81 @@
1
+ import type { Accessor } from 'solid-js';
2
+ import type { RepeatRangeNode } from '../client/RepeatRangeNode.ts';
3
+ import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
4
+ import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
5
+ import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
6
+ import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
7
+ import type { RepeatSequenceDefinition } from '../model/RepeatSequenceDefinition.ts';
8
+ import type { RepeatDefinition } from './RepeatInstance.ts';
9
+ import { RepeatInstance } from './RepeatInstance.ts';
10
+ import type { Root } from './Root.ts';
11
+ import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
12
+ import { DescendantNode } from './abstract/DescendantNode.ts';
13
+ import type { GeneralParentNode } from './hierarchy.ts';
14
+ import type { NodeID } from './identity.ts';
15
+ import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
16
+ import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
17
+ import type { TextRange } from './text/TextRange.ts';
18
+ interface RepeatRangeStateSpec extends DescendantNodeSharedStateSpec {
19
+ readonly hint: null;
20
+ readonly label: Accessor<TextRange<'label'> | null>;
21
+ readonly children: Accessor<readonly NodeID[]>;
22
+ readonly valueOptions: null;
23
+ readonly value: null;
24
+ }
25
+ export declare class RepeatRange extends DescendantNode<RepeatSequenceDefinition, RepeatRangeStateSpec, RepeatInstance> implements RepeatRangeNode, EvaluationContext, SubscribableDependency {
26
+ /**
27
+ * A repeat range doesn't have a corresponding primary instance element of its
28
+ * own, and its instances are appended to the range's parent element. During
29
+ * creation of the initial primary instance state and DOM trees, we _could_
30
+ * reliably append all of the range's instances in order as the definition
31
+ * tree is recursed. But that would fail to handle some instance addition
32
+ * cases afterwards.
33
+ *
34
+ * Most notably, we need to know where in the primary instance tree to append
35
+ * instances created for a range which is currently empty. As a lucky
36
+ * coincidence, this need coincides with the ability to add instances at any
37
+ * arbitrary index within the range. In each case, we can reference a primary
38
+ * instance DOM node which will become the new instance's preceding sibling.
39
+ * Where the range is empty, we use this {@link Comment} node (itself created
40
+ * and appended during range initialization) in lieu of a nonexistent
41
+ * preceding instance's {@link contextNode}.
42
+ *
43
+ * @todo We likely want to remove these during submission serialization.
44
+ * @todo Can we use a
45
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Range | DOM Range}
46
+ * instead?
47
+ */
48
+ private readonly anchorNode;
49
+ private readonly childrenState;
50
+ protected readonly state: SharedNodeState<RepeatRangeStateSpec>;
51
+ protected engineState: EngineState<RepeatRangeStateSpec>;
52
+ readonly nodeType = "repeat-range";
53
+ readonly currentState: MaterializedChildren<CurrentState<RepeatRangeStateSpec>, RepeatInstance>;
54
+ constructor(parent: GeneralParentNode, definition: RepeatSequenceDefinition);
55
+ private getLastIndex;
56
+ protected initializeContextNode(parentContextNode: Element): Element;
57
+ protected computeReference(parent: GeneralParentNode): string;
58
+ getInstanceIndex(instance: RepeatInstance): number;
59
+ addInstances(afterIndex?: number, count?: number, definition?: RepeatDefinition): Root;
60
+ /**
61
+ * Removes the {@link RepeatInstance}s corresponding to the specified range of
62
+ * indexes, and then removes those repeat instances from the repeat range's
63
+ * own children state in that order:
64
+ *
65
+ * 1. Identify the set of {@link RepeatInstance}s to be removed.
66
+ *
67
+ * 2. For each {@link RepeatInstance} pending removal, perform that node's
68
+ * removal logic. @see {@link RepeatInstance.remove} for more detail.
69
+ *
70
+ * 3. Finalize update to the repeat range's own {@link childrenState},
71
+ * omitting those {@link RepeatInstance}s which were removed.
72
+ *
73
+ * This ordering ensures a consistent representation of state is established
74
+ * prior to any downstream reactive updates, and ensures that removed nodes'
75
+ * reactivity is cleaned up.
76
+ */
77
+ removeInstances(startIndex: number, count?: number): Root;
78
+ subscribe(): void;
79
+ getChildren(): readonly RepeatInstance[];
80
+ }
81
+ export {};
@@ -0,0 +1,70 @@
1
+ import type { XFormsXPathEvaluator } from '@getodk/xpath';
2
+ import type { Accessor, Signal } from 'solid-js';
3
+ import type { XFormDOM } from '../XFormDOM.ts';
4
+ import type { ActiveLanguage, FormLanguage, FormLanguages } from '../client/FormLanguage.ts';
5
+ import type { RootNode } from '../client/RootNode.ts';
6
+ import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
7
+ import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
8
+ import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
9
+ import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
10
+ import type { RootDefinition } from '../model/RootDefinition.ts';
11
+ import { InstanceNode } from './abstract/InstanceNode.ts';
12
+ import type { GeneralChildNode } from './hierarchy.ts';
13
+ import type { NodeID } from './identity.ts';
14
+ import type { EvaluationContext, EvaluationContextRoot } from './internal-api/EvaluationContext.ts';
15
+ import type { InstanceConfig } from './internal-api/InstanceConfig.ts';
16
+ import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
17
+ import type { TranslationContext } from './internal-api/TranslationContext.ts';
18
+ interface RootStateSpec {
19
+ readonly reference: string;
20
+ readonly readonly: boolean;
21
+ readonly relevant: boolean;
22
+ readonly required: boolean;
23
+ readonly label: null;
24
+ readonly hint: null;
25
+ readonly children: Accessor<readonly NodeID[]>;
26
+ readonly valueOptions: null;
27
+ readonly value: null;
28
+ readonly activeLanguage: Signal<ActiveLanguage>;
29
+ }
30
+ export declare class Root extends InstanceNode<RootDefinition, RootStateSpec, GeneralChildNode> implements RootNode, EvaluationContext, EvaluationContextRoot, SubscribableDependency, TranslationContext {
31
+ static initialize(xformDOM: XFormDOM, definition: RootDefinition, engineConfig: InstanceConfig): Promise<Root>;
32
+ private readonly childrenState;
33
+ protected readonly state: SharedNodeState<RootStateSpec>;
34
+ protected readonly engineState: EngineState<RootStateSpec>;
35
+ readonly nodeType = "root";
36
+ readonly currentState: MaterializedChildren<CurrentState<RootStateSpec>, GeneralChildNode>;
37
+ protected readonly instanceDOM: XFormDOM;
38
+ readonly root: this;
39
+ readonly evaluator: XFormsXPathEvaluator;
40
+ private readonly rootReference;
41
+ get contextReference(): string;
42
+ readonly contextNode: Element;
43
+ readonly parent: null;
44
+ readonly languages: FormLanguages;
45
+ get activeLanguage(): ActiveLanguage;
46
+ protected constructor(xformDOM: XFormDOM, definition: RootDefinition, engineConfig: InstanceConfig);
47
+ /**
48
+ * Waits until form state is fully initialized.
49
+ *
50
+ * As much as possible, all instance state computations are implemented so
51
+ * that they complete synchronously.
52
+ *
53
+ * There is currently one exception: because instance nodes may form
54
+ * computation dependencies into their descendants as well as their ancestors,
55
+ * there is an allowance **during form initialization only** to account for
56
+ * this chicken/egg scenario. Note that this allowance is intentionally,
57
+ * strictly limited: if form state initialization is not resolved within a
58
+ * single microtask tick we throw/reject.
59
+ *
60
+ * All subsequent computations are always performed synchronously (and we will
61
+ * use tests to validate this, by utilizing the synchronously returned `Root`
62
+ * state from client-facing write interfaces).
63
+ */
64
+ formStateInitialized(): Promise<void>;
65
+ protected computeReference(_parent: null, definition: RootDefinition): string;
66
+ getChildren(): readonly GeneralChildNode[];
67
+ setLanguage(language: FormLanguage): Root;
68
+ subscribe(): void;
69
+ }
70
+ export {};
@@ -0,0 +1,45 @@
1
+ import type { Accessor } from 'solid-js';
2
+ import type { AnySelectDefinition } from '../body/control/select/SelectDefinition.ts';
3
+ import type { SelectItem, SelectNode } from '../client/SelectNode.ts';
4
+ import type { TextRange } from '../index.ts';
5
+ import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
+ import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
+ import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
+ import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
9
+ import type { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
10
+ import type { Root } from './Root.ts';
11
+ import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
12
+ import { DescendantNode } from './abstract/DescendantNode.ts';
13
+ import type { GeneralParentNode } from './hierarchy.ts';
14
+ import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
15
+ import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
16
+ import type { ValueContext } from './internal-api/ValueContext.ts';
17
+ export interface SelectFieldDefinition extends ValueNodeDefinition {
18
+ readonly bodyElement: AnySelectDefinition;
19
+ }
20
+ interface SelectFieldStateSpec extends DescendantNodeStateSpec<readonly SelectItem[]> {
21
+ readonly label: Accessor<TextRange<'label'> | null>;
22
+ readonly hint: Accessor<TextRange<'hint'> | null>;
23
+ readonly children: null;
24
+ readonly value: SimpleAtomicState<readonly SelectItem[]>;
25
+ readonly valueOptions: Accessor<readonly SelectItem[]>;
26
+ }
27
+ export declare class SelectField extends DescendantNode<SelectFieldDefinition, SelectFieldStateSpec, null> implements SelectNode, EvaluationContext, SubscribableDependency, ValueContext<readonly SelectItem[]> {
28
+ private readonly selectExclusive;
29
+ protected readonly state: SharedNodeState<SelectFieldStateSpec>;
30
+ protected engineState: EngineState<SelectFieldStateSpec>;
31
+ readonly nodeType = "select";
32
+ readonly currentState: CurrentState<SelectFieldStateSpec>;
33
+ readonly encodeValue: (runtimeValue: readonly SelectItem[]) => string;
34
+ readonly decodeValue: (instanceValue: string) => readonly SelectItem[];
35
+ protected readonly getValueOptions: Accessor<readonly SelectItem[]>;
36
+ constructor(parent: GeneralParentNode, definition: SelectFieldDefinition);
37
+ protected getSelectItemsByValue(valueOptions?: readonly SelectItem[]): ReadonlyMap<string, SelectItem>;
38
+ protected computeReference(parent: GeneralParentNode): string;
39
+ protected updateSelectedItemValues(values: readonly string[]): void;
40
+ protected setSelectedItemValue(value: string | null): void;
41
+ select(selectedItem: SelectItem): Root;
42
+ deselect(deselectedItem: SelectItem): Root;
43
+ getChildren(): readonly [];
44
+ }
45
+ export {};
@@ -0,0 +1,39 @@
1
+ import type { Accessor } from 'solid-js';
2
+ import type { InputDefinition } from '../body/control/InputDefinition.ts';
3
+ import type { StringNode } from '../client/StringNode.ts';
4
+ import type { TextRange } from '../index.ts';
5
+ import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
+ import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
+ import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
+ import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
9
+ import type { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
10
+ import type { Root } from './Root.ts';
11
+ import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
12
+ import { DescendantNode } from './abstract/DescendantNode.ts';
13
+ import type { GeneralParentNode } from './hierarchy.ts';
14
+ import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
15
+ import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
16
+ import type { ValueContext } from './internal-api/ValueContext.ts';
17
+ export interface StringFieldDefinition extends ValueNodeDefinition {
18
+ readonly bodyElement: InputDefinition | null;
19
+ }
20
+ interface StringFieldStateSpec extends DescendantNodeStateSpec<string> {
21
+ readonly label: Accessor<TextRange<'label'> | null>;
22
+ readonly hint: Accessor<TextRange<'hint'> | null>;
23
+ readonly children: null;
24
+ readonly value: SimpleAtomicState<string>;
25
+ readonly valueOptions: null;
26
+ }
27
+ export declare class StringField extends DescendantNode<StringFieldDefinition, StringFieldStateSpec, null> implements StringNode, EvaluationContext, SubscribableDependency, ValueContext<string> {
28
+ protected readonly state: SharedNodeState<StringFieldStateSpec>;
29
+ protected engineState: EngineState<StringFieldStateSpec>;
30
+ readonly nodeType = "string";
31
+ readonly currentState: CurrentState<StringFieldStateSpec>;
32
+ readonly encodeValue: (value: string) => string;
33
+ readonly decodeValue: (value: string) => string;
34
+ constructor(parent: GeneralParentNode, definition: StringFieldDefinition);
35
+ protected computeReference(parent: GeneralParentNode): string;
36
+ getChildren(): readonly [];
37
+ setValue(value: string): Root;
38
+ }
39
+ export {};
@@ -0,0 +1,30 @@
1
+ import { type Accessor } from 'solid-js';
2
+ import type { SubtreeDefinition, SubtreeNode } from '../client/SubtreeNode.ts';
3
+ import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
4
+ import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
5
+ import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
6
+ import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
7
+ import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
8
+ import { DescendantNode } from './abstract/DescendantNode.ts';
9
+ import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
10
+ import type { NodeID } from './identity.ts';
11
+ import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
12
+ import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
13
+ interface SubtreeStateSpec extends DescendantNodeSharedStateSpec {
14
+ readonly label: null;
15
+ readonly hint: null;
16
+ readonly children: Accessor<readonly NodeID[]>;
17
+ readonly valueOptions: null;
18
+ readonly value: null;
19
+ }
20
+ export declare class Subtree extends DescendantNode<SubtreeDefinition, SubtreeStateSpec, GeneralChildNode> implements SubtreeNode, EvaluationContext, SubscribableDependency {
21
+ private readonly childrenState;
22
+ protected readonly state: SharedNodeState<SubtreeStateSpec>;
23
+ protected engineState: EngineState<SubtreeStateSpec>;
24
+ readonly nodeType = "subtree";
25
+ readonly currentState: MaterializedChildren<CurrentState<SubtreeStateSpec>, GeneralChildNode>;
26
+ constructor(parent: GeneralParentNode, definition: SubtreeDefinition);
27
+ protected computeReference(parent: GeneralParentNode): string;
28
+ getChildren(): readonly GeneralChildNode[];
29
+ }
30
+ export {};
@@ -0,0 +1,76 @@
1
+ import type { XFormsXPathEvaluator } from '@getodk/xpath';
2
+ import type { Accessor } from 'solid-js';
3
+ import type { BaseNode } from '../../client/BaseNode.ts';
4
+ import type { AnyDescendantNodeDefinition } from '../../model/DescendentNodeDefinition.ts';
5
+ import type { AnyNodeDefinition } from '../../model/NodeDefinition.ts';
6
+ import type { RepeatInstanceDefinition } from '../../model/RepeatInstanceDefinition.ts';
7
+ import type { ValueNodeDefinition } from '../../model/ValueNodeDefinition.ts';
8
+ import type { RepeatRange } from '../RepeatRange.ts';
9
+ import type { Root } from '../Root.ts';
10
+ import type { AnyChildNode, GeneralParentNode } from '../hierarchy.ts';
11
+ import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
12
+ import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
13
+ import type { InstanceNodeStateSpec } from './InstanceNode.ts';
14
+ import { InstanceNode } from './InstanceNode.ts';
15
+ export interface DescendantNodeSharedStateSpec {
16
+ readonly reference: Accessor<string>;
17
+ readonly readonly: Accessor<boolean>;
18
+ readonly relevant: Accessor<boolean>;
19
+ readonly required: Accessor<boolean>;
20
+ }
21
+ export type DescendantNodeStateSpec<Value = never> = InstanceNodeStateSpec<Value> & DescendantNodeSharedStateSpec;
22
+ export type DescendantNodeDefinition = Extract<AnyNodeDefinition, AnyDescendantNodeDefinition>;
23
+ export type DescendantNodeParent<Definition extends DescendantNodeDefinition> = Definition extends ValueNodeDefinition ? GeneralParentNode : Definition extends RepeatInstanceDefinition ? RepeatRange : GeneralParentNode;
24
+ export type AnyDescendantNode = DescendantNode<DescendantNodeDefinition, DescendantNodeStateSpec<any>, any>;
25
+ export declare abstract class DescendantNode<Definition extends DescendantNodeDefinition, Spec extends DescendantNodeStateSpec<any>, Child extends AnyChildNode | null = null> extends InstanceNode<Definition, Spec, Child> implements BaseNode, EvaluationContext, SubscribableDependency {
26
+ readonly parent: DescendantNodeParent<Definition>;
27
+ readonly definition: Definition;
28
+ readonly root: Root;
29
+ readonly evaluator: XFormsXPathEvaluator;
30
+ readonly contextNode: Element;
31
+ constructor(parent: DescendantNodeParent<Definition>, definition: Definition);
32
+ protected computeChildStepReference(parent: DescendantNodeParent<Definition>): string;
33
+ protected abstract computeReference(parent: DescendantNodeParent<Definition>, definition: Definition): string;
34
+ protected buildSharedStateSpec(parent: DescendantNodeParent<Definition>, definition: Definition): DescendantNodeSharedStateSpec;
35
+ protected createContextNode(parentContextNode: Element, nodeName: string): Element;
36
+ /**
37
+ * Currently expected to be overridden by...
38
+ *
39
+ * - Repeat range: returns its parent's context node, because it doesn't have
40
+ * a node in the primary instance tree.
41
+ *
42
+ * - Repeat instance: returns its created context node, but overrides handles
43
+ * appending behavior separately (for inserting at the end of its parent
44
+ * range, or even at an arbitrary index within the range, after instance
45
+ * creation is has completed).
46
+ */
47
+ protected initializeContextNode(parentContextNode: Element, nodeName: string): Element;
48
+ /**
49
+ * @package
50
+ *
51
+ * Performs recursive removal, first of the node's descendants, then of the
52
+ * node itself. For all {@link DescendantNode}s, removal involves **at least**
53
+ * disposal of its {@link scope} ({@link ReactiveScope}).
54
+ *
55
+ * It is expected that the outermost node targeted for removal will always be
56
+ * a {@link RepeatInstance}. @see {@link RepeatInstance.remove} for additional
57
+ * details.
58
+ *
59
+ * It is also expected that upon that outermost node's removal, its parent
60
+ * {@link RepeatRange} will perform a reactive update to its children state so
61
+ * that:
62
+ *
63
+ * 1. Any downstream computations affected by the removal are updated.
64
+ * 2. The client invoking removal is also reactively updated (where
65
+ * applicable).
66
+ *
67
+ * @see {@link RepeatInstance.remove} and {@link RepeatRange.removeInstances}
68
+ * for additional details about their respective node-specific removal
69
+ * behaviors and ordering.
70
+ *
71
+ * @todo Possibly retain removed repeat instances in memory. This came up as a
72
+ * behavior of Collect/JavaRosa, and we should investigate the details and
73
+ * ramifications of that, and whether it's the desired behavior.
74
+ */
75
+ remove(this: AnyChildNode): void;
76
+ }
@@ -0,0 +1,107 @@
1
+ import type { XFormsXPathEvaluator } from '@getodk/xpath';
2
+ import type { Accessor, Signal } from 'solid-js';
3
+ import type { BaseNode } from '../../client/BaseNode.ts';
4
+ import type { InstanceNodeType } from '../../client/node-types.ts';
5
+ import type { TextRange } from '../../index.ts';
6
+ import type { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
7
+ import type { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
8
+ import type { SharedNodeState } from '../../lib/reactivity/node-state/createSharedNodeState.ts';
9
+ import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
10
+ import type { SimpleAtomicState } from '../../lib/reactivity/types.ts';
11
+ import type { AnyNodeDefinition } from '../../model/NodeDefinition.ts';
12
+ import type { Root } from '../Root.ts';
13
+ import type { AnyChildNode, AnyNode, AnyParentNode } from '../hierarchy.ts';
14
+ import type { NodeID } from '../identity.ts';
15
+ import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
16
+ import type { InstanceConfig } from '../internal-api/InstanceConfig.ts';
17
+ import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
18
+ export interface InstanceNodeStateSpec<Value = never> {
19
+ readonly reference: Accessor<string> | string;
20
+ readonly readonly: Accessor<boolean> | boolean;
21
+ readonly relevant: Accessor<boolean> | boolean;
22
+ readonly required: Accessor<boolean> | boolean;
23
+ readonly label: Accessor<TextRange<'label'> | null> | null;
24
+ readonly hint: Accessor<TextRange<'hint'> | null> | null;
25
+ readonly children: Accessor<readonly NodeID[]> | null;
26
+ readonly valueOptions: Accessor<null> | Accessor<readonly unknown[]> | null;
27
+ readonly value: Signal<Value> | SimpleAtomicState<Value> | null;
28
+ }
29
+ type AnyInstanceNode = InstanceNode<AnyNodeDefinition, InstanceNodeStateSpec<any>, any>;
30
+ interface InitializedStateOptions<T, K extends keyof T> {
31
+ readonly uninitializedFallback: T[K];
32
+ }
33
+ /**
34
+ * This type has the same effect as {@link MaterializedChildren}, but abstractly
35
+ * handles leaf node types as well.
36
+ */
37
+ export type InstanceNodeCurrentState<Spec extends InstanceNodeStateSpec<any>, Child> = CurrentState<Omit<Spec, 'children'>> & {
38
+ readonly children: [Child] extends [AnyChildNode] ? readonly Child[] : null;
39
+ };
40
+ export declare abstract class InstanceNode<Definition extends AnyNodeDefinition, Spec extends InstanceNodeStateSpec<any>, Child extends AnyChildNode | null = null> implements BaseNode, EvaluationContext, SubscribableDependency {
41
+ readonly engineConfig: InstanceConfig;
42
+ readonly parent: AnyParentNode | null;
43
+ readonly definition: Definition;
44
+ protected readonly isStateInitialized: Accessor<boolean>;
45
+ protected abstract readonly state: SharedNodeState<Spec>;
46
+ protected abstract readonly engineState: EngineState<Spec>;
47
+ /**
48
+ * Provides a generalized mechanism for accessing a reactive state value
49
+ * during a node's construction, while {@link engineState} is still being
50
+ * defined and thus isn't assigned.
51
+ *
52
+ * The fallback value specified in {@link options} will be returned on access
53
+ * until {@link isStateInitialized} returns true. This ensures:
54
+ *
55
+ * - a value of the expected type will be available
56
+ * - any read access will become reactive to the actual state, once it has
57
+ * been initialized and {@link engineState} is assigned
58
+ *
59
+ * @todo This is one among several chicken/egg problems encountered trying to
60
+ * support state initialization in which some aspects of the state derive from
61
+ * other aspects of it. It would be nice to dispense with this entirely. But
62
+ * if it must persist, we should also consider replacing the method with a
63
+ * direct accessor once state initialization completes, so the initialized
64
+ * check is only called until it becomes impertinent.
65
+ */
66
+ protected getInitializedState<K extends keyof EngineState<Spec>>(key: K, options: InitializedStateOptions<EngineState<Spec>, K>): EngineState<Spec>[K];
67
+ /**
68
+ * @package Exposed on every node type to facilitate inheritance, as well as
69
+ * conditional behavior for value nodes.
70
+ */
71
+ get isReadonly(): boolean;
72
+ /**
73
+ * @package Exposed on every node type to facilitate inheritance, as well as
74
+ * conditional behavior for value nodes.
75
+ */
76
+ get isRelevant(): boolean;
77
+ readonly nodeId: NodeID;
78
+ abstract readonly nodeType: InstanceNodeType;
79
+ abstract readonly currentState: InstanceNodeCurrentState<Spec, Child>;
80
+ abstract readonly root: Root;
81
+ abstract readonly evaluator: XFormsXPathEvaluator;
82
+ readonly scope: ReactiveScope;
83
+ get contextReference(): string;
84
+ abstract readonly contextNode: Element;
85
+ constructor(engineConfig: InstanceConfig, parent: AnyParentNode | null, definition: Definition);
86
+ /**
87
+ * @package This presently serves a few internal use cases, where certain
88
+ * behaviors depend on arbitrary traversal from any point in the instance
89
+ * tree, without particular regard for the visited node type. It isn't
90
+ * intended for external traversal or any other means of consuming children by
91
+ * a client. This return type intentionally deviates from one structural
92
+ * expectation, requiring even leaf nodes to return an array (though for those
93
+ * nodes it will always be empty). This affords consistency and efficiency of
94
+ * interface for those internal uses.
95
+ */
96
+ abstract getChildren(this: AnyInstanceNode): readonly AnyChildNode[];
97
+ protected abstract computeReference(parent: AnyInstanceNode | null, definition: Definition): string;
98
+ getNodeByReference(this: AnyNode, visited: WeakSet<AnyNode>, dependencyReference: string): SubscribableDependency | null;
99
+ getSubscribableDependencyByReference(this: AnyNode, reference: string): SubscribableDependency | null;
100
+ /**
101
+ * This is a default implementation suitable for most node types. The rest
102
+ * (currently: `Root`, `RepeatRange`, `RepeatInstance`) should likely extend
103
+ * this behavior, rather than simply overriding it.
104
+ */
105
+ subscribe(): void;
106
+ }
107
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
2
+ export declare const buildChildren: (parent: GeneralParentNode) => GeneralChildNode[];
@@ -0,0 +1,12 @@
1
+ import type { Group } from './Group.ts';
2
+ import type { RepeatInstance } from './RepeatInstance.ts';
3
+ import type { RepeatRange } from './RepeatRange.ts';
4
+ import type { Root } from './Root.ts';
5
+ import type { SelectField } from './SelectField.ts';
6
+ import type { StringField } from './StringField.ts';
7
+ import type { Subtree } from './Subtree.ts';
8
+ export type AnyNode = Root | Group | Subtree | RepeatRange | RepeatInstance | StringField | SelectField;
9
+ export type AnyParentNode = Root | Group | Subtree | RepeatRange | RepeatInstance;
10
+ export type GeneralParentNode = Root | Group | Subtree | RepeatInstance;
11
+ export type AnyChildNode = Group | Subtree | RepeatRange | RepeatInstance | StringField | SelectField;
12
+ export type GeneralChildNode = Group | Subtree | RepeatRange | StringField | SelectField;
@@ -0,0 +1,7 @@
1
+ declare const NODE_ID_BRAND: unique symbol;
2
+ type NODE_ID_BRAND = typeof NODE_ID_BRAND;
3
+ export type NodeID = string & {
4
+ readonly [NODE_ID_BRAND]: true;
5
+ };
6
+ export declare const declareNodeID: (id: string) => NodeID;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { RootNode } from '../client/RootNode.ts';
2
+ import type { InitializeFormOptions as BaseInitializeFormOptions, FormResource } from '../client/index.ts';
3
+ import type { InstanceConfig } from './internal-api/InstanceConfig.ts';
4
+ interface InitializeFormOptions extends BaseInitializeFormOptions {
5
+ readonly config: Partial<InstanceConfig>;
6
+ }
7
+ export declare const initializeForm: (input: FormResource, options?: Partial<InitializeFormOptions>) => Promise<RootNode>;
8
+ export {};
@@ -0,0 +1,34 @@
1
+ import type { XFormsXPathEvaluator } from '@getodk/xpath';
2
+ import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
3
+ import type { SubscribableDependency } from './SubscribableDependency.ts';
4
+ import type { TranslationContext } from './TranslationContext.ts';
5
+ export interface EvaluationContextRoot extends SubscribableDependency, TranslationContext {
6
+ }
7
+ /**
8
+ * Provides a common interface to establish context for XPath-based
9
+ * computations, i.e. to evaluate {@link DependentExpression}s where:
10
+ *
11
+ * - the expression may have dynamic dependency **references** (e.g. relative
12
+ * references resolve to repeat instances or their descendants)
13
+ * - the expression may reference dynamic dependency **values** (e.g. an
14
+ * expression referencing the value of another node)
15
+ * - the expression may be dependent on the form's currently active language
16
+ * (e.g. `jr:itext`)
17
+ * - any dynamic case is expected to be internally reactive
18
+ */
19
+ export interface EvaluationContext {
20
+ readonly scope: ReactiveScope;
21
+ readonly evaluator: XFormsXPathEvaluator;
22
+ readonly root: EvaluationContextRoot;
23
+ /**
24
+ * Produces the current absolute reference to the {@link contextNode}, where
25
+ * the absolute `/` resolves to the active form state's primary instance root.
26
+ */
27
+ get contextReference(): string;
28
+ readonly contextNode: Node;
29
+ /**
30
+ * Resolves a nodeset reference, possibly relative to the
31
+ * {@link EvaluationContext.contextNode}.
32
+ */
33
+ readonly getSubscribableDependencyByReference: (reference: string) => SubscribableDependency | null;
34
+ }
@@ -0,0 +1,8 @@
1
+ import type { EngineConfig } from '../../client/EngineConfig.ts';
2
+ import type { CreateUniqueId } from '../../lib/unique-id.ts';
3
+ export interface InstanceConfig extends Required<EngineConfig> {
4
+ /**
5
+ * Uniqueness per form instance session (so e.g. persistence isn't necessary).
6
+ */
7
+ readonly createUniqueId: CreateUniqueId;
8
+ }