@microsoft/fast-element 2.0.0-beta.9 → 2.0.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 (142) hide show
  1. package/.eslintrc.json +1 -1
  2. package/CHANGELOG.json +518 -0
  3. package/CHANGELOG.md +181 -1
  4. package/README.md +1 -9
  5. package/api-extractor.context.json +14 -0
  6. package/api-extractor.di.json +14 -0
  7. package/dist/context/context.api.json +1068 -0
  8. package/dist/di/di.api.json +4929 -0
  9. package/dist/dts/binding/binding.d.ts +49 -0
  10. package/dist/dts/binding/normalize.d.ts +9 -0
  11. package/dist/dts/binding/one-time.d.ts +11 -0
  12. package/dist/dts/binding/one-way.d.ts +20 -0
  13. package/dist/dts/{templating/binding-signal.d.ts → binding/signal.d.ts} +19 -4
  14. package/dist/dts/{templating/binding-two-way.d.ts → binding/two-way.d.ts} +9 -5
  15. package/dist/dts/components/attributes.d.ts +7 -1
  16. package/dist/dts/components/element-controller.d.ts +104 -8
  17. package/dist/dts/components/element-hydration.d.ts +2 -0
  18. package/dist/dts/components/fast-definitions.d.ts +6 -0
  19. package/dist/dts/components/hydration.d.ts +56 -0
  20. package/dist/dts/components/install-hydration.d.ts +1 -0
  21. package/dist/dts/context.d.ts +29 -15
  22. package/dist/dts/di/di.d.ts +0 -5
  23. package/dist/dts/dom-policy.d.ts +83 -0
  24. package/dist/dts/dom.d.ts +100 -0
  25. package/dist/dts/hydration/target-builder.d.ts +63 -0
  26. package/dist/dts/index.d.ts +33 -26
  27. package/dist/dts/index.rollup.d.ts +0 -1
  28. package/dist/dts/index.rollup.debug.d.ts +0 -1
  29. package/dist/dts/interfaces.d.ts +32 -82
  30. package/dist/dts/metadata.d.ts +6 -5
  31. package/dist/dts/observation/arrays.d.ts +1 -1
  32. package/dist/dts/observation/observable.bench.d.ts +18 -0
  33. package/dist/dts/observation/observable.d.ts +5 -5
  34. package/dist/dts/pending-task.d.ts +19 -7
  35. package/dist/dts/platform.d.ts +11 -2
  36. package/dist/dts/polyfills.d.ts +0 -8
  37. package/dist/dts/styles/css-binding-directive.d.ts +60 -0
  38. package/dist/dts/styles/css.d.ts +9 -7
  39. package/dist/dts/styles/element-styles.d.ts +1 -14
  40. package/dist/dts/styles/host.d.ts +2 -5
  41. package/dist/dts/styles/style-strategy.d.ts +42 -0
  42. package/dist/dts/templating/compiler.d.ts +11 -13
  43. package/dist/dts/templating/{binding.d.ts → html-binding-directive.d.ts} +21 -41
  44. package/dist/dts/templating/html-directive.d.ts +44 -140
  45. package/dist/dts/templating/install-hydratable-view-templates.d.ts +1 -0
  46. package/dist/dts/templating/node-observation.d.ts +11 -1
  47. package/dist/dts/templating/ref.d.ts +4 -0
  48. package/dist/dts/templating/render.bench.d.ts +3 -0
  49. package/dist/dts/templating/render.d.ts +49 -9
  50. package/dist/dts/templating/repeat-basic-reverse.bench.d.ts +3 -0
  51. package/dist/dts/templating/repeat-basic-shift.bench.d.ts +3 -0
  52. package/dist/dts/templating/repeat.d.ts +31 -9
  53. package/dist/dts/templating/template.d.ts +97 -12
  54. package/dist/dts/templating/view.d.ts +146 -29
  55. package/dist/dts/templating/when-basic.bench.d.ts +3 -0
  56. package/dist/dts/templating/when-conditional.bench.d.ts +3 -0
  57. package/dist/dts/templating/when-switch.bench.d.ts +3 -0
  58. package/dist/dts/templating/when.d.ts +3 -1
  59. package/dist/dts/testing/fakes.d.ts +12 -1
  60. package/dist/dts/tsdoc-metadata.json +1 -1
  61. package/dist/dts/utilities.d.ts +55 -1
  62. package/dist/esm/binding/binding.js +18 -0
  63. package/dist/esm/binding/normalize.js +17 -0
  64. package/dist/esm/binding/one-time.js +21 -0
  65. package/dist/esm/binding/one-way.js +30 -0
  66. package/dist/esm/{templating/binding-signal.js → binding/signal.js} +22 -6
  67. package/dist/esm/{templating/binding-two-way.js → binding/two-way.js} +18 -12
  68. package/dist/esm/components/attributes.js +19 -6
  69. package/dist/esm/components/element-controller.js +319 -49
  70. package/dist/esm/components/element-hydration.js +2 -0
  71. package/dist/esm/components/fast-definitions.js +12 -4
  72. package/dist/esm/components/fast-element.js +3 -1
  73. package/dist/esm/components/hydration.js +104 -0
  74. package/dist/esm/components/install-hydration.js +3 -0
  75. package/dist/esm/context.js +26 -4
  76. package/dist/esm/debug.js +8 -2
  77. package/dist/esm/di/di.js +9 -12
  78. package/dist/esm/dom-policy.js +345 -0
  79. package/dist/esm/dom.js +101 -0
  80. package/dist/esm/hydration/target-builder.js +175 -0
  81. package/dist/esm/index.js +34 -25
  82. package/dist/esm/index.rollup.debug.js +3 -1
  83. package/dist/esm/index.rollup.js +3 -1
  84. package/dist/esm/interfaces.js +51 -3
  85. package/dist/esm/metadata.js +11 -8
  86. package/dist/esm/observation/arrays.js +1 -1
  87. package/dist/esm/observation/observable.bench.js +79 -0
  88. package/dist/esm/observation/observable.js +20 -15
  89. package/dist/esm/observation/update-queue.js +2 -2
  90. package/dist/esm/pending-task.js +13 -1
  91. package/dist/esm/platform.js +12 -2
  92. package/dist/esm/polyfills.js +3 -61
  93. package/dist/esm/styles/css-binding-directive.js +76 -0
  94. package/dist/esm/styles/css.js +14 -7
  95. package/dist/esm/styles/element-styles.js +0 -33
  96. package/dist/esm/styles/style-strategy.js +1 -0
  97. package/dist/esm/templating/children.js +8 -4
  98. package/dist/esm/templating/compiler.js +37 -44
  99. package/dist/esm/templating/html-binding-directive.js +218 -0
  100. package/dist/esm/templating/html-directive.js +25 -152
  101. package/dist/esm/templating/install-hydratable-view-templates.js +17 -0
  102. package/dist/esm/templating/node-observation.js +14 -8
  103. package/dist/esm/templating/ref.js +1 -1
  104. package/dist/esm/templating/render.bench.js +56 -0
  105. package/dist/esm/templating/render.js +74 -30
  106. package/dist/esm/templating/repeat-basic-reverse.bench.js +43 -0
  107. package/dist/esm/templating/repeat-basic-shift.bench.js +43 -0
  108. package/dist/esm/templating/repeat.js +116 -17
  109. package/dist/esm/templating/template.js +135 -60
  110. package/dist/esm/templating/view.js +254 -34
  111. package/dist/esm/templating/when-basic.bench.js +36 -0
  112. package/dist/esm/templating/when-conditional.bench.js +39 -0
  113. package/dist/esm/templating/when-switch.bench.js +68 -0
  114. package/dist/esm/templating/when.js +12 -5
  115. package/dist/esm/testing/fakes.js +32 -1
  116. package/dist/esm/testing/fixture.js +1 -1
  117. package/dist/esm/utilities.js +97 -1
  118. package/dist/fast-element.api.json +9789 -5667
  119. package/dist/fast-element.d.ts +813 -2392
  120. package/dist/fast-element.debug.js +2788 -974
  121. package/dist/fast-element.debug.min.js +3 -1
  122. package/dist/fast-element.js +2641 -833
  123. package/dist/fast-element.min.js +3 -1
  124. package/dist/fast-element.untrimmed.d.ts +662 -314
  125. package/docs/{api-report.md → api-report.api.md} +238 -151
  126. package/docs/context/api-report.api.md +69 -0
  127. package/docs/di/api-report.api.md +315 -0
  128. package/karma.conf.cjs +2 -1
  129. package/package.json +59 -47
  130. package/scripts/run-api-extractor.js +51 -0
  131. package/scripts/run-benchmarks.js +46 -0
  132. package/tensile.config.js +12 -0
  133. package/dist/dts/templating/dom.d.ts +0 -41
  134. package/dist/esm/templating/binding.js +0 -282
  135. package/dist/esm/templating/dom.js +0 -49
  136. package/docs/guide/declaring-templates.md +0 -230
  137. package/docs/guide/defining-elements.md +0 -214
  138. package/docs/guide/leveraging-css.md +0 -253
  139. package/docs/guide/next-steps.md +0 -13
  140. package/docs/guide/observables-and-state.md +0 -213
  141. package/docs/guide/using-directives.md +0 -576
  142. package/docs/guide/working-with-shadow-dom.md +0 -296
@@ -1,2698 +1,1119 @@
1
1
  /**
2
- * Represents a getter/setter property accessor on an object.
2
+ * A decorator and DI resolver that will resolve an array of all dependencies
3
+ * registered with the specified key.
4
+ * @param key - The key to resolve all dependencies for.
5
+ * @param searchAncestors - [optional] Indicates whether to search ancestor containers.
3
6
  * @public
4
7
  */
