From 5b4d51844315721f62afb5f3b358e4fd2fc9f93d Mon Sep 17 00:00:00 2001 From: mc-petry Date: Tue, 15 Dec 2015 13:27:17 +0200 Subject: [PATCH 01/40] Update redux devtools to v3 --- .../redux-devtools-dock-monitor.d.ts | 63 ++++++++++ .../redux-devtools-log-monitor.d.ts | 43 +++++++ redux-devtools/redux-devtools-2.1.4-tests.tsx | 62 ++++++++++ redux-devtools/redux-devtools-2.1.4.d.ts | 109 +++++++++++++++++ redux-devtools/redux-devtools-tests.tsx | 84 +++++-------- redux-devtools/redux-devtools.d.ts | 113 ++---------------- 6 files changed, 318 insertions(+), 156 deletions(-) create mode 100644 redux-devtools-dock-monitor/redux-devtools-dock-monitor.d.ts create mode 100644 redux-devtools-log-monitor/redux-devtools-log-monitor.d.ts create mode 100644 redux-devtools/redux-devtools-2.1.4-tests.tsx create mode 100644 redux-devtools/redux-devtools-2.1.4.d.ts diff --git a/redux-devtools-dock-monitor/redux-devtools-dock-monitor.d.ts b/redux-devtools-dock-monitor/redux-devtools-dock-monitor.d.ts new file mode 100644 index 000000000..f7e3ded8c --- /dev/null +++ b/redux-devtools-dock-monitor/redux-devtools-dock-monitor.d.ts @@ -0,0 +1,63 @@ +// Type definitions for redux-devtools-dock-monitor 1.0.1 +// Project: https://github.com/gaearon/redux-devtools-dock-monitor +// Definitions by: Petryshyn Sergii +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "redux-devtools-dock-monitor" { + import * as React from 'react' + + interface IDockMonitorProps { + /** + * Any valid Redux DevTools monitor. + */ + children?: React.ReactNode + + /** + * A key or a key combination that toggles the dock visibility. + * Must be recognizable by parse-key (for example, 'ctrl-h') + */ + toggleVisibilityKey: string + + /** + * A key or a key combination that toggles the dock position. + * Must be recognizable by parse-key (for example, 'ctrl-w') + */ + changePositionKey: string + + /** + * When true, the dock size is a fraction of the window size, fixed otherwise. + * + * @default true + */ + fluid?: boolean + + /** + * Size of the dock. When fluid is true, a float (0.5 means half the window size). + * When fluid is false, a width in pixels + * + * @default 0.3 (3/10th of the window size) + */ + defaultSize?: number + + /** + * Where the dock appears on the screen. + * Valid values: 'left', 'top', 'right', 'bottom' + * + * @default 'right' + */ + defaultPosition?: string + + /** + * @default true + */ + defaultIsVisible?: boolean + } + + class DockMonitor extends React.Component { + } + + let dockMonitor: (new () => DockMonitor) + export = dockMonitor +} \ No newline at end of file diff --git a/redux-devtools-log-monitor/redux-devtools-log-monitor.d.ts b/redux-devtools-log-monitor/redux-devtools-log-monitor.d.ts new file mode 100644 index 000000000..0dbd2e107 --- /dev/null +++ b/redux-devtools-log-monitor/redux-devtools-log-monitor.d.ts @@ -0,0 +1,43 @@ +// Type definitions for redux-devtools-log-monitor 1.0.1 +// Project: https://github.com/gaearon/redux-devtools-log-monitor +// Definitions by: Petryshyn Sergii +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "redux-devtools-log-monitor" { + import * as React from 'react' + + interface ILogMonitorProps { + /** + * Either a string referring to one of the themes provided by + * redux-devtools-themes or a custom object of the same format. + * + * @see https://github.com/gaearon/redux-devtools-themes + */ + theme?: string + + /** + * A function that selects the slice of the state for DevTools to show. + * + * @example state => state.thePart.iCare.about. + * @default state => state. + */ + select?: (state: any) => any + + /** + * When true, records the current scroll top every second so it + * can be restored on refresh. This only has effect when used together + * with persistState() enhancer from Redux DevTools. + * + * @default true + */ + preserveScrollTop?: boolean + } + + class LogMonitor extends React.Component { + } + + var logMonitor: (new () => LogMonitor) + export = logMonitor +} \ No newline at end of file diff --git a/redux-devtools/redux-devtools-2.1.4-tests.tsx b/redux-devtools/redux-devtools-2.1.4-tests.tsx new file mode 100644 index 000000000..c17aa38ab --- /dev/null +++ b/redux-devtools/redux-devtools-2.1.4-tests.tsx @@ -0,0 +1,62 @@ +/// +/// +/// + +import { compose, createStore, applyMiddleware, Middleware, Reducer } from 'redux'; +import { devTools, persistState } from 'redux-devtools'; +import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react'; +import * as React from 'react'; +import { Component } from 'react'; + +declare var m1: Middleware; +declare var m2: Middleware; +declare var m3: Middleware; +declare var reducer: Reducer; +class CounterApp extends Component { }; +class Provider extends Component<{ store: any }, any> { }; + +const finalCreateStore = compose( + // Enables your middleware: + applyMiddleware(m1, m2, m3), // any Redux middleware, e.g. redux-thunk + // Provides support for DevTools: + devTools(), + // Lets you write ?debug_session= in address bar to persist debug sessions + persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)) +)(createStore); +const store = finalCreateStore(reducer); + +class Root extends Component { + render() { + return ( +
+ + {() => } + + + + +
+ ); + } +} + +// +// https://github.com/gaearon/redux-devtools/blob/master/examples/counter/containers/App.js +// + +class App extends Component { + render() { + return ( +
+ + {() => } + + + + +
+ ); + } +} diff --git a/redux-devtools/redux-devtools-2.1.4.d.ts b/redux-devtools/redux-devtools-2.1.4.d.ts new file mode 100644 index 000000000..7612adb7c --- /dev/null +++ b/redux-devtools/redux-devtools-2.1.4.d.ts @@ -0,0 +1,109 @@ +// Type definitions for redux-devtools 2.1.4 +// Project: https://github.com/gaearon/redux-devtools +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "redux-devtools" { + export function devTools(): Function; + export function persistState(sessionId: any, stateDeserializer?: Function, actionDeserializer?: Function): Function; +} + +declare module "redux-devtools/lib/react" { + import * as React from 'react'; + + export class DevTools extends React.Component { + + } + + export interface DevToolsProps { + monitor: Function; + store: Store; + } + + export interface Store { + devToolStore: DevToolStore; + } + + export class DevToolStore extends React.Component { + dispatch: Function; + } + + export class DebugPanel extends React.Component { } + + export interface DebugPanelProps { + position?: string; + zIndex?: number; + fontSize?: string; + overflow?: string; + opacity?: number; + color?: string; + left?: boolean|number; + right?: boolean|number; + top?: boolean|number; + bottom?: boolean|number; + maxHeight?: string; + maxWidth?: string; + wordWrap?: string; + boxSizing?: string; + boxShadow?: string; + getStyle?: () => DebugPanelProps; + } + + export class LogMonitor extends React.Component { } + + export interface LogMonitorProps { + computedStates?: ComputedState[]; + currentStateIndex?: number; + monitorState?: MonitorState; + stagedActions?: Action[]; + skippedActions?: boolean[]; + reset?: Function; + commit?: Function; + rollback?: Function; + sweep?: Function; + toggleAction?: Function; + jumpToState?: Function; + setMonitorState?: Function; + select?: Function; + visibleOnLoad?: boolean; + theme?: Theme|string; + } + + export interface ComputedState { + state?: any; + error?: string; + } + + export interface MonitorState { + isViaible?: boolean; + } + + export interface Action { + type: string; + } + + export interface Theme { + scheme: string; + author: string; + base00: string; + base01: string; + base02: string; + base03: string; + base04: string; + base05: string; + base06: string; + base07: string; + base08: string; + base09: string; + base0A: string; + base0B: string; + base0C: string; + base0D: string; + base0E: string; + base0F: string; + } +} + diff --git a/redux-devtools/redux-devtools-tests.tsx b/redux-devtools/redux-devtools-tests.tsx index c17aa38ab..45d541091 100644 --- a/redux-devtools/redux-devtools-tests.tsx +++ b/redux-devtools/redux-devtools-tests.tsx @@ -1,62 +1,34 @@ -/// -/// /// +/// +/// +/// +/// +/// -import { compose, createStore, applyMiddleware, Middleware, Reducer } from 'redux'; -import { devTools, persistState } from 'redux-devtools'; -import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react'; -import * as React from 'react'; -import { Component } from 'react'; +import * as React from 'react' +import { createStore, applyMiddleware, compose } from 'redux' +import { Provider } from 'react-redux' +import { createDevTools, persistState } from 'redux-devtools' +import * as LogMonitor from 'redux-devtools-log-monitor' +import * as DockMonitor from 'redux-devtools-dock-monitor' -declare var m1: Middleware; -declare var m2: Middleware; -declare var m3: Middleware; -declare var reducer: Reducer; -class CounterApp extends Component { }; -class Provider extends Component<{ store: any }, any> { }; +const DevTools = createDevTools( + + + +) const finalCreateStore = compose( - // Enables your middleware: - applyMiddleware(m1, m2, m3), // any Redux middleware, e.g. redux-thunk - // Provides support for DevTools: - devTools(), - // Lets you write ?debug_session= in address bar to persist debug sessions - persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)) -)(createStore); -const store = finalCreateStore(reducer); + DevTools.instrument(), + persistState('test-session') +)(createStore) -class Root extends Component { - render() { - return ( -
- - {() => } - - - - -
- ); - } -} - -// -// https://github.com/gaearon/redux-devtools/blob/master/examples/counter/containers/App.js -// - -class App extends Component { - render() { - return ( -
- - {() => } - - - - -
- ); - } -} +class App extends React.Component { + render() { + return ( + + + + ) + } +} \ No newline at end of file diff --git a/redux-devtools/redux-devtools.d.ts b/redux-devtools/redux-devtools.d.ts index 7612adb7c..8494b0322 100644 --- a/redux-devtools/redux-devtools.d.ts +++ b/redux-devtools/redux-devtools.d.ts @@ -1,109 +1,22 @@ -// Type definitions for redux-devtools 2.1.4 +// Type definitions for redux-devtools 3.0.0 // Project: https://github.com/gaearon/redux-devtools -// Definitions by: Qubo -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions by: Petryshyn Sergii +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// declare module "redux-devtools" { - export function devTools(): Function; - export function persistState(sessionId: any, stateDeserializer?: Function, actionDeserializer?: Function): Function; -} + import * as React from 'react' -declare module "redux-devtools/lib/react" { - import * as React from 'react'; + interface IDevTools { + new (): JSX.ElementClass + instrument(): Function + } - export class DevTools extends React.Component { + export function createDevTools(el: React.ReactElement): IDevTools + export function persistState(debugSessionKey: () => string): Function - } - - export interface DevToolsProps { - monitor: Function; - store: Store; - } - - export interface Store { - devToolStore: DevToolStore; - } - - export class DevToolStore extends React.Component { - dispatch: Function; - } - - export class DebugPanel extends React.Component { } - - export interface DebugPanelProps { - position?: string; - zIndex?: number; - fontSize?: string; - overflow?: string; - opacity?: number; - color?: string; - left?: boolean|number; - right?: boolean|number; - top?: boolean|number; - bottom?: boolean|number; - maxHeight?: string; - maxWidth?: string; - wordWrap?: string; - boxSizing?: string; - boxShadow?: string; - getStyle?: () => DebugPanelProps; - } - - export class LogMonitor extends React.Component { } - - export interface LogMonitorProps { - computedStates?: ComputedState[]; - currentStateIndex?: number; - monitorState?: MonitorState; - stagedActions?: Action[]; - skippedActions?: boolean[]; - reset?: Function; - commit?: Function; - rollback?: Function; - sweep?: Function; - toggleAction?: Function; - jumpToState?: Function; - setMonitorState?: Function; - select?: Function; - visibleOnLoad?: boolean; - theme?: Theme|string; - } - - export interface ComputedState { - state?: any; - error?: string; - } - - export interface MonitorState { - isViaible?: boolean; - } - - export interface Action { - type: string; - } - - export interface Theme { - scheme: string; - author: string; - base00: string; - base01: string; - base02: string; - base03: string; - base04: string; - base05: string; - base06: string; - base07: string; - base08: string; - base09: string; - base0A: string; - base0B: string; - base0C: string; - base0D: string; - base0E: string; - base0F: string; - } -} + var factory: { instrument(): Function } + export default factory; +} \ No newline at end of file From 36e2ea37c5b57e0eaa7f2cddf52a1fa255a8b8f3 Mon Sep 17 00:00:00 2001 From: mc-petry Date: Tue, 15 Dec 2015 15:08:54 +0200 Subject: [PATCH 02/40] Add log & dock monitors tests, fix devtools persostState --- .../redux-devtools-dock-monitor-tests.tsx | 7 +++++++ .../redux-devtools-log-monitor-tests.tsx | 7 +++++++ redux-devtools/redux-devtools-tests.tsx | 11 ++++------- redux-devtools/redux-devtools.d.ts | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 redux-devtools-dock-monitor/redux-devtools-dock-monitor-tests.tsx create mode 100644 redux-devtools-log-monitor/redux-devtools-log-monitor-tests.tsx diff --git a/redux-devtools-dock-monitor/redux-devtools-dock-monitor-tests.tsx b/redux-devtools-dock-monitor/redux-devtools-dock-monitor-tests.tsx new file mode 100644 index 000000000..dee4b39c2 --- /dev/null +++ b/redux-devtools-dock-monitor/redux-devtools-dock-monitor-tests.tsx @@ -0,0 +1,7 @@ +/// +/// + +import * as React from 'react' +import * as DockMonitor from 'redux-devtools-dock-monitor' + +let dockMonitor = \ No newline at end of file diff --git a/redux-devtools-log-monitor/redux-devtools-log-monitor-tests.tsx b/redux-devtools-log-monitor/redux-devtools-log-monitor-tests.tsx new file mode 100644 index 000000000..a472705e4 --- /dev/null +++ b/redux-devtools-log-monitor/redux-devtools-log-monitor-tests.tsx @@ -0,0 +1,7 @@ +/// +/// + +import * as React from 'react' +import * as LogMonitor from 'redux-devtools-log-monitor' + +let logMonitor = \ No newline at end of file diff --git a/redux-devtools/redux-devtools-tests.tsx b/redux-devtools/redux-devtools-tests.tsx index 45d541091..2cacd47c7 100644 --- a/redux-devtools/redux-devtools-tests.tsx +++ b/redux-devtools/redux-devtools-tests.tsx @@ -1,21 +1,18 @@ /// /// /// -/// -/// /// import * as React from 'react' import { createStore, applyMiddleware, compose } from 'redux' import { Provider } from 'react-redux' import { createDevTools, persistState } from 'redux-devtools' -import * as LogMonitor from 'redux-devtools-log-monitor' -import * as DockMonitor from 'redux-devtools-dock-monitor' + +class DevToolsMonitor extends React.Component { +} const DevTools = createDevTools( - - - + ) const finalCreateStore = compose( diff --git a/redux-devtools/redux-devtools.d.ts b/redux-devtools/redux-devtools.d.ts index 8494b0322..47ad2198d 100644 --- a/redux-devtools/redux-devtools.d.ts +++ b/redux-devtools/redux-devtools.d.ts @@ -14,7 +14,7 @@ declare module "redux-devtools" { } export function createDevTools(el: React.ReactElement): IDevTools - export function persistState(debugSessionKey: () => string): Function + export function persistState(debugSessionKey: string): Function var factory: { instrument(): Function } From 31c6eea1529cb2d35c87e0c3975ea7c50b87f449 Mon Sep 17 00:00:00 2001 From: mc-petry Date: Tue, 15 Dec 2015 15:16:56 +0200 Subject: [PATCH 03/40] Fix redux-devtools 2.1.4 tests --- redux-devtools/redux-devtools-2.1.4-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redux-devtools/redux-devtools-2.1.4-tests.tsx b/redux-devtools/redux-devtools-2.1.4-tests.tsx index c17aa38ab..a57811f16 100644 --- a/redux-devtools/redux-devtools-2.1.4-tests.tsx +++ b/redux-devtools/redux-devtools-2.1.4-tests.tsx @@ -1,4 +1,4 @@ -/// +/// /// /// From 08f607cb8bb0014eaba4633e01fc62339ec22e90 Mon Sep 17 00:00:00 2001 From: Deividas Bakanas Date: Tue, 15 Dec 2015 21:05:00 +0200 Subject: [PATCH 04/40] Definition file added --- .../react-notification-system.d.ts | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 react-notification-system/react-notification-system.d.ts diff --git a/react-notification-system/react-notification-system.d.ts b/react-notification-system/react-notification-system.d.ts new file mode 100644 index 000000000..52a5d7d98 --- /dev/null +++ b/react-notification-system/react-notification-system.d.ts @@ -0,0 +1,89 @@ +// Type definitions for React Notification System v0.2.6 +// Project: https://www.npmjs.com/package/react-notification-system +// Definitions by: Giedrius Grabauskas , Deividas Bakanas +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module NotificationSystem { + + import React = __React; + + export interface System extends React.Component { + addNotification(notification: Notification): Notification; + removeNotification(notification: Notification): void; + removeNotification(uid: string): void; + } + + export interface CallBackFunction { + (notification: Notification): void; + } + + export interface Notification { + title?: string; + message?: string; + level?: string; + position?: string; + autoDismiss?: number; + dismissible?: boolean; + action?: ActionObject; + onAdd?: CallBackFunction; + onRemove?: CallBackFunction; + uid?: number | string; + } + + export interface ActionObject { + label: string; + callback?: Function; + } + + export interface ContainersStyle { + DefaultStyle: React.CSSProperties; + tl?: React.CSSProperties; + tr?: React.CSSProperties; + tc?: React.CSSProperties; + bl?: React.CSSProperties; + br?: React.CSSProperties; + bc?: React.CSSProperties; + } + + export interface ItemStyle { + DefaultStyle?: React.CSSProperties; + success?: React.CSSProperties; + error?: React.CSSProperties; + warning?: React.CSSProperties; + info?: React.CSSProperties; + } + + export interface WrapperStyle { + DefaultStyle?: React.CSSProperties; + } + + export interface Style { + Wrapper?: any; + Containers?: ContainersStyle; + NotificationItem?: ItemStyle; + Title?: ItemStyle; + MessageWrapper?: WrapperStyle; + Dismiss?: ItemStyle; + Action?: ItemStyle; + ActionWrapper?: WrapperStyle; + } + + export interface Attributes { + noAnimation?: boolean; + ref?: string; + style?: Style | boolean; + } + + + export interface Component { + (): React.ReactElement; + } +} + + +declare module 'react-notification-system' { + var component: NotificationSystem.Component; + export = component; +} From 13a6bf3c0f418dadec4bc4db85866b83ee817636 Mon Sep 17 00:00:00 2001 From: Deividas Bakanas Date: Tue, 15 Dec 2015 21:05:47 +0200 Subject: [PATCH 05/40] Test file added --- .../react-notification-system-test.ts | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 react-notification-system/react-notification-system-test.ts diff --git a/react-notification-system/react-notification-system-test.ts b/react-notification-system/react-notification-system-test.ts new file mode 100644 index 000000000..07cd8ff2c --- /dev/null +++ b/react-notification-system/react-notification-system-test.ts @@ -0,0 +1,62 @@ +/// +/// + +import React = require('react'); +import NotificationSystem = require('react-notification-system'); + + +class MyComponent extends React.Component { + private notificationSystem: NotificationSystem.System = null; + + private notification: NotificationSystem.Notification = { + message: 'Notification message', + level: 'success', + action: { + label: "Button inside this notification", + callback: () => { + this.notificationSystem.removeNotification(this.notification); + } + } + }; + + private addNotification() { + this.notification = this.notificationSystem.addNotification(this.notification); + } + + componentDidMount() { + this.notificationSystem = this.refs['notificationSystem'] as NotificationSystem.System; + this.addNotification(); + } + + render() { + + var style = { + NotificationItem: { // Override the notification item + DefaultStyle: { // Applied to every notification, regardless of the notification level + margin: '10px 5px 2px 1px' + }, + + success: { // Applied only to the success notification item + color: 'red' + } + } + }; + + var attributes: NotificationSystem.Attributes = { + style: { + Containers: { + DefaultStyle: { + margin: '10px 5px 2px 1px' + } + }, + Title: { + success: { + color: 'green' + } + } + } + }; + + return React.createElement(NotificationSystem, { title: "NotificationTitile", style: style, } as NotificationSystem.Attributes); + } +} From a507ed9ef2955734b3cf362a0a74b21c7241cebc Mon Sep 17 00:00:00 2001 From: mc-petry Date: Wed, 16 Dec 2015 12:36:41 +0200 Subject: [PATCH 06/40] Use ES6 default style export --- .../redux-devtools-dock-monitor-tests.tsx | 2 +- .../redux-devtools-dock-monitor.d.ts | 6 +----- .../redux-devtools-log-monitor-tests.tsx | 2 +- redux-devtools-log-monitor/redux-devtools-log-monitor.d.ts | 6 +----- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/redux-devtools-dock-monitor/redux-devtools-dock-monitor-tests.tsx b/redux-devtools-dock-monitor/redux-devtools-dock-monitor-tests.tsx index dee4b39c2..00845bdc0 100644 --- a/redux-devtools-dock-monitor/redux-devtools-dock-monitor-tests.tsx +++ b/redux-devtools-dock-monitor/redux-devtools-dock-monitor-tests.tsx @@ -2,6 +2,6 @@ /// import * as React from 'react' -import * as DockMonitor from 'redux-devtools-dock-monitor' +import DockMonitor from 'redux-devtools-dock-monitor' let dockMonitor = \ No newline at end of file diff --git a/redux-devtools-dock-monitor/redux-devtools-dock-monitor.d.ts b/redux-devtools-dock-monitor/redux-devtools-dock-monitor.d.ts index f7e3ded8c..09e3d9603 100644 --- a/redux-devtools-dock-monitor/redux-devtools-dock-monitor.d.ts +++ b/redux-devtools-dock-monitor/redux-devtools-dock-monitor.d.ts @@ -55,9 +55,5 @@ declare module "redux-devtools-dock-monitor" { defaultIsVisible?: boolean } - class DockMonitor extends React.Component { - } - - let dockMonitor: (new () => DockMonitor) - export = dockMonitor + export default class DockMonitor extends React.Component {} } \ No newline at end of file diff --git a/redux-devtools-log-monitor/redux-devtools-log-monitor-tests.tsx b/redux-devtools-log-monitor/redux-devtools-log-monitor-tests.tsx index a472705e4..dbcdbcf7a 100644 --- a/redux-devtools-log-monitor/redux-devtools-log-monitor-tests.tsx +++ b/redux-devtools-log-monitor/redux-devtools-log-monitor-tests.tsx @@ -2,6 +2,6 @@ /// import * as React from 'react' -import * as LogMonitor from 'redux-devtools-log-monitor' +import LogMonitor from 'redux-devtools-log-monitor' let logMonitor = \ No newline at end of file diff --git a/redux-devtools-log-monitor/redux-devtools-log-monitor.d.ts b/redux-devtools-log-monitor/redux-devtools-log-monitor.d.ts index 0dbd2e107..8c96c804d 100644 --- a/redux-devtools-log-monitor/redux-devtools-log-monitor.d.ts +++ b/redux-devtools-log-monitor/redux-devtools-log-monitor.d.ts @@ -35,9 +35,5 @@ declare module "redux-devtools-log-monitor" { preserveScrollTop?: boolean } - class LogMonitor extends React.Component { - } - - var logMonitor: (new () => LogMonitor) - export = logMonitor + export default class LogMonitor extends React.Component {} } \ No newline at end of file From 389b49fc0e89bcdbdc0ca0ec8167099941e60501 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Fri, 18 Dec 2015 16:18:08 +0100 Subject: [PATCH 07/40] Definition for prettyjson package added --- prettyjson/prettyjson-tests.ts | 18 +++++++++++ prettyjson/prettyjson.d.ts | 59 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 prettyjson/prettyjson-tests.ts create mode 100644 prettyjson/prettyjson.d.ts diff --git a/prettyjson/prettyjson-tests.ts b/prettyjson/prettyjson-tests.ts new file mode 100644 index 000000000..4df6b1fc8 --- /dev/null +++ b/prettyjson/prettyjson-tests.ts @@ -0,0 +1,18 @@ +/// + +var options: prettyjson.IOptions, + input: string, + output: string; + + +input = 'This is a string'; +output = prettyjson.render(input); + +output = prettyjson.render(input, {}, 4); + +output = prettyjson.render(['first string', ['nested 1', 'nested 2'], 'second string']); + +output = prettyjson.render({param1: 'first string', param2: 'second string'}); + +output = prettyjson.render({first_param: {subparam: 'first string', subparam2: 'another string'}, second_param: 'second string'}); + diff --git a/prettyjson/prettyjson.d.ts b/prettyjson/prettyjson.d.ts new file mode 100644 index 000000000..f1f0dbf23 --- /dev/null +++ b/prettyjson/prettyjson.d.ts @@ -0,0 +1,59 @@ +// Type definitions for prettyjson +// Project: https://github.com/rafeca/prettyjson +// Definitions by: Wael BEN ZID EL GUEBSI +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare module PrettyJSON { + + /** + * Defines prettyjson version + */ + export var version: string; + + /** + * Render pretty json. + * + * @param data {Object} Data to prettify. + * @param options {IOptions} Hash with different options to configure the renderer. + * @param indentation {number} Indentation size. + * + * @return {string} pretty serialized json data ready to display. + */ + export function render(data: Object, options?: IOptions, indentation?: number): string; + + /** + * Render pretty json from a string. + * + * @param data {string} Serialized JSON data to prettify. + * @param options {IOptions} Hash with different options to configure the renderer. + * @param indentation {number} Indentation size. + * + * @return {string} pretty serialized json data ready to display. + */ + export function renderString(data: string, options?: IOptions, indentation?: number): string; + + export interface IOptions { + + /** + * Define behavior for Array objects + */ + emptyArrayMsg ?: string; // default: (empty) + inlineArrays ?: boolean; + + /** + * Color definition + */ + noColor ?: boolean; + keysColor ?: string; + dashColor ?: string; + numberColor ?: string; + stringColor ?: string; + + defaultIndentation ?: number; + } +} + +declare module "prettyjson" { + export = PrettyJSON; +} From e3dea91f4300f526bbb4d1baa8b558598d69d751 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Tue, 22 Dec 2015 12:17:04 +0100 Subject: [PATCH 08/40] More tests added --- prettyjson/prettyjson-tests.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prettyjson/prettyjson-tests.ts b/prettyjson/prettyjson-tests.ts index 4df6b1fc8..9d7c43918 100644 --- a/prettyjson/prettyjson-tests.ts +++ b/prettyjson/prettyjson-tests.ts @@ -2,9 +2,13 @@ var options: prettyjson.IOptions, input: string, - output: string; + output: string, + version: string; +console.log("using prettyjson v" + prettyjson.version) +version = prettyjson.version; + input = 'This is a string'; output = prettyjson.render(input); @@ -16,3 +20,4 @@ output = prettyjson.render({param1: 'first string', param2: 'second string'}); output = prettyjson.render({first_param: {subparam: 'first string', subparam2: 'another string'}, second_param: 'second string'}); +prettyjson.renderString('{name: "Wael", nested: {list: ["a", "b"], int: 3}}') From a5f6fa793f206da5521580987d219493014810a1 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Tue, 22 Dec 2015 12:17:58 +0100 Subject: [PATCH 09/40] module declaration fixed --- prettyjson/prettyjson.d.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/prettyjson/prettyjson.d.ts b/prettyjson/prettyjson.d.ts index f1f0dbf23..b2a6399ac 100644 --- a/prettyjson/prettyjson.d.ts +++ b/prettyjson/prettyjson.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module PrettyJSON { +declare module prettyjson { /** * Defines prettyjson version @@ -14,13 +14,13 @@ declare module PrettyJSON { /** * Render pretty json. * - * @param data {Object} Data to prettify. + * @param data {any} Data to prettify. * @param options {IOptions} Hash with different options to configure the renderer. * @param indentation {number} Indentation size. * * @return {string} pretty serialized json data ready to display. */ - export function render(data: Object, options?: IOptions, indentation?: number): string; + export function render(data: any, options?: IOptions, indentation?: number): string; /** * Render pretty json from a string. @@ -53,7 +53,3 @@ declare module PrettyJSON { defaultIndentation ?: number; } } - -declare module "prettyjson" { - export = PrettyJSON; -} From cf2a968f0edd7d30773f7d23fe3708fa029d5ab7 Mon Sep 17 00:00:00 2001 From: error Date: Tue, 22 Dec 2015 10:26:33 -0600 Subject: [PATCH 10/40] add easing functions to jquery and jqueryui --- jquery/jquery.d.ts | 13 +++++++++++++ jqueryui/jqueryui.d.ts | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 29b7697b2..ff259e7fb 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -607,6 +607,16 @@ interface JQueryAnimationOptions { specialEasing?: Object; } +interface JQueryEasingFunction { + ( percent: number ): number; +} + +interface JQueryEasingFunctions { + [ name: string ]: JQueryEasingFunction; + linear: JQueryEasingFunction; + swing: JQueryEasingFunction; +} + /** * Static members of jQuery (those on $ and jQuery themselves) */ @@ -889,6 +899,9 @@ interface JQueryStatic { /** * Effects */ + + easing: JQueryEasingFunctions; + fx: { tick: () => void; /** diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 9dd576e1a..197c4dbd1 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -1804,3 +1804,36 @@ interface JQueryStatic { widget: JQueryUI.Widget; Widget: JQueryUI.Widget; } + +interface JQueryEasingFunctions { + easeInQuad: JQueryEasingFunction; + easeOutQuad: JQueryEasingFunction; + easeInOutQuad: JQueryEasingFunction; + easeInCubic: JQueryEasingFunction; + easeOutCubic: JQueryEasingFunction; + easeInOutCubic: JQueryEasingFunction; + easeInQuart: JQueryEasingFunction; + easeOutQuart: JQueryEasingFunction; + easeInOutQuart: JQueryEasingFunction; + easeInQuint: JQueryEasingFunction; + easeOutQuint: JQueryEasingFunction; + easeInOutQuint: JQueryEasingFunction; + easeInExpo: JQueryEasingFunction; + easeOutExpo: JQueryEasingFunction; + easeInOutExpo: JQueryEasingFunction; + easeInSine: JQueryEasingFunction; + easeOutSine: JQueryEasingFunction; + easeInOutSine: JQueryEasingFunction; + easeInCirc: JQueryEasingFunction; + easeOutCirc: JQueryEasingFunction; + easeInOutCirc: JQueryEasingFunction; + easeInElastic: JQueryEasingFunction; + easeOutElastic: JQueryEasingFunction; + easeInOutElastic: JQueryEasingFunction; + easeInBack: JQueryEasingFunction; + easeOutBack: JQueryEasingFunction; + easeInOutBack: JQueryEasingFunction; + easeInBounce: JQueryEasingFunction; + easeOutBounce: JQueryEasingFunction; + easeInOutBounce: JQueryEasingFunction; +} \ No newline at end of file From acce45cb00a565e797d822f8509b742a26dd72c7 Mon Sep 17 00:00:00 2001 From: Deividas Bakanas Date: Sun, 27 Dec 2015 01:35:59 +0200 Subject: [PATCH 11/40] File renamed react-notification-system-test.ts changed to react-notification-system-tests.ts --- ...fication-system-test.ts => react-notification-system-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename react-notification-system/{react-notification-system-test.ts => react-notification-system-tests.ts} (100%) diff --git a/react-notification-system/react-notification-system-test.ts b/react-notification-system/react-notification-system-tests.ts similarity index 100% rename from react-notification-system/react-notification-system-test.ts rename to react-notification-system/react-notification-system-tests.ts From ccf1db94c840f6615b14dd9edf2e26b33e9da421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Darida?= Date: Thu, 7 Jan 2016 17:46:50 +0100 Subject: [PATCH 12/40] Update webfontloader.d.ts The 'text' property of the Google interface is optional. https://github.com/typekit/webfontloader#google --- webfontloader/webfontloader.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webfontloader/webfontloader.d.ts b/webfontloader/webfontloader.d.ts index 0afadfd3b..bea108ec1 100644 --- a/webfontloader/webfontloader.d.ts +++ b/webfontloader/webfontloader.d.ts @@ -35,8 +35,8 @@ declare module WebFont { monotype?:Monotype; } export interface Google { - families?:Array; - text: string; + families:Array; + text?: string; } export interface Typekit { id?:Array; @@ -57,4 +57,4 @@ declare module WebFont { } declare module "webfontloader" { export = WebFont; -} \ No newline at end of file +} From d5e1c4b1f5283ed68e3407f9cefb1266af0fbfbe Mon Sep 17 00:00:00 2001 From: Ben Loveridge Date: Thu, 7 Jan 2016 14:07:07 -0700 Subject: [PATCH 13/40] Support more variations of IStateService.get --- angular-ui-router/angular-ui-router-tests.ts | 7 ++++++- angular-ui-router/angular-ui-router.d.ts | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/angular-ui-router/angular-ui-router-tests.ts b/angular-ui-router/angular-ui-router-tests.ts index 41661d60d..07711b9b8 100644 --- a/angular-ui-router/angular-ui-router-tests.ts +++ b/angular-ui-router/angular-ui-router-tests.ts @@ -177,8 +177,13 @@ class UrlLocatorTestService implements IUrlLocatorTestService { if (this.$state.href("myState") === "/myState") { // } - this.$state.get("myState"); this.$state.get(); + this.$state.get("myState"); + this.$state.get("myState", "yourState"); + this.$state.get("myState", this.$state.current); + this.$state.get(this.$state.current); + this.$state.get(this.$state.current, "yourState"); + this.$state.get(this.$state.current, this.$state.current); this.$state.reload(); // http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state#properties diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts index a22b7d0da..324ec676c 100644 --- a/angular-ui-router/angular-ui-router.d.ts +++ b/angular-ui-router/angular-ui-router.d.ts @@ -261,7 +261,10 @@ declare module angular.ui { is(state: IState, params?: {}): boolean; href(state: IState, params?: {}, options?: IHrefOptions): string; href(state: string, params?: {}, options?: IHrefOptions): string; - get(state: string): IState; + get(state: string, context?: string): IState; + get(state: IState, context?: string): IState; + get(state: string, context?: IState): IState; + get(state: IState, context?: IState): IState; get(): IState[]; /** A reference to the state's config object. However you passed it in. Useful for accessing custom data. */ current: IState; From 9b36091bd5e929310f609b284f728dd6f7948e23 Mon Sep 17 00:00:00 2001 From: Julien Paroche Date: Fri, 8 Jan 2016 12:19:59 +0100 Subject: [PATCH 14/40] Add clone method from version 1.3.0 --- tinycolor/tinycolor.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tinycolor/tinycolor.d.ts b/tinycolor/tinycolor.d.ts index 4d36c084b..d7bc54342 100644 --- a/tinycolor/tinycolor.d.ts +++ b/tinycolor/tinycolor.d.ts @@ -329,6 +329,11 @@ interface tinycolorInstance { * Gets the complement of the current color */ complement(): tinycolorInstance; + + /** + * Gets a new instance with the current color + */ + clone(): tinycolorInstance; } declare module Readable { From 1fed7c61fa0fa5bde54707de5c1663fedba2b333 Mon Sep 17 00:00:00 2001 From: Niko Kovacic Date: Fri, 8 Jan 2016 14:19:13 +0100 Subject: [PATCH 15/40] Angular Formly IFormlyConfig added missing properties. --- angular-formly/angular-formly-tests.ts | 9 +++++++++ angular-formly/angular-formly.d.ts | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/angular-formly/angular-formly-tests.ts b/angular-formly/angular-formly-tests.ts index 2374fde4a..0ec57ed44 100644 --- a/angular-formly/angular-formly-tests.ts +++ b/angular-formly/angular-formly-tests.ts @@ -20,6 +20,15 @@ class FormConfig { name: 'customInput', extends: 'input' }); + + formlyConfig.disableWarnings = true; + formlyConfig.templateManipulators = undefined; + + formlyConfig.extras.apiCheckInstance = null; + formlyConfig.extras.defaultHideDirective = 'ng-if'; + formlyConfig.extras.disableNgModelAttrsManipulator = true; + formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = angular.noop; + formlyConfig.extras.explicitAsync = true; } } diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index 7ee3d3194..b5688ed7a 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -558,10 +558,24 @@ declare module AngularFormly { validateOptions?: Function; } + interface IFormlyConfigExtras { + disableNgModelAttrsManipulator: boolean; + apiCheckInstance: any; + ngModelAttrsManipulatorPreferUnbound: boolean; + removeChromeAutoComplete: boolean; + defaultHideDirective: string; + errorExistsAndShouldBeVisibleExpression: any; + getFieldId: Function; + fieldTransform: Function; + explicitAsync: boolean; + } + interface IFormlyConfig { + disableWarnings: boolean; + extras: IFormlyConfigExtras; setType(typeOptions: ITypeOptions): void; setWrapper(wrapperOptions: IWrapperOptions): void; - + templateManipulators: ITemplateManipulators; } interface ITemplateScopeOptions { From 89ccc5f3cd92a48129121eab7809e0a84eb9be18 Mon Sep 17 00:00:00 2001 From: Niko Kovacic Date: Fri, 8 Jan 2016 14:30:32 +0100 Subject: [PATCH 16/40] Added additional tests for extra property --- angular-formly/angular-formly-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/angular-formly/angular-formly-tests.ts b/angular-formly/angular-formly-tests.ts index 0ec57ed44..01449aa4b 100644 --- a/angular-formly/angular-formly-tests.ts +++ b/angular-formly/angular-formly-tests.ts @@ -29,6 +29,9 @@ class FormConfig { formlyConfig.extras.disableNgModelAttrsManipulator = true; formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = angular.noop; formlyConfig.extras.explicitAsync = true; + formlyConfig.extras.fieldTransform = angular.noop; + formlyConfig.extras.getFieldId = angular.noop; + formlyConfig.extras.ngModelAttrsManipulatorPreferUnbound = true; } } From e19066cf24f05ffee4a8add300bb9b9c188323f6 Mon Sep 17 00:00:00 2001 From: Niko Kovacic Date: Fri, 8 Jan 2016 15:25:42 +0100 Subject: [PATCH 17/40] Small lint fixes. --- angular-formly/angular-formly.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index b5688ed7a..8c07ea800 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -16,8 +16,8 @@ declare module 'angular-formly' { declare module AngularFormly { - interface IFieldArray extends Array { - + interface IFieldArray extends Array { + } interface IFieldGroup { @@ -160,7 +160,7 @@ declare module AngularFormly { */ asyncValidators?: { [key: string]: string | IExpressionFunction | IValidator; - } + }; /** * This is a great way to add custom behavior to a specific field. It is injectable with the $scope of the @@ -210,7 +210,7 @@ declare module AngularFormly { */ expressionProperties?: { [key: string]: string | IExpressionFunction | IValidator; - } + }; /** @@ -219,7 +219,7 @@ declare module AngularFormly { * * see http://docs.angular-formly.com/docs/field-configuration-object#hide-boolean */ - hide?: boolean + hide?: boolean; /** @@ -432,7 +432,7 @@ declare module AngularFormly { */ show?: boolean; - } + }; /** @@ -446,7 +446,7 @@ declare module AngularFormly { */ validators?: { [key: string]: string | IExpressionFunction | IValidator; - } + }; /** From ee54597e99178c48aea20a268af6160406545551 Mon Sep 17 00:00:00 2001 From: error Date: Fri, 8 Jan 2016 11:02:19 -0600 Subject: [PATCH 18/40] add easing tests --- jquery/jquery-tests.ts | 102 +++++++++++++++++++++---------------- jqueryui/jqueryui-tests.ts | 25 ++++++++- 2 files changed, 80 insertions(+), 47 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 27eea1c81..32e5c28e7 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -88,7 +88,7 @@ function test_ajax() { alert('Load was performed.'); }, error: function (jqXHR, textStatus, errorThrown) { - alert('Load failed. responseJSON=' + jqXHR.responseJSON); + alert('Load failed. responseJSON=' + jqXHR.responseJSON); } }); var _super = jQuery.ajaxSettings.xhr; @@ -1155,7 +1155,7 @@ function test_dblclick() { divdbl.dblclick(function () { divdbl.toggleClass('dbl'); }); - $('#target').dblclick(); + $('#target').dblclick(); } function test_delay() { @@ -1710,6 +1710,18 @@ function test_focusout() { }); } +function test_easing() { + var easing = jQuery.easing, + easing_fns = ["linear", "swing"], + step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error + easing_fns.forEach( function( name ) { + var fn = easing[ name ]; + for( var i = 0; i <= 1; i += step ) { + console.log( "$.easing." + name + "(" + i + "): " + fn.call(easing, i) ); + } + } ); +} + function test_fx() { jQuery.fx.interval = 100; $("input").click(function () { @@ -2740,7 +2752,7 @@ function test_keyup() { } function test_resize() { - $('#other').resize(); + $('#other').resize(); $('#other').resize(function () { alert('Handler for .resize() called.'); }); @@ -2750,7 +2762,7 @@ function test_resize() { } function test_scroll() { - $('#other').scroll(); + $('#other').scroll(); $('#other').scroll(function () { alert('Handler for .scroll() called.'); }); @@ -2760,7 +2772,7 @@ function test_scroll() { } function test_select() { - $('#other').select(); + $('#other').select(); $('#other').select(function () { alert('Handler for .select() called.'); }); @@ -3147,8 +3159,8 @@ function test_text() { } $('#item').click(function(e) { - if (e.ctrlKey) { console.log('control pressed'); } - if (e.altKey) { console.log('alt pressed'); } + if (e.ctrlKey) { console.log('control pressed'); } + if (e.altKey) { console.log('alt pressed'); } }); function test_addBack() { @@ -3165,27 +3177,27 @@ function test_addBack() { // http://api.jquery.com/jQuery.parseHTML/ function test_parseHTML() { - var $log = $( "#log" ), - str = "hello, my name is jQuery.", - html = $.parseHTML( str ), - nodeNames = []; + var $log = $( "#log" ), + str = "hello, my name is jQuery.", + html = $.parseHTML( str ), + nodeNames = []; - // Append the parsed HTML - $log.append( html ); + // Append the parsed HTML + $log.append( html ); - // Gather the parsed HTML's node names - $.each( html, function( i, el ) { - nodeNames[i] = "
  • " + el.nodeName + "
  • "; - }); + // Gather the parsed HTML's node names + $.each( html, function( i, el ) { + nodeNames[i] = "
  • " + el.nodeName + "
  • "; + }); - // Insert the node names - $log.append( "

    Node Names:

    " ); - $( "
      " ) - .append( nodeNames.join( "" ) ) - .appendTo( $log ); + // Insert the node names + $log.append( "

      Node Names:

      " ); + $( "
        " ) + .append( nodeNames.join( "" ) ) + .appendTo( $log ); - // parse HTML with all parameters - $.parseHTML( str, document, true ); + // parse HTML with all parameters + $.parseHTML( str, document, true ); } // http://api.jquery.com/jQuery.parseJSON/ @@ -3218,7 +3230,7 @@ function test_not() { $("p").not("#selected"); $("p").not($("div p.selected")); - + var el1 = $("
        ")[0]; var el2 = $("
        ")[0]; $("p").not([el1, el2]); @@ -3367,30 +3379,30 @@ function test_deferred_promise() { } function test_promise_then_change_type() { - function request() { - var def = $.Deferred(); - var promise = def.promise(null); + function request() { + var def = $.Deferred(); + var promise = def.promise(null); - def.rejectWith(this, [new Error()]); + def.rejectWith(this, [new Error()]); - return promise; - } + return promise; + } - function count() { - var def = request(); - return def.then(data => { - try { - var count: number = parseInt(data.count, 10); - } catch (err) { - return $.Deferred().reject(err).promise(); - } - return $.Deferred().resolve(count).promise(); - }); - } + function count() { + var def = request(); + return def.then(data => { + try { + var count: number = parseInt(data.count, 10); + } catch (err) { + return $.Deferred().reject(err).promise(); + } + return $.Deferred().resolve(count).promise(); + }); + } - count().done(data => { - }).fail((exception: Error) => { - }); + count().done(data => { + }).fail((exception: Error) => { + }); } function test_promise_then_not_return_deferred() { diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index bc84cb475..6bf4d9eb4 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1458,8 +1458,8 @@ function test_dialog() { $(".selector").dialog({ title: "Dialog Title" }); $(".selector").dialog({ width: 500 }); $(".selector").dialog({ zIndex: 20 }); - var $el = $( ".selector" ).dialog( "moveToTop" ); - var isOpen = $( ".selector" ).dialog( "isOpen" ); + var $el = $( ".selector" ).dialog( "moveToTop" ); + var isOpen = $( ".selector" ).dialog( "isOpen" ); } @@ -1818,3 +1818,24 @@ function test_widget() { $(".selector").jQuery.Widget("option", "disabled", true); $(".selector").jQuery.Widget("option", { disabled: true }); } + +function test_easing() { + var easing = jQuery.easing, + easing_fns = ["easeInQuad", "easeOutQuad", "easeInOutQuad", + "easeInCubic", "easeOutCubic", "easeInOutCubic", + "easeInQuart", "easeOutQuart", "easeInOutQuart", + "easeInQuint", "easeOutQuint", "easeInOutQuint", + "easeInExpo", "easeOutExpo", "easeInOutExpo", + "easeInSine", "easeOutSine", "easeInOutSine", + "easeInCirc", "easeOutCirc", "easeInOutCirc", + "easeInElastic", "easeOutElastic", "easeInOutElastic", + "easeInBack", "easeOutBack", "easeInOutBack", + "easeInBounce", "easeOutBounce", "easeInOutBounce"], + step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error + easing_fns.forEach( function( name ) { + var fn = easing[ name ]; + for( var i = 0; i <= 1; i += step ) { + console.log( "$.easing." + name + "(" + i + "): " + fn.call(easing, i) ); + } + } ); +} From ca6fb1fb78ed94654d841bbe2163851bbb20da40 Mon Sep 17 00:00:00 2001 From: error Date: Fri, 8 Jan 2016 11:15:12 -0600 Subject: [PATCH 19/40] Revert "add easing tests" This reverts commit ee54597e99178c48aea20a268af6160406545551. --- jquery/jquery-tests.ts | 102 ++++++++++++++++--------------------- jqueryui/jqueryui-tests.ts | 25 +-------- 2 files changed, 47 insertions(+), 80 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 32e5c28e7..27eea1c81 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -88,7 +88,7 @@ function test_ajax() { alert('Load was performed.'); }, error: function (jqXHR, textStatus, errorThrown) { - alert('Load failed. responseJSON=' + jqXHR.responseJSON); + alert('Load failed. responseJSON=' + jqXHR.responseJSON); } }); var _super = jQuery.ajaxSettings.xhr; @@ -1155,7 +1155,7 @@ function test_dblclick() { divdbl.dblclick(function () { divdbl.toggleClass('dbl'); }); - $('#target').dblclick(); + $('#target').dblclick(); } function test_delay() { @@ -1710,18 +1710,6 @@ function test_focusout() { }); } -function test_easing() { - var easing = jQuery.easing, - easing_fns = ["linear", "swing"], - step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error - easing_fns.forEach( function( name ) { - var fn = easing[ name ]; - for( var i = 0; i <= 1; i += step ) { - console.log( "$.easing." + name + "(" + i + "): " + fn.call(easing, i) ); - } - } ); -} - function test_fx() { jQuery.fx.interval = 100; $("input").click(function () { @@ -2752,7 +2740,7 @@ function test_keyup() { } function test_resize() { - $('#other').resize(); + $('#other').resize(); $('#other').resize(function () { alert('Handler for .resize() called.'); }); @@ -2762,7 +2750,7 @@ function test_resize() { } function test_scroll() { - $('#other').scroll(); + $('#other').scroll(); $('#other').scroll(function () { alert('Handler for .scroll() called.'); }); @@ -2772,7 +2760,7 @@ function test_scroll() { } function test_select() { - $('#other').select(); + $('#other').select(); $('#other').select(function () { alert('Handler for .select() called.'); }); @@ -3159,8 +3147,8 @@ function test_text() { } $('#item').click(function(e) { - if (e.ctrlKey) { console.log('control pressed'); } - if (e.altKey) { console.log('alt pressed'); } + if (e.ctrlKey) { console.log('control pressed'); } + if (e.altKey) { console.log('alt pressed'); } }); function test_addBack() { @@ -3177,27 +3165,27 @@ function test_addBack() { // http://api.jquery.com/jQuery.parseHTML/ function test_parseHTML() { - var $log = $( "#log" ), - str = "hello, my name is jQuery.", - html = $.parseHTML( str ), - nodeNames = []; + var $log = $( "#log" ), + str = "hello, my name is jQuery.", + html = $.parseHTML( str ), + nodeNames = []; - // Append the parsed HTML - $log.append( html ); + // Append the parsed HTML + $log.append( html ); - // Gather the parsed HTML's node names - $.each( html, function( i, el ) { - nodeNames[i] = "
      1. " + el.nodeName + "
      2. "; - }); + // Gather the parsed HTML's node names + $.each( html, function( i, el ) { + nodeNames[i] = "
      3. " + el.nodeName + "
      4. "; + }); - // Insert the node names - $log.append( "

        Node Names:

        " ); - $( "
          " ) - .append( nodeNames.join( "" ) ) - .appendTo( $log ); + // Insert the node names + $log.append( "

          Node Names:

          " ); + $( "
            " ) + .append( nodeNames.join( "" ) ) + .appendTo( $log ); - // parse HTML with all parameters - $.parseHTML( str, document, true ); + // parse HTML with all parameters + $.parseHTML( str, document, true ); } // http://api.jquery.com/jQuery.parseJSON/ @@ -3230,7 +3218,7 @@ function test_not() { $("p").not("#selected"); $("p").not($("div p.selected")); - + var el1 = $("
            ")[0]; var el2 = $("
            ")[0]; $("p").not([el1, el2]); @@ -3379,30 +3367,30 @@ function test_deferred_promise() { } function test_promise_then_change_type() { - function request() { - var def = $.Deferred(); - var promise = def.promise(null); + function request() { + var def = $.Deferred(); + var promise = def.promise(null); - def.rejectWith(this, [new Error()]); + def.rejectWith(this, [new Error()]); - return promise; - } + return promise; + } - function count() { - var def = request(); - return def.then(data => { - try { - var count: number = parseInt(data.count, 10); - } catch (err) { - return $.Deferred().reject(err).promise(); - } - return $.Deferred().resolve(count).promise(); - }); - } + function count() { + var def = request(); + return def.then(data => { + try { + var count: number = parseInt(data.count, 10); + } catch (err) { + return $.Deferred().reject(err).promise(); + } + return $.Deferred().resolve(count).promise(); + }); + } - count().done(data => { - }).fail((exception: Error) => { - }); + count().done(data => { + }).fail((exception: Error) => { + }); } function test_promise_then_not_return_deferred() { diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index 6bf4d9eb4..bc84cb475 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1458,8 +1458,8 @@ function test_dialog() { $(".selector").dialog({ title: "Dialog Title" }); $(".selector").dialog({ width: 500 }); $(".selector").dialog({ zIndex: 20 }); - var $el = $( ".selector" ).dialog( "moveToTop" ); - var isOpen = $( ".selector" ).dialog( "isOpen" ); + var $el = $( ".selector" ).dialog( "moveToTop" ); + var isOpen = $( ".selector" ).dialog( "isOpen" ); } @@ -1818,24 +1818,3 @@ function test_widget() { $(".selector").jQuery.Widget("option", "disabled", true); $(".selector").jQuery.Widget("option", { disabled: true }); } - -function test_easing() { - var easing = jQuery.easing, - easing_fns = ["easeInQuad", "easeOutQuad", "easeInOutQuad", - "easeInCubic", "easeOutCubic", "easeInOutCubic", - "easeInQuart", "easeOutQuart", "easeInOutQuart", - "easeInQuint", "easeOutQuint", "easeInOutQuint", - "easeInExpo", "easeOutExpo", "easeInOutExpo", - "easeInSine", "easeOutSine", "easeInOutSine", - "easeInCirc", "easeOutCirc", "easeInOutCirc", - "easeInElastic", "easeOutElastic", "easeInOutElastic", - "easeInBack", "easeOutBack", "easeInOutBack", - "easeInBounce", "easeOutBounce", "easeInOutBounce"], - step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error - easing_fns.forEach( function( name ) { - var fn = easing[ name ]; - for( var i = 0; i <= 1; i += step ) { - console.log( "$.easing." + name + "(" + i + "): " + fn.call(easing, i) ); - } - } ); -} From e0078362c7022c5c943f8b64e67f822800141784 Mon Sep 17 00:00:00 2001 From: error Date: Fri, 8 Jan 2016 11:18:33 -0600 Subject: [PATCH 20/40] add easing tests for jQuery and jQueryUI --- jquery/jquery-tests.ts | 12 ++++++++++++ jqueryui/jqueryui-tests.ts | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 27eea1c81..a1c545a6f 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1710,6 +1710,18 @@ function test_focusout() { }); } +function test_easing() { + var easing = jQuery.easing, + easing_fns = ["linear", "swing"], + step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error + easing_fns.forEach( function( name ) { + var fn = easing[ name ]; + for( var i = 0; i <= 1; i += step ) { + console.log( "$.easing." + name + "(" + i + "): " + fn.call(easing, i) ); + } + } ); +} + function test_fx() { jQuery.fx.interval = 100; $("input").click(function () { diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index bc84cb475..56a371f99 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1818,3 +1818,24 @@ function test_widget() { $(".selector").jQuery.Widget("option", "disabled", true); $(".selector").jQuery.Widget("option", { disabled: true }); } + +function test_easing() { + var easing = jQuery.easing, + easing_fns = ["easeInQuad", "easeOutQuad", "easeInOutQuad", + "easeInCubic", "easeOutCubic", "easeInOutCubic", + "easeInQuart", "easeOutQuart", "easeInOutQuart", + "easeInQuint", "easeOutQuint", "easeInOutQuint", + "easeInExpo", "easeOutExpo", "easeInOutExpo", + "easeInSine", "easeOutSine", "easeInOutSine", + "easeInCirc", "easeOutCirc", "easeInOutCirc", + "easeInElastic", "easeOutElastic", "easeInOutElastic", + "easeInBack", "easeOutBack", "easeInOutBack", + "easeInBounce", "easeOutBounce", "easeInOutBounce"], + step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error + easing_fns.forEach( function( name ) { + var fn = easing[ name ]; + for( var i = 0; i <= 1; i += step ) { + console.log( "$.easing." + name + "(" + i + "): " + fn.call(easing, i) ); + } + } ); +} From 70a1f40bc8ef810b4272d37553cf86c6785be7f8 Mon Sep 17 00:00:00 2001 From: Dominique Rau Date: Fri, 8 Jan 2016 16:27:40 +0100 Subject: [PATCH 21/40] Update according to https://github.com/gulpjs/vinyl/releases/tag/v1.1.0 (fix) Add missing semicolons and tests mend --- vinyl/vinyl-0.4.3.d.ts | 108 +++++++ vinyl/vinyl-0.4.3.tests.ts | 560 +++++++++++++++++++++++++++++++++++++ vinyl/vinyl-tests.ts | 170 ++++++++--- vinyl/vinyl.d.ts | 42 ++- 4 files changed, 840 insertions(+), 40 deletions(-) create mode 100644 vinyl/vinyl-0.4.3.d.ts create mode 100644 vinyl/vinyl-0.4.3.tests.ts diff --git a/vinyl/vinyl-0.4.3.d.ts b/vinyl/vinyl-0.4.3.d.ts new file mode 100644 index 000000000..3669de261 --- /dev/null +++ b/vinyl/vinyl-0.4.3.d.ts @@ -0,0 +1,108 @@ +// Type definitions for vinyl 0.4.3 +// Project: https://github.com/wearefractal/vinyl +// Definitions by: vvakame , jedmao +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "vinyl" { + + import fs = require("fs"); + + /** + * A virtual file format. + */ + class File { + constructor(options?: { + /** + * Default: process.cwd() + */ + cwd?: string; + /** + * Used for relative pathing. Typically where a glob starts. + */ + base?: string; + /** + * Full path to the file. + */ + path?: string; + /** + * Path history. Has no effect if options.path is passed. + */ + history?: string[]; + /** + * The result of an fs.stat call. See fs.Stats for more information. + */ + stat?: fs.Stats; + /** + * File contents. + * Type: Buffer, Stream, or null + */ + contents?: Buffer | NodeJS.ReadWriteStream; + }); + + /** + * Default: process.cwd() + */ + public cwd: string; + /** + * Used for relative pathing. Typically where a glob starts. + */ + public base: string; + /** + * Full path to the file. + */ + public path: string; + public stat: fs.Stats; + /** + * Type: Buffer|Stream|null (Default: null) + */ + public contents: Buffer | NodeJS.ReadableStream; + /** + * Returns path.relative for the file base and file path. + * Example: + * var file = new File({ + * cwd: "/", + * base: "/test/", + * path: "/test/file.js" + * }); + * console.log(file.relative); // file.js + */ + public relative: string; + + public isBuffer(): boolean; + + public isStream(): boolean; + + public isNull(): boolean; + + public isDirectory(): boolean; + + /** + * Returns a new File object with all attributes cloned. Custom attributes are deep-cloned. + */ + public clone(opts?: { contents?: boolean }): File; + + /** + * If file.contents is a Buffer, it will write it to the stream. + * If file.contents is a Stream, it will pipe it to the stream. + * If file.contents is null, it will do nothing. + */ + public pipe( + stream: T, + opts?: { + /** + * If false, the destination stream will not be ended (same as node core). + */ + end?: boolean; + }): T; + + /** + * Returns a pretty String interpretation of the File. Useful for console.log. + */ + public inspect(): string; + } + + export = File; + +} \ No newline at end of file diff --git a/vinyl/vinyl-0.4.3.tests.ts b/vinyl/vinyl-0.4.3.tests.ts new file mode 100644 index 000000000..22a7d775a --- /dev/null +++ b/vinyl/vinyl-0.4.3.tests.ts @@ -0,0 +1,560 @@ +/// +/// + +/// + +import File = require('vinyl'); +import Stream = require('stream'); +import fs = require('fs'); + +declare var fakeStream: NodeJS.ReadWriteStream; + +describe('File', () => { + + describe('constructor()', () => { + + it('should default cwd to process.cwd', done => { + var file = new File(); + file.cwd.should.equal(process.cwd()); + done(); + }); + + it('should default base to cwd', done => { + var cwd = "/"; + var file = new File({cwd: cwd}); + file.base.should.equal(cwd); + done(); + }); + + it('should default base to cwd even when none is given', done => { + var file = new File(); + file.base.should.equal(process.cwd()); + done(); + }); + + it('should default path to null', done => { + var file = new File(); + should.not.exist(file.path); + done(); + }); + + it('should default stat to null', done => { + var file = new File(); + should.not.exist(file.stat); + done(); + }); + + it('should default contents to null', done => { + var file = new File(); + should.not.exist(file.contents); + done(); + }); + + it('should set base to given value', done => { + var val = "/"; + var file = new File({base: val}); + file.base.should.equal(val); + done(); + }); + + it('should set cwd to given value', done => { + var val = "/"; + var file = new File({cwd: val}); + file.cwd.should.equal(val); + done(); + }); + + it('should set path to given value', done => { + var val = "/test.coffee"; + var file = new File({path: val}); + file.path.should.equal(val); + done(); + }); + + it('should set stat to given value', done => { + var val = {}; + var file = new File({stat: val}); + file.stat.should.equal(val); + done(); + }); + + it('should set contents to given value', done => { + var val = new Buffer("test"); + var file = new File({contents: val}); + file.contents.should.equal(val); + done(); + }); + }); + + describe('isBuffer()', () => { + it('should return true when the contents are a Buffer', done => { + var val = new Buffer("test"); + var file = new File({contents: val}); + file.isBuffer().should.equal(true); + done(); + }); + + it('should return false when the contents are a Stream', done => { + var file = new File({ contents: fakeStream}); + file.isBuffer().should.equal(false); + done(); + }); + + it('should return false when the contents are a null', done => { + var file = new File({contents: null}); + file.isBuffer().should.equal(false); + done(); + }); + }); + + describe('isStream()', () => { + it('should return false when the contents are a Buffer', done => { + var val = new Buffer("test"); + var file = new File({contents: val}); + file.isStream().should.equal(false); + done(); + }); + + it('should return true when the contents are a Stream', done => { + var file = new File({ contents: fakeStream}); + file.isStream().should.equal(true); + done(); + }); + + it('should return false when the contents are a null', done => { + var file = new File({contents: null}); + file.isStream().should.equal(false); + done(); + }); + }); + + describe('isNull()', () => { + it('should return false when the contents are a Buffer', done => { + var val = new Buffer("test"); + var file = new File({contents: val}); + file.isNull().should.equal(false); + done(); + }); + + it('should return false when the contents are a Stream', done => { + var file = new File({ contents: fakeStream}); + file.isNull().should.equal(false); + done(); + }); + + it('should return true when the contents are a null', done => { + var file = new File({contents: null}); + file.isNull().should.equal(true); + done(); + }); + }); + + describe('isDirectory()', () => { + var fakeStat = { + isDirectory() { + return true; + } + }; + + it('should return false when the contents are a Buffer', done => { + var val = new Buffer("test"); + var file = new File({contents: val, stat: fakeStat}); + file.isDirectory().should.equal(false); + done(); + }); + + it('should return false when the contents are a Stream', done => { + var file = new File({ contents: fakeStream, stat: fakeStat}); + file.isDirectory().should.equal(false); + done(); + }); + + it('should return true when the contents are a null', done => { + var file = new File({contents: null, stat: fakeStat}); + file.isDirectory().should.equal(true); + done(); + }); + }); + + describe('clone()', () => { + it('should copy all attributes over with Buffer', done => { + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: new Buffer("test") + }; + var file = new File(options); + var file2 = file.clone(); + + file2.should.not.equal(file, 'refs should be different'); + file2.cwd.should.equal(file.cwd); + file2.base.should.equal(file.base); + file2.path.should.equal(file.path); + + let fileContents = file.contents; + let file2Contents = file2.contents; + + file2Contents.should.not.equal(fileContents, 'buffer ref should be different'); + + let fileUtf8Contents = fileContents instanceof Buffer ? + fileContents.toString('utf8') : + (fileContents).toString(); + let file2Utf8Contents = file2Contents instanceof Buffer ? + file2Contents.toString('utf8') : + (file2Contents).toString(); + + file2Utf8Contents.should.equal(fileUtf8Contents); + done(); + }); + + it('should copy all attributes over with Stream', done => { + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: fakeStream + }; + var file = new File(options); + var file2 = file.clone(); + + file2.should.not.equal(file, 'refs should be different'); + file2.cwd.should.equal(file.cwd); + file2.base.should.equal(file.base); + file2.path.should.equal(file.path); + file2.contents.should.equal(file.contents, 'stream ref should be the same'); + done(); + }); + + it('should copy all attributes over with null', done => { + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: fakeStream + }; + var file = new File(options); + var file2 = file.clone(); + + file2.should.not.equal(file, 'refs should be different'); + file2.cwd.should.equal(file.cwd); + file2.base.should.equal(file.base); + file2.path.should.equal(file.path); + should.not.exist(file2.contents); + done(); + }); + + it('should properly clone the `stat` property', done => { + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.js", + contents: new Buffer("test"), + stat: fs.statSync(__filename) + }; + + var file = new File(options); + var copy = file.clone(); + + // ReSharper disable WrongExpressionStatement + copy.stat.isFile().should.be.true; + copy.stat.isDirectory().should.be.false; + // ReSharper restore WrongExpressionStatement + + done(); + }); + }); + + describe('pipe()', () => { + it('should write to stream with Buffer', done => { + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: new Buffer("test") + }; + var file = new File(options); + var stream = new Stream.PassThrough(); + stream.on('data', (chunk: any) => { + should.exist(chunk); + (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); + chunk.toString('utf8').should.equal(options.contents.toString('utf8')); + }); + stream.on('end', () => { + done(); + }); + var ret = file.pipe(stream); + ret.should.equal(stream, 'should return the stream'); + }); + + it('should pipe to stream with Stream', done => { + var testChunk = new Buffer("test"); + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: new Stream.PassThrough() + }; + var file = new File(options); + var stream = new Stream.PassThrough(); + stream.on('data', (chunk: any) => { + should.exist(chunk); + (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); + chunk.toString('utf8').should.equal(testChunk.toString('utf8')); + done(); + }); + var ret = file.pipe(stream); + ret.should.equal(stream, 'should return the stream'); + + let fileContents = file.contents; + if (fileContents instanceof Buffer) { + fileContents.write(testChunk.toString()); + } + }); + + it('should do nothing with null', done => { + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: fakeStream + }; + var file = new File(options); + var stream = new Stream.PassThrough(); + stream.on('data', () => { + throw new Error("should not write"); + }); + stream.on('end', () => { + done(); + }); + var ret = file.pipe(stream); + ret.should.equal(stream, 'should return the stream'); + }); + + it('should write to stream with Buffer', done => { + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: new Buffer("test") + }; + var file = new File(options); + var stream = new Stream.PassThrough(); + stream.on('data', (chunk: any) => { + should.exist(chunk); + (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); + chunk.toString('utf8').should.equal(options.contents.toString('utf8')); + done(); + }); + stream.on('end', () => { + throw new Error("should not end"); + }); + var ret = file.pipe(stream, {end: false}); + ret.should.equal(stream, 'should return the stream'); + }); + + it('should pipe to stream with Stream', done => { + var testChunk = new Buffer("test"); + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: new Stream.PassThrough() + }; + var file = new File(options); + var stream = new Stream.PassThrough(); + stream.on('data', (chunk: any) => { + should.exist(chunk); + (chunk instanceof Buffer).should.equal(true, 'should write as a buffer'); + chunk.toString('utf8').should.equal(testChunk.toString('utf8')); + done(); + }); + stream.on('end', () => { + throw new Error("should not end"); + }); + var ret = file.pipe(stream, {end: false}); + ret.should.equal(stream, 'should return the stream'); + + let fileContents = file.contents; + if (fileContents instanceof Buffer) { + fileContents.write(testChunk.toString()); + } + }); + + it('should do nothing with null', done => { + var options = { + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: fakeStream + }; + var file = new File(options); + var stream = new Stream.PassThrough(); + stream.on('data', () => { + throw new Error("should not write"); + }); + stream.on('end', () => { + throw new Error("should not end"); + }); + var ret = file.pipe(stream, {end: false}); + ret.should.equal(stream, 'should return the stream'); + process.nextTick(done); + }); + }); + + describe('inspect()', () => { + it('should return correct format when no contents and no path', done => { + var file = new File(); + file.inspect().should.equal(''); + done(); + }); + + it('should return correct format when Buffer and no path', done => { + var val = new Buffer("test"); + var file = new File({ + contents: val + }); + file.inspect().should.equal('>'); + done(); + }); + + it('should return correct format when Buffer and relative path', done => { + var val = new Buffer("test"); + var file = new File({ + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: val + }); + file.inspect().should.equal('>'); + done(); + }); + + it('should return correct format when Buffer and only path and no base', done => { + var val = new Buffer("test"); + var file = new File({ + cwd: "/", + path: "/test/test.coffee", + contents: val + }); + delete file.base; + file.inspect().should.equal('>'); + done(); + }); + + it('should return correct format when Stream and relative path', done => { + var file = new File({ + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: new Stream.PassThrough() + }); + file.inspect().should.equal('>'); + done(); + }); + + it('should return correct format when null and relative path', done => { + var file = new File({ + cwd: "/", + base: "/test/", + path: "/test/test.coffee", + contents: null + }); + file.inspect().should.equal(''); + done(); + }); + }); + + describe('contents get/set', () => { + it('should work with Buffer', done => { + var val = new Buffer("test"); + var file = new File(); + file.contents = val; + file.contents.should.equal(val); + done(); + }); + + it('should work with Stream', done => { + var val = new Stream.PassThrough(); + var file = new File(); + file.contents = val; + file.contents.should.equal(val); + done(); + }); + + it('should work with null', done => { + var file = new File(); + file.contents = null; + (file.contents === null).should.equal(true); + done(); + }); + + it('should not work with string', done => { + var val = "test"; + var file = new File(); + try { + file.contents = new Buffer(val); + } catch (err) { + should.exist(err); + done(); + } + }); + }); + + describe('relative get/set', () => { + it('should error on set', done => { + var file = new File(); + try { + file.relative = "test"; + } catch (err) { + should.exist(err); + done(); + } + }); + + it('should error on get when no base', done => { + var a: string; + var file = new File(); + delete file.base; + try { + // ReSharper disable once AssignedValueIsNeverUsed + a = file.relative; + } catch (err) { + should.exist(err); + done(); + } + }); + + it('should error on get when no path', done => { + var a: string; + var file = new File(); + try { + // ReSharper disable once AssignedValueIsNeverUsed + a = file.relative; + } catch (err) { + should.exist(err); + done(); + } + }); + + it('should return a relative path from base', done => { + var file = new File({ + cwd: "/", + base: "/test/", + path: "/test/test.coffee" + }); + file.relative.should.equal("test.coffee"); + done(); + }); + + it('should return a relative path from cwd', done => { + var file = new File({ + cwd: "/", + path: "/test/test.coffee" + }); + file.relative.should.equal("test/test.coffee"); + done(); + }); + }); + +}); diff --git a/vinyl/vinyl-tests.ts b/vinyl/vinyl-tests.ts index cb1ceaea6..1d39646b1 100644 --- a/vinyl/vinyl-tests.ts +++ b/vinyl/vinyl-tests.ts @@ -22,13 +22,13 @@ describe('File', () => { it('should default base to cwd', done => { var cwd = "/"; var file = new File({cwd: cwd}); - file.base.should.equal(cwd); + file.basename.should.equal(cwd); done(); }); it('should default base to cwd even when none is given', done => { var file = new File(); - file.base.should.equal(process.cwd()); + file.basename.should.equal(process.cwd()); done(); }); @@ -53,7 +53,7 @@ describe('File', () => { it('should set base to given value', done => { var val = "/"; var file = new File({base: val}); - file.base.should.equal(val); + file.basename.should.equal(val); done(); }); @@ -84,6 +84,41 @@ describe('File', () => { file.contents.should.equal(val); done(); }); + + it('should default basename to cwd', done => { + var cwd = "/"; + var file = new File({cwd: cwd}); + file.basename.should.equal(cwd); + done(); + }); + + it('should default basename to cwd even when none is given', done => { + var file = new File(); + file.basename.should.equal(process.cwd()); + done(); + }); + + it('should set basename to given value', done => { + var val = "/"; + var file = new File({base: val}); + file.basename.should.equal(val); + done(); + }); + + it('should default extname to null', done => { + var cwd = "/"; + var file = new File({cwd: cwd}); + should.not.exist(file.path); + done(); + }); + + it('should default dirname to null', done => { + var cwd = "/"; + var file = new File({cwd: cwd}); + should.not.exist(file.dirname); + done(); + }); + }); describe('isBuffer()', () => { @@ -149,33 +184,6 @@ describe('File', () => { }); }); - describe('isDirectory()', () => { - var fakeStat = { - isDirectory() { - return true; - } - }; - - it('should return false when the contents are a Buffer', done => { - var val = new Buffer("test"); - var file = new File({contents: val, stat: fakeStat}); - file.isDirectory().should.equal(false); - done(); - }); - - it('should return false when the contents are a Stream', done => { - var file = new File({ contents: fakeStream, stat: fakeStat}); - file.isDirectory().should.equal(false); - done(); - }); - - it('should return true when the contents are a null', done => { - var file = new File({contents: null, stat: fakeStat}); - file.isDirectory().should.equal(true); - done(); - }); - }); - describe('clone()', () => { it('should copy all attributes over with Buffer', done => { var options = { @@ -189,7 +197,7 @@ describe('File', () => { file2.should.not.equal(file, 'refs should be different'); file2.cwd.should.equal(file.cwd); - file2.base.should.equal(file.base); + file2.basename.should.equal(file.basename); file2.path.should.equal(file.path); let fileContents = file.contents; @@ -220,7 +228,7 @@ describe('File', () => { file2.should.not.equal(file, 'refs should be different'); file2.cwd.should.equal(file.cwd); - file2.base.should.equal(file.base); + file2.basename.should.equal(file.basename); file2.path.should.equal(file.path); file2.contents.should.equal(file.contents, 'stream ref should be the same'); done(); @@ -238,7 +246,7 @@ describe('File', () => { file2.should.not.equal(file, 'refs should be different'); file2.cwd.should.equal(file.cwd); - file2.base.should.equal(file.base); + file2.basename.should.equal(file.basename); file2.path.should.equal(file.path); should.not.exist(file2.contents); done(); @@ -258,7 +266,6 @@ describe('File', () => { // ReSharper disable WrongExpressionStatement copy.stat.isFile().should.be.true; - copy.stat.isDirectory().should.be.false; // ReSharper restore WrongExpressionStatement done(); @@ -437,7 +444,7 @@ describe('File', () => { path: "/test/test.coffee", contents: val }); - delete file.base; + delete file.basename; file.inspect().should.equal('>'); done(); }); @@ -515,7 +522,7 @@ describe('File', () => { it('should error on get when no base', done => { var a: string; var file = new File(); - delete file.base; + delete file.basename; try { // ReSharper disable once AssignedValueIsNeverUsed a = file.relative; @@ -557,4 +564,95 @@ describe('File', () => { }); }); + describe('path get/set', () => { + + it('should return an absolute path', done => { + var file = new File({ + cwd: "/", + base: "/test/", + path: "/test/test.coffee" + }); + file.path.should.equal("/test/test.coffee"); + done(); + }); + + }); + + describe('history get', () => { + it('should error on set', done => { + var file = new File(); + try { + file.history = []; + } catch (err) { + should.exist(err); + done(); + } + }); + + it('should return an history', done => { + var file = new File({ + cwd: "/", + base: "/test/", + path: "/test/test.coffee" + }); + file.history.should.equal(["/test/test.coffee"]); + done(); + }); + + }); + + describe('dirname get', () => { + + it('should return an dirname', done => { + var file = new File({ + cwd: "/", + base: "/test/", + path: "/test/test.coffee" + }); + file.dirname.should.equal("test"); + done(); + }); + + it('should set dirname to given value', done => { + var file = new File(); + file.dirname = ".ext" + file.dirname.should.equal(".ext") + done(); + }); + + it('should set dirname to null', done => { + var file = new File(); + file.dirname = null + should.not.exist(file.dirname) + done(); + }); + }); + + describe('extname get/set', () => { + + it('should return an extname', done => { + var file = new File({ + cwd: "/", + base: "/test/", + path: "/test/test.coffee" + }); + file.dirname.should.equal(".coffee"); + done(); + }); + + it('should set extname to given value', done => { + var file = new File(); + file.extname = ".ext" + file.extname.should.equal(".ext") + done(); + }); + + it('should set extname to null', done => { + var file = new File(); + file.extname = null + should.not.exist(file.extname) + done(); + }); + }); + }); diff --git a/vinyl/vinyl.d.ts b/vinyl/vinyl.d.ts index 39960361f..77bf252b7 100644 --- a/vinyl/vinyl.d.ts +++ b/vinyl/vinyl.d.ts @@ -1,4 +1,4 @@ -// Type definitions for vinyl 0.4.3 +// Type definitions for vinyl 1.1.0 // Project: https://github.com/wearefractal/vinyl // Definitions by: vvakame , jedmao // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -14,26 +14,32 @@ declare module "vinyl" { */ class File { constructor(options?: { + /** * Default: process.cwd() */ cwd?: string; + /** * Used for relative pathing. Typically where a glob starts. */ base?: string; + /** * Full path to the file. */ path?: string; + /** * Path history. Has no effect if options.path is passed. */ history?: string[]; + /** * The result of an fs.stat call. See fs.Stats for more information. */ stat?: fs.Stats; + /** * File contents. * Type: Buffer, Stream, or null @@ -45,19 +51,40 @@ declare module "vinyl" { * Default: process.cwd() */ public cwd: string; + /** * Used for relative pathing. Typically where a glob starts. */ + public dirname: string; + public basename: string; public base: string; + /** * Full path to the file. */ public path: string; public stat: fs.Stats; + + /** + * Gets and sets stem (filename without suffix) for the file path. + */ + public stem: string; + + /** + * Gets and sets path.extname for the file path + */ + public extname: string; + + /** + * Array of path values the file object has had + */ + public history: string[]; + /** * Type: Buffer|Stream|null (Default: null) */ public contents: Buffer | NodeJS.ReadableStream; + /** * Returns path.relative for the file base and file path. * Example: @@ -70,18 +97,25 @@ declare module "vinyl" { */ public relative: string; + /** + * Returns true if file.contents is a Buffer. + */ public isBuffer(): boolean; + /** + * Returns true if file.contents is a Stream. + */ public isStream(): boolean; + /** + * Returns true if file.contents is null. + */ public isNull(): boolean; - public isDirectory(): boolean; - /** * Returns a new File object with all attributes cloned. Custom attributes are deep-cloned. */ - public clone(opts?: { contents?: boolean }): File; + public clone(opts?: { contents?: boolean, deep?:boolean }): File; /** * If file.contents is a Buffer, it will write it to the stream. From c44772fa6a7d07071baa6e11c9007b6d978f2d81 Mon Sep 17 00:00:00 2001 From: error Date: Fri, 8 Jan 2016 14:36:01 -0600 Subject: [PATCH 22/40] update easing tests for jQuery and jQueryUI --- jquery/jquery-tests.ts | 18 +++++++------ jqueryui/jqueryui-tests.ts | 55 ++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index a1c545a6f..08e66551a 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1711,15 +1711,17 @@ function test_focusout() { } function test_easing() { - var easing = jQuery.easing, - easing_fns = ["linear", "swing"], - step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error - easing_fns.forEach( function( name ) { - var fn = easing[ name ]; - for( var i = 0; i <= 1; i += step ) { - console.log( "$.easing." + name + "(" + i + "): " + fn.call(easing, i) ); + const easing = jQuery.easing; + + function test_easing_function( name: string, fn: JQueryEasingFunction ) { + const step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error + for( let i = 0; i <= 1; i += step ) { + console.log( `$.easing.${name}(${i}): ${fn.call(easing, i)}` ); } - } ); + } + + test_easing_function( "linear", easing.linear ); + test_easing_function( "swing", easing.swing ); } function test_fx() { diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index 56a371f99..c6d4f110c 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1820,22 +1820,43 @@ function test_widget() { } function test_easing() { - var easing = jQuery.easing, - easing_fns = ["easeInQuad", "easeOutQuad", "easeInOutQuad", - "easeInCubic", "easeOutCubic", "easeInOutCubic", - "easeInQuart", "easeOutQuart", "easeInOutQuart", - "easeInQuint", "easeOutQuint", "easeInOutQuint", - "easeInExpo", "easeOutExpo", "easeInOutExpo", - "easeInSine", "easeOutSine", "easeInOutSine", - "easeInCirc", "easeOutCirc", "easeInOutCirc", - "easeInElastic", "easeOutElastic", "easeInOutElastic", - "easeInBack", "easeOutBack", "easeInOutBack", - "easeInBounce", "easeOutBounce", "easeInOutBounce"], - step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error - easing_fns.forEach( function( name ) { - var fn = easing[ name ]; - for( var i = 0; i <= 1; i += step ) { - console.log( "$.easing." + name + "(" + i + "): " + fn.call(easing, i) ); + const easing = jQuery.easing; + + function test_easing_function( name: string, fn: JQueryEasingFunction ) { + const step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error + for( let i = 0; i <= 1; i += step ) { + console.log( `$.easing.${name}(${i}): ${fn.call(easing, i)}` ); } - } ); + } + + test_easing_function("easeInQuad", easing.easeInQuad); + test_easing_function("easeOutQuad", easing.easeOutQuad); + test_easing_function("easeInOutQuad", easing.easeInOutQuad); + test_easing_function("easeInCubic", easing.easeInCubic); + test_easing_function("easeOutCubic", easing.easeOutCubic); + test_easing_function("easeInOutCubic", easing.easeInOutCubic); + test_easing_function("easeInQuart", easing.easeInQuart); + test_easing_function("easeOutQuart", easing.easeOutQuart); + test_easing_function("easeInOutQuart", easing.easeInOutQuart); + test_easing_function("easeInQuint", easing.easeInQuint); + test_easing_function("easeOutQuint", easing.easeOutQuint); + test_easing_function("easeInOutQuint", easing.easeInOutQuint); + test_easing_function("easeInExpo", easing.easeInExpo); + test_easing_function("easeOutExpo", easing.easeOutExpo); + test_easing_function("easeInOutExpo", easing.easeInOutExpo); + test_easing_function("easeInSine", easing.easeInSine); + test_easing_function("easeOutSine", easing.easeOutSine); + test_easing_function("easeInOutSine", easing.easeInOutSine); + test_easing_function("easeInCirc", easing.easeInCirc); + test_easing_function("easeOutCirc", easing.easeOutCirc); + test_easing_function("easeInOutCirc", easing.easeInOutCirc); + test_easing_function("easeInElastic", easing.easeInElastic); + test_easing_function("easeOutElastic", easing.easeOutElastic); + test_easing_function("easeInOutElastic", easing.easeInOutElastic); + test_easing_function("easeInBack", easing.easeInBack); + test_easing_function("easeOutBack", easing.easeOutBack); + test_easing_function("easeInOutBack", easing.easeInOutBack); + test_easing_function("easeInBounce", easing.easeInBounce); + test_easing_function("easeOutBounce", easing.easeOutBounce); + test_easing_function("easeInOutBounce", easing.easeInOutBounce); } From fda3d9c587df3940304c9b68ea33d6c985ff0623 Mon Sep 17 00:00:00 2001 From: ccrowhurstram Date: Fri, 8 Jan 2016 21:29:18 +0000 Subject: [PATCH 23/40] add latest ng-table typing --- ng-table/ng-table-tests.ts | 114 +++++ ng-table/ng-table.d.ts | 838 +++++++++++++++++++++++++++++++++++++ 2 files changed, 952 insertions(+) create mode 100644 ng-table/ng-table-tests.ts create mode 100644 ng-table/ng-table.d.ts diff --git a/ng-table/ng-table-tests.ts b/ng-table/ng-table-tests.ts new file mode 100644 index 000000000..1cc9c47a0 --- /dev/null +++ b/ng-table/ng-table-tests.ts @@ -0,0 +1,114 @@ +/// + +interface IPerson { + age: number; + name: string; +} + +function printPerson(p: IPerson) { + console.log('age: ' + p.age); + console.log('name: ' + p.name); +} + +// NgTableParams signature tests +namespace NgTableParamsTests { + + let initialParams: NgTable.IParamValues = { + filter: { name: 'Christian' }, + sorting: { age: 'asc' } + }; + let settings: NgTable.ISettings = { + dataset: [{ age: 1, name: 'Christian' }, { age: 2, name: 'Lee' }, { age: 40, name: 'Christian' }], + filterOptions: { + filterComparator: true, + filterDelay: 100 + }, + counts: [10, 20, 50] + }; + + export let tableParams = new NgTableParams(initialParams, settings); + + // modify parameters + tableParams.filter({ name: 'Lee' }); + tableParams.sorting('age', 'desc'); + tableParams.count(10); + tableParams.group(item => (item.age * 10).toString()); + + // modify settings at runtime + tableParams.settings({ + dataset: [{ age: 1, name: 'Brandon' }, { age: 2, name: 'Lee' }] + }); + + tableParams.reload().then(rows => { + rows.forEach(printPerson); + }); +} + +// Dynamic table column signature tests +namespace ColumnTests { + interface ICustomColFields { + field: string; + } + let dynamicCols: (NgTable.Columns.IDynamicTableColDef & ICustomColFields)[]; + + dynamicCols.push({ + class: () => 'table', + field: 'age', + filter: { age: 'number' }, + sortable: true, + show: true, + title: 'Age of Person', + titleAlt: 'Age' + }); +} + +namespace EventsTests { + declare let events: NgTable.Events.IEventsChannel; + + let unregistrationFuncs: NgTable.Events.IUnregistrationFunc[] = []; + let x: NgTable.Events.IUnregistrationFunc; + + x = events.onAfterCreated(params => { + // do stuff + }); + unregistrationFuncs.push(x); + + x = events.onAfterReloadData((params, newData, oldData) => { + newData.forEach(row => { + if (isDataGroup(row)) { + row.data.forEach(printPerson) + } else { + printPerson(row); + } + }); + }, NgTableParamsTests.tableParams); + unregistrationFuncs.push(x); + + x = events.onDatasetChanged((params, newDataset, oldDataset) => { + if (newDataset != null) { + newDataset.forEach(printPerson); + } + }, NgTableParamsTests.tableParams); + unregistrationFuncs.push(x); + + x = events.onPagesChanged((params, newButtons, oldButtons) => { + newButtons.forEach(printPageButton); + }, NgTableParamsTests.tableParams); + unregistrationFuncs.push(x); + + unregistrationFuncs.forEach(f => { + f(); + }); + + + function printPageButton(btn: NgTable.IPageButton) { + console.log('type: ' + btn.type); + console.log('number: ' + btn['number']); + console.log('current: ' + btn.current); + console.log('active: ' + btn.active); + } + + function isDataGroup(row: any): row is NgTable.Data.IDataRowGroup { + return ('$hideRows' in row); + } +} \ No newline at end of file diff --git a/ng-table/ng-table.d.ts b/ng-table/ng-table.d.ts new file mode 100644 index 000000000..ab485a277 --- /dev/null +++ b/ng-table/ng-table.d.ts @@ -0,0 +1,838 @@ +// Type definitions for ng-table +// Project: https://github.com/esvit/ng-table +// Definitions by: Christian Crowhurst +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +/** + * Parameters manager for an ngTable directive + */ +declare class NgTableParams { + /** + * The page of data rows currently being displayed in the table + */ + data: T[]; + + constructor(baseParameters?: NgTable.IParamValues, baseSettings?: NgTable.ISettings) + + /** + * Returns the number of data rows per page + */ + count(): number + /** + * Sets the number of data rows per page. + * Changes to count will cause `isDataReloadRequired` to return true + */ + count(count: number): NgTableParams + + /** + * Returns the current filter values used to restrict the set of data rows. + * @param trim supply true to return the current filter minus any insignificant values + * (null, undefined and empty string) + */ + filter(trim?: boolean): NgTable.IFilterValues + /** + * Sets filter values to the `filter` supplied; any existing filter will be removed + * Changes to filter will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 + */ + filter(filter: NgTable.IFilterValues): NgTableParams + /** + * Generate array of pages. + * When no arguments supplied, the current parameter state of this `NgTableParams` instance will be used + */ + generatePagesArray(currentPage?: number, totalItems?: number, pageSize?: number, maxBlocks?: number): NgTable.IPageButton[] + /** + * Returns the current grouping used to group the data rows + */ + group(): NgTable.Grouping + /** + * Sets grouping to the `field` and `sortDirection` supplied; any existing grouping will be removed + * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 + */ + group(field: string, sortDirection?: string): NgTableParams + /** + * Sets grouping to the `group` supplied; any existing grouping will be removed. + * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 + */ + group(group: NgTable.Grouping): NgTableParams + /** + * Returns true when an attempt to `reload` the current `parameter` values have resulted in a failure. + * This method will continue to return true until the `reload` is successfully called or when the + * `parameter` values have changed + */ + hasErrorState(): boolean + /** + * Returns true if `filter` has significant filter value(s) (any value except null, undefined, or empty string), + * otherwise false + */ + hasFilter(): boolean + /** + * Return true when a change to `filters` require the `reload` method + * to be run so as to ensure the data presented to the user reflects these filters + */ + hasFilterChanges(): boolean + /** + * Returns true when at least one group has been set + */ + hasGroup(): boolean + /** + * Returns true when the `group` and when supplied, the `sortDirection` matches an existing group + */ + hasGroup(group: string | NgTable.IGroupingFunc, sortDirection?: string): boolean + /** + * Return true when a change to this instance should require the `reload` method + * to be run so as to ensure the data rows presented to the user reflects the current state. + * + * Note that this method will return false when the `reload` method has run but fails. In this case + * `hasErrorState` will return true. + * + * The built-in `ngTable` directives will watch for when this function returns true and will then call + * the `reload` method to load its data rows + */ + isDataReloadRequired(): boolean + /** + * Returns sorting values in a format that can be consumed by the angular `$orderBy` filter service + */ + orderBy(): string[] + /** + * Trigger a reload of the data rows + */ + reload>(): ng.IPromise + /** + * Returns the settings for the table. + */ + settings(): NgTable.ISettings + /** + * Sets the settings for the table; new setting values will be merged with the existing settings. + * Supplying a new `dataset` will cause `isDataReloadRequired` to return true and the `ngTableEventsChannel` + * to fire its `datasetChanged` event + */ + settings(newSettings: NgTable.ISettings): NgTableParams + /** + * Returns the current sorting used to order the data rows. + * Changes to sorting will cause `isDataReloadRequired` to return true + */ + sorting(): NgTable.ISortingValues + /** + * Sets sorting values to the `sorting` supplied; any existing sorting will be removed. + * Changes to sorting will cause `isDataReloadRequired` to return true + */ + sorting(sorting: NgTable.ISortingValues): NgTableParams + /** + * Sets sorting to the `field` and `direction` supplied; any existing sorting will be removed + */ + sorting(field: string, direction: string): NgTableParams + /** + * Returns the index of the current "slice" of data rows + */ + page(): number + /** + * Sets the index of the current "slice" of data rows. The index starts at 1. + * Changing the page number will cause `isDataReloadRequired` to return true + */ + page(page: number): NgTableParams + /** + * Returns the count of the data rows that match the current `filter` + */ + total(): number + /** + * Sets `settings().total` to the value supplied. + * Typically you will need to set a `total` in the body of any custom `getData` function + * you supply as a setting value to this instance. + * @example + * var tp = new NgTableParams({}, { getData: customGetData }) + * function customGetData(params) { + * var queryResult = /* code to fetch current data rows and total *\/ + * params.total(queryResult.total); + * return queryResult.dataRowsPage; + * } + */ + total(total: number): NgTableParams + /** + * Returns the current parameter values uri-encoded. Set `asString` to + * true for the parameters to be returned as an array of strings of the form 'paramName=value' + * otherwise parameters returned as a key-value object + */ + url(asString?: boolean): { [name: string]: string } | string[] +} + +declare namespace NgTable { + + interface IDataSettings { + applyPaging?: boolean; + } + + /** + * An angular value object that allow for overriding of the initial default values used when constructing + * an instance of `NgTableParams` + */ + interface IDefaults { + params?: IParamValues; + settings?: ISettings + } + + /** + * Map of the names of fields declared on a data row and the corrosponding filter value + */ + interface IFilterValues { [name: string]: any } + + /** + * Map of the names of fields on a data row and the corrosponding sort direction; + * Set the value of a key to undefined to let value of `ISettings.defaultSort` apply + */ + interface ISortingValues { [name: string]: string } + + type Grouping = IGroupValues | IGroupingFunc; + + /** + * Map of the names of fields on a data row and the corrosponding sort direction + */ + interface IGroupValues { [name: string]: string } + + /** + * Signature of a function that should return the name of the group + * that the `item` should be placed within + */ + interface IGroupingFunc { + (item: T): string; + /** + * 'asc' or 'desc'; leave undefined to let the value of `ISettings.groupOptions.defaultSort` apply + */ + sortDirection?: string + } + + /** + * The runtime values for `NgTableParams` that determine the set of data rows and + * how they are to be displayed in a table + */ + interface IParamValues { + /** + * The index of the "slice" of data rows, starting at 1, to be displayed by the table. + */ + page?: number; + /** + * The number of data rows per page + */ + count?: number; + /** + * The filter that should be applied to restrict the set of data rows + */ + filter?: IFilterValues; + /** + * The sort order that should be applied to the data rows. + */ + sorting?: ISortingValues; + /** + * The grouping that should be applied to the data rows + */ + group?: string | Grouping; + } + + + type FilterComparator = boolean | IFilterComparatorFunc; + + interface IFilterComparatorFunc { + (actual: T, expected: T): boolean; + } + + interface IFilterFunc { + (data: T[], filter: IFilterValues, filterComparator: FilterComparator): T[] + } + + + interface IFilterSettings { + /** + * Use this to determine how items are matched against the filter values. + * This setting is identical to the `comparator` parameter supported by the angular + * `$filter` filter service + * + * Defaults to `undefined` which will result in a case insensitive susbstring match when + * `IDefaultGetData` service is supplying the implementation for the + * `ISettings.getData` function + */ + filterComparator?: FilterComparator; + /** + * A duration to wait for the user to stop typing before applying the filter. + * - Defaults to 0 for small managed inmemory arrays ie where a `ISettings.dataset` argument is + * supplied to `NgTableParams.settings`. + * - Defaults to 500 milliseconds otherwise. + */ + filterDelay?: number; + /** + * The number of elements up to which a managed inmemory array is considered small. Defaults to 10000. + */ + filterDelayThreshold?: number; + /** + * Overrides `IDefaultGetDataProvider.filterFilterName`. + * The value supplied should be the name of the angular `$filter` service that will be selected to perform + * the actual filter logic. + * Defaults to 'filter'. + */ + filterFilterName?: string; + /** + * Tells `IDefaultGetData` to use this function supplied to perform the filtering instead of selecting an angular $filter. + */ + filterFn?: IFilterFunc; + /** + * The layout to use when multiple html templates are to rendered in a single table header column. + * Available values: + * - stack (the default) + * - horizontal + */ + filterLayout?: string + } + + interface IGroupSettings { + /** + * The default sort direction that will be used whenever a group is supplied that + * does not define its own sort direction + */ + defaultSort?: string; + /** + * Determines whether groups should be displayed expanded to show their items. Defaults to true + */ + isExpanded?: boolean; + } + + /** + * Definition of the buttons rendered by the data row pager directive + */ + interface IPageButton { + type: string; + number?: number; + active: boolean; + current?: boolean; + } + + /** + * Configuration settings for `NgTableParams` + */ + interface ISettings { + /** + * Returns true whenever a call to `getData` is in progress + */ + $loading?: boolean; + /** + * An array that contains all the data rows that NgTable should manage. + * The `gateData` function will be used to manage the data rows + * that ultimately will be displayed. + */ + dataset?: T[]; + dataOptions?: {}; + /** + * The total number of data rows before paging has been applied. + * Typically you will not need to supply this yourself + */ + total?: number; + /** + * The default sort direction that will be used whenever a sorting is supplied that + * does not define its own sort direction + */ + defaultSort?: string; + filterOptions?: IFilterSettings; + groupOptions?: IGroupSettings; + /** + * The page size buttons that should be displayed. Each value defined in the array + * determines the possible values that can be supplied to `NgTableParams.page()` + */ + counts?: number[]; + /** + * The collection of interceptors that should apply to the results of a call to + * the `getData` function before the data rows are displayed in the table + */ + interceptors?: IInterceptor[]; + /** + * Configuration for the template that will display the page size buttons + */ + paginationMaxBlocks?: number; + /** + * Configuration for the template that will display the page size buttons + */ + paginationMinBlocks?: number; + /** + * The html tag that will be used to display the sorting indicator in the table header + */ + sortingIndicator?: string; + /** + * The function that will be used fetch data rows. Leave undefined to let the `IDefaultGetData` + * service provide a default implementation that will work with the `dataset` array you supply. + * + * Typically you will supply a custom function when you need to execute filtering, paging and sorting + * on the server + */ + getData?: Data.IGetDataFunc | Data.IInterceptableGetDataFunc; + /** + * The function that will be used group data rows according to the groupings returned by `NgTableParams.group()` + */ + getGroups?: Data.IGetGroupFunc; + } + + /** + * Configuration values that determine the behaviour of the `ngTableFilterConfig` service + */ + interface IFilterConfigValues { + /** + * The default base url to use when deriving the url for a filter template given just an alias name + * Defaults to 'ng-table/filters/' + */ + defaultBaseUrl?: string; + /** + * The extension to use when deriving the url of a filter template when given just an alias name + */ + defaultExt?: string; + /** + * A map of alias names and their corrosponding urls. A lookup against this map will be used + * to find the url matching an alias name. + * If no match is found then a url will be derived using the following pattern `${defaultBaseUrl}${aliasName}.${defaultExt}` + */ + aliasUrls?: { [name: string]: string }; + } + + /** + * The angular provider used to configure the behaviour of the `ngTableFilterConfig` service + */ + interface IFilterConfigProvider { + $get: IFilterConfig; + /** + * Reset back to factory defaults the config values that `ngTableFilterConfig` service will use + */ + resetConfigs(): void; + /** + * Set the config values used by `ngTableFilterConfig` service + */ + setConfig(customConfig: IFilterConfigValues): void; + } + + /** + * A key value-pair map where the key is the name of a field in a data row and the value is the definition + * for the template used to render a filter cell in the header of a html table. + * Where the value is supplied as a string this should either be url to a html template or an alias to a url registered + * using the `ngTableFilterConfigProvider` + * @example + * vm.ageFilter = { "age": "number" } + * @example + * vm.ageFilter = { "age": "my/custom/ageTemplate.html" } + * @example + * vm.ageFilter = { "age": { id: "number", placeholder: "Age of person"} } + */ + interface IFilterTemplateDefMap { + [name: string]: string | IFilterTemplateDef + } + + /** + * A fully qualified template definition for a single filter + */ + interface IFilterTemplateDef { + /** + * A url to a html template of an alias to a url registered using the `ngTableFilterConfigProvider` + */ + id: string, + /** + * The text that should be rendered as a prompt to assist the user when entering a filter value + */ + placeholder: string + } + + /** + * Exposes configuration values and methods used to return the location of the html + * templates used to render the filter row of an ng-table directive + */ + interface IFilterConfig { + /** + * Readonly copy of the final values used to configure the service. + */ + config: IFilterConfigValues, + /** + * Return the url of the html filter template for the supplied definition and key. + * For more information see the documentation for `IFilterTemplateMap` + */ + getTemplateUrl(filterDef: string | IFilterTemplateDef, filterKey?: string): string, + /** + * Return the url of the html filter template registered with the alias supplied + */ + getUrlForAlias(aliasName: string, filterKey?: string): string + } + + interface InternalTableParams extends NgTableParams { + isNullInstance: boolean + } + + /** + * A custom object that can be registered with an NgTableParams instance that can be used + * to post-process the results (and failures) returned by its `getData` function + */ + interface IInterceptor { + response?: (data: TData, params: NgTableParams) => TData; + responseError?: (reason: any, params: NgTableParams) => any; + } + + type SelectData = ISelectOption[] | ISelectDataFunc + + interface ISelectOption { + id: string | number; + title: string; + } + + interface ISelectDataFunc { + (): ISelectOption[] | ng.IPromise + } + + /** + * Definition of the constructor function that will construct new instances of `NgTableParams`. + * On construction of `NgTableParams` the `ngTableEventsChannel` will fire its `afterCreated` event. + */ + interface ITableParamsConstructor { + new (baseParameters?: IParamValues, baseSettings?: ISettings): NgTableParams + } + + + namespace Data { + + type DataResult = T | IDataRowGroup; + + interface IDataRowGroup { + data: T[]; + $hideRows: boolean; + value: string; + } + + /** + * A default implementation of the getData function that will apply the `filter`, `orderBy` and + * paging values from the `NgTableParams` instance supplied to the data array supplied. + * + * A call to this function will: + * - return the resulting array + * - assign the total item count after filtering to the `total` of the `NgTableParams` instance supplied + */ + interface IDefaultGetData { + (data: T[], params: NgTableParams): T[]; + /** + * Convenience function that this service will use to apply paging to the data rows. + * + * Returns a slice of rows from the `data` array supplied and sets the `NgTableParams.total()` + * on the `params` instance supplied to `data.length` + */ + applyPaging(data: T[], params: NgTableParams): T[], + /** + * Returns a reference to the function that this service will use to filter data rows + */ + getFilterFn(params: NgTableParams): IFilterFunc, + /** + * Returns a reference to the function that this service will use to sort data rows + */ + getOrderByFn(params?: NgTableParams): void + } + + /** + * Allows for the configuration of the ngTableDefaultGetData service. + */ + interface IDefaultGetDataProvider { + $get(): IDefaultGetData; + /** + * The name of a angular filter that knows how to apply the values returned by + * `NgTableParams.filter()` to restrict an array of data. + * (defaults to the angular `filter` filter service) + */ + filterFilterName: string, + /** + * The name of a angular filter that knows how to apply the values returned by + * `NgTableParams.orderBy()` to sort an array of data. + * (defaults to the angular `orderBy` filter service) + */ + sortingFilterName: string + } + + interface IGetDataBcShimFunc { + (originalFunc: ILegacyGetDataFunc): { (params: NgTableParams): ng.IPromise } + } + + /** + * Signature of a function that will called whenever NgTable requires to load data rows + * into the table. + * `params` is the table requesting the data rows + */ + interface IGetDataFunc { + (params: NgTableParams): T[] | ng.IPromise; + } + + interface IGetGroupFunc { + (params: NgTableParams): { [name: string]: IDataRowGroup[] } + } + + /** + * Variation of the `IGetDataFunc` function signature that allows for flexibility for + * the shape of the return value. + * Typcially you will use this function signature when you want to configure `NgTableParams` with + * interceptors that will return the final data rows array. + */ + interface IInterceptableGetDataFunc { + (params: NgTableParams): TResult; + } + + interface ILegacyGetDataFunc { + ($defer: ng.IDeferred, params: NgTableParams): void + } + } + + namespace Events { + interface IEventSelectorFunc { + (publisher: NgTableParams): boolean + } + + type EventSelector = NgTableParams | IEventSelectorFunc + + interface IDatasetChangedListener { + (publisher: NgTableParams, newDataset: T[], oldDataset: T[]): any + } + interface IAfterCreatedListener { + (publisher: NgTableParams): any + } + interface IAfterReloadDataListener { + (publisher: NgTableParams, newData: NgTable.Data.DataResult[], oldData: NgTable.Data.DataResult[]): any + } + interface IPagesChangedListener { + (publisher: NgTableParams, newPages: NgTable.IPageButton[], oldPages: NgTable.IPageButton[]): any + } + + interface IUnregistrationFunc { + (): void + } + + interface IEventsChannel { + /** + * Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed. + * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a + * `scope` to have angular automatically unregister the listener when the `scope` is destroyed. + * + * @param listener the function that will be called when the event fires + * @param scope the angular `$scope` that will limit the lifetime of the event subscription + * @param eventFilter a predicate function that should return true to receive the event + * @return a unregistration function that when called will unregister the `listener` + */ + onAfterCreated(listener: Events.IAfterCreatedListener, scope: ng.IScope, eventFilter?: Events.IEventSelectorFunc): IUnregistrationFunc; + /** + * Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed. + * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. + * + * @param listener the function that will be called when the event fires + * @param eventFilter a predicate function that should return true to receive the event + * @return a unregistration function that when called will unregister the `listener` + */ + onAfterCreated(listener: Events.IAfterCreatedListener, eventFilter?: Events.IEventSelectorFunc): IUnregistrationFunc; + /** + * Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed + * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a + * `scope` to have angular automatically unregister the listener when the `scope` is destroyed. + * + * @param listener the function that will be called when the event fires + * @param scope the angular `$scope` that will limit the lifetime of the event subscription + * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event + * @return a unregistration function that when called will unregister the `listener` + */ + onAfterReloadData(listener: Events.IAfterReloadDataListener, scope: ng.IScope, eventFilter?: Events.EventSelector): IUnregistrationFunc; + /** + * Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed + * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. + * + * @param listener the function that will be called when the event fires + * @param eventFilter a predicate function that should return true to receive the event + * @return a unregistration function that when called will unregister the `listener` + */ + onAfterReloadData(listener: Events.IAfterReloadDataListener, eventFilter?: Events.EventSelector): IUnregistrationFunc; + + /** + * Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance. + * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a + * `scope` to have angular automatically unregister the listener when the `scope` is destroyed. + * + * @param listener the function that will be called when the event fires + * @param scope the angular `$scope` that will limit the lifetime of the event subscription + * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event + * @return a unregistration function that when called will unregister the `listener` + */ + onDatasetChanged(listener: Events.IDatasetChangedListener, scope: ng.IScope, eventFilter?: Events.EventSelector): IUnregistrationFunc; + /** + * Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance. + * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. + * + * @param listener the function that will be called when the event fires + * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event + * @return a unregistration function that when called will unregister the `listener` + */ + onDatasetChanged(listener: Events.IDatasetChangedListener, eventFilter?: Events.EventSelector): IUnregistrationFunc; + + /** + * Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change + * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a + * `scope` to have angular automatically unregister the listener when the `scope` is destroyed. + * + * @param listener the function that will be called when the event fires + * @param scope the angular `$scope` that will limit the lifetime of the event subscription + * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event + * @return a unregistration function that when called will unregister the `listener` + */ + onPagesChanged(listener: Events.IPagesChangedListener, scope: ng.IScope, eventFilter?: Events.EventSelector): IUnregistrationFunc; + /** + * Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change + * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. + * + * @param listener the function that will be called when the event fires + * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event + * @return a unregistration function that when called will unregister the `listener` + */ + onPagesChanged(listener: Events.IPagesChangedListener, eventFilter?: Events.EventSelector): IUnregistrationFunc; + + publishAfterCreated(publisher: NgTableParams): void; + publishAfterReloadData(publisher: NgTableParams, newData: T[], oldData: T[]): void; + publishDatasetChanged(publisher: NgTableParams, newDataset: T[], oldDataset: T[]): void; + publishPagesChanged(publisher: NgTableParams, newPages: NgTable.IPageButton[], oldPages: NgTable.IPageButton[]): void; + } + } + + namespace Columns { + + type ColumnFieldContext = ng.IScope & { + $column: IColumnDef; + $columns: IColumnDef[]; + } + + interface IColumnField { + (context?: ColumnFieldContext): T; + assign($scope: ng.IScope, value: T): void; + } + + /** + * The definition of the column within a ngTable. + * When using `ng-table` directive a column definition will be parsed from each `td` tag found in the + * `tr` data row tag. + * + * @example + * + * + * + * + */ + interface IColumnDef { + /** + * Custom CSS class that should be added to the `th` tag(s) of this column in the table header + * + * To set this on the `td` tag of a html table use the attribute `header-class` or `data-header-class` + */ + class: IColumnField; + /** + * The `ISelectOption`s that can be used in a html filter template for this colums. + */ + data?: SelectData; + /** + * The index position of this column within the `$columns` container array + */ + id: number; + /** + * The definition of 0 or more html filter templates that should be rendered for this column in + * the table header + */ + filter: IColumnField; + /** + * Supplies the `ISelectOption`s that can be used in a html filter template for this colums. + * At the creation of the `NgTableParams` this field will be called and the result then assigned + * to the `data` field of this column. + */ + filterData: IColumnField | SelectData>; + /** + * The name of the data row field that will be used to group on, or false when this column + * does not support grouping + */ + groupable: IColumnField; + /** + * The url of a custom html template that should be used to render a table header for this column + * + * To set this on the `td` tag for a html table use the attribute `header` or `data-header` + */ + headerTemplateURL: IColumnField; + /** + * The text that should be used as a tooltip for this column in the table header + */ + headerTitle: IColumnField; + /** + * Determines whether this column should be displayed in the table + * + * To set this on the `td` tag for a html table use the attribute `ng-if` + */ + show: IColumnField; + /** + * The name of the data row field that will be used to sort on, or false when this column + * does not support sorting + */ + sortable: IColumnField; + /** + * The title of this column that should be displayed in the table header + */ + title: IColumnField; + /** + * An alternate column title. Typically this can be used for responsive table layouts + * where the titleAlt should be used for small screen sizes + */ + titleAlt: IColumnField; + } + + type DynamicTableColField = IDynamicTableColFieldFunc | T; + + interface IDynamicTableColFieldFunc { + (context: ColumnFieldContext): T; + } + + /** + * The definition of the column supplied to a ngTableDynamic directive. + */ + interface IDynamicTableColDef { + /** + * Custom CSS class that should be added to the `th` tag(s) of this column in the table header + */ + class?: DynamicTableColField; + /** + * The definition of 0 or more html filter templates that should be rendered for this column in + * the table header + */ + filter?: DynamicTableColField; + /** + * Supplies the `ISelectOption`s that can be used in a html filter template for this colums. + * At the creation of the `NgTableParams` this field will be called and the result then assigned + * to the `data` field of this column. + */ + filterData?: DynamicTableColField | SelectData>; + /** + * The name of the data row field that will be used to group on, or false when this column + * does not support grouping + */ + groupable?: DynamicTableColField; + /** + * The url of a custom html template that should be used to render a table header for this column + */ + headerTemplateURL?: DynamicTableColField; + /** + * The text that should be used as a tooltip for this column in the table header + */ + headerTitle?: DynamicTableColField; + /** + * Determines whether this column should be displayed in the table + */ + show?: DynamicTableColField; + /** + * The name of the data row field that will be used to sort on, or false when this column + * does not support sorting + */ + sortable?: DynamicTableColField; + /** + * The title of this column that should be displayed in the table header + */ + title?: DynamicTableColField; + /** + * An alternate column title. Typically this can be used for responsive table layouts + * where the titleAlt should be used for small screen sizes + */ + titleAlt?: DynamicTableColField; + } + } +} + From 07c1937a85b506cb599f82a8f9be0100878b5dad Mon Sep 17 00:00:00 2001 From: Tadeusz Hucal Date: Sat, 9 Jan 2016 00:05:13 +0100 Subject: [PATCH 24/40] Angular GrowlV2 - added missing message methods; fixed module name --- angular-growl-v2/angular-growl-v2-tests.ts | 4 ++++ angular-growl-v2/angular-growl-v2.d.ts | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/angular-growl-v2/angular-growl-v2-tests.ts b/angular-growl-v2/angular-growl-v2-tests.ts index fdb661161..c03e0725a 100644 --- a/angular-growl-v2/angular-growl-v2-tests.ts +++ b/angular-growl-v2/angular-growl-v2-tests.ts @@ -58,4 +58,8 @@ app.controller("Ctrl", ($scope:angular.IScope, growlMessages.destroyAllMessages(0); growlMessages.addMessage(messages[0]); growlMessages.deleteMessage(messages[1]); + + var testMessage = growl.warning(message); + testMessage.setText("Some other message"); + testMessage.destroy(); }); diff --git a/angular-growl-v2/angular-growl-v2.d.ts b/angular-growl-v2/angular-growl-v2.d.ts index a8e262071..07c0dbe37 100644 --- a/angular-growl-v2/angular-growl-v2.d.ts +++ b/angular-growl-v2/angular-growl-v2.d.ts @@ -39,6 +39,16 @@ declare module angular.growl { */ interface IGrowlMessage extends IGrowlMessageConfig { text: string; + + /** + * Destroy the message. + */ + destroy(): void; + /** + * Update the message body. + * @param newText new message body + */ + setText(newText: string): void; } /** @@ -223,7 +233,7 @@ declare module angular.growl { * @param referenceId * @param limitMessages */ - initDirective(referenceId: number, limitMessages: number): ng.IDirective; + initDirective(referenceId: number, limitMessages: number): angular.IDirective; /** * Get current messages From 0fbf24e27e240cc59b8d9c27610a2fe055fda75d Mon Sep 17 00:00:00 2001 From: stephenjelfs Date: Sat, 9 Jan 2016 12:12:42 +0100 Subject: [PATCH 25/40] Fixed-Data-Table row mouse event method signatures should include event parameters. --- fixed-data-table/fixed-data-table-tests.tsx | 24 +++++++++++++++++++++ fixed-data-table/fixed-data-table.d.ts | 16 +++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/fixed-data-table/fixed-data-table-tests.tsx b/fixed-data-table/fixed-data-table-tests.tsx index 1f10a9fdb..2c8e04a7d 100644 --- a/fixed-data-table/fixed-data-table-tests.tsx +++ b/fixed-data-table/fixed-data-table-tests.tsx @@ -161,3 +161,27 @@ class MyTable4 extends React.Component<{}, MyTable4State> { ); } } + +// Listen for events +class MyTable5 extends React.Component<{}, {}> { + render(): React.ReactElement { + return ( + {}} + onScrollEnd={(x: number, y: number) => {}} + onContentHeightChange={(newHeight: number) => {}} + onRowClick={(event: React.SyntheticEvent, rowIndex: number) => {}} + onRowDoubleClick={(event: React.SyntheticEvent, rowIndex: number) => {}} + onRowMouseDown={(event: React.SyntheticEvent, rowIndex: number) => {}} + onRowMouseEnter={(event: React.SyntheticEvent, rowIndex: number) => {}} + onRowMouseLeave={(event: React.SyntheticEvent, rowIndex: number) => {}} + onColumnResizeEndCallback={(newColumnWidth: number, columnKey: string) => {}}> + // add columns +
            + ); + } +} diff --git a/fixed-data-table/fixed-data-table.d.ts b/fixed-data-table/fixed-data-table.d.ts index 219b7e39f..843eb458e 100644 --- a/fixed-data-table/fixed-data-table.d.ts +++ b/fixed-data-table/fixed-data-table.d.ts @@ -187,13 +187,13 @@ declare module FixedDataTable { * Callback that is called when scrolling starts with * current horizontal and vertical scroll values. */ - onScrollStart?: (horizontalScroll: number, verticalScroll: number) => void; + onScrollStart?: (x: number, y: number) => void; /** * Callback that is called when scrolling ends or stops with * new horizontal and vertical scroll values. */ - onScrollEnd?: (horizontalScroll: number, verticalScroll: number) => void; + onScrollEnd?: (x: number, y: number) => void; /** * Callback that is called when rowHeightGetter returns a @@ -201,35 +201,35 @@ declare module FixedDataTable { * is necessary because initially table estimates heights * of some parts of the content. */ - onContentHeightChange?: (height: number) => void; + onContentHeightChange?: (newHeight: number) => void; /** * Callback that is called when a row is clicked. */ - onRowClick?: (index: number) => void; + onRowClick?: (event: __React.SyntheticEvent, rowIndex: number) => void; /** * Callback that is called when a row is double clicked. */ - onRowDoubleClick?: (index: number) => void; + onRowDoubleClick?: (event: __React.SyntheticEvent, rowIndex: number) => void; /** * Callback that is called when a mouse-down event happens * on a row. */ - onRowMouseDown?: (index: number) => void; + onRowMouseDown?: (event: __React.SyntheticEvent, rowIndex: number) => void; /** * Callback that is called when a mouse-enter event happens * on a row. */ - onRowMouseEnter?: (index: number) => void; + onRowMouseEnter?: (event: __React.SyntheticEvent, rowIndex: number) => void; /** * Callback that is called when a mouse-leave event happens * on a row. */ - onRowMouseLeave?: (index: number) => void; + onRowMouseLeave?: (event: __React.SyntheticEvent, rowIndex: number) => void; /** * Callback that is called when resizer has been released From 88dd64ae4f16a3444bb636c2cc28ebe572917054 Mon Sep 17 00:00:00 2001 From: mzsm Date: Sat, 9 Jan 2016 20:33:20 +0900 Subject: [PATCH 26/40] Support Wii U Internet Browser, Extended Functionality --- wiiu/wiiu-tests.ts | 56 +++++++++++++++++++++++ wiiu/wiiu.d.ts | 112 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 wiiu/wiiu-tests.ts create mode 100644 wiiu/wiiu.d.ts diff --git a/wiiu/wiiu-tests.ts b/wiiu/wiiu-tests.ts new file mode 100644 index 000000000..0417e252a --- /dev/null +++ b/wiiu/wiiu-tests.ts @@ -0,0 +1,56 @@ +/// + +var state = window.wiiu.gamepad.update(); +if( !state.isEnabled || !state.isDataValid ){ + console.log('gyro X:' + state.gyroX.toString() + ' Y:' + state.gyroY.toString() + ' Z:' + state.gyroZ.toString()); + console.log('angle X:' + state.angleX.toString() + ' Y:' + state.angleY.toString() + ' Z:' + state.angleZ.toString()); + console.log('dirX X:' + state.dirXx.toString() + ' Y:' + state.dirXy.toString() + ' Z:' + state.dirXz.toString()); + console.log('dirY X:' + state.dirYx.toString() + ' Y:' + state.dirYy.toString() + ' Z:' + state.dirYz.toString()); + console.log('dirZ X:' + state.dirZx.toString() + ' Y:' + state.dirZy.toString() + ' Z:' + state.dirZz.toString()); + console.log('acc X:' + state.accX.toString() + ' Y:' + state.accY.toString() + ' Z:' + state.accZ.toString()); + console.log('LStick axis X:' + state.lStickX.toString() + ' Y:' + state.lStickY.toString()); + console.log('RStick axis X:' + state.rStickX.toString() + ' Y:' + state.rStickY.toString()); + + if(state.hold & window.wiiu.Button.A){ + console.log('pushing A button'); + } + + if( state.tpTouch && state.tpValidity == window.wiiu.TPValidity.VALID ){ + console.log("touch X:" + state.contentX.toString() + " Y:" + state.contentY.toString()); + } +} + +document.getElementById('video').addEventListener('wiiu_videoplayer_end', (e) => { + console.log(e); + console.log('VideoPlayer end'); +}); + +if(window.wiiu.videoplayer.viewMode == 0){ + window.wiiu.videoplayer.viewMode = 1; +} +window.wiiu.videoplayer.end(); + +window.addEventListener('wiiu_imageview_start', (e) => { + console.log(e); + console.log('ImageViewer start'); +}); +window.addEventListener('wiiu_imageview_end', (e) => { + console.log(e); + console.log('ImageViewer end'); +}); +window.addEventListener('wiiu_imageview_change_viewmode', (e) => { + console.log(e); + console.log('ImageViewer change viewmode'); + if(window.wiiu.imageview.viewMode == 1){ + window.wiiu.imageview.viewMode = 0; + } +}); +window.addEventListener('wiiu_imageview_change_content', (e) => { + console.log(e); + console.log('ImageViewer change content'); +}); +window.addEventListener('wiiu_imageview_error', (e) => { + console.log(e); + console.log('ImageViewer error'); + console.log(window.wiiu.imageview.getErrorCode()); +}); diff --git a/wiiu/wiiu.d.ts b/wiiu/wiiu.d.ts new file mode 100644 index 000000000..b7111c91b --- /dev/null +++ b/wiiu/wiiu.d.ts @@ -0,0 +1,112 @@ +// Type definitions for Wii U Internet Browser, Extended Functionality +// Project: https://www.nintendo.co.jp/wiiu/hardware/internetbrowser/extended_functionality.html +// Definitions by: MIZUSHIMA Junki +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module wiiu { + const enum TPValidity { + VALID = 0, + X_INVALID = 1, + Y_INVALID = 2, + INVALID = 3 + } + const enum Button { + MINUS = 0x00000004, + SELECT = MINUS, + PLUS = 0x00000008, + START = PLUS, + R = 0x00000010, + L = 0x00000020, + ZR = 0x00000040, + ZL = 0x00000080, + DOWN = 0x00000100, + UP = 0x00000200, + RIGHT = 0x00000400, + LEFT = 0x00000800, + Y = 0x00001000, + X = 0x00002000, + B = 0x00004000, + A = 0x00008000, + R_STICK = 0x00020000, + L_STICK = 0x00040000, + R_STICK_DOWN = 0x00800000, + R_STICK_UP = 0x01000000, + R_STICK_RIGHT = 0x02000000, + R_STICK_LEFT = 0x04000000, + L_STICK_DOWN = 0x08000000, + L_STICK_UP = 0x10000000, + L_STICK_RIGHT = 0x20000000, + L_STICK_LEFT = 0x40000000 + } + + interface WiiuGamePad { + isEnabled: boolean; + isDataValid: boolean; + tpTouch: boolean; + tpValidity: number; + contentX: number; + contentY: number; + lStickX: number; + lStickY: number; + rStickX: number; + rStickY: number; + hold: number; + accX: number; + accY: number; + accZ: number; + gyroX: number; + gyroY: number; + gyroZ: number; + angleX: number; + angleY: number; + angleZ: number; + dirXx: number; + dirXy: number; + dirYx: number; + dirXz: number; + dirYy: number; + dirYz: number; + dirZx: number; + dirZz: number; + dirZy: number; + + update(): WiiuGamePad; + } + + interface VideoPlayer { + viewMode: number; + + end(): boolean; + } + + const enum ImageViewErrorCode { + UNSUPPORTED_FORMAT = 202, + DIMENSIONS_TOO_LARGE = 203, + FILE_SIZE_TOO_LARGE = 204, + TOO_MANY_PIXELS_PROGRESSIVE_JPEG = 205 + } + + interface ImageView { + viewMode: number; + + end(): boolean; + getErrorCode(): number; + } + + var gamepad: WiiuGamePad; + var videoplayer: VideoPlayer; + var imageview: ImageView; +} + +interface HTMLElement { + addEventListener(type: "wiiu_videoplayer_end", listener: (ev: CustomEvent) => any, useCapture?: boolean): void; +} + +interface Window { + wiiu: typeof wiiu; + addEventListener(type: "wiiu_imageview_start", listener: (ev: CustomEvent) => any, useCapture?: boolean): void; + addEventListener(type: "wiiu_imageview_end", listener: (ev: CustomEvent) => any, useCapture?: boolean): void; + addEventListener(type: "wiiu_imageview_change_viewmode", listener: (ev: CustomEvent) => any, useCapture?: boolean): void; + addEventListener(type: "wiiu_imageview_change_content", listener: (ev: CustomEvent) => any, useCapture?: boolean): void; + addEventListener(type: "wiiu_imageview_error", listener: (ev: CustomEvent) => any, useCapture?: boolean): void; +} From fb2254b775339aaf10b9f71f801c46b978481fb0 Mon Sep 17 00:00:00 2001 From: mzsm Date: Sat, 9 Jan 2016 20:40:38 +0900 Subject: [PATCH 27/40] Rename title --- wiiu/wiiu.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiiu/wiiu.d.ts b/wiiu/wiiu.d.ts index b7111c91b..184fc5f0a 100644 --- a/wiiu/wiiu.d.ts +++ b/wiiu/wiiu.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Wii U Internet Browser, Extended Functionality +// Type definitions for Extended Functionality of Wii U Internet Browser // Project: https://www.nintendo.co.jp/wiiu/hardware/internetbrowser/extended_functionality.html // Definitions by: MIZUSHIMA Junki // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 2eecb30774e4b92855e3f2f8487a79f4b8998d63 Mon Sep 17 00:00:00 2001 From: "Igor N. Dultsev" Date: Sat, 9 Jan 2016 18:40:21 +0600 Subject: [PATCH 28/40] fixed module export type from Exphbs to ExpressHandleBars Since it is now working this way --- express-handlebars/express-handlebars.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/express-handlebars/express-handlebars.d.ts b/express-handlebars/express-handlebars.d.ts index 04eb07162..70137e1d3 100644 --- a/express-handlebars/express-handlebars.d.ts +++ b/express-handlebars/express-handlebars.d.ts @@ -1,6 +1,7 @@ // Type definitions for express-handlebars // Project: https://github.com/ericf/express-handlebars // Definitions by: Sam Saint-Pettersen +// Updated by: Igor Dultsev // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -40,7 +41,12 @@ interface Exphbs { renderView(viewPath: string, optionsOrCallback: any, callback?: () => string): void; } +interface ExpressHandlebars { + (options?: ExphbsOptions): Function; + create (options?: ExphbsOptions): Exphbs; +} + declare module "express-handlebars" { - var exphbs: Exphbs; + var exphbs: ExpressHandlebars; export = exphbs; } From abd3d655962a537a8369e7a9b81956cc39127584 Mon Sep 17 00:00:00 2001 From: "Igor N. Dultsev" Date: Sat, 9 Jan 2016 18:40:38 +0600 Subject: [PATCH 29/40] updated test to reflect changes in typing file --- express-handlebars/express-handlebars-tests.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/express-handlebars/express-handlebars-tests.ts b/express-handlebars/express-handlebars-tests.ts index 3fa6ef31d..982ff2367 100644 --- a/express-handlebars/express-handlebars-tests.ts +++ b/express-handlebars/express-handlebars-tests.ts @@ -6,9 +6,8 @@ import express = require('express'); import exphbs = require('express-handlebars'); var app = express(); -var hbs: Exphbs = exphbs.create({defaultLayout: 'main'}); -app.engine('handlebars', hbs.engine); +app.engine('handlebars', exphbs({defaultLayout: 'main'})); app.set('view engine', 'handlebars'); app.listen(1337); From 2c157f229f62f851b9fa116f8a11d364ba29a97a Mon Sep 17 00:00:00 2001 From: "Igor N. Dultsev" Date: Sat, 9 Jan 2016 18:50:38 +0600 Subject: [PATCH 30/40] Fix header --- express-handlebars/express-handlebars.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/express-handlebars/express-handlebars.d.ts b/express-handlebars/express-handlebars.d.ts index 70137e1d3..1f24f5ea4 100644 --- a/express-handlebars/express-handlebars.d.ts +++ b/express-handlebars/express-handlebars.d.ts @@ -1,7 +1,6 @@ // Type definitions for express-handlebars // Project: https://github.com/ericf/express-handlebars -// Definitions by: Sam Saint-Pettersen -// Updated by: Igor Dultsev +// Definitions by: Sam Saint-Pettersen , Igor Dultsev // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From f5f2993142a8692b8f5ae7838fd96bb4d655c31a Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sat, 9 Jan 2016 18:24:48 +0500 Subject: [PATCH 31/40] lodash: signatures of _.toArray have been changed --- lodash/lodash-tests.ts | 38 ++++++++++++++++++++++++++------------ lodash/lodash.d.ts | 35 +++++++++++++++++++++++------------ 2 files changed, 49 insertions(+), 24 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 77a20e2e2..3119daee6 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -6255,15 +6255,13 @@ module TestToArray { let array: TResult[]; let list: _.List; let dictionary: _.Dictionary; + let numericDictionary: _.NumericDictionary; { let result: string[]; + result = _.toArray(''); result = _.toArray(''); - - result = (function (a: string) {return _.toArray(arguments);})(''); - - result = _((function (a: string) {return arguments;})('')).toArray().value(); } { @@ -6272,22 +6270,38 @@ module TestToArray { result = _.toArray(array); result = _.toArray(list); result = _.toArray(dictionary); + result = _.toArray(numericDictionary); - result = _(array).toArray().value(); - result = _(list).toArray().value(); - result = _(dictionary).toArray().value(); + result = _.toArray(array); + result = _.toArray(list); + result = _.toArray(dictionary); + result = _.toArray(numericDictionary); } { let result: any[]; result = _.toArray(); - result = _.toArray(42); - result = _.toArray(true); + result = _.toArray(42); + result = _.toArray(true); + } - result = _('').toArray().value(); - result = _(42).toArray().value(); - result = _(true).toArray().value(); + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).toArray(); + result = _(list).toArray(); + result = _(dictionary).toArray(); + result = _(numericDictionary).toArray(); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().toArray(); + result = _(list).chain().toArray(); + result = _(dictionary).chain().toArray(); + result = _(numericDictionary).chain().toArray(); } } diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index c45ec90ee..6b3d269fd 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -10320,12 +10320,7 @@ declare module _ { * @param value The value to convert. * @return Returns the converted array. */ - toArray(value: string): string[]; - - /** - * @see _.toArray - */ - toArray(value: List|Dictionary): T[]; + toArray(value: List|Dictionary|NumericDictionary): T[]; /** * @see _.toArray @@ -10335,12 +10330,7 @@ declare module _ { /** * @see _.toArray */ - toArray(value: TValue): any[]; - - /** - * @see _.toArray - */ - toArray(value?: any): any[]; + toArray(value?: any): TResult[]; } interface LoDashImplicitWrapper { @@ -10364,6 +10354,27 @@ declare module _ { toArray(): LoDashImplicitArrayWrapper; } + interface LoDashExplicitWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashExplicitArrayWrapper; + } + //_.toPlainObject interface LoDashStatic { /** From 58ba924b2ac9c213c0bf1ce9c4100b1c4ff2082f Mon Sep 17 00:00:00 2001 From: Robert Van Gorkom Date: Sat, 9 Jan 2016 08:54:45 -0800 Subject: [PATCH 32/40] Adding meteor roles definitions. --- meteor-roles/meteor-roles-tests.ts | 150 ++++++++++++++++ meteor-roles/meteor-roles.d.ts | 264 +++++++++++++++++++++++++++++ 2 files changed, 414 insertions(+) create mode 100644 meteor-roles/meteor-roles-tests.ts create mode 100644 meteor-roles/meteor-roles.d.ts diff --git a/meteor-roles/meteor-roles-tests.ts b/meteor-roles/meteor-roles-tests.ts new file mode 100644 index 000000000..dae900800 --- /dev/null +++ b/meteor-roles/meteor-roles-tests.ts @@ -0,0 +1,150 @@ +/// +/// +/// + +/** + * All code below was copied from the examples at https://github.com/alanning/meteor-roles/. + * When necessary, code was added to make the examples work (e.g. declaring a variable + * that was assumed to have been declared earlier) + */ + +var joesUserId = '1234'; +Roles.addUsersToRoles(joesUserId, ['manage-team','schedule-game'], 'manchester-united.com') +Roles.addUsersToRoles(joesUserId, ['player','goalie'], 'real-madrid.com') + +Roles.userIsInRole(joesUserId, 'manage-team', 'manchester-united.com') // => true +Roles.userIsInRole(joesUserId, 'manage-team', 'real-madrid.com') // => false + +Roles.addUsersToRoles(joesUserId, 'super-admin', Roles.GLOBAL_GROUP) + +var bobsUserId = '1234'; +Roles.addUsersToRoles(bobsUserId, ['manage-team','schedule-game']) +// internal representation - no groups +// user.roles = ['manage-team','schedule-game'] + +Roles.addUsersToRoles(joesUserId, ['manage-team','schedule-game'], 'manchester-united.com') +Roles.addUsersToRoles(joesUserId, ['player','goalie'], 'real-madrid.com') +// internal representation - groups +// NOTE: MongoDB uses periods to represent hierarchy so periods in group names +// are converted to underscores. +// +// user.roles = { +// 'manchester-united_com': ['manage-team','schedule-game'], +// 'real-madrid_com': ['player','goalie'] +// } + +Meteor.roles.find({}); + + + +var users = [ + {name:"Normal User",email:"normal@example.com",roles:[]}, + {name:"View-Secrets User",email:"view@example.com",roles:['view-secrets']}, + {name:"Manage-Users User",email:"manage@example.com",roles:['manage-users']}, + {name:"Admin User",email:"admin@example.com",roles:['admin']} +]; + +_.each(users, function (user) { + var id : string; + + id = Accounts.createUser({ + email: user.email, + password: "apple1", + profile: { name: user.name } + }); + + if (user.roles.length > 0) { + // Need _id of existing user record so this call must come + // after `Accounts.createUser` or `Accounts.onCreate` + Roles.addUsersToRoles(id, user.roles, 'default-group'); + } + +}); + + + +// server/publish.js + +// Give authorized users access to sensitive data by group +Meteor.publish('secrets', function (group : string) { + if (Roles.userIsInRole(this.userId, ['view-secrets','admin'], group)) { + +// return Meteor.secrets.find({group: group}); + + } else { + + // user not authorized. do not publish secrets + this.stop(); + return; + + } +}); + + +Accounts.validateNewUser(function (user : Meteor.User) { + var loggedInUser = Meteor.user(); + + if (Roles.userIsInRole(loggedInUser, ['admin','manage-users'])) { + // NOTE: This example assumes the user is not using groups. + return true; + } + + throw new Meteor.Error('403', "Not authorized to create new users"); +}); + + +// server/userMethods.js + +Meteor.methods({ + /** + * delete a user from a specific group + * + * @method deleteUser + * @param {String} targetUserId _id of user to delete + * @param {String} group Company to update permissions for + */ + deleteUser: function (targetUserId : string, group : string) { + var loggedInUser = Meteor.user() + + if (!loggedInUser || + !Roles.userIsInRole(loggedInUser, + ['manage-users', 'support-staff'], group)) { + throw new Meteor.Error('403', "Access denied") + } + + // remove permissions for target group + Roles.setUserRoles(targetUserId, [], group) + + // do other actions required when a user is removed... + } +}) + + + +// server/userMethods.js + +Meteor.methods({ + /** + * update a user's permissions + * + * @param {Object} targetUserId Id of user to update + * @param {Array} roles User's new permissions + * @param {String} group Company to update permissions for + */ + updateRoles: function (targetUserId : string, roles : string[], group : string) { + var loggedInUser = Meteor.user() + + if (!loggedInUser || + !Roles.userIsInRole(loggedInUser, + ['manage-users', 'support-staff'], group)) { + throw new Meteor.Error('403', "Access denied") + } + + Roles.setUserRoles(targetUserId, roles, group) + } +}) + + + + + diff --git a/meteor-roles/meteor-roles.d.ts b/meteor-roles/meteor-roles.d.ts new file mode 100644 index 000000000..95e4223ac --- /dev/null +++ b/meteor-roles/meteor-roles.d.ts @@ -0,0 +1,264 @@ +/// + +// Type definitions for Meteor Roles 1.2.14 +// Project: https://github.com/alanning/meteor-roles/ +// Definitions by: Robbie Van Gorkom +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * Provides functions related to user authorization. Compatible with built-in Meteor accounts packages. + * + * @module Roles + */ +declare module Roles { + /** + * Constant used to reference the special 'global' group that + * can be used to apply blanket permissions across all groups. + * + * @example + * Roles.addUsersToRoles(user, 'admin', Roles.GLOBAL_GROUP) + * Roles.userIsInRole(user, 'admin') // => true + * + * Roles.setUserRoles(user, 'support-staff', Roles.GLOBAL_GROUP) + * Roles.userIsInRole(user, 'support-staff') // => true + * Roles.userIsInRole(user, 'admin') // => false + * + * @property GLOBAL_GROUP + * @type String + * @static + * @final + */ + var GLOBAL_GROUP : string; + + /** + * Subscription handle for the currently logged in user's permissions. + * + * NOTE: The corresponding publish function, `_roles`, depends on + * `this.userId` so it will automatically re-run when the currently + * logged-in user changes. + * + * @example + * + * `Roles.subscription.ready()` // => `true` if user roles have been loaded + * + * @property subscription + * @type Object + * @for Roles + */ + var subscription : Subscription; + + /** + * Add users to roles. Will create roles as needed. + * + * NOTE: Mixing grouped and non-grouped roles for the same user + * is not supported and will throw an error. + * + * Makes 2 calls to database: + * 1. retrieve list of all existing roles + * 2. update users' roles + * + * @example + * Roles.addUsersToRoles(userId, 'admin') + * Roles.addUsersToRoles(userId, ['view-secrets'], 'example.com') + * Roles.addUsersToRoles([user1, user2], ['user','editor']) + * Roles.addUsersToRoles([user1, user2], ['glorious-admin', 'perform-action'], 'example.org') + * Roles.addUsersToRoles(userId, 'admin', Roles.GLOBAL_GROUP) + * + * @method addUsersToRoles + * @param {Array|String} users User id(s) or object(s) with an _id field + * @param {Array|String} roles Name(s) of roles/permissions to add users to + * @param {String} [group] Optional group name. If supplied, roles will be + * specific to that group. + * Group names can not start with '$' or numbers. + * Periods in names '.' are automatically converted + * to underscores. + * The special group Roles.GLOBAL_GROUP provides + * a convenient way to assign blanket roles/permissions + * across all groups. The roles/permissions in the + * Roles.GLOBAL_GROUP group will be automatically + * included in checks for any group. + */ + function addUsersToRoles( + user : string|string[]|Object|Object[], + roles : string|string[], + group? : string + ) : void; + + /** + * Create a new role. Whitespace will be trimmed. + * + * @method createRole + * @param {String} role Name of role + * @return {String} id of new role + */ + function createRole(role : string) : string; + + /** + * Delete an existing role. Will throw "Role in use" error if any users + * are currently assigned to the target role. + * + * @method deleteRole + * @param {String} role Name of role + */ + function deleteRole (role : string) : void; + + /** + * Retrieve set of all existing roles + * + * @method getAllRoles + * @return {Cursor} cursor of existing roles + */ + function getAllRoles() : Mongo.Cursor; + + /** + * Retrieve users groups, if any + * + * @method getGroupsForUser + * @param {String|Object} user User Id or actual user object + * @param {String} [role] Optional name of roles to restrict groups to. + * + * @return {Array} Array of user's groups, unsorted. Roles.GLOBAL_GROUP will be omitted + */ + function getGroupsForUser( + user : string|Object, + role? : string + ) : string[]; + + /** + * Retrieve users roles + * + * @method getRolesForUser + * @param {String|Object} user User Id or actual user object + * @param {String} [group] Optional name of group to restrict roles to. + * User's Roles.GLOBAL_GROUP will also be included. + * @return {Array} Array of user's roles, unsorted. + */ + function getRolesForUser( + user : string|Object, + group? : string + ) : Role[]; + + /** + * Retrieve all users who are in target role. + * + * NOTE: This is an expensive query; it performs a full collection scan + * on the users collection since there is no index set on the 'roles' field. + * This is by design as most queries will specify an _id so the _id index is + * used automatically. + * + * @method getUsersInRole + * @param {Array|String} role Name of role/permission. If array, users + * returned will have at least one of the roles + * specified but need not have _all_ roles. + * @param {String} [group] Optional name of group to restrict roles to. + * User's Roles.GLOBAL_GROUP will also be checked. + * @param {Object} [options] Optional options which are passed directly + * through to `Meteor.users.find(query, options)` + * @return {Cursor} cursor of users in role + */ + function getUsersInRole( + role : string|string[], + group? : string, + options? : { + sort?: Mongo.SortSpecifier; + skip?: number; + limit?: number; + fields?: Mongo.FieldSpecifier; + reactive?: boolean; + transform?: Function; + }) : Mongo.Cursor; + + /** + * Remove users from roles + * + * @example + * Roles.removeUsersFromRoles(users.bob, 'admin') + * Roles.removeUsersFromRoles([users.bob, users.joe], ['editor']) + * Roles.removeUsersFromRoles([users.bob, users.joe], ['editor', 'user']) + * Roles.removeUsersFromRoles(users.eve, ['user'], 'group1') + * + * @method removeUsersFromRoles + * @param {Array|String} users User id(s) or object(s) with an _id field + * @param {Array|String} roles Name(s) of roles to add users to + * @param {String} [group] Optional. Group name. If supplied, only that + * group will have roles removed. + */ + function removeUsersFromRoles( + user : string|string[]|Object|Object[], + roles? : string[], + group? : string + ) : void; + + /** + * Set a users roles/permissions. + * + * @example + * Roles.setUserRoles(userId, 'admin') + * Roles.setUserRoles(userId, ['view-secrets'], 'example.com') + * Roles.setUserRoles([user1, user2], ['user','editor']) + * Roles.setUserRoles([user1, user2], ['glorious-admin', 'perform-action'], 'example.org') + * Roles.setUserRoles(userId, 'admin', Roles.GLOBAL_GROUP) + * + * @method setUserRoles + * @param {Array|String} users User id(s) or object(s) with an _id field + * @param {Array|String} roles Name(s) of roles/permissions to add users to + * @param {String} [group] Optional group name. If supplied, roles will be + * specific to that group. + * Group names can not start with '$'. + * Periods in names '.' are automatically converted + * to underscores. + * The special group Roles.GLOBAL_GROUP provides + * a convenient way to assign blanket roles/permissions + * across all groups. The roles/permissions in the + * Roles.GLOBAL_GROUP group will be automatically + * included in checks for any group. + */ + function setUserRoles ( + user : string|string[]|Object|Object[], + roles : string|string[], + group? : string + ) : void; + + /** + * Check if user has specified permissions/roles + * + * @example + * // non-group usage + * Roles.userIsInRole(user, 'admin') + * Roles.userIsInRole(user, ['admin','editor']) + * Roles.userIsInRole(userId, 'admin') + * Roles.userIsInRole(userId, ['admin','editor']) + * + * // per-group usage + * Roles.userIsInRole(user, ['admin','editor'], 'group1') + * Roles.userIsInRole(userId, ['admin','editor'], 'group1') + * Roles.userIsInRole(userId, ['admin','editor'], Roles.GLOBAL_GROUP) + * + * // this format can also be used as short-hand for Roles.GLOBAL_GROUP + * Roles.userIsInRole(user, 'admin') + * + * @method userIsInRole + * @param {String|Object} user User Id or actual user object + * @param {String|Array} roles Name of role/permission or Array of + * roles/permissions to check against. If array, + * will return true if user is in _any_ role. + * @param {String} [group] Optional. Name of group. If supplied, limits check + * to just that group. + * The user's Roles.GLOBAL_GROUP will always be checked + * whether group is specified or not. + * @return {Boolean} true if user is in _any_ of the target roles + */ + function userIsInRole( + user : string|string[]|Object|Object[], + roles : string|string[], + group? : string + ) : boolean; + + interface Role { + name : string; + } +} // module + +declare module Meteor { + var roles : Mongo.Collection; +} From 3005019f55de22a17a8c547cd8c6a4746fe51b19 Mon Sep 17 00:00:00 2001 From: Robert Van Gorkom Date: Sat, 9 Jan 2016 09:00:50 -0800 Subject: [PATCH 33/40] Fixing declaration format. --- meteor-roles/meteor-roles.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meteor-roles/meteor-roles.d.ts b/meteor-roles/meteor-roles.d.ts index 95e4223ac..487300b82 100644 --- a/meteor-roles/meteor-roles.d.ts +++ b/meteor-roles/meteor-roles.d.ts @@ -1,10 +1,10 @@ -/// - // Type definitions for Meteor Roles 1.2.14 // Project: https://github.com/alanning/meteor-roles/ // Definitions by: Robbie Van Gorkom // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + /** * Provides functions related to user authorization. Compatible with built-in Meteor accounts packages. * From 005ff4b6d71cc7b474386446948b4f6b2f5f7d19 Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Sun, 10 Jan 2016 18:28:42 +0100 Subject: [PATCH 34/40] The definition was incomplete --- recursive-readdir/recursive-readdir.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/recursive-readdir/recursive-readdir.d.ts b/recursive-readdir/recursive-readdir.d.ts index b948fac87..4cd17c80b 100644 --- a/recursive-readdir/recursive-readdir.d.ts +++ b/recursive-readdir/recursive-readdir.d.ts @@ -3,13 +3,16 @@ // Definitions by: Elisée Maurer // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module "recursive-readdir" { +/// +declare module "recursive-readdir" { + import * as fs from "fs"; module RecursiveReaddir { interface readdir { (path: string, callback: (error: Error, files: string[]) => any): void; // ignorePattern supports glob syntax via https://github.com/isaacs/minimatch - (path: string, ignorePattern: string[], callback: (error: Error, files: string[]) => any): void; + (path: string, ignorePattern: (string | ((file: string, stats: fs.Stats) => void))[], callback: (error: Error, files: string[]) => any): void; + (path: string, ignoreFunction: (file: string, stats: fs.Stats) => void, callback: (error: Error, files: string[]) => any): void; } } From 2d4654128dd3304fffe0561e980d8b379d873528 Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Sun, 10 Jan 2016 22:40:14 -0800 Subject: [PATCH 35/40] Maker.js 0.6.8 added exporter options --- maker.js/makerjs-tests.ts | 16 ++++++++++++- maker.js/makerjs.d.ts | 50 ++++++++++++++++++++++++++++++++++----- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/maker.js/makerjs-tests.ts b/maker.js/makerjs-tests.ts index 4b6b5f80e..e314f0966 100644 --- a/maker.js/makerjs-tests.ts +++ b/maker.js/makerjs-tests.ts @@ -42,7 +42,19 @@ function test() { makerjs.exporter.toDXF(model); makerjs.exporter.toOpenJsCad(model); makerjs.exporter.toSTL(model); - makerjs.exporter.toSVG(model); + makerjs.exporter.toSVG(model, + { + annotate: true, + fontSize: '', + origin: [], + scale: 9.9, + stroke: '', + strokeWidth: '', + svgAttrs: {}, + units: '', + useSvgPathOnly: false, + viewBox: false + }); makerjs.exporter.tryGetModelUnits(model); } @@ -51,6 +63,7 @@ function test() { makerjs.kit.getParameterValues(null); ({}).max; ({}).metaParameters; + ({}).notes; } function testMeasure() { @@ -83,6 +96,7 @@ function test() { makerjs.model.rotate(makerjs.model.scale(model, 6), 45, [0,0]); makerjs.model.scale(model, 7); makerjs.model.walkPaths(model, (modelContext: MakerJs.IModel, pathId: string, pathContext: MakerJs.IPath) => {}); + model.exporterOptions = { foo: 'bar' }; } function testModels(): MakerJs.IModel[] { diff --git a/maker.js/makerjs.d.ts b/maker.js/makerjs.d.ts index cb217adb4..b45a1ceff 100644 --- a/maker.js/makerjs.d.ts +++ b/maker.js/makerjs.d.ts @@ -345,6 +345,12 @@ declare module MakerJs { * Optional layer of this model. */ layer?: string; + /** + * Optional exporter options for this model. + */ + exporterOptions?: { + [exporterName: string]: any; + }; } /** * Callback signature for model.walkPaths(). @@ -412,6 +418,10 @@ declare module MakerJs { * Each element of the array corresponds to a parameter of the constructor, in order. */ metaParameters?: IMetaParameter[]; + /** + * Information about this kit, in plain text or markdown format. + */ + notes?: string; } } declare module MakerJs.angle { @@ -1225,12 +1235,36 @@ declare module MakerJs.exporter { * Optional size of curve facets. */ facetSize?: number; + /** + * Optional override of function name, default is "main". + */ + functionName?: string; + /** + * Optional options applied to specific first-child models by model id. + */ + modelMap?: IOpenJsCadOptionsMap; + } + interface IOpenJsCadOptionsMap { + [modelId: string]: IOpenJsCadOptions; } } declare module MakerJs.exporter { function toSVG(modelToExport: IModel, options?: ISVGRenderOptions): string; function toSVG(pathsToExport: IPath[], options?: ISVGRenderOptions): string; function toSVG(pathToExport: IPath, options?: ISVGRenderOptions): string; + /** + * Map of MakerJs unit system to SVG unit system + */ + interface svgUnitConversion { + [unitType: string]: { + svgUnitType: string; + scaleConversion: number; + }; + } + /** + * Map of MakerJs unit system to SVG unit system + */ + var svgUnit: svgUnitConversion; /** * SVG rendering options. */ @@ -1239,6 +1273,10 @@ declare module MakerJs.exporter { * Optional attributes to add to the root svg tag. */ svgAttrs?: IXmlTagAttrs; + /** + * SVG font size and font size units. + */ + fontSize?: string; /** * SVG stroke width of paths. This may have a unit type suffix, if not, the value will be in the same unit system as the units property. */ @@ -1246,27 +1284,27 @@ declare module MakerJs.exporter { /** * SVG color of the rendered paths. */ - stroke: string; + stroke?: string; /** * Scale of the SVG rendering. */ - scale: number; + scale?: number; /** * Indicate that the id's of paths should be rendered as SVG text elements. */ - annotate: boolean; + annotate?: boolean; /** * Rendered reference origin. */ - origin: IPoint; + origin?: IPoint; /** * Use SVG < path > elements instead of < line >, < circle > etc. */ - useSvgPathOnly: boolean; + useSvgPathOnly?: boolean; /** * Flag to use SVG viewbox. */ - viewBox: boolean; + viewBox?: boolean; } } declare module MakerJs.models { From b3109b5c64dc07a42fa00e191ba8a87e009a04b5 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Mon, 11 Jan 2016 09:09:46 +0100 Subject: [PATCH 36/40] Naming convention fixed --- prettyjson/prettyjson-tests.ts | 2 +- prettyjson/prettyjson.d.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/prettyjson/prettyjson-tests.ts b/prettyjson/prettyjson-tests.ts index 9d7c43918..80ecbbb0f 100644 --- a/prettyjson/prettyjson-tests.ts +++ b/prettyjson/prettyjson-tests.ts @@ -1,6 +1,6 @@ /// -var options: prettyjson.IOptions, +var options: prettyjson.RendererOptions, input: string, output: string, version: string; diff --git a/prettyjson/prettyjson.d.ts b/prettyjson/prettyjson.d.ts index b2a6399ac..cf2a69c19 100644 --- a/prettyjson/prettyjson.d.ts +++ b/prettyjson/prettyjson.d.ts @@ -20,7 +20,7 @@ declare module prettyjson { * * @return {string} pretty serialized json data ready to display. */ - export function render(data: any, options?: IOptions, indentation?: number): string; + export function render(data: any, options?: RendererOptions, indentation?: number): string; /** * Render pretty json from a string. @@ -31,9 +31,9 @@ declare module prettyjson { * * @return {string} pretty serialized json data ready to display. */ - export function renderString(data: string, options?: IOptions, indentation?: number): string; + export function renderString(data: string, options?: RendererOptions, indentation?: number): string; - export interface IOptions { + export interface RendererOptions { /** * Define behavior for Array objects From 99a4e27e9b376ad0636a5b8430076ce460f55ba3 Mon Sep 17 00:00:00 2001 From: Niko Kovacic Date: Mon, 11 Jan 2016 13:27:33 +0100 Subject: [PATCH 37/40] FieldGroup property in IFieldGroup should be optional. --- angular-formly/angular-formly.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index 8c07ea800..f42b35a89 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -24,7 +24,7 @@ declare module AngularFormly { data?: Object; className?: string; elementAttributes?: string; - fieldGroup: IFieldArray; + fieldGroup?: IFieldArray; form?: Object; hide?: boolean; hideExpression?: string | IExpressionFunction; From 8acb8a3f7bfef5469cae1c249beb9c44259e1d3d Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Mon, 11 Jan 2016 13:53:15 +0000 Subject: [PATCH 38/40] Fix return type of Entry.{moveTo,copyTo} in filesystem.d.ts --- filesystem/filesystem.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filesystem/filesystem.d.ts b/filesystem/filesystem.d.ts index 1b76846b4..d99105f0b 100644 --- a/filesystem/filesystem.d.ts +++ b/filesystem/filesystem.d.ts @@ -161,7 +161,7 @@ interface Entry { * A move of a file on top of an existing file must attempt to delete and replace that file. * A move of a directory on top of an existing empty directory must attempt to delete and replace that directory. */ - moveTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):string; + moveTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void; /** * Copy an entry to a different location on the file system. It is an error to try to: @@ -178,7 +178,7 @@ interface Entry { * * Directory copies are always recursive--that is, they copy all contents of the directory. */ - copyTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):string; + copyTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void; /** * Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists. From 39e510415cb398c5b982f68adec1a82f84bebadd Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 12 Jan 2016 01:10:13 +0500 Subject: [PATCH 39/40] node: definition of the module "crypto" has been changed --- node/node-tests.ts | 7 +++++++ node/node.d.ts | 14 +++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index d3a76a983..9aebe5c53 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -203,6 +203,13 @@ function stream_readable_pipe_test() { var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex'); +{ + let hmac: crypto.Hmac; + (hmac = crypto.createHmac('md5', 'hello')).end('world', 'utf8', () => { + let hash: Buffer|string = hmac.read(); + }); +} + function crypto_cipher_decipher_string_test() { var key:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]); var clearText:string = "This is the clear text."; diff --git a/node/node.d.ts b/node/node.d.ts index 6c4fbfa47..a7f1a1617 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1681,13 +1681,13 @@ declare module "crypto" { export function createHash(algorithm: string): Hash; export function createHmac(algorithm: string, key: string): Hmac; export function createHmac(algorithm: string, key: Buffer): Hmac; - interface Hash { + export interface Hash { update(data: any, input_encoding?: string): Hash; digest(encoding: 'buffer'): Buffer; digest(encoding: string): any; digest(): Buffer; } - interface Hmac { + export interface Hmac extends NodeJS.ReadWriteStream { update(data: any, input_encoding?: string): Hmac; digest(encoding: 'buffer'): Buffer; digest(encoding: string): any; @@ -1695,7 +1695,7 @@ declare module "crypto" { } export function createCipher(algorithm: string, password: any): Cipher; export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; - interface Cipher { + export interface Cipher { update(data: Buffer): Buffer; update(data: string, input_encoding?: string, output_encoding?: string): string; final(): Buffer; @@ -1704,7 +1704,7 @@ declare module "crypto" { } export function createDecipher(algorithm: string, password: any): Decipher; export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; - interface Decipher { + export interface Decipher { update(data: Buffer): Buffer; update(data: string, input_encoding?: string, output_encoding?: string): string; final(): Buffer; @@ -1712,18 +1712,18 @@ declare module "crypto" { setAutoPadding(auto_padding: boolean): void; } export function createSign(algorithm: string): Signer; - interface Signer extends NodeJS.WritableStream { + export interface Signer extends NodeJS.WritableStream { update(data: any): void; sign(private_key: string, output_format: string): string; } export function createVerify(algorith: string): Verify; - interface Verify extends NodeJS.WritableStream { + export interface Verify extends NodeJS.WritableStream { update(data: any): void; verify(object: string, signature: string, signature_format?: string): boolean; } export function createDiffieHellman(prime_length: number): DiffieHellman; export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; - interface DiffieHellman { + export interface DiffieHellman { generateKeys(encoding?: string): string; computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; getPrime(encoding?: string): string; From ceedbb35506c4b20867ddb495e8626ea04f38969 Mon Sep 17 00:00:00 2001 From: Max Shmelev Date: Mon, 11 Jan 2016 18:34:47 -0500 Subject: [PATCH 40/40] Support TypeScript 1.7 modules This fix allows to import modules in TypesScript 1.7 using `import` keyword, like: import * as sinonChai from 'sinon-chai'; The current version gives compilation error: "Module sinon-chai resolves to a non-module entity" --- sinon-chai/sinon-chai.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/sinon-chai/sinon-chai.d.ts b/sinon-chai/sinon-chai.d.ts index 03bd0e81d..1695b1e54 100644 --- a/sinon-chai/sinon-chai.d.ts +++ b/sinon-chai/sinon-chai.d.ts @@ -80,5 +80,6 @@ declare module Chai { declare module "sinon-chai" { function sinonChai(chai: any, utils: any): void; + namespace sinonChai { } export = sinonChai; }