@getodk/xforms-engine 0.3.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 +15 -5
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -49
- package/dist/client/GroupNode.d.ts +2 -3
- package/dist/client/InputNode.d.ts +53 -0
- package/dist/client/ModelValueNode.d.ts +13 -9
- package/dist/client/NodeAppearances.d.ts +1 -2
- package/dist/client/NoteNode.d.ts +3 -4
- package/dist/client/RootNode.d.ts +36 -10
- package/dist/client/SelectNode.d.ts +4 -5
- package/dist/client/SubtreeNode.d.ts +1 -2
- package/dist/client/TextRange.d.ts +3 -4
- package/dist/client/TriggerNode.d.ts +25 -0
- package/dist/client/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -1
- package/dist/client/hierarchy.d.ts +9 -5
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/index.d.ts +0 -1
- package/dist/client/node-types.d.ts +3 -1
- package/dist/client/repeat/BaseRepeatRangeNode.d.ts +1 -2
- package/dist/client/repeat/RepeatInstanceNode.d.ts +2 -3
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +1 -2
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +1 -2
- 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/unsupported/RangeNode.d.ts +9 -0
- package/dist/client/unsupported/RankNode.d.ts +9 -0
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +32 -0
- package/dist/client/unsupported/UploadNode.d.ts +9 -0
- package/dist/client/validation.d.ts +2 -3
- 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 +16 -4
- package/dist/index.js +8559 -4700
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +9 -5
- package/dist/instance/InputControl.d.ts +36 -0
- package/dist/instance/ModelValue.d.ts +16 -27
- package/dist/instance/Note.d.ts +11 -5
- package/dist/instance/PrimaryInstance.d.ts +84 -0
- package/dist/instance/Root.d.ts +31 -28
- package/dist/instance/SelectField.d.ts +13 -6
- package/dist/instance/Subtree.d.ts +10 -6
- package/dist/instance/TriggerControl.d.ts +47 -0
- package/dist/instance/abstract/DescendantNode.d.ts +33 -26
- package/dist/instance/abstract/InstanceNode.d.ts +50 -31
- package/dist/instance/abstract/UnsupportedControl.d.ts +53 -0
- package/dist/instance/abstract/ValueNode.d.ts +48 -0
- package/dist/instance/children.d.ts +0 -1
- package/dist/instance/hierarchy.d.ts +13 -8
- package/dist/instance/identity.d.ts +2 -7
- package/dist/instance/index.d.ts +0 -1
- package/dist/instance/internal-api/EvaluationContext.d.ts +53 -13
- package/dist/instance/internal-api/InstanceConfig.d.ts +8 -3
- 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 -3
- package/dist/instance/internal-api/ValidationContext.d.ts +12 -6
- package/dist/instance/internal-api/ValueContext.d.ts +5 -5
- 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 +40 -85
- package/dist/instance/repeat/RepeatInstance.d.ts +11 -30
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +3 -4
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +3 -4
- package/dist/instance/resource.d.ts +1 -2
- package/dist/instance/text/TextChunk.d.ts +0 -1
- package/dist/instance/text/TextRange.d.ts +1 -2
- package/dist/instance/unsupported/RangeControl.d.ts +6 -0
- package/dist/instance/unsupported/RankControl.d.ts +6 -0
- package/dist/instance/unsupported/UploadControl.d.ts +6 -0
- 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/TokenListParser.d.ts +3 -3
- 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 +4 -2
- package/dist/lib/reactivity/createChildrenState.d.ts +7 -6
- package/dist/lib/reactivity/createComputedExpression.d.ts +19 -7
- package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -3
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -1
- package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
- package/dist/lib/reactivity/createValueState.d.ts +6 -11
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -5
- package/dist/lib/reactivity/node-state/createClientState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createCurrentState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createEngineState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/representations.d.ts +0 -1
- package/dist/lib/reactivity/scope.d.ts +0 -1
- package/dist/lib/reactivity/text/createFieldHint.d.ts +1 -2
- package/dist/lib/reactivity/text/createNodeLabel.d.ts +1 -2
- package/dist/lib/reactivity/text/createNoteText.d.ts +1 -2
- package/dist/lib/reactivity/text/createTextRange.d.ts +0 -1
- package/dist/lib/reactivity/types.d.ts +0 -1
- package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +0 -1
- package/dist/lib/reactivity/validation/createValidation.d.ts +0 -1
- package/dist/lib/xml-serialization.d.ts +41 -0
- package/dist/parse/XFormDOM.d.ts +42 -0
- package/dist/{XFormDefinition.d.ts → parse/XFormDefinition.d.ts} +3 -5
- package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
- package/dist/{body → parse/body}/BodyDefinition.d.ts +16 -11
- package/dist/{body → parse/body}/BodyElementDefinition.d.ts +7 -7
- package/dist/{body → parse/body}/RepeatElementDefinition.d.ts +3 -4
- package/dist/{body → parse/body}/UnsupportedBodyElementDefinition.d.ts +0 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +3 -0
- package/dist/{body → parse/body}/appearance/selectAppearanceParser.d.ts +1 -2
- package/dist/{body → parse/body}/appearance/structureElementAppearanceParser.d.ts +1 -2
- package/dist/parse/body/appearance/unknownAppearanceParser.d.ts +3 -0
- package/dist/{body → parse/body}/control/ControlDefinition.d.ts +3 -4
- package/dist/{body/control/InputDefinition.d.ts → parse/body/control/InputControlDefinition.d.ts} +2 -3
- package/dist/parse/body/control/RangeControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/RankControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/TriggerControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/UploadControlDefinition.d.ts +11 -0
- package/dist/{body → parse/body}/control/select/ItemDefinition.d.ts +2 -3
- package/dist/{body → parse/body}/control/select/ItemsetDefinition.d.ts +4 -5
- package/dist/{body → parse/body}/control/select/ItemsetNodesetContext.d.ts +1 -4
- package/dist/{body → parse/body}/control/select/SelectDefinition.d.ts +3 -12
- package/dist/{body → parse/body}/group/BaseGroupDefinition.d.ts +3 -5
- package/dist/{body → parse/body}/group/LogicalGroupDefinition.d.ts +0 -1
- package/dist/{body → parse/body}/group/PresentationGroupDefinition.d.ts +1 -2
- package/dist/{body → parse/body}/group/StructuralGroupDefinition.d.ts +0 -1
- package/dist/{model/BindComputation.d.ts → parse/expression/BindComputationExpression.d.ts} +5 -6
- package/dist/{body/control/select → parse/expression}/ItemsetNodesetExpression.d.ts +2 -3
- package/dist/{body/control/select → parse/expression}/ItemsetValueExpression.d.ts +2 -3
- package/dist/parse/expression/RepeatCountControlExpression.d.ts +2 -3
- package/dist/parse/expression/TextLiteralExpression.d.ts +9 -0
- package/dist/parse/expression/TextOutputExpression.d.ts +7 -0
- package/dist/parse/expression/TextReferenceExpression.d.ts +7 -0
- package/dist/parse/expression/TextTranslationExpression.d.ts +8 -0
- package/dist/parse/expression/abstract/DependencyContext.d.ts +7 -0
- package/dist/{expression → parse/expression/abstract}/DependentExpression.d.ts +4 -6
- package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
- package/dist/parse/model/BindDefinition.d.ts +38 -0
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -2
- 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/{model → parse/model}/LeafNodeDefinition.d.ts +4 -3
- package/dist/{model → parse/model}/ModelBindMap.d.ts +1 -2
- package/dist/{model → parse/model}/ModelDefinition.d.ts +3 -2
- package/dist/{model → parse/model}/NodeDefinition.d.ts +0 -2
- package/dist/parse/{NoteNodeDefinition.d.ts → model/NoteNodeDefinition.d.ts} +12 -13
- package/dist/{model → parse/model}/RepeatInstanceDefinition.d.ts +1 -2
- package/dist/{model → parse/model}/RepeatRangeDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/RepeatTemplateDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/RootDefinition.d.ts +5 -5
- 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/{model → parse/model}/SubtreeDefinition.d.ts +1 -2
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
- package/dist/parse/text/HintDefinition.d.ts +2 -3
- package/dist/parse/text/ItemLabelDefinition.d.ts +2 -3
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +3 -4
- package/dist/parse/text/LabelDefinition.d.ts +5 -6
- package/dist/parse/text/MessageDefinition.d.ts +4 -5
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +8 -9
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +4 -7
- package/dist/parse/xpath/path-resolution.d.ts +0 -1
- package/dist/parse/xpath/predicate-analysis.d.ts +0 -1
- package/dist/parse/xpath/reference-parsing.d.ts +0 -1
- package/dist/parse/xpath/semantic-analysis.d.ts +5 -1
- package/dist/parse/xpath/syntax-traversal.d.ts +0 -1
- package/dist/solid.js +8398 -4543
- package/dist/solid.js.map +1 -1
- package/package.json +14 -12
- package/src/client/BaseNode.ts +17 -7
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/GroupNode.ts +2 -2
- package/src/client/InputNode.ts +77 -0
- package/src/client/ModelValueNode.ts +31 -8
- package/src/client/NodeAppearances.ts +1 -1
- package/src/client/NoteNode.ts +3 -3
- package/src/client/RootNode.ts +39 -9
- package/src/client/SelectNode.ts +5 -5
- package/src/client/SubtreeNode.ts +1 -1
- package/src/client/TextRange.ts +4 -5
- package/src/client/TriggerNode.ts +29 -0
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +16 -4
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +19 -5
- package/src/client/repeat/BaseRepeatRangeNode.ts +1 -1
- package/src/client/repeat/RepeatInstanceNode.ts +2 -2
- package/src/client/repeat/RepeatRangeControlledNode.ts +1 -1
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +1 -1
- 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/unsupported/RangeNode.ts +14 -0
- package/src/client/unsupported/RankNode.ts +14 -0
- package/src/client/unsupported/UnsupportedControlNode.ts +40 -0
- package/src/client/unsupported/UploadNode.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 +16 -2
- 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 +26 -10
- package/src/instance/PrimaryInstance.ts +244 -0
- package/src/instance/Root.ts +64 -132
- package/src/instance/SelectField.ts +62 -25
- package/src/instance/Subtree.ts +19 -7
- package/src/instance/{StringField.ts → TriggerControl.ts} +61 -30
- package/src/instance/abstract/DescendantNode.ts +92 -47
- package/src/instance/abstract/InstanceNode.ts +104 -98
- package/src/instance/abstract/UnsupportedControl.ts +174 -0
- package/src/instance/abstract/ValueNode.ts +127 -0
- package/src/instance/children.ts +83 -14
- package/src/instance/hierarchy.ts +36 -14
- package/src/instance/identity.ts +3 -9
- package/src/instance/index.ts +26 -8
- package/src/instance/internal-api/EvaluationContext.ts +61 -14
- 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 +13 -5
- package/src/instance/internal-api/ValueContext.ts +5 -4
- 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 +51 -132
- package/src/instance/repeat/RepeatInstance.ts +20 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +6 -6
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +3 -5
- package/src/instance/resource.ts +1 -1
- package/src/instance/text/TextChunk.ts +1 -1
- package/src/instance/unsupported/RangeControl.ts +9 -0
- package/src/instance/unsupported/RankControl.ts +9 -0
- package/src/instance/unsupported/UploadControl.ts +9 -0
- 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/TokenListParser.ts +11 -7
- 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 +8 -1
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +59 -36
- package/src/lib/reactivity/createInstanceValueState.ts +166 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- package/src/lib/reactivity/createSelectItems.ts +23 -23
- package/src/lib/reactivity/createTranslationState.ts +61 -0
- package/src/lib/reactivity/createValueState.ts +64 -122
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
- package/src/lib/reactivity/node-state/createSpecifiedState.ts +1 -1
- package/src/lib/reactivity/text/createFieldHint.ts +1 -1
- package/src/lib/reactivity/text/createNodeLabel.ts +1 -1
- package/src/lib/reactivity/text/createNoteText.ts +1 -1
- package/src/lib/reactivity/text/createTextRange.ts +8 -7
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +9 -4
- package/src/lib/reactivity/validation/createValidation.ts +2 -3
- package/src/lib/xml-serialization.ts +96 -0
- package/src/{XFormDOM.ts → parse/XFormDOM.ts} +110 -75
- package/src/{XFormDefinition.ts → parse/XFormDefinition.ts} +3 -8
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/{body → parse/body}/BodyDefinition.ts +46 -29
- package/src/{body → parse/body}/BodyElementDefinition.ts +12 -6
- package/src/{body → parse/body}/RepeatElementDefinition.ts +7 -5
- package/src/{body → parse/body}/appearance/inputAppearanceParser.ts +2 -2
- package/src/{body → parse/body}/appearance/selectAppearanceParser.ts +1 -1
- package/src/{body → parse/body}/appearance/structureElementAppearanceParser.ts +1 -1
- package/src/parse/body/appearance/unknownAppearanceParser.ts +5 -0
- package/src/{body → parse/body}/control/ControlDefinition.ts +4 -4
- package/src/{body/control/InputDefinition.ts → parse/body/control/InputControlDefinition.ts} +3 -5
- package/src/parse/body/control/RangeControlDefinition.ts +26 -0
- package/src/parse/body/control/RankControlDefinition.ts +27 -0
- package/src/parse/body/control/TriggerControlDefinition.ts +26 -0
- package/src/parse/body/control/UploadControlDefinition.ts +26 -0
- package/src/{body → parse/body}/control/select/ItemDefinition.ts +2 -2
- package/src/{body → parse/body}/control/select/ItemsetDefinition.ts +5 -5
- package/src/{body → parse/body}/control/select/ItemsetNodesetContext.ts +1 -6
- package/src/{body → parse/body}/control/select/SelectDefinition.ts +3 -11
- package/src/{body → parse/body}/group/BaseGroupDefinition.ts +11 -22
- package/src/{body → parse/body}/group/PresentationGroupDefinition.ts +1 -1
- package/src/{model/BindComputation.ts → parse/expression/BindComputationExpression.ts} +8 -8
- package/src/{body/control/select → parse/expression}/ItemsetNodesetExpression.ts +2 -2
- package/src/{body/control/select → parse/expression}/ItemsetValueExpression.ts +2 -2
- package/src/parse/expression/RepeatCountControlExpression.ts +2 -2
- package/src/parse/expression/TextLiteralExpression.ts +19 -0
- package/src/parse/{text/OutputChunkDefinition.ts → expression/TextOutputExpression.ts} +4 -4
- package/src/parse/{text/ReferenceChunkDefinition.ts → expression/TextReferenceExpression.ts} +4 -4
- package/src/parse/{text/TranslationChunkDefinition.ts → expression/TextTranslationExpression.ts} +4 -4
- package/src/{expression → parse/expression/abstract}/DependencyContext.ts +0 -26
- package/src/{expression → parse/expression/abstract}/DependentExpression.ts +5 -16
- package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
- package/src/parse/model/BindDefinition.ts +104 -0
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/{model → 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/{model → parse/model}/LeafNodeDefinition.ts +4 -1
- package/src/{model → parse/model}/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +24 -0
- package/src/{model → parse/model}/NodeDefinition.ts +0 -3
- package/src/parse/{NoteNodeDefinition.ts → model/NoteNodeDefinition.ts} +12 -12
- package/src/{model → parse/model}/RepeatRangeDefinition.ts +1 -1
- package/src/{model → parse/model}/RootDefinition.ts +4 -3
- 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/HintDefinition.ts +2 -2
- package/src/parse/text/ItemLabelDefinition.ts +2 -2
- package/src/parse/text/ItemsetLabelDefinition.ts +7 -7
- package/src/parse/text/LabelDefinition.ts +5 -5
- package/src/parse/text/MessageDefinition.ts +7 -7
- package/src/parse/text/abstract/TextElementDefinition.ts +14 -14
- package/src/parse/text/abstract/TextRangeDefinition.ts +4 -10
- package/src/parse/xpath/semantic-analysis.ts +29 -0
- package/dist/XFormDOM.d.ts +0 -32
- package/dist/XFormDataType.d.ts +0 -27
- package/dist/body/appearance/inputAppearanceParser.d.ts +0 -4
- package/dist/client/StringNode.d.ts +0 -47
- package/dist/expression/DependencyContext.d.ts +0 -13
- package/dist/instance/StringField.d.ts +0 -45
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -60
- package/dist/model/BindDefinition.d.ts +0 -34
- package/dist/parse/text/OutputChunkDefinition.d.ts +0 -8
- package/dist/parse/text/ReferenceChunkDefinition.d.ts +0 -8
- package/dist/parse/text/StaticTextChunkDefinition.d.ts +0 -10
- package/dist/parse/text/TranslationChunkDefinition.d.ts +0 -9
- package/dist/parse/text/abstract/TextChunkDefinition.d.ts +0 -18
- package/src/XFormDataType.ts +0 -64
- package/src/client/StringNode.ts +0 -52
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/model/BindDefinition.ts +0 -106
- package/src/model/ModelDefinition.ts +0 -19
- package/src/parse/TODO.md +0 -3
- package/src/parse/text/StaticTextChunkDefinition.ts +0 -19
- package/src/parse/text/abstract/TextChunkDefinition.ts +0 -38
- /package/dist/{model → parse/model}/BindElement.d.ts +0 -0
- /package/src/{body → parse/body}/UnsupportedBodyElementDefinition.ts +0 -0
- /package/src/{body → parse/body}/group/LogicalGroupDefinition.ts +0 -0
- /package/src/{body → parse/body}/group/StructuralGroupDefinition.ts +0 -0
- /package/src/{model → parse/model}/BindElement.ts +0 -0
- /package/src/{model → parse/model}/RepeatInstanceDefinition.ts +0 -0
- /package/src/{model → parse/model}/RepeatTemplateDefinition.ts +0 -0
- /package/src/{model → parse/model}/SubtreeDefinition.ts +0 -0
package/src/instance/children.ts
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
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
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
6
|
+
import type { TriggerNodeDefinition } from '../client/TriggerNode.ts';
|
|
7
|
+
import type { RangeNodeDefinition } from '../client/unsupported/RangeNode.ts';
|
|
8
|
+
import type { RankNodeDefinition } from '../client/unsupported/RankNode.ts';
|
|
9
|
+
import type { UnsupportedControlDefinition } from '../client/unsupported/UnsupportedControlNode.ts';
|
|
10
|
+
import type { UploadNodeDefinition } from '../client/unsupported/UploadNode.ts';
|
|
11
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
12
|
+
import { NoteNodeDefinition } from '../parse/model/NoteNodeDefinition.ts';
|
|
13
|
+
import type { SubtreeDefinition as ModelSubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
|
|
7
14
|
import { Group } from './Group.ts';
|
|
8
15
|
import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
9
|
-
import {
|
|
16
|
+
import { InputControl } from './InputControl.ts';
|
|
17
|
+
import { ModelValue } from './ModelValue.ts';
|
|
10
18
|
import { Note } from './Note.ts';
|
|
11
19
|
import { RepeatRangeControlled } from './repeat/RepeatRangeControlled.ts';
|
|
12
20
|
import { RepeatRangeUncontrolled } from './repeat/RepeatRangeUncontrolled.ts';
|
|
13
21
|
import type { SelectFieldDefinition } from './SelectField.ts';
|
|
14
22
|
import { SelectField } from './SelectField.ts';
|
|
15
|
-
import type { StringFieldDefinition } from './StringField.ts';
|
|
16
|
-
import { StringField } from './StringField.ts';
|
|
17
23
|
import { Subtree } from './Subtree.ts';
|
|
24
|
+
import { TriggerControl } from './TriggerControl.ts';
|
|
25
|
+
import { RangeControl } from './unsupported/RangeControl.ts';
|
|
26
|
+
import { RankControl } from './unsupported/RankControl.ts';
|
|
27
|
+
import { UploadControl } from './unsupported/UploadControl.ts';
|
|
18
28
|
|
|
19
29
|
const isSubtreeDefinition = (
|
|
20
30
|
definition: ModelSubtreeDefinition
|
|
@@ -22,7 +32,18 @@ const isSubtreeDefinition = (
|
|
|
22
32
|
return definition.bodyElement == null;
|
|
23
33
|
};
|
|
24
34
|
|
|
25
|
-
type
|
|
35
|
+
type AnyUnsupportedControlDefinition =
|
|
36
|
+
| RangeNodeDefinition
|
|
37
|
+
| RankNodeDefinition
|
|
38
|
+
| UploadNodeDefinition;
|
|
39
|
+
|
|
40
|
+
// prettier-ignore
|
|
41
|
+
type ControlNodeDefinition =
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
43
|
+
| InputDefinition
|
|
44
|
+
| SelectFieldDefinition
|
|
45
|
+
| TriggerNodeDefinition
|
|
46
|
+
| AnyUnsupportedControlDefinition;
|
|
26
47
|
|
|
27
48
|
type AnyLeafNodeDefinition = ControlNodeDefinition | ModelValueDefinition;
|
|
28
49
|
|
|
@@ -32,12 +53,40 @@ const isModelValueDefinition = (
|
|
|
32
53
|
return definition.bodyElement == null;
|
|
33
54
|
};
|
|
34
55
|
|
|
35
|
-
const
|
|
36
|
-
definition: ControlNodeDefinition
|
|
37
|
-
): definition is StringFieldDefinition => {
|
|
56
|
+
const isInputDefinition = (definition: ControlNodeDefinition): definition is InputDefinition => {
|
|
38
57
|
return definition.bodyElement.type === 'input';
|
|
39
58
|
};
|
|
40
59
|
|
|
60
|
+
const isSelectFieldDefinition = (
|
|
61
|
+
definition: ControlNodeDefinition
|
|
62
|
+
): definition is SelectFieldDefinition => {
|
|
63
|
+
return definition.bodyElement.type === 'select' || definition.bodyElement.type === 'select1';
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const isRangeNodeDefinition = (
|
|
67
|
+
definition: UnsupportedControlDefinition
|
|
68
|
+
): definition is RangeNodeDefinition => {
|
|
69
|
+
return definition.bodyElement.type === 'range';
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const isRankNodeDefinition = (
|
|
73
|
+
definition: UnsupportedControlDefinition
|
|
74
|
+
): definition is RankNodeDefinition => {
|
|
75
|
+
return definition.bodyElement.type === 'rank';
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const isTriggerNodeDefinition = (
|
|
79
|
+
definition: ControlNodeDefinition
|
|
80
|
+
): definition is TriggerNodeDefinition => {
|
|
81
|
+
return definition.bodyElement.type === 'trigger';
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const isUploadNodeDefinition = (
|
|
85
|
+
definition: ControlNodeDefinition
|
|
86
|
+
): definition is UploadNodeDefinition => {
|
|
87
|
+
return definition.bodyElement.type === 'upload';
|
|
88
|
+
};
|
|
89
|
+
|
|
41
90
|
export const buildChildren = (parent: GeneralParentNode): GeneralChildNode[] => {
|
|
42
91
|
const { children } = parent.definition;
|
|
43
92
|
|
|
@@ -71,14 +120,34 @@ export const buildChildren = (parent: GeneralParentNode): GeneralChildNode[] =>
|
|
|
71
120
|
const leafChild: AnyLeafNodeDefinition = child;
|
|
72
121
|
|
|
73
122
|
if (isModelValueDefinition(leafChild)) {
|
|
74
|
-
return
|
|
123
|
+
return ModelValue.from(parent, leafChild);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (isInputDefinition(leafChild)) {
|
|
127
|
+
return InputControl.from(parent, leafChild);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (isSelectFieldDefinition(leafChild)) {
|
|
131
|
+
return new SelectField(parent, leafChild);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (isTriggerNodeDefinition(leafChild)) {
|
|
135
|
+
return new TriggerControl(parent, leafChild);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (isRangeNodeDefinition(leafChild)) {
|
|
139
|
+
return new RangeControl(parent, leafChild);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (isRankNodeDefinition(leafChild)) {
|
|
143
|
+
return new RankControl(parent, leafChild);
|
|
75
144
|
}
|
|
76
145
|
|
|
77
|
-
if (
|
|
78
|
-
return new
|
|
146
|
+
if (isUploadNodeDefinition(leafChild)) {
|
|
147
|
+
return new UploadControl(parent, leafChild);
|
|
79
148
|
}
|
|
80
149
|
|
|
81
|
-
|
|
150
|
+
throw new UnreachableError(leafChild);
|
|
82
151
|
}
|
|
83
152
|
|
|
84
153
|
default: {
|
|
@@ -1,32 +1,47 @@
|
|
|
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';
|
|
12
|
+
import type { TriggerControl } from './TriggerControl.ts';
|
|
13
|
+
import type { RangeControl } from './unsupported/RangeControl.ts';
|
|
14
|
+
import type { RankControl } from './unsupported/RankControl.ts';
|
|
15
|
+
import type { UploadControl } from './unsupported/UploadControl.ts';
|
|
11
16
|
|
|
12
17
|
export type RepeatRange = RepeatRangeControlled | RepeatRangeUncontrolled;
|
|
13
18
|
|
|
19
|
+
// prettier-ignore
|
|
20
|
+
export type AnyUnsupportedControl =
|
|
21
|
+
| RangeControl
|
|
22
|
+
| RankControl
|
|
23
|
+
| UploadControl;
|
|
24
|
+
|
|
14
25
|
// prettier-ignore
|
|
15
26
|
export type AnyNode =
|
|
16
27
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
28
|
+
| PrimaryInstance
|
|
17
29
|
| Root
|
|
18
30
|
| Group
|
|
19
31
|
| Subtree
|
|
20
32
|
| RepeatRange
|
|
21
33
|
| RepeatInstance
|
|
22
34
|
| Note
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
| SelectField
|
|
35
|
+
| AnyModelValue
|
|
36
|
+
| AnyInputControl
|
|
37
|
+
| SelectField
|
|
38
|
+
| TriggerControl
|
|
39
|
+
| AnyUnsupportedControl;
|
|
26
40
|
|
|
27
41
|
// prettier-ignore
|
|
28
42
|
export type AnyParentNode =
|
|
29
43
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
44
|
+
| PrimaryInstance
|
|
30
45
|
| Root
|
|
31
46
|
| Group
|
|
32
47
|
| Subtree
|
|
@@ -44,14 +59,17 @@ export type GeneralParentNode =
|
|
|
44
59
|
// prettier-ignore
|
|
45
60
|
export type AnyChildNode =
|
|
46
61
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
62
|
+
| Root
|
|
47
63
|
| Group
|
|
48
64
|
| Subtree
|
|
49
65
|
| RepeatRange
|
|
50
66
|
| RepeatInstance
|
|
51
|
-
|
|
|
67
|
+
| AnyModelValue
|
|
52
68
|
| Note
|
|
53
|
-
|
|
|
54
|
-
| SelectField
|
|
69
|
+
| AnyInputControl
|
|
70
|
+
| SelectField
|
|
71
|
+
| TriggerControl
|
|
72
|
+
| AnyUnsupportedControl;
|
|
55
73
|
|
|
56
74
|
// prettier-ignore
|
|
57
75
|
export type GeneralChildNode =
|
|
@@ -59,15 +77,19 @@ export type GeneralChildNode =
|
|
|
59
77
|
| Group
|
|
60
78
|
| Subtree
|
|
61
79
|
| RepeatRange
|
|
62
|
-
|
|
|
80
|
+
| AnyModelValue
|
|
63
81
|
| Note
|
|
64
|
-
|
|
|
65
|
-
| SelectField
|
|
82
|
+
| AnyInputControl
|
|
83
|
+
| SelectField
|
|
84
|
+
| TriggerControl
|
|
85
|
+
| AnyUnsupportedControl;
|
|
66
86
|
|
|
67
87
|
// prettier-ignore
|
|
68
88
|
export type AnyValueNode =
|
|
69
89
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
70
|
-
|
|
|
90
|
+
| AnyModelValue
|
|
71
91
|
| Note
|
|
72
|
-
|
|
|
73
|
-
| SelectField
|
|
92
|
+
| AnyInputControl
|
|
93
|
+
| SelectField
|
|
94
|
+
| TriggerControl
|
|
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 {
|
|
2
|
+
import { getOwner } from 'solid-js';
|
|
3
|
+
import type { EngineConfig } from '../client/EngineConfig.ts';
|
|
3
4
|
import type { RootNode } from '../client/RootNode.ts';
|
|
5
|
+
import { MISSING_RESOURCE_BEHAVIOR } from '../client/constants.ts';
|
|
4
6
|
import type {
|
|
5
7
|
InitializeFormOptions as BaseInitializeFormOptions,
|
|
6
8
|
FormResource,
|
|
7
9
|
InitializeForm,
|
|
8
10
|
} from '../client/index.ts';
|
|
9
11
|
import { retrieveSourceXMLResource } from '../instance/resource.ts';
|
|
12
|
+
import { createReactiveScope } from '../lib/reactivity/scope.ts';
|
|
10
13
|
import { createUniqueId } from '../lib/unique-id.ts';
|
|
11
|
-
import {
|
|
14
|
+
import { XFormDOM } from '../parse/XFormDOM.ts';
|
|
15
|
+
import { XFormDefinition } from '../parse/XFormDefinition.ts';
|
|
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';
|
|
3
|
-
import type {
|
|
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';
|
|
4
8
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
5
|
-
import type {
|
|
9
|
+
import type { DependentExpression } from '../../parse/expression/abstract/DependentExpression.ts';
|
|
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,12 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormNodeID } from '../../client/identity.ts';
|
|
2
|
+
import type { AnyViolation } from '../../client/validation.ts';
|
|
3
|
+
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
2
4
|
import type { MessageDefinition } from '../../parse/text/MessageDefinition.ts';
|
|
3
5
|
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
interface ValidationContextCurrentState {
|
|
8
|
+
get reference(): string;
|
|
9
|
+
}
|
|
5
10
|
|
|
6
11
|
interface ValidationContextDefinitionBind {
|
|
7
|
-
readonly constraint:
|
|
12
|
+
readonly constraint: BindComputationExpression<'constraint'>;
|
|
8
13
|
readonly constraintMsg: MessageDefinition<'constraintMsg'> | null;
|
|
9
|
-
readonly required:
|
|
14
|
+
readonly required: BindComputationExpression<'required'>;
|
|
10
15
|
readonly requiredMsg: MessageDefinition<'requiredMsg'> | null;
|
|
11
16
|
}
|
|
12
17
|
|
|
@@ -14,9 +19,12 @@ interface ValidationContextDefinition {
|
|
|
14
19
|
readonly bind: ValidationContextDefinitionBind;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
|
-
export interface ValidationContext extends EvaluationContext
|
|
22
|
+
export interface ValidationContext extends EvaluationContext {
|
|
23
|
+
readonly nodeId: FormNodeID;
|
|
18
24
|
readonly definition: ValidationContextDefinition;
|
|
25
|
+
readonly currentState: ValidationContextCurrentState;
|
|
19
26
|
|
|
27
|
+
getViolation(): AnyViolation | null;
|
|
20
28
|
isRelevant(): boolean;
|
|
21
29
|
isRequired(): boolean;
|
|
22
30
|
isBlank(): boolean;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import type { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
1
2
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
|
-
import type {
|
|
3
|
+
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
3
4
|
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
4
5
|
|
|
5
6
|
export type InstanceValue = string;
|
|
6
7
|
|
|
7
8
|
interface ValueContextDefinitionBind {
|
|
8
|
-
readonly calculate:
|
|
9
|
-
readonly readonly:
|
|
9
|
+
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
10
|
+
readonly readonly: BindComputationExpression<'readonly'>;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export interface ValueContextDefinition {
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import type { EscapedXMLText } from '../../../lib/xml-serialization.ts';
|
|
3
|
+
import type {
|
|
4
|
+
ClientReactiveSubmittableChildNode,
|
|
5
|
+
ClientReactiveSubmittableParentNode,
|
|
6
|
+
} from './ClientReactiveSubmittableParentNode.ts';
|
|
7
|
+
|
|
8
|
+
interface ClientReactiveSubmittableLeafNodeCurrentState<RuntimeValue> {
|
|
9
|
+
get relevant(): boolean;
|
|
10
|
+
get value(): RuntimeValue;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type SerializedSubmissionValue = string;
|
|
14
|
+
|
|
15
|
+
interface ClientReactiveSubmittableLeafNodeDefinition {
|
|
16
|
+
readonly nodeName: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ClientReactiveSubmittableLeafNode<RuntimeValue> {
|
|
20
|
+
readonly definition: ClientReactiveSubmittableLeafNodeDefinition;
|
|
21
|
+
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode>;
|
|
22
|
+
readonly currentState: ClientReactiveSubmittableLeafNodeCurrentState<RuntimeValue>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A client-reactive submittable leaf node is responsible for producing a
|
|
26
|
+
* string representation of its value state, suitable for serialization for
|
|
27
|
+
* submission. It **MUST NOT** perform any further submission-specific
|
|
28
|
+
* serialization duties: in particular, the value **MUST NOT** be escaped for
|
|
29
|
+
* XML. This responsibility is delegated up the stack, to avoid repeat
|
|
30
|
+
* escaping.
|
|
31
|
+
*
|
|
32
|
+
* Note: excluding {@link EscapedXMLText} here does not have an effect on the
|
|
33
|
+
* type system, it is a documentation-only hint, to help guard against future
|
|
34
|
+
* double-escaping mistakes.
|
|
35
|
+
*/
|
|
36
|
+
readonly encodeValue: (
|
|
37
|
+
this: unknown,
|
|
38
|
+
runtimeValue: RuntimeValue
|
|
39
|
+
) => Exclude<string, EscapedXMLText>;
|
|
40
|
+
|
|
41
|
+
readonly submissionState: SubmissionState;
|
|
42
|
+
}
|