This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-present Evan You
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+17
View File
@@ -0,0 +1,17 @@
# Vue Class Component
ECMAScript / TypeScript decorator for class-style Vue components.
[![npm](https://img.shields.io/npm/v/vue-class-component.svg)](https://www.npmjs.com/package/vue-class-component)
## Document
See [https://class-component.vuejs.org](https://class-component.vuejs.org)
## Questions
For questions and support please use the [the official forum](http://forum.vuejs.org) or [community chat](https://chat.vuejs.org/). The issue list of this repo is **exclusively** for bug reports and feature requests.
## License
[MIT](http://opensource.org/licenses/MIT)
+329
View File
@@ -0,0 +1,329 @@
/**
* vue-class-component v7.2.3
* (c) 2015-present Evan You
* @license MIT
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var Vue = _interopDefault(require('vue'));
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
// The rational behind the verbose Reflect-feature check below is the fact that there are polyfills
// which add an implementation for Reflect.defineMetadata but not for Reflect.getOwnMetadataKeys.
// Without this check consumers will encounter hard to track down runtime errors.
function reflectionIsSupported() {
return typeof Reflect !== 'undefined' && Reflect.defineMetadata && Reflect.getOwnMetadataKeys;
}
function copyReflectionMetadata(to, from) {
forwardMetadata(to, from);
Object.getOwnPropertyNames(from.prototype).forEach(function (key) {
forwardMetadata(to.prototype, from.prototype, key);
});
Object.getOwnPropertyNames(from).forEach(function (key) {
forwardMetadata(to, from, key);
});
}
function forwardMetadata(to, from, propertyKey) {
var metaKeys = propertyKey ? Reflect.getOwnMetadataKeys(from, propertyKey) : Reflect.getOwnMetadataKeys(from);
metaKeys.forEach(function (metaKey) {
var metadata = propertyKey ? Reflect.getOwnMetadata(metaKey, from, propertyKey) : Reflect.getOwnMetadata(metaKey, from);
if (propertyKey) {
Reflect.defineMetadata(metaKey, metadata, to, propertyKey);
} else {
Reflect.defineMetadata(metaKey, metadata, to);
}
});
}
var fakeArray = {
__proto__: []
};
var hasProto = fakeArray instanceof Array;
function createDecorator(factory) {
return function (target, key, index) {
var Ctor = typeof target === 'function' ? target : target.constructor;
if (!Ctor.__decorators__) {
Ctor.__decorators__ = [];
}
if (typeof index !== 'number') {
index = undefined;
}
Ctor.__decorators__.push(function (options) {
return factory(options, key, index);
});
};
}
function mixins() {
for (var _len = arguments.length, Ctors = new Array(_len), _key = 0; _key < _len; _key++) {
Ctors[_key] = arguments[_key];
}
return Vue.extend({
mixins: Ctors
});
}
function isPrimitive(value) {
var type = _typeof(value);
return value == null || type !== 'object' && type !== 'function';
}
function warn(message) {
if (typeof console !== 'undefined') {
console.warn('[vue-class-component] ' + message);
}
}
function collectDataFromConstructor(vm, Component) {
// override _init to prevent to init as Vue instance
var originalInit = Component.prototype._init;
Component.prototype._init = function () {
var _this = this;
// proxy to actual vm
var keys = Object.getOwnPropertyNames(vm); // 2.2.0 compat (props are no longer exposed as self properties)
if (vm.$options.props) {
for (var key in vm.$options.props) {
if (!vm.hasOwnProperty(key)) {
keys.push(key);
}
}
}
keys.forEach(function (key) {
if (key.charAt(0) !== '_') {
Object.defineProperty(_this, key, {
get: function get() {
return vm[key];
},
set: function set(value) {
vm[key] = value;
},
configurable: true
});
}
});
}; // should be acquired class property values
var data = new Component(); // restore original _init to avoid memory leak (#209)
Component.prototype._init = originalInit; // create plain data object
var plainData = {};
Object.keys(data).forEach(function (key) {
if (data[key] !== undefined) {
plainData[key] = data[key];
}
});
if (process.env.NODE_ENV !== 'production') {
if (!(Component.prototype instanceof Vue) && Object.keys(plainData).length > 0) {
warn('Component class must inherit Vue or its descendant class ' + 'when class property is used.');
}
}
return plainData;
}
var $internalHooks = ['data', 'beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeDestroy', 'destroyed', 'beforeUpdate', 'updated', 'activated', 'deactivated', 'render', 'errorCaptured', 'serverPrefetch' // 2.6
];
function componentFactory(Component) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
options.name = options.name || Component._componentTag || Component.name; // prototype props.
var proto = Component.prototype;
Object.getOwnPropertyNames(proto).forEach(function (key) {
if (key === 'constructor') {
return;
} // hooks
if ($internalHooks.indexOf(key) > -1) {
options[key] = proto[key];
return;
}
var descriptor = Object.getOwnPropertyDescriptor(proto, key);
if (descriptor.value !== void 0) {
// methods
if (typeof descriptor.value === 'function') {
(options.methods || (options.methods = {}))[key] = descriptor.value;
} else {
// typescript decorated data
(options.mixins || (options.mixins = [])).push({
data: function data() {
return _defineProperty({}, key, descriptor.value);
}
});
}
} else if (descriptor.get || descriptor.set) {
// computed properties
(options.computed || (options.computed = {}))[key] = {
get: descriptor.get,
set: descriptor.set
};
}
});
(options.mixins || (options.mixins = [])).push({
data: function data() {
return collectDataFromConstructor(this, Component);
}
}); // decorate options
var decorators = Component.__decorators__;
if (decorators) {
decorators.forEach(function (fn) {
return fn(options);
});
delete Component.__decorators__;
} // find super
var superProto = Object.getPrototypeOf(Component.prototype);
var Super = superProto instanceof Vue ? superProto.constructor : Vue;
var Extended = Super.extend(options);
forwardStaticMembers(Extended, Component, Super);
if (reflectionIsSupported()) {
copyReflectionMetadata(Extended, Component);
}
return Extended;
}
var reservedPropertyNames = [// Unique id
'cid', // Super Vue constructor
'super', // Component options that will be used by the component
'options', 'superOptions', 'extendOptions', 'sealedOptions', // Private assets
'component', 'directive', 'filter'];
var shouldIgnore = {
prototype: true,
arguments: true,
callee: true,
caller: true
};
function forwardStaticMembers(Extended, Original, Super) {
// We have to use getOwnPropertyNames since Babel registers methods as non-enumerable
Object.getOwnPropertyNames(Original).forEach(function (key) {
// Skip the properties that should not be overwritten
if (shouldIgnore[key]) {
return;
} // Some browsers does not allow reconfigure built-in properties
var extendedDescriptor = Object.getOwnPropertyDescriptor(Extended, key);
if (extendedDescriptor && !extendedDescriptor.configurable) {
return;
}
var descriptor = Object.getOwnPropertyDescriptor(Original, key); // If the user agent does not support `__proto__` or its family (IE <= 10),
// the sub class properties may be inherited properties from the super class in TypeScript.
// We need to exclude such properties to prevent to overwrite
// the component options object which stored on the extended constructor (See #192).
// If the value is a referenced value (object or function),
// we can check equality of them and exclude it if they have the same reference.
// If it is a primitive value, it will be forwarded for safety.
if (!hasProto) {
// Only `cid` is explicitly exluded from property forwarding
// because we cannot detect whether it is a inherited property or not
// on the no `__proto__` environment even though the property is reserved.
if (key === 'cid') {
return;
}
var superDescriptor = Object.getOwnPropertyDescriptor(Super, key);
if (!isPrimitive(descriptor.value) && superDescriptor && superDescriptor.value === descriptor.value) {
return;
}
} // Warn if the users manually declare reserved properties
if (process.env.NODE_ENV !== 'production' && reservedPropertyNames.indexOf(key) >= 0) {
warn("Static property name '".concat(key, "' declared on class '").concat(Original.name, "' ") + 'conflicts with reserved property name of Vue internal. ' + 'It may cause unexpected behavior of the component. Consider renaming the property.');
}
Object.defineProperty(Extended, key, descriptor);
});
}
function Component(options) {
if (typeof options === 'function') {
return componentFactory(options);
}
return function (Component) {
return componentFactory(Component, options);
};
}
Component.registerHooks = function registerHooks(keys) {
$internalHooks.push.apply($internalHooks, _toConsumableArray(keys));
};
exports.createDecorator = createDecorator;
exports.default = Component;
exports.mixins = mixins;
@@ -0,0 +1,268 @@
/**
* vue-class-component v7.2.3
* (c) 2015-present Evan You
* @license MIT
*/
import Vue from 'vue';
// The rational behind the verbose Reflect-feature check below is the fact that there are polyfills
// which add an implementation for Reflect.defineMetadata but not for Reflect.getOwnMetadataKeys.
// Without this check consumers will encounter hard to track down runtime errors.
function reflectionIsSupported() {
return typeof Reflect !== 'undefined' && Reflect.defineMetadata && Reflect.getOwnMetadataKeys;
}
function copyReflectionMetadata(to, from) {
forwardMetadata(to, from);
Object.getOwnPropertyNames(from.prototype).forEach(key => {
forwardMetadata(to.prototype, from.prototype, key);
});
Object.getOwnPropertyNames(from).forEach(key => {
forwardMetadata(to, from, key);
});
}
function forwardMetadata(to, from, propertyKey) {
var metaKeys = propertyKey ? Reflect.getOwnMetadataKeys(from, propertyKey) : Reflect.getOwnMetadataKeys(from);
metaKeys.forEach(metaKey => {
var metadata = propertyKey ? Reflect.getOwnMetadata(metaKey, from, propertyKey) : Reflect.getOwnMetadata(metaKey, from);
if (propertyKey) {
Reflect.defineMetadata(metaKey, metadata, to, propertyKey);
} else {
Reflect.defineMetadata(metaKey, metadata, to);
}
});
}
var fakeArray = {
__proto__: []
};
var hasProto = fakeArray instanceof Array;
function createDecorator(factory) {
return (target, key, index) => {
var Ctor = typeof target === 'function' ? target : target.constructor;
if (!Ctor.__decorators__) {
Ctor.__decorators__ = [];
}
if (typeof index !== 'number') {
index = undefined;
}
Ctor.__decorators__.push(options => factory(options, key, index));
};
}
function mixins() {
for (var _len = arguments.length, Ctors = new Array(_len), _key = 0; _key < _len; _key++) {
Ctors[_key] = arguments[_key];
}
return Vue.extend({
mixins: Ctors
});
}
function isPrimitive(value) {
var type = typeof value;
return value == null || type !== 'object' && type !== 'function';
}
function warn(message) {
if (typeof console !== 'undefined') {
console.warn('[vue-class-component] ' + message);
}
}
function collectDataFromConstructor(vm, Component) {
// override _init to prevent to init as Vue instance
var originalInit = Component.prototype._init;
Component.prototype._init = function () {
// proxy to actual vm
var keys = Object.getOwnPropertyNames(vm); // 2.2.0 compat (props are no longer exposed as self properties)
if (vm.$options.props) {
for (var key in vm.$options.props) {
if (!vm.hasOwnProperty(key)) {
keys.push(key);
}
}
}
keys.forEach(key => {
if (key.charAt(0) !== '_') {
Object.defineProperty(this, key, {
get: () => vm[key],
set: value => {
vm[key] = value;
},
configurable: true
});
}
});
}; // should be acquired class property values
var data = new Component(); // restore original _init to avoid memory leak (#209)
Component.prototype._init = originalInit; // create plain data object
var plainData = {};
Object.keys(data).forEach(key => {
if (data[key] !== undefined) {
plainData[key] = data[key];
}
});
{
if (!(Component.prototype instanceof Vue) && Object.keys(plainData).length > 0) {
warn('Component class must inherit Vue or its descendant class ' + 'when class property is used.');
}
}
return plainData;
}
var $internalHooks = ['data', 'beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeDestroy', 'destroyed', 'beforeUpdate', 'updated', 'activated', 'deactivated', 'render', 'errorCaptured', 'serverPrefetch' // 2.6
];
function componentFactory(Component) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
options.name = options.name || Component._componentTag || Component.name; // prototype props.
var proto = Component.prototype;
Object.getOwnPropertyNames(proto).forEach(function (key) {
if (key === 'constructor') {
return;
} // hooks
if ($internalHooks.indexOf(key) > -1) {
options[key] = proto[key];
return;
}
var descriptor = Object.getOwnPropertyDescriptor(proto, key);
if (descriptor.value !== void 0) {
// methods
if (typeof descriptor.value === 'function') {
(options.methods || (options.methods = {}))[key] = descriptor.value;
} else {
// typescript decorated data
(options.mixins || (options.mixins = [])).push({
data() {
return {
[key]: descriptor.value
};
}
});
}
} else if (descriptor.get || descriptor.set) {
// computed properties
(options.computed || (options.computed = {}))[key] = {
get: descriptor.get,
set: descriptor.set
};
}
});
(options.mixins || (options.mixins = [])).push({
data() {
return collectDataFromConstructor(this, Component);
}
}); // decorate options
var decorators = Component.__decorators__;
if (decorators) {
decorators.forEach(fn => fn(options));
delete Component.__decorators__;
} // find super
var superProto = Object.getPrototypeOf(Component.prototype);
var Super = superProto instanceof Vue ? superProto.constructor : Vue;
var Extended = Super.extend(options);
forwardStaticMembers(Extended, Component, Super);
if (reflectionIsSupported()) {
copyReflectionMetadata(Extended, Component);
}
return Extended;
}
var reservedPropertyNames = [// Unique id
'cid', // Super Vue constructor
'super', // Component options that will be used by the component
'options', 'superOptions', 'extendOptions', 'sealedOptions', // Private assets
'component', 'directive', 'filter'];
var shouldIgnore = {
prototype: true,
arguments: true,
callee: true,
caller: true
};
function forwardStaticMembers(Extended, Original, Super) {
// We have to use getOwnPropertyNames since Babel registers methods as non-enumerable
Object.getOwnPropertyNames(Original).forEach(key => {
// Skip the properties that should not be overwritten
if (shouldIgnore[key]) {
return;
} // Some browsers does not allow reconfigure built-in properties
var extendedDescriptor = Object.getOwnPropertyDescriptor(Extended, key);
if (extendedDescriptor && !extendedDescriptor.configurable) {
return;
}
var descriptor = Object.getOwnPropertyDescriptor(Original, key); // If the user agent does not support `__proto__` or its family (IE <= 10),
// the sub class properties may be inherited properties from the super class in TypeScript.
// We need to exclude such properties to prevent to overwrite
// the component options object which stored on the extended constructor (See #192).
// If the value is a referenced value (object or function),
// we can check equality of them and exclude it if they have the same reference.
// If it is a primitive value, it will be forwarded for safety.
if (!hasProto) {
// Only `cid` is explicitly exluded from property forwarding
// because we cannot detect whether it is a inherited property or not
// on the no `__proto__` environment even though the property is reserved.
if (key === 'cid') {
return;
}
var superDescriptor = Object.getOwnPropertyDescriptor(Super, key);
if (!isPrimitive(descriptor.value) && superDescriptor && superDescriptor.value === descriptor.value) {
return;
}
} // Warn if the users manually declare reserved properties
if ( reservedPropertyNames.indexOf(key) >= 0) {
warn("Static property name '".concat(key, "' declared on class '").concat(Original.name, "' ") + 'conflicts with reserved property name of Vue internal. ' + 'It may cause unexpected behavior of the component. Consider renaming the property.');
}
Object.defineProperty(Extended, key, descriptor);
});
}
function Component(options) {
if (typeof options === 'function') {
return componentFactory(options);
}
return function (Component) {
return componentFactory(Component, options);
};
}
Component.registerHooks = function registerHooks(keys) {
$internalHooks.push(...keys);
};
export default Component;
export { createDecorator, mixins };
@@ -0,0 +1,6 @@
/**
* vue-class-component v7.2.3
* (c) 2015-present Evan You
* @license MIT
*/
import Vue from"vue";function reflectionIsSupported(){return"undefined"!=typeof Reflect&&Reflect.defineMetadata&&Reflect.getOwnMetadataKeys}function copyReflectionMetadata(e,t){forwardMetadata(e,t),Object.getOwnPropertyNames(t.prototype).forEach(r=>{forwardMetadata(e.prototype,t.prototype,r)}),Object.getOwnPropertyNames(t).forEach(r=>{forwardMetadata(e,t,r)})}function forwardMetadata(e,t,r){(r?Reflect.getOwnMetadataKeys(t,r):Reflect.getOwnMetadataKeys(t)).forEach(o=>{var a=r?Reflect.getOwnMetadata(o,t,r):Reflect.getOwnMetadata(o,t);r?Reflect.defineMetadata(o,a,e,r):Reflect.defineMetadata(o,a,e)})}var fakeArray={__proto__:[]},hasProto=fakeArray instanceof Array;function createDecorator(e){return(t,r,o)=>{var a="function"==typeof t?t:t.constructor;a.__decorators__||(a.__decorators__=[]),"number"!=typeof o&&(o=void 0),a.__decorators__.push(t=>e(t,r,o))}}function mixins(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Vue.extend({mixins:t})}function isPrimitive(e){var t=typeof e;return null==e||"object"!==t&&"function"!==t}function collectDataFromConstructor(e,t){var r=t.prototype._init;t.prototype._init=function(){var t=Object.getOwnPropertyNames(e);if(e.$options.props)for(var r in e.$options.props)e.hasOwnProperty(r)||t.push(r);t.forEach(t=>{"_"!==t.charAt(0)&&Object.defineProperty(this,t,{get:()=>e[t],set:r=>{e[t]=r},configurable:!0})})};var o=new t;t.prototype._init=r;var a={};return Object.keys(o).forEach(e=>{void 0!==o[e]&&(a[e]=o[e])}),a}var $internalHooks=["data","beforeCreate","created","beforeMount","mounted","beforeDestroy","destroyed","beforeUpdate","updated","activated","deactivated","render","errorCaptured","serverPrefetch"];function componentFactory(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.name=t.name||e._componentTag||e.name;var r=e.prototype;Object.getOwnPropertyNames(r).forEach(function(e){if("constructor"!==e)if($internalHooks.indexOf(e)>-1)t[e]=r[e];else{var o=Object.getOwnPropertyDescriptor(r,e);void 0!==o.value?"function"==typeof o.value?(t.methods||(t.methods={}))[e]=o.value:(t.mixins||(t.mixins=[])).push({data:()=>({[e]:o.value})}):(o.get||o.set)&&((t.computed||(t.computed={}))[e]={get:o.get,set:o.set})}}),(t.mixins||(t.mixins=[])).push({data(){return collectDataFromConstructor(this,e)}});var o=e.__decorators__;o&&(o.forEach(e=>e(t)),delete e.__decorators__);var a=Object.getPrototypeOf(e.prototype),n=a instanceof Vue?a.constructor:Vue,c=n.extend(t);return forwardStaticMembers(c,e,n),reflectionIsSupported()&&copyReflectionMetadata(c,e),c}var shouldIgnore={prototype:!0,arguments:!0,callee:!0,caller:!0};function forwardStaticMembers(e,t,r){Object.getOwnPropertyNames(t).forEach(o=>{if(!shouldIgnore[o]){var a=Object.getOwnPropertyDescriptor(e,o);if(!a||a.configurable){var n=Object.getOwnPropertyDescriptor(t,o);if(!hasProto){if("cid"===o)return;var c=Object.getOwnPropertyDescriptor(r,o);if(!isPrimitive(n.value)&&c&&c.value===n.value)return}Object.defineProperty(e,o,n)}}})}function Component(e){return"function"==typeof e?componentFactory(e):function(t){return componentFactory(t,e)}}Component.registerHooks=function(e){$internalHooks.push(...e)};export default Component;export{createDecorator,mixins};
+322
View File
@@ -0,0 +1,322 @@
/**
* vue-class-component v7.2.3
* (c) 2015-present Evan You
* @license MIT
*/
import Vue from 'vue';
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
// The rational behind the verbose Reflect-feature check below is the fact that there are polyfills
// which add an implementation for Reflect.defineMetadata but not for Reflect.getOwnMetadataKeys.
// Without this check consumers will encounter hard to track down runtime errors.
function reflectionIsSupported() {
return typeof Reflect !== 'undefined' && Reflect.defineMetadata && Reflect.getOwnMetadataKeys;
}
function copyReflectionMetadata(to, from) {
forwardMetadata(to, from);
Object.getOwnPropertyNames(from.prototype).forEach(function (key) {
forwardMetadata(to.prototype, from.prototype, key);
});
Object.getOwnPropertyNames(from).forEach(function (key) {
forwardMetadata(to, from, key);
});
}
function forwardMetadata(to, from, propertyKey) {
var metaKeys = propertyKey ? Reflect.getOwnMetadataKeys(from, propertyKey) : Reflect.getOwnMetadataKeys(from);
metaKeys.forEach(function (metaKey) {
var metadata = propertyKey ? Reflect.getOwnMetadata(metaKey, from, propertyKey) : Reflect.getOwnMetadata(metaKey, from);
if (propertyKey) {
Reflect.defineMetadata(metaKey, metadata, to, propertyKey);
} else {
Reflect.defineMetadata(metaKey, metadata, to);
}
});
}
var fakeArray = {
__proto__: []
};
var hasProto = fakeArray instanceof Array;
function createDecorator(factory) {
return function (target, key, index) {
var Ctor = typeof target === 'function' ? target : target.constructor;
if (!Ctor.__decorators__) {
Ctor.__decorators__ = [];
}
if (typeof index !== 'number') {
index = undefined;
}
Ctor.__decorators__.push(function (options) {
return factory(options, key, index);
});
};
}
function mixins() {
for (var _len = arguments.length, Ctors = new Array(_len), _key = 0; _key < _len; _key++) {
Ctors[_key] = arguments[_key];
}
return Vue.extend({
mixins: Ctors
});
}
function isPrimitive(value) {
var type = _typeof(value);
return value == null || type !== 'object' && type !== 'function';
}
function warn(message) {
if (typeof console !== 'undefined') {
console.warn('[vue-class-component] ' + message);
}
}
function collectDataFromConstructor(vm, Component) {
// override _init to prevent to init as Vue instance
var originalInit = Component.prototype._init;
Component.prototype._init = function () {
var _this = this;
// proxy to actual vm
var keys = Object.getOwnPropertyNames(vm); // 2.2.0 compat (props are no longer exposed as self properties)
if (vm.$options.props) {
for (var key in vm.$options.props) {
if (!vm.hasOwnProperty(key)) {
keys.push(key);
}
}
}
keys.forEach(function (key) {
if (key.charAt(0) !== '_') {
Object.defineProperty(_this, key, {
get: function get() {
return vm[key];
},
set: function set(value) {
vm[key] = value;
},
configurable: true
});
}
});
}; // should be acquired class property values
var data = new Component(); // restore original _init to avoid memory leak (#209)
Component.prototype._init = originalInit; // create plain data object
var plainData = {};
Object.keys(data).forEach(function (key) {
if (data[key] !== undefined) {
plainData[key] = data[key];
}
});
if (process.env.NODE_ENV !== 'production') {
if (!(Component.prototype instanceof Vue) && Object.keys(plainData).length > 0) {
warn('Component class must inherit Vue or its descendant class ' + 'when class property is used.');
}
}
return plainData;
}
var $internalHooks = ['data', 'beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeDestroy', 'destroyed', 'beforeUpdate', 'updated', 'activated', 'deactivated', 'render', 'errorCaptured', 'serverPrefetch' // 2.6
];
function componentFactory(Component) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
options.name = options.name || Component._componentTag || Component.name; // prototype props.
var proto = Component.prototype;
Object.getOwnPropertyNames(proto).forEach(function (key) {
if (key === 'constructor') {
return;
} // hooks
if ($internalHooks.indexOf(key) > -1) {
options[key] = proto[key];
return;
}
var descriptor = Object.getOwnPropertyDescriptor(proto, key);
if (descriptor.value !== void 0) {
// methods
if (typeof descriptor.value === 'function') {
(options.methods || (options.methods = {}))[key] = descriptor.value;
} else {
// typescript decorated data
(options.mixins || (options.mixins = [])).push({
data: function data() {
return _defineProperty({}, key, descriptor.value);
}
});
}
} else if (descriptor.get || descriptor.set) {
// computed properties
(options.computed || (options.computed = {}))[key] = {
get: descriptor.get,
set: descriptor.set
};
}
});
(options.mixins || (options.mixins = [])).push({
data: function data() {
return collectDataFromConstructor(this, Component);
}
}); // decorate options
var decorators = Component.__decorators__;
if (decorators) {
decorators.forEach(function (fn) {
return fn(options);
});
delete Component.__decorators__;
} // find super
var superProto = Object.getPrototypeOf(Component.prototype);
var Super = superProto instanceof Vue ? superProto.constructor : Vue;
var Extended = Super.extend(options);
forwardStaticMembers(Extended, Component, Super);
if (reflectionIsSupported()) {
copyReflectionMetadata(Extended, Component);
}
return Extended;
}
var reservedPropertyNames = [// Unique id
'cid', // Super Vue constructor
'super', // Component options that will be used by the component
'options', 'superOptions', 'extendOptions', 'sealedOptions', // Private assets
'component', 'directive', 'filter'];
var shouldIgnore = {
prototype: true,
arguments: true,
callee: true,
caller: true
};
function forwardStaticMembers(Extended, Original, Super) {
// We have to use getOwnPropertyNames since Babel registers methods as non-enumerable
Object.getOwnPropertyNames(Original).forEach(function (key) {
// Skip the properties that should not be overwritten
if (shouldIgnore[key]) {
return;
} // Some browsers does not allow reconfigure built-in properties
var extendedDescriptor = Object.getOwnPropertyDescriptor(Extended, key);
if (extendedDescriptor && !extendedDescriptor.configurable) {
return;
}
var descriptor = Object.getOwnPropertyDescriptor(Original, key); // If the user agent does not support `__proto__` or its family (IE <= 10),
// the sub class properties may be inherited properties from the super class in TypeScript.
// We need to exclude such properties to prevent to overwrite
// the component options object which stored on the extended constructor (See #192).
// If the value is a referenced value (object or function),
// we can check equality of them and exclude it if they have the same reference.
// If it is a primitive value, it will be forwarded for safety.
if (!hasProto) {
// Only `cid` is explicitly exluded from property forwarding
// because we cannot detect whether it is a inherited property or not
// on the no `__proto__` environment even though the property is reserved.
if (key === 'cid') {
return;
}
var superDescriptor = Object.getOwnPropertyDescriptor(Super, key);
if (!isPrimitive(descriptor.value) && superDescriptor && superDescriptor.value === descriptor.value) {
return;
}
} // Warn if the users manually declare reserved properties
if (process.env.NODE_ENV !== 'production' && reservedPropertyNames.indexOf(key) >= 0) {
warn("Static property name '".concat(key, "' declared on class '").concat(Original.name, "' ") + 'conflicts with reserved property name of Vue internal. ' + 'It may cause unexpected behavior of the component. Consider renaming the property.');
}
Object.defineProperty(Extended, key, descriptor);
});
}
function Component(options) {
if (typeof options === 'function') {
return componentFactory(options);
}
return function (Component) {
return componentFactory(Component, options);
};
}
Component.registerHooks = function registerHooks(keys) {
$internalHooks.push.apply($internalHooks, _toConsumableArray(keys));
};
export default Component;
export { createDecorator, mixins };
+333
View File
@@ -0,0 +1,333 @@
/**
* vue-class-component v7.2.3
* (c) 2015-present Evan You
* @license MIT
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
(global = global || self, factory(global.VueClassComponent = {}, global.Vue));
}(this, (function (exports, Vue) { 'use strict';
Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue;
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
// The rational behind the verbose Reflect-feature check below is the fact that there are polyfills
// which add an implementation for Reflect.defineMetadata but not for Reflect.getOwnMetadataKeys.
// Without this check consumers will encounter hard to track down runtime errors.
function reflectionIsSupported() {
return typeof Reflect !== 'undefined' && Reflect.defineMetadata && Reflect.getOwnMetadataKeys;
}
function copyReflectionMetadata(to, from) {
forwardMetadata(to, from);
Object.getOwnPropertyNames(from.prototype).forEach(function (key) {
forwardMetadata(to.prototype, from.prototype, key);
});
Object.getOwnPropertyNames(from).forEach(function (key) {
forwardMetadata(to, from, key);
});
}
function forwardMetadata(to, from, propertyKey) {
var metaKeys = propertyKey ? Reflect.getOwnMetadataKeys(from, propertyKey) : Reflect.getOwnMetadataKeys(from);
metaKeys.forEach(function (metaKey) {
var metadata = propertyKey ? Reflect.getOwnMetadata(metaKey, from, propertyKey) : Reflect.getOwnMetadata(metaKey, from);
if (propertyKey) {
Reflect.defineMetadata(metaKey, metadata, to, propertyKey);
} else {
Reflect.defineMetadata(metaKey, metadata, to);
}
});
}
var fakeArray = {
__proto__: []
};
var hasProto = fakeArray instanceof Array;
function createDecorator(factory) {
return function (target, key, index) {
var Ctor = typeof target === 'function' ? target : target.constructor;
if (!Ctor.__decorators__) {
Ctor.__decorators__ = [];
}
if (typeof index !== 'number') {
index = undefined;
}
Ctor.__decorators__.push(function (options) {
return factory(options, key, index);
});
};
}
function mixins() {
for (var _len = arguments.length, Ctors = new Array(_len), _key = 0; _key < _len; _key++) {
Ctors[_key] = arguments[_key];
}
return Vue.extend({
mixins: Ctors
});
}
function isPrimitive(value) {
var type = _typeof(value);
return value == null || type !== 'object' && type !== 'function';
}
function warn(message) {
if (typeof console !== 'undefined') {
console.warn('[vue-class-component] ' + message);
}
}
function collectDataFromConstructor(vm, Component) {
// override _init to prevent to init as Vue instance
var originalInit = Component.prototype._init;
Component.prototype._init = function () {
var _this = this;
// proxy to actual vm
var keys = Object.getOwnPropertyNames(vm); // 2.2.0 compat (props are no longer exposed as self properties)
if (vm.$options.props) {
for (var key in vm.$options.props) {
if (!vm.hasOwnProperty(key)) {
keys.push(key);
}
}
}
keys.forEach(function (key) {
if (key.charAt(0) !== '_') {
Object.defineProperty(_this, key, {
get: function get() {
return vm[key];
},
set: function set(value) {
vm[key] = value;
},
configurable: true
});
}
});
}; // should be acquired class property values
var data = new Component(); // restore original _init to avoid memory leak (#209)
Component.prototype._init = originalInit; // create plain data object
var plainData = {};
Object.keys(data).forEach(function (key) {
if (data[key] !== undefined) {
plainData[key] = data[key];
}
});
{
if (!(Component.prototype instanceof Vue) && Object.keys(plainData).length > 0) {
warn('Component class must inherit Vue or its descendant class ' + 'when class property is used.');
}
}
return plainData;
}
var $internalHooks = ['data', 'beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeDestroy', 'destroyed', 'beforeUpdate', 'updated', 'activated', 'deactivated', 'render', 'errorCaptured', 'serverPrefetch' // 2.6
];
function componentFactory(Component) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
options.name = options.name || Component._componentTag || Component.name; // prototype props.
var proto = Component.prototype;
Object.getOwnPropertyNames(proto).forEach(function (key) {
if (key === 'constructor') {
return;
} // hooks
if ($internalHooks.indexOf(key) > -1) {
options[key] = proto[key];
return;
}
var descriptor = Object.getOwnPropertyDescriptor(proto, key);
if (descriptor.value !== void 0) {
// methods
if (typeof descriptor.value === 'function') {
(options.methods || (options.methods = {}))[key] = descriptor.value;
} else {
// typescript decorated data
(options.mixins || (options.mixins = [])).push({
data: function data() {
return _defineProperty({}, key, descriptor.value);
}
});
}
} else if (descriptor.get || descriptor.set) {
// computed properties
(options.computed || (options.computed = {}))[key] = {
get: descriptor.get,
set: descriptor.set
};
}
});
(options.mixins || (options.mixins = [])).push({
data: function data() {
return collectDataFromConstructor(this, Component);
}
}); // decorate options
var decorators = Component.__decorators__;
if (decorators) {
decorators.forEach(function (fn) {
return fn(options);
});
delete Component.__decorators__;
} // find super
var superProto = Object.getPrototypeOf(Component.prototype);
var Super = superProto instanceof Vue ? superProto.constructor : Vue;
var Extended = Super.extend(options);
forwardStaticMembers(Extended, Component, Super);
if (reflectionIsSupported()) {
copyReflectionMetadata(Extended, Component);
}
return Extended;
}
var reservedPropertyNames = [// Unique id
'cid', // Super Vue constructor
'super', // Component options that will be used by the component
'options', 'superOptions', 'extendOptions', 'sealedOptions', // Private assets
'component', 'directive', 'filter'];
var shouldIgnore = {
prototype: true,
arguments: true,
callee: true,
caller: true
};
function forwardStaticMembers(Extended, Original, Super) {
// We have to use getOwnPropertyNames since Babel registers methods as non-enumerable
Object.getOwnPropertyNames(Original).forEach(function (key) {
// Skip the properties that should not be overwritten
if (shouldIgnore[key]) {
return;
} // Some browsers does not allow reconfigure built-in properties
var extendedDescriptor = Object.getOwnPropertyDescriptor(Extended, key);
if (extendedDescriptor && !extendedDescriptor.configurable) {
return;
}
var descriptor = Object.getOwnPropertyDescriptor(Original, key); // If the user agent does not support `__proto__` or its family (IE <= 10),
// the sub class properties may be inherited properties from the super class in TypeScript.
// We need to exclude such properties to prevent to overwrite
// the component options object which stored on the extended constructor (See #192).
// If the value is a referenced value (object or function),
// we can check equality of them and exclude it if they have the same reference.
// If it is a primitive value, it will be forwarded for safety.
if (!hasProto) {
// Only `cid` is explicitly exluded from property forwarding
// because we cannot detect whether it is a inherited property or not
// on the no `__proto__` environment even though the property is reserved.
if (key === 'cid') {
return;
}
var superDescriptor = Object.getOwnPropertyDescriptor(Super, key);
if (!isPrimitive(descriptor.value) && superDescriptor && superDescriptor.value === descriptor.value) {
return;
}
} // Warn if the users manually declare reserved properties
if ( reservedPropertyNames.indexOf(key) >= 0) {
warn("Static property name '".concat(key, "' declared on class '").concat(Original.name, "' ") + 'conflicts with reserved property name of Vue internal. ' + 'It may cause unexpected behavior of the component. Consider renaming the property.');
}
Object.defineProperty(Extended, key, descriptor);
});
}
function Component(options) {
if (typeof options === 'function') {
return componentFactory(options);
}
return function (Component) {
return componentFactory(Component, options);
};
}
Component.registerHooks = function registerHooks(keys) {
$internalHooks.push.apply($internalHooks, _toConsumableArray(keys));
};
exports.createDecorator = createDecorator;
exports.default = Component;
exports.mixins = mixins;
Object.defineProperty(exports, '__esModule', { value: true });
})));
+6
View File
@@ -0,0 +1,6 @@
/**
* vue-class-component v7.2.3
* (c) 2015-present Evan You
* @license MIT
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e=e||self).VueClassComponent={},e.Vue)}(this,function(e,t){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e,t,r){(r?Reflect.getOwnMetadataKeys(t,r):Reflect.getOwnMetadataKeys(t)).forEach(function(n){var o=r?Reflect.getOwnMetadata(n,t,r):Reflect.getOwnMetadata(n,t);r?Reflect.defineMetadata(n,o,e,r):Reflect.defineMetadata(n,o,e)})}t=t&&t.hasOwnProperty("default")?t.default:t;var a={__proto__:[]}instanceof Array;var i=["data","beforeCreate","created","beforeMount","mounted","beforeDestroy","destroyed","beforeUpdate","updated","activated","deactivated","render","errorCaptured","serverPrefetch"];function c(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n.name=n.name||e._componentTag||e.name;var c=e.prototype;Object.getOwnPropertyNames(c).forEach(function(e){if("constructor"!==e)if(i.indexOf(e)>-1)n[e]=c[e];else{var t=Object.getOwnPropertyDescriptor(c,e);void 0!==t.value?"function"==typeof t.value?(n.methods||(n.methods={}))[e]=t.value:(n.mixins||(n.mixins=[])).push({data:function(){return function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}({},e,t.value)}}):(t.get||t.set)&&((n.computed||(n.computed={}))[e]={get:t.get,set:t.set})}}),(n.mixins||(n.mixins=[])).push({data:function(){return function(e,t){var r=t.prototype._init;t.prototype._init=function(){var t=this,r=Object.getOwnPropertyNames(e);if(e.$options.props)for(var n in e.$options.props)e.hasOwnProperty(n)||r.push(n);r.forEach(function(r){"_"!==r.charAt(0)&&Object.defineProperty(t,r,{get:function(){return e[r]},set:function(t){e[r]=t},configurable:!0})})};var n=new t;t.prototype._init=r;var o={};return Object.keys(n).forEach(function(e){void 0!==n[e]&&(o[e]=n[e])}),o}(this,e)}});var u=e.__decorators__;u&&(u.forEach(function(e){return e(n)}),delete e.__decorators__);var p,s,d=Object.getPrototypeOf(e.prototype),y=d instanceof t?d.constructor:t,l=y.extend(n);return function(e,t,n){Object.getOwnPropertyNames(t).forEach(function(o){if(!f[o]){var i=Object.getOwnPropertyDescriptor(e,o);if(!i||i.configurable){var c,u,p=Object.getOwnPropertyDescriptor(t,o);if(!a){if("cid"===o)return;var s=Object.getOwnPropertyDescriptor(n,o);if(c=p.value,u=r(c),null!=c&&("object"===u||"function"===u)&&s&&s.value===p.value)return}Object.defineProperty(e,o,p)}}})}(l,e,y),"undefined"!=typeof Reflect&&Reflect.defineMetadata&&Reflect.getOwnMetadataKeys&&(o(p=l,s=e),Object.getOwnPropertyNames(s.prototype).forEach(function(e){o(p.prototype,s.prototype,e)}),Object.getOwnPropertyNames(s).forEach(function(e){o(p,s,e)})),l}var f={prototype:!0,arguments:!0,callee:!0,caller:!0};function u(e){return"function"==typeof e?c(e):function(t){return c(t,e)}}u.registerHooks=function(e){i.push.apply(i,n(e))},e.createDecorator=function(e){return function(t,r,n){var o="function"==typeof t?t:t.constructor;o.__decorators__||(o.__decorators__=[]),"number"!=typeof n&&(n=void 0),o.__decorators__.push(function(t){return e(t,r,n)})}},e.default=u,e.mixins=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return t.extend({mixins:r})},Object.defineProperty(e,"__esModule",{value:!0})});
+20
View File
@@ -0,0 +1,20 @@
import { VNode } from 'vue'
declare module 'vue/types/vue' {
interface Vue {
data?(): object
beforeCreate?(): void
created?(): void
beforeMount?(): void
mounted?(): void
beforeDestroy?(): void
destroyed?(): void
beforeUpdate?(): void
updated?(): void
activated?(): void
deactivated?(): void
render?(createElement: CreateElement): VNode
errorCaptured?(err: Error, vm: Vue, info: string): boolean | undefined
serverPrefetch?(): Promise<unknown>
}
}
+1
View File
@@ -0,0 +1 @@
// Dummy empty file to avoid import error when using hooks.d.ts
+4
View File
@@ -0,0 +1,4 @@
import Vue, { ComponentOptions } from 'vue';
import { VueClass } from './declarations';
export declare const $internalHooks: string[];
export declare function componentFactory(Component: VueClass<Vue>, options?: ComponentOptions<Vue>): VueClass<Vue>;
+144
View File
@@ -0,0 +1,144 @@
import Vue from 'vue';
import { copyReflectionMetadata, reflectionIsSupported } from './reflect';
import { collectDataFromConstructor } from './data';
import { hasProto, isPrimitive, warn } from './util';
export const $internalHooks = [
'data',
'beforeCreate',
'created',
'beforeMount',
'mounted',
'beforeDestroy',
'destroyed',
'beforeUpdate',
'updated',
'activated',
'deactivated',
'render',
'errorCaptured',
'serverPrefetch' // 2.6
];
export function componentFactory(Component, options = {}) {
options.name = options.name || Component._componentTag || Component.name;
// prototype props.
const proto = Component.prototype;
Object.getOwnPropertyNames(proto).forEach(function (key) {
if (key === 'constructor') {
return;
}
// hooks
if ($internalHooks.indexOf(key) > -1) {
options[key] = proto[key];
return;
}
const descriptor = Object.getOwnPropertyDescriptor(proto, key);
if (descriptor.value !== void 0) {
// methods
if (typeof descriptor.value === 'function') {
(options.methods || (options.methods = {}))[key] = descriptor.value;
}
else {
// typescript decorated data
(options.mixins || (options.mixins = [])).push({
data() {
return { [key]: descriptor.value };
}
});
}
}
else if (descriptor.get || descriptor.set) {
// computed properties
(options.computed || (options.computed = {}))[key] = {
get: descriptor.get,
set: descriptor.set
};
}
});
(options.mixins || (options.mixins = [])).push({
data() {
return collectDataFromConstructor(this, Component);
}
});
// decorate options
const decorators = Component.__decorators__;
if (decorators) {
decorators.forEach(fn => fn(options));
delete Component.__decorators__;
}
// find super
const superProto = Object.getPrototypeOf(Component.prototype);
const Super = superProto instanceof Vue
? superProto.constructor
: Vue;
const Extended = Super.extend(options);
forwardStaticMembers(Extended, Component, Super);
if (reflectionIsSupported()) {
copyReflectionMetadata(Extended, Component);
}
return Extended;
}
const reservedPropertyNames = [
// Unique id
'cid',
// Super Vue constructor
'super',
// Component options that will be used by the component
'options',
'superOptions',
'extendOptions',
'sealedOptions',
// Private assets
'component',
'directive',
'filter'
];
const shouldIgnore = {
prototype: true,
arguments: true,
callee: true,
caller: true
};
function forwardStaticMembers(Extended, Original, Super) {
// We have to use getOwnPropertyNames since Babel registers methods as non-enumerable
Object.getOwnPropertyNames(Original).forEach(key => {
// Skip the properties that should not be overwritten
if (shouldIgnore[key]) {
return;
}
// Some browsers does not allow reconfigure built-in properties
const extendedDescriptor = Object.getOwnPropertyDescriptor(Extended, key);
if (extendedDescriptor && !extendedDescriptor.configurable) {
return;
}
const descriptor = Object.getOwnPropertyDescriptor(Original, key);
// If the user agent does not support `__proto__` or its family (IE <= 10),
// the sub class properties may be inherited properties from the super class in TypeScript.
// We need to exclude such properties to prevent to overwrite
// the component options object which stored on the extended constructor (See #192).
// If the value is a referenced value (object or function),
// we can check equality of them and exclude it if they have the same reference.
// If it is a primitive value, it will be forwarded for safety.
if (!hasProto) {
// Only `cid` is explicitly exluded from property forwarding
// because we cannot detect whether it is a inherited property or not
// on the no `__proto__` environment even though the property is reserved.
if (key === 'cid') {
return;
}
const superDescriptor = Object.getOwnPropertyDescriptor(Super, key);
if (!isPrimitive(descriptor.value) &&
superDescriptor &&
superDescriptor.value === descriptor.value) {
return;
}
}
// Warn if the users manually declare reserved properties
if (process.env.NODE_ENV !== 'production' &&
reservedPropertyNames.indexOf(key) >= 0) {
warn(`Static property name '${key}' declared on class '${Original.name}' ` +
'conflicts with reserved property name of Vue internal. ' +
'It may cause unexpected behavior of the component. Consider renaming the property.');
}
Object.defineProperty(Extended, key, descriptor);
});
}
+3
View File
@@ -0,0 +1,3 @@
import Vue from 'vue';
import { VueClass } from './declarations';
export declare function collectDataFromConstructor(vm: Vue, Component: VueClass<Vue>): {};
+45
View File
@@ -0,0 +1,45 @@
import Vue from 'vue';
import { warn } from './util';
export function collectDataFromConstructor(vm, Component) {
// override _init to prevent to init as Vue instance
const originalInit = Component.prototype._init;
Component.prototype._init = function () {
// proxy to actual vm
const keys = Object.getOwnPropertyNames(vm);
// 2.2.0 compat (props are no longer exposed as self properties)
if (vm.$options.props) {
for (const key in vm.$options.props) {
if (!vm.hasOwnProperty(key)) {
keys.push(key);
}
}
}
keys.forEach(key => {
if (key.charAt(0) !== '_') {
Object.defineProperty(this, key, {
get: () => vm[key],
set: value => { vm[key] = value; },
configurable: true
});
}
});
};
// should be acquired class property values
const data = new Component();
// restore original _init to avoid memory leak (#209)
Component.prototype._init = originalInit;
// create plain data object
const plainData = {};
Object.keys(data).forEach(key => {
if (data[key] !== undefined) {
plainData[key] = data[key];
}
});
if (process.env.NODE_ENV !== 'production') {
if (!(Component.prototype instanceof Vue) && Object.keys(plainData).length > 0) {
warn('Component class must inherit Vue or its descendant class ' +
'when class property is used.');
}
}
return plainData;
}
+7
View File
@@ -0,0 +1,7 @@
import Vue, { ComponentOptions } from 'vue';
export declare type VueClass<V> = {
new (...args: any[]): V & Vue;
} & typeof Vue;
export declare type DecoratedClass = VueClass<Vue> & {
__decorators__?: ((options: ComponentOptions<Vue>) => void)[];
};
View File
+12
View File
@@ -0,0 +1,12 @@
import Vue, { ComponentOptions } from 'vue';
import { VueClass } from './declarations';
export { createDecorator, VueDecorator, mixins } from './util';
declare function Component<V extends Vue>(options: ComponentOptions<V> & ThisType<V>): <VC extends VueClass<V>>(target: VC) => VC;
declare namespace Component {
var registerHooks: (keys: string[]) => void;
}
declare function Component<VC extends VueClass<Vue>>(target: VC): VC;
declare namespace Component {
var registerHooks: (keys: string[]) => void;
}
export default Component;
+14
View File
@@ -0,0 +1,14 @@
import { componentFactory, $internalHooks } from './component';
export { createDecorator, mixins } from './util';
function Component(options) {
if (typeof options === 'function') {
return componentFactory(options);
}
return function (Component) {
return componentFactory(Component, options);
};
}
Component.registerHooks = function registerHooks(keys) {
$internalHooks.push(...keys);
};
export default Component;
+4
View File
@@ -0,0 +1,4 @@
import Vue, { VueConstructor } from 'vue';
import { VueClass } from './declarations';
export declare function reflectionIsSupported(): false | typeof Reflect.getOwnMetadataKeys;
export declare function copyReflectionMetadata(to: VueConstructor, from: VueClass<Vue>): void;
+31
View File
@@ -0,0 +1,31 @@
// The rational behind the verbose Reflect-feature check below is the fact that there are polyfills
// which add an implementation for Reflect.defineMetadata but not for Reflect.getOwnMetadataKeys.
// Without this check consumers will encounter hard to track down runtime errors.
export function reflectionIsSupported() {
return typeof Reflect !== 'undefined' && Reflect.defineMetadata && Reflect.getOwnMetadataKeys;
}
export function copyReflectionMetadata(to, from) {
forwardMetadata(to, from);
Object.getOwnPropertyNames(from.prototype).forEach(key => {
forwardMetadata(to.prototype, from.prototype, key);
});
Object.getOwnPropertyNames(from).forEach(key => {
forwardMetadata(to, from, key);
});
}
function forwardMetadata(to, from, propertyKey) {
const metaKeys = propertyKey
? Reflect.getOwnMetadataKeys(from, propertyKey)
: Reflect.getOwnMetadataKeys(from);
metaKeys.forEach(metaKey => {
const metadata = propertyKey
? Reflect.getOwnMetadata(metaKey, from, propertyKey)
: Reflect.getOwnMetadata(metaKey, from);
if (propertyKey) {
Reflect.defineMetadata(metaKey, metadata, to, propertyKey);
}
else {
Reflect.defineMetadata(metaKey, metadata, to);
}
});
}
+18
View File
@@ -0,0 +1,18 @@
import Vue, { ComponentOptions } from 'vue';
import { VueClass } from './declarations';
export declare const noop: () => void;
export declare const hasProto: boolean;
export interface VueDecorator {
(Ctor: typeof Vue): void;
(target: Vue, key: string): void;
(target: Vue, key: string, index: number): void;
}
export declare function createDecorator(factory: (options: ComponentOptions<Vue>, key: string, index: number) => void): VueDecorator;
export declare function mixins<A>(CtorA: VueClass<A>): VueClass<A>;
export declare function mixins<A, B>(CtorA: VueClass<A>, CtorB: VueClass<B>): VueClass<A & B>;
export declare function mixins<A, B, C>(CtorA: VueClass<A>, CtorB: VueClass<B>, CtorC: VueClass<C>): VueClass<A & B & C>;
export declare function mixins<A, B, C, D>(CtorA: VueClass<A>, CtorB: VueClass<B>, CtorC: VueClass<C>, CtorD: VueClass<D>): VueClass<A & B & C & D>;
export declare function mixins<A, B, C, D, E>(CtorA: VueClass<A>, CtorB: VueClass<B>, CtorC: VueClass<C>, CtorD: VueClass<D>, CtorE: VueClass<E>): VueClass<A & B & C & D & E>;
export declare function mixins<T>(...Ctors: VueClass<Vue>[]): VueClass<T>;
export declare function isPrimitive(value: any): boolean;
export declare function warn(message: string): void;
+30
View File
@@ -0,0 +1,30 @@
import Vue from 'vue';
export const noop = () => { };
const fakeArray = { __proto__: [] };
export const hasProto = fakeArray instanceof Array;
export function createDecorator(factory) {
return (target, key, index) => {
const Ctor = typeof target === 'function'
? target
: target.constructor;
if (!Ctor.__decorators__) {
Ctor.__decorators__ = [];
}
if (typeof index !== 'number') {
index = undefined;
}
Ctor.__decorators__.push(options => factory(options, key, index));
};
}
export function mixins(...Ctors) {
return Vue.extend({ mixins: Ctors });
}
export function isPrimitive(value) {
const type = typeof value;
return value == null || (type !== 'object' && type !== 'function');
}
export function warn(message) {
if (typeof console !== 'undefined') {
console.warn('[vue-class-component] ' + message);
}
}
+114
View File
@@ -0,0 +1,114 @@
{
"_args": [
[
"vue-class-component@7.2.3",
"/home/node/nuxt"
]
],
"_from": "vue-class-component@7.2.3",
"_id": "vue-class-component@7.2.3",
"_inBundle": false,
"_integrity": "sha512-oEqYpXKaFN+TaXU+mRLEx8dX0ah85aAJEe61mpdoUrq0Bhe/6sWhyZX1JjMQLhVsHAkncyhedhmCdDVSasUtDw==",
"_location": "/vue-class-component",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "vue-class-component@7.2.3",
"name": "vue-class-component",
"escapedName": "vue-class-component",
"rawSpec": "7.2.3",
"saveSpec": null,
"fetchSpec": "7.2.3"
},
"_requiredBy": [
"/nuxt-property-decorator",
"/vue-property-decorator"
],
"_resolved": "https://registry.npmjs.org/vue-class-component/-/vue-class-component-7.2.3.tgz",
"_spec": "7.2.3",
"_where": "/home/node/nuxt",
"author": {
"name": "Evan You"
},
"bugs": {
"url": "https://github.com/vuejs/vue-class-component/issues"
},
"description": "ES201X/TypeScript class decorator for Vue components",
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-decorators": "^7.7.4",
"@babel/plugin-syntax-jsx": "^7.7.4",
"@babel/preset-env": "^7.7.7",
"@types/chai": "^4.2.7",
"@types/mocha": "^5.2.7",
"@types/node": "^13.1.6",
"@typescript-eslint/parser": "^2.15.0",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^8.0.6",
"babel-plugin-transform-vue-jsx": "^4.0.1",
"chai": "^4.2.0",
"css-loader": "^3.4.2",
"eslint": "^6.8.0",
"eslint-plugin-vue-libs": "^4.0.0",
"mocha": "^7.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.0",
"rollup": "^1.29.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-replace": "^2.2.0",
"testdouble": "^3.12.5",
"ts-loader": "^6.2.1",
"typescript": "^3.7.4",
"uglify-es": "^3.3.9",
"vue": "^2.6.11",
"vue-loader": "^15.8.3",
"vue-template-compiler": "^2.6.11",
"vuepress": "^1.2.0",
"vuex": "^3.1.2",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
},
"files": [
"dist",
"lib",
"hooks.js",
"hooks.d.ts"
],
"homepage": "https://github.com/vuejs/vue-class-component#readme",
"keywords": [
"vue",
"class",
"babel",
"typescript"
],
"license": "MIT",
"main": "dist/vue-class-component.common.js",
"module": "dist/vue-class-component.esm.js",
"name": "vue-class-component",
"peerDependencies": {
"vue": "^2.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/vue-class-component.git"
},
"scripts": {
"build": "npm run build:ts && npm run build:main",
"build:main": "node build/build.js",
"build:ts": "tsc -p .",
"clean": "rimraf ./lib",
"dev": "webpack --config example/webpack.config.js --watch",
"dev:test": "node build/dev-test.js",
"docs:build": "vuepress build docs",
"docs:dev": "vuepress dev docs",
"example": "npm run build && webpack --config example/webpack.config.js",
"lint": "eslint --ext js,jsx,ts,tsx,vue .",
"release": "bash build/release.sh",
"test": "npm run build && webpack --config test/webpack.config.js && mocha test/test.build.js"
},
"typings": "lib/index.d.ts",
"unpkg": "dist/vue-class-component.js",
"version": "7.2.3"
}