@microsoft/fast-element 2.0.0-beta.6 → 2.0.0-beta.8

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 (64) hide show
  1. package/CHANGELOG.json +78 -0
  2. package/CHANGELOG.md +25 -1
  3. package/dist/dts/components/attributes.d.ts +10 -0
  4. package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +24 -25
  5. package/dist/dts/components/fast-definitions.d.ts +28 -3
  6. package/dist/dts/components/fast-element.d.ts +2 -2
  7. package/dist/dts/di/di.d.ts +41 -0
  8. package/dist/dts/index.d.ts +2 -2
  9. package/dist/dts/observation/observable.d.ts +86 -47
  10. package/dist/dts/pending-task.d.ts +20 -0
  11. package/dist/dts/platform.d.ts +6 -0
  12. package/dist/dts/styles/css-directive.d.ts +2 -2
  13. package/dist/dts/styles/element-styles.d.ts +3 -3
  14. package/dist/dts/styles/host.d.ts +68 -0
  15. package/dist/dts/templating/binding-signal.d.ts +2 -2
  16. package/dist/dts/templating/binding-two-way.d.ts +11 -3
  17. package/dist/dts/templating/binding.d.ts +21 -119
  18. package/dist/dts/templating/children.d.ts +1 -1
  19. package/dist/dts/templating/html-directive.d.ts +69 -39
  20. package/dist/dts/templating/node-observation.d.ts +4 -5
  21. package/dist/dts/templating/ref.d.ts +5 -13
  22. package/dist/dts/templating/render.d.ts +15 -20
  23. package/dist/dts/templating/repeat.d.ts +11 -16
  24. package/dist/dts/templating/slotted.d.ts +1 -1
  25. package/dist/dts/templating/template.d.ts +4 -4
  26. package/dist/dts/templating/view.d.ts +68 -9
  27. package/dist/dts/templating/when.d.ts +1 -1
  28. package/dist/dts/testing/exports.d.ts +1 -0
  29. package/dist/dts/testing/fakes.d.ts +4 -0
  30. package/dist/dts/testing/fixture.d.ts +0 -6
  31. package/dist/esm/components/attributes.js +13 -4
  32. package/dist/esm/components/{controller.js → element-controller.js} +95 -105
  33. package/dist/esm/components/fast-definitions.js +3 -1
  34. package/dist/esm/components/fast-element.js +4 -4
  35. package/dist/esm/di/di.js +87 -3
  36. package/dist/esm/index.js +2 -1
  37. package/dist/esm/observation/observable.js +59 -126
  38. package/dist/esm/pending-task.js +16 -0
  39. package/dist/esm/platform.js +24 -0
  40. package/dist/esm/styles/css.js +4 -4
  41. package/dist/esm/{observation/behavior.js → styles/host.js} +0 -0
  42. package/dist/esm/templating/binding-signal.js +21 -17
  43. package/dist/esm/templating/binding-two-way.js +32 -27
  44. package/dist/esm/templating/binding.js +73 -177
  45. package/dist/esm/templating/html-directive.js +78 -7
  46. package/dist/esm/templating/node-observation.js +9 -8
  47. package/dist/esm/templating/ref.js +4 -12
  48. package/dist/esm/templating/render.js +30 -31
  49. package/dist/esm/templating/repeat.js +37 -38
  50. package/dist/esm/templating/template.js +3 -4
  51. package/dist/esm/templating/view.js +98 -29
  52. package/dist/esm/testing/exports.js +1 -0
  53. package/dist/esm/testing/fakes.js +76 -0
  54. package/dist/esm/testing/fixture.js +1 -3
  55. package/dist/fast-element.api.json +5720 -5385
  56. package/dist/fast-element.d.ts +510 -399
  57. package/dist/fast-element.debug.js +497 -514
  58. package/dist/fast-element.debug.min.js +1 -1
  59. package/dist/fast-element.js +497 -514
  60. package/dist/fast-element.min.js +1 -1
  61. package/dist/fast-element.untrimmed.d.ts +519 -405
  62. package/docs/api-report.md +197 -129
  63. package/package.json +5 -1
  64. package/dist/dts/observation/behavior.d.ts +0 -19
