Merge branch 'master' into switch-0.9.5

Conflicts:
	chartjs/dx.chartjs.d.ts
	phonejs/dx.phonejs.d.ts
This commit is contained in:
Masahiro Wakame
2013-12-13 14:44:10 +09:00
17 changed files with 1416 additions and 320 deletions
+2 -2
View File
@@ -19,8 +19,8 @@ declare module ng.ui {
params?: any[];
views?: {};
abstract?: boolean;
onEnter?: Function;
onExit?: Function;
onEnter?: any;
onExit?: any;
data?: any;
}
+2 -2
View File
@@ -10,7 +10,7 @@
declare module Backbone {
interface AddOptions extends Silenceable {
at: number;
at?: number;
}
interface HistoryOptions extends Silenceable {
@@ -19,7 +19,7 @@ declare module Backbone {
}
interface NavigateOptions {
trigger: boolean;
trigger?: boolean;
}
interface RouterOptions {
-1
View File
@@ -1 +0,0 @@
""
+15 -18
View File
@@ -208,7 +208,7 @@ declare module DevExpress.data {
}
export interface StoreOptions {
key?: any;
errorHandler: ErrorHandler;
errorHandler?: ErrorHandler;
loaded?: JQueryCallback;
loading?: JQueryCallback;
modified?: JQueryCallback;
@@ -294,14 +294,6 @@ declare module DevExpress.data {
export class ODataStore extends Store {
constructor(options?: ODataStoreOptions);
}
interface IODataContextBase {
get(operationName: string, params: { [key: string]: any }): JQueryDeferred<Array<any>>;
invoke(operationName: string, params: { [key: string]: any }, httpMethod?: string): JQueryDeferred<Array<any>>;
objectLink(entityAlias: string, key: any): { __metadata: { uri: string }; }
}
interface IODataContext extends IODataContextBase {
[entitySetName: string]: any;
}
export interface ODataContextOptions {
url: string;
jsonp?: boolean;
@@ -310,11 +302,11 @@ declare module DevExpress.data {
beforeSend?: () => any;
entities?: Array<any>;
}
export class ODataContext implements IODataContextBase {
export class ODataContext {
constructor(options?: ODataContextOptions);
get(operationName: string, params: { [key: string]: any }): JQueryDeferred<Array<any>>;
invoke(operationName: string, params: { [key: string]: any }, httpMethod?: string): JQueryDeferred<Array<any>>;
objectLink(entityAlias: string, key: any): { __metadata: { uri: string }; }
objectLink(entityAlias: string, key: any): { __metadata: { uri: string }; };
}
}
declare module DevExpress.ui {
@@ -1030,7 +1022,12 @@ declare module DevExpress.viz.charts.series {
hoverStyle?: AreaSeriesStyle;
point?: BasePointOptions;
}
// export interface RangeBarSeriesOptions extends z_BaseRangeSeriesOptions, z_BaseBarSeriesOptions { }
export interface RangeBarSeriesOptions extends z_BaseBarSeriesOptions {
rangeValue1Field?: string;
rangeValue2Field?: string;
pane?: string;
axis?: string;
}
export interface SplineSeriesOptions extends LineSeriesOptions { }
export interface SplineAreaSeries extends AreaSeriesOptions { }
export interface StackedLineSeries extends LineSeriesOptions { }
@@ -1094,7 +1091,7 @@ declare module DevExpress.viz.charts.series {
fullstackedline?: FullStackedLineSeriesOptions;
line?: LineSeriesOptions;
rangearea?: RangeAreaSeriesOptions;
rangebar?: any; // RangeBarSeriesOptions
rangebar?: RangeBarSeriesOptions;
scatter?: ScatterSeriesOptions;
spline?: SplineSeriesOptions;
splinearea?: SplineAreaSeries;
@@ -1373,8 +1370,8 @@ declare module DevExpress.viz.map {
borderColor?: string;
color?: string;
};
dataSource?: any;
area?: {
mapData?: any;
areaSettings?: {
borderColor?: string;
color?: string;
hoveredBorderColor?: string;
@@ -1389,8 +1386,8 @@ declare module DevExpress.viz.map {
click?: (arg: Proxy) => void;
selectionChanged?: (arg: Proxy) => void;
};
markerDataSource?: any;
marker?: {
markers?: any;
markerSettings?: {
borderColor?: string;
color?: string;
hoveredBorderColor?: string;
@@ -1448,7 +1445,7 @@ declare module DevExpress.viz.map {
}
export class Proxy {
type: string;
attr(name: string): any;
attribute(name: string): any;
selected(state: boolean): void;
selected(): boolean;
}
+88 -88
View File
@@ -10,77 +10,77 @@ declare module CodeMirror {
/** If you want to define extra methods in terms of the CodeMirror API, it is possible to use defineExtension.
This will cause the given value(usually a method) to be added to all CodeMirror instances created from then on. */
function defineExtension(name: string, value: any);
function defineExtension(name: string, value: any): void;
/** Like defineExtension, but the method will be added to the interface for Doc objects instead. */
function defineDocExtension(name: string, value: any);
function defineDocExtension(name: string, value: any): void;
/** Similarly, defineOption can be used to define new options for CodeMirror.
The updateFunc will be called with the editor instance and the new value when an editor is initialized,
and whenever the option is modified through setOption. */
function defineOption(name: string, default_: any, updateFunc: Function);
function defineOption(name: string, default_: any, updateFunc: Function): void;
/** If your extention just needs to run some code whenever a CodeMirror instance is initialized, use CodeMirror.defineInitHook.
Give it a function as its only argument, and from then on, that function will be called (with the instance as argument)
whenever a new CodeMirror instance is initialized. */
function defineInitHook(func: Function);
function defineInitHook(func: Function): void;
function on(element: any, eventName: string, handler: Function);
function off(element: any, eventName: string, handler: Function);
function on(element: any, eventName: string, handler: Function): void;
function off(element: any, eventName: string, handler: Function): void;
/** Fired whenever a change occurs to the document. changeObj has a similar type as the object passed to the editor's "change" event,
but it never has a next property, because document change events are not batched (whereas editor change events are). */
function on(doc: Doc, eventName: 'change', handler: (instance: Doc, change: EditorChange) => void );
function off(doc: Doc, eventName: 'change', handler: (instance: Doc, change: EditorChange) => void );
function on(doc: Doc, eventName: 'change', handler: (instance: Doc, change: EditorChange) => void ): void;
function off(doc: Doc, eventName: 'change', handler: (instance: Doc, change: EditorChange) => void ): void;
/** See the description of the same event on editor instances. */
function on(doc: Doc, eventName: 'beforeChange', handler: (instance: Doc, change: EditorChangeCancellable) => void );
function off(doc: Doc, eventName: 'beforeChange', handler: (instance: Doc, change: EditorChangeCancellable) => void );
function on(doc: Doc, eventName: 'beforeChange', handler: (instance: Doc, change: EditorChangeCancellable) => void ): void;
function off(doc: Doc, eventName: 'beforeChange', handler: (instance: Doc, change: EditorChangeCancellable) => void ): void;
/** Fired whenever the cursor or selection in this document changes. */
function on(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void );
function off(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void );
function on(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ): void;
function off(doc: Doc, eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ): void;
/** Equivalent to the event by the same name as fired on editor instances. */
function on(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: Position; anchor: Position; }) => void );
function off(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: Position; anchor: Position; }) => void );
function on(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: Position; anchor: Position; }) => void ): void;
function off(doc: Doc, eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: Position; anchor: Position; }) => void ): void;
/** Will be fired when the line object is deleted. A line object is associated with the start of the line.
Mostly useful when you need to find out when your gutter markers on a given line are removed. */
function on(line: LineHandle, eventName: 'delete', handler: () => void );
function off(line: LineHandle, eventName: 'delete', handler: () => void );
function on(line: LineHandle, eventName: 'delete', handler: () => void ): void;
function off(line: LineHandle, eventName: 'delete', handler: () => void ): void;
/** Fires when the line's text content is changed in any way (but the line is not deleted outright).
The change object is similar to the one passed to change event on the editor object. */
function on(line: LineHandle, eventName: 'change', handler: (line: LineHandle, change: EditorChange) => void );
function off(line: LineHandle, eventName: 'change', handler: (line: LineHandle, change: EditorChange) => void );
function on(line: LineHandle, eventName: 'change', handler: (line: LineHandle, change: EditorChange) => void ): void;
function off(line: LineHandle, eventName: 'change', handler: (line: LineHandle, change: EditorChange) => void ): void;
/** Fired when the cursor enters the marked range. From this event handler, the editor state may be inspected but not modified,
with the exception that the range on which the event fires may be cleared. */
function on(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void );
function off(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void );
function on(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void ): void;
function off(marker: TextMarker, eventName: 'beforeCursorEnter', handler: () => void ): void;
/** Fired when the range is cleared, either through cursor movement in combination with clearOnEnter or through a call to its clear() method.
Will only be fired once per handle. Note that deleting the range through text editing does not fire this event,
because an undo action might bring the range back into existence. */
function on(marker: TextMarker, eventName: 'clear', handler: () => void );
function off(marker: TextMarker, eventName: 'clear', handler: () => void );
function on(marker: TextMarker, eventName: 'clear', handler: () => void ): void;
function off(marker: TextMarker, eventName: 'clear', handler: () => void ): void;
/** Fired when the last part of the marker is removed from the document by editing operations. */
function on(marker: TextMarker, eventName: 'hide', handler: () => void );
function off(marker: TextMarker, eventName: 'hide', handler: () => void );
function on(marker: TextMarker, eventName: 'hide', handler: () => void ): void;
function off(marker: TextMarker, eventName: 'hide', handler: () => void ): void;
/** Fired when, after the marker was removed by editing, a undo operation brought the marker back. */
function on(marker: TextMarker, eventName: 'unhide', handler: () => void );
function off(marker: TextMarker, eventName: 'unhide', handler: () => void );
function on(marker: TextMarker, eventName: 'unhide', handler: () => void ): void;
function off(marker: TextMarker, eventName: 'unhide', handler: () => void ): void;
/** Fired whenever the editor re-adds the widget to the DOM. This will happen once right after the widget is added (if it is scrolled into view),
and then again whenever it is scrolled out of view and back in again, or when changes to the editor options
or the line the widget is on require the widget to be redrawn. */
function on(line: LineWidget, eventName: 'redraw', handler: () => void );
function off(line: LineWidget, eventName: 'redraw', handler: () => void );
function on(line: LineWidget, eventName: 'redraw', handler: () => void ): void;
function off(line: LineWidget, eventName: 'redraw', handler: () => void ): void;
interface Editor {
@@ -100,7 +100,7 @@ declare module CodeMirror {
/** Change the configuration of the editor. option should the name of an option, and value should be a valid value for that option. */
setOption(option: string, value: any);
setOption(option: string, value: any): void;
/** Retrieves the current value of the given option for this editor instance. */
getOption(option: string): any;
@@ -110,21 +110,21 @@ declare module CodeMirror {
Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them,
the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed,
in which case they end up below other keymaps added with this method. */
addKeyMap(map: any, bottom?: boolean);
addKeyMap(map: any, bottom?: boolean): void;
/** Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string,
which will be compared against the name property of the active keymaps. */
removeKeyMap(map: any);
removeKeyMap(map: any): void;
/** Enable a highlighting overlay.This is a stateless mini - mode that can be used to add extra highlighting.
For example, the search add - on uses it to highlight the term that's currently being searched.
mode can be a mode spec or a mode object (an object with a token method). The options parameter is optional. If given, it should be an object.
Currently, only the opaque option is recognized. This defaults to off, but can be given to allow the overlay styling, when not null,
to override the styling of the base mode entirely, instead of the two being applied together. */
addOverlay(mode: any, options?: any);
addOverlay(mode: any, options?: any): void;
/** Pass this the exact argument passed for the mode parameter to addOverlay to remove an overlay again. */
removeOverlay(mode: any);
removeOverlay(mode: any): void;
/** Retrieve the currently active document from an editor. */
@@ -140,7 +140,7 @@ declare module CodeMirror {
setGutterMarker(line: any, gutterID: string, value: HTMLElement): CodeMirror.LineHandle;
/** Remove all gutter markers in the gutter with the given ID. */
clearGutter(gutterID: string);
clearGutter(gutterID: string): void;
/** Set a CSS class name for the given line.line can be a number or a line handle.
where determines to which element this class should be applied, can can be one of "text" (the text element, which lies in front of the selection),
@@ -171,7 +171,7 @@ declare module CodeMirror {
/** Puts node, which should be an absolutely positioned DOM node, into the editor, positioned right below the given { line , ch } position.
When scrollIntoView is true, the editor will ensure that the entire node is visible (if possible).
To remove the widget again, simply use DOM methods (move it somewhere else, or call removeChild on its parent). */
addWidget(pos: CodeMirror.Position, node: HTMLElement, scrollIntoView: boolean);
addWidget(pos: CodeMirror.Position, node: HTMLElement, scrollIntoView: boolean): void;
/** Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards.
line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line.
@@ -192,10 +192,10 @@ declare module CodeMirror {
/** Programatically set the size of the editor (overriding the applicable CSS rules).
width and height height can be either numbers(interpreted as pixels) or CSS units ("100%", for example).
You can pass null for either of them to indicate that that dimension should not be changed. */
setSize(width: any, height: any);
setSize(width: any, height: any): void;
/** Scroll the editor to a given(pixel) position.Both arguments may be left as null or undefined to have no effect. */
scrollTo(x: number, y: number);
scrollTo(x: number, y: number): void;
/** Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area,
and the size of the visible area(minus scrollbars). */
@@ -210,11 +210,11 @@ declare module CodeMirror {
/** Scrolls the given element into view. pos is a { line , ch } position, referring to a given character, null, to refer to the cursor.
The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
scrollIntoView(pos: CodeMirror.Position, margin?: number);
scrollIntoView(pos: CodeMirror.Position, margin?: number): void;
/** Scrolls the given element into view. pos is a { left , top , right , bottom } object, in editor-local coordinates.
The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
scrollIntoView(pos: { left: number; top: number; right: number; bottom: number; }, margin: number);
scrollIntoView(pos: { left: number; top: number; right: number; bottom: number; }, margin: number): void;
/** Returns an { left , top , bottom } object containing the coordinates of the cursor position.
If mode is "local" , they will be relative to the top-left corner of the editable document.
@@ -251,7 +251,7 @@ declare module CodeMirror {
/** If your code does something to change the size of the editor element (window resizes are already listened for), or unhides it,
you should probably follow up by calling this method to ensure CodeMirror is still looking as intended. */
refresh();
refresh(): void;
/** Retrieves information about the token the current mode found before the given position (a {line, ch} object). */
@@ -285,11 +285,11 @@ declare module CodeMirror {
"smart" Use the mode's smart indentation if available, behave like "prev" otherwise.
"add" Increase the indentation of the line by one indent unit.
"subtract" Reduce the indentation of the line. */
indentLine(line: number, dir?: string);
indentLine(line: number, dir?: string): void;
/** Give the editor focus. */
focus();
focus(): void;
/** Returns the hidden textarea used to read input. */
getInputField(): HTMLTextAreaElement;
@@ -308,61 +308,61 @@ declare module CodeMirror {
/** Events are registered with the on method (and removed with the off method).
These are the events that fire on the instance object. The name of the event is followed by the arguments that will be passed to the handler.
The instance argument always refers to the editor instance. */
on(eventName: string, handler: (instance: CodeMirror.Editor) => void );
off(eventName: string, handler: (instance: CodeMirror.Editor) => void );
on(eventName: string, handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: string, handler: (instance: CodeMirror.Editor) => void ): void;
/** Fires every time the content of the editor is changed. */
on(eventName: 'change', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList) => void );
off(eventName: 'change', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList) => void );
on(eventName: 'change', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList) => void ): void;
off(eventName: 'change', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeLinkedList) => void ): void;
/** This event is fired before a change is applied, and its handler may choose to modify or cancel the change.
The changeObj never has a next property, since this is fired for each individual change, and not batched per operation.
Note: you may not do anything from a "beforeChange" handler that would cause changes to the document or its visualization.
Doing so will, since this handler is called directly from the bowels of the CodeMirror implementation,
probably cause the editor to become corrupted. */
on(eventName: 'beforeChange', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => void );
off(eventName: 'beforeChange', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => void );
on(eventName: 'beforeChange', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => void ): void;
off(eventName: 'beforeChange', handler: (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => void ): void;
/** Will be fired when the cursor or selection moves, or any change is made to the editor content. */
on(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void );
off(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void );
on(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'cursorActivity', handler: (instance: CodeMirror.Editor) => void ): void;
/** This event is fired before the selection is moved. Its handler may modify the resulting selection head and anchor.
Handlers for this event have the same restriction as "beforeChange" handlers they should not do anything to directly update the state of the editor. */
on(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: CodeMirror.Position; anchor: CodeMirror.Position; }) => void );
off(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: CodeMirror.Position; anchor: CodeMirror.Position; }) => void );
on(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: CodeMirror.Position; anchor: CodeMirror.Position; }) => void ): void;
off(eventName: 'beforeSelectionChange', handler: (instance: CodeMirror.Editor, selection: { head: CodeMirror.Position; anchor: CodeMirror.Position; }) => void ): void;
/** Fires whenever the view port of the editor changes (due to scrolling, editing, or any other factor).
The from and to arguments give the new start and end of the viewport. */
on(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void );
off(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void );
on(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void ): void;
off(eventName: 'viewportChange', handler: (instance: CodeMirror.Editor, from: number, to: number) => void ): void;
/** Fires when the editor gutter (the line-number area) is clicked. Will pass the editor instance as first argument,
the (zero-based) number of the line that was clicked as second argument, the CSS class of the gutter that was clicked as third argument,
and the raw mousedown event object as fourth argument. */
on(eventName: 'gutterClick', handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: Event) => void );
off(eventName: 'gutterClick', handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: Event) => void );
on(eventName: 'gutterClick', handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: Event) => void ): void;
off(eventName: 'gutterClick', handler: (instance: CodeMirror.Editor, line: number, gutter: string, clickEvent: Event) => void ): void;
/** Fires whenever the editor is focused. */
on(eventName: 'focus', handler: (instance: CodeMirror.Editor) => void );
off(eventName: 'focus', handler: (instance: CodeMirror.Editor) => void );
on(eventName: 'focus', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'focus', handler: (instance: CodeMirror.Editor) => void ): void;
/** Fires whenever the editor is unfocused. */
on(eventName: 'blur', handler: (instance: CodeMirror.Editor) => void );
off(eventName: 'blur', handler: (instance: CodeMirror.Editor) => void );
on(eventName: 'blur', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'blur', handler: (instance: CodeMirror.Editor) => void ): void;
/** Fires when the editor is scrolled. */
on(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void );
off(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void );
on(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'scroll', handler: (instance: CodeMirror.Editor) => void ): void;
/** Will be fired whenever CodeMirror updates its DOM display. */
on(eventName: 'update', handler: (instance: CodeMirror.Editor) => void );
off(eventName: 'update', handler: (instance: CodeMirror.Editor) => void );
on(eventName: 'update', handler: (instance: CodeMirror.Editor) => void ): void;
off(eventName: 'update', handler: (instance: CodeMirror.Editor) => void ): void;
/** Fired whenever a line is (re-)rendered to the DOM. Fired right after the DOM element is built, before it is added to the document.
The handler may mess with the style of the resulting element, or add event handlers, but should not try to change the state of the editor. */
on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void );
off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void );
on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ): void;
off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ): void;
}
class Doc {
@@ -372,7 +372,7 @@ declare module CodeMirror {
getValue(seperator?: string): string;
/** Set the editor content. */
setValue(content: string);
setValue(content: string): void;
/** Get the text between the given points in the editor, which should be {line, ch} objects.
An optional third argument can be given to indicate the line separator string to use (defaults to "\n"). */
@@ -380,16 +380,16 @@ declare module CodeMirror {
/** Replace the part of the document between from and to with the given string.
from and to must be {line, ch} objects. to can be left off to simply insert the string at position from. */
replaceRange(replacement: string, from: CodeMirror.Position, to: CodeMirror.Position);
replaceRange(replacement: string, from: CodeMirror.Position, to: CodeMirror.Position): void;
/** Get the content of line n. */
getLine(n: number): string;
/** Set the content of line n. */
setLine(n: number, text: string);
setLine(n: number, text: string): void;
/** Remove the given line from the document. */
removeLine(n: number);
removeLine(n: number): void;
/** Get the number of lines in the editor. */
lineCount(): number;
@@ -410,16 +410,16 @@ declare module CodeMirror {
/** Iterate over the whole document, and call f for each line, passing the line handle.
This is a faster way to visit a range of line handlers than calling getLineHandle for each of them.
Note that line handles have a text property containing the line's content (as a string). */
eachLine(f: (line: CodeMirror.LineHandle) => void );
eachLine(f: (line: CodeMirror.LineHandle) => void ): void;
/** Iterate over the range from start up to (not including) end, and call f for each line, passing the line handle.
This is a faster way to visit a range of line handlers than calling getLineHandle for each of them.
Note that line handles have a text property containing the line's content (as a string). */
eachLine(start: number, end: number, f: (line: CodeMirror.LineHandle) => void );
eachLine(start: number, end: number, f: (line: CodeMirror.LineHandle) => void ): void;
/** Set the editor content as 'clean', a flag that it will retain until it is edited, and which will be set again when such an edit is undone again.
Useful to track whether the content needs to be saved. */
markClean();
markClean(): void;
/** Returns whether the document is currently clean (not modified since initialization or the last call to markClean). */
isClean(): boolean;
@@ -431,7 +431,7 @@ declare module CodeMirror {
/** Replace the selection with the given string. By default, the new selection will span the inserted text.
The optional collapse argument can be used to change this passing "start" or "end" will collapse the selection to the start or end of the inserted text. */
replaceSelection(replacement: string, collapse?: string)
replaceSelection(replacement: string, collapse?: string): void;
/** start is a an optional string indicating which end of the selection to return.
It may be "start" , "end" , "head"(the side of the selection that moves when you press shift + arrow),
@@ -442,20 +442,20 @@ declare module CodeMirror {
somethingSelected(): boolean;
/** Set the cursor position.You can either pass a single { line , ch } object , or the line and the character as two separate parameters. */
setCursor(pos: CodeMirror.Position);
setCursor(pos: CodeMirror.Position): void;
/** Set the selection range.anchor and head should be { line , ch } objects.head defaults to anchor when not given. */
setSelection(anchor: CodeMirror.Position, head: CodeMirror.Position);
setSelection(anchor: CodeMirror.Position, head: CodeMirror.Position): void;
/** Similar to setSelection , but will, if shift is held or the extending flag is set,
move the head of the selection while leaving the anchor at its current place.
pos2 is optional , and can be passed to ensure a region (for example a word or paragraph) will end up selected
(in addition to whatever lies between that region and the current anchor). */
extendSelection(from: CodeMirror.Position, to?: CodeMirror.Position);
extendSelection(from: CodeMirror.Position, to?: CodeMirror.Position): void;
/** Sets or clears the 'extending' flag , which acts similar to the shift key,
in that it will cause cursor movement and calls to extendSelection to leave the selection anchor in place. */
setExtending(value: boolean);
setExtending(value: boolean): void;
/** Retrieve the editor associated with a document. May return null. */
@@ -481,30 +481,30 @@ declare module CodeMirror {
/** Break the link between two documents. After calling this , changes will no longer propagate between the documents,
and, if they had a shared history, the history will become separate. */
unlinkDoc(doc: CodeMirror.Doc);
unlinkDoc(doc: CodeMirror.Doc): void;
/** Will call the given function for all documents linked to the target document. It will be passed two arguments,
the linked document and a boolean indicating whether that document shares history with the target. */
iterLinkedDocs(fn: (doc: CodeMirror.Doc, sharedHist: boolean) => void );
iterLinkedDocs(fn: (doc: CodeMirror.Doc, sharedHist: boolean) => void ): void;
/** Undo one edit (if any undo events are stored). */
undo();
undo(): void;
/** Redo one undone edit. */
redo();
redo(): void;
/** Returns an object with {undo, redo } properties , both of which hold integers , indicating the amount of stored undo and redo operations. */
historySize(): { undo: number; redo: number; };
/** Clears the editor's undo history. */
clearHistory();
clearHistory(): void;
/** Get a(JSON - serializeable) representation of the undo history. */
getHistory(): any;
/** Replace the editor's undo history with the one provided, which must be a value as returned by getHistory.
Note that this will have entirely undefined results if the editor content isn't also the same as it was when getHistory was called. */
setHistory(history: any);
setHistory(history: any): void;
/** Can be used to mark a range of text with a specific CSS class name. from and to should be { line , ch } objects. */
@@ -548,7 +548,7 @@ declare module CodeMirror {
interface TextMarker {
/** Remove the mark. */
clear();
clear(): void;
/** Returns a {from, to} object (both holding document positions), indicating the current position of the marked range,
or undefined if the marker is no longer in the document. */
@@ -564,7 +564,7 @@ declare module CodeMirror {
/** Call this if you made some change to the widget's DOM node that might affect its height.
It'll force CodeMirror to update the height of the line that contains the widget. */
changed();
changed(): void;
}
interface EditorChange {
@@ -585,9 +585,9 @@ declare module CodeMirror {
interface EditorChangeCancellable extends CodeMirror.EditorChange {
/** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. */
update(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string);
update(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string): void;
cancel();
cancel(): void;
}
interface Position {
+131 -132
View File
@@ -20,7 +20,7 @@ app.use(express.session());
// Session-persisted message middleware
app.use(function (req, res, next) {
app.use((req: express.Request, res: express.Response, next) => {
var err = req.session.error
, msg = req.session.success;
delete req.session.error;
@@ -40,7 +40,7 @@ var users = <any>{
// when you create a user, generate a salt
// and hash the password ('foobar' is the pass here)
hash('foobar', function (err, salt, hash) {
hash('foobar', (err, salt, hash) => {
if (err) throw err;
// store the salt & hash in the "db"
users.tj.salt = salt;
@@ -58,11 +58,11 @@ function authenticate(name, pass, fn) {
// apply the same algorithm to the POSTed password, applying
// the hash against the pass / salt, if there is a match we
// found the user
hash(pass, user.salt, function (err, hash) {
hash(pass, user.salt, (err, hash) => {
if (err) return fn(err);
if (hash == user.hash) return fn(null, user);
fn(new Error('invalid password'));
})
});
}
function restrict(req: express.Request, res: express.Response, next?: Function) {
@@ -74,32 +74,32 @@ function restrict(req: express.Request, res: express.Response, next?: Function)
}
}
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.redirect('login');
});
app.get('/restricted', restrict, function (req, res) {
app.get('/restricted', restrict, (req: express.Request, res: express.Response) => {
res.send('Wahoo! restricted area, click to <a href="/logout">logout</a>');
});
app.get('/logout', function (req, res) {
app.get('/logout', (req: express.Request, res: express.Response) => {
// destroy the user's session to log them out
// will be re-created next request
req.session.destroy(function () {
req.session.destroy(() => {
res.redirect('/');
});
});
app.get('/login', function (req, res) {
app.get('/login', (req: express.Request, res: express.Response) => {
res.render('login');
});
app.post('/login', function (req, res) {
authenticate(req.body.username, req.body.password, function (err, user) {
app.post('/login', (req: express.Request, res: express.Response) => {
authenticate(req.body.username, req.body.password, (err, user) => {
if (user) {
// Regenerate session when signing in
// to prevent fixation
req.session.regenerate(function () {
req.session.regenerate(() => {
// Store the user's primary key
// in the session store to be retrieved,
// or in this case the entire user object
@@ -139,7 +139,7 @@ while (n--) {
app.use(express.logger('dev'));
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.render('pets', { pets: pets });
});
@@ -148,24 +148,24 @@ console.log('Express listening on port 3000');
/////////////
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.format({
html: function () {
res.send('<ul>' + users.map(function (user) {
html: () => {
res.send('<ul>' + users.map(user => {
return '<li>' + user.name + '</li>';
}).join('') + '</ul>');
},
text: function () {
res.send(users.map(function (user) {
text: () => {
res.send(users.map(user => {
return ' - ' + user.name + '\n';
}).join(''));
},
json: function () {
json: () => {
res.json(users);
}
})
});
});
// or you could write a tiny middleware like
@@ -173,9 +173,9 @@ app.get('/', function (req, res) {
function format(mod) {
var obj = require(mod);
return function (req, res) {
return (req: express.Request, res: express.Response) => {
res.format(obj);
}
};
}
app.get('/users', format('./users'));
@@ -207,7 +207,7 @@ app.use(express.cookieParser('my secret here'));
// parses json, x-www-form-urlencoded, and multipart/form-data
app.use(express.bodyParser());
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
if (req.cookies.remember) {
res.send('Remembered :). Click to <a href="/forget">forget</a>!.');
} else {
@@ -217,12 +217,12 @@ app.get('/', function (req, res) {
}
});
app.get('/forget', function (req, res) {
app.get('/forget', (req: express.Request, res: express.Response) => {
res.clearCookie('remember');
res.redirect('back');
});
app.post('/', function (req, res) {
app.post('/', (req: express.Request, res: express.Response) => {
var minute = 60000;
if (req.body.remember) res.cookie('remember', 1, { maxAge: minute });
res.redirect('back');
@@ -248,7 +248,7 @@ app.use(express.cookieSession());
app.use(count);
// custom middleware
function count(req, res) {
function count(req: express.Request, res: express.Response) {
req.session.count = req.session.count || 0;
var n = req.session.count++;
res.send('viewed ' + n + ' times\n');
@@ -274,7 +274,7 @@ api.use(express.bodyParser());
* CORS support.
*/
api.all('*', function (req, res, next) {
api.all('*', (req: express.Request, res: express.Response, next) => {
if (!req.get('Origin')) return next();
// use "*" here to accept any origin
res.set('Access-Control-Allow-Origin', 'http://localhost:3000');
@@ -289,7 +289,7 @@ api.all('*', function (req, res, next) {
* POST a user.
*/
api.post('/user', function (req, res) {
api.post('/user', (req: express.Request, res: express.Response) => {
console.log(req.body);
res.send(201);
});
@@ -302,7 +302,7 @@ console.log('api listening on 3001');
////////////////////
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.send('<ul>'
+ '<li>Download <a href="/files/amazing.txt">amazing.txt</a>.</li>'
+ '<li>Download <a href="/files/missing.txt">missing.txt</a>.</li>'
@@ -311,7 +311,7 @@ app.get('/', function (req, res) {
// /files/* is accessed via req.params[0]
// but here we name it :file
app.get('/files/:file(*)', function (req, res, next?) {
app.get('/files/:file(*)', (req: express.Request, res: express.Response) => {
var file = req.params.file
, path = __dirname + '/files/' + file;
@@ -322,7 +322,7 @@ app.get('/files/:file(*)', function (req, res, next?) {
// below our routes, you will be able to
// "intercept" errors, otherwise Connect
// will respond with 500 "Internal Server Error".
app.use(function (err, req, res, next) {
app.use((err, req, res: express.Response, next) => {
// special-case 404s,
// remember you could
// render a 404 template here
@@ -363,7 +363,7 @@ app.set('views', __dirname + '/views');
// ex: res.render('users.html').
app.set('view engine', 'html');
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.render('users', {
users: users,
title: "EJS example",
@@ -390,12 +390,12 @@ app.use(app.router);
app.use(error);
// error handling middleware have an arity of 4
// instead of the typical (req, res, next),
// instead of the typical (req: express.Request, res: express.Response, next),
// otherwise they behave exactly like regular
// middleware, you may have several of them,
// in different orders etc.
function error(err, req, res, next) {
function error(err, req, res: express.Response, next) {
// log it
if (!test) console.error(err.stack);
@@ -403,14 +403,14 @@ function error(err, req, res, next) {
res.send(500);
}
app.get('/', function (req, res) {
app.get('/', () => {
// Caught and passed down to the errorHandler middleware
throw new Error('something broke!');
});
app.get('/next', function (req, res, next) {
app.get('/next', (req: express.Request, res: express.Response, next) => {
// We can also pass exceptions to next()
process.nextTick(function () {
process.nextTick(() => {
next(new Error('oh no!'));
});
});
@@ -460,7 +460,7 @@ app.use(app.router);
// $ curl http://localhost:3000/notfound -H "Accept: application/json"
// $ curl http://localhost:3000/notfound -H "Accept: text/plain"
app.use(function (req, res, next) {
app.use((req: express.Request, res: express.Response) => {
res.status(404);
// respond with html page
@@ -481,7 +481,7 @@ app.use(function (req, res, next) {
// error-handling middleware, take the same form
// as regular middleware, however they require an
// arity of 4, aka the signature (err, req, res, next).
// arity of 4, aka the signature (err, req, res: express.Response, next).
// when connect has an error, it will invoke ONLY error-handling
// middleware.
@@ -491,7 +491,7 @@ app.use(function (req, res, next) {
// would remain being executed, however here
// we simply respond with an error page.
app.use(function (err, req, res, next) {
app.use((err, req, res: express.Response) => {
// we may use properties of the error object
// here and next(err) appropriately, or if
// we possibly recovered from the error, simply next().
@@ -501,25 +501,25 @@ app.use(function (err, req, res, next) {
// Routes
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.render('index.jade');
});
app.get('/404', function (req, res, next) {
app.get('/404', (req: express.Request, res: express.Response, next) => {
// trigger a 404 since no other middleware
// will match /404 after this one, and we're not
// responding here
next();
});
app.get('/403', function (req, res, next) {
app.get('/403', (req: express.Request, res: express.Response, next) => {
// trigger a 403 error
var err = <any>new Error('not allowed!');
err.status = 403;
next(err);
});
app.get('/500', function (req, res, next) {
app.get('/500', (req: express.Request, res: express.Response, next) => {
// trigger a generic (500) error
next(new Error('keyboard cat!'));
});
@@ -552,7 +552,7 @@ User.prototype.toJSON = function () {
return {
id: this.id,
name: this.name
}
};
};
app.use(express.logger('dev'));
@@ -563,7 +563,7 @@ app.use(express.logger('dev'));
// to the templates, so "expose" will
// be present.
app.use(function (req, res, next) {
app.use((req: express.Request, res: express.Response, next) => {
res.locals.expose = {};
// you could alias this as req or res.expose
// to make it shorter and less annoying
@@ -572,16 +572,16 @@ app.use(function (req, res, next) {
// pretend we loaded a user
app.use(function (req, res, next) {
app.use((req: express.Request, res: express.Response, next) => {
req.user = new User('Tobi');
next();
});
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.redirect('/user');
});
app.get('/user', function (req, res) {
app.get('/user', (req: express.Request, res: express.Response) => {
// we only want to expose the user
// to the client for this route:
res.locals.expose.user = req.user;
@@ -593,7 +593,7 @@ console.log('app listening on port 3000');
///////////////////////
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.send('Hello World');
});
@@ -604,33 +604,33 @@ console.log('Express started on port 3000');
// register .md as an engine in express view system
app.engine('md', function (path, options, fn) {
fs.readFile(path, 'utf8', function (err, str) {
app.engine('md', (path, options, fn) => {
fs.readFile(path, 'utf8', (err, str) => {
if (err) return fn(err);
try {
var html = md(str);
html = html.replace(/\{([^}]+)\}/g, function (_, name) {
html = html.replace(/\{([^}]+)\}/g, (_, name) => {
return options[name] || '';
})
});
fn(null, html);
} catch (err) {
fn(err);
}
});
})
});
app.set('views', __dirname + '/views');
// make it the default so we dont need .md
app.set('view engine', 'md');
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.render('index', { title: 'Markdown Example' });
})
});
app.get('/fail', function (req, res) {
app.get('/fail', (req: express.Request, res: express.Response) => {
res.render('missing', { title: 'Markdown Example' });
})
});
if (!module.parent) {
app.listen(3000);
@@ -643,9 +643,9 @@ var mformat: any;
// bodyParser in connect 2.x uses node-formidable to parse
// the multipart form data.
app.use(express.bodyParser())
app.use(express.bodyParser());
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.send('<form method="post" enctype="multipart/form-data">'
+ '<p>Title: <input type="text" name="title" /></p>'
+ '<p>Image: <input type="file" name="image" /></p>'
@@ -653,7 +653,7 @@ app.get('/', function (req, res) {
+ '</form>');
});
app.post('/', function (req, res, next) {
app.post('/', (req: express.Request, res: express.Response) => {
// the uploaded file can be found as `req.files.image` and the
// title field as `req.body.title`
res.send(mformat('\nuploaded %s (%d Kb) to %s as %s'
@@ -680,7 +680,6 @@ if (!module.parent) {
*/
var online: any;
var redis: any;
var db: any;
// online
@@ -690,7 +689,7 @@ online = online(db);
// activity tracking, in this case using
// the UA string, you would use req.user.id etc
app.use(function (req, res, next) {
app.use((req: express.Request, res: express.Response, next) => {
// fire-and-forget
online.add(req.headers['user-agent']);
next();
@@ -701,7 +700,7 @@ app.use(function (req, res, next) {
*/
function list(ids) {
return '<ul>' + ids.map(function (id) {
return '<ul>' + ids.map(id => {
return '<li>' + id + '</li>';
}).join('') + '</ul>';
}
@@ -710,8 +709,8 @@ function list(ids) {
* GET users online.
*/
app.get('/', function (req, res, next) {
online.last(5, function (err, ids) {
app.get('/', (req: express.Request, res: express.Response, next) => {
online.last(5, (err, ids) => {
if (err) return next(err);
res.send('<p>Users online: ' + ids.length + '</p>' + list(ids));
});
@@ -724,7 +723,7 @@ console.log('listening on port 3000');
// Convert :to and :from to integers
app.param(['to', 'from'], function (req, res, next, num, name) {
app.param(['to', 'from'], (req: express.Request, res: express.Response, next, num, name) => {
req.params[name] = num = parseInt(num, 10);
if (isNaN(num)) {
next(new Error('failed to parseInt ' + num));
@@ -735,7 +734,7 @@ app.param(['to', 'from'], function (req, res, next, num, name) {
// Load user by id
app.param('user', function (req, res, next, id) {
app.param('user', (req: express.Request, res: express.Response, next, id) => {
if (req.user = users[id]) {
next();
} else {
@@ -747,7 +746,7 @@ app.param('user', function (req, res, next, id) {
* GET index.
*/
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.send('Visit /user/0 or /users/0-2');
});
@@ -755,7 +754,7 @@ app.get('/', function (req, res) {
* GET :user.
*/
app.get('/user/:user', function (req, res, next) {
app.get('/user/:user', (req: express.Request, res: express.Response) => {
res.send('user ' + req.user.name);
});
@@ -763,10 +762,10 @@ app.get('/user/:user', function (req, res, next) {
* GET users :from - :to.
*/
app.get('/users/:from-:to', function (req, res, next) {
app.get('/users/:from-:to', (req: express.Request, res: express.Response) => {
var from = req.params.from
, to = req.params.to
, names = users.map(function (user) { return user.name; });
, names = users.map(user => { return user.name; });
res.send('users ' + names.slice(from, to).join(', '));
});
@@ -781,7 +780,7 @@ if (!module.parent) {
app.resource = function (path, obj) {
this.get(path, obj.index);
this.get(path + '/:a..:b.:format?', function (req, res) {
this.get(path + '/:a..:b.:format?', (req: express.Request, res: express.Response) => {
var a = parseInt(req.params.a, 10)
, b = parseInt(req.params.b, 10)
, format = req.params.format;
@@ -794,19 +793,19 @@ app.resource = function (path, obj) {
// Fake controller.
var FUser = {
index: function (req, res) {
index: (req: express.Request, res: express.Response) => {
res.send(users);
},
show: function (req, res) {
show: (req: express.Request, res: express.Response) => {
res.send(users[req.params.id] || { error: 'Cannot find user' });
},
destroy: function (req, res) {
destroy: (req: express.Request, res: express.Response) => {
var id = req.params.id;
var destroyed = id in users;
delete users[id];
res.send(destroyed ? 'destroyed' : 'Cannot find user');
},
range: function (req, res, a, b, format) {
range: (req: express.Request, res: express.Response, a, b, format) => {
var range = users.slice(a, b + 1);
switch (format) {
case 'json':
@@ -814,7 +813,7 @@ var FUser = {
break;
case 'html':
default:
var html = '<ul>' + range.map(function (user) {
var html = '<ul>' + range.map(user => {
return '<li>' + user.name + '</li>';
}).join('\n') + '</ul>';
res.send(html);
@@ -831,7 +830,7 @@ var FUser = {
app.resource('/users', FUser);
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.send([
'<h1>Examples:</h1> <ul>'
, '<li>GET /users</li>'
@@ -854,7 +853,7 @@ if (!module.parent) {
var verbose: any;
app.map = function (a, route) {
app.map = (a, route) => {
route = route || '';
for (var key in a) {
switch (typeof a[key]) {
@@ -872,25 +871,25 @@ app.map = function (a, route) {
};
var users2 = {
list: function (req, res) {
list: (req: express.Request, res: express.Response) => {
res.send('user list');
},
get: function (req, res) {
get: (req: express.Request, res: express.Response) => {
res.send('user ' + req.params.uid);
},
del: function (req, res) {
del: (req: express.Request, res: express.Response) => {
res.send('delete users');
}
};
var pets2 = {
list: function (req, res) {
list: (req: express.Request, res: express.Response) => {
res.send('user ' + req.params.uid + '\'s pets');
},
del: function (req, res) {
del: (req: express.Request, res: express.Response) => {
res.send('delete ' + req.params.uid + '\'s pet ' + req.params.pid);
}
};
@@ -922,7 +921,7 @@ app.listen(3000);
// curl http://localhost:3000/user/1/edit (unauthorized since this is not you)
// curl -X DELETE http://localhost:3000/user/0 (unauthorized since you are not an admin)
function loadUser(req, res, next) {
function loadUser(req: express.Request, res: express.Response, next) {
// You would fetch your user from the db
var user = users[req.params.id];
if (user) {
@@ -933,7 +932,7 @@ function loadUser(req, res, next) {
}
}
function andRestrictToSelf(req, res, next) {
function andRestrictToSelf(req: express.Request, res: express.Response, next) {
// If our authenticated user is the user we are viewing
// then everything is fine :)
if (req.authenticatedUser.id == req.user.id) {
@@ -948,13 +947,13 @@ function andRestrictToSelf(req, res, next) {
}
function andRestrictTo(role) {
return function (req, res, next) {
return (req: express.Request, res: express.Response, next) => {
if (req.authenticatedUser.role == role) {
next();
} else {
next(new Error('Unauthorized'));
}
}
};
}
// Middleware for faux authentication
@@ -962,24 +961,24 @@ function andRestrictTo(role) {
// but this illustrates how an authenticated user
// may interact with middleware
app.use(function (req, res, next) {
app.use((req: express.Request, res: express.Response, next) => {
req.authenticatedUser = users[0];
next();
});
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.redirect('/user/0');
});
app.get('/user/:id', loadUser, function (req, res) {
app.get('/user/:id', loadUser, (req: express.Request, res: express.Response) => {
res.send('Viewing user ' + req.user.name);
});
app.get('/user/:id/edit', loadUser, andRestrictToSelf, function (req, res) {
app.get('/user/:id/edit', loadUser, andRestrictToSelf, (req: express.Request, res: express.Response) => {
res.send('Editing user ' + req.user.name);
});
app.del('/user/:id', loadUser, andRestrictTo('admin'), function (req, res) {
app.del('/user/:id', loadUser, andRestrictTo('admin'), (req: express.Request, res: express.Response) => {
res.send('Deleted user ' + req.user.name);
});
@@ -1003,7 +1002,7 @@ db.sadd('cat', 'luna');
* GET the search page.
*/
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.render('search');
});
@@ -1011,9 +1010,9 @@ app.get('/', function (req, res) {
* GET search for :query.
*/
app.get('/search/:query?', function (req, res) {
app.get('/search/:query?', (req: express.Request, res: express.Response) => {
var query = req.params.query;
db.smembers(query, function (err, vals) {
db.smembers(query, (err, vals) => {
if (err) return res.send(500);
res.send(vals);
});
@@ -1026,7 +1025,7 @@ app.get('/search/:query?', function (req, res) {
* template.
*/
app.get('/client.js', function (req, res) {
app.get('/client.js', (req: express.Request, res: express.Response) => {
res.sendfile(__dirname + '/client.js');
});
@@ -1045,7 +1044,7 @@ app.use(express.cookieParser('keyboard cat'));
// Populates req.session
app.use(express.session());
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
var body = '';
if (req.session.views) {
++req.session.views;
@@ -1118,11 +1117,11 @@ var main = express();
main.use(express.logger('dev'));
main.get('/', function (req, res) {
res.send('Hello from main app!')
main.get('/', (req: express.Request, res: express.Response) => {
res.send('Hello from main app!');
});
main.get('/:sub', function (req, res) {
main.get('/:sub', (req: express.Request, res: express.Response) => {
res.send('requsted ' + req.params.sub);
});
@@ -1130,12 +1129,12 @@ main.get('/:sub', function (req, res) {
var redirect = express();
redirect.all('*', function (req, res) {
redirect.all('*', (req: express.Request, res: express.Response) => {
console.log(req.subdomains);
res.redirect('http://example.com:3000/' + req.subdomains[0]);
});
app.use(express.vhost('*.example.com', redirect))
app.use(express.vhost('*.example.com', redirect));
app.use(express.vhost('example.com', main));
app.listen(3000);
@@ -1162,7 +1161,7 @@ function merror(status, msg) {
// meaning only paths prefixed with "/api"
// will cause this middleware to be invoked
app.use('/api', function (req, res, next) {
app.use('/api', (req, res: express.Response, next) => {
var key = req.query['api-key'];
// key isnt present
@@ -1186,7 +1185,7 @@ app.use(app.router);
// it will be passed through the defined middleware
// in order, but ONLY those with an arity of 4, ignoring
// regular middleware.
app.use(function (err, req, res, next) {
app.use((err, req, res: express.Response) => {
// whatever you want here, feel free to populate
// properties on `err` to treat it differently in here.
res.send(err.status || 500, { error: err.message });
@@ -1195,7 +1194,7 @@ app.use(function (err, req, res, next) {
// our custom JSON 404 middleware. Since it's placed last
// it will be the last middleware called, if all others
// invoke next() and do not respond.
app.use(function (req, res) {
app.use((req: express.Request, res: express.Response) => {
res.send(404, { error: "Lame, can't find that" });
});
@@ -1223,15 +1222,15 @@ var userRepos = {
// we now can assume the api key is valid,
// and simply expose the data
app.get('/api/users', function (req, res, next) {
app.get('/api/users', (req: express.Request, res: express.Response) => {
res.send(users);
});
app.get('/api/repos', function (req, res, next) {
app.get('/api/repos', (req: express.Request, res: express.Response) => {
res.send(repos);
});
app.get('/api/user/:name/repos', function (req, res, next) {
app.get('/api/user/:name/repos', (req: express.Request, res: express.Response, next) => {
var name = req.params.name
, user = userRepos[name];
@@ -1248,19 +1247,19 @@ if (!module.parent) {
function test_general() {
app.use(function (err, req, res, next) {
app.use((err, req, res: express.Response) => {
console.error(err.stack);
res.send(500, 'Something broke!');
});
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(function (err, req, res, next) { });
app.use(() => {});
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.get('/', function (req, res) {
app.get('/', (req: express.Request, res: express.Response) => {
res.send('hello world');
});
@@ -1285,18 +1284,18 @@ function test_general() {
app.set('db uri', 'localhost/dev');
});
app.configure('stage', 'production', function () { });
app.configure('stage', 'production', () => {});
app.configure('1', '2', '3', function () { });
app.configure('1', '2', '3', () => {});
app.use(function (req, res, next) {
app.use((req: express.Request, res: express.Response) => {
res.send('Hello World');
});
app.engine('jade', require('jade').__express);
var User;
app.param('user', (req, res, next, id) => {
app.param('user', (req: express.Request, res: express.Response, next, id) => {
User.find(id, (err, user) =>{
if (err) {
next(err);
@@ -1309,7 +1308,7 @@ function test_general() {
});
});
app.get(/^\/commits\/(\d+)(?:\.\.(\d+))?$/, (req, res) => {
app.get(/^\/commits\/(\d+)(?:\.\.(\d+))?$/, (req: express.Request, res: express.Response) => {
var from = req.params[0];
var to = req.params[1] || 'HEAD';
res.send('commit range ' + from + '..' + to);
@@ -1319,7 +1318,7 @@ function test_general() {
app.locals.strftime = require('strftime');
var requireAuthentication;
var loadUser = function () { };
var loadUser = () => {};
app.all('*', requireAuthentication, loadUser);
app.all('*', loadUser);
app.all('*', loadUser, loadUser, loadUser);
@@ -1331,9 +1330,9 @@ function test_general() {
phone: '1-250-858-9990',
email: 'me@myapp.com'
});
app.render('email', function (err, html) { });
app.render('email', () => {});
app.render('email', { name: 'Tobi' }, function (err, html) { });
app.render('email', { name: 'Tobi' }, () => {});
}
function test_request() {
@@ -1413,24 +1412,24 @@ function test_response() {
res.type('application/json');
res.format({
'text/plain': function () {
'text/plain': () => {
res.send('hey');
},
'text/html': function () {
'text/html': () => {
res.send('hey');
},
'application/json': function () {
'application/json': () => {
res.send({ message: 'hey' });
}
});
res.attachment();
res.attachment('path/to/logo.png');
app.get('/user/:uid/photos/:file', function (req, res) {
app.get('/user/:uid/photos/:file', (req: express.Request, res: express.Response) => {
var uid = req.params.uid
, file = req.params.file;
req.user.mayViewFilesFrom(uid, function (yes) {
req.user.mayViewFilesFrom(uid, yes => {
if (yes) {
res.sendfile('/uploads/' + uid + '/' + file);
} else {
@@ -1441,7 +1440,7 @@ function test_response() {
res.download('/report-12345.pdf');
res.download('/report-12345.pdf', 'report.pdf');
res.download('/report-12345.pdf', 'report.pdf', function (err) {
res.download('/report-12345.pdf', 'report.pdf', err => {
if (err) { } else { }
});
@@ -1450,19 +1449,19 @@ function test_response() {
last: 'http://api.example.com/users?page=5'
});
app.use(function (req, res, next) {
app.use((req: express.Request, res: express.Response, next) => {
res.locals.user = req.user;
res.locals.authenticated = !req.user.anonymous;
next();
});
res.render('index', function (err, html) { });
res.render('user', { name: 'Tobi' }, function (err, html) { });
res.render('index', () => {});
res.render('user', { name: 'Tobi' }, () => {});
}
function test_middleware() {
app.use(express.basicAuth('username', 'password'));
app.use(express.basicAuth(function (user, pass) {
app.use(express.basicAuth((user, pass) => {
return 'tj' == user && 'wahoo' == pass;
}));
app.use(express.bodyParser());
+25 -28
View File
@@ -125,6 +125,8 @@ declare module "express" {
success: string;
views: any;
count: number;
}
interface Request {
@@ -156,6 +158,8 @@ declare module "express" {
header(name: string): string;
headers: string[];
/**
* Check if the given `type(s)` is acceptable, returning
* the best match when true, otherwise `undefined`, in which
@@ -235,19 +239,8 @@ declare module "express" {
/**
* Return an array of Accepted media types
* ordered from highest quality to lowest.
*
* Examples:
*
* [ { value: 'application/json',
* quality: 1,
* type: 'application',
* subtype: 'json' },
* { value: 'text/html',
* quality: 0.5,
* type: 'text',
* subtype: 'html' } ]
*/
accepted: any[];
accepted: MediaType[];
/**
* Return an array of Accepted languages
@@ -417,6 +410,8 @@ declare module "express" {
user: any;
authenticatedUser: any;
files: any;
/**
@@ -434,6 +429,20 @@ declare module "express" {
signedCookies: any;
originalUrl: string;
url: string;
}
interface MediaType {
value: string;
quality: number;
type: string;
subtype: string;
}
interface Send {
(status: number, body?: any): Response;
(body: any): Response;
}
interface Response extends http.ServerResponse {
@@ -469,11 +478,7 @@ declare module "express" {
* res.send(404, 'Sorry, cant find that');
* res.send(404);
*/
send(status: number): Response;
send(bodyOrStatus: any): Response;
send(status: number, body: any): Response;
send: Send;
/**
* Send JSON response.
@@ -485,11 +490,7 @@ declare module "express" {
* res.json(500, 'oh noes!');
* res.json(404, 'I dont have that');
*/
json(status: number): Response;
json(bodyOrStatus: any): Response;
json(status: number, body: any): Response;
json: Send;
/**
* Send JSON response with JSONP callback support.
@@ -501,11 +502,7 @@ declare module "express" {
* res.jsonp(500, 'oh noes!');
* res.jsonp(404, 'I dont have that');
*/
jsonp(status: number): Response;
jsonp(bodyOrStatus: any): Response;
jsonp(status: number, body: any): Response;
jsonp: Send;
/**
* Transfer the file at the given `path`.
@@ -884,7 +881,7 @@ declare module "express" {
*/
param(name: string, fn: Function): Application;
param(name: any[], fn: Function): Application;
param(name: string[], fn: Function): Application;
/**
* Assign `setting` to `val`, or return `setting`'s value.
+944 -14
View File
File diff suppressed because it is too large Load Diff
+51
View File
@@ -404,6 +404,57 @@ declare module google {
width?: number;
}
//#endregion
//#region BarChart
// https://google-developers.appspot.com/chart/interactive/docs/gallery/barchart#Configuration_Options
export interface BarChartOptions {
aggregationTarget?: string;
animation?: TransitionAnimation;
axisTitlesPosition?: string; // in, out, none
backgroundColor?: any;
bar?: ColumnChartBarOptions;
chartArea?: ChartArea;
colors?: string[];
dataOpacity?: number;
enableInteractivity?: boolean;
focusTarget?: string;
fontSize?: number;
fontName?: string;
hAxis?: ChartAxis;
height?: number;
isStacked?: boolean;
legend?: ChartLegend;
reverseCategories?: boolean;
series?: any;
theme?: string;
title?: string;
titlePosition?: string;
titleTextStyle?: ChartTextStyle;
tooltip?: ChartTooltip;
vAxes?: any;
vAxis?: ChartAxis;
width?: number;
}
// https://google-developers.appspot.com/chart/interactive/docs/gallery/barchart
export class BarChart {
constructor(element: Element);
draw(data: DataTable, options: BarChartOptions): void;
draw(data: DataView, options: BarChartOptions): void;
getBoundingBox(id: string): ChartBoundingBox;
getChartAreaBoundingBox(): ChartBoundingBox;
getChartLayoutInterface(): ChartLayoutInterface;
getHAxisValue(position: number, axisIndex?: number): number;
getVAxisValue(position: number, axisIndex?: number): number;
getXLocation(position: number, axisIndex?: number): number;
getYLocation(position: number, axisIndex?: number): number;
getSelection(): any[];
setSelection(selection: any[]): void;
clearChart(): void;
}
//#endregion
//#region Events
+7
View File
@@ -0,0 +1,7 @@
/// <reference path="karma-jasmine.d.ts" />
ddescribe("A suite", () => {
iit("contains spec with an expectation", () => {
expect(true).toBe(true);
});
});
+9
View File
@@ -0,0 +1,9 @@
// Type definitions for karma-jasmine plugin
// Project: https://github.com/karma-runner/karma-jasmine
// Definitions by: Michel Salib <michelsalib@hotmail.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jasmine/jasmine.d.ts" />
declare function ddescribe(description: string, specDefinitions: () => void): void;
declare function iit(expectation: string, assertion: () => void): void;
-1
View File
@@ -195,7 +195,6 @@ interface NodeBuffer {
writeDoubleLE(value: number, offset: number, noAssert?: boolean): void;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): void;
fill(value: any, offset?: number, end?: number): void;
INSPECT_MAX_BYTES: number;
}
interface NodeTimer {
+2 -2
View File
@@ -14,8 +14,8 @@ module Test {
namespace: "global",
defaultLayout: "slideout",
navigation: [
{ title: "Home", action: "#home" },
{ title: "About", action: "#about" }
{ id: "first", title: "Home", action: "#home" },
{ id: "second", title: "About", action: "#about" }
]
});
application.router.register(":view/:id", { view: "home", id: undefined });
+17 -32
View File
@@ -208,7 +208,7 @@ declare module DevExpress.data {
}
export interface StoreOptions {
key?: any;
errorHandler: ErrorHandler;
errorHandler?: ErrorHandler;
loaded?: JQueryCallback;
loading?: JQueryCallback;
modified?: JQueryCallback;
@@ -294,14 +294,6 @@ declare module DevExpress.data {
export class ODataStore extends Store {
constructor(options?: ODataStoreOptions);
}
interface IODataContextBase {
get(operationName: string, params: { [key: string]: any }): JQueryDeferred<Array<any>>;
invoke(operationName: string, params: { [key: string]: any }, httpMethod?: string): JQueryDeferred<Array<any>>;
objectLink(entityAlias: string, key: any): { __metadata: { uri: string }; }
}
interface IODataContext extends IODataContextBase {
[entitySetName: string]: any;
}
export interface ODataContextOptions {
url: string;
jsonp?: boolean;
@@ -310,24 +302,18 @@ declare module DevExpress.data {
beforeSend?: () => any;
entities?: Array<any>;
}
export class ODataContext implements IODataContextBase {
export class ODataContext {
constructor(options?: ODataContextOptions);
get(operationName: string, params: { [key: string]: any }): JQueryDeferred<Array<any>>;
invoke(operationName: string, params: { [key: string]: any }, httpMethod?: string): JQueryDeferred<Array<any>>;
objectLink(entityAlias: string, key: any): { __metadata: { uri: string }; }
objectLink(entityAlias: string, key: any): { __metadata: { uri: string }; };
}
}
declare module DevExpress.framework {
interface NavigationItem {
title: string;
icon?: string;
root?: boolean;
action: any;
}
export interface dxViewOptions {
name: string;
title: string;
layout: string;
title?: string;
layout?: string;
}
export class dxView extends ui.Component {
constructor(options?: dxViewOptions);
@@ -365,19 +351,19 @@ declare module DevExpress.framework {
export class dxContent extends ui.Component {
constructor(options?: dxLayoutOptions);
}
export interface CommandOptions extends ui.ComponentOptions {
export interface dxCommandOptions extends ui.ComponentOptions {
id: string;
action: any;
icon: string;
title: string;
iconSrc: string;
visible: boolean;
action?: any;
icon?: string;
title?: string;
iconSrc?: string;
visible?: boolean;
}
export class dxCommand extends ui.Component {
public beforeExecute: JQueryCallback;
public afterExecute: JQueryCallback;
constructor(element: JQuery, options?: CommandOptions);
constructor(element: Element, options?: CommandOptions);
constructor(element: JQuery, options?: dxCommandOptions);
constructor(element: Element, options?: dxCommandOptions);
execute(): void;
}
export class dxCommandContainer extends ui.Component {
@@ -543,7 +529,7 @@ declare module DevExpress.framework {
disableViewCache?: boolean;
stateManager?: StateManager;
navigationManager?: NavigationManager;
navigation?: NavigationItem[];
navigation?: dxCommandOptions[];
commandMapping?: CommandMap;
}
export class Application {
@@ -552,7 +538,7 @@ declare module DevExpress.framework {
public components: any[];
public stateManager: StateManager;
public commandMapping: CommandMap;
public navigation: NavigationItem[];
public navigation: dxCommand[];
public navigationManager: NavigationManager;
public beforeViewSetup: JQueryCallback;
public afterViewSetup: JQueryCallback;
@@ -669,7 +655,7 @@ declare module DevExpress.framework.html {
}
export interface HtmlApplicationBaseOptions extends framework.ApplicationOptions {
device?: devices.Device;
defaultLayout?: string;
navigationType?: string;
}
export class HtmlApplicationBase extends framework.Application {
public viewRendered: JQueryCallback;
@@ -685,7 +671,6 @@ declare module DevExpress.framework.html {
}
export class HtmlApplication extends HtmlApplicationBase {
public viewEngine: ViewEngineBase;
public blankViewRendered: JQueryCallback;
constructor(options?: HtmlApplicationOptions);
}
}
@@ -904,7 +889,7 @@ declare module DevExpress.ui {
autoPagingEnabled?: boolean;
scrollingEnabled?: boolean;
showScrollbar?: boolean;
useNative?: boolean;
useNativeScrolling?: boolean;
grouped?: boolean;
editEnabled?: boolean;
showNextButton?: boolean;
+86
View File
@@ -0,0 +1,86 @@
///<reference path="../node/node.d.ts"/>
///<reference path="promptly.d.ts"/>
import promptly = require('promptly');
process.stdin
// Options
var options: promptly.Options = {}
options = {
default: 'value'
}
options = {
trim: false
}
options = {
retry: false
}
options = {
silent: false
}
options = {
input: process.stdin
}
options = {
output: process.stdout
}
// Validator
options = {
validator: () => {}
}
options = {
validator: (value: string) => {}
}
options = {
validator: (value: string) => {
return 'result';
}
}
options = {
validator: [
(value: string) => { return 'result' },
(value: string) => { return 'result' }
]
}
// Prompt
promptly.prompt('hello world');
promptly.prompt('hello world', options);
promptly.prompt('hello world', () => {
});
promptly.prompt('hello world', options, (err: Error, value: string) => {
});
// Password
promptly.password('hello world');
promptly.password('hello world', options);
promptly.password('hello world', () => {
});
promptly.password('hello world', options, (err: Error, value: string) => {
});
// Confirm
promptly.confirm('hello world');
promptly.confirm('hello world', options);
promptly.confirm('hello world', () => {
});
promptly.confirm('hello world', options, (err: Error, value: string) => {
});
// Choose
promptly.choose('hello world', ['test1', 'test2']);
promptly.choose('hello world', ['test1', 'test2'], options);
promptly.choose('hello world', ['test1', 'test2'], () => {
});
promptly.choose('hello world', ['test1', 'test2'], options, (err: Error, value: string) => {
});
+36
View File
@@ -0,0 +1,36 @@
// Type definitions for node-promptly 1.1.1
// Project: https://github.com/IndigoUnited/node-promptly
// Definitions by: Dan Spencer <https://github.com/danrspencer>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../node/node.d.ts"/>
declare module "promptly" {
interface Callback {
(err: Error, value: string): void;
}
export interface Options {
default?: string;
trim?: boolean;
validator?: any;
retry?: boolean;
silent?: boolean;
input?: ReadableStream;
output?: WritableStream;
}
export function prompt(message: string, fn?: Callback):any;
export function prompt(message: string, opts: Options, fn?: Callback):any;
export function password(message: string, fn?: Callback):any;
export function password(message: string, opts: Options, fn?: Callback):any;
export function confirm(message: string, fn?: Callback):any;
export function confirm(message: string, opts: Options, fn?: Callback):any;
export function choose(message: string, choices: string[], fn?: Callback):any;
export function choose(message: string, choices: string[], opts: Options, fn?: Callback):any;
}
+1
View File
@@ -51,6 +51,7 @@ declare module When {
promise: Promise<T>;
reject(reason: any): void;
resolve(value?: T): void;
resolve(value?: Promise<T>): void;
}
interface Promise<T> {