@govela/runtime 0.3.1 → 0.4.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 (2) hide show
  1. package/package.json +1 -1
  2. package/runtime-blocks.js +13 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@govela/runtime",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Runtime of components compiled by the Vela compiler. Generated from runtime/; do not edit.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/runtime-blocks.js CHANGED
@@ -565,6 +565,17 @@ export function $$each(cursor, collection, key, row, fallback, changed, dirtyRow
565
565
  // Branch fragments receive { value } or { error }. A settlement of a promise
566
566
  // that is no longer current is ignored.
567
567
 
568
+ // reviveError rebuilds an error object the server wrote in its payload
569
+ // form: kind, own message, own enumerable properties.
570
+ const errorKinds = { Error, TypeError, RangeError };
571
+ function reviveError(form) {
572
+ const error = new (errorKinds[form.kind] || Error)();
573
+ if ('message' in form) {
574
+ Object.defineProperty(error, 'message', { value: form.message, writable: true, configurable: true });
575
+ }
576
+ return Object.assign(error, form.props);
577
+ }
578
+
568
579
  export function $$await(cursor, operand, pending, then, catcher, changed) {
569
580
  let anchor;
570
581
  let promise = null;
@@ -620,7 +631,8 @@ export function $$await(cursor, operand, pending, then, catcher, changed) {
620
631
  if (then) current = cursor.mount(then, { value: entry.value });
621
632
  } else if (token === 'c') {
622
633
  state = 2;
623
- if (catcher) current = cursor.mount(catcher, { error: entry.error });
634
+ const error = entry.errorObject ? reviveError(entry.error) : entry.error;
635
+ if (catcher) current = cursor.mount(catcher, { error });
624
636
  } else {
625
637
  state = 0;
626
638
  if (pending) current = cursor.mount(pending);