From de8574d395843d0581c09b17e30046abf32354cb Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 19 Jan 2016 10:52:33 +0100 Subject: [PATCH 01/67] removed the KeyBinding constructor --- ace/ace.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/ace/ace.d.ts b/ace/ace.d.ts index 8fed295f20..b7ce4ebaa8 100644 --- a/ace/ace.d.ts +++ b/ace/ace.d.ts @@ -77,9 +77,6 @@ declare module AceAjax { onTextInput(text: any): void; } - var KeyBinding: { - new(editor: Editor): KeyBinding; - } export interface TextMode { From 7c5dbff213cb8a7f27200b1fa03af82b2c649c23 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Mon, 28 Mar 2016 13:55:13 -0400 Subject: [PATCH 02/67] TransitionGroup spreads HTMLAttribute props onto its component --- react/react-addons-transition-group.d.ts | 2 +- react/react-tests.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/react/react-addons-transition-group.d.ts b/react/react-addons-transition-group.d.ts index ca7bb4c31e..b31d7a5d2d 100644 --- a/react/react-addons-transition-group.d.ts +++ b/react/react-addons-transition-group.d.ts @@ -7,7 +7,7 @@ declare namespace __React { - interface TransitionGroupProps { + interface TransitionGroupProps extends HTMLAttributes { component?: ReactType; childFactory?: (child: ReactElement) => ReactElement; } diff --git a/react/react-tests.ts b/react/react-tests.ts index e0d9bb7be7..ca289ebda5 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -480,7 +480,9 @@ React.createFactory(CSSTransitionGroup)({ transitionName: "transition", transitionAppear: false, transitionEnter: true, - transitionLeave: true + transitionLeave: true, + id: "some-id", + className: "some-class" }); React.createFactory(CSSTransitionGroup)({ From f74ae92ad0817dfc6c5170e19bc00b3957927a0b Mon Sep 17 00:00:00 2001 From: Leon Adler Date: Wed, 22 Jun 2016 13:47:46 +0200 Subject: [PATCH 03/67] Fix package name for sortablejs --- sortablejs/sortablejs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sortablejs/sortablejs.d.ts b/sortablejs/sortablejs.d.ts index 1348a57fbb..87ca56e7c3 100644 --- a/sortablejs/sortablejs.d.ts +++ b/sortablejs/sortablejs.d.ts @@ -202,7 +202,7 @@ declare namespace Sortablejs { import Sortable = Sortablejs.Sortable; -declare module 'Sortable' { +declare module 'sortablejs' { import Sortable = Sortablejs.Sortable; export = Sortable; } From 0c2447dc9bd44504e3901ca834e1e99cf13d9b9d Mon Sep 17 00:00:00 2001 From: Charles Arnold Date: Mon, 27 Jun 2016 12:32:07 -0700 Subject: [PATCH 04/67] add gregorian-calendar type definitions --- .../gregorian-calendar-tests.ts | 14 + gregorian-calendar/gregorian-calendar.d.ts | 274 ++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 gregorian-calendar/gregorian-calendar-tests.ts create mode 100644 gregorian-calendar/gregorian-calendar.d.ts diff --git a/gregorian-calendar/gregorian-calendar-tests.ts b/gregorian-calendar/gregorian-calendar-tests.ts new file mode 100644 index 0000000000..d364e00fd2 --- /dev/null +++ b/gregorian-calendar/gregorian-calendar-tests.ts @@ -0,0 +1,14 @@ +/// + +import GregorianCalendar = require('gregorian-calendar'); +import GregorianCalendarFormat = require('gregorian-calendar-format'); + + +let cal = new GregorianCalendar(); +cal.set(2016, 7, 27, 0, 0, 0, 0); + +let fmt = new GregorianCalendarFormat('yyyy-MM'); + +let calAsStr = fmt.format(cal); +console.log(calAsStr); + diff --git a/gregorian-calendar/gregorian-calendar.d.ts b/gregorian-calendar/gregorian-calendar.d.ts new file mode 100644 index 0000000000..0bb2ffa934 --- /dev/null +++ b/gregorian-calendar/gregorian-calendar.d.ts @@ -0,0 +1,274 @@ +// Type definitions for gregorian-calendar v4.1.4 +// Project: https://github.com/yiminghe/gregorian-calendar +// Definitions by: Charlie Arnold +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare module 'gregorian-calendar' { + + class GregorianCalendar { + + constructor(locale?: Object); + + /** + * same as call setYear, setMonth, setDayOfMonth .... + */ + set(year: Number, month: Number, dayOfMonth: Number, + hourOfDay: Number, minutes: Number, seconds: Number, + milliseconds: Number): void; + + /** + * set absolute time for current instance + */ + setTime(time: Number): void; + + /** + * get absolute time for current instance + */ + getTime(): Number; + + /** + * set current date instance's timezone offset (in minutes) + */ + setTimezoneOffset(timezoneOffset: Number): void + + /** + * current date instance's timezone offset (in minutes) + */ + getTimezoneOffset(): Number; + + /** + * set the year of the given calendar field. + */ + setYear(year: Number): void; + + /** + * Returns the year of the given calendar field. + */ + getYear(): Number; + + /** + * set the month of the given calendar field. January is 0, you can use enum + */ + setMonth(month: Number): void; + + /** + * set the month of the given calendar field without influence month. + * 2015-09-29 -> setMonth(2) -> 2015-03-01 + * 2015-09-29 -> rollSetMonth(2) -> 2015-02-28 + */ + rollSetMonth(month: Number): void; + + /** + * Returns the month of the given calendar field. + */ + getMonth(): Number; + + /** + * set the day of month of the given calendar field. + */ + setDayOfMonth(day: Number): void; + + /** + * Returns the day of month of the given calendar field. + */ + getDayOfMonth(): Number; + + + /** + * set the hour of day for the given calendar field. + */ + setHourOfDay(hour: Number): void; + + /** + * Returns the hour of day for the given calendar field. + */ + getHourOfDay(): Number + + /** + * set the minute of the given calendar field. + */ + setMinutes(minute: Number): void; + + /** + * Returns the minute of the given calendar field. + */ + getMinutes(): Number; + + /** + * set the second of the given calendar field. + */ + setSeconds(second: Number): void; + + /** + * Returns the second of the given calendar field. + */ + getSeconds(): Number; + + /** + * set the millisecond of the given calendar field. + */ + setMilliSeconds(second: Number): void; + + /** + * Returns the millisecond of the given calendar field. + */ + getMilliSeconds(): Number; + + /** + * Returns the week of year of the given calendar field. + */ + getWeekOfYear(): Number; + + /** + * Returns the week of month of the given calendar field. + */ + getWeekOfMonth(): Number; + + /** + * Returns the day of year of the given calendar field. + */ + getDayOfYear(): Number; + + /** + * Returns the day of week of the given calendar field. sunday is 0, monday is 1 + */ + getDayOfWeek(): Number; + + /** + * Returns the day of week in month of the given calendar field. + */ + getDayOfWeekInMonth(): Number; + + /** + * add the year of the given calendar field. + */ + addYear(amount: Number): void; + + /** + * add the month of the given calendar field. + */ + addMonth(amount: Number): void; + + /** + * add the day of month of the given calendar field. + */ + addDayOfMonth(amount: Number): void; + + /** + * add the hour of day of the given calendar field. + */ + addHourOfDay(amount: Number): void; + + /** + * add the minute of the given calendar field. + */ + addMinute(amount: Number): void; + + /** + * add the second of the given calendar field. + */ + addSecond(amount: Number): void; + + /** + * add the millisecond of the given calendar field. + */ + addMilliSecond(amount: Number): void; + + /** + * Returns the week number of year represented by this GregorianCalendar. + */ + getWeekYear(): Number; + + /** + * Sets this GregorianCalendar to the date given by the date specifiers - weekYear, weekOfYear, and dayOfWeek. + * weekOfYear follows the WEEK_OF_YEAR numbering. + * The dayOfWeek value must be one of the DAY_OF_WEEK values: SUNDAY to SATURDAY. + * weekYear: the week year + * weekOfYear: the week number based on weekYear + * dayOfWeek: the day of week value + */ + setWeekDate(weekYear: Number, weekOfYear: Number, dayOfWeek: Number): void; + + /** + * Returns the number of weeks in the week year + */ + getWeeksInWeekYear(): Number; + + /** + * Returns a clone of current instance + */ + clone(): GregorianCalendar; + + equals(other: GregorianCalendar): boolean; + + /** + * compare this object and other by day. return -1 0 or 1 + */ + compareToDay(other: GregorianCalendar): Number; + + /** + * clear all field of current instance + */ + clear(): void; + } + + export = GregorianCalendar; +} + +declare module 'gregorian-calendar-format' { + + import GregorianCalendar = require('gregorian-calendar'); + + enum DateTimeStyle { + /** + * full style + */ + FULL = 0, + /** + * long style + */ + LONG, + /** + * medium style + */ + MEDIUM, + /** + * short style + */ + SHORT, + } + + class DateTimeFormat { + + public Style: DateTimeStyle; + + /** + * @param pattern The format pattern string + * @param locale The local of to output (defaults to require('gregorian-calendar/lib/locale/en_US'), + * may also be one of: + * require('gregorian-calendar/lib/locale/zh_CN') + * require('gregorian-calendar/lib/locale/ru_RU') + */ + constructor(pattern: string, locale?: Object); + + /** + * format an instance of GregorianCalendar according to pattern + */ + format(calendar: GregorianCalendar): String; + + /** + * parse a dateString to an instance of GregorianCalendar according to pattern, it's better to specify calendarLocale, such as + * `df.parse('2013-11-12', {locale: require('gregorian-calendar/lib/locale/zh_CN'}));` + */ + parse(dateString: String, {locale: Object}): GregorianCalendar; + + /** + * get a predefine GregorianCalendarFormat instance + */ + getDateTimeInstance(dateStyle: DateTimeStyle, timeStyle: DateTimeStyle, locale?: Object): DateTimeFormat; + } + + export = DateTimeFormat; +} + From b99577c66564b69f9ba44758e19eb4e603b264c4 Mon Sep 17 00:00:00 2001 From: Oscar Lorentzon Date: Mon, 27 Jun 2016 22:27:41 +0200 Subject: [PATCH 05/67] Correct param and return types for ShapeUtils triangulation methods. --- threejs/three.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index c7a36b3234..389d247e53 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -5725,8 +5725,8 @@ declare namespace THREE { export namespace ShapeUtils { export function area(contour: number[]): number; - export function triangulate(contour: number[], indices: boolean): number[]; - export function triangulateShape(contour: number[], holes: any[]): number[]; + export function triangulate(contour: Vector2[], indices: boolean): Vector2[][] | number[][]; + export function triangulateShape(contour: Vector2[], holes: Vector2[][]): Vector2[][]; export function isClockWise(pts: number[]): boolean; export function b2(t: number, p0: number, p1: number, p2: number): number; export function b3(t: number, p0: number, p1: number, p2: number, p3: number): number; From 7dba2468ba67b130023f6578a7d35c91acdac47d Mon Sep 17 00:00:00 2001 From: DmitryEfimenko Date: Mon, 27 Jun 2016 16:08:01 -0700 Subject: [PATCH 06/67] export interfaces --- agenda/agenda.d.ts | 560 ++++++++++++++++++++++----------------------- 1 file changed, 279 insertions(+), 281 deletions(-) diff --git a/agenda/agenda.d.ts b/agenda/agenda.d.ts index 011676bc86..463ba43d2e 100644 --- a/agenda/agenda.d.ts +++ b/agenda/agenda.d.ts @@ -19,277 +19,6 @@ declare module "agenda" { (err?: Error, result?: T): void; } - /** - * Agenda Configuration. - */ - interface AgendaConfiguration { - - /** - * Sets the interval with which the queue is checked. A number in milliseconds or a frequency string. - */ - processEvery?: string | number; - - /** - * Takes a number which specifies the default number of a specific job that can be running at any given moment. - * By default it is 5. - */ - defaultConcurrency?: number; - - /** - * Takes a number which specifies the max number of jobs that can be running at any given moment. By default it - * is 20. - */ - maxConcurrency?: number; - - /** - * Takes a number which specifies the default number of a specific job that can be locked at any given moment. - * By default it is 0 for no max. - */ - defaultLockLimit?: number; - - /** - * Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is - * 0 for no max. - */ - lockLimit?: number; - - /** - * Takes a number which specifies the default lock lifetime in milliseconds. By default it is 10 minutes. This - * can be overridden by specifying the lockLifetime option to a defined job. - */ - defaultLockLifetime?: number; - - /** - * Specifies that Agenda should be initialized using and existing MongoDB connection. - */ - mongo?: { - /** - * The MongoDB database connection to use. - */ - db: Db; - - /** - * The name of the collection to use. - */ - collection?: string; - } - - /** - * Specifies that Agenda should connect to MongoDB. - */ - db?: { - /** - * The connection URL. - */ - address: string; - - /** - * The name of the collection to use. - */ - collection?: string; - - /** - * Connection options to pass to MongoDB. - */ - options?: any; - } - } - - /** - * The database record associated with a job. - */ - interface JobAttributes { - /** - * The record identity. - */ - _id: ObjectID; - - /** - * The name of the job. - */ - name: string; - - /** - * The type of the job (single|normal). - */ - type: string; - - /** - * The job details. - */ - data: { [name: string]: any }; - - /** - * The priority of the job. - */ - priority: number; - - /** - * How often the job is repeated using a human-readable or cron format. - */ - repeatInterval: string | number; - - /** - * The timezone that conforms to [moment-timezone](http://momentjs.com/timezone/). - */ - repeatTimezone: string; - - /** - * Date/time the job was las modified. - */ - lastModifiedBy: string; - - /** - * Date/time the job will run next. - */ - nextRunAt: Date; - - /** - * Date/time the job was locked. - */ - lockedAt: Date; - - /** - * Date/time the job was last run. - */ - lastRunAt: Date; - - /** - * Date/time the job last finished running. - */ - lastFinishedAt: Date; - - /** - * The reason the job failed. - */ - failReason: string; - - /** - * The number of times the job has failed. - */ - failCount: number; - - /** - * The date/time the job last failed. - */ - failedAt: Date; - } - - /** - * A scheduled job. - */ - interface Job { - - /** - * The database record associated with the job. - */ - attrs: JobAttributes; - - /** - * Specifies an interval on which the job should repeat. - * @param interval A human-readable format String, a cron format String, or a Number. - * @param options An optional argument that can include a timezone field. The timezone should be a string as - * accepted by moment-timezone and is considered when using an interval in the cron string format. - */ - repeatEvery(interval: string | number, options?: { timezone?: string }): Job - - /** - * Specifies a time when the job should repeat. [Possible values](https://github.com/matthewmueller/date#examples). - * @param time - */ - repeatAt(time: string): Job - - /** - * Disables the job. - */ - disable(): Job; - - /** - * Enables the job. - */ - enable(): Job; - - /** - * Ensure that only one instance of this job exists with the specified properties - * @param value The properties associated with the job that must be unqiue. - * @param opts - */ - unique(value: any, opts?: { insertOnly?: boolean }): Job; - - /** - * Specifies the next time at which the job should run. - * @param time The next time at which the job should run. - */ - schedule(time: string | Date): Job; - - /** - * Specifies the priority weighting of the job. - * @param value The priority of the job (lowest|low|normal|high|highest|number). - */ - priority(value: string | number): Job; - - /** - * Sets job.attrs.failedAt to now, and sets job.attrs.failReason to reason. - * @param reason A message or Error object that indicates why the job failed. - */ - fail(reason: string | Error): Job; - - /** - * Runs the given job and calls callback(err, job) upon completion. Normally you never need to call this manually - * @param cb Called when the job is completed. - */ - run(cb?: ResultCallback): Job; - - /** - * Returns true if the job is running; otherwise, returns false. - */ - isRunning(): boolean; - - /** - * Saves the job into the database. - * @param cb Called when the job is saved. - */ - save(cb?: ResultCallback): Job; - - /** - * Removes the job from the database and cancels the job. - * @param cb Called after the job has beeb removed from the database. - */ - remove(cb?: Callback): void; - - /** - * Resets the lock on the job. Useful to indicate that the job hasn't timed out when you have very long running - * jobs. - * @param cb Called after the job has been saved to the database. - */ - touch(cb?: Callback): void; - } - - interface JobOptions { - - /** - * Maximum number of that job that can be running at once (per instance of agenda) - */ - concurrency?: number; - - /** - * Maximum number of that job that can be locked at once (per instance of agenda) - */ - lockLimit?: number; - - /** - * Interval in ms of how long the job stays locked for (see multiple job processors for more info). A job will - * automatically unlock if done() is called. - */ - lockLifetime?: number; - - /** - * (lowest|low|normal|high|highest|number) specifies the priority of the job. Higher priority jobs will run - * first. - */ - priority?: string | number; - } - class Agenda extends EventEmitter { /** @@ -297,7 +26,7 @@ declare module "agenda" { * @param config Optional configuration to initialize the Agenda. * @param cb Optional callback called with the MongoDB colleciton. */ - constructor(config?: AgendaConfiguration, cb?: ResultCallback); + constructor(config?: Agenda.AgendaConfiguration, cb?: ResultCallback); /** * Connect to the specified MongoDB server and database. @@ -360,14 +89,14 @@ declare module "agenda" { * @param name The name of the job. * @param data Data to associated with the job. */ - create(name: string, data?: any): Job; + create(name: string, data?: any): Agenda.Job; /** * Find all Jobs matching `query` and pass same back in cb(). * @param query * @param cb */ - jobs(query: any, cb: ResultCallback): void; + jobs(query: any, cb: ResultCallback): void; /** * Removes all jobs in the database without defined behaviors. Useful if you change a definition name and want @@ -384,8 +113,8 @@ declare module "agenda" { * @param options The options for the job. * @param handler The handler to execute. */ - define(name: string, handler: (job?: Job, done?: (err?: Error) => void) => void): void; - define(name: string, options: JobOptions, handler: (job?: Job, done?: (err?: Error) => void) => void): void; + define(name: string, handler: (job?: Agenda.Job, done?: (err?: Error) => void) => void): void; + define(name: string, options: Agenda.JobOptions, handler: (job?: Agenda.Job, done?: (err?: Error) => void) => void): void; /** * Runs job name at the given interval. Optionally, data and options can be passed in. @@ -395,8 +124,8 @@ declare module "agenda" { * @param options An optional argument that will be passed to job.repeatEvery. * @param cb An optional callback function which will be called when the job has been persisted in the database. */ - every(interval: number | string, names: string, data?: any, options?: any, cb?: ResultCallback): Job; - every(interval: number | string, names: string[], data?: any, options?: any, cb?: ResultCallback): Job[]; + every(interval: number | string, names: string, data?: any, options?: any, cb?: ResultCallback): Agenda.Job; + every(interval: number | string, names: string[], data?: any, options?: any, cb?: ResultCallback): Agenda.Job[]; /** * Schedules a job to run name once at a given time. @@ -405,8 +134,8 @@ declare module "agenda" { * @param data An optional argument that will be passed to the processing function under job.attrs.data. * @param cb An optional callback function which will be called when the job has been persisted in the database. */ - schedule(when: Date | string, names: string, data?: any, cb?: ResultCallback): Job; - schedule(when: Date | string, names: string[], data?: any, cb?: ResultCallback): Job[]; + schedule(when: Date | string, names: string, data?: any, cb?: ResultCallback): Agenda.Job; + schedule(when: Date | string, names: string[], data?: any, cb?: ResultCallback): Agenda.Job[]; /** * Schedules a job to run name once immediately. @@ -414,7 +143,7 @@ declare module "agenda" { * @param data An optional argument that will be passed to the processing function under job.attrs.data. * @param cb An optional callback function which will be called when the job has been persisted in the database. */ - now(name: string, data?: any, cb?: ResultCallback): Job; + now(name: string, data?: any, cb?: ResultCallback): Agenda.Job; /** * Cancels any jobs matching the passed mongodb-native query, and removes them from the database. @@ -436,7 +165,276 @@ declare module "agenda" { } namespace Agenda { + /** + * Agenda Configuration. + */ + interface AgendaConfiguration { + /** + * Sets the interval with which the queue is checked. A number in milliseconds or a frequency string. + */ + processEvery?: string | number; + + /** + * Takes a number which specifies the default number of a specific job that can be running at any given moment. + * By default it is 5. + */ + defaultConcurrency?: number; + + /** + * Takes a number which specifies the max number of jobs that can be running at any given moment. By default it + * is 20. + */ + maxConcurrency?: number; + + /** + * Takes a number which specifies the default number of a specific job that can be locked at any given moment. + * By default it is 0 for no max. + */ + defaultLockLimit?: number; + + /** + * Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is + * 0 for no max. + */ + lockLimit?: number; + + /** + * Takes a number which specifies the default lock lifetime in milliseconds. By default it is 10 minutes. This + * can be overridden by specifying the lockLifetime option to a defined job. + */ + defaultLockLifetime?: number; + + /** + * Specifies that Agenda should be initialized using and existing MongoDB connection. + */ + mongo?: { + /** + * The MongoDB database connection to use. + */ + db: Db; + + /** + * The name of the collection to use. + */ + collection?: string; + } + + /** + * Specifies that Agenda should connect to MongoDB. + */ + db?: { + /** + * The connection URL. + */ + address: string; + + /** + * The name of the collection to use. + */ + collection?: string; + + /** + * Connection options to pass to MongoDB. + */ + options?: any; + } + } + + /** + * The database record associated with a job. + */ + interface JobAttributes { + /** + * The record identity. + */ + _id: ObjectID; + + /** + * The name of the job. + */ + name: string; + + /** + * The type of the job (single|normal). + */ + type: string; + + /** + * The job details. + */ + data: { [name: string]: any }; + + /** + * The priority of the job. + */ + priority: number; + + /** + * How often the job is repeated using a human-readable or cron format. + */ + repeatInterval: string | number; + + /** + * The timezone that conforms to [moment-timezone](http://momentjs.com/timezone/). + */ + repeatTimezone: string; + + /** + * Date/time the job was las modified. + */ + lastModifiedBy: string; + + /** + * Date/time the job will run next. + */ + nextRunAt: Date; + + /** + * Date/time the job was locked. + */ + lockedAt: Date; + + /** + * Date/time the job was last run. + */ + lastRunAt: Date; + + /** + * Date/time the job last finished running. + */ + lastFinishedAt: Date; + + /** + * The reason the job failed. + */ + failReason: string; + + /** + * The number of times the job has failed. + */ + failCount: number; + + /** + * The date/time the job last failed. + */ + failedAt: Date; + } + + /** + * A scheduled job. + */ + interface Job { + + /** + * The database record associated with the job. + */ + attrs: JobAttributes; + + /** + * Specifies an interval on which the job should repeat. + * @param interval A human-readable format String, a cron format String, or a Number. + * @param options An optional argument that can include a timezone field. The timezone should be a string as + * accepted by moment-timezone and is considered when using an interval in the cron string format. + */ + repeatEvery(interval: string | number, options?: { timezone?: string }): Job + + /** + * Specifies a time when the job should repeat. [Possible values](https://github.com/matthewmueller/date#examples). + * @param time + */ + repeatAt(time: string): Job + + /** + * Disables the job. + */ + disable(): Job; + + /** + * Enables the job. + */ + enable(): Job; + + /** + * Ensure that only one instance of this job exists with the specified properties + * @param value The properties associated with the job that must be unqiue. + * @param opts + */ + unique(value: any, opts?: { insertOnly?: boolean }): Job; + + /** + * Specifies the next time at which the job should run. + * @param time The next time at which the job should run. + */ + schedule(time: string | Date): Job; + + /** + * Specifies the priority weighting of the job. + * @param value The priority of the job (lowest|low|normal|high|highest|number). + */ + priority(value: string | number): Job; + + /** + * Sets job.attrs.failedAt to now, and sets job.attrs.failReason to reason. + * @param reason A message or Error object that indicates why the job failed. + */ + fail(reason: string | Error): Job; + + /** + * Runs the given job and calls callback(err, job) upon completion. Normally you never need to call this manually + * @param cb Called when the job is completed. + */ + run(cb?: ResultCallback): Job; + + /** + * Returns true if the job is running; otherwise, returns false. + */ + isRunning(): boolean; + + /** + * Saves the job into the database. + * @param cb Called when the job is saved. + */ + save(cb?: ResultCallback): Job; + + /** + * Removes the job from the database and cancels the job. + * @param cb Called after the job has beeb removed from the database. + */ + remove(cb?: Callback): void; + + /** + * Resets the lock on the job. Useful to indicate that the job hasn't timed out when you have very long running + * jobs. + * @param cb Called after the job has been saved to the database. + */ + touch(cb?: Callback): void; + } + + interface JobOptions { + + /** + * Maximum number of that job that can be running at once (per instance of agenda) + */ + concurrency?: number; + + /** + * Maximum number of that job that can be locked at once (per instance of agenda) + */ + lockLimit?: number; + + /** + * Interval in ms of how long the job stays locked for (see multiple job processors for more info). A job will + * automatically unlock if done() is called. + */ + lockLifetime?: number; + + /** + * (lowest|low|normal|high|highest|number) specifies the priority of the job. Higher priority jobs will run + * first. + */ + priority?: string | number; + } } export = Agenda; From 4c1e6bfd169b0daeb85271f14bc277caf1c67a8d Mon Sep 17 00:00:00 2001 From: cw882 Date: Tue, 28 Jun 2016 11:31:13 +0100 Subject: [PATCH 07/67] Update openlayers.d.ts Added StaticImageOptions and ZoomToExtentOptions. Updated the classes to require the option types. --- openlayers/openlayers.d.ts | 47 +++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index fafaaa186b..ebdb27d979 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -4,7 +4,50 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace olx { +interface StaticImageOptions { + /** Attributions */ + attributions?: Array + + /*** The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you are using the WebGL renderer or if you want to access pixel data with the Canvas renderer. See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail. */ + crossOrigin?: string + + /*** Extent of the image in map coordinates. This is the [left, bottom, right, top] map coordinates of your image.*/ + imageExtent: ol.Extent; + + /*** Size of the image in pixels.*/ + imageSize?: ol.Size; + + /*** experimental Optional function to load an image given a URL.*/ + imageLoadFunction?: ol.TileLoadFunctionType; + + /*** Optional logo.*/ + logo?: olx.LogoOptions; + + /*** experimental Projection.*/ + projection: ol.proj.Projection; + + /*** Image URL.*/ + url: string; + } + + interface ZoomToExtentOptions { + /*** Class name. Default is ol-zoom-extent.*/ + className?: string; + + /*** Target.*/ + target?: Element; + + /*** Text label to use for the button. Default is E. Instead of text, also a Node (e.g. a span element) can be used.*/ + label?: string | Node; + + /*** Text label to use for the button tip. Default is Zoom to extent.*/ + tipLabel?: string; + + /*** The extent to zoom to. If undefined the validity extent of the view projection is used.*/ + extent: ol.Extent; + } + interface AttributionOptions { /** HTML markup for this attribution. */ @@ -2376,6 +2419,7 @@ declare namespace ol { } class ZoomToExtent { + constructor(options?: olx.ZoomToExtentOptions); } } @@ -4109,7 +4153,8 @@ declare namespace ol { class ImageMapGuide extends Image { } - class ImageStatic extends Image { + class ImageStatic extends ol.source.Image { + constructor(options?: olx.StaticImageOptions); } class ImageVector extends ImageCanvas { From 1eba4008703b9338fde6096645b7a2ff93df10cb Mon Sep 17 00:00:00 2001 From: cw882 Date: Tue, 28 Jun 2016 11:37:25 +0100 Subject: [PATCH 08/67] Update openlayers.d.ts Formatting change --- openlayers/openlayers.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index ebdb27d979..270876f440 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace olx { -interface StaticImageOptions { + interface StaticImageOptions { /** Attributions */ attributions?: Array From c4d63af4ec126eaa52d191b4914c65250a027a50 Mon Sep 17 00:00:00 2001 From: Thomas-P Date: Tue, 28 Jun 2016 13:42:30 +0200 Subject: [PATCH 09/67] Fixing return values for Observable functions All Observable functions return an Observable instead of T. So I fixed this in the rx-lite.d.ts --- rx/rx-lite-tests.ts | 33 +++++++++++++++++++++++++++++++++ rx/rx-lite.d.ts | 12 ++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/rx/rx-lite-tests.ts b/rx/rx-lite-tests.ts index 9949fa2ea8..a6adbdc289 100644 --- a/rx/rx-lite-tests.ts +++ b/rx/rx-lite-tests.ts @@ -9,5 +9,38 @@ function test_scan() { const source2: Rx.Observable = Rx.Observable.range(1, 3) .scan((acc, x, i, source) => acc + x, '...'); + + /* concatAll Example */ + var source = Rx.Observable.range(0, 3) + .map(function (x) { return Rx.Observable.range(x, 3); }) + .concatAll(); + + var subscription = source.subscribe( + function (x) { + console.log('Next: %s', x); + }, + function (err) { + console.log('Error: %s', err); + }, + function () { + console.log('Completed'); + }); + + /* mergeAll example */ + var source = Rx.Observable.range(0, 3) + .map(function (x) { return Rx.Observable.range(x, 3); }) + .mergeAll(); + + var subscription = source.subscribe( + function (x) { + console.log('Next: %s', x); + }, + function (err) { + console.log('Error: %s', err); + }, + function () { + console.log('Completed'); + }); + } diff --git a/rx/rx-lite.d.ts b/rx/rx-lite.d.ts index aa8137f7b7..f159979204 100644 --- a/rx/rx-lite.d.ts +++ b/rx/rx-lite.d.ts @@ -245,8 +245,8 @@ declare namespace Rx { withLatestFrom(souces: (Observable|IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; concat(...sources: (Observable|IPromise)[]): Observable; concat(sources: (Observable|IPromise)[]): Observable; - concatAll(): T; - concatObservable(): T; // alias for concatAll + concatAll(): Observable; + concatObservable(): Observable; // alias for concatAll concatMap(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat concatMap(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat concatMap(selector: (value: T, index: number) => Observable): Observable; // alias for selectConcat @@ -257,12 +257,12 @@ declare namespace Rx { merge(maxConcurrent: number): T; merge(other: Observable): Observable; merge(other: IPromise): Observable; - mergeAll(): T; - mergeObservable(): T; // alias for mergeAll + mergeAll(): Observable; + mergeObservable(): Observable; // alias for mergeAll skipUntil(other: Observable): Observable; skipUntil(other: IPromise): Observable; - switch(): T; - switchLatest(): T; // alias for switch + switch(): Observable; + switchLatest(): Observable; // alias for switch takeUntil(other: Observable): Observable; takeUntil(other: IPromise): Observable; zip(second: Observable|IPromise): Observable<[T, T2]>; From f67617804d06fa21089bbfe7d48dd42ea183b457 Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Tue, 28 Jun 2016 16:07:00 -0400 Subject: [PATCH 10/67] Added Definitions for jSuite and SuiteScript --- suitescript/suitescript.d.ts | 145 +++++++++++++++++++++++++---------- 1 file changed, 105 insertions(+), 40 deletions(-) diff --git a/suitescript/suitescript.d.ts b/suitescript/suitescript.d.ts index 3fee0a8785..e3517b37ef 100644 --- a/suitescript/suitescript.d.ts +++ b/suitescript/suitescript.d.ts @@ -309,7 +309,7 @@ declare namespace nlobjAssistant.prototype { /** * */ - getFieldValues : /* nlobjAssistantStep.prototype.getFieldValues */ any; + getFieldValues : /* nlobjAssistantStep.prototype.getFieldValues */ string[]; /** * @@ -319,12 +319,12 @@ declare namespace nlobjAssistant.prototype { /** * */ - getLineItemValue : /* nlobjAssistantStep.prototype.getLineItemValue */ any; + getLineItemValue : /* nlobjAssistantStep.prototype.getLineItemValue */ string; /** * */ - getAllFields : /* nlobjAssistantStep.prototype.getAllFields */ any; + getAllFields : /* nlobjAssistantStep.prototype.getAllFields */ string[]; /** * @@ -414,10 +414,12 @@ declare namespace nlobjForm.prototype { * @param initializeValues * @return */ -declare function nlapiCopyRecord(type:string, id:any, initializeValues:any):nlobjRecord; +declare function nlapiCopyRecord(type:string, id:any, initializeValues?:any):nlobjRecord; declare function nlapiDisableLineItemField(type:string, fldnam:string, val:boolean):void; declare function nlapiDisableField(fldnam:string, val:any):void; +declare function nlapiLoadSearch(fldnam:string, val:any):void; +declare function nlapiCreateSearch(type:string, filters:nlobjSearchFilter|nlobjSearchFilter[], columns:nlobjSearchColumn|nlobjSearchColumn[]):nlobjSearch; /** * Load an existing record from the system. @@ -439,7 +441,7 @@ declare function nlapiDisableField(fldnam:string, val:any):void; * @param initializeValues * @return */ -declare function nlapiLoadRecord(type:string, id:any, initializeValues:any):nlobjRecord; +declare function nlapiLoadRecord(type:string, id:any, initializeValues?:any):nlobjRecord; /** * Instantiate a new nlobjRecord object containing all the default field data for that record type. @@ -457,7 +459,7 @@ declare function nlapiLoadRecord(type:string, id:any, initializeValues:any):nlob * @param initializeValues * @return */ -declare function nlapiCreateRecord(type:string, initializeValues:any):nlobjRecord; +declare function nlapiCreateRecord(type:string, initializeValues?:any):nlobjRecord; /** * Submit a record to the system for creation or update. @@ -478,7 +480,7 @@ declare function nlapiCreateRecord(type:string, initializeValues:any):nlobjRecor * @param ignoreMandatoryFields? * @return */ -declare function nlapiSubmitRecord(record:any, doSourcing?:boolean, ignoreMandatoryFields?:boolean):string; +declare function nlapiSubmitRecord(record:any, doSourcing?:boolean, ignoreMandatoryFields?:boolean):any; /** * Delete a record from the system. @@ -720,7 +722,7 @@ declare function nlapiResolveURL(type:string, subtype:string, id?:string, pagemo * @param parameters? * @return */ -declare function nlapiSetRedirectURL(type:string, subtype:string, id?:string, pagemode?:string, parameters?:any):void; +declare function nlapiSetRedirectURL(type:string, identifier:string, id?:string|number, editmode?:boolean, parameters?:any):void; /** * Request a URL to an external or internal resource. @@ -745,7 +747,7 @@ declare function nlapiSetRedirectURL(type:string, subtype:string, id?:string, pa * @param method * @return */ -declare function nlapiRequestURL(url:string, postdata:any, headers?:any, callback?:any, method?:any):any; +declare function nlapiRequestURL(url:string, postdata?:any, headers?:any, callback?:any, method?:any):any; /** * Return context information about the current user/script. @@ -860,7 +862,7 @@ declare function nlapiGetRecordId():any; * @param replyTo * @return */ -declare function nlapiSendEmail(from:any, to:any, subject:string, body:string, cc:any, bcc:any, records:any, files:any, notifySenderOnBounce:boolean, internalOnly:boolean, replyTo:string):any; +declare function nlapiSendEmail(author:number, recipient:string|number, subject:string, body:string|nlobjFile[], cc?:string|string[], bcc?:string|string[], records?:any, attachments?:nlobjFile|nlobjFile[], notifySenderOnBounce?:boolean, internalOnly?:boolean, replyTo?:string):void; /** * Sends a single on-demand campaign email to a specified recipient and returns a campaign response ID to track the email. @@ -1234,7 +1236,7 @@ declare function nlapiGetLineItemDateTimeValue(type:string, fldnam:string, linen * @param linenum * @param value */ -declare function nlapiSetLineItemValue(type:string, fldnam:string, linenum:any, value:string):void; +declare function nlapiSetLineItemValue(type:string, fldnam:string, linenum:any, value:any):void; /** * Set the value of a sublist field on the current record on a page. @@ -1377,7 +1379,7 @@ declare function nlapiRemoveLineItem(type:string, line?:any):any; * @param synchronous? * @return */ -declare function nlapiSetCurrentLineItemValue(type:string, fldnam:string, value:string, firefieldchanged?:boolean, synchronous?:boolean):any; +declare function nlapiSetCurrentLineItemValue(type:string, fldnam:string, value:string|number, firefieldchanged?:boolean, synchronous?:boolean):void; /** * Set the value of a field on the currently selected line. @@ -1811,7 +1813,7 @@ declare function nlapiLoadFile(id:any):any; * @param file * @return */ -declare function nlapiSubmitFile(file:any):any; +declare function nlapiSubmitFile(file:nlobjFile):any; /** * Delete a file from the file cabinet. @@ -1842,7 +1844,7 @@ declare function nlapiDeleteFile(id:any):any; * @param contents * @return */ -declare function nlapiCreateFile(name:string, type:string, contents:string):any; +declare function nlapiCreateFile(name:string, type:string, contents:string):nlobjFile; /** * Perform a mail merge operation using any template and up to 2 records and returns an nlobjFile with the results. @@ -1961,7 +1963,7 @@ declare function nlapiLogExecution(type:string, title:string, details?:string):a * @param parameters * @return */ -declare function nlapiScheduleScript(script:any, deployment:any, parameters:any):string; +declare function nlapiScheduleScript(script:string, deployment:string, parameters?:any):string; /** * Return a URL with a generated OAuth token. @@ -2016,7 +2018,7 @@ declare function nlapiSubmitConfiguration(setup:any):void; * @param format * @return */ -declare function nlapiStringToDate(str:string, format:string):any; +declare function nlapiStringToDate(str:string, format?:string):Date; /** * Convert a Date object into a String @@ -2030,7 +2032,7 @@ declare function nlapiStringToDate(str:string, format:string):any; * @param formattype? * @return */ -declare function nlapiDateToString(d:any, formattype?:string):string; +declare function nlapiDateToString(d:Date, formattype?:string):string; /** * Add days to a Date object and returns a new Date @@ -2082,7 +2084,7 @@ declare function nlapiFormatCurrency(str:string):string; * @param s * @return */ -declare function nlapiEncrypt(s:string):string; +declare function nlapiEncrypt(s:string, algotithm:string, key?:string):string; /** * Escape a String for use in an XML document. @@ -2152,6 +2154,8 @@ declare function nlapiValidateXML(xmlDocument:any, schemaDocument:any, schemaFol */ declare function nlapiSelectValue(node:any, xpath:string):string; +declare function nlapiYieldScript():void; + /** * Select an array of values from an XML node using XPath. Supports custom namespaces (nodes in default namespace can be referenced using "nlapi" as the prefix) * @@ -2190,7 +2194,7 @@ declare function nlapiSelectNode(node:any, xpath:string):any; * @param node * @param xpath */ -declare function nlapiSelectNodes(node:any, xpath:string):void; +declare function nlapiSelectNodes(node:any, xpath:string):any; /** * Calculate exchange rate between two currencies as of today or an optional effective date. @@ -2386,6 +2390,51 @@ declare function removeSubrecord(fldnam:string):void; */ declare function viewSubrecord(fldnam:string):void; + +declare interface nlobjSearch { + +} + +declare interface StandardLine { + getEntityId():number; + getId():number; + getSubsidiaryId():number; + getTaxableAmount():string; + getTaxAmount():string; + getTaxItemId():number; + getTaxType():string; + isPosting():boolean; + isTaxable():boolean; +} + +declare interface StandardLines { + getCount(): number; + getLine(index:number):StandardLine; +} + +declare interface CustomLine { + isBookSpecific():boolean; + setBookSpecific(bookSpecific:boolean):void; + setAccountId(accountId:number):void; + setClassId(classId:number):void; + setCreditAmount(credit:string):void; + setDebitAmount(debit:string):void; + setDepartmentId(departmentId:number):void; + setLocationId(locationId:number):void; + setMemo(memo:string):void; +} + +declare interface CustomLines { + addNewLine():CustomLine; + getCount():number; + getLine(index:number):CustomLine; +} + +declare interface AccountingBook { + getId():number; + isPrimary():boolean; +} + /** * Return a new instance of nlobjRecord used for accessing and manipulating record objects. * @@ -2414,7 +2463,7 @@ declare interface nlobjRecord { * @since 2008.1 * @return */ - getId(): any; + getId(): string|number; /** * Return the recordType corresponding to this record. @@ -2533,7 +2582,7 @@ declare interface nlobjRecord { * @param value * @return */ - setFieldValue(name:string, value:string): any; + setFieldValue(name:string, value:string|number): any; /** * Set the values of a multi-select field. @@ -2577,7 +2626,7 @@ declare interface nlobjRecord { * @since 2008.1 * @param name */ - getFieldValues(name:string): void; + getFieldValues(name:string): string[]; /** * Set the value (via display value) of a select field. @@ -2696,7 +2745,7 @@ declare interface nlobjRecord { * * @since 2008.1 */ - getAllFields(): void; + getAllFields(): string[]; /** * Return an Array of all field names on a record for a particular sublist. @@ -2767,7 +2816,7 @@ declare interface nlobjRecord { * @param name * @param line */ - getLineItemValue(group:string, name:string, line:any): void; + getLineItemValue(group:string, name:string, line:any): string; /** * Return the value of a sublist field. @@ -2823,7 +2872,9 @@ declare interface nlobjRecord { * @param value * @return */ - setCurrentLineItemValue(group:string, name:string, value:string): any; + setCurrentLineItemValue(group:string, name:string, value:string|number, firefieldchanged?:boolean, synchronous?:boolean):void; + + setCurrentLineItemText(group:string, name:string, value:string|number, firefieldchanged?:boolean, synchronous?:boolean):void; /** * Set the current value of a sublist field. @@ -2966,7 +3017,7 @@ declare interface nlobjRecord { * @since 2009.2 * @param group */ - getLineItemCount(group:string): void; + getLineItemCount(group:string): any; /** * Return line number for 1st occurence of field value in a sublist column. @@ -3226,7 +3277,7 @@ declare interface nlobjConfiguration { * @since 2009.2 * @param name */ - getFieldValues(name:string): void; + getFieldValues(name:string): string[]; /** * set the value (via display value) of a field. @@ -3302,7 +3353,7 @@ declare interface nlobjConfiguration { * * @since 2009.2 */ - getAllFields(): void; + getAllFields(): string[]; } /** @@ -3612,7 +3663,7 @@ declare interface nlobjSearchColumn { * @param summary * @return */ - new (name:string, join:string, summary:string): any; + new (name:string, join?:string, summary?:string): nlobjSearchColumn; /** * return the name of this search column. @@ -3684,6 +3735,12 @@ declare interface nlobjSearchColumn { * @return */ setSort(order:any): (name:string, join:string, summary:string) => void; + + setLabel(label:string): nlobjSearchColumn; +} + +declare class nlobjSearchColumn { + constructor (name:string, join?:string, summary?:string); } /** @@ -4037,7 +4094,7 @@ declare interface nlobjContext { * return the environment that the script is executing in: SANDBOX, PRODUCTION, BETA, INTERNAL * @since 2008.2 */ - getEnvironment(): void; + getEnvironment(): string; /** * return the logging level for the current script execution. Not supported in CLIENT scripts @@ -4233,6 +4290,10 @@ declare interface nlobjError { getInternalId(): any; } +declare class nlobjError { + constructor (name:string, join?:string, summary?:string); +} + /** * Return a new instance of nlobjServerResponse.. * @@ -4310,7 +4371,7 @@ declare interface nlobjServerResponse { * @since 2008.1 * @return */ - getCode(): any; + getCode(): string; /** * return the response body returned. @@ -4322,7 +4383,7 @@ declare interface nlobjServerResponse { * @since 2008.1 * @return */ - getBody(): string; + getBody(): any; /** * return the nlobjError thrown via a client call to nlapiRequestURL. @@ -4352,6 +4413,8 @@ declare interface nlobjResponse { */ new (): any; + getBody(): any; + /** * add a value for a response header. * @param {string} name of header @@ -4450,7 +4513,7 @@ declare interface nlobjResponse { * @param disposition * @return */ - setContentType(type:string, filename:string, disposition:string): any; + setContentType(type:string, name?:string, disposition?:string): void; /** * sets the redirect URL for the response. all URLs must be internal unless the Suitelet is being executed in an "Available without Login" context @@ -4473,7 +4536,7 @@ declare interface nlobjResponse { * @param parameters? * @return */ - sendRedirect(type:string, subtype:string, id?:string, pagemode?:string, parameters?:any): any; + sendRedirect(type:string, subtype:string, id?:string|number, pagemode?:boolean, parameters?:any): any; /** * write information (text/xml/html) to the response. @@ -4529,6 +4592,8 @@ declare interface nlobjResponse { * @return */ setEncoding(encoding:string): any; + + getCode():string; } /** @@ -4654,7 +4719,7 @@ declare interface nlobjRequest { * @param name * @return */ - getFile(name:string): () => void; + getFile(name:string): nlobjFile; /** * return an Object containing field names to file objects for all uploaded files. @@ -4677,7 +4742,7 @@ declare interface nlobjRequest { * @since 2008.1 * @return */ - getBody(): string; + getBody(): any; /** * return the URL of the request @@ -5616,7 +5681,7 @@ declare interface nlobjAssistant { * * @since 2009.2 */ - getAllFields(): void; + getAllFields(): string[]; /** * return an array of the names of all sublists on this page . @@ -6106,7 +6171,7 @@ declare interface nlobjSubList { * @since 2010.1 * @param group */ - getLineItemCount(group:string): void; + getLineItemCount(group:string): any; /** * add a field (column) to this sublist. @@ -6368,7 +6433,7 @@ declare interface nlobjAssistantStep { * @since 2009.2 * @param name */ - getFieldValues(name:string): void; + getFieldValues(name:string): string[]; /** * return the number of lines previously entered by the user in this step (or -1 if the sublist does not exist). @@ -6411,7 +6476,7 @@ declare interface nlobjAssistantStep { * * @since 2009.2 */ - getAllFields(): void; + getAllFields(): string[]; /** * return an array of the names of all sublists entered by the user during this step. From 1043225508dbad61cc67fa92ef6ed362e724609c Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 02:10:13 +0200 Subject: [PATCH 11/67] WIA Typescript definitions Windows Image Acquisitions --- activex/jscript-extensions.d.ts | 6 + ...crosoft-windows-image-acquisition-tests.ts | 73 ++++ .../microsoft-windows-image-acquisition.d.ts | 380 ++++++++++++++++++ 3 files changed, 459 insertions(+) create mode 100644 activex/jscript-extensions.d.ts create mode 100644 activex/microsoft-windows-image-acquisition-tests.ts create mode 100644 activex/microsoft-windows-image-acquisition.d.ts diff --git a/activex/jscript-extensions.d.ts b/activex/jscript-extensions.d.ts new file mode 100644 index 0000000000..b156983ff1 --- /dev/null +++ b/activex/jscript-extensions.d.ts @@ -0,0 +1,6 @@ +interface VarDate { } + +interface DateConstructor { + new (vd: VarDate): Date; + getVarDate: () => VarDate; +} \ No newline at end of file diff --git a/activex/microsoft-windows-image-acquisition-tests.ts b/activex/microsoft-windows-image-acquisition-tests.ts new file mode 100644 index 0000000000..66a9d75a7d --- /dev/null +++ b/activex/microsoft-windows-image-acquisition-tests.ts @@ -0,0 +1,73 @@ +/// + +//source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx + + +//Convert a file +var commonDialog = new ActiveXObject('WIA.CommonDialog'); +var img = commonDialog.ShowAcquireImage(); +if (img.FormatID != WIA.FormatID.wiaFormatJPEG) { + var ip = new ActiveXObject('WIA.ImageProcess'); + ip.Filters.Add(ip.FilterInfos.Item('Convert').FilterID); + ip.Filters.Item(1).Properties.Item("FormatID").Value = WIA.FormatID.wiaFormatJPEG; + img = ip.Apply(img); +} + + +//Take a picture +var dev = commonDialog.ShowSelectDevice(); +if (dev.Type == WIA.WiaDeviceType.CameraDeviceType) { + var itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture); +} + + +//Display detailed property information +dev = commonDialog.ShowSelectDevice(); +var e = new Enumerator(dev.Properties); //no foreach over ActiveX collections +e.moveFirst(); +while (!e.atEnd()) { + var p = e.item(); + var s = p.Name + ' (' + p.PropertyID + ') = '; + if (p.IsVector) { + s += '[vector of data]'; + } else { + s += p.Value; + if (p.SubType != WIA.WiaSubType.UnspecifiedSubType) { + if (p.Value != p.SubTypeDefault) { + s += ' (Default = ' + p.SubTypeDefault + ')'; + } + } + } + + if (p.IsReadOnly) { + s += ' [READ ONLY]'; + } else { + switch (p.SubType) { + case WIA.WiaSubType.FlagSubType: + case WIA.WiaSubType.ListSubType: + if (p.SubType == WIA.WiaSubType.FlagSubType) { + s += ' [valid flags include: '; + } else { + s += ' [valid values include: '; + } + var count = p.SubTypeValues.Count; + for (var i = 1; i <= count; i++) { + s += p.SubTypeValues.Item(i); + if (i < count) { + s += ', '; + } + } + s += ']'; + break; + case WIA.WiaSubType.RangeSubType: + s += ' [valid values in the range from ' + p.SubTypeMin + ' to ' + p.SubTypeMax + ' in increments of ' + p.SubTypeStep + ']'; + break; + } + } + + if (WScript) { + WScript.Echo(s); + } else if (window) { + window.alert(s); + } +} \ No newline at end of file diff --git a/activex/microsoft-windows-image-acquisition.d.ts b/activex/microsoft-windows-image-acquisition.d.ts new file mode 100644 index 0000000000..c35bb416df --- /dev/null +++ b/activex/microsoft-windows-image-acquisition.d.ts @@ -0,0 +1,380 @@ +// Type definitions for Microsoft Windows Image Acquisition +// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms630827(v=vs.85).aspx +// Definitions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace WIA { + + //Enums + type CommandID = + "{04E725B0-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandChangeDocument + | "{E208C170-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandDeleteAllItems + | "{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandSynchronize + | "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandTakePicture + | "{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandUnloadDocument + const CommandID: { + wiaCommandChangeDocument: CommandID, + wiaCommandDeleteAllItems: CommandID, + wiaCommandSynchronize: CommandID, + wiaCommandTakePicture: CommandID, + wiaCommandUnloadDocument: CommandID + } + + type EventID = + "{A28BBADE-64B6-11D2-A231-00C04FA31809}" //wiaEventDeviceConnected + | "{143E4E83-6497-11D2-A231-00C04FA31809}" //wiaEventDeviceDisconnected + | "{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemCreated + | "{1D22A559-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemDeleted + | "{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}" //wiaEventScanEmailImage + | "{C00EB793-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanFaxImage + | "{9B2B662C-6185-438C-B68B-E39EE25E71CB}" //wiaEventScanFilmImage + | "{A6C5A715-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanImage + | "{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}" //wiaEventScanImage2 + | "{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}" //wiaEventScanImage3 + | "{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}" //wiaEventScanImage4 + | "{9D095B89-37D6-4877-AFED-62A297DC6DBE}" //wiaEventScanOCRImage + | "{B441F425-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanPrintImage + const EventID: { + wiaEventDeviceConnected: EventID, + wiaEventDeviceDisconnected: EventID, + wiaEventItemCreated: EventID, + wiaEventItemDeleted: EventID, + wiaEventScanEmailImage: EventID, + wiaEventScanFaxImage: EventID, + wiaEventScanFilmImage: EventID, + wiaEventScanImage: EventID, + wiaEventScanImage2: EventID, + wiaEventScanImage3: EventID, + wiaEventScanImage4: EventID, + wiaEventScanOCRImage: EventID, + wiaEventScanPrintImage: EventID + } + + type FormatID = + "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatBMP + | "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatGIF + | "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatJPEG + | "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatPNG + | "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatTIFF + const FormatID: { + wiaFormatBMP: FormatID, + wiaFormatGIF: FormatID, + wiaFormatJPEG: FormatID, + wiaFormatPNG: FormatID, + wiaFormatTIFF: FormatID + } + + type Miscellaneous = + "*" //wiaAnyDeviceID + | "{00000000-0000-0000-0000-000000000000}" //wiaIDUnknown + const Miscellaneous: { + wiaAnyDeviceID: Miscellaneous, + wiaIDUnknown: Miscellaneous + } + + const enum WiaDeviceType { + CameraDeviceType = 2, + ScannerDeviceType = 1, + UnspecifiedDeviceType = 0, + VideoDeviceType = 3 + } + + const enum WiaEventFlag { + ActionEvent = 2, + NotificationEvent = 1 + } + + const enum WiaImageBias { + MaximizeQuality = 131072, + MinimizeSize = 65536 + } + + const enum WiaImageIntent { + ColorIntent = 1, + GrayscaleIntent = 2, + TextIntent = 4, + UnspecifiedIntent = 0 + } + + const enum WiaImagePropertyType { + ByteImagePropertyType = 1001, + LongImagePropertyType = 1004, + RationalImagePropertyType = 1006, + StringImagePropertyType = 1002, + UndefinedImagePropertyType = 1000, + UnsignedIntegerImagePropertyType = 1003, + UnsignedLongImagePropertyType = 1005, + UnsignedRationalImagePropertyType = 1007, + VectorOfBytesImagePropertyType = 1101, + VectorOfLongsImagePropertyType = 1103, + VectorOfRationalsImagePropertyType = 1105, + VectorOfUndefinedImagePropertyType = 1100, + VectorOfUnsignedIntegersImagePropertyType = 1102, + VectorOfUnsignedLongsImagePropertyType = 1104, + VectorOfUnsignedRationalsImagePropertyType = 1106 + } + + const enum WiaItemFlag { + AnalyzeItemFlag = 16, + AudioItemFlag = 32, + BurstItemFlag = 2048, + DeletedItemFlag = 128, + DeviceItemFlag = 64, + DisconnectedItemFlag = 256, + FileItemFlag = 2, + FolderItemFlag = 4, + FreeItemFlag = 0, + GeneratedItemFlag = 16384, + HasAttachmentsItemFlag = 32768, + HPanoramaItemFlag = 512, + ImageItemFlag = 1, + RemovedItemFlag = -2147483648, + RootItemFlag = 8, + StorageItemFlag = 4096, + TransferItemFlag = 8192, + VideoItemFlag = 65536, + VPanoramaItemFlag = 1024 + } + + const enum WiaPropertyType { + BooleanPropertyType = 1, + BytePropertyType = 2, + ClassIDPropertyType = 15, + CurrencyPropertyType = 12, + DatePropertyType = 13, + DoublePropertyType = 11, + ErrorCodePropertyType = 7, + FileTimePropertyType = 14, + HandlePropertyType = 18, + IntegerPropertyType = 3, + LargeIntegerPropertyType = 8, + LongPropertyType = 5, + ObjectPropertyType = 17, + SinglePropertyType = 10, + StringPropertyType = 16, + UnsignedIntegerPropertyType = 4, + UnsignedLargeIntegerPropertyType = 9, + UnsignedLongPropertyType = 6, + UnsupportedPropertyType = 0, + VariantPropertyType = 19, + VectorOfBooleansPropertyType = 101, + VectorOfBytesPropertyType = 102, + VectorOfClassIDsPropertyType = 115, + VectorOfCurrenciesPropertyType = 112, + VectorOfDatesPropertyType = 113, + VectorOfDoublesPropertyType = 111, + VectorOfErrorCodesPropertyType = 107, + VectorOfFileTimesPropertyType = 114, + VectorOfIntegersPropertyType = 103, + VectorOfLargeIntegersPropertyType = 108, + VectorOfLongsPropertyType = 105, + VectorOfSinglesPropertyType = 110, + VectorOfStringsPropertyType = 116, + VectorOfUnsignedIntegersPropertyType = 104, + VectorOfUnsignedLargeIntegersPropertyType = 109, + VectorOfUnsignedLongsPropertyType = 106, + VectorOfVariantsPropertyType = 119 + } + + const enum WiaSubType { + FlagSubType = 3, + ListSubType = 2, + RangeSubType = 1, + UnspecifiedSubType = 0 + } + + //Classes + interface CommonDialog { + ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile + ShowAcquisitionWizard: (Device: Device) => any + ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void + ShowItemProperties: (Item: Item, CancelError?: boolean) => void + ShowPhotoPrintingWizard: (Files: any) => void + ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device + ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items + ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any + } + + interface Device { + Commands: DeviceCommands + DeviceID: string + Events: DeviceEvents + ExecuteCommand: (CommandID: string) => Item + GetItem: (ItemID: string) => Item + Items: Items + Properties: Properties + Type: WiaDeviceType + WiaItem: any /*VT_UNKNOWN*/ + } + + interface DeviceCommand { + CommandID: string + Description: string + Name: string + } + + interface DeviceCommands { + Count: number + Item: (Index: number) => DeviceCommand + } + + interface DeviceEvent { + Description: string + EventID: string + Name: string + Type: WiaEventFlag + } + + interface DeviceEvents { + Count: number + Item: (Index: number) => DeviceEvent + } + + interface DeviceInfo { + Connect: Device + DeviceID: string + Properties: Properties + Type: WiaDeviceType + } + + interface DeviceInfos { + Count: number + Item: (Index: any) => DeviceInfo + } + + interface DeviceManager { + DeviceInfos: DeviceInfos + RegisterEvent: (EventID: string, DeviceID?: string) => void + RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + UnregisterEvent: (EventID: string, DeviceID?: string) => void + UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + } + + interface Filter { + Description: string + FilterID: string + Name: string + Properties: Properties + } + + interface FilterInfo { + Description: string + FilterID: string + Name: string + } + + interface FilterInfos { + Count: number + Item: (Index: any) => FilterInfo + } + + interface Filters { + Add: (FilterID: string, Index?: number) => void + Count: number + Item: (Index: number) => Filter + Remove: (Index: number) => void + } + + interface Formats { + Count: number + Item: (Index: number) => string + } + + interface ImageFile { + ActiveFrame: number + ARGBData: Vector + FileData: Vector + FileExtension: string + FormatID: string + FrameCount: number + Height: number + HorizontalResolution: number + IsAlphaPixelFormat: boolean + IsAnimated: boolean + IsExtendedPixelFormat: boolean + IsIndexedPixelFormat: boolean + LoadFile: (Filename: string) => void + PixelDepth: number + Properties: Properties + SaveFile: (Filename: string) => void + VerticalResolution: number + Width: number + } + + interface ImageProcess { + Apply: (Source: ImageFile) => ImageFile + FilterInfos: FilterInfos + Filters: Filters + } + + interface Item { + Commands: DeviceCommands + ExecuteCommand: (CommandID: string) => Item + Formats: Formats + ItemID: string + Items: Items + Properties: Properties + Transfer: (FormatID?: string) => any + WiaItem: any /*VT_UNKNOWN*/ + } + + interface Items { + Add: (Name: string, Flags: number) => void + Count: number + Item: (Index: number) => Item + Remove: (Index: number) => void + } + + interface Properties { + Count: number + Exists: (Index: any) => boolean + Item: (Index: any) => Property + } + + interface Property { + IsReadOnly: boolean + IsVector: boolean + Name: string + PropertyID: number + SubType: WiaSubType + SubTypeDefault: any + SubTypeMax: number + SubTypeMin: number + SubTypeStep: number + SubTypeValues: Vector + Type: number + Value: any + } + + interface Rational { + Denominator: number + Numerator: number + Value: number + } + + interface Vector { + Add: (Value: any, Index?: number) => void + BinaryData: any + Clear: void + Count: number + Date: VarDate + ImageFile: (Width?: number, Height?: number) => ImageFile + Item: (Index: number) => any //Also has setter with parameters + Picture: (Width?: number, Height?: number) => any + Remove: (Index: number) => any + SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void + String: (Unicode?: boolean) => string + } + +} + +interface ActiveXObject { + new (progID: 'WIA.Rational'): WIA.Rational; + new (progID: 'WIA.Vector'): WIA.Vector; + new (progID: 'WIA.ImageFile'): WIA.ImageFile; + new (progID: 'WIA.ImageProcess'): WIA.ImageProcess; + new (progID: 'WIA.CommonDialog'): WIA.CommonDialog; + new (progID: 'WIA.DeviceManager'): WIA.DeviceManager; +} From d14f5d484f51cce942c4ec6cd13c611e89553f3c Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 02:41:40 +0200 Subject: [PATCH 12/67] WIA Typescript definitions --- ts-activex/jscript-extensions.d.ts | 16 + ts-activex/jscript-extensions.tests.ts | 5 + ...crosoft-windows-image-acquisition-tests.ts | 73 ++++ .../microsoft-windows-image-acquisition.d.ts | 380 ++++++++++++++++++ 4 files changed, 474 insertions(+) create mode 100644 ts-activex/jscript-extensions.d.ts create mode 100644 ts-activex/jscript-extensions.tests.ts create mode 100644 ts-activex/microsoft-windows-image-acquisition-tests.ts create mode 100644 ts-activex/microsoft-windows-image-acquisition.d.ts diff --git a/ts-activex/jscript-extensions.d.ts b/ts-activex/jscript-extensions.d.ts new file mode 100644 index 0000000000..b7291366bf --- /dev/null +++ b/ts-activex/jscript-extensions.d.ts @@ -0,0 +1,16 @@ +// Type definitions for Microsoft JScript extensions +// Project: https://msdn.microsoft.com/en-us/library/yek4tbz0(v=vs.84).aspx +// Definitions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +//These will become unnecessary with the next version of Typescript + +interface VarDate { } + +interface DateConstructor { + new (vd: VarDate): Date; +} + +interface Date { + getVarDate: () => VarDate; +} \ No newline at end of file diff --git a/ts-activex/jscript-extensions.tests.ts b/ts-activex/jscript-extensions.tests.ts new file mode 100644 index 0000000000..1e4fa6a41d --- /dev/null +++ b/ts-activex/jscript-extensions.tests.ts @@ -0,0 +1,5 @@ +/// + +var x: VarDate; +var dte = new Date(x); +x = dte.getVarDate(); \ No newline at end of file diff --git a/ts-activex/microsoft-windows-image-acquisition-tests.ts b/ts-activex/microsoft-windows-image-acquisition-tests.ts new file mode 100644 index 0000000000..66a9d75a7d --- /dev/null +++ b/ts-activex/microsoft-windows-image-acquisition-tests.ts @@ -0,0 +1,73 @@ +/// + +//source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx + + +//Convert a file +var commonDialog = new ActiveXObject('WIA.CommonDialog'); +var img = commonDialog.ShowAcquireImage(); +if (img.FormatID != WIA.FormatID.wiaFormatJPEG) { + var ip = new ActiveXObject('WIA.ImageProcess'); + ip.Filters.Add(ip.FilterInfos.Item('Convert').FilterID); + ip.Filters.Item(1).Properties.Item("FormatID").Value = WIA.FormatID.wiaFormatJPEG; + img = ip.Apply(img); +} + + +//Take a picture +var dev = commonDialog.ShowSelectDevice(); +if (dev.Type == WIA.WiaDeviceType.CameraDeviceType) { + var itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture); +} + + +//Display detailed property information +dev = commonDialog.ShowSelectDevice(); +var e = new Enumerator(dev.Properties); //no foreach over ActiveX collections +e.moveFirst(); +while (!e.atEnd()) { + var p = e.item(); + var s = p.Name + ' (' + p.PropertyID + ') = '; + if (p.IsVector) { + s += '[vector of data]'; + } else { + s += p.Value; + if (p.SubType != WIA.WiaSubType.UnspecifiedSubType) { + if (p.Value != p.SubTypeDefault) { + s += ' (Default = ' + p.SubTypeDefault + ')'; + } + } + } + + if (p.IsReadOnly) { + s += ' [READ ONLY]'; + } else { + switch (p.SubType) { + case WIA.WiaSubType.FlagSubType: + case WIA.WiaSubType.ListSubType: + if (p.SubType == WIA.WiaSubType.FlagSubType) { + s += ' [valid flags include: '; + } else { + s += ' [valid values include: '; + } + var count = p.SubTypeValues.Count; + for (var i = 1; i <= count; i++) { + s += p.SubTypeValues.Item(i); + if (i < count) { + s += ', '; + } + } + s += ']'; + break; + case WIA.WiaSubType.RangeSubType: + s += ' [valid values in the range from ' + p.SubTypeMin + ' to ' + p.SubTypeMax + ' in increments of ' + p.SubTypeStep + ']'; + break; + } + } + + if (WScript) { + WScript.Echo(s); + } else if (window) { + window.alert(s); + } +} \ No newline at end of file diff --git a/ts-activex/microsoft-windows-image-acquisition.d.ts b/ts-activex/microsoft-windows-image-acquisition.d.ts new file mode 100644 index 0000000000..c35bb416df --- /dev/null +++ b/ts-activex/microsoft-windows-image-acquisition.d.ts @@ -0,0 +1,380 @@ +// Type definitions for Microsoft Windows Image Acquisition +// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms630827(v=vs.85).aspx +// Definitions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace WIA { + + //Enums + type CommandID = + "{04E725B0-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandChangeDocument + | "{E208C170-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandDeleteAllItems + | "{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandSynchronize + | "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandTakePicture + | "{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandUnloadDocument + const CommandID: { + wiaCommandChangeDocument: CommandID, + wiaCommandDeleteAllItems: CommandID, + wiaCommandSynchronize: CommandID, + wiaCommandTakePicture: CommandID, + wiaCommandUnloadDocument: CommandID + } + + type EventID = + "{A28BBADE-64B6-11D2-A231-00C04FA31809}" //wiaEventDeviceConnected + | "{143E4E83-6497-11D2-A231-00C04FA31809}" //wiaEventDeviceDisconnected + | "{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemCreated + | "{1D22A559-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemDeleted + | "{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}" //wiaEventScanEmailImage + | "{C00EB793-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanFaxImage + | "{9B2B662C-6185-438C-B68B-E39EE25E71CB}" //wiaEventScanFilmImage + | "{A6C5A715-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanImage + | "{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}" //wiaEventScanImage2 + | "{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}" //wiaEventScanImage3 + | "{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}" //wiaEventScanImage4 + | "{9D095B89-37D6-4877-AFED-62A297DC6DBE}" //wiaEventScanOCRImage + | "{B441F425-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanPrintImage + const EventID: { + wiaEventDeviceConnected: EventID, + wiaEventDeviceDisconnected: EventID, + wiaEventItemCreated: EventID, + wiaEventItemDeleted: EventID, + wiaEventScanEmailImage: EventID, + wiaEventScanFaxImage: EventID, + wiaEventScanFilmImage: EventID, + wiaEventScanImage: EventID, + wiaEventScanImage2: EventID, + wiaEventScanImage3: EventID, + wiaEventScanImage4: EventID, + wiaEventScanOCRImage: EventID, + wiaEventScanPrintImage: EventID + } + + type FormatID = + "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatBMP + | "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatGIF + | "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatJPEG + | "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatPNG + | "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatTIFF + const FormatID: { + wiaFormatBMP: FormatID, + wiaFormatGIF: FormatID, + wiaFormatJPEG: FormatID, + wiaFormatPNG: FormatID, + wiaFormatTIFF: FormatID + } + + type Miscellaneous = + "*" //wiaAnyDeviceID + | "{00000000-0000-0000-0000-000000000000}" //wiaIDUnknown + const Miscellaneous: { + wiaAnyDeviceID: Miscellaneous, + wiaIDUnknown: Miscellaneous + } + + const enum WiaDeviceType { + CameraDeviceType = 2, + ScannerDeviceType = 1, + UnspecifiedDeviceType = 0, + VideoDeviceType = 3 + } + + const enum WiaEventFlag { + ActionEvent = 2, + NotificationEvent = 1 + } + + const enum WiaImageBias { + MaximizeQuality = 131072, + MinimizeSize = 65536 + } + + const enum WiaImageIntent { + ColorIntent = 1, + GrayscaleIntent = 2, + TextIntent = 4, + UnspecifiedIntent = 0 + } + + const enum WiaImagePropertyType { + ByteImagePropertyType = 1001, + LongImagePropertyType = 1004, + RationalImagePropertyType = 1006, + StringImagePropertyType = 1002, + UndefinedImagePropertyType = 1000, + UnsignedIntegerImagePropertyType = 1003, + UnsignedLongImagePropertyType = 1005, + UnsignedRationalImagePropertyType = 1007, + VectorOfBytesImagePropertyType = 1101, + VectorOfLongsImagePropertyType = 1103, + VectorOfRationalsImagePropertyType = 1105, + VectorOfUndefinedImagePropertyType = 1100, + VectorOfUnsignedIntegersImagePropertyType = 1102, + VectorOfUnsignedLongsImagePropertyType = 1104, + VectorOfUnsignedRationalsImagePropertyType = 1106 + } + + const enum WiaItemFlag { + AnalyzeItemFlag = 16, + AudioItemFlag = 32, + BurstItemFlag = 2048, + DeletedItemFlag = 128, + DeviceItemFlag = 64, + DisconnectedItemFlag = 256, + FileItemFlag = 2, + FolderItemFlag = 4, + FreeItemFlag = 0, + GeneratedItemFlag = 16384, + HasAttachmentsItemFlag = 32768, + HPanoramaItemFlag = 512, + ImageItemFlag = 1, + RemovedItemFlag = -2147483648, + RootItemFlag = 8, + StorageItemFlag = 4096, + TransferItemFlag = 8192, + VideoItemFlag = 65536, + VPanoramaItemFlag = 1024 + } + + const enum WiaPropertyType { + BooleanPropertyType = 1, + BytePropertyType = 2, + ClassIDPropertyType = 15, + CurrencyPropertyType = 12, + DatePropertyType = 13, + DoublePropertyType = 11, + ErrorCodePropertyType = 7, + FileTimePropertyType = 14, + HandlePropertyType = 18, + IntegerPropertyType = 3, + LargeIntegerPropertyType = 8, + LongPropertyType = 5, + ObjectPropertyType = 17, + SinglePropertyType = 10, + StringPropertyType = 16, + UnsignedIntegerPropertyType = 4, + UnsignedLargeIntegerPropertyType = 9, + UnsignedLongPropertyType = 6, + UnsupportedPropertyType = 0, + VariantPropertyType = 19, + VectorOfBooleansPropertyType = 101, + VectorOfBytesPropertyType = 102, + VectorOfClassIDsPropertyType = 115, + VectorOfCurrenciesPropertyType = 112, + VectorOfDatesPropertyType = 113, + VectorOfDoublesPropertyType = 111, + VectorOfErrorCodesPropertyType = 107, + VectorOfFileTimesPropertyType = 114, + VectorOfIntegersPropertyType = 103, + VectorOfLargeIntegersPropertyType = 108, + VectorOfLongsPropertyType = 105, + VectorOfSinglesPropertyType = 110, + VectorOfStringsPropertyType = 116, + VectorOfUnsignedIntegersPropertyType = 104, + VectorOfUnsignedLargeIntegersPropertyType = 109, + VectorOfUnsignedLongsPropertyType = 106, + VectorOfVariantsPropertyType = 119 + } + + const enum WiaSubType { + FlagSubType = 3, + ListSubType = 2, + RangeSubType = 1, + UnspecifiedSubType = 0 + } + + //Classes + interface CommonDialog { + ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile + ShowAcquisitionWizard: (Device: Device) => any + ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void + ShowItemProperties: (Item: Item, CancelError?: boolean) => void + ShowPhotoPrintingWizard: (Files: any) => void + ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device + ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items + ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any + } + + interface Device { + Commands: DeviceCommands + DeviceID: string + Events: DeviceEvents + ExecuteCommand: (CommandID: string) => Item + GetItem: (ItemID: string) => Item + Items: Items + Properties: Properties + Type: WiaDeviceType + WiaItem: any /*VT_UNKNOWN*/ + } + + interface DeviceCommand { + CommandID: string + Description: string + Name: string + } + + interface DeviceCommands { + Count: number + Item: (Index: number) => DeviceCommand + } + + interface DeviceEvent { + Description: string + EventID: string + Name: string + Type: WiaEventFlag + } + + interface DeviceEvents { + Count: number + Item: (Index: number) => DeviceEvent + } + + interface DeviceInfo { + Connect: Device + DeviceID: string + Properties: Properties + Type: WiaDeviceType + } + + interface DeviceInfos { + Count: number + Item: (Index: any) => DeviceInfo + } + + interface DeviceManager { + DeviceInfos: DeviceInfos + RegisterEvent: (EventID: string, DeviceID?: string) => void + RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + UnregisterEvent: (EventID: string, DeviceID?: string) => void + UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + } + + interface Filter { + Description: string + FilterID: string + Name: string + Properties: Properties + } + + interface FilterInfo { + Description: string + FilterID: string + Name: string + } + + interface FilterInfos { + Count: number + Item: (Index: any) => FilterInfo + } + + interface Filters { + Add: (FilterID: string, Index?: number) => void + Count: number + Item: (Index: number) => Filter + Remove: (Index: number) => void + } + + interface Formats { + Count: number + Item: (Index: number) => string + } + + interface ImageFile { + ActiveFrame: number + ARGBData: Vector + FileData: Vector + FileExtension: string + FormatID: string + FrameCount: number + Height: number + HorizontalResolution: number + IsAlphaPixelFormat: boolean + IsAnimated: boolean + IsExtendedPixelFormat: boolean + IsIndexedPixelFormat: boolean + LoadFile: (Filename: string) => void + PixelDepth: number + Properties: Properties + SaveFile: (Filename: string) => void + VerticalResolution: number + Width: number + } + + interface ImageProcess { + Apply: (Source: ImageFile) => ImageFile + FilterInfos: FilterInfos + Filters: Filters + } + + interface Item { + Commands: DeviceCommands + ExecuteCommand: (CommandID: string) => Item + Formats: Formats + ItemID: string + Items: Items + Properties: Properties + Transfer: (FormatID?: string) => any + WiaItem: any /*VT_UNKNOWN*/ + } + + interface Items { + Add: (Name: string, Flags: number) => void + Count: number + Item: (Index: number) => Item + Remove: (Index: number) => void + } + + interface Properties { + Count: number + Exists: (Index: any) => boolean + Item: (Index: any) => Property + } + + interface Property { + IsReadOnly: boolean + IsVector: boolean + Name: string + PropertyID: number + SubType: WiaSubType + SubTypeDefault: any + SubTypeMax: number + SubTypeMin: number + SubTypeStep: number + SubTypeValues: Vector + Type: number + Value: any + } + + interface Rational { + Denominator: number + Numerator: number + Value: number + } + + interface Vector { + Add: (Value: any, Index?: number) => void + BinaryData: any + Clear: void + Count: number + Date: VarDate + ImageFile: (Width?: number, Height?: number) => ImageFile + Item: (Index: number) => any //Also has setter with parameters + Picture: (Width?: number, Height?: number) => any + Remove: (Index: number) => any + SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void + String: (Unicode?: boolean) => string + } + +} + +interface ActiveXObject { + new (progID: 'WIA.Rational'): WIA.Rational; + new (progID: 'WIA.Vector'): WIA.Vector; + new (progID: 'WIA.ImageFile'): WIA.ImageFile; + new (progID: 'WIA.ImageProcess'): WIA.ImageProcess; + new (progID: 'WIA.CommonDialog'): WIA.CommonDialog; + new (progID: 'WIA.DeviceManager'): WIA.DeviceManager; +} From 1ae946ae466acb2a6f5695980ec68fe4102326a1 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 02:42:37 +0200 Subject: [PATCH 13/67] Revert "WIA Typescript definitions" This reverts commit 1043225508dbad61cc67fa92ef6ed362e724609c. --- activex/jscript-extensions.d.ts | 6 - ...crosoft-windows-image-acquisition-tests.ts | 73 ---- .../microsoft-windows-image-acquisition.d.ts | 380 ------------------ 3 files changed, 459 deletions(-) delete mode 100644 activex/jscript-extensions.d.ts delete mode 100644 activex/microsoft-windows-image-acquisition-tests.ts delete mode 100644 activex/microsoft-windows-image-acquisition.d.ts diff --git a/activex/jscript-extensions.d.ts b/activex/jscript-extensions.d.ts deleted file mode 100644 index b156983ff1..0000000000 --- a/activex/jscript-extensions.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -interface VarDate { } - -interface DateConstructor { - new (vd: VarDate): Date; - getVarDate: () => VarDate; -} \ No newline at end of file diff --git a/activex/microsoft-windows-image-acquisition-tests.ts b/activex/microsoft-windows-image-acquisition-tests.ts deleted file mode 100644 index 66a9d75a7d..0000000000 --- a/activex/microsoft-windows-image-acquisition-tests.ts +++ /dev/null @@ -1,73 +0,0 @@ -/// - -//source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx - - -//Convert a file -var commonDialog = new ActiveXObject('WIA.CommonDialog'); -var img = commonDialog.ShowAcquireImage(); -if (img.FormatID != WIA.FormatID.wiaFormatJPEG) { - var ip = new ActiveXObject('WIA.ImageProcess'); - ip.Filters.Add(ip.FilterInfos.Item('Convert').FilterID); - ip.Filters.Item(1).Properties.Item("FormatID").Value = WIA.FormatID.wiaFormatJPEG; - img = ip.Apply(img); -} - - -//Take a picture -var dev = commonDialog.ShowSelectDevice(); -if (dev.Type == WIA.WiaDeviceType.CameraDeviceType) { - var itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture); -} - - -//Display detailed property information -dev = commonDialog.ShowSelectDevice(); -var e = new Enumerator(dev.Properties); //no foreach over ActiveX collections -e.moveFirst(); -while (!e.atEnd()) { - var p = e.item(); - var s = p.Name + ' (' + p.PropertyID + ') = '; - if (p.IsVector) { - s += '[vector of data]'; - } else { - s += p.Value; - if (p.SubType != WIA.WiaSubType.UnspecifiedSubType) { - if (p.Value != p.SubTypeDefault) { - s += ' (Default = ' + p.SubTypeDefault + ')'; - } - } - } - - if (p.IsReadOnly) { - s += ' [READ ONLY]'; - } else { - switch (p.SubType) { - case WIA.WiaSubType.FlagSubType: - case WIA.WiaSubType.ListSubType: - if (p.SubType == WIA.WiaSubType.FlagSubType) { - s += ' [valid flags include: '; - } else { - s += ' [valid values include: '; - } - var count = p.SubTypeValues.Count; - for (var i = 1; i <= count; i++) { - s += p.SubTypeValues.Item(i); - if (i < count) { - s += ', '; - } - } - s += ']'; - break; - case WIA.WiaSubType.RangeSubType: - s += ' [valid values in the range from ' + p.SubTypeMin + ' to ' + p.SubTypeMax + ' in increments of ' + p.SubTypeStep + ']'; - break; - } - } - - if (WScript) { - WScript.Echo(s); - } else if (window) { - window.alert(s); - } -} \ No newline at end of file diff --git a/activex/microsoft-windows-image-acquisition.d.ts b/activex/microsoft-windows-image-acquisition.d.ts deleted file mode 100644 index c35bb416df..0000000000 --- a/activex/microsoft-windows-image-acquisition.d.ts +++ /dev/null @@ -1,380 +0,0 @@ -// Type definitions for Microsoft Windows Image Acquisition -// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/ms630827(v=vs.85).aspx -// Definitions by: Zev Spitz -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace WIA { - - //Enums - type CommandID = - "{04E725B0-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandChangeDocument - | "{E208C170-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandDeleteAllItems - | "{9B26B7B2-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandSynchronize - | "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}" //wiaCommandTakePicture - | "{1F3B3D8E-ACAE-11D2-A093-00C04F72DC3C}" //wiaCommandUnloadDocument - const CommandID: { - wiaCommandChangeDocument: CommandID, - wiaCommandDeleteAllItems: CommandID, - wiaCommandSynchronize: CommandID, - wiaCommandTakePicture: CommandID, - wiaCommandUnloadDocument: CommandID - } - - type EventID = - "{A28BBADE-64B6-11D2-A231-00C04FA31809}" //wiaEventDeviceConnected - | "{143E4E83-6497-11D2-A231-00C04FA31809}" //wiaEventDeviceDisconnected - | "{4C8F4EF5-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemCreated - | "{1D22A559-E14F-11D2-B326-00C04F68CE61}" //wiaEventItemDeleted - | "{C686DCEE-54F2-419E-9A27-2FC7F2E98F9E}" //wiaEventScanEmailImage - | "{C00EB793-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanFaxImage - | "{9B2B662C-6185-438C-B68B-E39EE25E71CB}" //wiaEventScanFilmImage - | "{A6C5A715-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanImage - | "{FC4767C1-C8B3-48A2-9CFA-2E90CB3D3590}" //wiaEventScanImage2 - | "{154E27BE-B617-4653-ACC5-0FD7BD4C65CE}" //wiaEventScanImage3 - | "{A65B704A-7F3C-4447-A75D-8A26DFCA1FDF}" //wiaEventScanImage4 - | "{9D095B89-37D6-4877-AFED-62A297DC6DBE}" //wiaEventScanOCRImage - | "{B441F425-8C6E-11D2-977A-0000F87A926F}" //wiaEventScanPrintImage - const EventID: { - wiaEventDeviceConnected: EventID, - wiaEventDeviceDisconnected: EventID, - wiaEventItemCreated: EventID, - wiaEventItemDeleted: EventID, - wiaEventScanEmailImage: EventID, - wiaEventScanFaxImage: EventID, - wiaEventScanFilmImage: EventID, - wiaEventScanImage: EventID, - wiaEventScanImage2: EventID, - wiaEventScanImage3: EventID, - wiaEventScanImage4: EventID, - wiaEventScanOCRImage: EventID, - wiaEventScanPrintImage: EventID - } - - type FormatID = - "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatBMP - | "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatGIF - | "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatJPEG - | "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatPNG - | "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}" //wiaFormatTIFF - const FormatID: { - wiaFormatBMP: FormatID, - wiaFormatGIF: FormatID, - wiaFormatJPEG: FormatID, - wiaFormatPNG: FormatID, - wiaFormatTIFF: FormatID - } - - type Miscellaneous = - "*" //wiaAnyDeviceID - | "{00000000-0000-0000-0000-000000000000}" //wiaIDUnknown - const Miscellaneous: { - wiaAnyDeviceID: Miscellaneous, - wiaIDUnknown: Miscellaneous - } - - const enum WiaDeviceType { - CameraDeviceType = 2, - ScannerDeviceType = 1, - UnspecifiedDeviceType = 0, - VideoDeviceType = 3 - } - - const enum WiaEventFlag { - ActionEvent = 2, - NotificationEvent = 1 - } - - const enum WiaImageBias { - MaximizeQuality = 131072, - MinimizeSize = 65536 - } - - const enum WiaImageIntent { - ColorIntent = 1, - GrayscaleIntent = 2, - TextIntent = 4, - UnspecifiedIntent = 0 - } - - const enum WiaImagePropertyType { - ByteImagePropertyType = 1001, - LongImagePropertyType = 1004, - RationalImagePropertyType = 1006, - StringImagePropertyType = 1002, - UndefinedImagePropertyType = 1000, - UnsignedIntegerImagePropertyType = 1003, - UnsignedLongImagePropertyType = 1005, - UnsignedRationalImagePropertyType = 1007, - VectorOfBytesImagePropertyType = 1101, - VectorOfLongsImagePropertyType = 1103, - VectorOfRationalsImagePropertyType = 1105, - VectorOfUndefinedImagePropertyType = 1100, - VectorOfUnsignedIntegersImagePropertyType = 1102, - VectorOfUnsignedLongsImagePropertyType = 1104, - VectorOfUnsignedRationalsImagePropertyType = 1106 - } - - const enum WiaItemFlag { - AnalyzeItemFlag = 16, - AudioItemFlag = 32, - BurstItemFlag = 2048, - DeletedItemFlag = 128, - DeviceItemFlag = 64, - DisconnectedItemFlag = 256, - FileItemFlag = 2, - FolderItemFlag = 4, - FreeItemFlag = 0, - GeneratedItemFlag = 16384, - HasAttachmentsItemFlag = 32768, - HPanoramaItemFlag = 512, - ImageItemFlag = 1, - RemovedItemFlag = -2147483648, - RootItemFlag = 8, - StorageItemFlag = 4096, - TransferItemFlag = 8192, - VideoItemFlag = 65536, - VPanoramaItemFlag = 1024 - } - - const enum WiaPropertyType { - BooleanPropertyType = 1, - BytePropertyType = 2, - ClassIDPropertyType = 15, - CurrencyPropertyType = 12, - DatePropertyType = 13, - DoublePropertyType = 11, - ErrorCodePropertyType = 7, - FileTimePropertyType = 14, - HandlePropertyType = 18, - IntegerPropertyType = 3, - LargeIntegerPropertyType = 8, - LongPropertyType = 5, - ObjectPropertyType = 17, - SinglePropertyType = 10, - StringPropertyType = 16, - UnsignedIntegerPropertyType = 4, - UnsignedLargeIntegerPropertyType = 9, - UnsignedLongPropertyType = 6, - UnsupportedPropertyType = 0, - VariantPropertyType = 19, - VectorOfBooleansPropertyType = 101, - VectorOfBytesPropertyType = 102, - VectorOfClassIDsPropertyType = 115, - VectorOfCurrenciesPropertyType = 112, - VectorOfDatesPropertyType = 113, - VectorOfDoublesPropertyType = 111, - VectorOfErrorCodesPropertyType = 107, - VectorOfFileTimesPropertyType = 114, - VectorOfIntegersPropertyType = 103, - VectorOfLargeIntegersPropertyType = 108, - VectorOfLongsPropertyType = 105, - VectorOfSinglesPropertyType = 110, - VectorOfStringsPropertyType = 116, - VectorOfUnsignedIntegersPropertyType = 104, - VectorOfUnsignedLargeIntegersPropertyType = 109, - VectorOfUnsignedLongsPropertyType = 106, - VectorOfVariantsPropertyType = 119 - } - - const enum WiaSubType { - FlagSubType = 3, - ListSubType = 2, - RangeSubType = 1, - UnspecifiedSubType = 0 - } - - //Classes - interface CommonDialog { - ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile - ShowAcquisitionWizard: (Device: Device) => any - ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void - ShowItemProperties: (Item: Item, CancelError?: boolean) => void - ShowPhotoPrintingWizard: (Files: any) => void - ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device - ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items - ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any - } - - interface Device { - Commands: DeviceCommands - DeviceID: string - Events: DeviceEvents - ExecuteCommand: (CommandID: string) => Item - GetItem: (ItemID: string) => Item - Items: Items - Properties: Properties - Type: WiaDeviceType - WiaItem: any /*VT_UNKNOWN*/ - } - - interface DeviceCommand { - CommandID: string - Description: string - Name: string - } - - interface DeviceCommands { - Count: number - Item: (Index: number) => DeviceCommand - } - - interface DeviceEvent { - Description: string - EventID: string - Name: string - Type: WiaEventFlag - } - - interface DeviceEvents { - Count: number - Item: (Index: number) => DeviceEvent - } - - interface DeviceInfo { - Connect: Device - DeviceID: string - Properties: Properties - Type: WiaDeviceType - } - - interface DeviceInfos { - Count: number - Item: (Index: any) => DeviceInfo - } - - interface DeviceManager { - DeviceInfos: DeviceInfos - RegisterEvent: (EventID: string, DeviceID?: string) => void - RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void - UnregisterEvent: (EventID: string, DeviceID?: string) => void - UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void - } - - interface Filter { - Description: string - FilterID: string - Name: string - Properties: Properties - } - - interface FilterInfo { - Description: string - FilterID: string - Name: string - } - - interface FilterInfos { - Count: number - Item: (Index: any) => FilterInfo - } - - interface Filters { - Add: (FilterID: string, Index?: number) => void - Count: number - Item: (Index: number) => Filter - Remove: (Index: number) => void - } - - interface Formats { - Count: number - Item: (Index: number) => string - } - - interface ImageFile { - ActiveFrame: number - ARGBData: Vector - FileData: Vector - FileExtension: string - FormatID: string - FrameCount: number - Height: number - HorizontalResolution: number - IsAlphaPixelFormat: boolean - IsAnimated: boolean - IsExtendedPixelFormat: boolean - IsIndexedPixelFormat: boolean - LoadFile: (Filename: string) => void - PixelDepth: number - Properties: Properties - SaveFile: (Filename: string) => void - VerticalResolution: number - Width: number - } - - interface ImageProcess { - Apply: (Source: ImageFile) => ImageFile - FilterInfos: FilterInfos - Filters: Filters - } - - interface Item { - Commands: DeviceCommands - ExecuteCommand: (CommandID: string) => Item - Formats: Formats - ItemID: string - Items: Items - Properties: Properties - Transfer: (FormatID?: string) => any - WiaItem: any /*VT_UNKNOWN*/ - } - - interface Items { - Add: (Name: string, Flags: number) => void - Count: number - Item: (Index: number) => Item - Remove: (Index: number) => void - } - - interface Properties { - Count: number - Exists: (Index: any) => boolean - Item: (Index: any) => Property - } - - interface Property { - IsReadOnly: boolean - IsVector: boolean - Name: string - PropertyID: number - SubType: WiaSubType - SubTypeDefault: any - SubTypeMax: number - SubTypeMin: number - SubTypeStep: number - SubTypeValues: Vector - Type: number - Value: any - } - - interface Rational { - Denominator: number - Numerator: number - Value: number - } - - interface Vector { - Add: (Value: any, Index?: number) => void - BinaryData: any - Clear: void - Count: number - Date: VarDate - ImageFile: (Width?: number, Height?: number) => ImageFile - Item: (Index: number) => any //Also has setter with parameters - Picture: (Width?: number, Height?: number) => any - Remove: (Index: number) => any - SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void - String: (Unicode?: boolean) => string - } - -} - -interface ActiveXObject { - new (progID: 'WIA.Rational'): WIA.Rational; - new (progID: 'WIA.Vector'): WIA.Vector; - new (progID: 'WIA.ImageFile'): WIA.ImageFile; - new (progID: 'WIA.ImageProcess'): WIA.ImageProcess; - new (progID: 'WIA.CommonDialog'): WIA.CommonDialog; - new (progID: 'WIA.DeviceManager'): WIA.DeviceManager; -} From 00e95cc6bb9ebbde03ddefc522e31d768b7bf4b4 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 03:20:45 +0200 Subject: [PATCH 14/67] fix test filename --- ts-activex/jscript-extensions-tests.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 ts-activex/jscript-extensions-tests.ts diff --git a/ts-activex/jscript-extensions-tests.ts b/ts-activex/jscript-extensions-tests.ts new file mode 100644 index 0000000000..1e4fa6a41d --- /dev/null +++ b/ts-activex/jscript-extensions-tests.ts @@ -0,0 +1,5 @@ +/// + +var x: VarDate; +var dte = new Date(x); +x = dte.getVarDate(); \ No newline at end of file From 43449c604f997d75e917769c662e3d3b3fb2c0ae Mon Sep 17 00:00:00 2001 From: Cao Jiannan Date: Wed, 29 Jun 2016 09:46:09 +0800 Subject: [PATCH 15/67] Mongoose - fix post callback (#9850) * fix post function * fix tests --- mongoose/mongoose-tests.ts | 2 +- mongoose/mongoose.d.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mongoose/mongoose-tests.ts b/mongoose/mongoose-tests.ts index cd5f53c4d9..2f6467437c 100644 --- a/mongoose/mongoose-tests.ts +++ b/mongoose/mongoose-tests.ts @@ -369,7 +369,7 @@ schema.path('name'); schema.path('name', Number); schema.pathType('name'); schema.plugin(function() {}); -schema.post('save', function(next: () => void, doc: IActor) {}); +schema.post('save', function(doc: IActor) {}); schema.pre('save', function(next: () => void) {}); schema.requiredPaths(); schema.static('findByName', function(name: string, callback: () => void) {}); diff --git a/mongoose/mongoose.d.ts b/mongoose/mongoose.d.ts index 6d74a0e4b1..7a4d33c522 100644 --- a/mongoose/mongoose.d.ts +++ b/mongoose/mongoose.d.ts @@ -276,8 +276,7 @@ declare module "mongoose" { pre(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema; pre(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema; - post(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema; - post(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema; + post(method: string, fn: (doc: Document, next?: HookNextFunction) => any ): Schema; requiredPaths(): string[]; set(key: string, value: any): void; From 904225af50f930c4095c825382be184ed45bf10c Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 03:57:44 +0200 Subject: [PATCH 16/67] Rename jscript-extensions test file --- ts-activex/jscript-extensions.tests.ts | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 ts-activex/jscript-extensions.tests.ts diff --git a/ts-activex/jscript-extensions.tests.ts b/ts-activex/jscript-extensions.tests.ts deleted file mode 100644 index 1e4fa6a41d..0000000000 --- a/ts-activex/jscript-extensions.tests.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// - -var x: VarDate; -var dte = new Date(x); -x = dte.getVarDate(); \ No newline at end of file From 1a600158484cc6f0ad0cb92feb07e06803746fc3 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 03:58:00 +0200 Subject: [PATCH 17/67] Added semicolons after interface members --- .../microsoft-windows-image-acquisition.d.ts | 232 +++++++++--------- 1 file changed, 116 insertions(+), 116 deletions(-) diff --git a/ts-activex/microsoft-windows-image-acquisition.d.ts b/ts-activex/microsoft-windows-image-acquisition.d.ts index c35bb416df..ccae387346 100644 --- a/ts-activex/microsoft-windows-image-acquisition.d.ts +++ b/ts-activex/microsoft-windows-image-acquisition.d.ts @@ -187,185 +187,185 @@ declare namespace WIA { //Classes interface CommonDialog { - ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile - ShowAcquisitionWizard: (Device: Device) => any - ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void - ShowItemProperties: (Item: Item, CancelError?: boolean) => void - ShowPhotoPrintingWizard: (Files: any) => void - ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device - ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items - ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any + ShowAcquireImage: (DeviceType?: WiaDeviceType, Intent?: WiaImageIntent, Bias?: WiaImageBias, FormatID?: string, AlwaysSelectDevice?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => ImageFile; + ShowAcquisitionWizard: (Device: Device) => any; + ShowDeviceProperties: (Device: Device, CancelError?: boolean) => void; + ShowItemProperties: (Item: Item, CancelError?: boolean) => void; + ShowPhotoPrintingWizard: (Files: any) => void; + ShowSelectDevice: (DeviceType?: WiaDeviceType, AlwaysSelectDevice?: boolean, CancelError?: boolean) => Device; + ShowSelectItems: (Device: Device, Intent?: WiaImageIntent, Bias?: WiaImageBias, SingleSelect?: boolean, UseCommonUI?: boolean, CancelError?: boolean) => Items; + ShowTransfer: (Item: Item, FormatID?: string, CancelError?: boolean) => any; } interface Device { - Commands: DeviceCommands - DeviceID: string - Events: DeviceEvents - ExecuteCommand: (CommandID: string) => Item - GetItem: (ItemID: string) => Item - Items: Items - Properties: Properties - Type: WiaDeviceType - WiaItem: any /*VT_UNKNOWN*/ + Commands: DeviceCommands; + DeviceID: string; + Events: DeviceEvents; + ExecuteCommand: (CommandID: string) => Item; + GetItem: (ItemID: string) => Item; + Items: Items; + Properties: Properties; + Type: WiaDeviceType; + WiaItem: any /*VT_UNKNOWN*/; } interface DeviceCommand { - CommandID: string - Description: string - Name: string + CommandID: string; + Description: string; + Name: string; } interface DeviceCommands { - Count: number - Item: (Index: number) => DeviceCommand + Count: number; + Item: (Index: number) => DeviceCommand; } interface DeviceEvent { - Description: string - EventID: string - Name: string - Type: WiaEventFlag + Description: string; + EventID: string; + Name: string; + Type: WiaEventFlag; } interface DeviceEvents { - Count: number - Item: (Index: number) => DeviceEvent + Count: number; + Item: (Index: number) => DeviceEvent; } interface DeviceInfo { - Connect: Device - DeviceID: string - Properties: Properties - Type: WiaDeviceType + Connect: () => Device; + DeviceID: string; + Properties: Properties; + Type: WiaDeviceType; } interface DeviceInfos { - Count: number - Item: (Index: any) => DeviceInfo + Count: number; + Item: (Index: any) => DeviceInfo; } interface DeviceManager { - DeviceInfos: DeviceInfos - RegisterEvent: (EventID: string, DeviceID?: string) => void - RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void - UnregisterEvent: (EventID: string, DeviceID?: string) => void - UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void + DeviceInfos: DeviceInfos; + RegisterEvent: (EventID: string, DeviceID?: string) => void; + RegisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void; + UnregisterEvent: (EventID: string, DeviceID?: string) => void; + UnregisterPersistentEvent: (Command: string, Name: string, Description: string, Icon: string, EventID: string, DeviceID?: string) => void; } interface Filter { - Description: string - FilterID: string - Name: string - Properties: Properties + Description: string; + FilterID: string; + Name: string; + Properties: Properties; } interface FilterInfo { - Description: string - FilterID: string - Name: string + Description: string; + FilterID: string; + Name: string; } interface FilterInfos { - Count: number - Item: (Index: any) => FilterInfo + Count: number; + Item: (Index: any) => FilterInfo; } interface Filters { - Add: (FilterID: string, Index?: number) => void - Count: number - Item: (Index: number) => Filter - Remove: (Index: number) => void + Add: (FilterID: string, Index?: number) => void; + Count: number; + Item: (Index: number) => Filter; + Remove: (Index: number) => void; } interface Formats { - Count: number - Item: (Index: number) => string + Count: number; + Item: (Index: number) => string; } interface ImageFile { - ActiveFrame: number - ARGBData: Vector - FileData: Vector - FileExtension: string - FormatID: string - FrameCount: number - Height: number - HorizontalResolution: number - IsAlphaPixelFormat: boolean - IsAnimated: boolean - IsExtendedPixelFormat: boolean - IsIndexedPixelFormat: boolean - LoadFile: (Filename: string) => void - PixelDepth: number - Properties: Properties - SaveFile: (Filename: string) => void - VerticalResolution: number - Width: number + ActiveFrame: number; + ARGBData: Vector; + FileData: Vector; + FileExtension: string; + FormatID: string; + FrameCount: number; + Height: number; + HorizontalResolution: number; + IsAlphaPixelFormat: boolean; + IsAnimated: boolean; + IsExtendedPixelFormat: boolean; + IsIndexedPixelFormat: boolean; + LoadFile: (Filename: string) => void; + PixelDepth: number; + Properties: Properties; + SaveFile: (Filename: string) => void; + VerticalResolution: number; + Width: number; } interface ImageProcess { - Apply: (Source: ImageFile) => ImageFile - FilterInfos: FilterInfos - Filters: Filters + Apply: (Source: ImageFile) => ImageFile; + FilterInfos: FilterInfos; + Filters: Filters; } interface Item { - Commands: DeviceCommands - ExecuteCommand: (CommandID: string) => Item - Formats: Formats - ItemID: string - Items: Items - Properties: Properties - Transfer: (FormatID?: string) => any - WiaItem: any /*VT_UNKNOWN*/ + Commands: DeviceCommands; + ExecuteCommand: (CommandID: string) => Item; + Formats: Formats; + ItemID: string; + Items: Items; + Properties: Properties; + Transfer: (FormatID?: string) => any; + WiaItem: any /*VT_UNKNOWN*/; } interface Items { - Add: (Name: string, Flags: number) => void - Count: number - Item: (Index: number) => Item - Remove: (Index: number) => void + Add: (Name: string, Flags: number) => void; + Count: number; + Item: (Index: number) => Item; + Remove: (Index: number) => void; } interface Properties { - Count: number - Exists: (Index: any) => boolean - Item: (Index: any) => Property + Count: number; + Exists: (Index: any) => boolean; + Item: (Index: any) => Property; } interface Property { - IsReadOnly: boolean - IsVector: boolean - Name: string - PropertyID: number - SubType: WiaSubType - SubTypeDefault: any - SubTypeMax: number - SubTypeMin: number - SubTypeStep: number - SubTypeValues: Vector - Type: number - Value: any + IsReadOnly: boolean; + IsVector: boolean; + Name: string; + PropertyID: number; + SubType: WiaSubType; + SubTypeDefault: any; + SubTypeMax: number; + SubTypeMin: number; + SubTypeStep: number; + SubTypeValues: Vector; + Type: number; + Value: any; } interface Rational { - Denominator: number - Numerator: number - Value: number + Denominator: number; + Numerator: number; + Value: number; } interface Vector { - Add: (Value: any, Index?: number) => void - BinaryData: any - Clear: void - Count: number - Date: VarDate - ImageFile: (Width?: number, Height?: number) => ImageFile - Item: (Index: number) => any //Also has setter with parameters - Picture: (Width?: number, Height?: number) => any - Remove: (Index: number) => any - SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void - String: (Unicode?: boolean) => string + Add: (Value: any, Index?: number) => void; + BinaryData: any; + Clear: () => void; + Count: number; + Date: VarDate; + ImageFile: (Width?: number, Height?: number) => ImageFile; + Item: (Index: number) => any //Also has setter with parameters; + Picture: (Width?: number, Height?: number) => any; + Remove: (Index: number) => any; + SetFromString: (Value: string, Resizable?: boolean, Unicode?: boolean) => void; + String: (Unicode?: boolean) => string; } } From 1eb303df579ac8dd4b5b554a6a09ea599bc17414 Mon Sep 17 00:00:00 2001 From: Zev Spitz Date: Wed, 29 Jun 2016 03:58:15 +0200 Subject: [PATCH 18/67] Microsoft Scripting Runtime --- .../microsoft-scripting-runtime-tests.ts | 67 ++++++ ts-activex/microsoft-scripting-runtime.d.ts | 206 ++++++++++++++++++ 2 files changed, 273 insertions(+) create mode 100644 ts-activex/microsoft-scripting-runtime-tests.ts create mode 100644 ts-activex/microsoft-scripting-runtime.d.ts diff --git a/ts-activex/microsoft-scripting-runtime-tests.ts b/ts-activex/microsoft-scripting-runtime-tests.ts new file mode 100644 index 0000000000..623b48368a --- /dev/null +++ b/ts-activex/microsoft-scripting-runtime-tests.ts @@ -0,0 +1,67 @@ +/// + + +//source -- https://msdn.microsoft.com/en-us/library/ebkhfaaz.aspx + + +//Generates a string describing the drive type of a given Drive object. +var showDriveType = (drive: Scripting.Drive) => { + switch (drive.DriveType) { + case Scripting.DriveTypeConst.Removable: + return 'Removeable'; + case Scripting.DriveTypeConst.Fixed: + return 'Fixecd'; + case Scripting.DriveTypeConst.Remote: + return 'Network'; + case Scripting.DriveTypeConst.CDRom: + return 'CD-ROM'; + case Scripting.DriveTypeConst.RamDisk: + return 'RAM Disk'; + default: + return 'Unknown'; + } +}; + + +//Generates a string describing the attributes of a file or folder. +var showFileAttributes = (file: Scripting.File) => { + var attr = file.Attributes; + if (attr == 0) { + return 'Normal'; + } + var attributeStrings: string[] = []; + if (attr & Scripting.FileAttribute.Directory) { attributeStrings.push('Directory'); } + if (attr & Scripting.FileAttribute.ReadOnly) { attributeStrings.push('Read-only'); } + if (attr & Scripting.FileAttribute.Hidden) { attributeStrings.push('Hidden'); } + if (attr & Scripting.FileAttribute.System) { attributeStrings.push('System'); } + if (attr & Scripting.FileAttribute.Volume) { attributeStrings.push('Volume'); } + if (attr & Scripting.FileAttribute.Archive) { attributeStrings.push('Archive'); } + if (attr & Scripting.FileAttribute.Alias) { attributeStrings.push('Alias'); } + if (attr & Scripting.FileAttribute.Compressed) { attributeStrings.push('Compressed'); } + return attributeStrings.join(','); +}; + + +//source --https://msdn.microsoft.com/en-us/library/ts2t8ybh(v=vs.84).aspx +var showFreeSpace = (drvPath: string) => { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var d = fso.GetDrive(fso.GetDriveName(drvPath)); + var s = "Drive " + drvPath + " - "; + s += d.VolumeName + "
"; + s += "Free Space: " + d.FreeSpace / 1024 + " Kbytes"; + return (s); +}; + + +//source -- https://msdn.microsoft.com/en-us/library/kaf6yaft(v=vs.84).aspx +var getALine = (filespec: string) => { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var file = fso.OpenTextFile(filespec, Scripting.IOMode.ForReading, false); + + var s = ""; + while (!file.AtEndOfLine) { + s += file.Read(1); + } + file.Close(); + return (s); +} \ No newline at end of file diff --git a/ts-activex/microsoft-scripting-runtime.d.ts b/ts-activex/microsoft-scripting-runtime.d.ts new file mode 100644 index 0000000000..0f2f734818 --- /dev/null +++ b/ts-activex/microsoft-scripting-runtime.d.ts @@ -0,0 +1,206 @@ +// Type definitions for Microsoft Scripting Runtime +// Project: https://msdn.microsoft.com/en-us/library/bstcxhf7.aspx?f=255&MSPPError=-2147217396 +// Definitions by: Zev Spitz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Scripting { + + //Enums + const enum CompareMethod { + BinaryCompare = 0, + DatabaseCompare = 2, + TextCompare = 1 + } + + const enum DriveTypeConst { + CDRom = 4, + Fixed = 2, + RamDisk = 5, + Remote = 3, + Removable = 1, + UnknownType = 0 + } + + const enum FileAttribute { + Alias = 1024, + Archive = 32, + Compressed = 2048, + Directory = 16, + Hidden = 2, + Normal = 0, + ReadOnly = 1, + System = 4, + Volume = 8 + } + + const enum IOMode { + ForAppending = 8, + ForReading = 1, + ForWriting = 2 + } + + const enum SpecialFolderConst { + SystemFolder = 1, + TemporaryFolder = 2, + WindowsFolder = 0 + } + + const enum StandardStreamTypes { + StdErr = 2, + StdIn = 0, + StdOut = 1 + } + + const enum Tristate { + TristateFalse = 0, + TristateMixed = -2, + TristateTrue = -1, + TristateUseDefault = -2 + } + + //Classes + interface Dictionary { + Add: (Key: any, Item: any) => void; + CompareMode: CompareMethod; + Count: number; + Exists: (Key: any) => boolean; + HashVal: (Key: any) => any; + Item: (Key: any) => any //Also has setter with parameters; + Items: () => any; + Key: (Key: any) => any; + Keys: () => any; + Remove: (Key: any) => void; + RemoveAll: () => void; + } + + interface Drive { + AvailableSpace: any; + DriveLetter: string; + DriveType: DriveTypeConst; + FileSystem: string; + FreeSpace: any; + IsReady: boolean; + Path: string; + RootFolder: Folder; + SerialNumber: number; + ShareName: string; + TotalSize: any; + VolumeName: string; + } + + interface Drives { + Count: number; + Item: (Key: any) => Drive; + } + + interface Encoder { + EncodeScriptFile: (szExt: string, bstrStreamIn: string, cFlags: number, bstrDefaultLang: string) => string; + } + + interface File { + Attributes: FileAttribute; + Copy: (Destination: string, OverWriteFiles?: boolean) => void; + DateCreated: VarDate; + DateLastAccessed: VarDate; + DateLastModified: VarDate; + Delete: (Force?: boolean) => void; + Drive: Drive; + Move: (Destination: string) => void; + Name: string; + OpenAsTextStream: (IOMode?: IOMode, Format?: Tristate) => TextStream; + ParentFolder: Folder; + Path: string; + ShortName: string; + ShortPath: string; + Size: any; + Type: string; + } + + interface Files { + Count: number; + Item: (Key: any) => File; + } + + interface FileSystemObject { + BuildPath: (Path: string, Name: string) => string; + CopyFile: (Source: string, Destination: string, OverWriteFiles?: boolean) => void; + CopyFolder: (Source: string, Destination: string, OverWriteFiles?: boolean) => void; + CreateFolder: (Path: string) => Folder; + CreateTextFile: (FileName: string, Overwrite?: boolean, Unicode?: boolean) => TextStream; + DeleteFile: (FileSpec: string, Force?: boolean) => void; + DeleteFolder: (FolderSpec: string, Force?: boolean) => void; + DriveExists: (DriveSpec: string) => boolean; + Drives: Drives; + FileExists: (FileSpec: string) => boolean; + FolderExists: (FolderSpec: string) => boolean; + GetAbsolutePathName: (Path: string) => string; + GetBaseName: (Path: string) => string; + GetDrive: (DriveSpec: string) => Drive; + GetDriveName: (Path: string) => string; + GetExtensionName: (Path: string) => string; + GetFile: (FilePath: string) => File; + GetFileName: (Path: string) => string; + GetFileVersion: (FileName: string) => string; + GetFolder: (FolderPath: string) => Folder; + GetParentFolderName: (Path: string) => string; + GetSpecialFolder: (SpecialFolder: SpecialFolderConst) => Folder; + GetStandardStream: (StandardStreamType: StandardStreamTypes, Unicode?: boolean) => TextStream; + GetTempName: () => string; + MoveFile: (Source: string, Destination: string) => void; + MoveFolder: (Source: string, Destination: string) => void; + OpenTextFile: (FileName: string, IOMode?: IOMode, Create?: boolean, Format?: Tristate) => TextStream; + } + + interface Folder { + Attributes: FileAttribute; + Copy: (Destination: string, OverWriteFiles?: boolean) => void; + CreateTextFile: (FileName: string, Overwrite?: boolean, Unicode?: boolean) => TextStream; + DateCreated: VarDate; + DateLastAccessed: VarDate; + DateLastModified: VarDate; + Delete: (Force?: boolean) => void; + Drive: Drive; + Files: Files; + IsRootFolder: boolean; + Move: (Destination: string) => void; + Name: string; + ParentFolder: Folder; + Path: string; + ShortName: string; + ShortPath: string; + Size: any; + SubFolders: Folders; + Type: string; + } + + interface Folders { + Add: (Name: string) => Folder; + Count: number; + Item: (Key: any) => Folder; + } + + interface TextStream { + AtEndOfLine: boolean; + AtEndOfStream: boolean; + Close: () => void; + Column: number; + Line: number; + Read: (Characters: number) => string; + ReadAll: () => string; + ReadLine: () => string; + Skip: (Characters: number) => void; + SkipLine: () => void; + Write: (Text: string) => void; + WriteBlankLines: (Lines: number) => void; + WriteLine: (Text?: string) => void; + } + +} + +interface ActiveXObject { + new (progID: 'Scripting.Dictionary'): Scripting.Dictionary; + new (progID: 'Scripting.FileSystemObject'): Scripting.FileSystemObject; + new (progID: 'Scripting.Encoder'): Scripting.Encoder; +} From 45bdf0b44a2e741f1bbd7789f14e1b26560cfc99 Mon Sep 17 00:00:00 2001 From: hrl7 Date: Wed, 29 Jun 2016 11:34:13 +0900 Subject: [PATCH 19/67] Update java to 0.7.2 --- java/java.d.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/java/java.d.ts b/java/java.d.ts index 04f603db77..e977ec1cac 100644 --- a/java/java.d.ts +++ b/java/java.d.ts @@ -1,6 +1,6 @@ -// Type definitions for java 0.5.4 +// Type definitions for java 0.7.2 // Project: https://github.com/joeferner/node-java -// Definitions by: Jim Lloyd +// Definitions by: Jim Lloyd , Kentaro Teramoto // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -36,16 +36,26 @@ declare namespace NodeJavaCore { // *NodeAPI* declares methods & members exported by the node java module. interface NodeAPI { classpath: string[]; + options: string[]; asyncOptions: AsyncOptions; + nativeBindingLocation: string; + callMethod(instance: any, className: string, methodName: string, args: any[], callback: Callback): void; callMethodSync(instance: any, className: string, methodName: string, ...args: any[]): any; + callStaticMethod(className: string, methodName: string, ...args: Array>): void; callStaticMethodSync(className: string, methodName: string, ...args: any[]): any; + getStaticFieldValue(className: string, fieldName: string): any; + setStaticFieldValue(className: string, fieldName: string, newValue: any): void; instanceOf(javaObject: any, className: string): boolean; registerClient(before: (cb: Callback) => void, after?: (cb: Callback) => void): void; registerClientP(beforeP: () => Promise, afterP?: () => Promise): void; ensureJvm(done: Callback): void; ensureJvm(): Promise; + isJvmCreated(): boolean; + newByte(val: number): any; + newChar(val: string|number): any; + newDouble(val: number): any; newShort(val: number): any; newLong(val: number): any; newFloat(val: number): any; From 72cfc0867571b216275d26b997ddb5d2d7eb1836 Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Wed, 29 Jun 2016 10:18:56 +0300 Subject: [PATCH 20/67] fix(localforage): fix driver() method to return string There seems to be a misunderstanding to what [the `driver()` method returns](https://github.com/mozilla/localForage/blob/master/src/localforage.js#L218-L220). Since it returns `LocalForageDriver._driver` it should be a string. --- localForage/localForage.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index 89e767037b..029e6bf16b 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -52,7 +52,7 @@ interface LocalForage { config(options: LocalForageOptions): boolean; createInstance(options: LocalForageOptions): LocalForage; - driver(): LocalForageDriver; + driver(): string | null; /** * Force usage of a particular driver or drivers, if available. * @param {string} driver From 531e93a3bc03cf84a477c8c952aa396e34d0dae8 Mon Sep 17 00:00:00 2001 From: Markus Wagner Date: Wed, 29 Jun 2016 09:23:30 +0200 Subject: [PATCH 21/67] Update cordova-plugin-ibeacon.d.ts Additional property added to interface PluginResult --- cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts b/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts index 1c7a293716..1aedefb676 100644 --- a/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts +++ b/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts @@ -50,6 +50,7 @@ declare namespace BeaconPlugin { beacons: Beacon[]; authorizationStatus: string; state: string; + error: string; } export interface Delegate { From 1936f51e478dcd840d6a44f76402672a45cd9d1e Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Wed, 29 Jun 2016 10:45:17 +0300 Subject: [PATCH 22/67] Update localForage.d.ts --- localForage/localForage.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index 029e6bf16b..803bde9e57 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -52,7 +52,7 @@ interface LocalForage { config(options: LocalForageOptions): boolean; createInstance(options: LocalForageOptions): LocalForage; - driver(): string | null; + driver(): string; /** * Force usage of a particular driver or drivers, if available. * @param {string} driver From b38089d5a67ddbb2b60b0bd4369507182610bac2 Mon Sep 17 00:00:00 2001 From: Kensuke Matsuzaki Date: Wed, 29 Jun 2016 18:48:18 +0900 Subject: [PATCH 23/67] Add axios config defaults definitions --- axios/axios-tests.ts | 6 ++++++ axios/axios.d.ts | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/axios/axios-tests.ts b/axios/axios-tests.ts index 040994531b..50e2388624 100644 --- a/axios/axios-tests.ts +++ b/axios/axios-tests.ts @@ -91,3 +91,9 @@ var repoSum = (repo1: Axios.AxiosXHR, repo2: Axios.AxiosXHR([getRepoDetails, getRepoDetails]).then(axios.spread(repoSum)); + +axios.defaults.baseURL = 'https://api.example.com'; +axios.defaults.headers.common['Authorization'] = "AUTH_TOKEN"; +axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; + +axiosInstance.defaults.headers.common['Authorization'] = "AUTH_TOKEN"; \ No newline at end of file diff --git a/axios/axios.d.ts b/axios/axios.d.ts index 44083f7960..9c4705d093 100644 --- a/axios/axios.d.ts +++ b/axios/axios.d.ts @@ -124,6 +124,18 @@ declare namespace Axios { data?: T; } + interface AxiosXHRConfigDefaults extends AxiosXHRConfigBase { + /** + * custom headers to be sent + */ + headers: { + common: {[index: string]: string}; + patch: {[index: string]: string}; + post: {[index: string]: string}; + put: {[index: string]: string}; + }; + } + /** * - expected response type, * - request body data type @@ -223,6 +235,11 @@ declare namespace Axios { */ interceptors: Interceptor; + /** + * Config defaults + */ + defaults: AxiosXHRConfigDefaults; + /** * equivalent to `Promise.all` */ From 858c0021ff62e0223e248ad2994e3a34327bead5 Mon Sep 17 00:00:00 2001 From: nkovacic Date: Wed, 29 Jun 2016 12:37:17 +0200 Subject: [PATCH 24/67] Added Dot-object typings --- dot-object/dot-object-tests.ts | 64 +++++++++++++ dot-object/dot-object.d.ts | 162 +++++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+) create mode 100644 dot-object/dot-object-tests.ts create mode 100644 dot-object/dot-object.d.ts diff --git a/dot-object/dot-object-tests.ts b/dot-object/dot-object-tests.ts new file mode 100644 index 0000000000..c6098defd2 --- /dev/null +++ b/dot-object/dot-object-tests.ts @@ -0,0 +1,64 @@ +/// + + +var obj = { + 'first_name': 'John', + 'last_name': 'Doe' +}; + +dot.move('first_name', 'contact.firstname', obj); +dot.move('last_name', 'contact.lastname', obj); + +var src = { + name: 'John', + stuff: { + phone: { + brand: 'iphone', + version: 6 + } + } +}; + +var tgt = {name: 'Brandon'}; + +dot.copy('stuff.phone', 'wanna.haves.phone', src, tgt); + +dot.transfer('stuff.phone', 'wanna.haves.phone', src, tgt); + +var row = { + 'id': 2, + 'contact.name.first': 'John', + 'contact.name.last': 'Doe', + 'contact.email': 'example@gmail.com', + 'contact.info.about.me': 'classified', + 'devices[0]': 'mobile', + 'devices[1]': 'laptop', + 'some.other.things.0': 'this', + 'some.other.things.1': 'that' +}; + +dot.object(row); + +dot.str('this.is.my.string', 'value', tgt); + +var newObj = { + some: { + nested: { + value: 'Hi there!' + } + } +}; + +var val = dot.pick('some.nested.value', newObj); +console.log(val); + +// Pick & Remove the value +val = dot.pick('some.nested.value', newObj, true); + +// shorthand +val = dot.remove('some.nested.value', newObj); + +// or use the alias `del` +val = dot.del('some.nested.value', newObj); + +var dot = new dot('=>'); \ No newline at end of file diff --git a/dot-object/dot-object.d.ts b/dot-object/dot-object.d.ts new file mode 100644 index 0000000000..f87fc0aa53 --- /dev/null +++ b/dot-object/dot-object.d.ts @@ -0,0 +1,162 @@ +// Type definitions for Dot-Object v1.4.1 +// Project: https://github.com/rhalff/dot-object +// Definitions by: Niko Kovačič +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare namespace DotObject { + interface Dot { + new(separator: string): Dot; + /** + * + * Copy a property from one object to another object. + * + * If the source path does not exist (undefined) + * the property on the other object will not be set. + * + * @param {String} source + * @param {String} target + * @param {Object} obj1 + * @param {Object} obj2 + * @param {Function|Array} mods + * @param {Boolean} merge + */ + copy(source: string, target: string, obj1: any, obj2: any, mods?: Function | Array, merge?: boolean): void; + /** + * + * Convert object to dotted-key/value pair + * + * Usage: + * + * var tgt = dot.dot(obj) + * + * or + * + * var tgt = {} + * dot.dot(obj, tgt) + * + * @param {Object} obj source object + * @param {Object} tgt target object + */ + dot(obj: any, tgt: any): void + /** + * + * Remove value from an object using dot notation. + * + * @param {String} path + * @param {Object} obj + * @return {Mixed} The removed value + */ + del(path: string, obj: any): any; + /** + * + * Move a property from one place to the other. + * + * If the source path does not exist (undefined) + * the target property will not be set. + * + * @param {String} source + * @param {String} target + * @param {Object} obj + * @param {Function|Array} mods + * @param {Boolean} merge + */ + move(source: string, target: string, obj: any, mods?: Function | Array, merge?: boolean): void; + /** + * + * Converts an object with dotted-key/value pairs to it's expanded version + * + * Optionally transformed by a set of modifiers. + * + * Usage: + * + * var row = { + * 'nr': 200, + * 'doc.name': ' My Document ' + * } + * + * var mods = { + * 'doc.name': [_s.trim, _s.underscored] + * } + * + * dot.object(row, mods) + * + * @param {Object} obj + * @param {Object} mods + */ + object(obj: any, mods?: Function | Array): void; + /** + * + * Pick a value from an object using dot notation. + * + * Optionally remove the value + * + * @param {String} path + * @param {Object} obj + * @param {Boolean} remove + */ + pick(path: string, obj: any, remove?: boolean): void; + /** + * + * Remove value from an object using dot notation. + * + * @param {String} path + * @param {Object} obj + * @return {Mixed} The removed value + */ + remove(path: string, obj: any): any; + /** + * @param {String} path dotted path + * @param {String} v value to be set + * @param {Object} obj object to be modified + * @param {Function|Array} mods optional modifier + */ + str(path: string, v: any, obj: Object, mods?: Function | Array): void; + /** + * + * Transfer a property from one object to another object. + * + * If the source path does not exist (undefined) + * the property on the other object will not be set. + * + * @param {String} source + * @param {String} target + * @param {Object} obj1 + * @param {Object} obj2 + * @param {Function|Array} mods + * @param {Boolean} merge + */ + transfer(source: string, target: string, obj1: any, obj2: any, mods?: Function | Array, merge?: boolean): void; + /** + * + * Transform an object + * + * Usage: + * + * var obj = { + * "id": 1, + * "some": { + * "thing": "else" + * } + * } + * + * var transform = { + * "id": "nr", + * "some.thing": "name" + * } + * + * var tgt = dot.transform(transform, obj) + * + * @param {Object} recipe Transform recipe + * @param {Object} obj Object to be transformed + * @param {Array} mods modifiers for the target + */ + transform(recipe: any, obj: any, mods?: Function | Array): void; + } +} + +declare var dot: DotObject.Dot; + +declare module 'dot-object' { + export = dot; +} \ No newline at end of file From c3c178dad936c9207ecce37fbd16d1ce51d488df Mon Sep 17 00:00:00 2001 From: Aleksandr Popitich Date: Wed, 29 Jun 2016 14:16:37 +0300 Subject: [PATCH 25/67] Fix return type for getRequestInfo method definition. --- adal-angular/adal.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adal-angular/adal.d.ts b/adal-angular/adal.d.ts index 76b86e7150..f181054ecf 100644 --- a/adal-angular/adal.d.ts +++ b/adal-angular/adal.d.ts @@ -133,7 +133,7 @@ declare namespace adal { * Gets requestInfo from given hash. * @returns {string} error message related to login */ - getRequestInfo(hash: string): string; + getRequestInfo(hash: string): RequestInfo; /** * Saves token from hash that is received from redirect. From 83b741116c2f23d2ec3ab3ef2e4ddc17e8d10d0b Mon Sep 17 00:00:00 2001 From: Aleksandr Popitich Date: Wed, 29 Jun 2016 14:32:47 +0300 Subject: [PATCH 26/67] Fix doc-string --- adal-angular/adal.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adal-angular/adal.d.ts b/adal-angular/adal.d.ts index f181054ecf..1c60cbf6ef 100644 --- a/adal-angular/adal.d.ts +++ b/adal-angular/adal.d.ts @@ -131,7 +131,7 @@ declare namespace adal { /** * Gets requestInfo from given hash. - * @returns {string} error message related to login + * @returns {RequestInfo} for appropriate hash. */ getRequestInfo(hash: string): RequestInfo; From 07967cd86a7a050469b4d86fc069af7539780182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kov=C3=A1cs=20Q?= Date: Wed, 29 Jun 2016 15:54:04 +0200 Subject: [PATCH 27/67] [Drop] Add delay time properties for options interface --- drop/drop.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drop/drop.d.ts b/drop/drop.d.ts index a642ad9edd..63f9c8621e 100644 --- a/drop/drop.d.ts +++ b/drop/drop.d.ts @@ -46,6 +46,12 @@ declare namespace Drop { constrainToScrollParent?: boolean; remove?: boolean; beforeClose?: () => boolean; + openDelay?: number; + closeDelay?: number; + focusDelay?: number; + blurDelay?: number; + hoverOpenDelay?: number; + hoverCloseDelay?: number; tetherOptions?: Tether.ITetherOptions; } } From a15f08332763d2e41d9787cec4e8324c9e5870dc Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Wed, 29 Jun 2016 23:20:31 +0900 Subject: [PATCH 28/67] Add Content type definition (#6381) * rename the definition file of another `content-type` library * add the definition of `content-type` library --- content-type/content-type-tests.ts | 48 ++++++------------------ content-type/content-type.d.ts | 38 ++++++++----------- deoxxa-content-type/content-type-test.ts | 47 +++++++++++++++++++++++ deoxxa-content-type/content-type.d.ts | 32 ++++++++++++++++ 4 files changed, 105 insertions(+), 60 deletions(-) create mode 100644 deoxxa-content-type/content-type-test.ts create mode 100644 deoxxa-content-type/content-type.d.ts diff --git a/content-type/content-type-tests.ts b/content-type/content-type-tests.ts index 872b3cded0..b9181fb3fd 100644 --- a/content-type/content-type-tests.ts +++ b/content-type/content-type-tests.ts @@ -1,47 +1,21 @@ /// +/// -import MediaType = require('content-type'); +import contentType = require('content-type'); +import express = require('express'); -// https://github.com/deoxxa/content-type/blob/master/README.md -function new_test(): void { - var p = new MediaType('text/html;level=1;q=0.5'); - p.q === 0.5; - p.params.level === "1"; - var q = new MediaType('application/json', { profile: 'http://example.com/schema.json' }); - q.type === "application/json"; - q.params.profile === "http://example.com/schema.json"; +var obj = contentType.parse('image/svg+xml; charset=utf-8'); - q.q = 1; - q.toString() === 'application/json;q=1;profile="http://example.com/schema.json"'; -} +console.log(obj.type); // => 'image/svg+xml' +console.log(obj.parameters.charset); // => 'utf-8' -function mediaCmp_test(): void { - MediaType.mediaCmp(MediaType.parseMedia('text/html'), MediaType.parseMedia('text/html')) === 0; - MediaType.mediaCmp(MediaType.parseMedia('*/*'), MediaType.parseMedia('text/html')) === 1; - MediaType.mediaCmp(MediaType.parseMedia('text/html;level=1'), MediaType.parseMedia('text/html')) === -1; - MediaType.mediaCmp(MediaType.parseMedia('application/json;profile="v1.json"'), MediaType.parseMedia('application/json;profile="v2.json"')) === null; -} -// https://github.com/deoxxa/content-type/blob/master/example.js -function example(): void { - var representations = [ - 'application/json', - 'text/html', - 'application/json;profile="schema.json"', - 'application/json;profile="different.json"', - ]; +var req: express.Request; +obj = contentType.parse(req); - var accept = [ - 'text/html;q=0.50', - '*/*;q=0.01', - 'application/json;profile=different.json', - 'application/json;profile="a,b;c.json?d=1;f=2";q=0.2', - ]; +var res: express.Response; +obj = contentType.parse(res); - console.log('Formats:\n\t' + representations.map(MediaType.parseMedia).join('\n\t')); +var str: string = contentType.format({type: 'image/svg+xml'}); - console.log('Accept:\n\t' + accept.map(MediaType.parseMedia).join('\n\t')); - - console.log('Selected:', (MediaType.select(representations.map(MediaType.parseMedia), accept.map(MediaType.parseMedia)) || 'None').toString()); -} \ No newline at end of file diff --git a/content-type/content-type.d.ts b/content-type/content-type.d.ts index 6e901e7f86..d8254fd8ed 100644 --- a/content-type/content-type.d.ts +++ b/content-type/content-type.d.ts @@ -1,32 +1,24 @@ -// Type definitions for content-type v0.0.1 -// Project: https://github.com/deoxxa/content-type -// Definitions by: Pine Mizune -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Type definitions for content-type v1.0.1 +// Project: https://www.npmjs.com/package/content-type +// Definitions by: Hiroki Horiuchi +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module ContentType { + interface StaticFunctions { + parse(string: string): MediaType; + parse(req: { headers: any; }): MediaType; + parse(res: { getHeader(key: string): string; }): MediaType; + format(obj: MediaType): string; + } -declare namespace ContentType { interface MediaType { type: string; - q?: number; - params: any; - toString(): string; - } - - interface SelectOptions { - sortAvailable?: boolean; - sortAccepted?: boolean; - } - - interface MediaTypeStatic { - new (s: string, p?: any): MediaType; - parseMedia(type: string): MediaType; - splitQuotedString(str: string, delimiter?: string, quote?: string): string[]; - splitContentTypes(str: string): string[]; - select(availableTypes: MediaType[], acceptedTypes: MediaType[], options?: SelectOptions): string; - mediaCmp(a: MediaType, b: MediaType): number; + parameters?: any; } } declare module "content-type" { - var x: ContentType.MediaTypeStatic; + var x: ContentType.StaticFunctions; export = x; } + diff --git a/deoxxa-content-type/content-type-test.ts b/deoxxa-content-type/content-type-test.ts new file mode 100644 index 0000000000..3e419933ef --- /dev/null +++ b/deoxxa-content-type/content-type-test.ts @@ -0,0 +1,47 @@ +/// + +import MediaType = require('content-type'); + +// https://github.com/deoxxa/content-type/blob/master/README.md +function new_test(): void { + var p = new MediaType('text/html;level=1;q=0.5'); + p.q === 0.5; + p.params.level === "1"; + + var q = new MediaType('application/json', { profile: 'http://example.com/schema.json' }); + q.type === "application/json"; + q.params.profile === "http://example.com/schema.json"; + + q.q = 1; + q.toString() === 'application/json;q=1;profile="http://example.com/schema.json"'; +} + +function mediaCmp_test(): void { + MediaType.mediaCmp(MediaType.parseMedia('text/html'), MediaType.parseMedia('text/html')) === 0; + MediaType.mediaCmp(MediaType.parseMedia('*/*'), MediaType.parseMedia('text/html')) === 1; + MediaType.mediaCmp(MediaType.parseMedia('text/html;level=1'), MediaType.parseMedia('text/html')) === -1; + MediaType.mediaCmp(MediaType.parseMedia('application/json;profile="v1.json"'), MediaType.parseMedia('application/json;profile="v2.json"')) === null; +} + +// https://github.com/deoxxa/content-type/blob/master/example.js +function example(): void { + var representations = [ + 'application/json', + 'text/html', + 'application/json;profile="schema.json"', + 'application/json;profile="different.json"', + ]; + + var accept = [ + 'text/html;q=0.50', + '*/*;q=0.01', + 'application/json;profile=different.json', + 'application/json;profile="a,b;c.json?d=1;f=2";q=0.2', + ]; + + console.log('Formats:\n\t' + representations.map(MediaType.parseMedia).join('\n\t')); + + console.log('Accept:\n\t' + accept.map(MediaType.parseMedia).join('\n\t')); + + console.log('Selected:', (MediaType.select(representations.map(MediaType.parseMedia), accept.map(MediaType.parseMedia)) || 'None').toString()); +} diff --git a/deoxxa-content-type/content-type.d.ts b/deoxxa-content-type/content-type.d.ts new file mode 100644 index 0000000000..6e901e7f86 --- /dev/null +++ b/deoxxa-content-type/content-type.d.ts @@ -0,0 +1,32 @@ +// Type definitions for content-type v0.0.1 +// Project: https://github.com/deoxxa/content-type +// Definitions by: Pine Mizune +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace ContentType { + interface MediaType { + type: string; + q?: number; + params: any; + toString(): string; + } + + interface SelectOptions { + sortAvailable?: boolean; + sortAccepted?: boolean; + } + + interface MediaTypeStatic { + new (s: string, p?: any): MediaType; + parseMedia(type: string): MediaType; + splitQuotedString(str: string, delimiter?: string, quote?: string): string[]; + splitContentTypes(str: string): string[]; + select(availableTypes: MediaType[], acceptedTypes: MediaType[], options?: SelectOptions): string; + mediaCmp(a: MediaType, b: MediaType): number; + } +} + +declare module "content-type" { + var x: ContentType.MediaTypeStatic; + export = x; +} From eedc8069d2631c2411aff84960472bbcd81e9a88 Mon Sep 17 00:00:00 2001 From: Lionel Date: Wed, 29 Jun 2016 17:22:05 +0200 Subject: [PATCH 29/67] add missing properties of $websocket instance This PR add the missing properties of $websocket instance as mention in the documentation https://github.com/AngularClass/angular-websocket#properties --- angular-websocket/angular-websocket-tests.ts | 22 +++++++ angular-websocket/angular-websocket.d.ts | 61 +++++++++++++++++++- 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/angular-websocket/angular-websocket-tests.ts b/angular-websocket/angular-websocket-tests.ts index 78ba982aa5..980e2001d3 100644 --- a/angular-websocket/angular-websocket-tests.ts +++ b/angular-websocket/angular-websocket-tests.ts @@ -1,6 +1,7 @@ /// let dummySocket: ng.websocket.IWebSocket; +let dummyPromise: ng.IPromise; let provider: ng.websocket.IWebSocketProvider = (url: string) => { return dummySocket; @@ -23,3 +24,24 @@ socket.close(); socket.send("Some great data here!").finally(() => {}); socket.send({ list: [1, 2, 3, 4] }); + +socket.socket.send("data"); +socket.socket.close(); +socket.socket.close(1); +socket.socket.close(1, "reason"); + +socket.sendQueue.push({ message: "msg", defered: dummyPromise }); + +socket.onOpenCallbacks.push((event: Event) => {}); +socket.onCloseCallbacks.push((event: CloseEvent) => {}); +socket.onErrorCallbacks.push((event: Event) => {}); +socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: 'Some Filter', autoApply: true }); +socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: /Some Filter/, autoApply: true }); +socket.onMessageCallbacks.push({ fn: (event: MessageEvent) => {}, pattern: undefined, autoApply: true }); + +socket.readyState = 0; + +socket.initialTimeout = 10; + +socket.maxTimeout = 5000; + diff --git a/angular-websocket/angular-websocket.d.ts b/angular-websocket/angular-websocket.d.ts index 04859a7d16..a01e5eab3e 100644 --- a/angular-websocket/angular-websocket.d.ts +++ b/angular-websocket/angular-websocket.d.ts @@ -30,6 +30,19 @@ declare namespace angular.websocket { autoApply?: boolean; } + /** Type corresponding to onMessage callbaks stored in $Websocket#onMessageCallbacks instance. */ + type IWebSocketMessageHandler = { + fn: (evt: MessageEvent) => void; + pattern: string | RegExp; + autoApply: boolean; + } + + /** Type corresponding to items stored in $WebSocket#sendQueue instance. */ + type IWebSocketQueueItem = { + message: any; + defered: ng.IPromise; + } + interface IWebSocket { /** @@ -81,6 +94,52 @@ declare namespace angular.websocket { * * @param data data to send, if this is an object, it will be stringified before sending */ - send(data: string | {}): ng.IPromise; + send(data: string | {}): ng.IPromise; + + /** + * WebSocket instance. + */ + socket: WebSocket; + + /** + * Queue of send calls to be made on socket when socket is able to receive data. + */ + sendQueue: IWebSocketQueueItem[]; + + /** + * List of callbacks to be executed when the socket is opened. + */ + onOpenCallbacks: ((evt: Event) => void)[]; + + /** + * List of callbacks to be executed when a message is received from the socket. + */ + onMessageCallbacks: IWebSocketMessageHandler[]; + + /** + * List of callbacks to be executed when an error is received from the socket. + */ + onErrorCallbacks: ((evt: Event) => void)[]; + + /** + * List of callbacks to be executed when the socket is closed. + */ + onCloseCallbacks: ((evt: CloseEvent) => void)[]; + + /** + * Returns either the readyState value from the underlying WebSocket instance + * or a proprietary value representing the internal state + */ + readyState: number; + + /** + * The initial timeout. + */ + initialTimeout: number; + + /** + * Maximun timeout used to determine reconnection delay. + */ + maxTimeout: number; } } From 1f9f669005bc1d5d4bccee69f68e76aac5044de1 Mon Sep 17 00:00:00 2001 From: Martin D Date: Wed, 29 Jun 2016 13:27:18 -0400 Subject: [PATCH 30/67] Create plotly.js-tests.ts --- plotly.js/plotly.js-tests.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 plotly.js/plotly.js-tests.ts diff --git a/plotly.js/plotly.js-tests.ts b/plotly.js/plotly.js-tests.ts new file mode 100644 index 0000000000..b5b8b9e275 --- /dev/null +++ b/plotly.js/plotly.js-tests.ts @@ -0,0 +1,11 @@ +/// + +var data = [ + { + x: ['giraffes', 'orangutans', 'monkeys'], + y: [20, 14, 23], + type: 'bar' + } +]; + +Plotly.newPlot('test', data); From 3a63e9bf45c62b1aee010b588338a621e008539e Mon Sep 17 00:00:00 2001 From: Martin D Date: Wed, 29 Jun 2016 13:31:25 -0400 Subject: [PATCH 31/67] Typings --- plotly.js/plotly.js.d.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 plotly.js/plotly.js.d.ts diff --git a/plotly.js/plotly.js.d.ts b/plotly.js/plotly.js.d.ts new file mode 100644 index 0000000000..c28d2ffb0f --- /dev/null +++ b/plotly.js/plotly.js.d.ts @@ -0,0 +1,33 @@ +// Type definitions for plotly.js +// Project: https://plot.ly/javascript/ +// Definitions by: Martin Duparc +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface PlotlyConfig { + staticPlot?: boolean, + editable?: boolean, + autosizable?: boolean, + fillFrame?: boolean, + frameMargins?: number, + scrollZoom?: boolean, + doubleClick?: string, + showTips?: boolean, + showLink?: boolean, + sendData?: boolean, + linkText?: string, + showSources?: boolean, + displayModeBar?: string|boolean, + modeBarButtonsToRemove?: any[], + modeBarButtonsToAdd?: any[], + modeBarButtons?: boolean, + displaylogo?: boolean, + plotGlPixelRatio?: number, + setBackground?: any, + topojsonURL?: string, + mapboxAccessToken?: string, + logging?: boolean +} + +declare var Plotly: { + newPlot(divid:string, data:any[], layout?:any, config?:PlotlyConfig):void +}; From 03ce6403844431465f2cfefe22c6032bd35eb173 Mon Sep 17 00:00:00 2001 From: Eric Brody Date: Wed, 29 Jun 2016 13:11:09 -0400 Subject: [PATCH 32/67] Adds declarations for the `node-usb` library --- node-usb/node-usb-tests.ts | 202 ++++++++++++++++++++++++++++++++ node-usb/node-usb.d.ts | 230 +++++++++++++++++++++++++++++++++++++ 2 files changed, 432 insertions(+) create mode 100644 node-usb/node-usb-tests.ts create mode 100644 node-usb/node-usb.d.ts diff --git a/node-usb/node-usb-tests.ts b/node-usb/node-usb-tests.ts new file mode 100644 index 0000000000..8ae22cf0cc --- /dev/null +++ b/node-usb/node-usb-tests.ts @@ -0,0 +1,202 @@ +/// + +import * as usb from "usb"; + +const device = new usb.Device(); + +device.timeout = 1; +device.busNumber = 1; +device.deviceAddress = 1; +device.portNumbers = [1, 2, 3]; + +device.open(true); +device.close(); +const xferDevice: usb.Device = device.controlTransfer(1, 1, 1, 1, 1, (error: string, buf: Buffer): usb.Device => new usb.Device()); +device.getStringDescriptor(1, (error: string, buf: Buffer) => null); +device.setConfiguration(1, (error: string) => null); +device.reset((error: string) => null); + +const deviceDesc: usb.DeviceDescriptor = new usb.DeviceDescriptor(); + +deviceDesc.bLength = 1; +deviceDesc.bDescriptorType = 1; +deviceDesc.bcdUSB = 1; +deviceDesc.bDeviceClass = 1; +deviceDesc.bDeviceSubClass = 1; +deviceDesc.bDeviceProtocol = 1; +deviceDesc.bMaxPacketSize = 1; +deviceDesc.idVendor = 1; +deviceDesc.idProduct = 1; +deviceDesc.bcdDevice = 1; +deviceDesc.iManufacturer = 1; +deviceDesc.iProduct = 1; +deviceDesc.iSerialNumber = 1; +deviceDesc.bNumConfigurations = 1; + +device.deviceDescriptor = deviceDesc; + +const configDesc: usb.ConfigDescriptor = new usb.ConfigDescriptor(); + +configDesc.bLength = 1; +configDesc.bDescriptorType = 1; +configDesc.wTotalLength = 1; +configDesc.bNumInterfaces = 1; +configDesc.bConfigurationValue = 1; +configDesc.iConfiguration = 1; +configDesc.bmAttributes = 1; +configDesc.bMaxPower = 1; +configDesc.extra = new Buffer([]); + +const deviceInterface: usb.Interface = device.interface(1); + +device.interfaces = [deviceInterface]; + +const iface = new usb.Interface(device, 1); + +iface.claim(); +iface.release((error: string) => null, (error: string) => null); +const kernelActive: boolean = iface.isKernelDriverActive(); +const detachKernel: number = iface.detachKernelDriver(); +const attachKernel: number = iface.attachKernelDriver(); +iface.setAltSetting(1, (error: string) => null); + +const endpointDesc: usb.EndpointDescriptor = new usb.EndpointDescriptor(); + +endpointDesc.bLength = 1; +endpointDesc.bDescriptorType = 1; +endpointDesc.bEndpointAddress = 1; +endpointDesc.bmAttributes = 1; +endpointDesc.wMaxPacketSize = 1; +endpointDesc.bInterval = 1; +endpointDesc.bRefresh = 1; +endpointDesc.bSynchAddress = 1; + +const ifaceInEndpoint: usb.IEndpoint = iface.endpoint(1) as usb.InEndpoint; +const ifaceOutEndpoint: usb.IEndpoint = iface.endpoint(1) as usb.OutEndpoint; + +const inEndpoint: usb.InEndpoint = new usb.InEndpoint(device, endpointDesc); + +inEndpoint.direction = "in"; +inEndpoint.transferType = 1; +inEndpoint.timeout = 1; +inEndpoint.descriptor = endpointDesc; +const xferInEndpoint: usb.InEndpoint = inEndpoint.transfer(1, (error: string, data: Buffer) => { return inEndpoint; }); +inEndpoint.startPoll(1, 1); +inEndpoint.stopPoll(() => null); + +const outEndpoint: usb.OutEndpoint = new usb.OutEndpoint(device, endpointDesc); +outEndpoint.direction = "out"; +outEndpoint.transferType = 1; +outEndpoint.timeout = 1; +outEndpoint.descriptor = endpointDesc; +const xferOutEndpoint: usb.OutEndpoint = outEndpoint.transfer(new Buffer([]), (error: string) => null); +outEndpoint.transferWithZLP(new Buffer([]), (error: string) => null); + +const findByDevice: usb.Device = usb.findByIds(1, 1); +usb.on("hey", (device: usb.Device) => null); +const deviceList: Array = usb.getDeviceList(); +usb.setDebugLevel(1); + +const CHECK_LIBUSB_CLASS_PER_INTERFACE: number = usb.LIBUSB_CLASS_PER_INTERFACE; +const CHECK_LIBUSB_CLASS_AUDIO: number = usb.LIBUSB_CLASS_AUDIO; +const CHECK_LIBUSB_CLASS_COMM: number = usb.LIBUSB_CLASS_COMM; +const CHECK_LIBUSB_CLASS_HID: number = usb.LIBUSB_CLASS_HID; +const CHECK_LIBUSB_CLASS_PRINTER: number = usb.LIBUSB_CLASS_PRINTER; +const CHECK_LIBUSB_CLASS_PTP: number = usb.LIBUSB_CLASS_PTP; +const CHECK_LIBUSB_CLASS_MASS_STORAGE: number = usb.LIBUSB_CLASS_MASS_STORAGE; +const CHECK_LIBUSB_CLASS_HUB: number = usb.LIBUSB_CLASS_HUB; +const CHECK_LIBUSB_CLASS_DATA: number = usb.LIBUSB_CLASS_DATA; +const CHECK_LIBUSB_CLASS_WIRELESS: number = usb.LIBUSB_CLASS_WIRELESS; +const CHECK_LIBUSB_CLASS_APPLICATION: number = usb.LIBUSB_CLASS_APPLICATION; +const CHECK_LIBUSB_CLASS_VENDOR_SPEC: number = usb.LIBUSB_CLASS_VENDOR_SPEC; +// libusb_standard_request +const CHECK_LIBUSB_REQUEST_GET_STATUS: number = usb.LIBUSB_REQUEST_GET_STATUS; +const CHECK_LIBUSB_REQUEST_CLEAR_FEATURE: number = usb.LIBUSB_REQUEST_CLEAR_FEATURE; +const CHECK_LIBUSB_REQUEST_SET_FEATURE: number = usb.LIBUSB_REQUEST_SET_FEATURE; +const CHECK_LIBUSB_REQUEST_SET_ADDRESS: number = usb.LIBUSB_REQUEST_SET_ADDRESS; +const CHECK_LIBUSB_REQUEST_GET_DESCRIPTOR: number = usb.LIBUSB_REQUEST_GET_DESCRIPTOR; +const CHECK_LIBUSB_REQUEST_SET_DESCRIPTOR: number = usb.LIBUSB_REQUEST_SET_DESCRIPTOR; +const CHECK_LIBUSB_REQUEST_GET_CONFIGURATION: number = usb.LIBUSB_REQUEST_GET_CONFIGURATION; +const CHECK_LIBUSB_REQUEST_SET_CONFIGURATION: number = usb.LIBUSB_REQUEST_SET_CONFIGURATION; +const CHECK_LIBUSB_REQUEST_GET_INTERFACE: number = usb.LIBUSB_REQUEST_GET_INTERFACE; +const CHECK_LIBUSB_REQUEST_SET_INTERFACE: number = usb.LIBUSB_REQUEST_SET_INTERFACE; +const CHECK_LIBUSB_REQUEST_SYNCH_FRAME: number = usb.LIBUSB_REQUEST_SYNCH_FRAME; +// libusb_descriptor_type +const CHECK_LIBUSB_DT_DEVICE: number = usb.LIBUSB_DT_DEVICE; +const CHECK_LIBUSB_DT_CONFIG: number = usb.LIBUSB_DT_CONFIG; +const CHECK_LIBUSB_DT_STRING: number = usb.LIBUSB_DT_STRING; +const CHECK_LIBUSB_DT_INTERFACE: number = usb.LIBUSB_DT_INTERFACE; +const CHECK_LIBUSB_DT_ENDPOINT: number = usb.LIBUSB_DT_ENDPOINT; +const CHECK_LIBUSB_DT_HID: number = usb.LIBUSB_DT_HID; +const CHECK_LIBUSB_DT_REPORT: number = usb.LIBUSB_DT_REPORT; +const CHECK_LIBUSB_DT_PHYSICAL: number = usb.LIBUSB_DT_PHYSICAL; +const CHECK_LIBUSB_DT_HUB: number = usb.LIBUSB_DT_HUB; +// libusb_endpoint_direction +const CHECK_LIBUSB_ENDPOINT_IN: number = usb.LIBUSB_ENDPOINT_IN; +const CHECK_LIBUSB_ENDPOINT_OUT: number = usb.LIBUSB_ENDPOINT_OUT; +// libusb_transfer_type +const CHECK_LIBUSB_TRANSFER_TYPE_CONTROL: number = usb.LIBUSB_TRANSFER_TYPE_CONTROL; +const CHECK_LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: number = usb.LIBUSB_TRANSFER_TYPE_ISOCHRONOUS; +const CHECK_LIBUSB_TRANSFER_TYPE_BULK: number = usb.LIBUSB_TRANSFER_TYPE_BULK; +const CHECK_LIBUSB_TRANSFER_TYPE_INTERRUPT: number = usb.LIBUSB_TRANSFER_TYPE_INTERRUPT; +// libusb_iso_sync_type +const CHECK_LIBUSB_ISO_SYNC_TYPE_NONE: number = usb.LIBUSB_ISO_SYNC_TYPE_NONE; +const CHECK_LIBUSB_ISO_SYNC_TYPE_ASYNC: number = usb.LIBUSB_ISO_SYNC_TYPE_ASYNC; +const CHECK_LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: number = usb.LIBUSB_ISO_SYNC_TYPE_ADAPTIVE; +const CHECK_LIBUSB_ISO_SYNC_TYPE_SYNC: number = usb.LIBUSB_ISO_SYNC_TYPE_SYNC; +// libusb_iso_usage_type +const CHECK_LIBUSB_ISO_USAGE_TYPE_DATA: number = usb.LIBUSB_ISO_USAGE_TYPE_DATA; +const CHECK_LIBUSB_ISO_USAGE_TYPE_FEEDBACK: number = usb.LIBUSB_ISO_USAGE_TYPE_FEEDBACK; +const CHECK_LIBUSB_ISO_USAGE_TYPE_IMPLICIT: number = usb.LIBUSB_ISO_USAGE_TYPE_IMPLICIT; +// libusb_transfer_status +const CHECK_LIBUSB_TRANSFER_COMPLETED: number = usb.LIBUSB_TRANSFER_COMPLETED; +const CHECK_LIBUSB_TRANSFER_ERROR: number = usb.LIBUSB_TRANSFER_ERROR; +const CHECK_LIBUSB_TRANSFER_TIMED_OUT: number = usb.LIBUSB_TRANSFER_TIMED_OUT; +const CHECK_LIBUSB_TRANSFER_CANCELLED: number = usb.LIBUSB_TRANSFER_CANCELLED; +const CHECK_LIBUSB_TRANSFER_STALL: number = usb.LIBUSB_TRANSFER_STALL; +const CHECK_LIBUSB_TRANSFER_NO_DEVICE: number = usb.LIBUSB_TRANSFER_NO_DEVICE; +const CHECK_LIBUSB_TRANSFER_OVERFLOW: number = usb.LIBUSB_TRANSFER_OVERFLOW; +// libusb_transfer_flags +const CHECK_LIBUSB_TRANSFER_SHORT_NOT_OK: number = usb.LIBUSB_TRANSFER_SHORT_NOT_OK; +const CHECK_LIBUSB_TRANSFER_FREE_BUFFER: number = usb.LIBUSB_TRANSFER_FREE_BUFFER; +const CHECK_LIBUSB_TRANSFER_FREE_TRANSFER: number = usb.LIBUSB_TRANSFER_FREE_TRANSFER; +// libusb_request_type +const CHECK_LIBUSB_REQUEST_TYPE_STANDARD: number = usb.LIBUSB_REQUEST_TYPE_STANDARD; +const CHECK_LIBUSB_REQUEST_TYPE_CLASS: number = usb.LIBUSB_REQUEST_TYPE_CLASS; +const CHECK_LIBUSB_REQUEST_TYPE_VENDOR: number = usb.LIBUSB_REQUEST_TYPE_VENDOR; +const CHECK_LIBUSB_REQUEST_TYPE_RESERVED: number = usb.LIBUSB_REQUEST_TYPE_RESERVED; +// libusb_request_recipient +const CHECK_LIBUSB_RECIPIENT_DEVICE: number = usb.LIBUSB_RECIPIENT_DEVICE; +const CHECK_LIBUSB_RECIPIENT_INTERFACE: number = usb.LIBUSB_RECIPIENT_INTERFACE; +const CHECK_LIBUSB_RECIPIENT_ENDPOINT: number = usb.LIBUSB_RECIPIENT_ENDPOINT; +const CHECK_LIBUSB_RECIPIENT_OTHER: number = usb.LIBUSB_RECIPIENT_OTHER; + +const CHECK_LIBUSB_CONTROL_SETUP_SIZE: number = usb.LIBUSB_CONTROL_SETUP_SIZE; + +// libusb_error +// Input/output error +const CHECK_LIBUSB_ERROR_IO: number = usb.LIBUSB_ERROR_IO; +// Invalid parameter +const CHECK_LIBUSB_ERROR_INVALID_PARAM: number = usb.LIBUSB_ERROR_INVALID_PARAM; +// Access denied (insufficient permissions) +const CHECK_LIBUSB_ERROR_ACCESS: number = usb.LIBUSB_ERROR_ACCESS; +// No such device (it may have been disconnected) +const CHECK_LIBUSB_ERROR_NO_DEVICE: number = usb.LIBUSB_ERROR_NO_DEVICE; +// Entity not found +const CHECK_LIBUSB_ERROR_NOT_FOUND: number = usb.LIBUSB_ERROR_NOT_FOUND; +// Resource busy +const CHECK_LIBUSB_ERROR_BUSY: number = usb.LIBUSB_ERROR_BUSY; +// Operation timed out +const CHECK_LIBUSB_ERROR_TIMEOUT: number = usb.LIBUSB_ERROR_TIMEOUT; +// Overflow +const CHECK_LIBUSB_ERROR_OVERFLOW: number = usb.LIBUSB_ERROR_OVERFLOW; +// Pipe error +const CHECK_LIBUSB_ERROR_PIPE: number = usb.LIBUSB_ERROR_PIPE; +// System call interrupted (perhaps due to signal) +const CHECK_LIBUSB_ERROR_INTERRUPTED: number = usb.LIBUSB_ERROR_INTERRUPTED; +// Insufficient memory +const CHECK_LIBUSB_ERROR_NO_MEM: number = usb.LIBUSB_ERROR_NO_MEM; +// Operation not supported or unimplemented on this platform +const CHECK_LIBUSB_ERROR_NOT_SUPPORTED: number = usb.LIBUSB_ERROR_NOT_SUPPORTED; +// Other error +const CHECK_LIBUSB_ERROR_OTHER: number = usb.LIBUSB_ERROR_OTHER; diff --git a/node-usb/node-usb.d.ts b/node-usb/node-usb.d.ts new file mode 100644 index 0000000000..0a52bdf127 --- /dev/null +++ b/node-usb/node-usb.d.ts @@ -0,0 +1,230 @@ +// Type definitions for node-usb 1.1.2 +// Project: https://github.com/nonolith/node-usb +// Definitions by: Eric Brody +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "usb" { + + class Device { + public timeout: number; + public busNumber: number; + public deviceAddress: number; + public portNumbers: Array; + public deviceDescriptor: DeviceDescriptor; + public configDescriptor: ConfigDescriptor; + public interfaces: Array; + + open(defaultConfig?: boolean): void; + close(): void; + interface(addr: number): Interface; + controlTransfer(bmRequestType: number, bRequest: number, wValue: number, wIndex: number, data_or_length: any, callback: (error?: string, buf?: Buffer) => void): Device; + getStringDescriptor(desc_index: number, callback: (error?: string, buf?: Buffer) => void): void; + setConfiguration(desired: number, cb: (err?: string) => void): void; + reset(callback: (err?: string) => void): void; + } + + class DeviceDescriptor { + public bLength: number; + public bDescriptorType: number; + public bcdUSB: number; + public bDeviceClass: number; + public bDeviceSubClass: number; + public bDeviceProtocol: number; + public bMaxPacketSize: number; + public idVendor: number; + public idProduct: number; + public bcdDevice: number; + public iManufacturer: number; + public iProduct: number; + public iSerialNumber: number; + public bNumConfigurations: number; + } + + class ConfigDescriptor { + public bLength: number; + public bDescriptorType: number; + public wTotalLength: number; + public bNumInterfaces: number; + public bConfigurationValue: number; + public iConfiguration: number; + public bmAttributes: number; + public bMaxPower: number; + public extra: Buffer; + } + + class Interface { + public descriptor: InterfaceDescriptor; + public endpoints: Array; + constructor(device: Device, id: number); + claim(): void; + release(closeEndpoints?: (err?: string) => void, cb?: (err?: string) => void): void; + isKernelDriverActive(): boolean; + detachKernelDriver(): number; + attachKernelDriver(): number; + setAltSetting(altSetting: number, cb: (err?: string) => void): void; + endpoint(addr: number): IEndpoint; + } + + class InterfaceDescriptor { + public bLength: number; + public bDescriptorType: number; + public bInterfaceNumber: number; + public bAlternateSetting: number; + public bNumEndpoints: number; + public bInterfaceClass: number; + public bInterfaceSubClass: number; + public bInterfaceProtocol: number; + public iInterface: number; + public extra: Buffer; + } + + interface IEndpoint { + direction: string; + transferType: number; + timeout: number; + descriptor: EndpointDescriptor; + } + + class InEndpoint implements IEndpoint { + public direction: string; + public transferType: number; + public timeout: number; + public descriptor: EndpointDescriptor; + constructor(device: Device, descriptor: EndpointDescriptor); + transfer(length: number, callback: (error: string, data: Buffer) => void): InEndpoint; + startPoll(nTransfers: number, transferSize: number): void; + stopPoll(cb: () => void): void; + } + + class OutEndpoint implements IEndpoint { + public direction: string; + public transferType: number; + public timeout: number; + public descriptor: EndpointDescriptor; + constructor(device: Device, descriptor: EndpointDescriptor); + transfer(buffer: Buffer, cb: (err?: string) => void): OutEndpoint; + transferWithZLP(buf: Buffer, cb: (err?: string) => void): void; + } + + class EndpointDescriptor { + public bLength: number; + public bDescriptorType: number; + public bEndpointAddress: number; + public bmAttributes: number; + public wMaxPacketSize: number; + public bInterval: number; + public bRefresh: number; + public bSynchAddress: number; + } + + function findByIds(vid: number, pid: number): Device; + function on(event: string, callback: (device: Device) => void): void; + function getDeviceList(): Array; + function setDebugLevel(level: number): void; + + const LIBUSB_CLASS_PER_INTERFACE: number; + const LIBUSB_CLASS_AUDIO: number; + const LIBUSB_CLASS_COMM: number; + const LIBUSB_CLASS_HID: number; + const LIBUSB_CLASS_PRINTER: number; + const LIBUSB_CLASS_PTP: number; + const LIBUSB_CLASS_MASS_STORAGE: number; + const LIBUSB_CLASS_HUB: number; + const LIBUSB_CLASS_DATA: number; + const LIBUSB_CLASS_WIRELESS: number; + const LIBUSB_CLASS_APPLICATION: number; + const LIBUSB_CLASS_VENDOR_SPEC: number; + // libusb_standard_request + const LIBUSB_REQUEST_GET_STATUS: number; + const LIBUSB_REQUEST_CLEAR_FEATURE: number; + const LIBUSB_REQUEST_SET_FEATURE: number; + const LIBUSB_REQUEST_SET_ADDRESS: number; + const LIBUSB_REQUEST_GET_DESCRIPTOR: number; + const LIBUSB_REQUEST_SET_DESCRIPTOR: number; + const LIBUSB_REQUEST_GET_CONFIGURATION: number; + const LIBUSB_REQUEST_SET_CONFIGURATION: number; + const LIBUSB_REQUEST_GET_INTERFACE: number; + const LIBUSB_REQUEST_SET_INTERFACE: number; + const LIBUSB_REQUEST_SYNCH_FRAME: number; + // libusb_descriptor_type + const LIBUSB_DT_DEVICE: number; + const LIBUSB_DT_CONFIG: number; + const LIBUSB_DT_STRING: number; + const LIBUSB_DT_INTERFACE: number; + const LIBUSB_DT_ENDPOINT: number; + const LIBUSB_DT_HID: number; + const LIBUSB_DT_REPORT: number; + const LIBUSB_DT_PHYSICAL: number; + const LIBUSB_DT_HUB: number; + // libusb_endpoint_direction + const LIBUSB_ENDPOINT_IN: number; + const LIBUSB_ENDPOINT_OUT: number; + // libusb_transfer_type + const LIBUSB_TRANSFER_TYPE_CONTROL: number; + const LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: number; + const LIBUSB_TRANSFER_TYPE_BULK: number; + const LIBUSB_TRANSFER_TYPE_INTERRUPT: number; + // libusb_iso_sync_type + const LIBUSB_ISO_SYNC_TYPE_NONE: number; + const LIBUSB_ISO_SYNC_TYPE_ASYNC: number; + const LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: number; + const LIBUSB_ISO_SYNC_TYPE_SYNC: number; + // libusb_iso_usage_type + const LIBUSB_ISO_USAGE_TYPE_DATA: number; + const LIBUSB_ISO_USAGE_TYPE_FEEDBACK: number; + const LIBUSB_ISO_USAGE_TYPE_IMPLICIT: number; + // libusb_transfer_status + const LIBUSB_TRANSFER_COMPLETED: number; + const LIBUSB_TRANSFER_ERROR: number; + const LIBUSB_TRANSFER_TIMED_OUT: number; + const LIBUSB_TRANSFER_CANCELLED: number; + const LIBUSB_TRANSFER_STALL: number; + const LIBUSB_TRANSFER_NO_DEVICE: number; + const LIBUSB_TRANSFER_OVERFLOW: number; + // libusb_transfer_flags + const LIBUSB_TRANSFER_SHORT_NOT_OK: number; + const LIBUSB_TRANSFER_FREE_BUFFER: number; + const LIBUSB_TRANSFER_FREE_TRANSFER: number; + // libusb_request_type + const LIBUSB_REQUEST_TYPE_STANDARD: number; + const LIBUSB_REQUEST_TYPE_CLASS: number; + const LIBUSB_REQUEST_TYPE_VENDOR: number; + const LIBUSB_REQUEST_TYPE_RESERVED: number; + // libusb_request_recipient + const LIBUSB_RECIPIENT_DEVICE: number; + const LIBUSB_RECIPIENT_INTERFACE: number; + const LIBUSB_RECIPIENT_ENDPOINT: number; + const LIBUSB_RECIPIENT_OTHER: number; + + const LIBUSB_CONTROL_SETUP_SIZE: number; + + // libusb_error + // Input/output error + const LIBUSB_ERROR_IO: number; + // Invalid parameter + const LIBUSB_ERROR_INVALID_PARAM: number; + // Access denied (insufficient permissions) + const LIBUSB_ERROR_ACCESS: number; + // No such device (it may have been disconnected) + const LIBUSB_ERROR_NO_DEVICE: number; + // Entity not found + const LIBUSB_ERROR_NOT_FOUND: number; + // Resource busy + const LIBUSB_ERROR_BUSY: number; + // Operation timed out + const LIBUSB_ERROR_TIMEOUT: number; + // Overflow + const LIBUSB_ERROR_OVERFLOW: number; + // Pipe error + const LIBUSB_ERROR_PIPE: number; + // System call interrupted (perhaps due to signal) + const LIBUSB_ERROR_INTERRUPTED: number; + // Insufficient memory + const LIBUSB_ERROR_NO_MEM: number; + // Operation not supported or unimplemented on this platform + const LIBUSB_ERROR_NOT_SUPPORTED: number; + // Other error + const LIBUSB_ERROR_OTHER: number; +} From 9dd59e8b12a5455719c1596fd18b62892834eb85 Mon Sep 17 00:00:00 2001 From: Marcel Good Date: Mon, 27 Jun 2016 10:40:24 -0700 Subject: [PATCH 33/67] Updated with changes from breeze.js master repo. --- breeze/breeze-tests.ts | 2 +- breeze/breeze.d.ts | 296 +++++++++++++++++++++++------------------ 2 files changed, 168 insertions(+), 130 deletions(-) diff --git a/breeze/breeze-tests.ts b/breeze/breeze-tests.ts index 022f4e3c16..7ddf30f5e9 100644 --- a/breeze/breeze-tests.ts +++ b/breeze/breeze-tests.ts @@ -883,7 +883,7 @@ function test_config() { o = config.getAdapter("myInterfaceName", "myAdapterName"); o = config.getAdapterInstance("myInterfaceName", "myAdapterName"); config.initializeAdapterInstance("myInterfaceName", "myAdapterName", true); - config.initializeAdapterInstances({ x: 3, y: "not" }); + config.initializeAdapterInstances({ ajax: "", dataService: "" }); s = config.interfaceInitialized.type; o = config.interfaceRegistry; o = config.objectRegistry; diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index 28a6be26c9..3fc54dc5d4 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -11,21 +11,22 @@ // Updated Jan 16 2015 for Breeze 1.4.17 to add support for noimplicitany - Kevin Wilson ( www.kwilson.me.uk ) // Updated Jan 20 2015 for Breeze 1.5.2 and merging changes from DefinitelyTyped // Updated Feb 28 2015 add any/all clause on Predicate +// Updated Jun 27 2016 - Marcel Good (www.ideablade.com) declare namespace breeze.core { - interface ErrorCallback { + export interface ErrorCallback { (error: Error): void; } - interface IEnum { + export interface IEnum { contains(object: any): boolean; fromName(name: string): EnumSymbol; getNames(): string[]; getSymbols(): EnumSymbol[]; } - class Enum implements IEnum { + export class Enum implements IEnum { constructor(name: string, methodObj?: any); addSymbol(propertiesObj?: any): EnumSymbol; @@ -37,14 +38,14 @@ declare namespace breeze.core { resolveSymbols(): void; } - class EnumSymbol { + export class EnumSymbol { parentEnum: IEnum; getName(): string; toString(): string; } - class Event { + export class Event { constructor(name: string, publisher: any, defaultErrorCallback?: ErrorCallback); static enable(eventName: string, target: any): void; @@ -91,25 +92,27 @@ declare namespace breeze.core { declare namespace breeze { - interface Entity { + export interface Entity { entityAspect: EntityAspect; entityType: EntityType; } - interface ComplexObject { + export interface ComplexObject { complexAspect: ComplexAspect; complexType: ComplexType; } - interface IProperty { + export interface IProperty { name: string; + nameOnServer: string; + displayName: string; parentType: IStructuralType; validators: Validator[]; isDataProperty: boolean; isNavigationProperty: boolean; } - interface IStructuralType { + export interface IStructuralType { complexProperties: DataProperty[]; dataProperties: DataProperty[]; name: string; @@ -119,13 +122,13 @@ declare namespace breeze { validators: Validator[]; } - class AutoGeneratedKeyType { + export class AutoGeneratedKeyType { static Identity: AutoGeneratedKeyType; static KeyGenerator: AutoGeneratedKeyType; static None: AutoGeneratedKeyType; } - class ComplexAspect { + export class ComplexAspect { complexObject: ComplexObject; getEntityAspect(): EntityAspect; parent: Object; @@ -134,7 +137,7 @@ declare namespace breeze { originalValues: Object; } - class ComplexType implements IStructuralType { + export class ComplexType implements IStructuralType { complexProperties: DataProperty[]; dataProperties: DataProperty[]; name: string; @@ -146,7 +149,7 @@ declare namespace breeze { getProperties(): DataProperty[]; } - class DataProperty implements IProperty { + export class DataProperty implements IProperty { complexTypeName: string; concurrencyMode: string; dataType: DataTypeSymbol; @@ -162,13 +165,14 @@ declare namespace breeze { maxLength: number; name: string; nameOnServer: string; + displayName: string; parentType: IStructuralType; relatedNavigationProperty: NavigationProperty; validators: Validator[]; constructor(config: DataPropertyOptions); } - interface DataPropertyOptions { + export interface DataPropertyOptions { complexTypeName?: string; concurrencyMode?: string; custom?: any; @@ -185,7 +189,7 @@ declare namespace breeze { validators?: Validator[]; } - class DataService { + export class DataService { adapterInstance: DataServiceAdapter; adapterName: string; hasServerMetadata: boolean; @@ -197,7 +201,7 @@ declare namespace breeze { using(config: DataServiceOptions): DataService; } - interface DataServiceOptions { + export interface DataServiceOptions { serviceName?: string; adapterName?: string; uriBuilderName?: string; @@ -206,7 +210,7 @@ declare namespace breeze { useJsonp?: boolean; } - class DataServiceAdapter { + export class DataServiceAdapter { checkForRecomposition(interfaceInitializedArgs: { interfaceName: string; isDefault: boolean }): void; initialize(): void; fetchMetadata(metadataStore: MetadataStore, dataService: DataService): breeze.promises.IPromise; @@ -215,7 +219,7 @@ declare namespace breeze { JsonResultsAdapter: JsonResultsAdapter; } - class JsonResultsAdapter { + export class JsonResultsAdapter { name: string; extractResults: (data: {}) => {}; visitNode: (node: {}, queryContext: QueryContext, nodeContext: NodeContext) => { entityType?: EntityType; nodeId?: any; nodeRefId?: any; ignore?: boolean; }; @@ -226,24 +230,24 @@ declare namespace breeze { }); } - interface QueryContext { + export interface QueryContext { url: string; - query: any; // how to also say it could be an EntityQuery or a string + query: EntityQuery | string; entityManager: EntityManager; dataService: DataService; queryOptions: QueryOptions; } - interface NodeContext { + export interface NodeContext { nodeType: string; } - class DataTypeSymbol extends breeze.core.EnumSymbol { + export class DataTypeSymbol extends breeze.core.EnumSymbol { defaultValue: any; isNumeric: boolean; isDate: boolean; } - interface DataType extends breeze.core.IEnum { + export interface DataType extends breeze.core.IEnum { Binary: DataTypeSymbol; Boolean: DataTypeSymbol; Byte: DataTypeSymbol; @@ -259,16 +263,36 @@ declare namespace breeze { String: DataTypeSymbol; Time: DataTypeSymbol; Undefined: DataTypeSymbol; + toDataType(typeName: string): DataTypeSymbol; parseDateFromServer(date: any): Date; defaultValue: any; isNumeric: boolean; - } - var DataType: DataType; + isInteger: boolean; - class EntityActionSymbol extends breeze.core.EnumSymbol { + /** Function to convert a value from string to this DataType. Note that this will be called each time a property is changed, so make it fast. */ + parse: (val: any, sourceTypeName: string) => any; + + /** Function to format this DataType for OData queries. */ + fmtOData: (val: any) => any; + + /** Optional function to get the next value for key generation, if this datatype is used as a key. Uses an internal table of previous values. */ + getNext?: () => any; + + /** Optional function to normalize a data value for comparison, if its value cannot be used directly. Note that this will be called each time a property is changed, so make it fast. */ + normalize?: (val: any) => any; + + /** Optional function to get the next value when the datatype is used as a concurrency property. */ + getConcurrencyValue?: (val: any) => any; + + /** Optional function to convert a raw (server) value from string to this DataType. */ + parseRawValue?: (val: any) => any; } - interface EntityAction extends breeze.core.IEnum { + export var DataType: DataType; + + export class EntityActionSymbol extends breeze.core.EnumSymbol { + } + export interface EntityAction extends breeze.core.IEnum { AcceptChanges: EntityActionSymbol; Attach: EntityActionSymbol; AttachOnImport: EntityActionSymbol; @@ -282,9 +306,9 @@ declare namespace breeze { PropertyChange: EntityActionSymbol; RejectChanges: EntityActionSymbol; } - var EntityAction: EntityAction; + export var EntityAction: EntityAction; - class EntityAspect { + export class EntityAspect { entity: Entity; entityManager: EntityManager; entityState: EntityStateSymbol; @@ -318,8 +342,6 @@ declare namespace breeze { removeValidationError(validator: Validator, property: NavigationProperty): void; removeValidationError(validationError: ValidationError): void; - /** Sets the entity to an EntityState of 'Added'. This is NOT the equivalent of calling {{#crossLink "EntityManager/addEntity"}}{{/crossLink}} - because no key generation will occur for autogenerated keys as a result of this operation. */ setAdded(): void; setDeleted(): void; setDetached(): void; @@ -333,7 +355,7 @@ declare namespace breeze { validateProperty(property: NavigationProperty, context?: any): boolean; } - class PropertyChangedEventArgs { + export class PropertyChangedEventArgs { entity: Entity; property: IProperty; propertyName: string; @@ -342,21 +364,21 @@ declare namespace breeze { parent: any; } - class PropertyChangedEvent extends breeze.core.Event { + export class PropertyChangedEvent extends breeze.core.Event { subscribe(callback?: (data: PropertyChangedEventArgs) => void): number; } - class ValidationErrorsChangedEventArgs { + export class ValidationErrorsChangedEventArgs { entity: Entity; added: ValidationError[]; removed: ValidationError[]; } - class ValidationErrorsChangedEvent extends breeze.core.Event { + export class ValidationErrorsChangedEvent extends breeze.core.Event { subscribe(callback?: (data: ValidationErrorsChangedEventArgs) => void): number; } - class EntityKey { + export class EntityKey { constructor(entityType: EntityType, keyValue: any); constructor(entityType: EntityType, keyValues: any[]); @@ -366,17 +388,17 @@ declare namespace breeze { values: any[]; } - interface EntityByKeyResult { + export interface EntityByKeyResult { entity: Entity; entityKey: EntityKey; fromCache: boolean; } - interface ExportEntitiesOptions { + export interface ExportEntitiesOptions { asString: boolean; // default true includeMetadata: boolean; // default true } - class EntityManager { + export class EntityManager { dataService: DataService; keyGeneratorCtor: Function; metadataStore: MetadataStore; @@ -392,7 +414,7 @@ declare namespace breeze { constructor(config?: EntityManagerOptions); constructor(config?: string); - acceptChanges(): void; + acceptChanges(): void; addEntity(entity: Entity): Entity; attachEntity(entity: Entity, entityState?: EntityStateSymbol, mergeStrategy?: MergeStrategySymbol): Entity; clear(): void; @@ -447,7 +469,7 @@ declare namespace breeze { setProperties(config: EntityManagerProperties): void; } - interface EntityManagerOptions { + export interface EntityManagerOptions { serviceName?: string; dataService?: DataService; metadataStore?: MetadataStore; @@ -457,7 +479,7 @@ declare namespace breeze { keyGeneratorCtor?: Function; } - interface EntityManagerProperties { + export interface EntityManagerProperties { serviceName?: string; dataService?: DataService; metadataStore?: MetadataStore; @@ -467,19 +489,19 @@ declare namespace breeze { keyGeneratorCtor?: Function; } - interface ExecuteQuerySuccessCallback { + export interface ExecuteQuerySuccessCallback { (data: QueryResult): void; } - interface ExecuteQueryErrorCallback { + export interface ExecuteQueryErrorCallback { (error: { query: EntityQuery; httpResponse: HttpResponse; entityManager: EntityManager; message?: string; stack?:string }): void; } - interface SaveChangesSuccessCallback { + export interface SaveChangesSuccessCallback { (saveResult: SaveResult): void; } - interface EntityError { + export interface EntityError { entity: Entity; errorMessage: string; errorName: string; @@ -487,7 +509,7 @@ declare namespace breeze { propertyName: string; } - interface SaveChangesErrorCallback { + export interface SaveChangesErrorCallback { (error: { entityErrors: EntityError[]; httpResponse: HttpResponse; @@ -497,26 +519,26 @@ declare namespace breeze { }): void; } - class EntityChangedEventArgs { + export class EntityChangedEventArgs { entity: Entity; entityAction: EntityActionSymbol; args: Object; } - class EntityChangedEvent extends breeze.core.Event { + export class EntityChangedEvent extends breeze.core.Event { subscribe(callback?: (data: EntityChangedEventArgs) => void): number; } - class HasChangesChangedEventArgs { + export class HasChangesChangedEventArgs { entityManager: EntityManager; hasChanges: boolean; } - class HasChangesChangedEvent extends breeze.core.Event { + export class HasChangesChangedEvent extends breeze.core.Event { subscribe(callback?: (data: HasChangesChangedEventArgs) => void): number; } - class EntityQuery { + export class EntityQuery { entityManager: EntityManager; orderByClause: OrderByClause; parameters: Object; @@ -573,10 +595,10 @@ declare namespace breeze { toJSON(): string; } - interface OrderByClause { + export interface OrderByClause { } - class EntityStateSymbol extends breeze.core.EnumSymbol { + export class EntityStateSymbol extends breeze.core.EnumSymbol { isAdded(): boolean; isAddedModifiedOrDeleted(): boolean; isDeleted(): boolean; @@ -585,16 +607,16 @@ declare namespace breeze { isUnchanged(): boolean; isUnchangedOrModified(): boolean; } - interface EntityState extends breeze.core.IEnum { + export interface EntityState extends breeze.core.IEnum { Added: EntityStateSymbol; Deleted: EntityStateSymbol; Detached: EntityStateSymbol; Modified: EntityStateSymbol; Unchanged: EntityStateSymbol; } - var EntityState: EntityState; + export var EntityState: EntityState; - class EntityType implements IStructuralType { + export class EntityType implements IStructuralType { autoGeneratedKeyType: AutoGeneratedKeyType; baseEntityType: EntityType; complexProperties: DataProperty[]; @@ -630,7 +652,7 @@ declare namespace breeze { toString(): string; } - interface EntityTypeOptions { + export interface EntityTypeOptions { shortName?: string; namespace?: string; autoGeneratedKeyType?: AutoGeneratedKeyType; @@ -639,24 +661,24 @@ declare namespace breeze { navigationProperties?: NavigationProperty[]; } - interface EntityTypeProperties { + export interface EntityTypeProperties { autoGeneratedKeyType?: AutoGeneratedKeyType; defaultResourceName?: string; serializerFn?: (dataProperty: DataProperty, value: any) => any; } - class FetchStrategySymbol extends breeze.core.EnumSymbol { + export class FetchStrategySymbol extends breeze.core.EnumSymbol { private foo; // to distinguish this class from MergeStrategySymbol } - interface FetchStrategy extends breeze.core.IEnum { + export interface FetchStrategy extends breeze.core.IEnum { FromLocalCache: FetchStrategySymbol; FromServer: FetchStrategySymbol; } - var FetchStrategy: FetchStrategy; + export var FetchStrategy: FetchStrategy; - class FilterQueryOpSymbol extends breeze.core.EnumSymbol { + export class FilterQueryOpSymbol extends breeze.core.EnumSymbol { } - interface FilterQueryOp extends breeze.core.IEnum { + export interface FilterQueryOp extends breeze.core.IEnum { Contains: FilterQueryOpSymbol; EndsWith: FilterQueryOpSymbol; Equals: FilterQueryOpSymbol; @@ -670,9 +692,9 @@ declare namespace breeze { Any: FilterQueryOpSymbol; All: FilterQueryOpSymbol; } - var FilterQueryOp: FilterQueryOp; + export var FilterQueryOp: FilterQueryOp; - class LocalQueryComparisonOptions { + export class LocalQueryComparisonOptions { static caseInsensitiveSQL: LocalQueryComparisonOptions; static defaultInstance: LocalQueryComparisonOptions; @@ -681,17 +703,17 @@ declare namespace breeze { setAsDefault(): void; } - class MergeStrategySymbol extends breeze.core.EnumSymbol { + export class MergeStrategySymbol extends breeze.core.EnumSymbol { } - interface MergeStrategy extends breeze.core.IEnum { + export interface MergeStrategy extends breeze.core.IEnum { OverwriteChanges: MergeStrategySymbol; PreserveChanges: MergeStrategySymbol; SkipMerge: MergeStrategySymbol; Disallowed: MergeStrategySymbol; } - var MergeStrategy: MergeStrategy; + export var MergeStrategy: MergeStrategy; - class MetadataStore { + export class MetadataStore { constructor(); constructor(config?: MetadataStoreOptions); namingConvention: NamingConvention; @@ -707,7 +729,7 @@ declare namespace breeze { static importMetadata(exportedString: string): MetadataStore; importMetadata(exportedString: string, allowMerge?: boolean): MetadataStore; isEmpty(): boolean; - registerEntityTypeCtor(entityTypeName: string, entityCtor: Function, initializationFn?: (entity: Entity) => void, noTrackingFn?: (entity: Entity) => Entity): void; + registerEntityTypeCtor(entityTypeName: string, entityCtor: Function, initializationFn?: (entity: Entity) => void, noTrackingFn?: (node: Object, entityType: EntityType) => Object): void; trackUnmappedType(entityCtor: Function, interceptor?: Function): void; setEntityTypeForResourceName(resourceName: string, entityType: EntityType): void; setEntityTypeForResourceName(resourceName: string, entityTypeName: string): void; @@ -715,12 +737,12 @@ declare namespace breeze { setProperties(config: { name?: string; serializerFn?: Function }): void; } - interface MetadataStoreOptions { + export interface MetadataStoreOptions { namingConvention?: NamingConvention; localQueryComparisonOptions?: LocalQueryComparisonOptions; } - class NamingConvention { + export class NamingConvention { static camelCase: NamingConvention; static defaultInstance: NamingConvention; static none: NamingConvention; @@ -736,12 +758,12 @@ declare namespace breeze { setAsDefault(): NamingConvention; } - interface NamingConventionOptions { + export interface NamingConventionOptions { serverPropertyNameToClient?: (name: string) => string; clientPropertyNameToServer?: (name: string) => string; } - class NavigationProperty implements IProperty { + export class NavigationProperty implements IProperty { associationName: string; entityType: EntityType; foreignKeyNames: string[]; @@ -750,6 +772,8 @@ declare namespace breeze { isNavigationProperty: boolean; isScalar: boolean; name: string; + nameOnServer: string; + displayName: string; parentType: IStructuralType; relatedDataProperties: DataProperty[]; validators: Validator[]; @@ -757,7 +781,7 @@ declare namespace breeze { constructor(config: NavigationPropertyOptions); } - interface NavigationPropertyOptions { + export interface NavigationPropertyOptions { name?: string; nameOnServer?: string; entityTypeName: string; @@ -768,15 +792,21 @@ declare namespace breeze { validators?: Validator[]; } - class Predicate { + export interface IRecursiveArray { + [i: number]: T | IRecursiveArray; + } + + export class Predicate { + constructor(); constructor(property: string, operator: string, value: any); constructor(property: string, operator: FilterQueryOpSymbol, value: any); constructor(property: string, operator: string, value: { value: any; isLiteral?: boolean; dataType?: breeze.DataType }); constructor(property: string, operator: FilterQueryOpSymbol, value: { value: any; isLiteral?: boolean; dataType?: breeze.DataType }); constructor(property: string, filterop: FilterQueryOpSymbol, property2: string, filterop2: FilterQueryOpSymbol, value: any); // for any/all clauses constructor(property: string, filterop: string, property2: string, filterop2: string, value: any); // for any/all clauses - /** Create predicate from an expression tree */ - constructor(tree: Object); + constructor(passthru: string); + constructor(predicate: Predicate); + constructor(anArray: IRecursiveArray); and: PredicateMethod; static and: PredicateMethod; @@ -798,7 +828,7 @@ declare namespace breeze { toJSON(): string; } - interface PredicateMethod { + export interface PredicateMethod { (predicates: Predicate[]): Predicate; (...predicates: Predicate[]): Predicate; (property: string, operator: string, value: any, valueIsLiteral?: boolean): Predicate; @@ -807,7 +837,7 @@ declare namespace breeze { (property: string, filterop: string, property2: string, filterop2: string, value: any): Predicate; // for any/all clauses } - class QueryOptions { + export class QueryOptions { static defaultInstance: QueryOptions; fetchStrategy: FetchStrategySymbol; mergeStrategy: MergeStrategySymbol; @@ -822,12 +852,12 @@ declare namespace breeze { using(config: FetchStrategySymbol): QueryOptions; } - interface QueryOptionsConfiguration { + export interface QueryOptionsConfiguration { fetchStrategy?: FetchStrategySymbol; mergeStrategy?: MergeStrategySymbol; } - interface HttpResponse { + export interface HttpResponse { config: any; data: Entity[]; error?: any; @@ -836,7 +866,7 @@ declare namespace breeze { getHeaders(headerName: string): string } - interface QueryResult { + export interface QueryResult { /** Top level entities returned */ results: Entity[]; /** Query that was executed */ @@ -851,33 +881,33 @@ declare namespace breeze { retrievedEntities?: Entity[] } - class SaveOptions { + export class SaveOptions { allowConcurrentSaves: boolean; resourceName: string; dataService: DataService; tag: Object; static defaultInstance: SaveOptions; - constructor(config?: { allowConcurrentSaves?: boolean; resourceName?: string; dataService?: DataService; tag?: any}); + constructor(config?: { allowConcurrentSaves?: boolean; resourceName?: string; dataService?: DataService; tag?: any }); setAsDefault(): SaveOptions; using(config: SaveOptionsConfiguration): SaveOptions; } - interface SaveOptionsConfiguration { + export interface SaveOptionsConfiguration { allowConcurrentSaves?: boolean; resourceName?: string; dataService?: DataService; tag?: Object; } - interface SaveResult { + export interface SaveResult { entities: Entity[]; keyMappings: any; XHR: XMLHttpRequest; } - class ValidationError { + export class ValidationError { key: string; context: any; errorMessage: string; @@ -889,7 +919,7 @@ declare namespace breeze { constructor(validator: Validator, context: any, errorMessage: string, key: string); } - class ValidationOptions { + export class ValidationOptions { static defaultInstance: ValidationOptions; validateOnAttach: boolean; validateOnPropertyChange: boolean; @@ -902,14 +932,14 @@ declare namespace breeze { using(config: ValidationOptionsConfiguration): ValidationOptions; } - interface ValidationOptionsConfiguration { + export interface ValidationOptionsConfiguration { validateOnAttach?: boolean; validateOnSave?: boolean; validateOnQuery?: boolean; validateOnPropertyChange?: boolean; } - class Validator { + export class Validator { /** Map of standard error message templates keyed by validator name.*/ static messageTemplates: any; context: any; @@ -962,7 +992,7 @@ declare namespace breeze { /** Creates a regular expression validator with a fixed expression. */ static makeRegExpValidator(validatorName: string, expression: RegExp, defaultMessage: string, context?: any): Validator; - /** Run this validator against the specified value. + /** Run this validator against the specified value. @param value {Object} Value to validate @param additionalContext {Object} Any additional contextual information that the Validator can make use of. @return {ValidationError|null} A ValidationError if validation fails, null otherwise */ @@ -972,11 +1002,11 @@ declare namespace breeze { getMessage(): string; } - interface ValidatorFunction { + export interface ValidatorFunction { (value: any, context: ValidatorFunctionContext): void; } - interface ValidatorFunctionContext { + export interface ValidatorFunctionContext { value: any; validatorName: string; displayName: string; @@ -984,84 +1014,89 @@ declare namespace breeze { message?: string; } - var metadataVersion: string; - var remoteAccess_odata: string; - var remoteAccess_webApi: string; - var version: string; + export var metadataVersion: string; + export var remoteAccess_odata: string; + export var remoteAccess_webApi: string; + export var version: string; + } declare namespace breeze.config { - var ajax: string; - var dataService: string; - var functionRegistry: Object; + + export var ajax: string; + export var dataService: string; + export var functionRegistry: Object; /** Returns the ctor function used to implement a specific interface with a specific adapter name. - @method getAdapter @param interfaceName {String} One of the following interface names "ajax", "dataService" or "modelLibrary" - @param [adapterName] {String} The name of any previously registered adapter. If this parameter is omitted then + @param adapterName {String} The name of any previously registered adapter. If this parameter is omitted then this method returns the "default" adapter for this interface. If there is no default adapter, then a null is returned. - @return {Function|null} Returns either a ctor function or null. + @returns {Function|null} Returns either a ctor function or null. **/ export function getAdapter(interfaceName: string, adapterName?: string): Function; /** Returns the adapter instance corresponding to the specified interface and adapter names. - @method getAdapterInstance @param interfaceName {String} The name of the interface. - @param [adapterName] {String} - The name of a previously registered adapter. If this parameter is + @param adapterName {String} - The name of a previously registered adapter. If this parameter is omitted then the default implementation of the specified interface is returned. If there is no defaultInstance of this interface, then the first registered instance of this interface is returned. @return {an instance of the specified adapter} **/ export function getAdapterInstance(interfaceName: string, adapterName?: string): Object; /** - Initializes a single adapter implementation. Initialization means either newing a instance of the + Initializes a single adapter implementation. Initialization means either newing a instance of the specified interface and then calling "initialize" on it or simply calling "initialize" on the instance if it already exists. - @method initializeAdapterInstance @param interfaceName {String} The name of the interface to which the adapter to initialize belongs. @param adapterName {String} - The name of a previously registered adapter to initialize. - @param [isDefault=true] {Boolean} - Whether to make this the default "adapter" for this interface. + @param isDefault=true {Boolean} - Whether to make this the default "adapter" for this interface. @return {an instance of the specified adapter} **/ export function initializeAdapterInstance(interfaceName: string, adapterName: string, isDefault?: boolean): void; + + export interface AdapterInstancesConfig { + /** the name of a previously registered "ajax" adapter */ + ajax?: string; + /** the name of a previously registered "dataService" adapter */ + dataService?: string; + /** the name of a previously registered "modelLibrary" adapter */ + modelLibary?: string; + /** the name of a previously registered "uriBuilder" adapter */ + uriBuilder?: string; + } /** Initializes a collection of adapter implementations and makes each one the default for its corresponding interface. - @method initializeAdapterInstances - @param config {Object} - @param [config.ajax] {String} - the name of a previously registered "ajax" adapter - @param [config.dataService] {String} - the name of a previously registered "dataService" adapter - @param [config.modelLibrary] {String} - the name of a previously registered "modelLibrary" adapter - @param [config.uriBuilder] {String} - the name of a previously registered "uriBuilder" adapter + @param config {AdapterInstancesConfig} @return [array of instances] **/ - export function initializeAdapterInstances(config: Object): Object[]; - var interfaceInitialized: Event; - var interfaceRegistry: Object; - var objectRegistry: Object; + export function initializeAdapterInstances(config: AdapterInstancesConfig): Object[]; + export var interfaceInitialized: Event; + export var interfaceRegistry: Object; + export var objectRegistry: Object; /** Method use to register implementations of standard breeze interfaces. Calls to this method are usually - made as the last step within an adapter implementation. - @method registerAdapter + made as the last step within an adapter implementation. @param interfaceName {String} - one of the following interface names "ajax", "dataService" or "modelLibrary" - @param adapterCtor {Function} - an ctor function that returns an instance of the specified interface. + @param adapterCtor {Function} - an ctor function that returns an instance of the specified interface. **/ export function registerAdapter(interfaceName: string, adapterCtor: Function): void; export function registerFunction(fn: Function, fnName: string): void; export function registerType(ctor: Function, typeName: string): void; //static setProperties(config: Object): void; //deprecated - /** + /** Set the promise implementation, if Q.js is not found. @param q - implementation of promise. @see http://wiki.commonjs.org/wiki/Promises/A */ export function setQ(q: breeze.promises.IPromiseService): void; - var stringifyPad: string; - var typeRegistry: Object; + export var stringifyPad: string; + export var typeRegistry: Object; } /** Promises interface used by Breeze. Usually implemented by Q (https://github.com/kriskowal/q) or angular.$q using breeze.config.setQ(impl) */ declare namespace breeze.promises { - interface IPromise { + + export interface IPromise { then(onFulfill: (value: T) => U, onReject?: (reason: any) => U): IPromise; then(onFulfill: (value: T) => IPromise, onReject?: (reason: any) => U): IPromise; then(onFulfill: (value: T) => U, onReject?: (reason: any) => IPromise): IPromise; @@ -1071,13 +1106,13 @@ declare namespace breeze.promises { finally(finallyCallback: () => any): IPromise; } - interface IDeferred { + export interface IDeferred { promise: IPromise; resolve(value: T): void; reject(reason: any): void; } - interface IPromiseService { + export interface IPromiseService { defer(): IDeferred; reject(reason?: any): IPromise; resolve(object: T): IPromise; @@ -1085,3 +1120,6 @@ declare namespace breeze.promises { } } +declare module "breeze" { + export = breeze; +} From 44446cecd77f05a429d8b7cf6fe33e1964abe9e4 Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Wed, 29 Jun 2016 21:27:14 -0400 Subject: [PATCH 34/67] Updated to more accurate 'types' --- suitescript/suitescript.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/suitescript/suitescript.d.ts b/suitescript/suitescript.d.ts index e3517b37ef..b4e6a740d8 100644 --- a/suitescript/suitescript.d.ts +++ b/suitescript/suitescript.d.ts @@ -54,7 +54,7 @@ declare namespace nlobjRecord.prototype { /** * */ - getLineItemCount : /* nlobjSubList.prototype.getLineItemCount */ any; + getLineItemCount : /* nlobjSubList.prototype.getLineItemCount */ string|number; /** * @@ -314,7 +314,7 @@ declare namespace nlobjAssistant.prototype { /** * */ - getLineItemCount : /* nlobjAssistantStep.prototype.getLineItemCount */ any; + getLineItemCount : /* nlobjAssistantStep.prototype.getLineItemCount */ string|number; /** * @@ -1236,7 +1236,7 @@ declare function nlapiGetLineItemDateTimeValue(type:string, fldnam:string, linen * @param linenum * @param value */ -declare function nlapiSetLineItemValue(type:string, fldnam:string, linenum:any, value:any):void; +declare function nlapiSetLineItemValue(type:string, fldnam:string, linenum:any, value:string|number):void; /** * Set the value of a sublist field on the current record on a page. @@ -1331,7 +1331,7 @@ declare function nlapiGetMatrixCount(type:string, fldnam:string):any; * @param type * @return */ -declare function nlapiGetLineItemCount(type:string):any; +declare function nlapiGetLineItemCount(type:string):string|number; /** * Insert and select a new line into the sublist on a page or userevent. @@ -3017,7 +3017,7 @@ declare interface nlobjRecord { * @since 2009.2 * @param group */ - getLineItemCount(group:string): any; + getLineItemCount(group:string): string|number; /** * Return line number for 1st occurence of field value in a sublist column. @@ -4679,7 +4679,7 @@ declare interface nlobjRequest { * @param group * @return */ - getLineItemCount(group:string): any; + getLineItemCount(group:string): string|number; /** * return the value of a request header. @@ -6171,7 +6171,7 @@ declare interface nlobjSubList { * @since 2010.1 * @param group */ - getLineItemCount(group:string): any; + getLineItemCount(group:string): string|number; /** * add a field (column) to this sublist. From ba12fade9c56f0b48b3a73e1f44014fdf05ba154 Mon Sep 17 00:00:00 2001 From: Sean Kelley Date: Wed, 29 Jun 2016 11:07:36 -0700 Subject: [PATCH 35/67] Add typings for react-is-deprecated. --- .../react-is-deprecated-tests.ts | 17 +++++++++ react-is-deprecated/react-is-deprecated.d.ts | 38 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 react-is-deprecated/react-is-deprecated-tests.ts create mode 100644 react-is-deprecated/react-is-deprecated.d.ts diff --git a/react-is-deprecated/react-is-deprecated-tests.ts b/react-is-deprecated/react-is-deprecated-tests.ts new file mode 100644 index 0000000000..f5574e44cf --- /dev/null +++ b/react-is-deprecated/react-is-deprecated-tests.ts @@ -0,0 +1,17 @@ +/// +/// + +import { PropTypes } from 'react'; +import { deprecate, addIsDeprecated } from 'react-is-deprecated'; + +// test: one-off deprecation +deprecate(PropTypes.string, 'message'); + +// test: one-off deprecated with isRequired +deprecate(PropTypes.string.isRequired, 'message'); + +// test: isDeprecated is added to a proptype +addIsDeprecated(PropTypes).string.isDeprecated('message'); + +// test: isRequired is still present on that proptype +addIsDeprecated(PropTypes).string.isRequired; diff --git a/react-is-deprecated/react-is-deprecated.d.ts b/react-is-deprecated/react-is-deprecated.d.ts new file mode 100644 index 0000000000..88a34306a5 --- /dev/null +++ b/react-is-deprecated/react-is-deprecated.d.ts @@ -0,0 +1,38 @@ +// Type definitions for react-is-deprecated v0.1.2 +// Project: https://github.com/Aweary/react-is-deprecated +// Definitions by: Sean Kelley +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module 'react-is-deprecated' { + import { Validator, Requireable, ValidationMap, ReactPropTypes } from 'react'; + + export function deprecate(validator: Validator, message: string): Validator; + + interface Deprecatable { + isDeprecated: (message: string) => Validator; + } + + // Unfortunately this copy-paste must happen -- I can't just take PropTypes and programmatically + // define a version that intersects in the Deprecatable interface into the keys. + interface DeprecatablePropTypes { + any: Requireable & Deprecatable; + array: Requireable & Deprecatable; + bool: Requireable & Deprecatable; + func: Requireable & Deprecatable; + number: Requireable & Deprecatable; + object: Requireable & Deprecatable; + string: Requireable & Deprecatable; + node: Requireable & Deprecatable; + element: Requireable & Deprecatable; + instanceOf(expectedClass: {}): Requireable & Deprecatable; + oneOf(types: any[]): Requireable & Deprecatable; + oneOfType(types: Validator[]): Requireable & Deprecatable; + arrayOf(type: Validator): Requireable & Deprecatable; + objectOf(type: Validator): Requireable & Deprecatable; + shape(type: ValidationMap): Requireable & Deprecatable; + } + + export function addIsDeprecated(propTypes: ReactPropTypes): DeprecatablePropTypes; +} From cff418127d1d43ff431079cc40035c146496955e Mon Sep 17 00:00:00 2001 From: LionelB Date: Thu, 30 Jun 2016 09:39:50 +0200 Subject: [PATCH 36/67] update angular-websocket service paramters --- angular-websocket/angular-websocket-tests.ts | 26 +++++++++++++++++++- angular-websocket/angular-websocket.d.ts | 14 ++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/angular-websocket/angular-websocket-tests.ts b/angular-websocket/angular-websocket-tests.ts index 980e2001d3..e7cb30fe49 100644 --- a/angular-websocket/angular-websocket-tests.ts +++ b/angular-websocket/angular-websocket-tests.ts @@ -2,11 +2,35 @@ let dummySocket: ng.websocket.IWebSocket; let dummyPromise: ng.IPromise; +let dummyScope: ng.IScope; -let provider: ng.websocket.IWebSocketProvider = (url: string) => { +let provider: ng.websocket.IWebSocketProvider = (url: string, protocols?:string[] | ng.websocket.IWebSocketConfigOptions, options?: ng.websocket.IWebSocketConfigOptions) => { return dummySocket; } +let socketWithProtocol = provider("wss://localhost", "protocol"); +let socketWithProtocols = provider("wss://localhost", ["protocol-a", "protocol-b"]); + +let socketWithOptions = provider("wss://localhost", { + scope: dummyScope, + rootScopeFailOver: true, + useApplyAsync: true, + initialTimeout: 100, + maxTimeout: 300000, + reconnectIfNotNormalClose: true, + binaryType: "blob" +}); + +let socketWithProtocolAndOptions = provider("wss://localhost", "protocol", { + scope: dummyScope, + rootScopeFailOver: true, + useApplyAsync: true, + initialTimeout: 100, + maxTimeout: 300000, + reconnectIfNotNormalClose: true, + binaryType: "blob" +}); + let socket = provider("wss://localhost"); socket.onOpen((event) => {}) diff --git a/angular-websocket/angular-websocket.d.ts b/angular-websocket/angular-websocket.d.ts index a01e5eab3e..6929561f9c 100644 --- a/angular-websocket/angular-websocket.d.ts +++ b/angular-websocket/angular-websocket.d.ts @@ -7,6 +7,18 @@ declare namespace angular.websocket { + /** + * Options available to be specified for IWebSocketProvider. + */ + type IWebSocketConfigOptions = { + scope?: ng.IScope; + rootScopeFailOver?: boolean; + useApplyAsync?: boolean; + initialTimeout?: number; + maxTimeout?: number; + binaryType?: "blob" | "arraybuffer"; + reconnectIfNotNormalClose?: boolean; + } interface IWebSocketProvider { /** * Creates and opens an IWebSocket instance. @@ -14,7 +26,7 @@ declare namespace angular.websocket { * @param url url to connect to * @return websocket instance */ - (url: string): IWebSocket; + (url: string, protocols?: string | string[] | IWebSocketConfigOptions, options?: IWebSocketConfigOptions): IWebSocket; } /** Options available to be specified for IWebSocket.onMessage */ From 706a6d27ed18500149c10a4cb507029bf62e2f43 Mon Sep 17 00:00:00 2001 From: nkovacic Date: Thu, 30 Jun 2016 10:55:56 +0200 Subject: [PATCH 37/67] Fixed constructor possible recursion, more precise function definition for modifiers and more tests for them. --- dot-object/dot-object-tests.ts | 11 +++++++---- dot-object/dot-object.d.ts | 23 +++++++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/dot-object/dot-object-tests.ts b/dot-object/dot-object-tests.ts index c6098defd2..ca7aa3f676 100644 --- a/dot-object/dot-object-tests.ts +++ b/dot-object/dot-object-tests.ts @@ -1,6 +1,5 @@ /// - var obj = { 'first_name': 'John', 'last_name': 'Doe' @@ -21,7 +20,9 @@ var src = { var tgt = {name: 'Brandon'}; -dot.copy('stuff.phone', 'wanna.haves.phone', src, tgt); +dot.copy('stuff.phone', 'wanna.haves.phone', src, tgt, [(arg: any) => { + return arg; +}]); dot.transfer('stuff.phone', 'wanna.haves.phone', src, tgt); @@ -37,7 +38,9 @@ var row = { 'some.other.things.1': 'that' }; -dot.object(row); +dot.object(row, (arg: any) => { + return arg; +}); dot.str('this.is.my.string', 'value', tgt); @@ -61,4 +64,4 @@ val = dot.remove('some.nested.value', newObj); // or use the alias `del` val = dot.del('some.nested.value', newObj); -var dot = new dot('=>'); \ No newline at end of file +var dotWithArrow = new dot('=>'); \ No newline at end of file diff --git a/dot-object/dot-object.d.ts b/dot-object/dot-object.d.ts index f87fc0aa53..953291c631 100644 --- a/dot-object/dot-object.d.ts +++ b/dot-object/dot-object.d.ts @@ -5,8 +5,15 @@ declare namespace DotObject { - interface Dot { + interface DotConstructor extends Dot { new(separator: string): Dot; + } + + interface ModifierFunctionWrapper { + (arg: any): any; + } + + interface Dot { /** * * Copy a property from one object to another object. @@ -21,7 +28,7 @@ declare namespace DotObject { * @param {Function|Array} mods * @param {Boolean} merge */ - copy(source: string, target: string, obj1: any, obj2: any, mods?: Function | Array, merge?: boolean): void; + copy(source: string, target: string, obj1: any, obj2: any, mods?: ModifierFunctionWrapper | Array, merge?: boolean): void; /** * * Convert object to dotted-key/value pair @@ -61,7 +68,7 @@ declare namespace DotObject { * @param {Function|Array} mods * @param {Boolean} merge */ - move(source: string, target: string, obj: any, mods?: Function | Array, merge?: boolean): void; + move(source: string, target: string, obj: any, mods?: ModifierFunctionWrapper | Array, merge?: boolean): void; /** * * Converts an object with dotted-key/value pairs to it's expanded version @@ -84,7 +91,7 @@ declare namespace DotObject { * @param {Object} obj * @param {Object} mods */ - object(obj: any, mods?: Function | Array): void; + object(obj: any, mods?: ModifierFunctionWrapper | Array): void; /** * * Pick a value from an object using dot notation. @@ -111,7 +118,7 @@ declare namespace DotObject { * @param {Object} obj object to be modified * @param {Function|Array} mods optional modifier */ - str(path: string, v: any, obj: Object, mods?: Function | Array): void; + str(path: string, v: any, obj: Object, mods?: ModifierFunctionWrapper | Array): void; /** * * Transfer a property from one object to another object. @@ -126,7 +133,7 @@ declare namespace DotObject { * @param {Function|Array} mods * @param {Boolean} merge */ - transfer(source: string, target: string, obj1: any, obj2: any, mods?: Function | Array, merge?: boolean): void; + transfer(source: string, target: string, obj1: any, obj2: any, mods?: ModifierFunctionWrapper | Array, merge?: boolean): void; /** * * Transform an object @@ -151,11 +158,11 @@ declare namespace DotObject { * @param {Object} obj Object to be transformed * @param {Array} mods modifiers for the target */ - transform(recipe: any, obj: any, mods?: Function | Array): void; + transform(recipe: any, obj: any, mods?: ModifierFunctionWrapper | Array): void; } } -declare var dot: DotObject.Dot; +declare var dot: DotObject.DotConstructor; declare module 'dot-object' { export = dot; From 99a779e9eb0c473ee65e49438b348bf7e9a97b84 Mon Sep 17 00:00:00 2001 From: Leon Yu Date: Thu, 30 Jun 2016 05:31:31 -0400 Subject: [PATCH 38/67] google-libphonenumber --- .../google-libphonenumber-tests.ts | 36 ++++++++++++++++++ .../google-libphonenumber.d.ts | 38 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 google-libphonenumber/google-libphonenumber-tests.ts create mode 100644 google-libphonenumber/google-libphonenumber.d.ts diff --git a/google-libphonenumber/google-libphonenumber-tests.ts b/google-libphonenumber/google-libphonenumber-tests.ts new file mode 100644 index 0000000000..0768f0f7a9 --- /dev/null +++ b/google-libphonenumber/google-libphonenumber-tests.ts @@ -0,0 +1,36 @@ +/// + +import libphonenumber = require('google-libphonenumber'); +import {PhoneNumberFormat, PhoneNumberUtil, AsYouTypeFormatter} from 'google-libphonenumber'; + +() => { + // Require `PhoneNumberFormat`. + var PNF = libphonenumber.PhoneNumberFormat; + + // Get an instance of `PhoneNumberUtil`. + var phoneUtil = libphonenumber.PhoneNumberUtil.getInstance(); + + // Parse number with country code. + var phoneNumber = phoneUtil.parse('202-456-1414', 'US'); + + // Print number in the international format. + console.log(phoneUtil.format(phoneNumber, PNF.INTERNATIONAL)); + // => +1 202-456-1414 +} + +() => { + // Require `AsYouTypeFormatter`. + var AsYouTypeFormatter = libphonenumber.AsYouTypeFormatter; + var formatter = new AsYouTypeFormatter('US'); + + console.log(formatter.inputDigit('6')); // => 6 + console.log(formatter.inputDigit('5')); // => 65 + console.log(formatter.inputDigit('0')); // => 650 + console.log(formatter.inputDigit('2')); // => 650-2 + console.log(formatter.inputDigit('5')); // => 650-25 + console.log(formatter.inputDigit('3')); // => 650-253 + console.log(formatter.inputDigit('2')); // => 650-2532 + console.log(formatter.inputDigit('2')); // => (650) 253-22 + + formatter.clear(); +} diff --git a/google-libphonenumber/google-libphonenumber.d.ts b/google-libphonenumber/google-libphonenumber.d.ts new file mode 100644 index 0000000000..fea36d9675 --- /dev/null +++ b/google-libphonenumber/google-libphonenumber.d.ts @@ -0,0 +1,38 @@ +// Type definitions for libphonenumber v7.4.3 +// Project: https://github.com/googlei18n/libphonenumber +// Project: https://github.com/seegno/google-libphonenumber +// Definitions by: Leon Yu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace libphonenumber { + export enum PhoneNumberFormat { + E164, + INTERNATIONAL, + NATIONAL, + RFC3966 + } + + interface PhoneNumber { + } + + export class PhoneNumberUtil { + static getInstance(): PhoneNumberUtil + parse(number: string, region: string): PhoneNumber; + isValidNumber(phoneNumber: PhoneNumber): boolean; + isValidNumberForRegion(phoneNumber: PhoneNumber): boolean; + getRegionCodeForNumber(phoneNumber: PhoneNumber): string; + isNANPACountry(regionCode: string): boolean; + format(phoneNumber: PhoneNumber, format: PhoneNumberFormat): string; + } + + export class AsYouTypeFormatter { + constructor(region: string); + inputDigit(digit: string): string; + clear(): void; + } +} + + +declare module 'google-libphonenumber' { + export = libphonenumber; +} From 402097684899fb9ff125e85638cc14499bb6e0a3 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 30 Jun 2016 17:07:02 +0700 Subject: [PATCH 39/67] react: rename argument and remove trailing whitespace `callBack` name not match the convention it should change to `callback` --- react/react.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/react/react.d.ts b/react/react.d.ts index 6f595fdbc9..2d0d1f1136 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -151,7 +151,7 @@ declare namespace __React { var PropTypes: ReactPropTypes; var Children: ReactChildren; var version: string; - + // // Component API // ---------------------------------------------------------------------- @@ -163,7 +163,7 @@ declare namespace __React { constructor(props?: P, context?: any); setState(f: (prevState: S, props: P) => S, callback?: () => any): void; setState(state: S, callback?: () => any): void; - forceUpdate(callBack?: () => any): void; + forceUpdate(callback?: () => any): void; render(): JSX.Element; // React.Props is now deprecated, which means that the `children` @@ -359,7 +359,7 @@ declare namespace __React { pseudoElement: string; elapsedTime: number; } - + interface TransitionEvent extends SyntheticEvent { propertyName: string; pseudoElement: string; From 9a062b06b62feaf8b07e980d31122a6e079c2ddb Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 30 Jun 2016 17:31:17 +0700 Subject: [PATCH 40/67] react: fix duplicate `statelessElement` in react-tests.ts --- react/react-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/react-tests.ts b/react/react-tests.ts index b914923e4b..097cbd591a 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -168,7 +168,7 @@ var factoryElement: React.CElement = var statelessFactory: React.SFCFactory = React.createFactory(StatelessComponent); -var statelessElement: React.SFCElement = +var statelessFactoryElement: React.SFCElement = statelessFactory(props); var classicFactory: React.ClassicFactory = From a0c70381ea1f2adfa3965afb5e6856a873497c5d Mon Sep 17 00:00:00 2001 From: Benoit V Date: Thu, 30 Jun 2016 13:52:27 +0200 Subject: [PATCH 41/67] Update leaflet.d.ts: Fixed DivIconOptions Updated DivIconOptions to reflect documentation (http://leafletjs.com/reference.html#divicon). Two changes: - "All Leaflet methods and options that accept Point objects also accept them in a simple Array form (unless noted otherwise)" - DivIconOptions accepts an optional popupAnchor property. --- leaflet/leaflet.d.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 94cbe8499a..23b958f2f5 100644 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -611,7 +611,7 @@ declare namespace L { /** * Size of the icon in pixels. Can be also set through CSS. */ - iconSize?: Point; + iconSize?: Point|[number, number]; /** * The coordinates of the "tip" of the icon (relative to its top left corner). @@ -619,7 +619,7 @@ declare namespace L { * location. Centered by default if size is specified, also can be set in CSS * with negative margins. */ - iconAnchor?: Point; + iconAnchor?: Point|[number, number]; /** * A custom class name to assign to the icon. @@ -635,6 +635,12 @@ declare namespace L { */ html?: string; + /** + * The coordinates of the point from which popups will "open", relative to the + * icon anchor. + */ + popupAnchor?: Point|[number, number]; + } } From 08d59f985e2f9fff0743643e9e5abeab2a0c1a41 Mon Sep 17 00:00:00 2001 From: Benoit V Date: Thu, 30 Jun 2016 16:15:19 +0200 Subject: [PATCH 42/67] Update leaflet.d.ts: TileLayerOptions subdomains: String or String[]. Description: Can be passed in the form of one string (where each letter is a subdomain name) or an array of strings. Documentation: http://leafletjs.com/reference.html --- leaflet/leaflet.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 94cbe8499a..98c1ce9ad3 100644 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -4091,7 +4091,7 @@ declare namespace L { * * Default value: 'abc'. */ - subdomains?: string[]; + subdomains?: string|string[]; /** * URL to the tile image to show in place of the tile that failed to load. From ce363be286e099ecb9395a473b92aa28c4620710 Mon Sep 17 00:00:00 2001 From: Casper Skydt Date: Thu, 30 Jun 2016 17:29:16 +0200 Subject: [PATCH 43/67] Added apigee-access --- apigee-access/apigee-access-tests.ts | 67 ++++++++++++++++++++++++++++ apigee-access/apigee-access.d.ts | 58 ++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 apigee-access/apigee-access-tests.ts create mode 100644 apigee-access/apigee-access.d.ts diff --git a/apigee-access/apigee-access-tests.ts b/apigee-access/apigee-access-tests.ts new file mode 100644 index 0000000000..99baec8021 --- /dev/null +++ b/apigee-access/apigee-access-tests.ts @@ -0,0 +1,67 @@ +/// +import apigee from "apigee-access"; + +//Sample code from +// https://www.npmjs.com/package/apigee-access + +var request: any = null; + +// Variables +var val1 = apigee.getVariable(request, 'TestVariable'); + +apigee.setIntVariable(request, 'TestVariable', '123'); +apigee.setIntVariable(request, 'TestVariable2', 42); + +apigee.deleteVariable(request, 'TestVariable'); + +// Mode +console.log('The deployment mode is ' + apigee.getMode()); + +// Cache +var cache = apigee.getCache('cache'); +var customCache = apigee.getCache('MyCustomCache', + { resource: 'MyCustomrResource' }); +cache.put('key2', 'Hello, World!', 120); +cache.put('key4', 'Hello, World!', function (err: any) { +}); + +cache.get('key', function (err: any, data: any) { +}); + +cache.remove('key'); + +// Secure Vault +var orgVault = apigee.getVault('vault1', 'organization'); +orgVault.get('key1', function (err: any, secretValue: any) { +}); + +// Quota Service +var quota = apigee.getQuota(); +quota.apply({ identifier: 'Foo', allow: 10, timeUnit: 'hour' }, + function (err: any, result: any) { + console.log('Quota applied: %j', result); + }); + +quota.apply({ + identifier: 'Foo', + timeUnit: 'hour', + allow: 100 +}, quotaResult); + +quota.apply({ + identifier: 'Bar', + timeUnit: 'minute', + interval: 5, + allow: 500 +}, quotaResult); + +quota.apply({ + identifier: 'Foo', + timeUnit: 'hour', + allow: 100, + weight: 10 +}, quotaResult); + +function quotaResult(err: any, r: any) { + if (err) { console.error('Quota failed'); } +} \ No newline at end of file diff --git a/apigee-access/apigee-access.d.ts b/apigee-access/apigee-access.d.ts new file mode 100644 index 0000000000..af34724023 --- /dev/null +++ b/apigee-access/apigee-access.d.ts @@ -0,0 +1,58 @@ +// Type definitions for apigee-access +// Project: https://www.npmjs.com/package/apigee-access +// Definitions by: Casper Skydt +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module ApigeeAccess { + + function getVariable(request: any, name: string): string | number | boolean; + function setVariable(request: any, name: string, value: string | number | boolean ): void; + function setIntVariable(request: any, name: string, value: string | number): void; + function deleteVariable(request: any, name: string): void; + function getCache(name: string, options?: CacheOptions): any; + function getVault(name: string, scope?: "organization" | "environment"): SecureVault; + function getQuota(options?: any): QuotaService; + function getMode(): "apigee" | "standalone"; + + interface CacheOptions{ + resource?: string; + scope?: "global" | "application" | "exclusive"; + defaultTtl?: number; + timeout?: number; + } + + interface Cache{ + put(key: string, data: any, ttl?: number, callback?: (err: any) => void): void; + get(key: string, callback: (err: any, data: any) => void): void; + remove(key: string, callback?: (err: any) => void): void; + } + + interface SecureVault{ + getKeys(callback: (err: any, data: any) => void): void; + get(key: string, callback: (err: any, data: any) => void): void; + } + + interface QuotaService{ + apply(options?: QuotaServiceApplyOptions, callback?: (err: any, data: QuotaServiceApplyCallbackData) => void): void; + } + + interface QuotaServiceApplyOptions{ + identifier: string; + timeUnit: "minute" | "hour" | "day" | "week" | "month"; + allow: number; + interval?: number; + weight?: number; + } + + interface QuotaServiceApplyCallbackData{ + used: number; + allowed: number; + isAllowed: boolean; + expiryTime: number; + timestamp: number; + } +} + +declare module "apigee-access"{ + export default ApigeeAccess; +} \ No newline at end of file From 9cfb866c9f912174c8c6d15a2dc24399cfd71f37 Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Thu, 30 Jun 2016 16:55:03 +0100 Subject: [PATCH 44/67] Create reflect-metadata.d.ts --- reflect-metadata/reflect-metadata.d.ts | 480 +++++++++++++++++++++++++ 1 file changed, 480 insertions(+) create mode 100644 reflect-metadata/reflect-metadata.d.ts diff --git a/reflect-metadata/reflect-metadata.d.ts b/reflect-metadata/reflect-metadata.d.ts new file mode 100644 index 0000000000..92ffd951a4 --- /dev/null +++ b/reflect-metadata/reflect-metadata.d.ts @@ -0,0 +1,480 @@ +// Type definitions for reflect-metadata +// Project: https://github.com/rbuckton/ReflectDecorators +// Definitions by: Ron Buckton +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "reflect-metadata" { + // The "reflect-metadata" module has no imports or exports, but can be used by modules to load the polyfill. +} + +declare namespace Reflect { + /** + * Applies a set of decorators to a target object. + * @param decorators An array of decorators. + * @param target The target object. + * @returns The result of applying the provided decorators. + * @remarks Decorators are applied in reverse order of their positions in the array. + * @example + * + * class C { } + * + * // constructor + * C = Reflect.decorate(decoratorsArray, C); + * + */ + function decorate(decorators: ClassDecorator[], target: Function): Function; + /** + * Applies a set of decorators to a property of a target object. + * @param decorators An array of decorators. + * @param target The target object. + * @param targetKey The property key to decorate. + * @param descriptor A property descriptor + * @remarks Decorators are applied in reverse order. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * static staticMethod() { } + * method() { } + * } + * + * // property (on constructor) + * Reflect.decorate(decoratorsArray, C, "staticProperty"); + * + * // property (on prototype) + * Reflect.decorate(decoratorsArray, C.prototype, "property"); + * + * // method (on constructor) + * Object.defineProperty(C, "staticMethod", + * Reflect.decorate(decoratorsArray, C, "staticMethod", + * Object.getOwnPropertyDescriptor(C, "staticMethod"))); + * + * // method (on prototype) + * Object.defineProperty(C.prototype, "method", + * Reflect.decorate(decoratorsArray, C.prototype, "method", + * Object.getOwnPropertyDescriptor(C.prototype, "method"))); + * + */ + function decorate(decorators: (PropertyDecorator | MethodDecorator)[], target: Object, targetKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor; + /** + * A default metadata decorator factory that can be used on a class, class member, or parameter. + * @param metadataKey The key for the metadata entry. + * @param metadataValue The value for the metadata entry. + * @returns A decorator function. + * @remarks + * If `metadataKey` is already defined for the target and target key, the + * metadataValue for that key will be overwritten. + * @example + * + * // constructor + * @Reflect.metadata(key, value) + * class C { + * } + * + * // property (on constructor, TypeScript only) + * class C { + * @Reflect.metadata(key, value) + * static staticProperty; + * } + * + * // property (on prototype, TypeScript only) + * class C { + * @Reflect.metadata(key, value) + * property; + * } + * + * // method (on constructor) + * class C { + * @Reflect.metadata(key, value) + * static staticMethod() { } + * } + * + * // method (on prototype) + * class C { + * @Reflect.metadata(key, value) + * method() { } + * } + * + */ + function metadata(metadataKey: any, metadataValue: any): { + (target: Function): void; + (target: Object, propertyKey: string | symbol): void; + }; + /** + * Define a unique metadata entry on the target. + * @param metadataKey A key used to store and retrieve metadata. + * @param metadataValue A value that contains attached metadata. + * @param target The target object on which to define metadata. + * @example + * + * class C { + * } + * + * // constructor + * Reflect.defineMetadata("custom:annotation", options, C); + * + * // decorator factory as metadata-producing annotation. + * function MyAnnotation(options): ClassDecorator { + * return target => Reflect.defineMetadata("custom:annotation", options, target); + * } + * + */ + function defineMetadata(metadataKey: any, metadataValue: any, target: Object): void; + /** + * Define a unique metadata entry on the target. + * @param metadataKey A key used to store and retrieve metadata. + * @param metadataValue A value that contains attached metadata. + * @param target The target object on which to define metadata. + * @param targetKey The property key for the target. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * static staticMethod(p) { } + * method(p) { } + * } + * + * // property (on constructor) + * Reflect.defineMetadata("custom:annotation", Number, C, "staticProperty"); + * + * // property (on prototype) + * Reflect.defineMetadata("custom:annotation", Number, C.prototype, "property"); + * + * // method (on constructor) + * Reflect.defineMetadata("custom:annotation", Number, C, "staticMethod"); + * + * // method (on prototype) + * Reflect.defineMetadata("custom:annotation", Number, C.prototype, "method"); + * + * // decorator factory as metadata-producing annotation. + * function MyAnnotation(options): PropertyDecorator { + * return (target, key) => Reflect.defineMetadata("custom:annotation", options, target, key); + * } + * + */ + function defineMetadata(metadataKey: any, metadataValue: any, target: Object, targetKey: string | symbol): void; + /** + * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`. + * @example + * + * class C { + * } + * + * // constructor + * result = Reflect.hasMetadata("custom:annotation", C); + * + */ + function hasMetadata(metadataKey: any, target: Object): boolean; + /** + * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey The property key for the target. + * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * static staticMethod(p) { } + * method(p) { } + * } + * + * // property (on constructor) + * result = Reflect.hasMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.hasMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.hasMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.hasMetadata("custom:annotation", C.prototype, "method"); + * + */ + function hasMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean; + /** + * Gets a value indicating whether the target object has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns `true` if the metadata key was defined on the target object; otherwise, `false`. + * @example + * + * class C { + * } + * + * // constructor + * result = Reflect.hasOwnMetadata("custom:annotation", C); + * + */ + function hasOwnMetadata(metadataKey: any, target: Object): boolean; + /** + * Gets a value indicating whether the target object has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey The property key for the target. + * @returns `true` if the metadata key was defined on the target object; otherwise, `false`. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * static staticMethod(p) { } + * method(p) { } + * } + * + * // property (on constructor) + * result = Reflect.hasOwnMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.hasOwnMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "method"); + * + */ + function hasOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean; + /** + * Gets the metadata value for the provided metadata key on the target object or its prototype chain. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * class C { + * } + * + * // constructor + * result = Reflect.getMetadata("custom:annotation", C); + * + */ + function getMetadata(metadataKey: any, target: Object): any; + /** + * Gets the metadata value for the provided metadata key on the target object or its prototype chain. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey The property key for the target. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * static staticMethod(p) { } + * method(p) { } + * } + * + * // property (on constructor) + * result = Reflect.getMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getMetadata("custom:annotation", C.prototype, "method"); + * + */ + function getMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any; + /** + * Gets the metadata value for the provided metadata key on the target object. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * class C { + * } + * + * // constructor + * result = Reflect.getOwnMetadata("custom:annotation", C); + * + */ + function getOwnMetadata(metadataKey: any, target: Object): any; + /** + * Gets the metadata value for the provided metadata key on the target object. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey The property key for the target. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * static staticMethod(p) { } + * method(p) { } + * } + * + * // property (on constructor) + * result = Reflect.getOwnMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getOwnMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "method"); + * + */ + function getOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any; + /** + * Gets the metadata keys defined on the target object or its prototype chain. + * @param target The target object on which the metadata is defined. + * @returns An array of unique metadata keys. + * @example + * + * class C { + * } + * + * // constructor + * result = Reflect.getMetadataKeys(C); + * + */ + function getMetadataKeys(target: Object): any[]; + /** + * Gets the metadata keys defined on the target object or its prototype chain. + * @param target The target object on which the metadata is defined. + * @param targetKey The property key for the target. + * @returns An array of unique metadata keys. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * static staticMethod(p) { } + * method(p) { } + * } + * + * // property (on constructor) + * result = Reflect.getMetadataKeys(C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getMetadataKeys(C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getMetadataKeys(C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getMetadataKeys(C.prototype, "method"); + * + */ + function getMetadataKeys(target: Object, targetKey: string | symbol): any[]; + /** + * Gets the unique metadata keys defined on the target object. + * @param target The target object on which the metadata is defined. + * @returns An array of unique metadata keys. + * @example + * + * class C { + * } + * + * // constructor + * result = Reflect.getOwnMetadataKeys(C); + * + */ + function getOwnMetadataKeys(target: Object): any[]; + /** + * Gets the unique metadata keys defined on the target object. + * @param target The target object on which the metadata is defined. + * @param targetKey The property key for the target. + * @returns An array of unique metadata keys. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * static staticMethod(p) { } + * method(p) { } + * } + * + * // property (on constructor) + * result = Reflect.getOwnMetadataKeys(C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getOwnMetadataKeys(C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getOwnMetadataKeys(C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getOwnMetadataKeys(C.prototype, "method"); + * + */ + function getOwnMetadataKeys(target: Object, targetKey: string | symbol): any[]; + /** + * Deletes the metadata entry from the target object with the provided key. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @returns `true` if the metadata entry was found and deleted; otherwise, false. + * @example + * + * class C { + * } + * + * // constructor + * result = Reflect.deleteMetadata("custom:annotation", C); + * + */ + function deleteMetadata(metadataKey: any, target: Object): boolean; + /** + * Deletes the metadata entry from the target object with the provided key. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey The property key for the target. + * @returns `true` if the metadata entry was found and deleted; otherwise, false. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * static staticMethod(p) { } + * method(p) { } + * } + * + * // property (on constructor) + * result = Reflect.deleteMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.deleteMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.deleteMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.deleteMetadata("custom:annotation", C.prototype, "method"); + * + */ + function deleteMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean; +} From 87148dc961ed944420e7b8e99017de4d76634498 Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Thu, 30 Jun 2016 16:58:44 +0100 Subject: [PATCH 45/67] Create reflect-metadata-test.ts --- reflect-metadata/reflect-metadata-test.ts | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 reflect-metadata/reflect-metadata-test.ts diff --git a/reflect-metadata/reflect-metadata-test.ts b/reflect-metadata/reflect-metadata-test.ts new file mode 100644 index 0000000000..8cec67ed31 --- /dev/null +++ b/reflect-metadata/reflect-metadata-test.ts @@ -0,0 +1,42 @@ +/// + +// define metadata on an object or property +Reflect.defineMetadata(metadataKey, metadataValue, target); +Reflect.defineMetadata(metadataKey, metadataValue, target, propertyKey); + +// check for presence of a metadata key on the prototype chain of an object or property +let result = Reflect.hasMetadata(metadataKey, target); +let result = Reflect.hasMetadata(metadataKey, target, propertyKey); + +// check for presence of an own metadata key of an object or property +let result = Reflect.hasOwnMetadata(metadataKey, target); +let result = Reflect.hasOwnMetadata(metadataKey, target, propertyKey); + +// get metadata value of a metadata key on the prototype chain of an object or property +let result = Reflect.getMetadata(metadataKey, target); +let result = Reflect.getMetadata(metadataKey, target, propertyKey); + +// get metadata value of an own metadata key of an object or property +let result = Reflect.getOwnMetadata(metadataKey, target); +let result = Reflect.getOwnMetadata(metadataKey, target, propertyKey); + +// get all metadata keys on the prototype chain of an object or property +let result = Reflect.getMetadataKeys(target); +let result = Reflect.getMetadataKeys(target, propertyKey); + +// get all own metadata keys of an object or property +let result = Reflect.getOwnMetadataKeys(target); +let result = Reflect.getOwnMetadataKeys(target, propertyKey); + +// delete metadata from an object or property +let result = Reflect.deleteMetadata(metadataKey, target); +let result = Reflect.deleteMetadata(metadataKey, target, propertyKey); + +// apply metadata via a decorator to a constructor +@Reflect.metadata(metadataKey, metadataValue) +class C { + // apply metadata via a decorator to a method (property) + @Reflect.metadata(metadataKey, metadataValue) + method() { + } +} From 18a2b0a82d57841a64a1d86a8a0ee8b8ffa229b0 Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Thu, 30 Jun 2016 17:03:54 +0100 Subject: [PATCH 46/67] Update reflect-metadata-test.ts --- reflect-metadata/reflect-metadata-test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reflect-metadata/reflect-metadata-test.ts b/reflect-metadata/reflect-metadata-test.ts index 8cec67ed31..0a62b35fbd 100644 --- a/reflect-metadata/reflect-metadata-test.ts +++ b/reflect-metadata/reflect-metadata-test.ts @@ -1,5 +1,15 @@ /// +let target = { + some_property: { + + } +} + +let metadataKey = "key"; +let metadataValue = "val"; +let propertyKey = "some_property"; + // define metadata on an object or property Reflect.defineMetadata(metadataKey, metadataValue, target); Reflect.defineMetadata(metadataKey, metadataValue, target, propertyKey); From a38994a6955811f05d6300ed33d6cacee27028bc Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Thu, 30 Jun 2016 17:07:17 +0100 Subject: [PATCH 47/67] Update reflect-metadata-test.ts --- reflect-metadata/reflect-metadata-test.ts | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/reflect-metadata/reflect-metadata-test.ts b/reflect-metadata/reflect-metadata-test.ts index 0a62b35fbd..2b151c360b 100644 --- a/reflect-metadata/reflect-metadata-test.ts +++ b/reflect-metadata/reflect-metadata-test.ts @@ -15,32 +15,32 @@ Reflect.defineMetadata(metadataKey, metadataValue, target); Reflect.defineMetadata(metadataKey, metadataValue, target, propertyKey); // check for presence of a metadata key on the prototype chain of an object or property -let result = Reflect.hasMetadata(metadataKey, target); -let result = Reflect.hasMetadata(metadataKey, target, propertyKey); +let result1 = Reflect.hasMetadata(metadataKey, target); +let result2 = Reflect.hasMetadata(metadataKey, target, propertyKey); // check for presence of an own metadata key of an object or property -let result = Reflect.hasOwnMetadata(metadataKey, target); -let result = Reflect.hasOwnMetadata(metadataKey, target, propertyKey); +let result3 = Reflect.hasOwnMetadata(metadataKey, target); +let result4 = Reflect.hasOwnMetadata(metadataKey, target, propertyKey); // get metadata value of a metadata key on the prototype chain of an object or property -let result = Reflect.getMetadata(metadataKey, target); -let result = Reflect.getMetadata(metadataKey, target, propertyKey); +let result5 = Reflect.getMetadata(metadataKey, target); +let result6 = Reflect.getMetadata(metadataKey, target, propertyKey); // get metadata value of an own metadata key of an object or property -let result = Reflect.getOwnMetadata(metadataKey, target); -let result = Reflect.getOwnMetadata(metadataKey, target, propertyKey); +let result7 = Reflect.getOwnMetadata(metadataKey, target); +let result8 = Reflect.getOwnMetadata(metadataKey, target, propertyKey); // get all metadata keys on the prototype chain of an object or property -let result = Reflect.getMetadataKeys(target); -let result = Reflect.getMetadataKeys(target, propertyKey); +let result9 = Reflect.getMetadataKeys(target); +let result10 = Reflect.getMetadataKeys(target, propertyKey); // get all own metadata keys of an object or property -let result = Reflect.getOwnMetadataKeys(target); -let result = Reflect.getOwnMetadataKeys(target, propertyKey); +let result11 = Reflect.getOwnMetadataKeys(target); +let result12 = Reflect.getOwnMetadataKeys(target, propertyKey); // delete metadata from an object or property -let result = Reflect.deleteMetadata(metadataKey, target); -let result = Reflect.deleteMetadata(metadataKey, target, propertyKey); +let result13 = Reflect.deleteMetadata(metadataKey, target); +let result14 = Reflect.deleteMetadata(metadataKey, target, propertyKey); // apply metadata via a decorator to a constructor @Reflect.metadata(metadataKey, metadataValue) From 43c311427bb79ebbadfc37b31611552c943f4e24 Mon Sep 17 00:00:00 2001 From: dano-giftbit Date: Thu, 30 Jun 2016 14:13:17 -0700 Subject: [PATCH 48/67] Added Typing definitions for MaterialUI 0.15.1 and Moved 0.15.0 into legacy --- .../legacy/material-ui-0.15.0-tests.tsx | 4913 ++++++++++ .../material-ui-0.15.0-tests.tsx.tscparams | 1 + material-ui/legacy/material-ui-0.15.0.d.ts | 8414 +++++++++++++++++ material-ui/material-ui-tests.tsx | 40 +- material-ui/material-ui.d.ts | 31 +- 5 files changed, 13393 insertions(+), 6 deletions(-) create mode 100644 material-ui/legacy/material-ui-0.15.0-tests.tsx create mode 100644 material-ui/legacy/material-ui-0.15.0-tests.tsx.tscparams create mode 100644 material-ui/legacy/material-ui-0.15.0.d.ts diff --git a/material-ui/legacy/material-ui-0.15.0-tests.tsx b/material-ui/legacy/material-ui-0.15.0-tests.tsx new file mode 100644 index 0000000000..a0374db8b8 --- /dev/null +++ b/material-ui/legacy/material-ui-0.15.0-tests.tsx @@ -0,0 +1,4913 @@ +/// +/// +/// +/// + +import * as React from 'react'; +import {Component, PropTypes} from 'react'; +import * as ReactDOM from 'react-dom'; + +import getMuiTheme from 'material-ui/styles/getMuiTheme'; +import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; +import darkBaseTheme from 'material-ui/styles/baseThemes/darkBaseTheme'; +import muiThemeable from 'material-ui/styles/muiThemeable'; +import {MuiTheme} from 'material-ui/styles' + +import AppBar from 'material-ui/AppBar'; +import AutoComplete from 'material-ui/AutoComplete'; +import Avatar from 'material-ui/Avatar'; +import Badge from 'material-ui/Badge'; +import Checkbox from 'material-ui/Checkbox'; +import CircularProgress from 'material-ui/CircularProgress'; +import DatePicker from 'material-ui/DatePicker'; +import Dialog from 'material-ui/Dialog'; +import Divider from 'material-ui/Divider'; +import Drawer from 'material-ui/Drawer'; +import DropDownMenu from 'material-ui/DropDownMenu'; +import FlatButton from 'material-ui/FlatButton'; +import FloatingActionButton from 'material-ui/FloatingActionButton'; +import FontIcon from 'material-ui/FontIcon'; +import IconButton from 'material-ui/IconButton'; +import IconMenu from 'material-ui/IconMenu'; +import LinearProgress from 'material-ui/LinearProgress'; +import List from 'material-ui/List/List'; +import ListItem from 'material-ui/List/ListItem'; +import MenuItem from 'material-ui/MenuItem'; +import Paper from 'material-ui/Paper'; +import RaisedButton from 'material-ui/RaisedButton'; +import RefreshIndicator from 'material-ui/RefreshIndicator'; +import SelectField from 'material-ui/SelectField'; +import Slider from 'material-ui/Slider'; +import Snackbar from 'material-ui/Snackbar'; +import Subheader from 'material-ui/Subheader'; +import SvgIcon from 'material-ui/SvgIcon'; +import TextField from 'material-ui/TextField'; +import TimePicker from 'material-ui/TimePicker'; +import Toggle from 'material-ui/Toggle'; +import {Card, CardActions, CardHeader, CardMedia, CardTitle, CardText} from 'material-ui/Card'; +import {GridList, GridTile} from 'material-ui/GridList'; +import {MakeSelectable} from 'material-ui/List'; +import {Menu} from 'material-ui/Menu'; +import {Popover, PopoverAnimationVertical} from 'material-ui/Popover'; +import {RadioButton, RadioButtonGroup} from 'material-ui/RadioButton'; +import {Step, Stepper, StepLabel, StepContent, StepButton} from 'material-ui/Stepper'; +import {Table, TableBody, TableHeader, TableHeaderColumn, TableRow, TableRowColumn, TableFooter} from 'material-ui/Table'; +import {Tabs, Tab} from 'material-ui/Tabs'; +import {Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarTitle} from 'material-ui/Toolbar'; + +import ActionAndroid from 'material-ui/svg-icons/action/android'; +import ActionAssignment from 'material-ui/svg-icons/action/assignment'; +import ActionFavorite from 'material-ui/svg-icons/action/favorite'; +import ActionFavoriteBorder from 'material-ui/svg-icons/action/favorite-border'; +import ActionFlightTakeoff from 'material-ui/svg-icons/action/flight-takeoff'; +import ActionGrade from 'material-ui/svg-icons/action/grade'; +import ActionHome from 'material-ui/svg-icons/action/home'; +import ActionInfo from 'material-ui/svg-icons/action/info'; +import ArrowDropRight from 'material-ui/svg-icons/navigation-arrow-drop-right'; +import CommunicationCall from 'material-ui/svg-icons/communication/call'; +import CommunicationChatBubble from 'material-ui/svg-icons/communication/chat-bubble'; +import CommunicationEmail from 'material-ui/svg-icons/communication/email'; +import ContentAdd from 'material-ui/svg-icons/content/add'; +import ContentCopy from 'material-ui/svg-icons/content/content-copy'; +import ContentDrafts from 'material-ui/svg-icons/content/drafts'; +import ContentFilter from 'material-ui/svg-icons/content/filter-list'; +import ContentInbox from 'material-ui/svg-icons/content/inbox'; +import ContentLink from 'material-ui/svg-icons/content/link'; +import ContentSend from 'material-ui/svg-icons/content/send'; +import Delete from 'material-ui/svg-icons/action/delete'; +import Download from 'material-ui/svg-icons/file/file-download'; +import EditorInsertChart from 'material-ui/svg-icons/editor/insert-chart'; +import FileCloudDownload from 'material-ui/svg-icons/file/cloud-download'; +import FileFileDownload from 'material-ui/svg-icons/file/file-download'; +import FileFolder from 'material-ui/svg-icons/file/folder'; +import FolderIcon from 'material-ui/svg-icons/file/folder-open'; +import HardwareVideogameAsset from 'material-ui/svg-icons/hardware/videogame-asset'; +import MapsPersonPin from 'material-ui/svg-icons/maps/person-pin'; +import MapsPlace from 'material-ui/svg-icons/maps/place'; +import MoreVertIcon from 'material-ui/svg-icons/navigation/more-vert'; +import NavigationClose from 'material-ui/svg-icons/navigation/close'; +import NavigationExpandMoreIcon from 'material-ui/svg-icons/navigation/expand-more'; +import NotificationsIcon from 'material-ui/svg-icons/social/notifications'; +import PersonAdd from 'material-ui/svg-icons/social/person-add'; +import RemoveRedEye from 'material-ui/svg-icons/image/remove-red-eye'; +import StarBorder from 'material-ui/svg-icons/toggle/star-border'; +import UploadIcon from 'material-ui/svg-icons/file/cloud-upload'; +import WarningIcon from 'material-ui/svg-icons/alert/warning'; + +import {cyan500, cyan700, + grey100, grey300, grey400, grey500, + pinkA200, + white, darkBlack, fullBlack, + blue300, + indigo900, + orange200, + deepOrange300, + pink400, + purple500, + fullWhite, + blue500, red500, greenA200, yellow500, + transparent, yellow600, indigo500, lightBlack, + orange500, +} from 'material-ui/styles/colors'; +import {fade} from 'material-ui/utils/colorManipulator'; + + +import injectTapEventPlugin = require('react-tap-event-plugin'); + +// Needed for onTouchTap +// Check this repo: +// https://github.com/zilverline/react-tap-event-plugin +injectTapEventPlugin(); + +function handleTouchTap() { + alert('onTouchTap triggered on the title component'); +} + +const styles = { + title: { + cursor: 'pointer', + }, + exampleImageInput: { + cursor: 'pointer', + position: 'absolute', + top: 0, + bottom: 0, + right: 0, + left: 0, + width: '100%', + opacity: 0, + }, + button: { + margin: 12, + }, + smallIcon: { + width: 36, + height: 36, + }, + mediumIcon: { + width: 48, + height: 48, + }, + largeIcon: { + width: 60, + height: 60, + }, + small: { + width: 72, + height: 72, + padding: 16, + }, + medium: { + width: 96, + height: 96, + padding: 24, + }, + large: { + width: 120, + height: 120, + padding: 30, + }, + radioButton: { + marginTop: 16, + }, + root: { + display: 'flex', + flexWrap: 'wrap', + justifyContent: 'space-around', + }, + gridList: { + width: 500, + height: 500, + overflowY: 'auto', + marginBottom: 24, + }, + paper: { + display: 'inline-block', + float: 'left', + margin: '16px 32px 16px 0', + }, + rightIcon: { + textAlign: 'center', + lineHeight: '24px', + }, + customWidth: { + width: 200, + }, + h3: { + marginTop: 20, + fontWeight: 400, + }, + block: { + display: 'flex', + maxWidth: 250, + }, + block2: { + margin: 10, + }, + container: { + position: 'relative', + }, + refresh: { + display: 'inline-block', + position: 'relative', + }, + checkbox: { + marginBottom: 16, + }, + toggle: { + marginBottom: 16, + }, + propContainer: { + width: 200, + overflow: 'hidden', + margin: '20px auto 0', + }, + propToggleHeader: { + margin: '20px auto 10px', + }, + headline: { + fontSize: 24, + paddingTop: 16, + marginBottom: 12, + fontWeight: 400, + }, + errorStyle: { + color: orange500, + }, + underlineStyle: { + borderColor: orange500, + }, + floatingLabelStyle: { + color: orange500, + }, + floatingLabelFocusStyle: { + color: blue500, + }, +}; + +const style = { + marginRight: 20, + marginLeft: 20, + display: 'inline-block', + margin: '16px 32px 16px 0', +}; + +const customContentStyle = { + width: '100%', + maxWidth: 'none', +}; + +const iconStyles = { + marginRight: 24, +}; + + +// "http://www.material-ui.com/#/customization/themes" + +// This replaces the textColor value on the palette +// and then update the keys for each component that depends on it. +// More on Colors: http://www.material-ui.com/#/customization/colors +const muiTheme = getMuiTheme({ + palette: { + textColor: cyan500, + }, + appBar: { + height: 50, + }, +}); + +const darkMuiTheme = getMuiTheme(darkBaseTheme); + +const lightBaseTheme = { + spacing: { + iconSize: 24, + desktopGutter: 24, + desktopGutterMore: 32, + desktopGutterLess: 16, + desktopGutterMini: 8, + desktopKeylineIncrement: 64, + desktopDropDownMenuItemHeight: 32, + desktopDropDownMenuFontSize: 15, + desktopDrawerMenuItemHeight: 48, + desktopSubheaderHeight: 48, + desktopToolbarHeight: 56, + }, + fontFamily: 'Roboto, sans-serif', + palette: { + primary1Color: cyan500, + primary2Color: cyan700, + primary3Color: grey400, + accent1Color: pinkA200, + accent2Color: grey100, + accent3Color: grey500, + textColor: darkBlack, + alternateTextColor: white, + canvasColor: white, + borderColor: grey300, + disabledColor: fade(darkBlack, 0.3), + pickerHeaderColor: cyan500, + clockCircleColor: fade(darkBlack, 0.07), + shadowColor: fullBlack, + }, +}; + +const lightMuiTheme = getMuiTheme(lightBaseTheme); + + +class DeepDownTheTree extends React.Component<{} & {muiTheme: MuiTheme}, {}> { + static propTypes: React.ValidationMap = { + muiTheme: React.PropTypes.object.isRequired, + }; + + render() { + return ( + + Hello World! + + ); + } +} + + +// "http://www.material-ui.com/#/customization/inline-styles" +const InlineStylesCheckbox = () => ( + +); + + +// "http://www.material-ui.com/#/components/app-bar" +const AppBarExampleIcon = () => ( + +); + +const AppBarExampleIconButton = () => ( + Title} + onTitleTouchTap={handleTouchTap} + iconElementLeft={} + iconElementRight={} + /> +); + +const AppBarExampleIconMenu = () => ( + } + iconElementRight={ + + } + targetOrigin={{horizontal: 'right', vertical: 'top'}} + anchorOrigin={{horizontal: 'right', vertical: 'top'}} + > + + + + + } + /> +); + +// "http://www.material-ui.com/#/components/auto-complete" +export class AutoCompleteExampleSimple extends React.Component<{}, {dataSource: string[]}> { + + constructor(props) { + super(props); + + this.state = { + dataSource: [], + }; + } + + handleUpdateInput = (value) => { + this.setState({ + dataSource: [ + value, + value + value, + value + value + value, + ], + }); + }; + + render() { + return ( +
+ + +
+ ); + } +} + +const dataSource1 = [ + { + text: 'text-value1', + value: ( + + ), + }, + { + text: 'text-value2', + value: ( + + ), + }, +]; + +const dataSource2 = ['12345', '23456', '34567']; + +const dataSource3 = [ + {text: 'Some Text', value: 'someFirstValue'}, + {text: 'Some Text', value: 'someSecondValue'}, +]; + +const AutoCompleteExampleNoFilter = () => ( +
+
+
+ +
+); + +const colors = [ + 'Red', + 'Orange', + 'Yellow', + 'Green', + 'Blue', + 'Purple', + 'Black', + 'White', +]; + +const fruit = [ + 'Apple', 'Apricot', 'Avocado', + 'Banana', 'Bilberry', 'Blackberry', 'Blackcurrant', 'Blueberry', + 'Boysenberry', 'Blood Orange', + 'Cantaloupe', 'Currant', 'Cherry', 'Cherimoya', 'Cloudberry', + 'Coconut', 'Cranberry', 'Clementine', + 'Damson', 'Date', 'Dragonfruit', 'Durian', + 'Elderberry', + 'Feijoa', 'Fig', + 'Goji berry', 'Gooseberry', 'Grape', 'Grapefruit', 'Guava', + 'Honeydew', 'Huckleberry', + 'Jabouticaba', 'Jackfruit', 'Jambul', 'Jujube', 'Juniper berry', + 'Kiwi fruit', 'Kumquat', + 'Lemon', 'Lime', 'Loquat', 'Lychee', + 'Nectarine', + 'Mango', 'Marion berry', 'Melon', 'Miracle fruit', 'Mulberry', 'Mandarine', + 'Olive', 'Orange', + 'Papaya', 'Passionfruit', 'Peach', 'Pear', 'Persimmon', 'Physalis', 'Plum', 'Pineapple', + 'Pumpkin', 'Pomegranate', 'Pomelo', 'Purple Mangosteen', + 'Quince', + 'Raspberry', 'Raisin', 'Rambutan', 'Redcurrant', + 'Salal berry', 'Satsuma', 'Star fruit', 'Strawberry', 'Squash', 'Salmonberry', + 'Tamarillo', 'Tamarind', 'Tomato', 'Tangerine', + 'Ugli fruit', + 'Watermelon', +]; + +const AutoCompleteExampleFilters = () => ( +
+ +
+ +
+); + +// "http://www.material-ui.com/#/components/avatar" +const AvatarExampleSimple = () => ( + + + } + > + Image Avatar + + + } + > + Image Avatar with custom size + + } /> + } + > + FontIcon Avatar + + } + color={blue300} + backgroundColor={indigo900} + size={30} + style={style} + /> + } + > + FontIcon Avatar with custom colors and size + + } /> + } + > + SvgIcon Avatar + + } + color={orange200} + backgroundColor={pink400} + size={30} + style={style} + /> + } + > + SvgIcon Avatar with custom colors and size + + A} + > + Letter Avatar + + + A + + } + > + Letter Avatar with custom colors and size + + +); + + +// "http://www.material-ui.com/#/components/badge" +const BadgeExampleSimple = () => ( +
+ + + + + + + + +
+); + +const BadgeExampleContent = () => ( +
+ } + > + + + + Company Name + +
+); + + +// "http://www.material-ui.com/#/components/flat-button" +const FlatButtonExampleSimple = () => ( +
+ + + + +
+); + +const FlatButtonExampleComplex = () => ( +
+ + + + + } + /> + + } + /> + +
+); + +const FlatButtonExampleIcon = () => ( +
+ } + style={style} + /> + } + style={style} + /> + } + style={style} + /> +
+); + + +// "http://www.material-ui.com/#/components/raised-button" +const RaisedButtonExampleSimple = () => ( +
+ + + + +
+); + +const RaisedButtonExampleComplex = () => ( +
+ + + + } + style={styles.button} + /> + } + /> +
+); + +const RaisedButtonExampleIcon = () => ( +
+ } + style={style} + /> + } + style={style} + /> + } + style={style} + /> +
+); + + +// "http://www.material-ui.com/#/components/floating-action-button" +const FloatingActionButtonExampleSimple = () => ( +
+ + + + + + + + + + + + + + + + + + + + + + + +
+); + + +// "http://www.material-ui.com/#/components/icon-button" +const IconButtonExampleSimple = () => ( +
+ + +
+); + +const IconButtonExampleComplex = () => ( +
+ + + + + + + + + + home + +
+); + +const IconButtonExampleSize = () => ( +
+ + + + + + + + + + + + + + + +
+); + +const IconButtonExampleTooltip = () => ( +
+ + + + + + +
+); + +const IconButtonExampleTouch = () => ( +
+ + + + + + + + + + + + + + + + + + +
+); + + +// "http://www.material-ui.com/#/components/card" +const CardExampleWithAvatar = () => ( + + + } + > + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi. + Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque. + Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio. + + + + + + +); + +const CardExampleWithoutAvatar = () => ( + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi. + Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque. + Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio. + + + + + + +); + +class CardExampleControlled extends React.Component<{}, {expanded: boolean}> { + + constructor(props) { + super(props); + this.state = { + expanded: false, + }; + } + + handleExpandChange = (expanded) => { + this.setState({expanded: expanded}); + }; + + handleToggle = (event, toggle) => { + this.setState({expanded: toggle}); + }; + + handleExpand = () => { + this.setState({expanded: true}); + }; + + handleReduce = () => { + this.setState({expanded: false}); + }; + + render() { + return ( + + + + + + } + > + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi. + Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque. + Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio. + + + + + + + ); + } +} + + +// "http://www.material-ui.com/#/components/date-picker" +const DatePickerExampleSimple = () => ( +
+ + + +
+); + +const DatePickerExampleInline = () => ( +
+ + +
+); + +const optionsStyle = { + maxWidth: 255, + marginRight: 'auto', +}; + +interface DatePickerExampleToggleState { + minDate?: Date; + maxDate?: Date; + autoOk?: boolean; + disableYearSelection?: boolean; +} + +class DatePickerExampleToggle extends React.Component<{}, DatePickerExampleToggleState> { + constructor(props) { + super(props); + + const minDate = new Date(); + const maxDate = new Date(); + minDate.setFullYear(minDate.getFullYear() - 1); + minDate.setHours(0, 0, 0, 0); + maxDate.setFullYear(maxDate.getFullYear() + 1); + maxDate.setHours(0, 0, 0, 0); + + this.state = { + minDate: minDate, + maxDate: maxDate, + autoOk: false, + disableYearSelection: false, + }; + } + + handleChangeMinDate = (event, date) => { + this.setState({ + minDate: date, + }); + }; + + handleChangeMaxDate = (event, date) => { + this.setState({ + maxDate: date, + }); + }; + + handleToggle = (event, toggled) => { + this.setState({ + [event.target.name]: toggled, + }); + }; + + render() { + return ( +
+ +
+ + + + +
+
+ ); + } +} + +class DatePickerExampleControlled extends React.Component<{}, {controlledDate?: Date}> { + + constructor(props) { + super(props); + + this.state = { + controlledDate: null, + }; + } + + handleChange = (event, date) => { + this.setState({ + controlledDate: date, + }); + }; + + render() { + return ( + + ); + } +} + +function disableWeekends(date) { + return date.getDay() === 0 || date.getDay() === 6; +} +function disableRandomDates() { + return Math.random() > 0.7; +} +const DatePickerExampleDisableDates = () => ( +
+ + +
+); + +let DateTimeFormat = new Intl.DateTimeFormat('fr'); +const DatePickerExampleInternational = () => ( +
+ + + +
+); + + + +// "http://material-ui.com/#/components/dialog" +class DialogExampleSimple extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + return ( +
+ + + The actions in this window were passed in as an array of React objects. + +
+ ); + } +} + +class DialogExampleModal extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + return ( +
+ + + Only actions can close this dialog. + +
+ ); + } +} + +class DialogExampleCustomWidth extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + return ( +
+ + + This dialog spans the entire width of the screen. + +
+ ); + } +} + +class DialogExampleDialogDatePicker extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + ]; + + return ( +
+ + + Open a Date Picker dialog from within a dialog. + + +
+ ); + } +} + +class DialogExampleScrollable extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + const radios = []; + for (let i = 0; i < 30; i++) { + radios.push( + + ); + } + + return ( +
+ + + + {radios} + + +
+ ); + } +} + +class DialogExampleAlert extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + return ( +
+ + + Discard draft? + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/divider" +const DividerExampleForm = () => ( + + + + + + + + + + +); + +const DividerExampleList = () => ( + + + + + + + + + + + +); + +const DividerExampleMenu = () => ( + + + + + + +); + + +// "http://www.material-ui.com/#/components/drawer" +class DrawerSimpleExample extends React.Component<{}, {open?: boolean}> { + + constructor(props) { + super(props); + this.state = {open: false}; + } + + handleToggle = () => this.setState({open: !this.state.open}); + + render() { + return ( +
+ + + Menu Item + Menu Item 2 + +
+ ); + } +} + +class DrawerUndockedExample extends React.Component<{}, {open?: boolean}> { + + constructor(props) { + super(props); + this.state = {open: false}; + } + + handleToggle = () => this.setState({open: !this.state.open}); + + handleClose = () => this.setState({open: false}); + + render() { + return ( +
+ + this.setState({open})} + > + Menu Item + Menu Item 2 + +
+ ); + } +} + +class DrawerOpenRightExample extends React.Component<{}, {open?: boolean}> { + + constructor(props) { + super(props); + this.state = {open: false}; + } + + handleToggle = () => this.setState({open: !this.state.open}); + + render() { + return ( +
+ + + + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/grid-list" +const tilesData: {img: string, title: string, author: string, featured?: boolean}[] = [ + { + img: 'images/grid-list/00-52-29-429_640.jpg', + title: 'Breakfast', + author: 'jill111', + featured: true, + }, + { + img: 'images/grid-list/burger-827309_640.jpg', + title: 'Tasty burger', + author: 'pashminu', + }, + { + img: 'images/grid-list/camera-813814_640.jpg', + title: 'Camera', + author: 'Danson67', + }, + { + img: 'images/grid-list/morning-819362_640.jpg', + title: 'Morning', + author: 'fancycrave1', + }, + { + img: 'images/grid-list/hats-829509_640.jpg', + title: 'Hats', + author: 'Hans', + }, + { + img: 'images/grid-list/honey-823614_640.jpg', + title: 'Honey', + author: 'fancycravel', + }, + { + img: 'images/grid-list/vegetables-790022_640.jpg', + title: 'Vegetables', + author: 'jill111', + }, + { + img: 'images/grid-list/water-plant-821293_640.jpg', + title: 'Water plant', + author: 'BkrmadtyaKarki', + }, +]; + +const GridListExampleSimple = () => ( +
+ + December + {tilesData.map((tile) => ( + by {tile.author}} + actionIcon={} + > + + + ))} + +
+); + +const GridListExampleComplex = () => ( +
+ + {tilesData.map((tile) => ( + } + actionPosition="left" + titlePosition="top" + titleBackground="linear-gradient(to bottom, rgba(0,0,0,0.7) 0%,rgba(0,0,0,0.3) 70%,rgba(0,0,0,0) 100%)" + cols={tile.featured ? 2 : 1} + rows={tile.featured ? 2 : 1} + > + + + ))} + +
+); + + +// "http://www.material-ui.com/#/components/font-icon" +const FontIconExampleSimple = () => ( +
+ + + + + +
+); + +const FontIconExampleIcons = () => ( +
+ home + flight_takeoff + cloud_download + videogame_asset +
+); + + +// "http://www.material-ui.com/#/components/svg-icon" +const HomeIcon = (props) => ( + + + +); + +const SvgIconExampleSimple = () => ( +
+ + + +
+); + +const SvgIconExampleIcons = () => ( +
+ + + + +
+); + + +// "http://material-ui.com/#/components/lists" +const ListExampleSimple = () => ( + + + } /> + } /> + } /> + } /> + } /> + + + + } /> + } /> + } /> + } /> + + +); + +const ListExampleChat = () => ( + + + Recent chats + } + rightIcon={} + /> + } + rightIcon={} + /> + } + rightIcon={} + /> + } + rightIcon={} + /> + } + rightIcon={} + /> + + + + Previous chats + } + /> + } + /> + + +); + +const ListExampleContacts = () => ( + + + } + rightAvatar={} + /> + } + /> + } + /> + } + /> + + + + + A + + } + rightAvatar={} + /> + } + /> + } + /> + } + /> + + +); + +const ListExampleFolder = () => ( + + + Folders + } />} + rightIcon={} + primaryText="Photos" + secondaryText="Jan 9, 2014" + /> + } />} + rightIcon={} + primaryText="Recipes" + secondaryText="Jan 17, 2014" + /> + } />} + rightIcon={} + primaryText="Work" + secondaryText="Jan 28, 2014" + /> + + + + Files + } backgroundColor={blue500} />} + rightIcon={} + primaryText="Vacation itinerary" + secondaryText="Jan 20, 2014" + /> + } backgroundColor={yellow600} />} + rightIcon={} + primaryText="Kitchen remodel" + secondaryText="Jan 10, 2014" + /> + + +); + +const ListExampleNested = () => ( + + + Nested List Items + } /> + } /> + } + initiallyOpen={true} + primaryTogglesNestedList={true} + nestedItems={[ + } + />, + } + disabled={true} + nestedItems={[ + } />, + ]} + />, + ]} + /> + + +); + +const ListExampleSettings = () => ( +
+ + + General + + + + + + Hangout Notifications + } + primaryText="Notifications" + secondaryText="Allow notifications" + /> + } + primaryText="Sounds" + secondaryText="Hangouts message" + /> + } + primaryText="Video sounds" + secondaryText="Hangouts video call" + /> + + + + + + + + + Priority Interruptions + } /> + } /> + } /> + + + + Hangout Notifications + } /> + } /> + } /> + + +
+); + +const ListExamplePhone = () => ( + + + } + rightIcon={} + primaryText="(650) 555 - 1234" + secondaryText="Mobile" + /> + } + primaryText="(323) 555 - 6789" + secondaryText="Work" + /> + + + + } + primaryText="aliconnors@example.com" + secondaryText="Personal" + /> + + + +); + +const iconButtonElement = ( + + + +); + +const rightIconMenu = ( + + Reply + Forward + Delete + +); + +const ListExampleMessages = () => ( +
+ + + Today + } + primaryText="Brunch this weekend?" + secondaryText={ +

+ Brendan Lim -- + I'll be in your neighborhood doing errands this weekend. Do you want to grab brunch? +

+ } + secondaryTextLines={2} + /> + + } + primaryText={ +

Summer BBQ  4

+ } + secondaryText={ +

+ to me, Scott, Jennifer -- + Wish I could come, but I'm out of town this weekend. +

+ } + secondaryTextLines={2} + /> + + } + primaryText="Oui oui" + secondaryText={ +

+ Grace Ng -- + Do you have Paris recommendations? Have you ever been? +

+ } + secondaryTextLines={2} + /> + + } + primaryText="Birdthday gift" + secondaryText={ +

+ Kerem Suer -- + Do you have any ideas what we can get Heidi for her birthday? How about a pony? +

+ } + secondaryTextLines={2} + /> + + } + primaryText="Recipe to try" + secondaryText={ +

+ Raquel Parrado -- + We should eat this: grated squash. Corn and tomatillo tacos. +

+ } + secondaryTextLines={2} + /> +
+
+ + + Today + } + rightIconButton={rightIconMenu} + primaryText="Brendan Lim" + secondaryText={ +

+ Brunch this weekend?
+ I'll be in your neighborhood doing errands this weekend. Do you want to grab brunch? +

+ } + secondaryTextLines={2} + /> + + } + rightIconButton={rightIconMenu} + primaryText="me, Scott, Jennifer" + secondaryText={ +

+ Summer BBQ
+ Wish I could come, but I'm out of town this weekend. +

+ } + secondaryTextLines={2} + /> + + } + rightIconButton={rightIconMenu} + primaryText="Grace Ng" + secondaryText={ +

+ Oui oui
+ Do you have any Paris recs? Have you ever been? +

+ } + secondaryTextLines={2} + /> + + } + rightIconButton={rightIconMenu} + primaryText="Kerem Suer" + secondaryText={ +

+ Birthday gift
+ Do you have any ideas what we can get Heidi for her birthday? How about a pony? +

+ } + secondaryTextLines={2} + /> + + } + rightIconButton={rightIconMenu} + primaryText="Raquel Parrado" + secondaryText={ +

+ Recipe to try
+ We should eat this: grated squash. Corn and tomatillo tacos. +

+ } + secondaryTextLines={2} + /> +
+
+
+); + +function wrapState(ComposedComponent: React.ComponentClass<__MaterialUI.List.SelectableProps>) { + return class SelectableList extends Component<{defaultValue: number}, {selectedIndex: number}> { + static propTypes = { + children: PropTypes.node.isRequired, + defaultValue: PropTypes.number.isRequired, + }; + + componentWillMount() { + this.setState({ + selectedIndex: this.props.defaultValue, + }); + } + + handleRequestChange = (event, index) => { + this.setState({ + selectedIndex: index, + }); + }; + + render() { + return ( + + {this.props.children} + + ); + } + }; +} + +let SelectableList = wrapState(MakeSelectable(List)); + +const ListExampleSelectable = () => ( + + + Selectable Contacts + } + nestedItems={[ + } + />, + ]} + /> + } + /> + } + /> + } + /> + + +); + + +// "http://www.material-ui.com/#/components/menu" +const MenuExampleSimple = () => ( +
+ + + + + + + + + + + + + + + + +
+); + +const MenuExampleDisable = () => ( +
+ + + + + + + + + + + + + + + + + + + + +
+); + +const MenuExampleIcons = () => ( +
+ + + } /> + } /> + } /> + + } /> + } /> + + } /> + + + + + + } /> + settings} /> + settings + } + /> + ¶} /> + §} /> + + +
+); + +const MenuExampleSecondary = () => ( +
+ + + + + + + + + + } /> + } /> + } /> + } /> + } /> + + + + + + + + + + + + + + + + + + +
+); + +const MenuExampleNested = () => ( +
+ + + + + + } + menuItems={[ + } + menuItems={[ + , + , + , + , + ]} + />, + , + , + , + ]} + /> + + + + + + + +
+); + + +// "http://www.material-ui.com/#/components/icon-menu" +const IconMenuExampleSimple = () => ( +
+ } + anchorOrigin={{horizontal: 'left', vertical: 'top'}} + targetOrigin={{horizontal: 'left', vertical: 'top'}} + > + + + + + + + } + anchorOrigin={{horizontal: 'left', vertical: 'bottom'}} + targetOrigin={{horizontal: 'left', vertical: 'bottom'}} + > + + + + + + + } + anchorOrigin={{horizontal: 'right', vertical: 'bottom'}} + targetOrigin={{horizontal: 'right', vertical: 'bottom'}} + > + + + + + + + } + anchorOrigin={{horizontal: 'right', vertical: 'top'}} + targetOrigin={{horizontal: 'right', vertical: 'top'}} + > + + + + + + +
+); + +interface IconMenuExampleControlledState { + valueSingle?: string; + valueMultiple?: string[]; + openMenu?: boolean; +} + +class IconMenuExampleControlled extends React.Component<{}, IconMenuExampleControlledState> { + constructor(props) { + super(props); + + this.state = { + valueSingle: '3', + valueMultiple: ['3', '5'], + }; + } + + handleChangeSingle = (event, value) => { + this.setState({ + valueSingle: value, + }); + }; + + handleChangeMultiple = (event, value) => { + this.setState({ + valueMultiple: value, + }); + }; + + handleOpenMenu = () => { + this.setState({ + openMenu: true, + }); + } + + handleOnRequestChange = (value) => { + this.setState({ + openMenu: value, + }); + } + + render() { + return ( +
+ } + onChange={this.handleChangeSingle} + value={this.state.valueSingle} + > + + + + + + + } + onChange={this.handleChangeMultiple} + value={this.state.valueMultiple} + multiple={true} + > + + + + + + + + } + open={this.state.openMenu} + onRequestChange={this.handleOnRequestChange} + > + + + + + + +
+ ); + } +} + +const IconMenuExampleScrollable = () => ( + } + anchorOrigin={{horizontal: 'left', vertical: 'top'}} + targetOrigin={{horizontal: 'left', vertical: 'top'}} + maxHeight={272} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +const IconMenuExampleNested = () => ( +
+ } + anchorOrigin={{horizontal: 'left', vertical: 'top'}} + targetOrigin={{horizontal: 'left', vertical: 'top'}} + > + } + menuItems={[ + , + , + , + , + ]} + /> + + } + menuItems={[ + , + , + , + , + ]} + /> + + } /> + + + + +
+); + + +// "http://www.material-ui.com/#/components/dropdown-menu" +class DropDownMenuSimpleExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 1}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( +
+ + + + + + + +
+ + + + + + + +
+ ); + } +} + +class DropDownMenuOpenImmediateExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 2}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + + + + + + + ); + } +} + +const items: React.ReactElement<__MaterialUI.Menus.MenuItemProps>[] = []; +for (let i = 0; i < 100; i++ ) { + items.push(); +} + +class DropDownMenuLongMenuExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 10}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + {items} + + ); + } +} + +class DropDownMenuLabeledExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 2}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + + + + + + ); + } +} + + +// "http://material-ui.com/#/components/paper" +const PaperExampleSimple = () => ( +
+ + + + + +
+); + +const PaperExampleRounded = () => ( +
+ + + + + +
+); + +const PaperExampleCircle = () => ( +
+ + + + + +
+); + + +// "http://www.material-ui.com/#/components/popover" +class PopoverExampleSimple extends React.Component<{}, {open?: boolean, anchorEl?: React.ReactInstance}> { + + constructor(props) { + super(props); + + this.state = { + open: false, + }; + } + + handleTouchTap = (event) => { + // This prevents ghost click. + event.preventDefault(); + + this.setState({ + open: true, + anchorEl: event.currentTarget, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ + + + + + + + + +
+ ); + } +} + +class PopoverExampleAnimation extends React.Component<{}, {open?: boolean, anchorEl?: React.ReactInstance}> { + + constructor(props) { + super(props); + + this.state = { + open: false, + }; + } + + handleTouchTap = (event) => { + // This prevents ghost click. + event.preventDefault(); + this.setState({ + open: true, + anchorEl: event.currentTarget, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ + + + + + + + + +
+ ); + } +} + +interface PopoverExampleConfigurableState { + open?: boolean; + anchorOrigin?: __MaterialUI.propTypes.origin; + targetOrigin?: __MaterialUI.propTypes.origin; + anchorEl?: React.ReactInstance; +} + +class PopoverExampleConfigurable extends React.Component<{}, PopoverExampleConfigurableState> { + + constructor(props) { + super(props); + + this.state = { + open: false, + anchorOrigin: { + horizontal: 'left', + vertical: 'bottom', + }, + targetOrigin: { + horizontal: 'left', + vertical: 'top', + }, + }; + } + + handleTouchTap = (event) => { + // This prevents ghost click. + event.preventDefault(); + this.setState({ + open: true, + anchorEl: event.currentTarget, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + setAnchor = (positionElement, position) => { + const {anchorOrigin} = this.state; + anchorOrigin[positionElement] = position; + + this.setState({ + anchorOrigin: anchorOrigin, + }); + }; + + setTarget = (positionElement, position) => { + const {targetOrigin} = this.state; + targetOrigin[positionElement] = position; + + this.setState({ + targetOrigin: targetOrigin, + }); + }; + + render() { + return ( +
+ +

Current Settings

+
+          anchorOrigin: {JSON.stringify(this.state.anchorOrigin)}
+          
+ targetOrigin: {JSON.stringify(this.state.targetOrigin)} +
+

Position Options

+

Use the settings below to toggle the positioning of the popovers above

+

Anchor Origin

+
+
+ Vertical + + + +
+
+ Horizontal + + + +
+
+

Target Origin

+
+
+ Vertical + + + +
+
+ Horizontal + + + +
+
+ + + + + + + + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/circular-progress" +const CircularProgressExampleSimple = () => ( +
+ + + +
+); + +class CircularProgressExampleDeterminate extends React.Component<{}, {completed?: number}> { + private timer: number; + + constructor(props) { + super(props); + + this.state = { + completed: 0, + }; + } + + componentDidMount() { + this.timer = setTimeout(() => this.progress(5), 1000); + } + + componentWillUnmount() { + clearTimeout(this.timer); + } + + progress(completed) { + if (completed > 100) { + this.setState({completed: 100}); + } else { + this.setState({completed}); + const diff = Math.random() * 10; + this.timer = setTimeout(() => this.progress(completed + diff), 1000); + } + } + + render() { + return ( +
+ + + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/linear-progress" +const LinearProgressExampleSimple = () => ( + +); + +class LinearProgressExampleDeterminate extends React.Component<{}, {completed?: number}> { + private timer: number; + + constructor(props) { + super(props); + + this.state = { + completed: 0, + }; + } + + componentDidMount() { + this.timer = setTimeout(() => this.progress(5), 1000); + } + + componentWillUnmount() { + clearTimeout(this.timer); + } + + progress(completed) { + if (completed > 100) { + this.setState({completed: 100}); + } else { + this.setState({completed}); + const diff = Math.random() * 10; + this.timer = setTimeout(() => this.progress(completed + diff), 1000); + } + } + + render() { + return ( + + ); + } +} + + +// "http://www.material-ui.com/#/components/refresh-indicator" +const RefreshIndicatorExampleSimple = () => ( +
+ + + + +
+); + +const RefreshIndicatorExampleLoading = () => ( +
+ + +
+); + + +// "http://www.material-ui.com/#/components/select-field" +class SelectFieldExampleSimple extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 1}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( +
+ + + + + + + +
+ + + + +
+ + + + + + + +
+ + + + + + + +
+ ); + } +} + +class SelectFieldLongMenuExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 10}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + {items} + + ); + } +} + +class SelectFieldExampleCustomLabel extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 1}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + + + + + + ); + } +} + +const itemsPeriod = [ + , + , + , + , + , +]; + +export default class SelectFieldExampleFloatingLabel extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: null}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( +
+ + {itemsPeriod} + +
+ + {itemsPeriod} + +
+ ); + } +} + +class SelectFieldExampleError extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: null}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + const {value} = this.state; + + const night = value === 2 || value === 3; + + return ( +
+ + {itemsPeriod} + +
+ + {itemsPeriod} + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/slider" +const SliderExampleSimple = () => ( +
+ + + +
+); + +const SliderExampleDisabled = () => ( +
+ + + +
+); + +const SliderExampleStep = () => ( + +); + +class SliderExampleControlled extends React.Component<{}, {firstSlider?: number, secondSlider?: number}> { + + state = { + firstSlider: 0.5, + secondSlider: 50, + } + + handleFirstSlider(event, value) { + this.setState({firstSlider: value}); + } + + handleSecondSlider(event, value) { + this.setState({secondSlider: value}); + } + + render() { + return ( +
+ +

+ {'The value of this slider is: '} + {this.state.firstSlider} + {' from a range of 0 to 1 inclusive'} +

+ +

+ {'The value of this slider is: '} + {this.state.secondSlider} + {' from a range of 0 to 100 inclusive'} +

+
+ ); + } +} + + +// "http://www.material-ui.com/#/components/checkbox" +const CheckboxExampleSimple = () => ( +
+ + + } + uncheckedIcon={} + label="Custom icon" + style={styles.checkbox} + /> + + + +
+); + + +// "http://www.material-ui.com/#/components/radio-button" +const RadioButtonExampleSimple = () => ( +
+ + + + } + uncheckedIcon={} + style={styles.radioButton} + /> + + + + + + + + +
+); + + +// "http://www.material-ui.com/#/components/toggle" +const ToggleExampleSimple = () => ( +
+ + + + +
+); + + +// "http://material-ui.com/#/components/snackbar" +class SnackbarExampleSimple extends React.Component<{}, {open?: boolean}> { + + constructor(props) { + super(props); + this.state = { + open: false, + }; + } + + handleTouchTap = () => { + this.setState({ + open: true, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ + +
+ ); + } +} + +class SnackbarExampleAction extends React.Component<{}, {open?: boolean, autoHideDuration?: number, message?: string}> { + + constructor(props) { + super(props); + this.state = { + autoHideDuration: 4000, + message: 'Event added to your calendar', + open: false, + }; + } + + handleTouchTap = () => { + this.setState({ + open: true, + }); + }; + + handleActionTouchTap = () => { + this.setState({ + open: false, + }); + alert('Event removed from your calendar.'); + }; + + handleChangeDuration = (event) => { + const value = event.target.value; + this.setState({ + autoHideDuration: value.length > 0 ? parseInt(value) : 0, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ +
+ + +
+ ); + } +} + +class SnackbarExampleTwice extends React.Component<{}, {open?: boolean, message?: string}> { + + private timer: number; + + constructor(props) { + super(props); + this.state = { + message: 'Event 1 added to your calendar', + open: false, + }; + this.timer = undefined; + } + + componentWillUnMount() { + clearTimeout(this.timer); + } + + handleTouchTap = () => { + this.setState({ + open: true, + }); + + this.timer = setTimeout(() => { + this.setState({ + message: `Event ${Math.round(Math.random() * 100)} added to your calendar`, + }); + }, 1500); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/stepper" +class HorizontalLinearStepper extends React.Component<{}, {stepIndex?: number, finished?: boolean}> { + + state = { + finished: false, + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + this.setState({ + stepIndex: stepIndex + 1, + finished: stepIndex >= 2, + }); + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return 'Select campaign settings...'; + case 1: + return 'What is an ad group anyways?'; + case 2: + return 'This is the bit I really care about!'; + default: + return 'You\'re a long way from home sonny jim!'; + } + } + + render() { + const {finished, stepIndex} = this.state; + const contentStyle = {margin: '0 16px'}; + + return ( +
+ + + Select campaign settings + + + Create an ad group + + + Create an ad + + +
+ {finished ? ( +

+ { + event.preventDefault(); + this.setState({stepIndex: 0, finished: false}); + }} + > + Click here + to reset the example. +

+ ) : ( +
+

{this.getStepContent(stepIndex)}

+
+ + +
+
+ )} +
+
+ ); + } +} + +class VerticalLinearStepper extends React.Component<{}, {stepIndex?: number, finished?: boolean}> { + + state = { + finished: false, + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + this.setState({ + stepIndex: stepIndex + 1, + finished: stepIndex >= 2, + }); + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + renderStepActions(step) { + const {stepIndex} = this.state; + + return ( +
+ + {step > 0 && ( + + )} +
+ ); + } + + render() { + const {finished, stepIndex} = this.state; + + return ( +
+ + + Select campaign settings + +

+ For each ad campaign that you create, you can control how much + you're willing to spend on clicks and conversions, which networks + and geographical locations you want your ads to show on, and more. +

+ {this.renderStepActions(0)} +
+
+ + Create an ad group + +

An ad group contains one or more ads which target a shared set of keywords.

+ {this.renderStepActions(1)} +
+
+ + Create an ad + +

+ Try out different ad text to see what brings in the most customers, + and learn how to enhance your ads using features like ad extensions. + If you run into any problems with your ads, find out how to tell if + they're running and how to resolve approval issues. +

+ {this.renderStepActions(2)} +
+
+
+ {finished && ( +

+ { + event.preventDefault(); + this.setState({stepIndex: 0, finished: false}); + }} + > + Click here + to reset the example. +

+ )} +
+ ); + } +} + +class HorizontalNonLinearStepper extends React.Component<{}, {stepIndex?: number}> { + + state = { + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + if (stepIndex < 2) { + this.setState({stepIndex: stepIndex + 1}); + } + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return 'Select campaign settings...'; + case 1: + return 'What is an ad group anyways?'; + case 2: + return 'This is the bit I really care about!'; + default: + return 'You\'re a long way from home sonny jim!'; + } + } + + render() { + const {stepIndex} = this.state; + const contentStyle = {margin: '0 16px'}; + + return ( +
+ + + this.setState({stepIndex: 0})}> + Select campaign settings + + + + this.setState({stepIndex: 1})}> + Create an ad group + + + + this.setState({stepIndex: 2})}> + Create an ad + + + +
+

