@getodk/xforms-engine 0.2.0 → 0.4.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 +69 -4
- package/dist/client/EngineConfig.d.ts +0 -1
- package/dist/client/GroupNode.d.ts +4 -3
- package/dist/client/ModelValueNode.d.ts +36 -0
- package/dist/client/NodeAppearances.d.ts +1 -2
- package/dist/client/NoteNode.d.ts +52 -0
- package/dist/client/RootNode.d.ts +4 -3
- package/dist/client/SelectNode.d.ts +6 -5
- package/dist/client/StringNode.d.ts +6 -5
- package/dist/client/SubtreeNode.d.ts +3 -2
- package/dist/client/TextRange.d.ts +85 -3
- package/dist/client/TriggerNode.d.ts +25 -0
- package/dist/client/constants.d.ts +8 -0
- package/dist/client/hierarchy.d.ts +19 -10
- package/dist/client/index.d.ts +0 -1
- package/dist/client/node-types.d.ts +3 -1
- package/dist/client/{RepeatRangeNode.d.ts → repeat/BaseRepeatRangeNode.d.ts} +18 -18
- package/dist/client/{RepeatInstanceNode.d.ts → repeat/RepeatInstanceNode.d.ts} +9 -9
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +18 -0
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +19 -0
- package/dist/client/unsupported/RangeNode.d.ts +9 -0
- package/dist/client/unsupported/RankNode.d.ts +9 -0
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +32 -0
- package/dist/client/unsupported/UploadNode.d.ts +9 -0
- package/dist/client/validation.d.ts +162 -0
- package/dist/index.d.ts +14 -6
- package/dist/index.js +39696 -36151
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +3 -2
- package/dist/instance/ModelValue.d.ts +39 -0
- package/dist/instance/Note.d.ts +41 -0
- package/dist/instance/Root.d.ts +5 -4
- package/dist/instance/SelectField.d.ts +11 -6
- package/dist/instance/StringField.d.ts +12 -7
- package/dist/instance/Subtree.d.ts +2 -1
- package/dist/instance/TriggerControl.d.ts +40 -0
- package/dist/instance/abstract/DescendantNode.d.ts +8 -10
- package/dist/instance/abstract/InstanceNode.d.ts +3 -2
- package/dist/instance/abstract/UnsupportedControl.d.ts +46 -0
- package/dist/instance/children.d.ts +0 -1
- package/dist/instance/hierarchy.d.ts +15 -6
- package/dist/instance/index.d.ts +0 -1
- package/dist/instance/internal-api/EvaluationContext.d.ts +0 -1
- package/dist/instance/internal-api/InstanceConfig.d.ts +0 -1
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -1
- package/dist/instance/internal-api/TranslationContext.d.ts +0 -1
- package/dist/instance/internal-api/ValidationContext.d.ts +28 -0
- package/dist/instance/internal-api/ValueContext.d.ts +3 -4
- package/dist/instance/{RepeatRange.d.ts → repeat/BaseRepeatRange.d.ts} +46 -46
- package/dist/instance/{RepeatInstance.d.ts → repeat/RepeatInstance.d.ts} +13 -13
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +15 -0
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +34 -0
- package/dist/instance/resource.d.ts +0 -1
- package/dist/instance/text/TextChunk.d.ts +0 -1
- package/dist/instance/text/TextRange.d.ts +4 -5
- package/dist/instance/unsupported/RangeControl.d.ts +4 -0
- package/dist/instance/unsupported/RankControl.d.ts +4 -0
- package/dist/instance/unsupported/UploadControl.d.ts +4 -0
- package/dist/lib/TokenListParser.d.ts +3 -3
- package/dist/lib/dom/query.d.ts +1 -2
- package/dist/lib/reactivity/createChildrenState.d.ts +0 -1
- package/dist/lib/reactivity/createComputedExpression.d.ts +7 -3
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +4 -0
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -1
- package/dist/lib/reactivity/createValueState.d.ts +0 -1
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createClientState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createCurrentState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createEngineState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +1 -2
- package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +1 -2
- package/dist/lib/reactivity/node-state/representations.d.ts +0 -1
- package/dist/lib/reactivity/scope.d.ts +0 -1
- package/dist/lib/reactivity/text/createFieldHint.d.ts +3 -4
- package/dist/lib/reactivity/text/createNodeLabel.d.ts +3 -4
- package/dist/lib/reactivity/text/createNoteText.d.ts +24 -0
- package/dist/lib/reactivity/text/createTextRange.d.ts +5 -8
- package/dist/lib/reactivity/types.d.ts +0 -1
- package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +8 -0
- package/dist/lib/reactivity/validation/createValidation.d.ts +17 -0
- package/dist/{XFormDOM.d.ts → parse/XFormDOM.d.ts} +1 -2
- package/dist/{XFormDataType.d.ts → parse/XFormDataType.d.ts} +2 -4
- package/dist/{XFormDefinition.d.ts → parse/XFormDefinition.d.ts} +2 -3
- package/dist/{body → parse/body}/BodyDefinition.d.ts +15 -10
- package/dist/{body → parse/body}/BodyElementDefinition.d.ts +8 -7
- package/dist/{body → parse/body}/RepeatElementDefinition.d.ts +4 -5
- package/dist/{body → parse/body}/UnsupportedBodyElementDefinition.d.ts +0 -1
- package/dist/{body → parse/body}/appearance/inputAppearanceParser.d.ts +1 -2
- package/dist/{body → parse/body}/appearance/selectAppearanceParser.d.ts +1 -2
- package/dist/{body → parse/body}/appearance/structureElementAppearanceParser.d.ts +1 -2
- package/dist/parse/body/appearance/unknownAppearanceParser.d.ts +3 -0
- package/dist/{body → parse/body}/control/ControlDefinition.d.ts +3 -4
- package/dist/{body → parse/body}/control/InputDefinition.d.ts +1 -2
- package/dist/parse/body/control/RangeControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/RankControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/TriggerControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/UploadControlDefinition.d.ts +11 -0
- package/dist/{body → parse/body}/control/select/ItemDefinition.d.ts +3 -4
- package/dist/{body → parse/body}/control/select/ItemsetDefinition.d.ts +7 -7
- package/dist/{body → parse/body}/control/select/ItemsetNodesetContext.d.ts +2 -3
- package/dist/{body → parse/body}/control/select/SelectDefinition.d.ts +3 -12
- package/dist/{body → parse/body}/group/BaseGroupDefinition.d.ts +3 -5
- package/dist/{body → parse/body}/group/LogicalGroupDefinition.d.ts +0 -1
- package/dist/{body → parse/body}/group/PresentationGroupDefinition.d.ts +1 -2
- package/dist/{body → parse/body}/group/StructuralGroupDefinition.d.ts +0 -1
- package/dist/{model/BindComputation.d.ts → parse/expression/BindComputationExpression.d.ts} +5 -6
- package/dist/{body/control/select → parse/expression}/ItemsetNodesetExpression.d.ts +2 -3
- package/dist/{body/control/select → parse/expression}/ItemsetValueExpression.d.ts +2 -3
- package/dist/parse/expression/RepeatCountControlExpression.d.ts +18 -0
- package/dist/parse/expression/TextLiteralExpression.d.ts +9 -0
- package/dist/parse/expression/TextOutputExpression.d.ts +7 -0
- package/dist/parse/expression/TextReferenceExpression.d.ts +7 -0
- package/dist/parse/expression/TextTranslationExpression.d.ts +8 -0
- package/dist/{expression → parse/expression/abstract}/DependencyContext.d.ts +0 -1
- package/dist/{expression → parse/expression/abstract}/DependentExpression.d.ts +13 -10
- package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
- package/dist/parse/model/BindDefinition.d.ts +39 -0
- package/dist/{model → parse/model}/BindElement.d.ts +1 -0
- package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -1
- package/dist/{model/ValueNodeDefinition.d.ts → parse/model/LeafNodeDefinition.d.ts} +3 -4
- package/dist/{model → parse/model}/ModelBindMap.d.ts +0 -1
- package/dist/{model → parse/model}/ModelDefinition.d.ts +1 -2
- package/dist/{model → parse/model}/NodeDefinition.d.ts +8 -9
- package/dist/parse/model/NoteNodeDefinition.d.ts +30 -0
- package/dist/{model → parse/model}/RepeatInstanceDefinition.d.ts +3 -4
- package/dist/{model → parse/model}/RepeatRangeDefinition.d.ts +14 -5
- package/dist/{model → parse/model}/RepeatTemplateDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/RootDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/SubtreeDefinition.d.ts +1 -2
- package/dist/parse/text/HintDefinition.d.ts +8 -0
- package/dist/parse/text/ItemLabelDefinition.d.ts +8 -0
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +12 -0
- package/dist/parse/text/LabelDefinition.d.ts +14 -0
- package/dist/parse/text/MessageDefinition.d.ts +14 -0
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +22 -0
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +34 -0
- package/dist/parse/xpath/dependency-analysis.d.ts +40 -0
- package/dist/parse/xpath/path-resolution.d.ts +69 -0
- package/dist/parse/xpath/predicate-analysis.d.ts +29 -0
- package/dist/parse/xpath/reference-parsing.d.ts +17 -0
- package/dist/parse/xpath/semantic-analysis.d.ts +97 -0
- package/dist/parse/xpath/syntax-traversal.d.ts +68 -0
- package/dist/solid.js +8745 -5186
- package/dist/solid.js.map +1 -1
- package/package.json +15 -16
- package/src/client/BaseNode.ts +74 -8
- package/src/client/GroupNode.ts +4 -2
- package/src/client/ModelValueNode.ts +40 -0
- package/src/client/NodeAppearances.ts +1 -1
- package/src/client/NoteNode.ts +74 -0
- package/src/client/README.md +1 -0
- package/src/client/RootNode.ts +4 -2
- package/src/client/SelectNode.ts +6 -4
- package/src/client/StringNode.ts +6 -4
- package/src/client/SubtreeNode.ts +3 -1
- package/src/client/TextRange.ts +98 -2
- package/src/client/TriggerNode.ts +29 -0
- package/src/client/constants.ts +10 -0
- package/src/client/hierarchy.ts +43 -15
- package/src/client/node-types.ts +17 -2
- package/src/client/{RepeatRangeNode.ts → repeat/BaseRepeatRangeNode.ts} +18 -19
- package/src/client/{RepeatInstanceNode.ts → repeat/RepeatInstanceNode.ts} +10 -8
- package/src/client/repeat/RepeatRangeControlledNode.ts +20 -0
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +21 -0
- package/src/client/unsupported/RangeNode.ts +14 -0
- package/src/client/unsupported/RankNode.ts +14 -0
- package/src/client/unsupported/UnsupportedControlNode.ts +40 -0
- package/src/client/unsupported/UploadNode.ts +14 -0
- package/src/client/validation.ts +199 -0
- package/src/index.ts +21 -9
- package/src/instance/Group.ts +10 -4
- package/src/instance/ModelValue.ts +104 -0
- package/src/instance/Note.ts +142 -0
- package/src/instance/Root.ts +16 -6
- package/src/instance/SelectField.ts +29 -7
- package/src/instance/StringField.ts +36 -10
- package/src/instance/Subtree.ts +9 -3
- package/src/instance/TriggerControl.ts +134 -0
- package/src/instance/abstract/DescendantNode.ts +9 -10
- package/src/instance/abstract/InstanceNode.ts +29 -7
- package/src/instance/abstract/UnsupportedControl.ts +151 -0
- package/src/instance/children.ts +113 -16
- package/src/instance/hierarchy.ts +42 -5
- package/src/instance/index.ts +1 -1
- package/src/instance/internal-api/EvaluationContext.ts +1 -1
- package/src/instance/internal-api/ValidationContext.ts +32 -0
- package/src/instance/internal-api/ValueContext.ts +3 -3
- package/src/instance/{RepeatRange.ts → repeat/BaseRepeatRange.ts} +114 -99
- package/src/instance/{RepeatInstance.ts → repeat/RepeatInstance.ts} +27 -22
- package/src/instance/repeat/RepeatRangeControlled.ts +82 -0
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +67 -0
- package/src/instance/text/TextRange.ts +10 -4
- package/src/instance/unsupported/RangeControl.ts +5 -0
- package/src/instance/unsupported/RankControl.ts +5 -0
- package/src/instance/unsupported/UploadControl.ts +5 -0
- package/src/lib/TokenListParser.ts +11 -7
- package/src/lib/dom/query.ts +1 -1
- package/src/lib/reactivity/createComputedExpression.ts +25 -27
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +33 -0
- package/src/lib/reactivity/createSelectItems.ts +23 -16
- package/src/lib/reactivity/createValueState.ts +3 -3
- package/src/lib/reactivity/node-state/createSharedNodeState.ts +1 -1
- package/src/lib/reactivity/node-state/createSpecifiedState.ts +1 -1
- package/src/lib/reactivity/text/createFieldHint.ts +9 -7
- package/src/lib/reactivity/text/createNodeLabel.ts +8 -6
- package/src/lib/reactivity/text/createNoteText.ts +72 -0
- package/src/lib/reactivity/text/createTextRange.ts +17 -90
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +75 -0
- package/src/lib/reactivity/validation/createValidation.ts +196 -0
- package/src/{XFormDataType.ts → parse/XFormDataType.ts} +1 -3
- package/src/{XFormDefinition.ts → parse/XFormDefinition.ts} +2 -2
- package/src/{body → parse/body}/BodyDefinition.ts +44 -27
- package/src/{body → parse/body}/BodyElementDefinition.ts +13 -6
- package/src/{body → parse/body}/RepeatElementDefinition.ts +10 -20
- package/src/{body → parse/body}/appearance/inputAppearanceParser.ts +1 -1
- package/src/{body → parse/body}/appearance/selectAppearanceParser.ts +1 -1
- package/src/{body → parse/body}/appearance/structureElementAppearanceParser.ts +1 -1
- package/src/parse/body/appearance/unknownAppearanceParser.ts +5 -0
- package/src/{body → parse/body}/control/ControlDefinition.ts +5 -4
- package/src/parse/body/control/RangeControlDefinition.ts +26 -0
- package/src/parse/body/control/RankControlDefinition.ts +27 -0
- package/src/parse/body/control/TriggerControlDefinition.ts +26 -0
- package/src/parse/body/control/UploadControlDefinition.ts +26 -0
- package/src/{body → parse/body}/control/select/ItemDefinition.ts +4 -4
- package/src/parse/body/control/select/ItemsetDefinition.ts +53 -0
- package/src/{body → parse/body}/control/select/ItemsetNodesetContext.ts +2 -2
- package/src/{body → parse/body}/control/select/SelectDefinition.ts +3 -11
- package/src/{body → parse/body}/group/BaseGroupDefinition.ts +11 -21
- package/src/{body → parse/body}/group/PresentationGroupDefinition.ts +1 -1
- package/src/{model/BindComputation.ts → parse/expression/BindComputationExpression.ts} +8 -12
- package/src/parse/expression/ItemsetNodesetExpression.ts +8 -0
- package/src/{body/control/select → parse/expression}/ItemsetValueExpression.ts +2 -2
- package/src/parse/expression/RepeatCountControlExpression.ts +44 -0
- package/src/parse/expression/TextLiteralExpression.ts +19 -0
- package/src/parse/expression/TextOutputExpression.ts +25 -0
- package/src/parse/expression/TextReferenceExpression.ts +14 -0
- package/src/parse/expression/TextTranslationExpression.ts +38 -0
- package/src/{expression → parse/expression/abstract}/DependentExpression.ts +46 -28
- package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
- package/src/{model → parse/model}/BindDefinition.ts +30 -27
- package/src/{model → parse/model}/BindElement.ts +1 -0
- package/src/{model/ValueNodeDefinition.ts → parse/model/LeafNodeDefinition.ts} +4 -4
- package/src/{model → parse/model}/ModelBindMap.ts +4 -0
- package/src/{model → parse/model}/NodeDefinition.ts +12 -12
- package/src/parse/model/NoteNodeDefinition.ts +70 -0
- package/src/{model → parse/model}/RepeatInstanceDefinition.ts +2 -2
- package/src/parse/model/RepeatRangeDefinition.ts +94 -0
- package/src/{model → parse/model}/RootDefinition.ts +8 -4
- package/src/parse/text/HintDefinition.ts +25 -0
- package/src/parse/text/ItemLabelDefinition.ts +25 -0
- package/src/parse/text/ItemsetLabelDefinition.ts +44 -0
- package/src/parse/text/LabelDefinition.ts +61 -0
- package/src/parse/text/MessageDefinition.ts +49 -0
- package/src/parse/text/abstract/TextElementDefinition.ts +71 -0
- package/src/parse/text/abstract/TextRangeDefinition.ts +70 -0
- package/src/parse/xpath/dependency-analysis.ts +105 -0
- package/src/parse/xpath/path-resolution.ts +475 -0
- package/src/parse/xpath/predicate-analysis.ts +61 -0
- package/src/parse/xpath/reference-parsing.ts +90 -0
- package/src/parse/xpath/semantic-analysis.ts +466 -0
- package/src/parse/xpath/syntax-traversal.ts +129 -0
- package/dist/body/text/HintDefinition.d.ts +0 -11
- package/dist/body/text/LabelDefinition.d.ts +0 -22
- package/dist/body/text/TextElementDefinition.d.ts +0 -33
- package/dist/body/text/TextElementOutputPart.d.ts +0 -13
- package/dist/body/text/TextElementPart.d.ts +0 -13
- package/dist/body/text/TextElementReferencePart.d.ts +0 -7
- package/dist/body/text/TextElementStaticPart.d.ts +0 -7
- package/dist/lib/xpath/analysis.d.ts +0 -23
- package/dist/model/BindDefinition.d.ts +0 -32
- package/src/body/control/select/ItemsetDefinition.ts +0 -36
- package/src/body/control/select/ItemsetNodesetExpression.ts +0 -8
- package/src/body/text/HintDefinition.ts +0 -26
- package/src/body/text/LabelDefinition.ts +0 -68
- package/src/body/text/TextElementDefinition.ts +0 -97
- package/src/body/text/TextElementOutputPart.ts +0 -27
- package/src/body/text/TextElementPart.ts +0 -31
- package/src/body/text/TextElementReferencePart.ts +0 -21
- package/src/body/text/TextElementStaticPart.ts +0 -26
- package/src/lib/xpath/analysis.ts +0 -241
- package/src/model/RepeatRangeDefinition.ts +0 -53
- package/src/{XFormDOM.ts → parse/XFormDOM.ts} +0 -0
- package/src/{body → parse/body}/UnsupportedBodyElementDefinition.ts +0 -0
- package/src/{body → parse/body}/control/InputDefinition.ts +1 -1
- /package/src/{body → parse/body}/group/LogicalGroupDefinition.ts +0 -0
- /package/src/{body → parse/body}/group/StructuralGroupDefinition.ts +0 -0
- /package/src/{expression → parse/expression/abstract}/DependencyContext.ts +0 -0
- /package/src/{model → parse/model}/DescendentNodeDefinition.ts +0 -0
- /package/src/{model → parse/model}/ModelDefinition.ts +0 -0
- /package/src/{model → parse/model}/RepeatTemplateDefinition.ts +0 -0
- /package/src/{model → parse/model}/SubtreeDefinition.ts +0 -0
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError';
|
|
2
|
-
import { expressionParser } from '@getodk/xpath/expressionParser.js';
|
|
3
|
-
import type {
|
|
4
|
-
AbsoluteLocationPathNode,
|
|
5
|
-
AnyBinaryExprNode,
|
|
6
|
-
AnySyntaxNode,
|
|
7
|
-
FilterPathExprNode,
|
|
8
|
-
LocalPartNode,
|
|
9
|
-
PrefixedNameNode,
|
|
10
|
-
RelativeLocationPathNode,
|
|
11
|
-
UnprefixedNameNode,
|
|
12
|
-
} from '@getodk/xpath/static/grammar/SyntaxNode.js';
|
|
13
|
-
import type { AnyBinaryExprType } from '@getodk/xpath/static/grammar/type-names.js';
|
|
14
|
-
|
|
15
|
-
export type SingleChildNode = Extract<
|
|
16
|
-
AnySyntaxNode,
|
|
17
|
-
{ readonly children: readonly [AnySyntaxNode] }
|
|
18
|
-
>;
|
|
19
|
-
|
|
20
|
-
const isSingleNodeChild = (node: AnySyntaxNode): node is SingleChildNode => {
|
|
21
|
-
return node.childCount === 1;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const binaryExprNodeTypes = new Set<AnyBinaryExprType>([
|
|
25
|
-
'addition_expr',
|
|
26
|
-
'and_expr',
|
|
27
|
-
'division_expr',
|
|
28
|
-
'eq_expr',
|
|
29
|
-
'gt_expr',
|
|
30
|
-
'gte_expr',
|
|
31
|
-
'lt_expr',
|
|
32
|
-
'lte_expr',
|
|
33
|
-
'modulo_expr',
|
|
34
|
-
'multiplication_expr',
|
|
35
|
-
'ne_expr',
|
|
36
|
-
'or_expr',
|
|
37
|
-
'subtraction_expr',
|
|
38
|
-
'union_expr',
|
|
39
|
-
]);
|
|
40
|
-
|
|
41
|
-
const isBinaryExprNode = (node: AnySyntaxNode): node is AnyBinaryExprNode => {
|
|
42
|
-
return binaryExprNodeTypes.has(node.type as AnyBinaryExprType);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const matchesLocalName = (
|
|
46
|
-
localName: string,
|
|
47
|
-
nameNode: PrefixedNameNode | UnprefixedNameNode
|
|
48
|
-
): boolean => {
|
|
49
|
-
const localPartNode: LocalPartNode | UnprefixedNameNode =
|
|
50
|
-
nameNode.type === 'prefixed_name' ? nameNode.children[1] : nameNode;
|
|
51
|
-
|
|
52
|
-
return localPartNode.text === localName;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const isFunctionCalled = (localName: string, node: AnySyntaxNode): boolean => {
|
|
56
|
-
if (!node.text.includes(localName)) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (isSingleNodeChild(node)) {
|
|
61
|
-
const [child] = node.children;
|
|
62
|
-
|
|
63
|
-
return isFunctionCalled(localName, child);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (isBinaryExprNode(node)) {
|
|
67
|
-
const [lhs, rhs] = node.children;
|
|
68
|
-
|
|
69
|
-
return isFunctionCalled(localName, lhs) || isFunctionCalled(localName, rhs);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
switch (node.type) {
|
|
73
|
-
// Terminal nodes
|
|
74
|
-
case 'number':
|
|
75
|
-
case 'string_literal':
|
|
76
|
-
case 'variable_reference':
|
|
77
|
-
|
|
78
|
-
// Path sub-nodes which could not have a function call child
|
|
79
|
-
//
|
|
80
|
-
// This only errors because this set of cases is commented:
|
|
81
|
-
// eslint-disable-next-line no-fallthrough
|
|
82
|
-
case '//':
|
|
83
|
-
case 'absolute_root_location_path':
|
|
84
|
-
case 'axis_name':
|
|
85
|
-
case 'node_type_test':
|
|
86
|
-
case 'parent':
|
|
87
|
-
case 'self':
|
|
88
|
-
|
|
89
|
-
// Name nodes are also not function call parents
|
|
90
|
-
//
|
|
91
|
-
// This only errors because this set of cases is commented:
|
|
92
|
-
// eslint-disable-next-line no-fallthrough
|
|
93
|
-
case 'local_part':
|
|
94
|
-
case 'prefixed_name':
|
|
95
|
-
case 'prefix':
|
|
96
|
-
case 'unprefixed_name':
|
|
97
|
-
case 'unprefixed_wildcard_name_test':
|
|
98
|
-
return false;
|
|
99
|
-
|
|
100
|
-
// Path sub-nodes which could have a function call child
|
|
101
|
-
case 'abbreviated_absolute_location_path':
|
|
102
|
-
case 'abbreviated_step':
|
|
103
|
-
case 'absolute_location_path':
|
|
104
|
-
case 'axis_test':
|
|
105
|
-
case 'filter_path_expr':
|
|
106
|
-
case 'relative_location_path':
|
|
107
|
-
case 'step':
|
|
108
|
-
return node.children.some((childNode) => isFunctionCalled(localName, childNode));
|
|
109
|
-
|
|
110
|
-
case 'function_call': {
|
|
111
|
-
const [functionNameNode] = node.children;
|
|
112
|
-
const [nameNode] = functionNameNode.children;
|
|
113
|
-
|
|
114
|
-
return matchesLocalName(localName, nameNode);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
default:
|
|
118
|
-
throw new UnreachableError(node);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const isItextFunctionCalled = (expression: string): boolean => {
|
|
123
|
-
const { rootNode } = expressionParser.parse(expression);
|
|
124
|
-
|
|
125
|
-
return isFunctionCalled('itext', rootNode);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
type LocationPathSubExpressionNode =
|
|
129
|
-
| AbsoluteLocationPathNode
|
|
130
|
-
| FilterPathExprNode
|
|
131
|
-
| RelativeLocationPathNode;
|
|
132
|
-
|
|
133
|
-
const isAnyLocationPathExprNode = (node: AnySyntaxNode): node is LocationPathSubExpressionNode => {
|
|
134
|
-
const { type } = node;
|
|
135
|
-
|
|
136
|
-
if (type === 'absolute_location_path' || type === 'relative_location_path') {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return false;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// TODO: this does not currently even attempt to find sub-expressions nested
|
|
144
|
-
// within sub-expressions.
|
|
145
|
-
const findLocationPathExprNodes = (
|
|
146
|
-
node: AnySyntaxNode
|
|
147
|
-
): readonly LocationPathSubExpressionNode[] => {
|
|
148
|
-
const results: LocationPathSubExpressionNode[] = [];
|
|
149
|
-
|
|
150
|
-
if (isAnyLocationPathExprNode(node)) {
|
|
151
|
-
results.push(node);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
results.push(
|
|
155
|
-
...node.children.flatMap((childNode) => {
|
|
156
|
-
return findLocationPathExprNodes(childNode);
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
return results;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
// TODO: this is a very small subset of resolution that needs to be supported,
|
|
164
|
-
// and it's a hamfisted hack. **This is temporary** to unblock progress on
|
|
165
|
-
// computations, but a longer term solution will need to address:
|
|
166
|
-
//
|
|
167
|
-
// - non-abbreviation axes (parent, child, self) according to XForms spec
|
|
168
|
-
// - non-leading axes
|
|
169
|
-
// - context expressions which are more complex than a series of explicit
|
|
170
|
-
// element name test steps (this may be fine for binds!)
|
|
171
|
-
const resolveRelativeSubExpression = (contextReference: string | null, expression: string) => {
|
|
172
|
-
if (contextReference == null) {
|
|
173
|
-
return expression;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const [, axisAbbreviation, relativeExpression = ''] = expression.match(/^(\.{1,2})(\/.*$)?/) ?? [
|
|
177
|
-
null,
|
|
178
|
-
'',
|
|
179
|
-
expression,
|
|
180
|
-
];
|
|
181
|
-
|
|
182
|
-
switch (axisAbbreviation) {
|
|
183
|
-
case '':
|
|
184
|
-
return expression;
|
|
185
|
-
|
|
186
|
-
case '.':
|
|
187
|
-
return `${contextReference}${relativeExpression}`;
|
|
188
|
-
|
|
189
|
-
case '..':
|
|
190
|
-
return `${contextReference.replace(/\/[^/]+$/, '')}${relativeExpression}`;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
throw new Error(`Unexpected relative expression: ${expression}`);
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
interface GetNodesetDependenciesOptions {
|
|
197
|
-
readonly contextReference?: string | null;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* @default false
|
|
201
|
-
*/
|
|
202
|
-
readonly ignoreContextReference?: boolean;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Ignores location path sub-expressions whose full text is `null`. While this
|
|
206
|
-
* is technically a valid relative name test step, it seems that real forms in
|
|
207
|
-
* the wild use it as if XPath had an actual `null` token/value.
|
|
208
|
-
*
|
|
209
|
-
* @default true
|
|
210
|
-
*/
|
|
211
|
-
readonly ignoreNullExpressions?: boolean;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export const getNodesetDependencies = (
|
|
215
|
-
expression: string,
|
|
216
|
-
options: GetNodesetDependenciesOptions = {}
|
|
217
|
-
): Set<string> => {
|
|
218
|
-
const { rootNode } = expressionParser.parse(expression);
|
|
219
|
-
const subExpressionNodes = findLocationPathExprNodes(rootNode);
|
|
220
|
-
const {
|
|
221
|
-
contextReference = null,
|
|
222
|
-
ignoreContextReference = false,
|
|
223
|
-
ignoreNullExpressions = true,
|
|
224
|
-
} = options;
|
|
225
|
-
|
|
226
|
-
const subExpressions = subExpressionNodes
|
|
227
|
-
.map((syntaxNode) => resolveRelativeSubExpression(contextReference, syntaxNode.text))
|
|
228
|
-
.filter((subExpression) => {
|
|
229
|
-
if (ignoreContextReference && subExpression === contextReference) {
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (ignoreNullExpressions && subExpression === 'null') {
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return true;
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
return new Set(subExpressions);
|
|
241
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
2
|
-
import type { BindDefinition } from './BindDefinition.ts';
|
|
3
|
-
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
4
|
-
import type { NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
|
|
5
|
-
import { RepeatInstanceDefinition } from './RepeatInstanceDefinition.ts';
|
|
6
|
-
import { RepeatTemplateDefinition } from './RepeatTemplateDefinition.ts';
|
|
7
|
-
|
|
8
|
-
export class RepeatRangeDefinition
|
|
9
|
-
extends DescendentNodeDefinition<'repeat-range', RepeatElementDefinition>
|
|
10
|
-
implements NodeDefinition<'repeat-range'>
|
|
11
|
-
{
|
|
12
|
-
// TODO: if an implicit template is derived from an instance in a form
|
|
13
|
-
// definition, should its default values (if any) be cleared? Probably!
|
|
14
|
-
static createTemplateElement(instanceElement: Element): Element {
|
|
15
|
-
return instanceElement.cloneNode(true) as Element;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static createInstanceElement(templateElement: Element): Element {
|
|
19
|
-
return templateElement.cloneNode(true) as Element;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
readonly type = 'repeat-range';
|
|
23
|
-
|
|
24
|
-
readonly template: RepeatTemplateDefinition;
|
|
25
|
-
readonly children = null;
|
|
26
|
-
readonly instances: RepeatInstanceDefinition[];
|
|
27
|
-
|
|
28
|
-
readonly node = null;
|
|
29
|
-
readonly nodeName: string;
|
|
30
|
-
readonly defaultValue = null;
|
|
31
|
-
|
|
32
|
-
constructor(
|
|
33
|
-
parent: ParentNodeDefinition,
|
|
34
|
-
bind: BindDefinition,
|
|
35
|
-
bodyElement: RepeatElementDefinition,
|
|
36
|
-
modelNodes: readonly [Element, ...Element[]]
|
|
37
|
-
) {
|
|
38
|
-
super(parent, bind, bodyElement);
|
|
39
|
-
const { template, instanceNodes } = RepeatTemplateDefinition.parseModelNodes(this, modelNodes);
|
|
40
|
-
|
|
41
|
-
this.template = template;
|
|
42
|
-
this.nodeName = template.nodeName;
|
|
43
|
-
this.instances = instanceNodes.map((element) => {
|
|
44
|
-
return new RepeatInstanceDefinition(this, element);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
toJSON() {
|
|
49
|
-
const { bind, bodyElement: groupDefinition, parent, root, ...rest } = this;
|
|
50
|
-
|
|
51
|
-
return rest;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
|
-
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
3
2
|
import {
|
|
4
3
|
inputAppearanceParser,
|
|
5
4
|
type InputAppearanceDefinition,
|
|
6
5
|
} from '../appearance/inputAppearanceParser.ts';
|
|
6
|
+
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
7
7
|
import { ControlDefinition } from './ControlDefinition.ts';
|
|
8
8
|
|
|
9
9
|
export class InputDefinition extends ControlDefinition<'input'> {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|