@microsoft/fast-element 2.10.4 → 3.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -2
- package/README.md +244 -1
- package/dist/arrays/arrays.api.json +2621 -0
- package/dist/context/context.api.json +13 -13
- package/dist/declarative/declarative.api.json +8483 -0
- package/dist/di/di.api.json +16 -16
- package/dist/dts/__test__/helpers.d.ts +6 -0
- package/dist/dts/array-observer.d.ts +2 -0
- package/dist/dts/arrays.d.ts +2 -0
- package/dist/dts/attr.d.ts +1 -0
- package/dist/dts/binding/binding.d.ts +15 -5
- package/dist/dts/binding/one-time.d.ts +1 -1
- package/dist/dts/binding/one-way.d.ts +1 -1
- package/dist/dts/binding/signal.d.ts +6 -6
- package/dist/dts/binding/two-way.d.ts +2 -1
- package/dist/dts/binding.d.ts +7 -0
- package/dist/dts/components/attributes.d.ts +1 -4
- package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
- package/dist/dts/components/element-controller.d.ts +80 -114
- package/dist/dts/components/element-hydration.d.ts +1 -1
- package/dist/dts/components/enable-hydration.d.ts +54 -0
- package/dist/dts/components/fast-definitions.d.ts +98 -46
- package/dist/dts/components/fast-element.d.ts +43 -16
- package/dist/dts/components/hydration-tracker.d.ts +83 -0
- package/dist/dts/components/hydration.d.ts +23 -53
- package/dist/dts/components/schema.d.ts +205 -0
- package/dist/dts/context.d.ts +13 -13
- package/dist/dts/css.d.ts +3 -0
- package/dist/dts/debug.d.ts +5 -1
- package/dist/dts/declarative/attribute-map.d.ts +58 -0
- package/dist/dts/declarative/debug.d.ts +4 -0
- package/dist/dts/declarative/index.d.ts +14 -0
- package/dist/dts/declarative/interfaces.d.ts +8 -0
- package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
- package/dist/dts/declarative/observer-map.d.ts +89 -0
- package/dist/dts/declarative/runtime.d.ts +5 -0
- package/dist/dts/declarative/syntax.d.ts +21 -0
- package/dist/dts/declarative/template-bridge.d.ts +33 -0
- package/dist/dts/declarative/template-parser.d.ts +98 -0
- package/dist/dts/declarative/template.d.ts +10 -0
- package/dist/dts/declarative/utilities.d.ts +358 -0
- package/dist/dts/di/di.d.ts +7 -7
- package/dist/dts/directives/children.d.ts +2 -0
- package/dist/dts/directives/node-observation.d.ts +2 -0
- package/dist/dts/directives/ref.d.ts +2 -0
- package/dist/dts/directives/repeat.d.ts +4 -0
- package/dist/dts/directives/slotted.d.ts +2 -0
- package/dist/dts/directives/when.d.ts +3 -0
- package/dist/dts/dom-policy.d.ts +23 -5
- package/dist/dts/dom.d.ts +4 -16
- package/dist/dts/html.d.ts +5 -0
- package/dist/dts/hydration/diagnostics.d.ts +93 -0
- package/dist/dts/hydration/hydration-debugger.d.ts +35 -0
- package/dist/dts/hydration/messages.d.ts +62 -0
- package/dist/dts/hydration/runtime.d.ts +7 -0
- package/dist/dts/hydration/target-builder.d.ts +40 -12
- package/dist/dts/hydration.d.ts +18 -0
- package/dist/dts/index.d.ts +42 -42
- package/dist/dts/index.debug.d.ts +0 -1
- package/dist/dts/index.rollup.debug.d.ts +0 -1
- package/dist/dts/interfaces.d.ts +2 -49
- package/dist/dts/observable.d.ts +3 -6
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/observable.d.ts +3 -3
- package/dist/dts/observation/update-queue.d.ts +1 -1
- package/dist/dts/platform.d.ts +45 -8
- package/dist/dts/registry.d.ts +1 -0
- package/dist/dts/render.d.ts +7 -0
- package/dist/dts/schema.d.ts +1 -0
- package/dist/dts/state/exports.d.ts +1 -1
- package/dist/dts/state/state.d.ts +2 -2
- package/dist/dts/styles/css-directive.d.ts +5 -12
- package/dist/dts/styles/css.d.ts +5 -7
- package/dist/dts/styles/element-styles.d.ts +0 -10
- package/dist/dts/styles.d.ts +6 -0
- package/dist/dts/templating/compiler.d.ts +1 -1
- package/dist/dts/templating/html-binding-directive.d.ts +10 -2
- package/dist/dts/templating/html-directive.d.ts +19 -1
- package/dist/dts/templating/hydration-view.d.ts +130 -0
- package/dist/dts/templating/render.d.ts +1 -1
- package/dist/dts/templating/repeat.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +15 -7
- package/dist/dts/templating/view.d.ts +25 -102
- package/dist/dts/templating.d.ts +10 -0
- package/dist/dts/testing/exports.d.ts +2 -2
- package/dist/dts/testing/fakes.d.ts +4 -4
- package/dist/dts/updates.d.ts +1 -0
- package/dist/dts/volatile.d.ts +2 -0
- package/dist/esm/__test__/helpers.js +22 -0
- package/dist/esm/__test__/setup-node.js +18 -0
- package/dist/esm/array-observer.js +1 -0
- package/dist/esm/arrays.js +1 -0
- package/dist/esm/attr.js +1 -0
- package/dist/esm/binding/normalize.js +1 -1
- package/dist/esm/binding/signal.js +4 -4
- package/dist/esm/binding/two-way.js +3 -3
- package/dist/esm/binding.js +4 -0
- package/dist/esm/components/attributes.js +18 -11
- package/dist/esm/components/definition-schema-transforms.js +23 -0
- package/dist/esm/components/element-controller.js +206 -270
- package/dist/esm/components/element-hydration.js +1 -1
- package/dist/esm/components/enable-hydration.js +124 -0
- package/dist/esm/components/fast-definitions.js +219 -56
- package/dist/esm/components/fast-element.js +18 -27
- package/dist/esm/components/hydration-tracker.js +122 -0
- package/dist/esm/components/hydration.js +137 -140
- package/dist/esm/components/schema.js +253 -0
- package/dist/esm/context.js +6 -6
- package/dist/esm/css.js +3 -0
- package/dist/esm/debug.js +27 -26
- package/dist/esm/declarative/attribute-map.js +122 -0
- package/dist/esm/declarative/debug.js +4 -0
- package/dist/esm/declarative/index.js +4 -0
- package/dist/esm/declarative/interfaces.js +9 -0
- package/dist/esm/declarative/observer-map-utilities.js +565 -0
- package/dist/esm/declarative/observer-map.js +216 -0
- package/dist/esm/declarative/runtime.js +14 -0
- package/dist/esm/declarative/syntax.js +36 -0
- package/dist/esm/declarative/template-bridge.js +160 -0
- package/dist/esm/declarative/template-parser.js +306 -0
- package/dist/esm/declarative/template.js +143 -0
- package/dist/esm/declarative/utilities.js +1069 -0
- package/dist/esm/di/di.js +8 -9
- package/dist/esm/directives/children.js +1 -0
- package/dist/esm/directives/node-observation.js +1 -0
- package/dist/esm/directives/ref.js +1 -0
- package/dist/esm/directives/repeat.js +1 -0
- package/dist/esm/directives/slotted.js +1 -0
- package/dist/esm/directives/when.js +1 -0
- package/dist/esm/dom-policy.js +35 -6
- package/dist/esm/dom.js +1 -1
- package/dist/esm/html.js +2 -0
- package/dist/esm/hydration/diagnostics.js +50 -0
- package/dist/esm/hydration/hydration-debugger.js +112 -0
- package/dist/esm/hydration/messages.js +84 -0
- package/dist/esm/hydration/runtime.js +33 -0
- package/dist/esm/hydration/target-builder.js +144 -91
- package/dist/esm/hydration.js +6 -0
- package/dist/esm/index.debug.js +2 -1
- package/dist/esm/index.js +38 -29
- package/dist/esm/index.rollup.debug.js +3 -2
- package/dist/esm/index.rollup.js +1 -1
- package/dist/esm/interfaces.js +2 -45
- package/dist/esm/metadata.js +2 -8
- package/dist/esm/observable.js +1 -4
- package/dist/esm/observation/arrays.js +1 -1
- package/dist/esm/observation/notifier.js +2 -4
- package/dist/esm/observation/observable.js +5 -5
- package/dist/esm/observation/update-queue.js +47 -58
- package/dist/esm/platform.js +31 -30
- package/dist/esm/registry.js +1 -0
- package/dist/esm/render.js +1 -0
- package/dist/esm/schema.js +1 -0
- package/dist/esm/state/exports.js +1 -1
- package/dist/esm/styles/css-directive.js +1 -2
- package/dist/esm/styles/css.js +15 -56
- package/dist/esm/styles/element-styles.js +69 -15
- package/dist/esm/styles.js +2 -0
- package/dist/esm/templating/html-binding-directive.js +11 -9
- package/dist/esm/templating/hydration-view.js +228 -0
- package/dist/esm/templating/render.js +39 -18
- package/dist/esm/templating/repeat.js +69 -33
- package/dist/esm/templating/template.js +7 -7
- package/dist/esm/templating/view.js +25 -234
- package/dist/esm/templating.js +7 -0
- package/dist/esm/testing/exports.js +2 -2
- package/dist/esm/testing/fixture.js +2 -2
- package/dist/esm/testing/timeout.js +2 -2
- package/dist/esm/updates.js +1 -0
- package/dist/esm/volatile.js +1 -0
- package/dist/fast-element.api.json +14389 -11138
- package/dist/fast-element.d.ts +3651 -809
- package/dist/fast-element.debug.js +5666 -4722
- package/dist/fast-element.debug.min.js +2 -2
- package/dist/fast-element.js +5394 -4381
- package/dist/fast-element.min.js +2 -2
- package/dist/fast-element.untrimmed.d.ts +923 -472
- package/dist/hydration/hydration.api.json +6460 -0
- package/dist/styles/styles.api.json +2672 -0
- package/package.json +165 -45
- package/ARCHITECTURE_FASTELEMENT.md +0 -63
- package/ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md +0 -36
- package/ARCHITECTURE_INTRO.md +0 -10
- package/ARCHITECTURE_OVERVIEW.md +0 -52
- package/ARCHITECTURE_UPDATES.md +0 -11
- package/CHANGELOG.json +0 -2275
- package/DESIGN.md +0 -510
- package/api-extractor.context.json +0 -14
- package/api-extractor.di.json +0 -14
- package/biome.json +0 -4
- package/dist/dts/components/install-hydration.d.ts +0 -1
- package/dist/dts/pending-task.d.ts +0 -32
- package/dist/dts/styles/css-binding-directive.d.ts +0 -60
- package/dist/dts/templating/install-hydratable-view-templates.d.ts +0 -1
- package/dist/esm/components/install-hydration.js +0 -3
- package/dist/esm/pending-task.js +0 -28
- package/dist/esm/polyfills.js +0 -60
- package/dist/esm/styles/css-binding-directive.js +0 -76
- package/dist/esm/templating/install-hydratable-view-templates.js +0 -23
- package/docs/ACKNOWLEDGEMENTS.md +0 -12
- package/docs/api-report.api.md +0 -1122
- package/docs/context/api-report.api.md +0 -69
- package/docs/di/api-report.api.md +0 -315
- package/docs/fast-element-2-changes.md +0 -15
- package/playwright.config.ts +0 -26
- package/scripts/run-api-extractor.js +0 -51
- package/test/index.html +0 -11
- package/test/main.ts +0 -104
- package/test/vite.config.ts +0 -19
- package/tsconfig.api-extractor.json +0 -6
- /package/dist/dts/{polyfills.d.ts → __test__/setup-node.d.ts} +0 -0
package/dist/esm/pending-task.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A concrete implementation of {@link PendingTask}
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export class PendingTaskEvent extends Event {
|
|
6
|
-
/**
|
|
7
|
-
* Creates an instance of PendingTaskEvent.
|
|
8
|
-
* @param complete - A promise that resolves when the pending task is complete.
|
|
9
|
-
*/
|
|
10
|
-
constructor(complete) {
|
|
11
|
-
super(PendingTaskEvent.type, { bubbles: true, composed: true });
|
|
12
|
-
this.complete = complete;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Determines whether a value is a PendingTaskEvent.
|
|
16
|
-
* @param value - The value to check.
|
|
17
|
-
* @returns True if the value is a PendingTaskEvent; false otherwise.
|
|
18
|
-
*/
|
|
19
|
-
static isPendingTask(value) {
|
|
20
|
-
var _a;
|
|
21
|
-
return (value.type === PendingTaskEvent.type &&
|
|
22
|
-
typeof ((_a = value.complete) === null || _a === void 0 ? void 0 : _a.then) === "function");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The type of the pending task event.
|
|
27
|
-
*/
|
|
28
|
-
PendingTaskEvent.type = "pending-task";
|
package/dist/esm/polyfills.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
-
(function ensureGlobalThis() {
|
|
3
|
-
if (typeof globalThis !== "undefined") {
|
|
4
|
-
// We're running in a modern environment.
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
if (typeof global !== "undefined") {
|
|
9
|
-
// We're running in NodeJS
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
global.globalThis = global;
|
|
12
|
-
}
|
|
13
|
-
else if (typeof self !== "undefined") {
|
|
14
|
-
self.globalThis = self;
|
|
15
|
-
}
|
|
16
|
-
else if (typeof window !== "undefined") {
|
|
17
|
-
// We're running in the browser's main thread.
|
|
18
|
-
window.globalThis = window;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
// Hopefully we never get here...
|
|
22
|
-
// Not all environments allow eval and Function. Use only as a last resort:
|
|
23
|
-
// eslint-disable-next-line no-new-func
|
|
24
|
-
const result = new Function("return this")();
|
|
25
|
-
result.globalThis = result;
|
|
26
|
-
}
|
|
27
|
-
})();
|
|
28
|
-
(function requestIdleCallbackPolyfill() {
|
|
29
|
-
if ("requestIdleCallback" in globalThis) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A polyfill for requestIdleCallback that falls back to setTimeout.
|
|
34
|
-
*
|
|
35
|
-
* @param callback - The function to call when the browser is idle.
|
|
36
|
-
* @param options - Options object that may contain a timeout property.
|
|
37
|
-
* @returns An ID that can be used to cancel the callback.
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
globalThis.requestIdleCallback = function requestIdleCallback(callback, options) {
|
|
41
|
-
const start = Date.now();
|
|
42
|
-
return setTimeout(() => {
|
|
43
|
-
callback({
|
|
44
|
-
didTimeout: (options === null || options === void 0 ? void 0 : options.timeout)
|
|
45
|
-
? Date.now() - start >= options.timeout
|
|
46
|
-
: false,
|
|
47
|
-
timeRemaining: () => 0,
|
|
48
|
-
});
|
|
49
|
-
}, 1);
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* A polyfill for cancelIdleCallback that falls back to clearTimeout.
|
|
53
|
-
*
|
|
54
|
-
* @param id - The ID of the callback to cancel.
|
|
55
|
-
* @public
|
|
56
|
-
*/
|
|
57
|
-
globalThis.cancelIdleCallback = function cancelIdleCallback(id) {
|
|
58
|
-
clearTimeout(id);
|
|
59
|
-
};
|
|
60
|
-
})();
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { CSSDirective } from "./css-directive.js";
|
|
2
|
-
function handleChange(directive, controller, observer) {
|
|
3
|
-
controller.source.style.setProperty(directive.targetAspect, observer.bind(controller));
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Enables bindings in CSS.
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export class CSSBindingDirective {
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of CSSBindingDirective.
|
|
13
|
-
* @param dataBinding - The binding to use in CSS.
|
|
14
|
-
* @param targetAspect - The CSS property to target.
|
|
15
|
-
*/
|
|
16
|
-
constructor(dataBinding, targetAspect) {
|
|
17
|
-
this.dataBinding = dataBinding;
|
|
18
|
-
this.targetAspect = targetAspect;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Creates a CSS fragment to interpolate into the CSS document.
|
|
22
|
-
* @returns - the string to interpolate into CSS
|
|
23
|
-
*/
|
|
24
|
-
createCSS(add) {
|
|
25
|
-
add(this);
|
|
26
|
-
return `var(${this.targetAspect})`;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Executed when this behavior is attached to a controller.
|
|
30
|
-
* @param controller - Controls the behavior lifecycle.
|
|
31
|
-
*/
|
|
32
|
-
addedCallback(controller) {
|
|
33
|
-
var _a;
|
|
34
|
-
const element = controller.source;
|
|
35
|
-
if (!element.$cssBindings) {
|
|
36
|
-
element.$cssBindings = new Map();
|
|
37
|
-
const setAttribute = element.setAttribute;
|
|
38
|
-
element.setAttribute = (attr, value) => {
|
|
39
|
-
setAttribute.call(element, attr, value);
|
|
40
|
-
if (attr === "style") {
|
|
41
|
-
element.$cssBindings.forEach((v, k) => handleChange(k, v.controller, v.observer));
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
const observer = (_a = controller[this.targetAspect]) !== null && _a !== void 0 ? _a : (controller[this.targetAspect] = this.dataBinding.createObserver(this, this));
|
|
46
|
-
observer.controller = controller;
|
|
47
|
-
controller.source.$cssBindings.set(this, { controller, observer });
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Executed when this behavior's host is connected.
|
|
51
|
-
* @param controller - Controls the behavior lifecycle.
|
|
52
|
-
*/
|
|
53
|
-
connectedCallback(controller) {
|
|
54
|
-
handleChange(this, controller, controller[this.targetAspect]);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Executed when this behavior is detached from a controller.
|
|
58
|
-
* @param controller - Controls the behavior lifecycle.
|
|
59
|
-
*/
|
|
60
|
-
removedCallback(controller) {
|
|
61
|
-
if (controller.source.$cssBindings) {
|
|
62
|
-
controller.source.$cssBindings.delete(this);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Called when a subject this instance has subscribed to changes.
|
|
67
|
-
* @param subject - The subject of the change.
|
|
68
|
-
* @param args - The event args detailing the change that occurred.
|
|
69
|
-
*
|
|
70
|
-
* @internal
|
|
71
|
-
*/
|
|
72
|
-
handleChange(_, observer) {
|
|
73
|
-
handleChange(this, observer.controller, observer);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
CSSDirective.define(CSSBindingDirective);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Hydratable } from "../components/hydration.js";
|
|
2
|
-
import { ViewTemplate } from "./template.js";
|
|
3
|
-
import { HydrationView } from "./view.js";
|
|
4
|
-
// Configure ViewTemplate to be hydratable by attaching a symbol identifier
|
|
5
|
-
// and a hydrate method. Augmenting the hydration features is done by
|
|
6
|
-
// property assignment instead of class extension to better allow the
|
|
7
|
-
// hydration feature to be tree-shaken.
|
|
8
|
-
//
|
|
9
|
-
// When hydrate() is called, it creates a HydrationView that wraps the
|
|
10
|
-
// pre-rendered DOM range (firstChild → lastChild) instead of cloning a
|
|
11
|
-
// compiled DocumentFragment. The HydrationView will then use
|
|
12
|
-
// buildViewBindingTargets() to scan for hydration markers and attach
|
|
13
|
-
// reactive bindings to the existing DOM nodes.
|
|
14
|
-
Object.defineProperties(ViewTemplate.prototype, {
|
|
15
|
-
[Hydratable]: { value: Hydratable, enumerable: false, configurable: false },
|
|
16
|
-
hydrate: {
|
|
17
|
-
value: function (firstChild, lastChild, hostBindingTarget) {
|
|
18
|
-
return new HydrationView(firstChild, lastChild, this, hostBindingTarget);
|
|
19
|
-
},
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: false,
|
|
22
|
-
},
|
|
23
|
-
});
|
package/docs/ACKNOWLEDGEMENTS.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Acknowledgements
|
|
2
|
-
|
|
3
|
-
There are many great open source projects that have inspired us and enabled us to build FAST. Below are a few that stand out.
|
|
4
|
-
|
|
5
|
-
* [.NET](https://dotnet.microsoft.com/) - Many thanks to the .NET team for sharing their policies and practices upon which our issue management and release planning docs and practices were based.
|
|
6
|
-
* [asap](https://github.com/kriskowal/asap) - An awesome, time-tested async task queue implementation that heavily inspired our DOM update system.
|
|
7
|
-
* [Aurelia 1 and Aurelia 2](https://aurelia.io/) - Various details of Aurelia 2's decorator and metadata model inspired us in the design of `fast-element`. Additionally, Aurelia 1's mechanisms for array observation, binding, and template compilation also guided us in our work.
|
|
8
|
-
* [faastjs](https://github.com/faastjs) - A project with a similar name but a very different purpose. Their API documentation approach leveraging [api-extractor](https://api-extractor.com/) was a huge help to us.
|
|
9
|
-
* [Knockout](https://knockoutjs.com/) - One of the first JavaScript libraries (if not the first) to implement an observer system. The original techniques for observables and computed observables have influenced many libraries over the years. Re-interpreting these ideas in terms of modern JavaScript and DOM has helped us to build a powerful and robust system.
|
|
10
|
-
* [lit-html](https://lit-html.polymer-project.org/) - One of the first libraries to leverage standard JavaScript tagged template literals for HTML templates. We were inspired by this technique and wanted to explore whether it could be combined with our idea of arrow function binding expressions.
|
|
11
|
-
* [Polymer](https://www.polymer-project.org/) - One of the first libraries (if not the first) to embrace Web Components.
|
|
12
|
-
* [Vue](https://vuejs.org/) - We liked the terseness of the `:` and `@` syntax in templates, so we adapted it along with some modifications in our templates.
|