{this.getStepContent(stepIndex)}

+
+ + +
+
+
+ ); + } +} + +class VerticalNonLinear extends React.Component<{}, {stepIndex?: number}> { + + state = { + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + if (stepIndex < 2) { + this.setState({stepIndex: stepIndex + 1}); + } + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + renderStepActions(step) { + return ( +
+ + {step > 0 && ( + + )} +
+ ); + } + + render() { + const {stepIndex} = this.state; + + return ( +
+ + + this.setState({stepIndex: 0})}> + Select campaign settings + + +

+ For each ad campaign that you create, you can control how much + you're willing to spend on clicks and conversions, which networks + and geographical locations you want your ads to show on, and more. +

+ {this.renderStepActions(0)} +
+
+ + this.setState({stepIndex: 1})}> + Create an ad group + + +

An ad group contains one or more ads which target a shared set of keywords.

+ {this.renderStepActions(1)} +
+
+ + this.setState({stepIndex: 2})}> + Create an ad + + +

+ Try out different ad text to see what brings in the most customers, + and learn how to enhance your ads using features like ad extensions. + If you run into any problems with your ads, find out how to tell if + they're running and how to resolve approval issues. +

+ {this.renderStepActions(2)} +
+
+
+
+ ); + } +} + +const getStyles = () => { + return { + root: { + width: '100%', + maxWidth: 700, + margin: 'auto', + }, + content: { + margin: '0 16px', + }, + actions: { + marginTop: 12, + }, + backButton: { + marginRight: 12, + }, + }; +}; + +class GranularControlStepper extends React.Component<{}, {stepIndex?: number, visited?: number[]}> { + + state = { + stepIndex: null, + visited: [], + }; + + componentWillMount() { + const {stepIndex, visited} = this.state; + this.setState({visited: visited.concat(stepIndex)}); + } + + componentWillUpdate(nextProps, nextState) { + const {stepIndex, visited} = nextState; + if (visited.indexOf(stepIndex) === -1) { + this.setState({visited: visited.concat(stepIndex)}); + } + } + + handleNext = () => { + const {stepIndex} = this.state; + if (stepIndex < 2) { + this.setState({stepIndex: stepIndex + 1}); + } + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return 'Select campaign settings...'; + case 1: + return 'What is an ad group anyways?'; + case 2: + return 'This is the bit I really care about!'; + default: + return 'Click a step to get started.'; + } + } + + render() { + const {stepIndex, visited} = this.state; + const styles = getStyles(); + + return ( +
+

+ { + event.preventDefault(); + this.setState({stepIndex: null, visited: []}); + }} + > + Click here + to reset the example. +

+ + + this.setState({stepIndex: 0})}> + Select campaign settings + + + + this.setState({stepIndex: 1})}> + Create an ad group + + + + this.setState({stepIndex: 2})}> + Create an ad + + + +
+

