@getodk/xforms-engine 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/BaseNode.d.ts +14 -3
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -48
- package/dist/client/InputNode.d.ts +53 -0
- package/dist/client/ModelValueNode.d.ts +12 -7
- package/dist/client/NoteNode.d.ts +2 -2
- package/dist/client/RootNode.d.ts +34 -7
- package/dist/client/SelectNode.d.ts +2 -2
- package/dist/client/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -0
- package/dist/client/hierarchy.d.ts +4 -4
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/node-types.d.ts +2 -1
- package/dist/client/resources.d.ts +93 -0
- package/dist/client/submission/SubmissionData.d.ts +7 -0
- package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
- package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
- package/dist/client/submission/SubmissionOptions.d.ts +23 -0
- package/dist/client/submission/SubmissionResult.d.ts +91 -0
- package/dist/client/submission/SubmissionState.d.ts +12 -0
- package/dist/client/validation.d.ts +2 -2
- package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
- package/dist/error/ValueTypeInvariantError.d.ts +17 -0
- package/dist/error/XPathFunctionalityError.d.ts +14 -0
- package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
- package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +10856 -8585
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +9 -4
- package/dist/instance/InputControl.d.ts +36 -0
- package/dist/instance/ModelValue.d.ts +16 -26
- package/dist/instance/Note.d.ts +10 -3
- package/dist/instance/PrimaryInstance.d.ts +84 -0
- package/dist/instance/Root.d.ts +29 -25
- package/dist/instance/SelectField.d.ts +10 -2
- package/dist/instance/Subtree.d.ts +10 -5
- package/dist/instance/TriggerControl.d.ts +10 -3
- package/dist/instance/abstract/DescendantNode.d.ts +31 -23
- package/dist/instance/abstract/InstanceNode.d.ts +49 -29
- package/dist/instance/abstract/UnsupportedControl.d.ts +10 -3
- package/dist/instance/abstract/ValueNode.d.ts +48 -0
- package/dist/instance/hierarchy.d.ts +9 -8
- package/dist/instance/identity.d.ts +2 -7
- package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
- package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
- package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
- package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
- package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
- package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
- package/dist/instance/internal-api/ValueContext.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +31 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +18 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +17 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +39 -83
- package/dist/instance/repeat/RepeatInstance.d.ts +11 -29
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
- package/dist/instance/resource.d.ts +1 -1
- package/dist/instance/text/TextRange.d.ts +1 -1
- package/dist/instance/unsupported/RangeControl.d.ts +3 -1
- package/dist/instance/unsupported/RankControl.d.ts +3 -1
- package/dist/instance/unsupported/UploadControl.d.ts +3 -1
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
- package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
- package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
- package/dist/integration/xpath/adapter/kind.d.ts +32 -0
- package/dist/integration/xpath/adapter/names.d.ts +16 -0
- package/dist/integration/xpath/adapter/traversal.d.ts +25 -0
- package/dist/integration/xpath/adapter/values.d.ts +2 -0
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +19 -0
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +16 -0
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +40 -0
- package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +17 -0
- package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
- package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
- package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
- package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
- package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
- package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
- package/dist/lib/codecs/ValueCodec.d.ts +30 -0
- package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +47 -0
- package/dist/lib/dom/query.d.ts +3 -0
- package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
- package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
- package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
- package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
- package/dist/lib/reactivity/createValueState.d.ts +6 -10
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
- package/dist/lib/xml-serialization.d.ts +41 -0
- package/dist/parse/XFormDOM.d.ts +18 -7
- package/dist/parse/XFormDefinition.d.ts +1 -2
- package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
- package/dist/parse/body/BodyDefinition.d.ts +3 -3
- package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
- package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +1 -1
- package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -2
- package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
- package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
- package/dist/parse/model/BindDefinition.d.ts +4 -5
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +0 -1
- package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +3 -1
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/ModelDefinition.d.ts +2 -0
- package/dist/parse/model/NodeDefinition.d.ts +0 -1
- package/dist/parse/model/NoteNodeDefinition.d.ts +4 -4
- package/dist/parse/model/RootDefinition.d.ts +3 -2
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
- package/dist/parse/xpath/semantic-analysis.d.ts +5 -0
- package/dist/solid.js +8174 -5921
- package/dist/solid.js.map +1 -1
- package/package.json +13 -11
- package/src/client/BaseNode.ts +16 -6
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/InputNode.ts +77 -0
- package/src/client/ModelValueNode.ts +30 -7
- package/src/client/NoteNode.ts +2 -2
- package/src/client/RootNode.ts +37 -7
- package/src/client/SelectNode.ts +3 -3
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +5 -5
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +12 -6
- package/src/client/resources.ts +118 -0
- package/src/client/submission/SubmissionData.ts +12 -0
- package/src/client/submission/SubmissionDefinition.ts +16 -0
- package/src/client/submission/SubmissionInstanceFile.ts +9 -0
- package/src/client/submission/SubmissionOptions.ts +28 -0
- package/src/client/submission/SubmissionResult.ts +124 -0
- package/src/client/submission/SubmissionState.ts +14 -0
- package/src/client/validation.ts +2 -2
- package/src/error/ErrorProductionDesignPendingError.ts +6 -0
- package/src/error/ValueTypeInvariantError.ts +22 -0
- package/src/error/XPathFunctionalityError.ts +26 -0
- package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
- package/src/error/XPathFunctionalityPendingError.ts +18 -0
- package/src/index.ts +10 -1
- package/src/instance/Group.ts +17 -5
- package/src/instance/InputControl.ts +119 -0
- package/src/instance/ModelValue.ts +47 -54
- package/src/instance/Note.ts +24 -8
- package/src/instance/PrimaryInstance.ts +244 -0
- package/src/instance/Root.ts +62 -134
- package/src/instance/SelectField.ts +56 -19
- package/src/instance/Subtree.ts +19 -7
- package/src/instance/TriggerControl.ts +23 -6
- package/src/instance/abstract/DescendantNode.ts +90 -45
- package/src/instance/abstract/InstanceNode.ts +103 -105
- package/src/instance/abstract/UnsupportedControl.ts +28 -5
- package/src/instance/abstract/ValueNode.ts +127 -0
- package/src/instance/children.ts +9 -10
- package/src/instance/hierarchy.ts +19 -15
- package/src/instance/identity.ts +3 -9
- package/src/instance/index.ts +25 -7
- package/src/instance/internal-api/EvaluationContext.ts +60 -13
- package/src/instance/internal-api/InstanceConfig.ts +9 -2
- package/src/instance/internal-api/InstanceValueContext.ts +24 -0
- package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
- package/src/instance/internal-api/TranslationContext.ts +3 -2
- package/src/instance/internal-api/ValidationContext.ts +3 -4
- package/src/instance/internal-api/ValueContext.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +42 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +25 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +23 -0
- package/src/instance/repeat/BaseRepeatRange.ts +50 -131
- package/src/instance/repeat/RepeatInstance.ts +20 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
- package/src/instance/resource.ts +1 -1
- package/src/instance/text/TextChunk.ts +1 -1
- package/src/instance/unsupported/RangeControl.ts +5 -1
- package/src/instance/unsupported/RankControl.ts +5 -1
- package/src/instance/unsupported/UploadControl.ts +5 -1
- package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
- package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
- package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
- package/src/integration/xpath/adapter/kind.ts +114 -0
- package/src/integration/xpath/adapter/names.ts +99 -0
- package/src/integration/xpath/adapter/traversal.ts +228 -0
- package/src/integration/xpath/adapter/values.ts +5 -0
- package/src/integration/xpath/static-dom/StaticAttribute.ts +33 -0
- package/src/integration/xpath/static-dom/StaticDocument.ts +38 -0
- package/src/integration/xpath/static-dom/StaticElement.ts +106 -0
- package/src/integration/xpath/static-dom/StaticNamedNode.ts +45 -0
- package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
- package/src/integration/xpath/static-dom/StaticText.ts +28 -0
- package/src/lib/client-reactivity/README.md +0 -0
- package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
- package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
- package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
- package/src/lib/codecs/DecimalValueCodec.ts +46 -0
- package/src/lib/codecs/IntValueCodec.ts +100 -0
- package/src/lib/codecs/StringValueCodec.ts +11 -0
- package/src/lib/codecs/ValueCodec.ts +106 -0
- package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
- package/src/lib/codecs/getSharedValueCodec.ts +77 -0
- package/src/lib/dom/query.ts +7 -0
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +57 -34
- package/src/lib/reactivity/createInstanceValueState.ts +166 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- package/src/lib/reactivity/createSelectItems.ts +21 -21
- package/src/lib/reactivity/createTranslationState.ts +61 -0
- package/src/lib/reactivity/createValueState.ts +62 -120
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
- package/src/lib/reactivity/text/createTextRange.ts +4 -3
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
- package/src/lib/reactivity/validation/createValidation.ts +2 -3
- package/src/lib/xml-serialization.ts +96 -0
- package/src/parse/XFormDOM.ts +110 -75
- package/src/parse/XFormDefinition.ts +1 -6
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/parse/body/BodyDefinition.ts +3 -3
- package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
- package/src/parse/body/control/{InputDefinition.ts → InputControlDefinition.ts} +3 -5
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -5
- package/src/parse/expression/abstract/DependencyContext.ts +0 -26
- package/src/parse/expression/abstract/DependentExpression.ts +2 -13
- package/src/parse/model/BindDefinition.ts +5 -8
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/parse/model/DescendentNodeDefinition.ts +0 -6
- package/src/parse/model/FormSubmissionDefinition.ts +44 -0
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +41 -0
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
- package/src/parse/model/LeafNodeDefinition.ts +4 -1
- package/src/parse/model/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +6 -1
- package/src/parse/model/NodeDefinition.ts +0 -3
- package/src/parse/model/NoteNodeDefinition.ts +3 -3
- package/src/parse/model/RootDefinition.ts +2 -1
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
- package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +414 -0
- package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
- package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
- package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
- package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
- package/src/parse/xpath/semantic-analysis.ts +29 -0
- package/dist/client/StringNode.d.ts +0 -46
- package/dist/instance/StringField.d.ts +0 -44
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
- package/dist/parse/XFormDataType.d.ts +0 -25
- package/src/client/StringNode.ts +0 -52
- package/src/instance/StringField.ts +0 -120
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/parse/XFormDataType.ts +0 -62
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
2
|
import { Accessor, Signal } from 'solid-js';
|
|
3
3
|
import { BaseNode } from '../../client/BaseNode.ts';
|
|
4
4
|
import { NodeAppearances } from '../../client/NodeAppearances.ts';
|
|
5
|
-
import {
|
|
5
|
+
import { FormNodeID } from '../../client/identity.ts';
|
|
6
|
+
import { InstanceNodeType as ClientInstanceNodeType } from '../../client/node-types.ts';
|
|
7
|
+
import { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
6
8
|
import { NodeValidationState } from '../../client/validation.ts';
|
|
7
|
-
import { TextRange } from '../../index.ts';
|
|
9
|
+
import { ActiveLanguage, TextRange } from '../../index.ts';
|
|
10
|
+
import { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
11
|
+
import { XFormsXPathPrimaryInstanceNode, XFormsXPathPrimaryInstanceNodeKind } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
12
|
+
import { PrimaryInstanceXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
8
13
|
import { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
9
14
|
import { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
10
15
|
import { SharedNodeState } from '../../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
11
16
|
import { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
12
17
|
import { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
13
18
|
import { AnyNodeDefinition } from '../../parse/model/NodeDefinition.ts';
|
|
19
|
+
import { PrimaryInstance } from '../PrimaryInstance.ts';
|
|
14
20
|
import { Root } from '../Root.ts';
|
|
15
|
-
import { AnyChildNode,
|
|
16
|
-
import { NodeID } from '../identity.ts';
|
|
21
|
+
import { AnyChildNode, AnyParentNode } from '../hierarchy.ts';
|
|
17
22
|
import { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
18
23
|
import { InstanceConfig } from '../internal-api/InstanceConfig.ts';
|
|
19
|
-
|
|
24
|
+
export type EngineInstanceNodeType = ClientInstanceNodeType | 'primary-instance';
|
|
25
|
+
export interface BaseEngineNode extends Omit<BaseNode, 'nodeType'> {
|
|
26
|
+
readonly nodeType: EngineInstanceNodeType;
|
|
27
|
+
}
|
|
20
28
|
export interface InstanceNodeStateSpec<Value = never> {
|
|
21
29
|
readonly reference: Accessor<string> | string;
|
|
22
30
|
readonly readonly: Accessor<boolean> | boolean;
|
|
@@ -24,7 +32,7 @@ export interface InstanceNodeStateSpec<Value = never> {
|
|
|
24
32
|
readonly required: Accessor<boolean> | boolean;
|
|
25
33
|
readonly label: Accessor<TextRange<'label'> | null> | null;
|
|
26
34
|
readonly hint: Accessor<TextRange<'hint'> | null> | null;
|
|
27
|
-
readonly children: Accessor<readonly
|
|
35
|
+
readonly children: Accessor<readonly FormNodeID[]> | null;
|
|
28
36
|
readonly valueOptions: Accessor<null> | Accessor<readonly unknown[]> | null;
|
|
29
37
|
readonly value: Signal<Value> | SimpleAtomicState<Value> | null;
|
|
30
38
|
}
|
|
@@ -43,13 +51,17 @@ interface ComputableReferenceNode {
|
|
|
43
51
|
type ComputeInstanceNodeReference = <This extends ComputableReferenceNode>(this: This, parent: This['parent'], definition: This['definition']) => string;
|
|
44
52
|
export interface InstanceNodeOptions {
|
|
45
53
|
readonly computeReference?: () => string;
|
|
54
|
+
readonly scope?: ReactiveScope;
|
|
46
55
|
}
|
|
47
|
-
export declare abstract class InstanceNode<Definition extends AnyNodeDefinition, Spec extends InstanceNodeStateSpec<any>, Child extends AnyChildNode | null = null> implements
|
|
56
|
+
export declare abstract class InstanceNode<Definition extends AnyNodeDefinition, Spec extends InstanceNodeStateSpec<any>, Parent extends AnyParentNode | null, Child extends AnyChildNode | null = null> implements BaseEngineNode, XFormsXPathPrimaryInstanceNode, EvaluationContext {
|
|
48
57
|
readonly engineConfig: InstanceConfig;
|
|
49
|
-
readonly parent:
|
|
58
|
+
readonly parent: Parent;
|
|
50
59
|
readonly definition: Definition;
|
|
51
60
|
protected abstract readonly state: SharedNodeState<Spec>;
|
|
52
61
|
protected abstract readonly engineState: EngineState<Spec>;
|
|
62
|
+
abstract readonly [XPathNodeKindKey]: XFormsXPathPrimaryInstanceNodeKind;
|
|
63
|
+
readonly rootDocument: PrimaryInstance;
|
|
64
|
+
abstract readonly root: Root;
|
|
53
65
|
/**
|
|
54
66
|
* @package Exposed on every node type to facilitate inheritance, as well as
|
|
55
67
|
* conditional behavior for value nodes.
|
|
@@ -70,37 +82,45 @@ export declare abstract class InstanceNode<Definition extends AnyNodeDefinition,
|
|
|
70
82
|
* conditional behavior for value nodes.
|
|
71
83
|
*/
|
|
72
84
|
abstract readonly isRelevant: Accessor<boolean>;
|
|
73
|
-
readonly nodeId:
|
|
74
|
-
abstract readonly nodeType:
|
|
85
|
+
readonly nodeId: FormNodeID;
|
|
86
|
+
abstract readonly nodeType: EngineInstanceNodeType;
|
|
75
87
|
abstract readonly appearances: NodeAppearances<Definition>;
|
|
76
88
|
abstract readonly currentState: InstanceNodeCurrentState<Spec, Child>;
|
|
77
89
|
abstract readonly validationState: NodeValidationState;
|
|
78
|
-
abstract readonly
|
|
79
|
-
abstract readonly evaluator:
|
|
90
|
+
abstract readonly submissionState: SubmissionState;
|
|
91
|
+
abstract readonly evaluator: EngineXPathEvaluator;
|
|
92
|
+
abstract readonly getActiveLanguage: Accessor<ActiveLanguage>;
|
|
93
|
+
abstract readonly isAttached: Accessor<boolean>;
|
|
80
94
|
readonly scope: ReactiveScope;
|
|
81
95
|
readonly computeReference: ComputeInstanceNodeReference;
|
|
82
96
|
protected readonly computeChildStepReference: ComputeInstanceNodeReference;
|
|
83
97
|
readonly contextReference: () => string;
|
|
84
|
-
abstract readonly contextNode: Element;
|
|
85
|
-
constructor(engineConfig: InstanceConfig, parent: AnyParentNode | null, definition: Definition, options?: InstanceNodeOptions);
|
|
86
98
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
* Note: it is expected that at least some node subclasses will override this
|
|
100
|
+
* to reflect (or in the case of intermediate abstract base classes, to
|
|
101
|
+
* constrain) their more specific `this` type.
|
|
102
|
+
*/
|
|
103
|
+
readonly contextNode: PrimaryInstanceXPathNode;
|
|
104
|
+
constructor(engineConfig: InstanceConfig, parent: Parent, definition: Definition, options?: InstanceNodeOptions);
|
|
105
|
+
/** @package */
|
|
106
|
+
isPrimaryInstance(): this is PrimaryInstance;
|
|
107
|
+
/** @package */
|
|
108
|
+
isRoot(): this is Root;
|
|
109
|
+
/**
|
|
110
|
+
* @package This presently serves a growing variety of internal use cases,
|
|
111
|
+
* where certain behaviors depend on arbitrary traversal from any point in the
|
|
112
|
+
* instance tree, without particular regard for the visited node type. It
|
|
113
|
+
* isn't intended for external traversal or any other means of consuming
|
|
114
|
+
* children by a client. This return type intentionally deviates from one
|
|
115
|
+
* structural expectation, requiring even leaf nodes to return an array
|
|
116
|
+
* (though for those nodes it will always be empty). This affords consistency
|
|
117
|
+
* and efficiency of interface for those internal uses.
|
|
95
118
|
*/
|
|
96
119
|
abstract getChildren(this: AnyInstanceNode): readonly AnyChildNode[];
|
|
97
|
-
getNodesByReference(this: AnyNode, visited: WeakSet<AnyNode>, dependencyReference: string): readonly SubscribableDependency[];
|
|
98
|
-
getSubscribableDependenciesByReference(this: AnyNode, reference: string): readonly SubscribableDependency[];
|
|
99
120
|
/**
|
|
100
|
-
*
|
|
101
|
-
* (currently: `Root`, `RepeatRange`, `RepeatInstance`) should likely extend
|
|
102
|
-
* this behavior, rather than simply overriding it.
|
|
121
|
+
* @todo Values as text nodes(?)
|
|
103
122
|
*/
|
|
104
|
-
|
|
123
|
+
getXPathChildNodes(): readonly AnyChildNode[];
|
|
124
|
+
getXPathValue(): string;
|
|
105
125
|
}
|
|
106
126
|
export {};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
1
2
|
import { Accessor } from 'solid-js';
|
|
2
3
|
import { UnsupportedControlNodeType } from '../../client/node-types.ts';
|
|
4
|
+
import { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
3
5
|
import { TextRange } from '../../client/TextRange.ts';
|
|
4
6
|
import { UnsupportedControlDefinition, UnsupportedControlElementDefinition, UnsupportedControlNode } from '../../client/unsupported/UnsupportedControlNode.ts';
|
|
5
7
|
import { AnyViolation, LeafNodeValidationState } from '../../client/validation.ts';
|
|
8
|
+
import { XFormsXPathElement } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
6
9
|
import { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
7
10
|
import { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
8
11
|
import { SharedNodeState } from '../../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
9
12
|
import { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
10
13
|
import { UnknownAppearanceDefinition } from '../../parse/body/appearance/unknownAppearanceParser.ts';
|
|
11
|
-
import { GeneralParentNode } from '../hierarchy.ts';
|
|
14
|
+
import { AnyUnsupportedControl, GeneralParentNode } from '../hierarchy.ts';
|
|
12
15
|
import { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
13
|
-
import {
|
|
16
|
+
import { ClientReactiveSubmittableLeafNode } from '../internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
14
17
|
import { ValidationContext } from '../internal-api/ValidationContext.ts';
|
|
15
18
|
import { ValueContext } from '../internal-api/ValueContext.ts';
|
|
16
19
|
import { DescendantNode, DescendantNodeStateSpec } from './DescendantNode.ts';
|
|
@@ -27,17 +30,21 @@ interface UnsupportedControlStateSpec extends DescendantNodeStateSpec<unknown> {
|
|
|
27
30
|
readonly value: SimpleAtomicState<unknown>;
|
|
28
31
|
readonly valueOptions: never;
|
|
29
32
|
}
|
|
30
|
-
export declare abstract class UnsupportedControl<Type extends UnsupportedControlNodeType> extends DescendantNode<TypedUnsupportedControlDefinition<Type>, UnsupportedControlStateSpec, null> implements UnsupportedControlNode,
|
|
33
|
+
export declare abstract class UnsupportedControl<Type extends UnsupportedControlNodeType> extends DescendantNode<TypedUnsupportedControlDefinition<Type>, UnsupportedControlStateSpec, GeneralParentNode, null> implements UnsupportedControlNode, XFormsXPathElement, EvaluationContext, ValidationContext, ValueContext<unknown>, ClientReactiveSubmittableLeafNode<unknown> {
|
|
31
34
|
private readonly validation;
|
|
32
35
|
protected readonly state: SharedNodeState<UnsupportedControlStateSpec>;
|
|
36
|
+
readonly [XPathNodeKindKey] = "element";
|
|
33
37
|
protected readonly engineState: EngineState<UnsupportedControlStateSpec>;
|
|
34
38
|
abstract readonly nodeType: Type;
|
|
35
39
|
readonly appearances: UnknownAppearanceDefinition;
|
|
36
40
|
readonly currentState: CurrentState<UnsupportedControlStateSpec>;
|
|
37
41
|
get validationState(): LeafNodeValidationState;
|
|
42
|
+
readonly submissionState: SubmissionState;
|
|
43
|
+
abstract readonly contextNode: AnyUnsupportedControl & this;
|
|
38
44
|
readonly encodeValue: (instanceValue: unknown) => string;
|
|
39
45
|
readonly decodeValue: (instanceValue: unknown) => unknown;
|
|
40
46
|
constructor(parent: GeneralParentNode, definition: TypedUnsupportedControlDefinition<Type>);
|
|
47
|
+
getXPathValue(): string;
|
|
41
48
|
getViolation(): AnyViolation | null;
|
|
42
49
|
isBlank(): boolean;
|
|
43
50
|
getChildren(): readonly [];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import { Accessor } from 'solid-js';
|
|
3
|
+
import { BaseValueNode } from '../../client/BaseValueNode.ts';
|
|
4
|
+
import { LeafNodeType as ValueNodeType } from '../../client/node-types.ts';
|
|
5
|
+
import { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
6
|
+
import { AnyViolation, LeafNodeValidationState } from '../../client/validation.ts';
|
|
7
|
+
import { ValueType } from '../../client/ValueType.ts';
|
|
8
|
+
import { XFormsXPathElement } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
9
|
+
import { RuntimeValueSetter, RuntimeValueState, ValueCodec } from '../../lib/codecs/ValueCodec.ts';
|
|
10
|
+
import { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
11
|
+
import { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
12
|
+
import { SharedNodeState } from '../../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
13
|
+
import { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
14
|
+
import { SharedValidationState } from '../../lib/reactivity/validation/createValidation.ts';
|
|
15
|
+
import { LeafNodeDefinition } from '../../parse/model/LeafNodeDefinition.ts';
|
|
16
|
+
import { GeneralParentNode } from '../hierarchy.ts';
|
|
17
|
+
import { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
18
|
+
import { DecodeInstanceValue, InstanceValueContext } from '../internal-api/InstanceValueContext.ts';
|
|
19
|
+
import { ClientReactiveSubmittableValueNode } from '../internal-api/submission/ClientReactiveSubmittableValueNode.ts';
|
|
20
|
+
import { ValidationContext } from '../internal-api/ValidationContext.ts';
|
|
21
|
+
import { DescendantNodeStateSpec, DescendantNode } from './DescendantNode.ts';
|
|
22
|
+
export type ValueNodeDefinition<V extends ValueType> = LeafNodeDefinition<V>;
|
|
23
|
+
export interface ValueNodeStateSpec<RuntimeValue> extends DescendantNodeStateSpec<RuntimeValue> {
|
|
24
|
+
readonly children: null;
|
|
25
|
+
readonly valueOptions: null;
|
|
26
|
+
readonly value: SimpleAtomicState<RuntimeValue>;
|
|
27
|
+
readonly instanceValue: Accessor<string>;
|
|
28
|
+
}
|
|
29
|
+
export declare abstract class ValueNode<V extends ValueType, Definition extends ValueNodeDefinition<V>, RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> extends DescendantNode<Definition, ValueNodeStateSpec<RuntimeValue>, GeneralParentNode, null> implements BaseValueNode<V, RuntimeValue>, XFormsXPathElement, EvaluationContext, InstanceValueContext, ValidationContext, ClientReactiveSubmittableValueNode {
|
|
30
|
+
protected readonly validation: SharedValidationState;
|
|
31
|
+
protected readonly getInstanceValue: Accessor<string>;
|
|
32
|
+
protected readonly valueState: RuntimeValueState<RuntimeValue>;
|
|
33
|
+
protected readonly setValueState: RuntimeValueSetter<RuntimeInputValue>;
|
|
34
|
+
readonly [XPathNodeKindKey] = "element";
|
|
35
|
+
readonly getXPathValue: () => string;
|
|
36
|
+
protected abstract readonly state: SharedNodeState<ValueNodeStateSpec<RuntimeValue>>;
|
|
37
|
+
protected abstract readonly engineState: EngineState<ValueNodeStateSpec<RuntimeValue>>;
|
|
38
|
+
readonly decodeInstanceValue: DecodeInstanceValue;
|
|
39
|
+
abstract readonly nodeType: ValueNodeType;
|
|
40
|
+
readonly valueType: V;
|
|
41
|
+
abstract readonly currentState: CurrentState<ValueNodeStateSpec<RuntimeValue>>;
|
|
42
|
+
get validationState(): LeafNodeValidationState;
|
|
43
|
+
readonly submissionState: SubmissionState;
|
|
44
|
+
constructor(parent: GeneralParentNode, definition: Definition, codec: ValueCodec<V, RuntimeValue, RuntimeInputValue>);
|
|
45
|
+
getViolation(): AnyViolation | null;
|
|
46
|
+
isBlank(): boolean;
|
|
47
|
+
getChildren(): readonly [];
|
|
48
|
+
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { Group } from './Group.ts';
|
|
2
|
-
import {
|
|
2
|
+
import { AnyInputControl } from './InputControl.ts';
|
|
3
|
+
import { AnyModelValue } from './ModelValue.ts';
|
|
3
4
|
import { Note } from './Note.ts';
|
|
5
|
+
import { PrimaryInstance } from './PrimaryInstance.ts';
|
|
4
6
|
import { RepeatInstance } from './repeat/RepeatInstance.ts';
|
|
5
7
|
import { RepeatRangeControlled } from './repeat/RepeatRangeControlled.ts';
|
|
6
8
|
import { RepeatRangeUncontrolled } from './repeat/RepeatRangeUncontrolled.ts';
|
|
7
9
|
import { Root } from './Root.ts';
|
|
8
10
|
import { SelectField } from './SelectField.ts';
|
|
9
|
-
import { StringField } from './StringField.ts';
|
|
10
11
|
import { Subtree } from './Subtree.ts';
|
|
11
12
|
import { TriggerControl } from './TriggerControl.ts';
|
|
12
13
|
import { RangeControl } from './unsupported/RangeControl.ts';
|
|
13
14
|
import { RankControl } from './unsupported/RankControl.ts';
|
|
14
15
|
import { UploadControl } from './unsupported/UploadControl.ts';
|
|
15
16
|
export type RepeatRange = RepeatRangeControlled | RepeatRangeUncontrolled;
|
|
16
|
-
export type
|
|
17
|
-
export type AnyNode = Root | Group | Subtree | RepeatRange | RepeatInstance | Note |
|
|
18
|
-
export type AnyParentNode = Root | Group | Subtree | RepeatRange | RepeatInstance;
|
|
17
|
+
export type AnyUnsupportedControl = RangeControl | RankControl | UploadControl;
|
|
18
|
+
export type AnyNode = PrimaryInstance | Root | Group | Subtree | RepeatRange | RepeatInstance | Note | AnyModelValue | AnyInputControl | SelectField | TriggerControl | AnyUnsupportedControl;
|
|
19
|
+
export type AnyParentNode = PrimaryInstance | Root | Group | Subtree | RepeatRange | RepeatInstance;
|
|
19
20
|
export type GeneralParentNode = Root | Group | Subtree | RepeatInstance;
|
|
20
|
-
export type AnyChildNode = Group | Subtree | RepeatRange | RepeatInstance |
|
|
21
|
-
export type GeneralChildNode = Group | Subtree | RepeatRange |
|
|
22
|
-
export type AnyValueNode =
|
|
21
|
+
export type AnyChildNode = Root | Group | Subtree | RepeatRange | RepeatInstance | AnyModelValue | Note | AnyInputControl | SelectField | TriggerControl | AnyUnsupportedControl;
|
|
22
|
+
export type GeneralChildNode = Group | Subtree | RepeatRange | AnyModelValue | Note | AnyInputControl | SelectField | TriggerControl | AnyUnsupportedControl;
|
|
23
|
+
export type AnyValueNode = AnyModelValue | Note | AnyInputControl | SelectField | TriggerControl | AnyUnsupportedControl;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type NodeID = string & {
|
|
4
|
-
readonly [NODE_ID_BRAND]: true;
|
|
5
|
-
};
|
|
6
|
-
export declare const declareNodeID: (id: string) => NodeID;
|
|
7
|
-
export {};
|
|
1
|
+
import { FormNodeID } from '../client/identity.ts';
|
|
2
|
+
export declare const nodeID: (id: string) => FormNodeID;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { XFormsXPathEvaluator } from '@getodk/xpath';
|
|
2
1
|
import { Accessor } from 'solid-js';
|
|
2
|
+
import { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
3
|
+
import { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
3
4
|
import { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
4
|
-
import { SubscribableDependency } from './SubscribableDependency.ts';
|
|
5
5
|
import { TranslationContext } from './TranslationContext.ts';
|
|
6
|
-
export interface EvaluationContextRoot extends SubscribableDependency, TranslationContext {
|
|
7
|
-
}
|
|
8
6
|
/**
|
|
9
7
|
* Provides a common interface to establish context for XPath-based
|
|
10
8
|
* computations, i.e. to evaluate {@link DependentExpression}s where:
|
|
@@ -16,20 +14,63 @@ export interface EvaluationContextRoot extends SubscribableDependency, Translati
|
|
|
16
14
|
* - the expression may be dependent on the form's currently active language
|
|
17
15
|
* (e.g. `jr:itext`)
|
|
18
16
|
* - any dynamic case is expected to be internally reactive
|
|
17
|
+
*
|
|
18
|
+
* Historical note: we previously utilized static analysis and a related
|
|
19
|
+
* abstraction to set up reactive subscriptions to node references, values, and
|
|
20
|
+
* other pertinent state changes warranting an expression's recomputation. Those
|
|
21
|
+
* are still described above because they provide useful insight for the
|
|
22
|
+
* **effect** of evaluating a given {@link DependentExpression}, with a given
|
|
23
|
+
* {@link EvaluationContext}.
|
|
24
|
+
*
|
|
25
|
+
* The reactive subscription mechanism has since been largely replaced, with the
|
|
26
|
+
* engine's implementation of {@link EngineXPathEvaluator} and its corresponding
|
|
27
|
+
* {@link engineDOMAdapter | XPath DOM adapter implementation}.
|
|
28
|
+
*
|
|
29
|
+
* @todo There is still one notable exception: translation expressions (i.e.
|
|
30
|
+
* expressions calling {@link https://getodk.github.io/xforms-spec/#fn:jr:itext}
|
|
31
|
+
* | `jr:itext`). We still perform analysis to identify such calls, and when
|
|
32
|
+
* evaluating those expressions we still explicitly subscribe to the form's
|
|
33
|
+
* active language state. A further refactor, moving more of the responsibility
|
|
34
|
+
* for translation state up out of `@getodk/xpath` into the engine, would likely
|
|
35
|
+
* allow us to further simplify the engine's reactive XPath recomputation
|
|
36
|
+
* approach.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link createTranslationState} for additional context.
|
|
19
39
|
*/
|
|
20
|
-
export interface EvaluationContext {
|
|
40
|
+
export interface EvaluationContext extends TranslationContext {
|
|
41
|
+
/**
|
|
42
|
+
* Used to determine whether {@link contextNode} is attached to its
|
|
43
|
+
* {@link EngineXPathNode} document hierarchy.
|
|
44
|
+
*
|
|
45
|
+
* - If this function returns `true`: expressions are evaluated as defined.
|
|
46
|
+
* - If this function returns `false`: expressions are evaluated to either an
|
|
47
|
+
* explicit default value (if provided) or an implicit default value
|
|
48
|
+
* appropriate for the requested result type.
|
|
49
|
+
*
|
|
50
|
+
* @see {@link createComputedExpression} for further detail on the latter.
|
|
51
|
+
*/
|
|
52
|
+
readonly isAttached: Accessor<boolean>;
|
|
21
53
|
readonly scope: ReactiveScope;
|
|
22
|
-
readonly evaluator:
|
|
23
|
-
readonly root: EvaluationContextRoot;
|
|
54
|
+
readonly evaluator: EngineXPathEvaluator;
|
|
24
55
|
/**
|
|
25
56
|
* Produces the current absolute reference to the {@link contextNode}, where
|
|
26
|
-
* the
|
|
57
|
+
* the AbsoluteLocationPath expression `/` resolves to the active
|
|
58
|
+
* {@link PrimaryInstance}, and each Step and/or position Predicate from there
|
|
59
|
+
* corresponds to the node hierarchy descending from there.
|
|
27
60
|
*/
|
|
28
61
|
readonly contextReference: Accessor<string>;
|
|
29
|
-
readonly contextNode: Node;
|
|
30
62
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
63
|
+
* Note: in most cases, implementations of {@link EvaluationContext} will
|
|
64
|
+
* **also** be an implementation of {@link EngineXPathNode} (as concrete
|
|
65
|
+
* implementations of {@link InstanceNode}). This property is an intentional
|
|
66
|
+
* indirection which:
|
|
67
|
+
*
|
|
68
|
+
* - Expresses only the much more limited set of properties which must be
|
|
69
|
+
* present to initialize computations during those nodes' construction.
|
|
70
|
+
*
|
|
71
|
+
* - Allows for a handful of cases where an {@link InstanceNode} provides the
|
|
72
|
+
* requisite facilities for evaluating expressions in a {@link StaticNode}'s
|
|
73
|
+
* context (itemsets being a prominent example).
|
|
33
74
|
*/
|
|
34
|
-
|
|
75
|
+
readonly contextNode: EngineXPathNode;
|
|
35
76
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MissingResourceBehavior } from '../../client/constants.ts';
|
|
2
|
+
import { OpaqueReactiveObjectFactory } from '../../client/OpaqueReactiveObjectFactory.ts';
|
|
3
|
+
import { FetchFormAttachment, FetchResource } from '../../client/resources.ts';
|
|
2
4
|
import { CreateUniqueId } from '../../lib/unique-id.ts';
|
|
3
|
-
export interface InstanceConfig
|
|
5
|
+
export interface InstanceConfig {
|
|
6
|
+
readonly stateFactory: OpaqueReactiveObjectFactory;
|
|
7
|
+
readonly fetchFormDefinition: FetchResource;
|
|
8
|
+
readonly fetchFormAttachment: FetchFormAttachment;
|
|
9
|
+
readonly missingResourceBehavior: MissingResourceBehavior;
|
|
4
10
|
/**
|
|
5
11
|
* Uniqueness per form instance session (so e.g. persistence isn't necessary).
|
|
6
12
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
|
+
import { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
3
|
+
import { EvaluationContext } from './EvaluationContext.ts';
|
|
4
|
+
export type DecodeInstanceValue = (value: string) => string;
|
|
5
|
+
interface InstanceValueContextDefinitionBind {
|
|
6
|
+
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
7
|
+
readonly readonly: BindComputationExpression<'readonly'>;
|
|
8
|
+
}
|
|
9
|
+
export interface InstanceValueContextDefinition {
|
|
10
|
+
readonly bind: InstanceValueContextDefinitionBind;
|
|
11
|
+
readonly defaultValue: string;
|
|
12
|
+
}
|
|
13
|
+
export interface InstanceValueContext extends EvaluationContext {
|
|
14
|
+
readonly scope: ReactiveScope;
|
|
15
|
+
readonly definition: InstanceValueContextDefinition;
|
|
16
|
+
readonly decodeInstanceValue: DecodeInstanceValue;
|
|
17
|
+
isReadonly(): boolean;
|
|
18
|
+
isRelevant(): boolean;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FormLanguage } from '../../client/FormLanguage.ts';
|
|
2
|
+
import { RootNode, RootNodeState } from '../../client/RootNode.ts';
|
|
3
|
+
export interface PrimaryInstanceDocumentState extends Omit<RootNodeState, 'children'> {
|
|
4
|
+
/**
|
|
5
|
+
* @todo while this is an internal interface, this feels like maybe an
|
|
6
|
+
* unnecessary indirection? It would probably be fine for it to reference
|
|
7
|
+
* `Root` directly? We do get some minor benefit from making sure the client
|
|
8
|
+
* and internal types are aligned, but we also already enforce that by
|
|
9
|
+
* ensuring `Root implements RootNode`...
|
|
10
|
+
*/
|
|
11
|
+
get children(): readonly RootNode[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Provides an interface most similar to what we would expose at the
|
|
15
|
+
* `@getodk/xforms-engine` package boundary, if we were to document the primary
|
|
16
|
+
* instance document's types for a client.
|
|
17
|
+
*
|
|
18
|
+
* Note: this interface (as well as {@link currentState}'s {@link PrimaryInstanceDocumentState}) is derived from {@link RootNode} to help avoid drift if that underlying interface (or its shared {@link BaseNode} interface) is updated.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export interface PrimaryInstanceDocument extends Omit<RootNode, 'nodeType' | 'currentState' | 'setLanguage'> {
|
|
22
|
+
readonly nodeType: 'primary-instance';
|
|
23
|
+
readonly currentState: PrimaryInstanceDocumentState;
|
|
24
|
+
/**
|
|
25
|
+
* @todo This intentionally returns `unknown` as a hint that we will likely
|
|
26
|
+
* want to move away from returning {@link RootNode} (i.e. "all of the state",
|
|
27
|
+
* as it was conceived in that design effort) on every state change.
|
|
28
|
+
*
|
|
29
|
+
* In this case, it may be sensible to return any of:
|
|
30
|
+
*
|
|
31
|
+
* - Just the state set directly (i.e. the input {@link FormLanguage})
|
|
32
|
+
* - That effective state, and some representation of all affected nodes
|
|
33
|
+
* - Something less obvious, but potentially more useful to clients?
|
|
34
|
+
*/
|
|
35
|
+
setLanguage(language: FormLanguage): unknown;
|
|
36
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { ActiveLanguage } from '../../client/FormLanguage.ts';
|
|
2
3
|
export interface TranslationContext {
|
|
3
|
-
|
|
4
|
+
readonly getActiveLanguage: Accessor<ActiveLanguage>;
|
|
4
5
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { FormNodeID } from '../../client/identity.ts';
|
|
1
2
|
import { AnyViolation } from '../../client/validation.ts';
|
|
2
3
|
import { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
3
4
|
import { MessageDefinition } from '../../parse/text/MessageDefinition.ts';
|
|
4
|
-
import { NodeID } from '../identity.ts';
|
|
5
5
|
import { EvaluationContext } from './EvaluationContext.ts';
|
|
6
|
-
import { SubscribableDependency } from './SubscribableDependency.ts';
|
|
7
6
|
interface ValidationContextCurrentState {
|
|
8
7
|
get reference(): string;
|
|
9
8
|
}
|
|
@@ -16,8 +15,8 @@ interface ValidationContextDefinitionBind {
|
|
|
16
15
|
interface ValidationContextDefinition {
|
|
17
16
|
readonly bind: ValidationContextDefinitionBind;
|
|
18
17
|
}
|
|
19
|
-
export interface ValidationContext extends EvaluationContext
|
|
20
|
-
readonly nodeId:
|
|
18
|
+
export interface ValidationContext extends EvaluationContext {
|
|
19
|
+
readonly nodeId: FormNodeID;
|
|
21
20
|
readonly definition: ValidationContextDefinition;
|
|
22
21
|
readonly currentState: ValidationContextCurrentState;
|
|
23
22
|
getViolation(): AnyViolation | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
1
2
|
import { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
3
|
import { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
3
4
|
import { EvaluationContext } from './EvaluationContext.ts';
|
|
@@ -13,7 +14,7 @@ export interface ValueContextDefinition {
|
|
|
13
14
|
export interface ValueContext<RuntimeValue> extends EvaluationContext {
|
|
14
15
|
readonly scope: ReactiveScope;
|
|
15
16
|
readonly definition: ValueContextDefinition;
|
|
16
|
-
readonly contextNode:
|
|
17
|
+
readonly contextNode: EngineXPathNode & this;
|
|
17
18
|
isReadonly(): boolean;
|
|
18
19
|
isRelevant(): boolean;
|
|
19
20
|
readonly encodeValue: (this: unknown, runtimeValue: RuntimeValue) => InstanceValue;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SubmissionDefinition } from '../../../client/submission/SubmissionDefinition.ts';
|
|
2
|
+
import { AncestorNodeValidationState } from '../../../client/validation.ts';
|
|
3
|
+
import { Root } from '../../Root.ts';
|
|
4
|
+
import { ClientReactiveSubmittableParentNode, ClientReactiveSubmittableParentNodeDefinition } from './ClientReactiveSubmittableParentNode.ts';
|
|
5
|
+
interface ClientReactiveSubmittableInstanceDefinition extends ClientReactiveSubmittableParentNodeDefinition {
|
|
6
|
+
readonly submission: SubmissionDefinition;
|
|
7
|
+
}
|
|
8
|
+
export interface ClientReactiveSubmittableInstance extends ClientReactiveSubmittableParentNode<Root> {
|
|
9
|
+
readonly definition: ClientReactiveSubmittableInstanceDefinition;
|
|
10
|
+
readonly root: Root;
|
|
11
|
+
readonly parent: null;
|
|
12
|
+
readonly validationState: AncestorNodeValidationState;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import { EscapedXMLText } from '../../../lib/xml-serialization.ts';
|
|
3
|
+
import { ClientReactiveSubmittableChildNode, ClientReactiveSubmittableParentNode } from './ClientReactiveSubmittableParentNode.ts';
|
|
4
|
+
interface ClientReactiveSubmittableLeafNodeCurrentState<RuntimeValue> {
|
|
5
|
+
get relevant(): boolean;
|
|
6
|
+
get value(): RuntimeValue;
|
|
7
|
+
}
|
|
8
|
+
export type SerializedSubmissionValue = string;
|
|
9
|
+
interface ClientReactiveSubmittableLeafNodeDefinition {
|
|
10
|
+
readonly nodeName: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ClientReactiveSubmittableLeafNode<RuntimeValue> {
|
|
13
|
+
readonly definition: ClientReactiveSubmittableLeafNodeDefinition;
|
|
14
|
+
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode>;
|
|
15
|
+
readonly currentState: ClientReactiveSubmittableLeafNodeCurrentState<RuntimeValue>;
|
|
16
|
+
/**
|
|
17
|
+
* A client-reactive submittable leaf node is responsible for producing a
|
|
18
|
+
* string representation of its value state, suitable for serialization for
|
|
19
|
+
* submission. It **MUST NOT** perform any further submission-specific
|
|
20
|
+
* serialization duties: in particular, the value **MUST NOT** be escaped for
|
|
21
|
+
* XML. This responsibility is delegated up the stack, to avoid repeat
|
|
22
|
+
* escaping.
|
|
23
|
+
*
|
|
24
|
+
* Note: excluding {@link EscapedXMLText} here does not have an effect on the
|
|
25
|
+
* type system, it is a documentation-only hint, to help guard against future
|
|
26
|
+
* double-escaping mistakes.
|
|
27
|
+
*/
|
|
28
|
+
readonly encodeValue: (this: unknown, runtimeValue: RuntimeValue) => Exclude<string, EscapedXMLText>;
|
|
29
|
+
readonly submissionState: SubmissionState;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
export interface ClientReactiveSubmittableChildNode {
|
|
3
|
+
readonly submissionState: SubmissionState;
|
|
4
|
+
}
|
|
5
|
+
interface ClientReactiveSubmittableParentNodeCurrentState<Child extends ClientReactiveSubmittableChildNode> {
|
|
6
|
+
get relevant(): boolean;
|
|
7
|
+
get children(): readonly Child[];
|
|
8
|
+
}
|
|
9
|
+
export interface ClientReactiveSubmittableParentNodeDefinition {
|
|
10
|
+
readonly nodeName: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ClientReactiveSubmittableParentNode<Child extends ClientReactiveSubmittableChildNode> {
|
|
13
|
+
readonly definition: ClientReactiveSubmittableParentNodeDefinition;
|
|
14
|
+
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode> | null;
|
|
15
|
+
readonly currentState: ClientReactiveSubmittableParentNodeCurrentState<Child>;
|
|
16
|
+
readonly submissionState: SubmissionState;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import { ClientReactiveSubmittableChildNode, ClientReactiveSubmittableParentNode } from './ClientReactiveSubmittableParentNode.ts';
|
|
3
|
+
interface ClientReactiveSubmittableValueNodeCurrentState {
|
|
4
|
+
get relevant(): boolean;
|
|
5
|
+
get instanceValue(): string;
|
|
6
|
+
}
|
|
7
|
+
export type SerializedSubmissionValue = string;
|
|
8
|
+
interface ClientReactiveSubmittableValueNodeDefinition {
|
|
9
|
+
readonly nodeName: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ClientReactiveSubmittableValueNode {
|
|
12
|
+
readonly definition: ClientReactiveSubmittableValueNodeDefinition;
|
|
13
|
+
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode>;
|
|
14
|
+
readonly currentState: ClientReactiveSubmittableValueNodeCurrentState;
|
|
15
|
+
readonly submissionState: SubmissionState;
|
|
16
|
+
}
|
|
17
|
+
export {};
|