@microsoft/fast-element 2.0.0-beta.2 → 2.0.0-beta.21

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.
Files changed (115) hide show
  1. package/CHANGELOG.json +509 -0
  2. package/CHANGELOG.md +189 -1
  3. package/dist/dts/components/attributes.d.ts +15 -0
  4. package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +74 -28
  5. package/dist/dts/components/fast-definitions.d.ts +41 -9
  6. package/dist/dts/components/fast-element.d.ts +14 -26
  7. package/dist/dts/components/hydration.d.ts +14 -0
  8. package/dist/{esm/observation/behavior.js → dts/components/install-hydration.d.ts} +0 -0
  9. package/dist/dts/context.d.ts +7 -7
  10. package/dist/dts/di/di.d.ts +894 -0
  11. package/dist/dts/dom-policy.d.ts +83 -0
  12. package/dist/dts/dom.d.ts +100 -0
  13. package/dist/dts/index.d.ts +5 -4
  14. package/dist/dts/index.rollup.d.ts +0 -1
  15. package/dist/dts/index.rollup.debug.d.ts +0 -1
  16. package/dist/dts/interfaces.d.ts +62 -80
  17. package/dist/dts/metadata.d.ts +5 -5
  18. package/dist/dts/observation/observable.d.ts +99 -54
  19. package/dist/dts/pending-task.d.ts +32 -0
  20. package/dist/dts/platform.d.ts +8 -1
  21. package/dist/dts/polyfills.d.ts +0 -8
  22. package/dist/dts/state/exports.d.ts +3 -0
  23. package/dist/dts/state/reactive.d.ts +8 -0
  24. package/dist/dts/state/state.d.ts +141 -0
  25. package/dist/dts/state/visitor.d.ts +6 -0
  26. package/dist/dts/state/watch.d.ts +10 -0
  27. package/dist/dts/styles/css-directive.d.ts +2 -2
  28. package/dist/dts/styles/css.d.ts +0 -5
  29. package/dist/dts/styles/element-styles.d.ts +10 -17
  30. package/dist/dts/styles/host.d.ts +68 -0
  31. package/dist/dts/styles/style-strategy.d.ts +42 -0
  32. package/dist/dts/templating/binding-signal.d.ts +12 -27
  33. package/dist/dts/templating/binding-two-way.d.ts +22 -37
  34. package/dist/dts/templating/binding.d.ts +76 -208
  35. package/dist/dts/templating/children.d.ts +1 -1
  36. package/dist/dts/templating/compiler.d.ts +11 -13
  37. package/dist/dts/templating/html-directive.d.ts +91 -97
  38. package/dist/dts/templating/node-observation.d.ts +15 -6
  39. package/dist/dts/templating/ref.d.ts +7 -11
  40. package/dist/dts/templating/render.d.ts +296 -0
  41. package/dist/dts/templating/repeat.d.ts +23 -34
  42. package/dist/dts/templating/slotted.d.ts +1 -1
  43. package/dist/dts/templating/template.d.ts +92 -14
  44. package/dist/dts/templating/view.d.ts +81 -11
  45. package/dist/dts/templating/when.d.ts +3 -3
  46. package/dist/dts/testing/exports.d.ts +3 -0
  47. package/dist/dts/testing/fakes.d.ts +14 -0
  48. package/dist/dts/testing/fixture.d.ts +84 -0
  49. package/dist/dts/testing/timeout.d.ts +7 -0
  50. package/dist/dts/utilities.d.ts +55 -19
  51. package/dist/esm/components/attributes.js +28 -5
  52. package/dist/esm/components/{controller.js → element-controller.js} +238 -137
  53. package/dist/esm/components/fast-definitions.js +38 -30
  54. package/dist/esm/components/fast-element.js +27 -16
  55. package/dist/esm/components/hydration.js +35 -0
  56. package/dist/esm/components/install-hydration.js +2 -0
  57. package/dist/esm/context.js +7 -3
  58. package/dist/esm/debug.js +41 -5
  59. package/dist/esm/di/di.js +1430 -0
  60. package/dist/esm/dom-policy.js +345 -0
  61. package/dist/esm/dom.js +101 -0
  62. package/dist/esm/index.js +4 -2
  63. package/dist/esm/index.rollup.debug.js +3 -1
  64. package/dist/esm/index.rollup.js +3 -1
  65. package/dist/esm/interfaces.js +52 -0
  66. package/dist/esm/metadata.js +9 -8
  67. package/dist/esm/observation/arrays.js +303 -2
  68. package/dist/esm/observation/observable.js +88 -142
  69. package/dist/esm/observation/update-queue.js +2 -2
  70. package/dist/esm/pending-task.js +28 -0
  71. package/dist/esm/platform.js +28 -3
  72. package/dist/esm/polyfills.js +3 -61
  73. package/dist/esm/state/exports.js +3 -0
  74. package/dist/esm/state/reactive.js +34 -0
  75. package/dist/esm/state/state.js +148 -0
  76. package/dist/esm/state/visitor.js +28 -0
  77. package/dist/esm/state/watch.js +36 -0
  78. package/dist/esm/styles/css.js +4 -9
  79. package/dist/esm/styles/element-styles.js +14 -33
  80. package/dist/esm/styles/host.js +1 -0
  81. package/dist/esm/styles/style-strategy.js +1 -0
  82. package/dist/esm/templating/binding-signal.js +67 -62
  83. package/dist/esm/templating/binding-two-way.js +72 -39
  84. package/dist/esm/templating/binding.js +142 -286
  85. package/dist/esm/templating/children.js +8 -4
  86. package/dist/esm/templating/compiler.js +59 -43
  87. package/dist/esm/templating/html-directive.js +56 -75
  88. package/dist/esm/templating/node-observation.js +20 -13
  89. package/dist/esm/templating/ref.js +4 -12
  90. package/dist/esm/templating/render.js +402 -0
  91. package/dist/esm/templating/repeat.js +88 -75
  92. package/dist/esm/templating/template.js +132 -60
  93. package/dist/esm/templating/view.js +113 -29
  94. package/dist/esm/templating/when.js +5 -4
  95. package/dist/esm/testing/exports.js +3 -0
  96. package/dist/esm/testing/fakes.js +107 -0
  97. package/dist/esm/testing/fixture.js +86 -0
  98. package/dist/esm/testing/timeout.js +24 -0
  99. package/dist/esm/utilities.js +97 -96
  100. package/dist/fast-element.api.json +9741 -8201
  101. package/dist/fast-element.d.ts +889 -646
  102. package/dist/fast-element.debug.js +2001 -1167
  103. package/dist/fast-element.debug.min.js +1 -1
  104. package/dist/fast-element.js +1907 -1109
  105. package/dist/fast-element.min.js +1 -1
  106. package/dist/fast-element.untrimmed.d.ts +913 -703
  107. package/docs/api-report.md +331 -258
  108. package/package.json +38 -16
  109. package/dist/dts/hooks.d.ts +0 -20
  110. package/dist/dts/observation/behavior.d.ts +0 -19
  111. package/dist/dts/observation/splice-strategies.d.ts +0 -13
  112. package/dist/dts/templating/dom.d.ts +0 -41
  113. package/dist/esm/hooks.js +0 -32
  114. package/dist/esm/observation/splice-strategies.js +0 -400
  115. package/dist/esm/templating/dom.js +0 -49
