@microsoft/fast-element 2.9.1 → 2.10.0
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.json +58 -0
- package/CHANGELOG.md +22 -1
- package/dist/context/context.api.json +7 -7
- package/dist/di/di.api.json +12 -12
- package/dist/dts/binding/one-way.d.ts +1 -1
- package/dist/dts/binding/two-way.d.ts +3 -3
- package/dist/dts/components/attributes.d.ts +4 -4
- package/dist/dts/components/element-controller.d.ts +19 -8
- package/dist/dts/components/fast-definitions.d.ts +5 -5
- package/dist/dts/components/fast-element.d.ts +2 -2
- package/dist/dts/context.d.ts +8 -8
- package/dist/dts/di/di.d.ts +15 -15
- package/dist/dts/dom-policy.d.ts +8 -8
- package/dist/dts/dom.d.ts +2 -2
- package/dist/dts/index.d.ts +41 -28
- package/dist/dts/interfaces.d.ts +7 -7
- package/dist/dts/observable.d.ts +4 -2
- package/dist/dts/observation/arrays.d.ts +2 -2
- package/dist/dts/observation/observable.d.ts +3 -3
- package/dist/dts/observation/update-queue.d.ts +1 -1
- package/dist/dts/platform.d.ts +1 -1
- package/dist/dts/state/state.d.ts +10 -10
- package/dist/dts/state/watch.d.ts +1 -1
- package/dist/dts/styles/css-binding-directive.d.ts +2 -2
- package/dist/dts/styles/css-directive.d.ts +1 -1
- package/dist/dts/styles/css.d.ts +4 -4
- package/dist/dts/styles/element-styles.d.ts +2 -2
- package/dist/dts/templating/children.d.ts +2 -2
- package/dist/dts/templating/compiler.d.ts +3 -3
- package/dist/dts/templating/html-binding-directive.d.ts +3 -3
- package/dist/dts/templating/html-directive.d.ts +5 -5
- package/dist/dts/templating/node-observation.d.ts +2 -2
- package/dist/dts/templating/ref.d.ts +1 -1
- package/dist/dts/templating/render.d.ts +10 -10
- package/dist/dts/templating/repeat.d.ts +4 -4
- package/dist/dts/templating/slotted.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +4 -4
- package/dist/dts/templating/view.d.ts +2 -2
- package/dist/esm/binding/one-way.js +1 -1
- package/dist/esm/binding/two-way.js +3 -3
- package/dist/esm/components/element-controller.js +152 -106
- package/dist/esm/components/fast-definitions.js +16 -16
- package/dist/esm/context.js +2 -2
- package/dist/esm/di/di.js +73 -63
- package/dist/esm/dom-policy.js +2 -2
- package/dist/esm/dom.js +2 -2
- package/dist/esm/index.js +21 -22
- package/dist/esm/interfaces.js +38 -0
- package/dist/esm/observable.js +1 -1
- package/dist/esm/observation/arrays.js +29 -22
- package/dist/esm/observation/observable.js +3 -3
- package/dist/esm/styles/css.js +2 -2
- package/dist/esm/styles/element-styles.js +9 -9
- package/dist/esm/templating/children.js +1 -1
- package/dist/esm/templating/compiler.js +5 -5
- package/dist/esm/templating/html-binding-directive.js +2 -2
- package/dist/esm/templating/node-observation.js +1 -1
- package/dist/esm/templating/render.js +4 -4
- package/dist/esm/templating/repeat.js +11 -11
- package/dist/esm/templating/slotted.js +1 -1
- package/dist/esm/templating/template.js +7 -7
- package/dist/esm/templating/view.js +9 -9
- package/dist/fast-element.api.json +96 -37
- package/dist/fast-element.d.ts +4 -4
- package/dist/fast-element.debug.js +2414 -2321
- package/dist/fast-element.debug.min.js +2 -2
- package/dist/fast-element.js +2414 -2321
- package/dist/fast-element.min.js +2 -2
- package/dist/fast-element.untrimmed.d.ts +17 -6
- package/docs/api-report.api.md +5 -4
- package/docs/di/api-report.api.md +4 -4
- package/karma.conf.cjs +13 -7
- package/package.json +6 -46
- package/playwright.config.ts +18 -0
- package/test/index.html +11 -0
- package/test/main.ts +10 -0
- package/test/vite.config.ts +19 -0
- package/dist/dts/observation/observable.bench.d.ts +0 -18
- package/dist/dts/templating/render.bench.d.ts +0 -3
- package/dist/dts/templating/repeat-basic-reverse.bench.d.ts +0 -3
- package/dist/dts/templating/repeat-basic-shift.bench.d.ts +0 -3
- package/dist/dts/templating/when-basic.bench.d.ts +0 -3
- package/dist/dts/templating/when-conditional.bench.d.ts +0 -3
- package/dist/dts/templating/when-switch.bench.d.ts +0 -3
- package/dist/esm/observation/observable.bench.js +0 -79
- package/dist/esm/templating/render.bench.js +0 -56
- package/dist/esm/templating/repeat-basic-reverse.bench.js +0 -43
- package/dist/esm/templating/repeat-basic-shift.bench.js +0 -43
- package/dist/esm/templating/when-basic.bench.js +0 -36
- package/dist/esm/templating/when-conditional.bench.js +0 -39
- package/dist/esm/templating/when-switch.bench.js +0 -68
- package/scripts/run-benchmarks.js +0 -46
- package/tensile.config.js +0 -12
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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,
|
|
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,
|
|
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(
|
|
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(
|
|
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,
|
|
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
|
|
739
|
+
case ResolverStrategy.singleton: {
|
|
730
740
|
if (this.resolving) {
|
|
731
|
-
throw FAST.error(
|
|
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 =
|
|
749
|
+
this.strategy = ResolverStrategy.instance;
|
|
740
750
|
this.resolving = false;
|
|
741
751
|
return instance;
|
|
742
752
|
});
|
|
743
753
|
}
|
|
744
|
-
case
|
|
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(
|
|
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
|
|
768
|
+
case ResolverStrategy.instance:
|
|
759
769
|
return this.state;
|
|
760
|
-
case
|
|
770
|
+
case ResolverStrategy.singleton: {
|
|
761
771
|
if (this.resolving) {
|
|
762
|
-
throw FAST.error(
|
|
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 =
|
|
778
|
+
this.strategy = ResolverStrategy.instance;
|
|
769
779
|
this.resolving = false;
|
|
770
780
|
return this.state;
|
|
771
781
|
}
|
|
772
|
-
case
|
|
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(
|
|
786
|
+
throw FAST.error(Message.noFactoryForResolver, { key: this.key });
|
|
777
787
|
}
|
|
778
788
|
return factory.construct(requestor);
|
|
779
789
|
}
|
|
780
|
-
case
|
|
790
|
+
case ResolverStrategy.callback:
|
|
781
791
|
return this.state(handler, requestor, this);
|
|
782
|
-
case
|
|
792
|
+
case ResolverStrategy.array:
|
|
783
793
|
return this.state[0].resolve(handler, requestor);
|
|
784
|
-
case
|
|
794
|
+
case ResolverStrategy.alias:
|
|
785
795
|
return requestor.get(this.state);
|
|
786
796
|
default:
|
|
787
|
-
throw FAST.error(
|
|
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
|
|
796
|
-
case
|
|
805
|
+
case ResolverStrategy.singleton:
|
|
806
|
+
case ResolverStrategy.transient:
|
|
797
807
|
return container.getFactory(this.state);
|
|
798
|
-
case
|
|
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;
|
|
@@ -902,6 +912,18 @@ const factories = new Map();
|
|
|
902
912
|
* @internal
|
|
903
913
|
*/
|
|
904
914
|
export class ContainerImpl {
|
|
915
|
+
get parent() {
|
|
916
|
+
if (this._parent === void 0) {
|
|
917
|
+
this._parent = this.config.parentLocator(this.owner);
|
|
918
|
+
}
|
|
919
|
+
return this._parent;
|
|
920
|
+
}
|
|
921
|
+
get depth() {
|
|
922
|
+
return this.parent === null ? 0 : this.parent.depth + 1;
|
|
923
|
+
}
|
|
924
|
+
get responsibleForOwnerRequests() {
|
|
925
|
+
return this.config.responsibleForOwnerRequests;
|
|
926
|
+
}
|
|
905
927
|
constructor(owner, config) {
|
|
906
928
|
this.owner = owner;
|
|
907
929
|
this.config = config;
|
|
@@ -935,18 +957,6 @@ export class ContainerImpl {
|
|
|
935
957
|
}
|
|
936
958
|
}
|
|
937
959
|
}
|
|
938
|
-
get parent() {
|
|
939
|
-
if (this._parent === void 0) {
|
|
940
|
-
this._parent = this.config.parentLocator(this.owner);
|
|
941
|
-
}
|
|
942
|
-
return this._parent;
|
|
943
|
-
}
|
|
944
|
-
get depth() {
|
|
945
|
-
return this.parent === null ? 0 : this.parent.depth + 1;
|
|
946
|
-
}
|
|
947
|
-
get responsibleForOwnerRequests() {
|
|
948
|
-
return this.config.responsibleForOwnerRequests;
|
|
949
|
-
}
|
|
950
960
|
handleContextRequests(enable) {
|
|
951
961
|
this.isHandlingContextRequests = enable;
|
|
952
962
|
}
|
|
@@ -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(
|
|
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 ===
|
|
1016
|
+
result.strategy === ResolverStrategy.array) {
|
|
1007
1017
|
result.state.push(resolver);
|
|
1008
1018
|
}
|
|
1009
1019
|
else {
|
|
1010
|
-
resolvers.set(key, new ResolverImpl(key,
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
1205
|
+
throw FAST.error(Message.invalidResolver);
|
|
1196
1206
|
}
|
|
1197
1207
|
return registrationResolver;
|
|
1198
1208
|
}
|
|
1199
1209
|
else if (keyAsValue.$isInterface) {
|
|
1200
|
-
throw FAST.error(
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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(
|
|
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 ===
|
|
1354
|
+
resolver.strategy === ResolverStrategy.array) {
|
|
1345
1355
|
const state = resolver.state;
|
|
1346
1356
|
let i = state.length;
|
|
1347
1357
|
const results = new Array(i);
|
package/dist/esm/dom-policy.js
CHANGED
|
@@ -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(
|
|
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(
|
|
70
|
+
throw FAST.error(Message.onlySetDOMPolicyOnce);
|
|
71
71
|
}
|
|
72
72
|
defaultPolicy = value;
|
|
73
73
|
},
|
package/dist/esm/index.js
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { emptyArray, FAST } from "./platform.js";
|
|
2
2
|
// DOM
|
|
3
|
-
export {
|
|
3
|
+
export { DOM, DOMAspect } from "./dom.js";
|
|
4
4
|
// Observation
|
|
5
|
-
export {
|
|
5
|
+
export { ArrayObserver, lengthOf, Sort, sortedCount, Splice, SpliceStrategy, SpliceStrategySupport, } from "./observation/arrays.js";
|
|
6
6
|
export { PropertyChangeNotifier, SubscriberSet, } from "./observation/notifier.js";
|
|
7
|
-
export {
|
|
7
|
+
export { ExecutionContext, Observable, observable, SourceLifetime, volatile, } from "./observation/observable.js";
|
|
8
8
|
export { Updates } from "./observation/update-queue.js";
|
|
9
9
|
// Binding
|
|
10
10
|
export { Binding } from "./binding/binding.js";
|
|
11
|
-
export { listener, oneWay } from "./binding/one-way.js";
|
|
12
|
-
export { oneTime } from "./binding/one-time.js";
|
|
13
11
|
export { normalizeBinding } from "./binding/normalize.js";
|
|
12
|
+
export { oneTime } from "./binding/one-time.js";
|
|
13
|
+
export { listener, oneWay } from "./binding/one-way.js";
|
|
14
14
|
// Styles
|
|
15
|
-
export {
|
|
16
|
-
export { css } from "./styles/css.js";
|
|
15
|
+
export { CSSBindingDirective } from "./styles/css-binding-directive.js";
|
|
17
16
|
export { cssDirective, CSSDirective, } from "./styles/css-directive.js";
|
|
17
|
+
export { css } from "./styles/css.js";
|
|
18
|
+
export { ElementStyles, } from "./styles/element-styles.js";
|
|
18
19
|
export {} from "./styles/host.js";
|
|
19
|
-
export {} from "./styles/style-strategy.js";
|
|
20
|
-
export { CSSBindingDirective } from "./styles/css-binding-directive.js";
|
|
21
20
|
// Templating
|
|
22
|
-
export {
|
|
21
|
+
export { children, ChildrenDirective } from "./templating/children.js";
|
|
23
22
|
export { Compiler } from "./templating/compiler.js";
|
|
24
|
-
export {
|
|
25
|
-
export { HTMLBindingDirective, } from "./templating/html-binding-directive.js";
|
|
23
|
+
export { HTMLBindingDirective } from "./templating/html-binding-directive.js";
|
|
26
24
|
export { htmlDirective, HTMLDirective, StatelessAttachedAttributeDirective, } from "./templating/html-directive.js";
|
|
25
|
+
export { Markup, Parser } from "./templating/markup.js";
|
|
26
|
+
export { elements, NodeObservationDirective } from "./templating/node-observation.js";
|
|
27
27
|
export { ref, RefDirective } from "./templating/ref.js";
|
|
28
|
-
export { when } from "./templating/when.js";
|
|
29
|
-
export { repeat, RepeatBehavior, RepeatDirective, } from "./templating/repeat.js";
|
|
30
|
-
export { slotted, SlottedDirective, } from "./templating/slotted.js";
|
|
31
|
-
export { children, ChildrenDirective, } from "./templating/children.js";
|
|
32
|
-
export { HTMLView, HydrationBindingError, } from "./templating/view.js";
|
|
33
|
-
export { elements, NodeObservationDirective, } from "./templating/node-observation.js";
|
|
34
28
|
export { render, RenderBehavior, RenderDirective } from "./templating/render.js";
|
|
29
|
+
export { repeat, RepeatBehavior, RepeatDirective } from "./templating/repeat.js";
|
|
30
|
+
export { slotted, SlottedDirective } from "./templating/slotted.js";
|
|
31
|
+
export { html, InlineTemplateDirective, ViewTemplate } from "./templating/template.js";
|
|
32
|
+
export { HTMLView, HydrationBindingError } from "./templating/view.js";
|
|
33
|
+
export { when } from "./templating/when.js";
|
|
35
34
|
// Components
|
|
36
|
-
export { customElement, FASTElement } from "./components/fast-element.js";
|
|
37
|
-
export { FASTElementDefinition, fastElementRegistry, TemplateOptions, } from "./components/fast-definitions.js";
|
|
38
35
|
export { attr, AttributeConfiguration, AttributeDefinition, booleanConverter, nullableBooleanConverter, nullableNumberConverter, } from "./components/attributes.js";
|
|
39
|
-
export { ElementController, HydratableElementController, needsHydrationAttribute, } from "./components/element-controller.js";
|
|
36
|
+
export { ElementController, HydratableElementController, needsHydrationAttribute, Stages, } from "./components/element-controller.js";
|
|
37
|
+
export { FASTElementDefinition, fastElementRegistry, TemplateOptions, } from "./components/fast-definitions.js";
|
|
38
|
+
export { customElement, FASTElement } from "./components/fast-element.js";
|
|
40
39
|
export { deferHydrationAttribute, isHydratable } from "./components/hydration.js";
|
package/dist/esm/interfaces.js
CHANGED
|
@@ -43,6 +43,44 @@ switch (kernelMode) {
|
|
|
43
43
|
break;
|
|
44
44
|
}
|
|
45
45
|
export { KernelServiceId };
|
|
46
|
+
/**
|
|
47
|
+
* Warning and error messages.
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export var Message;
|
|
51
|
+
(function (Message) {
|
|
52
|
+
// 1000 - 1100 Kernel
|
|
53
|
+
// 1101 - 1200 Observation
|
|
54
|
+
Message[Message["needsArrayObservation"] = 1101] = "needsArrayObservation";
|
|
55
|
+
// 1201 - 1300 Templating
|
|
56
|
+
Message[Message["onlySetDOMPolicyOnce"] = 1201] = "onlySetDOMPolicyOnce";
|
|
57
|
+
Message[Message["bindingInnerHTMLRequiresTrustedTypes"] = 1202] = "bindingInnerHTMLRequiresTrustedTypes";
|
|
58
|
+
Message[Message["twoWayBindingRequiresObservables"] = 1203] = "twoWayBindingRequiresObservables";
|
|
59
|
+
Message[Message["hostBindingWithoutHost"] = 1204] = "hostBindingWithoutHost";
|
|
60
|
+
Message[Message["unsupportedBindingBehavior"] = 1205] = "unsupportedBindingBehavior";
|
|
61
|
+
Message[Message["directCallToHTMLTagNotAllowed"] = 1206] = "directCallToHTMLTagNotAllowed";
|
|
62
|
+
Message[Message["onlySetTemplatePolicyOnce"] = 1207] = "onlySetTemplatePolicyOnce";
|
|
63
|
+
Message[Message["cannotSetTemplatePolicyAfterCompilation"] = 1208] = "cannotSetTemplatePolicyAfterCompilation";
|
|
64
|
+
Message[Message["blockedByDOMPolicy"] = 1209] = "blockedByDOMPolicy";
|
|
65
|
+
// 1301 - 1400 Styles
|
|
66
|
+
// 1401 - 1500 Components
|
|
67
|
+
Message[Message["missingElementDefinition"] = 1401] = "missingElementDefinition";
|
|
68
|
+
// 1501 - 1600 Context and Dependency Injection
|
|
69
|
+
Message[Message["noRegistrationForContext"] = 1501] = "noRegistrationForContext";
|
|
70
|
+
Message[Message["noFactoryForResolver"] = 1502] = "noFactoryForResolver";
|
|
71
|
+
Message[Message["invalidResolverStrategy"] = 1503] = "invalidResolverStrategy";
|
|
72
|
+
Message[Message["cannotAutoregisterDependency"] = 1504] = "cannotAutoregisterDependency";
|
|
73
|
+
Message[Message["cannotResolveKey"] = 1505] = "cannotResolveKey";
|
|
74
|
+
Message[Message["cannotConstructNativeFunction"] = 1506] = "cannotConstructNativeFunction";
|
|
75
|
+
Message[Message["cannotJITRegisterNonConstructor"] = 1507] = "cannotJITRegisterNonConstructor";
|
|
76
|
+
Message[Message["cannotJITRegisterIntrinsic"] = 1508] = "cannotJITRegisterIntrinsic";
|
|
77
|
+
Message[Message["cannotJITRegisterInterface"] = 1509] = "cannotJITRegisterInterface";
|
|
78
|
+
Message[Message["invalidResolver"] = 1510] = "invalidResolver";
|
|
79
|
+
Message[Message["invalidKey"] = 1511] = "invalidKey";
|
|
80
|
+
Message[Message["noDefaultResolver"] = 1512] = "noDefaultResolver";
|
|
81
|
+
Message[Message["cyclicDependency"] = 1513] = "cyclicDependency";
|
|
82
|
+
Message[Message["connectUpdateRequiresController"] = 1514] = "connectUpdateRequiresController";
|
|
83
|
+
})(Message || (Message = {}));
|
|
46
84
|
/**
|
|
47
85
|
* Determines whether or not an object is a function.
|
|
48
86
|
* @public
|
package/dist/esm/observable.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Observable exports for easy access to the Observable API
|
|
3
3
|
*/
|
|
4
4
|
export { ExecutionContext, Observable, observable, SourceLifetime, volatile, } from "./observation/observable.js";
|
|
5
|
-
export { PropertyChangeNotifier, SubscriberSet
|
|
5
|
+
export { PropertyChangeNotifier, SubscriberSet } from "./observation/notifier.js";
|