Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

effector-vue

Package Overview
Dependencies
Maintainers
5
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

effector-vue - npm Package Compare versions

Comparing version 23.0.0-rc.4 to 23.0.0-rc.5

68

compat.d.ts

@@ -1,2 +0,2 @@

import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue'
import Vue, {WatchOptions, VueConstructor} from 'vue'
import {

@@ -7,3 +7,3 @@ ThisTypedComponentOptionsWithArrayProps,

import {ExtendedVue} from 'vue/types/vue'
import {Store, Unit} from 'effector'
import {Scope, Store, Unit} from 'effector'

@@ -13,10 +13,23 @@ type Inference<EffectorState> = EffectorState extends Store<infer State>

: EffectorState extends {[storeName: string]: Store<any>}
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never}
? {
[K in keyof EffectorState]: EffectorState[K] extends Store<infer U>
? U
: never
}
: EffectorState extends Unit<infer State>
? number
: never;
: never
type EffectorType = Store<any> | {[key: string]: Store<any> | Unit<any>} | (() => Store<any> | Unit<any>)
type EffectorType =
| Store<any>
| {[key: string]: Store<any> | Unit<any>}
| (() => Store<any> | Unit<any>)
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State> | Unit<infer State>) | Store<infer State> | Unit<infer State>
type ExpandType<
V extends Vue,
EffectorState extends EffectorType,
> = EffectorState extends
| ((this: V) => Store<infer State> | Unit<infer State>)
| Store<infer State>
| Unit<infer State>
? {state: State}

@@ -34,4 +47,12 @@ : EffectorState extends {[storeName: string]: Store<any> | Unit<any>}

interface VueConstructor<V extends Vue> {
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps<
extend<
EffectorState extends EffectorType,
Data,
Methods,
Computed,
PropNames extends string = never,
>(
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithArrayProps<
ExpandType<V, EffectorState> & V,

@@ -43,5 +64,13 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Record<PropNames, any>
>
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps<
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithRecordProps<
ExpandType<V, EffectorState> & V,

@@ -53,3 +82,9 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Props
>
}

@@ -92,3 +127,3 @@ }

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -110,3 +145,3 @@ options: ThisTypedComponentOptionsWithArrayProps<

Computed,
Props
Props,
>(

@@ -128,3 +163,3 @@ options: ThisTypedComponentOptionsWithRecordProps<

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -140,1 +175,6 @@ options: ThisTypedComponentOptionsWithArrayProps<

): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames>
export function EffectorScopePlugin(config: {
scope: Scope
scopeName?: string
}): Plugin

@@ -1,2 +0,2 @@

'use strict';function e(e){return e&&'object'==typeof e&&'default'in e?e.default:e}Object.defineProperty(exports,'__esModule',{value:1});var t=require('vue'),r=require('effector/compat'),o=e(t),i={beforeCreate:function(){var e=this,t=this.$options.effector;if('function'==typeof t&&(t=t.call(this)),t){this.$options.computed||(this.$options.computed={});var i={};if(r.is.store(t))i={state:t};else{if('object'!=typeof t)throw Error('property should be Store');i=Object.assign({},t)}this.__clear=r.createEvent(),r.withRegion(this.__clear,(function(){var t={},n=0;for(var f in i){var c=i[f];if(r.is.store(c))t[f]=c;else{if(!r.is.event(c)&&!r.is.effect(c))throw Error("Effector property "+f+" should be Store or Unit (will be transform to Store<number>)");t[f]=r.restore(c.map((function(){return++n})),null)}}var a=r.combine(t);for(var s in a.defaultState)o.util.defineReactive(e,s,a.defaultState[s]);a.watch((function(t){for(var r in t)e[r]=t[r]}));var u=function(o){var i=r.createEvent();r.sample({clock:i,target:t[o]}),e.$options.computed[o]={get:function(){return e[o]},set:i}};for(var l in t)u(l)}))}},beforeDestroy:function(){this.__clear&&r.clearNode(this.__clear)}};exports.VueEffector=function(e){e.mixin(i)},exports.createComponent=function(e,t){return o.extend(Object.assign({},e,t&&{effector:function(){return t}}))};
'use strict';function e(e){return e&&'object'==typeof e&&'default'in e?e.default:e}Object.defineProperty(exports,'__esModule',{value:1});var t=require('vue'),o=require('effector/compat'),r=e(t),i={beforeCreate:function(){var e=this,t=this.$options.effector;if('function'==typeof t&&(t=t.call(this)),t){this.$options.computed||(this.$options.computed={});var i={};if(o.is.store(t))i={state:t};else{if('object'!=typeof t)throw Error('property should be Store');i=Object.assign({},t)}this.__clear=o.createEvent(),o.withRegion(this.__clear,(function(){var t={},n=0;for(var c in i){var f=i[c];if(o.is.store(f))t[c]=f;else{if(!o.is.event(f)&&!o.is.effect(f))throw Error("Effector property "+c+" should be Store or Unit (will be transform to Store<number>)");t[c]=o.restore(f.map((function(){return++n})),null)}}var s=o.combine(t);for(var a in s.defaultState)r.util.defineReactive(e,a,s.defaultState[a]);s.watch((function(t){for(var o in t)e[o]=t[o]}));var u=function(r){var i=o.createEvent();o.sample({clock:i,target:t[r]}),e.$options.computed[r]={get:function(){return e[r]},set:i}};for(var l in t)u(l)}))}},beforeDestroy:function(){this.__clear&&o.clearNode(this.__clear)}};exports.EffectorScopePlugin=function(e){return{install:function(t){var o,r=null!==(o=e.scopeName)&&void 0!==o?o:'root';t.config.globalProperties.scopeName=r,t.provide(t.config.globalProperties.scopeName,e.scope)}}},exports.VueEffector=function(e){e.mixin(i)},exports.createComponent=function(e,t){return r.extend(Object.assign({},e,t&&{effector:function(){return t}}))};
//# sourceMappingURL=compat.js.map

@@ -1,43 +0,109 @@

