@casl/angular
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -5,2 +5,9 @@ # Change Log | ||
## [3.0.3](https://github.com/stalniy/casl/compare/@casl/angular@3.0.2...@casl/angular@3.0.3) (2020-02-21) | ||
### Bug Fixes | ||
* **angular:** reverts back prerelease hook ([1fc60c2](https://github.com/stalniy/casl/commit/1fc60c248d7e837fae39eb760cb308a73959b59d)), closes [#266](https://github.com/stalniy/casl/issues/266) | ||
## [3.0.2](https://github.com/stalniy/casl/compare/@casl/angular@3.0.1...@casl/angular@3.0.2) (2020-02-20) | ||
@@ -7,0 +14,0 @@ |
@@ -1,61 +0,38 @@ | ||
import { ɵɵdefineDirective, ɵɵdirectiveInject, ɵɵinjectPipeChangeDetectorRef, ɵɵdefinePipe, ɵɵinvalidFactory, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope } from '@angular/core'; | ||
import { ɵɵdirectiveInject, ɵɵinjectPipeChangeDetectorRef, ɵɵdefinePipe, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope } from '@angular/core'; | ||
import { Ability } from '@casl/ability'; | ||
var AbilityPipe = | ||
var noop = function noop() {}; // TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041 | ||
var CanPipe = | ||
/*#__PURE__*/ | ||
function () { | ||
function AbilityPipe(ability, cd) { | ||
this._ability = ability; | ||
this._cd = cd; | ||
function CanPipe(ability, cd) { | ||
this.ability = ability; | ||
this.cd = cd; | ||
this.unsubscribeFromAbility = noop; | ||
} | ||
var _proto = AbilityPipe.prototype; | ||
var _proto = CanPipe.prototype; | ||
_proto.transform = function transform() { | ||
var _this = this, | ||
_this$_ability; | ||
_proto.transform = function transform(resource, action, field) { | ||
var _this = this; | ||
if (!this._unsubscribeFromAbility) { | ||
this._unsubscribeFromAbility = this._ability.on('updated', function () { | ||
return _this._cd.markForCheck(); | ||
if (this.unsubscribeFromAbility === noop) { | ||
this.unsubscribeFromAbility = this.ability.on('updated', function () { | ||
return _this.cd.markForCheck(); | ||
}); | ||
} | ||
return (_this$_ability = this._ability).can.apply(_this$_ability, arguments); | ||
return this.can(action, resource, field); | ||
}; | ||
_proto.ngOnDestroy = function ngOnDestroy() { | ||
if (this._unsubscribeFromAbility) { | ||
this._unsubscribeFromAbility(); | ||
} | ||
_proto.can = function can(action, subject, field) { | ||
return this.ability.can(action, subject, field); | ||
}; | ||
return AbilityPipe; | ||
}(); | ||
AbilityPipe.ɵfac = function AbilityPipe_Factory(t) { | ||
ɵɵinvalidFactory(); | ||
}; | ||
AbilityPipe.ɵdir = ɵɵdefineDirective({ | ||
type: AbilityPipe | ||
}); // TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041 | ||
var CanPipe = | ||
/*#__PURE__*/ | ||
function () { | ||
function CanPipe(ability, cd) { | ||
this.pipe = new AbilityPipe(ability, cd); | ||
} | ||
var _proto2 = CanPipe.prototype; | ||
_proto2.transform = function transform(subject, action, field) { | ||
return this.pipe.transform(action, subject, field); | ||
_proto.ngOnDestroy = function ngOnDestroy() { | ||
this.unsubscribeFromAbility(); | ||
}; | ||
_proto2.ngOnDestroy = function ngOnDestroy() { | ||
this.pipe.ngOnDestroy(); | ||
}; | ||
return CanPipe; | ||
@@ -74,34 +51,5 @@ }(); | ||
var AblePipe = | ||
/*#__PURE__*/ | ||
function () { | ||
function AblePipe(ability, cd) { | ||
this.pipe = new AbilityPipe(ability, cd); | ||
} | ||
var _proto3 = AblePipe.prototype; | ||
_proto3.transform = function transform() { | ||
var _this$pipe; | ||
return (_this$pipe = this.pipe).transform.apply(_this$pipe, arguments); | ||
}; | ||
_proto3.ngOnDestroy = function ngOnDestroy() { | ||
this.pipe.ngOnDestroy(); | ||
}; | ||
return AblePipe; | ||
}(); | ||
AblePipe.ɵfac = function AblePipe_Factory(t) { | ||
return new (t || AblePipe)(ɵɵdirectiveInject(Ability), ɵɵinjectPipeChangeDetectorRef()); | ||
}; | ||
AblePipe.ɵpipe = ɵɵdefinePipe({ | ||
name: "able", | ||
type: AblePipe, | ||
pure: false | ||
}); | ||
function createAbility() { | ||
return new Ability([]); | ||
} | ||
var AbilityModule = | ||
@@ -117,5 +65,3 @@ /*#__PURE__*/ | ||
provide: Ability, | ||
useFactory: function useFactory() { | ||
return new Ability([]); | ||
} | ||
useFactory: createAbility | ||
}] | ||
@@ -138,8 +84,8 @@ }; | ||
(typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(AbilityModule, { | ||
declarations: [CanPipe, AblePipe], | ||
exports: [CanPipe, AblePipe] | ||
declarations: [CanPipe], | ||
exports: [CanPipe] | ||
}); | ||
})(); | ||
export { AbilityModule, AblePipe, CanPipe }; | ||
export { AbilityModule, CanPipe, createAbility }; | ||
//# sourceMappingURL=index.js.map |
@@ -1,45 +0,28 @@ | ||
import { ɵɵdefineDirective, ɵɵdirectiveInject, ɵɵinjectPipeChangeDetectorRef, ɵɵdefinePipe, ɵɵinvalidFactory, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope } from '@angular/core'; | ||
import { ɵɵdirectiveInject, ɵɵinjectPipeChangeDetectorRef, ɵɵdefinePipe, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope } from '@angular/core'; | ||
import { Ability } from '@casl/ability'; | ||
class AbilityPipe { | ||
constructor(ability, cd) { | ||
this._ability = ability; | ||
this._cd = cd; | ||
} | ||
const noop = () => {}; // TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041 | ||
transform(...args) { | ||
if (!this._unsubscribeFromAbility) { | ||
this._unsubscribeFromAbility = this._ability.on('updated', () => this._cd.markForCheck()); | ||
} | ||
return this._ability.can(...args); | ||
class CanPipe { | ||
constructor(ability, cd) { | ||
this.ability = ability; | ||
this.cd = cd; | ||
this.unsubscribeFromAbility = noop; | ||
} | ||
ngOnDestroy() { | ||
if (this._unsubscribeFromAbility) { | ||
this._unsubscribeFromAbility(); | ||
transform(resource, action, field) { | ||
if (this.unsubscribeFromAbility === noop) { | ||
this.unsubscribeFromAbility = this.ability.on('updated', () => this.cd.markForCheck()); | ||
} | ||
} | ||
} | ||
AbilityPipe.ɵfac = function AbilityPipe_Factory(t) { | ||
ɵɵinvalidFactory(); | ||
}; | ||
AbilityPipe.ɵdir = ɵɵdefineDirective({ | ||
type: AbilityPipe | ||
}); // TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041 | ||
class CanPipe { | ||
constructor(ability, cd) { | ||
this.pipe = new AbilityPipe(ability, cd); | ||
return this.can(action, resource, field); | ||
} | ||
transform(subject, action, field) { | ||
return this.pipe.transform(action, subject, field); | ||
can(action, subject, field) { | ||
return this.ability.can(action, subject, field); | ||
} | ||
ngOnDestroy() { | ||
this.pipe.ngOnDestroy(); | ||
this.unsubscribeFromAbility(); | ||
} | ||
@@ -59,27 +42,5 @@ | ||
class AblePipe { | ||
constructor(ability, cd) { | ||
this.pipe = new AbilityPipe(ability, cd); | ||
} | ||
transform(...args) { | ||
return this.pipe.transform(...args); | ||
} | ||
ngOnDestroy() { | ||
this.pipe.ngOnDestroy(); | ||
} | ||
function createAbility() { | ||
return new Ability([]); | ||
} | ||
AblePipe.ɵfac = function AblePipe_Factory(t) { | ||
return new (t || AblePipe)(ɵɵdirectiveInject(Ability), ɵɵinjectPipeChangeDetectorRef()); | ||
}; | ||
AblePipe.ɵpipe = ɵɵdefinePipe({ | ||
name: "able", | ||
type: AblePipe, | ||
pure: false | ||
}); | ||
class AbilityModule { | ||
@@ -91,3 +52,3 @@ static forRoot() { | ||
provide: Ability, | ||
useFactory: () => new Ability([]) | ||
useFactory: createAbility | ||
}] | ||
@@ -109,8 +70,8 @@ }; | ||
(typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(AbilityModule, { | ||
declarations: [CanPipe, AblePipe], | ||
exports: [CanPipe, AblePipe] | ||
declarations: [CanPipe], | ||
exports: [CanPipe] | ||
}); | ||
})(); | ||
export { AbilityModule, AblePipe, CanPipe }; | ||
export { AbilityModule, CanPipe, createAbility }; | ||
//# sourceMappingURL=index.js.map |
import { ChangeDetectorRef } from '@angular/core'; | ||
import { Unsubscribe, AnyAbility, AbilityParameters } from '@casl/ability'; | ||
import { Ability } from '@casl/ability'; | ||
import * as i0 from "@angular/core"; | ||
declare class AbilityPipe<T extends AnyAbility> { | ||
protected _unsubscribeFromAbility?: Unsubscribe; | ||
private _ability; | ||
private _cd; | ||
constructor(ability: T, cd: ChangeDetectorRef); | ||
transform(...args: Parameters<T['can']>): boolean; | ||
export declare class CanPipe { | ||
protected ability: Ability; | ||
protected cd: ChangeDetectorRef; | ||
protected unsubscribeFromAbility: Function; | ||
constructor(ability: Ability, cd: ChangeDetectorRef); | ||
transform(resource: any, action: string, field?: string): boolean; | ||
can(action: string, subject: any, field?: string): boolean; | ||
ngOnDestroy(): void; | ||
static ɵfac: i0.ɵɵFactoryDef<AbilityPipe<any>>; | ||
static ɵdir: i0.ɵɵDirectiveDefWithMeta<AbilityPipe<any>, never, never, {}, {}, never>; | ||
static ɵfac: i0.ɵɵFactoryDef<CanPipe>; | ||
static ɵpipe: i0.ɵɵPipeDefWithMeta<CanPipe, "can">; | ||
} | ||
export declare class CanPipe<T extends AnyAbility> { | ||
protected pipe: AbilityPipe<T>; | ||
constructor(ability: T, cd: ChangeDetectorRef); | ||
transform(subject: AbilityParameters<T>['subject'], action: AbilityParameters<T>['action'], field?: string): boolean; | ||
ngOnDestroy(): void; | ||
static ɵfac: i0.ɵɵFactoryDef<CanPipe<any>>; | ||
static ɵpipe: i0.ɵɵPipeDefWithMeta<CanPipe<any>, "can">; | ||
} | ||
export declare class AblePipe<T extends AnyAbility> { | ||
protected pipe: AbilityPipe<T>; | ||
constructor(ability: T, cd: ChangeDetectorRef); | ||
transform(...args: Parameters<T['can']>): boolean; | ||
ngOnDestroy(): void; | ||
static ɵfac: i0.ɵɵFactoryDef<AblePipe<any>>; | ||
static ɵpipe: i0.ɵɵPipeDefWithMeta<AblePipe<any>, "able">; | ||
} | ||
export {}; |
import { ModuleWithProviders } from '@angular/core'; | ||
import { AnyAbility } from '@casl/ability'; | ||
import { Ability } from '@casl/ability'; | ||
import * as i0 from "@angular/core"; | ||
import * as i1 from "./can"; | ||
export declare function createAbility(): Ability; | ||
export declare class AbilityModule { | ||
static forRoot<T extends AnyAbility>(): ModuleWithProviders<AbilityModule>; | ||
static ɵmod: i0.ɵɵNgModuleDefWithMeta<AbilityModule, [typeof i1.CanPipe, typeof i1.AblePipe], never, [typeof i1.CanPipe, typeof i1.AblePipe]>; | ||
static forRoot(): ModuleWithProviders<AbilityModule>; | ||
static ɵmod: i0.ɵɵNgModuleDefWithMeta<AbilityModule, [typeof i1.CanPipe], never, [typeof i1.CanPipe]>; | ||
static ɵinj: i0.ɵɵInjectorDef<AbilityModule>; | ||
} |
@@ -5,61 +5,38 @@ (function (global, factory) { | ||
(global = global || self, factory((global.casl = global.casl || {}, global.casl.ng = {}), global.ng.core, global.casl)); | ||
}(this, (function (exports, i0, ability) { 'use strict'; | ||
}(this, (function (exports, i0, i1) { 'use strict'; | ||
var AbilityPipe = | ||
var noop = function noop() {}; // TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041 | ||
var CanPipe = | ||
/*#__PURE__*/ | ||
function () { | ||
function AbilityPipe(ability, cd) { | ||
this._ability = ability; | ||
this._cd = cd; | ||
function CanPipe(ability, cd) { | ||
this.ability = ability; | ||
this.cd = cd; | ||
this.unsubscribeFromAbility = noop; | ||
} | ||
var _proto = AbilityPipe.prototype; | ||
var _proto = CanPipe.prototype; | ||
_proto.transform = function transform() { | ||
var _this = this, | ||
_this$_ability; | ||
_proto.transform = function transform(resource, action, field) { | ||
var _this = this; | ||
if (!this._unsubscribeFromAbility) { | ||
this._unsubscribeFromAbility = this._ability.on('updated', function () { | ||
return _this._cd.markForCheck(); | ||
if (this.unsubscribeFromAbility === noop) { | ||
this.unsubscribeFromAbility = this.ability.on('updated', function () { | ||
return _this.cd.markForCheck(); | ||
}); | ||
} | ||
return (_this$_ability = this._ability).can.apply(_this$_ability, arguments); | ||
return this.can(action, resource, field); | ||
}; | ||
_proto.ngOnDestroy = function ngOnDestroy() { | ||
if (this._unsubscribeFromAbility) { | ||
this._unsubscribeFromAbility(); | ||
} | ||
_proto.can = function can(action, subject, field) { | ||
return this.ability.can(action, subject, field); | ||
}; | ||
return AbilityPipe; | ||
}(); | ||
AbilityPipe.ɵfac = function AbilityPipe_Factory(t) { | ||
i0.ɵɵinvalidFactory(); | ||
}; | ||
AbilityPipe.ɵdir = i0.ɵɵdefineDirective({ | ||
type: AbilityPipe | ||
}); // TODO: `pure` can be removed after https://github.com/angular/angular/issues/15041 | ||
var CanPipe = | ||
/*#__PURE__*/ | ||
function () { | ||
function CanPipe(ability, cd) { | ||
this.pipe = new AbilityPipe(ability, cd); | ||
} | ||
var _proto2 = CanPipe.prototype; | ||
_proto2.transform = function transform(subject, action, field) { | ||
return this.pipe.transform(action, subject, field); | ||
_proto.ngOnDestroy = function ngOnDestroy() { | ||
this.unsubscribeFromAbility(); | ||
}; | ||
_proto2.ngOnDestroy = function ngOnDestroy() { | ||
this.pipe.ngOnDestroy(); | ||
}; | ||
return CanPipe; | ||
@@ -69,3 +46,3 @@ }(); | ||
CanPipe.ɵfac = function CanPipe_Factory(t) { | ||
return new (t || CanPipe)(i0.ɵɵdirectiveInject(ability.Ability), i0.ɵɵinjectPipeChangeDetectorRef()); | ||
return new (t || CanPipe)(i0.ɵɵdirectiveInject(i1.Ability), i0.ɵɵinjectPipeChangeDetectorRef()); | ||
}; | ||
@@ -79,34 +56,5 @@ | ||
var AblePipe = | ||
/*#__PURE__*/ | ||
function () { | ||
function AblePipe(ability, cd) { | ||
this.pipe = new AbilityPipe(ability, cd); | ||
} | ||
var _proto3 = AblePipe.prototype; | ||
_proto3.transform = function transform() { | ||
var _this$pipe; | ||
return (_this$pipe = this.pipe).transform.apply(_this$pipe, arguments); | ||
}; | ||
_proto3.ngOnDestroy = function ngOnDestroy() { | ||
this.pipe.ngOnDestroy(); | ||
}; | ||
return AblePipe; | ||
}(); | ||
AblePipe.ɵfac = function AblePipe_Factory(t) { | ||
return new (t || AblePipe)(i0.ɵɵdirectiveInject(ability.Ability), i0.ɵɵinjectPipeChangeDetectorRef()); | ||
}; | ||
AblePipe.ɵpipe = i0.ɵɵdefinePipe({ | ||
name: "able", | ||
type: AblePipe, | ||
pure: false | ||
}); | ||
function createAbility() { | ||
return new i1.Ability([]); | ||
} | ||
var AbilityModule = | ||
@@ -121,6 +69,4 @@ /*#__PURE__*/ | ||
providers: [{ | ||
provide: ability.Ability, | ||
useFactory: function useFactory() { | ||
return new ability.Ability([]); | ||
} | ||
provide: i1.Ability, | ||
useFactory: createAbility | ||
}] | ||
@@ -143,4 +89,4 @@ }; | ||
(typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(AbilityModule, { | ||
declarations: [CanPipe, AblePipe], | ||
exports: [CanPipe, AblePipe] | ||
declarations: [CanPipe], | ||
exports: [CanPipe] | ||
}); | ||
@@ -150,4 +96,4 @@ })(); | ||
exports.AbilityModule = AbilityModule; | ||
exports.AblePipe = AblePipe; | ||
exports.CanPipe = CanPipe; | ||
exports.createAbility = createAbility; | ||
@@ -154,0 +100,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "@casl/angular", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Angular module for CASL which makes it easy to add permissions in any Angular application", | ||
@@ -22,3 +22,3 @@ "main": "dist/umd/index.js", | ||
"lint": "node -p -e '`Skip linting for typescript`'", | ||
"prerelease2": "NODE_ENV=production npm run build && npm test", | ||
"prerelease": "NODE_ENV=production npm run build && npm test", | ||
"release": "semantic-release -e ../../tools/semantic-release", | ||
@@ -25,0 +25,0 @@ "postinstall": "node ./tools/exists.js package-lock.json && ngcc || true" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
36190
236
1