): Promise;
export class EmptyError extends Error {
message: string;
}
export function firstValueFrom(observable: Observable): Promise;
export function operatorNext(fn: (subs: Subscriber) => NextFunction, unsubscribe?: () => void): (source: Observable) => Observable;
export function operator(fn: (subs: Subscriber, source: Observable) => Observer & {
next: NextFunction;
unsubscribe?: UnsubscribeFunction;
}): Operator;
/**
* Applies a given project function to each value emitted by the source Observable, and emits the resulting values as an Observable.
*/
export function map(mapFn: (val: T) => T2): (source: Observable) => Observable;
/**
* Applies an accumulator function over the source Observable, and returns the accumulated result when the source completes, given an optional seed value.
*/
export function debounceFunction any>(fn: F, delay?: number): ((...args: Parameters) => void) & {
cancel(): void;
};
export function interval(period: number): Observable;
export function timer(delay: number): Observable;
/**
* Emits a value from the source Observable only after a particular time span has passed without another source emission.
*/
export function debounceTime(time?: number, useTimer?: typeof timer): Operator;
/**
* Projects each source value to an Observable which is merged in the output Observable,
* emitting values only from the most recently projected Observable.
*/
export function switchMap(project: (val: T) => Observable): (source: Observable) => Observable;
/**
* Projects each source value to an Observable which is merged in the output Observable.
*/
export function mergeMap(project: (val: T) => Observable): (source: Observable) => Observable;
/**
* Projects each source value to an Observable which is merged in the output Observable
* only if the previous projected Observable has completed.
*/
/**
* Filter items emitted by the source Observable.
*
* @see distinctUntilChanged
*/
export function filter(fn: (val: T) => boolean): Operator;
/**
* Emits only the first count values emitted by the source Observable.
*/
export function take(howMany: number): (source: Observable) => Observable;
/**
* Emits values while fn result is truthy.
*/
export function takeWhile(fn: (val: T) => boolean): (source: Observable) => Observable;
/**
* Emits only the first value emitted by the source Observable.
* Delivers an EmptyError to the Observer's error callback if the Observable completes before any next notification was sent
*/
export function first(): Operator;
/**
* Perform a side effect for every emission on the source Observable,
* but return an Observable that is identical to the source.
*/
export function tap(fn: (val: T) => void): Operator;
/**
* Catches errors on the observable.
*
* @param selector A function that takes as arguments the error `err`, and `source`, which
* is the source observable. The observable
* returned will be used to continue the observable chain.
*
*/
export function catchError(selector: (err: unknown, source: Observable) => Observable | void): Operator;
/**
* Returns an Observable that emits all items emitted by the source Observable
* that are distinct by comparison from the previous item.
*/
export function distinctUntilChanged(): Operator;
export function select(key: K): (source: Observable) => Observable;
export function share(): Operator;
/**
* Returns an observable that shares a single subscription to the underlying sequence containing only the last notification.
*/
export function publishLast(): Operator;
type MergeResult[]> = R extends (infer U)[] ? Observable> : never;
/**
* Creates an output Observable which concurrently emits all values from every given input Observable.
*/
export function merge[]>(...observables: R): MergeResult;
/**
* Combines multiple Observables to create an Observable whose values are calculated from the values, in order, of each of its input Observables.
*/
export function zip[]>(...observables: T): Observable>;
/**
* Combines multiple Observables to create an Observable whose values are calculated from the
* latest values of each of its input Observables.
*/
export function combineLatest[]>(...observables: T): Observable>;
/**
* Returns an Observable that mirrors the source Observable, but will call a
* specified function when the source terminates on complete or error.
*/
export function finalize(unsubscribe: () => void): Operator;
export function ignoreElements(): Operator;
/**
* Creates an Observable that emits no items to the Observer and immediately emits an error notification.
*/
export function throwError(error: unknown): Observable;
/**
* An observable that completes on subscription.
*/
export const EMPTY: Observable;
/**
* Creates a new Behavior Subject.
*/
export function be(initialValue: T): BehaviorSubject;
/**
* Creates a new Observable
*/
export function observable(subscribe: SubscribeFunction): Observable;
/**
* Creates a new Subject
*/
export function subject(): Subject;
/**
* Creates a new Reference object. A reference is a Behavior Subject that does not require an initial value.
*/
export function ref(): Reference;
export const operators: {
readonly catchError: typeof catchError;
readonly debounceTime: typeof debounceTime;
readonly distinctUntilChanged: typeof distinctUntilChanged;
readonly filter: typeof filter;
readonly finalize: typeof finalize;
readonly first: typeof first;
readonly ignoreElements: typeof ignoreElements;
readonly map: typeof map;
readonly mergeMap: typeof mergeMap;
readonly publishLast: typeof publishLast;
readonly select: typeof select;
readonly share: typeof share;
readonly switchMap: typeof switchMap;
readonly take: typeof take;
readonly takeWhile: typeof takeWhile;
readonly tap: typeof tap;
};
export interface Observable {
catchError(selector: (err: unknown, source: Observable) => Observable | void): Observable;
debounceTime(time?: number, timer?: (delay: number) => Observable): Observable;
distinctUntilChanged(): Observable;
filter(fn: (val: T) => boolean): Observable;
finalize(fn: () => void): Observable;
first(): Observable;
map(mapFn: (val: T) => T2): Observable;
mergeMap(project: (val: T) => Observable): Observable;
publishLast(): Observable;
select(key: K): Observable;
share(): Observable;
switchMap(project: (val: T) => Observable): Observable;
take(howMany: number): Observable;
takeWhile(fn: (val: T) => boolean): Observable;
tap(tapFn: (val: T) => void): Observable;
ignoreElements(): Observable;
}
}
///
declare module "@cxl/ui/tsx.js" {
import { Observable } from "@cxl/ui/rx.js";
global {
namespace dom {
namespace JSX {
type ElementClass = Bindable;
interface ElementAttributesProperty {
jsxAttributes: unknown;
}
interface ElementChildrenAttribute {
children: {};
}
type Element = Node;
type IntrinsicElements = {
[P in keyof HTMLElementTagNameMap]: NativeType;
};
interface IntrinsicClassAttributes {
$?: Binding | Observable;
}
}
}
}
export type Binding = (el: T) => Observable;
export type Child = string | Node | number | ((host: Bindable) => Node) | undefined | Observable;
export type Children = Child | Child[];
export type NativeChild = string | number | Node | undefined;
export type NativeChildren = NativeChild | NativeChild[];
export type NativeType = {
[K in keyof Omit]?: T[K];
} & {
children?: NativeChildren;
};
export type Disallowed = Observable | Function;
export type AttributeType = {
[K in keyof Omit]?: T[K] extends Disallowed ? never : T[K] | Observable;
} & {
children?: Children;
};
export interface Bindable extends Node {
bind(binding: Observable): void;
}
export function expression(host: Bindable, binding: Observable): Text;
export function renderChildren(host: Bindable | Node, children: Children, appendTo?: Node): void;
interface ComponentConstructor {
create(): T;
}
export function dom(elementType: ComponentConstructor, attributes?: AttributeType, ...children: Child[]): T;
export function dom(elementType: (attributes?: T2) => Bindable, attributes?: T2, ...children: Child[]): T;
export function dom(elementType: K, attributes?: NativeType, ...children: Child[]): HTMLElementTagNameMap[K];
export default dom;
}
///
declare module "@cxl/ui/dom.js" {
import { Observable, Subject, Subscriber, Subscription } from "@cxl/ui/rx.js";
global {
interface Node {
$$attributeObserver?: AttributeObserver;
$$childrenObserver?: ChildrenObserver;
}
}
export type ElementContent = string | Node | undefined;
export type TemplateContent = string | Element | HTMLTemplateElement | NodeList;
export function empty(el: Element | DocumentFragment): void;
export function setContent(el: Element, content: ElementContent): void;
export function on(element: Window, event: K, options?: AddEventListenerOptions): Observable;
export function on(element: EventTarget, event: K, options?: AddEventListenerOptions): Observable;
export function on