@microsoft/fast-element 1.10.2 → 2.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/.eslintrc.json +1 -12
  2. package/CHANGELOG.json +387 -1
  3. package/CHANGELOG.md +74 -2
  4. package/README.md +2 -2
  5. package/dist/dts/components/attributes.d.ts +4 -1
  6. package/dist/dts/components/controller.d.ts +12 -11
  7. package/dist/dts/components/fast-definitions.d.ts +10 -2
  8. package/dist/dts/components/fast-element.d.ts +12 -5
  9. package/dist/dts/context.d.ts +157 -0
  10. package/dist/dts/debug.d.ts +1 -0
  11. package/dist/dts/hooks.d.ts +20 -0
  12. package/dist/dts/index.d.ts +16 -15
  13. package/dist/dts/index.debug.d.ts +2 -0
  14. package/dist/dts/index.rollup.d.ts +2 -0
  15. package/dist/dts/index.rollup.debug.d.ts +3 -0
  16. package/dist/dts/interfaces.d.ts +145 -0
  17. package/dist/dts/metadata.d.ts +25 -0
  18. package/dist/dts/observation/arrays.d.ts +207 -0
  19. package/dist/dts/observation/behavior.d.ts +4 -4
  20. package/dist/dts/observation/notifier.d.ts +18 -18
  21. package/dist/dts/observation/observable.d.ts +56 -18
  22. package/dist/dts/observation/splice-strategies.d.ts +13 -0
  23. package/dist/dts/observation/update-queue.d.ts +40 -0
  24. package/dist/dts/platform.d.ts +18 -67
  25. package/dist/dts/polyfills.d.ts +8 -0
  26. package/dist/dts/styles/css-directive.d.ts +43 -5
  27. package/dist/dts/styles/css.d.ts +19 -3
  28. package/dist/dts/styles/element-styles.d.ts +42 -62
  29. package/dist/dts/templating/binding-signal.d.ts +38 -0
  30. package/dist/dts/templating/binding-two-way.d.ts +56 -0
  31. package/dist/dts/templating/binding.d.ts +233 -65
  32. package/dist/dts/templating/children.d.ts +18 -15
  33. package/dist/dts/templating/compiler.d.ts +46 -28
  34. package/dist/dts/templating/dom.d.ts +41 -0
  35. package/dist/dts/templating/html-directive.d.ts +181 -43
  36. package/dist/dts/templating/markup.d.ts +48 -0
  37. package/dist/dts/templating/node-observation.d.ts +45 -29
  38. package/dist/dts/templating/ref.d.ts +6 -12
  39. package/dist/dts/templating/repeat.d.ts +26 -14
  40. package/dist/dts/templating/slotted.d.ts +13 -14
  41. package/dist/dts/templating/template.d.ts +27 -21
  42. package/dist/dts/templating/view.d.ts +15 -22
  43. package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
  44. package/dist/dts/utilities.d.ts +40 -0
  45. package/dist/esm/components/attributes.js +25 -24
  46. package/dist/esm/components/controller.js +77 -57
  47. package/dist/esm/components/fast-definitions.js +16 -22
  48. package/dist/esm/components/fast-element.js +10 -2
  49. package/dist/esm/context.js +159 -0
  50. package/dist/esm/debug.js +30 -0
  51. package/dist/esm/hooks.js +32 -0
  52. package/dist/esm/index.debug.js +2 -0
  53. package/dist/esm/index.js +19 -14
  54. package/dist/esm/index.rollup.debug.js +3 -0
  55. package/dist/esm/index.rollup.js +2 -0
  56. package/dist/esm/interfaces.js +8 -1
  57. package/dist/esm/metadata.js +60 -0
  58. package/dist/esm/observation/arrays.js +269 -0
  59. package/dist/esm/observation/notifier.js +27 -35
  60. package/dist/esm/observation/observable.js +93 -68
  61. package/dist/esm/observation/{array-change-records.js → splice-strategies.js} +136 -62
  62. package/dist/esm/observation/update-queue.js +67 -0
  63. package/dist/esm/platform.js +36 -42
  64. package/dist/esm/polyfills.js +85 -0
  65. package/dist/esm/styles/css-directive.js +29 -13
  66. package/dist/esm/styles/css.js +27 -40
  67. package/dist/esm/styles/element-styles.js +65 -104
  68. package/dist/esm/templating/binding-signal.js +84 -0
  69. package/dist/esm/templating/binding-two-way.js +82 -0
  70. package/dist/esm/templating/binding.js +306 -153
  71. package/dist/esm/templating/children.js +33 -23
  72. package/dist/esm/templating/compiler.js +236 -152
  73. package/dist/esm/templating/dom.js +49 -0
  74. package/dist/esm/templating/html-directive.js +128 -40
  75. package/dist/esm/templating/markup.js +75 -0
  76. package/dist/esm/templating/node-observation.js +50 -45
  77. package/dist/esm/templating/ref.js +7 -16
  78. package/dist/esm/templating/repeat.js +39 -36
  79. package/dist/esm/templating/slotted.js +23 -20
  80. package/dist/esm/templating/template.js +51 -95
  81. package/dist/esm/templating/view.js +44 -43
  82. package/dist/esm/templating/when.js +2 -1
  83. package/dist/esm/utilities.js +139 -0
  84. package/dist/fast-element.api.json +11789 -5377
  85. package/dist/fast-element.d.ts +1178 -530
  86. package/dist/fast-element.debug.js +3722 -0
  87. package/dist/fast-element.debug.min.js +1 -0
  88. package/dist/fast-element.js +3484 -4033
  89. package/dist/fast-element.min.js +1 -1
  90. package/dist/fast-element.untrimmed.d.ts +2699 -0
  91. package/docs/api-report.md +472 -219
  92. package/docs/fast-element-2-changes.md +15 -0
  93. package/docs/guide/declaring-templates.md +4 -4
  94. package/docs/guide/defining-elements.md +2 -2
  95. package/docs/guide/next-steps.md +2 -2
  96. package/docs/guide/observables-and-state.md +1 -1
  97. package/docs/guide/using-directives.md +1 -1
  98. package/karma.conf.cjs +6 -17
  99. package/package.json +63 -15
  100. package/dist/dts/dom.d.ts +0 -112
  101. package/dist/dts/observation/array-change-records.d.ts +0 -48
  102. package/dist/dts/observation/array-observer.d.ts +0 -9
  103. package/dist/esm/dom.js +0 -207
  104. package/dist/esm/observation/array-observer.js +0 -177
