@getodk/xforms-engine 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/BaseNode.d.ts +14 -3
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -48
- package/dist/client/InputNode.d.ts +53 -0
- package/dist/client/ModelValueNode.d.ts +12 -7
- package/dist/client/NoteNode.d.ts +2 -2
- package/dist/client/RootNode.d.ts +34 -7
- package/dist/client/SelectNode.d.ts +2 -2
- package/dist/client/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -0
- package/dist/client/hierarchy.d.ts +4 -4
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/node-types.d.ts +2 -1
- package/dist/client/resources.d.ts +93 -0
- package/dist/client/submission/SubmissionData.d.ts +7 -0
- package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
- package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
- package/dist/client/submission/SubmissionOptions.d.ts +23 -0
- package/dist/client/submission/SubmissionResult.d.ts +91 -0
- package/dist/client/submission/SubmissionState.d.ts +12 -0
- package/dist/client/validation.d.ts +2 -2
- package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
- package/dist/error/ValueTypeInvariantError.d.ts +17 -0
- package/dist/error/XPathFunctionalityError.d.ts +14 -0
- package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
- package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +10856 -8585
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +9 -4
- package/dist/instance/InputControl.d.ts +36 -0
- package/dist/instance/ModelValue.d.ts +16 -26
- package/dist/instance/Note.d.ts +10 -3
- package/dist/instance/PrimaryInstance.d.ts +84 -0
- package/dist/instance/Root.d.ts +29 -25
- package/dist/instance/SelectField.d.ts +10 -2
- package/dist/instance/Subtree.d.ts +10 -5
- package/dist/instance/TriggerControl.d.ts +10 -3
- package/dist/instance/abstract/DescendantNode.d.ts +31 -23
- package/dist/instance/abstract/InstanceNode.d.ts +49 -29
- package/dist/instance/abstract/UnsupportedControl.d.ts +10 -3
- package/dist/instance/abstract/ValueNode.d.ts +48 -0
- package/dist/instance/hierarchy.d.ts +9 -8
- package/dist/instance/identity.d.ts +2 -7
- package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
- package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
- package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
- package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
- package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
- package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
- package/dist/instance/internal-api/ValueContext.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +31 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +18 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +17 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +39 -83
- package/dist/instance/repeat/RepeatInstance.d.ts +11 -29
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
- package/dist/instance/resource.d.ts +1 -1
- package/dist/instance/text/TextRange.d.ts +1 -1
- package/dist/instance/unsupported/RangeControl.d.ts +3 -1
- package/dist/instance/unsupported/RankControl.d.ts +3 -1
- package/dist/instance/unsupported/UploadControl.d.ts +3 -1
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
- package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
- package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
- package/dist/integration/xpath/adapter/kind.d.ts +32 -0
- package/dist/integration/xpath/adapter/names.d.ts +16 -0
- package/dist/integration/xpath/adapter/traversal.d.ts +25 -0
- package/dist/integration/xpath/adapter/values.d.ts +2 -0
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +19 -0
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +16 -0
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +40 -0
- package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +17 -0
- package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
- package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
- package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
- package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
- package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
- package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
- package/dist/lib/codecs/ValueCodec.d.ts +30 -0
- package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +47 -0
- package/dist/lib/dom/query.d.ts +3 -0
- package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
- package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
- package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
- package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
- package/dist/lib/reactivity/createValueState.d.ts +6 -10
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
- package/dist/lib/xml-serialization.d.ts +41 -0
- package/dist/parse/XFormDOM.d.ts +18 -7
- package/dist/parse/XFormDefinition.d.ts +1 -2
- package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
- package/dist/parse/body/BodyDefinition.d.ts +3 -3
- package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
- package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +1 -1
- package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -2
- package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
- package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
- package/dist/parse/model/BindDefinition.d.ts +4 -5
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +0 -1
- package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +3 -1
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/ModelDefinition.d.ts +2 -0
- package/dist/parse/model/NodeDefinition.d.ts +0 -1
- package/dist/parse/model/NoteNodeDefinition.d.ts +4 -4
- package/dist/parse/model/RootDefinition.d.ts +3 -2
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
- package/dist/parse/xpath/semantic-analysis.d.ts +5 -0
- package/dist/solid.js +8174 -5921
- package/dist/solid.js.map +1 -1
- package/package.json +13 -11
- package/src/client/BaseNode.ts +16 -6
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/InputNode.ts +77 -0
- package/src/client/ModelValueNode.ts +30 -7
- package/src/client/NoteNode.ts +2 -2
- package/src/client/RootNode.ts +37 -7
- package/src/client/SelectNode.ts +3 -3
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +5 -5
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +12 -6
- package/src/client/resources.ts +118 -0
- package/src/client/submission/SubmissionData.ts +12 -0
- package/src/client/submission/SubmissionDefinition.ts +16 -0
- package/src/client/submission/SubmissionInstanceFile.ts +9 -0
- package/src/client/submission/SubmissionOptions.ts +28 -0
- package/src/client/submission/SubmissionResult.ts +124 -0
- package/src/client/submission/SubmissionState.ts +14 -0
- package/src/client/validation.ts +2 -2
- package/src/error/ErrorProductionDesignPendingError.ts +6 -0
- package/src/error/ValueTypeInvariantError.ts +22 -0
- package/src/error/XPathFunctionalityError.ts +26 -0
- package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
- package/src/error/XPathFunctionalityPendingError.ts +18 -0
- package/src/index.ts +10 -1
- package/src/instance/Group.ts +17 -5
- package/src/instance/InputControl.ts +119 -0
- package/src/instance/ModelValue.ts +47 -54
- package/src/instance/Note.ts +24 -8
- package/src/instance/PrimaryInstance.ts +244 -0
- package/src/instance/Root.ts +62 -134
- package/src/instance/SelectField.ts +56 -19
- package/src/instance/Subtree.ts +19 -7
- package/src/instance/TriggerControl.ts +23 -6
- package/src/instance/abstract/DescendantNode.ts +90 -45
- package/src/instance/abstract/InstanceNode.ts +103 -105
- package/src/instance/abstract/UnsupportedControl.ts +28 -5
- package/src/instance/abstract/ValueNode.ts +127 -0
- package/src/instance/children.ts +9 -10
- package/src/instance/hierarchy.ts +19 -15
- package/src/instance/identity.ts +3 -9
- package/src/instance/index.ts +25 -7
- package/src/instance/internal-api/EvaluationContext.ts +60 -13
- package/src/instance/internal-api/InstanceConfig.ts +9 -2
- package/src/instance/internal-api/InstanceValueContext.ts +24 -0
- package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
- package/src/instance/internal-api/TranslationContext.ts +3 -2
- package/src/instance/internal-api/ValidationContext.ts +3 -4
- package/src/instance/internal-api/ValueContext.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +42 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +25 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +23 -0
- package/src/instance/repeat/BaseRepeatRange.ts +50 -131
- package/src/instance/repeat/RepeatInstance.ts +20 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
- package/src/instance/resource.ts +1 -1
- package/src/instance/text/TextChunk.ts +1 -1
- package/src/instance/unsupported/RangeControl.ts +5 -1
- package/src/instance/unsupported/RankControl.ts +5 -1
- package/src/instance/unsupported/UploadControl.ts +5 -1
- package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
- package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
- package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
- package/src/integration/xpath/adapter/kind.ts +114 -0
- package/src/integration/xpath/adapter/names.ts +99 -0
- package/src/integration/xpath/adapter/traversal.ts +228 -0
- package/src/integration/xpath/adapter/values.ts +5 -0
- package/src/integration/xpath/static-dom/StaticAttribute.ts +33 -0
- package/src/integration/xpath/static-dom/StaticDocument.ts +38 -0
- package/src/integration/xpath/static-dom/StaticElement.ts +106 -0
- package/src/integration/xpath/static-dom/StaticNamedNode.ts +45 -0
- package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
- package/src/integration/xpath/static-dom/StaticText.ts +28 -0
- package/src/lib/client-reactivity/README.md +0 -0
- package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
- package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
- package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
- package/src/lib/codecs/DecimalValueCodec.ts +46 -0
- package/src/lib/codecs/IntValueCodec.ts +100 -0
- package/src/lib/codecs/StringValueCodec.ts +11 -0
- package/src/lib/codecs/ValueCodec.ts +106 -0
- package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
- package/src/lib/codecs/getSharedValueCodec.ts +77 -0
- package/src/lib/dom/query.ts +7 -0
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +57 -34
- package/src/lib/reactivity/createInstanceValueState.ts +166 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- package/src/lib/reactivity/createSelectItems.ts +21 -21
- package/src/lib/reactivity/createTranslationState.ts +61 -0
- package/src/lib/reactivity/createValueState.ts +62 -120
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
- package/src/lib/reactivity/text/createTextRange.ts +4 -3
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
- package/src/lib/reactivity/validation/createValidation.ts +2 -3
- package/src/lib/xml-serialization.ts +96 -0
- package/src/parse/XFormDOM.ts +110 -75
- package/src/parse/XFormDefinition.ts +1 -6
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/parse/body/BodyDefinition.ts +3 -3
- package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
- package/src/parse/body/control/{InputDefinition.ts → InputControlDefinition.ts} +3 -5
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -5
- package/src/parse/expression/abstract/DependencyContext.ts +0 -26
- package/src/parse/expression/abstract/DependentExpression.ts +2 -13
- package/src/parse/model/BindDefinition.ts +5 -8
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/parse/model/DescendentNodeDefinition.ts +0 -6
- package/src/parse/model/FormSubmissionDefinition.ts +44 -0
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +41 -0
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
- package/src/parse/model/LeafNodeDefinition.ts +4 -1
- package/src/parse/model/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +6 -1
- package/src/parse/model/NodeDefinition.ts +0 -3
- package/src/parse/model/NoteNodeDefinition.ts +3 -3
- package/src/parse/model/RootDefinition.ts +2 -1
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
- package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +414 -0
- package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
- package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
- package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
- package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
- package/src/parse/xpath/semantic-analysis.ts +29 -0
- package/dist/client/StringNode.d.ts +0 -46
- package/dist/instance/StringField.d.ts +0 -44
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
- package/dist/parse/XFormDataType.d.ts +0 -25
- package/src/client/StringNode.ts +0 -52
- package/src/instance/StringField.ts +0 -120
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/parse/XFormDataType.ts +0 -62
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import { XFormsXPathNode } from '../adapter/XFormsXPathNode.ts';
|
|
3
|
+
import { StaticAttribute } from './StaticAttribute.ts';
|
|
4
|
+
import { StaticDocument } from './StaticDocument.ts';
|
|
5
|
+
import { StaticElement } from './StaticElement.ts';
|
|
6
|
+
import { StaticText } from './StaticText.ts';
|
|
7
|
+
export type StaticNodeKind = 'document' | 'element' | 'attribute' | 'text';
|
|
8
|
+
export type StaticNodeType<Kind extends StaticNodeKind> = `static-${Kind}`;
|
|
9
|
+
export declare abstract class StaticNode<Kind extends StaticNodeKind> implements XFormsXPathNode {
|
|
10
|
+
abstract readonly [XPathNodeKindKey]: Kind;
|
|
11
|
+
abstract readonly nodeType: StaticNodeType<Kind>;
|
|
12
|
+
/**
|
|
13
|
+
* A concrete {@link StaticDocument} instance, representing the topmost node
|
|
14
|
+
* of a static document tree, containing all of:
|
|
15
|
+
*
|
|
16
|
+
* - {@link root}
|
|
17
|
+
* - {@link children}
|
|
18
|
+
* - any {@link StaticChildNode} descendants of either of the above
|
|
19
|
+
*/
|
|
20
|
+
abstract readonly rootDocument: StaticDocument;
|
|
21
|
+
/**
|
|
22
|
+
* A concrete {@link StaticElement} instance, representing the single,
|
|
23
|
+
* immediate child of {@link rootDocument}, containing all other descendants
|
|
24
|
+
* of its document tree.
|
|
25
|
+
*/
|
|
26
|
+
abstract readonly root: StaticElement;
|
|
27
|
+
abstract readonly children: readonly StaticChildNode[] | null;
|
|
28
|
+
getXPathChildNodes(): readonly StaticChildNode[];
|
|
29
|
+
abstract getXPathValue(): string;
|
|
30
|
+
}
|
|
31
|
+
export type AnyStaticNode = StaticDocument | StaticElement | StaticAttribute | StaticText;
|
|
32
|
+
export type StaticParentNode = StaticDocument | StaticElement;
|
|
33
|
+
export type StaticChildNode = StaticElement | StaticText;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import { XFormsXPathText } from '../adapter/XFormsXPathNode.ts';
|
|
3
|
+
import { StaticDocument } from './StaticDocument.ts';
|
|
4
|
+
import { StaticElement } from './StaticElement.ts';
|
|
5
|
+
import { StaticNode } from './StaticNode.ts';
|
|
6
|
+
export declare class StaticText extends StaticNode<'text'> implements XFormsXPathText {
|
|
7
|
+
readonly parent: StaticElement;
|
|
8
|
+
readonly value: string;
|
|
9
|
+
readonly [XPathNodeKindKey] = "text";
|
|
10
|
+
readonly nodeType = "static-text";
|
|
11
|
+
readonly rootDocument: StaticDocument;
|
|
12
|
+
readonly root: StaticElement;
|
|
13
|
+
readonly children: null;
|
|
14
|
+
constructor(parent: StaticElement, value: string);
|
|
15
|
+
getXPathValue(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import { ClientReactiveSubmittableInstance } from '../../../instance/internal-api/submission/ClientReactiveSubmittableInstance.ts';
|
|
3
|
+
export declare const createInstanceSubmissionState: (node: ClientReactiveSubmittableInstance) => SubmissionState;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import { ClientReactiveSubmittableLeafNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
3
|
+
export declare const createLeafNodeSubmissionState: <Value>(node: ClientReactiveSubmittableLeafNode<Value>) => SubmissionState;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import { ClientReactiveSubmittableParentNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts';
|
|
3
|
+
import { RepeatInstance } from '../../../instance/repeat/RepeatInstance.ts';
|
|
4
|
+
export declare const createNodeRangeSubmissionState: (node: ClientReactiveSubmittableParentNode<RepeatInstance>) => SubmissionState;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import { GeneralChildNode } from '../../../instance/hierarchy.ts';
|
|
3
|
+
import { ClientReactiveSubmittableParentNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts';
|
|
4
|
+
export declare const createParentNodeSubmissionState: (node: ClientReactiveSubmittableParentNode<GeneralChildNode>) => SubmissionState;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import { ClientReactiveSubmittableValueNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts';
|
|
3
|
+
export declare const createValueNodeSubmissionState: (node: ClientReactiveSubmittableValueNode) => SubmissionState;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SubmissionChunkedType } from '../../../client/submission/SubmissionOptions.ts';
|
|
2
|
+
import { SubmissionResult } from '../../../client/submission/SubmissionResult.ts';
|
|
3
|
+
import { ClientReactiveSubmittableInstance } from '../../../instance/internal-api/submission/ClientReactiveSubmittableInstance.ts';
|
|
4
|
+
export interface PrepeareSubmissionOptions<ChunkedType extends SubmissionChunkedType> {
|
|
5
|
+
readonly chunked: ChunkedType;
|
|
6
|
+
readonly maxSize: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const prepareSubmission: <ChunkedType extends SubmissionChunkedType>(instanceRoot: ClientReactiveSubmittableInstance, options: PrepeareSubmissionOptions<ChunkedType>) => SubmissionResult<ChunkedType>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
2
|
+
export type DecimalInputValue = bigint | number | string | null;
|
|
3
|
+
export type DecimalRuntimeValue = number | null;
|
|
4
|
+
export declare class DecimalValueCodec extends ValueCodec<'decimal', DecimalRuntimeValue, DecimalInputValue> {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
2
|
+
export type IntInputValue = bigint | number | string | null;
|
|
3
|
+
export type IntRuntimeValue = bigint | null;
|
|
4
|
+
export declare class IntValueCodec extends ValueCodec<'int', IntRuntimeValue, IntInputValue> {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { ValueType } from '../../client/ValueType.ts';
|
|
3
|
+
import { DecodeInstanceValue } from '../../instance/internal-api/InstanceValueContext.ts';
|
|
4
|
+
import { SimpleAtomicState } from '../reactivity/types.ts';
|
|
5
|
+
type CodecEncoder<RuntimeInputValue> = (input: RuntimeInputValue) => string;
|
|
6
|
+
type CodecDecoder<RuntimeValue> = (value: string) => RuntimeValue;
|
|
7
|
+
type RuntimeValueAccessor<RuntimeValue> = Accessor<RuntimeValue>;
|
|
8
|
+
export type RuntimeValueSetter<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = (input: RuntimeInputValue) => RuntimeValue;
|
|
9
|
+
export type RuntimeValueState<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = readonly [
|
|
10
|
+
get: RuntimeValueAccessor<RuntimeValue>,
|
|
11
|
+
set: RuntimeValueSetter<RuntimeValue, RuntimeInputValue>
|
|
12
|
+
];
|
|
13
|
+
export type CreateRuntimeValueState<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = (instanceState: SimpleAtomicState<string>) => RuntimeValueState<RuntimeValue, RuntimeInputValue>;
|
|
14
|
+
type RuntimeValueStateFactory<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = (encodeValue: CodecEncoder<RuntimeInputValue>, decodeValue: CodecDecoder<RuntimeValue>) => CreateRuntimeValueState<RuntimeValue, RuntimeInputValue>;
|
|
15
|
+
type DecodeInstanceValueFactory<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = (encodeValue: CodecEncoder<RuntimeInputValue>, decodeValue: CodecDecoder<RuntimeValue>) => DecodeInstanceValue;
|
|
16
|
+
interface ValueCodecOptions<RuntimeValue extends RuntimeInputValue, RuntimeInputValue> {
|
|
17
|
+
readonly decodeInstanceValueFactory?: DecodeInstanceValueFactory<RuntimeValue, RuntimeInputValue>;
|
|
18
|
+
readonly runtimeValueStateFactory?: RuntimeValueStateFactory<RuntimeValue, RuntimeInputValue>;
|
|
19
|
+
}
|
|
20
|
+
export declare abstract class ValueCodec<V extends ValueType, RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> {
|
|
21
|
+
readonly valueType: V;
|
|
22
|
+
readonly encodeValue: CodecEncoder<RuntimeInputValue>;
|
|
23
|
+
readonly decodeValue: CodecDecoder<RuntimeValue>;
|
|
24
|
+
protected readonly defaultRuntimeValueStateFactory: RuntimeValueStateFactory<RuntimeValue, RuntimeInputValue>;
|
|
25
|
+
protected readonly defaultDecodeInstanceValueFactory: DecodeInstanceValueFactory<RuntimeValue, RuntimeInputValue>;
|
|
26
|
+
readonly decodeInstanceValue: DecodeInstanceValue;
|
|
27
|
+
readonly createRuntimeValueState: CreateRuntimeValueState<RuntimeValue, RuntimeInputValue>;
|
|
28
|
+
constructor(valueType: V, encodeValue: CodecEncoder<RuntimeInputValue>, decodeValue: CodecDecoder<RuntimeValue>, options?: ValueCodecOptions<RuntimeValue, RuntimeInputValue>);
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Provides fallback functionality where a {@link ValueCodec} is expected, for
|
|
5
|
+
* those {@link ValueType | value types} which are still pending implementation.
|
|
6
|
+
* This allows consistent use of the {@link ValueCodec} interface while
|
|
7
|
+
* maintaining the current behavior of treating those unimplemented value types
|
|
8
|
+
* as string values.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ValueTypePlaceholderCodec<V extends ValueType> extends ValueCodec<V, string, string> {
|
|
11
|
+
constructor(valueType: V);
|
|
12
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import { DecimalInputValue, DecimalRuntimeValue } from './DecimalValueCodec.ts';
|
|
3
|
+
import { IntInputValue, IntRuntimeValue } from './IntValueCodec.ts';
|
|
4
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
5
|
+
interface RuntimeValuesByType {
|
|
6
|
+
readonly string: string;
|
|
7
|
+
readonly int: IntRuntimeValue;
|
|
8
|
+
readonly decimal: DecimalRuntimeValue;
|
|
9
|
+
readonly boolean: string;
|
|
10
|
+
readonly date: string;
|
|
11
|
+
readonly time: string;
|
|
12
|
+
readonly dateTime: string;
|
|
13
|
+
readonly geopoint: string;
|
|
14
|
+
readonly geotrace: string;
|
|
15
|
+
readonly geoshape: string;
|
|
16
|
+
readonly binary: string;
|
|
17
|
+
readonly barcode: string;
|
|
18
|
+
readonly intent: string;
|
|
19
|
+
}
|
|
20
|
+
export type RuntimeValue<V extends ValueType> = RuntimeValuesByType[V];
|
|
21
|
+
interface RuntimeInputValuesByType {
|
|
22
|
+
readonly string: string;
|
|
23
|
+
readonly int: IntInputValue;
|
|
24
|
+
readonly decimal: DecimalInputValue;
|
|
25
|
+
readonly boolean: string;
|
|
26
|
+
readonly date: string;
|
|
27
|
+
readonly time: string;
|
|
28
|
+
readonly dateTime: string;
|
|
29
|
+
readonly geopoint: string;
|
|
30
|
+
readonly geotrace: string;
|
|
31
|
+
readonly geoshape: string;
|
|
32
|
+
readonly binary: string;
|
|
33
|
+
readonly barcode: string;
|
|
34
|
+
readonly intent: string;
|
|
35
|
+
}
|
|
36
|
+
export type RuntimeInputValue<V extends ValueType> = RuntimeInputValuesByType[V];
|
|
37
|
+
type SharedValueCodecs = {
|
|
38
|
+
readonly [V in ValueType]: ValueCodec<V, RuntimeValue<V>, RuntimeInputValue<V>>;
|
|
39
|
+
};
|
|
40
|
+
export type SharedValueCodec<V extends ValueType> = SharedValueCodecs[V];
|
|
41
|
+
/**
|
|
42
|
+
* Provides codecs for each {@link ValueType | value type}, for nodes with a
|
|
43
|
+
* common representation of those value types.
|
|
44
|
+
*/
|
|
45
|
+
export declare const sharedValueCodecs: SharedValueCodecs;
|
|
46
|
+
export declare const getSharedValueCodec: <V extends ValueType>(valueType: V) => SharedValueCodec<V>;
|
|
47
|
+
export {};
|
package/dist/lib/dom/query.d.ts
CHANGED
|
@@ -23,3 +23,6 @@ export declare const getLabelElement: (parent: Element) => LabelElement | null;
|
|
|
23
23
|
export declare const getRepeatGroupLabelElement: (parent: Element) => RepeatGroupLabelElement | null;
|
|
24
24
|
export declare const getRepeatElement: (parent: Element) => RepeatElement | null;
|
|
25
25
|
export declare const getValueElement: (parent: ItemElement | ItemsetElement) => ValueElement | null;
|
|
26
|
+
export interface SubmissionElement extends LocalNamedElement<'submission'> {
|
|
27
|
+
}
|
|
28
|
+
export declare const getSubmissionElement: (parent: Element) => SubmissionElement | null;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Accessor, Setter, Signal } from 'solid-js';
|
|
2
|
+
import { FormNodeID } from '../../client/identity.ts';
|
|
2
3
|
import { AnyChildNode, AnyParentNode } from '../../instance/hierarchy.ts';
|
|
3
|
-
import { NodeID } from '../../instance/identity.ts';
|
|
4
4
|
export interface ChildrenState<Child extends AnyChildNode> {
|
|
5
5
|
readonly children: Signal<readonly Child[]>;
|
|
6
6
|
readonly getChildren: Accessor<readonly Child[]>;
|
|
7
7
|
readonly setChildren: Setter<readonly Child[]>;
|
|
8
|
-
readonly childIds: Accessor<readonly
|
|
8
|
+
readonly childIds: Accessor<readonly FormNodeID[]>;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Creates a synchronized pair of:
|
|
12
12
|
*
|
|
13
13
|
* - Internal children state suitable for all parent node types
|
|
14
|
-
* - The same children state computed as an array of each child's
|
|
14
|
+
* - The same children state computed as an array of each child's
|
|
15
|
+
* {@link FormNodeID}
|
|
15
16
|
*
|
|
16
17
|
* This state is used, in tandem with {@link materializeCurrentStateChildren},
|
|
17
18
|
* to ensure children in **client-facing** state are not written into nested
|
|
@@ -26,11 +27,12 @@ export interface ChildrenState<Child extends AnyChildNode> {
|
|
|
26
27
|
* The produced {@link ChildrenState.childIds} memo is intended to be used to
|
|
27
28
|
* specify each parent node's `children` in an instance of {@link EngineState}.
|
|
28
29
|
* In so doing, the node's corresponding (internal, synchronized)
|
|
29
|
-
* {@link ClientState} will likewise store only the children's
|
|
30
|
+
* {@link ClientState} will likewise store only the children's
|
|
31
|
+
* {@link FormNodeID}s.
|
|
30
32
|
*
|
|
31
33
|
* As a client reacts to changes in a given parent node's `children` state, that
|
|
32
34
|
* node's {@link CurrentState} should produce the child nodes corresponding to
|
|
33
|
-
* those {@link
|
|
35
|
+
* those {@link FormNodeID}s with the aforementioned
|
|
34
36
|
* {@link materializeCurrentStateChildren}.
|
|
35
37
|
*/
|
|
36
38
|
export declare const createChildrenState: <Parent extends AnyParentNode, Child extends AnyChildNode>(parent: Parent) => ChildrenState<Child>;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import { Accessor } from 'solid-js';
|
|
2
2
|
import { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
4
4
|
import { DependentExpression, DependentExpressionResultType } from '../../parse/expression/abstract/DependentExpression.ts';
|
|
5
5
|
interface ComputedExpressionResults {
|
|
6
6
|
readonly boolean: boolean;
|
|
7
|
-
readonly nodes:
|
|
7
|
+
readonly nodes: EngineXPathNode[];
|
|
8
8
|
readonly number: number;
|
|
9
9
|
readonly string: string;
|
|
10
10
|
}
|
|
11
11
|
type EvaluatedExpression<Type extends DependentExpressionResultType> = ComputedExpressionResults[Type];
|
|
12
12
|
type ComputedExpression<Type extends DependentExpressionResultType> = Accessor<EvaluatedExpression<Type>>;
|
|
13
|
-
interface CreateComputedExpressionOptions {
|
|
14
|
-
|
|
13
|
+
interface CreateComputedExpressionOptions<Type extends DependentExpressionResultType> {
|
|
14
|
+
/**
|
|
15
|
+
* If a default value is provided, {@link createComputedExpression} will
|
|
16
|
+
* produce this value for computations in a non-attached evaluation context,
|
|
17
|
+
* i.e. when evaluating an expression against a node which has not yet been
|
|
18
|
+
* appended to its parents children state (or which has since been removed
|
|
19
|
+
* from that state). A non-attached state is detected when
|
|
20
|
+
* {@link EvaluationContext.isAttached} returns false.
|
|
21
|
+
*
|
|
22
|
+
* If no default value is provided, an implicit default value is produced as
|
|
23
|
+
* appropriate for the expression's intrinsic result type.
|
|
24
|
+
*
|
|
25
|
+
* @see {@link defaultEvaluationsByType} for these implicit defaults.
|
|
26
|
+
*/
|
|
27
|
+
readonly defaultValue?: EvaluatedExpression<Type>;
|
|
15
28
|
}
|
|
16
|
-
export declare const createComputedExpression: <Type extends DependentExpressionResultType>(context: EvaluationContext, dependentExpression: DependentExpression<Type>, options?: CreateComputedExpressionOptions) => ComputedExpression<Type>;
|
|
29
|
+
export declare const createComputedExpression: <Type extends DependentExpressionResultType>(context: EvaluationContext, dependentExpression: DependentExpression<Type>, options?: CreateComputedExpressionOptions<Type>) => ComputedExpression<Type>;
|
|
17
30
|
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InstanceValueContext } from '../../instance/internal-api/InstanceValueContext.ts';
|
|
2
|
+
import { SimpleAtomicState } from './types.ts';
|
|
3
|
+
type InitialValueSource = 'FORM_DEFAULT' | 'PRIMARY_INSTANCE';
|
|
4
|
+
export interface InstanceValueStateOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Specifies the source of a {@link createInstanceValueState} signal's initial
|
|
7
|
+
* value state, where:
|
|
8
|
+
*
|
|
9
|
+
* - 'FORM_DEFAULT': Derives the initial state from the form's definition of
|
|
10
|
+
* the node itself. This is the default option, appropriate when
|
|
11
|
+
* initializing a form without additional primary instance data. In other
|
|
12
|
+
* words, this value should not be used for edits.
|
|
13
|
+
*
|
|
14
|
+
* - 'PRIMARY_INSTANCE': Derives the initial state from the current text
|
|
15
|
+
* content of the {@link ValueNode.contextNode}. This option should be
|
|
16
|
+
* specified when initializing a form with existing primary instance data,
|
|
17
|
+
* such as when editing a previous submission.
|
|
18
|
+
*
|
|
19
|
+
* @default 'FORM_DEFAULT'
|
|
20
|
+
*
|
|
21
|
+
* Specifies whether a {@link createInstanceValueState} signal's initial state
|
|
22
|
+
* should be derived from the current text content of the
|
|
23
|
+
* {@link ValueNode.contextNode | primary instance DOM state}.
|
|
24
|
+
*/
|
|
25
|
+
readonly initialValueSource?: InitialValueSource;
|
|
26
|
+
}
|
|
27
|
+
export type InstanceValueState = SimpleAtomicState<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Provides a consistent interface for value nodes of any type which:
|
|
30
|
+
*
|
|
31
|
+
* - derives initial state from either an existing instance (e.g. for edits) or
|
|
32
|
+
* the node's definition (e.g. initializing a new submission)
|
|
33
|
+
* - decodes current primary instance state into the value node's runtime type
|
|
34
|
+
* - encodes updated runtime values to store updated instance state
|
|
35
|
+
* - initializes reactive computation of `calculate` bind expressions for those
|
|
36
|
+
* nodes defined with one
|
|
37
|
+
* - prevents downstream writes to nodes in a readonly state
|
|
38
|
+
*/
|
|
39
|
+
export declare const createInstanceValueState: (context: InstanceValueContext, options?: InstanceValueStateOptions) => InstanceValueState;
|
|
40
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Accessor } from 'solid-js';
|
|
2
2
|
import { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
|
|
3
|
-
import {
|
|
4
|
-
export declare const createNoteReadonlyThunk: (context: EvaluationContext,
|
|
3
|
+
import { NoteNodeDefinition } from '../../parse/model/NoteNodeDefinition.ts';
|
|
4
|
+
export declare const createNoteReadonlyThunk: (context: EvaluationContext, definition: NoteNodeDefinition) => Accessor<true>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { ActiveLanguage, FormLanguage, FormLanguages } from '../../client/FormLanguage.ts';
|
|
3
|
+
import { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
4
|
+
import { ReactiveScope } from './scope.ts';
|
|
5
|
+
import { SimpleAtomicStateSetter } from './types.ts';
|
|
6
|
+
interface TranslationState {
|
|
7
|
+
readonly languages: FormLanguages;
|
|
8
|
+
readonly getActiveLanguage: Accessor<ActiveLanguage>;
|
|
9
|
+
readonly setActiveLanguage: SimpleAtomicStateSetter<FormLanguage>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @todo It's been very silly all along that {@link XFormsXPathEvaluator} is
|
|
13
|
+
* responsible for parsing translation languages, and maintaining the active
|
|
14
|
+
* language state. It is especially silly now that we've moved _part of the
|
|
15
|
+
* parsing_ up to the constructor call site. Let's finish off that awkwardness
|
|
16
|
+
* in a subsequent refactor.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createTranslationState: (scope: ReactiveScope, evaluator: EngineXPathEvaluator) => TranslationState;
|
|
19
|
+
export {};
|
|
@@ -12,8 +12,7 @@ export interface ValueStateOptions {
|
|
|
12
12
|
* other words, this value should not be used for edits.
|
|
13
13
|
*
|
|
14
14
|
* - 'PRIMARY_INSTANCE': Derives the initial state from the current text
|
|
15
|
-
* content of the {@link ValueNode.contextNode}
|
|
16
|
-
* backing store/source of thruth for primary instance state). This option
|
|
15
|
+
* content of the {@link ValueNode.contextNode}. This option
|
|
17
16
|
* should be specified when initializing a form with existing primary
|
|
18
17
|
* instance data, such as when editing a previous submission.
|
|
19
18
|
*
|
|
@@ -29,16 +28,13 @@ type ValueState<RuntimeValue> = SimpleAtomicState<RuntimeValue>;
|
|
|
29
28
|
/**
|
|
30
29
|
* Provides a consistent interface for value nodes of any type which:
|
|
31
30
|
*
|
|
32
|
-
* - derives initial state from either
|
|
33
|
-
*
|
|
34
|
-
* - decodes primary instance state into the value node's runtime type
|
|
35
|
-
* - encodes
|
|
31
|
+
* - derives initial state from either an existing instance (e.g. for edits) or
|
|
32
|
+
* the node's definition (e.g. initializing a new submission)
|
|
33
|
+
* - decodes current primary instance state into the value node's runtime type
|
|
34
|
+
* - encodes updated runtime values to store updated instance state
|
|
36
35
|
* - initializes reactive computation of `calculate` bind expressions for those
|
|
37
36
|
* nodes defined with one
|
|
38
|
-
* -
|
|
39
|
-
* (whether performed by a client, or by a reactive `calculate` computation)
|
|
40
|
-
* are persisted, ensuring a consistent view of state when downstream
|
|
41
|
-
* computations perform XPath evaluations against that primary instance state
|
|
37
|
+
* - prevents downstream writes to nodes in a readonly state
|
|
42
38
|
*/
|
|
43
39
|
export declare const createValueState: <RuntimeValue>(context: ValueContext<RuntimeValue>, options?: ValueStateOptions) => ValueState<RuntimeValue>;
|
|
44
40
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { FormNodeID } from '../../client/identity.ts';
|
|
1
2
|
import { AnyChildNode } from '../../instance/hierarchy.ts';
|
|
2
|
-
import { NodeID } from '../../instance/identity.ts';
|
|
3
3
|
import { ChildrenState } from './createChildrenState.ts';
|
|
4
4
|
import { ReactiveScope } from './scope.ts';
|
|
5
5
|
export interface EncodedParentState {
|
|
6
|
-
readonly children: readonly
|
|
6
|
+
readonly children: readonly FormNodeID[];
|
|
7
7
|
}
|
|
8
8
|
export type MaterializedChildren<BaseState extends EncodedParentState, Child extends AnyChildNode | null> = Omit<BaseState, 'children'> & {
|
|
9
9
|
readonly children: readonly Child[];
|
|
@@ -11,8 +11,8 @@ export type MaterializedChildren<BaseState extends EncodedParentState, Child ext
|
|
|
11
11
|
/**
|
|
12
12
|
* Creates a wrapper proxy around a parent node's {@link CurrentState} to map
|
|
13
13
|
* `children` state, which is written to the node's (internal, synchronized)
|
|
14
|
-
* {@link ClientState} as an array of {@link
|
|
15
|
-
* corresponding to those IDs.
|
|
14
|
+
* {@link ClientState} as an array of {@link FormNodeID}s, back to the node
|
|
15
|
+
* objects corresponding to those IDs.
|
|
16
16
|
*
|
|
17
17
|
* @see {@link createChildrenState} for further detail.
|
|
18
18
|
*/
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare const ESCAPED_XML_TEXT_BRAND: unique symbol;
|
|
2
|
+
export type EscapedXMLText = string & {
|
|
3
|
+
readonly [ESCAPED_XML_TEXT_BRAND]: true;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* This is based on the `escapeHTML` implementation in
|
|
7
|
+
* {@link https://github.com/ryansolid/dom-expressions} (Solid's JSX transform).
|
|
8
|
+
*
|
|
9
|
+
* @see {@link https://github.com/ryansolid/dom-expressions/pull/27} for
|
|
10
|
+
* motivation to derive this implementation approach.
|
|
11
|
+
*
|
|
12
|
+
* The intent is that this can be updated easily if the base implementation
|
|
13
|
+
* changes. As such, some aspects of this implementation differ from some of our
|
|
14
|
+
* typical code style preferences.
|
|
15
|
+
*
|
|
16
|
+
* Notable changes from the base implementation:
|
|
17
|
+
*
|
|
18
|
+
* - Formatting: automated only.
|
|
19
|
+
* - Naming: the {@link text} parameter is named `html` in the base
|
|
20
|
+
* implementation. That would be confusing if preserved.
|
|
21
|
+
* - Types:
|
|
22
|
+
* - Parameter types are added (of course)
|
|
23
|
+
* - Return type is branded as {@link EscapedXMLText}, to allow downstream
|
|
24
|
+
* checks that escaping has been performed. Return statements are cast
|
|
25
|
+
* accordingly.
|
|
26
|
+
* - {@link text} attempts to minimize risk of double-escaping by excluding
|
|
27
|
+
* that same branded type.
|
|
28
|
+
* - The '>' character is also escaped, necessary for producing valid XML.
|
|
29
|
+
*
|
|
30
|
+
* As with the base implementation, we leave some characters unescaped:
|
|
31
|
+
*
|
|
32
|
+
* - " (double quote): except when {@link attr} is `true`.
|
|
33
|
+
*
|
|
34
|
+
* - ' (single quote): on the assumption that attributes are always serialized
|
|
35
|
+
* in double quotes. If we ever move this to `@getodk/common`, we'd want to
|
|
36
|
+
* reconsider this assumption.
|
|
37
|
+
*/
|
|
38
|
+
export declare const escapeXMLText: <Text extends string>(text: Exclude<Text, EscapedXMLText>, attr?: boolean) => EscapedXMLText;
|
|
39
|
+
export declare const serializeParentElementXML: (nodeName: string, serializedChildren: readonly string[]) => string;
|
|
40
|
+
export declare const serializeLeafElementXML: (nodeName: string, xmlValue: EscapedXMLText) => string;
|
|
41
|
+
export {};
|
package/dist/parse/XFormDOM.d.ts
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface
|
|
1
|
+
import { KnownAttributeLocalNamedElement } from '../../../common/types/dom.ts';
|
|
2
|
+
interface DOMBindElement extends KnownAttributeLocalNamedElement<'bind', 'nodeset'> {
|
|
3
|
+
}
|
|
4
|
+
export interface DOMItextTranslationElement extends KnownAttributeLocalNamedElement<'translation', 'lang'> {
|
|
5
|
+
}
|
|
6
|
+
export interface DOMSecondaryInstanceElement extends KnownAttributeLocalNamedElement<'instance', 'id'> {
|
|
7
|
+
}
|
|
8
|
+
interface XFormDOMOptions {
|
|
3
9
|
readonly isNormalized: boolean;
|
|
4
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @todo **Everything** in this class should be cacheable. Maybe not worth it
|
|
13
|
+
* for small forms, but may make a pretty substantial difference for very large
|
|
14
|
+
* forms (in bytes) in sessions creating multiple instances of the same form.
|
|
15
|
+
*/
|
|
5
16
|
export declare class XFormDOM {
|
|
6
17
|
protected readonly sourceXML: string;
|
|
7
18
|
static from(sourceXML: string): XFormDOM;
|
|
8
19
|
protected readonly normalizedXML: string;
|
|
9
|
-
readonly rootEvaluator: XFormsXPathEvaluator;
|
|
10
|
-
readonly primaryInstanceEvaluator: XFormsXPathEvaluator;
|
|
11
20
|
readonly xformDocument: XMLDocument;
|
|
12
21
|
readonly html: Element;
|
|
13
22
|
readonly head: Element;
|
|
14
23
|
readonly title: Element;
|
|
15
24
|
readonly model: Element;
|
|
25
|
+
readonly binds: readonly DOMBindElement[];
|
|
16
26
|
readonly primaryInstance: Element;
|
|
17
27
|
readonly primaryInstanceRoot: Element;
|
|
28
|
+
readonly itextTranslationElements: readonly DOMItextTranslationElement[];
|
|
29
|
+
readonly secondaryInstanceElements: readonly DOMSecondaryInstanceElement[];
|
|
18
30
|
readonly body: Element;
|
|
19
|
-
protected constructor(sourceXML: string, options:
|
|
20
|
-
|
|
21
|
-
toJSON(): Omit<this, "head" | "html" | "title" | "toJSON" | "model" | "primaryInstanceRoot" | "xformDocument" | "rootEvaluator" | "primaryInstanceEvaluator" | "primaryInstance" | "createInstance"> & {
|
|
31
|
+
protected constructor(sourceXML: string, options: XFormDOMOptions);
|
|
32
|
+
toJSON(): Omit<this, "head" | "html" | "title" | "toJSON" | "model" | "primaryInstanceRoot" | "primaryInstance" | "xformDocument"> & {
|
|
22
33
|
xformDocument: string;
|
|
23
34
|
html: string;
|
|
24
35
|
head: string;
|
|
@@ -2,7 +2,6 @@ import { BodyDefinition } from '../parse/body/BodyDefinition.ts';
|
|
|
2
2
|
import { ModelDefinition } from './model/ModelDefinition.ts';
|
|
3
3
|
import { XFormDOM } from './XFormDOM.ts';
|
|
4
4
|
export declare class XFormDefinition {
|
|
5
|
-
readonly sourceXML: string;
|
|
6
5
|
readonly xformDOM: XFormDOM;
|
|
7
6
|
readonly xformDocument: XMLDocument;
|
|
8
7
|
readonly id: string;
|
|
@@ -10,5 +9,5 @@ export declare class XFormDefinition {
|
|
|
10
9
|
readonly rootReference: string;
|
|
11
10
|
readonly body: BodyDefinition;
|
|
12
11
|
readonly model: ModelDefinition;
|
|
13
|
-
constructor(
|
|
12
|
+
constructor(xformDOM: XFormDOM);
|
|
14
13
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { JRResourceURL } from '../../../../common/src/jr-resources/JRResourceURL.ts';
|
|
2
|
+
export type FormAttachmentDataType = 'media' | 'secondary-instance';
|
|
3
|
+
/**
|
|
4
|
+
* @todo This type anticipates work to support media form attachments, which
|
|
5
|
+
* will tend to be associated with binary data. The
|
|
6
|
+
* expectation is that:
|
|
7
|
+
*
|
|
8
|
+
* - {@link Blob} would be appropriate for representing data from attachment
|
|
9
|
+
* resources which are conventionally loaded to completion (where network
|
|
10
|
+
* conditions are favorable), such as images
|
|
11
|
+
*
|
|
12
|
+
* - {@link MediaSource} or {@link ReadableStream} may be more appropriate for
|
|
13
|
+
* representing data from resources which are conventionally streamed in a
|
|
14
|
+
* browser context (often regardless of network conditions), such as video and
|
|
15
|
+
* audio
|
|
16
|
+
*/
|
|
17
|
+
export type FormAttachmentMediaData = Blob | MediaSource | ReadableStream<unknown>;
|
|
18
|
+
export type FormAttachmentSecondaryInstanceData = string;
|
|
19
|
+
type FormAttachmentData<DataType extends FormAttachmentDataType> = DataType extends 'media' ? FormAttachmentMediaData : FormAttachmentSecondaryInstanceData;
|
|
20
|
+
export declare abstract class FormAttachmentResource<DataType extends FormAttachmentDataType> {
|
|
21
|
+
readonly dataType: DataType;
|
|
22
|
+
readonly resourceURL: JRResourceURL;
|
|
23
|
+
readonly contentType: string;
|
|
24
|
+
readonly data: FormAttachmentData<DataType>;
|
|
25
|
+
protected constructor(dataType: DataType, resourceURL: JRResourceURL, contentType: string, data: FormAttachmentData<DataType>);
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParsedTokenList, TokenListParser } from '../../lib/TokenListParser.ts';
|
|
2
2
|
import { XFormDefinition } from '../../parse/XFormDefinition.ts';
|
|
3
3
|
import { DependencyContext } from '../expression/abstract/DependencyContext.ts';
|
|
4
|
-
import {
|
|
4
|
+
import { InputControlDefinition } from './control/InputControlDefinition.ts';
|
|
5
5
|
import { RangeControlDefinition } from './control/RangeControlDefinition.ts';
|
|
6
6
|
import { RankControlDefinition } from './control/RankControlDefinition.ts';
|
|
7
7
|
import { AnySelectDefinition } from './control/select/SelectDefinition.ts';
|
|
@@ -17,7 +17,7 @@ export interface BodyElementParentContext {
|
|
|
17
17
|
readonly reference: string | null;
|
|
18
18
|
readonly element: Element;
|
|
19
19
|
}
|
|
20
|
-
export type ControlElementDefinition = AnySelectDefinition |
|
|
20
|
+
export type ControlElementDefinition = AnySelectDefinition | InputControlDefinition | RangeControlDefinition | RankControlDefinition | TriggerControlDefinition | UploadControlDefinition;
|
|
21
21
|
type SupportedBodyElementDefinition = RepeatElementDefinition | LogicalGroupDefinition | PresentationGroupDefinition | StructuralGroupDefinition | ControlElementDefinition;
|
|
22
22
|
export type AnyBodyElementDefinition = SupportedBodyElementDefinition | UnsupportedBodyElementDefinition;
|
|
23
23
|
export type BodyElementDefinitionArray = readonly AnyBodyElementDefinition[];
|
|
@@ -70,6 +70,6 @@ export declare class BodyDefinition extends DependencyContext implements BodyEle
|
|
|
70
70
|
constructor(form: XFormDefinition);
|
|
71
71
|
getBodyElement(reference: string): AnyBodyElementDefinition | null;
|
|
72
72
|
getChildElementDefinitions(form: XFormDefinition, parent: BodyElementParentContext, parentElement: Element, children?: readonly Element[]): readonly AnyBodyElementDefinition[];
|
|
73
|
-
toJSON(): Omit<this, "form" | "
|
|
73
|
+
toJSON(): Omit<this, "form" | "toJSON" | "isTranslated" | "getBodyElement" | "getChildElementDefinitions">;
|
|
74
74
|
}
|
|
75
75
|
export {};
|
|
@@ -14,5 +14,5 @@ export declare class RepeatElementDefinition extends BodyElementDefinition<'repe
|
|
|
14
14
|
readonly noAddRemoveExpression: string | null;
|
|
15
15
|
readonly children: BodyElementDefinitionArray;
|
|
16
16
|
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
|
|
17
|
-
toJSON(): Omit<this, "parent" | "form" | "
|
|
17
|
+
toJSON(): Omit<this, "parent" | "form" | "toJSON" | "isTranslated">;
|
|
18
18
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TokenListParser, ParsedTokenList } from '../../../lib/TokenListParser.ts';
|
|
2
|
-
export declare const inputAppearanceParser: TokenListParser<"multiline" | "numbers" | "url" | "
|
|
2
|
+
export declare const inputAppearanceParser: TokenListParser<"multiline" | "numbers" | "url" | "thousands-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked", "multiline" | "numbers" | "url" | "thousands-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked">;
|
|
3
3
|
export type InputAppearanceDefinition = ParsedTokenList<typeof inputAppearanceParser>;
|
|
@@ -2,7 +2,7 @@ import { XFormDefinition } from '../../XFormDefinition.ts';
|
|
|
2
2
|
import { InputAppearanceDefinition } from '../appearance/inputAppearanceParser.ts';
|
|
3
3
|
import { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
4
4
|
import { ControlDefinition } from './ControlDefinition.ts';
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class InputControlDefinition extends ControlDefinition<'input'> {
|
|
6
6
|
static isCompatible(localName: string): boolean;
|
|
7
7
|
readonly type = "input";
|
|
8
8
|
readonly appearances: InputAppearanceDefinition;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DependencyContext } from '../../../expression/abstract/DependencyContext.ts';
|
|
2
|
-
import { AnyDependentExpression } from '../../../expression/abstract/DependentExpression.ts';
|
|
3
2
|
import { ItemsetDefinition } from './ItemsetDefinition.ts';
|
|
4
3
|
export declare class ItemsetNodesetContext extends DependencyContext {
|
|
5
4
|
protected readonly itemset: ItemsetDefinition;
|
|
@@ -7,5 +6,4 @@ export declare class ItemsetNodesetContext extends DependencyContext {
|
|
|
7
6
|
readonly reference: string;
|
|
8
7
|
constructor(itemset: ItemsetDefinition, nodesetExpression: string);
|
|
9
8
|
set isTranslated(value: true);
|
|
10
|
-
registerDependentExpression(expression: AnyDependentExpression): void;
|
|
11
9
|
}
|