@lushly-dev/fast-element 3.0.1-preview.0 → 3.0.1-preview.2
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.md +12 -0
- package/dist/command/command.api.json +7857 -0
- package/dist/context/context.api.json +1084 -0
- package/dist/declarative/declarative.api.json +8130 -0
- package/dist/definition-schema/definition-schema.api.json +2689 -0
- package/dist/di/di.api.json +4945 -0
- package/dist/dts/arrays.d.ts +2 -0
- package/dist/dts/binding/binding.d.ts +59 -0
- package/dist/dts/binding/exports.d.ts +9 -0
- package/dist/dts/binding/normalize.d.ts +9 -0
- package/dist/dts/binding/one-time.d.ts +11 -0
- package/dist/dts/binding/one-way.d.ts +20 -0
- package/dist/dts/binding/signal.d.ts +36 -0
- package/dist/dts/binding/two-way.d.ts +44 -0
- package/dist/dts/command/behavior.d.ts +94 -0
- package/dist/dts/command/behaviors/confirm-behavior.d.ts +139 -0
- package/dist/dts/command/behaviors/undo-behavior.d.ts +178 -0
- package/dist/dts/command/command.d.ts +79 -0
- package/dist/dts/command/component-registry.d.ts +50 -0
- package/dist/dts/command/components/confirm-dialog.d.ts +117 -0
- package/dist/dts/command/index.d.ts +21 -0
- package/dist/dts/command/registry.d.ts +201 -0
- package/dist/dts/command/schema-validation.d.ts +45 -0
- package/dist/dts/command/types.d.ts +332 -0
- package/dist/dts/command/validation.d.ts +116 -0
- package/dist/dts/command/weak-ref.d.ts +11 -0
- package/dist/dts/components/attributes.d.ts +153 -0
- package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
- package/dist/dts/components/element-controller.d.ts +349 -0
- package/dist/dts/components/element-hydration.d.ts +2 -0
- package/dist/dts/components/enable-hydration.d.ts +66 -0
- package/dist/dts/components/fast-definitions.d.ts +211 -0
- package/dist/dts/components/fast-element-registry.d.ts +23 -0
- package/dist/dts/components/fast-element.d.ts +91 -0
- package/dist/dts/components/hydration-tracker.d.ts +110 -0
- package/dist/dts/components/hydration.d.ts +52 -0
- package/dist/dts/components/schema.d.ts +205 -0
- package/dist/dts/context.d.ts +171 -0
- package/dist/dts/debug.d.ts +5 -0
- package/dist/dts/declarative/attribute-map.d.ts +58 -0
- package/dist/dts/declarative/debug.d.ts +4 -0
- package/dist/dts/declarative/index.d.ts +14 -0
- package/dist/dts/declarative/interfaces.d.ts +8 -0
- package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
- package/dist/dts/declarative/observer-map.d.ts +89 -0
- package/dist/dts/declarative/runtime.d.ts +5 -0
- package/dist/dts/declarative/syntax.d.ts +21 -0
- package/dist/dts/declarative/template-bridge.d.ts +33 -0
- package/dist/dts/declarative/template-parser.d.ts +98 -0
- package/dist/dts/declarative/template.d.ts +9 -0
- package/dist/dts/declarative/utilities.d.ts +358 -0
- package/dist/dts/definition-schema/api.d.ts +42 -0
- package/dist/dts/definition-schema/cem.d.ts +78 -0
- package/dist/dts/definition-schema/extension.d.ts +18 -0
- package/dist/dts/definition-schema/extract.d.ts +38 -0
- package/dist/dts/definition-schema/index.d.ts +9 -0
- package/dist/dts/definition-schema/storage.d.ts +35 -0
- package/dist/dts/definition-schema/types.d.ts +176 -0
- package/dist/dts/dev-mode.d.ts +13 -0
- package/dist/dts/di/di.d.ts +894 -0
- package/dist/dts/dom-policy.d.ts +101 -0
- package/dist/dts/dom.d.ts +88 -0
- package/dist/dts/hydration/diagnostics.d.ts +93 -0
- package/dist/dts/hydration/exports.d.ts +18 -0
- package/dist/dts/hydration/hydration-debugger.d.ts +35 -0
- package/dist/dts/hydration/messages.d.ts +62 -0
- package/dist/dts/hydration/runtime.d.ts +7 -0
- package/dist/dts/hydration/target-builder.d.ts +107 -0
- package/dist/dts/index.d.ts +51 -0
- package/dist/dts/index.debug.d.ts +1 -0
- package/dist/dts/index.rollup.d.ts +1 -0
- package/dist/dts/index.rollup.debug.d.ts +1 -0
- package/dist/dts/interfaces.d.ts +106 -0
- package/dist/dts/metadata.d.ts +26 -0
- package/dist/dts/observation/arrays.d.ts +248 -0
- package/dist/dts/observation/notifier.d.ts +127 -0
- package/dist/dts/observation/observable.d.ts +276 -0
- package/dist/dts/observation/update-queue.d.ts +40 -0
- package/dist/dts/observation/volatile.d.ts +9 -0
- package/dist/dts/platform.d.ts +87 -0
- package/dist/dts/registry.d.ts +2 -0
- package/dist/dts/render.d.ts +7 -0
- package/dist/dts/schema.d.ts +1 -0
- package/dist/dts/scoped/detection.d.ts +55 -0
- package/dist/dts/scoped/index.d.ts +68 -0
- package/dist/dts/scoped/mixin.d.ts +118 -0
- package/dist/dts/scoped/registry.d.ts +76 -0
- package/dist/dts/scoped/types.d.ts +48 -0
- package/dist/dts/state/exports.d.ts +3 -0
- package/dist/dts/state/reactive.d.ts +8 -0
- package/dist/dts/state/state.d.ts +141 -0
- package/dist/dts/state/visitor.d.ts +6 -0
- package/dist/dts/state/watch.d.ts +10 -0
- package/dist/dts/styles/css-directive.d.ts +50 -0
- package/dist/dts/styles/css.d.ts +34 -0
- package/dist/dts/styles/element-styles.d.ts +61 -0
- package/dist/dts/styles/host.d.ts +65 -0
- package/dist/dts/styles/style-strategy.d.ts +42 -0
- package/dist/dts/templating/children.d.ts +62 -0
- package/dist/dts/templating/compiler.d.ts +54 -0
- package/dist/dts/templating/html-binding-directive.d.ts +155 -0
- package/dist/dts/templating/html-directive.d.ts +218 -0
- package/dist/dts/templating/html.d.ts +1 -0
- package/dist/dts/templating/hydration-view.d.ts +130 -0
- package/dist/dts/templating/markup.d.ts +48 -0
- package/dist/dts/templating/node-observation.d.ts +99 -0
- package/dist/dts/templating/ref.d.ts +23 -0
- package/dist/dts/templating/render.d.ts +318 -0
- package/dist/dts/templating/repeat.d.ts +131 -0
- package/dist/dts/templating/slotted.d.ts +38 -0
- package/dist/dts/templating/template.d.ts +221 -0
- package/dist/dts/templating/view.d.ts +268 -0
- package/dist/dts/templating/when.d.ts +12 -0
- package/dist/dts/testing/exports.d.ts +3 -0
- package/dist/dts/testing/fakes.d.ts +16 -0
- package/dist/dts/testing/fixture.d.ts +84 -0
- package/dist/dts/testing/models.d.ts +20 -0
- package/dist/dts/testing/timeout.d.ts +7 -0
- package/dist/dts/trust/index.d.ts +8 -0
- package/dist/dts/trust/types.d.ts +48 -0
- package/dist/dts/trust/utils.d.ts +26 -0
- package/dist/dts/tsdoc-metadata.json +11 -0
- package/dist/dts/utilities.d.ts +76 -0
- package/dist/esm/arrays.js +1 -0
- package/dist/esm/binding/binding.js +18 -0
- package/dist/esm/binding/exports.js +6 -0
- package/dist/esm/binding/normalize.js +17 -0
- package/dist/esm/binding/one-time.js +21 -0
- package/dist/esm/binding/one-way.js +30 -0
- package/dist/esm/binding/signal.js +99 -0
- package/dist/esm/binding/two-way.js +109 -0
- package/dist/esm/command/behavior.js +155 -0
- package/dist/esm/command/behaviors/confirm-behavior.js +225 -0
- package/dist/esm/command/behaviors/undo-behavior.js +313 -0
- package/dist/esm/command/command.js +104 -0
- package/dist/esm/command/component-registry.js +107 -0
- package/dist/esm/command/components/confirm-dialog.js +370 -0
- package/dist/esm/command/index.js +22 -0
- package/dist/esm/command/registry.js +755 -0
- package/dist/esm/command/schema-validation.js +194 -0
- package/dist/esm/command/types.js +86 -0
- package/dist/esm/command/validation.js +508 -0
- package/dist/esm/command/weak-ref.js +5 -0
- package/dist/esm/components/attributes.js +219 -0
- package/dist/esm/components/definition-schema-transforms.js +23 -0
- package/dist/esm/components/element-controller.js +840 -0
- package/dist/esm/components/element-hydration.js +2 -0
- package/dist/esm/components/enable-hydration.js +123 -0
- package/dist/esm/components/fast-definitions.js +294 -0
- package/dist/esm/components/fast-element-registry.js +67 -0
- package/dist/esm/components/fast-element.js +82 -0
- package/dist/esm/components/hydration-tracker.js +211 -0
- package/dist/esm/components/hydration.js +187 -0
- package/dist/esm/components/schema.js +253 -0
- package/dist/esm/context.js +185 -0
- package/dist/esm/debug.js +71 -0
- package/dist/esm/declarative/attribute-map.js +122 -0
- package/dist/esm/declarative/debug.js +4 -0
- package/dist/esm/declarative/index.js +10 -0
- package/dist/esm/declarative/interfaces.js +9 -0
- package/dist/esm/declarative/observer-map-utilities.js +565 -0
- package/dist/esm/declarative/observer-map.js +216 -0
- package/dist/esm/declarative/runtime.js +14 -0
- package/dist/esm/declarative/syntax.js +36 -0
- package/dist/esm/declarative/template-bridge.js +160 -0
- package/dist/esm/declarative/template-parser.js +306 -0
- package/dist/esm/declarative/template.js +116 -0
- package/dist/esm/declarative/utilities.js +1069 -0
- package/dist/esm/definition-schema/api.js +129 -0
- package/dist/esm/definition-schema/cem.js +89 -0
- package/dist/esm/definition-schema/extension.js +53 -0
- package/dist/esm/definition-schema/extract.js +167 -0
- package/dist/esm/definition-schema/index.js +8 -0
- package/dist/esm/definition-schema/storage.js +58 -0
- package/dist/esm/definition-schema/types.js +8 -0
- package/dist/esm/dev-mode.js +22 -0
- package/dist/esm/di/di.js +1441 -0
- package/dist/esm/dom-policy.js +374 -0
- package/dist/esm/dom.js +101 -0
- package/dist/esm/hydration/diagnostics.js +50 -0
- package/dist/esm/hydration/exports.js +6 -0
- package/dist/esm/hydration/hydration-debugger.js +112 -0
- package/dist/esm/hydration/messages.js +84 -0
- package/dist/esm/hydration/runtime.js +33 -0
- package/dist/esm/hydration/target-builder.js +264 -0
- package/dist/esm/index.debug.js +3 -0
- package/dist/esm/index.js +49 -0
- package/dist/esm/index.rollup.debug.js +6 -0
- package/dist/esm/index.rollup.js +4 -0
- package/dist/esm/interfaces.js +55 -0
- package/dist/esm/metadata.js +57 -0
- package/dist/esm/observation/arrays.js +661 -0
- package/dist/esm/observation/notifier.js +162 -0
- package/dist/esm/observation/observable.js +324 -0
- package/dist/esm/observation/update-queue.js +56 -0
- package/dist/esm/observation/volatile.js +16 -0
- package/dist/esm/platform.js +98 -0
- package/dist/esm/registry.js +2 -0
- package/dist/esm/render.js +1 -0
- package/dist/esm/schema.js +1 -0
- package/dist/esm/scoped/detection.js +102 -0
- package/dist/esm/scoped/index.js +69 -0
- package/dist/esm/scoped/mixin.js +127 -0
- package/dist/esm/scoped/registry.js +125 -0
- package/dist/esm/scoped/types.js +4 -0
- package/dist/esm/state/exports.js +3 -0
- package/dist/esm/state/reactive.js +34 -0
- package/dist/esm/state/state.js +148 -0
- package/dist/esm/state/visitor.js +28 -0
- package/dist/esm/state/watch.js +36 -0
- package/dist/esm/styles/css-directive.js +36 -0
- package/dist/esm/styles/css.js +56 -0
- package/dist/esm/styles/element-styles.js +144 -0
- package/dist/esm/styles/host.js +1 -0
- package/dist/esm/styles/style-strategy.js +1 -0
- package/dist/esm/templating/children.js +67 -0
- package/dist/esm/templating/compiler.js +359 -0
- package/dist/esm/templating/html-binding-directive.js +288 -0
- package/dist/esm/templating/html-directive.js +113 -0
- package/dist/esm/templating/html.js +1 -0
- package/dist/esm/templating/hydration-view.js +228 -0
- package/dist/esm/templating/markup.js +83 -0
- package/dist/esm/templating/node-observation.js +84 -0
- package/dist/esm/templating/ref.js +21 -0
- package/dist/esm/templating/render.js +468 -0
- package/dist/esm/templating/repeat.js +434 -0
- package/dist/esm/templating/slotted.js +49 -0
- package/dist/esm/templating/template.js +206 -0
- package/dist/esm/templating/view.js +298 -0
- package/dist/esm/templating/when.js +22 -0
- package/dist/esm/testing/exports.js +3 -0
- package/dist/esm/testing/fakes.js +107 -0
- package/dist/esm/testing/fixture.js +86 -0
- package/dist/esm/testing/models.js +58 -0
- package/dist/esm/testing/timeout.js +24 -0
- package/dist/esm/trust/index.js +7 -0
- package/dist/esm/trust/types.js +6 -0
- package/dist/esm/trust/utils.js +126 -0
- package/dist/esm/utilities.js +140 -0
- package/dist/fast-element.api.json +26798 -0
- package/dist/fast-element.d.ts +3985 -0
- package/dist/fast-element.debug.js +7604 -0
- package/dist/fast-element.debug.min.js +3 -0
- package/dist/fast-element.js +7603 -0
- package/dist/fast-element.min.js +3 -0
- package/dist/fast-element.untrimmed.d.ts +4103 -0
- package/dist/observation/arrays/arrays.api.json +2621 -0
- package/dist/scoped/scoped.api.json +891 -0
- package/dist/trust/trust.api.json +629 -0
- package/package.json +21 -23
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { DOMAspect } from "../dom.js";
|
|
2
|
+
import type { DOMPolicy } from "../dom-policy.js";
|
|
3
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
4
|
+
import type { Expression, ExpressionObserver } from "../observation/observable.js";
|
|
5
|
+
/**
|
|
6
|
+
* The directive from which a binding originates.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface BindingDirective {
|
|
11
|
+
/**
|
|
12
|
+
* The binding.
|
|
13
|
+
*/
|
|
14
|
+
readonly dataBinding: Binding;
|
|
15
|
+
/**
|
|
16
|
+
* The evaluated target aspect.
|
|
17
|
+
*/
|
|
18
|
+
readonly targetAspect?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The type of aspect to target.
|
|
21
|
+
*/
|
|
22
|
+
readonly aspectType?: DOMAspect;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Captures a binding expression along with related information and capabilities.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
|
|
30
|
+
/**
|
|
31
|
+
* Options associated with the binding.
|
|
32
|
+
*/
|
|
33
|
+
options?: any;
|
|
34
|
+
/**
|
|
35
|
+
* Evaluates the binding.
|
|
36
|
+
*/
|
|
37
|
+
evaluate: Expression<TSource, TReturn, TParent>;
|
|
38
|
+
/**
|
|
39
|
+
* The security policy to associate with this binding.
|
|
40
|
+
*/
|
|
41
|
+
policy?: DOMPolicy;
|
|
42
|
+
/**
|
|
43
|
+
* Indicates whether the binding is volatile.
|
|
44
|
+
*/
|
|
45
|
+
isVolatile: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a binding.
|
|
48
|
+
* @param evaluate - Evaluates the binding.
|
|
49
|
+
* @param policy - The security policy to associate with this binding.
|
|
50
|
+
* @param isVolatile - Indicates whether the binding is volatile.
|
|
51
|
+
*/
|
|
52
|
+
constructor(evaluate: Expression<TSource, TReturn, TParent>, policy?: DOMPolicy, isVolatile?: boolean);
|
|
53
|
+
/**
|
|
54
|
+
* Creates an observer capable of notifying a subscriber when the output of a binding changes.
|
|
55
|
+
* @param subscriber - The subscriber to changes in the binding.
|
|
56
|
+
* @param directive - The Binding directive to create the observer for.
|
|
57
|
+
*/
|
|
58
|
+
abstract createObserver(subscriber: Subscriber, directive: BindingDirective): ExpressionObserver<TSource, TReturn, TParent>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { DOMAspect, DOMPolicy } from "../dom.js";
|
|
2
|
+
export type { Subscriber } from "../observation/notifier.js";
|
|
3
|
+
export type { Expression, ExpressionObserver } from "../observation/observable.js";
|
|
4
|
+
export { Binding, type BindingDirective } from "./binding.js";
|
|
5
|
+
export { normalizeBinding } from "./normalize.js";
|
|
6
|
+
export { oneTime } from "./one-time.js";
|
|
7
|
+
export { listener, oneWay } from "./one-way.js";
|
|
8
|
+
export { Signal, signal } from "./signal.js";
|
|
9
|
+
export { type TwoWayBindingOptions, TwoWaySettings, twoWay, } from "./two-way.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Expression } from "../observation/observable.js";
|
|
2
|
+
import { Binding } from "./binding.js";
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes the input value into a binding.
|
|
5
|
+
* @param value - The value to create the default binding for.
|
|
6
|
+
* @returns A binding configuration for the provided value.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeBinding<TSource = any, TReturn = any, TParent = any>(value: Expression<TSource, TReturn, TParent> | Binding<TSource, TReturn, TParent> | {}): Binding<TSource, TReturn, TParent>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DOMPolicy } from "../dom-policy.js";
|
|
2
|
+
import type { Expression } from "../observation/observable.js";
|
|
3
|
+
import { Binding } from "./binding.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a one time binding
|
|
6
|
+
* @param expression - The binding to refresh when signaled.
|
|
7
|
+
* @param policy - The security policy to associate with th binding.
|
|
8
|
+
* @returns A binding configuration.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function oneTime<T = any>(expression: Expression<T>, policy?: DOMPolicy): Binding<T>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DOMPolicy } from "../dom-policy.js";
|
|
2
|
+
import { type Expression } from "../observation/observable.js";
|
|
3
|
+
import { Binding } from "./binding.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates an standard binding.
|
|
6
|
+
* @param expression - The binding to refresh when changed.
|
|
7
|
+
* @param policy - The security policy to associate with th binding.
|
|
8
|
+
* @param isVolatile - Indicates whether the binding is volatile or not.
|
|
9
|
+
* @returns A binding configuration.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare function oneWay<T = any>(expression: Expression<T>, policy?: DOMPolicy, isVolatile?: boolean): Binding<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates an event listener binding.
|
|
15
|
+
* @param expression - The binding to invoke when the event is raised.
|
|
16
|
+
* @param options - Event listener options.
|
|
17
|
+
* @returns A binding configuration.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare function listener<T = any>(expression: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { DOMPolicy } from "../dom-policy.js";
|
|
2
|
+
import type { Subscriber } from "../observation/notifier.js";
|
|
3
|
+
import type { Expression } from "../observation/observable.js";
|
|
4
|
+
import { Binding } from "./binding.js";
|
|
5
|
+
/**
|
|
6
|
+
* The gateway to signal APIs.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare const Signal: Readonly<{
|
|
10
|
+
/**
|
|
11
|
+
* Subscribes to a signal.
|
|
12
|
+
* @param signal - The signal to subscribe to.
|
|
13
|
+
* @param subscriber - The subscriber.
|
|
14
|
+
*/
|
|
15
|
+
subscribe(signal: string, subscriber: Subscriber): void;
|
|
16
|
+
/**
|
|
17
|
+
* Unsubscribes from the signal.
|
|
18
|
+
* @param signal - The signal to unsubscribe from.
|
|
19
|
+
* @param subscriber - The subscriber.
|
|
20
|
+
*/
|
|
21
|
+
unsubscribe(signal: string, subscriber: Subscriber): void;
|
|
22
|
+
/**
|
|
23
|
+
* Sends the specified signal to subscribers.
|
|
24
|
+
* @param signal - The signal to send.
|
|
25
|
+
*/
|
|
26
|
+
send(signal: string): void;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a signal binding configuration with the supplied options.
|
|
30
|
+
* @param expression - The binding to refresh when signaled.
|
|
31
|
+
* @param options - The signal name or a binding to use to retrieve the signal name.
|
|
32
|
+
* @param policy - The security policy to associate with th binding.
|
|
33
|
+
* @returns A binding configuration.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare function signal<T = any>(expression: Expression<T>, options: string | Expression<T>, policy?: DOMPolicy): Binding<T>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DOMPolicy } from "../dom-policy.js";
|
|
2
|
+
import { type Expression } from "../observation/observable.js";
|
|
3
|
+
import { Binding, type BindingDirective } from "./binding.js";
|
|
4
|
+
/**
|
|
5
|
+
* The twoWay binding options.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export type TwoWayBindingOptions = {
|
|
9
|
+
changeEvent?: string;
|
|
10
|
+
fromView?: (value: any) => any;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The settings required to enable two-way binding.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface TwoWaySettings {
|
|
17
|
+
/**
|
|
18
|
+
* Determines which event to listen to, to detect changes in the view.
|
|
19
|
+
* @param bindingSource - The directive to determine the change event for.
|
|
20
|
+
* @param target - The target element to determine the change event for.
|
|
21
|
+
*/
|
|
22
|
+
determineChangeEvent(bindingSource: BindingDirective, target: HTMLElement): string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Enables configuring two-way binding settings.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare const TwoWaySettings: Readonly<{
|
|
29
|
+
/**
|
|
30
|
+
* Configures two-way binding.
|
|
31
|
+
* @param settings - The settings to use for the two-way binding system.
|
|
32
|
+
*/
|
|
33
|
+
configure(settings: TwoWaySettings): void;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a default binding.
|
|
37
|
+
* @param expression - The binding to refresh when changed.
|
|
38
|
+
* @param optionsOrChangeEvent - The binding options or the name of the change event to use.
|
|
39
|
+
* @param policy - The security policy to associate with the binding.
|
|
40
|
+
* @param isBindingVolatile - Indicates whether the binding is volatile or not.
|
|
41
|
+
* @returns A binding.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function twoWay<T = any>(expression: Expression<T>, optionsOrChangeEvent?: TwoWayBindingOptions | string, policy?: DOMPolicy, isBindingVolatile?: boolean): Binding<T>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommandBehavior - Lifecycle management for `command`-decorated methods.
|
|
3
|
+
* Bridges `command` decorator metadata to the CommandRegistry.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Implements the FAST host-behavior lifecycle structurally.
|
|
7
|
+
* Commands are discovered in addedCallback, registered on connect, and
|
|
8
|
+
* unregistered on disconnect.
|
|
9
|
+
*
|
|
10
|
+
* Uses Observable.track() for reactive canExecute and when getters,
|
|
11
|
+
* allowing UI to reactively update when command availability changes.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Behavior is automatically added when an element has command decorators
|
|
16
|
+
* class MyEditor extends FASTElement {
|
|
17
|
+
* @observable
|
|
18
|
+
* hasChanges = false;
|
|
19
|
+
*
|
|
20
|
+
* // Reactive canExecute getter
|
|
21
|
+
* get saveCanExecute(): boolean {
|
|
22
|
+
* return this.hasChanges;
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @command('editor.save', { label: 'Save' })
|
|
26
|
+
* save(): CommandResult {
|
|
27
|
+
* return success({ saved: true });
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Minimal controller contract required by command behaviors.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export interface CommandHostController {
|
|
37
|
+
readonly source: HTMLElement;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Behavior that manages command lifecycle for FASTElement components.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* - Discovers `command`-decorated methods via getCommandMetadata
|
|
44
|
+
* - Registers commands with CommandRegistry on connect
|
|
45
|
+
* - Unregisters commands on disconnect
|
|
46
|
+
* - Provides reactive canExecute/when getters via Observable.track()
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare class CommandBehavior {
|
|
51
|
+
/**
|
|
52
|
+
* Map of command IDs to their registry entries.
|
|
53
|
+
* Populated in addedCallback, used in connect/disconnect.
|
|
54
|
+
*/
|
|
55
|
+
private commands;
|
|
56
|
+
/**
|
|
57
|
+
* Reference to the host element.
|
|
58
|
+
* Set in addedCallback for use in discoverCommands.
|
|
59
|
+
*/
|
|
60
|
+
private host;
|
|
61
|
+
/**
|
|
62
|
+
* Called when the behavior is first attached to a controller.
|
|
63
|
+
* Discovers all `command`-decorated methods on the host element.
|
|
64
|
+
*
|
|
65
|
+
* @param controller - The host controller managing this behavior
|
|
66
|
+
*/
|
|
67
|
+
addedCallback(controller: CommandHostController): void;
|
|
68
|
+
/**
|
|
69
|
+
* Called when the host element connects to the DOM.
|
|
70
|
+
* Registers all discovered commands with the CommandRegistry.
|
|
71
|
+
*
|
|
72
|
+
* @param controller - The host controller managing this behavior
|
|
73
|
+
*/
|
|
74
|
+
connectedCallback(controller: CommandHostController): void;
|
|
75
|
+
/**
|
|
76
|
+
* Called when the host element disconnects from the DOM.
|
|
77
|
+
* Unregisters all commands from the CommandRegistry.
|
|
78
|
+
*
|
|
79
|
+
* @param controller - The host controller managing this behavior
|
|
80
|
+
*/
|
|
81
|
+
disconnectedCallback(controller: CommandHostController): void;
|
|
82
|
+
/**
|
|
83
|
+
* Discovers all `command`-decorated methods on the host element
|
|
84
|
+
* and creates CommandEntry objects for each.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* For each command:
|
|
88
|
+
* - Binds the method to the host element
|
|
89
|
+
* - Creates reactive canExecute getter checking for `${methodName}CanExecute`
|
|
90
|
+
* - Creates reactive when getter checking for `${methodName}When`
|
|
91
|
+
* - Stores WeakRef to host for garbage collection safety
|
|
92
|
+
*/
|
|
93
|
+
private discoverCommands;
|
|
94
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConfirmBehavior - Intercepts destructive commands and prompts for confirmation.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Uses the CommandRegistry interceptor API to intercept commands marked with
|
|
6
|
+
* `destructive: true`. Exposes pending confirmation state for UI rendering.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { ConfirmBehavior } from '@lushly-dev/fast-element/command.js';
|
|
11
|
+
*
|
|
12
|
+
* class MyApp extends FASTElement {
|
|
13
|
+
* private confirmBehavior = new ConfirmBehavior();
|
|
14
|
+
*
|
|
15
|
+
* connectedCallback() {
|
|
16
|
+
* super.connectedCallback();
|
|
17
|
+
* this.$fastController.addBehavior(this.confirmBehavior);
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* // In template (pendingConfirmation is observable, so the template updates):
|
|
21
|
+
* // <fast-af-confirm-dialog
|
|
22
|
+
* // :open="${x => x.confirmBehavior.pendingConfirmation !== null}"
|
|
23
|
+
* // :prompt="${x => x.confirmBehavior.pendingConfirmation?.prompt}"
|
|
24
|
+
* // @confirm="${x => x.confirmBehavior.executeConfirmed()}"
|
|
25
|
+
* // @cancel="${x => x.confirmBehavior.cancelPending()}">
|
|
26
|
+
* // </fast-af-confirm-dialog>
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
import type { CommandHostController } from "../behavior.js";
|
|
33
|
+
/**
|
|
34
|
+
* Error code for user-cancelled operations.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare const USER_CANCELLED = "USER_CANCELLED";
|
|
38
|
+
/**
|
|
39
|
+
* Pending confirmation state.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export interface PendingConfirmation {
|
|
43
|
+
/** The command ID being confirmed */
|
|
44
|
+
commandId: string;
|
|
45
|
+
/** The command label for display */
|
|
46
|
+
label: string;
|
|
47
|
+
/** The confirmation prompt to show */
|
|
48
|
+
prompt: string;
|
|
49
|
+
/** Internal resolver - do not use directly */
|
|
50
|
+
resolve: (confirmed: boolean) => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Behavior that intercepts destructive commands and prompts for user confirmation.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* - Installs a shared `confirm` interceptor with the CommandRegistry while at
|
|
57
|
+
* least one instance is connected (reference counted: the interceptor is added
|
|
58
|
+
* by the first instance and removed when the last one disconnects)
|
|
59
|
+
* - Intercepts commands where `destructive: true`
|
|
60
|
+
* - When several instances are connected, the most recently connected one handles
|
|
61
|
+
* confirmations; if it disconnects, the previous one takes over
|
|
62
|
+
* - Concurrent confirmations are queued: `pendingConfirmation` is the oldest
|
|
63
|
+
* unsettled one, and each `executeConfirmed()`/`cancelPending()` settles it and
|
|
64
|
+
* exposes the next
|
|
65
|
+
* - `pendingConfirmation` is observable, so templates binding to it update
|
|
66
|
+
* - Cancels any pending confirmation on disconnect
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export declare class ConfirmBehavior {
|
|
71
|
+
/** Pending confirmations, oldest first */
|
|
72
|
+
private queue;
|
|
73
|
+
/** Whether this instance is currently connected */
|
|
74
|
+
private connected;
|
|
75
|
+
/** Name of the interceptor for registration/removal */
|
|
76
|
+
private static readonly INTERCEPTOR_NAME;
|
|
77
|
+
/** Connected instances, oldest first. The last one is the active handler. */
|
|
78
|
+
private static readonly instances;
|
|
79
|
+
/**
|
|
80
|
+
* Called when the host element connects to the DOM.
|
|
81
|
+
* Registers this instance and, for the first one, the shared interceptor.
|
|
82
|
+
*
|
|
83
|
+
* @param controller - The host controller managing this behavior
|
|
84
|
+
*/
|
|
85
|
+
connectedCallback(controller: CommandHostController): void;
|
|
86
|
+
/**
|
|
87
|
+
* Called when the host element disconnects from the DOM.
|
|
88
|
+
* Cancels pending confirmations, and removes the shared interceptor when this
|
|
89
|
+
* was the last connected instance.
|
|
90
|
+
*
|
|
91
|
+
* @param controller - The host controller managing this behavior
|
|
92
|
+
*/
|
|
93
|
+
disconnectedCallback(controller: CommandHostController): void;
|
|
94
|
+
/**
|
|
95
|
+
* Gets the oldest pending confirmation, if any.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* Observable: use this in templates to show a confirmation dialog and to get the
|
|
99
|
+
* prompt text. When several confirmations are queued, the next one becomes
|
|
100
|
+
* current after the present one is settled.
|
|
101
|
+
*
|
|
102
|
+
* @returns The pending confirmation or null
|
|
103
|
+
*/
|
|
104
|
+
get pendingConfirmation(): PendingConfirmation | null;
|
|
105
|
+
/**
|
|
106
|
+
* Gets the number of unsettled confirmations, including the current one.
|
|
107
|
+
* Observable.
|
|
108
|
+
*/
|
|
109
|
+
get pendingCount(): number;
|
|
110
|
+
/**
|
|
111
|
+
* Confirms the current pending operation and allows it to proceed.
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* Call this when the user clicks "Confirm" in your confirmation UI.
|
|
115
|
+
* The intercepted command will then execute normally.
|
|
116
|
+
*/
|
|
117
|
+
executeConfirmed(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Cancels the current pending operation.
|
|
120
|
+
*
|
|
121
|
+
* @remarks
|
|
122
|
+
* Call this when the user clicks "Cancel" in your confirmation UI.
|
|
123
|
+
* The intercepted command will return a USER_CANCELLED error.
|
|
124
|
+
*/
|
|
125
|
+
cancelPending(): void;
|
|
126
|
+
private settleCurrent;
|
|
127
|
+
private settleAll;
|
|
128
|
+
/**
|
|
129
|
+
* Queues a confirmation prompt and waits for user response.
|
|
130
|
+
*
|
|
131
|
+
* @param commandId - The command ID being confirmed
|
|
132
|
+
* @param label - The command label for display
|
|
133
|
+
* @param prompt - The confirmation prompt text
|
|
134
|
+
* @returns Promise that resolves to true if confirmed, false if cancelled
|
|
135
|
+
*
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
private showConfirmation;
|
|
139
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UndoBehavior - Manages an undo stack for undoable commands.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Uses the CommandRegistry PostHook API to observe command execution and
|
|
6
|
+
* capture undo functions. Provides keyboard shortcut support (Ctrl+Z).
|
|
7
|
+
*
|
|
8
|
+
* Commands are undoable if the source element has a matching `${methodName}Undo()`
|
|
9
|
+
* method that returns a function to reverse the operation. `methodName` is the name
|
|
10
|
+
* of the `@command`-decorated method (not the last segment of the command ID).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { UndoBehavior } from '@lushly-dev/fast-element/command.js';
|
|
15
|
+
*
|
|
16
|
+
* class MyApp extends FASTElement {
|
|
17
|
+
* private undoBehavior = new UndoBehavior({ limit: 20 });
|
|
18
|
+
*
|
|
19
|
+
* connectedCallback() {
|
|
20
|
+
* super.connectedCallback();
|
|
21
|
+
* this.$fastController.addBehavior(this.undoBehavior);
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* // Command with undo support
|
|
25
|
+
* @command("editor.delete")
|
|
26
|
+
* delete() { ... }
|
|
27
|
+
*
|
|
28
|
+
* // Undo function - returns the reverse operation
|
|
29
|
+
* deleteUndo() {
|
|
30
|
+
* return () => { ... restore deleted content ... };
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
import type { CommandHostController } from "../behavior.js";
|
|
38
|
+
/**
|
|
39
|
+
* Entry in the undo stack.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export interface UndoEntry {
|
|
43
|
+
/** The command ID that was executed */
|
|
44
|
+
commandId: string;
|
|
45
|
+
/** The command label for display */
|
|
46
|
+
label: string;
|
|
47
|
+
/** Arguments that were passed to the command */
|
|
48
|
+
args: unknown[];
|
|
49
|
+
/** The undo function to reverse the operation */
|
|
50
|
+
undoFn: () => void | Promise<void>;
|
|
51
|
+
/** Timestamp when the command was executed */
|
|
52
|
+
timestamp: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Options for configuring UndoBehavior.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export interface UndoBehaviorOptions {
|
|
59
|
+
/** Maximum number of undo entries to keep (default: 10) */
|
|
60
|
+
limit?: number;
|
|
61
|
+
/** Whether to register Ctrl+Z keyboard shortcut (default: true) */
|
|
62
|
+
enableKeyboardShortcut?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Behavior that manages an undo stack for undoable commands.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* - Installs a shared PostHook with the CommandRegistry while at least one instance
|
|
69
|
+
* is connected (reference counted: added by the first instance, removed when the
|
|
70
|
+
* last one disconnects)
|
|
71
|
+
* - When several instances are connected, the most recently connected one records
|
|
72
|
+
* undo entries and handles the keyboard shortcut
|
|
73
|
+
* - Captures undo functions from `${methodName}Undo()` convention
|
|
74
|
+
* - Maintains a limited stack of undo entries
|
|
75
|
+
* - Provides `undo()` method and Ctrl/Cmd+Z keyboard shortcut; the shortcut is left
|
|
76
|
+
* to the browser when the event target is an editable element
|
|
77
|
+
* - Cleans up on disconnect
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare class UndoBehavior {
|
|
82
|
+
/** Undo stack (most recent at the end) */
|
|
83
|
+
private stack;
|
|
84
|
+
/** Maximum stack size */
|
|
85
|
+
private readonly limit;
|
|
86
|
+
/** Whether keyboard shortcut is enabled */
|
|
87
|
+
private readonly enableKeyboardShortcut;
|
|
88
|
+
/** Bound keyboard handler for cleanup */
|
|
89
|
+
private boundKeydownHandler;
|
|
90
|
+
/** Name of the post-hook for registration/removal */
|
|
91
|
+
private static readonly POST_HOOK_NAME;
|
|
92
|
+
/** Connected instances, oldest first. The last one is the active handler. */
|
|
93
|
+
private static readonly instances;
|
|
94
|
+
/** Whether this instance is currently connected */
|
|
95
|
+
private connected;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a new UndoBehavior instance.
|
|
98
|
+
*
|
|
99
|
+
* @param options - Configuration options
|
|
100
|
+
*/
|
|
101
|
+
constructor(options?: UndoBehaviorOptions);
|
|
102
|
+
/**
|
|
103
|
+
* Called when the host element connects to the DOM.
|
|
104
|
+
* Registers the undo post-hook with CommandRegistry.
|
|
105
|
+
*
|
|
106
|
+
* @param controller - The host controller managing this behavior
|
|
107
|
+
*/
|
|
108
|
+
connectedCallback(controller: CommandHostController): void;
|
|
109
|
+
/**
|
|
110
|
+
* Called when the host element disconnects from the DOM.
|
|
111
|
+
* Removes the post-hook (when this was the last instance) and cleans up state.
|
|
112
|
+
*
|
|
113
|
+
* @param controller - The host controller managing this behavior
|
|
114
|
+
*/
|
|
115
|
+
disconnectedCallback(controller: CommandHostController): void;
|
|
116
|
+
/**
|
|
117
|
+
* Gets the current undo stack.
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* Returns a copy of the stack to prevent external mutation.
|
|
121
|
+
*
|
|
122
|
+
* @returns Array of undo entries (most recent last)
|
|
123
|
+
*/
|
|
124
|
+
getStack(): readonly UndoEntry[];
|
|
125
|
+
/**
|
|
126
|
+
* Gets the number of entries in the undo stack.
|
|
127
|
+
*
|
|
128
|
+
* @returns The stack size
|
|
129
|
+
*/
|
|
130
|
+
get stackSize(): number;
|
|
131
|
+
/**
|
|
132
|
+
* Whether there are any operations to undo.
|
|
133
|
+
*
|
|
134
|
+
* @returns True if the stack is not empty
|
|
135
|
+
*/
|
|
136
|
+
get canUndo(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Gets the most recent undo entry without removing it.
|
|
139
|
+
*
|
|
140
|
+
* @returns The most recent entry, or undefined if stack is empty
|
|
141
|
+
*/
|
|
142
|
+
peek(): UndoEntry | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Undoes the most recent operation.
|
|
145
|
+
*
|
|
146
|
+
* @remarks
|
|
147
|
+
* Pops the most recent entry from the stack and executes its undo function.
|
|
148
|
+
* If the undo function is async, this returns a Promise.
|
|
149
|
+
*
|
|
150
|
+
* @returns Promise that resolves when the undo is complete
|
|
151
|
+
*/
|
|
152
|
+
undo(): Promise<boolean>;
|
|
153
|
+
/**
|
|
154
|
+
* Clears the entire undo stack.
|
|
155
|
+
*/
|
|
156
|
+
clear(): void;
|
|
157
|
+
/**
|
|
158
|
+
* Handles a command execution and potentially adds to the undo stack.
|
|
159
|
+
*
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
162
|
+
private handleCommandExecuted;
|
|
163
|
+
/**
|
|
164
|
+
* Extracts the method name from a command ID.
|
|
165
|
+
*
|
|
166
|
+
* @param commandId - The command ID (e.g., "editor.save")
|
|
167
|
+
* @returns The method name (e.g., "save")
|
|
168
|
+
*
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
private extractMethodName;
|
|
172
|
+
/**
|
|
173
|
+
* Handles keyboard events for Ctrl+Z shortcut.
|
|
174
|
+
*
|
|
175
|
+
* @internal
|
|
176
|
+
*/
|
|
177
|
+
private handleKeydown;
|
|
178
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `command` decorator for FASTElement methods.
|
|
3
|
+
* Binds methods to the Command Registry for AI agent interaction.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Uses FAST's createMetadataLocator with push() pattern for metadata storage.
|
|
7
|
+
* Metadata is discovered at connect-time by CommandBehavior.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { FASTElement } from '@lushly-dev/fast-element';
|
|
12
|
+
* import { command, success } from '@lushly-dev/fast-element/command.js';
|
|
13
|
+
*
|
|
14
|
+
* class MyEditor extends FASTElement {
|
|
15
|
+
* @command('editor.save', { label: 'Save', keybinding: 'Ctrl+S' })
|
|
16
|
+
* save(): CommandResult {
|
|
17
|
+
* // Save logic here
|
|
18
|
+
* return success({ saved: true });
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { CommandId, CommandMetadata, CommandOptions } from "./types.js";
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves all command metadata for a given class.
|
|
26
|
+
*
|
|
27
|
+
* @param target - The class constructor to retrieve metadata for
|
|
28
|
+
* @returns Array of CommandMetadata for all `command` decorators on the class
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const metadata = getCommandMetadata(MyEditor);
|
|
33
|
+
* console.log(metadata); // [{ id: 'editor.save', methodName: 'save', ... }]
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare function getCommandMetadata(target: Function): readonly CommandMetadata[];
|
|
39
|
+
/**
|
|
40
|
+
* Decorator that registers a method as a command.
|
|
41
|
+
* Commands are discoverable by AI agents and command palettes.
|
|
42
|
+
*
|
|
43
|
+
* @param id - Namespace-prefixed command identifier (e.g., "editor.save")
|
|
44
|
+
* @param options - Optional command configuration
|
|
45
|
+
* @returns A method decorator
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* - Command IDs must include a namespace prefix (e.g., "app.action")
|
|
49
|
+
* - Runtime warning is emitted if namespace is missing
|
|
50
|
+
* - Metadata is stored using FAST's push() pattern
|
|
51
|
+
* - Commands are registered with CommandRegistry when element connects
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* class TextEditor extends FASTElement {
|
|
56
|
+
* // Basic command
|
|
57
|
+
* @command('editor.selectAll')
|
|
58
|
+
* selectAll(): CommandResult {
|
|
59
|
+
* return success({ selected: true });
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* // Command with full options
|
|
63
|
+
* @command('editor.save', {
|
|
64
|
+
* label: 'Save Document',
|
|
65
|
+
* icon: 'save',
|
|
66
|
+
* description: 'Save the current document',
|
|
67
|
+
* category: 'File',
|
|
68
|
+
* keybinding: 'Ctrl+S',
|
|
69
|
+
* when: 'editorFocus'
|
|
70
|
+
* })
|
|
71
|
+
* save(): CommandResult {
|
|
72
|
+
* return success({ saved: true });
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare function command(id: CommandId, options?: CommandOptions): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|