@@ -1,3 +1,4 @@
1
+ import { Constructable } from "../interfaces.js";
1
2
  import { ComposableStyles, ElementStyles } from "../styles/element-styles.js";
2
3
  import type { ElementViewTemplate } from "../templating/template.js";
3
4
  import { AttributeConfiguration, AttributeDefinition } from "./attributes.js";
@@ -35,7 +36,7 @@ export interface PartialFASTElementDefinition {
35
36
  * Defines metadata for a FASTElement.
36
37
  * @public
37
38
  */
38
- export declare class FASTElementDefinition<TType extends Function = Function> {
39
+ export declare class FASTElementDefinition<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> {
39
40
  private observedAttributes;
40
41
  /**
41
42
  * The type this element definition describes.
@@ -87,11 +88,18 @@ export declare class FASTElementDefinition<TType extends Function = Function> {
87
88
  /**
88
89
  * Defines a custom element based on this definition.
89
90
  * @param registry - The element registry to define the element in.
91
+ * @remarks
92
+ * This operation is idempotent per registry.
90
93
  */
91
94
  define(registry?: CustomElementRegistry): this;
92
95
  /**
93
96
  * Gets the element definition associated with the specified type.
94
97
  * @param type - The custom element type to retrieve the definition for.
95
98
  */
96
- static readonly forType: <TType_1 extends Function>(key: TType_1) => FASTElementDefinition<Function> | undefined;
99
+ static readonly getByType: (key: Function) => FASTElementDefinition<Constructable<HTMLElement>> | undefined;
100
+ /**
101
+ * Gets the element definition associated with the instance.
102
+ * @param instance - The custom element instance to retrieve the definition for.
103
+ */
104
+ static readonly getForInstance: (object: any) => FASTElementDefinition<Constructable<HTMLElement>> | undefined;
97
105
  }
@@ -1,10 +1,11 @@
1
+ import type { Constructable } from "../interfaces.js";
1
2
  import { Controller } from "./controller.js";
2
- import { PartialFASTElementDefinition } from "./fast-definitions.js";
3
+ import { FASTElementDefinition, 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,13 @@ 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 Function>(type: TType, nameOrDef?: string | PartialFASTElementDefinition | undefined): TType;
69
+ define<TType extends Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType;
70
+ /**
71
+ * Defines metadata for a FASTElement which can be used to later define the element.
72
+ * IMPORTANT: This API will be renamed to "compose" in a future beta.
73
+ * @public
74
+ */
75
+ metadata<TType_1 extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType_1, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType_1>;
69
76
  };
70
77
  /**
71
78
  * Decorator: Defines a platform custom element based on `FASTElement`.
@@ -73,4 +80,4 @@ export declare const FASTElement: (new () => HTMLElement & FASTElement) & {
73
80
  * that describes the element to define.
74
81
  * @public
75
82
  */
76
- export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Function) => void;
83
+ export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Constructable<HTMLElement>) => void;
@@ -0,0 +1,157 @@
1
+ import type { Constructable } from "./interfaces.js";
2
+ /**
3
+ * A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes.
4
+ * @public
5
+ */
6
+ export declare type Context<T> = {
7
+ readonly name: string;
8
+ readonly initialValue?: T;
9
+ };
10
+ /**
11
+ * A constant key that can be used to represent a Context dependency.
12
+ * The key can be used for context or DI but also doubles as a decorator for
13
+ * resolving the associated dependency.
14
+ * @beta
15
+ */
16
+ export declare type ContextDecorator<T = any> = Readonly<Context<T>> & PropertyDecorator & ParameterDecorator;
17
+ /**
18
+ * A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes.
19
+ * The FASTContext can also be used as a decorator to declare context dependencies or as a key for DI.
20
+ * @beta
21
+ */
22
+ export declare type FASTContext<T> = ContextDecorator<T> & {
23
+ get(target: EventTarget): T;
24
+ provide(target: EventTarget, value: T): void;
25
+ request(target: EventTarget, callback: ContextCallback<T>, multiple?: boolean): void;
26
+ handle(target: EventTarget, callback: (event: ContextEvent<FASTContext<T>>) => void): any;
27
+ };
28
+ /**
29
+ * A strategy that controls how all Context.request API calls are handled.
30
+ * @remarks
31
+ * By default this is handled via Context.dispatch, which dispatched a ContextEvent.
32
+ * @beta
33
+ */
34
+ export declare type FASTContextRequestStrategy = <T extends UnknownContext>(target: EventTarget, context: T, callback: ContextCallback<ContextType<T>>, multiple: any) => void;
35
+ declare const contextEventType = "context-request";
36
+ /**
37
+ * Enables using the {@link https://github.com/webcomponents-cg/community-protocols/blob/main/proposals/context.md | W3C Community Context protocol.}
38
+ * @beta
39
+ */
40
+ export declare const Context: Readonly<{
41
+ /**
42
+ * The event type used for W3C Context Protocol requests.
43
+ */
44
+ eventType: "context-request";
45
+ /**
46
+ * Creates a W3C Community Protocol-based Context object to use in requesting/providing
47
+ * context through the DOM.
48
+ * @param name - The name to use for the connext. Useful in debugging.
49
+ * @param initialValue - An optional initial value to use if a context handler isn't found.
50
+ */
51
+ create<T = unknown>(name: string, initialValue?: T | undefined): FASTContext<T>;
52
+ /**
53
+ * Sets the strategy used by all FAST-specific context requests made through the
54
+ * Context.request, Context.get, Context.defineProperty, and ContextDecorator APIs.
55
+ * @param strategy - The strategy to use. By default, the strategy is Context.dispatch.
56
+ */
57
+ setDefaultRequestStrategy(strategy: FASTContextRequestStrategy): void;
58
+ /**
59
+ * Gets the context value for the target node or returns the initial value if
60
+ * a context handler is not found.
61
+ * @param target - The target to get the context for.
62
+ * @param context - The context to locate.
63
+ * @returns The context value.
64
+ * @remarks
65
+ * Uses the default request strategy to locate the context. If no context is found
66
+ * then the initial value of the context is returned.
67
+ */
68
+ get<T_1 extends UnknownContext>(target: EventTarget, context: T_1): ContextType<T_1>;
69
+ /**
70
+ * Requests the context value for the target node.
71
+ * @param target - The target to request the context for.
72
+ * @param context - The context to locate.
73
+ * @param callback - A callback to invoke with the context value.
74
+ * @param multiple - Whether the context requestor expects to handle updates
75
+ * to the context value after the initial request.
76
+ * @remarks
77
+ * Uses the default request strategy to locate the context.
78
+ */
79
+ request<T_2 extends UnknownContext>(target: EventTarget, context: T_2, callback: ContextCallback<ContextType<T_2>>, multiple?: boolean): void;
80
+ /**
81
+ *
82
+ * @param target - The target to dispatch the context event on.
83
+ * @param context - The context to locate.
84
+ * @param callback - The callback to invoke with the context value.
85
+ * @param multiple - Whether the context requestor expects to handle updates
86
+ * to the context value after the initial request.
87
+ * @remarks
88
+ * This API does NOT use the default request strategy. It always dispatches
89
+ * an event through the DOM.
90
+ */
91
+ dispatch<T_3 extends UnknownContext>(target: EventTarget, context: T_3, callback: ContextCallback<ContextType<T_3>>, multiple?: boolean): void;
92
+ provide<T_4 extends UnknownContext>(target: EventTarget, context: T_4, value: ContextType<T_4>): void;
93
+ /**
94
+ *
95
+ * @param target - The target on which to handle context requests.
96
+ * @param callback - The callback to invoke when a context request is received.
97
+ * @param context - The context to handle requests for.
98
+ * @remarks
99
+ * If a context is not provided then the callback will be invoked for all context
100
+ * requests that are received on the target.
101
+ */
102
+ handle<T_5 extends UnknownContext>(target: EventTarget, callback: (event: ContextEvent<T_5>) => void, context?: T_5 | undefined): void;
103
+ /**
104
+ * Defines a getter-only property on the target that will return the context
105
+ * value for the target.
106
+ * @param target The target to define the property on.
107
+ * @param propertyName The name of the property to define.
108
+ * @param context The context that will be used to retrieve the property value.
109
+ * @remarks
110
+ * Uses the default request strategy to locate the context and will return the
111
+ * initialValue if the context isn't handled.
112
+ */
113
+ defineProperty<T_6 extends UnknownContext>(target: Constructable<EventTarget> | EventTarget, propertyName: string, context: T_6): void;
114
+ }>;
115
+ /**
116
+ * An unknown context type.
117
+ * @public
118
+ */
119
+ export declare type UnknownContext = Context<unknown>;
120
+ /**
121
+ * A helper type which can extract a Context value type from a Context type
122
+ * @public
123
+ */
124
+ export declare type ContextType<T extends UnknownContext> = T extends Context<infer Y> ? Y : never;
125
+ /**
126
+ * A callback which is provided by a context requester and is called with the value satisfying the request.
127
+ * This callback can be called multiple times by context providers as the requested value is changed.
128
+ * @public
129
+ */
130
+ export declare type ContextCallback<ValueType> = (value: ValueType, dispose?: () => void) => void;
131
+ /**
132
+ * An event fired by a context requester to signal it desires a named context.
133
+ *
134
+ * A provider should inspect the `context` property of the event to determine if it has a value that can
135
+ * satisfy the request, calling the `callback` with the requested value if so.
136
+ *
137
+ * If the requested context event contains a truthy `multiple` value, then a provider can call the callback
138
+ * multiple times if the value is changed, if this is the case the provider should pass a `dispose`
139
+ * method to the callback which requesters can invoke to indicate they no longer wish to receive these updates.
140
+ * @public
141
+ */
142
+ export declare class ContextEvent<T extends UnknownContext> extends Event {
143
+ readonly context: T;
144
+ readonly callback: ContextCallback<ContextType<T>>;
145
+ readonly multiple?: boolean | undefined;
146
+ constructor(context: T, callback: ContextCallback<ContextType<T>>, multiple?: boolean | undefined);
147
+ }
148
+ declare global {
149
+ interface HTMLElementEventMap {
150
+ /**
151
+ * A 'context-request' event can be emitted by any element which desires
152
+ * a context value to be injected by an external provider.
153
+ */
154
+ [contextEventType]: ContextEvent<UnknownContext>;
155
+ }
156
+ }
157
+ export {};
@@ -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;
@@ -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 { Splice } from "./observation/array-change-records.js";
16
- export { enableArrayObservation } from "./observation/array-observer.js";
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 { elements, ElementsFilter, NodeBehaviorOptions, } from "./templating/node-observation.js";
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";
@@ -0,0 +1,2 @@
1
+ import "./debug.js";
2
+ export * from "./index.js";
@@ -0,0 +1,2 @@
1
+ import "./polyfills.js";
2
+ export * from "./index.js";
@@ -0,0 +1,3 @@
1
+ import "./polyfills.js";
2
+ import "./debug.js";
3
+ export * from "./index.js";
@@ -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,138 @@ 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
+ twoWayBindingRequiresObservables = 1203,
158
+ missingElementDefinition = 1401
159
+ }
160
+ /**
161
+ * @internal
162
+ */
163
+ export declare const isFunction: (object: any) => object is Function;
164
+ /**
165
+ * @internal
166
+ */
167
+ export declare const isString: (object: any) => object is string;
@@ -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
+ }>;