@merkur/plugin-error 0.33.0 → 0.34.3

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/lib/index.cjs CHANGED
@@ -232,6 +232,7 @@ async function updateHook(widget, originalUpdate, ...rest) {
232
232
  function setErrorInfo(widget, error) {
233
233
  widget.error.status = error.status;
234
234
  widget.error.message = error.message;
235
+ widget.error.url = error.params?.url;
235
236
 
236
237
  if (ENV === DEV) {
237
238
  widget.error.stack = error.stack;
package/lib/index.es9.cjs CHANGED
@@ -195,8 +195,10 @@ async function updateHook(widget, originalUpdate, ...rest) {
195
195
  // HELPER FUNCTIONS
196
196
 
197
197
  function setErrorInfo(widget, error) {
198
+ var _error$params;
198
199
  widget.error.status = error.status;
199
200
  widget.error.message = error.message;
201
+ widget.error.url = (_error$params = error.params) === null || _error$params === void 0 ? void 0 : _error$params.url;
200
202
  if (ENV === DEV) {
201
203
  widget.error.stack = error.stack;
202
204
  }
package/lib/index.es9.mjs CHANGED
@@ -193,8 +193,10 @@ async function updateHook(widget, originalUpdate, ...rest) {
193
193
  // HELPER FUNCTIONS
194
194
 
195
195
  function setErrorInfo(widget, error) {
196
+ var _error$params;
196
197
  widget.error.status = error.status;
197
198
  widget.error.message = error.message;
199
+ widget.error.url = (_error$params = error.params) === null || _error$params === void 0 ? void 0 : _error$params.url;
198
200
  if (ENV === DEV) {
199
201
  widget.error.stack = error.stack;
200
202
  }
package/lib/index.js CHANGED
@@ -232,6 +232,7 @@ async function updateHook(widget, originalUpdate, ...rest) {
232
232
  function setErrorInfo(widget, error) {
233
233
  widget.error.status = error.status;
234
234
  widget.error.message = error.message;
235
+ widget.error.url = error.params?.url;
235
236
 
236
237
  if (ENV === DEV) {
237
238
  widget.error.stack = error.stack;
package/lib/index.mjs CHANGED
@@ -230,6 +230,7 @@ async function updateHook(widget, originalUpdate, ...rest) {
230
230
  function setErrorInfo(widget, error) {
231
231
  widget.error.status = error.status;
232
232
  widget.error.message = error.message;
233
+ widget.error.url = error.params?.url;
233
234
 
234
235
  if (ENV === DEV) {
235
236
  widget.error.stack = error.stack;
package/lib/index.umd.js CHANGED
@@ -1 +1 @@
1
- function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},r(t)}!function(r,t){if("function"==typeof define&&define.amd)define("@merkur/plugin-error",["exports","@merkur/core"],t);else if("undefined"!=typeof exports)t(exports,require("@merkur/core"));else{var e={exports:{}};t(e.exports,r.Merkur.Core),r.Merkur=r.Merkur||{},r.Merkur.Plugin=r.Merkur.Plugin||{},r.Merkur.Plugin.Error=e.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t,e){Object.defineProperty(t,"__esModule",{value:!0}),t.GenericError=t.ERROR_EVENTS=void 0,t.errorPlugin=function(){return{setup:function(r){return s((function*(){return r.error=r.error?r.error:{status:null,message:null},r}))()},create:function(r){return s((function*(){if(g===d){if(!r.$in.component)throw new Error("You must install missing plugin: npm i @merkur/plugin-component");if(!r.$in.eventEmitter)throw new Error("You must install missing plugin: npm i @merkur/plugin-event-emitter")}return(0,e.hookMethod)(r,"info",j),(0,e.hookMethod)(r,"load",w),(0,e.hookMethod)(r,"mount",P),(0,e.hookMethod)(r,"update",S),r}))()}}},t.renderContent=N,t.setErrorInfo=x;var n=["status"];function o(r){return function(r){if(Array.isArray(r))return i(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,t){if(!r)return;if("string"==typeof r)return i(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return i(r,t)}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function u(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),e.push.apply(e,n)}return e}function c(r,t,e){return(t=p(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function a(r,t,e,n,o,i,u){try{var c=r[i](u),a=c.value}catch(r){return void e(r)}c.done?t(a):Promise.resolve(a).then(n,o)}function s(r){return function(){var t=this,e=arguments;return new Promise((function(n,o){var i=r.apply(t,e);function u(r){a(i,n,o,u,c,"next",r)}function c(r){a(i,n,o,u,c,"throw",r)}u(void 0)}))}}function f(r,t){if(null==r)return{};var e,n,o=function(r,t){if(null==r)return{};var e,n,o={},i=Object.keys(r);for(n=0;n<i.length;n++)e=i[n],t.indexOf(e)>=0||(o[e]=r[e]);return o}(r,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n<i.length;n++)e=i[n],t.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(r,e)&&(o[e]=r[e])}return o}function l(r,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,p(n.key),n)}}function p(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===r(e)?e:String(e)}function y(r,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,t){return r.__proto__=t,r},y(r,t)}function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(r){return!1}}();return function(){var n,o=b(t);if(e){var i=b(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(t,e){if(e&&("object"===r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(t)}(this,n)}}function b(r){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},b(r)}function m(r){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!(this instanceof m))throw new TypeError("Cannot call a class as a function");if(this.constructor===m)throw new TypeError("The ExtensibleError is an abstract class and must be extended before it can be instantiated.");Error.call(this,r),this.name=this.constructor.name,this.message=r,this._nativeError=new Error(r),this._nativeError.name=this.name,this._nativeError.columnNumber&&(this.lineNumber=this._nativeError.lineNumber,this.columnNumber=this._nativeError.columnNumber,this.fileName=this._nativeError.fileName),this._stack=null,this._dropInternalStackFrames=t}m.prototype=Object.create(Error.prototype),m.prototype.constructor=m,Object.defineProperty(m.prototype,"stack",{configurable:!0,enumerable:!1,get:function(){if(this._stack)return this._stack;var r=this._nativeError.stack;if("string"==typeof r){if(this._dropInternalStackFrames){for(var t=r.split("\n"),e=1,n=Object.getPrototypeOf(this);n!==m.prototype;)n=Object.getPrototypeOf(n),e++;t.splice(1,e),this._stack=t.join("\n")}else this._stack=r;return this._stack}}});var v=function(r){!function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),t&&y(r,t)}(u,r);var t,e,o,i=h(u);function u(r,t){var e;!function(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),e=i.call(this,r);var o=t.status,c=void 0===o?500:o,a=f(t,n);return e.name="Error",e.status=c,e._params=a,e}return t=u,(e=[{key:"params",get:function(){return this._params}}])&&l(t.prototype,e),o&&l(t,o),Object.defineProperty(t,"prototype",{writable:!1}),u}(m);t.GenericError=v;var d="development",g="undefined"!=typeof process&&process&&process.env?process.env.NODE_ENV:d,O={ERROR:"@merkur/plugin-error.error"};function w(r,t){return E.apply(this,arguments)}function E(){return E=s((function*(r,t){var e={};if(r.error.status)return e;try{for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];e=yield t.apply(void 0,o)}catch(t){t.status=t.status||500,x(r,t),M(r,t)}return e})),E.apply(this,arguments)}function j(r,t){return k.apply(this,arguments)}function k(){return k=s((function*(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];var i=yield t.apply(void 0,n);return function(r){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?u(Object(e),!0).forEach((function(t){c(r,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):u(Object(e)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))}))}return r}({error:r.error},i)})),k.apply(this,arguments)}function P(r,t){return _.apply(this,arguments)}function _(){return _=s((function*(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];return N(r,t,n)})),_.apply(this,arguments)}function S(r,t){return R.apply(this,arguments)}function R(){return R=s((function*(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];return N(r,t,n)})),R.apply(this,arguments)}function x(r,t){r.error.status=t.status,r.error.message=t.message,g===d&&(r.error.stack=t.stack)}function M(r,t){r.emit(O.ERROR,{error:t})}function N(r,t,e){return T.apply(this,arguments)}function T(){return(T=s((function*(r,t,e){if(r.error.status)try{return yield t.apply(void 0,o(e))}catch(r){return""}try{return yield t.apply(void 0,o(e))}catch(n){return n.status=n.status||500,x(r,n),M(r,n),N(r,t,e)}}))).apply(this,arguments)}t.ERROR_EVENTS=O}));
1
+ function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},r(t)}!function(r,t){if("function"==typeof define&&define.amd)define("@merkur/plugin-error",["exports","@merkur/core"],t);else if("undefined"!=typeof exports)t(exports,require("@merkur/core"));else{var e={exports:{}};t(e.exports,r.Merkur.Core),r.Merkur=r.Merkur||{},r.Merkur.Plugin=r.Merkur.Plugin||{},r.Merkur.Plugin.Error=e.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t,e){Object.defineProperty(t,"__esModule",{value:!0}),t.GenericError=t.ERROR_EVENTS=void 0,t.errorPlugin=function(){return{setup:function(r){return s((function*(){return r.error=r.error?r.error:{status:null,message:null},r}))()},create:function(r){return s((function*(){if(d===v){if(!r.$in.component)throw new Error("You must install missing plugin: npm i @merkur/plugin-component");if(!r.$in.eventEmitter)throw new Error("You must install missing plugin: npm i @merkur/plugin-event-emitter")}return(0,e.hookMethod)(r,"info",E),(0,e.hookMethod)(r,"load",O),(0,e.hookMethod)(r,"mount",k),(0,e.hookMethod)(r,"update",_),r}))()}}},t.renderContent=M,t.setErrorInfo=R;var n=["status"];function o(r){return function(r){if(Array.isArray(r))return i(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,t){if(!r)return;if("string"==typeof r)return i(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return i(r,t)}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function u(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),e.push.apply(e,n)}return e}function a(r,t,e){return(t=p(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function c(r,t,e,n,o,i,u){try{var a=r[i](u),c=a.value}catch(r){return void e(r)}a.done?t(c):Promise.resolve(c).then(n,o)}function s(r){return function(){var t=this,e=arguments;return new Promise((function(n,o){var i=r.apply(t,e);function u(r){c(i,n,o,u,a,"next",r)}function a(r){c(i,n,o,u,a,"throw",r)}u(void 0)}))}}function f(r,t){if(null==r)return{};var e,n,o=function(r,t){if(null==r)return{};var e,n,o={},i=Object.keys(r);for(n=0;n<i.length;n++)e=i[n],t.indexOf(e)>=0||(o[e]=r[e]);return o}(r,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n<i.length;n++)e=i[n],t.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(r,e)&&(o[e]=r[e])}return o}function l(r,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,p(n.key),n)}}function p(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"===r(e)?e:String(e)}function y(r,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,t){return r.__proto__=t,r},y(r,t)}function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(r){return!1}}();return function(){var n,o=b(t);if(e){var i=b(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return function(t,e){if(e&&("object"===r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(t)}(this,n)}}function b(r){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},b(r)}function m(r){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!(this instanceof m))throw new TypeError("Cannot call a class as a function");if(this.constructor===m)throw new TypeError("The ExtensibleError is an abstract class and must be extended before it can be instantiated.");Error.call(this,r),this.name=this.constructor.name,this.message=r,this._nativeError=new Error(r),this._nativeError.name=this.name,this._nativeError.columnNumber&&(this.lineNumber=this._nativeError.lineNumber,this.columnNumber=this._nativeError.columnNumber,this.fileName=this._nativeError.fileName),this._stack=null,this._dropInternalStackFrames=t}m.prototype=Object.create(Error.prototype),m.prototype.constructor=m,Object.defineProperty(m.prototype,"stack",{configurable:!0,enumerable:!1,get:function(){if(this._stack)return this._stack;var r=this._nativeError.stack;if("string"==typeof r){if(this._dropInternalStackFrames){for(var t=r.split("\n"),e=1,n=Object.getPrototypeOf(this);n!==m.prototype;)n=Object.getPrototypeOf(n),e++;t.splice(1,e),this._stack=t.join("\n")}else this._stack=r;return this._stack}}});t.GenericError=function(r){!function(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),t&&y(r,t)}(u,r);var t,e,o,i=h(u);function u(r,t){var e;!function(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),e=i.call(this,r);var o=t.status,a=void 0===o?500:o,c=f(t,n);return e.name="Error",e.status=a,e._params=c,e}return t=u,(e=[{key:"params",get:function(){return this._params}}])&&l(t.prototype,e),o&&l(t,o),Object.defineProperty(t,"prototype",{writable:!1}),u}(m);var v="development",d="undefined"!=typeof process&&process&&process.env?process.env.NODE_ENV:v,g=t.ERROR_EVENTS={ERROR:"@merkur/plugin-error.error"};function O(r,t){return w.apply(this,arguments)}function w(){return w=s((function*(r,t){var e={};if(r.error.status)return e;try{for(var n=arguments.length,o=new Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];e=yield t.apply(void 0,o)}catch(t){t.status=t.status||500,R(r,t),x(r,t)}return e})),w.apply(this,arguments)}function E(r,t){return j.apply(this,arguments)}function j(){return j=s((function*(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];var i=yield t.apply(void 0,n);return function(r){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?u(Object(e),!0).forEach((function(t){a(r,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):u(Object(e)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))}))}return r}({error:r.error},i)})),j.apply(this,arguments)}function k(r,t){return P.apply(this,arguments)}function P(){return P=s((function*(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];return M(r,t,n)})),P.apply(this,arguments)}function _(r,t){return S.apply(this,arguments)}function S(){return S=s((function*(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];return M(r,t,n)})),S.apply(this,arguments)}function R(r,t){var e;r.error.status=t.status,r.error.message=t.message,r.error.url=null===(e=t.params)||void 0===e?void 0:e.url,d===v&&(r.error.stack=t.stack)}function x(r,t){r.emit(g.ERROR,{error:t})}function M(r,t,e){return N.apply(this,arguments)}function N(){return(N=s((function*(r,t,e){if(r.error.status)try{return yield t.apply(void 0,o(e))}catch(r){return""}try{return yield t.apply(void 0,o(e))}catch(n){return n.status=n.status||500,R(r,n),x(r,n),M(r,t,e)}}))).apply(this,arguments)}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkur/plugin-error",
3
- "version": "0.33.0",
3
+ "version": "0.34.3",
4
4
  "description": "Merkur plugin for error handling.",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -50,12 +50,12 @@
50
50
  },
51
51
  "homepage": "https://merkur.js.org/",
52
52
  "devDependencies": {
53
- "@merkur/core": "^0.33.0",
54
- "@merkur/plugin-component": "^0.33.0"
53
+ "@merkur/core": "^0.34.0",
54
+ "@merkur/plugin-component": "^0.34.0"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@merkur/core": "*",
58
58
  "@merkur/plugin-component": "*"
59
59
  },
60
- "gitHead": "3e88b57abfad267ac3f3b20b2ae6bf50f93f5375"
60
+ "gitHead": "33f0f525bc40721c4c6749ae0f8624b15552f10e"
61
61
  }