@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
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import type { BaseValueNode } from '../../client/BaseValueNode.ts';
|
|
4
|
+
import type { LeafNodeType as ValueNodeType } from '../../client/node-types.ts';
|
|
5
|
+
import type { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
6
|
+
import type { AnyViolation, LeafNodeValidationState } from '../../client/validation.ts';
|
|
7
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
8
|
+
import type { XFormsXPathElement } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
9
|
+
import { createValueNodeSubmissionState } from '../../lib/client-reactivity/submission/createValueNodeSubmissionState.ts';
|
|
10
|
+
import type {
|
|
11
|
+
RuntimeValueSetter,
|
|
12
|
+
RuntimeValueState,
|
|
13
|
+
ValueCodec,
|
|
14
|
+
} from '../../lib/codecs/ValueCodec.ts';
|
|
15
|
+
import { createInstanceValueState } from '../../lib/reactivity/createInstanceValueState.ts';
|
|
16
|
+
import type { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
17
|
+
import type { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
18
|
+
import type { SharedNodeState } from '../../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
19
|
+
import type { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
20
|
+
import type { SharedValidationState } from '../../lib/reactivity/validation/createValidation.ts';
|
|
21
|
+
import { createValidationState } from '../../lib/reactivity/validation/createValidation.ts';
|
|
22
|
+
import { LeafNodeDefinition } from '../../parse/model/LeafNodeDefinition.ts';
|
|
23
|
+
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
24
|
+
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
25
|
+
import type {
|
|
26
|
+
DecodeInstanceValue,
|
|
27
|
+
InstanceValueContext,
|
|
28
|
+
} from '../internal-api/InstanceValueContext.ts';
|
|
29
|
+
import type { ClientReactiveSubmittableValueNode } from '../internal-api/submission/ClientReactiveSubmittableValueNode.ts';
|
|
30
|
+
import type { ValidationContext } from '../internal-api/ValidationContext.ts';
|
|
31
|
+
import type { DescendantNodeStateSpec } from './DescendantNode.ts';
|
|
32
|
+
import { DescendantNode } from './DescendantNode.ts';
|
|
33
|
+
|
|
34
|
+
export type ValueNodeDefinition<V extends ValueType> = LeafNodeDefinition<V>;
|
|
35
|
+
|
|
36
|
+
export interface ValueNodeStateSpec<RuntimeValue> extends DescendantNodeStateSpec<RuntimeValue> {
|
|
37
|
+
readonly children: null;
|
|
38
|
+
readonly valueOptions: null;
|
|
39
|
+
readonly value: SimpleAtomicState<RuntimeValue>;
|
|
40
|
+
readonly instanceValue: Accessor<string>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export abstract class ValueNode<
|
|
44
|
+
V extends ValueType,
|
|
45
|
+
Definition extends ValueNodeDefinition<V>,
|
|
46
|
+
RuntimeValue extends RuntimeInputValue,
|
|
47
|
+
RuntimeInputValue = RuntimeValue,
|
|
48
|
+
>
|
|
49
|
+
extends DescendantNode<Definition, ValueNodeStateSpec<RuntimeValue>, GeneralParentNode, null>
|
|
50
|
+
implements
|
|
51
|
+
BaseValueNode<V, RuntimeValue>,
|
|
52
|
+
XFormsXPathElement,
|
|
53
|
+
EvaluationContext,
|
|
54
|
+
InstanceValueContext,
|
|
55
|
+
ValidationContext,
|
|
56
|
+
ClientReactiveSubmittableValueNode
|
|
57
|
+
{
|
|
58
|
+
protected readonly validation: SharedValidationState;
|
|
59
|
+
protected readonly getInstanceValue: Accessor<string>;
|
|
60
|
+
protected readonly valueState: RuntimeValueState<RuntimeValue>;
|
|
61
|
+
protected readonly setValueState: RuntimeValueSetter<RuntimeInputValue>;
|
|
62
|
+
|
|
63
|
+
// XFormsXPathElement
|
|
64
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
65
|
+
override readonly getXPathValue: () => string;
|
|
66
|
+
|
|
67
|
+
// InstanceNode
|
|
68
|
+
protected abstract override readonly state: SharedNodeState<ValueNodeStateSpec<RuntimeValue>>;
|
|
69
|
+
protected abstract override readonly engineState: EngineState<ValueNodeStateSpec<RuntimeValue>>;
|
|
70
|
+
|
|
71
|
+
// InstanceValueContext
|
|
72
|
+
readonly decodeInstanceValue: DecodeInstanceValue;
|
|
73
|
+
|
|
74
|
+
// BaseValueNode
|
|
75
|
+
abstract override readonly nodeType: ValueNodeType;
|
|
76
|
+
readonly valueType: V;
|
|
77
|
+
|
|
78
|
+
abstract override readonly currentState: CurrentState<ValueNodeStateSpec<RuntimeValue>>;
|
|
79
|
+
|
|
80
|
+
get validationState(): LeafNodeValidationState {
|
|
81
|
+
return this.validation.currentState;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
readonly submissionState: SubmissionState;
|
|
85
|
+
|
|
86
|
+
constructor(
|
|
87
|
+
parent: GeneralParentNode,
|
|
88
|
+
definition: Definition,
|
|
89
|
+
codec: ValueCodec<V, RuntimeValue, RuntimeInputValue>
|
|
90
|
+
) {
|
|
91
|
+
super(parent, definition);
|
|
92
|
+
|
|
93
|
+
this.valueType = definition.valueType;
|
|
94
|
+
this.decodeInstanceValue = codec.decodeInstanceValue;
|
|
95
|
+
|
|
96
|
+
const instanceValueState = createInstanceValueState(this, {
|
|
97
|
+
initialValueSource: 'FORM_DEFAULT',
|
|
98
|
+
});
|
|
99
|
+
const valueState = codec.createRuntimeValueState(instanceValueState);
|
|
100
|
+
|
|
101
|
+
const [getInstanceValue] = instanceValueState;
|
|
102
|
+
const [, setValueState] = valueState;
|
|
103
|
+
|
|
104
|
+
this.getInstanceValue = getInstanceValue;
|
|
105
|
+
this.setValueState = setValueState;
|
|
106
|
+
this.getXPathValue = getInstanceValue;
|
|
107
|
+
this.valueState = valueState;
|
|
108
|
+
this.validation = createValidationState(this, {
|
|
109
|
+
clientStateFactory: this.engineConfig.stateFactory,
|
|
110
|
+
});
|
|
111
|
+
this.submissionState = createValueNodeSubmissionState(this);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ValidationContext
|
|
115
|
+
getViolation(): AnyViolation | null {
|
|
116
|
+
return this.validation.engineState.violation;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
isBlank(): boolean {
|
|
120
|
+
return this.getInstanceValue() === '';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// InstanceNode
|
|
124
|
+
getChildren(): readonly [] {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
}
|
package/src/instance/children.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
2
2
|
import type { GroupDefinition } from '../client/GroupNode.ts';
|
|
3
|
+
import type { InputDefinition } from '../client/InputNode.ts';
|
|
4
|
+
import type { ModelValueDefinition } from '../client/ModelValueNode.ts';
|
|
3
5
|
import type { SubtreeDefinition } from '../client/SubtreeNode.ts';
|
|
4
6
|
import type { TriggerNodeDefinition } from '../client/TriggerNode.ts';
|
|
5
7
|
import type { RangeNodeDefinition } from '../client/unsupported/RangeNode.ts';
|
|
@@ -11,14 +13,13 @@ import { NoteNodeDefinition } from '../parse/model/NoteNodeDefinition.ts';
|
|
|
11
13
|
import type { SubtreeDefinition as ModelSubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
|
|
12
14
|
import { Group } from './Group.ts';
|
|
13
15
|
import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
14
|
-
import {
|
|
16
|
+
import { InputControl } from './InputControl.ts';
|
|
17
|
+
import { ModelValue } from './ModelValue.ts';
|
|
15
18
|
import { Note } from './Note.ts';
|
|
16
19
|
import { RepeatRangeControlled } from './repeat/RepeatRangeControlled.ts';
|
|
17
20
|
import { RepeatRangeUncontrolled } from './repeat/RepeatRangeUncontrolled.ts';
|
|
18
21
|
import type { SelectFieldDefinition } from './SelectField.ts';
|
|
19
22
|
import { SelectField } from './SelectField.ts';
|
|
20
|
-
import type { StringFieldDefinition } from './StringField.ts';
|
|
21
|
-
import { StringField } from './StringField.ts';
|
|
22
23
|
import { Subtree } from './Subtree.ts';
|
|
23
24
|
import { TriggerControl } from './TriggerControl.ts';
|
|
24
25
|
import { RangeControl } from './unsupported/RangeControl.ts';
|
|
@@ -39,8 +40,8 @@ type AnyUnsupportedControlDefinition =
|
|
|
39
40
|
// prettier-ignore
|
|
40
41
|
type ControlNodeDefinition =
|
|
41
42
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
43
|
+
| InputDefinition
|
|
42
44
|
| SelectFieldDefinition
|
|
43
|
-
| StringFieldDefinition
|
|
44
45
|
| TriggerNodeDefinition
|
|
45
46
|
| AnyUnsupportedControlDefinition;
|
|
46
47
|
|
|
@@ -52,9 +53,7 @@ const isModelValueDefinition = (
|
|
|
52
53
|
return definition.bodyElement == null;
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
const
|
|
56
|
-
definition: ControlNodeDefinition
|
|
57
|
-
): definition is StringFieldDefinition => {
|
|
56
|
+
const isInputDefinition = (definition: ControlNodeDefinition): definition is InputDefinition => {
|
|
58
57
|
return definition.bodyElement.type === 'input';
|
|
59
58
|
};
|
|
60
59
|
|
|
@@ -121,11 +120,11 @@ export const buildChildren = (parent: GeneralParentNode): GeneralChildNode[] =>
|
|
|
121
120
|
const leafChild: AnyLeafNodeDefinition = child;
|
|
122
121
|
|
|
123
122
|
if (isModelValueDefinition(leafChild)) {
|
|
124
|
-
return
|
|
123
|
+
return ModelValue.from(parent, leafChild);
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
if (
|
|
128
|
-
return
|
|
126
|
+
if (isInputDefinition(leafChild)) {
|
|
127
|
+
return InputControl.from(parent, leafChild);
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
if (isSelectFieldDefinition(leafChild)) {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { Group } from './Group.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyInputControl } from './InputControl.ts';
|
|
3
|
+
import type { AnyModelValue } from './ModelValue.ts';
|
|
3
4
|
import type { Note } from './Note.ts';
|
|
5
|
+
import type { PrimaryInstance } from './PrimaryInstance.ts';
|
|
4
6
|
import type { RepeatInstance } from './repeat/RepeatInstance.ts';
|
|
5
7
|
import type { RepeatRangeControlled } from './repeat/RepeatRangeControlled.ts';
|
|
6
8
|
import type { RepeatRangeUncontrolled } from './repeat/RepeatRangeUncontrolled.ts';
|
|
7
9
|
import type { Root } from './Root.ts';
|
|
8
10
|
import type { SelectField } from './SelectField.ts';
|
|
9
|
-
import type { StringField } from './StringField.ts';
|
|
10
11
|
import type { Subtree } from './Subtree.ts';
|
|
11
12
|
import type { TriggerControl } from './TriggerControl.ts';
|
|
12
13
|
import type { RangeControl } from './unsupported/RangeControl.ts';
|
|
@@ -16,7 +17,7 @@ import type { UploadControl } from './unsupported/UploadControl.ts';
|
|
|
16
17
|
export type RepeatRange = RepeatRangeControlled | RepeatRangeUncontrolled;
|
|
17
18
|
|
|
18
19
|
// prettier-ignore
|
|
19
|
-
export type
|
|
20
|
+
export type AnyUnsupportedControl =
|
|
20
21
|
| RangeControl
|
|
21
22
|
| RankControl
|
|
22
23
|
| UploadControl;
|
|
@@ -24,21 +25,23 @@ export type UnsupportedControl =
|
|
|
24
25
|
// prettier-ignore
|
|
25
26
|
export type AnyNode =
|
|
26
27
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
28
|
+
| PrimaryInstance
|
|
27
29
|
| Root
|
|
28
30
|
| Group
|
|
29
31
|
| Subtree
|
|
30
32
|
| RepeatRange
|
|
31
33
|
| RepeatInstance
|
|
32
34
|
| Note
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
+
| AnyModelValue
|
|
36
|
+
| AnyInputControl
|
|
35
37
|
| SelectField
|
|
36
38
|
| TriggerControl
|
|
37
|
-
|
|
|
39
|
+
| AnyUnsupportedControl;
|
|
38
40
|
|
|
39
41
|
// prettier-ignore
|
|
40
42
|
export type AnyParentNode =
|
|
41
43
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
44
|
+
| PrimaryInstance
|
|
42
45
|
| Root
|
|
43
46
|
| Group
|
|
44
47
|
| Subtree
|
|
@@ -56,16 +59,17 @@ export type GeneralParentNode =
|
|
|
56
59
|
// prettier-ignore
|
|
57
60
|
export type AnyChildNode =
|
|
58
61
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
62
|
+
| Root
|
|
59
63
|
| Group
|
|
60
64
|
| Subtree
|
|
61
65
|
| RepeatRange
|
|
62
66
|
| RepeatInstance
|
|
63
|
-
|
|
|
67
|
+
| AnyModelValue
|
|
64
68
|
| Note
|
|
65
|
-
|
|
|
69
|
+
| AnyInputControl
|
|
66
70
|
| SelectField
|
|
67
71
|
| TriggerControl
|
|
68
|
-
|
|
|
72
|
+
| AnyUnsupportedControl;
|
|
69
73
|
|
|
70
74
|
// prettier-ignore
|
|
71
75
|
export type GeneralChildNode =
|
|
@@ -73,19 +77,19 @@ export type GeneralChildNode =
|
|
|
73
77
|
| Group
|
|
74
78
|
| Subtree
|
|
75
79
|
| RepeatRange
|
|
76
|
-
|
|
|
80
|
+
| AnyModelValue
|
|
77
81
|
| Note
|
|
78
|
-
|
|
|
82
|
+
| AnyInputControl
|
|
79
83
|
| SelectField
|
|
80
84
|
| TriggerControl
|
|
81
|
-
|
|
|
85
|
+
| AnyUnsupportedControl;
|
|
82
86
|
|
|
83
87
|
// prettier-ignore
|
|
84
88
|
export type AnyValueNode =
|
|
85
89
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
86
|
-
|
|
|
90
|
+
| AnyModelValue
|
|
87
91
|
| Note
|
|
88
|
-
|
|
|
92
|
+
| AnyInputControl
|
|
89
93
|
| SelectField
|
|
90
94
|
| TriggerControl
|
|
91
|
-
|
|
|
95
|
+
| AnyUnsupportedControl;
|
package/src/instance/identity.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
type NODE_ID_BRAND = typeof NODE_ID_BRAND;
|
|
1
|
+
import type { FormNodeID } from '../client/identity.ts';
|
|
3
2
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
// Just another added safeguard to ensure we're not mistakenly handling
|
|
7
|
-
// rando `NodeID` strings which aren't explicitly attached to the node
|
|
8
|
-
// types we expect.
|
|
9
|
-
export const declareNodeID = (id: string): NodeID => {
|
|
10
|
-
return id as NodeID;
|
|
3
|
+
export const nodeID = (id: string): FormNodeID => {
|
|
4
|
+
return `node:${id}` satisfies FormNodeID;
|
|
11
5
|
};
|
package/src/instance/index.ts
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import { identity } from '@getodk/common/lib/identity.ts';
|
|
2
|
+
import { getOwner } from 'solid-js';
|
|
3
|
+
import type { EngineConfig } from '../client/EngineConfig.ts';
|
|
2
4
|
import type { RootNode } from '../client/RootNode.ts';
|
|
5
|
+
import { MISSING_RESOURCE_BEHAVIOR } from '../client/constants.ts';
|
|
3
6
|
import type {
|
|
4
7
|
InitializeFormOptions as BaseInitializeFormOptions,
|
|
5
8
|
FormResource,
|
|
6
9
|
InitializeForm,
|
|
7
10
|
} from '../client/index.ts';
|
|
8
11
|
import { retrieveSourceXMLResource } from '../instance/resource.ts';
|
|
12
|
+
import { createReactiveScope } from '../lib/reactivity/scope.ts';
|
|
9
13
|
import { createUniqueId } from '../lib/unique-id.ts';
|
|
14
|
+
import { XFormDOM } from '../parse/XFormDOM.ts';
|
|
10
15
|
import { XFormDefinition } from '../parse/XFormDefinition.ts';
|
|
11
|
-
import {
|
|
16
|
+
import { SecondaryInstancesDefinition } from '../parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts';
|
|
17
|
+
import { PrimaryInstance } from './PrimaryInstance.ts';
|
|
12
18
|
import type { InstanceConfig } from './internal-api/InstanceConfig.ts';
|
|
13
19
|
|
|
14
20
|
interface InitializeFormOptions extends BaseInitializeFormOptions {
|
|
15
21
|
readonly config: Partial<InstanceConfig>;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
|
-
const buildInstanceConfig = (options:
|
|
24
|
+
const buildInstanceConfig = (options: EngineConfig = {}): InstanceConfig => {
|
|
19
25
|
return {
|
|
20
|
-
createUniqueId
|
|
21
|
-
|
|
26
|
+
createUniqueId,
|
|
27
|
+
fetchFormDefinition: options.fetchFormDefinition ?? fetch,
|
|
28
|
+
fetchFormAttachment: options.fetchFormAttachment ?? fetch,
|
|
29
|
+
missingResourceBehavior: options.missingResourceBehavior ?? MISSING_RESOURCE_BEHAVIOR.DEFAULT,
|
|
22
30
|
stateFactory: options.stateFactory ?? identity,
|
|
23
31
|
};
|
|
24
32
|
};
|
|
@@ -27,11 +35,21 @@ export const initializeForm = async (
|
|
|
27
35
|
input: FormResource,
|
|
28
36
|
options: Partial<InitializeFormOptions> = {}
|
|
29
37
|
): Promise<RootNode> => {
|
|
38
|
+
const owner = getOwner();
|
|
39
|
+
const scope = createReactiveScope({ owner });
|
|
30
40
|
const engineConfig = buildInstanceConfig(options.config);
|
|
31
|
-
const sourceXML = await retrieveSourceXMLResource(input,
|
|
32
|
-
|
|
41
|
+
const sourceXML = await retrieveSourceXMLResource(input, {
|
|
42
|
+
fetchResource: engineConfig.fetchFormDefinition,
|
|
43
|
+
});
|
|
44
|
+
const xformDOM = XFormDOM.from(sourceXML);
|
|
45
|
+
const secondaryInstances = await SecondaryInstancesDefinition.load(xformDOM, {
|
|
46
|
+
fetchResource: engineConfig.fetchFormAttachment,
|
|
47
|
+
missingResourceBehavior: engineConfig.missingResourceBehavior,
|
|
48
|
+
});
|
|
49
|
+
const form = new XFormDefinition(xformDOM);
|
|
50
|
+
const primaryInstance = new PrimaryInstance(scope, form.model, secondaryInstances, engineConfig);
|
|
33
51
|
|
|
34
|
-
return
|
|
52
|
+
return primaryInstance.root;
|
|
35
53
|
};
|
|
36
54
|
|
|
37
55
|
initializeForm satisfies InitializeForm;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import type { XFormsXPathEvaluator } from '@getodk/xpath';
|
|
2
1
|
import type { Accessor } from 'solid-js';
|
|
2
|
+
import type { engineDOMAdapter } from '../../integration/xpath/adapter/engineDOMAdapter.ts';
|
|
3
|
+
import type { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
4
|
+
import type { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
5
|
+
import type { StaticNode } from '../../integration/xpath/static-dom/StaticNode.ts';
|
|
6
|
+
import type { createComputedExpression } from '../../lib/reactivity/createComputedExpression.ts';
|
|
7
|
+
import type { createTranslationState } from '../../lib/reactivity/createTranslationState.ts';
|
|
3
8
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
4
9
|
import type { DependentExpression } from '../../parse/expression/abstract/DependentExpression.ts';
|
|
5
|
-
import type {
|
|
10
|
+
import type { InstanceNode } from '../abstract/InstanceNode.ts';
|
|
11
|
+
import type { PrimaryInstance } from '../PrimaryInstance.ts';
|
|
6
12
|
import type { TranslationContext } from './TranslationContext.ts';
|
|
7
13
|
|
|
8
|
-
export interface EvaluationContextRoot extends SubscribableDependency, TranslationContext {}
|
|
9
|
-
|
|
10
14
|
/**
|
|
11
15
|
* Provides a common interface to establish context for XPath-based
|
|
12
16
|
* computations, i.e. to evaluate {@link DependentExpression}s where:
|
|
@@ -18,23 +22,66 @@ export interface EvaluationContextRoot extends SubscribableDependency, Translati
|
|
|
18
22
|
* - the expression may be dependent on the form's currently active language
|
|
19
23
|
* (e.g. `jr:itext`)
|
|
20
24
|
* - any dynamic case is expected to be internally reactive
|
|
25
|
+
*
|
|
26
|
+
* Historical note: we previously utilized static analysis and a related
|
|
27
|
+
* abstraction to set up reactive subscriptions to node references, values, and
|
|
28
|
+
* other pertinent state changes warranting an expression's recomputation. Those
|
|
29
|
+
* are still described above because they provide useful insight for the
|
|
30
|
+
* **effect** of evaluating a given {@link DependentExpression}, with a given
|
|
31
|
+
* {@link EvaluationContext}.
|
|
32
|
+
*
|
|
33
|
+
* The reactive subscription mechanism has since been largely replaced, with the
|
|
34
|
+
* engine's implementation of {@link EngineXPathEvaluator} and its corresponding
|
|
35
|
+
* {@link engineDOMAdapter | XPath DOM adapter implementation}.
|
|
36
|
+
*
|
|
37
|
+
* @todo There is still one notable exception: translation expressions (i.e.
|
|
38
|
+
* expressions calling {@link https://getodk.github.io/xforms-spec/#fn:jr:itext}
|
|
39
|
+
* | `jr:itext`). We still perform analysis to identify such calls, and when
|
|
40
|
+
* evaluating those expressions we still explicitly subscribe to the form's
|
|
41
|
+
* active language state. A further refactor, moving more of the responsibility
|
|
42
|
+
* for translation state up out of `@getodk/xpath` into the engine, would likely
|
|
43
|
+
* allow us to further simplify the engine's reactive XPath recomputation
|
|
44
|
+
* approach.
|
|
45
|
+
*
|
|
46
|
+
* @see {@link createTranslationState} for additional context.
|
|
21
47
|
*/
|
|
22
|
-
export interface EvaluationContext {
|
|
48
|
+
export interface EvaluationContext extends TranslationContext {
|
|
49
|
+
/**
|
|
50
|
+
* Used to determine whether {@link contextNode} is attached to its
|
|
51
|
+
* {@link EngineXPathNode} document hierarchy.
|
|
52
|
+
*
|
|
53
|
+
* - If this function returns `true`: expressions are evaluated as defined.
|
|
54
|
+
* - If this function returns `false`: expressions are evaluated to either an
|
|
55
|
+
* explicit default value (if provided) or an implicit default value
|
|
56
|
+
* appropriate for the requested result type.
|
|
57
|
+
*
|
|
58
|
+
* @see {@link createComputedExpression} for further detail on the latter.
|
|
59
|
+
*/
|
|
60
|
+
readonly isAttached: Accessor<boolean>;
|
|
61
|
+
|
|
23
62
|
readonly scope: ReactiveScope;
|
|
24
|
-
readonly evaluator:
|
|
25
|
-
readonly root: EvaluationContextRoot;
|
|
63
|
+
readonly evaluator: EngineXPathEvaluator;
|
|
26
64
|
|
|
27
65
|
/**
|
|
28
66
|
* Produces the current absolute reference to the {@link contextNode}, where
|
|
29
|
-
* the
|
|
67
|
+
* the AbsoluteLocationPath expression `/` resolves to the active
|
|
68
|
+
* {@link PrimaryInstance}, and each Step and/or position Predicate from there
|
|
69
|
+
* corresponds to the node hierarchy descending from there.
|
|
30
70
|
*/
|
|
31
71
|
readonly contextReference: Accessor<string>;
|
|
32
72
|
|
|
33
|
-
readonly contextNode: Node;
|
|
34
|
-
|
|
35
73
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
74
|
+
* Note: in most cases, implementations of {@link EvaluationContext} will
|
|
75
|
+
* **also** be an implementation of {@link EngineXPathNode} (as concrete
|
|
76
|
+
* implementations of {@link InstanceNode}). This property is an intentional
|
|
77
|
+
* indirection which:
|
|
78
|
+
*
|
|
79
|
+
* - Expresses only the much more limited set of properties which must be
|
|
80
|
+
* present to initialize computations during those nodes' construction.
|
|
81
|
+
*
|
|
82
|
+
* - Allows for a handful of cases where an {@link InstanceNode} provides the
|
|
83
|
+
* requisite facilities for evaluating expressions in a {@link StaticNode}'s
|
|
84
|
+
* context (itemsets being a prominent example).
|
|
38
85
|
*/
|
|
39
|
-
|
|
86
|
+
readonly contextNode: EngineXPathNode;
|
|
40
87
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MissingResourceBehavior } from '../../client/constants.ts';
|
|
2
|
+
import type { OpaqueReactiveObjectFactory } from '../../client/OpaqueReactiveObjectFactory.ts';
|
|
3
|
+
import type { FetchFormAttachment, FetchResource } from '../../client/resources.ts';
|
|
2
4
|
import type { CreateUniqueId } from '../../lib/unique-id.ts';
|
|
3
5
|
|
|
4
|
-
export interface InstanceConfig
|
|
6
|
+
export interface InstanceConfig {
|
|
7
|
+
readonly stateFactory: OpaqueReactiveObjectFactory;
|
|
8
|
+
readonly fetchFormDefinition: FetchResource;
|
|
9
|
+
readonly fetchFormAttachment: FetchFormAttachment;
|
|
10
|
+
readonly missingResourceBehavior: MissingResourceBehavior;
|
|
11
|
+
|
|
5
12
|
/**
|
|
6
13
|
* Uniqueness per form instance session (so e.g. persistence isn't necessary).
|
|
7
14
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
|
+
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
3
|
+
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
4
|
+
|
|
5
|
+
export type DecodeInstanceValue = (value: string) => string;
|
|
6
|
+
|
|
7
|
+
interface InstanceValueContextDefinitionBind {
|
|
8
|
+
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
9
|
+
readonly readonly: BindComputationExpression<'readonly'>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface InstanceValueContextDefinition {
|
|
13
|
+
readonly bind: InstanceValueContextDefinitionBind;
|
|
14
|
+
readonly defaultValue: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface InstanceValueContext extends EvaluationContext {
|
|
18
|
+
readonly scope: ReactiveScope;
|
|
19
|
+
readonly definition: InstanceValueContextDefinition;
|
|
20
|
+
readonly decodeInstanceValue: DecodeInstanceValue;
|
|
21
|
+
|
|
22
|
+
isReadonly(): boolean;
|
|
23
|
+
isRelevant(): boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { FormLanguage } from '../../client/FormLanguage.ts';
|
|
2
|
+
import type { RootNode, RootNodeState } from '../../client/RootNode.ts';
|
|
3
|
+
|
|
4
|
+
export interface PrimaryInstanceDocumentState
|
|
5
|
+
extends Omit<
|
|
6
|
+
RootNodeState,
|
|
7
|
+
// Allow for override with `RootNode`, which is not presently considered a
|
|
8
|
+
// child node in the client API
|
|
9
|
+
'children'
|
|
10
|
+
> {
|
|
11
|
+
/**
|
|
12
|
+
* @todo while this is an internal interface, this feels like maybe an
|
|
13
|
+
* unnecessary indirection? It would probably be fine for it to reference
|
|
14
|
+
* `Root` directly? We do get some minor benefit from making sure the client
|
|
15
|
+
* and internal types are aligned, but we also already enforce that by
|
|
16
|
+
* ensuring `Root implements RootNode`...
|
|
17
|
+
*/
|
|
18
|
+
get children(): readonly RootNode[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Provides an interface most similar to what we would expose at the
|
|
23
|
+
* `@getodk/xforms-engine` package boundary, if we were to document the primary
|
|
24
|
+
* instance document's types for a client.
|
|
25
|
+
*
|
|
26
|
+
* 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.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export interface PrimaryInstanceDocument
|
|
30
|
+
extends Omit<
|
|
31
|
+
RootNode,
|
|
32
|
+
// prettier-ignore
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
34
|
+
| 'nodeType' // Allow for override with 'primary-instance'
|
|
35
|
+
| 'currentState' // Allow for override of `children`
|
|
36
|
+
| 'setLanguage' // Allow for override of return type
|
|
37
|
+
> {
|
|
38
|
+
readonly nodeType: 'primary-instance';
|
|
39
|
+
readonly currentState: PrimaryInstanceDocumentState;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @todo This intentionally returns `unknown` as a hint that we will likely
|
|
43
|
+
* want to move away from returning {@link RootNode} (i.e. "all of the state",
|
|
44
|
+
* as it was conceived in that design effort) on every state change.
|
|
45
|
+
*
|
|
46
|
+
* In this case, it may be sensible to return any of:
|
|
47
|
+
*
|
|
48
|
+
* - Just the state set directly (i.e. the input {@link FormLanguage})
|
|
49
|
+
* - That effective state, and some representation of all affected nodes
|
|
50
|
+
* - Something less obvious, but potentially more useful to clients?
|
|
51
|
+
*/
|
|
52
|
+
setLanguage(language: FormLanguage): unknown;
|
|
53
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Accessor } from 'solid-js';
|
|
2
|
+
import type { ActiveLanguage } from '../../client/FormLanguage.ts';
|
|
2
3
|
|
|
3
4
|
export interface TranslationContext {
|
|
4
|
-
|
|
5
|
+
readonly getActiveLanguage: Accessor<ActiveLanguage>;
|
|
5
6
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import type { FormNodeID } from '../../client/identity.ts';
|
|
1
2
|
import type { AnyViolation } from '../../client/validation.ts';
|
|
2
3
|
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
3
4
|
import type { MessageDefinition } from '../../parse/text/MessageDefinition.ts';
|
|
4
|
-
import type { NodeID } from '../identity.ts';
|
|
5
5
|
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
6
|
-
import type { SubscribableDependency } from './SubscribableDependency.ts';
|
|
7
6
|
|
|
8
7
|
interface ValidationContextCurrentState {
|
|
9
8
|
get reference(): string;
|
|
@@ -20,8 +19,8 @@ interface ValidationContextDefinition {
|
|
|
20
19
|
readonly bind: ValidationContextDefinitionBind;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
export interface ValidationContext extends EvaluationContext
|
|
24
|
-
readonly nodeId:
|
|
22
|
+
export interface ValidationContext extends EvaluationContext {
|
|
23
|
+
readonly nodeId: FormNodeID;
|
|
25
24
|
readonly definition: ValidationContextDefinition;
|
|
26
25
|
readonly currentState: ValidationContextCurrentState;
|
|
27
26
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
1
2
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
3
|
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
3
4
|
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
@@ -17,7 +18,7 @@ export interface ValueContextDefinition {
|
|
|
17
18
|
export interface ValueContext<RuntimeValue> extends EvaluationContext {
|
|
18
19
|
readonly scope: ReactiveScope;
|
|
19
20
|
readonly definition: ValueContextDefinition;
|
|
20
|
-
readonly contextNode:
|
|
21
|
+
readonly contextNode: EngineXPathNode & this;
|
|
21
22
|
|
|
22
23
|
isReadonly(): boolean;
|
|
23
24
|
isRelevant(): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SubmissionDefinition } from '../../../client/submission/SubmissionDefinition.ts';
|
|
2
|
+
import type { AncestorNodeValidationState } from '../../../client/validation.ts';
|
|
3
|
+
import type { Root } from '../../Root.ts';
|
|
4
|
+
import type {
|
|
5
|
+
ClientReactiveSubmittableParentNode,
|
|
6
|
+
ClientReactiveSubmittableParentNodeDefinition,
|
|
7
|
+
} from './ClientReactiveSubmittableParentNode.ts';
|
|
8
|
+
|
|
9
|
+
interface ClientReactiveSubmittableInstanceDefinition
|
|
10
|
+
extends ClientReactiveSubmittableParentNodeDefinition {
|
|
11
|
+
readonly submission: SubmissionDefinition;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ClientReactiveSubmittableInstance
|
|
15
|
+
extends ClientReactiveSubmittableParentNode<Root> {
|
|
16
|
+
readonly definition: ClientReactiveSubmittableInstanceDefinition;
|
|
17
|
+
readonly root: Root;
|
|
18
|
+
readonly parent: null;
|
|
19
|
+
readonly validationState: AncestorNodeValidationState;
|
|
20
|
+
}
|