@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
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ValueTypeInvariantError } from '../../error/ValueTypeInvariantError.ts';
|
|
2
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Per {@link https://getodk.github.io/xforms-spec/#data-type:int}, which
|
|
6
|
+
* specifies "as in {@link https://www.w3.org/TR/xmlschema-2/#int | XML 1.0}":
|
|
7
|
+
*
|
|
8
|
+
* > int is ·derived· from long by setting the value of ·maxInclusive· to be
|
|
9
|
+
* > 2147483647 and ·minInclusive· to be -2147483648.
|
|
10
|
+
*/
|
|
11
|
+
const INT_BOUNDS = {
|
|
12
|
+
MIN: -2_147_483_648n,
|
|
13
|
+
MAX: 2_147_483_647n,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const assertIntBounds = <T extends bigint | null>(value: T): T => {
|
|
17
|
+
if (value == null) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (value < INT_BOUNDS.MIN || value > INT_BOUNDS.MAX) {
|
|
22
|
+
throw new ValueTypeInvariantError(
|
|
23
|
+
'int',
|
|
24
|
+
`Unable to decode int value from ${String(value)}: expected value to be between ${INT_BOUNDS.MIN} and ${INT_BOUNDS.MAX} (inclusive)`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const boundedInt = (value: bigint | number): bigint => {
|
|
32
|
+
const result = BigInt(value);
|
|
33
|
+
|
|
34
|
+
assertIntBounds(result);
|
|
35
|
+
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type IntInputValue = bigint | number | string | null;
|
|
40
|
+
|
|
41
|
+
const numberToInt = (value: number): bigint | null => {
|
|
42
|
+
if (!Number.isFinite(value)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return boundedInt(Math.trunc(value));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const encodeInt = (value: IntInputValue): string => {
|
|
50
|
+
let intValue: bigint | null;
|
|
51
|
+
|
|
52
|
+
switch (typeof value) {
|
|
53
|
+
case 'object':
|
|
54
|
+
value satisfies null;
|
|
55
|
+
intValue = null;
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case 'number':
|
|
59
|
+
intValue = numberToInt(value);
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
case 'string':
|
|
63
|
+
intValue = decodeInt(value);
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
value satisfies bigint;
|
|
68
|
+
|
|
69
|
+
intValue = boundedInt(value);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (intValue == null) {
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return String(intValue);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type IntRuntimeValue = bigint | null;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Note: Collect/JavaRosa trim decimal values (i.e. round closest to zero). We
|
|
83
|
+
* do the same.
|
|
84
|
+
*
|
|
85
|
+
* @todo Note that we enforce bounds **after** rounding, which may not be quite
|
|
86
|
+
* right! Look at actual Collect/JR implementation to align.
|
|
87
|
+
*/
|
|
88
|
+
const decodeInt = (value: string): IntRuntimeValue => {
|
|
89
|
+
if (value === '') {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return numberToInt(Number(value));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export class IntValueCodec extends ValueCodec<'int', IntRuntimeValue, IntInputValue> {
|
|
97
|
+
constructor() {
|
|
98
|
+
super('int', encodeInt, decodeInt);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { identity } from '@getodk/common/lib/identity.ts';
|
|
2
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
3
|
+
|
|
4
|
+
export class StringValueCodec extends ValueCodec<'string', string, string> {
|
|
5
|
+
constructor() {
|
|
6
|
+
super('string', identity, identity, {
|
|
7
|
+
decodeInstanceValueFactory: () => identity,
|
|
8
|
+
runtimeValueStateFactory: () => identity,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Accessor } from 'solid-js';
|
|
2
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
3
|
+
import type { DecodeInstanceValue } from '../../instance/internal-api/InstanceValueContext.ts';
|
|
4
|
+
import type { SimpleAtomicState } from '../reactivity/types.ts';
|
|
5
|
+
|
|
6
|
+
type CodecEncoder<RuntimeInputValue> = (input: RuntimeInputValue) => string;
|
|
7
|
+
|
|
8
|
+
type CodecDecoder<RuntimeValue> = (value: string) => RuntimeValue;
|
|
9
|
+
|
|
10
|
+
type RuntimeValueAccessor<RuntimeValue> = Accessor<RuntimeValue>;
|
|
11
|
+
|
|
12
|
+
export type RuntimeValueSetter<
|
|
13
|
+
RuntimeValue extends RuntimeInputValue,
|
|
14
|
+
RuntimeInputValue = RuntimeValue,
|
|
15
|
+
> = (input: RuntimeInputValue) => RuntimeValue;
|
|
16
|
+
|
|
17
|
+
export type RuntimeValueState<
|
|
18
|
+
RuntimeValue extends RuntimeInputValue,
|
|
19
|
+
RuntimeInputValue = RuntimeValue,
|
|
20
|
+
> = readonly [
|
|
21
|
+
get: RuntimeValueAccessor<RuntimeValue>,
|
|
22
|
+
set: RuntimeValueSetter<RuntimeValue, RuntimeInputValue>,
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export type CreateRuntimeValueState<
|
|
26
|
+
RuntimeValue extends RuntimeInputValue,
|
|
27
|
+
RuntimeInputValue = RuntimeValue,
|
|
28
|
+
> = (
|
|
29
|
+
instanceState: SimpleAtomicState<string>
|
|
30
|
+
) => RuntimeValueState<RuntimeValue, RuntimeInputValue>;
|
|
31
|
+
|
|
32
|
+
type RuntimeValueStateFactory<
|
|
33
|
+
RuntimeValue extends RuntimeInputValue,
|
|
34
|
+
RuntimeInputValue = RuntimeValue,
|
|
35
|
+
> = (
|
|
36
|
+
encodeValue: CodecEncoder<RuntimeInputValue>,
|
|
37
|
+
decodeValue: CodecDecoder<RuntimeValue>
|
|
38
|
+
) => CreateRuntimeValueState<RuntimeValue, RuntimeInputValue>;
|
|
39
|
+
|
|
40
|
+
type DecodeInstanceValueFactory<
|
|
41
|
+
RuntimeValue extends RuntimeInputValue,
|
|
42
|
+
RuntimeInputValue = RuntimeValue,
|
|
43
|
+
> = (
|
|
44
|
+
encodeValue: CodecEncoder<RuntimeInputValue>,
|
|
45
|
+
decodeValue: CodecDecoder<RuntimeValue>
|
|
46
|
+
) => DecodeInstanceValue;
|
|
47
|
+
|
|
48
|
+
interface ValueCodecOptions<RuntimeValue extends RuntimeInputValue, RuntimeInputValue> {
|
|
49
|
+
readonly decodeInstanceValueFactory?: DecodeInstanceValueFactory<RuntimeValue, RuntimeInputValue>;
|
|
50
|
+
readonly runtimeValueStateFactory?: RuntimeValueStateFactory<RuntimeValue, RuntimeInputValue>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export abstract class ValueCodec<
|
|
54
|
+
V extends ValueType,
|
|
55
|
+
RuntimeValue extends RuntimeInputValue,
|
|
56
|
+
RuntimeInputValue = RuntimeValue,
|
|
57
|
+
> {
|
|
58
|
+
protected readonly defaultRuntimeValueStateFactory: RuntimeValueStateFactory<
|
|
59
|
+
RuntimeValue,
|
|
60
|
+
RuntimeInputValue
|
|
61
|
+
> = (encodeValue, decodeValue) => {
|
|
62
|
+
return (instanceState) => {
|
|
63
|
+
const [getInstanceValue, setInstanceValue] = instanceState;
|
|
64
|
+
|
|
65
|
+
const getValue = (): RuntimeValue => {
|
|
66
|
+
return decodeValue(getInstanceValue());
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const setValue = (runtimeValue: RuntimeInputValue): RuntimeValue => {
|
|
70
|
+
const encodedValue = encodeValue(runtimeValue);
|
|
71
|
+
const persistedValue = setInstanceValue(encodedValue);
|
|
72
|
+
|
|
73
|
+
return decodeValue(persistedValue);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return [getValue, setValue];
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
protected readonly defaultDecodeInstanceValueFactory: DecodeInstanceValueFactory<
|
|
81
|
+
RuntimeValue,
|
|
82
|
+
RuntimeInputValue
|
|
83
|
+
> = (encodeValue, decodeValue) => {
|
|
84
|
+
return (instanceValue) => {
|
|
85
|
+
return encodeValue(decodeValue(instanceValue));
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
readonly decodeInstanceValue: DecodeInstanceValue;
|
|
90
|
+
readonly createRuntimeValueState: CreateRuntimeValueState<RuntimeValue, RuntimeInputValue>;
|
|
91
|
+
|
|
92
|
+
constructor(
|
|
93
|
+
readonly valueType: V,
|
|
94
|
+
readonly encodeValue: CodecEncoder<RuntimeInputValue>,
|
|
95
|
+
readonly decodeValue: CodecDecoder<RuntimeValue>,
|
|
96
|
+
options: ValueCodecOptions<RuntimeValue, RuntimeInputValue> = {}
|
|
97
|
+
) {
|
|
98
|
+
const {
|
|
99
|
+
decodeInstanceValueFactory = this.defaultDecodeInstanceValueFactory,
|
|
100
|
+
runtimeValueStateFactory = this.defaultRuntimeValueStateFactory,
|
|
101
|
+
} = options;
|
|
102
|
+
|
|
103
|
+
this.decodeInstanceValue = decodeInstanceValueFactory(encodeValue, decodeValue);
|
|
104
|
+
this.createRuntimeValueState = runtimeValueStateFactory(encodeValue, decodeValue);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { identity } from '@getodk/common/lib/identity.ts';
|
|
2
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
3
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides fallback functionality where a {@link ValueCodec} is expected, for
|
|
7
|
+
* those {@link ValueType | value types} which are still pending implementation.
|
|
8
|
+
* This allows consistent use of the {@link ValueCodec} interface while
|
|
9
|
+
* maintaining the current behavior of treating those unimplemented value types
|
|
10
|
+
* as string values.
|
|
11
|
+
*/
|
|
12
|
+
export class ValueTypePlaceholderCodec<V extends ValueType> extends ValueCodec<V, string, string> {
|
|
13
|
+
constructor(valueType: V) {
|
|
14
|
+
super(valueType, identity, identity, {
|
|
15
|
+
decodeInstanceValueFactory: () => identity,
|
|
16
|
+
runtimeValueStateFactory: () => identity,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import {
|
|
3
|
+
DecimalValueCodec,
|
|
4
|
+
type DecimalInputValue,
|
|
5
|
+
type DecimalRuntimeValue,
|
|
6
|
+
} from './DecimalValueCodec.ts';
|
|
7
|
+
import { IntValueCodec, type IntInputValue, type IntRuntimeValue } from './IntValueCodec.ts';
|
|
8
|
+
import { StringValueCodec } from './StringValueCodec.ts';
|
|
9
|
+
import type { ValueCodec } from './ValueCodec.ts';
|
|
10
|
+
import { ValueTypePlaceholderCodec } from './ValueTypePlaceholderCodec.ts';
|
|
11
|
+
|
|
12
|
+
interface RuntimeValuesByType {
|
|
13
|
+
readonly string: string;
|
|
14
|
+
readonly int: IntRuntimeValue;
|
|
15
|
+
readonly decimal: DecimalRuntimeValue;
|
|
16
|
+
readonly boolean: string;
|
|
17
|
+
readonly date: string;
|
|
18
|
+
readonly time: string;
|
|
19
|
+
readonly dateTime: string;
|
|
20
|
+
readonly geopoint: string;
|
|
21
|
+
readonly geotrace: string;
|
|
22
|
+
readonly geoshape: string;
|
|
23
|
+
readonly binary: string;
|
|
24
|
+
readonly barcode: string;
|
|
25
|
+
readonly intent: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type RuntimeValue<V extends ValueType> = RuntimeValuesByType[V];
|
|
29
|
+
|
|
30
|
+
interface RuntimeInputValuesByType {
|
|
31
|
+
readonly string: string;
|
|
32
|
+
readonly int: IntInputValue;
|
|
33
|
+
readonly decimal: DecimalInputValue;
|
|
34
|
+
readonly boolean: string;
|
|
35
|
+
readonly date: string;
|
|
36
|
+
readonly time: string;
|
|
37
|
+
readonly dateTime: string;
|
|
38
|
+
readonly geopoint: string;
|
|
39
|
+
readonly geotrace: string;
|
|
40
|
+
readonly geoshape: string;
|
|
41
|
+
readonly binary: string;
|
|
42
|
+
readonly barcode: string;
|
|
43
|
+
readonly intent: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type RuntimeInputValue<V extends ValueType> = RuntimeInputValuesByType[V];
|
|
47
|
+
|
|
48
|
+
type SharedValueCodecs = {
|
|
49
|
+
readonly [V in ValueType]: ValueCodec<V, RuntimeValue<V>, RuntimeInputValue<V>>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type SharedValueCodec<V extends ValueType> = SharedValueCodecs[V];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Provides codecs for each {@link ValueType | value type}, for nodes with a
|
|
56
|
+
* common representation of those value types.
|
|
57
|
+
*/
|
|
58
|
+
export const sharedValueCodecs: SharedValueCodecs = {
|
|
59
|
+
string: new StringValueCodec(),
|
|
60
|
+
|
|
61
|
+
int: new IntValueCodec(),
|
|
62
|
+
decimal: new DecimalValueCodec(),
|
|
63
|
+
boolean: new ValueTypePlaceholderCodec('boolean'),
|
|
64
|
+
date: new ValueTypePlaceholderCodec('date'),
|
|
65
|
+
time: new ValueTypePlaceholderCodec('time'),
|
|
66
|
+
dateTime: new ValueTypePlaceholderCodec('dateTime'),
|
|
67
|
+
geopoint: new ValueTypePlaceholderCodec('geopoint'),
|
|
68
|
+
geotrace: new ValueTypePlaceholderCodec('geotrace'),
|
|
69
|
+
geoshape: new ValueTypePlaceholderCodec('geoshape'),
|
|
70
|
+
binary: new ValueTypePlaceholderCodec('binary'),
|
|
71
|
+
barcode: new ValueTypePlaceholderCodec('barcode'),
|
|
72
|
+
intent: new ValueTypePlaceholderCodec('intent'),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const getSharedValueCodec = <V extends ValueType>(valueType: V): SharedValueCodec<V> => {
|
|
76
|
+
return sharedValueCodecs[valueType];
|
|
77
|
+
};
|
package/src/lib/dom/query.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
KnownAttributeLocalNamedElement,
|
|
4
4
|
LocalNamedElement,
|
|
5
5
|
} from '@getodk/common/types/dom.ts';
|
|
6
|
-
import type { SelectElement } from '../../body/control/select/SelectDefinition';
|
|
6
|
+
import type { SelectElement } from '../../parse/body/control/select/SelectDefinition';
|
|
7
7
|
|
|
8
8
|
const hintLookup = new ScopedElementLookup(':scope > hint', 'hint');
|
|
9
9
|
const itemLookup = new ScopedElementLookup(':scope > item', 'item');
|
|
@@ -15,6 +15,7 @@ const repeatGroupLabelLookup = new ScopedElementLookup(
|
|
|
15
15
|
);
|
|
16
16
|
const repeatLookup = new ScopedElementLookup(':scope > repeat[nodeset]', 'repeat[nodeset]');
|
|
17
17
|
const valueLookup = new ScopedElementLookup(':scope > value', 'value');
|
|
18
|
+
const submissionLookup = new ScopedElementLookup(':scope > submission', 'submission');
|
|
18
19
|
|
|
19
20
|
export interface HintElement extends LocalNamedElement<'hint'> {}
|
|
20
21
|
|
|
@@ -60,3 +61,9 @@ export const getRepeatElement = (parent: Element): RepeatElement | null => {
|
|
|
60
61
|
export const getValueElement = (parent: ItemElement | ItemsetElement): ValueElement | null => {
|
|
61
62
|
return valueLookup.getElement<ValueElement>(parent);
|
|
62
63
|
};
|
|
64
|
+
|
|
65
|
+
export interface SubmissionElement extends LocalNamedElement<'submission'> {}
|
|
66
|
+
|
|
67
|
+
export const getSubmissionElement = (parent: Element): SubmissionElement | null => {
|
|
68
|
+
return submissionLookup.getElement<SubmissionElement>(parent);
|
|
69
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Accessor, Setter, Signal } from 'solid-js';
|
|
2
2
|
import { createSignal } from 'solid-js';
|
|
3
|
+
import type { FormNodeID } from '../../client/identity.ts';
|
|
3
4
|
import type { OpaqueReactiveObjectFactory } from '../../index.ts';
|
|
4
5
|
import type { AnyChildNode, AnyParentNode } from '../../instance/hierarchy.ts';
|
|
5
|
-
import type { NodeID } from '../../instance/identity.ts';
|
|
6
6
|
import type { materializeCurrentStateChildren } from './materializeCurrentStateChildren.ts';
|
|
7
7
|
import type { ClientState } from './node-state/createClientState.ts';
|
|
8
8
|
import type { CurrentState } from './node-state/createCurrentState.ts';
|
|
@@ -12,14 +12,15 @@ export interface ChildrenState<Child extends AnyChildNode> {
|
|
|
12
12
|
readonly children: Signal<readonly Child[]>;
|
|
13
13
|
readonly getChildren: Accessor<readonly Child[]>;
|
|
14
14
|
readonly setChildren: Setter<readonly Child[]>;
|
|
15
|
-
readonly childIds: Accessor<readonly
|
|
15
|
+
readonly childIds: Accessor<readonly FormNodeID[]>;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Creates a synchronized pair of:
|
|
20
20
|
*
|
|
21
21
|
* - Internal children state suitable for all parent node types
|
|
22
|
-
* - The same children state computed as an array of each child's
|
|
22
|
+
* - The same children state computed as an array of each child's
|
|
23
|
+
* {@link FormNodeID}
|
|
23
24
|
*
|
|
24
25
|
* This state is used, in tandem with {@link materializeCurrentStateChildren},
|
|
25
26
|
* to ensure children in **client-facing** state are not written into nested
|
|
@@ -34,11 +35,12 @@ export interface ChildrenState<Child extends AnyChildNode> {
|
|
|
34
35
|
* The produced {@link ChildrenState.childIds} memo is intended to be used to
|
|
35
36
|
* specify each parent node's `children` in an instance of {@link EngineState}.
|
|
36
37
|
* In so doing, the node's corresponding (internal, synchronized)
|
|
37
|
-
* {@link ClientState} will likewise store only the children's
|
|
38
|
+
* {@link ClientState} will likewise store only the children's
|
|
39
|
+
* {@link FormNodeID}s.
|
|
38
40
|
*
|
|
39
41
|
* As a client reacts to changes in a given parent node's `children` state, that
|
|
40
42
|
* node's {@link CurrentState} should produce the child nodes corresponding to
|
|
41
|
-
* those {@link
|
|
43
|
+
* those {@link FormNodeID}s with the aforementioned
|
|
42
44
|
* {@link materializeCurrentStateChildren}.
|
|
43
45
|
*/
|
|
44
46
|
export const createChildrenState = <Parent extends AnyParentNode, Child extends AnyChildNode>(
|
|
@@ -65,7 +67,7 @@ export const createChildrenState = <Parent extends AnyParentNode, Child extends
|
|
|
65
67
|
* likely also slightly more efficient. We can revisit the tradeoff if/when
|
|
66
68
|
* those hypothetical generalizations become a priority.
|
|
67
69
|
*/
|
|
68
|
-
const ids = createSignal<readonly
|
|
70
|
+
const ids = createSignal<readonly FormNodeID[]>([]);
|
|
69
71
|
const [childIds, setChildIds] = ids;
|
|
70
72
|
|
|
71
73
|
type ChildrenSetterCallback = (prev: readonly Child[]) => readonly Child[];
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
2
|
-
import type { XFormsXPathEvaluator } from '@getodk/xpath';
|
|
3
2
|
import type { Accessor } from 'solid-js';
|
|
4
3
|
import { createMemo } from 'solid-js';
|
|
4
|
+
import type { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
|
|
5
|
+
import type { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
6
|
+
import type { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
5
7
|
import type {
|
|
6
8
|
DependentExpression,
|
|
7
9
|
DependentExpressionResultType,
|
|
8
|
-
} from '../../expression/DependentExpression.ts';
|
|
9
|
-
import type { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
|
|
10
|
-
import type { SubscribableDependency } from '../../instance/internal-api/SubscribableDependency.ts';
|
|
10
|
+
} from '../../parse/expression/abstract/DependentExpression.ts';
|
|
11
11
|
import { isConstantExpression } from '../../parse/xpath/semantic-analysis.ts';
|
|
12
12
|
|
|
13
13
|
interface ComputedExpressionResults {
|
|
14
14
|
readonly boolean: boolean;
|
|
15
|
-
readonly nodes:
|
|
15
|
+
readonly nodes: EngineXPathNode[];
|
|
16
16
|
readonly number: number;
|
|
17
17
|
readonly string: string;
|
|
18
18
|
}
|
|
@@ -25,16 +25,18 @@ type EvaluatedExpression<
|
|
|
25
25
|
// prettier-ignore
|
|
26
26
|
type ExpressionEvaluator<
|
|
27
27
|
Type extends DependentExpressionResultType
|
|
28
|
-
> = () => EvaluatedExpression<Type
|
|
28
|
+
> = () => EvaluatedExpression<Type>;
|
|
29
|
+
|
|
30
|
+
interface ExpressionEvaluatorOptions {
|
|
31
|
+
get contextNode(): EngineXPathNode;
|
|
32
|
+
}
|
|
29
33
|
|
|
30
34
|
const expressionEvaluator = <Type extends DependentExpressionResultType>(
|
|
31
|
-
evaluator:
|
|
32
|
-
contextNode: Node,
|
|
35
|
+
evaluator: EngineXPathEvaluator,
|
|
33
36
|
type: Type,
|
|
34
|
-
expression: string
|
|
37
|
+
expression: string,
|
|
38
|
+
options: ExpressionEvaluatorOptions
|
|
35
39
|
): ExpressionEvaluator<Type> => {
|
|
36
|
-
const options = { contextNode };
|
|
37
|
-
|
|
38
40
|
switch (type) {
|
|
39
41
|
case 'boolean':
|
|
40
42
|
return (() => {
|
|
@@ -61,50 +63,71 @@ const expressionEvaluator = <Type extends DependentExpressionResultType>(
|
|
|
61
63
|
}
|
|
62
64
|
};
|
|
63
65
|
|
|
66
|
+
type DefaultEvaluationsByType = {
|
|
67
|
+
readonly [Type in DependentExpressionResultType]: EvaluatedExpression<Type>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const DEFAULT_BOOLEAN_EVALUATION = false;
|
|
71
|
+
const DEFAULT_NODES_EVALUATION: [] = [];
|
|
72
|
+
const DEFAULT_NUMBER_EVALUATION = NaN;
|
|
73
|
+
const DEFAULT_STRING_EVALUATION = '';
|
|
74
|
+
|
|
75
|
+
const defaultEvaluationsByType: DefaultEvaluationsByType = {
|
|
76
|
+
boolean: DEFAULT_BOOLEAN_EVALUATION,
|
|
77
|
+
nodes: DEFAULT_NODES_EVALUATION,
|
|
78
|
+
number: DEFAULT_NUMBER_EVALUATION,
|
|
79
|
+
string: DEFAULT_STRING_EVALUATION,
|
|
80
|
+
};
|
|
81
|
+
|
|
64
82
|
// prettier-ignore
|
|
65
83
|
type ComputedExpression<Type extends DependentExpressionResultType> = Accessor<
|
|
66
84
|
EvaluatedExpression<Type>
|
|
67
85
|
>;
|
|
68
86
|
|
|
69
|
-
interface CreateComputedExpressionOptions {
|
|
70
|
-
|
|
87
|
+
interface CreateComputedExpressionOptions<Type extends DependentExpressionResultType> {
|
|
88
|
+
/**
|
|
89
|
+
* If a default value is provided, {@link createComputedExpression} will
|
|
90
|
+
* produce this value for computations in a non-attached evaluation context,
|
|
91
|
+
* i.e. when evaluating an expression against a node which has not yet been
|
|
92
|
+
* appended to its parents children state (or which has since been removed
|
|
93
|
+
* from that state). A non-attached state is detected when
|
|
94
|
+
* {@link EvaluationContext.isAttached} returns false.
|
|
95
|
+
*
|
|
96
|
+
* If no default value is provided, an implicit default value is produced as
|
|
97
|
+
* appropriate for the expression's intrinsic result type.
|
|
98
|
+
*
|
|
99
|
+
* @see {@link defaultEvaluationsByType} for these implicit defaults.
|
|
100
|
+
*/
|
|
101
|
+
readonly defaultValue?: EvaluatedExpression<Type>;
|
|
71
102
|
}
|
|
72
103
|
|
|
73
104
|
export const createComputedExpression = <Type extends DependentExpressionResultType>(
|
|
74
105
|
context: EvaluationContext,
|
|
75
106
|
dependentExpression: DependentExpression<Type>,
|
|
76
|
-
options: CreateComputedExpressionOptions = {}
|
|
107
|
+
options: CreateComputedExpressionOptions<Type> = {}
|
|
77
108
|
): ComputedExpression<Type> => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
109
|
+
return context.scope.runTask(() => {
|
|
110
|
+
const { contextNode, evaluator } = context;
|
|
111
|
+
const { expression, isTranslated, resultType } = dependentExpression;
|
|
112
|
+
const evaluatePreInitializationDefaultValue = () => {
|
|
113
|
+
return options?.defaultValue ?? defaultEvaluationsByType[resultType];
|
|
114
|
+
};
|
|
115
|
+
const evaluateExpression = expressionEvaluator(evaluator, resultType, expression, {
|
|
116
|
+
contextNode,
|
|
117
|
+
});
|
|
82
118
|
|
|
83
|
-
return scope.runTask(() => {
|
|
84
119
|
if (isConstantExpression(expression)) {
|
|
85
120
|
return createMemo(evaluateExpression);
|
|
86
121
|
}
|
|
87
122
|
|
|
88
|
-
const { arbitraryDependencies = [] } = options;
|
|
89
|
-
|
|
90
|
-
const getReferencedDependencies = createMemo(() => {
|
|
91
|
-
return dependencyReferences.flatMap((reference) => {
|
|
92
|
-
return context.getSubscribableDependenciesByReference(reference) ?? [];
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
123
|
return createMemo(() => {
|
|
97
|
-
if (
|
|
98
|
-
|
|
124
|
+
if (!context.isAttached()) {
|
|
125
|
+
return evaluatePreInitializationDefaultValue();
|
|
99
126
|
}
|
|
100
127
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
getReferencedDependencies().forEach((dependency) => {
|
|
106
|
-
dependency.subscribe();
|
|
107
|
-
});
|
|
128
|
+
if (isTranslated) {
|
|
129
|
+
context.getActiveLanguage();
|
|
130
|
+
}
|
|
108
131
|
|
|
109
132
|
return evaluateExpression();
|
|
110
133
|
});
|