{"version":3,"file":"mobxreact.mjs","sources":["../src/utils/utils.ts","../src/observerClass.ts","../src/observer.tsx","../src/index.ts"],"sourcesContent":["export function shallowEqual(objA: any, objB: any): boolean {\n    //From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js\n    if (is(objA, objB)) {\n        return true\n    }\n    if (typeof objA !== \"object\" || objA === null || typeof objB !== \"object\" || objB === null) {\n        return false\n    }\n    const keysA = Object.keys(objA)\n    const keysB = Object.keys(objB)\n    if (keysA.length !== keysB.length) {\n        return false\n    }\n    for (let i = 0; i < keysA.length; i++) {\n        if (!Object.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {\n            return false\n        }\n    }\n    return true\n}\n\nfunction is(x: any, y: any): boolean {\n    // From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js\n    if (x === y) {\n        return x !== 0 || 1 / x === 1 / y\n    } else {\n        return x !== x && y !== y\n    }\n}\n\n/**\n * Utilities for patching componentWillUnmount, to make sure @disposeOnUnmount works correctly icm with user defined hooks\n * and the handler provided by mobx-react\n */\nconst mobxMixins = Symbol(\"patchMixins\")\nconst mobxPatchedDefinition = Symbol(\"patchedDefinition\")\n\nexport interface Mixins extends Record<string, any> {\n    locks: number\n    methods: Array<Function>\n}\n\nfunction getMixins(target: object, methodName: string): Mixins {\n    const mixins = (target[mobxMixins] = target[mobxMixins] || {})\n    const methodMixins = (mixins[methodName] = mixins[methodName] || {})\n    methodMixins.locks = methodMixins.locks || 0\n    methodMixins.methods = methodMixins.methods || []\n    return methodMixins\n}\n\nfunction wrapper(realMethod: Function, mixins: Mixins, ...args: Array<any>) {\n    // locks are used to ensure that mixins are invoked only once per invocation, even on recursive calls\n    mixins.locks++\n\n    try {\n        let retVal\n        if (realMethod !== undefined && realMethod !== null) {\n            retVal = realMethod.apply(this, args)\n        }\n\n        return retVal\n    } finally {\n        mixins.locks--\n        if (mixins.locks === 0) {\n            mixins.methods.forEach(mx => {\n                mx.apply(this, args)\n            })\n        }\n    }\n}\n\nfunction wrapFunction(realMethod: Function, mixins: Mixins): (...args: Array<any>) => any {\n    const fn = function (...args: Array<any>) {\n        wrapper.call(this, realMethod, mixins, ...args)\n    }\n    return fn\n}\n\nexport function patch(target: object, methodName: string, mixinMethod: Function): void {\n    const mixins = getMixins(target, methodName)\n\n    if (mixins.methods.indexOf(mixinMethod) < 0) {\n        mixins.methods.push(mixinMethod)\n    }\n\n    const oldDefinition = Object.getOwnPropertyDescriptor(target, methodName)\n    if (oldDefinition && oldDefinition[mobxPatchedDefinition]) {\n        // already patched definition, do not repatch\n        return\n    }\n\n    const originalMethod = target[methodName]\n    const newDefinition = createDefinition(\n        target,\n        methodName,\n        oldDefinition ? oldDefinition.enumerable : undefined,\n        mixins,\n        originalMethod\n    )\n\n    Object.defineProperty(target, methodName, newDefinition)\n}\n\nfunction createDefinition(\n    target: object,\n    methodName: string,\n    enumerable: any,\n    mixins: Mixins,\n    originalMethod: Function\n): PropertyDescriptor {\n    let wrappedFunc = wrapFunction(originalMethod, mixins)\n\n    return {\n        // @ts-ignore\n        [mobxPatchedDefinition]: true,\n        get: function () {\n            return wrappedFunc\n        },\n        set: function (value) {\n            if (this === target) {\n                wrappedFunc = wrapFunction(value, mixins)\n            } else {\n                // when it is an instance of the prototype/a child prototype patch that particular case again separately\n                // since we need to store separate values depending on wether it is the actual instance, the prototype, etc\n                // e.g. the method for super might not be the same as the method for the prototype which might be not the same\n                // as the method for the instance\n                const newDefinition = createDefinition(this, methodName, enumerable, mixins, value)\n                Object.defineProperty(this, methodName, newDefinition)\n            }\n        },\n        configurable: true,\n        enumerable: enumerable\n    }\n}\n","import { PureComponent, Component, ComponentClass, ClassAttributes } from \"react\"\nimport {\n    _allowStateChanges,\n    Reaction,\n    _allowStateReadsStart,\n    _allowStateReadsEnd,\n    _getGlobalState\n} from \"mobx\"\nimport {\n    isUsingStaticRendering,\n    _observerFinalizationRegistry as observerFinalizationRegistry\n} from \"mobx-react-lite\"\nimport { shallowEqual, patch } from \"./utils/utils\"\n\nconst administrationSymbol = Symbol(\"ObserverAdministration\")\nconst isMobXReactObserverSymbol = Symbol(\"isMobXReactObserver\")\n\nlet observablePropDescriptors: PropertyDescriptorMap\nif (__DEV__) {\n    observablePropDescriptors = {\n        props: createObservablePropDescriptor(\"props\"),\n        state: createObservablePropDescriptor(\"state\"),\n        context: createObservablePropDescriptor(\"context\")\n    }\n}\n\ntype ObserverAdministration = {\n    reaction: Reaction | null // also serves as disposed flag\n    forceUpdate: Function | null\n    mounted: boolean // we could use forceUpdate as mounted flag\n    reactionInvalidatedBeforeMount: boolean\n    name: string\n    // Used only on __DEV__\n    props: any\n    state: any\n    context: any\n}\n\nfunction getAdministration(component: Component): ObserverAdministration {\n    // We create administration lazily, because we can't patch constructor\n    // and the exact moment of initialization partially depends on React internals.\n    // At the time of writing this, the first thing invoked is one of the observable getter/setter (state/props/context).\n    return (component[administrationSymbol] ??= {\n        reaction: null,\n        mounted: false,\n        reactionInvalidatedBeforeMount: false,\n        forceUpdate: null,\n        name: getDisplayName(component.constructor as ComponentClass),\n        state: undefined,\n        props: undefined,\n        context: undefined\n    })\n}\n\nexport function makeClassComponentObserver(\n    componentClass: ComponentClass<any, any>\n): ComponentClass<any, any> {\n    const { prototype } = componentClass\n\n    if (componentClass[isMobXReactObserverSymbol]) {\n        const displayName = getDisplayName(componentClass)\n        throw new Error(\n            `The provided component class (${displayName}) has already been declared as an observer component.`\n        )\n    } else {\n        componentClass[isMobXReactObserverSymbol] = true\n    }\n\n    if (prototype.componentWillReact) {\n        throw new Error(\"The componentWillReact life-cycle event is no longer supported\")\n    }\n    if (componentClass[\"__proto__\"] !== PureComponent) {\n        if (!prototype.shouldComponentUpdate) {\n            prototype.shouldComponentUpdate = observerSCU\n        } else if (prototype.shouldComponentUpdate !== observerSCU) {\n            // n.b. unequal check, instead of existence check, as @observer might be on superclass as well\n            throw new Error(\n                \"It is not allowed to use shouldComponentUpdate in observer based components.\"\n            )\n        }\n    }\n\n    if (__DEV__) {\n        Object.defineProperties(prototype, observablePropDescriptors)\n    }\n\n    const originalRender = prototype.render\n    if (typeof originalRender !== \"function\") {\n        const displayName = getDisplayName(componentClass)\n        throw new Error(\n            `[mobx-react] class component (${displayName}) is missing \\`render\\` method.` +\n                `\\n\\`observer\\` requires \\`render\\` being a function defined on prototype.` +\n                `\\n\\`render = () => {}\\` or \\`render = function() {}\\` is not supported.`\n        )\n    }\n\n    prototype.render = function () {\n        Object.defineProperty(this, \"render\", {\n            // There is no safe way to replace render, therefore it's forbidden.\n            configurable: false,\n            writable: false,\n            value: isUsingStaticRendering()\n                ? originalRender\n                : createReactiveRender.call(this, originalRender)\n        })\n        return this.render()\n    }\n\n    const originalComponentDidMount = prototype.componentDidMount\n    prototype.componentDidMount = function () {\n        if (__DEV__ && this.componentDidMount !== Object.getPrototypeOf(this).componentDidMount) {\n            const displayName = getDisplayName(componentClass)\n            throw new Error(\n                `[mobx-react] \\`observer(${displayName}).componentDidMount\\` must be defined on prototype.` +\n                    `\\n\\`componentDidMount = () => {}\\` or \\`componentDidMount = function() {}\\` is not supported.`\n            )\n        }\n\n        // `componentDidMount` may not be called at all. React can abandon the instance after `render`.\n        // That's why we use finalization registry to dispose reaction created during render.\n        // Happens with `<Suspend>` see #3492\n        //\n        // `componentDidMount` can be called immediately after `componentWillUnmount` without calling `render` in between.\n        // Happens with `<StrictMode>`see #3395.\n        //\n        // If `componentDidMount` is called, it's guaranteed to run synchronously with render (similary to `useLayoutEffect`).\n        // Therefore we don't have to worry about external (observable) state being updated before mount (no state version checking).\n        //\n        // Things may change: \"In the future, React will provide a feature that lets components preserve state between unmounts\"\n\n        const admin = getAdministration(this)\n\n        admin.mounted = true\n\n        // Component instance committed, prevent reaction disposal.\n        observerFinalizationRegistry.unregister(this)\n\n        // We don't set forceUpdate before mount because it requires a reference to `this`,\n        // therefore `this` could NOT be garbage collected before mount,\n        // preventing reaction disposal by FinalizationRegistry and leading to memory leak.\n        // As an alternative we could have `admin.instanceRef = new WeakRef(this)`, but lets avoid it if possible.\n        admin.forceUpdate = () => this.forceUpdate()\n\n        if (!admin.reaction || admin.reactionInvalidatedBeforeMount) {\n            // Missing reaction:\n            // 1. Instance was unmounted (reaction disposed) and immediately remounted without running render #3395.\n            // 2. Reaction was disposed by finalization registry before mount. Shouldn't ever happen for class components:\n            // `componentDidMount` runs synchronously after render, but our registry are deferred (can't run in between).\n            // In any case we lost subscriptions to observables, so we have to create new reaction and re-render to resubscribe.\n            // The reaction will be created lazily by following render.\n\n            // Reaction invalidated before mount:\n            // 1. A descendant's `componenDidMount` invalidated it's parent #3730\n\n            admin.forceUpdate()\n        }\n        return originalComponentDidMount?.apply(this, arguments)\n    }\n\n    // TODO@major Overly complicated \"patch\" is only needed to support the deprecated @disposeOnUnmount\n    patch(prototype, \"componentWillUnmount\", function () {\n        if (isUsingStaticRendering()) {\n            return\n        }\n        const admin = getAdministration(this)\n        admin.reaction?.dispose()\n        admin.reaction = null\n        admin.forceUpdate = null\n        admin.mounted = false\n        admin.reactionInvalidatedBeforeMount = false\n    })\n\n    return componentClass\n}\n\n// Generates a friendly name for debugging\nfunction getDisplayName(componentClass: ComponentClass) {\n    return componentClass.displayName || componentClass.name || \"<component>\"\n}\n\nfunction createReactiveRender(originalRender: any) {\n    const boundOriginalRender = originalRender.bind(this)\n\n    const admin = getAdministration(this)\n\n    function reactiveRender() {\n        if (!admin.reaction) {\n            // Create reaction lazily to support re-mounting #3395\n            admin.reaction = createReaction(admin)\n            if (!admin.mounted) {\n                // React can abandon this instance and never call `componentDidMount`/`componentWillUnmount`,\n                // we have to make sure reaction will be disposed.\n                observerFinalizationRegistry.register(this, admin, this)\n            }\n        }\n\n        let error: unknown = undefined\n        let renderResult = undefined\n        admin.reaction.track(() => {\n            try {\n                // TODO@major\n                // Optimization: replace with _allowStateChangesStart/End (not available in mobx@6.0.0)\n                renderResult = _allowStateChanges(false, boundOriginalRender)\n            } catch (e) {\n                error = e\n            }\n        })\n        if (error) {\n            throw error\n        }\n        return renderResult\n    }\n\n    return reactiveRender\n}\n\nfunction createReaction(admin: ObserverAdministration) {\n    return new Reaction(`${admin.name}.render()`, () => {\n        if (!admin.mounted) {\n            // This is neccessary to avoid react warning about calling forceUpdate on component that isn't mounted yet.\n            // This happens when component is abandoned after render - our reaction is already created and reacts to changes.\n            // `componenDidMount` runs synchronously after `render`, so unlike functional component, there is no delay during which the reaction could be invalidated.\n            // However `componentDidMount` runs AFTER it's descendants' `componentDidMount`, which CAN invalidate the reaction, see #3730. Therefore remember and forceUpdate on mount.\n            admin.reactionInvalidatedBeforeMount = true\n            return\n        }\n\n        try {\n            admin.forceUpdate?.()\n        } catch (error) {\n            admin.reaction?.dispose()\n            admin.reaction = null\n        }\n    })\n}\n\nfunction observerSCU(nextProps: ClassAttributes<any>, nextState: any): boolean {\n    if (isUsingStaticRendering()) {\n        console.warn(\n            \"[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side.\"\n        )\n    }\n    // update on any state changes (as is the default)\n    if (this.state !== nextState) {\n        return true\n    }\n    // update if props are shallowly not equal, inspired by PureRenderMixin\n    // we could return just 'false' here, and avoid the `skipRender` checks etc\n    // however, it is nicer if lifecycle events are triggered like usually,\n    // so we return true here if props are shallowly modified.\n    return !shallowEqual(this.props, nextProps)\n}\n\nfunction createObservablePropDescriptor(key: \"props\" | \"state\" | \"context\") {\n    return {\n        configurable: true,\n        enumerable: true,\n        get() {\n            const admin = getAdministration(this)\n            const derivation = _getGlobalState().trackingDerivation\n            if (derivation && derivation !== admin.reaction) {\n                throw new Error(\n                    `[mobx-react] Cannot read \"${admin.name}.${key}\" in a reactive context, as it isn't observable.\n                    Please use component lifecycle method to copy the value into a local observable first.\n                    See https://github.com/mobxjs/mobx/blob/main/packages/mobx-react/README.md#note-on-using-props-and-state-in-derivations`\n                )\n            }\n            return admin[key]\n        },\n        set(value) {\n            getAdministration(this)[key] = value\n        }\n    }\n}\n","import * as React from \"react\"\nimport { observer as observerLite } from \"mobx-react-lite\"\n\nimport { makeClassComponentObserver } from \"./observerClass\"\nimport { IReactComponent } from \"./types/IReactComponent\"\n\n/**\n * Observer function / decorator\n */\nexport function observer<T extends IReactComponent>(\n    component: T,\n    context: ClassDecoratorContext\n): void\nexport function observer<T extends IReactComponent>(component: T): T\nexport function observer<T extends IReactComponent>(\n    component: T,\n    context?: ClassDecoratorContext\n): T {\n    if (context && context.kind !== \"class\") {\n        throw new Error(\"The @observer decorator can be used on classes only\")\n    }\n\n    if (\n        Object.prototype.isPrototypeOf.call(React.Component, component) ||\n        Object.prototype.isPrototypeOf.call(React.PureComponent, component)\n    ) {\n        // Class component\n        return makeClassComponentObserver(component as React.ComponentClass<any, any>) as T\n    } else {\n        // Function component\n        return observerLite(component as React.FunctionComponent<any>) as unknown as T\n    }\n}\n","import { observable } from \"mobx\"\nimport { Component } from \"react\"\n\nif (!Component) {\n    throw new Error(\"mobx-react requires React to be available\")\n}\n\nif (!observable) {\n    throw new Error(\"mobx-react requires mobx to be available\")\n}\n\nexport {\n    Observer,\n    isUsingStaticRendering,\n    enableStaticRendering,\n    useLocalObservable,\n    _observerFinalizationRegistry,\n    clearTimers\n} from \"mobx-react-lite\"\n\nexport { observer } from \"./observer\"\n"],"names":["shallowEqual","objA","objB","is","keysA","Object","keys","keysB","length","i","hasOwnProperty","call","x","y","mobxMixins","Symbol","mobxPatchedDefinition","getMixins","target","methodName","mixins","methodMixins","locks","methods","wrapper","realMethod","args","retVal","undefined","apply","forEach","mx","wrapFunction","fn","patch","mixinMethod","indexOf","push","oldDefinition","getOwnPropertyDescriptor","originalMethod","newDefinition","createDefinition","enumerable","defineProperty","wrappedFunc","get","set","value","configurable","administrationSymbol","isMobXReactObserverSymbol","observablePropDescriptors","__DEV__","props","createObservablePropDescriptor","state","context","getAdministration","component","_component$administra","reaction","mounted","reactionInvalidatedBeforeMount","forceUpdate","name","getDisplayName","constructor","makeClassComponentObserver","componentClass","prototype","displayName","Error","componentWillReact","PureComponent","shouldComponentUpdate","observerSCU","defineProperties","originalRender","render","writable","isUsingStaticRendering","createReactiveRender","originalComponentDidMount","componentDidMount","getPrototypeOf","admin","observerFinalizationRegistry","unregister","arguments","_admin$reaction","dispose","boundOriginalRender","bind","reactiveRender","createReaction","register","error","renderResult","track","_allowStateChanges","e","Reaction","_admin$reaction2","nextProps","nextState","console","warn","key","derivation","_getGlobalState","trackingDerivation","observer","kind","isPrototypeOf","React","Component","observerLite","observable"],"mappings":";;;;;;;;AAAgB,SAAAA,YAAYA,CAACC,IAAS,EAAEC,IAAS,EAAA;AAC7C;AACA,EAAA,IAAIC,EAAE,CAACF,IAAI,EAAEC,IAAI,CAAC,EAAE;AAChB,IAAA,OAAO,IAAI,CAAA;AACf,GAAA;AACA,EAAA,IAAI,OAAOD,IAAI,KAAK,QAAQ,IAAIA,IAAI,KAAK,IAAI,IAAI,OAAOC,IAAI,KAAK,QAAQ,IAAIA,IAAI,KAAK,IAAI,EAAE;AACxF,IAAA,OAAO,KAAK,CAAA;AAChB,GAAA;AACA,EAAA,MAAME,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACL,IAAI,CAAC,CAAA;AAC/B,EAAA,MAAMM,KAAK,GAAGF,MAAM,CAACC,IAAI,CAACJ,IAAI,CAAC,CAAA;AAC/B,EAAA,IAAIE,KAAK,CAACI,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;AAC/B,IAAA,OAAO,KAAK,CAAA;AAChB,GAAA;AACA,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,KAAK,CAACI,MAAM,EAAEC,CAAC,EAAE,EAAE;AACnC,IAAA,IAAI,CAACJ,MAAM,CAACK,cAAc,CAACC,IAAI,CAACT,IAAI,EAAEE,KAAK,CAACK,CAAC,CAAC,CAAC,IAAI,CAACN,EAAE,CAACF,IAAI,CAACG,KAAK,CAACK,CA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