@microsoft/fast-element 2.0.0-beta.2 → 2.0.0-beta.20

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 (113) hide show
  1. package/CHANGELOG.json +488 -0
  2. package/CHANGELOG.md +180 -1
  3. package/dist/dts/components/attributes.d.ts +15 -0
  4. package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +74 -28
  5. package/dist/dts/components/fast-definitions.d.ts +41 -9
  6. package/dist/dts/components/fast-element.d.ts +14 -26
  7. package/dist/dts/components/hydration.d.ts +14 -0
  8. package/dist/{esm/observation/behavior.js → dts/components/install-hydration.d.ts} +0 -0
  9. package/dist/dts/context.d.ts +1 -1
  10. package/dist/dts/di/di.d.ts +894 -0
  11. package/dist/dts/dom-policy.d.ts +68 -0
  12. package/dist/dts/dom.d.ts +100 -0
  13. package/dist/dts/index.d.ts +5 -4
  14. package/dist/dts/index.rollup.d.ts +0 -1
  15. package/dist/dts/index.rollup.debug.d.ts +0 -1
  16. package/dist/dts/interfaces.d.ts +60 -79
  17. package/dist/dts/observation/observable.d.ts +99 -54
  18. package/dist/dts/pending-task.d.ts +20 -0
  19. package/dist/dts/platform.d.ts +7 -0
  20. package/dist/dts/polyfills.d.ts +0 -8
  21. package/dist/dts/state/exports.d.ts +3 -0
  22. package/dist/dts/state/reactive.d.ts +8 -0
  23. package/dist/dts/state/state.d.ts +141 -0
  24. package/dist/dts/state/visitor.d.ts +6 -0
  25. package/dist/dts/state/watch.d.ts +10 -0
  26. package/dist/dts/styles/css-directive.d.ts +2 -2
  27. package/dist/dts/styles/css.d.ts +0 -5
  28. package/dist/dts/styles/element-styles.d.ts +10 -17
  29. package/dist/dts/styles/host.d.ts +68 -0
  30. package/dist/dts/styles/style-strategy.d.ts +42 -0
  31. package/dist/dts/templating/binding-signal.d.ts +12 -27
  32. package/dist/dts/templating/binding-two-way.d.ts +22 -37
  33. package/dist/dts/templating/binding.d.ts +76 -208
  34. package/dist/dts/templating/children.d.ts +1 -1
  35. package/dist/dts/templating/compiler.d.ts +11 -13
  36. package/dist/dts/templating/html-directive.d.ts +91 -97
  37. package/dist/dts/templating/node-observation.d.ts +15 -6
  38. package/dist/dts/templating/ref.d.ts +7 -11
  39. package/dist/dts/templating/render.d.ts +296 -0
  40. package/dist/dts/templating/repeat.d.ts +23 -34
  41. package/dist/dts/templating/slotted.d.ts +1 -1
  42. package/dist/dts/templating/template.d.ts +92 -14
  43. package/dist/dts/templating/view.d.ts +81 -11
  44. package/dist/dts/templating/when.d.ts +3 -3
  45. package/dist/dts/testing/exports.d.ts +3 -0
  46. package/dist/dts/testing/fakes.d.ts +14 -0
  47. package/dist/dts/testing/fixture.d.ts +84 -0
  48. package/dist/dts/testing/timeout.d.ts +7 -0
  49. package/dist/dts/utilities.d.ts +53 -18
  50. package/dist/esm/components/attributes.js +28 -5
  51. package/dist/esm/components/{controller.js → element-controller.js} +239 -137
  52. package/dist/esm/components/fast-definitions.js +38 -30
  53. package/dist/esm/components/fast-element.js +27 -16
  54. package/dist/esm/components/hydration.js +35 -0
  55. package/dist/esm/components/install-hydration.js +2 -0
  56. package/dist/esm/context.js +5 -1
  57. package/dist/esm/debug.js +40 -5
  58. package/dist/esm/di/di.js +1430 -0
  59. package/dist/esm/dom-policy.js +337 -0
  60. package/dist/esm/dom.js +101 -0
  61. package/dist/esm/index.js +4 -2
  62. package/dist/esm/index.rollup.debug.js +3 -1
  63. package/dist/esm/index.rollup.js +3 -1
  64. package/dist/esm/interfaces.js +52 -0
  65. package/dist/esm/observation/arrays.js +303 -2
  66. package/dist/esm/observation/observable.js +88 -142
  67. package/dist/esm/observation/update-queue.js +2 -2
  68. package/dist/esm/pending-task.js +16 -0
  69. package/dist/esm/platform.js +27 -2
  70. package/dist/esm/polyfills.js +3 -61
  71. package/dist/esm/state/exports.js +3 -0
  72. package/dist/esm/state/reactive.js +34 -0
  73. package/dist/esm/state/state.js +148 -0
  74. package/dist/esm/state/visitor.js +28 -0
  75. package/dist/esm/state/watch.js +36 -0
  76. package/dist/esm/styles/css.js +4 -9
  77. package/dist/esm/styles/element-styles.js +14 -33
  78. package/dist/esm/styles/host.js +1 -0
  79. package/dist/esm/styles/style-strategy.js +1 -0
  80. package/dist/esm/templating/binding-signal.js +67 -62
  81. package/dist/esm/templating/binding-two-way.js +72 -39
  82. package/dist/esm/templating/binding.js +142 -286
  83. package/dist/esm/templating/children.js +8 -4
  84. package/dist/esm/templating/compiler.js +59 -43
  85. package/dist/esm/templating/html-directive.js +56 -75
  86. package/dist/esm/templating/node-observation.js +20 -13
  87. package/dist/esm/templating/ref.js +4 -12
  88. package/dist/esm/templating/render.js +402 -0
  89. package/dist/esm/templating/repeat.js +88 -75
  90. package/dist/esm/templating/template.js +132 -60
  91. package/dist/esm/templating/view.js +113 -29
  92. package/dist/esm/templating/when.js +5 -4
  93. package/dist/esm/testing/exports.js +3 -0
  94. package/dist/esm/testing/fakes.js +107 -0
  95. package/dist/esm/testing/fixture.js +86 -0
  96. package/dist/esm/testing/timeout.js +24 -0
  97. package/dist/esm/utilities.js +95 -95
  98. package/dist/fast-element.api.json +9487 -8326
  99. package/dist/fast-element.d.ts +847 -644
  100. package/dist/fast-element.debug.js +1993 -1166
  101. package/dist/fast-element.debug.min.js +1 -1
  102. package/dist/fast-element.js +1903 -1111
  103. package/dist/fast-element.min.js +1 -1
  104. package/dist/fast-element.untrimmed.d.ts +911 -701
  105. package/docs/api-report.md +329 -252
  106. package/package.json +38 -16
  107. package/dist/dts/hooks.d.ts +0 -20
  108. package/dist/dts/observation/behavior.d.ts +0 -19
  109. package/dist/dts/observation/splice-strategies.d.ts +0 -13
  110. package/dist/dts/templating/dom.d.ts +0 -41
  111. package/dist/esm/hooks.js +0 -32
  112. package/dist/esm/observation/splice-strategies.js +0 -400
  113. package/dist/esm/templating/dom.js +0 -49
@@ -24,7 +24,7 @@ export declare interface Accessor {
24
24
  * Used to add behaviors when constructing styles.
25
25
  * @public
26
26
  */
27
- export declare type AddBehavior = (behavior: Behavior<HTMLElement>) => void;
27
+ export declare type AddBehavior = (behavior: HostBehavior<HTMLElement>) => void;
28
28
 
29
29
  /**
30
30
  * Used to add behavior factories when constructing templates.
@@ -32,20 +32,6 @@ export declare type AddBehavior = (behavior: Behavior<HTMLElement>) => void;
32
32
  */
33
33
  export declare type AddViewBehaviorFactory = (factory: ViewBehaviorFactory) => string;
34
34
 
35
- /**
36
- * https://wicg.github.io/construct-stylesheets/
37
- * https://developers.google.com/web/updates/2019/02/constructable-stylesheets
38
- *
39
- * @internal
40
- */
41
- export declare class AdoptedStyleSheetsStrategy implements StyleStrategy {
42
- /** @internal */
43
- readonly sheets: CSSStyleSheet[];
44
- constructor(styles: (string | CSSStyleSheet)[]);
45
- addStylesTo(target: StyleTarget): void;
46
- removeStylesFrom(target: StyleTarget): void;
47
- }
48
-
49
35
  /**
50
36
  * An observer for arrays.
51
37
  * @public
@@ -90,53 +76,6 @@ export declare const ArrayObserver: Readonly<{
90
76
  readonly enable: () => void;
91
77
  }>;
92
78
 
93
- /**
94
- * The type of HTML aspect to target.
95
- * @public
96
- */
97
- export declare const Aspect: Readonly<{
98
- /**
99
- * Not aspected.
100
- */
101
- readonly none: 0;
102
- /**
103
- * An attribute.
104
- */
105
- readonly attribute: 1;
106
- /**
107
- * A boolean attribute.
108
- */
109
- readonly booleanAttribute: 2;
110
- /**
111
- * A property.
112
- */
113
- readonly property: 3;
114
- /**
115
- * Content
116
- */
117
- readonly content: 4;
118
- /**
119
- * A token list.
120
- */
121
- readonly tokenList: 5;
122
- /**
123
- * An event.
124
- */
125
- readonly event: 6;
126
- /**
127
- *
128
- * @param directive - The directive to assign the aspect to.
129
- * @param value - The value to base the aspect determination on.
130
- */
131
- readonly assign: (directive: Aspected, value: string) => void;
132
- }>;
133
-
134
- /**
135
- * The type of HTML aspect to target.
136
- * @public
137
- */
138
- export declare type Aspect = typeof Aspect[Exclude<keyof typeof Aspect, "assign" | "none">];
139
-
140
79
  /**
141
80
  * Represents something that applies to a specific aspect of the DOM.
142
81
  * @public
@@ -153,11 +92,11 @@ export declare interface Aspected {
153
92
  /**
154
93
  * The type of aspect to target.
155
94
  */
156
- aspectType: Aspect;
95
+ aspectType: DOMAspect;
157
96
  /**
158
97
  * A binding if one is associated with the aspect.
159
98
  */
160
- binding?: Binding;
99
+ dataBinding?: Binding;
161
100
  }
162
101
 
163
102
  /**
@@ -186,6 +125,17 @@ export declare type AttributeConfiguration = {
186
125
  converter?: ValueConverter;
187
126
  };
188
127
 
128
+ /**
129
+ * Metadata used to configure a custom attribute's behavior.
130
+ * @public
131
+ */
132
+ export declare const AttributeConfiguration: Readonly<{
133
+ /**
134
+ * Locates all attribute configurations associated with a type.
135
+ */
136
+ locate: (target: {}) => AttributeConfiguration[];
137
+ }>;
138
+
189
139
  /**
190
140
  * An implementation of {@link Accessor} that supports reactivity,
191
141
  * change callbacks, attribute reflection, and type conversion for
@@ -265,121 +215,41 @@ export declare class AttributeDefinition implements Accessor {
265
215
  export declare type AttributeMode = typeof reflectMode | typeof booleanMode | "fromView";
266
216
 
267
217
  /**
268
- * Represents an object that can contribute behavior to a view or
269
- * element's bind/unbind operations.
270
- * @public
271
- */
272
- export declare interface Behavior<TSource = any, TParent = any> {
273
- /**
274
- * Bind this behavior to the source.
275
- * @param source - The source to bind to.
276
- * @param context - The execution context that the binding is operating within.
277
- */
278
- bind(source: TSource, context: ExecutionContext<TParent>): void;
279
- /**
280
- * Unbinds this behavior from the source.
281
- * @param source - The source to unbind from.
282
- */
283
- unbind(source: TSource, context: ExecutionContext<TParent>): void;
284
- }
285
-
286
- /**
287
- * Creates a binding directive with the specified configuration.
288
- * @param binding - The binding expression.
289
- * @param config - The binding configuration.
290
- * @returns A binding directive.
291
- * @public
292
- */
293
- export declare function bind<T = any>(binding: Binding<T>, config?: BindingConfig | DefaultBindingOptions): CaptureType<T>;
294
-
295
- /**
296
- * The signature of an arrow function capable of being evaluated
297
- * as part of a template binding update.
298
- * @public
299
- */
300
- export declare type Binding<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn;
301
-
302
- /**
303
- * Describes the configuration for a binding expression.
304
- * @public
305
- */
306
- export declare interface BindingConfig<T = any> {
307
- /**
308
- * The binding mode to configure the binding with.
309
- */
310
- mode: BindingMode;
311
- /**
312
- * Options to be supplied to the binding behaviors.
313
- */
314
- options: T;
315
- }
316
-
317
- /**
318
- * Describes the configuration for a binding expression.
218
+ * Creates an standard binding.
219
+ * @param expression - The binding to refresh when changed.
220
+ * @param policy - The security policy to associate with th binding.
221
+ * @param isVolatile - Indicates whether the binding is volatile or not.
222
+ * @returns A binding configuration.
319
223
  * @public
320
224
  */
