@wirestate/lit 0.7.0-experimental.2 → 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.
Files changed (81) hide show
  1. package/cjs/development/index.js +164 -191
  2. package/cjs/development/index.js.map +1 -1
  3. package/cjs/production/index.js +1 -1
  4. package/cjs/production/index.js.map +1 -1
  5. package/esm/development/commands/on-command-controller.js +17 -20
  6. package/esm/development/commands/on-command-controller.js.map +1 -1
  7. package/esm/development/commands/on-command.js +4 -9
  8. package/esm/development/commands/on-command.js.map +1 -1
  9. package/esm/development/commands/use-on-command.js +4 -3
  10. package/esm/development/commands/use-on-command.js.map +1 -1
  11. package/esm/development/consumption/injection.js +10 -9
  12. package/esm/development/consumption/injection.js.map +1 -1
  13. package/esm/development/consumption/use-container.js +2 -2
  14. package/esm/development/consumption/use-container.js.map +1 -1
  15. package/esm/development/consumption/use-injection.js +9 -7
  16. package/esm/development/consumption/use-injection.js.map +1 -1
  17. package/esm/development/consumption/use-scope.js +2 -2
  18. package/esm/development/consumption/use-scope.js.map +1 -1
  19. package/esm/development/context/container-context.js +2 -2
  20. package/esm/development/context/container-context.js.map +1 -1
  21. package/esm/development/error/error-code.js +1 -1
  22. package/esm/development/error/error-code.js.map +1 -1
  23. package/esm/development/events/on-event-controller.js +20 -24
  24. package/esm/development/events/on-event-controller.js.map +1 -1
  25. package/esm/development/events/on-event.js +5 -11
  26. package/esm/development/events/on-event.js.map +1 -1
  27. package/esm/development/events/use-on-events.js +5 -5
  28. package/esm/development/events/use-on-events.js.map +1 -1
  29. package/esm/development/provision/container-provide.js +7 -7
  30. package/esm/development/provision/container-provide.js.map +1 -1
  31. package/esm/development/provision/container-provider.js +17 -23
  32. package/esm/development/provision/container-provider.js.map +1 -1
  33. package/esm/development/provision/sub-container-provide.js +7 -7
  34. package/esm/development/provision/sub-container-provide.js.map +1 -1
  35. package/esm/development/provision/sub-container-provider.js +28 -31
  36. package/esm/development/provision/sub-container-provider.js.map +1 -1
  37. package/esm/development/queries/on-query-controller.js +17 -20
  38. package/esm/development/queries/on-query-controller.js.map +1 -1
  39. package/esm/development/queries/on-query.js +4 -9
  40. package/esm/development/queries/on-query.js.map +1 -1
  41. package/esm/development/queries/use-on-query.js +4 -3
  42. package/esm/development/queries/use-on-query.js.map +1 -1
  43. package/esm/production/commands/on-command-controller.js +1 -1
  44. package/esm/production/commands/on-command-controller.js.map +1 -1
  45. package/esm/production/commands/on-command.js +1 -1
  46. package/esm/production/commands/on-command.js.map +1 -1
  47. package/esm/production/commands/use-on-command.js +1 -1
  48. package/esm/production/commands/use-on-command.js.map +1 -1
  49. package/esm/production/consumption/injection.js +1 -1
  50. package/esm/production/consumption/injection.js.map +1 -1
  51. package/esm/production/consumption/use-container.js +1 -1
  52. package/esm/production/consumption/use-container.js.map +1 -1
  53. package/esm/production/consumption/use-injection.js +1 -1
  54. package/esm/production/consumption/use-injection.js.map +1 -1
  55. package/esm/production/consumption/use-scope.js +1 -1
  56. package/esm/production/consumption/use-scope.js.map +1 -1
  57. package/esm/production/context/container-context.js +1 -1
  58. package/esm/production/context/container-context.js.map +1 -1
  59. package/esm/production/error/error-code.js +1 -1
  60. package/esm/production/error/error-code.js.map +1 -1
  61. package/esm/production/events/on-event-controller.js +1 -1
  62. package/esm/production/events/on-event-controller.js.map +1 -1
  63. package/esm/production/events/on-event.js +1 -1
  64. package/esm/production/events/on-event.js.map +1 -1
  65. package/esm/production/events/use-on-events.js +1 -1
  66. package/esm/production/events/use-on-events.js.map +1 -1
  67. package/esm/production/provision/container-provide.js +1 -1
  68. package/esm/production/provision/container-provide.js.map +1 -1
  69. package/esm/production/provision/container-provider.js +1 -1
  70. package/esm/production/provision/container-provider.js.map +1 -1
  71. package/esm/production/provision/sub-container-provide.js +1 -1
  72. package/esm/production/provision/sub-container-provide.js.map +1 -1
  73. package/esm/production/provision/sub-container-provider.js +1 -1
  74. package/esm/production/provision/sub-container-provider.js.map +1 -1
  75. package/esm/production/queries/on-query-controller.js +1 -1
  76. package/esm/production/queries/on-query-controller.js.map +1 -1
  77. package/esm/production/queries/on-query.js +1 -1
  78. package/esm/production/queries/on-query.js.map +1 -1
  79. package/esm/production/queries/use-on-query.js +1 -1
  80. package/esm/production/queries/use-on-query.js.map +1 -1
  81. package/package.json +1 -1
