@microsoft/fast-element 2.9.2 → 2.10.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.
Files changed (82) hide show
  1. package/CHANGELOG.json +58 -0
  2. package/CHANGELOG.md +22 -1
  3. package/dist/dts/binding/one-way.d.ts +1 -1
  4. package/dist/dts/binding/two-way.d.ts +2 -2
  5. package/dist/dts/components/attributes.d.ts +1 -1
  6. package/dist/dts/components/element-controller.d.ts +19 -8
  7. package/dist/dts/components/fast-definitions.d.ts +4 -4
  8. package/dist/dts/components/fast-element.d.ts +2 -2
  9. package/dist/dts/context.d.ts +1 -1
  10. package/dist/dts/di/di.d.ts +2 -2
  11. package/dist/dts/dom-policy.d.ts +3 -3
  12. package/dist/dts/index.d.ts +41 -28
  13. package/dist/dts/observable.d.ts +4 -2
  14. package/dist/dts/observation/arrays.d.ts +1 -1
  15. package/dist/dts/observation/observable.d.ts +1 -1
  16. package/dist/dts/observation/update-queue.d.ts +1 -1
  17. package/dist/dts/platform.d.ts +1 -1
  18. package/dist/dts/state/state.d.ts +1 -1
  19. package/dist/dts/state/watch.d.ts +1 -1
  20. package/dist/dts/styles/css-binding-directive.d.ts +1 -1
  21. package/dist/dts/styles/css.d.ts +2 -2
  22. package/dist/dts/templating/children.d.ts +1 -2
  23. package/dist/dts/templating/compiler.d.ts +2 -2
  24. package/dist/dts/templating/html-binding-directive.d.ts +3 -3
  25. package/dist/dts/templating/html-directive.d.ts +2 -2
  26. package/dist/dts/templating/node-observation.d.ts +1 -1
  27. package/dist/dts/templating/ref.d.ts +1 -1
  28. package/dist/dts/templating/render.d.ts +4 -4
  29. package/dist/dts/templating/repeat.d.ts +4 -4
  30. package/dist/dts/templating/slotted.d.ts +1 -1
  31. package/dist/dts/templating/template.d.ts +2 -2
  32. package/dist/dts/templating/view.d.ts +2 -2
  33. package/dist/esm/binding/one-way.js +1 -1
  34. package/dist/esm/binding/two-way.js +3 -3
  35. package/dist/esm/components/element-controller.js +69 -23
  36. package/dist/esm/components/fast-definitions.js +1 -1
  37. package/dist/esm/context.js +2 -2
  38. package/dist/esm/di/di.js +61 -51
  39. package/dist/esm/dom-policy.js +2 -2
  40. package/dist/esm/dom.js +2 -2
  41. package/dist/esm/index.js +21 -22
  42. package/dist/esm/interfaces.js +38 -0
  43. package/dist/esm/observable.js +1 -1
  44. package/dist/esm/observation/arrays.js +17 -10
  45. package/dist/esm/observation/observable.js +3 -3
  46. package/dist/esm/styles/css.js +2 -2
  47. package/dist/esm/templating/children.js +5 -8
  48. package/dist/esm/templating/compiler.js +5 -5
  49. package/dist/esm/templating/html-binding-directive.js +2 -2
  50. package/dist/esm/templating/node-observation.js +1 -1
  51. package/dist/esm/templating/render.js +4 -4
  52. package/dist/esm/templating/repeat.js +4 -4
  53. package/dist/esm/templating/slotted.js +1 -1
  54. package/dist/esm/templating/template.js +7 -7
  55. package/dist/fast-element.api.json +70 -11
  56. package/dist/fast-element.debug.js +2312 -2224
  57. package/dist/fast-element.debug.min.js +2 -2
  58. package/dist/fast-element.js +2312 -2224
  59. package/dist/fast-element.min.js +2 -2
  60. package/dist/fast-element.untrimmed.d.ts +17 -7
  61. package/docs/api-report.api.md +5 -4
  62. package/package.json +4 -3
  63. package/playwright.config.ts +18 -0
  64. package/test/index.html +11 -0
  65. package/test/main.ts +10 -0
  66. package/test/vite.config.ts +19 -0
  67. package/dist/dts/observation/observable.bench.d.ts +0 -18
  68. package/dist/dts/templating/render.bench.d.ts +0 -3
  69. package/dist/dts/templating/repeat-basic-reverse.bench.d.ts +0 -3
  70. package/dist/dts/templating/repeat-basic-shift.bench.d.ts +0 -3
  71. package/dist/dts/templating/when-basic.bench.d.ts +0 -3
  72. package/dist/dts/templating/when-conditional.bench.d.ts +0 -3
  73. package/dist/dts/templating/when-switch.bench.d.ts +0 -3
  74. package/dist/esm/observation/observable.bench.js +0 -79
  75. package/dist/esm/templating/render.bench.js +0 -56
  76. package/dist/esm/templating/repeat-basic-reverse.bench.js +0 -43
  77. package/dist/esm/templating/repeat-basic-shift.bench.js +0 -43
  78. package/dist/esm/templating/when-basic.bench.js +0 -36
  79. package/dist/esm/templating/when-conditional.bench.js +0 -39
  80. package/dist/esm/templating/when-switch.bench.js +0 -68
  81. package/scripts/run-benchmarks.js +0 -46
  82. package/tensile.config.js +0 -12
