@microsoft/fast-element 1.10.2 → 2.0.0-beta.3
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 +387 -1
- package/CHANGELOG.md +74 -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 +10 -2
- package/dist/dts/components/fast-element.d.ts +12 -5
- package/dist/dts/context.d.ts +157 -0
- 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 +145 -0
- package/dist/dts/metadata.d.ts +25 -0
- package/dist/dts/observation/arrays.d.ts +207 -0
- package/dist/dts/observation/behavior.d.ts +4 -4
- package/dist/dts/observation/notifier.d.ts +18 -18
- package/dist/dts/observation/observable.d.ts +56 -18
- 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-signal.d.ts +38 -0
- package/dist/dts/templating/binding-two-way.d.ts +56 -0
- package/dist/dts/templating/binding.d.ts +233 -65
- package/dist/dts/templating/children.d.ts +18 -15
- package/dist/dts/templating/compiler.d.ts +46 -28
- package/dist/dts/templating/dom.d.ts +41 -0
- package/dist/dts/templating/html-directive.d.ts +181 -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 +26 -14
- package/dist/dts/templating/slotted.d.ts +13 -14
- package/dist/dts/templating/template.d.ts +27 -21
- package/dist/dts/templating/view.d.ts +15 -22
- package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
- 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 +16 -22
- package/dist/esm/components/fast-element.js +10 -2
- package/dist/esm/context.js +159 -0
- package/dist/esm/debug.js +30 -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/metadata.js +60 -0
- package/dist/esm/observation/arrays.js +269 -0
- package/dist/esm/observation/notifier.js +27 -35
- package/dist/esm/observation/observable.js +93 -68
- 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-signal.js +84 -0
- package/dist/esm/templating/binding-two-way.js +82 -0
- package/dist/esm/templating/binding.js +306 -153
- package/dist/esm/templating/children.js +33 -23
- package/dist/esm/templating/compiler.js +236 -152
- package/dist/esm/templating/dom.js +49 -0
- package/dist/esm/templating/html-directive.js +128 -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 +39 -36
- package/dist/esm/templating/slotted.js +23 -20
- package/dist/esm/templating/template.js +51 -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 +11789 -5377
- package/dist/fast-element.d.ts +1178 -530
- package/dist/fast-element.debug.js +3722 -0
- package/dist/fast-element.debug.min.js +1 -0
- package/dist/fast-element.js +3484 -4033
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +2699 -0
- package/docs/api-report.md +472 -219
- package/docs/fast-element-2-changes.md +15 -0
- package/docs/guide/declaring-templates.md +4 -4
- package/docs/guide/defining-elements.md +2 -2
- package/docs/guide/next-steps.md +2 -2
- package/docs/guide/observables-and-state.md +1 -1
- package/docs/guide/using-directives.md +1 -1
- package/karma.conf.cjs +6 -17
- package/package.json +63 -15
- 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 -177
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { Subscriber, SubscriberSet } from "./notifier.js";
|
|
2
|
+
/**
|
|
3
|
+
* A splice map is a representation of how a previous array of items
|
|
4
|
+
* was transformed into a new array of items. Conceptually it is a list of
|
|
5
|
+
* tuples of
|
|
6
|
+
*
|
|
7
|
+
* (index, removed, addedCount)
|
|
8
|
+
*
|
|
9
|
+
* which are kept in ascending index order of. The tuple represents that at
|
|
10
|
+
* the |index|, |removed| sequence of items were removed, and counting forward
|
|
11
|
+
* from |index|, |addedCount| items were added.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class Splice {
|
|
15
|
+
index: number;
|
|
16
|
+
removed: any[];
|
|
17
|
+
addedCount: number;
|
|
18
|
+
/**
|
|
19
|
+
* Indicates that this splice represents a complete array reset.
|
|
20
|
+
*/
|
|
21
|
+
reset?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a splice.
|
|
24
|
+
* @param index - The index that the splice occurs at.
|
|
25
|
+
* @param removed - The items that were removed.
|
|
26
|
+
* @param addedCount - The number of items that were added.
|
|
27
|
+
*/
|
|
28
|
+
constructor(index: number, removed: any[], addedCount: number);
|
|
29
|
+
/**
|
|
30
|
+
* Adjusts the splice index based on the provided array.
|
|
31
|
+
* @param array - The array to adjust to.
|
|
32
|
+
* @returns The same splice, mutated based on the reference array.
|
|
33
|
+
*/
|
|
34
|
+
adjustTo(array: any[]): this;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Indicates what level of feature support the splice
|
|
38
|
+
* strategy provides.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare const SpliceStrategySupport: Readonly<{
|
|
42
|
+
/**
|
|
43
|
+
* Only supports resets.
|
|
44
|
+
*/
|
|
45
|
+
readonly reset: 1;
|
|
46
|
+
/**
|
|
47
|
+
* Supports tracking splices and resets.
|
|
48
|
+
*/
|
|
49
|
+
readonly splice: 2;
|
|
50
|
+
/**
|
|
51
|
+
* Supports tracking splices and resets, while applying some form
|
|
52
|
+
* of optimization, such as merging, to the splices.
|
|
53
|
+
*/
|
|
54
|
+
readonly optimized: 3;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* The available values for SpliceStrategySupport.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare type SpliceStrategySupport = typeof SpliceStrategySupport[keyof typeof SpliceStrategySupport];
|
|
61
|
+
/**
|
|
62
|
+
* An approach to tracking changes in an array.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export interface SpliceStrategy {
|
|
66
|
+
/**
|
|
67
|
+
* The level of feature support the splice strategy provides.
|
|
68
|
+
*/
|
|
69
|
+
readonly support: SpliceStrategySupport;
|
|
70
|
+
/**
|
|
71
|
+
* Normalizes the splices before delivery to array change subscribers.
|
|
72
|
+
* @param previous - The previous version of the array if a reset has taken place.
|
|
73
|
+
* @param current - The current version of the array.
|
|
74
|
+
* @param changes - The set of changes tracked against the array.
|
|
75
|
+
*/
|
|
76
|
+
normalize(previous: unknown[] | undefined, current: unknown[], changes: Splice[] | undefined): readonly Splice[];
|
|
77
|
+
/**
|
|
78
|
+
* Performs and tracks a pop operation on an array.
|
|
79
|
+
* @param array - The array to track the change for.
|
|
80
|
+
* @param observer - The observer to register the change with.
|
|
81
|
+
* @param pop - The operation to perform.
|
|
82
|
+
* @param args - The arguments for the operation.
|
|
83
|
+
*/
|
|
84
|
+
pop(array: any[], observer: ArrayObserver, pop: typeof Array.prototype.pop, args: any[]): any;
|
|
85
|
+
/**
|
|
86
|
+
* Performs and tracks a push operation on an array.
|
|
87
|
+
* @param array - The array to track the change for.
|
|
88
|
+
* @param observer - The observer to register the change with.
|
|
89
|
+
* @param push - The operation to perform.
|
|
90
|
+
* @param args - The arguments for the operation.
|
|
91
|
+
*/
|
|
92
|
+
push(array: any[], observer: ArrayObserver, push: typeof Array.prototype.push, args: any[]): any;
|
|
93
|
+
/**
|
|
94
|
+
* Performs and tracks a reverse operation on an array.
|
|
95
|
+
* @param array - The array to track the change for.
|
|
96
|
+
* @param observer - The observer to register the change with.
|
|
97
|
+
* @param reverse - The operation to perform.
|
|
98
|
+
* @param args - The arguments for the operation.
|
|
99
|
+
*/
|
|
100
|
+
reverse(array: any[], observer: ArrayObserver, reverse: typeof Array.prototype.reverse, args: any[]): any;
|
|
101
|
+
/**
|
|
102
|
+
* Performs and tracks a shift operation on an array.
|
|
103
|
+
* @param array - The array to track the change for.
|
|
104
|
+
* @param observer - The observer to register the change with.
|
|
105
|
+
* @param shift - The operation to perform.
|
|
106
|
+
* @param args - The arguments for the operation.
|
|
107
|
+
*/
|
|
108
|
+
shift(array: any[], observer: ArrayObserver, shift: typeof Array.prototype.shift, args: any[]): any;
|
|
109
|
+
/**
|
|
110
|
+
* Performs and tracks a sort operation on an array.
|
|
111
|
+
* @param array - The array to track the change for.
|
|
112
|
+
* @param observer - The observer to register the change with.
|
|
113
|
+
* @param sort - The operation to perform.
|
|
114
|
+
* @param args - The arguments for the operation.
|
|
115
|
+
*/
|
|
116
|
+
sort(array: any[], observer: ArrayObserver, sort: typeof Array.prototype.sort, args: any[]): any[];
|
|
117
|
+
/**
|
|
118
|
+
* Performs and tracks a splice operation on an array.
|
|
119
|
+
* @param array - The array to track the change for.
|
|
120
|
+
* @param observer - The observer to register the change with.
|
|
121
|
+
* @param splice - The operation to perform.
|
|
122
|
+
* @param args - The arguments for the operation.
|
|
123
|
+
*/
|
|
124
|
+
splice(array: any[], observer: ArrayObserver, splice: typeof Array.prototype.splice, args: any[]): any;
|
|
125
|
+
/**
|
|
126
|
+
* Performs and tracks an unshift operation on an array.
|
|
127
|
+
* @param array - The array to track the change for.
|
|
128
|
+
* @param observer - The observer to register the change with.
|
|
129
|
+
* @param unshift - The operation to perform.
|
|
130
|
+
* @param args - The arguments for the operation.
|
|
131
|
+
*/
|
|
132
|
+
unshift(array: any[], observer: ArrayObserver, unshift: typeof Array.prototype.unshift, args: any[]): any[];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Functionality related to tracking changes in arrays.
|
|
136
|
+
* @public
|
|
137
|
+
*/
|
|
138
|
+
export declare const SpliceStrategy: Readonly<{
|
|
139
|
+
/**
|
|
140
|
+
* A set of changes that represent a full array reset.
|
|
141
|
+
*/
|
|
142
|
+
readonly reset: Splice[];
|
|
143
|
+
/**
|
|
144
|
+
* Sets the default strategy to use for array observers.
|
|
145
|
+
* @param strategy - The splice strategy to use.
|
|
146
|
+
*/
|
|
147
|
+
readonly setDefaultStrategy: (strategy: SpliceStrategy) => void;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Observes array lengths.
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
export interface LengthObserver extends Subscriber {
|
|
154
|
+
/**
|
|
155
|
+
* The length of the observed array.
|
|
156
|
+
*/
|
|
157
|
+
length: number;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* An observer for arrays.
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
export interface ArrayObserver extends SubscriberSet {
|
|
164
|
+
/**
|
|
165
|
+
* The strategy to use for tracking changes.
|
|
166
|
+
*/
|
|
167
|
+
strategy: SpliceStrategy | null;
|
|
168
|
+
/**
|
|
169
|
+
* The length observer for the array.
|
|
170
|
+
*/
|
|
171
|
+
readonly lengthObserver: LengthObserver;
|
|
172
|
+
/**
|
|
173
|
+
* Adds a splice to the list of changes.
|
|
174
|
+
* @param splice - The splice to add.
|
|
175
|
+
*/
|
|
176
|
+
addSplice(splice: Splice): void;
|
|
177
|
+
/**
|
|
178
|
+
* Indicates that a reset change has occurred.
|
|
179
|
+
* @param oldCollection - The collection as it was before the reset.
|
|
180
|
+
*/
|
|
181
|
+
reset(oldCollection: any[] | undefined): void;
|
|
182
|
+
/**
|
|
183
|
+
* Flushes the changes to subscribers.
|
|
184
|
+
*/
|
|
185
|
+
flush(): void;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* An observer for arrays.
|
|
189
|
+
* @public
|
|
190
|
+
*/
|
|
191
|
+
export declare const ArrayObserver: Readonly<{
|
|
192
|
+
/**
|
|
193
|
+
* Enables the array observation mechanism.
|
|
194
|
+
* @remarks
|
|
195
|
+
* Array observation is enabled automatically when using the
|
|
196
|
+
* {@link RepeatDirective}, so calling this API manually is
|
|
197
|
+
* not typically necessary.
|
|
198
|
+
*/
|
|
199
|
+
readonly enable: () => void;
|
|
200
|
+
}>;
|
|
201
|
+
/**
|
|
202
|
+
* Enables observing the length of an array.
|
|
203
|
+
* @param array - The array to observe the length of.
|
|
204
|
+
* @returns The length of the array.
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
export declare function lengthOf<T>(array: readonly T[]): number;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { ExecutionContext } from "./observable.js";
|
|
2
2
|
/**
|
|
3
|
-
* Represents
|
|
3
|
+
* Represents an object that can contribute behavior to a view or
|
|
4
4
|
* element's bind/unbind operations.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export interface Behavior {
|
|
7
|
+
export interface Behavior<TSource = any, TParent = any> {
|
|
8
8
|
/**
|
|
9
9
|
* Bind this behavior to the source.
|
|
10
10
|
* @param source - The source to bind to.
|
|
11
11
|
* @param context - The execution context that the binding is operating within.
|
|
12
12
|
*/
|
|
13
|
-
bind(source:
|
|
13
|
+
bind(source: TSource, context: ExecutionContext<TParent>): void;
|
|
14
14
|
/**
|
|
15
15
|
* Unbinds this behavior from the source.
|
|
16
16
|
* @param source - The source to unbind from.
|
|
17
17
|
*/
|
|
18
|
-
unbind(source:
|
|
18
|
+
unbind(source: TSource, context: ExecutionContext<TParent>): void;
|
|
19
19
|
}
|
|
@@ -4,21 +4,21 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export interface Subscriber {
|
|
6
6
|
/**
|
|
7
|
-
* Called when a
|
|
8
|
-
* @param
|
|
7
|
+
* Called when a subject this instance has subscribed to changes.
|
|
8
|
+
* @param subject - The subject of the change.
|
|
9
9
|
* @param args - The event args detailing the change that occurred.
|
|
10
10
|
*/
|
|
11
|
-
handleChange(
|
|
11
|
+
handleChange(subject: any, args: any): void;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Provides change
|
|
14
|
+
* Provides change notifications for an observed subject.
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
export interface Notifier {
|
|
18
18
|
/**
|
|
19
|
-
* The
|
|
19
|
+
* The object that subscribers will receive notifications for.
|
|
20
20
|
*/
|
|
21
|
-
readonly
|
|
21
|
+
readonly subject: any;
|
|
22
22
|
/**
|
|
23
23
|
* Notifies all subscribers, based on the args.
|
|
24
24
|
* @param args - Data passed along to subscribers during notification.
|
|
@@ -47,7 +47,7 @@ export interface Notifier {
|
|
|
47
47
|
/**
|
|
48
48
|
* An implementation of {@link Notifier} that efficiently keeps track of
|
|
49
49
|
* subscribers interested in a specific change notification on an
|
|
50
|
-
* observable
|
|
50
|
+
* observable subject.
|
|
51
51
|
*
|
|
52
52
|
* @remarks
|
|
53
53
|
* This set is optimized for the most common scenario of 1 or 2 subscribers.
|
|
@@ -60,15 +60,15 @@ export declare class SubscriberSet implements Notifier {
|
|
|
60
60
|
private sub2;
|
|
61
61
|
private spillover;
|
|
62
62
|
/**
|
|
63
|
-
* The
|
|
63
|
+
* The object that subscribers will receive notifications for.
|
|
64
64
|
*/
|
|
65
|
-
readonly
|
|
65
|
+
readonly subject: any;
|
|
66
66
|
/**
|
|
67
|
-
* Creates an instance of SubscriberSet for the specified
|
|
68
|
-
* @param
|
|
67
|
+
* Creates an instance of SubscriberSet for the specified subject.
|
|
68
|
+
* @param subject - The subject that subscribers will receive notifications from.
|
|
69
69
|
* @param initialSubscriber - An initial subscriber to changes.
|
|
70
70
|
*/
|
|
71
|
-
constructor(
|
|
71
|
+
constructor(subject: any, initialSubscriber?: Subscriber);
|
|
72
72
|
/**
|
|
73
73
|
* Checks whether the provided subscriber has been added to this set.
|
|
74
74
|
* @param subscriber - The subscriber to test for inclusion in this set.
|
|
@@ -97,16 +97,16 @@ export declare class SubscriberSet implements Notifier {
|
|
|
97
97
|
*/
|
|
98
98
|
export declare class PropertyChangeNotifier implements Notifier {
|
|
99
99
|
private subscribers;
|
|
100
|
-
private
|
|
100
|
+
private subjectSubscribers;
|
|
101
101
|
/**
|
|
102
|
-
* The
|
|
102
|
+
* The subject that property changes are being notified for.
|
|
103
103
|
*/
|
|
104
|
-
readonly
|
|
104
|
+
readonly subject: any;
|
|
105
105
|
/**
|
|
106
|
-
* Creates an instance of PropertyChangeNotifier for the specified
|
|
107
|
-
* @param
|
|
106
|
+
* Creates an instance of PropertyChangeNotifier for the specified subject.
|
|
107
|
+
* @param subject - The object that subscribers will receive notifications for.
|
|
108
108
|
*/
|
|
109
|
-
constructor(
|
|
109
|
+
constructor(subject: any);
|
|
110
110
|
/**
|
|
111
111
|
* Notifies all subscribers, based on the specified property.
|
|
112
112
|
* @param propertyName - The property name, passed along to subscribers during notification.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Disposable } from "../interfaces.js";
|
|
1
2
|
import type { Notifier, Subscriber } from "./notifier.js";
|
|
2
3
|
/**
|
|
3
4
|
* Represents a getter/setter property accessor on an object.
|
|
@@ -44,23 +45,28 @@ export interface ObservationRecord {
|
|
|
44
45
|
* Enables evaluation of and subscription to a binding.
|
|
45
46
|
* @public
|
|
46
47
|
*/
|
|
47
|
-
export interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier {
|
|
48
|
+
export interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier, Disposable {
|
|
48
49
|
/**
|
|
49
50
|
* Begins observing the binding for the source and returns the current value.
|
|
50
51
|
* @param source - The source that the binding is based on.
|
|
51
52
|
* @param context - The execution context to execute the binding within.
|
|
52
53
|
* @returns The value of the binding.
|
|
53
54
|
*/
|
|
54
|
-
observe(source: TSource, context
|
|
55
|
-
/**
|
|
56
|
-
* Unsubscribe from all dependent observables of the binding.
|
|
57
|
-
*/
|
|
58
|
-
disconnect(): void;
|
|
55
|
+
observe(source: TSource, context?: ExecutionContext<TParent>): TReturn;
|
|
59
56
|
/**
|
|
60
57
|
* Gets {@link ObservationRecord|ObservationRecords} that the {@link BindingObserver}
|
|
61
58
|
* is observing.
|
|
62
59
|
*/
|
|
63
60
|
records(): IterableIterator<ObservationRecord>;
|
|
61
|
+
/**
|
|
62
|
+
* Sets the update mode used by the observer.
|
|
63
|
+
* @param isAsync - Indicates whether updates should be asynchronous.
|
|
64
|
+
* @remarks
|
|
65
|
+
* By default, the update mode is asynchronous, since that provides the best
|
|
66
|
+
* performance for template rendering scenarios. Passing false to setMode will
|
|
67
|
+
* instead cause the observer to notify subscribers immediately when changes occur.
|
|
68
|
+
*/
|
|
69
|
+
setMode(isAsync: boolean): void;
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
72
|
* Common Observable APIs.
|
|
@@ -76,7 +82,7 @@ export declare const Observable: Readonly<{
|
|
|
76
82
|
* Gets a notifier for an object or Array.
|
|
77
83
|
* @param source - The object or Array to get the notifier for.
|
|
78
84
|
*/
|
|
79
|
-
getNotifier: (source: any) =>
|
|
85
|
+
getNotifier: <T extends Notifier = Notifier>(source: any) => T;
|
|
80
86
|
/**
|
|
81
87
|
* Records a property change for a source object.
|
|
82
88
|
* @param source - The object to record the change against.
|
|
@@ -114,13 +120,13 @@ export declare const Observable: Readonly<{
|
|
|
114
120
|
* @param initialSubscriber - An initial subscriber to changes in the binding value.
|
|
115
121
|
* @param isVolatileBinding - Indicates whether the binding's dependency list must be re-evaluated on every value evaluation.
|
|
116
122
|
*/
|
|
117
|
-
binding<TSource = any, TReturn = any
|
|
123
|
+
binding<TSource = any, TReturn = any>(binding: Binding<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): BindingObserver<TSource, TReturn, any>;
|
|
118
124
|
/**
|
|
119
125
|
* Determines whether a binding expression is volatile and needs to have its dependency list re-evaluated
|
|
120
126
|
* on every evaluation of the value.
|
|
121
127
|
* @param binding - The binding to inspect.
|
|
122
128
|
*/
|
|
123
|
-
isVolatileBinding<TSource_1 = any, TReturn_1 = any
|
|
129
|
+
isVolatileBinding<TSource_1 = any, TReturn_1 = any>(binding: Binding<TSource_1, TReturn_1, any>): boolean;
|
|
124
130
|
}>;
|
|
125
131
|
/**
|
|
126
132
|
* Decorator: Defines an observable property on the target.
|
|
@@ -141,7 +147,11 @@ export declare function volatile(target: {}, name: string | Accessor, descriptor
|
|
|
141
147
|
* Provides additional contextual information available to behaviors and expressions.
|
|
142
148
|
* @public
|
|
143
149
|
*/
|
|
144
|
-
export declare class ExecutionContext<
|
|
150
|
+
export declare class ExecutionContext<TParentSource = any> {
|
|
151
|
+
/**
|
|
152
|
+
* The default execution context.
|
|
153
|
+
*/
|
|
154
|
+
static readonly default: ExecutionContext<any>;
|
|
145
155
|
/**
|
|
146
156
|
* The index of the current item within a repeat context.
|
|
147
157
|
*/
|
|
@@ -151,13 +161,14 @@ export declare class ExecutionContext<TParent = any, TGrandparent = any> {
|
|
|
151
161
|
*/
|
|
152
162
|
length: number;
|
|
153
163
|
/**
|
|
154
|
-
* The parent data
|
|
164
|
+
* The parent data source within a nested context.
|
|
155
165
|
*/
|
|
156
|
-
parent:
|
|
166
|
+
readonly parent: TParentSource;
|
|
157
167
|
/**
|
|
158
168
|
* The parent execution context when in nested context scenarios.
|
|
159
169
|
*/
|
|
160
|
-
parentContext: ExecutionContext<
|
|
170
|
+
readonly parentContext: ExecutionContext<TParentSource>;
|
|
171
|
+
private constructor();
|
|
161
172
|
/**
|
|
162
173
|
* The current event within an event handler.
|
|
163
174
|
*/
|
|
@@ -187,15 +198,42 @@ export declare class ExecutionContext<TParent = any, TGrandparent = any> {
|
|
|
187
198
|
* is the last item in the collection.
|
|
188
199
|
*/
|
|
189
200
|
get isLast(): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* Returns the typed event detail of a custom event.
|
|
203
|
+
*/
|
|
204
|
+
eventDetail<TDetail>(): TDetail;
|
|
205
|
+
/**
|
|
206
|
+
* Returns the typed event target of the event.
|
|
207
|
+
*/
|
|
208
|
+
eventTarget<TTarget extends EventTarget>(): TTarget;
|
|
209
|
+
/**
|
|
210
|
+
* Updates the position/size on a context associated with a list item.
|
|
211
|
+
* @param index - The new index of the item.
|
|
212
|
+
* @param length - The new length of the list.
|
|
213
|
+
*/
|
|
214
|
+
updatePosition(index: number, length: number): void;
|
|
215
|
+
/**
|
|
216
|
+
* Creates a new execution context descendent from the current context.
|
|
217
|
+
* @param source - The source for the context if different than the parent.
|
|
218
|
+
* @returns A child execution context.
|
|
219
|
+
*/
|
|
220
|
+
createChildContext<TParentSource>(parentSource: TParentSource): ExecutionContext<TParentSource>;
|
|
221
|
+
/**
|
|
222
|
+
* Creates a new execution context descent suitable for use in list rendering.
|
|
223
|
+
* @param item - The list item to serve as the source.
|
|
224
|
+
* @param index - The index of the item in the list.
|
|
225
|
+
* @param length - The length of the list.
|
|
226
|
+
*/
|
|
227
|
+
createItemContext(index: number, length: number): ExecutionContext<TParentSource>;
|
|
190
228
|
/**
|
|
191
229
|
* Sets the event for the current execution context.
|
|
192
230
|
* @param event - The event to set.
|
|
193
231
|
* @internal
|
|
194
232
|
*/
|
|
195
233
|
static setEvent(event: Event | null): void;
|
|
234
|
+
/**
|
|
235
|
+
* Creates a new root execution context.
|
|
236
|
+
* @returns A new execution context.
|
|
237
|
+
*/
|
|
238
|
+
static create(): ExecutionContext;
|
|
196
239
|
}
|
|
197
|
-
/**
|
|
198
|
-
* The default execution context used in binding expressions.
|
|
199
|
-
* @public
|
|
200
|
-
*/
|
|
201
|
-
export declare const defaultExecutionContext: ExecutionContext<any, any>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SpliceStrategy } from "./arrays.js";
|
|
2
|
+
/**
|
|
3
|
+
* A SpliceStrategy that attempts to merge all splices into the minimal set of
|
|
4
|
+
* splices needed to represent the change from the old array to the new array.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const mergeSpliceStrategy: SpliceStrategy;
|
|
8
|
+
/**
|
|
9
|
+
* A splice strategy that doesn't create splices, but instead
|
|
10
|
+
* tracks every change as a full array reset.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const resetSpliceStrategy: SpliceStrategy;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Callable } from "../interfaces.js";
|
|
2
|
+
/**
|
|
3
|
+
* A work queue used to synchronize writes to the DOM.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface UpdateQueue {
|
|
7
|
+
/**
|
|
8
|
+
* Schedules DOM update work in the next batch.
|
|
9
|
+
* @param callable - The callable function or object to queue.
|
|
10
|
+
*/
|
|
11
|
+
enqueue(callable: Callable): void;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves with the next DOM update.
|
|
14
|
+
*/
|
|
15
|
+
next(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Immediately processes all work previously scheduled
|
|
18
|
+
* through enqueue.
|
|
19
|
+
* @remarks
|
|
20
|
+
* This also forces next() promises
|
|
21
|
+
* to resolve.
|
|
22
|
+
*/
|
|
23
|
+
process(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Sets the update mode used by enqueue.
|
|
26
|
+
* @param isAsync - Indicates whether DOM updates should be asynchronous.
|
|
27
|
+
* @remarks
|
|
28
|
+
* By default, the update mode is asynchronous, since that provides the best
|
|
29
|
+
* performance in the browser. Passing false to setMode will instead cause
|
|
30
|
+
* the queue to be immediately processed for each call to enqueue. However,
|
|
31
|
+
* ordering will still be preserved so that nested tasks do not run until
|
|
32
|
+
* after parent tasks complete.
|
|
33
|
+
*/
|
|
34
|
+
setMode(isAsync: boolean): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The default UpdateQueue.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare const Updates: UpdateQueue;
|
package/dist/dts/platform.d.ts
CHANGED
|
@@ -1,84 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
* A policy for use with the standard trustedTypes platform API.
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export declare type TrustedTypesPolicy = {
|
|
6
|
-
/**
|
|
7
|
-
* Creates trusted HTML.
|
|
8
|
-
* @param html - The HTML to clear as trustworthy.
|
|
9
|
-
*/
|
|
10
|
-
createHTML(html: string): string;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Enables working with trusted types.
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export declare type TrustedTypes = {
|
|
17
|
-
/**
|
|
18
|
-
* Creates a trusted types policy.
|
|
19
|
-
* @param name - The policy name.
|
|
20
|
-
* @param rules - The policy rules implementation.
|
|
21
|
-
*/
|
|
22
|
-
createPolicy(name: string, rules: TrustedTypesPolicy): TrustedTypesPolicy;
|
|
23
|
-
};
|
|
1
|
+
import type { FASTGlobal } from "./interfaces.js";
|
|
24
2
|
/**
|
|
25
3
|
* The FAST global.
|
|
26
4
|
* @internal
|
|
27
5
|
*/
|
|
28
|
-
export
|
|
29
|
-
/**
|
|
30
|
-
* The list of loaded versions.
|
|
31
|
-
*/
|
|
32
|
-
readonly versions: string[];
|
|
33
|
-
/**
|
|
34
|
-
* Gets a kernel value.
|
|
35
|
-
* @param id - The id to get the value for.
|
|
36
|
-
* @param initialize - Creates the initial value for the id if not already existing.
|
|
37
|
-
*/
|
|
38
|
-
getById<T>(id: string | number): T | null;
|
|
39
|
-
getById<T>(id: string | number, initialize: () => T): T;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* The platform global type.
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
export declare type Global = typeof globalThis & {
|
|
46
|
-
/**
|
|
47
|
-
* Enables working with trusted types.
|
|
48
|
-
*/
|
|
49
|
-
trustedTypes: TrustedTypes;
|
|
50
|
-
/**
|
|
51
|
-
* The FAST global.
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
readonly FAST: FASTGlobal;
|
|
55
|
-
};
|
|
6
|
+
export declare const FAST: FASTGlobal;
|
|
56
7
|
/**
|
|
57
|
-
* A
|
|
58
|
-
*
|
|
8
|
+
* A readonly, empty array.
|
|
9
|
+
* @remarks
|
|
10
|
+
* Typically returned by APIs that return arrays when there are
|
|
11
|
+
* no actual items to return.
|
|
59
12
|
* @public
|
|
60
13
|
*/
|
|
61
|
-
export declare const
|
|
14
|
+
export declare const emptyArray: readonly never[];
|
|
62
15
|
/**
|
|
63
|
-
*
|
|
16
|
+
* Do not change. Part of shared kernel contract.
|
|
64
17
|
* @internal
|
|
65
18
|
*/
|
|
66
|
-
export
|
|
19
|
+
export interface TypeDefinition {
|
|
20
|
+
type: Function;
|
|
21
|
+
}
|
|
67
22
|
/**
|
|
68
|
-
*
|
|
23
|
+
* Do not change. Part of shared kernel contract.
|
|
69
24
|
* @internal
|
|
70
25
|
*/
|
|
71
|
-
export
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
elementRegistry = 4
|
|
26
|
+
export interface TypeRegistry<TDefinition extends TypeDefinition> {
|
|
27
|
+
register(definition: TDefinition): boolean;
|
|
28
|
+
getByType(key: Function): TDefinition | undefined;
|
|
29
|
+
getForInstance(object: any): TDefinition | undefined;
|
|
76
30
|
}
|
|
77
31
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @remarks
|
|
80
|
-
* Typically returned by APIs that return arrays when there are
|
|
81
|
-
* no actual items to return.
|
|
32
|
+
* Do not change. Part of shared kernel contract.
|
|
82
33
|
* @internal
|
|
83
34
|
*/
|
|
84
|
-
export declare
|
|
35
|
+
export declare function createTypeRegistry<TDefinition extends TypeDefinition>(): TypeRegistry<TDefinition>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StyleStrategy, StyleTarget } from "./interfaces.js";
|
|
2
|
+
export declare class StyleElementStrategy implements StyleStrategy {
|
|
3
|
+
private readonly styles;
|
|
4
|
+
private readonly styleClass;
|
|
5
|
+
constructor(styles: string[]);
|
|
6
|
+
addStylesTo(target: StyleTarget): void;
|
|
7
|
+
removeStylesFrom(target: StyleTarget): void;
|
|
8
|
+
}
|
|
@@ -1,19 +1,57 @@
|
|
|
1
|
+
import type { Constructable } from "../interfaces.js";
|
|
1
2
|
import type { Behavior } from "../observation/behavior.js";
|
|
2
3
|
import type { ComposableStyles } from "./element-styles.js";
|
|
4
|
+
/**
|
|
5
|
+
* Used to add behaviors when constructing styles.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare type AddBehavior = (behavior: Behavior<HTMLElement>) => void;
|
|
3
9
|
/**
|
|
4
10
|
* Directive for use in {@link css}.
|
|
5
11
|
*
|
|
6
12
|
* @public
|
|
7
13
|
*/
|
|
8
|
-
export
|
|
14
|
+
export interface CSSDirective {
|
|
9
15
|
/**
|
|
10
16
|
* Creates a CSS fragment to interpolate into the CSS document.
|
|
11
17
|
* @returns - the string to interpolate into CSS
|
|
12
18
|
*/
|
|
13
|
-
createCSS(): ComposableStyles;
|
|
19
|
+
createCSS(add: AddBehavior): ComposableStyles;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Defines metadata for a CSSDirective.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export interface CSSDirectiveDefinition<TType extends Constructable<CSSDirective> = Constructable<CSSDirective>> {
|
|
14
26
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @returns - the behavior to bind to the host element, or undefined.
|
|
27
|
+
* The type that the definition provides metadata for.
|
|
17
28
|
*/
|
|
18
|
-
|
|
29
|
+
readonly type: TType;
|
|
19
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Instructs the css engine to provide dynamic styles or
|
|
33
|
+
* associate behaviors with styles.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare const CSSDirective: Readonly<{
|
|
37
|
+
/**
|
|
38
|
+
* Gets the directive definition associated with the instance.
|
|
39
|
+
* @param instance - The directive instance to retrieve the definition for.
|
|
40
|
+
*/
|
|
41
|
+
getForInstance: (object: any) => CSSDirectiveDefinition<Constructable<CSSDirective>> | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the directive definition associated with the specified type.
|
|
44
|
+
* @param type - The directive type to retrieve the definition for.
|
|
45
|
+
*/
|
|
46
|
+
getByType: (key: Function) => CSSDirectiveDefinition<Constructable<CSSDirective>> | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Defines a CSSDirective.
|
|
49
|
+
* @param type - The type to define as a directive.
|
|
50
|
+
*/
|
|
51
|
+
define<TType extends Constructable<CSSDirective>>(type: any): TType;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Decorator: Defines a CSSDirective.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export declare function cssDirective(): (type: Constructable<CSSDirective>) => void;
|