import { Scope } from '@babel/traverse';
import {ComputedRef, DeepReadonly, Ref, UnwrapRef} from '@vue/reactivity'
import {Domain, Store, Event} from 'effector'
import {Domain, Store, Event, Effect, Scope} from 'effector'
type GateConfig<T> = {
name?: string;
defaultState?: T;
domain?: Domain;
sid?: string;
};
name?: string
defaultState?: T
domain?: Domain
sid?: string
}
type Gate<Props> = {
open: Event<Props>;
close: Event<Props>;
status: Store<boolean>;
state: Store<Props>;
set: Event<Props>;
};
open: Event<Props>
close: Event<Props>
status: Store<boolean>
state: Store<Props>
set: Event<Props>
}
type ExtractStore<T extends Record<string, Store<unknown>>> = {
[Key in keyof T]: T[Key] extends Store<infer U> ? Ref<UnwrapRef<U>> : never
}
}
export interface UseVModel {
<T>(vm: Store<T>): Ref<T>
<T extends Record<string, Store<any>>>(vm: T): ExtractStore<T>
}
export interface UseVModel {
<T>(vm: Store<T>): Ref<T>
<T extends Record<string, Store<any>>>(vm: T): ExtractStore<T>
}
export function useStoreMap<State, Result, Keys = unknown>(
config: {
store: Store<State>;
keys?: () => Keys;
fn: (state: State, keys: Keys) => Result;
updateFilter?: (update: Result, current: Result) => boolean;
defaultValue?: Result;
store: Store<State>
keys?: () => Keys
fn: (state: State, keys: Keys) => Result
updateFilter?: (update: Result, current: Result) => boolean
defaultValue?: Result
},
scope?: Scope
scope?: Scope,
): ComputedRef<Result>
export function useVModel<T>(vm: Store<T>): Ref<UnwrapRef<T>>
export function useVModel<T extends Record<string, Store<any>>>(vm: T): ExtractStore<T>
export function useVModel<T extends Record<string, Store<any>>>(
vm: T,
): ExtractStore<T>
export function useStore<T>(store: Store<T>): DeepReadonly<Ref<T>>
export function createGate<Props>(config?: GateConfig<Props>): Gate<Props>
export function useGate<Props>(GateComponent: Gate<Props>, cb?: () => Props): void
export function useGate<Props>(
GateComponent: Gate<Props>,
cb?: () => Props,
): void
export function useUnit<State>(
store: Store<State>,
opts?: {forceScope?: boolean},
): DeepReadonly<Ref<State>>
export function useUnit(
event: Event<void>,
opts?: {forceScope?: boolean},
): () => void
export function useUnit<T>(
event: Event<T>,
opts?: {forceScope?: boolean},
): (payload: T) => T
export function useUnit<R>(
fx: Effect<void, R, any>,
opts?: {forceScope?: boolean},
): () => Promise<R>
export function useUnit<T, R>(
fx: Effect<T, R, any>,
opts?: {forceScope?: boolean},
): (payload: T) => Promise<R>
export function useUnit<
List extends (Event<any> | Effect<any, any> | Store<any>)[],
>(
list: [...List],
opts?: {forceScope?: boolean},
): {
[Key in keyof List]: List[Key] extends Event<infer T>
? Equal<T, void> extends true
? () => void
: (payload: T) => T
: List[Key] extends Effect<infer P, infer D, any>
? Equal<P, void> extends true
? () => Promise<D>
: (payload: P) => Promise<D>
: List[Key] extends Store<infer V>
? DeepReadonly<Ref<V>>
: never
}
export function useUnit<
Shape extends Record<string, Event<any> | Effect<any, any, any> | Store<any>>,
>(
shape: Shape | {'@@unitShape': () => Shape},
opts?: {forceScope?: boolean},
): {
[Key in keyof Shape]: Shape[Key] extends Event<infer T>
? Equal<T, void> extends true
? () => void
: (payload: T) => T
: Shape[Key] extends Effect<infer P, infer D, any>
? Equal<P, void> extends true
? () => Promise<D>
: (payload: P) => Promise<D>
: Shape[Key] extends Store<infer V>
? DeepReadonly<Ref<V>>
: never
}
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y
? 1
: 2
? true
: false

@@ -1,2 +0,2 @@

