/// /// declare namespace dojo { /* general implied types */ type NodeOrString = Node | string; type ElementOrString = Element | string; type NodeFragmentOrString = NodeOrString | DocumentFragment; interface GenericConstructor { new (...args: any[]): T; prototype: T; } interface GenericObject { [id: string]: any; } interface GenericFunction { (...args: any[]): T; } interface Handle { remove(): void; } interface EventListener { (evt: any): void; } interface BuildProfile { resourceTags: { [tag: string]: (filename: string, mid?: string) => boolean; }; } interface Package { location?: string; main?: string; name?: string; } export interface ModuleMap extends ModuleMapItem { [ sourceMid: string ]: ModuleMapReplacement; } export interface ModuleMapItem { [ mid: string ]: /* ModuleMapReplacement | ModuleMap */ any; } export interface ModuleMapReplacement extends ModuleMapItem { [ findMid: string ]: /* replaceMid */ string; } /* dojo/AdapterRegistry */ interface AdapterRegistry { /** * register a check function to determine if the wrap function or * object gets selected */ register(name: string, check: (...args: any[]) => boolean, wrap: Function, directReturn?: boolean, override?: boolean): void; /** * Find an adapter for the given arguments. If no suitable adapter * is found, throws an exception. match() accepts any number of * arguments, all of which are passed to all matching functions * from the registered pairs. */ match(...args: any[]): any; /** * Remove a named adapter from the registry */ unregister(name: string): boolean; } interface AdapterRegistryConstructor { new (returnWrappers?: boolean): AdapterRegistry; prototype: AdapterRegistry; } /* dojo/aspect */ interface AfterAdvice { (result: T, ...args: any[]): T; } interface AroundAdvice { (origFn: GenericFunction): (...args: any[]) => T; } interface BeforeAdvice { (...args: any[]): any[] | void; } interface Aspect { /** * The "before" export of the aspect module is a function that can be used to attach * "before" advice to a method. This function will be executed before the original attach * is executed. This function will be called with the arguments used to call the mattach * This function may optionally return an array as the new arguments to use tattach * the original method (or the previous, next-to-execute before advice, if one exattach * If the before method doesn't return anything (returns undefined) the original argattach * will be presattach * If there are multiple "before" advisors, they are executed in the reverse order they were registered. */ before(target: GenericObject, methodName: string, advice: BeforeAdvice | Function): Handle; /** * The "around" export of the aspect module is a function that can be used to attach * "around" advice to a method. The advisor function is immediately executeattach * the around() is called, is passed a single argument that is a function that attach * called to continue execution of the original method (or the next around advattach * The advisor function should return a function, and this function will be called whattach * the method is called. It will be called with the arguments used to call the mattach * Whatever this function returns will be returned as the result of the method call (unless after advise changes it). */ around(target: GenericObject, methodName: string, advice: AroundAdvice | Function): Handle; /** * The "after" export of the aspect module is a function that can be used to attach * "after" advice to a method. This function will be executed after the original method * is executed. By default the function will be called with a single argument, the return * value of the original method, or the the return value of the last executed advice (if a previous one exists). * The fourth (optional) argument can be set to true to so the function receives the original * arguments (from when the original method was called) rather than the return value. * If there are multiple "after" advisors, they are executed in the order they were registered. */ after(target: GenericObject, methodName: string, advice: AfterAdvice | Function, receiveArguments?: boolean): Handle; } /* dojo/back */ interface BackArgs { back?: GenericFunction; forward?: GenericFunction; changeUrl?: boolean | string; } interface Back { getHash(): string; setHash(h: string): void; /** * private method. Do not call this directly. */ goBack(): void; /** * private method. Do not call this directly. */ goForward(): void; /** * Initializes the undo stack. This must be called from a ` * into a function */ _functionFromScript(node: HTMLScriptElement, attrData: string): Function; /** * Takes array of nodes, and turns them into class instances and * potentially calls a startup method to allow them to connect with * any children. */ instantiate(nodes: Node[], mixin?: Object, options?: ParserOptions): any[]; /** * Takes array of objects representing nodes, and turns them into class instances and * potentially calls a startup method to allow them to connect with * any children. */ _instantiate(nodes: ParserObjects[], mixin?: Object, options?: ParserOptions, returnPromise?: boolean): any[] | promise.Promise; /** * Calls new ctor(params, node), where params is the hash of parameters specified on the node, * excluding data-dojo-type and data-dojo-mixins. Does not call startup(). */ construct( ctor: GenericConstructor, node: Node, mixin?: Object, options?: ParserOptions, scripts?: HTMLScriptElement[], inherited?: { [prop: string]: any; } ): promise.Promise | T; /** * Scan a DOM tree and return an array of objects representing the DOMNodes * that need to be turned into widgets. */ scan(root?: Node, options?: ParserOptions): promise.Promise; /** * Helper for _scanAMD(). Takes a `` node, * calls require() to load the specified modules and (asynchronously) assign them to the specified global * variables, and returns a Promise for when that operation completes. * * In the example above, it is effectively doing a require(["acme/bar", ...], function(a){ bar = a; }). */ _require(script: HTMLScriptElement, options: ParserOptions): promise.Promise; /** * Scans the DOM for any declarative requires and returns their values. */ _scanAmd(root?: Node, options?: ParserOptions): promise.Promise; /** * Scan the DOM for class instances, and instantiate them. */ parse(rootNode?: Node, options?: ParserOptions): InstancesArray; } /* dojo/query */ interface NodeListFilterCallback { (item: T, idx: number, nodeList: this): boolean; } type NodeListFilter = string | NodeListFilterCallback; interface NodeList extends ArrayLike { /** * decorate an array to make it look like a `dojo/NodeList`. */ _wrap(a: U[], parent?: NodeList, NodeListCtor?: NodeListConstructor): NodeList; _NodeListCtor: NodeListConstructor; toString(): string; /** * private function to hold to a parent NodeList. end() to return the parent NodeList. */ _stash(parent: Node): this; /** * Listen for events on the nodes in the NodeList. */ on(eventName: string, listener: EventListener): Handle[]; /** * Ends use of the current `NodeList` by returning the previous NodeList * that generated the current NodeList. */ end(): NodeList; /** * Returns a new NodeList, maintaining this one in place */ slice(begin: number, end?: number): this; /** * Returns a new NodeList, manipulating this NodeList based on * the arguments passed, potentially splicing in new elements * at an offset, optionally deleting elements */ splice(index: number, howmany?: number, ...items: T[]): this; /** * see `dojo/_base/array.indexOf()`. The primary difference is that the acted-on * array is implicitly this NodeList */ indexOf(value: T, fromIndex?: number, findLast?: boolean): number; /** * see `dojo/_base/array.lastIndexOf()`. The primary difference is that the * acted-on array is implicitly this NodeList */ lastIndexOf(value: T, fromIndex?: number): number; /** * see `dojo/_base/array.every()` and the [Array.every * docs](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every). * Takes the same structure of arguments and returns as * dojo/_base/array.every() with the caveat that the passed array is * implicitly this NodeList */ every(callback: (item: T, idx: number, nodeList: this) => boolean | string, thisObj?: Object): boolean; /** * Takes the same structure of arguments and returns as * `dojo/_base/array.some()` with the caveat that the passed array as * implicitly this NodeList. See `dojo/_base/array.some()` and Mozillaas * [Array.soas * documentation](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some). */ some(callback: (item: T, idx: number, nodeList: this) => boolean | string, thisObj?: Object): boolean; /** * Returns a new NodeList comprised of items in this NodeList * as well as items passed in as parameters */ concat(...items: T[]): this; /** * see `dojo/_base/array.map()`. The primary difference is that the acted-on * array is implicitly this NodeList and the return is a * NodeList (a subclass of Array) */ map(func: (item: T, idx: number, nodeList: this) => U, obj?: Object): NodeList; /** * see `dojo/_base/array.forEach()`. The primary difference is that the acted-on * array is implicitly this NodeList. If you want the option to break out * of the forEach loop, use every() or some() instead. */ forEach(callback: (item: T, idx: number, nodeList: this) => void, thisObj?: Object): this; /** * "masks" the built-in javascript filter() method (supported * in Dojo via `dojo/_base/array.filter`) to support passing a simple * string filter in addition to supporting filtering function * objects. */ filter(filter: NodeListFilter, thisObj?: Object): NodeList; /** * Create a new instance of a specified class, using the * specified properties and each node in the NodeList as a * srcNodeRef. */ instantiate(declaredClass: string | GenericConstructor, properties?: Object): this; /** * Returns a new NodeList comprised of items in this NodeList * at the given index or indices. */ at(...indices: number[]): this; } interface NodeListConstructor { new (array: number | Array | NodeListOf): NodeList; new (...args: T[]): NodeList; (array: number | Array | NodeListOf): NodeList; (...args: T[]): NodeList; prototype: NodeList; /** * decorate an array to make it look like a `dojo/NodeList`. */ _wrap(a: U[], parent?: NodeList, NodeListCtor?: NodeListConstructor): NodeList; /** * adapts a single node function to be used in the map-type * actions. The return is a new array of values, as via `dojo/_base/array.map` */ _adaptAsMap(f: (node: T) => U, o?: Object): NodeList; /** * adapts a single node function to be used in the forEach-type * actions. The initial object is returned from the specialized * function. */ _adaptAsForEach(f: (node: T) => void, o?: Object): this; /** * adapts a single node function to be used in the filter-type actions */ _adaptAsFilter(f: (node: T) => boolean, o?: Object): this; /** * adapts a single node function to be used in the map-type * actions, behaves like forEach() or map() depending on arguments */ _adaptWithCondition(f: (node: T) => U | void, g: (...args: any[]) => boolean, o?: Object): NodeList | this; } interface Query { /** * Returns nodes which match the given CSS selector, searching the * entire document by default but optionally taking a node to scope * the search by. Returns an instance of NodeList. */ (query: string, root?: NodeOrString): NodeList; (root: Node): NodeList; NodeList: NodeListConstructor; /** * Test to see if a node matches a selector */ matches(node: Node, selector: string, root?: NodeOrString): boolean; /** * Filters an array of nodes. Note that this does not guarantee to return a NodeList, just an array. */ filter(nodes: NodeList | T[], select: string, root?: NodeOrString): T[] | NodeList; /** * can be used as AMD plugin to conditionally load new query engine */ load(id: string, parentRequire: Function, loaded: Function): void; /* TODO: Align with loader api */ } /* dojo/ready */ interface Ready { /** * Add a function to execute on DOM content loaded and all requested modules have arrived and been evaluated. * In most cases, the `domReady` plug-in should suffice and this method should not be needed. * * When called in a non-browser environment, just checks that all requested modules have arrived and been * evaluated. */ (callback: Function): void; (context: Object, callback: Function | string): void; (priority: number, callback: Function): void; (priority: number, context: Object, callback: Function | string): void; } /* dojo/regexp */ interface RegExpModule { /** * Adds escape sequences for special characters in regular expressions */ escapeString(str: string, except?: string): string; /** * Builds a regular expression that groups subexpressions */ buildGroupRE(arr: any[] | Object, re: (item: any) => string, nonCapture?: boolean): string; /** * adds group match to expression */ group(expression: string, nonCapture?: boolean): string; } /* dojo/request */ /* This is contained in request.d.ts */ /* dojo/require */ interface RequirePlugin { dynamic: number; normalize(id: string): string; load(mid: string, require: any, loaded: (...modules: any[]) => void): void; } /* dojo/robot */ interface Robot extends doh.Robot { _resolveNode(n: NodeOrString | (() => Node)): Node; _scrollIntoView(n: Node): void; _position(n: Node): DomGeometryBoxExtents; _getWindowChain(n: Node): Window[]; /** * Scroll the passed node into view, if it is not. */ scrollIntoView(node: NodeOrString | (() => Node), delay?: number): void; /** * Moves the mouse over the specified node at the specified relative x,y offset. */ mouseMoveAt( node: NodeOrString | (() => Node), delay?: number, duration?: number, offsetX?: number, offsetY?: number ): void; } /* dojo/robotx */ interface RobotX extends Robot { /** * Called every time a new page is loaded into the iframe, to setup variables * Point dojo.global, dojo.publish, etc. to refer to iframe. * Remove for 2.0? */ _updateDocument(): void; /** * Opens the application at the specified URL for testing, redirecting dojo to point to the application * environment instead of the test environment. */ initRobot(url: string): void; /** * Notifies DOH that the doh.robot is about to make a page change in the application it is driving, * returning a doh.Deferred object the user should return in their runTest function as part of a DOH test. */ waitForPageToLoad(submitActions: () => void): any; } /* dojo/router */ /* Module just exports instance of dojo.router.BaseRouter */ /* dojo/sniff */ interface Has { (name: 'air'): boolean; (name: 'wp'): void | number; (name: 'msapp'): void | number; (name: 'khtml'): void | number; (name: 'edge'): void | number; (name: 'opr'): void | number; (name: 'webkit'): void | number; (name: 'chrome'): void | number; (name: 'android'): void | number; (name: 'safari'): void | number; (name: 'mac'): boolean; (name: 'quirks'): boolean; (name: 'iphone'): void | number; (name: 'ipod'): void | number; (name: 'ipad'): void | number; (name: 'ios'): void | number; (name: 'bb'): void | number | boolean; (name: 'trident'): void | number; (name: 'svg'): boolean; (name: 'opera'): void | number; (name: 'mozilla'): void | number; (name: 'ff'): void | number; (name: 'ie'): void | number; (name: 'wii'): boolean | any; } /* Just rexports has after adding features */ /* dojo/Stateful */ interface WatchHandle extends Handle { unwatch(): void; } interface Stateful { /** * Used across all instances a hash to cache attribute names and their getter * and setter names. */ _attrPairNames: { [attr: string]: string }; /** * Helper function for get() and set(). * Caches attribute name values so we don't do the string ops every time. */ _getAttrNames(name: string): string; /** * Automatic setting of params during construction */ postscript(params?: Object): void; /** * Get a property on a Stateful instance. */ get(name: K): T[K]; /** * Set a property on a Stateful instance */ set(name: K, value: T[K]): this; set(name: K, ...values: T[K]): this; set(values: Partial): this; /** * Internal helper for directly changing an attribute value. */ _changeAttrValue(name: string, value: any): this; /** * Watches a property for changes */ watch(callback:(prop: keyof any, oldValue: any, newValue: any) => void): WatchHandle; watch(name: K, callback: (prop: K, oldValue: T[K], newValue: T[K]) => void): WatchHandle; } interface StatefulConstructor extends _base.DeclareConstructor { new (params?: Partial): Stateful; } /* dojo/string */ interface String { /** * Efficiently escape a string for insertion into HTML (innerHTML or attributes), replacing &, <, >, ", ', and / characters. */ escape(str: string): string; /** * Efficiently replicate a string `n` times. */ rep(str: string, num: number): string; /** * Pad a string to guarantee that it is at least `size` length by * filling with the character `ch` at either the start or end of the * string. Pads at the start, by default. */ pad(text: string, size: number, ch?: string, end?: boolean): string; /** * Performs parameterized substitutions on a string. Throws an * exception if any parameter is unmatched. */ substitute(template: string, map: Object | any[], transform?: (value: any, key: string) => any, thisObject?: Object): string; /** * Trims whitespace from both sides of the string */ trim(str: string): string; } /* dojo/text */ /** * A getter and setter for storing the string content associated with the * module and url arguments. */ interface Cache { (module: string | GenericObject, url: string, value?: string | { value: string, sanitize?: boolean }): string; } interface Text { /** * the dojo/text caches it's own resources because of dojo.cache */ dynamic: boolean; normalize(id: string, toAbsMid: Function): string; /* TODO: Align with loader api */ load(id: string, parentRequire: Function, loaded: Function): void; /* TODO: Align with loader api */ } /* dojo/throttle */ interface Throttle { (cb: T, wait: number): T; } /* dojo/topic */ interface Topic { /** * Publishes a message to a topic on the pub/sub hub. All arguments after * the first will be passed to the subscribers, so any number of arguments * can be provided (not just event). */ publish(topic: string | ExtensionEvent, ...event: any[]): boolean; /** * Subscribes to a topic on the pub/sub hub */ subscribe(topic: string | ExtensionEvent, listener: EventListener | Function): Handle; } /* dojo/touch */ interface Touch { press: ExtensionEvent; move: ExtensionEvent; release: ExtensionEvent; cancel: ExtensionEvent; over: ExtensionEvent; out: ExtensionEvent; enter: ExtensionEvent; leave: ExtensionEvent; } /* dojo/uacss */ /* rexports has after adding classes to dom */ /* dojo/when */ interface When { /** * Transparently applies callbacks to values and/or promises. */ (value: T | dojo.promise.Promise): dojo.promise.Promise; (value: T | dojo.promise.Promise, callback?: dojo.promise.PromiseCallback, errback?: dojo.promise.PromiseErrback, progress?: dojo.promise.PromiseProgback): T | dojo.promise.Promise; (value: T | dojo.promise.Promise, callback?: dojo.promise.PromiseCallback, errback?: dojo.promise.PromiseErrback, progress?: dojo.promise.PromiseProgback): U | dojo.promise.Promise; } /* dojo/window */ interface WindowModule { /** * Returns the dimensions and scroll position of the viewable area of a browser window */ getBox(doc?: Document): DomGeometryBox; /** * Get window object associated with document doc. */ get(doc?: Document): Window; /** * Scroll the passed node into view using minimal movement, if it is not already. */ scrollIntoView(node: Element, pos?: DomGeometryXYBox): void; } }