@getodk/xforms-engine 0.9.0 → 0.11.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.
Files changed (40) hide show
  1. package/dist/client/SelectNode.d.ts +1 -0
  2. package/dist/client/TextRange.d.ts +4 -0
  3. package/dist/index.js +133 -160
  4. package/dist/index.js.map +1 -1
  5. package/dist/instance/SelectControl.d.ts +1 -0
  6. package/dist/instance/text/TextRange.d.ts +11 -1
  7. package/dist/lib/reactivity/text/createTextRange.d.ts +1 -2
  8. package/dist/parse/expression/TextChunkExpression.d.ts +16 -0
  9. package/dist/parse/shared/parseInstanceXML.d.ts +1 -1
  10. package/dist/parse/text/ItemsetLabelDefinition.d.ts +2 -4
  11. package/dist/parse/text/MessageDefinition.d.ts +3 -7
  12. package/dist/parse/text/abstract/TextElementDefinition.d.ts +2 -8
  13. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +2 -2
  14. package/dist/solid.js +133 -160
  15. package/dist/solid.js.map +1 -1
  16. package/package.json +2 -2
  17. package/src/client/SelectNode.ts +2 -0
  18. package/src/client/TextRange.ts +5 -1
  19. package/src/error/LoadFormFailureError.ts +9 -35
  20. package/src/instance/SelectControl.ts +6 -0
  21. package/src/instance/text/TextRange.ts +21 -1
  22. package/src/lib/reactivity/text/createTextRange.ts +56 -43
  23. package/src/lib/reactivity/validation/createValidation.ts +1 -3
  24. package/src/parse/expression/TextChunkExpression.ts +78 -0
  25. package/src/parse/shared/parseInstanceXML.ts +4 -2
  26. package/src/parse/text/ItemsetLabelDefinition.ts +8 -12
  27. package/src/parse/text/MessageDefinition.ts +9 -16
  28. package/src/parse/text/abstract/TextElementDefinition.ts +10 -26
  29. package/src/parse/text/abstract/TextRangeDefinition.ts +2 -2
  30. package/src/parse/xpath/semantic-analysis.ts +7 -2
  31. package/dist/parse/expression/TextLiteralExpression.d.ts +0 -9
  32. package/dist/parse/expression/TextOutputExpression.d.ts +0 -7
  33. package/dist/parse/expression/TextReferenceExpression.d.ts +0 -7
  34. package/dist/parse/expression/TextTranslationExpression.d.ts +0 -8
  35. package/dist/parse/expression/abstract/TextChunkExpression.d.ts +0 -17
  36. package/src/parse/expression/TextLiteralExpression.ts +0 -19
  37. package/src/parse/expression/TextOutputExpression.ts +0 -25
  38. package/src/parse/expression/TextReferenceExpression.ts +0 -14
  39. package/src/parse/expression/TextTranslationExpression.ts +0 -38
  40. package/src/parse/expression/abstract/TextChunkExpression.ts +0 -38
