@wirestate/lit 0.7.0-experimental.1 → 0.7.0-experimental.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -2
- package/README.md +49 -31
- package/cjs/development/index.js +420 -362
- package/cjs/development/index.js.map +1 -1
- package/cjs/production/index.js +1 -1
- package/cjs/production/index.js.map +1 -1
- package/esm/development/commands/on-command-controller.js +19 -22
- package/esm/development/commands/on-command-controller.js.map +1 -1
- package/esm/development/commands/on-command.js +4 -9
- package/esm/development/commands/on-command.js.map +1 -1
- package/esm/development/commands/use-on-command.js +4 -3
- package/esm/development/commands/use-on-command.js.map +1 -1
- package/esm/development/consumption/injection.js +14 -13
- package/esm/development/consumption/injection.js.map +1 -1
- package/esm/development/consumption/use-container.js +40 -0
- package/esm/development/consumption/use-container.js.map +1 -0
- package/esm/development/consumption/use-injection.js +12 -10
- package/esm/development/consumption/use-injection.js.map +1 -1
- package/esm/development/consumption/use-scope.js +44 -0
- package/esm/development/consumption/use-scope.js.map +1 -0
- package/esm/development/context/container-context.js +17 -0
- package/esm/development/context/container-context.js.map +1 -0
- package/esm/development/error/error-code.js +1 -1
- package/esm/development/error/error-code.js.map +1 -1
- package/esm/development/events/on-event-controller.js +22 -26
- package/esm/development/events/on-event-controller.js.map +1 -1
- package/esm/development/events/on-event.js +5 -11
- package/esm/development/events/on-event.js.map +1 -1
- package/esm/development/events/use-on-events.js +5 -5
- package/esm/development/events/use-on-events.js.map +1 -1
- package/esm/development/index.js +9 -7
- package/esm/development/index.js.map +1 -1
- package/esm/development/provision/container-provide.js +68 -0
- package/esm/development/provision/container-provide.js.map +1 -0
- package/esm/development/provision/container-provider.js +68 -0
- package/esm/development/provision/container-provider.js.map +1 -0
- package/esm/development/provision/sub-container-provide.js +56 -0
- package/esm/development/provision/sub-container-provide.js.map +1 -0
- package/esm/development/provision/sub-container-provider.js +90 -0
- package/esm/development/provision/sub-container-provider.js.map +1 -0
- package/esm/development/provision/use-container-provision.js +44 -0
- package/esm/development/provision/use-container-provision.js.map +1 -0
- package/esm/development/provision/use-sub-container-provider.js +34 -0
- package/esm/development/provision/use-sub-container-provider.js.map +1 -0
- package/esm/development/queries/on-query-controller.js +19 -22
- package/esm/development/queries/on-query-controller.js.map +1 -1
- package/esm/development/queries/on-query.js +4 -9
- package/esm/development/queries/on-query.js.map +1 -1
- package/esm/development/queries/use-on-query.js +4 -3
- package/esm/development/queries/use-on-query.js.map +1 -1
- package/esm/production/commands/on-command-controller.js +1 -1
- package/esm/production/commands/on-command-controller.js.map +1 -1
- package/esm/production/commands/on-command.js +1 -1
- package/esm/production/commands/on-command.js.map +1 -1
- package/esm/production/commands/use-on-command.js +1 -1
- package/esm/production/commands/use-on-command.js.map +1 -1
- package/esm/production/consumption/injection.js +1 -1
- package/esm/production/consumption/injection.js.map +1 -1
- package/esm/production/consumption/use-container.js +1 -0
- package/esm/production/consumption/use-container.js.map +1 -0
- package/esm/production/consumption/use-injection.js +1 -1
- package/esm/production/consumption/use-injection.js.map +1 -1
- package/esm/production/consumption/use-scope.js +1 -0
- package/esm/production/consumption/use-scope.js.map +1 -0
- package/esm/production/context/container-context.js +1 -0
- package/esm/production/context/container-context.js.map +1 -0
- package/esm/production/error/error-code.js +1 -1
- package/esm/production/error/error-code.js.map +1 -1
- package/esm/production/events/on-event-controller.js +1 -1
- package/esm/production/events/on-event-controller.js.map +1 -1
- package/esm/production/events/on-event.js +1 -1
- package/esm/production/events/on-event.js.map +1 -1
- package/esm/production/events/use-on-events.js +1 -1
- package/esm/production/events/use-on-events.js.map +1 -1
- package/esm/production/index.js +1 -1
- package/esm/production/provision/container-provide.js +1 -0
- package/esm/production/provision/container-provide.js.map +1 -0
- package/esm/production/provision/container-provider.js +1 -0
- package/esm/production/provision/container-provider.js.map +1 -0
- package/esm/production/provision/sub-container-provide.js +1 -0
- package/esm/production/provision/sub-container-provide.js.map +1 -0
- package/esm/production/provision/sub-container-provider.js +1 -0
- package/esm/production/provision/sub-container-provider.js.map +1 -0
- package/esm/production/provision/use-container-provision.js +1 -0
- package/esm/production/provision/use-container-provision.js.map +1 -0
- package/esm/production/provision/use-sub-container-provider.js +1 -0
- package/esm/production/provision/use-sub-container-provider.js.map +1 -0
- package/esm/production/queries/on-query-controller.js +1 -1
- package/esm/production/queries/on-query-controller.js.map +1 -1
- package/esm/production/queries/on-query.js +1 -1
- package/esm/production/queries/on-query.js.map +1 -1
- package/esm/production/queries/use-on-query.js +1 -1
- package/esm/production/queries/use-on-query.js.map +1 -1
- package/index.d.ts +271 -176
- package/package.json +2 -2
- package/esm/development/context/ioc-context.js +0 -17
- package/esm/development/context/ioc-context.js.map +0 -1
- package/esm/development/provision/injectables-provide.js +0 -47
- package/esm/development/provision/injectables-provide.js.map +0 -1
- package/esm/development/provision/injectables-provider-controller.js +0 -123
- package/esm/development/provision/injectables-provider-controller.js.map +0 -1
- package/esm/development/provision/ioc-provide.js +0 -58
- package/esm/development/provision/ioc-provide.js.map +0 -1
- package/esm/development/provision/ioc-provider-controller.js +0 -75
- package/esm/development/provision/ioc-provider-controller.js.map +0 -1
- package/esm/development/provision/use-injectables-provider.js +0 -27
- package/esm/development/provision/use-injectables-provider.js.map +0 -1
- package/esm/development/provision/use-ioc-provision.js +0 -27
- package/esm/development/provision/use-ioc-provision.js.map +0 -1
- package/esm/production/context/ioc-context.js +0 -1
- package/esm/production/context/ioc-context.js.map +0 -1
- package/esm/production/provision/injectables-provide.js +0 -1
- package/esm/production/provision/injectables-provide.js.map +0 -1
- package/esm/production/provision/injectables-provider-controller.js +0 -1
- package/esm/production/provision/injectables-provider-controller.js.map +0 -1
- package/esm/production/provision/ioc-provide.js +0 -1
- package/esm/production/provision/ioc-provide.js.map +0 -1
- package/esm/production/provision/ioc-provider-controller.js +0 -1
- package/esm/production/provision/ioc-provider-controller.js.map +0 -1
- package/esm/production/provision/use-injectables-provider.js +0 -1
- package/esm/production/provision/use-injectables-provider.js.map +0 -1
- package/esm/production/provision/use-ioc-provision.js +0 -1
- package/esm/production/provision/use-ioc-provision.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContextConsumer } from '@lit/context';
|
|
2
2
|
import { EventBus } from '@wirestate/core';
|
|
3
|
-
import {
|
|
3
|
+
import { ContainerContext } from '../context/container-context.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Controller that subscribes to events for the host element's lifetime.
|
|
@@ -11,58 +11,54 @@ import { IocContextObject } from '../context/ioc-context.js';
|
|
|
11
11
|
*
|
|
12
12
|
* @group Events
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
class OnEventController {
|
|
15
|
+
bus = null;
|
|
16
|
+
unsubscriber = null;
|
|
15
17
|
/**
|
|
16
18
|
* @param host - The host element.
|
|
17
19
|
* @param types - Event types to listen for. If null, all events will be handled.
|
|
18
20
|
* @param handler - The event handler function.
|
|
19
21
|
*/
|
|
20
|
-
|
|
21
|
-
var _this = this;
|
|
22
|
-
this.bus = null;
|
|
23
|
-
this.unsubscriber = null;
|
|
22
|
+
constructor(host, types, handler) {
|
|
24
23
|
host.addController(this);
|
|
25
24
|
this.types = types;
|
|
26
25
|
this.handler = handler;
|
|
27
26
|
new ContextConsumer(host, {
|
|
28
|
-
context:
|
|
27
|
+
context: ContainerContext,
|
|
29
28
|
subscribe: true,
|
|
30
|
-
callback:
|
|
31
|
-
|
|
29
|
+
callback: container => {
|
|
30
|
+
this.bus = container.get(EventBus);
|
|
32
31
|
if (host.isConnected) {
|
|
33
|
-
|
|
32
|
+
this.resubscribe();
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
|
-
|
|
37
|
+
hostConnected() {
|
|
39
38
|
this.resubscribe();
|
|
40
|
-
}
|
|
41
|
-
|
|
39
|
+
}
|
|
40
|
+
hostDisconnected() {
|
|
42
41
|
this.cleanup();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var _this = this;
|
|
42
|
+
}
|
|
43
|
+
resubscribe() {
|
|
46
44
|
this.cleanup();
|
|
47
45
|
if (this.bus) {
|
|
48
46
|
if (this.types === null) {
|
|
49
47
|
this.unsubscriber = this.bus.subscribe(this.handler);
|
|
50
48
|
} else {
|
|
51
|
-
this.unsubscriber = this.bus.subscribe(
|
|
52
|
-
if (
|
|
53
|
-
|
|
49
|
+
this.unsubscriber = this.bus.subscribe(event => {
|
|
50
|
+
if (this.types.includes(event.type)) {
|
|
51
|
+
this.handler(event);
|
|
54
52
|
}
|
|
55
53
|
});
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
(_a = this.unsubscriber) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
56
|
+
}
|
|
57
|
+
cleanup() {
|
|
58
|
+
this.unsubscriber?.();
|
|
62
59
|
this.unsubscriber = null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
66
62
|
|
|
67
63
|
export { OnEventController };
|
|
68
64
|
//# sourceMappingURL=on-event-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-event-controller.js","sources":["../../../../../../../../src/wirestate-lit/events/on-event-controller.ts"],"sourcesContent":[null],"names":["OnEventController","
|
|
1
|
+
{"version":3,"file":"on-event-controller.js","sources":["../../../../../../../../src/wirestate-lit/events/on-event-controller.ts"],"sourcesContent":[null],"names":["OnEventController","bus","unsubscriber","constructor","host","types","handler","addController","ContextConsumer","context","ContainerContext","subscribe","callback","container","get","EventBus","isConnected","resubscribe","hostConnected","hostDisconnected","cleanup","event","includes","type"],"mappings":";;;;AAUA;;;;;;;;AAQG;MACUA,iBAAiB,CAAA;AACpBC,EAAAA,GAAG,GAAuB,IAAI;AAC9BC,EAAAA,YAAY,GAAgC,IAAI;AAKxD;;;;AAIG;AACHC,EAAAA,WAAAA,CAAmBC,IAAqB,EAAEC,KAAyC,EAAEC,OAAwB,EAAA;AAG3GF,IAAAA,IAAI,CAACG,aAAa,CAAC,IAAI,CAAC;IAExB,IAAI,CAACF,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,OAAO,GAAGA,OAAO;IAEtB,IAAIE,eAAe,CAACJ,IAAI,EAAE;AACxBK,MAAAA,OAAO,EAAEC,gBAAgB;AACzBC,MAAAA,SAAS,EAAE,IAAI;MACfC,QAAQ,EAAGC,SAAS,IAAI;QACtB,IAAI,CAACZ,GAAG,GAAGY,SAAS,CAACC,GAAG,CAACC,QAAQ,CAAC;QAElC,IAAIX,IAAI,CAACY,WAAW,EAAE;UACpB,IAAI,CAACC,WAAW,EAAE;AACpB,QAAA;AACF,MAAA;AACD,KAAA,CAAC;AACJ,EAAA;AAEOC,EAAAA,aAAaA,GAAA;IAElB,IAAI,CAACD,WAAW,EAAE;AACpB,EAAA;AAEOE,EAAAA,gBAAgBA,GAAA;IAErB,IAAI,CAACC,OAAO,EAAE;AAChB,EAAA;AAEQH,EAAAA,WAAWA,GAAA;IACjB,IAAI,CAACG,OAAO,EAAE;IAEd,IAAI,IAAI,CAACnB,GAAG,EAAE;AAGZ,MAAA,IAAI,IAAI,CAACI,KAAK,KAAK,IAAI,EAAE;AACvB,QAAA,IAAI,CAACH,YAAY,GAAG,IAAI,CAACD,GAAG,CAACU,SAAS,CAAC,IAAI,CAACL,OAAuB,CAAC;AACtE,MAAA,CAAC,MAAM;QACL,IAAI,CAACJ,YAAY,GAAG,IAAI,CAACD,GAAG,CAACU,SAAS,CAAEU,KAAK,IAAI;UAC/C,IAAK,IAAI,CAAChB,KAAkC,CAACiB,QAAQ,CAACD,KAAK,CAACE,IAAI,CAAC,EAAE;AACjE,YAAA,IAAI,CAACjB,OAAO,CAACe,KAAU,CAAC;AAC1B,UAAA;AACF,QAAA,CAAC,CAAC;AACJ,MAAA;AACF,IAAA;AACF,EAAA;AAEQD,EAAAA,OAAOA,GAAA;IAGb,IAAI,CAAClB,YAAY,IAAI;IACrB,IAAI,CAACA,YAAY,GAAG,IAAI;AAC1B,EAAA;AACD;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __spreadArray } from 'tslib';
|
|
2
1
|
import { OnEventController } from './on-event-controller.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -43,22 +42,17 @@ import { OnEventController } from './on-event-controller.js';
|
|
|
43
42
|
* ```
|
|
44
43
|
*/
|
|
45
44
|
function onEvent(types) {
|
|
46
|
-
|
|
47
|
-
return
|
|
45
|
+
const normalized = types === undefined ? null : Array.isArray(types) ? [...types] : [types];
|
|
46
|
+
return (protoOrTarget, nameOrContext) => {
|
|
48
47
|
if (typeof nameOrContext === "object") {
|
|
49
48
|
// Standard decorators:
|
|
50
49
|
nameOrContext.addInitializer(function () {
|
|
51
|
-
|
|
52
|
-
new OnEventController(this, normalized, function (event) {
|
|
53
|
-
return _this[nameOrContext.name](event);
|
|
54
|
-
});
|
|
50
|
+
new OnEventController(this, normalized, event => this[nameOrContext.name](event));
|
|
55
51
|
});
|
|
56
52
|
} else {
|
|
57
53
|
// Experimental legacy decorators:
|
|
58
|
-
protoOrTarget.constructor.addInitializer(
|
|
59
|
-
new OnEventController(element, normalized,
|
|
60
|
-
return element[nameOrContext](event);
|
|
61
|
-
});
|
|
54
|
+
protoOrTarget.constructor.addInitializer(element => {
|
|
55
|
+
new OnEventController(element, normalized, event => element[nameOrContext](event));
|
|
62
56
|
});
|
|
63
57
|
}
|
|
64
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-event.js","sources":["../../../../../../../../src/wirestate-lit/events/on-event.ts"],"sourcesContent":[null],"names":["onEvent","types","normalized","undefined","Array","isArray","
|
|
1
|
+
{"version":3,"file":"on-event.js","sources":["../../../../../../../../src/wirestate-lit/events/on-event.ts"],"sourcesContent":[null],"names":["onEvent","types","normalized","undefined","Array","isArray","protoOrTarget","nameOrContext","addInitializer","OnEventController","event","name","constructor","element"],"mappings":";;AAyBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCG;AACG,SAAUA,OAAOA,CAA0BC,KAA4C,EAAA;EAC3F,MAAMC,UAAU,GACdD,KAAK,KAAKE,SAAS,GAAG,IAAI,GAAGC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,GAAG,CAAC,GAAIA,KAAkC,CAAC,GAAG,CAACA,KAAkB,CAAC;AAErH,EAAA,OAAQ,CAACK,aAAqB,EAAEC,aAAwD,KAAI;AAC1F,IAAA,IAAI,OAAOA,aAAa,KAAK,QAAQ,EAAE;AACrC;MACAA,aAAa,CAACC,cAAc,CAAC,YAAA;AAC3B,QAAA,IAAIC,iBAAiB,CAAC,IAAuB,EAAEP,UAAU,EAAGQ,KAAK,IAC9D,IAAkB,CAACH,aAAa,CAACI,IAAI,CAAC,CAACD,KAAK,CAAC,CAC/C;AACH,MAAA,CAAC,CAAC;AACJ,IAAA,CAAC,MAAM;AACL;AACCJ,MAAAA,aAAa,CAACM,WAAsC,CAACJ,cAAc,CAAEK,OAAwB,IAAU;AACtG,QAAA,IAAIJ,iBAAiB,CAACI,OAAO,EAAEX,UAAU,EAAGQ,KAAK,IAAMG,OAAqB,CAACN,aAAa,CAAC,CAACG,KAAK,CAAC,CAAC;AACrG,MAAA,CAAC,CAAC;AACJ,IAAA;EACF,CAAC;AACH;;;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __spreadArray } from 'tslib';
|
|
2
1
|
import { OnEventController } from './on-event-controller.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -31,10 +30,11 @@ import { OnEventController } from './on-event-controller.js';
|
|
|
31
30
|
* }
|
|
32
31
|
* ```
|
|
33
32
|
*/
|
|
34
|
-
function useOnEvents(host,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
function useOnEvents(host, {
|
|
34
|
+
types,
|
|
35
|
+
handler
|
|
36
|
+
}) {
|
|
37
|
+
const normalized = types ? Array.isArray(types) ? [...types] : [types] : null;
|
|
38
38
|
return new OnEventController(host, normalized, handler);
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-on-events.js","sources":["../../../../../../../../src/wirestate-lit/events/use-on-events.ts"],"sourcesContent":[null],"names":["useOnEvents","host","
|
|
1
|
+
{"version":3,"file":"use-on-events.js","sources":["../../../../../../../../src/wirestate-lit/events/use-on-events.ts"],"sourcesContent":[null],"names":["useOnEvents","host","types","handler","normalized","Array","isArray","OnEventController"],"mappings":";;AAuBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AACG,SAAUA,WAAWA,CACzBC,IAAqB,EACrB;EAAEC,KAAK;AAAEC,EAAAA;AAAO,CAAsB,EAAA;EAEtC,MAAMC,UAAU,GAAuCF,KAAK,GACxDG,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,GAClB,CAAC,GAAIA,KAAkC,CAAC,GACxC,CAACA,KAAkB,CAAC,GACtB,IAAI;EAER,OAAO,IAAIK,iBAAiB,CAAIN,IAAI,EAAEG,UAAU,EAAED,OAAO,CAAC;AAC5D;;;;"}
|
package/esm/development/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { injection } from './consumption/injection.js';
|
|
2
|
+
export { useContainer } from './consumption/use-container.js';
|
|
2
3
|
export { useInjection } from './consumption/use-injection.js';
|
|
4
|
+
export { useScope } from './consumption/use-scope.js';
|
|
3
5
|
export { onCommand } from './commands/on-command.js';
|
|
4
6
|
export { OnCommandController } from './commands/on-command-controller.js';
|
|
5
7
|
export { useOnCommand } from './commands/use-on-command.js';
|
|
@@ -9,11 +11,11 @@ export { useOnEvents } from './events/use-on-events.js';
|
|
|
9
11
|
export { onQuery } from './queries/on-query.js';
|
|
10
12
|
export { OnQueryController } from './queries/on-query-controller.js';
|
|
11
13
|
export { useOnQuery } from './queries/use-on-query.js';
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
14
|
+
export { ContainerContext } from './context/container-context.js';
|
|
15
|
+
export { ContainerProvider } from './provision/container-provider.js';
|
|
16
|
+
export { SubContainerProvider } from './provision/sub-container-provider.js';
|
|
17
|
+
export { containerProvide } from './provision/container-provide.js';
|
|
18
|
+
export { subContainerProvide } from './provision/sub-container-provide.js';
|
|
19
|
+
export { useContainerProvision } from './provision/use-container-provision.js';
|
|
20
|
+
export { useSubContainerProvider } from './provision/use-sub-container-provider.js';
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ContainerProvider } from './container-provider.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Decorator that provides an IoC container to child components.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* The container is provided via Lit context.
|
|
8
|
+
*
|
|
9
|
+
* - Pass `container` to expose an external container without taking
|
|
10
|
+
* ownership.
|
|
11
|
+
* - Pass `options` to create a managed container during construction,
|
|
12
|
+
* activate configured entries on connect, destroy it on disconnect, and
|
|
13
|
+
* recreate it on reconnect.
|
|
14
|
+
*
|
|
15
|
+
* @group Provision
|
|
16
|
+
*
|
|
17
|
+
* @param options - Provisioning options.
|
|
18
|
+
* @param options.container - External container instance to provide.
|
|
19
|
+
* @param options.options - Managed container creation options.
|
|
20
|
+
* @returns An instance of {@link ContainerProviderDecorator}.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* class MyRootElement extends LitElement {
|
|
25
|
+
* @containerProvide({
|
|
26
|
+
* options: {
|
|
27
|
+
* seed: { someData: "value" },
|
|
28
|
+
* entries: [LoggerService],
|
|
29
|
+
* },
|
|
30
|
+
* })
|
|
31
|
+
* private containerProvider!: ContainerProvider;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* class MyRootElement extends LitElement {
|
|
38
|
+
* @containerProvide({ container: container })
|
|
39
|
+
* private containerProvider!: ContainerProvider;
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
function containerProvide(options) {
|
|
44
|
+
return (protoOrTarget, nameOrContext) => {
|
|
45
|
+
if (typeof nameOrContext === "object") {
|
|
46
|
+
// Standard decorators:
|
|
47
|
+
nameOrContext.addInitializer(function () {
|
|
48
|
+
protoOrTarget.set.call(this, new ContainerProvider(this, options));
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
let controller;
|
|
52
|
+
protoOrTarget.constructor.addInitializer(element => {
|
|
53
|
+
controller = new ContainerProvider(element, options);
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
get() {
|
|
57
|
+
return controller;
|
|
58
|
+
},
|
|
59
|
+
set() {},
|
|
60
|
+
configurable: true,
|
|
61
|
+
enumerable: true
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { containerProvide };
|
|
68
|
+
//# sourceMappingURL=container-provide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-provide.js","sources":["../../../../../../../../src/wirestate-lit/provision/container-provide.ts"],"sourcesContent":[null],"names":["containerProvide","options","protoOrTarget","nameOrContext","addInitializer","set","call","ContainerProvider","controller","constructor","element","get","configurable","enumerable"],"mappings":";;AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCG;AACG,SAAUA,gBAAgBA,CAC9BC,OAAiC,EAAA;AAEjC,EAAA,OAAQ,CACNC,aAAkF,EAClFC,aAAiG,KAC/F;AACF,IAAA,IAAI,OAAOA,aAAa,KAAK,QAAQ,EAAE;AACrC;MACAA,aAAa,CAACC,cAAc,CAAC,YAAA;AAC3BF,QAAAA,aAAa,CAACG,GAAG,CAACC,IAAI,CAAC,IAAI,EAAE,IAAIC,iBAAiB,CAAC,IAAoB,EAAEN,OAAO,CAAC,CAAC;AACpF,MAAA,CAAC,CAAC;AACJ,IAAA,CAAC,MAAM;AACL,MAAA,IAAIO,UAAuC;AAE1CN,MAAAA,aAAa,CAACO,WAAsC,CAACL,cAAc,CAAEM,OAAwB,IAAU;AACtGF,QAAAA,UAAU,GAAG,IAAID,iBAAiB,CAACG,OAAY,EAAET,OAAO,CAAC;AAC3D,MAAA,CAAC,CAAC;MAEF,OAAO;AACLU,QAAAA,GAAGA,GAAA;AACD,UAAA,OAAOH,UAAkC;QAC3C,CAAC;QACDH,GAAGA,IAAU,CAAC;AACdO,QAAAA,YAAY,EAAE,IAAI;AAClBC,QAAAA,UAAU,EAAE;OACb;AACH,IAAA;EACF,CAAC;AACH;;;;"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ContextProvider } from '@lit/context';
|
|
2
|
+
import { WirestateError, createContainer } from '@wirestate/core';
|
|
3
|
+
import { ContainerContext } from '../context/container-context.js';
|
|
4
|
+
import { ERROR_CODE_INVALID_ARGUMENTS } from '../error/error-code.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Provider that exposes an IoC container context to the host element and its children.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* The provider supports two modes:
|
|
11
|
+
*
|
|
12
|
+
* - External mode: `container` is an existing {@link Container}. The
|
|
13
|
+
* provider passes it through context and does not alter its lifecycle.
|
|
14
|
+
* - Managed mode: `options` is {@link CreateContainerOptions}. The provider
|
|
15
|
+
* creates a container during construction without eager activation,
|
|
16
|
+
* activates configured entries when the host connects, disposes the
|
|
17
|
+
* container when the host disconnects, and recreates it on reconnect.
|
|
18
|
+
*
|
|
19
|
+
* @group Provision
|
|
20
|
+
*/
|
|
21
|
+
class ContainerProvider extends ContextProvider {
|
|
22
|
+
destroyed = false;
|
|
23
|
+
/**
|
|
24
|
+
* @param host - The host element.
|
|
25
|
+
* @param options - Provisioning options.
|
|
26
|
+
* @param options.container - External container instance to provide.
|
|
27
|
+
* @param options.options - Managed container creation options.
|
|
28
|
+
*/
|
|
29
|
+
constructor(host, options) {
|
|
30
|
+
if (!options.container && !options.options) {
|
|
31
|
+
throw new WirestateError(ERROR_CODE_INVALID_ARGUMENTS, "ContainerProvider requires a valid container instance or creation options.");
|
|
32
|
+
} else if (options.container && options.options) {
|
|
33
|
+
throw new WirestateError(ERROR_CODE_INVALID_ARGUMENTS, "ContainerProvider requires only container or valid options object to be provided.");
|
|
34
|
+
}
|
|
35
|
+
super(host, {
|
|
36
|
+
context: ContainerContext,
|
|
37
|
+
initialValue: options.container ? options.container : createContainer({
|
|
38
|
+
...options.options,
|
|
39
|
+
activate: []
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
this.options = options.options;
|
|
43
|
+
}
|
|
44
|
+
hostConnected() {
|
|
45
|
+
if (this.options) {
|
|
46
|
+
if (this.destroyed) {
|
|
47
|
+
this.value = createContainer(this.options);
|
|
48
|
+
this.destroyed = false;
|
|
49
|
+
} else {
|
|
50
|
+
if (this.options?.activate) {
|
|
51
|
+
for (const entry of this.options.activate) {
|
|
52
|
+
this.value.get(entry);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
super.hostConnected();
|
|
58
|
+
}
|
|
59
|
+
hostDisconnected() {
|
|
60
|
+
if (this.options) {
|
|
61
|
+
this.value.unbindAll();
|
|
62
|
+
this.destroyed = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { ContainerProvider };
|
|
68
|
+
//# sourceMappingURL=container-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-provider.js","sources":["../../../../../../../../src/wirestate-lit/provision/container-provider.ts"],"sourcesContent":[null],"names":["ContainerProvider","ContextProvider","destroyed","constructor","host","options","container","WirestateError","ERROR_CODE_INVALID_ARGUMENTS","context","ContainerContext","initialValue","createContainer","activate","hostConnected","value","entry","get","hostDisconnected","unbindAll"],"mappings":";;;;;AAyCA;;;;;;;;;;;;;;AAcG;AACG,MAAOA,iBACX,SAAQC,eAA2C,CAAA;AAKzCC,EAAAA,SAAS,GAAY,KAAK;AAEpC;;;;;AAKG;AACHC,EAAAA,WAAAA,CAAmBC,IAAO,EAAEC,OAAiC,EAAA;IAC3D,IAAI,CAACA,OAAO,CAACC,SAAS,IAAI,CAACD,OAAO,CAACA,OAAO,EAAE;AAC1C,MAAA,MAAM,IAAIE,cAAc,CACtBC,4BAA4B,EAC5B,4EAA4E,CAC7E;IACH,CAAC,MAAM,IAAIH,OAAO,CAACC,SAAS,IAAID,OAAO,CAACA,OAAO,EAAE;AAC/C,MAAA,MAAM,IAAIE,cAAc,CACtBC,4BAA4B,EAC5B,mFAAmF,CACpF;AACH,IAAA;IAEA,KAAK,CAACJ,IAAI,EAAE;AACVK,MAAAA,OAAO,EAAEC,gBAAgB;MACzBC,YAAY,EAAEN,OAAO,CAACC,SAAS,GAAGD,OAAO,CAACC,SAAS,GAAGM,eAAe,CAAC;QAAE,GAAGP,OAAO,CAACA,OAAO;AAAEQ,QAAAA,QAAQ,EAAE;OAAI;AAC3G,KAAA,CAAC;AAEF,IAAA,IAAI,CAACR,OAAO,GAAGA,OAAO,CAACA,OAAO;AAQhC,EAAA;AAEOS,EAAAA,aAAaA,GAAA;IAClB,IAAI,IAAI,CAACT,OAAO,EAAE;MAChB,IAAI,IAAI,CAACH,SAAS,EAAE;QAKlB,IAAI,CAACa,KAAK,GAAGH,eAAe,CAAC,IAAI,CAACP,OAAO,CAAC;QAC1C,IAAI,CAACH,SAAS,GAAG,KAAK;AACxB,MAAA,CAAC,MAAM;AACL,QAAA,IAAI,IAAI,CAACG,OAAO,EAAEQ,QAAQ,EAAE;UAK1B,KAAK,MAAMG,KAAK,IAAI,IAAI,CAACX,OAAO,CAACQ,QAAQ,EAAE;AACzC,YAAA,IAAI,CAACE,KAAK,CAACE,GAAG,CAACD,KAAK,CAAC;AACvB,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;IAEA,KAAK,CAACF,aAAa,EAAE;AACvB,EAAA;AAEOI,EAAAA,gBAAgBA,GAAA;IACrB,IAAI,IAAI,CAACb,OAAO,EAAE;AAKhB,MAAA,IAAI,CAACU,KAAK,CAACI,SAAS,EAAE;MACtB,IAAI,CAACjB,SAAS,GAAG,IAAI;AACvB,IAAA;AACF,EAAA;AACD;;;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { SubContainerProvider } from './sub-container-provider.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Decorator that provides a managed child container derived from the nearest
|
|
5
|
+
* parent container context.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The child container is created from the current parent context when the host
|
|
9
|
+
* connects, destroyed when it disconnects, and recreated when the parent
|
|
10
|
+
* container changes.
|
|
11
|
+
*
|
|
12
|
+
* @group Provision
|
|
13
|
+
*
|
|
14
|
+
* @param options - Provisioning options.
|
|
15
|
+
* @param options.options - Child-container creation options.
|
|
16
|
+
* @returns An instance of {@link SubContainerProviderDecorator}.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* class MyComponent extends LitElement {
|
|
21
|
+
* @subContainerProvide({
|
|
22
|
+
* options: {
|
|
23
|
+
* entries: [AuthService, UserService],
|
|
24
|
+
* activate: [AuthService],
|
|
25
|
+
* },
|
|
26
|
+
* })
|
|
27
|
+
* public containerProvider!: SubContainerProvider<MyComponent>;
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function subContainerProvide(options) {
|
|
32
|
+
return (protoOrTarget, nameOrContext) => {
|
|
33
|
+
if (typeof nameOrContext === "object") {
|
|
34
|
+
// Standard decorators:
|
|
35
|
+
nameOrContext.addInitializer(function () {
|
|
36
|
+
protoOrTarget.set.call(this, new SubContainerProvider(this, options));
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
let provider;
|
|
40
|
+
protoOrTarget.constructor.addInitializer(element => {
|
|
41
|
+
provider = new SubContainerProvider(element, options);
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
get() {
|
|
45
|
+
return provider;
|
|
46
|
+
},
|
|
47
|
+
set() {},
|
|
48
|
+
configurable: true,
|
|
49
|
+
enumerable: true
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { subContainerProvide };
|
|
56
|
+
//# sourceMappingURL=sub-container-provide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sub-container-provide.js","sources":["../../../../../../../../src/wirestate-lit/provision/sub-container-provide.ts"],"sourcesContent":[null],"names":["subContainerProvide","options","protoOrTarget","nameOrContext","addInitializer","set","call","SubContainerProvider","provider","constructor","element","get","configurable","enumerable"],"mappings":";;AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACG,SAAUA,mBAAmBA,CACjCC,OAAoC,EAAA;AAEpC,EAAA,OAAQ,CACNC,aAAmG,EACnGC,aAAkH,KAChH;AACF,IAAA,IAAI,OAAOA,aAAa,KAAK,QAAQ,EAAE;AACrC;MACAA,aAAa,CAACC,cAAc,CAAC,YAAA;AAC3BF,QAAAA,aAAa,CAACG,GAAG,CAACC,IAAI,CAAC,IAAI,EAAE,IAAIC,oBAAoB,CAAC,IAAuB,EAAEN,OAAO,CAAC,CAAC;AAC1F,MAAA,CAAC,CAAC;AACJ,IAAA,CAAC,MAAM;AACL,MAAA,IAAIO,QAAwC;AAE3CN,MAAAA,aAAa,CAACO,WAAsC,CAACL,cAAc,CAAEM,OAAwB,IAAU;AACtGF,QAAAA,QAAQ,GAAG,IAAID,oBAAoB,CAACG,OAAY,EAAET,OAAO,CAAC;AAC5D,MAAA,CAAC,CAAC;MAEF,OAAO;AACLU,QAAAA,GAAGA,GAAA;AACD,UAAA,OAAOH,QAAmC;QAC5C,CAAC;QACDH,GAAGA,IAAU,CAAC;AACdO,QAAAA,YAAY,EAAE,IAAI;AAClBC,QAAAA,UAAU,EAAE;OACb;AACH,IAAA;EACF,CAAC;AACH;;;;"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ContextProvider, ContextConsumer } from '@lit/context';
|
|
2
|
+
import { createContainer } from '@wirestate/core';
|
|
3
|
+
import { ContainerContext } from '../context/container-context.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provider that exposes a managed child container for the host element's lifetime.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* The provider always owns a child container derived from the nearest parent
|
|
10
|
+
* {@link ContainerContext}. When connected, it creates a child container using
|
|
11
|
+
* the latest parent context, provides it to descendants, destroys it when the
|
|
12
|
+
* host disconnects, and replaces it whenever the parent container changes.
|
|
13
|
+
*
|
|
14
|
+
* @group Provision
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* class MyComponent extends LitElement {
|
|
19
|
+
* private container = new SubContainerProvider(this, {
|
|
20
|
+
* options: {
|
|
21
|
+
* entries: [AuthService, UserService],
|
|
22
|
+
* activate: [AuthService],
|
|
23
|
+
* seeds: [[AuthService, { role: "admin" }]],
|
|
24
|
+
* },
|
|
25
|
+
* });
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
class SubContainerProvider extends ContextProvider {
|
|
30
|
+
parent = null;
|
|
31
|
+
destroyed = true;
|
|
32
|
+
/**
|
|
33
|
+
* @param host - The host element.
|
|
34
|
+
* @param options - Provisioning options, including child entries, eager activations, and seeds.
|
|
35
|
+
*/
|
|
36
|
+
constructor(host, options) {
|
|
37
|
+
super(host, {
|
|
38
|
+
context: ContainerContext
|
|
39
|
+
});
|
|
40
|
+
this.options = options.options;
|
|
41
|
+
this.consumer = new ContextConsumer(host, {
|
|
42
|
+
context: ContainerContext,
|
|
43
|
+
subscribe: true,
|
|
44
|
+
callback: context => {
|
|
45
|
+
const previousParent = this.parent;
|
|
46
|
+
this.parent = context;
|
|
47
|
+
if (host.isConnected) {
|
|
48
|
+
if (this.destroyed || !this.value || previousParent !== context) {
|
|
49
|
+
this.destroyContainer();
|
|
50
|
+
this.createContainer();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
hostConnected() {
|
|
57
|
+
if (this.parent && (this.destroyed || !this.value)) {
|
|
58
|
+
this.destroyContainer();
|
|
59
|
+
this.createContainer();
|
|
60
|
+
}
|
|
61
|
+
super.hostConnected();
|
|
62
|
+
}
|
|
63
|
+
hostDisconnected() {
|
|
64
|
+
this.destroyContainer();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Replaces the currently provided child container with a new one derived
|
|
68
|
+
* from the latest parent context.
|
|
69
|
+
*/
|
|
70
|
+
createContainer() {
|
|
71
|
+
const container = createContainer({
|
|
72
|
+
...this.options,
|
|
73
|
+
parent: this.parent
|
|
74
|
+
});
|
|
75
|
+
this.destroyed = false;
|
|
76
|
+
this.value = container;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Destroys the currently provided child container.
|
|
80
|
+
*/
|
|
81
|
+
destroyContainer() {
|
|
82
|
+
if (this.value && !this.destroyed) {
|
|
83
|
+
this.value.unbindAll();
|
|
84
|
+
this.destroyed = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { SubContainerProvider };
|
|
90
|
+
//# sourceMappingURL=sub-container-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sub-container-provider.js","sources":["../../../../../../../../src/wirestate-lit/provision/sub-container-provider.ts"],"sourcesContent":[null],"names":["SubContainerProvider","ContextProvider","parent","destroyed","constructor","host","options","context","ContainerContext","consumer","ContextConsumer","subscribe","callback","previousParent","isConnected","value","destroyContainer","createContainer","hostConnected","hostDisconnected","container","unbindAll"],"mappings":";;;;AAkDA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,MAAOA,oBACX,SAAQC,eAA2C,CAAA;AAMzCC,EAAAA,MAAM,GAAqB,IAAI;AAC/BC,EAAAA,SAAS,GAAY,IAAI;AAEnC;;;AAGG;AACHC,EAAAA,WAAAA,CAAmBC,IAAO,EAAEC,OAAoC,EAAA;IAC9D,KAAK,CAACD,IAAI,EAAE;AACVE,MAAAA,OAAO,EAAEC;AACV,KAAA,CAAC;AAIF,IAAA,IAAI,CAACF,OAAO,GAAGA,OAAO,CAACA,OAAO;AAE9B,IAAA,IAAI,CAACG,QAAQ,GAAG,IAAIC,eAAe,CAACL,IAAI,EAAE;AACxCE,MAAAA,OAAO,EAAEC,gBAAgB;AACzBG,MAAAA,SAAS,EAAE,IAAI;MACfC,QAAQ,EAAGL,OAAkB,IAAI;AAC/B,QAAA,MAAMM,cAAc,GAAqB,IAAI,CAACX,MAAM;QAEpD,IAAI,CAACA,MAAM,GAAGK,OAAO;QAErB,IAAIF,IAAI,CAACS,WAAW,EAAE;AAMpB,UAAA,IAAI,IAAI,CAACX,SAAS,IAAI,CAAC,IAAI,CAACY,KAAK,IAAIF,cAAc,KAAKN,OAAO,EAAE;YAC/D,IAAI,CAACS,gBAAgB,EAAE;YACvB,IAAI,CAACC,eAAe,EAAE;AACxB,UAAA;AACF,QAAA;AAMF,MAAA;AACD,KAAA,CAAC;AACJ,EAAA;AAEOC,EAAAA,aAAaA,GAAA;AAOlB,IAAA,IAAI,IAAI,CAAChB,MAAM,KAAK,IAAI,CAACC,SAAS,IAAI,CAAC,IAAI,CAACY,KAAK,CAAC,EAAE;MAClD,IAAI,CAACC,gBAAgB,EAAE;MACvB,IAAI,CAACC,eAAe,EAAE;AACxB,IAAA;IAEA,KAAK,CAACC,aAAa,EAAE;AACvB,EAAA;AAEOC,EAAAA,gBAAgBA,GAAA;IAOrB,IAAI,CAACH,gBAAgB,EAAE;AACzB,EAAA;AAEA;;;AAGG;AACOC,EAAAA,eAAeA,GAAA;IACvB,MAAMG,SAAS,GAAcH,eAAe,CAAC;MAC3C,GAAG,IAAI,CAACX,OAAO;MACfJ,MAAM,EAAE,IAAI,CAACA;AACd,KAAA,CAAC;IAQF,IAAI,CAACC,SAAS,GAAG,KAAK;IACtB,IAAI,CAACY,KAAK,GAAGK,SAAS;AACxB,EAAA;AAEA;;AAEG;AACOJ,EAAAA,gBAAgBA,GAAA;IACxB,IAAI,IAAI,CAACD,KAAK,IAAI,CAAC,IAAI,CAACZ,SAAS,EAAE;AAMjC,MAAA,IAAI,CAACY,KAAK,CAACM,SAAS,EAAE;MACtB,IAAI,CAAClB,SAAS,GAAG,IAAI;AACvB,IAAA;AACF,EAAA;AACD;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ContainerProvider } from './container-provider.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook that provides a container to the host element and its children.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Pass `container` to expose an external `Container` without taking
|
|
8
|
+
* ownership. Pass `options` to create a managed container during
|
|
9
|
+
* construction, activate configured entries on connect, destroy it on
|
|
10
|
+
* disconnect, and recreate it on reconnect.
|
|
11
|
+
*
|
|
12
|
+
* @group Provision
|
|
13
|
+
*
|
|
14
|
+
* @param host - The host element.
|
|
15
|
+
* @param options - Provisioning options.
|
|
16
|
+
* @param options.container - External container instance to provide.
|
|
17
|
+
* @param options.options - Managed container creation options.
|
|
18
|
+
* @returns An instance of {@link ContainerProvider}.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* class MyRootElement extends LitElement {
|
|
23
|
+
* private containerProvider: ContainerProvider = useContainerProvision(this, {
|
|
24
|
+
* options: {
|
|
25
|
+
* entries: [LoggerService],
|
|
26
|
+
* activate: [LoggerService],
|
|
27
|
+
* },
|
|
28
|
+
* });
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* class MyRootElement extends LitElement {
|
|
35
|
+
* private containerProvider: ContainerProvider = useContainerProvision(this, { container: container });
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
function useContainerProvision(host, options) {
|
|
40
|
+
return new ContainerProvider(host, options);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { useContainerProvision };
|
|
44
|
+
//# sourceMappingURL=use-container-provision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-container-provision.js","sources":["../../../../../../../../src/wirestate-lit/provision/use-container-provision.ts"],"sourcesContent":[null],"names":["useContainerProvision","host","options","ContainerProvider"],"mappings":";;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;AACG,SAAUA,qBAAqBA,CACnCC,IAAO,EACPC,OAAqC,EAAA;AAErC,EAAA,OAAO,IAAIC,iBAAiB,CAACF,IAAI,EAAEC,OAAO,CAAC;AAC7C;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SubContainerProvider } from './sub-container-provider.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook that provides a managed child container for the host element's lifetime.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* The child container is derived from the current parent
|
|
8
|
+
* {@link ContainerContext}, recreated when that parent context changes, and
|
|
9
|
+
* destroyed when the host disconnects.
|
|
10
|
+
*
|
|
11
|
+
* @group Provision
|
|
12
|
+
*
|
|
13
|
+
* @param host - The host element.
|
|
14
|
+
* @param options - Provisioning options.
|
|
15
|
+
* @param options.options - Child-container creation options.
|
|
16
|
+
* @returns An instance of {@link SubContainerProvider}.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* class MyComponent extends LitElement {
|
|
21
|
+
* private containerProvider: SubContainerProvider = useSubContainerProvider(this, {
|
|
22
|
+
* options: {
|
|
23
|
+
* entries: [AuthService, UserService],
|
|
24
|
+
* },
|
|
25
|
+
* });
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function useSubContainerProvider(host, options) {
|
|
30
|
+
return new SubContainerProvider(host, options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { useSubContainerProvider };
|
|
34
|
+
//# sourceMappingURL=use-sub-container-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-sub-container-provider.js","sources":["../../../../../../../../src/wirestate-lit/provision/use-sub-container-provider.ts"],"sourcesContent":[null],"names":["useSubContainerProvider","host","options","SubContainerProvider"],"mappings":";;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACG,SAAUA,uBAAuBA,CACrCC,IAAO,EACPC,OAAoC,EAAA;AAEpC,EAAA,OAAO,IAAIC,oBAAoB,CAAIF,IAAI,EAAEC,OAAO,CAAC;AACnD;;;;"}
|