@getodk/xforms-engine 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/BaseNode.d.ts +4 -4
- package/dist/client/BaseValueNode.d.ts +7 -3
- package/dist/client/RootNode.d.ts +20 -16
- package/dist/client/UploadNode.d.ts +53 -0
- package/dist/client/attachments/InstanceAttachmentMeta.d.ts +8 -0
- package/dist/client/attachments/InstanceAttachmentsConfig.d.ts +8 -0
- package/dist/client/constants.d.ts +11 -12
- package/dist/client/form/CreateFormInstance.d.ts +14 -0
- package/dist/client/form/EditFormInstance.d.ts +62 -0
- package/dist/client/form/FormInstance.d.ts +104 -0
- package/dist/client/form/FormInstanceConfig.d.ts +19 -0
- package/dist/client/form/FormResource.d.ts +1 -0
- package/dist/client/form/LoadForm.d.ts +79 -0
- package/dist/client/form/LoadFormResult.d.ts +67 -0
- package/dist/client/form/RestoreFormInstance.d.ts +8 -0
- package/dist/client/hierarchy.d.ts +4 -5
- package/dist/client/index.d.ts +40 -11
- package/dist/client/node-types.d.ts +2 -3
- package/dist/client/repeat/BaseRepeatRangeNode.d.ts +3 -4
- package/dist/client/repeat/RepeatInstanceNode.d.ts +4 -5
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +2 -2
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +2 -2
- package/dist/client/resources.d.ts +1 -1
- package/dist/client/serialization/InstanceData.d.ts +14 -0
- package/dist/client/serialization/InstanceFile.d.ts +6 -0
- package/dist/client/serialization/InstancePayload.d.ts +93 -0
- package/dist/client/serialization/InstancePayloadOptions.d.ts +24 -0
- package/dist/client/serialization/InstanceState.d.ts +12 -0
- package/dist/client/submission/{SubmissionDefinition.d.ts → SubmissionMeta.d.ts} +1 -1
- package/dist/entrypoints/FormInstance.d.ts +20 -0
- package/dist/entrypoints/FormResult/BaseFormResult.d.ts +22 -0
- package/dist/entrypoints/FormResult/BaseInstantiableFormResult.d.ts +25 -0
- package/dist/entrypoints/FormResult/FormFailureResult.d.ts +17 -0
- package/dist/entrypoints/FormResult/FormSuccessResult.d.ts +15 -0
- package/dist/entrypoints/FormResult/FormWarningResult.d.ts +15 -0
- package/dist/entrypoints/createInstance.d.ts +9 -0
- package/dist/entrypoints/editInstance.d.ts +9 -0
- package/dist/entrypoints/index.d.ts +4 -0
- package/dist/entrypoints/loadForm.d.ts +4 -0
- package/dist/entrypoints/restoreInstance.d.ts +9 -0
- package/dist/error/LoadFormFailureError.d.ts +9 -0
- package/dist/error/MalformedInstanceDataError.d.ts +3 -0
- package/dist/error/TemplatedNodeAttributeSerializationError.d.ts +22 -0
- package/dist/error/UploadValueTypeError.d.ts +8 -0
- package/dist/index.d.ts +2 -33
- package/dist/index.js +8280 -6779
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +6 -5
- package/dist/instance/InputControl.d.ts +5 -4
- package/dist/instance/ModelValue.d.ts +5 -4
- package/dist/instance/Note.d.ts +4 -3
- package/dist/instance/PrimaryInstance.d.ts +34 -8
- package/dist/instance/RangeControl.d.ts +5 -4
- package/dist/instance/RankControl.d.ts +6 -5
- package/dist/instance/Root.d.ts +7 -9
- package/dist/instance/SelectControl.d.ts +4 -3
- package/dist/instance/Subtree.d.ts +6 -5
- package/dist/instance/TriggerControl.d.ts +4 -3
- package/dist/instance/UploadControl.d.ts +58 -0
- package/dist/instance/abstract/DescendantNode.d.ts +10 -1
- package/dist/instance/abstract/InstanceNode.d.ts +7 -4
- package/dist/instance/abstract/ValueNode.d.ts +7 -5
- package/dist/instance/attachments/InstanceAttachment.d.ts +42 -0
- package/dist/instance/attachments/InstanceAttachmentsState.d.ts +9 -0
- package/dist/instance/children/DescendantNodeInitOptions.d.ts +32 -0
- package/dist/instance/{children.d.ts → children/buildChildren.d.ts} +1 -1
- package/dist/instance/children/childrenInitOptions.d.ts +9 -0
- package/dist/instance/children/normalizeChildInitOptions.d.ts +2 -0
- package/dist/instance/hierarchy.d.ts +6 -7
- package/dist/instance/input/InitialInstanceState.d.ts +13 -0
- package/dist/instance/input/InstanceAttachmentMap.d.ts +19 -0
- package/dist/instance/internal-api/InstanceAttachmentContext.d.ts +19 -0
- package/dist/instance/internal-api/InstanceConfig.d.ts +4 -9
- package/dist/instance/internal-api/InstanceValueContext.d.ts +8 -1
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableInstance.d.ts +16 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.d.ts +32 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableParentNode.d.ts +18 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.d.ts +13 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableValueNode.d.ts +21 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +10 -8
- package/dist/instance/repeat/RepeatInstance.d.ts +10 -7
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +27 -3
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +4 -3
- package/dist/instance/resource.d.ts +5 -1
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +2 -2
- package/dist/integration/xpath/adapter/kind.d.ts +4 -10
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +4 -5
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +13 -10
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +21 -22
- package/dist/integration/xpath/static-dom/StaticNode.d.ts +1 -1
- package/dist/integration/xpath/static-dom/StaticParentNode.d.ts +13 -0
- package/dist/integration/xpath/static-dom/staticNodeName.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createNodeRangeInstanceState.d.ts +4 -0
- package/dist/lib/client-reactivity/instance-state/createParentNodeInstanceState.d.ts +4 -0
- package/dist/lib/client-reactivity/instance-state/createPrimaryInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createRootInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.d.ts +6 -0
- package/dist/lib/client-reactivity/instance-state/createValueNodeInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/prepareInstancePayload.d.ts +8 -0
- package/dist/lib/names/UnprefixedXFormsName.d.ts +4 -0
- package/dist/lib/reactivity/createInstanceAttachment.d.ts +8 -0
- package/dist/lib/reactivity/createInstanceValueState.d.ts +2 -27
- package/dist/lib/resource-helpers.d.ts +2 -0
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/body/BodyDefinition.d.ts +2 -1
- package/dist/parse/body/control/UploadControlDefinition.d.ts +2 -0
- package/dist/parse/model/BindDefinition.d.ts +1 -1
- package/dist/parse/model/BindTypeDefinition.d.ts +2 -7
- package/dist/parse/model/ItextTranslationsDefinition.d.ts +18 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +4 -5
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/ModelDefinition.d.ts +9 -2
- package/dist/parse/model/NodeDefinition.d.ts +18 -30
- package/dist/parse/model/NoteNodeDefinition.d.ts +3 -2
- package/dist/parse/model/RangeNodeDefinition.d.ts +2 -1
- package/dist/parse/model/RepeatDefinition.d.ts +62 -0
- package/dist/parse/model/RootAttributeDefinition.d.ts +1 -4
- package/dist/parse/model/RootAttributeMap.d.ts +2 -1
- package/dist/parse/model/RootDefinition.d.ts +7 -8
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +15 -2
- package/dist/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/defineSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +1 -7
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/{FormSubmissionDefinition.d.ts → SubmissionDefinition.d.ts} +2 -2
- package/dist/parse/model/SubtreeDefinition.d.ts +4 -5
- package/dist/parse/model/nodeDefinitionMap.d.ts +5 -0
- package/dist/parse/shared/parseInstanceXML.d.ts +21 -0
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +4 -21
- package/dist/solid.js +8251 -6751
- package/dist/solid.js.map +1 -1
- package/package.json +15 -14
- package/src/client/BaseNode.ts +4 -4
- package/src/client/BaseValueNode.ts +7 -3
- package/src/client/RootNode.ts +32 -19
- package/src/client/UploadNode.ts +78 -0
- package/src/client/attachments/InstanceAttachmentMeta.ts +10 -0
- package/src/client/attachments/InstanceAttachmentsConfig.ts +13 -0
- package/src/client/constants.ts +12 -14
- package/src/client/form/CreateFormInstance.ts +19 -0
- package/src/client/form/EditFormInstance.ts +93 -0
- package/src/client/form/FormInstance.ts +114 -0
- package/src/client/form/FormInstanceConfig.ts +21 -0
- package/src/client/form/FormResource.ts +1 -0
- package/src/client/form/LoadForm.ts +92 -0
- package/src/client/form/LoadFormResult.ts +103 -0
- package/src/client/form/RestoreFormInstance.ts +14 -0
- package/src/client/hierarchy.ts +5 -8
- package/src/client/index.ts +49 -29
- package/src/client/node-types.ts +3 -8
- package/src/client/repeat/BaseRepeatRangeNode.ts +3 -4
- package/src/client/repeat/RepeatInstanceNode.ts +4 -8
- package/src/client/repeat/RepeatRangeControlledNode.ts +2 -2
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +2 -2
- package/src/client/resources.ts +2 -2
- package/src/client/serialization/InstanceData.ts +24 -0
- package/src/client/serialization/InstanceFile.ts +9 -0
- package/src/client/serialization/InstancePayload.ts +126 -0
- package/src/client/serialization/InstancePayloadOptions.ts +29 -0
- package/src/client/serialization/InstanceState.ts +14 -0
- package/src/client/submission/{SubmissionDefinition.ts → SubmissionMeta.ts} +1 -1
- package/src/entrypoints/FormInstance.ts +56 -0
- package/src/entrypoints/FormResult/BaseFormResult.ts +40 -0
- package/src/entrypoints/FormResult/BaseInstantiableFormResult.ts +109 -0
- package/src/entrypoints/FormResult/FormFailureResult.ts +44 -0
- package/src/entrypoints/FormResult/FormSuccessResult.ts +25 -0
- package/src/entrypoints/FormResult/FormWarningResult.ts +25 -0
- package/src/entrypoints/createInstance.ts +23 -0
- package/src/entrypoints/editInstance.ts +24 -0
- package/src/entrypoints/index.ts +4 -0
- package/src/entrypoints/loadForm.ts +154 -0
- package/src/entrypoints/restoreInstance.ts +27 -0
- package/src/error/LoadFormFailureError.ts +114 -0
- package/src/error/MalformedInstanceDataError.ts +3 -0
- package/src/error/TemplatedNodeAttributeSerializationError.ts +24 -0
- package/src/error/UploadValueTypeError.ts +13 -0
- package/src/index.ts +2 -46
- package/src/instance/Group.ts +16 -15
- package/src/instance/InputControl.ts +17 -11
- package/src/instance/ModelValue.ts +17 -11
- package/src/instance/Note.ts +10 -9
- package/src/instance/PrimaryInstance.ts +68 -31
- package/src/instance/RangeControl.ts +17 -11
- package/src/instance/RankControl.ts +28 -19
- package/src/instance/Root.ts +20 -31
- package/src/instance/SelectControl.ts +21 -12
- package/src/instance/Subtree.ts +16 -15
- package/src/instance/TriggerControl.ts +21 -12
- package/src/instance/UploadControl.ts +184 -0
- package/src/instance/abstract/DescendantNode.ts +12 -2
- package/src/instance/abstract/InstanceNode.ts +9 -5
- package/src/instance/abstract/ValueNode.ts +11 -13
- package/src/instance/attachments/InstanceAttachment.ts +69 -0
- package/src/instance/attachments/InstanceAttachmentsState.ts +18 -0
- package/src/instance/children/DescendantNodeInitOptions.ts +35 -0
- package/src/instance/{children.ts → children/buildChildren.ts} +57 -53
- package/src/instance/children/childrenInitOptions.ts +117 -0
- package/src/instance/children/normalizeChildInitOptions.ts +332 -0
- package/src/instance/hierarchy.ts +6 -9
- package/src/instance/input/InitialInstanceState.ts +108 -0
- package/src/instance/input/InstanceAttachmentMap.ts +154 -0
- package/src/instance/internal-api/InstanceAttachmentContext.ts +20 -0
- package/src/instance/internal-api/InstanceConfig.ts +6 -10
- package/src/instance/internal-api/InstanceValueContext.ts +9 -1
- package/src/instance/internal-api/serialization/ClientReactiveSerializableInstance.ts +22 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.ts +43 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts +26 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.ts +24 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableValueNode.ts +28 -0
- package/src/instance/repeat/BaseRepeatRange.ts +19 -24
- package/src/instance/repeat/RepeatInstance.ts +26 -19
- package/src/instance/repeat/RepeatRangeControlled.ts +90 -17
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +10 -9
- package/src/instance/resource.ts +14 -1
- package/src/integration/xpath/EngineXPathEvaluator.ts +2 -2
- package/src/integration/xpath/adapter/kind.ts +1 -28
- package/src/integration/xpath/adapter/traversal.ts +2 -2
- package/src/integration/xpath/static-dom/StaticAttribute.ts +6 -5
- package/src/integration/xpath/static-dom/StaticDocument.ts +17 -16
- package/src/integration/xpath/static-dom/StaticElement.ts +196 -50
- package/src/integration/xpath/static-dom/StaticNode.ts +1 -1
- package/src/integration/xpath/static-dom/StaticParentNode.ts +22 -0
- package/src/integration/xpath/static-dom/staticNodeName.ts +20 -0
- package/src/lib/client-reactivity/instance-state/createNodeRangeInstanceState.ts +17 -0
- package/src/lib/client-reactivity/instance-state/createParentNodeInstanceState.ts +22 -0
- package/src/lib/client-reactivity/instance-state/createPrimaryInstanceState.ts +12 -0
- package/src/lib/client-reactivity/{submission/createRootSubmissionState.ts → instance-state/createRootInstanceState.ts} +4 -4
- package/src/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.ts +31 -0
- package/src/lib/client-reactivity/instance-state/createValueNodeInstanceState.ts +21 -0
- package/src/lib/client-reactivity/instance-state/prepareInstancePayload.ts +237 -0
- package/src/lib/names/UnprefixedXFormsName.ts +12 -0
- package/src/lib/reactivity/createInstanceAttachment.ts +212 -0
- package/src/lib/reactivity/createInstanceValueState.ts +27 -51
- package/src/lib/resource-helpers.ts +33 -0
- package/src/parse/XFormDOM.ts +1 -3
- package/src/parse/body/BodyDefinition.ts +4 -0
- package/src/parse/body/control/UploadControlDefinition.ts +42 -0
- package/src/parse/model/BindDefinition.ts +1 -1
- package/src/parse/model/BindTypeDefinition.ts +68 -26
- package/src/parse/model/ItextTranslationsDefinition.ts +79 -0
- package/src/parse/model/LeafNodeDefinition.ts +3 -5
- package/src/parse/model/ModelBindMap.ts +0 -5
- package/src/parse/model/ModelDefinition.ts +36 -3
- package/src/parse/model/NodeDefinition.ts +19 -45
- package/src/parse/model/NoteNodeDefinition.ts +4 -3
- package/src/parse/model/RangeNodeDefinition.ts +3 -2
- package/src/parse/model/RepeatDefinition.ts +382 -0
- package/src/parse/model/RootAttributeDefinition.ts +6 -7
- package/src/parse/model/RootAttributeMap.ts +15 -10
- package/src/parse/model/RootDefinition.ts +17 -19
- package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +23 -2
- package/src/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.ts +14 -0
- package/src/parse/model/SecondaryInstance/defineSecondaryInstance.ts +32 -0
- package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +3 -24
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +33 -86
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +1 -30
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +64 -137
- package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +9 -7
- package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +1 -1
- package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +7 -7
- package/src/parse/model/{FormSubmissionDefinition.ts → SubmissionDefinition.ts} +2 -2
- package/src/parse/model/SubtreeDefinition.ts +4 -5
- package/src/parse/model/nodeDefinitionMap.ts +34 -0
- package/src/parse/shared/parseInstanceXML.ts +79 -0
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +45 -130
- package/dist/client/EngineConfig.d.ts +0 -79
- package/dist/client/submission/SubmissionData.d.ts +0 -7
- package/dist/client/submission/SubmissionInstanceFile.d.ts +0 -6
- package/dist/client/submission/SubmissionOptions.d.ts +0 -23
- package/dist/client/submission/SubmissionResult.d.ts +0 -91
- package/dist/client/submission/SubmissionState.d.ts +0 -12
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +0 -30
- package/dist/client/unsupported/UploadNode.d.ts +0 -9
- package/dist/instance/abstract/UnsupportedControl.d.ts +0 -54
- package/dist/instance/index.d.ts +0 -8
- package/dist/instance/internal-api/ValueContext.d.ts +0 -23
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +0 -14
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +0 -32
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +0 -19
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +0 -18
- package/dist/instance/unsupported/UploadControl.d.ts +0 -6
- package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +0 -4
- package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +0 -4
- package/dist/lib/client-reactivity/submission/createRootSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +0 -8
- package/dist/lib/reactivity/createValueState.d.ts +0 -40
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +0 -4
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +0 -9
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +0 -8
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +0 -17
- package/dist/parse/model/RepeatRangeDefinition.d.ts +0 -32
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +0 -31
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +0 -4
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +0 -7
- package/src/client/EngineConfig.ts +0 -84
- package/src/client/submission/SubmissionData.ts +0 -12
- package/src/client/submission/SubmissionInstanceFile.ts +0 -9
- package/src/client/submission/SubmissionOptions.ts +0 -28
- package/src/client/submission/SubmissionResult.ts +0 -124
- package/src/client/submission/SubmissionState.ts +0 -14
- package/src/client/unsupported/UnsupportedControlNode.ts +0 -36
- package/src/client/unsupported/UploadNode.ts +0 -14
- package/src/instance/abstract/UnsupportedControl.ts +0 -175
- package/src/instance/index.ts +0 -55
- package/src/instance/internal-api/ValueContext.ts +0 -28
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +0 -20
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +0 -43
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +0 -26
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +0 -24
- package/src/instance/unsupported/UploadControl.ts +0 -9
- package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +0 -12
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +0 -20
- package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +0 -17
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +0 -22
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +0 -21
- package/src/lib/client-reactivity/submission/prepareSubmission.ts +0 -172
- package/src/lib/reactivity/createValueState.ts +0 -200
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +0 -4
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +0 -42
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +0 -31
- package/src/parse/model/RepeatInstanceDefinition.ts +0 -38
- package/src/parse/model/RepeatRangeDefinition.ts +0 -98
- package/src/parse/model/RepeatTemplateDefinition.ts +0 -149
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +0 -4
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +0 -12
package/src/instance/resource.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
2
2
|
import { getBlobText } from '@getodk/common/lib/web-compat/blob.ts';
|
|
3
|
-
import type { FormResource } from '../client/
|
|
3
|
+
import type { FormResource } from '../client/form/FormResource.ts';
|
|
4
4
|
import type { FetchResource, FetchResourceResponse } from '../client/resources.ts';
|
|
5
5
|
|
|
6
6
|
export type { FetchResource, FetchResourceResponse, FormResource };
|
|
@@ -76,3 +76,16 @@ export const retrieveSourceXMLResource = async (
|
|
|
76
76
|
|
|
77
77
|
return text;
|
|
78
78
|
};
|
|
79
|
+
|
|
80
|
+
interface RetrieveFormDefinitionOptions {
|
|
81
|
+
readonly fetchFormDefinition: FetchResource;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const retrieveFormDefinition = async (
|
|
85
|
+
resource: FormResource,
|
|
86
|
+
options: RetrieveFormDefinitionOptions
|
|
87
|
+
): Promise<ResourceXML> => {
|
|
88
|
+
return retrieveSourceXMLResource(resource, {
|
|
89
|
+
fetchResource: options.fetchFormDefinition,
|
|
90
|
+
});
|
|
91
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { XFormsItextTranslationMap, XFormsSecondaryInstanceMap } from '@getodk/xpath';
|
|
2
2
|
import { XFormsXPathEvaluator } from '@getodk/xpath';
|
|
3
3
|
import type { PrimaryInstance } from '../../instance/PrimaryInstance.ts';
|
|
4
|
-
import type { ItextTranslationRootDefinition } from '../../parse/model/
|
|
5
|
-
import type { SecondaryInstanceRootDefinition } from '../../parse/model/SecondaryInstance/
|
|
4
|
+
import type { ItextTranslationRootDefinition } from '../../parse/model/ItextTranslationsDefinition.ts';
|
|
5
|
+
import type { SecondaryInstanceRootDefinition } from '../../parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts';
|
|
6
6
|
import { engineDOMAdapter } from './adapter/engineDOMAdapter.ts';
|
|
7
7
|
import type { EngineXPathNode } from './adapter/kind.ts';
|
|
8
8
|
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import type { XPathNodeKind } from '@getodk/xpath';
|
|
2
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';
|
|
3
|
+
import type { AnyChildNode, AnyNode, AnyParentNode } from '../../../instance/hierarchy.ts';
|
|
10
4
|
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
5
|
import type { StaticAttribute } from '../static-dom/StaticAttribute.ts';
|
|
16
6
|
import type { StaticDocument } from '../static-dom/StaticDocument.ts';
|
|
17
7
|
import type { StaticElement } from '../static-dom/StaticElement.ts';
|
|
@@ -35,26 +25,14 @@ export type PrimaryInstanceXPathChildNode =
|
|
|
35
25
|
| PrimaryInstanceXPathElement
|
|
36
26
|
| PrimaryInstanceXPathComment;
|
|
37
27
|
|
|
38
|
-
// prettier-ignore
|
|
39
|
-
export type PrimaryInstanceXPathValueElement<Value> =
|
|
40
|
-
& AnyValueNode
|
|
41
|
-
& ValueContext<Value>
|
|
42
|
-
& XFormsXPathElement;
|
|
43
|
-
|
|
44
28
|
// prettier-ignore
|
|
45
29
|
export type EngineXPathDocument =
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
47
30
|
| PrimaryInstance
|
|
48
|
-
| ItextTranslationDefinition
|
|
49
|
-
| SecondaryInstanceDefinition
|
|
50
31
|
| StaticDocument;
|
|
51
32
|
|
|
52
33
|
// prettier-ignore
|
|
53
34
|
export type EngineXPathElement =
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
55
35
|
| PrimaryInstanceXPathElement
|
|
56
|
-
| ItextTranslationRootDefinition
|
|
57
|
-
| SecondaryInstanceRootDefinition
|
|
58
36
|
| StaticElement;
|
|
59
37
|
|
|
60
38
|
// prettier-ignore
|
|
@@ -83,12 +61,7 @@ type PrimaryInstanceXPathParentNode = Extract<AnyParentNode, XPathAdapterParentN
|
|
|
83
61
|
|
|
84
62
|
// prettier-ignore
|
|
85
63
|
export type EngineXPathParentNode =
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
87
64
|
| PrimaryInstanceXPathParentNode
|
|
88
|
-
| ItextTranslationDefinition
|
|
89
|
-
| SecondaryInstanceDefinition
|
|
90
|
-
| ItextTranslationRootDefinition
|
|
91
|
-
| SecondaryInstanceRootDefinition
|
|
92
65
|
| StaticDocument
|
|
93
66
|
| StaticElement;
|
|
94
67
|
|
|
@@ -2,7 +2,7 @@ import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
|
2
2
|
import { ErrorProductionDesignPendingError } from '../../../error/ErrorProductionDesignPendingError.ts';
|
|
3
3
|
import { XPathFunctionalityPendingError } from '../../../error/XPathFunctionalityPendingError.ts';
|
|
4
4
|
import type { AnyNode } from '../../../instance/hierarchy.ts';
|
|
5
|
-
import type { AnyStaticNode,
|
|
5
|
+
import type { AnyStaticNode, StaticNodeParent } from '../static-dom/StaticNode.ts';
|
|
6
6
|
import type {
|
|
7
7
|
EngineXPathAttribute,
|
|
8
8
|
EngineXPathDocument,
|
|
@@ -168,7 +168,7 @@ const primaryInstanceElementContains = (ancestor: AnyNode, other: AnyNode): bool
|
|
|
168
168
|
return primaryInstanceElementContains(ancestor, parent);
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
const staticParentNodeContains = (ancestor:
|
|
171
|
+
const staticParentNodeContains = (ancestor: StaticNodeParent, other: AnyStaticNode): boolean => {
|
|
172
172
|
if (ancestor === other) {
|
|
173
173
|
return false;
|
|
174
174
|
}
|
|
@@ -4,11 +4,10 @@ import type { XFormsXPathAttribute } from '../adapter/XFormsXPathNode.ts';
|
|
|
4
4
|
import type { StaticDocument } from './StaticDocument.ts';
|
|
5
5
|
import type { StaticElement } from './StaticElement.ts';
|
|
6
6
|
import { StaticNode } from './StaticNode.ts';
|
|
7
|
+
import { staticNodeName, type StaticNodeNameSource } from './staticNodeName.ts';
|
|
7
8
|
|
|
8
|
-
interface StaticAttributeOptions {
|
|
9
|
-
readonly
|
|
10
|
-
readonly prefix?: string | null;
|
|
11
|
-
readonly localName: string;
|
|
9
|
+
export interface StaticAttributeOptions {
|
|
10
|
+
readonly name: StaticNodeNameSource;
|
|
12
11
|
readonly value: string;
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -18,6 +17,7 @@ export class StaticAttribute extends StaticNode<'attribute'> implements XFormsXP
|
|
|
18
17
|
readonly rootDocument: StaticDocument;
|
|
19
18
|
readonly root: StaticElement;
|
|
20
19
|
readonly qualifiedName: QualifiedName;
|
|
20
|
+
readonly nodeset: string;
|
|
21
21
|
readonly attributes = [] as const;
|
|
22
22
|
readonly children = null;
|
|
23
23
|
readonly value: string;
|
|
@@ -30,7 +30,8 @@ export class StaticAttribute extends StaticNode<'attribute'> implements XFormsXP
|
|
|
30
30
|
|
|
31
31
|
this.rootDocument = parent.rootDocument;
|
|
32
32
|
this.root = parent.root;
|
|
33
|
-
this.qualifiedName =
|
|
33
|
+
this.qualifiedName = staticNodeName(options.name);
|
|
34
|
+
this.nodeset = `${parent.nodeset}/@${this.qualifiedName.getPrefixedName()}`;
|
|
34
35
|
this.value = options.value;
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
1
|
import type { XFormsXPathDocument } from '../adapter/XFormsXPathNode.ts';
|
|
2
|
+
import type { StaticElementOptions } from './StaticElement.ts';
|
|
3
3
|
import { StaticElement } from './StaticElement.ts';
|
|
4
|
-
import {
|
|
4
|
+
import { StaticParentNode } from './StaticParentNode.ts';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
interface StaticDocumentOptions {
|
|
7
|
+
readonly documentRoot: StaticElementOptions;
|
|
8
|
+
readonly nodesetPrefix?: string;
|
|
9
|
+
}
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
extends StaticNode<'document'>
|
|
12
|
-
implements XFormsXPathDocument
|
|
13
|
-
{
|
|
14
|
-
readonly [XPathNodeKindKey] = 'document';
|
|
15
|
-
readonly nodeType = 'static-document';
|
|
11
|
+
export class StaticDocument extends StaticParentNode<'document'> implements XFormsXPathDocument {
|
|
16
12
|
readonly rootDocument: StaticDocument;
|
|
17
|
-
readonly root:
|
|
13
|
+
readonly root: StaticElement;
|
|
18
14
|
readonly parent = null;
|
|
19
|
-
readonly
|
|
15
|
+
readonly nodeset: string;
|
|
16
|
+
readonly children: readonly [root: StaticElement];
|
|
17
|
+
readonly childElements: readonly [root: StaticElement];
|
|
20
18
|
|
|
21
|
-
constructor(
|
|
22
|
-
super();
|
|
19
|
+
constructor(options: StaticDocumentOptions) {
|
|
20
|
+
super('document');
|
|
23
21
|
|
|
22
|
+
this.nodeset = options.nodesetPrefix ?? '/';
|
|
24
23
|
this.rootDocument = this;
|
|
25
24
|
|
|
26
|
-
const
|
|
25
|
+
const { documentRoot } = options;
|
|
26
|
+
const root = new StaticElement(this, documentRoot);
|
|
27
27
|
|
|
28
28
|
this.root = root;
|
|
29
29
|
this.children = [root];
|
|
30
|
+
this.childElements = this.children;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
// XFormsXPathDocument
|
|
@@ -1,81 +1,218 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
2
|
+
import { ErrorProductionDesignPendingError } from '../../../error/ErrorProductionDesignPendingError.ts';
|
|
3
|
+
import type { QualifiedNameSource } from '../../../lib/names/QualifiedName.ts';
|
|
2
4
|
import { QualifiedName } from '../../../lib/names/QualifiedName.ts';
|
|
3
5
|
import type { EngineDOMAdapter } from '../adapter/engineDOMAdapter.ts';
|
|
4
6
|
import type { XFormsXPathElement } from '../adapter/XFormsXPathNode.ts';
|
|
7
|
+
import type { StaticAttributeOptions } from './StaticAttribute.ts';
|
|
5
8
|
import { StaticAttribute } from './StaticAttribute.ts';
|
|
6
9
|
import type { StaticDocument } from './StaticDocument.ts';
|
|
7
|
-
import type { StaticChildNode
|
|
8
|
-
import {
|
|
10
|
+
import type { StaticChildNode } from './StaticNode.ts';
|
|
11
|
+
import { staticNodeName } from './staticNodeName.ts';
|
|
12
|
+
import { StaticParentNode } from './StaticParentNode.ts';
|
|
13
|
+
import { StaticText } from './StaticText.ts';
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
// prettier-ignore
|
|
16
|
+
export type StaticElementChildOption =
|
|
17
|
+
| StaticElementOptions
|
|
18
|
+
| string;
|
|
13
19
|
|
|
14
20
|
export interface StaticElementOptions {
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
21
|
+
readonly name: QualifiedNameSource | string;
|
|
22
|
+
readonly attributes?: readonly StaticAttributeOptions[];
|
|
23
|
+
readonly children?: readonly StaticElementChildOption[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface StaticElementChildrenResult {
|
|
27
|
+
readonly children: readonly StaticChildNode[];
|
|
28
|
+
readonly childElements: readonly StaticElement[];
|
|
29
|
+
readonly leafValue: string | null;
|
|
18
30
|
}
|
|
19
31
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
const leafElementChildrenResult = (
|
|
33
|
+
parent: StaticElement,
|
|
34
|
+
leafValue: string
|
|
35
|
+
): StaticElementChildrenResult => {
|
|
36
|
+
const child = new StaticText(parent, leafValue);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
children: [child],
|
|
40
|
+
childElements: [],
|
|
41
|
+
leafValue: leafValue,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const blankLeafElementChildrenResult = (parent: StaticElement): StaticElementChildrenResult => {
|
|
46
|
+
return leafElementChildrenResult(parent, '');
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Builds several "views" into a {@link StaticElement}'s children as:
|
|
51
|
+
*
|
|
52
|
+
* - An array of all of its {@link StaticChildNode | child nodes}
|
|
53
|
+
* - A subset array of only its {@link StaticElement | child elements}
|
|
54
|
+
* - A {@link StaticElementChildrenResult.leafValue | "leaf value"} which is
|
|
55
|
+
* populated with the text value of a {@link StaticText | text node} if **and
|
|
56
|
+
* only if** that text node is the element's sole child node (which is in turn
|
|
57
|
+
* used to identify which _elements_ are {@link StaticLeafElement | leaf}
|
|
58
|
+
* nodes)
|
|
59
|
+
*
|
|
60
|
+
* @todo this is awkwardly named and awkward to describe! It's done this way for
|
|
61
|
+
* efficiency (which makes a substantial difference for large forms), at the
|
|
62
|
+
* expense of code clarity.
|
|
63
|
+
*
|
|
64
|
+
* @todo Handle comment nodes (1): we have discussed the possibility of using
|
|
65
|
+
* comments as a placeholder for omitted non-relevant repeat instances, as an
|
|
66
|
+
* aide to recreating them in restore/edit modes.
|
|
67
|
+
*
|
|
68
|
+
* @todo Handle comment nodes (2): comments are currently _effectively implied_
|
|
69
|
+
* in the function-body comment about a homogenous sequence of 2+ strings, i.e.
|
|
70
|
+
* in a structure like `<foo>bar<!-- bat -->quux</foo>`. If we handle comment
|
|
71
|
+
* nodes, the only way we'd encounter that scenario is if we're parsing a
|
|
72
|
+
* `StaticElement` from a DOM `Element` (or some other source with similar
|
|
73
|
+
* semantics) where its child nodes have been manipulated into that state. As
|
|
74
|
+
* such, if we do handle comments, that comment should likely be removed.
|
|
75
|
+
*/
|
|
76
|
+
const buildStaticElementChildren = (
|
|
77
|
+
parent: StaticElement,
|
|
78
|
+
options: StaticElementOptions
|
|
79
|
+
): StaticElementChildrenResult => {
|
|
80
|
+
const children = Array<StaticChildNode>();
|
|
81
|
+
const childElements = Array<StaticElement>();
|
|
82
|
+
const childOptions = options.children ?? [''];
|
|
83
|
+
|
|
84
|
+
// No children: blank value
|
|
85
|
+
if (childOptions.length === 0) {
|
|
86
|
+
return {
|
|
87
|
+
children,
|
|
88
|
+
childElements,
|
|
89
|
+
leafValue: '',
|
|
90
|
+
};
|
|
38
91
|
}
|
|
92
|
+
|
|
93
|
+
const [head, ...tail] = childOptions;
|
|
94
|
+
|
|
95
|
+
if (tail.length === 0) {
|
|
96
|
+
// - If no child options are specified, default to a single empty/blank
|
|
97
|
+
// `StaticText` child node, and assign its value
|
|
98
|
+
if (head == null) {
|
|
99
|
+
return blankLeafElementChildrenResult(parent);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// - If exactly one child option is specified, and it is a string, create
|
|
103
|
+
// `StaticText` child and assign its value
|
|
104
|
+
if (typeof head === 'string') {
|
|
105
|
+
return leafElementChildrenResult(parent, head);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// If 2+ child options, for each:
|
|
110
|
+
//
|
|
111
|
+
// - Populate `children` (and `childElements`, as appopriate)
|
|
112
|
+
// - Do not populate `value`. For cases which need an arbitrary
|
|
113
|
+
// `StaticElement`'s text value (i.e. `XPath`, perhaps eventually some
|
|
114
|
+
// serialization use cases), it will be computed recursively as needed.
|
|
115
|
+
//
|
|
116
|
+
// Note: in theory, we may encounter a homogenous sequence of 2+ strings! In
|
|
117
|
+
// theory we should normalize those into a single string.
|
|
118
|
+
if (typeof head === 'string' && tail.length === 0) {
|
|
119
|
+
const child = new StaticText(parent, head);
|
|
120
|
+
|
|
121
|
+
children.push(child);
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
children,
|
|
125
|
+
childElements,
|
|
126
|
+
leafValue: child.value,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
for (const item of childOptions) {
|
|
131
|
+
switch (typeof item) {
|
|
132
|
+
case 'string':
|
|
133
|
+
children.push(new StaticText(parent, item));
|
|
134
|
+
break;
|
|
135
|
+
|
|
136
|
+
case 'object': {
|
|
137
|
+
const childElement = new StaticElement(parent, item);
|
|
138
|
+
|
|
139
|
+
children.push(childElement);
|
|
140
|
+
childElements.push(childElement);
|
|
141
|
+
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
default:
|
|
146
|
+
throw new UnreachableError(item);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
children,
|
|
152
|
+
childElements,
|
|
153
|
+
leafValue: null,
|
|
154
|
+
};
|
|
39
155
|
};
|
|
40
156
|
|
|
41
|
-
export class StaticElement
|
|
42
|
-
|
|
43
|
-
implements XFormsXPathElement
|
|
44
|
-
{
|
|
45
|
-
readonly [XFORMS_LOCAL_NAME]?: string;
|
|
46
|
-
readonly [XFORMS_KNOWN_ATTRIBUTE]?: string;
|
|
157
|
+
export class StaticElement extends StaticParentNode<'element'> implements XFormsXPathElement {
|
|
158
|
+
private computedValue: string | null;
|
|
47
159
|
|
|
48
|
-
readonly [XPathNodeKindKey] = 'element';
|
|
49
|
-
readonly nodeType = 'static-element';
|
|
50
160
|
readonly rootDocument: StaticDocument;
|
|
51
161
|
readonly root: StaticElement;
|
|
52
162
|
readonly qualifiedName: QualifiedName;
|
|
163
|
+
readonly nodeset: string;
|
|
53
164
|
readonly attributes: readonly StaticAttribute[];
|
|
54
165
|
readonly children: readonly StaticChildNode[];
|
|
55
|
-
readonly
|
|
166
|
+
readonly childElements: readonly StaticElement[];
|
|
167
|
+
readonly value: string | null;
|
|
56
168
|
|
|
57
169
|
constructor(
|
|
58
|
-
readonly parent:
|
|
59
|
-
attributesFactory: StaticElementAttributesFactory,
|
|
60
|
-
childNodesFactory: StaticElementChildNodesFactory,
|
|
170
|
+
readonly parent: StaticDocument | StaticElement,
|
|
61
171
|
options: StaticElementOptions
|
|
62
172
|
) {
|
|
63
|
-
super();
|
|
173
|
+
super('element');
|
|
64
174
|
|
|
65
175
|
const { rootDocument } = parent;
|
|
176
|
+
let nodesetPrefix = parent.nodeset;
|
|
66
177
|
|
|
67
178
|
this.rootDocument = rootDocument;
|
|
68
179
|
|
|
69
180
|
// Account for the fact that we may be constructing the document root!
|
|
70
181
|
if (parent === rootDocument) {
|
|
71
182
|
this.root = this;
|
|
183
|
+
|
|
184
|
+
// Avoid nodeset like `//foo` when `/foo` is expected/intended
|
|
185
|
+
if (nodesetPrefix === '/') {
|
|
186
|
+
nodesetPrefix = '';
|
|
187
|
+
}
|
|
72
188
|
} else {
|
|
73
189
|
this.root = parent.root;
|
|
74
190
|
}
|
|
75
191
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.
|
|
192
|
+
const { name, attributes = [] } = options;
|
|
193
|
+
|
|
194
|
+
this.qualifiedName = staticNodeName(name);
|
|
195
|
+
this.nodeset = `${nodesetPrefix}/${this.qualifiedName.getPrefixedName()}`;
|
|
196
|
+
this.attributes = attributes.map((attrOptions) => {
|
|
197
|
+
return new StaticAttribute(this, attrOptions);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const { children, childElements, leafValue } = buildStaticElementChildren(this, options);
|
|
201
|
+
|
|
202
|
+
this.children = children;
|
|
203
|
+
this.childElements = childElements;
|
|
204
|
+
this.computedValue = leafValue;
|
|
205
|
+
this.value = leafValue;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
isLeafElement(): this is StaticLeafElement {
|
|
209
|
+
return this.value != null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
assertLeafElement(): asserts this is StaticLeafElement {
|
|
213
|
+
if (!this.isLeafElement()) {
|
|
214
|
+
throw new ErrorProductionDesignPendingError();
|
|
215
|
+
}
|
|
79
216
|
}
|
|
80
217
|
|
|
81
218
|
/**
|
|
@@ -100,20 +237,29 @@ export class StaticElement<Parent extends StaticParentNode = StaticParentNode>
|
|
|
100
237
|
* up. (This was put off because the types are already plenty complex as it
|
|
101
238
|
* is.)
|
|
102
239
|
*/
|
|
103
|
-
getAttributeValue
|
|
104
|
-
this: This,
|
|
105
|
-
localName: LocalName
|
|
106
|
-
): StaticElementKnownAttributeValue<This, LocalName> {
|
|
240
|
+
getAttributeValue(localName: string): string | null {
|
|
107
241
|
const attribute = this.getAttributeNode(localName);
|
|
108
242
|
const value = attribute?.value ?? null;
|
|
109
243
|
|
|
110
|
-
assertStaticElementKnownAttributeValue(this, localName, value);
|
|
111
|
-
|
|
112
244
|
return value;
|
|
113
245
|
}
|
|
114
246
|
|
|
115
247
|
// XFormsXPathElement
|
|
116
248
|
getXPathValue(): string {
|
|
117
|
-
|
|
249
|
+
const { computedValue } = this;
|
|
250
|
+
|
|
251
|
+
if (computedValue != null) {
|
|
252
|
+
return computedValue;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const result = this.children.map((child) => child.getXPathValue()).join('');
|
|
256
|
+
|
|
257
|
+
this.computedValue = result;
|
|
258
|
+
|
|
259
|
+
return result;
|
|
118
260
|
}
|
|
119
261
|
}
|
|
262
|
+
|
|
263
|
+
export interface StaticLeafElement extends StaticElement {
|
|
264
|
+
readonly value: string;
|
|
265
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { StaticElement } from './StaticElement.ts';
|
|
3
|
+
import { StaticNode, type StaticChildNode } from './StaticNode.ts';
|
|
4
|
+
|
|
5
|
+
type StaticParentNodeKind = 'document' | 'element';
|
|
6
|
+
|
|
7
|
+
type StaticParentNodeType<Kind extends StaticParentNodeKind> = `static-${Kind}`;
|
|
8
|
+
|
|
9
|
+
export abstract class StaticParentNode<Kind extends StaticParentNodeKind> extends StaticNode<Kind> {
|
|
10
|
+
abstract override readonly children: readonly StaticChildNode[];
|
|
11
|
+
abstract readonly childElements: readonly StaticElement[];
|
|
12
|
+
|
|
13
|
+
readonly [XPathNodeKindKey]: Kind;
|
|
14
|
+
readonly nodeType: StaticParentNodeType<Kind>;
|
|
15
|
+
|
|
16
|
+
constructor(kind: Kind) {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
this[XPathNodeKindKey] = kind;
|
|
20
|
+
this.nodeType = `static-${kind}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { QualifiedName, type QualifiedNameSource } from '../../../lib/names/QualifiedName.ts';
|
|
2
|
+
import { UnprefixedXFormsName } from '../../../lib/names/UnprefixedXFormsName.ts';
|
|
3
|
+
|
|
4
|
+
// prettier-ignore
|
|
5
|
+
export type StaticNodeNameSource =
|
|
6
|
+
| QualifiedName
|
|
7
|
+
| QualifiedNameSource
|
|
8
|
+
| string;
|
|
9
|
+
|
|
10
|
+
export const staticNodeName = (source: StaticNodeNameSource): QualifiedName => {
|
|
11
|
+
if (source instanceof QualifiedName) {
|
|
12
|
+
return source;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof source === 'string') {
|
|
16
|
+
return new UnprefixedXFormsName(source);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return new QualifiedName(source);
|
|
20
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { InstanceState } from '../../../client/serialization/InstanceState.ts';
|
|
2
|
+
import type { ClientReactiveSerializableParentNode } from '../../../instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts';
|
|
3
|
+
import type { RepeatInstance } from '../../../instance/repeat/RepeatInstance.ts';
|
|
4
|
+
|
|
5
|
+
export const createNodeRangeInstanceState = (
|
|
6
|
+
node: ClientReactiveSerializableParentNode<RepeatInstance>
|
|
7
|
+
): InstanceState => {
|
|
8
|
+
return {
|
|
9
|
+
get instanceXML() {
|
|
10
|
+
const serializedChildren = node.currentState.children.map((child) => {
|
|
11
|
+
return child.instanceState.instanceXML;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return serializedChildren.join('');
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { InstanceState } from '../../../client/serialization/InstanceState.ts';
|
|
2
|
+
import type { GeneralChildNode } from '../../../instance/hierarchy.ts';
|
|
3
|
+
import type { ClientReactiveSerializableParentNode } from '../../../instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts';
|
|
4
|
+
import { serializeParentElementXML } from '../../xml-serialization.ts';
|
|
5
|
+
|
|
6
|
+
export const createParentNodeInstanceState = (
|
|
7
|
+
node: ClientReactiveSerializableParentNode<GeneralChildNode>
|
|
8
|
+
): InstanceState => {
|
|
9
|
+
return {
|
|
10
|
+
get instanceXML() {
|
|
11
|
+
if (!node.currentState.relevant) {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const serializedChildren = node.currentState.children.map((child) => {
|
|
16
|
+
return child.instanceState.instanceXML;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return serializeParentElementXML(node.definition.qualifiedName, serializedChildren);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InstanceState } from '../../../client/serialization/InstanceState.ts';
|
|
2
|
+
import type { ClientReactiveSerializableInstance } from '../../../instance/internal-api/serialization/ClientReactiveSerializableInstance.ts';
|
|
3
|
+
|
|
4
|
+
export const createPrimaryInstanceState = (
|
|
5
|
+
node: ClientReactiveSerializableInstance
|
|
6
|
+
): InstanceState => {
|
|
7
|
+
return {
|
|
8
|
+
get instanceXML(): string {
|
|
9
|
+
return node.root.instanceState.instanceXML;
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InstanceState } from '../../../client/serialization/InstanceState.ts';
|
|
2
2
|
import type { Root } from '../../../instance/Root.ts';
|
|
3
3
|
import { serializeParentElementXML } from '../../xml-serialization.ts';
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const createRootInstanceState = (node: Root): InstanceState => {
|
|
6
6
|
return {
|
|
7
|
-
get
|
|
7
|
+
get instanceXML() {
|
|
8
8
|
const { namespaceDeclarations, attributes } = node.definition;
|
|
9
9
|
const serializedChildren = node.currentState.children.map((child) => {
|
|
10
|
-
return child.
|
|
10
|
+
return child.instanceState.instanceXML;
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
return serializeParentElementXML(node.definition.qualifiedName, serializedChildren, {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { InstanceState } from '../../../client/serialization/InstanceState.ts';
|
|
2
|
+
import { TemplatedNodeAttributeSerializationError } from '../../../error/TemplatedNodeAttributeSerializationError.ts';
|
|
3
|
+
import type { ClientReactiveSerializableTemplatedNode } from '../../../instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.ts';
|
|
4
|
+
import { serializeParentElementXML } from '../../xml-serialization.ts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @see {@link TemplatedNodeAttributeSerializationError}
|
|
8
|
+
*/
|
|
9
|
+
export const createTemplatedNodeInstanceState = (
|
|
10
|
+
node: ClientReactiveSerializableTemplatedNode
|
|
11
|
+
): InstanceState => {
|
|
12
|
+
return {
|
|
13
|
+
get instanceXML() {
|
|
14
|
+
if (!node.currentState.relevant) {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const serializedChildren = node.currentState.children.map((child) => {
|
|
19
|
+
return child.instanceState.instanceXML;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const { attributes } = node.currentState;
|
|
23
|
+
|
|
24
|
+
if (attributes != null) {
|
|
25
|
+
throw new TemplatedNodeAttributeSerializationError();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return serializeParentElementXML(node.definition.qualifiedName, serializedChildren);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
};
|