@@ -1,4 +1,4 @@
1
- import "../interfaces.js";
1
+ import { Message } from "../interfaces.js";
2
2
  import { PropertyChangeNotifier } from "../observation/notifier.js";
3
3
  import { ExecutionContext, Observable, SourceLifetime, } from "../observation/observable.js";
4
4
  import { FAST, makeSerializationNoop } from "../platform.js";
@@ -22,6 +22,21 @@ function getShadowRoot(element) {
22
22
  return (_b = (_a = element.shadowRoot) !== null && _a !== void 0 ? _a : shadowRoots.get(element)) !== null && _b !== void 0 ? _b : null;
23
23
  }
24
24
  let elementControllerStrategy;
25
+ /**
26
+ * The various lifecycle stages of an ElementController.
27
+ * @public
28
+ */
29
+ export var Stages;
30
+ (function (Stages) {
31
+ /** The element is in the process of connecting. */
32
+ Stages[Stages["connecting"] = 0] = "connecting";
33
+ /** The element is connected. */
34
+ Stages[Stages["connected"] = 1] = "connected";
35
+ /** The element is in the process of disconnecting. */
36
+ Stages[Stages["disconnecting"] = 2] = "disconnecting";
37
+ /** The element is disconnected. */
38
+ Stages[Stages["disconnected"] = 3] = "disconnected";
39
+ })(Stages || (Stages = {}));
25
40
  /**
26
41
  * Controls the lifecycle and rendering of a `FASTElement`.
27
42
  * @public
@@ -33,7 +48,7 @@ export class ElementController extends PropertyChangeNotifier {
33
48
  */
34
49
  get isConnected() {
35
50
  Observable.track(this, isConnectedPropertyName);
36
- return this.stage === 1 /* Stages.connected */;
51
+ return this.stage === Stages.connected;
37
52
  }
38
53
  /**
39
54
  * The context the expression is evaluated against.
@@ -168,7 +183,7 @@ export class ElementController extends PropertyChangeNotifier {
168
183
  /**
169
184
  * The current lifecycle stage of the controller.
170
185
  */
171
- this.stage = 3 /* Stages.disconnected */;
186
+ this.stage = Stages.disconnected;
172
187
  /**
173
188
  * A guard against connecting behaviors multiple times
174
189
  * during connect in scenarios where a behavior adds
@@ -245,7 +260,7 @@ export class ElementController extends PropertyChangeNotifier {
245
260
  behavior.addedCallback && behavior.addedCallback(this);
246
261
  if (behavior.connectedCallback &&
247
262
  !this.guardBehaviorConnection &&
248
- (this.stage === 1 /* Stages.connected */ || this.stage === 0 /* Stages.connecting */)) {
263
+ (this.stage === Stages.connected || this.stage === Stages.connecting)) {
249
264
  behavior.connectedCallback(this);
250
265
  }
251
266
  }
@@ -269,7 +284,7 @@ export class ElementController extends PropertyChangeNotifier {
269
284
  }
