@casl/angular
Version:
Angular module for CASL which makes it easy to add permissions in any Angular app
91 lines (81 loc) • 2.13 kB
JavaScript
import * as e from "@angular/core";
import { Inject as t, Injectable as r, Pipe as o, inject as n, signal as s } from "@angular/core";
import { Ability as i } from "@casl/ability";
import { Observable as a } from "rxjs";
var d = class {
constructor() {
this.t = s([], ...ngDevMode ? [ {
debugName: "_rules"
} ] : []), this.o = n(i), this.can = (...e) => (this.t(), this.o.can(...e)), this.cannot = (...e) => !this.can(...e),
this.i = this.o.on("updated", e => {
this.t.set(e.rules);
});
}
ngOnDestroy() {
this.i();
}
update(e) {
this.o.update(e);
}
};
d.ɵfac = function(e) {
return new (e || d);
}, d.ɵprov = e.ɵɵdefineInjectable({
token: d,
factory: d.ɵfac,
providedIn: "root"
}), ("undefined" == typeof ngDevMode || ngDevMode) && e.ɵsetClassMetadata(d, [ {
type: r,
args: [ {
providedIn: "root"
} ]
} ], () => [], null);
var u = class {
constructor(e) {
this.u = e;
}
transform(...e) {
return this.u.can(...e);
}
};
u.ɵfac = function(t) {
return new (t || u)(e.ɵɵdirectiveInject(d, 16));
}, u.ɵpipe = e.ɵɵdefinePipe({
name: "able",
type: u,
pure: !1
}), ("undefined" == typeof ngDevMode || ngDevMode) && e.ɵsetClassMetadata(u, [ {
type: o,
args: [ {
name: "able",
pure: !1,
standalone: !0
} ]
} ], () => [ {
type: d
} ], null);
var p = class {
constructor(e) {
this.ability$ = new a(t => (t.next(e), e.on("updated", () => t.next(e))));
}
};
p.ɵfac = function(t) {
return new (t || p)(e.ɵɵinject(i));
}, p.ɵprov = e.ɵɵdefineInjectable({
token: p,
factory: p.ɵfac,
providedIn: "root"
}), ("undefined" == typeof ngDevMode || ngDevMode) && e.ɵsetClassMetadata(p, [ {
type: r,
args: [ {
providedIn: "root"
} ]
} ], () => [ {
type: void 0,
decorators: [ {
type: t,
args: [ i ]
} ]
} ], null);
export { p as AbilityService, d as AbilityServiceSignal, u as AblePipe };
//# sourceMappingURL=index.mjs.map