5
- export declare interface Accessor {
8
+ export declare const all: (key: any, searchAncestors?: boolean) => ReturnType<typeof DI.inject>;
9
+
10
+ /**
11
+ * A function capable of asynchronously locating a resolver for a key.
12
+ * @public
13
+ */
14
+ export declare type AsyncRegistrationLocator = (key: Key) => Promise<Registration | null>;
15
+
16
+ /**
17
+ * Represents a type which can be constructed with the new operator.
18
+ *
19
+ * @public
20
+ */
21
+ declare type Constructable<T = {}> = {
22
+ new (...args: any[]): T;
23
+ };
24
+
25
+ /**
26
+ * Implemented by dependency injection containers.
27
+ * @public
28
+ */
29
+ export declare interface Container extends ServiceLocator {
30
+ /**
31
+ * Registers dependencies with the container via registration objects.
32
+ * @param params - The registration objects.
33
+ */
34
+ register(...params: any[]): Container;
35
+ /**
36
+ * Registers a resolver with the container for the specified key.
37
+ * @param key - The key to register the resolver under.
38
+ * @param resolver - The resolver to register.
39
+ */
40
+ registerResolver<K extends Key, T = K>(key: K, resolver: Resolver<T>): Resolver<T>;
41
+ /**
42
+ * Registers a transformer with the container for the specified key.
43
+ * @param key - The key to resolved to register the transformer with.
44
+ * @param transformer - The transformer to register.
45
+ */
46
+ registerTransformer<K extends Key, T = K>(key: K, transformer: Transformer_2<T>): boolean;
47
+ /**
48
+ * Gets a resolver for the specified key.
49
+ * @param key - The key to get the resolver for.
50
+ * @param autoRegister - Indicates whether or not to try to auto-register a dependency for
51
+ * the key if one is not explicitly registered.
52
+ */
53
+ getResolver<K extends Key, T = K>(key: K | Key, autoRegister?: boolean): Resolver<T> | null;
6
54
  /**
7
- * The name of the property.
55
+ * Registers a factory with the container for the specified key.
56
+ * @param key - The key to register the factory under.
57
+ * @param factory - The factory to register.
8
58
  */
9
- name: string;
59
+ registerFactory<T extends Constructable>(key: T, factory: Factory<T>): void;
10
60
  /**
11
- * Gets the value of the property on the source object.
12
- * @param source - The source object to access.
61
+ * Gets the factory for the specified key.
62
+ * @param key - The key to get the factory for.
13
63
  */
14
- getValue(source: any): any;
64
+ getFactory<T extends Constructable>(key: T): Factory<T>;
15
65
  /**
16
- * Sets the value of the property on the source object.
17
- * @param source - The source object to access.
18
- * @param value - The value to set the property to.
66
+ * Creates a child dependency injection container parented to this container.
67
+ * @param config - The configuration for the new container.
19
68
  */
20
- setValue(source: any, value: any): void;
69
+ createChild(config?: Partial<Omit<ContainerConfiguration, "parentLocator">>): Container;
21
70
  }
22
71
 
23
72
  /**
24
- * Used to add behaviors when constructing styles.
25
- * @public
26
- */
27
- export declare type AddBehavior = (behavior: HostBehavior<HTMLElement>) => void;
28
-
29
- /**
30
- * Used to add behavior factories when constructing templates.
73
+ * The key that resolves the dependency injection Container itself.
31
74
  * @public
32
75
  */
33
- export declare type AddViewBehaviorFactory = (factory: ViewBehaviorFactory) => string;
34
-
35
- /* Excluded from this release type: AdoptedStyleSheetsStrategy */
76
+ export declare const Container: ContextDecorator<Container>;
36
77
 
37
78
  /**
38
- * An observer for arrays.
79
+ * Configuration for a dependency injection container.
39
80
  * @public
40
81
  */
41
- export declare interface ArrayObserver extends SubscriberSet {
82
+ export declare interface ContainerConfiguration {
42
83
  /**
43
- * The strategy to use for tracking changes.
84
+ * The locator function used to find the parent of the container.
44
85
  */
45
- strategy: SpliceStrategy | null;
86
+ parentLocator: ParentLocator;
46
87
  /**
47
- * The length observer for the array.
88
+ * When an asynchronous get request is made to the container, if no
89
+ * resolver is found for the key, this function is called to provide
90
+ * a registration.
48
91
  */
49
- readonly lengthObserver: LengthObserver;
92
+ asyncRegistrationLocator: AsyncRegistrationLocator;
50
93
  /**
51
- * Adds a splice to the list of changes.
52
- * @param splice - The splice to add.
94
+ * Indicates whether this container should resolve dependencies that are directly made
95
+ * by its owner. The default is "false" which results in the parent container being used.
53
96
  */
54
- addSplice(splice: Splice): void;
97
+ responsibleForOwnerRequests: boolean;
55
98
  /**
56
- * Indicates that a reset change has occurred.
57
- * @param oldCollection - The collection as it was before the reset.
99
+ * Gets the default resolver to use during auto-registration.
100
+ * @param key - The key to register the dependency with.
101
+ * @param handler - The container that is handling the auto-registration request.
58
102
  */
59
- reset(oldCollection: any[] | undefined): void;
60
- /**
61
- * Flushes the changes to subscribers.
62
- */
63
- flush(): void;
103
+ defaultResolver(key: Key, handler: Container): Resolver;
64
104
  }
65
105
 
66
106
  /**
67
- * An observer for arrays.
107
+ * Configuration for a dependency injection container.
68
108
  * @public
69
109
  */
70
- export declare const ArrayObserver: Readonly<{
110
+ export declare const ContainerConfiguration: Readonly<{
71
111
  /**
72
- * Enables the array observation mechanism.
112
+ * The default configuration used when creating a DOM-disconnected container.
73
113
  * @remarks
74
- * Array observation is enabled automatically when using the
75
- * {@link RepeatDirective}, so calling this API manually is
76
- * not typically necessary.
114
+ * The default creates a root container, with no parent container. It does not handle
115
+ * owner requests and it uses singleton resolution behavior for auto-registration.
77
116
  */
78
- readonly enable: () => void;
117
+ default: Readonly<ContainerConfiguration>;
79
118
  }>;
80
119
 
81
120
  /**
82
- * The type of HTML aspect to target.
121
+ * @internal
122
+ */
123
+ export declare class ContainerImpl implements DOMContainer {
124
+ protected owner: any;
125
+ protected config: ContainerConfiguration;
126
+ private _parent;
127
+ private registerDepth;
128
+ private resolvers;
129
+ private isHandlingContextRequests;
130
+ get parent(): ContainerImpl | null;
131
+ get depth(): number;
132
+ get responsibleForOwnerRequests(): boolean;
133
+ constructor(owner: any, config: ContainerConfiguration);
134
+ handleContextRequests(enable: boolean): void;
135
+ register(...params: any[]): Container;
136
+ registerResolver<K extends Key, T = K>(key: K, resolver: Resolver<T>): Resolver<T>;
137
+ registerTransformer<K extends Key, T = K>(key: K, transformer: Transformer_2<T>): boolean;
138
+ getResolver<K extends Key, T = K>(key: K | Key, autoRegister?: boolean): Resolver<T> | null;
139
+ has<K extends Key>(key: K, searchAncestors?: boolean): boolean;
140
+ getAsync<K extends Key>(key: K): Promise<Resolved<K>>;
141
+ get<K extends Key>(key: K): Resolved<K>;
142
+ getAll<K extends Key>(key: K, searchAncestors?: boolean): readonly Resolved<K>[];
143
+ getFactory<K extends Constructable>(Type: K): Factory<K>;
144
+ registerFactory<K extends Constructable>(key: K, factory: Factory<K>): void;
145
+ createChild(config?: Partial<Omit<ContainerConfiguration, "parentLocator">>): Container;
146
+ private jitRegister;
147
+ }
148
+
149
+ /**
150
+ * A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes.
151
+ * @public
152
+ */
153
+ declare type Context<T> = {
154
+ readonly name: string;
155
+ readonly initialValue?: T;
156
+ };
157
+
158
+ /**
159
+ * Enables using:
160
+ * {@link https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md | W3C Community Context protocol.}
83
161
  * @public
84
162
  */
85
- export declare const Aspect: Readonly<{
163
+ declare const Context: Readonly<{
164
+ /**
165
+ * The event type used for W3C Context Protocol requests.
166
+ */
167
+ eventType: "context-request";
86
168
  /**
87
- * Not aspected.
169
+ * Returns a FASTContext object from the global context registry matching the given name if found.
170
+ * Otherwise, returns a new FASTContext with this name.
171
+ * @param name - The name of the FASTContext to get or create.
172
+ * @returns A FASTContext object.
88
173
  */
89
- readonly none: 0;
174
+ for<T = unknown>(name: string): FASTContext<T>;
90
175
  /**
91
- * An attribute.
176
+ * Creates a W3C Community Protocol-based Context object to use in requesting/providing
177
+ * context through the DOM.
178
+ * @param name - The name to use for the connext. Useful in debugging.
179
+ * @param initialValue - An optional initial value to use if a context handler isn't found.
92
180
  */
93
- readonly attribute: 1;
181
+ create<T_1 = unknown>(name: string, initialValue?: T_1 | undefined): FASTContext<T_1>;
94
182
  /**
95
- * A boolean attribute.
183
+ * Sets the strategy used by all FAST-specific context requests made through the
184
+ * Context.request, Context.get, Context.defineProperty, and ContextDecorator APIs.
185
+ * @param strategy - The strategy to use. By default, the strategy is Context.dispatch.
96
186
  */
97
- readonly booleanAttribute: 2;
187
+ setDefaultRequestStrategy(strategy: FASTContextRequestStrategy): void;
98
188
  /**
99
- * A property.
189
+ * Gets the context value for the target node or returns the initial value if
190
+ * a context handler is not found.
191
+ * @param target - The target to get the context for.
192
+ * @param context - The context to locate.
193
+ * @returns The context value.
194
+ * @remarks
195
+ * Uses the default request strategy to locate the context. If no context is found
196
+ * then the initial value of the context is returned.
100
197
  */
101
- readonly property: 3;
198
+ get<T_2 extends UnknownContext>(target: EventTarget, context: T_2): ContextType<T_2>;
102
199
  /**
103
- * Content
200
+ * Requests the context value for the target node.
201
+ * @param target - The target to request the context for.
202
+ * @param context - The context to locate.
203
+ * @param callback - A callback to invoke with the context value.
204
+ * @param multiple - Whether the context requestor expects to handle updates
205
+ * to the context value after the initial request.
206
+ * @remarks
207
+ * Uses the default request strategy to locate the context.
104
208
  */
105
- readonly content: 4;
209
+ request<T_3 extends UnknownContext>(target: EventTarget, context: T_3, callback: ContextCallback<ContextType<T_3>>, multiple?: boolean): void;
106
210
  /**
107
- * A token list.
211
+ *
212
+ * @param target - The target to dispatch the context event on.
213
+ * @param context - The context to locate.
214
+ * @param callback - The callback to invoke with the context value.
215
+ * @param multiple - Whether the context requestor expects to handle updates
216
+ * to the context value after the initial request.
217
+ * @remarks
218
+ * This API does NOT use the default request strategy. It always dispatches
219
+ * an event through the DOM.
108
220
  */
109
- readonly tokenList: 5;
221
+ dispatch<T_4 extends UnknownContext>(target: EventTarget, context: T_4, callback: ContextCallback<ContextType<T_4>>, multiple?: boolean): void;
110
222
  /**
111
- * An event.
223
+ * Enables an event target to provide a context value.
224
+ * @param target The target to provide the context value for.
225
+ * @param context The context to provide the value for.
226
+ * @param value The value to provide for the context.
112
227
  */
113
- readonly event: 6;
228
+ provide<T_5 extends UnknownContext>(target: EventTarget, context: T_5, value: ContextType<T_5>): void;
114
229
  /**
115
230
  *
116
- * @param directive - The directive to assign the aspect to.
117
- * @param value - The value to base the aspect determination on.
231
+ * @param target - The target on which to handle context requests.
232
+ * @param callback - The callback to invoke when a context request is received.
233
+ * @param context - The context to handle requests for.
234
+ * @remarks
235
+ * If a context is not provided then the callback will be invoked for all context
236
+ * requests that are received on the target.
237
+ */
238
+ handle<T_6 extends UnknownContext>(target: EventTarget, callback: (event: ContextEvent<T_6>) => void, context?: T_6 | undefined): void;
239
+ /**
240
+ * Defines a getter-only property on the target that will return the context
241
+ * value for the target.
242
+ * @param target The target to define the property on.
243
+ * @param propertyName The name of the property to define.
244
+ * @param context The context that will be used to retrieve the property value.
118
245
  * @remarks
119
- * If a falsy value is provided, then the content aspect will be assigned.
246
+ * Uses the default request strategy to locate the context and will return the
247
+ * initialValue if the context isn't handled.
120
248
  */
121
- readonly assign: (directive: Aspected, value?: string) => void;
249
+ defineProperty<T_7 extends UnknownContext>(target: Constructable<EventTarget> | EventTarget, propertyName: string, context: T_7): void;
122
250
  }>;
123
251
 
124
252
  /**
125
- * The type of HTML aspect to target.
253
+ * A callback which is provided by a context requester and is called with the value satisfying the request.
254
+ * This callback can be called multiple times by context providers as the requested value is changed.
126
255
  * @public
127
256
  */
128
- export declare type Aspect = typeof Aspect[Exclude<keyof typeof Aspect, "assign" | "none">];
257
+ declare type ContextCallback<ValueType> = (value: ValueType, dispose?: () => void) => void;
129
258
 
130
259
  /**
131
- * Represents something that applies to a specific aspect of the DOM.
260
+ * A constant key that can be used to represent a Context dependency.
261
+ * The key can be used for context or DI but also doubles as a decorator for
262
+ * resolving the associated dependency.
132
263
  * @public
133
264
  */
134
- export declare interface Aspected {
135
- /**
136
- * The original source aspect exactly as represented in markup.
137
- */
138
- sourceAspect: string;
139
- /**
140
- * The evaluated target aspect, determined after processing the source.
141
- */
142
- targetAspect: string;
143
- /**
144
- * The type of aspect to target.
145
- */
146
- aspectType: Aspect;
147
- /**
148
- * A binding if one is associated with the aspect.
149
- */
150
- dataBinding?: Binding;
151
- }
265
+ declare type ContextDecorator<T = any> = Readonly<Context<T>> & PropertyDecorator & ParameterDecorator_2;
152
266
 
153
267
  /**
154
- * Decorator: Specifies an HTML attribute.
155
- * @param config - The configuration for the attribute.
268
+ * An event fired by a context requester to signal it desires a named context.
269
+ *
270
+ * A provider should inspect the `context` property of the event to determine if it has a value that can
271
+ * satisfy the request, calling the `callback` with the requested value if so.
272
+ *
273
+ * If the requested context event contains a truthy `multiple` value, then a provider can call the callback
274
+ * multiple times if the value is changed, if this is the case the provider should pass a `dispose`
275
+ * method to the callback which requesters can invoke to indicate they no longer wish to receive these updates.
156
276
  * @public
157
277
  */
158
- export declare function attr(config?: DecoratorAttributeConfiguration): (target: {}, property: string) => void;
278
+ declare class ContextEvent<T extends UnknownContext> extends Event {
279
+ readonly context: T;
280
+ readonly callback: ContextCallback<ContextType<T>>;
281
+ readonly multiple?: boolean | undefined;
282
+ constructor(context: T, callback: ContextCallback<ContextType<T>>, multiple?: boolean | undefined);
283
+ }
159
284
 
160
285
  /**
161
- * Decorator: Specifies an HTML attribute.
162
- * @param target - The class to define the attribute on.
163
- * @param prop - The property name to be associated with the attribute.
286
+ * A helper type which can extract a Context value type from a Context type
164
287
  * @public
165
288
  */
166
- export declare function attr(target: {}, prop: string): void;
289
+ declare type ContextType<T extends UnknownContext> = T extends Context<infer Y> ? Y : never;
167
290
 
168
- /**
169
- * Metadata used to configure a custom attribute's behavior.
170
- * @public
171
- */
172
- export declare type AttributeConfiguration = {
173
- property: string;
174
- attribute?: string;
175
- mode?: AttributeMode;
176
- converter?: ValueConverter;
177
- };
291
+ declare function createContext<K extends Key>(nameConfigOrCallback?: string | ((builder: ResolverBuilder<K>) => Resolver<K>) | InterfaceConfiguration, configuror?: (builder: ResolverBuilder<K>) => Resolver<K>): ContextDecorator<K>;
178
292
 
179
293
  /**
180
- * Metadata used to configure a custom attribute's behavior.
294
+ * A set of default resolvers useful in configuring a container.
181
295
  * @public
182
296
  */
183
- export declare const AttributeConfiguration: Readonly<{
297
+ export declare const DefaultResolver: Readonly<{
184
298
  /**
185
- * Locates all attribute configurations associated with a type.
299
+ * Disables auto-registration and throws for all un-registered dependencies.
300
+ * @param key - The key to create the resolver for.
186
301
  */
187
- locate: (target: {}) => AttributeConfiguration[];
302
+ none(key: Key): Resolver;
303
+ /**
304
+ * Provides default singleton resolution behavior during auto-registration.
305
+ * @param key - The key to create the resolver for.
306
+ * @returns The resolver.
307
+ */
308
+ singleton(key: Key): Resolver;
309
+ /**
310
+ * Provides default transient resolution behavior during auto-registration.
311
+ * @param key - The key to create the resolver for.
312
+ * @returns The resolver.
313
+ */
314
+ transient(key: Key): Resolver;
188
315
  }>;
189
316
 
190
317
  /**
191
- * An implementation of {@link Accessor} that supports reactivity,
192
- * change callbacks, attribute reflection, and type conversion for
193
- * custom elements.
318
+ * The gateway to dependency injection APIs.
194
319
  * @public
195
320
  */
196
- export declare class AttributeDefinition implements Accessor {
197
- private readonly fieldName;
198
- private readonly callbackName;
199
- private readonly hasCallback;
200
- private readonly guards;
321
+ export declare const DI: Readonly<{
201
322
  /**
202
- * The class constructor that owns this attribute.
323
+ * Installs dependency injection as the default strategy for handling
324
+ * all calls to Context.request.
325
+ * @param fallback - Creates a container if one cannot be found.
203
326
  */
204
- readonly Owner: Function;
327
+ installAsContextRequestStrategy(fallback?: () => DOMContainer): void;
205
328
  /**
206
- * The name of the property associated with the attribute.
329
+ * Creates a new dependency injection container.
330
+ * @param config - The configuration for the container.
331
+ * @returns A newly created dependency injection container.
207
332
  */
208
- readonly name: string;
333
+ createContainer(config?: Partial<ContainerConfiguration>): Container;
334
+ /**
335
+ * Finds the dependency injection container responsible for providing dependencies
336
+ * to the specified node.
337
+ * @param target - The node to find the responsible container for.
338
+ * @param fallback - Creates a container if one cannot be found.
339
+ * @returns The container responsible for providing dependencies to the node.
340
+ * @remarks
341
+ * This will be the same as the parent container if the specified node
342
+ * does not itself host a container configured with responsibleForOwnerRequests.
343
+ */
344
+ findResponsibleContainer(target: EventTarget, fallback?: () => DOMContainer): DOMContainer;
209
345
  /**
210
- * The name of the attribute in HTML.
346
+ * Find the dependency injection container up the DOM tree from this node.
347
+ * @param target - The node to find the parent container for.
348
+ * @param fallback - Creates a container if one cannot be found.
349
+ * @returns The parent container of this node.
350
+ * @remarks
351
+ * This will be the same as the responsible container if the specified node
352
+ * does not itself host a container configured with responsibleForOwnerRequests.
211
353
  */
212
- readonly attribute: string;
354
+ findParentContainer(target: EventTarget, fallback?: () => DOMContainer): DOMContainer;
213
355
  /**
214
- * The {@link AttributeMode} that describes the behavior of this attribute.
356
+ * Returns a dependency injection container if one is explicitly owned by the specified
357
+ * node. If one is not owned, then a new container is created and assigned to the node.
358
+ * @param target - The node to find or create the container for.
359
+ * @param config - The configuration for the container if one needs to be created.
360
+ * @returns The located or created container.
361
+ * @remarks
362
+ * This API does not search for a responsible or parent container. It looks only for a container
363
+ * directly defined on the specified node and creates one at that location if one does not
364
+ * already exist.
365
+ */
366
+ getOrCreateDOMContainer(target?: EventTarget, config?: Partial<Omit<ContainerConfiguration, "parentLocator">>): DOMContainer;
367
+ /**
368
+ * Gets the dependency keys representing what is needed to instantiate the specified type.
369
+ * @param Type - The type to get the dependencies for.
370
+ * @returns An array of dependency keys.
371
+ */
372
+ getDependencies(Type: Constructable | Injectable): Key[];
373
+ /**
374
+ * Defines a property on a web component class. The value of this property will
375
+ * be resolved from the dependency injection container responsible for the element
376
+ * instance, based on where it is connected in the DOM.
377
+ * @param target - The target to define the property on.
378
+ * @param propertyName - The name of the property to define.
379
+ * @param key - The dependency injection key.
380
+ * @param respectConnection - Indicates whether or not to update the property value if the
381
+ * hosting component is disconnected and then re-connected at a different location in the DOM.
382
+ * @remarks
383
+ * The respectConnection option is only applicable to elements that descend from FASTElement.
215
384
  */
216
- readonly mode: AttributeMode;
385
+ defineProperty(target: {}, propertyName: string, key: Key, respectConnection?: boolean): void;
217
386
  /**
218
- * A {@link ValueConverter} that integrates with the property getter/setter
219
- * to convert values to and from a DOM string.
387
+ * Creates a dependency injection key.
388
+ * @param nameConfigOrCallback - A friendly name for the key or a lambda that configures a
389
+ * default resolution for the dependency.
390
+ * @param configuror - If a friendly name was provided for the first parameter, then an optional
391
+ * lambda that configures a default resolution for the dependency can be provided second.
392
+ * @returns The created key.
393
+ * @remarks
394
+ * The created key can be used as a property decorator or constructor parameter decorator,
395
+ * in addition to its standard use in an inject array or through direct container APIs.
220
396
  */
221
- readonly converter?: ValueConverter;
397
+ createContext: typeof createContext;
222
398
  /**
223
- * Creates an instance of AttributeDefinition.
224
- * @param Owner - The class constructor that owns this attribute.
225
- * @param name - The name of the property associated with the attribute.
226
- * @param attribute - The name of the attribute in HTML.
227
- * @param mode - The {@link AttributeMode} that describes the behavior of this attribute.
228
- * @param converter - A {@link ValueConverter} that integrates with the property getter/setter
229
- * to convert values to and from a DOM string.
399
+ * A decorator that specifies what to inject into its target.
400
+ * @param dependencies - The dependencies to inject.
401
+ * @returns The decorator to be applied to the target class.
402
+ * @remarks
403
+ * The decorator can be used to decorate a class, listing all of the classes dependencies.
404
+ * Or it can be used to decorate a constructor parameter, indicating what to inject for that
405
+ * parameter.
406
+ * Or it can be used for a web component property, indicating what that property should resolve to.
230
407
  */
231
- constructor(Owner: Function, name: string, attribute?: string, mode?: AttributeMode, converter?: ValueConverter);
408
+ inject(...dependencies: Key[]): (target: any, key?: string | number, descriptor?: PropertyDescriptor | number) => void;
232
409
  /**
233
- * Sets the value of the attribute/property on the source element.
234
- * @param source - The source element to access.
235
- * @param value - The value to set the attribute/property to.
410
+ * Registers the `target` class as a transient dependency; each time the dependency is resolved
411
+ * a new instance will be created.
412
+ *
413
+ * @param target - The class / constructor function to register as transient.
414
+ * @returns The same class, with a static `register` method that takes a container and returns the appropriate resolver.
415
+ *
416
+ * @example
417
+ * On an existing class
418
+ * ```ts
419
+ * class Foo { }
420
+ * DI.transient(Foo);
421
+ * ```
422
+ *
423
+ * @example
424
+ * Inline declaration
425
+ *
426
+ * ```ts
427
+ * const Foo = DI.transient(class { });
428
+ * // Foo is now strongly typed with register
429
+ * Foo.register(container);
430
+ * ```
431
+ *
432
+ * @public
236
433
  */
237
- setValue(source: HTMLElement, newValue: any): void;
434
+ transient<T extends Constructable<{}>>(target: T & Partial<RegisterSelf<T>>): T & RegisterSelf<T>;
238
435
  /**
239
- * Gets the value of the attribute/property on the source element.
240
- * @param source - The source element to access.
436
+ * Registers the `target` class as a singleton dependency; the class will only be created once. Each
437
+ * consecutive time the dependency is resolved, the same instance will be returned.
438
+ *
439
+ * @param target - The class / constructor function to register as a singleton.
440
+ * @returns The same class, with a static `register` method that takes a container and returns the appropriate resolver.
441
+ * @example
442
+ * On an existing class
443
+ * ```ts
444
+ * class Foo { }
445
+ * DI.singleton(Foo);
446
+ * ```
447
+ *
448
+ * @example
449
+ * Inline declaration
450
+ * ```ts
451
+ * const Foo = DI.singleton(class { });
452
+ * // Foo is now strongly typed with register
453
+ * Foo.register(container);
454
+ * ```
455
+ *
456
+ * @public
241
457
  */
242
- getValue(source: HTMLElement): any;
243
- /* Excluded from this release type: onAttributeChangedCallback */
244
- private tryReflectToAttribute;
245
- /* Excluded from this release type: collect */
246
- }
458
+ singleton<T_1 extends Constructable<{}>>(target: T_1 & Partial<RegisterSelf<T_1>>, options?: SingletonOptions): T_1 & RegisterSelf<T_1>;
459
+ }>;
247
460
 
248
461
  /**
249
- * The mode that specifies the runtime behavior of the attribute.
250
- * @remarks
251
- * By default, attributes run in `reflect` mode, propagating their property
252
- * values to the DOM and DOM values to the property. The `boolean` mode also
253
- * reflects values, but uses the HTML standard boolean attribute behavior,
254
- * interpreting the presence of the attribute as `true` and the absence as
255
- * `false`. The `fromView` behavior only updates the property value based on
256
- * changes in the DOM, but does not reflect property changes back.
462
+ * A Container that is associated with a specific Node in the DOM.
257
463
  * @public
258
464
  */
259
- export declare type AttributeMode = typeof reflectMode | typeof booleanMode | "fromView";
465
+ export declare interface DOMContainer extends Container {
466
+ /**
467
+ * Instructs this particular Container to handle W3C Community Context requests
468
+ * that propagate to its associated DOM node.
469
+ * @param enable - true to enable context requests handling; false otherwise.
470
+ * @beta
471
+ */
472
+ handleContextRequests(enable: boolean): void;
473
+ }
260
474
 
261
475
  /**
262
- * Creates an standard binding.
263
- * @param binding - The binding to refresh when changed.
264
- * @param isVolatile - Indicates whether the binding is volatile or not.
265
- * @returns A binding configuration.
476
+ * The key that resolves a DOMContainer itself.
266
477
  * @public
267
478
  */
268
- export declare function bind<T = any>(binding: Expression<T>, isVolatile?: boolean): Binding<T>;
479
+ export declare const DOMContainer: ContextDecorator<DOMContainer>;
269
480
 
270
481
  /**
271
- * Captures a binding expression along with related information and capabilities.
272
- *
482
+ * Used by the default Resolver to create instances of objects when needed.
273
483
  * @public
274
484
  */
275
- export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
276
- evaluate: Expression<TSource, TReturn, TParent>;
277
- isVolatile: boolean;
485
+ export declare interface Factory<T extends Constructable = any> {
486
+ /**
487
+ * The concrete type this factory creates.
488
+ */
489
+ readonly Type: T;
278
490
  /**
279
- * Options associated with the binding.
491
+ * Registers a transformer function to alter the object after instantiation but before
492
+ * returning the final constructed instance.
493
+ * @param transformer - The transformer function.
280
494
  */
281
- options?: any;
495
+ registerTransformer(transformer: Transformer_2<T>): void;
282
496
  /**
283
- * Creates a binding.
284
- * @param evaluate - Evaluates the binding.
285
- * @param isVolatile - Indicates whether the binding is volatile.
497
+ * Constructs an instance of the factory's object.
498
+ * @param container - The container the object is being constructor for.
499
+ * @param dynamicDependencies - Dynamic dependencies supplied to the constructor.
286
500
  */
287
- constructor(evaluate: Expression<TSource, TReturn, TParent>, isVolatile?: boolean);
501
+ construct(container: Container, dynamicDependencies?: Key[]): Resolved<T>;
288
502
  /**
289
- * Creates an observer capable of notifying a subscriber when the output of a binding changes.
290
- * @param directive - The HTML Directive to create the observer for.
291
- * @param subscriber - The subscriber to changes in the binding.
503
+ * Constructs an instance of the factory's object, allowing for
504
+ * async resolution of dependencies.
505
+ * @param container - The container the object is being constructor for.
506
+ * @param dynamicDependencies - Dynamic dependencies supplied to the constructor.
292
507
  */
293
- abstract createObserver(directive: HTMLDirective, subscriber: Subscriber): ExpressionObserver<TSource, TReturn, TParent>;
508
+ constructAsync(container: Container, dynamicDependencies?: Key[]): Promise<Resolved<T>>;
509
+ }
510
+
511
+ /** @internal */
512
+ export declare class FactoryImpl<T extends Constructable = any> implements Factory<T> {
513
+ Type: T;
514
+ private readonly dependencies;
515
+ private transformers;
516
+ constructor(Type: T, dependencies: Key[]);
517
+ constructAsync(container: Container, dynamicDependencies?: Key[]): Promise<Resolved<T>>;
518
+ construct(container: Container, dynamicDependencies?: Key[]): Resolved<T>;
519
+ private constructCore;
520
+ registerTransformer(transformer: (instance: any) => any): void;
294
521
  }
295
522
 
296
523
  /**
297
- * A {@link ValueConverter} that converts to and from `boolean` values.
298
- * @remarks
299
- * Used automatically when the `boolean` {@link AttributeMode} is selected.
524
+ * A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes.
525
+ * The FASTContext can also be used as a decorator to declare context dependencies or as a key for DI.
300
526
  * @public
301
527
  */
302
- export declare const booleanConverter: ValueConverter;
303
-
304
- declare const booleanMode = "boolean";
528
+ declare type FASTContext<T> = ContextDecorator<T> & {
529
+ get(target: EventTarget): T;
530
+ provide(target: EventTarget, value: T): void;
531
+ request(target: EventTarget, callback: ContextCallback<T>, multiple?: boolean): void;
532
+ handle(target: EventTarget, callback: (event: ContextEvent<FASTContext<T>>) => void): void;
533
+ };
305
534
 
306
535
  /**
307
- * Represents a callable type such as a function or an object with a "call" method.
536
+ * A strategy that controls how all Context.request API calls are handled.
537
+ * @remarks
538
+ * By default this is handled via Context.dispatch, which dispatches a ContextEvent.
308
539
  * @public
309
540
  */
310
- export declare type Callable = typeof Function.prototype.call | {
311
- call(): void;
312
- };
541
+ declare type FASTContextRequestStrategy = <T extends UnknownContext>(target: EventTarget, context: T, callback: ContextCallback<ContextType<T>>, multiple: any) => void;
313
542
 
314
543
  /**
315
- * A marker interface used to capture types when interpolating Directive helpers
316
- * into templates.
544
+ * A decorator that tells the container not to try to inject a dependency.
545
+ *
317
546
  * @public
318
547
  */
319
- export declare interface CaptureType<TSource, TParent> {
320
- }
548
+ export declare function ignore(target: Injectable, property?: string | number, descriptor?: PropertyDescriptor | number): void;
321
549
 
322
550
  /**
323
- * The options used to configure child list observation.
551
+ * A decorator that specifies what to inject into its target.
552
+ * @param dependencies - The dependencies to inject.
553
+ * @returns The decorator to be applied to the target class.
554
+ * @remarks
555
+ * The decorator can be used to decorate a class, listing all of the classes dependencies.
556
+ * Or it can be used to decorate a constructor paramter, indicating what to inject for that
557
+ * parameter.
558
+ * Or it can be used for a web component property, indicating what that property should resolve to.
559
+ *
324
560
  * @public
325
561
  */
326
- export declare interface ChildListDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, Omit<MutationObserverInit, "subtree" | "childList"> {
327
- }
562
+ export declare const inject: (...dependencies: Key[]) => (target: any, key?: string | number, descriptor?: PropertyDescriptor | number) => void;
328
563
 
329
564
  /**
330
- * A directive that observes the `childNodes` of an element and updates a property
331
- * whenever they change.
332
- * @param propertyOrOptions - The options used to configure child node observation.
565
+ * A class that declares constructor injected dependencies through
566
+ * a static "inject" field array of keys.
333
567
  * @public
334
568
  */
335
- export declare function children<TSource = any, TParent = any>(propertyOrOptions: (keyof TSource & string) | ChildrenDirectiveOptions<keyof TSource & string>): CaptureType<TSource, TParent>;
569
+ export declare type Injectable<T = {}> = Constructable<T> & {
570
+ inject?: Key[];
571
+ };
336
572
 
337
573
  /**
338
- * The runtime behavior for child node observation.
574
+ * Used to configure a dependency injection interface key.
339
575
  * @public
340
576
  */
341
- export declare class ChildrenDirective extends NodeObservationDirective<ChildrenDirectiveOptions> {
342
- private observerProperty;
343
- /**
344
- * Creates an instance of ChildrenDirective.
345
- * @param options - The options to use in configuring the child observation behavior.
346
- */
347
- constructor(options: ChildrenDirectiveOptions);
577
+ export declare interface InterfaceConfiguration {
348
578
  /**
349
- * Begins observation of the nodes.
350
- * @param target - The target to observe.
579
+ * The friendly name for the interface. Useful for debugging.
351
580
  */
352
- observe(target: any): void;
581
+ friendlyName?: string;
353
582
  /**
354
- * Disconnects observation of the nodes.
355
- * @param target - The target to unobserve.
583
+ * When true, the dependency will be re-resolved when FASTElement connection changes.
584
+ * If the resolved value changes due to connection change, a {@link @microsoft/fast-element#Observable | notification }
585
+ * will be emitted for the property, with the previous and next values provided to any subscriber.
356
586
  */
357
- disconnect(target: any): void;
358
- /**
359
- * Retrieves the raw nodes that should be assigned to the source property.
360
- * @param target - The target to get the node to.
361
- */
362
- getNodes(target: Element): Node[];
363
- private handleEvent;
587
+ respectConnection?: boolean;
364
588
  }
365
589
 
366
590
  /**
367
- * The options used to configure child/subtree node observation.
591
+ * A key that is used to register dependencies with a dependency injection container.
368
592
  * @public
369
593
  */
370
- export declare type ChildrenDirectiveOptions<T = any> = ChildListDirectiveOptions<T> | SubtreeDirectiveOptions<T>;
594
+ export declare type Key = PropertyKey | object | ContextDecorator | Constructable | Resolver;
371
595
 
372
596
  /**
373
- * A function capable of compiling a template from the preprocessed form produced
374
- * by the html template function into a result that can instantiate views.
597
+ * A decorator that lazily injects a dependency depending on whether the `Key` is present at the time of function call.
598
+ *
599
+ * @example
600
+ * You need to make your argument a function that returns the type, for example
601
+ * ```ts
602
+ * class Foo {
603
+ * constructor( @lazy('random') public random: () => number )
604
+ * }
605
+ * const foo = container.get(Foo); // instanceof Foo
606
+ * foo.random(); // throws
607
+ * ```
608
+ * would throw an exception because you haven't registered `'random'` before calling the method.
609
+ * @example
610
+ * This, would give you a new 'Math.random()' number each time.
611
+ * ```ts
612
+ * class Foo {
613
+ * constructor( @lazy('random') public random: () => random )
614
+ * }
615
+ * container.register(Registration.callback('random', Math.random ));
616
+ * container.get(Foo).random(); // some random number
617
+ * container.get(Foo).random(); // another random number
618
+ * ```
619
+ *
620
+ * `@lazy` does not manage the lifecycle of the underlying key. If you want a singleton, you have to register as a
621
+ * `singleton`, `transient` would also behave as you would expect, providing you a new instance each time.
622
+ *
623
+ * @param key - The key to lazily resolve.
624
+ * see {@link DI.createContext} on interactions with interfaces
625
+ *
375
626
  * @public
376
627
  */
377
- export declare type CompilationStrategy = (
378
- /**
379
- * The preprocessed HTML string or template to compile.
380
- */
381
- html: string | HTMLTemplateElement,
382
- /**
383
- * The behavior factories used within the html that is being compiled.
384
- */
385
- factories: Record<string, ViewBehaviorFactory>) => HTMLTemplateCompilationResult;
628
+ export declare const lazy: (key: any) => any;
386
629
 
387
630
  /**
388
- * Common APIs related to compilation.
631
+ * A decorator that indicates that a new instance should be injected scoped to the
632
+ * container that requested the instance.
633
+ * @param key - The dependency key for the new instance.
634
+ * @remarks
635
+ * This creates a resolver with an instance strategy pointing to the new instance, effectively
636
+ * making this a singleton, scoped to the container or DOM's subtree.
637
+ *
389
638
  * @public
390
639
  */
391
- export declare const Compiler: {
392
- /**
393
- * Sets the HTML trusted types policy used by the compiler.
394
- * @param policy - The policy to set for HTML.
395
- * @remarks
396
- * This API can only be called once, for security reasons. It should be
397
- * called by the application developer at the start of their program.
398
- */
399
- setHTMLPolicy(policy: TrustedTypesPolicy): void;
400
- /**
401
- * Compiles a template and associated directives into a compilation
402
- * result which can be used to create views.
403
- * @param html - The html string or template element to compile.
404
- * @param directives - The directives referenced by the template.
405
- * @remarks
406
- * The template that is provided for compilation is altered in-place
407
- * and cannot be compiled again. If the original template must be preserved,
408
- * it is recommended that you clone the original and pass the clone to this API.
409
- * @public
410
- */
411
- compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, directives: Record<string, ViewBehaviorFactory>): HTMLTemplateCompilationResult<TSource, TParent>;
412
- /**
413
- * Sets the default compilation strategy that will be used by the ViewTemplate whenever
414
- * it needs to compile a view preprocessed with the html template function.
415
- * @param strategy - The compilation strategy to use when compiling templates.
416
- */
417
- setDefaultStrategy(strategy: CompilationStrategy): void;
418
- /**
419
- * Aggregates an array of strings and directives into a single directive.
420
- * @param parts - A heterogeneous array of static strings interspersed with
421
- * directives.
422
- * @returns A single inline directive that aggregates the behavior of all the parts.
423
- */
424
- aggregate(parts: (string | ViewBehaviorFactory)[]): ViewBehaviorFactory;
425
- };
640
+ export declare const newInstanceForScope: (key: any) => any;
426
641
 
427
642
  /**
428
- * Represents styles that can be composed into the ShadowDOM of a custom element.
643
+ * A decorator that indicates that a new instance should be injected.
644
+ * @param key - The dependency key for the new instance.
645
+ * @remarks
646
+ * The instance is not internally cached with a resolver as newInstanceForScope does.
647
+ *
429
648
  * @public
430
649
  */
431
- export declare type ComposableStyles = string | ElementStyles | CSSStyleSheet;
432
-
433
- declare function compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(this: TType, nameOrDef: string | PartialFASTElementDefinition): FASTElementDefinition<TType>;
434
-
435
- declare function compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType>;
650
+ export declare const newInstanceOf: (key: any) => any;
436
651
 
437
652
  /**
438
- * Allows for the creation of Constructable mixin classes.
653
+ * A decorator that allows you to optionally inject a dependency depending on whether the [[`Key`]] is present, for example:
654
+ * @example
655
+ * ```ts
656
+ * class Foo {
657
+ * constructor( @inject('mystring') public str: string = 'somestring' )
658
+ * }
659
+ * container.get(Foo); // throws
660
+ * ```
661
+ * would fail
662
+ *
663
+ * @example
664
+ * ```ts
665
+ * class Foo {
666
+ * constructor( @optional('mystring') public str: string = 'somestring' )
667
+ * }
668
+ * container.get(Foo).str // somestring
669
+ * ```
670
+ * if you use it without a default it will inject `undefined`, so remember to mark your input type as
671
+ * possibly `undefined`!
672
+ *
673
+ * @param key - The key to optionally resolve.
674
+ * see {@link DI.createContext} on interactions with interfaces
439
675
  *
440
676
  * @public
441
677
  */
442
- export declare type Constructable<T = {}> = {
443
- new (...args: any[]): T;
444
- };
678
+ export declare const optional: (key: any) => any;
445
679
 
446
680
  /**
447
- * A type that instantiates a StyleStrategy.
681
+ * A temporary type as a workaround for the TS compiler's erroneous built-in ParameterDecorator type.
448
682
  * @public
449
683
  */
450
- export declare type ConstructibleStyleStrategy = {
451
- /**
452
- * Creates an instance of the strategy.
453
- * @param styles - The styles to initialize the strategy with.
454
- */
455
- new (styles: (string | CSSStyleSheet)[]): StyleStrategy;
456
- };
684
+ declare type ParameterDecorator_2 = (target: Object, propertyKey: string | undefined, parameterIndex: number) => void;
457
685
 
458
686
  /**
459
- * A simple template that can create ContentView instances.
687
+ * A function capable of locating the parent container based on a container's owner.
688
+ * @remarks
689
+ * A container owner is usually an HTMLElement instance.
460
690
  * @public
461
691
  */
462
- export declare interface ContentTemplate {
463
- /**
464
- * Creates a simple content view instance.
465
- */
466
- create(): ContentView;
467
- }
692
+ export declare type ParentLocator = (owner: any) => Container | null;
468
693
 
469
694
  /**
470
- * A simple View that can be interpolated into HTML content.
695
+ * Represents an object that can register itself.
471
696
  * @public
472
697
  */
473
- export declare interface ContentView {
474
- readonly context: ExecutionContext;
475
- /**
476
- * Binds a view's behaviors to its binding source.
477
- * @param source - The binding source for the view's binding behaviors.
478
- * @param context - The execution context to run the view within.
479
- */
480
- bind(source: any, context?: ExecutionContext): void;
481
- /**
482
- * Unbinds a view's behaviors from its binding source and context.
483
- */
484
- unbind(): void;
698
+ export declare type RegisterSelf<T extends Constructable> = {
485
699
  /**
486
- * Inserts the view's DOM nodes before the referenced node.
487
- * @param node - The node to insert the view's DOM before.
700
+ * Registers itself with the container.
701
+ * @param container - The container to register with.
488
702
  */
489
- insertBefore(node: Node): void;
703
+ register(container: Container): Resolver<InstanceType<T>>;
490
704
  /**
491
- * Removes the view's DOM nodes.
492
- * The nodes are not disposed and the view can later be re-inserted.
705
+ * Indicates whether during auto registration the object should be
706
+ * registered in the requesting container rather than the handling container.
493
707
  */
494
- remove(): void;
495
- }
496
-
497
- /* Excluded from this release type: createMetadataLocator */
498
-
499
- /* Excluded from this release type: createTypeRegistry */
500
-
501
- /**
502
- * Transforms a template literal string into styles.
503
- * @param strings - The string fragments that are interpolated with the values.
504
- * @param values - The values that are interpolated with the string fragments.
505
- * @remarks
506
- * The css helper supports interpolation of strings and ElementStyle instances.
507
- * @public
508
- */
509
- export declare const css: CSSTemplateTag;
708
+ registerInRequestor: boolean;
709
+ };
510
710
 
511
711
  /**
512
- * Directive for use in {@link css}.
513
- *
712
+ * Implemented by objects that wish to register dependencies in the container
713
+ * by creating resolvers.
514
714
  * @public
515
715
  */
516
- export declare interface CSSDirective {
716
+ export declare interface Registration<K = any> {
517
717
  /**
518
- * Creates a CSS fragment to interpolate into the CSS document.
519
- * @returns - the string to interpolate into CSS
718
+ * Creates a resolver for a desired dependency.
719
+ * @param container - The container to register the dependency within.
720
+ * @param key - The key to register dependency under, if overridden.
520
721
  */
521
- createCSS(add: AddBehavior): ComposableStyles;
722
+ register(container: Container): Resolver<K>;
522
723
  }
523
724
 
524
725
  /**
525
- * Instructs the css engine to provide dynamic styles or
526
- * associate behaviors with styles.
726
+ * You can use the resulting Registration of any of the factory methods
727
+ * to register with the container.
728
+ *
729
+ * @example
730
+ * ```
731
+ * class Foo {}
732
+ * const container = DI.createContainer();
733
+ * container.register(Registration.instance(Foo, new Foo()));
734
+ * container.get(Foo);
735
+ * ```
736
+ *
527
737
  * @public
528
738
  */
529
- export declare const CSSDirective: Readonly<{
739
+ export declare const Registration: Readonly<{
740
+ /**
741
+ * Allows you to pass an instance.
742
+ * Every time you request this {@link Key} you will get this instance back.
743
+ *
744
+ * @example
745
+ * ```
746
+ * Registration.instance(Foo, new Foo()));
747
+ * ```
748
+ *
749
+ * @param key - The key to register the instance under.
750
+ * @param value - The instance to return when the key is requested.
751
+ */
752
+ instance<T>(key: Key, value: T): Registration<T>;
753
+ /**
754
+ * Creates an instance from the class.
755
+ * Every time you request this {@link Key} you will get the same one back.
756
+ *
757
+ * @example
758
+ * ```
759
+ * Registration.singleton(Foo, Foo);
760
+ * ```
761
+ *
762
+ * @param key - The key to register the singleton under.
763
+ * @param value - The class to instantiate as a singleton when first requested.
764
+ */
765
+ singleton<T_1 extends Constructable<{}>>(key: Key, value: T_1): Registration<InstanceType<T_1>>;
766
+ /**
767
+ * Creates an instance from a class.
768
+ * Every time you request this {@link Key} you will get a new instance.
769
+ *
770
+ * @example
771
+ * ```
772
+ * Registration.instance(Foo, Foo);
773
+ * ```
774
+ *
775
+ * @param key - The key to register the instance type under.
776
+ * @param value - The class to instantiate each time the key is requested.
777
+ */
778
+ transient<T_2 extends Constructable<{}>>(key: Key, value: T_2): Registration<InstanceType<T_2>>;
530
779
  /**
531
- * Gets the directive definition associated with the instance.
532
- * @param instance - The directive instance to retrieve the definition for.
780
+ * Delegates to a callback function to provide the dependency.
781
+ * Every time you request this {@link Key} the callback will be invoked to provide
782
+ * the dependency.
783
+ *
784
+ * @example
785
+ * ```
786
+ * Registration.callback(Foo, () => new Foo());
787
+ * Registration.callback(Bar, (c: Container) => new Bar(c.get(Foo)));
788
+ * ```
789
+ *
790
+ * @param key - The key to register the callback for.
791
+ * @param callback - The function that is expected to return the dependency.
533
792
  */
534
- getForInstance: (object: any) => CSSDirectiveDefinition<Constructable<CSSDirective>> | undefined;
793
+ callback<T_3>(key: Key, callback: ResolveCallback<T_3>): Registration<Resolved<T_3>>;
535
794
  /**
536
- * Gets the directive definition associated with the specified type.
537
- * @param type - The directive type to retrieve the definition for.
795
+ * Delegates to a callback function to provide the dependency and then caches the
796
+ * dependency for future requests.
797
+ *
798
+ * @example
799
+ * ```
800
+ * Registration.cachedCallback(Foo, () => new Foo());
801
+ * Registration.cachedCallback(Bar, (c: Container) => new Bar(c.get(Foo)));
802
+ * ```
803
+ *
804
+ * @param key - The key to register the callback for.
805
+ * @param callback - The function that is expected to return the dependency.
806
+ * @remarks
807
+ * If you pass the same Registration to another container, the same cached value will be used.
808
+ * Should all references to the resolver returned be removed, the cache will expire.
538
809
  */
539
- getByType: (key: Function) => CSSDirectiveDefinition<Constructable<CSSDirective>> | undefined;
810
+ cachedCallback<T_4>(key: Key, callback: ResolveCallback<T_4>): Registration<Resolved<T_4>>;
540
811
  /**
541
- * Defines a CSSDirective.
542
- * @param type - The type to define as a directive.
812
+ * Creates an alternate {@link Key} to retrieve an instance by.
813
+ *
814
+ * @example
815
+ * ```
816
+ * Register.singleton(Foo, Foo)
817
+ * Register.aliasTo(Foo, MyFoos);
818
+ *
819
+ * container.getAll(MyFoos) // contains an instance of Foo
820
+ * ```
821
+ *
822
+ * @param originalKey - The original key that has been registered.
823
+ * @param aliasKey - The alias to the original key.
543
824
  */
544
- define<TType extends Constructable<CSSDirective>>(type: any): TType;
825
+ aliasTo<T_5>(originalKey: T_5, aliasKey: Key): Registration<Resolved<T_5>>;
545
826
  }>;
546
827
 
547
828
  /**
548
- * Decorator: Defines a CSSDirective.
549
- * @public
550
- */
551
- export declare function cssDirective(): (type: Constructable<CSSDirective>) => void;
552
-
553
- /**
554
- * Defines metadata for a CSSDirective.
829
+ * Implemented by objects that which to register dependencies in a container.
555
830
  * @public
556
831
  */
557
- export declare interface CSSDirectiveDefinition<TType extends Constructable<CSSDirective> = Constructable<CSSDirective>> {
832
+ export declare interface Registry {
558
833
  /**
559
- * The type that the definition provides metadata for.
834
+ * Registers dependencies in the specified container.
835
+ * @param container - The container to register dependencies in.
836
+ * @param params - Parameters that affect the registration process.
837
+ * @remarks
838
+ * If this registry doubles as a Registration, it should return a Resolver
839
+ * for the registered dependency.
560
840
  */
561
- readonly type: TType;
841
+ register(container: Container, ...params: unknown[]): void | Resolver;
562
842
  }
563
843
 
564
844
  /**
565
- * @deprecated Use css.partial instead.
845
+ * Represents a custom callback for resolving a request from the container.
846
+ * The handler is the container that is invoking the callback. The requestor
847
+ * is the original container that made the request. The handler and the requestor
848
+ * may not be the same if the request has bubbled up to a parent container in the DI hierarchy.
849
+ * The resolver is the instance of the resolver that stores the callback. This is provided in case
850
+ * the callback needs a place or key against which to store state across resolutions.
566
851
  * @public
567
852
  */
568
- export declare const cssPartial: (strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => CSSDirective;
853
+ export declare type ResolveCallback<T = any> = (handler: Container, requestor: Container, resolver: Resolver<T>) => T;
569
854
 
570
855
  /**
571
- * Transforms a template literal string into styles.
572
- * @param strings - The string fragments that are interpolated with the values.
573
- * @param values - The values that are interpolated with the string fragments.
574
- * @remarks
575
- * The css helper supports interpolation of strings and ElementStyle instances.
576
- * Use the .partial method to create partial CSS fragments.
577
- * @public
578
- */
579
- export declare type CSSTemplateTag = ((strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => ElementStyles) & {
580
- /**
581
- * Transforms a template literal string into partial CSS.
582
- * @param strings - The string fragments that are interpolated with the values.
583
- * @param values - The values that are interpolated with the string fragments.
584
- * @public
585
- */
586
- partial(strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]): CSSDirective;
587
- };
588
-
589
- /**
590
- * Decorator: Defines a platform custom element based on `FASTElement`.
591
- * @param nameOrDef - The name of the element to define or a definition object
592
- * that describes the element to define.
856
+ * Represents something resolved from a service locator.
593
857
  * @public
594
858
  */
595
- export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Constructable<HTMLElement>) => void;
859
+ export declare type Resolved<K> = K extends ContextDecorator<infer T> ? T : K extends Constructable ? InstanceType<K> : K extends ResolverLike<any, infer T1> ? T1 extends Constructable ? InstanceType<T1> : T1 : K;
596
860
 
597
861
  /**
598
- * Metadata used to configure a custom attribute's behavior through a decorator.
862
+ * Internally, the DI system maps "keys" to "resolvers". A resolver controls
863
+ * how a dependency is resolved. Resolvers for transient, singleton, etc. are
864
+ * provided out of the box, but you can also implement Resolver yourself and supply
865
+ * custom logic for resolution.
599
866
  * @public
600
867
  */
601
- export declare type DecoratorAttributeConfiguration = Omit<AttributeConfiguration, "property">;
602
-
603
- declare function define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(this: TType, nameOrDef: string | PartialFASTElementDefinition): TType;
604
-
605
- declare function define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType;
868
+ export declare interface Resolver<K = any> extends ResolverLike<Container, K> {
869
+ }
606
870
 
607
871
  /**
608
- * Provides a mechanism for releasing resources.
872
+ * A utility class used that constructs and registers resolvers for a dependency
873
+ * injection container. Supports a standard set of object lifetimes.
609
874
  * @public
610
875
  */
611
- export declare interface Disposable {
876
+ export declare class ResolverBuilder<K> {
877
+ private container;
878
+ private key;
612
879
  /**
613
- * Disposes the resources.
880
+ *
881
+ * @param container - The container to create resolvers for.
882
+ * @param key - The key to register resolvers under.
614
883
  */
615
- dispose(): void;
616
- }
617
-
618
- /**
619
- * Common DOM APIs.
620
- * @public
621
- */
622
- export declare const DOM: Readonly<{
884
+ constructor(container: Container, key: Key);
623
885
  /**
624
- * @deprecated
625
- * Use Updates.enqueue().
886
+ * Creates a resolver for an existing object instance.
887
+ * @param value - The instance to resolve.
888
+ * @returns The resolver.
626
889
  */
627
- queueUpdate: (callable: Callable) => void;
890
+ instance(value: K): Resolver<K>;
628
891
  /**
629
- * @deprecated
630
- * Use Updates.next()
892
+ * Creates a resolver that enforces a singleton lifetime.
893
+ * @param value - The type to create and cache the singleton for.
894
+ * @returns The resolver.
631
895
  */
632
- nextUpdate: () => Promise<void>;
896
+ singleton(value: Constructable): Resolver<K>;
633
897
  /**
634
- * @deprecated
635
- * Use Updates.process()
898
+ * Creates a resolver that creates a new instance for every dependency request.
899
+ * @param value - The type to create instances of.
900
+ * @returns - The resolver.
636
901
  */
637
- processUpdates: () => void;
902
+ transient(value: Constructable): Resolver<K>;
638
903
  /**
639
- * Sets an attribute value on an element.
640
- * @param element - The element to set the attribute value on.
641
- * @param attributeName - The attribute name to set.
642
- * @param value - The value of the attribute to set.
643
- * @remarks
644
- * If the value is `null` or `undefined`, the attribute is removed, otherwise
645
- * it is set to the provided value using the standard `setAttribute` API.
904
+ * Creates a resolver that invokes a callback function for every dependency resolution
905
+ * request, allowing custom logic to return the dependency.
906
+ * @param value - The callback to call during resolution.
907
+ * @returns The resolver.
646
908
  */
647
- setAttribute(element: HTMLElement, attributeName: string, value: any): void;
909
+ callback(value: ResolveCallback<K>): Resolver<K>;
648
910
  /**
649
- * Sets a boolean attribute value.
650
- * @param element - The element to set the boolean attribute value on.
651
- * @param attributeName - The attribute name to set.
652
- * @param value - The value of the attribute to set.
653
- * @remarks
654
- * If the value is true, the attribute is added; otherwise it is removed.
911
+ * Creates a resolver that invokes a callback function the first time that a dependency
912
+ * resolution is requested. The returned value is then cached and provided for all
913
+ * subsequent requests.
914
+ * @param value - The callback to call during the first resolution.
915
+ * @returns The resolver.
655
916
  */
656
- setBooleanAttribute(element: HTMLElement, attributeName: string, value: boolean): void;
657
- }>;
917
+ cachedCallback(value: ResolveCallback<K>): Resolver<K>;
918
+ /**
919
+ * Aliases the current key to a different key.
920
+ * @param destinationKey - The key to point the alias to.
921
+ * @returns The resolver.
922
+ */
923
+ aliasTo(destinationKey: Key): Resolver<K>;
924
+ private registerResolver;
925
+ }
926
+
927
+ /** @internal */
928
+ export declare class ResolverImpl implements Resolver, Registration {
929
+ key: Key;
930
+ strategy: ResolverStrategy;
931
+ state: any;
932
+ constructor(key: Key, strategy: ResolverStrategy, state: any);
933
+ get $isResolver(): true;
934
+ private resolving;
935
+ register(container: Container): Resolver;
936
+ resolveAsync(handler: Container, requestor: Container): Promise<any>;
937
+ resolve(handler: Container, requestor: Container): any;
938
+ getFactory(container: Container): Factory | null;
939
+ }
940
+
941
+ declare interface ResolverLike<C, K = any> {
942
+ readonly $isResolver: true;
943
+ resolve(handler: C, requestor: C): Resolved<K>;
944
+ resolveAsync(handler: C, requestor: C): Promise<Resolved<K>>;
945
+ getFactory?(container: C): (K extends Constructable ? Factory<K> : never) | null;
946
+ }
947
+
948
+ /** @internal */
949
+ export declare const enum ResolverStrategy {
950
+ instance = 0,
951
+ singleton = 1,
952
+ transient = 2,
953
+ callback = 3,
954
+ array = 4,
955
+ alias = 5
956
+ }
658
957
 
659
958
  /**
660
- * Controls the lifecycle and rendering of a `FASTElement`.
959
+ * Implemented by objects capable of resolving services and other dependencies.
661
960
  * @public
662
961
  */
663
- export declare class ElementController<TElement extends HTMLElement = HTMLElement> extends PropertyChangeNotifier implements HostController<TElement> {
664
- private boundObservables;
665
- private needsInitialization;
666
- private hasExistingShadowRoot;
667
- private _template;
668
- private _isConnected;
669
- private behaviors;
670
- private _mainStyles;
671
- /**
672
- * This allows Observable.getNotifier(...) to return the Controller
673
- * when the notifier for the Controller itself is being requested. The
674
- * result is that the Observable system does not need to create a separate
675
- * instance of Notifier for observables on the Controller. The component and
676
- * the controller will now share the same notifier, removing one-object construct
677
- * per web component instance.
678
- */
679
- private readonly $fastController;
962
+ export declare interface ServiceLocator {
680
963
  /**
681
- * The element being controlled by this controller.
964
+ * Determines whether the locator has the ability to provide an implementation
965
+ * for the requested key.
966
+ * @param key - The dependency key to lookup.
967
+ * @param searchAncestors - Indicates whether to search the entire hierarchy of service locators.
682
968
  */
683
- readonly source: TElement;
969
+ has<K extends Key>(key: K | Key, searchAncestors: boolean): boolean;
684
970
  /**
685
- * The element definition that instructs this controller
686
- * in how to handle rendering and other platform integrations.
971
+ * Gets a dependency by key.
972
+ * @param key - The key to lookup.
687
973
  */
688
- readonly definition: FASTElementDefinition;
974
+ get<K extends Key>(key: K): Resolved<K>;
689
975
  /**
690
- * The view associated with the custom element.
691
- * @remarks
692
- * If `null` then the element is managing its own rendering.
693
- */
694
- readonly view: ElementView<TElement> | null;
695
- /**
696
- * Indicates whether or not the custom element has been
697
- * connected to the document.
698
- */
699
- get isConnected(): boolean;
700
- private setIsConnected;
701
- /**
702
- * Gets/sets the template used to render the component.
703
- * @remarks
704
- * This value can only be accurately read after connect but can be set at any time.
705
- */
706
- get template(): ElementViewTemplate<TElement> | null;
707
- set template(value: ElementViewTemplate<TElement> | null);
708
- /**
709
- * The main set of styles used for the component, independent
710
- * of any dynamically added styles.
976
+ * Gets a dependency by key.
977
+ * @param key - The key to lookup.
711
978
  */
712
- get mainStyles(): ElementStyles | null;
713
- set mainStyles(value: ElementStyles | null);
714
- /* Excluded from this release type: __constructor */
979
+ get<K extends Key>(key: Key): Resolved<K>;
715
980
  /**
716
- * Adds the behavior to the component.
717
- * @param behavior - The behavior to add.
981
+ * Gets a dependency by key.
982
+ * @param key - The key to lookup.
718
983
  */
719
- addBehavior(behavior: HostBehavior<TElement>): void;
984
+ get<K extends Key>(key: K | Key): Resolved<K>;
720
985
  /**
721
- * Removes the behavior from the component.
722
- * @param behavior - The behavior to remove.
723
- * @param force - Forces removal even if this behavior was added more than once.
986
+ * Gets a dependency by key, allowing for asynchronously
987
+ * resolved dependencies.
988
+ * @param key - The key to lookup.
724
989
  */
725
- removeBehavior(behavior: HostBehavior<TElement>, force?: boolean): void;
990
+ getAsync<K extends Key>(key: K): Promise<Resolved<K>>;
726
991
  /**
727
- * Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
728
- * @param styles - The styles to add.
992
+ * Gets a dependency by key, allowing for asynchronously
993
+ * resolved dependencies.
994
+ * @param key - The key to lookup.
729
995
  */
730
- addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
996
+ getAsync<K extends Key>(key: Key): Promise<Resolved<K>>;
731
997
  /**
732
- * Removes styles from this element. Providing an HTMLStyleElement will detach the element instance from the shadowRoot.
733
- * @param styles - the styles to remove.
998
+ * Gets a dependency by key, allowing for asynchronously
999
+ * resolved dependencies.
1000
+ * @param key - The key to lookup.
734
1001
  */
735
- removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
1002
+ getAsync<K extends Key>(key: K | Key): Promise<Resolved<K>>;
736
1003
  /**
737
- * Runs connected lifecycle behavior on the associated element.
1004
+ * Gets an array of all dependencies by key.
1005
+ * @param key - The key to lookup.
1006
+ * @param searchAncestors - Indicates whether to search the entire hierarchy of service locators.
738
1007
  */
739
- connect(): void;
1008
+ getAll<K extends Key>(key: K, searchAncestors?: boolean): readonly Resolved<K>[];
740
1009
  /**
741
- * Runs disconnected lifecycle behavior on the associated element.
1010
+ * Gets an array of all dependencies by key.
1011
+ * @param key - The key to lookup.
1012
+ * @param searchAncestors - Indicates whether to search the entire hierarchy of service locators.
742
1013
  */
743
- disconnect(): void;
1014
+ getAll<K extends Key>(key: Key, searchAncestors?: boolean): readonly Resolved<K>[];
744
1015
  /**
745
- * Runs the attribute changed callback for the associated element.
746
- * @param name - The name of the attribute that changed.
747
- * @param oldValue - The previous value of the attribute.
748
- * @param newValue - The new value of the attribute.
1016
+ * Gets an array of all dependencies by key.
1017
+ * @param key - The key to lookup.
1018
+ * @param searchAncestors - Indicates whether to search the entire hierarchy of service locators.
749
1019
  */
750
- onAttributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
751
- /**
752
- * Emits a custom HTML event.
753
- * @param type - The type name of the event.
754
- * @param detail - The event detail object to send with the event.
755
- * @param options - The event options. By default bubbles and composed.
756
- * @remarks
757
- * Only emits events if connected.
758
- */
759
- emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean;
760
- private finishInitialization;
761
- private renderTemplate;
762
- /**
763
- * Locates or creates a controller for the specified element.
764
- * @param element - The element to return the controller for.
765
- * @remarks
766
- * The specified element must have a {@link FASTElementDefinition}
767
- * registered either through the use of the {@link customElement}
768
- * decorator or a call to `FASTElement.define`.
769
- */
770
- static forCustomElement(element: HTMLElement): ElementController;
1020
+ getAll<K extends Key>(key: K | Key, searchAncestors?: boolean): readonly Resolved<K>[];
771
1021
  }
772
1022
 
773
1023
  /**
774
- * Creates a function that can be used to filter a Node array, selecting only elements.
775
- * @param selector - An optional selector to restrict the filter to.
1024
+ * The key that resolves the ServiceLocator itself.
776
1025
  * @public
777
1026
  */
778
- export declare const elements: (selector?: string) => ElementsFilter;
1027
+ export declare const ServiceLocator: ContextDecorator<ServiceLocator>;
779
1028
 
780
1029
  /**
781
- * Elements filter function type.
1030
+ * Registers the decorated class as a singleton dependency; the class will only be created once. Each
1031
+ * consecutive time the dependency is resolved, the same instance will be returned.
1032
+ *
1033
+ * @example
1034
+ * ```ts
1035
+ * @singleton()
1036
+ * class Foo { }
1037
+ * ```
782
1038
  *
783
1039
  * @public
784
1040
  */
785
- export declare type ElementsFilter = (value: Node, index?: number, array?: Node[]) => boolean;
1041
+ export declare function singleton<T extends Constructable>(): typeof singletonDecorator;
786
1042
 
787
1043
  /**
788
- * Represents styles that can be applied to a custom element.
789
1044
  * @public
790
1045
  */
791
- export declare class ElementStyles {
792
- readonly styles: ReadonlyArray<ComposableStyles>;
793
- private targets;
794
- private _strategy;
795
- /**
796
- * The behaviors associated with this set of styles.
797
- */
798
- readonly behaviors: ReadonlyArray<HostBehavior<HTMLElement>> | null;
799
- /**
800
- * Gets the StyleStrategy associated with these element styles.
801
- */
802
- get strategy(): StyleStrategy;
803
- /**
804
- * Creates an instance of ElementStyles.
805
- * @param styles - The styles that will be associated with elements.
806
- */
807
- constructor(styles: ReadonlyArray<ComposableStyles>);
808
- /* Excluded from this release type: addStylesTo */
809
- /* Excluded from this release type: removeStylesFrom */
810
- /* Excluded from this release type: isAttachedTo */
811
- /**
812
- * Associates behaviors with this set of styles.
813
- * @param behaviors - The behaviors to associate.
814
- */
815
- withBehaviors(...behaviors: HostBehavior<HTMLElement>[]): this;
816
- /**
817
- * Sets the strategy that handles adding/removing these styles for an element.
818
- * @param strategy - The strategy to use.
819
- */
820
- withStrategy(Strategy: ConstructibleStyleStrategy): this;
821
- /**
822
- * Sets the default strategy type to use when creating style strategies.
823
- * @param Strategy - The strategy type to construct.
824
- */
825
- static setDefaultStrategy(Strategy: ConstructibleStyleStrategy): void;
826
- /**
827
- * Normalizes a set of composable style options.
828
- * @param styles - The style options to normalize.
829
- * @returns A singular ElementStyles instance or undefined.
830
- */
831
- static normalize(styles: ComposableStyles | ComposableStyles[] | undefined): ElementStyles | undefined;
832
- /**
833
- * Indicates whether the DOM supports the adoptedStyleSheets feature.
834
- */
835
- static readonly supportsAdoptedStyleSheets: boolean;
836
- }
1046
+ export declare function singleton<T extends Constructable>(options?: SingletonOptions): typeof singletonDecorator;
837
1047
 
838
1048
  /**
839
- * A View representing DOM nodes specifically for rendering the view of a custom element.
840
- * @public
841
- */
842
- export declare interface ElementView<TSource = any, TParent = any> extends View<TSource, TParent> {
843
- /**
844
- * Appends the view's DOM nodes to the referenced node.
845
- * @param node - The parent node to append the view's DOM nodes to.
846
- */
847
- appendTo(node: Node): void;
848
- }
849
-
850
- /**
851
- * A template capable of creating views specifically for rendering custom elements.
852
- * @public
853
- */
854
- export declare interface ElementViewTemplate<TSource = any, TParent = any> {
855
- /**
856
- * Creates an ElementView instance based on this template definition.
857
- * @param hostBindingTarget - The element that host behaviors will be bound to.
858
- */
859
- create(hostBindingTarget: Element): ElementView<TSource, TParent>;
860
- /**
861
- * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
862
- * @param source - The data source to bind the template to.
863
- * @param host - The Element where the template will be rendered.
864
- * @param hostBindingTarget - An HTML element to target the host bindings at if different from the
865
- * host that the template is being attached to.
866
- */
867
- render(source: TSource, host: Node, hostBindingTarget?: Element): ElementView<TSource, TParent>;
868
- }
869
-
870
- /**
871
- * A readonly, empty array.
872
- * @remarks
873
- * Typically returned by APIs that return arrays when there are
874
- * no actual items to return.
875
- * @public
876
- */
877
- export declare const emptyArray: readonly never[];
878
-
879
- /**
880
- * Provides additional contextual information available to behaviors and expressions.
881
- * @public
882
- */
883
- export declare interface ExecutionContext<TParent = any> {
884
- /**
885
- * The index of the current item within a repeat context.
886
- */
887
- index: number;
888
- /**
889
- * The length of the current collection within a repeat context.
890
- */
891
- length: number;
892
- /**
893
- * The parent data source within a nested context.
894
- */
895
- parent: TParent;
896
- /**
897
- * The parent execution context when in nested context scenarios.
898
- */
899
- parentContext: ExecutionContext<TParent>;
900
- /**
901
- * The current event within an event handler.
902
- */
903
- readonly event: Event;
904
- /**
905
- * Indicates whether the current item within a repeat context
906
- * has an even index.
907
- */
908
- readonly isEven: boolean;
909
- /**
910
- * Indicates whether the current item within a repeat context
911
- * has an odd index.
912
- */
913
- readonly isOdd: boolean;
914
- /**
915
- * Indicates whether the current item within a repeat context
916
- * is the first item in the collection.
917
- */
918
- readonly isFirst: boolean;
919
- /**
920
- * Indicates whether the current item within a repeat context
921
- * is somewhere in the middle of the collection.
922
- */
923
- readonly isInMiddle: boolean;
924
- /**
925
- * Indicates whether the current item within a repeat context
926
- * is the last item in the collection.
927
- */
928
- readonly isLast: boolean;
929
- /**
930
- * Returns the typed event detail of a custom event.
931
- */
932
- eventDetail<TDetail>(): TDetail;
933
- /**
934
- * Returns the typed event target of the event.
935
- */
936
- eventTarget<TTarget extends EventTarget>(): TTarget;
937
- }
938
-
939
- /**
940
- * Provides additional contextual information available to behaviors and expressions.
941
- * @public
942
- */
943
- export declare const ExecutionContext: Readonly<{
944
- /**
945
- * A default execution context.
946
- */
947
- default: ExecutionContext<any>;
948
- /**
949
- * Gets the current event.
950
- * @returns An event object.
951
- */
952
- getEvent(): Event | null;
953
- /**
954
- * Sets the current event.
955
- * @param event - An event object.
956
- */
957
- setEvent(event: Event | null): void;
958
- }>;
959
-
960
- /**
961
- * The signature of an arrow function capable of being evaluated
962
- * against source data and within an execution context.
963
- * @public
964
- */
965
- export declare type Expression<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn;
966
-
967
- /**
968
- * Controls the lifecycle of an expression and provides relevant context.
969
- * @public
970
- */
971
- export declare interface ExpressionController<TSource = any, TParent = any> {
972
- /**
973
- * The source the expression is evaluated against.
974
- */
975
- readonly source: TSource;
976
- /**
977
- * Indicates how the source's lifetime relates to the controller's lifetime.
978
- */
979
- readonly sourceLifetime?: SourceLifetime;
980
- /**
981
- * The context the expression is evaluated against.
982
- */
983
- readonly context: ExecutionContext<TParent>;
984
- /**
985
- * Indicates whether the controller is bound.
986
- */
987
- readonly isBound: boolean;
988
- /**
989
- * Registers an unbind handler with the controller.
990
- * @param behavior - An object to call when the controller unbinds.
991
- */
992
- onUnbind(behavior: {
993
- unbind(controller: ExpressionController<TSource, TParent>): any;
994
- }): void;
995
- }
996
-
997
- /**
998
- * Enables evaluation of and subscription to a binding.
999
- * @public
1000
- */
1001
- export declare interface ExpressionNotifier<TSource = any, TReturn = any, TParent = any> extends Notifier, ExpressionObserver<TSource, TReturn, TParent>, Disposable {
1002
- /**
1003
- * Observes the expression.
1004
- * @param source - The source for the expression.
1005
- * @param context - The context for the expression.
1006
- */
1007
- observe(source: TSource, context?: ExecutionContext): TReturn;
1008
- /**
1009
- * Gets {@link ObservationRecord|ObservationRecords} that the {@link ExpressionNotifier}
1010
- * is observing.
1011
- */
1012
- records(): IterableIterator<ObservationRecord>;
1013
- /**
1014
- * Sets the update mode used by the observer.
1015
- * @param isAsync - Indicates whether updates should be asynchronous.
1016
- * @remarks
1017
- * By default, the update mode is asynchronous, since that provides the best
1018
- * performance for template rendering scenarios. Passing false to setMode will
1019
- * instead cause the observer to notify subscribers immediately when changes occur.
1020
- */
1021
- setMode(isAsync: boolean): void;
1022
- }
1023
-
1024
- /**
1025
- * Observes an expression for changes.
1026
- * @public
1027
- */
1028
- export declare interface ExpressionObserver<TSource = any, TReturn = any, TParent = any> {
1029
- /**
1030
- * Binds the expression to the source.
1031
- * @param controller - The controller that manages the lifecycle and related
1032
- * context for the expression.
1033
- */
1034
- bind(controller: ExpressionController<TSource, TParent>): TReturn;
1035
- }
1036
-
1037
- /* Excluded from this release type: FAST */
1038
-
1039
- /**
1040
- * Represents a custom element based on the FASTElement infrastructure.
1041
- * @public
1042
- */
1043
- export declare interface FASTElement extends HTMLElement {
1044
- /**
1045
- * The underlying controller that handles the lifecycle and rendering of
1046
- * this FASTElement.
1047
- */
1048
- readonly $fastController: ElementController;
1049
- /**
1050
- * Emits a custom HTML event.
1051
- * @param type - The type name of the event.
1052
- * @param detail - The event detail object to send with the event.
1053
- * @param options - The event options. By default bubbles and composed.
1054
- * @remarks
1055
- * Only emits events if the element is connected.
1056
- */
1057
- $emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): boolean | void;
1058
- /**
1059
- * The connected callback for this FASTElement.
1060
- * @remarks
1061
- * This method is invoked by the platform whenever this FASTElement
1062
- * becomes connected to the document.
1063
- */
1064
- connectedCallback(): void;
1065
- /**
1066
- * The disconnected callback for this FASTElement.
1067
- * @remarks
1068
- * This method is invoked by the platform whenever this FASTElement
1069
- * becomes disconnected from the document.
1070
- */
1071
- disconnectedCallback(): void;
1072
- /**
1073
- * The attribute changed callback for this FASTElement.
1074
- * @param name - The name of the attribute that changed.
1075
- * @param oldValue - The previous value of the attribute.
1076
- * @param newValue - The new value of the attribute.
1077
- * @remarks
1078
- * This method is invoked by the platform whenever an observed
1079
- * attribute of FASTElement has a value change.
1080
- */
1081
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
1082
- }
1083
-
1084
- /**
1085
- * A minimal base class for FASTElements that also provides
1086
- * static helpers for working with FASTElements.
1087
- * @public
1088
- */
1089
- export declare const FASTElement: {
1090
- new (): FASTElement;
1091
- define: typeof define;
1092
- compose: typeof compose;
1093
- from: typeof from;
1094
- };
1095
-
1096
- /**
1097
- * Defines metadata for a FASTElement.
1098
- * @public
1099
- */
1100
- export declare class FASTElementDefinition<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> {
1101
- private platformDefined;
1102
- /**
1103
- * The type this element definition describes.
1104
- */
1105
- readonly type: TType;
1106
- /**
1107
- * Indicates if this element has been defined in at least one registry.
1108
- */
1109
- get isDefined(): boolean;
1110
- /**
1111
- * The name of the custom element.
1112
- */
1113
- readonly name: string;
1114
- /**
1115
- * The custom attributes of the custom element.
1116
- */
1117
- readonly attributes: ReadonlyArray<AttributeDefinition>;
1118
- /**
1119
- * A map enabling lookup of attribute by associated property name.
1120
- */
1121
- readonly propertyLookup: Record<string, AttributeDefinition>;
1122
- /**
1123
- * A map enabling lookup of property by associated attribute name.
1124
- */
1125
- readonly attributeLookup: Record<string, AttributeDefinition>;
1126
- /**
1127
- * The template to render for the custom element.
1128
- */
1129
- readonly template?: ElementViewTemplate;
1130
- /**
1131
- * The styles to associate with the custom element.
1132
- */
1133
- readonly styles?: ElementStyles;
1134
- /**
1135
- * Options controlling the creation of the custom element's shadow DOM.
1136
- */
1137
- readonly shadowOptions?: ShadowRootOptions;
1138
- /**
1139
- * Options controlling how the custom element is defined with the platform.
1140
- */
1141
- readonly elementOptions: ElementDefinitionOptions;
1142
- /**
1143
- * The registry to register this component in by default.
1144
- */
1145
- readonly registry: CustomElementRegistry;
1146
- private constructor();
1147
- /**
1148
- * Defines a custom element based on this definition.
1149
- * @param registry - The element registry to define the element in.
1150
- * @remarks
1151
- * This operation is idempotent per registry.
1152
- */
1153
- define(registry?: CustomElementRegistry): this;
1154
- /**
1155
- * Creates an instance of FASTElementDefinition.
1156
- * @param type - The type this definition is being created for.
1157
- * @param nameOrDef - The name of the element to define or a config object
1158
- * that describes the element to define.
1159
- */
1160
- static compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType>;
1161
- /**
1162
- * Gets the element definition associated with the specified type.
1163
- * @param type - The custom element type to retrieve the definition for.
1164
- */
1165
- static readonly getByType: (key: Function) => FASTElementDefinition<Constructable<HTMLElement>> | undefined;
1166
- /**
1167
- * Gets the element definition associated with the instance.
1168
- * @param instance - The custom element instance to retrieve the definition for.
1169
- */
1170
- static readonly getForInstance: (object: any) => FASTElementDefinition<Constructable<HTMLElement>> | undefined;
1171
- }
1172
-
1173
- /* Excluded from this release type: FASTGlobal */
1174
-
1175
- declare function from<TBase extends typeof HTMLElement>(BaseType: TBase): new () => InstanceType<TBase> & FASTElement;
1176
-
1177
- /**
1178
- * Represents an object that can contribute behavior to a host.
1179
- * @public
1180
- */
1181
- export declare interface HostBehavior<TSource = any> {
1182
- /**
1183
- * Executed when this behavior is attached to a controller.
1184
- * @param controller - Controls the behavior lifecycle.
1185
- */
1186
- addedCallback?(controller: HostController<TSource>): void;
1187
- /**
1188
- * Executed when this behavior is detached from a controller.
1189
- * @param controller - Controls the behavior lifecycle.
1190
- */
1191
- removedCallback?(controller: HostController<TSource>): void;
1192
- /**
1193
- * Executed when this behavior's host is connected.
1194
- * @param controller - Controls the behavior lifecycle.
1195
- */
1196
- connectedCallback?(controller: HostController<TSource>): void;
1197
- /**
1198
- * Executed when this behavior's host is disconnected.
1199
- * @param controller - Controls the behavior lifecycle.
1200
- */
1201
- disconnectedCallback?(controller: HostController<TSource>): void;
1202
- }
1203
-
1204
- /**
1205
- * Controls the lifecycle and context of behaviors and styles
1206
- * associated with a component host.
1207
- * @public
1208
- */
1209
- export declare interface HostController<TSource = any> {
1210
- /**
1211
- * The component source.
1212
- */
1213
- readonly source: TSource;
1214
- /**
1215
- * Indicates whether the host is connected or not.
1216
- */
1217
- readonly isConnected: boolean;
1218
- /**
1219
- * The main set of styles used for the component, independent
1220
- * of any behavior-specific styles.
1221
- */
1222
- mainStyles: ElementStyles | null;
1223
- /**
1224
- * Adds the behavior to the component.
1225
- * @param behavior - The behavior to add.
1226
- */
1227
- addBehavior(behavior: HostBehavior<TSource>): void;
1228
- /**
1229
- * Removes the behavior from the component.
1230
- * @param behavior - The behavior to remove.
1231
- * @param force - Forces removal even if this behavior was added more than once.
1232
- */
1233
- removeBehavior(behavior: HostBehavior<TSource>, force?: boolean): void;
1234
- /**
1235
- * Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
1236
- * @param styles - The styles to add.
1237
- */
1238
- addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
1239
- /**
1240
- * Removes styles from this element. Providing an HTMLStyleElement will detach the element instance from the shadowRoot.
1241
- * @param styles - the styles to remove.
1242
- */
1243
- removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
1244
- }
1245
-
1246
- /**
1247
- * Transforms a template literal string into a ViewTemplate.
1248
- * @param strings - The string fragments that are interpolated with the values.
1249
- * @param values - The values that are interpolated with the string fragments.
1250
- * @remarks
1251
- * The html helper supports interpolation of strings, numbers, binding expressions,
1252
- * other template instances, and Directive instances.
1253
- * @public
1254
- */
1255
- export declare function html<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent>[]): ViewTemplate<TSource, TParent>;
1256
-
1257
- /**
1258
- * A directive that applies bindings.
1259
- * @public
1260
- */
1261
- export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected {
1262
- dataBinding: Binding;
1263
- private data;
1264
- private updateTarget;
1265
- /**
1266
- * The unique id of the factory.
1267
- */
1268
- id: string;
1269
- /**
1270
- * The structural id of the DOM node to which the created behavior will apply.
1271
- */
1272
- nodeId: string;
1273
- /**
1274
- * The original source aspect exactly as represented in markup.
1275
- */
1276
- sourceAspect: string;
1277
- /**
1278
- * The evaluated target aspect, determined after processing the source.
1279
- */
1280
- targetAspect: string;
1281
- /**
1282
- * The type of aspect to target.
1283
- */
1284
- aspectType: Aspect;
1285
- /**
1286
- * Creates an instance of HTMLBindingDirective.
1287
- * @param dataBinding - The binding configuration to apply.
1288
- */
1289
- constructor(dataBinding: Binding);
1290
- /**
1291
- * Creates HTML to be used within a template.
1292
- * @param add - Can be used to add behavior factories to a template.
1293
- */
1294
- createHTML(add: AddViewBehaviorFactory): string;
1295
- /**
1296
- * Creates a behavior.
1297
- */
1298
- createBehavior(): ViewBehavior;
1299
- /* Excluded from this release type: bindDefault */
1300
- /* Excluded from this release type: bind */
1301
- /* Excluded from this release type: bindContent */
1302
- /* Excluded from this release type: bindEvent */
1303
- /* Excluded from this release type: unbind */
1304
- /* Excluded from this release type: handleEvent */
1305
- /* Excluded from this release type: handleChange */
1306
- }
1307
-
1308
- /**
1309
- * Instructs the template engine to apply behavior to a node.
1310
- * @public
1311
- */
1312
- export declare interface HTMLDirective {
1313
- /**
1314
- * Creates HTML to be used within a template.
1315
- * @param add - Can be used to add behavior factories to a template.
1316
- */
1317
- createHTML(add: AddViewBehaviorFactory): string;
1318
- }
1319
-
1320
- /**
1321
- * Instructs the template engine to apply behavior to a node.
1322
- * @public
1323
- */
1324
- export declare const HTMLDirective: Readonly<{
1325
- /**
1326
- * Gets the directive definition associated with the instance.
1327
- * @param instance - The directive instance to retrieve the definition for.
1328
- */
1329
- getForInstance: (object: any) => HTMLDirectiveDefinition<Constructable<HTMLDirective>> | undefined;
1330
- /**
1331
- * Gets the directive definition associated with the specified type.
1332
- * @param type - The directive type to retrieve the definition for.
1333
- */
1334
- getByType: (key: Function) => HTMLDirectiveDefinition<Constructable<HTMLDirective>> | undefined;
1335
- /**
1336
- * Defines an HTMLDirective based on the options.
1337
- * @param type - The type to define as a directive.
1338
- * @param options - Options that specify the directive's application.
1339
- */
1340
- define<TType extends Constructable<HTMLDirective>>(type: TType, options?: PartialHTMLDirectiveDefinition): TType;
1341
- }>;
1342
-
1343
- /**
1344
- * Decorator: Defines an HTMLDirective.
1345
- * @param options - Provides options that specify the directive's application.
1346
- * @public
1347
- */
1348
- export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
1349
-
1350
- /**
1351
- * Defines metadata for an HTMLDirective.
1352
- * @public
1353
- */
1354
- export declare interface HTMLDirectiveDefinition<TType extends Constructable<HTMLDirective> = Constructable<HTMLDirective>> extends Required<PartialHTMLDirectiveDefinition> {
1355
- /**
1356
- * The type that the definition provides metadata for.
1357
- */
1358
- readonly type: TType;
1359
- }
1360
-
1361
- /**
1362
- * The result of a template compilation operation.
1363
- * @public
1364
- */
1365
- export declare interface HTMLTemplateCompilationResult<TSource = any, TParent = any> {
1366
- /**
1367
- * Creates a view instance.
1368
- * @param hostBindingTarget - The host binding target for the view.
1369
- */
1370
- createView(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
1371
- }
1372
-
1373
- /**
1374
- * The standard View implementation, which also implements ElementView and SyntheticView.
1375
- * @public
1376
- */
1377
- export declare class HTMLView<TSource = any, TParent = any> implements ElementView<TSource, TParent>, SyntheticView<TSource, TParent>, ExecutionContext<TParent> {
1378
- private fragment;
1379
- private factories;
1380
- readonly targets: ViewBehaviorTargets;
1381
- private behaviors;
1382
- private unbindables;
1383
- /**
1384
- * The data that the view is bound to.
1385
- */
1386
- source: TSource | null;
1387
- /**
1388
- * Indicates whether the controller is bound.
1389
- */
1390
- isBound: boolean;
1391
- /**
1392
- * Indicates how the source's lifetime relates to the controller's lifetime.
1393
- */
1394
- readonly sourceLifetime: SourceLifetime;
1395
- /**
1396
- * The execution context the view is running within.
1397
- */
1398
- context: ExecutionContext<TParent>;
1399
- /**
1400
- * The index of the current item within a repeat context.
1401
- */
1402
- index: number;
1403
- /**
1404
- * The length of the current collection within a repeat context.
1405
- */
1406
- length: number;
1407
- /**
1408
- * The parent data source within a nested context.
1409
- */
1410
- readonly parent: TParent;
1411
- /**
1412
- * The parent execution context when in nested context scenarios.
1413
- */
1414
- readonly parentContext: ExecutionContext<TParent>;
1415
- /**
1416
- * The current event within an event handler.
1417
- */
1418
- get event(): Event;
1419
- /**
1420
- * Indicates whether the current item within a repeat context
1421
- * has an even index.
1422
- */
1423
- get isEven(): boolean;
1424
- /**
1425
- * Indicates whether the current item within a repeat context
1426
- * has an odd index.
1427
- */
1428
- get isOdd(): boolean;
1429
- /**
1430
- * Indicates whether the current item within a repeat context
1431
- * is the first item in the collection.
1432
- */
1433
- get isFirst(): boolean;
1434
- /**
1435
- * Indicates whether the current item within a repeat context
1436
- * is somewhere in the middle of the collection.
1437
- */
1438
- get isInMiddle(): boolean;
1439
- /**
1440
- * Indicates whether the current item within a repeat context
1441
- * is the last item in the collection.
1442
- */
1443
- get isLast(): boolean;
1444
- /**
1445
- * Returns the typed event detail of a custom event.
1446
- */
1447
- eventDetail<TDetail>(): TDetail;
1448
- /**
1449
- * Returns the typed event target of the event.
1450
- */
1451
- eventTarget<TTarget extends EventTarget>(): TTarget;
1452
- /**
1453
- * The first DOM node in the range of nodes that make up the view.
1454
- */
1455
- firstChild: Node;
1456
- /**
1457
- * The last DOM node in the range of nodes that make up the view.
1458
- */
1459
- lastChild: Node;
1460
- /**
1461
- * Constructs an instance of HTMLView.
1462
- * @param fragment - The html fragment that contains the nodes for this view.
1463
- * @param behaviors - The behaviors to be applied to this view.
1464
- */
1465
- constructor(fragment: DocumentFragment, factories: ReadonlyArray<ViewBehaviorFactory>, targets: ViewBehaviorTargets);
1466
- /**
1467
- * Appends the view's DOM nodes to the referenced node.
1468
- * @param node - The parent node to append the view's DOM nodes to.
1469
- */
1470
- appendTo(node: Node): void;
1471
- /**
1472
- * Inserts the view's DOM nodes before the referenced node.
1473
- * @param node - The node to insert the view's DOM before.
1474
- */
1475
- insertBefore(node: Node): void;
1476
- /**
1477
- * Removes the view's DOM nodes.
1478
- * The nodes are not disposed and the view can later be re-inserted.
1479
- */
1480
- remove(): void;
1481
- /**
1482
- * Removes the view and unbinds its behaviors, disposing of DOM nodes afterward.
1483
- * Once a view has been disposed, it cannot be inserted or bound again.
1484
- */
1485
- dispose(): void;
1486
- onUnbind(behavior: {
1487
- unbind(controller: ViewController<TSource, TParent>): any;
1488
- }): void;
1489
- /**
1490
- * Binds a view's behaviors to its binding source.
1491
- * @param source - The binding source for the view's binding behaviors.
1492
- * @param context - The execution context to run the behaviors within.
1493
- */
1494
- bind(source: TSource, context?: ExecutionContext<TParent>): void;
1495
- /**
1496
- * Unbinds a view's behaviors from its binding source.
1497
- */
1498
- unbind(): void;
1499
- private evaluateUnbindables;
1500
- /**
1501
- * Efficiently disposes of a contiguous range of synthetic view instances.
1502
- * @param views - A contiguous range of views to be disposed.
1503
- */
1504
- static disposeContiguousBatch(views: SyntheticView[]): void;
1505
- }
1506
-
1507
- /**
1508
- * Observes array lengths.
1509
- * @public
1510
- */
1511
- export declare interface LengthObserver extends Subscriber {
1512
- /**
1513
- * The length of the observed array.
1514
- */
1515
- length: number;
1516
- }
1517
-
1518
- /**
1519
- * Enables observing the length of an array.
1520
- * @param array - The array to observe the length of.
1521
- * @returns The length of the array.
1522
- * @public
1523
- */
1524
- export declare function lengthOf<T>(array: readonly T[]): number;
1525
-
1526
- /**
1527
- * Creates an event listener binding.
1528
- * @param binding - The binding to invoke when the event is raised.
1529
- * @param options - Event listener options.
1530
- * @returns A binding configuration.
1531
- * @public
1532
- */
1533
- export declare function listener<T = any>(binding: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
1534
-
1535
- /**
1536
- * Common APIs related to markup generation.
1537
- * @public
1538
- */
1539
- export declare const Markup: Readonly<{
1540
- /**
1541
- * Creates a placeholder string suitable for marking out a location *within*
1542
- * an attribute value or HTML content.
1543
- * @param index - The directive index to create the placeholder for.
1544
- * @remarks
1545
- * Used internally by binding directives.
1546
- */
1547
- interpolation: (id: string) => string;
1548
- /**
1549
- * Creates a placeholder that manifests itself as an attribute on an
1550
- * element.
1551
- * @param attributeName - The name of the custom attribute.
1552
- * @param index - The directive index to create the placeholder for.
1553
- * @remarks
1554
- * Used internally by attribute directives such as `ref`, `slotted`, and `children`.
1555
- */
1556
- attribute: (id: string) => string;
1557
- /**
1558
- * Creates a placeholder that manifests itself as a marker within the DOM structure.
1559
- * @param index - The directive index to create the placeholder for.
1560
- * @remarks
1561
- * Used internally by structural directives such as `repeat`.
1562
- */
1563
- comment: (id: string) => string;
1564
- }>;
1565
-
1566
- /* Excluded from this release type: Mutable */
1567
-
1568
- /**
1569
- * Options for configuring node observation behavior.
1570
- * @public
1571
- */
1572
- export declare interface NodeBehaviorOptions<T = any> {
1573
- /**
1574
- * The property to assign the observed nodes to.
1575
- */
1576
- property: T;
1577
- /**
1578
- * Filters nodes that are synced with the property.
1579
- * Called one time for each element in the array.
1580
- * @param value - The Node that is being inspected.
1581
- * @param index - The index of the node within the array.
1582
- * @param array - The Node array that is being filtered.
1583
- */
1584
- filter?: ElementsFilter;
1585
- }
1586
-
1587
- /**
1588
- * A base class for node observation.
1589
- * @public
1590
- * @remarks
1591
- * Internally used by the SlottedDirective and the ChildrenDirective.
1592
- */
1593
- export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
1594
- private sourceProperty;
1595
- /**
1596
- * Bind this behavior to the source.
1597
- * @param source - The source to bind to.
1598
- * @param context - The execution context that the binding is operating within.
1599
- * @param targets - The targets that behaviors in a view can attach to.
1600
- */
1601
- bind(controller: ViewController): void;
1602
- /**
1603
- * Unbinds this behavior from the source.
1604
- * @param source - The source to unbind from.
1605
- * @param context - The execution context that the binding is operating within.
1606
- * @param targets - The targets that behaviors in a view can attach to.
1607
- */
1608
- unbind(controller: ViewController): void;
1609
- /**
1610
- * Gets the data source for the target.
1611
- * @param target - The target to get the source for.
1612
- * @returns The source.
1613
- */
1614
- protected getSource(target: Node): any;
1615
- /**
1616
- * Updates the source property with the computed nodes.
1617
- * @param source - The source object to assign the nodes property to.
1618
- * @param value - The nodes to assign to the source object property.
1619
- */
1620
- protected updateTarget(source: any, value: ReadonlyArray<any>): void;
1621
- /**
1622
- * Computes the set of nodes that should be assigned to the source property.
1623
- * @param target - The target to compute the nodes for.
1624
- * @returns The computed nodes.
1625
- * @remarks
1626
- * Applies filters if provided.
1627
- */
1628
- protected computeNodes(target: any): Node[];
1629
- /**
1630
- * Begins observation of the nodes.
1631
- * @param target - The target to observe.
1632
- */
1633
- protected abstract observe(target: any): void;
1634
- /**
1635
- * Disconnects observation of the nodes.
1636
- * @param target - The target to unobserve.
1637
- */
1638
- protected abstract disconnect(target: any): void;
1639
- /**
1640
- * Retrieves the raw nodes that should be assigned to the source property.
1641
- * @param target - The target to get the node to.
1642
- */
1643
- protected abstract getNodes(target: any): Node[];
1644
- }
1645
-
1646
- /**
1647
- * Normalizes the input value into a binding.
1648
- * @param value - The value to create the default binding for.
1649
- * @returns A binding configuration for the provided value.
1650
- * @public
1651
- */
1652
- export declare function normalizeBinding<TSource = any, TReturn = any, TParent = any>(value: Expression<TSource, TReturn, TParent> | Binding<TSource, TReturn, TParent> | {}): Binding<TSource, TReturn, TParent>;
1653
-
1654
- /**
1655
- * Provides change notifications for an observed subject.
1656
- * @public
1657
- */
1658
- export declare interface Notifier {
1659
- /**
1660
- * The object that subscribers will receive notifications for.
1661
- */
1662
- readonly subject: any;
1663
- /**
1664
- * Notifies all subscribers, based on the args.
1665
- * @param args - Data passed along to subscribers during notification.
1666
- * @remarks
1667
- * In some implementations, the args may be used to target specific subscribers.
1668
- * This is usually in the case where a propertyName was passed during subscription.
1669
- */
1670
- notify(args: any): void;
1671
- /**
1672
- * Subscribes to notification of changes in an object's state.
1673
- * @param subscriber - The object that is subscribing for change notification.
1674
- * @param propertyToWatch - The name of the property that the subscriber is interested in watching for changes.
1675
- * @remarks
1676
- * Some implementation may or may not require the propertyToWatch.
1677
- */
1678
- subscribe(subscriber: Subscriber, propertyToWatch?: any): void;
1679
- /**
1680
- * Unsubscribes from notification of changes in an object's state.
1681
- * @param subscriber - The object that is unsubscribing from change notification.
1682
- * @param propertyToUnwatch - The name of the property that the subscriber is no longer interested in watching.
1683
- * @remarks
1684
- * Some implementation may or may not require the propertyToUnwatch.
1685
- */
1686
- unsubscribe(subscriber: Subscriber, propertyToUnwatch?: any): void;
1687
- }
1688
-
1689
- /**
1690
- * A {@link ValueConverter} that converts to and from `number` values.
1691
- * @remarks
1692
- * This converter allows for nullable numbers, returning `null` if the
1693
- * input was `null`, `undefined`, or `NaN`.
1694
- * @public
1695
- */
1696
- export declare const nullableNumberConverter: ValueConverter;
1697
-
1698
- /**
1699
- * Common Observable APIs.
1700
- * @public
1701
- */
1702
- export declare const Observable: Readonly<{
1703
- /* Excluded from this release type: setArrayObserverFactory */
1704
- /**
1705
- * Gets a notifier for an object or Array.
1706
- * @param source - The object or Array to get the notifier for.
1707
- */
1708
- getNotifier: <T extends Notifier = Notifier>(source: any) => T;
1709
- /**
1710
- * Records a property change for a source object.
1711
- * @param source - The object to record the change against.
1712
- * @param propertyName - The property to track as changed.
1713
- */
1714
- track(source: unknown, propertyName: string): void;
1715
- /**
1716
- * Notifies watchers that the currently executing property getter or function is volatile
1717
- * with respect to its observable dependencies.
1718
- */
1719
- trackVolatile(): void;
1720
- /**
1721
- * Notifies subscribers of a source object of changes.
1722
- * @param source - the object to notify of changes.
1723
- * @param args - The change args to pass to subscribers.
1724
- */
1725
- notify(source: unknown, args: any): void;
1726
- /**
1727
- * Defines an observable property on an object or prototype.
1728
- * @param target - The target object to define the observable on.
1729
- * @param nameOrAccessor - The name of the property to define as observable;
1730
- * or a custom accessor that specifies the property name and accessor implementation.
1731
- */
1732
- defineProperty(target: {}, nameOrAccessor: string | Accessor): void;
1733
- /**
1734
- * Finds all the observable accessors defined on the target,
1735
- * including its prototype chain.
1736
- * @param target - The target object to search for accessor on.
1737
- */
1738
- getAccessors: (target: {}) => Accessor[];
1739
- /**
1740
- * Creates a {@link ExpressionNotifier} that can watch the
1741
- * provided {@link Expression} for changes.
1742
- * @param binding - The binding to observe.
1743
- * @param initialSubscriber - An initial subscriber to changes in the binding value.
1744
- * @param isVolatileBinding - Indicates whether the binding's dependency list must be re-evaluated on every value evaluation.
1745
- */
1746
- binding<TSource = any, TReturn = any>(binding: Expression<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): ExpressionNotifier<TSource, TReturn, any>;
1747
- /**
1748
- * Determines whether a binding expression is volatile and needs to have its dependency list re-evaluated
1749
- * on every evaluation of the value.
1750
- * @param binding - The binding to inspect.
1751
- */
1752
- isVolatileBinding<TSource_1 = any, TReturn_1 = any>(binding: Expression<TSource_1, TReturn_1, any>): boolean;
1753
- }>;
1754
-
1755
- /**
1756
- * Decorator: Defines an observable property on the target.
1757
- * @param target - The target to define the observable on.
1758
- * @param nameOrAccessor - The property name or accessor to define the observable as.
1759
- * @public
1760
- */
1761
- export declare function observable(target: {}, nameOrAccessor: string | Accessor): void;
1762
-
1763
- /**
1764
- * A record of observable property access.
1765
- * @public
1766
- */
1767
- export declare interface ObservationRecord {
1768
- /**
1769
- * The source object with an observable property that was accessed.
1770
- */
1771
- propertySource: any;
1772
- /**
1773
- * The name of the observable property on {@link ObservationRecord.propertySource} that was accessed.
1774
- */
1775
- propertyName: string;
1776
- }
1777
-
1778
- /**
1779
- * Creates a one time binding
1780
- * @param binding - The binding to refresh when signaled.
1781
- * @returns A binding configuration.
1782
- * @public
1783
- */
1784
- export declare function oneTime<T = any>(binding: Expression<T>): Binding<T>;
1785
-
1786
- /**
1787
- * Common APIs related to content parsing.
1788
- * @public
1789
- */
1790
- export declare const Parser: Readonly<{
1791
- /**
1792
- * Parses text content or HTML attribute content, separating out the static strings
1793
- * from the directives.
1794
- * @param value - The content or attribute string to parse.
1795
- * @param factories - A list of directives to search for in the string.
1796
- * @returns A heterogeneous array of static strings interspersed with
1797
- * directives or null if no directives are found in the string.
1798
- */
1799
- parse(value: string, factories: Record<string, ViewBehaviorFactory>): (string | ViewBehaviorFactory)[] | null;
1800
- }>;
1801
-
1802
- /**
1803
- * Represents metadata configuration for a custom element.
1804
- * @public
1805
- */
1806
- export declare interface PartialFASTElementDefinition {
1807
- /**
1808
- * The name of the custom element.
1809
- */
1810
- readonly name: string;
1811
- /**
1812
- * The template to render for the custom element.
1813
- */
1814
- readonly template?: ElementViewTemplate;
1815
- /**
1816
- * The styles to associate with the custom element.
1817
- */
1818
- readonly styles?: ComposableStyles | ComposableStyles[];
1819
- /**
1820
- * The custom attributes of the custom element.
1821
- */
1822
- readonly attributes?: (AttributeConfiguration | string)[];
1823
- /**
1824
- * Options controlling the creation of the custom element's shadow DOM.
1825
- * @remarks
1826
- * If not provided, defaults to an open shadow root. Provide null
1827
- * to render to the associated template to the light DOM instead.
1828
- */
1829
- readonly shadowOptions?: Partial<ShadowRootOptions> | null;
1830
- /**
1831
- * Options controlling how the custom element is defined with the platform.
1832
- */
1833
- readonly elementOptions?: ElementDefinitionOptions;
1834
- /**
1835
- * The registry to register this component in by default.
1836
- * @remarks
1837
- * If not provided, defaults to the global registry.
1838
- */
1839
- readonly registry?: CustomElementRegistry;
1840
- }
1841
-
1842
- /**
1843
- * Represents metadata configuration for an HTMLDirective.
1844
- * @public
1845
- */
1846
- export declare interface PartialHTMLDirectiveDefinition {
1847
- /**
1848
- * Indicates whether the directive needs access to template contextual information
1849
- * such as the sourceAspect, targetAspect, and aspectType.
1850
- */
1851
- aspected?: boolean;
1852
- }
1853
-
1854
- /**
1855
- * An implementation of Notifier that allows subscribers to be notified
1856
- * of individual property changes on an object.
1857
- * @public
1858
- */
1859
- export declare class PropertyChangeNotifier implements Notifier {
1860
- private subscribers;
1861
- private subjectSubscribers;
1862
- /**
1863
- * The subject that property changes are being notified for.
1864
- */
1865
- readonly subject: any;
1866
- /**
1867
- * Creates an instance of PropertyChangeNotifier for the specified subject.
1868
- * @param subject - The object that subscribers will receive notifications for.
1869
- */
1870
- constructor(subject: any);
1871
- /**
1872
- * Notifies all subscribers, based on the specified property.
1873
- * @param propertyName - The property name, passed along to subscribers during notification.
1874
- */
1875
- notify(propertyName: string): void;
1876
- /**
1877
- * Subscribes to notification of changes in an object's state.
1878
- * @param subscriber - The object that is subscribing for change notification.
1879
- * @param propertyToWatch - The name of the property that the subscriber is interested in watching for changes.
1880
- */
1881
- subscribe(subscriber: Subscriber, propertyToWatch?: string): void;
1882
- /**
1883
- * Unsubscribes from notification of changes in an object's state.
1884
- * @param subscriber - The object that is unsubscribing from change notification.
1885
- * @param propertyToUnwatch - The name of the property that the subscriber is no longer interested in watching.
1886
- */
1887
- unsubscribe(subscriber: Subscriber, propertyToUnwatch?: string): void;
1888
- }
1889
-
1890
- /**
1891
- * A directive that observes the updates a property with a reference to the element.
1892
- * @param propertyName - The name of the property to assign the reference to.
1893
- * @public
1894
- */
1895
- export declare const ref: <TSource = any, TParent = any>(propertyName: keyof TSource & string) => CaptureType<TSource, TParent>;
1896
-
1897
- /**
1898
- * The runtime behavior for template references.
1899
- * @public
1900
- */
1901
- export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
1902
- /**
1903
- * Bind this behavior.
1904
- * @param controller - The view controller that manages the lifecycle of this behavior.
1905
- */
1906
- bind(controller: ViewController): void;
1907
- }
1908
-
1909
- declare const reflectMode = "reflect";
1910
-
1911
- /**
1912
- * A directive that enables list rendering.
1913
- * @param items - The array to render.
1914
- * @param template - The template or a template binding used obtain a template
1915
- * to render for each item in the array.
1916
- * @param options - Options used to turn on special repeat features.
1917
- * @public
1918
- */
1919
- export declare function repeat<TSource = any, TArray extends ReadonlyArray<any> = ReadonlyArray<any>, TParent = any>(items: Expression<TSource, TArray, TParent> | Binding<TSource, TArray, TParent> | ReadonlyArray<any>, template: Expression<TSource, ViewTemplate<any, TSource>> | Binding<TSource, ViewTemplate<any, TSource>> | ViewTemplate<any, TSource>, options?: RepeatOptions): CaptureType<TSource, TParent>;
1920
-
1921
- /**
1922
- * A behavior that renders a template for each item in an array.
1923
- * @public
1924
- */
1925
- export declare class RepeatBehavior<TSource = any> implements ViewBehavior, Subscriber {
1926
- private directive;
1927
- private location;
1928
- private controller;
1929
- private views;
1930
- private template;
1931
- private templateBindingObserver;
1932
- private items;
1933
- private itemsObserver;
1934
- private itemsBindingObserver;
1935
- private bindView;
1936
- /**
1937
- * Creates an instance of RepeatBehavior.
1938
- * @param location - The location in the DOM to render the repeat.
1939
- * @param dataBinding - The array to render.
1940
- * @param isItemsBindingVolatile - Indicates whether the items binding has volatile dependencies.
1941
- * @param templateBinding - The template to render for each item.
1942
- * @param isTemplateBindingVolatile - Indicates whether the template binding has volatile dependencies.
1943
- * @param options - Options used to turn on special repeat features.
1944
- */
1945
- constructor(directive: RepeatDirective);
1946
- /**
1947
- * Bind this behavior.
1948
- * @param controller - The view controller that manages the lifecycle of this behavior.
1949
- */
1950
- bind(controller: ViewController): void;
1951
- /**
1952
- * Unbinds this behavior.
1953
- */
1954
- unbind(): void;
1955
- /**
1956
- * Handles changes in the array, its items, and the repeat template.
1957
- * @param source - The source of the change.
1958
- * @param args - The details about what was changed.
1959
- */
1960
- handleChange(source: any, args: Splice[] | ExpressionObserver): void;
1961
- private observeItems;
1962
- private updateViews;
1963
- private refreshAllViews;
1964
- private unbindAllViews;
1965
- }
1966
-
1967
- /**
1968
- * A directive that configures list rendering.
1969
- * @public
1970
- */
1971
- export declare class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
1972
- readonly dataBinding: Binding<TSource>;
1973
- readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
1974
- readonly options: RepeatOptions;
1975
- /**
1976
- * The unique id of the factory.
1977
- */
1978
- id: string;
1979
- /**
1980
- * The structural id of the DOM node to which the created behavior will apply.
1981
- */
1982
- nodeId: string;
1983
- /**
1984
- * Creates a placeholder string based on the directive's index within the template.
1985
- * @param index - The index of the directive within the template.
1986
- */
1987
- createHTML(add: AddViewBehaviorFactory): string;
1988
- /**
1989
- * Creates an instance of RepeatDirective.
1990
- * @param dataBinding - The binding that provides the array to render.
1991
- * @param templateBinding - The template binding used to obtain a template to render for each item in the array.
1992
- * @param options - Options used to turn on special repeat features.
1993
- */
1994
- constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
1995
- /**
1996
- * Creates a behavior for the provided target node.
1997
- * @param target - The node instance to create the behavior for.
1998
- */
1999
- createBehavior(): RepeatBehavior<TSource>;
2000
- }
2001
-
2002
- /**
2003
- * Options for configuring repeat behavior.
2004
- * @public
2005
- */
2006
- export declare interface RepeatOptions {
2007
- /**
2008
- * Enables index, length, and dependent positioning updates in item templates.
2009
- */
2010
- positioning?: boolean;
2011
- /**
2012
- * Enables view recycling
2013
- */
2014
- recycle?: boolean;
2015
- }
2016
-
2017
- /**
2018
- * Shadow root initialization options.
2019
- * @public
2020
- */
2021
- export declare interface ShadowRootOptions extends ShadowRootInit {
2022
- /**
2023
- * A registry that provides the custom elements visible
2024
- * from within this shadow root.
2025
- * @beta
2026
- */
2027
- registry?: CustomElementRegistry;
2028
- }
2029
-
2030
- /**
2031
- * A directive that observes the `assignedNodes()` of a slot and updates a property
2032
- * whenever they change.
2033
- * @param propertyOrOptions - The options used to configure slotted node observation.
2034
- * @public
2035
- */
2036
- export declare function slotted<TSource = any, TParent = any>(propertyOrOptions: (keyof TSource & string) | SlottedDirectiveOptions<keyof TSource & string>): CaptureType<TSource, TParent>;
2037
-
2038
- /**
2039
- * The runtime behavior for slotted node observation.
2040
- * @public
2041
- */
2042
- export declare class SlottedDirective extends NodeObservationDirective<SlottedDirectiveOptions> {
2043
- /**
2044
- * Begins observation of the nodes.
2045
- * @param target - The target to observe.
2046
- */
2047
- observe(target: EventSource): void;
2048
- /**
2049
- * Disconnects observation of the nodes.
2050
- * @param target - The target to unobserve.
2051
- */
2052
- disconnect(target: EventSource): void;
2053
- /**
2054
- * Retrieves the raw nodes that should be assigned to the source property.
2055
- * @param target - The target to get the node to.
2056
- */
2057
- getNodes(target: HTMLSlotElement): Node[];
2058
- /* Excluded from this release type: handleEvent */
2059
- }
2060
-
2061
- /**
2062
- * The options used to configure slotted node observation.
2063
- * @public
2064
- */
2065
- export declare interface SlottedDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, AssignedNodesOptions {
2066
- }
2067
-
2068
- /**
2069
- * Describes how the source's lifetime relates to its controller's lifetime.
2070
- * @public
2071
- */
2072
- export declare const SourceLifetime: Readonly<{
2073
- /**
2074
- * The source to controller lifetime relationship is unknown.
2075
- */
2076
- readonly unknown: undefined;
2077
- /**
2078
- * The source and controller lifetimes are coupled to one another.
2079
- * They can/will be GC'd together.
2080
- */
2081
- readonly coupled: 1;
2082
- }>;
2083
-
2084
- /**
2085
- * Describes how the source's lifetime relates to its controller's lifetime.
2086
- * @public
2087
- */
2088
- export declare type SourceLifetime = typeof SourceLifetime[keyof typeof SourceLifetime];
2089
-
2090
- /**
2091
- * A splice map is a representation of how a previous array of items
2092
- * was transformed into a new array of items. Conceptually it is a list of
2093
- * tuples of
2094
- *
2095
- * (index, removed, addedCount)
2096
- *
2097
- * which are kept in ascending index order of. The tuple represents that at
2098
- * the |index|, |removed| sequence of items were removed, and counting forward
2099
- * from |index|, |addedCount| items were added.
2100
- * @public
2101
- */
2102
- export declare class Splice {
2103
- index: number;
2104
- removed: any[];
2105
- addedCount: number;
2106
- /**
2107
- * Indicates that this splice represents a complete array reset.
2108
- */
2109
- reset?: boolean;
2110
- /**
2111
- * Creates a splice.
2112
- * @param index - The index that the splice occurs at.
2113
- * @param removed - The items that were removed.
2114
- * @param addedCount - The number of items that were added.
2115
- */
2116
- constructor(index: number, removed: any[], addedCount: number);
2117
- /**
2118
- * Adjusts the splice index based on the provided array.
2119
- * @param array - The array to adjust to.
2120
- * @returns The same splice, mutated based on the reference array.
2121
- */
2122
- adjustTo(array: any[]): this;
2123
- }
2124
-
2125
- /**
2126
- * An approach to tracking changes in an array.
2127
- * @public
2128
- */
2129
- export declare interface SpliceStrategy {
2130
- /**
2131
- * The level of feature support the splice strategy provides.
2132
- */
2133
- readonly support: SpliceStrategySupport;
2134
- /**
2135
- * Normalizes the splices before delivery to array change subscribers.
2136
- * @param previous - The previous version of the array if a reset has taken place.
2137
- * @param current - The current version of the array.
2138
- * @param changes - The set of changes tracked against the array.
2139
- */
2140
- normalize(previous: unknown[] | undefined, current: unknown[], changes: Splice[] | undefined): readonly Splice[];
2141
- /**
2142
- * Performs and tracks a pop operation on an array.
2143
- * @param array - The array to track the change for.
2144
- * @param observer - The observer to register the change with.
2145
- * @param pop - The operation to perform.
2146
- * @param args - The arguments for the operation.
2147
- */
2148
- pop(array: any[], observer: ArrayObserver, pop: typeof Array.prototype.pop, args: any[]): any;
2149
- /**
2150
- * Performs and tracks a push operation on an array.
2151
- * @param array - The array to track the change for.
2152
- * @param observer - The observer to register the change with.
2153
- * @param push - The operation to perform.
2154
- * @param args - The arguments for the operation.
2155
- */
2156
- push(array: any[], observer: ArrayObserver, push: typeof Array.prototype.push, args: any[]): any;
2157
- /**
2158
- * Performs and tracks a reverse operation on an array.
2159
- * @param array - The array to track the change for.
2160
- * @param observer - The observer to register the change with.
2161
- * @param reverse - The operation to perform.
2162
- * @param args - The arguments for the operation.
2163
- */
2164
- reverse(array: any[], observer: ArrayObserver, reverse: typeof Array.prototype.reverse, args: any[]): any;
2165
- /**
2166
- * Performs and tracks a shift operation on an array.
2167
- * @param array - The array to track the change for.
2168
- * @param observer - The observer to register the change with.
2169
- * @param shift - The operation to perform.
2170
- * @param args - The arguments for the operation.
2171
- */
2172
- shift(array: any[], observer: ArrayObserver, shift: typeof Array.prototype.shift, args: any[]): any;
2173
- /**
2174
- * Performs and tracks a sort operation on an array.
2175
- * @param array - The array to track the change for.
2176
- * @param observer - The observer to register the change with.
2177
- * @param sort - The operation to perform.
2178
- * @param args - The arguments for the operation.
2179
- */
2180
- sort(array: any[], observer: ArrayObserver, sort: typeof Array.prototype.sort, args: any[]): any[];
2181
- /**
2182
- * Performs and tracks a splice operation on an array.
2183
- * @param array - The array to track the change for.
2184
- * @param observer - The observer to register the change with.
2185
- * @param splice - The operation to perform.
2186
- * @param args - The arguments for the operation.
2187
- */
2188
- splice(array: any[], observer: ArrayObserver, splice: typeof Array.prototype.splice, args: any[]): any;
2189
- /**
2190
- * Performs and tracks an unshift operation on an array.
2191
- * @param array - The array to track the change for.
2192
- * @param observer - The observer to register the change with.
2193
- * @param unshift - The operation to perform.
2194
- * @param args - The arguments for the operation.
2195
- */
2196
- unshift(array: any[], observer: ArrayObserver, unshift: typeof Array.prototype.unshift, args: any[]): any[];
2197
- }
2198
-
2199
- /**
2200
- * Functionality related to tracking changes in arrays.
2201
- * @public
2202
- */
2203
- export declare const SpliceStrategy: Readonly<{
2204
- /**
2205
- * A set of changes that represent a full array reset.
2206
- */
2207
- readonly reset: Splice[];
2208
- /**
2209
- * Sets the default strategy to use for array observers.
2210
- * @param strategy - The splice strategy to use.
2211
- */
2212
- readonly setDefaultStrategy: (strategy: SpliceStrategy) => void;
2213
- }>;
2214
-
2215
- /**
2216
- * Indicates what level of feature support the splice
2217
- * strategy provides.
2218
- * @public
2219
- */
2220
- export declare const SpliceStrategySupport: Readonly<{
2221
- /**
2222
- * Only supports resets.
2223
- */
2224
- readonly reset: 1;
2225
- /**
2226
- * Supports tracking splices and resets.
2227
- */
2228
- readonly splice: 2;
2229
- /**
2230
- * Supports tracking splices and resets, while applying some form
2231
- * of optimization, such as merging, to the splices.
2232
- */
2233
- readonly optimized: 3;
2234
- }>;
2235
-
2236
- /**
2237
- * The available values for SpliceStrategySupport.
2238
- * @public
2239
- */
2240
- export declare type SpliceStrategySupport = typeof SpliceStrategySupport[keyof typeof SpliceStrategySupport];
2241
-
2242
- /**
2243
- * A base class used for attribute directives that don't need internal state.
2244
- * @public
2245
- */
2246
- export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
2247
- protected options: TOptions;
2248
- /**
2249
- * The unique id of the factory.
2250
- */
2251
- id: string;
2252
- /**
2253
- * The structural id of the DOM node to which the created behavior will apply.
2254
- */
2255
- nodeId: string;
2256
- /**
2257
- * Creates an instance of RefDirective.
2258
- * @param options - The options to use in configuring the directive.
2259
- */
2260
- constructor(options: TOptions);
2261
- /**
2262
- * Creates a placeholder string based on the directive's index within the template.
2263
- * @param index - The index of the directive within the template.
2264
- * @remarks
2265
- * Creates a custom attribute placeholder.
2266
- */
2267
- createHTML(add: AddViewBehaviorFactory): string;
2268
- /**
2269
- * Creates a behavior.
2270
- * @param targets - The targets available for behaviors to be attached to.
2271
- */
2272
- createBehavior(): ViewBehavior;
2273
- /**
2274
- * Bind this behavior.
2275
- * @param controller - The view controller that manages the lifecycle of this behavior.
2276
- */
2277
- abstract bind(controller: ViewController): void;
2278
- }
2279
-
2280
- /**
2281
- * Implemented to provide specific behavior when adding/removing styles
2282
- * for elements.
2283
- * @public
2284
- */
2285
- export declare interface StyleStrategy {
2286
- /**
2287
- * Adds styles to the target.
2288
- * @param target - The target to add the styles to.
2289
- */
2290
- addStylesTo(target: StyleTarget): void;
2291
- /**
2292
- * Removes styles from the target.
2293
- * @param target - The target to remove the styles from.
2294
- */
2295
- removeStylesFrom(target: StyleTarget): void;
2296
- }
2297
-
2298
- /**
2299
- * A node that can be targeted by styles.
2300
- * @public
2301
- */
2302
- export declare interface StyleTarget {
2303
- /**
2304
- * Stylesheets to be adopted by the node.
2305
- */
2306
- adoptedStyleSheets?: CSSStyleSheet[];
2307
- /**
2308
- * Adds styles to the target by appending the styles.
2309
- * @param styles - The styles element to add.
2310
- */
2311
- append(styles: HTMLStyleElement): void;
2312
- /**
2313
- * Removes styles from the target.
2314
- * @param styles - The styles element to remove.
2315
- */
2316
- removeChild(styles: HTMLStyleElement): void;
2317
- /**
2318
- * Returns all element descendants of node that match selectors.
2319
- * @param selectors - The CSS selector to use for the query.
2320
- */
2321
- querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
2322
- }
2323
-
2324
- /**
2325
- * Implemented by objects that are interested in change notifications.
2326
- * @public
2327
- */
2328
- export declare interface Subscriber {
2329
- /**
2330
- * Called when a subject this instance has subscribed to changes.
2331
- * @param subject - The subject of the change.
2332
- * @param args - The event args detailing the change that occurred.
2333
- */
2334
- handleChange(subject: any, args: any): void;
2335
- }
2336
-
2337
- /**
2338
- * An implementation of {@link Notifier} that efficiently keeps track of
2339
- * subscribers interested in a specific change notification on an
2340
- * observable subject.
1049
+ * Registers the `target` class as a singleton dependency; the class will only be created once. Each
1050
+ * consecutive time the dependency is resolved, the same instance will be returned.
1051
+ *
1052
+ * @param target - The class / constructor function to register as a singleton.
1053
+ *
1054
+ * @example
1055
+ * ```ts
1056
+ * @singleton()
1057
+ * class Foo { }
1058
+ * ```
2341
1059
  *
2342
- * @remarks
2343
- * This set is optimized for the most common scenario of 1 or 2 subscribers.
2344
- * With this in mind, it can store a subscriber in an internal field, allowing it to avoid Array#push operations.
2345
- * If the set ever exceeds two subscribers, it upgrades to an array automatically.
2346
- * @public
2347
- */
2348
- export declare class SubscriberSet implements Notifier {
2349
- private sub1;
2350
- private sub2;
2351
- private spillover;
2352
- /**
2353
- * The object that subscribers will receive notifications for.
2354
- */
2355
- readonly subject: any;
2356
- /**
2357
- * Creates an instance of SubscriberSet for the specified subject.
2358
- * @param subject - The subject that subscribers will receive notifications from.
2359
- * @param initialSubscriber - An initial subscriber to changes.
2360
- */
2361
- constructor(subject: any, initialSubscriber?: Subscriber);
2362
- /**
2363
- * Checks whether the provided subscriber has been added to this set.
2364
- * @param subscriber - The subscriber to test for inclusion in this set.
2365
- */
2366
- has(subscriber: Subscriber): boolean;
2367
- /**
2368
- * Subscribes to notification of changes in an object's state.
2369
- * @param subscriber - The object that is subscribing for change notification.
2370
- */
2371
- subscribe(subscriber: Subscriber): void;
2372
- /**
2373
- * Unsubscribes from notification of changes in an object's state.
2374
- * @param subscriber - The object that is unsubscribing from change notification.
2375
- */
2376
- unsubscribe(subscriber: Subscriber): void;
2377
- /**
2378
- * Notifies all subscribers.
2379
- * @param args - Data passed along to subscribers during notification.
2380
- */
2381
- notify(args: any): void;
2382
- }
2383
-
2384
- /**
2385
- * The options used to configure subtree observation.
2386
- * @public
2387
- */
2388
- export declare interface SubtreeDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, Omit<MutationObserverInit, "subtree" | "childList"> {
2389
- /**
2390
- * Indicates that child subtrees should be observed for changes.
2391
- */
2392
- subtree: boolean;
2393
- /**
2394
- * When subtrees are observed, a query selector is required to indicate
2395
- * which of potentially many nodes should be assigned to the property.
2396
- */
2397
- selector: string;
2398
- }
2399
-
2400
- /**
2401
- * A view representing a range of DOM nodes which can be added/removed ad hoc.
2402
- * @public
2403
- */
2404
- export declare interface SyntheticView<TSource = any, TParent = any> extends View<TSource, TParent> {
2405
- /**
2406
- * The first DOM node in the range of nodes that make up the view.
2407
- */
2408
- readonly firstChild: Node;
2409
- /**
2410
- * The last DOM node in the range of nodes that make up the view.
2411
- */
2412
- readonly lastChild: Node;
2413
- /**
2414
- * Inserts the view's DOM nodes before the referenced node.
2415
- * @param node - The node to insert the view's DOM before.
2416
- */
2417
- insertBefore(node: Node): void;
2418
- /**
2419
- * Removes the view's DOM nodes.
2420
- * The nodes are not disposed and the view can later be re-inserted.
2421
- */
2422
- remove(): void;
2423
- }
2424
-
2425
- /**
2426
- * A template capable of rendering views not specifically connected to custom elements.
2427
- * @public
2428
- */
2429
- export declare interface SyntheticViewTemplate<TSource = any, TParent = any> {
2430
- /**
2431
- * Creates a SyntheticView instance based on this template definition.
2432
- */
2433
- create(): SyntheticView<TSource, TParent>;
2434
- }
2435
-
2436
- /**
2437
- * Represents the types of values that can be interpolated into a template.
2438
1060
  * @public
2439
1061
  */
2440
- export declare type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
1062
+ export declare function singleton<T extends Constructable>(target: T & Partial<RegisterSelf<T>>): T & RegisterSelf<T>;
2441
1063
 
2442
- /**
2443
- * Enables working with trusted types.
2444
- * @public
2445
- */
2446
- export declare type TrustedTypes = {
2447
- /**
2448
- * Creates a trusted types policy.
2449
- * @param name - The policy name.
2450
- * @param rules - The policy rules implementation.
2451
- */
2452
- createPolicy(name: string, rules: TrustedTypesPolicy): TrustedTypesPolicy;
2453
- };
1064
+ declare function singletonDecorator<T extends Constructable>(target: T & Partial<RegisterSelf<T>>): T & RegisterSelf<T>;
2454
1065
 
2455
- /**
2456
- * A policy for use with the standard trustedTypes platform API.
2457
- * @public
2458
- */
2459
- export declare type TrustedTypesPolicy = {
2460
- /**
2461
- * Creates trusted HTML.
2462
- * @param html - The HTML to clear as trustworthy.
2463
- */
2464
- createHTML(html: string): string;
1066
+ declare type SingletonOptions = {
1067
+ scoped: boolean;
2465
1068
  };
2466
1069
 
2467
- /* Excluded from this release type: TypeDefinition */
2468
-
2469
- /* Excluded from this release type: TypeRegistry */
2470
-
2471
- /**
2472
- * A work queue used to synchronize writes to the DOM.
2473
- * @public
2474
- */
2475
- export declare interface UpdateQueue {
2476
- /**
2477
- * Schedules DOM update work in the next batch.
2478
- * @param callable - The callable function or object to queue.
2479
- */
2480
- enqueue(callable: Callable): void;
2481
- /**
2482
- * Resolves with the next DOM update.
2483
- */
2484
- next(): Promise<void>;
2485
- /**
2486
- * Immediately processes all work previously scheduled
2487
- * through enqueue.
2488
- * @remarks
2489
- * This also forces next() promises
2490
- * to resolve.
2491
- */
2492
- process(): void;
2493
- /**
2494
- * Sets the update mode used by enqueue.
2495
- * @param isAsync - Indicates whether DOM updates should be asynchronous.
2496
- * @remarks
2497
- * By default, the update mode is asynchronous, since that provides the best
2498
- * performance in the browser. Passing false to setMode will instead cause
2499
- * the queue to be immediately processed for each call to enqueue. However,
2500
- * ordering will still be preserved so that nested tasks do not run until
2501
- * after parent tasks complete.
2502
- */
2503
- setMode(isAsync: boolean): void;
2504
- }
2505
-
2506
- /**
2507
- * The default UpdateQueue.
2508
- * @public
2509
- */
2510
- export declare const Updates: UpdateQueue;
2511
-
2512
- /**
2513
- * Represents objects that can convert values to and from
2514
- * view or model representations.
2515
- * @public
2516
- */
2517
- export declare interface ValueConverter {
2518
- /**
2519
- * Converts a value from its representation in the model, to a representation for the view.
2520
- * @param value - The value to convert to a view representation.
2521
- */
2522
- toView(value: any): any;
2523
- /**
2524
- * Converts a value from its representation in the view, to a representation for the model.
2525
- * @param value - The value to convert to a model representation.
2526
- */
2527
- fromView(value: any): any;
2528
- }
2529
-
2530
- /**
2531
- * Represents a collection of DOM nodes which can be bound to a data source.
2532
- * @public
2533
- */
2534
- export declare interface View<TSource = any, TParent = any> extends Disposable {
2535
- /**
2536
- * The execution context the view is running within.
2537
- */
2538
- readonly context: ExecutionContext<TParent>;
2539
- /**
2540
- * The data that the view is bound to.
2541
- */
2542
- readonly source: TSource | null;
2543
- /**
2544
- * Binds a view's behaviors to its binding source.
2545
- * @param source - The binding source for the view's binding behaviors.
2546
- */
2547
- bind(source: TSource, context?: ExecutionContext<TParent>): void;
2548
- /**
2549
- * Unbinds a view's behaviors from its binding source and context.
2550
- */
2551
- unbind(): void;
2552
- }
2553
-
2554
- /**
2555
- * Represents an object that can contribute behavior to a view.
2556
- * @public
2557
- */
2558
- export declare interface ViewBehavior<TSource = any, TParent = any> {
2559
- /**
2560
- * Bind this behavior.
2561
- * @param controller - The view controller that manages the lifecycle of this behavior.
2562
- */
2563
- bind(controller: ViewController<TSource, TParent>): void;
2564
- }
2565
-
2566
- /**
2567
- * A factory that can create a {@link ViewBehavior} associated with a particular
2568
- * location within a DOM fragment.
2569
- * @public
2570
- */
2571
- export declare interface ViewBehaviorFactory {
2572
- /**
2573
- * The unique id of the factory.
2574
- */
2575
- id: string;
2576
- /**
2577
- * The structural id of the DOM node to which the created behavior will apply.
2578
- */
2579
- nodeId: string;
2580
- /**
2581
- * Creates a behavior.
2582
- */
2583
- createBehavior(): ViewBehavior;
2584
- }
2585
-
2586
- /**
2587
- * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
2588
- * control ViewBehaviors.
2589
- * @public
2590
- */
2591
- export declare interface ViewBehaviorOrchestrator<TSource = any, TParent = any> extends ViewController<TSource, TParent>, HostBehavior<TSource> {
2592
- /**
2593
- *
2594
- * @param nodeId - The structural id of the DOM node to which a behavior will apply.
2595
- * @param target - The DOM node associated with the id.
2596
- */
2597
- addTarget(nodeId: string, target: Node): void;
2598
- /**
2599
- * Adds a behavior.
2600
- * @param behavior - The behavior to add.
2601
- */
2602
- addBehavior(behavior: ViewBehavior): void;
2603
- /**
2604
- * Adds a behavior factory.
2605
- * @param factory - The behavior factory to add.
2606
- * @param target - The target the factory will create behaviors for.
2607
- */
2608
- addBehaviorFactory(factory: ViewBehaviorFactory, target: Node): void;
2609
- }
2610
-
2611
1070
  /**
2612
- * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
2613
- * control ViewBehaviors.
1071
+ * Transforms an object after it is created but before it is returned
1072
+ * to the requestor.
2614
1073
  * @public
2615
1074
  */
2616
- export declare const ViewBehaviorOrchestrator: Readonly<{
2617
- /**
2618
- * Creates a ViewBehaviorOrchestrator.
2619
- * @param source - The source to to associate behaviors with.
2620
- * @returns A ViewBehaviorOrchestrator.
2621
- */
2622
- create<TSource = any, TParent = any>(source: TSource): ViewBehaviorOrchestrator<TSource, TParent>;
2623
- }>;
1075
+ declare type Transformer_2<K> = (instance: Resolved<K>) => Resolved<K>;
1076
+ export { Transformer_2 as Transformer }
2624
1077
 
2625
1078
  /**
2626
- * The target nodes available to a behavior.
1079
+ * Registers the decorated class as a transient dependency; each time the dependency is resolved
1080
+ * a new instance will be created.
1081
+ *
1082
+ * @example
1083
+ * ```ts
1084
+ * @transient()
1085
+ * class Foo { }
1086
+ * ```
1087
+ *
2627
1088
  * @public
2628
1089
  */
2629
- export declare type ViewBehaviorTargets = {
2630
- [id: string]: Node;
2631
- };
1090
+ export declare function transient<T extends Constructable>(): typeof transientDecorator;
2632
1091
 
2633
1092
  /**
2634
- * Controls the lifecycle of a view and provides relevant context.
1093
+ * Registers the `target` class as a transient dependency; each time the dependency is resolved
1094
+ * a new instance will be created.
1095
+ *
1096
+ * @param target - The class / constructor function to register as transient.
1097
+ *
1098
+ * @example
1099
+ * ```ts
1100
+ * @transient()
1101
+ * class Foo { }
1102
+ * ```
1103
+ *
2635
1104
  * @public
2636
1105
  */
2637
- export declare interface ViewController<TSource = any, TParent = any> extends ExpressionController<TSource, TParent> {
2638
- /**
2639
- * The parts of the view that are targeted by view behaviors.
2640
- */
2641
- readonly targets: ViewBehaviorTargets;
2642
- }
1106
+ export declare function transient<T extends Constructable>(target: T & Partial<RegisterSelf<T>>): T & RegisterSelf<T>;
2643
1107
 
2644
- /**
2645
- * A template capable of creating HTMLView instances or rendering directly to DOM.
2646
- * @public
2647
- */
2648
- export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate<TSource, TParent>, SyntheticViewTemplate<TSource, TParent> {
2649
- private result;
2650
- /**
2651
- * The html representing what this template will
2652
- * instantiate, including placeholders for directives.
2653
- */
2654
- readonly html: string | HTMLTemplateElement;
2655
- /**
2656
- * The directives that will be connected to placeholders in the html.
2657
- */
2658
- readonly factories: Record<string, ViewBehaviorFactory>;
2659
- /**
2660
- * Creates an instance of ViewTemplate.
2661
- * @param html - The html representing what this template will instantiate, including placeholders for directives.
2662
- * @param factories - The directives that will be connected to placeholders in the html.
2663
- */
2664
- constructor(html: string | HTMLTemplateElement, factories: Record<string, ViewBehaviorFactory>);
2665
- /**
2666
- * Creates an HTMLView instance based on this template definition.
2667
- * @param hostBindingTarget - The element that host behaviors will be bound to.
2668
- */
2669
- create(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
2670
- /**
2671
- * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
2672
- * @param source - The data source to bind the template to.
2673
- * @param host - The Element where the template will be rendered.
2674
- * @param hostBindingTarget - An HTML element to target the host bindings at if different from the
2675
- * host that the template is being attached to.
2676
- */
2677
- render(source: TSource, host: Node, hostBindingTarget?: Element): HTMLView<TSource, TParent>;
2678
- }
1108
+ declare function transientDecorator<T extends Constructable>(target: T & Partial<RegisterSelf<T>>): T & RegisterSelf<T>;
2679
1109
 
2680
1110
  /**
2681
- * Decorator: Marks a property getter as having volatile observable dependencies.
2682
- * @param target - The target that the property is defined on.
2683
- * @param name - The property name.
2684
- * @param name - The existing descriptor.
1111
+ * An unknown context type.
2685
1112
  * @public
2686
1113
  */
2687
- export declare function volatile(target: {}, name: string | Accessor, descriptor: PropertyDescriptor): PropertyDescriptor;
1114
+ declare type UnknownContext = Context<unknown>;
2688
1115
 
2689
- /**
2690
- * A directive that enables basic conditional rendering in a template.
2691
- * @param condition - The condition to test for rendering.
2692
- * @param templateOrTemplateBinding - The template or a binding that gets
2693
- * the template to render when the condition is true.
2694
- * @public
2695
- */
2696
- export declare function when<TSource = any, TReturn = any, TParent = any>(condition: Expression<TSource, TReturn, TParent> | boolean, templateOrTemplateBinding: SyntheticViewTemplate<TSource, TParent> | Expression<TSource, SyntheticViewTemplate<TSource, TParent>, TParent>): CaptureType<TSource, TParent>;
1116
+ /** @internal */
1117
+ export declare function validateKey(key: any): void;
2697
1118
 
2698
1119
  export { }