/// /** * Defines the save/load logic for a value. */ export interface IComponentSerializer { /** * Transform a live object into a serializable value * @param data The initial values defined by the user */ serialize(data: any): any; /** * Returns a hydrated object from the given value * @param data A serialized value */ load(data: any): any; } /** * Property descriptor. Defines the type and default value for a property * This will be used to reset a property when the user's creation stop or when added for the first time */ export interface IComponentProperty { type: T; value: T | (() => T); noReset?: boolean; } /** * Defines a serializer for a data type. That data type will then be able to be save and loaded by the editor * @param type The data type targetted by this serializer. e.g. String, Number, Function, MyClass... * @param serializer A serializer able to svae and load that specific deata type */ export declare function registerTypeSerializer(type: any, serializer: IComponentSerializer): void; /** * A default serializer that handle native JSON types */ export declare const defaultSerializer: IComponentSerializer; /** * A null serializer that save nothing, and load nothing. * Can be used when a data type for a property must not be exported */ export declare const noopSerializer: { serialize(): null; load(): null; }; /** * Defines a set of properties working together. These properties will be reset when the user's creation stop. * This set of properties can be invalidated to notify the part or any piece of Editor UI that a render is required. */ export declare class PartComponent { invalidated: boolean; private _onDidInvalidate; private _properties; [K: string]: any; constructor(); /** * Fires when the component is invalidated. Indicates that the data held by properties has changed since it was last applied * @event */ readonly onDidInvalidate: import("@kano/common/index.js").IEvent; protected _setupProperties(): void; /** * Reset all properties to their default values */ reset(): void; /** * Mark this component as invalidated */ invalidate(): void; /** * Mark this component as not invalidated. Use after the component data was rendered */ apply(): void; static readonly properties: {}; /** * Use the defined serializers for known data types to store all properties values into a serializable JSON object */ serialize(): { [K: string]: any; }; /** * Re-hydrate properties from a stored state * @param data A JSON object containing values for each properties */ load(data: any): void; render(ctx: CanvasRenderingContext2D, el: HTMLElement): void; }