function e(e,t,o){let r=[effector.step.run({fn:e=>t(e)})];if(o){let t=effector.createNode({node:r}),n=e.graphite.id,a=o.additionalLinks,l=a[n]||[];return a[n]=l,l.push(t),()=>{let e=l.indexOf(t);-1!==e&&l.splice(e,1),effector.clearNode(t)}}{let t=effector.createNode({node:r,parent:[e],family:{owners:e}});return()=>{effector.clearNode(t)}}}function t(e,t){return t?t.getState(e):e.getState()}function o(){let e,t=i.getCurrentInstance(),o=null==t?void 0:t.appContext.config.globalProperties.scopeName;return o&&(e=i.inject(o)),{scopeName:o,scope:e}}function r(e){let t=i.unref(e);return i.isReactive(t)?i.toRaw(t):t}function n(e,t=[]){if(null===e||'object'!=typeof e)return e;let o=t.filter((t=>t.original===e))[0];if(o)return o.copy;let r=Array.isArray(e)?[]:{};return t.push({original:e,copy:r}),Object.keys(e).forEach((o=>{r[o]=n(e[o],t)})),r}function a(a,l,s){if(!effector.is.store(a))throw Error("expect useVModel argument to be a store");let{scope:u}=o(),c=i.ref(n(t(a,u))),d=0,f=0,p=e(a,(e=>{d||(f=1,c.value=i.ref(n(e)).value)}),u);return i.onUnmounted((()=>{p()})),i.watch((()=>l&&s?s[l]:c.value),(e=>{if(d=1,!f){let t=i.ref(r(e)).value;a.setState(n(t))}f=0,d=0}),{deep:1,immediate:0}),c}function l(e,t){let o=t?e:e[0];var r;(e=>{if(!e)throw Error('expect first argument be an object')})(d(r=o)||(e=>'function'==typeof e)(r));let n=o.or,a=o.and;if(a){let o=t?a:a[0];if(d(o)&&'and'in o){let o=l(a,t);e=o[0],n={...n,...o[1]}}else e=a}return[e,n]}function s(e,t){let o,a;t&&(a=i.computed(t),o=i.watch(a,(t=>{let o=r(t);e.set(n(o))}),{deep:1,immediate:1})),i.onMounted((()=>{if(void 0!==a){let t=r(a.value);e.open(n(t))}else e.open()})),i.onUnmounted((()=>{if(void 0!==a){let t=r(a.value);e.close(n(t))}else e.close();o&&o()}))}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector'),i=require('vue');let u=e=>{throw Error(e)};const c=(e,t)=>e!==t;let d=e=>'object'==typeof e&&null!==e,f=(e,t={})=>(d(e)&&(f(e.or,t),(e=>{for(let n in e)r=n,(e=>void 0===e)(o=e[n])||'or'===r||'and'===r||(t[r]=o);var o,r})(e),f(e.and,t)),t);exports.createGate=(...e)=>{function t(e){s(t,(()=>e))}var o;let r=e&&(e=>d(e)&&(e.and||e.or))(e[0])?e:[{and:e}],[[n],a]=l(r),i=f({or:a,and:n}),u=null==n?void 0:n.domain,c=`${u?`${u.compositeName.fullName}/`:''}${(null==i?void 0:i.name)||'gate'}`,p=effector.createEvent({name:`${c}.set`,sid:i.sid?`${i.sid}|set`:void 0}),v=effector.createEvent({name:`${c}.open`,sid:i.sid?`${i.sid}|open`:void 0}),m=effector.createEvent({name:`${c}.close`,sid:i.sid?`${i.sid}|close`:void 0}),y=effector.createStore(Boolean(0),{name:`${c}.status`,serialize:'ignore'}),h=effector.createStore(null!==(o=null==n?void 0:n.defaultState)&&void 0!==o?o:null,{name:`${c}.state`,sid:null==i?void 0:i.sid});if(h.on(p,((e,t)=>t)),y.on(v,(()=>Boolean(1))).on(m,(()=>Boolean(0))),t.open=v,t.close=m,t.status=y,t.state=h,t.set=p,effector.sample({clock:v,target:p}),h.reset(m),null!=n&&n.domain){let{hooks:e}=n.domain;effector.launch({target:[e.store,e.store,e.event,e.event,e.event],params:[y,h,v,m,p]})}return t},exports.useGate=s,exports.useStore=r=>{effector.is.store(r)||u("expect useStore argument to be a store");let{scope:n}=o(),a=t(r,n),l=i.shallowRef(a),s=e(r,(e=>{l.value=i.shallowRef(e).value}),n);return i.onUnmounted((()=>{s()})),i.readonly(l)},exports.useStoreMap=(e,r)=>{effector.is.store(e.store)||u('useStoreMap expects a store'),void 0!==e.keys&&'function'!=typeof e.keys&&u('useStoreMap expects keys as a function'),'function'!=typeof e.fn&&u('useStoreMap expects fn as a function');let n=r||o().scope,a=i.computed(e.keys?e.keys:()=>{}),l=e.updateFilter||c,s=t(e.store,n),d="object"==typeof s&&0==Array.isArray(s),f=d?i.shallowReactive(s):i.shallowRef(s),p=effector.createWatch({unit:e.store,fn:e=>{if(d)for(let t in e)l(e[t],f[t])&&(f[t]=e[t]);else void 0!==e&&l(e,f.value)&&(f.value=e)},scope:n});return i.onUnmounted((()=>{p()})),i.computed((()=>{let t=e.fn(d?f:f.value,a.value);return void 0!==t?t:e.defaultValue}))},exports.useVModel=e=>{if(effector.is.store(e))return a(e);let t=i.reactive({}),o=Object.fromEntries(Object.entries(e).map((([e,o])=>[e,a(o,e,t)])));for(let e in o)t[e]=o[e];return t};
function e(e,t){return t?t.getState(e):e.getState()}function t(){let e,t=i.getCurrentInstance(),o=null==t?void 0:t.appContext.config.globalProperties.scopeName;return o&&(e=i.inject(o)),{scopeName:o,scope:e}}function o(e){let t=i.unref(e);return i.isReactive(t)?i.toRaw(t):t}function n(e,t=[]){if(null===e||'object'!=typeof e)return e;let o=t.filter((t=>t.original===e))[0];if(o)return o.copy;let r=Array.isArray(e)?[]:{};return t.push({original:e,copy:r}),Object.keys(e).forEach((o=>{r[o]=n(e[o],t)})),r}function r(r,a,s){if(!effector.is.store(r))throw Error('expect useVModel argument to be a store');let{scope:l}=t(),u=i.ref(n(e(r,l))),c=0,f=0,p=effector.createWatch({unit:r,fn:e=>{c||(f=1,u.value=i.ref(n(e)).value)},scope:l});return i.onUnmounted((()=>{p()})),i.watch((()=>a&&s?s[a]:u.value),(e=>{if(c=1,!f){let t=i.ref(o(e)).value;r.setState(n(t))}f=0,c=0}),{deep:1,immediate:0}),u}function a(e,t){let o=t?e:e[0];var n;(e=>{if(!e)throw Error('expect first argument be an object')})(c(n=o)||(e=>'function'==typeof e)(n));let r=o.or,s=o.and;if(s){let o=t?s:s[0];if(c(o)&&'and'in o){let o=a(s,t);e=o[0],r={...r,...o[1]}}else e=s}return[e,r]}function s(e,t){let r,a;t&&(a=i.computed(t),r=i.watch(a,(t=>{let r=o(t);e.set(n(r))}),{deep:1,immediate:1})),i.onMounted((()=>{if(void 0!==a){let t=o(a.value);e.open(n(t))}else e.open()})),i.onUnmounted((()=>{if(void 0!==a){let t=o(a.value);e.close(n(t))}else e.close();r&&r()}))}Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector'),i=require('vue');let l=e=>{throw Error(e)};const u=(e,t)=>e!==t;let c=e=>'object'==typeof e&&null!==e,f=(e,t={})=>(c(e)&&(f(e.or,t),(e=>{for(let r in e)n=r,(e=>void 0===e)(o=e[r])||'or'===n||'and'===n||(t[n]=o);var o,n})(e),f(e.and,t)),t);exports.createGate=(...e)=>{function t(e){s(t,(()=>e))}var o;let n=e&&(e=>c(e)&&(e.and||e.or))(e[0])?e:[{and:e}],[[r],i]=a(n),l=f({or:i,and:r}),u=null==r?void 0:r.domain,p=`${u?`${u.compositeName.fullName}/`:''}${(null==l?void 0:l.name)||'gate'}`,d=effector.createEvent({name:`${p}.set`,sid:l.sid?`${l.sid}|set`:void 0}),v=effector.createEvent({name:`${p}.open`,sid:l.sid?`${l.sid}|open`:void 0}),m=effector.createEvent({name:`${p}.close`,sid:l.sid?`${l.sid}|close`:void 0}),h=effector.createStore(Boolean(0),{name:`${p}.status`,serialize:'ignore'}),y=effector.createStore(null!==(o=null==r?void 0:r.defaultState)&&void 0!==o?o:null,{name:`${p}.state`,sid:null==l?void 0:l.sid});if(y.on(d,((e,t)=>t)),h.on(v,(()=>Boolean(1))).on(m,(()=>Boolean(0))),t.open=v,t.close=m,t.status=h,t.state=y,t.set=d,effector.sample({clock:v,target:d}),y.reset(m),null!=r&&r.domain){let{hooks:e}=r.domain;effector.launch({target:[e.store,e.store,e.event,e.event,e.event],params:[h,y,v,m,d]})}return t},exports.useGate=s,exports.useStore=o=>{effector.is.store(o)||l('expect useStore argument to be a store');let{scope:n}=t(),r=e(o,n),a=i.shallowRef(r),s=effector.createWatch({unit:o,fn:e=>{a.value=i.shallowRef(e).value},scope:n});return i.onUnmounted((()=>{s()})),i.readonly(a)},exports.useStoreMap=(o,n)=>{effector.is.store(o.store)||l('useStoreMap expects a store'),void 0!==o.keys&&'function'!=typeof o.keys&&l('useStoreMap expects keys as a function'),'function'!=typeof o.fn&&l('useStoreMap expects fn as a function');let r=n||t().scope,a=i.computed(o.keys?o.keys:()=>{}),s=o.updateFilter||u,c=e(o.store,r),f="object"==typeof c&&0==Array.isArray(c),p=f?i.shallowReactive(c):i.shallowRef(c),d=effector.createWatch({unit:o.store,fn:e=>{if(f)for(let t in e)s(e[t],p[t])&&(p[t]=e[t]);else void 0!==e&&s(e,p.value)&&(p.value=e)},scope:r});return i.onUnmounted((()=>{d()})),i.computed((()=>{let e=o.fn(f?p:p.value,a.value);return void 0!==e?e:o.defaultValue}))},exports.useUnit=o=>{let{scope:n}=t(),r=effector.is.unit(o),a={};r?a={unit:o}:'@@unitShape'in o?'function'==typeof o['@@unitShape']?a=o['@@unitShape']():l('expect @@unitShape to be a function'):a=o;let s=Array.isArray(a),u=[],c=[];for(let e in a){let t=a[e];effector.is.unit(t)||l('expect useUnit argument to be a unit'),effector.is.event(t)||effector.is.effect(t)?c.push(e):u.push(e)}let f={};for(let t of u){let o=e(a[t],n),r=i.shallowRef(o),s=effector.createWatch({unit:a[t],fn:e=>{r.value=i.shallowRef(e).value},scope:n});f[t]={stop:s,ref:r}}if(i.onUnmounted((()=>{for(let e of Object.values(f))e.stop()})),r&&effector.is.store(o))return i.readonly(f.unit.ref);if(r&&effector.is.event(o))return effector.scopeBind(a.unit,{scope:n,safe:1});let p={};for(let e of c)p[e]=effector.scopeBind(a[e],{scope:n,safe:1});for(let[e,t]of Object.entries(f))p[e]=i.readonly(t.ref);return s?Object.values(p):p},exports.useVModel=e=>{if(effector.is.store(e))return r(e);let t=i.reactive({}),o=Object.fromEntries(Object.entries(e).map((([e,o])=>[e,r(o,e,t)])));for(let e in o)t[e]=o[e];return t};
//# sourceMappingURL=composition.cjs.js.map

