import * as apprt_core_load_css from 'apprt-core/load-css'; /** * The methods of this interface are available when a Promise * has been augmented using the `trackState` function. */ interface StateQueryable { /** Returns true if the promise is settled, i.e. if it is no longer pending. */ isSettled(): boolean; /** Returns true if the promise is fulfilled, i.e. if it has a success value. */ isFulfilled(): boolean; /** Returns true if the promise is rejected, i.e. if it contains an error. */ isRejected(): boolean; /** Returns true if the promise was cancelled before it was able to complete. */ isCancelled(): boolean; } type State = "pending" | "fulfilled" | "rejected" | "cancelled"; declare const PROMISE: unique symbol; declare const STATE: unique symbol; declare const PRIVATE_CONSTRUCTOR_TAG: unique symbol; /** * Wrapper of global.Promise class. * Read more about [Promises](./PROMISES.md). * * @see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Promise */ declare class ExtendedPromise implements Promise { private [PROMISE]; private [STATE]?; /** * Creates Promise instances. * @param executor defined as (resolve,reject)=> \{\} * @example * ```ts * new Promise((resolve, reject)=>{ * ... * }); * ``` */ constructor(executor: (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void) => void); /** * Internal constructor. Do not call. */ constructor(promise: PromiseLike | LegacyDojoDeferred, state: State | undefined, tag: typeof PRIVATE_CONSTRUCTOR_TAG); /** Creates a new resolved promise */ static resolve(): ExtendedPromise; /** * Creates a new resolved promise with the given value * @param value result object. * @returns a promise in fulfilled state. */ static resolve(value: T): ExtendedPromise; /** * @param reason The reason the promise was rejected. * @returns a promise in rejected state. */ static reject(reason?: any): ExtendedPromise; /** * Creates promise which fulfills if all other promises are fulfilled. * Or rejects if one of the promises rejects. * * @param iterable Iterable of Promise instances */ static all(iterable: T): ExtendedPromise<{ -readonly [P in keyof T]: Awaited; }>; /** * Creates promise which fulfills if one of the other promises fulfills. * Or rejects if one of the promises rejects. * * @param iterable Iterable of Promise instances */ static race(iterable: Iterable): ExtendedPromise ? U : T>; /** * Creates promise which fulfills if one of the other promises fulfills. * Or rejects if one of the promises rejects. * * @param iterable Iterable of Promise instances */ static race(iterable: Iterable>): ExtendedPromise; /** * Creates a promise that resolves after all of the given promises have either fulfilled or rejected, * with an array of objects that each describes the outcome of each promise. * * @param iterable Iterable of Promise instances */ static allSettled(iterable: Iterable>): ExtendedPromise>[]>; /** * Promise.any() takes an iterable of Promise objects and, as soon as one of the promises in the iterable fulfills, * returns a single promise that resolves with the value from that promise. * If no promises in the iterable fulfill (if all of the given promises are rejected), * then the returned promise is rejected with an AggregateError, * Essentially, this method is the opposite of Promise.all(). * * @param iterable Iterable of Promise instances */ static any(iterable: (T | PromiseLike)[] | Iterable>): ExtendedPromise; /** * Produces an object with a promise along with its resolution and rejection functions. * Allows to resolve/reject the promise manually after creating it. * * @example * ```ts * const { promise, resolve, reject } = Promise.withResolvers(); * ``` * @returns {{ promise, resolve, reject }} */ static withResolvers(): { resolve: (value: T | PromiseLike) => void; reject: (reason?: unknown) => void; promise: ExtendedPromise; }; /** * This method tests if a given object is a promise. * The algorithm will return true for: * * apprt-core/Promise * * global Promise * * dojo/Deferred * * dojo/Deferred.promise * * Note: Because of support for dojo/Deferred any object with a * 'then', 'isResolved' and 'isRejected' method is detected as a promise. * * @param candidate a potential promise. * @returns true if candidate is a promise. */ static isPromise(candidate: any): candidate is PromiseLike; /** * Wraps e.g. dojo/Deferred or native Promise to this Promise class. * @returns a promise */ static wrap(promise: PromiseLike | LegacyDojoDeferred): ExtendedPromise; /** * Augments the given Promise with new state lookup functions. */ static trackState(promise: PromiseLike | LegacyDojoDeferred): ExtendedPromise & StateQueryable; /** * Registers success and/or error handlers. * @param success called when the promise resolves * @param failure called when the promise rejects */ then(success?: ((value: T) => TResult1 | PromiseLike) | undefined | null, failure?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): ExtendedPromise; /** * Registers an error handler. * @param failure called when the promise rejects */ catch(failure?: ((reason: any) => TResult | PromiseLike) | undefined | null): ExtendedPromise; /** * Registers an error handler. Which is not called if the error is a Cancel instance. * @param failure called when the promise rejects */ else(failure?: ((reason: any) => TResult | PromiseLike) | undefined | null): ExtendedPromise; /** * Registers a handler, which is called in success or error state. * But the handler is not able to change the result state! * @param handler function invoked regardless of success or error */ finally(handler?: (() => void) | undefined | null): ExtendedPromise; /** * @returns this instance, augmented with augmented with: * * * isFulfilled() * * isRejected() * * isCancelled() * * isSettled() */ trackState(): ExtendedPromise & StateQueryable; get [Symbol.toStringTag](): string; } interface LegacyDojoDeferred { promise: any; isResolved(): boolean; isRejected(): boolean; isFulfilled(): boolean; isCanceled(): boolean; progress(update: any, strict?: boolean): any; resolve(value?: any, strict?: boolean): any; reject(error?: any, strict?: boolean): any; then(callback?: any, errback?: any, progback?: any): any; cancel(reason?: any, strict?: boolean): any; toString(): string; } /** * The executor argument for new cancelable promises. * * @param resolve callback to resolve the promise with a success value * @param reject callback to reject the promise with an error * @param onCancelled accepts a cleanup function to invoke when the promise is cancelled */ type CancelablePromiseExecutor = (resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void, onCancelled: (cleanup: () => void) => void) => void; /** * Promise class which provides a 'cancel' method. * Read more about [Promises](./PROMISES.md). */ declare class CancelablePromise extends ExtendedPromise { /** * Cancels the execution of this promise. */ readonly cancel: (reason?: string) => ExtendedPromise; /** * Creates Promise instances with "cancel" function. * @param executor function defined as (resolve,reject,onCancelled)=> \{\} * @example * ```ts * const p = new CancelablePromise((resolve, reject, onCancelled) => { * onCancelled(() => { * doSomething(); * }); * }); * * // grab cancel function for later cancellation * const cancel = p.cancel; * * // now cancel * cancel(); * ``` */ constructor(executor: CancelablePromiseExecutor); /** * Creates CancelablePromise around the given promise. * * @param promise base promise. * @returns a cancelable promise */ static cancelable(promise: PromiseLike): CancelablePromise; } declare namespace css { /** * @fileOverview This is file contains some utility functions related to css manipulation. */ /** * Adds removes classes dijitVisible,dijitHidden from a node. */ function switchVisibility(node: any, visibility: any): void; /** * Adds removes the class dijitDisplayNone. */ function switchHidden(node: any, hidden: any): void; /** * Tests if node is hidden (switchHidden was called) */ function isHidden(node: any): any; /** * Adds removes the class ctLoading. */ function switchLoading(node: any, loading: any): void; /** * Adds removes the class ctTransparent. */ function switchTransparency(node: any, transparent: any): void; function toggleClass(node: any, className: any, enabled: any): void; function replaceClass(node: any, classNameOnEnabled: any, classNameOnDisabled: any, enabled: any): void; /** * Checks if a node has all given css classes. */ function hasClasses(node: any, cssClasses: any): any; /** * Checks if the user currently drags something (checks for 'dojoMove' on body) */ function isInDraggingMode(): any; /** * Checks if the given node is part of an drag operation. * Which is the case if css.isInDraggingMode() === true and the node or one of it's parents has the class * "dojoMoveItem". */ function isNodeInDraggingMode(node: any): any; /** * Sets width and height of all nodes given in nodes array to auto. */ function resetSizeOfNodes(nodes: any): void; /** * Sets width and height of node to auto. */ function resetSizeOfNode(node: any): void; /** * Finds the next parent with relative or absolute position settings. * @param obj can be a widget or a domNode. */ function findRelativeOrAbsoluteParentNode(obj: any): any; let _applicationRootClass: string; /** * Finds the parent which is a framework application root. * Please use this method only if, there is no other way to get the application context injected! */ function findApplicationRootNode(source: any): any; /** * Finds the all possible app roots in the page. */ function findApplicationRootNodes(): NodeListOf; /** * Finds a parent with matching css classes. */ function findParentWithClass(source: any, cssClasses: any): any; function findParentLayoutContainer(source: any): any; /** * Simple util to go bottom up from a source node to all parents. * If filterCB matches a parent the iteration stops and returns the parent. */ function findParentNode(source: any, filterCb: any, scope: any): any; function hasParentNode(node: any): any; /** * Adds a css link element to the document header. */ function appendCSSLinkToHead(url: any, doc: any, pos: any): void; /** * Creates a new css link element. */ function createCSSLink(url: any): any; /** * Creates and places a css link at a given position. */ function placeCSSLink(url: any, refNode: any, pos: any): void; function findHeadNode(doc: any): any; function findCSSLinkInHead(url: any, doc: any): any; /** * Removes a css link from the document header. */ function removeCSSLinkFromHead(url: any, doc: any): void; /** * Replaces a css link from the document header. */ function replaceCSSLinkInHead(urlOld: any, urlNew: any, doc: any): void; /** * Appends the csslink to the head and loads it. * Returns a promise which says, when the css is loaded! * * @deprecated use apprt-core/load-css instead */ function loadCSS(urls: any): CancelablePromise; /** * Following is an "hack" to watch if a css file is fully loaded * http://otaqui.com/blog/890/cssp-loading-css-with-javascript-and-getting-an-onload-callback/ * * @deprecated use css.loadCSS */ function waitUntilLoad(rootNode: any, className: any, cb: any, scope: any): void; /** * Calc the margin + border + padding extents of a node. */ function getMarginPadBorderExtents(node: any): { t: any; l: any; w: any; h: any; }; /** * Returns the dpi calculated for this screen. */ function getScreenDPI(): number; } export { css as default };