assemblerjs 1.1.21 → 1.1.22
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/index11.js +2 -2
- package/dist/index11.mjs +2 -2
- package/dist/index13.js +1 -1
- package/dist/index13.mjs +1 -1
- package/dist/index16.js +1 -1
- package/dist/index16.mjs +1 -1
- package/dist/index17.js +1 -1
- package/dist/index17.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/index2.js +2 -2
- package/dist/index2.mjs +2 -2
- 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 +3 -3
- package/dist/index22.mjs +3 -3
- package/dist/index23.js +3 -3
- package/dist/index23.mjs +3 -3
- package/dist/index24.js +2 -2
- package/dist/index24.mjs +2 -2
- package/dist/index25.js +1 -1
- package/dist/index25.mjs +1 -1
- package/dist/index26.js +1 -1
- package/dist/index26.mjs +1 -1
- package/dist/index29.js +158 -17
- package/dist/index29.mjs +157 -14
- package/dist/index3.js +1 -1
- package/dist/index3.mjs +1 -1
- package/dist/index30.js +43 -100
- package/dist/index30.mjs +43 -98
- package/dist/index31.js +71 -32
- package/dist/index31.mjs +71 -31
- package/dist/index32.js +51 -154
- package/dist/index32.mjs +51 -153
- package/dist/index33.js +28 -47
- package/dist/index33.mjs +28 -47
- package/dist/index34.js +161 -65
- package/dist/index34.mjs +161 -65
- package/dist/index35.js +58 -50
- package/dist/index35.mjs +58 -50
- package/dist/index36.js +18 -32
- package/dist/index36.mjs +15 -32
- package/dist/index37.js +99 -167
- package/dist/index37.mjs +97 -167
- package/dist/index38.js +16 -57
- package/dist/index38.mjs +16 -57
- package/dist/index39.js +38 -20
- package/dist/index39.mjs +37 -20
- package/dist/index4.js +7 -7
- package/dist/index4.mjs +7 -7
- package/dist/index42.js +29 -49
- package/dist/index42.mjs +28 -49
- package/dist/index44.js +49 -29
- package/dist/index44.mjs +49 -28
- package/dist/index45.js +25 -9
- package/dist/index45.mjs +25 -9
- package/dist/index49.js +1 -1
- package/dist/index49.mjs +1 -1
- package/dist/index50.js +1 -1
- package/dist/index50.mjs +1 -1
- package/dist/index51.js +1 -1
- package/dist/index51.mjs +1 -1
- package/package.json +1 -1
package/dist/index32.js
CHANGED
|
@@ -2,163 +2,60 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const hookManager = require('./
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const inject = require('./index42.js');
|
|
11
|
-
const injectable = require('./index45.js');
|
|
5
|
+
const hookManager = require('./index31.js');
|
|
6
|
+
const debugLogger = require('./index34.js');
|
|
7
|
+
const cycleDetector = require('./index35.js');
|
|
8
|
+
const injectableManager = require('./index29.js');
|
|
9
|
+
const schema = require('./index37.js');
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (t && t !== 'Object') {
|
|
33
|
-
return t;
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const t = JSON.stringify(e);
|
|
37
|
-
if (t.length > 100) {
|
|
38
|
-
return t.substring(0, 100) + '...';
|
|
11
|
+
class AssemblerBuilder {
|
|
12
|
+
build(n, r) {
|
|
13
|
+
const i = debugLogger.DebugLogger.getInstance();
|
|
14
|
+
schema.setDefinitionValue('singleton', true, n);
|
|
15
|
+
i.logPhaseStart('registration');
|
|
16
|
+
const l = this.assembler.register([
|
|
17
|
+
n
|
|
18
|
+
]);
|
|
19
|
+
const c = this.assembler.injectableManager.getRegisteredIdentifiers();
|
|
20
|
+
i.logPhaseEnd('registration', undefined, {
|
|
21
|
+
registered: c
|
|
22
|
+
});
|
|
23
|
+
const h = cycleDetector.CycleDetector.getInstance().detect(this.assembler.injectableManager.getInjectables(), (e)=>injectableManager.formatIdentifier(e));
|
|
24
|
+
if (h.length > 0) {
|
|
25
|
+
for (const e of h){
|
|
26
|
+
i.log('error', 'Circular dependency detected', {
|
|
27
|
+
cycle: e.cycle,
|
|
28
|
+
path: e.path
|
|
29
|
+
});
|
|
39
30
|
}
|
|
40
|
-
return t;
|
|
41
|
-
} catch {
|
|
42
|
-
return '[UnknownObject]';
|
|
43
31
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
error: e
|
|
71
|
-
});
|
|
72
|
-
throw new Error(e);
|
|
73
|
-
}
|
|
74
|
-
const f = injectable.Injectable.of(c, this.privateContext, this.publicContext);
|
|
75
|
-
a.logRegistration(f);
|
|
76
|
-
this.injectables.set(f.identifier, f);
|
|
77
|
-
if (f.concrete) {
|
|
78
|
-
hookManager.HookManager.callHook(f.concrete, 'onRegister', this.publicContext, f.configuration);
|
|
79
|
-
}
|
|
80
|
-
return f;
|
|
81
|
-
}
|
|
82
|
-
has(e) {
|
|
83
|
-
return this.injectables.has(e);
|
|
84
|
-
}
|
|
85
|
-
require(e, t, n) {
|
|
86
|
-
if (!this.injectables.has(e)) {
|
|
87
|
-
const r = this.resolvingStack.has(e);
|
|
88
|
-
const i = r ? 'Circular dependency detected' : 'Dependency not registered';
|
|
89
|
-
const o = formatIdentifier(e);
|
|
90
|
-
const a = c(e);
|
|
91
|
-
const f = t?.__paramIndex;
|
|
92
|
-
const u = t?.__paramCount;
|
|
93
|
-
const l = t?.__expectedType;
|
|
94
|
-
const g = r ? `Circular dependency detected: '${o}' is already being resolved.` : `Dependency '${o}' has not been registered (Class/Service not found in current assemblages).`;
|
|
95
|
-
const d = {
|
|
96
|
-
identifier: o,
|
|
97
|
-
caller: n ? formatIdentifier(n) : 'unknown',
|
|
98
|
-
type: a,
|
|
99
|
-
error: g
|
|
100
|
-
};
|
|
101
|
-
if (f !== undefined) {
|
|
102
|
-
d.paramIndex = f;
|
|
103
|
-
}
|
|
104
|
-
if (u !== undefined) {
|
|
105
|
-
d.paramCount = u;
|
|
106
|
-
}
|
|
107
|
-
if (l !== undefined) {
|
|
108
|
-
const e = l?.name || formatIdentifier(l);
|
|
109
|
-
d.expectedType = e;
|
|
110
|
-
}
|
|
111
|
-
debugLogger.DebugLogger.getInstance().log('error', i, d);
|
|
112
|
-
throw new Error(g);
|
|
113
|
-
}
|
|
114
|
-
const r = this.injectables.get(e);
|
|
115
|
-
this.resolvingStack.add(r.identifier);
|
|
116
|
-
try {
|
|
117
|
-
if (r.isSingleton) {
|
|
118
|
-
return this.singletonStrategy.resolve(r, t);
|
|
119
|
-
} else {
|
|
120
|
-
return this.transientStrategy.resolve(r, t);
|
|
121
|
-
}
|
|
122
|
-
} finally{
|
|
123
|
-
this.resolvingStack.delete(r.identifier);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
concrete(e) {
|
|
127
|
-
const t = this.injectables.get(e);
|
|
128
|
-
if (t) return t.concrete;
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
tagged(...e) {
|
|
132
|
-
const t = [];
|
|
133
|
-
for (const n of e){
|
|
134
|
-
for (const [e, r] of this.injectables){
|
|
135
|
-
if (r.tags.includes(n)) t.push(r.build());
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return t;
|
|
139
|
-
}
|
|
140
|
-
dispose() {
|
|
141
|
-
for (const [e, t] of this.injectables){
|
|
142
|
-
t.dispose();
|
|
143
|
-
}
|
|
144
|
-
this.resolvingStack.clear();
|
|
145
|
-
}
|
|
146
|
-
get size() {
|
|
147
|
-
return this.injectables.size;
|
|
148
|
-
}
|
|
149
|
-
getRegisteredIdentifiers() {
|
|
150
|
-
return Array.from(this.injectables.keys()).map((e)=>e?.name || String(e));
|
|
151
|
-
}
|
|
152
|
-
getInjectables() {
|
|
153
|
-
return this.injectables;
|
|
154
|
-
}
|
|
155
|
-
constructor(){
|
|
156
|
-
this.injectables = new Map();
|
|
157
|
-
this.resolvingStack = new Set();
|
|
158
|
-
this.singletonStrategy = new resolutionStrategies.SingletonStrategy();
|
|
159
|
-
this.transientStrategy = new resolutionStrategies.TransientStrategy();
|
|
32
|
+
i.logPhaseStart('resolution');
|
|
33
|
+
const g = this.assembler.require(l.identifier, r);
|
|
34
|
+
i.logPhaseEnd('resolution');
|
|
35
|
+
const m = this.assembler.hookManager.getCache().find((e)=>e.instance === g);
|
|
36
|
+
if (!m) {
|
|
37
|
+
throw new Error('Root instance not found in assemblages cache.');
|
|
38
|
+
}
|
|
39
|
+
const b = this.assembler.hookManager.getCache().indexOf(m);
|
|
40
|
+
this.assembler.hookManager.getCache().splice(b, 1);
|
|
41
|
+
i.logPhaseStart('hooks:onInit');
|
|
42
|
+
this.assembler.hookManager.callInitHooks(this.assembler.publicContext);
|
|
43
|
+
const d = r ? {
|
|
44
|
+
...l.configuration,
|
|
45
|
+
...r
|
|
46
|
+
} : l.configuration;
|
|
47
|
+
hookManager.HookManager.callHookImmediate(g, 'onInit', this.assembler.publicContext, d);
|
|
48
|
+
i.logPhaseEnd('hooks:onInit');
|
|
49
|
+
i.logPhaseStart('hooks:onInited');
|
|
50
|
+
this.assembler.hookManager.callInitedHooks(this.assembler.publicContext);
|
|
51
|
+
hookManager.HookManager.callHookImmediate(g, 'onInited', this.assembler.publicContext, d);
|
|
52
|
+
i.logPhaseEnd('hooks:onInited');
|
|
53
|
+
this.assembler.hookManager.clearCache();
|
|
54
|
+
return g;
|
|
55
|
+
}
|
|
56
|
+
constructor(e){
|
|
57
|
+
this.assembler = e;
|
|
160
58
|
}
|
|
161
59
|
}
|
|
162
60
|
|
|
163
|
-
exports.
|
|
164
|
-
exports.formatIdentifier = formatIdentifier;
|
|
61
|
+
exports.AssemblerBuilder = AssemblerBuilder;
|
package/dist/index32.mjs
CHANGED
|
@@ -1,159 +1,57 @@
|
|
|
1
|
-
import { HookManager } from './
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { resolveInjectionTuple } from './index42.mjs';
|
|
7
|
-
import { Injectable } from './index45.mjs';
|
|
1
|
+
import { HookManager } from './index31.mjs';
|
|
2
|
+
import { DebugLogger } from './index34.mjs';
|
|
3
|
+
import { CycleDetector } from './index35.mjs';
|
|
4
|
+
import { formatIdentifier } from './index29.mjs';
|
|
5
|
+
import { setDefinitionValue } from './index37.mjs';
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (t && t !== 'Object') {
|
|
29
|
-
return t;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
const t = JSON.stringify(e);
|
|
33
|
-
if (t.length > 100) {
|
|
34
|
-
return t.substring(0, 100) + '...';
|
|
7
|
+
class AssemblerBuilder {
|
|
8
|
+
build(n, r) {
|
|
9
|
+
const i = DebugLogger.getInstance();
|
|
10
|
+
setDefinitionValue('singleton', true, n);
|
|
11
|
+
i.logPhaseStart('registration');
|
|
12
|
+
const l = this.assembler.register([
|
|
13
|
+
n
|
|
14
|
+
]);
|
|
15
|
+
const c = this.assembler.injectableManager.getRegisteredIdentifiers();
|
|
16
|
+
i.logPhaseEnd('registration', undefined, {
|
|
17
|
+
registered: c
|
|
18
|
+
});
|
|
19
|
+
const h = CycleDetector.getInstance().detect(this.assembler.injectableManager.getInjectables(), (e)=>formatIdentifier(e));
|
|
20
|
+
if (h.length > 0) {
|
|
21
|
+
for (const e of h){
|
|
22
|
+
i.log('error', 'Circular dependency detected', {
|
|
23
|
+
cycle: e.cycle,
|
|
24
|
+
path: e.path
|
|
25
|
+
});
|
|
35
26
|
}
|
|
36
|
-
return t;
|
|
37
|
-
} catch {
|
|
38
|
-
return '[UnknownObject]';
|
|
39
27
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
error: e
|
|
67
|
-
});
|
|
68
|
-
throw new Error(e);
|
|
69
|
-
}
|
|
70
|
-
const f = Injectable.of(c, this.privateContext, this.publicContext);
|
|
71
|
-
a.logRegistration(f);
|
|
72
|
-
this.injectables.set(f.identifier, f);
|
|
73
|
-
if (f.concrete) {
|
|
74
|
-
HookManager.callHook(f.concrete, 'onRegister', this.publicContext, f.configuration);
|
|
75
|
-
}
|
|
76
|
-
return f;
|
|
77
|
-
}
|
|
78
|
-
has(e) {
|
|
79
|
-
return this.injectables.has(e);
|
|
80
|
-
}
|
|
81
|
-
require(e, t, n) {
|
|
82
|
-
if (!this.injectables.has(e)) {
|
|
83
|
-
const r = this.resolvingStack.has(e);
|
|
84
|
-
const i = r ? 'Circular dependency detected' : 'Dependency not registered';
|
|
85
|
-
const o = formatIdentifier(e);
|
|
86
|
-
const a = c(e);
|
|
87
|
-
const f = t?.__paramIndex;
|
|
88
|
-
const u = t?.__paramCount;
|
|
89
|
-
const l = t?.__expectedType;
|
|
90
|
-
const g = r ? `Circular dependency detected: '${o}' is already being resolved.` : `Dependency '${o}' has not been registered (Class/Service not found in current assemblages).`;
|
|
91
|
-
const d = {
|
|
92
|
-
identifier: o,
|
|
93
|
-
caller: n ? formatIdentifier(n) : 'unknown',
|
|
94
|
-
type: a,
|
|
95
|
-
error: g
|
|
96
|
-
};
|
|
97
|
-
if (f !== undefined) {
|
|
98
|
-
d.paramIndex = f;
|
|
99
|
-
}
|
|
100
|
-
if (u !== undefined) {
|
|
101
|
-
d.paramCount = u;
|
|
102
|
-
}
|
|
103
|
-
if (l !== undefined) {
|
|
104
|
-
const e = l?.name || formatIdentifier(l);
|
|
105
|
-
d.expectedType = e;
|
|
106
|
-
}
|
|
107
|
-
DebugLogger.getInstance().log('error', i, d);
|
|
108
|
-
throw new Error(g);
|
|
109
|
-
}
|
|
110
|
-
const r = this.injectables.get(e);
|
|
111
|
-
this.resolvingStack.add(r.identifier);
|
|
112
|
-
try {
|
|
113
|
-
if (r.isSingleton) {
|
|
114
|
-
return this.singletonStrategy.resolve(r, t);
|
|
115
|
-
} else {
|
|
116
|
-
return this.transientStrategy.resolve(r, t);
|
|
117
|
-
}
|
|
118
|
-
} finally{
|
|
119
|
-
this.resolvingStack.delete(r.identifier);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
concrete(e) {
|
|
123
|
-
const t = this.injectables.get(e);
|
|
124
|
-
if (t) return t.concrete;
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
tagged(...e) {
|
|
128
|
-
const t = [];
|
|
129
|
-
for (const n of e){
|
|
130
|
-
for (const [e, r] of this.injectables){
|
|
131
|
-
if (r.tags.includes(n)) t.push(r.build());
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return t;
|
|
135
|
-
}
|
|
136
|
-
dispose() {
|
|
137
|
-
for (const [e, t] of this.injectables){
|
|
138
|
-
t.dispose();
|
|
139
|
-
}
|
|
140
|
-
this.resolvingStack.clear();
|
|
141
|
-
}
|
|
142
|
-
get size() {
|
|
143
|
-
return this.injectables.size;
|
|
144
|
-
}
|
|
145
|
-
getRegisteredIdentifiers() {
|
|
146
|
-
return Array.from(this.injectables.keys()).map((e)=>e?.name || String(e));
|
|
147
|
-
}
|
|
148
|
-
getInjectables() {
|
|
149
|
-
return this.injectables;
|
|
150
|
-
}
|
|
151
|
-
constructor(){
|
|
152
|
-
this.injectables = new Map();
|
|
153
|
-
this.resolvingStack = new Set();
|
|
154
|
-
this.singletonStrategy = new SingletonStrategy();
|
|
155
|
-
this.transientStrategy = new TransientStrategy();
|
|
28
|
+
i.logPhaseStart('resolution');
|
|
29
|
+
const g = this.assembler.require(l.identifier, r);
|
|
30
|
+
i.logPhaseEnd('resolution');
|
|
31
|
+
const m = this.assembler.hookManager.getCache().find((e)=>e.instance === g);
|
|
32
|
+
if (!m) {
|
|
33
|
+
throw new Error('Root instance not found in assemblages cache.');
|
|
34
|
+
}
|
|
35
|
+
const b = this.assembler.hookManager.getCache().indexOf(m);
|
|
36
|
+
this.assembler.hookManager.getCache().splice(b, 1);
|
|
37
|
+
i.logPhaseStart('hooks:onInit');
|
|
38
|
+
this.assembler.hookManager.callInitHooks(this.assembler.publicContext);
|
|
39
|
+
const d = r ? {
|
|
40
|
+
...l.configuration,
|
|
41
|
+
...r
|
|
42
|
+
} : l.configuration;
|
|
43
|
+
HookManager.callHookImmediate(g, 'onInit', this.assembler.publicContext, d);
|
|
44
|
+
i.logPhaseEnd('hooks:onInit');
|
|
45
|
+
i.logPhaseStart('hooks:onInited');
|
|
46
|
+
this.assembler.hookManager.callInitedHooks(this.assembler.publicContext);
|
|
47
|
+
HookManager.callHookImmediate(g, 'onInited', this.assembler.publicContext, d);
|
|
48
|
+
i.logPhaseEnd('hooks:onInited');
|
|
49
|
+
this.assembler.hookManager.clearCache();
|
|
50
|
+
return g;
|
|
51
|
+
}
|
|
52
|
+
constructor(e){
|
|
53
|
+
this.assembler = e;
|
|
156
54
|
}
|
|
157
55
|
}
|
|
158
56
|
|
|
159
|
-
export {
|
|
57
|
+
export { AssemblerBuilder };
|
package/dist/index33.js
CHANGED
|
@@ -2,55 +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
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
throw new Error(s);
|
|
21
|
-
}
|
|
22
|
-
this.objects.set(r, o);
|
|
23
|
-
return o;
|
|
24
|
-
}
|
|
25
|
-
has(e) {
|
|
26
|
-
return this.objects.has(e);
|
|
27
|
-
}
|
|
28
|
-
require(r) {
|
|
29
|
-
if (!this.objects.has(r)) {
|
|
30
|
-
const o = typeof r === 'symbol' ? r.toString() : String(r);
|
|
31
|
-
const s = `Object/value '${o}' has not been registered in the object store.`;
|
|
32
|
-
debugLogger.DebugLogger.getInstance().log('error', 'Object/value not found', {
|
|
33
|
-
identifier: o,
|
|
34
|
-
type: t(r),
|
|
35
|
-
error: s
|
|
36
|
-
});
|
|
37
|
-
throw new Error(s);
|
|
38
|
-
}
|
|
39
|
-
return this.objects.get(r);
|
|
40
|
-
}
|
|
41
|
-
addGlobal(e, t) {
|
|
42
|
-
if (this.globals.has(e)) {
|
|
43
|
-
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
44
|
-
}
|
|
45
|
-
this.globals.set(e, t);
|
|
5
|
+
class ContextProvider {
|
|
6
|
+
createPublicContext() {
|
|
7
|
+
return {
|
|
8
|
+
has: this.assembler.has.bind(this.assembler),
|
|
9
|
+
require: this.assembler.require.bind(this.assembler),
|
|
10
|
+
concrete: this.assembler.concrete.bind(this.assembler),
|
|
11
|
+
tagged: this.assembler.tagged.bind(this.assembler),
|
|
12
|
+
dispose: this.assembler.dispose.bind(this.assembler),
|
|
13
|
+
global: this.assembler.global.bind(this.assembler),
|
|
14
|
+
on: this.assembler.on.bind(this.assembler),
|
|
15
|
+
once: this.assembler.once.bind(this.assembler),
|
|
16
|
+
off: this.assembler.off.bind(this.assembler),
|
|
17
|
+
events: this.assembler.channels
|
|
18
|
+
};
|
|
46
19
|
}
|
|
47
|
-
|
|
48
|
-
return
|
|
20
|
+
createPrivateContext(s) {
|
|
21
|
+
return {
|
|
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
|
+
};
|
|
49
31
|
}
|
|
50
|
-
constructor(){
|
|
51
|
-
this.
|
|
52
|
-
this.globals = new Map();
|
|
32
|
+
constructor(s){
|
|
33
|
+
this.assembler = s;
|
|
53
34
|
}
|
|
54
35
|
}
|
|
55
36
|
|
|
56
|
-
exports.
|
|
37
|
+
exports.ContextProvider = ContextProvider;
|
package/dist/index33.mjs
CHANGED
|
@@ -1,52 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
throw new Error(s);
|
|
17
|
-
}
|
|
18
|
-
this.objects.set(r, o);
|
|
19
|
-
return o;
|
|
20
|
-
}
|
|
21
|
-
has(e) {
|
|
22
|
-
return this.objects.has(e);
|
|
23
|
-
}
|
|
24
|
-
require(r) {
|
|
25
|
-
if (!this.objects.has(r)) {
|
|
26
|
-
const o = typeof r === 'symbol' ? r.toString() : String(r);
|
|
27
|
-
const s = `Object/value '${o}' has not been registered in the object store.`;
|
|
28
|
-
DebugLogger.getInstance().log('error', 'Object/value not found', {
|
|
29
|
-
identifier: o,
|
|
30
|
-
type: t(r),
|
|
31
|
-
error: s
|
|
32
|
-
});
|
|
33
|
-
throw new Error(s);
|
|
34
|
-
}
|
|
35
|
-
return this.objects.get(r);
|
|
36
|
-
}
|
|
37
|
-
addGlobal(e, t) {
|
|
38
|
-
if (this.globals.has(e)) {
|
|
39
|
-
throw new Error(`Global value with key '${e}' has already been registered.`);
|
|
40
|
-
}
|
|
41
|
-
this.globals.set(e, t);
|
|
1
|
+
class ContextProvider {
|
|
2
|
+
createPublicContext() {
|
|
3
|
+
return {
|
|
4
|
+
has: this.assembler.has.bind(this.assembler),
|
|
5
|
+
require: this.assembler.require.bind(this.assembler),
|
|
6
|
+
concrete: this.assembler.concrete.bind(this.assembler),
|
|
7
|
+
tagged: this.assembler.tagged.bind(this.assembler),
|
|
8
|
+
dispose: this.assembler.dispose.bind(this.assembler),
|
|
9
|
+
global: this.assembler.global.bind(this.assembler),
|
|
10
|
+
on: this.assembler.on.bind(this.assembler),
|
|
11
|
+
once: this.assembler.once.bind(this.assembler),
|
|
12
|
+
off: this.assembler.off.bind(this.assembler),
|
|
13
|
+
events: this.assembler.channels
|
|
14
|
+
};
|
|
42
15
|
}
|
|
43
|
-
|
|
44
|
-
return
|
|
16
|
+
createPrivateContext(s) {
|
|
17
|
+
return {
|
|
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
|
+
};
|
|
45
27
|
}
|
|
46
|
-
constructor(){
|
|
47
|
-
this.
|
|
48
|
-
this.globals = new Map();
|
|
28
|
+
constructor(s){
|
|
29
|
+
this.assembler = s;
|
|
49
30
|
}
|
|
50
31
|
}
|
|
51
32
|
|
|
52
|
-
export {
|
|
33
|
+
export { ContextProvider };
|