@casl/angular 8.2.1 → 8.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,7 @@ This package allows to integrate `@casl/ability` with [Angular] application. It
8
8
 
9
9
  ## Installation
10
10
 
11
- The latest version of this package is compiled by Ivy, so **apps that do not use Ivy are no longer supported.**
11
+ The latest version of this package is compiled by Ivy, so **apps that do not use Ivy are no longer supported**.
12
12
 
13
13
  ```sh
14
14
  npm install @casl/angular @casl/ability
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casl/angular",
3
- "version": "8.2.1",
3
+ "version": "8.2.2",
4
4
  "description": "Angular module for CASL which makes it easy to add permissions in any Angular app",
5
5
  "main": "dist/umd/index.js",
6
6
  "module": "dist/es5m/index.js",
@@ -47,19 +47,19 @@
47
47
  "author": "Sergii Stotskyi <sergiy.stotskiy@gmail.com>",
48
48
  "license": "MIT",
49
49
  "peerDependencies": {
50
- "@angular/core": "^14.0.0 || ^15.0.0 || ^16.0.0",
50
+ "@angular/core": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
51
51
  "@casl/ability": "^3.0.0 || ^4.0.0 || ^5.1.0 || ^6.0.0",
52
52
  "rxjs": "^7.5.5",
53
53
  "tslib": "^2.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@angular-devkit/build-angular": "^16.0.0",
57
- "@angular/common": "^16.0.0",
58
- "@angular/compiler": "^16.0.0",
59
- "@angular/compiler-cli": "^16.0.0",
60
- "@angular/core": "^16.0.0",
61
- "@angular/platform-browser": "^16.0.0",
62
- "@angular/platform-browser-dynamic": "^16.0.0",
56
+ "@angular-devkit/build-angular": "^17.0.0",
57
+ "@angular/common": "^17.0.0",
58
+ "@angular/compiler": "^17.0.0",
59
+ "@angular/compiler-cli": "^17.0.0",
60
+ "@angular/core": "^17.0.0",
61
+ "@angular/platform-browser": "^17.0.0",
62
+ "@angular/platform-browser-dynamic": "^17.0.0",
63
63
  "@casl/ability": "^6.0.0",
64
64
  "@casl/dx": "workspace:^1.0.0",
65
65
  "@types/jest": "^29.0.0",
@@ -67,8 +67,8 @@
67
67
  "jest-preset-angular": "^13.0.0",
68
68
  "rxjs": "^7.5.5",
69
69
  "tslib": "^2.0.0",
70
- "typescript": "~5.0.0",
71
- "zone.js": "~0.13.0"
70
+ "typescript": "~5.2.0",
71
+ "zone.js": "~0.14.0"
72
72
  },
73
73
  "files": [
74
74
  "dist",
@@ -1,105 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Pipe, Inject, NgModule, Injectable } from '@angular/core';
3
- import { PureAbility } from '@casl/ability';
4
- import { Observable } from 'rxjs';
5
-
6
- var AblePipe = /** @class */ (function () {
7
- function AblePipe(ability) {
8
- this._ability = ability;
9
- }
10
- AblePipe.prototype.transform = function () {
11
- var _a;
12
- var args = [];
13
- for (var _i = 0; _i < arguments.length; _i++) {
14
- args[_i] = arguments[_i];
15
- }
16
- return (_a = this._ability).can.apply(_a, args);
17
- };
18
- AblePipe.ɵfac = function AblePipe_Factory(t) { return new (t || AblePipe)(i0.ɵɵdirectiveInject(PureAbility, 16)); };
19
- AblePipe.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "able", type: AblePipe, pure: false });
20
- return AblePipe;
21
- }());
22
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AblePipe, [{
23
- type: Pipe,
24
- args: [{ name: 'able', pure: false }]
25
- }], function () { return [{ type: undefined, decorators: [{
26
- type: Inject,
27
- args: [PureAbility]
28
- }] }]; }, null); })();
29
- var AblePurePipe = /** @class */ (function () {
30
- function AblePurePipe(ability) {
31
- this._ability = ability;
32
- }
33
- // TODO: `Observable` can be removed after https://github.com/angular/angular/issues/15041
34
- AblePurePipe.prototype.transform = function () {
35
- var _this = this;
36
- var args = [];
37
- for (var _i = 0; _i < arguments.length; _i++) {
38
- args[_i] = arguments[_i];
39
- }
40
- return new Observable(function (s) {
41
- var emit = function () {
42
- var _a;
43
- return s.next((_a = _this._ability).can.apply(_a, args));
44
- };
45
- emit();
46
- return _this._ability.on('updated', emit);
47
- });
48
- };
49
- AblePurePipe.ɵfac = function AblePurePipe_Factory(t) { return new (t || AblePurePipe)(i0.ɵɵdirectiveInject(PureAbility, 16)); };
50
- AblePurePipe.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "ablePure", type: AblePurePipe, pure: true });
51
- return AblePurePipe;
52
- }());
53
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AblePurePipe, [{
54
- type: Pipe,
55
- args: [{ name: 'ablePure' }]
56
- }], function () { return [{ type: undefined, decorators: [{
57
- type: Inject,
58
- args: [PureAbility]
59
- }] }]; }, null); })();
60
-
61
- var AbilityModule = /** @class */ (function () {
62
- function AbilityModule() {
63
- }
64
- AbilityModule.ɵfac = function AbilityModule_Factory(t) { return new (t || AbilityModule)(); };
65
- AbilityModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AbilityModule });
66
- AbilityModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
67
- return AbilityModule;
68
- }());
69
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AbilityModule, [{
70
- type: NgModule,
71
- args: [{
72
- declarations: [
73
- AblePipe,
74
- AblePurePipe,
75
- ],
76
- exports: [
77
- AblePipe,
78
- AblePurePipe,
79
- ],
80
- }]
81
- }], null, null); })();
82
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(AbilityModule, { declarations: [AblePipe,
83
- AblePurePipe], exports: [AblePipe,
84
- AblePurePipe] }); })();
85
-
86
- var AbilityService = /** @class */ (function () {
87
- function AbilityService(ability) {
88
- this.ability$ = new Observable(function (observer) {
89
- observer.next(ability);
90
- return ability.on('updated', function () { return observer.next(ability); });
91
- });
92
- }
93
- AbilityService.ɵfac = function AbilityService_Factory(t) { return new (t || AbilityService)(i0.ɵɵinject(PureAbility)); };
94
- AbilityService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AbilityService, factory: AbilityService.ɵfac });
95
- return AbilityService;
96
- }());
97
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AbilityService, [{
98
- type: Injectable
99
- }], function () { return [{ type: undefined, decorators: [{
100
- type: Inject,
101
- args: [PureAbility]
102
- }] }]; }, null); })();
103
-
104
- export { AbilityModule, AbilityService, AblePipe, AblePurePipe };
105
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/pipes.ts","../../src/AbilityModule.ts","../../src/AbilityService.ts"],"sourcesContent":["import { Pipe, Inject, PipeTransform } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Pipe({ name: 'able', pure: false })\nexport class AblePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n transform(...args: Parameters<T['can']>): boolean {\n return this._ability.can(...args);\n }\n}\n\n@Pipe({ name: 'ablePure' })\nexport class AblePurePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n // TODO: `Observable` can be removed after https://github.com/angular/angular/issues/15041\n transform(...args: Parameters<T['can']>): Observable<boolean> {\n return new Observable((s) => {\n const emit = () => s.next(this._ability.can(...args));\n emit();\n return this._ability.on('updated', emit);\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { AblePipe, AblePurePipe } from './pipes';\n\n@NgModule({\n declarations: [\n AblePipe,\n AblePurePipe,\n ],\n exports: [\n AblePipe,\n AblePurePipe,\n ],\n})\nexport class AbilityModule {\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Injectable()\nexport class AbilityService<T extends AnyAbility> {\n readonly ability$: Observable<T>;\n\n constructor(@Inject(PureAbility) ability: T) {\n this.ability$ = new Observable((observer) => {\n observer.next(ability);\n return ability.on('updated', () => observer.next(ability));\n });\n }\n}\n"],"names":[],"mappings":";;;;;AAIA,IAAA,QAAA,kBAAA,YAAA;AAIE,IAAA,SAAA,QAAA,CAAiC,OAAU,EAAA;AACzC,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;KACzB;AAED,IAAA,QAAA,CAAA,SAAA,CAAA,SAAS,GAAT,YAAA;;QAAU,IAA6B,IAAA,GAAA,EAAA,CAAA;aAA7B,IAA6B,EAAA,GAAA,CAAA,EAA7B,EAA6B,GAAA,SAAA,CAAA,MAAA,EAA7B,EAA6B,EAAA,EAAA;YAA7B,IAA6B,CAAA,EAAA,CAAA,GAAA,SAAA,CAAA,EAAA,CAAA,CAAA;;QACrC,OAAO,CAAA,EAAA,GAAA,IAAI,CAAC,QAAQ,EAAC,GAAG,CAAI,KAAA,CAAA,EAAA,EAAA,IAAI,CAAE,CAAA;KACnC,CAAA;AATU,IAAA,QAAA,CAAA,IAAA,GAAA,SAAA,gBAAA,CAAA,CAAA,EAAA,EAAA,OAAA,KAAA,CAAA,IAAA,QAAQ,uBAGC,WAAW,EAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA;yEAHpB,QAAQ,EAAA,IAAA,EAAA,KAAA,EAAA,CAAA,CAAA;AALrB,IAAA,OAAA,QAAA,CAAA;AAeC,CAXD,EAWC,EAAA;uFAVY,QAAQ,EAAA,CAAA;cADpB,IAAI;AAAC,QAAA,IAAA,EAAA,CAAA,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;;sBAIpB,MAAM;uBAAC,WAAW,CAAA;;AASjC,IAAA,YAAA,kBAAA,YAAA;AAIE,IAAA,SAAA,YAAA,CAAiC,OAAU,EAAA;AACzC,QAA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AA;cAD1B,UAAU;;sBAII,MAAM;uBAAC,WAAW,CAAA;;;;;"}
@@ -1,86 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Pipe, Inject, NgModule, Injectable } from '@angular/core';
3
- import { PureAbility } from '@casl/ability';
4
- import { Observable } from 'rxjs';
5
-
6
- class AblePipe {
7
- constructor(ability) {
8
- this._ability = ability;
9
- }
10
- transform(...args) {
11
- return this._ability.can(...args);
12
- }
13
- }
14
- AblePipe.ɵfac = function AblePipe_Factory(t) { return new (t || AblePipe)(i0.ɵɵdirectiveInject(PureAbility, 16)); };
15
- AblePipe.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "able", type: AblePipe, pure: false });
16
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AblePipe, [{
17
- type: Pipe,
18
- args: [{ name: 'able', pure: false }]
19
- }], function () { return [{ type: undefined, decorators: [{
20
- type: Inject,
21
- args: [PureAbility]
22
- }] }]; }, null); })();
23
- class AblePurePipe {
24
- constructor(ability) {
25
- this._ability = ability;
26
- }
27
- // TODO: `Observable` can be removed after https://github.com/angular/angular/issues/15041
28
- transform(...args) {
29
- return new Observable((s) => {
30
- const emit = () => s.next(this._ability.can(...args));
31
- emit();
32
- return this._ability.on('updated', emit);
33
- });
34
- }
35
- }
36
- AblePurePipe.ɵfac = function AblePurePipe_Factory(t) { return new (t || AblePurePipe)(i0.ɵɵdirectiveInject(PureAbility, 16)); };
37
- AblePurePipe.ɵpipe = /*@__PURE__*/ i0.ɵɵdefinePipe({ name: "ablePure", type: AblePurePipe, pure: true });
38
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AblePurePipe, [{
39
- type: Pipe,
40
- args: [{ name: 'ablePure' }]
41
- }], function () { return [{ type: undefined, decorators: [{
42
- type: Inject,
43
- args: [PureAbility]
44
- }] }]; }, null); })();
45
-
46
- class AbilityModule {
47
- }
48
- AbilityModule.ɵfac = function AbilityModule_Factory(t) { return new (t || AbilityModule)(); };
49
- AbilityModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: AbilityModule });
50
- AbilityModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({});
51
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AbilityModule, [{
52
- type: NgModule,
53
- args: [{
54
- declarations: [
55
- AblePipe,
56
- AblePurePipe,
57
- ],
58
- exports: [
59
- AblePipe,
60
- AblePurePipe,
61
- ],
62
- }]
63
- }], null, null); })();
64
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(AbilityModule, { declarations: [AblePipe,
65
- AblePurePipe], exports: [AblePipe,
66
- AblePurePipe] }); })();
67
-
68
- class AbilityService {
69
- constructor(ability) {
70
- this.ability$ = new Observable((observer) => {
71
- observer.next(ability);
72
- return ability.on('updated', () => observer.next(ability));
73
- });
74
- }
75
- }
76
- AbilityService.ɵfac = function AbilityService_Factory(t) { return new (t || AbilityService)(i0.ɵɵinject(PureAbility)); };
77
- AbilityService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AbilityService, factory: AbilityService.ɵfac });
78
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AbilityService, [{
79
- type: Injectable
80
- }], function () { return [{ type: undefined, decorators: [{
81
- type: Inject,
82
- args: [PureAbility]
83
- }] }]; }, null); })();
84
-
85
- export { AbilityModule, AbilityService, AblePipe, AblePurePipe };
86
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/pipes.ts","../../src/AbilityModule.ts","../../src/AbilityService.ts"],"sourcesContent":["import { Pipe, Inject, PipeTransform } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Pipe({ name: 'able', pure: false })\nexport class AblePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n transform(...args: Parameters<T['can']>): boolean {\n return this._ability.can(...args);\n }\n}\n\n@Pipe({ name: 'ablePure' })\nexport class AblePurePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n // TODO: `Observable` can be removed after https://github.com/angular/angular/issues/15041\n transform(...args: Parameters<T['can']>): Observable<boolean> {\n return new Observable((s) => {\n const emit = () => s.next(this._ability.can(...args));\n emit();\n return this._ability.on('updated', emit);\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { AblePipe, AblePurePipe } from './pipes';\n\n@NgModule({\n declarations: [\n AblePipe,\n AblePurePipe,\n ],\n exports: [\n AblePipe,\n AblePurePipe,\n ],\n})\nexport class AbilityModule {\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Injectable()\nexport class AbilityService<T extends AnyAbility> {\n readonly ability$: Observable<T>;\n\n constructor(@Inject(PureAbility) ability: T) {\n this.ability$ = new Observable((observer) => {\n observer.next(ability);\n return ability.on('updated', () => observer.next(ability));\n });\n }\n}\n"],"names":[],"mappings":";;;;;AAIA,MACa,QAAQ,CAAA;AAGnB,IAAA,WAAA,CAAiC,OAAU,EAAA;AACzC,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;KACzB;IAED,SAAS,CAAC,GAAG,IAA0B,EAAA;QACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;KACnC;;AATU,QAAA,CAAA,IAAA,GAAA,SAAA,gBAAA,CAAA,CAAA,EAAA,EAAA,OAAA,KAAA,CAAA,IAAA,QAAQ,uBAGC,WAAW,EAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA;qEAHpB,QAAQ,EAAA,IAAA,EAAA,KAAA,EAAA,CAAA,CA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QAAQ;oBACR,YAAY;AACb,iBAAA;AACF,aAAA,CAAA;;AACY,CAAA,YAAA,EAAA,CAAA,OAAA,SAAA,KAAA,WAAA,IAAA,SAAA,KAAA,EAAA,CAAA,kBAAA,CAAA,aAAa,mBARtB,QAAQ;AACR,QAAA,YAAY,aAGZ,QAAQ;QACR,YAAY,CAAA,EAAA,CAAA,CAAA,EAAA,GAAA;;ACNhB,MACa,cAAc,CAAA;AAGzB,IAAA,WAAA,CAAiC,OAAU,EAAA;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,UAAU,CAAC,CAAC,QAAQ,KAAI;AAC1C,YAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACvB,YAAA,OAAO,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7D,SAAC,CAAC,CAAC;KACJ;;AARU,cAAA,CAAA,IAAA,GAAA,SAAA,sBAAA,CAAA,CAAA,EAAA,EAAA,OAAA,KAAA,CAAA,IAAA,cAAc,cAGL,WAAW,CAAA,CAAA,CAAA,EAAA,CAAA;AAHpB,cAAA,CAAA,KAAA,iBAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,KAAA,EAAA,cAAc,WAAd,cAAc,CAAA,IAAA,EAAA,CAAA,CAAA;uFAAd,cAAc,EAAA,CAAA;cAD1B,UAAU;;sBAII,MAAM;uBAAC,WAAW,CAAA;;;;;"}
@@ -1,7 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- import * as i1 from "./pipes";
3
- export declare class AbilityModule {
4
- static ɵfac: i0.ɵɵFactoryDeclaration<AbilityModule, never>;
5
- static ɵmod: i0.ɵɵNgModuleDeclaration<AbilityModule, [typeof i1.AblePipe, typeof i1.AblePurePipe], never, [typeof i1.AblePipe, typeof i1.AblePurePipe]>;
6
- static ɵinj: i0.ɵɵInjectorDeclaration<AbilityModule>;
7
- }
@@ -1,9 +0,0 @@
1
- import { AnyAbility } from '@casl/ability';
2
- import { Observable } from 'rxjs';
3
- import * as i0 from "@angular/core";
4
- export declare class AbilityService<T extends AnyAbility> {
5
- readonly ability$: Observable<T>;
6
- constructor(ability: T);
7
- static ɵfac: i0.ɵɵFactoryDeclaration<AbilityService<any>, never>;
8
- static ɵprov: i0.ɵɵInjectableDeclaration<AbilityService<any>>;
9
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- /// <amd-module name="@casl/angular" />
5
- export * from './public';
@@ -1,18 +0,0 @@
1
- import { PipeTransform } from '@angular/core';
2
- import { AnyAbility } from '@casl/ability';
3
- import { Observable } from 'rxjs';
4
- import * as i0 from "@angular/core";
5
- export declare class AblePipe<T extends AnyAbility> implements PipeTransform {
6
- private _ability;
7
- constructor(ability: T);
8
- transform(...args: Parameters<T['can']>): boolean;
9
- static ɵfac: i0.ɵɵFactoryDeclaration<AblePipe<any>, never>;
10
- static ɵpipe: i0.ɵɵPipeDeclaration<AblePipe<any>, "able", false>;
11
- }
12
- export declare class AblePurePipe<T extends AnyAbility> implements PipeTransform {
13
- private _ability;
14
- constructor(ability: T);
15
- transform(...args: Parameters<T['can']>): Observable<boolean>;
16
- static ɵfac: i0.ɵɵFactoryDeclaration<AblePurePipe<any>, never>;
17
- static ɵpipe: i0.ɵɵPipeDeclaration<AblePurePipe<any>, "ablePure", false>;
18
- }
@@ -1,3 +0,0 @@
1
- export * from './pipes';
2
- export * from './AbilityModule';
3
- export * from './AbilityService';
package/dist/umd/index.js DELETED
@@ -1,130 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@casl/ability'), require('rxjs')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@casl/ability', 'rxjs'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.casl = global.casl || {}, global.casl.ng = {}), global.ng.core, global.casl, global.rxjs));
5
- })(this, (function (exports, i0, ability, rxjs) { 'use strict';
6
-
7
- function _interopNamespaceDefault(e) {
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () { return e[k]; }
16
- });
17
- }
18
- });
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
-
24
- var i0__namespace = /*#__PURE__*/_interopNamespaceDefault(i0);
25
-
26
- var AblePipe = /** @class */ (function () {
27
- function AblePipe(ability) {
28
- this._ability = ability;
29
- }
30
- AblePipe.prototype.transform = function () {
31
- var _a;
32
- var args = [];
33
- for (var _i = 0; _i < arguments.length; _i++) {
34
- args[_i] = arguments[_i];
35
- }
36
- return (_a = this._ability).can.apply(_a, args);
37
- };
38
- AblePipe.ɵfac = function AblePipe_Factory(t) { return new (t || AblePipe)(i0__namespace.ɵɵdirectiveInject(ability.PureAbility, 16)); };
39
- AblePipe.ɵpipe = /*@__PURE__*/ i0__namespace.ɵɵdefinePipe({ name: "able", type: AblePipe, pure: false });
40
- return AblePipe;
41
- }());
42
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(AblePipe, [{
43
- type: i0.Pipe,
44
- args: [{ name: 'able', pure: false }]
45
- }], function () { return [{ type: undefined, decorators: [{
46
- type: i0.Inject,
47
- args: [ability.PureAbility]
48
- }] }]; }, null); })();
49
- var AblePurePipe = /** @class */ (function () {
50
- function AblePurePipe(ability) {
51
- this._ability = ability;
52
- }
53
- // TODO: `Observable` can be removed after https://github.com/angular/angular/issues/15041
54
- AblePurePipe.prototype.transform = function () {
55
- var _this = this;
56
- var args = [];
57
- for (var _i = 0; _i < arguments.length; _i++) {
58
- args[_i] = arguments[_i];
59
- }
60
- return new rxjs.Observable(function (s) {
61
- var emit = function () {
62
- var _a;
63
- return s.next((_a = _this._ability).can.apply(_a, args));
64
- };
65
- emit();
66
- return _this._ability.on('updated', emit);
67
- });
68
- };
69
- AblePurePipe.ɵfac = function AblePurePipe_Factory(t) { return new (t || AblePurePipe)(i0__namespace.ɵɵdirectiveInject(ability.PureAbility, 16)); };
70
- AblePurePipe.ɵpipe = /*@__PURE__*/ i0__namespace.ɵɵdefinePipe({ name: "ablePure", type: AblePurePipe, pure: true });
71
- return AblePurePipe;
72
- }());
73
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(AblePurePipe, [{
74
- type: i0.Pipe,
75
- args: [{ name: 'ablePure' }]
76
- }], function () { return [{ type: undefined, decorators: [{
77
- type: i0.Inject,
78
- args: [ability.PureAbility]
79
- }] }]; }, null); })();
80
-
81
- var AbilityModule = /** @class */ (function () {
82
- function AbilityModule() {
83
- }
84
- AbilityModule.ɵfac = function AbilityModule_Factory(t) { return new (t || AbilityModule)(); };
85
- AbilityModule.ɵmod = /*@__PURE__*/ i0__namespace.ɵɵdefineNgModule({ type: AbilityModule });
86
- AbilityModule.ɵinj = /*@__PURE__*/ i0__namespace.ɵɵdefineInjector({});
87
- return AbilityModule;
88
- }());
89
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(AbilityModule, [{
90
- type: i0.NgModule,
91
- args: [{
92
- declarations: [
93
- AblePipe,
94
- AblePurePipe,
95
- ],
96
- exports: [
97
- AblePipe,
98
- AblePurePipe,
99
- ],
100
- }]
101
- }], null, null); })();
102
- (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0__namespace.ɵɵsetNgModuleScope(AbilityModule, { declarations: [AblePipe,
103
- AblePurePipe], exports: [AblePipe,
104
- AblePurePipe] }); })();
105
-
106
- var AbilityService = /** @class */ (function () {
107
- function AbilityService(ability) {
108
- this.ability$ = new rxjs.Observable(function (observer) {
109
- observer.next(ability);
110
- return ability.on('updated', function () { return observer.next(ability); });
111
- });
112
- }
113
- AbilityService.ɵfac = function AbilityService_Factory(t) { return new (t || AbilityService)(i0__namespace.ɵɵinject(ability.PureAbility)); };
114
- AbilityService.ɵprov = /*@__PURE__*/ i0__namespace.ɵɵdefineInjectable({ token: AbilityService, factory: AbilityService.ɵfac });
115
- return AbilityService;
116
- }());
117
- (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(AbilityService, [{
118
- type: i0.Injectable
119
- }], function () { return [{ type: undefined, decorators: [{
120
- type: i0.Inject,
121
- args: [ability.PureAbility]
122
- }] }]; }, null); })();
123
-
124
- exports.AbilityModule = AbilityModule;
125
- exports.AbilityService = AbilityService;
126
- exports.AblePipe = AblePipe;
127
- exports.AblePurePipe = AblePurePipe;
128
-
129
- }));
130
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/pipes.ts","../../src/AbilityModule.ts","../../src/AbilityService.ts"],"sourcesContent":["import { Pipe, Inject, PipeTransform } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Pipe({ name: 'able', pure: false })\nexport class AblePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n transform(...args: Parameters<T['can']>): boolean {\n return this._ability.can(...args);\n }\n}\n\n@Pipe({ name: 'ablePure' })\nexport class AblePurePipe<T extends AnyAbility> implements PipeTransform {\n private _ability: T;\n\n constructor(@Inject(PureAbility) ability: T) {\n this._ability = ability;\n }\n\n // TODO: `Observable` can be removed after https://github.com/angular/angular/issues/15041\n transform(...args: Parameters<T['can']>): Observable<boolean> {\n return new Observable((s) => {\n const emit = () => s.next(this._ability.can(...args));\n emit();\n return this._ability.on('updated', emit);\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { AblePipe, AblePurePipe } from './pipes';\n\n@NgModule({\n declarations: [\n AblePipe,\n AblePurePipe,\n ],\n exports: [\n AblePipe,\n AblePurePipe,\n ],\n})\nexport class AbilityModule {\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { PureAbility, AnyAbility } from '@casl/ability';\nimport { Observable } from 'rxjs';\n\n@Injectable()\nexport class AbilityService<T extends AnyAbility> {\n readonly ability$: Observable<T>;\n\n constructor(@Inject(PureAbility) ability: T) {\n this.ability$ = new Observable((observer) => {\n observer.next(ability);\n return ability.on('updated', () => observer.next(ability));\n });\n }\n}\n"],"names":["PureAbility","Pipe","Inject","Observable","NgModule","i0","Injectable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,QAAA,QAAA,kBAAA,YAAA;IAIE,IAAA,SAAA,QAAA,CAAiC,OAAU,EAAA;IACzC,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;SACzB;IAED,IAAA,QAAA,CAAA,SAAA,CAAA,SAAS,GAAT,YAAA;;YAAU,IAA6B,IAAA,GAAA,EAAA,CAAA;iBAA7B,IAA6B,EAAA,GAAA,CAAA,EAA7B,EAA6B,GAAA,SAAA,CAAA,MAAA,EAA7B,EAA6B,EAAA,EAAA;gBAA7B,IAA6B,CAAA,EAAA,CAAA,GAAA,SAAA,CAAA,EAAA,CAAA,CAAA;;YACrC,OAAO,CAAA,EAAA,GAAA,IAAI,CAAC,QAAQ,EAAC,GAAG,CAAI,KAAA,CAAA,EAAA,EAAA,IAAI,CAAE,CAAA;SACnC,CAAA;IATU,IAAA,QAAA,CAAA,IAAA,GAAA,SAAA,gBAAA,CAAA,CAAA,EAAA,EAAA,OAAA,KAAA,CAAA,IAAA,QAAQ,kCAGCA,mBAAW,EAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA;wFAHpB,QAAQ,EAAA,IAAA,EAAA,KAAA,EAAA,CAAA,CAAA;IALrB,IAAA,OAAA,QAAA,CAAA;IAeC,CAXD,EAWC,EAAA;sGAVY,QAAQ,EAAA,CAAA;kBADpBC,OAAI;IAAC,QAAA,IAAA,EAAA,CAAA,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,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