UNPKG

vue-class-component

Version:

ES201X/TypeScript class decorator for Vue components

6 lines 6.27 kB
/** * vue-class-component v8.0.0-rc.1 * (c) 2015-present Evan You * @license MIT */ var VueClassComponent=function(t,e){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function c(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?u(Object(r),!0).forEach(function(e){o(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}function f(t){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}function p(t,e,r){return(p=s()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&a(o,r.prototype),o}).apply(null,arguments)}function l(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function y(t){var e=s();return function(){var r,n=f(t);if(e){var o=f(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return l(this,r)}}function b(t){return function(t){if(Array.isArray(t))return v(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return v(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return v(t,e)}(t)||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 v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function h(t,e,r){Object.defineProperty(t,e,{get:r,enumerable:!1,configurable:!0})}function _(t,e){return t.hasOwnProperty(e)?t[e]:void 0}var d=function(){function t(e,n){var o=this;r(this,t),h(this,"$props",function(){return e}),h(this,"$attrs",function(){return n.attrs}),h(this,"$slots",function(){return n.slots}),h(this,"$emit",function(){return n.emit}),Object.keys(e).forEach(function(t){Object.defineProperty(o,t,{enumerable:!1,configurable:!0,writable:!0,value:e[t]})})}var o,u,f;return o=t,f=[{key:"registerHooks",value:function(t){var e;(e=this.__h).push.apply(e,b(t))}},{key:"with",value:function(t){var e=new t,n={};Object.keys(e).forEach(function(t){var r=e[t];n[t]=null!==r&&void 0!==r?r:null});var o=function(t){i(n,t);var e=y(n);function n(){return r(this,n),e.apply(this,arguments)}return n}(this);return o.__b={props:n},o}},{key:"__vccOpts",get:function(){if(this===O)return{};var t=this,r=_(t,"__c");if(r)return r;var n=c({},_(t,"__o"));t.__c=n;var o=function(t){var e=Object.getPrototypeOf(t.prototype);if(e)return e.constructor}(t);o&&(n.extends=o.__vccOpts);var u=_(t,"__b");u&&(n.mixins=n.mixins||[],n.mixins.unshift(u)),n.methods=c({},n.methods),n.computed=c({},n.computed);var i=t.prototype;Object.getOwnPropertyNames(i).forEach(function(e){if("constructor"!==e)if(t.__h.indexOf(e)>-1)n[e]=i[e];else{var r=Object.getOwnPropertyDescriptor(i,e);"function"!=typeof r.value?(r.get||r.set)&&(n.computed[e]={get:r.get,set:r.set}):n.methods[e]=r.value}}),n.setup=function(r,n){var o,u=new t(r,n),c=Object.keys(u),i={},f=null;return c.forEach(function(t){void 0===u[t]||u[t]&&u[t].__s||(i[t]=e.ref(u[t]),function(t,e,r){Object.defineProperty(t,e,{get:function(){return r[e].value},set:function(t){r[e].value=t},enumerable:!0,configurable:!0})}(u,t,i))}),c.forEach(function(t){if(u[t]&&u[t].__s){var r=u[t].__s();r instanceof Promise?(f||(f=Promise.resolve(i)),f=f.then(function(){return r.then(function(r){return i[t]=e.proxyRefs(r),i})})):i[t]=e.proxyRefs(r)}}),null!==(o=f)&&void 0!==o?o:i};var f=_(t,"__d");f&&f.forEach(function(t){return t(n)});return["render","ssrRender","__file","__cssModules","__scopeId","__hmrId"].forEach(function(e){t[e]&&(n[e]=t[e])}),n}}],(u=null)&&n(o.prototype,u),f&&n(o,f),t}();d.__h=["data","beforeCreate","created","beforeMount","mounted","beforeUnmount","unmounted","beforeUpdate","updated","activated","deactivated","render","errorCaptured","serverPrefetch"];var O=d;return t.Options=function(t){return function(e){return e.__o=t,e}},t.Vue=O,t.createDecorator=function(t){return function(e,r,n){var o="function"==typeof e?e:e.constructor;o.__d||(o.__d=[]),"number"!=typeof n&&(n=void 0),o.__d.push(function(e){return t(e,r,n)})}},t.mixins=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var o;return(o=function(t){i(o,O);var n=y(o);function o(){for(var t,u=arguments.length,c=new Array(u),i=0;i<u;i++)c[i]=arguments[i];return r(this,o),t=n.call.apply(n,[this].concat(c)),e.forEach(function(e){var r=p(e,c);Object.keys(r).forEach(function(e){t[e]=r[e]})}),t}return o}()).__b={mixins:e.map(function(t){return t.__vccOpts})},o},t.prop=function(t){return t},t.setup=function(t){return{__s:t}},t}({},Vue);