@@ -0,0 +1,83 @@
1
+ import { DOMAspect, DOMPolicy, DOMSink } from "./dom.js";
2
+ import { TrustedTypesPolicy } from "./interfaces.js";
3
+ /**
4
+ * A specific DOM sink guard for a node aspect.
5
+ * @public
6
+ */
7
+ export declare type DOMSinkGuards = Record<string, (tagName: string | null, aspect: DOMAspect, aspectName: string, sink: DOMSink) => DOMSink>;
8
+ /**
9
+ * Aspect-specific guards for a DOM Policy.
10
+ * @public
11
+ */
12
+ export declare type DOMAspectGuards = {
13
+ /**
14
+ * Guards for attributes.
15
+ */
16
+ [DOMAspect.attribute]?: DOMSinkGuards;
17
+ /**
18
+ * Guards for boolean attributes.
19
+ */
20
+ [DOMAspect.booleanAttribute]?: DOMSinkGuards;
21
+ /**
22
+ * Guards for properties.
23
+ */
24
+ [DOMAspect.property]?: DOMSinkGuards;
25
+ /**
26
+ * Guards for content.
27
+ */
28
+ [DOMAspect.content]?: DOMSinkGuards;
29
+ /**
30
+ * Guards for token list manipulation.
31
+ */
32
+ [DOMAspect.tokenList]?: DOMSinkGuards;
33
+ /**
34
+ * Guards for events.
35
+ */
36
+ [DOMAspect.event]?: DOMSinkGuards;
37
+ };
38
+ /**
39
+ * Element-specific guards for a DOM Policy.
40
+ * @public
41
+ */
42
+ export declare type DOMElementGuards = Record<string, DOMAspectGuards>;
43
+ /**
44
+ * Guard configuration for a DOM Policy.
45
+ * @public
46
+ */
47
+ export declare type DOMGuards = {
48
+ /**
49
+ * Guards for specific elements.
50
+ */
51
+ elements: DOMElementGuards;
52
+ /**
53
+ * General aspect guards independent of the element type.
54
+ */
55
+ aspects: DOMAspectGuards;
56
+ };
57
+ /**
58
+ * Options for creating a DOM Policy.
59
+ * @public
60
+ */
61
+ export declare type DOMPolicyOptions = {
62
+ /**
63
+ * The trusted type to use for HTML creation.
64
+ */
65
+ trustedType?: TrustedTypesPolicy;
66
+ /**
67
+ * The DOM guards used to override or extend the defaults.
68
+ */
69
+ guards?: Partial<DOMGuards>;
70
+ };
71
+ /**
72
+ * A helper for creating DOM policies.
73
+ * @public
74
+ */
75
+ declare const DOMPolicy: Readonly<{
76
+ /**
77
+ * Creates a new DOM Policy object.
78
+ * @param options The options to use in creating the policy.
79
+ * @returns The newly created DOMPolicy.
80
+ */
81
+ create(options?: DOMPolicyOptions): Readonly<DOMPolicy>;
82
+ }>;
83
+ export { DOMPolicy };
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The type of HTML aspect to target.
3
+ * @public
4
+ */
5
+ export declare const DOMAspect: Readonly<{
6
+ /**
7
+ * Not aspected.
8
+ */
9
+ readonly none: 0;
10
+ /**
11
+ * An attribute.
12
+ */
13
+ readonly attribute: 1;
14
+ /**
15
+ * A boolean attribute.
16
+ */
17
+ readonly booleanAttribute: 2;
18
+ /**
19
+ * A property.
20
+ */
21
+ readonly property: 3;
22
+ /**
23
+ * Content
24
+ */
25
+ readonly content: 4;
26
+ /**
27
+ * A token list.
28
+ */
29
+ readonly tokenList: 5;
30
+ /**
31
+ * An event.
32
+ */
33
+ readonly event: 6;
34
+ }>;
35
+ /**
36
+ * The type of HTML aspect to target.
37
+ * @public
38
+ */
39
+ export declare type DOMAspect = typeof DOMAspect[Exclude<keyof typeof DOMAspect, "none">];
40
+ /**
41
+ * A function used to send values to a DOM sink.
42
+ * @public
43
+ */
44
+ export declare type DOMSink = (target: Node, aspectName: string, value: any, ...args: any[]) => void;
45
+ /**
46
+ * A security policy that FAST can use to interact with the DOM.
47
+ * @public
48
+ */
49
+ export interface DOMPolicy {
50
+ /**
51
+ * Creates safe HTML from the provided value.
52
+ * @param value - The source to convert to safe HTML.
53
+ */
54
+ createHTML(value: string): string;
55
+ /**
56
+ * Protects a DOM sink that intends to write to the DOM.
57
+ * @param tagName - The tag name for the element to write to.
58
+ * @param aspect - The aspect of the DOM to write to.
59
+ * @param aspectName - The name of the aspect to write to.
60
+ * @param sink - The sink that is used to write to the DOM.
61
+ */
62
+ protect(tagName: string | null, aspect: DOMAspect, aspectName: string, sink: DOMSink): DOMSink;
63
+ }
64
+ /**
65
+ * Common DOM APIs.
66
+ * @public
67
+ */
68
+ export declare const DOM: Readonly<{
69
+ /**
70
+ * Gets the dom policy used by the templating system.
71
+ */
72
+ readonly policy: DOMPolicy;
73
+ /**
74
+ * Sets the dom policy used by the templating system.
75
+ * @param policy - The policy to set.
76
+ * @remarks
77
+ * This API can only be called once, for security reasons. It should be
78
+ * called by the application developer at the start of their program.
79
+ */
80
+ setPolicy(value: DOMPolicy): void;
81
+ /**
82
+ * Sets an attribute value on an element.
83
+ * @param element - The element to set the attribute value on.
84
+ * @param attributeName - The attribute name to set.
85
+ * @param value - The value of the attribute to set.
86
+ * @remarks
87
+ * If the value is `null` or `undefined`, the attribute is removed, otherwise
88
+ * it is set to the provided value using the standard `setAttribute` API.
89
+ */
90
+ setAttribute(element: HTMLElement, attributeName: string, value: any): void;
91
+ /**
92
+ * Sets a boolean attribute value.
93
+ * @param element - The element to set the boolean attribute value on.
94
+ * @param attributeName - The attribute name to set.
95
+ * @param value - The value of the attribute to set.
96
+ * @remarks
97
+ * If the value is true, the attribute is added; otherwise it is removed.
98
+ */
99
+ setBooleanAttribute(element: HTMLElement, attributeName: string, value: boolean): void;
100
+ }>;
@@ -1,14 +1,15 @@
1
- export type { Callable, Constructable, Disposable, FASTGlobal, Mutable, StyleStrategy, StyleTarget, TrustedTypes, TrustedTypesPolicy, } from "./interfaces.js";
1
+ export type { Callable, Constructable, Class, Disposable, FASTGlobal, TrustedTypesPolicy, } from "./interfaces.js";
2
2
  export * from "./platform.js";