@@ -1,43 +0,109 @@

import { Scope } from '@babel/traverse';
import {ComputedRef, DeepReadonly, Ref, UnwrapRef} from '@vue/reactivity'
import {Domain, Store, Event} from 'effector'
import {Domain, Store, Event, Effect, Scope} from 'effector'
type GateConfig<T> = {
name?: string;
defaultState?: T;
domain?: Domain;
sid?: string;
};
name?: string
defaultState?: T
domain?: Domain
sid?: string
}
type Gate<Props> = {
open: Event<Props>;
close: Event<Props>;
status: Store<boolean>;
state: Store<Props>;
set: Event<Props>;
};
open: Event<Props>
close: Event<Props>
status: Store<boolean>
state: Store<Props>
set: Event<Props>
}
type ExtractStore<T extends Record<string, Store<unknown>>> = {
[Key in keyof T]: T[Key] extends Store<infer U> ? Ref<UnwrapRef<U>> : never
}
}
export interface UseVModel {
<T>(vm: Store<T>): Ref<T>
<T extends Record<string, Store<any>>>(vm: T): ExtractStore<T>
}
export interface UseVModel {
<T>(vm: Store<T>): Ref<T>
<T extends Record<string, Store<any>>>(vm: T): ExtractStore<T>
}
export function useStoreMap<State, Result, Keys = unknown>(
config: {
store: Store<State>;
keys?: () => Keys;
fn: (state: State, keys: Keys) => Result;
updateFilter?: (update: Result, current: Result) => boolean;
defaultValue?: Result;
store: Store<State>
keys?: () => Keys
fn: (state: State, keys: Keys) => Result
updateFilter?: (update: Result, current: Result) => boolean
defaultValue?: Result
},
scope?: Scope
scope?: Scope,
): ComputedRef<Result>
export function useVModel<T>(vm: Store<T>): Ref<UnwrapRef<T>>
export function useVModel<T extends Record<string, Store<any>>>(vm: T): ExtractStore<T>
export function useVModel<T extends Record<string, Store<any>>>(
vm: T,
): ExtractStore<T>
export function useStore<T>(store: Store<T>): DeepReadonly<Ref<T>>
export function createGate<Props>(config?: GateConfig<Props>): Gate<Props>
export function useGate<Props>(GateComponent: Gate<Props>, cb?: () => Props): void
export function useGate<Props>(
GateComponent: Gate<Props>,
cb?: () => Props,
): void
export function useUnit<State>(
store: Store<State>,
opts?: {forceScope?: boolean},
): DeepReadonly<Ref<State>>
export function useUnit(
event: Event<void>,
opts?: {forceScope?: boolean},
): () => void
export function useUnit<T>(
event: Event<T>,
opts?: {forceScope?: boolean},
): (payload: T) => T
export function useUnit<R>(
fx: Effect<void, R, any>,
opts?: {forceScope?: boolean},
): () => Promise<R>
export function useUnit<T, R>(
fx: Effect<T, R, any>,
opts?: {forceScope?: boolean},
): (payload: T) => Promise<R>
export function useUnit<
List extends (Event<any> | Effect<any, any> | Store<any>)[],
>(
list: [...List],
opts?: {forceScope?: boolean},
): {
[Key in keyof List]: List[Key] extends Event<infer T>
? Equal<T, void> extends true
? () => void
: (payload: T) => T
: List[Key] extends Effect<infer P, infer D, any>
? Equal<P, void> extends true
? () => Promise<D>
: (payload: P) => Promise<D>
: List[Key] extends Store<infer V>
? DeepReadonly<Ref<V>>
: never
}
export function useUnit<
Shape extends Record<string, Event<any> | Effect<any, any, any> | Store<any>>,
>(
shape: Shape | {'@@unitShape': () => Shape},
opts?: {forceScope?: boolean},
): {
[Key in keyof Shape]: Shape[Key] extends Event<infer T>
? Equal<T, void> extends true
? () => void
: (payload: T) => T
: Shape[Key] extends Effect<infer P, infer D, any>
? Equal<P, void> extends true
? () => Promise<D>
: (payload: P) => Promise<D>
: Shape[Key] extends Store<infer V>
? DeepReadonly<Ref<V>>
: never
}
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y
? 1
: 2
? true
: false

