@getodk/xforms-engine 0.10.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.
@@ -15,7 +15,7 @@ import { ModelDefinition } from '../model/ModelDefinition.ts';
15
15
  * @todo Aside from this being a hack, it's not very robust because it makes
16
16
  * assumptions which are _likely but definitely not guaranteed_!
17
17
  *
18
- * - Instance XML (probably) doeesn't declare a default namespace
18
+ * - Instance XML (probably) doesn't declare a default namespace
19
19
  * - Instance XML **definitely** declares non-default namespaces
20
20
  */
21
21
  export declare const parseInstanceXML: (model: ModelDefinition, instanceXML: string) => StaticDocument;
package/dist/solid.js CHANGED
@@ -67,37 +67,17 @@ const formResourceMetadata = (resource) => {
67
67
  rawData: null
68
68
  };
69
69
  }
70
- return {
71
- description: "Raw string data",
72
- rawData: resource
73
- };
70
+ return;
74
71
  };
75
72
  class LoadFormFailureError extends AggregateError {
76
73
  constructor(resource, errors) {
77
- const { description, rawData } = formResourceMetadata(resource);
78
- const messageLines = [
79
- `Failed to load form resource: ${description}`,
80
- "\n",
81
- ...errors.map((error) => {
82
- const aggregatedMessage = error.message;
83
- if (aggregatedMessage == null) {
84
- return "- Unknown error";
85
- }
86
- return `- ${aggregatedMessage}`;
87
- })
88
- ];
89
- if (rawData != null) {
90
- messageLines.push("\n- - -\n", "Raw resource data:", rawData);
91
- }
92
- const message = messageLines.join("\n");
74
+ const metadata = formResourceMetadata(resource);
75
+ const errorMessages = errors.map((error) => error.message || "Unknown error").join("\n");
76
+ const message = metadata?.description ? `Form source: ${metadata.description}
77
+ ${errorMessages}` : errorMessages;
93
78
  super(errors, message);
94
79
  const [head, ...tail] = errors;
95
- if (head != null && tail.length === 0) {
96
- const { stack } = head;
97
- if (typeof stack === "string") {
98
- this.stack = stack;
99
- }
100
- }
80
+ this.stack = typeof head?.stack === "string" && !tail.length ? head.stack : "No error trace available.";
101
81
  }
102
82
  }
103
83
 
@@ -27127,7 +27107,8 @@ const getWrappedInstanceRootElement = (xml) => {
27127
27107
  return root;
27128
27108
  };
27129
27109
  const parseInstanceXML = (model, instanceXML) => {
27130
- const wrappedXML = wrapInstanceXML(model, instanceXML);
27110
+ const cleanedXML = instanceXML.replace(/<\?xml\s+[^?]*\?>\s*/, "");
27111
+ const wrappedXML = wrapInstanceXML(model, cleanedXML);
27131
27112
  const root = getWrappedInstanceRootElement(wrappedXML);
27132
27113
  return parseStaticDocumentFromDOMSubtree(root);
27133
27114
  };