vue-class-component
Advanced tools
Comparing version 8.0.0-beta.3 to 8.0.0-beta.4
@@ -0,1 +1,22 @@ | ||
# [8.0.0-beta.4](https://github.com/vuejs/vue-class-component/compare/v8.0.0-beta.3...v8.0.0-beta.4) (2020-10-04) | ||
### Breaking Changes | ||
* Reverted `props` and `emits` helper proposed at [#447](https://github.com/vuejs/vue-class-component/issues/447) | ||
### Bug Fixes | ||
* **types:** include undefined type for optional prop definition ([19880a7](https://github.com/vuejs/vue-class-component/commit/19880a72a27d260af1ec14f628f440ff2a2ccd80)) | ||
* make decorator accepts any vue constructor types (fix [#457](https://github.com/vuejs/vue-class-component/issues/457)) ([c3ccae0](https://github.com/vuejs/vue-class-component/commit/c3ccae03d795380c615e90fe066c4e1ffb272e15)) | ||
### Features | ||
* allow to define `props` by class ([fd96c63](https://github.com/vuejs/vue-class-component/commit/fd96c6323377b287519005594865ed1264602642)) | ||
* You can see the detailed proposal at [#465](https://github.com/vuejs/vue-class-component/issues/465) | ||
* support async setup (fix [#463](https://github.com/vuejs/vue-class-component/issues/463)) ([90336e9](https://github.com/vuejs/vue-class-component/commit/90336e99d4dcaf69f4e8e2743f962f069002f304)) | ||
# [8.0.0-beta.3](https://github.com/vuejs/vue-class-component/compare/v8.0.0-beta.2...v8.0.0-beta.3) (2020-09-17) | ||
@@ -2,0 +23,0 @@ |
/** | ||
* vue-class-component v8.0.0-beta.3 | ||
* vue-class-component v8.0.0-beta.4 | ||
* (c) 2015-present Evan You | ||
@@ -289,2 +289,35 @@ * @license MIT | ||
}, { | ||
key: "props", | ||
value: function props(Props) { | ||
var propsMeta = new Props(); | ||
var props = {}; | ||
Object.keys(propsMeta).forEach(function (key) { | ||
var meta = propsMeta[key]; | ||
props[key] = meta !== null && meta !== void 0 ? meta : null; | ||
}); | ||
var PropsMixin = /*#__PURE__*/function (_this2) { | ||
_inherits(PropsMixin, _this2); | ||
var _super = _createSuper(PropsMixin); | ||
function PropsMixin() { | ||
_classCallCheck(this, PropsMixin); | ||
return _super.apply(this, arguments); | ||
} | ||
_createClass(PropsMixin, null, [{ | ||
key: "__vccExtend", | ||
value: function __vccExtend(options) { | ||
options.props = props; | ||
} | ||
}]); | ||
return PropsMixin; | ||
}(this); | ||
return PropsMixin; | ||
} | ||
}, { | ||
key: "__vccOpts", | ||
@@ -345,5 +378,8 @@ get: function get() { | ||
options.setup = function (props, ctx) { | ||
var _promise; | ||
var data = new Ctor(props, ctx); | ||
var dataKeys = Object.keys(data); | ||
var plainData = {}; // Initialize reactive data and convert constructor `this` to a proxy | ||
var plainData = {}; | ||
var promise = null; // Initialize reactive data and convert constructor `this` to a proxy | ||
@@ -365,6 +401,19 @@ dataKeys.forEach(function (key) { | ||
plainData[key] = vue.proxyRefs(setupState); | ||
if (setupState instanceof Promise) { | ||
if (!promise) { | ||
promise = Promise.resolve(plainData); | ||
} | ||
promise = promise.then(function () { | ||
return setupState.then(function (value) { | ||
plainData[key] = vue.proxyRefs(value); | ||
return plainData; | ||
}); | ||
}); | ||
} else { | ||
plainData[key] = vue.proxyRefs(setupState); | ||
} | ||
} | ||
}); | ||
return plainData; | ||
return (_promise = promise) !== null && _promise !== void 0 ? _promise : plainData; | ||
}; | ||
@@ -464,50 +513,2 @@ | ||
} | ||
function props(propsOptions) { | ||
var PropsMixin = /*#__PURE__*/function (_Vue2) { | ||
_inherits(PropsMixin, _Vue2); | ||
var _super2 = _createSuper(PropsMixin); | ||
function PropsMixin() { | ||
_classCallCheck(this, PropsMixin); | ||
return _super2.apply(this, arguments); | ||
} | ||
_createClass(PropsMixin, null, [{ | ||
key: "__vccExtend", | ||
value: function __vccExtend(options) { | ||
options.props = propsOptions; | ||
} | ||
}]); | ||
return PropsMixin; | ||
}(Vue); | ||
return PropsMixin; | ||
} | ||
function emits(emitsOptions) { | ||
var EmitsMixin = /*#__PURE__*/function (_Vue3) { | ||
_inherits(EmitsMixin, _Vue3); | ||
var _super3 = _createSuper(EmitsMixin); | ||
function EmitsMixin() { | ||
_classCallCheck(this, EmitsMixin); | ||
return _super3.apply(this, arguments); | ||
} | ||
_createClass(EmitsMixin, null, [{ | ||
key: "__vccExtend", | ||
value: function __vccExtend(options) { | ||
options.emits = emitsOptions; | ||
} | ||
}]); | ||
return EmitsMixin; | ||
}(Vue); | ||
return EmitsMixin; | ||
} | ||
function setup(setupFn) { | ||
@@ -521,8 +522,12 @@ // Hack to delay the invocation of setup function. | ||
// Actual implementation | ||
function prop(options) { | ||
return options; | ||
} | ||
exports.Options = Options; | ||
exports.Vue = Vue; | ||
exports.createDecorator = createDecorator; | ||
exports.emits = emits; | ||
exports.mixins = mixins; | ||
exports.props = props; | ||
exports.prop = prop; | ||
exports.setup = setup; |
import { AllowedComponentProps } from 'vue'; | ||
import { ComponentCustomProps } from 'vue'; | ||
import { ComponentObjectPropsOptions } from 'vue'; | ||
import { ComponentOptions } from 'vue'; | ||
import { ComponentPublicInstance } from 'vue'; | ||
import { ExtractDefaultPropTypes } from 'vue'; | ||
import { ExtractPropTypes } from 'vue'; | ||
import { EmitsOptions } from 'vue'; | ||
import { Prop } from 'vue'; | ||
import { PropType } from 'vue'; | ||
import { Ref } from 'vue'; | ||
@@ -32,34 +32,53 @@ import { ShallowUnwrapRef } from 'vue'; | ||
export declare function emits<EmitNames extends string>(emitNames: EmitNames[]): VueConstructor<Vue<unknown, EmitNames[]>>; | ||
export declare type DefaultFactory<T> = (props: Record<string, unknown>) => T | null | undefined; | ||
export declare function emits<EmitsOptions extends ObjectEmitsOptions>(emitsOptions: EmitsOptions): VueConstructor<Vue<unknown, EmitsOptions>>; | ||
export declare type DefaultKeys<P> = { | ||
[K in keyof P]: P[K] extends WithDefault<any> ? K : never; | ||
}[keyof P]; | ||
export declare type EmitsOptions = ObjectEmitsOptions | string[]; | ||
export declare type ExtractDefaultProps<P> = { | ||
[K in DefaultKeys<P>]: P[K] extends WithDefault<infer T> ? T : never; | ||
}; | ||
export declare type ExtractInstance<T> = T extends VueMixin<infer V> ? V : never; | ||
export declare type MixedVueBase<Mixins extends VueMixin[]> = Mixins extends (infer T)[] ? VueConstructor<NarrowEmit<UnionToIntersection<ExtractInstance<T>> & Vue> & VueBase> : never; | ||
export declare type ExtractProps<P> = { | ||
[K in keyof P]: P[K] extends WithDefault<infer T> ? T : P[K]; | ||
}; | ||
export declare type MixedVueBase<Mixins extends VueMixin[]> = Mixins extends (infer T)[] ? VueConstructor<UnionToIntersection<ExtractInstance<T>> & Vue> : never; | ||
export declare function mixins<T extends VueMixin[]>(...Ctors: T): MixedVueBase<T>; | ||
export declare type NarrowEmit<T extends VueBase> = Omit<T, '$emit' | keyof ClassComponentHooks> & ClassComponentHooks & { | ||
$emit: T['$emit'] extends ((event: string, ...args: any[]) => void) & infer R ? unknown extends R ? T['$emit'] : R : T['$emit']; | ||
}; | ||
export declare function Options<V extends Vue>(options: ComponentOptions & ThisType<V>): <VC extends VueConstructor<VueBase>>(target: VC) => VC; | ||
export declare type ObjectEmitsOptions = Record<string, ((...args: any[]) => any) | null>; | ||
export declare function prop<T>(options: PropOptionsWithDefault<T>): WithDefault<T>; | ||
export declare function Options<V extends Vue>(options: ComponentOptions & ThisType<V>): <VC extends VueConstructor>(target: VC) => VC; | ||
export declare function prop<T>(options: PropOptionsWithRequired<T>): T; | ||
export declare function props<PropNames extends string, Props = Readonly<{ | ||
[key in PropNames]?: any; | ||
}>>(propNames: PropNames[]): VueConstructor<Vue<Props> & Props>; | ||
export declare function prop<T>(options: Prop<T>): T | undefined; | ||
export declare function props<PropsOptions extends ComponentObjectPropsOptions, Props = Readonly<ExtractPropTypes<PropsOptions>>, DefaultProps = ExtractDefaultPropTypes<PropsOptions>>(propsOptions: PropsOptions): VueConstructor<Vue<Props, {}, DefaultProps> & Props>; | ||
export declare interface PropOptions<T = any, D = T> { | ||
type?: PropType<T> | true | null; | ||
required?: boolean; | ||
default?: D | DefaultFactory<D> | null | undefined | object; | ||
validator?(value: unknown): boolean; | ||
} | ||
export declare interface PropOptionsWithDefault<T, D = T> extends PropOptions<T, D> { | ||
default: PropOptions<T, D>['default']; | ||
} | ||
export declare interface PropOptionsWithRequired<T, D = T> extends PropOptions<T, D> { | ||
required: true; | ||
} | ||
export declare type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps; | ||
export declare function setup<R>(setupFn: () => R): UnwrapSetupValue<R>; | ||
export declare function setup<R>(setupFn: () => R): UnwrapSetupValue<UnwrapPromise<R>>; | ||
export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
export declare type UnwrapPromise<T> = T extends Promise<infer R> ? R : T; | ||
export declare type UnwrapSetupValue<T> = T extends Ref<infer R> ? R : ShallowUnwrapRef<T>; | ||
@@ -75,8 +94,12 @@ | ||
new (...args: any[]): V; | ||
registerHooks(keys: string[]): void; | ||
props<P extends { | ||
new (): unknown; | ||
}>(Props: P): VueConstructor<V & VueWithProps<InstanceType<P>>>; | ||
} | ||
export declare interface VueDecorator { | ||
(Ctor: VueConstructor): void; | ||
(target: Vue, key: string): void; | ||
(target: Vue, key: string, index: number): void; | ||
(Ctor: VueConstructor<VueBase>): void; | ||
(target: VueBase, key: string): void; | ||
(target: VueBase, key: string, index: number): void; | ||
} | ||
@@ -101,5 +124,12 @@ | ||
/* Excluded from this release type: __hmrId */ | ||
registerHooks(keys: string[]): void; | ||
} | ||
export declare type VueWithProps<P> = Vue<ExtractProps<P>, {}, ExtractDefaultProps<P>> & ExtractProps<P>; | ||
export declare interface WithDefault<T> { | ||
[withDefaultSymbol]: T; | ||
} | ||
declare const withDefaultSymbol: unique symbol; | ||
export { } |
/** | ||
* vue-class-component v8.0.0-beta.3 | ||
* vue-class-component v8.0.0-beta.4 | ||
* (c) 2015-present Evan You | ||
@@ -165,5 +165,8 @@ * @license MIT | ||
options.setup = function (props, ctx) { | ||
var _promise; | ||
var data = new Ctor(props, ctx); | ||
var dataKeys = Object.keys(data); | ||
var plainData = {}; // Initialize reactive data and convert constructor `this` to a proxy | ||
var plainData = {}; | ||
var promise = null; // Initialize reactive data and convert constructor `this` to a proxy | ||
@@ -185,6 +188,19 @@ dataKeys.forEach(key => { | ||
plainData[key] = proxyRefs(setupState); | ||
if (setupState instanceof Promise) { | ||
if (!promise) { | ||
promise = Promise.resolve(plainData); | ||
} | ||
promise = promise.then(() => { | ||
return setupState.then(value => { | ||
plainData[key] = proxyRefs(value); | ||
return plainData; | ||
}); | ||
}); | ||
} else { | ||
plainData[key] = proxyRefs(setupState); | ||
} | ||
} | ||
}); | ||
return plainData; | ||
return (_promise = promise) !== null && _promise !== void 0 ? _promise : plainData; | ||
}; | ||
@@ -212,2 +228,20 @@ | ||
static props(Props) { | ||
var propsMeta = new Props(); | ||
var props = {}; | ||
Object.keys(propsMeta).forEach(key => { | ||
var meta = propsMeta[key]; | ||
props[key] = meta !== null && meta !== void 0 ? meta : null; | ||
}); | ||
class PropsMixin extends this { | ||
static __vccExtend(options) { | ||
options.props = props; | ||
} | ||
} | ||
return PropsMixin; | ||
} | ||
} | ||
@@ -267,22 +301,2 @@ /** @internal */ | ||
} | ||
function props(propsOptions) { | ||
class PropsMixin extends Vue { | ||
static __vccExtend(options) { | ||
options.props = propsOptions; | ||
} | ||
} | ||
return PropsMixin; | ||
} | ||
function emits(emitsOptions) { | ||
class EmitsMixin extends Vue { | ||
static __vccExtend(options) { | ||
options.emits = emitsOptions; | ||
} | ||
} | ||
return EmitsMixin; | ||
} | ||
function setup(setupFn) { | ||
@@ -296,2 +310,7 @@ // Hack to delay the invocation of setup function. | ||
export { Options, Vue, createDecorator, emits, mixins, props, setup }; | ||
// Actual implementation | ||
function prop(options) { | ||
return options; | ||
} | ||
export { Options, Vue, createDecorator, mixins, prop, setup }; |
/** | ||
* vue-class-component v8.0.0-beta.3 | ||
* vue-class-component v8.0.0-beta.4 | ||
* (c) 2015-present Evan You | ||
* @license MIT | ||
*/ | ||
import{ref,proxyRefs}from"vue";function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);t&&(c=c.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,c)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function defineGetter(e,t,r){Object.defineProperty(e,t,{get:r,enumerable:!1,configurable:!0})}function defineProxy(e,t,r){Object.defineProperty(e,t,{get:()=>r[t].value,set:e=>{r[t].value=e},enumerable:!0,configurable:!0})}function getSuper(e){var t=Object.getPrototypeOf(e.prototype);if(t)return t.constructor}class VueImpl{constructor(e,t){defineGetter(this,"$props",()=>e),defineGetter(this,"$attrs",()=>t.attrs),defineGetter(this,"$slots",()=>t.slots),defineGetter(this,"$emit",()=>t.emit),Object.keys(e).forEach(t=>{Object.defineProperty(this,t,{enumerable:!1,configurable:!0,writable:!0,value:e[t]})})}static __vccExtend(e){e.mixins=e.mixins||[],e.mixins.push(this.__vccOpts)}static get __vccOpts(){if(this===Vue)return{};var e=this.hasOwnProperty("__vccCache")&&this.__vccCache;if(e)return e;var t=this,r=this.__vccCache=this.hasOwnProperty("__vccBase")?_objectSpread2({},this.__vccBase):{},c=getSuper(t);c&&c.__vccExtend(r),r.methods=_objectSpread2({},r.methods),r.computed=_objectSpread2({},r.computed);var o=t.prototype;Object.getOwnPropertyNames(o).forEach(e=>{if("constructor"!==e)if(t.__vccHooks.indexOf(e)>-1)r[e]=o[e];else{var c=Object.getOwnPropertyDescriptor(o,e);"function"!=typeof c.value?(c.get||c.set)&&(r.computed[e]={get:c.get,set:c.set}):r.methods[e]=c.value}}),r.setup=function(e,r){var c=new t(e,r),o=Object.keys(c),n={};return o.forEach(e=>{void 0===c[e]||c[e]&&c[e].__s||(n[e]=ref(c[e]),defineProxy(c,e,n))}),o.forEach(e=>{if(c[e]&&c[e].__s){var t=c[e].__s();n[e]=proxyRefs(t)}}),n};var n=this.hasOwnProperty("__vccDecorators")&&this.__vccDecorators;n&&n.forEach(e=>e(r));return["render","ssrRender","__file","__cssModules","__scopeId","__hmrId"].forEach(e=>{t[e]&&(r[e]=t[e])}),r}static registerHooks(e){this.__vccHooks.push(...e)}}VueImpl.__vccHooks=["data","beforeCreate","created","beforeMount","mounted","beforeUnmount","unmounted","beforeUpdate","updated","activated","deactivated","render","errorCaptured","serverPrefetch"];var Vue;function Options(e){return t=>(t.__vccBase=e,t)}function createDecorator(e){return(t,r,c)=>{var o="function"==typeof t?t:t.constructor;o.__vccDecorators||(o.__vccDecorators=[]),"number"!=typeof c&&(c=void 0),o.__vccDecorators.push(t=>e(t,r,c))}}function mixins(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return class extends Vue{static __vccExtend(e){t.forEach(t=>t.__vccExtend(e))}constructor(){for(var e=arguments.length,r=new Array(e),c=0;c<e;c++)r[c]=arguments[c];super(...r),t.forEach(e=>{var t=new e(...r);Object.keys(t).forEach(e=>{this[e]=t[e]})})}}}function props(e){return class extends Vue{static __vccExtend(t){t.props=e}}}function emits(e){return class extends Vue{static __vccExtend(t){t.emits=e}}}function setup(e){return{__s:e}}export{Options,VueImpl as Vue,createDecorator,emits,mixins,props,setup}; | ||
import{ref,proxyRefs}from"vue";function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function defineGetter(e,t,r){Object.defineProperty(e,t,{get:r,enumerable:!1,configurable:!0})}function defineProxy(e,t,r){Object.defineProperty(e,t,{get:()=>r[t].value,set:e=>{r[t].value=e},enumerable:!0,configurable:!0})}function getSuper(e){var t=Object.getPrototypeOf(e.prototype);if(t)return t.constructor}class VueImpl{constructor(e,t){defineGetter(this,"$props",()=>e),defineGetter(this,"$attrs",()=>t.attrs),defineGetter(this,"$slots",()=>t.slots),defineGetter(this,"$emit",()=>t.emit),Object.keys(e).forEach(t=>{Object.defineProperty(this,t,{enumerable:!1,configurable:!0,writable:!0,value:e[t]})})}static __vccExtend(e){e.mixins=e.mixins||[],e.mixins.push(this.__vccOpts)}static get __vccOpts(){if(this===Vue)return{};var e=this.hasOwnProperty("__vccCache")&&this.__vccCache;if(e)return e;var t=this,r=this.__vccCache=this.hasOwnProperty("__vccBase")?_objectSpread2({},this.__vccBase):{},o=getSuper(t);o&&o.__vccExtend(r),r.methods=_objectSpread2({},r.methods),r.computed=_objectSpread2({},r.computed);var c=t.prototype;Object.getOwnPropertyNames(c).forEach(e=>{if("constructor"!==e)if(t.__vccHooks.indexOf(e)>-1)r[e]=c[e];else{var o=Object.getOwnPropertyDescriptor(c,e);"function"!=typeof o.value?(o.get||o.set)&&(r.computed[e]={get:o.get,set:o.set}):r.methods[e]=o.value}}),r.setup=function(e,r){var o,c=new t(e,r),n=Object.keys(c),s={},i=null;return n.forEach(e=>{void 0===c[e]||c[e]&&c[e].__s||(s[e]=ref(c[e]),defineProxy(c,e,s))}),n.forEach(e=>{if(c[e]&&c[e].__s){var t=c[e].__s();t instanceof Promise?(i||(i=Promise.resolve(s)),i=i.then(()=>t.then(t=>(s[e]=proxyRefs(t),s)))):s[e]=proxyRefs(t)}}),null!==(o=i)&&void 0!==o?o:s};var n=this.hasOwnProperty("__vccDecorators")&&this.__vccDecorators;n&&n.forEach(e=>e(r));return["render","ssrRender","__file","__cssModules","__scopeId","__hmrId"].forEach(e=>{t[e]&&(r[e]=t[e])}),r}static registerHooks(e){this.__vccHooks.push(...e)}static props(e){var t=new e,r={};Object.keys(t).forEach(e=>{var o=t[e];r[e]=null!==o&&void 0!==o?o:null});return class extends(this){static __vccExtend(e){e.props=r}}}}VueImpl.__vccHooks=["data","beforeCreate","created","beforeMount","mounted","beforeUnmount","unmounted","beforeUpdate","updated","activated","deactivated","render","errorCaptured","serverPrefetch"];var Vue;function Options(e){return t=>(t.__vccBase=e,t)}function createDecorator(e){return(t,r,o)=>{var c="function"==typeof t?t:t.constructor;c.__vccDecorators||(c.__vccDecorators=[]),"number"!=typeof o&&(o=void 0),c.__vccDecorators.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 class extends Vue{static __vccExtend(e){t.forEach(t=>t.__vccExtend(e))}constructor(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];super(...r),t.forEach(e=>{var t=new e(...r);Object.keys(t).forEach(e=>{this[e]=t[e]})})}}}function setup(e){return{__s:e}}function prop(e){return e}export{Options,VueImpl as Vue,createDecorator,mixins,prop,setup}; |
/** | ||
* vue-class-component v8.0.0-beta.3 | ||
* vue-class-component v8.0.0-beta.4 | ||
* (c) 2015-present Evan You | ||
@@ -285,2 +285,35 @@ * @license MIT | ||
}, { | ||
key: "props", | ||
value: function props(Props) { | ||
var propsMeta = new Props(); | ||
var props = {}; | ||
Object.keys(propsMeta).forEach(function (key) { | ||
var meta = propsMeta[key]; | ||
props[key] = meta !== null && meta !== void 0 ? meta : null; | ||
}); | ||
var PropsMixin = /*#__PURE__*/function (_this2) { | ||
_inherits(PropsMixin, _this2); | ||
var _super = _createSuper(PropsMixin); | ||
function PropsMixin() { | ||
_classCallCheck(this, PropsMixin); | ||
return _super.apply(this, arguments); | ||
} | ||
_createClass(PropsMixin, null, [{ | ||
key: "__vccExtend", | ||
value: function __vccExtend(options) { | ||
options.props = props; | ||
} | ||
}]); | ||
return PropsMixin; | ||
}(this); | ||
return PropsMixin; | ||
} | ||
}, { | ||
key: "__vccOpts", | ||
@@ -341,5 +374,8 @@ get: function get() { | ||
options.setup = function (props, ctx) { | ||
var _promise; | ||
var data = new Ctor(props, ctx); | ||
var dataKeys = Object.keys(data); | ||
var plainData = {}; // Initialize reactive data and convert constructor `this` to a proxy | ||
var plainData = {}; | ||
var promise = null; // Initialize reactive data and convert constructor `this` to a proxy | ||
@@ -361,6 +397,19 @@ dataKeys.forEach(function (key) { | ||
plainData[key] = proxyRefs(setupState); | ||
if (setupState instanceof Promise) { | ||
if (!promise) { | ||
promise = Promise.resolve(plainData); | ||
} | ||
promise = promise.then(function () { | ||
return setupState.then(function (value) { | ||
plainData[key] = proxyRefs(value); | ||
return plainData; | ||
}); | ||
}); | ||
} else { | ||
plainData[key] = proxyRefs(setupState); | ||
} | ||
} | ||
}); | ||
return plainData; | ||
return (_promise = promise) !== null && _promise !== void 0 ? _promise : plainData; | ||
}; | ||
@@ -460,50 +509,2 @@ | ||
} | ||
function props(propsOptions) { | ||
var PropsMixin = /*#__PURE__*/function (_Vue2) { | ||
_inherits(PropsMixin, _Vue2); | ||
var _super2 = _createSuper(PropsMixin); | ||
function PropsMixin() { | ||
_classCallCheck(this, PropsMixin); | ||
return _super2.apply(this, arguments); | ||
} | ||
_createClass(PropsMixin, null, [{ | ||
key: "__vccExtend", | ||
value: function __vccExtend(options) { | ||
options.props = propsOptions; | ||
} | ||
}]); | ||
return PropsMixin; | ||
}(Vue); | ||
return PropsMixin; | ||
} | ||
function emits(emitsOptions) { | ||
var EmitsMixin = /*#__PURE__*/function (_Vue3) { | ||
_inherits(EmitsMixin, _Vue3); | ||
var _super3 = _createSuper(EmitsMixin); | ||
function EmitsMixin() { | ||
_classCallCheck(this, EmitsMixin); | ||
return _super3.apply(this, arguments); | ||
} | ||
_createClass(EmitsMixin, null, [{ | ||
key: "__vccExtend", | ||
value: function __vccExtend(options) { | ||
options.emits = emitsOptions; | ||
} | ||
}]); | ||
return EmitsMixin; | ||
}(Vue); | ||
return EmitsMixin; | ||
} | ||
function setup(setupFn) { | ||
@@ -517,2 +518,7 @@ // Hack to delay the invocation of setup function. | ||
export { Options, Vue, createDecorator, emits, mixins, props, setup }; | ||
// Actual implementation | ||
function prop(options) { | ||
return options; | ||
} | ||
export { Options, Vue, createDecorator, mixins, prop, setup }; |
/** | ||
* vue-class-component v8.0.0-beta.3 | ||
* vue-class-component v8.0.0-beta.4 | ||
* (c) 2015-present Evan You | ||
@@ -286,2 +286,35 @@ * @license MIT | ||
}, { | ||
key: "props", | ||
value: function props(Props) { | ||
var propsMeta = new Props(); | ||
var props = {}; | ||
Object.keys(propsMeta).forEach(function (key) { | ||
var meta = propsMeta[key]; | ||
props[key] = meta !== null && meta !== void 0 ? meta : null; | ||
}); | ||
var PropsMixin = /*#__PURE__*/function (_this2) { | ||
_inherits(PropsMixin, _this2); | ||
var _super = _createSuper(PropsMixin); | ||
function PropsMixin() { | ||
_classCallCheck(this, PropsMixin); | ||
return _super.apply(this, arguments); | ||
} | ||
_createClass(PropsMixin, null, [{ | ||
key: "__vccExtend", | ||
value: function __vccExtend(options) { | ||
options.props = props; | ||
} | ||
}]); | ||
return PropsMixin; | ||
}(this); | ||
return PropsMixin; | ||
} | ||
}, { | ||
key: "__vccOpts", | ||
@@ -342,5 +375,8 @@ get: function get() { | ||
options.setup = function (props, ctx) { | ||
var _promise; | ||
var data = new Ctor(props, ctx); | ||
var dataKeys = Object.keys(data); | ||
var plainData = {}; // Initialize reactive data and convert constructor `this` to a proxy | ||
var plainData = {}; | ||
var promise = null; // Initialize reactive data and convert constructor `this` to a proxy | ||
@@ -362,6 +398,19 @@ dataKeys.forEach(function (key) { | ||
plainData[key] = vue.proxyRefs(setupState); | ||
if (setupState instanceof Promise) { | ||
if (!promise) { | ||
promise = Promise.resolve(plainData); | ||
} | ||
promise = promise.then(function () { | ||
return setupState.then(function (value) { | ||
plainData[key] = vue.proxyRefs(value); | ||
return plainData; | ||
}); | ||
}); | ||
} else { | ||
plainData[key] = vue.proxyRefs(setupState); | ||
} | ||
} | ||
}); | ||
return plainData; | ||
return (_promise = promise) !== null && _promise !== void 0 ? _promise : plainData; | ||
}; | ||
@@ -461,50 +510,2 @@ | ||
} | ||
function props(propsOptions) { | ||
var PropsMixin = /*#__PURE__*/function (_Vue2) { | ||
_inherits(PropsMixin, _Vue2); | ||
var _super2 = _createSuper(PropsMixin); | ||
function PropsMixin() { | ||
_classCallCheck(this, PropsMixin); | ||
return _super2.apply(this, arguments); | ||
} | ||
_createClass(PropsMixin, null, [{ | ||
key: "__vccExtend", | ||
value: function __vccExtend(options) { | ||
options.props = propsOptions; | ||
} | ||
}]); | ||
return PropsMixin; | ||
}(Vue); | ||
return PropsMixin; | ||
} | ||
function emits(emitsOptions) { | ||
var EmitsMixin = /*#__PURE__*/function (_Vue3) { | ||
_inherits(EmitsMixin, _Vue3); | ||
var _super3 = _createSuper(EmitsMixin); | ||
function EmitsMixin() { | ||
_classCallCheck(this, EmitsMixin); | ||
return _super3.apply(this, arguments); | ||
} | ||
_createClass(EmitsMixin, null, [{ | ||
key: "__vccExtend", | ||
value: function __vccExtend(options) { | ||
options.emits = emitsOptions; | ||
} | ||
}]); | ||
return EmitsMixin; | ||
}(Vue); | ||
return EmitsMixin; | ||
} | ||
function setup(setupFn) { | ||
@@ -518,8 +519,12 @@ // Hack to delay the invocation of setup function. | ||
// Actual implementation | ||
function prop(options) { | ||
return options; | ||
} | ||
exports.Options = Options; | ||
exports.Vue = Vue; | ||
exports.createDecorator = createDecorator; | ||
exports.emits = emits; | ||
exports.mixins = mixins; | ||
exports.props = props; | ||
exports.prop = prop; | ||
exports.setup = setup; | ||
@@ -526,0 +531,0 @@ |
/** | ||
* vue-class-component v8.0.0-beta.3 | ||
* vue-class-component v8.0.0-beta.4 | ||
* (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&&n(t.prototype,e),r&&n(t,r),t}function c(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 i(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){c(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 f(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&&s(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(){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 l(t,e,r){return(l=p()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&s(o,r.prototype),o}).apply(null,arguments)}function y(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 v(t){var e=p();return function(){var r,n=a(t);if(e){var o=a(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return y(this,r)}}function h(t){return function(t){if(Array.isArray(t))return _(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 _(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 _(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 _(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 b(t,e,r){Object.defineProperty(t,e,{get:r,enumerable:!1,configurable:!0})}var d=function(){function t(e,n){var o=this;r(this,t),b(this,"$props",function(){return e}),b(this,"$attrs",function(){return n.attrs}),b(this,"$slots",function(){return n.slots}),b(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]})})}return o(t,null,[{key:"__vccExtend",value:function(t){t.mixins=t.mixins||[],t.mixins.push(this.__vccOpts)}},{key:"registerHooks",value:function(t){var e;(e=this.__vccHooks).push.apply(e,h(t))}},{key:"__vccOpts",get:function(){if(this===O)return{};var t=this.hasOwnProperty("__vccCache")&&this.__vccCache;if(t)return t;var r=this,n=this.__vccCache=this.hasOwnProperty("__vccBase")?i({},this.__vccBase):{},o=function(t){var e=Object.getPrototypeOf(t.prototype);if(e)return e.constructor}(r);o&&o.__vccExtend(n),n.methods=i({},n.methods),n.computed=i({},n.computed);var c=r.prototype;Object.getOwnPropertyNames(c).forEach(function(t){if("constructor"!==t)if(r.__vccHooks.indexOf(t)>-1)n[t]=c[t];else{var e=Object.getOwnPropertyDescriptor(c,t);"function"!=typeof e.value?(e.get||e.set)&&(n.computed[t]={get:e.get,set:e.set}):n.methods[t]=e.value}}),n.setup=function(t,n){var o=new r(t,n),c=Object.keys(o),u={};return c.forEach(function(t){void 0===o[t]||o[t]&&o[t].__s||(u[t]=e.ref(o[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})}(o,t,u))}),c.forEach(function(t){if(o[t]&&o[t].__s){var r=o[t].__s();u[t]=e.proxyRefs(r)}}),u};var u=this.hasOwnProperty("__vccDecorators")&&this.__vccDecorators;u&&u.forEach(function(t){return t(n)});return["render","ssrRender","__file","__cssModules","__scopeId","__hmrId"].forEach(function(t){r[t]&&(n[t]=r[t])}),n}}]),t}();d.__vccHooks=["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.__vccBase=t,e}},t.Vue=O,t.createDecorator=function(t){return function(e,r,n){var o="function"==typeof e?e:e.constructor;o.__vccDecorators||(o.__vccDecorators=[]),"number"!=typeof n&&(n=void 0),o.__vccDecorators.push(function(e){return t(e,r,n)})}},t.emits=function(t){return function(e){f(c,O);var n=v(c);function c(){return r(this,c),n.apply(this,arguments)}return o(c,null,[{key:"__vccExtend",value:function(e){e.emits=t}}]),c}()},t.mixins=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(t){f(c,O);var n=v(c);function c(){for(var t,o=arguments.length,u=new Array(o),i=0;i<o;i++)u[i]=arguments[i];return r(this,c),t=n.call.apply(n,[this].concat(u)),e.forEach(function(e){var r=l(e,u);Object.keys(r).forEach(function(e){t[e]=r[e]})}),t}return o(c,null,[{key:"__vccExtend",value:function(t){e.forEach(function(e){return e.__vccExtend(t)})}}]),c}()},t.props=function(t){return function(e){f(c,O);var n=v(c);function c(){return r(this,c),n.apply(this,arguments)}return o(c,null,[{key:"__vccExtend",value:function(e){e.props=t}}]),c}()},t.setup=function(t){return{__s:t}},t}({},Vue); | ||
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&&n(t.prototype,e),r&&n(t,r),t}function c(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 i(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){c(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 f(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&&s(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(){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 l(t,e,r){return(l=p()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&s(o,r.prototype),o}).apply(null,arguments)}function y(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 v(t){var e=p();return function(){var r,n=a(t);if(e){var o=a(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return y(this,r)}}function h(t){return function(t){if(Array.isArray(t))return b(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 b(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 b(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 b(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 _(t,e,r){Object.defineProperty(t,e,{get:r,enumerable:!1,configurable:!0})}var d=function(){function t(e,n){var o=this;r(this,t),_(this,"$props",function(){return e}),_(this,"$attrs",function(){return n.attrs}),_(this,"$slots",function(){return n.slots}),_(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]})})}return o(t,null,[{key:"__vccExtend",value:function(t){t.mixins=t.mixins||[],t.mixins.push(this.__vccOpts)}},{key:"registerHooks",value:function(t){var e;(e=this.__vccHooks).push.apply(e,h(t))}},{key:"props",value:function(t){var e=new t,n={};return Object.keys(e).forEach(function(t){var r=e[t];n[t]=null!==r&&void 0!==r?r:null}),function(t){f(c,t);var e=v(c);function c(){return r(this,c),e.apply(this,arguments)}return o(c,null,[{key:"__vccExtend",value:function(t){t.props=n}}]),c}(this)}},{key:"__vccOpts",get:function(){if(this===O)return{};var t=this.hasOwnProperty("__vccCache")&&this.__vccCache;if(t)return t;var r=this,n=this.__vccCache=this.hasOwnProperty("__vccBase")?i({},this.__vccBase):{},o=function(t){var e=Object.getPrototypeOf(t.prototype);if(e)return e.constructor}(r);o&&o.__vccExtend(n),n.methods=i({},n.methods),n.computed=i({},n.computed);var c=r.prototype;Object.getOwnPropertyNames(c).forEach(function(t){if("constructor"!==t)if(r.__vccHooks.indexOf(t)>-1)n[t]=c[t];else{var e=Object.getOwnPropertyDescriptor(c,t);"function"!=typeof e.value?(e.get||e.set)&&(n.computed[t]={get:e.get,set:e.set}):n.methods[t]=e.value}}),n.setup=function(t,n){var o,c=new r(t,n),u=Object.keys(c),i={},f=null;return u.forEach(function(t){void 0===c[t]||c[t]&&c[t].__s||(i[t]=e.ref(c[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})}(c,t,i))}),u.forEach(function(t){if(c[t]&&c[t].__s){var r=c[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 u=this.hasOwnProperty("__vccDecorators")&&this.__vccDecorators;u&&u.forEach(function(t){return t(n)});return["render","ssrRender","__file","__cssModules","__scopeId","__hmrId"].forEach(function(t){r[t]&&(n[t]=r[t])}),n}}]),t}();d.__vccHooks=["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.__vccBase=t,e}},t.Vue=O,t.createDecorator=function(t){return function(e,r,n){var o="function"==typeof e?e:e.constructor;o.__vccDecorators||(o.__vccDecorators=[]),"number"!=typeof n&&(n=void 0),o.__vccDecorators.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];return function(t){f(c,O);var n=v(c);function c(){for(var t,o=arguments.length,u=new Array(o),i=0;i<o;i++)u[i]=arguments[i];return r(this,c),t=n.call.apply(n,[this].concat(u)),e.forEach(function(e){var r=l(e,u);Object.keys(r).forEach(function(e){t[e]=r[e]})}),t}return o(c,null,[{key:"__vccExtend",value:function(t){e.forEach(function(e){return e.__vccExtend(t)})}}]),c}()},t.prop=function(t){return t},t.setup=function(t){return{__s:t}},t}({},Vue); |
{ | ||
"name": "vue-class-component", | ||
"version": "8.0.0-beta.3", | ||
"version": "8.0.0-beta.4", | ||
"description": "ES201X/TypeScript class decorator for Vue components", | ||
@@ -61,3 +61,3 @@ "main": "dist/vue-class-component.cjs.js", | ||
"@types/node": "^14.6.0", | ||
"@vue/compiler-sfc": "^3.0.0-rc.12", | ||
"@vue/compiler-sfc": "^3.0.0", | ||
"babel-jest": "^26.3.0", | ||
@@ -78,3 +78,3 @@ "babel-loader": "^8.1.0", | ||
"uglify-es": "^3.3.9", | ||
"vue": "^3.0.0-rc.12", | ||
"vue": "^3.0.0", | ||
"vue-loader": "^16.0.0-beta.5", | ||
@@ -81,0 +81,0 @@ "webpack": "^4.44.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75622
1639