@@ -1,43 +0,109 @@

import { Scope } from '@babel/traverse';
import {ComputedRef, DeepReadonly, Ref, UnwrapRef} from '@vue/reactivity'
import {Domain, Store, Event} from 'effector'
import {Domain, Store, Event, Effect, Scope} from 'effector'
type GateConfig<T> = {
name?: string;
defaultState?: T;
domain?: Domain;
sid?: string;
};
name?: string
defaultState?: T
domain?: Domain
sid?: string
}
type Gate<Props> = {
open: Event<Props>;
close: Event<Props>;
status: Store<boolean>;
state: Store<Props>;
set: Event<Props>;
};
open: Event<Props>
close: Event<Props>
status: Store<boolean>
state: Store<Props>
set: Event<Props>
}
type ExtractStore<T extends Record<string, Store<unknown>>> = {
[Key in keyof T]: T[Key] extends Store<infer U> ? Ref<UnwrapRef<U>> : never
}
}
export interface UseVModel {
<T>(vm: Store<T>): Ref<T>
<T extends Record<string, Store<any>>>(vm: T): ExtractStore<T>
}
export interface UseVModel {
<T>(vm: Store<T>): Ref<T>
<T extends Record<string, Store<any>>>(vm: T): ExtractStore<T>
}
export function useStoreMap<State, Result, Keys = unknown>(
config: {
store: Store<State>;
keys?: () => Keys;
fn: (state: State, keys: Keys) => Result;
updateFilter?: (update: Result, current: Result) => boolean;
defaultValue?: Result;
store: Store<State>
keys?: () => Keys
fn: (state: State, keys: Keys) => Result
updateFilter?: (update: Result, current: Result) => boolean
defaultValue?: Result
},
scope?: Scope
scope?: Scope,
): ComputedRef<Result>
export function useVModel<T>(vm: Store<T>): Ref<UnwrapRef<T>>
export function useVModel<T extends Record<string, Store<any>>>(vm: T): ExtractStore<T>
export function useVModel<T extends Record<string, Store<any>>>(
vm: T,
): ExtractStore<T>
export function useStore<T>(store: Store<T>): DeepReadonly<Ref<T>>
export function createGate<Props>(config?: GateConfig<Props>): Gate<Props>
export function useGate<Props>(GateComponent: Gate<Props>, cb?: () => Props): void
export function useGate<Props>(
GateComponent: Gate<Props>,
cb?: () => Props,
): void
export function useUnit<State>(
store: Store<State>,
opts?: {forceScope?: boolean},
): DeepReadonly<Ref<State>>
export function useUnit(
event: Event<void>,
opts?: {forceScope?: boolean},
): () => void
export function useUnit<T>(
event: Event<T>,
opts?: {forceScope?: boolean},
): (payload: T) => T
export function useUnit<R>(
fx: Effect<void, R, any>,
opts?: {forceScope?: boolean},
): () => Promise<R>
export function useUnit<T, R>(
fx: Effect<T, R, any>,
opts?: {forceScope?: boolean},
): (payload: T) => Promise<R>
export function useUnit<
List extends (Event<any> | Effect<any, any> | Store<any>)[],
>(
list: [...List],
opts?: {forceScope?: boolean},
): {
[Key in keyof List]: List[Key] extends Event<infer T>
? Equal<T, void> extends true
? () => void
: (payload: T) => T
: List[Key] extends Effect<infer P, infer D, any>
? Equal<P, void> extends true
? () => Promise<D>
: (payload: P) => Promise<D>
: List[Key] extends Store<infer V>
? DeepReadonly<Ref<V>>
: never
}
export function useUnit<
Shape extends Record<string, Event<any> | Effect<any, any, any> | Store<any>>,
>(
shape: Shape | {'@@unitShape': () => Shape},
opts?: {forceScope?: boolean},
): {
[Key in keyof Shape]: Shape[Key] extends Event<infer T>
? Equal<T, void> extends true
? () => void
: (payload: T) => T
: Shape[Key] extends Effect<infer P, infer D, any>
? Equal<P, void> extends true
? () => Promise<D>
: (payload: P) => Promise<D>
: Shape[Key] extends Store<infer V>
? DeepReadonly<Ref<V>>
: never
}
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y
? 1
: 2
? true
: false

@@ -1,2 +0,2 @@

import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue'
import Vue, {WatchOptions, VueConstructor} from 'vue'
import {

@@ -7,3 +7,3 @@ ThisTypedComponentOptionsWithArrayProps,

import {ExtendedVue} from 'vue/types/vue'
import {Store, Unit} from 'effector'
import {Scope, Store, Unit} from 'effector'

@@ -13,10 +13,23 @@ type Inference<EffectorState> = EffectorState extends Store<infer State>

: EffectorState extends {[storeName: string]: Store<any>}
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never}
? {
[K in keyof EffectorState]: EffectorState[K] extends Store<infer U>
? U
: never
}
: EffectorState extends Unit<infer State>
? number
: never;
: never
type EffectorType = Store<any> | {[key: string]: Store<any> | Unit<any>} | (() => Store<any> | Unit<any>)
type EffectorType =
| Store<any>
| {[key: string]: Store<any> | Unit<any>}
| (() => Store<any> | Unit<any>)
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State> | Unit<infer State>) | Store<infer State> | Unit<infer State>
type ExpandType<
V extends Vue,
EffectorState extends EffectorType,
> = EffectorState extends
| ((this: V) => Store<infer State> | Unit<infer State>)
| Store<infer State>
| Unit<infer State>
? {state: State}

