@getodk/xforms-engine 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/client/BaseNode.d.ts +4 -0
- package/dist/client/BaseValueNode.d.ts +1 -1
- package/dist/client/GroupNode.d.ts +1 -0
- package/dist/client/InputNode.d.ts +32 -3
- package/dist/client/ModelValueNode.d.ts +1 -0
- package/dist/client/NoteNode.d.ts +24 -7
- package/dist/client/RangeNode.d.ts +36 -0
- package/dist/client/RankNode.d.ts +46 -0
- package/dist/client/RootNode.d.ts +6 -3
- package/dist/client/SelectNode.d.ts +47 -25
- package/dist/client/SubtreeNode.d.ts +1 -0
- package/dist/client/TriggerNode.d.ts +10 -6
- package/dist/client/hierarchy.d.ts +5 -5
- package/dist/client/node-types.d.ts +2 -2
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +1 -3
- package/dist/error/RankMissingValueError.d.ts +3 -0
- package/dist/error/RankValueTypeError.d.ts +6 -0
- package/dist/error/SelectValueTypeError.d.ts +15 -0
- package/dist/error/XFormsSpecViolationError.d.ts +2 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +5604 -4666
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +1 -0
- package/dist/instance/InputControl.d.ts +5 -3
- package/dist/instance/ModelValue.d.ts +2 -0
- package/dist/instance/Note.d.ts +13 -25
- package/dist/instance/PrimaryInstance.d.ts +1 -0
- package/dist/instance/RangeControl.d.ts +34 -0
- package/dist/instance/RankControl.d.ts +40 -0
- package/dist/instance/Root.d.ts +1 -0
- package/dist/instance/SelectControl.d.ts +66 -0
- package/dist/instance/Subtree.d.ts +1 -0
- package/dist/instance/TriggerControl.d.ts +9 -22
- package/dist/instance/abstract/DescendantNode.d.ts +1 -2
- package/dist/instance/abstract/InstanceNode.d.ts +3 -1
- package/dist/instance/abstract/UnsupportedControl.d.ts +1 -0
- package/dist/instance/abstract/ValueNode.d.ts +0 -1
- package/dist/instance/hierarchy.d.ts +9 -9
- package/dist/instance/internal-api/InstanceValueContext.d.ts +2 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +2 -1
- package/dist/instance/repeat/BaseRepeatRange.d.ts +1 -0
- package/dist/instance/repeat/RepeatInstance.d.ts +1 -0
- package/dist/integration/xpath/adapter/names.d.ts +1 -11
- package/dist/integration/xpath/adapter/traversal.d.ts +10 -9
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +10 -3
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +0 -1
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +12 -4
- package/dist/lib/client-reactivity/submission/createRootSubmissionState.d.ts +3 -0
- package/dist/lib/codecs/Geopoint/Geopoint.d.ts +48 -0
- package/dist/lib/codecs/Geopoint/GeopointValueCodec.d.ts +5 -0
- package/dist/lib/codecs/NoteCodec.d.ts +8 -0
- package/dist/lib/codecs/RangeCodec.d.ts +8 -0
- package/dist/lib/codecs/TriggerCodec.d.ts +7 -0
- package/dist/lib/codecs/ValueArrayCodec.d.ts +11 -0
- package/dist/lib/codecs/ValueCodec.d.ts +2 -2
- package/dist/lib/codecs/getNoteCodec.d.ts +3 -0
- package/dist/lib/codecs/getSelectCodec.d.ts +5 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +3 -2
- package/dist/lib/codecs/items/BaseItemCodec.d.ts +9 -0
- package/dist/lib/codecs/items/MultipleValueItemCodec.d.ts +14 -0
- package/dist/lib/codecs/items/SingleValueItemCodec.d.ts +24 -0
- package/dist/lib/dom/query.d.ts +1 -2
- package/dist/lib/names/NamespaceDeclaration.d.ts +45 -0
- package/dist/lib/names/NamespaceDeclarationMap.d.ts +137 -0
- package/dist/lib/names/NamespaceURL.d.ts +30 -0
- package/dist/lib/names/QualifiedName.d.ts +113 -0
- package/dist/lib/number-parsers.d.ts +2 -0
- package/dist/lib/reactivity/createItemCollection.d.ts +21 -0
- package/dist/lib/xml-serialization.d.ts +11 -2
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/body/BodyDefinition.d.ts +2 -2
- package/dist/parse/body/appearance/rangeAppearanceParser.d.ts +3 -0
- package/dist/parse/body/control/InputControlDefinition.d.ts +3 -0
- package/dist/parse/body/control/ItemDefinition.d.ts +14 -0
- package/dist/parse/body/control/ItemsetDefinition.d.ts +18 -0
- package/dist/parse/body/control/RangeControlDefinition.d.ts +31 -2
- package/dist/parse/body/control/RankControlDefinition.d.ts +7 -3
- package/dist/parse/body/control/{select/SelectDefinition.d.ts → SelectControlDefinition.d.ts} +9 -9
- package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -1
- package/dist/parse/expression/ItemsetValueExpression.d.ts +1 -1
- package/dist/parse/model/BindDefinition.d.ts +3 -1
- package/dist/parse/model/BindPreloadDefinition.d.ts +42 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +4 -13
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +2 -1
- package/dist/parse/model/LeafNodeDefinition.d.ts +7 -4
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/NodeDefinition.d.ts +16 -19
- package/dist/parse/model/NoteNodeDefinition.d.ts +6 -5
- package/dist/parse/model/RangeNodeDefinition.d.ts +41 -0
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatRangeDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +7 -4
- package/dist/parse/model/RootAttributeDefinition.d.ts +24 -0
- package/dist/parse/model/RootAttributeMap.d.ts +23 -0
- package/dist/parse/model/RootDefinition.d.ts +9 -7
- package/dist/parse/model/SubtreeDefinition.d.ts +7 -4
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +2 -3
- package/dist/parse/text/ItemLabelDefinition.d.ts +1 -1
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +2 -2
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +1 -1
- package/dist/parse/xpath/semantic-analysis.d.ts +1 -3
- package/dist/solid.js +5603 -4665
- package/dist/solid.js.map +1 -1
- package/package.json +15 -12
- package/src/client/BaseNode.ts +5 -0
- package/src/client/BaseValueNode.ts +1 -1
- package/src/client/GroupNode.ts +1 -0
- package/src/client/InputNode.ts +38 -2
- package/src/client/ModelValueNode.ts +1 -0
- package/src/client/NoteNode.ts +43 -7
- package/src/client/RangeNode.ts +51 -0
- package/src/client/RankNode.ts +54 -0
- package/src/client/RootNode.ts +11 -5
- package/src/client/SelectNode.ts +53 -26
- package/src/client/SubtreeNode.ts +1 -0
- package/src/client/TriggerNode.ts +12 -6
- package/src/client/hierarchy.ts +7 -8
- package/src/client/node-types.ts +1 -1
- package/src/client/unsupported/UnsupportedControlNode.ts +2 -6
- package/src/error/RankMissingValueError.ts +5 -0
- package/src/error/RankValueTypeError.ts +13 -0
- package/src/error/SelectValueTypeError.ts +22 -0
- package/src/error/XFormsSpecViolationError.ts +1 -0
- package/src/index.ts +2 -12
- package/src/instance/Group.ts +1 -0
- package/src/instance/InputControl.ts +42 -2
- package/src/instance/ModelValue.ts +2 -0
- package/src/instance/Note.ts +34 -59
- package/src/instance/PrimaryInstance.ts +1 -0
- package/src/instance/RangeControl.ts +113 -0
- package/src/instance/RankControl.ts +199 -0
- package/src/instance/Root.ts +3 -2
- package/src/instance/SelectControl.ts +219 -0
- package/src/instance/Subtree.ts +1 -0
- package/src/instance/TriggerControl.ts +36 -75
- package/src/instance/abstract/DescendantNode.ts +1 -6
- package/src/instance/abstract/InstanceNode.ts +10 -2
- package/src/instance/abstract/UnsupportedControl.ts +1 -0
- package/src/instance/abstract/ValueNode.ts +3 -2
- package/src/instance/children.ts +71 -30
- package/src/instance/hierarchy.ts +21 -16
- package/src/instance/internal-api/InstanceValueContext.ts +2 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +2 -1
- package/src/instance/repeat/BaseRepeatRange.ts +2 -0
- package/src/instance/repeat/RepeatInstance.ts +1 -0
- package/src/instance/resource.ts +4 -1
- package/src/integration/xpath/adapter/names.ts +66 -17
- package/src/integration/xpath/adapter/traversal.ts +10 -9
- package/src/integration/xpath/static-dom/StaticAttribute.ts +15 -7
- package/src/integration/xpath/static-dom/StaticDocument.ts +0 -2
- package/src/integration/xpath/static-dom/StaticElement.ts +21 -8
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +1 -1
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +1 -1
- package/src/lib/client-reactivity/submission/createRootSubmissionState.ts +19 -0
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +2 -2
- package/src/lib/codecs/Geopoint/Geopoint.ts +150 -0
- package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +20 -0
- package/src/lib/codecs/NoteCodec.ts +32 -0
- package/src/lib/codecs/RangeCodec.ts +65 -0
- package/src/lib/codecs/TriggerCodec.ts +64 -0
- package/src/lib/codecs/ValueArrayCodec.ts +42 -0
- package/src/lib/codecs/ValueCodec.ts +2 -2
- package/src/lib/codecs/getNoteCodec.ts +27 -0
- package/src/lib/codecs/getSelectCodec.ts +27 -0
- package/src/lib/codecs/getSharedValueCodec.ts +5 -3
- package/src/lib/codecs/items/BaseItemCodec.ts +20 -0
- package/src/lib/codecs/items/MultipleValueItemCodec.ts +28 -0
- package/src/lib/codecs/items/SingleValueItemCodec.ts +67 -0
- package/src/lib/dom/query.ts +1 -2
- package/src/lib/names/NamespaceDeclaration.ts +106 -0
- package/src/lib/names/NamespaceDeclarationMap.ts +228 -0
- package/src/lib/names/NamespaceURL.ts +44 -0
- package/src/lib/names/QualifiedName.ts +170 -0
- package/src/lib/number-parsers.ts +25 -0
- package/src/lib/reactivity/createInstanceValueState.ts +50 -0
- package/src/lib/reactivity/{createSelectItems.ts → createItemCollection.ts} +41 -36
- package/src/lib/xml-serialization.ts +76 -9
- package/src/parse/XFormDOM.ts +141 -21
- package/src/parse/XFormDefinition.ts +1 -4
- package/src/parse/body/BodyDefinition.ts +4 -4
- package/src/parse/body/appearance/rangeAppearanceParser.ts +11 -0
- package/src/parse/body/control/InputControlDefinition.ts +9 -0
- package/src/parse/body/control/{select/ItemDefinition.ts → ItemDefinition.ts} +8 -6
- package/src/parse/body/control/{select/ItemsetDefinition.ts → ItemsetDefinition.ts} +11 -9
- package/src/parse/body/control/RangeControlDefinition.ts +91 -6
- package/src/parse/body/control/RankControlDefinition.ts +25 -7
- package/src/parse/body/control/{select/SelectDefinition.ts → SelectControlDefinition.ts} +9 -9
- package/src/parse/expression/ItemsetNodesetExpression.ts +1 -1
- package/src/parse/expression/ItemsetValueExpression.ts +1 -1
- package/src/parse/model/BindDefinition.ts +4 -0
- package/src/parse/model/BindPreloadDefinition.ts +100 -0
- package/src/parse/model/DescendentNodeDefinition.ts +7 -25
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +2 -1
- package/src/parse/model/LeafNodeDefinition.ts +11 -4
- package/src/parse/model/NodeDefinition.ts +24 -45
- package/src/parse/model/NoteNodeDefinition.ts +8 -7
- package/src/parse/model/RangeNodeDefinition.ts +118 -0
- package/src/parse/model/RepeatInstanceDefinition.ts +11 -7
- package/src/parse/model/RepeatRangeDefinition.ts +11 -7
- package/src/parse/model/RepeatTemplateDefinition.ts +11 -7
- package/src/parse/model/RootAttributeDefinition.ts +45 -0
- package/src/parse/model/RootAttributeMap.ts +44 -0
- package/src/parse/model/RootDefinition.ts +29 -28
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +1 -0
- package/src/parse/model/SubtreeDefinition.ts +12 -12
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +3 -3
- package/src/parse/text/ItemLabelDefinition.ts +1 -1
- package/src/parse/text/ItemsetLabelDefinition.ts +2 -2
- package/src/parse/text/abstract/TextElementDefinition.ts +1 -1
- package/src/parse/xpath/semantic-analysis.ts +4 -3
- package/dist/client/unsupported/RangeNode.d.ts +0 -9
- package/dist/client/unsupported/RankNode.d.ts +0 -9
- package/dist/instance/SelectField.d.ts +0 -58
- package/dist/instance/unsupported/RangeControl.d.ts +0 -6
- package/dist/instance/unsupported/RankControl.d.ts +0 -6
- package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +0 -17
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -16
- package/dist/parse/body/control/select/ItemDefinition.d.ts +0 -13
- package/dist/parse/body/control/select/ItemsetDefinition.d.ts +0 -17
- package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -9
- package/src/client/unsupported/RangeNode.ts +0 -14
- package/src/client/unsupported/RankNode.ts +0 -14
- package/src/instance/SelectField.ts +0 -263
- package/src/instance/unsupported/RangeControl.ts +0 -9
- package/src/instance/unsupported/RankControl.ts +0 -9
- package/src/integration/xpath/static-dom/StaticNamedNode.ts +0 -45
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -21
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import { XFORMS_KNOWN_ATTRIBUTE, XFORMS_LOCAL_NAME, XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import { QualifiedName } from '../../../lib/names/QualifiedName.ts';
|
|
2
3
|
import { XFormsXPathElement } from '../adapter/XFormsXPathNode.ts';
|
|
3
4
|
import { StaticAttribute } from './StaticAttribute.ts';
|
|
4
|
-
import {
|
|
5
|
-
import { StaticChildNode, StaticParentNode } from './StaticNode.ts';
|
|
5
|
+
import { StaticDocument } from './StaticDocument.ts';
|
|
6
|
+
import { StaticChildNode, StaticParentNode, StaticNode } from './StaticNode.ts';
|
|
6
7
|
export type StaticElementAttributesFactory = (element: StaticElement) => readonly StaticAttribute[];
|
|
7
8
|
export type StaticElementChildNodesFactory = (element: StaticElement) => readonly StaticChildNode[];
|
|
8
|
-
export interface StaticElementOptions
|
|
9
|
+
export interface StaticElementOptions {
|
|
10
|
+
readonly namespaceURI: string | null;
|
|
11
|
+
readonly prefix?: string | null;
|
|
12
|
+
readonly localName: string;
|
|
9
13
|
}
|
|
10
14
|
type StaticElementKnownAttributeValue<T extends StaticElement, LocalName extends string> = T extends {
|
|
11
15
|
readonly [XFORMS_KNOWN_ATTRIBUTE]: LocalName;
|
|
12
16
|
} ? string : string | null;
|
|
13
|
-
export declare class StaticElement<Parent extends StaticParentNode = StaticParentNode> extends
|
|
17
|
+
export declare class StaticElement<Parent extends StaticParentNode = StaticParentNode> extends StaticNode<'element'> implements XFormsXPathElement {
|
|
18
|
+
readonly parent: Parent;
|
|
14
19
|
readonly [XFORMS_LOCAL_NAME]?: string;
|
|
15
20
|
readonly [XFORMS_KNOWN_ATTRIBUTE]?: string;
|
|
16
21
|
readonly [XPathNodeKindKey] = "element";
|
|
17
22
|
readonly nodeType = "static-element";
|
|
23
|
+
readonly rootDocument: StaticDocument;
|
|
18
24
|
readonly root: StaticElement;
|
|
25
|
+
readonly qualifiedName: QualifiedName;
|
|
19
26
|
readonly attributes: readonly StaticAttribute[];
|
|
20
27
|
readonly children: readonly StaticChildNode[];
|
|
28
|
+
readonly value: null;
|
|
21
29
|
constructor(parent: Parent, attributesFactory: StaticElementAttributesFactory, childNodesFactory: StaticElementChildNodesFactory, options: StaticElementOptions);
|
|
22
30
|
/**
|
|
23
31
|
* @todo Generalize this, incorporate into {@link EngineDOMAdapter}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This abstract class defines the minimal behavior for a default geopoint.
|
|
3
|
+
* It can be expanded later to support units (e.g., degrees or meters),
|
|
4
|
+
* which would also serve as documentation to clarify what each value represents.
|
|
5
|
+
*/
|
|
6
|
+
declare abstract class SemanticValue<Semantic extends string, Value extends number | null> {
|
|
7
|
+
readonly value: Value;
|
|
8
|
+
abstract readonly semantic: Semantic;
|
|
9
|
+
constructor(value: Value);
|
|
10
|
+
}
|
|
11
|
+
declare class Latitude extends SemanticValue<'latitude', number> {
|
|
12
|
+
readonly semantic = "latitude";
|
|
13
|
+
}
|
|
14
|
+
declare class Longitude extends SemanticValue<'longitude', number> {
|
|
15
|
+
readonly semantic = "longitude";
|
|
16
|
+
}
|
|
17
|
+
declare class Altitude<Value extends number | null = number> extends SemanticValue<'altitude', Value> {
|
|
18
|
+
readonly semantic = "altitude";
|
|
19
|
+
}
|
|
20
|
+
declare class Accuracy<Value extends number | null = number> extends SemanticValue<'accuracy', Value> {
|
|
21
|
+
readonly semantic = "accuracy";
|
|
22
|
+
}
|
|
23
|
+
export interface GeopointValue {
|
|
24
|
+
readonly latitude: number;
|
|
25
|
+
readonly longitude: number;
|
|
26
|
+
readonly altitude: number | null;
|
|
27
|
+
readonly accuracy: number | null;
|
|
28
|
+
}
|
|
29
|
+
export type GeopointRuntimeValue = GeopointValue | null;
|
|
30
|
+
export type GeopointInputValue = GeopointRuntimeValue | string;
|
|
31
|
+
type GeopointTuple = readonly [
|
|
32
|
+
latitude: Latitude,
|
|
33
|
+
longitude: Longitude,
|
|
34
|
+
altitude: Altitude<null> | Altitude<number>,
|
|
35
|
+
accuracy: Accuracy
|
|
36
|
+
] | readonly [latitude: Latitude, longitude: Longitude, altitude: Altitude] | readonly [latitude: Latitude, longitude: Longitude];
|
|
37
|
+
export declare class Geopoint {
|
|
38
|
+
private readonly internalValue;
|
|
39
|
+
constructor(coordinates: GeopointValue);
|
|
40
|
+
getTuple(): GeopointTuple;
|
|
41
|
+
getRuntimeValue(): GeopointRuntimeValue;
|
|
42
|
+
private isValidDegrees;
|
|
43
|
+
private isValidNumber;
|
|
44
|
+
private static isNullLocation;
|
|
45
|
+
static parseString(value: string): GeopointRuntimeValue;
|
|
46
|
+
static toCoordinatesString(value: GeopointInputValue): string;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import { RuntimeInputValue, RuntimeValue, SharedValueCodec } from './getSharedValueCodec.ts';
|
|
3
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
4
|
+
export type NoteRuntimeValue<V extends ValueType> = RuntimeValue<V> | null;
|
|
5
|
+
export type NoteInputValue<V extends ValueType> = RuntimeInputValue<V> | RuntimeValue<V> | null;
|
|
6
|
+
export declare class NoteCodec<V extends ValueType> extends ValueCodec<V, NoteRuntimeValue<V>, NoteInputValue<V>> {
|
|
7
|
+
constructor(baseCodec: SharedValueCodec<V>);
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RangeNodeDefinition, RangeValueType } from '../../parse/model/RangeNodeDefinition.ts';
|
|
2
|
+
import { RuntimeInputValue, RuntimeValue, SharedValueCodec } from './getSharedValueCodec.ts';
|
|
3
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
4
|
+
export type RangeRuntimeValue<V extends RangeValueType> = RuntimeValue<V>;
|
|
5
|
+
export type RangeInputValue<V extends RangeValueType> = RuntimeInputValue<V>;
|
|
6
|
+
export declare class RangeCodec<V extends RangeValueType> extends ValueCodec<V, RangeRuntimeValue<V>, RangeInputValue<V>> {
|
|
7
|
+
constructor(baseCodec: SharedValueCodec<V>, definition: RangeNodeDefinition<V>);
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ValueCodec } from './ValueCodec.ts';
|
|
2
|
+
export type TriggerValueType = 'string';
|
|
3
|
+
export type TriggerRuntimeValue = boolean;
|
|
4
|
+
export type TriggerInputValue = boolean | '' | null;
|
|
5
|
+
export declare class TriggerCodec extends ValueCodec<TriggerValueType, TriggerRuntimeValue, TriggerInputValue> {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import { RuntimeValue, SharedValueCodec } from './getSharedValueCodec.ts';
|
|
3
|
+
import { CodecDecoder, CodecEncoder, ValueCodec } from './ValueCodec.ts';
|
|
4
|
+
export type SplitInstanceValues = (value: string) => readonly string[];
|
|
5
|
+
export type JoinInstnaceValues = (values: readonly string[]) => string;
|
|
6
|
+
export type RuntimeItemValue<V extends ValueType> = NonNullable<RuntimeValue<V>>;
|
|
7
|
+
export type RuntimeValues<V extends ValueType> = ReadonlyArray<RuntimeItemValue<V>>;
|
|
8
|
+
export declare abstract class ValueArrayCodec<V extends ValueType, Values extends RuntimeValues<V> = RuntimeValues<V>> extends ValueCodec<V, Values, Values> {
|
|
9
|
+
readonly decodeItemValue: CodecDecoder<RuntimeItemValue<V>>;
|
|
10
|
+
constructor(baseCodec: SharedValueCodec<V>, encodeValue: CodecEncoder<Values>, decodeValue: CodecDecoder<Values>);
|
|
11
|
+
}
|
|
@@ -2,8 +2,8 @@ import { Accessor } from 'solid-js';
|
|
|
2
2
|
import { ValueType } from '../../client/ValueType.ts';
|
|
3
3
|
import { DecodeInstanceValue } from '../../instance/internal-api/InstanceValueContext.ts';
|
|
4
4
|
import { SimpleAtomicState } from '../reactivity/types.ts';
|
|
5
|
-
type CodecEncoder<RuntimeInputValue> = (input: RuntimeInputValue) => string;
|
|
6
|
-
type CodecDecoder<RuntimeValue> = (value: string) => RuntimeValue;
|
|
5
|
+
export type CodecEncoder<RuntimeInputValue> = (input: RuntimeInputValue) => string;
|
|
6
|
+
export type CodecDecoder<RuntimeValue> = (value: string) => RuntimeValue;
|
|
7
7
|
type RuntimeValueAccessor<RuntimeValue> = Accessor<RuntimeValue>;
|
|
8
8
|
export type RuntimeValueSetter<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = (input: RuntimeInputValue) => RuntimeValue;
|
|
9
9
|
export type RuntimeValueState<RuntimeValue extends RuntimeInputValue, RuntimeInputValue = RuntimeValue> = readonly [
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SelectDefinition } from '../../client/SelectNode.ts';
|
|
2
|
+
import { MultipleValueItemCodec } from './items/MultipleValueItemCodec.ts';
|
|
3
|
+
import { SingleValueItemCodec } from './items/SingleValueItemCodec.ts';
|
|
4
|
+
export type SelectCodec = MultipleValueItemCodec | SingleValueItemCodec;
|
|
5
|
+
export declare const getSelectCodec: (definition: SelectDefinition<"string">) => SelectCodec;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ValueType } from '../../client/ValueType.ts';
|
|
2
2
|
import { DecimalInputValue, DecimalRuntimeValue } from './DecimalValueCodec.ts';
|
|
3
|
+
import { GeopointInputValue, GeopointRuntimeValue } from './Geopoint/Geopoint.ts';
|
|
3
4
|
import { IntInputValue, IntRuntimeValue } from './IntValueCodec.ts';
|
|
4
5
|
import { ValueCodec } from './ValueCodec.ts';
|
|
5
6
|
interface RuntimeValuesByType {
|
|
@@ -10,7 +11,7 @@ interface RuntimeValuesByType {
|
|
|
10
11
|
readonly date: string;
|
|
11
12
|
readonly time: string;
|
|
12
13
|
readonly dateTime: string;
|
|
13
|
-
readonly geopoint:
|
|
14
|
+
readonly geopoint: GeopointRuntimeValue;
|
|
14
15
|
readonly geotrace: string;
|
|
15
16
|
readonly geoshape: string;
|
|
16
17
|
readonly binary: string;
|
|
@@ -26,7 +27,7 @@ interface RuntimeInputValuesByType {
|
|
|
26
27
|
readonly date: string;
|
|
27
28
|
readonly time: string;
|
|
28
29
|
readonly dateTime: string;
|
|
29
|
-
readonly geopoint:
|
|
30
|
+
readonly geopoint: GeopointInputValue;
|
|
30
31
|
readonly geotrace: string;
|
|
31
32
|
readonly geoshape: string;
|
|
32
33
|
readonly binary: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ValueType } from '../../../client/ValueType.ts';
|
|
2
|
+
import { SharedValueCodec } from '../getSharedValueCodec.ts';
|
|
3
|
+
import { ValueArrayCodec } from '../ValueArrayCodec.ts';
|
|
4
|
+
import { CodecDecoder, CodecEncoder } from '../ValueCodec.ts';
|
|
5
|
+
export type BaseItemValueType = 'string';
|
|
6
|
+
export type UnsupportedBaseItemValueType = Exclude<ValueType, BaseItemValueType>;
|
|
7
|
+
export declare abstract class BaseItemCodec<Values extends readonly string[] = readonly string[]> extends ValueArrayCodec<BaseItemValueType, Values> {
|
|
8
|
+
constructor(baseCodec: SharedValueCodec<'string'>, encodeValue: CodecEncoder<Values>, decodeValue: CodecDecoder<Values>);
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SharedValueCodec } from '../getSharedValueCodec.ts';
|
|
2
|
+
import { BaseItemCodec } from './BaseItemCodec.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Value codec implementation for `<select>` and `<odk:rank>` controls.
|
|
5
|
+
*
|
|
6
|
+
* This generalizes the application of a {@link SharedValueCodec} implementation
|
|
7
|
+
* over individual select and rank values, where those values are serialized as a
|
|
8
|
+
* whitespace-separated list. All other encoding and decoding logic is deferred
|
|
9
|
+
* to the provided {@link baseCodec}, ensuring that select and rank value types are
|
|
10
|
+
* treated consistently with the same underlying data types for other controls.
|
|
11
|
+
*/
|
|
12
|
+
export declare class MultipleValueItemCodec extends BaseItemCodec<readonly string[]> {
|
|
13
|
+
constructor(baseCodec: SharedValueCodec<'string'>);
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SharedValueCodec } from '../getSharedValueCodec.ts';
|
|
2
|
+
import { BaseItemCodec } from './BaseItemCodec.ts';
|
|
3
|
+
export type SingleValueSelectRuntimeValues = readonly [] | readonly [string];
|
|
4
|
+
/**
|
|
5
|
+
* @see {@link encodeValueFactory}
|
|
6
|
+
*/
|
|
7
|
+
type SingleValueSelectCodecValues = SingleValueSelectRuntimeValues | readonly string[];
|
|
8
|
+
/**
|
|
9
|
+
* Value codec implementation for `<select1>` controls.
|
|
10
|
+
*
|
|
11
|
+
* Note: this implementation is a specialization of the same principles
|
|
12
|
+
* underlying {@link MultipleValueItemCodec}. It is implemented separately:
|
|
13
|
+
*
|
|
14
|
+
* 1. to address a semantic difference between `<select>` and `<select1>`
|
|
15
|
+
* values: the former are serialized as a space-separated list, but that does
|
|
16
|
+
* not apply to the latter;
|
|
17
|
+
*
|
|
18
|
+
* 2. as an optimization, as the more general implementation performs poorly on
|
|
19
|
+
* forms which we monitor for performance.
|
|
20
|
+
*/
|
|
21
|
+
export declare class SingleValueItemCodec extends BaseItemCodec<SingleValueSelectCodecValues> {
|
|
22
|
+
constructor(baseCodec: SharedValueCodec<'string'>);
|
|
23
|
+
}
|
|
24
|
+
export {};
|
package/dist/lib/dom/query.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { KnownAttributeLocalNamedElement, LocalNamedElement } from '../../../../common/types/dom.ts';
|
|
2
|
-
import { SelectElement } from '../../parse/body/control/select/SelectDefinition';
|
|
3
2
|
export interface HintElement extends LocalNamedElement<'hint'> {
|
|
4
3
|
}
|
|
5
4
|
export interface ItemElement extends LocalNamedElement<'item'> {
|
|
@@ -17,7 +16,7 @@ export interface RepeatElement extends KnownAttributeLocalNamedElement<'repeat',
|
|
|
17
16
|
export interface ValueElement extends LocalNamedElement<'value'> {
|
|
18
17
|
}
|
|
19
18
|
export declare const getHintElement: (parent: Element) => HintElement | null;
|
|
20
|
-
export declare const getItemElements: (parent:
|
|
19
|
+
export declare const getItemElements: (parent: Element) => readonly ItemElement[];
|
|
21
20
|
export declare const getItemsetElement: (parent: Element) => ItemsetElement | null;
|
|
22
21
|
export declare const getLabelElement: (parent: Element) => LabelElement | null;
|
|
23
22
|
export declare const getRepeatGroupLabelElement: (parent: Element) => RepeatGroupLabelElement | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { NamespaceURI } from './QualifiedName.ts';
|
|
2
|
+
interface NamespaceDeclarationXMLSerializationOptions {
|
|
3
|
+
readonly omitDefaultNamespace?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface NamespaceDeclarationOptions {
|
|
6
|
+
readonly declaredPrefix: string | null;
|
|
7
|
+
readonly declaredURI: NamespaceURI;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Provides a generalized representation of an XML namespace declaration, which
|
|
11
|
+
* can be used for:
|
|
12
|
+
*
|
|
13
|
+
* - Resolution of a declared namespace URI, by its declared prefix
|
|
14
|
+
* - Resolution of a declared namespace prefix associated with its namespace URI
|
|
15
|
+
* - Scoped resolution of same in an arbitrary DOM-like tree of nodes (or
|
|
16
|
+
* representations thereof)
|
|
17
|
+
* - Serialization of the namespace declaration as an XML representation, as
|
|
18
|
+
* part of broader XML serialization logic from an arbitrary DOM-like tree of
|
|
19
|
+
* nodes (or representations thereof)
|
|
20
|
+
*
|
|
21
|
+
* @see {@link NamespaceDeclarationMap} for details on scoped usage
|
|
22
|
+
*/
|
|
23
|
+
export declare class NamespaceDeclaration {
|
|
24
|
+
private readonly serializedXML;
|
|
25
|
+
/**
|
|
26
|
+
* A namespace is declared as either:
|
|
27
|
+
*
|
|
28
|
+
* - a "default" namespace (for which no prefix is declared, in which case
|
|
29
|
+
* this value will be `null`)
|
|
30
|
+
*
|
|
31
|
+
* - a namespace prefix (for which the prefix can be used to reference the
|
|
32
|
+
* declared namespace, in which case this value will be a `string`)
|
|
33
|
+
*/
|
|
34
|
+
readonly declaredPrefix: string | null;
|
|
35
|
+
/**
|
|
36
|
+
* A namespace is declared for a {@link NamespaceURI}, i.e. either a
|
|
37
|
+
* {@link URL} or `null`, where `null` corresponds to the "null namespace"
|
|
38
|
+
* (i.e. `xmlns=""` or `xmlns:prefix=""`, in serialized XML).
|
|
39
|
+
*/
|
|
40
|
+
readonly declaredURI: NamespaceURI;
|
|
41
|
+
constructor(options: NamespaceDeclarationOptions);
|
|
42
|
+
declaresNamespaceURI(namespaceURI: NamespaceURI): boolean;
|
|
43
|
+
serializeNamespaceDeclarationXML(options?: NamespaceDeclarationXMLSerializationOptions): string;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { NamespaceDeclaration } from './NamespaceDeclaration.ts';
|
|
2
|
+
import { NamespaceURI, QualifiedName } from './QualifiedName.ts';
|
|
3
|
+
export interface NamedNodeDefinition {
|
|
4
|
+
readonly qualifiedName: QualifiedName;
|
|
5
|
+
}
|
|
6
|
+
type NamedNodeDefinitionMap = ReadonlyMap<QualifiedName, NamedNodeDefinition>;
|
|
7
|
+
export interface NamedSubtreeDefinition extends NamedNodeDefinition {
|
|
8
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
9
|
+
readonly parent: NamedSubtreeDefinition | null;
|
|
10
|
+
readonly attributes?: NamedNodeDefinitionMap;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @todo This is a bit of a code style experiment! Responsive to
|
|
14
|
+
* {@link https://github.com/getodk/web-forms/issues/296 | How should we represent enumerated types?}.
|
|
15
|
+
* Observations to be considered for that issue...
|
|
16
|
+
*
|
|
17
|
+
* This more or less works as one would expect, with one really irritating
|
|
18
|
+
* downside: unlike a **TypeScript `enum`**, code completions (in VSCode, but
|
|
19
|
+
* I'd expect the same for any TypeScript language server/LSP implementation)
|
|
20
|
+
* automatically suggest the bare string values rather than the equivalent
|
|
21
|
+
* syntax referencing the enumerations as defined here. Without care, it would
|
|
22
|
+
* be fairly trivial to lose consistency between the source "enum" and consuming
|
|
23
|
+
* code which we presume to be an exhaustive check (such as the `switch`
|
|
24
|
+
* statement operating on it below). This is somewhat mitigated for now by
|
|
25
|
+
* habitual use of {@link UnreachableError} (and would be better mitigated by a
|
|
26
|
+
* lint rule to enforce exhaustiveness checks over similar enumerations). But
|
|
27
|
+
* there is an obvious _stylistic mismatch_ between how an editor treats "thing
|
|
28
|
+
* shaped like `enum` but not semantically an `enum`", whereas there's no such
|
|
29
|
+
* mismatch in how it treats a plain "union of strings". If nothing else, that
|
|
30
|
+
* mismatch would tend to exacerbate exhaustiveness drift as an enumeration
|
|
31
|
+
* evolves.
|
|
32
|
+
*/
|
|
33
|
+
declare const DECLARE_NAMESPACE_RESULTS: {
|
|
34
|
+
readonly SUCCESS: "SUCCESS";
|
|
35
|
+
readonly HOISTED: "HOISTED";
|
|
36
|
+
readonly DEFERRED: "DEFERRED";
|
|
37
|
+
readonly REDUNDANT: "REDUNDANT";
|
|
38
|
+
readonly CONFLICT: "CONFLICT";
|
|
39
|
+
};
|
|
40
|
+
type DeclareNamespaceResultEnum = typeof DECLARE_NAMESPACE_RESULTS;
|
|
41
|
+
type DeclareNamespaceResult = DeclareNamespaceResultEnum[keyof DeclareNamespaceResultEnum];
|
|
42
|
+
export declare class NamespaceDeclarationMap extends Map<string | null, NamespaceDeclaration> {
|
|
43
|
+
readonly subtree: NamedSubtreeDefinition;
|
|
44
|
+
constructor(subtree: NamedSubtreeDefinition);
|
|
45
|
+
/**
|
|
46
|
+
* For any {@link definition | named node definition}, we can _infer_ a
|
|
47
|
+
* namespace declaration (rather than parsing it directly, which is error
|
|
48
|
+
* prone depending on parsing context) from that definition's
|
|
49
|
+
* {@link QualifiedName.namespaceURI} and {@link QualifiedName.prefix} (if the
|
|
50
|
+
* latter is defined).
|
|
51
|
+
*
|
|
52
|
+
* If a namespace declaration can be inferred, we "declare" (set, in
|
|
53
|
+
* {@link Map} semantics) it in **EITHER**:
|
|
54
|
+
*
|
|
55
|
+
* - An ancestor {@link NamedSubtreeDefinition | named subtree definition}'s
|
|
56
|
+
* {@link NamespaceDeclarationMap}: if such an ancestor exists and has no
|
|
57
|
+
* conflicting declaration for the same prefix; **OR**
|
|
58
|
+
* - This {@link NamespaceDeclarationMap}, if no suitable ancestor exists
|
|
59
|
+
*
|
|
60
|
+
* This can be described as "hoisting" the declaration to the uppermost node
|
|
61
|
+
* (or definitional representation of same) where it would be valid to declare
|
|
62
|
+
* the namespace for its prefix.
|
|
63
|
+
*
|
|
64
|
+
* In the following example, note that this logic applies for arbitrary tree
|
|
65
|
+
* structures satisfying the {@link NamedNodeDefinition} and
|
|
66
|
+
* {@link NamedSubtreeDefinition} interfaces. XML syntax is used to provide a
|
|
67
|
+
* concise explanation, but it should not be inferred that this is operating
|
|
68
|
+
* directly on an XML value (or any platform-native DOM structure of the
|
|
69
|
+
* same).
|
|
70
|
+
*
|
|
71
|
+
* @example Given an input tree like:
|
|
72
|
+
*
|
|
73
|
+
* ```xml
|
|
74
|
+
* <foo xmlns="https://example.com/DEFAULT_ONE">
|
|
75
|
+
* <bar:bat xmlns:bar="https://example.com/bar"/>
|
|
76
|
+
* <baz xmlns="https://example.com/DEFAULT_TWO"/>
|
|
77
|
+
* </foo>
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* The namespace declarations will be assigned as if they'd been declared
|
|
81
|
+
* like:
|
|
82
|
+
*
|
|
83
|
+
* ```xml
|
|
84
|
+
* <foo
|
|
85
|
+
* xmlns="https://example.com/DEFAULT_ONE"
|
|
86
|
+
* xmlns:bar="https://example.com/bar"
|
|
87
|
+
* >
|
|
88
|
+
* <!-- bar declaration has no conflict in foo, hoisted to parent -->
|
|
89
|
+
* <bar:bat/>
|
|
90
|
+
* <!-- default declaration conflicts with foo's default, not hoisted -->
|
|
91
|
+
* <baz xmlns="https://example.com/DEFAULT_TWO"/>
|
|
92
|
+
* </foo>
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* **IMPORTANT:** this behavior may seem overly complicated! It should be
|
|
96
|
+
* noted that the behavior:
|
|
97
|
+
*
|
|
98
|
+
* 1. ... is conceptually similar to behavior observable in a web standard
|
|
99
|
+
* WHAT Working Group DOM (as in browser DOM, XML DOM) implementation.
|
|
100
|
+
* There, serializing any subtree element will produce namespace
|
|
101
|
+
* declarations on the root element for any namespaces _referenced within
|
|
102
|
+
* its subtree but declared on an ancestor_. Note that in this case, the
|
|
103
|
+
* hierarchical behavior is inverted, but it demonstrates the same
|
|
104
|
+
* effective namespace scoping semantics.
|
|
105
|
+
*
|
|
106
|
+
* 2. ... vastly simplifies our ability to produce a compact XML
|
|
107
|
+
* representation from any arbitrary tree representation of its nodes.
|
|
108
|
+
* Hoisting namespace declarations to their uppermost scope, and
|
|
109
|
+
* deduplicating recursively up the ancestor tree, ensures that we only
|
|
110
|
+
* declare a given namespace once as it is referenced.
|
|
111
|
+
*
|
|
112
|
+
* @todo While this design is intended to help with producing compact
|
|
113
|
+
* serialized XML, at time of writing there is still an aspect which is
|
|
114
|
+
* unaddressed in the serialization logic: we assume namespace declarations
|
|
115
|
+
* are referenced if they've been parsed. This logic doesn't hold for nodes
|
|
116
|
+
* which are ultimately omitted from serialization, which would occur for
|
|
117
|
+
* non-relevant nodes, and repeat ranges with zero repeat instances (or any of
|
|
118
|
+
* their descendants). A future iteration of this same behavior could produce
|
|
119
|
+
* XML which is theoretically more compact, by performing the same declaration
|
|
120
|
+
* hoisting logic _dynamically at call time_ rather than at parse time.
|
|
121
|
+
*/
|
|
122
|
+
declareNamespace(definition: NamedNodeDefinition): DeclareNamespaceResult;
|
|
123
|
+
/**
|
|
124
|
+
* Given a {@link namespaceURI}, resolves a declared prefix (which may be
|
|
125
|
+
* `null`) for the {@link subtree} context **or any of its ancestors**. This
|
|
126
|
+
* is an important semantic detail:
|
|
127
|
+
*
|
|
128
|
+
* - Namespace declarations on a given subtree are effective for all of its
|
|
129
|
+
* descendants _until another declaration for the same prefix or namespace
|
|
130
|
+
* URI is encountered_
|
|
131
|
+
* - We "hoist" namespace declarations up to the uppermost {@link subtree}'s
|
|
132
|
+
* {@link NamespaceDeclarationMap} during parsing (as described in more
|
|
133
|
+
* detail on {@link declareNamespace}).
|
|
134
|
+
*/
|
|
135
|
+
lookupPrefix(namespaceURI: NamespaceURI): string | null;
|
|
136
|
+
}
|
|
137
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience wrapper to represent an XML namespace URI as a {@link URL}. This
|
|
3
|
+
* representation is used/responsible for:
|
|
4
|
+
*
|
|
5
|
+
* - normalized logic for XML semantics around special namespace URI values, in
|
|
6
|
+
* particular for consistent handling of the "null namespace" (input for such
|
|
7
|
+
* is accepted as either an empty string or `null`)
|
|
8
|
+
* - validation of input: a non-"null namespace" value will be rejected if it is
|
|
9
|
+
* not a valid URI string
|
|
10
|
+
* - type-level distinction between a namespace URI and a
|
|
11
|
+
* {@link NamespaceDeclaration.declaredPrefix | namespace declaration's prefix},
|
|
12
|
+
* as an aide to avoid using one in place of the other as e.g. a positional
|
|
13
|
+
* argument
|
|
14
|
+
*
|
|
15
|
+
* @todo Test the finer distinctions between "URL" and "URI"!
|
|
16
|
+
*
|
|
17
|
+
* @todo Probably not a huge deal in the scheme of things, but this is almost
|
|
18
|
+
* entirely pure overhead at runtime! The "validation" use case is kind of a
|
|
19
|
+
* stretch, and may well be wrong. The type-level distinction from a namespace
|
|
20
|
+
* prefix, however, has proved useful **quite a few times** during iteration of
|
|
21
|
+
* this change. If we can actually measure an impact, it might be worth instead
|
|
22
|
+
* considering "branded types" for the type-level distinct (in which case we
|
|
23
|
+
* could use a factory function to handle both the branding and special XML
|
|
24
|
+
* semantics).
|
|
25
|
+
*/
|
|
26
|
+
export declare class NamespaceURL extends URL {
|
|
27
|
+
static from(namespaceURI: NamespaceURL | string | null): NamespaceURL | null;
|
|
28
|
+
readonly href: string;
|
|
29
|
+
private constructor();
|
|
30
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { NamespaceURL } from './NamespaceURL.ts';
|
|
2
|
+
export type NamespaceURI = NamespaceURL | null;
|
|
3
|
+
export type QualifiedNamePrefix = string | null;
|
|
4
|
+
export interface NamespaceQualifiedNameSource {
|
|
5
|
+
readonly namespaceURI: NamespaceURI | string;
|
|
6
|
+
readonly localName: string;
|
|
7
|
+
/**
|
|
8
|
+
* Note that this property is intentionally optional as one of the
|
|
9
|
+
* {@link QualifiedNameSource | QualifiedName source input}, and its absence
|
|
10
|
+
* is treated differently from an explicitly assigned `null` value.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link SourcePrefixUnspecified}, {@link DeferredPrefix}
|
|
13
|
+
*/
|
|
14
|
+
readonly prefix?: QualifiedNamePrefix;
|
|
15
|
+
}
|
|
16
|
+
declare const SOURCE_PREFIX_UNSPECIFIED: unique symbol;
|
|
17
|
+
/**
|
|
18
|
+
* May be used as a placeholder for a {@link QualifiedName.prefix}, where the
|
|
19
|
+
* actual prefix may not be known at definition time.
|
|
20
|
+
*
|
|
21
|
+
* Example: parsing non-XML sources into an XML-like tree, e.g. for XPath
|
|
22
|
+
* evaluation; in which case, we may not need to resolve a prefix for the name
|
|
23
|
+
* until such a node is serialized as XML, if it ever is.
|
|
24
|
+
*/
|
|
25
|
+
type SourcePrefixUnspecified = typeof SOURCE_PREFIX_UNSPECIFIED;
|
|
26
|
+
/**
|
|
27
|
+
* Represents a {@link QualifiedName.prefix} whose resolution may be deferred,
|
|
28
|
+
* e.g. until all requisite parsing is complete and/or until XML serialization
|
|
29
|
+
* requires use of a prefix to represent the corresponding
|
|
30
|
+
* {@link QualifiedName.namespaceURI}.
|
|
31
|
+
*/
|
|
32
|
+
type DeferredPrefix = string | null | SourcePrefixUnspecified;
|
|
33
|
+
interface DeferredPrefixedQualifiedNameSource {
|
|
34
|
+
readonly namespaceURI: NamespaceURI | string;
|
|
35
|
+
readonly prefix: DeferredPrefix;
|
|
36
|
+
readonly localName: string;
|
|
37
|
+
}
|
|
38
|
+
export type QualifiedNameSource = NamespaceQualifiedNameSource | DeferredPrefixedQualifiedNameSource;
|
|
39
|
+
interface PrefixResolutionOptions {
|
|
40
|
+
lookupPrefix(namespaceURI: NamespaceURI | string): string | null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @todo This is in the `lib` directory because it's a cross-cutting concern,
|
|
44
|
+
* applicable to:
|
|
45
|
+
*
|
|
46
|
+
* - Parsing XML into a useful runtime data model (usage which motivated initial
|
|
47
|
+
* development of this class)
|
|
48
|
+
* - Serializing XML from a runtime data model (also motivated initial dev)
|
|
49
|
+
* - `@getodk/xpath` (internal) e.g. references to
|
|
50
|
+
* {@link https://www.w3.org/TR/REC-xml-names/#NT-QName | QName} in various
|
|
51
|
+
* parts of XPath expression _syntax_, as well as various parts of the package
|
|
52
|
+
* interpreting those parts of syntax
|
|
53
|
+
* - `@getodk/xpath` (cross-package), e.g. in aspects of the
|
|
54
|
+
* {@link XPathDOMAdapter} APIs, and implementations thereof
|
|
55
|
+
* - A zillion potential optimizations, e.g. where names are useful in a lookup
|
|
56
|
+
* table (or used in conjunction with other information to construct keys for
|
|
57
|
+
* same)
|
|
58
|
+
*
|
|
59
|
+
* @todo As a cross-cutting concern, there are subtle but important differences
|
|
60
|
+
* between certain XPath and XML semantics around expressions of a "null"
|
|
61
|
+
* {@link prefix}. E.g. in the expression `/foo`, **technically** the `foo` Step
|
|
62
|
+
* should select child elements _in the null namespace_, whereas in most other
|
|
63
|
+
* cases a null prefix (when explicitly assigned `null`, rather than
|
|
64
|
+
* {@link DeferredPrefix | deferred for later resolution}) is expected to
|
|
65
|
+
* correspond _to the default namespace_ (whatever that is in the context of the
|
|
66
|
+
* {@link QualifiedName | qualified-named thing}).
|
|
67
|
+
*
|
|
68
|
+
* @todo As a mechanism for many optimizations, an evolution of this class would
|
|
69
|
+
* be **BY FAR** most useful if it can be treated as a _value type_, despite
|
|
70
|
+
* challenges using non-primitives as such in a JS runtime. To be clear: it
|
|
71
|
+
* would be most useful if every instance of {@link QualifiedName} having the
|
|
72
|
+
* same property values (or in some cases, the same combined
|
|
73
|
+
* {@link namespaceURI}/{@link localName} or combined
|
|
74
|
+
* {@link prefix}/{@link localName}) would also have _reference equality_ with
|
|
75
|
+
* other instances having the same property values (or pertinent subset
|
|
76
|
+
* thereof). Making a somewhat obvious point explicit: this would be
|
|
77
|
+
* particularly useful in cases where a lookup table is implemented as a native
|
|
78
|
+
* {@link Map}, where using {@link QualifiedName} as a key would break
|
|
79
|
+
* expectations (and probably quite a lot of functionality!) if 2+ equivalent
|
|
80
|
+
* keys mapped to different values.
|
|
81
|
+
*
|
|
82
|
+
* @todo Where we would want to treat instances as a value type, it would be
|
|
83
|
+
* useful to look at prior art for representation of the same data as a string.
|
|
84
|
+
* One frame of reference worth looking at is
|
|
85
|
+
* {@link https://www.w3.org/TR/xpath-30/#prod-xpath30-URIQualifiedName | XPath 3.0's URIQualifiedName}
|
|
86
|
+
* (but note that this syntax is mutually exclusive with the prefixed `QName`).
|
|
87
|
+
*/
|
|
88
|
+
export declare class QualifiedName implements DeferredPrefixedQualifiedNameSource {
|
|
89
|
+
private readonly defaultPrefixResolutionOptions;
|
|
90
|
+
readonly namespaceURI: NamespaceURI;
|
|
91
|
+
/**
|
|
92
|
+
* @see {@link SourcePrefixUnspecified}, {@link DeferredPrefix}
|
|
93
|
+
*/
|
|
94
|
+
readonly prefix: DeferredPrefix;
|
|
95
|
+
readonly localName: string;
|
|
96
|
+
constructor(source: QualifiedNameSource);
|
|
97
|
+
/**
|
|
98
|
+
* @todo at time of writing, it's not expected we will actually supply
|
|
99
|
+
* {@link options} in calls to this method! Current calls are from definitions
|
|
100
|
+
* whose prefixes are known at parse time (i.e. they are prefixed in the
|
|
101
|
+
* source XML from which they're parsed).
|
|
102
|
+
*
|
|
103
|
+
* The intent of accepting the options here now is to leave a fairly large
|
|
104
|
+
* breadcrumb, for any use case where we might want to serialize XML from
|
|
105
|
+
* artificially constructed DOM-like trees (e.g. `StaticNode` implementations
|
|
106
|
+
* defined by parsing non-XML external secondary instances such as CSV and
|
|
107
|
+
* GeoJSON). AFAIK this doesn't correspond to any known feature in the "like
|
|
108
|
+
* Collect" scope, but it could have implications for inspecting form details
|
|
109
|
+
* in e.g. "debug/form design/dev mode" scenarios.
|
|
110
|
+
*/
|
|
111
|
+
getPrefixedName(options?: PrefixResolutionOptions): string;
|
|
112
|
+
}
|
|
113
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { SelectItem } from '../../client/SelectNode.ts';
|
|
3
|
+
import { RankItem } from '../../client/RankNode.ts';
|
|
4
|
+
import { SelectControl } from '../../instance/SelectControl.ts';
|
|
5
|
+
import { RankControl } from '../../instance/RankControl.ts';
|
|
6
|
+
export type ItemCollectionControl = RankControl | SelectControl;
|
|
7
|
+
type Item = RankItem | SelectItem;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a reactive computation of a {@link ItemCollectionControl}'s
|
|
10
|
+
* {@link Item}s, in support of the field's `valueOptions`.
|
|
11
|
+
*
|
|
12
|
+
* - The control defined with static `<item>`s will compute to an corresponding
|
|
13
|
+
* static list of items.
|
|
14
|
+
* - The control defined with a computed `<itemset>` will compute to a reactive list
|
|
15
|
+
* of items.
|
|
16
|
+
* - Items of both will produce {@link ItemType.label | labels} reactive to
|
|
17
|
+
* their appropriate dependencies (whether relative to the itemset item node,
|
|
18
|
+
* referencing a form's `itext` translations, etc).
|
|
19
|
+
*/
|
|
20
|
+
export declare const createItemCollection: (control: ItemCollectionControl) => Accessor<readonly Item[]>;
|
|
21
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NamespaceDeclarationMap } from './names/NamespaceDeclarationMap.ts';
|
|
2
|
+
import { QualifiedName } from './names/QualifiedName.ts';
|
|
1
3
|
declare const ESCAPED_XML_TEXT_BRAND: unique symbol;
|
|
2
4
|
export type EscapedXMLText = string & {
|
|
3
5
|
readonly [ESCAPED_XML_TEXT_BRAND]: true;
|
|
@@ -36,6 +38,13 @@ export type EscapedXMLText = string & {
|
|
|
36
38
|
* reconsider this assumption.
|
|
37
39
|
*/
|
|
38
40
|
export declare const escapeXMLText: <Text extends string>(text: Exclude<Text, EscapedXMLText>, attr?: boolean) => EscapedXMLText;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
interface SerializableElementAttribute {
|
|
42
|
+
serializeAttributeXML(): string;
|
|
43
|
+
}
|
|
44
|
+
interface ElementXMLSerializationOptions {
|
|
45
|
+
readonly namespaceDeclarations?: NamespaceDeclarationMap;
|
|
46
|
+
readonly attributes?: readonly SerializableElementAttribute[];
|
|
47
|
+
}
|
|
48
|
+
export declare const serializeParentElementXML: (qualifiedName: QualifiedName, serializedChildren: readonly string[], options?: ElementXMLSerializationOptions) => string;
|
|
49
|
+
export declare const serializeLeafElementXML: (qualifiedName: QualifiedName, xmlValue: EscapedXMLText, options?: ElementXMLSerializationOptions) => string;
|
|
41
50
|
export {};
|
package/dist/parse/XFormDOM.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare class XFormDOM {
|
|
|
29
29
|
readonly secondaryInstanceElements: readonly DOMSecondaryInstanceElement[];
|
|
30
30
|
readonly body: Element;
|
|
31
31
|
protected constructor(sourceXML: string, options: XFormDOMOptions);
|
|
32
|
-
toJSON(): Omit<this, "head" | "html" | "title" | "
|
|
32
|
+
toJSON(): Omit<this, "head" | "html" | "title" | "primaryInstance" | "model" | "primaryInstanceRoot" | "xformDocument" | "toJSON"> & {
|
|
33
33
|
xformDocument: string;
|
|
34
34
|
html: string;
|
|
35
35
|
head: string;
|