3
+ export * from "./dom.js";
3
4
  export * from "./observation/observable.js";
4
5
  export * from "./observation/notifier.js";
5
6
  export * from "./observation/arrays.js";
6
7
  export * from "./observation/update-queue.js";
7
- export type { Behavior } from "./observation/behavior.js";
8
8
  export * from "./styles/element-styles.js";
9
9
  export * from "./styles/css.js";
10
10
  export * from "./styles/css-directive.js";
11
- export * from "./templating/dom.js";
11
+ export * from "./styles/host.js";
12
+ export * from "./styles/style-strategy.js";
12
13
  export * from "./templating/template.js";
13
14
  export * from "./templating/compiler.js";
14
15
  export { Markup, Parser } from "./templating/markup.js";
@@ -24,4 +25,4 @@ export * from "./templating/node-observation.js";
24
25
  export * from "./components/fast-element.js";
25
26
  export * from "./components/fast-definitions.js";
26
27
  export * from "./components/attributes.js";
27
- export * from "./components/controller.js";
28
+ export { ElementController, ElementControllerStrategy, } from "./components/element-controller.js";
@@ -1,2 +1 @@
1
- import "./polyfills.js";
2
1
  export * from "./index.js";
@@ -1,3 +1,2 @@
1
- import "./polyfills.js";
2
1
  import "./debug.js";