321
- export declare const BindingConfig: Readonly<{
322
- /**
323
- * Creates a binding configuration based on the provided mode and options.
324
- * @param mode - The mode to use for the configuration.
325
- * @param defaultOptions - The default options to use for the configuration.
326
- * @returns A new binding configuration.
327
- */
328
- define<T>(mode: BindingMode, defaultOptions: T): BindingConfig<T> & BindingConfigResolver<T>;
329
- }>;
225
+ export declare function bind<T = any>(expression: Expression<T>, policy?: DOMPolicy, isVolatile?: boolean): Binding<T>;
330
226
 
331
227
  /**
332
- * Creates a new binding configuration based on the supplied options.
333
- * @public
334
- */
335
- export declare type BindingConfigResolver<T> = (options: T) => BindingConfig<T>;
336
-
337
- /**
338
- * Describes how aspects of an HTML element will be affected by bindings.
339
- * @public
340
- */
341
- export declare type BindingMode = Record<Aspect, (directive: HTMLBindingDirective) => Pick<ViewBehaviorFactory, "createBehavior">>;
342
-
343
- /**
344
- * Describes how aspects of an HTML element will be affected by bindings.
345
- * @public
346
- */
347
- export declare const BindingMode: Readonly<{
348
- /**
349
- * Creates a binding mode based on the supplied behavior types.
350
- * @param UpdateType - The base behavior type used to update aspects.
351
- * @param EventType - The base behavior type used to respond to events.
352
- * @returns A new binding mode.
353
- */
354
- define(UpdateType: typeof UpdateBinding, EventType?: typeof EventBinding): BindingMode;
355
- }>;
356
-
357
- /**
358
- * Enables evaluation of and subscription to a binding.
228
+ * Captures a binding expression along with related information and capabilities.
229
+ *
359
230
  * @public
360
231
  */
361
- export declare interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier, Disposable {
232
+ export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
233
+ evaluate: Expression<TSource, TReturn, TParent>;
234
+ policy?: DOMPolicy | undefined;
235
+ isVolatile: boolean;
362
236
  /**
363
- * Begins observing the binding for the source and returns the current value.
364
- * @param source - The source that the binding is based on.
365
- * @param context - The execution context to execute the binding within.
366
- * @returns The value of the binding.
237
+ * Options associated with the binding.
367
238
  */
368
- observe(source: TSource, context?: ExecutionContext<TParent>): TReturn;
239
+ options?: any;
369
240
  /**
370
- * Gets {@link ObservationRecord|ObservationRecords} that the {@link BindingObserver}
371
- * is observing.
241
+ * Creates a binding.
242
+ * @param evaluate - Evaluates the binding.
243
+ * @param policy - The security policy to associate with this binding.
244
+ * @param isVolatile - Indicates whether the binding is volatile.
372
245
  */
373
- records(): IterableIterator<ObservationRecord>;
246
+ constructor(evaluate: Expression<TSource, TReturn, TParent>, policy?: DOMPolicy | undefined, isVolatile?: boolean);
374
247
  /**
375
- * Sets the update mode used by the observer.
376
- * @param isAsync - Indicates whether updates should be asynchronous.
377
- * @remarks
378
- * By default, the update mode is asynchronous, since that provides the best
379
- * performance for template rendering scenarios. Passing false to setMode will
380
- * instead cause the observer to notify subscribers immediately when changes occur.
248
+ * Creates an observer capable of notifying a subscriber when the output of a binding changes.
249
+ * @param directive - The HTML Directive to create the observer for.
250
+ * @param subscriber - The subscriber to changes in the binding.
381
251
  */
382
- setMode(isAsync: boolean): void;
252
+ abstract createObserver(directive: HTMLDirective, subscriber: Subscriber): ExpressionObserver<TSource, TReturn, TParent>;
383
253
  }
384
254
 
385
255
  /**
@@ -405,44 +275,7 @@ export declare type Callable = typeof Function.prototype.call | {
405
275
  * into templates.
406
276
  * @public
407
277
  */
408
- export declare interface CaptureType<TSource> {
409
- }
410
-
411
- /**
412
- * A binding behavior for bindings that change.
413
- * @public
414
- */
415
- export declare class ChangeBinding extends UpdateBinding {
416
- private isBindingVolatile;
417
- private observerProperty;
418
- /**
419
- * Creates an instance of ChangeBinding.
420
- * @param directive - The directive that has the configuration for this behavior.
421
- * @param updateTarget - The function used to update the target with the latest value.
422
- */
423
- constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
424
- /**
425
- * Returns the binding observer used to update the node.
426
- * @param target - The target node.
427
- * @returns A BindingObserver.
428
- */
429
- protected getObserver(target: Node): BindingObserver;
430
- /**
431
- * Bind this behavior to the source.
432
- * @param source - The source to bind to.
433
- * @param context - The execution context that the binding is operating within.
434
- * @param targets - The targets that behaviors in a view can attach to.
435
- */
436
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
437
- /**
438
- * Unbinds this behavior from the source.
439
- * @param source - The source to unbind from.
440
- * @param context - The execution context that the binding is operating within.
441
- * @param targets - The targets that behaviors in a view can attach to.
442
- */
443
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
444
- /** @internal */
445
- handleChange(binding: Binding, observer: BindingObserver): void;
278
+ export declare interface CaptureType<TSource, TParent> {
446
279
  }
447
280
 
448
281
  /**
@@ -458,7 +291,7 @@ export declare interface ChildListDirectiveOptions<T = any> extends NodeBehavior
458
291
  * @param propertyOrOptions - The options used to configure child node observation.
459
292
  * @public
460
293
  */
461
- export declare function children<T = any>(propertyOrOptions: (keyof T & string) | ChildrenDirectiveOptions<keyof T & string>): CaptureType<T>;
294
+ export declare function children<TSource = any, TParent = any>(propertyOrOptions: (keyof TSource & string) | ChildrenDirectiveOptions<keyof TSource & string>): CaptureType<TSource, TParent>;
462
295
 
463
296
  /**
464
297
  * The runtime behavior for child node observation.
@@ -495,6 +328,17 @@ export declare class ChildrenDirective extends NodeObservationDirective<Children
495
328
  */
496
329
  export declare type ChildrenDirectiveOptions<T = any> = ChildListDirectiveOptions<T> | SubtreeDirectiveOptions<T>;
497
330
 
331
+ /**
332
+ * Represents a constructable class with a prototype.
333
+ * @public
334
+ */
335
+ export declare type Class<T, C = {}> = C & Constructable<T> & {
336
+ /**
337
+ * The class's prototype;
338
+ */
339
+ readonly prototype: T;
340
+ };
341
+
498
342
  /**
499
343
  * A function capable of compiling a template from the preprocessed form produced
500
344
  * by the html template function into a result that can instantiate views.
@@ -508,33 +352,36 @@ html: string | HTMLTemplateElement,
508
352
  /**
509
353
  * The behavior factories used within the html that is being compiled.
510
354
  */
511
- factories: Record<string, ViewBehaviorFactory>) => HTMLTemplateCompilationResult;
355
+ factories: Record<string, ViewBehaviorFactory>,
356
+ /**
357
+ * The security policy to compile the html with.
358
+ */
359
+ policy: DOMPolicy) => HTMLTemplateCompilationResult;
360
+
361
+ /**
362
+ * Represents a ViewBehaviorFactory after the compilation process has completed.
363
+ * @public
364
+ */
365
+ export declare type CompiledViewBehaviorFactory = Required<ViewBehaviorFactory>;
512
366
 
513
367
  /**
514
368
  * Common APIs related to compilation.
515
369
  * @public
516
370
  */
517
371
  export declare const Compiler: {
518
- /**
519
- * Sets the HTML trusted types policy used by the compiler.
520
- * @param policy - The policy to set for HTML.
521
- * @remarks
522
- * This API can only be called once, for security reasons. It should be
523
- * called by the application developer at the start of their program.
524
- */
525
- setHTMLPolicy(policy: TrustedTypesPolicy): void;
526
372
  /**
527
373
  * Compiles a template and associated directives into a compilation
528
374
  * result which can be used to create views.
529
375
  * @param html - The html string or template element to compile.
530
- * @param directives - The directives referenced by the template.
376
+ * @param factories - The behavior factories referenced by the template.
377
+ * @param policy - The security policy to compile the html with.
531
378
  * @remarks
532
379
  * The template that is provided for compilation is altered in-place
533
380
  * and cannot be compiled again. If the original template must be preserved,
534
381
  * it is recommended that you clone the original and pass the clone to this API.
535
382
  * @public
536
383
  */
537
- compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, directives: Record<string, ViewBehaviorFactory>): HTMLTemplateCompilationResult<TSource, TParent>;
384
+ compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, factories: Record<string, ViewBehaviorFactory>, policy?: DOMPolicy): HTMLTemplateCompilationResult<TSource, TParent>;
538
385
  /**
539
386
  * Sets the default compilation strategy that will be used by the ViewTemplate whenever
540
387
  * it needs to compile a view preprocessed with the html template function.
@@ -545,9 +392,10 @@ export declare const Compiler: {
545
392
  * Aggregates an array of strings and directives into a single directive.
546
393
  * @param parts - A heterogeneous array of static strings interspersed with
547
394
  * directives.
395
+ * @param policy - The security policy to use with the aggregated bindings.
548
396
  * @returns A single inline directive that aggregates the behavior of all the parts.
549
397
  */
550
- aggregate(parts: (string | ViewBehaviorFactory)[]): ViewBehaviorFactory;
398
+ aggregate(parts: (string | ViewBehaviorFactory)[], policy?: DOMPolicy): ViewBehaviorFactory;
551
399
  };
552
400
 
553
401
  /**
@@ -556,8 +404,12 @@ export declare const Compiler: {
556
404
  */
557
405
  export declare type ComposableStyles = string | ElementStyles | CSSStyleSheet;
558
406
 
407
+ declare function compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(this: TType, nameOrDef: string | PartialFASTElementDefinition): FASTElementDefinition<TType>;
408
+
409
+ declare function compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType>;
410
+
559
411
  /**
560
- * Allows for the creation of Constructable mixin classes.
412
+ * Represents a type which can be constructed with the new operator.
561
413
  *
562
414
  * @public
563
415
  */
@@ -578,127 +430,51 @@ export declare type ConstructibleStyleStrategy = {
578
430
  };
579
431
 
580
432
  /**
581
- * Controls the lifecycle and rendering of a `FASTElement`.
433
+ * A simple template that can create ContentView instances.
582
434
  * @public
583
435
  */
