@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,126 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
XPathAttributeKind,
|
|
3
|
+
XPathCommentKind,
|
|
4
|
+
XPathDocumentKind,
|
|
5
|
+
XPathElementKind,
|
|
6
|
+
XPathTextKind,
|
|
7
|
+
} from '@getodk/xpath';
|
|
8
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
9
|
+
|
|
10
|
+
const XFORMS_XPATH_NODE_RANGE_BRAND = Symbol('XFORMS_XPATH_NODE_RANGE_BRAND');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* To be used with any engine representation of a "range" of contiguous child
|
|
14
|
+
* nodes (also somewhat analogous to a DOM "fragment"). This mapping is
|
|
15
|
+
* conceptually disjoint, but serves an important purpose:
|
|
16
|
+
*
|
|
17
|
+
* - While such a "range" may increase the hierarchical depth of an
|
|
18
|
+
* engine-internal representation, it **DOES NOT** contribute the same
|
|
19
|
+
* hierarchy in XPath evaluation semantics.
|
|
20
|
+
* - Such a "range" may be treated as a distinct context node for evaluating an
|
|
21
|
+
* expression. This most cleanly maps to XPath's comment semantics in that it
|
|
22
|
+
* allows the "range" to have a clear document position (hierarchically a
|
|
23
|
+
* child of its parent element; sequentially a sibling to that parent's other
|
|
24
|
+
* child nodes).
|
|
25
|
+
*
|
|
26
|
+
* (Note: while this is phrased as an abstract concept, it is intended to
|
|
27
|
+
* correspond directly to the engine's "repeat range" concept. The specific type
|
|
28
|
+
* is not referenced here because they have an inverse relationship in the
|
|
29
|
+
* module/type graph.)
|
|
30
|
+
*/
|
|
31
|
+
// prettier-ignore
|
|
32
|
+
export type XFormsXPathNodeRangeKind =
|
|
33
|
+
& 'comment'
|
|
34
|
+
& { readonly [XFORMS_XPATH_NODE_RANGE_BRAND]: true };
|
|
35
|
+
|
|
36
|
+
export const XFORMS_XPATH_NODE_RANGE_KIND = 'comment' as XFormsXPathNodeRangeKind;
|
|
37
|
+
|
|
38
|
+
// prettier-ignore
|
|
39
|
+
export type XFormsXPathNodeKind =
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
41
|
+
| XPathDocumentKind
|
|
42
|
+
| XFormsXPathNodeRangeKind
|
|
43
|
+
| XPathElementKind
|
|
44
|
+
| XPathAttributeKind
|
|
45
|
+
| XPathTextKind
|
|
46
|
+
| XPathCommentKind;
|
|
47
|
+
|
|
48
|
+
export interface XFormsXPathNode {
|
|
49
|
+
readonly [XPathNodeKindKey]: XFormsXPathNodeKind;
|
|
50
|
+
readonly rootDocument: XFormsXPathDocument;
|
|
51
|
+
readonly root: XFormsXPathElement;
|
|
52
|
+
|
|
53
|
+
getXPathChildNodes(this: XFormsXPathNode): readonly XFormsXPathDescendantNode[];
|
|
54
|
+
getXPathValue(this: XFormsXPathNode): string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface XFormsXPathDocument extends XFormsXPathNode {
|
|
58
|
+
readonly [XPathNodeKindKey]: XPathDocumentKind;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface XFormsXPathElement extends XFormsXPathNode {
|
|
62
|
+
readonly [XPathNodeKindKey]: XPathElementKind;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @see {@link XFormsXPathNodeRangeKind}
|
|
67
|
+
*/
|
|
68
|
+
export interface XFormsXPathNodeRange extends XFormsXPathNode {
|
|
69
|
+
readonly [XPathNodeKindKey]: XFormsXPathNodeRangeKind;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface XFormsXPathAttribute extends XFormsXPathNode {
|
|
73
|
+
readonly [XPathNodeKindKey]: XPathAttributeKind;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface XFormsXPathText extends XFormsXPathNode {
|
|
77
|
+
readonly [XPathNodeKindKey]: XPathTextKind;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface XFormsXPathComment extends XFormsXPathNode {
|
|
81
|
+
readonly [XPathNodeKindKey]: XPathCommentKind;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// prettier-ignore
|
|
85
|
+
export type XPathNamedNodeKind =
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
87
|
+
| XPathElementKind
|
|
88
|
+
| XPathAttributeKind;
|
|
89
|
+
|
|
90
|
+
export interface XFormsXPathNamedNode extends XFormsXPathNode {
|
|
91
|
+
readonly [XPathNodeKindKey]: XPathNamedNodeKind;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// prettier-ignore
|
|
95
|
+
export type XFormsXPathDescendantNodeKind =
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
97
|
+
| XFormsXPathNodeRangeKind
|
|
98
|
+
| XPathElementKind
|
|
99
|
+
| XPathTextKind
|
|
100
|
+
| XPathCommentKind;
|
|
101
|
+
|
|
102
|
+
export interface XFormsXPathDescendantNode extends XFormsXPathNode {
|
|
103
|
+
readonly [XPathNodeKindKey]: XFormsXPathDescendantNodeKind;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// prettier-ignore
|
|
107
|
+
export type XFormsXPathPrimaryInstanceNodeKind =
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
109
|
+
| XPathDocumentKind
|
|
110
|
+
| XFormsXPathNodeRangeKind
|
|
111
|
+
| XPathElementKind
|
|
112
|
+
| XPathTextKind;
|
|
113
|
+
|
|
114
|
+
export interface XFormsXPathPrimaryInstanceNode extends XFormsXPathNode {
|
|
115
|
+
readonly [XPathNodeKindKey]: XFormsXPathPrimaryInstanceNodeKind;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// prettier-ignore
|
|
119
|
+
export type XFormsXPathPrimaryInstanceDescendantNodeKind =
|
|
120
|
+
| XFormsXPathNodeRangeKind
|
|
121
|
+
| XPathElementKind
|
|
122
|
+
| XPathTextKind;
|
|
123
|
+
|
|
124
|
+
export interface XFormsXPathPrimaryInstanceDescendantNode extends XFormsXPathNode {
|
|
125
|
+
readonly [XPathNodeKindKey]: XFormsXPathPrimaryInstanceDescendantNodeKind;
|
|
126
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { XPathDOMAdapter } from '@getodk/xpath';
|
|
2
|
+
import type { EngineXPathNode } from './kind.ts';
|
|
3
|
+
import { getEngineXPathNodeKind, isEngineXPathNode } from './kind.ts';
|
|
4
|
+
import {
|
|
5
|
+
getEngineProcessingInstructionName,
|
|
6
|
+
getEngineXPathNodeLocalName,
|
|
7
|
+
getEngineXPathNodeNamespaceURI,
|
|
8
|
+
getEngineXPathNodeQualifiedName,
|
|
9
|
+
resolveEngineXPathNodeNamespaceURI,
|
|
10
|
+
} from './names.ts';
|
|
11
|
+
import {
|
|
12
|
+
compareDocumentOrder,
|
|
13
|
+
getChildElements,
|
|
14
|
+
getChildNodes,
|
|
15
|
+
getContainingEngineXPathDocument,
|
|
16
|
+
getEngineXPathAttributes,
|
|
17
|
+
getNamespaceDeclarations,
|
|
18
|
+
getNextSiblingElement,
|
|
19
|
+
getNextSiblingNode,
|
|
20
|
+
getParentNode,
|
|
21
|
+
getPreviousSiblingElement,
|
|
22
|
+
getPreviousSiblingNode,
|
|
23
|
+
isDescendantNode,
|
|
24
|
+
} from './traversal.ts';
|
|
25
|
+
import { getEngineXPathNodeValue } from './values.ts';
|
|
26
|
+
|
|
27
|
+
export interface EngineDOMAdapter extends XPathDOMAdapter<EngineXPathNode> {}
|
|
28
|
+
|
|
29
|
+
export const engineDOMAdapter: EngineDOMAdapter = {
|
|
30
|
+
// XPathNodeKindAdapter
|
|
31
|
+
getNodeKind: getEngineXPathNodeKind,
|
|
32
|
+
isXPathNode: isEngineXPathNode,
|
|
33
|
+
|
|
34
|
+
// XPathNameAdapter
|
|
35
|
+
getLocalName: getEngineXPathNodeLocalName,
|
|
36
|
+
getNamespaceURI: getEngineXPathNodeNamespaceURI,
|
|
37
|
+
getQualifiedName: getEngineXPathNodeQualifiedName,
|
|
38
|
+
getProcessingInstructionName: getEngineProcessingInstructionName,
|
|
39
|
+
resolveNamespaceURI: resolveEngineXPathNodeNamespaceURI,
|
|
40
|
+
|
|
41
|
+
// XPathValueAdapter
|
|
42
|
+
getNodeValue: getEngineXPathNodeValue,
|
|
43
|
+
|
|
44
|
+
// XPathTraversalAdapter
|
|
45
|
+
compareDocumentOrder,
|
|
46
|
+
getAttributes: getEngineXPathAttributes,
|
|
47
|
+
getChildElements: getChildElements,
|
|
48
|
+
getChildNodes: getChildNodes,
|
|
49
|
+
getContainingDocument: getContainingEngineXPathDocument,
|
|
50
|
+
getNamespaceDeclarations: getNamespaceDeclarations,
|
|
51
|
+
getNextSiblingElement: getNextSiblingElement,
|
|
52
|
+
getNextSiblingNode: getNextSiblingNode,
|
|
53
|
+
getParentNode: getParentNode,
|
|
54
|
+
getPreviousSiblingElement: getPreviousSiblingElement,
|
|
55
|
+
getPreviousSiblingNode: getPreviousSiblingNode,
|
|
56
|
+
isDescendantNode: isDescendantNode,
|
|
57
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { XPathNodeKind } from '@getodk/xpath';
|
|
2
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
3
|
+
import type {
|
|
4
|
+
AnyChildNode,
|
|
5
|
+
AnyNode,
|
|
6
|
+
AnyParentNode,
|
|
7
|
+
AnyValueNode,
|
|
8
|
+
} from '../../../instance/hierarchy.ts';
|
|
9
|
+
import type { ValueContext } from '../../../instance/internal-api/ValueContext.ts';
|
|
10
|
+
import type { PrimaryInstance } from '../../../instance/PrimaryInstance.ts';
|
|
11
|
+
import type { ItextTranslationDefinition } from '../../../parse/model/ItextTranslation/ItextTranslationDefinition.ts';
|
|
12
|
+
import type { ItextTranslationRootDefinition } from '../../../parse/model/ItextTranslation/ItextTranslationRootDefinition.ts';
|
|
13
|
+
import type { SecondaryInstanceDefinition } from '../../../parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts';
|
|
14
|
+
import type { SecondaryInstanceRootDefinition } from '../../../parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts';
|
|
15
|
+
import type { StaticAttribute } from '../static-dom/StaticAttribute.ts';
|
|
16
|
+
import type { StaticDocument } from '../static-dom/StaticDocument.ts';
|
|
17
|
+
import type { StaticElement } from '../static-dom/StaticElement.ts';
|
|
18
|
+
import type { StaticText } from '../static-dom/StaticText.ts';
|
|
19
|
+
import type {
|
|
20
|
+
XFormsXPathComment,
|
|
21
|
+
XFormsXPathDocument,
|
|
22
|
+
XFormsXPathElement,
|
|
23
|
+
XFormsXPathPrimaryInstanceNode,
|
|
24
|
+
} from './XFormsXPathNode.ts';
|
|
25
|
+
|
|
26
|
+
export type PrimaryInstanceXPathNode = Extract<AnyNode, XFormsXPathPrimaryInstanceNode>;
|
|
27
|
+
|
|
28
|
+
export type PrimaryInstanceXPathElement = Extract<AnyChildNode, XFormsXPathElement>;
|
|
29
|
+
|
|
30
|
+
export type PrimaryInstanceXPathComment = Extract<AnyChildNode, XFormsXPathComment>;
|
|
31
|
+
|
|
32
|
+
// prettier-ignore
|
|
33
|
+
export type PrimaryInstanceXPathChildNode =
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
35
|
+
| PrimaryInstanceXPathElement
|
|
36
|
+
| PrimaryInstanceXPathComment;
|
|
37
|
+
|
|
38
|
+
// prettier-ignore
|
|
39
|
+
export type PrimaryInstanceXPathValueElement<Value> =
|
|
40
|
+
& AnyValueNode
|
|
41
|
+
& ValueContext<Value>
|
|
42
|
+
& XFormsXPathElement;
|
|
43
|
+
|
|
44
|
+
// prettier-ignore
|
|
45
|
+
export type EngineXPathDocument =
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
47
|
+
| PrimaryInstance
|
|
48
|
+
| ItextTranslationDefinition
|
|
49
|
+
| SecondaryInstanceDefinition
|
|
50
|
+
| StaticDocument;
|
|
51
|
+
|
|
52
|
+
// prettier-ignore
|
|
53
|
+
export type EngineXPathElement =
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
55
|
+
| PrimaryInstanceXPathElement
|
|
56
|
+
| ItextTranslationRootDefinition
|
|
57
|
+
| SecondaryInstanceRootDefinition
|
|
58
|
+
| StaticElement;
|
|
59
|
+
|
|
60
|
+
// prettier-ignore
|
|
61
|
+
export type EngineXPathComment =
|
|
62
|
+
| PrimaryInstanceXPathComment;
|
|
63
|
+
|
|
64
|
+
// Giving this a type alias anticipates eventually implementing attributes
|
|
65
|
+
// in primary instance state as well
|
|
66
|
+
export type EngineXPathAttribute = StaticAttribute;
|
|
67
|
+
|
|
68
|
+
export type EngineXPathText = StaticText;
|
|
69
|
+
|
|
70
|
+
// prettier-ignore
|
|
71
|
+
export type XFormsXPathChildNode =
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
73
|
+
| EngineXPathElement
|
|
74
|
+
| EngineXPathText
|
|
75
|
+
| EngineXPathComment;
|
|
76
|
+
|
|
77
|
+
// prettier-ignore
|
|
78
|
+
type XPathAdapterParentNode =
|
|
79
|
+
| XFormsXPathDocument
|
|
80
|
+
| XFormsXPathElement;
|
|
81
|
+
|
|
82
|
+
type PrimaryInstanceXPathParentNode = Extract<AnyParentNode, XPathAdapterParentNode>;
|
|
83
|
+
|
|
84
|
+
// prettier-ignore
|
|
85
|
+
export type EngineXPathParentNode =
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
87
|
+
| PrimaryInstanceXPathParentNode
|
|
88
|
+
| ItextTranslationDefinition
|
|
89
|
+
| SecondaryInstanceDefinition
|
|
90
|
+
| ItextTranslationRootDefinition
|
|
91
|
+
| SecondaryInstanceRootDefinition
|
|
92
|
+
| StaticDocument
|
|
93
|
+
| StaticElement;
|
|
94
|
+
|
|
95
|
+
// prettier-ignore
|
|
96
|
+
export type EngineXPathNode =
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
98
|
+
| EngineXPathDocument
|
|
99
|
+
| EngineXPathElement
|
|
100
|
+
| EngineXPathAttribute
|
|
101
|
+
| EngineXPathText
|
|
102
|
+
| EngineXPathComment;
|
|
103
|
+
|
|
104
|
+
export const isEngineXPathNode = (value: unknown): value is EngineXPathNode => {
|
|
105
|
+
return typeof value === 'object' && value != null && XPathNodeKindKey in value;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const getEngineXPathNodeKind = (node: EngineXPathNode): XPathNodeKind => {
|
|
109
|
+
return node[XPathNodeKindKey];
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const isEngineXPathElement = (node: EngineXPathNode): node is EngineXPathElement => {
|
|
113
|
+
return getEngineXPathNodeKind(node) === 'element';
|
|
114
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ENKETO_NAMESPACE_URI,
|
|
3
|
+
ENKETO_PREFIX,
|
|
4
|
+
FN_NAMESPACE_URI,
|
|
5
|
+
FN_PREFIX,
|
|
6
|
+
HTML_PREFIX,
|
|
7
|
+
JAVAROSA_NAMESPACE_URI,
|
|
8
|
+
JAVAROSA_PREFIX,
|
|
9
|
+
ODK_NAMESPACE_URI,
|
|
10
|
+
ODK_PREFIX,
|
|
11
|
+
OPENROSA_XFORMS_NAMESPACE_URI,
|
|
12
|
+
OPENROSA_XFORMS_PREFIX,
|
|
13
|
+
XFORMS_NAMESPACE_URI,
|
|
14
|
+
XFORMS_PREFIX,
|
|
15
|
+
XHTML_NAMESPACE_URI,
|
|
16
|
+
} from '@getodk/common/constants/xmlns.ts';
|
|
17
|
+
import { XPathFunctionalityNotSupportedError } from '../../../error/XPathFunctionalityNotSupportedError.ts';
|
|
18
|
+
import type { AnyStaticNode } from '../static-dom/StaticNode.ts';
|
|
19
|
+
import type { EngineXPathNode } from './kind.ts';
|
|
20
|
+
|
|
21
|
+
export const getEngineXPathNodeNamespaceURI = (node: EngineXPathNode): string | null => {
|
|
22
|
+
switch (node.nodeType) {
|
|
23
|
+
case 'primary-instance':
|
|
24
|
+
case 'static-document':
|
|
25
|
+
case 'static-text':
|
|
26
|
+
case 'repeat-range:controlled':
|
|
27
|
+
case 'repeat-range:uncontrolled':
|
|
28
|
+
return null;
|
|
29
|
+
|
|
30
|
+
case 'static-attribute':
|
|
31
|
+
case 'static-element':
|
|
32
|
+
return node.qualifiedName.namespaceURI?.href ?? null;
|
|
33
|
+
|
|
34
|
+
default:
|
|
35
|
+
return node.definition.qualifiedName.namespaceURI?.href ?? null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const getEngineXPathNodeQualifiedName = (node: EngineXPathNode): string => {
|
|
40
|
+
switch (node.nodeType) {
|
|
41
|
+
case 'static-attribute':
|
|
42
|
+
case 'static-element':
|
|
43
|
+
return node.qualifiedName.getPrefixedName();
|
|
44
|
+
|
|
45
|
+
case 'static-document':
|
|
46
|
+
case 'static-text':
|
|
47
|
+
return '';
|
|
48
|
+
|
|
49
|
+
default:
|
|
50
|
+
return node.definition.qualifiedName.getPrefixedName();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const getEngineXPathNodeLocalName = (node: EngineXPathNode): string => {
|
|
55
|
+
switch (node.nodeType) {
|
|
56
|
+
case 'static-attribute':
|
|
57
|
+
case 'static-element':
|
|
58
|
+
return node.qualifiedName.localName;
|
|
59
|
+
|
|
60
|
+
case 'static-document':
|
|
61
|
+
case 'static-text':
|
|
62
|
+
return '';
|
|
63
|
+
|
|
64
|
+
default:
|
|
65
|
+
return node.definition.qualifiedName.localName;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const getEngineProcessingInstructionName =
|
|
70
|
+
XPathFunctionalityNotSupportedError.createStubImplementation('processing-instruction');
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @todo in most cases we should not have **custom** namespace resolution from a
|
|
74
|
+
* static node (e.g. external secondary instance, itext translation) context.
|
|
75
|
+
* The main exception to that would be _XML external secondary instances_, which
|
|
76
|
+
* of course can declare arbitrary namespaces on any arbitrary subtree, just
|
|
77
|
+
* like a form definition's XML. In all other cases, we'd want to resolve a
|
|
78
|
+
* prefix here from the _primary instance_ context. However, we don't (yet) have
|
|
79
|
+
* access to the primary instance context from a static node. So we currently
|
|
80
|
+
* fall back to the previous (incomplete/potentially wrong) default mapping.
|
|
81
|
+
*
|
|
82
|
+
* Note that this is relatively safe for the general case, and only potentially
|
|
83
|
+
* wrong for:
|
|
84
|
+
*
|
|
85
|
+
* 1. Forms authored as XML, with arbitrary/non-default namespace declarations
|
|
86
|
+
* 2. XML external secondary instances, also with arbitrary/non-default
|
|
87
|
+
* namespace declarations
|
|
88
|
+
*/
|
|
89
|
+
const resolveNamespaceURIFromStaticNodeContext = (_: AnyStaticNode, prefix: string | null) => {
|
|
90
|
+
switch (prefix) {
|
|
91
|
+
case null:
|
|
92
|
+
return XFORMS_NAMESPACE_URI;
|
|
93
|
+
|
|
94
|
+
case ENKETO_PREFIX:
|
|
95
|
+
return ENKETO_NAMESPACE_URI;
|
|
96
|
+
|
|
97
|
+
case FN_PREFIX:
|
|
98
|
+
return FN_NAMESPACE_URI;
|
|
99
|
+
|
|
100
|
+
case HTML_PREFIX:
|
|
101
|
+
return XHTML_NAMESPACE_URI;
|
|
102
|
+
|
|
103
|
+
case JAVAROSA_PREFIX:
|
|
104
|
+
return JAVAROSA_NAMESPACE_URI;
|
|
105
|
+
|
|
106
|
+
case ODK_PREFIX:
|
|
107
|
+
return ODK_NAMESPACE_URI;
|
|
108
|
+
|
|
109
|
+
case OPENROSA_XFORMS_PREFIX:
|
|
110
|
+
return OPENROSA_XFORMS_NAMESPACE_URI;
|
|
111
|
+
|
|
112
|
+
case XFORMS_PREFIX:
|
|
113
|
+
return XFORMS_NAMESPACE_URI;
|
|
114
|
+
|
|
115
|
+
default:
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const resolveEngineXPathNodeNamespaceURI = (
|
|
121
|
+
node: EngineXPathNode,
|
|
122
|
+
prefix: string | null
|
|
123
|
+
): string | null => {
|
|
124
|
+
switch (node.nodeType) {
|
|
125
|
+
case 'static-attribute':
|
|
126
|
+
case 'static-document':
|
|
127
|
+
case 'static-element':
|
|
128
|
+
case 'static-text':
|
|
129
|
+
return resolveNamespaceURIFromStaticNodeContext(node, prefix);
|
|
130
|
+
|
|
131
|
+
case 'group':
|
|
132
|
+
case 'input':
|
|
133
|
+
case 'model-value':
|
|
134
|
+
case 'note':
|
|
135
|
+
case 'primary-instance':
|
|
136
|
+
case 'range':
|
|
137
|
+
case 'rank':
|
|
138
|
+
case 'repeat-instance':
|
|
139
|
+
case 'repeat-range:controlled':
|
|
140
|
+
case 'repeat-range:uncontrolled':
|
|
141
|
+
case 'root':
|
|
142
|
+
case 'select':
|
|
143
|
+
case 'subtree':
|
|
144
|
+
case 'trigger':
|
|
145
|
+
case 'upload':
|
|
146
|
+
return node.definition.namespaceDeclarations.get(prefix)?.declaredURI?.href ?? null;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
2
|
+
import { ErrorProductionDesignPendingError } from '../../../error/ErrorProductionDesignPendingError.ts';
|
|
3
|
+
import { XPathFunctionalityPendingError } from '../../../error/XPathFunctionalityPendingError.ts';
|
|
4
|
+
import type { AnyNode } from '../../../instance/hierarchy.ts';
|
|
5
|
+
import type { AnyStaticNode, StaticParentNode } from '../static-dom/StaticNode.ts';
|
|
6
|
+
import type {
|
|
7
|
+
EngineXPathAttribute,
|
|
8
|
+
EngineXPathDocument,
|
|
9
|
+
EngineXPathElement,
|
|
10
|
+
EngineXPathNode,
|
|
11
|
+
EngineXPathParentNode,
|
|
12
|
+
PrimaryInstanceXPathChildNode,
|
|
13
|
+
XFormsXPathChildNode,
|
|
14
|
+
} from './kind.ts';
|
|
15
|
+
import { isEngineXPathElement } from './kind.ts';
|
|
16
|
+
|
|
17
|
+
export const getContainingEngineXPathDocument = (node: EngineXPathNode): EngineXPathDocument => {
|
|
18
|
+
return node.rootDocument;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const getEngineXPathAttributes = (node: EngineXPathNode): Iterable<EngineXPathAttribute> => {
|
|
22
|
+
if (node.nodeType === 'static-element') {
|
|
23
|
+
return node.attributes;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return [];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @todo We've now laid most of the groundwork necessary to implement this
|
|
31
|
+
* properly. At time of writing it has still been deferred because:
|
|
32
|
+
*
|
|
33
|
+
* 1. The scope of changes enabling it is already a fairly large yak shave.
|
|
34
|
+
* 2. It is only used to support XPath LocationPath Steps whose AxisName is
|
|
35
|
+
* `namespace`. If we _ever_ support this, it would probably be for extremely
|
|
36
|
+
* niche use cases!
|
|
37
|
+
*
|
|
38
|
+
* @todo Since we've consciously deferred implementing this (twice now!), should
|
|
39
|
+
* it throw? It might be nice to be alerted if the assumptions in point 2 above
|
|
40
|
+
* are somehow wrong (or become wrong).
|
|
41
|
+
*/
|
|
42
|
+
export const getNamespaceDeclarations = (): Iterable<never> => [];
|
|
43
|
+
|
|
44
|
+
export const getParentNode = (node: EngineXPathNode): EngineXPathParentNode | null => {
|
|
45
|
+
if (node.nodeType === 'repeat-instance') {
|
|
46
|
+
return node.parent.parent;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return node.parent;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const getChildNodes = (node: EngineXPathNode): readonly XFormsXPathChildNode[] => {
|
|
53
|
+
return node.getXPathChildNodes();
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const getChildElements = (node: EngineXPathNode): readonly EngineXPathElement[] => {
|
|
57
|
+
return getChildNodes(node).filter(isEngineXPathElement);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const getPreviousSiblingNode = (node: EngineXPathNode): XFormsXPathChildNode | null => {
|
|
61
|
+
const parent = getParentNode(node);
|
|
62
|
+
|
|
63
|
+
if (parent == null) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let previous: EngineXPathNode | null = null;
|
|
68
|
+
|
|
69
|
+
for (const child of getChildNodes(parent)) {
|
|
70
|
+
if (child === node) {
|
|
71
|
+
return previous;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
previous = child;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return null;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const getPreviousSiblingElement = (node: EngineXPathNode): EngineXPathElement | null => {
|
|
81
|
+
const parent = getParentNode(node);
|
|
82
|
+
|
|
83
|
+
if (parent == null) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let previous: EngineXPathElement | null = null;
|
|
88
|
+
|
|
89
|
+
for (const child of getChildNodes(parent)) {
|
|
90
|
+
if (child === node) {
|
|
91
|
+
return previous;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (isEngineXPathElement(child)) {
|
|
95
|
+
previous = child;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return null;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const getNextSiblingNode = (node: EngineXPathNode): XFormsXPathChildNode | null => {
|
|
103
|
+
const parent = getParentNode(node);
|
|
104
|
+
|
|
105
|
+
if (parent == null) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let visitedCurrent = false;
|
|
110
|
+
|
|
111
|
+
for (const child of getChildNodes(parent)) {
|
|
112
|
+
if (child === node) {
|
|
113
|
+
visitedCurrent = true;
|
|
114
|
+
} else if (visitedCurrent) {
|
|
115
|
+
return child;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return null;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const getNextSiblingElement = (node: EngineXPathNode): EngineXPathElement | null => {
|
|
123
|
+
const parent = getParentNode(node);
|
|
124
|
+
|
|
125
|
+
if (parent == null) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let visitedCurrent = false;
|
|
130
|
+
|
|
131
|
+
for (const child of getChildNodes(parent)) {
|
|
132
|
+
if (child === node) {
|
|
133
|
+
visitedCurrent = true;
|
|
134
|
+
} else if (visitedCurrent && isEngineXPathElement(child)) {
|
|
135
|
+
return child;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return null;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const isPrimaryInstanceChildNode = (
|
|
143
|
+
node: EngineXPathNode
|
|
144
|
+
): node is PrimaryInstanceXPathChildNode => {
|
|
145
|
+
switch (node.nodeType) {
|
|
146
|
+
case 'primary-instance':
|
|
147
|
+
case 'static-attribute':
|
|
148
|
+
case 'static-element':
|
|
149
|
+
case 'static-text':
|
|
150
|
+
return false;
|
|
151
|
+
|
|
152
|
+
default:
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const primaryInstanceElementContains = (ancestor: AnyNode, other: AnyNode): boolean => {
|
|
158
|
+
if (other === ancestor) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const { parent, root } = other;
|
|
163
|
+
|
|
164
|
+
if (parent == null || parent === root) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return primaryInstanceElementContains(ancestor, parent);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const staticParentNodeContains = (ancestor: StaticParentNode, other: AnyStaticNode): boolean => {
|
|
172
|
+
if (ancestor === other) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const { parent } = other;
|
|
177
|
+
|
|
178
|
+
if (parent == null) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return staticParentNodeContains(ancestor, parent);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export const isDescendantNode = (ancestor: EngineXPathNode, other: EngineXPathNode) => {
|
|
186
|
+
// TODO: "descendant" semantics != "contains" semantics
|
|
187
|
+
if (ancestor === other) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (ancestor.nodeType === 'primary-instance') {
|
|
192
|
+
return isPrimaryInstanceChildNode(other);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (other.nodeType === 'primary-instance') {
|
|
196
|
+
// TODO: in the event this does somehow occur, this is not the kind of error
|
|
197
|
+
// messaging we want to surface to users! It is, however, exactly the kind
|
|
198
|
+
// of messaging we want to surface to us.
|
|
199
|
+
throw new ErrorProductionDesignPendingError(
|
|
200
|
+
'Exhaustive check failed: comparing hierarchy of two primary instance documents. It is unclear how this could ever occur. If it has, something may have gone horribly wrong!'
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (isPrimaryInstanceChildNode(ancestor)) {
|
|
205
|
+
return isPrimaryInstanceChildNode(other) && primaryInstanceElementContains(ancestor, other);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (isPrimaryInstanceChildNode(other)) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
switch (ancestor.nodeType) {
|
|
213
|
+
case 'static-attribute':
|
|
214
|
+
case 'static-text':
|
|
215
|
+
return false;
|
|
216
|
+
|
|
217
|
+
case 'static-document':
|
|
218
|
+
case 'static-element':
|
|
219
|
+
break;
|
|
220
|
+
|
|
221
|
+
default:
|
|
222
|
+
throw new UnreachableError(ancestor);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return staticParentNodeContains(ancestor, other);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export const compareDocumentOrder =
|
|
229
|
+
XPathFunctionalityPendingError.createStubImplementation('compareDocumentOrder');
|