assemblerjs 1.1.1 → 1.1.3
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/dist/index.d.ts +53 -8
- package/dist/index13.js +1 -1
- package/dist/index13.mjs +1 -1
- package/dist/index18.js +1 -1
- package/dist/index18.mjs +1 -1
- package/dist/index19.js +1 -1
- package/dist/index19.mjs +1 -1
- package/dist/index20.js +1 -1
- package/dist/index20.mjs +1 -1
- package/dist/index21.js +1 -1
- package/dist/index21.mjs +1 -1
- package/dist/index22.js +1 -1
- package/dist/index22.mjs +1 -1
- package/dist/index23.js +1 -1
- package/dist/index23.mjs +1 -1
- package/dist/index24.js +1 -1
- package/dist/index24.mjs +1 -1
- package/dist/index27.js +1 -1
- package/dist/index27.mjs +1 -1
- package/dist/index30.js +8 -2
- package/dist/index30.mjs +8 -2
- package/dist/index31.js +38 -20
- package/dist/index31.mjs +37 -20
- package/dist/index32.js +17 -58
- package/dist/index32.mjs +17 -58
- package/dist/index33.js +57 -20
- package/dist/index33.mjs +57 -20
- package/dist/index34.js +23 -57
- package/dist/index34.mjs +23 -57
- package/dist/index35.js +75 -27
- package/dist/index35.mjs +75 -27
- package/dist/index36.js +39 -29
- package/dist/index36.mjs +39 -29
- package/dist/index37.js +30 -39
- package/dist/index37.mjs +30 -38
- package/dist/index38.js +125 -97
- package/dist/index38.mjs +125 -97
- package/dist/index39.js +101 -24
- package/dist/index39.mjs +101 -24
- package/dist/index4.js +21 -8
- package/dist/index4.mjs +21 -8
- package/dist/index40.js +28 -48
- package/dist/index40.mjs +28 -48
- package/dist/index41.js +43 -3
- package/dist/index41.mjs +43 -3
- package/dist/index42.js +22 -28
- package/dist/index42.mjs +21 -27
- package/dist/index43.js +26 -169
- package/dist/index43.mjs +25 -169
- package/dist/index44.js +192 -940
- package/dist/index44.mjs +192 -940
- package/dist/index45.js +942 -2
- package/dist/index45.mjs +942 -2
- package/dist/index46.js +2 -2
- package/dist/index46.mjs +2 -2
- package/dist/index47.js +2 -14
- package/dist/index47.mjs +2 -14
- package/dist/index48.js +9 -23
- package/dist/index48.mjs +9 -23
- package/dist/index49.js +32 -55
- package/dist/index49.mjs +32 -54
- package/dist/index50.js +67 -0
- package/dist/index50.mjs +62 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -79,7 +79,8 @@ declare abstract class AbstractInjectable<T> {
|
|
|
79
79
|
abstract readonly privateContext: AssemblerPrivateContext;
|
|
80
80
|
abstract readonly publicContext: AssemblerContext;
|
|
81
81
|
abstract readonly identifier: Identifier<T> | string | symbol;
|
|
82
|
-
abstract readonly concrete
|
|
82
|
+
abstract readonly concrete?: Concrete<T>;
|
|
83
|
+
abstract readonly factory?: Factory<T>;
|
|
83
84
|
abstract readonly configuration: Record<string, any>;
|
|
84
85
|
abstract dependencies: (Identifier<unknown> | any)[];
|
|
85
86
|
abstract definition: AssemblageDefinition;
|
|
@@ -310,6 +311,14 @@ export declare interface AssemblageDefinition {
|
|
|
310
311
|
* `assembler.js` dependency injection container and handler.
|
|
311
312
|
*/
|
|
312
313
|
export declare class Assembler extends EventManager implements AbstractAssembler {
|
|
314
|
+
/**
|
|
315
|
+
* Enable debug mode with optional configuration
|
|
316
|
+
*/
|
|
317
|
+
static enableDebug(options?: AssemblerDebugOptions): void;
|
|
318
|
+
/**
|
|
319
|
+
* Disable debug mode
|
|
320
|
+
*/
|
|
321
|
+
static disableDebug(): void;
|
|
313
322
|
/**
|
|
314
323
|
* Build the dependencies tree from an assemblage as entry point.
|
|
315
324
|
*
|
|
@@ -370,6 +379,24 @@ export declare interface AssemblerContext {
|
|
|
370
379
|
events: AbstractAssembler['channels'];
|
|
371
380
|
}
|
|
372
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Debug options for Assembler build process
|
|
384
|
+
*/
|
|
385
|
+
export declare interface AssemblerDebugOptions {
|
|
386
|
+
enabled?: boolean;
|
|
387
|
+
logger?: (level: 'info' | 'warn' | 'error', message: string, data?: any) => void;
|
|
388
|
+
logPhases?: {
|
|
389
|
+
registration?: boolean;
|
|
390
|
+
resolution?: boolean;
|
|
391
|
+
construction?: boolean;
|
|
392
|
+
hooks?: boolean;
|
|
393
|
+
cache?: boolean;
|
|
394
|
+
};
|
|
395
|
+
logTimings?: boolean;
|
|
396
|
+
logDependencyTree?: boolean;
|
|
397
|
+
useColors?: boolean;
|
|
398
|
+
}
|
|
399
|
+
|
|
373
400
|
/**
|
|
374
401
|
* `Assembler` dispose method type.
|
|
375
402
|
*/
|
|
@@ -429,8 +456,9 @@ export declare function Before(pointcut: string, priority?: number): (target: an
|
|
|
429
456
|
*/
|
|
430
457
|
declare interface Buildable<T> {
|
|
431
458
|
identifier: Identifier<T>;
|
|
432
|
-
concrete
|
|
459
|
+
concrete?: Concrete<T>;
|
|
433
460
|
instance?: T;
|
|
461
|
+
factory?: () => T;
|
|
434
462
|
configuration: Record<string, any>;
|
|
435
463
|
}
|
|
436
464
|
|
|
@@ -557,7 +585,7 @@ export declare const decorateGlobal: (identifier: string | symbol, target: any,
|
|
|
557
585
|
* @param target The target class
|
|
558
586
|
* @param index The parameter index
|
|
559
587
|
*/
|
|
560
|
-
export declare const decorateUse: (identifier:
|
|
588
|
+
export declare const decorateUse: (identifier: UseIdentifier, target: any, index: number) => void;
|
|
561
589
|
|
|
562
590
|
/**
|
|
563
591
|
* Type for a function that creates a decorator.
|
|
@@ -621,6 +649,11 @@ export declare class EventManager implements AbstractEventManager {
|
|
|
621
649
|
private cleanChannel;
|
|
622
650
|
}
|
|
623
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Factory function that returns an instance of type T.
|
|
654
|
+
*/
|
|
655
|
+
declare type Factory<T> = () => T;
|
|
656
|
+
|
|
624
657
|
export declare const getAssemblageContext: <T>(target: Concrete<T> | Function) => AssemblerContext;
|
|
625
658
|
|
|
626
659
|
export declare const getAssemblageDefinition: <T>(target: Concrete<T>) => AssemblageDefinition;
|
|
@@ -698,7 +731,7 @@ declare class Injectable<T> implements AbstractInjectable<T> {
|
|
|
698
731
|
/** Unique identifier for this injectable. */
|
|
699
732
|
readonly identifier: Identifier<T> | string | symbol;
|
|
700
733
|
/** The concrete class to instantiate. */
|
|
701
|
-
readonly concrete: Concrete<T
|
|
734
|
+
readonly concrete: Concrete<T> | undefined;
|
|
702
735
|
/** Base configuration for this injectable. */
|
|
703
736
|
readonly configuration: Record<string, any>;
|
|
704
737
|
/** Merged configuration used during build (base + runtime). */
|
|
@@ -720,6 +753,7 @@ declare class Injectable<T> implements AbstractInjectable<T> {
|
|
|
720
753
|
private dependenciesIds;
|
|
721
754
|
protected singletonInstance: T | undefined;
|
|
722
755
|
private builder;
|
|
756
|
+
readonly factory?: () => T;
|
|
723
757
|
static of<TNew>(buildable: Buildable<TNew>, privateContext: AssemblerPrivateContext, publicContext: AssemblerContext): Injectable<TNew>;
|
|
724
758
|
private constructor();
|
|
725
759
|
/**
|
|
@@ -834,9 +868,10 @@ declare interface InjectableResolver {
|
|
|
834
868
|
declare type Injection<T> = BaseInjection<T> | ConfiguredInjection<T> | ConcreteInjection<T> | ConcreteConfiguredInjection<T>;
|
|
835
869
|
|
|
836
870
|
/**
|
|
837
|
-
* Injectable binds an instance of a class to an identifier (abstract or concrete).
|
|
871
|
+
* Injectable binds an instance or factory of a class to an identifier (abstract or concrete).
|
|
872
|
+
* The second element can be either an instance or a factory function that returns an instance.
|
|
838
873
|
*/
|
|
839
|
-
declare type InstanceInjection<T> = Tuple<[Identifier<T> | string | symbol, T]>;
|
|
874
|
+
declare type InstanceInjection<T> = Tuple<[Identifier<T> | string | symbol, T | Factory<T>]>;
|
|
840
875
|
|
|
841
876
|
/**
|
|
842
877
|
* Check if a given class is an `Assemblage`.
|
|
@@ -1307,10 +1342,20 @@ export declare interface TransversalMetadata {
|
|
|
1307
1342
|
}
|
|
1308
1343
|
|
|
1309
1344
|
/**
|
|
1310
|
-
* Injects an object passed with `string
|
|
1345
|
+
* Injects an object passed with `string`, `symbol` or abstract class identifier.
|
|
1346
|
+
* The identifier can be:
|
|
1347
|
+
* - A string: @Use('logger')
|
|
1348
|
+
* - A symbol: @Use(Symbol.for('logger'))
|
|
1349
|
+
* - An abstract class: @Use(ILogger)
|
|
1350
|
+
*
|
|
1311
1351
|
* @param identifier The identifier of the object to inject
|
|
1312
1352
|
* @returns A parameter decorator
|
|
1313
1353
|
*/
|
|
1314
|
-
export declare const Use: (param?:
|
|
1354
|
+
export declare const Use: (param?: UseIdentifier | undefined) => ParameterDecorator;
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* Identifier can be a string, symbol, or an abstract class/interface.
|
|
1358
|
+
*/
|
|
1359
|
+
export declare type UseIdentifier = string | symbol | Function;
|
|
1315
1360
|
|
|
1316
1361
|
export { }
|
package/dist/index13.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const core = require('@assemblerjs/core');
|
|
6
|
-
const pointcutMatcher = require('./
|
|
6
|
+
const pointcutMatcher = require('./index40.js');
|
|
7
7
|
const affect = require('./index12.js');
|
|
8
8
|
const schema = require('./index30.js');
|
|
9
9
|
|
package/dist/index13.mjs
CHANGED
package/dist/index18.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index32.js');
|
|
7
7
|
|
|
8
8
|
let ContextResolver = class ContextResolver {
|
|
9
9
|
resolve(e, r, t) {
|
package/dist/index18.mjs
CHANGED
package/dist/index19.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index32.js');
|
|
7
7
|
|
|
8
8
|
let ConfigurationResolver = class ConfigurationResolver {
|
|
9
9
|
resolve(r, o, e, n) {
|
package/dist/index19.mjs
CHANGED
package/dist/index20.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index32.js');
|
|
7
7
|
|
|
8
8
|
let DefinitionResolver = class DefinitionResolver {
|
|
9
9
|
resolve(e, r) {
|
package/dist/index20.mjs
CHANGED
package/dist/index21.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
const parameterDecoratorFactory = require('./index17.js');
|
|
6
|
-
const resolverStore = require('./
|
|
6
|
+
const resolverStore = require('./index32.js');
|
|
7
7
|
|
|
8
8
|
let DisposeResolver = class DisposeResolver {
|
|
9
9
|
resolve(e, r, s) {
|
package/dist/index21.mjs
CHANGED
package/dist/index22.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const reflection = require('./index29.js');
|
|
6
6
|
const parameterDecoratorFactory = require('./index17.js');
|
|
7
7
|
const helpers = require('./index25.js');
|
|
8
|
-
const resolverStore = require('./
|
|
8
|
+
const resolverStore = require('./index32.js');
|
|
9
9
|
|
|
10
10
|
let UseResolver = class UseResolver {
|
|
11
11
|
resolve(r, o, t) {
|
package/dist/index22.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getOwnCustomMetadata } from './index29.mjs';
|
|
2
2
|
import { ParameterDecoratorFactory } from './index17.mjs';
|
|
3
3
|
import { getParamValueKey } from './index25.mjs';
|
|
4
|
-
import { ResolverStore } from './
|
|
4
|
+
import { ResolverStore } from './index32.mjs';
|
|
5
5
|
|
|
6
6
|
let UseResolver = class UseResolver {
|
|
7
7
|
resolve(r, o, t) {
|
package/dist/index23.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const reflection = require('./index29.js');
|
|
6
6
|
const parameterDecoratorFactory = require('./index17.js');
|
|
7
7
|
const helpers = require('./index25.js');
|
|
8
|
-
const resolverStore = require('./
|
|
8
|
+
const resolverStore = require('./index32.js');
|
|
9
9
|
|
|
10
10
|
let GlobalResolver = class GlobalResolver {
|
|
11
11
|
resolve(e, r, a) {
|
package/dist/index23.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getOwnCustomMetadata } from './index29.mjs';
|
|
2
2
|
import { ParameterDecoratorFactory } from './index17.mjs';
|
|
3
3
|
import { getParamValueKey } from './index25.mjs';
|
|
4
|
-
import { ResolverStore } from './
|
|
4
|
+
import { ResolverStore } from './index32.mjs';
|
|
5
5
|
|
|
6
6
|
let GlobalResolver = class GlobalResolver {
|
|
7
7
|
resolve(e, r, a) {
|
package/dist/index24.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
const reflection = require('./index29.js');
|
|
6
6
|
const parameterDecoratorFactory = require('./index17.js');
|
|
7
7
|
const helpers = require('./index25.js');
|
|
8
|
-
const resolverStore = require('./
|
|
8
|
+
const resolverStore = require('./index32.js');
|
|
9
9
|
|
|
10
10
|
let OptionalResolver = class OptionalResolver {
|
|
11
11
|
resolve(o, t, n) {
|
package/dist/index24.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getParamTypes, getOwnCustomMetadata } from './index29.mjs';
|
|
2
2
|
import { ParameterDecoratorFactory } from './index17.mjs';
|
|
3
3
|
import { getParamValueKey } from './index25.mjs';
|
|
4
|
-
import { ResolverStore } from './
|
|
4
|
+
import { ResolverStore } from './index32.mjs';
|
|
5
5
|
|
|
6
6
|
let OptionalResolver = class OptionalResolver {
|
|
7
7
|
resolve(o, t, n) {
|
package/dist/index27.js
CHANGED
package/dist/index27.mjs
CHANGED
package/dist/index30.js
CHANGED
|
@@ -31,9 +31,15 @@ const n = {
|
|
|
31
31
|
transform: (r)=>r
|
|
32
32
|
},
|
|
33
33
|
use: {
|
|
34
|
-
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>
|
|
34
|
+
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>{
|
|
35
|
+
if (!Array.isArray(r) || r.length !== 2) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const e = r[1];
|
|
39
|
+
return typeof e !== 'undefined';
|
|
40
|
+
}),
|
|
35
41
|
throw: ()=>{
|
|
36
|
-
throw new Error(`'use' property must be an array of tuples of length 2.`);
|
|
42
|
+
throw new Error(`'use' property must be an array of tuples of length 2 with [identifier, instance | factory].`);
|
|
37
43
|
},
|
|
38
44
|
transform: (r)=>r
|
|
39
45
|
},
|
package/dist/index30.mjs
CHANGED
|
@@ -27,9 +27,15 @@ const n = {
|
|
|
27
27
|
transform: (r)=>r
|
|
28
28
|
},
|
|
29
29
|
use: {
|
|
30
|
-
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>
|
|
30
|
+
test: (r)=>typeof r === 'undefined' || Array.isArray(r) && r.every((r)=>{
|
|
31
|
+
if (!Array.isArray(r) || r.length !== 2) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const e = r[1];
|
|
35
|
+
return typeof e !== 'undefined';
|
|
36
|
+
}),
|
|
31
37
|
throw: ()=>{
|
|
32
|
-
throw new Error(`'use' property must be an array of tuples of length 2.`);
|
|
38
|
+
throw new Error(`'use' property must be an array of tuples of length 2 with [identifier, instance | factory].`);
|
|
33
39
|
},
|
|
34
40
|
transform: (r)=>r
|
|
35
41
|
},
|
package/dist/index31.js
CHANGED
|
@@ -2,27 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const eventManager = require('./index6.js');
|
|
6
|
+
|
|
7
|
+
const registerEvents = (t, n)=>{
|
|
8
|
+
const o = t.concrete !== undefined && t.concrete.prototype instanceof eventManager.EventManager;
|
|
9
|
+
if (o) {
|
|
10
|
+
const e = n;
|
|
11
|
+
const o = e.channels;
|
|
12
|
+
for (const n of t.events){
|
|
13
|
+
if (!o.has(n)) e.addChannels(n);
|
|
14
|
+
if (!t.privateContext.events.has(n)) t.privateContext.addChannels(n);
|
|
15
|
+
}
|
|
16
|
+
for (const e of t.events){
|
|
17
|
+
n.on(e, (...n)=>{
|
|
18
|
+
t.privateContext.emit(e, ...n);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
for (const e of t.events){
|
|
23
|
+
if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
|
|
13
24
|
}
|
|
14
|
-
return new r();
|
|
15
|
-
}
|
|
16
|
-
static hasResolver(e) {
|
|
17
|
-
return this.resolvers.has(e);
|
|
18
|
-
}
|
|
19
|
-
static getRegisteredTypes() {
|
|
20
|
-
return Array.from(this.resolvers.keys());
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
};
|
|
27
|
+
const unregisterEvents = (t, n)=>{
|
|
28
|
+
const o = t.concrete !== undefined && t.concrete.prototype instanceof eventManager.EventManager;
|
|
29
|
+
if (o) {
|
|
30
|
+
const e = n;
|
|
31
|
+
for (const n of t.events){
|
|
32
|
+
e.off(n);
|
|
33
|
+
}
|
|
34
|
+
e.removeChannels(...t.events);
|
|
35
|
+
t.privateContext.removeChannels(...t.events);
|
|
36
|
+
} else {
|
|
37
|
+
for (const e of t.events){
|
|
38
|
+
if (t.privateContext.events.has(e)) {
|
|
39
|
+
t.privateContext.removeChannels(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
24
42
|
}
|
|
25
|
-
}
|
|
26
|
-
ResolverStore.resolvers = new Map();
|
|
43
|
+
};
|
|
27
44
|
|
|
28
|
-
exports.
|
|
45
|
+
exports.registerEvents = registerEvents;
|
|
46
|
+
exports.unregisterEvents = unregisterEvents;
|
package/dist/index31.mjs
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { EventManager } from './index6.mjs';
|
|
2
|
+
|
|
3
|
+
const registerEvents = (t, n)=>{
|
|
4
|
+
const o = t.concrete !== undefined && t.concrete.prototype instanceof EventManager;
|
|
5
|
+
if (o) {
|
|
6
|
+
const e = n;
|
|
7
|
+
const o = e.channels;
|
|
8
|
+
for (const n of t.events){
|
|
9
|
+
if (!o.has(n)) e.addChannels(n);
|
|
10
|
+
if (!t.privateContext.events.has(n)) t.privateContext.addChannels(n);
|
|
11
|
+
}
|
|
12
|
+
for (const e of t.events){
|
|
13
|
+
n.on(e, (...n)=>{
|
|
14
|
+
t.privateContext.emit(e, ...n);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
for (const e of t.events){
|
|
19
|
+
if (!t.privateContext.events.has(e)) t.privateContext.addChannels(e);
|
|
9
20
|
}
|
|
10
|
-
return new r();
|
|
11
|
-
}
|
|
12
|
-
static hasResolver(e) {
|
|
13
|
-
return this.resolvers.has(e);
|
|
14
|
-
}
|
|
15
|
-
static getRegisteredTypes() {
|
|
16
|
-
return Array.from(this.resolvers.keys());
|
|
17
21
|
}
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
};
|
|
23
|
+
const unregisterEvents = (t, n)=>{
|
|
24
|
+
const o = t.concrete !== undefined && t.concrete.prototype instanceof EventManager;
|
|
25
|
+
if (o) {
|
|
26
|
+
const e = n;
|
|
27
|
+
for (const n of t.events){
|
|
28
|
+
e.off(n);
|
|
29
|
+
}
|
|
30
|
+
e.removeChannels(...t.events);
|
|
31
|
+
t.privateContext.removeChannels(...t.events);
|
|
32
|
+
} else {
|
|
33
|
+
for (const e of t.events){
|
|
34
|
+
if (t.privateContext.events.has(e)) {
|
|
35
|
+
t.privateContext.removeChannels(e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
20
38
|
}
|
|
21
|
-
}
|
|
22
|
-
ResolverStore.resolvers = new Map();
|
|
39
|
+
};
|
|
23
40
|
|
|
24
|
-
export {
|
|
41
|
+
export { registerEvents, unregisterEvents };
|
package/dist/index32.js
CHANGED
|
@@ -2,68 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.privateContext = e;
|
|
14
|
-
this.publicContext = t;
|
|
15
|
-
}
|
|
16
|
-
register(r, n = false) {
|
|
17
|
-
const o = n === true ? use.resolveInstanceInjectionTuple(r) : inject.resolveInjectionTuple(r);
|
|
18
|
-
if (this.has(o.identifier)) {
|
|
19
|
-
throw new Error(`An assemblage is already registered with identifier '${o.identifier.name}'.`);
|
|
20
|
-
}
|
|
21
|
-
const a = injectable.Injectable.of(o, this.privateContext, this.publicContext);
|
|
22
|
-
this.injectables.set(a.identifier, a);
|
|
23
|
-
hookManager.HookManager.callHook(a.concrete, 'onRegister', this.publicContext, a.configuration);
|
|
24
|
-
return a;
|
|
25
|
-
}
|
|
26
|
-
has(e) {
|
|
27
|
-
return this.injectables.has(e);
|
|
28
|
-
}
|
|
29
|
-
require(e, t) {
|
|
30
|
-
if (!this.injectables.has(e)) {
|
|
31
|
-
throw new Error(`Class with identifier '${e.name}' has not been registered or is a circular dependency.`);
|
|
5
|
+
class ResolverStore {
|
|
6
|
+
static register(e, r) {
|
|
7
|
+
this.resolvers.set(e, r);
|
|
8
|
+
}
|
|
9
|
+
static getResolver(e) {
|
|
10
|
+
const r = this.resolvers.get(e);
|
|
11
|
+
if (!r) {
|
|
12
|
+
throw new Error(`No resolver found for decorator type: ${e}`);
|
|
32
13
|
}
|
|
33
|
-
|
|
34
|
-
if (i.isSingleton) {
|
|
35
|
-
return this.singletonStrategy.resolve(i, t);
|
|
36
|
-
} else {
|
|
37
|
-
return this.transientStrategy.resolve(i, t);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
concrete(e) {
|
|
41
|
-
const t = this.injectables.get(e);
|
|
42
|
-
if (t) return t.concrete;
|
|
43
|
-
return;
|
|
14
|
+
return new r();
|
|
44
15
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
for (const i of e){
|
|
48
|
-
for (const [e, s] of this.injectables){
|
|
49
|
-
if (s.tags.includes(i)) t.push(s.build());
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return t;
|
|
53
|
-
}
|
|
54
|
-
dispose() {
|
|
55
|
-
for (const [e, t] of this.injectables){
|
|
56
|
-
t.dispose();
|
|
57
|
-
}
|
|
16
|
+
static hasResolver(e) {
|
|
17
|
+
return this.resolvers.has(e);
|
|
58
18
|
}
|
|
59
|
-
|
|
60
|
-
return this.
|
|
19
|
+
static getRegisteredTypes() {
|
|
20
|
+
return Array.from(this.resolvers.keys());
|
|
61
21
|
}
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
65
|
-
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
22
|
+
static clear() {
|
|
23
|
+
this.resolvers.clear();
|
|
66
24
|
}
|
|
67
25
|
}
|
|
26
|
+
ResolverStore.resolvers = new Map();
|
|
68
27
|
|
|
69
|
-
exports.
|
|
28
|
+
exports.ResolverStore = ResolverStore;
|
package/dist/index32.mjs
CHANGED
|
@@ -1,65 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.privateContext = e;
|
|
10
|
-
this.publicContext = t;
|
|
11
|
-
}
|
|
12
|
-
register(r, n = false) {
|
|
13
|
-
const o = n === true ? resolveInstanceInjectionTuple(r) : resolveInjectionTuple(r);
|
|
14
|
-
if (this.has(o.identifier)) {
|
|
15
|
-
throw new Error(`An assemblage is already registered with identifier '${o.identifier.name}'.`);
|
|
16
|
-
}
|
|
17
|
-
const a = Injectable.of(o, this.privateContext, this.publicContext);
|
|
18
|
-
this.injectables.set(a.identifier, a);
|
|
19
|
-
HookManager.callHook(a.concrete, 'onRegister', this.publicContext, a.configuration);
|
|
20
|
-
return a;
|
|
21
|
-
}
|
|
22
|
-
has(e) {
|
|
23
|
-
return this.injectables.has(e);
|
|
24
|
-
}
|
|
25
|
-
require(e, t) {
|
|
26
|
-
if (!this.injectables.has(e)) {
|
|
27
|
-
throw new Error(`Class with identifier '${e.name}' has not been registered or is a circular dependency.`);
|
|
1
|
+
class ResolverStore {
|
|
2
|
+
static register(e, r) {
|
|
3
|
+
this.resolvers.set(e, r);
|
|
4
|
+
}
|
|
5
|
+
static getResolver(e) {
|
|
6
|
+
const r = this.resolvers.get(e);
|
|
7
|
+
if (!r) {
|
|
8
|
+
throw new Error(`No resolver found for decorator type: ${e}`);
|
|
28
9
|
}
|
|
29
|
-
|
|
30
|
-
if (i.isSingleton) {
|
|
31
|
-
return this.singletonStrategy.resolve(i, t);
|
|
32
|
-
} else {
|
|
33
|
-
return this.transientStrategy.resolve(i, t);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
concrete(e) {
|
|
37
|
-
const t = this.injectables.get(e);
|
|
38
|
-
if (t) return t.concrete;
|
|
39
|
-
return;
|
|
10
|
+
return new r();
|
|
40
11
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
for (const i of e){
|
|
44
|
-
for (const [e, s] of this.injectables){
|
|
45
|
-
if (s.tags.includes(i)) t.push(s.build());
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return t;
|
|
49
|
-
}
|
|
50
|
-
dispose() {
|
|
51
|
-
for (const [e, t] of this.injectables){
|
|
52
|
-
t.dispose();
|
|
53
|
-
}
|
|
12
|
+
static hasResolver(e) {
|
|
13
|
+
return this.resolvers.has(e);
|
|
54
14
|
}
|
|
55
|
-
|
|
56
|
-
return this.
|
|
15
|
+
static getRegisteredTypes() {
|
|
16
|
+
return Array.from(this.resolvers.keys());
|
|
57
17
|
}
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
this.singletonStrategy = new SingletonStrategy();
|
|
61
|
-
this.transientStrategy = new TransientStrategy();
|
|
18
|
+
static clear() {
|
|
19
|
+
this.resolvers.clear();
|
|
62
20
|
}
|
|
63
21
|
}
|
|
22
|
+
ResolverStore.resolvers = new Map();
|
|
64
23
|
|
|
65
|
-
export {
|
|
24
|
+
export { ResolverStore };
|