@@ -2,20 +2,19 @@
2
2
 
3
3
  var context = require('@lit/context');
4
4
  var core = require('@wirestate/core');
5
- var tslib = require('tslib');
6
5
 
7
6
  /**
8
7
  * Unique symbol used as a key for the IoC context.
9
8
  *
10
9
  * @group Context
11
10
  */
12
- var CONTAINER_KEY = Symbol("ContainerContext");
11
+ const CONTAINER_KEY = Symbol("ContainerContext");
13
12
  /**
14
13
  * Lit context object for providing and consuming the container.
15
14
  *
16
15
  * @group Context
17
16
  */
18
- var ContainerContext = context.createContext(CONTAINER_KEY);
17
+ const ContainerContext = context.createContext(CONTAINER_KEY);
19
18
 
20
19
  /**
21
20
  * Decorator to inject a service from the IoC container into a Lit element property.
@@ -50,30 +49,31 @@ var ContainerContext = context.createContext(CONTAINER_KEY);
50
49
  * ```
51
50
  */
52
51
  function injection(optionsOrInjectionId) {
53
- var options = typeof optionsOrInjectionId === "object" && optionsOrInjectionId !== null && "injectionId" in optionsOrInjectionId ? optionsOrInjectionId : {
52
+ const options = typeof optionsOrInjectionId === "object" && optionsOrInjectionId !== null && "injectionId" in optionsOrInjectionId ? optionsOrInjectionId : {
54
53
  injectionId: optionsOrInjectionId
55
54
  };
56
- return function (protoOrTarget, nameOrContext) {
57
- var injectionId = options.injectionId,
58
- once = options.once;
55
+ return (protoOrTarget, nameOrContext) => {
56
+ const {
57
+ injectionId,
58
+ once
59
+ } = options;
59
60
  // Standard decorators branch.
60
61
  if (typeof nameOrContext === "object") {
61
62
  nameOrContext.addInitializer(function () {
62
- var _this = this;
63
63
  new context.ContextConsumer(this, {
64
64
  context: ContainerContext,
65
- callback: function (container) {
66
- protoOrTarget.set.call(_this, container.get(injectionId));
65
+ callback: container => {
66
+ protoOrTarget.set.call(this, container.get(injectionId));
67
67
  },
68
68
  subscribe: !once
69
69
  });
70
70
  });
71
71
  } else {
72
72
  // Experimental decorators branch.
73
- protoOrTarget.constructor.addInitializer(function (element) {
73
+ protoOrTarget.constructor.addInitializer(element => {
74
74
  new context.ContextConsumer(element, {
75
75
  context: ContainerContext,
76
- callback: function (container) {
76
+ callback: container => {
77
77
  element[nameOrContext] = container.get(injectionId);
78
78
  },
79
79
  subscribe: !once
@@ -106,12 +106,12 @@ function injection(optionsOrInjectionId) {
106
106
  * ```
107
107
  */
108
108
  function useContainer(host) {
109
- var current = {
109
+ const current = {
110
110
  value: null
111
111
  };
112
112
  new context.ContextConsumer(host, {
113
113
  context: ContainerContext,
114
- callback: function (container) {
114
+ callback: container => {
115
115
  current.value = container;
116
116
  }
117
117
  });
@@ -150,20 +150,22 @@ function useContainer(host) {
150
150
  * ```
151
151
  */
152
152
  function useInjection(host, optionsOrInjectionId) {
153
- var options = typeof optionsOrInjectionId === "object" && optionsOrInjectionId !== null && "injectionId" in optionsOrInjectionId ? optionsOrInjectionId : {
153
+ const options = typeof optionsOrInjectionId === "object" && optionsOrInjectionId !== null && "injectionId" in optionsOrInjectionId ? optionsOrInjectionId : {
154
154
  injectionId: optionsOrInjectionId
155
155
  };
156
- var once = options.once,
157
- injectionId = options.injectionId,
158
- value = options.value;
159
- var current = {
156
+ const {
157
+ once,
158
+ injectionId,
159
+ value
160
+ } = options;
161
+ const current = {
160
162
  value: value,
161
- injectionId: injectionId
163
+ injectionId
162
164
  };
163
165
  new context.ContextConsumer(host, {
164
166
  context: ContainerContext,
165
167
  subscribe: !once,
166
- callback: function (container) {
168
+ callback: container => {
167
169
  current.value = container.get(injectionId);
168
170
  }
169
171
  });
@@ -194,14 +196,14 @@ function useInjection(host, optionsOrInjectionId) {
194
196
  * ```
195
197
  */
196
198
  function useScope(host) {
197
- var current = {
199
+ const current = {
198
200
  value: undefined,
199
201
  injectionId: core.WireScope
200
202
  };
201
203
  new context.ContextConsumer(host, {
202
204
  context: ContainerContext,
203
205
  subscribe: true,
204
- callback: function (container) {
206
+ callback: container => {
205
207
  current.value = container.get(core.WireScope);
206
208
  }
207
209
  });
@@ -217,49 +219,46 @@ function useScope(host) {
217
219
  *
218
220
  * @group Commands
219
221
  */
220
- var OnCommandController = /** @class */function () {
222
+ class OnCommandController {
223
+ bus = null;
224
+ unregister = null;
221
225
  /**
222
226
  * @param host - The host element.
223
227
  * @param type - Unique identifier of the command to handle.
224
228
  * @param handler - The command handler function.
225
229
  */
226
- function OnCommandController(host, type, handler) {
227
- var _this = this;
228
- this.bus = null;
229
- this.unregister = null;
230
+ constructor(host, type, handler) {
230
231
  host.addController(this);
231
232
  this.type = type;
232
233
  this.handler = handler;
233
234
  new context.ContextConsumer(host, {
234
235
  context: ContainerContext,
235
236
  subscribe: true,
236
- callback: function (container) {
237
- _this.bus = container.get(core.CommandBus);
237
+ callback: container => {
238
+ this.bus = container.get(core.CommandBus);
238
239
  if (host.isConnected) {
239
- _this.reregister();
240
+ this.reregister();
240
241
  }
241
242
  }
242
243
  });
243
244
  }
244
- OnCommandController.prototype.hostConnected = function () {
245
+ hostConnected() {
245
246
  this.reregister();
246
- };
247
- OnCommandController.prototype.hostDisconnected = function () {
247
+ }
248
+ hostDisconnected() {
248
249
  this.cleanup();
249
- };
250
- OnCommandController.prototype.reregister = function () {
250
+ }
251
+ reregister() {
251
252
  this.cleanup();
252
253
  if (this.bus) {
253
254
  this.unregister = this.bus.register(this.type, this.handler);
254
255
  }
255
- };
256
- OnCommandController.prototype.cleanup = function () {
257
- var _a;
258
- (_a = this.unregister) === null || _a === void 0 ? void 0 : _a.call(this);
256
+ }
257
+ cleanup() {
258
+ this.unregister?.();
259
259
  this.unregister = null;
260
- };
261
- return OnCommandController;
262
- }();
260
+ }
261
+ }
263
262
 
264
263
  /**
265
264
  * Decorator for Lit element methods that handle a specific command.
@@ -283,21 +282,16 @@ var OnCommandController = /** @class */function () {
283
282
  * ```
284
283
  */
285
284
  function onCommand(type) {
286
- return function (protoOrTarget, nameOrContext) {
285
+ return (protoOrTarget, nameOrContext) => {
287
286
  if (typeof nameOrContext === "object") {
288
287
  // Standard decorators:
289
288
  nameOrContext.addInitializer(function () {
290
- var _this = this;
291
- new OnCommandController(this, type, function (data) {
292
- return _this[nameOrContext.name](data);
293
- });
289
+ new OnCommandController(this, type, data => this[nameOrContext.name](data));
294
290
  });
295
291
  } else {
296
292
  // Experimental legacy decorators:
297
- protoOrTarget.constructor.addInitializer(function (element) {
298
- new OnCommandController(element, type, function (data) {
299
- return element[nameOrContext](data);
300
- });
293
+ protoOrTarget.constructor.addInitializer(element => {
294
+ new OnCommandController(element, type, data => element[nameOrContext](data));
301
295
  });
302
296
  }
303
297
  };
@@ -324,9 +318,10 @@ function onCommand(type) {
324
318
  * }
325
319
  * ```
326
320
  */
327
- function useOnCommand(host, _a) {
328
- var type = _a.type,
329
- handler = _a.handler;
321
+ function useOnCommand(host, {
322
+ type,
323
+ handler
324
+ }) {
330
325
  return new OnCommandController(host, type, handler);
331
326
  }
332
327
 
@@ -339,58 +334,54 @@ function useOnCommand(host, _a) {
339
334
  *
340
335
  * @group Events
341
336
  */
342
- var OnEventController = /** @class */function () {
337
+ class OnEventController {
338
+ bus = null;
339
+ unsubscriber = null;
343
340
  /**
344
341
  * @param host - The host element.
345
342
  * @param types - Event types to listen for. If null, all events will be handled.
346
343
  * @param handler - The event handler function.
347
344
  */
348
- function OnEventController(host, types, handler) {
349
- var _this = this;
350
- this.bus = null;
351
- this.unsubscriber = null;
345
+ constructor(host, types, handler) {
352
346
  host.addController(this);
353
347
  this.types = types;
354
348
  this.handler = handler;
355
349
  new context.ContextConsumer(host, {
356
350
  context: ContainerContext,
357
351
  subscribe: true,
358
- callback: function (container) {
359
- _this.bus = container.get(core.EventBus);
352
+ callback: container => {
353
+ this.bus = container.get(core.EventBus);
360
354
  if (host.isConnected) {
361
- _this.resubscribe();
355
+ this.resubscribe();
362
356
  }
363
357
  }
364
358
  });
365
359
  }
366
- OnEventController.prototype.hostConnected = function () {
360
+ hostConnected() {
367
361
  this.resubscribe();
368
- };
369
- OnEventController.prototype.hostDisconnected = function () {
362
+ }
363
+ hostDisconnected() {
370
364
  this.cleanup();
371
- };
372
- OnEventController.prototype.resubscribe = function () {
373
- var _this = this;
365
+ }
366
+ resubscribe() {
374
367
  this.cleanup();
375
368
  if (this.bus) {
376
369
  if (this.types === null) {
377
370
  this.unsubscriber = this.bus.subscribe(this.handler);
378
371
  } else {
379
- this.unsubscriber = this.bus.subscribe(function (event) {
380
- if (_this.types.includes(event.type)) {
381
- _this.handler(event);
372
+ this.unsubscriber = this.bus.subscribe(event => {
373
+ if (this.types.includes(event.type)) {
374
+ this.handler(event);
382
375
  }
383
376
  });
384
377
  }
385
378
  }
386
- };
387
- OnEventController.prototype.cleanup = function () {
388
- var _a;
389
- (_a = this.unsubscriber) === null || _a === void 0 ? void 0 : _a.call(this);
379
+ }
380
+ cleanup() {
381
+ this.unsubscriber?.();
390
382
  this.unsubscriber = null;
391
- };
392
- return OnEventController;
393
- }();
383
+ }
384
+ }
394
385
 
395
386
  /**
396
387
  * Decorator for Lit element methods that handle events from the event bus.
@@ -434,22 +425,17 @@ var OnEventController = /** @class */function () {
434
425
  * ```
435
426
  */
436
427
  function onEvent(types) {
437
- var normalized = types === undefined ? null : Array.isArray(types) ? tslib.__spreadArray([], types, true) : [types];
438
- return function (protoOrTarget, nameOrContext) {
428
+ const normalized = types === undefined ? null : Array.isArray(types) ? [...types] : [types];
429
+ return (protoOrTarget, nameOrContext) => {
439
430
  if (typeof nameOrContext === "object") {
440
431
  // Standard decorators:
441
432
  nameOrContext.addInitializer(function () {
442
- var _this = this;
443
- new OnEventController(this, normalized, function (event) {
444
- return _this[nameOrContext.name](event);
445
- });
433
+ new OnEventController(this, normalized, event => this[nameOrContext.name](event));
446
434
  });
447
435
  } else {
448
436
  // Experimental legacy decorators:
449
- protoOrTarget.constructor.addInitializer(function (element) {
450
- new OnEventController(element, normalized, function (event) {
451
- return element[nameOrContext](event);
452
- });
437
+ protoOrTarget.constructor.addInitializer(element => {
438
+ new OnEventController(element, normalized, event => element[nameOrContext](event));
453
439
  });
454
440
  }
455
441
  };
@@ -485,10 +471,11 @@ function onEvent(types) {
485
471
  * }
486
472
  * ```
487
473
  */
488
- function useOnEvents(host, _a) {
489
- var types = _a.types,
490
- handler = _a.handler;
491
- var normalized = types ? Array.isArray(types) ? tslib.__spreadArray([], types, true) : [types] : null;
474
+ function useOnEvents(host, {
475
+ types,
476
+ handler
477
+ }) {
478
+ const normalized = types ? Array.isArray(types) ? [...types] : [types] : null;
492
479
  return new OnEventController(host, normalized, handler);
493
480
  }
494
481
 
@@ -501,49 +488,46 @@ function useOnEvents(host, _a) {
501
488
  *
502
489
  * @group Queries
503
490
  */
504
- var OnQueryController = /** @class */function () {
491
+ class OnQueryController {
492
+ bus = null;
493
+ unregister = null;
505
494
  /**
506
495
  * @param host - The host element.
507
496
  * @param type - Unique identifier of the query to handle.
508
497
  * @param handler - The query handler function.
509
498
  */
510
- function OnQueryController(host, type, handler) {
511
- var _this = this;
512
- this.bus = null;
513
- this.unregister = null;
499
+ constructor(host, type, handler) {
514
500
  host.addController(this);
515
501
  this.type = type;
516
502
  this.handler = handler;
517
503
  new context.ContextConsumer(host, {
518
504
  context: ContainerContext,
519
505
  subscribe: true,
520
- callback: function (container) {
521
- _this.bus = container.get(core.QueryBus);
506
+ callback: container => {
507
+ this.bus = container.get(core.QueryBus);
522
508
  if (host.isConnected) {
523
- _this.reregister();
509
+ this.reregister();
524
510
  }
525
511
  }
526
512
  });
527
513
  }
528
- OnQueryController.prototype.hostConnected = function () {
514
+ hostConnected() {
529
515
  this.reregister();
530
- };
531
- OnQueryController.prototype.hostDisconnected = function () {
516
+ }
517
+ hostDisconnected() {
532
518
  this.cleanup();
533
- };
534
- OnQueryController.prototype.reregister = function () {
519
+ }
520
+ reregister() {
535
521
  this.cleanup();
536
522
  if (this.bus) {
537
523
  this.unregister = this.bus.register(this.type, this.handler);
538
524
  }
539
- };
540
- OnQueryController.prototype.cleanup = function () {
541
- var _a;
542
- (_a = this.unregister) === null || _a === void 0 ? void 0 : _a.call(this);
525
+ }
526
+ cleanup() {
527
+ this.unregister?.();
543
528
  this.unregister = null;
544
- };
545
- return OnQueryController;
546
- }();
529
+ }
530
+ }
547
531
 
548
532
  /**
549
533
  * Decorator for Lit element methods that handle a specific query.
@@ -567,21 +551,16 @@ var OnQueryController = /** @class */function () {
567
551
  * ```
568
552
  */
569
553
  function onQuery(type) {
570
- return function (protoOrTarget, nameOrContext) {
554
+ return (protoOrTarget, nameOrContext) => {
571
555
  if (typeof nameOrContext === "object") {
572
556
  // Standard decorators:
573
557
  nameOrContext.addInitializer(function () {
574
- var _this = this;
575
- new OnQueryController(this, type, function (data) {
576
- return _this[nameOrContext.name](data);
577
- });
558
+ new OnQueryController(this, type, data => this[nameOrContext.name](data));
578
559
  });
579
560
  } else {
580
561
  // Experimental legacy decorators:
581
- protoOrTarget.constructor.addInitializer(function (element) {
582
- new OnQueryController(element, type, function (data) {
583
- return element[nameOrContext](data);
584
- });
562
+ protoOrTarget.constructor.addInitializer(element => {
563
+ new OnQueryController(element, type, data => element[nameOrContext](data));
585
564
  });
586
565
  }
587
566
  };
@@ -608,13 +587,14 @@ function onQuery(type) {
608
587
  * }
609
588
  * ```
610
589
  */
611
- function useOnQuery(host, _a) {
612
- var type = _a.type,
613
- handler = _a.handler;
590
+ function useOnQuery(host, {
591
+ type,
592
+ handler
593
+ }) {
614
594
  return new OnQueryController(host, type, handler);
615
595
  }
616
596
 
617
- var ERROR_CODE_INVALID_ARGUMENTS = 2051;
597
+ const ERROR_CODE_INVALID_ARGUMENTS = 2051;
618
598
 
619
599
  /**
620
600
  * Provider that exposes an IoC container context to the host element and its children.
@@ -631,56 +611,51 @@ var ERROR_CODE_INVALID_ARGUMENTS = 2051;
631
611
  *
632
612
  * @group Provision
633
613
  */
634
- var ContainerProvider = /** @class */function (_super) {
635
- tslib.__extends(ContainerProvider, _super);
614
+ class ContainerProvider extends context.ContextProvider {
615
+ destroyed = false;
636
616
  /**
637
617
  * @param host - The host element.
638
618
  * @param options - Provisioning options.
639
619
  * @param options.container - External container instance to provide.
640
620
  * @param options.options - Managed container creation options.
641
621
  */
642
- function ContainerProvider(host, options) {
643
- var _this = this;
622
+ constructor(host, options) {
644
623
  if (!options.container && !options.options) {
645
624
  throw new core.WirestateError(ERROR_CODE_INVALID_ARGUMENTS, "ContainerProvider requires a valid container instance or creation options.");
646
625
  } else if (options.container && options.options) {
647
626
  throw new core.WirestateError(ERROR_CODE_INVALID_ARGUMENTS, "ContainerProvider requires only container or valid options object to be provided.");
648
627
  }
649
- _this = _super.call(this, host, {
628
+ super(host, {
650
629
  context: ContainerContext,
651
- initialValue: options.container ? options.container : core.createContainer(tslib.__assign(tslib.__assign({}, options.options), {
630
+ initialValue: options.container ? options.container : core.createContainer({
631
+ ...options.options,
652
632
  activate: []
653
- }))
654
- }) || this;
655
- _this.destroyed = false;
656
- _this.options = options.options;
657
- return _this;
633
+ })
634
+ });
635
+ this.options = options.options;
658
636
  }
659
- ContainerProvider.prototype.hostConnected = function () {
660
- var _a;
637
+ hostConnected() {
661
638
  if (this.options) {
662
639
  if (this.destroyed) {
663
640
  this.value = core.createContainer(this.options);
664
641
  this.destroyed = false;
665
642
  } else {
666
- if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.activate) {
667
- for (var _i = 0, _b = this.options.activate; _i < _b.length; _i++) {
668
- var entry = _b[_i];
643
+ if (this.options?.activate) {
644
+ for (const entry of this.options.activate) {
669
645
  this.value.get(entry);
670
646
  }
671
647
  }
672
648
  }
673
649
  }
674
- _super.prototype.hostConnected.call(this);
675
- };
676
- ContainerProvider.prototype.hostDisconnected = function () {
650
+ super.hostConnected();
651
+ }
652
+ hostDisconnected() {
677
653
  if (this.options) {
678
654
  this.value.unbindAll();
679
655
  this.destroyed = true;
680
656
  }
681
- };
682
- return ContainerProvider;
683
- }(context.ContextProvider);
657
+ }
658
+ }
684
659
 
685
660
  /**
686
661
  * Provider that exposes a managed child container for the host element's lifetime.
@@ -706,67 +681,65 @@ var ContainerProvider = /** @class */function (_super) {
706
681
  * }
707
682
  * ```
708
683
  */
709
- var SubContainerProvider = /** @class */function (_super) {
710
- tslib.__extends(SubContainerProvider, _super);
684
+ class SubContainerProvider extends context.ContextProvider {
685
+ parent = null;
686
+ destroyed = true;
711
687
  /**
712
688
  * @param host - The host element.
713
689
  * @param options - Provisioning options, including child entries, eager activations, and seeds.
714
690
  */
715
- function SubContainerProvider(host, options) {
716
- var _this = _super.call(this, host, {
691
+ constructor(host, options) {
692
+ super(host, {
717
693
  context: ContainerContext
718
- }) || this;
719
- _this.parent = null;
720
- _this.destroyed = true;
721
- _this.options = options.options;
722
- _this.consumer = new context.ContextConsumer(host, {
694
+ });
695
+ this.options = options.options;
696
+ this.consumer = new context.ContextConsumer(host, {
723
697
  context: ContainerContext,
724
698
  subscribe: true,
725
- callback: function (context) {
726
- var previousParent = _this.parent;
727
- _this.parent = context;
699
+ callback: context => {
700
+ const previousParent = this.parent;
701
+ this.parent = context;
728
702
  if (host.isConnected) {
729
- if (_this.destroyed || !_this.value || previousParent !== context) {
730
- _this.destroyContainer();
731
- _this.createContainer();
703
+ if (this.destroyed || !this.value || previousParent !== context) {
704
+ this.destroyContainer();
705
+ this.createContainer();
732
706
  }
733
707
  }
734
708
  }
735
709
  });
736
- return _this;
737
710
  }
738
- SubContainerProvider.prototype.hostConnected = function () {
711
+ hostConnected() {
739
712
  if (this.parent && (this.destroyed || !this.value)) {
740
713
  this.destroyContainer();
741
714
  this.createContainer();
742
715
  }
743
- _super.prototype.hostConnected.call(this);
744
- };
745
- SubContainerProvider.prototype.hostDisconnected = function () {
716
+ super.hostConnected();
717
+ }
718
+ hostDisconnected() {
746
719
  this.destroyContainer();
747
- };
720
+ }
748
721
  /**
749
722
  * Replaces the currently provided child container with a new one derived
750
723
  * from the latest parent context.
751
724
  */
752
- SubContainerProvider.prototype.createContainer = function () {
753
- var container = core.createContainer(tslib.__assign(tslib.__assign({}, this.options), {
725
+ createContainer() {
726
+ const container = core.createContainer({
727
+ ...this.options,
754
728
  parent: this.parent
755
- }));
729
+ });
756
730
  this.destroyed = false;
757
731
  this.value = container;
758
- };
732
+ }
759
733
  /**
760
734
  * Destroys the currently provided child container.
761
735
  */
762
- SubContainerProvider.prototype.destroyContainer = function () {
736
+ destroyContainer() {
763
737
  if (this.value && !this.destroyed) {
764
738
  this.value.unbindAll();
765
739
  this.destroyed = true;
766
740
  }
767
- };
768
- return SubContainerProvider;
769
- }(context.ContextProvider);
741
+ }
742
+ }
770
743
 
771
744
  /**
772
745
  * Decorator that provides an IoC container to child components.
@@ -809,22 +782,22 @@ var SubContainerProvider = /** @class */function (_super) {
809
782
  * ```
810
783
  */
811
784
  function containerProvide(options) {
812
- return function (protoOrTarget, nameOrContext) {
785
+ return (protoOrTarget, nameOrContext) => {
813
786
  if (typeof nameOrContext === "object") {
814
787
  // Standard decorators:
815
788
  nameOrContext.addInitializer(function () {
816
789
  protoOrTarget.set.call(this, new ContainerProvider(this, options));
817
790
  });
818
791
  } else {
819
- var controller_1;
820
- protoOrTarget.constructor.addInitializer(function (element) {
821
- controller_1 = new ContainerProvider(element, options);
792
+ let controller;
793
+ protoOrTarget.constructor.addInitializer(element => {
794
+ controller = new ContainerProvider(element, options);
822
795
  });
823
796
  return {
824
- get: function () {
825
- return controller_1;
797
+ get() {
798
+ return controller;
826
799
  },
827
- set: function () {},
800
+ set() {},
828
801
  configurable: true,
829
802
  enumerable: true
830
803
  };
@@ -861,22 +834,22 @@ function containerProvide(options) {
861
834
  * ```
862
835
  */
863
836
  function subContainerProvide(options) {
864
- return function (protoOrTarget, nameOrContext) {
837
+ return (protoOrTarget, nameOrContext) => {
865
838
  if (typeof nameOrContext === "object") {
866
839
  // Standard decorators:
867
840
  nameOrContext.addInitializer(function () {
868
841
  protoOrTarget.set.call(this, new SubContainerProvider(this, options));
869
842
  });
870
843
  } else {
871
- var provider_1;
872
- protoOrTarget.constructor.addInitializer(function (element) {
873
- provider_1 = new SubContainerProvider(element, options);
844
+ let provider;
845
+ protoOrTarget.constructor.addInitializer(element => {
846
+ provider = new SubContainerProvider(element, options);
874
847
  });
875
848
  return {
876
- get: function () {
877
- return provider_1;
849
+ get() {
850
+ return provider;
878
851
  },
879
- set: function () {},
852
+ set() {},
880
853
  configurable: true,
881
854
  enumerable: true
882
855
  };