@jonloucks/contracts-ts 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/api/AutoClose.d.ts +5 -0
- package/api/AutoClose.d.ts.map +1 -1
- package/api/AutoClose.js +10 -1
- package/api/AutoClose.js.map +1 -1
- package/auxiliary/Validate.d.ts.map +1 -1
- package/auxiliary/Validate.js +6 -62
- package/auxiliary/Validate.js.map +1 -1
- package/impl/AutoCloseMany.impl.d.ts.map +1 -1
- package/impl/AutoCloseMany.impl.js +5 -2
- package/impl/AutoCloseMany.impl.js.map +1 -1
- package/impl/AutoCloseOne.impl.d.ts.map +1 -1
- package/impl/AutoCloseOne.impl.js +5 -2
- package/impl/AutoCloseOne.impl.js.map +1 -1
- package/impl/Storage.impl.d.ts +2 -1
- package/impl/Storage.impl.d.ts.map +1 -1
- package/impl/Storage.impl.js +4 -0
- package/impl/Storage.impl.js.map +1 -1
- package/package.json +7 -4
- package/version.js +1 -1
package/README.md
CHANGED
|
@@ -274,12 +274,15 @@ contracts-ts
|
|
|
274
274
|
<details markdown="1"><summary>CI Workflow</summary>
|
|
275
275
|
|
|
276
276
|
The CI workflow runs on every push and pull request to `main` branch. It:
|
|
277
|
-
- Tests against Node.js versions
|
|
277
|
+
- Tests against supported Node.js versions `>20.11.0 <21.0`, `22.x`, and `24.x`
|
|
278
278
|
- Runs linting
|
|
279
279
|
- Builds the project
|
|
280
280
|
- Runs tests with coverage
|
|
281
281
|
- Uploads coverage to Codecov (optional)
|
|
282
282
|
|
|
283
|
+
Compatibility note:
|
|
284
|
+
- Production `AutoClose` implementations intentionally support both `Symbol.dispose` and `Symbol.for("Symbol.dispose")` keys, so disposal remains stable in environments that do not provide `Symbol.dispose`.
|
|
285
|
+
|
|
283
286
|
</details>
|
|
284
287
|
|
|
285
288
|
<details markdown="1"><summary>Publish Workflow</summary>
|
package/api/AutoClose.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { OptionalType, RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
2
|
+
export declare function resolveDisposeSymbol(symbolType: {
|
|
3
|
+
dispose?: symbol;
|
|
4
|
+
for(key: string): symbol;
|
|
5
|
+
}): symbol;
|
|
6
|
+
export declare const DISPOSE_SYMBOL: symbol;
|
|
2
7
|
/**
|
|
3
8
|
* Type alias for AutoClose or a simple close function.
|
|
4
9
|
*/
|
package/api/AutoClose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoClose.d.ts","sourceRoot":"","sources":["../../src/api/AutoClose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAgC,MAAM,mCAAmC,CAAC;AAI7G;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,KAAK,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAU,SAAQ,KAAK;IACtC;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,SAAS;IAE9C;;;;;OAKG;IACH,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;CACnD;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,SAAS;IAE7C;;;;OAIG;IACH,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;CACnD;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"AutoClose.d.ts","sourceRoot":"","sources":["../../src/api/AutoClose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE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;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,SAAS,CAAC,CAG5E;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,SAAS,CAAC,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAWnF"}
|
package/api/AutoClose.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { guardFunctions, isNotPresent } from "@jonloucks/contracts-ts/api/Types";
|
|
2
2
|
import { presentCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
3
3
|
import { IllegalArgumentException } from "@jonloucks/contracts-ts/auxiliary/IllegalArgumentException";
|
|
4
|
+
export function resolveDisposeSymbol(symbolType) {
|
|
5
|
+
return symbolType.dispose ?? symbolType.for("Symbol.dispose");
|
|
6
|
+
}
|
|
7
|
+
export const DISPOSE_SYMBOL = resolveDisposeSymbol(Symbol);
|
|
4
8
|
/**
|
|
5
9
|
* A no-op AutoClose instance that does nothing on close or dispose.
|
|
6
10
|
*/
|
|
@@ -16,6 +20,9 @@ export const AUTO_CLOSE_NONE = {
|
|
|
16
20
|
*/
|
|
17
21
|
[Symbol.dispose]: () => {
|
|
18
22
|
// no-op
|
|
23
|
+
},
|
|
24
|
+
[DISPOSE_SYMBOL]: () => {
|
|
25
|
+
// no-op
|
|
19
26
|
}
|
|
20
27
|
};
|
|
21
28
|
/**
|
|
@@ -36,6 +43,7 @@ export function inlineAutoClose(action) {
|
|
|
36
43
|
return {
|
|
37
44
|
close: action,
|
|
38
45
|
[Symbol.dispose]: action,
|
|
46
|
+
[DISPOSE_SYMBOL]: action,
|
|
39
47
|
unwrapAutoCloseType: () => action
|
|
40
48
|
};
|
|
41
49
|
}
|
|
@@ -61,7 +69,8 @@ export function unwrap(autoClose) {
|
|
|
61
69
|
* @returns true if the instance implements AutoClose, false otherwise
|
|
62
70
|
*/
|
|
63
71
|
export function guard(instance) {
|
|
64
|
-
return guardFunctions(instance, 'close', Symbol.dispose)
|
|
72
|
+
return guardFunctions(instance, 'close', Symbol.dispose)
|
|
73
|
+
|| guardFunctions(instance, 'close', DISPOSE_SYMBOL);
|
|
65
74
|
}
|
|
66
75
|
/**
|
|
67
76
|
* Duck-typing check for object with close() method.
|
package/api/AutoClose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoClose.js","sourceRoot":"","sources":["../../src/api/AutoClose.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,cAAc,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoClose.js","sourceRoot":"","sources":["../../src/api/AutoClose.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,cAAc,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;AAEtG,MAAM,UAAU,oBAAoB,CAAC,UAA0D;IAC7F,OAAO,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAW,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAyDnE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAc;IAExC;;OAEG;IACH,KAAK,EAAE,GAAG,EAAE;QACV,QAAQ;IACV,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE;QACrB,Q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W,CAAC;IACrB,CAAC;SAAM,IAAI,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,OAAO,eAAe,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;SAAM,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QAC7C,OAAO,eAAe,CAAC,WAA4B,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Validate.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Validate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAIlE;;;;EAIE;AACF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"Validate.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Validate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAIlE;;;;EAIE;AACF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAqC5D"}
|
package/auxiliary/Validate.js
CHANGED
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
1
|
import { ContractException } from "@jonloucks/contracts-ts/api/ContractException";
|
|
54
2
|
import { create as createContract } from "@jonloucks/contracts-ts/api/RatifiedContract";
|
|
55
3
|
import { contractsCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
@@ -69,12 +17,11 @@ export function validateContracts(contracts) {
|
|
|
69
17
|
throw new ContractException("Contract should not be bound.");
|
|
70
18
|
}
|
|
71
19
|
{
|
|
72
|
-
const
|
|
20
|
+
const bindReturn = validContracts.bind(contract, () => deliverableValue);
|
|
21
|
+
if (null === bindReturn || bindReturn === undefined) {
|
|
22
|
+
throw new ContractException("Contract bind returned null.");
|
|
23
|
+
}
|
|
73
24
|
try {
|
|
74
|
-
const bindReturn = __addDisposableResource(env_1, validContracts.bind(contract, () => deliverableValue), false);
|
|
75
|
-
if (null === bindReturn || bindReturn === undefined) {
|
|
76
|
-
throw new ContractException("Contract bind returned null.");
|
|
77
|
-
}
|
|
78
25
|
if (!validContracts.isBound(contract)) {
|
|
79
26
|
throw new ContractException("Contract should have been bound.");
|
|
80
27
|
}
|
|
@@ -82,12 +29,8 @@ export function validateContracts(contracts) {
|
|
|
82
29
|
throw new ContractException("Contract claiming not working.");
|
|
83
30
|
}
|
|
84
31
|
}
|
|
85
|
-
catch (e_1) {
|
|
86
|
-
env_1.error = e_1;
|
|
87
|
-
env_1.hasError = true;
|
|
88
|
-
}
|
|
89
32
|
finally {
|
|
90
|
-
|
|
33
|
+
bindReturn.close();
|
|
91
34
|
}
|
|
92
35
|
}
|
|
93
36
|
if (validContracts.isBound(contract)) {
|
|
@@ -95,6 +38,7 @@ export function validateContracts(contracts) {
|
|
|
95
38
|
}
|
|
96
39
|
}
|
|
97
40
|
catch (thrown) {
|
|
41
|
+
console.error("Contracts validation error:", thrown);
|
|
98
42
|
ContractException.rethrow(thrown, "Contracts unexpected validation error.");
|
|
99
43
|
}
|
|
100
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Validate.js","sourceRoot":"","sources":["../../src/auxiliary/Validate.ts"],"names":[],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CAAC;gBAChE,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,UAAU,CAAC,KAAK,EAAE,CAAC;YACrB,CAAC;QACH,CAAC;QAED,IAAI,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,iBAAiB,CAAC,iCAAiC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAAC,OAAO,MAAe,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;QACrD,iBAAiB,CAAC,OAAO,CAAC,MAAM,EAAE,wCAAwC,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCloseMany.impl.d.ts","sourceRoot":"","sources":["../../src/impl/AutoCloseMany.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,
|
|
1
|
+
{"version":3,"file":"AutoCloseMany.impl.d.ts","sourceRoot":"","sources":["../../src/impl/AutoCloseMany.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAA8D,MAAM,uCAAuC,CAAC;AAC7I,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGjE;;;;GAIG;AACH,wBAAgB,MAAM,IAAI,YAAY,CAAC,aAAa,CAAC,CAEpD"}
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _AutoCloseManyImpl_closeables;
|
|
7
|
-
import { fromType as typeToAutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
7
|
+
import { DISPOSE_SYMBOL, fromType as typeToAutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
8
8
|
import { Internal } from "./Internal.impl.js";
|
|
9
9
|
/**
|
|
10
10
|
* Create an AutoCloseMany instance.
|
|
@@ -36,7 +36,10 @@ class AutoCloseManyImpl {
|
|
|
36
36
|
Internal.throwAggregateError("Multiple while closing.", ...errorList);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
[(_AutoCloseManyImpl_closeables = new WeakMap(),
|
|
39
|
+
[(_AutoCloseManyImpl_closeables = new WeakMap(), DISPOSE_SYMBOL)]() {
|
|
40
|
+
this.close();
|
|
41
|
+
}
|
|
42
|
+
[Symbol.dispose]() {
|
|
40
43
|
this.close();
|
|
41
44
|
}
|
|
42
45
|
static internalCreate() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCloseMany.impl.js","sourceRoot":"","sources":["../../src/impl/AutoCloseMany.impl.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAA2C,QAAQ,IAAI,eAAe,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoCloseMany.impl.js","sourceRoot":"","sources":["../../src/impl/AutoCloseMany.impl.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAA2C,cAAc,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAE7I,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,iBAAiB,CAAC,cAAc,EAAE,CAAC;AAC5C,CAAC;AAED,yCAAyC;AAEzC;;GAEG;AACH,MAAM,iBAAiB;IAErB,GAAG,CAAC,SAAsC;QACxC,uBAAA,IAAI,qCAAY,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,KAAK;QACH,MAAM,SAAS,GAAc,EAAE,CAAC;QAChC,OAAO,uBAAA,IAAI,qCAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC;gBACH,uBAAA,IAAI,qCAAY,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC;YAClC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,QAAQ,CAAC,mBAAmB,CAAC,yBAAyB,EAAE,GAAG,SAAS,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAED,iDAAC,cAAc,EAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,MAAM,CAAC,cAAc;QACnB,OAAO,IAAI,iBAAiB,EAAE,CAAC;IACjC,CAAC;IAED;QAIS,wCAAyC,EAAE,EAAC;IAHrD,CAAC;CAIF;AAAA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCloseOne.impl.d.ts","sourceRoot":"","sources":["../../src/impl/AutoCloseOne.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,
|
|
1
|
+
{"version":3,"file":"AutoCloseOne.impl.d.ts","sourceRoot":"","sources":["../../src/impl/AutoCloseOne.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAAyF,MAAM,uCAAuC,CAAC;AACvK,OAAO,EAA2B,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAI1F;;;GAGG;AACH,wBAAgB,MAAM,IAAI,YAAY,CAAC,YAAY,CAAC,CAEnD"}
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _AutoCloseOneImpl_reference;
|
|
7
|
-
import { fromType as typeToAutoClose, unwrap as unwrapAutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
7
|
+
import { DISPOSE_SYMBOL, fromType as typeToAutoClose, unwrap as unwrapAutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
8
8
|
import { isPresent } from "@jonloucks/contracts-ts/api/Types";
|
|
9
9
|
import { create as createAtomicReference } from "./AtomicReference.impl.js";
|
|
10
10
|
/**
|
|
@@ -25,7 +25,10 @@ class AutoCloseOneImpl {
|
|
|
25
25
|
autoClose.close();
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
[(_AutoCloseOneImpl_reference = new WeakMap(),
|
|
28
|
+
[(_AutoCloseOneImpl_reference = new WeakMap(), DISPOSE_SYMBOL)]() {
|
|
29
|
+
this.close();
|
|
30
|
+
}
|
|
31
|
+
[Symbol.dispose]() {
|
|
29
32
|
this.close();
|
|
30
33
|
}
|
|
31
34
|
set(newClose) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCloseOne.impl.js","sourceRoot":"","sources":["../../src/impl/AutoCloseOne.impl.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAA0C,QAAQ,IAAI,eAAe,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoCloseOne.impl.js","sourceRoot":"","sources":["../../src/impl/AutoCloseOne.impl.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAA0C,cAAc,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACvK,OAAO,EAAE,SAAS,EAA8B,MAAM,mCAAmC,CAAC;AAE1F,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAE5E;;;GAGG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,gBAAgB,CAAC,cAAc,EAAE,CAAC;AAC3C,CAAC;AAED,yCAAyC;AAEzC;;GAEG;AACH,MAAM,gBAAgB;IACpB,KAAK;QACH,IAAI,SAAS,GAAG,uBAAA,IAAI,mCAAW,CAAC,GAAG,EAAE,CAAC;QACtC,IAAI,SAAS,CAAC,SAAS,CAAC,IAAI,uBAAA,IAAI,mCAAW,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC;YAC3E,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;IAED,+CAAC,cAAc,EAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,GAAG,CAAC,QAAqC;QACvC,MAAM,OAAO,GAAG,uBAAA,IAAI,mCAAW,CAAC,GAAG,EAAE,CAAC;QACtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAEjF,IAAI,eAAe,CAAC,OAAO,CAAC,KAAK,eAAe,CAAC,aAAa,CAAC,EAAE,CAAC;YAChE,OAAO,CAAC,YAAY;QACtB,CAAC;QAED,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,iCAAiC;QACjD,CAAC;gBAAS,CAAC;YACT,uBAAA,IAAI,mCAAW,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,cAAc;QACnB,OAAO,IAAI,gBAAgB,EAAE,CAAC;IAChC,CAAC;IAED;QAIS,sCAAyC,qBAAqB,EAAa,EAAC;QAHnF,QAAQ;IACV,CAAC;CAGF"}
|
package/impl/Storage.impl.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
1
|
+
import { AutoClose, DISPOSE_SYMBOL } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
2
2
|
import { BindStrategy } from "@jonloucks/contracts-ts/api/BindStrategy";
|
|
3
3
|
import { Contract } from "@jonloucks/contracts-ts/api/Contract";
|
|
4
4
|
import { Contracts } from "@jonloucks/contracts-ts/api/Contracts";
|
|
5
5
|
import { Promisor } from "@jonloucks/contracts-ts/api/Promisor";
|
|
6
6
|
export declare class StorageImpl<T> implements AutoClose {
|
|
7
|
+
[DISPOSE_SYMBOL]: () => void;
|
|
7
8
|
constructor(contracts: Contracts, contract: Contract<T>, promisor: Promisor<T | null>, bindStrategy: BindStrategy);
|
|
8
9
|
[Symbol.dispose](): void;
|
|
9
10
|
bind(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Storage.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"Storage.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Storage.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAMhE,qBAAa,WAAW,CAAC,CAAC,CAAE,YAAW,SAAS;IAS9C,CAAC,cAAc,CAAC,QAAI,IAAI;gBAPZ,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,YAAY,EAAE,YAAY;IAWjH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAIxB,IAAI,IAAI,IAAI;IAKZ,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsC;CACpE"}
|
package/impl/Storage.impl.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DISPOSE_SYMBOL } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
1
2
|
import { create as createAutoCloseOne } from "./AutoCloseOne.impl.js";
|
|
2
3
|
// ---- Implementation details below ----
|
|
3
4
|
export class StorageImpl {
|
|
@@ -8,6 +9,9 @@ export class StorageImpl {
|
|
|
8
9
|
this.promisor = promisor;
|
|
9
10
|
this.bindStrategy = bindStrategy;
|
|
10
11
|
}
|
|
12
|
+
[DISPOSE_SYMBOL]() {
|
|
13
|
+
this.close();
|
|
14
|
+
}
|
|
11
15
|
[Symbol.dispose]() {
|
|
12
16
|
this.close();
|
|
13
17
|
}
|
package/impl/Storage.impl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.impl.js","sourceRoot":"","sources":["../../src/impl/Storage.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Storage.impl.js","sourceRoot":"","sources":["../../src/impl/Storage.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAMhG,OAAO,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,yCAAyC;AAEzC,MAAM,OAAO,WAAW;IAEtB,YAAY,SAAoB,EAAE,QAAqB,EAAE,QAA4B,EAAE,YAA0B;QA4BhG,iBAAY,GAAiB,kBAAkB,EAAE,CAAC;QA3BjE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,CAAC,cAAc,CAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,IAAI;QACF,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,KAAK;QACH,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CAOF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jonloucks/contracts-ts",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Typescript Dependency Contracts for dependency inversion",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"after:publish": "npm run clean",
|
|
44
44
|
"prepare": "npm run build",
|
|
45
45
|
"docs": "typedoc --options typedoc.json",
|
|
46
|
-
"badges": "npx badges-ts generate
|
|
46
|
+
"badges": "npx badges-ts generate",
|
|
47
47
|
"discover": "npx badges-ts discover",
|
|
48
48
|
"clean": "rm -rf dist",
|
|
49
49
|
"compile": "tsc",
|
|
@@ -66,15 +66,18 @@
|
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"registry": "https://registry.npmjs.org/"
|
|
68
68
|
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=16.0.0"
|
|
71
|
+
},
|
|
69
72
|
"devDependencies": {
|
|
70
|
-
"@jonloucks/badges-ts": "^0.
|
|
73
|
+
"@jonloucks/badges-ts": "^1.0.3",
|
|
71
74
|
"@types/node": "^25.2.3",
|
|
72
75
|
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
73
76
|
"@typescript-eslint/parser": "^8.53.1",
|
|
74
77
|
"c8": "^10.1.3",
|
|
75
78
|
"eslint": "^9.39.2",
|
|
76
79
|
"tsx": "^4.21.0",
|
|
77
|
-
"typedoc": "^0.28.
|
|
80
|
+
"typedoc": "^0.28.17",
|
|
78
81
|
"typescript": "^5.9.3"
|
|
79
82
|
}
|
|
80
83
|
}
|
package/version.js
CHANGED