@getodk/xforms-engine 0.4.0 → 0.6.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/README.md +1 -1
- package/dist/client/BaseNode.d.ts +18 -3
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -48
- package/dist/client/GroupNode.d.ts +1 -0
- package/dist/client/InputNode.d.ts +82 -0
- package/dist/client/ModelValueNode.d.ts +13 -7
- package/dist/client/NoteNode.d.ts +26 -9
- package/dist/client/RangeNode.d.ts +36 -0
- package/dist/client/RankNode.d.ts +46 -0
- package/dist/client/RootNode.d.ts +37 -7
- package/dist/client/SelectNode.d.ts +47 -25
- package/dist/client/SubtreeNode.d.ts +1 -0
- package/dist/client/TriggerNode.d.ts +10 -6
- package/dist/client/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -0
- package/dist/client/hierarchy.d.ts +8 -8
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/node-types.d.ts +3 -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/UnsupportedControlNode.d.ts +1 -3
- package/dist/client/validation.d.ts +2 -2
- package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
- package/dist/error/RankMissingValueError.d.ts +3 -0
- package/dist/error/RankValueTypeError.d.ts +6 -0
- package/dist/error/SelectValueTypeError.d.ts +15 -0
- package/dist/error/ValueTypeInvariantError.d.ts +17 -0
- package/dist/error/XFormsSpecViolationError.d.ts +2 -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 +12 -4
- package/dist/index.js +17864 -14655
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +10 -4
- package/dist/instance/InputControl.d.ts +38 -0
- package/dist/instance/ModelValue.d.ts +17 -25
- package/dist/instance/Note.d.ts +16 -21
- package/dist/instance/PrimaryInstance.d.ts +85 -0
- package/dist/instance/RangeControl.d.ts +34 -0
- package/dist/instance/RankControl.d.ts +40 -0
- package/dist/instance/Root.d.ts +30 -25
- package/dist/instance/SelectControl.d.ts +66 -0
- package/dist/instance/Subtree.d.ts +11 -5
- package/dist/instance/TriggerControl.d.ts +13 -19
- package/dist/instance/abstract/DescendantNode.d.ts +32 -25
- package/dist/instance/abstract/InstanceNode.d.ts +52 -30
- package/dist/instance/abstract/UnsupportedControl.d.ts +11 -3
- package/dist/instance/abstract/ValueNode.d.ts +47 -0
- package/dist/instance/hierarchy.d.ts +13 -12
- 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 +22 -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 +32 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +19 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +18 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +40 -83
- package/dist/instance/repeat/RepeatInstance.d.ts +12 -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/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 +6 -0
- package/dist/integration/xpath/adapter/traversal.d.ts +26 -0
- package/dist/integration/xpath/adapter/values.d.ts +2 -0
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +26 -0
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +15 -0
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +48 -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/createRootSubmissionState.d.ts +3 -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/Geopoint/Geopoint.d.ts +48 -0
- package/dist/lib/codecs/Geopoint/GeopointValueCodec.d.ts +5 -0
- package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
- package/dist/lib/codecs/NoteCodec.d.ts +8 -0
- package/dist/lib/codecs/RangeCodec.d.ts +8 -0
- package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
- package/dist/lib/codecs/TriggerCodec.d.ts +7 -0
- package/dist/lib/codecs/ValueArrayCodec.d.ts +11 -0
- package/dist/lib/codecs/ValueCodec.d.ts +30 -0
- package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
- package/dist/lib/codecs/getNoteCodec.d.ts +3 -0
- package/dist/lib/codecs/getSelectCodec.d.ts +5 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +48 -0
- package/dist/lib/codecs/items/BaseItemCodec.d.ts +9 -0
- package/dist/lib/codecs/items/MultipleValueItemCodec.d.ts +14 -0
- package/dist/lib/codecs/items/SingleValueItemCodec.d.ts +24 -0
- package/dist/lib/dom/query.d.ts +4 -2
- package/dist/lib/names/NamespaceDeclaration.d.ts +45 -0
- package/dist/lib/names/NamespaceDeclarationMap.d.ts +137 -0
- package/dist/lib/names/NamespaceURL.d.ts +30 -0
- package/dist/lib/names/QualifiedName.d.ts +113 -0
- package/dist/lib/number-parsers.d.ts +2 -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/createItemCollection.d.ts +21 -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 +50 -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 +4 -4
- package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
- package/dist/parse/body/appearance/rangeAppearanceParser.d.ts +3 -0
- package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +4 -1
- package/dist/parse/body/control/ItemDefinition.d.ts +14 -0
- package/dist/parse/body/control/ItemsetDefinition.d.ts +18 -0
- package/dist/parse/body/control/RangeControlDefinition.d.ts +31 -2
- package/dist/parse/body/control/RankControlDefinition.d.ts +7 -3
- package/dist/parse/body/control/{select/SelectDefinition.d.ts → SelectControlDefinition.d.ts} +9 -9
- package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -1
- package/dist/parse/expression/ItemsetValueExpression.d.ts +1 -1
- 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 +6 -5
- package/dist/parse/model/BindPreloadDefinition.d.ts +42 -0
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +4 -14
- 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 +9 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +9 -4
- 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 +16 -20
- package/dist/parse/model/NoteNodeDefinition.d.ts +9 -8
- package/dist/parse/model/RangeNodeDefinition.d.ts +41 -0
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatRangeDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +7 -4
- package/dist/parse/model/RootAttributeDefinition.d.ts +24 -0
- package/dist/parse/model/RootAttributeMap.d.ts +23 -0
- package/dist/parse/model/RootDefinition.d.ts +12 -9
- 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/model/SubtreeDefinition.d.ts +7 -4
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +23 -0
- package/dist/parse/text/ItemLabelDefinition.d.ts +1 -1
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +2 -2
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +1 -1
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
- package/dist/parse/xpath/semantic-analysis.d.ts +6 -3
- package/dist/solid.js +15437 -12246
- package/dist/solid.js.map +1 -1
- package/package.json +18 -13
- package/src/client/BaseNode.ts +21 -6
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/GroupNode.ts +1 -0
- package/src/client/InputNode.ts +113 -0
- package/src/client/ModelValueNode.ts +31 -7
- package/src/client/NoteNode.ts +45 -9
- package/src/client/RangeNode.ts +51 -0
- package/src/client/RankNode.ts +54 -0
- package/src/client/RootNode.ts +43 -7
- package/src/client/SelectNode.ts +53 -26
- package/src/client/SubtreeNode.ts +1 -0
- package/src/client/TriggerNode.ts +12 -6
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +12 -13
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +13 -7
- 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/UnsupportedControlNode.ts +2 -6
- package/src/client/validation.ts +2 -2
- package/src/error/ErrorProductionDesignPendingError.ts +6 -0
- package/src/error/RankMissingValueError.ts +5 -0
- package/src/error/RankValueTypeError.ts +13 -0
- package/src/error/SelectValueTypeError.ts +22 -0
- package/src/error/ValueTypeInvariantError.ts +22 -0
- package/src/error/XFormsSpecViolationError.ts +1 -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 +12 -13
- package/src/instance/Group.ts +18 -5
- package/src/instance/InputControl.ts +159 -0
- package/src/instance/ModelValue.ts +48 -53
- package/src/instance/Note.ts +40 -49
- package/src/instance/PrimaryInstance.ts +245 -0
- package/src/instance/RangeControl.ts +113 -0
- package/src/instance/RankControl.ts +199 -0
- package/src/instance/Root.ts +63 -134
- package/src/instance/SelectControl.ts +219 -0
- package/src/instance/Subtree.ts +20 -7
- package/src/instance/TriggerControl.ts +44 -66
- package/src/instance/abstract/DescendantNode.ts +91 -51
- package/src/instance/abstract/InstanceNode.ts +113 -107
- package/src/instance/abstract/UnsupportedControl.ts +29 -5
- package/src/instance/abstract/ValueNode.ts +128 -0
- package/src/instance/children.ts +80 -40
- package/src/instance/hierarchy.ts +39 -30
- 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 +26 -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 +43 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +26 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +24 -0
- package/src/instance/repeat/BaseRepeatRange.ts +52 -131
- package/src/instance/repeat/RepeatInstance.ts +21 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
- package/src/instance/resource.ts +5 -2
- package/src/instance/text/TextChunk.ts +1 -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 +148 -0
- package/src/integration/xpath/adapter/traversal.ts +229 -0
- package/src/integration/xpath/adapter/values.ts +5 -0
- package/src/integration/xpath/static-dom/StaticAttribute.ts +41 -0
- package/src/integration/xpath/static-dom/StaticDocument.ts +36 -0
- package/src/integration/xpath/static-dom/StaticElement.ts +119 -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/createRootSubmissionState.ts +19 -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/Geopoint/Geopoint.ts +150 -0
- package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +20 -0
- package/src/lib/codecs/IntValueCodec.ts +100 -0
- package/src/lib/codecs/NoteCodec.ts +32 -0
- package/src/lib/codecs/RangeCodec.ts +65 -0
- package/src/lib/codecs/StringValueCodec.ts +11 -0
- package/src/lib/codecs/TriggerCodec.ts +64 -0
- package/src/lib/codecs/ValueArrayCodec.ts +42 -0
- package/src/lib/codecs/ValueCodec.ts +106 -0
- package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
- package/src/lib/codecs/getNoteCodec.ts +27 -0
- package/src/lib/codecs/getSelectCodec.ts +27 -0
- package/src/lib/codecs/getSharedValueCodec.ts +79 -0
- package/src/lib/codecs/items/BaseItemCodec.ts +20 -0
- package/src/lib/codecs/items/MultipleValueItemCodec.ts +28 -0
- package/src/lib/codecs/items/SingleValueItemCodec.ts +67 -0
- package/src/lib/dom/query.ts +8 -2
- package/src/lib/names/NamespaceDeclaration.ts +106 -0
- package/src/lib/names/NamespaceDeclarationMap.ts +228 -0
- package/src/lib/names/NamespaceURL.ts +44 -0
- package/src/lib/names/QualifiedName.ts +170 -0
- package/src/lib/number-parsers.ts +25 -0
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +57 -34
- package/src/lib/reactivity/createInstanceValueState.ts +216 -0
- package/src/lib/reactivity/createItemCollection.ts +173 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- 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 +163 -0
- package/src/parse/XFormDOM.ts +231 -76
- package/src/parse/XFormDefinition.ts +2 -10
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/parse/body/BodyDefinition.ts +7 -7
- package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
- package/src/parse/body/appearance/rangeAppearanceParser.ts +11 -0
- package/src/parse/body/control/InputControlDefinition.ts +29 -0
- package/src/parse/body/control/{select/ItemDefinition.ts → ItemDefinition.ts} +8 -6
- package/src/parse/body/control/{select/ItemsetDefinition.ts → ItemsetDefinition.ts} +11 -9
- package/src/parse/body/control/RangeControlDefinition.ts +91 -6
- package/src/parse/body/control/RankControlDefinition.ts +25 -7
- package/src/parse/body/control/{select/SelectDefinition.ts → SelectControlDefinition.ts} +9 -9
- package/src/parse/expression/ItemsetNodesetExpression.ts +1 -1
- package/src/parse/expression/ItemsetValueExpression.ts +1 -1
- package/src/parse/expression/abstract/DependencyContext.ts +0 -26
- package/src/parse/expression/abstract/DependentExpression.ts +2 -13
- package/src/parse/model/BindDefinition.ts +9 -8
- package/src/parse/model/BindPreloadDefinition.ts +100 -0
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/parse/model/DescendentNodeDefinition.ts +7 -31
- package/src/parse/model/FormSubmissionDefinition.ts +44 -0
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +42 -0
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
- package/src/parse/model/LeafNodeDefinition.ts +15 -5
- package/src/parse/model/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +6 -1
- package/src/parse/model/NodeDefinition.ts +24 -48
- package/src/parse/model/NoteNodeDefinition.ts +11 -10
- package/src/parse/model/RangeNodeDefinition.ts +118 -0
- package/src/parse/model/RepeatInstanceDefinition.ts +11 -7
- package/src/parse/model/RepeatRangeDefinition.ts +11 -7
- package/src/parse/model/RepeatTemplateDefinition.ts +11 -7
- package/src/parse/model/RootAttributeDefinition.ts +45 -0
- package/src/parse/model/RootAttributeMap.ts +44 -0
- package/src/parse/model/RootDefinition.ts +31 -29
- 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 +415 -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/model/SubtreeDefinition.ts +12 -12
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
- package/src/parse/text/ItemLabelDefinition.ts +1 -1
- package/src/parse/text/ItemsetLabelDefinition.ts +2 -2
- package/src/parse/text/abstract/TextElementDefinition.ts +1 -1
- package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
- package/src/parse/xpath/semantic-analysis.ts +33 -3
- package/dist/client/StringNode.d.ts +0 -46
- package/dist/client/unsupported/RangeNode.d.ts +0 -9
- package/dist/client/unsupported/RankNode.d.ts +0 -9
- package/dist/instance/SelectField.d.ts +0 -50
- package/dist/instance/StringField.d.ts +0 -44
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
- package/dist/instance/unsupported/RangeControl.d.ts +0 -4
- package/dist/instance/unsupported/RankControl.d.ts +0 -4
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -16
- package/dist/parse/XFormDataType.d.ts +0 -25
- package/dist/parse/body/control/select/ItemDefinition.d.ts +0 -13
- package/dist/parse/body/control/select/ItemsetDefinition.d.ts +0 -17
- package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -11
- package/src/client/StringNode.ts +0 -52
- package/src/client/unsupported/RangeNode.ts +0 -14
- package/src/client/unsupported/RankNode.ts +0 -14
- package/src/instance/SelectField.ts +0 -226
- package/src/instance/StringField.ts +0 -120
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/instance/unsupported/RangeControl.ts +0 -5
- package/src/instance/unsupported/RankControl.ts +0 -5
- package/src/lib/reactivity/createSelectItems.ts +0 -168
- package/src/parse/XFormDataType.ts +0 -62
- package/src/parse/body/control/InputDefinition.ts +0 -22
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -26
package/src/instance/children.ts
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
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';
|
|
5
|
+
import type { SelectDefinition } from '../client/SelectNode.ts';
|
|
3
6
|
import type { SubtreeDefinition } from '../client/SubtreeNode.ts';
|
|
4
7
|
import type { TriggerNodeDefinition } from '../client/TriggerNode.ts';
|
|
5
|
-
import type {
|
|
6
|
-
import type { RankNodeDefinition } from '../client/unsupported/RankNode.ts';
|
|
7
|
-
import type { UnsupportedControlDefinition } from '../client/unsupported/UnsupportedControlNode.ts';
|
|
8
|
+
import type { RankDefinition } from '../client/RankNode.ts';
|
|
8
9
|
import type { UploadNodeDefinition } from '../client/unsupported/UploadNode.ts';
|
|
10
|
+
import { ErrorProductionDesignPendingError } from '../error/ErrorProductionDesignPendingError.ts';
|
|
9
11
|
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
10
12
|
import { NoteNodeDefinition } from '../parse/model/NoteNodeDefinition.ts';
|
|
13
|
+
import type {
|
|
14
|
+
AnyRangeNodeDefinition,
|
|
15
|
+
RangeLeafNodeDefinition,
|
|
16
|
+
} from '../parse/model/RangeNodeDefinition.ts';
|
|
17
|
+
import { RangeNodeDefinition } from '../parse/model/RangeNodeDefinition.ts';
|
|
11
18
|
import type { SubtreeDefinition as ModelSubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
|
|
12
19
|
import { Group } from './Group.ts';
|
|
13
20
|
import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
14
|
-
import {
|
|
21
|
+
import { InputControl } from './InputControl.ts';
|
|
22
|
+
import { ModelValue } from './ModelValue.ts';
|
|
15
23
|
import { Note } from './Note.ts';
|
|
24
|
+
import { RangeControl } from './RangeControl.ts';
|
|
16
25
|
import { RepeatRangeControlled } from './repeat/RepeatRangeControlled.ts';
|
|
17
26
|
import { RepeatRangeUncontrolled } from './repeat/RepeatRangeUncontrolled.ts';
|
|
18
|
-
import
|
|
19
|
-
import { SelectField } from './SelectField.ts';
|
|
20
|
-
import type { StringFieldDefinition } from './StringField.ts';
|
|
21
|
-
import { StringField } from './StringField.ts';
|
|
27
|
+
import { SelectControl } from './SelectControl.ts';
|
|
22
28
|
import { Subtree } from './Subtree.ts';
|
|
23
29
|
import { TriggerControl } from './TriggerControl.ts';
|
|
24
|
-
import {
|
|
25
|
-
import { RankControl } from './unsupported/RankControl.ts';
|
|
30
|
+
import { RankControl } from './RankControl.ts';
|
|
26
31
|
import { UploadControl } from './unsupported/UploadControl.ts';
|
|
27
32
|
|
|
28
33
|
const isSubtreeDefinition = (
|
|
@@ -31,16 +36,16 @@ const isSubtreeDefinition = (
|
|
|
31
36
|
return definition.bodyElement == null;
|
|
32
37
|
};
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
| RankNodeDefinition
|
|
37
|
-
| UploadNodeDefinition;
|
|
39
|
+
// prettier-ignore
|
|
40
|
+
type AnyUnsupportedControlDefinition = UploadNodeDefinition;
|
|
38
41
|
|
|
39
42
|
// prettier-ignore
|
|
40
43
|
type ControlNodeDefinition =
|
|
41
44
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
42
|
-
|
|
|
43
|
-
|
|
|
45
|
+
| InputDefinition
|
|
46
|
+
| RangeLeafNodeDefinition
|
|
47
|
+
| SelectDefinition
|
|
48
|
+
| RankDefinition
|
|
44
49
|
| TriggerNodeDefinition
|
|
45
50
|
| AnyUnsupportedControlDefinition;
|
|
46
51
|
|
|
@@ -52,28 +57,61 @@ const isModelValueDefinition = (
|
|
|
52
57
|
return definition.bodyElement == null;
|
|
53
58
|
};
|
|
54
59
|
|
|
55
|
-
const
|
|
56
|
-
definition: ControlNodeDefinition
|
|
57
|
-
): definition is StringFieldDefinition => {
|
|
60
|
+
const isInputDefinition = (definition: ControlNodeDefinition): definition is InputDefinition => {
|
|
58
61
|
return definition.bodyElement.type === 'input';
|
|
59
62
|
};
|
|
60
63
|
|
|
61
|
-
const
|
|
62
|
-
definition: ControlNodeDefinition
|
|
63
|
-
): definition is SelectFieldDefinition => {
|
|
64
|
+
const isSelectDefinition = (definition: ControlNodeDefinition): definition is SelectDefinition => {
|
|
64
65
|
return definition.bodyElement.type === 'select' || definition.bodyElement.type === 'select1';
|
|
65
66
|
};
|
|
66
67
|
|
|
67
|
-
const
|
|
68
|
-
definition
|
|
69
|
-
|
|
68
|
+
const isRankDefinition = (definition: ControlNodeDefinition): definition is RankDefinition => {
|
|
69
|
+
return definition.bodyElement.type === 'rank';
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const isRangeLeafNodeDefinition = (
|
|
73
|
+
definition: ControlNodeDefinition
|
|
74
|
+
): definition is RangeLeafNodeDefinition => {
|
|
70
75
|
return definition.bodyElement.type === 'range';
|
|
71
76
|
};
|
|
72
77
|
|
|
73
|
-
|
|
74
|
-
definition:
|
|
75
|
-
)
|
|
76
|
-
|
|
78
|
+
type AssertRangeNodeDefinition = (
|
|
79
|
+
definition: RangeLeafNodeDefinition
|
|
80
|
+
) => asserts definition is AnyRangeNodeDefinition;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* We need some way to narrow the base {@link RangeLeafNodeDefinition} type to
|
|
84
|
+
* {@link RankNodeDefinition} type.
|
|
85
|
+
*
|
|
86
|
+
* At time of writing, we know there is no code path to produce the broader
|
|
87
|
+
* type, but appeasing the type checker for it will help guard against
|
|
88
|
+
* introducing one. (And it would have caught exactly such a mistake in this
|
|
89
|
+
* phase of development, where a more optimistic type cast did not.)
|
|
90
|
+
*
|
|
91
|
+
* An `instanceof` check is appropriate because the narrower type refines all of
|
|
92
|
+
* the following:
|
|
93
|
+
*
|
|
94
|
+
* - `valueType` is a subset of the full range of
|
|
95
|
+
* {@link ValueType | specified value types} (only `int` or `decimal` are
|
|
96
|
+
* supported for range controls)
|
|
97
|
+
*
|
|
98
|
+
* - addition of range-specific properties: `min`, `max`, `step`
|
|
99
|
+
*/
|
|
100
|
+
const assertRangeNodeDefinition: AssertRangeNodeDefinition = (definition) => {
|
|
101
|
+
if (definition instanceof RangeNodeDefinition) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* At time of writing we know there is no code path producing this
|
|
107
|
+
* case, but appeasing the type checker for it now will guard against
|
|
108
|
+
* it happening mistakenly in any future refactoring. (Hint: it
|
|
109
|
+
* occurred during some refactoring that arrived here, which is why
|
|
110
|
+
* this isn't a type cast!)
|
|
111
|
+
*/
|
|
112
|
+
throw new ErrorProductionDesignPendingError(
|
|
113
|
+
`Invalid <range> definition with value type: ${definition.valueType}`
|
|
114
|
+
);
|
|
77
115
|
};
|
|
78
116
|
|
|
79
117
|
const isTriggerNodeDefinition = (
|
|
@@ -121,27 +159,29 @@ export const buildChildren = (parent: GeneralParentNode): GeneralChildNode[] =>
|
|
|
121
159
|
const leafChild: AnyLeafNodeDefinition = child;
|
|
122
160
|
|
|
123
161
|
if (isModelValueDefinition(leafChild)) {
|
|
124
|
-
return
|
|
162
|
+
return ModelValue.from(parent, leafChild);
|
|
125
163
|
}
|
|
126
164
|
|
|
127
|
-
if (
|
|
128
|
-
return
|
|
165
|
+
if (isInputDefinition(leafChild)) {
|
|
166
|
+
return InputControl.from(parent, leafChild);
|
|
129
167
|
}
|
|
130
168
|
|
|
131
|
-
if (
|
|
132
|
-
return
|
|
169
|
+
if (isSelectDefinition(leafChild)) {
|
|
170
|
+
return SelectControl.from(parent, leafChild);
|
|
133
171
|
}
|
|
134
172
|
|
|
135
|
-
if (
|
|
136
|
-
return
|
|
173
|
+
if (isRankDefinition(leafChild)) {
|
|
174
|
+
return RankControl.from(parent, leafChild);
|
|
137
175
|
}
|
|
138
176
|
|
|
139
|
-
if (
|
|
140
|
-
return
|
|
177
|
+
if (isTriggerNodeDefinition(leafChild)) {
|
|
178
|
+
return TriggerControl.from(parent, leafChild);
|
|
141
179
|
}
|
|
142
180
|
|
|
143
|
-
if (
|
|
144
|
-
|
|
181
|
+
if (isRangeLeafNodeDefinition(leafChild)) {
|
|
182
|
+
assertRangeNodeDefinition(leafChild);
|
|
183
|
+
|
|
184
|
+
return RangeControl.from(parent, leafChild);
|
|
145
185
|
}
|
|
146
186
|
|
|
147
187
|
if (isUploadNodeDefinition(leafChild)) {
|
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
import type { Group } from './Group.ts';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { AnyInputControl } from './InputControl.ts';
|
|
3
|
+
import type { AnyModelValue } from './ModelValue.ts';
|
|
4
|
+
import type { AnyNote } from './Note.ts';
|
|
5
|
+
import type { PrimaryInstance } from './PrimaryInstance.ts';
|
|
6
|
+
import type { AnyRangeControl } from './RangeControl.ts';
|
|
4
7
|
import type { RepeatInstance } from './repeat/RepeatInstance.ts';
|
|
5
8
|
import type { RepeatRangeControlled } from './repeat/RepeatRangeControlled.ts';
|
|
6
9
|
import type { RepeatRangeUncontrolled } from './repeat/RepeatRangeUncontrolled.ts';
|
|
7
10
|
import type { Root } from './Root.ts';
|
|
8
|
-
import type {
|
|
9
|
-
import type { StringField } from './StringField.ts';
|
|
11
|
+
import type { SelectControl } from './SelectControl.ts';
|
|
10
12
|
import type { Subtree } from './Subtree.ts';
|
|
11
13
|
import type { TriggerControl } from './TriggerControl.ts';
|
|
12
|
-
import type {
|
|
13
|
-
import type { RankControl } from './unsupported/RankControl.ts';
|
|
14
|
+
import type { RankControl } from './RankControl.ts';
|
|
14
15
|
import type { UploadControl } from './unsupported/UploadControl.ts';
|
|
15
16
|
|
|
16
17
|
export type RepeatRange = RepeatRangeControlled | RepeatRangeUncontrolled;
|
|
17
18
|
|
|
18
19
|
// prettier-ignore
|
|
19
|
-
export type
|
|
20
|
-
| RangeControl
|
|
21
|
-
| RankControl
|
|
22
|
-
| UploadControl;
|
|
20
|
+
export type AnyUnsupportedControl = UploadControl;
|
|
23
21
|
|
|
24
22
|
// prettier-ignore
|
|
25
23
|
export type AnyNode =
|
|
26
24
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
25
|
+
| PrimaryInstance
|
|
27
26
|
| Root
|
|
28
27
|
| Group
|
|
29
28
|
| Subtree
|
|
30
29
|
| RepeatRange
|
|
31
30
|
| RepeatInstance
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
31
|
+
| AnyNote
|
|
32
|
+
| AnyModelValue
|
|
33
|
+
| AnyInputControl
|
|
34
|
+
| AnyRangeControl
|
|
35
|
+
| RankControl
|
|
36
|
+
| SelectControl
|
|
36
37
|
| TriggerControl
|
|
37
|
-
|
|
|
38
|
+
| AnyUnsupportedControl;
|
|
38
39
|
|
|
39
40
|
// prettier-ignore
|
|
40
41
|
export type AnyParentNode =
|
|
41
42
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
43
|
+
| PrimaryInstance
|
|
42
44
|
| Root
|
|
43
45
|
| Group
|
|
44
46
|
| Subtree
|
|
@@ -56,16 +58,19 @@ export type GeneralParentNode =
|
|
|
56
58
|
// prettier-ignore
|
|
57
59
|
export type AnyChildNode =
|
|
58
60
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
61
|
+
| Root
|
|
59
62
|
| Group
|
|
60
63
|
| Subtree
|
|
61
64
|
| RepeatRange
|
|
62
65
|
| RepeatInstance
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
66
|
+
| AnyModelValue
|
|
67
|
+
| AnyNote
|
|
68
|
+
| AnyInputControl
|
|
69
|
+
| AnyRangeControl
|
|
70
|
+
| RankControl
|
|
71
|
+
| SelectControl
|
|
67
72
|
| TriggerControl
|
|
68
|
-
|
|
|
73
|
+
| AnyUnsupportedControl;
|
|
69
74
|
|
|
70
75
|
// prettier-ignore
|
|
71
76
|
export type GeneralChildNode =
|
|
@@ -73,19 +78,23 @@ export type GeneralChildNode =
|
|
|
73
78
|
| Group
|
|
74
79
|
| Subtree
|
|
75
80
|
| RepeatRange
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
81
|
+
| AnyModelValue
|
|
82
|
+
| AnyNote
|
|
83
|
+
| AnyInputControl
|
|
84
|
+
| AnyRangeControl
|
|
85
|
+
| RankControl
|
|
86
|
+
| SelectControl
|
|
80
87
|
| TriggerControl
|
|
81
|
-
|
|
|
88
|
+
| AnyUnsupportedControl;
|
|
82
89
|
|
|
83
90
|
// prettier-ignore
|
|
84
91
|
export type AnyValueNode =
|
|
85
92
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
93
|
+
| AnyModelValue
|
|
94
|
+
| AnyNote
|
|
95
|
+
| AnyInputControl
|
|
96
|
+
| AnyRangeControl
|
|
97
|
+
| RankControl
|
|
98
|
+
| SelectControl
|
|
90
99
|
| TriggerControl
|
|
91
|
-
|
|
|
100
|
+
| 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,26 @@
|
|
|
1
|
+
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
|
+
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
3
|
+
import type { AnyBindPreloadDefinition } from '../../parse/model/BindPreloadDefinition.ts';
|
|
4
|
+
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
5
|
+
|
|
6
|
+
export type DecodeInstanceValue = (value: string) => string;
|
|
7
|
+
|
|
8
|
+
interface InstanceValueContextDefinitionBind {
|
|
9
|
+
readonly preload: AnyBindPreloadDefinition | null;
|
|
10
|
+
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
11
|
+
readonly readonly: BindComputationExpression<'readonly'>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface InstanceValueContextDefinition {
|
|
15
|
+
readonly bind: InstanceValueContextDefinitionBind;
|
|
16
|
+
readonly defaultValue: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface InstanceValueContext extends EvaluationContext {
|
|
20
|
+
readonly scope: ReactiveScope;
|
|
21
|
+
readonly definition: InstanceValueContextDefinition;
|
|
22
|
+
readonly decodeInstanceValue: DecodeInstanceValue;
|
|
23
|
+
|
|
24
|
+
isReadonly(): boolean;
|
|
25
|
+
isRelevant(): boolean;
|
|
26
|
+
}
|
|
@@ -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
|
+
}
|