3
2
  export * from "./index.js";
@@ -6,13 +6,23 @@ export declare type Callable = typeof Function.prototype.call | {
6
6
  call(): void;
7
7
  };
8
8
  /**
9
- * Allows for the creation of Constructable mixin classes.
9
+ * Represents a type which can be constructed with the new operator.
10
10
  *
11
11
  * @public
12
12
  */
13
13
  export declare type Constructable<T = {}> = {
14
14
  new (...args: any[]): T;
15
15
  };
16
+ /**
17
+ * Represents a constructable class with a prototype.
18
+ * @public
19
+ */
20
+ export declare type Class<T, C = {}> = C & Constructable<T> & {
21
+ /**
22
+ * The class's prototype;
23
+ */
24
+ readonly prototype: T;
25
+ };
16
26
  /**
17
27
  * Provides a mechanism for releasing resources.
18
28
  * @public
@@ -23,18 +33,6 @@ export interface Disposable {
23
33
  */
24
34
  dispose(): void;
25
35
  }
26
- /**
27
- * Reverses all readonly members, making them mutable.
28
- * @internal
29
- */
30
- export declare type Mutable<T> = {
31
- -readonly [P in keyof T]: T[P];
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
36
  /**
39
37
  * A policy for use with the standard trustedTypes platform API.
40
38
  * @public
@@ -47,20 +45,15 @@ export declare type TrustedTypesPolicy = {
47
45
  createHTML(html: string): string;
48
46
  };
49
47
  /**
50
- * Enables working with trusted types.
51
- * @public
48
+ * Reverses all readonly members, making them mutable.
49
+ * @internal
52
50
  */
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;
51
+ export declare type Mutable<T> = {
52
+ -readonly [P in keyof T]: T[P];
60
53
  };
61
54
  /**
62
55
  * The FAST global.
63
- * @internal
56
+ * @public
64
57
  */
65
58
  export interface FASTGlobal {
66
59
  /**
@@ -77,90 +70,79 @@ export interface FASTGlobal {
77
70
  /**
78
71
  * Sends a warning to the developer.
79
72
  * @param code - The warning code to send.
80
- * @param args - Args relevant for the warning.
73
+ * @param values - Values relevant for the warning message.
81
74
  */
82
- warn(code: number, ...args: any[]): void;
75
+ warn(code: number, values?: Record<string, any>): void;
83
76
  /**
84
77
  * Creates an error.
85
78
  * @param code - The error code to send.
86
- * @param args - Args relevant for the error.
79
+ * @param values - Values relevant for the error message.
87
80
  */
88
- error(code: number, ...args: any[]): Error;
81
+ error(code: number, values?: Record<string, any>): Error;
89
82
  /**
90
83
  * Adds debug messages for errors and warnings.
91
84
  * @param messages - The message dictionary to add.
85
+ * @remarks
86
+ * Message can include placeholders like $\{name\} which can be
87
+ * replaced by values passed at runtime.
92
88
  */
93
89
  addMessages(messages: Record<number, string>): void;
94
90
  }
95
91
  /**
96
- * Core services shared across FAST instances.
92
+ * Core services that can be shared across FAST instances.
97
93
  * @internal
98
94
  */
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
- }
95
+ declare type KernelServiceId = {
96
+ readonly updateQueue: string | number;
97
+ readonly observable: string | number;
98
+ readonly contextEvent: string | number;
99
+ readonly elementRegistry: string | number;
100
+ };
101
+ declare let KernelServiceId: KernelServiceId;
102
+ export { KernelServiceId };
149
103
  /**
150
104
  * Warning and error messages.
151
105
  * @internal
152
106
  */
