{"version":3,"file":"mobxreactlite.mjs","sources":["../src/utils/assertEnvironment.ts","../src/utils/UniversalFinalizationRegistry.ts","../src/utils/observerFinalizationRegistry.ts","../src/staticRendering.ts","../src/useObserver.ts","../src/observer.ts","../src/ObserverComponent.ts","../src/useLocalObservable.ts","../src/index.ts"],"sourcesContent":["import { _getGlobalState } from \"mobx\"\nimport { useState, useSyncExternalStore } from \"react\"\n\nif (!useState || !useSyncExternalStore) {\n    throw new Error(\"mobx-react-lite requires React 18 or later\")\n}\nif (!(_getGlobalState?.()?.version >= 7)) {\n    throw new Error(\"mobx-react-lite requires mobx at least version 7 to be available\")\n}\n","export declare class FinalizationRegistryType<T> {\n    constructor(finalize: (value: T) => void)\n    register(target: object, value: T, token?: object): void\n    unregister(token: object): void\n}\n\ndeclare const FinalizationRegistry: typeof FinalizationRegistryType | undefined\n\nexport const REGISTRY_FINALIZE_AFTER = 10_000\nexport const REGISTRY_SWEEP_INTERVAL = 10_000\n\nexport class TimerBasedFinalizationRegistry<T> implements FinalizationRegistryType<T> {\n    private registrations: Map<unknown, { value: T; registeredAt: number }> = new Map()\n    private sweepTimeout: ReturnType<typeof setTimeout> | undefined\n\n    constructor(private readonly finalize: (value: T) => void) {}\n\n    // Token is actually required with this impl\n    register(target: object, value: T, token?: object) {\n        this.registrations.set(token, {\n            value,\n            registeredAt: Date.now()\n        })\n        this.scheduleSweep()\n    }\n\n    unregister(token: unknown) {\n        this.registrations.delete(token)\n    }\n\n    // Bound so it can be used directly as setTimeout callback.\n    sweep = (maxAge = REGISTRY_FINALIZE_AFTER) => {\n        // cancel timeout so we can force sweep anytime\n        clearTimeout(this.sweepTimeout)\n        this.sweepTimeout = undefined\n\n        const now = Date.now()\n        this.registrations.forEach((registration, token) => {\n            if (now - registration.registeredAt >= maxAge) {\n                this.finalize(registration.value)\n                this.registrations.delete(token)\n            }\n        })\n\n        if (this.registrations.size > 0) {\n            this.scheduleSweep()\n        }\n    }\n\n    // Bound so it can be exported directly as clearTimers test utility.\n    finalizeAllImmediately = () => {\n        this.sweep(0)\n    }\n\n    private scheduleSweep() {\n        if (this.sweepTimeout === undefined) {\n            this.sweepTimeout = setTimeout(this.sweep, REGISTRY_SWEEP_INTERVAL)\n        }\n    }\n}\n\nexport const UniversalFinalizationRegistry =\n    typeof FinalizationRegistry !== \"undefined\"\n        ? FinalizationRegistry\n        : TimerBasedFinalizationRegistry\n","import { Reaction } from \"mobx\"\nimport { UniversalFinalizationRegistry } from \"./UniversalFinalizationRegistry\"\n\nexport const observerFinalizationRegistry = new UniversalFinalizationRegistry(\n    (adm: { reaction: Reaction | null }) => {\n        adm.reaction?.dispose()\n        adm.reaction = null\n    }\n)\n","let globalIsUsingStaticRendering = false\n\nexport function enableStaticRendering(enable: boolean) {\n    globalIsUsingStaticRendering = enable\n}\n\nexport function isUsingStaticRendering(): boolean {\n    return globalIsUsingStaticRendering\n}\n","import { getDependencyTree, Reaction } from \"mobx\"\nimport React from \"react\"\nimport { isUsingStaticRendering } from \"./staticRendering\"\nimport { observerFinalizationRegistry } from \"./utils/observerFinalizationRegistry\"\n\n// Do not store `admRef` (even as part of a closure!) on this object,\n// otherwise it will prevent GC and therefore reaction disposal via FinalizationRegistry.\ntype ObserverAdministration = {\n    reaction: Reaction | null // also serves as disposed flag\n    onStoreChange: Function | null // also serves as mounted flag\n    // stateVersion that 'ticks' for every time the reaction fires\n    // tearing is still present,\n    // because there is no cross component synchronization,\n    // but we can use `useSyncExternalStore` API.\n    // TODO: optimize to use number?\n    stateVersion: any\n    name: string\n    // These don't depend on state/props, therefore we can keep them here instead of `useCallback`\n    subscribe: Parameters<typeof React.useSyncExternalStore>[0]\n    getSnapshot: Parameters<typeof React.useSyncExternalStore>[1]\n}\n\nfunction createReaction(adm: ObserverAdministration) {\n    adm.reaction = new Reaction(`observer${adm.name}`, () => {\n        adm.stateVersion = Symbol()\n        // onStoreChange won't be available until the component \"mounts\".\n        // If state changes in between initial render and mount,\n        // `useSyncExternalStore` should handle that by checking the state version and issuing update.\n        adm.onStoreChange?.()\n    })\n}\n\nexport function useObserver<T>(render: () => T, baseComponentName: string = \"observed\"): T {\n    if (isUsingStaticRendering()) {\n        return render()\n    }\n\n    const admRef = React.useRef<ObserverAdministration | null>(null)\n\n    if (!admRef.current) {\n        // First render\n        const adm: ObserverAdministration = {\n            reaction: null,\n            onStoreChange: null,\n            stateVersion: Symbol(),\n            name: baseComponentName,\n            subscribe(onStoreChange: () => void) {\n                // Do NOT access admRef here!\n                observerFinalizationRegistry.unregister(adm)\n                adm.onStoreChange = onStoreChange\n                if (!adm.reaction) {\n                    // We've lost our reaction and therefore all subscriptions, occurs when:\n                    // 1. Timer based finalization registry disposed reaction before component mounted.\n                    // 2. React \"re-mounts\" same component without calling render in between (typically <StrictMode>).\n                    // We have to recreate reaction and schedule re-render to recreate subscriptions,\n                    // even if state did not change.\n                    createReaction(adm)\n                    // `onStoreChange` won't force update if subsequent `getSnapshot` returns same value.\n                    // So we make sure that is not the case\n                    adm.stateVersion = Symbol()\n                }\n\n                return () => {\n                    // Do NOT access admRef here!\n                    adm.onStoreChange = null\n                    adm.reaction?.dispose()\n                    adm.reaction = null\n                }\n            },\n            getSnapshot() {\n                // Do NOT access admRef here!\n                return adm.stateVersion\n            }\n        }\n\n        admRef.current = adm\n    }\n\n    const adm = admRef.current!\n\n    if (!adm.reaction) {\n        // First render or reaction was disposed by registry before subscribe\n        createReaction(adm)\n        // StrictMode/ConcurrentMode/Suspense may mean that our component is\n        // rendered and abandoned multiple times, so we need to track leaked\n        // Reactions.\n        observerFinalizationRegistry.register(admRef, adm, adm)\n    }\n\n    React.useDebugValue(adm.reaction!, getDependencyTree)\n\n    React.useSyncExternalStore(\n        // Both of these must be stable, otherwise it would keep resubscribing every render.\n        adm.subscribe,\n        adm.getSnapshot,\n        adm.getSnapshot\n    )\n\n    // render the original component, but have the\n    // reaction track the observables, so that rendering\n    // can be invalidated (see above) once a dependency changes\n    let renderResult!: T\n    let exception\n    adm.reaction!.track(() => {\n        try {\n            renderResult = render()\n        } catch (e) {\n            exception = e\n        }\n    })\n\n    if (exception) {\n        throw exception // re-throw any exceptions caught during rendering\n    }\n\n    return renderResult\n}\n","import { forwardRef, memo } from \"react\"\n\nimport { isUsingStaticRendering } from \"./staticRendering\"\nimport { useObserver } from \"./useObserver\"\n\nconst hasSymbol = typeof Symbol === \"function\" && Symbol.for\nconst isFunctionNameConfigurable =\n    Object.getOwnPropertyDescriptor(() => {}, \"name\")?.configurable ?? false\n\n// Using react-is had some issues (and operates on elements, not on types), see #608 / #609\nconst ReactForwardRefSymbol = hasSymbol\n    ? Symbol.for(\"react.forward_ref\")\n    : typeof forwardRef === \"function\" && forwardRef((props: any) => null)[\"$$typeof\"]\n\nconst ReactMemoSymbol = hasSymbol\n    ? Symbol.for(\"react.memo\")\n    : typeof memo === \"function\" && memo((props: any) => null)[\"$$typeof\"]\n\nexport function observer<C extends React.FunctionComponent<any>>(\n    baseComponent: C\n): C & React.MemoExoticComponent<C>\n\nexport function observer<P extends object>(\n    baseComponent: React.FunctionComponent<P>\n): React.FunctionComponent<P> & React.MemoExoticComponent<React.FunctionComponent<P>>\n\nexport function observer<P extends object, TRef = {}>(\n    baseComponent: React.ForwardRefExoticComponent<\n        React.PropsWithoutRef<P> & React.RefAttributes<TRef>\n    >\n): React.MemoExoticComponent<\n    React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<TRef>>\n>\n\n// n.b. base case is not used for actual typings or exported in the typing files\nexport function observer<P extends object, TRef = {}>(\n    baseComponent:\n        | React.ForwardRefRenderFunction<TRef, P>\n        | React.FunctionComponent<P>\n        | React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<TRef>>\n) {\n    if (ReactMemoSymbol && baseComponent[\"$$typeof\"] === ReactMemoSymbol) {\n        throw new Error(\n            `[mobx-react-lite] You are trying to use \\`observer\\` on a function component wrapped in either another \\`observer\\` or \\`React.memo\\`. The observer already applies 'React.memo' for you.`\n        )\n    }\n\n    // The working of observer is explained step by step in this talk: https://www.youtube.com/watch?v=cPF4iBedoF0&feature=youtu.be&t=1307\n    if (isUsingStaticRendering()) {\n        return baseComponent\n    }\n\n    let useForwardRef = false\n    let render = baseComponent\n\n    const baseComponentName = baseComponent.displayName || baseComponent.name\n\n    // If already wrapped with forwardRef, unwrap,\n    // so we can patch render and apply memo\n    if (ReactForwardRefSymbol && baseComponent[\"$$typeof\"] === ReactForwardRefSymbol) {\n        useForwardRef = true\n        render = baseComponent[\"render\"]\n        if (typeof render !== \"function\") {\n            throw new Error(\n                `[mobx-react-lite] \\`render\\` property of ForwardRef was not a function`\n            )\n        }\n    }\n\n    let observerComponent = (props: any, ref: React.Ref<TRef>) => {\n        return useObserver(() => render(props, ref), baseComponentName)\n    }\n\n    // Inherit original name and displayName, see #3438\n    ;(observerComponent as React.FunctionComponent).displayName = baseComponent.displayName\n\n    if (isFunctionNameConfigurable) {\n        Object.defineProperty(observerComponent, \"name\", {\n            value: baseComponent.name,\n            writable: true,\n            configurable: true\n        })\n    }\n\n    if (useForwardRef) {\n        // `forwardRef` must be applied prior `memo`\n        // `forwardRef(observer(cmp))` throws:\n        // \"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))\"\n        observerComponent = forwardRef(observerComponent)\n    }\n\n    // memo; we are not interested in deep updates\n    // in props; we assume that if deep objects are changed,\n    // this is in observables, which would have been tracked anyway\n    observerComponent = memo(observerComponent)\n\n    copyStaticProperties(baseComponent, observerComponent)\n\n    return observerComponent\n}\n\n// based on https://github.com/mridgway/hoist-non-react-statics/blob/master/src/index.js\nconst hoistBlackList: any = {\n    $$typeof: true,\n    render: true,\n    compare: true,\n    type: true,\n    // Don't redefine `displayName`,\n    // it's defined as getter-setter pair on `memo` (see #3192).\n    displayName: true\n}\n\nfunction copyStaticProperties(base: any, target: any) {\n    Object.keys(base).forEach(key => {\n        if (!hoistBlackList[key]) {\n            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(base, key)!)\n        }\n    })\n}\n","import { useObserver } from \"./useObserver\"\nimport type { ReactNode } from \"react\"\n\ntype IObserverProps =\n    | { children: () => ReactNode; render?: never }\n    | { children?: never; render: () => ReactNode }\n    | { children?: never; render?: never }\n\nfunction ObserverComponent({ children, render }: IObserverProps) {\n    if (children && render) {\n        console.error(\n            \"MobX Observer: Do not use children and render in the same time in `Observer`\"\n        )\n    }\n    const component = children || render\n    if (typeof component !== \"function\") {\n        return null\n    }\n    return useObserver(component)\n}\nObserverComponent.displayName = \"Observer\"\n\nexport { ObserverComponent as Observer }\n","import { observable, AnnotationsMap } from \"mobx\"\nimport { useState } from \"react\"\n\nexport function useLocalObservable<TStore extends object>(\n    initializer: () => TStore,\n    annotations?: AnnotationsMap<TStore, never>\n): TStore {\n    return useState(() => observable(initializer(), annotations, { autoBind: true }))[0]\n}\n","import \"./utils/assertEnvironment\"\n\nimport { observerFinalizationRegistry } from \"./utils/observerFinalizationRegistry\"\n\nexport { isUsingStaticRendering, enableStaticRendering } from \"./staticRendering\"\nexport { observer } from \"./observer\"\nexport { Observer } from \"./ObserverComponent\"\nexport { useLocalObservable } from \"./useLocalObservable\"\n\nexport { observerFinalizationRegistry as _observerFinalizationRegistry }\nexport const clearTimers = observerFinalizationRegistry[\"finalizeAllImmediately\"] ?? (() => {})\n"],"names":["useState","useSyncExternalStore","Error","_getGlobalState","_getGlobalState2","version","REGISTRY_FINALIZE_AFTER","REGISTRY_SWEEP_INTERVAL","TimerBasedFinalizationRegistry","constructor","finalize","registrations","Map","sweepTimeout","sweep","maxAge","clearTimeout","undefined","now","Date","forEach","registration","token","registeredAt","value","delete","size","scheduleSweep","finalizeAllImmediately","register","target","set","unregister","setTimeout","UniversalFinalizationRegistry","FinalizationRegistry","observerFinalizationRegistry","adm","_adm$reaction","reaction","dispose","globalIsUsingStaticRendering","enableStaticRendering","enable","isUsingStaticRendering","createReaction","Reaction","name","stateVersion","Symbol","onStoreChange","useObserver","render","baseComponentName","admRef","React","useRef","current","subscribe","getSnapshot","useDebugValue","getDependencyTree","renderResult","exception","track","e","hasSymbol","for","isFunctionNameConfigurable","_Object$getOwnPropert","_Object$getOwnPropert2","Object","getOwnPropertyDescriptor","configurable","ReactForwardRefSymbol","forwardRef","props","ReactMemoSymbol","memo","observer","baseComponent","useForwardRef","displayName","observerComponent","ref","defineProperty","writable","copyStaticProperties","hoistBlackList","$$typeof","compare","type","base","keys","key","ObserverComponent","children","console","error","component","useLocalObservable","initializer","annotations","observable","autoBind","clearTimers","_observerFinalization"],"mappings":";;;;AAGA,IAAI,CAACA,QAAQ,IAAI,CAACC,oBAAoB,EAAE;AACpC,EAAA,MAAM,IAAIC,KAAK,CAAC,4CAA4C,CAAC,CAAA;AACjE,CAAA;AACA,IAAI,EAAE,CAAAC,eAAe,IAAAC,IAAAA,IAAAA,CAAAA,gBAAA,GAAfD,eAAe,EAAI,KAAA,IAAA,GAAA,KAAA,CAAA,GAAnBC,gBAAA,CAAqBC,OAAO,KAAI,CAAC,CAAC,EAAE;AACtC,EAAA,MAAM,IAAIH,KAAK,CAAC,kEAAkE,CAAC,CAAA;AACvF;;ACAO,MAAMI,uBAAuB,GAAG,KAAM,CAAA;AACtC,MAAMC,uBAAuB,GAAG,KAAM,CAAA;MAEhCC,8BAA8B,CAAA;EAIvCC,WAAAA,CAA6BC,QAA4B,EAAA;AAAA,IAAA,IAAA,CAA5BA,QAAA,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,IAAA,CAHrBC,aAAa,GAAqD,IAAIC,GAAG,EAAE,CAAA;AAAA,IAAA,IAAA,CAC3EC,YAAY,GAAA,KAAA,CAAA,CAAA;AAiBpB;AAAA,IAAA,IAAA,CACAC,KAAK,GAAG,CAACC,MAAM,GAAGT,uBAAuB,KAAI;AACzC;AACAU,MAAAA,YAAY,CAAC,IAAI,CAACH,YAAY,CAAC,CAAA;MAC/B,IAAI,CAACA,YAAY,GAAGI,SAAS,CAAA;AAE7B,MAAA,MAAMC,GAAG,GAAGC,IAAI,CAACD,G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