@@ -1,24 +1,24 @@
1
1
  import "../interfaces.js";
2
2
  import { PropertyChangeNotifier } from "../observation/notifier.js";
3
- import { ExecutionContext, Observable } from "../observation/observable.js";
3
+ import { Observable, SourceLifetime } from "../observation/observable.js";
4
4
  import { FAST } from "../platform.js";
5
5
  import { FASTElementDefinition } from "./fast-definitions.js";
6
- const shadowRoots = new WeakMap();
7
6
  const defaultEventOptions = {
8
7
  bubbles: true,
9
8
  composed: true,
10
9
  cancelable: true,
11
10
  };
11
+ const isConnectedPropertyName = "isConnected";
12
+ const shadowRoots = new WeakMap();
12
13
  function getShadowRoot(element) {
13
14
  var _a, _b;
14
15
  return (_b = (_a = element.shadowRoot) !== null && _a !== void 0 ? _a : shadowRoots.get(element)) !== null && _b !== void 0 ? _b : null;
15
16
  }
16
- const isConnectedPropertyName = "isConnected";
17
17
  /**
18
18
  * Controls the lifecycle and rendering of a `FASTElement`.
19
19
  * @public
20
20
  */
21
- export class Controller extends PropertyChangeNotifier {
21
+ export class ElementController extends PropertyChangeNotifier {
22
22
  /**
23
23
  * Creates a Controller to control the specified element.
24
24
  * @param element - The element to be controlled by this controller.
@@ -29,12 +29,12 @@ export class Controller extends PropertyChangeNotifier {
29
29
  constructor(element, definition) {
30
30
  super(element);
31
31
  this.boundObservables = null;
32
- this.behaviors = null;
33
32
  this.needsInitialization = true;
34
33
  this.hasExistingShadowRoot = false;
35
34
  this._template = null;
36
- this._styles = null;
37
35
  this._isConnected = false;
36
+ this.behaviors = null;
37
+ this._mainStyles = null;
38
38
  /**
39
39
  * This allows Observable.getNotifier(...) to return the Controller
40
40
  * when the notifier for the Controller itself is being requested. The
@@ -50,7 +50,7 @@ export class Controller extends PropertyChangeNotifier {
50
50
  * If `null` then the element is managing its own rendering.
51
51
  */
52
52
  this.view = null;
53
- this.element = element;
53
+ this.source = element;
54
54
  this.definition = definition;
55
55
  const shadowOptions = definition.shadowOptions;
56
56
  if (shadowOptions !== void 0) {
@@ -104,9 +104,9 @@ export class Controller extends PropertyChangeNotifier {
104
104
  // 1. Template overrides take top precedence.
105
105
  if (this._template === null) {
106
106
  const definition = this.definition;
107
- if (this.element.resolveTemplate) {
107
+ if (this.source.resolveTemplate) {
108
108
  // 2. Allow for element instance overrides next.
109
- this._template = this.element.resolveTemplate();
109
+ this._template = this.source.resolveTemplate();
110
110
  }
111
111
  else if (definition.template) {
112
112
  // 3. Default to the static definition.
@@ -125,48 +125,92 @@ export class Controller extends PropertyChangeNotifier {
125
125
  }
126
126
  }
127
127
  /**
128
- * Gets/sets the primary styles used for the component.
129
- * @remarks
130
- * This value can only be accurately read after connect but can be set at any time.
128
+ * The main set of styles used for the component, independent
129
+ * of any dynamically added styles.
131
130
  */
132
- get styles() {
131
+ get mainStyles() {
133
132
  var _a;
134
133
  // 1. Styles overrides take top precedence.
135
- if (this._styles === null) {
134
+ if (this._mainStyles === null) {
136
135
  const definition = this.definition;
137
- if (this.element.resolveStyles) {
136
+ if (this.source.resolveStyles) {
138
137
  // 2. Allow for element instance overrides next.
139
- this._styles = this.element.resolveStyles();
138
+ this._mainStyles = this.source.resolveStyles();
140
139
  }
141
140
  else if (definition.styles) {
142
141
  // 3. Default to the static definition.
143
- this._styles = (_a = definition.styles) !== null && _a !== void 0 ? _a : null;
142
+ this._mainStyles = (_a = definition.styles) !== null && _a !== void 0 ? _a : null;
144
143
  }
145
144
  }
146
- return this._styles;
145
+ return this._mainStyles;
147
146
  }
148
- set styles(value) {
149
- if (this._styles === value) {
147
+ set mainStyles(value) {
148
+ if (this._mainStyles === value) {
150
149
  return;
151
150
  }
152
- if (this._styles !== null) {
153
- this.removeStyles(this._styles);
151
+ if (this._mainStyles !== null) {
152
+ this.removeStyles(this._mainStyles);
154
153
  }
155
- this._styles = value;
154
+ this._mainStyles = value;
156
155
  if (!this.needsInitialization) {
157
156
  this.addStyles(value);
158
157
  }
159
158
  }
159
+ /**
160
+ * Adds the behavior to the component.
161
+ * @param behavior - The behavior to add.
162
+ */
163
+ addBehavior(behavior) {
164
+ var _a, _b;
165
+ const targetBehaviors = (_a = this.behaviors) !== null && _a !== void 0 ? _a : (this.behaviors = new Map());
166
+ const count = (_b = targetBehaviors.get(behavior)) !== null && _b !== void 0 ? _b : 0;
167
+ if (count === 0) {
168
+ targetBehaviors.set(behavior, 1);
169
+ behavior.addedCallback && behavior.addedCallback(this);
170
+ if (behavior.connectedCallback && this.isConnected) {
171
+ behavior.connectedCallback(this);
172
+ }
173
+ }
174
+ else {
175
+ targetBehaviors.set(behavior, count + 1);
176
+ }
177
+ }
178
+ /**
179
+ * Removes the behavior from the component.
180
+ * @param behavior - The behavior to remove.
181
+ * @param force - Forces removal even if this behavior was added more than once.
182
+ */
183
+ removeBehavior(behavior, force = false) {
184
+ const targetBehaviors = this.behaviors;
185
+ if (targetBehaviors === null) {
186
+ return;
187
+ }
188
+ const count = targetBehaviors.get(behavior);
189
+ if (count === void 0) {
190
+ return;
191
+ }
192
+ if (count === 1 || force) {
193
+ targetBehaviors.delete(behavior);
194
+ if (behavior.disconnectedCallback && this.isConnected) {
195
+ behavior.disconnectedCallback(this);
196
+ }
197
+ behavior.removedCallback && behavior.removedCallback(this);
198
+ }
199
+ else {
200
+ targetBehaviors.set(behavior, count - 1);
201
+ }
202
+ }
160
203
  /**
161
204
  * Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
162
205
  * @param styles - The styles to add.
163
206
  */
164
207
  addStyles(styles) {
208
+ var _a;
165
209
  if (!styles) {
166
210
  return;
167
211
  }
168
- const target = getShadowRoot(this.element) ||
169
- this.element.getRootNode();
212
+ const source = this.source;
213
+ const target = (_a = getShadowRoot(source)) !== null && _a !== void 0 ? _a : source.getRootNode();
170
214
  if (styles instanceof HTMLElement) {
171
215
  target.append(styles);
172
216
  }
@@ -174,7 +218,9 @@ export class Controller extends PropertyChangeNotifier {
174
218
  const sourceBehaviors = styles.behaviors;
175
219
  styles.addStylesTo(target);
176
220
  if (sourceBehaviors !== null) {
177
- this.addBehaviors(sourceBehaviors);
221
+ for (let i = 0, ii = sourceBehaviors.length; i < ii; ++i) {
222
+ this.addBehavior(sourceBehaviors[i]);
223
+ }
178
224
  }
179
225
  }
180
226
  }
@@ -183,11 +229,12 @@ export class Controller extends PropertyChangeNotifier {
183
229
  * @param styles - the styles to remove.
184
230
  */
185
231
  removeStyles(styles) {
232
+ var _a;
186
233
  if (!styles) {
187
234
  return;
188
235
  }
189
- const target = getShadowRoot(this.element) ||
190
- this.element.getRootNode();
236
+ const source = this.source;
237
+ const target = (_a = getShadowRoot(source)) !== null && _a !== void 0 ? _a : source.getRootNode();
191
238
  if (styles instanceof HTMLElement) {
192
239
  target.removeChild(styles);
193
240
  }
@@ -195,85 +242,29 @@ export class Controller extends PropertyChangeNotifier {
195
242
  const sourceBehaviors = styles.behaviors;
196
243
  styles.removeStylesFrom(target);
197
244
  if (sourceBehaviors !== null) {
198
- this.removeBehaviors(sourceBehaviors);
199
- }
200
- }
201
- }
202
- /**
203
- * Adds behaviors to this element.
204
- * @param behaviors - The behaviors to add.
205
- */
206
- addBehaviors(behaviors) {
207
- var _a;
208
- const targetBehaviors = (_a = this.behaviors) !== null && _a !== void 0 ? _a : (this.behaviors = new Map());
209
- const length = behaviors.length;
210
- const behaviorsToBind = [];
211
- for (let i = 0; i < length; ++i) {
212
- const behavior = behaviors[i];
213
- if (targetBehaviors.has(behavior)) {
214
- targetBehaviors.set(behavior, targetBehaviors.get(behavior) + 1);
215
- }
216
- else {
217
- targetBehaviors.set(behavior, 1);
218
- behaviorsToBind.push(behavior);
219
- }
220
- }
221
- if (this._isConnected) {
222
- const element = this.element;
223
- const context = ExecutionContext.default;
224
- for (let i = 0; i < behaviorsToBind.length; ++i) {
225
- behaviorsToBind[i].bind(element, context);
226
- }
227
- }
228
- }
229
- /**
230
- * Removes behaviors from this element.
231
- * @param behaviors - The behaviors to remove.
232
- * @param force - Forces unbinding of behaviors.
233
- */
234
- removeBehaviors(behaviors, force = false) {
235
- const targetBehaviors = this.behaviors;
236
- if (targetBehaviors === null) {
237
- return;
238
- }
239
- const length = behaviors.length;
240
- const behaviorsToUnbind = [];
241
- for (let i = 0; i < length; ++i) {
242
- const behavior = behaviors[i];
243
- if (targetBehaviors.has(behavior)) {
244
- const count = targetBehaviors.get(behavior) - 1;
245
- count === 0 || force
246
- ? targetBehaviors.delete(behavior) && behaviorsToUnbind.push(behavior)
247
- : targetBehaviors.set(behavior, count);
248
- }
249
- }
250
- if (this._isConnected) {
251
- const element = this.element;
252
- const context = ExecutionContext.default;
253
- for (let i = 0; i < behaviorsToUnbind.length; ++i) {
254
- behaviorsToUnbind[i].unbind(element, context);
245
+ for (let i = 0, ii = sourceBehaviors.length; i < ii; ++i) {
246
+ this.addBehavior(sourceBehaviors[i]);
247
+ }
255
248
  }
256
249
  }
257
250
  }
258
251
  /**
259
252
  * Runs connected lifecycle behavior on the associated element.
260
253
  */
261
- onConnectedCallback() {
254
+ connect() {
262
255
  if (this._isConnected) {
263
256
  return;
264
257
  }
265
- const element = this.element;
266
- const context = ExecutionContext.default;
267
258
  if (this.needsInitialization) {
268
259
  this.finishInitialization();
269
260
  }
270
261
  else if (this.view !== null) {
271
- this.view.bind(element, context);
262
+ this.view.bind(this.source);
272
263
  }
273
264
  const behaviors = this.behaviors;
274
265
  if (behaviors !== null) {
275
- for (const behavior of behaviors.keys()) {
276
- behavior.bind(element, context);
266
+ for (const key of behaviors.keys()) {
267
+ key.connectedCallback && key.connectedCallback(this);
277
268
  }
278
269
  }
279
270
  this.setIsConnected(true);
@@ -281,21 +272,18 @@ export class Controller extends PropertyChangeNotifier {
281
272
  /**
282
273
  * Runs disconnected lifecycle behavior on the associated element.
283
274
  */
284
- onDisconnectedCallback() {
275
+ disconnect() {
285
276
  if (!this._isConnected) {
286
277
  return;
287
278
  }
288
279
  this.setIsConnected(false);
289
- const view = this.view;
290
- if (view !== null) {
291
- view.unbind();
280
+ if (this.view !== null) {
281
+ this.view.unbind();
292
282
  }
293
283
  const behaviors = this.behaviors;
294
284
  if (behaviors !== null) {
295
- const element = this.element;
296
- const context = ExecutionContext.default;
297
- for (const behavior of behaviors.keys()) {
298
- behavior.unbind(element, context);
285
+ for (const key of behaviors.keys()) {
286
+ key.disconnectedCallback && key.disconnectedCallback(this);
299
287
  }
300
288
  }
301
289
  }
@@ -308,7 +296,7 @@ export class Controller extends PropertyChangeNotifier {
308
296
  onAttributeChangedCallback(name, oldValue, newValue) {
309
297
  const attrDef = this.definition.attributeLookup[name];
310
298
  if (attrDef !== void 0) {
311
- attrDef.onAttributeChangedCallback(this.element, newValue);
299
+ attrDef.onAttributeChangedCallback(this.source, newValue);
312
300
  }
313
301
  }
314
302
  /**
@@ -321,12 +309,12 @@ export class Controller extends PropertyChangeNotifier {
321
309
  */
322
310
  emit(type, detail, options) {
323
311
  if (this._isConnected) {
324
- return this.element.dispatchEvent(new CustomEvent(type, Object.assign(Object.assign({ detail }, defaultEventOptions), options)));
312
+ return this.source.dispatchEvent(new CustomEvent(type, Object.assign(Object.assign({ detail }, defaultEventOptions), options)));
325
313
  }
326
314
  return false;
327
315
  }
328
316
  finishInitialization() {
329
- const element = this.element;
317
+ const element = this.source;
330
318
  const boundObservables = this.boundObservables;
331
319
  // If we have any observables that were bound, re-apply their values.
332
320
  if (boundObservables !== null) {
@@ -338,15 +326,15 @@ export class Controller extends PropertyChangeNotifier {
338
326
  this.boundObservables = null;
339
327
  }
340
328
  this.renderTemplate(this.template);
341
- this.addStyles(this.styles);
329
+ this.addStyles(this.mainStyles);
342
330
  this.needsInitialization = false;
343
331
  }
344
332
  renderTemplate(template) {
345
333
  var _a;
346
- const element = this.element;
347
334
  // When getting the host to render to, we start by looking
348
335
  // up the shadow root. If there isn't one, then that means
349
336
  // we're doing a Light DOM render to the element's direct children.
337
+ const element = this.source;
350
338
  const host = (_a = getShadowRoot(element)) !== null && _a !== void 0 ? _a : element;
351
339
  if (this.view !== null) {
352
340
  // If there's already a view, we need to unbind and remove through dispose.
@@ -363,6 +351,8 @@ export class Controller extends PropertyChangeNotifier {
363
351
  if (template) {
364
352
  // If a new template was provided, render it.
365
353
  this.view = template.render(element, host, element);
354
+ this.view.sourceLifetime =
355
+ SourceLifetime.coupled;
366
356
  }
367
357
  }
368
358
  /**
@@ -382,6 +372,6 @@ export class Controller extends PropertyChangeNotifier {
382
372
  if (definition === void 0) {
383
373
  throw FAST.error(1401 /* Message.missingElementDefinition */);
384
374
  }
385
- return (element.$fastController = new Controller(element, definition));
375
+ return (element.$fastController = new ElementController(element, definition));
386
376
  }
387
377
  }
@@ -12,6 +12,7 @@ const fastElementRegistry = FAST.getById(4 /* KernelServiceId.elementRegistry */
12
12
  */
13
13
  export class FASTElementDefinition {
14
14
  constructor(type, nameOrConfig = type.definition) {
15
+ var _a;
15
16
  this.platformDefined = false;
16
17
  if (isString(nameOrConfig)) {
17
18
  nameOrConfig = { name: nameOrConfig };
@@ -19,6 +20,7 @@ export class FASTElementDefinition {
19
20
  this.type = type;
20
21
  this.name = nameOrConfig.name;
21
22
  this.template = nameOrConfig.template;
23
+ this.registry = (_a = nameOrConfig.registry) !== null && _a !== void 0 ? _a : customElements;
22
24
  const proto = type.prototype;
23
25
  const attributes = AttributeDefinition.collect(type, nameOrConfig.attributes);
24
26
  const observedAttributes = new Array(attributes.length);
@@ -63,7 +65,7 @@ export class FASTElementDefinition {
63
65
  * @remarks
64
66
  * This operation is idempotent per registry.
65
67
  */
66
- define(registry = customElements) {
68
+ define(registry = this.registry) {
67
69
  const type = this.type;
68
70
  if (!registry.get(this.name)) {
69
71
  this.platformDefined = true;
@@ -1,5 +1,5 @@
1
1
  import { isFunction } from "../interfaces.js";
2
- import { Controller } from "./controller.js";
2
+ import { ElementController } from "./element-controller.js";
3
3
  import { FASTElementDefinition, } from "./fast-definitions.js";
4
4
  /* eslint-disable-next-line @typescript-eslint/explicit-function-return-type */
5
5
  function createFASTElement(BaseType) {
@@ -7,16 +7,16 @@ function createFASTElement(BaseType) {
7
7
  constructor() {
8
8
  /* eslint-disable-next-line */
9
9
  super();
10
- Controller.forCustomElement(this);
10
+ ElementController.forCustomElement(this);
11
11
  }
12
12
  $emit(type, detail, options) {
13
13
  return this.$fastController.emit(type, detail, options);
14
14
  }
15
15
  connectedCallback() {
16
- this.$fastController.onConnectedCallback();
16
+ this.$fastController.connect();
17
17
  }
18
18
  disconnectedCallback() {
19
- this.$fastController.onDisconnectedCallback();
19
+ this.$fastController.disconnect();
20
20
  }
21
21
  attributeChangedCallback(name, oldValue, newValue) {
22
22
  this.$fastController.onAttributeChangedCallback(name, oldValue, newValue);
package/dist/esm/di/di.js CHANGED
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  /**
2
11
  * Big thanks to https://github.com/fkleuver and the https://github.com/aurelia/aurelia project
3
12
  * for the bulk of this code and many of the associated tests.
@@ -134,6 +143,7 @@ export const ContainerConfiguration = Object.freeze({
134
143
  */
135
144
  default: Object.freeze({
136
145
  parentLocator: () => null,
146
+ asyncRegistrationLocator: () => __awaiter(void 0, void 0, void 0, function* () { return null; }),
137
147
  responsibleForOwnerRequests: false,
138
148
  defaultResolver: DefaultResolver.singleton,
139
149
  }),
@@ -718,6 +728,35 @@ export class ResolverImpl {
718
728
  register(container) {
719
729
  return container.registerResolver(this.key, this);
720
730
  }
731
+ resolveAsync(handler, requestor) {
732
+ switch (this.strategy) {
733
+ case 1 /* ResolverStrategy.singleton */: {
734
+ if (this.resolving) {
735
+ throw FAST.error(1513 /* Message.cyclicDependency */, { name: this.state.name });
736
+ }
737
+ this.resolving = true;
738
+ return handler
739
+ .getFactory(this.state)
740
+ .constructAsync(requestor)
741
+ .then(instance => {
742
+ this.state = instance;
743
+ this.strategy = 0 /* ResolverStrategy.instance */;
744
+ this.resolving = false;
745
+ return instance;
746
+ });
747
+ }
748
+ case 2 /* ResolverStrategy.transient */: {
749
+ // Always create transients from the requesting container
750
+ const factory = handler.getFactory(this.state);
751
+ if (factory === null) {
752
+ throw FAST.error(1502 /* Message.noFactoryForResolver */, { key: this.key });
753
+ }
754
+ return factory.constructAsync(requestor);
755
+ }
756
+ default:
757
+ return Promise.resolve(this.resolve(handler, requestor));
758
+ }
759
+ }
721
760
  resolve(handler, requestor) {
722
761
  switch (this.strategy) {
723
762
  case 0 /* ResolverStrategy.instance */:
@@ -780,15 +819,25 @@ export class FactoryImpl {
780
819
  this.dependencies = dependencies;
781
820
  this.transformers = null;
782
821
  }
822
+ constructAsync(container, dynamicDependencies) {
823
+ return __awaiter(this, void 0, void 0, function* () {
824
+ const resolved = yield Promise.all(this.dependencies.map(x => container.getAsync(x)));
825
+ return this.constructCore(resolved, dynamicDependencies);
826
+ });
827
+ }
783
828
  construct(container, dynamicDependencies) {
829
+ const resolved = this.dependencies.map(containerGetKey, container);
830
+ return this.constructCore(resolved, dynamicDependencies);
831
+ }
832
+ constructCore(resolved, dynamicDependencies) {
784
833
  let instance;
785
834
  if (dynamicDependencies === void 0) {
786
- instance = new this.Type(...this.dependencies.map(containerGetKey, container));
835
+ instance = new this.Type(...resolved);
787
836
  }
788
837
  else {
789
- instance = new this.Type(...this.dependencies.map(containerGetKey, container), ...dynamicDependencies);
838
+ instance = new this.Type(...resolved, ...dynamicDependencies);
790
839
  }
791
- if (this.transformers == null) {
840
+ if (this.transformers === null) {
792
841
  return instance;
793
842
  }
794
843
  return this.transformers.reduce(transformInstance, instance);
@@ -802,6 +851,9 @@ const containerResolver = {
802
851
  resolve(handler, requestor) {
803
852
  return requestor;
804
853
  },
854
+ resolveAsync: function (handler, requestor) {
855
+ return Promise.resolve(requestor);
856
+ },
805
857
  };
806
858
  function isRegistry(obj) {
807
859
  return typeof obj.register === "function";
@@ -1014,6 +1066,38 @@ export class ContainerImpl {
1014
1066
  ? this.parent.has(key, true)
1015
1067
  : false;
1016
1068
  }
1069
+ getAsync(key) {
1070
+ return __awaiter(this, void 0, void 0, function* () {
1071
+ validateKey(key);
1072
+ if (key.$isResolver) {
1073
+ return key.resolveAsync(this, this);
1074
+ }
1075
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias */
1076
+ let current = this;
1077
+ let resolver;
1078
+ while (current != null) {
1079
+ resolver = current.resolvers.get(key);
1080
+ if (resolver == null) {
1081
+ if (current.parent == null) {
1082
+ const registration = yield this.config.asyncRegistrationLocator(key);
1083
+ if (!registration) {
1084
+ throw FAST.error(1505 /* Message.cannotResolveKey */, { key });
1085
+ }
1086
+ const handler = isRegisterInRequester(key)
1087
+ ? this
1088
+ : current;
1089
+ resolver = registration.register(handler);
1090
+ return resolver.resolveAsync(current, this);
1091
+ }
1092
+ current = current.parent;
1093
+ }
1094
+ else {
1095
+ return resolver.resolveAsync(current, this);
1096
+ }
1097
+ }
1098
+ throw FAST.error(1505 /* Message.cannotResolveKey */, { key });
1099
+ });
1100
+ }
1017
1101
  get(key) {
1018
1102
  validateKey(key);
1019
1103
  if (key.$isResolver) {
package/dist/esm/index.js CHANGED
@@ -8,6 +8,7 @@ export * from "./observation/update-queue.js";
8
8
  export * from "./styles/element-styles.js";
9
9
  export * from "./styles/css.js";
10
10
  export * from "./styles/css-directive.js";
11
+ export * from "./styles/host.js";
11
12
  // Templating
12
13
  export * from "./templating/dom.js";
13
14
  export * from "./templating/template.js";
@@ -26,4 +27,4 @@ export * from "./templating/node-observation.js";
26
27
  export * from "./components/fast-element.js";
27
28
  export * from "./components/fast-definitions.js";
28
29
  export * from "./components/attributes.js";
29
- export * from "./components/controller.js";
30
+ export * from "./components/element-controller.js";