@joist/di 3.7.0 → 3.9.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 +22 -5
- package/package.json +1 -1
- package/src/lib/inject.test.ts +13 -1
- package/src/lib/inject.ts +4 -4
- package/src/lib/injector.ts +23 -10
- package/src/lib/lifecycle.test.ts +95 -0
- package/src/lib/lifecycle.ts +4 -0
- package/src/lib.ts +1 -0
- package/target/lib/inject.d.ts +2 -2
- package/target/lib/inject.js +1 -1
- package/target/lib/inject.js.map +1 -1
- package/target/lib/inject.test.js +24 -1
- package/target/lib/inject.test.js.map +1 -1
- package/target/lib/injector.js +14 -4
- package/target/lib/injector.js.map +1 -1
- package/target/lib/lifecycle.d.ts +4 -0
- package/target/lib/lifecycle.js +5 -0
- package/target/lib/lifecycle.js.map +1 -0
- package/target/lib/lifecycle.test.d.ts +1 -0
- package/target/lib/lifecycle.test.js +134 -0
- package/target/lib/lifecycle.test.js.map +1 -0
- package/target/lib.d.ts +1 -0
- package/target/lib.js +1 -0
- package/target/lib.js.map +1 -1
package/README.md
CHANGED
|
@@ -9,8 +9,9 @@ Allows you to inject services into other class instances (including custom eleme
|
|
|
9
9
|
- [Installation](#installation)
|
|
10
10
|
- [Example Usage](#example)
|
|
11
11
|
- [Factories](#factories)
|
|
12
|
-
- [
|
|
12
|
+
- [StaticToken](#statictoken)
|
|
13
13
|
- [Testing](#testing)
|
|
14
|
+
- [LifeCycle](#life-cycle)
|
|
14
15
|
- [Parent/Child Relationship](#parentchild-relationship)
|
|
15
16
|
- [Custom Elements](#custom-elements)
|
|
16
17
|
- [Environment](#environment)
|
|
@@ -133,13 +134,13 @@ const app = new Injector([
|
|
|
133
134
|
]);
|
|
134
135
|
```
|
|
135
136
|
|
|
136
|
-
##
|
|
137
|
+
## StaticToken
|
|
137
138
|
|
|
138
139
|
In most cases a token is any constructable class. There are cases where you might want to return other data types that aren't objects.
|
|
139
140
|
|
|
140
141
|
```ts
|
|
141
142
|
// token that resolves to a string
|
|
142
|
-
const URL_TOKEN =
|
|
143
|
+
const URL_TOKEN = new StaticToken<string>('app_url');
|
|
143
144
|
|
|
144
145
|
const app = new Injector([
|
|
145
146
|
{
|
|
@@ -154,7 +155,7 @@ const app = new Injector([
|
|
|
154
155
|
A static token can be provided a default factory function to use on creation.
|
|
155
156
|
|
|
156
157
|
```ts
|
|
157
|
-
const URL_TOKEN =
|
|
158
|
+
const URL_TOKEN = new StaticToken('app_url', () => '/default-url/');
|
|
158
159
|
```
|
|
159
160
|
|
|
160
161
|
### Async values
|
|
@@ -163,7 +164,7 @@ Static tokens can also leverage promises for cases when you need to async create
|
|
|
163
164
|
|
|
164
165
|
```ts
|
|
165
166
|
// StaticToken<Promise<string>>
|
|
166
|
-
const URL_TOKEN =
|
|
167
|
+
const URL_TOKEN = new StaticToken('app_url', () => Promise.resolve('/default-url/'));
|
|
167
168
|
|
|
168
169
|
const app = new Injector();
|
|
169
170
|
|
|
@@ -212,6 +213,22 @@ const testApp = new Injector([
|
|
|
212
213
|
const api = testApp.get(ApiService);
|
|
213
214
|
```
|
|
214
215
|
|
|
216
|
+
## Life Cycle
|
|
217
|
+
|
|
218
|
+
To helo provide more information to services that are being created, joist will call several life cycle hooks as services are created. These hooks are defined using the provided symbols so there is no risk of naming colisions.
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
class MyService {
|
|
222
|
+
[LifeCycle.onInit]() {
|
|
223
|
+
// called the first time a service is created. (not pulled from cache)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
[LifeCycle.onInject]() {
|
|
227
|
+
// called every time a service is returned, whether it is from cache or not
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
215
232
|
## Parent/Child relationship
|
|
216
233
|
|
|
217
234
|
Injectors can be defined with a parent element. The top most parent will (by default) be where services are constructed and cached. Only if manually defined providers are found earlier in the chain will services be constructed lower. The injector resolution algorithm behaves as following.
|
package/package.json
CHANGED
package/src/lib/inject.test.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { expect } from '@open-wc/testing';
|
|
|
3
3
|
import { inject } from './inject.js';
|
|
4
4
|
import { injectable } from './injectable.js';
|
|
5
5
|
import { Injector } from './injector.js';
|
|
6
|
+
import { StaticToken } from './provider.js';
|
|
6
7
|
|
|
7
8
|
describe('inject', () => {
|
|
8
9
|
it('should work', () => {
|
|
@@ -42,7 +43,7 @@ describe('inject', () => {
|
|
|
42
43
|
const error = err as Error;
|
|
43
44
|
|
|
44
45
|
expect(error.message).to.equal(
|
|
45
|
-
`BarService is either not injectable or a service is being called in the constructor. \n Either add the @injectable to your class or use the onInject callback method.`
|
|
46
|
+
`BarService is either not injectable or a service is being called in the constructor. \n Either add the @injectable to your class or use the [LifeCycle.onInject] callback method.`
|
|
46
47
|
);
|
|
47
48
|
}
|
|
48
49
|
});
|
|
@@ -68,4 +69,15 @@ describe('inject', () => {
|
|
|
68
69
|
|
|
69
70
|
expect(parent.inject(BarService).foo().value).to.equal('100');
|
|
70
71
|
});
|
|
72
|
+
|
|
73
|
+
it('should inject a static token', () => {
|
|
74
|
+
const TOKEN = new StaticToken('test', () => 'Hello World');
|
|
75
|
+
|
|
76
|
+
@injectable
|
|
77
|
+
class HelloWorld {
|
|
78
|
+
hello = inject(TOKEN);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
expect(new HelloWorld().hello()).to.equal('Hello World');
|
|
82
|
+
});
|
|
71
83
|
});
|
package/src/lib/inject.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InjectionToken } from './provider.js';
|
|
2
2
|
import { INJECTABLE_MAP } from './injectable.js';
|
|
3
3
|
|
|
4
4
|
export type Injected<T> = () => T;
|
|
5
5
|
|
|
6
|
-
export function inject<This extends object, T
|
|
7
|
-
token:
|
|
6
|
+
export function inject<This extends object, T>(
|
|
7
|
+
token: InjectionToken<T>
|
|
8
8
|
): Injected<T> {
|
|
9
9
|
return function (this: This) {
|
|
10
10
|
const injector = INJECTABLE_MAP.get(this);
|
|
@@ -13,7 +13,7 @@ export function inject<This extends object, T extends object>(
|
|
|
13
13
|
const name = Object.getPrototypeOf(this.constructor).name;
|
|
14
14
|
|
|
15
15
|
throw new Error(
|
|
16
|
-
`${name} is either not injectable or a service is being called in the constructor. \n Either add the @injectable to your class or use the onInject callback method.`
|
|
16
|
+
`${name} is either not injectable or a service is being called in the constructor. \n Either add the @injectable to your class or use the [LifeCycle.onInject] callback method.`
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
|
package/src/lib/injector.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { INJECTABLE_MAP } from './injectable.js';
|
|
2
|
+
import { LifeCycle } from './lifecycle.js';
|
|
2
3
|
import { InjectionToken, Provider, StaticToken } from './provider.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -38,7 +39,11 @@ export class Injector {
|
|
|
38
39
|
get<T>(token: InjectionToken<T>): T {
|
|
39
40
|
// check for a local instance
|
|
40
41
|
if (this.#instances.has(token)) {
|
|
41
|
-
|
|
42
|
+
const instance = this.#instances.get(token)!;
|
|
43
|
+
|
|
44
|
+
callLifecycle(instance, LifeCycle.onInject);
|
|
45
|
+
|
|
46
|
+
return instance;
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
const provider = this.#findProvider(token);
|
|
@@ -102,16 +107,15 @@ export class Injector {
|
|
|
102
107
|
* this allows the created service to navigate up it's chain to find a root
|
|
103
108
|
*/
|
|
104
109
|
injector.setParent(this);
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* the on inject lifecycle hook should be called after the parent is defined.
|
|
108
|
-
* this ensures that services are initialized when the chain is settled
|
|
109
|
-
* this is required since the parent is set after the instance is constructed
|
|
110
|
-
*/
|
|
111
|
-
if ('onInject' in instance && typeof instance.onInject === 'function') {
|
|
112
|
-
instance.onInject();
|
|
113
|
-
}
|
|
114
110
|
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* the onInject and onInit lifecycle hook should be called after the parent is defined.
|
|
114
|
+
* this ensures that services are initialized when the chain is settled
|
|
115
|
+
* this is required since the parent is set after the instance is constructed
|
|
116
|
+
*/
|
|
117
|
+
callLifecycle(instance, LifeCycle.onInit);
|
|
118
|
+
callLifecycle(instance, LifeCycle.onInject);
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
return instance;
|
|
@@ -135,3 +139,12 @@ export class Injector {
|
|
|
135
139
|
export function injector(providers: Provider<unknown>[] = [], parent?: Injector) {
|
|
136
140
|
return new Injector(providers, parent);
|
|
137
141
|
}
|
|
142
|
+
function callLifecycle(instance: unknown, method: symbol) {
|
|
143
|
+
if (typeof instance === 'object' && instance !== null) {
|
|
144
|
+
const lifecycle = Reflect.get(instance, method);
|
|
145
|
+
|
|
146
|
+
if (typeof lifecycle === 'function') {
|
|
147
|
+
lifecycle.call(instance);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { Injector } from './injector.js';
|
|
3
|
+
import { LifeCycle } from './lifecycle.js';
|
|
4
|
+
import { injectable } from './injectable';
|
|
5
|
+
import { inject } from './inject.js';
|
|
6
|
+
|
|
7
|
+
describe('LifeCycle', () => {
|
|
8
|
+
it('should call onInit and onInject when a service is first created', () => {
|
|
9
|
+
const i = new Injector();
|
|
10
|
+
|
|
11
|
+
const res = {
|
|
12
|
+
onInit: 0,
|
|
13
|
+
onInject: 0
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
@injectable
|
|
17
|
+
class MyService {
|
|
18
|
+
[LifeCycle.onInit]() {
|
|
19
|
+
res.onInit++;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[LifeCycle.onInject]() {
|
|
23
|
+
res.onInject++;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
i.inject(MyService);
|
|
28
|
+
|
|
29
|
+
expect(res).to.deep.equal({
|
|
30
|
+
onInit: 1,
|
|
31
|
+
onInject: 1
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should call onInject any time a service is returned', () => {
|
|
36
|
+
const i = new Injector();
|
|
37
|
+
|
|
38
|
+
const res = {
|
|
39
|
+
onInit: 0,
|
|
40
|
+
onInject: 0
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
@injectable
|
|
44
|
+
class MyService {
|
|
45
|
+
[LifeCycle.onInit]() {
|
|
46
|
+
res.onInit++;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[LifeCycle.onInject]() {
|
|
50
|
+
res.onInject++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
i.inject(MyService);
|
|
55
|
+
i.inject(MyService);
|
|
56
|
+
|
|
57
|
+
expect(res).to.deep.equal({
|
|
58
|
+
onInit: 1,
|
|
59
|
+
onInject: 2
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should call onInject and on init when injected from another service', () => {
|
|
64
|
+
const i = new Injector();
|
|
65
|
+
|
|
66
|
+
const res = {
|
|
67
|
+
onInit: 0,
|
|
68
|
+
onInject: 0
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
@injectable
|
|
72
|
+
class MyService {
|
|
73
|
+
[LifeCycle.onInit]() {
|
|
74
|
+
res.onInit++;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[LifeCycle.onInject]() {
|
|
78
|
+
res.onInject++;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@injectable
|
|
83
|
+
class MyApp {
|
|
84
|
+
service = inject(MyService);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
i.inject(MyApp).service();
|
|
88
|
+
i.inject(MyService);
|
|
89
|
+
|
|
90
|
+
expect(res).to.deep.equal({
|
|
91
|
+
onInit: 1,
|
|
92
|
+
onInject: 2
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
package/src/lib.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { Provider, ConstructableToken, StaticToken, token } from './lib/provider
|
|
|
3
3
|
export { injectable, INJECTABLE_MAP } from './lib/injectable.js';
|
|
4
4
|
export { inject, Injected } from './lib/inject.js';
|
|
5
5
|
export { defineEnvironment, clearEnvironment } from './lib/environment.js';
|
|
6
|
+
export { LifeCycle } from './lib/lifecycle.js';
|
package/target/lib/inject.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InjectionToken } from './provider.js';
|
|
2
2
|
export type Injected<T> = () => T;
|
|
3
|
-
export declare function inject<This extends object, T
|
|
3
|
+
export declare function inject<This extends object, T>(token: InjectionToken<T>): Injected<T>;
|
package/target/lib/inject.js
CHANGED
|
@@ -4,7 +4,7 @@ export function inject(token) {
|
|
|
4
4
|
const injector = INJECTABLE_MAP.get(this);
|
|
5
5
|
if (injector === undefined) {
|
|
6
6
|
const name = Object.getPrototypeOf(this.constructor).name;
|
|
7
|
-
throw new Error(`${name} is either not injectable or a service is being called in the constructor. \n Either add the @injectable to your class or use the onInject callback method.`);
|
|
7
|
+
throw new Error(`${name} is either not injectable or a service is being called in the constructor. \n Either add the @injectable to your class or use the [LifeCycle.onInject] callback method.`);
|
|
8
8
|
}
|
|
9
9
|
return injector.inject(token);
|
|
10
10
|
};
|
package/target/lib/inject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../src/lib/inject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,UAAU,MAAM,CACpB,
|
|
1
|
+
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../src/lib/inject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,UAAU,MAAM,CACpB,KAAwB;IAExB,OAAO;QACL,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE1C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YAE1D,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,yKAAyK,CACjL,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { expect } from '@open-wc/testing';
|
|
|
3
3
|
import { inject } from './inject.js';
|
|
4
4
|
import { injectable } from './injectable.js';
|
|
5
5
|
import { Injector } from './injector.js';
|
|
6
|
+
import { StaticToken } from './provider.js';
|
|
6
7
|
describe('inject', () => {
|
|
7
8
|
it('should work', () => {
|
|
8
9
|
class HelloService {
|
|
@@ -61,7 +62,7 @@ describe('inject', () => {
|
|
|
61
62
|
}
|
|
62
63
|
catch (err) {
|
|
63
64
|
const error = err;
|
|
64
|
-
expect(error.message).to.equal(`BarService is either not injectable or a service is being called in the constructor. \n Either add the @injectable to your class or use the onInject callback method.`);
|
|
65
|
+
expect(error.message).to.equal(`BarService is either not injectable or a service is being called in the constructor. \n Either add the @injectable to your class or use the [LifeCycle.onInject] callback method.`);
|
|
65
66
|
}
|
|
66
67
|
});
|
|
67
68
|
it('should use the calling injector as parent', () => {
|
|
@@ -96,5 +97,27 @@ describe('inject', () => {
|
|
|
96
97
|
]);
|
|
97
98
|
expect(parent.inject(BarService).foo().value).to.equal('100');
|
|
98
99
|
});
|
|
100
|
+
it('should inject a static token', () => {
|
|
101
|
+
const TOKEN = new StaticToken('test', () => 'Hello World');
|
|
102
|
+
let HelloWorld = (() => {
|
|
103
|
+
let _classDecorators = [injectable];
|
|
104
|
+
let _classDescriptor;
|
|
105
|
+
let _classExtraInitializers = [];
|
|
106
|
+
let _classThis;
|
|
107
|
+
var HelloWorld = class {
|
|
108
|
+
static { _classThis = this; }
|
|
109
|
+
static {
|
|
110
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
111
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
112
|
+
HelloWorld = _classThis = _classDescriptor.value;
|
|
113
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
114
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
115
|
+
}
|
|
116
|
+
hello = inject(TOKEN);
|
|
117
|
+
};
|
|
118
|
+
return HelloWorld = _classThis;
|
|
119
|
+
})();
|
|
120
|
+
expect(new HelloWorld().hello()).to.equal('Hello World');
|
|
121
|
+
});
|
|
99
122
|
});
|
|
100
123
|
//# sourceMappingURL=inject.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject.test.js","sourceRoot":"","sources":["../../src/lib/inject.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"inject.test.js","sourceRoot":"","sources":["../../src/lib/inject.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,E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AAM,UAAU;YACd,KAAK,GAAG,GAAG,CAAC;SACb;YAGK,UAAU;oCADf,UAAU;;;;;;;;oBACX,6KAEC;;;oBAFK,uDAAU;;gBACd,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;;;;QAG3B,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC;YAC1B;gBACE,OAAO,EAAE,UAAU;gBACnB,GAAG,EAAE,KAAM,SAAQ,UAAU;oBAC3B,KAAK,GAAG,KAAK,CAAC;iBACf;aACF;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;YAGrD,UAAU;oCADf,UAAU;;;;;;;;oBACX,6KAEC;;;oBAFK,uDAAU;;gBACd,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;;;;QAGxB,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/target/lib/injector.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { INJECTABLE_MAP } from './injectable.js';
|
|
2
|
+
import { LifeCycle } from './lifecycle.js';
|
|
2
3
|
import { StaticToken } from './provider.js';
|
|
3
4
|
export class Injector {
|
|
4
5
|
#instances = new WeakMap();
|
|
@@ -13,7 +14,9 @@ export class Injector {
|
|
|
13
14
|
}
|
|
14
15
|
get(token) {
|
|
15
16
|
if (this.#instances.has(token)) {
|
|
16
|
-
|
|
17
|
+
const instance = this.#instances.get(token);
|
|
18
|
+
callLifecycle(instance, LifeCycle.onInject);
|
|
19
|
+
return instance;
|
|
17
20
|
}
|
|
18
21
|
const provider = this.#findProvider(token);
|
|
19
22
|
if (provider) {
|
|
@@ -53,10 +56,9 @@ export class Injector {
|
|
|
53
56
|
const injector = INJECTABLE_MAP.get(instance);
|
|
54
57
|
if (injector) {
|
|
55
58
|
injector.setParent(this);
|
|
56
|
-
if ('onInject' in instance && typeof instance.onInject === 'function') {
|
|
57
|
-
instance.onInject();
|
|
58
|
-
}
|
|
59
59
|
}
|
|
60
|
+
callLifecycle(instance, LifeCycle.onInit);
|
|
61
|
+
callLifecycle(instance, LifeCycle.onInject);
|
|
60
62
|
}
|
|
61
63
|
return instance;
|
|
62
64
|
}
|
|
@@ -75,4 +77,12 @@ export class Injector {
|
|
|
75
77
|
export function injector(providers = [], parent) {
|
|
76
78
|
return new Injector(providers, parent);
|
|
77
79
|
}
|
|
80
|
+
function callLifecycle(instance, method) {
|
|
81
|
+
if (typeof instance === 'object' && instance !== null) {
|
|
82
|
+
const lifecycle = Reflect.get(instance, method);
|
|
83
|
+
if (typeof lifecycle === 'function') {
|
|
84
|
+
lifecycle.call(instance);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
78
88
|
//# sourceMappingURL=injector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injector.js","sourceRoot":"","sources":["../../src/lib/injector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAA4B,WAAW,EAAE,MAAM,eAAe,CAAC;AAmBtE,MAAM,OAAO,QAAQ;IAEnB,UAAU,GAAG,IAAI,OAAO,EAA4B,CAAC;IAErD,MAAM,CAAC;IACP,SAAS,CAAC;IAEV,YAAY,YAAiC,EAAE,EAAE,MAAiB;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS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AS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/lib/lifecycle.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { expect } from '@open-wc/testing';
|
|
3
|
+
import { Injector } from './injector.js';
|
|
4
|
+
import { LifeCycle } from './lifecycle.js';
|
|
5
|
+
import { injectable } from './injectable';
|
|
6
|
+
import { inject } from './inject.js';
|
|
7
|
+
describe('LifeCycle', () => {
|
|
8
|
+
it('should call onInit and onInject when a service is first created', () => {
|
|
9
|
+
const i = new Injector();
|
|
10
|
+
const res = {
|
|
11
|
+
onInit: 0,
|
|
12
|
+
onInject: 0
|
|
13
|
+
};
|
|
14
|
+
let MyService = (() => {
|
|
15
|
+
let _classDecorators = [injectable];
|
|
16
|
+
let _classDescriptor;
|
|
17
|
+
let _classExtraInitializers = [];
|
|
18
|
+
let _classThis;
|
|
19
|
+
var MyService = class {
|
|
20
|
+
static { _classThis = this; }
|
|
21
|
+
static {
|
|
22
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
23
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
24
|
+
MyService = _classThis = _classDescriptor.value;
|
|
25
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
26
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
27
|
+
}
|
|
28
|
+
[LifeCycle.onInit]() {
|
|
29
|
+
res.onInit++;
|
|
30
|
+
}
|
|
31
|
+
[LifeCycle.onInject]() {
|
|
32
|
+
res.onInject++;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return MyService = _classThis;
|
|
36
|
+
})();
|
|
37
|
+
i.inject(MyService);
|
|
38
|
+
expect(res).to.deep.equal({
|
|
39
|
+
onInit: 1,
|
|
40
|
+
onInject: 1
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
it('should call onInject any time a service is returned', () => {
|
|
44
|
+
const i = new Injector();
|
|
45
|
+
const res = {
|
|
46
|
+
onInit: 0,
|
|
47
|
+
onInject: 0
|
|
48
|
+
};
|
|
49
|
+
let MyService = (() => {
|
|
50
|
+
let _classDecorators = [injectable];
|
|
51
|
+
let _classDescriptor;
|
|
52
|
+
let _classExtraInitializers = [];
|
|
53
|
+
let _classThis;
|
|
54
|
+
var MyService = class {
|
|
55
|
+
static { _classThis = this; }
|
|
56
|
+
static {
|
|
57
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
58
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
59
|
+
MyService = _classThis = _classDescriptor.value;
|
|
60
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
61
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
62
|
+
}
|
|
63
|
+
[LifeCycle.onInit]() {
|
|
64
|
+
res.onInit++;
|
|
65
|
+
}
|
|
66
|
+
[LifeCycle.onInject]() {
|
|
67
|
+
res.onInject++;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return MyService = _classThis;
|
|
71
|
+
})();
|
|
72
|
+
i.inject(MyService);
|
|
73
|
+
i.inject(MyService);
|
|
74
|
+
expect(res).to.deep.equal({
|
|
75
|
+
onInit: 1,
|
|
76
|
+
onInject: 2
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
it('should call onInject and on init when injected from another service', () => {
|
|
80
|
+
const i = new Injector();
|
|
81
|
+
const res = {
|
|
82
|
+
onInit: 0,
|
|
83
|
+
onInject: 0
|
|
84
|
+
};
|
|
85
|
+
let MyService = (() => {
|
|
86
|
+
let _classDecorators = [injectable];
|
|
87
|
+
let _classDescriptor;
|
|
88
|
+
let _classExtraInitializers = [];
|
|
89
|
+
let _classThis;
|
|
90
|
+
var MyService = class {
|
|
91
|
+
static { _classThis = this; }
|
|
92
|
+
static {
|
|
93
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
94
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
95
|
+
MyService = _classThis = _classDescriptor.value;
|
|
96
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
97
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
98
|
+
}
|
|
99
|
+
[LifeCycle.onInit]() {
|
|
100
|
+
res.onInit++;
|
|
101
|
+
}
|
|
102
|
+
[LifeCycle.onInject]() {
|
|
103
|
+
res.onInject++;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return MyService = _classThis;
|
|
107
|
+
})();
|
|
108
|
+
let MyApp = (() => {
|
|
109
|
+
let _classDecorators = [injectable];
|
|
110
|
+
let _classDescriptor;
|
|
111
|
+
let _classExtraInitializers = [];
|
|
112
|
+
let _classThis;
|
|
113
|
+
var MyApp = class {
|
|
114
|
+
static { _classThis = this; }
|
|
115
|
+
static {
|
|
116
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
117
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
118
|
+
MyApp = _classThis = _classDescriptor.value;
|
|
119
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
120
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
121
|
+
}
|
|
122
|
+
service = inject(MyService);
|
|
123
|
+
};
|
|
124
|
+
return MyApp = _classThis;
|
|
125
|
+
})();
|
|
126
|
+
i.inject(MyApp).service();
|
|
127
|
+
i.inject(MyService);
|
|
128
|
+
expect(res).to.deep.equal({
|
|
129
|
+
onInit: 1,
|
|
130
|
+
onInject: 2
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=lifecycle.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.test.js","sourceRoot":"","sources":["../../src/lib/lifecycle.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,CAAC,GAAG,IAAI,QAAQ,EAAE,CAAC;QAEzB,MAAM,GAAG,GAAG;YACV,MAAM,EAAE,CAAC;YACT,QAAQ,EAAE,CAAC;SACZ,CAAC;YAGI,SAAS;oCADd,UAAU;;;;;;;;oBACX,6KAQC;;;oBARK,uDAAS;;gBACb,CAAC,SAAS,CAAC,MAAM,CAAC;oBAChB,GAAG,CAAC,MAAM,EA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BARK,uDAAS;;gBACb,CAAC,SAAS,CAAC,MAAM,CAAC;oBAChB,GAAG,CAAC,MAAM,EAAE,CAAC;gBACf,CAAC;gBAED,CAAC,SAAS,CAAC,QAAQ,CAAC;oBAClB,GAAG,CAAC,QAAQ,EAAE,CAAC;gBACjB,CAAC;;;;YAIG,KAAK;oCADV,UAAU;;;;;;;;oBACX,6KAEC;;;oBAFK,uDAAK;;gBACT,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;;;;QAG9B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QAC1B,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEpB,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YACxB,MAAM,EAAE,CAAC;YACT,QAAQ,EAAE,CAAC;SACZ,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/target/lib.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { Provider, ConstructableToken, StaticToken, token } from './lib/provider
|
|
|
3
3
|
export { injectable, INJECTABLE_MAP } from './lib/injectable.js';
|
|
4
4
|
export { inject, Injected } from './lib/inject.js';
|
|
5
5
|
export { defineEnvironment, clearEnvironment } from './lib/environment.js';
|
|
6
|
+
export { LifeCycle } from './lib/lifecycle.js';
|
package/target/lib.js
CHANGED
|
@@ -3,4 +3,5 @@ export { StaticToken, token } from './lib/provider.js';
|
|
|
3
3
|
export { injectable, INJECTABLE_MAP } from './lib/injectable.js';
|
|
4
4
|
export { inject } from './lib/inject.js';
|
|
5
5
|
export { defineEnvironment, clearEnvironment } from './lib/environment.js';
|
|
6
|
+
export { LifeCycle } from './lib/lifecycle.js';
|
|
6
7
|
//# sourceMappingURL=lib.js.map
|
package/target/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAgC,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAgC,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
|