assemblerjs 1.0.1 → 1.1.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/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 +53 -55
- package/dist/index29.mjs +53 -55
- package/dist/index3.js +2 -2
- package/dist/index3.mjs +2 -2
- package/dist/index30.js +28 -28
- package/dist/index30.mjs +28 -28
- package/dist/index31.js +62 -28
- package/dist/index31.mjs +62 -28
- package/dist/index32.js +28 -19
- package/dist/index32.mjs +28 -19
- package/dist/index33.js +32 -49
- package/dist/index33.mjs +32 -49
- package/dist/index34.js +17 -8
- package/dist/index34.mjs +14 -8
- package/dist/index35.js +18 -24
- package/dist/index35.mjs +18 -23
- package/dist/index36.js +37 -108
- package/dist/index36.mjs +36 -108
- package/dist/index37.js +98 -10
- package/dist/index37.mjs +96 -10
- package/dist/index38.js +95 -20
- package/dist/index38.mjs +95 -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 +34 -0
- package/dist/index40.mjs +29 -0
- package/dist/index41.js +14 -0
- package/dist/index41.mjs +10 -0
- package/dist/index42.js +54 -0
- package/dist/index42.mjs +50 -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 +2 -2
package/dist/index28.mjs
CHANGED
|
@@ -1,33 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
}
|
|
1
|
+
const ReflectParamTypes = 'design:paramtypes';
|
|
2
|
+
const ReflectPrefix = '__';
|
|
3
|
+
const ReflectSuffix = '__';
|
|
4
|
+
var ReflectFlags;
|
|
5
|
+
(function(e) {
|
|
6
|
+
e["IsAssemblage"] = "is_assemblage";
|
|
7
|
+
})(ReflectFlags || (ReflectFlags = {}));
|
|
8
|
+
var ReflectValue;
|
|
9
|
+
(function(e) {
|
|
10
|
+
e["AssemblageDefinition"] = "assemblage:definition.value";
|
|
11
|
+
e["AssemblageContext"] = "assemblage:context.value";
|
|
12
|
+
e["TransversalAdvices"] = "transversal:advices";
|
|
13
|
+
e["AffectedMethods"] = "method:applied-aspects";
|
|
14
|
+
})(ReflectValue || (ReflectValue = {}));
|
|
32
15
|
|
|
33
|
-
export {
|
|
16
|
+
export { ReflectFlags, ReflectParamTypes, ReflectPrefix, ReflectSuffix, ReflectValue };
|
package/dist/index29.js
CHANGED
|
@@ -2,70 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const hookManager = require('./index31.js');
|
|
6
|
+
const resolutionStrategies = require('./index40.js');
|
|
7
|
+
const use = require('./index41.js');
|
|
8
|
+
const inject = require('./index42.js');
|
|
9
|
+
const injectable = require('./index43.js');
|
|
6
10
|
|
|
7
|
-
class
|
|
8
|
-
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
configuration: t
|
|
12
|
-
});
|
|
13
|
-
return this.initCache;
|
|
11
|
+
class InjectableManager {
|
|
12
|
+
setContexts(e, t) {
|
|
13
|
+
this.privateContext = e;
|
|
14
|
+
this.publicContext = t;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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}'.`);
|
|
18
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;
|
|
19
25
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
...this.initCache
|
|
23
|
-
].reverse()){
|
|
24
|
-
HookManager.callHookImmediate(t.instance, 'onInited', e, t.configuration);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
clearCache() {
|
|
28
|
-
this.initCache.length = 0;
|
|
26
|
+
has(e) {
|
|
27
|
+
return this.injectables.has(e);
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
|
|
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.`);
|
|
32
|
+
}
|
|
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
|
+
}
|
|
32
39
|
}
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
concrete(e) {
|
|
41
|
+
const t = this.injectables.get(e);
|
|
42
|
+
if (t) return t.concrete;
|
|
43
|
+
return;
|
|
35
44
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (core.isAsync(r)) {
|
|
42
|
-
r.bind(t)(o, n).then(()=>{
|
|
43
|
-
a();
|
|
44
|
-
}).catch((e)=>{
|
|
45
|
-
c(e);
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
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());
|
|
48
50
|
}
|
|
49
|
-
try {
|
|
50
|
-
r.bind(t)(o, n);
|
|
51
|
-
a();
|
|
52
|
-
} catch (e) {
|
|
53
|
-
c(e);
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
a();
|
|
57
51
|
}
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (core.isAsync(a)) {
|
|
64
|
-
a.bind(t)(o, n).catch(()=>{});
|
|
65
|
-
return;
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
dispose() {
|
|
55
|
+
for (const [e, t] of this.injectables){
|
|
56
|
+
t.dispose();
|
|
66
57
|
}
|
|
67
|
-
a.bind(t)(o, n);
|
|
68
58
|
}
|
|
69
|
-
|
|
59
|
+
get size() {
|
|
60
|
+
return this.injectables.size;
|
|
61
|
+
}
|
|
62
|
+
constructor(){
|
|
63
|
+
this.injectables = new Map();
|
|
64
|
+
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
65
|
+
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
70
68
|
|
|
71
|
-
exports.
|
|
69
|
+
exports.InjectableManager = InjectableManager;
|
package/dist/index29.mjs
CHANGED
|
@@ -1,67 +1,65 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HookManager } from './index31.mjs';
|
|
2
|
+
import { SingletonStrategy, TransientStrategy } from './index40.mjs';
|
|
3
|
+
import { resolveInstanceInjectionTuple } from './index41.mjs';
|
|
4
|
+
import { resolveInjectionTuple } from './index42.mjs';
|
|
5
|
+
import { Injectable } from './index43.mjs';
|
|
2
6
|
|
|
3
|
-
class
|
|
4
|
-
|
|
5
|
-
this.
|
|
6
|
-
|
|
7
|
-
configuration: t
|
|
8
|
-
});
|
|
9
|
-
return this.initCache;
|
|
7
|
+
class InjectableManager {
|
|
8
|
+
setContexts(e, t) {
|
|
9
|
+
this.privateContext = e;
|
|
10
|
+
this.publicContext = t;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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}'.`);
|
|
14
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;
|
|
15
21
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...this.initCache
|
|
19
|
-
].reverse()){
|
|
20
|
-
HookManager.callHookImmediate(t.instance, 'onInited', e, t.configuration);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
clearCache() {
|
|
24
|
-
this.initCache.length = 0;
|
|
22
|
+
has(e) {
|
|
23
|
+
return this.injectables.has(e);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
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.`);
|
|
28
|
+
}
|
|
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
|
+
}
|
|
28
35
|
}
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
concrete(e) {
|
|
37
|
+
const t = this.injectables.get(e);
|
|
38
|
+
if (t) return t.concrete;
|
|
39
|
+
return;
|
|
31
40
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (isAsync(r)) {
|
|
38
|
-
r.bind(t)(o, n).then(()=>{
|
|
39
|
-
a();
|
|
40
|
-
}).catch((e)=>{
|
|
41
|
-
c(e);
|
|
42
|
-
});
|
|
43
|
-
return;
|
|
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());
|
|
44
46
|
}
|
|
45
|
-
try {
|
|
46
|
-
r.bind(t)(o, n);
|
|
47
|
-
a();
|
|
48
|
-
} catch (e) {
|
|
49
|
-
c(e);
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
a();
|
|
53
47
|
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (isAsync(a)) {
|
|
60
|
-
a.bind(t)(o, n).catch(()=>{});
|
|
61
|
-
return;
|
|
48
|
+
return t;
|
|
49
|
+
}
|
|
50
|
+
dispose() {
|
|
51
|
+
for (const [e, t] of this.injectables){
|
|
52
|
+
t.dispose();
|
|
62
53
|
}
|
|
63
|
-
a.bind(t)(o, n);
|
|
64
54
|
}
|
|
65
|
-
|
|
55
|
+
get size() {
|
|
56
|
+
return this.injectables.size;
|
|
57
|
+
}
|
|
58
|
+
constructor(){
|
|
59
|
+
this.injectables = new Map();
|
|
60
|
+
this.singletonStrategy = new SingletonStrategy();
|
|
61
|
+
this.transientStrategy = new TransientStrategy();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
66
64
|
|
|
67
|
-
export {
|
|
65
|
+
export { InjectableManager };
|
package/dist/index3.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const constants = require('./
|
|
6
|
-
const reflection = require('./
|
|
5
|
+
const constants = require('./index28.js');
|
|
6
|
+
const reflection = require('./index34.js');
|
|
7
7
|
|
|
8
8
|
const isAssemblage = (s)=>{
|
|
9
9
|
return reflection.getOwnCustomMetadata(constants.ReflectFlags.IsAssemblage, s) || false;
|
package/dist/index3.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReflectFlags, ReflectValue } from './
|
|
2
|
-
import { getOwnCustomMetadata } from './
|
|
1
|
+
import { ReflectFlags, ReflectValue } from './index28.mjs';
|
|
2
|
+
import { getOwnCustomMetadata } from './index34.mjs';
|
|
3
3
|
|
|
4
4
|
const isAssemblage = (s)=>{
|
|
5
5
|
return getOwnCustomMetadata(ReflectFlags.IsAssemblage, s) || false;
|
package/dist/index30.js
CHANGED
|
@@ -2,36 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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.`);
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.assembler.hookManager.clearCache();
|
|
30
|
-
return r;
|
|
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);
|
|
31
30
|
}
|
|
32
|
-
constructor(
|
|
33
|
-
this.
|
|
31
|
+
constructor(){
|
|
32
|
+
this.objects = new Map();
|
|
33
|
+
this.globals = new Map();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
exports.
|
|
37
|
+
exports.ObjectManager = ObjectManager;
|
package/dist/index30.mjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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.`);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.assembler.hookManager.clearCache();
|
|
26
|
-
return r;
|
|
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);
|
|
27
26
|
}
|
|
28
|
-
constructor(
|
|
29
|
-
this.
|
|
27
|
+
constructor(){
|
|
28
|
+
this.objects = new Map();
|
|
29
|
+
this.globals = new Map();
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export {
|
|
33
|
+
export { ObjectManager };
|
package/dist/index31.js
CHANGED
|
@@ -2,36 +2,70 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
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
|
+
}
|
|
19
26
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
...s,
|
|
23
|
-
register: this.assembler.register.bind(this.assembler),
|
|
24
|
-
use: this.assembler.use.bind(this.assembler),
|
|
25
|
-
addGlobal: this.assembler.addGlobal.bind(this.assembler),
|
|
26
|
-
prepareInitHook: this.assembler.prepareInitHook.bind(this.assembler),
|
|
27
|
-
emit: this.assembler.emit.bind(this.assembler),
|
|
28
|
-
addChannels: this.assembler.addChannels.bind(this.assembler),
|
|
29
|
-
removeChannels: this.assembler.removeChannels.bind(this.assembler)
|
|
30
|
-
};
|
|
27
|
+
clearCache() {
|
|
28
|
+
this.initCache.length = 0;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
this.
|
|
30
|
+
getCache() {
|
|
31
|
+
return this.initCache;
|
|
32
|
+
}
|
|
33
|
+
constructor(){
|
|
34
|
+
this.initCache = [];
|
|
34
35
|
}
|
|
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
|
+
}
|
|
69
|
+
};
|
|
36
70
|
|
|
37
|
-
exports.
|
|
71
|
+
exports.HookManager = HookManager;
|
package/dist/index31.mjs
CHANGED
|
@@ -1,33 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
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
|
+
}
|
|
15
22
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...s,
|
|
19
|
-
register: this.assembler.register.bind(this.assembler),
|
|
20
|
-
use: this.assembler.use.bind(this.assembler),
|
|
21
|
-
addGlobal: this.assembler.addGlobal.bind(this.assembler),
|
|
22
|
-
prepareInitHook: this.assembler.prepareInitHook.bind(this.assembler),
|
|
23
|
-
emit: this.assembler.emit.bind(this.assembler),
|
|
24
|
-
addChannels: this.assembler.addChannels.bind(this.assembler),
|
|
25
|
-
removeChannels: this.assembler.removeChannels.bind(this.assembler)
|
|
26
|
-
};
|
|
23
|
+
clearCache() {
|
|
24
|
+
this.initCache.length = 0;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
this.
|
|
26
|
+
getCache() {
|
|
27
|
+
return this.initCache;
|
|
28
|
+
}
|
|
29
|
+
constructor(){
|
|
30
|
+
this.initCache = [];
|
|
30
31
|
}
|
|
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
|
+
}
|
|
65
|
+
};
|
|
32
66
|
|
|
33
|
-
export {
|
|
67
|
+
export { HookManager };
|