153
107
  export declare const enum Message {
154
108
  needsArrayObservation = 1101,
155
- onlySetHTMLPolicyOnce = 1201,
109
+ onlySetDOMPolicyOnce = 1201,
156
110
  bindingInnerHTMLRequiresTrustedTypes = 1202,
157
- missingElementDefinition = 1401
111
+ twoWayBindingRequiresObservables = 1203,
112
+ hostBindingWithoutHost = 1204,
113
+ unsupportedBindingBehavior = 1205,
114
+ directCallToHTMLTagNotAllowed = 1206,
115
+ onlySetTemplatePolicyOnce = 1207,
116
+ cannotSetTemplatePolicyAfterCompilation = 1208,
117
+ blockedByDOMPolicy = 1209,
118
+ missingElementDefinition = 1401,
119
+ noRegistrationForContext = 1501,
120
+ noFactoryForResolver = 1502,
121
+ invalidResolverStrategy = 1503,
122
+ cannotAutoregisterDependency = 1504,
123
+ cannotResolveKey = 1505,
124
+ cannotConstructNativeFunction = 1506,
125
+ cannotJITRegisterNonConstructor = 1507,
126
+ cannotJITRegisterIntrinsic = 1508,
127
+ cannotJITRegisterInterface = 1509,
128
+ invalidResolver = 1510,
129
+ invalidKey = 1511,
130
+ noDefaultResolver = 1512,
131
+ cyclicDependency = 1513,
132
+ connectUpdateRequiresController = 1514
158
133
  }
