{"version":3,"file":"wana.mjs","sources":["../src/ui/useDerived.ts","../src/ui/useO.ts","../src/ui/common.ts","../src/ui/useAuto.ts","../src/ui/withAuto.tsx","../src/ui/useEffects.tsx","../src/ui/useBinding.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { useLayoutEffect } from 'react-layout-effect'\nimport { emptyArray, Falsy } from '../common'\nimport { derive, Derived } from '../derive'\nimport { mountAuto } from '../mountAuto'\n\n/**\n * Create an observable getter that is managed by React.\n * This lets you memoize an expensive combination of observable values.\n *\n * If the `compute` argument changes over the course of a component's lifetime,\n * its value should be added to the `deps` array.\n *\n * When `deps` are changed, the derived state is reset. This is useful when\n * the `compute` function is using a variable from another function scope.\n */\nexport function useDerived<T>(\n  compute: () => T,\n  deps?: readonly any[]\n): Derived<T>\n\nexport function useDerived<T>(\n  compute: (() => T) | Falsy,\n  deps?: readonly any[]\n): Derived<T> | null\n\nexport function useDerived<T>(\n  compute: () => T,\n  discard: (memo: T, oldMemo: T | undefined) => boolean,\n  deps?: readonly any[]\n): Derived<T>\n\nexport function useDerived<T>(\n  compute: (() => T) | Falsy,\n  discard: (memo: T, oldMemo: T | undefined) => boolean,\n  deps?: readonly any[]\n): Derived<T> | null\n\nexport function useDerived<T>(\n  compute: (() => T) | Falsy,\n  discardOrDeps?:\n    | ((memo: T, oldMemo: T | undefined) => boolean)\n    | readonly any[],\n  deps?: readonly any[]\n) {\n  let discard: ((memo: T, oldMemo: T | undefined) => boolean) | undefined\n  if (typeof discardOrDeps == 'function') {\n    discard = discardOrDeps\n  } else {\n    deps = discardOrDeps\n  }\n\n  const [derived, setState] = useMemo(() => {\n    if (!compute) {\n      return [null, null]\n    }\n    const derived = derive(auto => {\n      const observer = auto.start(compute)\n      try {\n        var result = compute()\n      } finally {\n        auto.stop()\n      }\n      setState({ observer })\n      return result\n    }, discard)\n    const setState = mountAuto(derived.auto)\n    return [derived, setState]\n  }, deps || emptyArray)\n\n  useLayoutEffect(() => {\n    if (setState) {\n      setState({ mounted: true })\n      return () => setState({ mounted: false })\n    }\n  }, [setState])\n\n  return derived\n}\n","import { is } from '@alloc/is'\nimport { useMemoOne as useMemo } from 'use-memo-one'\nimport { emptyArray, getOwnDescriptor } from '../common'\nimport { Derived, isDerived, WithDerived } from '../derive'\nimport { noto } from '../noto'\nimport { o } from '../o'\nimport { useDerived } from './useDerived'\n\nexport function useO<T extends object>(\n  state: Exclude<T, Function>,\n  deps?: readonly any[]\n): WithDerived<T>\n\n/**\n * Create an observable getter that is managed by React.\n * This lets you memoize an expensive combination of observable values.\n */\nexport function useO<T>(\n  create: () => () => T,\n  deps?: readonly any[]\n): Derived<T>\n\n/** Create observable component state. */\nexport function useO<T>(\n  create: () => Exclude<T, Function>,\n  deps?: readonly any[]\n): T\n\n/** Memoize an object and return its observable proxy. Non-objects are returned as-is. */\nexport function useO<T>(state: T, deps?: readonly any[]): T\n\n/** @internal */\nexport function useO(state: any, deps?: readonly any[]) {\n  const result = useMemo<any>(\n    () => convertDerived(is.function(state) ? noto(state) : state),\n    deps || emptyArray\n  )\n  // Beware: Never switch between observable getter and observable object.\n  return is.function(result) ? useDerived(result, [result]) : o(result)\n}\n\n// Convert observable getters into property getters.\n// This is *not* responsible for disposal.\nfunction convertDerived(state: any) {\n  if (is.plainObject(state)) {\n    for (const key in state) {\n      const desc = getOwnDescriptor(state, key)!\n      if (isDerived(desc.value) && desc.configurable) {\n        Object.defineProperty(state, key, {\n          get: desc.value,\n        })\n      }\n    }\n  }\n  return state\n}\n","import { useEffect, useMemo, useState } from 'react'\nimport { useMemoOne } from 'use-memo-one'\nimport { emptyArray } from '../common'\n\n/** This lets a component determine if its render has been reconciled. */\nexport const RenderAction = ({ useAction }: { useAction: () => void }) => (\n  useAction(), null\n)\n\n/** Return a function that re-renders this component, if still mounted */\nexport function useForceUpdate() {\n  const update = useState<any>()[1]\n  const mounted = useMemo(makeMountedRef, [])\n  useEffect(mounted.unmount, emptyArray)\n  return () => {\n    if (mounted.current) {\n      update({})\n    }\n  }\n}\n\nfunction makeMountedRef() {\n  const mounted = {\n    current: true,\n    unmount: () => () => {\n      mounted.current = false\n    },\n  }\n  return mounted\n}\n\nexport const useConstant = <T>(create: () => T) =>\n  useMemoOne(create, emptyArray)\n\nexport const useDispose = (dispose: () => void) =>\n  useEffect(() => dispose, emptyArray)\n","import { is } from '@alloc/is'\nimport { useEffect } from 'react'\nimport { batchedUpdates } from 'react-batched-updates'\nimport { Auto } from '../auto'\nimport { no } from '../no'\nimport { useConstant, useDispose } from './common'\nimport { useDerived } from './useDerived'\n\ntype Deps = readonly any[]\ntype EffectReturn = void | (() => void | undefined)\n\n/** Wrap a `useEffect` call with magic observable tracking */\nexport function useAuto(effect: () => EffectReturn, deps?: readonly any[]): Auto\n\n/**\n * Combine a `useEffect` call with an `Auto` instance that invokes an\n * unobserved side `effect` when the `compute` function returns a new value.\n */\nexport function useAuto<T>(\n  compute: () => T,\n  effect: (value: T) => EffectReturn,\n  deps?: readonly any[]\n): Auto\n\n/** @internal */\nexport function useAuto(\n  computeOrEffect: () => unknown,\n  effectOrDeps?: Function | Deps,\n  deps?: Deps\n) {\n  const auto = useConstant(() => new Auto())\n  useDispose(() => auto.dispose())\n\n  let effect: () => EffectReturn\n  if (is.function(effectOrDeps)) {\n    const compute = useDerived(computeOrEffect, deps)\n    effect = () => no(effectOrDeps as any)(compute())\n  } else {\n    effect = computeOrEffect as any\n    deps = effectOrDeps as any\n  }\n\n  useEffect(\n    () =>\n      batchedUpdates(() => {\n        auto.run(effect)\n      }),\n    deps\n  )\n  return auto\n}\n","import { isDev } from '@alloc/is-dev'\nimport * as React from 'react'\nimport { forwardRef, ReactElement, Ref, RefAttributes, useMemo } from 'react'\nimport { useLayoutEffect } from 'react-layout-effect'\nimport { Auto, AutoObserver } from '../auto'\nimport { batch } from '../batch'\nimport { addDebugAction, getDebug, setDebug } from '../debug'\nimport { globals } from '../globals'\nimport { AutoDepth, useAutoDepth } from './context'\nimport { RenderAction, useDispose, useForceUpdate } from './common'\n\ninterface Component<P = any> {\n  (props: P): ReactElement | null\n  displayName?: string\n}\n\ninterface RefForwardingComponent<T = any, P = any> {\n  (props: P, ref: Ref<T>): ReactElement | null\n  displayName?: string\n}\n\ntype RefForwardingAuto<T extends RefForwardingComponent> = T &\n  ((\n    props: T extends RefForwardingComponent<infer U, infer P>\n      ? P & RefAttributes<U>\n      : never\n  ) => ReactElement | null)\n\n/** Wrap a component with magic observable tracking */\nexport function withAuto<T extends Component>(render: T): T\n\n/** Wrap a component with `forwardRef` and magic observable tracking */\nexport function withAuto<T extends RefForwardingComponent>(\n  render: T\n): RefForwardingAuto<T>\n\n/** @internal */\nexport function withAuto(render: any) {\n  let component: React.FunctionComponent<any> = (props, ref) => {\n    const { auto, depth, commit } = useAutoRender(component)\n\n    // Subscribe to observables as early as possible, because\n    // we don't want effects to trigger the previous observer.\n    useLayoutEffect(() => commit(observer, nonce))\n\n    // Track which observable state is used during render.\n    const observer = auto.start(render)\n    try {\n      var content = render(props, ref)\n    } finally {\n      auto.stop()\n    }\n\n    // Cache the nonce for cancellation purposes.\n    const { nonce } = observer\n\n    // React might discard this render without telling us, but we can\n    // detect that with our first child's render phase.\n    const recon = (\n      <RenderAction\n        useAction={() => {\n          auto.nonce = nonce\n        }}\n      />\n    )\n\n    return (\n      <AutoDepth value={depth + 1}>\n        {recon}\n        {content}\n      </AutoDepth>\n    )\n  }\n  if (render.length > 1) {\n    // Bind its component name to the ref forwarder.\n    Object.defineProperty(component, 'displayName', {\n      get: () => component.displayName,\n    })\n    component = forwardRef(component as any)\n  }\n  if (/^[A-Z]/.test(render.name)) {\n    component.displayName = render.name\n  }\n  if (isDev) {\n    Object.defineProperty(component, '__render', {\n      value: render,\n    })\n  }\n  return component\n}\n\n// withAuto.dev is used by @wana/babel-plugin-with-auto\nif (isDev) {\n  withAuto.dev = (render: any) => {\n    const Component = render.length > 1 ? React.forwardRef(render) : render\n    const AutoRender = React.forwardRef((props: any, ref: any) => {\n      const { auto, depth, commit } = useAutoRender(Component)\n      function useCommit(observer: AutoObserver) {\n        let nonce = 0\n        useLayoutEffect(() => commit(observer, nonce))\n        return () => {\n          nonce = observer.nonce\n          return (\n            <RenderAction\n              useAction={() => {\n                auto.nonce = nonce\n              }}\n            />\n          )\n        }\n      }\n      return (\n        <AutoDepth value={depth + 1}>\n          <Component {...props} ref={ref} $auto={auto} $useCommit={useCommit} />\n        </AutoDepth>\n      )\n    })\n    Object.defineProperty(AutoRender, 'displayName', {\n      get: () => 'AutoRender',\n      set(displayName) {\n        Component.displayName = displayName\n      },\n    })\n    return AutoRender\n  }\n}\n\nfunction useAutoRender(component: React.FunctionComponent<any>) {\n  const depth = useAutoDepth()\n\n  const forceUpdate = useForceUpdate()\n  const auto = useMemo(() => {\n    const auto = new Auto({\n      onDirty() {\n        if (isDev) {\n          addDebugAction(auto, 'dirty')\n        }\n        const { observer } = auto\n        // If no observer exists, our `component` is either unmounted\n        // or its first render is not committed yet. In the latter case,\n        // the reconciled nonce will soon be validated in a layout effect.\n        if (!observer) {\n          return\n        }\n        // The `dirty` flag is reset when our `component` rerenders,\n        // which means this `onDirty` function can be called again,\n        // before this batched update is ever processed.\n        batch.render(depth, () => {\n          // When the observer changes before the batch can be flushed,\n          // we bail out to avoid using the nonce of a value no longer observed.\n          if (observer == auto.observer) {\n            if (observer.nonce > auto.nonce) {\n              if (isDev) {\n                addDebugAction(auto, 'batch')\n              }\n              forceUpdate()\n            } else {\n              auto.dirty = false\n            }\n          }\n        })\n      },\n    })\n    if (isDev) {\n      setDebug(auto, {\n        name: component.displayName || 'Anonymous',\n        actions: ['init'],\n        renders: 0,\n      })\n    }\n    return auto\n  }, [])\n\n  if (isDev) {\n    getDebug(auto).renders!++\n    if (globals.onRender) {\n      globals.onRender(auto, depth, component)\n    }\n  }\n\n  useDispose(() => auto.dispose())\n  return {\n    auto,\n    depth,\n    commit(observer: AutoObserver, nonce: number) {\n      if (isDev) {\n        getDebug(auto).actions = []\n      }\n      // The `nonce` from the render phase will force an update\n      // if any observed values have changed since then.\n      if (!auto.commit(observer, nonce)) {\n        if (isDev) {\n          addDebugAction(auto, 'dirty')\n        }\n        forceUpdate()\n      } else if (isDev) {\n        addDebugAction(auto, 'observe')\n      }\n    },\n  }\n}\n","import { is } from '@alloc/is'\nimport { useMemo, useRef } from 'react'\nimport { useLayoutEffect } from 'react-layout-effect'\nimport { noop } from '../common'\nimport { no } from '../no'\nimport { Change } from '../observable'\nimport { SIZE } from '../symbols'\nimport { useChanges } from './useChanges'\n\ntype UnmountFn = () => undefined | void\n\ntype Source<T = any> =\n  | { [key: string]: T }\n  | ReadonlyArray<T>\n  | ReadonlySet<T>\n  | ReadonlyMap<any, T>\n\ntype Effect<T extends Source> = T extends Source<infer U>\n  ? T extends ReadonlyMap<infer P, U>\n    ? (value: U, key: P) => UnmountFn | void\n    : T extends ReadonlyArray<U> | ReadonlySet<U>\n    ? (value: U) => UnmountFn | void\n    : (value: U, key: string) => UnmountFn | void\n  : never\n\n/**\n * Create a layout effect for every key of your `values` object.\n *\n * Values are passed to your `effect` function as they are added and replaced.\n * The `effect` can return a cleanup function to call for removed values.\n *\n * Map objects use their keys\n */\nexport function useEffects<T extends Source>(\n  source: T,\n  effect: Effect<T>,\n  deps?: readonly any[]\n) {\n  const unmountFns = useMemo(() => new Map<any, UnmountFn>(), [])\n\n  type UsedEffect = (value: any, key?: any) => UnmountFn | void\n  const usedEffect = useRef<UsedEffect>(effect)\n  useLayoutEffect(() => {\n    usedEffect.current = effect\n  }, deps)\n\n  const target = no(source)\n  const isValueBased = is.array(target) || is.set(target)\n\n  // Process the initial values.\n  useLayoutEffect(() => {\n    if (is.function(target.forEach)) {\n      target.forEach(mount)\n    } else {\n      Object.keys(target).forEach(key => mount(target[key], key))\n    }\n    return () => unmountFns.forEach(unmount => unmount())\n  }, [source])\n\n  // Subscribe to changes.\n  useChanges(source, onChange)\n\n  function mount(value: any, key?: any) {\n    const cacheKey = isValueBased ? value : key\n    if (!(is.array(target) && unmountFns.has(cacheKey))) {\n      const effect = usedEffect.current\n      const unmount = isValueBased ? effect(value) : effect(value, key)\n      unmountFns.set(cacheKey, unmount || noop)\n    }\n  }\n\n  function onChange({ op, key, value, oldValue }: Change) {\n    if (key == SIZE) return\n    if (op == 'clear') {\n      unmountFns.forEach(unmount => unmount())\n      unmountFns.clear()\n    } else if (op == 'splice') {\n      if (is.array(target)) {\n        oldValue.forEach((value: any) => {\n          if (!target.includes(value)) {\n            unmountFns.get(value)!()\n            unmountFns.delete(value)\n          }\n        })\n        value.forEach((value: any) => {\n          if (!unmountFns.has(value)) {\n            mount(value)\n          }\n        })\n      }\n    } else {\n      if (op != 'add') {\n        const cacheKey = isValueBased ? oldValue : key\n        if (!(is.array(target) && target.includes(cacheKey))) {\n          unmountFns.get(cacheKey)!()\n          unmountFns.delete(cacheKey)\n        }\n      }\n      if (op != 'remove') {\n        const cacheKey = isValueBased ? value : key\n        if (!(is.array(target) && unmountFns.has(cacheKey))) {\n          mount(value, key)\n        }\n      }\n    }\n  }\n}\n","import { is } from '@alloc/is'\nimport { useLayoutEffect } from 'react-layout-effect'\nimport { Derived } from '../derive'\nimport { Observable } from '../observable'\nimport { $O, SIZE } from '../symbols'\nimport { useForceUpdate } from './common'\n\n/**\n * An alternative to `withAuto` that re-renders the caller\n * when the given observable value is changed.\n *\n * If you pass an object without a key, the entire object\n * is observed.\n *\n * ⚠️ This hook has performance drawbacks! It cannot automatically\n * batch React updates, so you need to wrap changes with `batchedUpdates`\n * to avoid multiple re-renders. It also cannot wait for ancestor\n * components to re-render first, which also leads to excessive re-renders.\n */\nexport function useBinding<T extends object, P extends keyof T>(\n  target: T extends ReadonlyMap<any, any> ? never : T,\n  key: P\n): T[P]\nexport function useBinding<K, V>(\n  target: ReadonlyMap<K, V>,\n  key: K\n): V | undefined\nexport function useBinding<T>(target: Derived<T>): T\nexport function useBinding<T extends object>(target: T): T\nexport function useBinding(\n  target: Record<string, any> & { [$O]?: Observable },\n  key?: any\n) {\n  const observable = target[$O]\n  const forceUpdate = useForceUpdate()\n  useLayoutEffect(\n    () =>\n      observable?.observe(resolveKey(target, key), change => {\n        // Ignore \"clear\" event from a derived getter, which only serves\n        // as a signal to check its nonce in the next batch. Since we don't\n        // use batching in this hook, just wait for a \"replace\" event.\n        if (change.op == 'clear' && is.function(target)) return\n        forceUpdate()\n      }).dispose,\n    [observable, key]\n  )\n\n  // Return the current value.\n  return key\n    ? is.map(target)\n      ? target.get(key)\n      : target[key]\n    : is.function(target)\n    ? target()\n    : target\n}\n\nconst resolveKey = (target: any, key: any = $O) =>\n  (key == 'length' && is.array(target)) || (key == 'size' && is.set(target))\n    ? SIZE\n    : key\n"],"names":["useMemo"],"mappings":";;;;;;;;;;;;;;;;;oBAuCE,SACA,eAGA,MACA;AACA,MAAI;AACJ,MAAI,OAAO,iBAAiB,YAAY;AACtC,cAAU;AAAA,SACL;AACL,WAAO;AAAA;AAGT,QAAM,CAAC,SAAS,YAAY,QAAQ,MAAM;AACxC,QAAI,CAAC,SAAS;AACZ,aAAO,CAAC,MAAM;AAAA;AAEhB,UAAM,WAAU,OAAO,UAAQ;AAC7B,YAAM,WAAW,KAAK,MAAM;AAC5B,UAAI;AACF,YAAI,SAAS;AAAA,gBACb;AACA,aAAK;AAAA;AAEP,gBAAS,CAAE;AACX,aAAO;AAAA,OACN;AACH,UAAM,YAAW,UAAU,SAAQ;AACnC,WAAO,CAAC,UAAS;AAAA,KAChB,QAAQ;AAEX,kBAAgB,MAAM;AACpB,QAAI,UAAU;AACZ,eAAS,CAAE,SAAS;AACpB,aAAO,MAAM,SAAS,CAAE,SAAS;AAAA;AAAA,KAElC,CAAC;AAEJ,SAAO;AAAA;;cC7CY,OAAY,MAAuB;AACtD,QAAM,SAASA,WACb,MAAM,eAAe,GAAG,SAAS,SAAS,KAAK,SAAS,QACxD,QAAQ;AAGV,SAAO,GAAG,SAAS,UAAU,WAAW,QAAQ,CAAC,WAAW,EAAE;AAAA;AAKhE,wBAAwB,OAAY;AAClC,MAAI,GAAG,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