@wirestate/lit 0.6.1 → 0.7.0-experimental.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/README.md +44 -44
- package/cjs/development/index.js +136 -129
- 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 +7 -6
- package/esm/development/commands/on-command-controller.js.map +1 -1
- package/esm/development/commands/on-command.js +7 -6
- package/esm/development/commands/on-command.js.map +1 -1
- package/esm/development/commands/use-on-command.js +7 -7
- package/esm/development/consumption/injection.js +6 -6
- package/esm/development/consumption/injection.js.map +1 -1
- package/esm/development/consumption/use-injection.js +7 -7
- package/esm/development/consumption/use-injection.js.map +1 -1
- package/esm/development/context/ioc-context.js +6 -6
- package/esm/development/context/ioc-context.js.map +1 -1
- package/esm/development/events/on-event-controller.js +10 -8
- package/esm/development/events/on-event-controller.js.map +1 -1
- package/esm/development/events/on-event.js +11 -8
- package/esm/development/events/on-event.js.map +1 -1
- package/esm/development/events/use-on-events.js +8 -8
- package/esm/development/index.js +1 -1
- package/esm/development/provision/injectables-provide.js +5 -5
- package/esm/development/provision/injectables-provide.js.map +1 -1
- package/esm/development/provision/injectables-provider-controller.js +14 -14
- package/esm/development/provision/injectables-provider-controller.js.map +1 -1
- package/esm/development/provision/ioc-provide.js +10 -7
- package/esm/development/provision/ioc-provide.js.map +1 -1
- package/esm/development/provision/ioc-provider-controller.js +13 -10
- package/esm/development/provision/ioc-provider-controller.js.map +1 -1
- package/esm/development/provision/use-injectables-provider.js +5 -11
- package/esm/development/provision/use-injectables-provider.js.map +1 -1
- package/esm/development/provision/use-ioc-provision.js +6 -8
- package/esm/development/provision/use-ioc-provision.js.map +1 -1
- package/esm/development/queries/on-query-controller.js +8 -7
- package/esm/development/queries/on-query-controller.js.map +1 -1
- package/esm/development/queries/on-query.js +7 -6
- package/esm/development/queries/on-query.js.map +1 -1
- package/esm/development/queries/use-on-query.js +7 -7
- 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.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-injection.js +1 -1
- package/esm/production/consumption/use-injection.js.map +1 -1
- package/esm/production/context/ioc-context.js +1 -1
- package/esm/production/context/ioc-context.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.map +1 -1
- package/esm/production/index.js +1 -1
- package/esm/production/provision/injectables-provide.js.map +1 -1
- package/esm/production/provision/injectables-provider-controller.js +1 -1
- package/esm/production/provision/injectables-provider-controller.js.map +1 -1
- package/esm/production/provision/ioc-provide.js.map +1 -1
- package/esm/production/provision/ioc-provider-controller.js +1 -1
- package/esm/production/provision/ioc-provider-controller.js.map +1 -1
- package/esm/production/provision/use-injectables-provider.js.map +1 -1
- package/esm/production/provision/use-ioc-provision.js.map +1 -1
- 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.map +1 -1
- package/index.d.ts +199 -172
- package/package.json +1 -1
package/cjs/development/index.js
CHANGED
|
@@ -5,25 +5,25 @@ var core = require('@wirestate/core');
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Unique symbol used as a key for the IoC context.
|
|
9
9
|
*
|
|
10
|
-
* @group
|
|
10
|
+
* @group Context
|
|
11
11
|
*/
|
|
12
12
|
var IOC_CONTAINER_KEY = Symbol("ContainerContext");
|
|
13
13
|
/**
|
|
14
|
-
* Lit context for providing and consuming the IoC container.
|
|
14
|
+
* Lit context object for providing and consuming the IoC container.
|
|
15
15
|
*
|
|
16
|
-
* @group
|
|
16
|
+
* @group Context
|
|
17
17
|
*/
|
|
18
|
-
var
|
|
18
|
+
var IocContextObject = context.createContext(IOC_CONTAINER_KEY);
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Decorator to inject a service from the IoC container into a Lit element property.
|
|
22
22
|
*
|
|
23
|
-
* @group
|
|
23
|
+
* @group Consumption
|
|
24
24
|
*
|
|
25
|
-
* @param optionsOrInjectionId -
|
|
26
|
-
* @returns
|
|
25
|
+
* @param optionsOrInjectionId - Injection options or service identifier.
|
|
26
|
+
* @returns An instance of {@link InjectionDecorator}.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* ```typescript
|
|
@@ -61,7 +61,7 @@ function injection(optionsOrInjectionId) {
|
|
|
61
61
|
nameOrContext.addInitializer(function () {
|
|
62
62
|
var _this = this;
|
|
63
63
|
new context.ContextConsumer(this, {
|
|
64
|
-
context:
|
|
64
|
+
context: IocContextObject,
|
|
65
65
|
callback: function (it) {
|
|
66
66
|
protoOrTarget.set.call(_this, it.container.get(injectionId));
|
|
67
67
|
},
|
|
@@ -72,7 +72,7 @@ function injection(optionsOrInjectionId) {
|
|
|
72
72
|
// Experimental decorators branch.
|
|
73
73
|
protoOrTarget.constructor.addInitializer(function (element) {
|
|
74
74
|
new context.ContextConsumer(element, {
|
|
75
|
-
context:
|
|
75
|
+
context: IocContextObject,
|
|
76
76
|
callback: function (it) {
|
|
77
77
|
element[nameOrContext] = it.container.get(injectionId);
|
|
78
78
|
},
|
|
@@ -84,13 +84,13 @@ function injection(optionsOrInjectionId) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* Hook (controller) to inject a service from the IoC container
|
|
87
|
+
* Hook (controller) to inject a service from the IoC container.
|
|
88
88
|
*
|
|
89
|
-
* @group
|
|
89
|
+
* @group Consumption
|
|
90
90
|
*
|
|
91
|
-
* @param host -
|
|
92
|
-
* @param optionsOrInjectionId -
|
|
93
|
-
* @returns
|
|
91
|
+
* @param host - The host element.
|
|
92
|
+
* @param optionsOrInjectionId - Injection options or service identifier.
|
|
93
|
+
* @returns An instance of {@link UseInjectionValue}.
|
|
94
94
|
*
|
|
95
95
|
* @example
|
|
96
96
|
* ```typescript
|
|
@@ -126,7 +126,7 @@ function useInjection(host, optionsOrInjectionId) {
|
|
|
126
126
|
injectionId: injectionId
|
|
127
127
|
};
|
|
128
128
|
new context.ContextConsumer(host, {
|
|
129
|
-
context:
|
|
129
|
+
context: IocContextObject,
|
|
130
130
|
subscribe: !once,
|
|
131
131
|
callback: function (it) {
|
|
132
132
|
current.value = it.container.get(injectionId);
|
|
@@ -136,17 +136,18 @@ function useInjection(host, optionsOrInjectionId) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
|
-
*
|
|
139
|
+
* Controller that registers a command handler for the host element's lifetime.
|
|
140
140
|
*
|
|
141
|
+
* @remarks
|
|
141
142
|
* The handler is registered when the host connects and unregistered when it disconnects.
|
|
142
|
-
*
|
|
143
|
+
* It automatically re-registers if the IoC container is updated.
|
|
143
144
|
*
|
|
144
|
-
* @group
|
|
145
|
+
* @group Commands
|
|
145
146
|
*/
|
|
146
147
|
var OnCommandController = /** @class */function () {
|
|
147
148
|
/**
|
|
148
149
|
* @param host - The host element.
|
|
149
|
-
* @param type -
|
|
150
|
+
* @param type - Unique identifier of the command to handle.
|
|
150
151
|
* @param handler - The command handler function.
|
|
151
152
|
*/
|
|
152
153
|
function OnCommandController(host, type, handler) {
|
|
@@ -157,7 +158,7 @@ var OnCommandController = /** @class */function () {
|
|
|
157
158
|
this.type = type;
|
|
158
159
|
this.handler = handler;
|
|
159
160
|
new context.ContextConsumer(host, {
|
|
160
|
-
context:
|
|
161
|
+
context: IocContextObject,
|
|
161
162
|
subscribe: true,
|
|
162
163
|
callback: function (context) {
|
|
163
164
|
_this.bus = context.container.get(core.CommandBus);
|
|
@@ -188,20 +189,21 @@ var OnCommandController = /** @class */function () {
|
|
|
188
189
|
}();
|
|
189
190
|
|
|
190
191
|
/**
|
|
191
|
-
* Decorator
|
|
192
|
+
* Decorator for Lit element methods that handle a specific command.
|
|
192
193
|
*
|
|
193
|
-
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* The handler is registered when the host connects and unregistered when it disconnects.
|
|
194
196
|
*
|
|
195
|
-
* @group
|
|
197
|
+
* @group Commands
|
|
196
198
|
*
|
|
197
|
-
* @param type - the command
|
|
198
|
-
* @returns
|
|
199
|
+
* @param type - Unique identifier of the command to handle.
|
|
200
|
+
* @returns A method decorator function.
|
|
199
201
|
*
|
|
200
202
|
* @example
|
|
201
203
|
* ```typescript
|
|
202
204
|
* class MyElement extends LitElement {
|
|
203
205
|
* @onCommand("SAVE")
|
|
204
|
-
* private
|
|
206
|
+
* private onSave(data: SomeData): void {
|
|
205
207
|
* // handle command
|
|
206
208
|
* }
|
|
207
209
|
* }
|
|
@@ -229,15 +231,15 @@ function onCommand(type) {
|
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
/**
|
|
232
|
-
*
|
|
234
|
+
* Hook that registers a command handler for the host element's lifetime.
|
|
233
235
|
*
|
|
234
|
-
* @group
|
|
236
|
+
* @group Commands
|
|
235
237
|
*
|
|
236
|
-
* @param host -
|
|
237
|
-
* @param options -
|
|
238
|
-
* @param options.type -
|
|
239
|
-
* @param options.handler -
|
|
240
|
-
* @returns
|
|
238
|
+
* @param host - The host element.
|
|
239
|
+
* @param options - Command handling options.
|
|
240
|
+
* @param options.type - The command type to listen for.
|
|
241
|
+
* @param options.handler - The command handler function.
|
|
242
|
+
* @returns The command controller instance.
|
|
241
243
|
*
|
|
242
244
|
* @example
|
|
243
245
|
* ```typescript
|
|
@@ -256,17 +258,19 @@ function useOnCommand(host, _a) {
|
|
|
256
258
|
}
|
|
257
259
|
|
|
258
260
|
/**
|
|
259
|
-
* Controller that subscribes to events
|
|
261
|
+
* Controller that subscribes to events for the host element's lifetime.
|
|
260
262
|
*
|
|
261
|
-
*
|
|
263
|
+
* @remarks
|
|
264
|
+
* The handler is registered when the host connects and unregistered when it disconnects.
|
|
265
|
+
* It automatically re-subscribes if the IoC container is updated.
|
|
262
266
|
*
|
|
263
|
-
* @group
|
|
267
|
+
* @group Events
|
|
264
268
|
*/
|
|
265
269
|
var OnEventController = /** @class */function () {
|
|
266
270
|
/**
|
|
267
|
-
* @param host -
|
|
268
|
-
* @param types -
|
|
269
|
-
* @param handler -
|
|
271
|
+
* @param host - The host element.
|
|
272
|
+
* @param types - Event types to listen for. If null, all events will be handled.
|
|
273
|
+
* @param handler - The event handler function.
|
|
270
274
|
*/
|
|
271
275
|
function OnEventController(host, types, handler) {
|
|
272
276
|
var _this = this;
|
|
@@ -276,7 +280,7 @@ var OnEventController = /** @class */function () {
|
|
|
276
280
|
this.types = types;
|
|
277
281
|
this.handler = handler;
|
|
278
282
|
new context.ContextConsumer(host, {
|
|
279
|
-
context:
|
|
283
|
+
context: IocContextObject,
|
|
280
284
|
subscribe: true,
|
|
281
285
|
callback: function (context) {
|
|
282
286
|
_this.bus = context.container.get(core.EventBus);
|
|
@@ -316,19 +320,22 @@ var OnEventController = /** @class */function () {
|
|
|
316
320
|
}();
|
|
317
321
|
|
|
318
322
|
/**
|
|
319
|
-
* Decorator
|
|
323
|
+
* Decorator for Lit element methods that handle events from the event bus.
|
|
320
324
|
*
|
|
321
|
-
* @
|
|
325
|
+
* @remarks
|
|
326
|
+
* The handler is registered when the host connects and unregistered when it disconnects.
|
|
327
|
+
*
|
|
328
|
+
* @group Events
|
|
322
329
|
*
|
|
323
330
|
* @param types - Event types to listen for. If omitted, all events will be handled.
|
|
324
|
-
* @returns
|
|
331
|
+
* @returns A method decorator function.
|
|
325
332
|
*
|
|
326
333
|
* @example
|
|
327
334
|
* ```typescript
|
|
328
335
|
* class MyElement extends LitElement {
|
|
329
336
|
* @onEvent()
|
|
330
337
|
* private onMyEvent(event: Event) {
|
|
331
|
-
* console.log(
|
|
338
|
+
* console.log("Event received:", event);
|
|
332
339
|
* }
|
|
333
340
|
* }
|
|
334
341
|
* ```
|
|
@@ -336,9 +343,9 @@ var OnEventController = /** @class */function () {
|
|
|
336
343
|
* @example
|
|
337
344
|
* ```typescript
|
|
338
345
|
* class MyElement extends LitElement {
|
|
339
|
-
* @onEvent(
|
|
346
|
+
* @onEvent("MY_EVENT_TYPE")
|
|
340
347
|
* private onMyEvent(event: MyEvent) {
|
|
341
|
-
* console.log(
|
|
348
|
+
* console.log("Event received:", event);
|
|
342
349
|
* }
|
|
343
350
|
* }
|
|
344
351
|
* ```
|
|
@@ -346,9 +353,9 @@ var OnEventController = /** @class */function () {
|
|
|
346
353
|
* @example
|
|
347
354
|
* ```typescript
|
|
348
355
|
* class MyElement extends LitElement {
|
|
349
|
-
* @onEvent([
|
|
356
|
+
* @onEvent(["MY_EVENT_TYPE_1", "MY_EVENT_TYPE_2"])
|
|
350
357
|
* private onMyEvent(event: Event) {
|
|
351
|
-
* console.log(
|
|
358
|
+
* console.log("Event received:", event);
|
|
352
359
|
* }
|
|
353
360
|
* }
|
|
354
361
|
* ```
|
|
@@ -376,15 +383,15 @@ function onEvent(types) {
|
|
|
376
383
|
}
|
|
377
384
|
|
|
378
385
|
/**
|
|
379
|
-
* Hook
|
|
386
|
+
* Hook that subscribes to events for the host element's lifetime.
|
|
380
387
|
*
|
|
381
|
-
* @group
|
|
388
|
+
* @group Events
|
|
382
389
|
*
|
|
383
|
-
* @param host -
|
|
384
|
-
* @param options -
|
|
385
|
-
* @param options.handler -
|
|
386
|
-
* @param options.types -
|
|
387
|
-
* @returns
|
|
390
|
+
* @param host - The host element.
|
|
391
|
+
* @param options - Event handling options.
|
|
392
|
+
* @param options.handler - Event handler function.
|
|
393
|
+
* @param options.types - Event types to listen for, if null or undefined, all events will be handled.
|
|
394
|
+
* @returns An instance of {@link OnEventController}.
|
|
388
395
|
*
|
|
389
396
|
* @example
|
|
390
397
|
* ```typescript
|
|
@@ -399,7 +406,7 @@ function onEvent(types) {
|
|
|
399
406
|
* ```typescript
|
|
400
407
|
* class MyElement extends LitElement {
|
|
401
408
|
* private eventHandler = useOnEvents(this, {
|
|
402
|
-
* types: [
|
|
409
|
+
* types: ["MY_EVENT"],
|
|
403
410
|
* handler: (event) => console.log(event),
|
|
404
411
|
* });
|
|
405
412
|
* }
|
|
@@ -415,16 +422,17 @@ function useOnEvents(host, _a) {
|
|
|
415
422
|
/**
|
|
416
423
|
* Reactive controller that registers a query handler on the {@link QueryBus} for the host element's lifetime.
|
|
417
424
|
*
|
|
425
|
+
* @remarks
|
|
418
426
|
* The handler is registered when the host connects and unregistered when it disconnects.
|
|
419
|
-
*
|
|
427
|
+
* It automatically re-registers if the IoC container is updated.
|
|
420
428
|
*
|
|
421
|
-
* @group
|
|
429
|
+
* @group Queries
|
|
422
430
|
*/
|
|
423
431
|
var OnQueryController = /** @class */function () {
|
|
424
432
|
/**
|
|
425
|
-
* @param host -
|
|
426
|
-
* @param type - the query
|
|
427
|
-
* @param handler -
|
|
433
|
+
* @param host - The host element.
|
|
434
|
+
* @param type - Unique identifier of the query to handle.
|
|
435
|
+
* @param handler - The query handler function.
|
|
428
436
|
*/
|
|
429
437
|
function OnQueryController(host, type, handler) {
|
|
430
438
|
var _this = this;
|
|
@@ -434,7 +442,7 @@ var OnQueryController = /** @class */function () {
|
|
|
434
442
|
this.type = type;
|
|
435
443
|
this.handler = handler;
|
|
436
444
|
new context.ContextConsumer(host, {
|
|
437
|
-
context:
|
|
445
|
+
context: IocContextObject,
|
|
438
446
|
subscribe: true,
|
|
439
447
|
callback: function (context) {
|
|
440
448
|
_this.bus = context.container.get(core.QueryBus);
|
|
@@ -465,20 +473,21 @@ var OnQueryController = /** @class */function () {
|
|
|
465
473
|
}();
|
|
466
474
|
|
|
467
475
|
/**
|
|
468
|
-
* Decorator
|
|
476
|
+
* Decorator for Lit element methods that handle a specific query.
|
|
469
477
|
*
|
|
470
|
-
*
|
|
478
|
+
* @remarks
|
|
479
|
+
* The handler is registered when the host connects and unregistered when it disconnects.
|
|
471
480
|
*
|
|
472
|
-
* @group
|
|
481
|
+
* @group Queries
|
|
473
482
|
*
|
|
474
|
-
* @param type - the query
|
|
475
|
-
* @returns
|
|
483
|
+
* @param type - Unique identifier of the query to handle.
|
|
484
|
+
* @returns A method decorator function.
|
|
476
485
|
*
|
|
477
486
|
* @example
|
|
478
487
|
* ```typescript
|
|
479
488
|
* class MyElement extends LitElement {
|
|
480
489
|
* @onQuery("GET_USER_NAME")
|
|
481
|
-
*
|
|
490
|
+
* private onGetUserName(data: QueryData) {
|
|
482
491
|
* return "Alice";
|
|
483
492
|
* }
|
|
484
493
|
* }
|
|
@@ -506,15 +515,15 @@ function onQuery(type) {
|
|
|
506
515
|
}
|
|
507
516
|
|
|
508
517
|
/**
|
|
509
|
-
*
|
|
518
|
+
* Hook that registers a query handler for the host element's lifetime.
|
|
510
519
|
*
|
|
511
|
-
* @group
|
|
520
|
+
* @group Queries
|
|
512
521
|
*
|
|
513
|
-
* @param host -
|
|
514
|
-
* @param options -
|
|
515
|
-
* @param options.type -
|
|
516
|
-
* @param options.handler -
|
|
517
|
-
* @returns
|
|
522
|
+
* @param host - The host element.
|
|
523
|
+
* @param options - Query handling options.
|
|
524
|
+
* @param options.type - The query type to handle.
|
|
525
|
+
* @param options.handler - The query handler function.
|
|
526
|
+
* @returns An instance of {@link OnQueryController}.
|
|
518
527
|
*
|
|
519
528
|
* @example
|
|
520
529
|
* ```typescript
|
|
@@ -535,16 +544,19 @@ function useOnQuery(host, _a) {
|
|
|
535
544
|
/**
|
|
536
545
|
* Controller that provides an IoC container context to the host element and its children.
|
|
537
546
|
*
|
|
547
|
+
* @remarks
|
|
538
548
|
* It manages the lifecycle of the container and handles revision updates to notify consumers.
|
|
549
|
+
* The container is created (or used from options) when the controller is instantiated.
|
|
550
|
+
* Seed data is applied when the host connects.
|
|
539
551
|
*
|
|
540
|
-
* @group
|
|
552
|
+
* @group Provision
|
|
541
553
|
*/
|
|
542
554
|
var IocProviderController = /** @class */function () {
|
|
543
555
|
/**
|
|
544
|
-
* @param host -
|
|
545
|
-
* @param options -
|
|
546
|
-
* @param options.container -
|
|
547
|
-
* @param options.seed -
|
|
556
|
+
* @param host - The host element.
|
|
557
|
+
* @param options - Provisioning options.
|
|
558
|
+
* @param options.container - Optional existing container to use. If not provided, a new one will be created.
|
|
559
|
+
* @param options.seed - Optional seed data to apply to the container.
|
|
548
560
|
*/
|
|
549
561
|
function IocProviderController(host, _a) {
|
|
550
562
|
var _b = _a === void 0 ? {} : _a,
|
|
@@ -554,10 +566,10 @@ var IocProviderController = /** @class */function () {
|
|
|
554
566
|
this.host = host;
|
|
555
567
|
this.revision = 1;
|
|
556
568
|
this.host.addController(this);
|
|
557
|
-
this.container = container !== null && container !== void 0 ? container : core.
|
|
569
|
+
this.container = container !== null && container !== void 0 ? container : core.createContainer();
|
|
558
570
|
this.seed = seed;
|
|
559
571
|
this.provider = new context.ContextProvider(host, {
|
|
560
|
-
context:
|
|
572
|
+
context: IocContextObject,
|
|
561
573
|
initialValue: {
|
|
562
574
|
container: this.container,
|
|
563
575
|
revision: this.revision,
|
|
@@ -569,7 +581,7 @@ var IocProviderController = /** @class */function () {
|
|
|
569
581
|
}
|
|
570
582
|
Object.defineProperty(IocProviderController.prototype, "value", {
|
|
571
583
|
/**
|
|
572
|
-
* @returns
|
|
584
|
+
* @returns Current {@link IocContext} value served to child consumers.
|
|
573
585
|
*/
|
|
574
586
|
get: function () {
|
|
575
587
|
return this.provider.value;
|
|
@@ -599,19 +611,22 @@ var IocProviderController = /** @class */function () {
|
|
|
599
611
|
}();
|
|
600
612
|
|
|
601
613
|
/**
|
|
602
|
-
* Decorator
|
|
614
|
+
* Decorator that provides an IoC container to child components.
|
|
615
|
+
*
|
|
616
|
+
* @remarks
|
|
617
|
+
* The container is provided via Lit context. It is created (or used from options) when the host connects.
|
|
603
618
|
*
|
|
604
|
-
* @group
|
|
619
|
+
* @group Provision
|
|
605
620
|
*
|
|
606
|
-
* @param options -
|
|
607
|
-
* @param options.container -
|
|
608
|
-
* @param options.seed -
|
|
609
|
-
* @returns
|
|
621
|
+
* @param options - Provisioning options.
|
|
622
|
+
* @param options.container - Optional existing container to use, if not provided, a new one will be created.
|
|
623
|
+
* @param options.seed - Optional seed data to apply to the container.
|
|
624
|
+
* @returns An instance of {@link IocProviderDecorator}.
|
|
610
625
|
*
|
|
611
626
|
* @example
|
|
612
627
|
* ```typescript
|
|
613
628
|
* class MyRootElement extends LitElement {
|
|
614
|
-
* @iocProvide({ seed: { someData:
|
|
629
|
+
* @iocProvide({ seed: { someData: "value" } })
|
|
615
630
|
* private ioc!: IocProviderController;
|
|
616
631
|
* }
|
|
617
632
|
* ```
|
|
@@ -652,14 +667,14 @@ function iocProvide(_a) {
|
|
|
652
667
|
var ERROR_CODE_INVALID_ARGUMENTS = 2051;
|
|
653
668
|
|
|
654
669
|
/**
|
|
655
|
-
* Controller that binds
|
|
656
|
-
* and unbinds them when the host disconnects.
|
|
670
|
+
* Controller that binds injectables to an IoC container for the host element's lifetime.
|
|
657
671
|
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
672
|
+
* @remarks
|
|
673
|
+
* Entries are bound when the host connects and unbound when it disconnects.
|
|
674
|
+
* If no `into` context is provided, it uses the nearest {@link IocProviderController}.
|
|
675
|
+
* Seeds are applied before entries are bound.
|
|
661
676
|
*
|
|
662
|
-
* @group
|
|
677
|
+
* @group Provision
|
|
663
678
|
*
|
|
664
679
|
* @example
|
|
665
680
|
* ```typescript
|
|
@@ -674,12 +689,12 @@ var ERROR_CODE_INVALID_ARGUMENTS = 2051;
|
|
|
674
689
|
*/
|
|
675
690
|
var InjectablesProviderController = /** @class */function () {
|
|
676
691
|
/**
|
|
677
|
-
* @param host -
|
|
678
|
-
* @param options -
|
|
679
|
-
* @param options.entries -
|
|
680
|
-
* @param options.into -
|
|
681
|
-
* @param options.activate -
|
|
682
|
-
* @param options.seeds -
|
|
692
|
+
* @param host - The host element.
|
|
693
|
+
* @param options - Provisioning options.
|
|
694
|
+
* @param options.entries - List of service entries to bind to the container.
|
|
695
|
+
* @param options.into - Target IoC context; if omitted, uses the nearest provider context.
|
|
696
|
+
* @param options.activate - List of service identifiers to activate immediately after binding.
|
|
697
|
+
* @param options.seeds - Seed data applied before binding.
|
|
683
698
|
*/
|
|
684
699
|
function InjectablesProviderController(host, options) {
|
|
685
700
|
var _this = this;
|
|
@@ -697,7 +712,7 @@ var InjectablesProviderController = /** @class */function () {
|
|
|
697
712
|
if (!this.into) {
|
|
698
713
|
// subscribe: false — binding happens once per connect, not on every revision update.
|
|
699
714
|
this.consumer = new context.ContextConsumer(host, {
|
|
700
|
-
context:
|
|
715
|
+
context: IocContextObject,
|
|
701
716
|
subscribe: false,
|
|
702
717
|
callback: function (context) {
|
|
703
718
|
if (!host.isConnected) {
|
|
@@ -770,19 +785,19 @@ var InjectablesProviderController = /** @class */function () {
|
|
|
770
785
|
/**
|
|
771
786
|
* Decorator that binds a set of injectables to the nearest IoC container for the host element's lifetime.
|
|
772
787
|
*
|
|
788
|
+
* @remarks
|
|
773
789
|
* Entries are bound when the host connects and unbound when it disconnects.
|
|
774
|
-
* The decorated accessor or property holds the resulting {@link InjectablesProviderController} instance.
|
|
775
790
|
*
|
|
776
|
-
* @group
|
|
791
|
+
* @group Provision
|
|
777
792
|
*
|
|
778
|
-
* @param options -
|
|
779
|
-
* @returns
|
|
793
|
+
* @param options - Provisioning options.
|
|
794
|
+
* @returns An instance of {@link InjectablesProviderDecorator}.
|
|
780
795
|
*
|
|
781
796
|
* @example
|
|
782
797
|
* ```typescript
|
|
783
798
|
* class MyComponent extends LitElement {
|
|
784
799
|
* @injectablesProvide({ entries: [AuthService, UserService], activate: [AuthService] })
|
|
785
|
-
* public
|
|
800
|
+
* public controller!: InjectablesProviderController<MyComponent>;
|
|
786
801
|
* }
|
|
787
802
|
* ```
|
|
788
803
|
*/
|
|
@@ -811,19 +826,13 @@ function injectablesProvide(options) {
|
|
|
811
826
|
}
|
|
812
827
|
|
|
813
828
|
/**
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
* Entries are bound when the host connects and unbound when it disconnects.
|
|
829
|
+
* Hook that binds injectables to the nearest IoC container for the host element's lifetime.
|
|
817
830
|
*
|
|
818
|
-
* @group
|
|
831
|
+
* @group Provision
|
|
819
832
|
*
|
|
820
|
-
* @param host -
|
|
821
|
-
* @param options -
|
|
822
|
-
* @
|
|
823
|
-
* @param options.into - target IoC context; if omitted, uses the nearest provider context
|
|
824
|
-
* @param options.activate - list of service identifiers to activate immediately after binding
|
|
825
|
-
* @param options.seeds - seed data applied before binding
|
|
826
|
-
* @returns the controller instance
|
|
833
|
+
* @param host - The host element.
|
|
834
|
+
* @param options - Provisioning options.
|
|
835
|
+
* @returns An instance of {@link InjectablesProviderController}.
|
|
827
836
|
*
|
|
828
837
|
* @example
|
|
829
838
|
* ```typescript
|
|
@@ -840,20 +849,18 @@ function useInjectablesProvider(host, options) {
|
|
|
840
849
|
}
|
|
841
850
|
|
|
842
851
|
/**
|
|
843
|
-
* Hook
|
|
852
|
+
* Hook that provides an IoC container to the host element and its children.
|
|
844
853
|
*
|
|
845
|
-
* @group
|
|
854
|
+
* @group Provision
|
|
846
855
|
*
|
|
847
|
-
* @param host -
|
|
848
|
-
* @param options -
|
|
849
|
-
* @
|
|
850
|
-
* @param options.seed - optional seed data to apply to the container
|
|
851
|
-
* @returns ioc provision controller instance
|
|
856
|
+
* @param host - The host element.
|
|
857
|
+
* @param options - Provisioning options.
|
|
858
|
+
* @returns An instance of {@link IocProviderController}.
|
|
852
859
|
*
|
|
853
860
|
* @example
|
|
854
861
|
* ```typescript
|
|
855
862
|
* class MyRootElement extends LitElement {
|
|
856
|
-
* private ioc = useIocProvision(this, { seed: { initialData:
|
|
863
|
+
* private ioc = useIocProvision(this, { seed: { initialData: "..." } });
|
|
857
864
|
* }
|
|
858
865
|
* ```
|
|
859
866
|
*/
|
|
@@ -864,8 +871,8 @@ function useIocProvision(host, options) {
|
|
|
864
871
|
return new IocProviderController(host, options);
|
|
865
872
|
}
|
|
866
873
|
|
|
867
|
-
exports.ContainerContext = ContainerContext;
|
|
868
874
|
exports.InjectablesProviderController = InjectablesProviderController;
|
|
875
|
+
exports.IocContextObject = IocContextObject;
|
|
869
876
|
exports.IocProviderController = IocProviderController;
|
|
870
877
|
exports.OnCommandController = OnCommandController;
|
|
871
878
|
exports.OnEventController = OnEventController;
|