@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
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { NamespaceURL } from './NamespaceURL.ts';
|
|
2
|
+
export type NamespaceURI = NamespaceURL | null;
|
|
3
|
+
export type QualifiedNamePrefix = string | null;
|
|
4
|
+
export interface NamespaceQualifiedNameSource {
|
|
5
|
+
readonly namespaceURI: NamespaceURI | string;
|
|
6
|
+
readonly localName: string;
|
|
7
|
+
/**
|
|
8
|
+
* Note that this property is intentionally optional as one of the
|
|
9
|
+
* {@link QualifiedNameSource | QualifiedName source input}, and its absence
|
|
10
|
+
* is treated differently from an explicitly assigned `null` value.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link SourcePrefixUnspecified}, {@link DeferredPrefix}
|
|
13
|
+
*/
|
|
14
|
+
readonly prefix?: QualifiedNamePrefix;
|
|
15
|
+
}
|
|
16
|
+
declare const SOURCE_PREFIX_UNSPECIFIED: unique symbol;
|
|
17
|
+
/**
|
|
18
|
+
* May be used as a placeholder for a {@link QualifiedName.prefix}, where the
|
|
19
|
+
* actual prefix may not be known at definition time.
|
|
20
|
+
*
|
|
21
|
+
* Example: parsing non-XML sources into an XML-like tree, e.g. for XPath
|
|
22
|
+
* evaluation; in which case, we may not need to resolve a prefix for the name
|
|
23
|
+
* until such a node is serialized as XML, if it ever is.
|
|
24
|
+
*/
|
|
25
|
+
type SourcePrefixUnspecified = typeof SOURCE_PREFIX_UNSPECIFIED;
|
|
26
|
+
/**
|
|
27
|
+
* Represents a {@link QualifiedName.prefix} whose resolution may be deferred,
|
|
28
|
+
* e.g. until all requisite parsing is complete and/or until XML serialization
|
|
29
|
+
* requires use of a prefix to represent the corresponding
|
|
30
|
+
* {@link QualifiedName.namespaceURI}.
|
|
31
|
+
*/
|
|
32
|
+
type DeferredPrefix = string | null | SourcePrefixUnspecified;
|
|
33
|
+
interface DeferredPrefixedQualifiedNameSource {
|
|
34
|
+
readonly namespaceURI: NamespaceURI | string;
|
|
35
|
+
readonly prefix: DeferredPrefix;
|
|
36
|
+
readonly localName: string;
|
|
37
|
+
}
|
|
38
|
+
export type QualifiedNameSource = NamespaceQualifiedNameSource | DeferredPrefixedQualifiedNameSource;
|
|
39
|
+
interface PrefixResolutionOptions {
|
|
40
|
+
lookupPrefix(namespaceURI: NamespaceURI | string): string | null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @todo This is in the `lib` directory because it's a cross-cutting concern,
|
|
44
|
+
* applicable to:
|
|
45
|
+
*
|
|
46
|
+
* - Parsing XML into a useful runtime data model (usage which motivated initial
|
|
47
|
+
* development of this class)
|
|
48
|
+
* - Serializing XML from a runtime data model (also motivated initial dev)
|
|
49
|
+
* - `@getodk/xpath` (internal) e.g. references to
|
|
50
|
+
* {@link https://www.w3.org/TR/REC-xml-names/#NT-QName | QName} in various
|
|
51
|
+
* parts of XPath expression _syntax_, as well as various parts of the package
|
|
52
|
+
* interpreting those parts of syntax
|
|
53
|
+
* - `@getodk/xpath` (cross-package), e.g. in aspects of the
|
|
54
|
+
* {@link XPathDOMAdapter} APIs, and implementations thereof
|
|
55
|
+
* - A zillion potential optimizations, e.g. where names are useful in a lookup
|
|
56
|
+
* table (or used in conjunction with other information to construct keys for
|
|
57
|
+
* same)
|
|
58
|
+
*
|
|
59
|
+
* @todo As a cross-cutting concern, there are subtle but important differences
|
|
60
|
+
* between certain XPath and XML semantics around expressions of a "null"
|
|
61
|
+
* {@link prefix}. E.g. in the expression `/foo`, **technically** the `foo` Step
|
|
62
|
+
* should select child elements _in the null namespace_, whereas in most other
|
|
63
|
+
* cases a null prefix (when explicitly assigned `null`, rather than
|
|
64
|
+
* {@link DeferredPrefix | deferred for later resolution}) is expected to
|
|
65
|
+
* correspond _to the default namespace_ (whatever that is in the context of the
|
|
66
|
+
* {@link QualifiedName | qualified-named thing}).
|
|
67
|
+
*
|
|
68
|
+
* @todo As a mechanism for many optimizations, an evolution of this class would
|
|
69
|
+
* be **BY FAR** most useful if it can be treated as a _value type_, despite
|
|
70
|
+
* challenges using non-primitives as such in a JS runtime. To be clear: it
|
|
71
|
+
* would be most useful if every instance of {@link QualifiedName} having the
|
|
72
|
+
* same property values (or in some cases, the same combined
|
|
73
|
+
* {@link namespaceURI}/{@link localName} or combined
|
|
74
|
+
* {@link prefix}/{@link localName}) would also have _reference equality_ with
|
|
75
|
+
* other instances having the same property values (or pertinent subset
|
|
76
|
+
* thereof). Making a somewhat obvious point explicit: this would be
|
|
77
|
+
* particularly useful in cases where a lookup table is implemented as a native
|
|
78
|
+
* {@link Map}, where using {@link QualifiedName} as a key would break
|
|
79
|
+
* expectations (and probably quite a lot of functionality!) if 2+ equivalent
|
|
80
|
+
* keys mapped to different values.
|
|
81
|
+
*
|
|
82
|
+
* @todo Where we would want to treat instances as a value type, it would be
|
|
83
|
+
* useful to look at prior art for representation of the same data as a string.
|
|
84
|
+
* One frame of reference worth looking at is
|
|
85
|
+
* {@link https://www.w3.org/TR/xpath-30/#prod-xpath30-URIQualifiedName | XPath 3.0's URIQualifiedName}
|
|
86
|
+
* (but note that this syntax is mutually exclusive with the prefixed `QName`).
|
|
87
|
+
*/
|
|
88
|
+
export declare class QualifiedName implements DeferredPrefixedQualifiedNameSource {
|
|
89
|
+
private readonly defaultPrefixResolutionOptions;
|
|
90
|
+
readonly namespaceURI: NamespaceURI;
|
|
91
|
+
/**
|
|
92
|
+
* @see {@link SourcePrefixUnspecified}, {@link DeferredPrefix}
|
|
93
|
+
*/
|
|
94
|
+
readonly prefix: DeferredPrefix;
|
|
95
|
+
readonly localName: string;
|
|
96
|
+
constructor(source: QualifiedNameSource);
|
|
97
|
+
/**
|
|
98
|
+
* @todo at time of writing, it's not expected we will actually supply
|
|
99
|
+
* {@link options} in calls to this method! Current calls are from definitions
|
|
100
|
+
* whose prefixes are known at parse time (i.e. they are prefixed in the
|
|
101
|
+
* source XML from which they're parsed).
|
|
102
|
+
*
|
|
103
|
+
* The intent of accepting the options here now is to leave a fairly large
|
|
104
|
+
* breadcrumb, for any use case where we might want to serialize XML from
|
|
105
|
+
* artificially constructed DOM-like trees (e.g. `StaticNode` implementations
|
|
106
|
+
* defined by parsing non-XML external secondary instances such as CSV and
|
|
107
|
+
* GeoJSON). AFAIK this doesn't correspond to any known feature in the "like
|
|
108
|
+
* Collect" scope, but it could have implications for inspecting form details
|
|
109
|
+
* in e.g. "debug/form design/dev mode" scenarios.
|
|
110
|
+
*/
|
|
111
|
+
getPrefixedName(options?: PrefixResolutionOptions): string;
|
|
112
|
+
}
|
|
113
|
+
export {};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Accessor, Setter, Signal } from 'solid-js';
|
|
2
|
+
import { FormNodeID } from '../../client/identity.ts';
|
|
2
3
|
import { AnyChildNode, AnyParentNode } from '../../instance/hierarchy.ts';
|
|
3
|
-
import { NodeID } from '../../instance/identity.ts';
|
|
4
4
|
export interface ChildrenState<Child extends AnyChildNode> {
|
|
5
5
|
readonly children: Signal<readonly Child[]>;
|
|
6
6
|
readonly getChildren: Accessor<readonly Child[]>;
|
|
7
7
|
readonly setChildren: Setter<readonly Child[]>;
|
|
8
|
-
readonly childIds: Accessor<readonly
|
|
8
|
+
readonly childIds: Accessor<readonly FormNodeID[]>;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Creates a synchronized pair of:
|
|
12
12
|
*
|
|
13
13
|
* - Internal children state suitable for all parent node types
|
|
14
|
-
* - The same children state computed as an array of each child's
|
|
14
|
+
* - The same children state computed as an array of each child's
|
|
15
|
+
* {@link FormNodeID}
|
|
15
16
|
*
|
|
16
17
|
* This state is used, in tandem with {@link materializeCurrentStateChildren},
|
|
17
18
|
* to ensure children in **client-facing** state are not written into nested
|
|
@@ -26,11 +27,12 @@ export interface ChildrenState<Child extends AnyChildNode> {
|
|
|
26
27
|
* The produced {@link ChildrenState.childIds} memo is intended to be used to
|
|
27
28
|
* specify each parent node's `children` in an instance of {@link EngineState}.
|
|
28
29
|
* In so doing, the node's corresponding (internal, synchronized)
|
|
29
|
-
* {@link ClientState} will likewise store only the children's
|
|
30
|
+
* {@link ClientState} will likewise store only the children's
|
|
31
|
+
* {@link FormNodeID}s.
|
|
30
32
|
*
|
|
31
33
|
* As a client reacts to changes in a given parent node's `children` state, that
|
|
32
34
|
* node's {@link CurrentState} should produce the child nodes corresponding to
|
|
33
|
-
* those {@link
|
|
35
|
+
* those {@link FormNodeID}s with the aforementioned
|
|
34
36
|
* {@link materializeCurrentStateChildren}.
|
|
35
37
|
*/
|
|
36
38
|
export declare const createChildrenState: <Parent extends AnyParentNode, Child extends AnyChildNode>(parent: Parent) => ChildrenState<Child>;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import { Accessor } from 'solid-js';
|
|
2
2
|
import { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
4
4
|
import { DependentExpression, DependentExpressionResultType } from '../../parse/expression/abstract/DependentExpression.ts';
|
|
5
5
|
interface ComputedExpressionResults {
|
|
6
6
|
readonly boolean: boolean;
|
|
7
|
-
readonly nodes:
|
|
7
|
+
readonly nodes: EngineXPathNode[];
|
|
8
8
|
readonly number: number;
|
|
9
9
|
readonly string: string;
|
|
10
10
|
}
|
|
11
11
|
type EvaluatedExpression<Type extends DependentExpressionResultType> = ComputedExpressionResults[Type];
|
|
12
12
|
type ComputedExpression<Type extends DependentExpressionResultType> = Accessor<EvaluatedExpression<Type>>;
|
|
13
|
-
interface CreateComputedExpressionOptions {
|
|
14
|
-
|
|
13
|
+
interface CreateComputedExpressionOptions<Type extends DependentExpressionResultType> {
|
|
14
|
+
/**
|
|
15
|
+
* If a default value is provided, {@link createComputedExpression} will
|
|
16
|
+
* produce this value for computations in a non-attached evaluation context,
|
|
17
|
+
* i.e. when evaluating an expression against a node which has not yet been
|
|
18
|
+
* appended to its parents children state (or which has since been removed
|
|
19
|
+
* from that state). A non-attached state is detected when
|
|
20
|
+
* {@link EvaluationContext.isAttached} returns false.
|
|
21
|
+
*
|
|
22
|
+
* If no default value is provided, an implicit default value is produced as
|
|
23
|
+
* appropriate for the expression's intrinsic result type.
|
|
24
|
+
*
|
|
25
|
+
* @see {@link defaultEvaluationsByType} for these implicit defaults.
|
|
26
|
+
*/
|
|
27
|
+
readonly defaultValue?: EvaluatedExpression<Type>;
|
|
15
28
|
}
|
|
16
|
-
export declare const createComputedExpression: <Type extends DependentExpressionResultType>(context: EvaluationContext, dependentExpression: DependentExpression<Type>, options?: CreateComputedExpressionOptions) => ComputedExpression<Type>;
|
|
29
|
+
export declare const createComputedExpression: <Type extends DependentExpressionResultType>(context: EvaluationContext, dependentExpression: DependentExpression<Type>, options?: CreateComputedExpressionOptions<Type>) => ComputedExpression<Type>;
|
|
17
30
|
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InstanceValueContext } from '../../instance/internal-api/InstanceValueContext.ts';
|
|
2
|
+
import { SimpleAtomicState } from './types.ts';
|
|
3
|
+
type InitialValueSource = 'FORM_DEFAULT' | 'PRIMARY_INSTANCE';
|
|
4
|
+
export interface InstanceValueStateOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Specifies the source of a {@link createInstanceValueState} signal's initial
|
|
7
|
+
* value state, where:
|
|
8
|
+
*
|
|
9
|
+
* - 'FORM_DEFAULT': Derives the initial state from the form's definition of
|
|
10
|
+
* the node itself. This is the default option, appropriate when
|
|
11
|
+
* initializing a form without additional primary instance data. In other
|
|
12
|
+
* words, this value should not be used for edits.
|
|
13
|
+
*
|
|
14
|
+
* - 'PRIMARY_INSTANCE': Derives the initial state from the current text
|
|
15
|
+
* content of the {@link ValueNode.contextNode}. This option should be
|
|
16
|
+
* specified when initializing a form with existing primary instance data,
|
|
17
|
+
* such as when editing a previous submission.
|
|
18
|
+
*
|
|
19
|
+
* @default 'FORM_DEFAULT'
|
|
20
|
+
*
|
|
21
|
+
* Specifies whether a {@link createInstanceValueState} signal's initial state
|
|
22
|
+
* should be derived from the current text content of the
|
|
23
|
+
* {@link ValueNode.contextNode | primary instance DOM state}.
|
|
24
|
+
*/
|
|
25
|
+
readonly initialValueSource?: InitialValueSource;
|
|
26
|
+
}
|
|
27
|
+
export type InstanceValueState = SimpleAtomicState<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Provides a consistent interface for value nodes of any type which:
|
|
30
|
+
*
|
|
31
|
+
* - derives initial state from either an existing instance (e.g. for edits) or
|
|
32
|
+
* the node's definition (e.g. initializing a new submission)
|
|
33
|
+
* - decodes current primary instance state into the value node's runtime type
|
|
34
|
+
* - encodes updated runtime values to store updated instance state
|
|
35
|
+
* - initializes reactive computation of `calculate` bind expressions for those
|
|
36
|
+
* nodes defined with one
|
|
37
|
+
* - prevents downstream writes to nodes in a readonly state
|
|
38
|
+
*/
|
|
39
|
+
export declare const createInstanceValueState: (context: InstanceValueContext, options?: InstanceValueStateOptions) => InstanceValueState;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { SelectItem } from '../../client/SelectNode.ts';
|
|
3
|
+
import { RankItem } from '../../client/RankNode.ts';
|
|
4
|
+
import { SelectControl } from '../../instance/SelectControl.ts';
|
|
5
|
+
import { RankControl } from '../../instance/RankControl.ts';
|
|
6
|
+
export type ItemCollectionControl = RankControl | SelectControl;
|
|
7
|
+
type Item = RankItem | SelectItem;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a reactive computation of a {@link ItemCollectionControl}'s
|
|
10
|
+
* {@link Item}s, in support of the field's `valueOptions`.
|
|
11
|
+
*
|
|
12
|
+
* - The control defined with static `<item>`s will compute to an corresponding
|
|
13
|
+
* static list of items.
|
|
14
|
+
* - The control defined with a computed `<itemset>` will compute to a reactive list
|
|
15
|
+
* of items.
|
|
16
|
+
* - Items of both will produce {@link ItemType.label | labels} reactive to
|
|
17
|
+
* their appropriate dependencies (whether relative to the itemset item node,
|
|
18
|
+
* referencing a form's `itext` translations, etc).
|
|
19
|
+
*/
|
|
20
|
+
export declare const createItemCollection: (control: ItemCollectionControl) => Accessor<readonly Item[]>;
|
|
21
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Accessor } from 'solid-js';
|
|
2
2
|
import { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
|
|
3
|
-
import {
|
|
4
|
-
export declare const createNoteReadonlyThunk: (context: EvaluationContext,
|
|
3
|
+
import { NoteNodeDefinition } from '../../parse/model/NoteNodeDefinition.ts';
|
|
4
|
+
export declare const createNoteReadonlyThunk: (context: EvaluationContext, definition: NoteNodeDefinition) => Accessor<true>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { ActiveLanguage, FormLanguage, FormLanguages } from '../../client/FormLanguage.ts';
|
|
3
|
+
import { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
4
|
+
import { ReactiveScope } from './scope.ts';
|
|
5
|
+
import { SimpleAtomicStateSetter } from './types.ts';
|
|
6
|
+
interface TranslationState {
|
|
7
|
+
readonly languages: FormLanguages;
|
|
8
|
+
readonly getActiveLanguage: Accessor<ActiveLanguage>;
|
|
9
|
+
readonly setActiveLanguage: SimpleAtomicStateSetter<FormLanguage>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @todo It's been very silly all along that {@link XFormsXPathEvaluator} is
|
|
13
|
+
* responsible for parsing translation languages, and maintaining the active
|
|
14
|
+
* language state. It is especially silly now that we've moved _part of the
|
|
15
|
+
* parsing_ up to the constructor call site. Let's finish off that awkwardness
|
|
16
|
+
* in a subsequent refactor.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createTranslationState: (scope: ReactiveScope, evaluator: EngineXPathEvaluator) => TranslationState;
|
|
19
|
+
export {};
|
|
@@ -12,8 +12,7 @@ export interface ValueStateOptions {
|
|
|
12
12
|
* other words, this value should not be used for edits.
|
|
13
13
|
*
|
|
14
14
|
* - 'PRIMARY_INSTANCE': Derives the initial state from the current text
|
|
15
|
-
* content of the {@link ValueNode.contextNode}
|
|
16
|
-
* backing store/source of thruth for primary instance state). This option
|
|
15
|
+
* content of the {@link ValueNode.contextNode}. This option
|
|
17
16
|
* should be specified when initializing a form with existing primary
|
|
18
17
|
* instance data, such as when editing a previous submission.
|
|
19
18
|
*
|
|
@@ -29,16 +28,13 @@ type ValueState<RuntimeValue> = SimpleAtomicState<RuntimeValue>;
|
|
|
29
28
|
/**
|
|
30
29
|
* Provides a consistent interface for value nodes of any type which:
|
|
31
30
|
*
|
|
32
|
-
* - derives initial state from either
|
|
33
|
-
*
|
|
34
|
-
* - decodes primary instance state into the value node's runtime type
|
|
35
|
-
* - encodes
|
|
31
|
+
* - derives initial state from either an existing instance (e.g. for edits) or
|
|
32
|
+
* the node's definition (e.g. initializing a new submission)
|
|
33
|
+
* - decodes current primary instance state into the value node's runtime type
|
|
34
|
+
* - encodes updated runtime values to store updated instance state
|
|
36
35
|
* - initializes reactive computation of `calculate` bind expressions for those
|
|
37
36
|
* nodes defined with one
|
|
38
|
-
* -
|
|
39
|
-
* (whether performed by a client, or by a reactive `calculate` computation)
|
|
40
|
-
* are persisted, ensuring a consistent view of state when downstream
|
|
41
|
-
* computations perform XPath evaluations against that primary instance state
|
|
37
|
+
* - prevents downstream writes to nodes in a readonly state
|
|
42
38
|
*/
|
|
43
39
|
export declare const createValueState: <RuntimeValue>(context: ValueContext<RuntimeValue>, options?: ValueStateOptions) => ValueState<RuntimeValue>;
|
|
44
40
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { FormNodeID } from '../../client/identity.ts';
|
|
1
2
|
import { AnyChildNode } from '../../instance/hierarchy.ts';
|
|
2
|
-
import { NodeID } from '../../instance/identity.ts';
|
|
3
3
|
import { ChildrenState } from './createChildrenState.ts';
|
|
4
4
|
import { ReactiveScope } from './scope.ts';
|
|
5
5
|
export interface EncodedParentState {
|
|
6
|
-
readonly children: readonly
|
|
6
|
+
readonly children: readonly FormNodeID[];
|
|
7
7
|
}
|
|
8
8
|
export type MaterializedChildren<BaseState extends EncodedParentState, Child extends AnyChildNode | null> = Omit<BaseState, 'children'> & {
|
|
9
9
|
readonly children: readonly Child[];
|
|
@@ -11,8 +11,8 @@ export type MaterializedChildren<BaseState extends EncodedParentState, Child ext
|
|
|
11
11
|
/**
|
|
12
12
|
* Creates a wrapper proxy around a parent node's {@link CurrentState} to map
|
|
13
13
|
* `children` state, which is written to the node's (internal, synchronized)
|
|
14
|
-
* {@link ClientState} as an array of {@link
|
|
15
|
-
* corresponding to those IDs.
|
|
14
|
+
* {@link ClientState} as an array of {@link FormNodeID}s, back to the node
|
|
15
|
+
* objects corresponding to those IDs.
|
|
16
16
|
*
|
|
17
17
|
* @see {@link createChildrenState} for further detail.
|
|
18
18
|
*/
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NamespaceDeclarationMap } from './names/NamespaceDeclarationMap.ts';
|
|
2
|
+
import { QualifiedName } from './names/QualifiedName.ts';
|
|
3
|
+
declare const ESCAPED_XML_TEXT_BRAND: unique symbol;
|
|
4
|
+
export type EscapedXMLText = string & {
|
|
5
|
+
readonly [ESCAPED_XML_TEXT_BRAND]: true;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* This is based on the `escapeHTML` implementation in
|
|
9
|
+
* {@link https://github.com/ryansolid/dom-expressions} (Solid's JSX transform).
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://github.com/ryansolid/dom-expressions/pull/27} for
|
|
12
|
+
* motivation to derive this implementation approach.
|
|
13
|
+
*
|
|
14
|
+
* The intent is that this can be updated easily if the base implementation
|
|
15
|
+
* changes. As such, some aspects of this implementation differ from some of our
|
|
16
|
+
* typical code style preferences.
|
|
17
|
+
*
|
|
18
|
+
* Notable changes from the base implementation:
|
|
19
|
+
*
|
|
20
|
+
* - Formatting: automated only.
|
|
21
|
+
* - Naming: the {@link text} parameter is named `html` in the base
|
|
22
|
+
* implementation. That would be confusing if preserved.
|
|
23
|
+
* - Types:
|
|
24
|
+
* - Parameter types are added (of course)
|
|
25
|
+
* - Return type is branded as {@link EscapedXMLText}, to allow downstream
|
|
26
|
+
* checks that escaping has been performed. Return statements are cast
|
|
27
|
+
* accordingly.
|
|
28
|
+
* - {@link text} attempts to minimize risk of double-escaping by excluding
|
|
29
|
+
* that same branded type.
|
|
30
|
+
* - The '>' character is also escaped, necessary for producing valid XML.
|
|
31
|
+
*
|
|
32
|
+
* As with the base implementation, we leave some characters unescaped:
|
|
33
|
+
*
|
|
34
|
+
* - " (double quote): except when {@link attr} is `true`.
|
|
35
|
+
*
|
|
36
|
+
* - ' (single quote): on the assumption that attributes are always serialized
|
|
37
|
+
* in double quotes. If we ever move this to `@getodk/common`, we'd want to
|
|
38
|
+
* reconsider this assumption.
|
|
39
|
+
*/
|
|
40
|
+
export declare const escapeXMLText: <Text extends string>(text: Exclude<Text, EscapedXMLText>, attr?: boolean) => EscapedXMLText;
|
|
41
|
+
interface SerializableElementAttribute {
|
|
42
|
+
serializeAttributeXML(): string;
|
|
43
|
+
}
|
|
44
|
+
interface ElementXMLSerializationOptions {
|
|
45
|
+
readonly namespaceDeclarations?: NamespaceDeclarationMap;
|
|
46
|
+
readonly attributes?: readonly SerializableElementAttribute[];
|
|
47
|
+
}
|
|
48
|
+
export declare const serializeParentElementXML: (qualifiedName: QualifiedName, serializedChildren: readonly string[], options?: ElementXMLSerializationOptions) => string;
|
|
49
|
+
export declare const serializeLeafElementXML: (qualifiedName: QualifiedName, xmlValue: EscapedXMLText, options?: ElementXMLSerializationOptions) => string;
|
|
50
|
+
export {};
|
package/dist/parse/XFormDOM.d.ts
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface
|
|
1
|
+
import { KnownAttributeLocalNamedElement } from '../../../common/types/dom.ts';
|
|
2
|
+
interface DOMBindElement extends KnownAttributeLocalNamedElement<'bind', 'nodeset'> {
|
|
3
|
+
}
|
|
4
|
+
export interface DOMItextTranslationElement extends KnownAttributeLocalNamedElement<'translation', 'lang'> {
|
|
5
|
+
}
|
|
6
|
+
export interface DOMSecondaryInstanceElement extends KnownAttributeLocalNamedElement<'instance', 'id'> {
|
|
7
|
+
}
|
|
8
|
+
interface XFormDOMOptions {
|
|
3
9
|
readonly isNormalized: boolean;
|
|
4
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @todo **Everything** in this class should be cacheable. Maybe not worth it
|
|
13
|
+
* for small forms, but may make a pretty substantial difference for very large
|
|
14
|
+
* forms (in bytes) in sessions creating multiple instances of the same form.
|
|
15
|
+
*/
|
|
5
16
|
export declare class XFormDOM {
|
|
6
17
|
protected readonly sourceXML: string;
|
|
7
18
|
static from(sourceXML: string): XFormDOM;
|
|
8
19
|
protected readonly normalizedXML: string;
|
|
9
|
-
readonly rootEvaluator: XFormsXPathEvaluator;
|
|
10
|
-
readonly primaryInstanceEvaluator: XFormsXPathEvaluator;
|
|
11
20
|
readonly xformDocument: XMLDocument;
|
|
12
21
|
readonly html: Element;
|
|
13
22
|
readonly head: Element;
|
|
14
23
|
readonly title: Element;
|
|
15
24
|
readonly model: Element;
|
|
25
|
+
readonly binds: readonly DOMBindElement[];
|
|
16
26
|
readonly primaryInstance: Element;
|
|
17
27
|
readonly primaryInstanceRoot: Element;
|
|
28
|
+
readonly itextTranslationElements: readonly DOMItextTranslationElement[];
|
|
29
|
+
readonly secondaryInstanceElements: readonly DOMSecondaryInstanceElement[];
|
|
18
30
|
readonly body: Element;
|
|
19
|
-
protected constructor(sourceXML: string, options:
|
|
20
|
-
|
|
21
|
-
toJSON(): Omit<this, "head" | "html" | "title" | "toJSON" | "model" | "primaryInstanceRoot" | "xformDocument" | "rootEvaluator" | "primaryInstanceEvaluator" | "primaryInstance" | "createInstance"> & {
|
|
31
|
+
protected constructor(sourceXML: string, options: XFormDOMOptions);
|
|
32
|
+
toJSON(): Omit<this, "head" | "html" | "title" | "primaryInstance" | "model" | "primaryInstanceRoot" | "xformDocument" | "toJSON"> & {
|
|
22
33
|
xformDocument: string;
|
|
23
34
|
html: string;
|
|
24
35
|
head: string;
|
|
@@ -2,7 +2,6 @@ import { BodyDefinition } from '../parse/body/BodyDefinition.ts';
|
|
|
2
2
|
import { ModelDefinition } from './model/ModelDefinition.ts';
|
|
3
3
|
import { XFormDOM } from './XFormDOM.ts';
|
|
4
4
|
export declare class XFormDefinition {
|
|
5
|
-
readonly sourceXML: string;
|
|
6
5
|
readonly xformDOM: XFormDOM;
|
|
7
6
|
readonly xformDocument: XMLDocument;
|
|
8
7
|
readonly id: string;
|
|
@@ -10,5 +9,5 @@ export declare class XFormDefinition {
|
|
|
10
9
|
readonly rootReference: string;
|
|
11
10
|
readonly body: BodyDefinition;
|
|
12
11
|
readonly model: ModelDefinition;
|
|
13
|
-
constructor(
|
|
12
|
+
constructor(xformDOM: XFormDOM);
|
|
14
13
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { JRResourceURL } from '../../../../common/src/jr-resources/JRResourceURL.ts';
|
|
2
|
+
export type FormAttachmentDataType = 'media' | 'secondary-instance';
|
|
3
|
+
/**
|
|
4
|
+
* @todo This type anticipates work to support media form attachments, which
|
|
5
|
+
* will tend to be associated with binary data. The
|
|
6
|
+
* expectation is that:
|
|
7
|
+
*
|
|
8
|
+
* - {@link Blob} would be appropriate for representing data from attachment
|
|
9
|
+
* resources which are conventionally loaded to completion (where network
|
|
10
|
+
* conditions are favorable), such as images
|
|
11
|
+
*
|
|
12
|
+
* - {@link MediaSource} or {@link ReadableStream} may be more appropriate for
|
|
13
|
+
* representing data from resources which are conventionally streamed in a
|
|
14
|
+
* browser context (often regardless of network conditions), such as video and
|
|
15
|
+
* audio
|
|
16
|
+
*/
|
|
17
|
+
export type FormAttachmentMediaData = Blob | MediaSource | ReadableStream<unknown>;
|
|
18
|
+
export type FormAttachmentSecondaryInstanceData = string;
|
|
19
|
+
type FormAttachmentData<DataType extends FormAttachmentDataType> = DataType extends 'media' ? FormAttachmentMediaData : FormAttachmentSecondaryInstanceData;
|
|
20
|
+
export declare abstract class FormAttachmentResource<DataType extends FormAttachmentDataType> {
|
|
21
|
+
readonly dataType: DataType;
|
|
22
|
+
readonly resourceURL: JRResourceURL;
|
|
23
|
+
readonly contentType: string;
|
|
24
|
+
readonly data: FormAttachmentData<DataType>;
|
|
25
|
+
protected constructor(dataType: DataType, resourceURL: JRResourceURL, contentType: string, data: FormAttachmentData<DataType>);
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ParsedTokenList, TokenListParser } from '../../lib/TokenListParser.ts';
|
|
2
2
|
import { XFormDefinition } from '../../parse/XFormDefinition.ts';
|
|
3
3
|
import { DependencyContext } from '../expression/abstract/DependencyContext.ts';
|
|
4
|
-
import {
|
|
4
|
+
import { InputControlDefinition } from './control/InputControlDefinition.ts';
|
|
5
5
|
import { RangeControlDefinition } from './control/RangeControlDefinition.ts';
|
|
6
6
|
import { RankControlDefinition } from './control/RankControlDefinition.ts';
|
|
7
|
-
import {
|
|
7
|
+
import { AnySelectControlDefinition } from './control/SelectControlDefinition.ts';
|
|
8
8
|
import { TriggerControlDefinition } from './control/TriggerControlDefinition.ts';
|
|
9
9
|
import { UploadControlDefinition } from './control/UploadControlDefinition.ts';
|
|
10
10
|
import { LogicalGroupDefinition } from './group/LogicalGroupDefinition.ts';
|
|
@@ -17,7 +17,7 @@ export interface BodyElementParentContext {
|
|
|
17
17
|
readonly reference: string | null;
|
|
18
18
|
readonly element: Element;
|
|
19
19
|
}
|
|
20
|
-
export type ControlElementDefinition =
|
|
20
|
+
export type ControlElementDefinition = AnySelectControlDefinition | InputControlDefinition | RangeControlDefinition | RankControlDefinition | TriggerControlDefinition | UploadControlDefinition;
|
|
21
21
|
type SupportedBodyElementDefinition = RepeatElementDefinition | LogicalGroupDefinition | PresentationGroupDefinition | StructuralGroupDefinition | ControlElementDefinition;
|
|
22
22
|
export type AnyBodyElementDefinition = SupportedBodyElementDefinition | UnsupportedBodyElementDefinition;
|
|
23
23
|
export type BodyElementDefinitionArray = readonly AnyBodyElementDefinition[];
|
|
@@ -70,6 +70,6 @@ export declare class BodyDefinition extends DependencyContext implements BodyEle
|
|
|
70
70
|
constructor(form: XFormDefinition);
|
|
71
71
|
getBodyElement(reference: string): AnyBodyElementDefinition | null;
|
|
72
72
|
getChildElementDefinitions(form: XFormDefinition, parent: BodyElementParentContext, parentElement: Element, children?: readonly Element[]): readonly AnyBodyElementDefinition[];
|
|
73
|
-
toJSON(): Omit<this, "form" | "
|
|
73
|
+
toJSON(): Omit<this, "form" | "toJSON" | "isTranslated" | "getBodyElement" | "getChildElementDefinitions">;
|
|
74
74
|
}
|
|
75
75
|
export {};
|
|
@@ -14,5 +14,5 @@ export declare class RepeatElementDefinition extends BodyElementDefinition<'repe
|
|
|
14
14
|
readonly noAddRemoveExpression: string | null;
|
|
15
15
|
readonly children: BodyElementDefinitionArray;
|
|
16
16
|
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
|
|
17
|
-
toJSON(): Omit<this, "parent" | "form" | "
|
|
17
|
+
toJSON(): Omit<this, "parent" | "form" | "toJSON" | "isTranslated">;
|
|
18
18
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TokenListParser, ParsedTokenList } from '../../../lib/TokenListParser.ts';
|
|
2
|
-
export declare const inputAppearanceParser: TokenListParser<"multiline" | "numbers" | "url" | "
|
|
2
|
+
export declare const inputAppearanceParser: TokenListParser<"multiline" | "numbers" | "url" | "thousands-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked", "multiline" | "numbers" | "url" | "thousands-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked">;
|
|
3
3
|
export type InputAppearanceDefinition = ParsedTokenList<typeof inputAppearanceParser>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ParsedTokenList, TokenListParser } from '../../../lib/TokenListParser.ts';
|
|
2
|
+
export declare const rangeAppearanceParser: TokenListParser<"no-ticks" | "picker" | "rating" | "vertical", "no-ticks" | "picker" | "rating" | "vertical">;
|
|
3
|
+
export type RangeAppearanceDefinition = ParsedTokenList<typeof rangeAppearanceParser>;
|
|
@@ -2,9 +2,12 @@ import { XFormDefinition } from '../../XFormDefinition.ts';
|
|
|
2
2
|
import { InputAppearanceDefinition } from '../appearance/inputAppearanceParser.ts';
|
|
3
3
|
import { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
4
4
|
import { ControlDefinition } from './ControlDefinition.ts';
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class InputControlDefinition extends ControlDefinition<'input'> {
|
|
6
6
|
static isCompatible(localName: string): boolean;
|
|
7
7
|
readonly type = "input";
|
|
8
8
|
readonly appearances: InputAppearanceDefinition;
|
|
9
|
+
readonly rows: number | null;
|
|
10
|
+
readonly accuracyThreshold: number | null;
|
|
11
|
+
readonly unacceptableAccuracyThreshold: number | null;
|
|
9
12
|
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
|
|
10
13
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ItemElement } from '../../../lib/dom/query.ts';
|
|
2
|
+
import { ItemLabelDefinition } from '../../text/ItemLabelDefinition.ts';
|
|
3
|
+
import { XFormDefinition } from '../../XFormDefinition.ts';
|
|
4
|
+
import { BodyElementDefinition } from '../BodyElementDefinition.ts';
|
|
5
|
+
import { AnySelectControlDefinition } from './SelectControlDefinition.ts';
|
|
6
|
+
import { RankControlDefinition } from './RankControlDefinition.ts';
|
|
7
|
+
export declare class ItemDefinition extends BodyElementDefinition<'item'> {
|
|
8
|
+
readonly parent: AnySelectControlDefinition | RankControlDefinition;
|
|
9
|
+
readonly category = "support";
|
|
10
|
+
readonly type = "item";
|
|
11
|
+
readonly label: ItemLabelDefinition | null;
|
|
12
|
+
readonly value: string;
|
|
13
|
+
constructor(form: XFormDefinition, parent: AnySelectControlDefinition | RankControlDefinition, element: ItemElement);
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ItemsetElement } from '../../../lib/dom/query.ts';
|
|
2
|
+
import { ItemsetNodesetExpression } from '../../expression/ItemsetNodesetExpression.ts';
|
|
3
|
+
import { ItemsetValueExpression } from '../../expression/ItemsetValueExpression.ts';
|
|
4
|
+
import { ItemsetLabelDefinition } from '../../text/ItemsetLabelDefinition.ts';
|
|
5
|
+
import { XFormDefinition } from '../../XFormDefinition.ts';
|
|
6
|
+
import { BodyElementDefinition } from '../BodyElementDefinition.ts';
|
|
7
|
+
import { AnySelectControlDefinition } from './SelectControlDefinition.ts';
|
|
8
|
+
import { RankControlDefinition } from './RankControlDefinition.ts';
|
|
9
|
+
export declare class ItemsetDefinition extends BodyElementDefinition<'itemset'> {
|
|
10
|
+
readonly parent: AnySelectControlDefinition | RankControlDefinition;
|
|
11
|
+
readonly category = "support";
|
|
12
|
+
readonly type = "itemset";
|
|
13
|
+
readonly reference: string;
|
|
14
|
+
readonly label: ItemsetLabelDefinition | null;
|
|
15
|
+
readonly nodes: ItemsetNodesetExpression;
|
|
16
|
+
readonly value: ItemsetValueExpression;
|
|
17
|
+
constructor(form: XFormDefinition, parent: AnySelectControlDefinition | RankControlDefinition, element: ItemsetElement);
|
|
18
|
+
}
|
|
@@ -1,11 +1,40 @@
|
|
|
1
1
|
import { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
|
-
import {
|
|
2
|
+
import { RangeAppearanceDefinition } from '../appearance/rangeAppearanceParser.ts';
|
|
3
3
|
import { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
4
4
|
import { ControlDefinition } from './ControlDefinition.ts';
|
|
5
|
+
type NumericString = `${number}`;
|
|
6
|
+
/**
|
|
7
|
+
* Per
|
|
8
|
+
* {@link https://getodk.github.io/xforms-spec/#body-elements | ODK XForms spec},
|
|
9
|
+
* the following attributes are required:
|
|
10
|
+
*
|
|
11
|
+
* - `start`
|
|
12
|
+
* - `end`
|
|
13
|
+
* - `step`
|
|
14
|
+
*
|
|
15
|
+
* While we also know that a `<range>` control is expected to have a bind type
|
|
16
|
+
* of either `decimal` or `int`, at this parsing stage we do not yet know which
|
|
17
|
+
* type is associated with the control. So we parse the attributes as strings,
|
|
18
|
+
* checking only that they appear to be numeric values. We also preserve the
|
|
19
|
+
* attributes' names here, for consistency with the spec.
|
|
20
|
+
*
|
|
21
|
+
* Downstream, we parse these to their appropriate numeric runtime types, and
|
|
22
|
+
* alias them to their more conventional names (i.e. "start" -> "min", "end" ->
|
|
23
|
+
* "max").
|
|
24
|
+
*/
|
|
25
|
+
export declare class RangeControlBoundsDefinition {
|
|
26
|
+
readonly start: NumericString;
|
|
27
|
+
readonly end: NumericString;
|
|
28
|
+
readonly step: NumericString;
|
|
29
|
+
static from(element: Element): RangeControlBoundsDefinition;
|
|
30
|
+
constructor(start: NumericString, end: NumericString, step: NumericString);
|
|
31
|
+
}
|
|
5
32
|
export declare class RangeControlDefinition extends ControlDefinition<'range'> {
|
|
6
33
|
static isCompatible(localName: string): boolean;
|
|
7
34
|
readonly type = "range";
|
|
8
|
-
readonly appearances:
|
|
35
|
+
readonly appearances: RangeAppearanceDefinition;
|
|
36
|
+
readonly bounds: RangeControlBoundsDefinition;
|
|
9
37
|
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
|
|
10
38
|
toJSON(): object;
|
|
11
39
|
}
|
|
40
|
+
export {};
|