@getodk/xforms-engine 0.10.0 → 0.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getodk/xforms-engine",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "XForms engine for ODK Web Forms",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "README.md"
30
30
  ],
31
31
  "engines": {
32
- "node": "^18.20.5 || ^20.18.1 || ^22.12.0",
32
+ "node": "^20.19.3 || ^22.12.0 || ^24.3.0",
33
33
  "yarn": "1.22.22"
34
34
  },
35
35
  "scripts": {
@@ -55,28 +55,28 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "bin-packer": "1.7.0",
58
- "papaparse": "^5.5.2",
59
- "solid-js": "^1.9.5",
58
+ "papaparse": "^5.5.3",
59
+ "solid-js": "^1.9.7",
60
60
  "temporal-polyfill": "^0.3.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@babel/core": "^7.26.10",
64
- "@getodk/tree-sitter-xpath": "0.1.3",
65
- "@getodk/xpath": "0.6.0",
66
- "@playwright/test": "^1.49.1",
67
- "@types/papaparse": "^5.3.15",
68
- "@vitest/browser": "^3.0.9",
63
+ "@babel/core": "^7.28.0",
64
+ "@getodk/tree-sitter-xpath": "0.2.0",
65
+ "@getodk/xpath": "0.7.0",
66
+ "@playwright/test": "^1.53.2",
67
+ "@types/papaparse": "^5.3.16",
68
+ "@vitest/browser": "^3.2.4",
69
69
  "babel-plugin-transform-jsbi-to-bigint": "^1.4.2",
70
70
  "http-server": "^14.1.1",
71
- "jsdom": "^26.0.0",
72
- "typedoc": "^0.28.2",
73
- "vite": "^6.2.3",
74
- "vite-plugin-dts": "^4.5.3",
71
+ "jsdom": "^26.1.0",
72
+ "typedoc": "^0.28.7",
73
+ "vite": "^7.0.3",
74
+ "vite-plugin-dts": "^4.5.4",
75
75
  "vite-plugin-no-bundle": "^4.0.0",
76
- "vitest": "^3.0.9"
76
+ "vitest": "^3.2.4"
77
77
  },
78
78
  "peerDependencies": {
79
- "solid-js": "^1.9.5"
79
+ "solid-js": "^1.9.7"
80
80
  },
81
81
  "peerDependenciesMeta": {
82
82
  "solid-js": {
@@ -49,7 +49,7 @@ interface FormResourceMetadata {
49
49
  readonly rawData: string | null;
50
50
  }
51
51
 
52
- const formResourceMetadata = (resource: FormResource): FormResourceMetadata => {
52
+ const formResourceMetadata = (resource: FormResource): FormResourceMetadata | undefined => {
53
53
  if (resource instanceof Blob) {
54
54
  return {
55
55
  description: blobDescription(resource),
@@ -64,10 +64,7 @@ const formResourceMetadata = (resource: FormResource): FormResourceMetadata => {
64
64
  };
65
65
  }
66
66
 
67
- return {
68
- description: 'Raw string data',
69
- rawData: resource,
70
- };
67
+ return;
71
68
  };
72
69
 
73
70
  /**
@@ -77,38 +74,15 @@ const formResourceMetadata = (resource: FormResource): FormResourceMetadata => {
77
74
  */
78
75
  export class LoadFormFailureError extends AggregateError {
79
76
  constructor(resource: FormResource, errors: readonly Error[]) {
80
- const { description, rawData } = formResourceMetadata(resource);
81
- const messageLines: string[] = [
82
- `Failed to load form resource: ${description}`,
83
- '\n',
84
-
85
- ...errors.map((error) => {
86
- const aggregatedMessage = error.message;
87
-
88
- if (aggregatedMessage == null) {
89
- return '- Unknown error';
90
- }
91
-
92
- return `- ${aggregatedMessage}`;
93
- }),
94
- ];
95
-
96
- if (rawData != null) {
97
- messageLines.push('\n- - -\n', 'Raw resource data:', rawData);
98
- }
99
-
100
- const message = messageLines.join('\n');
101
-
77
+ const metadata = formResourceMetadata(resource);
78
+ const errorMessages = errors.map((error) => error.message || 'Unknown error').join('\n');
79
+ const message = metadata?.description
80
+ ? `Form source: ${metadata.description}\n${errorMessages}`
81
+ : errorMessages;
102
82
  super(errors, message);
103
83
 
104
84
  const [head, ...tail] = errors;
105
-
106
- if (head != null && tail.length === 0) {
107
- const { stack } = head;
108
-
109
- if (typeof stack === 'string') {
110
- this.stack = stack;
111
- }
112
- }
85
+ this.stack =
86
+ typeof head?.stack === 'string' && !tail.length ? head.stack : 'No error trace available.';
113
87
  }
114
88
  }
@@ -68,11 +68,13 @@ const getWrappedInstanceRootElement = (xml: WrappedInstanceXML): Element => {
68
68
  * @todo Aside from this being a hack, it's not very robust because it makes
69
69
  * assumptions which are _likely but definitely not guaranteed_!
70
70
  *
71
- * - Instance XML (probably) doeesn't declare a default namespace
71
+ * - Instance XML (probably) doesn't declare a default namespace
72
72
  * - Instance XML **definitely** declares non-default namespaces
73
73
  */
74
74
  export const parseInstanceXML = (model: ModelDefinition, instanceXML: string): StaticDocument => {
75
- const wrappedXML = wrapInstanceXML(model, instanceXML);
75
+ // Remove XML declaration if present: xforms-engine defaults to UTF-8
76
+ const cleanedXML = instanceXML.replace(/<\?xml\s+[^?]*\?>\s*/, '');
77
+ const wrappedXML = wrapInstanceXML(model, cleanedXML);
76
78
  const root = getWrappedInstanceRootElement(wrappedXML);
77
79
 
78
80
  return parseStaticDocumentFromDOMSubtree(root);