@venizia/ignis-inversion 0.4.3 → 0.4.5-0
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/LICENSE.md +2 -5
- package/README.md +18 -6
- package/dist/esm/modules/container/base.d.ts.map +1 -1
- package/dist/esm/modules/container/base.js +3 -1
- package/dist/esm/modules/container/base.js.map +1 -1
- package/dist/esm/modules/container/container.d.ts.map +1 -1
- package/dist/esm/modules/container/container.js +1 -0
- package/dist/esm/modules/container/container.js.map +1 -1
- package/dist/esm/modules/container/index.d.ts +1 -0
- package/dist/esm/modules/container/index.d.ts.map +1 -1
- package/dist/esm/modules/container/index.js +1 -0
- package/dist/esm/modules/container/index.js.map +1 -1
- package/dist/esm/modules/container/verifier.d.ts +47 -0
- package/dist/esm/modules/container/verifier.d.ts.map +1 -0
- package/dist/esm/modules/container/verifier.js +115 -0
- package/dist/esm/modules/container/verifier.js.map +1 -0
- package/package.json +7 -15
- package/dist/cjs/common/base-helper.d.ts +0 -9
- package/dist/cjs/common/base-helper.d.ts.map +0 -1
- package/dist/cjs/common/base-helper.js +0 -11
- package/dist/cjs/common/base-helper.js.map +0 -1
- package/dist/cjs/common/index.d.ts +0 -5
- package/dist/cjs/common/index.d.ts.map +0 -1
- package/dist/cjs/common/index.js +0 -21
- package/dist/cjs/common/index.js.map +0 -1
- package/dist/cjs/common/logger.d.ts +0 -11
- package/dist/cjs/common/logger.d.ts.map +0 -1
- package/dist/cjs/common/logger.js +0 -26
- package/dist/cjs/common/logger.js.map +0 -1
- package/dist/cjs/common/types.d.ts +0 -22
- package/dist/cjs/common/types.d.ts.map +0 -1
- package/dist/cjs/common/types.js +0 -3
- package/dist/cjs/common/types.js.map +0 -1
- package/dist/cjs/common/utilities.d.ts +0 -38
- package/dist/cjs/common/utilities.d.ts.map +0 -1
- package/dist/cjs/common/utilities.js +0 -83
- package/dist/cjs/common/utilities.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -26
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/modules/binding/binding.d.ts +0 -37
- package/dist/cjs/modules/binding/binding.d.ts.map +0 -1
- package/dist/cjs/modules/binding/binding.js +0 -120
- package/dist/cjs/modules/binding/binding.js.map +0 -1
- package/dist/cjs/modules/binding/common/constants.d.ts +0 -19
- package/dist/cjs/modules/binding/common/constants.d.ts.map +0 -1
- package/dist/cjs/modules/binding/common/constants.js +0 -33
- package/dist/cjs/modules/binding/common/constants.js.map +0 -1
- package/dist/cjs/modules/binding/common/index.d.ts +0 -3
- package/dist/cjs/modules/binding/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/binding/common/index.js +0 -19
- package/dist/cjs/modules/binding/common/index.js.map +0 -1
- package/dist/cjs/modules/binding/common/types.d.ts +0 -28
- package/dist/cjs/modules/binding/common/types.d.ts.map +0 -1
- package/dist/cjs/modules/binding/common/types.js +0 -8
- package/dist/cjs/modules/binding/common/types.js.map +0 -1
- package/dist/cjs/modules/binding/index.d.ts +0 -3
- package/dist/cjs/modules/binding/index.d.ts.map +0 -1
- package/dist/cjs/modules/binding/index.js +0 -19
- package/dist/cjs/modules/binding/index.js.map +0 -1
- package/dist/cjs/modules/container/abstract.d.ts +0 -69
- package/dist/cjs/modules/container/abstract.d.ts.map +0 -1
- package/dist/cjs/modules/container/abstract.js +0 -12
- package/dist/cjs/modules/container/abstract.js.map +0 -1
- package/dist/cjs/modules/container/base.d.ts +0 -101
- package/dist/cjs/modules/container/base.d.ts.map +0 -1
- package/dist/cjs/modules/container/base.js +0 -193
- package/dist/cjs/modules/container/base.js.map +0 -1
- package/dist/cjs/modules/container/common/index.d.ts +0 -2
- package/dist/cjs/modules/container/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/container/common/index.js +0 -18
- package/dist/cjs/modules/container/common/index.js.map +0 -1
- package/dist/cjs/modules/container/common/types.d.ts +0 -60
- package/dist/cjs/modules/container/common/types.d.ts.map +0 -1
- package/dist/cjs/modules/container/common/types.js +0 -3
- package/dist/cjs/modules/container/common/types.js.map +0 -1
- package/dist/cjs/modules/container/container.d.ts +0 -24
- package/dist/cjs/modules/container/container.d.ts.map +0 -1
- package/dist/cjs/modules/container/container.js +0 -100
- package/dist/cjs/modules/container/container.js.map +0 -1
- package/dist/cjs/modules/container/index.d.ts +0 -5
- package/dist/cjs/modules/container/index.d.ts.map +0 -1
- package/dist/cjs/modules/container/index.js +0 -21
- package/dist/cjs/modules/container/index.js.map +0 -1
- package/dist/cjs/modules/error/app-error.d.ts +0 -32
- package/dist/cjs/modules/error/app-error.d.ts.map +0 -1
- package/dist/cjs/modules/error/app-error.js +0 -102
- package/dist/cjs/modules/error/app-error.js.map +0 -1
- package/dist/cjs/modules/error/common/constants.d.ts +0 -14
- package/dist/cjs/modules/error/common/constants.d.ts.map +0 -1
- package/dist/cjs/modules/error/common/constants.js +0 -23
- package/dist/cjs/modules/error/common/constants.js.map +0 -1
- package/dist/cjs/modules/error/common/index.d.ts +0 -3
- package/dist/cjs/modules/error/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/error/common/index.js +0 -19
- package/dist/cjs/modules/error/common/index.js.map +0 -1
- package/dist/cjs/modules/error/common/types.d.ts +0 -75
- package/dist/cjs/modules/error/common/types.d.ts.map +0 -1
- package/dist/cjs/modules/error/common/types.js +0 -3
- package/dist/cjs/modules/error/common/types.js.map +0 -1
- package/dist/cjs/modules/error/definition.d.ts +0 -10
- package/dist/cjs/modules/error/definition.d.ts.map +0 -1
- package/dist/cjs/modules/error/definition.js +0 -12
- package/dist/cjs/modules/error/definition.js.map +0 -1
- package/dist/cjs/modules/error/index.d.ts +0 -6
- package/dist/cjs/modules/error/index.d.ts.map +0 -1
- package/dist/cjs/modules/error/index.js +0 -22
- package/dist/cjs/modules/error/index.js.map +0 -1
- package/dist/cjs/modules/error/message-code.d.ts +0 -28
- package/dist/cjs/modules/error/message-code.d.ts.map +0 -1
- package/dist/cjs/modules/error/message-code.js +0 -57
- package/dist/cjs/modules/error/message-code.js.map +0 -1
- package/dist/cjs/modules/error/message-template.d.ts +0 -19
- package/dist/cjs/modules/error/message-template.d.ts.map +0 -1
- package/dist/cjs/modules/error/message-template.js +0 -38
- package/dist/cjs/modules/error/message-template.js.map +0 -1
- package/dist/cjs/modules/index.d.ts +0 -6
- package/dist/cjs/modules/index.d.ts.map +0 -1
- package/dist/cjs/modules/index.js +0 -22
- package/dist/cjs/modules/index.js.map +0 -1
- package/dist/cjs/modules/metadata/common/constants.d.ts +0 -6
- package/dist/cjs/modules/metadata/common/constants.d.ts.map +0 -1
- package/dist/cjs/modules/metadata/common/constants.js +0 -9
- package/dist/cjs/modules/metadata/common/constants.js.map +0 -1
- package/dist/cjs/modules/metadata/common/index.d.ts +0 -2
- package/dist/cjs/modules/metadata/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/metadata/common/index.js +0 -18
- package/dist/cjs/modules/metadata/common/index.js.map +0 -1
- package/dist/cjs/modules/metadata/index.d.ts +0 -3
- package/dist/cjs/modules/metadata/index.d.ts.map +0 -1
- package/dist/cjs/modules/metadata/index.js +0 -19
- package/dist/cjs/modules/metadata/index.js.map +0 -1
- package/dist/cjs/modules/metadata/injectors.d.ts +0 -16
- package/dist/cjs/modules/metadata/injectors.d.ts.map +0 -1
- package/dist/cjs/modules/metadata/injectors.js +0 -47
- package/dist/cjs/modules/metadata/injectors.js.map +0 -1
- package/dist/cjs/modules/registry/common/index.d.ts +0 -2
- package/dist/cjs/modules/registry/common/index.d.ts.map +0 -1
- package/dist/cjs/modules/registry/common/index.js +0 -18
- package/dist/cjs/modules/registry/common/index.js.map +0 -1
- package/dist/cjs/modules/registry/common/types.d.ts +0 -20
- package/dist/cjs/modules/registry/common/types.d.ts.map +0 -1
- package/dist/cjs/modules/registry/common/types.js +0 -3
- package/dist/cjs/modules/registry/common/types.js.map +0 -1
- package/dist/cjs/modules/registry/index.d.ts +0 -3
- package/dist/cjs/modules/registry/index.d.ts.map +0 -1
- package/dist/cjs/modules/registry/index.js +0 -19
- package/dist/cjs/modules/registry/index.js.map +0 -1
- package/dist/cjs/modules/registry/registry.d.ts +0 -66
- package/dist/cjs/modules/registry/registry.d.ts.map +0 -1
- package/dist/cjs/modules/registry/registry.js +0 -98
- package/dist/cjs/modules/registry/registry.js.map +0 -1
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { BaseHelper } from '../../common/base-helper';
|
|
2
|
-
import type { TBindingKey, TClass, TNullable } from '../../common/types';
|
|
3
|
-
import type { IBinding } from '../binding/common/types';
|
|
4
|
-
import type { MetadataRegistry } from '../registry/registry';
|
|
5
|
-
import type { IContainer } from './common/types';
|
|
6
|
-
/** Container CONTRACT as a class, typed against `IBinding` - implementations sharing no storage start here; ones that only vary resolution start at `BaseContainer`. */
|
|
7
|
-
export declare abstract class AbstractContainer extends BaseHelper implements IContainer {
|
|
8
|
-
constructor(opts?: {
|
|
9
|
-
scope: string;
|
|
10
|
-
});
|
|
11
|
-
abstract getMetadataRegistry(): MetadataRegistry;
|
|
12
|
-
abstract bind<T>(opts: {
|
|
13
|
-
key: TBindingKey;
|
|
14
|
-
}): IBinding<T>;
|
|
15
|
-
abstract isBound(opts: {
|
|
16
|
-
key: TBindingKey;
|
|
17
|
-
}): boolean;
|
|
18
|
-
abstract getBinding<T>(opts: {
|
|
19
|
-
key: TBindingKey | {
|
|
20
|
-
namespace: string;
|
|
21
|
-
key: string;
|
|
22
|
-
};
|
|
23
|
-
}): TNullable<IBinding<T>>;
|
|
24
|
-
abstract unbind(opts: {
|
|
25
|
-
key: TBindingKey;
|
|
26
|
-
}): boolean;
|
|
27
|
-
abstract set<T>(opts: {
|
|
28
|
-
binding: IBinding<T>;
|
|
29
|
-
}): void;
|
|
30
|
-
abstract get<T>(opts: {
|
|
31
|
-
key: TBindingKey | {
|
|
32
|
-
namespace: string;
|
|
33
|
-
key: string;
|
|
34
|
-
};
|
|
35
|
-
isOptional?: false;
|
|
36
|
-
}): T;
|
|
37
|
-
abstract get<T>(opts: {
|
|
38
|
-
key: TBindingKey | {
|
|
39
|
-
namespace: string;
|
|
40
|
-
key: string;
|
|
41
|
-
};
|
|
42
|
-
isOptional?: boolean;
|
|
43
|
-
}): T | undefined;
|
|
44
|
-
abstract gets<T extends unknown[]>(opts: {
|
|
45
|
-
bindings: {
|
|
46
|
-
[K in keyof T]: {
|
|
47
|
-
key: TBindingKey | {
|
|
48
|
-
namespace: string;
|
|
49
|
-
key: string;
|
|
50
|
-
};
|
|
51
|
-
isOptional?: boolean;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
}): {
|
|
55
|
-
[K in keyof T]: T[K] | undefined;
|
|
56
|
-
};
|
|
57
|
-
abstract resolve<T>(cls: TClass<T>): T;
|
|
58
|
-
abstract instantiate<T>(cls: TClass<T>): T;
|
|
59
|
-
abstract findByTag<T = any>(opts: {
|
|
60
|
-
tag: string;
|
|
61
|
-
exclude?: Array<string> | Set<string>;
|
|
62
|
-
}): IBinding<T>[];
|
|
63
|
-
abstract startResolutionCounting(): void;
|
|
64
|
-
abstract stopResolutionCounting(): void;
|
|
65
|
-
abstract getResolutionCounts(): ReadonlyMap<string, number>;
|
|
66
|
-
abstract clear(): void;
|
|
67
|
-
abstract reset(): void;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=abstract.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,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CAAC;KACtB,GAAG,CAAC,GAAG,SAAS;IACjB,QAAQ,CAAC,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE;QACvC,QAAQ,EAAE;aACP,CAAC,IAAI,MAAM,CAAC,GAAG;gBACd,GAAG,EAAE,WAAW,GAAG;oBAAE,SAAS,EAAE,MAAM,CAAC;oBAAC,GAAG,EAAE,MAAM,CAAA;iBAAE,CAAC;gBACtD,UAAU,CAAC,EAAE,OAAO,CAAC;aACtB;SACF,CAAC;KACH,GAAG;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;KAAE;IAExC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;IACtC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;IAE1C,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE;QAChC,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;KACvC,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE;IACjB,QAAQ,CAAC,uBAAuB,IAAI,IAAI;IACxC,QAAQ,CAAC,sBAAsB,IAAI,IAAI;IACvC,QAAQ,CAAC,mBAAmB,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;IAE3D,QAAQ,CAAC,KAAK,IAAI,IAAI;IACtB,QAAQ,CAAC,KAAK,IAAI,IAAI;CACvB"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractContainer = void 0;
|
|
4
|
-
const base_helper_1 = require("../../common/base-helper");
|
|
5
|
-
/** Container CONTRACT as a class, typed against `IBinding` - implementations sharing no storage start here; ones that only vary resolution start at `BaseContainer`. */
|
|
6
|
-
class AbstractContainer extends base_helper_1.BaseHelper {
|
|
7
|
-
constructor(opts) {
|
|
8
|
-
super({ scope: opts?.scope ?? AbstractContainer.name });
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.AbstractContainer = AbstractContainer;
|
|
12
|
-
//# sourceMappingURL=abstract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../src/modules/container/abstract.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAMlD,wKAAwK;AACxK,MAAsB,iBAAkB,SAAQ,wBAAU;IACxD,YAAY,IAAwB;QAClC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;CA0CF;AA7CD,8CA6CC","sourcesContent":["import { BaseHelper } from '@/common/base-helper';\nimport type { TBindingKey, TClass, TNullable } from '@/common/types';\nimport type { IBinding } from '../binding/common/types';\nimport type { MetadataRegistry } from '../registry/registry';\nimport type { IContainer } from './common/types';\n\n/** Container CONTRACT as a class, typed against `IBinding` - implementations sharing no storage start here; ones that only vary resolution start at `BaseContainer`. */\nexport abstract class AbstractContainer extends BaseHelper implements IContainer {\n constructor(opts?: { scope: string }) {\n super({ scope: opts?.scope ?? AbstractContainer.name });\n }\n\n abstract getMetadataRegistry(): MetadataRegistry;\n\n abstract bind<T>(opts: { key: TBindingKey }): IBinding<T>;\n abstract isBound(opts: { key: TBindingKey }): boolean;\n abstract getBinding<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n }): TNullable<IBinding<T>>;\n abstract unbind(opts: { key: TBindingKey }): boolean;\n abstract set<T>(opts: { binding: IBinding<T> }): void;\n\n abstract get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: false;\n }): T;\n abstract get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n }): T | undefined;\n abstract gets<T extends unknown[]>(opts: {\n bindings: {\n [K in keyof T]: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n };\n };\n }): { [K in keyof T]: T[K] | undefined };\n\n abstract resolve<T>(cls: TClass<T>): T;\n abstract instantiate<T>(cls: TClass<T>): T;\n\n abstract findByTag<T = any>(opts: {\n tag: string;\n exclude?: Array<string> | Set<string>;\n }): IBinding<T>[];\n abstract startResolutionCounting(): void;\n abstract stopResolutionCounting(): void;\n abstract getResolutionCounts(): ReadonlyMap<string, number>;\n\n abstract clear(): void;\n abstract reset(): void;\n}\n"]}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { type TBindingKey, type TClass, type TNullable } from '../../common/types';
|
|
2
|
-
import { Binding } from '../binding/binding';
|
|
3
|
-
import { AbstractContainer } from './abstract';
|
|
4
|
-
/** Storage half of the container, keyed by normalized binding-key strings - resolution (`instantiate`) stays abstract, it is the part an implementation swaps. */
|
|
5
|
-
export declare abstract class BaseContainer extends AbstractContainer {
|
|
6
|
-
protected bindings: Map<string, Binding<any>>;
|
|
7
|
-
/** How often each bound key has been handed out since counting started. */
|
|
8
|
-
protected resolutionCounts: Map<string, number>;
|
|
9
|
-
/** Off by default: the counter sits on the hottest path in the container, and an application that never reads the report should not pay for it. */
|
|
10
|
-
protected isCountingResolutions: boolean;
|
|
11
|
-
/** Whether `startResolutionCounting` has ever run. A report read without it would name every binding, which is a wrong answer rather than an empty one. */
|
|
12
|
-
protected hasStartedResolutionCounting: boolean;
|
|
13
|
-
/** The string each BOUND symbol is stored under: `Symbol('x')` twice is two keys, and both print as "Symbol(x)". */
|
|
14
|
-
protected symbolKeys: Map<symbol, string>;
|
|
15
|
-
/** How many symbols have been bound per description, so a new one gets its suffix in one step. */
|
|
16
|
-
protected symbolDescriptionCounts: Map<string, number>;
|
|
17
|
-
/**
|
|
18
|
-
* Nesting depth of the reads in progress. Past {@link CYCLE_CHECK_DEPTH} the keys are tracked, and
|
|
19
|
-
* a key met again is a cycle: a real graph is far shallower, so the common read pays one counter.
|
|
20
|
-
* Only the synchronous part is checked - a cycle through an `await` is not seen.
|
|
21
|
-
*/
|
|
22
|
-
protected resolutionDepth: number;
|
|
23
|
-
protected resolvingKeys: Set<string>;
|
|
24
|
-
constructor(opts?: {
|
|
25
|
-
scope: string;
|
|
26
|
-
});
|
|
27
|
-
getMetadataRegistry(): import("../registry/registry").MetadataRegistry;
|
|
28
|
-
/**
|
|
29
|
-
* The string a key is stored under, or `undefined` for a symbol that was never bound - a lookup
|
|
30
|
-
* never records one, so reading with throwaway symbols leaves nothing behind.
|
|
31
|
-
*/
|
|
32
|
-
protected toKeyString(opts: {
|
|
33
|
-
key: TBindingKey | {
|
|
34
|
-
namespace: string;
|
|
35
|
-
key: string;
|
|
36
|
-
};
|
|
37
|
-
}): string | undefined;
|
|
38
|
-
/** A bound symbol's own string: its description, suffixed (`Symbol(x)#2`) when another symbol holds it. */
|
|
39
|
-
protected bindSymbolKey(opts: {
|
|
40
|
-
key: symbol;
|
|
41
|
-
}): string;
|
|
42
|
-
bind<T>(opts: {
|
|
43
|
-
key: TBindingKey;
|
|
44
|
-
}): Binding<T>;
|
|
45
|
-
isBound(opts: {
|
|
46
|
-
key: TBindingKey;
|
|
47
|
-
}): boolean;
|
|
48
|
-
getBinding<T>(opts: {
|
|
49
|
-
key: TBindingKey | {
|
|
50
|
-
namespace: string;
|
|
51
|
-
key: string;
|
|
52
|
-
};
|
|
53
|
-
}): TNullable<Binding<T>>;
|
|
54
|
-
unbind(opts: {
|
|
55
|
-
key: TBindingKey;
|
|
56
|
-
}): boolean;
|
|
57
|
-
set<T>(opts: {
|
|
58
|
-
binding: Binding<T>;
|
|
59
|
-
}): void;
|
|
60
|
-
get<T>(opts: {
|
|
61
|
-
key: TBindingKey | {
|
|
62
|
-
namespace: string;
|
|
63
|
-
key: string;
|
|
64
|
-
};
|
|
65
|
-
isOptional?: false;
|
|
66
|
-
}): T;
|
|
67
|
-
get<T>(opts: {
|
|
68
|
-
key: TBindingKey | {
|
|
69
|
-
namespace: string;
|
|
70
|
-
key: string;
|
|
71
|
-
};
|
|
72
|
-
isOptional?: boolean;
|
|
73
|
-
}): T | undefined;
|
|
74
|
-
gets<T extends unknown[]>(opts: {
|
|
75
|
-
bindings: {
|
|
76
|
-
[K in keyof T]: {
|
|
77
|
-
key: TBindingKey | {
|
|
78
|
-
namespace: string;
|
|
79
|
-
key: string;
|
|
80
|
-
};
|
|
81
|
-
isOptional?: boolean;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
}): {
|
|
85
|
-
[K in keyof T]: T[K] | undefined;
|
|
86
|
-
};
|
|
87
|
-
/** Clears the counts and starts counting. Call it AFTER `initialize()`: boot resolves plenty no request ever asks for, and `bootChecks.binding.doVerify` reads every service and repository. */
|
|
88
|
-
startResolutionCounting(): void;
|
|
89
|
-
/** Stops counting and keeps what was counted, so `get` returns to its uncounted cost. */
|
|
90
|
-
stopResolutionCounting(): void;
|
|
91
|
-
/** How many times each bound key has been read since counting started. A key that was bound and never read is absent. The map is a copy. */
|
|
92
|
-
getResolutionCounts(): ReadonlyMap<string, number>;
|
|
93
|
-
resolve<T>(cls: TClass<T>): T;
|
|
94
|
-
findByTag<T = any>(opts: {
|
|
95
|
-
tag: string;
|
|
96
|
-
exclude?: Array<string> | Set<string>;
|
|
97
|
-
}): Binding<T>[];
|
|
98
|
-
clear(): void;
|
|
99
|
-
reset(): void;
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,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C,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE;QAChC,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;KACvC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE;IAyBP,KAAK,IAAI,IAAI;IAOb,KAAK,IAAI,IAAI;CAKvB"}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseContainer = void 0;
|
|
4
|
-
const binding_1 = require("../binding/binding");
|
|
5
|
-
const constants_1 = require("../binding/common/constants");
|
|
6
|
-
const error_1 = require("../error");
|
|
7
|
-
const registry_1 = require("../registry/registry");
|
|
8
|
-
const abstract_1 = require("./abstract");
|
|
9
|
-
/** A dependency graph nests far less than this; deeper is all but certainly a cycle, and is checked. */
|
|
10
|
-
const CYCLE_CHECK_DEPTH = 64;
|
|
11
|
-
/** Storage half of the container, keyed by normalized binding-key strings - resolution (`instantiate`) stays abstract, it is the part an implementation swaps. */
|
|
12
|
-
class BaseContainer extends abstract_1.AbstractContainer {
|
|
13
|
-
constructor(opts) {
|
|
14
|
-
super({ scope: opts?.scope ?? BaseContainer.name });
|
|
15
|
-
this.bindings = new Map();
|
|
16
|
-
/** How often each bound key has been handed out since counting started. */
|
|
17
|
-
this.resolutionCounts = new Map();
|
|
18
|
-
/** Off by default: the counter sits on the hottest path in the container, and an application that never reads the report should not pay for it. */
|
|
19
|
-
this.isCountingResolutions = false;
|
|
20
|
-
/** Whether `startResolutionCounting` has ever run. A report read without it would name every binding, which is a wrong answer rather than an empty one. */
|
|
21
|
-
this.hasStartedResolutionCounting = false;
|
|
22
|
-
/** The string each BOUND symbol is stored under: `Symbol('x')` twice is two keys, and both print as "Symbol(x)". */
|
|
23
|
-
this.symbolKeys = new Map();
|
|
24
|
-
/** How many symbols have been bound per description, so a new one gets its suffix in one step. */
|
|
25
|
-
this.symbolDescriptionCounts = new Map();
|
|
26
|
-
/**
|
|
27
|
-
* Nesting depth of the reads in progress. Past {@link CYCLE_CHECK_DEPTH} the keys are tracked, and
|
|
28
|
-
* a key met again is a cycle: a real graph is far shallower, so the common read pays one counter.
|
|
29
|
-
* Only the synchronous part is checked - a cycle through an `await` is not seen.
|
|
30
|
-
*/
|
|
31
|
-
this.resolutionDepth = 0;
|
|
32
|
-
this.resolvingKeys = new Set();
|
|
33
|
-
}
|
|
34
|
-
getMetadataRegistry() {
|
|
35
|
-
return registry_1.metadataRegistry;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* The string a key is stored under, or `undefined` for a symbol that was never bound - a lookup
|
|
39
|
-
* never records one, so reading with throwaway symbols leaves nothing behind.
|
|
40
|
-
*/
|
|
41
|
-
toKeyString(opts) {
|
|
42
|
-
const { key } = opts;
|
|
43
|
-
switch (typeof key) {
|
|
44
|
-
case 'string': {
|
|
45
|
-
return key;
|
|
46
|
-
}
|
|
47
|
-
case 'symbol': {
|
|
48
|
-
return this.symbolKeys.get(key);
|
|
49
|
-
}
|
|
50
|
-
case 'object': {
|
|
51
|
-
return constants_1.BindingKeys.build(key);
|
|
52
|
-
}
|
|
53
|
-
default: {
|
|
54
|
-
throw (0, error_1.getError)({
|
|
55
|
-
message: `[getBinding] Invalid binding key type | opts: ${String(key)} | allowed: [string, symbol, { namespace: string, key: string }]`,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/** A bound symbol's own string: its description, suffixed (`Symbol(x)#2`) when another symbol holds it. */
|
|
61
|
-
bindSymbolKey(opts) {
|
|
62
|
-
const { key } = opts;
|
|
63
|
-
const known = this.symbolKeys.get(key);
|
|
64
|
-
if (known !== undefined) {
|
|
65
|
-
return known;
|
|
66
|
-
}
|
|
67
|
-
const description = key.toString();
|
|
68
|
-
const count = (this.symbolDescriptionCounts.get(description) ?? 0) + 1;
|
|
69
|
-
this.symbolDescriptionCounts.set(description, count);
|
|
70
|
-
const keyStr = count === 1 ? description : `${description}#${count}`;
|
|
71
|
-
this.symbolKeys.set(key, keyStr);
|
|
72
|
-
return keyStr;
|
|
73
|
-
}
|
|
74
|
-
bind(opts) {
|
|
75
|
-
const { key } = opts;
|
|
76
|
-
const keyStr = typeof key === 'symbol' ? this.bindSymbolKey({ key }) : key;
|
|
77
|
-
const binding = new binding_1.Binding({ key: keyStr });
|
|
78
|
-
this.bindings.set(keyStr, binding);
|
|
79
|
-
return binding;
|
|
80
|
-
}
|
|
81
|
-
isBound(opts) {
|
|
82
|
-
const keyStr = this.toKeyString({ key: opts.key });
|
|
83
|
-
return keyStr !== undefined && this.bindings.has(keyStr);
|
|
84
|
-
}
|
|
85
|
-
getBinding(opts) {
|
|
86
|
-
const keyStr = this.toKeyString({ key: opts.key });
|
|
87
|
-
return keyStr === undefined ? undefined : this.bindings.get(keyStr);
|
|
88
|
-
}
|
|
89
|
-
unbind(opts) {
|
|
90
|
-
const { key } = opts;
|
|
91
|
-
const keyStr = this.toKeyString({ key });
|
|
92
|
-
if (typeof key === 'symbol') {
|
|
93
|
-
this.symbolKeys.delete(key);
|
|
94
|
-
}
|
|
95
|
-
return keyStr !== undefined && this.bindings.delete(keyStr);
|
|
96
|
-
}
|
|
97
|
-
set(opts) {
|
|
98
|
-
const { binding } = opts;
|
|
99
|
-
this.bindings.set(binding.key, binding);
|
|
100
|
-
}
|
|
101
|
-
get(opts) {
|
|
102
|
-
const { key, isOptional = false } = opts;
|
|
103
|
-
const binding = this.getBinding({ key });
|
|
104
|
-
if (binding) {
|
|
105
|
-
// Counted here and nowhere else: constructor injection, property injection, `application.get`
|
|
106
|
-
// and `verifyBindings` all arrive through this one method. A miss below is not a resolution.
|
|
107
|
-
if (this.isCountingResolutions) {
|
|
108
|
-
this.resolutionCounts.set(binding.key, (this.resolutionCounts.get(binding.key) ?? 0) + 1);
|
|
109
|
-
}
|
|
110
|
-
// The hot path: a cached singleton or a value builds nothing, so it cannot be part of a cycle.
|
|
111
|
-
if (binding.isSettled()) {
|
|
112
|
-
return binding.getValue(this);
|
|
113
|
-
}
|
|
114
|
-
this.resolutionDepth++;
|
|
115
|
-
const isTracked = this.resolutionDepth > CYCLE_CHECK_DEPTH;
|
|
116
|
-
if (isTracked && this.resolvingKeys.has(binding.key)) {
|
|
117
|
-
this.resolutionDepth--;
|
|
118
|
-
throw (0, error_1.getError)({
|
|
119
|
-
message: `Circular dependency | ${[...this.resolvingKeys, binding.key].join(' -> ')}`,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if (isTracked) {
|
|
123
|
-
this.resolvingKeys.add(binding.key);
|
|
124
|
-
}
|
|
125
|
-
try {
|
|
126
|
-
return binding.getValue(this);
|
|
127
|
-
}
|
|
128
|
-
finally {
|
|
129
|
-
this.resolutionDepth--;
|
|
130
|
-
if (isTracked) {
|
|
131
|
-
this.resolvingKeys.delete(binding.key);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (!isOptional) {
|
|
136
|
-
throw (0, error_1.getError)({
|
|
137
|
-
message: `Binding key: ${typeof key === 'object' ? constants_1.BindingKeys.build(key) : String(key)} is not bounded in context!`,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
gets(opts) {
|
|
143
|
-
return opts.bindings.map((opt) => this.get({ ...opt, isOptional: true }));
|
|
144
|
-
}
|
|
145
|
-
/** Clears the counts and starts counting. Call it AFTER `initialize()`: boot resolves plenty no request ever asks for, and `bootChecks.binding.doVerify` reads every service and repository. */
|
|
146
|
-
startResolutionCounting() {
|
|
147
|
-
this.resolutionCounts.clear();
|
|
148
|
-
this.isCountingResolutions = true;
|
|
149
|
-
this.hasStartedResolutionCounting = true;
|
|
150
|
-
}
|
|
151
|
-
/** Stops counting and keeps what was counted, so `get` returns to its uncounted cost. */
|
|
152
|
-
stopResolutionCounting() {
|
|
153
|
-
this.isCountingResolutions = false;
|
|
154
|
-
}
|
|
155
|
-
/** How many times each bound key has been read since counting started. A key that was bound and never read is absent. The map is a copy. */
|
|
156
|
-
getResolutionCounts() {
|
|
157
|
-
return new Map(this.resolutionCounts);
|
|
158
|
-
}
|
|
159
|
-
resolve(cls) {
|
|
160
|
-
return this.instantiate(cls);
|
|
161
|
-
}
|
|
162
|
-
findByTag(opts) {
|
|
163
|
-
const { tag, exclude } = opts;
|
|
164
|
-
const rs = [];
|
|
165
|
-
const bindings = this.bindings.values();
|
|
166
|
-
for (const binding of bindings) {
|
|
167
|
-
if (!binding.hasTag(tag)) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (exclude instanceof Array && exclude.length > 0 && exclude.includes(binding.key)) {
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
if (exclude instanceof Set && exclude.size > 0 && exclude.has(binding.key)) {
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
rs.push(binding);
|
|
177
|
-
}
|
|
178
|
-
return rs;
|
|
179
|
-
}
|
|
180
|
-
clear() {
|
|
181
|
-
const bindings = this.bindings.values();
|
|
182
|
-
for (const binding of bindings) {
|
|
183
|
-
binding.clearCache();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
reset() {
|
|
187
|
-
this.bindings.clear();
|
|
188
|
-
this.symbolKeys.clear();
|
|
189
|
-
this.symbolDescriptionCounts.clear();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
exports.BaseContainer = BaseContainer;
|
|
193
|
-
//# sourceMappingURL=base.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/modules/container/base.ts"],"names":[],"mappings":";;;AACA,gDAA6C;AAC7C,2DAA0D;AAC1D,oCAAoC;AACpC,mDAAwD;AACxD,yCAA+C;AAE/C,wGAAwG;AACxG,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,kKA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AI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpF,SAAS;YACX,CAAC;YAED,IAAI,OAAO,YAAY,GAAG,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3E,SAAS;YACX,CAAC;YAED,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAEQ,KAAK;QACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;IAEQ,KAAK;QACZ,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;CACF;AAzPD,sCAyPC","sourcesContent":["import { type TBindingKey, type TClass, type TNullable } from '@/common/types';\nimport { Binding } from '../binding/binding';\nimport { BindingKeys } from '../binding/common/constants';\nimport { getError } from '../error';\nimport { metadataRegistry } from '../registry/registry';\nimport { AbstractContainer } from './abstract';\n\n/** A dependency graph nests far less than this; deeper is all but certainly a cycle, and is checked. */\nconst CYCLE_CHECK_DEPTH = 64;\n\n/** Storage half of the container, keyed by normalized binding-key strings - resolution (`instantiate`) stays abstract, it is the part an implementation swaps. */\nexport abstract class BaseContainer extends AbstractContainer {\n protected bindings = new Map<string, Binding>();\n\n /** How often each bound key has been handed out since counting started. */\n protected resolutionCounts = new Map<string, number>();\n\n /** Off by default: the counter sits on the hottest path in the container, and an application that never reads the report should not pay for it. */\n protected isCountingResolutions = false;\n\n /** Whether `startResolutionCounting` has ever run. A report read without it would name every binding, which is a wrong answer rather than an empty one. */\n protected hasStartedResolutionCounting = false;\n\n /** The string each BOUND symbol is stored under: `Symbol('x')` twice is two keys, and both print as \"Symbol(x)\". */\n protected symbolKeys = new Map<symbol, string>();\n\n /** How many symbols have been bound per description, so a new one gets its suffix in one step. */\n protected symbolDescriptionCounts = new Map<string, number>();\n\n /**\n * Nesting depth of the reads in progress. Past {@link CYCLE_CHECK_DEPTH} the keys are tracked, and\n * a key met again is a cycle: a real graph is far shallower, so the common read pays one counter.\n * Only the synchronous part is checked - a cycle through an `await` is not seen.\n */\n protected resolutionDepth = 0;\n protected resolvingKeys = new Set<string>();\n\n constructor(opts?: { scope: string }) {\n super({ scope: opts?.scope ?? BaseContainer.name });\n }\n\n override getMetadataRegistry() {\n return metadataRegistry;\n }\n\n /**\n * The string a key is stored under, or `undefined` for a symbol that was never bound - a lookup\n * never records one, so reading with throwaway symbols leaves nothing behind.\n */\n protected toKeyString(opts: {\n key: TBindingKey | { namespace: string; key: string };\n }): string | undefined {\n const { key } = opts;\n\n switch (typeof key) {\n case 'string': {\n return key;\n }\n case 'symbol': {\n return this.symbolKeys.get(key);\n }\n case 'object': {\n return BindingKeys.build(key);\n }\n default: {\n throw getError({\n message: `[getBinding] Invalid binding key type | opts: ${String(key)} | allowed: [string, symbol, { namespace: string, key: string }]`,\n });\n }\n }\n }\n\n /** A bound symbol's own string: its description, suffixed (`Symbol(x)#2`) when another symbol holds it. */\n protected bindSymbolKey(opts: { key: symbol }): string {\n const { key } = opts;\n\n const known = this.symbolKeys.get(key);\n if (known !== undefined) {\n return known;\n }\n\n const description = key.toString();\n const count = (this.symbolDescriptionCounts.get(description) ?? 0) + 1;\n this.symbolDescriptionCounts.set(description, count);\n\n const keyStr = count === 1 ? description : `${description}#${count}`;\n this.symbolKeys.set(key, keyStr);\n return keyStr;\n }\n\n override bind<T>(opts: { key: TBindingKey }): Binding<T> {\n const { key } = opts;\n const keyStr = typeof key === 'symbol' ? this.bindSymbolKey({ key }) : key;\n const binding = new Binding<T>({ key: keyStr });\n this.bindings.set(keyStr, binding as Binding);\n return binding;\n }\n\n override isBound(opts: { key: TBindingKey }): boolean {\n const keyStr = this.toKeyString({ key: opts.key });\n return keyStr !== undefined && this.bindings.has(keyStr);\n }\n\n override getBinding<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n }): TNullable<Binding<T>> {\n const keyStr = this.toKeyString({ key: opts.key });\n return keyStr === undefined ? undefined : this.bindings.get(keyStr);\n }\n\n override unbind(opts: { key: TBindingKey }): boolean {\n const { key } = opts;\n const keyStr = this.toKeyString({ key });\n\n if (typeof key === 'symbol') {\n this.symbolKeys.delete(key);\n }\n\n return keyStr !== undefined && this.bindings.delete(keyStr);\n }\n\n override set<T>(opts: { binding: Binding<T> }): void {\n const { binding } = opts;\n this.bindings.set(binding.key, binding);\n }\n\n override get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: false;\n }): T;\n override get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n }): T | undefined;\n override get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n }): T | undefined {\n const { key, isOptional = false } = opts;\n\n const binding = this.getBinding<T>({ key });\n if (binding) {\n // Counted here and nowhere else: constructor injection, property injection, `application.get`\n // and `verifyBindings` all arrive through this one method. A miss below is not a resolution.\n if (this.isCountingResolutions) {\n this.resolutionCounts.set(binding.key, (this.resolutionCounts.get(binding.key) ?? 0) + 1);\n }\n\n // The hot path: a cached singleton or a value builds nothing, so it cannot be part of a cycle.\n if (binding.isSettled()) {\n return binding.getValue(this);\n }\n\n this.resolutionDepth++;\n const isTracked = this.resolutionDepth > CYCLE_CHECK_DEPTH;\n\n if (isTracked && this.resolvingKeys.has(binding.key)) {\n this.resolutionDepth--;\n throw getError({\n message: `Circular dependency | ${[...this.resolvingKeys, binding.key].join(' -> ')}`,\n });\n }\n\n if (isTracked) {\n this.resolvingKeys.add(binding.key);\n }\n\n try {\n return binding.getValue(this);\n } finally {\n this.resolutionDepth--;\n if (isTracked) {\n this.resolvingKeys.delete(binding.key);\n }\n }\n }\n\n if (!isOptional) {\n throw getError({\n message: `Binding key: ${typeof key === 'object' ? BindingKeys.build(key) : String(key)} is not bounded in context!`,\n });\n }\n\n return undefined;\n }\n\n override gets<T extends unknown[]>(opts: {\n bindings: {\n [K in keyof T]: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n };\n };\n }): { [K in keyof T]: T[K] | undefined } {\n return opts.bindings.map((opt) => this.get({ ...opt, isOptional: true })) as {\n [K in keyof T]: T[K] | undefined;\n };\n }\n\n /** Clears the counts and starts counting. Call it AFTER `initialize()`: boot resolves plenty no request ever asks for, and `bootChecks.binding.doVerify` reads every service and repository. */\n override startResolutionCounting(): void {\n this.resolutionCounts.clear();\n this.isCountingResolutions = true;\n this.hasStartedResolutionCounting = true;\n }\n\n /** Stops counting and keeps what was counted, so `get` returns to its uncounted cost. */\n override stopResolutionCounting(): void {\n this.isCountingResolutions = false;\n }\n\n /** How many times each bound key has been read since counting started. A key that was bound and never read is absent. The map is a copy. */\n override getResolutionCounts(): ReadonlyMap<string, number> {\n return new Map(this.resolutionCounts);\n }\n\n override resolve<T>(cls: TClass<T>): T {\n return this.instantiate(cls);\n }\n\n override findByTag<T = any>(opts: {\n tag: string;\n exclude?: Array<string> | Set<string>;\n }): Binding<T>[] {\n const { tag, exclude } = opts;\n\n const rs: Binding<T>[] = [];\n\n const bindings = this.bindings.values();\n for (const binding of bindings) {\n if (!binding.hasTag(tag)) {\n continue;\n }\n\n if (exclude instanceof Array && exclude.length > 0 && exclude.includes(binding.key)) {\n continue;\n }\n\n if (exclude instanceof Set && exclude.size > 0 && exclude.has(binding.key)) {\n continue;\n }\n\n rs.push(binding);\n }\n\n return rs;\n }\n\n override clear(): void {\n const bindings = this.bindings.values();\n for (const binding of bindings) {\n binding.clearCache();\n }\n }\n\n override reset(): void {\n this.bindings.clear();\n this.symbolKeys.clear();\n this.symbolDescriptionCounts.clear();\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/container/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/container/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB","sourcesContent":["export * from './types';\n"]}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { IBinding } from '../../binding/common/types';
|
|
2
|
-
import type { TBindingKey, TClass, TNullable } from '../../../common/types';
|
|
3
|
-
import type { MetadataRegistry } from '../../registry/registry';
|
|
4
|
-
export interface IContainer {
|
|
5
|
-
getMetadataRegistry(): MetadataRegistry;
|
|
6
|
-
bind<T>(opts: {
|
|
7
|
-
key: TBindingKey;
|
|
8
|
-
}): IBinding<T>;
|
|
9
|
-
isBound(opts: {
|
|
10
|
-
key: TBindingKey;
|
|
11
|
-
}): boolean;
|
|
12
|
-
getBinding<T>(opts: {
|
|
13
|
-
key: TBindingKey | {
|
|
14
|
-
namespace: string;
|
|
15
|
-
key: string;
|
|
16
|
-
};
|
|
17
|
-
}): TNullable<IBinding<T>>;
|
|
18
|
-
unbind(opts: {
|
|
19
|
-
key: TBindingKey;
|
|
20
|
-
}): boolean;
|
|
21
|
-
set<T>(opts: {
|
|
22
|
-
binding: IBinding<T>;
|
|
23
|
-
}): void;
|
|
24
|
-
get<T>(opts: {
|
|
25
|
-
key: TBindingKey | {
|
|
26
|
-
namespace: string;
|
|
27
|
-
key: string;
|
|
28
|
-
};
|
|
29
|
-
isOptional?: false;
|
|
30
|
-
}): T;
|
|
31
|
-
get<T>(opts: {
|
|
32
|
-
key: TBindingKey | {
|
|
33
|
-
namespace: string;
|
|
34
|
-
key: string;
|
|
35
|
-
};
|
|
36
|
-
isOptional?: boolean;
|
|
37
|
-
}): T | undefined;
|
|
38
|
-
gets<T extends unknown[]>(opts: {
|
|
39
|
-
bindings: {
|
|
40
|
-
[K in keyof T]: {
|
|
41
|
-
key: TBindingKey | {
|
|
42
|
-
namespace: string;
|
|
43
|
-
key: string;
|
|
44
|
-
};
|
|
45
|
-
isOptional?: boolean;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
}): {
|
|
49
|
-
[K in keyof T]: T[K] | undefined;
|
|
50
|
-
};
|
|
51
|
-
resolve<T>(cls: TClass<T>): T;
|
|
52
|
-
instantiate<T>(cls: TClass<T>): T;
|
|
53
|
-
findByTag<T = any>(opts: {
|
|
54
|
-
tag: string;
|
|
55
|
-
exclude?: Array<string> | Set<string>;
|
|
56
|
-
}): IBinding<T>[];
|
|
57
|
-
clear(): void;
|
|
58
|
-
reset(): void;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/container/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,UAAU;IACzB,mBAAmB,IAAI,gBAAgB,CAAC;IAExC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;QAAE,GAAG,EAAE,WAAW,CAAA;KAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC;IAC7C,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE;QAClB,GAAG,EAAE,WAAW,GAAG;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;KACvD,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC;IAC5C,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IAE7C,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE;QAAE,GAAG,EAAE,WAAW,GAAG;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,UAAU,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,CAAC,CAAC;IAC/F,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE;QACX,GAAG,EAAE,WAAW,GAAG;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;QACtD,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,GAAG,CAAC,GAAG,SAAS,CAAC;IAClB,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE;QAC9B,QAAQ,EAAE;aACP,CAAC,IAAI,MAAM,CAAC,GAAG;gBACd,GAAG,EAAE,WAAW,GAAG;oBAAE,SAAS,EAAE,MAAM,CAAC;oBAAC,GAAG,EAAE,MAAM,CAAA;iBAAE,CAAC;gBACtD,UAAU,CAAC,EAAE,OAAO,CAAC;aACtB;SACF,CAAC;KACH,GAAG;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS;KAAE,CAAC;IAEzC,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC9B,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAElC,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAChG,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/container/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IBinding } from '../../binding/common/types';\nimport type { TBindingKey, TClass, TNullable } from '@/common/types';\nimport type { MetadataRegistry } from '../../registry/registry';\n\nexport interface IContainer {\n getMetadataRegistry(): MetadataRegistry;\n\n bind<T>(opts: { key: TBindingKey }): IBinding<T>;\n isBound(opts: { key: TBindingKey }): boolean;\n getBinding<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n }): TNullable<IBinding<T>>;\n unbind(opts: { key: TBindingKey }): boolean;\n set<T>(opts: { binding: IBinding<T> }): void;\n\n get<T>(opts: { key: TBindingKey | { namespace: string; key: string }; isOptional?: false }): T;\n get<T>(opts: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n }): T | undefined;\n gets<T extends unknown[]>(opts: {\n bindings: {\n [K in keyof T]: {\n key: TBindingKey | { namespace: string; key: string };\n isOptional?: boolean;\n };\n };\n }): { [K in keyof T]: T[K] | undefined };\n\n resolve<T>(cls: TClass<T>): T;\n instantiate<T>(cls: TClass<T>): T;\n\n findByTag<T = any>(opts: { tag: string; exclude?: Array<string> | Set<string> }): IBinding<T>[];\n clear(): void;\n reset(): void;\n}\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type AnyType, type TBindingKey, type TClass, type TInjectTarget } from '../../common/types';
|
|
2
|
-
import { BaseContainer } from './base';
|
|
3
|
-
/** Default container: constructor + property injection driven by the decorator metadata registry. */
|
|
4
|
-
export declare class Container extends BaseContainer {
|
|
5
|
-
constructor(opts?: {
|
|
6
|
-
scope: string;
|
|
7
|
-
});
|
|
8
|
-
/**
|
|
9
|
-
* The class form reads the key the REGISTRATION recorded, so a call-site override and an imperative
|
|
10
|
-
* `application.service(X)` both resolve. `@inject` takes a key or a class; metadata a framework
|
|
11
|
-
* writes may carry both, and then the class wins and the key is the fallback for a class nothing
|
|
12
|
-
* recorded - one bound by hand with `bind({ key }).toClass(X)`. An optional class with neither
|
|
13
|
-
* resolves to `undefined`, as an optional key would.
|
|
14
|
-
*/
|
|
15
|
-
protected resolveBindingKey(opts: {
|
|
16
|
-
key?: TBindingKey;
|
|
17
|
-
target?: TInjectTarget;
|
|
18
|
-
isOptional?: boolean;
|
|
19
|
-
cls: TClass<AnyType>;
|
|
20
|
-
at: string;
|
|
21
|
-
}): TBindingKey | undefined;
|
|
22
|
-
instantiate<T>(cls: TClass<T>): T;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=container.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../src/modules/container/container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEjG,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,qGAAqG;AACrG,qBAAa,SAAU,SAAQ,aAAa;gBAC9B,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAIpC;;;;;;OAMG;IACH,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE;QAChC,GAAG,CAAC,EAAE,WAAW,CAAC;QAClB,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACrB,EAAE,EAAE,MAAM,CAAC;KACZ,GAAG,WAAW,GAAG,SAAS;IA0ClB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;CAyD3C"}
|