effector-vue
Advanced tools
Comparing version 20.4.0 to 20.4.1
@@ -9,8 +9,16 @@ import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue' | ||
type Inference<S> = S extends Store<infer State> | ||
type Inference<EffectorState> = EffectorState extends Store<infer State> | ||
? State | ||
: S extends {[storeName: string]: Store<any>} | ||
? {[K in keyof S]: S[K] extends Store<infer U> ? U : never} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never} | ||
: never | ||
type EffectorType = Store<any> | {[key: string]: Store<any>} | (() => Store<any>) | ||
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State>) | Store<infer State> | ||
? {state: State} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[Key in keyof EffectorState]: Inference<EffectorState[Key]>} | ||
: never | ||
declare module 'vue/types/vue' { | ||
@@ -23,5 +31,5 @@ interface Vue { | ||
interface VueConstructor<V extends Vue> { | ||
extend<S, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: ThisTypedComponentOptionsWithArrayProps< | ||
S & V, | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -32,6 +40,6 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<S, Data, Methods, Computed, Props>( | ||
options?: ThisTypedComponentOptionsWithRecordProps< | ||
S & V, | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -42,3 +50,3 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props> | ||
} | ||
@@ -49,3 +57,3 @@ } | ||
interface ComponentOptions<V extends Vue> { | ||
effector?: (this: V) => Store<any> | {[field: string]: Store<any>} | ||
effector?: EffectorType | ||
} | ||
@@ -109,3 +117,3 @@ } | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, Props> | ||
declare function createComponent< | ||
@@ -127,2 +135,2 @@ S extends {[field: string]: Store<any>}, | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, PropNames> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames> |
@@ -1,2 +0,2 @@ | ||
'use strict';function e(e,t){void 0===t&&(t={immediate:1});var r=this,o=n.createEvent(),i=n.createStore({});i.on(o,(function(e,t){return t}));var c=function(){r.$watch(e,(function(e,t){o({oldValue:t,newValue:e})}),t)};return r._data?c():r.$once('hook:created',c),i}function t(e){return this.$watchAsStore(e).map((function(e){return e.newValue}))}Object.defineProperty(exports,'__esModule',{value:1});var r,o=(r=require('vue'))&&'object'==typeof r&&'default'in r?r.default:r,n=require('effector/compat'),i={beforeCreate:function(){var e=this,t=e.$options.effector;if('function'==typeof t&&(t=t.call(e)),t)if(n.is.store(t))o.util.defineReactive(e,"state",t.getState()),e._subscription=t.watch((function(t){e.state=t}));else{if('object'!=typeof t||null===t)throw Error('property should be Store');var r=n.createStoreObject(t);for(var i in t)o.util.defineReactive(e,i,r.defaultState[i]);e._subscription=r.watch((function(t){for(var r in t)e[r]=t[r]}))}},beforeDestroy:function(){this._subscription&&this._subscription.unsubscribe()}};exports.VueEffector=function(r){r.mixin(i),r.prototype.$watchAsStore=e,r.prototype.$store=t},exports.createComponent=function(e,t){return o.extend(Object.assign({},e,t&&{effector:function(){return t}}))}; | ||
'use strict';function t(t,e={immediate:1}){const o=effector.createEvent(),i=effector.restore(o,{}),r=()=>{this.$watch(t,(t,e)=>{o({oldValue:e,newValue:t})},e)};return this._data?r():this.$once('hook:created',r),i}function e(t){return this.$watchAsStore(t).map(({newValue:t})=>t)}Object.defineProperty(exports,'__esModule',{value:1});var o,i=(o=require('vue'))&&'object'==typeof o&&'default'in o?o.default:o,effector=require('effector');const r={beforeCreate(){let t=this.$options.effector;if('function'==typeof t&&(t=t.call(this)),t)if(effector.is.store(t))i.util.defineReactive(this,"state",t.getState()),this._subscription=t.watch(t=>{this.state=t});else{if('object'!=typeof t||null===t)throw Error('property should be Store');{const e=effector.combine(t);for(const o in t)i.util.defineReactive(this,o,e.defaultState[o]);this._subscription=e.watch(t=>{for(const e in t)this[e]=t[e]})}}},beforeDestroy(){this._subscription&&this._subscription.unsubscribe()}};exports.VueEffector=o=>{o.mixin(r),o.prototype.$watchAsStore=t,o.prototype.$store=e},exports.createComponent=function(t,e){return i.extend(Object.assign({},t,e&&{effector:()=>e}))}; | ||
//# sourceMappingURL=compat.js.map |
@@ -9,8 +9,16 @@ import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue' | ||
type Inference<S> = S extends Store<infer State> | ||
type Inference<EffectorState> = EffectorState extends Store<infer State> | ||
? State | ||
: S extends {[storeName: string]: Store<any>} | ||
? {[K in keyof S]: S[K] extends Store<infer U> ? U : never} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never} | ||
: never | ||
type EffectorType = Store<any> | {[key: string]: Store<any>} | (() => Store<any>) | ||
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State>) | Store<infer State> | ||
? {state: State} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[Key in keyof EffectorState]: Inference<EffectorState[Key]>} | ||
: never | ||
declare module 'vue/types/vue' { | ||
@@ -23,5 +31,5 @@ interface Vue { | ||
interface VueConstructor<V extends Vue> { | ||
extend<S, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: ThisTypedComponentOptionsWithArrayProps< | ||
S & V, | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -32,6 +40,6 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<S, Data, Methods, Computed, Props>( | ||
options?: ThisTypedComponentOptionsWithRecordProps< | ||
S & V, | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -42,3 +50,3 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props> | ||
} | ||
@@ -49,3 +57,3 @@ } | ||
interface ComponentOptions<V extends Vue> { | ||
effector?: (this: V) => Store<any> | {[field: string]: Store<any>} | ||
effector?: EffectorType | ||
} | ||
@@ -109,3 +117,3 @@ } | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, Props> | ||
declare function createComponent< | ||
@@ -127,2 +135,2 @@ S extends {[field: string]: Store<any>}, | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, PropNames> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames> |
@@ -1,2 +0,2 @@ | ||
function e(e,t={immediate:1}){const o=this,r=effector.createEvent(),i=effector.createStore({});let s;i.on(r,(e,t)=>t);const c=()=>{s=o.$watch(e,(e,t)=>{r({oldValue:t,newValue:e})},t)};return o._data?c():o.$once('hook:created',c),i}function t(e){return this.$watchAsStore(e).map(({newValue:e})=>e)}Object.defineProperty(exports,'__esModule',{value:1});var o,r=(o=require('vue'))&&'object'==typeof o&&'default'in o?o.default:o,effector=require('effector');const i={beforeCreate(){const e=this;let t=e.$options.effector;if('function'==typeof t&&(t=t.call(e)),t)if(effector.is.store(t))r.util.defineReactive(e,"state",t.getState()),e._subscription=t.watch(t=>{e.state=t});else{if('object'!=typeof t||null===t)throw Error('property should be Store');{const o=effector.createStoreObject(t);for(const i in t)r.util.defineReactive(e,i,o.defaultState[i]);e._subscription=o.watch(t=>{for(const o in t)e[o]=t[o]})}}},beforeDestroy(){this._subscription&&this._subscription.unsubscribe()}};exports.VueEffector=o=>{o.mixin(i),o.prototype.$watchAsStore=e,o.prototype.$store=t},exports.createComponent=(e,t)=>r.extend(Object.assign({},e,t&&{effector:()=>t})); | ||
function e(e,t={immediate:1}){const o=effector.createEvent(),i=effector.restore(o,{}),r=()=>{this.$watch(e,(e,t)=>{o({oldValue:t,newValue:e})},t)};return this._data?r():this.$once('hook:created',r),i}function t(e){return this.$watchAsStore(e).map(({newValue:e})=>e)}Object.defineProperty(exports,'__esModule',{value:1});var o,i=(o=require('vue'))&&'object'==typeof o&&'default'in o?o.default:o,effector=require('effector');const r={beforeCreate(){let e=this.$options.effector;if('function'==typeof e&&(e=e.call(this)),e)if(effector.is.store(e))i.util.defineReactive(this,"state",e.getState()),this._subscription=e.watch(e=>{this.state=e});else{if('object'!=typeof e||null===e)throw Error('property should be Store');{const t=effector.combine(e);for(const o in e)i.util.defineReactive(this,o,t.defaultState[o]);this._subscription=t.watch(e=>{for(const t in e)this[t]=e[t]})}}},beforeDestroy(){this._subscription&&this._subscription.unsubscribe()}};exports.VueEffector=o=>{o.mixin(r),o.prototype.$watchAsStore=e,o.prototype.$store=t},exports.createComponent=(e,t)=>i.extend(Object.assign({},e,t&&{effector:()=>t})); | ||
//# sourceMappingURL=effector-vue.cjs.js.map |
@@ -9,8 +9,16 @@ import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue' | ||
type Inference<S> = S extends Store<infer State> | ||
type Inference<EffectorState> = EffectorState extends Store<infer State> | ||
? State | ||
: S extends {[storeName: string]: Store<any>} | ||
? {[K in keyof S]: S[K] extends Store<infer U> ? U : never} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never} | ||
: never | ||
type EffectorType = Store<any> | {[key: string]: Store<any>} | (() => Store<any>) | ||
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State>) | Store<infer State> | ||
? {state: State} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[Key in keyof EffectorState]: Inference<EffectorState[Key]>} | ||
: never | ||
declare module 'vue/types/vue' { | ||
@@ -23,5 +31,5 @@ interface Vue { | ||
interface VueConstructor<V extends Vue> { | ||
extend<S, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: ThisTypedComponentOptionsWithArrayProps< | ||
S & V, | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -32,6 +40,6 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<S, Data, Methods, Computed, Props>( | ||
options?: ThisTypedComponentOptionsWithRecordProps< | ||
S & V, | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -42,3 +50,3 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props> | ||
} | ||
@@ -49,3 +57,3 @@ } | ||
interface ComponentOptions<V extends Vue> { | ||
effector?: (this: V) => Store<any> | {[field: string]: Store<any>} | ||
effector?: EffectorType | ||
} | ||
@@ -109,3 +117,3 @@ } | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, Props> | ||
declare function createComponent< | ||
@@ -127,2 +135,2 @@ S extends {[field: string]: Store<any>}, | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, PropNames> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames> |
@@ -1,2 +0,2 @@ | ||
function t(t,e){return r.extend(Object.assign({},t,e&&{effector:()=>e}))}function e(t,e={immediate:1}){const o=this,r=s(),i=c({});let n;i.on(r,(t,e)=>e);const f=()=>{n=o.$watch(t,(t,e)=>{r({oldValue:e,newValue:t})},e)};return o._data?f():o.$once('hook:created',f),i}function o(t){return this.$watchAsStore(t).map(({newValue:t})=>t)}import r from'vue';import{is as i,createStoreObject as n,createEvent as s,createStore as c}from'effector';const f={beforeCreate(){const t=this;let e=t.$options.effector;if('function'==typeof e&&(e=e.call(t)),e)if(i.store(e))r.util.defineReactive(t,"state",e.getState()),t._subscription=e.watch(e=>{t.state=e});else{if('object'!=typeof e||null===e)throw Error('property should be Store');{const o=n(e);for(const i in e)r.util.defineReactive(t,i,o.defaultState[i]);t._subscription=o.watch(e=>{for(const o in e)t[o]=e[o]})}}},beforeDestroy(){this._subscription&&this._subscription.unsubscribe()}},a=t=>{t.mixin(f),t.prototype.$watchAsStore=e,t.prototype.$store=o};export{a as VueEffector,t as createComponent}; | ||
function t(t,e={immediate:1}){const o=s(),i=r(o,{}),n=()=>{this.$watch(t,(t,e)=>{o({oldValue:e,newValue:t})},e)};return this._data?n():this.$once('hook:created',n),i}function e(t){return this.$watchAsStore(t).map(({newValue:t})=>t)}function o(t,e){return i.extend(Object.assign({},t,e&&{effector:()=>e}))}import i from'vue';import{createEvent as s,restore as r,is as n,combine as c}from'effector';const f=o=>{o.mixin(a),o.prototype.$watchAsStore=t,o.prototype.$store=e},a={beforeCreate(){let t=this.$options.effector;if('function'==typeof t&&(t=t.call(this)),t)if(n.store(t))i.util.defineReactive(this,"state",t.getState()),this._subscription=t.watch(t=>{this.state=t});else{if('object'!=typeof t||null===t)throw Error('property should be Store');{const e=c(t);for(const o in t)i.util.defineReactive(this,o,e.defaultState[o]);this._subscription=e.watch(t=>{for(const e in t)this[e]=t[e]})}}},beforeDestroy(){this._subscription&&this._subscription.unsubscribe()}};export{f as VueEffector,o as createComponent}; | ||
//# sourceMappingURL=effector-vue.es.js.map |
@@ -9,8 +9,16 @@ import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue' | ||
type Inference<S> = S extends Store<infer State> | ||
type Inference<EffectorState> = EffectorState extends Store<infer State> | ||
? State | ||
: S extends {[storeName: string]: Store<any>} | ||
? {[K in keyof S]: S[K] extends Store<infer U> ? U : never} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never} | ||
: never | ||
type EffectorType = Store<any> | {[key: string]: Store<any>} | (() => Store<any>) | ||
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State>) | Store<infer State> | ||
? {state: State} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[Key in keyof EffectorState]: Inference<EffectorState[Key]>} | ||
: never | ||
declare module 'vue/types/vue' { | ||
@@ -23,5 +31,5 @@ interface Vue { | ||
interface VueConstructor<V extends Vue> { | ||
extend<S, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: ThisTypedComponentOptionsWithArrayProps< | ||
S & V, | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -32,6 +40,6 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<S, Data, Methods, Computed, Props>( | ||
options?: ThisTypedComponentOptionsWithRecordProps< | ||
S & V, | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -42,3 +50,3 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props> | ||
} | ||
@@ -49,3 +57,3 @@ } | ||
interface ComponentOptions<V extends Vue> { | ||
effector?: (this: V) => Store<any> | {[field: string]: Store<any>} | ||
effector?: EffectorType | ||
} | ||
@@ -109,3 +117,3 @@ } | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, Props> | ||
declare function createComponent< | ||
@@ -127,2 +135,2 @@ S extends {[field: string]: Store<any>}, | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, PropNames> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames> |
@@ -1,2 +0,2 @@ | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports,require('vue'),require('effector')):'function'==typeof define&&define.amd?define(['exports','vue','effector'],t):t((e=e||self).effectorVue={},e.Vue,e.effector)})(this,(function(e,t,effector){function o(e,t={immediate:1}){const o=this,r=effector.createEvent(),n=effector.createStore({});let i;n.on(r,(e,t)=>t);const c=()=>{i=o.$watch(e,(e,t)=>{r({oldValue:t,newValue:e})},t)};return o._data?c():o.$once('hook:created',c),n}function r(e){return this.$watchAsStore(e).map(({newValue:e})=>e)}t=t&&t.hasOwnProperty('default')?t.default:t;const n={beforeCreate(){const e=this;let o=e.$options.effector;if('function'==typeof o&&(o=o.call(e)),o)if(effector.is.store(o))t.util.defineReactive(e,"state",o.getState()),e._subscription=o.watch(t=>{e.state=t});else{if('object'!=typeof o||null===o)throw Error('property should be Store');{const r=effector.createStoreObject(o);for(const n in o)t.util.defineReactive(e,n,r.defaultState[n]);e._subscription=r.watch(t=>{for(const o in t)e[o]=t[o]})}}},beforeDestroy(){this._subscription&&this._subscription.unsubscribe()}};e.VueEffector=e=>{e.mixin(n),e.prototype.$watchAsStore=o,e.prototype.$store=r},e.createComponent=(e,o)=>t.extend(Object.assign({},e,o&&{effector:()=>o})),Object.defineProperty(e,'__esModule',{value:1})})); | ||
((e,t)=>{'object'==typeof exports&&'undefined'!=typeof module?t(exports,require('vue'),require('effector')):'function'==typeof define&&define.amd?define(['exports','vue','effector'],t):t((e=e||self).effectorVue={},e.Vue,e.effector)})(this,(function(e,t,effector){function o(e,t={immediate:1}){const o=effector.createEvent(),i=effector.restore(o,{}),r=()=>{this.$watch(e,(e,t)=>{o({oldValue:t,newValue:e})},t)};return this._data?r():this.$once('hook:created',r),i}function i(e){return this.$watchAsStore(e).map(({newValue:e})=>e)}t=t&&t.hasOwnProperty('default')?t.default:t;const r={beforeCreate(){let e=this.$options.effector;if('function'==typeof e&&(e=e.call(this)),e)if(effector.is.store(e))t.util.defineReactive(this,"state",e.getState()),this._subscription=e.watch(e=>{this.state=e});else{if('object'!=typeof e||null===e)throw Error('property should be Store');{const o=effector.combine(e);for(const i in e)t.util.defineReactive(this,i,o.defaultState[i]);this._subscription=o.watch(e=>{for(const t in e)this[t]=e[t]})}}},beforeDestroy(){this._subscription&&this._subscription.unsubscribe()}};e.VueEffector=e=>{e.mixin(r),e.prototype.$watchAsStore=o,e.prototype.$store=i},e.createComponent=(e,o)=>t.extend(Object.assign({},e,o&&{effector:()=>o})),Object.defineProperty(e,'__esModule',{value:1})})); | ||
//# sourceMappingURL=effector-vue.umd.js.map |
@@ -9,8 +9,16 @@ import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue' | ||
type Inference<S> = S extends Store<infer State> | ||
type Inference<EffectorState> = EffectorState extends Store<infer State> | ||
? State | ||
: S extends {[storeName: string]: Store<any>} | ||
? {[K in keyof S]: S[K] extends Store<infer U> ? U : never} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never} | ||
: never | ||
type EffectorType = Store<any> | {[key: string]: Store<any>} | (() => Store<any>) | ||
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State>) | Store<infer State> | ||
? {state: State} | ||
: EffectorState extends {[storeName: string]: Store<any>} | ||
? {[Key in keyof EffectorState]: Inference<EffectorState[Key]>} | ||
: never | ||
declare module 'vue/types/vue' { | ||
@@ -23,5 +31,5 @@ interface Vue { | ||
interface VueConstructor<V extends Vue> { | ||
extend<S, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: ThisTypedComponentOptionsWithArrayProps< | ||
S & V, | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -32,6 +40,6 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<S, Data, Methods, Computed, Props>( | ||
options?: ThisTypedComponentOptionsWithRecordProps< | ||
S & V, | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>> | ||
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>( | ||
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps< | ||
ExpandType<V, EffectorState> & V, | ||
Data, | ||
@@ -42,3 +50,3 @@ Methods, | ||
>, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props> | ||
} | ||
@@ -49,3 +57,3 @@ } | ||
interface ComponentOptions<V extends Vue> { | ||
effector?: (this: V) => Store<any> | {[field: string]: Store<any>} | ||
effector?: EffectorType | ||
} | ||
@@ -109,3 +117,3 @@ } | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, Props> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, Props> | ||
declare function createComponent< | ||
@@ -127,2 +135,2 @@ S extends {[field: string]: Store<any>}, | ||
store?: S, | ||
): ExtendedVue<V, Data, Methods, Computed, PropNames> | ||
): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames> |
{ | ||
"name": "effector-vue", | ||
"version": "20.4.0", | ||
"version": "20.4.1", | ||
"description": "Vue bindings for effector", | ||
@@ -38,10 +38,11 @@ "main": "effector-vue.cjs.js", | ||
"vue", | ||
"data", | ||
"effect", | ||
"event", | ||
"functional", | ||
"reactive", | ||
"state manager", | ||
"reactive", | ||
"functional", | ||
"store", | ||
"event", | ||
"effect", | ||
"data", | ||
"state" | ||
"state-manager", | ||
"state", | ||
"store" | ||
], | ||
@@ -48,0 +49,0 @@ "author": "Zero Bias", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
42583
613