@getodk/xforms-engine 0.1.0 → 0.2.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 (157) hide show
  1. package/dist/.vite/manifest.json +1 -0
  2. package/dist/XFormDOM.d.ts +1 -0
  3. package/dist/XFormDataType.d.ts +2 -1
  4. package/dist/XFormDefinition.d.ts +1 -0
  5. package/dist/body/BodyDefinition.d.ts +27 -9
  6. package/dist/body/BodyElementDefinition.d.ts +5 -4
  7. package/dist/body/RepeatElementDefinition.d.ts +19 -0
  8. package/dist/body/UnsupportedBodyElementDefinition.d.ts +3 -2
  9. package/dist/body/appearance/inputAppearanceParser.d.ts +4 -0
  10. package/dist/body/appearance/selectAppearanceParser.d.ts +4 -0
  11. package/dist/body/appearance/structureElementAppearanceParser.d.ts +4 -0
  12. package/dist/body/control/ControlDefinition.d.ts +5 -2
  13. package/dist/body/control/InputDefinition.d.ts +6 -0
  14. package/dist/body/control/select/ItemDefinition.d.ts +4 -3
  15. package/dist/body/control/select/ItemsetDefinition.d.ts +4 -3
  16. package/dist/body/control/select/ItemsetNodesetContext.d.ts +3 -2
  17. package/dist/body/control/select/ItemsetNodesetExpression.d.ts +2 -1
  18. package/dist/body/control/select/ItemsetValueExpression.d.ts +2 -1
  19. package/dist/body/control/select/SelectDefinition.d.ts +16 -5
  20. package/dist/body/group/BaseGroupDefinition.d.ts +6 -10
  21. package/dist/body/group/LogicalGroupDefinition.d.ts +1 -0
  22. package/dist/body/group/PresentationGroupDefinition.d.ts +3 -2
  23. package/dist/body/group/StructuralGroupDefinition.d.ts +1 -0
  24. package/dist/body/text/HintDefinition.d.ts +4 -4
  25. package/dist/body/text/LabelDefinition.d.ts +9 -7
  26. package/dist/body/text/TextElementDefinition.d.ts +9 -8
  27. package/dist/body/text/TextElementOutputPart.d.ts +2 -1
  28. package/dist/body/text/TextElementPart.d.ts +5 -4
  29. package/dist/body/text/TextElementReferencePart.d.ts +2 -1
  30. package/dist/body/text/TextElementStaticPart.d.ts +2 -1
  31. package/dist/client/BaseNode.d.ts +9 -3
  32. package/dist/client/EngineConfig.d.ts +2 -1
  33. package/dist/client/GroupNode.d.ts +10 -6
  34. package/dist/client/NodeAppearances.d.ts +15 -0
  35. package/dist/client/RepeatInstanceNode.d.ts +10 -6
  36. package/dist/client/RepeatRangeNode.d.ts +11 -7
  37. package/dist/client/RootNode.d.ts +24 -4
  38. package/dist/client/SelectNode.d.ts +10 -6
  39. package/dist/client/StringNode.d.ts +9 -5
  40. package/dist/client/SubtreeNode.d.ts +6 -4
  41. package/dist/client/TextRange.d.ts +2 -1
  42. package/dist/client/hierarchy.d.ts +9 -8
  43. package/dist/client/index.d.ts +3 -2
  44. package/dist/expression/DependencyContext.d.ts +2 -1
  45. package/dist/expression/DependentExpression.d.ts +3 -2
  46. package/dist/index.d.ts +2 -1
  47. package/dist/index.js +1882 -1757
  48. package/dist/index.js.map +1 -1
  49. package/dist/instance/Group.d.ts +15 -15
  50. package/dist/instance/RepeatInstance.d.ts +39 -15
  51. package/dist/instance/RepeatRange.d.ts +98 -20
  52. package/dist/instance/Root.d.ts +25 -39
  53. package/dist/instance/SelectField.d.ts +17 -17
  54. package/dist/instance/StringField.d.ts +17 -17
  55. package/dist/instance/Subtree.d.ts +13 -13
  56. package/dist/instance/abstract/DescendantNode.d.ts +26 -18
  57. package/dist/instance/abstract/InstanceNode.d.ts +44 -46
  58. package/dist/instance/children.d.ts +2 -1
  59. package/dist/instance/hierarchy.d.ts +8 -7
  60. package/dist/instance/index.d.ts +4 -3
  61. package/dist/instance/internal-api/EvaluationContext.d.ts +10 -8
  62. package/dist/instance/internal-api/InstanceConfig.d.ts +3 -2
  63. package/dist/instance/internal-api/SubscribableDependency.d.ts +2 -1
  64. package/dist/instance/internal-api/TranslationContext.d.ts +2 -1
  65. package/dist/instance/internal-api/ValueContext.d.ts +6 -5
  66. package/dist/instance/resource.d.ts +3 -2
  67. package/dist/instance/text/TextChunk.d.ts +4 -3
  68. package/dist/instance/text/TextRange.d.ts +2 -1
  69. package/dist/lib/TokenListParser.d.ts +84 -0
  70. package/dist/lib/dom/query.d.ts +8 -2
  71. package/dist/lib/reactivity/createChildrenState.d.ts +4 -3
  72. package/dist/lib/reactivity/createComputedExpression.d.ts +4 -3
  73. package/dist/lib/reactivity/createSelectItems.d.ts +4 -3
  74. package/dist/lib/reactivity/createValueState.d.ts +3 -2
  75. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +6 -4
  76. package/dist/lib/reactivity/node-state/createClientState.d.ts +7 -6
  77. package/dist/lib/reactivity/node-state/createCurrentState.d.ts +5 -4
  78. package/dist/lib/reactivity/node-state/createEngineState.d.ts +4 -3
  79. package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +7 -6
  80. package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +2 -1
  81. package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +3 -2
  82. package/dist/lib/reactivity/node-state/representations.d.ts +2 -1
  83. package/dist/lib/reactivity/scope.d.ts +2 -1
  84. package/dist/lib/reactivity/text/createFieldHint.d.ts +4 -3
  85. package/dist/lib/reactivity/text/createNodeLabel.d.ts +4 -3
  86. package/dist/lib/reactivity/text/createTextRange.d.ts +6 -5
  87. package/dist/lib/reactivity/types.d.ts +2 -1
  88. package/dist/lib/xpath/analysis.d.ts +2 -1
  89. package/dist/model/BindComputation.d.ts +2 -1
  90. package/dist/model/BindDefinition.d.ts +6 -5
  91. package/dist/model/DescendentNodeDefinition.d.ts +6 -6
  92. package/dist/model/ModelBindMap.d.ts +4 -3
  93. package/dist/model/ModelDefinition.d.ts +2 -1
  94. package/dist/model/NodeDefinition.d.ts +20 -19
  95. package/dist/model/RepeatInstanceDefinition.d.ts +7 -7
  96. package/dist/model/{RepeatSequenceDefinition.d.ts → RepeatRangeDefinition.d.ts} +7 -6
  97. package/dist/model/RepeatTemplateDefinition.d.ts +8 -8
  98. package/dist/model/RootDefinition.d.ts +8 -5
  99. package/dist/model/SubtreeDefinition.d.ts +5 -4
  100. package/dist/model/ValueNodeDefinition.d.ts +5 -5
  101. package/dist/solid.js +1873 -1751
  102. package/dist/solid.js.map +1 -1
  103. package/package.json +14 -18
  104. package/src/XFormDOM.ts +81 -8
  105. package/src/body/BodyDefinition.ts +38 -23
  106. package/src/body/RepeatElementDefinition.ts +70 -0
  107. package/src/body/appearance/inputAppearanceParser.ts +39 -0
  108. package/src/body/appearance/selectAppearanceParser.ts +38 -0
  109. package/src/body/appearance/structureElementAppearanceParser.ts +7 -0
  110. package/src/body/control/ControlDefinition.ts +4 -0
  111. package/src/body/control/InputDefinition.ts +13 -0
  112. package/src/body/control/select/SelectDefinition.ts +14 -5
  113. package/src/body/group/BaseGroupDefinition.ts +11 -49
  114. package/src/body/text/LabelDefinition.ts +15 -1
  115. package/src/body/text/TextElementDefinition.ts +5 -5
  116. package/src/client/BaseNode.ts +9 -1
  117. package/src/client/GroupNode.ts +6 -2
  118. package/src/client/NodeAppearances.ts +22 -0
  119. package/src/client/RepeatInstanceNode.ts +4 -0
  120. package/src/client/RepeatRangeNode.ts +6 -2
  121. package/src/client/RootNode.ts +22 -0
  122. package/src/client/SelectNode.ts +4 -0
  123. package/src/client/StringNode.ts +4 -0
  124. package/src/client/SubtreeNode.ts +1 -0
  125. package/src/instance/Group.ts +14 -9
  126. package/src/instance/RepeatInstance.ts +59 -15
  127. package/src/instance/RepeatRange.ts +133 -15
  128. package/src/instance/Root.ts +20 -64
  129. package/src/instance/SelectField.ts +7 -7
  130. package/src/instance/StringField.ts +8 -7
  131. package/src/instance/Subtree.ts +10 -7
  132. package/src/instance/abstract/DescendantNode.ts +45 -43
  133. package/src/instance/abstract/InstanceNode.ts +69 -86
  134. package/src/instance/children.ts +17 -7
  135. package/src/instance/index.ts +1 -1
  136. package/src/instance/internal-api/EvaluationContext.ts +5 -6
  137. package/src/instance/internal-api/ValueContext.ts +2 -2
  138. package/src/lib/TokenListParser.ts +156 -0
  139. package/src/lib/dom/query.ts +13 -0
  140. package/src/lib/reactivity/createChildrenState.ts +51 -6
  141. package/src/lib/reactivity/createComputedExpression.ts +1 -1
  142. package/src/lib/reactivity/createSelectItems.ts +4 -6
  143. package/src/lib/reactivity/createValueState.ts +6 -6
  144. package/src/lib/reactivity/materializeCurrentStateChildren.ts +3 -1
  145. package/src/model/DescendentNodeDefinition.ts +1 -2
  146. package/src/model/ModelDefinition.ts +1 -1
  147. package/src/model/NodeDefinition.ts +12 -12
  148. package/src/model/RepeatInstanceDefinition.ts +8 -13
  149. package/src/model/{RepeatSequenceDefinition.ts → RepeatRangeDefinition.ts} +6 -6
  150. package/src/model/RepeatTemplateDefinition.ts +10 -15
  151. package/src/model/RootDefinition.ts +6 -12
  152. package/src/model/SubtreeDefinition.ts +3 -3
  153. package/src/model/ValueNodeDefinition.ts +2 -3
  154. package/dist/body/RepeatDefinition.d.ts +0 -15
  155. package/dist/body/group/RepeatGroupDefinition.d.ts +0 -12
  156. package/src/body/RepeatDefinition.ts +0 -54
  157. package/src/body/group/RepeatGroupDefinition.ts +0 -91