{this.getStepContent(stepIndex)}

+ {stepIndex !== null && ( +
+ + +
+ )} +
+
+ ); + } +} + +class CustomIcon extends React.Component<{}, {stepIndex?: number}> { + + state = { + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + if (stepIndex < 2) { + this.setState({stepIndex: stepIndex + 1}); + } + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return 'Select campaign settings...'; + case 1: + return 'What is an ad group anyways?'; + case 2: + return 'This is the bit I really care about!'; + default: + return 'You\'re a long way from home sonny jim!'; + } + } + + render() { + return ( +
+ + + + Select campaign settings + + + + } + style={{color: red500}} + > + Create an ad group + + + + + Create an ad + + + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/subheader" +// Included in ListExampleChat and ListExampleFolder + +// "http://www.material-ui.com/#/components/table" +const TableExampleSimple = () => ( + + + + ID + Name + Status + + + + + 1 + John Smith + Employed + + + 2 + Randal White + Unemployed + + + 3 + Stephanie Sanders + Employed + + + 4 + Steve Brown + Employed + + +
+); + +const tableData: {name: string, status: string, selected?: boolean}[] = [ + { + name: 'John Smith', + status: 'Employed', + selected: true, + }, + { + name: 'Randal White', + status: 'Unemployed', + }, + { + name: 'Stephanie Sanders', + status: 'Employed', + selected: true, + }, + { + name: 'Steve Brown', + status: 'Employed', + }, + { + name: 'Joyce Whitten', + status: 'Employed', + }, + { + name: 'Samuel Roberts', + status: 'Employed', + }, + { + name: 'Adam Moore', + status: 'Employed', + }, +]; + +interface TableExampleComplexState { + fixedHeader?: boolean, + fixedFooter?: boolean, + stripedRows?: boolean, + showRowHover?: boolean, + selectable?: boolean, + multiSelectable?: boolean, + enableSelectAll?: boolean, + deselectOnClickaway?: boolean, + showCheckboxes?: boolean, + height?: string, +} + +class TableExampleComplex extends React.Component<{}, TableExampleComplexState> { + + constructor(props) { + super(props); + + this.state = { + fixedHeader: true, + fixedFooter: true, + stripedRows: false, + showRowHover: false, + selectable: true, + multiSelectable: false, + enableSelectAll: false, + deselectOnClickaway: true, + showCheckboxes: true, + height: '300px', + }; + } + + handleToggle = (event, toggled) => { + this.setState({ + [event.target.name]: toggled, + }); + }; + + handleChange = (event) => { + this.setState({height: event.target.value}); + }; + + render() { + return ( +
+ + + + + Super Header + + + + ID + Name + Status + + + + {tableData.map( (row, index) => ( + + {index} + {row.name} + {row.status} + + ))} + + + + ID + Name + Status + + + + Super Footer + + + +
+ +
+

Table Properties

+ + + + + + +

TableBody Properties

+ + + +

Multiple Properties

+ +
+
+ ); + } +} + +// "http://www.material-ui.com/#/components/tabs" +function handleActive(tab) { + alert(`A tab with this value property ${tab.props.value} was activated.`); +} + +const TabsExampleSimple = () => ( + + +
+

