@getodk/xforms-engine 0.16.1 → 0.17.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 (80) hide show
  1. package/dist/client/InputNode.d.ts +8 -4
  2. package/dist/client/MarkdownNode.d.ts +3 -0
  3. package/dist/client/NoteNode.d.ts +6 -2
  4. package/dist/client/form/FormInstanceConfig.d.ts +4 -0
  5. package/dist/client/form/LoadFormResult.d.ts +5 -14
  6. package/dist/client/form/ResetFormInstance.d.ts +13 -0
  7. package/dist/entrypoints/FormResult/BaseFormResult.d.ts +1 -0
  8. package/dist/entrypoints/FormResult/BaseInstantiableFormResult.d.ts +2 -0
  9. package/dist/entrypoints/FormResult/FormFailureResult.d.ts +2 -0
  10. package/dist/entrypoints/createPotentiallyClientOwnedReactiveScope.d.ts +19 -0
  11. package/dist/index.js +21681 -25500
  12. package/dist/index.js.map +1 -1
  13. package/dist/instance/PrimaryInstance.d.ts +4 -1
  14. package/dist/instance/internal-api/AttributeContext.d.ts +1 -0
  15. package/dist/instance/internal-api/InstanceConfig.d.ts +2 -1
  16. package/dist/instance/internal-api/InstanceValueContext.d.ts +1 -0
  17. package/dist/instance/markdown/MarkdownNode.d.ts +14 -9
  18. package/dist/integration/xpath/static-dom/StaticDocument.d.ts +2 -0
  19. package/dist/lib/codecs/{Geopoint/Geopoint.d.ts → geolocation/Geolocation.d.ts} +11 -15
  20. package/dist/lib/codecs/geolocation/Geopoint.d.ts +7 -0
  21. package/dist/lib/codecs/geolocation/Geoshape.d.ts +7 -0
  22. package/dist/lib/codecs/geolocation/Geotrace.d.ts +7 -0
  23. package/dist/lib/codecs/geolocation/createGeolocationValueCodec.d.ts +3 -0
  24. package/dist/lib/codecs/getSharedValueCodec.d.ts +7 -5
  25. package/dist/lib/reactivity/text/createTextRange.d.ts +0 -2
  26. package/dist/parse/XFormDOM.d.ts +7 -1
  27. package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
  28. package/dist/parse/model/ActionDefinition.d.ts +1 -1
  29. package/dist/parse/model/BindPreloadDefinition.d.ts +2 -1
  30. package/dist/parse/model/ModelActionMap.d.ts +3 -2
  31. package/dist/parse/model/ModelDefinition.d.ts +3 -5
  32. package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +0 -17
  33. package/dist/parse/model/SecondaryInstance/sources/external-instance-csv-parser.d.ts +8 -0
  34. package/dist/parse/model/TranslationDefinitionMap.d.ts +4 -0
  35. package/dist/solid.js +21407 -25226
  36. package/dist/solid.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/client/InputNode.ts +11 -3
  39. package/src/client/MarkdownNode.ts +3 -0
  40. package/src/client/NoteNode.ts +9 -1
  41. package/src/client/form/FormInstanceConfig.ts +6 -0
  42. package/src/client/form/LoadFormResult.ts +5 -17
  43. package/src/client/form/ResetFormInstance.ts +17 -0
  44. package/src/entrypoints/FormInstance.ts +2 -0
  45. package/src/entrypoints/FormResult/BaseFormResult.ts +1 -0
  46. package/src/entrypoints/FormResult/BaseInstantiableFormResult.ts +10 -1
  47. package/src/entrypoints/FormResult/FormFailureResult.ts +3 -0
  48. package/src/entrypoints/createPotentiallyClientOwnedReactiveScope.ts +30 -0
  49. package/src/entrypoints/loadForm.ts +1 -31
  50. package/src/instance/InputControl.ts +3 -5
  51. package/src/instance/PrimaryInstance.ts +17 -2
  52. package/src/instance/attachments/buildAttributes.ts +21 -1
  53. package/src/instance/internal-api/AttributeContext.ts +1 -0
  54. package/src/instance/internal-api/InstanceConfig.ts +3 -0
  55. package/src/instance/internal-api/InstanceValueContext.ts +1 -0
  56. package/src/instance/markdown/MarkdownNode.ts +19 -7
  57. package/src/instance/text/markdownFormat.ts +4 -3
  58. package/src/integration/xpath/static-dom/StaticDocument.ts +2 -0
  59. package/src/lib/codecs/{Geopoint/Geopoint.ts → geolocation/Geolocation.ts} +43 -24
  60. package/src/lib/codecs/geolocation/Geopoint.ts +15 -0
  61. package/src/lib/codecs/geolocation/Geoshape.ts +36 -0
  62. package/src/lib/codecs/geolocation/Geotrace.ts +36 -0
  63. package/src/lib/codecs/geolocation/createGeolocationValueCodec.ts +18 -0
  64. package/src/lib/codecs/getSharedValueCodec.ts +37 -11
  65. package/src/lib/reactivity/createInstanceValueState.ts +64 -34
  66. package/src/lib/reactivity/text/createTextRange.ts +71 -45
  67. package/src/parse/XFormDOM.ts +22 -2
  68. package/src/parse/model/ActionDefinition.ts +6 -6
  69. package/src/parse/model/BindDefinition.ts +1 -1
  70. package/src/parse/model/BindPreloadDefinition.ts +21 -14
  71. package/src/parse/model/ModelActionMap.ts +30 -13
  72. package/src/parse/model/ModelDefinition.ts +5 -10
  73. package/src/parse/model/RootDefinition.ts +2 -1
  74. package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +2 -184
  75. package/src/parse/model/SecondaryInstance/sources/external-instance-csv-parser.ts +185 -0
  76. package/src/parse/model/TranslationDefinitionMap.ts +23 -0
  77. package/dist/lib/codecs/Geopoint/GeopointValueCodec.d.ts +0 -5
  78. package/dist/parse/model/generateItextChunks.d.ts +0 -5
  79. package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +0 -20
  80. package/src/parse/model/generateItextChunks.ts +0 -61