@@ -1,9 +1,11 @@
1
- import type { RepeatSequenceDefinition } from '../model/RepeatSequenceDefinition.ts';
2
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
3
- import type { RepeatInstanceNode } from './RepeatInstanceNode.ts';
4
- import type { RootNode } from './RootNode.ts';
5
- import type { TextRange } from './TextRange.ts';
6
- import type { GeneralParentNode } from './hierarchy.ts';
1
+ import { RepeatRangeDefinition } from '../model/RepeatRangeDefinition.ts';
2
+ import { BaseNode, BaseNodeState } from './BaseNode.ts';
3
+ import { NodeAppearances } from './NodeAppearances.ts';
4
+ import { RepeatInstanceNode } from './RepeatInstanceNode.ts';
5
+ import { RootNode } from './RootNode.ts';
6
+ import { TextRange } from './TextRange.ts';
7
+ import { GeneralParentNode } from './hierarchy.ts';
8
+
7
9
  export interface RepeatRangeNodeState extends BaseNodeState {
8
10
  get hint(): null;
9
11
  get label(): TextRange<'label'> | null;
@@ -19,6 +21,7 @@ export interface RepeatRangeNodeState extends BaseNodeState {
19
21
  get valueOptions(): null;
20
22
  get value(): null;
21
23
  }
24
+ export type RepeatRangeNodeAppearances = NodeAppearances<RepeatRangeDefinition>;
22
25
  /**
23
26
  * Represents a contiguous set of zero or more {@link RepeatInstanceNode}s
24
27
  * (accessed by its
@@ -85,7 +88,8 @@ export interface RepeatRangeNodeState extends BaseNodeState {
85
88
  */
86
89
  export interface RepeatRangeNode extends BaseNode {
87
90
  readonly nodeType: 'repeat-range';
88
- readonly definition: RepeatSequenceDefinition;
91
+ readonly appearances: RepeatRangeNodeAppearances;
92
+ readonly definition: RepeatRangeDefinition;
89
93
  readonly root: RootNode;
90
94
  readonly parent: GeneralParentNode;
91
95
  readonly currentState: RepeatRangeNodeState;
@@ -1,7 +1,9 @@
1
- import type { RootDefinition } from '../model/RootDefinition.ts';
2
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
3
- import type { ActiveLanguage, FormLanguage, FormLanguages } from './FormLanguage.ts';
4
- import type { GeneralChildNode } from './hierarchy.ts';
1
+ import { BodyClassList } from '../body/BodyDefinition.ts';
2
+ import { RootDefinition } from '../model/RootDefinition.ts';
3
+ import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
+ import { ActiveLanguage, FormLanguage, FormLanguages } from './FormLanguage.ts';
5
+ import { GeneralChildNode } from './hierarchy.ts';
6
+
5
7
  export interface RootNodeState extends BaseNodeState {
6
8
  /**
7
9
  * This, along with {@link RootNode.languages} is the most significant break
@@ -18,6 +20,24 @@ export interface RootNodeState extends BaseNodeState {
18
20
  }
19
21
  export interface RootNode extends BaseNode {
20
22
  readonly nodeType: 'root';
23
+ /**
24
+ * @todo this along with {@link classes} is... awkward.
25
+ */
26
+ readonly appearances: null;
27
+ /**
28
+ * @todo This is another odd deviation in {@link RootNode}. Unlike
29
+ * {@link languages}, it doesn't feel particularly **essential**. While it
30
+ * would deviate from XForms spec terminology, it seems like it _might be
31
+ * reasonable_ to instead convey `<h:body class="...">` as
32
+ * {@link RootNode.appearances} in the client interface. They do have slightly
33
+ * different spec semantics (i.e. a body class can be anything, to trigger
34
+ * styling in a form UI). But the **most likely anticipated** use case in Web
35
+ * Forms would be the "pages" class, and perhaps "theme-grid". The former is
36
+ * definitely conceptually similar to a XForms `appearance` (albeit
37
+ * form-global, which is not a spec concept). The latter does as well, and we
38
+ * already anticipate applying that concept in non-form-global ways.
39
+ */
40
+ readonly classes: BodyClassList;
21
41
  readonly definition: RootDefinition;
22
42
  readonly root: RootNode;
23
43
  readonly parent: null;
@@ -1,9 +1,11 @@
1
- import type { AnySelectDefinition } from '../body/control/select/SelectDefinition.ts';
2
- import type { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
3
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
4
- import type { RootNode } from './RootNode.ts';
5
- import type { TextRange } from './TextRange.ts';
6
- import type { GeneralParentNode } from './hierarchy.ts';
1
+ import { AnySelectDefinition } from '../body/control/select/SelectDefinition.ts';
2
+ import { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
3
+ import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
+ import { NodeAppearances } from './NodeAppearances.ts';
5
+ import { RootNode } from './RootNode.ts';
6
+ import { TextRange } from './TextRange.ts';
7
+ import { GeneralParentNode } from './hierarchy.ts';
8
+
7
9
  export interface SelectItem {
8
10
  get value(): string;
9
11
  get label(): TextRange<'label'> | null;
@@ -31,8 +33,10 @@ export interface SelectNodeState extends BaseNodeState {
31
33
  export interface SelectDefinition extends ValueNodeDefinition {
32
34
  readonly bodyElement: AnySelectDefinition;
33
35
  }
36
+ export type SelectNodeAppearances = NodeAppearances<SelectDefinition>;
34
37
  export interface SelectNode extends BaseNode {
35
38
  readonly nodeType: 'select';
39
+ readonly appearances: SelectNodeAppearances;
36
40
  readonly definition: SelectDefinition;
37
41
  readonly root: RootNode;
38
42
  readonly parent: GeneralParentNode;
@@ -1,8 +1,10 @@
1
- import type { InputDefinition } from '../body/control/InputDefinition.ts';
2
- import type { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
3
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
4
- import type { RootNode } from './RootNode.ts';
5
- import type { GeneralParentNode } from './hierarchy.ts';
1
+ import { InputDefinition } from '../body/control/InputDefinition.ts';
2
+ import { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
3
+ import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
+ import { NodeAppearances } from './NodeAppearances.ts';
5
+ import { RootNode } from './RootNode.ts';
6
+ import { GeneralParentNode } from './hierarchy.ts';
7
+
6
8
  export interface StringNodeState extends BaseNodeState {
7
9
  get children(): null;
8
10
  get valueOptions(): null;
@@ -17,6 +19,7 @@ export interface StringNodeState extends BaseNodeState {
17
19
  export interface StringDefinition extends ValueNodeDefinition {
18
20
  readonly bodyElement: InputDefinition | null;
19
21
  }
22
+ export type StringNodeAppearances = NodeAppearances<StringDefinition>;
20
23
  /**
21
24
  * A node which can be assigned a string/text value. A string node **MAY**
22
25
  * correspond to form field defined as an XForms `<input>`, which a user-facing
@@ -26,6 +29,7 @@ export interface StringDefinition extends ValueNodeDefinition {
26
29
  */
27
30
  export interface StringNode extends BaseNode {
28
31
  readonly nodeType: 'string';
32
+ readonly appearances: StringNodeAppearances;
29
33
  readonly definition: StringDefinition;
30
34
  readonly root: RootNode;
31
35
  readonly parent: GeneralParentNode;
@@ -1,7 +1,8 @@
1
- import type { SubtreeDefinition as BaseSubtreeDefinition } from '../model/SubtreeDefinition.ts';
2
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
3
- import type { RootNode } from './RootNode.ts';
4
- import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
1
+ import { SubtreeDefinition as BaseSubtreeDefinition } from '../model/SubtreeDefinition.ts';
2
+ import { BaseNode, BaseNodeState } from './BaseNode.ts';
3
+ import { RootNode } from './RootNode.ts';
4
+ import { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
5
+
5
6
  export interface SubtreeNodeState extends BaseNodeState {
6
7
  get label(): null;
7
8
  get hint(): null;
@@ -45,6 +46,7 @@ export interface SubtreeDefinition extends BaseSubtreeDefinition {
45
46
  */
46
47
  export interface SubtreeNode extends BaseNode {
47
48
  readonly nodeType: 'subtree';
49
+ readonly appearances: null;
48
50
  readonly definition: SubtreeDefinition;
49
51
  readonly root: RootNode;
50
52
  readonly parent: GeneralParentNode;
@@ -1,4 +1,5 @@
1
- import type { ActiveLanguage } from './FormLanguage.ts';
1
+ import { ActiveLanguage } from './FormLanguage.ts';
2
+
2
3
  export type TextChunkSource = 'itext' | 'output' | 'static';
3
4
  /**
4
5
  * @todo This (and everything else to do with {@link TextRange}s is for
@@ -1,11 +1,12 @@
1
- import type { ExpandUnion } from '../../../common/types/helpers.d.ts';
2
- import type { GroupNode } from './GroupNode.ts';
3
- import type { RepeatInstanceNode } from './RepeatInstanceNode.ts';
4
- import type { RepeatRangeNode } from './RepeatRangeNode.ts';
5
- import type { RootNode } from './RootNode.ts';
6
- import type { SelectNode } from './SelectNode.ts';
7
- import type { StringNode } from './StringNode.ts';
8
- import type { SubtreeNode } from './SubtreeNode.ts';
1
+ import { ExpandUnion } from '../../../common/types/helpers.d.ts';
2
+ import { GroupNode } from './GroupNode.ts';
3
+ import { RepeatInstanceNode } from './RepeatInstanceNode.ts';
4
+ import { RepeatRangeNode } from './RepeatRangeNode.ts';
5
+ import { RootNode } from './RootNode.ts';
6
+ import { SelectNode } from './SelectNode.ts';
7
+ import { StringNode } from './StringNode.ts';
8
+ import { SubtreeNode } from './SubtreeNode.ts';
9
+
9
10
  export type AnyLeafNode = SelectNode | StringNode;
10
11
  /**
11
12
  * Any of the concrete node types which may be a parent of any other node.
@@ -1,5 +1,6 @@
1
- import type { EngineConfig } from './EngineConfig.ts';
2
- import type { RootNode } from './RootNode.ts';
1
+ import { EngineConfig } from './EngineConfig.ts';
2
+ import { RootNode } from './RootNode.ts';
3
+
3
4
  export type FormResource = Blob | URL | string;
4
5
  export interface InitializeFormOptions {
5
6
  readonly config: EngineConfig;
@@ -1,4 +1,5 @@
1
- import type { AnyDependentExpression } from './DependentExpression.ts';
1
+ import { AnyDependentExpression } from './DependentExpression.ts';
2
+
2
3
  export declare abstract class DependencyContext {
3
4
  abstract get parentReference(): string | null;
4
5
  abstract get reference(): string | null;
@@ -1,5 +1,6 @@
1
- import type { XFormsXPathEvaluator } from '@getodk/xpath';
2
- import type { DependencyContext } from './DependencyContext.ts';
1
+ import { XFormsXPathEvaluator } from '@getodk/xpath';
2
+ import { DependencyContext } from './DependencyContext.ts';
3
+
3
4
  declare const evaluatorMethodsByResultType: {
4
5
  readonly boolean: "evaluateBoolean";
5
6
  readonly nodes: "evaluateNodes";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { InitializeForm } from './index.ts';
1
+ import { InitializeForm } from './index.ts';
2
+
2
3
  export declare const initializeForm: InitializeForm;
3
4
  export type * from './client/EngineConfig.ts';
4
5
  export type * from './client/FormLanguage.ts';