584
- export declare class Controller<TElement extends HTMLElement = HTMLElement> extends PropertyChangeNotifier {
585
- private boundObservables;
586
- private behaviors;
587
- private needsInitialization;
588
- private hasExistingShadowRoot;
589
- private _template;
590
- private _styles;
591
- private _isConnected;
592
- /**
593
- * This allows Observable.getNotifier(...) to return the Controller
594
- * when the notifier for the Controller itself is being requested. The
595
- * result is that the Observable system does not need to create a separate
596
- * instance of Notifier for observables on the Controller. The component and
597
- * the controller will now share the same notifier, removing one-object construct
598
- * per web component instance.
599
- */
600
- private readonly $fastController;
601
- /**
602
- * The element being controlled by this controller.
603
- */
604
- readonly element: TElement;
605
- /**
606
- * The element definition that instructs this controller
607
- * in how to handle rendering and other platform integrations.
608
- */
609
- readonly definition: FASTElementDefinition;
610
- /**
611
- * The view associated with the custom element.
612
- * @remarks
613
- * If `null` then the element is managing its own rendering.
614
- */
615
- readonly view: ElementView<TElement> | null;
616
- /**
617
- * Indicates whether or not the custom element has been
618
- * connected to the document.
619
- */
620
- get isConnected(): boolean;
621
- private setIsConnected;
622
- /**
623
- * Gets/sets the template used to render the component.
624
- * @remarks
625
- * This value can only be accurately read after connect but can be set at any time.
626
- */
627
- get template(): ElementViewTemplate<TElement> | null;
628
- set template(value: ElementViewTemplate<TElement> | null);
629
- /**
630
- * Gets/sets the primary styles used for the component.
631
- * @remarks
632
- * This value can only be accurately read after connect but can be set at any time.
633
- */
634
- get styles(): ElementStyles | null;
635
- set styles(value: ElementStyles | null);
636
- /**
637
- * Creates a Controller to control the specified element.
638
- * @param element - The element to be controlled by this controller.
639
- * @param definition - The element definition metadata that instructs this
640
- * controller in how to handle rendering and other platform integrations.
641
- * @internal
642
- */
643
- constructor(element: TElement, definition: FASTElementDefinition);
436
+ export declare interface ContentTemplate {
644
437
  /**
645
- * Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
646
- * @param styles - The styles to add.
438
+ * Creates a simple content view instance.
647
439
  */
648
- addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
649
- /**
650
- * Removes styles from this element. Providing an HTMLStyleElement will detach the element instance from the shadowRoot.
651
- * @param styles - the styles to remove.
652
- */
653
- removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
654
- /**
655
- * Adds behaviors to this element.
656
- * @param behaviors - The behaviors to add.
657
- */
658
- addBehaviors(behaviors: ReadonlyArray<Behavior<TElement>>): void;
659
- /**
660
- * Removes behaviors from this element.
661
- * @param behaviors - The behaviors to remove.
662
- * @param force - Forces unbinding of behaviors.
663
- */
664
- removeBehaviors(behaviors: ReadonlyArray<Behavior<TElement>>, force?: boolean): void;
665
- /**
666
- * Runs connected lifecycle behavior on the associated element.
667
- */
668
- onConnectedCallback(): void;
440
+ create(): ContentView;
441
+ }
442
+
443
+ /**
444
+ * A simple View that can be interpolated into HTML content.
445
+ * @public
446
+ */
447
+ export declare interface ContentView {
448
+ readonly context: ExecutionContext;
669
449
  /**
670
- * Runs disconnected lifecycle behavior on the associated element.
450
+ * Binds a view's behaviors to its binding source.
451
+ * @param source - The binding source for the view's binding behaviors.
452
+ * @param context - The execution context to run the view within.
671
453
  */
672
- onDisconnectedCallback(): void;
454
+ bind(source: any, context?: ExecutionContext): void;
673
455
  /**
674
- * Runs the attribute changed callback for the associated element.
675
- * @param name - The name of the attribute that changed.
676
- * @param oldValue - The previous value of the attribute.
677
- * @param newValue - The new value of the attribute.
456
+ * Unbinds a view's behaviors from its binding source and context.
678
457
  */
679
- onAttributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
458
+ unbind(): void;
680
459
  /**
681
- * Emits a custom HTML event.
682
- * @param type - The type name of the event.
683
- * @param detail - The event detail object to send with the event.
684
- * @param options - The event options. By default bubbles and composed.
685
- * @remarks
686
- * Only emits events if connected.
460
+ * Inserts the view's DOM nodes before the referenced node.
461
+ * @param node - The node to insert the view's DOM before.
687
462
  */
688
- emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean;
689
- private finishInitialization;
690
- private renderTemplate;
463
+ insertBefore(node: Node): void;
691
464
  /**
692
- * Locates or creates a controller for the specified element.
693
- * @param element - The element to return the controller for.
694
- * @remarks
695
- * The specified element must have a {@link FASTElementDefinition}
696
- * registered either through the use of the {@link customElement}
697
- * decorator or a call to `FASTElement.define`.
465
+ * Removes the view's DOM nodes.
466
+ * The nodes are not disposed and the view can later be re-inserted.
698
467
  */
699
- static forCustomElement(element: HTMLElement): Controller;
468
+ remove(): void;
700
469
  }
701
470
 
471
+ /**
472
+ * Creates a function capable of locating metadata associated with a type.
473
+ * @returns A metadata locator function.
474
+ * @internal
475
+ */
476
+ export declare function createMetadataLocator<TMetadata>(): (target: {}) => TMetadata[];
477
+
702
478
  /**
703
479
  * Do not change. Part of shared kernel contract.
704
480
  * @internal
@@ -768,12 +544,6 @@ export declare interface CSSDirectiveDefinition<TType extends Constructable<CSSD
768
544
  readonly type: TType;
769
545
  }
770
546
 
771
- /**
772
- * @deprecated Use css.partial instead.
773
- * @public
774
- */
775
- export declare const cssPartial: (strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => CSSDirective;
776
-
777
547
  /**
778
548
  * Transforms a template literal string into styles.
779
549
  * @param strings - The string fragments that are interpolated with the values.
@@ -807,63 +577,269 @@ export declare function customElement(nameOrDef: string | PartialFASTElementDefi
807
577
  */
808
578
  export declare type DecoratorAttributeConfiguration = Omit<AttributeConfiguration, "property">;
809
579
 
580
+ declare function define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(this: TType, nameOrDef: string | PartialFASTElementDefinition): TType;
581
+
582
+ declare function define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType;
583
+
810
584
  /**
811
- * The default binding options.
585
+ * Provides a mechanism for releasing resources.
812
586
  * @public
813
587
  */
814
- export declare type DefaultBindingOptions = AddEventListenerOptions;
588
+ export declare interface Disposable {
589
+ /**
590
+ * Disposes the resources.
591
+ */
592
+ dispose(): void;
593
+ }
815
594
 
816
595
  /**
817
- * Provides a mechanism for releasing resources.
596
+ * Common DOM APIs.
818
597
  * @public
819
598
  */
820
- export declare interface Disposable {
599
+ export declare const DOM: Readonly<{
600
+ /**
601
+ * Gets the dom policy used by the templating system.
602
+ */
603
+ readonly policy: DOMPolicy;
604
+ /**
605
+ * Sets the dom policy used by the templating system.
606
+ * @param policy - The policy to set.
607
+ * @remarks
608
+ * This API can only be called once, for security reasons. It should be
609
+ * called by the application developer at the start of their program.
610
+ */
611
+ setPolicy(value: DOMPolicy): void;
612
+ /**
613
+ * Sets an attribute value on an element.
614
+ * @param element - The element to set the attribute value on.
615
+ * @param attributeName - The attribute name to set.
616
+ * @param value - The value of the attribute to set.
617
+ * @remarks
618
+ * If the value is `null` or `undefined`, the attribute is removed, otherwise
619
+ * it is set to the provided value using the standard `setAttribute` API.
620
+ */
621
+ setAttribute(element: HTMLElement, attributeName: string, value: any): void;
622
+ /**
623
+ * Sets a boolean attribute value.
624
+ * @param element - The element to set the boolean attribute value on.
625
+ * @param attributeName - The attribute name to set.
626
+ * @param value - The value of the attribute to set.
627
+ * @remarks
628
+ * If the value is true, the attribute is added; otherwise it is removed.
629
+ */
630
+ setBooleanAttribute(element: HTMLElement, attributeName: string, value: boolean): void;
631
+ }>;
632
+
633
+ /**
634
+ * The type of HTML aspect to target.
635
+ * @public
636
+ */
637
+ export declare const DOMAspect: Readonly<{
638
+ /**
639
+ * Not aspected.
640
+ */
641
+ readonly none: 0;
642
+ /**
643
+ * An attribute.
644
+ */
645
+ readonly attribute: 1;
646
+ /**
647
+ * A boolean attribute.
648
+ */
649
+ readonly booleanAttribute: 2;
650
+ /**
651
+ * A property.
652
+ */
653
+ readonly property: 3;
654
+ /**
655
+ * Content
656
+ */
657
+ readonly content: 4;
658
+ /**
659
+ * A token list.
660
+ */
661
+ readonly tokenList: 5;
662
+ /**
663
+ * An event.
664
+ */
665
+ readonly event: 6;
666
+ }>;
667
+
668
+ /**
669
+ * The type of HTML aspect to target.
670
+ * @public
671
+ */
672
+ export declare type DOMAspect = typeof DOMAspect[Exclude<keyof typeof DOMAspect, "none">];
673
+
674
+ /**
675
+ * A security policy that FAST can use to interact with the DOM.
676
+ * @public
677
+ */
678
+ export declare interface DOMPolicy {
679
+ /**
680
+ * Creates safe HTML from the provided value.
681
+ * @param value - The source to convert to safe HTML.
682
+ */
683
+ createHTML(value: string): string;
684
+ /**
685
+ * Protects a DOM sink that intends to write to the DOM.
686
+ * @param tagName - The tag name for the element to write to.
687
+ * @param aspect - The aspect of the DOM to write to.
688
+ * @param aspectName - The name of the aspect to write to.
689
+ * @param sink - The sink that is used to write to the DOM.
690
+ */
691
+ protect(tagName: string | null, aspect: DOMAspect, aspectName: string, sink: DOMSink): DOMSink;
692
+ }
693
+
694
+ /**
695
+ * A function used to send values to a DOM sink.
696
+ * @public
697
+ */
698
+ export declare type DOMSink = (target: Node, aspectName: string, value: any, ...args: any[]) => void;
699
+
700
+ /**
701
+ * Controls the lifecycle and rendering of a `FASTElement`.
702
+ * @public
703
+ */
704
+ export declare class ElementController<TElement extends HTMLElement = HTMLElement> extends PropertyChangeNotifier implements HostController<TElement> {
705
+ private boundObservables;
706
+ private needsInitialization;
707
+ private hasExistingShadowRoot;
708
+ private _template;
709
+ private stage;
710
+ /**
711
+ * A guard against connecting behaviors multiple times
712
+ * during connect in scenarios where a behavior adds
713
+ * another behavior during it's connectedCallback
714
+ */
715
+ private guardBehaviorConnection;
716
+ private behaviors;
717
+ private _mainStyles;
718
+ /**
719
+ * This allows Observable.getNotifier(...) to return the Controller
720
+ * when the notifier for the Controller itself is being requested. The
721
+ * result is that the Observable system does not need to create a separate
722
+ * instance of Notifier for observables on the Controller. The component and
723
+ * the controller will now share the same notifier, removing one-object construct
724
+ * per web component instance.
725
+ */
726
+ private readonly $fastController;
727
+ /**
728
+ * The element being controlled by this controller.
729
+ */
730
+ readonly source: TElement;
731
+ /**
732
+ * The element definition that instructs this controller
733
+ * in how to handle rendering and other platform integrations.
734
+ */
735
+ readonly definition: FASTElementDefinition;
736
+ /**
737
+ * The view associated with the custom element.
738
+ * @remarks
739
+ * If `null` then the element is managing its own rendering.
740
+ */
741
+ readonly view: ElementView<TElement> | null;
742
+ /**
743
+ * Indicates whether or not the custom element has been
744
+ * connected to the document.
745
+ */
746
+ get isConnected(): boolean;
747
+ /**
748
+ * Gets/sets the template used to render the component.
749
+ * @remarks
750
+ * This value can only be accurately read after connect but can be set at any time.
751
+ */
752
+ get template(): ElementViewTemplate<TElement> | null;
753
+ set template(value: ElementViewTemplate<TElement> | null);
754
+ /**
755
+ * The main set of styles used for the component, independent
756
+ * of any dynamically added styles.
757
+ */
758
+ get mainStyles(): ElementStyles | null;
759
+ set mainStyles(value: ElementStyles | null);
821
760
  /**
822
- * Disposes the resources.
761
+ * Creates a Controller to control the specified element.
762
+ * @param element - The element to be controlled by this controller.
763
+ * @param definition - The element definition metadata that instructs this
764
+ * controller in how to handle rendering and other platform integrations.
765
+ * @internal
823
766
  */
824
- dispose(): void;
825
- }
826
-
827
- /**
828
- * Common DOM APIs.
829
- * @public
830
- */
831
- export declare const DOM: Readonly<{
767
+ constructor(element: TElement, definition: FASTElementDefinition);
768
+ /**
769
+ * Adds the behavior to the component.
770
+ * @param behavior - The behavior to add.
771
+ */
772
+ addBehavior(behavior: HostBehavior<TElement>): void;
832
773
  /**
833
- * @deprecated
834
- * Use Updates.enqueue().
774
+ * Removes the behavior from the component.
775
+ * @param behavior - The behavior to remove.
776
+ * @param force - Forces removal even if this behavior was added more than once.
835
777
  */
836
- queueUpdate: (callable: Callable) => void;
778
+ removeBehavior(behavior: HostBehavior<TElement>, force?: boolean): void;
837
779
  /**
838
- * @deprecated
839
- * Use Updates.next()
780
+ * Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
781
+ * @param styles - The styles to add.
840
782
  */
841
- nextUpdate: () => Promise<void>;
783
+ addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
842
784
  /**
843
- * @deprecated
844
- * Use Updates.process()
785
+ * Removes styles from this element. Providing an HTMLStyleElement will detach the element instance from the shadowRoot.
786
+ * @param styles - the styles to remove.
845
787
  */
846
- processUpdates: () => void;
788
+ removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
847
789
  /**
848
- * Sets an attribute value on an element.
849
- * @param element - The element to set the attribute value on.
850
- * @param attributeName - The attribute name to set.
851
- * @param value - The value of the attribute to set.
790
+ * Runs connected lifecycle behavior on the associated element.
791
+ */
792
+ connect(): void;
793
+ /**
794
+ * Runs disconnected lifecycle behavior on the associated element.
795
+ */
796
+ disconnect(): void;
797
+ /**
798
+ * Runs the attribute changed callback for the associated element.
799
+ * @param name - The name of the attribute that changed.
800
+ * @param oldValue - The previous value of the attribute.
801
+ * @param newValue - The new value of the attribute.
802
+ */
803
+ onAttributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
804
+ /**
805
+ * Emits a custom HTML event.
806
+ * @param type - The type name of the event.
807
+ * @param detail - The event detail object to send with the event.
808
+ * @param options - The event options. By default bubbles and composed.
852
809
  * @remarks
853
- * If the value is `null` or `undefined`, the attribute is removed, otherwise
854
- * it is set to the provided value using the standard `setAttribute` API.
810
+ * Only emits events if connected.
855
811
  */
856
- setAttribute(element: HTMLElement, attributeName: string, value: any): void;
812
+ emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean;
857
813
  /**
858
- * Sets a boolean attribute value.
859
- * @param element - The element to set the boolean attribute value on.
860
- * @param attributeName - The attribute name to set.
861
- * @param value - The value of the attribute to set.
814
+ * Opts out of JSON stringification.
815
+ * @internal
816
+ */
817
+ toJSON: () => undefined;
818
+ private renderTemplate;
819
+ /**
820
+ * Locates or creates a controller for the specified element.
821
+ * @param element - The element to return the controller for.
862
822
  * @remarks
863
- * If the value is true, the attribute is added; otherwise it is removed.
823
+ * The specified element must have a {@link FASTElementDefinition}
824
+ * registered either through the use of the {@link customElement}
825
+ * decorator or a call to `FASTElement.define`.
864
826
  */
865
- setBooleanAttribute(element: HTMLElement, attributeName: string, value: boolean): void;
866
- }>;
827
+ static forCustomElement(element: HTMLElement): ElementController;
828
+ /**
829
+ * Sets the strategy that ElementController.forCustomElement uses to construct
830
+ * ElementController instances for an element.
831
+ * @param strategy - The strategy to use.
832
+ */
833
+ static setStrategy(strategy: ElementControllerStrategy): void;
834
+ }
835
+
836
+ /**
837
+ * A type that instantiates an ElementController
838
+ * @public
839
+ */
840
+ export declare interface ElementControllerStrategy {
841
+ new (element: HTMLElement, definition: FASTElementDefinition): ElementController;
842
+ }
867
843
 
868
844
  /**
869
845
  * Creates a function that can be used to filter a Node array, selecting only elements.
@@ -877,7 +853,7 @@ export declare const elements: (selector?: string) => ElementsFilter;
877
853
  *
878
854
  * @public
879
855
  */
880
- export declare type ElementsFilter = (value: Node, index: number, array: Node[]) => boolean;
856
+ export declare type ElementsFilter = (value: Node, index?: number, array?: Node[]) => boolean;
881
857
 
882
858
  /**
883
859
  * Represents styles that can be applied to a custom element.
@@ -890,7 +866,7 @@ export declare class ElementStyles {
890
866
  /**
891
867
  * The behaviors associated with this set of styles.
892
868
  */
893
- readonly behaviors: ReadonlyArray<Behavior<HTMLElement>> | null;
869
+ readonly behaviors: ReadonlyArray<HostBehavior<HTMLElement>> | null;
894
870
  /**
895
871
  * Gets the StyleStrategy associated with these element styles.
896
872
  */
@@ -910,7 +886,7 @@ export declare class ElementStyles {
910
886
  * Associates behaviors with this set of styles.
911
887
  * @param behaviors - The behaviors to associate.
912
888
  */
913
- withBehaviors(...behaviors: Behavior<HTMLElement>[]): this;
889
+ withBehaviors(...behaviors: HostBehavior<HTMLElement>[]): this;
914
890
  /**
915
891
  * Sets the strategy that handles adding/removing these styles for an element.
916
892
  * @param strategy - The strategy to use.
@@ -921,6 +897,12 @@ export declare class ElementStyles {
921
897
  * @param Strategy - The strategy type to construct.
922
898
  */
923
899
  static setDefaultStrategy(Strategy: ConstructibleStyleStrategy): void;
900
+ /**
901
+ * Normalizes a set of composable style options.
902
+ * @param styles - The style options to normalize.
903
+ * @returns A singular ElementStyles instance or undefined.
904
+ */
905
+ static normalize(styles: ComposableStyles | ComposableStyles[] | undefined): ElementStyles | undefined;
924
906
  /**
925
907
  * Indicates whether the DOM supports the adoptedStyleSheets feature.
926
908
  */
@@ -968,53 +950,11 @@ export declare interface ElementViewTemplate<TSource = any, TParent = any> {
968
950
  */
969
951
  export declare const emptyArray: readonly never[];
970
952
 
971
- /**
972
- * A binding behavior for handling events.
973
- * @public
974
- */
975
- export declare class EventBinding {
976
- readonly directive: HTMLBindingDirective;
977
- private contextProperty;
978
- private sourceProperty;
979
- /**
980
- * Creates an instance of EventBinding.
981
- * @param directive - The directive that has the configuration for this behavior.
982
- */
983
- constructor(directive: HTMLBindingDirective);
984
- /**
985
- * Bind this behavior to the source.
986
- * @param source - The source to bind to.
987
- * @param context - The execution context that the binding is operating within.
988
- * @param targets - The targets that behaviors in a view can attach to.
989
- */
990
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
991
- /**
992
- * Unbinds this behavior from the source.
993
- * @param source - The source to unbind from.
994
- * @param context - The execution context that the binding is operating within.
995
- * @param targets - The targets that behaviors in a view can attach to.
996
- */
997
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
998
- /**
999
- * Creates a behavior.
1000
- * @param targets - The targets available for behaviors to be attached to.
1001
- */
1002
- createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
1003
- /**
1004
- * @internal
1005
- */
1006
- handleEvent(event: Event): void;
1007
- }
1008
-
1009
953
  /**
1010
954
  * Provides additional contextual information available to behaviors and expressions.
1011
955
  * @public
1012
956
  */
1013
- export declare class ExecutionContext<TParentSource = any> {
1014
- /**
1015
- * The default execution context.
1016
- */
1017
- static readonly default: ExecutionContext<any>;
957
+ export declare interface ExecutionContext<TParent = any> {
1018
958
  /**
1019
959
  * The index of the current item within a repeat context.
1020
960
  */
@@ -1026,41 +966,40 @@ export declare class ExecutionContext<TParentSource = any> {
1026
966
  /**
1027
967
  * The parent data source within a nested context.
1028
968
  */
1029
- readonly parent: TParentSource;
969
+ parent: TParent;
1030
970
  /**
1031
971
  * The parent execution context when in nested context scenarios.
1032
972
  */
1033
- readonly parentContext: ExecutionContext<TParentSource>;
1034
- private constructor();
973
+ parentContext: ExecutionContext<TParent>;
1035
974
  /**
1036
975
  * The current event within an event handler.
1037
976
  */
1038
- get event(): Event;
977
+ readonly event: Event;
1039
978
  /**
1040
979
  * Indicates whether the current item within a repeat context
1041
980
  * has an even index.
1042
981
  */
1043
- get isEven(): boolean;
982
+ readonly isEven: boolean;
1044
983
  /**
1045
984
  * Indicates whether the current item within a repeat context
1046
985
  * has an odd index.
1047
986
  */
1048
- get isOdd(): boolean;
987
+ readonly isOdd: boolean;
1049
988
  /**
1050
989
  * Indicates whether the current item within a repeat context
1051
990
  * is the first item in the collection.
1052
991
  */
1053
- get isFirst(): boolean;
992
+ readonly isFirst: boolean;
1054
993
  /**
1055
994
  * Indicates whether the current item within a repeat context
1056
995
  * is somewhere in the middle of the collection.
1057
996
  */
1058
- get isInMiddle(): boolean;
997
+ readonly isInMiddle: boolean;
1059
998
  /**
1060
999
  * Indicates whether the current item within a repeat context
1061
1000
  * is the last item in the collection.
1062
1001
  */
1063
- get isLast(): boolean;
1002
+ readonly isLast: boolean;
1064
1003
  /**
1065
1004
  * Returns the typed event detail of a custom event.
1066
1005
  */
@@ -1069,36 +1008,104 @@ export declare class ExecutionContext<TParentSource = any> {
1069
1008
  * Returns the typed event target of the event.
1070
1009
  */
1071
1010
  eventTarget<TTarget extends EventTarget>(): TTarget;
1011
+ }
1012
+
1013
+ /**
1014
+ * Provides additional contextual information available to behaviors and expressions.
1015
+ * @public
1016
+ */
1017
+ export declare const ExecutionContext: Readonly<{
1018
+ /**
1019
+ * A default execution context.
1020
+ */
1021
+ default: ExecutionContext<any>;
1022
+ /**
1023
+ * Gets the current event.
1024
+ * @returns An event object.
1025
+ */
1026
+ getEvent(): Event | null;
1027
+ /**
1028
+ * Sets the current event.
1029
+ * @param event - An event object.
1030
+ */
1031
+ setEvent(event: Event | null): void;
1032
+ }>;
1033
+
1034
+ /**
1035
+ * The signature of an arrow function capable of being evaluated
1036
+ * against source data and within an execution context.
1037
+ * @public
1038
+ */
1039
+ export declare type Expression<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn;
1040
+
1041
+ /**
1042
+ * Controls the lifecycle of an expression and provides relevant context.
1043
+ * @public
1044
+ */
1045
+ export declare interface ExpressionController<TSource = any, TParent = any> {
1072
1046
  /**
1073
- * Updates the position/size on a context associated with a list item.
1074
- * @param index - The new index of the item.
1075
- * @param length - The new length of the list.
1047
+ * The source the expression is evaluated against.
1076
1048
  */
1077
- updatePosition(index: number, length: number): void;
1049
+ readonly source: TSource;
1078
1050
  /**
1079
- * Creates a new execution context descendent from the current context.
1080
- * @param source - The source for the context if different than the parent.
1081
- * @returns A child execution context.
1051
+ * Indicates how the source's lifetime relates to the controller's lifetime.
1082
1052
  */
1083
- createChildContext<TParentSource>(parentSource: TParentSource): ExecutionContext<TParentSource>;
1053
+ readonly sourceLifetime?: SourceLifetime;
1084
1054
  /**
1085
- * Creates a new execution context descent suitable for use in list rendering.
1086
- * @param item - The list item to serve as the source.
1087
- * @param index - The index of the item in the list.
1088
- * @param length - The length of the list.
1055
+ * The context the expression is evaluated against.
1089
1056
  */
1090
- createItemContext(index: number, length: number): ExecutionContext<TParentSource>;
1057
+ readonly context: ExecutionContext<TParent>;
1091
1058
  /**
1092
- * Sets the event for the current execution context.
1093
- * @param event - The event to set.
1094
- * @internal
1059
+ * Indicates whether the controller is bound.
1060
+ */
1061
+ readonly isBound: boolean;
1062
+ /**
1063
+ * Registers an unbind handler with the controller.
1064
+ * @param behavior - An object to call when the controller unbinds.
1065
+ */
1066
+ onUnbind(behavior: {
1067
+ unbind(controller: ExpressionController<TSource, TParent>): any;
1068
+ }): void;
1069
+ }
1070
+
1071
+ /**
1072
+ * Enables evaluation of and subscription to a binding.
1073
+ * @public
1074
+ */
1075
+ export declare interface ExpressionNotifier<TSource = any, TReturn = any, TParent = any> extends Notifier, ExpressionObserver<TSource, TReturn, TParent>, Disposable {
1076
+ /**
1077
+ * Observes the expression.
1078
+ * @param source - The source for the expression.
1079
+ * @param context - The context for the expression.
1080
+ */
1081
+ observe(source: TSource, context?: ExecutionContext): TReturn;
1082
+ /**
1083
+ * Gets {@link ObservationRecord|ObservationRecords} that the {@link ExpressionNotifier}
1084
+ * is observing.
1085
+ */
1086
+ records(): IterableIterator<ObservationRecord>;
1087
+ /**
1088
+ * Sets the update mode used by the observer.
1089
+ * @param isAsync - Indicates whether updates should be asynchronous.
1090
+ * @remarks
1091
+ * By default, the update mode is asynchronous, since that provides the best
1092
+ * performance for template rendering scenarios. Passing false to setMode will
1093
+ * instead cause the observer to notify subscribers immediately when changes occur.
1095
1094
  */
1096
- static setEvent(event: Event | null): void;
1095
+ setMode(isAsync: boolean): void;
1096
+ }
1097
+
1098
+ /**
1099
+ * Observes an expression for changes.
1100
+ * @public
1101
+ */
1102
+ export declare interface ExpressionObserver<TSource = any, TReturn = any, TParent = any> {
1097
1103
  /**
1098
- * Creates a new root execution context.
1099
- * @returns A new execution context.
1104
+ * Binds the expression to the source.
1105
+ * @param controller - The controller that manages the lifecycle and related
1106
+ * context for the expression.
1100
1107
  */
1101
- static create(): ExecutionContext;
1108
+ bind(controller: ExpressionController<TSource, TParent>): TReturn;
1102
1109
  }
1103
1110
 
1104
1111
  /**
@@ -1116,7 +1123,7 @@ export declare interface FASTElement extends HTMLElement {
1116
1123
  * The underlying controller that handles the lifecycle and rendering of
1117
1124
  * this FASTElement.
1118
1125
  */
1119
- readonly $fastController: Controller;
1126
+ readonly $fastController: ElementController;
1120
1127
  /**
1121
1128
  * Emits a custom HTML event.
1122
1129
  * @param type - The type name of the event.
@@ -1157,29 +1164,11 @@ export declare interface FASTElement extends HTMLElement {
1157
1164
  * static helpers for working with FASTElements.
1158
1165
  * @public
1159
1166
  */
1160
- export declare const FASTElement: (new () => HTMLElement & FASTElement) & {
1161
- /**
1162
- * Creates a new FASTElement base class inherited from the
1163
- * provided base type.
1164
- * @param BaseType - The base element type to inherit from.
1165
- */
1166
- from<TBase extends {
1167
- new (): HTMLElement;
1168
- prototype: HTMLElement;
1169
- }>(BaseType: TBase): new () => InstanceType<TBase> & FASTElement;
1170
- /**
1171
- * Defines a platform custom element based on the provided type and definition.
1172
- * @param type - The custom element type to define.
1173
- * @param nameOrDef - The name of the element to define or a definition object
1174
- * that describes the element to define.
1175
- */
1176
- define<TType extends Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType;
1177
- /**
1178
- * Defines metadata for a FASTElement which can be used to later define the element.
1179
- * IMPORTANT: This API will be renamed to "compose" in a future beta.
1180
- * @public
1181
- */
1182
- metadata<TType_1 extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType_1, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType_1>;
1167
+ export declare const FASTElement: {
1168
+ new (): FASTElement;
1169
+ define: typeof define;
1170
+ compose: typeof compose;
1171
+ from: typeof from;
1183
1172
  };
1184
1173
 
1185
1174
  /**
@@ -1187,7 +1176,7 @@ export declare const FASTElement: (new () => HTMLElement & FASTElement) & {
1187
1176
  * @public
1188
1177
  */
1189
1178
  export declare class FASTElementDefinition<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> {
1190
- private observedAttributes;
1179
+ private platformDefined;
1191
1180
  /**
1192
1181
  * The type this element definition describes.
1193
1182
  */
@@ -1223,18 +1212,16 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
1223
1212
  /**
1224
1213
  * Options controlling the creation of the custom element's shadow DOM.
1225
1214
  */
1226
- readonly shadowOptions?: ShadowRootInit;
1215
+ readonly shadowOptions?: ShadowRootOptions;
1227
1216
  /**
1228
1217
  * Options controlling how the custom element is defined with the platform.
1229
1218
  */
1230
- readonly elementOptions?: ElementDefinitionOptions;
1219
+ readonly elementOptions: ElementDefinitionOptions;
1231
1220
  /**
1232
- * Creates an instance of FASTElementDefinition.
1233
- * @param type - The type this definition is being created for.
1234
- * @param nameOrConfig - The name of the element to define or a config object
1235
- * that describes the element to define.
1221
+ * The registry to register this component in by default.
1236
1222
  */
1237
- constructor(type: TType, nameOrConfig?: PartialFASTElementDefinition | string);
1223
+ readonly registry: CustomElementRegistry;
1224
+ private constructor();
1238
1225
  /**
1239
1226
  * Defines a custom element based on this definition.
1240
1227
  * @param registry - The element registry to define the element in.
@@ -1242,6 +1229,19 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
1242
1229
  * This operation is idempotent per registry.
1243
1230
  */
1244
1231
  define(registry?: CustomElementRegistry): this;
1232
+ /**
1233
+ * Creates an instance of FASTElementDefinition.
1234
+ * @param type - The type this definition is being created for.
1235
+ * @param nameOrDef - The name of the element to define or a config object
1236
+ * that describes the element to define.
1237
+ */
1238
+ static compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType>;
1239
+ /**
1240
+ * Registers a FASTElement base type.
1241
+ * @param type - The type to register as a base type.
1242
+ * @internal
1243
+ */
1244
+ static registerBaseType(type: Function): void;
1245
1245
  /**
1246
1246
  * Gets the element definition associated with the specified type.
1247
1247
  * @param type - The custom element type to retrieve the definition for.
@@ -1273,22 +1273,96 @@ export declare interface FASTGlobal {
1273
1273
  /**
1274
1274
  * Sends a warning to the developer.
1275
1275
  * @param code - The warning code to send.
1276
- * @param args - Args relevant for the warning.
1276
+ * @param values - Values relevant for the warning message.
1277
1277
  */
1278
- warn(code: number, ...args: any[]): void;
1278
+ warn(code: number, values?: Record<string, any>): void;
1279
1279
  /**
1280
1280
  * Creates an error.
1281
1281
  * @param code - The error code to send.
1282
- * @param args - Args relevant for the error.
1282
+ * @param values - Values relevant for the error message.
1283
1283
  */
1284
- error(code: number, ...args: any[]): Error;
1284
+ error(code: number, values?: Record<string, any>): Error;
1285
1285
  /**
1286
1286
  * Adds debug messages for errors and warnings.
1287
1287
  * @param messages - The message dictionary to add.
1288
+ * @remarks
1289
+ * Message can include placeholders like $\{name\} which can be
1290
+ * replaced by values passed at runtime.
1288
1291
  */
1289
1292
  addMessages(messages: Record<number, string>): void;
1290
1293
  }
1291
1294
 
1295
+ declare function from<TBase extends typeof HTMLElement>(BaseType: TBase): new () => InstanceType<TBase> & FASTElement;
1296
+
1297
+ /**
1298
+ * Represents an object that can contribute behavior to a host.
1299
+ * @public
1300
+ */
1301
+ export declare interface HostBehavior<TSource = any> {
1302
+ /**
1303
+ * Executed when this behavior is attached to a controller.
1304
+ * @param controller - Controls the behavior lifecycle.
1305
+ */
1306
+ addedCallback?(controller: HostController<TSource>): void;
1307
+ /**
1308
+ * Executed when this behavior is detached from a controller.
1309
+ * @param controller - Controls the behavior lifecycle.
1310
+ */
1311
+ removedCallback?(controller: HostController<TSource>): void;
1312
+ /**
1313
+ * Executed when this behavior's host is connected.
1314
+ * @param controller - Controls the behavior lifecycle.
1315
+ */
1316
+ connectedCallback?(controller: HostController<TSource>): void;
1317
+ /**
1318
+ * Executed when this behavior's host is disconnected.
1319
+ * @param controller - Controls the behavior lifecycle.
1320
+ */
1321
+ disconnectedCallback?(controller: HostController<TSource>): void;
1322
+ }
1323
+
1324
+ /**
1325
+ * Controls the lifecycle and context of behaviors and styles
1326
+ * associated with a component host.
1327
+ * @public
1328
+ */
1329
+ export declare interface HostController<TSource = any> {
1330
+ /**
1331
+ * The component source.
1332
+ */
1333
+ readonly source: TSource;
1334
+ /**
1335
+ * Indicates whether the host is connected or not.
1336
+ */
1337
+ readonly isConnected: boolean;
1338
+ /**
1339
+ * The main set of styles used for the component, independent
1340
+ * of any behavior-specific styles.
1341
+ */
1342
+ mainStyles: ElementStyles | null;
1343
+ /**
1344
+ * Adds the behavior to the component.
1345
+ * @param behavior - The behavior to add.
1346
+ */
1347
+ addBehavior(behavior: HostBehavior<TSource>): void;
1348
+ /**
1349
+ * Removes the behavior from the component.
1350
+ * @param behavior - The behavior to remove.
1351
+ * @param force - Forces removal even if this behavior was added more than once.
1352
+ */
1353
+ removeBehavior(behavior: HostBehavior<TSource>, force?: boolean): void;
1354
+ /**
1355
+ * Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
1356
+ * @param styles - The styles to add.
1357
+ */
1358
+ addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
1359
+ /**
1360
+ * Removes styles from this element. Providing an HTMLStyleElement will detach the element instance from the shadowRoot.
1361
+ * @param styles - the styles to remove.
1362
+ */
1363
+ removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
1364
+ }
1365
+
1292
1366
  /**
1293
1367
  * Transforms a template literal string into a ViewTemplate.
1294
1368
  * @param strings - The string fragments that are interpolated with the values.
@@ -1298,17 +1372,16 @@ export declare interface FASTGlobal {
1298
1372
  * other template instances, and Directive instances.
1299
1373
  * @public
1300
1374
  */
1301
- export declare function html<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent>[]): ViewTemplate<TSource, TParent>;
1375
+ export declare const html: HTMLTemplateTag;
1302
1376
 
1303
1377
  /**
1304
1378
  * A directive that applies bindings.
1305
1379
  * @public
1306
1380
  */
1307
- export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, Aspected {
1308
- binding: Binding;
1309
- mode: BindingMode;
1310
- options: any;
1311
- private factory;
1381
+ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected {
1382
+ dataBinding: Binding;
1383
+ private data;
1384
+ private updateTarget;
1312
1385
  /**
1313
1386
  * The unique id of the factory.
1314
1387
  */
@@ -1316,7 +1389,15 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
1316
1389
  /**
1317
1390
  * The structural id of the DOM node to which the created behavior will apply.
1318
1391
  */
1319
- nodeId: string;
1392
+ targetNodeId: string;
1393
+ /**
1394
+ * The tagname associated with the target node.
1395
+ */
1396
+ targetTagName: string | null;
1397
+ /**
1398
+ * The policy that the created behavior must run under.
1399
+ */
1400
+ policy: DOMPolicy;
1320
1401
  /**
1321
1402
  * The original source aspect exactly as represented in markup.
1322
1403
  */
@@ -1328,14 +1409,12 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
1328
1409
  /**
1329
1410
  * The type of aspect to target.
1330
1411
  */
1331
- aspectType: Aspect;
1412
+ aspectType: DOMAspect;
1332
1413
  /**
1333
1414
  * Creates an instance of HTMLBindingDirective.
1334
- * @param binding - The binding to apply.
1335
- * @param mode - The binding mode to use when applying the binding.
1336
- * @param options - The options to configure the binding with.
1415
+ * @param dataBinding - The binding configuration to apply.
1337
1416
  */
1338
- constructor(binding: Binding, mode: BindingMode, options: any);
1417
+ constructor(dataBinding: Binding);
1339
1418
  /**
1340
1419
  * Creates HTML to be used within a template.
1341
1420
  * @param add - Can be used to add behavior factories to a template.
@@ -1343,9 +1422,16 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
1343
1422
  createHTML(add: AddViewBehaviorFactory): string;
1344
1423
  /**
1345
1424
  * Creates a behavior.
1346
- * @param targets - The targets available for behaviors to be attached to.
1347
1425
  */
1348
- createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
1426
+ createBehavior(): ViewBehavior;
1427
+ /** @internal */
1428
+ bind(controller: ViewController): void;
1429
+ /** @internal */
1430
+ unbind(controller: ViewController): void;
1431
+ /** @internal */
1432
+ handleEvent(event: Event): void;
1433
+ /** @internal */
1434
+ handleChange(binding: Expression, observer: ExpressionObserver): void;
1349
1435
  }
1350
1436
 
1351
1437
  /**
@@ -1381,6 +1467,14 @@ export declare const HTMLDirective: Readonly<{
1381
1467
  * @param options - Options that specify the directive's application.
1382
1468
  */
1383
1469
  define<TType extends Constructable<HTMLDirective>>(type: TType, options?: PartialHTMLDirectiveDefinition): TType;
1470
+ /**
1471
+ *
1472
+ * @param directive - The directive to assign the aspect to.
1473
+ * @param value - The value to base the aspect determination on.
1474
+ * @remarks
1475
+ * If a falsy value is provided, then the content aspect will be assigned.
1476
+ */
1477
+ assignAspect(directive: Aspected, value?: string): void;
1384
1478
  }>;
1385
1479
 
1386
1480
  /**
@@ -1407,29 +1501,109 @@ export declare interface HTMLDirectiveDefinition<TType extends Constructable<HTM
1407
1501
  */
1408
1502
  export declare interface HTMLTemplateCompilationResult<TSource = any, TParent = any> {
1409
1503
  /**
1410
- * Creates a view instance.
1411
- * @param hostBindingTarget - The host binding target for the view.
1504
+ * Creates a view instance.
1505
+ * @param hostBindingTarget - The host binding target for the view.
1506
+ */
1507
+ createView(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
1508
+ }
1509
+
1510
+ /**
1511
+ * Transforms a template literal string into a ViewTemplate.
1512
+ * @param strings - The string fragments that are interpolated with the values.
1513
+ * @param values - The values that are interpolated with the string fragments.
1514
+ * @remarks
1515
+ * The html helper supports interpolation of strings, numbers, binding expressions,
1516
+ * other template instances, and Directive instances.
1517
+ * @public
1518
+ */
1519
+ export declare type HTMLTemplateTag = (<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: TemplateValue<TSource, TParent>[]) => ViewTemplate<TSource, TParent>) & {
1520
+ /**
1521
+ * Transforms a template literal string into partial HTML.
1522
+ * @param html - The HTML string fragment to interpolate.
1523
+ * @public
1412
1524
  */
1413
- createView(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
1414
- }
1525
+ partial(html: string): InlineTemplateDirective;
1526
+ };
1415
1527
 
1416
1528
  /**
1417
1529
  * The standard View implementation, which also implements ElementView and SyntheticView.
1418
1530
  * @public
1419
1531
  */
1420
- export declare class HTMLView<TSource = any, TParent = any> implements ElementView<TSource, TParent>, SyntheticView<TSource, TParent> {
1532
+ export declare class HTMLView<TSource = any, TParent = any> implements ElementView<TSource, TParent>, SyntheticView<TSource, TParent>, ExecutionContext<TParent> {
1421
1533
  private fragment;
1422
1534
  private factories;
1423
- private targets;
1535
+ readonly targets: ViewBehaviorTargets;
1424
1536
  private behaviors;
1537
+ private unbindables;
1425
1538
  /**
1426
1539
  * The data that the view is bound to.
1427
1540
  */
1428
1541
  source: TSource | null;
1542
+ /**
1543
+ * Indicates whether the controller is bound.
1544
+ */
1545
+ isBound: boolean;
1546
+ /**
1547
+ * Indicates how the source's lifetime relates to the controller's lifetime.
1548
+ */
1549
+ readonly sourceLifetime: SourceLifetime;
1429
1550
  /**
1430
1551
  * The execution context the view is running within.
1431
1552
  */
1432
- context: ExecutionContext<TParent> | null;
1553
+ context: ExecutionContext<TParent>;
1554
+ /**
1555
+ * The index of the current item within a repeat context.
1556
+ */
1557
+ index: number;
1558
+ /**
1559
+ * The length of the current collection within a repeat context.
1560
+ */
1561
+ length: number;
1562
+ /**
1563
+ * The parent data source within a nested context.
1564
+ */
1565
+ readonly parent: TParent;
1566
+ /**
1567
+ * The parent execution context when in nested context scenarios.
1568
+ */
1569
+ readonly parentContext: ExecutionContext<TParent>;
1570
+ /**
1571
+ * The current event within an event handler.
1572
+ */
1573
+ get event(): Event;
1574
+ /**
1575
+ * Indicates whether the current item within a repeat context
1576
+ * has an even index.
1577
+ */
1578
+ get isEven(): boolean;
1579
+ /**
1580
+ * Indicates whether the current item within a repeat context
1581
+ * has an odd index.
1582
+ */
1583
+ get isOdd(): boolean;
1584
+ /**
1585
+ * Indicates whether the current item within a repeat context
1586
+ * is the first item in the collection.
1587
+ */
1588
+ get isFirst(): boolean;
1589
+ /**
1590
+ * Indicates whether the current item within a repeat context
1591
+ * is somewhere in the middle of the collection.
1592
+ */
1593
+ get isInMiddle(): boolean;
1594
+ /**
1595
+ * Indicates whether the current item within a repeat context
1596
+ * is the last item in the collection.
1597
+ */
1598
+ get isLast(): boolean;
1599
+ /**
1600
+ * Returns the typed event detail of a custom event.
1601
+ */
1602
+ eventDetail<TDetail>(): TDetail;
1603
+ /**
1604
+ * Returns the typed event target of the event.
1605
+ */
1606
+ eventTarget<TTarget extends EventTarget>(): TTarget;
1433
1607
  /**
1434
1608
  * The first DOM node in the range of nodes that make up the view.
1435
1609
  */
@@ -1443,7 +1617,7 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
1443
1617
  * @param fragment - The html fragment that contains the nodes for this view.
1444
1618
  * @param behaviors - The behaviors to be applied to this view.
1445
1619
  */
1446
- constructor(fragment: DocumentFragment, factories: ReadonlyArray<ViewBehaviorFactory>, targets: ViewBehaviorTargets);
1620
+ constructor(fragment: DocumentFragment, factories: ReadonlyArray<CompiledViewBehaviorFactory>, targets: ViewBehaviorTargets);
1447
1621
  /**
1448
1622
  * Appends the view's DOM nodes to the referenced node.
1449
1623
  * @param node - The parent node to append the view's DOM nodes to.
@@ -1464,16 +1638,25 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
1464
1638
  * Once a view has been disposed, it cannot be inserted or bound again.
1465
1639
  */
1466
1640
  dispose(): void;
1641
+ onUnbind(behavior: {
1642
+ unbind(controller: ViewController<TSource, TParent>): any;
1643
+ }): void;
1467
1644
  /**
1468
1645
  * Binds a view's behaviors to its binding source.
1469
1646
  * @param source - The binding source for the view's binding behaviors.
1470
1647
  * @param context - The execution context to run the behaviors within.
1471
1648
  */
1472
- bind(source: TSource, context: ExecutionContext<TParent>): void;
1649
+ bind(source: TSource, context?: ExecutionContext<TParent>): void;
1473
1650
  /**
1474
1651
  * Unbinds a view's behaviors from its binding source.
1475
1652
  */
1476
1653
  unbind(): void;
1654
+ /**
1655
+ * Opts out of JSON stringification.
1656
+ * @internal
1657
+ */
1658
+ toJSON: () => undefined;
1659
+ private evaluateUnbindables;
1477
1660
  /**
1478
1661
  * Efficiently disposes of a contiguous range of synthetic view instances.
1479
1662
  * @param views - A contiguous range of views to be disposed.
@@ -1481,6 +1664,29 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
1481
1664
  static disposeContiguousBatch(views: SyntheticView[]): void;
1482
1665
  }
1483
1666
 
1667
+ /**
1668
+ * Inlines a template into another template.
1669
+ * @public
1670
+ */
1671
+ export declare class InlineTemplateDirective implements HTMLDirective {
1672
+ private html;
1673
+ private factories;
1674
+ /**
1675
+ * An empty template partial.
1676
+ */
1677
+ static readonly empty: InlineTemplateDirective;
1678
+ /**
1679
+ * Creates an instance of InlineTemplateDirective.
1680
+ * @param template - The template to inline.
1681
+ */
1682
+ constructor(html: string, factories?: Record<string, ViewBehaviorFactory>);
1683
+ /**
1684
+ * Creates HTML to be used within a template.
1685
+ * @param add - Can be used to add behavior factories to a template.
1686
+ */
1687
+ createHTML(add: AddViewBehaviorFactory): string;
1688
+ }
1689
+
1484
1690
  /**
1485
1691
  * Observes array lengths.
1486
1692
  * @public
@@ -1500,6 +1706,15 @@ export declare interface LengthObserver extends Subscriber {
1500
1706
  */
1501
1707
  export declare function lengthOf<T>(array: readonly T[]): number;
1502
1708
 
1709
+ /**
1710
+ * Creates an event listener binding.
1711
+ * @param expression - The binding to invoke when the event is raised.
1712
+ * @param options - Event listener options.
1713
+ * @returns A binding configuration.
1714
+ * @public
1715
+ */
1716
+ export declare function listener<T = any>(expression: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
1717
+
1503
1718
  /**
1504
1719
  * Common APIs related to markup generation.
1505
1720
  * @public
@@ -1531,14 +1746,6 @@ export declare const Markup: Readonly<{
1531
1746
  comment: (id: string) => string;
1532
1747
  }>;
1533
1748
 
1534
- /**
1535
- * Reverses all readonly members, making them mutable.
1536
- * @internal
1537
- */
1538
- export declare type Mutable<T> = {
1539
- -readonly [P in keyof T]: T[P];
1540
- };
1541
-
1542
1749
  /**
1543
1750
  * Options for configuring node observation behavior.
1544
1751
  * @public
@@ -1565,21 +1772,31 @@ export declare interface NodeBehaviorOptions<T = any> {
1565
1772
  * Internally used by the SlottedDirective and the ChildrenDirective.
1566
1773
  */
1567
1774
  export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
1568
- private sourceProperty;
1775
+ private _id;
1776
+ private _controllerProperty;
1777
+ /**
1778
+ * The unique id of the factory.
1779
+ */
1780
+ get id(): string;
1781
+ set id(value: string);
1782
+ /**
1783
+ * The structural id of the DOM node to which the created behavior will apply.
1784
+ */
1785
+ targetNodeId: string;
1569
1786
  /**
1570
1787
  * Bind this behavior to the source.
1571
1788
  * @param source - The source to bind to.
1572
1789
  * @param context - The execution context that the binding is operating within.
1573
1790
  * @param targets - The targets that behaviors in a view can attach to.
1574
1791
  */
1575
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
1792
+ bind(controller: ViewController): void;
1576
1793
  /**
1577
1794
  * Unbinds this behavior from the source.
1578
1795
  * @param source - The source to unbind from.
1579
1796
  * @param context - The execution context that the binding is operating within.
1580
1797
  * @param targets - The targets that behaviors in a view can attach to.
1581
1798
  */
1582
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
1799
+ unbind(controller: ViewController): void;
1583
1800
  /**
1584
1801
  * Gets the data source for the target.
1585
1802
  * @param target - The target to get the source for.
@@ -1617,6 +1834,14 @@ export declare abstract class NodeObservationDirective<T extends NodeBehaviorOpt
1617
1834
  protected abstract getNodes(target: any): Node[];
1618
1835
  }
1619
1836
 
1837
+ /**
1838
+ * Normalizes the input value into a binding.
1839
+ * @param value - The value to create the default binding for.
1840
+ * @returns A binding configuration for the provided value.
1841
+ * @public
1842
+ */
1843
+ export declare function normalizeBinding<TSource = any, TReturn = any, TParent = any>(value: Expression<TSource, TReturn, TParent> | Binding<TSource, TReturn, TParent> | {}): Binding<TSource, TReturn, TParent>;
1844
+
1620
1845
  /**
1621
1846
  * Provides change notifications for an observed subject.
1622
1847
  * @public
@@ -1652,6 +1877,12 @@ export declare interface Notifier {
1652
1877
  unsubscribe(subscriber: Subscriber, propertyToUnwatch?: any): void;
1653
1878
  }
1654
1879
 
1880
+ /**
1881
+ * A {@link ValueConverter} that converts to and from `boolean` values. `null`, `undefined`, `""`, and `void` values are converted to `null`.
1882
+ * @public
1883
+ */
1884
+ export declare const nullableBooleanConverter: ValueConverter;
1885
+
1655
1886
  /**
1656
1887
  * A {@link ValueConverter} that converts to and from `number` values.
1657
1888
  * @remarks
@@ -1707,19 +1938,19 @@ export declare const Observable: Readonly<{
1707
1938
  */
1708
1939
  getAccessors: (target: {}) => Accessor[];
1709
1940
  /**
1710
- * Creates a {@link BindingObserver} that can watch the
1711
- * provided {@link Binding} for changes.
1712
- * @param binding - The binding to observe.
1941
+ * Creates a {@link ExpressionNotifier} that can watch the
1942
+ * provided {@link Expression} for changes.
1943
+ * @param expression - The binding to observe.
1713
1944
  * @param initialSubscriber - An initial subscriber to changes in the binding value.
1714
1945
  * @param isVolatileBinding - Indicates whether the binding's dependency list must be re-evaluated on every value evaluation.
1715
1946
  */
1716
- binding<TSource = any, TReturn = any>(binding: Binding<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): BindingObserver<TSource, TReturn, any>;
1947
+ binding<TSource = any, TReturn = any>(expression: Expression<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): ExpressionNotifier<TSource, TReturn, any>;
1717
1948
  /**
1718
1949
  * Determines whether a binding expression is volatile and needs to have its dependency list re-evaluated
1719
1950
  * on every evaluation of the value.
1720
- * @param binding - The binding to inspect.
1951
+ * @param expression - The binding to inspect.
1721
1952
  */
1722
- isVolatileBinding<TSource_1 = any, TReturn_1 = any>(binding: Binding<TSource_1, TReturn_1, any>): boolean;
1953
+ isVolatileBinding<TSource_1 = any, TReturn_1 = any>(expression: Expression<TSource_1, TReturn_1, any>): boolean;
1723
1954
  }>;
1724
1955
 
1725
1956
  /**
@@ -1746,30 +1977,13 @@ export declare interface ObservationRecord {
1746
1977
  }
1747
1978
 
1748
1979
  /**
1749
- * The default onChange binding configuration.
1750
- * @public
1751
- */
1752
- export declare const onChange: BindingConfig<AddEventListenerOptions> & BindingConfigResolver<AddEventListenerOptions>;
1753
-
1754
- /**
1755
- * The default onTime binding configuration.
1756
- * @public
1757
- */
1758
- export declare const oneTime: BindingConfig<AddEventListenerOptions> & BindingConfigResolver<AddEventListenerOptions>;
1759
-
1760
- /**
1761
- * A binding behavior for one-time bindings.
1980
+ * Creates a one time binding
1981
+ * @param expression - The binding to refresh when signaled.
1982
+ * @param policy - The security policy to associate with th binding.
1983
+ * @returns A binding configuration.
1762
1984
  * @public
1763
1985
  */
1764
- export declare class OneTimeBinding extends UpdateBinding {
1765
- /**
1766
- * Bind this behavior to the source.
1767
- * @param source - The source to bind to.
1768
- * @param context - The execution context that the binding is operating within.
1769
- * @param targets - The targets that behaviors in a view can attach to.
1770
- */
1771
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
1772
- }
1986
+ export declare function oneTime<T = any>(expression: Expression<T>, policy?: DOMPolicy): Binding<T>;
1773
1987
 
1774
1988
  /**
1775
1989
  * Common APIs related to content parsing.
@@ -1810,12 +2024,21 @@ export declare interface PartialFASTElementDefinition {
1810
2024
  readonly attributes?: (AttributeConfiguration | string)[];
1811
2025
  /**
1812
2026
  * Options controlling the creation of the custom element's shadow DOM.
2027
+ * @remarks
2028
+ * If not provided, defaults to an open shadow root. Provide null
2029
+ * to render to the associated template to the light DOM instead.
1813
2030
  */
1814
- readonly shadowOptions?: Partial<ShadowRootInit> | null;
2031
+ readonly shadowOptions?: Partial<ShadowRootOptions> | null;
1815
2032
  /**
1816
2033
  * Options controlling how the custom element is defined with the platform.
1817
2034
  */
1818
2035
  readonly elementOptions?: ElementDefinitionOptions;
2036
+ /**
2037
+ * The registry to register this component in by default.
2038
+ * @remarks
2039
+ * If not provided, defaults to the global registry.
2040
+ */
2041
+ readonly registry?: CustomElementRegistry;
1819
2042
  }
1820
2043
 
1821
2044
  /**
@@ -1871,7 +2094,7 @@ export declare class PropertyChangeNotifier implements Notifier {
1871
2094
  * @param propertyName - The name of the property to assign the reference to.
1872
2095
  * @public
1873
2096
  */
1874
- export declare const ref: <T = any>(propertyName: keyof T & string) => CaptureType<T>;
2097
+ export declare const ref: <TSource = any, TParent = any>(propertyName: keyof TSource & string) => CaptureType<TSource, TParent>;
1875
2098
 
1876
2099
  /**
1877
2100
  * The runtime behavior for template references.
@@ -1879,69 +2102,61 @@ export declare const ref: <T = any>(propertyName: keyof T & string) => CaptureTy
1879
2102
  */
1880
2103
  export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
1881
2104
  /**
1882
- * Bind this behavior to the source.
1883
- * @param source - The source to bind to.
1884
- * @param context - The execution context that the binding is operating within.
1885
- * @param targets - The targets that behaviors in a view can attach to.
2105
+ * The structural id of the DOM node to which the created behavior will apply.
1886
2106
  */
1887
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
2107
+ targetNodeId: string;
1888
2108
  /**
1889
- * Unbinds this behavior from the source.
1890
- * @param source - The source to unbind from.
2109
+ * Bind this behavior.
2110
+ * @param controller - The view controller that manages the lifecycle of this behavior.
1891
2111
  */
1892
- unbind(): void;
2112
+ bind(controller: ViewController): void;
1893
2113
  }
1894
2114
 
1895
2115
  declare const reflectMode = "reflect";
1896
2116
 
1897
2117
  /**
1898
2118
  * A directive that enables list rendering.
1899
- * @param itemsBinding - The array to render.
1900
- * @param templateOrTemplateBinding - The template or a template binding used obtain a template
2119
+ * @param items - The array to render.
2120
+ * @param template - The template or a template binding used obtain a template
1901
2121
  * to render for each item in the array.
1902
2122
  * @param options - Options used to turn on special repeat features.
1903
2123
  * @public
1904
2124
  */
1905
- export declare function repeat<TSource = any, TArray extends ReadonlyArray<any> = ReadonlyArray<any>>(itemsBinding: Binding<TSource, TArray, ExecutionContext<TSource>>, templateOrTemplateBinding: ViewTemplate | Binding<TSource, ViewTemplate>, options?: RepeatOptions): CaptureType<TSource>;
2125
+ 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>;
1906
2126
 
1907
2127
  /**
1908
2128
  * A behavior that renders a template for each item in an array.
1909
2129
  * @public
1910
2130
  */
1911
- export declare class RepeatBehavior<TSource = any> implements Behavior, Subscriber {
2131
+ export declare class RepeatBehavior<TSource = any> implements ViewBehavior, Subscriber {
2132
+ private directive;
1912
2133
  private location;
1913
- private itemsBinding;
1914
- private templateBinding;
1915
- private options;
1916
- private source;
1917
- private views;
2134
+ private controller;
1918
2135
  private template;
1919
2136
  private templateBindingObserver;
1920
2137
  private items;
1921
2138
  private itemsObserver;
1922
2139
  private itemsBindingObserver;
1923
- private context;
1924
- private childContext;
1925
2140
  private bindView;
2141
+ /** @internal */
2142
+ views: SyntheticView[];
1926
2143
  /**
1927
2144
  * Creates an instance of RepeatBehavior.
1928
2145
  * @param location - The location in the DOM to render the repeat.
1929
- * @param itemsBinding - The array to render.
2146
+ * @param dataBinding - The array to render.
1930
2147
  * @param isItemsBindingVolatile - Indicates whether the items binding has volatile dependencies.
1931
2148
  * @param templateBinding - The template to render for each item.
1932
2149
  * @param isTemplateBindingVolatile - Indicates whether the template binding has volatile dependencies.
1933
2150
  * @param options - Options used to turn on special repeat features.
1934
2151
  */
1935
- constructor(location: Node, itemsBinding: Binding<TSource, any[]>, isItemsBindingVolatile: boolean, templateBinding: Binding<TSource, SyntheticViewTemplate>, isTemplateBindingVolatile: boolean, options: RepeatOptions);
2152
+ constructor(directive: RepeatDirective);
1936
2153
  /**
1937
- * Bind this behavior to the source.
1938
- * @param source - The source to bind to.
1939
- * @param context - The execution context that the binding is operating within.
2154
+ * Bind this behavior.
2155
+ * @param controller - The view controller that manages the lifecycle of this behavior.
1940
2156
  */
1941
- bind(source: TSource, context: ExecutionContext): void;
2157
+ bind(controller: ViewController): void;
1942
2158
  /**
1943
- * Unbinds this behavior from the source.
1944
- * @param source - The source to unbind from.
2159
+ * Unbinds this behavior.
1945
2160
  */
1946
2161
  unbind(): void;
1947
2162
  /**
@@ -1949,7 +2164,7 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
1949
2164
  * @param source - The source of the change.
1950
2165
  * @param args - The details about what was changed.
1951
2166
  */
1952
- handleChange(source: any, args: Splice[]): void;
2167
+ handleChange(source: any, args: Splice[] | ExpressionObserver): void;
1953
2168
  private observeItems;
1954
2169
  private updateViews;
1955
2170
  private refreshAllViews;
@@ -1961,19 +2176,13 @@ export declare class RepeatBehavior<TSource = any> implements Behavior, Subscrib
1961
2176
  * @public
1962
2177
  */
1963
2178
  export declare class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
1964
- readonly itemsBinding: Binding;
2179
+ readonly dataBinding: Binding<TSource>;
1965
2180
  readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
1966
2181
  readonly options: RepeatOptions;
1967
- private isItemsBindingVolatile;
1968
- private isTemplateBindingVolatile;
1969
- /**
1970
- * The unique id of the factory.
1971
- */
1972
- id: string;
1973
2182
  /**
1974
2183
  * The structural id of the DOM node to which the created behavior will apply.
1975
2184
  */
1976
- nodeId: string;
2185
+ targetNodeId: string;
1977
2186
  /**
1978
2187
  * Creates a placeholder string based on the directive's index within the template.
1979
2188
  * @param index - The index of the directive within the template.
@@ -1981,16 +2190,16 @@ export declare class RepeatDirective<TSource = any> implements HTMLDirective, Vi
1981
2190
  createHTML(add: AddViewBehaviorFactory): string;
1982
2191
  /**
1983
2192
  * Creates an instance of RepeatDirective.
1984
- * @param itemsBinding - The binding that provides the array to render.
2193
+ * @param dataBinding - The binding that provides the array to render.
1985
2194
  * @param templateBinding - The template binding used to obtain a template to render for each item in the array.
1986
2195
  * @param options - Options used to turn on special repeat features.
1987
2196
  */
1988
- constructor(itemsBinding: Binding, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
2197
+ constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
1989
2198
  /**
1990
2199
  * Creates a behavior for the provided target node.
1991
2200
  * @param target - The node instance to create the behavior for.
1992
2201
  */
1993
- createBehavior(targets: ViewBehaviorTargets): RepeatBehavior<TSource>;
2202
+ createBehavior(): RepeatBehavior<TSource>;
1994
2203
  }
1995
2204
 
1996
2205
  /**
@@ -2008,13 +2217,26 @@ export declare interface RepeatOptions {
2008
2217
  recycle?: boolean;
2009
2218
  }
2010
2219
 
2220
+ /**
2221
+ * Shadow root initialization options.
2222
+ * @public
2223
+ */
2224
+ export declare interface ShadowRootOptions extends ShadowRootInit {
2225
+ /**
2226
+ * A registry that provides the custom elements visible
2227
+ * from within this shadow root.
2228
+ * @beta
2229
+ */
2230
+ registry?: CustomElementRegistry;
2231
+ }
2232
+
2011
2233
  /**
2012
2234
  * A directive that observes the `assignedNodes()` of a slot and updates a property
2013
2235
  * whenever they change.
2014
2236
  * @param propertyOrOptions - The options used to configure slotted node observation.
2015
2237
  * @public
2016
2238
  */
2017
- export declare function slotted<T = any>(propertyOrOptions: (keyof T & string) | SlottedDirectiveOptions<keyof T & string>): CaptureType<T>;
2239
+ export declare function slotted<TSource = any, TParent = any>(propertyOrOptions: (keyof TSource & string) | SlottedDirectiveOptions<keyof TSource & string>): CaptureType<TSource, TParent>;
2018
2240
 
2019
2241
  /**
2020
2242
  * The runtime behavior for slotted node observation.
@@ -2047,6 +2269,28 @@ export declare class SlottedDirective extends NodeObservationDirective<SlottedDi
2047
2269
  export declare interface SlottedDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, AssignedNodesOptions {
2048
2270
  }
2049
2271
 
2272
+ /**
2273
+ * Describes how the source's lifetime relates to its controller's lifetime.
2274
+ * @public
2275
+ */
2276
+ export declare const SourceLifetime: Readonly<{
2277
+ /**
2278
+ * The source to controller lifetime relationship is unknown.
2279
+ */
2280
+ readonly unknown: undefined;
2281
+ /**
2282
+ * The source and controller lifetimes are coupled to one another.
2283
+ * They can/will be GC'd together.
2284
+ */
2285
+ readonly coupled: 1;
2286
+ }>;
2287
+
2288
+ /**
2289
+ * Describes how the source's lifetime relates to its controller's lifetime.
2290
+ * @public
2291
+ */
2292
+ export declare type SourceLifetime = typeof SourceLifetime[keyof typeof SourceLifetime];
2293
+
2050
2294
  /**
2051
2295
  * A splice map is a representation of how a previous array of items
2052
2296
  * was transformed into a new array of items. Conceptually it is a list of
@@ -2203,26 +2447,18 @@ export declare type SpliceStrategySupport = typeof SpliceStrategySupport[keyof t
2203
2447
  * A base class used for attribute directives that don't need internal state.
2204
2448
  * @public
2205
2449
  */
2206
- export declare abstract class StatelessAttachedAttributeDirective<T> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
2207
- protected options: T;
2450
+ export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
2451
+ protected options: TOptions;
2208
2452
  /**
2209
- * The unique id of the factory.
2210
- */
2211
- id: string;
2212
- /**
2213
- * The structural id of the DOM node to which the created behavior will apply.
2453
+ * Opts out of JSON stringification.
2454
+ * @internal
2214
2455
  */
2215
- nodeId: string;
2456
+ toJSON: () => undefined;
2216
2457
  /**
2217
2458
  * Creates an instance of RefDirective.
2218
2459
  * @param options - The options to use in configuring the directive.
2219
2460
  */
2220
- constructor(options: T);
2221
- /**
2222
- * Creates a behavior.
2223
- * @param targets - The targets available for behaviors to be attached to.
2224
- */
2225
- createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
2461
+ constructor(options: TOptions);
2226
2462
  /**
2227
2463
  * Creates a placeholder string based on the directive's index within the template.
2228
2464
  * @param index - The index of the directive within the template.
@@ -2231,17 +2467,15 @@ export declare abstract class StatelessAttachedAttributeDirective<T> implements
2231
2467
  */
2232
2468
  createHTML(add: AddViewBehaviorFactory): string;
2233
2469
  /**
2234
- * Bind this behavior to the source.
2235
- * @param source - The source to bind to.
2236
- * @param context - The execution context that the binding is operating within.
2237
- * @param targets - The targets that behaviors in a view can attach to.
2470
+ * Creates a behavior.
2471
+ * @param targets - The targets available for behaviors to be attached to.
2238
2472
  */
2239
- abstract bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
2473
+ createBehavior(): ViewBehavior;
2240
2474
  /**
2241
- * Unbinds this behavior from the source.
2242
- * @param source - The source to unbind from.
2475
+ * Bind this behavior.
2476
+ * @param controller - The view controller that manages the lifecycle of this behavior.
2243
2477
  */
2244
- abstract unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
2478
+ abstract bind(controller: ViewController): void;
2245
2479
  }
2246
2480
 
2247
2481
  /**
@@ -2266,7 +2500,7 @@ export declare interface StyleStrategy {
2266
2500
  * A node that can be targeted by styles.
2267
2501
  * @public
2268
2502
  */
2269
- export declare interface StyleTarget {
2503
+ export declare interface StyleTarget extends Pick<Node, "getRootNode"> {
2270
2504
  /**
2271
2505
  * Stylesheets to be adopted by the node.
2272
2506
  */
@@ -2398,26 +2632,17 @@ export declare interface SyntheticViewTemplate<TSource = any, TParent = any> {
2398
2632
  * Creates a SyntheticView instance based on this template definition.
2399
2633
  */
2400
2634
  create(): SyntheticView<TSource, TParent>;
2635
+ /**
2636
+ * Returns a directive that can inline the template.
2637
+ */
2638
+ inline(): CaptureType<TSource, TParent>;
2401
2639
  }
2402
2640
 
2403
2641
  /**
2404
2642
  * Represents the types of values that can be interpolated into a template.
2405
2643
  * @public
2406
2644
  */
2407
- export declare type TemplateValue<TSource, TParent = any> = Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource>;
2408
-
2409
- /**
2410
- * Enables working with trusted types.
2411
- * @public
2412
- */
2413
- export declare type TrustedTypes = {
2414
- /**
2415
- * Creates a trusted types policy.
2416
- * @param name - The policy name.
2417
- * @param rules - The policy rules implementation.
2418
- */
2419
- createPolicy(name: string, rules: TrustedTypesPolicy): TrustedTypesPolicy;
2420
- };
2645
+ export declare type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
2421
2646
 
2422
2647
  /**
2423
2648
  * A policy for use with the standard trustedTypes platform API.
@@ -2449,40 +2674,6 @@ export declare interface TypeRegistry<TDefinition extends TypeDefinition> {
2449
2674
  getForInstance(object: any): TDefinition | undefined;
2450
2675
  }
2451
2676
 
2452
- /**
2453
- * A base binding behavior for DOM updates.
2454
- * @public
2455
- */
2456
- export declare class UpdateBinding implements ViewBehavior {
2457
- readonly directive: HTMLBindingDirective;
2458
- protected updateTarget: UpdateTarget;
2459
- /**
2460
- * Creates an instance of UpdateBinding.
2461
- * @param directive - The directive that has the configuration for this behavior.
2462
- * @param updateTarget - The function used to update the target with the latest value.
2463
- */
2464
- constructor(directive: HTMLBindingDirective, updateTarget: UpdateTarget);
2465
- /**
2466
- * Bind this behavior to the source.
2467
- * @param source - The source to bind to.
2468
- * @param context - The execution context that the binding is operating within.
2469
- * @param targets - The targets that behaviors in a view can attach to.
2470
- */
2471
- bind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
2472
- /**
2473
- * Unbinds this behavior from the source.
2474
- * @param source - The source to unbind from.
2475
- * @param context - The execution context that the binding is operating within.
2476
- * @param targets - The targets that behaviors in a view can attach to.
2477
- */
2478
- unbind(source: any, context: ExecutionContext, targets: ViewBehaviorTargets): void;
2479
- /**
2480
- * Creates a behavior.
2481
- * @param targets - The targets available for behaviors to be attached to.
2482
- */
2483
- createBehavior(targets: ViewBehaviorTargets): ViewBehavior;
2484
- }
2485
-
2486
2677
  /**
2487
2678
  * A work queue used to synchronize writes to the DOM.
2488
2679
  * @public
@@ -2524,29 +2715,6 @@ export declare interface UpdateQueue {
2524
2715
  */
2525
2716
  export declare const Updates: UpdateQueue;
2526
2717
 
2527
- /**
2528
- * A target update function.
2529
- * @param this - The "this" context for the update.
2530
- * @param target - The node that is targeted by the update.
2531
- * @param aspect - The aspect of the node that is being targeted.
2532
- * @param value - The value to assign to the aspect.
2533
- * @param source - The source object that the value was derived from.
2534
- * @param context - The execution context that the binding is being run under.
2535
- * @public
2536
- */
2537
- export declare type UpdateTarget = (this: UpdateTargetThis, target: Node, aspect: string, value: any, source: any, context: ExecutionContext) => void;
2538
-
2539
- /**
2540
- * The "this" context for an update target function.
2541
- * @public
2542
- */
2543
- export declare interface UpdateTargetThis {
2544
- /**
2545
- * The directive configuration for the update.
2546
- */
2547
- directive: HTMLBindingDirective;
2548
- }
2549
-
2550
2718
  /**
2551
2719
  * Represents objects that can convert values to and from
2552
2720
  * view or model representations.
@@ -2573,7 +2741,7 @@ export declare interface View<TSource = any, TParent = any> extends Disposable {
2573
2741
  /**
2574
2742
  * The execution context the view is running within.
2575
2743
  */
2576
- readonly context: ExecutionContext<TParent> | null;
2744
+ readonly context: ExecutionContext<TParent>;
2577
2745
  /**
2578
2746
  * The data that the view is bound to.
2579
2747
  */
@@ -2581,9 +2749,8 @@ export declare interface View<TSource = any, TParent = any> extends Disposable {
2581
2749
  /**
2582
2750
  * Binds a view's behaviors to its binding source.
2583
2751
  * @param source - The binding source for the view's binding behaviors.
2584
- * @param context - The execution context to run the view within.
2585
2752
  */
2586
- bind(source: TSource, context: ExecutionContext<TParent>): void;
2753
+ bind(source: TSource, context?: ExecutionContext<TParent>): void;
2587
2754
  /**
2588
2755
  * Unbinds a view's behaviors from its binding source and context.
2589
2756
  */
@@ -2596,23 +2763,14 @@ export declare interface View<TSource = any, TParent = any> extends Disposable {
2596
2763
  */
2597
2764
  export declare interface ViewBehavior<TSource = any, TParent = any> {
2598
2765
  /**
2599
- * Bind this behavior to the source.
2600
- * @param source - The source to bind to.
2601
- * @param context - The execution context that the binding is operating within.
2602
- * @param targets - The targets that behaviors in a view can attach to.
2603
- */
2604
- bind(source: TSource, context: ExecutionContext<TParent>, targets: ViewBehaviorTargets): void;
2605
- /**
2606
- * Unbinds this behavior from the source.
2607
- * @param source - The source to unbind from.
2608
- * @param context - The execution context that the binding is operating within.
2609
- * @param targets - The targets that behaviors in a view can attach to.
2766
+ * Bind this behavior.
2767
+ * @param controller - The view controller that manages the lifecycle of this behavior.
2610
2768
  */
2611
- unbind(source: TSource, context: ExecutionContext<TParent>, targets: ViewBehaviorTargets): void;
2769
+ bind(controller: ViewController<TSource, TParent>): void;
2612
2770
  }
2613
2771
 
2614
2772
  /**
2615
- * A factory that can create a {@link Behavior} associated with a particular
2773
+ * A factory that can create a {@link ViewBehavior} associated with a particular
2616
2774
  * location within a DOM fragment.
2617
2775
  * @public
2618
2776
  */
@@ -2620,16 +2778,23 @@ export declare interface ViewBehaviorFactory {
2620
2778
  /**
2621
2779
  * The unique id of the factory.
2622
2780
  */
2623
- id: string;
2781
+ id?: string;
2624
2782
  /**
2625
2783
  * The structural id of the DOM node to which the created behavior will apply.
2626
2784
  */
2627
- nodeId: string;
2785
+ targetNodeId?: string;
2786
+ /**
2787
+ * The tag name of the DOM node to which the created behavior will apply.
2788
+ */
2789
+ targetTagName?: string | null;
2790
+ /**
2791
+ * The policy that the created behavior must run under.
2792
+ */
2793
+ policy?: DOMPolicy;
2628
2794
  /**
2629
2795
  * Creates a behavior.
2630
- * @param targets - The targets available for behaviors to be attached to.
2631
2796
  */
2632
- createBehavior(targets: ViewBehaviorTargets): Behavior | ViewBehavior;
2797
+ createBehavior(): ViewBehavior;
2633
2798
  }
2634
2799
 
2635
2800
  /**
@@ -2640,11 +2805,23 @@ export declare type ViewBehaviorTargets = {
2640
2805
  [id: string]: Node;
2641
2806
  };
2642
2807
 
2808
+ /**
2809
+ * Controls the lifecycle of a view and provides relevant context.
2810
+ * @public
2811
+ */
2812
+ export declare interface ViewController<TSource = any, TParent = any> extends ExpressionController<TSource, TParent> {
2813
+ /**
2814
+ * The parts of the view that are targeted by view behaviors.
2815
+ */
2816
+ readonly targets: ViewBehaviorTargets;
2817
+ }
2818
+
2643
2819
  /**
2644
2820
  * A template capable of creating HTMLView instances or rendering directly to DOM.
2645
2821
  * @public
2646
2822
  */
2647
2823
  export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate<TSource, TParent>, SyntheticViewTemplate<TSource, TParent> {
2824
+ private policy?;
2648
2825
  private result;
2649
2826
  /**
2650
2827
  * The html representing what this template will
@@ -2659,13 +2836,27 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
2659
2836
  * Creates an instance of ViewTemplate.
2660
2837
  * @param html - The html representing what this template will instantiate, including placeholders for directives.
2661
2838
  * @param factories - The directives that will be connected to placeholders in the html.
2839
+ * @param policy - The security policy to use when compiling this template.
2662
2840
  */
2663
- constructor(html: string | HTMLTemplateElement, factories: Record<string, ViewBehaviorFactory>);
2841
+ constructor(html: string | HTMLTemplateElement, factories?: Record<string, ViewBehaviorFactory>, policy?: DOMPolicy | undefined);
2664
2842
  /**
2665
2843
  * Creates an HTMLView instance based on this template definition.
2666
2844
  * @param hostBindingTarget - The element that host behaviors will be bound to.
2667
2845
  */
2668
2846
  create(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
2847
+ /**
2848
+ * Returns a directive that can inline the template.
2849
+ */
2850
+ inline(): CaptureType<TSource, TParent>;
2851
+ /**
2852
+ * Sets the DOMPolicy for this template.
2853
+ * @param policy - The policy to associated with this template.
2854
+ * @returns The modified template instance.
2855
+ * @remarks
2856
+ * The DOMPolicy can only be set once for a template and cannot be
2857
+ * set after the template is compiled.
2858
+ */
2859
+ withPolicy(policy: DOMPolicy): this;
2669
2860
  /**
2670
2861
  * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
2671
2862
  * @param source - The data source to bind the template to.
@@ -2673,7 +2864,26 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
2673
2864
  * @param hostBindingTarget - An HTML element to target the host bindings at if different from the
2674
2865
  * host that the template is being attached to.
2675
2866
  */
2676
- render(source: TSource, host: Node, hostBindingTarget?: Element, context?: ExecutionContext): HTMLView<TSource, TParent>;
2867
+ render(source: TSource, host: Node, hostBindingTarget?: Element): HTMLView<TSource, TParent>;
2868
+ /**
2869
+ * Opts out of JSON stringification.
2870
+ * @internal
2871
+ */
2872
+ toJSON: () => undefined;
2873
+ /**
2874
+ * Creates a template based on a set of static strings and dynamic values.
2875
+ * @param strings - The static strings to create the template with.
2876
+ * @param values - The dynamic values to create the template with.
2877
+ * @param policy - The DOMPolicy to associated with the template.
2878
+ * @returns A ViewTemplate.
2879
+ * @remarks
2880
+ * This API should not be used directly under normal circumstances because constructing
2881
+ * a template in this way, if not done properly, can open up the application to XSS
2882
+ * attacks. When using this API, provide a strong DOMPolicy that can properly sanitize
2883
+ * and also be sure to manually sanitize all static strings particularly if they can
2884
+ * come from user input.
2885
+ */
2886
+ static create<TSource = any, TParent = any>(strings: string[], values: TemplateValue<TSource, TParent>[], policy?: DOMPolicy): ViewTemplate<TSource, TParent>;
2677
2887
  }
2678
2888
 
2679
2889
  /**
@@ -2687,11 +2897,11 @@ export declare function volatile(target: {}, name: string | Accessor, descriptor
2687
2897
 
2688
2898
  /**
2689
2899
  * A directive that enables basic conditional rendering in a template.
2690
- * @param binding - The condition to test for rendering.
2900
+ * @param condition - The condition to test for rendering.
2691
2901
  * @param templateOrTemplateBinding - The template or a binding that gets
2692
2902
  * the template to render when the condition is true.
2693
2903
  * @public
2694
2904
  */
2695
- export declare function when<TSource = any, TReturn = any>(binding: Binding<TSource, TReturn>, templateOrTemplateBinding: SyntheticViewTemplate | Binding<TSource, SyntheticViewTemplate>): CaptureType<TSource>;
2905
+ 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>;
2696
2906
 
2697
2907
  export { }