@@ -34,4 +47,12 @@ : EffectorState extends {[storeName: string]: Store<any> | Unit<any>}

interface VueConstructor<V extends Vue> {
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps<
extend<
EffectorState extends EffectorType,
Data,
Methods,
Computed,
PropNames extends string = never,
>(
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithArrayProps<
ExpandType<V, EffectorState> & V,

@@ -43,5 +64,13 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Record<PropNames, any>
>
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps<
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithRecordProps<
ExpandType<V, EffectorState> & V,

@@ -53,3 +82,9 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Props
>
}

@@ -92,3 +127,3 @@ }

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -110,3 +145,3 @@ options: ThisTypedComponentOptionsWithArrayProps<

Computed,
Props
Props,
>(

@@ -128,3 +163,3 @@ options: ThisTypedComponentOptionsWithRecordProps<

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -140,1 +175,6 @@ options: ThisTypedComponentOptionsWithArrayProps<

): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames>
export function EffectorScopePlugin(config: {
scope: Scope
scopeName?: string
}): Plugin

@@ -1,2 +0,2 @@

function e(e){return e&&'object'==typeof e&&'default'in e?e.default:e}Object.defineProperty(exports,'__esModule',{value:1});var t=require('vue'),effector=require('effector'),o=e(t);const r={beforeCreate(){let e=this.$options.effector;if('function'==typeof e&&(e=e.call(this)),!e)return;this.$options.computed||(this.$options.computed={});let t={};if(effector.is.store(e))t={state:e};else{if('object'!=typeof e)throw Error('property should be Store');t={...e}}this.__clear=effector.createEvent(),effector.withRegion(this.__clear,(()=>{let e={},r=0;for(let o in t){let i=t[o];if(effector.is.store(i))e[o]=i;else{if(!effector.is.event(i)&&!effector.is.effect(i))throw Error(`Effector property ${o} should be Store or Unit (will be transform to Store<number>)`);e[o]=effector.restore(i.map((()=>++r)),null)}}let i=effector.combine(e);for(let e in i.defaultState)o.util.defineReactive(this,e,i.defaultState[e]);i.watch((e=>{for(let t in e)this[t]=e[t]}));for(let t in e){let o=effector.createEvent();effector.sample({clock:o,target:e[t]}),this.$options.computed[t]={get:()=>this[t],set:o}}}))},beforeDestroy(){this.__clear&&effector.clearNode(this.__clear)}};exports.VueEffector=e=>{e.mixin(r)},exports.createComponent=(e,t)=>o.extend(Object.assign({},e,t&&{effector:()=>t}));
function e(e){return e&&'object'==typeof e&&'default'in e?e.default:e}Object.defineProperty(exports,'__esModule',{value:1});var t=require('vue'),effector=require('effector'),o=e(t);const r={beforeCreate(){let e=this.$options.effector;if('function'==typeof e&&(e=e.call(this)),!e)return;this.$options.computed||(this.$options.computed={});let t={};if(effector.is.store(e))t={state:e};else{if('object'!=typeof e)throw Error('property should be Store');t={...e}}this.__clear=effector.createEvent(),effector.withRegion(this.__clear,(()=>{let e={},r=0;for(let o in t){let i=t[o];if(effector.is.store(i))e[o]=i;else{if(!effector.is.event(i)&&!effector.is.effect(i))throw Error(`Effector property ${o} should be Store or Unit (will be transform to Store<number>)`);e[o]=effector.restore(i.map((()=>++r)),null)}}let i=effector.combine(e);for(let e in i.defaultState)o.util.defineReactive(this,e,i.defaultState[e]);i.watch((e=>{for(let t in e)this[t]=e[t]}));for(let t in e){let o=effector.createEvent();effector.sample({clock:o,target:e[t]}),this.$options.computed[t]={get:()=>this[t],set:o}}}))},beforeDestroy(){this.__clear&&effector.clearNode(this.__clear)}};exports.EffectorScopePlugin=e=>({install(t){var o;let r=null!==(o=e.scopeName)&&void 0!==o?o:'root';t.config.globalProperties.scopeName=r,t.provide(t.config.globalProperties.scopeName,e.scope)}}),exports.VueEffector=e=>{e.mixin(r)},exports.createComponent=(e,t)=>o.extend(Object.assign({},e,t&&{effector:()=>t}));
//# sourceMappingURL=effector-vue.cjs.js.map

@@ -1,2 +0,2 @@

import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue'
import Vue, {WatchOptions, VueConstructor} from 'vue'
import {

@@ -7,3 +7,3 @@ ThisTypedComponentOptionsWithArrayProps,

import {ExtendedVue} from 'vue/types/vue'
import {Store, Unit} from 'effector'
import {Scope, Store, Unit} from 'effector'

@@ -13,10 +13,23 @@ type Inference<EffectorState> = EffectorState extends Store<infer State>

: EffectorState extends {[storeName: string]: Store<any>}
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never}
? {
[K in keyof EffectorState]: EffectorState[K] extends Store<infer U>
? U
: never
}
: EffectorState extends Unit<infer State>
? number
: never;
: never
type EffectorType = Store<any> | {[key: string]: Store<any> | Unit<any>} | (() => Store<any> | Unit<any>)
type EffectorType =
| Store<any>
| {[key: string]: Store<any> | Unit<any>}
| (() => Store<any> | Unit<any>)
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State> | Unit<infer State>) | Store<infer State> | Unit<infer State>
type ExpandType<
V extends Vue,
EffectorState extends EffectorType,
> = EffectorState extends
| ((this: V) => Store<infer State> | Unit<infer State>)
| Store<infer State>
| Unit<infer State>
? {state: State}

@@ -34,4 +47,12 @@ : EffectorState extends {[storeName: string]: Store<any> | Unit<any>}

