@microsoft/fast-element 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ # FASTElement
2
+
3
+ The `FASTElement` is our extension of the `HTMLElement`. As such it leverages the lifecycles but also requires additional setup before before the class `constructor` or the `connectedCallback` method is executed which are explained in the [overview](./ARCHITECTURE_OVERVIEW.md). This document explains specifically what `FASTElement` leverages inside the `HTMLElement`s lifecycle hooks.
4
+
5
+ For an explanation into `HTMLElement` lifecycle hooks refer to the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#custom_element_lifecycle_callbacks).
6
+
7
+ ## A Custom Element is Detected by the Browser
8
+
9
+ Because the `FASTElement` is an extension of the `HTMLElement`, it makes use of the same lifecycle hooks and extends them with `$fastController`. It also initializes using another class `ElementController`, the methods this are called during the custom elements native `constructor`, `connectedCallback`, `disconnectedCallback`, and `attributeChangedCallback` lifecycle hooks.
10
+
11
+ ### 🔄 **Lifecycle**: Initialization
12
+
13
+ ```mermaid
14
+ flowchart TD
15
+ A[A <code>FASTElement</code> web component is added to the <code>DOM</code>] --> B
16
+ B[<code>FASTElement</code> initializes the <code>ElementController.forCustomElement</code> passing the Custom Element instance] --> C
17
+ B --> F[Observables applied to the <code>FASTElement</code> are updated on the FAST global without values]
18
+ C{Is an <code>ElementController</code> available?}
19
+ C --> |yes|E
20
+ C --> |no|D
21
+ D[Initialize a new <code>ElementController</code> referred to as setting an element controller strategy]
22
+ D --> F
23
+ E[<code>ElementController</code> captures the Custom Element instance and the definition and attaches them to the <code>$fastController</code> which is then attached to the instance]
24
+ ```
25
+
26
+ ### 🔄 **Lifecycle**: Component is connected
27
+
28
+ ```mermaid
29
+ flowchart TD
30
+ A[browser <code>HTMLElement</code>'s <code>connectedCallback</code> is called] --> B
31
+ B[<code>this.$fastController.connect</code> in FASTElement is called] --> C
32
+ B --> D
33
+ B --> E
34
+ B --> F
35
+ C[bind observables by capturing the Custom Elements properties and setting the values from the bound observables on the Custom Element]
36
+ D[connect behaviors by call the <code>connectedCallback</code> on all behaviors]
37
+ E[render template, execute an <code>ElementViewTemplate</code>'s render method]
38
+ F[add styles either as an appended <code>StyleElement</code> node or an <code>adoptedStylesheet</code> which may include and attach behaviors]
39
+ ```
40
+
41
+ #### Render Template
42
+
43
+ The rendering of the template on the `ElementController` is by the `renderTemplate` method which is called during the `ElementController.connect` method which is triggered by `HTMLElement`s `connectedCallback` lifecycle.
44
+
45
+ The `renderTemplate` identifies the Custom Element, and the shadow root associated with the Custom Element. This then places a rendering of the template (an `ElementView`) onto the internal `view` of the controller. When creating the `ElementView`/`HTMLView` using the `ViewTemplate.render`, the `Compile.compile()` method identifies a `DocumentFragment` either by using an existing `<template>` tag, or creating one to wrap the contents of the shadow root. A new `CompilationContext` is created and the `compileAttributes` function is called, this results in the replacement of the placeholder attributes initally set-up during the pre-render step with their values if a value has been assigned. The factories with the associated nodes identified are then passed to the context. The view then binds all behaviors to the source element. The `CompilationContext.createView` is executed with the `DocumentFragment` as the root, and returns an `HTMLView`. This `HTMLView` includes an `appendTo` method to attach the fragment to the host element, which it then does. It should be noted that the compiled HTML is a `string`, which when set on the `DocumentFragment` as `innerHTML`, this allows the browser to dictate the creation of HTML nodes.
46
+
47
+ ### 🔄 **Lifecycle**: Component is disconnected
48
+
49
+ When a component is disconnected, a cleanup step is created to remove associated behaviors.
50
+
51
+ ### 🔄 **Lifecycle**: Attribute has been changed
52
+
53
+ Attributes have an `AttributeDefinition` which allows for converters, attachment of the `<attributName>Changed` aspect of the `@attr` decorator among other capabilities.
54
+
55
+ ```mermaid
56
+ flowchart TD
57
+ A[The browser <code>HTMLElement</code>'s <code>attributeChangedCallback</code> is called] --> B
58
+ B[<code>this.$fastController.onAttributeChangedCallback</code> in <code>FASTElement</code> is called] --> C
59
+ C[calls the attribute definitions <code>onAttributeChangedCallback</code> method with the updated value] --> D
60
+ D[An <code>Updates.enqueue</code> is called which places the update in the task queue which is then executed, these are performed async unless otherwise specified]
61
+ ```
62
+
63
+ These changes are observed and similar to the way `Observables` work, they utilize an `Accessor` pattern which has a `getValue` and `setValue` in which DOM updates are applied.
@@ -0,0 +1,34 @@
1
+ # `html` tagged template literal
2
+
3
+ The `html` export from `@microsoft/fast-element` is used to create the template logic for the custom element.
4
+
5
+ ## Pre-processing the `html` tagged template literal contents
6
+
7
+ Before the template can be used it goes through a step to convert it into a `ViewTemplate` which it does via the `ViewTemplate.create()` method. This is then used during the `compose` step, before `FASTElement` is instantiated.
8
+
9
+ During the `Compiler.compile()` method(triggered by `ViewTemplate.create()` method), the following happens for each string:
10
+ - Factories with unique IDs are created for each tag template literal argument (or `TemplateValue`) which matches with the corresponding string
11
+ - A binding is created from the `TemplateValue`
12
+
13
+ A resulting string using a `createHTML()` function is produced using the `HTMLDirective`s executed for each factory. The behavior is augmented by the previous string from the `html` tag template which determines the aspect if one exists, these aspects are the `@`, `:`, or other binding aspect attached to attributes.
14
+
15
+ The `createHTML()` function utilizes a `Markup` attribute which is assigned to a factory's unique ID. The strings are concatenated and passed to a new `ViewTemplate` with all the factories (empty until one is assigned) that act as a dictionary with the unique IDs as the key to look up each factory once it has been created. The string this creates is injected into a `<template>` as `innerHTML`, which allows the browser to create the nodes and placeholder factory IDs, with the only `DOM` node that is explicitly created being the wrapping `<template>` element.
16
+
17
+ ## Directives
18
+
19
+ The `HTMLBindingDirective` applies bindings to items identified as various `TemplateValue`s within the `html` tagged template. The `createHTML` step uses the factory associated with the binding to create strings in the markup using the factory's ID.
20
+
21
+ ```mermaid
22
+ flowchart TD
23
+ A[A <code>new HTMLBindingDirective</code> is created with a data binding which has a policy, options, <code>createObserver</code>, and an evaluate method assigned to the passed arrow function such as <pre>x => x.foo</pre>]
24
+ B[<code>oneTime</code> binding passes the corresponding tag template argument, an arrow function]
25
+ C[<code>oneWay</code> binding passes a copy of the corresponding tag template argument, an arrow function]
26
+ D[An already specified binding such as a <code>repeat</code> or <code>when</code> directive is passed]
27
+ A --> B
28
+ A --> C
29
+ A --> D
30
+ E[When a <code>createObserver</code> is called, an <code>Observable.binding</code> is created passing the arrow function to be evaluated and the subscriber to be notified]
31
+ C --> E
32
+ F[When a <code>createObserver</code> is called, the instance of the one time binding is returned which includes a bind method returning the arrow function executed against the controller source and context]
33
+ B --> F
34
+ ```
@@ -0,0 +1,10 @@
1
+ # Introduction
2
+
3
+ This document (and the linked documents) explains how the exports and side effects of `@microsoft/fast-element` are used to create custom elements.
4
+
5
+ ## Glossary
6
+
7
+ - [Overview](./ARCHITECTURE_OVERVIEW.md): How the `@microsoft/fast-element` should be used by a developer and what code is executed during the first render.
8
+ - [`FASTElement`](./ARCHITECTURE_FASTELEMENT.md): How the `FASTElement` is architected.
9
+ - [`html` tagged template literal](./ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md): How the `html` tagged template literal takes and converts the contents into a `VIEWTemplate`.
10
+ - [`Updates` queue](./ARCHITECTURE_UPDATES.md): How updates to attributes and observables are processed.
@@ -0,0 +1,52 @@
1
+ # General FAST usage
2
+
3
+ `FASTElement` is an extension of `HTMLElement` which makes use of Custom Element APIs native to the browser. It also supplies the following methods:
4
+
5
+ - The `compose` method combines the Custom Element name, template, style, and other options to create the definition for the Custom Element.
6
+ - The `define` method makes use of the native Custom Element [`define()`](https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define) to register the Custom Element with a Custom Element Registry.
7
+ - The `from` method allows the use of Customized Built-in elements, which extend from native elements such as `HTMLButtonElement`.
8
+
9
+ ### Creating a Custom Element from FASTElement
10
+
11
+ A basic developer flow for defining a custom element looks like this:
12
+
13
+ ```mermaid
14
+ flowchart TD
15
+ A[Create a <code>FASTElement</code> web component by extending the <code>FASTElement</code> class] --> F
16
+ F[Compose with <code>FASTElement.compose</code> to include template and styles] --> G[Define the component in the browser with <code>FASTElement.define</code>]
17
+ ```
18
+
19
+ Let's take a look at the compose step to see what the FAST architecture is doing at this stage.
20
+
21
+ ### Composing a Custom Element
22
+
23
+ The `FASTElement.compose()` function creates a new `FASTElementDefinition`, which includes all metadata needed for the element (such as templates, attributes, and styles). The element definition is registered with the global `FAST` for re-use, and the `FASTElementDefinition` is returned. The resulting object can be retrieved via `ElementController.definition`.
24
+
25
+ ## A Custom Element in JavaScript is sent to the Browser
26
+
27
+ Let's step back from defining the Custom Element and consider what is happening when we import from the `@microsoft/fast-element` package.
28
+
29
+ First, a global `FAST` property will be created if one does not already exist, typically in browser on the `window`.
30
+
31
+ Additionally, when Custom Elements are included in a script a few things might happen even before a Custom Element gets detected by the browser. First, there are initial side effects caused by the use of decorators. These include the `attr` and `observable` decorators made available by the `@microsoft/fast-element` package.
32
+
33
+ Here is a basic flow of what code is executed and when during initial load of a script that contains a FAST defined Custom Element:
34
+
35
+ ```mermaid
36
+ flowchart TD
37
+ A@{ shape: circle, label: "The browser loads the JavaScript file containing FAST and FAST Custom Element definitions" }
38
+ B@{ shape: rect, label: "The FAST global is added to the window" }
39
+ A --> B
40
+ C@{ shape: rect, label: "A Custom Element executes the <code>compose</code> step"}
41
+ B --> C
42
+ D@{ shape: procs, label: "<ul style="text-align: left"><li>Any defined observable decorators are added to the FAST global</li><li>An attribute decorator locates the associated Custom Elements constructor which it uses to push itself to the Custom Elements attribute collection</li></ul>"}
43
+ C --> D
44
+ F@{ shape: rect, label: "An HTML tagged template literal is executed for the FAST Custom Element and applied to the definition" }
45
+ D --> F
46
+ G@{ shape: rect, label: "The <code>define</code> step is hit and the <code>customElement</code> is registered with the Custom Element Registry" }
47
+ F --> G
48
+ H@{ shape: rect, label: "A Custom Element is detected on the page and the browser initializes it" }
49
+ I@{ shape: dbl-circ, label: "The lifecycle steps for <code>FASTElement</code> are executed" }
50
+ G --> H
51
+ H --> I
52
+ ```
@@ -0,0 +1,11 @@
1
+ # `Updates`
2
+
3
+ The `Updates` API is part of the `FAST` global. The updates that are queued include updates to attributes, observables, and observed arrays.
4
+
5
+ ## Attributes
6
+
7
+ An attribute change may be queued when the value of the attribute is updated. This change is triggered by `HTMLElement` lifecycle hook `attributeChangedCallback`. The `Updates` queue is used to try to reflect the attribute with the updated value onto the element using `DOM` APIs.
8
+
9
+ ## Observables
10
+
11
+ The `Reflect` API is used to override `defineProperty` in order to observe a property on an Custom Element, this overrides the getter and setter, which allows subscribers to be notified of changes. Any changes which `set` the value are passed to the `Updates` queue.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,45 @@
2
2
  "name": "@microsoft/fast-element",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 11 Dec 2024 19:52:58 GMT",
