@microsoft/fast-element 1.10.0 → 2.0.0-beta.1
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 +396 -1
- package/CHANGELOG.md +68 -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 +8 -2
- package/dist/dts/components/fast-element.d.ts +5 -4
- 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 +144 -0
- package/dist/dts/observation/arrays.d.ts +207 -0
- package/dist/dts/observation/behavior.d.ts +5 -5
- package/dist/dts/observation/notifier.d.ts +18 -18
- package/dist/dts/observation/observable.d.ts +86 -29
- 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.d.ts +320 -64
- package/dist/dts/templating/children.d.ts +18 -15
- package/dist/dts/templating/compiler.d.ts +47 -28
- package/dist/dts/templating/dom.d.ts +41 -0
- package/dist/dts/templating/html-directive.d.ts +179 -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 +72 -14
- package/dist/dts/templating/slotted.d.ts +13 -14
- package/dist/dts/templating/template.d.ts +78 -23
- package/dist/dts/templating/view.d.ts +16 -23
- 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 +14 -22
- package/dist/esm/debug.js +29 -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/observation/arrays.js +269 -0
- package/dist/esm/observation/notifier.js +75 -83
- package/dist/esm/observation/observable.js +80 -107
- 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.js +465 -155
- package/dist/esm/templating/children.js +33 -23
- package/dist/esm/templating/compiler.js +235 -152
- package/dist/esm/templating/dom.js +49 -0
- package/dist/esm/templating/html-directive.js +125 -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 +38 -43
- package/dist/esm/templating/slotted.js +23 -20
- package/dist/esm/templating/template.js +71 -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 +14062 -5235
- package/dist/fast-element.d.ts +1434 -579
- package/dist/fast-element.debug.js +3824 -0
- package/dist/fast-element.debug.min.js +1 -0
- package/dist/fast-element.js +3565 -4014
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +2908 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/docs/api-report.md +590 -231
- package/docs/fast-element-2-changes.md +15 -0
- package/docs/guide/declaring-templates.md +5 -4
- package/docs/guide/defining-elements.md +3 -2
- package/docs/guide/leveraging-css.md +1 -0
- package/docs/guide/next-steps.md +3 -2
- package/docs/guide/observables-and-state.md +2 -1
- package/docs/guide/using-directives.md +2 -1
- package/docs/guide/working-with-shadow-dom.md +1 -0
- package/karma.conf.cjs +6 -17
- package/package.json +48 -14
- 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 -173
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { Constructable } from "../interfaces.js";
|
|
1
2
|
import { Controller } from "./controller.js";
|
|
2
3
|
import { PartialFASTElementDefinition } from "./fast-definitions.js";
|
|
3
4
|
/**
|
|
4
5
|
* Represents a custom element based on the FASTElement infrastructure.
|
|
5
6
|
* @public
|
|
6
7
|
*/
|
|
7
|
-
export interface FASTElement {
|
|
8
|
+
export interface FASTElement extends HTMLElement {
|
|
8
9
|
/**
|
|
9
10
|
* The underlying controller that handles the lifecycle and rendering of
|
|
10
11
|
* this FASTElement.
|
|
@@ -42,7 +43,7 @@ export interface FASTElement {
|
|
|
42
43
|
* This method is invoked by the platform whenever an observed
|
|
43
44
|
* attribute of FASTElement has a value change.
|
|
44
45
|
*/
|
|
45
|
-
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
46
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
49
|
* A minimal base class for FASTElements that also provides
|
|
@@ -65,7 +66,7 @@ export declare const FASTElement: (new () => HTMLElement & FASTElement) & {
|
|
|
65
66
|
* @param nameOrDef - The name of the element to define or a definition object
|
|
66
67
|
* that describes the element to define.
|
|
67
68
|
*/
|
|
68
|
-
define<TType extends
|
|
69
|
+
define<TType extends Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType;
|
|
69
70
|
};
|
|
70
71
|
/**
|
|
71
72
|
* Decorator: Defines a platform custom element based on `FASTElement`.
|
|
@@ -73,4 +74,4 @@ export declare const FASTElement: (new () => HTMLElement & FASTElement) & {
|
|
|
73
74
|
* that describes the element to define.
|
|
74
75
|
* @public
|
|
75
76
|
*/
|
|
76
|
-
export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type:
|
|
77
|
+
export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Constructable<HTMLElement>) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BindingObserver } from "./observation/observable.js";
|
|
2
|
+
/**
|
|
3
|
+
* Functions used for getting and setting a stateful value.
|
|
4
|
+
* @beta
|
|
5
|
+
*/
|
|
6
|
+
export declare type State<T> = [() => T, (newValue: T) => T];
|
|
7
|
+
/**
|
|
8
|
+
* Creates an observable state value.
|
|
9
|
+
* @param value The initial state value.
|
|
10
|
+
* @param deep Whether or not to convert the state value to an observable.
|
|
11
|
+
* @returns The state accessor functions.
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export declare function useState<T>(value: T, deep?: boolean): State<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Executes an action once, and then whenever any of its dependent state changes.
|
|
17
|
+
* @param action An action that is affected by state changes.
|
|
18
|
+
* @returns A BindingObserver which can be used to dispose of the effect.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useEffect(action: () => void): BindingObserver;
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
+
export type { Callable, Constructable, Disposable, FASTGlobal, Mutable, StyleStrategy, StyleTarget, TrustedTypes, TrustedTypesPolicy, } from "./interfaces.js";
|
|
1
2
|
export * from "./platform.js";
|
|
2
|
-
export * from "./templating/template.js";
|
|
3
|
-
export * from "./components/fast-element.js";
|
|
4
|
-
export { FASTElementDefinition, PartialFASTElementDefinition, } from "./components/fast-definitions.js";
|
|
5
|
-
export * from "./components/attributes.js";
|
|
6
|
-
export * from "./components/controller.js";
|
|
7
|
-
export type { Callable, Constructable, Mutable } from "./interfaces.js";
|
|
8
|
-
export * from "./templating/compiler.js";
|
|
9
|
-
export { ElementStyles, ElementStyleFactory, ComposableStyles, StyleTarget, } from "./styles/element-styles.js";
|
|
10
|
-
export { css, cssPartial } from "./styles/css.js";
|
|
11
|
-
export { CSSDirective } from "./styles/css-directive.js";
|
|
12
|
-
export * from "./templating/view.js";
|
|
13
3
|
export * from "./observation/observable.js";
|
|
14
4
|
export * from "./observation/notifier.js";
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export { DOM } from "./dom.js";
|
|
5
|
+
export * from "./observation/arrays.js";
|
|
6
|
+
export * from "./observation/update-queue.js";
|
|
18
7
|
export type { Behavior } from "./observation/behavior.js";
|
|
8
|
+
export * from "./styles/element-styles.js";
|
|
9
|
+
export * from "./styles/css.js";
|
|
10
|
+
export * from "./styles/css-directive.js";
|
|
11
|
+
export * from "./templating/dom.js";
|
|
12
|
+
export * from "./templating/template.js";
|
|
13
|
+
export * from "./templating/compiler.js";
|
|
14
|
+
export { Markup, Parser } from "./templating/markup.js";
|
|
19
15
|
export * from "./templating/binding.js";
|
|
20
16
|
export * from "./templating/html-directive.js";
|
|
21
17
|
export * from "./templating/ref.js";
|
|
@@ -23,4 +19,9 @@ export * from "./templating/when.js";
|
|
|
23
19
|
export * from "./templating/repeat.js";
|
|
24
20
|
export * from "./templating/slotted.js";
|
|
25
21
|
export * from "./templating/children.js";
|
|
26
|
-
export
|
|
22
|
+
export * from "./templating/view.js";
|
|
23
|
+
export * from "./templating/node-observation.js";
|
|
24
|
+
export * from "./components/fast-element.js";
|
|
25
|
+
export * from "./components/fast-definitions.js";
|
|
26
|
+
export * from "./components/attributes.js";
|
|
27
|
+
export * from "./components/controller.js";
|
package/dist/dts/interfaces.d.ts
CHANGED
|
@@ -13,6 +13,16 @@ 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
|
+
* Provides a mechanism for releasing resources.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export interface Disposable {
|
|
21
|
+
/**
|
|
22
|
+
* Disposes the resources.
|
|
23
|
+
*/
|
|
24
|
+
dispose(): void;
|
|
25
|
+
}
|
|
16
26
|
/**
|
|
17
27
|
* Reverses all readonly members, making them mutable.
|
|
18
28
|
* @internal
|
|
@@ -20,3 +30,137 @@ export declare type Constructable<T = {}> = {
|
|
|
20
30
|
export declare type Mutable<T> = {
|
|
21
31
|
-readonly [P in keyof T]: T[P];
|
|
22
32
|
};
|
|
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
|
+
/**
|
|
39
|
+
* A policy for use with the standard trustedTypes platform API.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare type TrustedTypesPolicy = {
|
|
43
|
+
/**
|
|
44
|
+
* Creates trusted HTML.
|
|
45
|
+
* @param html - The HTML to clear as trustworthy.
|
|
46
|
+
*/
|
|
47
|
+
createHTML(html: string): string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Enables working with trusted types.
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export declare type TrustedTypes = {
|
|
54
|
+
/**
|
|
55
|
+
* Creates a trusted types policy.
|
|
56
|
+
* @param name - The policy name.
|
|
57
|
+
* @param rules - The policy rules implementation.
|
|
58
|
+
*/
|
|
59
|
+
createPolicy(name: string, rules: TrustedTypesPolicy): TrustedTypesPolicy;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The FAST global.
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
export interface FASTGlobal {
|
|
66
|
+
/**
|
|
67
|
+
* The list of loaded versions.
|
|
68
|
+
*/
|
|
69
|
+
readonly versions: string[];
|
|
70
|
+
/**
|
|
71
|
+
* Gets a kernel value.
|
|
72
|
+
* @param id - The id to get the value for.
|
|
73
|
+
* @param initialize - Creates the initial value for the id if not already existing.
|
|
74
|
+
*/
|
|
75
|
+
getById<T>(id: string | number): T | null;
|
|
76
|
+
getById<T>(id: string | number, initialize: () => T): T;
|
|
77
|
+
/**
|
|
78
|
+
* Sends a warning to the developer.
|
|
79
|
+
* @param code - The warning code to send.
|
|
80
|
+
* @param args - Args relevant for the warning.
|
|
81
|
+
*/
|
|
82
|
+
warn(code: number, ...args: any[]): void;
|
|
83
|
+
/**
|
|
84
|
+
* Creates an error.
|
|
85
|
+
* @param code - The error code to send.
|
|
86
|
+
* @param args - Args relevant for the error.
|
|
87
|
+
*/
|
|
88
|
+
error(code: number, ...args: any[]): Error;
|
|
89
|
+
/**
|
|
90
|
+
* Adds debug messages for errors and warnings.
|
|
91
|
+
* @param messages - The message dictionary to add.
|
|
92
|
+
*/
|
|
93
|
+
addMessages(messages: Record<number, string>): void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Core services shared across FAST instances.
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
export declare const enum KernelServiceId {
|
|
100
|
+
updateQueue = 1,
|
|
101
|
+
observable = 2,
|
|
102
|
+
contextEvent = 3,
|
|
103
|
+
elementRegistry = 4,
|
|
104
|
+
styleSheetStrategy = 5,
|
|
105
|
+
developerChannel = 6
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A node that can be targeted by styles.
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export interface StyleTarget {
|
|
112
|
+
/**
|
|
113
|
+
* Stylesheets to be adopted by the node.
|
|
114
|
+
*/
|
|
115
|
+
adoptedStyleSheets?: CSSStyleSheet[];
|
|
116
|
+
/**
|
|
117
|
+
* Adds styles to the target by appending the styles.
|
|
118
|
+
* @param styles - The styles element to add.
|
|
119
|
+
*/
|
|
120
|
+
append(styles: HTMLStyleElement): void;
|
|
121
|
+
/**
|
|
122
|
+
* Removes styles from the target.
|
|
123
|
+
* @param styles - The styles element to remove.
|
|
124
|
+
*/
|
|
125
|
+
removeChild(styles: HTMLStyleElement): void;
|
|
126
|
+
/**
|
|
127
|
+
* Returns all element descendants of node that match selectors.
|
|
128
|
+
* @param selectors - The CSS selector to use for the query.
|
|
129
|
+
*/
|
|
130
|
+
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Implemented to provide specific behavior when adding/removing styles
|
|
134
|
+
* for elements.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
export interface StyleStrategy {
|
|
138
|
+
/**
|
|
139
|
+
* Adds styles to the target.
|
|
140
|
+
* @param target - The target to add the styles to.
|
|
141
|
+
*/
|
|
142
|
+
addStylesTo(target: StyleTarget): void;
|
|
143
|
+
/**
|
|
144
|
+
* Removes styles from the target.
|
|
145
|
+
* @param target - The target to remove the styles from.
|
|
146
|
+
*/
|
|
147
|
+
removeStylesFrom(target: StyleTarget): void;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Warning and error messages.
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
153
|
+
export declare const enum Message {
|
|
154
|
+
needsArrayObservation = 1101,
|
|
155
|
+
onlySetHTMLPolicyOnce = 1201,
|
|
156
|
+
bindingInnerHTMLRequiresTrustedTypes = 1202,
|
|
157
|
+
missingElementDefinition = 1401
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
162
|
+
export declare const isFunction: (object: any) => object is Function;
|
|
163
|
+
/**
|
|
164
|
+
* @internal
|
|
165
|
+
*/
|
|
166
|
+
export declare const isString: (object: any) => object is string;
|
|
@@ -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 length<T>(array: readonly T[]): number;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type { ExecutionContext } from "./observable.js";
|
|
1
|
+
import type { ExecutionContext, RootContext } 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, TContext extends ExecutionContext<TParent> = RootContext> {
|
|
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: TContext): 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: TContext): 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.
|