import { MatesUtils } from "../../MatesUtils"; type TScope = T & { reset?: () => void; __isScope___: boolean; }; /** * Creates a scope instance from `ScopeClass` and registers it on the current * host component so child components can access it via `getParentScope`. * * - Instantiates `ScopeClass` in a special context (`viewOuterInProgress = true`) * so atoms and other reactive primitives can be created inside the constructor. * - Walks all properties of the instance and binds non-atom methods to the instance * (`method.bind(returnObj)`), so methods work correctly when passed as callbacks. * - If the instance has a `setup(propsFn)` method, calls it with the component's * props function — this allows lifecycle hooks like `onMount`/`onCleanup` to be * registered inside `setup()`. * - Registers the instance on the host element's scope map so descendant components * can retrieve it via `getParentScope`. * - Marks the returned object with `__isScope___: true`. * - Throws if the same `ScopeClass` is used more than once in the same component. * * @param ScopeClass - A class whose constructor may contain atoms and reactive primitives. * @returns The instantiated scope object, augmented with `__isScope___: true`. * * @example * // In a parent component: * class CounterScope { * count = atom(0); * incr() { this.count.set(this.count() + 1); } * setup(props) { * onMount(() => console.log("mounted")); * } * } * * const counter = scope(CounterScope); * counter.count(); // 0 * counter.incr(); // count becomes 1 */ export declare const scope: (ScopeClass: new () => T) => TScope; /** * Retrieves a scope instance of `ScopeClass` from the nearest ancestor component * that created it via `scope(ScopeClass)`. * * - Dispatches a bubbling `CustomEvent("request-parent-scope")` up the DOM tree. * - Any ancestor host element that has the matching scope class registered will * call `detail.resolve(inst)`, providing the scope instance. * - Throws an error if no ancestor has registered the requested scope class. * * @param ScopeClass - The class whose scope instance should be retrieved from an ancestor. * @returns The scope instance registered by the nearest ancestor for `ScopeClass`. * @throws If no ancestor component has a matching scope registered. * * @example * // In a child component (ancestor must have called scope(CounterScope)): * const counter = getParentScope(CounterScope); * counter.count(); // reads the parent's atom * counter.incr(); // mutates the parent's atom */ export declare const getParentScope: (ScopeClass: new () => T) => TScope; /** * Register scope classes that WithScope should instantiate on every * component tree mount. Libraries call this at module level. * * Safe to call multiple times — duplicates are ignored (Set semantics). * * @example * import { registerGlobalScopes } from "mates"; * registerGlobalScopes([SnackbarScope, NotificationScope]); */ export declare function registerGlobalScopes(classes: Array object>): void; /** * Returns a snapshot of all registered global scope classes. * Used internally by WithScope. */ export declare function getGlobalScopeClasses(): Array object>; export declare const useUtils: () => TScope; /** Alias for `scope()` — creates a scope instance. */ export { scope as useScope }; //# sourceMappingURL=scope.d.ts.map