{"version":3,"file":"composition.mjs","sources":["effector-vue/lib/state-reader.ts","effector-vue/lib/get-scope.ts","effector-vue/useStore.ts","effector-vue/lib/deepCopy.ts","effector-vue/useVModel.ts","effector-vue/useStoreMap.ts","effector-vue/lib/unwrapProxy.ts","effector-vue/../effector/config.ts","effector-vue/../effector/is.ts","effector-vue/../effector/throw.ts","effector-vue/createGate.ts","effector-vue/useUnit.ts","effector-vue/EffectorScopePlugin.ts","effector-vue/lib/throw.ts","effector-vue/../effector/collection.ts"],"sourcesContent":["import {Scope, Store} from \"effector\"\n\nexport function stateReader<T>(store: Store<T>, scope?: Scope) {\n  return scope ? scope.getState(store) : store.getState()\n}\n","import {Scope} from 'effector'\nimport {getCurrentInstance, inject} from 'vue-next'\n\nexport function getScope() {\n  let scope: Scope | undefined\n  let ctx = getCurrentInstance()\n  let scopeName: string | undefined =\n    ctx?.appContext.config.globalProperties.scopeName\n\n  if (scopeName) {\n    scope = inject(scopeName)\n  }\n\n  return {\n    scopeName,\n    scope,\n  }\n}\n","import {is, createWatch, Store} from 'effector'\nimport {onUnmounted, readonly, shallowRef} from 'vue-next'\n\nimport {stateReader} from './lib/state-reader'\nimport {getScope} from './lib/get-scope'\nimport {throwError} from './lib/throw'\n\nexport function useStore<T>(store: Store<T>) {\n  if (!is.store(store)) throwError('expect useStore argument to be a store')\n  let {scope} = getScope()\n\n  let state = stateReader(store, scope)\n  let _ = shallowRef(state)\n\n  let stop = createWatch({\n    unit: store,\n    fn: value => {\n      _.value = shallowRef(value).value\n    },\n    scope,\n  })\n\n  onUnmounted(() => {\n    stop()\n  })\n\n  return readonly(_)\n}\n","// @ts-nocheck\nexport function deepCopy<T>(obj, cache = new Map()): T {\n  if (obj === null || typeof obj !== 'object') {\n    return obj\n  }\n\n  if (obj instanceof Date) {\n    return obj\n  }\n\n  const hit = cache.get(obj)\n\n  if (hit) {\n    return hit\n  }\n\n  const copy = Array.isArray(obj) ? [] : {}\n  cache.set(obj, copy)\n\n  for (const key of Object.keys(obj)) {\n    copy[key] = deepCopy(obj[key], cache)\n  }\n\n  return copy\n}\n","import {Store, is, createWatch} from 'effector'\nimport {type EffectScope, reactive, ref, watch, effectScope, onScopeDispose, toRaw, Reactive} from 'vue-next'\n\nimport {deepCopy} from './lib/deepCopy'\nimport {stateReader} from './lib/state-reader'\nimport {getScope} from './lib/get-scope'\nimport {UseVModel} from 'effector-vue/composition'\n\nfunction createVModel<T>(\n  store: Store<T>,\n  key?: string,\n  shape?: Record<string, unknown>,\n) {\n  if (!is.store(store)) throw Error('expect useVModel argument to be a store')\n\n  const {scope} = getScope()\n\n  const _ = ref(deepCopy(stateReader(store, scope)))\n\n  let isSelfUpdate = false\n  let fromEvent = false\n\n  const stop = createWatch({\n    unit: store,\n    fn: payload => {\n      if (isSelfUpdate) {\n        return\n      }\n\n      fromEvent = true\n      _.value = deepCopy(payload)\n    },\n    scope,\n  })\n\n  onScopeDispose(() => {\n    stop()\n  })\n\n  const watchFn = () => {\n    if (key && shape) {\n      return shape[key]\n    }\n    return _.value\n  }\n\n  watch(\n    watchFn,\n    value => {\n      isSelfUpdate = true\n\n      if (!fromEvent) {\n        // @ts-ignore\n        store.setState(deepCopy(toRaw(value)))\n      }\n\n      fromEvent = false\n      isSelfUpdate = false\n    },\n    /**\n     * `Boolean(true)` survives the build. A bare `true` ships as `1`, and Vue\n     * 3.5 reads a numeric `deep` as the depth to traverse.\n     */\n    {deep: Boolean(true)}\n  )\n\n  return _\n}\n\n// @ts-expect-error\nexport const useVModel: UseVModel = <\n  T,\n  K extends string = keyof Store<unknown>,\n>(\n  vm: Store<T> | Record<K, Store<T>>,\n  scope?: EffectScope\n) => {\n  const vueScope = scope || effectScope()\n\n  return vueScope.run(() => {\n    const _ = reactive({}) as Reactive<Record<string, unknown>>\n\n    if (is.store(vm)) {\n      return createVModel(vm)\n    }\n\n    const shape = Object.fromEntries(\n      Object.entries<Store<T>>(vm).map(([key, value]) => [\n        key,\n        createVModel(value, key, _)\n      ]),\n    )\n\n    for (const key in shape) {\n      _[key] = shape[key]\n    }\n\n    return _\n  })\n}\n","import { createWatch, is, Scope, Store } from \"effector\";\nimport { computed, onUnmounted, shallowReactive, shallowRef } from \"vue-next\";\nimport { getScope } from \"./lib/get-scope\";\nimport { stateReader } from \"./lib/state-reader\";\nimport { throwError } from \"./lib/throw\";\n\nconst basicUpdateFilter = <T>(upd: T, oldValue: T) => upd !== oldValue\n\nexport function useStoreMap<State, Result, Keys = unknown>(\n  config: {\n    store: Store<State>;\n    keys?: () => Keys;\n    fn: (state: State, keys: Keys) => Result;\n    updateFilter?: (update: Result, current: Result) => boolean;\n    defaultValue?: Result;\n  },\n  scope?: Scope\n) {\n  if (!is.store(config.store)) throwError('useStoreMap expects a store')\n  if (config.keys !== undefined && typeof config.keys !== 'function') throwError('useStoreMap expects keys as a function')\n  if (typeof config.fn !== 'function') throwError('useStoreMap expects fn as a function')\n\n\n  let _scope = scope || getScope().scope\n  let keys = config.keys ? computed(config.keys) : computed(() => undefined as Keys)\n  let updateFilter = config.updateFilter || basicUpdateFilter;\n\n  let state = stateReader(config.store, _scope)\n  let isShape = typeof state === \"object\" && Array.isArray(state) === false\n\n  let _ = isShape ? shallowReactive(state as any) : shallowRef(state)\n\n  let stop = createWatch({\n    unit: config.store,\n    fn: (value) => {\n      if (isShape) {\n        for (let key in value) {\n          if (updateFilter(value[key] as Result, _[key])) {\n            _[key] = value[key]\n          }\n        }\n      } else {\n        if (value !== undefined && updateFilter(value as unknown as Result, _.value)) {\n          _.value = value\n        }\n      }\n    },\n    scope: _scope\n  })\n\n  onUnmounted(() => {\n    stop()\n  })\n\n  return computed(() => {\n    let result = config.fn(isShape ? _ : _.value, keys.value)\n    return result !== undefined ? result : config.defaultValue\n  })\n}\n","import {isReactive, toRaw, unref} from 'vue-next'\n\nexport function unwrapProxy<T>(payload: T) {\n  const data = unref(payload)\n  const raw = isReactive(data) ? toRaw(data) : data\n  return raw\n}\n","import {forIn} from './collection'\nimport {assertObject, isObject, isVoid} from './is'\n\nexport function processArgsToConfig(\n  arg: any,\n  singleArgument: true,\n): [any, any | void]\nexport function processArgsToConfig(args: any[]): [any[], any | void]\nexport function processArgsToConfig(\n  args: any[],\n  singleArgument?: boolean,\n): [any[], any | void] {\n  const rawConfig = singleArgument ? args : args[0]\n  assertObject(rawConfig)\n  let metadata = rawConfig.or\n  const childConfig = rawConfig.and\n  if (childConfig) {\n    const unwrappedNestedValue = singleArgument ? childConfig : childConfig[0]\n    /**\n     * if there is no \"and\" field then we reached the leaf of the tree\n     * and this is an original user-defined argument\n     *\n     * note that in this case we're returning all arguments, not the only one been unwrapped\n     **/\n    if (!isObject(unwrappedNestedValue) || !('and' in unwrappedNestedValue)) {\n      args = childConfig\n    } else {\n      //@ts-expect-error\n      const nested = processArgsToConfig(childConfig, singleArgument)\n\n      args = nested[0]\n      metadata = {...metadata, ...nested[1]}\n    }\n  }\n  return [args, metadata]\n}\n\n/**\nprocessed fields:\n\n'name',\n'sid',\n'loc',\n'handler',\n'updateFilter',\n'parent',\n'serialize',\n'named',\n'derived',\n*/\nexport const flattenConfig = (part: any, config: Record<string, any> = {}) => {\n  if (isObject(part)) {\n    flattenConfig(part.or, config)\n    forIn(part, (value, field) => {\n      if (!isVoid(value) && field !== 'or' && field !== 'and') {\n        config[field] = value\n      }\n    })\n    flattenConfig(part.and, config)\n  }\n  return config\n}\n","export * as is from './validate'\nimport {forEach} from './collection'\nimport {assert} from './throw'\nimport {arrifyNodes} from './createNode'\nimport type {NodeUnit} from './index.h'\nimport type {DataCarrier} from './unit.h'\nimport {getMeta} from './getter'\n\nexport const isObject = (value: unknown): value is Record<any, any> =>\n  typeof value === 'object' && value !== null\nexport const isFunction = (value: unknown): value is Function =>\n  typeof value === 'function'\n\nexport const isVoid = (value: unknown): value is void => value === undefined\n\nexport const assertObject = (value: unknown) =>\n  assert(\n    isObject(value) || isFunction(value),\n    'expect first argument be an object',\n  ) // or function\n\nconst assertNodeSetItem = (\n  value: unknown,\n  method: string,\n  valueName: string,\n  reason: string,\n): asserts value is DataCarrier =>\n  assert(\n    !(\n      (!isObject(value) && !isFunction(value)) ||\n      (!('family' in value) && !('graphite' in value))\n    ),\n    `${method}: expect ${valueName} to be a unit (store, event or effect)${reason}`,\n  )\n\nexport const assertNodeSet = (\n  value: unknown,\n  method: string,\n  valueName: string,\n) => {\n  if (Array.isArray(value)) {\n    forEach(value, (item, i) =>\n      assertNodeSetItem(item, method, `${i} item of ${valueName}`, ''),\n    )\n  } else {\n    //@ts-expect-error some ts assertion edge case\n    assertNodeSetItem(value, method, valueName, ' or array of units')\n  }\n}\n\nexport const assertTarget = (\n  method: string,\n  target: NodeUnit | NodeUnit[],\n  targetField: string = 'target',\n) =>\n  forEach(arrifyNodes(target), item =>\n    assert(\n      !getMeta(item, 'derived'),\n      `${method}: derived unit in \"${targetField}\" is not supported, use createStore/createEvent instead\"`,\n    ),\n  )\n","import {getMeta} from './getter'\nimport {Node} from './index.h'\n\nexport function assert(\n  condition: unknown,\n  message: string,\n  errorTitle?: string,\n): asserts condition {\n  if (!condition)\n    throw Error(`${errorTitle ? errorTitle + ': ' : ''}${message}`)\n}\n\nexport const deprecate = (\n  condition: unknown,\n  subject: string,\n  suggestion?: string,\n  errorTitle?: string,\n) =>\n  !condition &&\n  console.error(\n    `${errorTitle ? errorTitle + ': ' : ''}${subject} is deprecated${\n      suggestion ? `, use ${suggestion} instead` : ''\n    }`,\n  )\n\nexport const printErrorWithNodeDetails = (message: string, node: Node) => {\n  const stack = getMeta(node, 'unitTrace')\n  const config = getMeta(node, 'config')\n  const locString = config?.loc\n    ? ` at ${config.loc.file}`\n    : null\n  const name = config?.name\n\n  let finalMessage = message\n  if (name) {\n    finalMessage = `${name}: ${message}`\n  }\n  if (locString) {\n    finalMessage = `${name}${locString}: ${message}`\n  }\n\n  const error = Error(finalMessage)\n\n  if (stack) {\n    error.stack = stack\n  }\n\n  if (!stack && !name && !locString) {\n    console.log(\n      `Add effector's Babel or SWC plugin to your config for more detailed debug information or \"import \"effector/enable_debug_traces\" to your code entry module to see full stack traces`,\n    )\n  }\n  console.error(error)\n}\n","import {\n  computed,\n  ComputedRef,\n  onMounted,\n  onUnmounted,\n  watch,\n  WatchStopHandle,\n} from 'vue-next'\nimport {createApi, launch, createStore, createEvent, sample} from 'effector'\nimport {Gate, GateConfig} from './composition.h'\nimport {deepCopy} from './lib/deepCopy'\nimport {unwrapProxy} from './lib/unwrapProxy'\nimport {flattenConfig, processArgsToConfig} from '../effector/config'\nimport {isObject} from '../effector/is'\n\nexport function useGate<Props>(GateComponent: Gate<Props>, cb?: () => Props) {\n  let unwatch: WatchStopHandle\n  let _: ComputedRef<Props>\n\n  if (cb) {\n    _ = computed(cb)\n\n    unwatch = watch(\n      _,\n      value => {\n        const raw = unwrapProxy(value)\n        GateComponent.set(deepCopy(raw))\n      },\n      {\n        /**\n         * `Boolean(true)` survives the build. A bare `true` ships as `1`, and Vue\n         * 3.5 reads a numeric `deep` as the depth to traverse.\n         */\n        deep: Boolean(true),\n        immediate: true,\n      },\n    )\n  }\n\n  onMounted(() => {\n    if (typeof _ !== \"undefined\") {\n      const raw = unwrapProxy(_.value)\n      GateComponent.open(deepCopy(raw))\n    } else {\n      GateComponent.open()\n    }\n  })\n\n  onUnmounted(() => {\n    if (typeof _ !== \"undefined\") {\n      const raw = unwrapProxy(_.value)\n      GateComponent.close(deepCopy(raw))\n    } else {\n      GateComponent.close()\n    }\n\n    if (unwatch) {\n      unwatch()\n    }\n  })\n}\n\nexport function isStructuredConfig(args: unknown) {\n  return isObject(args) && (args.and || args.or)\n}\n\nexport function createGate<Props>(...args: [GateConfig<Props>]): Gate<Props> {\n  const universalConfig =\n    args && isStructuredConfig(args[0]) ? args : [{and: args}]\n\n  const [[rawConfig], metadata] = processArgsToConfig(universalConfig)\n  const config = flattenConfig({\n    or: metadata,\n    and: rawConfig,\n  }) as {sid: string | undefined; name: string | undefined}\n  const name = config?.name || 'gate'\n  const domain = rawConfig?.domain\n\n  const fullName = `${domain ? `${domain.compositeName.fullName}/` : ''}${name}`\n  const set = createEvent<Props>({\n    name: `${fullName}.set`,\n    sid: config.sid ? `${config.sid}|set` : undefined,\n  })\n  const open = createEvent<Props>({\n    name: `${fullName}.open`,\n    sid: config.sid ? `${config.sid}|open` : undefined,\n  })\n  const close = createEvent<Props>({\n    name: `${fullName}.close`,\n    sid: config.sid ? `${config.sid}|close` : undefined,\n  })\n  const status = createStore(Boolean(false), {\n    name: `${fullName}.status`,\n    serialize: 'ignore',\n    // doesn't need to have sid, because it is internal store, should not be serialized\n  })\n  const state = createStore<Props>(rawConfig?.defaultState ?? null, {\n    name: `${fullName}.state`,\n    sid: config?.sid,\n  })\n\n  state.on(set, (_, state) => state)\n  status.on(open, () => Boolean(true)).on(close, () => Boolean(false))\n\n  function GateComponent(props: Props) {\n    useGate(GateComponent as any, () => props)\n  }\n\n  GateComponent.open = open\n  GateComponent.close = close\n  GateComponent.status = status\n  GateComponent.state = state\n  GateComponent.set = set\n\n  sample({ clock: open, target: set })\n\n  state.reset(close)\n\n  if (rawConfig?.domain) {\n    const {hooks} = rawConfig.domain\n    launch({\n      target: [\n        hooks.store,\n        hooks.store,\n        hooks.event,\n        hooks.event,\n        hooks.event,\n      ] as any,\n      params: [status, state, open, close, set],\n    })\n  }\n\n  // @ts-ignore\n  return GateComponent\n}\n","import {is, createWatch, Unit, scopeBind} from 'effector'\nimport {onUnmounted, readonly, shallowRef} from 'vue-next'\n\nimport {stateReader} from './lib/state-reader'\nimport {getScope} from './lib/get-scope'\nimport {throwError} from './lib/throw'\n\nexport function useUnit<Shape extends {[key: string]: Unit<any>}>(\n  config: Shape | {'@@unitShape': () => Shape},\n) {\n  const {scope} = getScope()\n\n  const isSingleUnit = is.unit(config)\n\n  let normShape: {[key: string]: Unit<any>} = {}\n  if (isSingleUnit) {\n    normShape = {unit: config}\n  } else if ('@@unitShape' in config) {\n    if (typeof config['@@unitShape'] === 'function') {\n      normShape = config['@@unitShape']()\n    } else {\n      throwError('expect @@unitShape to be a function')\n    }\n  } else {\n    normShape = config\n  }\n\n  const isList = Array.isArray(normShape)\n\n  const storeKeys: string[] = []\n  const eventKeys: string[] = []\n\n  for (const key in normShape) {\n    const unit = normShape[key]\n    if (!is.unit(unit)) throwError('expect useUnit argument to be a unit')\n    if (is.event(unit) || is.effect(unit)) {\n      eventKeys.push(key)\n    } else {\n      storeKeys.push(key)\n    }\n  }\n\n  const states: Record<string, any> = {}\n  for (const key of storeKeys) {\n    // @ts-expect-error TS can't infer that normShape[key] is a Store\n    const state = stateReader(normShape[key], scope)\n    const ref = shallowRef(state)\n    const stop = createWatch({\n      unit: normShape[key],\n      fn: value => {\n        ref.value = shallowRef(value).value\n      },\n      scope,\n    })\n\n    states[key] = {\n      stop,\n      ref,\n    }\n  }\n\n  onUnmounted(() => {\n    for (const val of Object.values(states)) {\n      val.stop()\n    }\n  })\n\n  if (isSingleUnit && is.store(config)) {\n    return readonly(states.unit.ref)\n  }\n\n  if (isSingleUnit && (is.event(config) || is.effect(config))) {\n    // @ts-expect-error TS can't infer that normShape.unit is a Effect/Event\n    return scopeBind(normShape.unit, {scope, safe: true})\n  }\n\n  const result: Record<string, any> = {}\n\n  for (const key of eventKeys) {\n    // @ts-expect-error TS can't infer that normShape[key] is a Effect/Event\n    result[key] = scopeBind(normShape[key], {scope, safe: true})\n  }\n  for (const [key, value] of Object.entries(states)) {\n    result[key] = readonly(value.ref)\n  }\n\n  if (isList) {\n    return Object.values(result)\n  }\n\n  return result\n}\n","import {Scope} from 'effector'\nimport {Plugin} from 'vue-next'\n\nexport function EffectorScopePlugin(options: {\n  scope: Scope\n  scopeName?: string\n}): Plugin {\n  return {\n    install(app) {\n      let scopeName = options.scopeName ?? 'root'\n\n      app.config.globalProperties.scopeName = scopeName\n      app.provide(app.config.globalProperties.scopeName, options.scope)\n    },\n  }\n}\n","export const throwError = (message: string) => {\n  throw Error(message)\n}\n","export function forIn<T, Key extends string = string>(\n  obj: Record<Key, T>,\n  cb: (value: T, key: Key) => void,\n) {\n  for (const key in obj) {\n    cb(obj[key], key)\n  }\n}\n\nexport const includes = <T>(list: T[], item: T) => list.includes(item)\n\nexport const removeItem = <T>(list: T[], item: T) => {\n  const pos = list.indexOf(item)\n  if (pos !== -1) {\n    list.splice(pos, 1)\n  }\n}\n\nexport const add = <T>(list: T[], item: T) => list.push(item)\n\nexport function forEach<T>(\n  list: T[],\n  fn: (item: T, index: number, list: T[]) => void,\n): void\nexport function forEach<K, T>(\n  list: Map<K, T>,\n  fn: (item: T, key: K) => void,\n): void\nexport function forEach<T>(list: Set<T>, fn: (item: T) => void): void\nexport function forEach(list: any, fn: Function) {\n  list.forEach(fn)\n}\n"],"names":["stateReader","store","scope","getState","getScope","ctx","getCurrentInstance","scopeName","appContext","config","globalProperties","inject","useStore","is","throwError","state","_","shallowRef","stop","createWatch","unit","fn","value","onUnmounted","readonly","deepCopy","obj","cache","Map","Date","hit","get","copy","Array","isArray","set","key","Object","keys","createVModel","shape","Error","ref","isSelfUpdate","fromEvent","payload","onScopeDispose","watch","watchFn","setState","toRaw","deep","Boolean","useStoreMap","undefined","_scope","computed","updateFilter","basicUpdateFilter","isShape","shallowReactive","result","defaultValue","unwrapProxy","data","unref","isReactive","processArgsToConfig","args","rawConfig","condition","assert","isObject","isFunction","metadata","or","childConfig","and","unwrappedNestedValue","nested","useGate","GateComponent","cb","unwatch","raw","immediate","onMounted","open","close","createGate","props","_rawConfig$defaultSta","universalConfig","isStructuredConfig","flattenConfig","domain","fullName","compositeName","name","createEvent","sid","status","createStore","serialize","defaultState","on","sample","clock","target","reset","hooks","launch","event","params","useUnit","isSingleUnit","normShape","isList","storeKeys","eventKeys","effect","push","states","val","values","scopeBind","safe","entries","EffectorScopePlugin","options","install","app","_options$scopeName","provide","message","useVModel","vm","effectScope","run","reactive","fromEntries","map","upd","oldValue","part","forIn","field","isVoid"],"mappings":"AAEO,SAASA,EAAeC,EAAiBC,GAC9C,OAAOA,EAAQA,EAAMC,SAASF,GAASA,EAAME,UAC/C,CC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