270
285
  if (count === 1 || force) {
271
286
  targetBehaviors.delete(behavior);
272
- if (behavior.disconnectedCallback && this.stage !== 3 /* Stages.disconnected */) {
287
+ if (behavior.disconnectedCallback && this.stage !== Stages.disconnected) {
273
288
  behavior.disconnectedCallback(this);
274
289
  }
275
290
  behavior.removedCallback && behavior.removedCallback(this);
@@ -330,10 +345,10 @@ export class ElementController extends PropertyChangeNotifier {
330
345
  * Runs connected lifecycle behavior on the associated element.
331
346
  */
332
347
  connect() {
333
- if (this.stage !== 3 /* Stages.disconnected */) {
348
+ if (this.stage !== Stages.disconnected) {
334
349
  return;
335
350
  }
336
- this.stage = 0 /* Stages.connecting */;
351
+ this.stage = Stages.connecting;
337
352
  this.bindObservables();
338
353
  this.connectBehaviors();
339
354
  if (this.needsInitialization) {
@@ -344,7 +359,7 @@ export class ElementController extends PropertyChangeNotifier {
344
359
  else if (this.view !== null) {
345
360
  this.view.bind(this.source);
346
361
  }
347
- this.stage = 1 /* Stages.connected */;
362
+ this.stage = Stages.connected;
348
363
  Observable.notify(this, isConnectedPropertyName);
349
364
  }
350
365
  /**
@@ -396,16 +411,16 @@ export class ElementController extends PropertyChangeNotifier {
396
411
  * Runs disconnected lifecycle behavior on the associated element.
397
412
  */
398
413
  disconnect() {
399
- if (this.stage !== 1 /* Stages.connected */) {
414
+ if (this.stage !== Stages.connected) {
400
415
  return;
401
416
  }
402
- this.stage = 2 /* Stages.disconnecting */;
417
+ this.stage = Stages.disconnecting;
403
418
  Observable.notify(this, isConnectedPropertyName);
404
419
  if (this.view !== null) {
405
420
  this.view.unbind();
406
421
  }
407
422
  this.disconnectBehaviors();
408
- this.stage = 3 /* Stages.disconnected */;
423
+ this.stage = Stages.disconnected;
409
424
  }
410
425
  /**
411
426
  * Runs the attribute changed callback for the associated element.
@@ -428,7 +443,7 @@ export class ElementController extends PropertyChangeNotifier {
428
443
  * Only emits events if connected.
429
444
  */
430
445
  emit(type, detail, options) {
431
- if (this.stage === 1 /* Stages.connected */) {
446
+ if (this.stage === Stages.connected) {
432
447
  return this.source.dispatchEvent(new CustomEvent(type, Object.assign(Object.assign({ detail }, defaultEventOptions), options)));
433
448
  }
434
449
  return false;
@@ -482,7 +497,7 @@ export class ElementController extends PropertyChangeNotifier {
482
497
  }
483
498
  const definition = FASTElementDefinition.getForInstance(element);
484
499
  if (definition === void 0) {
485
- throw FAST.error(1401 /* Message.missingElementDefinition */);
500
+ throw FAST.error(Message.missingElementDefinition);
486
501
  }
487
502
  Observable.getNotifier(definition).subscribe({
488
503
  handleChange: () => {
@@ -698,7 +713,12 @@ export class HydratableElementController extends ElementController {
698
713
  }
699
714
  // If there are no more hydrating instances, invoke the hydrationComplete callback
700
715
  if (((_a = HydratableElementController.hydratingInstances) === null || _a === void 0 ? void 0 : _a.size) === 0) {
701
- (_c = (_b = HydratableElementController.lifecycleCallbacks) === null || _b === void 0 ? void 0 : _b.hydrationComplete) === null || _c === void 0 ? void 0 : _c.call(_b);
716
+ try {
717
+ (_c = (_b = HydratableElementController.lifecycleCallbacks).hydrationComplete) === null || _c === void 0 ? void 0 : _c.call(_b);
718
+ }
719
+ catch (_d) {
720
+ // A lifecycle callback must never prevent post-hydration cleanup.
721
+ }
702
722
  // Reset to the default strategy after hydration is complete
703
723
  ElementController.setStrategy(ElementController);
704
724
  }
@@ -707,7 +727,7 @@ export class HydratableElementController extends ElementController {
707
727
  * Runs connected lifecycle behavior on the associated element.
708
728
  */
709
729
  connect() {
710
- var _a, _b, _c, _d, _e;
730
+ var _a, _b, _c, _d, _e, _f, _g;
711
731
  // Initialize needsHydration on first connect
712
732
  this.needsHydration =
713
733
  (_a = this.needsHydration) !== null && _a !== void 0 ? _a : this.source.hasAttribute(needsHydrationAttribute);
@@ -729,17 +749,31 @@ export class HydratableElementController extends ElementController {
729
749
  this.removeHydratingInstance();
730
750
  return;
731
751
  }
732
- if (this.stage !== 3 /* Stages.disconnected */) {
752
+ if (this.stage !== Stages.disconnected) {
733
753
  return;
734
754
  }
735
- (_c = (_b = HydratableElementController.lifecycleCallbacks) === null || _b === void 0 ? void 0 : _b.elementWillHydrate) === null || _c === void 0 ? void 0 : _c.call(_b, this.definition.name);
736
- this.stage = 0 /* Stages.connecting */;
755
+ if (!HydratableElementController.hydrationStarted) {
756
+ HydratableElementController.hydrationStarted = true;
757
+ try {
758
+ (_c = (_b = HydratableElementController.lifecycleCallbacks).hydrationStarted) === null || _c === void 0 ? void 0 : _c.call(_b);
759
+ }
760
+ catch (_h) {
761
+ // A lifecycle callback must never prevent hydration.
762
+ }
763
+ }
764
+ try {
765
+ (_e = (_d = HydratableElementController.lifecycleCallbacks).elementWillHydrate) === null || _e === void 0 ? void 0 : _e.call(_d, this.source);
766
+ }
767
+ catch (_j) {
768
+ // A lifecycle callback must never prevent hydration.
769
+ }
770
+ this.stage = Stages.connecting;
737
771
  this.bindObservables();
738
772
  this.connectBehaviors();
739
773
  if (this.template) {
740
774
  if (isHydratable(this.template)) {
741
775
  const element = this.source;
742
- const host = (_d = getShadowRoot(element)) !== null && _d !== void 0 ? _d : element;
776
+ const host = (_f = getShadowRoot(element)) !== null && _f !== void 0 ? _f : element;
743
777
  let firstChild = host.firstChild;
744
778
  let lastChild = host.lastChild;
745
779
  if (element.shadowRoot === null) {
@@ -754,14 +788,14 @@ export class HydratableElementController extends ElementController {
754
788
  }
755
789
  }
756
790
  this.view = this.template.hydrate(firstChild, lastChild, element);
757
- (_e = this.view) === null || _e === void 0 ? void 0 : _e.bind(this.source);
791
+ (_g = this.view) === null || _g === void 0 ? void 0 : _g.bind(this.source);
758
792
  }
759
793
  else {
760
794
  this.renderTemplate(this.template);
761
795
  }
762
796
  }
763
797
  this.addStyles(this.mainStyles);
764
- this.stage = 1 /* Stages.connected */;
798
+ this.stage = Stages.connected;
765
799
  this.source.removeAttribute(needsHydrationAttribute);
766
800
  this.needsInitialization = this.needsHydration = false;
767
801
  this.removeHydratingInstance();
@@ -775,10 +809,14 @@ export class HydratableElementController extends ElementController {
775
809
  if (!HydratableElementController.hydratingInstances) {
776
810
  return;
777
811
  }
812
+ try {
813
+ (_b = (_a = HydratableElementController.lifecycleCallbacks).elementDidHydrate) === null || _b === void 0 ? void 0 : _b.call(_a, this.source);
814
+ }
815
+ catch (_c) {
816
+ // A lifecycle callback must never prevent hydration.
817
+ }
778
818
  const name = this.definition.name;
779
819
  const instances = HydratableElementController.hydratingInstances.get(name);
780
- // Callback: After hydration has finished
781
- (_b = (_a = HydratableElementController.lifecycleCallbacks) === null || _a === void 0 ? void 0 : _a.elementDidHydrate) === null || _b === void 0 ? void 0 : _b.call(_a, this.definition.name);
782
820
  if (instances) {
783
821
  instances.delete(this.source);
784
822
  if (!instances.size) {
@@ -808,6 +846,14 @@ export class HydratableElementController extends ElementController {
808
846
  }
809
847
  }
810
848
  HydratableElementController.hydrationObserver = new UnobservableMutationObserver(HydratableElementController.hydrationObserverHandler);
849
+ /**
850
+ * Lifecycle callbacks for hydration events
851
+ */
852
+ HydratableElementController.lifecycleCallbacks = {};
853
+ /**
854
+ * Whether the hydrationStarted callback has already been invoked.
855
+ */
856
+ HydratableElementController.hydrationStarted = false;
811
857
  /**
812
858
  * An idle callback ID used to track hydration completion
813
859
  */
@@ -12,7 +12,7 @@ import { isString, KernelServiceId } from "../interfaces.js";
12
12
  import { Observable } from "../observation/observable.js";
13
13
  import { createTypeRegistry, FAST } from "../platform.js";
14
14
  import { ElementStyles } from "../styles/element-styles.js";
15
- import { AttributeDefinition } from "./attributes.js";
15
+ import { AttributeConfiguration, AttributeDefinition } from "./attributes.js";
16
16
  const defaultShadowOptions = { mode: "open" };
17
17
  const defaultElementOptions = {};
18
18
  const fastElementBaseTypes = new Set();
@@ -1,4 +1,4 @@
1
- import "./interfaces.js";
1
+ import { Message } from "./interfaces.js";
2
2
  import { Metadata } from "./metadata.js";
3
3
  import { FAST } from "./platform.js";
4
4
  const contextsByName = new Map();
@@ -37,7 +37,7 @@ export const Context = Object.freeze({
37
37
  create(name, initialValue) {
38
38
  const Interface = function (target, property, index) {
39
39
  if (target == null || new.target !== undefined) {
40
- throw FAST.error(1501 /* Message.noRegistrationForContext */, {
40
+ throw FAST.error(Message.noRegistrationForContext, {
41
41
  name: Interface.name,
42
42
  });
43
43
  }
package/dist/esm/di/di.js CHANGED
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  * Big thanks to https://github.com/fkleuver and the https://github.com/aurelia/aurelia project
12
12
  * for the bulk of this code and many of the associated tests.
13
13
  */
14
- import { Context } from "../context.js";
15
- import "../interfaces.js";
14
+ import { Context, ContextEvent, } from "../context.js";
15
+ import { Message } from "../interfaces.js";
16
16
  import { Metadata } from "../metadata.js";
17
17
  import { emptyArray, FAST } from "../platform.js";
18
18
  /**
@@ -36,7 +36,7 @@ export class ResolverBuilder {
36
36
  * @returns The resolver.
37
37
  */
38
38
  instance(value) {
39
- return this.registerResolver(0 /* ResolverStrategy.instance */, value);
39
+ return this.registerResolver(ResolverStrategy.instance, value);
40
40
  }
41
41
  /**
42
42
  * Creates a resolver that enforces a singleton lifetime.
@@ -44,7 +44,7 @@ export class ResolverBuilder {
44
44
  * @returns The resolver.
45
45
  */
46
46
  singleton(value) {
47
- return this.registerResolver(1 /* ResolverStrategy.singleton */, value);
47
+ return this.registerResolver(ResolverStrategy.singleton, value);
48
48
  }
49
49
  /**
50
50
  * Creates a resolver that creates a new instance for every dependency request.
@@ -52,7 +52,7 @@ export class ResolverBuilder {
52
52
  * @returns - The resolver.
53
53
  */
54
54
  transient(value) {
55
- return this.registerResolver(2 /* ResolverStrategy.transient */, value);
55
+ return this.registerResolver(ResolverStrategy.transient, value);
56
56
  }
57
57
  /**
58
58
  * Creates a resolver that invokes a callback function for every dependency resolution
@@ -61,7 +61,7 @@ export class ResolverBuilder {
61
61
  * @returns The resolver.
62
62
  */
63
63
  callback(value) {
64
- return this.registerResolver(3 /* ResolverStrategy.callback */, value);
64
+ return this.registerResolver(ResolverStrategy.callback, value);
65
65
  }
66
66
  /**
67
67
  * Creates a resolver that invokes a callback function the first time that a dependency
@@ -71,7 +71,7 @@ export class ResolverBuilder {
71
71
  * @returns The resolver.
72
72
  */
73
73
  cachedCallback(value) {
74
- return this.registerResolver(3 /* ResolverStrategy.callback */, cacheCallbackResult(value));
74
+ return this.registerResolver(ResolverStrategy.callback, cacheCallbackResult(value));
75
75
  }
76
76
  /**
77
77
  * Aliases the current key to a different key.
@@ -79,7 +79,7 @@ export class ResolverBuilder {
79
79
  * @returns The resolver.
80
80
  */
81
81
  aliasTo(destinationKey) {
82
- return this.registerResolver(5 /* ResolverStrategy.alias */, destinationKey);
82
+ return this.registerResolver(ResolverStrategy.alias, destinationKey);
83
83
  }
84
84
  registerResolver(strategy, state) {
85
85
  const { container, key } = this;
@@ -111,7 +111,7 @@ export const DefaultResolver = Object.freeze({
111
111
  * @param key - The key to create the resolver for.
112
112
  */
113
113
  none(key) {
114
- throw FAST.error(1512 /* Message.noDefaultResolver */, { key });
114
+ throw FAST.error(Message.noDefaultResolver, { key });
115
115
  },
116
116
  /**
117
117
  * Provides default singleton resolution behavior during auto-registration.
@@ -119,7 +119,7 @@ export const DefaultResolver = Object.freeze({
119
119
  * @returns The resolver.
120
120
  */
121
121
  singleton(key) {
122
- return new ResolverImpl(key, 1 /* ResolverStrategy.singleton */, key);
122
+ return new ResolverImpl(key, ResolverStrategy.singleton, key);
123
123
  },
124
124
  /**
125
125
  * Provides default transient resolution behavior during auto-registration.
@@ -127,7 +127,7 @@ export const DefaultResolver = Object.freeze({
127
127
  * @returns The resolver.
128
128
  */
129
129
  transient(key) {
130
- return new ResolverImpl(key, 2 /* ResolverStrategy.transient */, key);
130
+ return new ResolverImpl(key, ResolverStrategy.transient, key);
131
131
  },
132
132
  });
133
133
  /**
@@ -162,7 +162,7 @@ function createContext(nameConfigOrCallback, configuror) {
162
162
  : false;
163
163
  const Interface = function (target, property, index) {
164
164
  if (target == null || new.target !== undefined) {
165
- throw FAST.error(1501 /* Message.noRegistrationForContext */, { name: Interface.name });
165
+ throw FAST.error(Message.noRegistrationForContext, { name: Interface.name });
166
166
  }
167
167
  if (property) {
168
168
  DI.defineProperty(target, property, Interface, respectConnection);
@@ -385,7 +385,7 @@ export const DI = Object.freeze({
385
385
  if (respectConnection) {
386
386
  const notifier = this.$fastController;
387
387
  if (!notifier) {
388
- throw FAST.error(1514 /* Message.connectUpdateRequiresController */);
388
+ throw FAST.error(Message.connectUpdateRequiresController);
389
389
  }
390
390
  const handleChange = () => {
391
391
  const newContainer = DI.findResponsibleContainer(this);
@@ -693,7 +693,7 @@ ignore.resolve = () => undefined;
693
693
  */
694
694
  export const newInstanceForScope = createResolver((key, handler, requestor) => {
695
695
  const instance = createNewInstance(key, handler);
696
- const resolver = new ResolverImpl(key, 0 /* ResolverStrategy.instance */, instance);
696
+ const resolver = new ResolverImpl(key, ResolverStrategy.instance, instance);
697
697
  requestor.registerResolver(key, resolver);
698
698
  return instance;
699
699
  });
@@ -711,6 +711,16 @@ function createNewInstance(key, handler) {
711
711
  return handler.getFactory(key).construct(handler);
712
712
  }
713
713
  /** @internal */
714
+ export var ResolverStrategy;
715
+ (function (ResolverStrategy) {
716
+ ResolverStrategy[ResolverStrategy["instance"] = 0] = "instance";
717
+ ResolverStrategy[ResolverStrategy["singleton"] = 1] = "singleton";
718
+ ResolverStrategy[ResolverStrategy["transient"] = 2] = "transient";
719
+ ResolverStrategy[ResolverStrategy["callback"] = 3] = "callback";
720
+ ResolverStrategy[ResolverStrategy["array"] = 4] = "array";
721
+ ResolverStrategy[ResolverStrategy["alias"] = 5] = "alias";
722
+ })(ResolverStrategy || (ResolverStrategy = {}));
723
+ /** @internal */
714
724
  export class ResolverImpl {
715
725
  constructor(key, strategy, state) {
716
726
  this.key = key;
@@ -726,9 +736,9 @@ export class ResolverImpl {
726
736
  }
727
737
  resolveAsync(handler, requestor) {
728
738
  switch (this.strategy) {
729
- case 1 /* ResolverStrategy.singleton */: {
739
+ case ResolverStrategy.singleton: {
730
740
  if (this.resolving) {
731
- throw FAST.error(1513 /* Message.cyclicDependency */, { name: this.state.name });
741
+ throw FAST.error(Message.cyclicDependency, { name: this.state.name });
732
742
  }
733
743
  this.resolving = true;
734
744
  return handler
@@ -736,16 +746,16 @@ export class ResolverImpl {
736
746
  .constructAsync(requestor)
737
747
  .then(instance => {
738
748
  this.state = instance;
739
- this.strategy = 0 /* ResolverStrategy.instance */;
749
+ this.strategy = ResolverStrategy.instance;
740
750
  this.resolving = false;
741
751
  return instance;
742
752
  });
743
753
  }
744
- case 2 /* ResolverStrategy.transient */: {
754
+ case ResolverStrategy.transient: {
745
755
  // Always create transients from the requesting container
746
756
  const factory = handler.getFactory(this.state);
747
757
  if (factory === null) {
748
- throw FAST.error(1502 /* Message.noFactoryForResolver */, { key: this.key });
758
+ throw FAST.error(Message.noFactoryForResolver, { key: this.key });
749
759
  }
750
760
  return factory.constructAsync(requestor);
751
761
  }
@@ -755,36 +765,36 @@ export class ResolverImpl {
755
765
  }
756
766
  resolve(handler, requestor) {
757
767
  switch (this.strategy) {
758
- case 0 /* ResolverStrategy.instance */:
768
+ case ResolverStrategy.instance:
759
769
  return this.state;
760
- case 1 /* ResolverStrategy.singleton */: {
770
+ case ResolverStrategy.singleton: {
761
771
  if (this.resolving) {
762
- throw FAST.error(1513 /* Message.cyclicDependency */, { name: this.state.name });
772
+ throw FAST.error(Message.cyclicDependency, { name: this.state.name });
763
773
  }
764
774
  this.resolving = true;
765
775
  this.state = handler
766
776
  .getFactory(this.state)
767
777
  .construct(requestor);
768
- this.strategy = 0 /* ResolverStrategy.instance */;
778
+ this.strategy = ResolverStrategy.instance;
769
779
  this.resolving = false;
770
780
  return this.state;
771
781
  }
772
- case 2 /* ResolverStrategy.transient */: {
782
+ case ResolverStrategy.transient: {
773
783
  // Always create transients from the requesting container
774
784
  const factory = handler.getFactory(this.state);
775
785
  if (factory === null) {
776
- throw FAST.error(1502 /* Message.noFactoryForResolver */, { key: this.key });
786
+ throw FAST.error(Message.noFactoryForResolver, { key: this.key });
777
787
  }
778
788
  return factory.construct(requestor);
779
789
  }
780
- case 3 /* ResolverStrategy.callback */:
790
+ case ResolverStrategy.callback:
781
791
  return this.state(handler, requestor, this);
782
- case 4 /* ResolverStrategy.array */:
792
+ case ResolverStrategy.array:
783
793
  return this.state[0].resolve(handler, requestor);
784
- case 5 /* ResolverStrategy.alias */:
794
+ case ResolverStrategy.alias:
785
795
  return requestor.get(this.state);
786
796
  default:
787
- throw FAST.error(1503 /* Message.invalidResolverStrategy */, {
797
+ throw FAST.error(Message.invalidResolverStrategy, {
788
798
  strategy: this.strategy,
789
799
  });
790
800
  }
@@ -792,10 +802,10 @@ export class ResolverImpl {
792
802
  getFactory(container) {
793
803
  var _a, _b, _c;
794
804
  switch (this.strategy) {
795
- case 1 /* ResolverStrategy.singleton */:
796
- case 2 /* ResolverStrategy.transient */:
805
+ case ResolverStrategy.singleton:
806
+ case ResolverStrategy.transient:
797
807
  return container.getFactory(this.state);
798
- case 5 /* ResolverStrategy.alias */:
808
+ case ResolverStrategy.alias:
799
809
  return (_c = (_b = (_a = container.getResolver(this.state)) === null || _a === void 0 ? void 0 : _a.getFactory) === null || _b === void 0 ? void 0 : _b.call(_a, container)) !== null && _c !== void 0 ? _c : null;
800
810
  default:
801
811
  return null;
@@ -954,7 +964,7 @@ export class ContainerImpl {
954
964
  if (++this.registerDepth === 100) {
955
965
  // Most likely cause is trying to register a plain object that does not have a
956
966
  // register method and is not a class constructor
957
- throw FAST.error(1504 /* Message.cannotAutoregisterDependency */);
967
+ throw FAST.error(Message.cannotAutoregisterDependency);
958
968
  }
959
969
  let current;
960
970
  let keys;
@@ -1003,11 +1013,11 @@ export class ContainerImpl {
1003
1013
  resolvers.set(key, resolver);
1004
1014
  }
1005
1015
  else if (result instanceof ResolverImpl &&
1006
- result.strategy === 4 /* ResolverStrategy.array */) {
1016
+ result.strategy === ResolverStrategy.array) {
1007
1017
  result.state.push(resolver);
1008
1018
  }
1009
1019
  else {
1010
- resolvers.set(key, new ResolverImpl(key, 4 /* ResolverStrategy.array */, [result, resolver]));
1020
+ resolvers.set(key, new ResolverImpl(key, ResolverStrategy.array, [result, resolver]));
1011
1021
  }
1012
1022
  return resolver;
1013
1023
  }
@@ -1077,7 +1087,7 @@ export class ContainerImpl {
1077
1087
  if (current.parent == null) {
1078
1088
  const registration = yield this.config.asyncRegistrationLocator(key);
1079
1089
  if (!registration) {
1080
- throw FAST.error(1505 /* Message.cannotResolveKey */, { key });
1090
+ throw FAST.error(Message.cannotResolveKey, { key });
1081
1091
  }
1082
1092
  const handler = isRegisterInRequester(key)
1083
1093
  ? this
@@ -1091,7 +1101,7 @@ export class ContainerImpl {
1091
1101
  return resolver.resolveAsync(current, this);
1092
1102
  }
1093
1103
  }
1094
- throw FAST.error(1505 /* Message.cannotResolveKey */, { key });
1104
+ throw FAST.error(Message.cannotResolveKey, { key });
1095
1105
  });
1096
1106
  }
1097
1107
  get(key) {
@@ -1118,7 +1128,7 @@ export class ContainerImpl {
1118
1128
  return resolver.resolve(current, this);
1119
1129
  }
1120
1130
  }
1121
- throw FAST.error(1505 /* Message.cannotResolveKey */, { key });
1131
+ throw FAST.error(Message.cannotResolveKey, { key });
1122
1132
  }
1123
1133
  getAll(key, searchAncestors = false) {
1124
1134
  validateKey(key);
@@ -1159,7 +1169,7 @@ export class ContainerImpl {
1159
1169
  let factory = factories.get(Type);
1160
1170
  if (factory === void 0) {
1161
1171
  if (isNativeFunction(Type)) {
1162
- throw FAST.error(1506 /* Message.cannotConstructNativeFunction */, {
1172
+ throw FAST.error(Message.cannotConstructNativeFunction, {
1163
1173
  name: Type.name,
1164
1174
  });
1165
1175
  }
@@ -1175,12 +1185,12 @@ export class ContainerImpl {
1175
1185
  }
1176
1186
  jitRegister(keyAsValue, handler) {
1177
1187
  if (typeof keyAsValue !== "function") {
1178
- throw FAST.error(1507 /* Message.cannotJITRegisterNonConstructor */, {
1188
+ throw FAST.error(Message.cannotJITRegisterNonConstructor, {
1179
1189
  value: keyAsValue,
1180
1190
  });
1181
1191
  }
1182
1192
  if (InstrinsicTypeNames.has(keyAsValue.name)) {
1183
- throw FAST.error(1508 /* Message.cannotJITRegisterIntrinsic */, {
1193
+ throw FAST.error(Message.cannotJITRegisterIntrinsic, {
1184
1194
  value: keyAsValue.name,
1185
1195
  });
1186
1196
  }
@@ -1192,12 +1202,12 @@ export class ContainerImpl {
1192
1202
  if (newResolver != void 0) {
1193
1203
  return newResolver;
1194
1204
  }
1195
- throw FAST.error(1510 /* Message.invalidResolver */);
1205
+ throw FAST.error(Message.invalidResolver);
1196
1206
  }
1197
1207
  return registrationResolver;
1198
1208
  }
1199
1209
  else if (keyAsValue.$isInterface) {
1200
- throw FAST.error(1509 /* Message.cannotJITRegisterInterface */, {
1210
+ throw FAST.error(Message.cannotJITRegisterInterface, {
1201
1211
  value: keyAsValue.name,
1202
1212
  });
1203
1213
  }
@@ -1247,7 +1257,7 @@ export const Registration = Object.freeze({
1247
1257
  * @param value - The instance to return when the key is requested.
1248
1258
  */
1249
1259
  instance(key, value) {
1250
- return new ResolverImpl(key, 0 /* ResolverStrategy.instance */, value);
1260
+ return new ResolverImpl(key, ResolverStrategy.instance, value);
1251
1261
  },
1252
1262
  /**
1253
1263
  * Creates an instance from the class.
@@ -1262,7 +1272,7 @@ export const Registration = Object.freeze({
1262
1272
  * @param value - The class to instantiate as a singleton when first requested.
1263
1273
  */
1264
1274
  singleton(key, value) {
1265
- return new ResolverImpl(key, 1 /* ResolverStrategy.singleton */, value);
1275
+ return new ResolverImpl(key, ResolverStrategy.singleton, value);
1266
1276
  },
1267
1277
  /**
1268
1278
  * Creates an instance from a class.
@@ -1277,7 +1287,7 @@ export const Registration = Object.freeze({
1277
1287
  * @param value - The class to instantiate each time the key is requested.
1278
1288
  */
1279
1289
  transient(key, value) {
1280
- return new ResolverImpl(key, 2 /* ResolverStrategy.transient */, value);
1290
+ return new ResolverImpl(key, ResolverStrategy.transient, value);
1281
1291
  },
1282
1292
  /**
1283
1293
  * Delegates to a callback function to provide the dependency.
@@ -1294,7 +1304,7 @@ export const Registration = Object.freeze({
1294
1304
  * @param callback - The function that is expected to return the dependency.
1295
1305
  */
1296
1306
  callback(key, callback) {
1297
- return new ResolverImpl(key, 3 /* ResolverStrategy.callback */, callback);
1307
+ return new ResolverImpl(key, ResolverStrategy.callback, callback);
1298
1308
  },
1299
1309
  /**
1300
1310
  * Delegates to a callback function to provide the dependency and then caches the
@@ -1313,7 +1323,7 @@ export const Registration = Object.freeze({
1313
1323
  * Should all references to the resolver returned be removed, the cache will expire.
1314
1324
  */
1315
1325
  cachedCallback(key, callback) {
1316
- return new ResolverImpl(key, 3 /* ResolverStrategy.callback */, cacheCallbackResult(callback));
1326
+ return new ResolverImpl(key, ResolverStrategy.callback, cacheCallbackResult(callback));
1317
1327
  },
1318
1328
  /**
1319
1329
  * Creates an alternate {@link Key} to retrieve an instance by.
@@ -1330,18 +1340,18 @@ export const Registration = Object.freeze({
1330
1340
  * @param aliasKey - The alias to the original key.
1331
1341
  */
1332
1342
  aliasTo(originalKey, aliasKey) {
1333
- return new ResolverImpl(aliasKey, 5 /* ResolverStrategy.alias */, originalKey);
1343
+ return new ResolverImpl(aliasKey, ResolverStrategy.alias, originalKey);
1334
1344
  },
1335
1345
  });
1336
1346
  /** @internal */
1337
1347
  export function validateKey(key) {
1338
1348
  if (key === null || key === void 0) {
1339
- throw FAST.error(1511 /* Message.invalidKey */);
1349
+ throw FAST.error(Message.invalidKey);
1340
1350
  }
1341
1351
  }
1342
1352
  function buildAllResponse(resolver, handler, requestor) {
1343
1353
  if (resolver instanceof ResolverImpl &&
1344
- resolver.strategy === 4 /* ResolverStrategy.array */) {
1354
+ resolver.strategy === ResolverStrategy.array) {
1345
1355
  const state = resolver.state;
1346
1356
  let i = state.length;
1347
1357
  const results = new Array(i);
@@ -1,5 +1,5 @@
1
1
  import { DOMAspect } from "./dom.js";
2
- import { isString } from "./interfaces.js";
2
+ import { isString, Message } from "./interfaces.js";
3
3
  import { FAST } from "./platform.js";
4
4
  function safeURL(tagName, aspect, aspectName, sink) {
5
5
  return (target, name, value, ...rest) => {
@@ -10,7 +10,7 @@ function safeURL(tagName, aspect, aspectName, sink) {
10
10
  };
11
11
  }
12
12
  function block(tagName, aspect, aspectName, sink) {
13
- throw FAST.error(1209 /* Message.blockedByDOMPolicy */, {
13
+ throw FAST.error(Message.blockedByDOMPolicy, {
14
14
  aspectName,
15
15
  tagName: tagName !== null && tagName !== void 0 ? tagName : "text",
16
16
  });
package/dist/esm/dom.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./interfaces.js";
1
+ import { Message } from "./interfaces.js";
2
2
  import { FAST } from "./platform.js";
3
3
  /**
4
4
  * The type of HTML aspect to target.
@@ -67,7 +67,7 @@ export const DOM = Object.freeze({
67
67
  */
68
68
  setPolicy(value) {
69
69
  if (defaultPolicy !== fastPolicy) {
70
- throw FAST.error(1201 /* Message.onlySetDOMPolicyOnce */);
70
+ throw FAST.error(Message.onlySetDOMPolicyOnce);
71
71
  }
72
72
  defaultPolicy = value;
73
73
  },