assemblerjs 1.0.1 → 1.1.1
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 +8 -5
- package/dist/index.d.ts +430 -9
- package/dist/index.js +24 -12
- package/dist/index.mjs +16 -12
- package/dist/index11.js +82 -20
- package/dist/index11.mjs +78 -20
- package/dist/index12.js +17 -8
- package/dist/index12.mjs +16 -8
- package/dist/index13.js +148 -73
- package/dist/index13.mjs +148 -73
- package/dist/index14.js +4 -17
- package/dist/index14.mjs +4 -17
- package/dist/index15.js +21 -16
- package/dist/index15.mjs +21 -16
- package/dist/index16.js +10 -16
- package/dist/index16.mjs +10 -16
- package/dist/index17.js +88 -16
- package/dist/index17.mjs +88 -16
- package/dist/index18.js +11 -20
- package/dist/index18.mjs +11 -19
- package/dist/index19.js +11 -20
- package/dist/index19.mjs +11 -19
- package/dist/index2.js +3 -3
- package/dist/index2.mjs +3 -3
- package/dist/index20.js +11 -20
- package/dist/index20.mjs +11 -20
- package/dist/index21.js +14 -25
- package/dist/index21.mjs +14 -21
- package/dist/index22.js +24 -46
- package/dist/index22.mjs +23 -45
- package/dist/index23.js +22 -37
- package/dist/index23.mjs +21 -36
- package/dist/index24.js +26 -15
- package/dist/index24.mjs +26 -13
- package/dist/index25.js +24 -10
- package/dist/index25.mjs +20 -8
- package/dist/index26.js +45 -92
- package/dist/index26.mjs +44 -90
- package/dist/index27.js +2 -66
- package/dist/index27.mjs +2 -64
- package/dist/index28.js +17 -32
- package/dist/index28.mjs +15 -32
- package/dist/index29.js +15 -63
- package/dist/index29.mjs +12 -63
- package/dist/index3.js +2 -2
- package/dist/index3.mjs +2 -2
- package/dist/index30.js +98 -28
- package/dist/index30.mjs +96 -28
- package/dist/index31.js +19 -28
- package/dist/index31.mjs +19 -28
- package/dist/index32.js +58 -17
- package/dist/index32.mjs +58 -17
- package/dist/index33.js +32 -49
- package/dist/index33.mjs +32 -49
- package/dist/index34.js +65 -8
- package/dist/index34.mjs +65 -8
- package/dist/index35.js +28 -25
- package/dist/index35.mjs +28 -24
- package/dist/index36.js +30 -110
- package/dist/index36.mjs +30 -110
- package/dist/index37.js +38 -11
- package/dist/index37.mjs +37 -11
- package/dist/index38.js +100 -20
- package/dist/index38.mjs +100 -20
- package/dist/index39.js +23 -44
- package/dist/index39.mjs +23 -43
- package/dist/index4.js +5 -5
- package/dist/index4.mjs +5 -5
- package/dist/index40.js +54 -0
- package/dist/index40.mjs +50 -0
- package/dist/index41.js +14 -0
- package/dist/index41.mjs +10 -0
- package/dist/index42.js +34 -0
- package/dist/index42.mjs +29 -0
- package/dist/index43.js +177 -0
- package/dist/index43.mjs +173 -0
- package/dist/index44.js +947 -0
- package/dist/index44.mjs +943 -0
- package/dist/index45.js +7 -0
- package/dist/index45.mjs +3 -0
- package/dist/index46.js +7 -0
- package/dist/index46.mjs +3 -0
- package/dist/index47.js +19 -0
- package/dist/index47.mjs +15 -0
- package/dist/index48.js +33 -0
- package/dist/index48.mjs +29 -0
- package/dist/index49.js +67 -0
- package/dist/index49.mjs +62 -0
- package/package.json +1 -5
package/dist/index32.js
CHANGED
|
@@ -2,27 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const hookManager = require('./index34.js');
|
|
6
|
+
const resolutionStrategies = require('./index42.js');
|
|
7
|
+
const use = require('./index41.js');
|
|
8
|
+
const inject = require('./index40.js');
|
|
9
|
+
const injectable = require('./index43.js');
|
|
10
|
+
|
|
11
|
+
class InjectableManager {
|
|
12
|
+
setContexts(e, t) {
|
|
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.`);
|
|
13
32
|
}
|
|
14
|
-
|
|
33
|
+
const i = this.injectables.get(e);
|
|
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;
|
|
15
44
|
}
|
|
16
|
-
|
|
17
|
-
|
|
45
|
+
tagged(...e) {
|
|
46
|
+
const t = [];
|
|
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
|
+
}
|
|
18
58
|
}
|
|
19
|
-
|
|
20
|
-
return
|
|
59
|
+
get size() {
|
|
60
|
+
return this.injectables.size;
|
|
21
61
|
}
|
|
22
|
-
|
|
23
|
-
this.
|
|
62
|
+
constructor(){
|
|
63
|
+
this.injectables = new Map();
|
|
64
|
+
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
65
|
+
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
24
66
|
}
|
|
25
67
|
}
|
|
26
|
-
ResolverStore.resolvers = new Map();
|
|
27
68
|
|
|
28
|
-
exports.
|
|
69
|
+
exports.InjectableManager = InjectableManager;
|
package/dist/index32.mjs
CHANGED
|
@@ -1,24 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { HookManager } from './index34.mjs';
|
|
2
|
+
import { SingletonStrategy, TransientStrategy } from './index42.mjs';
|
|
3
|
+
import { resolveInstanceInjectionTuple } from './index41.mjs';
|
|
4
|
+
import { resolveInjectionTuple } from './index40.mjs';
|
|
5
|
+
import { Injectable } from './index43.mjs';
|
|
6
|
+
|
|
7
|
+
class InjectableManager {
|
|
8
|
+
setContexts(e, t) {
|
|
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.`);
|
|
9
28
|
}
|
|
10
|
-
|
|
29
|
+
const i = this.injectables.get(e);
|
|
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;
|
|
11
40
|
}
|
|
12
|
-
|
|
13
|
-
|
|
41
|
+
tagged(...e) {
|
|
42
|
+
const t = [];
|
|
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
|
+
}
|
|
14
54
|
}
|
|
15
|
-
|
|
16
|
-
return
|
|
55
|
+
get size() {
|
|
56
|
+
return this.injectables.size;
|
|
17
57
|
}
|
|
18
|
-
|
|
19
|
-
this.
|
|
58
|
+
constructor(){
|
|
59
|
+
this.injectables = new Map();
|
|
60
|
+
this.singletonStrategy = new SingletonStrategy();
|
|
61
|
+
this.transientStrategy = new TransientStrategy();
|
|
20
62
|
}
|
|
21
63
|
}
|
|
22
|
-
ResolverStore.resolvers = new Map();
|
|
23
64
|
|
|
24
|
-
export {
|
|
65
|
+
export { InjectableManager };
|
package/dist/index33.js
CHANGED
|
@@ -2,53 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
class ObjectManager {
|
|
6
|
+
use(e, t) {
|
|
7
|
+
if (this.has(e)) {
|
|
8
|
+
throw new Error(`A value is already registered with identifier '${String(e)}'.`);
|
|
9
|
+
}
|
|
10
|
+
this.objects.set(e, t);
|
|
11
|
+
return t;
|
|
12
|
+
}
|
|
13
|
+
has(e) {
|
|
14
|
+
return this.objects.has(e);
|
|
15
|
+
}
|
|
16
|
+
require(e) {
|
|
17
|
+
if (!this.objects.has(e)) {
|
|
18
|
+
throw new Error(`Injected object with identifier '${String(e)}' has not been registered.`);
|
|
19
|
+
}
|
|
20
|
+
return this.objects.get(e);
|
|
21
|
+
}
|
|
22
|
+
addGlobal(e, t) {
|
|
23
|
+
if (this.globals.has(e)) {
|
|
24
|
+
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
25
|
+
}
|
|
26
|
+
this.globals.set(e, t);
|
|
27
|
+
}
|
|
28
|
+
global(e) {
|
|
29
|
+
return this.globals.get(e);
|
|
30
|
+
}
|
|
31
|
+
constructor(){
|
|
32
|
+
this.objects = new Map();
|
|
33
|
+
this.globals = new Map();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
6
36
|
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
identifier: e[0],
|
|
10
|
-
concrete: e[0],
|
|
11
|
-
configuration: {}
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
const c = (o)=>{
|
|
15
|
-
const i = ()=>core.isClass(o[0]) && core.isClass(o[1]);
|
|
16
|
-
const c = ()=>core.isClass(o[0]) && core.isObject(o[1]);
|
|
17
|
-
const s = ()=>core.pipe(core.conditionally({
|
|
18
|
-
if: ()=>i(),
|
|
19
|
-
then: ()=>{
|
|
20
|
-
return {
|
|
21
|
-
identifier: o[0],
|
|
22
|
-
concrete: o[1],
|
|
23
|
-
configuration: {}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}), core.conditionally({
|
|
27
|
-
if: ()=>c(),
|
|
28
|
-
then: ()=>{
|
|
29
|
-
return {
|
|
30
|
-
identifier: o[0],
|
|
31
|
-
concrete: o[0],
|
|
32
|
-
configuration: o[1]
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
else: (e)=>e
|
|
36
|
-
}))();
|
|
37
|
-
return s();
|
|
38
|
-
};
|
|
39
|
-
const s = (e)=>{
|
|
40
|
-
return {
|
|
41
|
-
identifier: e[0],
|
|
42
|
-
concrete: e[1],
|
|
43
|
-
configuration: e[2]
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
const resolveInjectionTuple = (e)=>core.switchCase({
|
|
47
|
-
1: ()=>i(e),
|
|
48
|
-
2: ()=>c(e),
|
|
49
|
-
3: ()=>s(e)
|
|
50
|
-
}, ()=>{
|
|
51
|
-
throw new Error(`Injection tuple must be of length 1, 2 or 3.`);
|
|
52
|
-
})(e.length);
|
|
53
|
-
|
|
54
|
-
exports.resolveInjectionTuple = resolveInjectionTuple;
|
|
37
|
+
exports.ObjectManager = ObjectManager;
|
package/dist/index33.mjs
CHANGED
|
@@ -1,50 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
class ObjectManager {
|
|
2
|
+
use(e, t) {
|
|
3
|
+
if (this.has(e)) {
|
|
4
|
+
throw new Error(`A value is already registered with identifier '${String(e)}'.`);
|
|
5
|
+
}
|
|
6
|
+
this.objects.set(e, t);
|
|
7
|
+
return t;
|
|
8
|
+
}
|
|
9
|
+
has(e) {
|
|
10
|
+
return this.objects.has(e);
|
|
11
|
+
}
|
|
12
|
+
require(e) {
|
|
13
|
+
if (!this.objects.has(e)) {
|
|
14
|
+
throw new Error(`Injected object with identifier '${String(e)}' has not been registered.`);
|
|
15
|
+
}
|
|
16
|
+
return this.objects.get(e);
|
|
17
|
+
}
|
|
18
|
+
addGlobal(e, t) {
|
|
19
|
+
if (this.globals.has(e)) {
|
|
20
|
+
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
21
|
+
}
|
|
22
|
+
this.globals.set(e, t);
|
|
23
|
+
}
|
|
24
|
+
global(e) {
|
|
25
|
+
return this.globals.get(e);
|
|
26
|
+
}
|
|
27
|
+
constructor(){
|
|
28
|
+
this.objects = new Map();
|
|
29
|
+
this.globals = new Map();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
2
32
|
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
identifier: e[0],
|
|
6
|
-
concrete: e[0],
|
|
7
|
-
configuration: {}
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
const c = (o)=>{
|
|
11
|
-
const i = ()=>isClass(o[0]) && isClass(o[1]);
|
|
12
|
-
const c = ()=>isClass(o[0]) && isObject(o[1]);
|
|
13
|
-
const s = ()=>pipe(conditionally({
|
|
14
|
-
if: ()=>i(),
|
|
15
|
-
then: ()=>{
|
|
16
|
-
return {
|
|
17
|
-
identifier: o[0],
|
|
18
|
-
concrete: o[1],
|
|
19
|
-
configuration: {}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}), conditionally({
|
|
23
|
-
if: ()=>c(),
|
|
24
|
-
then: ()=>{
|
|
25
|
-
return {
|
|
26
|
-
identifier: o[0],
|
|
27
|
-
concrete: o[0],
|
|
28
|
-
configuration: o[1]
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
else: (e)=>e
|
|
32
|
-
}))();
|
|
33
|
-
return s();
|
|
34
|
-
};
|
|
35
|
-
const s = (e)=>{
|
|
36
|
-
return {
|
|
37
|
-
identifier: e[0],
|
|
38
|
-
concrete: e[1],
|
|
39
|
-
configuration: e[2]
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
const resolveInjectionTuple = (e)=>switchCase({
|
|
43
|
-
1: ()=>i(e),
|
|
44
|
-
2: ()=>c(e),
|
|
45
|
-
3: ()=>s(e)
|
|
46
|
-
}, ()=>{
|
|
47
|
-
throw new Error(`Injection tuple must be of length 1, 2 or 3.`);
|
|
48
|
-
})(e.length);
|
|
49
|
-
|
|
50
|
-
export { resolveInjectionTuple };
|
|
33
|
+
export { ObjectManager };
|
package/dist/index34.js
CHANGED
|
@@ -2,13 +2,70 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
6
|
+
|
|
7
|
+
class HookManager {
|
|
8
|
+
prepareInitHook(e, t) {
|
|
9
|
+
this.initCache.push({
|
|
10
|
+
instance: e,
|
|
11
|
+
configuration: t
|
|
12
|
+
});
|
|
13
|
+
return this.initCache;
|
|
14
|
+
}
|
|
15
|
+
callInitHooks(e) {
|
|
16
|
+
for (const t of this.initCache){
|
|
17
|
+
HookManager.callHookImmediate(t.instance, 'onInit', e, t.configuration);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
callInitedHooks(e) {
|
|
21
|
+
for (const t of [
|
|
22
|
+
...this.initCache
|
|
23
|
+
].reverse()){
|
|
24
|
+
HookManager.callHookImmediate(t.instance, 'onInited', e, t.configuration);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
clearCache() {
|
|
28
|
+
this.initCache.length = 0;
|
|
29
|
+
}
|
|
30
|
+
getCache() {
|
|
31
|
+
return this.initCache;
|
|
32
|
+
}
|
|
33
|
+
constructor(){
|
|
34
|
+
this.initCache = [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
HookManager.callHook = (t, i, o, n)=>{
|
|
38
|
+
return new Promise((a, c)=>{
|
|
39
|
+
const r = t[i];
|
|
40
|
+
if (r) {
|
|
41
|
+
if (core.isAsync(r)) {
|
|
42
|
+
r.bind(t)(o, n).then(()=>{
|
|
43
|
+
a();
|
|
44
|
+
}).catch((e)=>{
|
|
45
|
+
c(e);
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
r.bind(t)(o, n);
|
|
51
|
+
a();
|
|
52
|
+
} catch (e) {
|
|
53
|
+
c(e);
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
a();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
HookManager.callHookImmediate = (t, i, o, n)=>{
|
|
61
|
+
const a = t[i];
|
|
62
|
+
if (a) {
|
|
63
|
+
if (core.isAsync(a)) {
|
|
64
|
+
a.bind(t)(o, n).catch(()=>{});
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
a.bind(t)(o, n);
|
|
68
|
+
}
|
|
12
69
|
};
|
|
13
70
|
|
|
14
|
-
exports.
|
|
71
|
+
exports.HookManager = HookManager;
|
package/dist/index34.mjs
CHANGED
|
@@ -1,10 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { isAsync } from '@assemblerjs/core';
|
|
2
|
+
|
|
3
|
+
class HookManager {
|
|
4
|
+
prepareInitHook(e, t) {
|
|
5
|
+
this.initCache.push({
|
|
6
|
+
instance: e,
|
|
7
|
+
configuration: t
|
|
8
|
+
});
|
|
9
|
+
return this.initCache;
|
|
10
|
+
}
|
|
11
|
+
callInitHooks(e) {
|
|
12
|
+
for (const t of this.initCache){
|
|
13
|
+
HookManager.callHookImmediate(t.instance, 'onInit', e, t.configuration);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
callInitedHooks(e) {
|
|
17
|
+
for (const t of [
|
|
18
|
+
...this.initCache
|
|
19
|
+
].reverse()){
|
|
20
|
+
HookManager.callHookImmediate(t.instance, 'onInited', e, t.configuration);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
clearCache() {
|
|
24
|
+
this.initCache.length = 0;
|
|
25
|
+
}
|
|
26
|
+
getCache() {
|
|
27
|
+
return this.initCache;
|
|
28
|
+
}
|
|
29
|
+
constructor(){
|
|
30
|
+
this.initCache = [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
HookManager.callHook = (t, i, o, n)=>{
|
|
34
|
+
return new Promise((a, c)=>{
|
|
35
|
+
const r = t[i];
|
|
36
|
+
if (r) {
|
|
37
|
+
if (isAsync(r)) {
|
|
38
|
+
r.bind(t)(o, n).then(()=>{
|
|
39
|
+
a();
|
|
40
|
+
}).catch((e)=>{
|
|
41
|
+
c(e);
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
r.bind(t)(o, n);
|
|
47
|
+
a();
|
|
48
|
+
} catch (e) {
|
|
49
|
+
c(e);
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
a();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
HookManager.callHookImmediate = (t, i, o, n)=>{
|
|
57
|
+
const a = t[i];
|
|
58
|
+
if (a) {
|
|
59
|
+
if (isAsync(a)) {
|
|
60
|
+
a.bind(t)(o, n).catch(()=>{});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
a.bind(t)(o, n);
|
|
64
|
+
}
|
|
8
65
|
};
|
|
9
66
|
|
|
10
|
-
export {
|
|
67
|
+
export { HookManager };
|
package/dist/index35.js
CHANGED
|
@@ -2,33 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const hookManager = require('./index34.js');
|
|
6
|
+
const schema = require('./index30.js');
|
|
7
|
+
|
|
8
|
+
class AssemblerBuilder {
|
|
9
|
+
build(t, o) {
|
|
10
|
+
schema.setDefinitionValue('singleton', true, t);
|
|
11
|
+
const a = this.assembler.register([
|
|
12
|
+
t
|
|
13
|
+
]);
|
|
14
|
+
const r = this.assembler.require(a.identifier, o);
|
|
15
|
+
const i = this.assembler.hookManager.getCache().find((e)=>e.instance === r);
|
|
16
|
+
if (!i) {
|
|
17
|
+
throw new Error('Root instance not found in assemblages cache.');
|
|
10
18
|
}
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const n = this.assembler.hookManager.getCache().indexOf(i);
|
|
20
|
+
this.assembler.hookManager.getCache().splice(n, 1);
|
|
21
|
+
this.assembler.hookManager.callInitHooks(this.assembler.publicContext);
|
|
22
|
+
const l = o ? {
|
|
23
|
+
...a.configuration,
|
|
24
|
+
...o
|
|
25
|
+
} : a.configuration;
|
|
26
|
+
hookManager.HookManager.callHookImmediate(r, 'onInit', this.assembler.publicContext, l);
|
|
27
|
+
this.assembler.hookManager.callInitedHooks(this.assembler.publicContext);
|
|
28
|
+
hookManager.HookManager.callHookImmediate(r, 'onInited', this.assembler.publicContext, l);
|
|
29
|
+
this.assembler.hookManager.clearCache();
|
|
30
|
+
return r;
|
|
23
31
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
resolve(t, e) {
|
|
27
|
-
const n = t.build(e);
|
|
28
|
-
t.privateContext.prepareInitHook(n, t.configuration);
|
|
29
|
-
return n;
|
|
32
|
+
constructor(e){
|
|
33
|
+
this.assembler = e;
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
exports.
|
|
34
|
-
exports.TransientStrategy = TransientStrategy;
|
|
37
|
+
exports.AssemblerBuilder = AssemblerBuilder;
|
package/dist/index35.mjs
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { HookManager } from './index34.mjs';
|
|
2
|
+
import { setDefinitionValue } from './index30.mjs';
|
|
3
|
+
|
|
4
|
+
class AssemblerBuilder {
|
|
5
|
+
build(t, o) {
|
|
6
|
+
setDefinitionValue('singleton', true, t);
|
|
7
|
+
const a = this.assembler.register([
|
|
8
|
+
t
|
|
9
|
+
]);
|
|
10
|
+
const r = this.assembler.require(a.identifier, o);
|
|
11
|
+
const i = this.assembler.hookManager.getCache().find((e)=>e.instance === r);
|
|
12
|
+
if (!i) {
|
|
13
|
+
throw new Error('Root instance not found in assemblages cache.');
|
|
6
14
|
}
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const n = this.assembler.hookManager.getCache().indexOf(i);
|
|
16
|
+
this.assembler.hookManager.getCache().splice(n, 1);
|
|
17
|
+
this.assembler.hookManager.callInitHooks(this.assembler.publicContext);
|
|
18
|
+
const l = o ? {
|
|
19
|
+
...a.configuration,
|
|
20
|
+
...o
|
|
21
|
+
} : a.configuration;
|
|
22
|
+
HookManager.callHookImmediate(r, 'onInit', this.assembler.publicContext, l);
|
|
23
|
+
this.assembler.hookManager.callInitedHooks(this.assembler.publicContext);
|
|
24
|
+
HookManager.callHookImmediate(r, 'onInited', this.assembler.publicContext, l);
|
|
25
|
+
this.assembler.hookManager.clearCache();
|
|
26
|
+
return r;
|
|
19
27
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
resolve(t, e) {
|
|
23
|
-
const n = t.build(e);
|
|
24
|
-
t.privateContext.prepareInitHook(n, t.configuration);
|
|
25
|
-
return n;
|
|
28
|
+
constructor(e){
|
|
29
|
+
this.assembler = e;
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
export {
|
|
33
|
+
export { AssemblerBuilder };
|