@final-hill/decorator-contracts 0.24.0 → 0.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.24.2
4
+
5
+ * Updated README to use images instead of mermaid diagrams
6
+ * Updated dependencies
7
+ * Improved error messaging of MSG_INVALID_CONTEXT
8
+ * Grammar + spelling fix of `CHANGELOG.md`
9
+
10
+ ## v0.24.1
11
+
12
+ * Bugfix of generated type declaration (#238)
13
+ * Updated README to reflect current features (#239)
14
+ * Updated README to use mermaid diagram
15
+
3
16
  ## v0.24.0
4
17
 
5
18
  * Updated debugger settings to leverage modern VSCode
@@ -25,7 +38,7 @@
25
38
 
26
39
  * Added `implies` function
27
40
  * Added `iff` function
28
- * Added topic tags to github repo
41
+ * Added topic tags to GitHub repo
29
42
  * Updated `package.json` keywords
30
43
 
31
44
  ## v0.21.2
@@ -81,23 +94,23 @@
81
94
  * BREAKING CHANGE: contracts now managed separate from the class
82
95
  * Rewrote README to reflect the new architecture
83
96
  * Updated dependencies
84
- * Merged jest.config.js into package.json
97
+ * Merged `jest.config.js` into `package.json`
85
98
  * Updated linting rules
86
99
  * Moved unit tests to separate folder
87
100
  * Public property definitions are now illegal
88
- * Fixed package.json debug command
101
+ * Fixed `package.json` debug command
89
102
  * Bugfix of invariant inheritance
90
103
 
91
104
  ## v0.19.0
92
105
 
93
106
  * Updated README to include unpkg reference
94
107
  * Enabled sourcemaps
95
- * npm audit fix
108
+ * `npm audit fix`
96
109
  * Updated dependencies
97
110
  * Linting fixes
98
- * Updated contact info in README and package.json
111
+ * Updated contact info in README and `package.json`
99
112
  * BREAKING CHANGE: Decorators now accept arrow functions instead of traditional functions. The first parameter is `self`.
100
- * BREAKING CHANGE: @ensures now provides `old` as a parameter to access instance property values before feature execution
113
+ * BREAKING CHANGE: `@ensures` now provides `old` as a parameter to access instance property values before feature execution
101
114
 
102
115
  ## v0.18.1
103
116
 
@@ -105,10 +118,10 @@
105
118
 
106
119
  ## v0.18.0
107
120
 
108
- * Fixed missing PredicateType issue
121
+ * Fixed missing `PredicateType` issue
109
122
  * Reorganized README
110
123
  * Added NPM badges to README
111
- * Added package.json reference to github issues
124
+ * Added `package.json` reference to GitHub issues
112
125
  * Added licensing info to README
113
126
  * Removed extraneous build dependency
114
127
 
@@ -130,31 +143,31 @@
130
143
 
131
144
  ## v0.17.0
132
145
 
133
- * Migrated repository from Azure Devops to GitHub
134
- * Migrated Azure Devops CI/CD workflows to GitHub actions
146
+ * Migrated repository from Azure DevOps to GitHub
147
+ * Migrated Azure DevOps CI/CD workflows to GitHub actions
135
148
  * Created CHANGELOG.md and removed related build script
136
149
  * Replaced `#{YEAR}#` token with literal year. Removed related build script
137
150
  * Removed VSCode Azure DevOps suggested extensions
138
151
  * Changed license to AGPL-3.0-only
139
- * Updated repository url to point to GitHub url
140
- * Changed library namespace: `@thenewobjective` -> `@final-hill`
152
+ * Updated repository URL to point to GitHub URL
153
+ * Changed library namespace: `@thenewobjective` → `@final-hill`
141
154
  * Updated README Dependencies table
142
- * Updated @rescue documentation
155
+ * Updated `@rescue` documentation
143
156
  * Replaced build versioning with explicit versioning
144
- * Enabled @rescue inheritance
157
+ * Enabled `@rescue` inheritance
145
158
  * Created CONTRIBUTING.md
146
159
 
147
160
  ## v0.16.0
148
161
 
149
- * If an exception is thrown in a class feature without a @rescue defined, then the exception is raised to its caller after the @invariant is checked
150
- * If an error is thrown in @demands, the error is raised to the caller
151
- * If an error is raised in a @ensures then the associated @rescue is executed
162
+ * If an exception is thrown in a class feature without a `@rescue` defined, then the exception is raised to its caller after the `@invariant` is checked
163
+ * If an error is thrown in `@demands`, the error is raised to the caller
164
+ * If an error is raised in a `@ensures` then the associated `@rescue` is executed
152
165
  * Updated README examples
153
166
  * Updated implementation to consolidate error messages
154
167
 
155
168
  ## v0.15.0
156
169
 
157
- * Switched from tslint to eslint
170
+ * Switched from `tslint` to `eslint`
158
171
  * Updated assertions to support assertion types from TypeScript 3.7
159
172
  * Removed Babel dependency
160
173
  * Refactoring improvements
@@ -164,12 +177,12 @@
164
177
 
165
178
  * Updated YAML scripts to reference new Azure vm image
166
179
  * Refactored Unit Tests
167
- * Refactored implementation to prefer 'const' declarations
180
+ * Refactored implementation to prefer `const` declarations
168
181
  * Refactored README examples
169
- * Refactored RescueType to separate file
182
+ * Refactored `RescueType` to separate file
170
183
  * Refactored Rescue Decorator
171
- * @rescue now preserves the invariant after execution
172
- * If a @rescue is executed and the retry argument is not called, then an error is thrown
184
+ * `@rescue` now preserves the invariant after execution
185
+ * If a `@rescue` is executed and the retry argument is not called, then an error is thrown
173
186
 
174
187
  ## v0.13.0
175
188
 
@@ -181,58 +194,58 @@
181
194
  * Refactored codebase to utilize new TypeScript features
182
195
  * Added Introduction to README
183
196
  * Updated package keywords
184
- * @invariant changed to accept functions directly instead of a record factory
185
- * Multiple @invariant declarations can be assigned to a class
197
+ * `@invariant` changed to accept functions directly instead of a record factory
198
+ * Multiple `@invariant` declarations can be assigned to a class
186
199
 
187
200
  ## v0.11.0
188
201
 
189
- * Renamed @requires to @demands
190
- * npm audit fixes
191
- * Multiple @demands can be assigned to a class feature
192
- * Implementation of @ensures decorator
202
+ * Renamed `@requires` to `@demands`
203
+ * `npm audit fix`
204
+ * Multiple `@demands` can be assigned to a class feature
205
+ * Implementation of `@ensures` decorator
193
206
  * Reorganized README
194
207
 
195
208
  ## v0.10.0
196
209
 
197
210
  * Significant refactoring and efficiency improvements
198
- * @requires can not be strengthened in a subtype
211
+ * `@requires` can not be strengthened in a subtype
199
212
 
200
213
  ## v0.9.0
201
214
 
202
215
  * Refactoring and efficiency improvements
203
- * @override requires @invariant declaration in class ancestry
216
+ * `@override` requires `@invariant` declaration in class ancestry
204
217
  * Updated Jest configuration for reporting and VSCode debug support
205
218
  * Cleanup of documentation
206
- * Added checkMode support to @rescue
219
+ * Added `checkMode` support to `@rescue`
207
220
  * Added Babel compilation
208
- * @requires now works with inheritance
221
+ * `@requires` now works with inheritance
209
222
 
210
223
  ## v0.8.0
211
224
 
212
- * Implementation of @rescue decorator
213
- * Renamed debugMode to checkMode
225
+ * Implementation of `@rescue` decorator
226
+ * Renamed `debugMode` to `checkMode`
214
227
  * Refactoring and efficiency improvements
215
- * @requires restricted to instance class features
228
+ * `@requires` restricted to instance class features
216
229
  * Added linting rule to validate file license header
217
230
  * Updated TypeScript to 3.7.2
218
231
 
219
232
  ## v0.7.0
220
233
 
221
- * @invariant restricted to only one declaration per class
222
- * @override now supports accessors
223
- * Updated package.json metadata for discoverability
234
+ * `@invariant` restricted to only one declaration per class
235
+ * `@override` now supports accessors
236
+ * Updated `package.json` metadata for discoverability
224
237
  * Added Further Reading section to README
225
238
 
226
239
  ## v0.6.0
227
240
 
228
- * @invariant signature changed to accept a function that returns a record of assertions
229
- * @override restricted to instance class features
230
- * @override extended with additional checks to support Substitutability
241
+ * `@invariant` signature changed to accept a function that returns a record of assertions
242
+ * `@override` restricted to instance class features
243
+ * `@override` extended with additional checks to support Substitutability
231
244
  * Added linting checks to the project
232
245
 
233
246
  ## v0.5.0
234
247
 
235
- * @override decorator implemented
248
+ * `@override` decorator implemented
236
249
 
237
250
  ## v0.4.0
238
251
 
@@ -241,12 +254,12 @@
241
254
  ## v0.3.0
242
255
 
243
256
  * Table of Contents added to README
244
- * @invariant supports no arguments
257
+ * `@invariant` supports no arguments
245
258
 
246
259
  ## v0.2.0
247
260
 
248
261
  * Added assertion documentation to README
249
- * Assertions support debugMode flag
262
+ * Assertions support `debugMode` flag
250
263
  * Assertions return a boolean
251
264
  * Assertions support throwing custom error types
252
265
 
@@ -254,16 +267,16 @@
254
267
 
255
268
  * Added installation instructions to README
256
269
  * Enabled project debugging
257
- * @invariant can accept multiple assertions
258
- * @invariant supports message : assertion pairs
259
- * Ancestor @invariant enforced in subclasses
260
- * Subclasses support additional @invariant declarations
261
- * Added built-types to tasks.json
270
+ * `@invariant` can accept multiple assertions
271
+ * `@invariant` supports message : assertion pairs
272
+ * Ancestor `@invariant` enforced in subclasses
273
+ * Subclasses support additional `@invariant` declarations
274
+ * Added built-types to `tasks.json`
262
275
  * Refactoring and typing improvements
263
276
 
264
277
  ## v0.0.2
265
278
 
266
- Updated package.json namespace to @thenewobjective prefix
279
+ Updated `package.json` namespace to `@thenewobjective` prefix
267
280
 
268
281
  ## v0.0.1
269
282
 
@@ -272,5 +285,5 @@ Updated package.json namespace to @thenewobjective prefix
272
285
  * Initial Branch configuration
273
286
  * Initial Release configuration
274
287
  * Build tokenization
275
- * Initial @invariant implementation
288
+ * Initial `@invariant` implementation
276
289
  * Initial Documentation
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.23.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.22.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.23.0"></script>`
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 can not be assigned an `@override`
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
- class Stack<T> extends Contracted(stackContract) implements StackType<T> {
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, can not be assigned a `demands`
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, can not 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.
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 can not 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.
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);
@@ -901,9 +906,7 @@ where you can lexically determine where the handling occurs and optionally perfo
901
906
 
902
907
  When `obj.feature` is called the happy path is:
903
908
 
904
- ```ts
905
- invariant -> demands -> { feature body } -> ensures -> invariant
906
- ```
909
+ ![image](./docs/happy-path.png)
907
910
 
908
911
  If an error is thrown and there is no `rescue` defined then the `invariant`
909
912
  is checked before the error is raised to the caller.
@@ -912,7 +915,7 @@ If an error is thrown in the `invariant` then it is raised to the caller.
912
915
 
913
916
  If an error is thrown in the `demands` then the error is raised to the caller.
914
917
  In this case the `invariant` is not checked because the feature body has not
915
- been entered and the assertion can not modify the state of the class without
918
+ been entered and the assertion cannot modify the state of the class without
916
919
  calling another method which is governed by its own contracts.
917
920
 
918
921
  If an error is thrown by the feature body or the `ensures` then
@@ -922,22 +925,7 @@ starts from the beginning.
922
925
  If `rescue` throws an error or does not call `retry` then the
923
926
  `invariant` is checked before the error is raised to the caller.
924
927
 
925
- ```ts
926
- (error) <-----------------+
927
- ^ (throws) | (throws)
928
- | |
929
- obj.feature(...) -> @invariant -> @demands -> { feature body } --+
930
- ^ | |
931
- | | (throws) |
932
- | (retry) | | (return)
933
- +------------ @rescue <---+------+ |
934
- | | |
935
- | (throws|return) | |
936
- (error) <--- @invariant <-+ | |
937
- | (throws) |
938
- | |
939
- (return) <-- @invariant <---------------- @ensures <------+
940
- ```
928
+ ![image](./docs/order-of-assertions.png)
941
929
 
942
930
  ## Further Reading
943
931
 
@@ -10,7 +10,7 @@ declare type AnyFunc = (...args: any[]) => any;
10
10
  declare type NonFunctionPropertyNames<T extends AnyObject> = {
11
11
  [K in keyof T]: T[K] extends AnyFunc ? never : K;
12
12
  }[keyof T];
13
- declare type Properties<T extends AnyObject> = Pick<T, NonFunctionPropertyNames<T>>;
13
+ export declare type Properties<T extends AnyObject> = Pick<T, NonFunctionPropertyNames<T>>;
14
14
  export declare type Invariant<T extends AnyObject> = (self: T) => boolean;
15
15
  export declare type Demands<T extends AnyObject, F extends T[any]> = (self: T, ...args: Parameters<F>) => boolean;
16
16
  export declare type Ensures<T extends AnyObject, F extends T[any]> = (self: T, old: Properties<T>, ...args: Parameters<F>) => boolean;
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 type { Constructor } from 'lib/ClassType';
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, Contract, Contracted, Invariant, Rescue, implies, invariant, innerContract, extend, checkedMode, override, assert };
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 d{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=d},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 d=o(r(797));t.assert=d.default;const l=o(r(606));t.implies=l.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),d=o(r(318));function l(e,t,r){return function s(...n){var a,o;const{Class:l}=r,f=l.name;(0,c.assert)(this instanceof l,`${i.MSG_INVALID_CONTEXT}. Expected: this instanceof ${f}. this: ${this.constructor.name}`);const h=Reflect.get(this,c.innerContract);if(!h[c.checkedMode])return t.apply(this,n);let _;(0,u.assertInvariants)(this,h),(0,u.assertDemands)(this,h,f,e,n);try{const s=Object.create(null);(0,u.unChecked)(h,(()=>{r.features.forEach((({name:e,hasGetter:t})=>{t&&Object.defineProperty(s,e,{value:this[e]})}))}));const o=null===(a=Reflect.get(h.assertions,e))||void 0===a?void 0:a.within,i=Date.now();_=t.apply(this,n);const l=Date.now();o&&(0,c.assert)(l-i<o,`Timing constraint violated. Constraint: ${o}ms, actual: ${l-i}ms`),(0,d.default)(this,h,f,e,s,n)}catch(t){const r=null===(o=Reflect.get(h.assertions,e))||void 0===o?void 0:o.rescue;if(null==r)throw(0,u.assertInvariants)(this,h),t;let n=!1;if((0,u.unChecked)(h,(()=>{r.call(this,this,t,[],((...e)=>{(0,c.assert)(!n,i.MSG_SINGLE_RETRY),n=!0,h[c.checkedMode]=!0,_=s.call(this,...e)}))})),!n)throw(0,u.assertInvariants)(this,h),t}return(0,u.assertInvariants)(this,h),_}}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:l(r,e.getter,this)}:{}),n?{set:l(r,e.setter,this)}:{}),a?{value:l(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 d=!0;const l=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${l}`;r[a.checkedMode]&&l&&(0,o.default)(r,(()=>d=l.call(t,t,...c))),r[n.extend]&&!d?e(t,r[n.extend],s,i,c):(0,a.assert)(d,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 d;const l=null===(d=Reflect.get(r.assertions,i))||void 0===d?void 0:d.ensures,f=`ensures not met on ${s}.prototype.${String(i)}\r\n${l}`;r[a.checkedMode]&&l&&(0,o.default)(r,(()=>(0,a.assert)(l.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 d=s(r(950));t.Feature=d.default;const l=s(r(638));t.takeWhile=l.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),d=u.findFeature(t);(0,s.assert)(null!=d,`${n.MSG_MISSING_FEATURE}: ${u.Class.name}.prototype.${String(t)}`);const l=d.ancestorFeature;if((0,s.assert)(null!=l&&d.memberType===l.memberType,`${n.MSG_NO_MATCHING_FEATURE} '${u.Class.name}.prototype.${String(t)}'`),(0,s.assert)(!d.hasOverrides,n.MSG_DUPLICATE_OVERRIDE),d.hasOverrides=!0,d.isMethod){const e=d.value,t=l.value;(0,s.assert)(e.length==t.length,n.MSG_INVALID_ARG_LENGTH)}return d.overriddenOriginalDescriptor=r,Object.assign(Object.assign(Object.assign(Object.assign({enumerable:!0,configurable:!0},d.isAccessor?{}:{writable:!0}),d.hasGetter?{get(){(0,s.assert)(this.constructor[o.isContracted],n.MSG_NOT_CONTRACTED)}}:{}),d.hasSetter?{set(e){(0,s.assert)(this.constructor[o.isContracted],n.MSG_NOT_CONTRACTED)}}:{}),d.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,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,MAAaC,EAMTP,YAAYQ,EAA0CC,OAAOC,OAAO,eALpE,mBAGS,KAAAF,WAAiCC,OAAOC,OAAO,MAGpDb,KAAKS,GAAUE,EAAWF,GAC1BT,KAAKM,GAAsC,QAAvB,EAAAK,EAAWL,UAAY,SAC3C,EAAAN,KAAI,EAAmC,QAArB,EAAAW,EAA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AC,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,eACvBC,EAAYD,OAAO,aACnBE,EAASF,OAAO,UAkEX,EAAAD,YAAAA,EAAqB,EAAAE,UAAAA,EAAR,EAAAC,OAAAA,EA/BtB,MAAaC,EAMTP,YAAYQ,EAA0CC,OAAOC,OAAO,eALpE,mBAGS,KAAAF,WAAiCC,OAAOC,OAAO,MAGpDb,KAAKS,GAAUE,EAAWF,GAC1BT,KAAKM,GAAsC,QAAvB,EAAAK,EAAWL,UAAY,SAC3C,EAAAN,KAAI,EAAmC,QAArB,EAAAW,EAAWH,UAAU,QAAI,EAAAM,OAAM,KAEjDF,OAAOG,KAAKJ,GAAYK,SAAQC,YAC5B,MAAMC,EAAgBP,EAAWM,GACjCL,OAAOO,eAAenB,KAAKW,WAAYM,EAAa,CAChDG,MAAO,CACHC,QAA8B,QAArB,EAAAH,EAAcG,eAAO,QAAI,EAAAP,OAClCQ,QAA8B,QAArB,EAAAJ,EAAcI,eAAO,QAAI,EAAAR,OAClCS,OAAQL,EAAcK,OACtBC,OAAQN,EAAcM,SAE5B,KAGN,IAAAC,YAAWzB,KAAKW,WACpB,CAEc,KAAV,cAACH,MACD,OAAO,EAAAR,KAAI,MACf,EA5BJ,mHCvCA,eACA,SACA,SAEM0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AHA0K,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\nexport type 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 className = Class.name;\r\n\r\n assert(this instanceof Class, `${MSG_INVALID_CONTEXT}. Expected: this instanceof ${className}. this: ${this.constructor.name}`);\r\n\r\n const contract = Reflect.get(this, innerContract);\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, Properties } 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 extends Properties<any>>(\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","className","name","Reflect","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":""}
@@ -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
- export declare type Constructor<T> = new (...args: any[]) => T;
8
- export declare type AbstractConstructor<T> = abstract new (...args: any[]) => T;
9
- export declare type ClassType<T> = Constructor<T> | AbstractConstructor<T>;
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 };
@@ -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
+ import { Properties } from '../Contract';
7
8
  import { Contract } from '../';
8
- declare function assertEnsures<U>(ctx: U, contract: Contract<any>, className: string, featureName: PropertyKey, old: U, args: any[]): void;
9
+ declare function assertEnsures<U extends Properties<any>>(ctx: U, contract: Contract<any>, className: string, featureName: PropertyKey, old: U, args: any[]): void;
9
10
  export default assertEnsures;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@final-hill/decorator-contracts",
3
- "version": "0.24.0",
3
+ "version": "0.24.2",
4
4
  "description": "Code Contracts for TypeScript and ECMAScript classes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",