5
+ "date": "Mon, 24 Mar 2025 18:06:22 GMT",
6
+ "version": "2.2.0",
7
+ "tag": "@microsoft/fast-element_v2.2.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "7559015+janechu@users.noreply.github.com",
12
+ "package": "@microsoft/fast-element",
13
+ "commit": "4ef0c4d19c6ccce86756a55a26ad0a6a3c1cdb47",
14
+ "comment": "Expose the fast registry and allow triggering definition updates"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Thu, 13 Feb 2025 17:34:08 GMT",
21
+ "version": "2.1.0",
22
+ "tag": "@microsoft/fast-element_v2.1.0",
23
+ "comments": {
24
+ "minor": [
25
+ {
26
+ "author": "7559015+janechu@users.noreply.github.com",
27
+ "package": "@microsoft/fast-element",
28
+ "commit": "c4836e507f848b4838eb2c106c17dd18c28240b1",
29
+ "comment": "Update the ArrayObserver to better account for sort and reverse"
30
+ }
31
+ ],
32
+ "none": [
33
+ {
34
+ "author": "7559015+janechu@users.noreply.github.com",
35
+ "package": "@microsoft/fast-element",
36
+ "commit": "c6b9e8a436b7b52e5df02182b663167bb34cad8a",
37
+ "comment": "Add documentation explaining some architectural concepts"
38
+ }
39
+ ]
40
+ }
41
+ },
42
+ {
43
+ "date": "Wed, 11 Dec 2024 19:53:31 GMT",
6
44
  "version": "2.0.1",
7
45
  "tag": "@microsoft/fast-element_v2.0.1",
8
46
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,28 @@
1
1
  # Change Log - @microsoft/fast-element
2
2
 
3
- This log was last generated on Wed, 11 Dec 2024 19:52:58 GMT and should not be manually modified.
3
+ <!-- This log was last generated on Mon, 24 Mar 2025 18:06:22 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.2.0
8
+
9
+ Mon, 24 Mar 2025 18:06:22 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Expose the fast registry and allow triggering definition updates (7559015+janechu@users.noreply.github.com)
14
+
15
+ ## 2.1.0
16
+
17
+ Thu, 13 Feb 2025 17:34:08 GMT
18
+
19
+ ### Minor changes
20
+
21
+ - Update the ArrayObserver to better account for sort and reverse (7559015+janechu@users.noreply.github.com)
22
+
7
23
  ## 2.0.1
8
24
 
9
- Wed, 11 Dec 2024 19:52:58 GMT
25
+ Wed, 11 Dec 2024 19:53:31 GMT
10
26
 
11
27
  ### Patches
12
28
 
@@ -163,12 +163,13 @@ export declare class ElementController<TElement extends HTMLElement = HTMLElemen
163
163
  /**
164
164
  * Locates or creates a controller for the specified element.
165
165
  * @param element - The element to return the controller for.
166
+ * @param override - Reset the controller even if one has been defined.
166
167
  * @remarks
167
168
  * The specified element must have a {@link FASTElementDefinition}
168
169
  * registered either through the use of the {@link customElement}
169
170
  * decorator or a call to `FASTElement.define`.
170
171
  */
171
- static forCustomElement(element: HTMLElement): ElementController;
172
+ static forCustomElement(element: HTMLElement, override?: boolean): ElementController;
172
173
  /**
173
174
  * Sets the strategy that ElementController.forCustomElement uses to construct
174
175
  * ElementController instances for an element.
@@ -1,7 +1,14 @@
1
1
  import { Constructable } from "../interfaces.js";
2
+ import { TypeRegistry } from "../platform.js";
2
3
  import { ComposableStyles, ElementStyles } from "../styles/element-styles.js";
3
4
  import type { ElementViewTemplate } from "../templating/template.js";
4
5
  import { AttributeConfiguration, AttributeDefinition } from "./attributes.js";
6
+ /**
7
+ * The FAST custom element registry
8
+ * @internal
9
+ */
10
+ export declare const fastElementRegistry: TypeRegistry<FASTElementDefinition>;
11
+ export { TypeRegistry };
5
12
  /**
6
13
  * Shadow root initialization options.
7
14
  * @public
@@ -86,7 +93,7 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
86
93
  /**
87
94
  * The template to render for the custom element.
88
95
  */
89
- readonly template?: ElementViewTemplate;
96
+ template?: ElementViewTemplate;
90
97
  /**
91
98
  * The styles to associate with the custom element.
92
99
  */
@@ -3,7 +3,7 @@ export { FAST, emptyArray } from "./platform.js";
3
3
  export { DOMAspect, DOMSink, DOMPolicy, DOM } from "./dom.js";
4
4
  export { Accessor, Expression, ExecutionContext, ExpressionController, ExpressionObserver, ExpressionNotifier, Observable, observable, ObservationRecord, SourceLifetime, volatile, } from "./observation/observable.js";
5
5
  export { Notifier, PropertyChangeNotifier, Subscriber, SubscriberSet, } from "./observation/notifier.js";
6
- export { ArrayObserver, LengthObserver, lengthOf, Splice, SpliceStrategy, SpliceStrategySupport, } from "./observation/arrays.js";
6
+ export { ArrayObserver, LengthObserver, lengthOf, Splice, SpliceStrategy, SpliceStrategySupport, Sort, SortObserver, sortedCount, } from "./observation/arrays.js";
7
7
  export { UpdateQueue, Updates } from "./observation/update-queue.js";
8
8
  export { Binding, BindingDirective } from "./binding/binding.js";
9
9
  export { listener, oneWay } from "./binding/one-way.js";
@@ -29,6 +29,6 @@ export { ElementView, HTMLView, SyntheticView, View, HydratableView, HydrationBi
29
29
  export { elements, ElementsFilter, NodeBehaviorOptions, NodeObservationDirective, } from "./templating/node-observation.js";
30
30
  export { render, RenderBehavior, RenderDirective } from "./templating/render.js";
31
31
  export { customElement, FASTElement } from "./components/fast-element.js";
32
- export { FASTElementDefinition, PartialFASTElementDefinition, ShadowRootOptions, } from "./components/fast-definitions.js";
32
+ export { FASTElementDefinition, PartialFASTElementDefinition, ShadowRootOptions, fastElementRegistry, TypeRegistry, } from "./components/fast-definitions.js";
33
33
  export { attr, AttributeConfiguration, AttributeDefinition, AttributeMode, booleanConverter, DecoratorAttributeConfiguration, nullableBooleanConverter, nullableNumberConverter, ValueConverter, } from "./components/attributes.js";
34
34
  export { ElementController, ElementControllerStrategy, HydratableElementController, } from "./components/element-controller.js";
@@ -33,6 +33,18 @@ export declare class Splice {
33
33
  */
34
34
  adjustTo(array: any[]): this;
35
35
  }
36
+ /**
37
+ * A sort array indicates new index positions of array items.
38
+ * @public
39
+ */
40
+ export declare class Sort {
41
+ sorted?: number[] | undefined;
42
+ /**
43
+ * Creates a sort update.
44
+ * @param sorted - The updated index of sorted items.
45
+ */
46
+ constructor(sorted?: number[] | undefined);
47
+ }
36
48
  /**
37
49
  * Indicates what level of feature support the splice
38
50
  * strategy provides.
@@ -156,6 +168,17 @@ export interface LengthObserver extends Subscriber {
156
168
  */
157
169
  length: number;
158
170
  }
171
+ /**
172
+ * Observes array sort.
173
+ * @public
174
+ */
175
+ export interface SortObserver extends Subscriber {
176
+ /**
177
+ * The sorted times on the observed array, this should be incremented every time
178
+ * an item in the array changes location.
179
+ */
180
+ sorted: number;
181
+ }
159
182
  /**
160
183
  * An observer for arrays.
161
184
  * @public
@@ -169,11 +192,20 @@ export interface ArrayObserver extends SubscriberSet {
169
192
  * The length observer for the array.
170
193
  */
171
194
  readonly lengthObserver: LengthObserver;
195
+ /**
196
+ * The sort observer for the array.
197
+ */
198
+ readonly sortObserver: SortObserver;
172
199
  /**
173
200
  * Adds a splice to the list of changes.
174
201
  * @param splice - The splice to add.
175
202
  */
176
203
  addSplice(splice: Splice): void;
204
+ /**
205
+ * Adds a sort to the list of changes.
206
+ * @param sort - The sort to add.
207
+ */
208
+ addSort(sort: Sort): void;
177
209
  /**
178
210
  * Indicates that a reset change has occurred.
179
211
  * @param oldCollection - The collection as it was before the reset.
@@ -189,6 +221,7 @@ export interface ArrayObserver extends SubscriberSet {
189
221
  * @public
190
222
  */
191
223
  export declare const ArrayObserver: Readonly<{
224
+ readonly sorted: 0;
192
225
  /**
193
226
  * Enables the array observation mechanism.
194
227
  * @remarks
@@ -205,3 +238,10 @@ export declare const ArrayObserver: Readonly<{
205
238
  * @public
206
239
  */
207
240
  export declare function lengthOf<T>(array: readonly T[]): number;
241
+ /**
242
+ * Enables observing the sorted property of an array.
243
+ * @param array - The array to observe the sorted property of.
244
+ * @returns The sorted property.
245
+ * @public
246
+ */
247
+ export declare function sortedCount<T>(array: readonly T[]): number;
@@ -1,4 +1,4 @@
1
- import { Splice } from "../observation/arrays.js";
1
+ import { Sort, Splice } from "../observation/arrays.js";
2
2
  import type { Subscriber } from "../observation/notifier.js";
3
3
  import { Expression, ExpressionObserver } from "../observation/observable.js";
4
4
  import type { Binding, BindingDirective } from "../binding/binding.js";
@@ -81,9 +81,10 @@ export declare class RepeatBehavior<TSource = any> implements ViewBehavior, Subs
81
81
  * @param source - The source of the change.
82
82
  * @param args - The details about what was changed.
83
83
  */
84
- handleChange(source: any, args: Splice[] | ExpressionObserver): void;
84
+ handleChange(source: any, args: Splice[] | Sort[] | ExpressionObserver): void;
85
85
  private observeItems;
86
- private updateViews;
86
+ private updateSortedViews;
87
+ private updateSplicedViews;
87
88
  private refreshAllViews;
88
89
  private unbindAllViews;
89
90
  private hydrateViews;
@@ -417,20 +417,27 @@ export class ElementController extends PropertyChangeNotifier {
417
417
  /**
418
418
  * Locates or creates a controller for the specified element.
419
419
  * @param element - The element to return the controller for.
420
+ * @param override - Reset the controller even if one has been defined.
420
421
  * @remarks
421
422
  * The specified element must have a {@link FASTElementDefinition}
422
423
  * registered either through the use of the {@link customElement}
423
424
  * decorator or a call to `FASTElement.define`.
424
425
  */
425
- static forCustomElement(element) {
426
+ static forCustomElement(element, override = false) {
426
427
  const controller = element.$fastController;
427
- if (controller !== void 0) {
428
+ if (controller !== void 0 && !override) {
428
429
  return controller;
429
430
  }
430
431
  const definition = FASTElementDefinition.getForInstance(element);
431
432
  if (definition === void 0) {
432
433
  throw FAST.error(1401 /* Message.missingElementDefinition */);
433
434
  }
435
+ Observable.getNotifier(definition).subscribe({
436
+ handleChange: () => {
437
+ ElementController.forCustomElement(element, true);
438
+ element.$fastController.connect();
439
+ },
440
+ }, "template");
434
441
  return (element.$fastController = new elementControllerStrategy(element, definition));
435
442
  }
436
443
  /**
@@ -1,12 +1,25 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
1
10
  import { isString, KernelServiceId } from "../interfaces.js";
2
- import { Observable } from "../observation/observable.js";
11
+ import { observable, Observable } from "../observation/observable.js";
3
12
  import { createTypeRegistry, FAST } from "../platform.js";
4
13
  import { ElementStyles } from "../styles/element-styles.js";
5
14
  import { AttributeDefinition } from "./attributes.js";
6
15
  const defaultShadowOptions = { mode: "open" };
7
16
  const defaultElementOptions = {};
8
17
  const fastElementBaseTypes = new Set();
9
- const fastElementRegistry = FAST.getById(KernelServiceId.elementRegistry, () => createTypeRegistry());
18
+ /**
19
+ * The FAST custom element registry
20
+ * @internal
21
+ */
22
+ export const fastElementRegistry = FAST.getById(KernelServiceId.elementRegistry, () => createTypeRegistry());
10
23
  /**
11
24
  * Defines metadata for a FASTElement.
12
25
  * @public
@@ -106,3 +119,7 @@ FASTElementDefinition.getByType = fastElementRegistry.getByType;
106
119
  * @param instance - The custom element instance to retrieve the definition for.
107
120
  */
108
121
  FASTElementDefinition.getForInstance = fastElementRegistry.getForInstance;
122
+ __decorate([
123
+ observable,
124
+ __metadata("design:type", Object)
125
+ ], FASTElementDefinition.prototype, "template", void 0);
package/dist/esm/debug.js CHANGED
@@ -8,7 +8,7 @@ if (globalThis.FAST === void 0) {
8
8
  }
9
9
  const FAST = globalThis.FAST;
10
10
  const debugMessages = {
11
- [1101 /* needsArrayObservation */]: "Must call enableArrayObservation before observing arrays.",
11
+ [1101 /* needsArrayObservation */]: "Must call ArrayObserver.enable() before observing arrays.",
12
12
  [1201 /* onlySetDOMPolicyOnce */]: "The DOM Policy can only be set once.",
13
13
  [1202 /* bindingInnerHTMLRequiresTrustedTypes */]: "To bind innerHTML, you must use a TrustedTypesPolicy.",
14
14
  [1203 /* twoWayBindingRequiresObservables */]: "View=>Model update skipped. To use twoWay binding, the target property must be observable.",
package/dist/esm/index.js CHANGED
@@ -4,7 +4,7 @@ export { DOMAspect, DOM } from "./dom.js";
4
4
  // Observation
5
5
  export { ExecutionContext, Observable, observable, SourceLifetime, volatile, } from "./observation/observable.js";
6
6
  export { PropertyChangeNotifier, SubscriberSet, } from "./observation/notifier.js";
7
- export { ArrayObserver, lengthOf, Splice, SpliceStrategy, SpliceStrategySupport, } from "./observation/arrays.js";
7
+ export { ArrayObserver, lengthOf, Splice, SpliceStrategy, SpliceStrategySupport, Sort, sortedCount, } from "./observation/arrays.js";
8
8
  export { Updates } from "./observation/update-queue.js";
9
9
  // Binding
10
10
  export { Binding } from "./binding/binding.js";
@@ -34,6 +34,6 @@ export { elements, NodeObservationDirective, } from "./templating/node-observati
34
34
  export { render, RenderBehavior, RenderDirective } from "./templating/render.js";
35
35
  // Components
36
36
  export { customElement, FASTElement } from "./components/fast-element.js";
37
- export { FASTElementDefinition, } from "./components/fast-definitions.js";
37
+ export { FASTElementDefinition, fastElementRegistry, } from "./components/fast-definitions.js";
38
38
  export { attr, AttributeConfiguration, AttributeDefinition, booleanConverter, nullableBooleanConverter, nullableNumberConverter, } from "./components/attributes.js";
39
39
  export { ElementController, HydratableElementController, } from "./components/element-controller.js";