@pentops/j5-react-realm-auth
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -140,4 +140,4 @@ import React from 'react'; | ||
}; | ||
function createRealmAuthStore(initialState, realmAccessIdGetter = (defaultRealmAccessIdGetter)) { | ||
return create((set, get) => (Object.assign(Object.assign(Object.assign({}, defaultInitialState), { setContext: (cb, contextChangeActiveAccessSelector = (defaultContextChangeActiveAccessSelector), isAuthenticating = false) => { | ||
function createRealmAuthStore(initialState, realmAccessIdGetter = (defaultRealmAccessIdGetter), contextChangeActiveAccessSelector = (defaultContextChangeActiveAccessSelector)) { | ||
return create((set, get) => (Object.assign(Object.assign(Object.assign({}, defaultInitialState), { setContext: (cb, isAuthenticating = false) => { | ||
const { context: prevContext, activeAccess } = get(); | ||
@@ -157,3 +157,3 @@ const result = cb(prevContext); | ||
if (prevAccess && realmAccessId === realmAccessIdGetter(prevAccess)) { | ||
return; | ||
return prevAccess; | ||
} | ||
@@ -160,0 +160,0 @@ const access = (_a = context === null || context === void 0 ? void 0 : context.accesses) === null || _a === void 0 ? void 0 : _a.find((ctxAccess) => realmAccessId === realmAccessIdGetter(ctxAccess)); |
@@ -9,3 +9,3 @@ import type { RealmAuthStore } from './store'; | ||
export declare function selectSetActiveAccess<TRealmAccess extends RealmAccess = RealmAccess, TContext extends WhoAmIContext<TRealmAccess> = WhoAmIContext<TRealmAccess>>(state: RealmAuthStore<TRealmAccess, TContext>): (realmAccessId: string) => TRealmAccess | undefined; | ||
export declare function selectSetContext<TRealmAccess extends RealmAccess = RealmAccess, TContext extends WhoAmIContext<TRealmAccess> = WhoAmIContext<TRealmAccess>>(state: RealmAuthStore<TRealmAccess, TContext>): (cb: (context: TContext | undefined) => TContext | undefined, defaultActiveAccessSelector?: import("./store").ContextChangeActiveAccessSelector<TRealmAccess, TContext> | undefined, isAuthenticating?: boolean) => TContext | undefined; | ||
export declare function selectSetContext<TRealmAccess extends RealmAccess = RealmAccess, TContext extends WhoAmIContext<TRealmAccess> = WhoAmIContext<TRealmAccess>>(state: RealmAuthStore<TRealmAccess, TContext>): (cb: (context: TContext | undefined) => TContext | undefined, isAuthenticating?: boolean) => TContext | undefined; | ||
//# sourceMappingURL=selectors.d.ts.map |
@@ -11,3 +11,3 @@ import { type RealmAccess, type WhoAmIContext } from './types'; | ||
isAuthenticated: boolean; | ||
setContext: (cb: (context: TContext | undefined) => TContext | undefined, defaultActiveAccessSelector?: ContextChangeActiveAccessSelector<TRealmAccess, TContext>, isAuthenticating?: boolean) => TContext | undefined; | ||
setContext: (cb: (context: TContext | undefined) => TContext | undefined, isAuthenticating?: boolean) => TContext | undefined; | ||
setActiveAccess: (realmAccessId: string) => TRealmAccess | undefined; | ||
@@ -22,3 +22,3 @@ reset(): void; | ||
}; | ||
export declare function createRealmAuthStore<TRealmAccess extends RealmAccess = RealmAccess, TContext extends WhoAmIContext<TRealmAccess> = WhoAmIContext<TRealmAccess>>(initialState?: Partial<RealmAuthStore<TRealmAccess, TContext>>, realmAccessIdGetter?: RealmAccessIdGetter<TRealmAccess>): import("zustand").UseBoundStore<import("zustand").StoreApi<RealmAuthStore<TRealmAccess, TContext>>>; | ||
export declare function createRealmAuthStore<TRealmAccess extends RealmAccess = RealmAccess, TContext extends WhoAmIContext<TRealmAccess> = WhoAmIContext<TRealmAccess>>(initialState?: Partial<RealmAuthStore<TRealmAccess, TContext>>, realmAccessIdGetter?: RealmAccessIdGetter<TRealmAccess>, contextChangeActiveAccessSelector?: (context: WhoAmIContext<TRealmAccess> | undefined, activeAccess: TRealmAccess | undefined, realmAccessIdGetter?: RealmAccessIdGetter<TRealmAccess>) => TRealmAccess | undefined): import("zustand").UseBoundStore<import("zustand").StoreApi<RealmAuthStore<TRealmAccess, TContext>>>; | ||
export declare function createRealmAuthStoreHooks<TRealmAccess extends RealmAccess = RealmAccess, TContext extends WhoAmIContext<TRealmAccess> = WhoAmIContext<TRealmAccess>>(initialState?: Partial<RealmAuthStore<TRealmAccess, TContext>>, realmAccessIdGetter?: RealmAccessIdGetter<TRealmAccess>): { | ||
@@ -32,4 +32,4 @@ readonly useRealmAuthStore: import("zustand").UseBoundStore<import("zustand").StoreApi<RealmAuthStore<TRealmAccess, TContext>>>; | ||
readonly useRealmAuthSetActiveAccess: () => (realmAccessId: string) => TRealmAccess | undefined; | ||
readonly useRealmAuthSetContext: () => (cb: (context: TContext | undefined) => TContext | undefined, defaultActiveAccessSelector?: ContextChangeActiveAccessSelector<TRealmAccess, TContext> | undefined, isAuthenticating?: boolean) => TContext | undefined; | ||
readonly useRealmAuthSetContext: () => (cb: (context: TContext | undefined) => TContext | undefined, isAuthenticating?: boolean) => TContext | undefined; | ||
}; | ||
//# sourceMappingURL=store.d.ts.map |
{ | ||
"name": "@pentops/j5-react-realm-auth", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
291
21432