@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,20 +1,22 @@
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';
1
+ import { XFormsXPathEvaluator } from '@getodk/xpath';
2
+ import { Accessor, Signal } from 'solid-js';
3
+ import { BaseNode } from '../../client/BaseNode.ts';
4
+ import { NodeAppearances } from '../../client/NodeAppearances.ts';
5
+ import { InstanceNodeType } from '../../client/node-types.ts';
6
+ import { TextRange } from '../../index.ts';
7
+ import { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
8
+ import { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
9
+ import { SharedNodeState } from '../../lib/reactivity/node-state/createSharedNodeState.ts';
10
+ import { ReactiveScope } from '../../lib/reactivity/scope.ts';
11
+ import { SimpleAtomicState } from '../../lib/reactivity/types.ts';
12
+ import { AnyNodeDefinition } from '../../model/NodeDefinition.ts';
13
+ import { Root } from '../Root.ts';
14
+ import { AnyChildNode, AnyNode, AnyParentNode } from '../hierarchy.ts';
15
+ import { NodeID } from '../identity.ts';
16
+ import { EvaluationContext } from '../internal-api/EvaluationContext.ts';
17
+ import { InstanceConfig } from '../internal-api/InstanceConfig.ts';
18
+ import { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
19
+
18
20
  export interface InstanceNodeStateSpec<Value = never> {
19
21
  readonly reference: Accessor<string> | string;
20
22
  readonly readonly: Accessor<boolean> | boolean;
@@ -27,9 +29,6 @@ export interface InstanceNodeStateSpec<Value = never> {
27
29
  readonly value: Signal<Value> | SimpleAtomicState<Value> | null;
28
30
  }
29
31
  type AnyInstanceNode = InstanceNode<AnyNodeDefinition, InstanceNodeStateSpec<any>, any>;
30
- interface InitializedStateOptions<T, K extends keyof T> {
31
- readonly uninitializedFallback: T[K];
32
- }
33
32
  /**
34
33
  * This type has the same effect as {@link MaterializedChildren}, but abstractly
35
34
  * handles leaf node types as well.
@@ -37,52 +36,52 @@ interface InitializedStateOptions<T, K extends keyof T> {
37
36
  export type InstanceNodeCurrentState<Spec extends InstanceNodeStateSpec<any>, Child> = CurrentState<Omit<Spec, 'children'>> & {
38
37
  readonly children: [Child] extends [AnyChildNode] ? readonly Child[] : null;
39
38
  };
39
+ interface ComputableReferenceNode {
40
+ readonly parent: AnyParentNode | null;
41
+ readonly definition: AnyNodeDefinition;
42
+ }
43
+ type ComputeInstanceNodeReference = <This extends ComputableReferenceNode>(this: This, parent: This['parent'], definition: This['definition']) => string;
44
+ export interface InstanceNodeOptions {
45
+ readonly computeReference?: () => string;
46
+ }
40
47
  export declare abstract class InstanceNode<Definition extends AnyNodeDefinition, Spec extends InstanceNodeStateSpec<any>, Child extends AnyChildNode | null = null> implements BaseNode, EvaluationContext, SubscribableDependency {
41
48
  readonly engineConfig: InstanceConfig;
42
49
  readonly parent: AnyParentNode | null;
43
50
  readonly definition: Definition;
44
- protected readonly isStateInitialized: Accessor<boolean>;
45
51
  protected abstract readonly state: SharedNodeState<Spec>;
46
52
  protected abstract readonly engineState: EngineState<Spec>;
47
53
  /**
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.
54
+ * @package Exposed on every node type to facilitate inheritance, as well as
55
+ * conditional behavior for value nodes.
56
+ */
57
+ abstract readonly hasReadonlyAncestor: Accessor<boolean>;
58
+ /**
59
+ * @package Exposed on every node type to facilitate inheritance, as well as
60
+ * conditional behavior for value nodes.
65
61
  */
66
- protected getInitializedState<K extends keyof EngineState<Spec>>(key: K, options: InitializedStateOptions<EngineState<Spec>, K>): EngineState<Spec>[K];
62
+ abstract readonly isReadonly: Accessor<boolean>;
67
63
  /**
68
64
  * @package Exposed on every node type to facilitate inheritance, as well as
69
65
  * conditional behavior for value nodes.
70
66
  */
71
- get isReadonly(): boolean;
67
+ abstract readonly hasNonRelevantAncestor: Accessor<boolean>;
72
68
  /**
73
69
  * @package Exposed on every node type to facilitate inheritance, as well as
74
70
  * conditional behavior for value nodes.
75
71
  */
76
- get isRelevant(): boolean;
72
+ abstract readonly isRelevant: Accessor<boolean>;
77
73
  readonly nodeId: NodeID;
78
74
  abstract readonly nodeType: InstanceNodeType;
75
+ abstract readonly appearances: NodeAppearances<Definition>;
79
76
  abstract readonly currentState: InstanceNodeCurrentState<Spec, Child>;
80
77
  abstract readonly root: Root;
81
78
  abstract readonly evaluator: XFormsXPathEvaluator;
82
79
  readonly scope: ReactiveScope;
83
- get contextReference(): string;
80
+ readonly computeReference: ComputeInstanceNodeReference;
81
+ protected readonly computeChildStepReference: ComputeInstanceNodeReference;
82
+ readonly contextReference: () => string;
84
83
  abstract readonly contextNode: Element;
85
- constructor(engineConfig: InstanceConfig, parent: AnyParentNode | null, definition: Definition);
84
+ constructor(engineConfig: InstanceConfig, parent: AnyParentNode | null, definition: Definition, options?: InstanceNodeOptions);
86
85
  /**
87
86
  * @package This presently serves a few internal use cases, where certain
88
87
  * behaviors depend on arbitrary traversal from any point in the instance
@@ -94,9 +93,8 @@ export declare abstract class InstanceNode<Definition extends AnyNodeDefinition,
94
93
  * interface for those internal uses.
95
94
  */
96
95
  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;
96
+ getNodesByReference(this: AnyNode, visited: WeakSet<AnyNode>, dependencyReference: string): readonly SubscribableDependency[];
97
+ getSubscribableDependenciesByReference(this: AnyNode, reference: string): readonly SubscribableDependency[];
100
98
  /**
101
99
  * This is a default implementation suitable for most node types. The rest
102
100
  * (currently: `Root`, `RepeatRange`, `RepeatInstance`) should likely extend
@@ -1,2 +1,3 @@
1
- import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
1
+ import { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
2
+
2
3
  export declare const buildChildren: (parent: GeneralParentNode) => GeneralChildNode[];
@@ -1,10 +1,11 @@
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';
1
+ import { Group } from './Group.ts';
2
+ import { RepeatInstance } from './RepeatInstance.ts';
3
+ import { RepeatRange } from './RepeatRange.ts';
4
+ import { Root } from './Root.ts';
5
+ import { SelectField } from './SelectField.ts';
6
+ import { StringField } from './StringField.ts';
7
+ import { Subtree } from './Subtree.ts';
8
+
8
9
  export type AnyNode = Root | Group | Subtree | RepeatRange | RepeatInstance | StringField | SelectField;
9
10
  export type AnyParentNode = Root | Group | Subtree | RepeatRange | RepeatInstance;
10
11
  export type GeneralParentNode = Root | Group | Subtree | RepeatInstance;
@@ -1,6 +1,7 @@
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';
1
+ import { RootNode } from '../client/RootNode.ts';
2
+ import { InitializeFormOptions as BaseInitializeFormOptions, FormResource } from '../client/index.ts';
3
+ import { InstanceConfig } from './internal-api/InstanceConfig.ts';
4
+
4
5
  interface InitializeFormOptions extends BaseInitializeFormOptions {
5
6
  readonly config: Partial<InstanceConfig>;
6
7
  }
@@ -1,7 +1,9 @@
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';
1
+ import { XFormsXPathEvaluator } from '@getodk/xpath';
2
+ import { Accessor } from 'solid-js';
3
+ import { ReactiveScope } from '../../lib/reactivity/scope.ts';
4
+ import { SubscribableDependency } from './SubscribableDependency.ts';
5
+ import { TranslationContext } from './TranslationContext.ts';
6
+
5
7
  export interface EvaluationContextRoot extends SubscribableDependency, TranslationContext {
6
8
  }
7
9
  /**
@@ -24,11 +26,11 @@ export interface EvaluationContext {
24
26
  * Produces the current absolute reference to the {@link contextNode}, where
25
27
  * the absolute `/` resolves to the active form state's primary instance root.
26
28
  */
27
- get contextReference(): string;
29
+ readonly contextReference: Accessor<string>;
28
30
  readonly contextNode: Node;
29
31
  /**
30
- * Resolves a nodeset reference, possibly relative to the
31
- * {@link EvaluationContext.contextNode}.
32
+ * Resolves nodes corresponding to the provided node-set reference, possibly
33
+ * relative to the {@link EvaluationContext.contextNode}.
32
34
  */
33
- readonly getSubscribableDependencyByReference: (reference: string) => SubscribableDependency | null;
35
+ getSubscribableDependenciesByReference(reference: string): readonly SubscribableDependency[];
34
36
  }
@@ -1,5 +1,6 @@
1
- import type { EngineConfig } from '../../client/EngineConfig.ts';
2
- import type { CreateUniqueId } from '../../lib/unique-id.ts';
1
+ import { EngineConfig } from '../../client/EngineConfig.ts';
2
+ import { CreateUniqueId } from '../../lib/unique-id.ts';
3
+
3
4
  export interface InstanceConfig extends Required<EngineConfig> {
4
5
  /**
5
6
  * Uniqueness per form instance session (so e.g. persistence isn't necessary).
@@ -1,4 +1,5 @@
1
- import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
1
+ import { ReactiveScope } from '../../lib/reactivity/scope.ts';
2
+
2
3
  /**
3
4
  * Provides a common interface to explicitly establish a reactive subscription
4
5
  * to a form node, regardless of which node-specific details might trigger
@@ -1,4 +1,5 @@
1
- import type { ActiveLanguage } from '../../index.ts';
1
+ import { ActiveLanguage } from '../../index.ts';
2
+
2
3
  export interface TranslationContext {
3
4
  get activeLanguage(): ActiveLanguage;
4
5
  }
@@ -1,6 +1,7 @@
1
- import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
2
- import type { BindComputation } from '../../model/BindComputation.ts';
3
- import type { EvaluationContext } from './EvaluationContext.ts';
1
+ import { ReactiveScope } from '../../lib/reactivity/scope.ts';
2
+ import { BindComputation } from '../../model/BindComputation.ts';
3
+ import { EvaluationContext } from './EvaluationContext.ts';
4
+
4
5
  export type InstanceValue = string;
5
6
  interface ValueContextDefinitionBind {
6
7
  readonly calculate: BindComputation<'calculate'> | null;
@@ -14,8 +15,8 @@ export interface ValueContext<RuntimeValue> extends EvaluationContext {
14
15
  readonly scope: ReactiveScope;
15
16
  readonly definition: ValueContextDefinition;
16
17
  readonly contextNode: Element;
17
- get isReadonly(): boolean;
18
- get isRelevant(): boolean;
18
+ isReadonly(): boolean;
19
+ isRelevant(): boolean;
19
20
  readonly encodeValue: (this: unknown, runtimeValue: RuntimeValue) => InstanceValue;
20
21
  readonly decodeValue: (this: unknown, instanceValue: InstanceValue) => RuntimeValue;
21
22
  }
@@ -1,5 +1,6 @@
1
- import type { FetchResource, FetchResourceResponse } from '../client/EngineConfig.ts';
2
- import type { FormResource } from '../client/index.ts';
1
+ import { FetchResource, FetchResourceResponse } from '../client/EngineConfig.ts';
2
+ import { FormResource } from '../client/index.ts';
3
+
3
4
  export type { FetchResource, FetchResourceResponse, FormResource };
4
5
  export interface ResourceOptions {
5
6
  readonly fetchResource: FetchResource;
@@ -1,6 +1,7 @@
1
- import type { ActiveLanguage } from '../../client/FormLanguage.ts';
2
- import type { TextChunk as ClientTextChunk, TextChunkSource } from '../../client/TextRange.ts';
3
- import type { TranslationContext } from '../internal-api/TranslationContext.ts';
1
+ import { ActiveLanguage } from '../../client/FormLanguage.ts';
2
+ import { TextChunk as ClientTextChunk, TextChunkSource } from '../../client/TextRange.ts';
3
+ import { TranslationContext } from '../internal-api/TranslationContext.ts';
4
+
4
5
  export declare class TextChunk implements ClientTextChunk {
5
6
  readonly context: TranslationContext;
6
7
  readonly source: TextChunkSource;
@@ -1,4 +1,5 @@
1
- import type { TextRange as ClientTextRange, TextChunk } from '../../client/TextRange.ts';
1
+ import { TextRange as ClientTextRange, TextChunk } from '../../client/TextRange.ts';
2
+
2
3
  export type TextRole = 'hint' | 'label';
3
4
  export declare class TextRange<Role extends TextRole> implements ClientTextRange<Role> {
4
5
  readonly role: Role;
@@ -0,0 +1,84 @@
1
+ import { PartiallyKnownString } from '../../../common/types/string/PartiallyKnownString.ts';
2
+
3
+ type SymbolIterator = typeof Symbol.iterator;
4
+ type TokenListKey<CanonicalToken extends string> = PartiallyKnownString<CanonicalToken> | SymbolIterator;
5
+ type TokenListIterator<CanonicalToken extends string> = IterableIterator<PartiallyKnownString<CanonicalToken>>;
6
+ /**
7
+ * @see {@link TokenListParser}
8
+ */
9
+ export type TokenList<CanonicalToken extends string = string> = {
10
+ readonly [Key in TokenListKey<CanonicalToken>]: Key extends SymbolIterator ? () => TokenListIterator<CanonicalToken> : boolean;
11
+ };
12
+ interface TokenListAlias<CanonicalToken extends string> {
13
+ readonly fromAlias: string;
14
+ readonly toCanonical: CanonicalToken;
15
+ }
16
+ type TokenAliases<CanonicalToken extends string> = ReadonlyArray<TokenListAlias<CanonicalToken>>;
17
+ interface TokenListParserOptions<CanonicalToken extends string> {
18
+ readonly aliases?: TokenAliases<CanonicalToken>;
19
+ }
20
+ type TokenListAttributeName = PartiallyKnownString<'appearance' | 'class'>;
21
+ /**
22
+ * Intended primarily for use in parsing these features:
23
+ *
24
+ * - {@link https://getodk.github.io/xforms-spec/#appearances | appearances} ({@link https://xlsform.org/en/#appearance | additional documentation})
25
+ *
26
+ * - {@link https://getodk.github.io/xforms-spec/#body-attributes | body `class` attribute}
27
+ *
28
+ * This class is named as a reference to {@link DOMTokenList}
29
+ * ({@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList | MDN}),
30
+ * with these similarities:
31
+ *
32
+ * - Represents a value whose serialization is a space-separated list.
33
+ * - Each member ("token") is a string (without whitespace).
34
+ * - Provides set-like semantics to determine presence of members.
35
+ * - Provides ordering semantics as determined by the serialization.
36
+ *
37
+ * This class differs from that prior art in that:
38
+ *
39
+ * - It provides a notion of "canonical" members. This is _mostly_ (but not
40
+ * entirely) intended as a convenience to client developers, automatically
41
+ * populating canonical/known tokens for a given parser type in
42
+ * editor-provided autocomplete, etc. **Importantly**, non-canonical tokens
43
+ * _are not ignored_ in either the {@link TokenList}'s types or runtime
44
+ * values.
45
+ *
46
+ * - Provided "canonical" members may also be used to specify
47
+ * {@link TokenListParserOptions.aliases | optional aliases}. (Example: when
48
+ * parsing "appearances", an alias might map an older deprecated appearance to
49
+ * a newer canonical equivalent.) **Importantly**, when a token matches an
50
+ * alias, both that alias _and the token as-specified_ will be present in the
51
+ * produced {@link TokenList}.
52
+ *
53
+ * - As a parser, it is intended to be read-only. The serialized format which it
54
+ * parses is _generally_ the source of truth (excepting e.g. aliases).
55
+ * Notably, and as mentioned above, ordering is determined by:
56
+ *
57
+ * - Iterating each member, as provided by the serialized representation
58
+ *
59
+ * - If that member corresponds to an alias, that alias is yielded first
60
+ *
61
+ * - Regardless of whether the member corresponds to an alias, the member is
62
+ * yielded as-specified
63
+ *
64
+ * - A parsed {@link TokenList} is intended to maximize convenience of read-only
65
+ * access. Despite many _conceptual similarities_, most of the
66
+ * {@link DOMTokenList} **interface** is eschewed in favor of two (mutually
67
+ * equivalent) access mechanisms:
68
+ *
69
+ * - `Iterable<Token>`, with the ordering semantics described above
70
+ * - `Record<Token, boolean>`
71
+ *
72
+ * \* This may change, as we refine requirements. In the future, we may
73
+ * introduce a notion of mutually exclusive tokens (e.g. "appearances" which
74
+ * cannot be used together), which may in turn utilize instance-defined ordering
75
+ * as part of that mechanism.
76
+ */
77
+ export declare class TokenListParser<CanonicalToken extends string, TokenAlias extends CanonicalToken = CanonicalToken> {
78
+ readonly canonicalTokens: readonly CanonicalToken[];
79
+ private readonly aliases;
80
+ constructor(canonicalTokens: readonly CanonicalToken[], options?: TokenListParserOptions<TokenAlias>);
81
+ parseFrom(element: Element, attributeName: TokenListAttributeName): TokenList<CanonicalToken>;
82
+ }
83
+ export type ParsedTokenList<Parser extends TokenListParser<any>> = Parser extends TokenListParser<infer CanonicalToken> ? TokenList<CanonicalToken> : never;
84
+ export {};
@@ -1,5 +1,6 @@
1
- import type { KnownAttributeLocalNamedElement, LocalNamedElement } from '../../../../common/types/dom.ts';
2
- import type { SelectElement } from '../../body/control/select/SelectDefinition';
1
+ import { KnownAttributeLocalNamedElement, LocalNamedElement } from '../../../../common/types/dom.ts';
2
+ import { SelectElement } from '../../body/control/select/SelectDefinition';
3
+
3
4
  export interface HintElement extends LocalNamedElement<'hint'> {
4
5
  }
5
6
  export interface ItemElement extends LocalNamedElement<'item'> {
@@ -8,6 +9,10 @@ export interface ItemsetElement extends KnownAttributeLocalNamedElement<'itemset
8
9
  }
9
10
  export interface LabelElement extends LocalNamedElement<'label'> {
10
11
  }
12
+ export interface RepeatGroupLabelElement extends LabelElement {
13
+ getAttribute(name: 'form-definition-source'): 'repeat-group';
14
+ getAttribute(name: string): string;
15
+ }
11
16
  export interface RepeatElement extends KnownAttributeLocalNamedElement<'repeat', 'nodeset'> {
12
17
  }
13
18
  export interface ValueElement extends LocalNamedElement<'value'> {
@@ -16,5 +21,6 @@ export declare const getHintElement: (parent: Element) => HintElement | null;
16
21
  export declare const getItemElements: (parent: SelectElement) => readonly ItemElement[];
17
22
  export declare const getItemsetElement: (parent: Element) => ItemsetElement | null;
18
23
  export declare const getLabelElement: (parent: Element) => LabelElement | null;
24
+ export declare const getRepeatGroupLabelElement: (parent: Element) => RepeatGroupLabelElement | null;
19
25
  export declare const getRepeatElement: (parent: Element) => RepeatElement | null;
20
26
  export declare const getValueElement: (parent: ItemElement | ItemsetElement) => ValueElement | null;
@@ -1,6 +1,7 @@
1
- import { type Accessor, type Setter, type Signal } from 'solid-js';
2
- import type { AnyChildNode, AnyParentNode } from '../../instance/hierarchy.ts';
3
- import type { NodeID } from '../../instance/identity.ts';
1
+ import { Accessor, Setter, Signal } from 'solid-js';
2
+ import { AnyChildNode, AnyParentNode } from '../../instance/hierarchy.ts';
3
+ import { NodeID } from '../../instance/identity.ts';
4
+
4
5
  export interface ChildrenState<Child extends AnyChildNode> {
5
6
  readonly children: Signal<readonly Child[]>;
6
7
  readonly getChildren: Accessor<readonly Child[]>;
@@ -1,6 +1,7 @@
1
- import type { Accessor } from 'solid-js';
2
- import type { DependentExpression, DependentExpressionResultType } from '../../expression/DependentExpression.ts';
3
- import type { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { DependentExpression, DependentExpressionResultType } from '../../expression/DependentExpression.ts';
3
+ import { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
4
+
4
5
  interface ComputedExpressionResults {
5
6
  readonly boolean: boolean;
6
7
  readonly nodes: Node[];
@@ -1,6 +1,7 @@
1
- import type { Accessor } from 'solid-js';
2
- import type { SelectItem } from '../../index.ts';
3
- import type { SelectField } from '../../instance/SelectField.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { SelectItem } from '../../index.ts';
3
+ import { SelectField } from '../../instance/SelectField.ts';
4
+
4
5
  /**
5
6
  * Creates a reactive computation of a {@link SelectField}'s
6
7
  * {@link SelectItem}s, in support of the field's `valueOptions`.
@@ -1,5 +1,6 @@
1
- import type { ValueContext } from '../../instance/internal-api/ValueContext.ts';
2
- import type { SimpleAtomicState } from './types.ts';
1
+ import { ValueContext } from '../../instance/internal-api/ValueContext.ts';
2
+ import { SimpleAtomicState } from './types.ts';
3
+
3
4
  type InitialValueSource = 'FORM_DEFAULT' | 'PRIMARY_INSTANCE';
4
5
  export interface ValueStateOptions {
5
6
  /**
@@ -1,6 +1,8 @@
1
- import type { AnyChildNode } from '../../instance/hierarchy.ts';
2
- import type { NodeID } from '../../instance/identity.ts';
3
- import type { ChildrenState } from './createChildrenState.ts';
1
+ import { AnyChildNode } from '../../instance/hierarchy.ts';
2
+ import { NodeID } from '../../instance/identity.ts';
3
+ import { ChildrenState } from './createChildrenState.ts';
4
+ import { ReactiveScope } from './scope.ts';
5
+
4
6
  export interface EncodedParentState {
5
7
  readonly children: readonly NodeID[];
6
8
  }
@@ -15,4 +17,4 @@ export type MaterializedChildren<BaseState extends EncodedParentState, Child ext
15
17
  *
16
18
  * @see {@link createChildrenState} for further detail.
17
19
  */
18
- export declare const materializeCurrentStateChildren: <Child extends AnyChildNode, ParentState extends EncodedParentState>(currentState: ParentState, childrenState: ChildrenState<Child>) => MaterializedChildren<ParentState, Child>;
20
+ export declare const materializeCurrentStateChildren: <Child extends AnyChildNode, ParentState extends EncodedParentState>(scope: ReactiveScope, currentState: ParentState, childrenState: ChildrenState<Child>) => MaterializedChildren<ParentState, Child>;
@@ -1,9 +1,10 @@
1
- import type { ShallowMutable } from '../../../../../common/types/helpers.js';
2
- import type { OpaqueReactiveObjectFactory } from '../../../index.ts';
3
- import type { ReactiveScope } from '../scope.ts';
4
- import type { EngineState } from './createEngineState.ts';
5
- import type { SpecifiedState, StateSpec } from './createSpecifiedState.ts';
6
- import type { InternalClientRepresentation } from './representations.ts';
1
+ import { ShallowMutable } from '../../../../../common/types/helpers.js';
2
+ import { OpaqueReactiveObjectFactory } from '../../../index.ts';
3
+ import { ReactiveScope } from '../scope.ts';
4
+ import { EngineState } from './createEngineState.ts';
5
+ import { SpecifiedState, StateSpec } from './createSpecifiedState.ts';
6
+ import { InternalClientRepresentation } from './representations.ts';
7
+
7
8
  export type SpecifiedClientStateFactory<Factory extends OpaqueReactiveObjectFactory, Spec extends StateSpec> = ShallowMutable<SpecifiedState<Spec>> extends Parameters<Factory>[0] ? Factory : never;
8
9
  export type ClientState<Spec extends StateSpec> = InternalClientRepresentation<SpecifiedState<Spec>>;
9
10
  export declare const createClientState: <Factory extends OpaqueReactiveObjectFactory, Spec extends StateSpec>(scope: ReactiveScope, engineState: EngineState<Spec>, clientStateFactory: SpecifiedClientStateFactory<Factory, Spec>) => ClientState<Spec>;
@@ -1,6 +1,7 @@
1
- import type { ReactiveScope } from '../scope.ts';
2
- import type { ClientState } from './createClientState.ts';
3
- import type { SpecifiedState, StateSpec } from './createSpecifiedState.ts';
4
- import type { ReadonlyClientRepresentation } from './representations.ts';
1
+ import { ReactiveScope } from '../scope.ts';
2
+ import { ClientState } from './createClientState.ts';
3
+ import { SpecifiedState, StateSpec } from './createSpecifiedState.ts';
4
+ import { ReadonlyClientRepresentation } from './representations.ts';
5
+
5
6
  export type CurrentState<Spec extends StateSpec> = ReadonlyClientRepresentation<SpecifiedState<Spec>>;
6
7
  export declare const createCurrentState: <Spec extends StateSpec>(scope: ReactiveScope, clientState: ClientState<Spec>) => CurrentState<Spec>;
@@ -1,5 +1,6 @@
1
- import type { ReactiveScope } from '../scope.ts';
2
- import type { SpecifiedState, StateSpec } from './createSpecifiedState.ts';
3
- import type { EngineRepresentation } from './representations.ts';
1
+ import { ReactiveScope } from '../scope.ts';
2
+ import { SpecifiedState, StateSpec } from './createSpecifiedState.ts';
3
+ import { EngineRepresentation } from './representations.ts';
4
+
4
5
  export type EngineState<Spec extends StateSpec> = EngineRepresentation<SpecifiedState<Spec>>;
5
6
  export declare const createEngineState: <Spec extends StateSpec>(scope: ReactiveScope, spec: Spec) => EngineState<Spec>;
@@ -1,9 +1,10 @@
1
- import type { OpaqueReactiveObjectFactory } from '../../../index.ts';
2
- import type { ReactiveScope } from '../scope.ts';
3
- import type { ClientState, SpecifiedClientStateFactory } from './createClientState.ts';
4
- import type { CurrentState } from './createCurrentState.ts';
5
- import type { EngineState } from './createEngineState.ts';
6
- import type { MutablePropertySpec, SpecifiedState, StateSpec } from './createSpecifiedState.ts';
1
+ import { OpaqueReactiveObjectFactory } from '../../../index.ts';
2
+ import { ReactiveScope } from '../scope.ts';
3
+ import { ClientState, SpecifiedClientStateFactory } from './createClientState.ts';
4
+ import { CurrentState } from './createCurrentState.ts';
5
+ import { EngineState } from './createEngineState.ts';
6
+ import { MutablePropertySpec, SpecifiedState, StateSpec } from './createSpecifiedState.ts';
7
+
7
8
  type MutableKeyOf<Spec extends StateSpec> = {
8
9
  [K in string & keyof Spec]: Spec[K] extends MutablePropertySpec<any> ? K : never;
9
10
  }[string & keyof Spec];
@@ -1,4 +1,5 @@
1
- import type { StatePropertySpec } from './createSpecifiedState.ts';
1
+ import { StatePropertySpec } from './createSpecifiedState.ts';
2
+
2
3
  export interface SpecifiedPropertyDescriptor<T = any> extends TypedPropertyDescriptor<T> {
3
4
  readonly configurable: true;
4
5
  readonly enumerable: true;
@@ -1,5 +1,6 @@
1
- import type { Accessor, Signal } from 'solid-js';
2
- import type { SimpleAtomicState } from '../types.ts';
1
+ import { Accessor, Signal } from 'solid-js';
2
+ import { SimpleAtomicState } from '../types.ts';
3
+
3
4
  /**
4
5
  * Specifies a state object's property as mutable. Basic usage:
5
6
  *
@@ -1,4 +1,5 @@
1
- import type { ShallowMutable } from '../../../../../common/types/helpers.js';
1
+ import { ShallowMutable } from '../../../../../common/types/helpers.js';
2
+
2
3
  declare const ENGINE_REPRESENTATION: unique symbol;
3
4
  type ENGINE_REPRESENTATION = typeof ENGINE_REPRESENTATION;
4
5
  declare const INTERNAL_CLIENT_REPRESENTATION: unique symbol;
@@ -1,4 +1,5 @@
1
- import type { Owner } from 'solid-js';
1
+ import { Owner } from 'solid-js';
2
+
2
3
  type ReactiveScopeTask<T> = (scope: ReactiveScope) => T;
3
4
  type RunReactiveScopeTask = <T>(task: ReactiveScopeTask<T>) => T;
4
5
  export interface ReactiveScope {
@@ -1,5 +1,6 @@
1
- import { type Accessor } from 'solid-js';
2
- import type { EvaluationContext } from '../../../instance/internal-api/EvaluationContext.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { EvaluationContext } from '../../../instance/internal-api/EvaluationContext.ts';
3
3
  import { TextRange } from '../../../instance/text/TextRange.ts';
4
- import type { ValueNodeDefinition } from '../../../model/ValueNodeDefinition.ts';
4
+ import { ValueNodeDefinition } from '../../../model/ValueNodeDefinition.ts';
5
+
5
6
  export declare const createFieldHint: (context: EvaluationContext, definition: ValueNodeDefinition) => Accessor<TextRange<'hint'> | null>;
@@ -1,5 +1,6 @@
1
- import { type Accessor } from 'solid-js';
2
- import type { EvaluationContext } from '../../../instance/internal-api/EvaluationContext.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { EvaluationContext } from '../../../instance/internal-api/EvaluationContext.ts';
3
3
  import { TextRange } from '../../../instance/text/TextRange.ts';
4
- import type { AnyNodeDefinition } from '../../../model/NodeDefinition.ts';
4
+ import { AnyNodeDefinition } from '../../../model/NodeDefinition.ts';
5
+
5
6
  export declare const createNodeLabel: (context: EvaluationContext, definition: AnyNodeDefinition) => Accessor<TextRange<'label'> | null>;
@@ -1,7 +1,8 @@
1
- import { type Accessor } from 'solid-js';
2
- import type { TextElementDefinition } from '../../../body/text/TextElementDefinition.ts';
3
- import type { EvaluationContext } from '../../../instance/internal-api/EvaluationContext.ts';
4
- import { TextRange, type TextRole } from '../../../instance/text/TextRange.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { TextElementDefinition } from '../../../body/text/TextElementDefinition.ts';
3
+ import { EvaluationContext } from '../../../instance/internal-api/EvaluationContext.ts';
4
+ import { TextRange, TextRole } from '../../../instance/text/TextRange.ts';
5
+
5
6
  interface CreateTextRangeOptions<FallbackValue extends string | null> {
6
7
  readonly fallbackValue?: FallbackValue;
7
8
  }
@@ -15,5 +16,5 @@ type ComputedTextRange<Role extends TextRole, Definition extends TextElementDefi
15
16
  *
16
17
  * @todo This does not yet handle itext translations **with** outputs!
17
18
  */
18
- export declare const createTextRange: <Role extends TextRole, Definition extends TextElementDefinition<Role> | null, FallbackValue extends string | null = null>(context: EvaluationContext, role: Role, definition: Definition, options?: CreateTextRangeOptions<FallbackValue> | undefined) => ComputedTextRange<Role, Definition, FallbackValue>;
19
+ export declare const createTextRange: <Role extends TextRole, Definition extends TextElementDefinition<Role> | null, FallbackValue extends string | null = null>(context: EvaluationContext, role: Role, definition: Definition, options?: CreateTextRangeOptions<FallbackValue>) => ComputedTextRange<Role, Definition, FallbackValue>;
19
20
  export {};
@@ -1,4 +1,5 @@
1
- import type { Accessor, Setter } from 'solid-js';
1
+ import { Accessor, Setter } from 'solid-js';
2
+
2
3
  /**
3
4
  * A write interface to reactive atomic state. This type is intended to be used
4
5
  * as a relaxed version of {@link Setter}, where its callback form isn't