@microsoft/fast-element 2.0.0-beta.5 → 2.0.0-beta.7
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.json +72 -0
- package/CHANGELOG.md +24 -1
- package/dist/dts/components/attributes.d.ts +10 -0
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +24 -25
- package/dist/dts/components/fast-definitions.d.ts +28 -3
- package/dist/dts/components/fast-element.d.ts +2 -2
- package/dist/dts/di/di.d.ts +41 -0
- package/dist/dts/index.d.ts +2 -2
- package/dist/dts/interfaces.d.ts +4 -0
- package/dist/dts/observation/observable.d.ts +86 -47
- package/dist/dts/pending-task.d.ts +20 -0
- package/dist/dts/platform.d.ts +6 -0
- package/dist/dts/state/exports.d.ts +3 -0
- package/dist/dts/state/reactive.d.ts +8 -0
- package/dist/dts/state/state.d.ts +141 -0
- package/dist/dts/state/visitor.d.ts +6 -0
- package/dist/dts/state/watch.d.ts +10 -0
- package/dist/dts/styles/css-directive.d.ts +2 -2
- package/dist/dts/styles/element-styles.d.ts +3 -3
- package/dist/dts/styles/host.d.ts +68 -0
- package/dist/dts/templating/binding-signal.d.ts +2 -2
- package/dist/dts/templating/binding-two-way.d.ts +11 -3
- package/dist/dts/templating/binding.d.ts +21 -119
- package/dist/dts/templating/children.d.ts +1 -1
- package/dist/dts/templating/html-directive.d.ts +69 -39
- package/dist/dts/templating/node-observation.d.ts +4 -5
- package/dist/dts/templating/ref.d.ts +5 -13
- package/dist/dts/templating/render.d.ts +15 -20
- package/dist/dts/templating/repeat.d.ts +11 -16
- package/dist/dts/templating/slotted.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +4 -4
- package/dist/dts/templating/view.d.ts +68 -9
- package/dist/dts/templating/when.d.ts +1 -1
- package/dist/dts/testing/exports.d.ts +1 -0
- package/dist/dts/testing/fakes.d.ts +4 -0
- package/dist/dts/testing/fixture.d.ts +0 -6
- package/dist/dts/utilities.d.ts +0 -18
- package/dist/esm/components/attributes.js +13 -4
- package/dist/esm/components/{controller.js → element-controller.js} +95 -105
- package/dist/esm/components/fast-definitions.js +3 -1
- package/dist/esm/components/fast-element.js +4 -4
- package/dist/esm/di/di.js +87 -3
- package/dist/esm/index.js +2 -1
- package/dist/esm/interfaces.js +4 -0
- package/dist/esm/observation/observable.js +59 -126
- package/dist/esm/pending-task.js +16 -0
- package/dist/esm/platform.js +21 -0
- package/dist/esm/state/exports.js +3 -0
- package/dist/esm/state/reactive.js +34 -0
- package/dist/esm/state/state.js +148 -0
- package/dist/esm/state/visitor.js +28 -0
- package/dist/esm/state/watch.js +36 -0
- package/dist/esm/styles/css.js +4 -4
- package/dist/esm/{observation/behavior.js → styles/host.js} +0 -0
- package/dist/esm/templating/binding-signal.js +21 -17
- package/dist/esm/templating/binding-two-way.js +32 -27
- package/dist/esm/templating/binding.js +73 -177
- package/dist/esm/templating/html-directive.js +78 -7
- package/dist/esm/templating/node-observation.js +9 -8
- package/dist/esm/templating/ref.js +4 -12
- package/dist/esm/templating/render.js +30 -31
- package/dist/esm/templating/repeat.js +37 -38
- package/dist/esm/templating/template.js +3 -4
- package/dist/esm/templating/view.js +96 -24
- package/dist/esm/testing/exports.js +1 -0
- package/dist/esm/testing/fakes.js +76 -0
- package/dist/esm/testing/fixture.js +1 -3
- package/dist/esm/utilities.js +0 -95
- package/dist/fast-element.api.json +5720 -5385
- package/dist/fast-element.d.ts +510 -399
- package/dist/fast-element.debug.js +492 -509
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +492 -509
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +519 -405
- package/docs/api-report.md +197 -129
- package/package.json +8 -4
- package/dist/dts/hooks.d.ts +0 -20
- package/dist/dts/observation/behavior.d.ts +0 -19
- package/dist/esm/hooks.js +0 -32
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/fast-element",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Fri, 23 Sep 2022 22:53:27 GMT",
|
|
6
|
+
"tag": "@microsoft/fast-element_v2.0.0-beta.7",
|
|
7
|
+
"version": "2.0.0-beta.7",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "roeisenb@microsoft.com",
|
|
12
|
+
"package": "@microsoft/fast-element",
|
|
13
|
+
"commit": "1646b26450a08a77c8bd6302560fe12cc6989ae1",
|
|
14
|
+
"comment": "feat: improve parent typing and fix repeat context type bug"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "roeisenb@microsoft.com",
|
|
18
|
+
"package": "@microsoft/fast-element",
|
|
19
|
+
"commit": "0d786392a38e1d83e56fb1e2112a3e571d193c11",
|
|
20
|
+
"comment": "feat: prepare fast-element for scoped element registries"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "wendywendy@microsoft.com",
|
|
24
|
+
"package": "@microsoft/fast-element",
|
|
25
|
+
"commit": "a42ff75a9130a5ce13006c272c2e2bbbaffdbb41",
|
|
26
|
+
"comment": "persist totalAvailableViews to compare against removeIndex"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "863023+radium-v@users.noreply.github.com",
|
|
30
|
+
"package": "@microsoft/fast-element",
|
|
31
|
+
"commit": "ec2b158dcf39c8b4152b22c3b65963046b473e17",
|
|
32
|
+
"comment": "make ElementsFilter type arguments optional"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "roeisenb@microsoft.com",
|
|
36
|
+
"package": "@microsoft/fast-element",
|
|
37
|
+
"commit": "1039218eafa9a8dbea9da94e1c7803de48d1484c",
|
|
38
|
+
"comment": "fix(fast-element): attributes properly located in inheritance hierarchy"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"author": "nicholasrice@users.noreply.github.com",
|
|
42
|
+
"package": "@microsoft/fast-element",
|
|
43
|
+
"commit": "c1909e9899d517f9483b24043d49a8b193af3c26",
|
|
44
|
+
"comment": "Adds PendingTask community protocol"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"author": "roeisenb@microsoft.com",
|
|
48
|
+
"package": "@microsoft/fast-element",
|
|
49
|
+
"commit": "2edd63a8abe24c68cfc7c76d773c912c6f2d6543",
|
|
50
|
+
"comment": "feat: new behavior and context API design"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"author": "roeisenb@microsoft.com",
|
|
54
|
+
"package": "@microsoft/fast-element",
|
|
55
|
+
"commit": "eb62934b258334c7f92ab3a1112ea62b3901cdac",
|
|
56
|
+
"comment": "feat: implement getAsync code path for dependency injection"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"date": "Thu, 01 Sep 2022 21:53:34 GMT",
|
|
63
|
+
"tag": "@microsoft/fast-element_v2.0.0-beta.6",
|
|
64
|
+
"version": "2.0.0-beta.6",
|
|
65
|
+
"comments": {
|
|
66
|
+
"prerelease": [
|
|
67
|
+
{
|
|
68
|
+
"author": "roeisenb@microsoft.com",
|
|
69
|
+
"package": "@microsoft/fast-element",
|
|
70
|
+
"commit": "da9ebbe1b7471cd4e6f7b74f2f9bf02fcc54da4f",
|
|
71
|
+
"comment": "feat: add new state, ownedState, and computedState APIs"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
4
76
|
{
|
|
5
77
|
"date": "Thu, 18 Aug 2022 20:46:10 GMT",
|
|
6
78
|
"tag": "@microsoft/fast-element_v2.0.0-beta.5",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
# Change Log - @microsoft/fast-element
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 23 Sep 2022 22:53:27 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 2.0.0-beta.7
|
|
8
|
+
|
|
9
|
+
Fri, 23 Sep 2022 22:53:27 GMT
|
|
10
|
+
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- feat: improve parent typing and fix repeat context type bug (roeisenb@microsoft.com)
|
|
14
|
+
- feat: prepare fast-element for scoped element registries (roeisenb@microsoft.com)
|
|
15
|
+
- persist totalAvailableViews to compare against removeIndex (wendywendy@microsoft.com)
|
|
16
|
+
- make ElementsFilter type arguments optional (863023+radium-v@users.noreply.github.com)
|
|
17
|
+
- fix(fast-element): attributes properly located in inheritance hierarchy (roeisenb@microsoft.com)
|
|
18
|
+
- Adds PendingTask community protocol (nicholasrice@users.noreply.github.com)
|
|
19
|
+
- feat: new behavior and context API design (roeisenb@microsoft.com)
|
|
20
|
+
- feat: implement getAsync code path for dependency injection (roeisenb@microsoft.com)
|
|
21
|
+
|
|
22
|
+
## 2.0.0-beta.6
|
|
23
|
+
|
|
24
|
+
Thu, 01 Sep 2022 21:53:34 GMT
|
|
25
|
+
|
|
26
|
+
### Changes
|
|
27
|
+
|
|
28
|
+
- feat: add new state, ownedState, and computedState APIs (roeisenb@microsoft.com)
|
|
29
|
+
|
|
7
30
|
## 2.0.0-beta.5
|
|
8
31
|
|
|
9
32
|
Thu, 18 Aug 2022 20:46:10 GMT
|
|
@@ -40,6 +40,16 @@ export declare type AttributeConfiguration = {
|
|
|
40
40
|
mode?: AttributeMode;
|
|
41
41
|
converter?: ValueConverter;
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Metadata used to configure a custom attribute's behavior.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare const AttributeConfiguration: Readonly<{
|
|
48
|
+
/**
|
|
49
|
+
* Locates all attribute configurations associated with a type.
|
|
50
|
+
*/
|
|
51
|
+
locate: (target: {}) => AttributeConfiguration[];
|
|
52
|
+
}>;
|
|
43
53
|
/**
|
|
44
54
|
* Metadata used to configure a custom attribute's behavior through a decorator.
|
|
45
55
|
* @public
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostBehavior, HostController } from "../styles/host.js";
|
|
2
2
|
import { PropertyChangeNotifier } from "../observation/notifier.js";
|
|
3
|
-
import type { ElementStyles } from "../styles/element-styles.js";
|
|
4
3
|
import type { ElementViewTemplate } from "../templating/template.js";
|
|
5
4
|
import type { ElementView } from "../templating/view.js";
|
|
5
|
+
import type { ElementStyles } from "../styles/element-styles.js";
|
|
6
6
|
import { FASTElementDefinition } from "./fast-definitions.js";
|
|
7
7
|
/**
|
|
8
8
|
* Controls the lifecycle and rendering of a `FASTElement`.
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class ElementController<TElement extends HTMLElement = HTMLElement> extends PropertyChangeNotifier implements HostController<TElement> {
|
|
12
12
|
private boundObservables;
|
|
13
|
-
private behaviors;
|
|
14
13
|
private needsInitialization;
|
|
15
14
|
private hasExistingShadowRoot;
|
|
16
15
|
private _template;
|
|
17
|
-
private _styles;
|
|
18
16
|
private _isConnected;
|
|
17
|
+
private behaviors;
|
|
18
|
+
private _mainStyles;
|
|
19
19
|
/**
|
|
20
20
|
* This allows Observable.getNotifier(...) to return the Controller
|
|
21
21
|
* when the notifier for the Controller itself is being requested. The
|
|
@@ -28,7 +28,7 @@ export declare class Controller<TElement extends HTMLElement = HTMLElement> exte
|
|
|
28
28
|
/**
|
|
29
29
|
* The element being controlled by this controller.
|
|
30
30
|
*/
|
|
31
|
-
readonly
|
|
31
|
+
readonly source: TElement;
|
|
32
32
|
/**
|
|
33
33
|
* The element definition that instructs this controller
|
|
34
34
|
* in how to handle rendering and other platform integrations.
|
|
@@ -54,12 +54,11 @@ export declare class Controller<TElement extends HTMLElement = HTMLElement> exte
|
|
|
54
54
|
get template(): ElementViewTemplate<TElement> | null;
|
|
55
55
|
set template(value: ElementViewTemplate<TElement> | null);
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* This value can only be accurately read after connect but can be set at any time.
|
|
57
|
+
* The main set of styles used for the component, independent
|
|
58
|
+
* of any dynamically added styles.
|
|
60
59
|
*/
|
|
61
|
-
get
|
|
62
|
-
set
|
|
60
|
+
get mainStyles(): ElementStyles | null;
|
|
61
|
+
set mainStyles(value: ElementStyles | null);
|
|
63
62
|
/**
|
|
64
63
|
* Creates a Controller to control the specified element.
|
|
65
64
|
* @param element - The element to be controlled by this controller.
|
|
@@ -68,6 +67,17 @@ export declare class Controller<TElement extends HTMLElement = HTMLElement> exte
|
|
|
68
67
|
* @internal
|
|
69
68
|
*/
|
|
70
69
|
constructor(element: TElement, definition: FASTElementDefinition);
|
|
70
|
+
/**
|
|
71
|
+
* Adds the behavior to the component.
|
|
72
|
+
* @param behavior - The behavior to add.
|
|
73
|
+
*/
|
|
74
|
+
addBehavior(behavior: HostBehavior<TElement>): void;
|
|
75
|
+
/**
|
|
76
|
+
* Removes the behavior from the component.
|
|
77
|
+
* @param behavior - The behavior to remove.
|
|
78
|
+
* @param force - Forces removal even if this behavior was added more than once.
|
|
79
|
+
*/
|
|
80
|
+
removeBehavior(behavior: HostBehavior<TElement>, force?: boolean): void;
|
|
71
81
|
/**
|
|
72
82
|
* Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
|
|
73
83
|
* @param styles - The styles to add.
|
|
@@ -78,25 +88,14 @@ export declare class Controller<TElement extends HTMLElement = HTMLElement> exte
|
|
|
78
88
|
* @param styles - the styles to remove.
|
|
79
89
|
*/
|
|
80
90
|
removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
|
|
81
|
-
/**
|
|
82
|
-
* Adds behaviors to this element.
|
|
83
|
-
* @param behaviors - The behaviors to add.
|
|
84
|
-
*/
|
|
85
|
-
addBehaviors(behaviors: ReadonlyArray<Behavior<TElement>>): void;
|
|
86
|
-
/**
|
|
87
|
-
* Removes behaviors from this element.
|
|
88
|
-
* @param behaviors - The behaviors to remove.
|
|
89
|
-
* @param force - Forces unbinding of behaviors.
|
|
90
|
-
*/
|
|
91
|
-
removeBehaviors(behaviors: ReadonlyArray<Behavior<TElement>>, force?: boolean): void;
|
|
92
91
|
/**
|
|
93
92
|
* Runs connected lifecycle behavior on the associated element.
|
|
94
93
|
*/
|
|
95
|
-
|
|
94
|
+
connect(): void;
|
|
96
95
|
/**
|
|
97
96
|
* Runs disconnected lifecycle behavior on the associated element.
|
|
98
97
|
*/
|
|
99
|
-
|
|
98
|
+
disconnect(): void;
|
|
100
99
|
/**
|
|
101
100
|
* Runs the attribute changed callback for the associated element.
|
|
102
101
|
* @param name - The name of the attribute that changed.
|
|
@@ -123,5 +122,5 @@ export declare class Controller<TElement extends HTMLElement = HTMLElement> exte
|
|
|
123
122
|
* registered either through the use of the {@link customElement}
|
|
124
123
|
* decorator or a call to `FASTElement.define`.
|
|
125
124
|
*/
|
|
126
|
-
static forCustomElement(element: HTMLElement):
|
|
125
|
+
static forCustomElement(element: HTMLElement): ElementController;
|
|
127
126
|
}
|
|
@@ -2,6 +2,18 @@ import { Constructable } from "../interfaces.js";
|
|
|
2
2
|
import { ComposableStyles, ElementStyles } from "../styles/element-styles.js";
|
|
3
3
|
import type { ElementViewTemplate } from "../templating/template.js";
|
|
4
4
|
import { AttributeConfiguration, AttributeDefinition } from "./attributes.js";
|
|
5
|
+
/**
|
|
6
|
+
* Shadow root initialization options.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface ShadowRootOptions extends ShadowRootInit {
|
|
10
|
+
/**
|
|
11
|
+
* A registry that provides the custom elements visible
|
|
12
|
+
* from within this shadow root.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
registry?: CustomElementRegistry;
|
|
16
|
+
}
|
|
5
17
|
/**
|
|
6
18
|
* Represents metadata configuration for a custom element.
|
|
7
19
|
* @public
|
|
@@ -25,12 +37,21 @@ export interface PartialFASTElementDefinition {
|
|
|
25
37
|
readonly attributes?: (AttributeConfiguration | string)[];
|
|
26
38
|
/**
|
|
27
39
|
* Options controlling the creation of the custom element's shadow DOM.
|
|
40
|
+
* @remarks
|
|
41
|
+
* If not provided, defaults to an open shadow root. Provide null
|
|
42
|
+
* to render to the associated template to the light DOM instead.
|
|
28
43
|
*/
|
|
29
|
-
readonly shadowOptions?: Partial<
|
|
44
|
+
readonly shadowOptions?: Partial<ShadowRootOptions> | null;
|
|
30
45
|
/**
|
|
31
46
|
* Options controlling how the custom element is defined with the platform.
|
|
32
47
|
*/
|
|
33
48
|
readonly elementOptions?: ElementDefinitionOptions;
|
|
49
|
+
/**
|
|
50
|
+
* The registry to register this component in by default.
|
|
51
|
+
* @remarks
|
|
52
|
+
* If not provided, defaults to the global registry.
|
|
53
|
+
*/
|
|
54
|
+
readonly registry?: CustomElementRegistry;
|
|
34
55
|
}
|
|
35
56
|
/**
|
|
36
57
|
* Defines metadata for a FASTElement.
|
|
@@ -73,11 +94,15 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
|
|
|
73
94
|
/**
|
|
74
95
|
* Options controlling the creation of the custom element's shadow DOM.
|
|
75
96
|
*/
|
|
76
|
-
readonly shadowOptions?:
|
|
97
|
+
readonly shadowOptions?: ShadowRootOptions;
|
|
77
98
|
/**
|
|
78
99
|
* Options controlling how the custom element is defined with the platform.
|
|
79
100
|
*/
|
|
80
|
-
readonly elementOptions
|
|
101
|
+
readonly elementOptions: ElementDefinitionOptions;
|
|
102
|
+
/**
|
|
103
|
+
* The registry to register this component in by default.
|
|
104
|
+
*/
|
|
105
|
+
readonly registry: CustomElementRegistry;
|
|
81
106
|
private constructor();
|
|
82
107
|
/**
|
|
83
108
|
* Defines a custom element based on this definition.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Constructable } from "../interfaces.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ElementController } from "./element-controller.js";
|
|
3
3
|
import { FASTElementDefinition, PartialFASTElementDefinition } from "./fast-definitions.js";
|
|
4
4
|
/**
|
|
5
5
|
* Represents a custom element based on the FASTElement infrastructure.
|
|
@@ -10,7 +10,7 @@ export interface FASTElement extends HTMLElement {
|
|
|
10
10
|
* The underlying controller that handles the lifecycle and rendering of
|
|
11
11
|
* this FASTElement.
|
|
12
12
|
*/
|
|
13
|
-
readonly $fastController:
|
|
13
|
+
readonly $fastController: ElementController;
|
|
14
14
|
/**
|
|
15
15
|
* Emits a custom HTML event.
|
|
16
16
|
* @param type - The type name of the event.
|
package/dist/dts/di/di.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare type ResolveCallback<T = any> = (handler: Container, requestor: C
|
|
|
17
17
|
interface ResolverLike<C, K = any> {
|
|
18
18
|
readonly $isResolver: true;
|
|
19
19
|
resolve(handler: C, requestor: C): Resolved<K>;
|
|
20
|
+
resolveAsync(handler: C, requestor: C): Promise<Resolved<K>>;
|
|
20
21
|
getFactory?(container: C): (K extends Constructable ? Factory<K> : never) | null;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
@@ -68,6 +69,13 @@ export interface Factory<T extends Constructable = any> {
|
|
|
68
69
|
* @param dynamicDependencies - Dynamic dependencies supplied to the constructor.
|
|
69
70
|
*/
|
|
70
71
|
construct(container: Container, dynamicDependencies?: Key[]): Resolved<T>;
|
|
72
|
+
/**
|
|
73
|
+
* Constructs an instance of the factory's object, allowing for
|
|
74
|
+
* async resolution of dependencies.
|
|
75
|
+
* @param container - The container the object is being constructor for.
|
|
76
|
+
* @param dynamicDependencies - Dynamic dependencies supplied to the constructor.
|
|
77
|
+
*/
|
|
78
|
+
constructAsync(container: Container, dynamicDependencies?: Key[]): Promise<Resolved<T>>;
|
|
71
79
|
}
|
|
72
80
|
/**
|
|
73
81
|
* Implemented by objects capable of resolving services and other dependencies.
|
|
@@ -96,6 +104,24 @@ export interface ServiceLocator {
|
|
|
96
104
|
* @param key - The key to lookup.
|
|
97
105
|
*/
|
|
98
106
|
get<K extends Key>(key: K | Key): Resolved<K>;
|
|
107
|
+
/**
|
|
108
|
+
* Gets a dependency by key, allowing for asynchronously
|
|
109
|
+
* resolved dependencies.
|
|
110
|
+
* @param key - The key to lookup.
|
|
111
|
+
*/
|
|
112
|
+
getAsync<K extends Key>(key: K): Promise<Resolved<K>>;
|
|
113
|
+
/**
|
|
114
|
+
* Gets a dependency by key, allowing for asynchronously
|
|
115
|
+
* resolved dependencies.
|
|
116
|
+
* @param key - The key to lookup.
|
|
117
|
+
*/
|
|
118
|
+
getAsync<K extends Key>(key: Key): Promise<Resolved<K>>;
|
|
119
|
+
/**
|
|
120
|
+
* Gets a dependency by key, allowing for asynchronously
|
|
121
|
+
* resolved dependencies.
|
|
122
|
+
* @param key - The key to lookup.
|
|
123
|
+
*/
|
|
124
|
+
getAsync<K extends Key>(key: K | Key): Promise<Resolved<K>>;
|
|
99
125
|
/**
|
|
100
126
|
* Gets an array of all dependencies by key.
|
|
101
127
|
* @param key - The key to lookup.
|
|
@@ -285,6 +311,11 @@ export declare type Injectable<T = {}> = Constructable<T> & {
|
|
|
285
311
|
* @public
|
|
286
312
|
*/
|
|
287
313
|
export declare type ParentLocator = (owner: any) => Container | null;
|
|
314
|
+
/**
|
|
315
|
+
* A function capable of asynchronously locating a resolver for a key.
|
|
316
|
+
* @public
|
|
317
|
+
*/
|
|
318
|
+
export declare type AsyncRegistrationLocator = (key: Key) => Promise<Registration | null>;
|
|
288
319
|
/**
|
|
289
320
|
* Configuration for a dependency injection container.
|
|
290
321
|
* @public
|
|
@@ -294,6 +325,12 @@ export interface ContainerConfiguration {
|
|
|
294
325
|
* The locator function used to find the parent of the container.
|
|
295
326
|
*/
|
|
296
327
|
parentLocator: ParentLocator;
|
|
328
|
+
/**
|
|
329
|
+
* When an asynchronous get request is made to the container, if no
|
|
330
|
+
* resolver is found for the key, this function is called to provide
|
|
331
|
+
* a registration.
|
|
332
|
+
*/
|
|
333
|
+
asyncRegistrationLocator: AsyncRegistrationLocator;
|
|
297
334
|
/**
|
|
298
335
|
* Indicates whether this container should resolve dependencies that are directly made
|
|
299
336
|
* by its owner. The default is "false" which results in the parent container being used.
|
|
@@ -712,6 +749,7 @@ export declare class ResolverImpl implements Resolver, Registration {
|
|
|
712
749
|
get $isResolver(): true;
|
|
713
750
|
private resolving;
|
|
714
751
|
register(container: Container): Resolver;
|
|
752
|
+
resolveAsync(handler: Container, requestor: Container): Promise<any>;
|
|
715
753
|
resolve(handler: Container, requestor: Container): any;
|
|
716
754
|
getFactory(container: Container): Factory | null;
|
|
717
755
|
}
|
|
@@ -721,7 +759,9 @@ export declare class FactoryImpl<T extends Constructable = any> implements Facto
|
|
|
721
759
|
private readonly dependencies;
|
|
722
760
|
private transformers;
|
|
723
761
|
constructor(Type: T, dependencies: Key[]);
|
|
762
|
+
constructAsync(container: Container, dynamicDependencies?: Key[]): Promise<Resolved<T>>;
|
|
724
763
|
construct(container: Container, dynamicDependencies?: Key[]): Resolved<T>;
|
|
764
|
+
private constructCore;
|
|
725
765
|
registerTransformer(transformer: (instance: any) => any): void;
|
|
726
766
|
}
|
|
727
767
|
/**
|
|
@@ -744,6 +784,7 @@ export declare class ContainerImpl implements DOMContainer {
|
|
|
744
784
|
registerTransformer<K extends Key, T = K>(key: K, transformer: Transformer<T>): boolean;
|
|
745
785
|
getResolver<K extends Key, T = K>(key: K | Key, autoRegister?: boolean): Resolver<T> | null;
|
|
746
786
|
has<K extends Key>(key: K, searchAncestors?: boolean): boolean;
|
|
787
|
+
getAsync<K extends Key>(key: K): Promise<Resolved<K>>;
|
|
747
788
|
get<K extends Key>(key: K): Resolved<K>;
|
|
748
789
|
getAll<K extends Key>(key: K, searchAncestors?: boolean): readonly Resolved<K>[];
|
|
749
790
|
getFactory<K extends Constructable>(Type: K): Factory<K>;
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ export * from "./observation/observable.js";
|
|
|
4
4
|
export * from "./observation/notifier.js";
|
|
5
5
|
export * from "./observation/arrays.js";
|
|
6
6
|
export * from "./observation/update-queue.js";
|
|
7
|
-
export type { Behavior } from "./observation/behavior.js";
|
|
8
7
|
export * from "./styles/element-styles.js";
|
|
9
8
|
export * from "./styles/css.js";
|
|
10
9
|
export * from "./styles/css-directive.js";
|
|
10
|
+
export * from "./styles/host.js";
|
|
11
11
|
export * from "./templating/dom.js";
|
|
12
12
|
export * from "./templating/template.js";
|
|
13
13
|
export * from "./templating/compiler.js";
|
|
@@ -24,4 +24,4 @@ export * from "./templating/node-observation.js";
|
|
|
24
24
|
export * from "./components/fast-element.js";
|
|
25
25
|
export * from "./components/fast-definitions.js";
|
|
26
26
|
export * from "./components/attributes.js";
|
|
27
|
-
export * from "./components/controller.js";
|
|
27
|
+
export * from "./components/element-controller.js";
|
package/dist/dts/interfaces.d.ts
CHANGED
|
@@ -42,23 +42,77 @@ export interface ObservationRecord {
|
|
|
42
42
|
propertyName: string;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
45
|
+
* Describes how the source's lifetime relates to its controller's lifetime.
|
|
47
46
|
* @public
|
|
48
47
|
*/
|
|
49
|
-
export
|
|
48
|
+
export declare const SourceLifetime: Readonly<{
|
|
50
49
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @param source - The source to pass to the binding.
|
|
53
|
-
* @param context - The context to pass to the binding.
|
|
50
|
+
* The source to controller lifetime relationship is unknown.
|
|
54
51
|
*/
|
|
55
|
-
|
|
52
|
+
readonly unknown: undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The source and controller lifetimes are coupled to one another.
|
|
55
|
+
* They can/will be GC'd together.
|
|
56
|
+
*/
|
|
57
|
+
readonly coupled: 1;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Describes how the source's lifetime relates to its controller's lifetime.
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
export declare type SourceLifetime = typeof SourceLifetime[keyof typeof SourceLifetime];
|
|
64
|
+
/**
|
|
65
|
+
* Controls the lifecycle of an expression and provides relevant context.
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export interface ExpressionController<TSource = any, TParent = any> {
|
|
69
|
+
/**
|
|
70
|
+
* The source the expression is evaluated against.
|
|
71
|
+
*/
|
|
72
|
+
readonly source: TSource;
|
|
73
|
+
/**
|
|
74
|
+
* Indicates how the source's lifetime relates to the controller's lifetime.
|
|
75
|
+
*/
|
|
76
|
+
readonly sourceLifetime?: SourceLifetime;
|
|
77
|
+
/**
|
|
78
|
+
* The context the expression is evaluated against.
|
|
79
|
+
*/
|
|
80
|
+
readonly context: ExecutionContext<TParent>;
|
|
81
|
+
/**
|
|
82
|
+
* Indicates whether the controller is bound.
|
|
83
|
+
*/
|
|
84
|
+
readonly isBound: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Registers an unbind handler with the controller.
|
|
87
|
+
* @param behavior - An object to call when the controller unbinds.
|
|
88
|
+
*/
|
|
89
|
+
onUnbind(behavior: {
|
|
90
|
+
unbind(controller: ExpressionController<TSource, TParent>): any;
|
|
91
|
+
}): void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Observes an expression for changes.
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export interface ExpressionObserver<TSource = any, TReturn = any, TParent = any> {
|
|
98
|
+
/**
|
|
99
|
+
* Binds the expression to the source.
|
|
100
|
+
* @param controller - The controller that manages the lifecycle and related
|
|
101
|
+
* context for the expression.
|
|
102
|
+
*/
|
|
103
|
+
bind(controller: ExpressionController<TSource, TParent>): TReturn;
|
|
56
104
|
}
|
|
57
105
|
/**
|
|
58
106
|
* Enables evaluation of and subscription to a binding.
|
|
59
107
|
* @public
|
|
60
108
|
*/
|
|
61
|
-
export interface ExpressionNotifier<TSource = any, TReturn = any, TParent = any> extends Notifier, ExpressionObserver<TSource, TReturn, TParent
|
|
109
|
+
export interface ExpressionNotifier<TSource = any, TReturn = any, TParent = any> extends Notifier, ExpressionObserver<TSource, TReturn, TParent>, Disposable {
|
|
110
|
+
/**
|
|
111
|
+
* Observes the expression.
|
|
112
|
+
* @param source - The source for the expression.
|
|
113
|
+
* @param context - The context for the expression.
|
|
114
|
+
*/
|
|
115
|
+
observe(source: TSource, context?: ExecutionContext): TReturn;
|
|
62
116
|
/**
|
|
63
117
|
* Gets {@link ObservationRecord|ObservationRecords} that the {@link ExpressionNotifier}
|
|
64
118
|
* is observing.
|
|
@@ -153,11 +207,7 @@ export declare function volatile(target: {}, name: string | Accessor, descriptor
|
|
|
153
207
|
* Provides additional contextual information available to behaviors and expressions.
|
|
154
208
|
* @public
|
|
155
209
|
*/
|
|
156
|
-
export
|
|
157
|
-
/**
|
|
158
|
-
* The default execution context.
|
|
159
|
-
*/
|
|
160
|
-
static readonly default: ExecutionContext<any>;
|
|
210
|
+
export interface ExecutionContext<TParent = any> {
|
|
161
211
|
/**
|
|
162
212
|
* The index of the current item within a repeat context.
|
|
163
213
|
*/
|
|
@@ -169,41 +219,40 @@ export declare class ExecutionContext<TParentSource = any> {
|
|
|
169
219
|
/**
|
|
170
220
|
* The parent data source within a nested context.
|
|
171
221
|
*/
|
|
172
|
-
|
|
222
|
+
parent: TParent;
|
|
173
223
|
/**
|
|
174
224
|
* The parent execution context when in nested context scenarios.
|
|
175
225
|
*/
|
|
176
|
-
|
|
177
|
-
private constructor();
|
|
226
|
+
parentContext: ExecutionContext<TParent>;
|
|
178
227
|
/**
|
|
179
228
|
* The current event within an event handler.
|
|
180
229
|
*/
|
|
181
|
-
|
|
230
|
+
readonly event: Event;
|
|
182
231
|
/**
|
|
183
232
|
* Indicates whether the current item within a repeat context
|
|
184
233
|
* has an even index.
|
|
185
234
|
*/
|
|
186
|
-
|
|
235
|
+
readonly isEven: boolean;
|
|
187
236
|
/**
|
|
188
237
|
* Indicates whether the current item within a repeat context
|
|
189
238
|
* has an odd index.
|
|
190
239
|
*/
|
|
191
|
-
|
|
240
|
+
readonly isOdd: boolean;
|
|
192
241
|
/**
|
|
193
242
|
* Indicates whether the current item within a repeat context
|
|
194
243
|
* is the first item in the collection.
|
|
195
244
|
*/
|
|
196
|
-
|
|
245
|
+
readonly isFirst: boolean;
|
|
197
246
|
/**
|
|
198
247
|
* Indicates whether the current item within a repeat context
|
|
199
248
|
* is somewhere in the middle of the collection.
|
|
200
249
|
*/
|
|
201
|
-
|
|
250
|
+
readonly isInMiddle: boolean;
|
|
202
251
|
/**
|
|
203
252
|
* Indicates whether the current item within a repeat context
|
|
204
253
|
* is the last item in the collection.
|
|
205
254
|
*/
|
|
206
|
-
|
|
255
|
+
readonly isLast: boolean;
|
|
207
256
|
/**
|
|
208
257
|
* Returns the typed event detail of a custom event.
|
|
209
258
|
*/
|
|
@@ -212,34 +261,24 @@ export declare class ExecutionContext<TParentSource = any> {
|
|
|
212
261
|
* Returns the typed event target of the event.
|
|
213
262
|
*/
|
|
214
263
|
eventTarget<TTarget extends EventTarget>(): TTarget;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Provides additional contextual information available to behaviors and expressions.
|
|
267
|
+
* @public
|
|
268
|
+
*/
|
|
269
|
+
export declare const ExecutionContext: Readonly<{
|
|
215
270
|
/**
|
|
216
|
-
*
|
|
217
|
-
* @param index - The new index of the item.
|
|
218
|
-
* @param length - The new length of the list.
|
|
219
|
-
*/
|
|
220
|
-
updatePosition(index: number, length: number): void;
|
|
221
|
-
/**
|
|
222
|
-
* Creates a new execution context descendent from the current context.
|
|
223
|
-
* @param source - The source for the context if different than the parent.
|
|
224
|
-
* @returns A child execution context.
|
|
225
|
-
*/
|
|
226
|
-
createChildContext<TParentSource>(parentSource: TParentSource): ExecutionContext<TParentSource>;
|
|
227
|
-
/**
|
|
228
|
-
* Creates a new execution context descent suitable for use in list rendering.
|
|
229
|
-
* @param item - The list item to serve as the source.
|
|
230
|
-
* @param index - The index of the item in the list.
|
|
231
|
-
* @param length - The length of the list.
|
|
271
|
+
* A default execution context.
|
|
232
272
|
*/
|
|
233
|
-
|
|
273
|
+
default: ExecutionContext<any>;
|
|
234
274
|
/**
|
|
235
|
-
*
|
|
236
|
-
* @
|
|
237
|
-
* @internal
|
|
275
|
+
* Gets the current event.
|
|
276
|
+
* @returns An event object.
|
|
238
277
|
*/
|
|
239
|
-
|
|
278
|
+
getEvent(): Event | null;
|
|
240
279
|
/**
|
|
241
|
-
*
|
|
242
|
-
* @
|
|
280
|
+
* Sets the current event.
|
|
281
|
+
* @param event - An event object.
|
|
243
282
|
*/
|
|
244
|
-
|
|
245
|
-
}
|
|
283
|
+
setEvent(event: Event | null): void;
|
|
284
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* An implementation of the https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/pending-task.md proposal.
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
export interface PendingTask extends Event {
|
|
9
|
+
complete: Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A concrete implementation of {@link PendingTask}
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export declare class PendingTaskEvent extends Event implements PendingTask {
|
|
16
|
+
complete: Promise<void>;
|
|
17
|
+
static readonly type = "pending-task";
|
|
18
|
+
constructor(complete: Promise<void>);
|
|
19
|
+
static isPendingTask<T extends Event>(value: T | PendingTask): value is PendingTask;
|
|
20
|
+
}
|
package/dist/dts/platform.d.ts
CHANGED
|
@@ -33,3 +33,9 @@ export interface TypeRegistry<TDefinition extends TypeDefinition> {
|
|
|
33
33
|
* @internal
|
|
34
34
|
*/
|
|
35
35
|
export declare function createTypeRegistry<TDefinition extends TypeDefinition>(): TypeRegistry<TDefinition>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a function capable of locating metadata associated with a type.
|
|
38
|
+
* @returns A metadata locator function.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare function createMetadataLocator<TMetadata>(): (target: {}) => TMetadata[];
|