declare let _$_: { new (): {}; } & typeof globalThis; declare class $ extends _$_ { } declare namespace $ { export type $ = typeof $$; export class $$ extends $ { static $: $; } namespace $$ { type $$ = $; } export {}; } declare namespace $ { /** Generates unique identifier. */ function $mol_guid(length?: number, exists?: (id: string) => boolean): string; } declare namespace $ { function $mol_fail(error: any): never; } declare namespace $ { /** Special status statuses. */ enum $mol_wire_cursor { /** Update required. */ stale = -1, /** Some of (transitive) pub update required. */ doubt = -2, /** Actual state but may be dropped. */ fresh = -3, /** State will never be changed. */ final = -4 } } declare namespace $ { /** * Collects subscribers in compact array. 28B */ class $mol_wire_pub extends Object { constructor(id?: string); [Symbol.toStringTag]: string; data: unknown[]; static get [Symbol.species](): ArrayConstructor; /** * Index of first subscriber. */ protected sub_from: number; /** * All current subscribers. */ get sub_list(): readonly $mol_wire_sub[]; /** * Has any subscribers or not. */ get sub_empty(): boolean; /** * Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe. */ sub_on(sub: $mol_wire_pub, pub_pos: number): number; /** * Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`. */ sub_off(sub_pos: number): void; /** * Called when last sub was unsubscribed. **/ reap(): void; /** * Autowire this publisher with current subscriber. **/ promote(): void; /** * Enforce actualization. Should not throw errors. */ fresh(): void; /** * Allow to put data to caches in the subtree. */ complete(): void; get incompleted(): boolean; /** * Notify subscribers about self changes. */ emit(quant?: $mol_wire_cursor): void; /** * Moves peer from one position to another. Doesn't clear data at old position! */ peer_move(from_pos: number, to_pos: number): void; /** * Updates self position in the peer. */ peer_repos(peer_pos: number, self_pos: number): void; } } declare namespace $ { /** Generic subscriber interface */ interface $mol_wire_sub extends $mol_wire_pub { temp: boolean; pub_list: $mol_wire_pub[]; /** * Begin auto wire to publishers. * Returns previous auto subscriber that must me transfer to the `end`. */ track_on(): $mol_wire_sub | null; /** * Returns next auto wired publisher. It can be easely repormoted. * Or promotes next publisher to auto wire its togeter. * Must be used only between `track_on` and `track_off`. */ track_next(pub?: $mol_wire_pub): $mol_wire_pub | null; pub_off(pub_pos: number): void; /** * Unsubscribes from unpromoted publishers. */ track_cut(sub: $mol_wire_pub | null): void; /** * Ends auto wire to publishers. */ track_off(sub: $mol_wire_pub | null): void; /** * Receive notification about publisher changes. */ absorb(quant: $mol_wire_cursor, pos: number): void; /** * Unsubscribes from all publishers. */ destructor(): void; } } declare namespace $ { let $mol_wire_auto_sub: $mol_wire_sub | null; /** * When fulfilled, all publishers are promoted to this subscriber on access to its. */ function $mol_wire_auto(next?: $mol_wire_sub | null): $mol_wire_sub | null; /** * Affection queue. Used to prevent accidental stack overflow on emit. */ const $mol_wire_affected: ($mol_wire_sub | number)[]; } declare namespace $ { function $mol_fail_hidden(error: any): never; } declare namespace $ { function $mol_dev_format_register(config: { header: (val: any, config: any) => any; hasBody: (val: any, config: any) => false; } | { header: (val: any, config: any) => any; hasBody: (val: any, config: any) => boolean; body: (val: any, config: any) => any; }): void; const $mol_dev_format_head: unique symbol; const $mol_dev_format_body: unique symbol; function $mol_dev_format_native(obj: any): any[]; function $mol_dev_format_auto(obj: any): any[]; function $mol_dev_format_element(element: string, style: object, ...content: any[]): any[]; let $mol_dev_format_span: (style: object, ...content: any[]) => any[]; let $mol_dev_format_div: (style: object, ...content: any[]) => any[]; let $mol_dev_format_ol: (style: object, ...content: any[]) => any[]; let $mol_dev_format_li: (style: object, ...content: any[]) => any[]; let $mol_dev_format_table: (style: object, ...content: any[]) => any[]; let $mol_dev_format_tr: (style: object, ...content: any[]) => any[]; let $mol_dev_format_td: (style: object, ...content: any[]) => any[]; let $mol_dev_format_accent: (...args: any[]) => any[]; let $mol_dev_format_strong: (...args: any[]) => any[]; let $mol_dev_format_string: (...args: any[]) => any[]; let $mol_dev_format_shade: (...args: any[]) => any[]; let $mol_dev_format_indent: (...args: any[]) => any[]; } declare namespace $ { /** * Publisher that can auto collect other publishers. 32B * * P1 P2 P3 P4 S1 S2 S3 * ^ ^ * pubs_from subs_from */ class $mol_wire_pub_sub extends $mol_wire_pub implements $mol_wire_sub { protected pub_from: number; protected cursor: $mol_wire_cursor; get temp(): boolean; get pub_list(): $mol_wire_pub[]; track_on(): $mol_wire_sub | null; promote(): void; track_next(pub?: $mol_wire_pub): $mol_wire_pub | null; track_off(sub: $mol_wire_sub | null): void; pub_off(sub_pos: number): void; destructor(): void; track_cut(): void; complete(): void; complete_pubs(): void; absorb(quant?: $mol_wire_cursor, pos?: number): void; [$mol_dev_format_head](): any[]; /** * Is subscribed to any publisher or not. */ get pub_empty(): boolean; } } declare namespace $ { const $mol_ambient_ref: unique symbol; /** @deprecated use $ instead */ type $mol_ambient_context = $; function $mol_ambient(this: $ | void, overrides: Partial<$>): $; } declare namespace $ { /** * Proxy that delegates all to lazy returned target. * * $mol_delegate( Array.prototype , ()=> fetch_array() ) */ function $mol_delegate(proto: Value, target: () => Value): Value; } declare namespace $ { const $mol_owning_map: WeakMap; function $mol_owning_allow(having: Having): having is Having & { destructor(): void; }; function $mol_owning_get(having: Having, Owner?: { new (): Owner; }): Owner | null; function $mol_owning_check(owner: Owner, having: Having): having is Having & { destructor(): void; }; function $mol_owning_catch(owner: Owner, having: Having): boolean; } declare namespace $ { type $mol_type_writable = { -readonly [P in keyof T]: T[P]; }; } declare namespace $ { function $mol_func_name(this: $, func: Function): string; function $mol_func_name_from(target: Target, source: Function): Target; } declare namespace $ { const $mol_key_handle: unique symbol; const $mol_key_store: WeakMap; } declare namespace $ { class $mol_object2 { static $: $; [Symbol.toStringTag]: string; [$mol_ambient_ref]: $; get $(): $; set $(next: $); static create(this: new (init?: (instance: any) => void) => Instance, init?: (instance: $mol_type_writable) => void): Instance; static [Symbol.toPrimitive](): any; static toString(): any; static toJSON(): any; static [$mol_key_handle](): any; destructor(): void; static destructor(): void; [Symbol.dispose](): void; toString(): string; } } declare namespace $ { class $mol_after_tick extends $mol_object2 { task: () => void; static promise: Promise | null; cancelled: boolean; constructor(task: () => void); destructor(): void; } } declare namespace $ { function $mol_promise_like(val: any): val is Promise; } declare namespace $ { /** * Suspendable task with support both sync/async api. * * A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3 * ^ ^ ^ * args_from pubs_from subs_from **/ abstract class $mol_wire_fiber extends $mol_wire_pub_sub { readonly task: (this: Host, ...args: Args) => Result; readonly host?: Host | undefined; static warm: boolean; static planning: Set<$mol_wire_fiber>; static reaping: Set<$mol_wire_fiber>; static plan_task: $mol_after_tick | null; static plan(): void; static sync(): void; cache: Result | Error | Promise; get args(): Args; result(): Result | undefined; get incompleted(): boolean; field(): string; constructor(id: string, task: (this: Host, ...args: Args) => Result, host?: Host | undefined, args?: Args); plan(): this; reap(): void; toString(): string; toJSON(): string; [$mol_dev_format_head](): any[]; [$mol_dev_format_body](): null; get $(): any; emit(quant?: $mol_wire_cursor): void; fresh(): this | undefined; refresh(): void; abstract put(next: Result | Error | Promise): Result | Error | Promise; /** * Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider). * Should be called inside SuspenseAPI consumer (ie fiber). */ sync(): Awaited; /** * Asynchronous execution. * It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside. */ async_raw(): Promise; async(): Promise & { destructor(): void; }; step(): Promise; destructor(): void; } } declare namespace $ { let $mol_compare_deep_cache: WeakMap>; /** * Deeply compares two values. Returns true if equal. * Define `Symbol.toPrimitive` to customize. */ function $mol_compare_deep(left: Value, right: Value): boolean; } declare namespace $ { /** Logger event data */ type $mol_log3_event = { [key in string]: unknown; } & { /** Time of event creation */ time?: string; /** Place of event creation */ place: unknown; /** Short description of event */ message: string; } & Fields; /** Logger function */ type $mol_log3_logger = (this: $, event: $mol_log3_event) => Res; /** Log begin of some task */ let $mol_log3_come: $mol_log3_logger<{}>; /** Log end of some task */ let $mol_log3_done: $mol_log3_logger<{}>; /** Log error */ let $mol_log3_fail: $mol_log3_logger<{}>; /** Log warning message */ let $mol_log3_warn: $mol_log3_logger<{ hint: string; }>; /** Log some generic event */ let $mol_log3_rise: $mol_log3_logger<{}>; /** Log begin of log group, returns func to close group */ let $mol_log3_area: $mol_log3_logger<{}, () => void>; /** Log begin of collapsed group only when some logged inside, returns func to close group */ function $mol_log3_area_lazy(this: $, event: $mol_log3_event<{}>): () => void; let $mol_log3_stack: (() => void)[]; } declare namespace $ { /** * Extracts keys from `Input` which values extends `Upper` and extendable by `Lower`. * * type MathConstants = $mol_type_keys_extract< Math , number > // "E" | "PI" ... */ type $mol_type_keys_extract = { [Field in keyof Input]: unknown extends Input[Field] ? never : Input[Field] extends never ? never : Input[Field] extends Upper ? [ Lower ] extends [Input[Field]] ? Field : never : never; }[keyof Input]; } declare namespace $ { function $mol_log3_web_make(level: $mol_type_keys_extract, color: string): (this: $, event: $mol_log3_event<{}>) => () => void; } declare namespace $ { /** One-shot fiber */ class $mol_wire_task extends $mol_wire_fiber { static getter(task: (this: Host, ...args: Args) => Result): (host: Host, args: Args) => $mol_wire_task; get temp(): boolean; complete(): void; put(next: Result | Error | Promise): Error | Result | Promise; destructor(): void; } } declare namespace $ { /** Returns string key for any value. */ function $mol_key(value: Value): string; } declare namespace $ { class $mol_after_frame extends $mol_object2 { task: () => void; static _promise: Promise | null; static get promise(): Promise; cancelled: boolean; promise: Promise; constructor(task: () => void); destructor(): void; } } declare namespace $ { /** * Decorates method to fiber to ensure it is executed only once inside other fiber. */ function $mol_wire_method(host: Host, field: PropertyKey, descr?: TypedPropertyDescriptor<(...args: Args) => any>): { value: (this: Host, ...args: Args) => any; enumerable?: boolean; configurable?: boolean; writable?: boolean; get?: (() => (...args: Args) => any) | undefined; set?: ((value: (...args: Args) => any) => void) | undefined; }; } declare namespace $ { /** * Returns `Tuple` without first element. * * $mol_type_tail<[ 1 , 2 , 3 ]> // [ 2, 3 ] */ type $mol_type_tail = ((...tail: Tuple) => any) extends ((head: any, ...tail: infer Tail) => any) ? Tail : never; } declare namespace $ { /** * Returns last element of `Tuple`. * * $mol_type_tail<[ 1 , 2 , 3 ]> // 3 */ type $mol_type_foot = Tuple['length'] extends 0 ? never : Tuple[$mol_type_tail['length']]; } declare namespace $ { function $mol_fail_catch(error: unknown): boolean; } declare namespace $ { function $mol_try(handler: () => Result): Result | Error; } declare namespace $ { function $mol_try_web(handler2: () => Result): Result | Error; } declare namespace $ { function $mol_fail_log(error: unknown): boolean; } declare namespace $ { /** Long-living fiber. */ class $mol_wire_atom extends $mol_wire_fiber { static solo(host: Host, task: (this: Host, ...args: Args) => Result): $mol_wire_atom; static plex(host: Host, task: (this: Host, ...args: Args) => Result, key: Args[0]): $mol_wire_atom; static watching: Set<$mol_wire_atom>; static watcher: $mol_after_frame | null; static watch(): void; watch(): void; /** * Update atom value through another temp fiber. */ resync(args: Args): Error | Result | Promise; once(): Awaited; channel(): ((next?: $mol_type_foot) => Awaited) & { atom: $mol_wire_atom; }; destructor(): void; put(next: Result | Error | Promise): Error | Result | Promise; } } declare namespace $ { /** Run code without state changes */ function $mol_wire_probe(task: () => Value, def?: Value): Value | undefined; } declare namespace $ { /** * Disable reaping of current subscriber */ function $mol_wire_solid(): void; } declare namespace $ { /** * Real-time refresh current atom. * Don't use if possible. May reduce performance. */ function $mol_wire_watch(): void; } declare namespace $ { /** * Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber. * @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2 */ export function $mol_wire_sync(obj: Host): ObjectOrFunctionResultAwaited; type FunctionResultAwaited = Some extends (...args: infer Args) => infer Res ? (...args: Args) => Awaited : Some; type ConstructorResultAwaited = Some extends new (...args: infer Args) => infer Res ? new (...args: Args) => Res : {}; type MethodsResultAwaited = { [K in keyof Host]: FunctionResultAwaited; }; type ObjectOrFunctionResultAwaited = (Some extends (...args: any) => unknown ? FunctionResultAwaited : {}) & (Some extends Object ? MethodsResultAwaited & ConstructorResultAwaited : Some); export {}; } declare namespace $ { /** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */ export function $mol_wire_async(obj: Host): ObjectOrFunctionResultPromisify; type FunctionResultPromisify = Some extends (...args: infer Args) => infer Res ? Res extends PromiseLike ? Some : (...args: Args) => Promise : Some; type MethodsResultPromisify = { [K in keyof Host]: FunctionResultPromisify; }; type ObjectOrFunctionResultPromisify = (Some extends (...args: any) => unknown ? FunctionResultPromisify : {}) & (Some extends Object ? MethodsResultPromisify : Some); export {}; } declare namespace $ { /** Starts subtasks concurrently instead of serial. */ function $mol_wire_race any)[]>(...tasks: Tasks): { [index in keyof Tasks]: ReturnType; }; } declare namespace $ { /** Decorates solo object channel to [mol_wire_atom](../atom/atom.ts). */ export function $mol_wire_solo(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): TypedPropertyDescriptor<(...args: First_optional) => any>; type First_optional = Args extends [] ? [] : [Args[0] | undefined, ...$mol_type_tail]; export {}; } declare namespace $ { /** Reactive memoizing multiplexed property decorator. */ function $mol_wire_plex(host: object, field: string, descr?: TypedPropertyDescriptor<(...args: Args) => any>): { value: (this: typeof host, ...args: Args) => any; enumerable?: boolean; configurable?: boolean; writable?: boolean; get?: (() => (...args: Args) => any) | undefined; set?: ((value: (...args: Args) => any) => void) | undefined; }; } declare namespace $ { /** * Returns closure that returns constant value. * @example * const rnd = $mol_const( Math.random() ) */ function $mol_const(value: Value): { (): Value; '()': Value; }; } declare namespace $ { /** Incompatible with instance fields with initializators */ function $mol_wire_field(host: Host, field: Field, descr?: TypedPropertyDescriptor): any; } declare namespace $ { namespace $$ { } const $mol_object_field: unique symbol; class $mol_object extends $mol_object2 { static make(this: This, config: Partial>): InstanceType; } } declare namespace $ { /** * Reactive memoizing solo property decorator from [mol_wire](../wire/README.md) * @example * '@' $mol_mem * name(next?: string) { * return next ?? 'default' * } * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb */ let $mol_mem: typeof $mol_wire_solo; /** * Reactive memoizing multiplexed property decorator [mol_wire](../wire/README.md) * @example * '@' $mol_mem_key * name(id: number, next?: string) { * return next ?? 'default' * } * @see https://mol.hyoo.ru/#!section=docs/=qxmh6t_sinbmb */ let $mol_mem_key: typeof $mol_wire_plex; } declare namespace $ { class $mol_after_timeout extends $mol_object2 { delay: number; task: () => void; id: any; constructor(delay: number, task: () => void); destructor(): void; } } declare namespace $ { /** State of time moment */ class $mol_state_time extends $mol_object { static task(precision: number, reset?: null): $mol_after_timeout | $mol_after_frame; static now(precision: number): number; } } declare namespace $ { /** Transition atom value */ function $mol_wire_easing(next: any): any; } declare namespace $ { function $mol_wire_patch(obj: object): void; } declare namespace $ { /** * Returns type of function result or class instance. * * // 777 * $mol_type_result< ()=> 777 > * * // 777 * $mol_type_result< new()=> 777 > */ type $mol_type_result = Func extends (...params: any) => infer Result ? Result : Func extends new (...params: any) => infer Result ? Result : never; } declare namespace $ { function $mol_wire_let(host: Host): Host & { [Field in keyof Host]: { atom: $mol_wire_atom any>>, $mol_type_result>; }; }; } declare namespace $ { /** Reactive Set */ class $mol_wire_set extends Set { pub: $mol_wire_pub; has(value: Value): boolean; entries(): SetIterator<[Value, Value]>; keys(): SetIterator; values(): SetIterator; forEach(task: (value: Value, value2: Value, set: Set) => void, self?: any): void; [Symbol.iterator](): SetIterator; get size(): number; add(value: Value): this; delete(value: Value): boolean; clear(): void; item(val: Value, next?: boolean): boolean; } } declare namespace $ { function $mol_wire_proxy_pub(id: string, target: object): $mol_wire_pub; function $mol_wire_proxy(id: string, target: Target): Target; } declare namespace $ { /** reactive Dictionary */ class $mol_wire_dict extends Map { pub: $mol_wire_pub; has(key: Key): boolean; get(key: Key): Value | undefined; entries(): MapIterator<[Key, Value]>; keys(): MapIterator; values(): MapIterator; forEach(task: (value: Value, key: Key, dict: Map) => void, self?: any): void; [Symbol.iterator](): MapIterator<[Key, Value]>; get size(): number; set(key: Key, value: Value): this; delete(key: Key): boolean; clear(): void; item(key: Key, next?: Value | null): NonNullable | null; } } declare namespace $ { class $mol_promise extends Promise { done: (value: Result | PromiseLike) => void; fail: (reason?: any) => void; constructor(executor?: (done: (value: Result | PromiseLike) => void, fail: (reason?: any) => void) => void); } } declare namespace $ { function $mol_wait_timeout_async(this: $, timeout: number): Promise; function $mol_wait_timeout(this: $, timeout: number): void; } declare namespace $ { /** Watch and logs reactive states. Logger automatically added to test bundle which is adding to `test.html`. */ class $mol_wire_log extends $mol_object2 { static watch(task?: () => any): (() => any) | undefined; static track(fiber: $mol_wire_fiber): any; static active(): void; } } export = $; //# sourceMappingURL=web.d.ts.map