diff --git a/build.gradle b/build.gradle --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,12 @@ typescript { configureTsMain { compilerOptions { - types = ["requirejs", "dojo-typings"] + baseUrl = "$projectDir/src" + paths = [ + "dojo/*" : [ "typings/dojo/*" ], + "dijit/*" : [ "typings/dijit/*" ] + ] + types = ["requirejs", "$projectDir/src/typings/dojo/index" /*, "dojo-typings"*/] } } diff --git a/package-lock.json b/package-lock.json --- a/package-lock.json +++ b/package-lock.json @@ -1145,9 +1145,9 @@ "dev": true }, "typescript": { - "version": "3.7.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz", - "integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==", + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", + "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", "dev": true }, "uri-js": { diff --git a/package.json b/package.json --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "devDependencies": { "@types/requirejs": "2.1.31", "dojo": "1.16.0", - "typescript": "~3.7.5", + "typescript": "~3.8.3", "eslint": "6.8.0", "tslint": "6.0.0", "@implab/core-amd": "^1.3.2", diff --git a/src/main/ts/declare.ts b/src/main/ts/declare.ts --- a/src/main/ts/declare.ts +++ b/src/main/ts/declare.ts @@ -1,9 +1,10 @@ import declare = require("dojo/_base/declare"); import { each } from "@implab/core-amd/safe"; import { Constructor } from "@implab/core-amd/interfaces"; -// import { DeclareConstructor } from "dojo/_base/declare"; -type DeclareConstructor = dojo._base.DeclareConstructor; +// declare const declare: any; + +type DeclareConstructor = declare.DeclareConstructor; export interface AbstractConstructor { prototype: T; diff --git a/src/main/ts/tsx/DjxWidgetBase.ts b/src/main/ts/tsx/DjxWidgetBase.ts --- a/src/main/ts/tsx/DjxWidgetBase.ts +++ b/src/main/ts/tsx/DjxWidgetBase.ts @@ -3,8 +3,9 @@ import _WidgetBase = require("dijit/_Wid import _AttachMixin = require("dijit/_AttachMixin"); import { BuildContext, isNode } from "./traits"; import registry = require("dijit/registry"); -// import { Handle } from "dojo/interfaces"; -type Handle = dojo.Handle; +import { Handle } from "dojo/interfaces"; + +// type Handle = dojo.Handle; @djclass export abstract class DjxWidgetBase extends djbase(_WidgetBase, _AttachMixin) { diff --git a/src/main/tsconfig.json b/src/main/tsconfig.json --- a/src/main/tsconfig.json +++ b/src/main/tsconfig.json @@ -1,13 +1,18 @@ { "extends": "../tsconfig", "compilerOptions": { + "baseUrl": "../", "rootDir": "ts", "rootDirs": [ "ts", "typings" ], + "paths" : { + "dojo/*" : [ "typings/dojo/*" ], + "dijit/*" : [ "typings/dijit/*" ] + }, "types": [ - "requirejs", "dojo-typings", "./typings/index" + "requirejs", "./typings/index", "../typings/dojo/index" ] } } \ No newline at end of file diff --git a/src/test/ts/dummy.ts b/src/test/ts/dummy.ts --- a/src/test/ts/dummy.ts +++ b/src/test/ts/dummy.ts @@ -11,7 +11,7 @@ test("simple", (ok, fail, log) => { }, 100); }); -test("simple", async log => { +test("simple", async (log, fail) => { await delay(0); assert.ok(true); // everything is fine diff --git a/src/typings/dijit/_AttachMixin.d.ts b/src/typings/dijit/_AttachMixin.d.ts --- a/src/typings/dijit/_AttachMixin.d.ts +++ b/src/typings/dijit/_AttachMixin.d.ts @@ -1,6 +1,6 @@ -import { DeclareConstructor } from "dojo/_base/declare"; import { Handle } from "dojo/interfaces"; import _WidgetBase = require("./_WidgetBase"); +import declare = require("dojo/_base/declare"); declare module "./_WidgetBase" { interface _WidgetBase { @@ -81,7 +81,7 @@ interface _AttachMixin { destroyRendering(preserveDom?: boolean): void; } -interface _AttachMixinConstructor extends DeclareConstructor<_AttachMixin> { } +interface _AttachMixinConstructor extends declare.DeclareConstructor<_AttachMixin> { } declare const _AttachMixin: _AttachMixinConstructor; export = _AttachMixin; diff --git a/src/typings/dijit/_WidgetBase.d.ts b/src/typings/dijit/_WidgetBase.d.ts --- a/src/typings/dijit/_WidgetBase.d.ts +++ b/src/typings/dijit/_WidgetBase.d.ts @@ -2,7 +2,6 @@ import Stateful = require("dojo/Stateful import Destroyable = require("./Destroyable"); import { ExtensionEvent } from "dojo/on"; import { NodeFragmentOrString, Handle, NodeOrString, WatchHandle } from "dojo/interfaces"; -import { DeclareConstructor } from "dojo/_base/declare"; declare namespace _WidgetBase { interface _WidgetBase extends Stateful, Destroyable { @@ -231,7 +230,7 @@ declare namespace _WidgetBase { } interface _WidgetBaseConstructor extends DeclareConstructor { - new(params: Object, srcNodeRef: NodeOrString): W; + new(params: Object, srcNodeRef?: NodeOrString): W; } } diff --git a/src/typings/dojo/_base/Color.d.ts b/src/typings/dojo/_base/Color.d.ts --- a/src/typings/dojo/_base/Color.d.ts +++ b/src/typings/dojo/_base/Color.d.ts @@ -1,6 +1,6 @@ /* dojo/_base/Color */ -declare namespace dojoColor { +declare namespace Color { type ColorValue = [number, number, number]; type ColorValueAlpha = [number, number, number, number]; @@ -264,6 +264,6 @@ declare namespace dojoColor { } -type dojoColor = dojoColor.Color; -declare const dojoColor: dojoColor.ColorConstructor; -export = dojoColor; +type Color = Color.Color; +declare const Color: Color.ColorConstructor; +export = Color; diff --git a/src/typings/dojo/_base/Deferred.d.ts b/src/typings/dojo/_base/Deferred.d.ts --- a/src/typings/dojo/_base/Deferred.d.ts +++ b/src/typings/dojo/_base/Deferred.d.ts @@ -1,5 +1,6 @@ import DojoPromise = require("../promise/Promise"); import { PromiseCallback, PromiseErrback, PromiseProgback } from "../promise/Promise"; +import declare = require("./declare"); /* dojo/_base/Deferred */ diff --git a/src/typings/dojo/_base/array.d.ts b/src/typings/dojo/_base/array.d.ts --- a/src/typings/dojo/_base/array.d.ts +++ b/src/typings/dojo/_base/array.d.ts @@ -1,55 +1,51 @@ import { GenericConstructor } from "../interfaces"; /* dojo/_base/array */ -interface DojoArray { - /** - * Determines whether or not every item in arr satisfies the condition implemented by callback. - * @param {T[] | string} arr the array to iterate on. If a string, operates on individual characters. - * @param {Function | string} callback a function is invoked with three arguments: item, index, and - * array and returns true if the condition is met. - * @param {object} thisObj may be used to scope the call to callback - */ - every(arr: T[] | string, callback: string | ((item: T, idx: number, arr: T[]) => boolean), thisObj?: Object): boolean; + +/** + * Determines whether or not every item in arr satisfies the condition implemented by callback. + * @param {T[] | string} arr the array to iterate on. If a string, operates on individual characters. + * @param {Function | string} callback a function is invoked with three arguments: item, index, and + * array and returns true if the condition is met. + * @param {object} thisObj may be used to scope the call to callback + */ +export function every(arr: T[] | string, callback: string | ((item: T, idx: number, arr: T[]) => boolean), thisObj?: Object): boolean; - /** - * Determines whether or not any item in arr satisfies the condition implemented by callback. - */ - some(arr: T[] | string, callback: string | ((item: T, idx: number, arr: T[]) => boolean), thisObj?: Object): boolean; +/** + * Determines whether or not any item in arr satisfies the condition implemented by callback. + */ +export function some(arr: T[] | string, callback: string | ((item: T, idx: number, arr: T[]) => boolean), thisObj?: Object): boolean; - /** - * locates the last index of the provided value in the passed array. If the value is not found, -1 - * is returned. - * @param {boolean} findLast Makes indexOf() work like lastIndexOf(). Used internally; not meant - * for external usage. - */ - indexOf(arr: T[], value: T, fromIndex?: number, findLast?: boolean): number; +/** + * locates the last index of the provided value in the passed array. If the value is not found, -1 + * is returned. + * @param {boolean} findLast Makes indexOf() work like lastIndexOf(). Used internally; not meant + * for external usage. + */ +export function indexOf(arr: T[], value: T, fromIndex?: number, findLast?: boolean): number; - /** - * locates the first index of the provided value in the passed array. If the value is not found, - * -1 is returned. - */ - lastIndexOf(arr: T[], value: T, fromIndex?: number): number; +/** + * locates the first index of the provided value in the passed array. If the value is not found, + * -1 is returned. + */ +export function lastIndexOf(arr: T[], value: T, fromIndex?: number): number; - /** - * locates the last index of the provided value in the passed array. If the value is not found, - * -1 is returned. - */ - forEach(arr: T[], callback: string | ((item: T, idx: number, arr: T[]) => void), thisObj?: Object): void; +/** + * locates the last index of the provided value in the passed array. If the value is not found, + * -1 is returned. + */ +export function forEach(arr: T[], callback: string | ((item: T, idx: number, arr: T[]) => void), thisObj?: Object): void; - /** - * for every item in arr, callback is invoked. Return values are ignored. If you want to break - * out of the loop, consider using array.every() or array.some(). - */ - map(arr: T[] | string, callback: string | ((item: T, idx: number, arr: T[]) => U), thisObj?: Object, Ctr?: GenericConstructor): U[]; +/** + * for every item in arr, callback is invoked. Return values are ignored. If you want to break + * out of the loop, consider using array.every() or array.some(). + */ +export function map(arr: T[] | string, callback: string | ((item: T, idx: number, arr: T[]) => U), thisObj?: Object, Ctr?: GenericConstructor): U[]; - /** - * Returns a new Array with those items from arr that match the condition implemented by - * callback. - */ - filter(arr: T[], callback: string | ((item: T, idx: number, arr: T[]) => boolean), thisObj?: Object): T[]; +/** + * Returns a new Array with those items from arr that match the condition implemented by + * callback. + */ +export function filter(arr: T[], callback: string | ((item: T, idx: number, arr: T[]) => boolean), thisObj?: Object): T[]; - clearCache(): void; -} - -declare const dojoArray: DojoArray; -export = dojoArray; +export function clearCache(): void; diff --git a/src/typings/dojo/_base/browser.d.ts b/src/typings/dojo/_base/browser.d.ts --- a/src/typings/dojo/_base/browser.d.ts +++ b/src/typings/dojo/_base/browser.d.ts @@ -10,4 +10,4 @@ import"../query"; import "./xhr"; import "./fx"; -export = dojo; \ No newline at end of file +export = dojo; diff --git a/src/typings/dojo/_base/config.d.ts b/src/typings/dojo/_base/config.d.ts --- a/src/typings/dojo/_base/config.d.ts +++ b/src/typings/dojo/_base/config.d.ts @@ -1,151 +1,154 @@ import { ColorValue, ColorValueAlpha } from "./Color"; import { HasCache } from "../has"; -interface Config { - /** Defaults to `false`. If set to `true`, ensures that Dojo provides - * extended debugging feedback via Firebug. If Firebug is not available - * on your platform, setting `isDebug` to `true` will force Dojo to - * pull in (and display) the version of Firebug Lite which is - * integrated into the Dojo distribution, thereby always providing a - * debugging/logging console when `isDebug` is enabled. Note that - * Firebug's `console.*` methods are ALWAYS defined by Dojo. If - * `isDebug` is false and you are on a platform without Firebug, these - * methods will be defined as no-ops. - */ - isDebug: boolean; + +declare namespace config { + interface Config { + /** Defaults to `false`. If set to `true`, ensures that Dojo provides + * extended debugging feedback via Firebug. If Firebug is not available + * on your platform, setting `isDebug` to `true` will force Dojo to + * pull in (and display) the version of Firebug Lite which is + * integrated into the Dojo distribution, thereby always providing a + * debugging/logging console when `isDebug` is enabled. Note that + * Firebug's `console.*` methods are ALWAYS defined by Dojo. If + * `isDebug` is false and you are on a platform without Firebug, these + * methods will be defined as no-ops. + */ + isDebug: boolean; - /** - * The locale to assume for loading localized resources in this page, - * specified according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt). - * Must be specified entirely in lowercase, e.g. `en-us` and `zh-cn`. - * See the documentation for `dojo.i18n` and `dojo.requireLocalization` - * for details on loading localized resources. If no locale is specified, - * Dojo assumes the locale of the user agent, according to `navigator.userLanguage` - * or `navigator.language` properties. - */ - locale: string; + /** + * The locale to assume for loading localized resources in this page, + * specified according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt). + * Must be specified entirely in lowercase, e.g. `en-us` and `zh-cn`. + * See the documentation for `dojo.i18n` and `dojo.requireLocalization` + * for details on loading localized resources. If no locale is specified, + * Dojo assumes the locale of the user agent, according to `navigator.userLanguage` + * or `navigator.language` properties. + */ + locale: string; - /** - * No default value. Specifies additional locales whose - * resources should also be loaded alongside the default locale when - * calls to `dojo.requireLocalization()` are processed. - */ - extraLocale: string[]; + /** + * No default value. Specifies additional locales whose + * resources should also be loaded alongside the default locale when + * calls to `dojo.requireLocalization()` are processed. + */ + extraLocale: string[]; - /** - * The directory in which `dojo.js` is located. Under normal - * conditions, Dojo auto-detects the correct location from which it - * was loaded. You may need to manually configure `baseUrl` in cases - * where you have renamed `dojo.js` or in which `` tags confuse - * some browsers (e.g. IE 6). The variable `dojo.baseUrl` is assigned - * either the value of `djConfig.baseUrl` if one is provided or the - * auto-detected root if not. Other modules are located relative to - * this path. The path should end in a slash. - */ - baseUrl: string; + /** + * The directory in which `dojo.js` is located. Under normal + * conditions, Dojo auto-detects the correct location from which it + * was loaded. You may need to manually configure `baseUrl` in cases + * where you have renamed `dojo.js` or in which `` tags confuse + * some browsers (e.g. IE 6). The variable `dojo.baseUrl` is assigned + * either the value of `djConfig.baseUrl` if one is provided or the + * auto-detected root if not. Other modules are located relative to + * this path. The path should end in a slash. + */ + baseUrl: string; - /** - * A map of module names to paths relative to `dojo.baseUrl`. The - * key/value pairs correspond directly to the arguments which - * `dojo.registerModulePath` accepts. Specifying - * `djConfig.modulePaths = { "foo": "../../bar" }` is the equivalent - * of calling `dojo.registerModulePath("foo", "../../bar");`. Multiple - * modules may be configured via `djConfig.modulePaths`. - */ - modulePaths: { [mid: string]: string }; + /** + * A map of module names to paths relative to `dojo.baseUrl`. The + * key/value pairs correspond directly to the arguments which + * `dojo.registerModulePath` accepts. Specifying + * `djConfig.modulePaths = { "foo": "../../bar" }` is the equivalent + * of calling `dojo.registerModulePath("foo", "../../bar");`. Multiple + * modules may be configured via `djConfig.modulePaths`. + */ + modulePaths: { [mid: string]: string }; - /** - * Adds a callback via dojo/ready. Useful when Dojo is added after - * the page loads and djConfig.afterOnLoad is true. Supports the same - * arguments as dojo/ready. When using a function reference, use - * `djConfig.addOnLoad = function(){};`. For object with function name use - * `djConfig.addOnLoad = [myObject, "functionName"];` and for object with - * function reference use - * `djConfig.addOnLoad = [myObject, function(){}];` - */ - addOnLoad: () => void | [any, string]; + /** + * Adds a callback via dojo/ready. Useful when Dojo is added after + * the page loads and djConfig.afterOnLoad is true. Supports the same + * arguments as dojo/ready. When using a function reference, use + * `djConfig.addOnLoad = function(){};`. For object with function name use + * `djConfig.addOnLoad = [myObject, "functionName"];` and for object with + * function reference use + * `djConfig.addOnLoad = [myObject, function(){}];` + */ + addOnLoad: () => void | [any, string]; - /** - * Run the parser after the page is loaded - */ - parseOnLoad: boolean; + /** + * Run the parser after the page is loaded + */ + parseOnLoad: boolean; - /** - * An array of module names to be loaded immediately after dojo.js has been included - * in a page. - */ - require: string[]; + /** + * An array of module names to be loaded immediately after dojo.js has been included + * in a page. + */ + require: string[]; - /** - * Default duration, in milliseconds, for wipe and fade animations within dijits. - * Assigned to dijit.defaultDuration. - */ - defaultDuration: number; + /** + * Default duration, in milliseconds, for wipe and fade animations within dijits. + * Assigned to dijit.defaultDuration. + */ + defaultDuration: number; - /** - * Used by some modules to configure an empty iframe. Used by dojo/io/iframe and - * dojo/back, and dijit/popup support in IE where an iframe is needed to make sure native - * controls do not bleed through the popups. Normally this configuration variable - * does not need to be set, except when using cross-domain/CDN Dojo builds. - * Save dojo/resources/blank.html to your domain and set `djConfig.dojoBlankHtmlUrl` - * to the path on your domain your copy of blank.html. - */ - dojoBlankHtmlUrl: string; + /** + * Used by some modules to configure an empty iframe. Used by dojo/io/iframe and + * dojo/back, and dijit/popup support in IE where an iframe is needed to make sure native + * controls do not bleed through the popups. Normally this configuration variable + * does not need to be set, except when using cross-domain/CDN Dojo builds. + * Save dojo/resources/blank.html to your domain and set `djConfig.dojoBlankHtmlUrl` + * to the path on your domain your copy of blank.html. + */ + dojoBlankHtmlUrl: string; - /** - * Set this to true to enable publishing of topics for the different phases of - * IO operations. Publishing is done via dojo/topic.publish(). See dojo/main.__IoPublish for a list - * of topics that are published. - */ - ioPublish: boolean; + /** + * Set this to true to enable publishing of topics for the different phases of + * IO operations. Publishing is done via dojo/topic.publish(). See dojo/main.__IoPublish for a list + * of topics that are published. + */ + ioPublish: boolean; - /** - * If set to a value that evaluates to true such as a string or array and - * isDebug is true and Firebug is not available or running, then it bypasses - * the creation of Firebug Lite allowing you to define your own console object. - */ - useCustomLogger: any; + /** + * If set to a value that evaluates to true such as a string or array and + * isDebug is true and Firebug is not available or running, then it bypasses + * the creation of Firebug Lite allowing you to define your own console object. + */ + useCustomLogger: any; - /** - * Array containing the r, g, b components used as transparent color in dojo.Color; - * if undefined, ColorValue (white) will be used. - */ - transparentColor: ColorValue | ColorValueAlpha; + /** + * Array containing the r, g, b components used as transparent color in dojo.Color; + * if undefined, ColorValue (white) will be used. + */ + transparentColor: ColorValue | ColorValueAlpha; - /** - * Defines dependencies to be used before the loader has been loaded. - * When provided, they cause the loader to execute require(deps, callback) - * once it has finished loading. Should be used with callback. - */ - deps: () => string[] | string[]; + /** + * Defines dependencies to be used before the loader has been loaded. + * When provided, they cause the loader to execute require(deps, callback) + * once it has finished loading. Should be used with callback. + */ + deps: () => string[] | string[]; - /** - * Defines the cached has API variables - */ - hasCache: HasCache; + /** + * Defines the cached has API variables + */ + hasCache: HasCache; - /** - * Defines a callback to be used when dependencies are defined before - * the loader has been loaded. When provided, they cause the loader to - * execute require(deps, callback) once it has finished loading. - */ - callback: (...args: any[]) => void; + /** + * Defines a callback to be used when dependencies are defined before + * the loader has been loaded. When provided, they cause the loader to + * execute require(deps, callback) once it has finished loading. + */ + callback: (...args: any[]) => void; - /** - * Whether deferred instrumentation should be loaded or included - * in builds. - */ - deferredInstrumentation: boolean; + /** + * Whether deferred instrumentation should be loaded or included + * in builds. + */ + deferredInstrumentation: boolean; - /** - * Whether the deferred instrumentation should be used. - * - * * `"report-rejections"`: report each rejection as it occurs. - * * `true` or `1` or `"report-unhandled-rejections"`: wait 1 second - * in an attempt to detect unhandled rejections. - */ - useDeferredInstrumentation: string | boolean | number; + /** + * Whether the deferred instrumentation should be used. + * + * * `"report-rejections"`: report each rejection as it occurs. + * * `true` or `1` or `"report-unhandled-rejections"`: wait 1 second + * in an attempt to detect unhandled rejections. + */ + useDeferredInstrumentation: string | boolean | number; + } + } -type dojoConfig = Config; -declare const dojoConfig: Config; -export = dojoConfig; \ No newline at end of file +declare const config: config.Config; +export = config; diff --git a/src/typings/dojo/_base/connect.d.ts b/src/typings/dojo/_base/connect.d.ts --- a/src/typings/dojo/_base/connect.d.ts +++ b/src/typings/dojo/_base/connect.d.ts @@ -1,49 +1,47 @@ import { Handle } from "../interfaces"; -interface Connect { - /** - * TODO: Type this better - */ - _keypress(object: any, listener: EventListener): Handle; +/** + * TODO: Type this better + */ +export function _keypress(object: any, listener: EventListener): Handle; - /** - * `dojo.connect` is a deprecated event handling and delegation method in - * Dojo. It allows one function to "listen in" on the execution of - * any other, triggering the second whenever the first is called. Many - * listeners may be attached to a function, and source functions may - * be either regular function calls or DOM events. - */ - connect(obj: any, event: string, context: any, method: EventListener | string, dontFix?: boolean): Handle; - connect(event: string, context: any, method: EventListener | string, dontFix?: boolean): Handle; +/** + * `dojo.connect` is a deprecated event handling and delegation method in + * Dojo. It allows one function to "listen in" on the execution of + * any other, triggering the second whenever the first is called. Many + * listeners may be attached to a function, and source functions may + * be either regular function calls or DOM events. + */ +export function connect(obj: any, event: string, context: any, method: EventListener | string, dontFix?: boolean): Handle; +export function connect(event: string, context: any, method: EventListener | string, dontFix?: boolean): Handle; - /** - * Remove a link created by dojo.connect. - */ - disconnect(handle: Handle): void; +/** + * Remove a link created by dojo.connect. + */ +export function disconnect(handle: Handle): void; - /** - * Attach a listener to a named topic. The listener function is invoked whenever the - * named topic is published (see: dojo.publish). - * Returns a handle which is needed to unsubscribe this listener. - */ - subscribe(topic: string, context: any, method: EventListener): Handle; +/** + * Attach a listener to a named topic. The listener function is invoked whenever the + * named topic is published (see: dojo.publish). + * Returns a handle which is needed to unsubscribe this listener. + */ +export function subscribe(topic: string, context: any, method: EventListener): Handle; - /** - * Invoke all listener method subscribed to topic. - */ - publish(topic: string, args: any[]): boolean; +/** + * Invoke all listener method subscribed to topic. + */ +export function publish(topic: string, args: any[]): boolean; - /** - * Ensure that every time obj.event() is called, a message is published - * on the topic. Returns a handle which can be passed to - * dojo.disconnect() to disable subsequent automatic publication on - * the topic. - */ - connectPublisher(topic: string, obj: any, method: string): Handle; - connectPublisher(topic: string, method: EventListener): Handle; +/** + * Ensure that every time obj.event() is called, a message is published + * on the topic. Returns a handle which can be passed to + * dojo.disconnect() to disable subsequent automatic publication on + * the topic. + */ +export function connectPublisher(topic: string, obj: any, method: string): Handle; +export function connectPublisher(topic: string, method: EventListener): Handle; - /** - * Checks an event for the copy key (meta on Mac, and ctrl anywhere else) - */ - isCopyKey(e: Event): boolean; -} \ No newline at end of file +/** + * Checks an event for the copy key (meta on Mac, and ctrl anywhere else) + */ +export function isCopyKey(e: Event): boolean; diff --git a/src/typings/dojo/_base/declare.d.ts b/src/typings/dojo/_base/declare.d.ts --- a/src/typings/dojo/_base/declare.d.ts +++ b/src/typings/dojo/_base/declare.d.ts @@ -1,10 +1,11 @@ -declare namespace declare { - /* dojo/_base/declare */ +declare module "./kernel" { + interface Dojo { + declare: declare.Declare; + safeMixin: typeof declare.safeMixin; + } +} - /** - * dojo/_base/declare() returns a constructor `C`. `new C()` returns an Object with the following - * methods, in addition to the methods and properties specified via the arguments passed to declare(). - */ +declare namespace declare { interface DeclareCreatedObject { declaredClass: string; @@ -99,9 +100,6 @@ declare namespace declare { createSubclass(mixins: any, props: U): DeclareConstructor; } - /** - * Create a feature-rich constructor from compact notation. - */ interface Declare { (superClass: [DeclareConstructor, DeclareConstructor, DeclareConstructor, DeclareConstructor]): DeclareConstructor; (superClass: [DeclareConstructor, DeclareConstructor, DeclareConstructor]): DeclareConstructor; diff --git a/src/typings/dojo/_base/event.d.ts b/src/typings/dojo/_base/event.d.ts --- a/src/typings/dojo/_base/event.d.ts +++ b/src/typings/dojo/_base/event.d.ts @@ -1,22 +1,21 @@ /* dojo/_base/event */ /** + * @module * This module defines dojo DOM event API. Usually you should use dojo/on, and evt.stopPropagation() + * evt.preventDefault(), rather than this module. */ -interface EventModule { - /** - * normalizes properties on the event object including event - * bubbling methods, keystroke normalization, and x/y positions - */ - fix(evt: Event, sender: Element): Event; + - /** - * prevents propagation and clobbers the default action of the - * passed event - */ - stop(evt: Event): void; -} +/** + * normalizes properties on the event object including event + * bubbling methods, keystroke normalization, and x/y positions + */ +export declare function fix(evt: Event, sender: Element): Event; -declare const dojoEvent: EventModule; -export = dojoEvent; +/** + * prevents propagation and clobbers the default action of the + * passed event + */ +export declare function stop(evt: Event): void; + diff --git a/src/typings/dojo/_base/fx.d.ts b/src/typings/dojo/_base/fx.d.ts --- a/src/typings/dojo/_base/fx.d.ts +++ b/src/typings/dojo/_base/fx.d.ts @@ -1,218 +1,215 @@ import Evented = require("../Evented"); -declare namespace fx { - /* dojo/_base/fx */ +/* dojo/_base/fx */ + +export interface _Line { + /** + * Returns the point on the line + * @param {number} n a floating point number greater than 0 and less than 1 + */ + getValue(n: number): number; +} + +/** + * Object used to generate values from a start value to an end value + */ +export interface LineConstructor { + new(start: number, end: number): _Line; + + prototype: _Line; +} + +export interface EasingFunction { + (n?: number): number; +} + +export interface Animation extends Evented { + /** + * The time in milliseconds the animation will take to run + */ + duration: number; + + /** + * A two element array of start and end values, or a `_Line` instance to be + * used in the Animation. + */ + curve: _Line | [number, number]; + + /** + * A Function to adjust the acceleration (or deceleration) of the progress + * across a _Line + */ + easing?: EasingFunction; + + /** + * The number of times to loop the animation + */ + repeat: number; - interface Line { - /** - * Returns the point on the line - * @param {number} n a floating point number greater than 0 and less than 1 - */ - getValue(n: number): number; - } + /** + * the time in milliseconds to wait before advancing to next frame + * (used as a fps timer: 1000/rate = fps) + */ + rate: number; + + /** + * The time in milliseconds to wait before starting animation after it + * has been .play()'ed + */ + delay?: number; + + /** + * Synthetic event fired before a Animation begins playing (synchronous) + */ + beforeBegin?: Event; + + /** + * Synthetic event fired as a Animation begins playing (useful?) + */ + onBegin?: Event; + + /** + * Synthetic event fired at each interval of the Animation + */ + onAnimate?: Event; + + /** + * Synthetic event fired after the final frame of the Animation + */ + onEnd?: Event; + + /** + * Synthetic event fired any time the Animation is play()'ed + */ + onPlay?: Event; + + /** + * Synthetic event fired when the Animation is paused + */ + onPause?: Event; + + /** + * Synthetic event fires when the Animation is stopped + */ + onStop?: Event; + + _percent: number; + _startRepeatCount: number; + _getStep(): number; + + /** + * Convenience function. Fire event "evt" and pass it the + * arguments specified in "args". + */ + _fire(evt: Event, args?: any[]): this; /** - * Object used to generate values from a start value to an end value + * Start the animation. */ - interface LineConstructor { - new(start: number, end: number): Line; - } - - interface EasingFunction { - (n?: number): number; - } - - interface Animation extends Evented { - /** - * The time in milliseconds the animation will take to run - */ - duration: number; - - /** - * A two element array of start and end values, or a `_Line` instance to be - * used in the Animation. - */ - curve: Line | [number, number]; - - /** - * A Function to adjust the acceleration (or deceleration) of the progress - * across a _Line - */ - easing?: EasingFunction; + play(delay?: number, gotoStart?: boolean): this; - /** - * The number of times to loop the animation - */ - repeat: number; - - /** - * the time in milliseconds to wait before advancing to next frame - * (used as a fps timer: 1000/rate = fps) - */ - rate: number; + _play(gotoStart?: boolean): this; - /** - * The time in milliseconds to wait before starting animation after it - * has been .play()'ed - */ - delay?: number; - - /** - * Synthetic event fired before a Animation begins playing (synchronous) - */ - beforeBegin?: Event; - - /** - * Synthetic event fired as a Animation begins playing (useful?) - */ - onBegin?: Event; - - /** - * Synthetic event fired at each interval of the Animation - */ - onAnimate?: Event; + /** + * Pauses a running animation. + */ + pause(): this; - /** - * Synthetic event fired after the final frame of the Animation - */ - onEnd?: Event; - - /** - * Synthetic event fired any time the Animation is play()'ed - */ - onPlay?: Event; - - /** - * Synthetic event fired when the Animation is paused - */ - onPause?: Event; - - /** - * Synthetic event fires when the Animation is stopped - */ - onStop?: Event; - - _precent: number; - _startRepeatCount: number; - _getStep(): number; - - /** - * Convenience function. Fire event "evt" and pass it the - * arguments specified in "args". - */ - _fire(evt: Event, args?: any[]): this; + /** + * Sets the progress of the animation. + */ + gotoPercent(precent: number, andPlay?: boolean): this; - /** - * Start the animation. - */ - play(delay?: number, gotoStart?: boolean): this; - - _play(gotoStart?: boolean): this; - - /** - * Pauses a running animation. - */ - pause(): this; - - /** - * Sets the progress of the animation. - */ - gotoPercent(precent: number, andPlay?: boolean): this; + /** + * Stops a running animation. + */ + stop(gotoEnd?: boolean): Animation; - /** - * Stops a running animation. - */ - stop(gotoEnd?: boolean): Animation; - - /** - * cleanup the animation - */ - destroy(): void; - - /** - * Returns a string token representation of the status of - * the animation, one of: "paused", "playing", "stopped" - */ - status(): string; - - _cycle(): Animation; - _clearTimer(): void; - _startTimer(): void; - _stopTimer(): void; - } + /** + * cleanup the animation + */ + destroy(): void; /** - * A generic animation class that fires callbacks into its handlers - * object at various states. + * Returns a string token representation of the status of + * the animation, one of: "paused", "playing", "stopped" */ - interface AnimationConstructor { - new(args: any): Animation; - prototype: Animation; - } + status(): string; - interface AnimationCallback { - (node: HTMLElement): void; - } - - interface FadeArguments { - node: HTMLElement | string; - duration?: number; - easing?: EasingFunction; + _cycle(): Animation; + _clearTimer(): void; + _startTimer(): void; + _stopTimer(): void; +} - start?: Function; - end?: Function; - } +/** + * A generic animation class that fires callbacks into its handlers + * object at various states. + */ +export interface AnimationConstructor { + new(args: any): Animation; + prototype: Animation; +} - interface AnimationArgumentsProperties { - [name: string]: any; - } +export interface AnimationCallback { + (node: HTMLElement): void; +} - interface AnimationArguments extends FadeArguments { - properties?: AnimationArgumentsProperties; - onEnd?: AnimationCallback; - } +export interface FadeArguments { + node: HTMLElement | string; + duration?: number; + easing?: EasingFunction; - interface Fx { - _Line: LineConstructor; + start?: Function; + end?: Function; +} - Animation: AnimationConstructor; - - _fade(args: any): Animation; +export interface AnimationArgumentsProperties { + [name: string]: any; +} - /** - * Returns an animation that will fade node defined in 'args' from - * its current opacity to fully opaque. - */ - fadeIn(args: FadeArguments): Animation; +export interface AnimationArguments extends FadeArguments { + properties?: AnimationArgumentsProperties; + onEnd?: AnimationCallback; +} + + +export const _Line: LineConstructor; - /** - * Returns an animation that will fade node defined in 'args' - * from its current opacity to fully transparent. - */ - fadeOut(args: FadeArguments): Animation; +export const Animation: AnimationConstructor; + +export function _fade(args: any): Animation; - _defaultEasing(n?: number): number; +/** + * Returns an animation that will fade node defined in 'args' from + * its current opacity to fully opaque. + */ +export function fadeIn(args: FadeArguments): Animation; - /** - * Returns an animation that will transition the properties of - * node defined in `args` depending how they are defined in - * `args.properties` - */ - animateProperty(args: AnimationArguments): Animation; +/** + * Returns an animation that will fade node defined in 'args' + * from its current opacity to fully transparent. + */ +export function fadeOut(args: FadeArguments): Animation; + +export function _defaultEasing(n?: number): number; - /** - * A simpler interface to `animateProperty()`, also returns - * an instance of `Animation` but begins the animation - * immediately, unlike nearly every other Dojo animation API. - */ - anim( - node: HTMLElement | string, - properties: { [name: string]: any }, - duration?: number, - easing?: Function, - onEnd?: AnimationCallback, - delay?: number): Animation; - } -} -declare const fx: fx.Fx; -export = fx; +/** + * Returns an animation that will transition the properties of + * node defined in `args` depending how they are defined in + * `args.properties` + */ +export function animateProperty(args: AnimationArguments): Animation; + +/** + * A simpler interface to `animateProperty()`, also returns + * an instance of `Animation` but begins the animation + * immediately, unlike nearly every other Dojo animation API. + */ +export function anim( + node: HTMLElement | string, + properties: { [name: string]: any }, + duration?: number, + easing?: Function, + onEnd?: AnimationCallback, + delay?: number): Animation; diff --git a/src/typings/dojo/_base/kernel.d.ts b/src/typings/dojo/_base/kernel.d.ts --- a/src/typings/dojo/_base/kernel.d.ts +++ b/src/typings/dojo/_base/kernel.d.ts @@ -1,5 +1,5 @@ /* dojo/_base/kernel */ -import Config = require('./config'); +import { Config } from './config'; declare namespace dojo { interface Dijit { @@ -12,8 +12,7 @@ declare namespace dojo { interface Dojo { config: Config; global: any; - - // TODO: dojot, dojox + dijit: Dijit; dojox: Dojox;