Tab One

+

+ This is an example tab. +

+

+ You can put any sort of HTML or react component in here. It even keeps the component state! +

+ +
+
+ +
+

Tab Two

+

+ This is another example tab. +

+
+
+ +
+

Tab Three

+

+ This is a third example tab. +

+
+
+
+); + +class TabsExampleControlled extends React.Component<{}, {value?: string}> { + + constructor(props) { + super(props); + this.state = { + value: 'a', + }; + } + + handleChange = (value) => { + this.setState({ + value: value, + }); + }; + + render() { + return ( + + +
+

Controllable Tab A

+

+ Tabs are also controllable if you want to programmatically pass them their values. + This allows for more functionality in Tabs such as not + having any Tab selected or assigning them different values. +

+
+
+ +
+

Controllable Tab B

+

+ This is another example of a controllable tab. Remember, if you + use controllable Tabs, you need to give all of your tabs values or else + you wont be able to select them. +

+
+
+
+ ); + } +} + +const TabsExampleIcon = () => ( + + } /> + } /> + favorite} /> + +); + +const TabsExampleIconText = () => ( + + phone} + label="RECENTS" + /> + favorite} + label="FAVORITES" + /> + } + label="NEARBY" + /> + +); + + +// "http://www.material-ui.com/#/components/text-field" +const TextFieldExampleSimple = () => ( +
+
+
+
+
+
+
+
+
+
+ +
+); + +const TextFieldExampleError = () => ( +
+
+
+
+
+
+); + +const TextFieldExampleCustomize = () => ( +
+
+
+
+
+ +
+); + +const TextFieldExampleDisabled = () => ( +
+
+
+
+ +
+); + +class TextFieldExampleControlled extends React.Component<{}, {value?: string}> { + + constructor(props) { + super(props); + + this.state = { + value: 'Property Value', + }; + } + + handleChange = (event) => { + this.setState({ + value: event.target.value, + }); + }; + + render() { + return ( +
+ +
+ ); + } +} + +// "http://www.material-ui.com/#/components/time-picker" +const TimePickerExampleSimple = () => ( +
+ + + +
+); + +class TimePickerExampleComplex extends React.Component<{}, {value24?: Date, value12?: Date}> { + + constructor(props) { + super(props); + this.state = {value24: null, value12: null}; + } + + handleChangeTimePicker24 = (event, date) => { + this.setState({value24: date}); + }; + + handleChangeTimePicker12 = (event, date) => { + this.setState({value12: date}); + }; + + render() { + return ( +
+ + +
+ ); + } +} + +const TimePickerInternational = () => ( +
+ +
+); + + +// "http://www.material-ui.com/#/components/toolbar" +class ToolbarExamplesSimple extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = { + value: 3, + }; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + + + + + + + + + + + + + + + + + + + + } + > + + + + + + ); + } +} + + +interface MaterialUiTestsState { +} + +class MaterialUiTests extends React.Component<{}, MaterialUiTestsState> { + + render () { + return ( + + + + + ); + } +} + +// "http://www.material-ui.com/#/get-started/usage" +ReactDOM.render( + , + document.getElementById('app') +); \ No newline at end of file diff --git a/material-ui/legacy/material-ui-0.15.0-tests.tsx.tscparams b/material-ui/legacy/material-ui-0.15.0-tests.tsx.tscparams new file mode 100644 index 0000000000..855355b85f --- /dev/null +++ b/material-ui/legacy/material-ui-0.15.0-tests.tsx.tscparams @@ -0,0 +1 @@ +--experimentalDecorators \ No newline at end of file diff --git a/material-ui/legacy/material-ui-0.15.0.d.ts b/material-ui/legacy/material-ui-0.15.0.d.ts new file mode 100644 index 0000000000..d566c16a46 --- /dev/null +++ b/material-ui/legacy/material-ui-0.15.0.d.ts @@ -0,0 +1,8414 @@ +// Type definitions for material-ui v0.15.0 +// Project: https://github.com/callemall/material-ui +// Definitions by: Nathan Brown , Oliver Herrmann +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "material-ui" { + export import AppBar = __MaterialUI.AppBar; + export import AutoComplete = __MaterialUI.AutoComplete; + export import Avatar = __MaterialUI.Avatar; + export import Badge = __MaterialUI.Badge; + export import Card = __MaterialUI.Card.Card; + export import CardActions = __MaterialUI.Card.CardActions; + export import CardHeader = __MaterialUI.Card.CardHeader; + export import CardMedia = __MaterialUI.Card.CardMedia; + export import CardText = __MaterialUI.Card.CardText; + export import CardTitle = __MaterialUI.Card.CardTitle; + export import Checkbox = __MaterialUI.Switches.Checkbox; + export import CircularProgress = __MaterialUI.CircularProgress; + export import DatePicker = __MaterialUI.DatePicker.DatePicker; + export import Dialog = __MaterialUI.Dialog; + export import Divider = __MaterialUI.Divider; + export import Drawer = __MaterialUI.Drawer; + export import DropDownMenu = __MaterialUI.Menus.DropDownMenu; + export import FlatButton = __MaterialUI.FlatButton; + export import FloatingActionButton = __MaterialUI.FloatingActionButton; + export import FontIcon = __MaterialUI.FontIcon; + export import GridList = __MaterialUI.GridList.GridList; + export import GridTile = __MaterialUI.GridList.GridTile; + export import IconButton = __MaterialUI.IconButton; + export import IconMenu = __MaterialUI.Menus.IconMenu; + export import LinearProgress = __MaterialUI.LinearProgress; + export import List = __MaterialUI.List.List; + export import ListItem = __MaterialUI.List.ListItem; + export import MakeSelectable = __MaterialUI.List.MakeSelectable; + export import Menu = __MaterialUI.Menus.Menu; + export import MenuItem = __MaterialUI.Menus.MenuItem; + export import Paper = __MaterialUI.Paper; + export import Popover = __MaterialUI.Popover.Popover; + export import RadioButton = __MaterialUI.Switches.RadioButton; + export import RadioButtonGroup = __MaterialUI.Switches.RadioButtonGroup; + export import RaisedButton = __MaterialUI.RaisedButton; + export import RefreshIndicator = __MaterialUI.RefreshIndicator; + export import SelectField = __MaterialUI.SelectField; + export import Slider = __MaterialUI.Slider; + export import Subheader = __MaterialUI.Subheader; + export import SvgIcon = __MaterialUI.SvgIcon; + export import Step = __MaterialUI.Stepper.Step; + export import StepButton = __MaterialUI.Stepper.StepButton; + export import StepContent = __MaterialUI.Stepper.StepContent; + export import StepLabel = __MaterialUI.Stepper.StepLabel; + export import Stepper = __MaterialUI.Stepper; + export import Snackbar = __MaterialUI.Snackbar; + export import Tab = __MaterialUI.Tabs.Tab; + export import Tabs = __MaterialUI.Tabs.Tabs; + export import Table = __MaterialUI.Table.Table; + export import TableBody = __MaterialUI.Table.TableBody; + export import TableFooter = __MaterialUI.Table.TableFooter; + export import TableHeader = __MaterialUI.Table.TableHeader; + export import TableHeaderColumn = __MaterialUI.Table.TableHeaderColumn; + export import TableRow = __MaterialUI.Table.TableRow; + export import TableRowColumn = __MaterialUI.Table.TableRowColumn; + export import TextField = __MaterialUI.TextField; + export import TimePicker = __MaterialUI.TimePicker; + export import Toggle = __MaterialUI.Switches.Toggle; + export import Toolbar = __MaterialUI.Toolbar.Toolbar; + export import ToolbarGroup = __MaterialUI.Toolbar.ToolbarGroup; + export import ToolbarSeparator = __MaterialUI.Toolbar.ToolbarSeparator; + export import ToolbarTitle = __MaterialUI.Toolbar.ToolbarTitle; + + // export type definitions + export type TouchTapEvent = __MaterialUI.TouchTapEvent; + export type TouchTapEventHandler = __MaterialUI.TouchTapEventHandler; +} + +declare namespace __MaterialUI { + export import React = __React; + + // ReactLink is from "react/addons" + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + // What's common between React.TouchEvent and React.MouseEvent + interface TouchTapEvent extends React.SyntheticEvent { + altKey: boolean; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + } + + // What's common between React.TouchEventHandler and React.MouseEventHandler + interface TouchTapEventHandler extends React.EventHandler { } + + interface ThemeWrapperProps extends React.Props { + theme: Styles.MuiTheme; + } + export class ThemeWrapper extends React.Component { + } + + export namespace Styles { + interface Spacing { + iconSize?: number; + + desktopGutter?: number; + desktopGutterMore?: number; + desktopGutterLess?: number; + desktopGutterMini?: number; + desktopKeylineIncrement?: number; + desktopDropDownMenuItemHeight?: number; + desktopDropDownMenuFontSize?: number; + desktopLeftNavMenuItemHeight?: number; + desktopSubheaderHeight?: number; + desktopToolbarHeight?: number; + } + export var Spacing: Spacing; + + interface ThemePalette { + primary1Color?: string; + primary2Color?: string; + primary3Color?: string; + accent1Color?: string; + accent2Color?: string; + accent3Color?: string; + textColor?: string; + alternateTextColor?: string; + canvasColor?: string; + borderColor?: string; + disabledColor?: string; + pickerHeaderColor?: string; + clockCircleColor?: string; + shadowColor?: string; + } + interface MuiTheme { + spacing?: Spacing; + fontFamily?: string; + palette?: ThemePalette; + isRtl?: boolean; + userAgent?: string; + zIndex?: zIndex; + baseTheme?: RawTheme; + rawTheme?: RawTheme; + appBar?: { + color?: string; + textColor?: string; + height?: number; + titleFontWeight?: number; + padding?: number; + }; + avatar?: { + color?: string; + backgroundColor?: string; + borderColor?: string; + }; + badge?: { + color?: string; + textColor?: string; + primaryColor?: string; + primaryTextColor?: string; + secondaryColor?: string; + secondaryTextColor?: string; + fontWeight?: number; + }; + button?: { + height?: number; + minWidth?: number; + iconButtonSize?: number; + }; + card?: { + titleColor?: string; + subtitleColor?: string; + fontWeight?: number; + }; + cardMedia?: { + color?: string; + overlayContentBackground?: string; + titleColor?: string; + subtitleColor?: string; + }; + cardText?: { + textColor?: string; + }; + checkbox?: { + boxColor?: string; + checkedColor?: string; + requiredColor?: string; + disabledColor?: string; + labelColor?: string; + labelDisabledColor?: string; + }; + chip?: { + backgroundColor?: string; + deleteIconColor?: string; + textColor?: string; + fontSize?: number; + fontWeight?: number; + shadow?: string; + }; + datePicker?: { + color?: string; + textColor?: string; + calendarTextColor?: string; + selectColor?: string; + selectTextColor?: string; + calendarYearBackgroundColor?: string; + }; + dialog?: { + titleFontSize?: number; + bodyFontSize?: number; + bodyColor?: string; + }; + dropDownMenu?: { + accentColor?: string; + }; + enhancedButton?: { + tapHighlightColor?: string; + }; + flatButton?: { + color?: string; + buttonFilterColor?: string; + disabledTextColor?: string; + textColor?: string; + primaryTextColor?: string; + secondaryTextColor?: string; + fontSize?: number; + fontWeight?: number; + }; + floatingActionButton?: { + buttonSize?: number; + miniSize?: number; + color?: string; + iconColor?: string; + secondaryColor?: string; + secondaryIconColor?: string; + disabledTextColor?: string; + disabledColor?: string; + }; + gridTile?: { + textColor?: string; + }; + icon?: { + color?: string; + backgroundColor?: string; + }; + inkBar?: { + backgroundColor?: string; + }; + navDrawer?: { + width?: number; + color?: string; + }; + listItem?: { + nestedLevelDepth?: number; + secondaryTextColor?: string; + leftIconColor?: string; + rightIconColor?: string; + }; + menu?: { + backgroundColor?: string; + containerBackgroundColor?: string; + }; + menuItem?: { + dataHeight?: number; + height?: number; + hoverColor?: string; + padding?: number; + selectedTextColor?: string; + rightIconDesktopFill?: string; + }; + menuSubheader?: { + padding?: number; + borderColor?: string; + textColor?: string; + }; + overlay?: { + backgroundColor?: string; + }; + paper?: { + color?: string; + backgroundColor?: string; + zDepthShadows?: string[]; + }; + radioButton?: { + borderColor?: string; + backgroundColor?: string; + checkedColor?: string; + requiredColor?: string; + disabledColor?: string; + size?: number; + labelColor?: string; + labelDisabledColor?: string; + }; + raisedButton?: { + color?: string; + textColor?: string; + primaryColor?: string; + primaryTextColor?: string; + secondaryColor?: string; + secondaryTextColor?: string; + disabledColor?: string; + disabledTextColor?: string; + fontSize?: number; + fontWeight?: number; + }; + refreshIndicator?: { + strokeColor?: string; + loadingStrokeColor?: string; + }; + ripple?: { + color?: string; + }; + slider?: { + trackSize?: number; + trackColor?: string; + trackColorSelected?: string; + handleSize?: number; + handleSizeDisabled?: number; + handleSizeActive?: number; + handleColorZero?: string; + handleFillColor?: string; + selectionColor?: string; + rippleColor?: string; + }; + snackbar?: { + textColor?: string; + backgroundColor?: string; + actionColor?: string; + }; + subheader?: { + color?: string; + fontWeight?: number; + }; + stepper?: { + backgroundColor?: string; + hoverBackgroundColor?: string; + iconColor?: string; + hoveredIconColor?: string; + inactiveIconColor?: string; + textColor?: string; + disabledTextColor?: string; + connectorLineColor?: string; + }; + table?: { + backgroundColor?: string; + }; + tableFooter?: { + borderColor?: string; + textColor?: string; + }; + tableHeader?: { + borderColor?: string; + }; + tableHeaderColumn?: { + textColor?: string; + height?: number; + spacing?: number; + }; + tableRow?: { + hoverColor?: string; + stripeColor?: string; + selectedColor?: string; + textColor?: string; + borderColor?: string; + height?: number; + }; + tableRowColumn?: { + height?: number; + spacing?: number; + }; + tabs?: { + backgroundColor?: string; + textColor?: string; + selectedTextColor?: string; + }; + textField?: { + textColor?: string; + hintColor?: string; + floatingLabelColor?: string; + disabledTextColor?: string; + errorColor?: string; + focusColor?: string; + backgroundColor?: string; + borderColor?: string; + }; + timePicker?: { + color?: string; + textColor?: string; + accentColor?: string; + clockColor?: string; + clockCircleColor?: string; + headerColor?: string; + selectColor?: string; + selectTextColor?: string; + }; + toggle?: { + thumbOnColor?: string; + thumbOffColor?: string; + thumbDisabledColor?: string; + thumbRequiredColor?: string; + trackOnColor?: string; + trackOffColor?: string; + trackDisabledColor?: string; + labelColor?: string; + labelDisabledColor?: string; + trackRequiredColor?: string; + }; + toolbar?: { + color?: string; + hoverColor?: string; + backgroundColor?: string; + height?: number; + titleFontSize?: number; + iconColor?: string; + separatorColor?: string; + menuHoverColor?: string; + }; + tooltip?: { + color?: string; + rippleBackgroundColor?: string; + }; + } + + interface zIndex { + menu: number; + appBar: number; + drawerOverlay: number; + navDrawer: number; + dialogOverlay: number; + dialog: number; + layer: number; + popover: number; + snackbar: number; + tooltip: number; + } + export var zIndex: zIndex; + + interface RawTheme { + spacing?: Spacing; + fontFamily?: string; + palette?: ThemePalette; + } + var lightBaseTheme: RawTheme; + var darkBaseTheme: RawTheme; + + export function muiThemeable, P, S>(): (component: TComponent) => TComponent; + + //** @deprecated use MuiThemeProvider instead **/ + export function themeDecorator(muiTheme: Styles.MuiTheme): (Component: TFunction) => TFunction; + + interface MuiThemeProviderProps extends React.Props { + muiTheme: Styles.MuiTheme; + } + export class MuiThemeProvider extends React.Component{ + } + + export function getMuiTheme(...muiTheme: MuiTheme[]): MuiTheme; + + interface ThemeManager { + //** @deprecated ThemeManager is deprecated. please import getMuiTheme directly from "material-ui/styles/getMuiTheme" **/ + getMuiTheme(baseTheme: RawTheme, muiTheme?: MuiTheme): MuiTheme; + + //** @deprecated modifyRawThemeSpacing is deprecated. please use getMuiTheme to modify your theme directly. http://www.material-ui.com/#/customization/themes **/ + modifyRawThemeSpacing(muiTheme: MuiTheme, newSpacing: Spacing): MuiTheme; + + //** @deprecated modifyRawThemePalette is deprecated. please use getMuiTheme to modify your theme directly. http://www.material-ui.com/#/customization/themes **/ + modifyRawThemePalette(muiTheme: MuiTheme, newPaletteKeys: ThemePalette): MuiTheme; + + //** @deprecated modifyRawThemeFontFamily is deprecated. please use getMuiTheme to modify your theme directly. http://www.material-ui.com/#/customization/themes **/ + modifyRawThemeFontFamily(muiTheme: MuiTheme, newFontFamily: string): MuiTheme; + } + export var ThemeManager: ThemeManager; + + interface Transitions { + easeOut(duration?: string, property?: string | string[], delay?: string, easeFunction?: string): string; + create(duration?: string, property?: string, delay?: string, easeFunction?: string): string; + easeOutFunction: string; + easeInOutFunction: string; + } + export var Transitions: Transitions; + + interface Typography { + textFullBlack: string; + textDarkBlack: string; + textLightBlack: string; + textMinBlack: string; + textFullWhite: string; + textDarkWhite: string; + textLightWhite: string; + + // font weight + fontWeightLight: number; + fontWeightNormal: number; + fontWeightMedium: number; + + fontStyleButtonFontSize: number; + } + export var Typography: Typography; + + //** @deprecated use darkBaseTheme instead **/ + export var DarkRawTheme: RawTheme; + + //** @deprecated use lightBaseTheme instead **/ + export var LightRawTheme: RawTheme; + } + + interface AppBarProps extends React.Props { + className?: string; + iconClassNameLeft?: string; + iconClassNameRight?: string; + iconElementLeft?: React.ReactElement; + iconElementRight?: React.ReactElement; + iconStyleRight?: string; + onLeftIconButtonTouchTap?: TouchTapEventHandler; + onRightIconButtonTouchTap?: TouchTapEventHandler; + onTitleTouchTap?: TouchTapEventHandler; + showMenuIconButton?: boolean; + style?: React.CSSProperties; + title?: React.ReactNode; + titleStyle?: React.CSSProperties; + zDepth?: number; + } + export class AppBar extends React.Component{ + } + + interface AppCanvasProps extends React.Props { + } + export class AppCanvas extends React.Component { + } + + namespace propTypes { + type horizontal = 'left' | 'middle' | 'right'; + type vertical = 'top' | 'center' | 'bottom'; + + interface origin { + horizontal: horizontal; + vertical: vertical; + } + + type corners = 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'; + type cornersAndCenter = 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right'; + } + + type AutoCompleteDataItem = { text: string, value: React.ReactNode } | string; + type AutoCompleteDataSource = { text: string, value: React.ReactNode }[] | string[]; + interface AutoCompleteProps extends React.Props { + anchorOrigin?: propTypes.origin; + animated?: boolean; + dataSource: AutoCompleteDataSource; + disableFocusRipple?: boolean; + errorStyle?: React.CSSProperties; + errorText?: string; + filter?: (searchText: string, key: string, item: AutoCompleteDataItem) => boolean; + floatingLabelText?: string; + fullWidth?: boolean; + hintText?: string; + listStyle?: React.CSSProperties; + maxSearchResults?: number; + menuCloseDelay?: number; + menuProps?: any; + menuStyle?: React.CSSProperties; + onBlur?: React.FocusEventHandler; + onFocus?: React.FocusEventHandler; + onKeyDown?: React.KeyboardEventHandler; + onNewRequest?: (chosenRequest: string, index: number) => void; + onUpdateInput?: (searchText: string, dataSource: AutoCompleteDataSource) => void; + open?: boolean; + openOnFocus?: boolean; + searchText?: string; + style?: React.CSSProperties; + targetOrigin?: propTypes.origin; + /** @deprecated Instead, use openOnFocus */ + triggerUpdateOnFocus?: boolean; + } + export class AutoComplete extends React.Component { + static noFilter: () => boolean; + static defaultFilter: (searchText: string, key: string) => boolean; + static caseSensitiveFilter: (searchText: string, key: string) => boolean; + static caseInsensitiveFilter: (searchText: string, key: string) => boolean; + static levenshteinDistanceFilter(distanceLessThan: number): (searchText: string, key: string) => boolean; + static fuzzyFilter: (searchText: string, key: string) => boolean; + static Item: Menus.MenuItem; + static Divider: Divider; + } + + interface AvatarProps extends React.Props { + backgroundColor?: string; + className?: string; + color?: string; + icon?: React.ReactElement; + size?: number; + src?: string; + style?: React.CSSProperties; + } + export class Avatar extends React.Component { + } + + interface BadgeProps extends React.Props { + badgeContent: React.ReactNode; + badgeStyle?: React.CSSProperties; + className?: string; + primary?: boolean; + secondary?: boolean; + style?: React.CSSProperties; + } + export class Badge extends React.Component { + } + + interface BeforeAfterWrapperProps extends React.Props { + afterElementType?: string; + afterStyle?: React.CSSProperties; + beforeElementType?: string; + beforeStyle?: React.CSSProperties; + elementType?: string; + style?: React.CSSProperties; + } + export class BeforeAfterWrapper extends React.Component { + } + + // non generally overridden elements of EnhancedButton + interface SharedEnhancedButtonProps extends React.Props { + centerRipple?: boolean; + disableFocusRipple?: boolean; + disableKeyboardFocus?: boolean; + disableTouchRipple?: boolean; + focusRippleColor?: string; + focusRippleOpacity?: number; + keyboardFocused?: boolean; + linkButton?: boolean; + onBlur?: React.FocusEventHandler; + onFocus?: React.FocusEventHandler; + onKeyboardFocus?: (e: React.FocusEvent, isKeyboardFocused: boolean) => void; + onKeyDown?: React.KeyboardEventHandler; + onKeyUp?: React.KeyboardEventHandler; + onTouchTap?: TouchTapEventHandler; + onClick?: React.MouseEventHandler; + style?: React.CSSProperties; + tabIndex?: number; + touchRippleColor?: string; + touchRippleOpacity?: number; + type?: string; + containerElement?: React.ReactNode | string; + } + + interface EnhancedButtonProps extends React.HTMLAttributes, SharedEnhancedButtonProps { + // container element,