@microsoft/fast-element 1.10.5 → 2.0.0-beta.10
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 +629 -6
- package/CHANGELOG.md +152 -5
- package/dist/dts/components/attributes.d.ts +14 -1
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +32 -32
- package/dist/dts/components/fast-definitions.d.ts +51 -11
- package/dist/dts/components/fast-element.d.ts +18 -23
- package/dist/dts/context.d.ts +157 -0
- package/dist/{esm/observation/behavior.js → dts/debug.d.ts} +0 -0
- package/dist/dts/di/di.d.ts +899 -0
- package/dist/dts/index.d.ts +17 -16
- 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 +176 -0
- package/dist/dts/metadata.d.ts +25 -0
- package/dist/dts/observation/arrays.d.ts +207 -0
- package/dist/dts/observation/notifier.d.ts +18 -18
- package/dist/dts/observation/observable.d.ts +117 -34
- package/dist/dts/observation/update-queue.d.ts +40 -0
- package/dist/dts/pending-task.d.ts +20 -0
- package/dist/dts/platform.d.ts +23 -66
- package/dist/dts/polyfills.d.ts +8 -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 +44 -6
- package/dist/dts/styles/css.d.ts +19 -3
- package/dist/dts/styles/element-styles.d.ts +49 -63
- package/dist/dts/styles/host.d.ts +68 -0
- package/dist/dts/templating/binding-signal.d.ts +21 -0
- package/dist/dts/templating/binding-two-way.d.ts +39 -0
- package/dist/dts/templating/binding.d.ts +101 -70
- 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 +239 -45
- package/dist/dts/templating/markup.d.ts +48 -0
- package/dist/dts/templating/node-observation.d.ts +45 -30
- package/dist/dts/templating/ref.d.ts +6 -20
- package/dist/dts/templating/render.d.ts +272 -0
- package/dist/dts/templating/repeat.d.ts +36 -33
- package/dist/dts/templating/slotted.d.ts +13 -14
- package/dist/dts/templating/template.d.ts +28 -22
- package/dist/dts/templating/view.d.ts +82 -24
- package/dist/dts/templating/when.d.ts +3 -3
- package/dist/dts/testing/exports.d.ts +3 -0
- package/dist/dts/testing/fakes.d.ts +4 -0
- package/dist/dts/testing/fixture.d.ts +84 -0
- package/dist/dts/testing/timeout.d.ts +7 -0
- package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
- package/dist/dts/utilities.d.ts +22 -0
- package/dist/esm/components/attributes.js +38 -28
- package/dist/esm/components/{controller.js → element-controller.js} +150 -140
- package/dist/esm/components/fast-definitions.js +48 -46
- package/dist/esm/components/fast-element.js +31 -12
- package/dist/esm/context.js +163 -0
- package/dist/esm/debug.js +61 -0
- package/dist/esm/di/di.js +1435 -0
- package/dist/esm/index.debug.js +2 -0
- package/dist/esm/index.js +20 -14
- package/dist/esm/index.rollup.debug.js +3 -0
- package/dist/esm/index.rollup.js +2 -0
- package/dist/esm/interfaces.js +12 -1
- package/dist/esm/metadata.js +60 -0
- package/dist/esm/observation/arrays.js +570 -0
- package/dist/esm/observation/notifier.js +27 -35
- package/dist/esm/observation/observable.js +116 -149
- package/dist/esm/observation/update-queue.js +67 -0
- package/dist/esm/pending-task.js +16 -0
- package/dist/esm/platform.js +60 -42
- package/dist/esm/polyfills.js +85 -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-directive.js +29 -13
- package/dist/esm/styles/css.js +29 -42
- package/dist/esm/styles/element-styles.js +79 -104
- package/dist/esm/styles/host.js +1 -0
- package/dist/esm/templating/binding-signal.js +83 -0
- package/dist/esm/templating/binding-two-way.js +103 -0
- package/dist/esm/templating/binding.js +189 -159
- package/dist/esm/templating/children.js +33 -23
- package/dist/esm/templating/compiler.js +258 -152
- package/dist/esm/templating/dom.js +49 -0
- package/dist/esm/templating/html-directive.js +193 -36
- package/dist/esm/templating/markup.js +75 -0
- package/dist/esm/templating/node-observation.js +51 -45
- package/dist/esm/templating/ref.js +8 -25
- package/dist/esm/templating/render.js +391 -0
- package/dist/esm/templating/repeat.js +83 -79
- package/dist/esm/templating/slotted.js +23 -20
- package/dist/esm/templating/template.js +51 -93
- package/dist/esm/templating/view.js +125 -46
- package/dist/esm/templating/when.js +6 -4
- package/dist/esm/testing/exports.js +3 -0
- package/dist/esm/testing/fakes.js +76 -0
- package/dist/esm/testing/fixture.js +86 -0
- package/dist/esm/testing/timeout.js +24 -0
- package/dist/esm/utilities.js +44 -0
- package/dist/fast-element.api.json +12153 -5373
- package/dist/fast-element.d.ts +1448 -696
- package/dist/fast-element.debug.js +4107 -0
- package/dist/fast-element.debug.min.js +1 -0
- package/dist/fast-element.js +3817 -4029
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +2814 -0
- package/docs/api-report.md +567 -254
- package/docs/fast-element-2-changes.md +15 -0
- package/karma.conf.cjs +6 -17
- package/package.json +76 -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/dts/observation/behavior.d.ts +0 -19
- package/dist/esm/dom.js +0 -207
- package/dist/esm/observation/array-change-records.js +0 -326
- package/dist/esm/observation/array-observer.js +0 -177
|
@@ -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.
|
|
@@ -22,10 +23,10 @@ export interface Accessor {
|
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* The signature of an arrow function capable of being evaluated
|
|
25
|
-
*
|
|
26
|
+
* against source data and within an execution context.
|
|
26
27
|
* @public
|
|
27
28
|
*/
|
|
28
|
-
export declare type
|
|
29
|
+
export declare type Expression<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn;
|
|
29
30
|
/**
|
|
30
31
|
* A record of observable property access.
|
|
31
32
|
* @public
|
|
@@ -41,26 +42,91 @@ export interface ObservationRecord {
|
|
|
41
42
|
propertyName: string;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
+
* Describes how the source's lifetime relates to its controller's lifetime.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export declare const SourceLifetime: Readonly<{
|
|
49
|
+
/**
|
|
50
|
+
* The source to controller lifetime relationship is unknown.
|
|
51
|
+
*/
|
|
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.
|
|
45
95
|
* @public
|
|
46
96
|
*/
|
|
47
|
-
export interface
|
|
97
|
+
export interface ExpressionObserver<TSource = any, TReturn = any, TParent = any> {
|
|
48
98
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @param
|
|
51
|
-
*
|
|
52
|
-
* @returns The value of the binding.
|
|
99
|
+
* Binds the expression to the source.
|
|
100
|
+
* @param controller - The controller that manages the lifecycle and related
|
|
101
|
+
* context for the expression.
|
|
53
102
|
*/
|
|
54
|
-
|
|
103
|
+
bind(controller: ExpressionController<TSource, TParent>): TReturn;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Enables evaluation of and subscription to a binding.
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export interface ExpressionNotifier<TSource = any, TReturn = any, TParent = any> extends Notifier, ExpressionObserver<TSource, TReturn, TParent>, Disposable {
|
|
55
110
|
/**
|
|
56
|
-
*
|
|
111
|
+
* Observes the expression.
|
|
112
|
+
* @param source - The source for the expression.
|
|
113
|
+
* @param context - The context for the expression.
|
|
57
114
|
*/
|
|
58
|
-
|
|
115
|
+
observe(source: TSource, context?: ExecutionContext): TReturn;
|
|
59
116
|
/**
|
|
60
|
-
* Gets {@link ObservationRecord|ObservationRecords} that the {@link
|
|
117
|
+
* Gets {@link ObservationRecord|ObservationRecords} that the {@link ExpressionNotifier}
|
|
61
118
|
* is observing.
|
|
62
119
|
*/
|
|
63
120
|
records(): IterableIterator<ObservationRecord>;
|
|
121
|
+
/**
|
|
122
|
+
* Sets the update mode used by the observer.
|
|
123
|
+
* @param isAsync - Indicates whether updates should be asynchronous.
|
|
124
|
+
* @remarks
|
|
125
|
+
* By default, the update mode is asynchronous, since that provides the best
|
|
126
|
+
* performance for template rendering scenarios. Passing false to setMode will
|
|
127
|
+
* instead cause the observer to notify subscribers immediately when changes occur.
|
|
128
|
+
*/
|
|
129
|
+
setMode(isAsync: boolean): void;
|
|
64
130
|
}
|
|
65
131
|
/**
|
|
66
132
|
* Common Observable APIs.
|
|
@@ -76,7 +142,7 @@ export declare const Observable: Readonly<{
|
|
|
76
142
|
* Gets a notifier for an object or Array.
|
|
77
143
|
* @param source - The object or Array to get the notifier for.
|
|
78
144
|
*/
|
|
79
|
-
getNotifier: (source: any) =>
|
|
145
|
+
getNotifier: <T extends Notifier = Notifier>(source: any) => T;
|
|
80
146
|
/**
|
|
81
147
|
* Records a property change for a source object.
|
|
82
148
|
* @param source - The object to record the change against.
|
|
@@ -108,19 +174,19 @@ export declare const Observable: Readonly<{
|
|
|
108
174
|
*/
|
|
109
175
|
getAccessors: (target: {}) => Accessor[];
|
|
110
176
|
/**
|
|
111
|
-
* Creates a {@link
|
|
112
|
-
* provided {@link
|
|
113
|
-
* @param
|
|
177
|
+
* Creates a {@link ExpressionNotifier} that can watch the
|
|
178
|
+
* provided {@link Expression} for changes.
|
|
179
|
+
* @param expression - The binding to observe.
|
|
114
180
|
* @param initialSubscriber - An initial subscriber to changes in the binding value.
|
|
115
181
|
* @param isVolatileBinding - Indicates whether the binding's dependency list must be re-evaluated on every value evaluation.
|
|
116
182
|
*/
|
|
117
|
-
binding<TSource = any, TReturn = any
|
|
183
|
+
binding<TSource = any, TReturn = any>(expression: Expression<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): ExpressionNotifier<TSource, TReturn, any>;
|
|
118
184
|
/**
|
|
119
185
|
* Determines whether a binding expression is volatile and needs to have its dependency list re-evaluated
|
|
120
186
|
* on every evaluation of the value.
|
|
121
|
-
* @param
|
|
187
|
+
* @param expression - The binding to inspect.
|
|
122
188
|
*/
|
|
123
|
-
isVolatileBinding<TSource_1 = any, TReturn_1 = any
|
|
189
|
+
isVolatileBinding<TSource_1 = any, TReturn_1 = any>(expression: Expression<TSource_1, TReturn_1, any>): boolean;
|
|
124
190
|
}>;
|
|
125
191
|
/**
|
|
126
192
|
* Decorator: Defines an observable property on the target.
|
|
@@ -141,7 +207,7 @@ export declare function volatile(target: {}, name: string | Accessor, descriptor
|
|
|
141
207
|
* Provides additional contextual information available to behaviors and expressions.
|
|
142
208
|
* @public
|
|
143
209
|
*/
|
|
144
|
-
export
|
|
210
|
+
export interface ExecutionContext<TParent = any> {
|
|
145
211
|
/**
|
|
146
212
|
* The index of the current item within a repeat context.
|
|
147
213
|
*/
|
|
@@ -151,51 +217,68 @@ export declare class ExecutionContext<TParent = any, TGrandparent = any> {
|
|
|
151
217
|
*/
|
|
152
218
|
length: number;
|
|
153
219
|
/**
|
|
154
|
-
* The parent data
|
|
220
|
+
* The parent data source within a nested context.
|
|
155
221
|
*/
|
|
156
222
|
parent: TParent;
|
|
157
223
|
/**
|
|
158
224
|
* The parent execution context when in nested context scenarios.
|
|
159
225
|
*/
|
|
160
|
-
parentContext: ExecutionContext<
|
|
226
|
+
parentContext: ExecutionContext<TParent>;
|
|
161
227
|
/**
|
|
162
228
|
* The current event within an event handler.
|
|
163
229
|
*/
|
|
164
|
-
|
|
230
|
+
readonly event: Event;
|
|
165
231
|
/**
|
|
166
232
|
* Indicates whether the current item within a repeat context
|
|
167
233
|
* has an even index.
|
|
168
234
|
*/
|
|
169
|
-
|
|
235
|
+
readonly isEven: boolean;
|
|
170
236
|
/**
|
|
171
237
|
* Indicates whether the current item within a repeat context
|
|
172
238
|
* has an odd index.
|
|
173
239
|
*/
|
|
174
|
-
|
|
240
|
+
readonly isOdd: boolean;
|
|
175
241
|
/**
|
|
176
242
|
* Indicates whether the current item within a repeat context
|
|
177
243
|
* is the first item in the collection.
|
|
178
244
|
*/
|
|
179
|
-
|
|
245
|
+
readonly isFirst: boolean;
|
|
180
246
|
/**
|
|
181
247
|
* Indicates whether the current item within a repeat context
|
|
182
248
|
* is somewhere in the middle of the collection.
|
|
183
249
|
*/
|
|
184
|
-
|
|
250
|
+
readonly isInMiddle: boolean;
|
|
185
251
|
/**
|
|
186
252
|
* Indicates whether the current item within a repeat context
|
|
187
253
|
* is the last item in the collection.
|
|
188
254
|
*/
|
|
189
|
-
|
|
255
|
+
readonly isLast: boolean;
|
|
190
256
|
/**
|
|
191
|
-
*
|
|
192
|
-
|
|
193
|
-
|
|
257
|
+
* Returns the typed event detail of a custom event.
|
|
258
|
+
*/
|
|
259
|
+
eventDetail<TDetail>(): TDetail;
|
|
260
|
+
/**
|
|
261
|
+
* Returns the typed event target of the event.
|
|
194
262
|
*/
|
|
195
|
-
|
|
263
|
+
eventTarget<TTarget extends EventTarget>(): TTarget;
|
|
196
264
|
}
|
|
197
265
|
/**
|
|
198
|
-
*
|
|
266
|
+
* Provides additional contextual information available to behaviors and expressions.
|
|
199
267
|
* @public
|
|
200
268
|
*/
|
|
201
|
-
export declare const
|
|
269
|
+
export declare const ExecutionContext: Readonly<{
|
|
270
|
+
/**
|
|
271
|
+
* A default execution context.
|
|
272
|
+
*/
|
|
273
|
+
default: ExecutionContext<any>;
|
|
274
|
+
/**
|
|
275
|
+
* Gets the current event.
|
|
276
|
+
* @returns An event object.
|
|
277
|
+
*/
|
|
278
|
+
getEvent(): Event | null;
|
|
279
|
+
/**
|
|
280
|
+
* Sets the current event.
|
|
281
|
+
* @param event - An event object.
|
|
282
|
+
*/
|
|
283
|
+
setEvent(event: Event | null): void;
|
|
284
|
+
}>;
|
|
@@ -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;
|
|
@@ -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
|
@@ -1,84 +1,41 @@
|
|
|
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
|
-
}
|
|
6
|
+
export declare const FAST: FASTGlobal;
|
|
41
7
|
/**
|
|
42
|
-
*
|
|
8
|
+
* A readonly, empty array.
|
|
9
|
+
* @remarks
|
|
10
|
+
* Typically returned by APIs that return arrays when there are
|
|
11
|
+
* no actual items to return.
|
|
43
12
|
* @public
|
|
44
13
|
*/
|
|
45
|
-
export declare
|
|
46
|
-
/**
|
|
47
|
-
* Enables working with trusted types.
|
|
48
|
-
*/
|
|
49
|
-
trustedTypes: TrustedTypes;
|
|
50
|
-
/**
|
|
51
|
-
* The FAST global.
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
readonly FAST: FASTGlobal;
|
|
55
|
-
};
|
|
14
|
+
export declare const emptyArray: readonly never[];
|
|
56
15
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* @public
|
|
16
|
+
* Do not change. Part of shared kernel contract.
|
|
17
|
+
* @internal
|
|
60
18
|
*/
|
|
61
|
-
export
|
|
19
|
+
export interface TypeDefinition {
|
|
20
|
+
type: Function;
|
|
21
|
+
}
|
|
62
22
|
/**
|
|
63
|
-
*
|
|
23
|
+
* Do not change. Part of shared kernel contract.
|
|
64
24
|
* @internal
|
|
65
25
|
*/
|
|
66
|
-
export
|
|
26
|
+
export interface TypeRegistry<TDefinition extends TypeDefinition> {
|
|
27
|
+
register(definition: TDefinition): boolean;
|
|
28
|
+
getByType(key: Function): TDefinition | undefined;
|
|
29
|
+
getForInstance(object: any): TDefinition | undefined;
|
|
30
|
+
}
|
|
67
31
|
/**
|
|
68
|
-
*
|
|
32
|
+
* Do not change. Part of shared kernel contract.
|
|
69
33
|
* @internal
|
|
70
34
|
*/
|
|
71
|
-
export declare
|
|
72
|
-
updateQueue = 1,
|
|
73
|
-
observable = 2,
|
|
74
|
-
contextEvent = 3,
|
|
75
|
-
elementRegistry = 4
|
|
76
|
-
}
|
|
35
|
+
export declare function createTypeRegistry<TDefinition extends TypeDefinition>(): TypeRegistry<TDefinition>;
|
|
77
36
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @
|
|
80
|
-
* Typically returned by APIs that return arrays when there are
|
|
81
|
-
* no actual items to return.
|
|
37
|
+
* Creates a function capable of locating metadata associated with a type.
|
|
38
|
+
* @returns A metadata locator function.
|
|
82
39
|
* @internal
|
|
83
40
|
*/
|
|
84
|
-
export declare
|
|
41
|
+
export declare function createMetadataLocator<TMetadata>(): (target: {}) => TMetadata[];
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a plain object to a reactive, observable object.
|
|
3
|
+
* @param object - The object to make reactive.
|
|
4
|
+
* @param deep - Indicates whether or not to deeply convert the oject.
|
|
5
|
+
* @returns The converted object.
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
export declare function reactive<T>(object: T, deep?: boolean): T;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Disposable } from "../interfaces.js";
|
|
2
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating state.
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
export declare type StateOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Indicates whether to deeply make the state value observable.
|
|
10
|
+
*/
|
|
11
|
+
deep?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* A friendly name for the state.
|
|
14
|
+
*/
|
|
15
|
+
name?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A readonly stateful value.
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export declare type ReadonlyState<T> = {
|
|
22
|
+
/**
|
|
23
|
+
* Gets the current state value.
|
|
24
|
+
*/
|
|
25
|
+
(): T;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the current state value.
|
|
28
|
+
*/
|
|
29
|
+
readonly current: T;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A read/write stateful value.
|
|
33
|
+
* @beta
|
|
34
|
+
*/
|
|
35
|
+
export declare type State<T> = ReadonlyState<T> & {
|
|
36
|
+
/**
|
|
37
|
+
* Gets or sets the current state value.
|
|
38
|
+
*/
|
|
39
|
+
current: T;
|
|
40
|
+
/**
|
|
41
|
+
* Sets the current state value.
|
|
42
|
+
* @param value The new state value.
|
|
43
|
+
*/
|
|
44
|
+
set(value: T): void;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a readonly version of the state.
|
|
47
|
+
*/
|
|
48
|
+
asReadonly(): ReadonlyState<T>;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Creates a reactive state value.
|
|
52
|
+
* @param value - The initial state value.
|
|
53
|
+
* @param options - Options to customize the state or a friendly name.
|
|
54
|
+
* @returns A State instance.
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
export declare function state<T>(value: T, options?: string | StateOptions): State<T>;
|
|
58
|
+
/**
|
|
59
|
+
* A readonly stateful value associated with an object owner.
|
|
60
|
+
* @beta
|
|
61
|
+
*/
|
|
62
|
+
export declare type ReadonlyOwnedState<T> = {
|
|
63
|
+
/**
|
|
64
|
+
* Gets the current stateful value for the owner.
|
|
65
|
+
*/
|
|
66
|
+
(owner: any): T;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A read/write stateful value associated with an owner.
|
|
70
|
+
* @beta
|
|
71
|
+
*/
|
|
72
|
+
export declare type OwnedState<T> = ReadonlyOwnedState<T> & {
|
|
73
|
+
/**
|
|
74
|
+
* Sets
|
|
75
|
+
* @param owner - The object to set the state for the owner.
|
|
76
|
+
* @param value - The new state value.
|
|
77
|
+
*/
|
|
78
|
+
set(owner: any, value: T): void;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a readonly version of the state.
|
|
81
|
+
*/
|
|
82
|
+
asReadonly(): ReadonlyOwnedState<T>;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Creates a reactive state that has its value associated with a specific owner.
|
|
86
|
+
* @param value - The initial value or a factory that provides an initial value for each owner.
|
|
87
|
+
* @param options - Options to customize the state or a friendly name.
|
|
88
|
+
* @returns An OwnedState instance.
|
|
89
|
+
* @beta
|
|
90
|
+
*/
|
|
91
|
+
export declare function ownedState<T>(value: T | (() => T), options?: string | StateOptions): OwnedState<T>;
|
|
92
|
+
/**
|
|
93
|
+
* State whose value is computed from other dependencies.
|
|
94
|
+
* @beta
|
|
95
|
+
*/
|
|
96
|
+
export declare type ComputedState<T> = ReadonlyState<T> & Disposable & {
|
|
97
|
+
/**
|
|
98
|
+
* Subscribes to notification of changes in the state.
|
|
99
|
+
* @param subscriber - The object that is subscribing for change notification.
|
|
100
|
+
*/
|
|
101
|
+
subscribe(subscriber: Subscriber): void;
|
|
102
|
+
/**
|
|
103
|
+
* Unsubscribes from notification of changes in the state.
|
|
104
|
+
* @param subscriber - The object that is unsubscribing from change notification.
|
|
105
|
+
*/
|
|
106
|
+
unsubscribe(subscriber: Subscriber): void;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* A callback that enables computation setup.
|
|
110
|
+
* @beta
|
|
111
|
+
*/
|
|
112
|
+
export declare type ComputedSetupCallback = () => (() => void) | void;
|
|
113
|
+
/**
|
|
114
|
+
* Provides computed state capabilities.
|
|
115
|
+
* @beta
|
|
116
|
+
*/
|
|
117
|
+
export declare type ComputedBuilder = {
|
|
118
|
+
/**
|
|
119
|
+
* Callbacks related to computed state.
|
|
120
|
+
*/
|
|
121
|
+
on: {
|
|
122
|
+
/**
|
|
123
|
+
* Provides a setup callback for the computation.
|
|
124
|
+
* @param callback The callback to run to setup the computation.
|
|
125
|
+
*/
|
|
126
|
+
setup(callback: ComputedSetupCallback): void;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* A callback that initializes the computation.
|
|
131
|
+
* @beta
|
|
132
|
+
*/
|
|
133
|
+
export declare type ComputedInitializer<T> = (builder: ComputedBuilder) => () => T;
|
|
134
|
+
/**
|
|
135
|
+
* Creates a ComputedState.
|
|
136
|
+
* @param initialize - The initialization callback.
|
|
137
|
+
* @param name - A friendly name for this computation.
|
|
138
|
+
* @returns A ComputedState
|
|
139
|
+
* @beta
|
|
140
|
+
*/
|
|
141
|
+
export declare function computedState<T>(initialize: ComputedInitializer<T>, name?: string): ComputedState<T>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface ObjectVisitor<TVisitorData> {
|
|
2
|
+
visitObject(object: any, data: TVisitorData): void;
|
|
3
|
+
visitArray(array: any[], data: TVisitorData): void;
|
|
4
|
+
visitProperty(object: any, key: PropertyKey, value: any, data: TVisitorData): void;
|
|
5
|
+
}
|
|
6
|
+
export declare function visitObject<TVisitorData>(object: any, deep: boolean, visitor: ObjectVisitor<TVisitorData>, data: TVisitorData, traversed: WeakSet<any> | Set<any>): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Disposable } from "../interfaces.js";
|
|
2
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
3
|
+
/**
|
|
4
|
+
* Deeply subscribes to changes in existing observable objects.
|
|
5
|
+
* @param object - The observable object to watch.
|
|
6
|
+
* @param subscriber - The handler to call when changes are made to the object.
|
|
7
|
+
* @returns A disposable that can be used to unsubscribe from change updates.
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export declare function watch(object: any, subscriber: Subscriber | ((subject: any, args: any) => void)): Disposable;
|
|
@@ -1,19 +1,57 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Constructable } from "../interfaces.js";
|
|
2
|
+
import type { HostBehavior } from "./host.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: HostBehavior<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;
|