@microsoft/fast-element 2.0.0-beta.1 → 2.0.0-beta.11
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 +348 -0
- package/CHANGELOG.md +114 -1
- package/dist/dts/components/attributes.d.ts +10 -0
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +49 -25
- package/dist/dts/components/fast-definitions.d.ts +43 -9
- package/dist/dts/components/fast-element.d.ts +15 -21
- package/dist/dts/context.d.ts +157 -0
- package/dist/dts/di/di.d.ts +899 -0
- package/dist/dts/index.d.ts +2 -2
- package/dist/dts/interfaces.d.ts +45 -14
- package/dist/dts/metadata.d.ts +25 -0
- package/dist/dts/observation/arrays.d.ts +1 -1
- package/dist/dts/observation/observable.d.ts +101 -75
- package/dist/dts/pending-task.d.ts +20 -0
- package/dist/dts/platform.d.ts +7 -0
- package/dist/dts/polyfills.d.ts +1 -8
- 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 +10 -17
- 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 +69 -294
- package/dist/dts/templating/children.d.ts +1 -1
- package/dist/dts/templating/compiler.d.ts +1 -2
- package/dist/dts/templating/html-directive.d.ts +93 -35
- 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 +272 -0
- package/dist/dts/templating/repeat.d.ts +20 -75
- package/dist/dts/templating/slotted.d.ts +1 -1
- package/dist/dts/templating/template.d.ts +12 -61
- package/dist/dts/templating/view.d.ts +77 -12
- 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} +0 -0
- 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} +188 -109
- package/dist/esm/components/fast-definitions.js +38 -28
- package/dist/esm/components/fast-element.js +31 -12
- package/dist/esm/context.js +163 -0
- package/dist/esm/debug.js +36 -4
- package/dist/esm/di/di.js +1435 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/interfaces.js +4 -0
- package/dist/esm/metadata.js +60 -0
- package/dist/esm/observation/arrays.js +304 -3
- package/dist/esm/observation/observable.js +81 -87
- package/dist/esm/pending-task.js +16 -0
- package/dist/esm/platform.js +26 -1
- package/dist/esm/polyfills.js +1 -55
- 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/styles/element-styles.js +14 -33
- package/dist/esm/{observation/behavior.js → styles/host.js} +0 -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 +134 -414
- package/dist/esm/templating/compiler.js +30 -7
- package/dist/esm/templating/html-directive.js +100 -28
- package/dist/esm/templating/node-observation.js +9 -8
- package/dist/esm/templating/ref.js +4 -12
- package/dist/esm/templating/render.js +391 -0
- package/dist/esm/templating/repeat.js +96 -72
- package/dist/esm/templating/template.js +11 -29
- package/dist/esm/templating/view.js +107 -29
- package/dist/esm/templating/when.js +5 -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 +0 -95
- package/dist/fast-element.api.json +9278 -10745
- package/dist/fast-element.d.ts +707 -813
- package/dist/fast-element.debug.js +1229 -944
- package/dist/fast-element.debug.min.js +1 -1
- package/dist/fast-element.js +1191 -938
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +716 -824
- package/docs/api-report.md +265 -319
- package/package.json +39 -14
- package/dist/dts/hooks.d.ts +0 -20
- package/dist/dts/observation/behavior.d.ts +0 -19
- package/dist/dts/observation/splice-strategies.d.ts +0 -13
- package/dist/esm/hooks.js +0 -32
- package/dist/esm/observation/splice-strategies.js +0 -400
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
|
|
27
|
+
export { ElementController } from "./components/element-controller.js";
|
package/dist/dts/interfaces.d.ts
CHANGED
|
@@ -13,6 +13,20 @@ export declare type Callable = typeof Function.prototype.call | {
|
|
|
13
13
|
export declare type Constructable<T = {}> = {
|
|
14
14
|
new (...args: any[]): T;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Represents a class.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare type Class<T, C = {}> = C & {
|
|
21
|
+
/**
|
|
22
|
+
* The class's prototype;
|
|
23
|
+
*/
|
|
24
|
+
readonly prototype: T;
|
|
25
|
+
/**
|
|
26
|
+
* The class's constructor.
|
|
27
|
+
*/
|
|
28
|
+
new (...args: any[]): T;
|
|
29
|
+
};
|
|
16
30
|
/**
|
|
17
31
|
* Provides a mechanism for releasing resources.
|
|
18
32
|
* @public
|
|
@@ -30,11 +44,6 @@ export interface Disposable {
|
|
|
30
44
|
export declare type Mutable<T> = {
|
|
31
45
|
-readonly [P in keyof T]: T[P];
|
|
32
46
|
};
|
|
33
|
-
/**
|
|
34
|
-
* Extracts the item type from an array.
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
export declare type ArrayItem<T> = T extends ReadonlyArray<infer TItem> ? TItem : T extends Array<infer TItem> ? TItem : any;
|
|
38
47
|
/**
|
|
39
48
|
* A policy for use with the standard trustedTypes platform API.
|
|
40
49
|
* @public
|
|
@@ -77,18 +86,21 @@ export interface FASTGlobal {
|
|
|
77
86
|
/**
|
|
78
87
|
* Sends a warning to the developer.
|
|
79
88
|
* @param code - The warning code to send.
|
|
80
|
-
* @param
|
|
89
|
+
* @param values - Values relevant for the warning message.
|
|
81
90
|
*/
|
|
82
|
-
warn(code: number,
|
|
91
|
+
warn(code: number, values?: Record<string, any>): void;
|
|
83
92
|
/**
|
|
84
93
|
* Creates an error.
|
|
85
94
|
* @param code - The error code to send.
|
|
86
|
-
* @param
|
|
95
|
+
* @param values - Values relevant for the error message.
|
|
87
96
|
*/
|
|
88
|
-
error(code: number,
|
|
97
|
+
error(code: number, values?: Record<string, any>): Error;
|
|
89
98
|
/**
|
|
90
99
|
* Adds debug messages for errors and warnings.
|
|
91
100
|
* @param messages - The message dictionary to add.
|
|
101
|
+
* @remarks
|
|
102
|
+
* Message can include placeholders like $\{name\} which can be
|
|
103
|
+
* replaced by values passed at runtime.
|
|
92
104
|
*/
|
|
93
105
|
addMessages(messages: Record<number, string>): void;
|
|
94
106
|
}
|
|
@@ -100,15 +112,13 @@ export declare const enum KernelServiceId {
|
|
|
100
112
|
updateQueue = 1,
|
|
101
113
|
observable = 2,
|
|
102
114
|
contextEvent = 3,
|
|
103
|
-
elementRegistry = 4
|
|
104
|
-
styleSheetStrategy = 5,
|
|
105
|
-
developerChannel = 6
|
|
115
|
+
elementRegistry = 4
|
|
106
116
|
}
|
|
107
117
|
/**
|
|
108
118
|
* A node that can be targeted by styles.
|
|
109
119
|
* @public
|
|
110
120
|
*/
|
|
111
|
-
export interface StyleTarget {
|
|
121
|
+
export interface StyleTarget extends Pick<Node, "getRootNode"> {
|
|
112
122
|
/**
|
|
113
123
|
* Stylesheets to be adopted by the node.
|
|
114
124
|
*/
|
|
@@ -154,7 +164,24 @@ export declare const enum Message {
|
|
|
154
164
|
needsArrayObservation = 1101,
|
|
155
165
|
onlySetHTMLPolicyOnce = 1201,
|
|
156
166
|
bindingInnerHTMLRequiresTrustedTypes = 1202,
|
|
157
|
-
|
|
167
|
+
twoWayBindingRequiresObservables = 1203,
|
|
168
|
+
hostBindingWithoutHost = 1204,
|
|
169
|
+
unsupportedBindingBehavior = 1205,
|
|
170
|
+
missingElementDefinition = 1401,
|
|
171
|
+
noRegistrationForContext = 1501,
|
|
172
|
+
noFactoryForResolver = 1502,
|
|
173
|
+
invalidResolverStrategy = 1503,
|
|
174
|
+
cannotAutoregisterDependency = 1504,
|
|
175
|
+
cannotResolveKey = 1505,
|
|
176
|
+
cannotConstructNativeFunction = 1506,
|
|
177
|
+
cannotJITRegisterNonConstructor = 1507,
|
|
178
|
+
cannotJITRegisterIntrinsic = 1508,
|
|
179
|
+
cannotJITRegisterInterface = 1509,
|
|
180
|
+
invalidResolver = 1510,
|
|
181
|
+
invalidKey = 1511,
|
|
182
|
+
noDefaultResolver = 1512,
|
|
183
|
+
cyclicDependency = 1513,
|
|
184
|
+
connectUpdateRequiresController = 1514
|
|
158
185
|
}
|
|
159
186
|
/**
|
|
160
187
|
* @internal
|
|
@@ -164,3 +191,7 @@ export declare const isFunction: (object: any) => object is Function;
|
|
|
164
191
|
* @internal
|
|
165
192
|
*/
|
|
166
193
|
export declare const isString: (object: any) => object is string;
|
|
194
|
+
/**
|
|
195
|
+
* @internal
|
|
196
|
+
*/
|
|
197
|
+
export declare const noop: () => undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Constructable } from "./interfaces.js";
|
|
2
|
+
/**
|
|
3
|
+
* Provides basic metadata capabilities used by Context and Dependency Injection.
|
|
4
|
+
*/
|
|
5
|
+
export declare const Metadata: Readonly<{
|
|
6
|
+
/**
|
|
7
|
+
* Gets the "design:paramtypes" metadata for the specified type.
|
|
8
|
+
* @param Type - The type to get the metadata for.
|
|
9
|
+
* @returns The metadata array or a frozen empty array if no metadata is found.
|
|
10
|
+
*/
|
|
11
|
+
getDesignParamTypes: (Type: any) => any;
|
|
12
|
+
/**
|
|
13
|
+
* Gets the "annotation:paramtypes" metadata for the specified type.
|
|
14
|
+
* @param Type - The type to get the metadata for.
|
|
15
|
+
* @returns The metadata array or a frozen empty array if no metadata is found.
|
|
16
|
+
*/
|
|
17
|
+
getAnnotationParamTypes: (Type: any) => any;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param Type - Gets the "annotation:paramtypes" metadata for the specified type. If none is found,
|
|
21
|
+
* an empty, mutable metadata array is created and added.
|
|
22
|
+
* @returns The metadata array.
|
|
23
|
+
*/
|
|
24
|
+
getOrCreateAnnotationParamTypes(Type: Constructable): any[];
|
|
25
|
+
}>;
|
|
@@ -23,10 +23,10 @@ export interface Accessor {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* The signature of an arrow function capable of being evaluated
|
|
26
|
-
*
|
|
26
|
+
* against source data and within an execution context.
|
|
27
27
|
* @public
|
|
28
28
|
*/
|
|
29
|
-
export declare type
|
|
29
|
+
export declare type Expression<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn;
|
|
30
30
|
/**
|
|
31
31
|
* A record of observable property access.
|
|
32
32
|
* @public
|
|
@@ -41,20 +41,80 @@ export interface ObservationRecord {
|
|
|
41
41
|
*/
|
|
42
42
|
propertyName: string;
|
|
43
43
|
}
|
|
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.
|
|
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;
|
|
104
|
+
}
|
|
44
105
|
/**
|
|
45
106
|
* Enables evaluation of and subscription to a binding.
|
|
46
107
|
* @public
|
|
47
108
|
*/
|
|
48
|
-
export interface
|
|
109
|
+
export interface ExpressionNotifier<TSource = any, TReturn = any, TParent = any> extends Notifier, ExpressionObserver<TSource, TReturn, TParent>, Disposable {
|
|
49
110
|
/**
|
|
50
|
-
*
|
|
51
|
-
* @param source - The source
|
|
52
|
-
* @param context - The
|
|
53
|
-
* @returns The value of the binding.
|
|
111
|
+
* Observes the expression.
|
|
112
|
+
* @param source - The source for the expression.
|
|
113
|
+
* @param context - The context for the expression.
|
|
54
114
|
*/
|
|
55
|
-
observe(source: TSource, context?: ExecutionContext
|
|
115
|
+
observe(source: TSource, context?: ExecutionContext): TReturn;
|
|
56
116
|
/**
|
|
57
|
-
* Gets {@link ObservationRecord|ObservationRecords} that the {@link
|
|
117
|
+
* Gets {@link ObservationRecord|ObservationRecords} that the {@link ExpressionNotifier}
|
|
58
118
|
* is observing.
|
|
59
119
|
*/
|
|
60
120
|
records(): IterableIterator<ObservationRecord>;
|
|
@@ -114,19 +174,19 @@ export declare const Observable: Readonly<{
|
|
|
114
174
|
*/
|
|
115
175
|
getAccessors: (target: {}) => Accessor[];
|
|
116
176
|
/**
|
|
117
|
-
* Creates a {@link
|
|
118
|
-
* provided {@link
|
|
119
|
-
* @param
|
|
177
|
+
* Creates a {@link ExpressionNotifier} that can watch the
|
|
178
|
+
* provided {@link Expression} for changes.
|
|
179
|
+
* @param expression - The binding to observe.
|
|
120
180
|
* @param initialSubscriber - An initial subscriber to changes in the binding value.
|
|
121
181
|
* @param isVolatileBinding - Indicates whether the binding's dependency list must be re-evaluated on every value evaluation.
|
|
122
182
|
*/
|
|
123
|
-
binding<TSource = any, TReturn = any>(
|
|
183
|
+
binding<TSource = any, TReturn = any>(expression: Expression<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): ExpressionNotifier<TSource, TReturn, any>;
|
|
124
184
|
/**
|
|
125
185
|
* Determines whether a binding expression is volatile and needs to have its dependency list re-evaluated
|
|
126
186
|
* on every evaluation of the value.
|
|
127
|
-
* @param
|
|
187
|
+
* @param expression - The binding to inspect.
|
|
128
188
|
*/
|
|
129
|
-
isVolatileBinding<TSource_1 = any, TReturn_1 = any>(
|
|
189
|
+
isVolatileBinding<TSource_1 = any, TReturn_1 = any>(expression: Expression<TSource_1, TReturn_1, any>): boolean;
|
|
130
190
|
}>;
|
|
131
191
|
/**
|
|
132
192
|
* Decorator: Defines an observable property on the target.
|
|
@@ -147,60 +207,27 @@ export declare function volatile(target: {}, name: string | Accessor, descriptor
|
|
|
147
207
|
* Provides additional contextual information available to behaviors and expressions.
|
|
148
208
|
* @public
|
|
149
209
|
*/
|
|
150
|
-
export interface
|
|
151
|
-
/**
|
|
152
|
-
* The current event within an event handler.
|
|
153
|
-
*/
|
|
154
|
-
readonly event: Event;
|
|
210
|
+
export interface ExecutionContext<TParent = any> {
|
|
155
211
|
/**
|
|
156
|
-
*
|
|
157
|
-
*/
|
|
158
|
-
eventDetail<TDetail = any>(): TDetail;
|
|
159
|
-
/**
|
|
160
|
-
* Returns the typed event target of the event.
|
|
212
|
+
* The index of the current item within a repeat context.
|
|
161
213
|
*/
|
|
162
|
-
|
|
214
|
+
index: number;
|
|
163
215
|
/**
|
|
164
|
-
*
|
|
165
|
-
* @param source - The source for the context if different than the parent.
|
|
166
|
-
* @returns A child execution context.
|
|
216
|
+
* The length of the current collection within a repeat context.
|
|
167
217
|
*/
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Provides additional contextual information when inside a child template.
|
|
172
|
-
* @public
|
|
173
|
-
*/
|
|
174
|
-
export interface ChildContext<TParentSource = any> extends RootContext {
|
|
218
|
+
length: number;
|
|
175
219
|
/**
|
|
176
220
|
* The parent data source within a nested context.
|
|
177
221
|
*/
|
|
178
|
-
|
|
222
|
+
parent: TParent;
|
|
179
223
|
/**
|
|
180
224
|
* The parent execution context when in nested context scenarios.
|
|
181
225
|
*/
|
|
182
|
-
|
|
226
|
+
parentContext: ExecutionContext<TParent>;
|
|
183
227
|
/**
|
|
184
|
-
*
|
|
185
|
-
* @param item - The list item to serve as the source.
|
|
186
|
-
* @param index - The index of the item in the list.
|
|
187
|
-
* @param length - The length of the list.
|
|
188
|
-
*/
|
|
189
|
-
createItemContext(index: number, length: number): ItemContext<TParentSource>;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Provides additional contextual information when inside a repeat item template.s
|
|
193
|
-
* @public
|
|
194
|
-
*/
|
|
195
|
-
export interface ItemContext<TParentSource = any> extends ChildContext<TParentSource> {
|
|
196
|
-
/**
|
|
197
|
-
* The index of the current item within a repeat context.
|
|
198
|
-
*/
|
|
199
|
-
readonly index: number;
|
|
200
|
-
/**
|
|
201
|
-
* The length of the current collection within a repeat context.
|
|
228
|
+
* The current event within an event handler.
|
|
202
229
|
*/
|
|
203
|
-
readonly
|
|
230
|
+
readonly event: Event;
|
|
204
231
|
/**
|
|
205
232
|
* Indicates whether the current item within a repeat context
|
|
206
233
|
* has an even index.
|
|
@@ -227,32 +254,31 @@ export interface ItemContext<TParentSource = any> extends ChildContext<TParentSo
|
|
|
227
254
|
*/
|
|
228
255
|
readonly isLast: boolean;
|
|
229
256
|
/**
|
|
230
|
-
*
|
|
231
|
-
* @param index - The new index of the item.
|
|
232
|
-
* @param length - The new length of the list.
|
|
257
|
+
* Returns the typed event detail of a custom event.
|
|
233
258
|
*/
|
|
234
|
-
|
|
259
|
+
eventDetail<TDetail>(): TDetail;
|
|
260
|
+
/**
|
|
261
|
+
* Returns the typed event target of the event.
|
|
262
|
+
*/
|
|
263
|
+
eventTarget<TTarget extends EventTarget>(): TTarget;
|
|
235
264
|
}
|
|
236
265
|
/**
|
|
237
|
-
*
|
|
266
|
+
* Provides additional contextual information available to behaviors and expressions.
|
|
238
267
|
* @public
|
|
239
268
|
*/
|
|
240
269
|
export declare const ExecutionContext: Readonly<{
|
|
241
|
-
default: RootContext;
|
|
242
270
|
/**
|
|
243
|
-
*
|
|
244
|
-
* @param event - The event to set.
|
|
245
|
-
* @internal
|
|
271
|
+
* A default execution context.
|
|
246
272
|
*/
|
|
247
|
-
|
|
273
|
+
default: ExecutionContext<any>;
|
|
274
|
+
/**
|
|
275
|
+
* Gets the current event.
|
|
276
|
+
* @returns An event object.
|
|
277
|
+
*/
|
|
278
|
+
getEvent(): Event | null;
|
|
248
279
|
/**
|
|
249
|
-
*
|
|
250
|
-
* @
|
|
280
|
+
* Sets the current event.
|
|
281
|
+
* @param event - An event object.
|
|
251
282
|
*/
|
|
252
|
-
|
|
283
|
+
setEvent(event: Event | null): void;
|
|
253
284
|
}>;
|
|
254
|
-
/**
|
|
255
|
-
* Represents some sort of execution context.
|
|
256
|
-
* @public
|
|
257
|
-
*/
|
|
258
|
-
export declare type ExecutionContext<TParentSource = any> = RootContext | ChildContext<TParentSource> | ItemContext<TParentSource>;
|
|
@@ -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,4 +1,5 @@
|
|
|
1
1
|
import type { FASTGlobal } from "./interfaces.js";
|
|
2
|
+
import "./polyfills.js";
|
|
2
3
|
/**
|
|
3
4
|
* The FAST global.
|
|
4
5
|
* @internal
|
|
@@ -33,3 +34,9 @@ export interface TypeRegistry<TDefinition extends TypeDefinition> {
|
|
|
33
34
|
* @internal
|
|
34
35
|
*/
|
|
35
36
|
export declare function createTypeRegistry<TDefinition extends TypeDefinition>(): TypeRegistry<TDefinition>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a function capable of locating metadata associated with a type.
|
|
39
|
+
* @returns A metadata locator function.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare function createMetadataLocator<TMetadata>(): (target: {}) => TMetadata[];
|
package/dist/dts/polyfills.d.ts
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
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
|
+
export {};
|
|
@@ -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,11 +1,11 @@
|
|
|
1
1
|
import type { Constructable } from "../interfaces.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HostBehavior } from "./host.js";
|
|
3
3
|
import type { ComposableStyles } from "./element-styles.js";
|
|
4
4
|
/**
|
|
5
5
|
* Used to add behaviors when constructing styles.
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
|
-
export declare type AddBehavior = (behavior:
|
|
8
|
+
export declare type AddBehavior = (behavior: HostBehavior<HTMLElement>) => void;
|
|
9
9
|
/**
|
|
10
10
|
* Directive for use in {@link css}.
|
|
11
11
|
*
|