@final-hill/decorator-contracts 0.24.0 → 0.24.1
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/CHANGELOG.md +6 -0
- package/README.md +51 -29
- package/dist/assert.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/ClassType.d.ts +4 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -46,15 +46,15 @@ As a dependency run the command:
|
|
|
46
46
|
|
|
47
47
|
You can also use a specific [version](https://www.npmjs.com/package/@final-hill/decorator-contracts):
|
|
48
48
|
|
|
49
|
-
`npm install @final-hill/decorator-contracts@0.
|
|
49
|
+
`npm install @final-hill/decorator-contracts@0.24.1`
|
|
50
50
|
|
|
51
51
|
For use in a webpage:
|
|
52
52
|
|
|
53
53
|
`<script src="https://cdn.skypack.dev/@final-hill/decorator-contracts"></script>`
|
|
54
54
|
|
|
55
|
-
With a specific [version](https://www.npmjs.com/package/@final-hill/decorator-contracts@0.
|
|
55
|
+
With a specific [version](https://www.npmjs.com/package/@final-hill/decorator-contracts@0.24.1):
|
|
56
56
|
|
|
57
|
-
`<script src="https://cdn.skypack.dev/@final-hill/decorator-contracts@0.
|
|
57
|
+
`<script src="https://cdn.skypack.dev/@final-hill/decorator-contracts@0.24.1"></script>`
|
|
58
58
|
|
|
59
59
|
## Usage
|
|
60
60
|
|
|
@@ -375,7 +375,7 @@ Note that the current class or one of its ancestors must have `@Contracted(...)`
|
|
|
375
375
|
When assigned, candidate overrides are identified and an
|
|
376
376
|
error is raised if an associated `@override` is missing for that feature.
|
|
377
377
|
|
|
378
|
-
Static methods including the constructor
|
|
378
|
+
Static methods including the constructor cannot be assigned an `@override`
|
|
379
379
|
decorator. In the future this may be enabled for non-constructor static methods
|
|
380
380
|
but the implications are not clear at present.
|
|
381
381
|
|
|
@@ -502,7 +502,8 @@ const stackContract = new Contract<StackType<any>>({
|
|
|
502
502
|
}
|
|
503
503
|
})
|
|
504
504
|
|
|
505
|
-
|
|
505
|
+
@Contracted(stackContract)
|
|
506
|
+
class Stack<T> implements StackType<T> {
|
|
506
507
|
...
|
|
507
508
|
pop(): T {
|
|
508
509
|
return this.#implementation.pop();
|
|
@@ -517,7 +518,7 @@ In the above example the precondition of executing `pop`
|
|
|
517
518
|
on a stack is that it is not empty. If this assertion fails
|
|
518
519
|
an `AssertionError` is raised.
|
|
519
520
|
|
|
520
|
-
Static features, including the constructor,
|
|
521
|
+
Static features, including the constructor, cannot be assigned a `demands`
|
|
521
522
|
assertion. In the future this may be enabled for non-constructor static methods
|
|
522
523
|
but the implications are not clear at present.
|
|
523
524
|
|
|
@@ -546,6 +547,7 @@ const baseContract = new Contract<Base>({
|
|
|
546
547
|
})
|
|
547
548
|
|
|
548
549
|
const subContract = new Contract<Sub>({
|
|
550
|
+
[extend]: baseContract,
|
|
549
551
|
someMethod: {
|
|
550
552
|
demands(){ ... }
|
|
551
553
|
}
|
|
@@ -569,6 +571,7 @@ class Base {
|
|
|
569
571
|
}
|
|
570
572
|
|
|
571
573
|
const subContract = new Contract<Sub>({
|
|
574
|
+
[extend]: baseContract,
|
|
572
575
|
someMethod: {
|
|
573
576
|
demands(_self, x: number){ return -10 <= x && x <= 20 }
|
|
574
577
|
}
|
|
@@ -609,7 +612,7 @@ class Stack<T> {
|
|
|
609
612
|
|
|
610
613
|
In the above example the post-condition of executing push on a stack is that it is not empty. If this assertion fails an `AssertionError` is raised.
|
|
611
614
|
|
|
612
|
-
Static features, including the constructor,
|
|
615
|
+
Static features, including the constructor, cannot be assigned an `ensures` declaration. In the future this may be enabled for non-constructor static methods but the implications are not clear at present.
|
|
613
616
|
|
|
614
617
|
In addition to the `self` argument there is also an `old` argument which provides access to the values of any getters of the instance before its associated member was executed.
|
|
615
618
|
|
|
@@ -675,13 +678,14 @@ const baseContract = new Contract<Base>({
|
|
|
675
678
|
})
|
|
676
679
|
|
|
677
680
|
const subContract = new Contract<Sub>({
|
|
681
|
+
[extend]: baseContract,
|
|
678
682
|
someMethod: {
|
|
679
683
|
ensures(){ ... }
|
|
680
684
|
}
|
|
681
685
|
})
|
|
682
686
|
```
|
|
683
687
|
|
|
684
|
-
This subcontracted `ensures` declaration
|
|
688
|
+
This subcontracted `ensures` declaration cannot weaken the `ensures` of the base contract. What this means is that the new post-condition will be and-ed with its ancestors. If all of the `ensures` are true then the obligation is considered fulfilled by the author of the feature otherwise an `AssertionError` is raised.
|
|
685
689
|
|
|
686
690
|
```typescript
|
|
687
691
|
const baseContract = new Contract<Base>({
|
|
@@ -696,6 +700,7 @@ class Base {
|
|
|
696
700
|
}
|
|
697
701
|
|
|
698
702
|
const subContract = new Contract<Sub>({
|
|
703
|
+
[extend]: baseContract,
|
|
699
704
|
method: {
|
|
700
705
|
ensures(_self, _old, x: number){ return -10 <= x && x <= 20 }
|
|
701
706
|
}
|
|
@@ -799,8 +804,8 @@ const studentRepositoryContract = new Contract<StudentRepository>({
|
|
|
799
804
|
@Contracted(studentRepositoryContract)
|
|
800
805
|
class StudentRepository {
|
|
801
806
|
...
|
|
802
|
-
getStudent(id: string): Student {
|
|
803
|
-
const data = fetch(`/repos/students/${id}`).then(response => response.json())
|
|
807
|
+
async getStudent(id: string): Student {
|
|
808
|
+
const data = await fetch(`/repos/students/${id}`).then(response => response.json())
|
|
804
809
|
|
|
805
810
|
return new Student(data)
|
|
806
811
|
}
|
|
@@ -854,18 +859,18 @@ class AjaxRequest {
|
|
|
854
859
|
get attempts(): number { return this.#attempts }
|
|
855
860
|
set attempts(value: number) { this.#attempts = value }
|
|
856
861
|
|
|
857
|
-
get(url){
|
|
862
|
+
get(url) {
|
|
858
863
|
if(this.#attempts == 0)
|
|
859
864
|
return this.getFetch(url)
|
|
860
865
|
else if(this.#attempts == 1)
|
|
861
866
|
return this.getXhr(url)
|
|
862
867
|
}
|
|
863
868
|
|
|
864
|
-
getFetch(url) {
|
|
869
|
+
async getFetch(url) {
|
|
865
870
|
return await fetch(url)
|
|
866
871
|
}
|
|
867
872
|
|
|
868
|
-
getXhr(url) {
|
|
873
|
+
async getXhr(url) {
|
|
869
874
|
return await new Promise((resolve, reject) => {
|
|
870
875
|
const xhr = new XMLHttpRequest();
|
|
871
876
|
xhr.open('GET', url);
|
|
@@ -912,7 +917,7 @@ If an error is thrown in the `invariant` then it is raised to the caller.
|
|
|
912
917
|
|
|
913
918
|
If an error is thrown in the `demands` then the error is raised to the caller.
|
|
914
919
|
In this case the `invariant` is not checked because the feature body has not
|
|
915
|
-
been entered and the assertion
|
|
920
|
+
been entered and the assertion cannot modify the state of the class without
|
|
916
921
|
calling another method which is governed by its own contracts.
|
|
917
922
|
|
|
918
923
|
If an error is thrown by the feature body or the `ensures` then
|
|
@@ -922,21 +927,38 @@ starts from the beginning.
|
|
|
922
927
|
If `rescue` throws an error or does not call `retry` then the
|
|
923
928
|
`invariant` is checked before the error is raised to the caller.
|
|
924
929
|
|
|
925
|
-
```
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
930
|
+
```mermaid
|
|
931
|
+
flowchart LR
|
|
932
|
+
|
|
933
|
+
Feature(("obj.feature(...)"))
|
|
934
|
+
Invariant["@invariant"]
|
|
935
|
+
Invariant2["@invariant"]
|
|
936
|
+
Invariant3["@invariant"]
|
|
937
|
+
Demands["@demands"]
|
|
938
|
+
Ensures["@ensures"]
|
|
939
|
+
Rescue["@rescue"]
|
|
940
|
+
Error(("Error"))
|
|
941
|
+
Body["{feature body}"]
|
|
942
|
+
Result(("Result"))
|
|
943
|
+
|
|
944
|
+
Feature --> Invariant
|
|
945
|
+
Invariant -->|throws| Error
|
|
946
|
+
Invariant --> Demands
|
|
947
|
+
Demands -->|throws| Error
|
|
948
|
+
Demands --> Body
|
|
949
|
+
Body -->|throws| Rescue
|
|
950
|
+
Rescue -->|retry| Invariant
|
|
951
|
+
Body -->|returns| Ensures
|
|
952
|
+
Ensures -->|throws| Rescue
|
|
953
|
+
Ensures --> Invariant3
|
|
954
|
+
Invariant3 --> Result
|
|
955
|
+
Rescue --> |throws| Invariant2
|
|
956
|
+
Rescue --> |returns| Invariant2
|
|
957
|
+
Invariant2 --> Error
|
|
958
|
+
|
|
959
|
+
style Error fill:red
|
|
960
|
+
style Result fill:green
|
|
961
|
+
style Rescue fill:darkorange
|
|
940
962
|
```
|
|
941
963
|
|
|
942
964
|
## Further Reading
|
package/dist/assert.d.ts
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
5
5
|
* @see <https://spdx.org/licenses/AGPL-3.0-only.html>
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import { Constructor } from './';
|
|
8
8
|
export default function assert(condition: unknown, message?: string, ErrorConstructor?: Constructor<Error>): asserts condition;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* @see <https://spdx.org/licenses/AGPL-3.0-only.html>
|
|
6
6
|
*/
|
|
7
7
|
import AssertionError from './AssertionError';
|
|
8
|
-
import { Contract, extend, invariant, Invariant, checkedMode, Rescue } from './Contract';
|
|
9
8
|
import Contracted, { innerContract } from './Contracted';
|
|
10
9
|
import override from './override';
|
|
11
10
|
import assert from './assert';
|
|
12
11
|
import implies from './implies';
|
|
13
|
-
export { AssertionError,
|
|
12
|
+
export { AssertionError, Contracted, implies, innerContract, override, assert };
|
|
13
|
+
export { Contract, extend, invariant, Invariant, checkedMode, Rescue } from './Contract';
|
|
14
|
+
export { Constructor, AbstractConstructor, ClassType } from './lib/ClassType';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(this,(()=>(()=>{"use strict";var e={731:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class r extends Error{constructor(e){super(e)}}t.default=r},822:function(e,t,r){var s,n=this&&this.__classPrivateFieldSet||function(e,t,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,r):n?n.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.invariant=t.extend=t.checkedMode=t.Contract=void 0;const o=r(915),i=Symbol("checkedMode"),c=Symbol("invariant"),u=Symbol("extend");t.checkedMode=i,t.invariant=c,t.extend=u;class l{constructor(e=Object.create(null)){var t,r;s.set(this,void 0),this.assertions=Object.create(null),this[u]=e[u],this[i]=null===(t=e[i])||void 0===t||t,n(this,s,null!==(r=e[c])&&void 0!==r?r:o.fnTrue,"f"),Object.keys(e).forEach((t=>{var r,s;const n=e[t];Object.defineProperty(this.assertions,t,{value:{demands:null!==(r=n.demands)&&void 0!==r?r:o.fnTrue,ensures:null!==(s=n.ensures)&&void 0!==s?s:o.fnTrue,rescue:n.rescue,within:n.within}})})),(0,o.deepFreeze)(this.assertions)}get[(s=new WeakMap,c)](){return a(this,s,"f")}}t.Contract=l},879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.innerContract=t.isContracted=void 0;const s=r(915),n=r(607),a=r(860),o=Symbol("isContracted"),i=Symbol("innerContract");t.isContracted=o,t.innerContract=i,t.default=function(e=new n.Contract){return function(t){var r;if((0,n.assert)(!Object.getOwnPropertySymbols(t).includes(o),a.MSG_SINGLE_CONTRACT),!1===e[n.checkedMode])return t;const c=t[i];(0,n.assert)(!c||c&&e[n.extend]instanceof c.constructor,a.MSG_BAD_SUBCONTRACT);class u extends t{constructor(...e){super(...e);const r=this.constructor,o=s.CLASS_REGISTRY.getOrCreate(r);var c;if((0,n.assert)((c=o,this,!Object.entries(Object.getOwnPropertyDescriptors(this)).some((([e,t])=>new s.Feature(c,e,t).isProperty))),a.MSG_NO_PROPERTIES),!o.contractsChecked){let e=o.ancestry().reverse();[...e,o].forEach((e=>{e.contractsChecked||(e.checkOverrides(),e.contractsChecked=!0)})),e=(0,s.takeWhile)(e.reverse(),(e=>e.Class!==t)),[o,...e,s.CLASS_REGISTRY.get(t)].forEach((e=>{e.bindContract(u[i])}))}return(0,s.assertInvariants)(this,u[i]),this}static get[(r=o,i)](){return e}get[i](){return e}}return u[r]=!0,s.CLASS_REGISTRY.getOrCreate(u).contractsChecked=!1,Object.freeze(t),u}}},860:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MSG_BAD_SUBCONTRACT=t.MSG_INVALID_CONTEXT=t.MSG_SINGLE_RETRY=t.MSG_SINGLE_CONTRACT=t.MSG_MISSING_FEATURE=t.MSG_NOT_CONTRACTED=t.MSG_NO_PROPERTIES=t.MSG_DUPLICATE_OVERRIDE=t.MSG_NO_MATCHING_FEATURE=t.MSG_NO_STATIC=t.MSG_INVALID_ARG_LENGTH=t.ASSERTION_FAILED=void 0,t.ASSERTION_FAILED="Assertion failure",t.MSG_INVALID_ARG_LENGTH="An overridden method must have the same number of parameters as its ancestor method",t.MSG_NO_STATIC="Only instance members can be decorated, not static members",t.MSG_NO_MATCHING_FEATURE="This feature does not override an ancestor feature.",t.MSG_DUPLICATE_OVERRIDE="Only a single @override decorator can be assigned to a class member",t.MSG_NO_PROPERTIES="Public properties are forbidden",t.MSG_NOT_CONTRACTED="The current class or one of its ancestors must declare @Contracted(...)",t.MSG_MISSING_FEATURE="The requested feature is not registered",t.MSG_SINGLE_CONTRACT="Only a single @Contracted decorator is allowed per class",t.MSG_SINGLE_RETRY="retry can only be called once",t.MSG_INVALID_CONTEXT="A contracted feature can not be applied to objects of a different base class",t.MSG_BAD_SUBCONTRACT="A sub contract must extend a base contract"},797:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=s(r(731)),a=r(860);t.default=function(e,t=a.ASSERTION_FAILED,r=n.default){if(0==Boolean(e))throw new r(t)}},606:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return!e||t}},607:function(e,t,r){var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.assert=t.override=t.checkedMode=t.extend=t.innerContract=t.invariant=t.implies=t.Contracted=t.Contract=t.AssertionError=void 0;const i=o(r(731));t.AssertionError=i.default;const c=r(822);Object.defineProperty(t,"Contract",{enumerable:!0,get:function(){return c.Contract}}),Object.defineProperty(t,"extend",{enumerable:!0,get:function(){return c.extend}}),Object.defineProperty(t,"invariant",{enumerable:!0,get:function(){return c.invariant}}),Object.defineProperty(t,"checkedMode",{enumerable:!0,get:function(){return c.checkedMode}});const u=a(r(879));t.Contracted=u.default,Object.defineProperty(t,"innerContract",{enumerable:!0,get:function(){return u.innerContract}});const l=o(r(47));t.override=l.default;const d=o(r(797));t.assert=d.default;const f=o(r(606));t.implies=f.default},932:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(915);class n extends WeakMap{getOrCreate(e){return this.has(e)||this.set(e,new s.ClassRegistration(e)),this.get(e)}}const a=new n;t.default=a},359:function(e,t,r){var s,n=this&&this.__classPrivateFieldSet||function(e,t,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,r):n?n.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=r(860),c=r(607),u=r(915),l=o(r(318));function d(e,t,r){return function s(...n){var a,o;const{Class:d}=r;(0,c.assert)(this instanceof d,i.MSG_INVALID_CONTEXT);const f=Reflect.get(this,c.innerContract),h=d.name;if(!f[c.checkedMode])return t.apply(this,n);let _;(0,u.assertInvariants)(this,f),(0,u.assertDemands)(this,f,h,e,n);try{const s=Object.create(null);(0,u.unChecked)(f,(()=>{r.features.forEach((({name:e,hasGetter:t})=>{t&&Object.defineProperty(s,e,{value:this[e]})}))}));const o=null===(a=Reflect.get(f.assertions,e))||void 0===a?void 0:a.within,i=Date.now();_=t.apply(this,n);const d=Date.now();o&&(0,c.assert)(d-i<o,`Timing constraint violated. Constraint: ${o}ms, actual: ${d-i}ms`),(0,l.default)(this,f,h,e,s,n)}catch(t){const r=null===(o=Reflect.get(f.assertions,e))||void 0===o?void 0:o.rescue;if(null==r)throw(0,u.assertInvariants)(this,f),t;let n=!1;if((0,u.unChecked)(f,(()=>{r.call(this,this,t,[],((...e)=>{(0,c.assert)(!n,i.MSG_SINGLE_RETRY),n=!0,f[c.checkedMode]=!0,_=s.call(this,...e)}))})),!n)throw(0,u.assertInvariants)(this,f),t}return(0,u.assertInvariants)(this,f),_}}s=new WeakMap,t.default=class{constructor(e){this.Class=e,s.set(this,void 0),this.contractsChecked=!1;const t=this.Class.prototype;n(this,s,Reflect.ownKeys(t).filter((e=>"constructor"!=e&&e!==c.innerContract)).map((e=>new u.Feature(this,e,Object.getOwnPropertyDescriptor(t,e)))),"f")}get features(){return[...a(this,s,"f")]}get ParentClass(){var e;return null===(e=Object.getPrototypeOf(this.Class.prototype))||void 0===e?void 0:e.constructor}get parentRegistration(){return null==this.ParentClass?null:u.CLASS_REGISTRY.getOrCreate(this.ParentClass)}ancestry(){if(null==this.ParentClass)return[];{const e=u.CLASS_REGISTRY.getOrCreate(this.ParentClass);return[e,...e.ancestry()]}}ancestryFeatures(){return this.ancestry().flatMap((({features:e})=>e))}bindContract(e){if(this.contract=e,!e[c.checkedMode])return;const t=this.Class.prototype;this.features.forEach((e=>{const{name:r,hasGetter:s,hasSetter:n,isMethod:a}=e;Object.defineProperty(t,r,Object.assign(Object.assign(Object.assign({enumerable:!0},s?{get:d(r,e.getter,this)}:{}),n?{set:d(r,e.setter,this)}:{}),a?{value:d(r,e.value,this)}:{})),e.descriptor=Object.getOwnPropertyDescriptor(t,r)}))}checkOverrides(){const e=new Set(this.ancestryFeatures().map((({name:e})=>e)));this.features.forEach((({name:t,hasOverrides:r})=>{const s=`${this.Class.name}.prototype.${String(t)}`;(0,c.assert)(!r||e.has(t),`Unnecessary @override declaration on ${s}`),(0,c.assert)(r||!e.has(t),`@override decorator missing on ${s}`)}))}findFeature(e){var t,r;return null!==(t=this.features.find((({name:t})=>t===e)))&&void 0!==t?t:null===(r=this.parentRegistration)||void 0===r?void 0:r.findFeature(e)}}},950:function(e,t){var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,r):n?n.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),r=new WeakMap,s=new WeakMap,t.default=class{constructor(e,t,a){this.classRegistration=e,this.name=t,r.set(this,void 0),s.set(this,void 0),this.hasOverrides=!1,n(this,r,a,"f")}get ancestorFeature(){return this.classRegistration.ancestryFeatures().filter((e=>e.name===this.name))[0]}get getter(){return a(this,r,"f").get}get hasGetter(){return this.isAccessor&&null!=a(this,r,"f").get}get hasSetter(){return this.isAccessor&&null!=a(this,r,"f").set}get isProperty(){return"function"!=typeof a(this,r,"f").value&&void 0!==a(this,r,"f").value}get isMethod(){return"function"==typeof a(this,r,"f").value}get isAccessor(){return void 0===a(this,r,"f").value}get memberType(){return this.isMethod?"method":this.isProperty?"property":"accessor"}get setter(){return a(this,r,"f").set}get value(){return a(this,r,"f").value}get overriddenOriginalDescriptor(){return a(this,s,"f")}set overriddenOriginalDescriptor(e){n(this,s,e,"f")}get descriptor(){return a(this,r,"f")}set descriptor(e){n(this,r,e,"f")}}},357:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(822),a=r(607),o=s(r(71));t.default=function e(t,r,s,i,c){var u;let l=!0;const d=null===(u=Reflect.get(r.assertions,i))||void 0===u?void 0:u.demands,f=`demands not met on ${s}.prototype.${String(i)}\r\n${d}`;r[a.checkedMode]&&d&&(0,o.default)(r,(()=>l=d.call(t,t,...c))),r[n.extend]&&!l?e(t,r[n.extend],s,i,c):(0,a.assert)(l,f)}},318:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(822),a=r(607),o=s(r(71));t.default=function e(t,r,s,i,c,u){var l;const d=null===(l=Reflect.get(r.assertions,i))||void 0===l?void 0:l.ensures,f=`ensures not met on ${s}.prototype.${String(i)}\r\n${d}`;r[a.checkedMode]&&d&&(0,o.default)(r,(()=>(0,a.assert)(d.call(t,t,c,...u),f))),r[n.extend]&&e(t,r[n.extend],s,i,c,u)}},732:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(915),n=r(607);t.default=function e(t,r){r[n.checkedMode]&&(0,s.unChecked)(r,(()=>{const e=r[n.invariant];(0,n.assert)(e.call(t,t),`Invariant violated. ${e.toString()}`)})),r[n.extend]&&e(t,r[n.extend])}},963:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function e(t){for(const[,r]of Object.entries(t))null!=r&&"object"==typeof r&&e(r);Object.freeze(t)}},915:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.unChecked=t.takeWhile=t.fnTrue=t.Feature=t.deepFreeze=t.ClassRegistration=t.CLASS_REGISTRY=t.assertInvariants=t.assertEnsures=t.assertDemands=void 0;const n=s(r(357));t.assertDemands=n.default;const a=s(r(318));t.assertEnsures=a.default;const o=s(r(732));t.assertInvariants=o.default;const i=s(r(932));t.CLASS_REGISTRY=i.default;const c=s(r(359));t.ClassRegistration=c.default;const u=s(r(963));t.deepFreeze=u.default;const l=s(r(950));t.Feature=l.default;const d=s(r(638));t.takeWhile=d.default;const f=s(r(71));t.unChecked=f.default,t.fnTrue=()=>!0},638:(e,t)=>{function r(e,t){return e.length&&t(e[0])?[e[0],...r(e.slice(1),t)]:[]}Object.defineProperty(t,"__esModule",{value:!0}),t.takeWhile=void 0,t.takeWhile=r,t.default=r},71:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(607);t.default=(e,t)=>{try{e[s.checkedMode]=!1,t()}finally{e[s.checkedMode]=!0}}},47:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(607),n=r(860),a=r(915),o=r(879);t.default=function(e,t,r){const i=e.constructor,c="function"==typeof e;(0,s.assert)(!c,n.MSG_NO_STATIC,TypeError);const u=a.CLASS_REGISTRY.getOrCreate(i),l=u.findFeature(t);(0,s.assert)(null!=l,`${n.MSG_MISSING_FEATURE}: ${u.Class.name}.prototype.${String(t)}`);const d=l.ancestorFeature;if((0,s.assert)(null!=d&&l.memberType===d.memberType,`${n.MSG_NO_MATCHING_FEATURE} '${u.Class.name}.prototype.${String(t)}'`),(0,s.assert)(!l.hasOverrides,n.MSG_DUPLICATE_OVERRIDE),l.hasOverrides=!0,l.isMethod){const e=l.value,t=d.value;(0,s.assert)(e.length==t.length,n.MSG_INVALID_ARG_LENGTH)}return l.overriddenOriginalDescriptor=r,Object.assign(Object.assign(Object.assign(Object.assign({enumerable:!0,configurable:!0},l.isAccessor?{}:{writable:!0}),l.hasGetter?{get(){(0,s.assert)(this.constructor[o.isContracted],n.MSG_NOT_CONTRACTED)}}:{}),l.hasSetter?{set(e){(0,s.assert)(this.constructor[o.isContracted],n.MSG_NOT_CONTRACTED)}}:{}),l.isMethod?{value(){(0,s.assert)(this.constructor[o.isContracted],n.MSG_NOT_CONTRACTED)}}:{})}}},t={};return function r(s){var n=t[s];if(void 0!==n)return n.exports;var a=t[s]={exports:{}};return e[s].call(a.exports,a,a.exports,r),a.exports}(607)})()));
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(this,(()=>(()=>{"use strict";var e={731:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class r extends Error{constructor(e){super(e)}}t.default=r},822:function(e,t,r){var s,n=this&&this.__classPrivateFieldSet||function(e,t,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,r):n?n.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.invariant=t.extend=t.checkedMode=t.Contract=void 0;const o=r(915),i=Symbol("checkedMode"),c=Symbol("invariant"),u=Symbol("extend");t.checkedMode=i,t.invariant=c,t.extend=u;class l{constructor(e=Object.create(null)){var t,r;s.set(this,void 0),this.assertions=Object.create(null),this[u]=e[u],this[i]=null===(t=e[i])||void 0===t||t,n(this,s,null!==(r=e[c])&&void 0!==r?r:o.fnTrue,"f"),Object.keys(e).forEach((t=>{var r,s;const n=e[t];Object.defineProperty(this.assertions,t,{value:{demands:null!==(r=n.demands)&&void 0!==r?r:o.fnTrue,ensures:null!==(s=n.ensures)&&void 0!==s?s:o.fnTrue,rescue:n.rescue,within:n.within}})})),(0,o.deepFreeze)(this.assertions)}get[(s=new WeakMap,c)](){return a(this,s,"f")}}t.Contract=l},879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.innerContract=t.isContracted=void 0;const s=r(915),n=r(607),a=r(860),o=Symbol("isContracted"),i=Symbol("innerContract");t.isContracted=o,t.innerContract=i,t.default=function(e=new n.Contract){return function(t){var r;if((0,n.assert)(!Object.getOwnPropertySymbols(t).includes(o),a.MSG_SINGLE_CONTRACT),!1===e[n.checkedMode])return t;const c=t[i];(0,n.assert)(!c||c&&e[n.extend]instanceof c.constructor,a.MSG_BAD_SUBCONTRACT);class u extends t{constructor(...e){super(...e);const r=this.constructor,o=s.CLASS_REGISTRY.getOrCreate(r);var c;if((0,n.assert)((c=o,this,!Object.entries(Object.getOwnPropertyDescriptors(this)).some((([e,t])=>new s.Feature(c,e,t).isProperty))),a.MSG_NO_PROPERTIES),!o.contractsChecked){let e=o.ancestry().reverse();[...e,o].forEach((e=>{e.contractsChecked||(e.checkOverrides(),e.contractsChecked=!0)})),e=(0,s.takeWhile)(e.reverse(),(e=>e.Class!==t)),[o,...e,s.CLASS_REGISTRY.get(t)].forEach((e=>{e.bindContract(u[i])}))}return(0,s.assertInvariants)(this,u[i]),this}static get[(r=o,i)](){return e}get[i](){return e}}return u[r]=!0,s.CLASS_REGISTRY.getOrCreate(u).contractsChecked=!1,Object.freeze(t),u}}},860:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MSG_BAD_SUBCONTRACT=t.MSG_INVALID_CONTEXT=t.MSG_SINGLE_RETRY=t.MSG_SINGLE_CONTRACT=t.MSG_MISSING_FEATURE=t.MSG_NOT_CONTRACTED=t.MSG_NO_PROPERTIES=t.MSG_DUPLICATE_OVERRIDE=t.MSG_NO_MATCHING_FEATURE=t.MSG_NO_STATIC=t.MSG_INVALID_ARG_LENGTH=t.ASSERTION_FAILED=void 0,t.ASSERTION_FAILED="Assertion failure",t.MSG_INVALID_ARG_LENGTH="An overridden method must have the same number of parameters as its ancestor method",t.MSG_NO_STATIC="Only instance members can be decorated, not static members",t.MSG_NO_MATCHING_FEATURE="This feature does not override an ancestor feature.",t.MSG_DUPLICATE_OVERRIDE="Only a single @override decorator can be assigned to a class member",t.MSG_NO_PROPERTIES="Public properties are forbidden",t.MSG_NOT_CONTRACTED="The current class or one of its ancestors must declare @Contracted(...)",t.MSG_MISSING_FEATURE="The requested feature is not registered",t.MSG_SINGLE_CONTRACT="Only a single @Contracted decorator is allowed per class",t.MSG_SINGLE_RETRY="retry can only be called once",t.MSG_INVALID_CONTEXT="A contracted feature can not be applied to objects of a different base class",t.MSG_BAD_SUBCONTRACT="A sub contract must extend a base contract"},797:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=s(r(731)),a=r(860);t.default=function(e,t=a.ASSERTION_FAILED,r=n.default){if(0==Boolean(e))throw new r(t)}},606:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return!e||t}},607:function(e,t,r){var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&s(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.checkedMode=t.invariant=t.extend=t.Contract=t.assert=t.override=t.innerContract=t.implies=t.Contracted=t.AssertionError=void 0;const i=o(r(731));t.AssertionError=i.default;const c=a(r(879));t.Contracted=c.default,Object.defineProperty(t,"innerContract",{enumerable:!0,get:function(){return c.innerContract}});const u=o(r(47));t.override=u.default;const l=o(r(797));t.assert=l.default;const d=o(r(606));t.implies=d.default;var f=r(822);Object.defineProperty(t,"Contract",{enumerable:!0,get:function(){return f.Contract}}),Object.defineProperty(t,"extend",{enumerable:!0,get:function(){return f.extend}}),Object.defineProperty(t,"invariant",{enumerable:!0,get:function(){return f.invariant}}),Object.defineProperty(t,"checkedMode",{enumerable:!0,get:function(){return f.checkedMode}})},932:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(915);class n extends WeakMap{getOrCreate(e){return this.has(e)||this.set(e,new s.ClassRegistration(e)),this.get(e)}}const a=new n;t.default=a},359:function(e,t,r){var s,n=this&&this.__classPrivateFieldSet||function(e,t,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,r):n?n.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=r(860),c=r(607),u=r(915),l=o(r(318));function d(e,t,r){return function s(...n){var a,o;const{Class:d}=r;(0,c.assert)(this instanceof d,i.MSG_INVALID_CONTEXT);const f=Reflect.get(this,c.innerContract),h=d.name;if(!f[c.checkedMode])return t.apply(this,n);let _;(0,u.assertInvariants)(this,f),(0,u.assertDemands)(this,f,h,e,n);try{const s=Object.create(null);(0,u.unChecked)(f,(()=>{r.features.forEach((({name:e,hasGetter:t})=>{t&&Object.defineProperty(s,e,{value:this[e]})}))}));const o=null===(a=Reflect.get(f.assertions,e))||void 0===a?void 0:a.within,i=Date.now();_=t.apply(this,n);const d=Date.now();o&&(0,c.assert)(d-i<o,`Timing constraint violated. Constraint: ${o}ms, actual: ${d-i}ms`),(0,l.default)(this,f,h,e,s,n)}catch(t){const r=null===(o=Reflect.get(f.assertions,e))||void 0===o?void 0:o.rescue;if(null==r)throw(0,u.assertInvariants)(this,f),t;let n=!1;if((0,u.unChecked)(f,(()=>{r.call(this,this,t,[],((...e)=>{(0,c.assert)(!n,i.MSG_SINGLE_RETRY),n=!0,f[c.checkedMode]=!0,_=s.call(this,...e)}))})),!n)throw(0,u.assertInvariants)(this,f),t}return(0,u.assertInvariants)(this,f),_}}s=new WeakMap,t.default=class{constructor(e){this.Class=e,s.set(this,void 0),this.contractsChecked=!1;const t=this.Class.prototype;n(this,s,Reflect.ownKeys(t).filter((e=>"constructor"!=e&&e!==c.innerContract)).map((e=>new u.Feature(this,e,Object.getOwnPropertyDescriptor(t,e)))),"f")}get features(){return[...a(this,s,"f")]}get ParentClass(){var e;return null===(e=Object.getPrototypeOf(this.Class.prototype))||void 0===e?void 0:e.constructor}get parentRegistration(){return null==this.ParentClass?null:u.CLASS_REGISTRY.getOrCreate(this.ParentClass)}ancestry(){if(null==this.ParentClass)return[];{const e=u.CLASS_REGISTRY.getOrCreate(this.ParentClass);return[e,...e.ancestry()]}}ancestryFeatures(){return this.ancestry().flatMap((({features:e})=>e))}bindContract(e){if(this.contract=e,!e[c.checkedMode])return;const t=this.Class.prototype;this.features.forEach((e=>{const{name:r,hasGetter:s,hasSetter:n,isMethod:a}=e;Object.defineProperty(t,r,Object.assign(Object.assign(Object.assign({enumerable:!0},s?{get:d(r,e.getter,this)}:{}),n?{set:d(r,e.setter,this)}:{}),a?{value:d(r,e.value,this)}:{})),e.descriptor=Object.getOwnPropertyDescriptor(t,r)}))}checkOverrides(){const e=new Set(this.ancestryFeatures().map((({name:e})=>e)));this.features.forEach((({name:t,hasOverrides:r})=>{const s=`${this.Class.name}.prototype.${String(t)}`;(0,c.assert)(!r||e.has(t),`Unnecessary @override declaration on ${s}`),(0,c.assert)(r||!e.has(t),`@override decorator missing on ${s}`)}))}findFeature(e){var t,r;return null!==(t=this.features.find((({name:t})=>t===e)))&&void 0!==t?t:null===(r=this.parentRegistration)||void 0===r?void 0:r.findFeature(e)}}},950:function(e,t){var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,r,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,r):n?n.value=r:t.set(e,r),r},a=this&&this.__classPrivateFieldGet||function(e,t,r,s){if("a"===r&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?s:"a"===r?s.call(e):s?s.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),r=new WeakMap,s=new WeakMap,t.default=class{constructor(e,t,a){this.classRegistration=e,this.name=t,r.set(this,void 0),s.set(this,void 0),this.hasOverrides=!1,n(this,r,a,"f")}get ancestorFeature(){return this.classRegistration.ancestryFeatures().filter((e=>e.name===this.name))[0]}get getter(){return a(this,r,"f").get}get hasGetter(){return this.isAccessor&&null!=a(this,r,"f").get}get hasSetter(){return this.isAccessor&&null!=a(this,r,"f").set}get isProperty(){return"function"!=typeof a(this,r,"f").value&&void 0!==a(this,r,"f").value}get isMethod(){return"function"==typeof a(this,r,"f").value}get isAccessor(){return void 0===a(this,r,"f").value}get memberType(){return this.isMethod?"method":this.isProperty?"property":"accessor"}get setter(){return a(this,r,"f").set}get value(){return a(this,r,"f").value}get overriddenOriginalDescriptor(){return a(this,s,"f")}set overriddenOriginalDescriptor(e){n(this,s,e,"f")}get descriptor(){return a(this,r,"f")}set descriptor(e){n(this,r,e,"f")}}},357:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(822),a=r(607),o=s(r(71));t.default=function e(t,r,s,i,c){var u;let l=!0;const d=null===(u=Reflect.get(r.assertions,i))||void 0===u?void 0:u.demands,f=`demands not met on ${s}.prototype.${String(i)}\r\n${d}`;r[a.checkedMode]&&d&&(0,o.default)(r,(()=>l=d.call(t,t,...c))),r[n.extend]&&!l?e(t,r[n.extend],s,i,c):(0,a.assert)(l,f)}},318:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(822),a=r(607),o=s(r(71));t.default=function e(t,r,s,i,c,u){var l;const d=null===(l=Reflect.get(r.assertions,i))||void 0===l?void 0:l.ensures,f=`ensures not met on ${s}.prototype.${String(i)}\r\n${d}`;r[a.checkedMode]&&d&&(0,o.default)(r,(()=>(0,a.assert)(d.call(t,t,c,...u),f))),r[n.extend]&&e(t,r[n.extend],s,i,c,u)}},732:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(915),n=r(607);t.default=function e(t,r){r[n.checkedMode]&&(0,s.unChecked)(r,(()=>{const e=r[n.invariant];(0,n.assert)(e.call(t,t),`Invariant violated. ${e.toString()}`)})),r[n.extend]&&e(t,r[n.extend])}},963:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function e(t){for(const[,r]of Object.entries(t))null!=r&&"object"==typeof r&&e(r);Object.freeze(t)}},915:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.unChecked=t.takeWhile=t.fnTrue=t.Feature=t.deepFreeze=t.ClassRegistration=t.CLASS_REGISTRY=t.assertInvariants=t.assertEnsures=t.assertDemands=void 0;const n=s(r(357));t.assertDemands=n.default;const a=s(r(318));t.assertEnsures=a.default;const o=s(r(732));t.assertInvariants=o.default;const i=s(r(932));t.CLASS_REGISTRY=i.default;const c=s(r(359));t.ClassRegistration=c.default;const u=s(r(963));t.deepFreeze=u.default;const l=s(r(950));t.Feature=l.default;const d=s(r(638));t.takeWhile=d.default;const f=s(r(71));t.unChecked=f.default,t.fnTrue=()=>!0},638:(e,t)=>{function r(e,t){return e.length&&t(e[0])?[e[0],...r(e.slice(1),t)]:[]}Object.defineProperty(t,"__esModule",{value:!0}),t.takeWhile=void 0,t.takeWhile=r,t.default=r},71:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(607);t.default=(e,t)=>{try{e[s.checkedMode]=!1,t()}finally{e[s.checkedMode]=!0}}},47:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const s=r(607),n=r(860),a=r(915),o=r(879);t.default=function(e,t,r){const i=e.constructor,c="function"==typeof e;(0,s.assert)(!c,n.MSG_NO_STATIC,TypeError);const u=a.CLASS_REGISTRY.getOrCreate(i),l=u.findFeature(t);(0,s.assert)(null!=l,`${n.MSG_MISSING_FEATURE}: ${u.Class.name}.prototype.${String(t)}`);const d=l.ancestorFeature;if((0,s.assert)(null!=d&&l.memberType===d.memberType,`${n.MSG_NO_MATCHING_FEATURE} '${u.Class.name}.prototype.${String(t)}'`),(0,s.assert)(!l.hasOverrides,n.MSG_DUPLICATE_OVERRIDE),l.hasOverrides=!0,l.isMethod){const e=l.value,t=d.value;(0,s.assert)(e.length==t.length,n.MSG_INVALID_ARG_LENGTH)}return l.overriddenOriginalDescriptor=r,Object.assign(Object.assign(Object.assign(Object.assign({enumerable:!0,configurable:!0},l.isAccessor?{}:{writable:!0}),l.hasGetter?{get(){(0,s.assert)(this.constructor[o.isContracted],n.MSG_NOT_CONTRACTED)}}:{}),l.hasSetter?{set(e){(0,s.assert)(this.constructor[o.isContracted],n.MSG_NOT_CONTRACTED)}}:{}),l.isMethod?{value(){(0,s.assert)(this.constructor[o.isContracted],n.MSG_NOT_CONTRACTED)}}:{})}}},t={};return function r(s){var n=t[s];if(void 0!==n)return n.exports;var a=t[s]={exports:{}};return e[s].call(a.exports,a,a.exports,r),a.exports}(607)})()));
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","mappings":";CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,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D,kBAAkBsC,OAAOhH,MAE/F,MAAMyI,EAAapC,EAAQc,gBAS3B,IAPA,IAAAtG,QACkB,MAAd4H,GAAsBpC,EAAQiB,aAAemB,EAAWnB,WACxD,GAAG,EAAArE,4BAA4BxB,EAAaJ,MAAMqD,kBAAkBsC,OAAOhH,QAE/E,IAAAa,SAAQwF,EAAQS,aAAc,EAAA5D,wBAC9BmD,EAAQS,cAAe,EAEpBT,EAAQE,SAAU,CACjB,MAAMmC,EAAsCrC,EAAQlG,MAChDwI,EAAqCF,EAAWtI,OACpD,IAAAU,QAAO6H,EAAWP,QAAUQ,EAAUR,OAAQ,EAAApF,wBAMlD,OAHAsD,EAAQkB,6BAA+BZ,EAGhC,OAAP,kDACIH,YAAY,EACZoC,cAAc,GACTvC,EAAQe,WAAgC,CAAC,EAApB,CAACyB,UAAU,IACjCxC,EAAQpB,UAAY,CAACvC,OAAO,IAAA7B,QAAQ9B,KAAKG,YAAoB,EAAAuB,cAAe,EAAA0C,mBAAqB,GAAM,CAAC,GACxGkD,EAAQC,UAAY,CAACpC,IAAI4E,IAAI,IAAAjI,QAAQ9B,KAAKG,YAAoB,EAAAuB,cAAe,EAAA0C,mBAAqB,GAAM,CAAC,GACzGkD,EAAQE,SAAW,CAACpG,SAAS,IAAAU,QAAQ9B,KAAKG,YAAoB,EAAAuB,cAAe,EAAA0C,mBAAqB,GAAM,CAAC,EAErH,ICzDI4F,EAA2B,CAAC,SAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB5B,IAAjB6B,EACH,OAAOA,EAAazK,QAGrB,IAAIC,EAASqK,EAAyBE,GAAY,CAGjDxK,QAAS,CAAC,GAOX,OAHA0K,EAAoBF,GAAUzD,KAAK9G,EAAOD,QAASC,EAAQA,EAAOD,QAASuK,GAGpEtK,EAAOD,OACf,CCnB0BuK,CAAoB","sources":["webpack://@final-hill/decorator-contracts/webpack/universalModuleDefinition","webpack://@final-hill/decorator-contracts/./src/AssertionError.ts","webpack://@final-hill/decorator-contracts/./src/Contract.ts","webpack://@final-hill/decorator-contracts/./src/Contracted.ts","webpack://@final-hill/decorator-contracts/./src/Messages.ts","webpack://@final-hill/decorator-contracts/./src/assert.ts","webpack://@final-hill/decorator-contracts/./src/implies.ts","webpack://@final-hill/decorator-contracts/./src/index.ts","webpack://@final-hill/decorator-contracts/./src/lib/CLASS_REGISTRY.ts","webpack://@final-hill/decorator-contracts/./src/lib/ClassRegistration.ts","webpack://@final-hill/decorator-contracts/./src/lib/Feature.ts","webpack://@final-hill/decorator-contracts/./src/lib/assertDemands.ts","webpack://@final-hill/decorator-contracts/./src/lib/assertEnsures.ts","webpack://@final-hill/decorator-contracts/./src/lib/assertInvariants.ts","webpack://@final-hill/decorator-contracts/./src/lib/deepFreeze.ts","webpack://@final-hill/decorator-contracts/./src/lib/index.ts","webpack://@final-hill/decorator-contracts/./src/lib/takeWhile.ts","webpack://@final-hill/decorator-contracts/./src/lib/unChecked.ts","webpack://@final-hill/decorator-contracts/./src/override.ts","webpack://@final-hill/decorator-contracts/webpack/bootstrap","webpack://@final-hill/decorator-contracts/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, () => {\nreturn ","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\n/**\r\n * An AssertionError represents a failed assertion with an associated message\r\n */\r\nclass AssertionError extends Error {\r\n /**\r\n * Constructs a new instance of AssertionError\r\n *\r\n * @param {string} message - The associated message\r\n */\r\n constructor(message: string) {\r\n super(message);\r\n }\r\n}\r\n\r\nexport default AssertionError;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport {deepFreeze, fnTrue} from './lib';\r\n\r\nconst checkedMode = Symbol('checkedMode'),\r\n invariant = Symbol('invariant'),\r\n extend = Symbol('extend');\r\n\r\ntype AnyObject = Record<PropertyKey, any>;\r\ntype AnyFunc = (...args: any[]) => any;\r\n\r\ntype NonFunctionPropertyNames<T extends AnyObject> = { [K in keyof T]: T[K] extends AnyFunc ? never : K }[keyof T];\r\ntype Properties<T extends AnyObject> = Pick<T, NonFunctionPropertyNames<T>>;\r\n\r\nexport type Invariant<T extends AnyObject> = (self: T) => boolean;\r\nexport type Demands<T extends AnyObject, F extends T[any]> = (self: T, ...args: Parameters<F>) => boolean;\r\nexport type Ensures<T extends AnyObject, F extends T[any]> = (self: T, old: Properties<T>, ...args: Parameters<F>) => boolean;\r\nexport type Rescue<T extends AnyObject, F extends T[any]> = (\r\n self: T,\r\n error: Error,\r\n args: F extends AnyFunc ? Parameters<F> : [F],\r\n retry: F extends AnyFunc ? (...args: Parameters<F>) => any : (value: F) => void\r\n) => void;\r\n\r\nexport type ContractOptions<\r\n T extends AnyObject\r\n> = {\r\n [extend]: Contract<T>;\r\n [invariant]: Invariant<T>;\r\n [checkedMode]: boolean;\r\n} & {\r\n [K in keyof T]?: FeatureOption<T, T[K]>\r\n};\r\n\r\nexport interface FeatureOption<T extends AnyObject, F extends T[any]> {\r\n demands?: Demands<T,F>;\r\n ensures?: Ensures<T,F>;\r\n rescue?: Rescue<T,F>;\r\n within?: number;\r\n}\r\n\r\nexport class Contract<T extends AnyObject> {\r\n #invariant: Invariant<T>;\r\n [checkedMode]: boolean;\r\n readonly [extend]?: Contract<T>;\r\n readonly assertions: ContractOptions<T> = Object.create(null);\r\n\r\n constructor(assertions: Partial<ContractOptions<T>> = Object.create(null)) {\r\n this[extend] = assertions[extend];\r\n this[checkedMode] = assertions[checkedMode] ?? true;\r\n this.#invariant = assertions[invariant] ?? fnTrue;\r\n\r\n Object.keys(assertions).forEach(propertyKey => {\r\n const featureOption = assertions[propertyKey]!;\r\n Object.defineProperty(this.assertions,propertyKey, {\r\n value: {\r\n demands: featureOption.demands ?? fnTrue,\r\n ensures: featureOption.ensures ?? fnTrue,\r\n rescue: featureOption.rescue,\r\n within: featureOption.within\r\n }\r\n });\r\n });\r\n\r\n deepFreeze(this.assertions);\r\n }\r\n\r\n get [invariant](): Invariant<T> {\r\n return this.#invariant;\r\n }\r\n}\r\n\r\nexport {checkedMode, extend, invariant};","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { ClassRegistration, CLASS_REGISTRY, ClassType, Feature, takeWhile, assertInvariants } from './lib';\r\nimport { assert, checkedMode, Contract, extend } from './';\r\nimport { MSG_BAD_SUBCONTRACT, MSG_NO_PROPERTIES, MSG_SINGLE_CONTRACT } from './Messages';\r\n\r\nconst isContracted = Symbol('isContracted'),\r\n innerContract = Symbol('innerContract');\r\n\r\n/**\r\n * Checks the features of the provided object for properties.\r\n * If any are found an exception is thrown\r\n * @param {ClassRegistration} registration - The ClassRegistration for the object\r\n * @param {U} obj - The object to check\r\n * @throws {AssertionError} - Throws if a property is found\r\n * @returns {boolean} - The result of the test\r\n */\r\nfunction hasProperties<U>(registration: ClassRegistration, obj: U): boolean {\r\n return Object.entries(Object.getOwnPropertyDescriptors(obj))\r\n .some(([key, desc]) => new Feature(registration, key, desc).isProperty);\r\n}\r\n\r\n/**\r\n * Associates a contract with a class via the mixin pattern.\r\n *\r\n * @param {Contract} contract The Contract definition\r\n * @param {T} Base An optional base class\r\n * @returns {T} The base class for extension\r\n * @example\r\n *\r\n * @Contracted(stackContract)\r\n * class Stack<T> { ... }\r\n */\r\nfunction Contracted<\r\n T extends Contract<any> = Contract<any>,\r\n U extends ClassType<any> = ClassType<any>\r\n>(contract: T = new Contract() as T): ClassDecorator {\r\n return function (Base: U & { [innerContract]?: Contract<any> }) {\r\n assert(!Object.getOwnPropertySymbols(Base).includes(isContracted), MSG_SINGLE_CONTRACT);\r\n\r\n if (contract[checkedMode] === false) {\r\n return Base;\r\n }\r\n\r\n const baseContract = Base[innerContract];\r\n assert(\r\n !baseContract ||\r\n baseContract && contract[extend] instanceof baseContract.constructor,\r\n MSG_BAD_SUBCONTRACT\r\n );\r\n\r\n abstract class InnerContracted extends Base {\r\n // prevents multiple @Contracted decorators from being applied\r\n static readonly [isContracted] = true;\r\n\r\n constructor(...args: any[]) {\r\n super(...args);\r\n\r\n const Class = this.constructor as ClassType<any>,\r\n classRegistration = CLASS_REGISTRY.getOrCreate(Class);\r\n\r\n assert(!hasProperties(classRegistration, this), MSG_NO_PROPERTIES);\r\n\r\n if (!classRegistration.contractsChecked) {\r\n let ancRegistrations = classRegistration.ancestry().reverse();\r\n // top-down check overrides and pre-existing properties\r\n [...ancRegistrations, classRegistration].forEach(ancRegistration => {\r\n if (!ancRegistration.contractsChecked) {\r\n ancRegistration.checkOverrides();\r\n ancRegistration.contractsChecked = true;\r\n }\r\n });\r\n\r\n // bottom-up to closest Contracted class bind contracts\r\n ancRegistrations = takeWhile(ancRegistrations.reverse(), (cr => cr.Class !== Base));\r\n [classRegistration, ...ancRegistrations, CLASS_REGISTRY.get(Base)!].forEach(registration => {\r\n registration.bindContract(InnerContracted[innerContract]);\r\n });\r\n }\r\n\r\n assertInvariants(this, InnerContracted[innerContract]);\r\n\r\n return this;\r\n }\r\n\r\n // FIXME: dirty hack. Possibly resolved by moving to contracts as classes\r\n // The static getter is used by the construction invariant check\r\n // The instance getter is used by the feature declarations\r\n static get [innerContract]() { return contract; }\r\n get [innerContract]() { return contract; }\r\n }\r\n\r\n const classRegistration = CLASS_REGISTRY.getOrCreate(InnerContracted);\r\n classRegistration.contractsChecked = false;\r\n\r\n Object.freeze(Base);\r\n\r\n return InnerContracted;\r\n } as ClassDecorator;\r\n}\r\n\r\nexport { isContracted, innerContract };\r\nexport default Contracted;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nexport const ASSERTION_FAILED = 'Assertion failure';\r\nexport const MSG_INVALID_ARG_LENGTH = 'An overridden method must have the same number of parameters as its ancestor method';\r\nexport const MSG_NO_STATIC = 'Only instance members can be decorated, not static members';\r\nexport const MSG_NO_MATCHING_FEATURE = 'This feature does not override an ancestor feature.';\r\nexport const MSG_DUPLICATE_OVERRIDE = 'Only a single @override decorator can be assigned to a class member';\r\nexport const MSG_NO_PROPERTIES = 'Public properties are forbidden';\r\nexport const MSG_NOT_CONTRACTED = 'The current class or one of its ancestors must declare @Contracted(...)';\r\nexport const MSG_MISSING_FEATURE = 'The requested feature is not registered';\r\nexport const MSG_SINGLE_CONTRACT = 'Only a single @Contracted decorator is allowed per class';\r\nexport const MSG_SINGLE_RETRY = 'retry can only be called once';\r\nexport const MSG_INVALID_CONTEXT = 'A contracted feature can not be applied to objects of a different base class';\r\nexport const MSG_BAD_SUBCONTRACT = 'A sub contract must extend a base contract';","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport AssertionError from './AssertionError';\r\nimport { ASSERTION_FAILED } from './Messages';\r\nimport type { Constructor } from 'lib/ClassType';\r\n\r\n/**\r\n * An assertion is an expression of a property that must be true at a particular\r\n * point of step of program execution. It consists of a boolean expression\r\n * and a message. This function tests the provided condition. If the condition\r\n * is false an AssertionError is raised with an optional message.\r\n * If the provided condition is true then the function returns without raising an error\r\n *\r\n * @param {boolean} condition - The condition to test\r\n * @param {string} message - A descriptive message to associate with the AssertionError\r\n * @param {ClassType<Error>} ErrorConstructor - The constructor of the Error to use\r\n * @throws {Error} - When the condition is false\r\n * @see AssertionError\r\n * @throws {AssertionError} - Throws an AssertionError by default if the condition is false\r\n *\r\n * @example\r\n * let x = 15;\r\n * assert(x > 5, `Expected: x > 5. Actual: x = ${x}`)\r\n *\r\n * @example\r\n * let name = \"Tom\"\r\n * assert(name.trim().length > 0, 'Name is required', TypeError)\r\n */\r\nexport default function assert(condition: unknown, message = ASSERTION_FAILED, ErrorConstructor: Constructor<Error> = AssertionError): asserts condition {\r\n if(Boolean(condition) == false) {\r\n throw new ErrorConstructor(message);\r\n }\r\n}","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\n/**\r\n * Material Implication.\r\n * `p → q`\r\n * Also referred to as `if-then`.\r\n * An example of usage is the encoding of \"sunny weather is a precondition of visiting the beach\"\r\n * This is logically equivalent to: !p || q\r\n *\r\n * @example\r\n * implies(weather.isSunny, person.visitsBeach)\r\n *\r\n * @param {boolean} p - The antecedent\r\n * @param {boolean} q - The consequent\r\n * @returns {boolean} - The result\r\n */\r\nexport default function implies(p: boolean, q: boolean): boolean {\r\n return !p || q;\r\n}","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport AssertionError from './AssertionError';\r\nimport {Contract, extend, invariant, Invariant, checkedMode, Rescue} from './Contract';\r\nimport Contracted, {innerContract} from './Contracted';\r\nimport override from './override';\r\nimport assert from './assert';\r\nimport implies from './implies';\r\n\r\nexport {\r\n AssertionError, Contract, Contracted, Invariant, Rescue, implies,\r\n invariant, innerContract, extend, checkedMode, override, assert\r\n};","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport {ClassRegistration, ClassType} from './';\r\n\r\n/**\r\n * A WeakMap that tracks class registrations.\r\n * @see {@link ClassRegistration}\r\n */\r\nclass ClassRegistry extends WeakMap<ClassType<any>, ClassRegistration> {\r\n /**\r\n * Returns the class registry defined for the current class.\r\n * If the registry is undefined, a new one is created\r\n *\r\n * @param {ClassType<any>} Class - The class\r\n * @returns {ClassRegistration} - The ClassRegistration\r\n */\r\n getOrCreate(Class: ClassType<any>): ClassRegistration {\r\n if(this.has(Class)) {\r\n return this.get(Class)!;\r\n } else {\r\n this.set(Class, new ClassRegistration(Class));\r\n\r\n return this.get(Class)!;\r\n }\r\n }\r\n}\r\n\r\nconst CLASS_REGISTRY = new ClassRegistry();\r\n\r\nexport default CLASS_REGISTRY;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { MSG_INVALID_CONTEXT, MSG_SINGLE_RETRY } from '../Messages';\r\nimport { assert, checkedMode, Contract, innerContract } from '../';\r\nimport { assertInvariants, assertDemands, CLASS_REGISTRY, ClassType, Feature, unChecked } from './';\r\nimport assertEnsures from './assertEnsures';\r\n\r\n/**\r\n * Manages the evaluation of contract assertions for a feature\r\n *\r\n * @param {string} featureName - The name of the feature\r\n * @param {function(...args: any[]): any} fnOrig - The original unchecked feature\r\n * @param {ClassRegistration} registration - The class registration\r\n *\r\n * @returns {function(...args: any[]): any} - The original function augments with assertion checks\r\n */\r\nfunction checkedFeature(\r\n featureName: PropertyKey,\r\n fnOrig: (...args: any[]) => any,\r\n registration: ClassRegistration\r\n) {\r\n return function innerCheckedFeature(this: any, ...args: any[]) {\r\n const { Class } = registration;\r\n\r\n assert(this instanceof Class, MSG_INVALID_CONTEXT);\r\n\r\n const contract = Reflect.get(this, innerContract),\r\n className = Class.name;\r\n if (!contract[checkedMode]) {\r\n return fnOrig.apply(this, args);\r\n }\r\n\r\n assertInvariants(this, contract);\r\n assertDemands(this, contract, className, featureName, args);\r\n\r\n let result;\r\n try {\r\n const old = Object.create(null);\r\n unChecked(contract, () => {\r\n registration.features.forEach(({ name, hasGetter }) => {\r\n if (hasGetter) {\r\n Object.defineProperty(old, name, { value: this[name] });\r\n }\r\n });\r\n });\r\n const within: number = Reflect.get(contract.assertions, featureName)?.within,\r\n // TODO:Not all environments currently support performance.now() as a global and conditional import is inconvenient\r\n t0 = Date.now();\r\n result = fnOrig.apply(this, args);\r\n const t1 = Date.now();\r\n if (within) {\r\n assert(t1 - t0 < within,\r\n `Timing constraint violated. Constraint: ${within}ms, actual: ${t1 - t0}ms`\r\n );\r\n }\r\n assertEnsures(this, contract, className, featureName, old, args);\r\n } catch (error) {\r\n const rescue = Reflect.get(contract.assertions, featureName)?.rescue;\r\n if (rescue == null) {\r\n assertInvariants(this, contract);\r\n throw error;\r\n }\r\n let hasRetried = false;\r\n unChecked(contract, () => {\r\n rescue.call(this, this, error, [], (...args: any[]) => {\r\n assert(!hasRetried, MSG_SINGLE_RETRY);\r\n hasRetried = true;\r\n contract[checkedMode] = true;\r\n result = innerCheckedFeature.call(this, ...args);\r\n });\r\n });\r\n if (!hasRetried) {\r\n assertInvariants(this, contract);\r\n throw error;\r\n }\r\n }\r\n\r\n assertInvariants(this, contract);\r\n\r\n return result;\r\n };\r\n}\r\n\r\nclass ClassRegistration {\r\n #features: Feature[];\r\n contract!: Contract<any>; // Assigned by the Contracted class via this.bindContract\r\n contractsChecked = false;\r\n\r\n constructor(readonly Class: ClassType<any>) {\r\n const proto = this.Class.prototype;\r\n this.#features =\r\n Reflect.ownKeys(proto)\r\n .filter(key => key != 'constructor' && key !== innerContract)\r\n .map(key => new Feature(this, key, Object.getOwnPropertyDescriptor(proto, key)!));\r\n }\r\n\r\n /**\r\n * Returns the features associated with the registered class.\r\n *\r\n * @returns {Set<Feature>} The set of features\r\n */\r\n get features(): Feature[] {\r\n return [...this.#features];\r\n }\r\n\r\n /**\r\n * Returns a reference to the parent class\r\n */\r\n get ParentClass(): ClassType<any> | null {\r\n return Object.getPrototypeOf(this.Class.prototype)?.constructor;\r\n }\r\n\r\n /**\r\n * Returns the classRegistration of the parent class\r\n */\r\n get parentRegistration(): ClassRegistration | null {\r\n return this.ParentClass == null ? null : CLASS_REGISTRY.getOrCreate(this.ParentClass);\r\n }\r\n\r\n /**\r\n * Returns the registered class's ancestor class registrations.\r\n * Does not include the current class.\r\n *\r\n * @returns {ClassRegistration[]} - The ancestor class registrations\r\n */\r\n ancestry(): ClassRegistration[] {\r\n if (this.ParentClass == null) {\r\n return [];\r\n } else {\r\n const parentRegistry = CLASS_REGISTRY.getOrCreate(this.ParentClass);\r\n\r\n return [parentRegistry, ...parentRegistry.ancestry()];\r\n }\r\n }\r\n\r\n /**\r\n * Returns the features associated with the registered class's ancestors.\r\n * Does not include the current class.\r\n *\r\n * @returns {Feature[]} - The feature names\r\n */\r\n ancestryFeatures(): Feature[] {\r\n return this.ancestry().flatMap(({ features }) => features);\r\n }\r\n\r\n bindContract<T extends Contract<any>>(contract: T) {\r\n this.contract = contract;\r\n if (!contract[checkedMode]) {\r\n return;\r\n }\r\n const proto = this.Class.prototype;\r\n this.features.forEach(feature => {\r\n const { name, hasGetter, hasSetter, isMethod } = feature;\r\n\r\n Object.defineProperty(proto, name, {\r\n enumerable: true,\r\n ...(hasGetter ? { get: checkedFeature(name, feature.getter!, this) } : {}),\r\n ...(hasSetter ? { set: checkedFeature(name, feature.setter!, this) } : {}),\r\n ...(isMethod ? { value: checkedFeature(name, feature.value, this) } : {})\r\n });\r\n\r\n feature.descriptor = Object.getOwnPropertyDescriptor(proto, name)!;\r\n });\r\n }\r\n\r\n /**\r\n * Checks the features of the registered class for missing override decorators\r\n * @throws {AssertionError} - Throws if the verification fails\r\n */\r\n checkOverrides(): void {\r\n const ancestryFeatureNames = new Set(this.ancestryFeatures().map(({ name }) => name));\r\n this.features.forEach(({ name, hasOverrides }) => {\r\n const str = `${this.Class.name}.prototype.${String(name)}`;\r\n assert(!hasOverrides || ancestryFeatureNames.has(name), `Unnecessary @override declaration on ${str}`);\r\n assert(hasOverrides || !ancestryFeatureNames.has(name), `@override decorator missing on ${str}`);\r\n });\r\n }\r\n\r\n /**\r\n * Searches the current class and its ancestors for the nearest feature\r\n * matching the provided propertyKey.\r\n *\r\n * @param {PropertyKey} propertyKey - The key being searched\r\n * @returns {Feature | undefined} - The feature if it exists else otherwise\r\n */\r\n findFeature(propertyKey: PropertyKey): Feature | undefined {\r\n return this.features.find(({ name }) => name === propertyKey) ??\r\n this.parentRegistration?.findFeature(propertyKey);\r\n }\r\n}\r\n\r\nexport default ClassRegistration;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport ClassRegistration from './ClassRegistration';\r\n\r\nclass Feature {\r\n #descriptor: PropertyDescriptor;\r\n #overriddenOriginalDescriptor: PropertyDescriptor | undefined;\r\n\r\n /**\r\n * Does the current feature have an `@override` declaration?\r\n */\r\n hasOverrides = false;\r\n\r\n constructor(readonly classRegistration: ClassRegistration, readonly name: PropertyKey, descriptor: PropertyDescriptor){\r\n this.#descriptor = descriptor;\r\n }\r\n\r\n /**\r\n * Finds the nearest ancestor feature of the same key if it exists\r\n */\r\n get ancestorFeature(): Feature | null {\r\n return this.classRegistration.ancestryFeatures().filter(feature => feature.name === this.name)[0];\r\n }\r\n\r\n /**\r\n * Returns a reference to the getter if it exists\r\n */\r\n get getter() {\r\n return this.#descriptor.get;\r\n }\r\n\r\n /**\r\n * Determines if the feature is an accessor with a getter defined\r\n */\r\n get hasGetter(): boolean {\r\n return this.isAccessor && this.#descriptor.get != undefined;\r\n }\r\n\r\n /**\r\n * Determines if the feature is an accessor with a setter defined\r\n */\r\n get hasSetter(): boolean {\r\n return this.isAccessor && this.#descriptor.set != undefined;\r\n }\r\n\r\n /**\r\n * Determines if the feature is a property\r\n */\r\n get isProperty(): boolean {\r\n return typeof this.#descriptor.value != 'function' &&\r\n typeof this.#descriptor.value != 'undefined';\r\n }\r\n\r\n /**\r\n * Determines if the feature is a method\r\n */\r\n get isMethod(): boolean {\r\n return typeof this.#descriptor.value == 'function';\r\n }\r\n\r\n /**\r\n * Determines if the feature is an accessor\r\n */\r\n get isAccessor(): boolean {\r\n return typeof this.#descriptor.value == 'undefined';\r\n }\r\n\r\n /**\r\n * Returns a string representing the type of feature.\r\n * @returns {string} 'method' | 'property' | 'accessor'\r\n */\r\n get memberType(): 'method' | 'property' | 'accessor' {\r\n return this.isMethod ? 'method' :\r\n this.isProperty ? 'property' :\r\n 'accessor';\r\n }\r\n\r\n /**\r\n * Returns a reference to the setter if it exists\r\n */\r\n get setter() {\r\n return this.#descriptor.set;\r\n }\r\n\r\n /**\r\n * If the feature is a method, returns a reference to the implementation.\r\n * If the feature is a property, returns the value of the property\r\n * Otherwise returns undefined\r\n */\r\n get value(): any {\r\n return this.#descriptor.value;\r\n }\r\n\r\n /**\r\n * The original feature descriptor which was replaced by the `override` decorator\r\n */\r\n get overriddenOriginalDescriptor(): PropertyDescriptor| undefined {\r\n return this.#overriddenOriginalDescriptor;\r\n }\r\n set overriddenOriginalDescriptor(value: PropertyDescriptor | undefined) {\r\n this.#overriddenOriginalDescriptor = value;\r\n }\r\n\r\n /**\r\n * Returns a reference to the descriptor\r\n */\r\n get descriptor() {\r\n return this.#descriptor;\r\n }\r\n set descriptor(desc: PropertyDescriptor) {\r\n this.#descriptor = desc;\r\n }\r\n}\r\n\r\nexport default Feature;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { Demands, extend } from '../Contract';\r\nimport { assert, checkedMode, Contract } from '../';\r\nimport unChecked from './unChecked';\r\n\r\n/**\r\n * Applies invariant assertions to the provided class instance\r\n *\r\n * @param {U} ctx - The context class\r\n * @param {Contract<any>} contract - The contract\r\n * @param {string} className - The name of the class\r\n * @param {PropertyKey} featureName - The name of the feature\r\n * @param {any[]} args - The arguments of the feature to apply to the assertion\r\n * @throws {AssertionError}\r\n */\r\nfunction assertDemands<U extends object>(ctx: U, contract: Contract<U>, className: string, featureName: PropertyKey, args: any[]) {\r\n let result = true;\r\n const d: Demands<any, any> | undefined = Reflect.get(contract.assertions, featureName)?.demands,\r\n demandsError = `demands not met on ${className}.prototype.${String(featureName)}\\r\\n${d}`;\r\n if (contract[checkedMode]) {\r\n if (d) {\r\n unChecked(contract, () =>\r\n result = d.call(ctx, ctx, ...args)\r\n );\r\n }\r\n }\r\n\r\n if (contract[extend] && !result) {\r\n assertDemands(ctx, contract[extend], className, featureName, args);\r\n } else {\r\n assert(result, demandsError);\r\n }\r\n}\r\n\r\nexport default assertDemands;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { Ensures, extend } from '../Contract';\r\nimport { assert, checkedMode, Contract } from '../';\r\nimport unChecked from './unChecked';\r\n\r\n/**\r\n * Applies invariant assertions to the provided class instance\r\n *\r\n * @param {U} ctx - The context class\r\n * @param {Contract<any>} contract - The contract\r\n * @param {string} className - The name of the class\r\n * @param {PropertyKey} featureName - The name of the feature\r\n * @param {U} old - The original properties before execution\r\n * @param {any[]} args - The arguments of the feature to apply to the assertion\r\n * @throws {AssertionError}\r\n */\r\nfunction assertEnsures<U>(\r\n ctx: U,\r\n contract: Contract<any>,\r\n className: string,\r\n featureName: PropertyKey,\r\n old: U,\r\n args: any[]\r\n){\r\n const e: Ensures<any, any> | undefined = Reflect.get(contract.assertions, featureName)?.ensures,\r\n ensuresError = `ensures not met on ${className}.prototype.${String(featureName)}\\r\\n${e}`;\r\n\r\n if(contract[checkedMode]) {\r\n if(e) {\r\n unChecked(contract, () =>\r\n assert(e.call(ctx, ctx, old, ...args), ensuresError)\r\n );\r\n }\r\n }\r\n\r\n if(contract[extend]) {\r\n assertEnsures(ctx, contract[extend]!, className, featureName, old, args);\r\n }\r\n}\r\n\r\nexport default assertEnsures;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { unChecked } from './';\r\nimport { assert, checkedMode, Contract, extend, invariant } from '../';\r\n\r\n/**\r\n * Applies invariant assertions to the provided class instance\r\n *\r\n * @param {U} ctx - The context class\r\n * @param {Contract<any>} contract - The contract\r\n * @throws {AssertionError}\r\n */\r\nfunction assertInvariants<U>(ctx: U, contract: Contract<any>) {\r\n if (contract[checkedMode]) {\r\n unChecked(contract, () => {\r\n const iv = contract[invariant];\r\n assert(iv.call(ctx, ctx), `Invariant violated. ${iv.toString()}`);\r\n });\r\n }\r\n\r\n if (contract[extend]) {\r\n assertInvariants(ctx, contract[extend]!);\r\n }\r\n}\r\n\r\nexport default assertInvariants;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\n /**\r\n * Apply Object.freeze recursively\r\n * @param {object} object - The object to freeze\r\n */\r\nfunction deepFreeze(object: Record<PropertyKey, any>): void {\r\n // Freeze properties before freezing self\r\n for (const [,value] of Object.entries(object)) {\r\n if (value != undefined && typeof value === 'object') {\r\n deepFreeze(value);\r\n }\r\n }\r\n\r\n Object.freeze(object);\r\n}\r\n\r\nexport default deepFreeze;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport assertDemands from './assertDemands';\r\nimport assertEnsures from './assertEnsures';\r\nimport assertInvariants from './assertInvariants';\r\nimport CLASS_REGISTRY from './CLASS_REGISTRY';\r\nimport ClassRegistration from './ClassRegistration';\r\nimport {ClassType} from './ClassType';\r\nimport deepFreeze from './deepFreeze';\r\nimport Feature from './Feature';\r\nimport takeWhile from './takeWhile';\r\nimport unChecked from './unChecked';\r\n\r\nconst fnTrue = () => true;\r\n\r\nexport {\r\n assertDemands,\r\n assertEnsures,\r\n assertInvariants,\r\n CLASS_REGISTRY,\r\n ClassRegistration,\r\n ClassType,\r\n deepFreeze,\r\n Feature,\r\n fnTrue,\r\n takeWhile,\r\n unChecked\r\n};","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\n /**\r\n * Creates a new array from another one. Items from the original array\r\n * are taken if the provided predicate succeed. When the predicate fails,\r\n * no new items are taken\r\n *\r\n * @param {T[]} xs - The array to evaluate\r\n * @param {function(x:T): T[]} pred - The condition to apply to every element\r\n * @returns {T[]} - The filtered list\r\n */\r\nexport function takeWhile<T>(xs: T[], pred: (x: T) => boolean): T[] {\r\n return xs.length && pred(xs[0]) ? [xs[0], ...takeWhile(xs.slice(1), pred)] : [];\r\n}\r\n\r\nexport default takeWhile;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { checkedMode, Contract } from '../';\r\n\r\n/**\r\n * Disable contract checking for the provided function\r\n * @param {Contract<any>} contract - The code contract\r\n * @param {function(...args: any[]): any} fn - The function to execute\r\n */\r\nconst unChecked = (contract: Contract<any>, fn: () => any) => {\r\n try {\r\n contract[checkedMode] = false;\r\n fn();\r\n } finally {\r\n contract[checkedMode] = true;\r\n }\r\n};\r\n\r\nexport default unChecked;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { assert } from './';\r\nimport { MSG_NO_STATIC, MSG_NO_MATCHING_FEATURE, MSG_DUPLICATE_OVERRIDE, MSG_INVALID_ARG_LENGTH, MSG_NOT_CONTRACTED, MSG_MISSING_FEATURE } from './Messages';\r\nimport { CLASS_REGISTRY } from './lib';\r\nimport { isContracted } from './Contracted';\r\n\r\n/**\r\n * The 'override' decorator asserts that the current class feature is a specialization or\r\n * replacement of an ancestor class's feature of the same name and argument count\r\n *\r\n * @param {object} target - The class\r\n * @param {PropertyKey} propertyKey - The property key\r\n * @param {PropertyDescriptor} descriptor - The property descriptor\r\n * @returns {PropertyDescriptor} - The PropertyDescriptor\r\n */\r\nfunction override(target: Record<PropertyKey, any>, propertyKey: PropertyKey, descriptor: PropertyDescriptor): PropertyDescriptor {\r\n const Class = (target as any).constructor,\r\n isStatic = typeof target == 'function';\r\n\r\n assert(!isStatic, MSG_NO_STATIC, TypeError);\r\n\r\n const registration = CLASS_REGISTRY.getOrCreate(Class),\r\n feature = registration.findFeature(propertyKey);\r\n\r\n assert(feature != null, `${MSG_MISSING_FEATURE}: ${registration.Class.name}.prototype.${String(propertyKey)}`);\r\n\r\n const ancFeature = feature.ancestorFeature;\r\n\r\n assert(\r\n ancFeature != null && feature.memberType === ancFeature.memberType,\r\n `${MSG_NO_MATCHING_FEATURE} '${registration.Class.name}.prototype.${String(propertyKey)}'`\r\n );\r\n assert(!feature.hasOverrides, MSG_DUPLICATE_OVERRIDE);\r\n feature.hasOverrides = true;\r\n\r\n if(feature.isMethod) {\r\n const thisMethod: (...args: any[]) => any = feature.value,\r\n ancMethod: (...args: any[]) => any = ancFeature.value;\r\n assert(thisMethod.length == ancMethod.length, MSG_INVALID_ARG_LENGTH);\r\n }\r\n\r\n feature.overriddenOriginalDescriptor = descriptor;\r\n\r\n // method decorators are evaluated before class decorators\r\n return {\r\n enumerable: true,\r\n configurable: true,\r\n ...(!feature.isAccessor ? {writable: true} : {}),\r\n ...(feature.hasGetter ? {get(){ assert((this.constructor as any)[isContracted], MSG_NOT_CONTRACTED); } } : {}),\r\n ...(feature.hasSetter ? {set(_){ assert((this.constructor as any)[isContracted], MSG_NOT_CONTRACTED); } } : {}),\r\n ...(feature.isMethod ? {value() {assert((this.constructor as any)[isContracted], MSG_NOT_CONTRACTED); } } : {})\r\n };\r\n}\r\n\r\nexport default override;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(607);\n"],"names":["root","factory","exports","module","define","amd","a","i","this","AssertionError","Error","constructor","message","super","checkedMode","Symbol","invariant","extend","Contract","assertions","Object","create","fnTrue","keys","forEach","propertyKey","featureOption","defineProperty","value","demands","ensures","rescue","within","deepFreeze","isContracted","innerContract","contract","Base","assert","getOwnPropertySymbols","includes","MSG_SINGLE_CONTRACT","baseContract","MSG_BAD_SUBCONTRACT","InnerContracted","args","Class","classRegistration","CLASS_REGISTRY","getOrCreate","registration","entries","getOwnPropertyDescriptors","some","key","desc","Feature","isProperty","MSG_NO_PROPERTIES","contractsChecked","ancRegistrations","ancestry","reverse","ancRegistration","checkOverrides","takeWhile","cr","get","bindContract","assertInvariants","freeze","ASSERTION_FAILED","MSG_INVALID_ARG_LENGTH","MSG_NO_STATIC","MSG_NO_MATCHING_FEATURE","MSG_DUPLICATE_OVERRIDE","MSG_NOT_CONTRACTED","MSG_MISSING_FEATURE","MSG_SINGLE_RETRY","MSG_INVALID_CONTEXT","condition","ErrorConstructor","Boolean","p","q","Contracted","override","implies","ClassRegistry","WeakMap","has","set","ClassRegistration","checkedFeature","featureName","fnOrig","innerCheckedFeature","Reflect","className","name","apply","result","assertDemands","old","unChecked","features","hasGetter","t0","Date","now","t1","error","hasRetried","call","proto","prototype","ownKeys","filter","map","getOwnPropertyDescriptor","ParentClass","getPrototypeOf","parentRegistration","parentRegistry","ancestryFeatures","flatMap","feature","hasSetter","isMethod","enumerable","getter","setter","descriptor","ancestryFeatureNames","Set","hasOverrides","str","String","findFeature","find","ancestorFeature","isAccessor","undefined","memberType","overriddenOriginalDescriptor","ctx","d","demandsError","assertEnsures","e","ensuresError","iv","toString","object","xs","pred","length","slice","fn","target","isStatic","TypeError","ancFeature","thisMethod","ancMethod","configurable","writable","_","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.js","mappings":";CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,EACvE,CACA,CATD,CASGC,MAAM,2FCCT,MAAMC,UAAuBC,MAMzBC,YAAYC,GACRC,MAAMD,EACV,EAGJ,UAAeH,61BCdf,eAEMK,EAAcC,OAAO,eACrBC,EAAYD,OAAO,aACnBE,EAASF,OAAO,UAkEd,EAAAD,YAAAA,EAAqB,EAAAE,UAAAA,EAAR,EAAAC,OAAAA,EA/BrB,MAAa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kDACIH,YAAY,EACZoC,cAAc,GACTvC,EAAQe,WAAgC,CAAC,EAApB,CAACyB,UAAU,IACjCxC,EAAQpB,UAAY,CAACvC,OAAO,IAAA7B,QAAQ9B,KAAKG,YAAoB,EAAAuB,cAAe,EAAA0C,mBAAqB,GAAM,CAAC,GACxGkD,EAAQC,UAAY,CAACpC,IAAI4E,IAAI,IAAAjI,QAAQ9B,KAAKG,YAAoB,EAAAuB,cAAe,EAAA0C,mBAAqB,GAAM,CAAC,GACzGkD,EAAQE,SAAW,CAACpG,SAAS,IAAAU,QAAQ9B,KAAKG,YAAoB,EAAAuB,cAAe,EAAA0C,mBAAqB,GAAM,CAAC,EAErH,ICzDI4F,EAA2B,CAAC,SAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB5B,IAAjB6B,EACH,OAAOA,EAAazK,QAGrB,IAAIC,EAASqK,EAAyBE,GAAY,CAGjDxK,QAAS,CAAC,GAOX,OAHA0K,EAAoBF,GAAUzD,KAAK9G,EAAOD,QAASC,EAAQA,EAAOD,QAASuK,GAGpEtK,EAAOD,OACf,CCnB0BuK,CAAoB","sources":["webpack://@final-hill/decorator-contracts/webpack/universalModuleDefinition","webpack://@final-hill/decorator-contracts/./src/AssertionError.ts","webpack://@final-hill/decorator-contracts/./src/Contract.ts","webpack://@final-hill/decorator-contracts/./src/Contracted.ts","webpack://@final-hill/decorator-contracts/./src/Messages.ts","webpack://@final-hill/decorator-contracts/./src/assert.ts","webpack://@final-hill/decorator-contracts/./src/implies.ts","webpack://@final-hill/decorator-contracts/./src/index.ts","webpack://@final-hill/decorator-contracts/./src/lib/CLASS_REGISTRY.ts","webpack://@final-hill/decorator-contracts/./src/lib/ClassRegistration.ts","webpack://@final-hill/decorator-contracts/./src/lib/Feature.ts","webpack://@final-hill/decorator-contracts/./src/lib/assertDemands.ts","webpack://@final-hill/decorator-contracts/./src/lib/assertEnsures.ts","webpack://@final-hill/decorator-contracts/./src/lib/assertInvariants.ts","webpack://@final-hill/decorator-contracts/./src/lib/deepFreeze.ts","webpack://@final-hill/decorator-contracts/./src/lib/index.ts","webpack://@final-hill/decorator-contracts/./src/lib/takeWhile.ts","webpack://@final-hill/decorator-contracts/./src/lib/unChecked.ts","webpack://@final-hill/decorator-contracts/./src/override.ts","webpack://@final-hill/decorator-contracts/webpack/bootstrap","webpack://@final-hill/decorator-contracts/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(this, () => {\nreturn ","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\n/**\r\n * An AssertionError represents a failed assertion with an associated message\r\n */\r\nclass AssertionError extends Error {\r\n /**\r\n * Constructs a new instance of AssertionError\r\n *\r\n * @param {string} message - The associated message\r\n */\r\n constructor(message: string) {\r\n super(message);\r\n }\r\n}\r\n\r\nexport default AssertionError;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport {deepFreeze, fnTrue} from './lib';\r\n\r\nconst checkedMode = Symbol('checkedMode'),\r\n invariant = Symbol('invariant'),\r\n extend = Symbol('extend');\r\n\r\ntype AnyObject = Record<PropertyKey, any>;\r\ntype AnyFunc = (...args: any[]) => any;\r\n\r\ntype NonFunctionPropertyNames<T extends AnyObject> = { [K in keyof T]: T[K] extends AnyFunc ? never : K }[keyof T];\r\ntype Properties<T extends AnyObject> = Pick<T, NonFunctionPropertyNames<T>>;\r\n\r\nexport type Invariant<T extends AnyObject> = (self: T) => boolean;\r\nexport type Demands<T extends AnyObject, F extends T[any]> = (self: T, ...args: Parameters<F>) => boolean;\r\nexport type Ensures<T extends AnyObject, F extends T[any]> = (self: T, old: Properties<T>, ...args: Parameters<F>) => boolean;\r\nexport type Rescue<T extends AnyObject, F extends T[any]> = (\r\n self: T,\r\n error: Error,\r\n args: F extends AnyFunc ? Parameters<F> : [F],\r\n retry: F extends AnyFunc ? (...args: Parameters<F>) => any : (value: F) => void\r\n) => void;\r\n\r\nexport type ContractOptions<\r\n T extends AnyObject\r\n> = {\r\n [extend]: Contract<T>;\r\n [invariant]: Invariant<T>;\r\n [checkedMode]: boolean;\r\n} & {\r\n [K in keyof T]?: FeatureOption<T, T[K]>\r\n};\r\n\r\nexport interface FeatureOption<T extends AnyObject, F extends T[any]> {\r\n demands?: Demands<T,F>;\r\n ensures?: Ensures<T,F>;\r\n rescue?: Rescue<T,F>;\r\n within?: number;\r\n}\r\n\r\nexport class Contract<T extends AnyObject> {\r\n #invariant: Invariant<T>;\r\n [checkedMode]: boolean;\r\n readonly [extend]?: Contract<T>;\r\n readonly assertions: ContractOptions<T> = Object.create(null);\r\n\r\n constructor(assertions: Partial<ContractOptions<T>> = Object.create(null)) {\r\n this[extend] = assertions[extend];\r\n this[checkedMode] = assertions[checkedMode] ?? true;\r\n this.#invariant = assertions[invariant] ?? fnTrue;\r\n\r\n Object.keys(assertions).forEach(propertyKey => {\r\n const featureOption = assertions[propertyKey]!;\r\n Object.defineProperty(this.assertions,propertyKey, {\r\n value: {\r\n demands: featureOption.demands ?? fnTrue,\r\n ensures: featureOption.ensures ?? fnTrue,\r\n rescue: featureOption.rescue,\r\n within: featureOption.within\r\n }\r\n });\r\n });\r\n\r\n deepFreeze(this.assertions);\r\n }\r\n\r\n get [invariant](): Invariant<T> {\r\n return this.#invariant;\r\n }\r\n}\r\n\r\nexport {checkedMode, extend, invariant};","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { ClassRegistration, CLASS_REGISTRY, ClassType, Feature, takeWhile, assertInvariants } from './lib';\r\nimport { assert, checkedMode, Contract, extend } from './';\r\nimport { MSG_BAD_SUBCONTRACT, MSG_NO_PROPERTIES, MSG_SINGLE_CONTRACT } from './Messages';\r\n\r\nconst isContracted = Symbol('isContracted'),\r\n innerContract = Symbol('innerContract');\r\n\r\n/**\r\n * Checks the features of the provided object for properties.\r\n * If any are found an exception is thrown\r\n * @param {ClassRegistration} registration - The ClassRegistration for the object\r\n * @param {U} obj - The object to check\r\n * @throws {AssertionError} - Throws if a property is found\r\n * @returns {boolean} - The result of the test\r\n */\r\nfunction hasProperties<U>(registration: ClassRegistration, obj: U): boolean {\r\n return Object.entries(Object.getOwnPropertyDescriptors(obj))\r\n .some(([key, desc]) => new Feature(registration, key, desc).isProperty);\r\n}\r\n\r\n/**\r\n * Associates a contract with a class via the mixin pattern.\r\n *\r\n * @param {Contract} contract The Contract definition\r\n * @param {T} Base An optional base class\r\n * @returns {T} The base class for extension\r\n * @example\r\n *\r\n * @Contracted(stackContract)\r\n * class Stack<T> { ... }\r\n */\r\nfunction Contracted<\r\n T extends Contract<any> = Contract<any>,\r\n U extends ClassType<any> = ClassType<any>\r\n>(contract: T = new Contract() as T): ClassDecorator {\r\n return function (Base: U & { [innerContract]?: Contract<any> }) {\r\n assert(!Object.getOwnPropertySymbols(Base).includes(isContracted), MSG_SINGLE_CONTRACT);\r\n\r\n if (contract[checkedMode] === false) {\r\n return Base;\r\n }\r\n\r\n const baseContract = Base[innerContract];\r\n assert(\r\n !baseContract ||\r\n baseContract && contract[extend] instanceof baseContract.constructor,\r\n MSG_BAD_SUBCONTRACT\r\n );\r\n\r\n abstract class InnerContracted extends Base {\r\n // prevents multiple @Contracted decorators from being applied\r\n static readonly [isContracted] = true;\r\n\r\n constructor(...args: any[]) {\r\n super(...args);\r\n\r\n const Class = this.constructor as ClassType<any>,\r\n classRegistration = CLASS_REGISTRY.getOrCreate(Class);\r\n\r\n assert(!hasProperties(classRegistration, this), MSG_NO_PROPERTIES);\r\n\r\n if (!classRegistration.contractsChecked) {\r\n let ancRegistrations = classRegistration.ancestry().reverse();\r\n // top-down check overrides and pre-existing properties\r\n [...ancRegistrations, classRegistration].forEach(ancRegistration => {\r\n if (!ancRegistration.contractsChecked) {\r\n ancRegistration.checkOverrides();\r\n ancRegistration.contractsChecked = true;\r\n }\r\n });\r\n\r\n // bottom-up to closest Contracted class bind contracts\r\n ancRegistrations = takeWhile(ancRegistrations.reverse(), (cr => cr.Class !== Base));\r\n [classRegistration, ...ancRegistrations, CLASS_REGISTRY.get(Base)!].forEach(registration => {\r\n registration.bindContract(InnerContracted[innerContract]);\r\n });\r\n }\r\n\r\n assertInvariants(this, InnerContracted[innerContract]);\r\n\r\n return this;\r\n }\r\n\r\n // FIXME: dirty hack. Possibly resolved by moving to contracts as classes\r\n // The static getter is used by the construction invariant check\r\n // The instance getter is used by the feature declarations\r\n static get [innerContract]() { return contract; }\r\n get [innerContract]() { return contract; }\r\n }\r\n\r\n const classRegistration = CLASS_REGISTRY.getOrCreate(InnerContracted);\r\n classRegistration.contractsChecked = false;\r\n\r\n Object.freeze(Base);\r\n\r\n return InnerContracted;\r\n } as ClassDecorator;\r\n}\r\n\r\nexport { isContracted, innerContract };\r\nexport default Contracted;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nexport const ASSERTION_FAILED = 'Assertion failure';\r\nexport const MSG_INVALID_ARG_LENGTH = 'An overridden method must have the same number of parameters as its ancestor method';\r\nexport const MSG_NO_STATIC = 'Only instance members can be decorated, not static members';\r\nexport const MSG_NO_MATCHING_FEATURE = 'This feature does not override an ancestor feature.';\r\nexport const MSG_DUPLICATE_OVERRIDE = 'Only a single @override decorator can be assigned to a class member';\r\nexport const MSG_NO_PROPERTIES = 'Public properties are forbidden';\r\nexport const MSG_NOT_CONTRACTED = 'The current class or one of its ancestors must declare @Contracted(...)';\r\nexport const MSG_MISSING_FEATURE = 'The requested feature is not registered';\r\nexport const MSG_SINGLE_CONTRACT = 'Only a single @Contracted decorator is allowed per class';\r\nexport const MSG_SINGLE_RETRY = 'retry can only be called once';\r\nexport const MSG_INVALID_CONTEXT = 'A contracted feature can not be applied to objects of a different base class';\r\nexport const MSG_BAD_SUBCONTRACT = 'A sub contract must extend a base contract';","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport AssertionError from './AssertionError';\r\nimport { ASSERTION_FAILED } from './Messages';\r\nimport { Constructor } from './';\r\n\r\n/**\r\n * An assertion is an expression of a property that must be true at a particular\r\n * point of step of program execution. It consists of a boolean expression\r\n * and a message. This function tests the provided condition. If the condition\r\n * is false an AssertionError is raised with an optional message.\r\n * If the provided condition is true then the function returns without raising an error\r\n *\r\n * @param {boolean} condition - The condition to test\r\n * @param {string} message - A descriptive message to associate with the AssertionError\r\n * @param {ClassType<Error>} ErrorConstructor - The constructor of the Error to use\r\n * @throws {Error} - When the condition is false\r\n * @see AssertionError\r\n * @throws {AssertionError} - Throws an AssertionError by default if the condition is false\r\n *\r\n * @example\r\n * let x = 15;\r\n * assert(x > 5, `Expected: x > 5. Actual: x = ${x}`)\r\n *\r\n * @example\r\n * let name = \"Tom\"\r\n * assert(name.trim().length > 0, 'Name is required', TypeError)\r\n */\r\nexport default function assert(condition: unknown, message = ASSERTION_FAILED, ErrorConstructor: Constructor<Error> = AssertionError): asserts condition {\r\n if (Boolean(condition) == false) {\r\n throw new ErrorConstructor(message);\r\n }\r\n}","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\n/**\r\n * Material Implication.\r\n * `p → q`\r\n * Also referred to as `if-then`.\r\n * An example of usage is the encoding of \"sunny weather is a precondition of visiting the beach\"\r\n * This is logically equivalent to: !p || q\r\n *\r\n * @example\r\n * implies(weather.isSunny, person.visitsBeach)\r\n *\r\n * @param {boolean} p - The antecedent\r\n * @param {boolean} q - The consequent\r\n * @returns {boolean} - The result\r\n */\r\nexport default function implies(p: boolean, q: boolean): boolean {\r\n return !p || q;\r\n}","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport AssertionError from './AssertionError';\r\nimport Contracted, { innerContract } from './Contracted';\r\nimport override from './override';\r\nimport assert from './assert';\r\nimport implies from './implies';\r\n\r\nexport { AssertionError, Contracted, implies, innerContract, override, assert };\r\nexport { Contract, extend, invariant, Invariant, checkedMode, Rescue } from './Contract';\r\nexport { Constructor, AbstractConstructor, ClassType } from './lib/ClassType';","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport {ClassRegistration, ClassType} from './';\r\n\r\n/**\r\n * A WeakMap that tracks class registrations.\r\n * @see {@link ClassRegistration}\r\n */\r\nclass ClassRegistry extends WeakMap<ClassType<any>, ClassRegistration> {\r\n /**\r\n * Returns the class registry defined for the current class.\r\n * If the registry is undefined, a new one is created\r\n *\r\n * @param {ClassType<any>} Class - The class\r\n * @returns {ClassRegistration} - The ClassRegistration\r\n */\r\n getOrCreate(Class: ClassType<any>): ClassRegistration {\r\n if(this.has(Class)) {\r\n return this.get(Class)!;\r\n } else {\r\n this.set(Class, new ClassRegistration(Class));\r\n\r\n return this.get(Class)!;\r\n }\r\n }\r\n}\r\n\r\nconst CLASS_REGISTRY = new ClassRegistry();\r\n\r\nexport default CLASS_REGISTRY;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { MSG_INVALID_CONTEXT, MSG_SINGLE_RETRY } from '../Messages';\r\nimport { assert, checkedMode, Contract, innerContract } from '../';\r\nimport { assertInvariants, assertDemands, CLASS_REGISTRY, ClassType, Feature, unChecked } from './';\r\nimport assertEnsures from './assertEnsures';\r\n\r\n/**\r\n * Manages the evaluation of contract assertions for a feature\r\n *\r\n * @param {string} featureName - The name of the feature\r\n * @param {function(...args: any[]): any} fnOrig - The original unchecked feature\r\n * @param {ClassRegistration} registration - The class registration\r\n *\r\n * @returns {function(...args: any[]): any} - The original function augments with assertion checks\r\n */\r\nfunction checkedFeature(\r\n featureName: PropertyKey,\r\n fnOrig: (...args: any[]) => any,\r\n registration: ClassRegistration\r\n) {\r\n return function innerCheckedFeature(this: any, ...args: any[]) {\r\n const { Class } = registration;\r\n\r\n assert(this instanceof Class, MSG_INVALID_CONTEXT);\r\n\r\n const contract = Reflect.get(this, innerContract),\r\n className = Class.name;\r\n if (!contract[checkedMode]) {\r\n return fnOrig.apply(this, args);\r\n }\r\n\r\n assertInvariants(this, contract);\r\n assertDemands(this, contract, className, featureName, args);\r\n\r\n let result;\r\n try {\r\n const old = Object.create(null);\r\n unChecked(contract, () => {\r\n registration.features.forEach(({ name, hasGetter }) => {\r\n if (hasGetter) {\r\n Object.defineProperty(old, name, { value: this[name] });\r\n }\r\n });\r\n });\r\n const within: number = Reflect.get(contract.assertions, featureName)?.within,\r\n // TODO:Not all environments currently support performance.now() as a global and conditional import is inconvenient\r\n t0 = Date.now();\r\n result = fnOrig.apply(this, args);\r\n const t1 = Date.now();\r\n if (within) {\r\n assert(t1 - t0 < within,\r\n `Timing constraint violated. Constraint: ${within}ms, actual: ${t1 - t0}ms`\r\n );\r\n }\r\n assertEnsures(this, contract, className, featureName, old, args);\r\n } catch (error) {\r\n const rescue = Reflect.get(contract.assertions, featureName)?.rescue;\r\n if (rescue == null) {\r\n assertInvariants(this, contract);\r\n throw error;\r\n }\r\n let hasRetried = false;\r\n unChecked(contract, () => {\r\n rescue.call(this, this, error, [], (...args: any[]) => {\r\n assert(!hasRetried, MSG_SINGLE_RETRY);\r\n hasRetried = true;\r\n contract[checkedMode] = true;\r\n result = innerCheckedFeature.call(this, ...args);\r\n });\r\n });\r\n if (!hasRetried) {\r\n assertInvariants(this, contract);\r\n throw error;\r\n }\r\n }\r\n\r\n assertInvariants(this, contract);\r\n\r\n return result;\r\n };\r\n}\r\n\r\nclass ClassRegistration {\r\n #features: Feature[];\r\n contract!: Contract<any>; // Assigned by the Contracted class via this.bindContract\r\n contractsChecked = false;\r\n\r\n constructor(readonly Class: ClassType<any>) {\r\n const proto = this.Class.prototype;\r\n this.#features =\r\n Reflect.ownKeys(proto)\r\n .filter(key => key != 'constructor' && key !== innerContract)\r\n .map(key => new Feature(this, key, Object.getOwnPropertyDescriptor(proto, key)!));\r\n }\r\n\r\n /**\r\n * Returns the features associated with the registered class.\r\n *\r\n * @returns {Set<Feature>} The set of features\r\n */\r\n get features(): Feature[] {\r\n return [...this.#features];\r\n }\r\n\r\n /**\r\n * Returns a reference to the parent class\r\n */\r\n get ParentClass(): ClassType<any> | null {\r\n return Object.getPrototypeOf(this.Class.prototype)?.constructor;\r\n }\r\n\r\n /**\r\n * Returns the classRegistration of the parent class\r\n */\r\n get parentRegistration(): ClassRegistration | null {\r\n return this.ParentClass == null ? null : CLASS_REGISTRY.getOrCreate(this.ParentClass);\r\n }\r\n\r\n /**\r\n * Returns the registered class's ancestor class registrations.\r\n * Does not include the current class.\r\n *\r\n * @returns {ClassRegistration[]} - The ancestor class registrations\r\n */\r\n ancestry(): ClassRegistration[] {\r\n if (this.ParentClass == null) {\r\n return [];\r\n } else {\r\n const parentRegistry = CLASS_REGISTRY.getOrCreate(this.ParentClass);\r\n\r\n return [parentRegistry, ...parentRegistry.ancestry()];\r\n }\r\n }\r\n\r\n /**\r\n * Returns the features associated with the registered class's ancestors.\r\n * Does not include the current class.\r\n *\r\n * @returns {Feature[]} - The feature names\r\n */\r\n ancestryFeatures(): Feature[] {\r\n return this.ancestry().flatMap(({ features }) => features);\r\n }\r\n\r\n bindContract<T extends Contract<any>>(contract: T) {\r\n this.contract = contract;\r\n if (!contract[checkedMode]) {\r\n return;\r\n }\r\n const proto = this.Class.prototype;\r\n this.features.forEach(feature => {\r\n const { name, hasGetter, hasSetter, isMethod } = feature;\r\n\r\n Object.defineProperty(proto, name, {\r\n enumerable: true,\r\n ...(hasGetter ? { get: checkedFeature(name, feature.getter!, this) } : {}),\r\n ...(hasSetter ? { set: checkedFeature(name, feature.setter!, this) } : {}),\r\n ...(isMethod ? { value: checkedFeature(name, feature.value, this) } : {})\r\n });\r\n\r\n feature.descriptor = Object.getOwnPropertyDescriptor(proto, name)!;\r\n });\r\n }\r\n\r\n /**\r\n * Checks the features of the registered class for missing override decorators\r\n * @throws {AssertionError} - Throws if the verification fails\r\n */\r\n checkOverrides(): void {\r\n const ancestryFeatureNames = new Set(this.ancestryFeatures().map(({ name }) => name));\r\n this.features.forEach(({ name, hasOverrides }) => {\r\n const str = `${this.Class.name}.prototype.${String(name)}`;\r\n assert(!hasOverrides || ancestryFeatureNames.has(name), `Unnecessary @override declaration on ${str}`);\r\n assert(hasOverrides || !ancestryFeatureNames.has(name), `@override decorator missing on ${str}`);\r\n });\r\n }\r\n\r\n /**\r\n * Searches the current class and its ancestors for the nearest feature\r\n * matching the provided propertyKey.\r\n *\r\n * @param {PropertyKey} propertyKey - The key being searched\r\n * @returns {Feature | undefined} - The feature if it exists else otherwise\r\n */\r\n findFeature(propertyKey: PropertyKey): Feature | undefined {\r\n return this.features.find(({ name }) => name === propertyKey) ??\r\n this.parentRegistration?.findFeature(propertyKey);\r\n }\r\n}\r\n\r\nexport default ClassRegistration;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport ClassRegistration from './ClassRegistration';\r\n\r\nclass Feature {\r\n #descriptor: PropertyDescriptor;\r\n #overriddenOriginalDescriptor: PropertyDescriptor | undefined;\r\n\r\n /**\r\n * Does the current feature have an `@override` declaration?\r\n */\r\n hasOverrides = false;\r\n\r\n constructor(readonly classRegistration: ClassRegistration, readonly name: PropertyKey, descriptor: PropertyDescriptor){\r\n this.#descriptor = descriptor;\r\n }\r\n\r\n /**\r\n * Finds the nearest ancestor feature of the same key if it exists\r\n */\r\n get ancestorFeature(): Feature | null {\r\n return this.classRegistration.ancestryFeatures().filter(feature => feature.name === this.name)[0];\r\n }\r\n\r\n /**\r\n * Returns a reference to the getter if it exists\r\n */\r\n get getter() {\r\n return this.#descriptor.get;\r\n }\r\n\r\n /**\r\n * Determines if the feature is an accessor with a getter defined\r\n */\r\n get hasGetter(): boolean {\r\n return this.isAccessor && this.#descriptor.get != undefined;\r\n }\r\n\r\n /**\r\n * Determines if the feature is an accessor with a setter defined\r\n */\r\n get hasSetter(): boolean {\r\n return this.isAccessor && this.#descriptor.set != undefined;\r\n }\r\n\r\n /**\r\n * Determines if the feature is a property\r\n */\r\n get isProperty(): boolean {\r\n return typeof this.#descriptor.value != 'function' &&\r\n typeof this.#descriptor.value != 'undefined';\r\n }\r\n\r\n /**\r\n * Determines if the feature is a method\r\n */\r\n get isMethod(): boolean {\r\n return typeof this.#descriptor.value == 'function';\r\n }\r\n\r\n /**\r\n * Determines if the feature is an accessor\r\n */\r\n get isAccessor(): boolean {\r\n return typeof this.#descriptor.value == 'undefined';\r\n }\r\n\r\n /**\r\n * Returns a string representing the type of feature.\r\n * @returns {string} 'method' | 'property' | 'accessor'\r\n */\r\n get memberType(): 'method' | 'property' | 'accessor' {\r\n return this.isMethod ? 'method' :\r\n this.isProperty ? 'property' :\r\n 'accessor';\r\n }\r\n\r\n /**\r\n * Returns a reference to the setter if it exists\r\n */\r\n get setter() {\r\n return this.#descriptor.set;\r\n }\r\n\r\n /**\r\n * If the feature is a method, returns a reference to the implementation.\r\n * If the feature is a property, returns the value of the property\r\n * Otherwise returns undefined\r\n */\r\n get value(): any {\r\n return this.#descriptor.value;\r\n }\r\n\r\n /**\r\n * The original feature descriptor which was replaced by the `override` decorator\r\n */\r\n get overriddenOriginalDescriptor(): PropertyDescriptor| undefined {\r\n return this.#overriddenOriginalDescriptor;\r\n }\r\n set overriddenOriginalDescriptor(value: PropertyDescriptor | undefined) {\r\n this.#overriddenOriginalDescriptor = value;\r\n }\r\n\r\n /**\r\n * Returns a reference to the descriptor\r\n */\r\n get descriptor() {\r\n return this.#descriptor;\r\n }\r\n set descriptor(desc: PropertyDescriptor) {\r\n this.#descriptor = desc;\r\n }\r\n}\r\n\r\nexport default Feature;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { Demands, extend } from '../Contract';\r\nimport { assert, checkedMode, Contract } from '../';\r\nimport unChecked from './unChecked';\r\n\r\n/**\r\n * Applies invariant assertions to the provided class instance\r\n *\r\n * @param {U} ctx - The context class\r\n * @param {Contract<any>} contract - The contract\r\n * @param {string} className - The name of the class\r\n * @param {PropertyKey} featureName - The name of the feature\r\n * @param {any[]} args - The arguments of the feature to apply to the assertion\r\n * @throws {AssertionError}\r\n */\r\nfunction assertDemands<U extends object>(ctx: U, contract: Contract<U>, className: string, featureName: PropertyKey, args: any[]) {\r\n let result = true;\r\n const d: Demands<any, any> | undefined = Reflect.get(contract.assertions, featureName)?.demands,\r\n demandsError = `demands not met on ${className}.prototype.${String(featureName)}\\r\\n${d}`;\r\n if (contract[checkedMode]) {\r\n if (d) {\r\n unChecked(contract, () =>\r\n result = d.call(ctx, ctx, ...args)\r\n );\r\n }\r\n }\r\n\r\n if (contract[extend] && !result) {\r\n assertDemands(ctx, contract[extend], className, featureName, args);\r\n } else {\r\n assert(result, demandsError);\r\n }\r\n}\r\n\r\nexport default assertDemands;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { Ensures, extend } from '../Contract';\r\nimport { assert, checkedMode, Contract } from '../';\r\nimport unChecked from './unChecked';\r\n\r\n/**\r\n * Applies invariant assertions to the provided class instance\r\n *\r\n * @param {U} ctx - The context class\r\n * @param {Contract<any>} contract - The contract\r\n * @param {string} className - The name of the class\r\n * @param {PropertyKey} featureName - The name of the feature\r\n * @param {U} old - The original properties before execution\r\n * @param {any[]} args - The arguments of the feature to apply to the assertion\r\n * @throws {AssertionError}\r\n */\r\nfunction assertEnsures<U>(\r\n ctx: U,\r\n contract: Contract<any>,\r\n className: string,\r\n featureName: PropertyKey,\r\n old: U,\r\n args: any[]\r\n){\r\n const e: Ensures<any, any> | undefined = Reflect.get(contract.assertions, featureName)?.ensures,\r\n ensuresError = `ensures not met on ${className}.prototype.${String(featureName)}\\r\\n${e}`;\r\n\r\n if(contract[checkedMode]) {\r\n if(e) {\r\n unChecked(contract, () =>\r\n assert(e.call(ctx, ctx, old, ...args), ensuresError)\r\n );\r\n }\r\n }\r\n\r\n if(contract[extend]) {\r\n assertEnsures(ctx, contract[extend]!, className, featureName, old, args);\r\n }\r\n}\r\n\r\nexport default assertEnsures;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { unChecked } from './';\r\nimport { assert, checkedMode, Contract, extend, invariant } from '../';\r\n\r\n/**\r\n * Applies invariant assertions to the provided class instance\r\n *\r\n * @param {U} ctx - The context class\r\n * @param {Contract<any>} contract - The contract\r\n * @throws {AssertionError}\r\n */\r\nfunction assertInvariants<U>(ctx: U, contract: Contract<any>) {\r\n if (contract[checkedMode]) {\r\n unChecked(contract, () => {\r\n const iv = contract[invariant];\r\n assert(iv.call(ctx, ctx), `Invariant violated. ${iv.toString()}`);\r\n });\r\n }\r\n\r\n if (contract[extend]) {\r\n assertInvariants(ctx, contract[extend]!);\r\n }\r\n}\r\n\r\nexport default assertInvariants;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\n /**\r\n * Apply Object.freeze recursively\r\n * @param {object} object - The object to freeze\r\n */\r\nfunction deepFreeze(object: Record<PropertyKey, any>): void {\r\n // Freeze properties before freezing self\r\n for (const [,value] of Object.entries(object)) {\r\n if (value != undefined && typeof value === 'object') {\r\n deepFreeze(value);\r\n }\r\n }\r\n\r\n Object.freeze(object);\r\n}\r\n\r\nexport default deepFreeze;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport assertDemands from './assertDemands';\r\nimport assertEnsures from './assertEnsures';\r\nimport assertInvariants from './assertInvariants';\r\nimport CLASS_REGISTRY from './CLASS_REGISTRY';\r\nimport ClassRegistration from './ClassRegistration';\r\nimport {ClassType} from './ClassType';\r\nimport deepFreeze from './deepFreeze';\r\nimport Feature from './Feature';\r\nimport takeWhile from './takeWhile';\r\nimport unChecked from './unChecked';\r\n\r\nconst fnTrue = () => true;\r\n\r\nexport {\r\n assertDemands,\r\n assertEnsures,\r\n assertInvariants,\r\n CLASS_REGISTRY,\r\n ClassRegistration,\r\n ClassType,\r\n deepFreeze,\r\n Feature,\r\n fnTrue,\r\n takeWhile,\r\n unChecked\r\n};","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\n /**\r\n * Creates a new array from another one. Items from the original array\r\n * are taken if the provided predicate succeed. When the predicate fails,\r\n * no new items are taken\r\n *\r\n * @param {T[]} xs - The array to evaluate\r\n * @param {function(x:T): T[]} pred - The condition to apply to every element\r\n * @returns {T[]} - The filtered list\r\n */\r\nexport function takeWhile<T>(xs: T[], pred: (x: T) => boolean): T[] {\r\n return xs.length && pred(xs[0]) ? [xs[0], ...takeWhile(xs.slice(1), pred)] : [];\r\n}\r\n\r\nexport default takeWhile;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { checkedMode, Contract } from '../';\r\n\r\n/**\r\n * Disable contract checking for the provided function\r\n * @param {Contract<any>} contract - The code contract\r\n * @param {function(...args: any[]): any} fn - The function to execute\r\n */\r\nconst unChecked = (contract: Contract<any>, fn: () => any) => {\r\n try {\r\n contract[checkedMode] = false;\r\n fn();\r\n } finally {\r\n contract[checkedMode] = true;\r\n }\r\n};\r\n\r\nexport default unChecked;","/*!\r\n * @license\r\n * Copyright (C) 2022 Final Hill LLC\r\n * SPDX-License-Identifier: AGPL-3.0-only\r\n * @see <https://spdx.org/licenses/AGPL-3.0-only.html>\r\n */\r\n\r\nimport { assert } from './';\r\nimport { MSG_NO_STATIC, MSG_NO_MATCHING_FEATURE, MSG_DUPLICATE_OVERRIDE, MSG_INVALID_ARG_LENGTH, MSG_NOT_CONTRACTED, MSG_MISSING_FEATURE } from './Messages';\r\nimport { CLASS_REGISTRY } from './lib';\r\nimport { isContracted } from './Contracted';\r\n\r\n/**\r\n * The 'override' decorator asserts that the current class feature is a specialization or\r\n * replacement of an ancestor class's feature of the same name and argument count\r\n *\r\n * @param {object} target - The class\r\n * @param {PropertyKey} propertyKey - The property key\r\n * @param {PropertyDescriptor} descriptor - The property descriptor\r\n * @returns {PropertyDescriptor} - The PropertyDescriptor\r\n */\r\nfunction override(target: Record<PropertyKey, any>, propertyKey: PropertyKey, descriptor: PropertyDescriptor): PropertyDescriptor {\r\n const Class = (target as any).constructor,\r\n isStatic = typeof target == 'function';\r\n\r\n assert(!isStatic, MSG_NO_STATIC, TypeError);\r\n\r\n const registration = CLASS_REGISTRY.getOrCreate(Class),\r\n feature = registration.findFeature(propertyKey);\r\n\r\n assert(feature != null, `${MSG_MISSING_FEATURE}: ${registration.Class.name}.prototype.${String(propertyKey)}`);\r\n\r\n const ancFeature = feature.ancestorFeature;\r\n\r\n assert(\r\n ancFeature != null && feature.memberType === ancFeature.memberType,\r\n `${MSG_NO_MATCHING_FEATURE} '${registration.Class.name}.prototype.${String(propertyKey)}'`\r\n );\r\n assert(!feature.hasOverrides, MSG_DUPLICATE_OVERRIDE);\r\n feature.hasOverrides = true;\r\n\r\n if(feature.isMethod) {\r\n const thisMethod: (...args: any[]) => any = feature.value,\r\n ancMethod: (...args: any[]) => any = ancFeature.value;\r\n assert(thisMethod.length == ancMethod.length, MSG_INVALID_ARG_LENGTH);\r\n }\r\n\r\n feature.overriddenOriginalDescriptor = descriptor;\r\n\r\n // method decorators are evaluated before class decorators\r\n return {\r\n enumerable: true,\r\n configurable: true,\r\n ...(!feature.isAccessor ? {writable: true} : {}),\r\n ...(feature.hasGetter ? {get(){ assert((this.constructor as any)[isContracted], MSG_NOT_CONTRACTED); } } : {}),\r\n ...(feature.hasSetter ? {set(_){ assert((this.constructor as any)[isContracted], MSG_NOT_CONTRACTED); } } : {}),\r\n ...(feature.isMethod ? {value() {assert((this.constructor as any)[isContracted], MSG_NOT_CONTRACTED); } } : {})\r\n };\r\n}\r\n\r\nexport default override;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(607);\n"],"names":["root","factory","exports","module","define","amd","a","i","this","AssertionError","Error","constructor","message","super","checkedMode","Symbol","invariant","extend","Contract","assertions","Object","create","fnTrue","keys","forEach","propertyKey","featureOption","defineProperty","value","demands","ensures","rescue","within","deepFreeze","isContracted","innerContract","contract","Base","assert","getOwnPropertySymbols","includes","MSG_SINGLE_CONTRACT","baseContract","MSG_BAD_SUBCONTRACT","InnerContracted","args","Class","classRegistration","CLASS_REGISTRY","getOrCreate","registration","entries","getOwnPropertyDescriptors","some","key","desc","Feature","isProperty","MSG_NO_PROPERTIES","contractsChecked","ancRegistrations","ancestry","reverse","ancRegistration","checkOverrides","takeWhile","cr","get","bindContract","assertInvariants","freeze","ASSERTION_FAILED","MSG_INVALID_ARG_LENGTH","MSG_NO_STATIC","MSG_NO_MATCHING_FEATURE","MSG_DUPLICATE_OVERRIDE","MSG_NOT_CONTRACTED","MSG_MISSING_FEATURE","MSG_SINGLE_RETRY","MSG_INVALID_CONTEXT","condition","ErrorConstructor","Boolean","p","q","Contracted","override","implies","ClassRegistry","WeakMap","has","set","ClassRegistration","checkedFeature","featureName","fnOrig","innerCheckedFeature","Reflect","className","name","apply","result","assertDemands","old","unChecked","features","hasGetter","t0","Date","now","t1","error","hasRetried","call","proto","prototype","ownKeys","filter","map","getOwnPropertyDescriptor","ParentClass","getPrototypeOf","parentRegistration","parentRegistry","ancestryFeatures","flatMap","feature","hasSetter","isMethod","enumerable","getter","setter","descriptor","ancestryFeatureNames","Set","hasOverrides","str","String","findFeature","find","ancestorFeature","isAccessor","undefined","memberType","overriddenOriginalDescriptor","ctx","d","demandsError","assertEnsures","e","ensuresError","iv","toString","object","xs","pred","length","slice","fn","target","isStatic","TypeError","ancFeature","thisMethod","ancMethod","configurable","writable","_","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
|
package/dist/lib/ClassType.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
5
5
|
* @see <https://spdx.org/licenses/AGPL-3.0-only.html>
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
declare type Constructor<T> = new (...args: any[]) => T;
|
|
8
|
+
declare type AbstractConstructor<T> = abstract new (...args: any[]) => T;
|
|
9
|
+
declare type ClassType<T> = Constructor<T> | AbstractConstructor<T>;
|
|
10
|
+
export { Constructor, AbstractConstructor, ClassType };
|