@@ -1,17 +0,0 @@
1
- import { TextChunkSource } from '../../../client/TextRange.ts';
2
- import { AnyTextRangeDefinition } from '../../text/abstract/TextRangeDefinition.ts';
3
- import { TextLiteralExpression } from '../TextLiteralExpression.ts';
4
- import { TextOutputExpression } from '../TextOutputExpression.ts';
5
- import { TextReferenceExpression } from '../TextReferenceExpression.ts';
6
- import { TextTranslationExpression } from '../TextTranslationExpression.ts';
7
- import { DependentExpression } from './DependentExpression.ts';
8
- interface TextChunkExpressionOptions {
9
- readonly isTranslated?: true;
10
- }
11
- export declare abstract class TextChunkExpression<Source extends TextChunkSource> extends DependentExpression<'string'> {
12
- abstract readonly source: Source;
13
- readonly stringValue?: string;
14
- constructor(context: AnyTextRangeDefinition, expression: string, options?: TextChunkExpressionOptions);
15
- }
16
- export type AnyTextChunkExpression = TextLiteralExpression | TextOutputExpression | TextReferenceExpression | TextTranslationExpression;
17
- export {};
@@ -1,19 +0,0 @@
1
- import type { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
2
- import { TextChunkExpression } from './abstract/TextChunkExpression.ts';
3
-
4
- export type TextLiteralSourceNode = Attr | Text;
5
-
6
- export class TextLiteralExpression extends TextChunkExpression<'literal'> {
7
- static from(context: AnyTextRangeDefinition, stringValue: string): TextLiteralExpression {
8
- return new this(context, stringValue);
9
- }
10
-
11
- readonly source = 'literal';
12
-
13
- private constructor(
14
- context: AnyTextRangeDefinition,
15
- override readonly stringValue: string
16
- ) {
17
- super(context, 'null');
18
- }
19
- }
@@ -1,25 +0,0 @@
1
- import type { KnownAttributeLocalNamedElement } from '@getodk/common/types/dom.ts';
2
- import type { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
3
- import { TextChunkExpression } from './abstract/TextChunkExpression.ts';
4
-
5
- interface OutputElement extends KnownAttributeLocalNamedElement<'output', 'value'> {}
6
-
7
- const isOutputElement = (element: Element): element is OutputElement => {
8
- return element.localName === 'output' && element.hasAttribute('value');
9
- };
10
-
11
- export class TextOutputExpression extends TextChunkExpression<'output'> {
12
- static from(context: AnyTextRangeDefinition, element: Element): TextOutputExpression | null {
13
- if (isOutputElement(element)) {
14
- return new this(context, element);
15
- }
16
-
17
- return null;
18
- }
19
-
20
- readonly source = 'output';
21
-
22
- private constructor(context: AnyTextRangeDefinition, element: OutputElement) {
23
- super(context, element.getAttribute('value'));
24
- }
25
- }
@@ -1,14 +0,0 @@
1
- import type { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
2
- import { TextChunkExpression } from './abstract/TextChunkExpression.ts';
3
-
4
- export class TextReferenceExpression extends TextChunkExpression<'reference'> {
5
- static from(context: AnyTextRangeDefinition, refExpression: string): TextReferenceExpression {
6
- return new this(context, refExpression);
7
- }
8
-
9
- readonly source = 'reference';
10
-
11
- private constructor(context: AnyTextRangeDefinition, refExpression: string) {
12
- super(context, refExpression);
13
- }
14
- }
@@ -1,38 +0,0 @@
1
- import { expressionParser } from '@getodk/xpath/expressionParser.js';
2
- import type { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
3
- import type { TranslationExpression } from '../xpath/semantic-analysis.ts';
4
- import { isTranslationExpression } from '../xpath/semantic-analysis.ts';
5
- import { TextChunkExpression } from './abstract/TextChunkExpression.ts';
6
-
7
- export class TextTranslationExpression extends TextChunkExpression<'translation'> {
8
- static fromMessage(
9
- context: AnyTextRangeDefinition,
10
- maybeExpression: string
11
- ): TextTranslationExpression | null {
12
- try {
13
- expressionParser.parse(maybeExpression);
14
- } catch {
15
- return null;
16
- }
17
-
18
- if (isTranslationExpression(maybeExpression)) {
19
- return new this(context, maybeExpression);
20
- }
21
-
22
- return null;
23
- }
24
-
25
- static from(context: AnyTextRangeDefinition, maybeExpression: string) {
26
- if (isTranslationExpression(maybeExpression)) {
27
- return new this(context, maybeExpression);
28
- }
29
-
30
- return null;
31
- }
32
-
33
- readonly source = 'translation';
34
-
35
- private constructor(context: AnyTextRangeDefinition, expression: TranslationExpression) {
36
- super(context, expression, { isTranslated: true });
37
- }
38
- }
@@ -1,38 +0,0 @@
1
- import type { TextChunkSource } from '../../../client/TextRange.ts';
2
- import type { AnyTextRangeDefinition } from '../../text/abstract/TextRangeDefinition.ts';
3
- import type { TextLiteralExpression } from '../TextLiteralExpression.ts';
4
- import type { TextOutputExpression } from '../TextOutputExpression.ts';
5
- import type { TextReferenceExpression } from '../TextReferenceExpression.ts';
6
- import type { TextTranslationExpression } from '../TextTranslationExpression.ts';
7
- import { DependentExpression } from './DependentExpression.ts';
8
-
9
- interface TextChunkExpressionOptions {
10
- readonly isTranslated?: true;
11
- }
12
-
13
- export abstract class TextChunkExpression<
14
- Source extends TextChunkSource,
15
- > extends DependentExpression<'string'> {
16
- abstract readonly source: Source;
17
- readonly stringValue?: string;
18
-
19
- constructor(
20
- context: AnyTextRangeDefinition,
21
- expression: string,
22
- options: TextChunkExpressionOptions = {}
23
- ) {
24
- super(context, 'string', expression, {
25
- semanticDependencies: {
26
- translations: options.isTranslated,
27
- },
28
- ignoreContextReference: true,
29
- });
30
- }
31
- }
32
-
33
- // prettier-ignore
34
- export type AnyTextChunkExpression =
35
- | TextLiteralExpression
36
- | TextOutputExpression
37
- | TextReferenceExpression
38
- | TextTranslationExpression;