interface VueConstructor<V extends Vue> {
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps<
extend<
EffectorState extends EffectorType,
Data,
Methods,
Computed,
PropNames extends string = never,
>(
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithArrayProps<
ExpandType<V, EffectorState> & V,

@@ -43,5 +64,13 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Record<PropNames, any>
>
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps<
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithRecordProps<
ExpandType<V, EffectorState> & V,

@@ -53,3 +82,9 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Props
>
}

@@ -92,3 +127,3 @@ }

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -110,3 +145,3 @@ options: ThisTypedComponentOptionsWithArrayProps<

Computed,
Props
Props,
>(

@@ -128,3 +163,3 @@ options: ThisTypedComponentOptionsWithRecordProps<

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -140,1 +175,6 @@ options: ThisTypedComponentOptionsWithArrayProps<

): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames>
export function EffectorScopePlugin(config: {
scope: Scope
scopeName?: string
}): Plugin

@@ -1,2 +0,2 @@

import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue'
import Vue, {WatchOptions, VueConstructor} from 'vue'
import {

@@ -7,3 +7,3 @@ ThisTypedComponentOptionsWithArrayProps,

import {ExtendedVue} from 'vue/types/vue'
import {Store, Unit} from 'effector'
import {Scope, Store, Unit} from 'effector'

@@ -13,10 +13,23 @@ type Inference<EffectorState> = EffectorState extends Store<infer State>

: EffectorState extends {[storeName: string]: Store<any>}
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never}
? {
[K in keyof EffectorState]: EffectorState[K] extends Store<infer U>
? U
: never
}
: EffectorState extends Unit<infer State>
? number
: never;
: never
type EffectorType = Store<any> | {[key: string]: Store<any> | Unit<any>} | (() => Store<any> | Unit<any>)
type EffectorType =
| Store<any>
| {[key: string]: Store<any> | Unit<any>}
| (() => Store<any> | Unit<any>)
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State> | Unit<infer State>) | Store<infer State> | Unit<infer State>
type ExpandType<
V extends Vue,
EffectorState extends EffectorType,
> = EffectorState extends
| ((this: V) => Store<infer State> | Unit<infer State>)
| Store<infer State>
| Unit<infer State>
? {state: State}

@@ -34,4 +47,12 @@ : EffectorState extends {[storeName: string]: Store<any> | Unit<any>}

interface VueConstructor<V extends Vue> {
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps<
extend<
EffectorState extends EffectorType,
Data,
Methods,
Computed,
PropNames extends string = never,
>(
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithArrayProps<
ExpandType<V, EffectorState> & V,

@@ -43,5 +64,13 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Record<PropNames, any>
>
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps<
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithRecordProps<
ExpandType<V, EffectorState> & V,

@@ -53,3 +82,9 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Props
>
}

@@ -92,3 +127,3 @@ }

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -110,3 +145,3 @@ options: ThisTypedComponentOptionsWithArrayProps<

Computed,
Props
Props,
>(

@@ -128,3 +163,3 @@ options: ThisTypedComponentOptionsWithRecordProps<

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -140,1 +175,6 @@ options: ThisTypedComponentOptionsWithArrayProps<

): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames>
export function EffectorScopePlugin(config: {
scope: Scope
scopeName?: string
}): Plugin

@@ -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='undefined'!=typeof globalThis?globalThis:e||self).effectorVue={},e.Vue,e.effector)})(this,(function(e,t,effector){function o(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var r=o(t);const i={beforeCreate(){let e=this.$options.effector;if('function'==typeof e&&(e=e.call(this)),!e)return;this.$options.computed||(this.$options.computed={});let t={};if(effector.is.store(e))t={state:e};else{if('object'!=typeof e)throw Error('property should be Store');t={...e}}this.__clear=effector.createEvent(),effector.withRegion(this.__clear,(()=>{let e={},o=0;for(let r in t){let i=t[r];if(effector.is.store(i))e[r]=i;else{if(!effector.is.event(i)&&!effector.is.effect(i))throw Error(`Effector property ${r} should be Store or Unit (will be transform to Store<number>)`);e[r]=effector.restore(i.map((()=>++o)),null)}}let i=effector.combine(e);for(let e in i.defaultState)r.default.util.defineReactive(this,e,i.defaultState[e]);i.watch((e=>{for(let t in e)this[t]=e[t]}));for(let t in e){let o=effector.createEvent();effector.sample({clock:o,target:e[t]}),this.$options.computed[t]={get:()=>this[t],set:o}}}))},beforeDestroy(){this.__clear&&effector.clearNode(this.__clear)}};e.VueEffector=e=>{e.mixin(i)},e.createComponent=(e,t)=>r.default.extend(Object.assign({},e,t&&{effector:()=>t})),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='undefined'!=typeof globalThis?globalThis:e||self).effectorVue={},e.Vue,e.effector)})(this,(function(e,t,effector){function o(e){return e&&'object'==typeof e&&'default'in e?e:{default:e}}var r=o(t);const i={beforeCreate(){let e=this.$options.effector;if('function'==typeof e&&(e=e.call(this)),!e)return;this.$options.computed||(this.$options.computed={});let t={};if(effector.is.store(e))t={state:e};else{if('object'!=typeof e)throw Error('property should be Store');t={...e}}this.__clear=effector.createEvent(),effector.withRegion(this.__clear,(()=>{let e={},o=0;for(let r in t){let i=t[r];if(effector.is.store(i))e[r]=i;else{if(!effector.is.event(i)&&!effector.is.effect(i))throw Error(`Effector property ${r} should be Store or Unit (will be transform to Store<number>)`);e[r]=effector.restore(i.map((()=>++o)),null)}}let i=effector.combine(e);for(let e in i.defaultState)r.default.util.defineReactive(this,e,i.defaultState[e]);i.watch((e=>{for(let t in e)this[t]=e[t]}));for(let t in e){let o=effector.createEvent();effector.sample({clock:o,target:e[t]}),this.$options.computed[t]={get:()=>this[t],set:o}}}))},beforeDestroy(){this.__clear&&effector.clearNode(this.__clear)}};e.EffectorScopePlugin=e=>({install(t){var o;let r=null!==(o=e.scopeName)&&void 0!==o?o:'root';t.config.globalProperties.scopeName=r,t.provide(t.config.globalProperties.scopeName,e.scope)}}),e.VueEffector=e=>{e.mixin(i)},e.createComponent=(e,t)=>r.default.extend(Object.assign({},e,t&&{effector:()=>t})),Object.defineProperty(e,'__esModule',{value:1})}));
//# sourceMappingURL=effector-vue.umd.js.map

@@ -1,2 +0,2 @@

