@quantform/core 0.7.10 → 0.7.11
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/lib/module.d.ts +3 -0
- package/lib/module.d.ts.map +1 -1
- package/lib/module.js +6 -2
- package/package.json +1 -1
- package/src/module.ts +6 -2
package/lib/module.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import 'reflect-metadata';
|
|
3
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
4
|
import { DependencyContainer, inject, injectable, injectAll, InjectionToken } from 'tsyringe';
|
|
3
5
|
export declare const provider: typeof injectable;
|
|
4
6
|
export declare const provide: typeof inject;
|
|
@@ -8,6 +10,7 @@ export type Dependency = {
|
|
|
8
10
|
useClass?: any;
|
|
9
11
|
useValue?: any;
|
|
10
12
|
};
|
|
13
|
+
export declare function setAsyncLocalStorage(als: AsyncLocalStorage<Module>): void;
|
|
11
14
|
/**
|
|
12
15
|
* Hook to get access to current execution module dependencies.
|
|
13
16
|
*/
|
package/lib/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAEL,mBAAmB,EACnB,MAAM,EACN,UAAU,EACV,SAAS,EACT,cAAc,EAEf,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,QAAQ,mBAAa,CAAC;AACnC,eAAO,MAAM,OAAO,eAAS,CAAC;AAC9B,eAAO,MAAM,UAAU,kBAAY,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAuBF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,iBAAiB,CAAC,MAAM,CAAC,QAElE;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,oCAQtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,YAI5B,CAAC;AAEF;;;GAGG;AACH,qBAAa,MAAM;IAGL,OAAO,CAAC,QAAQ,CAAC,YAAY;IAFzC,OAAO,CAAC,SAAS,CAAC,CAAsB;gBAEX,YAAY,EAAE,UAAU,EAAE;IAEvD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;KAAE,CAAC;IAWxD;;;OAGG;IACH,OAAO;IAQP;;;OAGG;IACH,SAAS,CAAC,cAAc,IAAI,mBAAmB;IAgB/C;;;;;OAKG;IACH,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC;IAYnC;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;CAWzC"}
|
package/lib/module.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Module = exports.throwWithContext = exports.useContext = exports.provideAll = exports.provide = exports.provider = void 0;
|
|
12
|
+
exports.Module = exports.throwWithContext = exports.useContext = exports.setAsyncLocalStorage = exports.provideAll = exports.provide = exports.provider = void 0;
|
|
13
13
|
require("reflect-metadata");
|
|
14
14
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
15
15
|
const tsyringe_1 = require("tsyringe");
|
|
@@ -31,7 +31,11 @@ function missingInjectionTokenError(token) {
|
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
let moduleLocalStorage = new node_async_hooks_1.AsyncLocalStorage();
|
|
35
|
+
function setAsyncLocalStorage(als) {
|
|
36
|
+
moduleLocalStorage = als;
|
|
37
|
+
}
|
|
38
|
+
exports.setAsyncLocalStorage = setAsyncLocalStorage;
|
|
35
39
|
/**
|
|
36
40
|
* Hook to get access to current execution module dependencies.
|
|
37
41
|
*/
|
package/package.json
CHANGED
package/src/module.ts
CHANGED
|
@@ -40,13 +40,17 @@ function missingInjectionTokenError(token: InjectionToken) {
|
|
|
40
40
|
/**
|
|
41
41
|
*
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
let moduleLocalStorage = new AsyncLocalStorage<Module>();
|
|
44
|
+
|
|
45
|
+
export function setAsyncLocalStorage(als: AsyncLocalStorage<Module>) {
|
|
46
|
+
moduleLocalStorage = als;
|
|
47
|
+
}
|
|
44
48
|
|
|
45
49
|
/**
|
|
46
50
|
* Hook to get access to current execution module dependencies.
|
|
47
51
|
*/
|
|
48
52
|
export const useContext = <T>(token: InjectionToken<T>) => {
|
|
49
|
-
const module = moduleLocalStorage.getStore()
|
|
53
|
+
const module = moduleLocalStorage.getStore();
|
|
50
54
|
|
|
51
55
|
if (!module) {
|
|
52
56
|
throw noModuleError();
|