@@ -0,0 +1,23 @@
1
+ import type { DOMItextTranslationElement } from '../XFormDOM.ts';
2
+
3
+ const generateChunksForLanguage = (
4
+ translationElement: DOMItextTranslationElement
5
+ ): Map<string, Element> => {
6
+ return new Map(
7
+ Array.from(translationElement.children).map((textElement) => {
8
+ const itextId = textElement.getAttribute('id');
9
+ return [itextId!, textElement] as const;
10
+ })
11
+ );
12
+ };
13
+
14
+ export class TranslationDefinitionMap extends Map<string, Map<string, Element>> {
15
+ constructor(translationElements: readonly DOMItextTranslationElement[]) {
16
+ super(
17
+ translationElements.map((translationElement) => {
18
+ const lang = translationElement.getAttribute('lang');
19
+ return [lang, generateChunksForLanguage(translationElement)] as const;
20
+ })
21
+ );
22
+ }
23
+ }
@@ -1,5 +0,0 @@
1
- import { ValueCodec } from '../ValueCodec.ts';
2
- import { GeopointInputValue, GeopointRuntimeValue } from './Geopoint.ts';
3
- export declare class GeopointValueCodec extends ValueCodec<'geopoint', GeopointRuntimeValue, GeopointInputValue> {
4
- constructor();
5
- }
@@ -1,5 +0,0 @@
1
- import { TextChunkExpression } from '../expression/TextChunkExpression.ts';
2
- import { DOMItextTranslationElement } from '../XFormDOM.ts';
3
- export interface ChunkExpressionsByItextId extends Map<string, ReadonlyArray<TextChunkExpression<'string'>>> {
4
- }
5
- export declare const generateItextChunks: (translationElements: readonly DOMItextTranslationElement[]) => Map<string, ChunkExpressionsByItextId>;
@@ -1,20 +0,0 @@
1
- import { type CodecDecoder, type CodecEncoder, ValueCodec } from '../ValueCodec.ts';
2
- import { Geopoint, type GeopointInputValue, type GeopointRuntimeValue } from './Geopoint.ts';
3
-
4
- export class GeopointValueCodec extends ValueCodec<
5
- 'geopoint',
6
- GeopointRuntimeValue,
7
- GeopointInputValue
8
- > {
9
- constructor() {
10
- const encodeValue: CodecEncoder<GeopointInputValue> = (value) => {
11
- return Geopoint.toCoordinatesString(value);
12
- };
13
-
14
- const decodeValue: CodecDecoder<GeopointRuntimeValue> = (value: string) => {
15
- return Geopoint.parseString(value);
16
- };
17
-
18
- super('geopoint', encodeValue, decodeValue);
19
- }
20
- }
@@ -1,61 +0,0 @@
1
- import {
2
- isResourceType,
3
- type JRResourceURLString,
4
- type ResourceType,
5
- } from '@getodk/common/jr-resources/JRResourceURL.ts';
6
- import { isElementNode, isTextNode } from '@getodk/common/lib/dom/predicates.ts';
7
- import { TextChunkExpression } from '../expression/TextChunkExpression.ts';
8
- import type { DOMItextTranslationElement } from '../XFormDOM.ts';
9
-
10
- const generateChunk = (node: Node): TextChunkExpression<'string'> | null => {
11
- if (isElementNode(node)) {
12
- return TextChunkExpression.fromOutput(node);
13
- }
14
- if (isTextNode(node)) {
15
- const formAttribute = node.parentElement!.getAttribute('form') as ResourceType;
16
- if (isResourceType(formAttribute)) {
17
- return TextChunkExpression.fromResource(node.data as JRResourceURLString, formAttribute);
18
- }
19
- return TextChunkExpression.fromLiteral(node.data);
20
- }
21
- return null;
22
- };
23
-
24
- const generateChunksForValues = (valueElement: ChildNode): Array<TextChunkExpression<'string'>> => {
25
- return Array.from(valueElement.childNodes)
26
- .map((node) => generateChunk(node))
27
- .filter((chunk) => chunk !== null);
28
- };
29
-
30
- const generateChunksForTranslation = (
31
- textElement: Element
32
- ): Array<TextChunkExpression<'string'>> => {
33
- return Array.from(textElement.childNodes).flatMap((valueElement) =>
34
- generateChunksForValues(valueElement)
35
- );
36
- };
37
-
38
- const generateChunksForLanguage = (
39
- translationElement: DOMItextTranslationElement
40
- ): Map<string, ReadonlyArray<TextChunkExpression<'string'>>> => {
41
- return new Map(
42
- Array.from(translationElement.children).map((textElement) => {
43
- const itextId = textElement.getAttribute('id');
44
- return [itextId!, generateChunksForTranslation(textElement)] as const;
45
- })
46
- );
47
- };
48
-
49
- export interface ChunkExpressionsByItextId
50
- extends Map<string, ReadonlyArray<TextChunkExpression<'string'>>> {}
51
-
52
- export const generateItextChunks = (
53
- translationElements: readonly DOMItextTranslationElement[]
54
- ): Map<string, ChunkExpressionsByItextId> => {
55
- return new Map(
56
- translationElements.map((translationElement) => {
57
- const lang = translationElement.getAttribute('lang');
58
- return [lang, generateChunksForLanguage(translationElement)] as const;
59
- })
60
- );
61
- };