import Vue, {ComponentOptions, WatchOptions, VueConstructor} from 'vue'
import Vue, {WatchOptions, VueConstructor} from 'vue'
import {

@@ -7,3 +7,3 @@ ThisTypedComponentOptionsWithArrayProps,

import {ExtendedVue} from 'vue/types/vue'
import {Store, Unit} from 'effector'
import {Scope, Store, Unit} from 'effector'

@@ -13,10 +13,23 @@ type Inference<EffectorState> = EffectorState extends Store<infer State>

: EffectorState extends {[storeName: string]: Store<any>}
? {[K in keyof EffectorState]: EffectorState[K] extends Store<infer U> ? U : never}
? {
[K in keyof EffectorState]: EffectorState[K] extends Store<infer U>
? U
: never
}
: EffectorState extends Unit<infer State>
? number
: never;
: never
type EffectorType = Store<any> | {[key: string]: Store<any> | Unit<any>} | (() => Store<any> | Unit<any>)
type EffectorType =
| Store<any>
| {[key: string]: Store<any> | Unit<any>}
| (() => Store<any> | Unit<any>)
type ExpandType<V extends Vue, EffectorState extends EffectorType> = EffectorState extends ((this: V) => Store<infer State> | Unit<infer State>) | Store<infer State> | Unit<infer State>
type ExpandType<
V extends Vue,
EffectorState extends EffectorType,
> = EffectorState extends
| ((this: V) => Store<infer State> | Unit<infer State>)
| Store<infer State>
| Unit<infer State>
? {state: State}

@@ -34,4 +47,12 @@ : EffectorState extends {[storeName: string]: Store<any> | Unit<any>}

interface VueConstructor<V extends Vue> {
extend<EffectorState extends EffectorType, Data, Methods, Computed, PropNames extends string = never>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithArrayProps<
extend<
EffectorState extends EffectorType,
Data,
Methods,
Computed,
PropNames extends string = never,
>(
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithArrayProps<
ExpandType<V, EffectorState> & V,

@@ -43,5 +64,13 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Record<PropNames, any>>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Record<PropNames, any>
>
extend<EffectorState extends EffectorType, Data, Methods, Computed, Props>(
options?: {effector?: EffectorState} & ThisTypedComponentOptionsWithRecordProps<
options?: {
effector?: EffectorState
} & ThisTypedComponentOptionsWithRecordProps<
ExpandType<V, EffectorState> & V,

@@ -53,3 +82,9 @@ Data,

>,
): ExtendedVue<ExpandType<V, EffectorState> & V, Data, Methods, Computed, Props>
): ExtendedVue<
ExpandType<V, EffectorState> & V,
Data,
Methods,
Computed,
Props
>
}

@@ -92,3 +127,3 @@ }

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -110,3 +145,3 @@ options: ThisTypedComponentOptionsWithArrayProps<

Computed,
Props
Props,
>(

@@ -128,3 +163,3 @@ options: ThisTypedComponentOptionsWithRecordProps<

Computed,
PropNames extends string
PropNames extends string,
>(

@@ -140,1 +175,6 @@ options: ThisTypedComponentOptionsWithArrayProps<

): ExtendedVue<Inference<S> & V, Data, Methods, Computed, PropNames>
export function EffectorScopePlugin(config: {
scope: Scope
scopeName?: string
}): Plugin
{
"name": "effector-vue",
"version": "23.0.0-rc.4",
"version": "23.0.0-rc.5",
"description": "Vue bindings for effector",

@@ -5,0 +5,0 @@ "main": "effector-vue.cjs.js",

@@ -1,5 +0,8 @@

import {Plugin} from 'vue';
import {Scope, Event} from 'effector';
import {Plugin} from 'vue'
import {Scope, Event} from 'effector'
/** @deprecated since v23.0.0 */
export function VueSSRPlugin(config: {scope: Scope; scopeName?: string}): Plugin
/** @deprecated since v23.0.0 */
export function useEvent<T>(event: Event<T>): (payload: T) => void

@@ -1,2 +0,2 @@

Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector'),e=require('vue');exports.VueSSRPlugin=e=>({install(o){var r;let t=null!==(r=e.scopeName)&&void 0!==r?r:"root";o.config.globalProperties.scopeName=t,o.provide(o.config.globalProperties.scopeName,e.scope)}}),exports.useEvent=o=>{let{scope:r}=(()=>{let o,r=e.getCurrentInstance(),t=null==r?void 0:r.appContext.config.globalProperties.scopeName;return t&&(o=e.inject(t)),{scopeName:t,scope:o}})();return r?effector.scopeBind(o,{scope:r}):o};
Object.defineProperty(exports,'__esModule',{value:1});var effector=require('effector'),e=require('vue');exports.VueSSRPlugin=e=>(console.error('VueSSRPlugin from effector-vue/ssr is deprecated, use EffectorScopePlugin from effector-vue instead'),{install(o){var r;let s=null!==(r=e.scopeName)&&void 0!==r?r:'root';o.config.globalProperties.scopeName=s,o.provide(o.config.globalProperties.scopeName,e.scope)}}),exports.useEvent=o=>{console.error('useEvent from effector-vue/ssr is deprecated, use useUnit from effector-vue/composition instead');let{scope:r}=(()=>{let o,r=e.getCurrentInstance(),s=null==r?void 0:r.appContext.config.globalProperties.scopeName;return s&&(o=e.inject(s)),{scopeName:s,scope:o}})();return r?effector.scopeBind(o,{scope:r}):o};
//# sourceMappingURL=ssr.cjs.js.map

@@ -1,5 +0,8 @@

import {Plugin} from 'vue';
import {Scope, Event} from 'effector';
import {Plugin} from 'vue'
import {Scope, Event} from 'effector'
/** @deprecated since v23.0.0 */
export function VueSSRPlugin(config: {scope: Scope; scopeName?: string}): Plugin
/** @deprecated since v23.0.0 */
export function useEvent<T>(event: Event<T>): (payload: T) => void

@@ -1,5 +0,8 @@

import {Plugin} from 'vue';
import {Scope, Event} from 'effector';
import {Plugin} from 'vue'
import {Scope, Event} from 'effector'
/** @deprecated since v23.0.0 */
export function VueSSRPlugin(config: {scope: Scope; scopeName?: string}): Plugin
/** @deprecated since v23.0.0 */
export function useEvent<T>(event: Event<T>): (payload: T) => void

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc