@microsoft/fast-element 1.10.0 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +1 -12
- package/CHANGELOG.json +396 -1
- package/CHANGELOG.md +68 -2
- package/README.md +2 -2
- package/dist/dts/components/attributes.d.ts +4 -1
- package/dist/dts/components/controller.d.ts +12 -11
- package/dist/dts/components/fast-definitions.d.ts +8 -2
- package/dist/dts/components/fast-element.d.ts +5 -4
- package/dist/dts/debug.d.ts +1 -0
- package/dist/dts/hooks.d.ts +20 -0
- package/dist/dts/index.d.ts +16 -15
- package/dist/dts/index.debug.d.ts +2 -0
- package/dist/dts/index.rollup.d.ts +2 -0
- package/dist/dts/index.rollup.debug.d.ts +3 -0
- package/dist/dts/interfaces.d.ts +144 -0
- package/dist/dts/observation/arrays.d.ts +207 -0
- package/dist/dts/observation/behavior.d.ts +5 -5
- package/dist/dts/observation/notifier.d.ts +18 -18
- package/dist/dts/observation/observable.d.ts +86 -29
- package/dist/dts/observation/splice-strategies.d.ts +13 -0
- package/dist/dts/observation/update-queue.d.ts +40 -0
- package/dist/dts/platform.d.ts +18 -67
- package/dist/dts/polyfills.d.ts +8 -0
- package/dist/dts/styles/css-directive.d.ts +43 -5
- package/dist/dts/styles/css.d.ts +19 -3
- package/dist/dts/styles/element-styles.d.ts +42 -62
- package/dist/dts/templating/binding.d.ts +320 -64
- package/dist/dts/templating/children.d.ts +18 -15
- package/dist/dts/templating/compiler.d.ts +47 -28
- package/dist/dts/templating/dom.d.ts +41 -0
- package/dist/dts/templating/html-directive.d.ts +179 -43
- package/dist/dts/templating/markup.d.ts +48 -0
- package/dist/dts/templating/node-observation.d.ts +45 -29
- package/dist/dts/templating/ref.d.ts +6 -12
- package/dist/dts/templating/repeat.d.ts +72 -14
- package/dist/dts/templating/slotted.d.ts +13 -14
- package/dist/dts/templating/template.d.ts +78 -23
- package/dist/dts/templating/view.d.ts +16 -23
- package/dist/dts/utilities.d.ts +40 -0
- package/dist/esm/components/attributes.js +25 -24
- package/dist/esm/components/controller.js +77 -57
- package/dist/esm/components/fast-definitions.js +14 -22
- package/dist/esm/debug.js +29 -0
- package/dist/esm/hooks.js +32 -0
- package/dist/esm/index.debug.js +2 -0
- package/dist/esm/index.js +19 -14
- package/dist/esm/index.rollup.debug.js +3 -0
- package/dist/esm/index.rollup.js +2 -0
- package/dist/esm/interfaces.js +8 -1
- package/dist/esm/observation/arrays.js +269 -0
- package/dist/esm/observation/notifier.js +75 -83
- package/dist/esm/observation/observable.js +80 -107
- package/dist/esm/observation/{array-change-records.js → splice-strategies.js} +136 -62
- package/dist/esm/observation/update-queue.js +67 -0
- package/dist/esm/platform.js +36 -42
- package/dist/esm/polyfills.js +85 -0
- package/dist/esm/styles/css-directive.js +29 -13
- package/dist/esm/styles/css.js +27 -40
- package/dist/esm/styles/element-styles.js +65 -104
- package/dist/esm/templating/binding.js +465 -155
- package/dist/esm/templating/children.js +33 -23
- package/dist/esm/templating/compiler.js +235 -152
- package/dist/esm/templating/dom.js +49 -0
- package/dist/esm/templating/html-directive.js +125 -40
- package/dist/esm/templating/markup.js +75 -0
- package/dist/esm/templating/node-observation.js +50 -45
- package/dist/esm/templating/ref.js +7 -16
- package/dist/esm/templating/repeat.js +38 -43
- package/dist/esm/templating/slotted.js +23 -20
- package/dist/esm/templating/template.js +71 -95
- package/dist/esm/templating/view.js +44 -43
- package/dist/esm/templating/when.js +2 -1
- package/dist/esm/utilities.js +139 -0
- package/dist/fast-element.api.json +14062 -5235
- package/dist/fast-element.d.ts +1434 -579
- package/dist/fast-element.debug.js +3824 -0
- package/dist/fast-element.debug.min.js +1 -0
- package/dist/fast-element.js +3565 -4014
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +2908 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/docs/api-report.md +590 -231
- package/docs/fast-element-2-changes.md +15 -0
- package/docs/guide/declaring-templates.md +5 -4
- package/docs/guide/defining-elements.md +3 -2
- package/docs/guide/leveraging-css.md +1 -0
- package/docs/guide/next-steps.md +3 -2
- package/docs/guide/observables-and-state.md +2 -1
- package/docs/guide/using-directives.md +2 -1
- package/docs/guide/working-with-shadow-dom.md +1 -0
- package/karma.conf.cjs +6 -17
- package/package.json +48 -14
- package/dist/dts/dom.d.ts +0 -112
- package/dist/dts/observation/array-change-records.d.ts +0 -48
- package/dist/dts/observation/array-observer.d.ts +0 -9
- package/dist/esm/dom.js +0 -207
- package/dist/esm/observation/array-observer.js +0 -173
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changes in FASTElement 2.0
|
|
2
|
+
|
|
3
|
+
## Breaking Changes
|
|
4
|
+
|
|
5
|
+
* `HTMLDirective` - The `targetIndex: number` property has been replaced by a `targetId: string` property. The `createBehavior` method no longer takes a target `Node` but instead takes a `BehaviorTargets` instance. The actual target can be looked up on the `BehaviorTargets` instance by indexing with the `targetId` property.
|
|
6
|
+
* `compileTemplate()` - Internals have been significantly changed. The implementation no longer uses a TreeWalker. The return type has change to an `HTMLTemplateCompilationResult` with different properties.
|
|
7
|
+
* `View` and `HTMLView` - Type parameters added to enable strongly typed views based on their data source. The constructor of `HTMLView` has a new signature based on changes to the compiler's output. Internals have been cleaned up and no longer rely on the Range type.
|
|
8
|
+
* `ElementViewTemplate`, `SyntheticViewTemplate`, and `ViewTemplate` - Added type parameters throughout. Logic to instantiate and apply behaviors moved out of the template and into the view where it can be lazily executed. Removed the ability of the `render` method to take a string id of the node to render to. You must provide a node.
|
|
9
|
+
* `DOM` - Tree Walker methods are no longer used and are thus removed. The API for removing child nodes has been removed as well since it was only used in one place and could be inlined. The helper `createCustomAttributePlaceholder()` no longer requires an attribute name. It will be uniquely generated internally.
|
|
10
|
+
* `class` - Bindings to `class` are now more nuanced. Binding directly to `class` will simply set the `className` property. If you need to bind to `class` knowing that manual JS will also manipulate the `classList` in addition to the binding, then you should now bind to `:classList` instead. This allows for performance optimizations in the simple, most common case.
|
|
11
|
+
* `Behavior` and `ViewBehavior` - `Behavior` now requires an `ExecutionContext` for `unbind`. Behaviors can be used for elements or views. `ViewBehavior` has been introduced for use exclusively with views, and provides some optimization opportunities.
|
|
12
|
+
* `RefBehavior` has been replaced with `RefDirective`. The directive also implements `ViewBehavior` allowing a single directive instance to be shared across all template instances that use the ref.
|
|
13
|
+
* Removed `SlottedBehavior` and `ChildrenBehavior` have been replaced with `SlottedDirective` and `ChildrenDirective`. These directives allow a single directive instance to be shared across all template instances that use the ref.
|
|
14
|
+
* Removed `AttachedBehaviorHTMLDirective` and `AttachedBehaviorType` since they are no longer used in the new directive/behavior architecture for ref, slotted, and children.
|
|
15
|
+
* Renamed `Notifier#source` to `Notifier#subject` to align with other observable terminology and prevent name clashes with `BindingObserver` properties.
|
|
@@ -3,6 +3,7 @@ id: declaring-templates
|
|
|
3
3
|
title: Declaring Templates
|
|
4
4
|
sidebar_label: Declaring Templates
|
|
5
5
|
custom_edit_url: https://github.com/microsoft/fast/edit/master/packages/web-components/fast-element/docs/guide/declaring-templates.md
|
|
6
|
+
description: While you can create and update nodes in the Shadow DOM manually, FASTElement provides a streamlined templating system for the most common rendering scenarios.
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
## Basic templates
|
|
@@ -143,7 +144,7 @@ When binding to `class`, the underlying engine will not over-write classes added
|
|
|
143
144
|
|
|
144
145
|
**Example: Nullish value**
|
|
145
146
|
|
|
146
|
-
Some cases may occur where an attribute needs to have a value when used however not present if unused. These are different than boolean attributes by where their presence alone triggers their effect. In this situation a nullish value (`null` or `undefined`) may be provided so the attribute won't exist in that condition.
|
|
147
|
+
Some cases may occur where an attribute needs to have a value when used however not present if unused. These are different than boolean attributes by where their presence alone triggers their effect. In this situation, a nullish value (`null` or `undefined`) may be provided so the attribute won't exist in that condition.
|
|
147
148
|
|
|
148
149
|
```html
|
|
149
150
|
<div aria-hidden="${x => x.isViewable ? 'true' : null}"></div>
|
|
@@ -217,13 +218,13 @@ The second example demonstrates an important characteristic of the templating en
|
|
|
217
218
|
It is during the `connectedCallback` phase of the Custom Element lifecycle that `FASTElement` creates templates and binds the resulting view. The creation of the template only occurs the first time the element is connected, while binding happens every time the element is connected (with unbinding happening during the `disconnectedCallback` for symmetry).
|
|
218
219
|
|
|
219
220
|
:::note
|
|
220
|
-
In the future we're planning new optimizations that will enable us to safely determine when we do not need to unbind/rebind certain views.
|
|
221
|
+
In the future, we're planning new optimizations that will enable us to safely determine when we do not need to unbind/rebind certain views.
|
|
221
222
|
:::
|
|
222
223
|
|
|
223
224
|
In most cases, the template that `FASTElement` renders is determined by the `template` property of the Custom Element's configuration. However, you can also implement a method on your Custom Element class named `resolveTemplate()` that returns a template instance. If this method is present, it will be called during `connectedCallback` to obtain the template to use. This allows the element author to dynamically select completely different templates based on the state of the element at the time of connection.
|
|
224
225
|
|
|
225
|
-
In addition to dynamic template selection during the `connectedCallback`, the `$fastController` property of `FASTElement` enables dynamically changing the template at any time
|
|
226
|
+
In addition to dynamic template selection during the `connectedCallback`, the `$fastController` property of `FASTElement` enables dynamically changing the template at any time by setting the controller's `template` property to any valid template.
|
|
226
227
|
|
|
227
228
|
:::tip
|
|
228
|
-
Check out [our Cheat Sheet](
|
|
229
|
+
Check out [our Cheat Sheet](../resources/cheat-sheet.md#bindings) for a quick guide on bindings.
|
|
229
230
|
:::
|
|
@@ -3,6 +3,7 @@ id: defining-elements
|
|
|
3
3
|
title: Defining Elements
|
|
4
4
|
sidebar_label: Defining Elements
|
|
5
5
|
custom_edit_url: https://github.com/microsoft/fast/edit/master/packages/web-components/fast-element/docs/guide/defining-elements.md
|
|
6
|
+
description: To define a custom element, begin by creating a class that extends FASTElement and decorate it with the @customElement decorator, providing the element name.
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
## Basic elements
|
|
@@ -57,7 +58,7 @@ export class NameTag extends FASTElement {
|
|
|
57
58
|
To add attributes to your HTML element, create properties decorated by the `@attr` decorator. All attributes defined this way will be automatically registered with the platform so that they can be updated through the browser's native `setAttribute` API as well as the property. You can optionally add a method with the naming convention *propertyName*Changed to your class (e.g. `greeting` and `greetingChanged()`), and this method will be called whenever your property changes, whether it changes through the property or the attribute API.
|
|
58
59
|
|
|
59
60
|
:::note
|
|
60
|
-
All properties decorated with `@attr` are also *observable*. See [observables and state](./observables-and-state) for information about how observables enable efficient rendering.
|
|
61
|
+
All properties decorated with `@attr` are also *observable*. See [observables and state](./observables-and-state.md) for information about how observables enable efficient rendering.
|
|
61
62
|
:::
|
|
62
63
|
|
|
63
64
|
By default, anything extending from `FASTElement` will automatically have a `ShadowRoot` attached in order to enable encapsulated rendering.
|
|
@@ -141,7 +142,7 @@ export class MyCounter extends FASTElement {
|
|
|
141
142
|
|
|
142
143
|
## The element lifecycle
|
|
143
144
|
|
|
144
|
-
All Web Components support a series of lifecycle events that you can tap into to execute custom code at specific points in time. `FASTElement` implements several of these callbacks automatically in order to enable features of its templating engine (described in [declaring templates](./declaring-templates)). However, you can override them to provide your own code. Here's an example of how you would execute custom code when your element is inserted into the DOM.
|
|
145
|
+
All Web Components support a series of lifecycle events that you can tap into to execute custom code at specific points in time. `FASTElement` implements several of these callbacks automatically in order to enable features of its templating engine (described in [declaring templates](./declaring-templates.md)). However, you can override them to provide your own code. Here's an example of how you would execute custom code when your element is inserted into the DOM.
|
|
145
146
|
|
|
146
147
|
**Example: Tapping into the Custom Element Lifecycle**
|
|
147
148
|
|
|
@@ -3,6 +3,7 @@ id: leveraging-css
|
|
|
3
3
|
title: Leveraging CSS
|
|
4
4
|
sidebar_label: Leveraging CSS
|
|
5
5
|
custom_edit_url: https://github.com/microsoft/fast/edit/master/packages/web-components/fast-element/docs/guide/leveraging-css.md
|
|
6
|
+
description: Similar to HTML, FASTElement provides a css tagged template helper to allow creating and re-using CSS.
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
## Basic styles
|
package/docs/guide/next-steps.md
CHANGED
|
@@ -3,10 +3,11 @@ id: next-steps
|
|
|
3
3
|
title: Next Steps
|
|
4
4
|
sidebar_label: Next Steps
|
|
5
5
|
custom_edit_url: https://github.com/microsoft/fast/edit/master/packages/web-components/fast-element/docs/guide/next-steps.md
|
|
6
|
+
description: Now that you're familiar with the robust and powerful features of FASTElement, you're ready to build your own components and apps.
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
We've seen how to use `FASTElement` to declaratively build Web Components. In addition to the basics of element and attribute definition, `FASTElement` also provides a way to declare templates capable of high-performance rendering, and efficient, incremental batched updates. Finally, CSS can easily be associated with an element in a way that leverages core platform optimizations for performance and low memory allocation.
|
|
9
10
|
|
|
10
|
-
Now that you're familiar with the robust and powerful features of `FASTElement`, you're ready to build your own components and apps. But you don't have to start from scratch there either! If you haven't already explored them, check out our [FAST Components](../components/getting-started), which provide all the basic UI building-blocks you'd expect in a modern component library. You can also leverage the same adaptive design system that our own components use to enable robust theming throughout all you create. Read more on that in [Styling Components](
|
|
11
|
+
Now that you're familiar with the robust and powerful features of `FASTElement`, you're ready to build your own components and apps. But you don't have to start from scratch there either! If you haven't already explored them, check out our [FAST Components](../components/getting-started.md), which provide all the basic UI building-blocks you'd expect in a modern component library. You can also leverage the same adaptive design system that our own components use to enable robust theming throughout all you create. Read more on that in [Styling Components](../design-systems/fast-frame.md#configuring-components). Finally, you'll want to take advantage of a modern toolset by installing [a powerful editor and plugins](../tools/vscode.md).
|
|
11
12
|
|
|
12
|
-
For a quick reference, check out [our Cheat Sheet](
|
|
13
|
+
For a quick reference, check out [our Cheat Sheet](../resources/cheat-sheet.md).
|
|
@@ -3,6 +3,7 @@ id: observables-and-state
|
|
|
3
3
|
title: Observables and State
|
|
4
4
|
sidebar_label: Observables and State
|
|
5
5
|
custom_edit_url: https://github.com/microsoft/fast/edit/master/packages/web-components/fast-element/docs/guide/observables-and-state.md
|
|
6
|
+
description: To enable binding tracking and change notification, properties must be decorated with either @attr or @observable.
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
## Reactivity
|
|
@@ -122,7 +123,7 @@ export class Person {
|
|
|
122
123
|
|
|
123
124
|
### External observation
|
|
124
125
|
|
|
125
|
-
Decorated properties can be subscribed to, to receive notification of changes in the property value. The templating engine uses this, but you can also directly subscribe
|
|
126
|
+
Decorated properties can be subscribed to, to receive notification of changes in the property value. The templating engine uses this, but you can also directly subscribe. Here's how you would subscribe to changes in the `name` property of a `Person` class:
|
|
126
127
|
|
|
127
128
|
**Example: Subscribing to an Observable**
|
|
128
129
|
|
|
@@ -3,6 +3,7 @@ id: using-directives
|
|
|
3
3
|
title: Using Directives
|
|
4
4
|
sidebar_label: Using Directives
|
|
5
5
|
custom_edit_url: https://github.com/microsoft/fast/edit/master/packages/web-components/fast-element/docs/guide/using-directives.md
|
|
6
|
+
description: In addition to declaring dynamic parts of templates with expressions, you also have access to several powerful directives, which aid in common scenarios.
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
In addition to declaring dynamic parts of templates with expressions, you also have access to several powerful *directives*, which aid in common scenarios.
|
|
@@ -508,7 +509,7 @@ If using the `subtree` option for `children` then a `selector` is *required* in
|
|
|
508
509
|
|
|
509
510
|
### The `slotted` directive
|
|
510
511
|
|
|
511
|
-
Sometimes you may want references to all nodes that are assigned to a particular slot. To accomplish this, use the `slotted` directive. (For more on slots, see [Working with Shadow DOM](./working-with-shadow-dom).)
|
|
512
|
+
Sometimes you may want references to all nodes that are assigned to a particular slot. To accomplish this, use the `slotted` directive. (For more on slots, see [Working with Shadow DOM](./working-with-shadow-dom.md).)
|
|
512
513
|
|
|
513
514
|
```ts
|
|
514
515
|
import { FASTElement, customElement, html, slotted } from '@microsoft/fast-element';
|
|
@@ -3,6 +3,7 @@ id: working-with-shadow-dom
|
|
|
3
3
|
title: Working with Shadow DOM
|
|
4
4
|
sidebar_label: Working with Shadow DOM
|
|
5
5
|
custom_edit_url: https://github.com/microsoft/fast/edit/master/packages/web-components/fast-element/docs/guide/working-with-shadow-dom.md
|
|
6
|
+
description: See how our custom elements can be composed together with standard HTML or other custom elements.
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
So far we've looked at how to define elements, how to define attributes on those elements, and how to control element rendering through declarative templates. However, we haven't yet seen how our custom elements can be composed together with standard HTML or other custom elements.
|
package/karma.conf.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
|
-
|
|
3
2
|
const basePath = path.resolve(__dirname);
|
|
4
3
|
|
|
5
4
|
const commonChromeFlags = [
|
|
@@ -44,9 +43,9 @@ module.exports = function (config) {
|
|
|
44
43
|
require("karma-chrome-launcher"),
|
|
45
44
|
require("karma-firefox-launcher"),
|
|
46
45
|
],
|
|
47
|
-
files: [`dist/esm/__test__/${setup}.
|
|
46
|
+
files: [`dist/esm/__test__/${setup}.cjs`],
|
|
48
47
|
preprocessors: {
|
|
49
|
-
[`dist/esm/__test__/${setup}.
|
|
48
|
+
[`dist/esm/__test__/${setup}.cjs`]: ["webpack", "sourcemap"],
|
|
50
49
|
},
|
|
51
50
|
webpackMiddleware: {
|
|
52
51
|
// webpack-dev-middleware configuration
|
|
@@ -54,7 +53,7 @@ module.exports = function (config) {
|
|
|
54
53
|
stats: "errors-only",
|
|
55
54
|
},
|
|
56
55
|
webpack: {
|
|
57
|
-
mode: "
|
|
56
|
+
mode: "development",
|
|
58
57
|
resolve: {
|
|
59
58
|
extensions: [".js"],
|
|
60
59
|
modules: ["dist", "node_modules"],
|
|
@@ -65,12 +64,8 @@ module.exports = function (config) {
|
|
|
65
64
|
hints: false,
|
|
66
65
|
},
|
|
67
66
|
optimization: {
|
|
68
|
-
namedModules: false,
|
|
69
|
-
namedChunks: false,
|
|
70
|
-
nodeEnv: false,
|
|
71
67
|
usedExports: true,
|
|
72
68
|
flagIncludedChunks: false,
|
|
73
|
-
occurrenceOrder: false,
|
|
74
69
|
sideEffects: true,
|
|
75
70
|
concatenateModules: true,
|
|
76
71
|
splitChunks: {
|
|
@@ -89,14 +84,8 @@ module.exports = function (config) {
|
|
|
89
84
|
},
|
|
90
85
|
{
|
|
91
86
|
test: /\.js$/,
|
|
92
|
-
use: [
|
|
93
|
-
|
|
94
|
-
loader: "source-map-loader",
|
|
95
|
-
options: {
|
|
96
|
-
enforce: "pre",
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
],
|
|
87
|
+
use: ["source-map-loader"],
|
|
88
|
+
enforce: "pre",
|
|
100
89
|
},
|
|
101
90
|
],
|
|
102
91
|
},
|
|
@@ -125,7 +114,7 @@ module.exports = function (config) {
|
|
|
125
114
|
timeout: 5000,
|
|
126
115
|
},
|
|
127
116
|
},
|
|
128
|
-
logLevel: config.LOG_ERROR, // to disable the WARN 404 for image requests
|
|
117
|
+
logLevel: config.LOG_ERROR, // to disable the WARN 404 for image requests,
|
|
129
118
|
};
|
|
130
119
|
|
|
131
120
|
if (config.coverage) {
|
package/package.json
CHANGED
|
@@ -1,24 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/fast-element",
|
|
3
3
|
"description": "A library for constructing Web Components",
|
|
4
|
-
"
|
|
5
|
-
"version": "1.10.0",
|
|
4
|
+
"version": "2.0.0-beta.1",
|
|
6
5
|
"author": {
|
|
7
6
|
"name": "Microsoft",
|
|
8
7
|
"url": "https://discord.gg/FcSNfg4"
|
|
9
8
|
},
|
|
9
|
+
"homepage": "https://www.fast.design/",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/Microsoft/fast.git"
|
|
13
|
+
"url": "git+https://github.com/Microsoft/fast.git",
|
|
14
|
+
"directory": "packages/web-components/fast-element"
|
|
14
15
|
},
|
|
15
16
|
"bugs": {
|
|
16
17
|
"url": "https://github.com/Microsoft/fast/issues/new/choose"
|
|
17
18
|
},
|
|
19
|
+
"type": "module",
|
|
18
20
|
"main": "dist/esm/index.js",
|
|
19
21
|
"types": "dist/fast-element.d.ts",
|
|
20
|
-
"
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/fast-element.d.ts",
|
|
25
|
+
"production": "./dist/esm/index.js",
|
|
26
|
+
"development": "./dist/esm/index.debug.js",
|
|
27
|
+
"default": "./dist/esm/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./polyfills": {
|
|
30
|
+
"types": "./dist/dts/polyfills.d.ts",
|
|
31
|
+
"default": "./dist/esm/polyfills.js"
|
|
32
|
+
},
|
|
33
|
+
"./debug": {
|
|
34
|
+
"types": "./dist/dts/debug.d.ts",
|
|
35
|
+
"default": "./dist/esm/debug.js"
|
|
36
|
+
},
|
|
37
|
+
"./splice-strategies": {
|
|
38
|
+
"types": "./dist/dts/observation/splice-strategies.d.ts",
|
|
39
|
+
"default": "./dist/esm/observation/splice-strategies.js"
|
|
40
|
+
},
|
|
41
|
+
"./utilities": {
|
|
42
|
+
"types": "./dist/dts/utilities.d.ts",
|
|
43
|
+
"default": "./dist/esm/utilities.js"
|
|
44
|
+
},
|
|
45
|
+
"./hooks": {
|
|
46
|
+
"types": "./dist/dts/hooks.d.ts",
|
|
47
|
+
"default": "./dist/esm/hooks.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
21
50
|
"unpkg": "dist/fast-element.min.js",
|
|
51
|
+
"sideEffects": [
|
|
52
|
+
"./dist/esm/debug.js",
|
|
53
|
+
"./dist/esm/polyfills.js"
|
|
54
|
+
],
|
|
22
55
|
"scripts": {
|
|
23
56
|
"clean:dist": "node ../../../build/clean.js dist",
|
|
24
57
|
"doc": "api-extractor run --local",
|
|
@@ -46,13 +79,14 @@
|
|
|
46
79
|
"test-firefox:verbose": "karma start karma.conf.cjs --browsers=FirefoxHeadless --single-run --coverage --reporter=mocha"
|
|
47
80
|
},
|
|
48
81
|
"devDependencies": {
|
|
49
|
-
"@microsoft/api-extractor": "7.
|
|
82
|
+
"@microsoft/api-extractor": "7.24.2",
|
|
50
83
|
"@types/chai": "^4.2.11",
|
|
84
|
+
"@types/chai-spies": "^1.0.3",
|
|
51
85
|
"@types/karma": "^5.0.0",
|
|
52
86
|
"@types/mocha": "^7.0.2",
|
|
53
87
|
"@types/webpack-env": "^1.15.2",
|
|
54
|
-
"@types/web-ie11": "^0.0.0",
|
|
55
88
|
"chai": "^4.2.0",
|
|
89
|
+
"chai-spies": "^1.0.0",
|
|
56
90
|
"esm": "^3.2.25",
|
|
57
91
|
"ignore-loader": "^0.1.2",
|
|
58
92
|
"istanbul": "^0.4.5",
|
|
@@ -68,21 +102,21 @@
|
|
|
68
102
|
"karma-mocha-reporter": "^2.2.5",
|
|
69
103
|
"karma-source-map-support": "^1.4.0",
|
|
70
104
|
"karma-sourcemap-loader": "^0.3.7",
|
|
71
|
-
"karma-webpack": "^
|
|
105
|
+
"karma-webpack": "^5.0.0",
|
|
72
106
|
"mocha": "^7.1.2",
|
|
73
107
|
"prettier": "2.0.2",
|
|
74
|
-
"rollup": "^2.
|
|
108
|
+
"rollup": "^2.71.1",
|
|
75
109
|
"rollup-plugin-filesize": "^9.1.2",
|
|
76
|
-
"rollup-plugin-terser": "^
|
|
77
|
-
"rollup
|
|
78
|
-
"rollup-plugin-typescript2": "^0.27.0",
|
|
110
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
111
|
+
"@rollup/plugin-typescript": "^8.3.2",
|
|
79
112
|
"source-map": "^0.7.3",
|
|
80
113
|
"source-map-loader": "^0.2.4",
|
|
81
114
|
"ts-loader": "^7.0.2",
|
|
82
115
|
"ts-node": "^8.9.1",
|
|
83
116
|
"tsconfig-paths": "^3.9.0",
|
|
84
|
-
"tslib": "^
|
|
85
|
-
"typescript": "^4.
|
|
86
|
-
"webpack": "^
|
|
117
|
+
"tslib": "^2.4.0",
|
|
118
|
+
"typescript": "^4.7.0",
|
|
119
|
+
"webpack": "^5.72.0",
|
|
120
|
+
"webpack-cli": "^4.9.2"
|
|
87
121
|
}
|
|
88
122
|
}
|
package/dist/dts/dom.d.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { Callable } from "./interfaces.js";
|
|
2
|
-
import { TrustedTypesPolicy } from "./platform.js";
|
|
3
|
-
/** @internal */
|
|
4
|
-
export declare const _interpolationStart: string;
|
|
5
|
-
/** @internal */
|
|
6
|
-
export declare const _interpolationEnd: string;
|
|
7
|
-
/**
|
|
8
|
-
* Common DOM APIs.
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export declare const DOM: Readonly<{
|
|
12
|
-
/**
|
|
13
|
-
* Indicates whether the DOM supports the adoptedStyleSheets feature.
|
|
14
|
-
*/
|
|
15
|
-
supportsAdoptedStyleSheets: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Sets the HTML trusted types policy used by the templating engine.
|
|
18
|
-
* @param policy - The policy to set for HTML.
|
|
19
|
-
* @remarks
|
|
20
|
-
* This API can only be called once, for security reasons. It should be
|
|
21
|
-
* called by the application developer at the start of their program.
|
|
22
|
-
*/
|
|
23
|
-
setHTMLPolicy(policy: TrustedTypesPolicy): void;
|
|
24
|
-
/**
|
|
25
|
-
* Turns a string into trusted HTML using the configured trusted types policy.
|
|
26
|
-
* @param html - The string to turn into trusted HTML.
|
|
27
|
-
* @remarks
|
|
28
|
-
* Used internally by the template engine when creating templates
|
|
29
|
-
* and setting innerHTML.
|
|
30
|
-
*/
|
|
31
|
-
createHTML(html: string): string;
|
|
32
|
-
/**
|
|
33
|
-
* Determines if the provided node is a template marker used by the runtime.
|
|
34
|
-
* @param node - The node to test.
|
|
35
|
-
*/
|
|
36
|
-
isMarker(node: Node): node is Comment;
|
|
37
|
-
/**
|
|
38
|
-
* Given a marker node, extract the {@link HTMLDirective} index from the placeholder.
|
|
39
|
-
* @param node - The marker node to extract the index from.
|
|
40
|
-
*/
|
|
41
|
-
extractDirectiveIndexFromMarker(node: Comment): number;
|
|
42
|
-
/**
|
|
43
|
-
* Creates a placeholder string suitable for marking out a location *within*
|
|
44
|
-
* an attribute value or HTML content.
|
|
45
|
-
* @param index - The directive index to create the placeholder for.
|
|
46
|
-
* @remarks
|
|
47
|
-
* Used internally by binding directives.
|
|
48
|
-
*/
|
|
49
|
-
createInterpolationPlaceholder(index: number): string;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a placeholder that manifests itself as an attribute on an
|
|
52
|
-
* element.
|
|
53
|
-
* @param attributeName - The name of the custom attribute.
|
|
54
|
-
* @param index - The directive index to create the placeholder for.
|
|
55
|
-
* @remarks
|
|
56
|
-
* Used internally by attribute directives such as `ref`, `slotted`, and `children`.
|
|
57
|
-
*/
|
|
58
|
-
createCustomAttributePlaceholder(attributeName: string, index: number): string;
|
|
59
|
-
/**
|
|
60
|
-
* Creates a placeholder that manifests itself as a marker within the DOM structure.
|
|
61
|
-
* @param index - The directive index to create the placeholder for.
|
|
62
|
-
* @remarks
|
|
63
|
-
* Used internally by structural directives such as `repeat`.
|
|
64
|
-
*/
|
|
65
|
-
createBlockPlaceholder(index: number): string;
|
|
66
|
-
/**
|
|
67
|
-
* Schedules DOM update work in the next async batch.
|
|
68
|
-
* @param callable - The callable function or object to queue.
|
|
69
|
-
*/
|
|
70
|
-
queueUpdate: (callable: Callable) => void;
|
|
71
|
-
/**
|
|
72
|
-
* Immediately processes all work previously scheduled
|
|
73
|
-
* through queueUpdate.
|
|
74
|
-
* @remarks
|
|
75
|
-
* This also forces nextUpdate promises
|
|
76
|
-
* to resolve.
|
|
77
|
-
*/
|
|
78
|
-
processUpdates: () => void;
|
|
79
|
-
/**
|
|
80
|
-
* Resolves with the next DOM update.
|
|
81
|
-
*/
|
|
82
|
-
nextUpdate(): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Sets an attribute value on an element.
|
|
85
|
-
* @param element - The element to set the attribute value on.
|
|
86
|
-
* @param attributeName - The attribute name to set.
|
|
87
|
-
* @param value - The value of the attribute to set.
|
|
88
|
-
* @remarks
|
|
89
|
-
* If the value is `null` or `undefined`, the attribute is removed, otherwise
|
|
90
|
-
* it is set to the provided value using the standard `setAttribute` API.
|
|
91
|
-
*/
|
|
92
|
-
setAttribute(element: HTMLElement, attributeName: string, value: any): void;
|
|
93
|
-
/**
|
|
94
|
-
* Sets a boolean attribute value.
|
|
95
|
-
* @param element - The element to set the boolean attribute value on.
|
|
96
|
-
* @param attributeName - The attribute name to set.
|
|
97
|
-
* @param value - The value of the attribute to set.
|
|
98
|
-
* @remarks
|
|
99
|
-
* If the value is true, the attribute is added; otherwise it is removed.
|
|
100
|
-
*/
|
|
101
|
-
setBooleanAttribute(element: HTMLElement, attributeName: string, value: boolean): void;
|
|
102
|
-
/**
|
|
103
|
-
* Removes all the child nodes of the provided parent node.
|
|
104
|
-
* @param parent - The node to remove the children from.
|
|
105
|
-
*/
|
|
106
|
-
removeChildNodes(parent: Node): void;
|
|
107
|
-
/**
|
|
108
|
-
* Creates a TreeWalker configured to walk a template fragment.
|
|
109
|
-
* @param fragment - The fragment to walk.
|
|
110
|
-
*/
|
|
111
|
-
createTemplateWalker(fragment: DocumentFragment): TreeWalker;
|
|
112
|
-
}>;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a set of splice-based changes against an Array.
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export interface Splice {
|
|
6
|
-
/**
|
|
7
|
-
* The index that the splice occurs at.
|
|
8
|
-
*/
|
|
9
|
-
index: number;
|
|
10
|
-
/**
|
|
11
|
-
* The items that were removed.
|
|
12
|
-
*/
|
|
13
|
-
removed: any[];
|
|
14
|
-
/**
|
|
15
|
-
* The number of items that were added.
|
|
16
|
-
*/
|
|
17
|
-
addedCount: number;
|
|
18
|
-
}
|
|
19
|
-
/** @internal */
|
|
20
|
-
export declare function newSplice(index: number, removed: any[], addedCount: number): Splice;
|
|
21
|
-
/**
|
|
22
|
-
* Splice Projection functions:
|
|
23
|
-
*
|
|
24
|
-
* A splice map is a representation of how a previous array of items
|
|
25
|
-
* was transformed into a new array of items. Conceptually it is a list of
|
|
26
|
-
* tuples of
|
|
27
|
-
*
|
|
28
|
-
* <index, removed, addedCount>
|
|
29
|
-
*
|
|
30
|
-
* which are kept in ascending index order of. The tuple represents that at
|
|
31
|
-
* the |index|, |removed| sequence of items were removed, and counting forward
|
|
32
|
-
* from |index|, |addedCount| items were added.
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
|
-
* @internal
|
|
36
|
-
* @remarks
|
|
37
|
-
* Lacking individual splice mutation information, the minimal set of
|
|
38
|
-
* splices can be synthesized given the previous state and final state of an
|
|
39
|
-
* array. The basic approach is to calculate the edit distance matrix and
|
|
40
|
-
* choose the shortest path through it.
|
|
41
|
-
*
|
|
42
|
-
* Complexity: O(l * p)
|
|
43
|
-
* l: The length of the current array
|
|
44
|
-
* p: The length of the old array
|
|
45
|
-
*/
|
|
46
|
-
export declare function calcSplices(current: any[], currentStart: number, currentEnd: number, old: any[], oldStart: number, oldEnd: number): ReadonlyArray<never> | Splice[];
|
|
47
|
-
/** @internal */
|
|
48
|
-
export declare function projectArraySplices(array: any[], changeRecords: any[]): Splice[];
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enables the array observation mechanism.
|
|
3
|
-
* @remarks
|
|
4
|
-
* Array observation is enabled automatically when using the
|
|
5
|
-
* {@link RepeatDirective}, so calling this API manually is
|
|
6
|
-
* not typically necessary.
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export declare function enableArrayObservation(): void;
|