permix
Version:
Permix is a lightweight, framework-agnostic, type-safe permissions management library for JavaScript applications on the client and server sides.
25 lines (24 loc) • 936 B
TypeScript
import type { Definition, Permix, Rules } from '../core/index.mjs';
export interface PermixContext<T extends Definition> {
permix: Permix<T>;
isReady: boolean;
rules: Rules<T> | null;
}
/**
* Provides Permix context to the Svelte component tree.
*
* Must be called during component initialization (inside `<PermixProvider>`).
*
* @link https://permix.letstri.dev/docs/integrations/svelte
*/
export declare function providePermix<T extends Definition>(permix: Permix<T>): void;
export declare function usePermixContext<T extends Definition>(): PermixContext<T>;
/**
* Access Permix check and readiness state inside a Svelte component.
*
* @link https://permix.letstri.dev/docs/integrations/svelte
*/
export declare function usePermix<T extends Definition>(permix: Pick<Permix<T>, 'getRules' | 'check'>): {
check: (...args: import("../core/index.mjs").CheckArgs<T>) => boolean;
readonly isReady: boolean;
};