159
134
  /**
135
+ * Determines whether or not an object is a function.
160
136
  * @internal
161
137
  */
162
138
  export declare const isFunction: (object: any) => object is Function;
163
139
  /**
140
+ * Determines whether or not an object is a string.
164
141
  * @internal
165
142
  */
166
143
  export declare const isString: (object: any) => object is string;
144
+ /**
145
+ * A function which does nothing.
146
+ * @internal
147
+ */
148
+ export declare const noop: () => undefined;
@@ -8,18 +8,18 @@ export declare const Metadata: Readonly<{
8
8
  * @param Type - The type to get the metadata for.
9
9
  * @returns The metadata array or a frozen empty array if no metadata is found.
10
10
  */
11
- getDesignParamTypes: (Type: any) => any;
11
+ getDesignParamTypes: (Type: Constructable) => readonly any[];
12
12
  /**
13
13
  * Gets the "annotation:paramtypes" metadata for the specified type.
14
14
  * @param Type - The type to get the metadata for.
15
15
  * @returns The metadata array or a frozen empty array if no metadata is found.
16
16
  */
17
- getAnnotationParamTypes: (Type: any) => any;
17
+ getAnnotationParamTypes: (Type: Constructable) => readonly any[];
18
18
  /**
19
- *
20
- * @param Type - Gets the "annotation:paramtypes" metadata for the specified type. If none is found,
19
+ * Gets the "annotation:paramtypes" metadata for the specified type. If none is found,
21
20
  * an empty, mutable metadata array is created and added.
22
- * @returns The metadata array.
21
+ * @param Type - The type to get or create the metadata for.
22
+ * @returns A mutable metadata array.
23
23
  */
24
24
  getOrCreateAnnotationParamTypes(Type: Constructable): any[];
25
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
- * as part of a template binding update.
26
+ * against source data and within an execution context.
27
27
  * @public
28
28
  */
29
- export declare type Binding<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn;
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 BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier, Disposable {
109
+ export interface ExpressionNotifier<TSource = any, TReturn = any, TParent = any> extends Notifier, ExpressionObserver<TSource, TReturn, TParent>, Disposable {
49
110
  /**
50
- * Begins observing the binding for the source and returns the current value.
51
- * @param source - The source that the binding is based on.
52
- * @param context - The execution context to execute the binding within.
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<TParent>): TReturn;
115
+ observe(source: TSource, context?: ExecutionContext): TReturn;
56
116
  /**
57
- * Gets {@link ObservationRecord|ObservationRecords} that the {@link BindingObserver}
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 BindingObserver} that can watch the
118
- * provided {@link Binding} for changes.
119
- * @param binding - The binding to observe.
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>(binding: Binding<TSource, TReturn, any>, initialSubscriber?: Subscriber, isVolatileBinding?: boolean): BindingObserver<TSource, 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 binding - The binding to inspect.
187
+ * @param expression - The binding to inspect.
128
188
  */
129
- isVolatileBinding<TSource_1 = any, TReturn_1 = any>(binding: Binding<TSource_1, TReturn_1, any>): boolean;
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,11 +207,7 @@ 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 declare class ExecutionContext<TParentSource = any> {
151
- /**
152
- * The default execution context.
153
- */
154
- static readonly default: ExecutionContext<any>;
210
+ export interface ExecutionContext<TParent = any> {
155
211
  /**
156
212
  * The index of the current item within a repeat context.
157
213
  */
@@ -163,41 +219,40 @@ export declare class ExecutionContext<TParentSource = any> {
163
219
  /**
164
220
  * The parent data source within a nested context.
165
221
  */
166
- readonly parent: TParentSource;
222
+ parent: TParent;
167
223
  /**
168
224
  * The parent execution context when in nested context scenarios.
169
225
  */
170
- readonly parentContext: ExecutionContext<TParentSource>;
171
- private constructor();
226
+ parentContext: ExecutionContext<TParent>;
172
227
  /**
173
228
  * The current event within an event handler.
174
229
  */
175
- get event(): Event;
230
+ readonly event: Event;
176
231
  /**
177
232
  * Indicates whether the current item within a repeat context
178
233
  * has an even index.
179
234
  */
180
- get isEven(): boolean;
235
+ readonly isEven: boolean;
181
236
  /**
182
237
  * Indicates whether the current item within a repeat context
183
238
  * has an odd index.
184
239
  */
185
- get isOdd(): boolean;
240
+ readonly isOdd: boolean;
186
241
  /**
187
242
  * Indicates whether the current item within a repeat context
188
243
  * is the first item in the collection.
189
244
  */
190
- get isFirst(): boolean;
245
+ readonly isFirst: boolean;
191
246
  /**
192
247
  * Indicates whether the current item within a repeat context
193
248
  * is somewhere in the middle of the collection.
194
249
  */
195
- get isInMiddle(): boolean;
250
+ readonly isInMiddle: boolean;
196
251
  /**
197
252
  * Indicates whether the current item within a repeat context
198
253
  * is the last item in the collection.
199
254
  */
200
- get isLast(): boolean;
255
+ readonly isLast: boolean;
201
256
  /**
202
257
  * Returns the typed event detail of a custom event.
203
258
  */
@@ -206,34 +261,24 @@ export declare class ExecutionContext<TParentSource = any> {
206
261
  * Returns the typed event target of the event.
207
262
  */
208
263
  eventTarget<TTarget extends EventTarget>(): TTarget;
264
+ }
265
+ /**
266
+ * Provides additional contextual information available to behaviors and expressions.
267
+ * @public
268
+ */
269
+ export declare const ExecutionContext: Readonly<{
209
270
  /**
210
- * Updates the position/size on a context associated with a list item.
211
- * @param index - The new index of the item.
212
- * @param length - The new length of the list.
213
- */
214
- updatePosition(index: number, length: number): void;
215
- /**
216
- * Creates a new execution context descendent from the current context.
217
- * @param source - The source for the context if different than the parent.
218
- * @returns A child execution context.
219
- */
220
- createChildContext<TParentSource>(parentSource: TParentSource): ExecutionContext<TParentSource>;
221
- /**
222
- * Creates a new execution context descent suitable for use in list rendering.
223
- * @param item - The list item to serve as the source.
224
- * @param index - The index of the item in the list.
225
- * @param length - The length of the list.
271
+ * A default execution context.
226
272
  */
227
- createItemContext(index: number, length: number): ExecutionContext<TParentSource>;
273
+ default: ExecutionContext<any>;
228
274
  /**
229
- * Sets the event for the current execution context.
230
- * @param event - The event to set.
231
- * @internal
275
+ * Gets the current event.
276
+ * @returns An event object.
232
277
  */
233
- static setEvent(event: Event | null): void;
278
+ getEvent(): Event | null;
234
279
  /**
235
- * Creates a new root execution context.
236
- * @returns A new execution context.
280
+ * Sets the current event.
281
+ * @param event - An event object.
237
282
  */
238
- static create(): ExecutionContext;
239
- }
283
+ setEvent(event: Event | null): void;
284
+ }>;