export type JSONPatch = Record & { length?: never; }; export type Paths = [ string, any ][]; export type WatcherArgsValue = string | Element | DocumentFragment | undefined; export type WatcherArgs = Record; export type ErrorFn = (name: string, ctx?: Record) => Error; export type ActionContext = { el: HTMLOrSVG; evt?: Event; error: ErrorFn; cleanups: Map void>; }; export type RequirementType = "allowed" | "must" | "denied" | "exclusive"; export type Requirement = RequirementType | { key: Exclude; value?: Exclude; } | { key?: Exclude; value: Exclude; }; export type Rx = (...args: any[]) => B extends true ? unknown : void; export type ReqField = R extends "must" | { [P in K]: "must"; } ? Return : R extends "denied" | { [P in K]: "denied"; } ? undefined : R extends "allowed" | { [P in K]: "allowed"; } | (K extends keyof R ? never : R) ? Return | undefined : never; export type ReqFields = R extends "exclusive" ? { key: string; value: undefined; rx: undefined; } | { key: undefined; value: string; rx: Rx; } : { key: ReqField; value: ReqField; rx: ReqField>; }; export type AttributeContext = { el: HTMLOrSVG; mods: Modifiers; rawKey: string; evt?: Event; error: ErrorFn; loadedPluginNames: { actions: Readonly>; attributes: Readonly>; }; } & ReqFields; export type AttributePlugin = { name: string; apply: (ctx: AttributeContext) => void | (() => void); requirement?: R; returnsValue?: RxReturn; argNames?: string[]; }; export type WatcherContext = { error: ErrorFn; }; export type WatcherPlugin = { name: string; apply: (ctx: WatcherContext, args: WatcherArgs) => void; }; export type ActionPlugin = { name: string; apply: (ctx: ActionContext, ...args: any[]) => T; }; export type MergePatchArgs = { ifMissing?: boolean; }; export type HTMLOrSVG = HTMLElement | SVGElement | MathMLElement; export type Modifiers = Map>; export type SignalFilterOptions = { include?: RegExp | string; exclude?: RegExp | string; }; export type Signal = { (): T; (value: T): boolean; }; export type Computed = () => T; export type Effect = () => void; export declare const actions: Record any>; export declare const attribute: (plugin: AttributePlugin) => void; export declare const action: (plugin: ActionPlugin) => void; export declare const watcher: (plugin: WatcherPlugin) => void; export interface ReactiveNode { deps_?: Link; depsTail_?: Link; subs_?: Link; subsTail_?: Link; flags_: ReactiveFlags; } export interface Link { version_: number; dep_: ReactiveNode; sub_: ReactiveNode; prevSub_?: Link; nextSub_?: Link; prevDep_?: Link; nextDep_?: Link; } declare enum ReactiveFlags { None = 0, Mutable = 1, Watching = 2, RecursedCheck = 4, Recursed = 8, Dirty = 16, Pending = 32 } export declare const beginBatch: () => void; export declare const endBatch: () => void; export declare const startPeeking: (sub?: ReactiveNode) => void; export declare const stopPeeking: () => void; export declare const signal: (initialValue?: T) => Signal; export declare const computed: (getter: (previousValue?: T) => T) => Computed; export declare const effect: (fn: () => void) => Effect; export declare const getPath: (path: string) => T | undefined; export declare const mergePatch: (patch: JSONPatch, { ifMissing }?: MergePatchArgs) => void; export declare const mergePaths: (paths: Paths, options?: MergePatchArgs) => void; /** * Filters the root store based on an include and exclude RegExp * * @returns The filtered object */ export declare const filtered: ({ include, exclude }?: SignalFilterOptions, obj?: JSONPatch) => Record; export declare const root: Record; export type DefaultValue = T | (() => T); export type Codec = { decode(value: unknown): T; encode(value: T): string; }; export type CodecDocs = { description?: string; label?: string; control?: "auto" | "text" | "textarea" | "number" | "boolean" | "select"; placeholder?: string; }; export type CodecManifest = { type: "string" | "number" | "boolean" | "date" | "json" | "js" | "binary" | "array" | "tuple" | "object" | "oneOf" | "custom"; values?: readonly unknown[]; docs?: CodecDocs; }; export type RuntimeCodec = Codec & { decode(value: unknown): T; encode(value: T): string; default(value: DefaultValue): RuntimeCodec; docs(meta: CodecDocs): RuntimeCodec; readonly manifestMeta?: CodecManifest; }; export type InferCodec = T extends RuntimeCodec ? Value : never; export type StringCodec = RuntimeCodec & { readonly trim: StringCodec; readonly upper: StringCodec; readonly lower: StringCodec; readonly kebab: StringCodec; readonly camel: StringCodec; readonly snake: StringCodec; readonly pascal: StringCodec; readonly title: StringCodec; prefix(value: string): StringCodec; suffix(value: string): StringCodec; maxLength(length: number): StringCodec; default(value: DefaultValue): StringCodec; }; export type NumberCodec = RuntimeCodec & { min(value: number): NumberCodec; max(value: number): NumberCodec; clamp(minValue: number, maxValue: number): NumberCodec; step(stepValue: number, base?: number): NumberCodec; readonly round: NumberCodec; ceil(decimals?: number): NumberCodec; floor(decimals?: number): NumberCodec; fit(inMin: number, inMax: number, outMin: number, outMax: number, clamped?: boolean, rounded?: boolean): NumberCodec; default(value: DefaultValue): NumberCodec; }; export type BoolCodec = RuntimeCodec & { default(value: DefaultValue): BoolCodec; }; export type DateCodec = RuntimeCodec & { default(value: DefaultValue): DateCodec; }; export type JsonCodec = RuntimeCodec & { default(value: DefaultValue): JsonCodec; }; export type JsCodec = RuntimeCodec & { default(value: DefaultValue): JsCodec; }; export type BinCodec = RuntimeCodec & { default(value: DefaultValue): BinCodec; }; export type ArrayCodec = RuntimeCodec & { default(value: DefaultValue): ArrayCodec; }; export type TupleCodec = RuntimeCodec & { default(value: DefaultValue): TupleCodec; }; export type ObjectCodec> = RuntimeCodec & { default(value: DefaultValue): ObjectCodec; }; export type OneOfCodec = RuntimeCodec & { default(value: DefaultValue): OneOfCodec; }; export type CodecRegistry = { string: StringCodec; number: NumberCodec; bool: BoolCodec; date: DateCodec; json: JsonCodec; js: JsCodec; bin: BinCodec; array(codec: RuntimeCodec): ArrayCodec; array[]>(...codecs: T): TupleCodec<{ [K in keyof T]: InferCodec; }>; object>>(shape: T): ObjectCodec<{ [K in keyof T]: InferCodec; }>; oneOf(...values: T): OneOfCodec; oneOf[]>(...codecs: T): OneOfCodec>; }; export type PropDefs = Record>; export type InferProps = { [K in keyof T]: InferCodec; }; export declare const createCodec: (handlers: Codec) => RuntimeCodec; export type TaggedLiteral = (strings: TemplateStringsArray, ...values: unknown[]) => DocumentFragment; export type AnyRecord = { [key: string]: any; }; export type SetupSignal = ((name: string, initialValue: T) => T) & AnyRecord; export type RefCtors = Record Element>; export type InstancesOf = { [K in keyof C]?: InstanceType; }; export type StateRecord = AnyRecord; export type PropOverrideGetter, Name extends keyof Props & string> = (getDefault: () => Props[Name]) => any; export type PropOverrideSetter, Name extends keyof Props & string> = (value: any, setDefault: (value: Props[Name]) => void) => void; export type HostPropDescriptor = Omit; export type RocketHost = HTMLElement & { dispatchRocketAction(name: string, el: Element | null, evt: Event | undefined, cleanups: Map void>, ...args: any[]): any; }; export type RocketHostWithProps> = RocketHost & Props; export type SetupEmit = { (type: string): void; (...types: [ string, ...string[] ]): void; (type: string, detail: Detail, options?: Omit, "detail">): void; }; export type SetupEmitCancellable = { (type: string): boolean; (type: string, detail: Detail, options?: Omit, "detail" | "cancelable">): boolean; }; export type PropObserver> = (() => void) | ((props: Props, changes: Partial) => void); export type SetupContext> = { props: Props; $: Record; $$: SetupSignal; effect(fn: () => void): () => void; apply(root: HTMLOrSVG | ShadowRoot, merge?: boolean): void; adoptStyles(host: HTMLElement, ...styles: string[]): void; cleanup(fn: () => void): void; emit: SetupEmit; emitCancellable: SetupEmitCancellable; actions: Record any>; action(name: string, fn: RocketAction): void; observeProps(fn: PropObserver, ...propNames: Array): () => void; overrideProp(name: Name, getter?: PropOverrideGetter, setter?: PropOverrideSetter): void; defineHostProp(name: string, descriptor: HostPropDescriptor): void; render: SetupRender; host: RocketHostWithProps; }; export type FirstUpdateContext, Refs extends RefCtors = RefCtors> = SetupContext & { refs: InstancesOf; }; export type RenderContext> = { html: TaggedLiteral; svg: TaggedLiteral; props: Props; host: RocketHostWithProps; }; export type RenderContextOverrides> = Partial>; export type RocketPrimitiveRenderValue = string | number | boolean | bigint | Date | null | undefined; export type RocketComposedRenderValue = RocketPrimitiveRenderValue | Node | Iterable; export type RocketRenderValue = DocumentFragment | RocketPrimitiveRenderValue | Iterable; export type RocketRender> = (context: RenderContext, ...args: any[]) => RocketRenderValue; export type SetupRender> = (context: RenderContextOverrides, ...args: any[]) => void; export type RocketAction> = (context: { host: RocketHostWithProps; props: Props; state: StateRecord; el: Element | null; evt: Event | undefined; }, ...args: any[]) => any; export type RocketDefinition = { refs?: Refs; props?: (codecs: CodecRegistry) => Defs; manifest?: RocketManifestMeta; setup?: (context: SetupContext>) => void; onFirstRender?: (context: FirstUpdateContext, Refs>) => void; render?: RocketRender>; mode?: "open" | "closed" | "light"; renderOnPropChange?: boolean | ((context: { host: RocketHostWithProps>; props: InferProps; changes: Partial>; }) => boolean); }; export type RocketManifestMeta = { slots?: RocketManifestSlot[]; events?: RocketManifestEvent[]; }; export type RocketManifestSlot = { name: string; description?: string; }; export type RocketManifestEvent = { name: string; kind?: "event" | "custom-event"; bubbles?: boolean; composed?: boolean; description?: string; }; export type RocketPublishOptions = { endpoint: string; headers?: Record; }; export declare const publishRocketManifests: ({ endpoint, headers, }: RocketPublishOptions) => Promise; export declare function rocket(tag: string, options?: RocketDefinition): CustomElementConstructor | undefined; export {};