@wailsio/runtime 3.0.0-alpha.96 → 3.0.0-alpha.97

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/calls.js CHANGED
@@ -20,21 +20,10 @@ const cancelCall = newRuntimeCaller(objectNames.CancelCall);
20
20
  const callResponses = new Map();
21
21
  const CallBinding = 0;
22
22
  const CancelMethod = 0;
23
- /**
24
- * Exception class that will be thrown in case the bound method returns an error.
25
- * The value of the {@link RuntimeError#name} property is "RuntimeError".
26
- */
27
- export class RuntimeError extends Error {
28
- /**
29
- * Constructs a new RuntimeError instance.
30
- * @param message - The error message.
31
- * @param options - Options to be forwarded to the Error constructor.
32
- */
33
- constructor(message, options) {
34
- super(message, options);
35
- this.name = "RuntimeError";
36
- }
37
- }
23
+ // runtime.js needs to use RuntimeError internally to properly parse and return
24
+ // errors for binding calls, so it had to move there. Exporting here again to
25
+ // keep from breaking the public Call interface.
26
+ export { RuntimeError } from "./runtime.js";
38
27
  /**
39
28
  * Generates a unique ID using the nanoid library.
40
29
  *
package/dist/runtime.js CHANGED
@@ -19,6 +19,21 @@ function runtimeURL() {
19
19
  const CHUNK_THRESHOLD = 512 * 1024;
20
20
  // Re-export nanoid for custom transport implementations
21
21
  export { nanoid };
22
+ /**
23
+ * Exception class that will be thrown in case the bound method returns an error.
24
+ * The value of the {@link RuntimeError#name} property is "RuntimeError".
25
+ */
26
+ export class RuntimeError extends Error {
27
+ /**
28
+ * Constructs a new RuntimeError instance.
29
+ * @param message - The error message.
30
+ * @param options - Options to be forwarded to the Error constructor.
31
+ */
32
+ constructor(message, options) {
33
+ super(message, options);
34
+ this.name = "RuntimeError";
35
+ }
36
+ }
22
37
  // Object Names
23
38
  export const objectNames = Object.freeze({
24
39
  Call: 0,
@@ -112,6 +127,25 @@ async function runtimeCallWithID(objectID, method, windowName, args) {
112
127
  response = await fetch(url, { method: 'POST', headers, body: bodyStr });
113
128
  }
114
129
  if (!response.ok) {
130
+ const ct = response.headers.get("Content-Type");
131
+ if (ct === null || ct === void 0 ? void 0 : ct.includes("application/json")) {
132
+ const json = await response.json();
133
+ let err;
134
+ switch (json.kind) {
135
+ case "ReferenceError":
136
+ err = new ReferenceError(json.message);
137
+ break;
138
+ case "TypeError":
139
+ err = new TypeError(json.message);
140
+ break;
141
+ case "RuntimeError":
142
+ err = new RuntimeError(json.message);
143
+ break;
144
+ default: err = new Error(json.message);
145
+ }
146
+ err.cause = json.cause;
147
+ throw err;
148
+ }
115
149
  throw new Error(await response.text());
116
150
  }
117
151
  if (((_b = (_a = response.headers.get("Content-Type")) === null || _a === void 0 ? void 0 : _a.indexOf("application/json")) !== null && _b !== void 0 ? _b : -1) !== -1) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wailsio/runtime",
3
3
  "type": "module",
4
- "version": "3.0.0-alpha.96",
4
+ "version": "3.0.0-alpha.97",
5
5
  "description": "Wails Runtime",
6
6
  "types": "types/index.d.ts",
7
7
  "exports": {
package/types/calls.d.ts CHANGED
@@ -18,18 +18,7 @@ export type CallOptions = {
18
18
  /** Arguments to be passed into the bound method. */
19
19
  args: any[];
20
20
  };
21
- /**
22
- * Exception class that will be thrown in case the bound method returns an error.
23
- * The value of the {@link RuntimeError#name} property is "RuntimeError".
24
- */
25
- export declare class RuntimeError extends Error {
26
- /**
27
- * Constructs a new RuntimeError instance.
28
- * @param message - The error message.
29
- * @param options - Options to be forwarded to the Error constructor.
30
- */
31
- constructor(message?: string, options?: ErrorOptions);
32
- }
21
+ export { RuntimeError } from "./runtime.js";
33
22
  /**
34
23
  * Call a bound method according to the given call options.
35
24
  *
@@ -1,5 +1,17 @@
1
1
  import { nanoid } from "./nanoid.js";
2
2
  export { nanoid };
3
+ /**
4
+ * Exception class that will be thrown in case the bound method returns an error.
5
+ * The value of the {@link RuntimeError#name} property is "RuntimeError".
6
+ */
7
+ export declare class RuntimeError extends Error {
8
+ /**
9
+ * Constructs a new RuntimeError instance.
10
+ * @param message - The error message.
11
+ * @param options - Options to be forwarded to the Error constructor.
12
+ */
13
+ constructor(message?: string, options?: ErrorOptions);
14
+ }
3
15
  export declare const objectNames: Readonly<{
4
16
  Call: 0;
5
17
  Clipboard: 1;