@getodk/xforms-engine 0.6.0 → 0.7.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/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 +17 -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/index.d.ts +37 -11
- package/dist/client/node-types.d.ts +2 -2
- 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 +12 -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 +23 -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/index.d.ts +2 -33
- package/dist/index.js +1915 -1419
- 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 +35 -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/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/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/input/InitialInstanceState.d.ts +13 -0
- package/dist/instance/input/InstanceAttachmentMap.d.ts +19 -0
- package/dist/instance/internal-api/InstanceConfig.d.ts +2 -9
- package/dist/instance/internal-api/InstanceValueContext.d.ts +8 -1
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableInstance.d.ts +14 -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/instance/unsupported/UploadControl.d.ts +32 -4
- 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/codecs/TempUnsupportedControlCodec.d.ts +7 -0
- package/dist/lib/names/UnprefixedXFormsName.d.ts +4 -0
- package/dist/lib/reactivity/createInstanceValueState.d.ts +2 -27
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/model/BindDefinition.d.ts +1 -1
- 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 +1709 -1213
- package/dist/solid.js.map +1 -1
- package/package.json +1 -1
- package/src/client/BaseNode.ts +4 -4
- package/src/client/BaseValueNode.ts +7 -3
- package/src/client/RootNode.ts +27 -19
- 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 +18 -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/index.ts +47 -29
- package/src/client/node-types.ts +2 -4
- 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 +16 -0
- package/src/client/serialization/InstanceFile.ts +9 -0
- package/src/client/serialization/InstancePayload.ts +126 -0
- package/src/client/serialization/InstancePayloadOptions.ts +28 -0
- package/src/client/serialization/InstanceState.ts +14 -0
- package/src/client/submission/{SubmissionDefinition.ts → SubmissionMeta.ts} +1 -1
- package/src/entrypoints/FormInstance.ts +55 -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/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 +69 -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/abstract/DescendantNode.ts +12 -2
- package/src/instance/abstract/InstanceNode.ts +9 -5
- package/src/instance/abstract/ValueNode.ts +11 -13
- package/src/instance/children/DescendantNodeInitOptions.ts +35 -0
- package/src/instance/{children.ts → children/buildChildren.ts} +55 -48
- package/src/instance/children/childrenInitOptions.ts +117 -0
- package/src/instance/children/normalizeChildInitOptions.ts +332 -0
- package/src/instance/input/InitialInstanceState.ts +108 -0
- package/src/instance/input/InstanceAttachmentMap.ts +142 -0
- package/src/instance/internal-api/InstanceConfig.ts +3 -10
- package/src/instance/internal-api/InstanceValueContext.ts +9 -1
- package/src/instance/internal-api/serialization/ClientReactiveSerializableInstance.ts +20 -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/instance/unsupported/UploadControl.ts +116 -5
- 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 +173 -0
- package/src/lib/codecs/TempUnsupportedControlCodec.ts +32 -0
- package/src/lib/names/UnprefixedXFormsName.ts +12 -0
- package/src/lib/reactivity/createInstanceValueState.ts +27 -51
- package/src/parse/model/ItextTranslationsDefinition.ts +79 -0
- package/src/parse/model/LeafNodeDefinition.ts +3 -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/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/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/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/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/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
|
@@ -2,6 +2,7 @@ import { XPathNodeKindKey } from '@getodk/xpath';
|
|
|
2
2
|
import type { ModelValueDefinition, ModelValueNode } from '../client/ModelValueNode.ts';
|
|
3
3
|
import type { ValueType } from '../client/ValueType.ts';
|
|
4
4
|
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
5
|
+
import type { StaticLeafElement } from '../integration/xpath/static-dom/StaticElement.ts';
|
|
5
6
|
import type { RuntimeInputValue, RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
|
|
6
7
|
import { getSharedValueCodec } from '../lib/codecs/getSharedValueCodec.ts';
|
|
7
8
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
@@ -12,7 +13,7 @@ import { ValueNode, type ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
|
12
13
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
13
14
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
14
15
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
15
|
-
import type {
|
|
16
|
+
import type { ClientReactiveSerializableValueNode } from './internal-api/serialization/ClientReactiveSerializableValueNode.ts';
|
|
16
17
|
|
|
17
18
|
interface ModelValueStateSpec<V extends ValueType> extends ValueNodeStateSpec<RuntimeValue<V>> {
|
|
18
19
|
readonly label: null;
|
|
@@ -27,14 +28,19 @@ export class ModelValue<V extends ValueType = ValueType>
|
|
|
27
28
|
XFormsXPathElement,
|
|
28
29
|
EvaluationContext,
|
|
29
30
|
ValidationContext,
|
|
30
|
-
|
|
31
|
+
ClientReactiveSerializableValueNode
|
|
31
32
|
{
|
|
32
|
-
static from(
|
|
33
|
+
static from(
|
|
34
|
+
parent: GeneralParentNode,
|
|
35
|
+
instanceNode: StaticLeafElement | null,
|
|
36
|
+
definition: ModelValueDefinition
|
|
37
|
+
): AnyModelValue;
|
|
33
38
|
static from<V extends ValueType>(
|
|
34
39
|
parent: GeneralParentNode,
|
|
40
|
+
instanceNode: StaticLeafElement | null,
|
|
35
41
|
definition: ModelValueDefinition<V>
|
|
36
42
|
): ModelValue<V> {
|
|
37
|
-
return new this(parent, definition);
|
|
43
|
+
return new this(parent, instanceNode, definition);
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
// XFormsXPathElement
|
|
@@ -50,14 +56,14 @@ export class ModelValue<V extends ValueType = ValueType>
|
|
|
50
56
|
readonly nodeOptions = null;
|
|
51
57
|
readonly currentState: CurrentState<ModelValueStateSpec<V>>;
|
|
52
58
|
|
|
53
|
-
constructor(
|
|
59
|
+
constructor(
|
|
60
|
+
parent: GeneralParentNode,
|
|
61
|
+
instanceNode: StaticLeafElement | null,
|
|
62
|
+
definition: ModelValueDefinition<V>
|
|
63
|
+
) {
|
|
54
64
|
const codec = getSharedValueCodec(definition.valueType);
|
|
55
65
|
|
|
56
|
-
super(parent, definition, codec);
|
|
57
|
-
|
|
58
|
-
const sharedStateOptions = {
|
|
59
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
60
|
-
};
|
|
66
|
+
super(parent, instanceNode, definition, codec);
|
|
61
67
|
|
|
62
68
|
const state = createSharedNodeState(
|
|
63
69
|
this.scope,
|
|
@@ -74,7 +80,7 @@ export class ModelValue<V extends ValueType = ValueType>
|
|
|
74
80
|
value: this.valueState,
|
|
75
81
|
instanceValue: this.getInstanceValue,
|
|
76
82
|
},
|
|
77
|
-
|
|
83
|
+
this.instanceConfig
|
|
78
84
|
);
|
|
79
85
|
|
|
80
86
|
this.state = state;
|
package/src/instance/Note.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { NoteNode, NoteNodeAppearances, NoteValue } from '../client/NoteNod
|
|
|
5
5
|
import type { TextRange } from '../client/TextRange.ts';
|
|
6
6
|
import type { ValueType } from '../client/ValueType.ts';
|
|
7
7
|
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
8
|
+
import type { StaticLeafElement } from '../integration/xpath/static-dom/StaticElement.ts';
|
|
8
9
|
import { getNoteCodec } from '../lib/codecs/getNoteCodec.ts';
|
|
9
10
|
import type { NoteInputValue, NoteRuntimeValue } from '../lib/codecs/NoteCodec.ts';
|
|
10
11
|
import { createNoteReadonlyThunk } from '../lib/reactivity/createNoteReadonlyThunk.ts';
|
|
@@ -19,7 +20,7 @@ import type { NoteNodeDefinition } from '../parse/model/NoteNodeDefinition.ts';
|
|
|
19
20
|
import { ValueNode, type ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
20
21
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
21
22
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
22
|
-
import type {
|
|
23
|
+
import type { ClientReactiveSerializableValueNode } from './internal-api/serialization/ClientReactiveSerializableValueNode.ts';
|
|
23
24
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
24
25
|
|
|
25
26
|
interface NoteStateSpec<V extends ValueType> extends ValueNodeStateSpec<NoteValue<V>> {
|
|
@@ -37,7 +38,7 @@ export class Note<V extends ValueType = ValueType>
|
|
|
37
38
|
XFormsXPathElement,
|
|
38
39
|
EvaluationContext,
|
|
39
40
|
ValidationContext,
|
|
40
|
-
|
|
41
|
+
ClientReactiveSerializableValueNode
|
|
41
42
|
{
|
|
42
43
|
// XFormsXPathElement
|
|
43
44
|
override readonly [XPathNodeKindKey] = 'element';
|
|
@@ -52,17 +53,17 @@ export class Note<V extends ValueType = ValueType>
|
|
|
52
53
|
readonly nodeOptions = null;
|
|
53
54
|
readonly currentState: CurrentState<NoteStateSpec<V>>;
|
|
54
55
|
|
|
55
|
-
constructor(
|
|
56
|
+
constructor(
|
|
57
|
+
parent: GeneralParentNode,
|
|
58
|
+
instanceNode: StaticLeafElement | null,
|
|
59
|
+
definition: NoteNodeDefinition<V>
|
|
60
|
+
) {
|
|
56
61
|
const codec = getNoteCodec(definition.valueType);
|
|
57
62
|
|
|
58
|
-
super(parent, definition, codec);
|
|
63
|
+
super(parent, instanceNode, definition, codec);
|
|
59
64
|
|
|
60
65
|
this.appearances = definition.bodyElement.appearances;
|
|
61
66
|
|
|
62
|
-
const sharedStateOptions = {
|
|
63
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
67
|
const isReadonly = createNoteReadonlyThunk(this, definition);
|
|
67
68
|
const noteTextComputation = createNoteText(this, definition.noteTextDefinition);
|
|
68
69
|
|
|
@@ -108,7 +109,7 @@ export class Note<V extends ValueType = ValueType>
|
|
|
108
109
|
value: this.valueState,
|
|
109
110
|
instanceValue: this.getInstanceValue,
|
|
110
111
|
},
|
|
111
|
-
|
|
112
|
+
this.instanceConfig
|
|
112
113
|
);
|
|
113
114
|
|
|
114
115
|
this.state = state;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
2
|
import type { Accessor } from 'solid-js';
|
|
3
3
|
import { createSignal } from 'solid-js';
|
|
4
|
+
import type { FormInstanceInitializationMode } from '../client/form/FormInstance.ts';
|
|
4
5
|
import type { ActiveLanguage, FormLanguage, FormLanguages } from '../client/FormLanguage.ts';
|
|
5
6
|
import type { FormNodeID } from '../client/identity.ts';
|
|
6
7
|
import type { RootNode } from '../client/RootNode.ts';
|
|
8
|
+
import type { InstancePayload } from '../client/serialization/InstancePayload.ts';
|
|
7
9
|
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from '../client/
|
|
11
|
-
import type {
|
|
12
|
-
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
10
|
+
InstancePayloadOptions,
|
|
11
|
+
InstancePayloadType,
|
|
12
|
+
} from '../client/serialization/InstancePayloadOptions.ts';
|
|
13
|
+
import type { InstanceState } from '../client/serialization/InstanceState.ts';
|
|
13
14
|
import type { AncestorNodeValidationState } from '../client/validation.ts';
|
|
14
15
|
import type { XFormsXPathDocument } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
15
16
|
import { EngineXPathEvaluator } from '../integration/xpath/EngineXPathEvaluator.ts';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
17
|
+
import type { StaticDocument } from '../integration/xpath/static-dom/StaticDocument.ts';
|
|
18
|
+
import { createPrimaryInstanceState } from '../lib/client-reactivity/instance-state/createPrimaryInstanceState.ts';
|
|
19
|
+
import { prepareInstancePayload } from '../lib/client-reactivity/instance-state/prepareInstancePayload.ts';
|
|
18
20
|
import { createChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
19
21
|
import { createTranslationState } from '../lib/reactivity/createTranslationState.ts';
|
|
20
22
|
import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
@@ -30,10 +32,11 @@ import type { ModelDefinition } from '../parse/model/ModelDefinition.ts';
|
|
|
30
32
|
import type { RootDefinition } from '../parse/model/RootDefinition.ts';
|
|
31
33
|
import type { SecondaryInstancesDefinition } from '../parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts';
|
|
32
34
|
import { InstanceNode } from './abstract/InstanceNode.ts';
|
|
35
|
+
import type { InitialInstanceState } from './input/InitialInstanceState.ts';
|
|
33
36
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
34
37
|
import type { InstanceConfig } from './internal-api/InstanceConfig.ts';
|
|
35
38
|
import type { PrimaryInstanceDocument } from './internal-api/PrimaryInstanceDocument.ts';
|
|
36
|
-
import type {
|
|
39
|
+
import type { ClientReactiveSerializableInstance } from './internal-api/serialization/ClientReactiveSerializableInstance.ts';
|
|
37
40
|
import type { TranslationContext } from './internal-api/TranslationContext.ts';
|
|
38
41
|
import { Root } from './Root.ts';
|
|
39
42
|
|
|
@@ -74,20 +77,55 @@ interface PrimaryInstanceStateSpec {
|
|
|
74
77
|
readonly activeLanguage: Accessor<ActiveLanguage>;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
interface PrimaryInstanceStateInputByMode {
|
|
81
|
+
readonly create: null;
|
|
82
|
+
readonly edit: InitialInstanceState;
|
|
83
|
+
readonly restore: InitialInstanceState;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type PrimaryInstanceInitialState<Mode extends FormInstanceInitializationMode> =
|
|
87
|
+
PrimaryInstanceStateInputByMode[Mode];
|
|
88
|
+
|
|
89
|
+
export interface BasePrimaryInstanceOptions {
|
|
90
|
+
readonly scope: ReactiveScope;
|
|
91
|
+
readonly model: ModelDefinition;
|
|
92
|
+
readonly secondaryInstances: SecondaryInstancesDefinition;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface ModelessPrimaryInstanceOptions extends BasePrimaryInstanceOptions {
|
|
96
|
+
readonly config: InstanceConfig;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface PrimaryInstanceOptions<Mode extends FormInstanceInitializationMode>
|
|
100
|
+
extends ModelessPrimaryInstanceOptions {
|
|
101
|
+
readonly mode: Mode;
|
|
102
|
+
readonly initialState: PrimaryInstanceInitialState<Mode>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export class PrimaryInstance<
|
|
106
|
+
Mode extends FormInstanceInitializationMode = FormInstanceInitializationMode,
|
|
107
|
+
>
|
|
78
108
|
extends InstanceNode<RootDefinition, PrimaryInstanceStateSpec, null, Root>
|
|
79
109
|
implements
|
|
80
110
|
PrimaryInstanceDocument,
|
|
81
111
|
XFormsXPathDocument,
|
|
82
112
|
TranslationContext,
|
|
83
113
|
EvaluationContext,
|
|
84
|
-
|
|
114
|
+
ClientReactiveSerializableInstance
|
|
85
115
|
{
|
|
116
|
+
/**
|
|
117
|
+
* @todo this will be populated as we introduce other initialization modes!
|
|
118
|
+
*/
|
|
119
|
+
readonly initializationMode: FormInstanceInitializationMode = 'create';
|
|
120
|
+
|
|
121
|
+
readonly model: ModelDefinition;
|
|
122
|
+
|
|
86
123
|
// InstanceNode
|
|
87
124
|
protected readonly state: SharedNodeState<PrimaryInstanceStateSpec>;
|
|
88
125
|
protected readonly engineState: EngineState<PrimaryInstanceStateSpec>;
|
|
89
|
-
readonly getChildren: Accessor<readonly Root[]>;
|
|
90
126
|
|
|
127
|
+
override readonly instanceNode: StaticDocument;
|
|
128
|
+
readonly getChildren: Accessor<readonly Root[]>;
|
|
91
129
|
readonly hasReadonlyAncestor = () => false;
|
|
92
130
|
readonly isReadonly = () => false;
|
|
93
131
|
readonly hasNonRelevantAncestor = () => false;
|
|
@@ -99,7 +137,7 @@ export class PrimaryInstance
|
|
|
99
137
|
// XFormsXPathDocument
|
|
100
138
|
readonly [XPathNodeKindKey] = 'document';
|
|
101
139
|
|
|
102
|
-
// PrimaryInstanceDocument,
|
|
140
|
+
// PrimaryInstanceDocument, ClientReactiveSerializableInstance
|
|
103
141
|
readonly nodeType = 'primary-instance';
|
|
104
142
|
readonly appearances = null;
|
|
105
143
|
readonly nodeOptions = null;
|
|
@@ -107,7 +145,7 @@ export class PrimaryInstance
|
|
|
107
145
|
readonly root: Root;
|
|
108
146
|
readonly currentState: MaterializedChildren<CurrentState<PrimaryInstanceStateSpec>, Root>;
|
|
109
147
|
readonly validationState: AncestorNodeValidationState;
|
|
110
|
-
readonly
|
|
148
|
+
readonly instanceState: InstanceState;
|
|
111
149
|
readonly languages: FormLanguages;
|
|
112
150
|
|
|
113
151
|
// TranslationContext (+ EvaluationContext)
|
|
@@ -118,19 +156,21 @@ export class PrimaryInstance
|
|
|
118
156
|
readonly evaluator: EngineXPathEvaluator;
|
|
119
157
|
override readonly contextNode = this;
|
|
120
158
|
|
|
121
|
-
constructor(
|
|
122
|
-
scope
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
) {
|
|
127
|
-
const { root: definition } = model;
|
|
159
|
+
constructor(options: PrimaryInstanceOptions<Mode>) {
|
|
160
|
+
const { mode, initialState, scope, model, secondaryInstances, config } = options;
|
|
161
|
+
const { instance: modelInstance } = model;
|
|
162
|
+
const activeInstance = initialState?.document ?? modelInstance;
|
|
163
|
+
const definition = model.getRootDefinition(activeInstance);
|
|
128
164
|
|
|
129
|
-
super(
|
|
165
|
+
super(config, null, activeInstance, definition, {
|
|
130
166
|
scope,
|
|
131
167
|
computeReference: () => PRIMARY_INSTANCE_REFERENCE,
|
|
132
168
|
});
|
|
133
169
|
|
|
170
|
+
this.initializationMode = mode;
|
|
171
|
+
this.model = model;
|
|
172
|
+
this.instanceNode = activeInstance;
|
|
173
|
+
|
|
134
174
|
const [isAttached, setIsAttached] = createSignal(false);
|
|
135
175
|
|
|
136
176
|
this.isAttached = isAttached;
|
|
@@ -170,9 +210,7 @@ export class PrimaryInstance
|
|
|
170
210
|
children: childrenState.childIds,
|
|
171
211
|
};
|
|
172
212
|
|
|
173
|
-
const state = createSharedNodeState(scope, stateSpec,
|
|
174
|
-
clientStateFactory: engineConfig.stateFactory,
|
|
175
|
-
});
|
|
213
|
+
const state = createSharedNodeState(scope, stateSpec, config);
|
|
176
214
|
|
|
177
215
|
this.state = state;
|
|
178
216
|
this.engineState = state.engineState;
|
|
@@ -187,7 +225,7 @@ export class PrimaryInstance
|
|
|
187
225
|
return root.validationState.violations;
|
|
188
226
|
},
|
|
189
227
|
};
|
|
190
|
-
this.
|
|
228
|
+
this.instanceState = createPrimaryInstanceState(this);
|
|
191
229
|
|
|
192
230
|
childrenState.setChildren([root]);
|
|
193
231
|
setIsAttached(true);
|
|
@@ -231,12 +269,12 @@ export class PrimaryInstance
|
|
|
231
269
|
return this.setActiveLanguage(availableFormLanguage);
|
|
232
270
|
}
|
|
233
271
|
|
|
234
|
-
// PrimaryInstanceDocument
|
|
235
|
-
|
|
236
|
-
options?:
|
|
237
|
-
): Promise<
|
|
238
|
-
const result =
|
|
239
|
-
|
|
272
|
+
// PrimaryInstanceDocument
|
|
273
|
+
prepareInstancePayload<PayloadType extends InstancePayloadType = 'monolithic'>(
|
|
274
|
+
options?: InstancePayloadOptions<PayloadType>
|
|
275
|
+
): Promise<InstancePayload<PayloadType>> {
|
|
276
|
+
const result = prepareInstancePayload(this, {
|
|
277
|
+
payloadType: (options?.payloadType ?? 'monolithic') as PayloadType,
|
|
240
278
|
maxSize: options?.maxSize ?? Infinity,
|
|
241
279
|
});
|
|
242
280
|
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
} from '../client/RangeNode.ts';
|
|
9
9
|
import type { TextRange } from '../client/TextRange.ts';
|
|
10
10
|
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
11
|
+
import type { StaticLeafElement } from '../integration/xpath/static-dom/StaticElement.ts';
|
|
11
12
|
import { RangeCodec } from '../lib/codecs/RangeCodec.ts';
|
|
12
13
|
import { getSharedValueCodec } from '../lib/codecs/getSharedValueCodec.ts';
|
|
13
14
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
@@ -26,7 +27,7 @@ import { ValueNode, type ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
|
26
27
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
27
28
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
28
29
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
29
|
-
import type {
|
|
30
|
+
import type { ClientReactiveSerializableValueNode } from './internal-api/serialization/ClientReactiveSerializableValueNode.ts';
|
|
30
31
|
|
|
31
32
|
interface RangeControlStateSpec<V extends RangeValueType>
|
|
32
33
|
extends ValueNodeStateSpec<RangeValue<V>> {
|
|
@@ -42,14 +43,19 @@ export class RangeControl<V extends RangeValueType = RangeValueType>
|
|
|
42
43
|
XFormsXPathElement,
|
|
43
44
|
EvaluationContext,
|
|
44
45
|
ValidationContext,
|
|
45
|
-
|
|
46
|
+
ClientReactiveSerializableValueNode
|
|
46
47
|
{
|
|
47
|
-
static from(
|
|
48
|
+
static from(
|
|
49
|
+
parent: GeneralParentNode,
|
|
50
|
+
instanceNode: StaticLeafElement | null,
|
|
51
|
+
definition: AnyRangeNodeDefinition
|
|
52
|
+
): AnyRangeControl;
|
|
48
53
|
static from<V extends RangeValueType>(
|
|
49
54
|
parent: GeneralParentNode,
|
|
55
|
+
instanceNode: StaticLeafElement | null,
|
|
50
56
|
definition: RangeNodeDefinition<V>
|
|
51
57
|
): RangeControl<V> {
|
|
52
|
-
return new this<V>(parent, definition);
|
|
58
|
+
return new this<V>(parent, instanceNode, definition);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
// XFormsXPathElement
|
|
@@ -65,18 +71,18 @@ export class RangeControl<V extends RangeValueType = RangeValueType>
|
|
|
65
71
|
readonly nodeOptions = null;
|
|
66
72
|
readonly currentState: CurrentState<RangeControlStateSpec<V>>;
|
|
67
73
|
|
|
68
|
-
constructor(
|
|
74
|
+
constructor(
|
|
75
|
+
parent: GeneralParentNode,
|
|
76
|
+
instanceNode: StaticLeafElement | null,
|
|
77
|
+
definition: RangeNodeDefinition<V>
|
|
78
|
+
) {
|
|
69
79
|
const baseCodec = getSharedValueCodec(definition.valueType);
|
|
70
80
|
const codec = new RangeCodec(baseCodec, definition);
|
|
71
81
|
|
|
72
|
-
super(parent, definition, codec);
|
|
82
|
+
super(parent, instanceNode, definition, codec);
|
|
73
83
|
|
|
74
84
|
this.appearances = definition.bodyElement.appearances;
|
|
75
85
|
|
|
76
|
-
const sharedStateOptions = {
|
|
77
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
78
|
-
};
|
|
79
|
-
|
|
80
86
|
const state = createSharedNodeState(
|
|
81
87
|
this.scope,
|
|
82
88
|
{
|
|
@@ -92,7 +98,7 @@ export class RangeControl<V extends RangeValueType = RangeValueType>
|
|
|
92
98
|
value: this.valueState,
|
|
93
99
|
instanceValue: this.getInstanceValue,
|
|
94
100
|
},
|
|
95
|
-
|
|
101
|
+
this.instanceConfig
|
|
96
102
|
);
|
|
97
103
|
|
|
98
104
|
this.state = state;
|
|
@@ -3,7 +3,14 @@ import type { Accessor } from 'solid-js';
|
|
|
3
3
|
import { createMemo } from 'solid-js';
|
|
4
4
|
import type { RankDefinition, RankItem, RankNode, RankValueOptions } from '../client/RankNode.ts';
|
|
5
5
|
import type { TextRange } from '../client/TextRange.ts';
|
|
6
|
+
import type { ValueType } from '../client/ValueType.ts';
|
|
7
|
+
import { RankMissingValueError } from '../error/RankMissingValueError.ts';
|
|
8
|
+
import { RankValueTypeError } from '../error/RankValueTypeError.ts';
|
|
6
9
|
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
10
|
+
import type { StaticLeafElement } from '../integration/xpath/static-dom/StaticElement.ts';
|
|
11
|
+
import { sharedValueCodecs } from '../lib/codecs/getSharedValueCodec.ts';
|
|
12
|
+
import { MultipleValueItemCodec } from '../lib/codecs/items/MultipleValueItemCodec.ts';
|
|
13
|
+
import { createItemCollection } from '../lib/reactivity/createItemCollection.ts';
|
|
7
14
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
8
15
|
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
9
16
|
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
@@ -11,20 +18,14 @@ import { createSharedNodeState } from '../lib/reactivity/node-state/createShared
|
|
|
11
18
|
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
12
19
|
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
13
20
|
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
21
|
+
import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
14
22
|
import type { Root } from './Root.ts';
|
|
15
23
|
import type { ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
16
24
|
import { ValueNode } from './abstract/ValueNode.ts';
|
|
17
25
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
18
26
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
19
27
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
20
|
-
import type {
|
|
21
|
-
import { MultipleValueItemCodec } from '../lib/codecs/items/MultipleValueItemCodec.ts';
|
|
22
|
-
import { sharedValueCodecs } from '../lib/codecs/getSharedValueCodec.ts';
|
|
23
|
-
import { createItemCollection } from '../lib/reactivity/createItemCollection.ts';
|
|
24
|
-
import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
25
|
-
import type { ValueType } from '../client/ValueType.ts';
|
|
26
|
-
import { RankMissingValueError } from '../error/RankMissingValueError.ts';
|
|
27
|
-
import { RankValueTypeError } from '../error/RankValueTypeError.ts';
|
|
28
|
+
import type { ClientReactiveSerializableValueNode } from './internal-api/serialization/ClientReactiveSerializableValueNode.ts';
|
|
28
29
|
|
|
29
30
|
export type AnyRankDefinition = {
|
|
30
31
|
[V in ValueType]: RankDefinition<V>;
|
|
@@ -66,12 +67,20 @@ export class RankControl
|
|
|
66
67
|
XFormsXPathElement,
|
|
67
68
|
EvaluationContext,
|
|
68
69
|
ValidationContext,
|
|
69
|
-
|
|
70
|
+
ClientReactiveSerializableValueNode
|
|
70
71
|
{
|
|
71
|
-
static from(
|
|
72
|
-
|
|
72
|
+
static from(
|
|
73
|
+
parent: GeneralParentNode,
|
|
74
|
+
instanceNode: StaticLeafElement | null,
|
|
75
|
+
definition: RankDefinition
|
|
76
|
+
): RankControl;
|
|
77
|
+
static from(
|
|
78
|
+
parent: GeneralParentNode,
|
|
79
|
+
instanceNode: StaticLeafElement | null,
|
|
80
|
+
definition: AnyRankDefinition
|
|
81
|
+
): RankControl {
|
|
73
82
|
assertRankNodeDefinition(definition);
|
|
74
|
-
return new this(parent, definition);
|
|
83
|
+
return new this(parent, instanceNode, definition);
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
private readonly mapOptionsByValue: Accessor<RankItemMap>;
|
|
@@ -91,9 +100,13 @@ export class RankControl
|
|
|
91
100
|
readonly nodeOptions = null;
|
|
92
101
|
readonly currentState: CurrentState<RankControlStateSpec>;
|
|
93
102
|
|
|
94
|
-
private constructor(
|
|
103
|
+
private constructor(
|
|
104
|
+
parent: GeneralParentNode,
|
|
105
|
+
instanceNode: StaticLeafElement | null,
|
|
106
|
+
definition: RankDefinition<'string'>
|
|
107
|
+
) {
|
|
95
108
|
const codec = new MultipleValueItemCodec(sharedValueCodecs.string);
|
|
96
|
-
super(parent, definition, codec);
|
|
109
|
+
super(parent, instanceNode, definition, codec);
|
|
97
110
|
|
|
98
111
|
this.appearances = definition.bodyElement.appearances;
|
|
99
112
|
|
|
@@ -150,10 +163,6 @@ export class RankControl
|
|
|
150
163
|
return createMemo(() => codec.encodeValue(getValue()));
|
|
151
164
|
});
|
|
152
165
|
|
|
153
|
-
const sharedStateOptions = {
|
|
154
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
155
|
-
};
|
|
156
|
-
|
|
157
166
|
const state = createSharedNodeState(
|
|
158
167
|
this.scope,
|
|
159
168
|
{
|
|
@@ -168,7 +177,7 @@ export class RankControl
|
|
|
168
177
|
value: valueState,
|
|
169
178
|
instanceValue: this.getInstanceValue,
|
|
170
179
|
},
|
|
171
|
-
|
|
180
|
+
this.instanceConfig
|
|
172
181
|
);
|
|
173
182
|
|
|
174
183
|
this.state = state;
|
package/src/instance/Root.ts
CHANGED
|
@@ -3,16 +3,15 @@ import type { Accessor } from 'solid-js';
|
|
|
3
3
|
import type { ActiveLanguage, FormLanguage, FormLanguages } from '../client/FormLanguage.ts';
|
|
4
4
|
import type { FormNodeID } from '../client/identity.ts';
|
|
5
5
|
import type { RootNode } from '../client/RootNode.ts';
|
|
6
|
-
import type {
|
|
6
|
+
import type { InstancePayload } from '../client/serialization/InstancePayload.ts';
|
|
7
7
|
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from '../client/
|
|
11
|
-
import type {
|
|
12
|
-
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
8
|
+
InstancePayloadOptions,
|
|
9
|
+
InstancePayloadType,
|
|
10
|
+
} from '../client/serialization/InstancePayloadOptions.ts';
|
|
11
|
+
import type { InstanceState } from '../client/serialization/InstanceState.ts';
|
|
13
12
|
import type { AncestorNodeValidationState } from '../client/validation.ts';
|
|
14
13
|
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
15
|
-
import {
|
|
14
|
+
import { createRootInstanceState } from '../lib/client-reactivity/instance-state/createRootInstanceState.ts';
|
|
16
15
|
import type { ChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
17
16
|
import { createChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
18
17
|
import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
@@ -25,10 +24,10 @@ import { createAggregatedViolations } from '../lib/reactivity/validation/createA
|
|
|
25
24
|
import type { BodyClassList } from '../parse/body/BodyDefinition.ts';
|
|
26
25
|
import type { RootDefinition } from '../parse/model/RootDefinition.ts';
|
|
27
26
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
28
|
-
import { buildChildren } from './children.ts';
|
|
27
|
+
import { buildChildren } from './children/buildChildren.ts';
|
|
29
28
|
import type { GeneralChildNode } from './hierarchy.ts';
|
|
30
29
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
31
|
-
import type {
|
|
30
|
+
import type { ClientReactiveSerializableParentNode } from './internal-api/serialization/ClientReactiveSerializableParentNode.ts';
|
|
32
31
|
import type { TranslationContext } from './internal-api/TranslationContext.ts';
|
|
33
32
|
import type { PrimaryInstance } from './PrimaryInstance.ts';
|
|
34
33
|
|
|
@@ -54,7 +53,7 @@ export class Root
|
|
|
54
53
|
XFormsXPathElement,
|
|
55
54
|
EvaluationContext,
|
|
56
55
|
TranslationContext,
|
|
57
|
-
|
|
56
|
+
ClientReactiveSerializableParentNode<GeneralChildNode>
|
|
58
57
|
{
|
|
59
58
|
private readonly childrenState: ChildrenState<GeneralChildNode>;
|
|
60
59
|
|
|
@@ -80,22 +79,16 @@ export class Root
|
|
|
80
79
|
readonly classes: BodyClassList;
|
|
81
80
|
readonly currentState: MaterializedChildren<CurrentState<RootStateSpec>, GeneralChildNode>;
|
|
82
81
|
readonly validationState: AncestorNodeValidationState;
|
|
83
|
-
readonly
|
|
84
|
-
|
|
85
|
-
// ClientReactiveSubmittableInstance
|
|
86
|
-
get submissionDefinition(): SubmissionDefinition {
|
|
87
|
-
return this.definition.submission;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// RootNode
|
|
82
|
+
readonly instanceState: InstanceState;
|
|
91
83
|
readonly languages: FormLanguages;
|
|
92
84
|
|
|
93
85
|
constructor(parent: PrimaryInstance) {
|
|
94
|
-
const { definition } = parent;
|
|
86
|
+
const { definition, instanceNode: instance } = parent;
|
|
87
|
+
const instanceNode = instance.root;
|
|
95
88
|
const { nodeset: reference } = definition;
|
|
96
89
|
const computeReference: Accessor<string> = () => reference;
|
|
97
90
|
|
|
98
|
-
super(parent, definition, {
|
|
91
|
+
super(parent, instanceNode, definition, {
|
|
99
92
|
computeReference,
|
|
100
93
|
});
|
|
101
94
|
|
|
@@ -106,10 +99,6 @@ export class Root
|
|
|
106
99
|
this.childrenState = childrenState;
|
|
107
100
|
this.languages = parent.languages;
|
|
108
101
|
|
|
109
|
-
const sharedStateOptions = {
|
|
110
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
102
|
const state = createSharedNodeState(
|
|
114
103
|
this.scope,
|
|
115
104
|
{
|
|
@@ -124,7 +113,7 @@ export class Root
|
|
|
124
113
|
value: null,
|
|
125
114
|
children: childrenState.childIds,
|
|
126
115
|
},
|
|
127
|
-
|
|
116
|
+
this.instanceConfig
|
|
128
117
|
);
|
|
129
118
|
|
|
130
119
|
this.state = state;
|
|
@@ -136,8 +125,8 @@ export class Root
|
|
|
136
125
|
);
|
|
137
126
|
|
|
138
127
|
childrenState.setChildren(buildChildren(this));
|
|
139
|
-
this.validationState = createAggregatedViolations(this,
|
|
140
|
-
this.
|
|
128
|
+
this.validationState = createAggregatedViolations(this, this.instanceConfig);
|
|
129
|
+
this.instanceState = createRootInstanceState(this);
|
|
141
130
|
}
|
|
142
131
|
|
|
143
132
|
getChildren(): readonly GeneralChildNode[] {
|
|
@@ -151,9 +140,9 @@ export class Root
|
|
|
151
140
|
return this;
|
|
152
141
|
}
|
|
153
142
|
|
|
154
|
-
|
|
155
|
-
options?:
|
|
156
|
-
): Promise<
|
|
157
|
-
return this.rootDocument.
|
|
143
|
+
prepareInstancePayload<PayloadType extends InstancePayloadType = 'monolithic'>(
|
|
144
|
+
options?: InstancePayloadOptions<PayloadType>
|
|
145
|
+
): Promise<InstancePayload<PayloadType>> {
|
|
146
|
+
return this.rootDocument.prepareInstancePayload(options);
|
|
158
147
|
}
|
|
159
148
|
}
|