From 90fe3e51ea05b90acd58cd65ccc17dd578771b65 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 21 Apr 2015 11:14:03 -0700 Subject: [PATCH 001/357] PlayerOptions width and height should be strings, adds Player.destroy() Per https://developers.google.com/youtube/iframe_api_reference PlayerOptions can be other than numbers, in fact in the API reference are created as strings even though they are specified as numbers: '100%' works. Also adds the Player.destroy() method, which removes the iframe from the DOM. --- youtube/youtube.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/youtube/youtube.d.ts b/youtube/youtube.d.ts index 85f96b22f..42262f452 100644 --- a/youtube/youtube.d.ts +++ b/youtube/youtube.d.ts @@ -50,8 +50,8 @@ declare module YT { } export interface PlayerOptions { - width?: number; - height?: number; + width?: string; + height?: string; videoId?: string; playerVars?: PlayerVars; events?: Events; @@ -147,6 +147,9 @@ declare module YT { // Event Listener addEventListener(event: string, handler: EventHandler): void; + + // DOM + destroy(): void; } export enum PlayerState { From 6a02cedcf0a68b7d46c45f588427a6a4965f4ba4 Mon Sep 17 00:00:00 2001 From: Alvaro Dias Date: Sun, 13 Sep 2015 04:49:18 -0700 Subject: [PATCH 002/357] Add bundles, skipDataMain and onNodeCreated --- requirejs/require.d.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/requirejs/require.d.ts b/requirejs/require.d.ts index 58fb4f6f1..113ead635 100644 --- a/requirejs/require.d.ts +++ b/requirejs/require.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RequireJS 2.1.8 +// Type definitions for RequireJS 2.1.20 // Project: http://requirejs.org/ // Definitions by: Josh Baldwin // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -88,6 +88,10 @@ interface RequireConfig { // baseUrl. paths?: { [key: string]: any; }; + // Allows configuring multiple module IDs to be found in + // another script. + bundles?: { [key: string]: any; }; + // Dictionary of Shim's. // does not cover case of key->string[] shim?: { [key: string]: RequireShim; }; @@ -182,6 +186,20 @@ interface RequireConfig { **/ scriptType?: string; + /** + * If set to true, skips the data-main attribute scanning done + * to start module loading. Useful if RequireJS is embedded in + * a utility library that may interact with other RequireJS + * library on the page, and the embedded version should not do + * data-main loading. + **/ + skipDataMain?: boolean; + + /** + * Allow extending requirejs to support Subresource Integrity + * (SRI). + **/ + onNodeCreated?: (node: HTMLScriptElement, config: RequireConfig, moduleName: string, url: string) => void; } // todo: not sure what to do with this guy From ec3fd22445c7d10ee983baf056ca2215511a4ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81xel=20Costas=20Pena?= Date: Wed, 16 Sep 2015 17:05:54 +0200 Subject: [PATCH 003/357] Add simpleStorage type definitions. Add simpleStorage to CONTRIBUTORS.md. *NOTE file naming includes uppercase characters disregarding the Contribution guide Quality Criteria because of another different package named simplestorage already existing on npm.* --- CONTRIBUTORS.md | 1 + simpleStorage/simpleStorage.d.ts | 110 +++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 simpleStorage/simpleStorage.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d4a3000cb..0b6c2f714 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1024,6 +1024,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](signature_pad/signature_pad.d.ts) [signature_pad](https://github.com/szimek/signature_pad) by [Abubaker Bashir](https://github.com/AbubakerB) * [:link:](simple-cw-node/simple-cw-node.d.ts) [simple-cw-node](https://github.com/astronaughts/simple-cw-node) by [vvakame](https://github.com/vvakame) * [:link:](jquery.simplemodal/jquery.simplemodal.d.ts) [SimpleModal](http://www.ericmmartin.com/projects/simplemodal) by [Friedrich von Never](https://github.com/ForNeVeR) +* [:link:](simpleStorage/simpleStorage.d.ts) [simpleStorage](https://github.com/andris9/simpleStorage) by [Áxel Costas Pena](https://github.com/axelcostaspena) * [:link:](sinon/sinon.d.ts) [Sinon](http://sinonjs.org) by [William Sears](https://github.com/mrbigdog2u) * [:link:](sinon-chai/sinon-chai.d.ts) [sinon-chai](https://github.com/domenic/sinon-chai) by [Kazi Manzur Rashid](https://github.com/kazimanzurrashid), [Jed Mao](https://github.com/jedmao) * [:link:](sinon-chrome/sinon-chrome.d.ts) [Sinon-Chrome](https://github.com/vitalets/sinon-chrome) by [Tim Perry](https://github.com/pimterry) diff --git a/simpleStorage/simpleStorage.d.ts b/simpleStorage/simpleStorage.d.ts new file mode 100644 index 000000000..52c4f27ee --- /dev/null +++ b/simpleStorage/simpleStorage.d.ts @@ -0,0 +1,110 @@ +// Type definitions for simpleStorage v0.1.3 +// Project: https://github.com/andris9/simpleStorage +// Definitions by: Áxel Costas Pena +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module andris9_simpleStorage { + + /** + * {@link simpleStorage} API is a subset of {@link http://www.jstorage.info/|jStorage} with slight modifications, so for most cases it should work out of the box if you are converting from {@link http://www.jstorage.info/|jStorage}. Main difference is between return values - if an action failed because of an error (storage full, storage not available, invalid data used etc.), you get the error object as the return value. {@link http://www.jstorage.info/|jStorage} never indicated anything if an error occurred. + * @see https://github.com/andris9/simpleStorage#usage + */ + export interface SimpleStorage { + + version: string; + + /** + * Check if local storage can be used. + * Returns true if storage is available. + * @see https://github.com/andris9/simpleStorage#canuse + */ + canUse(): boolean; + + /** + * Store or update a value in local storage. + * Returns true if value was stored, false if value was not stored or {@link Error} object if value was not stored because of an error. + * @param key The key for the value. + * @param value Value to be stored (can be any JSONeable value). + * @param [options] Optional options object. + * @see https://github.com/andris9/simpleStorage#setkey-value-options + */ + set(key: string, value: any, options?: SetOptions): boolean|Error; + + /** + * Retrieve a value from local storage. + * Returns the value for a key or undefined if the key was not found. + * @param key The key to be retrieved. + * @see https://github.com/andris9/simpleStorage#getkey + */ + get(key: string): any; + + /** + * Removes a value from local storage. + * Returns true if the value was deleted, false if the value was not found or {@link Error} object if value was not deleted because of an error. + * @param key The key to be deleted. + * @see https://github.com/andris9/simpleStorage#deletekeykey + */ + deleteKey(key: string): boolean|Error; + + /** + * Set a millisecond timeout. When the timeout is reached, the key is removed automatically from local storage. + * Returns true if ttl was set, false if value was not found or {@link Error} object if ttl was not set because of an error. + * @param key The key to be updated. + * @param ttl Timeout in milliseconds. If the value is 0, timeout is cleared from the key. + * @see https://github.com/andris9/simpleStorage#setttlkey-ttl + */ + setTTL(key: string, ttl: number): boolean|Error; + + /** + * Retrieve remaining milliseconds for a key with TTL. + * Returns the finite number of remaining milliseconds, Infinity if TTL is not set for the selected key or false if the selected key does not exist or is expired. + * @param key The key to be checked. + * @see https://github.com/andris9/simpleStorage#getttlkey + */ + getTTL(key: string): number|boolean; + + /** + * Clear all values. + * Returns true if storage was flushed or {@link Error} object if storage was not flushed because of an error. + * @see https://github.com/andris9/simpleStorage#flush + */ + flush(): boolean|Error; + + /** + * Retrieve all used keys as an array. + * Returns an array of keys. + * @see https://github.com/andris9/simpleStorage#index + */ + index(): [string]|boolean; + + /** + * Get used storage in symbol count. + * @see https://github.com/andris9/simpleStorage#storagesize + */ + storageSize(): number; + } + + /** + * @see https://github.com/andris9/simpleStorage#setkey-value-options + */ + export interface SetOptions { + /** + * Sets the time-to-live (TTL) value in milliseconds for the given key/value. + */ + TTL?: number; + } + +} + +declare module "simpleStorage" { + export = simpleStorage; +} + +/** + * Cross-browser key-value store database to store data locally in the browser. + * {@link simpleStorage} is a fork of {@link http://www.jstorage.info/|jStorage} that only includes the minimal set of features. Basically it is a wrapper for native {@link JSON} + {@link WindowLocalStorage.localStorage|localStorage} with some TTL magic mixed in. + * The module has no dependencies, you can use it as a standalone script (introduces {@link simpleStorage} global) or as an AMD module. All modern browsers (including mobile) are supported, older browsers (IE7, Firefox 3) are not. + * {@link simpleStorage} is very small - about 1kB in size when minimized and gzipped. + * @see https://github.com/andris9/simpleStorage#simplestorage + */ +declare var simpleStorage:andris9_simpleStorage.SimpleStorage; From 2775004106418bd2eb92d8825aa02a893949d63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81xel=20Costas=20Pena?= Date: Wed, 16 Sep 2015 17:06:25 +0200 Subject: [PATCH 004/357] Add simpleStorage tests. --- simpleStorage/simpleStorage-tests.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 simpleStorage/simpleStorage-tests.ts diff --git a/simpleStorage/simpleStorage-tests.ts b/simpleStorage/simpleStorage-tests.ts new file mode 100644 index 000000000..9ffcd1853 --- /dev/null +++ b/simpleStorage/simpleStorage-tests.ts @@ -0,0 +1,17 @@ +/// + +var versionTest: string = simpleStorage.version; +var canUseTest: boolean = simpleStorage.canUse(); +var simpleStorageTest1: boolean|Error = simpleStorage.set("string", 7); +var simpleStorageTest2: boolean|Error = simpleStorage.set("string", 7, {}); +var simpleStorageTest3: boolean|Error = simpleStorage.set("string", 7, { TTL: 7 }); +var simpleStorageTest4: boolean|Error = simpleStorage.set("string", undefined); +var simpleStorageTest5: boolean|Error = simpleStorage.set("string", undefined, {}); +var simpleStorageTest6: boolean|Error = simpleStorage.set("string", undefined, { TTL: 7 }); +var getTest: any = simpleStorage.get("string"); +var deleteKeyTest: boolean|Error = simpleStorage.deleteKey("string"); +var setTTLTest: boolean|Error = simpleStorage.setTTL("string", 7); +var getTTLTest: number|boolean = simpleStorage.getTTL("string"); +var flushTest: boolean|Error = simpleStorage.flush(); +var indexTest: [string]|boolean = simpleStorage.index(); +var storageSizeTest: number = simpleStorage.storageSize(); From 29485a77a86145ac34d189372ae5a35e1cec1011 Mon Sep 17 00:00:00 2001 From: Alexandru Ciuca Date: Fri, 2 Oct 2015 19:09:05 +0300 Subject: [PATCH 005/357] material-ui - Also export types in named modules --- material-ui/material-ui-tests.tsx | 23 +-- material-ui/material-ui.d.ts | 292 +++++++++++++++++++----------- 2 files changed, 200 insertions(+), 115 deletions(-) diff --git a/material-ui/material-ui-tests.tsx b/material-ui/material-ui-tests.tsx index 39691caa8..4c69f3410 100644 --- a/material-ui/material-ui-tests.tsx +++ b/material-ui/material-ui-tests.tsx @@ -2,7 +2,7 @@ /// import * as React from "react/addons"; -import mui = require("material-ui"); +import Checkbox = require("material-ui/lib/checkbox"); import Colors = require("material-ui/lib/styles/colors"); import AppBar = require("material-ui/lib/app-bar"); import IconButton = require("material-ui/lib/icon-button"); @@ -27,6 +27,7 @@ import IconMenu = require("material-ui/lib/menus/icon-menu"); import Menu = require('material-ui/lib/menus/menu'); import MenuItem = require('material-ui/lib/menus/menu-item'); import MenuDivider = require('material-ui/lib/menus/menu-divider'); +import ThemeManager = require('material-ui/lib/styles/theme-manager'); import NavigationClose = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/navigation/close", but they aren't defined yet. import FileFolder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/file/folder", but they aren't defined yet. @@ -35,37 +36,37 @@ import ActionGrade = require("material-ui/lib/svg-icon"); // TODO: Should actua import ToggleStarBorder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. import ArrowDropRight = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. +type CheckboxProps = __MaterialUI.CheckboxProps; +type MuiTheme = __MaterialUI.Styles.MuiTheme; +type TouchTapEvent = __MaterialUI.TouchTapEvent; + class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedStateMixin { // injected with mixin linkState: (key: string) => React.ReactLink; - dialog: mui.Dialog; - //dialog2: Dialog; // can't get type directly from require("material-ui/lib/dialog"); + dialog: Dialog; - private touchTapEventHandler(e: __MaterialUI.TouchTapEvent) { + private touchTapEventHandler(e: TouchTapEvent) { this.dialog.show(); - //this.dialog2.show(); } private formEventHandler(e: React.FormEvent) { } - private selectFieldChangeHandler(e: __MaterialUI.TouchTapEvent, si: number, mi: any) { + private selectFieldChangeHandler(e: TouchTapEvent, si: number, mi: any) { } render() { // "http://material-ui.com/#/customization/themes" - let ThemeManager = mui.Styles.ThemeManager; - let muiTheme: mui.Styles.MuiTheme = ThemeManager.getMuiTheme({ + let muiTheme: MuiTheme = ThemeManager.getMuiTheme({ palette: { accent1Color: Colors.cyan100 }, spacing: { - + } }); // "http://material-ui.com/#/customization/inline-styles" - let Checkbox = mui.Checkbox; let element: React.ReactElement; element = implements React.LinkedSta iconStyle={{ fill: '#FF4081' }}/> - element = React.createElement<__MaterialUI.CheckboxProps>(Checkbox, { + element = React.createElement(Checkbox, { id: "checkboxId1", name: "checkboxName1", value: "checkboxValue1", label: "went for a run today", style: { width: '50%', margin: '0 auto' diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index 87bd32a09..3bb7f3762 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -6,8 +6,6 @@ /// declare module "material-ui" { - // The reason for exporting the namespace types (__MaterialUI.*) is to also export the type for casting variable. - export import AppBar = __MaterialUI.AppBar; // require('material-ui/lib/app-bar'); export import AppCanvas = __MaterialUI.AppCanvas; // require('material-ui/lib/app-canvas'); export import Avatar = __MaterialUI.Avatar; // require('material-ui/lib/avatar'); @@ -51,16 +49,7 @@ declare module "material-ui" { export import SelectField = __MaterialUI.SelectField; // require('material-ui/lib/select-field'); export import Slider = __MaterialUI.Slider; // require('material-ui/lib/slider'); export import SvgIcon = __MaterialUI.SvgIcon; // require('material-ui/lib/svg-icon'); - - import NavigationMenu = require('material-ui/lib/svg-icons/navigation/menu'); - import NavigationChevronLeft = require('material-ui/lib/svg-icons/navigation/chevron-left'); - import NavigationChevronRight = require('material-ui/lib/svg-icons/navigation/chevron-right'); - export var Icons: { - NavigationMenu: __MaterialUI.NavigationMenu; - NavigationChevronLeft: __MaterialUI.NavigationChevronLeft; - NavigationChevronRight: __MaterialUI.NavigationChevronRight; - }; - + export import Icons = __MaterialUI.Icons; export import Styles = __MaterialUI.Styles; // require('material-ui/lib/styles/'); export import Snackbar = __MaterialUI.Snackbar; // require('material-ui/lib/snackbar'); export import Tab = __MaterialUI.Tabs.Tab; // require('material-ui/lib/tabs/tab'); @@ -84,9 +73,9 @@ declare module "material-ui" { export import Utils = __MaterialUI.Utils; // require('material-ui/lib/utils/'); // export type definitions - export import TouchTapEvent = __MaterialUI.TouchTapEvent; - export import TouchTapEventHandler = __MaterialUI.TouchTapEventHandler; - export import DialogAction = __MaterialUI.DialogAction; + export type TouchTapEvent = __MaterialUI.TouchTapEvent; + export type TouchTapEventHandler = __MaterialUI.TouchTapEventHandler; + export type DialogAction = __MaterialUI.DialogAction; } declare namespace __MaterialUI { @@ -805,6 +794,12 @@ declare namespace __MaterialUI { export class SvgIcon extends React.Component { } + export namespace Icons { + export import NavigationMenu = __MaterialUI.NavigationMenu; + export import NavigationChevronLeft = __MaterialUI.NavigationChevronLeft; + export import NavigationChevronRight = __MaterialUI.NavigationChevronRight; + } + interface NavigationMenuProps extends React.Props { } export class NavigationMenu extends React.Component { @@ -1478,127 +1473,158 @@ declare namespace __MaterialUI { } // __MaterialUI declare module 'material-ui/lib/app-bar' { - export = __MaterialUI.AppBar; + import AppBar = __MaterialUI.AppBar; + export = AppBar; } declare module 'material-ui/lib/app-canvas' { - export = __MaterialUI.AppCanvas; + import AppCanvas = __MaterialUI.AppCanvas; + export = AppCanvas; } declare module 'material-ui/lib/avatar' { - export = __MaterialUI.Avatar; + import Avatar = __MaterialUI.Avatar; + export = Avatar; } declare module 'material-ui/lib/before-after-wrapper' { - export = __MaterialUI.BeforeAfterWrapper; + import BeforeAfterWrapper = __MaterialUI.BeforeAfterWrapper; + export = BeforeAfterWrapper; } declare module 'material-ui/lib/card/card' { - export = __MaterialUI.Card.Card; + import Card = __MaterialUI.Card.Card; + export = Card; } declare module 'material-ui/lib/card/card-actions' { - export = __MaterialUI.Card.CardActions; + import CardActions = __MaterialUI.Card.CardActions; + export = CardActions; } declare module 'material-ui/lib/card/card-expandable' { - export = __MaterialUI.Card.CardExpandable; + import CardExpandable = __MaterialUI.Card.CardExpandable; + export = CardExpandable; } declare module 'material-ui/lib/card/card-header' { - export = __MaterialUI.Card.CardHeader; + import CardHeader = __MaterialUI.Card.CardHeader; + export = CardHeader; } declare module 'material-ui/lib/card/card-media' { - export = __MaterialUI.Card.CardMedia; + import CardMedia = __MaterialUI.Card.CardMedia; + export = CardMedia; } declare module 'material-ui/lib/card/card-text' { - export = __MaterialUI.Card.CardText; + import CardText = __MaterialUI.Card.CardText; + export = CardText; } declare module 'material-ui/lib/card/card-title' { - export = __MaterialUI.Card.CardTitle; + import CardTitle = __MaterialUI.Card.CardTitle; + export = CardTitle; } declare module 'material-ui/lib/checkbox' { - export = __MaterialUI.Checkbox; + import Checkbox = __MaterialUI.Checkbox; + export = Checkbox; } declare module 'material-ui/lib/circular-progress' { - export = __MaterialUI.CircularProgress; + import CircularProgress = __MaterialUI.CircularProgress; + export = CircularProgress; } declare module 'material-ui/lib/clearfix' { - export = __MaterialUI.ClearFix; + import ClearFix = __MaterialUI.ClearFix; + export = ClearFix; } declare module 'material-ui/lib/date-picker/date-picker' { - export = __MaterialUI.DatePicker.DatePicker; + import DatePicker = __MaterialUI.DatePicker.DatePicker; + export = DatePicker; } declare module 'material-ui/lib/date-picker/date-picker-dialog' { - export = __MaterialUI.DatePicker.DatePickerDialog; + import DatePickerDialog = __MaterialUI.DatePicker.DatePickerDialog; + export = DatePickerDialog; } declare module 'material-ui/lib/dialog' { - export = __MaterialUI.Dialog; + import Dialog = __MaterialUI.Dialog; + export = Dialog; } declare module 'material-ui/lib/drop-down-icon' { - export = __MaterialUI.DropDownIcon; + import DropDownIcon = __MaterialUI.DropDownIcon; + export = DropDownIcon; } declare module 'material-ui/lib/drop-down-menu' { - export = __MaterialUI.DropDownMenu; + import DropDownMenu = __MaterialUI.DropDownMenu; + export = DropDownMenu; } declare module 'material-ui/lib/enhanced-button' { - export = __MaterialUI.EnhancedButton; + import EnhancedButton = __MaterialUI.EnhancedButton; + export = EnhancedButton; } declare module 'material-ui/lib/flat-button' { - export = __MaterialUI.FlatButton; + import FlatButton = __MaterialUI.FlatButton; + export = FlatButton; } declare module 'material-ui/lib/floating-action-button' { - export = __MaterialUI.FloatingActionButton; + import FloatingActionButton = __MaterialUI.FloatingActionButton; + export = FloatingActionButton; } declare module 'material-ui/lib/font-icon' { - export = __MaterialUI.FontIcon; + import FontIcon = __MaterialUI.FontIcon; + export = FontIcon; } declare module 'material-ui/lib/icon-button' { - export = __MaterialUI.IconButton; + import IconButton = __MaterialUI.IconButton; + export = IconButton; } declare module 'material-ui/lib/left-nav' { - export = __MaterialUI.LeftNav; + import LeftNav = __MaterialUI.LeftNav; + export = LeftNav; } declare module 'material-ui/lib/linear-progress' { - export = __MaterialUI.LinearProgress; + import LinearProgress = __MaterialUI.LinearProgress; + export = LinearProgress; } declare module 'material-ui/lib/lists/list' { - export = __MaterialUI.Lists.List; + import List = __MaterialUI.Lists.List; + export = List; } declare module 'material-ui/lib/lists/list-divider' { - export = __MaterialUI.Lists.ListDivider; + import ListDivider = __MaterialUI.Lists.ListDivider; + export = ListDivider; } declare module 'material-ui/lib/lists/list-item' { - export = __MaterialUI.Lists.ListItem; + import ListItem = __MaterialUI.Lists.ListItem; + export = ListItem; } declare module 'material-ui/lib/menu/menu' { - export = __MaterialUI.Menu.Menu; + import Menu = __MaterialUI.Menu.Menu; + export = Menu; } declare module 'material-ui/lib/menu/menu-item' { - export = __MaterialUI.Menu.MenuItem; + import MenuItem = __MaterialUI.Menu.MenuItem; + export = MenuItem; } declare module 'material-ui/lib/mixins/' { @@ -1609,43 +1635,53 @@ declare module 'material-ui/lib/mixins/' { } declare module 'material-ui/lib/mixins/click-awayable' { - export = __MaterialUI.Mixins.ClickAwayable; + import ClickAwayable = __MaterialUI.Mixins.ClickAwayable; + export = ClickAwayable; } declare module 'material-ui/lib/mixins/window-listenable' { - export = __MaterialUI.Mixins.WindowListenable; + import WindowListenable = __MaterialUI.Mixins.WindowListenable; + export = WindowListenable; } declare module 'material-ui/lib/mixins/style-propable' { - export = __MaterialUI.Mixins.StylePropable; + import StylePropable = __MaterialUI.Mixins.StylePropable; + export = StylePropable; } declare module 'material-ui/lib/mixins/style-resizable' { - export = __MaterialUI.Mixins.StyleResizable; + import StyleResizable = __MaterialUI.Mixins.StyleResizable; + export = StyleResizable; } declare module 'material-ui/lib/overlay' { - export = __MaterialUI.Overlay; + import Overlay = __MaterialUI.Overlay; + export = Overlay; } declare module 'material-ui/lib/paper' { - export = __MaterialUI.Paper; + import Paper = __MaterialUI.Paper; + export = Paper; } declare module 'material-ui/lib/radio-button' { - export = __MaterialUI.RadioButton; + import RadioButton = __MaterialUI.RadioButton; + export = RadioButton; } declare module 'material-ui/lib/radio-button-group' { - export = __MaterialUI.RadioButtonGroup; + import RadioButtonGroup = __MaterialUI.RadioButtonGroup; + export = RadioButtonGroup; } declare module 'material-ui/lib/raised-button' { - export = __MaterialUI.RaisedButton; + import RaisedButton = __MaterialUI.RaisedButton; + export = RaisedButton; } declare module 'material-ui/lib/refresh-indicator' { - export = __MaterialUI.RefreshIndicator; + import RefreshIndicator = __MaterialUI.RefreshIndicator; + export = RefreshIndicator; } declare module 'material-ui/lib/ripples/' { @@ -1655,27 +1691,33 @@ declare module 'material-ui/lib/ripples/' { } declare module 'material-ui/lib/select-field' { - export = __MaterialUI.SelectField; + import SelectField = __MaterialUI.SelectField; + export = SelectField; } declare module 'material-ui/lib/slider' { - export = __MaterialUI.Slider; + import Slider = __MaterialUI.Slider; + export = Slider; } declare module 'material-ui/lib/svg-icon' { - export = __MaterialUI.SvgIcon; + import SvgIcon = __MaterialUI.SvgIcon; + export = SvgIcon; } declare module 'material-ui/lib/svg-icons/navigation/menu' { - export = __MaterialUI.NavigationMenu; + import NavigationMenu = __MaterialUI.NavigationMenu; + export = NavigationMenu; } declare module 'material-ui/lib/svg-icons/navigation/chevron-left' { - export = __MaterialUI.NavigationChevronLeft; + import NavigationChevronLeft = __MaterialUI.NavigationChevronLeft; + export = NavigationChevronLeft; } declare module 'material-ui/lib/svg-icons/navigation/chevron-right' { - export = __MaterialUI.NavigationChevronRight; + import NavigationChevronRight = __MaterialUI.NavigationChevronRight; + export = NavigationChevronRight; } declare module 'material-ui/lib/styles/' { @@ -1691,113 +1733,140 @@ declare module 'material-ui/lib/styles/' { } declare module 'material-ui/lib/styles/auto-prefix' { - export = __MaterialUI.Styles.AutoPrefix; + import AutoPrefix = __MaterialUI.Styles.AutoPrefix; + export = AutoPrefix; } declare module 'material-ui/lib/styles/spacing' { - var Spacing: __MaterialUI.Styles.Spacing; + type Spacing = __MaterialUI.Styles.Spacing; + var Spacing: Spacing; export = Spacing; } declare module 'material-ui/lib/styles/theme-manager' { - export = __MaterialUI.Styles.ThemeManager; + import ThemeManager = __MaterialUI.Styles.ThemeManager; + export = ThemeManager; } declare module 'material-ui/lib/styles/transitions' { - export = __MaterialUI.Styles.Transitions; + import Transitions = __MaterialUI.Styles.Transitions; + export = Transitions; } declare module 'material-ui/lib/styles/typography' { - export = __MaterialUI.Styles.Typography; + import Typography = __MaterialUI.Styles.Typography; + export = Typography; } declare module 'material-ui/lib/styles/raw-themes/light-raw-theme' { - export = __MaterialUI.Styles.LightRawTheme; + import LightRawTheme = __MaterialUI.Styles.LightRawTheme; + export = LightRawTheme; } declare module 'material-ui/lib/styles/raw-themes/dark-raw-theme' { - export = __MaterialUI.Styles.DarkRawTheme; + import DarkRawTheme = __MaterialUI.Styles.DarkRawTheme; + export = DarkRawTheme; } declare module 'material-ui/lib/styles/theme-decorator' { - export = __MaterialUI.Styles.ThemeDecorator; + import ThemeDecorator = __MaterialUI.Styles.ThemeDecorator; + export = ThemeDecorator; } declare module 'material-ui/lib/snackbar' { - export = __MaterialUI.Snackbar; + import Snackbar = __MaterialUI.Snackbar; + export = Snackbar; } declare module 'material-ui/lib/tabs/tab' { - export = __MaterialUI.Tabs.Tab; + import Tab = __MaterialUI.Tabs.Tab; + export = Tab; } declare module 'material-ui/lib/tabs/tabs' { - export = __MaterialUI.Tabs.Tabs; + import Tabs = __MaterialUI.Tabs.Tabs; + export = Tabs; } declare module 'material-ui/lib/table/table' { - export = __MaterialUI.Table.Table; + import Table = __MaterialUI.Table.Table; + export = Table; } declare module 'material-ui/lib/table/table-body' { - export = __MaterialUI.Table.TableBody; + import TableBody = __MaterialUI.Table.TableBody; + export = TableBody; } declare module 'material-ui/lib/table/table-footer' { - export = __MaterialUI.Table.TableFooter; + import TableFooter = __MaterialUI.Table.TableFooter; + export = TableFooter; } declare module 'material-ui/lib/table/table-header' { - export = __MaterialUI.Table.TableHeader; + import TableHeader = __MaterialUI.Table.TableHeader; + export = TableHeader; } declare module 'material-ui/lib/table/table-header-column' { - export = __MaterialUI.Table.TableHeaderColumn; + import TableHeaderColumn = __MaterialUI.Table.TableHeaderColumn; + export = TableHeaderColumn; } declare module 'material-ui/lib/table/table-row' { - export = __MaterialUI.Table.TableRow; + import TableRow = __MaterialUI.Table.TableRow; + export = TableRow; } declare module 'material-ui/lib/table/table-row-column' { - export = __MaterialUI.Table.TableRowColumn; + import TableRowColumn = __MaterialUI.Table.TableRowColumn; + export = TableRowColumn; } declare module 'material-ui/lib/theme-wrapper' { - export = __MaterialUI.ThemeWrapper; + import ThemeWrapper = __MaterialUI.ThemeWrapper; + export = ThemeWrapper; } declare module 'material-ui/lib/toggle' { - export = __MaterialUI.Toggle; + import Toggle = __MaterialUI.Toggle; + export = Toggle; } declare module 'material-ui/lib/time-picker' { - export = __MaterialUI.TimePicker; + import TimePicker = __MaterialUI.TimePicker; + export = TimePicker; } declare module 'material-ui/lib/text-field' { - export = __MaterialUI.TextField; + import TextField = __MaterialUI.TextField; + export = TextField; } declare module 'material-ui/lib/toolbar/toolbar' { - export = __MaterialUI.Toolbar.Toolbar; + import Toolbar = __MaterialUI.Toolbar.Toolbar; + export = Toolbar; } declare module 'material-ui/lib/toolbar/toolbar-group' { - export = __MaterialUI.Toolbar.ToolbarGroup; + import ToolbarGroup = __MaterialUI.Toolbar.ToolbarGroup; + export = ToolbarGroup; } declare module 'material-ui/lib/toolbar/toolbar-separator' { - export = __MaterialUI.Toolbar.ToolbarSeparator; + import ToolbarSeparator = __MaterialUI.Toolbar.ToolbarSeparator; + export = ToolbarSeparator; } declare module 'material-ui/lib/toolbar/toolbar-title' { - export = __MaterialUI.Toolbar.ToolbarTitle; + import ToolbarTitle = __MaterialUI.Toolbar.ToolbarTitle; + export = ToolbarTitle; } declare module 'material-ui/lib/tooltip' { - export = __MaterialUI.Tooltip; + import Tooltip = __MaterialUI.Tooltip; + export = Tooltip; } declare module 'material-ui/lib/utils/' { @@ -1814,63 +1883,78 @@ declare module 'material-ui/lib/utils/' { } declare module 'material-ui/lib/utils/color-manipulator' { - export = __MaterialUI.Utils.ColorManipulator; + import ColorManipulator = __MaterialUI.Utils.ColorManipulator; + export = ColorManipulator; } declare module 'material-ui/lib/utils/css-event' { - export = __MaterialUI.Utils.CssEvent; + import CssEvent = __MaterialUI.Utils.CssEvent; + export = CssEvent; } declare module 'material-ui/lib/utils/dom' { - export = __MaterialUI.Utils.Dom; + import Dom = __MaterialUI.Utils.Dom; + export = Dom; } declare module 'material-ui/lib/utils/events' { - export = __MaterialUI.Utils.Events; + import Events = __MaterialUI.Utils.Events; + export = Events; } declare module 'material-ui/lib/utils/extend' { - export = __MaterialUI.Utils.Extend; + import Extend = __MaterialUI.Utils.Extend; + export = Extend; } declare module 'material-ui/lib/utils/immutability-helper' { - export = __MaterialUI.Utils.ImmutabilityHelper; + import ImmutabilityHelper = __MaterialUI.Utils.ImmutabilityHelper; + export = ImmutabilityHelper; } declare module 'material-ui/lib/utils/key-code' { - export = __MaterialUI.Utils.KeyCode; + import KeyCode = __MaterialUI.Utils.KeyCode; + export = KeyCode; } declare module 'material-ui/lib/utils/key-line' { - export = __MaterialUI.Utils.KeyLine; + import KeyLine = __MaterialUI.Utils.KeyLine; + export = KeyLine; } declare module 'material-ui/lib/utils/unique-id' { - export = __MaterialUI.Utils.UniqueId; + import UniqueId = __MaterialUI.Utils.UniqueId; + export = UniqueId; } declare module 'material-ui/lib/utils/styles' { - export = __MaterialUI.Utils.Styles; + import Styles = __MaterialUI.Utils.Styles; + export = Styles; } declare module "material-ui/lib/menus/icon-menu" { - export = __MaterialUI.Menus.IconMenu; + import IconMenu = __MaterialUI.Menus.IconMenu; + export = IconMenu; } declare module "material-ui/lib/menus/menu" { - export = __MaterialUI.Menus.Menu; + import Menu = __MaterialUI.Menus.Menu; + export = Menu; } declare module "material-ui/lib/menus/menu-item" { - export = __MaterialUI.Menus.MenuItem; + import MenuItem = __MaterialUI.Menus.MenuItem; + export = MenuItem; } declare module "material-ui/lib/menus/menu-divider" { - export = __MaterialUI.Menus.MenuDivider; + import MenuDivider = __MaterialUI.Menus.MenuDivider; + export = MenuDivider; } declare module "material-ui/lib/styles/colors" { - export = __MaterialUI.Styles.Colors; + import Colors = __MaterialUI.Styles.Colors; + export = Colors; } declare namespace __MaterialUI.Styles { From da423b45597264225413158966ac1278e5ec62f8 Mon Sep 17 00:00:00 2001 From: Brandon Luong Date: Fri, 2 Oct 2015 16:45:49 -0700 Subject: [PATCH 006/357] add LTS to longDateFormat --- moment/moment-node.d.ts | 2 ++ moment/moment-tests.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/moment/moment-node.d.ts b/moment/moment-node.d.ts index b109893a3..da60a5c53 100644 --- a/moment/moment-node.d.ts +++ b/moment/moment-node.d.ts @@ -343,11 +343,13 @@ declare module moment { LLL: string; LLLL: string; LT: string; + LTS: string; l?: string; ll?: string; lll?: string; llll?: string; lt?: string; + lts?: string; } diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index 29712c115..67724068f 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -378,6 +378,7 @@ moment.locale('en', { moment.locale('en', { longDateFormat : { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", l: "M/D/YYYY", @@ -392,6 +393,7 @@ moment.locale('en', { moment.locale('en', { longDateFormat : { + LTS: "h:mm A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM Do YYYY", From 5570a79a99d6cd990c498abc0b480680fa2d777b Mon Sep 17 00:00:00 2001 From: Brandon Luong Date: Fri, 2 Oct 2015 16:55:58 -0700 Subject: [PATCH 007/357] fixing tests --- moment/moment-external-tests.ts | 3 +++ moment/moment-tests.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/moment/moment-external-tests.ts b/moment/moment-external-tests.ts index ed3e1e2a8..c8108d1b9 100644 --- a/moment/moment-external-tests.ts +++ b/moment/moment-external-tests.ts @@ -255,6 +255,7 @@ moment.locale('en', { weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], weekdaysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], longDateFormat: { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D YYYY", @@ -376,6 +377,7 @@ moment.locale('en', { moment.locale('en', { longDateFormat : { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", l: "M/D/YYYY", @@ -390,6 +392,7 @@ moment.locale('en', { moment.locale('en', { longDateFormat : { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM Do YYYY", diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index 67724068f..26b2f1d0f 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -257,6 +257,7 @@ moment.locale('en', { weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], weekdaysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], longDateFormat: { + LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D YYYY", From 0be6de745e7ed0374ad64299bc5afbc1b3ceb800 Mon Sep 17 00:00:00 2001 From: jessesh Date: Mon, 5 Oct 2015 13:24:59 -0700 Subject: [PATCH 008/357] This commit contains lots of changes to update the WinJS.d.ts file from WinJS 3.X to WinJS 4.4 --- winjs/winjs.d.ts | 3293 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 2473 insertions(+), 820 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 195ecb66e..acf6802bf 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -4,18 +4,12 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /* ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. +Copyright (c) Microsoft Corporation. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************** */ /** @@ -58,6 +52,11 @@ interface IOHelper { * @returns A promise that is completed when the file has been written. **/ writeText(fileName: string, text: string): WinJS.Promise; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + storage: any; } /** @@ -88,16 +87,6 @@ declare module WinJS.Application { //#endregion Objects - //#region Methods - - /** - * Informs the application object that asynchronous work is being performed, and that this event handler should not be considered complete until the promise completes. This function can be set inside the handlers for all WinJS.Application events: onactivated oncheckpoint onerror onloaded onready onsettings onunload. - * @param promise The promise that should complete before processing is complete. - **/ - function setPromise(promise: Promise): void; - - //#endregion Methods - //#region Functions /** @@ -141,47 +130,61 @@ declare module WinJS.Application { //#region Events + interface IPromiseEvent extends CustomEvent { + /** + * Informs the application object that asynchronous work is being performed, and that this event handler should not be considered complete until the promise completes. This function can be set inside the handlers for all WinJS.Application events: onactivated oncheckpoint onerror onloaded onready onsettings onunload. + * @param promise The promise that should complete before processing is complete. + **/ + setPromise(promise: IPromise): void; + } + /** * Occurs when WinRT activation has occurred. The name of this event is "activated" (and also "mainwindowactivated"). This event occurs after the loaded event and before the ready event. * @param eventInfo An object that contains information about the event. For more information about event arguments, see the WinRT event argument classes: WebUICachedFileUpdaterActivatedEventArgs, WebUICameraSettingsActivatedEventArgs, WebUIContactPickerActivatedEventArgs, WebUIDeviceActivatedEventArgs, WebUIFileActivatedEventArgs, WebUIFileOpenPickerActivatedEventArgs, WebUIFileSavePickerActivatedEventArgs, WebUILaunchActivatedEventArgs, WebUIPrintTaskSettingsActivatedEventArgs, WebUIProtocolActivatedEventArgs, WebUISearchActivatedEventArgs, WebUIShareTargetActivatedEventArgs. **/ - function onactivated(eventInfo: CustomEvent): void; + function onactivated(eventInfo: IPromiseEvent): void; /** * Occurs when receiving PLM notification or when the checkpoint function is called. * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise. **/ - function oncheckpoint(eventInfo: CustomEvent): void; + function oncheckpoint(eventInfo: IPromiseEvent): void; /** * Occurs when an unhandled error has been raised. * @param eventInfo An object that contains information about the event. **/ - function onerror(eventInfo: CustomEvent): void; + function onerror(eventInfo: IPromiseEvent): void; /** * Occurs after the DOMContentLoaded event, which fires after the page has been parsed but before all the resources are loaded. This event occurs before the activated event and the ready event. * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: type, setPromise. **/ - function onloaded(eventInfo: CustomEvent): void; + function onloaded(eventInfo: IPromiseEvent): void; /** * Occurs when the application is ready. This event occurs after the loaded event and the activated event. * @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise. **/ - function onready(eventInfo: CustomEvent): void; + function onready(eventInfo: IPromiseEvent): void; /** * Occurs when the settings charm is invoked. * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: type, applicationcommands. **/ - function onsettings(eventInfo: CustomEvent): void; + function onsettings(eventInfo: IPromiseEvent): void; /** * Occurs when the application is about to be unloaded. * @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type, setPromise. **/ - function onunload(eventInfo: CustomEvent): void; + function onunload(eventInfo: IPromiseEvent): void; + + /** + * Occurs whenever a user clicks the hardware backbutton. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following sub-properties: type + **/ + function onbackclick(eventInfo: IPromiseEvent): void; //#endregion Events @@ -192,11 +195,6 @@ declare module WinJS.Application { declare module WinJS.Binding { //#region Properties - /** - * Determines whether or not binding should automatically set the ID of an element. This property should be set to true in apps that use WinJS (WinJS) binding. - **/ - var optimizeBindingReferences: boolean; - //#endregion Properties //#region Objects @@ -276,7 +274,7 @@ declare module WinJS.Binding { /** * Do not instantiate. A list returned by the createFiltered method. **/ - class FilteredListProjection extends ListProjection { + interface FilteredListProjection extends ListProjection { //#region Methods /** @@ -320,9 +318,9 @@ declare module WinJS.Binding { } /** - * Do not instantiate. A list of groups. + * A list of groups. **/ - class GroupsListProjection extends ListBase { + interface GroupsListProjection extends ListBase { //#region Methods /** @@ -362,13 +360,13 @@ declare module WinJS.Binding { /** * Do not instantiate. Sorts the underlying list by group key and within a group respects the position of the item in the underlying list. Returned by createGrouped. **/ - class GroupedSortedListProjection extends SortedListProjection { + interface GroupedSortedListProjection extends SortedListProjection { //#region Properties /** * Gets a List, which is a projection of the groups that were identified in this list. **/ - groups: GroupsListProjection; + groups: GroupsListProjection; //#endregion Properties @@ -383,12 +381,12 @@ declare module WinJS.Binding { /** * Represents a list of objects that can be accessed by index or by a string key. Provides methods to search, sort, filter, and manipulate the data. **/ - class List extends ListBaseWithMutators { + class List implements ListBaseWithMutators { //#region Constructors /** * Creates a List object. - * @constructor + * @constructor * @param list The array containing the elements to initalize the list. * @param options You can set two Boolean options: binding and proxy. If options.binding is true, the list contains the result of calling as on the element values. If options.proxy is true, the list specified as the first parameter is used as the storage for the List. This option should be used with care, because uncoordinated edits to the data storage may result in errors. **/ @@ -396,86 +394,6 @@ declare module WinJS.Binding { //#endregion Constructors - //#region Methods - - /** - * Gets a key/data pair for the specified list index. - * @param index The index of value to retrieve. - * @returns An object with .key and .data properties. - **/ - getItem(index: number): IKeyDataPair; - - /** - * Gets a key/data pair for the list item key specified. - * @param key The key of the value to retrieve. - * @returns An object with .key and .data properties. - **/ - getItemFromKey(key: string): IKeyDataPair; - - /** - * Gets the index of the first occurrence of a key in a list. - * @param key The key to locate in the list. - * @returns The index of the first occurrence of a key in a list, or -1 if not found. - **/ - indexOfKey(key: string): number; - - /** - * Moves the value at index to the specified position. - * @param index The original index of the value. - * @param newIndex The index of the value after the move. - **/ - move(index: number, newIndex: number): void; - - /** - * Forces the list to send a itemmutated notification to any listeners for the value at the specified index. - * @param index The index of the value that was mutated. - **/ - notifyMutated(index: number): void; - - /** - * Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution. - **/ - reverse(): void; - - /** - * Replaces the value at the specified index with a new value. - * @param index The index of the value that was replaced. - * @param newValue The new value. - **/ - setAt(index: number, newValue: T): void; - - /** - * Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution. - * @param sortFunction The function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. - **/ - sort(sortFunction?: (left: T, right: T) => number): void; - - /** - * Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the list from which to start removing elements. - * @param howMany The number of elements to remove. - * @param item The elements to insert into the list in place of the deleted elements. - * @returns The deleted elements. - **/ - splice(start: number, howMany?: number, ...item: T[]): T[]; - - //#endregion Methods - - //#region Properties - - /** - * Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list. - **/ - length: number; - - //#endregion Properties - - } - - /** - * Represents a base class for lists. - **/ - class ListBase { //#region Events /** @@ -555,7 +473,341 @@ declare module WinJS.Binding { * @param groupSorter A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after). * @returns A grouped projection over the list. **/ - createGrouped(groupKey: (x: T) => string, groupData: (x: T) => any, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection; + createGrouped(groupKey: (x: T) => string, groupData: (x: T) => G, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection; + + /** + * Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change. + * @param sorter A function that accepts two arguments. The function is called with elements in the list. It must return one of the following numeric values: negative if the first argument is less than the second, zero if the two arguments are equivalent, positive if the first argument is greater than the second. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @returns A sorted projection over the list. + **/ + createSorted(sorter: (left: T, right: T) => number): SortedListProjection; + + /** + * Raises an event of the specified type and with the specified additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Checks whether the specified callback function returns true for all elements in a list. + * @param callback A function that accepts up to three arguments. This function is called for each element in the list until it returns false or the end of the list is reached. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns true if the callback returns true for all elements in the list. + **/ + every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Returns the elements of a list that meet the condition specified in a callback function. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns An array containing the elements that meet the condition specified in the callback function. + **/ + filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; + + /** + * Calls the specified callback function for each element in a list. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows: value, index, array. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + **/ + forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + /** + * Gets the value at the specified index. + * @param index The index of the value to get. + * @returns The value at the specified index. + **/ + getAt(index: number): T; + + /** + * Gets a key/data pair for the specified list index. + * @param index The index of value to retrieve. + * @returns An object with .key and .data properties. + **/ + getItem(index: number): IKeyDataPair; + + /** + * Gets a key/data pair for the list item key specified. + * @param key The key of the value to retrieve. + * @returns An object with .key and .data properties. + **/ + getItemFromKey(key: string): IKeyDataPair; + + /** + * Gets the index of the first occurrence of the specified value in a list. + * @param searchElement The value to locate in the list. + * @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + * @returns The index of the first occurrence of a value in a list or -1 if not found. + **/ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Gets the index of the first occurrence of a key in a list. + * @param key The key to locate in the list. + * @returns The index of the first occurrence of a key in a list, or -1 if not found. + **/ + indexOfKey(key: string): number; + + /** + * Returns a string consisting of all the elements of a list separated by the specified separator string. + * @param separator A string used to separate the elements of a list. If this parameter is omitted, the list elements are separated with a comma. + * @returns The elements of a list separated by the specified separator string. + **/ + join(separator?: string): string; + + /** + * Gets the index of the last occurrence of the specified value in a list. + * @param searchElement The value to locate in the list. + * @param fromIndex The index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the list. + * @returns The index of the last occurrence of a value in a list, or -1 if not found. + **/ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Calls the specified callback function on each element of a list, and returns an array that contains the results. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list. + * @param thisArg n object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns An array containing the result of calling the callback function on each element in the list. + **/ + map(callback: (value: T, index: number, array: T[]) => G, thisArg?: any): G[]; + + /** + * Moves the value at index to the specified position. + * @param index The original index of the value. + * @param newIndex The index of the value after the move. + **/ + move(index: number, newIndex: number): void; + + /** + * Notifies listeners that a property value was updated. + * @param name The name of the property that is being updated. + * @param newValue The new value for the property. + * @param oldValue The old value for the property. + * @returns A promise that is completed when the notifications are complete. + **/ + notify(name: string, newValue: any, oldValue: any): Promise; + + /** + * Forces the list to send a itemmutated notification to any listeners for the value at the specified index. + * @param index The index of the value that was mutated. + **/ + notifyMutated(index: number): void; + + /** + * Forces the list to send a reload notification to any listeners. + **/ + notifyReload(): void; + + /** + * Removes the last element from a list and returns it. + * @returns The last element from the list. + **/ + pop(): T; + + /** + * Appends new element(s) to a list, and returns the new length of the list. + * @param value The element to insert at the end of the list. + * @returns The new length of the list. + **/ + push(value: T): number; + push(...values: T[]): number; + + /** + * Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list. + * @param initiallValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the function provides this value as an argument instead of a list value. + * @returns The return value from the last call to the callback function. + **/ + reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initiallValue?: T): T; + + /** + * Accumulates a single result by calling the specified callback function for all elements in a list, starting with the last member of the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callback A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list. + * @param initialValue If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value. + * @returns The return value from the last call to callback function. + **/ + reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initialValue?: T): T; + + /** + * Removes an event listener from the control. + * @param type The type (name) of the event. + * @param listener The listener to remove. + * @param useCapture true if capture is to be initiated, otherwise false. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Returns a list with the elements reversed. This method reverses the elements of a list object in place. It does not create a new list object during execution. + **/ + reverse(): void; + + /** + * Replaces the value at the specified index with a new value. + * @param index The index of the value that was replaced. + * @param newValue The new value. + **/ + setAt(index: number, newValue: T): void; + + /** + * Removes the first element from a list and returns it. + * @returns The first element from the list. + **/ + shift(): T; + + /** + * Extracts a section of a list and returns a new list. + * @param begin The index that specifies the beginning of the section. + * @param end The index that specifies the end of the section. + * @returns Returns a section of list. + **/ + slice(begin: number, end?: number): T[]; + + /** + * Checks whether the specified callback function returns true for any element of a list. + * @param callback A function that accepts up to three arguments. The function is called for each element in the list until it returns true, or until the end of the list. + * @param thisArg An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used. + * @returns true if callback returns true for any element in the list. + **/ + some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Returns a list with the elements sorted. This method sorts the elements of a list object in place. It does not create a new list object during execution. + * @param sortFunction The function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + **/ + sort(sortFunction?: (left: T, right: T) => number): void; + + /** + * Removes elements from a list and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the list from which to start removing elements. + * @param howMany The number of elements to remove. + * @param item The elements to insert into the list in place of the deleted elements. + * @returns The deleted elements. + **/ + splice(start: number, howMany?: number, ...item: T[]): T[]; + + /** + * Removes one or more listeners from the notification list for a given property. + * @param name The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed. + * @param action The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property. + * @returns This object is returned. + **/ + unbind(name: string, action: Function): any; + + /** + * Appends new element(s) to a list, and returns the new length of the list. + * @param value The element to insert at the start of the list. + * @returns The new length of the list. + **/ + unshift(value: T): number; + unshift(...values: T[]): number; + + //#endregion Methods + + //#region Properties + + /** + * Gets the IListDataSource for the list. The only purpose of this property is to adapt a List to the data model that is used by ListView and FlipView. + **/ + dataSource: WinJS.UI.IListDataSource; + + /** + * Gets or sets the length of the list, which is an integer value one higher than the highest element defined in the list. + **/ + length: number; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } + + /** + * Represents a base class for lists. + **/ + interface ListBase { + //#region Events + + /** + * An item in the list has changed its value. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, newItem, newValue, oldItem, oldValue. + **/ + onitemchanged(eventInfo: CustomEvent): void; + + /** + * A new item has been inserted into the list. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + oniteminserted(eventInfo: CustomEvent): void; + + /** + * An item has been changed locations in the list. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + onitemmoved(eventInfo: CustomEvent): void; + + /** + * An item has been mutated. This event occurs as a result of calling the notifyMutated method. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + onitemmutated(eventInfo: CustomEvent): void; + + /** + * An item has been removed from the list. + * @param eventInfo An object that contains information about the event. The detail contains the following information: index, key, value. + **/ + onitemremoved(eventInfo: CustomEvent): void; + + /** + * The list has been refreshed. Any references to items in the list may be incorrect. + * @param eventInfo An object that contains information about the event. The detail property of this object is null. + **/ + onreload(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Adds an event listener to the control. + * @param type The type (name) of the event. + * @param listener The listener to invoke when the event gets raised. + * @param useCapture If true, initiates capture, otherwise false. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action. + * @param name The name of the property to which to bind the action. + * @param action The function to invoke asynchronously when the property may have changed. + * @returns A reference to this observableMixin object. + **/ + bind(name: string, action: Function): any; + + /** + * Returns a new list consisting of a combination of two arrays. + * @param item Additional items to add to the end of the list. + * @returns An array containing the concatenation of the list and any other supplied items. + **/ + concat(...item: T[]): T[]; + + /** + * Creates a live filtered projection over this list. As the list changes, the filtered projection reacts to those changes and may also change. + * @param predicate A function that accepts a single argument. The createFiltered function calls the callback with each element in the list. If the function returns true, that element will be included in the filtered list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @returns A filtered projection over the list. + **/ + createFiltered(predicate: (x: T) => boolean): FilteredListProjection; + + /** + * Creates a live grouped projection over this list. As the list changes, the grouped projection reacts to those changes and may also change. The grouped projection sorts all the elements of the list to be in group-contiguous order. The grouped projection also contains a .groups property, which is a List representing the groups that were found in the list. + * @param groupKey A function that accepts a single argument. The function is called with each element in the list, the function should return a string representing the group containing the element. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications. + * @param groupData A function that accepts a single argument. The function is called once, on one element per group. It should return the value that should be set as the data of the .groups list element for this group. The data value usually serves as summary or header information for the group. + * @param groupSorter A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after). + * @returns A grouped projection over the list. + **/ + createGrouped(groupKey: (x: T) => string, groupData: (x: T) => G, groupSorter?: (left: string, right: string) => number): GroupedSortedListProjection; /** * Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change. @@ -704,18 +956,13 @@ declare module WinJS.Binding { **/ dataSource: WinJS.UI.IListDataSource; - /** - * Indicates that the object is compatibile with declarative processing. - **/ - static supportedForProcessing: boolean; - //#endregion Properties } /** * Represents a base class for normal list modifying operations. **/ - class ListBaseWithMutators extends ListBase { + interface ListBaseWithMutators extends ListBase { //#region Methods /** @@ -752,7 +999,7 @@ declare module WinJS.Binding { /** * Represents a base class for list projections. **/ - class ListProjection extends ListBaseWithMutators { + interface ListProjection extends ListBaseWithMutators { //#region Methods /** @@ -897,7 +1144,7 @@ declare module WinJS.Binding { /** * Do not instantiate. Returned by the createSorted method. **/ - class SortedListProjection extends ListProjection { + interface SortedListProjection extends ListProjection { //#region Methods /** @@ -948,30 +1195,35 @@ declare module WinJS.Binding { /** * Creates a template that provides a reusable declarative binding element. - * @constructor + * @constructor * @param element The DOM element to convert to a template. * @param options If this parameter is supplied, the template is loaded from the URI and the content of the element parameter is ignored. You can add the following options: href. **/ - constructor(element: HTMLElement, options?:any); + constructor(element: HTMLElement, options?: any); //#endregion Constructors //#region Methods /** - * Binds values from the specified data context to elements that are descendants of the specified root element that have the declarative binding attributes specified (data-win-bind). - * @param dataContext The object to use for default data binding. - * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. - * @returns A Promise that will be completed after binding has finished. The value is either container or the created DIV. promise that is completed after binding has finished. + * Binds values from the specified data context to elements that are descendants of the specified root element that have the declarative binding attributes specified (data-win-bind). + * @param dataContext The object to use for default data binding. + * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. + * @returns A Promise that will be completed after binding has finished. The value is either container or the created DIV. promise that is completed after binding has finished. **/ render(dataContext: any, container?: HTMLElement): Promise; /** - * Renders a template based on the specified URI (static method). - * @param href The URI from which to load the template. - * @param dataContext The object to use for default data binding. - * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. - * @returns A promise that is completed after binding has finished. The value is either the object in the container parameter or the created DIV. + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. Use render instead. + **/ + renderItem(item: WinJS.Promise, recyled: HTMLElement): { element: WinJS.Promise; renderComplete: WinJS.Promise; }; + + /** + * Renders a template based on the specified URI (static method). + * @param href The URI from which to load the template. + * @param dataContext The object to use for default data binding. + * @param container The element to which to add this rendered template. If this parameter is omitted, a new DIV is created. + * @returns A promise that is completed after binding has finished. The value is either the object in the container parameter or the created DIV. **/ static render(href: string, dataContext: any, container?: HTMLElement): Promise; @@ -1004,10 +1256,21 @@ declare module WinJS.Binding { **/ extractChild: boolean; + /** + * Gets or sets the Number of milliseconds to delay instantiating declarative controls. Zero (0) will result in no delay, any negative number + * will result in a setImmediate delay, any positive number will be treated as the number of milliseconds. + **/ + processTimeout: number; + /** * Determines whether the Template contains declarative controls that must be processed separately. This property is always true. The controls that belong to a Template object's children are instantiated when a Template instance is rendered. **/ - isDeclarativeControlContainer: boolean; + static isDeclarativeControlContainer: boolean; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; //#endregion Properties @@ -1071,6 +1334,11 @@ declare module WinJS.Binding { **/ function expandProperties(shape: any): any; + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + function getValue(obj: any, path?: any) + /** * Marks a custom initializer function as being compatible with declarative data binding. * @param customInitializer The custom initializer to be marked as compatible with declarative data binding. @@ -1078,15 +1346,6 @@ declare module WinJS.Binding { **/ function initializer(customInitializer: Function): Function; - /** - * Notifies listeners that a property value was updated. - * @param name The name of the property that is being updated. - * @param newValue The new value for the property. - * @param oldValue The old value for the property. - * @returns A promise that is completed when the notifications are complete. - **/ - function notify(name: string, newValue: string, oldValue: string): Promise; - /** * Sets the destination property to the value of the source property. * @param source The source object. @@ -1211,7 +1470,7 @@ declare module WinJS { /** * Creates an Error object with the specified name and message properties. - * @constructor + * @constructor * @param name The name of this error. The name is meant to be consumed programmatically and should not be localized. * @param message The message for this error. The message is meant to be consumed by humans and should be localized. **/ @@ -1219,6 +1478,15 @@ declare module WinJS { //#endregion Constructors + //#region Properties + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } interface IPromise { @@ -1243,7 +1511,7 @@ declare module WinJS { /** * A promise provides a mechanism to schedule work to be done on a value that has not yet been computed. It is a convenient abstraction for managing interactions with asynchronous APIs. For more information about asynchronous programming, see Asynchronous programming. For more information about promises in JavaScript, see Asynchronous programming in JavaScript. For more information about using promises, see the WinJS Promise sample. - * @constructor + * @constructor * @param init The function that is called during construction of the Promise that contains the implementation of the operation that the Promise will represent. This can be synchronous or asynchronous, depending on the nature of the operation. Note that placing code within this function does not automatically run it asynchronously; that must be done explicitly with other asynchronous APIs such as setImmediate, setTimeout, requestAnimationFrame, and the Windows Runtime asynchronous APIs. The init function is given three arguments: completeDispatch, errorDispatch, progressDispatch. This parameter is optional. * @param onCancel The function to call if a consumer of this promise wants to cancel its undone work. Promises are not required to support cancellation. **/ @@ -1460,6 +1728,15 @@ declare module WinJS { //#endregion Methods + //#region Properties + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } //#endregion Objects @@ -1473,12 +1750,7 @@ declare module WinJS { * @param type The type of message (error, warning, info, etc.). **/ function log(message: string, tags?: string, type?: string): void; - function log(message: ()=>string, tags?: string, type?: string): void; - - /** - * This method has been deprecated. Strict processing is always on; you don't have to call this method to turn it on. - **/ - function strictProcessing(): void; + function log(message: () => string, tags?: string, type?: string): void; /** * Wraps calls to XMLHttpRequest in a promise. @@ -1499,7 +1771,7 @@ declare module WinJS { headers?: any; data?: any; responseType?: string; - customRequestInitializer?:(request: XMLHttpRequest) => void; + customRequestInitializer?: (request: XMLHttpRequest) => void; } //#endregion Interfaces @@ -1692,7 +1964,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that adds an item or items to a list. * @param added Element or elements to add to the list. - * @param affected Element or elements affected by the added items. + * @param affected Element or elements affected by the added items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createAddToListAnimation(added: any, affected: any): IAnimationMethodResponse; @@ -1700,7 +1972,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that adds an item or items to a list of search results. * @param added Element or elements to add to the list. - * @param affected Element or elements affected by the added items. + * @param affected Element or elements affected by the added items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createAddToSearchListAnimation(added: any, affected: any): IAnimationMethodResponse; @@ -1708,7 +1980,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that collapses a list. * @param hidden Element or elements hidden as a result of the collapse. - * @param affected Element or elements affected by the hidden items. + * @param affected Element or elements affected by the hidden items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createCollapseAnimation(hidden: any, affected: any): IAnimationMethodResponse; @@ -1716,7 +1988,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that removes an item or items from a list. * @param deleted Element or elements to delete from the list. - * @param remaining Element or elements affected by the removal of the deleted items. + * @param remaining Element or elements affected by the removal of the deleted items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createDeleteFromListAnimation(deleted: any, remaining: any): IAnimationMethodResponse; @@ -1724,7 +1996,7 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that removes an item or items from a list of search results. * @param deleted Element or elements to delete from the list. - * @param remaining Element or elements affected by the removal of the deleted items. + * @param remaining Element or elements affected by the removal of the deleted items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createDeleteFromSearchListAnimation(deleted: any, remaining: any): IAnimationMethodResponse; @@ -1732,11 +2004,21 @@ declare module WinJS.UI.Animation { /** * Creates an object that performs an animation that expands a list. * @param revealed Element or elements revealed by the expansion. - * @param affected Element or elements affected by the newly revealed items. + * @param affected Element or elements affected by the newly revealed items. Typically, this is all other items displayed in the list. * @returns An object whose execute method is used to execute the animation. The execute method returns a Promise that completes when the animation is finished. **/ function createExpandAnimation(revealed: any, affected: any): IAnimationMethodResponse; + /** + * Creates an exit and entrance animation to play for a page navigation given the current and incoming pages' + * animation preferences and whether the pages are navigating forwards or backwards. + * @param currentPreferredAnimation A value from WinJS.UI.PageNavigationAnimation describing the animation the current page prefers to use. + * @param A value from nextPreferredAnimation WinJS.UI.PageNavigationAnimation describing the animation the incoming page prefers to use. + * @param movingBackwards Boolean value for whether the navigation is moving backwards. + * @returns an object containing the exit and entrance animations to play based on the parameters given. + **/ + function createPageNavigationAnimations(currentPreferredAnimation: string, nextPreferredAnimation: string, movingBackwards: boolean): { exit: Function; entrance: Function }; + /** * Creates an object that performs a peek animation. * @param element Element or elements involved in the peek. @@ -1791,6 +2073,34 @@ declare module WinJS.UI.Animation { **/ function dragSourceStart(dragSource: any, affected?: any): Promise; + /** + * Execute the incoming phase of the drill in animation, scaling up the incoming page while fading it in. + * @param incomingPage Element to be scaled up and faded in. + * @returns Promise object that completes when the animation is complete. + **/ + function drillInIncoming(incomingPage: HTMLElement): Promise; + + /** + * Execute the outgoing phase of the drill in animation, scaling up the outgoing page while fading it out. + * @param incomingPage Element to be scaled up and faded out. + * @returns Promise object that completes when the animation is complete. + **/ + function drillInOutgoing(outgoingPage: HTMLElement): Promise; + + /** + * Execute the incoming phase of the drill out animation, scaling down the incoming page while fading it in. + * @param incomingPage Element to be scaled up and faded in. + * @returns Promise object that completes when the animation is complete. + **/ + function drillOutIncoming(incomingPage: HTMLElement): Promise; + + /** + * Execute the outgoing phase of the drill out animation, scaling down the outgoing page while fading it out. + * @param outgoingPage Element to be scaled down and faded out. + * @returns Promise object that completes when the animation is complete. + **/ + function drillOutOutgoing(outgoingPage: HTMLElement): Promise; + /** * Performs an animation that displays one or more elements on a page. * @param incoming Element or elements that compose the incoming content. @@ -2264,7 +2574,8 @@ declare module WinJS.UI { threebars, fourbars, scan, - preview + preview, + hamburger } /** @@ -2313,6 +2624,10 @@ declare module WinJS.UI { * The edit operation timed out. **/ noResponse, + /** + * The edit operation was canceled. + **/ + canceled, /** * The data source cannot be written to. **/ @@ -2390,7 +2705,15 @@ declare module WinJS.UI { /** * The object is an item in the list. **/ - item + item, + /** + * The object is the header for the list. + **/ + header, + /** + * The object is the footer for the list. + **/ + footer } /** @@ -2461,10 +2784,147 @@ declare module WinJS.UI { none } + /** + * Specifies what animation type should be returned by WinJS.UI.Animation.createPageNavigationAnimations. + **/ + enum PageNavigationAnimation { + /** + * The pages will exit and enter using a turnstile animation. + **/ + turnstile, + /** + * The pages will exit and enter using an animation that slides up/down. + **/ + slide, + /** + * The pages will enter using an enterPage animation, and exit with no animation. + **/ + enterPage, + /** + * The pages will exit and enter using a continuum animation. + **/ + continuum, + } + //#endregion Enumerations //#region Interfaces + /** + * Define the shape of a Command object to be used in AppBar and ToolBar controls. + **/ + export interface ICommand { + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Releases resources held by this ICommand. Call this method when the ICommand is no longer needed. After calling this method, the ICommand becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets a value that indicates whether the ICommand is disabled. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the ICommand. + **/ + element: HTMLElement; + + /** + * Adds an extra CSS class during construction. + **/ + extraClass: string; + + /** + * Gets or sets the HTMLElement with a 'content' type ICommand that should receive focus whenever focus moves by the user pressing HOME or the arrow keys, from the previous ICommand to this ICommand. + **/ + firstElementFocus: HTMLElement; + + /** + * Gets or sets the Flyout object displayed by this command. The specified flyout is shown when the ICommand's button is invoked. + **/ + flyout: Flyout; + + /** + * Gets or sets a value that indicates whether the ICommand is hiding or in the process of becoming hidden. + **/ + hidden: boolean; + + /** + * Gets or sets the icon of the ICommand. + **/ + icon: string; + + /** + * Gets the element identifier (ID) of the command. + **/ + id: string; + + /** + * Gets or sets the label of the command. + **/ + label: string; + + /** + * Gets or sets the HTMLElement with a 'content' type ICommand that should receive focus whenever focus moves by the user pressing END or the arrow keys, from the previous Command to this Command. + **/ + lastElementFocus: HTMLElement; + + /** + * Gets or sets the function to be invoked when the command is clicked. + **/ + onclick: Function; + + /** + * Gets the section of the parent control that the command is in. The section can only be set through constructor options. + **/ + section: string; + + /** + * Gets or sets the selected state of a toggle button. + **/ + selected: boolean; + + /** + * Gets or sets the tooltip of the command. + **/ + tooltip: string; + + /** + * Gets the type of the command. The type can only be set through constructor options. + **/ + type: string; + + /** + * Gets or sets the priority of the command. + **/ + priority: number; + + //#endregion Properties + } + + /** * Contains items that were requested from an IListDataAdapter and provides some information about those items. **/ @@ -2575,145 +3035,6 @@ declare module WinJS.UI { } - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. Represents a layout for the ListView. - **/ - interface ILayout { - //#region Methods - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param beginScrollPosition The first visible pixel in the ListView. For horizontal layouts, this is the x-coordinate of the pixel. For vertical layouts, this is the y-coordinate. - * @param wholeItem true if the item must be completely visible; otherwise, false if its ok for the item to be partially visible. Promise. - * @returns A Promise for the index of the first visible item at the specified point. - **/ - calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param endScrollPosition The last visible pixel in the ListView. For horizontal layouts, this is the x-coordinate of the pixel. For vertical layouts, this is the y-coordinate. - * @param wholeItem true if the item must be completely visible; otherwise, false if its ok for the item to be partially visible. Promise. - * @returns A Promise for the index of the last visible item at the specified point. - **/ - calculateLastVisible(endScrollPosition: number, wholeItem: boolean): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @returns A object that has these properties: animationPromise, newEndIndex. - **/ - endLayout(): any; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param itemIndex The index of the item. - * @returns A Promise that returns an object with these properties: left, top, contentWidth, contentHeight, totalWidth, totalHeight. - **/ - getItemPosition(itemIndex: number): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param itemIndex The data source index of the current item. - * @param element The element for the current item. - * @param keyPressed The key that was pressed. This function must check for the arrow keys (leftArrow, upArrow, rightArrow, downArrow), pageDown, and pageUp and determine which item the user navigated to. - * @returns A Promise that contains the index of the next item (This item becomes the current item). - **/ - getKeyboardNavigatedItem(itemIndex: number, element: HTMLElement, keyPressed: WinJS.Utilities.Key): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @returns A Promise that returns an object that has these properties: beginScrollPosition, endScrollPosition. - **/ - getScrollBarRange(): Promise; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param x The x-coordinate to test. - * @param y The y-coordinate to test. - **/ - hitTest(x: number, y: number): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param elements The elements that represent the items that were added. - **/ - itemsAdded(elements: HTMLElement[]): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - **/ - itemsMoved(): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param elements The elements that represent the items that were removed. - **/ - itemsRemoved(elements: HTMLElement[]): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param groupIndex The index of the group in the group data source. - * @param element The element to render for the group header. - **/ - layoutHeader(groupIndex: number, element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param itemIndex The index of the item in the data source. - * @param element The element to render for the item. - **/ - layoutItem(itemIndex: number, element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param element The element that represents a header in the data source. - **/ - prepareHeader(element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param element An element that represents an item in the data source. - **/ - prepareItem(element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param element The element being released. - **/ - releaseItem(element: HTMLElement): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - **/ - reset(): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param site The layout site for the layout. You can use this object to query the hosting ListView for info you might need to lay out items. - **/ - setSite(site: ILayoutSite): void; - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - * @param beginScrollPosition The starting pixel of the area to which the items are rendered. - * @param endScrollPosition The last pixel of the area to which the items are rendered. - * @param count The upper bound of the number of items to render. - * @returns A Promise that returns an object that has these properties: beginIndex, endIndex. - **/ - startLayout(beginScrollPosition: number, endScrollPosition: number, count: number): Promise; - - //#endregion Methods - - //#region Properties - - /** - * This API is no longer supported. Starting with the Windows Library for JavaScript 2.0 Preview, use the ILayout2 interface. - **/ - horizontal: boolean; - - //#endregion Properties - - } - /** * Represents a layout for the ListView. **/ @@ -3613,14 +3934,15 @@ declare module WinJS.UI { //#region Objects /** - * Represents an application toolbar for displaying commands. + * Displays ICommands in overlayed application pane that opens and closes at the top or bottom of the main view. **/ class AppBar { + //#region Constructors /** * Creates a new AppBar object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new AppBar. **/ @@ -3631,28 +3953,28 @@ declare module WinJS.UI { //#region Events /** - * Occurs immediately after the AppBar is hidden. + * Occurs immediately after the AppBar is closed. * @param eventInfo An object that contains information about the event. **/ - onafterhide(eventInfo: Event): void; + onafterclose: (eventInfo: CustomEvent) => void; /** - * Occurs after the AppBar is shown. + * Occurs immeidately after the AppBar is opened. * @param eventInfo An object that contains information about the event. **/ - onaftershow(eventInfo: Event): void; + onafteropen: (eventInfo: CustomEvent) => void; /** - * Occurs before the AppBar is hidden. + * Occurs immediately before the AppBar is closed. Is cancelable. * @param eventInfo An object that contains information about the event. **/ - onbeforehide(eventInfo: Event): void; + onbeforeclose: (eventInfo: CustomEvent) => void; /** - * Occurs before a hidden AppBar is shown. + * Occurs immediately before the AppBar is opened. Is cancelable. * @param eventInfo An object that contains information about the event. **/ - onbeforeshow(eventInfo: Event): void; + onbeforeopen: (eventInfo: CustomEvent) => void; //#endregion Events @@ -3660,11 +3982,19 @@ declare module WinJS.UI { /** * Registers an event handler for the specified event. - * @param type The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param type The event type to register. It must be beforeopen, beforeclose, afteropen, or afterclose. * @param listener The event handler function to associate with the event. * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. **/ - addEventListener(type: string, listener: Function, useCapture?: boolean): void; + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeopen, beforeclose, afteropen, or afterclose. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; /** * Raises an event of the specified type and with additional properties. @@ -3672,7 +4002,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: any): boolean; + dispatchEvent(eventName: string, eventProperties: any): boolean; /** * Releases resources held by this AppBar. Call this method when the AppBar is no longer needed. After calling this method, the AppBar becomes unusable. @@ -3680,69 +4010,46 @@ declare module WinJS.UI { dispose(): void; /** - * Returns the AppBarCommand object identified by id. + * Returns the Command object identified by id. * @param id The element idenitifier (ID) of the command to be returned. - * @returns The command identified by id. If multiple commands have the same ID, returns an array of all the commands matching the ID. + * @returns The command identified by id. If multiple commands have the same ID, returns the first command found. **/ - getCommandById(id: string): AppBarCommand; - - /** - * Hides the AppBar. - **/ - hide(): void; - - /** - * Hides the specified commands of the AppBar. - * @param commands The commands to hide. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. - * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. - **/ - hideCommands(commands: any[], immediate?: boolean): void; - - /** - * Removes an event handler that the addEventListener method registered. - * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. - * @param listener The event handler function to remove. - * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. - **/ - removeEventListener(type: string, listener: Function, useCapture?: boolean): void; - - /** - * Shows the AppBar if it is not disabled. - **/ - show(): void; - - /** - * Shows the specified commands of the AppBar. - * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. - * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. - **/ - showCommands(commands: any[], immediate?: boolean): void; + getCommandById(id: string): ICommand; /** * Shows the specified commands of the AppBar while hiding all other commands. - * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. - * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. + * @param commands The commands to show. The array elements may be ICommand objects, or the string identifiers (IDs) of commands. **/ - showOnlyCommands(commands: any[], immediate?: boolean): void; + showOnlyCommands(commands: Array): void; + + /** + * Opens the AppBar. + **/ + open(): void; + + /** + * Closes the AppBar. + **/ + close(): void; + + /** + * Forces the AppBar to update its layout. + **/ + forceLayout(): void; //#endregion Methods //#region Properties /** - * Gets/Sets how AppBar will display itself while hidden. Values are "none" and "minimal". + * Gets/Sets how AppBar will display itself while closed. Values are "none" , "minimal", "compact" and "full". **/ closedDisplayMode: string; /** - * Sets the AppBarCommand objects that appear in the app bar. + * Gets or sets the Binding List of WinJS.UI.Command for the AppBar. **/ - commands: AppBarCommand[]; - - /** - * Gets or sets a value that indicates whether the AppBar is disabled. - **/ - disabled: boolean; + data: WinJS.Binding.List; /** * Gets the DOM element that hosts the AppBar. @@ -3750,24 +4057,55 @@ declare module WinJS.UI { element: HTMLElement; /** - * Gets a value that indicates whether the AppBar is hidden or in the process of becoming hidden. + * Gets or sets whether the AppBar is currently opened. **/ - hidden: boolean; - - /** - * Gets or sets the layout of the app bar contents. - **/ - layout: string; + opened: boolean; /** * Gets or sets a value that specifies whether the AppBar appears at the top or bottom of the main view. **/ placement: string; - /** - * Gets or sets a value that indicates whether the AppBar is sticky (won't light dismiss). If not sticky, the app bar dismisses normally when the user touches outside of the appbar. + /** + * Display options for the AppBar when closed. **/ - sticky: boolean; + static ClosedDisplayMode: { + /** + * When the AppBar is closed, it is not visible and doesn't take up any space. + **/ + none: string; + /** + * When the AppBar is closed, its height is reduced to the minimal height required to display only its overflowbutton. All other content in the AppBar is not displayed. + **/ + minimal: string; + /** + * When the AppBar is closed, its height is reduced such that button commands are still visible, but their labels are hidden. + **/ + compact: string; + /** + * When the AppBar is closed, its height is always sized to content. + **/ + full: string; + }; + + /** + * Display options for AppBar placement in relation to the main view. + */ + static Placement: { + /** + * The AppBar appears at the top of the main view + **/ + top: string; + /** + * The AppBar appears at the bottom of the main view + **/ + bottom: string; + }; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; //#endregion Properties @@ -3776,12 +4114,12 @@ declare module WinJS.UI { /** * Represents a command to be displayed in an app bar. **/ - class AppBarCommand { + class AppBarCommand implements ICommand { //#region Constructors /** * Creates a new AppBarCommand object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new AppBarCommand. **/ @@ -3806,7 +4144,7 @@ declare module WinJS.UI { /** * Removes an event handler that the addEventListener method registered. - * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param type The event type to unregister. * @param listener The event handler function to remove. * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. **/ @@ -3872,7 +4210,7 @@ declare module WinJS.UI { onclick: Function; /** - * Gets the section of the app bar that the command is in. + * Gets the section of the parent control that the command is in. The section can only be set through constructor options. **/ section: string; @@ -3887,14 +4225,159 @@ declare module WinJS.UI { tooltip: string; /** - * Gets the type of the command. + * Gets the type of the command. The type can only be set through constructor options. **/ type: string; + /** + * Gets or sets the priority of the command + **/ + priority: number; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } + /** + * A rich input box that provides suggestions as the user types. + **/ + class AutoSuggestBox { + //#region Constructors + + /** + * Creates a new AutoSuggestBox. + * @constructor + * @param element The DOM element hosts the new AutoSuggestBox. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLElement, options?: any); + + //#endregion Constructors + + //#region Events + + /** + * Raised when the user or the app changes the queryText. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.queryText, detail.linguisticDetails. + **/ + onquerychanged(eventInfo: CustomEvent): void; + + /** + * Raised awhen the user presses Enter. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.queryText, detail.linguisticDetails, detail.keyModifiers. + **/ + onquerysubmitted(eventInfo: CustomEvent): void; + + /** + * Raised when the user selects a suggested option for their query. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.tag, detail.keyModifiers, detail.storageFile. + **/ + onresultsuggestionchosen(eventInfo: CustomEvent): void; + + /** + * Raised when the system requests suggestions from this app. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.language, detail.linguisticDetails, detail.queryText, detail.searchSuggestionCollection. + **/ + onsuggestionsrequested(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Releases resources held by this AutoSuggestBox. Call this method when the AutoSuggestBox is no longer needed. After calling this method, the AutoSuggestBox becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Specifies whether suggestions based on local files are automatically displayed in the input field, and defines the criteria that + * the system uses to locate and filter these suggestions. + * @param settings The new settings for local content suggestions. + **/ + setLocalContentSuggestionSettings(settings: any): void + + //#endregion Methods + + //#region Properties + + /** + * Gets or sets whether the first suggestion is chosen when the user presses Enter. + **/ + chooseSuggestionOnEnter: boolean; + + /** + * Gets or sets a value that specifies whether the AutoSuggestBox is disabled. If the control is disabled, it won't receive focus. + **/ + disabled: boolean; + + /** + * Gets the DOM element that hosts the AutoSuggestBox. + **/ + element: HTMLElement; + + /** + * Gets or sets the placeholder text for the AutoSuggestBox. This text is displayed if there is no other text in the input box. + **/ + placeholderText: string; + + /** + * Gets or sets the query text for the AutoSuggestBox. + **/ + queryText: string; + + /** + * Gets or sets the history context. This context is used a secondary key (the app ID is the primary key) for storing history. + **/ + searchHistoryContext: string; + + /** + * Gets or sets a value that specifies whether history is disabled. + **/ + searchHistoryDisabled: boolean; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + + /** + * Creates the image argument for SearchSuggestionCollection.appendResultSuggestion. + * @param url The url of the image. + **/ + static createResultSuggestionImage(url: string): any; + } + /** * Provides backwards navigation in the form of a button. **/ @@ -3903,7 +4386,7 @@ declare module WinJS.UI { /** * Creates a new BackButton. - * @constructor + * @constructor * @param element The DOM element hosts the new BackButton. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -3956,6 +4439,11 @@ declare module WinJS.UI { **/ element: HTMLElement; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -3968,7 +4456,7 @@ declare module WinJS.UI { /** * Creates a new CellSpanningLayout. - * @constructor + * @constructor * @param options An object that contains one or more property/value pairs to apply to the new CellSpanningLayout. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". **/ constructor(options?: any); @@ -4023,10 +4511,10 @@ declare module WinJS.UI { /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. - * @param tree - * @param changedRange - * @param modifiedItems - * @param modifiedGroups + * @param tree + * @param changedRange + * @param modifiedItems + * @param modifiedGroups **/ layout(tree: ILayoutSite2, changedRange: any, modifiedItems: any, modifiedGroups: any): void; @@ -4074,10 +4562,178 @@ declare module WinJS.UI { **/ orientation: WinJS.UI.Orientation; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } + /** + * Data associated with hiding a dialog. + **/ + interface ContentDialogHideInfo { + /*** + * The dialog's dismissal result. May be 'primary', 'secondary', 'none', or whatever custom value was passed to hide. + **/ + result: string + } + + /** + * Event object associated with hiding a dialog. + **/ + interface ContentDialogHideEvent extends Event { + detail: ContentDialogHideInfo + } + + /** + * Represents a command to be displayed in an AppBar or ToolBar + **/ + class Command extends AppBarCommand implements ICommand { + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + } + + /** + * Displays a modal dialog which can display arbitrary HTML content. + **/ + class ContentDialog { + /** + * Specifies the result of dismissing the ContentDialog. + **/ + static DismissalResult: { + /** + * The dialog was dismissed without the user selecting any of the commands. The user may have dismissed the dialog by hitting the escape key or pressing the hardware back button. + **/ + none: string; + /** + * The user dismissed the dialog by pressing the primary command. + **/ + primary: string; + /** + * The user dismissed the dialog by pressing the secondary command. + **/ + secondary: string + } + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Creates a new ContentDialog control. + * @constructor + * @param The DOM element that hosts the ContentDialog control. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLElement, options?: any); + + /** + * Gets the DOM element that hosts the ContentDialog control. + **/ + element: HTMLElement; + + /** + * Gets or sets the ContentDialog's visibility. + **/ + hidden: boolean; + + /** + * The text displayed as the title of the dialog. + **/ + title: string; + + /** + * The text displayed on the primary command's button. + **/ + primaryCommandText: string; + + /** + * Indicates whether the button representing the primary command is currently disabled. + **/ + primaryCommandDisabled: boolean; + + /** + * The text displayed on the secondary command's button. + **/ + secondaryCommandText: string; + + /** + * Indicates whether the button representing the secondary command is currently disabled. + **/ + secondaryCommandDisabled: boolean; + + /** + * Shows the ContentDialog. Only one ContentDialog may be shown at a time. If another ContentDialog is already shown, this ContentDialog will remain hidden. + * @returns A promise which is successfully fulfilled when the dialog is dismissed. The completion value indicates the dialog's dismissal result. This may be 'primary', 'secondary', 'none', or whatever custom value was passed to hide. If this ContentDialog cannot be shown because a ContentDialog is already showing or the ContentDialog is disposed, then the return value is a promise which is in an error state. If preventDefault() is called on the beforeshow event, then this promise will be canceled. + **/ + show(): Promise; + + /** + * Hides the ContentDialog. + * @param result A value indicating why the dialog is being hidden. The promise returned by show will be fulfilled with this value. + **/ + hide(result?: any): void; + + /** + * Disposes this control. + **/ + dispose(): void; + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(type: string, listener: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Raised just before showing a dialog. Call preventDefault on this event to stop the dialog from being shown. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeshow(eventInfo: Event): void; + + /** + * Raised immediately after a dialog is fully shown. + * @param eventInfo An object that contains information about the event. + **/ + onaftershow(eventInfo: Event): void; + + /** + * Raised just before hiding a dialog. Call preventDefault on this event to stop the dialog from being hidden. + * @param eventInfo An object that contains information about the event. + **/ + onbeforehide(eventInfo: ContentDialogHideEvent): void; + + /** + * Raised immediately after a dialog is fully hidden. + * @param eventInfo An object that contains information about the event. + **/ + onafterhide(eventInfo: ContentDialogHideEvent): void; + } + /** * Allows users to pick a date value. **/ @@ -4086,7 +4742,7 @@ declare module WinJS.UI { /** * Initializes a new instance of the DatePicker control. - * @constructor + * @constructor * @param element The DOM element associated with the DatePicker control. * @param options The set of options to be applied initially to the DatePicker control. The options are the following: calendar, current, datePattern, disabled, maxYear, minYear, monthPattern, yearPattern. **/ @@ -4128,12 +4784,9 @@ declare module WinJS.UI { dispose(): void; /** - * Raises an event of the specified type and with additional properties. - * @param type The type (name) of the event. - * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. - * @returns true if preventDefault was called on the event, otherwise false. + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. Use render instead. **/ - raiseEvent(type: string, eventProperties: any): boolean; + static getInformation(startDate: any, endDate: any, calendar?: any, datePatterns?: any): any; /** * Removes a listener for the specified event. @@ -4192,6 +4845,11 @@ declare module WinJS.UI { **/ yearPattern: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -4199,7 +4857,7 @@ declare module WinJS.UI { /** * Adds event-related methods to the control. **/ - class DOMEventMixin { + module DOMEventMixin { //#region Methods /** @@ -4208,7 +4866,7 @@ declare module WinJS.UI { * @param listener The listener to invoke when the event gets raised. * @param useCapture true to initiate capture; otherwise, false. **/ - addEventListener(type: string, listener: Function, useCapture?: boolean): void; + export function addEventListener(type: string, listener: Function, useCapture?: boolean): void; /** * Raises an event of the specified type, adding the specified additional properties. @@ -4216,7 +4874,7 @@ declare module WinJS.UI { * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. * @returns true if preventDefault was called on the event, otherwise false. **/ - dispatchEvent(type: string, eventProperties: any): boolean; + export function dispatchEvent(type: string, eventProperties: any): boolean; /** * Removes an event listener from the control. @@ -4224,17 +4882,9 @@ declare module WinJS.UI { * @param listener The listener to remove. * @param useCapture true to initiate capture; otherwise, false. **/ - removeEventListener(type: string, listener: Function, useCapture?: boolean): void; - - /** - * Adds the set of declaratively specified options (properties and events) to the specified control. If the name of the options property begins with "on", the property value is a function and the control supports addEventListener. This method calls the addEventListener method on the control. - * @param control The control on which the properties and events are to be applied. - * @param options The set of options that are specified declaratively. - **/ - setOptions(control: any, options: any): void; + export function removeEventListener(type: string, listener: Function, useCapture?: boolean): void; //#endregion Methods - } /** @@ -4245,7 +4895,7 @@ declare module WinJS.UI { /** * Creates a new FlipView. - * @constructor + * @constructor * @param element The DOM element that hosts the control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the pageselected event, add a property named "onpageselected" and set its value to the event handler. **/ @@ -4375,6 +5025,31 @@ declare module WinJS.UI { **/ orientation: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Event Name + **/ + static datasourceCountChangedEvent: string; + + /** + * Event Name + **/ + static pageCompletedEvent: string; + + /** + * Event Name + **/ + static pageSelectedEvent: string; + + /** + * Event Name + **/ + static pageVisibilityChangedEvent: string; + //#endregion Properties } @@ -4387,7 +5062,7 @@ declare module WinJS.UI { /** * Creates a new Flyout object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new Flyout. **/ @@ -4433,6 +5108,14 @@ declare module WinJS.UI { **/ addEventListener(type: string, listener: Function, useCapture?: boolean): void; + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(eventName: string, eventProperties: any): boolean; + /** * Releases resources held by this object. Call this method when the object is no longer needed. After calling this method, the object becomes unusable. **/ @@ -4443,6 +5126,26 @@ declare module WinJS.UI { **/ hide(): void; + /** + * Shows the Flyout, if hidden, regardless of other states. + * @param anchor. DOM element to temporarily anchor the position of the Flyout to. This is optional if Flyout.anchor has already been set. + * @param placement The placement of the Flyout to the anchor: the string literal "top", "bottom", "left", or "right". + * @param alignment For "top" or "bottom" placement, the alignment of the Flyout to the anchor's edge: the string literal "center", "left", or "right". + **/ + show(anchor?: HTMLElement, placement?: string, alignment?: string): void; + + /** + * Shows the Flyout, if hidden, regardless of other states, top and left aligned at the specified coordinates, + * @param coordinates Required. The point where the top left corner of the flyout will appear, relative to the top and left edge of the visual viewport. + **/ + showAt(coordinates: { x: number; y: number; }): void; + + /** + * Shows the Flyout, if hidden, regardless of other states, top and left aligned at the location of the mouse event object, + * @param mouseEventObj Required. The MouseEvent Object specifying where to show the Flyout. + **/ + showAt(mouseEventObj: MouseEvent): void; + /** * Removes an event handler that the addEventListener method registered. * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. @@ -4451,14 +5154,6 @@ declare module WinJS.UI { **/ removeEventListener(type: string, listener: Function, useCapture?: boolean): void; - /** - * Shows the Flyout, if hidden, regardless of other states. - * @param anchor Required. The DOM element to anchor the Flyout. - * @param placement The placement of the Flyout to the anchor: the string literal "top", "bottom", "left", or "right". - * @param alignment For "top" or "bottom" placement, the alignment of the Flyout to the anchor's edge: the string literal "center", "left", or "right". - **/ - show(anchor: HTMLElement, placement?: string, alignment?: string): void; - //#endregion Methods //#region Properties @@ -4473,13 +5168,18 @@ declare module WinJS.UI { **/ anchor: HTMLElement; + /** + * Gets or sets a value that indicates whether the Flyout is disabled. + **/ + disabled: boolean; + /** * Gets the DOM element that hosts the Flyout. **/ element: HTMLElement; /** - * Gets a value that indicates whether the Flyout is hidden or in the process of becoming hidden. + * Gets a value that indicates whether the Flyout is hidden or in the process of becoming hidden, or sets the Flyout to hide or show itself. **/ hidden: boolean; @@ -4488,6 +5188,11 @@ declare module WinJS.UI { **/ placement: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -4500,7 +5205,7 @@ declare module WinJS.UI { /** * Creates a new GridLayout object. - * @constructor + * @constructor * @param options The set of properties and values to apply to the new GridLayout. **/ constructor(options?: any); @@ -4509,20 +5214,6 @@ declare module WinJS.UI { //#region Methods - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param wholeItem - **/ - calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): void; - - /** - * This method is no longer supported. - * @param endScrollPosition - * @param wholeItem - **/ - calculateLastVisible(endScrollPosition: number, wholeItem: boolean): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -4533,11 +5224,6 @@ declare module WinJS.UI { **/ dragOver(): void; - /** - * This method is no longer supported. - **/ - endLayout(): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -4551,27 +5237,6 @@ declare module WinJS.UI { **/ getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any; - /** - * This method is no longer supported. - * @param itemIndex - **/ - getItemPosition(itemIndex: number): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element - * @param keyPressed - **/ - getKeyboardNavigatedItem(itemIndex: number, element: any, keyPressed: any): void; - - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param endScrollPosition - **/ - getScrollbarRange(beginScrollPosition: number, endScrollPosition: number): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. * @param x The x-coordinate, or the horizontal position on the screen. @@ -4579,11 +5244,6 @@ declare module WinJS.UI { **/ hitTest(x: number, y: number): void; - /** - * This method is no longer supported. - **/ - init(): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. * @param site The rendering site for the layout. @@ -4591,12 +5251,6 @@ declare module WinJS.UI { **/ initialize(site: ILayoutSite2, groupsEnabled: boolean): void; - /** - * This method is no longer supported. - * @param elements - **/ - itemsAdded(elements: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. * @param firstPixel The first pixel the range of items falls between. @@ -4604,94 +5258,25 @@ declare module WinJS.UI { **/ itemsFromRange(firstPixel: number, lastPixel: number): void; - /** - * This method is no longer supported. - **/ - itemsMoved(): void; - - /** - * This method is no longer supported. - * @param elements - **/ - itemsRemoved(elements: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. - * @param tree - * @param changedRange - * @param modifiedItems - * @param modifiedGroups + * @param tree + * @param changedRange + * @param modifiedItems + * @param modifiedGroups **/ layout(tree: any, changedRange: any, modifiedItems: any, modifiedGroups: any): void; - /** - * This method is no longer supported. - * @param groupIndex - * @param element A DOM element. - **/ - layoutHeader(groupIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element A DOM element. - **/ - layoutItem(itemIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param element - **/ - prepareHeader(element: HTMLElement): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element A DOM element. - **/ - prepareItem(itemIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param item - * @param newItem - **/ - releaseItem(item: any, newItem: any): void; - - /** - * This method is no longer supported. - **/ - reset(): void; - - /** - * This method is no longer supported. - * @param layoutSite - **/ - setSite(layoutSite: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ setupAnimations(): void; - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param endScrollPositionScrollPosition - **/ - startLayout(beginScrollPosition: number, endScrollPositionScrollPosition: number): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ uninitialize(): void; - /** - * This method is no longer supported. - * @param count - **/ - updateBackdrop(count: number): void; - //#endregion Methods //#region Properties @@ -4716,11 +5301,6 @@ declare module WinJS.UI { **/ groupInfo: Function; - /** - * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use the orientation property instead. - **/ - horizontal: boolean; - /** * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. **/ @@ -4746,6 +5326,11 @@ declare module WinJS.UI { **/ orientation: WinJS.UI.Orientation; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -4758,7 +5343,7 @@ declare module WinJS.UI { /** * Creates a new Hub control. - * @constructor + * @constructor * @param element The DOM element that will host the Hub control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the contentanimating event, add a property named "oncontentanimating" to the options object and set its value to the event handler. **/ @@ -4811,6 +5396,12 @@ declare module WinJS.UI { **/ dispose(): void; + /** + * Forces the Hub to update its layout. + * Use this function when making the Hub visible again after you've set its style.display property to "none” or after style changes have been made that affect the size of the HubSections. + **/ + forceLayout(): void; + /** * Removes an event handler that the addEventListener method registered. * @param eventName The name of the event that the event handler is registered for. @@ -4873,6 +5464,47 @@ declare module WinJS.UI { **/ zoomableView: IZoomableView; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Specifies whether the Hub animation is an entrance animation or a transition animation. + **/ + static AnimationType: { + /** + * The animation plays when the Hub is first displayed. + **/ + entrance: string; + /** + * The animation plays when the Hub is changing its content. + **/ + contentTransition: string; + /** + * The animation plays when a section is inserted into the Hub. + **/ + insert: string; + /** + * The animation plays when a section is removed into the Hub. + **/ + remove: string; + } + + /** + * Gets the current loading state of the Hub. + **/ + static LoadingState: { + /** + * The Hub is loading sections. + **/ + loading: string; + /** + * All sections are loaded and animations are complete. + **/ + complete: string; + } + //#endregion Properties } @@ -4885,7 +5517,7 @@ declare module WinJS.UI { /** * Creates a new HubSection. - * @constructor + * @constructor * @param element The DOM element hosts the new HubSection. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -4924,6 +5556,16 @@ declare module WinJS.UI { **/ isHeaderStatic: boolean; + /** + * This object supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + static isDeclarativeControlContainer: any; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -4944,6 +5586,15 @@ declare module WinJS.UI { //#endregion Constructors + //#region Properties + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } /** @@ -4954,7 +5605,7 @@ declare module WinJS.UI { /** * Creates a new ItemContainer. - * @constructor + * @constructor * @param element The DOM element hosts the new ItemContainer. For the ItemContainer to be accessible, this element must have its role attribute set to "list" or "listbox". If tapBehavior is set to none and selectionDisabled is true, then use the "list" role; otherwise, use the "listbox" role. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -5059,6 +5710,11 @@ declare module WinJS.UI { **/ tapBehavior: TapBehavior; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -5067,6 +5723,10 @@ declare module WinJS.UI { * This object supports the WinJS infrastructure and is not intended to be used directly from your code. **/ class Layout { + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; } /** @@ -5077,7 +5737,7 @@ declare module WinJS.UI { /** * Creates a new ListLayout. - * @constructor + * @constructor * @param options An object that contains one or more property/value pairs to apply to the new ListLayout. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". **/ constructor(options?: any); @@ -5086,20 +5746,6 @@ declare module WinJS.UI { //#region Methods - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param wholeItem - **/ - calculateFirstVisible(beginScrollPosition: number, wholeItem: boolean): void; - - /** - * This method is no longer supported. - * @param endScrollPosition - * @param wholeItem - **/ - calculateLastVisible(endScrollPosition: number, wholeItem: boolean): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -5110,11 +5756,6 @@ declare module WinJS.UI { **/ dragOver(): void; - /** - * This method is no longer supported. - **/ - endLayout(): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -5128,27 +5769,6 @@ declare module WinJS.UI { **/ getAdjacent(currentItem: any, pressedKey: WinJS.Utilities.Key): any; - /** - * This method is no longer supported. - * @param itemIndex - **/ - getItemPosition(itemIndex: number): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element - * @param keyPressed - **/ - getKeyboardNavigatedItem(itemIndex: number, element: HTMLElement, keyPressed: any): void; - - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param endScrollPosition - **/ - getScrollbarRange(beginScrollPosition: number, endScrollPosition: number): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. * @param x The x-coordinate, or the horizontal position on the screen. @@ -5156,117 +5776,37 @@ declare module WinJS.UI { **/ hitTest(x: number, y: number): void; - /** - * This method is no longer supported. - **/ - init(): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ initialize(): void; - /** - * This method is no longer supported. - * @param elements - **/ - itemsAdded(elements: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. - * @param firstPixel - * @param lastPixel + * @param firstPixel + * @param lastPixel **/ itemsFromRange(firstPixel: number, lastPixel: number): void; - /** - * This method is no longer supported. - **/ - itemsMoved(): void; - - /** - * This method is no longer supported. - * @param elements - **/ - itemsRemoved(elements: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. - * @param tree - * @param changedRange - * @param modifiedItems - * @param modifiedGroups + * @param tree + * @param changedRange + * @param modifiedItems + * @param modifiedGroups **/ layout(tree: any, changedRange: any, modifiedItems: any, modifiedGroups: any): void; - /** - * This method is no longer supported. - * @param groupIndex - * @param element A DOM element. - **/ - layoutHeader(groupIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element A DOM element. - **/ - layoutItem(itemIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param element - **/ - prepareHeader(element: HTMLElement): void; - - /** - * This method is no longer supported. - * @param itemIndex - * @param element A DOM element. - **/ - prepareItem(itemIndex: number, element: any): void; - - /** - * This method is no longer supported. - * @param item - * @param newItem - **/ - releaseItem(item: any, newItem: any): void; - - /** - * This method is no longer supported. - **/ - reset(): void; - - /** - * This method is no longer supported. - * @param layoutSite - **/ - setSite(layoutSite: any): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ setupAnimations(): void; - /** - * This method is no longer supported. - * @param beginScrollPosition - * @param endScrollPositionScrollPosition - **/ - startLayout(beginScrollPosition: number, endScrollPositionScrollPosition: number): void; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ uninitialize(): void; - /** - * This method is no longer supported. - * @param count - **/ - updateBackdrop(count: number): void; - //#endregion Methods //#region Properties @@ -5286,21 +5826,6 @@ declare module WinJS.UI { **/ groupHeaderPosition: WinJS.UI.HeaderPosition; - /** - * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. - **/ - groupInfo: Function; - - /** - * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use the orientation property instead. - **/ - horizontal: boolean; - - /** - * This property is no longer supported. Starting with the Windows Library for JavaScript 2.0, use a CellSpanningLayout. - **/ - itemInfo: Function; - /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ @@ -5311,6 +5836,11 @@ declare module WinJS.UI { **/ orientation: WinJS.UI.Orientation; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -5323,7 +5853,7 @@ declare module WinJS.UI { /** * Creates a new ListView. - * @constructor + * @constructor * @param element The DOM element that hosts the ListView control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the selectionchanged event, add a property named "onselectionchanged" to the options object and set its value to the event handler. **/ @@ -5333,6 +5863,12 @@ declare module WinJS.UI { //#region Events + /** + * Raised when the accessibility attributes have been added to the ListView items. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties detail.firstIndex, detail.lastIndex, detail.firstHeaderIndex, detail.lastHeaderIndex. + **/ + onaccessibilityannotationcomplete(eventInfo: CustomEvent): void; + /** * Occurs when the ListView is about to play an entrance or contentTransition animation. * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.type, detail.setPromise. @@ -5417,6 +5953,18 @@ declare module WinJS.UI { **/ onselectionchanging(eventInfo: CustomEvent): void; + /** + * Raised when the header's visibility property changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.visible. + **/ + onheadervisibilitychanged(eventInfo: CustomEvent): void; + + /** + * Raised when the footer's visibility property changes. + * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.visible. + **/ + onfootervisibilitychanged(eventInfo: CustomEvent): void; + //#endregion Events //#region Methods @@ -5559,6 +6107,16 @@ declare module WinJS.UI { **/ layout: ILayout2; + /** + * Gets or sets the footer of the ListView. + **/ + footer: HTMLElement; + + /** + * Gets or sets the header of the ListView. + **/ + header: HTMLElement; + /** * Gets or sets a value that specifies how the ListView fetches items and adds and removes them to the DOM. Don't change the value of this property after the ListView has begun loading data. **/ @@ -5575,15 +6133,25 @@ declare module WinJS.UI { maxDeferredItemCleanup: number; /** - * Gets or sets the number of pages to load when the loadingBehavior property is set to "incremental" and the user scrolls beyond the threshold specified by the pagesToLoadThreshold property. + * This property is deprecated. Gets or sets the number of pages to load when the loadingBehavior property is set to "incremental" and the user scrolls beyond the threshold specified by the pagesToLoadThreshold property. **/ pagesToLoad: number; /** - * Gets or sets the threshold (in pages) for initiating an incremental load. When the last visible item is within the specified number of pages from the end of the loaded portion of the list, and if automaticallyLoadPages is true and loadingBehavior is set to "incremental", the ListView initiates an incremental load. + * This property is deprecated. Gets or sets the threshold (in pages) for initiating an incremental load. When the last visible item is within the specified number of pages from the end of the loaded portion of the list, and if automaticallyLoadPages is true and loadingBehavior is set to "incremental", the ListView initiates an incremental load. **/ pagesToLoadThreshold: number; + /** + * Gets or sets the maximum number of pages to prefetch in the leading buffer for virtualization. + **/ + maxLeadingPages: number; + + /** + * Gets or sets the maximum number of pages to prefetch in the trailing buffer for virtualization. + **/ + maxTrailingPages: number; + /** * Gets or sets the function that is called when the ListView discards or recycles the element representation of a group header. **/ @@ -5624,19 +6192,59 @@ declare module WinJS.UI { **/ zoomableView: IZoomableView>; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } /** - * A tab control that displays multiple items. -**/ + * An enumeration of Media commands that the transport bar buttons support. + **/ + interface MediaCommand { + audioTracks: string; + cast: string; + chapterSkipBack: string; + chapterSkipForward: string; + closedCaptions: string; + fastForward: string; + goToLive: string; + nextTrack: string; + pause: string; + play: string; + playbackRate: string; + playFromBeginning: string; + previousTrack: string; + rewind: string; + seek: string; + stop: string; + timeSkipBack: string; + timeSkipForward: string; + volume: string; + zoom: string; + } + + /** + * The types of timeline markers supported by the MediaPlayer. + **/ + interface MarkerType { + advertisement: string; + chapter: string; + custom: string; + } + + /** + * A tab control that displays multiple items. + **/ class Pivot { //#region Constructors /** * Creates a new Pivot. - * @constructor + * @constructor * @param element The DOM element hosts the new Pivot. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler. **/ @@ -5689,6 +6297,12 @@ declare module WinJS.UI { **/ dispose(): void; + /** + * Forces the control to relayout its content. This function is expected to be called + * when the pivot element is manually resized. + **/ + forceLayout(): void; + /** * Removes an event handler that the addEventListener method registered. * @param eventName The name of the event that the event handler is registered for. @@ -5706,6 +6320,16 @@ declare module WinJS.UI { **/ element: HTMLElement; + /** + * Gets or sets the left custom header. + **/ + customLeftHeader: HTMLElement; + + /** + * Gets or sets the right custom header. + **/ + customRightHeader: HTMLElement; + /** * Gets or sets the Binding.List that contains the PivotItem objects that belong to this Pivot. **/ @@ -5726,6 +6350,11 @@ declare module WinJS.UI { **/ selectedItem: PivotItem; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the title displayed above the PivotItem controls. **/ @@ -5742,7 +6371,7 @@ declare module WinJS.UI { /** * Creates a new PivotItem. - * @constructor + * @constructor * @param element The DOM element hosts the new PivotItem. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler. **/ @@ -5776,6 +6405,16 @@ declare module WinJS.UI { **/ header: string; + /** + * This object supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + static isDeclarativeControlContainer: any; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -5787,7 +6426,7 @@ declare module WinJS.UI { /** * Creates a new Menu object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new Menu. **/ @@ -5833,6 +6472,14 @@ declare module WinJS.UI { **/ addEventListener(type: string, listener: Function, useCapture?: boolean): void; + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(eventName: string, eventProperties: any): boolean; + /** * Releases resources held by this Menu. Call this method when the Menu is no longer needed. After calling this method, the Menu becomes unusable. **/ @@ -5855,7 +6502,7 @@ declare module WinJS.UI { * @param commands The commands to hide. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. **/ - hideCommands(commands: any[], immediate: boolean): void; + hideCommands(commands: any[], immediate?: boolean): void; /** * Removes an event handler that the addEventListener method registered. @@ -5873,19 +6520,32 @@ declare module WinJS.UI { **/ show(anchor: HTMLElement, placement?: string, alignment?: string): void; + /** + * Shows the Menu, if hidden, regardless of other states, top and left aligned at the specified coordinates, + * @param coordinates Required. The point where the top left corner of the Menu will appear, relative to the top and left edge of the visual viewport. + **/ + showAt(coordinates: { x: number; y: number; }): void; + + /** + * Shows the Menu, if hidden, regardless of other states, top and left aligned at the location of the mouse event object, + * @param mouseEventObj Required. The MouseEvent Object specifying where to show the Menu. + **/ + showAt(mouseEventObj: MouseEvent): void; + + /** * Shows the specified commands of the Menu. * @param commands The commands to show. The array elements may be Menu objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. **/ - showCommands(commands: any[], immediate: boolean): void; + showCommands(commands: any[], immediate?: boolean): void; /** * Shows the specified commands of the Menu while hiding all other commands. * @param commands The commands to show. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. **/ - showOnlyCommands(commands: any[], immediate: boolean): void; + showOnlyCommands(commands: any[], immediate?: boolean): void; //#endregion Methods @@ -5906,13 +6566,18 @@ declare module WinJS.UI { **/ commands: MenuCommand[]; + /** + * Gets or sets a value that indicates whether the Menu is disabled. + **/ + disabled: boolean; + /** * Gets the DOM element that hosts the Menu. **/ element: HTMLElement; /** - * Gets a value that indicates whether the Menu is hidden or in the process of becoming hidden. + * Gets a value that indicates whether the Menu is hidden or in the process of becoming hidden, or sets the Menu to hide or show itself. **/ hidden: boolean; @@ -5921,6 +6586,11 @@ declare module WinJS.UI { **/ placement: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -5933,7 +6603,7 @@ declare module WinJS.UI { /** * Creates a new MenuCommand object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new MenuCommand. **/ @@ -5945,7 +6615,7 @@ declare module WinJS.UI { /** * Registers an event handler for the specified event. - * @param type The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param type The event type to register. * @param listener The event handler function to associate with the event. * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. **/ @@ -5958,7 +6628,7 @@ declare module WinJS.UI { /** * Removes an event handler that the addEventListener method registered. - * @param type The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide. + * @param type The event type to unregister. * @param listener The event handler function to remove. * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. **/ @@ -6013,6 +6683,11 @@ declare module WinJS.UI { **/ selected: boolean; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets the type of the command. **/ @@ -6023,14 +6698,14 @@ declare module WinJS.UI { } /** - * Displays navigation commands in a toolbar that the user can show or hide. + * Displays NavBarCommands in an overlayed navigation pane that opens and closes at the top or bottom of the main view. **/ class NavBar { //#region Constructors /** * Creates a new NavBar. - * @constructor + * @constructor * @param element The DOM element that will host the new NavBar. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -6041,28 +6716,28 @@ declare module WinJS.UI { //#region Events /** - * Occurs immediately after the NavBar is hidden. + * Occurs immediately after the NavBar is closed. * @param eventInfo An object that contains information about the event. **/ - onafterhide(eventInfo: Event): void; + onafterclose(eventInfo: Event): void; /** - * Raised after the NavBar is shown. + * Raised after the NavBar is opened. * @param eventInfo An object that contains information about the event. **/ - onaftershow(eventInfo: Event): void; + onafteropen(eventInfo: Event): void; /** - * Raised just before the NavBar is hidden. + * Raised just before the NavBar is closed. * @param eventInfo An object that contains information about the event. **/ - onbeforehide(eventInfo: Event): void; + onbeforeclose(eventInfo: Event): void; /** - * Occurs before a hidden NavBar is shown. + * Occurs before a closed NavBar is opened. * @param eventInfo An object that contains information about the event. **/ - onbeforeshow(eventInfo: Event): void; + onbeforeopen(eventInfo: Event): void; /** * Occurs after the NavBar has finished processing its child elements. @@ -6096,16 +6771,16 @@ declare module WinJS.UI { dispose(): void; /** - * Hides the NavBar. + * Closes the NavBar. **/ - hide(): void; + close(): void; /** * Hides the specified commands of the NavBar. * @param commands The commands to hide. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. **/ - hideCommands(commands: any[], immediate: boolean): void; + hideCommands(commands: any[], immediate?: boolean): void; /** * Removes an event handler that the addEventListener method registered. @@ -6116,52 +6791,59 @@ declare module WinJS.UI { removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; /** - * Shows the NavBar if it is not disabled. + * Opens the NavBar **/ - show(): void; + open(): void; /** * Shows the specified commands of the NavBar. * @param commands The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. **/ - showCommands(commands: any[], immediate: boolean): void; + showCommands(commands: any[], immediate?: boolean): void; /** * Shows the specified commands of the NavBar while hiding all other commands. * @param commands The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. **/ - showOnlyCommands(commands: any[], immediate: boolean): void; + showOnlyCommands(commands: any[], immediate?: boolean): void; //#endregion Methods //#region Properties + /** + * Gets/Sets how NavBar will display itself while closed. Values are "none" and "minimal". + **/ + closedDisplayMode: string; + /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ commands: AppBarCommand; - /** - * Gets or sets a value that indicates whether the NavBar is disabled. - **/ - disabled: boolean; - /** * Gets the HTML element that hosts this NavBar. **/ element: HTMLElement; /** - * Gets a value that indicates whether the NavBar is hidden or in the process of becoming hidden. + * Returns the NavBarCommand object identified by id. + * @param id The element idenitifier (ID) of the NavBarCommand to be returned. + * @returns The NavBarCommand identified by id. If multiple commands have the same ID, returns the first command found. + **/ + getCommandById(id: string): NavBarCommand; + + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. Use NavBar.opened instead. **/ hidden: boolean; /** - * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + * Gets a value that indicates whether the NavBar is opened or in the process of becoming opened, or sets the NavBar to open or close itself. **/ - layout: string; + opened: boolean; /** * Gets or sets a value that specifies whether the NavBar appears at the top or bottom of the main view. @@ -6169,9 +6851,14 @@ declare module WinJS.UI { placement: string; /** - * Gets or sets a value that indicates whether the NavBar is sticky (won't light dismiss). If not sticky, the NavBar dismisses normally when the user touches outside of the NavBar. + * This object supports the WinJS infrastructure and is not intended to be used directly from your code. **/ - sticky: boolean; + static isDeclarativeControlContainer: any; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; //#endregion Properties @@ -6185,7 +6872,7 @@ declare module WinJS.UI { /** * Creates a new NavBarCommand. - * @constructor + * @constructor * @param element The DOM element hosts the new NavBarCommand. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -6193,6 +6880,16 @@ declare module WinJS.UI { //#endregion Constructors + //#region Events + + /** + * This API supports the Windows Library for JavaScript infrastructure and is not intended to be used directly from your code. + * Use NavBarContainer.oninvoked instead. + **/ + oninvoked: any; + + //#endregion Events + //#region Methods /** @@ -6263,10 +6960,15 @@ declare module WinJS.UI { **/ state: any; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the tooltip of the command. **/ - tooltip: any; + tooltip: string; //#endregion Properties @@ -6280,7 +6982,7 @@ declare module WinJS.UI { /** * Creates a new NavBarContainer. - * @constructor + * @constructor * @param element The DOM element hosts the new NavBarContainer. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -6374,6 +7076,11 @@ declare module WinJS.UI { **/ maxRows: number; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the WinJS.Binding.Template or templating function that creates the DOM elements for each item in the data source. Each item can contain multiple elements, but it must have a single root element. **/ @@ -6391,7 +7098,7 @@ declare module WinJS.UI { /** * Creates a new Rating. - * @constructor + * @constructor * @param element The DOM element hosts the new Rating. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler. **/ @@ -6473,6 +7180,11 @@ declare module WinJS.UI { **/ maxRating: number; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets a set of descriptions to show for rating values in the tooltip. **/ @@ -6495,11 +7207,11 @@ declare module WinJS.UI { /** * Creates a new Repeater control. - * @constructor + * @constructor * @param elemnt The DOM element that will host the new control. The Repeater will create an element if this value is null. * @param options An object that contains one or more property/value pairs to apply to the new Repeater. Each property of the options object corresponds to one of the object's properties or events. Event names must begin with "on". **/ - constructor(element?:HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -6630,6 +7342,16 @@ declare module WinJS.UI { **/ length: number; + /** + * This object supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + static isDeclarativeControlContainer: any; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets a WinJS.Binding.Template or custom rendering function that defines the HTML of each item within the Repeater. **/ @@ -6647,7 +7369,7 @@ declare module WinJS.UI { /** * Creates a new SearchBox. - * @constructor + * @constructor * @param element The DOM element hosts the new SearchBox. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ @@ -6669,17 +7391,11 @@ declare module WinJS.UI { **/ onquerysubmitted(eventInfo: CustomEvent): void; - /** - * Raised when the app automatically redirects focus to the search box. This event can only be raised when the focusOnKeyboardInput property is set to true. - * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.propertyName. - **/ - onreceivingfocusonkeyboardinput(eventInfo: CustomEvent): void; - /** * Raised when the user selects a suggested option for the search. * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: detail.tag, detail.keyModifiers, detail.storageFile. **/ - onresultsuggestionschosen(eventInfo: CustomEvent): void; + onresultsuggestionchosen(eventInfo: CustomEvent): void; /** * Raised when the system requests search suggestions from this app. @@ -6770,6 +7486,11 @@ declare module WinJS.UI { **/ searchHistoryDisabled: boolean; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties static createResultSuggestionImage(url: string): any; @@ -6784,7 +7505,7 @@ declare module WinJS.UI { /** * Creates a new SemanticZoom. - * @constructor + * @constructor * @param element The DOM element that hosts the SemanticZoom. * @param options An object that contains one or more property/value pairs to apply to the new control. This object can contain these properties: initiallyZoomedOut Boolean, zoomFactor 0.2–0.85. **/ @@ -6838,6 +7559,11 @@ declare module WinJS.UI { **/ removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + setTimeoutAfterTTFF(callback: Function, delay: number): void + //#endregion Methods //#region Properties @@ -6852,16 +7578,16 @@ declare module WinJS.UI { **/ enableButton: boolean; - /** - * Determines whether any controls contained in a SemanticZoom should be processed separately. This property is always true, meaning that the SemanticZoom takes care of processing its own controls. - **/ - isDeclarativeControlContainer: boolean; - /** * Gets or sets a value that indicates whether SemanticZoom is locked and zooming between views is disabled. **/ locked: boolean; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets a value that indicates whether the control is zoomed out. **/ @@ -6872,6 +7598,16 @@ declare module WinJS.UI { **/ zoomFactor: number; + /** + * Gets or sets a mapping function which can be used to change the item that is targeted on zoom in. + **/ + zoomedInItem: (any) => any; + + /** + * Gets or sets a mapping function which can be used to change the item that is targeted on zoom out. + **/ + zoomedOutItem: (any) => any; + //#endregion Properties } @@ -6884,7 +7620,7 @@ declare module WinJS.UI { /** * Creates a new SettingsFlyout object. - * @constructor + * @constructor * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new SettingsFlyout. **/ @@ -6979,10 +7715,20 @@ declare module WinJS.UI { **/ static showSettings(id: string, path: any): void; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Methods //#region Properties + /** + * Specifies whether the SettingsFlyout is disabled. + **/ + disabled: boolean; + /** * Gets the DOM element the SettingsFlyout is attached to. **/ @@ -7006,6 +7752,325 @@ declare module WinJS.UI { //#endregion Properties } + /** + * Displays a SplitView which renders a collapsable pane next to arbitrary HTML content. + **/ + class SplitView { + /** + * Placement options for a SplitView's pane. + **/ + static PanePlacement: { + /** + * Pane is positioned left of the SplitView's content. + **/ + left: string; + /** + * Pane is positioned right of the SplitView's content. + **/ + right: string; + /** + * Pane is positioned above the SplitView's content. + **/ + top: string; + /** + * Pane is positioned below the SplitView's content. + **/ + bottom: string; + } + + /** + * Display options for a SplitView's pane when it is closed. + **/ + static ClosedDisplayMode: { + /** + * When the pane is closed, it is not visible and doesn't take up any space. + **/ + none: string; + /** + * When the pane is closed, it occupies space leaving less room for the SplitView's content. + **/ + inline: string; + } + + /** + * Display options for a SplitView's pane when it is open. + **/ + static OpenedDisplayMode: { + /** + * When the pane is open, it occupies space leaving less room for the SplitView's content. + **/ + inline: string; + /** + * When the pane is open, it doesn't take up any space and it is light dismissable. + **/ + overlay: string; + } + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Creates a new SplitView. + * @constructor + * @param element The DOM element hosts the new SplitView. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLElement, options?: any); + + /** + * Gets the DOM element that hosts the SplitView control. + **/ + element: HTMLElement; + + /** + * Gets the DOM element that hosts the SplitView pane. + **/ + paneElement: HTMLElement; + + /** + * Gets the DOM element that hosts the SplitView's content. + **/ + contentElement: HTMLElement; + + /** + * Gets or sets the placement of the SplitView's pane. + **/ + panePlacement: string; + + /** + * Gets or sets the display mode of the SplitView's pane when it is closed. + **/ + closedDisplayMode: string; + + /** + * Gets or sets the display mode of the SplitView's pane when it is open. + **/ + openedDisplayMode: string; + + /** + * Gets or sets whether the SpitView's pane is currently open. + **/ + paneOpened: boolean; + + /** + * Opens the SplitView's pane. + **/ + openPane(): void; + + /** + * Closes the SplitView's pane. + **/ + closePane(): void; + + /** + * Disposes this control. + **/ + dispose(): void; + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Raised just before opening the pane. Call preventDefault on this event to stop the pane from opening. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeopen(eventInfo: Event): void; + + /** + * Raised immediately after the pane is fully open. + * @param eventInfo An object that contains information about the event. + **/ + onafteropen(eventInfo: Event): void; + + /** + * Raised just before closing the pane. Call preventDefault on this event to stop the pane from closing. + * @param eventInfo An object that contains information about the event. + **/ + onbeforeclose(eventInfo: Event): void; + + /** + * Raised immediately after the pane is fully closed. + * @param eventInfo An object that contains information about the event. + **/ + onafterclose(eventInfo: Event): void; + } + + /** + * Displays a button which is used for opening and closing a SplitView's pane. + **/ + class SplitViewPaneToggle { + /** + * Creates a new SplitViewPaneToggle. + * @constructor + * @param element The DOM element hosts the new SplitViewPaneToggle. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLButtonElement, options?: any); + + /** + * Gets the DOM element that hosts the SplitViewPaneToggle control. + **/ + element: HTMLButtonElement; + + /** + * Gets or sets the DOM element of the SplitView that is associated with the SplitViewPaneToggle control. + * When the SplitViewPaneToggle is invoked, it'll toggle this SplitView's pane. + **/ + splitView: HTMLElement; + + /** + * Disposes this control. + **/ + dispose(): void; + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Raised when the SplitViewPaneToggle is invoked. + * @param eventInfo An object that contains information about the event. + **/ + oninvoked(eventInfo: Event): void; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + } + + /** + * Represents a command in the SplitView Pane. + **/ + class SplitViewCommand { + //#region Constructors + + /** + * Creates a new SplitViewCommand. + * @constructor + * @param element The DOM element hosts the new SplitViewCommand. + * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. + **/ + constructor(element?: HTMLElement, options?: any); + + //#endregion Constructors + + //# region Events + + /** + * Raised when a SplitViewCommand has been invoked. + * @param eventInfo An object that contains information about the event. + **/ + oninvoked(eventInfo: CustomEvent): void; + + //#endregion Events + + //#region Methods + + /** + * Registers an event handler for the specified event. + * @param eventName The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click". + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Releases resources held by this SplitViewCommand. Call this method when the SplitViewCommand is no longer needed. After calling this method, the SplitViewCommand becomes unusable. + **/ + dispose(): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param eventName The name of the event that the event handler is registered for. + * @param eventCallback The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; + + //#endregion Methods + + //#region Properties + + /** + * Gets the HTML element that hosts this SplitViewCommand. + **/ + element: HTMLElement; + + /** + * Gets or sets the command's icon. + **/ + icon: string; + + /** + * Gets or sets the label of the command. + **/ + label: string; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + /** + * Gets or sets the tooltip of the command. + **/ + tooltip: string; + + //#endregion Properties + } /** * A type of IListDataSource that provides read-access to an object that implements the IStorageQueryResultBase interface. A StorageDataSource enables you to query and bind to items in the data source. @@ -7033,8 +8098,37 @@ declare module WinJS.UI { **/ loadThumbnail(item: IItem, image: HTMLImageElement): Promise; + /** + * Registers an event handler for the specified event. + * @param type The name of the event for which to add a listener. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(type: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param details The set of additional properties to be attached to the event object. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(type: string, details: any): boolean; + + /** + * Removes a listener for the specified event. + * @param type The name of the event for which to remove a listener. + * @param eventHandler The event handler function to associate with the event. + * @param useCapture Optional. The same value that was passed to addEventListener for this listener. It may be omitted if it was omitted when calling addEventListener. + **/ + removeEventListener(type: string, eventHandler: Function, useCapture?: any): void; + //#endregion Methods + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + } /** @@ -7045,7 +8139,7 @@ declare module WinJS.UI { /** * Creates a new TabContainer. - * @constructor + * @constructor * @param element The DOM element that hosts the TabContainer control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties. **/ @@ -7069,6 +8163,11 @@ declare module WinJS.UI { **/ childFocus: HTMLElement; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the tab index of this container. **/ @@ -7086,7 +8185,7 @@ declare module WinJS.UI { /** * Initializes a new instance of a TimePicker control. - * @constructor + * @constructor * @param element The DOM element associated with the TimePicker control. * @param options The set of options to be applied initially to the TimePicker control. The options are the following: clock. **/ @@ -7128,12 +8227,9 @@ declare module WinJS.UI { dispose(): void; /** - * Raises an event of the specified type and with additional properties. - * @param type The type (name) of the event. - * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. - * @returns true if preventDefault was called on the event, otherwise false. + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. Use render instead. **/ - raiseEvent(type: string, eventProperties: any): boolean; + static getInformation(clock: any, minuteIncrement: any, timerPatterns?: any): any; /** * Removes a listener for the specified event. @@ -7187,6 +8283,11 @@ declare module WinJS.UI { **/ periodPattern: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -7199,7 +8300,7 @@ declare module WinJS.UI { /** * Creates a new ToggleSwitch. - * @constructor + * @constructor * @param element The DOM that hosts the control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the change event, add a property named "onchange" to the options object and set its value to the event handler. **/ @@ -7240,20 +8341,6 @@ declare module WinJS.UI { **/ dispose(): void; - /** - * Handles the specified event. - * @param event The event. - **/ - handleEvent(event: any): void; - - /** - * Raises an event of the specified type and with additional properties. - * @param type The type (name) of the event. - * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. - * @returns true if preventDefault was called on the event, otherwise false. - **/ - raiseEvent(type: string, eventProperties: any): boolean; - /** * Removes an event handler that the addEventListener method registered. * @param eventName The name of the event that the event handler is registered for. @@ -7291,6 +8378,11 @@ declare module WinJS.UI { **/ labelOn: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + /** * Gets or sets the main text for the ToggleSwitch control. This text is always displayed, regardless of whether the control is switched on or off. **/ @@ -7299,6 +8391,139 @@ declare module WinJS.UI { //#endregion Properties } + /** + * Displays ICommands within the flow of the app. Use the ToolBar around other statically positioned app content. + **/ + class ToolBar { + + /** + * Display options for the closed ToolBar. + **/ + public static ClosedDisplayMode: { + /** + * When the ToolBar is closed, the height of the ToolBar is reduced such that button commands are still visible, but their labels are hidden. + **/ + compact: string; + /** + * When the ToolBar is closed, the height of the ToolBar is always sized to content. + **/ + full: string; + }; + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + public static supportedForProcessing: boolean; + + /** + * Gets the DOM element that hosts the ToolBar. + **/ + public element: HTMLElement; + + /** + * Gets or sets the Binding List of ICommand for the ToolBar. + **/ + public data: WinJS.Binding.List; + + /** + * Gets or sets the closedDisplayMode for the ToolBar. Values are "compact" and "full". + **/ + public closedDisplayMode: string; + + /** + * Creates a new ToolBar control. + * @param element The DOM element that will host the control. + * @param options The set of properties and values to apply to the new ToolBar. + **/ + constructor(element?: HTMLElement, options?: any); + + /** + * Disposes the ToolBar + **/ + public dispose(): void; + + /** + * Forces the ToolBar to update its layout. + * Use this function when the window did not change size, but the ToolBar itself did. + **/ + public forceLayout(): void; + + /** + * Opens the ToolBar + **/ + public open(): void; + + /** + * Closes the ToolBar + **/ + public close(): void; + + /** + * Returns the Command object identified by id. + * @param id The element idenitifier (ID) of the command to be returned. + * @returns The command identified by id. If multiple commands have the same ID, returns the first command found. + **/ + getCommandById(id: string): ICommand; + + /** + * Shows the specified commands of the ToolBar while hiding all other commands. + * @param commands The commands to show. The array elements may be ICommand objects, or the string identifiers (IDs) of commands. + **/ + showOnlyCommands(commands: Array): void; + + /** + * Gets or sets whether the ToolBar is currently opened. + **/ + public opened: boolean; + + /** + * Occurs immediately before the control is opened. Is cancelable. + * @param eventInfo An object that contains information about the event. + **/ + public onbeforeopen: (eventInfo: CustomEvent) => void; + + /** + * Occurs immediately after the control is opened. + * @param eventInfo An object that contains information about the event. + **/ + public onafteropen: (eventInfo: CustomEvent) => void; + + /** + * Occurs immediately before the control is closed. Is cancelable. + * @param eventInfo An object that contains information about the event. + **/ + public onbeforeclose: (eventInfo: CustomEvent) => void; + + /** + * Occurs immediately after the control is closed. + * @param eventInfo An object that contains information about the event. + **/ + public onafterclose: (eventInfo: CustomEvent) => void; + + /** + * Registers an event handler for the specified event. + * @param type The event type to register. It must be beforeopen, beforeclose, afteropen, or afterclose. + * @param listener The event handler function to associate with the event. + * @param useCapture Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. + **/ + addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Removes an event handler that the addEventListener method registered. + * @param type The event type to unregister. It must be beforeopen, beforeclose, afteropen, or afterclose. + * @param listener The event handler function to remove. + * @param useCapture Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. + **/ + removeEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(eventName: string, eventProperties: any): boolean; + } /** * Displays a tooltip that can contain images and formatting. @@ -7412,6 +8637,11 @@ declare module WinJS.UI { **/ placement: string; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -7442,6 +8672,14 @@ declare module WinJS.UI { **/ addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean): void; + /** + * Raises an event of the specified type and with additional properties. + * @param eventName The name of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + dispatchEvent(eventName: string, eventProperties: any): boolean; + /** * Releases resources held by this ViewBox. Call this method when the ViewBox is no longer needed. After calling this method, the ViewBox becomes unusable. **/ @@ -7469,6 +8707,11 @@ declare module WinJS.UI { **/ element: HTMLElement; + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + //#endregion Properties } @@ -7488,7 +8731,7 @@ declare module WinJS.UI { /** * Initializes the VirtualizedDataSource base class of a custom data source. - * @constructor + * @constructor * @param listDataAdapter The object that supplies data to the VirtualizedDataSource. * @param options An object that can contain properties that specify additional options for the VirtualizedDataSource. It supports these properties: cacheSize. **/ @@ -7498,12 +8741,6 @@ declare module WinJS.UI { //#region Events - /** - * Occurs when the status of the VirtualizedDataSource changes. - * @param eventInfo An object that contains information about the event. The detail property of this object contains the following sub-properties: status. - **/ - statuschanged(eventInfo: CustomEvent): void; - //#endregion Events //#region Methods @@ -7534,6 +8771,15 @@ declare module WinJS.UI { //#endregion Methods + //#region Properties + + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#endregion Properties + } //#endregion Objects @@ -7597,6 +8843,11 @@ declare module WinJS.UI { **/ function isAnimationEnabled(): boolean; + /** + * * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + function optionsParser(value: string, context?: any, functionContext?: any): any; + /** * Applies declarative control binding to all elements, starting at the specified root element. * @param rootElement The element at which to start applying the binding. If this parameter is not specified, the binding is applied to the entire document. @@ -7621,22 +8872,156 @@ declare module WinJS.UI { function scopedSelect(selector: string, element: HTMLElement): HTMLElement; /** - * Given a DOM element and a control, attaches the control to the element. - * @param element Element to associate with the control. - * @param control The control to attach to the element. - **/ - function setControl(element: HTMLElement, control: any): void; - - /** - * Adds the set of declaratively specified options (properties and events) to the specified control. If name of the options property begins with "on", the property value is a function and the control supports addEventListener. setControl calls addEventListener on the control. + * Adds the set of declaratively specified options (properties and events) to the specified control. If name of the options property begins with "on", the property value is a function and the control supports addEventListener, setOptions calls addEventListener on the control. * @param control The control on which the properties and events are to be applied. * @param options The set of options that are specified declaratively. **/ function setOptions(control: any, options?: any): void; + /** + * This API supports the WinJS infrastructure and is not intended to be used directly from your code. + **/ + function simpleItemRenderer(Function): Function; + //#endregion Functions } +/** + * Provides utility functions for generic directional focus movement +**/ +declare module WinJS.UI.XYFocus { + export interface XYFocusOptions { + /** + * The focus scope, only children of this element are considered in the calculation. + **/ + focusRoot?: HTMLElement; + + /** + * A rectangle indicating where focus came from before the current state. + **/ + historyRect?: IRect; + + /** + * The element from which to calculate the next focusable element; if specified, referenceRect is ignored. + **/ + referenceElement?: HTMLElement; + + /** + * The rectangle from which to calculate next focusable element; ignored if referenceElement is also specified. + **/ + referenceRect?: IRect; + } + + export interface IRect { + left: number; + right?: number; + top: number; + bottom?: number; + + height: number; + width: number; + } + + export interface XYFocusEvent extends CustomEvent { + detail: { nextFocusElement: HTMLElement; keyCode: number; previousFocusElement: HTMLElement }; + } + + /** + * Gets the mapping object that maps keycodes to XYFocus actions. + **/ + export var keyCodeMap: { + /** + * The array of keycodes that cause XYFocus to accept. + **/ + accept: Array; + /** + * The array of keycodes that cause XYFocus to cancel. + **/ + cancel: Array; + /** + * The array of keycodes that cause XYFocus to navigate down. + **/ + down: Array; + /** + * The array of keycodes that cause XYFocus to navigate left. + **/ + left: Array; + /** + * The array of keycodes that cause XYFocus to navigate right. + **/ + right: Array; + /** + * The array of keycodes that cause XYFocus to navigate up. + **/ + up: Array; + }; + + /** + * Gets or sets the focus root when invoking XYFocus APIs. + **/ + export var focusRoot: HTMLElement; + + /** + * Adds an event listener to XYFocus events. + * @param type The type (name) of the event. + * @param listener The listener to invoke when the event gets raised. + **/ + export function addEventListener(type: string, handler: EventListener): void; + + /** + * Raises an event of the specified type and with additional properties. + * @param type The type (name) of the event. + * @param eventProperties The set of additional properties to be attached to the event object when the event is raised. + * @returns true if preventDefault was called on the event, otherwise false. + **/ + export function dispatchEvent(type: string, eventProperties: any): boolean; + + /** + * Removes an event listener to XYFocus events. + * @param type The type (name) of the event. + * @param listener The listener to remove. + **/ + export function removeEventListener(type: string, handler: EventListener): void; + + /** + * Returns the next focusable element from the current active element (or reference, if supplied) towards the specified direction. + * @param direction The direction to search. + * @param options An options object configuring the search. + **/ + export function findNextFocusElement(direction: string, options?: XYFocusOptions): HTMLElement; + export function findNextFocusElement(direction: "left", options?: XYFocusOptions): HTMLElement; + export function findNextFocusElement(direction: "right", options?: XYFocusOptions): HTMLElement; + export function findNextFocusElement(direction: "up", options?: XYFocusOptions): HTMLElement; + export function findNextFocusElement(direction: "down", options?: XYFocusOptions): HTMLElement; + + /** + * Moves focus to the next focusable element from the current active element (or reference, if supplied) towards the specific direction. + * @param direction The direction to move. + * @param options An options object configuring the focus move. + **/ + export function moveFocus(direction: string, options?: XYFocusOptions): HTMLElement; + export function moveFocus(direction: "left", options?: XYFocusOptions): HTMLElement; + export function moveFocus(direction: "right", options?: XYFocusOptions): HTMLElement; + export function moveFocus(direction: "up", options?: XYFocusOptions): HTMLElement; + export function moveFocus(direction: "down", options?: XYFocusOptions): HTMLElement; + + //#region Events + + /** + * Occurs immeidately after XYFocus has changed focus targets. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: previousFocusElemewnt, keyCode. + **/ + export function onfocuschanged(eventInfo: CustomEvent): void; + + /** + * Occurs immeidately before XYFocus changes focus targets. Is cancelable. + * @param eventInfo An object that contains information about the event. The detail property of this object includes the following subproperties: nextFocusElement, keyCode. + **/ + export function onfocuschanging(eventInfo: CustomEvent): void; + + //#endregion Events +} + /** * Provides functions to load HTML content programmatically. **/ @@ -7792,7 +9177,7 @@ declare module WinJS.UI.TrackTabBehavior { * Removes the tab order information from the specified element. * @param element The element to remove tab information from. **/ - function detatch(element: HTMLElement): void; + function detach(element: HTMLElement): void; //#endregion Functions @@ -8151,6 +9536,38 @@ declare module WinJS.Utilities { * The F12 key. **/ F12, + /** + * The XBox One Remote navigation view button. + **/ + NavigationView, + /** + * The XBox One Remote navigation menu button. + **/ + NavigationMenu, + /** + * The XBox One Remote navigation up button. + **/ + NavigationUp, + /** + * The XBox One Remote navigation down button. + **/ + NavigationDown, + /** + * The XBox One Remote navigation left button. + **/ + NavigationLeft, + /** + * The XBox One Remote navigation right button. + **/ + NavigationRight, + /** + * The XBox One Remote navigation accept button. + **/ + NavigationAccept, + /** + * The XBox One Remote navigation cancel button. + **/ + NavigationCancel, /** * The NUMBER LOCK key. **/ @@ -8198,6 +9615,105 @@ declare module WinJS.Utilities { /** * The open bracket key ([). **/ + /** + * The XBox One gamepad A button. + **/ + GamepadA, + /** + * The XBox One gamepad B button. + **/ + GamepadB, + /** + * The XBox One gamepad X button. + **/ + GamepadX, + /** + * The XBox One gamepad Y button. + **/ + GamepadY, + /** + * The XBox One gamepad right shoulder. + **/ + GamepadRightShoulder, + /** + * The XBox One gamepad left shoulder. + **/ + GamepadLeftShoulder, + /** + * The XBox One gamepad left trigger. + **/ + GamepadLeftTrigger, + /** + * The XBox One gamepad right trigger. + **/ + GamepadRightTrigger, + /** + * The XBox One gamepad dpad up. + **/ + GamepadDPadUp, + /** + * The XBox One gamepad dpad down. + **/ + GamepadDPadDown, + /** + * The XBox One gamepad dpad left. + **/ + GamepadDPadLeft, + /** + * The XBox One gamepad dpad right. + **/ + GamepadDPadRight, + /** + * The XBox One gamepad menu button. + **/ + GamepadMenu, + /** + * The XBox One gamepad view button. + **/ + GamepadView, + /** + * The XBox One gamepad left thumbstick button. + **/ + GamepadLeftThumbstick, + /** + * The XBox One gamepad right thumbstick button. + **/ + GamepadRightThumbstick, + /** + * The XBox One gamepad left thumbstick's up. + **/ + GamepadLeftThumbstickUp, + /** + * The XBox One gamepad left thumbstick's down. + **/ + GamepadLeftThumbstickDown, + /** + * The XBox One gamepad left thumbstick's right. + **/ + GamepadLeftThumbstickRight, + /** + * The XBox One gamepad left thumbstick's left. + **/ + GamepadLeftThumbstickLeft, + /** + * The XBox One gamepad right thumbstick's up. + **/ + GamepadRightThumbstickUp, + /** + * The XBox One gamepad right thumbstick's down. + **/ + GamepadRightThumbstickDown, + /** + * The XBox One gamepad right thumbstick's right. + **/ + GamepadRightThumbstickRight, + /** + * The XBox One gamepad right thumbstick's left. + **/ + GamepadRightThumbstickLeft, + /** + * The open bracket key ([). + **/ openBracket, /** * The backslash key (\). @@ -8210,7 +9726,11 @@ declare module WinJS.Utilities { /** * The single quote key ('). **/ - singleQuote + singleQuote, + /** + * Any IME input. + **/ + IME, } //#endregion Enumerations @@ -8254,7 +9774,7 @@ declare module WinJS.Utilities { /** * Represents the result of a query selector, and provides various operations that perform actions over the elements of the collection. **/ - interface QueryCollection extends Array { + class QueryCollection implements Array { //#region Methods /** @@ -8264,13 +9784,6 @@ declare module WinJS.Utilities { **/ addClass(name: string): QueryCollection; - /** - * Creates a QueryCollection that contains the children of the specified parent element. - * @param element The parent element. - * @returns The QueryCollection that contains the children of the element. - **/ - children(element: HTMLElement): QueryCollection; - /** * Clears the specified style property for all the elements in the collection. * @param name The name of the style property to be cleared. @@ -8315,13 +9828,6 @@ declare module WinJS.Utilities { **/ hasClass(name: string): boolean; - /** - * Looks up an element by ID and wraps the result in a QueryCollection. - * @param id The ID of the element. - * @returns A QueryCollection that contains the element, if it is found. - **/ - id(id: string): QueryCollection; - /** * Adds a set of items to this QueryCollection. * @param items The items to add to the QueryCollection. This may be an array-like object, a document fragment, or a single item. @@ -8358,7 +9864,7 @@ declare module WinJS.Utilities { /** * Removes the specified class from all the elements in the collection. * @param name The name of the class to be removed. - * @returns his QueryCollection object. + * @returns This QueryCollection object. **/ removeClass(name: string): QueryCollection; @@ -8405,14 +9911,161 @@ declare module WinJS.Utilities { //#endregion Methods - } + /** + * Indicates that the object is compatibile with declarative processing. + **/ + static supportedForProcessing: boolean; + + //#region Array.prototype + + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + **/ + concat(...items: U[]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + **/ + concat(...items: T[]): T[]; + + /** + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + **/ + join(separator?: string): string; + + /** + * Removes the last element from an array and returns it. + **/ + pop(): T; + + /** + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + **/ + push(...items: T[]): number; + + /** + * Reverses the elements in an Array. + **/ + reverse(): T[]; + + /** + * Removes the first element from an array and returns it. + **/ + shift(): T; + + /** + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + **/ + slice(start?: number, end?: number): T[]; + + /** + * Sorts an array. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + **/ + sort(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + **/ + splice(start: number): T[]; + + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + **/ + splice(start: number, deleteCount: number, ...items: T[]): T[]; + + /** + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + **/ + unshift(...items: T[]): number; + + /** + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + **/ + indexOf(searchElement: T, fromIndex?: number): number; + + /** + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + **/ + lastIndexOf(searchElement: T, fromIndex?: number): number; + + /** + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + **/ + every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + **/ + some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + **/ + map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + **/ + filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + **/ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + **/ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + **/ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + **/ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + /** + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + **/ + length: number; + + [n: number]: T; + + //#endregion Array.prototype - /** - * Constructor support for QueryCollection interface - **/ - export var QueryCollection: { - new (items: T[]): QueryCollection; - prototype: QueryCollection; } //#endregion Objects @@ -8536,7 +10189,7 @@ declare module WinJS.Utilities { * @param element The element. * @returns An object with two properties: scrollLeft and scrollTop **/ - function getScrollPosition(element: HTMLElement): { scrollLeft: number; scrollTop: number}; + function getScrollPosition(element: HTMLElement): { scrollLeft: number; scrollTop: number }; /** * Gets the tab index of the specified element. @@ -8668,7 +10321,7 @@ declare module WinJS.Utilities { * @param element The element. * @param position An object describing the position to set. **/ - function setScrollPosition(element: HTMLElement, position: { scrollLeft: number; scrollTop: number}): void; + function setScrollPosition(element: HTMLElement, position: { scrollLeft: number; scrollTop: number }): void; /** * Configures a logger that writes messages containing the specified tags to the JavaScript console. @@ -8700,9 +10353,9 @@ declare module WinJS.Utilities { var hasWinRT: boolean; /** - * Indicates whether the app is running on Windows Phone. + * Determines if strict declarative processing is enabled in this script context. **/ - var isPhone: boolean; + var strictProcessing: boolean; //#endregion Properties From 62d8b030ef550d85fa4830146955a9d59dba5c1a Mon Sep 17 00:00:00 2001 From: jessesh Date: Mon, 5 Oct 2015 13:40:22 -0700 Subject: [PATCH 009/357] Fixes "implicit any" errors. --- winjs/winjs.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index acf6802bf..903019698 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -1337,7 +1337,7 @@ declare module WinJS.Binding { /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ - function getValue(obj: any, path?: any) + function getValue(obj: any, path?: any): any; /** * Marks a custom initializer function as being compatible with declarative data binding. @@ -7601,12 +7601,12 @@ declare module WinJS.UI { /** * Gets or sets a mapping function which can be used to change the item that is targeted on zoom in. **/ - zoomedInItem: (any) => any; + zoomedInItem: (any: any) => any; /** * Gets or sets a mapping function which can be used to change the item that is targeted on zoom out. **/ - zoomedOutItem: (any) => any; + zoomedOutItem: (any: any) => any; //#endregion Properties @@ -8881,7 +8881,7 @@ declare module WinJS.UI { /** * This API supports the WinJS infrastructure and is not intended to be used directly from your code. **/ - function simpleItemRenderer(Function): Function; + function simpleItemRenderer(fn: Function): Function; //#endregion Functions From 729ca9b124a7d4b4631b6295d9ce8f2d848ae4fe Mon Sep 17 00:00:00 2001 From: David Pertiller Date: Mon, 5 Oct 2015 23:23:24 +0200 Subject: [PATCH 010/357] included method definition for onrendered event which provides the rendered canvas element --- html2canvas/html2canvas.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html2canvas/html2canvas.d.ts b/html2canvas/html2canvas.d.ts index 689421971..61eba51fd 100644 --- a/html2canvas/html2canvas.d.ts +++ b/html2canvas/html2canvas.d.ts @@ -37,6 +37,8 @@ declare module Html2Canvas { /** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */ useCORS?: boolean; + /** Callback providing the rendered canvas element after rendering */ + onrendered?(canvas: HTMLElement): void; } } From 282c4c28548911940f9bea3aeba34bdd59e20ce5 Mon Sep 17 00:00:00 2001 From: William Comartin Date: Tue, 6 Oct 2015 15:59:48 -0400 Subject: [PATCH 011/357] add angular-dialog-service typescript definitions --- .../angular-dialog-service.d.ts | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 angular-dialog-service/angular-dialog-service.d.ts diff --git a/angular-dialog-service/angular-dialog-service.d.ts b/angular-dialog-service/angular-dialog-service.d.ts new file mode 100644 index 000000000..aa057642c --- /dev/null +++ b/angular-dialog-service/angular-dialog-service.d.ts @@ -0,0 +1,82 @@ +// Type definitions for Angular Dialog Service 5.2.8 +// Project: https://github.com/m-e-conroy/angular-dialog-service +// Definitions by: William Comartin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module angular.dialogservice { + + interface IDialogOptions { + /** + * Set to false to disable animations on new modal/backdrop. Does not toggle animations for modals/backdrops that are already displayed. + * + * @default false + */ + animation?: boolean; + + /** + * controls the presence of a backdrop + * Allowed values: + * - true (default) + * - false (no backdrop) + * - 'static' backdrop is present but modal window is not closed when clicking outside of the modal window + * + * @default true + */ + backdrop?: boolean | string; + + /** + * indicates whether the dialog should be closable by hitting the ESC key + * + * @default true + */ + keyboard?: boolean; + + /** + * additional CSS class(es) to be added to a modal backdrop template + * + * @default 'dialogs-backdrop-default' + */ + backdropClass?: string; + + /** + * additional CSS class(es) to be added to a modal window template + * + * @default 'dialogs-default' + */ + windowClass?: string; + + /** + * Optional suffix of modal window class. The value used is appended to the `modal-` class, i.e. a value of `sm` gives `modal-sm`. + * + * @default 'lg' + */ + size?: string; + } + + interface IDialogService { + /** + * Opens a new error modal instance. + */ + error(header: string, msg: string, progress: number, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + /** + * Opens a new wait modal instance. + */ + wait(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + /** + * Opens a new notify modal instance. + */ + notify(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + /** + * Opens a new confirm modal instance. + */ + confirm(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + /** + * Opens a new custom modal instance. + */ + create(url: string, ctrlr: string, data: any, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + } + +} From a20e020adc793a637d79ab39d3a47d2cab838109 Mon Sep 17 00:00:00 2001 From: Gabriel Mak Date: Wed, 7 Oct 2015 09:23:48 +0100 Subject: [PATCH 012/357] Add support for NavBrand construct Adding support for NavBrand construct in newer react-bootstrap --- react-bootstrap/react-bootstrap.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/react-bootstrap/react-bootstrap.d.ts b/react-bootstrap/react-bootstrap.d.ts index 0c0584474..fe6323aa4 100644 --- a/react-bootstrap/react-bootstrap.d.ts +++ b/react-bootstrap/react-bootstrap.d.ts @@ -459,6 +459,15 @@ declare module "react-bootstrap" { interface Navbar extends React.ReactElement { } interface NavbarClass extends React.ComponentClass { } var Navbar: NavbarClass; + + // + // ---------------------------------------- + interface NavBrandProps { + + } + interface NavBrand extends React.ReactElement { } + interface NavBrandClass extends React.ComponentClass { } + var NavBrand: NavBrandClass; // From 202d240a0a0c86661b30f3a97169e70f72484293 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 09:07:44 -0600 Subject: [PATCH 013/357] 'request': Added more tests from project page and fixed definitions accordingly --- request/request-tests.ts | 438 ++++++++++++++++++++++++++++++++++++++- request/request.d.ts | 146 ++++++++----- 2 files changed, 517 insertions(+), 67 deletions(-) diff --git a/request/request-tests.ts b/request/request-tests.ts index 9d7cbf3bc..7f04be26a 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -4,6 +4,7 @@ import request = require('request'); import http = require('http'); import stream = require('stream'); import formData = require('form-data'); +import fs = require('fs'); var value: any; var str: string; @@ -20,7 +21,7 @@ var headers: {[key: string]: string}; var agent: http.Agent; var write: stream.Writable; var req: request.Request; -var form: formData.FormData; +var form1: formData.FormData; var bodyArr: request.RequestPart[] = [{ body: value @@ -125,8 +126,6 @@ req.destroy(); // --- --- --- --- --- --- --- --- --- --- --- --- -var callback: (error: any, response: any, body: any) => void; - value = request.initParams; req = request(uri); @@ -136,13 +135,6 @@ req = request(uri, callback); req = request(options); req = request(options, callback); -req = request.request(uri); -req = request.request(uri, options); -req = request.request(uri, options, callback); -req = request.request(uri, callback); -req = request.request(options); -req = request.request(options, callback); - req = request.get(uri); req = request.get(uri, options); req = request.get(uri, options, callback); @@ -204,3 +196,429 @@ request // check response }) .pipe(request.put('http://another.com/another.png')); + +//The following examples from https://github.com/request/request +request('http://www.google.com', function (error, response, body) { + if (!error && response.statusCode == 200) { + console.log(body); // Show the HTML for the Google homepage. + } +}); + +request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')); + +fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json')); + +request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://google.com/img.png') + .on('response', function(response) { + console.log(response.statusCode); // 200 + console.log(response.headers['content-type']); // 'image/png' + }) + .pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://mysite.com/doodle.png') + .on('error', function(err) { + console.log(err); + }) + .pipe(fs.createWriteStream('doodle.png')); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + if (req.method === 'PUT') { + req.pipe(request.put('http://mysite.com/doodle.png')); + } else if (req.method === 'GET' || req.method === 'HEAD') { + request.get('http://mysite.com/doodle.png').pipe(resp); + } + } +}); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + var x = request('http://mysite.com/doodle.png'); + req.pipe(x); + x.pipe(resp); + } +}); + +var resp: http.ServerResponse; +req.pipe(request('http://mysite.com/doodle.png')).pipe(resp); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + r.get('http://google.com/doodle.png').pipe(resp); + } +}); + +request.post('http://service.com/upload', {form:{key:'value'}}); +// or +request.post('http://service.com/upload').form({key:'value'}); +// or +request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ }); + +var data = { + // Pass a simple key-value pair + my_field: 'my_value', + // Pass data via Buffers + my_buffer: new Buffer([1, 2, 3]), + // Pass data via Streams + my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), + // Pass multiple values /w an Array + attachments: [ + fs.createReadStream(__dirname + '/attachment1.jpg'), + fs.createReadStream(__dirname + '/attachment2.jpg') + ], + // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS} + // Use case: for some types of streams, you'll need to provide "file"-related information manually. + // See the `form-data` README for more information about options: https://github.com/felixge/node-form-data + custom_file: { + value: fs.createReadStream('/dev/urandom'), + options: { + filename: 'topsecret.jpg', + contentType: 'image/jpg' + } + } +}; +request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) { + if (err) { + return console.error('upload failed:', err); + } + console.log('Upload successful! Server responded with:', body); +}); + +var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {}); +var form = requestMultipart.form(); +form.append('my_field', 'my_value'); +form.append('my_buffer', new Buffer([1, 2, 3])); +form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'}); + +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: { + chunked: false, + data: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' } + ] + } + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' }, + { body: fs.createReadStream('image.png') } + ] + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); + +request.get('http://some.server.com/').auth('username', 'password', false); +// or +request.get('http://some.server.com/', { + 'auth': { + 'user': 'username', + 'pass': 'password', + 'sendImmediately': false + } +}); +// or +request.get('http://some.server.com/').auth(null, null, true, 'bearerToken'); +// or +request.get('http://some.server.com/', { + 'auth': { + 'bearer': 'bearerToken' + } +}); + +var username = 'username', + password = 'password', + url = 'http://' + username + ':' + password + '@some.server.com'; + +request({url: url}, function (error, response, body) { + // Do more stuff with 'body' here +}); + +options = { + url: 'https://api.github.com/repos/request/request', + headers: { + 'User-Agent': 'request' + } +}; + +function callback(error, response, body) { + if (!error && response.statusCode == 200) { + var info = JSON.parse(body); + console.log(info.stargazers_count + " Stars"); + console.log(info.forks_count + " Forks"); + } +} + +request(options, callback); + +// OAuth1.0 - 3-legged server side flow (Twitter example) +// step 1 +import qs = require('querystring'); +const CONSUMER_KEY = 'key'; +const CONSUMER_SECRET = 'secret'; +oauth = + { callback: 'http://mysite.com/callback/' + , consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + } + , url = 'https://api.twitter.com/oauth/request_token' + ; +request.post({url:url, oauth:oauth}, function (e, r, body) { + // Ideally, you would take the body in the response + // and construct a URL that a user clicks on (like a sign in button). + // The verifier is only available in the response after a user has + // verified with twitter that they are authorizing your app. + + // step 2 + var req_data = qs.parse(body); + var uri = 'https://api.twitter.com/oauth/authenticate' + + '?' + qs.stringify({oauth_token: req_data.oauth_token}); + // redirect the user to the authorize uri + + // step 3 + // after the user is redirected back to your server + var auth_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: auth_data.oauth_token + , token_secret: req_data.oauth_token_secret + , verifier: auth_data.oauth_verifier + } + , url = 'https://api.twitter.com/oauth/access_token' + ; + request.post({url:url, oauth:oauth}, function (e, r, body) { + // ready to make signed requests on behalf of the user + var perm_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: perm_data.oauth_token + , token_secret: perm_data.oauth_token_secret + } + , url = 'https://api.twitter.com/1.1/users/show.json' + , qs = + { screen_name: perm_data.screen_name + , user_id: perm_data.user_id + } + ; + request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + console.log(user); + }); + }); +}); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key') + , caFile = path.resolve(__dirname, 'ssl/ca.cert.pem'); + +options = { + url: 'https://api.some-server.com/', + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + passphrase: 'password', + ca: fs.readFileSync(caFile) +}; + +request.get(options); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key'); + +options = { + url: 'https://api.some-server.com/', + agentOptions: { + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format: + // pfx: fs.readFileSync(pfxFilePath), + passphrase: 'password', + securityOptions: 'SSL_OP_NO_SSLv3' + } +}; + +request.get(options); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + secureProtocol: 'SSLv3_method' + } +}); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + ca: fs.readFileSync('ca.cert.pem') + } +}); + + +request({ + // will be ignored + method: 'GET', + uri: 'http://www.google.com', + + // HTTP Archive Request Object + har: { + url: 'http://www.mockbin.com/har', + method: 'POST', + headers: [ + { + name: 'content-type', + value: 'application/x-www-form-urlencoded' + } + ], + postData: { + mimeType: 'application/x-www-form-urlencoded', + params: [ + { + name: 'foo', + value: 'bar' + }, + { + name: 'hello', + value: 'world' + } + ] + } + } + }); + +//requests using baseRequest() will set the 'x-token' header +var baseRequest = request.defaults({ + headers: {'x-token': 'my-token'} +}); + +//requests using specialRequest() will include the 'x-token' header set in +//baseRequest and will also include the 'special' header +var specialRequest = baseRequest.defaults({ + headers: {special: 'special value'} +}); + +request.put(url); +request.patch(url); +request.post(url); +request.head(url); +request.del(url); +request.get(url); +request.cookie('key1=value1'); +request.jar(); +request.debug = true; + +request.get('http://10.255.255.1', {timeout: 1500}, function(err) { + console.log(err.code === 'ETIMEDOUT'); + // Set to `true` if the timeout was a connection timeout, `false` or + // `undefined` otherwise. + console.log(err.connect === true); + process.exit(0); +}); + +var rand = Math.floor(Math.random()*100000000).toString(); + request( + { method: 'PUT' + , uri: 'http://mikeal.iriscouch.com/testjs/' + rand + , multipart: + [ { 'content-type': 'application/json' + , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + } + , { body: 'I am an attachment' } + ] + } + , function (error, response, body) { + if(response.statusCode == 201){ + console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + } else { + console.log('error: '+ response.statusCode) + console.log(body) + } + } + ); + +request( + { method: 'GET' + , uri: 'http://www.google.com' + , gzip: true + } + , function (error, response, body) { + // body is the decompressed response body + console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) + console.log('the decoded data is: ' + body) + } + ).on('data', function(data) { + // decompressed data as it is received + console.log('decoded chunk: ' + data) + }) + .on('response', function(response) { + // unmodified http.IncomingMessage object + response.on('data', function(data) { + // compressed data as it is received + console.log('received ' + data.length + ' bytes of compressed data') + }) + }); + +var requestWithJar = request.defaults({jar: true}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar() +requestWithJar = request.defaults({jar:j}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar(); +cookie = request.cookie('key1=value1'); +var url = 'http://www.google.com'; +j.setCookie(cookie, url); +request({url: url, jar: j}, function () { + request('http://images.google.com'); +}); + +//TODO: add definitions for tough-cookie-filestore +//var FileCookieStore = require('tough-cookie-filestore'); +// NOTE - currently the 'cookies.json' file must already exist! +//var j = request.jar(new FileCookieStore('cookies.json')); +requestWithJar = request.defaults({ jar : j }) +request('http://www.google.com', function() { + request('http://images.google.com'); +}); + +var j = request.jar() +request({url: 'http://www.google.com', jar: j}, function () { + var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..." + var cookies = j.getCookies(url); + // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] +}); diff --git a/request/request.d.ts b/request/request.d.ts index 4827bc7a6..f3a2741fb 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -13,50 +13,50 @@ declare module 'request' { import http = require('http'); import FormData = require('form-data'); import url = require('url'); + import fs = require('fs'); - export = RequestAPI; - - function RequestAPI(uri: string, options?: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; - function RequestAPI(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; - function RequestAPI(options: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; - - module RequestAPI { - export function defaults(options: Options): typeof RequestAPI; - - export function request(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function request(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function request(options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function forever(agentOptions: any, optionsArg: any): Request; - export function jar(): CookieJar; - export function cookie(str: string): Cookie; - - export var initParams: any; - + namespace request { + export interface RequestAPI { + defaults(options: Options): RequestAPI; + (uri: string, + options?: Options, + callback?: (error: any, response: http.IncomingMessage, body: any) => void) + : Request; + (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + forever(agentOptions: any, optionsArg: any): Request; + jar(): CookieJar; + cookie(str: string): Cookie; + + initParams: any; + debug: boolean; + } + export interface Options { url?: string; uri?: string; @@ -70,7 +70,7 @@ declare module 'request' { hawk ?: HawkOptions; qs?: any; json?: any; - multipart?: RequestPart[]; + multipart?: RequestPart[] | Multipart; agentOptions?: any; agentClass?: any; forever?: any; @@ -88,17 +88,47 @@ declare module 'request' { proxy?: any; strictSSL?: boolean; gzip?: boolean; + preambleCRLF?: boolean; + postambleCRLF?: boolean; + key?: Buffer; + cert?: Buffer; + passphrase?: string; + ca?: Buffer; + har?: HttpArchiveRequest; } + + export interface HttpArchiveRequest { + url?: string; + method?: string; + headers?: NameValuePair[]; + postData?: { + mimeType?: string; + params?: NameValuePair[]; + } + } + export interface NameValuePair { + name: string; + value: string; + } + + export interface Multipart { + chunked?: boolean; + data?: { + 'content-type'?: string, + body: string + }[]; + } + export interface RequestPart { headers?: Headers; body: any; } - + export interface Request extends stream.Stream { readable: boolean; writable: boolean; - + getAgent(): http.Agent; //start(): void; //abort(): void; @@ -114,9 +144,9 @@ declare module 'request' { auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request; oauth(oauth: OAuthOptions): Request; jar(jar: CookieJar): Request; - + on(event: string, listener: Function): Request; - + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding: string, cb?: Function): boolean; @@ -131,11 +161,11 @@ declare module 'request' { destroy(): void; toJSON(): string; } - + export interface Headers { [key: string]: any; } - + export interface AuthOptions { user?: string; username?: string; @@ -144,7 +174,7 @@ declare module 'request' { sendImmediately?: boolean; bearer?: string; } - + export interface OAuthOptions { callback?: string; consumer_key?: string; @@ -153,28 +183,28 @@ declare module 'request' { token_secret?: string; verifier?: string; } - + export interface HawkOptions { credentials: any; } - + export interface AWSOptions { secret: string; bucket?: string; } - + export interface CookieJar { setCookie(cookie: Cookie, uri: string|url.Url, options?: any): void getCookieString(uri: string|url.Url): string getCookies(uri: string|url.Url): Cookie[] } - + export interface CookieValue { name: string; value: any; httpOnly: boolean; } - + export interface Cookie extends Array { constructor(name: string, req: Request): void; str: string; @@ -182,5 +212,7 @@ declare module 'request' { path: string; toString(): string; } - } + } + var request: request.RequestAPI; + export = request; } From c91de3cf9a015956bc5702a78fd04235ed677403 Mon Sep 17 00:00:00 2001 From: William Comartin Date: Wed, 7 Oct 2015 11:30:13 -0400 Subject: [PATCH 014/357] add angular-dialog-service-tests --- .../angular-dialog-service-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 angular-dialog-service/angular-dialog-service-tests.ts diff --git a/angular-dialog-service/angular-dialog-service-tests.ts b/angular-dialog-service/angular-dialog-service-tests.ts new file mode 100644 index 000000000..646b9b1ce --- /dev/null +++ b/angular-dialog-service/angular-dialog-service-tests.ts @@ -0,0 +1,16 @@ +/// + + +var options : angular.dialogservice.IDialogOptions = {}; +options.animation = true; +options.backdrop = true; +options.keyboard = true; +options.backdropClass = "some-css-class"; +options.windowClass = "some-css-class"; +options.size = 'md'; + +var dialogs : angular.dialogservice.IDialogService; +dialogs.error('Error','An unknown error occurred preventing the completion of the requested action.'); +dialogs.wait('Creating User','Please wait while we attempt to create user "Michael Conroy."

This should only take a moment.',50); +dialogs.notify('Something Happened','Something happened at this point in the application that I wish to let you know about'); +dialogs.create('url/to/a/template','ctrlrToUse',{data: topass,anotherVar: 'value'},{}); From 0078ccfafc5515a07abc501ebb93f7767855e35c Mon Sep 17 00:00:00 2001 From: William Comartin Date: Wed, 7 Oct 2015 11:33:40 -0400 Subject: [PATCH 015/357] Fix Tests for angular-dialog-service --- angular-dialog-service/angular-dialog-service-tests.ts | 2 +- angular-dialog-service/angular-dialog-service.d.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/angular-dialog-service/angular-dialog-service-tests.ts b/angular-dialog-service/angular-dialog-service-tests.ts index 646b9b1ce..8142a3a71 100644 --- a/angular-dialog-service/angular-dialog-service-tests.ts +++ b/angular-dialog-service/angular-dialog-service-tests.ts @@ -13,4 +13,4 @@ var dialogs : angular.dialogservice.IDialogService; dialogs.error('Error','An unknown error occurred preventing the completion of the requested action.'); dialogs.wait('Creating User','Please wait while we attempt to create user "Michael Conroy."

This should only take a moment.',50); dialogs.notify('Something Happened','Something happened at this point in the application that I wish to let you know about'); -dialogs.create('url/to/a/template','ctrlrToUse',{data: topass,anotherVar: 'value'},{}); +dialogs.create('url/to/a/template','ctrlrToUse',{},{}); diff --git a/angular-dialog-service/angular-dialog-service.d.ts b/angular-dialog-service/angular-dialog-service.d.ts index aa057642c..38ce8589e 100644 --- a/angular-dialog-service/angular-dialog-service.d.ts +++ b/angular-dialog-service/angular-dialog-service.d.ts @@ -60,23 +60,23 @@ declare module angular.dialogservice { /** * Opens a new error modal instance. */ - error(header: string, msg: string, progress: number, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + error(header: string, msg: string, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance /** * Opens a new wait modal instance. */ - wait(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + wait(header: string, msg: string, progress: number, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance /** * Opens a new notify modal instance. */ - notify(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + notify(header: string, msg: string, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance /** * Opens a new confirm modal instance. */ - confirm(header: string, msg: string, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + confirm(header: string, msg: string, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance /** * Opens a new custom modal instance. */ - create(url: string, ctrlr: string, data: any, opts: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance + create(url: string, ctrlr: string, data: any, opts?: IDialogOptions): ng.ui.bootstrap.IModalServiceInstance } } From 31d1cc43cd5f828fec19f35c286396f859fa47cc Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 09:41:45 -0600 Subject: [PATCH 016/357] Change request-promise to use full 'request' API --- request-promise/request-promise-tests.ts | 453 ++++++++++++++++++++++- request-promise/request-promise.d.ts | 25 +- request/request-tests.ts | 2 +- request/request.d.ts | 54 +-- 4 files changed, 486 insertions(+), 48 deletions(-) diff --git a/request-promise/request-promise-tests.ts b/request-promise/request-promise-tests.ts index 41a5eb80d..ad2f8f61f 100644 --- a/request-promise/request-promise-tests.ts +++ b/request-promise/request-promise-tests.ts @@ -1,17 +1,466 @@ /// import rp = require('request-promise'); +import nodeRequest = require('request'); rp('http://www.google.com') .then(console.dir) .catch(console.error); -var options: rp.Options = { +var options: nodeRequest.Options = { uri : 'http://posttestserver.com/post.php', - method : 'POST' + method : 'POST', + json: true, + body: { some: 'payload' } }; rp(options) .then(console.dir) .catch(console.error); +// --> Displays length of response from server after post + +// Get full response after DELETE +options = { + method: 'DELETE', + uri: 'http://my-server/path/to/resource/1234' +}; + +rp(options) + .then(function (response) { + console.log("DELETE succeeded with status %d", response.statusCode); + }) + .catch(console.error); + +//The following examples from https://github.com/request/request +import fs = require('fs'); +import http = require('http'); +var request = rp; + +//The following examples from https://github.com/request/request +request('http://www.google.com', function (error, response, body) { + if (!error && response.statusCode == 200) { + console.log(body); // Show the HTML for the Google homepage. + } +}); + +request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')); + +fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json')); + +request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://google.com/img.png') + .on('response', function(response) { + console.log(response.statusCode); // 200 + console.log(response.headers['content-type']); // 'image/png' + }) + .pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://mysite.com/doodle.png') + .on('error', function(err) { + console.log(err); + }) + .pipe(fs.createWriteStream('doodle.png')); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + if (req.method === 'PUT') { + req.pipe(request.put('http://mysite.com/doodle.png')); + } else if (req.method === 'GET' || req.method === 'HEAD') { + request.get('http://mysite.com/doodle.png').pipe(resp); + } + } +}); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + var x = request('http://mysite.com/doodle.png'); + req.pipe(x); + x.pipe(resp); + } +}); + +var resp: http.ServerResponse; +var req: nodeRequest.Request; +req.pipe(request('http://mysite.com/doodle.png')).pipe(resp); + +var r = request; +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + r.get('http://google.com/doodle.png').pipe(resp); + } +}); + +request.post('http://service.com/upload', {form:{key:'value'}}); +// or +request.post('http://service.com/upload').form({key:'value'}); +// or +request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ }); + +var data = { + // Pass a simple key-value pair + my_field: 'my_value', + // Pass data via Buffers + my_buffer: new Buffer([1, 2, 3]), + // Pass data via Streams + my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), + // Pass multiple values /w an Array + attachments: [ + fs.createReadStream(__dirname + '/attachment1.jpg'), + fs.createReadStream(__dirname + '/attachment2.jpg') + ], + // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS} + // Use case: for some types of streams, you'll need to provide "file"-related information manually. + // See the `form-data` README for more information about options: https://github.com/felixge/node-form-data + custom_file: { + value: fs.createReadStream('/dev/urandom'), + options: { + filename: 'topsecret.jpg', + contentType: 'image/jpg' + } + } +}; +request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) { + if (err) { + return console.error('upload failed:', err); + } + console.log('Upload successful! Server responded with:', body); +}); + +var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {}); +var form = requestMultipart.form(); +form.append('my_field', 'my_value'); +form.append('my_buffer', new Buffer([1, 2, 3])); +form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'}); + +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: { + chunked: false, + data: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' } + ] + } + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' }, + { body: fs.createReadStream('image.png') } + ] + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); + +request.get('http://some.server.com/').auth('username', 'password', false); +// or +request.get('http://some.server.com/', { + 'auth': { + 'user': 'username', + 'pass': 'password', + 'sendImmediately': false + } +}); +// or +request.get('http://some.server.com/').auth(null, null, true, 'bearerToken'); +// or +request.get('http://some.server.com/', { + 'auth': { + 'bearer': 'bearerToken' + } +}); + +var username = 'username', + password = 'password', + url = 'http://' + username + ':' + password + '@some.server.com'; + +request({url: url}, function (error, response, body) { + // Do more stuff with 'body' here +}); + +options = { + url: 'https://api.github.com/repos/request/request', + headers: { + 'User-Agent': 'request' + } +}; + +function callback(error, response, body) { + if (!error && response.statusCode == 200) { + var info = JSON.parse(body); + console.log(info.stargazers_count + " Stars"); + console.log(info.forks_count + " Forks"); + } +} + +request(options, callback); + +// OAuth1.0 - 3-legged server side flow (Twitter example) +// step 1 +import qs = require('querystring'); +const CONSUMER_KEY = 'key'; +const CONSUMER_SECRET = 'secret'; +var oauth = + { callback: 'http://mysite.com/callback/' + , consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + } + , url = 'https://api.twitter.com/oauth/request_token' + ; +request.post({url:url, oauth:oauth}, function (e, r, body) { + // Ideally, you would take the body in the response + // and construct a URL that a user clicks on (like a sign in button). + // The verifier is only available in the response after a user has + // verified with twitter that they are authorizing your app. + + // step 2 + var req_data = qs.parse(body); + var uri = 'https://api.twitter.com/oauth/authenticate' + + '?' + qs.stringify({oauth_token: req_data.oauth_token}); + // redirect the user to the authorize uri + + // step 3 + // after the user is redirected back to your server + var auth_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: auth_data.oauth_token + , token_secret: req_data.oauth_token_secret + , verifier: auth_data.oauth_verifier + } + , url = 'https://api.twitter.com/oauth/access_token' + ; + request.post({url:url, oauth:oauth}, function (e, r, body) { + // ready to make signed requests on behalf of the user + var perm_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: perm_data.oauth_token + , token_secret: perm_data.oauth_token_secret + } + , url = 'https://api.twitter.com/1.1/users/show.json' + , qs = + { screen_name: perm_data.screen_name + , user_id: perm_data.user_id + } + ; + request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + console.log(user); + }); + }); +}); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key') + , caFile = path.resolve(__dirname, 'ssl/ca.cert.pem'); + +options = { + url: 'https://api.some-server.com/', + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + passphrase: 'password', + ca: fs.readFileSync(caFile) +}; + +request.get(options); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key'); + +options = { + url: 'https://api.some-server.com/', + agentOptions: { + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format: + // pfx: fs.readFileSync(pfxFilePath), + passphrase: 'password', + securityOptions: 'SSL_OP_NO_SSLv3' + } +}; + +request.get(options); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + secureProtocol: 'SSLv3_method' + } +}); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + ca: fs.readFileSync('ca.cert.pem') + } +}); + + +request({ + // will be ignored + method: 'GET', + uri: 'http://www.google.com', + + // HTTP Archive Request Object + har: { + url: 'http://www.mockbin.com/har', + method: 'POST', + headers: [ + { + name: 'content-type', + value: 'application/x-www-form-urlencoded' + } + ], + postData: { + mimeType: 'application/x-www-form-urlencoded', + params: [ + { + name: 'foo', + value: 'bar' + }, + { + name: 'hello', + value: 'world' + } + ] + } + } + }); + +//requests using baseRequest() will set the 'x-token' header +var baseRequest = request.defaults({ + headers: {'x-token': 'my-token'} +}); + +//requests using specialRequest() will include the 'x-token' header set in +//baseRequest and will also include the 'special' header +var specialRequest = baseRequest.defaults({ + headers: {special: 'special value'} +}); + +request.put(url); +request.patch(url); +request.post(url); +request.head(url); +request.del(url); +request.get(url); +request.cookie('key1=value1'); +request.jar(); +request.debug = true; + +request.get('http://10.255.255.1', {timeout: 1500}, function(err) { + console.log(err.code === 'ETIMEDOUT'); + // Set to `true` if the timeout was a connection timeout, `false` or + // `undefined` otherwise. + console.log(err.connect === true); + process.exit(0); +}); + +var rand = Math.floor(Math.random()*100000000).toString(); + request( + { method: 'PUT' + , uri: 'http://mikeal.iriscouch.com/testjs/' + rand + , multipart: + [ { 'content-type': 'application/json' + , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + } + , { body: 'I am an attachment' } + ] + } + , function (error, response, body) { + if(response.statusCode == 201){ + console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + } else { + console.log('error: '+ response.statusCode) + console.log(body) + } + } + ); + +request( + { method: 'GET' + , uri: 'http://www.google.com' + , gzip: true + } + , function (error, response, body) { + // body is the decompressed response body + console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) + console.log('the decoded data is: ' + body) + } + ).on('data', function(data) { + // decompressed data as it is received + console.log('decoded chunk: ' + data) + }) + .on('response', function(response) { + // unmodified http.IncomingMessage object + response.on('data', function(data) { + // compressed data as it is received + console.log('received ' + data.length + ' bytes of compressed data') + }) + }); + +var requestWithJar = request.defaults({jar: true}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar() +requestWithJar = request.defaults({jar:j}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar(); +var cookie = request.cookie('key1=value1'); +var url = 'http://www.google.com'; +j.setCookie(cookie, url); +request({url: url, jar: j}, function () { + request('http://images.google.com'); +}); + +//TODO: add definitions for tough-cookie-filestore +//var FileCookieStore = require('tough-cookie-filestore'); +// NOTE - currently the 'cookies.json' file must already exist! +//var j = request.jar(new FileCookieStore('cookies.json')); +requestWithJar = request.defaults({ jar : j }) +request('http://www.google.com', function() { + request('http://images.google.com'); +}); + +var j = request.jar() +request({url: 'http://www.google.com', jar: j}, function () { + var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..." + var cookies = j.getCookies(url); + // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] +}); diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 246f1e5d9..67b82ebd8 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -1,31 +1,20 @@ // Type definitions for request-promise v0.4.2 // Project: https://www.npmjs.com/package/request-promise -// Definitions by: Christopher Glantschnig +// Definitions by: Christopher Glantschnig , Joe Skeen // Definitions: https://github.com/borisyankov/DefinitelyTyped // Change [0]: 2015/08/20 - Aya Morisawa -/// -/// /// /// declare module 'request-promise' { import request = require('request'); - import stream = require('stream'); - import http = require('http'); - import FormData = require('form-data'); - - export = RequestPromiseAPI; - - function RequestPromiseAPI(options: RequestPromiseAPI.Options): Promise; - function RequestPromiseAPI(uri: string): Promise; - - module RequestPromiseAPI { - export interface Options extends request.Options { - simple?: boolean; - transform?: (body: any, response: http.IncomingMessage) => any; - resolveWithFullResponse?: boolean; - } + import http = require('http'); + + interface RequestPromise extends request.Request, Promise { } + + var requestPromise: request.RequestAPI; + export = requestPromise; } diff --git a/request/request-tests.ts b/request/request-tests.ts index 7f04be26a..99c7f566c 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -33,7 +33,7 @@ var bodyArr: request.RequestPart[] = [{ // --- --- --- --- --- --- --- --- --- --- --- --- -str = req.toJSON(); +obj = req.toJSON(); var cookieValue: request.CookieValue; str = cookieValue.name; diff --git a/request/request.d.ts b/request/request.d.ts index f3a2741fb..202adf955 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -1,6 +1,6 @@ // Type definitions for request // Project: https://github.com/mikeal/request -// Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor +// Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor , Joe Skeen // Definitions: https://github.com/borisyankov/DefinitelyTyped // Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts @@ -16,40 +16,40 @@ declare module 'request' { import fs = require('fs'); namespace request { - export interface RequestAPI { - defaults(options: Options): RequestAPI; + export interface RequestAPI { + defaults(options: Options): RequestAPI; (uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void) - : Request; - (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + : TRequest; + (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - forever(agentOptions: any, optionsArg: any): Request; + forever(agentOptions: any, optionsArg: any): TRequest; jar(): CookieJar; cookie(str: string): Cookie; @@ -159,7 +159,7 @@ declare module 'request' { resume(): void; abort(): void; destroy(): void; - toJSON(): string; + toJSON(): Object; } export interface Headers { @@ -213,6 +213,6 @@ declare module 'request' { toString(): string; } } - var request: request.RequestAPI; + var request: request.RequestAPI; export = request; } From b06d25ff7a01af49ca934962021de73f4d292818 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:01:23 -0600 Subject: [PATCH 017/357] Fix implicit any issues --- request-promise/request-promise-tests.ts | 34 ++++++++-------- request/request-tests.ts | 33 ++++++++-------- request/request.d.ts | 49 ++++++++++++------------ 3 files changed, 57 insertions(+), 59 deletions(-) diff --git a/request-promise/request-promise-tests.ts b/request-promise/request-promise-tests.ts index ad2f8f61f..a4d28a8f4 100644 --- a/request-promise/request-promise-tests.ts +++ b/request-promise/request-promise-tests.ts @@ -37,7 +37,6 @@ import fs = require('fs'); import http = require('http'); var request = rp; -//The following examples from https://github.com/request/request request('http://www.google.com', function (error, response, body) { if (!error && response.statusCode == 200) { console.log(body); // Show the HTML for the Google homepage. @@ -52,7 +51,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img request .get('http://google.com/img.png') - .on('response', function(response) { + .on('response', function(response: any) { console.log(response.statusCode); // 200 console.log(response.headers['content-type']); // 'image/png' }) @@ -60,7 +59,7 @@ request request .get('http://mysite.com/doodle.png') - .on('error', function(err) { + .on('error', function(err: any) { console.log(err); }) .pipe(fs.createWriteStream('doodle.png')); @@ -212,7 +211,7 @@ options = { } }; -function callback(error, response, body) { +function callback(error: any, response: http.IncomingMessage, body: string) { if (!error && response.statusCode == 200) { var info = JSON.parse(body); console.log(info.stargazers_count + " Stars"); @@ -248,7 +247,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { // step 3 // after the user is redirected back to your server - var auth_data = qs.parse(body) + var auth_data: any = qs.parse(body) , oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET @@ -260,20 +259,19 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { ; request.post({url:url, oauth:oauth}, function (e, r, body) { // ready to make signed requests on behalf of the user - var perm_data = qs.parse(body) - , oauth = + var perm_data: any = qs.parse(body); + var oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET , token: perm_data.oauth_token , token_secret: perm_data.oauth_token_secret - } - , url = 'https://api.twitter.com/1.1/users/show.json' - , qs = - { screen_name: perm_data.screen_name - , user_id: perm_data.user_id - } - ; - request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + }; + var url = 'https://api.twitter.com/1.1/users/show.json'; + var query = { + screen_name: perm_data.screen_name, + user_id: perm_data.user_id + }; + request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) { console.log(user); }); }); @@ -418,13 +416,13 @@ request( console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) console.log('the decoded data is: ' + body) } - ).on('data', function(data) { + ).on('data', function(data: any) { // decompressed data as it is received console.log('decoded chunk: ' + data) }) - .on('response', function(response) { + .on('response', function(response: http.IncomingMessage) { // unmodified http.IncomingMessage object - response.on('data', function(data) { + response.on('data', function(data: any[]) { // compressed data as it is received console.log('received ' + data.length + ' bytes of compressed data') }) diff --git a/request/request-tests.ts b/request/request-tests.ts index 99c7f566c..2e878893b 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -212,7 +212,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img request .get('http://google.com/img.png') - .on('response', function(response) { + .on('response', function(response: any) { console.log(response.statusCode); // 200 console.log(response.headers['content-type']); // 'image/png' }) @@ -220,7 +220,7 @@ request request .get('http://mysite.com/doodle.png') - .on('error', function(err) { + .on('error', function(err: any) { console.log(err); }) .pipe(fs.createWriteStream('doodle.png')); @@ -370,7 +370,7 @@ options = { } }; -function callback(error, response, body) { +function callback(error: any, response: http.IncomingMessage, body: string) { if (!error && response.statusCode == 200) { var info = JSON.parse(body); console.log(info.stargazers_count + " Stars"); @@ -406,7 +406,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { // step 3 // after the user is redirected back to your server - var auth_data = qs.parse(body) + var auth_data: any = qs.parse(body) , oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET @@ -418,20 +418,19 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { ; request.post({url:url, oauth:oauth}, function (e, r, body) { // ready to make signed requests on behalf of the user - var perm_data = qs.parse(body) - , oauth = + var perm_data: any = qs.parse(body); + var oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET , token: perm_data.oauth_token , token_secret: perm_data.oauth_token_secret - } - , url = 'https://api.twitter.com/1.1/users/show.json' - , qs = - { screen_name: perm_data.screen_name - , user_id: perm_data.user_id - } - ; - request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + }; + var url = 'https://api.twitter.com/1.1/users/show.json'; + var query = { + screen_name: perm_data.screen_name, + user_id: perm_data.user_id + }; + request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) { console.log(user); }); }); @@ -576,13 +575,13 @@ request( console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) console.log('the decoded data is: ' + body) } - ).on('data', function(data) { + ).on('data', function(data: any) { // decompressed data as it is received console.log('decoded chunk: ' + data) }) - .on('response', function(response) { + .on('response', function(response: http.IncomingMessage) { // unmodified http.IncomingMessage object - response.on('data', function(data) { + response.on('data', function(data: any[]) { // compressed data as it is received console.log('received ' + data.length + ' bytes of compressed data') }) diff --git a/request/request.d.ts b/request/request.d.ts index 202adf955..711b3d3c1 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -18,36 +18,33 @@ declare module 'request' { namespace request { export interface RequestAPI { defaults(options: Options): RequestAPI; - (uri: string, - options?: Options, - callback?: (error: any, response: http.IncomingMessage, body: any) => void) - : TRequest; - (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + (uri: string, options?: Options, callback?: RequestCallback): TRequest; + (uri: string, callback?: RequestCallback): TRequest; + (options?: Options, callback?: RequestCallback): TRequest; - get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + get(uri: string, options?: Options, callback?: RequestCallback): TRequest; + get(uri: string, callback?: RequestCallback): TRequest; + get(options: Options, callback?: RequestCallback): TRequest; - post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + post(uri: string, options?: Options, callback?: RequestCallback): TRequest; + post(uri: string, callback?: RequestCallback): TRequest; + post(options: Options, callback?: RequestCallback): TRequest; - put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + put(uri: string, options?: Options, callback?: RequestCallback): TRequest; + put(uri: string, callback?: RequestCallback): TRequest; + put(options: Options, callback?: RequestCallback): TRequest; - head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + head(uri: string, options?: Options, callback?: RequestCallback): TRequest; + head(uri: string, callback?: RequestCallback): TRequest; + head(options: Options, callback?: RequestCallback): TRequest; - patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + patch(uri: string, options?: Options, callback?: RequestCallback): TRequest; + patch(uri: string, callback?: RequestCallback): TRequest; + patch(options: Options, callback?: RequestCallback): TRequest; - del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + del(uri: string, options?: Options, callback?: RequestCallback): TRequest; + del(uri: string, callback?: RequestCallback): TRequest; + del(options: Options, callback?: RequestCallback): TRequest; forever(agentOptions: any, optionsArg: any): TRequest; jar(): CookieJar; @@ -97,6 +94,10 @@ declare module 'request' { har?: HttpArchiveRequest; } + export interface RequestCallback { + (error: any, response: http.IncomingMessage, body: any): void; + } + export interface HttpArchiveRequest { url?: string; method?: string; From 98184ee41d3848d537e04d0414323e73cb2dbe47 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:51:29 -0600 Subject: [PATCH 018/357] Added back missing options and fixed promise exposure --- request-promise/request-promise.d.ts | 14 ++++++++++++-- request/request.d.ts | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 67b82ebd8..7a94ce596 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -12,9 +12,19 @@ declare module 'request-promise' { import request = require('request'); import http = require('http'); - interface RequestPromise extends request.Request, Promise { + interface RequestPromise extends request.Request { + then(onFulfilled: Function, onRejected: Function): Promise; + catch(onRejected: Function): Promise; + finally(onFinished: Function): Promise; + promise(): Promise; } - var requestPromise: request.RequestAPI; + interface RequestPromiseOptions extends request.Options { + simple?: boolean; + transform?: (body: any, response: http.IncomingMessage) => any; + resolveWithFullResponse?: boolean; + } + + var requestPromise: request.RequestAPI; export = requestPromise; } diff --git a/request/request.d.ts b/request/request.d.ts index 711b3d3c1..f0ec40f3b 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -16,8 +16,8 @@ declare module 'request' { import fs = require('fs'); namespace request { - export interface RequestAPI { - defaults(options: Options): RequestAPI; + export interface RequestAPI { + defaults(options: Options): RequestAPI; (uri: string, options?: Options, callback?: RequestCallback): TRequest; (uri: string, callback?: RequestCallback): TRequest; (options?: Options, callback?: RequestCallback): TRequest; @@ -214,6 +214,6 @@ declare module 'request' { toString(): string; } } - var request: request.RequestAPI; + var request: request.RequestAPI; export = request; } From 1a9a1665fb7f72239ca3e3b0b5024ff7c0963c36 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:55:24 -0600 Subject: [PATCH 019/357] fix tests --- request-promise/request-promise.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 7a94ce596..1832787be 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -13,7 +13,7 @@ declare module 'request-promise' { import http = require('http'); interface RequestPromise extends request.Request { - then(onFulfilled: Function, onRejected: Function): Promise; + then(onFulfilled: Function, onRejected?: Function): Promise; catch(onRejected: Function): Promise; finally(onFinished: Function): Promise; promise(): Promise; From 6c9b4cf0248de82bc63dee6af72fe8dfb9d2501b Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:58:20 -0600 Subject: [PATCH 020/357] fix implicit any --- request-promise/request-promise-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-promise/request-promise-tests.ts b/request-promise/request-promise-tests.ts index a4d28a8f4..347cca818 100644 --- a/request-promise/request-promise-tests.ts +++ b/request-promise/request-promise-tests.ts @@ -27,7 +27,7 @@ options = { }; rp(options) - .then(function (response) { + .then(function (response: http.IncomingMessage) { console.log("DELETE succeeded with status %d", response.statusCode); }) .catch(console.error); From 2d23048aa0c96acfa7d2c667484029acdd446896 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 11:12:48 -0600 Subject: [PATCH 021/357] Use generic Options to allow for custom options from request-promise --- request/request.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/request/request.d.ts b/request/request.d.ts index f0ec40f3b..db8ca8c7d 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -17,34 +17,34 @@ declare module 'request' { namespace request { export interface RequestAPI { - defaults(options: Options): RequestAPI; - (uri: string, options?: Options, callback?: RequestCallback): TRequest; + defaults(options: TOptions): RequestAPI; + (uri: string, options?: TOptions, callback?: RequestCallback): TRequest; (uri: string, callback?: RequestCallback): TRequest; - (options?: Options, callback?: RequestCallback): TRequest; + (options?: TOptions, callback?: RequestCallback): TRequest; - get(uri: string, options?: Options, callback?: RequestCallback): TRequest; + get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; get(uri: string, callback?: RequestCallback): TRequest; - get(options: Options, callback?: RequestCallback): TRequest; + get(options: TOptions, callback?: RequestCallback): TRequest; - post(uri: string, options?: Options, callback?: RequestCallback): TRequest; + post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; post(uri: string, callback?: RequestCallback): TRequest; - post(options: Options, callback?: RequestCallback): TRequest; + post(options: TOptions, callback?: RequestCallback): TRequest; - put(uri: string, options?: Options, callback?: RequestCallback): TRequest; + put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; put(uri: string, callback?: RequestCallback): TRequest; - put(options: Options, callback?: RequestCallback): TRequest; + put(options: TOptions, callback?: RequestCallback): TRequest; - head(uri: string, options?: Options, callback?: RequestCallback): TRequest; + head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; head(uri: string, callback?: RequestCallback): TRequest; - head(options: Options, callback?: RequestCallback): TRequest; + head(options: TOptions, callback?: RequestCallback): TRequest; - patch(uri: string, options?: Options, callback?: RequestCallback): TRequest; + patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; patch(uri: string, callback?: RequestCallback): TRequest; - patch(options: Options, callback?: RequestCallback): TRequest; + patch(options: TOptions, callback?: RequestCallback): TRequest; - del(uri: string, options?: Options, callback?: RequestCallback): TRequest; + del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; del(uri: string, callback?: RequestCallback): TRequest; - del(options: Options, callback?: RequestCallback): TRequest; + del(options: TOptions, callback?: RequestCallback): TRequest; forever(agentOptions: any, optionsArg: any): TRequest; jar(): CookieJar; From 71b6e0f1fdbc2d43e0e2423505932a14b14081f1 Mon Sep 17 00:00:00 2001 From: ashwin027 Date: Wed, 7 Oct 2015 18:47:15 -0700 Subject: [PATCH 022/357] Added missing options to IGridoptions Added missing options enableGridMenu and useExternalFiltering. --- ui-grid/ui-grid.d.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index ece964280..47a2452f8 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -600,6 +600,13 @@ declare module uiGrid { * @default false */ enableFiltering?: boolean; + /** + * False by default. When enabled, this adds a settings icon in the top right of the grid, + * which floats above the column header. The menu by default gives access to show/hide columns, + * but can be customized to show additional actions. + * @default false + */ + enableGridMenu?: boolean; /** * uiGridConstants.scrollbars.ALWAYS by default. This settings controls the horizontal scrollbar for the grid. * Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER @@ -791,6 +798,12 @@ declare module uiGrid { * @default 20 */ virtualizationThreshold?: number; + /** + * Disables client side filtering. When true, handle the filterChanged event and set data, + * defaults to false + * @default false + */ + useExternalFiltering?: boolean; /** * Default time in milliseconds to throttle scroll events to, defaults to 70ms * @default 70 From 05b17e447eea3f7ea6c3fcaca752b0316e7cd28d Mon Sep 17 00:00:00 2001 From: Jan Bevers Date: Mon, 12 Oct 2015 13:58:51 +0200 Subject: [PATCH 023/357] jQuery : updated "not" elements param to be an array (was incorrectly using a spread operator) --- jquery/jquery-tests.ts | 4 ++++ jquery/jquery.d.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 0ba33c193..62cd273f4 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -3217,6 +3217,10 @@ function test_not() { $("p").not("#selected"); $("p").not($("div p.selected")); + + var el1 = $("
")[0]; + var el2 = $("
")[0]; + $("p").not([el1, el2]); } function test_EventIsNewable() { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 5beb4e4af..aa89a8fe6 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -3050,7 +3050,7 @@ interface JQuery { * * @param elements One or more DOM elements to remove from the matched set. */ - not(...elements: Element[]): JQuery; + not(elements: Element[]): JQuery; /** * Remove elements from the set of matched elements. * From a5e51041afe166d2a736f88a7f5d281b9649ba5e Mon Sep 17 00:00:00 2001 From: Jan Bevers Date: Mon, 12 Oct 2015 15:07:14 +0200 Subject: [PATCH 024/357] jQuery : updated "not" elements param to be an element or array of element --- jquery/jquery.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index aa89a8fe6..8401753e3 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -3050,7 +3050,7 @@ interface JQuery { * * @param elements One or more DOM elements to remove from the matched set. */ - not(elements: Element[]): JQuery; + not(elements: Element|Element[]): JQuery; /** * Remove elements from the set of matched elements. * From de3b92a51fcf654881cab1f7e5409d685df09c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Bourgeois?= Date: Wed, 7 Oct 2015 22:46:56 +0200 Subject: [PATCH 025/357] Knockout KnockoutUtils cleanup. Over the time bindings over properties not exposed inside minified versions of knockout have made their way into the definitions. --- knockout/knockout.d.ts | 146 +++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 86 deletions(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index f4ad8766e..bee7041de 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -6,7 +6,7 @@ interface KnockoutSubscribableFunctions { [key: string]: KnockoutBindingHandler; - + notifySubscribers(valueToWrite?: T, event?: string): void; } @@ -16,7 +16,7 @@ interface KnockoutComputedFunctions { interface KnockoutObservableFunctions { [key: string]: KnockoutBindingHandler; - + equalityComparer(a: any, b: any): boolean; } @@ -36,7 +36,7 @@ interface KnockoutObservableArrayFunctions { // Ko specific [key: string]: KnockoutBindingHandler; - + replace(oldItem: T, newItem: T): void; remove(item: T): T[]; @@ -77,7 +77,7 @@ interface KnockoutComputedStatic { interface KnockoutComputed extends KnockoutObservable, KnockoutComputedFunctions { fn: KnockoutComputedFunctions; - + dispose(): void; isActive(): boolean; getDependenciesCount(): number; @@ -216,22 +216,12 @@ interface KnockoutExtenders { trackArrayChanges(target: any): any; } +// +// NOTE TO MAINTAINERS AND CONTRIBUTORS : pay attention to only include symbols that are +// publicly exported in the minified version of ko, without that you can give the false +// impression that some functions will be available in production builds. +// interface KnockoutUtils { - - ////////////////////////////////// - // utils.domManipulation.js - ////////////////////////////////// - - simpleHtmlParse(html: string): any[]; - - jQueryHtmlParse(html: string): any[]; - - parseHtmlFragment(html: string): any[]; - - setHtml(node: Element, html: string): void; - - setHtml(node: Element, html: () => string): void; - ////////////////////////////////// // utils.domData.js ////////////////////////////////// @@ -260,93 +250,77 @@ interface KnockoutUtils { removeNode(node: Node): void; }; - ////////////////////////////////// - // utils.js - ////////////////////////////////// - - fieldsIncludedWithJsonPost: any[]; - - compareArrays(a: T[], b: T[]): Array>; - - arrayForEach(array: T[], action: (item: T, index: number) => void): void; - - arrayIndexOf(array: T[], item: T): number; - - arrayFirst(array: T[], predicate: (item: T) => boolean, predicateOwner?: any): T; - - arrayRemoveItem(array: any[], itemToRemove: any): void; - - arrayGetDistinctValues(array: T[]): T[]; - - arrayMap(array: T[], mapping: (item: T) => U): U[]; + addOrRemoveItem(array: T[] | KnockoutObservable, value: T, included: T): void; arrayFilter(array: T[], predicate: (item: T) => boolean): T[]; + arrayFirst(array: T[], predicate: (item: T) => boolean, predicateOwner?: any): T; + + arrayForEach(array: T[], action: (item: T, index: number) => void): void; + + arrayGetDistinctValues(array: T[]): T[]; + + arrayIndexOf(array: T[], item: T): number; + + arrayMap(array: T[], mapping: (item: T) => U): U[]; + arrayPushAll(array: T[] | KnockoutObservableArray, valuesToPush: T[]): T[]; + arrayRemoveItem(array: any[], itemToRemove: any): void; + + compareArrays(a: T[], b: T[]): Array>; + extend(target: Object, source: Object): Object; - moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement; + fieldsIncludedWithJsonPost: any[]; - cloneNodes(nodesArray: any[], shouldCleanNodes: boolean): any[]; + getFormFields(form: any, fieldName: string): any[]; - setDomNodeChildren(domNode: any, childNodes: any[]): void; + objectForEach(obj: any, action: (key: any, value: any) => void): void; - replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void; + parseHtmlFragment(html: string): any[]; - setOptionNodeSelectionState(optionNode: any, isSelected: boolean): void; + parseJson(jsonString: string): any; - stringTrim(str: string): string; + postJson(urlOrForm: any, data: any, options: any): void; - stringTokenize(str: string, delimiter: string): string[]; + peekObservable(value: KnockoutObservable): T; - stringStartsWith(str: string, startsWith: string): boolean; - - domNodeIsContainedBy(node: any, containedByNode: any): boolean; - - domNodeIsAttachedToDocument(node: any): boolean; - - tagNameLower(element: any): string; + range(min: any, max: any): any; registerEventHandler(element: any, eventType: any, handler: Function): void; + setHtml(node: Element, html: () => string): void; + + setHtml(node: Element, html: string): void; + + setTextContent(element: any, textContent: string | KnockoutObservable): void; + + stringifyJson(data: any, replacer?: Function, space?: string): string; + + toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void; + triggerEvent(element: any, eventType: any): void; unwrapObservable(value: KnockoutObservable | T): T; - peekObservable(value: KnockoutObservable): T; - - toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void; - - setTextContent(element: any, textContent: string | KnockoutObservable): void; // IT's PART OF THE MINIFIED API SURFACE https://github.com/knockout/knockout/blob/master/src/utils.js#L599 - - setElementName(element: any, name: string): void; - - forceRefresh(node: any): void; - - ensureSelectElementIsRenderedCorrectly(selectElement: any): void; - - range(min: any, max: any): any; - - makeArray(arrayLikeObject: any): any[]; - - getFormFields(form: any, fieldName: string): any[]; - - parseJson(jsonString: string): any; - - stringifyJson(data: any, replacer?: Function, space?: string): string; - - postJson(urlOrForm: any, data: any, options: any): void; - - ieVersion: number; - - isIe6: boolean; - - isIe7: boolean; - - objectForEach(obj: any, action: (key: any, value: any) => void): void; - - addOrRemoveItem(array: T[] | KnockoutObservable, value: T, included: T): void; + // NOT PART OF THE MINIFIED API SURFACE (ONLY IN knockout-{version}.debug.js) https://github.com/SteveSanderson/knockout/issues/670 + // forceRefresh(node: any): void; + // ieVersion: number; + // isIe6: boolean; + // isIe7: boolean; + // jQueryHtmlParse(html: string): any[]; + // makeArray(arrayLikeObject: any): any[]; + // moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement; + // replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void; + // setDomNodeChildren(domNode: any, childNodes: any[]): void; + // setElementName(element: any, name: string): void; + // setOptionNodeSelectionState(optionNode: any, isSelected: boolean): void; + // simpleHtmlParse(html: string): any[]; + // stringStartsWith(str: string, startsWith: string): boolean; + // stringTokenize(str: string, delimiter: string): string[]; + // stringTrim(str: string): string; + // tagNameLower(element: any): string; } interface KnockoutArrayChange { @@ -575,7 +549,7 @@ interface KnockoutComputedContext { } // -// refactored types into a namespace to reduce global pollution +// refactored types into a namespace to reduce global pollution // and used Union Types to simplify overloads (requires TypeScript 1.4) // declare module KnockoutComponentTypes { From 2ae4b96283a813e22f25c13a70f577866ec2de94 Mon Sep 17 00:00:00 2001 From: Roger Chen Date: Mon, 12 Oct 2015 15:27:34 -0700 Subject: [PATCH 026/357] Change autoComplete to a string typing in React --- react/react.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/react.d.ts b/react/react.d.ts index de8ba6732..ba86c4690 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -427,7 +427,7 @@ declare namespace __React { allowTransparency?: boolean; alt?: string; async?: boolean; - autoComplete?: boolean; + autoComplete?: string; autoFocus?: boolean; autoPlay?: boolean; cellPadding?: number | string; From 1efa53d0d2f6a9281d4c5fbe0d069cdc453fb53a Mon Sep 17 00:00:00 2001 From: Cherry Ng Date: Sat, 10 Oct 2015 23:29:12 +0800 Subject: [PATCH 027/357] Add defs + tests for Bounce.js --- bounce.js/bounce-tests.ts | 77 +++++++++++++++++++++++++++++++++++++++ bounce.js/bounce.d.ts | 66 +++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 bounce.js/bounce-tests.ts create mode 100644 bounce.js/bounce.d.ts diff --git a/bounce.js/bounce-tests.ts b/bounce.js/bounce-tests.ts new file mode 100644 index 000000000..bd90bfe4c --- /dev/null +++ b/bounce.js/bounce-tests.ts @@ -0,0 +1,77 @@ +/// +/// + +import Bounce from 'bounce.js'; +import * as $ from 'jquery'; + +function test_chaining_transformations() { + var bounce = new Bounce(); + bounce + .scale({ + from: { x: 0, y: 0 }, + to: { x: 2, y: 2 }, + duration: 1000 + }) + .rotate({ + from: 0, + to: 360, + delay: 500 + }) + .translate({ + from: { x: 0, y: -100 }, + to: { x: 0, y: 0 }, + stiffness: 1, + bounces: 4 + }) + .skew({ + from: { x: 1, y: 0.8 }, + to: { x: 0.8, y: 1 }, + easing: 'bounce' + }); +} + +function test_serialization() { + var b1 = new Bounce(); + var serialized = b1.serialize(); + var b2 = new Bounce(); + b2.deserialize(serialized); +} + +function test_apply () { + var bounce = new Bounce(); + var element = document.createElement('div'); + bounce.applyTo(element); + bounce.applyTo([element]); + bounce.applyTo($('div')); + + var options = { + loop: true, + remove: true, + onComplete: () => {} + }; + bounce.applyTo(element, options); + bounce.applyTo([element], options); + bounce.applyTo($('div'), options); +} + +function test_apply_promise () { + var bounce = new Bounce(); + var element = document.createElement('div'); + bounce.applyTo($('div')).then(() => {}); + + var options = { + loop: true, + remove: true + }; + bounce.applyTo($('div')).then(() => {}); +} + +function test_define() { + var bounce = new Bounce(); + bounce.define('named-animation'); +} + +function test_remove() { + var bounce = new Bounce(); + bounce.remove(); +} diff --git a/bounce.js/bounce.d.ts b/bounce.js/bounce.d.ts new file mode 100644 index 000000000..9ff7c3a08 --- /dev/null +++ b/bounce.js/bounce.d.ts @@ -0,0 +1,66 @@ +// Type definitions for Bounce.js v0.8.2 +// Project: http://github.com/tictail/bounce.js +// Definitions by: Cherry +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'bounce.js' { + export default Bounce + + interface Point2D { + x: number + y: number + } + + interface BounceOptions { + from: T + to: T + duration?: number + delay?: number + easing?: string + bounces?: number + stiffness?: number + } + + interface AnimationOptions { + loop?: boolean + remove?: boolean + onComplete?: () => void + } + + interface SerailizedComponent { + type: string + from: T + to: T + duration: number + delay: number + easing: string + bounces: number + stiffness: number + } + + class Bounce { + static FPS: number + static counter: number + + static isSupported(): boolean + + constructor(); + + scale(options: BounceOptions): Bounce + rotate(options: BounceOptions): Bounce + translate(options: BounceOptions): Bounce + skew(options: BounceOptions): Bounce + + serialize(): SerailizedComponent[] + deserialize(serailized: SerailizedComponent[]): Bounce + + applyTo(element: Element, options?: AnimationOptions): void + applyTo(elements: Element[], options?: AnimationOptions): void + applyTo(elements: JQuery, options?: AnimationOptions): JQueryPromise + + define(name: string): Bounce + remove(): void + } +} From 5fc7b22967d562c19a7155ac7d3f744a714eb8d5 Mon Sep 17 00:00:00 2001 From: Cherry Ng Date: Tue, 13 Oct 2015 07:39:21 +0800 Subject: [PATCH 028/357] Rename bounce.js to bounce --- {bounce.js => bounce}/bounce-tests.ts | 2 +- {bounce.js => bounce}/bounce.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename {bounce.js => bounce}/bounce-tests.ts (98%) rename {bounce.js => bounce}/bounce.d.ts (98%) diff --git a/bounce.js/bounce-tests.ts b/bounce/bounce-tests.ts similarity index 98% rename from bounce.js/bounce-tests.ts rename to bounce/bounce-tests.ts index bd90bfe4c..e8dd64d2b 100644 --- a/bounce.js/bounce-tests.ts +++ b/bounce/bounce-tests.ts @@ -1,7 +1,7 @@ /// /// -import Bounce from 'bounce.js'; +import Bounce from 'bounce'; import * as $ from 'jquery'; function test_chaining_transformations() { diff --git a/bounce.js/bounce.d.ts b/bounce/bounce.d.ts similarity index 98% rename from bounce.js/bounce.d.ts rename to bounce/bounce.d.ts index 9ff7c3a08..562fa210f 100644 --- a/bounce.js/bounce.d.ts +++ b/bounce/bounce.d.ts @@ -5,7 +5,7 @@ /// -declare module 'bounce.js' { +declare module 'bounce' { export default Bounce interface Point2D { From 7053dee09501ac08e2ba1c82dfdc60eacb8e7806 Mon Sep 17 00:00:00 2001 From: Cherry Ng Date: Tue, 13 Oct 2015 07:48:19 +0800 Subject: [PATCH 029/357] Fix module naming --- bounce/bounce-tests.ts | 2 +- bounce/bounce.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bounce/bounce-tests.ts b/bounce/bounce-tests.ts index e8dd64d2b..bd90bfe4c 100644 --- a/bounce/bounce-tests.ts +++ b/bounce/bounce-tests.ts @@ -1,7 +1,7 @@ /// /// -import Bounce from 'bounce'; +import Bounce from 'bounce.js'; import * as $ from 'jquery'; function test_chaining_transformations() { diff --git a/bounce/bounce.d.ts b/bounce/bounce.d.ts index 562fa210f..9ff7c3a08 100644 --- a/bounce/bounce.d.ts +++ b/bounce/bounce.d.ts @@ -5,7 +5,7 @@ /// -declare module 'bounce' { +declare module 'bounce.js' { export default Bounce interface Point2D { From 4a18823cc7eb4b6b3f00a92129fce3268cc42f59 Mon Sep 17 00:00:00 2001 From: Dominic Alie Date: Tue, 13 Oct 2015 16:03:07 -0400 Subject: [PATCH 030/357] Leaflet.Editable type definitions --- leaflet-editable/leaflet-editable-tests.ts | 1 + leaflet-editable/leaflet-editable.d.ts | 256 +++++++++++++++++++++ 2 files changed, 257 insertions(+) create mode 100644 leaflet-editable/leaflet-editable-tests.ts create mode 100644 leaflet-editable/leaflet-editable.d.ts diff --git a/leaflet-editable/leaflet-editable-tests.ts b/leaflet-editable/leaflet-editable-tests.ts new file mode 100644 index 000000000..ebb90cc97 --- /dev/null +++ b/leaflet-editable/leaflet-editable-tests.ts @@ -0,0 +1 @@ +/// \ No newline at end of file diff --git a/leaflet-editable/leaflet-editable.d.ts b/leaflet-editable/leaflet-editable.d.ts new file mode 100644 index 000000000..663cd7573 --- /dev/null +++ b/leaflet-editable/leaflet-editable.d.ts @@ -0,0 +1,256 @@ +// Type definitions for Leaflet.Editable 0.7 +// Project: https://github.com/yohanboniface/Leaflet.Editable +// Definitions by: Dominic Alie +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module L { + /** + * Make geometries editable in Leaflet. + * + * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to + * control editing of geometries. So you can easily build your own UI with your own needs and choices. + */ + export interface EditableStatic { + new (map: Map, options: EditOptions): Editable; + } + + /** + * Options to pass to L.Editable when instanciating. + */ + export interface EditOptions { + /** + * Class to be used when creating a new Polyline. + */ + polylineClass?: Object; + + /** + * Class to be used when creating a new Polygon. + */ + polygonClass?: Object; + + /** + * Class to be used when creating a new Marker. + */ + markerClass?: Object; + + /** + * CSS class to be added to the map container while drawing. + */ + drawingCSSClass?: string; + + /** + * Layer used to store edit tools (vertex, line guide…). + */ + editLayer?: L.LayerGroup; + + /** + * Default layer used to store drawn features (marker, polyline…). + */ + featuresLayer?: L.LayerGroup; + + /** + * Class to be used as vertex, for path editing. + */ + vertexMarkerClass?: Object; + + /** + * Class to be used as middle vertex, pulled by the user to create a new point in the middle of a path. + */ + middleMarkerClass?: Object; + + /** + * Class to be used as Polyline editor. + */ + polylineEditorClass?: Object; + + /** + * Class to be used as Polygon editor. + */ + polygonEditorClass?: Object; + + /** + * Class to be used as Marker editor. + */ + markerEditorClass?: Object; + + /** + * Options to be passed to the line guides. + */ + lineGuideOptions?: Object; + + /** + * Set this to true if you don't want middle markers. + */ + skipMiddleMarkers?: boolean; + } + + /** + * Make geometries editable in Leaflet. + * + * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to + * control editing of geometries. So you can easily build your own UI with your own needs and choices. + */ + export interface Editable extends Mixin.LeafletMixinEvents { + /** + * Options to pass to L.Editable when instanciating. + */ + options: EditOptions; + + currentPolygon: Polyline|Polygon|Marker; + + /** + * Start drawing a polyline. If latlng is given, a first point will be added. In any case, continuing on user + * click. If options is given, it will be passed to the polyline class constructor. + */ + startPolyline(latLng?: LatLng, options?: L.PolylineOptions): L.Polyline; + + /** + * Start drawing a polygon. If latlng is given, a first point will be added. In any case, continuing on user + * click. If options is given, it will be passed to the polygon class constructor. + */ + startPolygon(latLng?: LatLng, options?: L.PolylineOptions): L.Polygon; + + /** + * Start adding a marker. If latlng is given, the marker will be shown first at this point. In any case, it + * will follow the user mouse, and will have a final latlng on next click (or touch). If options is given, + * it will be passed to the marker class constructor. + */ + startMarker(latLng?: LatLng, options?: L.MarkerOptions): L.Marker; + + /** + * When you need to stop any ongoing drawing, without needing to know which editor is active. + */ + stopDrawing(): void; + } + + export var Editable: EditableStatic; + + /** + * EditableMixin is included to L.Polyline, L.Polygon and L.Marker. It adds the following methods to them. + * + * When editing is enabled, the editor is accessible on the instance with the editor property. + */ + export interface EditableMixin { + /** + * Enable editing, by creating an editor if not existing, and then calling enable on it. + */ + enableEdit(): any; + + /** + * Disable editing, also remove the editor property reference. + */ + disableEdit(): void; + + /** + * Enable or disable editing, according to current status. + */ + toggleEdit(): void; + + /** + * Return true if current instance has an editor attached, and this editor is enabled. + */ + editEnabled(): boolean; + } + + export interface Map { + /** + * Whether to create a L.Editable instance at map init or not. + */ + editable: boolean; + + /** + * Options to pass to L.Editable when instanciating. + */ + editOptions: EditOptions; + + /** + * L.Editable plugin instance. + */ + editTools: Editable; + } + + export interface Polyline extends EditableMixin { + } + + export interface MapOptions { + /** + * Whether to create a L.Editable instance at map init or not. + */ + editable?: boolean; + + /** + * Options to pass to L.Editable when instanciating. + */ + editOptions?: EditOptions; + } + + /** + * When editing a feature (marker, polyline…), an editor is attached to it. This editor basically knows + * how to handle the edition. + */ + export interface BaseEditor { + /** + * Set up the drawing tools for the feature to be editable. + */ + enable(): MarkerEditor|PolylineEditor|PolygonEditor; + + /** + * Remove editing tools. + */ + disable(): MarkerEditor|PolylineEditor|PolygonEditor; + } + + /** + * Inherit from L.Editable.BaseEditor. + * Inherited by L.Editable.PolylineEditor and L.Editable.PolygonEditor. + */ + export interface PathEditor extends BaseEditor { + /** + * Rebuild edit elements (vertex, middlemarker, etc.). + */ + reset(): void; + } + + /** + * Inherit from L.Editable.PathEditor. + */ + export interface PolylineEditor extends PathEditor { + /** + * Set up drawing tools to continue the line forward. + */ + continueForward(): void; + + /** + * Set up drawing tools to continue the line backward. + */ + continueBackward(): void; + } + + /** + * Inherit from L.Editable.PathEditor. + */ + export interface PolygonEditor extends PathEditor { + /** + * Set up drawing tools for creating a new hole on the polygon. If the latlng param is given, a first + * point is created. + */ + newHole(latlng: LatLng): void; + } + + /** + * Inherit from L.Editable.BaseEditor. + */ + export interface MarkerEditor extends BaseEditor { + } + + export interface Marker extends EditableMixin, MarkerEditor { + } + + export interface Polyline extends EditableMixin, PolylineEditor { + } + + export interface Polygon extends EditableMixin, PolygonEditor { + } +} \ No newline at end of file From 8be1e783befd89f43cf62907dab718a9a33a18d9 Mon Sep 17 00:00:00 2001 From: Jared Klopper Date: Wed, 14 Oct 2015 13:39:09 +1300 Subject: [PATCH 031/357] Add object parsing overload to moment setter --- moment/moment-node.d.ts | 3 ++- moment/moment-tests.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/moment/moment-node.d.ts b/moment/moment-node.d.ts index 93be9f6d4..9490d0320 100644 --- a/moment/moment-node.d.ts +++ b/moment/moment-node.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Moment.js 2.8.0 +// Type definitions for Moment.js 2.10.6 // Project: https://github.com/timrwood/moment // Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -303,6 +303,7 @@ declare module moment { get(unit: string): number; set(unit: string, value: number): Moment; + set(input: MomentInput): Moment; } type formatFunction = () => string; diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index 29712c115..28fedc65e 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -127,6 +127,15 @@ moment().isoWeeks(45); moment().dayOfYear(); moment().dayOfYear(45); +moment().set('year', 2013); +moment().set('month', 3); // April +moment().set('date', 1); +moment().set('hour', 13); +moment().set('minute', 20); +moment().set('second', 30); +moment().set('millisecond', 123); +moment().set({'year': 2013, 'month': 3}); + var getMilliseconds: number = moment().milliseconds(); var getSeconds: number = moment().seconds(); var getMinutes: number = moment().minutes(); From 3e7df0c95a5136d899c977d019744d3e5efbfe97 Mon Sep 17 00:00:00 2001 From: hamza zia Date: Wed, 14 Oct 2015 13:48:59 +0800 Subject: [PATCH 032/357] added rethink promise API --- rethinkdb/rethinkdb-tests.ts | 24 +++++++++++++++++++++--- rethinkdb/rethinkdb.d.ts | 15 ++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/rethinkdb/rethinkdb-tests.ts b/rethinkdb/rethinkdb-tests.ts index e94e5271c..a6911e302 100644 --- a/rethinkdb/rethinkdb-tests.ts +++ b/rethinkdb/rethinkdb-tests.ts @@ -7,9 +7,9 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) { var testDb = r.db('test') testDb.tableCreate('users').run(conn, function(err, stuff) { var users = testDb.table('users') - + users.insert({name: "bob"}).run(conn, function() {}) - + users.filter(function(doc?) { return doc("henry").eq("bob") }) @@ -19,6 +19,24 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) { }) + }) +}) + +// use promises instead of callbacks +r.connect({host:"localhost", port: 28015}).then(function(conn) { + console.log("HI", conn) + var testDb = r.db('test') + testDb.tableCreate('users').run(conn).then(function(stuff) { + var users = testDb.table('users') + + users.insert({name: "bob"}).run(conn, function() {}) + + users.filter(function(doc?) { + return doc("henry").eq("bob") + }) + .between("james", "beth") + .limit(4) + .run(conn); }) -}) \ No newline at end of file +}) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 2c65a7cf4..22b721b9a 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -4,10 +4,11 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped // Reference: http://www.rethinkdb.com/api/#js // TODO: Document manipulation and below +/// declare module "rethinkdb" { - export function connect(host:ConnectionOptions, cb:(err:Error, conn:Connection)=>void); + export function connect(host:ConnectionOptions, cb?:(err:Error, conn:Connection)=>void):Promise; export function dbCreate(name:string):Operation; export function dbDrop(name:string):Operation; @@ -50,7 +51,7 @@ declare module "rethinkdb" { interface Connection { close(); - reconnect(cb:(err:Error, conn:Connection)=>void); + reconnect(cb?:(err:Error, conn:Connection)=>void):Promise; use(dbName:string); addListener(event:string, cb:Function); on(event:string, cb:Function); @@ -139,11 +140,11 @@ declare module "rethinkdb" { } interface ExpressionFunction { - (doc:Expression):Expression; + (doc:Expression):Expression; } interface JoinFunction { - (left:Expression, right:Expression):Expression; + (left:Expression, right:Expression):Expression; } interface ReduceFunction { @@ -159,7 +160,7 @@ declare module "rethinkdb" { interface UpdateOptions { non_atomic: boolean; durability: string; // 'soft' - return_vals: boolean; // false + return_vals: boolean; // false } interface WriteResult { @@ -193,7 +194,7 @@ declare module "rethinkdb" { } interface Expression extends Writeable, Operation { - (prop:string):Expression; + (prop:string):Expression; merge(query:Expression):Expression; append(prop:string):Expression; contains(prop:string):Expression; @@ -221,7 +222,7 @@ declare module "rethinkdb" { } interface Operation { - run(conn:Connection, cb:(err:Error, result:T)=>void); + run(conn:Connection, cb?:(err:Error, result:T)=>void):Promise; } interface Aggregator {} From d5e0dcb4c74fb6bef454898238c68fb96e53ddc3 Mon Sep 17 00:00:00 2001 From: Kopleman Date: Wed, 14 Oct 2015 09:45:23 +0300 Subject: [PATCH 033/357] Updating angilar-ui-router.d.ts. Adding missed cache?:boolean to IState interaface --- angular-ui-router/angular-ui-router.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts index 3ec31968c..1164079e7 100644 --- a/angular-ui-router/angular-ui-router.d.ts +++ b/angular-ui-router/angular-ui-router.d.ts @@ -71,10 +71,16 @@ declare module angular.ui { * Arbitrary data object, useful for custom configuration. */ data?: any; + /** * Boolean (default true). If false will not re-trigger the same state just because a search/query parameter has changed. Useful for when you'd like to modify $location.search() without triggering a reload. */ reloadOnSearch?: boolean; + + /** + * Boolean (default true). If false will reload state on everytransitions. Useful for when you'd like to restore all data to its initial state. + */ + cache?: boolean; } interface IStateProvider extends angular.IServiceProvider { From f13c1b1248ebeee0f8ac239e5478a076803d6444 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 14 Oct 2015 10:45:11 +0200 Subject: [PATCH 034/357] denodeify --- denodeify/denodeify-tests.ts | 10 ++++++++++ denodeify/denodeify.d.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 denodeify/denodeify-tests.ts create mode 100644 denodeify/denodeify.d.ts diff --git a/denodeify/denodeify-tests.ts b/denodeify/denodeify-tests.ts new file mode 100644 index 000000000..0cd6a0c98 --- /dev/null +++ b/denodeify/denodeify-tests.ts @@ -0,0 +1,10 @@ +/// +/// +/// + +import denodeify = require("denodeify"); +import fs = require('fs'); +import cp = require('child_process'); + +const readFile = denodeify(fs.readFile); +const exec = denodeify(cp.exec, (err, stdout, stderr) => [err, stdout]); \ No newline at end of file diff --git a/denodeify/denodeify.d.ts b/denodeify/denodeify.d.ts new file mode 100644 index 000000000..fec2fbf3c --- /dev/null +++ b/denodeify/denodeify.d.ts @@ -0,0 +1,36 @@ +// Type definitions for denodeify 1.2.1 +// Project: https://github.com/matthew-andrews/denodeify +// Definitions by: joaomoreno +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "denodeify" { + function _(fn: _.F0, transformer?: _.M): () => Promise; + function _(fn: _.F1, transformer?: _.M): (a:A) => Promise; + function _(fn: _.F2, transformer?: _.M): (a:A, b:B) => Promise; + function _(fn: _.F3, transformer?: _.M): (a:A, b:B, c:C) => Promise; + function _(fn: _.F4, transformer?: _.M): (a:A, b:B, c:C, d:D) => Promise; + function _(fn: _.F5, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E) => Promise; + function _(fn: _.F6, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E, f:F) => Promise; + function _(fn: _.F7, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E, f:F, g:G) => Promise; + function _(fn: _.F8, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E, f:F, g:G, h:H) => Promise; + function _(fn: _.F, transformer?: _.M): (...args: any[]) => Promise; + + module _ { + type Callback = (err: Error, result: R) => any; + type F0 = (cb: Callback) => any; + type F1 = (a:A, cb: Callback) => any; + type F2 = (a:A, b:B, cb: Callback) => any; + type F3 = (a:A, b:B, c:C, cb: Callback) => any; + type F4 = (a:A, b:B, c:C, d:D, cb: Callback) => any; + type F5 = (a:A, b:B, c:C, d:D, e:E, cb: Callback) => any; + type F6 = (a:A, b:B, c:C, d:D, e:E, f:F, cb: Callback) => any; + type F7 = (a:A, b:B, c:C, d:D, e:E, f:F, g:G, cb: Callback) => any; + type F8 = (a:A, b:B, c:C, d:D, e:E, f:F, g:G, h:H, cb: Callback) => any; + type F = (...args: any[]) => any; + type M = (err: Error, ...args: any[]) => any[]; + } + + export = _; +} \ No newline at end of file From 96d71628078c65c92d1ed4b782b723919678d91f Mon Sep 17 00:00:00 2001 From: Abubaker Bashir Date: Wed, 14 Oct 2015 12:33:11 +0100 Subject: [PATCH 035/357] Added config singleton and missing properties Added - CKEDITOR.config : singleton ([doc link](http://docs.ckeditor.com/#!/api/CKEDITOR.config)) - config.contentsCss - string or string array ([doc link](http://docs.ckeditor.com/#!/api/CKEDITOR.config)) - customConfig - string ([doc link](http://docs.ckeditor.com/#!/api/CKEDITOR.config)) --- ckeditor/ckeditor.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ckeditor/ckeditor.d.ts b/ckeditor/ckeditor.d.ts index a8f268074..cab51f72c 100644 --- a/ckeditor/ckeditor.d.ts +++ b/ckeditor/ckeditor.d.ts @@ -64,6 +64,7 @@ declare module CKEDITOR { var status: string; var timestamp: string; var version: string; + var config: config; // Methods @@ -556,6 +557,7 @@ declare module CKEDITOR { } interface config { + contentsCss?: string | string[]; startupMode?: string; removeButtons?: string; removePlugins?: string; @@ -576,6 +578,7 @@ declare module CKEDITOR { height?: string | number; toolbarLocation?: string; readOnly?: boolean; + customConfig?: string; } From 0159e32ca7e4b549ba0c962189680d7c833b3e5d Mon Sep 17 00:00:00 2001 From: voximplant Date: Wed, 14 Oct 2015 14:57:55 +0300 Subject: [PATCH 036/357] Initial commit --- voximplant-websdk/voximplant-websdk-tests.ts | 85 ++ voximplant-websdk/voximplant-websdk.d.ts | 1165 ++++++++++++++++++ 2 files changed, 1250 insertions(+) create mode 100644 voximplant-websdk/voximplant-websdk-tests.ts create mode 100644 voximplant-websdk/voximplant-websdk.d.ts diff --git a/voximplant-websdk/voximplant-websdk-tests.ts b/voximplant-websdk/voximplant-websdk-tests.ts new file mode 100644 index 000000000..2a9363c37 --- /dev/null +++ b/voximplant-websdk/voximplant-websdk-tests.ts @@ -0,0 +1,85 @@ +/// + +var vox: VoxImplant.Client = VoxImplant.getInstance(), + call: VoxImplant.Call; + +vox.init({ + micRequired: true +}); + +vox.addEventListener("SDKReady", function(event: VoxImplant.Events.SDKReady) { + console.log("VoxImplant SDK ver. " + event.version + " initialized"); + vox.connect(); +}); + +vox.addEventListener("ConnectionEstablished", function(event: VoxImplant.Events.ConnectionEstablished) { + console.log("Connection established"); + vox.login("username", "password"); +}); + +vox.addEventListener("ConnectionClosed", function(event: VoxImplant.Events.ConnectionClosed) { + console.log("Connection closed"); +}); + +vox.addEventListener("ConnectionFailed", function(event: VoxImplant.Events.ConnectionFailed) { + console.log("Connection failed. Reason: " + event.message); +}); + +vox.addEventListener("AuthEvent", function(event: VoxImplant.Events.AuthEvent) { + if (event.result === true) { + // Authorized successfully + console.log("Logged in as " + event.displayName); + + call = vox.call("some_number", false); + call.addEventListener("Connected", function(callevent: VoxImplant.CallEvents.Connected) { + console.log("Call connected"); + }); + call.addEventListener("Failed", function(callevent: VoxImplant.CallEvents.Failed) { + console.log("Call failed, reason: " + callevent.reason); + }); + call.addEventListener("Disconnected", function(callevent: VoxImplant.CallEvents.Disconnected) { + console.log("Call disconnected"); + }); + + var msg_id:String = vox.sendInstantMessage("other_user", "Hello World!"); + + } else { + console.log("Authorization failed. Code: " + event.code); + } +}); + +vox.addEventListener("MicAccessResult", function(event: VoxImplant.Events.MicAccessResult) { + console.log("Microphone access allowed: " + event.result); +}); + +vox.addEventListener("IncomingCall", function(event: VoxImplant.Events.IncomingCall) { + call = event.call; + call.addEventListener("Connected", function(callevent: VoxImplant.CallEvents.Connected) { + console.log("Inbound Call Connected"); + setTimeout(function() { + vox.disconnect(); + }, 5000); + }); + call.answer(); +}); + +vox.addEventListener("MessageReceived", function(event: VoxImplant.IMEvents.MessageReceived) { + console.log("Message received: " + event.content + " from " + event.id + " id " + event.message_id); +}); + +vox.addEventListener("SourcesInfoUpdated", function(event: VoxImplant.Events.SourcesInfoUpdated) { + var audioSources: VoxImplant.AudioSourceInfo[] = vox.audioSources(), + videoSources: VoxImplant.VideoSourceInfo[] = vox.videoSources(); + console.log("Received recording sources data:"); + console.log("Audio: " + audioSources); + console.log("Video: " + videoSources); + + vox.useAudioSource(audioSources[0].id, function() { console.log('OK'); }, function() { console.log('Failed'); }); + vox.useVideoSource(videoSources[0].id, function() { console.log('OK'); }, function() { console.log('Failed'); }); +}); + +vox.addEventListener("RosterReceived", function(event: VoxImplant.IMEvents.RosterReceived) { + var roster: VoxImplant.RosterItem[] = event.roster; + console.log("Roster received: " + roster); +}); + diff --git a/voximplant-websdk/voximplant-websdk.d.ts b/voximplant-websdk/voximplant-websdk.d.ts new file mode 100644 index 000000000..1609b6e70 --- /dev/null +++ b/voximplant-websdk/voximplant-websdk.d.ts @@ -0,0 +1,1165 @@ +// Type definitions for VoxImplant Web SDK 3.0.x +// Project: http://voximplant.com/ +// Definitions by: Alexey Aylarov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module VoxImplant { + + module Events { + + /** + * Event dispatched after login , loginWithOneTimeKey, requestOneTimeLoginKey or loginWithCode function call + */ + interface AuthEvent { + /** + * Auth error code, possible values are: 301 - code for 'code' auth type was sent, 302 - key for 'onetimekey' auth type received, 401 - invalid password, 404 - invalid username, 403 - user account is frozen, 500 - internal error + */ + code? : number; + /** + * Authorized user's display name + */ + displayName?: string; + /** + * This parameter is used to calculate hash parameter for loginWithOneTimeKey method. AuthEvent with the key dispatched after requestOneTimeLoginKey method was called + */ + key?: string; + /** + * Application options + */ + options?: Object; + /** + * True in case of successful authorization, false - otherwise + */ + result: boolean; + } + + /** + * Event dispatched if connection to VoxImplant Cloud was closed because of network problems. See connect function + */ + interface ConnectionClosed {} + + /** + * Event dispatched after connection to VoxImplant Cloud was established successfully. See connect function + */ + interface ConnectionEstablished {} + + /** + * Event dispatched if connection to VoxImplant Cloud couldn't be established. See connect function + */ + interface ConnectionFailed { + /** + * Failure reason description + */ + message: string; + } + + /** + * Event dispatched in case of instant messaging subsystem error + */ + interface IMError { + /** + * Error data object, contains the error details + */ + errorData: Object; + /** + * Error type + */ + errorType: IMErrorType; + } + + /** + * Event dispatched when there is a new incoming call to current user + */ + interface IncomingCall { + /** + * Incoming call instance. See VoxImplant.Call for details + */ + call: Call; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + } + + /** + * Event dispatched after user interaction with the mic access dialog. + */ + interface MicAccessResult { + /** + * True is access was allowed, false - otherwise + */ + result: boolean; + } + + /** + * Event dispatched when packet loss data received from VoxImplant servers + */ + interface NetStatsReceived { + /** + * Network info object + */ + stats: NetworkInfo; + } + + /** + * Event dispatched after sound playback was stopped. See playToneScript and stopPlayback functions + */ + interface PlaybackFinished {} + + /** + * Event dispatched after SDK was successfully initialized after init function call + */ + interface SDKReady { + /** + * SDK version + */ + version: string; + } + + /** + * Event dispatched when audio and video sources information was updated. See audioSources and videoSources for details + */ + interface SourcesInfoUpdated {} + + } + + module CallEvents { + + /** + * Event dispatched after call was connected + */ + interface Connected { + /** + * Call that dispatched the event + */ + call: Call; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + } + + /** + * Event dispatched after call was disconnected + */ + interface Disconnected { + /** + * Call that dispatched the event + */ + call: Call; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + } + + /** + * Event dispatched after if call failed + */ + interface Failed { + /** + * Call that dispatched the event + */ + call: Call; + /** + * Status code of the call (i.e. 486) + */ + code: number; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + /** + * Status message of call failure (i.e. Busy Here) + */ + reason: string; + } + + /** + * Event dispatched when INFO message is received + */ + interface InfoReceived { + /** + * Content of the message + */ + body: string; + /** + * Call that dispatched the event + */ + call: Call; + /** + * Optional SIP headers received with the message + */ + headers?: Object; + /** + * MIME type of INFO message + */ + mimeType: string; + } + + /** + * Event dispatched when text message is received + */ + interface MessageReceived { + /** + * Call that dispatched the event + */ + call: Call; + /** + * Content of the message + */ + text: string; + } + + /** + * Event dispatched when progress tone playback starts + */ + interface ProgressToneStart { + /** + * Call that dispatched the event + */ + call: Call; + } + + /** + * Event dispatched when progress tone playback stops + */ + interface ProgressToneStop { + /** + * Call that dispatched the event + */ + call: Call; + } + + /** + * Event dispatched when call has been transferred successfully + */ + interface TransferComplete { + /** + * Call that dispatched the event + */ + call: Call; + } + + /** + * Event dispatched when call transfer failed + */ + interface TransferFailed { + /** + * Call that dispatched the event + */ + call: Call; + } + } + + module IMEvents { + + /** + * Event dispatched when chat session state updated + */ + interface ChatStateUpdate { + /** + * User id + */ + id: string, + /** + * Resource name + */ + resource?: string, + /** + * Current chat session state. See VoxImplant.ChatStateType enum + */ + state: ChatStateType + } + + /** + * Event dispatched when instant message received + */ + interface MessageReceived { + /** + * Message content + */ + content: string, + /** + * User id + */ + id: string, + /** + * Message id + */ + message_id: string, + /** + * Resource name + */ + resource?: string + } + + /** + * Event dispatched when sent message status changed + */ + interface MessageStatus { + /** + * User id + */ + id: string, + /** + * Message id + */ + message_id: string, + /** + * Resource name + */ + resource?: string, + /** + * Message event type. See VoxImplant.MessageEventType enum + */ + type: MessageEventType + } + + /** + * Event dispatched when self presence updated + */ + interface PresenceUpdate { + /** + * User id + */ + id: string, + /** + * Status message + */ + message: string, + /** + * Current presence status + */ + presence: UserStatuses, + /** + * Resource name + */ + resource?: string + } + + /** + * Event dispatched when roster item changed + */ + interface RosterItemChange { + /** + * User display name + */ + displayName: string, + /** + * User id + */ + id: string, + /** + * Resource name + */ + resource?: string, + /** + * Roster item event type. See VoxImplant.RosterItemEvent enum + */ + type: RosterItemEvent + } + + /** + * Event dispatched when roster item presence update happened + */ + interface RosterPresenceUpdate { + /** + * User id + */ + id: string, + /** + * Status message + */ + message?: string, + /** + * Current presence status + */ + presence: UserStatuses, + /** + * Resource name + */ + resource?: string + } + + /** + * Event dispatched when roster data received + */ + interface RosterReceived { + /** + * User id + */ + id: string, + /** + * Array contains VoxImplant.RosterItem elements + */ + roster: RosterItem[] + } + + /** + * Event dispatched when some user tries to add current user into his roster. Current user can confirm or reject the subscription, then VoxImplant.IMEvents.RosterItemChange will be dispatched on for user that made the request + */ + interface SubscriptionRequest { + /** + * User id + */ + id: string, + /** + * Optional message + */ + message?: string, + /** + * Resource name + */ + resource?: string, + /** + * Message event type. See VoxImplant.SubscriptionRequestType enum + */ + type: SubscriptionRequestType + } + + } + + type VoxImplantEvent = Events.AuthEvent | Events.ConnectionClosed | Events.ConnectionEstablished | + Events.ConnectionFailed | Events.IMError | Events.IncomingCall | Events.MicAccessResult | + Events.NetStatsReceived | Events.PlaybackFinished | Events.SDKReady | Events.SourcesInfoUpdated; + + + type VoxImplantCallEvent = CallEvents.Connected | CallEvents.Disconnected | CallEvents.Failed | + CallEvents.InfoReceived | CallEvents.MessageReceived | CallEvents.ProgressToneStart | + CallEvents.ProgressToneStop | CallEvents.TransferComplete | CallEvents.TransferFailed; + + type VoxImplantIMEvent = IMEvents.ChatStateUpdate | IMEvents.MessageReceived | IMEvents.MessageStatus | + IMEvents.PresenceUpdate | IMEvents.RosterItemChange | IMEvents.RosterPresenceUpdate | + IMEvents.RosterReceived | IMEvents.SubscriptionRequest; + + /** + * VoxImplant SDK Configuration + */ + interface Config { + /** + * XSS protection for inbound instant messages that can contain HTML content + */ + imXSSprotection?: boolean; + /** + * If set to true microphone access dialog will be shown and all functions will become available only after user allowed access + */ + micRequired?: boolean; + /** + * Automatically plays progress tone by means of SDK according to specified progressToneCountry + */ + progressTone?: boolean; + /** + * Country code for progress tone generated automatically if progressTone set to true + */ + progressToneCountry?: string; + /** + * Show debug info in console + */ + showDebugInfo?: boolean; + /** + * Show Flash Settings panel instead of standard Allow/Deny dialog (in Flash mode) + */ + showFlashSettings?: boolean; + /** + * Id of HTMLElement that will be used as container for Flash component of SDK (Mic/cam access dialog will appear in the container). If micRequired set to true element should have size not less than 215x138 (px) for access dialog to be shown + */ + swfContainer?: string; + /** + * Force VoxImplant to use Flash (WebRTC is used if available by default) + */ + useFlashOnly?: boolean; + /** + * Force VoxImplant to use WebRTC (WebRTC is used if available by default). Error will be thrown if WebRTC in unavailable + */ + useRTCOnly?: boolean; + /** + * Default constraints that will be applied while the next attachRecordingDevice function call or if micRequired set to true + */ + videoConstraints?: VideoSettings; + /** + * Video support + */ + videoSupport?: boolean; + } + + /** + * VoxImplant login options + */ + interface LoginOptions { + /** + * If set to false Web SDK can be used only for ACD status management + */ + receiveCalls?: boolean; + /** + * If set to true user presence will be changed automatically while a call + */ + serverPresenceControl?: boolean; + } + + /** + * Audio recording device info + */ + interface AudioSourceInfo { + /** + * Device id that can be used to choose audio recording device + */ + id: number | string; + /** + * Device name , in WebRTC mode populated with real data only when app has been opened using HTTPS protocol + */ + name: string; + } + + /** + * Video recording device info + */ + interface VideoSourceInfo { + /** + * Device id that can be used to choose video recording device + */ + id: number | string; + /** + * Device name , in WebRTC mode populated with real data only when app has been opened using HTTPS protocol + */ + name: string; + } + + enum ChatStateType { + /** + * User is actively participating in the chat session + */ + Active, + /** + * User is composing a message + */ + Composing, + /** + * User has effectively ended their participation in the chat session + */ + Gone, + /** + * User has not been actively participating in the chat session + */ + Inactive, + /** + * Invalid type + */ + Invalid, + /** + * User had been composing but now has stopped + */ + Paused + } + + enum IMErrorType { + RemoteFunctionError, + Error, + RosterError + } + + enum MessageEventType { + /** + * Cancels the 'Composing' event + */ + Cancel, + /** + * Indicates that a reply is being composed + */ + Composing, + /** + * Indicates that the message has been delivered to the recipient + */ + Delivered, + /** + * Indicates that the message has been displayed + */ + Displayed, + /** + * Invalid type + */ + Invalid, + /** + * Indicates that the message has been stored offline by the intended recipient's server + */ + Offline + } + + enum OperatorACDStatuses { + AfterService, + DND, + InService, + Offline, + Online, + Ready, + Timeout + } + + enum RosterItemEvent { + /** + * Roster item added + */ + Added, + /** + * Roster item removed + */ + Removed, + /** + * User subscribed on your status updates (authorized the request) + */ + Subscribed, + /** + * User unsubscribed from your status updates (didn't authorize the request) + */ + Unsubscribed, + /** + * Roster item updated + */ + Updated + } + + enum SubscriptionRequestType { + /** + * User is asking for permission to add you into his roster + */ + Subscribe, + /** + * User removed you from his roster + */ + Unsubscribe + } + + enum UserStatuses { + /** + * User is away + */ + Away, + /** + * User is available for chat + */ + Chat, + /** + * User is in DND state (Do Not Disturbed) + */ + DND, + /** + * User is offline + */ + Offline, + /** + * User is online + */ + Online, + /** + * User is in XA state (eXtended Away) + */ + XA + } + + /** + * Client class used to control platform functions. Can't be instantiatied directly (singleton), please use VoxImplant.getInstance to get the class instance + */ + interface Client { + /** + * Register handler for specified event + * + * @param eventName Event name + * @param eventHandler Handler function. A single parameter is passed - object with the event information + */ + addEventListener(eventName: string, eventHandler: (eventObject: VoxImplantEvent | VoxImplantIMEvent) => any): void; + /** + * Add roster item (IM) + * + * @param user_id User id + * @param name Display name + * @param group User group + */ + addRosterItem(user_id: string, name: string, group?: string): void; + /** + * Add roster item group (IM) + * + * @param user_id User id + * @param group Group name + */ + addRosterItemGroup(user_id: string, group: string): void; + /** + * Enable microphone/camera if micRequired in VoxImplant.Config was set to false (WebRTC mode only) + * + * @param successCallback A function called in case of successful audio recording device change + * @param failedCallback A function called in case of problems while changing audio recording device + */ + attachRecordingDevice(successCallback?: () => any, failedCallback?: () => any): void; + /** + * Get a list of all currently available audio sources / microphones + */ + audioSources(): AudioSourceInfo[]; + /** + * Create call + * + * @param number The number to call + * @param useVideo Tells if video should be supported for the call + * @param customData Custom string associated with the call session. It can be later obtained from Call History using HTTP API + * @param extraHeaders Optional custom parameters (SIP headers) that should be passed with call (INVITE) message. Parameter names must start with "X-" to be processed by application. IMPORTANT: Headers size limit is 200 bytes + */ + call(number: string, useVideo?: boolean, customData?: string, extraHeaders?: Object): Call; + /** + * Get current config + */ + config(): Config; + /** + * Connect to VoxImplant Cloud + */ + connect(): void; + /** + * Check if connected to VoxImplant Cloud + */ + connected(): boolean; + /** + * Disable microphone/camera if micRequired in VoxImplant.Config was set to false (WebRTC mode only) + */ + detachRecordingDevice(): void; + /** + * Disconnect from VoxImplant Cloud + */ + disconnect(): void; + /** + * Initialize SDK. SDKReady event will be dispatched after succesful SDK initialization. SDK can't be used until it's initialized + * + * @param config Client configuration options + */ + init(config: Config): void; + /** + * Check if WebRTC support is available + */ + isRTCsupported(): boolean; + /** + * Login into application + * + * @param username + * @param password + * @param options Login options + */ + login(username: string, password: string, options?: LoginOptions): void; + /** + * Login into application using 'code' auth method + * + * @param username + * @param code + * @param options Login options + */ + loginWithCode(username: string, code: string, options?: LoginOptions): void; + /** + * Login into application using 'onetimekey' auth method + * + * @param username + * @param hash + * @param options Login options + */ + loginWithOneTimeKey(username: string, hash: string, options?: LoginOptions): void; + /** + * Move roster item group (IM) + * + * @param user_id User id + * @param groupSrc Group name (source) + * @param groupDst Group name (destination) + */ + moveRosterItemGroup(user_id: string, groupSrc: string, groupDst: string): void; + /** + * Play ToneScript using WebAudio API + * + * @param script Tonescript string + * @param loop Loop playback if true + */ + playToneScript(script: string, loop?: boolean): void; + /** + * Remove handler for specified event + * + * @param eventName Event name + * @param eventHandler Handler function + */ + removeEventListener(eventName: string, eventHandler: () => any): void; + /** + * Remove roster item (IM) + * + * @param user_id User id + */ + removeRosterItem(user_id: string): void; + /** + * Remove roster item group (IM) + * + * @param user_id User id + * @param group Group name + */ + remoteRosterItemGroup(user_id: string, group: string): void; + /** + * Rename roster item (IM) + * + * @param user_id User id + * @param name New display name + */ + renameRosterItem(user_id: string, name: string): void; + /** + * Request a key for 'onetimekey' auth method. Server will send the key in AuthResult event with code 302 + * + * @param username + */ + requestOneTimeLoginKey(username: string): void; + /** + * Send message to user (IM) + * + * @param user_id User id + * @param content Message content + */ + sendInstantMessage(user_id: string, content: string): string; + /** + * Start/stop sending local video to remote party/parties + * + * @param flag Start/stop - true/false + */ + sendVideo(flag: boolean): void; + /** + * Set active call + * + * @param call VoxImplant call instance + * @param active If true make call active, otherwise make call inactive + */ + setCallActive(call: Call, active: boolean): void; + /** + * Set chat session state info + * + * @param user_id User id + * @param status Chat session status. See VoxImplant.ChatStateType enum + */ + setChatState(user_id: string, status: ChatStateType): void; + /** + * Set local video position + * + * @param x Horizontal position (px) + * @param y Vertical position (px) + */ + setLocalVideoPosition(x: number, y: number): void; + /** + * Set local video size + * + * @param width Width in pixels + * @param height Height in pixels + */ + setLocalVideoSize(width: number, height: number): void; + /** + * Set local video size + * + * @param user_id User id + * @param type Message event type: VoxImplant.MessageEventType.Delivered or VoxImplant.MessageEventType.Displayed. See VoxImplant.MessageEventType enum + * @param message_id Message id(s) + */ + setMessageStatus(user_id: string, type: MessageEventType, message_id: string[]): void; + /** + * Set ACD status + * + * @param status Presence status string, see VoxImplant.OperatorACDStatuses + */ + setOperatorACDStatus(status: OperatorACDStatuses): void; + /** + * Set presence + * + * @param status Presence status from VoxImplant.UserStatuses + * @param msg Presence text message + */ + setPresenceStatus(status: UserStatuses, msg: string): void; + /** + * Set background color of flash app (only for Flash mode) + * + * @param color Color in web format (i.e. #000000 for black) + */ + setSwfColor(color: string): void; + /** + * Set bandwidth limit for video calls. Currently supported by Chrome/Chromium. The limit will be applied for the next call. (WebRTC mode only) + * + * @param bandwidth Bandwidth limit in kilobits per second (kbps) + */ + setVideoBandwidth(bandwidth: number): void; + /** + * Set video settings globally. This settings will be used for the next call. + * + * @param settings Video settings + * @param successCallback Success callback function + * @param failedCallback Failed callback function + */ + setVideoSettings(settings: VideoSettings | FlashVideoSettings, successCallback?: () => any, failedCallback?: () => any): void; + /** + * Show flash settings panel + * + * @param panel Settings type - default/microphone/camera/etc as described in SecurityPanel class + */ + showFlashSettingsPanel(panel?: string): void; + /** + * Show/hide local video + * + * @param flag Show/hide - true/false + */ + showLocalVideo(flag: boolean): void; + /** + * Stop playing ToneScript using WebAudio API + */ + stopPlayback(): void; + /** + * Transfer call, depending on the result VoxImplant.CallEvents.TransferComplete or VoxImplant.CallEvents.TransferFailed event will be dispatched + * + * @param call1 Call which will be transferred + * @param call2 Call where call1 will be transferred + */ + transferCall(call1: Call, call2: Call): void; + /** + * Use specified audio source , use audioSources to get the list of available audio sources + * + * @param id Id of the audio source + * @param successCallback Called in WebRTC mode if audio source changed successfully + * @param failedCallback Called in WebRTC mode if audio source couldn't be changed successfully + */ + useAudioSource(id: number | string, successCallback?: () => any, failedCallback?: () => any): void; + /** + * Use specified audio source , use audioSources to get the list of available audio sources + * + * @param id Id of the video source + * @param successCallback Called in WebRTC mode if video source changed successfully + * @param failedCallback Called in WebRTC mode if video source couldn't be changed successfully + */ + useVideoSource(id: number | string, successCallback?: () => any, failedCallback?: () => any): void; + /** + * Get a list of all currently available video sources / cameras + */ + videoSources(): VideoSourceInfo[]; + } + + interface Call { + /** + * Returns information about the call's media state (active/inactive) + */ + active(): boolean; + /** + * Register handler for specified event + * + * @param eventName Event name + * @param eventHandler Handler function. A single parameter is passed - object with the event information + */ + addEventListener(eventName: string, eventHandler: (eventObject: VoxImplantCallEvent) => any): void; + /** + * Answer on incoming call + * + * @param customData Set custom string associated with call session. It can be later obtained from Call History using HTTP API + * @param extraHeaders Optional custom parameters (SIP headers) that should be sent after accepting incoming call. Parameter names must start with "X-" to be processed by application + */ + answer(customData?: string, extraHeaders?: Object): void; + /** + * Reject incoming call + * + * @param extraHeaders Optional custom parameters (SIP headers) that should be sent after accepting incoming call. Parameter names must start with "X-" to be processed by application + */ + decline(extraHeaders?: Object): void; + /** + * Returns display name + */ + displayName(): string; + /** + * Returns HTML video element's id for the call (WebRTC mode) + */ + getVideoElementId(): string; + /** + * Hangup call + * + * @param extraHeaders Optional custom parameters (SIP headers) that should be sent after disconnecting/cancelling call. Parameter names must start with "X-" to be processed by application + */ + hangup(extraHeaders?: Object): void; + /** + * Returns headers object + */ + headers(): Object; + /** + * Returns call id + */ + id(): string; + /** + * Mute microphone + */ + muteMicrophone(): void; + /** + * Mute sound + */ + mutePlayback(): void; + /** + * Returns dialed number or caller id + */ + number(): string; + /** + * Reject incoming call + * + * @param extraHeaders Optional custom parameters (SIP headers) that should be sent after disconnecting/cancelling call. Parameter names must start with "X-" to be processed by application + */ + reject(extraHeaders?: Object): void; + /** + * Remove handler for specified event + * + * @param eventName Event name + * @param eventHandler Handler function + */ + removeEventListener(eventName: string, eventHandler: () => any): void; + /** + * Send Info (SIP INFO) message inside the call + * + * @param mimeType MIME type of the message + * @param body Message content + * @param extraHeaders Optional headers to be passed with the message + */ + sendInfo(mimeType: string, body: string, extraHeaders?: Object): void; + /** + * Send text message + * + * @param msg Message text + */ + sendMessage(msg: string): void; + /** + * Send tone (DTMF) + * + * @param key Send tone according to pressed key: 0-9 , * , # + */ + sendTone(key: string): void; + /** + * Set remote video position + * + * @param x Horizontal position (px) + * @param y Vertical position (px) + */ + setRemoteVideoPosition(x: number, y: number): void; + /** + * Set remote video size + * + * @param width Width in pixels + * @param height Height in pixels + */ + setRemoteVideoSize(width: number, height: number): void; + /** + * Set video settings + * + * @param settings Video settings for current call + * @param successCallback Called in WebRTC mode if video settings were applied successfully + * @param failedCallback Called in WebRTC mode if video settings couldn't be applied + */ + setVideoSettings(settings: VideoSettings | FlashVideoSettings, successCallback?: () => any, failedCallback?: () => any): void; + /** + * Show/hide remote party video + * + * @param flag Show/hide - true/false + */ + showRemoteVideo(flag: boolean): void; + /** + * Get call's current state + */ + state(): string; + /** + * Unmute microphone + */ + unmuteMicrophone(): void; + /** + * Unmute sound + */ + unmutePlayback(): void; + } + + /** + * WebRTC Video Settings (aka Constraints) + */ + interface VideoSettings { + /** + * Mandatory constraints object + */ + mandatory: Object; + /** + * Optional constraints object + */ + optional: Object; + } + + /** + * Flash Video Settings + */ + interface FlashVideoSettings { + /** + * The maximum amount of bandwidth the current outgoing video feed can use, in bytes + */ + bandwidth?: number; + /** + * The maximum rate at which the camera can capture data, in frames per second + */ + fps?: number; + /** + * Height in pixels (should be set together with width) + */ + height?: number; + /** + * Width in pixels (should be set together with height) + */ + width?: number; + /** + * Keyframe interval (seconds) + */ + keyframeInterval?: number; + /** + * H.264 video codec level + */ + level?: string; + /** + * H.264 video codec profile + */ + profile?: string; + /** + * The required level of picture quality, as determined by the amount of compression being applied to each video frame. Acceptable quality values range from 1 (lowest quality, maximum compression) to 100 (highest quality, no compression). The default value is 0, which means that picture quality can vary as needed to avoid exceeding available bandwidth + */ + quality?: number; + } + + /** + * Network information + */ + interface NetworkInfo { + /** + * Packet loss percentage + */ + packetLoss: number; + } + + /** + * VoxImplant roster item + */ + interface RosterItem { + /** + * Groups this roster item belongs to + */ + groups: string[], + /** + * User id + */ + id: string, + /** + * User display name + */ + name: string, + /** + * Resources + */ + resources: string[], + /** + * Subscription type + */ + subscription_type: number + } + + /** + * Get Client instance to use platform functions + */ + function getInstance(): Client; + /** + * VoxImplant Web SDK lib version + */ + function version(): String; + +} From 8dfd709683480bf87b3fa9ab92b0e2894cb70a3f Mon Sep 17 00:00:00 2001 From: abreits Date: Wed, 14 Oct 2015 14:33:16 +0200 Subject: [PATCH 037/357] amqplib: callback api definition and tests added --- amqplib/amqplib-tests.ts | 28 ++++++++ amqplib/amqplib.d.ts | 149 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+) diff --git a/amqplib/amqplib-tests.ts b/amqplib/amqplib-tests.ts index 7a1f51200..cfb9adbe1 100644 --- a/amqplib/amqplib-tests.ts +++ b/amqplib/amqplib-tests.ts @@ -1,5 +1,6 @@ /// +// promise api tests import amqp = require("amqplib"); var msg = "Hello World"; @@ -19,3 +20,30 @@ amqp.connect("amqp://localhost") .then(channel => channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString()))) .ensure(() => connection.close()); }); + +// callback api tests +import amqpcb = require("amqplib/callback_api"); + +amqpcb.connect("amqp://localhost", (err, connection) => { + if(!err) { + connection.createChannel((err, channel) => { + if (!err) { + channel.assertQueue("myQueue", (err, ok) => { + channel.sendToQueue("myQueue", new Buffer(msg)); + }); + } + }); + } +}); + +amqpcb.connect("amqp://localhost", (err, connection) => { + if(!err) { + connection.createChannel((err, channel) => { + if (!err) { + channel.assertQueue("myQueue", (err, ok) => { + channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())); + }); + } + }); + } +}); diff --git a/amqplib/amqplib.d.ts b/amqplib/amqplib.d.ts index 0c7f0720a..c6f73feef 100644 --- a/amqplib/amqplib.d.ts +++ b/amqplib/amqplib.d.ts @@ -1,6 +1,7 @@ // Type definitions for amqplib 0.3.x // Project: https://github.com/squaremo/amqp.node // Definitions by: Michael Nahkies +// Definitions for callback api added by: Ab Reitsma // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -142,3 +143,151 @@ declare module "amqplib" { function connect(url: string, socketOptions?: any): when.Promise; } + +declare module "amqplib/callback_api" { + + import events = require("events"); + + interface Connection extends events.EventEmitter { + close(callback?: (err: any) => void); + createChannel(callback: (err: any, channel: Channel) => void); + createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void); + } + + module Replies { + interface Empty { + } + interface AssertQueue { + queue: string; + messageCount: number; + consumerCount: number; + } + interface DeleteQueue { + messageCount: number; + } + interface PurgeQueue { + messageCount: number; + } + interface AssertExchange { + exchange: string; + } + interface Consume { + consumerTag: string; + } + } + + module Options { + interface AssertQueue { + exclusive?: boolean; + durable?: boolean; + autoDelete?: boolean; + arguments?: any; + messageTtl?: number; + expires?: number; + deadLetterExchange?: string; + maxLength?: number; + } + interface DeleteQueue { + ifUnused?: boolean; + ifEmpty?: boolean; + } + interface AssertExchange { + durable?: boolean; + internal?: boolean; + autoDelete?: boolean; + alternateExchange?: string; + arguments?: any; + } + interface DeleteExchange { + ifUnused?: boolean; + } + interface Publish { + expiration?: string; + userId?: string; + CC?: string | string[]; + + mandatory?: boolean; + persistent?: boolean; + deliveryMode?: boolean | number; + BCC?: string | string[]; + + contentType?: string; + contentEncoding?: string; + headers?: Object; + priority?: number; + correlationId?: string; + replyTo?: string; + messageId?: string; + timestamp?: number; + type?: string; + appId?: string; + } + interface Consume { + consumerTag?: string; + noLocal?: boolean; + noAck?: boolean; + exclusive?: boolean; + priority?: number; + arguments?: Object; + } + interface Get { + noAck?: boolean; + } + } + + interface Message { + content: Buffer; + fields: any; + properties: any; + } + + interface Channel extends events.EventEmitter { + close(callback: (err: any) => void); + + assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void); + checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void); + + deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void); + purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void); + + bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + + assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void); + checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void); + + deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void); + + bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + + publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean; + sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean; + + consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void); + + cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void); + get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void); + + ack(message: Message, allUpTo?: boolean): void; + ackAll(): void; + + nack(message: Message, allUpTo?: boolean, requeue?: boolean): void; + nackAll(requeue?: boolean): void; + reject(message: Message, requeue?: boolean): void; + + prefetch(count: number, global?: boolean); + recover(callback?: (err: any, ok: Replies.Empty) => void); + } + + interface ConfirmChannel extends Channel { + publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; + sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; + + waitForConfirms(callback?: (err: any) => void); + } + + function connect(callback: (err: any, connection: Connection) => void); + function connect(url: string, callback: (err: any, connection: Connection) => void); + function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void); +} From 93bcd768f07af500f68c26abfba8ed2827c81eac Mon Sep 17 00:00:00 2001 From: abreits Date: Wed, 14 Oct 2015 14:58:55 +0200 Subject: [PATCH 038/357] amqplib: callback-api added (second try) --- amqplib/amqplib-tests.ts | 8 +++++-- amqplib/amqplib.d.ts | 51 ++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/amqplib/amqplib-tests.ts b/amqplib/amqplib-tests.ts index cfb9adbe1..c22bc7ac9 100644 --- a/amqplib/amqplib-tests.ts +++ b/amqplib/amqplib-tests.ts @@ -29,7 +29,9 @@ amqpcb.connect("amqp://localhost", (err, connection) => { connection.createChannel((err, channel) => { if (!err) { channel.assertQueue("myQueue", (err, ok) => { - channel.sendToQueue("myQueue", new Buffer(msg)); + if(!err) { + channel.sendToQueue("myQueue", new Buffer(msg)); + } }); } }); @@ -41,7 +43,9 @@ amqpcb.connect("amqp://localhost", (err, connection) => { connection.createChannel((err, channel) => { if (!err) { channel.assertQueue("myQueue", (err, ok) => { - channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())); + if(!err) { + channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())); + } }); } }); diff --git a/amqplib/amqplib.d.ts b/amqplib/amqplib.d.ts index c6f73feef..a6e6e7a05 100644 --- a/amqplib/amqplib.d.ts +++ b/amqplib/amqplib.d.ts @@ -1,7 +1,6 @@ // Type definitions for amqplib 0.3.x // Project: https://github.com/squaremo/amqp.node -// Definitions by: Michael Nahkies -// Definitions for callback api added by: Ab Reitsma +// Definitions by: Michael Nahkies , Ab Reitsma // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -149,9 +148,9 @@ declare module "amqplib/callback_api" { import events = require("events"); interface Connection extends events.EventEmitter { - close(callback?: (err: any) => void); - createChannel(callback: (err: any, channel: Channel) => void); - createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void); + close(callback?: (err: any) => void): void; + createChannel(callback: (err: any, channel: Channel) => void): void; + createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void; } module Replies { @@ -242,32 +241,32 @@ declare module "amqplib/callback_api" { } interface Channel extends events.EventEmitter { - close(callback: (err: any) => void); + close(callback: (err: any) => void): void; - assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void); - checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void); + assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void): void; + checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void; - deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void); - purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void); + deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void): void; + purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void): void; - bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); - unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; + unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; - assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void); - checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void); + assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void): void; + checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void; - deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void); + deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void): void; - bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); - unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void); + bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; + unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void; publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean; sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean; - consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void); + consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void; - cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void); - get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void); + cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void; + get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void): void; ack(message: Message, allUpTo?: boolean): void; ackAll(): void; @@ -276,18 +275,18 @@ declare module "amqplib/callback_api" { nackAll(requeue?: boolean): void; reject(message: Message, requeue?: boolean): void; - prefetch(count: number, global?: boolean); - recover(callback?: (err: any, ok: Replies.Empty) => void); + prefetch(count: number, global?: boolean): void; + recover(callback?: (err: any, ok: Replies.Empty) => void): void; } interface ConfirmChannel extends Channel { publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean; - waitForConfirms(callback?: (err: any) => void); + waitForConfirms(callback?: (err: any) => void): void; } - function connect(callback: (err: any, connection: Connection) => void); - function connect(url: string, callback: (err: any, connection: Connection) => void); - function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void); + function connect(callback: (err: any, connection: Connection) => void): void; + function connect(url: string, callback: (err: any, connection: Connection) => void): void; + function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void): void; } From 9e7d9453a136e98970eeae042706680d0e974c67 Mon Sep 17 00:00:00 2001 From: abreits Date: Wed, 14 Oct 2015 15:09:10 +0200 Subject: [PATCH 039/357] amqplib: callback-api definition and tests added --- amqplib/amqplib-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amqplib/amqplib-tests.ts b/amqplib/amqplib-tests.ts index c22bc7ac9..f99a3bde1 100644 --- a/amqplib/amqplib-tests.ts +++ b/amqplib/amqplib-tests.ts @@ -28,7 +28,7 @@ amqpcb.connect("amqp://localhost", (err, connection) => { if(!err) { connection.createChannel((err, channel) => { if (!err) { - channel.assertQueue("myQueue", (err, ok) => { + channel.assertQueue("myQueue", {}, (err, ok) => { if(!err) { channel.sendToQueue("myQueue", new Buffer(msg)); } @@ -42,7 +42,7 @@ amqpcb.connect("amqp://localhost", (err, connection) => { if(!err) { connection.createChannel((err, channel) => { if (!err) { - channel.assertQueue("myQueue", (err, ok) => { + channel.assertQueue("myQueue", {}, (err, ok) => { if(!err) { channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())); } From cbd5556169709445e7b577e1888515f49eb5f47c Mon Sep 17 00:00:00 2001 From: James Alexander Date: Wed, 14 Oct 2015 10:49:05 -0400 Subject: [PATCH 040/357] Added additional IOptions properties Properties addSuffix, removeTags, and empty were all missing from the type definition for gulp-inject --- gulp-inject/gulp-inject.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gulp-inject/gulp-inject.d.ts b/gulp-inject/gulp-inject.d.ts index 42f5fb348..fb2668a1f 100644 --- a/gulp-inject/gulp-inject.d.ts +++ b/gulp-inject/gulp-inject.d.ts @@ -22,8 +22,11 @@ declare module "gulp-inject" { ignorePath?: string | string[]; relative?: boolean; addPrefix?: string; + addSuffix?: string; addRootSlash?: boolean; name?: string; + removeTags?: boolean; + empty?: boolean; starttag?: string | ITagFunction; endtag?: string | ITagFunction; transform?: ITransformFunction; From abd8bf27637b962f572cc5d6e622ed2f7ed21a6b Mon Sep 17 00:00:00 2001 From: Dominic Alie Date: Wed, 14 Oct 2015 11:05:27 -0400 Subject: [PATCH 041/357] Add tests --- leaflet-editable/leaflet-editable-tests.ts | 58 +++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/leaflet-editable/leaflet-editable-tests.ts b/leaflet-editable/leaflet-editable-tests.ts index ebb90cc97..fa904f671 100644 --- a/leaflet-editable/leaflet-editable-tests.ts +++ b/leaflet-editable/leaflet-editable-tests.ts @@ -1 +1,57 @@ -/// \ No newline at end of file +/// + +var map: L.Map = L.map('div', { + editable: true, + editOptions: { + drawingCSSClass: 'css-class', + editLayer: L.layerGroup(), + featuresLayer: L.layerGroup(), + lineGuideOptions: {}, + markerClass: MarkerClass, + markerEditorClass: MarkerEditorClass, + middleMarkerClass: MiddleMarkerClass, + polygonClass: PolygonClass, + polygonEditorClass: PolygonEditorClass, + polylineClass: PolylineClass, + polylineEditorClass: PolylineEditorClass, + skipMiddleMarkers: true, + vertexMarkerClass: VertexMarkerClass + } +}); + +var currentPoly: L.Polygon|L.Polyline| L.Marker = map.editTools.currentPolygon; +map.editTools.stopDrawing(); + +var marker: L.Marker = map.editTools.startMarker(L.latLng(0, 0), { draggable: true }); +marker.disable(); +marker.enable(); +marker.toggleEdit(); +var enabled: boolean = marker.editEnabled(); + +var polyline: L.Polyline = map.editTools.startPolyline(L.latLng(0, 0), { noClip: true }); +polyline.continueBackward(); +polyline.continueForward(); +polyline.disable(); +polyline.enable(); +enabled = polyline.editEnabled(); +polyline.reset(); +polyline.toggleEdit(); + +var polygon: L.Polygon = map.editTools.startPolygon(L.latLng(0, 0), { noClip: true }); +polygon.continueBackward(); +polygon.continueForward(); +polygon.disable(); +polygon.enable(); +enabled = polygon.editEnabled(); +polygon.newHole(L.latLng(0, 0)); +polygon.reset(); +polygon.toggleEdit(); + +class MarkerClass { } +class MarkerEditorClass { } +class MiddleMarkerClass { } +class PolygonClass { } +class PolygonEditorClass { } +class PolylineClass { } +class PolylineEditorClass { } +class VertexMarkerClass { } \ No newline at end of file From 710bfe47992af4f1a81d7c8b07082c72e750c1b0 Mon Sep 17 00:00:00 2001 From: soycode Date: Wed, 14 Oct 2015 14:20:25 -0700 Subject: [PATCH 042/357] update freedom.js pgp interface --- freedom/freedom.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/freedom/freedom.d.ts b/freedom/freedom.d.ts index f012c9dea..fa80a530c 100644 --- a/freedom/freedom.d.ts +++ b/freedom/freedom.d.ts @@ -406,6 +406,12 @@ declare module freedom.PgpProvider { interface PublicKey { key: string; fingerprint: string; + words: string[]; + } + + interface KeyFingerprint { + fingerprint: string; + words: string[]; } interface VerifyDecryptResult { @@ -418,6 +424,7 @@ declare module freedom.PgpProvider { setup(passphrase: string, userid: string): Promise; clear(): Promise; exportKey(): Promise; + getFingerprint(publicKey: string): Promise; signEncrypt(data: ArrayBuffer, encryptKey?: string, sign?: boolean): Promise; verifyDecrypt(data: ArrayBuffer, From c04af9e6ad6aafd0dc041fb0125a1fb8d714ad4d Mon Sep 17 00:00:00 2001 From: Phips Peter Date: Mon, 28 Sep 2015 21:42:20 -0700 Subject: [PATCH 043/357] Add benchmark.js This adds the benchmark tests. --- benchmark/benchmark-tests.ts | 237 +++++++++++++++++++++++++++++++++++ benchmark/benchmark.d.ts | 192 ++++++++++++++++++++++++++++ 2 files changed, 429 insertions(+) create mode 100644 benchmark/benchmark-tests.ts create mode 100644 benchmark/benchmark.d.ts diff --git a/benchmark/benchmark-tests.ts b/benchmark/benchmark-tests.ts new file mode 100644 index 000000000..363e522b0 --- /dev/null +++ b/benchmark/benchmark-tests.ts @@ -0,0 +1,237 @@ +/// +import Benchmark = require("benchmark"); + +var suite = new Benchmark.Suite; + +// add tests +suite.add('RegExp#test', function() { + /o/.test('Hello World!'); +}) +.add('String#indexOf', function() { + 'Hello World!'.indexOf('o') > -1; +}) +.add('String#match', function() { + !!'Hello World!'.match(/o/); +}) +// add listeners +.on('cycle', function(event: {target: any}) { + console.log(String(event.target)); +}) +.on('complete', function() { + console.log('Fastest is ' + this.filter('fastest').pluck('name')); +}) +// run async +.run({ 'async': true }); + +var fn: Function; +var onStart: Function; +var onCycle: Function; +var onAbort: Function; +var onError: Function; +var onReset: Function; +var onComplete: Function; +var setup: Function; +var teardown: Function; +var benches: Benchmark[]; +var listener: Function; +var count: number; + +// basic usage (the `new` operator is optional) +var bench = new Benchmark(fn); + +// or using a name first +var bench = new Benchmark('foo', fn); + +// or with options +var bench = new Benchmark('foo', fn, { + + // displayed by Benchmark#toString if `name` is not available + 'id': 'xyz', + + // called when the benchmark starts running + 'onStart': onStart, + + // called after each run cycle + 'onCycle': onCycle, + + // called when aborted + 'onAbort': onAbort, + + // called when a test errors + 'onError': onError, + + // called when reset + 'onReset': onReset, + + // called when the benchmark completes running + 'onComplete': onComplete, + + // compiled/called before the test loop + 'setup': setup, + + // compiled/called after the test loop + 'teardown': teardown +}); + +// or name and options +var bench = new Benchmark('foo', { + + // a flag to indicate the benchmark is deferred + 'defer': true, + + // benchmark test function + 'fn': function(deferred: {resolve(): void}) { + // call resolve() when the deferred test is finished + deferred.resolve(); + } +}); + +// or options only +var bench = new Benchmark({ + + // benchmark name + 'name': 'foo', + + // benchmark test as a string + 'fn': '[1,2,3,4].sort()' +}); + +// a test’s `this` binding is set to the benchmark instance +var bench = new Benchmark('foo', function() { + 'My name is '.concat(this.name); // My name is foo +}); + +// get odd numbers +Benchmark.filter([1, 2, 3, 4, 5], function(n) { + return n % 2; +}); // -> [1, 3, 5]; + +// get fastest benchmarks +Benchmark.filter(benches, 'fastest'); + +// get slowest benchmarks +Benchmark.filter(benches, 'slowest'); + +// get benchmarks that completed without erroring +Benchmark.filter(benches, 'successful'); + +// invoke `reset` on all benchmarks +Benchmark.invoke(benches, 'reset'); + +// invoke `emit` with arguments +Benchmark.invoke(benches, 'emit', 'complete', listener); + +// invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks +Benchmark.invoke(benches, { + + // invoke the `run` method + 'name': 'run', + + // pass a single argument + 'args': true, + + // treat as queue, removing benchmarks from front of `benches` until empty + 'queued': true, + + // called before any benchmarks have been invoked. + 'onStart': onStart, + + // called between invoking benchmarks + 'onCycle': onCycle, + + // called after all benchmarks have been invoked. + 'onComplete': onComplete +}); + +var element: HTMLElement; +// basic usage +var bench = new Benchmark({ + 'setup': function() { + var c = this.count, + element = document.getElementById('container'); + while (c--) { + element.appendChild(document.createElement('div')); + } + }, + 'fn': function() { + element.removeChild(element.lastChild); + } +}); + +// or using strings +var bench = new Benchmark({ + 'setup': '\ + var a = 0;\n\ + (function() {\n\ + (function() {\n\ + (function() {', + 'fn': 'a += 1;', + 'teardown': '\ + }())\n\ + }())\n\ + }())' +}); + +var bizarro = bench.clone({ + 'name': 'doppelganger' +}); + +// unregister a listener for an event type +bench.off('cycle', listener); + +// unregister a listener for multiple event types +bench.off('start cycle', listener); + +// unregister all listeners for an event type +bench.off('cycle'); + +// unregister all listeners for multiple event types +bench.off('start cycle complete'); + +// unregister all listeners for all event types +bench.off(); + +// register a listener for an event type +bench.on('cycle', listener); + +// register a listener for multiple event types +bench.on('start cycle', listener); + +// basic usage +bench.run(); + +// or with options +bench.run({ 'async': true }); + +// basic usage +suite.add(fn); + +// or using a name first +suite.add('foo', fn); + +// or with options +suite.add('foo', fn, { + 'onCycle': onCycle, + 'onComplete': onComplete +}); + +// or name and options +suite.add('foo', { + 'fn': fn, + 'onCycle': onCycle, + 'onComplete': onComplete +}); + +// or options only +suite.add({ + 'name': 'foo', + 'fn': fn, + 'onCycle': onCycle, + 'onComplete': onComplete +}); + +// basic usage +suite.run(); + +// or with options +suite.run({ 'async': true, 'queued': true }); diff --git a/benchmark/benchmark.d.ts b/benchmark/benchmark.d.ts new file mode 100644 index 000000000..3365f335c --- /dev/null +++ b/benchmark/benchmark.d.ts @@ -0,0 +1,192 @@ +// Type definitions for Benchmark v1.0.0 +// Project: http://benchmarkjs.com +// Definitions by: Asana +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "benchmark" { + class Benchmark { + static deepClone(value: T): T; + static each(obj: Object | any[], callback: Function, thisArg?: any): void; + static extend(destination: Object, ...sources: Object[]): Object; + static filter(arr: T[], callback: (value: T) => any, thisArg?: any): T[]; + static filter(arr: T[], filter: string, thisArg?: any): T[]; + static forEach(arr: T[], callback: (value: T) => any, thisArg?: any): void; + static formatNumber(num: number): string; + static forOwn(obj: Object, callback: Function, thisArg?: any): void; + static hasKey(obj: Object, key: string): boolean; + static indexOf(arr: T[], value: T, fromIndex?: number): number; + static interpolate(template: string, values: Object): string; + static invoke(benches: Benchmark[], name: string | Object, ...args: any[]): any[]; + static join(obj: Object, separator1?: string, separator2?: string): string; + static map(arr: T[], callback: (value: T) => K, thisArg?: any): K[]; + static pluck(arr: T[], key: string): K[]; + static reduce(arr: T[], callback: (accumulator: K, value: T) => K, thisArg?: any): K; + + static options: Benchmark.Options; + static platform: Benchmark.Platform; + static support: Benchmark.Support; + static version: string; + + constructor(fn: Function | string, options?: Benchmark.Options); + constructor(name: string, fn: Function | string, options?: Benchmark.Options); + constructor(name: string, options?: Benchmark.Options); + constructor(options: Benchmark.Options); + + aborted: boolean; + compiled: Function | string; + count: number; + cycles: number; + error: Error; + fn: Function | string; + hz: number; + running: boolean; + setup: Function | string; + teardown: Function | string; + + stats: Benchmark.Stats; + times: Benchmark.Times; + + abort(): Benchmark; + clone(options: Benchmark.Options): Benchmark; + compare(benchmark: Benchmark): number; + emit(type: string | Object): any; + listeners(type: string): Function[]; + off(type?: string, listener?: Function): Benchmark; + off(types: string[]): Benchmark; + on(type?: string, listener?: Function): Benchmark; + on(types: string[]): Benchmark; + reset(): Benchmark; + run(options?: Benchmark.Options): Benchmark; + toString(): string; + } + + module Benchmark { + export interface Options { + async?: boolean; + defer?: boolean; + delay?: number; + id?: string; + initCount?: number; + maxTime?: number; + minSamples?: number; + minTime?: number; + name?: string; + onAbort?: Function; + onComplete?: Function; + onCycle?: Function; + onError?: Function; + onReset?: Function; + onStart?: Function; + setup?: Function | string; + teardown?: Function | string; + fn?: Function | string; + queued?: boolean; + } + + export interface Platform { + description: string; + layout: string; + manufacturer: string; + name: string; + os: string; + prerelease: string; + product: string; + version: string; + toString(): string; + } + + export interface Support { + air: boolean; + argumentsClass: boolean; + browser: boolean; + charByIndex: boolean; + charByOwnIndex: boolean; + decompilation: boolean; + descriptors: boolean; + getAllKeys: boolean; + iteratesOwnFirst: boolean; + java: boolean; + nodeClass: boolean; + timeout: boolean; + } + + export interface Stats { + deviation: number; + mean: number; + moe: number; + rme: number; + sample: any[]; + sem: number; + variance: number; + } + + export interface Times { + cycle: number; + elapsed: number; + period: number; + timeStamp: number; + } + + export class Deferred { + constructor(clone: Benchmark); + + benchmark: Benchmark; + cycles: number; + elapsed: number; + timeStamp: number; + } + + export class Event { + constructor(type: string | Object); + + aborted: boolean; + cancelled: boolean; + currentTarget: Object; + result: any; + target: Object; + timeStamp: number; + type: string; + } + + export class Suite { + static options: { name: string }; + + constructor(name?: string, options?: Options); + + aborted: boolean; + length: number; + running: boolean; + abort(): Suite; + add(name: string, fn: Function | string, options?: Options): Suite; + add(fn: Function | string, options?: Options): Suite; + add(name: string, options?: Options): Suite; + add(options: Options): Suite; + clone(options: Options): Suite; + emit(type: string | Object): any; + filter(callback: Function | string): Suite; + forEach(callback: Function): Suite; + indexOf(value: any): number; + invoke(name: string, ...args: any[]): any[]; + join(separator?: string): string; + listeners(type: string): Function[]; + map(callback: Function): any[]; + off(type?: string, callback?: Function): Benchmark; + off(types: string[]): Benchmark; + on(type?: string, callback?: Function): Benchmark; + on(types: string[]): Benchmark; + pluck(property: string): any[]; + pop(): Function; + push(benchmark: Benchmark): number; + reduce(callback: Function, accumulator: T): T; + reset(): Suite; + reverse(): any[]; + run(options?: Options): Suite; + shift(): Benchmark; + slice(start: number, end: number): any[]; + slice(start: number, deleteCount: number, ...values: any[]): any[]; + unshift(benchmark: Benchmark): number; + } + } + + export = Benchmark; +} From aa15031dcc8596d08543bbd7648496472bd54c11 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 15 Oct 2015 05:33:36 +0500 Subject: [PATCH 044/357] lodash: signatures of the method _.toArray have been changed --- lodash/lodash-tests.ts | 47 ++++++++++++++++++++--- lodash/lodash.d.ts | 86 +++++++++++++++++++++++++----------------- 2 files changed, 93 insertions(+), 40 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index adf86e9a6..b0dffe01e 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1850,12 +1850,6 @@ result = _([1, 2, 3]).sortBy(function (num) { return this.sin(num); }, result = _(['banana', 'strawberry', 'apple']).sortBy('length').value(); result = _(foodsOrganic).sortByAll('organic', (food) => food.name, { organic: true }).value(); -(function (a: number, b: number, c: number, d: number): Array { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); -result = _.toArray([1, 2, 3, 4]); -(function (a: number, b: number, c: number, d: number): Array { return _(arguments).toArray().slice(1).value(); })(1, 2, 3, 4); -result = _([1,2,3,4]).toArray().value(); - - result = _.where(stoogesCombined, { 'age': 40 }); result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); @@ -2418,6 +2412,47 @@ result = _(1).lte(2); result = _([]).lte(2); result = _({}).lte(2); +// _.toArray +module TestToArray { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; + + { + let result: string[]; + + result = _.toArray(''); + + result = (function (a: string) {return _.toArray(arguments);})(''); + + result = _((function (a: string) {return arguments;})('')).toArray().value(); + } + + { + let result: TResult[]; + + result = _.toArray(array); + result = _.toArray(list); + result = _.toArray(dictionary); + + result = _(array).toArray().value(); + result = _(list).toArray().value(); + result = _(dictionary).toArray().value(); + } + + { + let result: any[]; + + result = _.toArray(); + result = _.toArray(42); + result = _.toArray(true); + + result = _('').toArray().value(); + result = _(42).toArray().value(); + result = _(true).toArray().value(); + } +} + // _.toPlainObject module TestToPlainObject { let result: TResult; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d5463ffc0..c77ff2f17 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5649,40 +5649,6 @@ declare module _ { orders?: string[]): LoDashArrayWrapper; } - //_.toArray - interface LoDashStatic { - /** - * Converts the collection to an array. - * @param collection The collection to convert. - * @return The new converted array. - **/ - toArray(collection: Array): T[]; - - /** - * @see _.toArray - **/ - toArray(collection: List): T[]; - - /** - * @see _.toArray - **/ - toArray(collection: Dictionary): T[]; - } - - interface LoDashArrayWrapper { - /** - * @see _.toArray - **/ - toArray(): LoDashArrayWrapper; - } - - interface LoDashObjectWrapper { - /** - * @see _.toArray - **/ - toArray(): LoDashArrayWrapper; - } - //_.where interface LoDashStatic { /** @@ -7068,6 +7034,58 @@ declare module _ { lte(other: any): boolean; } + //_.toArray + interface LoDashStatic { + /** + * Converts value to an array. + * + * @param value The value to convert. + * @return Returns the converted array. + */ + toArray(value: string): string[]; + + /** + * @see _.toArray + */ + toArray(value: List|Dictionary): T[]; + + /** + * @see _.toArray + */ + toArray(value: TValue): TResult[]; + + /** + * @see _.toArray + */ + toArray(value: TValue): any[]; + + /** + * @see _.toArray + */ + toArray(value?: any): any[]; + } + + interface LoDashWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashArrayWrapper; + } + + interface LoDashArrayWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashArrayWrapper; + } + //_.toPlainObject interface LoDashStatic { /** From e43b2a00c08db45e1ac52d806f7e7f402bda6627 Mon Sep 17 00:00:00 2001 From: Giovanni Bassi Date: Wed, 14 Oct 2015 21:42:05 -0300 Subject: [PATCH 045/357] Add docopt See more about docopt at http://docopt.org/ This is specific for the library at https://www.npmjs.com/package/docopt --- docopt/docopt-tests.ts | 11 +++++++++++ docopt/docopt.d.ts | 23 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 docopt/docopt-tests.ts create mode 100644 docopt/docopt.d.ts diff --git a/docopt/docopt-tests.ts b/docopt/docopt-tests.ts new file mode 100644 index 000000000..b8c1a2c25 --- /dev/null +++ b/docopt/docopt-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +var doc = ` +Usage: + quick_example.coffee tcp [--timeout=] + quick_example.coffee serial [--baud=9600] [--timeout=] + quick_example.coffee -h | --help | --version +`; +var {docopt} = require('docopt'); +console.log(docopt(doc, { version: '0.1.1rc' })); diff --git a/docopt/docopt.d.ts b/docopt/docopt.d.ts new file mode 100644 index 000000000..ea2330a19 --- /dev/null +++ b/docopt/docopt.d.ts @@ -0,0 +1,23 @@ +// Type definitions for Docopt v0.6.2 +// Project: http://docopt.org/ +// Definitions by: Giovanni Bassi +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface DocoptOption { + /** is an optional argument vector. It defaults to the arguments passed to your program (process.argv[2..]). You can also supply it with an array of strings, as with process.argv. For example: ['--verbose', '-o', 'hai.txt'] */ + argv?: Array, + /** (default:true) specifies whether the parser should automatically print the help message (supplied as doc) in case -h or --help options are encountered. After showing the usage-message, the program will terminate. If you want to handle -h or --help options manually (the same as other options), set help=false. */ + help?: boolean, + /** (default:null) is an optional argument that specifies the version of your program. If supplied, then, if the parser encounters --version option, it will print the supplied version and terminate. version could be any printable object, but most likely a string, e.g. '2.1.0rc1'. */ + version?: any, + /** (default false) If set to true will disallow mixing options and positional argument. I.e. after first positional argument, all arguments will be interpreted as positional even if the look like options. This can be used for strict compatibility with POSIX, or if you want to dispatch your arguments to other programs. */ + options_first?: boolean, + /** (default true) If set to false will cause docopt to throw exceptions instead of printing the error to console and terminating the application. This flag is mainly for testing purposes. */ + exit?: boolean +} +declare module "docopt" { + /** + * @param doc should be a string with the help message, written according to rules of the docopt language. + */ + export function docopt(doc: string, options: DocoptOption): any; +} From 161890155f7c9b7e036be50d1ab7869971aaa716 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Thu, 15 Oct 2015 12:34:37 +0200 Subject: [PATCH 046/357] fixed typings issue as reported in #6225 --- mobservable-react/mobservable-react.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobservable-react/mobservable-react.d.ts b/mobservable-react/mobservable-react.d.ts index f42627a85..e95fc69f5 100644 --- a/mobservable-react/mobservable-react.d.ts +++ b/mobservable-react/mobservable-react.d.ts @@ -10,7 +10,7 @@ declare module "mobservable-react" { * Turns a React component or stateless render function into a reactive component. */ export function reactiveComponent

(clazz: React.ClassicComponentClass

): React.ClassicComponentClass

; + export function reactiveComponent>(target: TFunction): void; // decorator signature export function reactiveComponent

(clazz: React.ComponentClass

): React.ComponentClass

; - export function reactiveComponent>(target: TFunction): TFunction | void; // decorator signature export function reactiveComponent

(renderFunction: (props: P) => React.ReactElement): React.ClassicComponentClass

; } \ No newline at end of file From 8f7a76d23067e6bdf6e177ace30f9972ea55a88b Mon Sep 17 00:00:00 2001 From: bgrieder Date: Thu, 15 Oct 2015 15:36:21 +0200 Subject: [PATCH 047/357] Definitions for react-intl 1.2.0 --- react-intl/react-intl-tests.tsx | 137 ++++++++++++++++++++++++++++++++ react-intl/react-intl.d.ts | 97 ++++++++++++++++++++++ 2 files changed, 234 insertions(+) create mode 100644 react-intl/react-intl-tests.tsx create mode 100644 react-intl/react-intl.d.ts diff --git a/react-intl/react-intl-tests.tsx b/react-intl/react-intl-tests.tsx new file mode 100644 index 000000000..648142a25 --- /dev/null +++ b/react-intl/react-intl-tests.tsx @@ -0,0 +1,137 @@ +/** + * Created by Bruno Grieder + */ +import * as React from 'react' + +import * as reactMixin from 'react-mixin' +import {IntlMixin, IntlComponent, FormattedNumber, FormattedMessage, FormattedDate} from 'react-intl' + + +/////////////////////////////////////////////////////////////////////////// +// +// This class does not use the mixin and react-mixin is not required +// The MESSQGES are maintained in the file +// To use it call +// +//////////////////////////////////////////////////////////////////////////// + + +const MESSAGES = { + + Sorry: { + 'en-US': 'Sorry {name}', + 'fr-FR': 'Désolé {name}' + } +} + + +module I18nDirect { + + export interface Props extends IntlComponent.Props {} +} + +@reactMixin.decorate( IntlMixin ) +class I18nDirect extends React.Component { //implements IntlComponent { + + private _currentLocale: string + private _messages: {[key: string]: string} + + constructor( props: I18nDirect.Props ) { + super( props ) + } + + //Mixin + //getIntlMessage: (key: string) => string = this['getIntlMessage'] + + + render() { + + return ( + +

    +
  • FormattedNumber:  + +
  • +
  • FormattedMessage:  + +
  • +
  • FormattedDate:  + +
  • +
+ + ) + } + + componentWillReceiveProps( nextProps: I18nDirect.Props ) { + this.compileMessages(nextProps) + } + + componentWillMount() { + this.compileMessages(this.props) + } + + + private compileMessages = (props: I18nDirect.Props): void => { + + let locale = ( props.locales && props.locales[ 0 ] ) || 'en-US' + + if (this._currentLocale !== locale) { + + this._messages = Object.keys( MESSAGES ).reduce( + ( dic, key ) => { + dic[ key ] = MESSAGES[ key ][ locale ] + return dic + }, + {} as { [key: string]: string; } + ) + } + } + +} + +/////////////////////////////////////////////////////////////////////////// +// +// This class uses the mixin and react-mixin is +// The MESSAGES are passed from messages property of the props +// To use it call +// +//////////////////////////////////////////////////////////////////////////// + + +module I18nMixin { + + export interface Props extends IntlComponent.Props {} +} + +@reactMixin.decorate( IntlMixin ) +class I18nMixin extends React.Component implements IntlComponent { + + private _currentLocale: string + + constructor( props: I18nMixin.Props ) { + super( props ) + } + + //Expose the method provided by the Mixin + getIntlMessage: (key: string) => string = this['getIntlMessage'] + + + render() { + + return ( + +
    +
  • FormattedNumber: + +
  • +
  • FormattedMessage: + {/* this uses the mixin */} +
  • +
+ + ) + } +} + +export { I18nDirect, I18nMixin } diff --git a/react-intl/react-intl.d.ts b/react-intl/react-intl.d.ts new file mode 100644 index 000000000..d1ee2772b --- /dev/null +++ b/react-intl/react-intl.d.ts @@ -0,0 +1,97 @@ +// Type definitions for react-intl 1.2.0 +// Project: http://formatjs.io/react/ +// Definitions by: Bruno Grieder +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "react-intl" { + + import * as React from 'react' + + module ReactIntl { + + + interface IIntlMixin extends React.Mixin { + getIntlMessage(key: string): string + } + + var IntlMixin: IIntlMixin + + module IntlComponent { + interface Props { + locales?: string[] + messages?: {[key: string]: any} + formats?: string[] + } + } + interface IntlComponent { + getIntlMessage(key: string): string; + } + + + module FormattedDate { + export interface Props extends IntlComponent.Props { + value: Date + day?: string + month?: string + year?: string + } + } + class FormattedDate extends React.Component {} + + + module FormattedTime { + export interface Props extends IntlComponent.Props { + value: Date + day?: string + month?: string + year?: string + format?: string + } + } + class FormattedTime extends React.Component {} + + + module FormattedRelative { + export interface Props extends IntlComponent.Props { + value: number + units?: string //"second", "minute", "hour", "day", "month" or "year" + style?: string //"best fit" (default) or "numeric" + format?: string + } + } + class FormattedRelative extends React.Component {} + + + module FormattedMessage { + export interface Props extends IntlComponent.Props { + message: string; + [prop: string]: any + } + } + class FormattedMessage extends React.Component {} + + + module FormattedHTMLMessage { + export interface Props extends IntlComponent.Props { + message: string; + [prop: string]: any + } + } + class FormattedHTMLMessage extends React.Component {} + + + module FormattedNumber { + export interface Props extends IntlComponent.Props { + value: number + style?: string + currency?: string + format?: string + } + } + class FormattedNumber extends React.Component {} + + } + + export = ReactIntl + +} \ No newline at end of file From 977932ec0fe59cde82112441fc7afbf83a6908c5 Mon Sep 17 00:00:00 2001 From: bgrieder Date: Thu, 15 Oct 2015 16:00:09 +0200 Subject: [PATCH 048/357] clean-up of test file --- react-intl/react-intl-tests.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/react-intl/react-intl-tests.tsx b/react-intl/react-intl-tests.tsx index 648142a25..1a5aba9b3 100644 --- a/react-intl/react-intl-tests.tsx +++ b/react-intl/react-intl-tests.tsx @@ -30,8 +30,7 @@ module I18nDirect { export interface Props extends IntlComponent.Props {} } -@reactMixin.decorate( IntlMixin ) -class I18nDirect extends React.Component { //implements IntlComponent { +class I18nDirect extends React.Component { private _currentLocale: string private _messages: {[key: string]: string} @@ -40,9 +39,6 @@ class I18nDirect extends React.Component { //implements I super( props ) } - //Mixin - //getIntlMessage: (key: string) => string = this['getIntlMessage'] - render() { From b5956f2bef11b743b05366023f619039f2ba3c1a Mon Sep 17 00:00:00 2001 From: tkqubo Date: Thu, 15 Oct 2015 23:54:55 +0900 Subject: [PATCH 049/357] Revert "Merge webpack-env.* into webpack.*" This reverts commit b123aa5469db5e5a56f8517eca31c1cdaf569ed4. --- webpack/webpack-env-tests.ts | 15 +++++ webpack/webpack-env.d.ts | 103 +++++++++++++++++++++++++++++++++++ webpack/webpack-tests.ts | 19 ------- webpack/webpack.d.ts | 98 --------------------------------- 4 files changed, 118 insertions(+), 117 deletions(-) create mode 100644 webpack/webpack-env-tests.ts create mode 100644 webpack/webpack-env.d.ts diff --git a/webpack/webpack-env-tests.ts b/webpack/webpack-env-tests.ts new file mode 100644 index 000000000..b4a9693ec --- /dev/null +++ b/webpack/webpack-env-tests.ts @@ -0,0 +1,15 @@ +/// + +interface SomeModule { + someMethod(): void; +} + +let someModule = require('./someModule'); +someModule.someMethod(); + +let context = require.context('./somePath', true); +let contextModule = context('./someModule'); + +require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => { + +}); diff --git a/webpack/webpack-env.d.ts b/webpack/webpack-env.d.ts new file mode 100644 index 000000000..01ea6e404 --- /dev/null +++ b/webpack/webpack-env.d.ts @@ -0,0 +1,103 @@ +// Type definitions for webpack 1.12.2 (module API) +// Project: https://github.com/webpack/webpack +// Definitions by: use-strict +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * Webpack module API - variables and global functions available inside modules + */ + +declare namespace __WebpackModuleApi { + interface RequireContext { + keys(): string[]; + (id: string): T; + resolve(id: string): string; + } + + interface RequireFunction { + /** + * Returns the exports from a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available. + */ + (path: string): T; + /** + * Behaves similar to require.ensure, but the callback is called with the exports of each dependency in the paths array. There is no option to provide a chunk name. + */ + (paths: string[], callback: (...modules: any[]) => void): void; + /** + * Download additional dependencies on demand. The paths array lists modules that should be available. When they are, callback is called. If the callback is a function expression, dependencies in that source part are extracted and also loaded on demand. A single request is fired to the server, except if all modules are already available. + * + * This creates a chunk. The chunk can be named. If a chunk with this name already exists, the dependencies are merged into that chunk and that chunk is used. + */ + ensure: (paths: string[], callback: (require: (path: string) => T) => void) => void; + context: (path: string, deep?: boolean, filter?: RegExp) => RequireContext; + /** + * Returns the module id of a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available. + * + * The module id is a number in webpack (in contrast to node.js where it is a string, the filename). + */ + resolve(path: string): number; + /** + * Like require.resolve, but doesn’t include the module into the bundle. It’s a weak dependency. + */ + resolveWeak(path: string): number; + /** + * Ensures that the dependency is available, but don’t execute it. This can be use for optimizing the position of a module in the chunks. + */ + include(path: string): void; + /** + * Multiple requires to the same module result in only one module execution and only one export. Therefore a cache in the runtime exists. Removing values from this cache cause new module execution and a new export. This is only needed in rare cases (for compatibility!). + */ + cache: { + [id: string]: any; + } + } +} + +declare var require: __WebpackModuleApi.RequireFunction; + +/** + * The resource query of the current module. + * + * e.g. __resourceQuery === "?test" // Inside "file.js?test" + */ +declare var __resourceQuery: string; + +/** + * Equals the config options output.publicPath. + */ +declare var __webpack_public_path__: string; + +/** + * The raw require function. This expression isn’t parsed by the Parser for dependencies. + */ +declare var __webpack_require__: any; + +/** + * The internal chunk loading function + * + * @param chunkId The id for the chunk to load. + * @param callback A callback function called once the chunk is loaded. + */ +declare var __webpack_chunk_load__: (chunkId: any, callback: (require: (id: string) => any) => void) => void; + +/** + * Access to the internal object of all modules. + */ +declare var __webpack_modules__: any[]; + +/** + * Access to the hash of the compilation. + * + * Only available with the HotModuleReplacementPlugin or the ExtendedAPIPlugin + */ +declare var __webpack_hash__: any; + +/** + * Generates a require function that is not parsed by webpack. Can be used to do cool stuff with a global require function if available. + */ +declare var __non_webpack_require__: any; + +/** + * Equals the config option debug + */ +declare var DEBUG: boolean; \ No newline at end of file diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 5a70c2e10..27a4a5385 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -386,22 +386,3 @@ plugin = new webpack.ExtendedAPIPlugin(); plugin = new webpack.NoErrorsPlugin(); plugin = new webpack.WatchIgnorePlugin(paths); -// -// http://webpack.github.io/docs/api-in-modules.html -// - -interface SomeModule { - someMethod(): void; -} - -let someModule: SomeModule = require('./someModule'); -someModule.someMethod(); - -let context2 = require.context('./somePath', true); -let contextModule: SomeModule = context2('./someModule'); - -require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => { - -}); - - diff --git a/webpack/webpack.d.ts b/webpack/webpack.d.ts index 82cf56458..f2049bbc9 100644 --- a/webpack/webpack.d.ts +++ b/webpack/webpack.d.ts @@ -259,101 +259,3 @@ declare module "webpack" { export = webpack; } -/** - * Webpack module API - variables and global functions available inside modules - */ - -declare namespace __WebpackModuleApi { - interface RequireContext { - keys(): string[]; - (id: string): T; - resolve(id: string): string; - } - - interface RequireFunction { - /** - * Returns the exports from a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available. - */ - (path: string): T; - /** - * Behaves similar to require.ensure, but the callback is called with the exports of each dependency in the paths array. There is no option to provide a chunk name. - */ - (paths: string[], callback: (...modules: any[]) => void): void; - /** - * Download additional dependencies on demand. The paths array lists modules that should be available. When they are, callback is called. If the callback is a function expression, dependencies in that source part are extracted and also loaded on demand. A single request is fired to the server, except if all modules are already available. - * - * This creates a chunk. The chunk can be named. If a chunk with this name already exists, the dependencies are merged into that chunk and that chunk is used. - */ - ensure: (paths: string[], callback: (require: (path: string) => T) => void) => void; - context: (path: string, deep?: boolean, filter?: RegExp) => RequireContext; - /** - * Returns the module id of a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available. - * - * The module id is a number in webpack (in contrast to node.js where it is a string, the filename). - */ - resolve(path: string): number; - /** - * Like require.resolve, but doesn’t include the module into the bundle. It’s a weak dependency. - */ - resolveWeak(path: string): number; - /** - * Ensures that the dependency is available, but don’t execute it. This can be use for optimizing the position of a module in the chunks. - */ - include(path: string): void; - /** - * Multiple requires to the same module result in only one module execution and only one export. Therefore a cache in the runtime exists. Removing values from this cache cause new module execution and a new export. This is only needed in rare cases (for compatibility!). - */ - cache: { - [id: string]: any; - } - } -} - -declare var require: __WebpackModuleApi.RequireFunction; - -/** - * The resource query of the current module. - * - * e.g. __resourceQuery === "?test" // Inside "file.js?test" - */ -declare var __resourceQuery: string; - -/** - * Equals the config options output.publicPath. - */ -declare var __webpack_public_path__: string; - -/** - * The raw require function. This expression isn’t parsed by the Parser for dependencies. - */ -declare var __webpack_require__: any; - -/** - * The internal chunk loading function - * - * @param chunkId The id for the chunk to load. - * @param callback A callback function called once the chunk is loaded. - */ -declare var __webpack_chunk_load__: (chunkId: any, callback: (require: (id: string) => any) => void) => void; - -/** - * Access to the internal object of all modules. - */ -declare var __webpack_modules__: any[]; - -/** - * Access to the hash of the compilation. - * - * Only available with the HotModuleReplacementPlugin or the ExtendedAPIPlugin - */ -declare var __webpack_hash__: any; - -/** - * Generates a require function that is not parsed by webpack. Can be used to do cool stuff with a global require function if available. - */ -declare var __non_webpack_require__: any; - -/** - * Equals the config option debug - */ -declare var DEBUG: boolean; From cf0a8f5d7054f667eb8549edd50ca7f1d18b8ca3 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Thu, 15 Oct 2015 16:58:53 +0200 Subject: [PATCH 050/357] Update FileSaver: add the parameter: "disableAutoBOM". --- FileSaver/FileSaver-tests.ts | 5 +++-- FileSaver/FileSaver.d.ts | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/FileSaver/FileSaver-tests.ts b/FileSaver/FileSaver-tests.ts index 6a5426a6a..4cfae373e 100644 --- a/FileSaver/FileSaver-tests.ts +++ b/FileSaver/FileSaver-tests.ts @@ -6,6 +6,7 @@ function testSaveAs() { var data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); var filename: string = 'hello world.txt'; - - saveAs(data, filename); + var disableAutoBOM = true; + + saveAs(data, filename, disableAutoBOM); } diff --git a/FileSaver/FileSaver.d.ts b/FileSaver/FileSaver.d.ts index 0b6cc75d6..fa5f31947 100644 --- a/FileSaver/FileSaver.d.ts +++ b/FileSaver/FileSaver.d.ts @@ -20,8 +20,14 @@ interface FileSaver { * @summary File name. * @type {DOMString} */ - filename: string + filename: string, + + /** + * @summary Disable Unicode text encoding hints or not. + * @type {boolean} + */ + disableAutoBOM?: boolean ): void } -declare var saveAs: FileSaver; \ No newline at end of file +declare var saveAs: FileSaver; From 14d66bda05b1996ac36137e1d38334bc6095f165 Mon Sep 17 00:00:00 2001 From: Rob Howard Date: Thu, 15 Oct 2015 08:28:29 -0700 Subject: [PATCH 051/357] Initial commit of office-js.d.ts Includes basic tests for Word and Excel objects --- office-js/office-js-tests.ts | 175 ++ office-js/office-js.d.ts | 5300 ++++++++++++++++++++++++++++++++++ 2 files changed, 5475 insertions(+) create mode 100644 office-js/office-js-tests.ts create mode 100644 office-js/office-js.d.ts diff --git a/office-js/office-js-tests.ts b/office-js/office-js-tests.ts new file mode 100644 index 000000000..cd568d0e6 --- /dev/null +++ b/office-js/office-js-tests.ts @@ -0,0 +1,175 @@ +/* +------------------------------------------ START OF LICENSE ----------------------------------------- +office-js +Copyright (c) Microsoft Corporation +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +----------------------------------------------- END OF LICENSE ------------------------------------------ +*/ + +/// + +function test_excel() { + + // Range + Excel.run(function(ctx) { + var range = ctx.workbook.getSelectedRange().load("values"); + return ctx.sync() + .then(function() { + var vals = range.values; + for (var i = 0; i < vals.length; i++){ + for (var j = 0; j < vals[i].length; j++){ + vals[i][j] = vals[i][j].toUpperCase(); + } + } + range.values = vals; + }) + .then(ctx.sync); + }).catch(function (error) { + console.log(error); + }); + + + // Chart + Excel.run(function (ctx) { + var sheet = ctx.workbook.worksheets.getItem("Sheet1"); + + var range = sheet.getRange("A1:B3"); + range.values = [ + ["", "Gender"], + ["Male", 12], + ["Female", 14] + ]; + + var chart = sheet.charts.add("pie", range, "auto"); + + chart.format.fill.setSolidColor("F8F8FF"); + + chart.title.text = "Class Demographics"; + chart.title.format.font.bold = true; + chart.title.format.font.size = 18; + chart.title.format.font.color = "568568"; + + chart.legend.position = "right"; + chart.legend.format.font.name = "Algerian"; + chart.legend.format.font.size = 13; + + chart.dataLabels.showPercentage = true; + chart.dataLabels.format.font.size = 15; + chart.dataLabels.format.font.color = "444444"; + + var points = chart.series.getItemAt(0).points; + points.getItemAt(0).format.fill.setSolidColor("8FBC8F"); + points.getItemAt(1).format.fill.setSolidColor("D87093"); + + return ctx.sync(); + }).catch(function (error) { + console.log(error); + }); + + + // Table + Excel.run(function (ctx) { + var rows = ctx.workbook.tables.getItem("Table1").rows.load("values"); + return ctx.sync() + .then(function () { + var largestRow = 0; + var largestValue = 0; + + for (var i = 0; i < rows.items.length; i++){ + if (rows.items[i].values[0][1] > largestValue){ + largestRow = i; + largestValue = rows.items[i].values[0][1]; + } + } + + var largestRowRng = rows.getItemAt(largestRow).getRange(); + largestRowRng.format.fill.color = "#ff0000"; + + }) + .then(ctx.sync); + }).catch(function (error) { + console.log(error); + }); + +} + +function test_word() { + + // Search + Word.run(function (context) { + + // Create a proxy object for the document body. + var body = context.document.body; + + // Setup the search options. + var options = Word.SearchOptions.newObject(context); + options.matchCase = false + + // Queue a commmand to search the document. + var searchResults = context.document.body.search('video', options); + + // Queue a commmand to load the results. + context.load(searchResults, 'text, font'); + + // Synchronize the document state by executing the queued-up commands, + // and return a promise to indicate task completion. + return context.sync().then(function () { + var results = 'Found count: ' + searchResults.items.length + + '; we highlighted the results.'; + + // Queue a command to change the font for each found item. + for (var i = 0; i < searchResults.items.length; i++) { + searchResults.items[i].font.color = '#FF0000' // Change color to Red + searchResults.items[i].font.highlightColor = '#FFFF00'; + searchResults.items[i].font.bold = true; + } + + // Synchronize the document state by executing the queued-up commands, + // and return a promise to indicate task completion. + return context.sync().then(function () { + console.log(results); + }); + }); + }) + .catch(function (error) { + console.log('Error: ' + JSON.stringify(error)); + if (error instanceof OfficeExtension.Error) { + console.log('Debug info: ' + JSON.stringify(error.debugInfo)); + } + }); + + + // Content control + Word.run(function (context) { + + // Create a proxy range object for the current selection. + var range = context.document.getSelection(); + + // Queue a commmand to create the content control. + var myContentControl = range.insertContentControl(); + myContentControl.tag = 'Customer-Address'; + myContentControl.title = 'Enter Customer Address Here:'; + myContentControl.style = 'Heading 2'; + myContentControl.insertText('One Microsoft Way, Redmond, WA 98052', 'replace'); + myContentControl.cannotEdit = true; + myContentControl.appearance = 'tags'; + + // Queue a command to load the id property for the content control you created. + context.load(myContentControl, 'id'); + + // Synchronize the document state by executing the queued-up commands, + // and return a promise to indicate task completion. + return context.sync().then(function () { + console.log('Created content control with id: ' + myContentControl.id); + }); + }) + .catch(function (error) { + console.log('Error: ' + JSON.stringify(error)); + if (error instanceof OfficeExtension.Error) { + console.log('Debug info: ' + JSON.stringify(error.debugInfo)); + } + }); + +} diff --git a/office-js/office-js.d.ts b/office-js/office-js.d.ts new file mode 100644 index 000000000..cb146fae1 --- /dev/null +++ b/office-js/office-js.d.ts @@ -0,0 +1,5300 @@ +/* +------------------------------------------ START OF LICENSE ----------------------------------------- +office-js +Copyright (c) Microsoft Corporation +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +----------------------------------------------- END OF LICENSE ------------------------------------------ +*/ + +// Type definitions for Office.js +// Project: http://dev.office.com +// Definitions by: OfficeDev +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare module Office { + export var context: Context; + /** + * This method is called after the Office API was loaded. + * @param reason Indicates how the app was initialized + */ + export function initialize(reason: InitializationReason): void; + /** + * Indicates if the large namespace for objects will be used or not. + * @param useShortNamespace Indicates if 'true' that the short namespace will be used + */ + export function useShortNamespace(useShortNamespace: boolean): void; + // Enumerations + export enum AsyncResultStatus { + /** + * Operation succeeded + */ + Succeeded, + /** + * Operation failed, check error object + */ + Failed + } + export enum InitializationReason { + /** + * Indicates the app was just inserted in the document + */ + Inserted, + /** + * Indicates if the extension already existed in the document + */ + DocumentOpened + } + // Objects + export interface AsyncResult { + asyncContext: any; + status: AsyncResultStatus; + error: Error; + value: any; + } + export interface Context { + contentLanguage: string; + displayLanguage: string; + license: string; + touchEnabled: boolean; + requirements: { + /** + * Check if the specified requirement set is supported by the host Office application. + * @param name - Set name. e.g.: "MatrixBindings". + * @param minVersion - The minimum required version. + */ + isSetSupported(name: string, minVersion?: number): boolean; + } + } + export interface Error { + message: string; + name: string; + } +} +declare module OfficeExtension { + /** An abstract proxy object that represents an object in an Office document. You create proxy objects from the context (or from other proxy objects), add commands to a queue to act on the object, and then synchronize the proxy object state with the document by calling "context.sync()". */ + class ClientObject { + /** The request context associated with the object */ + context: ClientRequestContext; + } +} +declare module OfficeExtension { + interface LoadOption { + select?: string | string[]; + expand?: string | string[]; + top?: number; + skip?: number; + } + /** An abstract RequestContext object that facilitates requests to the host Office application. The "Excel.run" and "Word.run" methods provide a request context. */ + class ClientRequestContext { + constructor(url?: string); + /** Collection of objects that are tracked for automatic adjustments based on surrounding changes in the document. */ + trackedObjects: TrackedObjects; + /** Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. */ + load(object: ClientObject, option?: string | string[] | LoadOption): void; + /** Adds a trace message to the queue. If the promise returned by "context.sync()" is rejected due to an error, this adds a ".traceMessages" array to the OfficeExtension.Error object, containing all trace messages that were executed. These messages can help you monitor the program execution sequence and detect the cause of the error. */ + trace(message: string): void; + /** Synchronizes the state between JavaScript proxy objects and the Office document, by executing instructions queued on the request context and retrieving properties of loaded Office objects for use in your code.�This method returns a promise, which is resolved when the synchronization is complete. */ + sync(passThroughValue?: T): IPromise; + } +} +declare module OfficeExtension { + /** Contains the result for methods that return primitive types. The object's value property is retrieved from the document after "context.sync()" is invoked. */ + class ClientResult { + /** The value of the result that is retrieved from the document after "context.sync()" is invoked. */ + value: T; + } +} +declare module OfficeExtension { + /** The error object returned by "context.sync()", if a promise is rejected due to an error while processing the request. */ + class Error { + /** Error name: "OfficeExtension.Error".*/ + name: string; + /** The error message passed through from the host Office application. */ + message: string; + /** Stack trace, if applicable. */ + stack: string; + /** Error code string, such as "InvalidArgument". */ + code: string; + /** Trace messages (if any) that were added via a "context.trace()" invocation before calling "context.sync()". If there was an error, this contains all trace messages that were executed before the error occurred. These messages can help you monitor the program execution sequence and detect the case of the error. */ + traceMessages: Array; + /** Debug info, if applicable. The ".errorLocation" property can describe the object and method or property that caused the error. */ + debugInfo: { + /** If applicable, will return the object type and the name of the method or property that caused the error. */ + errorLocation?: string; + }; + } +} +declare module OfficeExtension { + class ErrorCodes { + static accessDenied: string; + static generalException: string; + static activityLimitReached: string; + } +} +declare module OfficeExtension { + /** A Promise object that represents a deferred interaction with the host Office application. Promises can be chained via ".then", and errors can be caught via ".catch". Remember to always use a ".catch" on the outer promise, and to return intermediary promises so as not to break the promise chain. */ + interface IPromise { + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => IPromise): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => U): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => IPromise, onRejected?: (error: any) => void): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => IPromise): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): IPromise; + /** + * This method will be called once the previous promise has been resolved. + * Both the onFulfilled on onRejected callbacks are optional. + * If either or both are omitted, the next onFulfilled/onRejected in the chain will be called called. + * @returns A new promise for the value or error that was returned from onFulfilled/onRejected. + */ + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): IPromise; + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => IPromise): IPromise; + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => U): IPromise; + /** + * Catches failures or exceptions from actions within the promise, or from an unhandled exception earlier in the call stack. + * @param onRejected function to be called if or when the promise rejects. + */ + catch(onRejected?: (error: any) => void): IPromise; + } +} +declare module OfficeExtension { + /** Collection of tracked objects, contained within a request context. See "context.trackedObjects" for more information. */ + class TrackedObjects { + /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ + add(object: ClientObject): void; + /** Track a new object for automatic adjustment based on surrounding changes in the document. Only some object types require this. If you are using an object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created. */ + add(objects: ClientObject[]): void; + /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ + remove(object: ClientObject): void; + /** Release the memory associated with an object that was previously added to this collection. Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect. */ + remove(objects: ClientObject[]): void; + } +} + +declare module Office { + /** + * Returns a promise of an object described in the expression. Callback is invoked only if method fails. + * @param expression The object to be retrieved. Example "bindings#BindingName", retrieves a binding promise for a binding named 'BindingName' + * @param callback The optional callback method + */ + export function select(expression: string, callback?: (result: AsyncResult) => void): Binding; + // Enumerations + export enum ActiveView { + Read, + Edit + } + export enum BindingType { + /** + * Text based Binding + */ + Text, + /** + * Matrix based Binding + */ + Matrix, + /** + * Table based Binding + */ + Table + } + export enum CoercionType { + /** + * Coerce as Text + */ + Text, + /** + * Coerce as Matrix + */ + Matrix, + /** + * Coerce as Table + */ + Table, + /** + * Coerce as HTML + */ + Html, + /** + * Coerce as Office Open XML + */ + Ooxml, + /** + * Coerce as JSON object containing an array of the ids, titles, and indexes of the selected slides. + */ + SlideRange + } + export enum DocumentMode { + /** + * Document in Read Only Mode + */ + ReadOnly, + /** + * Document in Read/Write Mode + */ + ReadWrite + } + export enum EventType { + /** + * Occurs when the user changes the current view of the document. + */ + ActiveViewChanged, + /** + * Triggers when a binding level data change happens + */ + BindingDataChanged, + /** + * Triggers when a binding level selection happens + */ + BindingSelectionChanged, + /** + * Triggers when a document level selection happens + */ + DocumentSelectionChanged, + /** + * Triggers when a customXmlPart node was deleted + */ + NodeDeleted, + /** + * Triggers when a customXmlPart node was inserted + */ + NodeInserted, + /** + * Triggers when a customXmlPart node was replaced + */ + NodeReplaced, + /** + * Triggers when settings change in a co-Auth session. + */ + SettingsChanged, + /** + * Triggers when a Task selection happens in Project. + */ + TaskSelectionChanged, + /** + * Triggers when a Resource selection happens in Project. + */ + ResourceSelectionChanged, + /** + * Triggers when a View selection happens in Project. + */ + ViewSelectionChanged + } + export enum FileType { + /** + * Returns the file as plain text + */ + Text, + /** + * Returns the file as a byte array + */ + Compressed, + /** + * Returns the file in PDF format as a byte array + */ + Pdf + } + export enum FilterType { + /** + * Returns all items + */ + All, + /** + * Returns only visible items + */ + OnlyVisible + } + export enum GoToType { + /** + * Goes to a binding object using the specified binding id. + */ + Binding, + /** + * Goes to a named item using that item's name. + * In Excel, you can use any structured reference for a named range or table: "Worksheet2!Table1" + */ + NamedItem, + /** + * Goes to a slide using the specified id. + */ + Slide, + /** + * Goes to the specified index by slide number or enum Office.Index + */ + Index + } + export enum Index { + First, + Last, + Next, + Previous + } + export enum SelectionMode { + Default, + Selected, + None + } + export enum ValueFormat { + /** + * Returns items without format + */ + Unformatted, + /** + * Returns items with format + */ + Formatted + } + // Objects + export interface Binding { + document: Document; + /** + * Id of the Binding + */ + id: string; + type: BindingType; + /** + * Adds an event handler to the object using the specified event type. + * @param eventType The event type. For binding it can be 'bindingDataChanged' and 'bindingSelectionChanged' + * @param handler The name of the handler + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addHandlerAsync(eventType: EventType, handler: any, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Returns the current selection. + * @param options Syntax example: {coercionType: 'matrix,'valueFormat: 'formatted', filterType:'all'} + * coercionType: The expected shape of the selection. If not specified returns the bindingType shape. Use Office.CoercionType or text value. + * valueFormat: Get data with or without format. Use Office.ValueFormat or text value. + * startRow: Used in partial get for table/matrix. Indicates the start row. + * startColumn: Used in partial get for table/matrix. Indicates the start column. + * rowCount: Used in partial get for table/matrix. Indicates the number of rows from the start row. + * columnCount: Used in partial get for table/matrix. Indicates the number of columns from the start column. + * filterType: Get the visible or all the data. Useful when filtering data. Use Office.FilterType or text value. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getDataAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an event handler from the object using the specified event type. + * @param eventType The event type. For binding can be 'bindingDataChanged' and 'bindingSelectionChanged' + * @param options Syntax example: {handler:eventHandler} + * handler: Indicates a specific handler to be removed, if not specified all handlers are removed + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Writes the specified data into the current selection. + * @param data The data to be set. Either a string or value, 2d array or TableData object + * @param options Syntax example: {coercionType:Office.CoercionType.Matrix} or {coercionType: 'matrix'} + * coercionType: Explicitly sets the shape of the data object. Use Office.CoercionType or text value. If not supplied is inferred from the data type. + * startRow: Used in partial set for table/matrix. Indicates the start row. + * startColumn: Used in partial set for table/matrix. Indicates the start column. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setDataAsync(data: any, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Bindings { + document: Document; + /** + * Creates a binding against a named object in the document + * @param itemName Name of the bindable object in the document. For Example 'MyExpenses' table in Excel." + * @param bindingType The Office BindingType for the data + * @param options Syntax example: {id: "BindingID"} + * id: Name of the binding, autogenerated if not supplied. + * asyncContext: Object keeping state for the callback + * columns: The string[] of the columns involved in the binding + * @param callback The optional callback method + */ + addFromNamedItemAsync(itemName: string, bindingType: BindingType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Create a binding by prompting the user to make a selection on the document. + * @param bindingType The Office BindingType for the data + * @param options addFromPromptAsyncOptions- e.g. {promptText: "Please select data", id: "mySales"} + * promptText: Greet your users with a friendly word. + * asyncContext: Object keeping state for the callback + * id: Identifier. + * sampleData: A TableData that gives sample table in the Dialog.TableData.Headers is [][] of string. + * @param callback The optional callback method + */ + addFromPromptAsync(bindingType: BindingType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Create a binding based on what the user's current selection. + * @param bindingType The Office BindingType for the data + * @param options addFromSelectionAsyncOptions- e.g. {id: "BindingID"} + * id: Identifier. + * asyncContext: Object keeping state for the callback + * columns: The string[] of the columns involved in the binding + * sampleData: A TableData that gives sample table in the Dialog.TableData.Headers is [][] of string. + * @param callback The optional callback method + */ + addFromSelectionAsync(bindingType: BindingType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets an array with all the binding objects in the document. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getAllAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Retrieves a binding based on its Name + * @param id The binding id + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getByIdAsync(id: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes the binding from the document + * @param id The binding id + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + releaseByIdAsync(id: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Bindings { + /** + * Gets a value that indicates whether the content is in HTML or text format. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getTypeAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds the specified content to the beginning of the item body + * @param data The string to be inserted at the beginning of the body + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + prependAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Replaces the selection in the body with the specified text + * @param data The string to be inserted at the beginning of the body + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setSelectedDataAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Context { + document: Document; + } + export interface CustomXmlNode { + baseName: string; + namespaceUri: string; + nodeType: string; + /** + * Gets the nodes associated with the xPath expression. + * @param xPath The xPath expression + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getNodesAsync(xPath: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the node value. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getNodeValueAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the node's XML. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getXmlAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Sets the node value. + * @param value The value to be set on the node + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setNodeValueAsync(value: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Sets the node XML. + * @param xml The XML to be set on the node + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setXmlAsync(xml: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface CustomXmlPart { + builtIn: boolean; + id: string; + namespaceManager: CustomXmlPrefixMappings; + /** + * Adds an event handler to the object using the specified event type. + * @param eventType The event type. For CustomXmlPartNode it can be 'nodeDeleted', 'nodeInserted' or 'nodeReplaced' + * @param handler The name of the handler + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addHandlerAsync(eventType: EventType, handler?: (result: any) => void, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Deletes the Custom XML Part. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + deleteAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the nodes associated with the xPath expression. + * @param xPath The xPath expression + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getNodesAsync(xPath: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the XML for the Custom XML Part. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getXmlAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an event handler from the object using the specified event type. + * @param eventType The event type. For CustomXmlPartNode it can be 'nodeDeleted', 'nodeInserted' or 'nodeReplaced' + * @param options Syntax example: {handler:eventHandler} + * handler: Indicates a specific handler to be removed, if not specified all handlers are removed + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface CustomXmlParts { + /** + * Asynchronously adds a new custom XML part to a file. + * @param xml The XML to add to the newly created custom XML part. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. + */ + addAsync(xml: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Asynchronously gets the specified custom XML part by its id. + * @param id The id of the custom XML part. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. + */ + getByIdAsync(id: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Asynchronously gets the specified custom XML part(s) by its namespace. + * @param ns The namespace to search. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. + */ + getByNamespaceAsync(ns: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface CustomXmlPrefixMappings { + /** + * Adds a namespace. + * @param prefix The namespace prefix + * @param ns The namespace URI + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addNamespaceAsync(prefix: string, ns: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets a namespace with the specified prefix + * @param prefix The namespace prefix + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getNamespaceAsync(prefix: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets a prefix for the specified URI + * @param ns The namespace URI + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getPrefixAsync(ns: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Document { + bindings: Bindings; + customXmlParts: CustomXmlParts; + mode: DocumentMode; + settings: Settings; + url: string; + /** + * Adds an event handler for the specified event type. + * @param eventType The event type. For document can be 'DocumentSelectionChanged' + * @param handler The name of the handler + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addHandlerAsync(eventType: EventType, handler: any, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Returns the current view of the presentation. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getActiveViewAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the entire file in slices of up to 4MB. + * @param fileType The format in which the file will be returned + * @param options Syntax example: {sliceSize:1024} + * sliceSize: Specifies the desired slice size (in bytes) up to 4MB. If not specified a default slice size of 4MB will be used. + * @param callback The optional callback method + */ + getFileAsync(fileType: FileType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets file properties of the current document. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getFilePropertiesAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Returns the current selection. + * @param coercionType The expected shape of the selection. + * @param options Syntax example: {valueFormat: 'formatted', filterType:'all'} + * valueFormat: Get data with or without format. Use Office.ValueFormat or text value. + * filterType: Get the visible or all the data. Useful when filtering data. Use Office.FilterType or text value. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getSelectedDataAsync(coercionType: CoercionType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Goes to the specified object or location in the document. + * @param id The identifier of the object or location to go to. + * @param goToType The type of the location to go to. + * @param options Syntax example: {asyncContext:context} + * selectionMode: Use Office.SelectionMode or text value. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + goToByIdAsync(id: string, goToType: GoToType, options?: any, callback?: (result: AsyncResult) => void): void; + goToByIdAsync(id: number, goToType: GoToType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an event handler for the specified event type. + * @param eventType The event type. For document can be 'DocumentSelectionChanged' + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * handler: The name of the handler. If not specified all handlers are removed + * @param callback The optional callback method + */ + removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Writes the specified data into the current selection. + * @param data The data to be set. Either a string or value, 2d array or TableData object + * @param options Syntax example: {coercionType:Office.CoercionType.Matrix} or {coercionType: 'matrix'} + * coercionType: Explicitly sets the shape of the data object. Use Office.CoercionType or text value. If not supplied is inferred from the data type. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setSelectedDataAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface File { + size: number; + sliceCount: number; + /** + * Closes the File. + * @param callback The optional callback method + */ + closeAsync(callback?: (result: AsyncResult) => void): void; + /** + * Gets the specified slice. + * @param sliceIndex The index of the slice to be retrieved + * @param callback The optional callback method + */ + getSliceAsync(sliceIndex: number, callback?: (result: AsyncResult) => void): void; + } + export interface FileProperties { + /** + * File's URL + */ + url: string + } + export interface MatrixBinding extends Binding { + columnCount: number; + rowCount: number; + } + export interface Settings { + /** + * Adds an event handler for the object using the specified event type. + * @param eventType The event type. For settings can be 'settingsChanged' + * @param handler The name of the handler + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addHandlerAsync(eventType: EventType, handler: any, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Retrieves the setting with the specified name. + * @param settingName The name of the setting + */ + get(name: string): any; + /** + * Gets the latest version of the settings object. + * @param callback The optional callback method + */ + refreshAsync(callback?: (result: AsyncResult) => void): void; + /** + * Removes the setting with the specified name. + * @param settingName The name of the setting + */ + remove(name: string): void; + /** + * Removes an event handler for the specified event type. + * @param eventType The event type. For settings can be 'settingsChanged' + * @param options Syntax example: {handler:eventHandler} + * handler: Indicates a specific handler to be removed, if not specified all handlers are removed + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + removeHandlerAsync(eventType: EventType, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Saves all settings. + * @param options Syntax example: {overwriteIfStale:false} + * overwriteIfStale: Indicates whether the setting will be replaced if stale. + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + saveAsync(callback?: (result: AsyncResult) => void): void; + /** + * Sets a value for the setting with the specified name. + * @param settingName The name of the setting + * @param value The value for the setting + */ + set(name: string, value: any): void; + } + export interface Slice { + data: any; + index: number; + size: number; + } + export interface TableBinding extends Binding { + columnCount: number; + hasHeaders: boolean; + rowCount: number; + /** + * Adds the specified columns to the table + * @param tableData A TableData object with the headers and rows + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addColumnsAsync(tableData: TableData, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds the specified rows to the table + * @param rows A 2D array with the rows to add + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + addRowsAsync(rows: any[][], options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Clears the table + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + deleteAllDataValuesAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Clears formatting on the bound table. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + clearFormatsAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Gets the formatting on specified items in the table. + * @param cellReference An object literal containing name-value pairs that specify the range of cells to get formatting from. + * @param formats An array specifying the format properties to get. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getFormatsAsync(cellReference?: any, formats?: any[], options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Sets formatting on specified items and data in the table. + * @param formatsInfo Array elements are themselves three-element arrays:[target, type, formats] + * target: The identifier of the item to format. String. + * type: The kind of item to format. String. + * formats: An object literal containing a list of property name-value pairs that define the formatting to apply. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setFormatsAsync(formatsInfo?: any[][], options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Updates table formatting options on the bound table. + * @param tableOptions An object literal containing a list of property name-value pairs that define the table options to apply. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + setTableOptionsAsync(tableOptions: any, options?: any, callback?: (result: AsyncResult) => void): void; + } + export class TableData { + constructor(rows: any[][], headers: any[][]); + headers: any[][]; + rows: any[][]; + } + export interface TextBinding extends Binding { } + export enum ProjectProjectFields { + CurrencyDigits, + CurrencySymbol, + CurrencySymbolPosition, + DurationUnits, + GUID, + Finish, + Start, + ReadOnly, + VERSION, + WorkUnits, + ProjectServerUrl, + WSSUrl, + WSSList + } + export enum ProjectResourceFields { + Accrual, + ActualCost, + ActualOvertimeCost, + ActualOvertimeWork, + ActualOvertimeWorkProtected, + ActualWork, + ActualWorkProtected, + BaseCalendar, + Baseline10BudgetCost, + Baseline10BudgetWork, + Baseline10Cost, + Baseline10Work, + Baseline1BudgetCost, + Baseline1BudgetWork, + Baseline1Cost, + Baseline1Work, + Baseline2BudgetCost, + Baseline2BudgetWork, + Baseline2Cost, + Baseline2Work, + Baseline3BudgetCost, + Baseline3BudgetWork, + Baseline3Cost, + Baseline3Work, + Baseline4BudgetCost, + Baseline4BudgetWork, + Baseline4Cost, + Baseline4Work, + Baseline5BudgetCost, + Baseline5BudgetWork, + Baseline5Cost, + Baseline5Work, + Baseline6BudgetCost, + Baseline6BudgetWork, + Baseline6Cost, + Baseline6Work, + Baseline7BudgetCost, + Baseline7BudgetWork, + Baseline7Cost, + Baseline7Work, + Baseline8BudgetCost, + Baseline8BudgetWork, + Baseline8Cost, + Baseline8Work, + Baseline9BudgetCost, + Baseline9BudgetWork, + Baseline9Cost, + Baseline9Work, + BaselineBudgetCost, + BaselineBudgetWork, + BaselineCost, + BaselineWork, + BudgetCost, + BudgetWork, + ResourceCalendarGUID, + Code, + Cost1, + Cost10, + Cost2, + Cost3, + Cost4, + Cost5, + Cost6, + Cost7, + Cost8, + Cost9, + ResourceCreationDate, + Date1, + Date10, + Date2, + Date3, + Date4, + Date5, + Date6, + Date7, + Date8, + Date9, + Duration1, + Duration10, + Duration2, + Duration3, + Duration4, + Duration5, + Duration6, + Duration7, + Duration8, + Duration9, + Email, + End, + Finish1, + Finish10, + Finish2, + Finish3, + Finish4, + Finish5, + Finish6, + Finish7, + Finish8, + Finish9, + Flag10, + Flag1, + Flag11, + Flag12, + Flag13, + Flag14, + Flag15, + Flag16, + Flag17, + Flag18, + Flag19, + Flag2, + Flag20, + Flag3, + Flag4, + Flag5, + Flag6, + Flag7, + Flag8, + Flag9, + Group, + Units, + Name, + Notes, + Number1, + Number10, + Number11, + Number12, + Number13, + Number14, + Number15, + Number16, + Number17, + Number18, + Number19, + Number2, + Number20, + Number3, + Number4, + Number5, + Number6, + Number7, + Number8, + Number9, + OvertimeCost, + OvertimeRate, + OvertimeWork, + PercentWorkComplete, + CostPerUse, + Generic, + OverAllocated, + RegularWork, + RemainingCost, + RemainingOvertimeCost, + RemainingOvertimeWork, + RemainingWork, + ResourceGUID, + Cost, + Work, + Start, + Start1, + Start10, + Start2, + Start3, + Start4, + Start5, + Start6, + Start7, + Start8, + Start9, + StandardRate, + Text1, + Text10, + Text11, + Text12, + Text13, + Text14, + Text15, + Text16, + Text17, + Text18, + Text19, + Text2, + Text20, + Text21, + Text22, + Text23, + Text24, + Text25, + Text26, + Text27, + Text28, + Text29, + Text3, + Text30, + Text4, + Text5, + Text6, + Text7, + Text8, + Text9 + } + export enum ProjectTaskFields { + ActualCost, + ActualDuration, + ActualFinish, + ActualOvertimeCost, + ActualOvertimeWork, + ActualStart, + ActualWork, + Text1, + Text10, + Finish10, + Start10, + Text11, + Text12, + Text13, + Text14, + Text15, + Text16, + Text17, + Text18, + Text19, + Finish1, + Start1, + Text2, + Text20, + Text21, + Text22, + Text23, + Text24, + Text25, + Text26, + Text27, + Text28, + Text29, + Finish2, + Start2, + Text3, + Text30, + Finish3, + Start3, + Text4, + Finish4, + Start4, + Text5, + Finish5, + Start5, + Text6, + Finish6, + Start6, + Text7, + Finish7, + Start7, + Text8, + Finish8, + Start8, + Text9, + Finish9, + Start9, + Baseline10BudgetCost, + Baseline10BudgetWork, + Baseline10Cost, + Baseline10Duration, + Baseline10Finish, + Baseline10FixedCost, + Baseline10FixedCostAccrual, + Baseline10Start, + Baseline10Work, + Baseline1BudgetCost, + Baseline1BudgetWork, + Baseline1Cost, + Baseline1Duration, + Baseline1Finish, + Baseline1FixedCost, + Baseline1FixedCostAccrual, + Baseline1Start, + Baseline1Work, + Baseline2BudgetCost, + Baseline2BudgetWork, + Baseline2Cost, + Baseline2Duration, + Baseline2Finish, + Baseline2FixedCost, + Baseline2FixedCostAccrual, + Baseline2Start, + Baseline2Work, + Baseline3BudgetCost, + Baseline3BudgetWork, + Baseline3Cost, + Baseline3Duration, + Baseline3Finish, + Baseline3FixedCost, + Baseline3FixedCostAccrual, + Basline3Start, + Baseline3Work, + Baseline4BudgetCost, + Baseline4BudgetWork, + Baseline4Cost, + Baseline4Duration, + Baseline4Finish, + Baseline4FixedCost, + Baseline4FixedCostAccrual, + Baseline4Start, + Baseline4Work, + Baseline5BudgetCost, + Baseline5BudgetWork, + Baseline5Cost, + Baseline5Duration, + Baseline5Finish, + Baseline5FixedCost, + Baseline5FixedCostAccrual, + Baseline5Start, + Baseline5Work, + Baseline6BudgetCost, + Baseline6BudgetWork, + Baseline6Cost, + Baseline6Duration, + Baseline6Finish, + Baseline6FixedCost, + Baseline6FixedCostAccrual, + Baseline6Start, + Baseline6Work, + Baseline7BudgetCost, + Baseline7BudgetWork, + Baseline7Cost, + Baseline7Duration, + Baseline7Finish, + Baseline7FixedCost, + Baseline7FixedCostAccrual, + Baseline7Start, + Baseline7Work, + Baseline8BudgetCost, + Baseline8BudgetWork, + Baseline8Cost, + Baseline8Duration, + Baseline8Finish, + Baseline8FixedCost, + Baseline8FixedCostAccrual, + Baseline8Start, + Baseline8Work, + Baseline9BudgetCost, + Baseline9BudgetWork, + Baseline9Cost, + Baseline9Duration, + Baseline9Finish, + Baseline9FixedCost, + Baseline9FixedCostAccrual, + Baseline9Start, + Baseline9Work, + BaselineBudgetCost, + BaselineBudgetWork, + BaselineCost, + BaselineDuration, + BaselineFinish, + BaselineFixedCost, + BaselineFixedCostAccrual, + BaselineStart, + BaselineWork, + BudgetCost, + BudgetFixedCost, + BudgetFixedWork, + BudgetWork, + TaskCalendarGUID, + ConstraintDate, + ConstraintType, + Cost1, + Cost10, + Cost2, + Cost3, + Cost4, + Cost5, + Cost6, + Cost7, + Cost8, + Cost9, + Date1, + Date10, + Date2, + Date3, + Date4, + Date5, + Date6, + Date7, + Date8, + Date9, + Deadline, + Duration1, + Duration10, + Duration2, + Duration3, + Duration4, + Duration5, + Duration6, + Duration7, + Duration8, + Duration9, + Duration, + EarnedValueMethod, + FinishSlack, + FixedCost, + FixedCostAccrual, + Flag10, + Flag1, + Flag11, + Flag12, + Flag13, + Flag14, + Flag15, + Flag16, + Flag17, + Flag18, + Flag19, + Flag2, + Flag20, + Flag3, + Flag4, + Flag5, + Flag6, + Flag7, + Flag8, + Flag9, + FreeSlack, + HasRollupSubTasks, + ID, + Name, + Notes, + Number1, + Number10, + Number11, + Number12, + Number13, + Number14, + Number15, + Number16, + Number17, + Number18, + Number19, + Number2, + Number20, + Number3, + Number4, + Number5, + Number6, + Number7, + Number8, + Number9, + ScheduledDuration, + ScheduledFinish, + ScheduledStart, + OutlineLevel, + OvertimeCost, + OvertimeWork, + PercentComplete, + PercentWorkComplete, + Predecessors, + PreleveledFinish, + PreleveledStart, + Priority, + Active, + Critical, + Milestone, + Overallocated, + IsRollup, + Summary, + RegularWork, + RemainingCost, + RemainingDuration, + RemainingOvertimeCost, + RemainingWork, + ResourceNames, + Cost, + Finish, + Start, + Work, + StartSlack, + Status, + Successors, + StatusManager, + TotalSlack, + TaskGUID, + Type, + WBS, + WBSPREDECESSORS, + WBSSUCCESSORS, + WSSID + } + export enum ProjectViewTypes { + Gantt, + NetworkDiagram, + TaskDiagram, + TaskForm, + TaskSheet, + ResourceForm, + ResourceSheet, + ResourceGraph, + TeamPlanner, + TaskDetails, + TaskNameForm, + ResourceNames, + Calendar, + TaskUsage, + ResourceUsage, + Timeline + } + // Objects + export interface Document { + /** + * Get Project field (Ex. ProjectWebAccessURL). + * @param fieldId Project level fields. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getProjectFieldAsync(fieldId: number, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get resource field for provided resource Id. (Ex.ResourceName) + * @param resourceId Either a string or value of the Resource Id. + * @param fieldId Resource Fields. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getResourceFieldAsync(resourceId: string, fieldId: number, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the current selected Resource's Id. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getSelectedResourceAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the current selected Task's Id. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getSelectedTaskAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the current selected View Type (Ex. Gantt) and View Name. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getSelectedViewAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the Task Name, WSS Task Id, and ResourceNames for given taskId. + * @param taskId Either a string or value of the Task Id. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getTaskAsync(taskId: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get task field for provided task Id. (Ex. StartDate). + * @param taskId Either a string or value of the Task Id. + * @param fieldId Task Fields. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getTaskFieldAsync(taskId: string, fieldId: number, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Get the WSS Url and list name for the Tasks List, the MPP is synced too. + * @param options Syntax example: {asyncContext:context} + * asyncContext: Object keeping state for the callback + * @param callback The optional callback method + */ + getWSSUrlAsync(options?: any, callback?: (result: AsyncResult) => void): void; + } +} + + +declare module Excel { + /** + * + * Represents the Excel application that manages the workbook. + */ + class Application extends OfficeExtension.ClientObject { + private m_calculationMode; + /** + * + * Returns the calculation mode used in the workbook. See Excel.CalculationMode for details. Read-only. + */ + calculationMode: string; + /** + * + * Recalculate all currently opened workbooks in Excel. + * + * @param calculationType Specifies the calculation type to use. See Excel.CalculationType for details. + */ + calculate(calculationType: string): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Application; + } + /** + * + * Workbook is the top level object which contains related workbook objects such as worksheets, tables, ranges, etc. + */ + class Workbook extends OfficeExtension.ClientObject { + private m_application; + private m_bindings; + private m_names; + private m_tables; + private m_worksheets; + /** + * + * Represents Excel application instance that contains this workbook. Read-only. + */ + application: Excel.Application; + /** + * + * Represents a collection of bindings that are part of the workbook. Read-only. + */ + bindings: Excel.BindingCollection; + /** + * + * Represents a collection of workbook scoped named items (named ranges and constants). Read-only. + */ + names: Excel.NamedItemCollection; + /** + * + * Represents a collection of tables associated with the workbook. Read-only. + */ + tables: Excel.TableCollection; + /** + * + * Represents a collection of worksheets associated with the workbook. Read-only. + */ + worksheets: Excel.WorksheetCollection; + /** + * + * Gets the currently selected range from the workbook. + * + */ + getSelectedRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Workbook; + } + /** + * + * An Excel worksheet is a grid of cells. It can contain data, tables, charts, etc. + */ + class Worksheet extends OfficeExtension.ClientObject { + private m_charts; + private m_id; + private m_name; + private m_position; + private m_tables; + private m_visibility; + /** + * + * Returns collection of charts that are part of the worksheet. Read-only. + */ + charts: Excel.ChartCollection; + /** + * + * Collection of tables that are part of the worksheet. Read-only. + */ + tables: Excel.TableCollection; + /** + * + * Returns a value that uniquely identifies the worksheet in a given workbook. The value of the identifier remains the same even when the worksheet is renamed or moved. Read-only. + */ + id: string; + /** + * + * The display name of the worksheet. + */ + name: string; + /** + * + * The zero-based position of the worksheet within the workbook. + */ + position: number; + /** + * + * The Visibility of the worksheet, Read-only. + */ + visibility: string; + /** + * + * Activate the worksheet in the Excel UI. + * + */ + activate(): void; + /** + * + * Deletes the worksheet from the workbook. + * + */ + delete(): void; + /** + * + * Gets the range object containing the single cell based on row and column numbers. The cell can be outside the bounds of its parent range, so long as it's stays within the worksheet grid. + * + * @param row The row number of the cell to be retrieved. Zero-indexed. + * @param column the column number of the cell to be retrieved. Zero-indexed. + */ + getCell(row: number, column: number): Excel.Range; + /** + * + * Gets the range object specified by the address or name. + * + * @param address The address or the name of the range. If not specified, the entire worksheet range is returned. + */ + getRange(address?: string): Excel.Range; + /** + * + * The used range is the smallest range than encompasses any cells that have a value or formatting assigned to them. If the worksheet is blank, this function will return the top left cell. + * + */ + getUsedRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Worksheet; + } + /** + * + * Represents a collection of worksheet objects that are part of the workbook. + */ + class WorksheetCollection extends OfficeExtension.ClientObject { + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Adds a new worksheet to the workbook. The worksheet will be added at the end of existing worksheets. If you wish to activate the newly added worksheet, call ".activate() on it. + * + * @param name The name of the worksheet to be added. If specified, name should be unqiue. If not specified, Excel determines the name of the new worksheet. + */ + add(name?: string): Excel.Worksheet; + /** + * + * Gets the currently active worksheet in the workbook. + * + */ + getActiveWorksheet(): Excel.Worksheet; + /** + * + * Gets a worksheet object using its Name or ID. + * + * @param key The Name or ID of the worksheet. + */ + getItem(key: string): Excel.Worksheet; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.WorksheetCollection; + } + /** + * + * Range represents a set of one or more contiguous cells such as a cell, a row, a column, block of cells, etc. + */ + class Range extends OfficeExtension.ClientObject { + private m_address; + private m_addressLocal; + private m_cellCount; + private m_columnCount; + private m_columnIndex; + private m_format; + private m_formulas; + private m_formulasLocal; + private m_numberFormat; + private m_rowCount; + private m_rowIndex; + private m_text; + private m_valueTypes; + private m_values; + private m_worksheet; + private m__ReferenceId; + /** + * + * Returns a format object, encapsulating the range's font, fill, borders, alignment, and other properties. Read-only. + */ + format: Excel.RangeFormat; + /** + * + * The worksheet containing the current range. Read-only. + */ + worksheet: Excel.Worksheet; + /** + * + * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. Sheet1!A1:B4). Read-only. + */ + address: string; + /** + * + * Represents range reference for the specified range in the language of the user. Read-only. + */ + addressLocal: string; + /** + * + * Number of cells in the range. Read-only. + */ + cellCount: number; + /** + * + * Represents the total number of columns in the range. Read-only. + */ + columnCount: number; + /** + * + * Represents the column number of the first cell in the range. Zero-indexed. Read-only. + */ + columnIndex: number; + /** + * + * Represents the formula in A1-style notation. + */ + formulas: Array>; + /** + * + * Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. + */ + formulasLocal: Array>; + /** + * + * Represents Excel's number format code for the given cell. + */ + numberFormat: Array>; + /** + * + * Returns the total number of rows in the range. Read-only. + */ + rowCount: number; + /** + * + * Returns the row number of the first cell in the range. Zero-indexed. Read-only. + */ + rowIndex: number; + /** + * + * Text values of the specified range. The Text value will not depend on the cell width. The # sign substitution that happens in Excel UI will not affect the text value returned by the API. Read-only. + */ + text: Array>; + /** + * + * Represents the type of data of each cell. Read-only. + */ + valueTypes: Array>; + /** + * + * Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string. + */ + values: Array>; + /** + * + * Clear range values, format, fill, border, etc. + * + * @param applyTo Determines the type of clear action. See Excel.ClearApplyTo for details. + */ + clear(applyTo?: string): void; + /** + * + * Deletes the cells associated with the range. + * + * @param shift Specifies which way to shift the cells. See Excel.DeleteShiftDirection for details. + */ + delete(shift: string): void; + /** + * + * Gets the smallest range object that encompasses the given ranges. For example, the GetBoundingRect of "B2:C5" and "D10:E15" is "B2:E16". + * + * @param anotherRange The range object or address or range name. + */ + getBoundingRect(anotherRange: Excel.Range | string): Excel.Range; + /** + * + * Gets the range object containing the single cell based on row and column numbers. The cell can be outside the bounds of its parent range, so long as it's stays within the worksheet grid. The returned cell is located relative to the top left cell of the range. + * + * @param row Row number of the cell to be retrieved. Zero-indexed. + * @param column Column number of the cell to be retrieved. Zero-indexed. + */ + getCell(row: number, column: number): Excel.Range; + /** + * + * Gets a column contained in the range. + * + * @param column Column number of the range to be retrieved. Zero-indexed. + */ + getColumn(column: number): Excel.Range; + /** + * + * Gets an object that represents the entire column of the range. + * + */ + getEntireColumn(): Excel.Range; + /** + * + * Gets an object that represents the entire row of the range. + * + */ + getEntireRow(): Excel.Range; + /** + * + * Gets the range object that represents the rectangular intersection of the given ranges. + * + * @param anotherRange The range object or range address that will be used to determine the intersection of ranges. + */ + getIntersection(anotherRange: Excel.Range | string): Excel.Range; + /** + * + * Gets the last cell within the range. For example, the last cell of "B2:D5" is "D5". + * + */ + getLastCell(): Excel.Range; + /** + * + * Gets the last column within the range. For example, the last column of "B2:D5" is "D2:D5". + * + */ + getLastColumn(): Excel.Range; + /** + * + * Gets the last row within the range. For example, the last row of "B2:D5" is "B5:D5". + * + */ + getLastRow(): Excel.Range; + /** + * + * Gets an object which represents a range that's offset from the specified range. The dimension of the returned range will match this range. If the resulting range is forced outside the bounds of the worksheet grid, an exception will be thrown. + * + * @param rowOffset The number of rows (positive, negative, or 0) by which the range is to be offset. Positive values are offset downward, and negative values are offset upward. + * @param columnOffset The number of columns (positive, negative, or 0) by which the range is to be offset. Positive values are offset to the right, and negative values are offset to the left. + */ + getOffsetRange(rowOffset: number, columnOffset: number): Excel.Range; + /** + * + * Gets a row contained in the range. + * + * @param row Row number of the range to be retrieved. Zero-indexed. + */ + getRow(row: number): Excel.Range; + /** + * + * Returns the used range of the given range object. + * + */ + getUsedRange(): Excel.Range; + /** + * + * Inserts a cell or a range of cells into the worksheet in place of this range, and shifts the other cells to make space. Returns a new Range object at the now blank space. + * + * @param shift Specifies which way to shift the cells. See Excel.InsertShiftDirection for details. + */ + insert(shift: string): Excel.Range; + /** + * + * Selects the specified range in the Excel UI. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Range; + } + /** + * + * A collection of all the nameditem objects that are part of the workbook. + */ + class NamedItemCollection extends OfficeExtension.ClientObject { + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Gets a nameditem object using its name + * + * @param name nameditem name. + */ + getItem(name: string): Excel.NamedItem; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.NamedItemCollection; + } + /** + * + * Represents a defined name for a range of cells or value. Names can be primitive named objects (as seen in the type below), range object, reference to a range. This object can be used to obtain range object associated with names. + */ + class NamedItem extends OfficeExtension.ClientObject { + private m_name; + private m_type; + private m_value; + private m_visible; + private m__Id; + /** + * + * The name of the object. Read-only. + */ + name: string; + /** + * + * Indicates what type of reference is associated with the name. See Excel.NamedItemType for details. Read-only. + */ + type: string; + /** + * + * Represents the formula that the name is defined to refer to. E.g. =Sheet14!$B$2:$H$12, =4.75, etc. Read-only. + */ + value: any; + /** + * + * Specifies whether the object is visible or not. + */ + visible: boolean; + /** + * + * Returns the range object that is associated with the name. Throws an exception if the named item's type is not a range. + * + */ + getRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.NamedItem; + } + /** + * + * Represents an Office.js binding that is defined in the workbook. + */ + class Binding extends OfficeExtension.ClientObject { + private m_id; + private m_type; + /** + * + * Represents binding identifier. Read-only. + */ + id: string; + /** + * + * Returns the type of the binding. See Excel.BindingType for details. Read-only. + */ + type: string; + /** + * + * Returns the range represented by the binding. Will throw an error if binding is not of the correct type. + * + */ + getRange(): Excel.Range; + /** + * + * Returns the table represented by the binding. Will throw an error if binding is not of the correct type. + * + */ + getTable(): Excel.Table; + /** + * + * Returns the text represented by the binding. Will throw an error if binding is not of the correct type. + * + */ + getText(): OfficeExtension.ClientResult; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Binding; + } + /** + * + * Represents the collection of all the binding objects that are part of the workbook. + */ + class BindingCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of bindings in the collection. Read-only. + */ + count: number; + /** + * + * Gets a binding object by ID. + * + * @param id Id of the binding object to be retrieved. + */ + getItem(id: string): Excel.Binding; + /** + * + * Gets a binding object based on its position in the items array. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Binding; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.BindingCollection; + } + /** + * + * Represents a collection of all the tables that are part of the workbook. + */ + class TableCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of tables in the workbook. Read-only. + */ + count: number; + /** + * + * Create a new table. The range source address determines the worksheet under which the table will be added. If the table cannot be added (e.g., because the address is invalid, or the table would overlap with another table), an error will be thrown. + * + * @param address Address or name of the range object representing the data source. If the address does not contain a sheet name, the currently-active sheet is used. + * @param hasHeaders Boolean value that indicates whether the data being imported has column labels. If the source does not contain headers (i.e,. when this property set to false), Excel will automatically generate header shifting the data down by one row. + */ + add(address: string, hasHeaders: boolean): Excel.Table; + /** + * + * Gets a table by Name or ID. + * + * @param key Name or ID of the table to be retrieved. + */ + getItem(key: number | string): Excel.Table; + /** + * + * Gets a table based on its position in the collection. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Table; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableCollection; + } + /** + * + * Represents an Excel table. + */ + class Table extends OfficeExtension.ClientObject { + private m_columns; + private m_id; + private m_name; + private m_rows; + private m_showHeaders; + private m_showTotals; + private m_style; + /** + * + * Represents a collection of all the columns in the table. Read-only. + */ + columns: Excel.TableColumnCollection; + /** + * + * Represents a collection of all the rows in the table. Read-only. + */ + rows: Excel.TableRowCollection; + /** + * + * Returns a value that uniquely identifies the table in a given workbook. The value of the identifier remains the same even when the table is renamed. Read-only. + */ + id: number; + /** + * + * Name of the table. + */ + name: string; + /** + * + * Indicates whether the header row is visible or not. This value can be set to show or remove the header row. + */ + showHeaders: boolean; + /** + * + * Indicates whether the total row is visible or not. This value can be set to show or remove the total row. + */ + showTotals: boolean; + /** + * + * Constant value that represents the Table style. Possible values are: TableStyleLight1 thru TableStyleLight21, TableStyleMedium1 thru TableStyleMedium28, TableStyleStyleDark1 thru TableStyleStyleDark11. A custom user-defined style present in the workbook can also be specified. + */ + style: string; + /** + * + * Deletes the table. + * + */ + delete(): void; + /** + * + * Gets the range object associated with the data body of the table. + * + */ + getDataBodyRange(): Excel.Range; + /** + * + * Gets the range object associated with header row of the table. + * + */ + getHeaderRowRange(): Excel.Range; + /** + * + * Gets the range object associated with the entire table. + * + */ + getRange(): Excel.Range; + /** + * + * Gets the range object associated with totals row of the table. + * + */ + getTotalRowRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Table; + } + /** + * + * Represents a collection of all the columns that are part of the table. + */ + class TableColumnCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of columns in the table. Read-only. + */ + count: number; + /** + * + * Adds a new column to the table. + * + * @param index Specifies the relative position of the new column. The previous column at this position is shifted to the right. The index value should be equal to or less than the last column's index value, so it cannot be used to append a column at the end of the table. Zero-indexed. + * @param values A 2-dimensional array of unformatted values of the table column. + */ + add(index: number, values?: Array> | boolean | string | number): Excel.TableColumn; + /** + * + * Gets a column object by Name or ID. + * + * @param key Column Name or ID. + */ + getItem(key: number | string): Excel.TableColumn; + /** + * + * Gets a column based on its position in the collection. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.TableColumn; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableColumnCollection; + } + /** + * + * Represents a column in a table. + */ + class TableColumn extends OfficeExtension.ClientObject { + private m_id; + private m_index; + private m_name; + private m_values; + /** + * + * Returns a unique key that identifies the column within the table. Read-only. + */ + id: number; + /** + * + * Returns the index number of the column within the columns collection of the table. Zero-indexed. Read-only. + */ + index: number; + /** + * + * Returns the name of the table column. Read-only. + */ + name: string; + /** + * + * Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string. + */ + values: Array>; + /** + * + * Deletes the column from the table. + * + */ + delete(): void; + /** + * + * Gets the range object associated with the data body of the column. + * + */ + getDataBodyRange(): Excel.Range; + /** + * + * Gets the range object associated with the header row of the column. + * + */ + getHeaderRowRange(): Excel.Range; + /** + * + * Gets the range object associated with the entire column. + * + */ + getRange(): Excel.Range; + /** + * + * Gets the range object associated with the totals row of the column. + * + */ + getTotalRowRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableColumn; + } + /** + * + * Represents a collection of all the rows that are part of the table. + */ + class TableRowCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of rows in the table. Read-only. + */ + count: number; + /** + * + * Adds a new row to the table. + * + * @param index Specifies the relative position of the new row. If null, the addition happens at the end. Any rows below the inserted row are shifted downwards. Zero-indexed. + * @param values A 2-dimensional array of unformatted values of the table row. + */ + add(index?: number, values?: Array> | boolean | string | number): Excel.TableRow; + /** + * + * Gets a row based on its position in the collection. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.TableRow; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableRowCollection; + } + /** + * + * Represents a row in a table. + */ + class TableRow extends OfficeExtension.ClientObject { + private m_index; + private m_values; + /** + * + * Returns the index number of the row within the rows collection of the table. Zero-indexed. Read-only. + */ + index: number; + /** + * + * Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string. + */ + values: Array>; + /** + * + * Deletes the row from the table. + * + */ + delete(): void; + /** + * + * Returns the range object associated with the entire row. + * + */ + getRange(): Excel.Range; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.TableRow; + } + /** + * + * A format object encapsulating the range's font, fill, borders, alignment, and other properties. + */ + class RangeFormat extends OfficeExtension.ClientObject { + private m_borders; + private m_fill; + private m_font; + private m_horizontalAlignment; + private m_verticalAlignment; + private m_wrapText; + /** + * + * Collection of border objects that apply to the overall range selected Read-only. + */ + borders: Excel.RangeBorderCollection; + /** + * + * Returns the fill object defined on the overall range. Read-only. + */ + fill: Excel.RangeFill; + /** + * + * Returns the font object defined on the overall range selected Read-only. + */ + font: Excel.RangeFont; + /** + * + * Represents the horizontal alignment for the specified object. See Excel.HorizontalAlignment for details. + */ + horizontalAlignment: string; + /** + * + * Represents the vertical alignment for the specified object. See Excel.VerticalAlignment for details. + */ + verticalAlignment: string; + /** + * + * Indicates if Excel wraps the text in the object. A null value indicates that the entire range doesn't have uniform wrap setting + */ + wrapText: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeFormat; + } + /** + * + * Represents the background of a range object. + */ + class RangeFill extends OfficeExtension.ClientObject { + private m_color; + /** + * + * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange") + */ + color: string; + /** + * + * Resets the range background. + * + */ + clear(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeFill; + } + /** + * + * Represents the border of an object. + */ + class RangeBorder extends OfficeExtension.ClientObject { + private m_color; + private m_sideIndex; + private m_style; + private m_weight; + /** + * + * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). + */ + color: string; + /** + * + * Constant value that indicates the specific side of the border. See Excel.BorderIndex for details. Read-only. + */ + sideIndex: string; + /** + * + * One of the constants of line style specifying the line style for the border. See Excel.BorderLineStyle for details. + */ + style: string; + /** + * + * Specifies the weight of the border around a range. See Excel.BorderWeight for details. + */ + weight: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeBorder; + } + /** + * + * Represents the border objects that make up range border. + */ + class RangeBorderCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Number of border objects in the collection. Read-only. + */ + count: number; + /** + * + * Gets a border object using its name + * + * @param index Index value of the border object to be retrieved. See Excel.BorderIndex for details. + */ + getItem(index: string): Excel.RangeBorder; + /** + * + * Gets a border object using its index + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.RangeBorder; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeBorderCollection; + } + /** + * + * This object represents the font attributes (font name, font size, color, etc.) for an object. + */ + class RangeFont extends OfficeExtension.ClientObject { + private m_bold; + private m_color; + private m_italic; + private m_name; + private m_size; + private m_underline; + /** + * + * Represents the bold status of font. + */ + bold: boolean; + /** + * + * HTML color code representation of the text color. E.g. #FF0000 represents Red. + */ + color: string; + /** + * + * Represents the italic status of the font. + */ + italic: boolean; + /** + * + * Font name (e.g. "Calibri") + */ + name: string; + /** + * + * Font size. + */ + size: number; + /** + * + * Type of underline applied to the font. See Excel.RangeUnderlineStyle for details. + */ + underline: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.RangeFont; + } + /** + * + * A collection of all the chart objects on a worksheet. + */ + class ChartCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of charts in the worksheet. Read-only. + */ + count: number; + /** + * + * Creates a new chart. + * + * @param type Represents the type of a chart. See Excel.ChartType for details. + * @param sourceData The Range object corresponding to the source data. + * @param seriesBy Specifies the way columns or rows are used as data series on the chart. See Excel.ChartSeriesBy for details. + */ + add(type: string, sourceData: Excel.Range, seriesBy?: string): Excel.Chart; + /** + * + * Gets a chart using its name. If there are multiple charts with the same name, the first one will be returned. + * + * @param name Name of the chart to be retrieved. + */ + getItem(name: string): Excel.Chart; + /** + * + * Gets a chart based on its position in the collection. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.Chart; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartCollection; + } + /** + * + * Represents a chart object in a workbook. + */ + class Chart extends OfficeExtension.ClientObject { + private m_axes; + private m_dataLabels; + private m_format; + private m_height; + private m_left; + private m_legend; + private m_name; + private m_series; + private m_title; + private m_top; + private m_width; + private m__Id; + /** + * + * Represents chart axes. Read-only. + */ + axes: Excel.ChartAxes; + /** + * + * Represents the datalabels on the chart. Read-only. + */ + dataLabels: Excel.ChartDataLabels; + /** + * + * Encapsulates the format properties for the chart area. Read-only. + */ + format: Excel.ChartAreaFormat; + /** + * + * Represents the legend for the chart. Read-only. + */ + legend: Excel.ChartLegend; + /** + * + * Represents either a single series or collection of series in the chart. Read-only. + */ + series: Excel.ChartSeriesCollection; + /** + * + * Represents the title of the specified chart, including the text, visibility, position and formating of the title. Read-only. + */ + title: Excel.ChartTitle; + /** + * + * Represents the height, in points, of the chart object. + */ + height: number; + /** + * + * The distance, in points, from the left side of the chart to the worksheet origin. + */ + left: number; + /** + * + * Represents the name of a chart object. + */ + name: string; + /** + * + * Represents the distance, in points, from the top edge of the object to the top of row 1 (on a worksheet) or the top of the chart area (on a chart). + */ + top: number; + /** + * + * Represents the width, in points, of the chart object. + */ + width: number; + /** + * + * Deletes the chart object. + * + */ + delete(): void; + /** + * + * Resets the source data for the chart. + * + * @param sourceData The Range object corresponding to the source data. + * @param seriesBy Specifies the way columns or rows are used as data series on the chart. Can be one of the following: Auto (default), Rows, Columns. See Excel.ChartSeriesBy for details. + */ + setData(sourceData: Excel.Range, seriesBy?: string): void; + /** + * + * Positions the chart relative to cells on the worksheet. + * + * @param startCell The start cell. This is where the chart will be moved to. The start cell is the top-left or top-right cell, depending on the user's right-to-left display settings. + * @param endCell (Optional) The end cell. If specified, the chart's width and height will be set to fully cover up this cell/range. + */ + setPosition(startCell: Excel.Range | string, endCell?: Excel.Range | string): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.Chart; + } + /** + * + * Encapsulates the format properties for the overall chart area. + */ + class ChartAreaFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_font; + /** + * + * Represents the fill format of an object, which includes background formatting information. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents the font attributes (font name, font size, color, etc.) for the current object. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAreaFormat; + } + /** + * + * Represents a collection of chart series. + */ + class ChartSeriesCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of series in the collection. Read-only. + */ + count: number; + /** + * + * Retrieves a series based on its position in the collection + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.ChartSeries; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartSeriesCollection; + } + /** + * + * Represents a series in a chart. + */ + class ChartSeries extends OfficeExtension.ClientObject { + private m_format; + private m_name; + private m_points; + /** + * + * Represents the formatting of a chart series, which includes fill and line formatting. Read-only. + */ + format: Excel.ChartSeriesFormat; + /** + * + * Represents a collection of all points in the series. Read-only. + */ + points: Excel.ChartPointsCollection; + /** + * + * Represents the name of a series in a chart. + */ + name: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartSeries; + } + /** + * + * encapsulates the format properties for the chart series + */ + class ChartSeriesFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_line; + /** + * + * Represents the fill format of a chart series, which includes background formating information. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents line formatting. Read-only. + */ + line: Excel.ChartLineFormat; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartSeriesFormat; + } + /** + * + * A collection of all the chart points within a series inside a chart. + */ + class ChartPointsCollection extends OfficeExtension.ClientObject { + private m_count; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Returns the number of chart points in the collection. Read-only. + */ + count: number; + /** + * + * Retrieve a point based on its position within the series. + * + * @param index Index value of the object to be retrieved. Zero-indexed. + */ + getItemAt(index: number): Excel.ChartPoint; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartPointsCollection; + } + /** + * + * Represents a point of a series in a chart. + */ + class ChartPoint extends OfficeExtension.ClientObject { + private m_format; + private m_value; + /** + * + * Encapsulates the format properties chart point. Read-only. + */ + format: Excel.ChartPointFormat; + /** + * + * Returns the value of a chart point. Read-only. + */ + value: any; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartPoint; + } + /** + * + * Represents formatting object for chart points. + */ + class ChartPointFormat extends OfficeExtension.ClientObject { + private m_fill; + /** + * + * Represents the fill format of a chart, which includes background formating information. Read-only. + */ + fill: Excel.ChartFill; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartPointFormat; + } + /** + * + * Represents the chart axes. + */ + class ChartAxes extends OfficeExtension.ClientObject { + private m_categoryAxis; + private m_seriesAxis; + private m_valueAxis; + /** + * + * Represents the category axis in a chart. Read-only. + */ + categoryAxis: Excel.ChartAxis; + /** + * + * Represents the series axis of a 3-dimensional chart. Read-only. + */ + seriesAxis: Excel.ChartAxis; + /** + * + * Represents the value axis in an axis. Read-only. + */ + valueAxis: Excel.ChartAxis; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxes; + } + /** + * + * Represents a single axis in a chart. + */ + class ChartAxis extends OfficeExtension.ClientObject { + private m_format; + private m_majorGridlines; + private m_majorUnit; + private m_maximum; + private m_minimum; + private m_minorGridlines; + private m_minorUnit; + private m_title; + /** + * + * Represents the formatting of a chart object, which includes line and font formatting. Read-only. + */ + format: Excel.ChartAxisFormat; + /** + * + * Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. + */ + majorGridlines: Excel.ChartGridlines; + /** + * + * Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. + */ + minorGridlines: Excel.ChartGridlines; + /** + * + * Represents the axis title. Read-only. + */ + title: Excel.ChartAxisTitle; + /** + * + * Represents the interval between two major tick marks. Can be set to a numeric value or an empty string. The returned value is always a number. + */ + majorUnit: any; + /** + * + * Represents the maximum value on the value axis. Can be set to a numeric value or an empty string (for automatic axis values). The returned value is always a number. + */ + maximum: any; + /** + * + * Represents the minimum value on the value axis. Can be set to a numeric value or an empty string (for automatic axis values). The returned value is always a number. + */ + minimum: any; + /** + * + * Represents the interval between two minor tick marks. "Can be set to a numeric value or an empty string (for automatic axis values). The returned value is always a number. + */ + minorUnit: any; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxis; + } + /** + * + * Encapsulates the format properties for the chart axis. + */ + class ChartAxisFormat extends OfficeExtension.ClientObject { + private m_font; + private m_line; + /** + * + * Represents the font attributes (font name, font size, color, etc.) for a chart axis element. Read-only. + */ + font: Excel.ChartFont; + /** + * + * Represents chart line formatting. Read-only. + */ + line: Excel.ChartLineFormat; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxisFormat; + } + /** + * + * Represents the title of a chart axis. + */ + class ChartAxisTitle extends OfficeExtension.ClientObject { + private m_format; + private m_text; + private m_visible; + /** + * + * Represents the formatting of chart axis title. Read-only. + */ + format: Excel.ChartAxisTitleFormat; + /** + * + * Represents the axis title. + */ + text: string; + /** + * + * A boolean that specifies the visibility of an axis title. + */ + visible: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxisTitle; + } + /** + * + * Represents the chart axis title formatting. + */ + class ChartAxisTitleFormat extends OfficeExtension.ClientObject { + private m_font; + /** + * + * Represents the font attributes, such as font name, font size, color, etc. of chart axis title object. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartAxisTitleFormat; + } + /** + * + * Represents a collection of all the data labels on a chart point. + */ + class ChartDataLabels extends OfficeExtension.ClientObject { + private m_format; + private m_position; + private m_separator; + private m_showBubbleSize; + private m_showCategoryName; + private m_showLegendKey; + private m_showPercentage; + private m_showSeriesName; + private m_showValue; + /** + * + * Represents the format of chart data labels, which includes fill and font formatting. Read-only. + */ + format: Excel.ChartDataLabelFormat; + /** + * + * DataLabelPosition value that represents the position of the data label. See Excel.ChartDataLabelPosition for details. + */ + position: string; + /** + * + * String representing the separator used for the data labels on a chart. + */ + separator: string; + /** + * + * Boolean value representing if the data label bubble size is visible or not. + */ + showBubbleSize: boolean; + /** + * + * Boolean value representing if the data label category name is visible or not. + */ + showCategoryName: boolean; + /** + * + * Boolean value representing if the data label legend key is visible or not. + */ + showLegendKey: boolean; + /** + * + * Boolean value representing if the data label percentage is visible or not. + */ + showPercentage: boolean; + /** + * + * Boolean value representing if the data label series name is visible or not. + */ + showSeriesName: boolean; + /** + * + * Boolean value representing if the data label value is visible or not. + */ + showValue: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartDataLabels; + } + /** + * + * Encapsulates the format properties for the chart data labels. + */ + class ChartDataLabelFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_font; + /** + * + * Represents the fill format of the current chart data label. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents the font attributes (font name, font size, color, etc.) for a chart data label. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartDataLabelFormat; + } + /** + * + * Represents major or minor gridlines on a chart axis. + */ + class ChartGridlines extends OfficeExtension.ClientObject { + private m_format; + private m_visible; + /** + * + * Represents the formatting of chart gridlines. Read-only. + */ + format: Excel.ChartGridlinesFormat; + /** + * + * Boolean value representing if the axis gridlines are visible or not. + */ + visible: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartGridlines; + } + /** + * + * Encapsulates the format properties for chart gridlines. + */ + class ChartGridlinesFormat extends OfficeExtension.ClientObject { + private m_line; + /** + * + * Represents chart line formatting. Read-only. + */ + line: Excel.ChartLineFormat; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartGridlinesFormat; + } + /** + * + * Represents the legend in a chart. + */ + class ChartLegend extends OfficeExtension.ClientObject { + private m_format; + private m_overlay; + private m_position; + private m_visible; + /** + * + * Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. + */ + format: Excel.ChartLegendFormat; + /** + * + * Boolean value for whether the chart legend should overlap with the main body of the chart. + */ + overlay: boolean; + /** + * + * Represents the position of the legend on the chart. See Excel.ChartLegendPosition for details. + */ + position: string; + /** + * + * A boolean value the represents the visibility of a ChartLegend object. + */ + visible: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartLegend; + } + /** + * + * Encapsulates the format properties of a chart legend. + */ + class ChartLegendFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_font; + /** + * + * Represents the fill format of an object, which includes background formating information. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents the font attributes such as font name, font size, color, etc. of a chart legend. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartLegendFormat; + } + /** + * + * Represents a chart title object of a chart. + */ + class ChartTitle extends OfficeExtension.ClientObject { + private m_format; + private m_overlay; + private m_text; + private m_visible; + /** + * + * Represents the formatting of a chart title, which includes fill and font formatting. Read-only. + */ + format: Excel.ChartTitleFormat; + /** + * + * Boolean value representing if the chart title will overlay the chart or not. + */ + overlay: boolean; + /** + * + * Represents the title text of a chart. + */ + text: string; + /** + * + * A boolean value the represents the visibility of a chart title object. + */ + visible: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartTitle; + } + /** + * + * Provides access to the office art formatting for chart title. + */ + class ChartTitleFormat extends OfficeExtension.ClientObject { + private m_fill; + private m_font; + /** + * + * Represents the fill format of an object, which includes background formating information. Read-only. + */ + fill: Excel.ChartFill; + /** + * + * Represents the font attributes (font name, font size, color, etc.) for an object. Read-only. + */ + font: Excel.ChartFont; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartTitleFormat; + } + /** + * + * Represents the fill formatting for a chart element. + */ + class ChartFill extends OfficeExtension.ClientObject { + /** + * + * Clear the fill color of a chart element. + * + */ + clear(): void; + /** + * + * Sets the fill formatting of a chart element to a uniform color. + * + * @param color HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). + */ + setSolidColor(color: string): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartFill; + } + /** + * + * Enapsulates the formatting options for line elements. + */ + class ChartLineFormat extends OfficeExtension.ClientObject { + private m_color; + /** + * + * HTML color code representing the color of lines in the chart. + */ + color: string; + /** + * + * Clear the line format of a chart element. + * + */ + clear(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartLineFormat; + } + /** + * + * This object represents the font attributes (font name, font size, color, etc.) for a chart object. + */ + class ChartFont extends OfficeExtension.ClientObject { + private m_bold; + private m_color; + private m_italic; + private m_name; + private m_size; + private m_underline; + /** + * + * Represents the bold status of font. + */ + bold: boolean; + /** + * + * HTML color code representation of the text color. E.g. #FF0000 represents Red. + */ + color: string; + /** + * + * Represents the italic status of the font. + */ + italic: boolean; + /** + * + * Font name (e.g. "Calibri") + */ + name: string; + /** + * + * Size of the font (e.g. 11) + */ + size: number; + /** + * + * Type of underline applied to the font. See Excel.ChartUnderlineStyle for details. + */ + underline: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Excel.ChartFont; + } + module BindingType { + var range: string; + var table: string; + var text: string; + } + module BorderIndex { + var edgeTop: string; + var edgeBottom: string; + var edgeLeft: string; + var edgeRight: string; + var insideVertical: string; + var insideHorizontal: string; + var diagonalDown: string; + var diagonalUp: string; + } + module BorderLineStyle { + var none: string; + var continuous: string; + var dash: string; + var dashDot: string; + var dashDotDot: string; + var dot: string; + var double: string; + var slantDashDot: string; + } + module BorderWeight { + var hairline: string; + var thin: string; + var medium: string; + var thick: string; + } + module CalculationMode { + var automatic: string; + var automaticExceptTables: string; + var manual: string; + } + module CalculationType { + var recalculate: string; + var full: string; + var fullRebuild: string; + } + module ClearApplyTo { + var all: string; + var formats: string; + var contents: string; + } + module ChartDataLabelPosition { + var invalid: string; + var none: string; + var center: string; + var insideEnd: string; + var insideBase: string; + var outsideEnd: string; + var left: string; + var right: string; + var top: string; + var bottom: string; + var bestFit: string; + var callout: string; + } + module ChartLegendPosition { + var invalid: string; + var top: string; + var bottom: string; + var left: string; + var right: string; + var corner: string; + var custom: string; + } + module ChartSeriesBy { + var auto: string; + var columns: string; + var rows: string; + } + module ChartType { + var invalid: string; + var columnClustered: string; + var columnStacked: string; + var columnStacked100: string; + var _3DColumnClustered: string; + var _3DColumnStacked: string; + var _3DColumnStacked100: string; + var barClustered: string; + var barStacked: string; + var barStacked100: string; + var _3DBarClustered: string; + var _3DBarStacked: string; + var _3DBarStacked100: string; + var lineStacked: string; + var lineStacked100: string; + var lineMarkers: string; + var lineMarkersStacked: string; + var lineMarkersStacked100: string; + var pieOfPie: string; + var pieExploded: string; + var _3DPieExploded: string; + var barOfPie: string; + var xyscatterSmooth: string; + var xyscatterSmoothNoMarkers: string; + var xyscatterLines: string; + var xyscatterLinesNoMarkers: string; + var areaStacked: string; + var areaStacked100: string; + var _3DAreaStacked: string; + var _3DAreaStacked100: string; + var doughnutExploded: string; + var radarMarkers: string; + var radarFilled: string; + var surface: string; + var surfaceWireframe: string; + var surfaceTopView: string; + var surfaceTopViewWireframe: string; + var bubble: string; + var bubble3DEffect: string; + var stockHLC: string; + var stockOHLC: string; + var stockVHLC: string; + var stockVOHLC: string; + var cylinderColClustered: string; + var cylinderColStacked: string; + var cylinderColStacked100: string; + var cylinderBarClustered: string; + var cylinderBarStacked: string; + var cylinderBarStacked100: string; + var cylinderCol: string; + var coneColClustered: string; + var coneColStacked: string; + var coneColStacked100: string; + var coneBarClustered: string; + var coneBarStacked: string; + var coneBarStacked100: string; + var coneCol: string; + var pyramidColClustered: string; + var pyramidColStacked: string; + var pyramidColStacked100: string; + var pyramidBarClustered: string; + var pyramidBarStacked: string; + var pyramidBarStacked100: string; + var pyramidCol: string; + var _3DColumn: string; + var line: string; + var _3DLine: string; + var _3DPie: string; + var pie: string; + var xyscatter: string; + var _3DArea: string; + var area: string; + var doughnut: string; + var radar: string; + } + module ChartUnderlineStyle { + var none: string; + var single: string; + } + module DeleteShiftDirection { + var up: string; + var left: string; + } + module HorizontalAlignment { + var general: string; + var left: string; + var center: string; + var right: string; + var fill: string; + var justify: string; + var centerAcrossSelection: string; + var distributed: string; + } + module InsertShiftDirection { + var down: string; + var right: string; + } + module NamedItemType { + var string: string; + var integer: string; + var double: string; + var boolean: string; + var range: string; + } + module RangeUnderlineStyle { + var none: string; + var single: string; + var double: string; + var singleAccountant: string; + var doubleAccountant: string; + } + module SheetVisibility { + var visible: string; + var hidden: string; + var veryHidden: string; + } + module RangeValueType { + var unknown: string; + var empty: string; + var string: string; + var integer: string; + var double: string; + var boolean: string; + var error: string; + } + module VerticalAlignment { + var top: string; + var center: string; + var bottom: string; + var justify: string; + var distributed: string; + } + module ErrorCodes { + var accessDenied: string; + var generalException: string; + var insertDeleteConflict: string; + var invalidArgument: string; + var invalidBinding: string; + var invalidOperation: string; + var invalidReference: string; + var invalidSelection: string; + var itemAlreadyExists: string; + var itemNotFound: string; + var notImplemented: string; + var unsupportedOperation: string; + } +} +declare module Excel { + /** + * The RequestContext object facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the request context is required to get access to the Excel object model from the add-in. + */ + class RequestContext extends OfficeExtension.ClientRequestContext { + private m_workbook; + constructor(url?: string); + workbook: Workbook; + } + /** + * Executes a batch script that performs actions on the Excel object model. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * @param batch - A function that takes in an Excel.RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the request context is required to get access to the Excel object model from the add-in. + */ + function run(batch: (context: Excel.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; +} + +declare module Word { + /** + * + * Represents the body of a document or a section. + */ + class Body extends OfficeExtension.ClientObject { + private m_contentControls; + private m_font; + private m_inlinePictures; + private m_paragraphs; + private m_parentContentControl; + private m_style; + private m_text; + private m__ReferenceId; + /** + * + * Gets the collection of rich text content control objects that are in the body. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the text format of the body. Use this to get and set font name, size, color, and other properties. Read-only. + */ + font: Word.Font; + /** + * + * Gets the collection of inlinePicture objects that are in the body. The collection does not include floating images. Read-only. + */ + inlinePictures: Word.InlinePictureCollection; + /** + * + * Gets the collection of paragraph objects that are in the body. Read-only. + */ + paragraphs: Word.ParagraphCollection; + /** + * + * Gets the content control that contains the body. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets the style used for the body. This is the name of the pre-installed or custom style. + */ + style: string; + /** + * + * Gets the text of the body. Use the insertText method to insert text. Read-only. + */ + text: string; + /** + * + * Clears the contents of the body object. The user can perform the undo operation on the cleared content. + * + */ + clear(): void; + /** + * + * Gets the HTML representation of the body object. + * + */ + getHtml(): OfficeExtension.ClientResult; + /** + * + * Gets the OOXML (Office Open XML) representation of the body object. + * + */ + getOoxml(): OfficeExtension.ClientResult; + /** + * + * Inserts a break at the specified location. The insertLocation value can be 'Start' or 'End'. + * + * @param breakType Required. The break type to add to the body. + * @param insertLocation Required. The value can be 'Start' or 'End'. + */ + insertBreak(breakType: string, insertLocation: string): void; + /** + * + * Wraps the body object with a Rich Text content control. + * + */ + insertContentControl(): Word.ContentControl; + /** + * + * Inserts a document into the body at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param base64File Required. The base64 encoded file contents to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertFileFromBase64(base64File: string, insertLocation: string): Word.Range; + /** + * + * Inserts HTML at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param html Required. The HTML to be inserted in the document. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertHtml(html: string, insertLocation: string): Word.Range; + /** + * + * Inserts OOXML at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param ooxml Required. The OOXML to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertOoxml(ooxml: string, insertLocation: string): Word.Range; + /** + * + * Inserts a paragraph at the specified location. The insertLocation value can be 'Start' or 'End'. + * + * @param paragraphText Required. The paragraph text to be inserted. + * @param insertLocation Required. The value can be 'Start' or 'End'. + */ + insertParagraph(paragraphText: string, insertLocation: string): Word.Paragraph; + /** + * + * Inserts text into the body at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param text Required. Text to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertText(text: string, insertLocation: string): Word.Range; + /** + * + * Performs a search with the specified searchOptions on the scope of the body object. The search results are a collection of range objects. + * + * @param searchText Required. The search text. + * @param searchOptions Optional. Options for the search. + */ + search(searchText: string, searchOptions?: Word.SearchOptions | { + ignorePunct?: boolean; + ignoreSpace?: boolean; + matchCase?: boolean; + matchPrefix?: boolean; + matchSoundsLike?: boolean; + matchSuffix?: boolean; + matchWholeWord?: boolean; + matchWildCards?: boolean; + }): Word.SearchResultCollection; + /** + * + * Selects the body and navigates the Word UI to it. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Body; + } + /** + * + * Represents a content control. Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Individual content controls may contain contents such as images, tables, or paragraphs of formatted text. Currently, only rich text content controls are supported. + */ + class ContentControl extends OfficeExtension.ClientObject { + private m_appearance; + private m_cannotDelete; + private m_cannotEdit; + private m_color; + private m_contentControls; + private m_font; + private m_id; + private m_inlinePictures; + private m_paragraphs; + private m_parentContentControl; + private m_placeholderText; + private m_removeWhenEdited; + private m_style; + private m_tag; + private m_text; + private m_title; + private m_type; + private m__ReferenceId; + /** + * + * Gets the collection of content control objects in the content control. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the text format of the content control. Use this to get and set font name, size, color, and other properties. Read-only. + */ + font: Word.Font; + /** + * + * Gets the collection of inlinePicture objects in the content control. The collection does not include floating images. Read-only. + */ + inlinePictures: Word.InlinePictureCollection; + /** + * + * Get the collection of paragraph objects in the content control. Read-only. + */ + paragraphs: Word.ParagraphCollection; + /** + * + * Gets the content control that contains the content control. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets the appearance of the content control. The value can be 'boundingBox', 'tags' or 'hidden'. + */ + appearance: string; + /** + * + * Gets or sets a value that indicates whether the user can delete the content control. Mutually exclusive with removeWhenEdited. + */ + cannotDelete: boolean; + /** + * + * Gets or sets a value that indicates whether the user can edit the contents of the content control. + */ + cannotEdit: boolean; + /** + * + * Gets or sets the color of the content control. Color is set in "#RRGGBB" format or by using the color name. + */ + color: string; + /** + * + * Gets an integer that represents the content control identifier. Read-only. + */ + id: number; + /** + * + * Gets or sets the placeholder text of the content control. Dimmed text will be displayed when the content control is empty. + */ + placeholderText: string; + /** + * + * Gets or sets a value that indicates whether the content control is removed after it is edited. Mutually exclusive with cannotDelete. + */ + removeWhenEdited: boolean; + /** + * + * Gets or sets the style used for the content control. This is the name of the pre-installed or custom style. + */ + style: string; + /** + * + * Gets or sets a tag to identify a content control. + */ + tag: string; + /** + * + * Gets the text of the content control. Read-only. + */ + text: string; + /** + * + * Gets or sets the title for a content control. + */ + title: string; + /** + * + * Gets the content control type. Only rich text content controls are supported currently. Read-only. + */ + type: string; + /** + * + * Clears the contents of the content control. The user can perform the undo operation on the cleared content. + * + */ + clear(): void; + /** + * + * Deletes the content control and its content. If keepContent is set to true, the content is not deleted. + * + * @param keepContent Required. Indicates whether the content should be deleted with the content control. If keepContent is set to true, the content is not deleted. + */ + delete(keepContent: boolean): void; + /** + * + * Gets the HTML representation of the content control object. + * + */ + getHtml(): OfficeExtension.ClientResult; + /** + * + * Gets the Office Open XML (OOXML) representation of the content control object. + * + */ + getOoxml(): OfficeExtension.ClientResult; + /** + * + * Inserts a break at the specified location. The insertLocation value can be 'Before', 'After', 'Start' or 'End'. + * + * @param breakType Required. Type of break (breakType.md) + * @param insertLocation Required. The value can be 'Before', 'After', 'Start' or 'End'. + */ + insertBreak(breakType: string, insertLocation: string): void; + /** + * + * Inserts a document into the current content control at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param base64File Required. Base64 encoded contents of the file to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertFileFromBase64(base64File: string, insertLocation: string): Word.Range; + /** + * + * Inserts HTML into the content control at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param html Required. The HTML to be inserted in to the content control. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertHtml(html: string, insertLocation: string): Word.Range; + /** + * + * Inserts OOXML into the content control at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param ooxml Required. The OOXML to be inserted in to the content control. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertOoxml(ooxml: string, insertLocation: string): Word.Range; + /** + * + * Inserts a paragraph at the specified location. The insertLocation value can be 'Before', 'After', 'Start' or 'End'. + * + * @param paragraphText Required. The paragrph text to be inserted. + * @param insertLocation Required. The value can be 'Before', 'After', 'Start' or 'End'. + */ + insertParagraph(paragraphText: string, insertLocation: string): Word.Paragraph; + /** + * + * Inserts text into the content control at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param text Required. The text to be inserted in to the content control. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertText(text: string, insertLocation: string): Word.Range; + /** + * + * Performs a search with the specified searchOptions on the scope of the content control object. The search results are a collection of range objects. + * + * @param searchText Required. The search text. + * @param searchOptions Optional. Options for the search. + */ + search(searchText: string, searchOptions?: Word.SearchOptions | { + ignorePunct?: boolean; + ignoreSpace?: boolean; + matchCase?: boolean; + matchPrefix?: boolean; + matchSoundsLike?: boolean; + matchSuffix?: boolean; + matchWholeWord?: boolean; + matchWildCards?: boolean; + }): Word.SearchResultCollection; + /** + * + * Selects the content control. This causes Word to scroll to the selection. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.ContentControl; + } + /** + * + * Contains a collection of ContentControl objects. Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Individual content controls may contain contents such as images, tables, or paragraphs of formatted text. Currently, only rich text content controls are supported. + */ + class ContentControlCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * + * Gets a content control by its identifier. + * + * @param id Required. A content control identifier. + */ + getById(id: number): Word.ContentControl; + /** + * + * Gets the content controls that have the specified tag. + * + * @param tag Required. A tag set on a content control. + */ + getByTag(tag: string): Word.ContentControlCollection; + /** + * + * Gets the content controls that have the specified title. + * + * @param title Required. The title of a content control. + */ + getByTitle(title: string): Word.ContentControlCollection; + /** + * + * Gets a content control by its index in the collection. + * + * @param index The index + */ + getItem(index: number): Word.ContentControl; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.ContentControlCollection; + } + /** + * + * The Document object is the top level object. A Document object contains one or more sections, content controls, and the body that contains the contents of the document. + */ + class Document extends OfficeExtension.ClientObject { + private m_body; + private m_contentControls; + private m_saved; + private m_sections; + /** + * + * Gets the body of the document. The body is the text that excludes headers, footers, footnotes, textboxes, etc.. Read-only. + */ + body: Word.Body; + /** + * + * Gets the collection of content control objects that are in the current document. This includes content controls in the body of the document, headers, footers, textboxes, etc.. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the collection of section objects that are in the document. Read-only. + */ + sections: Word.SectionCollection; + /** + * + * Indicates whether the changes in the document have been saved. A value of true indicates that the document hasn't changed since it was saved. Read-only. + */ + saved: boolean; + /** + * + * Gets the current selection of the document. Multiple selections are not supported. + * + */ + getSelection(): Word.Range; + /** + * + * Saves the document. This will use the Word default file naming convention if the document has not been saved before. + * + */ + save(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Document; + } + /** + * + * Represents a font. + */ + class Font extends OfficeExtension.ClientObject { + private m_bold; + private m_color; + private m_doubleStrikeThrough; + private m_highlightColor; + private m_italic; + private m_name; + private m_size; + private m_strikeThrough; + private m_subscript; + private m_superscript; + private m_underline; + private m__ReferenceId; + /** + * + * Gets or sets a value that indicates whether the font is bold. True if the font is formatted as bold, otherwise, false. + */ + bold: boolean; + /** + * + * Gets or sets the color for the specified font. You can provide the value in the "#RRGGBB" format or the color name. + */ + color: string; + /** + * + * Gets or sets a value that indicates whether the font has a double strike through. True if the font is formatted as double strikethrough text, otherwise, false. + */ + doubleStrikeThrough: boolean; + /** + * + * Gets or sets the highlight color for the specified font. You can provide the value as either in the "#RRGGBB" format or the color name. + */ + highlightColor: string; + /** + * + * Gets or sets a value that indicates whether the font is italicized. True if the font is italicized, otherwise, false. + */ + italic: boolean; + /** + * + * Gets or sets a value that represents the name of the font. + */ + name: string; + /** + * + * Gets or sets a value that represents the font size in points. + */ + size: number; + /** + * + * Gets or sets a value that indicates whether the font has a strike through. True if the font is formatted as strikethrough text, otherwise, false. + */ + strikeThrough: boolean; + /** + * + * Gets or sets a value that indicates whether the font is a subscript. True if the font is formatted as subscript, otherwise, false. + */ + subscript: boolean; + /** + * + * Gets or sets a value that indicates whether the font is a superscript. True if the font is formatted as superscript, otherwise, false. + */ + superscript: boolean; + /** + * + * Gets or sets a value that indicates the font's underline type. 'None' if the font is not underlined. + */ + underline: string; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Font; + } + /** + * + * Represents an inline picture. + */ + class InlinePicture extends OfficeExtension.ClientObject { + private m_altTextDescription; + private m_altTextTitle; + private m_height; + private m_hyperlink; + private m_lockAspectRatio; + private m_parentContentControl; + private m_width; + private m__Id; + private m__ReferenceId; + /** + * + * Gets the content control that contains the inline image. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets a string that represents the alternative text associated with the inline image + */ + altTextDescription: string; + /** + * + * Gets or sets a string that contains the title for the inline image. + */ + altTextTitle: string; + /** + * + * Gets or sets a number that describes the height of the inline image. + */ + height: number; + /** + * + * Gets or sets the hyperlink associated with the inline image. + */ + hyperlink: string; + /** + * + * Gets or sets a value that indicates whether the inline image retains its original proportions when you resize it. + */ + lockAspectRatio: boolean; + /** + * + * Gets or sets a number that describes the width of the inline image. + */ + width: number; + /** + * + * Gets the base64 encoded string representation of the inline image. + * + */ + getBase64ImageSrc(): OfficeExtension.ClientResult; + /** + * + * Wraps the inline picture with a rich text content control. + * + */ + insertContentControl(): Word.ContentControl; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.InlinePicture; + } + /** + * + * Contains a collection of [inlinePicture](inlinePicture.md) objects. + */ + class InlinePictureCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.InlinePictureCollection; + } + /** + * + * Represents a single paragraph in a selection, range, content control, or document body. + */ + class Paragraph extends OfficeExtension.ClientObject { + private m_alignment; + private m_contentControls; + private m_firstLineIndent; + private m_font; + private m_inlinePictures; + private m_leftIndent; + private m_lineSpacing; + private m_lineUnitAfter; + private m_lineUnitBefore; + private m_outlineLevel; + private m_parentContentControl; + private m_rightIndent; + private m_spaceAfter; + private m_spaceBefore; + private m_style; + private m_text; + private m__Id; + private m__ReferenceId; + /** + * + * Gets the collection of content control objects that are in the paragraph. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the text format of the paragraph. Use this to get and set font name, size, color, and other properties. Read-only. + */ + font: Word.Font; + /** + * + * Gets the collection of inlinePicture objects that are in the paragraph. The collection does not include floating images. Read-only. + */ + inlinePictures: Word.InlinePictureCollection; + /** + * + * Gets the content control that contains the paragraph. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets the alignment for a paragraph. The value can be "left", "centered", "right", or "justified". + */ + alignment: string; + /** + * + * Gets or sets the value, in points, for a first line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent. + */ + firstLineIndent: number; + /** + * + * Gets or sets the left indent value, in points, for the paragraph. + */ + leftIndent: number; + /** + * + * Gets or sets the line spacing, in points, for the specified paragraph. In the Word UI, this value is divided by 12. + */ + lineSpacing: number; + /** + * + * Gets or sets the amount of spacing, in grid lines. after the paragraph. + */ + lineUnitAfter: number; + /** + * + * Gets or sets the amount of spacing, in grid lines, before the paragraph. + */ + lineUnitBefore: number; + /** + * + * Gets or sets the outline level for the paragraph. + */ + outlineLevel: number; + /** + * + * Gets or sets the right indent value, in points, for the paragraph. + */ + rightIndent: number; + /** + * + * Gets or sets the spacing, in points, after the paragraph. + */ + spaceAfter: number; + /** + * + * Gets or sets the spacing, in points, before the paragraph. + */ + spaceBefore: number; + /** + * + * Gets or sets the style used for the paragraph. This is the name of the pre-installed or custom style. + */ + style: string; + /** + * + * Gets the text of the paragraph. Read-only. + */ + text: string; + /** + * + * Clears the contents of the paragraph object. The user can perform the undo operation on the cleared content. + * + */ + clear(): void; + /** + * + * Deletes the paragraph and its content from the document. + * + */ + delete(): void; + /** + * + * Gets the HTML representation of the paragraph object. + * + */ + getHtml(): OfficeExtension.ClientResult; + /** + * + * Gets the Office Open XML (OOXML) representation of the paragraph object. + * + */ + getOoxml(): OfficeExtension.ClientResult; + /** + * + * Inserts a break at the specified location. The insertLocation value can be 'Start' or 'End'. + * + * @param breakType Required. The break type to add to the document. + * @param insertLocation Required. The value can be 'Before' or 'After'. + */ + insertBreak(breakType: string, insertLocation: string): void; + /** + * + * Wraps the paragraph object with a rich text content control. + * + */ + insertContentControl(): Word.ContentControl; + /** + * + * Inserts a document into the current paragraph at the specified location. The insertLocation value can be 'Start' or 'End'. + * + * @param base64File Required. The file base64 encoded file contents to be inserted. + * @param insertLocation Required. The value can be 'Start' or 'End'. + */ + insertFileFromBase64(base64File: string, insertLocation: string): Word.Range; + /** + * + * Inserts HTML into the paragraph at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param html Required. The HTML to be inserted in the paragraph. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertHtml(html: string, insertLocation: string): Word.Range; + /** + * + * Inserts a picture into the paragraph at the specified location. The insertLocation value can be 'Before', 'After', 'Start' or 'End'. + * + * @param base64EncodedImage Required. The HTML to be inserted in the paragraph. + * @param insertLocation Required. The value can be 'Before', 'After', 'Start' or 'End'. + */ + insertInlinePictureFromBase64(base64EncodedImage: string, insertLocation: string): Word.InlinePicture; + /** + * + * Inserts OOXML into the paragraph at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param ooxml Required. The OOXML to be inserted in the paragraph. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertOoxml(ooxml: string, insertLocation: string): Word.Range; + /** + * + * Inserts a paragraph at the specified location. The insertLocation value can be 'Before' or 'After'. + * + * @param paragraphText Required. The paragraph text to be inserted. + * @param insertLocation Required. The value can be 'Before' or 'After'. + */ + insertParagraph(paragraphText: string, insertLocation: string): Word.Paragraph; + /** + * + * Inserts text into the paragraph at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param text Required. Text to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertText(text: string, insertLocation: string): Word.Range; + /** + * + * Performs a search with the specified searchOptions on the scope of the paragraph object. The search results are a collection of range objects. + * + * @param searchText Required. The search text. + * @param searchOptions Optional. Options for the search. + */ + search(searchText: string, searchOptions?: Word.SearchOptions | { + ignorePunct?: boolean; + ignoreSpace?: boolean; + matchCase?: boolean; + matchPrefix?: boolean; + matchSoundsLike?: boolean; + matchSuffix?: boolean; + matchWholeWord?: boolean; + matchWildCards?: boolean; + }): Word.SearchResultCollection; + /** + * + * Selects and navigates the Word UI to the paragraph. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Paragraph; + } + /** + * + * Contains a collection of [paragraph](paragraph.md) objects. + */ + class ParagraphCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.ParagraphCollection; + } + /** + * + * Represents a contiguous area in a document. + */ + class Range extends OfficeExtension.ClientObject { + private m_contentControls; + private m_font; + private m_paragraphs; + private m_parentContentControl; + private m_style; + private m_text; + private m__Id; + private m__ReferenceId; + /** + * + * Gets the collection of content control objects that are in the range. Read-only. + */ + contentControls: Word.ContentControlCollection; + /** + * + * Gets the text format of the range. Use this to get and set font name, size, color, and other properties. Read-only. + */ + font: Word.Font; + /** + * + * Gets the collection of paragraph objects that are in the range. Read-only. + */ + paragraphs: Word.ParagraphCollection; + /** + * + * Gets the content control that contains the range. Returns null if there isn't a parent content control. Read-only. + */ + parentContentControl: Word.ContentControl; + /** + * + * Gets or sets the style used for the range. This is the name of the pre-installed or custom style. + */ + style: string; + /** + * + * Gets the text of the range. Read-only. + */ + text: string; + /** + * + * Clears the contents of the range object. The user can perform the undo operation on the cleared content. + * + */ + clear(): void; + /** + * + * Deletes the range and its content from the document. + * + */ + delete(): void; + /** + * + * Gets the HTML representation of the range object. + * + */ + getHtml(): OfficeExtension.ClientResult; + /** + * + * Gets the OOXML representation of the range object. + * + */ + getOoxml(): OfficeExtension.ClientResult; + /** + * + * Inserts a break at the specified location. The insertLocation value can be 'Replace', 'Before' or 'After'. + * + * @param breakType Required. The break type to add to the range. + * @param insertLocation Required. The value can be 'Replace', 'Before' or 'After'. + */ + insertBreak(breakType: string, insertLocation: string): void; + /** + * + * Wraps the range object with a rich text content control. + * + */ + insertContentControl(): Word.ContentControl; + /** + * + * Inserts a document into the range at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param base64File Required. The file base64 encoded file contents to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertFileFromBase64(base64File: string, insertLocation: string): Word.Range; + /** + * + * Inserts HTML into the range at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param html Required. The HTML to be inserted in the range. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertHtml(html: string, insertLocation: string): Word.Range; + /** + * + * Inserts OOXML into the range at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param ooxml Required. The OOXML to be inserted in the range. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertOoxml(ooxml: string, insertLocation: string): Word.Range; + /** + * + * Inserts a paragraph into the range at the specified location. The insertLocation value can be 'Before' or 'After'. + * + * @param paragraphText Required. The paragraph text to be inserted. + * @param insertLocation Required. The value can be 'Before' or 'After'. + */ + insertParagraph(paragraphText: string, insertLocation: string): Word.Paragraph; + /** + * + * Inserts text into the range at the specified location. The insertLocation value can be 'Replace', 'Start' or 'End'. + * + * @param text Required. Text to be inserted. + * @param insertLocation Required. The value can be 'Replace', 'Start' or 'End'. + */ + insertText(text: string, insertLocation: string): Word.Range; + /** + * + * Performs a search with the specified searchOptions on the scope of the range object. The search results are a collection of range objects. + * + * @param searchText Required. The search text. + * @param searchOptions Optional. Options for the search. + */ + search(searchText: string, searchOptions?: Word.SearchOptions | { + ignorePunct?: boolean; + ignoreSpace?: boolean; + matchCase?: boolean; + matchPrefix?: boolean; + matchSoundsLike?: boolean; + matchSuffix?: boolean; + matchWholeWord?: boolean; + matchWildCards?: boolean; + }): Word.SearchResultCollection; + /** + * + * Selects and navigates the Word UI to the range. + * + */ + select(): void; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Range; + } + /** + * + * Specifies the options to be included in a search operation. + */ + class SearchOptions extends OfficeExtension.ClientObject { + private m_ignorePunct; + private m_ignoreSpace; + private m_matchCase; + private m_matchPrefix; + private m_matchSoundsLike; + private m_matchSuffix; + private m_matchWholeWord; + private m_matchWildCards; + /** + * + * Gets or sets a value that indicates whether to ignore all punctuation characters between words. Corresponds to the Ignore punctuation check box in the Find and Replace dialog box. + */ + ignorePunct: boolean; + /** + * + * Gets or sets a value that indicates whether to ignore all white space between words. Corresponds to the Ignore white-space characters check box in the Find and Replace dialog box. + */ + ignoreSpace: boolean; + /** + * + * Gets or sets a value that indicates whether to perform a case sensitive search. Corresponds to the Match case check box in the Find and Replace dialog box (Edit menu). + */ + matchCase: boolean; + /** + * + * Gets or sets a value that indicates whether to match words that begin with the search string. Corresponds to the Match prefix check box in the Find and Replace dialog box. + */ + matchPrefix: boolean; + /** + * + * Gets or sets a value that indicates whether to find words that sound similar to the search string. Corresponds to the Sounds like check box in the Find and Replace dialog box + */ + matchSoundsLike: boolean; + /** + * + * Gets or sets a value that indicates whether to match words that end with the search string. Corresponds to the Match suffix check box in the Find and Replace dialog box. + */ + matchSuffix: boolean; + /** + * + * Gets or sets a value that indicates whether to find operation only entire words, not text that is part of a larger word. Corresponds to the Find whole words only check box in the Find and Replace dialog box. + */ + matchWholeWord: boolean; + /** + * + * Gets or sets a value that indicates whether the search will be performed using special search operators. Corresponds to the Use wildcards check box in the Find and Replace dialog box. + */ + matchWildCards: boolean; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.SearchOptions; + /** + * Create a new instance of Word.SearchOptions object + */ + static newObject(context: OfficeExtension.ClientRequestContext): Word.SearchOptions; + } + /** + * + * Contains a collection of [range](range.md) objects as a result of a search operation. + */ + class SearchResultCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.SearchResultCollection; + } + /** + * + * Represents a section in a Word document. + */ + class Section extends OfficeExtension.ClientObject { + private m_body; + private m__Id; + private m__ReferenceId; + /** + * + * Gets the body of the section. This does not include the header/footer and other section metadata. Read-only. + */ + body: Word.Body; + /** + * + * Gets one of the section's footers. + * + * @param type Required. The type of footer to return. This value can be: 'primary', 'firstPage' or 'evenPages'. + */ + getFooter(type: string): Word.Body; + /** + * + * Gets one of the section's headers. + * + * @param type Required. The type of header to return. This value can be: 'primary', 'firstPage' or 'evenPages'. + */ + getHeader(type: string): Word.Body; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.Section; + } + /** + * + * Contains the collection of the document's [section](section.md) objects. + */ + class SectionCollection extends OfficeExtension.ClientObject { + private m__ReferenceId; + private m__items; + /** Gets the loaded child items in this collection. */ + items: Array; + /** + * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + */ + load(option?: string | string[] | OfficeExtension.LoadOption): Word.SectionCollection; + } + /** + * + * ContentControl types + */ + module ContentControlType { + var richText: string; + } + /** + * + * ContentControl appearance + */ + module ContentControlAppearance { + var boundingBox: string; + var tags: string; + var hidden: string; + } + /** + * + * Underline types + */ + module UnderlineType { + var none: string; + var single: string; + var word: string; + var double: string; + var dotted: string; + var hidden: string; + var thick: string; + var dashLine: string; + var dotLine: string; + var dotDashLine: string; + var twoDotDashLine: string; + var wave: string; + } + module BreakType { + var page: string; + var column: string; + var next: string; + var sectionContinuous: string; + var sectionEven: string; + var sectionOdd: string; + var line: string; + var lineClearLeft: string; + var lineClearRight: string; + var textWrapping: string; + } + module InsertLocation { + var before: string; + var after: string; + var start: string; + var end: string; + var replace: string; + } + module Alignment { + var unknown: string; + var left: string; + var centered: string; + var right: string; + var justified: string; + } + module HeaderFooterType { + var primary: string; + var firstPage: string; + var evenPages: string; + } + module ErrorCodes { + var accessDenied: string; + var generalException: string; + var invalidArgument: string; + var itemNotFound: string; + var notImplemented: string; + } +} +declare module Word { + /** + * The RequestContext object facilitates requests to the Word application. Since the Office add-in and the Word application run in two different processes, the request context is required to get access to the Word object model from the add-in. + */ + class RequestContext extends OfficeExtension.ClientRequestContext { + private m_document; + constructor(url?: string); + document: Document; + } + /** + * Executes a batch script that performs actions on the Word object model. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Word application. Since the Office add-in and the Word application run in two different processes, the request context is required to get access to the Word object model from the add-in. + */ + function run(batch: (context: Word.RequestContext) => OfficeExtension.IPromise): OfficeExtension.IPromise; +} + +declare module Office.MailboxEnums { + export enum BodyType { + /** + * The body is in HTML format + */ + HTML, + /** + * The body is in text format + */ + text + } + export enum EntityType { + /** + * Specifies that the entity is a meeting suggestion + */ + MeetingSuggestion, + /** + * Specifies that the entity is a task suggestion + */ + TaskSuggestion, + /** + * Specifies that the entity is a postal address + */ + Address, + /** + * Specifies that the entity is SMTP email address + */ + EmailAddress, + /** + * Specifies that the entity is an Internet URL + */ + Url, + /** + * Specifies that the entity is US phone number + */ + PhoneNumber, + /** + * Specifies that the entity is a contact + */ + Contact + } + export enum ItemType { + /** + * A meeting request, response, or cancellation + */ + Message, + /** + * Specifies an appointment item + */ + Appointment + } + export enum ResponseType { + /** + * There has been no response from the attendee + */ + None, + /** + * The attendee is the meeting organizer + */ + Organizer, + /** + * The meeting request was tentatively accepted by the attendee + */ + Tentative, + /** + * The meeting request was accepted by the attendee + */ + Accepted, + /** + * The meeting request was declined by the attendee + */ + Declined + } + export enum RecipientType { + /** + * Specifies that the recipient is not one of the other recipient types + */ + Other, + /** + * Specifies that the recipient is a distribution list containing a list of email addresses + */ + DistributionList, + /** + * Specifies that the recipient is an SMTP email address that is on the Exchange server + */ + User, + /** + * Specifies that the recipient is an SMTP email address that is not on the Exchange server + */ + ExternalUser + } + export enum AttachmentType { + /** + * The attachment is a file + */ + File, + /** + * The attachment is an Exchange item + */ + Item + } +} +declare module Office { + export module Types { + export interface ItemRead extends Office.Item { + subject: any; + /** + * Displays a reply form that includes the sender and all the recipients of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyAllForm(htmlBody: string): void; + /** + * Displays a reply form that includes only the sender of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyForm(htmlBody: string): void; + /** + * Gets an array of entities found in an message + */ + getEntities(): Office.Entities; + /** + * Gets an array of entities of the specified entity type found in an message + * @param entityType One of the EntityType enumeration values + */ + getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; + /** + * Returns well-known entities that pass the named filter defined in the manifest XML file + * @param name A TableData object with the headers and rows + */ + getFilteredEntitiesByName(name: string): Office.Entities; + /** + * Returns string values in the currently selected message object that match the regular expressions defined in the manifest XML file + */ + getRegExMatches(): string[]; + /** + * Returns string values that match the named regular expression defined in the manifest XML file + */ + getRegExMatchesByName(name: string): string[]; + } + export interface ItemCompose extends Office.Item { + body: Office.Body; + subject: any; + /** + * Adds a file to a message as an attachment + * @param uri The URI that provides the location of the file to attach to the message. The maximum length is 2048 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds an Exchange item, such as a message, as an attachment to the message + * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an attachment from a message + * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; + } + export interface MessageCompose extends Office.Message { + attachments: Office.AttachmentDetails[]; + body: Office.Body; + bcc: Office.Recipients; + cc: Office.Recipients; + subject: Office.Subject; + to: Office.Recipients; + /** + * Adds a file to a message as an attachment + * @param uri The URI that provides the location of the file to attach to the message. The maximum length is 2048 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds an Exchange item, such as a message, as an attachment to the message + * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an attachment from a message + * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; + } + export interface MessageRead extends Office.Message { + cc: Office.EmailAddressDetails[]; + from: Office.EmailAddressDetails; + internetMessageId: string; + normalizedSubject: string; + sender: Office.EmailAddressDetails; + subject: string; + to: Office.EmailAddressDetails; + /** + * Displays a reply form that includes the sender and all the recipients of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyAllForm(htmlBody: string): void; + /** + * Displays a reply form that includes only the sender of the selected message + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyForm(htmlBody: string): void; + /** + * Gets an array of entities found in an message + */ + getEntities(): Office.Entities; + /** + * Gets an array of entities of the specified entity type found in an message + * @param entityType One of the EntityType enumeration values + */ + getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; + /** + * Returns well-known entities that pass the named filter defined in the manifest XML file + * @param name A TableData object with the headers and rows + */ + getFilteredEntitiesByName(name: string): Office.Entities; + /** + * Returns string values in the currently selected message object that match the regular expressions defined in the manifest XML file + */ + getRegExMatches(): string[]; + /** + * Returns string values that match the named regular expression defined in the manifest XML file + */ + getRegExMatchesByName(name: string): string[]; + } + export interface AppointmentCompose extends Office.Appointment { + body: Office.Body; + end: Office.Time; + location: Office.Location; + optionalAttendees: Office.Recipients; + requiredAttendees: Office.Recipients; + start: Office.Time; + subject: Office.Subject; + /** + * Adds a file to an appointment as an attachment + * @param uri The URI that provides the location of the file to attach to the appointment. The maximum length is 2048 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addFileAttachmentAsync(uri: string, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds an Exchange item, such as a message, as an attachment to the appointment + * @param itemId The Exchange identifier of the item to attach. The maximum length is 100 characters + * @param attachmentName The name of the attachment that is shown while the attachment is uploading. The maximum length is 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + addItemAttachmentAsync(itemId: any, attachmentName: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Removes an attachment from a appointment + * @param attachmentIndex The index of the attachment to remove. The maximum length of the string is 100 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional callback method + */ + removeAttachmentAsync(attachmentIndex: string, option?: any, callback?: (result: AsyncResult) => void): void; + } + export interface AppointmentRead extends Office.Appointment { + attachments: Office.AttachmentDetails[]; + end: Date; + location: string; + normalizedSubject: string; + optionalAttendees: Office.EmailAddressDetails; + organizer: Office.EmailAddressDetails; + requiredAttendees: Office.EmailAddressDetails; + resources: string[]; + start: Date; + subject: string; + /** + * Displays a reply form that includes the organizer and all the attendees of the selected appointment item + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyAllForm(htmlBody: string): void; + /** + * Displays a reply form that includes only the organizer of the selected appointment item + * @param htmlBody A string that contains text and HTML and that represents the body of the reply form. The string is limited to 32 KB + */ + displayReplyForm(htmlBody: string): void; + /** + * Gets an array of entities found in an appointment + */ + getEntities(): Office.Entities; + /** + * Gets an array of entities of the specified entity type found in an appointment + * @param entityType One of the EntityType enumeration values + */ + getEntitiesByType(entityType: Office.MailboxEnums.EntityType): Office.Entities; + /** + * Returns well-known entities that pass the named filter defined in the manifest XML file + * @param name A TableData object with the headers and rows + */ + getFilteredEntitiesByName(name: string): Office.Entities; + /** + * Returns string values in the currently selected appointment object that match the regular expressions defined in the manifest XML file + */ + getRegExMatches(): string[]; + /** + * Returns string values that match the named regular expression defined in the manifest XML file + */ + getRegExMatchesByName(name: string): string[]; + } + } + export module cast { + export module item { + function toAppointmentCompose(item: Office.Item): Office.Types.AppointmentCompose; + function toAppointmentRead(item: Office.Item): Office.Types.AppointmentRead; + function toAppointment(item: Office.Item): Office.Appointment; + function toMessageCompose(item: Office.Item): Office.Types.MessageCompose; + function toMessageRead(item: Office.Item): Office.Types.MessageRead; + function toMessage(item: Office.Item): Office.Message; + function toItemCompose(item: Office.Item): Office.Types.ItemCompose; + function toItemRead(item: Office.Item): Office.Types.ItemRead; + } + } + export interface AttachmentDetails { + attachmentType: Office.MailboxEnums.AttachmentType; + contentType: string; + id: string; + isInline: boolean; + name: string; + size: number; + } + export interface Contact { + personName: string; + businessName: string; + phoneNumbers: PhoneNumber[]; + emailAddresses: string[]; + urls: string[]; + addresses: string[]; + contactString: string; + } + + export interface Context { + mailbox: Mailbox; + roamingSettings: RoamingSettings; + } + export interface CustomProperties { + /** + * Returns the value of the specified custom property + * @param name The name of the property to be returned + */ + get(name: string): any; + /** + * Sets the specified property to the specified value + * @param name The name of the property to be set + * @param value The value of the property to be set + */ + set(name: string, value: string): void; + /** + * Removes the specified property from the custom property collection. + * @param name The name of the property to be removed + */ + remove(name: string): void; + /** + * Saves the custom property collection to the server + * @param callback The optional callback method + * @param userContext Optional variable for any state data that is passed to the saveAsync method + */ + saveAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + } + export interface EmailAddressDetails { + emailAddress: string; + displayName: string; + appointmentResponse: Office.MailboxEnums.ResponseType; + recipientType: Office.MailboxEnums.RecipientType; + } + export interface EmailUser { + name: string; + userId: string; + } + export interface Entities { + addresses: string[]; + taskSuggestions: string[]; + meetingSuggestions: MeetingSuggestion[]; + emailAddresses: string[]; + urls: string[]; + phoneNumbers: PhoneNumber[]; + contacts: Contact[]; + } + export interface Item { + dateTimeCreated: Date; + dateTimeModified: Date; + itemClass: string; + itemId: string; + itemType: Office.MailboxEnums.ItemType; + /** + * Asynchronously loads custom properties that are specific to the item and a app for Office + * @param callback The optional callback method + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + loadCustomPropertiesAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + } + export interface Appointment extends Item { + } + export interface Body { + /** + * Gets a value that indicates whether the content is in HTML or text format + * @param tableData A TableData object with the headers and rows + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the getTypeAsync method returns + */ + getTypeAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Adds the specified content to the beginning of the item body + * @param data The string to be inserted at the beginning of the body. The string is limited to 1,000,000 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + prependAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Replaces the selection in the body with the specified text + * @param data The string to be inserted at the beginning of the body. The string is limited to 1,000,000 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setSelectedDataAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Location { + /** + * Begins an asynchronous request for the location of an appointment + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to set the location of an appointment + * @param data The location of the appointment. The string is limited to 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the location is set + */ + setAsync(location: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface Mailbox { + item: Item; + userProfile: UserProfile; + /** + * Gets a Date object from a dictionary containing time information + * @param timeValue A Date object + */ + convertToLocalClientTime(timeValue: Date): any; + /** + * Gets a dictionary containing time information in local client time + * @param input A dictionary containing a date. The dictionary should contain the following fields: year, month, date, hours, minutes, seconds, time zone, time zone offset + */ + convertToUtcClientTime(input: any): Date; + /** + * Displays an existing calendar appointment + * @param itemId The Exchange Web Services (EWS) identifier for an existing calendar appointment + */ + displayAppointmentForm(itemId: any): void; + /** + * Displays an existing message + * @param itemId The Exchange Web Services (EWS) identifier for an existing message + */ + displayMessageForm(itemId: any): void; + /** + * Displays a form for creating a new calendar appointment + * @param requiredAttendees An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the required attendees for the appointment. The array is limited to a maximum of 100 entries + * @param optionalAttendees An array of strings containing the email addresses or an array containing an EmailAddressDetails object for each of the optional attendees for the appointment. The array is limited to a maximum of 100 entries + * @param start A Date object specifying the start date and time of the appointment + * @param end A Date object specifying the end date and time of the appointment + * @param location A string containing the location of the appointment. The string is limited to a maximum of 255 characters + * @param resources An array of strings containing the resources required for the appointment. The array is limited to a maximum of 100 entries + * @param subject A string containing the subject of the appointment. The string is limited to a maximum of 255 characters + * @param body The body of the appointment message. The body content is limited to a maximum size of 32 KB + */ + displayNewAppointmentForm(requiredAttendees: any, optionalAttendees: any, start: Date, end: Date, location: string, resources: string[], subject: string, body: string): void; + /** + * Gets a string that contains a token used to get an attachment or item from an Exchange Server + * @param callback The optional method to call when the string is inserted + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + getCallbackTokenAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + /** + * Gets a token identifying the user and the app for Office + * @param callback The optional method to call when the string is inserted + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + getUserIdentityTokenAsync(callback?: (result: AsyncResult) => void, userContext?: any): void; + /** + * Makes an asynchronous request to an Exchange Web Services (EWS) service on the Exchange server that hosts the user’s mailbox + * @param data The EWS request + * @param callback The optional method to call when the string is inserted + * @param userContext Optional variable for any state data that is passed to the asynchronous method + */ + makeEwsRequestAsync(data: any, callback?: (result: AsyncResult) => void, userContext?: any): void; + } + export interface Message extends Item { + conversationId: string; + } + export interface MeetingRequest extends Message { + start: Date; + end: Date; + location: string; + optionalAttendees: EmailAddressDetails[]; + requiredAttendees: EmailAddressDetails[]; + } + export interface MeetingSuggestion { + meetingString: string; + attendees: EmailAddressDetails[]; + location: string; + subject: string; + start: Date; + end: Date; + } + export interface PhoneNumber { + phoneString: string; + originalPhoneString: string; + type: string; + } + export interface Recipients { + /** + * Begins an asynchronous request to add a recipient list to an appointment or message + * @param recipients The recipients to add to the recipients list + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + addAsync(recipients: any, options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to get the recipient list for an appointment or message + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to set the recipient list for an appointment or message + * @param recipients The recipients to add to the recipients list + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setAsync(recipients: any, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface RoamingSettings { + /** + * Retrieves the specified setting + * @param name The case-sensitive name of the setting to retrieve + */ + get(name: string): any; + /** + * Removes the specified setting + * @param name The case-sensitive name of the setting to remove + */ + remove(name: string): void; + /** + * Saves the settings + * @param callback A function that is invoked when the callback returns, whose only parameter is of type AsyncResult + */ + saveAsync(callback?: (result: AsyncResult) => void): void; + /** + * Sets or creates the specified setting + * @param name The case-sensitive name of the setting to set or create + * @param value Specifies the value to be stored + */ + set(name: string, value: any): void; + } + export interface Subject { + /** + * Begins an asynchronous request to get the subject of an appointment or message + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous call to set the subject of an appointment or message + * @param data The subject of the appointment. The string is limited to 255 characters + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setAsync(data: string, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface TaskSuggestion { + assignees: EmailUser[]; + taskString: string; + } + export interface Time { + /** + * Begins an asynchronous request to get the start or end time + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + getAsync(options?: any, callback?: (result: AsyncResult) => void): void; + /** + * Begins an asynchronous request to set the start or end time + * @param dateTime A date-time object in Coordinated Universal Time (UTC) + * @param options Any optional parameters or state data passed to the method + * @param callback The optional method to call when the string is inserted + */ + setAsync(dateTime: Date, options?: any, callback?: (result: AsyncResult) => void): void; + } + export interface UserProfile { + displayName: string; + emailAddress: string; + timeZone: string; + } +} From 372689cd4334e5e1ad2779ca3ade9b1e2cfd757a Mon Sep 17 00:00:00 2001 From: laco0416 Date: Fri, 16 Oct 2015 00:55:16 +0900 Subject: [PATCH 052/357] Update polymer.d.ts: fix es6 class syntax --- polymer/polymer-tests.ts | 4 ++-- polymer/polymer.d.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/polymer/polymer-tests.ts b/polymer/polymer-tests.ts index 311fda967..8a44ed285 100644 --- a/polymer/polymer-tests.ts +++ b/polymer/polymer-tests.ts @@ -63,7 +63,7 @@ var el2 = document.createElement('my-element'); class MyElement2 { is: string; - registered() { + beforeRegister() { this.is = "my-element2"; } } @@ -74,7 +74,7 @@ Polymer(MyElement2); class MyElement3 implements polymer.Base { is: string; - registered() { + beforeRegister() { this.is = "my-element3"; } } diff --git a/polymer/polymer.d.ts b/polymer/polymer.d.ts index b764aeb2a..9117301af 100644 --- a/polymer/polymer.d.ts +++ b/polymer/polymer.d.ts @@ -201,6 +201,8 @@ declare module polymer { observers?: string[]; + beforeRegister?(): void; + registered?(): void; created?(): void; From 45fc24faad7d693ea87d914ae2c3d162c93c51e7 Mon Sep 17 00:00:00 2001 From: Dmytro Nemoga Date: Thu, 15 Oct 2015 19:00:14 +0300 Subject: [PATCH 053/357] Update `IActionDescriptor` accordingly to official documentation --- angularjs/angular-resource-tests.ts | 23 ++++++++++++++++++----- angularjs/angular-resource.d.ts | 11 +++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts index f7f248ea8..cfa7712cc 100644 --- a/angularjs/angular-resource-tests.ts +++ b/angularjs/angular-resource-tests.ts @@ -8,11 +8,24 @@ interface IMyResourceClass extends angular.resource.IResourceClass /////////////////////////////////////// var actionDescriptor: angular.resource.IActionDescriptor; -actionDescriptor.url = '/api/test-url/' -actionDescriptor.headers = { header: 'value' }; -actionDescriptor.isArray = true; -actionDescriptor.method = 'method action'; -actionDescriptor.params = { key: 'value' }; +angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactoryService, $timeout: angular.ITimeoutService) { + actionDescriptor.method = 'method action'; + actionDescriptor.params = { key: 'value' }; + actionDescriptor.url = '/api/test-url/'; + actionDescriptor.isArray = true; + actionDescriptor.transformRequest = function () { }; + actionDescriptor.transformRequest = [function () { }]; + actionDescriptor.transformResponse = function () { }; + actionDescriptor.transformResponse = [function () { }]; + actionDescriptor.headers = { header: 'value' }; + actionDescriptor.cache = true; + actionDescriptor.cache = $cacheFactory('cacheId'); + actionDescriptor.timeout = 1000; + actionDescriptor.timeout = $timeout(function () { }); + actionDescriptor.withCredentials = true; + actionDescriptor.responseType = 'response type'; + actionDescriptor.interceptor = { key: 'value' }; +}); /////////////////////////////////////// diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 4688a9c6f..5c8637059 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -46,11 +46,18 @@ declare module angular.resource { // Just a reference to facilitate describing new actions interface IActionDescriptor { - url?: string; method: string; - isArray?: boolean; params?: any; + url?: string; + isArray?: boolean; + transformRequest?: angular.IHttpResquestTransformer | angular.IHttpResquestTransformer[]; + transformResponse?: angular.IHttpResponseTransformer | angular.IHttpResponseTransformer[]; headers?: any; + cache?: boolean | angular.ICacheObject; + timeout?: number | angular.IPromise; + withCredentials?: boolean; + responseType?: string; + interceptor?: any; } // Baseclass for everyresource with default actions. From 93662fbe0a3392b19c0f297605e5295643e895f1 Mon Sep 17 00:00:00 2001 From: Blake Doss Date: Thu, 15 Oct 2015 13:49:47 -0400 Subject: [PATCH 054/357] Added additional template methods. --- typeahead/typeahead.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index a8b139937..49538fbd9 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -152,6 +152,20 @@ declare module Twitter.Typeahead { * If it's a precompiled template, the passed in context will contain query and isEmpty. */ header?: any; + + /** + * Rendered when 0 suggestions are available for the given query. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query. + */ + notFound?: (query: string) => string; + + /** + * Rendered when 0 synchronous suggestions are available but asynchronous suggestions are expected. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query. + */ + pending?: (query: string) => string; /** * Used to render a single suggestion. From ff9d48a65907c052541cf17fe582c8eab84e42e4 Mon Sep 17 00:00:00 2001 From: John Vilk Date: Thu, 15 Oct 2015 16:03:27 -0400 Subject: [PATCH 055/357] Adding definition of mocha.throwError, with test to cover it. See implementation in Mocha's source code here: https://github.com/mochajs/mocha/blob/c4393c456839d6bf2cbb4abb1cd177010ee06458/support/browser-entry.js#L98 --- mocha/mocha-tests.ts | 4 ++++ mocha/mocha.d.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/mocha/mocha-tests.ts b/mocha/mocha-tests.ts index f90fefaf9..c50f5feab 100644 --- a/mocha/mocha-tests.ts +++ b/mocha/mocha-tests.ts @@ -249,3 +249,7 @@ function test_run_withOnComplete() { console.log(failures); }); } + +function test_throwError() { + mocha.throwError(new Error("I'm an error!")); +} diff --git a/mocha/mocha.d.ts b/mocha/mocha.d.ts index 88dc359fc..b4f182aab 100644 --- a/mocha/mocha.d.ts +++ b/mocha/mocha.d.ts @@ -100,6 +100,12 @@ declare class Mocha { invert(): Mocha; ignoreLeaks(value: boolean): Mocha; checkLeaks(): Mocha; + /** + * Function to allow assertion libraries to throw errors directly into mocha. + * This is useful when running tests in a browser because window.onerror will + * only receive the 'message' attribute of the Error. + */ + throwError(error: Error): void; /** Enables growl support. */ growl(): Mocha; globals(value: string): Mocha; From 741c1c4b53914d4cac5e6bef3beb68b202eada46 Mon Sep 17 00:00:00 2001 From: Andrew Fong Date: Thu, 15 Oct 2015 23:14:04 +0000 Subject: [PATCH 056/357] Flush for analytics-node --- analytics-node/analytics-node-tests.ts | 9 +++++++++ analytics-node/analytics-node.d.ts | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/analytics-node/analytics-node-tests.ts b/analytics-node/analytics-node-tests.ts index 66a4b4995..57c48252f 100644 --- a/analytics-node/analytics-node-tests.ts +++ b/analytics-node/analytics-node-tests.ts @@ -80,3 +80,12 @@ function testIntegrations(): void { } }); } + +function testFlush(): void { + analytics.flush(); + analytics.flush(function(err, batch) { + if (err) { alert("Oh nos!"); } + else { console.log(batch.batch[0].type); } + }); +} + diff --git a/analytics-node/analytics-node.d.ts b/analytics-node/analytics-node.d.ts index 981e754e5..d4376d83e 100644 --- a/analytics-node/analytics-node.d.ts +++ b/analytics-node/analytics-node.d.ts @@ -65,6 +65,16 @@ declare module AnalyticsNode { anonymous_id?: string | number; integrations?: Integrations; }): Analytics; + + /* Flush batched calls to make sure nothing is left in the queue */ + flush(fn?: (err: Error, batch: { + batch: Array<{ + type: string; + }>; + messageId: string; + sentAt: Date; + timestamp: Date; + }) => void): Analytics; } } From b2e6fc12fcc9f9f8793c0d6da01441d4d46b17d2 Mon Sep 17 00:00:00 2001 From: Rob Howard Date: Thu, 15 Oct 2015 16:30:42 -0700 Subject: [PATCH 057/357] Moving header above license Travis failed due to headers appearing below license information. Moved it up. --- office-js/office-js.d.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/office-js/office-js.d.ts b/office-js/office-js.d.ts index cb146fae1..a89525adb 100644 --- a/office-js/office-js.d.ts +++ b/office-js/office-js.d.ts @@ -1,3 +1,8 @@ +// Type definitions for Office.js +// Project: http://dev.office.com +// Definitions by: OfficeDev +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /* ------------------------------------------ START OF LICENSE ----------------------------------------- office-js @@ -8,12 +13,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI ----------------------------------------------- END OF LICENSE ------------------------------------------ */ -// Type definitions for Office.js -// Project: http://dev.office.com -// Definitions by: OfficeDev -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - declare module Office { export var context: Context; /** From d4f3ed0cc7f7aba3b47dc6dbc68ead8a97052fe4 Mon Sep 17 00:00:00 2001 From: Yuki Kodama Date: Fri, 16 Oct 2015 02:43:41 +0000 Subject: [PATCH 058/357] Fix param name --- redux/redux.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redux/redux.d.ts b/redux/redux.d.ts index 1bcbedc63..669ab6b99 100644 --- a/redux/redux.d.ts +++ b/redux/redux.d.ts @@ -43,7 +43,7 @@ declare module Redux { function createStore(reducer: Reducer, initialState?: any): Store; function bindActionCreators(actionCreators: T, dispatch: Dispatch): T; function combineReducers(reducers: any): Reducer; - function applyMiddleware(...middleware: Middleware[]): Function; + function applyMiddleware(...middlewares: Middleware[]): Function; function compose(...functions: Function[]): T; } From cbe4869fdacd9d3adc9b6652bfc50ac500f181fa Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 16 Oct 2015 09:43:59 +0500 Subject: [PATCH 059/357] lodash: signatures of a method _.isEqual (and of an alias _.eq) have been changed --- lodash/lodash-tests.ts | 53 ++++++++------- lodash/lodash.d.ts | 147 +++++++++++++++++++---------------------- 2 files changed, 95 insertions(+), 105 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index adf86e9a6..b4678f153 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2271,6 +2271,20 @@ var testCloneDeepCustomizerFn: TestCloneDeepCustomizerFn; result = _({a: {b: 2}}).cloneDeep(testCloneDeepCustomizerFn, any); } +// _.eq +module TestEq { + let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean; + let result: boolean; + + result = _.eq(any, any); + result = _.eq(any, any, customizer); + result = _.eq(any, any, customizer, any); + + result = _(any).eq(any); + result = _(any).eq(any, customizer); + result = _(any).eq(any, customizer, any) +} + // _.gt result = _.gt(1, 2); result = _(1).gt(2); @@ -2321,6 +2335,20 @@ result = _([1, 2, 3]).isEmpty(); result = _({}).isEmpty(); result = _('').isEmpty(); +// _.isEqual +module TestIsEqual { + let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean; + let result: boolean; + + result = _.isEqual(any, any); + result = _.isEqual(any, any, customizer); + result = _.isEqual(any, any, customizer, any); + + result = _(any).isEqual(any); + result = _(any).isEqual(any, customizer); + result = _(any).isEqual(any, customizer, any) +} + // _.isError result = _.isError(any); result = _(1).isError(); @@ -2758,31 +2786,6 @@ result = _({}).has(['', 42, true]); result = _({}).invert(true).value(); } -// _.isEqual (alias: _.eq) -result = _.isEqual(1, 1); -result = _(1).isEqual(1); -result = _.eq(1, 1); -result = _(1).eq(1); - -var testEqObject = { 'user': 'fred' }; -var testEqOtherObject = { 'user': 'fred' }; -result = _.isEqual(testEqObject, testEqOtherObject); -result = _(testEqObject).isEqual(testEqOtherObject); -result = _.eq(testEqObject, testEqOtherObject); -result = _(testEqObject).eq(testEqOtherObject); - -var testEqArray = ['hello', 'goodbye']; -var testEqOtherArray = ['hi', 'goodbye']; -var testEqCustomizerFn = (value: any, other: any): boolean => { - if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) { - return true; - } -}; -result = _.isEqual(testEqArray, testEqOtherArray, testEqCustomizerFn); -result = _(testEqArray).isEqual(testEqOtherArray, testEqCustomizerFn); -result = _.eq(testEqArray, testEqOtherArray, testEqCustomizerFn); -result = _(testEqArray).eq(testEqOtherArray, testEqCustomizerFn); - class Stooge { constructor( public name: string, diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d5463ffc0..a574e10c3 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6636,6 +6636,30 @@ declare module _ { thisArg?: any): T; } + //_.eq + interface LoDashStatic { + /** + * @see _.isEqual + */ + eq( + value: any, + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isEqual + */ + eq( + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + //_.gt interface LoDashStatic { /** @@ -6775,6 +6799,49 @@ declare module _ { isEmpty(): boolean; } + //_.isEqual + interface IsEqualCustomizer { + (value: any, other: any, indexOrKey?: number|string): boolean; + } + + interface LoDashStatic { + /** + * Performs a deep comparison between two values to determine if they are equivalent. If customizer is + * provided it’s invoked to compare values. If customizer returns undefined comparisons are handled by the + * method instead. The customizer is bound to thisArg and invoked with up to three arguments: (value, other + * [, index|key]). + * + * Note: This method supports comparing arrays, booleans, Date objects, numbers, Object objects, regexes, + * and strings. Objects are compared by their own, not inherited, enumerable properties. Functions and DOM + * nodes are not supported. Provide a customizer function to extend support for comparing other values. + * + * @alias _.eq + * + * @param value The value to compare. + * @param other The other value to compare. + * @param customizer The function to customize value comparisons. + * @param thisArg The this binding of customizer. + * @return Returns true if the values are equivalent, else false. + */ + isEqual( + value: any, + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isEqual + */ + isEqual( + other: any, + customizer?: IsEqualCustomizer, + thisArg?: any + ): boolean; + } + //_.isError interface LoDashStatic { /** @@ -7998,86 +8065,6 @@ declare module _ { invert(multiValue?: boolean): LoDashObjectWrapper; } - //_.isEqual - interface EqCustomizer { - (value: any, other: any, indexOrKey?: number|string): boolean; - } - - interface LoDashStatic { - /** - * Performs a deep comparison between two values to determine if they are equivalent. If customizer is - * provided it is invoked to compare values. If customizer returns undefined comparisons are handled - * by the method instead. The customizer is bound to thisArg and invoked with three - * arguments: (value, other [, index|key]). - * @param value The value to compare. - * @param other The other value to compare. - * @param callback The function to customize value comparisons. - * @param thisArg The this binding of customizer. - * @return True if the values are equivalent, else false. - */ - isEqual(value?: any, - other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(value?: any, - other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - } - - interface LoDashWrapper { - /** - * @see _.isEqual - */ - isEqual(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - } - - interface LoDashArrayWrapper { - /** - * @see _.isEqual - */ - isEqual(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - } - - interface LoDashObjectWrapper { - /** - * @see _.isEqual - */ - isEqual(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - - /** - * @see _.isEqual - */ - eq(other?: any, - callback?: EqCustomizer, - thisArg?: any): boolean; - } - //_.keys interface LoDashStatic { /** From 5e3a73a24bcb05b96491692bc522f9bff7cc0e6c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 16 Oct 2015 10:03:05 +0500 Subject: [PATCH 060/357] lodash: signatures of the method _.findLastKey have been changed --- lodash/lodash-tests.ts | 43 ++++++++++++++++-- lodash/lodash.d.ts | 98 ++++++++++++++++++++++++++++++++---------- 2 files changed, 116 insertions(+), 25 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index adf86e9a6..ba0f5e130 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2676,9 +2676,46 @@ module TestFindKey { } } -result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { - return num % 2 == 1; -}); +// _.findLastKey +module TestFindLastKey { + let result: string; + + { + let predicateFn: (value: any, key?: string, object?: {}) => boolean; + + result = _.findLastKey<{a: string;}>({a: ''}); + + result = _.findLastKey<{a: string;}>({a: ''}, predicateFn); + result = _.findLastKey<{a: string;}>({a: ''}, predicateFn, any); + + + result = _.findLastKey<{a: string;}>({a: ''}, ''); + result = _.findLastKey<{a: string;}>({a: ''}, '', any); + + result = _.findLastKey<{a: number;}, {a: string;}>({a: ''}, {a: 42}); + + result = _<{a: string;}>({a: ''}).findLastKey(); + + result = _<{a: string;}>({a: ''}).findLastKey(predicateFn); + result = _<{a: string;}>({a: ''}).findLastKey(predicateFn, any); + + + result = _<{a: string;}>({a: ''}).findLastKey(''); + result = _<{a: string;}>({a: ''}).findLastKey('', any); + + result = _<{a: string;}>({a: ''}).findLastKey<{a: number;}>({a: 42}); + } + + { + let predicateFn: (value: string, key?: string, collection?: _.Dictionary) => boolean; + + result = _.findLastKey({a: ''}, predicateFn); + result = _.findLastKey({a: ''}, predicateFn, any); + + result = _<{a: string;}>({a: ''}).findLastKey(predicateFn); + result = _<{a: string;}>({a: ''}).findLastKey(predicateFn, any); + } +} result = _.forIn(new Dog('Dagny'), function (value, key) { console.log(key); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d5463ffc0..9ff00c49f 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7745,32 +7745,86 @@ declare module _ { //_.findLastKey interface LoDashStatic { /** - * This method is like _.findKey except that it iterates over elements of a collection in the opposite order. - * @param object The object to search. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - * @return The key of the found element, else undefined. - **/ - findLastKey( - object: any, - callback: (value: any) => boolean, - thisArg?: any): string; + * This method is like _.findKey except that it iterates over elements of a collection in the opposite order. + * + * If a property name is provided for predicate the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @param object The object to search. + * @param predicate The function invoked per iteration. + * @param thisArg The this binding of predicate. + * @return Returns the key of the matched element, else undefined. + */ + findLastKey( + object: TObject, + predicate?: DictionaryIterator, + thisArg?: any + ): string; /** - * @see _.findLastKey - * @param pluckValue _.pluck style callback - **/ - findLastKey( - object: any, - pluckValue: string): string; + * @see _.findLastKey + */ + findLastKey( + object: TObject, + predicate?: ObjectIterator, + thisArg?: any + ): string; /** - * @see _.findLastKey - * @param whereValue _.where style callback - **/ - findLastKey, T>( - object: T, - whereValue: W): string; + * @see _.findLastKey + */ + findLastKey( + object: TObject, + predicate?: string, + thisArg?: any + ): string; + + /** + * @see _.findLastKey + */ + findLastKey, TObject>( + object: TObject, + predicate?: TWhere + ): string; + } + + interface LoDashObjectWrapper { + /** + * @see _.findLastKey + */ + findLastKey( + predicate?: DictionaryIterator, + thisArg?: any + ): string; + + /** + * @see _.findLastKey + */ + findLastKey( + predicate?: ObjectIterator, + thisArg?: any + ): string; + + /** + * @see _.findLastKey + */ + findLastKey( + predicate?: string, + thisArg?: any + ): string; + + /** + * @see _.findLastKey + */ + findLastKey>( + predicate?: TWhere + ): string; } //_.forIn From 1d2b45ff7326c96d2c956449619799d375bf4c21 Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Fri, 16 Oct 2015 16:15:04 +1100 Subject: [PATCH 061/357] licence -> license for consistency :rose: --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5cc7045d7..82833752d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Please see the [contribution guide](http://definitelytyped.org/guides/contributi Here is are the [currently requested definitions](https://github.com/borisyankov/DefinitelyTyped/labels/Definition%3ARequest). -## Licence +## License This project is licensed under the MIT license. From 720460e0e66dcfc95110dd2f28dfd88c192fce1f Mon Sep 17 00:00:00 2001 From: Mark Bouwman Date: Fri, 16 Oct 2015 11:51:23 +0200 Subject: [PATCH 062/357] transitionTo() and reload() should return promises http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state --- angular-ui-router/angular-ui-router.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts index 3ec31968c..2162b0220 100644 --- a/angular-ui-router/angular-ui-router.d.ts +++ b/angular-ui-router/angular-ui-router.d.ts @@ -229,10 +229,10 @@ declare module angular.ui { */ go(to: string, params?: {}, options?: IStateOptions): angular.IPromise; go(to: IState, params?: {}, options?: IStateOptions): angular.IPromise; - transitionTo(state: string, params?: {}, updateLocation?: boolean): void; - transitionTo(state: IState, params?: {}, updateLocation?: boolean): void; - transitionTo(state: string, params?: {}, options?: IStateOptions): void; - transitionTo(state: IState, params?: {}, options?: IStateOptions): void; + transitionTo(state: string, params?: {}, updateLocation?: boolean): ng.IPromise; + transitionTo(state: IState, params?: {}, updateLocation?: boolean): ng.IPromise; + transitionTo(state: string, params?: {}, options?: IStateOptions): ng.IPromise; + transitionTo(state: IState, params?: {}, options?: IStateOptions): ng.IPromise; includes(state: string, params?: {}): boolean; is(state:string, params?: {}): boolean; is(state: IState, params?: {}): boolean; @@ -244,7 +244,7 @@ declare module angular.ui { current: IState; /** A param object, e.g. {sectionId: section.id)}, that you'd like to test against the current active state. */ params: IStateParamsService; - reload(): void; + reload(): ng.IPromise; /** Currently pending transition. A promise that'll resolve or reject. */ transition: ng.IPromise<{}>; From 4442fe3853c09c39dbb94fa11a1443c0284971c9 Mon Sep 17 00:00:00 2001 From: Vincent de Lagabbe Date: Fri, 16 Oct 2015 13:29:48 +0200 Subject: [PATCH 063/357] Fix async.forEachFor signature "key" should not be an array --- async/async.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/async/async.d.ts b/async/async.d.ts index 6054e9a47..966d5abaa 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -76,9 +76,9 @@ interface Async { each(arr: T[], iterator: AsyncIterator, callback?: ErrorCallback): void; eachSeries(arr: T[], iterator: AsyncIterator, callback?: ErrorCallback): void; eachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; - forEachOf(obj: any, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void; + forEachOf(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; forEachOf(obj: T[], iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; - forEachOfSeries(obj: any, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void; + forEachOfSeries(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; forEachOfSeries(obj: T[], iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; forEachOfLimit(obj: any, limit: number, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void; forEachOfLimit(obj: T[], limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; From 91e1c3f3fcdae9d1b0c32a0b0f95e13b32f21d51 Mon Sep 17 00:00:00 2001 From: vvakame Date: Fri, 16 Oct 2015 22:03:39 +0900 Subject: [PATCH 064/357] remove unused reference at hammerjs/hammerjs.d.ts --- hammerjs/hammerjs.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index 5ea8165b0..0df86dfc6 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -3,8 +3,6 @@ // Definitions by: Philip Bulley , Han Lin Yap // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// - declare var Hammer:HammerStatic; declare module "hammerjs" { From eee4f2b199639b598f87535e62deb39c9baabdc2 Mon Sep 17 00:00:00 2001 From: Artur Wasilewski Date: Fri, 16 Oct 2015 15:06:18 +0200 Subject: [PATCH 065/357] Fixed syntax in .d.ts file --- ui-grid/ui-grid.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 8b67f649b..ef013fdf1 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -734,13 +734,13 @@ declare module uiGrid { * to load when scrolling up * @default false */ - infiniteScrollUp?: boolean, + infiniteScrollUp?: boolean; /** * Inform the grid of whether there are rows * to load scrolling down * @default true */ - infiniteScrollDown?: boolean, + infiniteScrollDown?: boolean; /** * Defaults to 200 * @default 200 From ee35457a50c7d47aa540597d7fdf850b57f79420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Castre?= Date: Fri, 16 Oct 2015 15:55:22 +0200 Subject: [PATCH 066/357] Improve durandal.d.ts if you use Q instead of jQuery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Durandal supports injection/configuration to use a different library for Deferred/Promises (ref http://durandaljs.com/documentation/Q.html) When using a different Deferred/Promise implementation, you might want to use a different Promise interface in the durandal.d.ts file. Added some type annotations to ensure that durandal.d.ts won’t make compilation fail when the compiling with the noImplicitAny option set to true. Note that I'm not the author of these changes but was asked to review it, and then publish it for the benefits of the community. --- durandal/durandal.d.ts | 132 ++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 60 deletions(-) diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index 86f988cbe..612e85c64 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Durandal 2.1.0 +// Type definitions for Durandal 2.1.0 // Project: http://durandaljs.com // Definitions by: Blue Spire // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -12,6 +12,18 @@ /// /// +// By default, Durandal uses JQuery's Defer/Promise implementation, but durandal supports injecting/configuring +// usage of different JavaScript Defer/Promise libraries (f.ex. Q or ES6 Promise polyfills). +// You might therefore want to use a different interface from a community typings file or your custom unified interface. +// When using f.ex. Q as Defer/Promise library replace the lines below with: + +// +// interface DurandalPromise extends Q.Promise +// interface DurandalDeferred extends Q.Deferred + +interface DurandalPromise extends JQueryPromise { } +interface DurandalDeferred extends JQueryDeferred { } + /** * The system module encapsulates the most basic features used by other modules. * @requires require @@ -45,7 +57,7 @@ interface DurandalSystemModule { * @param {object} obj The object whose module id you wish to set. * @param {string} id The id to set for the specified object. */ - setModuleId(obj, id: string): void; + setModuleId(obj: any, id: string): void; /** * Resolves the default object instance for a module. If the module is an object, the module is returned. If the module is a function, that function is called with `new` and it's result is returned. @@ -89,9 +101,9 @@ interface DurandalSystemModule { /** * Creates a deferred object which can be used to create a promise. Optionally pass a function action to perform which will be passed an object used in resolving the promise. * @param {function} [action] The action to defer. You will be passed the deferred object as a paramter. - * @returns {JQueryDeferred} The deferred object. + * @returns {Deferred} The deferred object. */ - defer(action?: (dfd: JQueryDeferred) => void): JQueryDeferred; + defer(action?: (dfd: DurandalDeferred) => void): DurandalDeferred; /** * Creates a simple V4 UUID. This should not be used as a PK in your database. It can be used to generate internal, unique ids. For a more robust solution see [node-uuid](https://github.com/broofa/node-uuid). @@ -102,23 +114,23 @@ interface DurandalSystemModule { /** * Uses require.js to obtain a module. This function returns a promise which resolves with the module instance. * @param {string} moduleId The id of the module to load. - * @returns {JQueryPromise} A promise for the loaded module. + * @returns {Promise} A promise for the loaded module. */ - acquire(moduleId: string): JQueryPromise; + acquire(moduleId: string): DurandalPromise; /** * Uses require.js to obtain an array of modules. This function returns a promise which resolves with the modules instances in an array. * @param {string[]} moduleIds The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. + * @returns {Promise} A promise for the loaded module. */ - acquire(modules: string[]): JQueryPromise; + acquire(modules: string[]): DurandalPromise; /** * Uses require.js to obtain multiple modules. This function returns a promise which resolves with the module instances in an array. * @param {string} moduleIds* The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. + * @returns {Promise} A promise for the loaded module. */ - acquire(...moduleIds: string[]): JQueryPromise; + acquire(...moduleIds: string[]): DurandalPromise; /** * Extends the first object with the properties of the following objects. @@ -130,9 +142,9 @@ interface DurandalSystemModule { /** * Uses a setTimeout to wait the specified milliseconds. * @param {number} milliseconds The number of milliseconds to wait. - * @returns {JQueryPromise} + * @returns {Promise} */ - wait(milliseconds: number): JQueryPromise; + wait(milliseconds: number): DurandalPromise; /** * Gets all the owned keys of the specified object. @@ -295,14 +307,14 @@ interface DurandalViewEngineModule { * @param {string} id The view id whose view should be cached. * @param {DOMElement} view The view to cache. */ - putViewInCache(id: string, view: HTMLElement); + putViewInCache(id: string, view: HTMLElement): void; /** * Creates the view associated with the view id. * @param {string} viewId The view id whose view should be created. - * @returns {JQueryPromise} A promise of the view. + * @returns {DurandalPromise} A promise of the view. */ - createView(viewId: string): JQueryPromise; + createView(viewId: string): DurandalPromise; /** * Called when a view cannot be found to provide the opportunity to locate or generate a fallback view. Mainly used to ease development. @@ -311,7 +323,7 @@ interface DurandalViewEngineModule { * @param {Error} requirePath The error that was returned from the attempt to locate the default view. * @returns {Promise} A promise for the fallback view. */ - createFallbackView(viewId: string, requirePath: string, err: Error): JQueryPromise; + createFallbackView(viewId: string, requirePath: string, err: Error): DurandalPromise; } /** @@ -439,7 +451,7 @@ interface DurandalViewLocatorModule { * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. * @returns {Promise} A promise of the view. */ - locateViewForObject(obj: any, area: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + locateViewForObject(obj: any, area: string, elementsToSearch?: HTMLElement[]): DurandalPromise; /** * Converts a module id into a view id. By default the ids are the same. @@ -470,7 +482,7 @@ interface DurandalViewLocatorModule { * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. * @returns {Promise} A promise of the view. */ - locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): DurandalPromise; /** * Locates the specified view. @@ -479,7 +491,7 @@ interface DurandalViewLocatorModule { * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. * @returns {Promise} A promise of the view. */ - locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): DurandalPromise; } /** @@ -514,7 +526,7 @@ declare module 'durandal/composition' { area?: string; preserveContext?: boolean; activate?: boolean; - strategy?: (context: CompositionContext) => JQueryPromise; + strategy?: (context: CompositionContext) => DurandalPromise; composingNewView: boolean; child: HTMLElement; binding?: (child: HTMLElement, parent: HTMLElement, context: CompositionContext) => void; @@ -547,7 +559,7 @@ declare module 'durandal/composition' { * @param {object} [config] The binding handler instance. If none is provided, the name will be used to look up an existing handler which will then be converted to a composition handler. * @param {function} [initOptionsFactory] If the registered binding needs to return options from its init call back to knockout, this function will server as a factory for those options. It will receive the same parameters that the init function does. */ - export function addBindingHandler(name, config?: KnockoutBindingHandler, initOptionsFactory?: (element?: HTMLElement, valueAccessor?: any, allBindingsAccessor?: any, viewModel?: any, bindingContext?: KnockoutBindingContext) => any); + export function addBindingHandler(name: string, config?: KnockoutBindingHandler, initOptionsFactory?: (element?: HTMLElement, valueAccessor?: any, allBindingsAccessor?: any, viewModel?: any, bindingContext?: KnockoutBindingContext) => any): void; /** * Gets an object keyed with all the elements that are replacable parts, found within the supplied elements. The key will be the part name and the value will be the element itself. @@ -568,7 +580,7 @@ declare module 'durandal/composition' { * @param {object} context The composition context containing the model and possibly existing viewElements. * @returns {promise} A promise for the view. */ - export var defaultStrategy: (context: CompositionContext) => JQueryPromise; + export var defaultStrategy: (context: CompositionContext) => DurandalPromise; /** * Initiates a composition. @@ -663,13 +675,13 @@ declare module 'plugins/dialog' { * In this function, you are expected to add a DOM element to the tree which will serve as the "host" for the modal's composed view. You must add a property called host to the modalWindow object which references the dom element. It is this host which is passed to the composition module. * @param {Dialog} theDialog The dialog model. */ - addHost(theDialog: Dialog); + addHost(theDialog: Dialog): void; /** * This function is expected to remove any DOM machinery associated with the specified dialog and do any other necessary cleanup. * @param {Dialog} theDialog The dialog model. */ - removeHost(theDialog: Dialog); + removeHost(theDialog: Dialog): void; /** * This function is called after the modal is fully composed into the DOM, allowing your implementation to do any final modifications, such as positioning or animation. You can obtain the original dialog object by using `getDialog` on context.model. @@ -677,14 +689,14 @@ declare module 'plugins/dialog' { * @param {DOMElement} parent The parent view. * @param {object} context The composition context. */ - compositionComplete(child: HTMLElement, parent: HTMLElement, context: composition.CompositionContext); + compositionComplete(child: HTMLElement, parent: HTMLElement, context: composition.CompositionContext): void; } interface Dialog { owner: any; context: DialogContext; activator: DurandalActivator; - close(): JQueryPromise; + close(): DurandalPromise; settings: composition.CompositionContext; } @@ -745,7 +757,7 @@ declare module 'plugins/dialog' { * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. */ - export function show(obj: any, activationData?: any, context?: string): JQueryPromise; + export function show(obj: any, activationData?: any, context?: string): DurandalPromise; /** * Shows a message box. @@ -756,7 +768,7 @@ declare module 'plugins/dialog' { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - export function showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): JQueryPromise; + export function showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Shows a message box. @@ -767,7 +779,7 @@ declare module 'plugins/dialog' { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - export function showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): JQueryPromise; + export function showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Installs this module into Durandal; called by the framework. Adds `app.showDialog` and `app.showMessage` convenience methods. @@ -890,7 +902,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @returns {Promise} A promise of the get response data. */ - export function get(url: string, query?: Object, headers?: Object): JQueryPromise; + export function get(url: string, query?: Object, headers?: Object): DurandalPromise; /** * Makes an JSONP request. @@ -900,7 +912,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @returns {Promise} A promise of the response data. */ - export function jsonp(url: string, query?: Object, callbackParam?: string, headers?: Object): JQueryPromise; + export function jsonp(url: string, query?: Object, callbackParam?: string, headers?: Object): DurandalPromise; /** * Makes an HTTP POST request. @@ -909,7 +921,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @returns {Promise} A promise of the response data. */ - export function post(url: string, data: Object, headers?: Object): JQueryPromise; + export function post(url: string, data: Object, headers?: Object): DurandalPromise; /** * Makes an HTTP PUT request. @@ -919,7 +931,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @return {Promise} A promise of the response data. */ - export function put(url: string, data: Object, headers?: Object): JQueryPromise; + export function put(url: string, data: Object, headers?: Object): DurandalPromise; /** * Makes an HTTP DELETE request. @@ -929,7 +941,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @return {Promise} A promise of the get response data. */ - export function remove(url: string, query?: Object, headers?: Object): JQueryPromise; + export function remove(url: string, query?: Object, headers?: Object): DurandalPromise; } /** @@ -964,7 +976,7 @@ declare module 'plugins/observable' { * @param {function|object} evaluatorOrOptions The Knockout computed function or computed options object. * @returns {KnockoutComputed} The underlying computed observable. */ - export function defineProperty(obj: any, propertyName: string, evaluatorOrOptions?: KnockoutComputedDefine); + export function defineProperty(obj: any, propertyName: string, evaluatorOrOptions?: KnockoutComputedDefine): KnockoutComputed; /** * Installs the plugin into the view model binder's `beforeBind` hook so that objects are automatically converted before being bound. @@ -1046,7 +1058,7 @@ declare module 'plugins/serializer' { * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. * @returns {string} The JSON string. */ - export function serialize(object: any, settings?: string); + export function serialize(object: any, settings?: string): string; /** * Serializes the object. @@ -1054,7 +1066,7 @@ declare module 'plugins/serializer' { * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. * @returns {string} The JSON string. */ - export function serialize(object: any, settings?: number); + export function serialize(object: any, settings?: number): string; /** * Serializes the object. @@ -1062,7 +1074,7 @@ declare module 'plugins/serializer' { * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. * @returns {string} The JSON string. */ - export function serialize(object: any, settings?: SerializerOptions); + export function serialize(object: any, settings?: SerializerOptions): string; /** * Gets the type id for an object instance, using the configured `typeAttribute`. @@ -1081,7 +1093,7 @@ declare module 'plugins/serializer' { * @param {string} typeId The type id. * @param {function} constructor The constructor. */ - export function registerType(typeId: string, constructor: () => any); + export function registerType(typeId: string, constructor: () => any): void; /** * The default reviver function used during deserialization. By default is detects type properties on objects and uses them to re-construct the correct object using the provided constructor mapping. @@ -1091,7 +1103,7 @@ declare module 'plugins/serializer' { * @param {object} getConstructor A custom function used to get the constructor function associated with a type id. * @returns {object} The value. */ - export function reviver(key: string, value: any, getTypeId: (value: any) => string, getConstructor: (string) => () => any): any; + export function reviver(key: string, value: any, getTypeId: (value: any) => string, getConstructor: (id: string) => () => any): any; /** * Deserialize the JSON. @@ -1128,7 +1140,7 @@ declare module 'plugins/widget' { * Creates a ko binding handler for the specified kind. * @param {string} kind The kind to create a custom binding handler for. */ - export function registerKind(kind: string); + export function registerKind(kind: string): void; /** * Maps views and module to the kind identifier if a non-standard pattern is desired. @@ -1136,7 +1148,7 @@ declare module 'plugins/widget' { * @param {string} [viewId] The unconventional view id to map the kind to. * @param {string} [moduleId] The unconventional module id to map the kind to. */ - export function mapKind(kind: string, viewId?: string, moduleId?: string); + export function mapKind(kind: string, viewId?: string, moduleId?: string): void; /** * Maps a kind name to it's module id. First it looks up a custom mapped kind, then falls back to `convertKindToModulePath`. @@ -1172,7 +1184,7 @@ declare module 'plugins/widget' { * @param {object} settings The widget settings. * @param {object} [bindingContext] The current binding context. */ - export function create(element: HTMLElement, settings: WidgetSettings, bindingContext?: KnockoutBindingContext); + export function create(element: HTMLElement, settings: WidgetSettings, bindingContext?: KnockoutBindingContext): void; } /** @@ -1279,14 +1291,14 @@ interface DurandalAppModule extends DurandalEventSupport { * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. */ - showDialog(obj: any, activationData?: any, context?: string): JQueryPromise; + showDialog(obj: any, activationData?: any, context?: string): DurandalPromise; /** * Closes the dialog associated with the specified object. via the dialog plugin. * @param {object} obj The object whose dialog should be closed. * @param {object} results* The results to return back to the dialog caller after closing. */ - closeDialog(obj: any, ...results); + closeDialog(obj: any, ...results: any[]): void; /** * Shows a message box via the dialog plugin. @@ -1297,7 +1309,7 @@ interface DurandalAppModule extends DurandalEventSupport { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): JQueryPromise; + showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Shows a message box. @@ -1308,7 +1320,7 @@ interface DurandalAppModule extends DurandalEventSupport { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): JQueryPromise; + showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Configures one or more plugins to be loaded and installed into the application. @@ -1322,7 +1334,7 @@ interface DurandalAppModule extends DurandalEventSupport { * Starts the application. * @returns {promise} */ - start(): JQueryPromise; + start(): DurandalPromise; /** * Sets the root module/view for the application. @@ -1404,7 +1416,7 @@ interface DurandalActivator extends KnockoutComputed { * @param {boolean} close Whether or not to check if close is possible. * @returns {promise} */ - canDeactivateItem(item: T, close: boolean): JQueryPromise; + canDeactivateItem(item: T, close: boolean): DurandalPromise; /** * Deactivates the specified item. @@ -1412,7 +1424,7 @@ interface DurandalActivator extends KnockoutComputed { * @param {boolean} close Whether or not to close the item. * @returns {promise} */ - deactivateItem(item: T, close: boolean): JQueryPromise; + deactivateItem(item: T, close: boolean): DurandalPromise; /** * Determines whether or not the specified item can be activated. @@ -1420,7 +1432,7 @@ interface DurandalActivator extends KnockoutComputed { * @param {object} activationData Data associated with the activation. * @returns {promise} */ - canActivateItem(newItem: T, activationData?: any): JQueryPromise; + canActivateItem(newItem: T, activationData?: any): DurandalPromise; /** * Activates the specified item. @@ -1428,31 +1440,31 @@ interface DurandalActivator extends KnockoutComputed { * @param {object} newActivationData Data associated with the activation. * @returns {promise} */ - activateItem(newItem: T, activationData?: any): JQueryPromise; + activateItem(newItem: T, activationData?: any): DurandalPromise; /** * Determines whether or not the activator, in its current state, can be activated. * @returns {promise} */ - canActivate(): JQueryPromise; + canActivate(): DurandalPromise; /** * Activates the activator, in its current state. * @returns {promise} */ - activate(): JQueryPromise; + activate(): DurandalPromise; /** * Determines whether or not the activator, in its current state, can be deactivated. * @returns {promise} */ - canDeactivate(close: boolean): JQueryPromise; + canDeactivate(close: boolean): DurandalPromise; /** * Deactivates the activator, in its current state. * @returns {promise} */ - deactivate(close: boolean): JQueryPromise; + deactivate(close: boolean): DurandalPromise; /** * Adds canActivate, activate, canDeactivate and deactivate functions to the provided model which pass through to the corresponding functions on the activator. @@ -1462,7 +1474,7 @@ interface DurandalActivator extends KnockoutComputed { /** * Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them. */ - forItems(items): DurandalActivator; + forItems(items: any[]): DurandalActivator; } interface DurandalHistoryOptions { @@ -1509,7 +1521,7 @@ interface DurandalRouteConfiguration { title?: any; moduleId?: string; hash?: string; - route?: string|string[]; + route?: string | string[]; routePattern?: RegExp; isActive?: KnockoutComputed; nav?: any; @@ -1765,7 +1777,7 @@ interface DurandalRouterBase extends DurandalEventSupport { * @param {object} instruction The route instruction. The instruction object has config, fragment, queryString, params and queryParams properties. * @returns {Promise|Boolean|String} If a boolean, determines whether or not the route should activate or be cancelled. If a string, causes a redirect to the specified route. Can also be a promise for either of these value types. */ - guardRoute?: (instance: Object, instruction: DurandalRouteInstruction) => JQueryPromise|boolean|string; + guardRoute?: (instance: Object, instruction: DurandalRouteInstruction) => DurandalPromise | boolean | string; /** * Parent router of the current child router. @@ -1785,7 +1797,7 @@ interface DurandalRootRouter extends DurandalRouterBase { * Activates the router and the underlying history tracking mechanism. * @returns {Promise} A promise that resolves when the router is ready. */ - activate(options?: DurandalHistoryOptions): JQueryPromise; + activate(options?: DurandalHistoryOptions): DurandalPromise; /** * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. From bb4692f5d2bba524eb9b810cf7c83a1ec671d547 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Fri, 16 Oct 2015 17:07:49 +0200 Subject: [PATCH 067/357] Extended definition for roslib to match library functions --- roslib/roslib.d.ts | 361 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 356 insertions(+), 5 deletions(-) diff --git a/roslib/roslib.d.ts b/roslib/roslib.d.ts index 667a37983..9bab4a49f 100644 --- a/roslib/roslib.d.ts +++ b/roslib/roslib.d.ts @@ -3,22 +3,373 @@ // Definitions by: Stefan Profanter // Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* ---------------------------------- + + NOTE: This typescript definition is not yet complete. I should be extended if definitions are missing. + + ---------------------------------- */ + declare module ROSLIB { export class Ros { - constructor(data: { - url: string + /** + * Manages connection to the server and all interactions with ROS. + * + * Emits the following events: + * * 'error' - there was an error with ROS + * * 'connection' - connected to the WebSocket server + * * 'close' - disconnected to the WebSocket server + * * - a message came from rosbridge with the given topic name + * * - a service response came from rosbridge with the given ID + * + * @constructor + * @param options - possible keys include: + * * url (optional) - the WebSocket URL for rosbridge (can be specified later with `connect`) + */ + constructor(options:{ + url?: string }); - on(eventName: string, callback: (event: any) => void) : void; - connect(url: string) : void; + on(eventName:string, callback:(event:any) => void):void; + + /** + * Connect to the specified WebSocket. + * + * @param url - WebSocket URL for Rosbridge + */ + connect(url:string):void; + + /** + * Disconnect from the WebSocket server. + */ + close():void; + + /** + * Sends an authorization request to the server. + * + * @param mac - MAC (hash) string given by the trusted source. + * @param client - IP of the client. + * @param dest - IP of the destination. + * @param rand - Random string given by the trusted source. + * @param t - Time of the authorization request. + * @param level - User level as a string given by the client. + * @param end - End time of the client's session. + */ + authenticate(mac:string, client:string, dest:string, rand:string, t:number, level:string, end:string): void; + + + /** + * Sends the message over the WebSocket, but queues the message up if not yet + * connected. + */ + callOnConnection(message:any): void; + + /** + * Retrieves list of topics in ROS as an array. + * + * @param callback function with params: + * * topics - Array of topic names + */ + getTopics(callback:(topics:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves Topics in ROS as an array as specific type + * + * @param topicType topic type to find: + * @param callback function with params: + * * topics - Array of topic names + */ + getTopicsForType(topicType:string, callback:(topics:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves list of active service names in ROS. + * + * @param callback - function with the following params: + * * services - array of service names + */ + getServices(callback:(services:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves list of services in ROS as an array as specific type + * + * @param serviceType service type to find: + * @param callback function with params: + * * topics - Array of service names + */ + getServicesForType(serviceType: string, callback:(services:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves list of active node names in ROS. + * + * @param callback - function with the following params: + * * nodes - array of node names + */ + getNodes(callback:(nodes:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves list of param names from the ROS Parameter Server. + * + * @param callback function with params: + * * params - array of param names. + */ + getParams(callback:(params:string[]) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves a type of ROS topic. + * + * @param topic name of the topic: + * @param callback - function with params: + * * type - String of the topic type + */ + getTopicType(topic: string, callback:(type:string) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves a type of ROS service. + * + * @param service name of service: + * @param callback - function with params: + * * type - String of the service type + */ + getServiceType(service: string, callback:(type:string) => void, failedCallback:(error:any)=>void): void; + + /** + * Retrieves a detail of ROS message. + * + * @param callback - function with params: + * * details - Array of the message detail + * @param message - String of a topic type + */ + getMessageDetails(message: Message, callback:(detail:any) => void, failedCallback:(error:any)=>void): void; + + /** + * Decode a typedefs into a dictionary like `rosmsg show foo/bar` + * + * @param defs - array of type_def dictionary + */ + decodeTypeDefs(defs: any): void; + } + + export class Message { + /** + * Message objects are used for publishing and subscribing to and from topics. + * + * @constructor + * @param values - object matching the fields defined in the .msg definition file + */ + constructor(values:any); + } + + export class Param { + /** + * A ROS parameter. + * + * @constructor + * @param options - possible keys include: + * * ros - the ROSLIB.Ros connection handle + * * name - the param name, like max_vel_x + */ + constructor(options:{ + ros: Ros, + name: string + }); + + /** + * Fetches the value of the param. + * + * @param callback - function with the following params: + * * value - the value of the param from ROS. + */ + get(callback:(response:any) => void): void; + + /** + * Sets the value of the param in ROS. + * + * @param value - value to set param to. + */ + set(value:any, callback:(response:any) => void): void; + + /** + * Delete this parameter on the ROS server. + */ + delete(callback:(response:any) => void): void; + } export class Service { - constructor(data: { + /** + * A ROS service client. + * + * @constructor + * @params options - possible keys include: + * * ros - the ROSLIB.Ros connection handle + * * name - the service name, like /add_two_ints + * * serviceType - the service type, like 'rospy_tutorials/AddTwoInts' + */ + constructor(data:{ ros: Ros, name: string, serviceType: string }); + + /** + * Calls the service. Returns the service response in the callback. + * + * @param request - the ROSLIB.ServiceRequest to send + * @param callback - function with params: + * * response - the response from the service request + * @param failedCallback - the callback function when the service call failed (optional). Params: + * * error - the error message reported by ROS + */ + callService(request:ServiceRequest, callback:(response:any) => void, failedCallback?:(error:any) => void): void; + } + + export class ServiceRequest { + /** + * A ServiceRequest is passed into the service call. + * + * @constructor + * @param values - object matching the fields defined in the .srv definition file + */ + constructor(values: any); + } + + export class ServiceResponse { + /** + * A ServiceResponse is returned from the service call. + * + * @constructor + * @param values - object matching the fields defined in the .srv definition file + */ + constructor(values: any); + } + + export class Topic { + /** + * Publish and/or subscribe to a topic in ROS. + * + * Emits the following events: + * * 'warning' - if there are any warning during the Topic creation + * * 'message' - the message data from rosbridge + * + * @constructor + * @param options - object with following keys: + * * ros - the ROSLIB.Ros connection handle + * * name - the topic name, like /cmd_vel + * * messageType - the message type, like 'std_msgs/String' + * * compression - the type of compression to use, like 'png' + * * throttle_rate - the rate (in ms in between messages) at which to throttle the topics + * * queue_size - the queue created at bridge side for re-publishing webtopics (defaults to 100) + * * latch - latch the topic when publishing + * * queue_length - the queue length at bridge side used when subscribing (defaults to 0, no queueing). + */ + constructor(options: { + ros: Ros, + name: string, + messageType: string, + compression: string, + throttle_rate: number, + queue_size: number, + latch: number, + queue_length: number + }); + + /** + * Every time a message is published for the given topic, the callback + * will be called with the message object. + * + * @param callback - function with the following params: + * * message - the published message + */ + subscribe(callback: (message: Message) => void): void; + + /** + * Unregisters as a subscriber for the topic. Unsubscribing stop remove + * all subscribe callbacks. To remove a call back, you must explicitly + * pass the callback function in. + * + * @param callback - the optional callback to unregister, if + * * provided and other listeners are registered the topic won't + * * unsubscribe, just stop emitting to the passed listener + */ + unsubscribe(callback?: () => void): void; + + /** + * Registers as a publisher for the topic. + */ + advertise(): void; + + /** + * Unregisters as a publisher for the topic. + */ + unadvertise(): void; + + /** + * Publish the message. + * + * @param message - A ROSLIB.Message object. + */ + publish(message: Message): void; + } + + class ActionClient { + /** + * An actionlib action client. + * + * Emits the following events: + * * 'timeout' - if a timeout occurred while sending a goal + * * 'status' - the status messages received from the action server + * * 'feedback' - the feedback messages received from the action server + * * 'result' - the result returned from the action server + * + * @constructor + * @param options - object with following keys: + * * ros - the ROSLIB.Ros connection handle + * * serverName - the action server name, like /fibonacci + * * actionName - the action message name, like 'actionlib_tutorials/FibonacciAction' + * * timeout - the timeout length when connecting to the action server + */ + constructor(options: { + ros: Ros, + serverName: string, + actionName: string, + timeout: number + }); + + /** + * Cancel all goals associated with this ActionClient. + */ + cancel(): void; + } + + class Goal { + /** + * An actionlib goal goal is associated with an action server. + * + * Emits the following events: + * * 'timeout' - if a timeout occurred while sending a goal + * + * @constructor + * @param object with following keys: + * * actionClient - the ROSLIB.ActionClient to use with this goal + * * goalMessage - The JSON object containing the goal for the action server + */ + constructor(options: { + actionClient: ActionClient, + goalMessage: any + }); + + /** + * Send the goal to the action server. + * + * @param timeout (optional) - a timeout length for the goal's result + */ + send(timeout?: number): void; + + /** + * Cancel the current goal. + */ + cancel(): void; } } + From 70dc7d5bd011694a5f0a3abccd53780629273342 Mon Sep 17 00:00:00 2001 From: haizz Date: Fri, 16 Oct 2015 18:30:14 +0300 Subject: [PATCH 068/357] react-bootstrap: added 'show' property to ModalProps --- react-bootstrap/react-bootstrap.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react-bootstrap/react-bootstrap.d.ts b/react-bootstrap/react-bootstrap.d.ts index 8f3803a6b..5e3532c64 100644 --- a/react-bootstrap/react-bootstrap.d.ts +++ b/react-bootstrap/react-bootstrap.d.ts @@ -249,6 +249,7 @@ declare module "react-bootstrap" { dialogComponent?: any; // TODO: Add more specific type enforceFocus?: boolean; keyboard?: boolean; + show?: boolean; } interface Modal extends React.ReactElement { } interface ModalClass extends React.ComponentClass { From 39c221338d56e953b745bfdd761f8c594d8f92da Mon Sep 17 00:00:00 2001 From: Dominic Alie Date: Fri, 16 Oct 2015 11:33:55 -0400 Subject: [PATCH 069/357] JSTS type definitions --- jsts/jsts-tests.ts | 145 ++++ jsts/jsts.d.ts | 1666 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1811 insertions(+) create mode 100644 jsts/jsts-tests.ts create mode 100644 jsts/jsts.d.ts diff --git a/jsts/jsts-tests.ts b/jsts/jsts-tests.ts new file mode 100644 index 000000000..3b37d0f18 --- /dev/null +++ b/jsts/jsts-tests.ts @@ -0,0 +1,145 @@ +/// +var str: string; +var n: number; +var bool: boolean; +var obj: any; + +var c: jsts.geom.Coordinate = new jsts.geom.Coordinate(n, n); +var e: jsts.geom.Envelope = new jsts.geom.Envelope(n, n, n, n); +var g: jsts.geom.Geometry = new jsts.geom.Geometry(); +var lr: jsts.geom.LinearRing = new jsts.geom.LinearRing([c]); +var ls: jsts.geom.LineString = new jsts.geom.LineString([c]); +var p: jsts.geom.Point = new jsts.geom.Point(c); +var poly: jsts.geom.Polygon = new jsts.geom.Polygon(lr); + +str = jsts.version; + +c = new jsts.geom.Coordinate(c); +c = c.clone(); +n = c.compareTo(c); +n = c.distance(c); +bool = c.equals(c); +bool = c.equals2D(c); +c.setCoordinate(c); +n = c.x; +n = c.y; +n = c.z; + +e = new jsts.geom.Envelope(c); +e = new jsts.geom.Envelope(e); +e = new jsts.geom.Envelope(c, c); +c = e.centre(); +e = e.clone(); +bool = e.contains(e); +bool = e.contains(c); +bool = e.contains(n, n); +bool = e.covers(c); +bool = e.covers(e); +bool = e.covers(n, n); +n = e.distance(e); +bool = e.equals(e); +e.expandBy(n); +e.expandToInclude(c); +e.expandToInclude(e); +e.expandToInclude(n, n); +n = e.getArea(); +n = e.getHeight(); +n = e.getMaxX(); +n = e.getMaxY(); +n = e.getMinX(); +n = e.getMinY(); +n = e.getWidth(); +e = e.intersection(e); +bool = e.intersects(e); +bool = e.intersects(c); +bool = e.intersects(n, n); +bool = e.isNull(); +n = e.maxx; +n = e.maxy; +n = e.minx; +n = e.miny; +e.setToNull(); +str = e.toString(); +e.translate(n, n); + +g.apply({}); +g = g.buffer(n, n, n); +g.checkNotGeometryCollection(g); +g = g.clone(); +n = g.compare([{}], [{}]); +n = g.compareTo(g); +n = g.compareToSameClass(g); +e = g.computeEnvelopeInternal(); +bool = g.contains(g); +g = g.convexHull(); +bool = g.coveredBy(g); +bool = g.covers(g); +bool = g.crosses(g); +g = g.difference(g); +bool = g.disjoint(g); +n = g.distance(g); +e = g.envelope; +bool = g.equal(c, c, n); +bool = g.equals(g); +bool = g.equalsExact(g, n); +bool = g.equalsNorm(g); +bool = g.equalsTopo(g); +n = g.getArea(); +g = g.getBoundary(); +n = g.getBoundaryDimension(); +p = g.getCentroid(); +c = g.getCoordinate(); +var coords: jsts.geom.Coordinate[] = g.getCoordinates(); +n = g.getDimension(); +g = g.getEnvelope(); +e = g.getEnvelopeInternal(); +obj = g.getFactory(); +g = g.getGeometryN(n); +str = g.getGeometryType(); +p = g.getInteriorPoint(); +n = g.getLength(); +n = g.getNumGeometries(); +n = g.getNumPoints(); +obj = g.getPrecisionModel(); +g = g.intersection(g); +bool = g.intersects(g); +bool = g.isEmpty(); +bool = g.isEquivalentClass(g); +bool = g.isGeometryCollection(); +bool = g.isGeometryCollectionBase(); +bool = g.isRectangle(); +bool = g.isSimple(); +bool = g.isValid(); +bool = g.isWithinDistance(g, n); +g = g.norm(); +g.normalize(); +bool = g.overlaps(g); +bool = g.relate(g, str); +obj = g.relate2(g); +g = g.symDifference(g); +str = g.toString(); +bool = g.touches(g); +g = g.union(g); +bool = g.within(g); + +c = ls.getCoordinateN(n); +p = ls.getEndPoint(); +p = ls.getPointN(n); +p = ls.getStartPoint(); +bool = ls.isClosed(); +bool = ls.isRing(); + +n = p.getX(); +n = p.getY(); +p = p.reverse(); + +lr = poly.getExteriorRing(); +lr = poly.getInteriorRingN(n); +n = poly.getNumInteriorRing(); + +var gjw: jsts.io.GeoJSONWriter = new jsts.io.GeoJSONWriter(); +obj = gjw.write(g); + +var wr: jsts.io.WKTReader = new jsts.io.WKTReader(); +g = wr.read(str); +wr.reducePrecision(g); \ No newline at end of file diff --git a/jsts/jsts.d.ts b/jsts/jsts.d.ts new file mode 100644 index 000000000..2eac4d5a4 --- /dev/null +++ b/jsts/jsts.d.ts @@ -0,0 +1,1666 @@ +// Type definitions for jsts 0.16.0 +// Project: https://github.com/bjornharrtell/jsts +// Definitions by: Stephane Alie +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module jsts { + export var version: string; + + module geom { + /** + * A lightweight class used to store coordinates on the 2-dimensional + * Cartesian plane. It is distinct from {@link Point}, which is a subclass of + * {@link Geometry}. Unlike objects of type {@link Point} (which contain + * additional information such as an envelope, a precision model, and spatial + * reference system information), a Coordinate only contains + * coordinate values and accessor methods. + */ + export class Coordinate { + /** + * @constructor + */ + constructor(x: number, y: number); + + /** + * @constructor + */ + constructor(c: Coordinate); + + /** + * Gets or sets the x value. + */ + x: number; + + /** + * Gets or sets the y value. + */ + y: number; + + /** + * Gets or sets the z value. + */ + z: number; + + /** + * Sets this Coordinates (x,y,z) values to that of + * other. + * + * @param {Coordinate} + * other the Coordinate to copy. + */ + setCoordinate(other: Coordinate): void; + + /** + * Clones this instance. + * + * @return {Coordinate} A point instance cloned from this. + */ + clone(): Coordinate; + + /** + * Computes the 2-dimensional Euclidean distance to another location. The + * Z-ordinate is ignored. + * + * @param {Coordinate} + * p a point. + * @return {number} the 2-dimensional Euclidean distance between the + * locations. + */ + distance(p: Coordinate): number; + + /** + * Returns whether the planar projections of the two Coordinates + * are equal. + * + * @param {Coordinate} + * other a Coordinate with which to do the 2D + * comparison. + * @return {boolean} true if the x- and y-coordinates are + * equal; the z-coordinates do not have to be equal. + */ + equals2D(other: Coordinate): boolean; + + /** + * Returns true if other has the same values for + * the x and y ordinates. Since Coordinates are 2.5D, this routine ignores the + * z value when making the comparison. + * + * @param {Coordinate} + * other a Coordinate with which to do the comparison. + * @return {boolean} true if other is a + * Coordinate with the same values for the x and y + * ordinates. + */ + equals(other: Coordinate): boolean; + + /** + * Compares this {@link Coordinate} with the specified {@link Coordinate} for + * order. This method ignores the z value when making the comparison. Returns: + *
    + *
  • -1 : this.x < other.x || ((this.x == other.x) && (this.y < other.y)) + *
  • 0 : this.x == other.x && this.y = other.y + *
  • 1 : this.x > other.x || ((this.x == other.x) && (this.y > other.y)) + * + *
+ * Note: This method assumes that ordinate values are valid numbers. NaN + * values are not handled correctly. + * + * @param {Coordinate} + * other the Coordinate with which this + * Coordinate is being compared. + * @return {number} -1, zero, or 1 as explained above. + */ + compareTo(other: Coordinate): number; + } + + /** + * Defines a rectangular region of the 2D coordinate plane. It is often used to + * represent the bounding box of a {@link Geometry}, e.g. the minimum and + * maximum x and y values of the {@link Coordinate}s. + *

+ * Note that Envelopes support infinite or half-infinite regions, by using the + * values of Double.POSITIVE_INFINITY and + * Double.NEGATIVE_INFINITY. + *

+ * When Envelope objects are created or initialized, the supplies extent values + * are automatically sorted into the correct order. + */ + export class Envelope { + /** + * Test the point q to see whether it intersects the Envelope defined by p1-p2 + * + * NOTE: calls intersectsEnvelope if four arguments are given to simulate + * overloaded function + * + * @param {jsts.geom.Coordinate} + * p1 one extremal point of the envelope. + * @param {jsts.geom.Coordinate} + * p2 another extremal point of the envelope. + * @param {jsts.geom.Coordinate} + * q the point to test for intersection. + * @return {boolean} true if q intersects the envelope p1-p2. + */ + static intersects(p1: Coordinate, p2: Coordinate, q: Coordinate): boolean; + + /** + * Test the envelope defined by p1-p2 for intersection with the envelope defined + * by q1-q2 + * + * @param {jsts.geom.Coordinate} + * p1 one extremal point of the envelope P. + * @param {jsts.geom.Coordinate} + * p2 another extremal point of the envelope P. + * @param {jsts.geom.Coordinate} + * q1 one extremal point of the envelope Q. + * @param {jsts.geom.Coordinate} + * q2 another extremal point of the envelope Q. + * @return {boolean} true if Q intersects P. + */ + static intersectsEnvelope(p1: Coordinate, p2: Coordinate, q1: Coordinate, q2: Coordinate): boolean; + + /** + * Creates an Envelope for a region defined by maximum and + * minimum values. + * + * @param {number} x1 the first x-value. + * @param {number} x2 the second x-value. + * @param {number} y1 the first y-value. + * @param {number} y2 the second y-value. + */ + constructor(x1: number, x2: number, y1: number, y2: number); + + /** + * Initialize an Envelope to a region defined by two Coordinates. + * + * @param {jsts.geom.Coordinate} p1 the first Coordinate. + * @param {jsts.geom.Coordinate} p2 the second Coordinate. + */ + constructor(p1: Coordinate, p2: Coordinate); + + /** + * Initialize an Envelope to a region defined by a single + * Coordinate. + * + * @param {jsts.geom.Coordinate} p the Coordinate. + */ + constructor(p: Coordinate); + + /** + * Initialize an Envelope from an existing Envelope. + * + * @param {jsts.geom.Envelope} env the Envelope to initialize from. + */ + constructor(env: Envelope); + + /** + * the minimum x-coordinate. + */ + minx: number; + + /** + * the maximum x-coordinate. + */ + maxx: number; + + /** + * the minimum y-coordinate. + */ + miny: number; + + /** + * the maximum y-coordinate. + */ + maxy: number; + + /** + * Makes this Envelope a "null" envelope, that is, the envelope + * of the empty geometry. + */ + setToNull(): void; + + /** + * Returns true if this Envelope is a "null" + * envelope. + * + * @return {boolean} true if this Envelope is + * uninitialized or is the envelope of the empty geometry. + */ + isNull(): boolean; + + /** + * Returns the difference between the maximum and minimum y values. + * + * @return {number} max y - min y, or 0 if this is a null Envelope. + */ + getHeight(): number; + + /** + * Returns the difference between the maximum and minimum x values. + * + * @return {number} max x - min x, or 0 if this is a null Envelope. + */ + getWidth(): number; + + /** + * Returns the Envelopes minimum x-value. min x > max x + * indicates that this is a null Envelope. + * + * @return {number} the minimum x-coordinate. + */ + getMinX(): number; + + /** + * Returns the Envelopes maximum x-value. min x > max x + * indicates that this is a null Envelope. + * + * @return {number} the maximum x-coordinate. + */ + getMaxX(): number; + + /** + * Returns the Envelopes minimum y-value. min y > max y + * indicates that this is a null Envelope. + * + * @return {number} the minimum y-coordinate. + */ + getMinY(): number; + + /** + * Returns the Envelopes maximum y-value. min y > max y + * indicates that this is a null Envelope. + * + * @return {number} the maximum y-coordinate. + */ + getMaxY(): number; + + /** + * Gets the area of this envelope. + * + * @return {number} the area of the envelope, 0.0 if the envelope is null. + */ + getArea(): number; + + /** + * Enlarges this Envelope so that it contains the given + * {@link Coordinate}. Has no effect if the point is already on or within the + * envelope. + * + * @param {jsts.geom.Coordinate} p the Coordinate to expand to include. + */ + expandToInclude(p: Coordinate): void; + + /** + * Enlarges this Envelope so that it contains the given point. + * Has no effect if the point is already on or within the envelope. + * + * @param {number} x the value to lower the minimum x to or to raise the maximum x to. + * @param {number} y the value to lower the minimum y to or to raise the maximum y to. + */ + expandToInclude(x: number, y: number): void; + + /** + * Enlarges this Envelope so that it contains the + * other Envelope. Has no effect if other is + * wholly on or within the envelope. + * + * @param {jsts.geom.Envelope} other the Envelope to expand to include. + */ + expandToInclude(other: Envelope): void; + + /** + * Expands this envelope by a given distance in all directions. Both positive + * and negative distances are supported. + * + * @param {number} distance the distance to expand the envelope. + */ + expandBy(distance: number): void; + + /** + * Expands this envelope by a given distance in all directions. Both positive + * and negative distances are supported. + * + * @param {number} + * deltaX the distance to expand the envelope along the the X axis. + * @param {number} + * deltaY the distance to expand the envelope along the the Y axis. + */ + expandBy(deltaX: number, deltaY: number): void; + + /** + * Translates this envelope by given amounts in the X and Y direction. + * + * @param {number} + * transX the amount to translate along the X axis. + * @param {number} + * transY the amount to translate along the Y axis. + */ + translate(transX: number, transY: number): void; + + /** + * Computes the coordinate of the centre of this envelope (as long as it is + * non-null + * + * @return {jsts.geom.Coordinate} the centre coordinate of this envelope null + * if the envelope is null. + */ + centre(): Coordinate; + + /** + * Computes the intersection of two {@link Envelopes} + * + * @param {jsts.geom.Envelope} + * env the envelope to intersect with. + * @return {jsts.geom.Envelope} a new Envelope representing the intersection of + * the envelopes (this will be the null envelope if either argument is + * null, or they do not intersect. + */ + intersection(env: Envelope): Envelope; + + /** + * Check if the region defined by other overlaps (intersects) the + * region of this Envelope. + * + * @param {jsts.geom.Envelope} + * other the Envelope which this Envelope + * is being checked for overlapping. + * @return {boolean} true if the Envelopes + * overlap. + */ + intersects(other: Envelope): boolean; + + /** + * Check if the point p overlaps (lies inside) the region of this + * Envelope. + * + * @param {jsts.geom.Coordinate} + * p the Coordinate to be tested. + * @return {boolean} true if the point overlaps this + * Envelope. + */ + intersects(p: Coordinate): boolean; + + /** + * Check if the point (x, y) overlaps (lies inside) the region of + * this Envelope. + * + * @param {number} + * x the x-ordinate of the point. + * @param {number} + * y the y-ordinate of the point. + * @return {boolean} true if the point overlaps this + * Envelope. + */ + intersects(x: number, y: number): boolean; + + /** + * Tests if the Envelope other lies wholely inside this + * Envelope (inclusive of the boundary). + *

+ * Note that this is not the same definition as the SFS + * contains, which would exclude the envelope boundary. + * + * @param {jsts.geom.Envelope} + * other the Envelope to check. + * @return {boolean} true if other is contained in this + * Envelope. + * + * @see covers(Envelope) + */ + contains(other: Envelope): boolean; + + /** + * Tests if the given point lies in or on the envelope. + *

+ * Note that this is not the same definition as the SFS + * contains, which would exclude the envelope boundary. + * + * @param {jsts.geom.Coordinate} + * p the point which this Envelope is being checked for + * containing. + * @return {boolean} true if the point lies in the interior or on + * the boundary of this Envelope. + * + * @see covers(Coordinate) + */ + contains(p: Coordinate): boolean; + + /** + * Tests if the given point lies in or on the envelope. + *

+ * Note that this is not the same definition as the SFS + * contains, which would exclude the envelope boundary. + * + * @param {number} + * x the x-coordinate of the point which this Envelope + * is being checked for containing. + * @param {number} + * y the y-coordinate of the point which this Envelope + * is being checked for containing. + * @return {boolean} true if (x, y) lies in the + * interior or on the boundary of this Envelope. + * + * @see covers(double, double) + */ + contains(x: number, y: number): boolean; + + /** + * Tests if the given point lies in or on the envelope. + * + * @param {number} + * x the x-coordinate of the point which this Envelope + * is being checked for containing. + * @param {number} + * y the y-coordinate of the point which this Envelope + * is being checked for containing. + * @return {boolean} true if (x, y) lies in the + * interior or on the boundary of this Envelope. + */ + covers(x: number, y: number): boolean; + + /** + * Tests if the given point lies in or on the envelope. + * + * @param {jsts.geom.Coordinate} + * p the point which this Envelope is being checked for + * containing. + * @return {boolean} true if the point lies in the interior or on + * the boundary of this Envelope. + */ + covers(p: Coordinate): boolean; + + /** + * Tests if the Envelope other lies wholely inside this + * Envelope (inclusive of the boundary). + * + * @param {jsts.geom.Envelope} + * other the Envelope to check. + * @return {boolean} true if this Envelope covers the + * other. + */ + covers(other: Envelope): boolean; + + /** + * Computes the distance between this and another Envelope. + * + * @param {jsts.geom.Envelope} + * env The Envelope to test this Envelope + * against. + * @return {number} The distance between overlapping Envelopes is 0. Otherwise, + * the distance is the Euclidean distance between the closest points. + */ + distance(env: Envelope): number; + + /** + * @param {jsts.geom.Envelope} + * other the Envelope to check against. + * @return {boolean} true if envelopes are equal. + */ + equals(other: Envelope): boolean; + + /** + * @return {string} String representation of this Envelope. + */ + toString(): string; + + /** + * @return {jsts.geom.Envelope} A new instance copied from this. + */ + clone(): Envelope; + } + + /** + * The base class for all geometric objects. + */ + export class Geometry { + /** + * Creates a new Geometry via the specified GeometryFactory. + */ + constructor(factory?: any); + + /** + * The bounding box of this Geometry. + */ + envelope: Envelope; + + /** + * Gets the factory which contains the context in which this geometry was created. + * + * @return {jsts.geom.GeometryFactory} the factory for this geometry. + */ + getFactory(): any; + + /** + * Returns the name of this object's com.vivid.jts.geom interface. + * + * @return {string} The name of this Geometrys most specific jsts.geom interface. + */ + getGeometryType(): string; + + /** + *Returns the number of {@link Geometry}s in a {@link GeometryCollection} + * (or 1, if the geometry is not a collection). + * + * @return {number} the number of geometries contained in this geometry. + */ + getNumGeometries(): number; + + /** + * Returns an element {@link Geometry} from a {@link GeometryCollection} (or + * this, if the geometry is not a collection). + * + * @param {number} n The index of the geometry element. + * + * @return {Geometry} the n'th geometry contained in this geometry. + */ + getGeometryN(n: number): Geometry; + + /** + * Returns the PrecisionModel used by the Geometry. + * + * @return {PrecisionModel} the specification of the grid of allowable points, for this + * Geometry and all other Geometrys. + */ + getPrecisionModel(): any; + + /** + * Returns a vertex of this Geometry (usually, but not + * necessarily, the first one). The returned coordinate should not be assumed to + * be an actual Coordinate object used in the internal representation. + * + * @return {Coordinate} a {@link Coordinate} which is a vertex of this + * Geometry. null if this Geometry is empty. + */ + getCoordinate(): Coordinate; + + /** + * Returns an array containing the values of all the vertices for this geometry. + * If the geometry is a composite, the array will contain all the vertices for + * the components, in the order in which the components occur in the geometry. + *

+ * In general, the array cannot be assumed to be the actual internal storage for + * the vertices. Thus modifying the array may not modify the geometry itself. + * Use the {@link CoordinateSequence#setOrdinate} method (possibly on the + * components) to modify the underlying data. If the coordinates are modified, + * {@link #geometryChanged} must be called afterwards. + * + * @return {Coordinate[]} the vertices of this Geometry. + * @see geometryChanged + * @see CoordinateSequence#setOrdinate + */ + getCoordinates(): Coordinate[]; + + /** + * Returns the count of this Geometrys vertices. The + * Geometry s contained by composite Geometrys + * must be Geometry's; that is, they must implement getNumPoints + * + * @return {number} the number of vertices in this Geometry. + */ + getNumPoints(): number; + + /** + * Tests whether this {@link Geometry} is simple. In general, the SFS + * specification of simplicity follows the rule: + *

    + *
  • A Geometry is simple iff the only self-intersections are at boundary + * points. + *
+ * Simplicity is defined for each {@link Geometry} subclass as follows: + *
    + *
  • Valid polygonal geometries are simple by definition, so + * isSimple trivially returns true. + *
  • Linear geometries are simple iff they do not self-intersect at points + * other than boundary points. + *
  • Zero-dimensional geometries (points) are simple iff they have no + * repeated points. + *
  • Empty Geometrys are always simple + *
      + * + * @return {boolean} true if this Geometry has any + * points of self-tangency, self-intersection or other anomalous points. + * @see #isValid + */ + isSimple(): boolean; + + /** + * Tests the validity of this Geometry. Subclasses provide their + * own definition of "valid". + * + * @return {boolean} true if this Geometry is + * valid. + * + * @see IsValidOp + */ + isValid(): boolean; + + /** + * Returns whether or not the set of points in this Geometry is + * empty. + * + * @return {boolean} true if this Geometry equals + * the empty geometry. + */ + isEmpty(): boolean; + + /** + * Returns the minimum distance between this Geometry and the + * Geometry g + * + * @param {Geometry} + * g the Geometry from which to compute the distance. + * @return {number} the distance between the geometries. 0 if either input + * geometry is empty. + * @throws IllegalArgumentException + * if g is null + */ + distance(g: Geometry): number; + + /** + * Tests whether the distance from this Geometry to another is + * less than or equal to a specified value. + * + * @param {Geometry} + * geom the Geometry to check the distance to. + * @param {number} + * distance the distance value to compare. + * @return {boolean} true if the geometries are less than + * distance apart. + */ + isWithinDistance(geom: Geometry, distance: number): boolean; + + isRectangle(): boolean; + + /** + * Returns the area of this Geometry. Areal Geometries have a + * non-zero area. They override this function to compute the area. Others return + * 0.0 + * + * @return the area of the Geometry. + */ + getArea(): number; + + /** + * Returns the length of this Geometry. Linear geometries return + * their length. Areal geometries return their perimeter. They override this + * function to compute the area. Others return 0.0 + * + * @return the length of the Geometry. + */ + getLength(): number; + + /** + * Computes the centroid of this Geometry. The centroid is equal + * to the centroid of the set of component Geometries of highest dimension + * (since the lower-dimension geometries contribute zero "weight" to the + * centroid) + * + * @return a {@link Point} which is the centroid of this Geometry. + */ + getCentroid(): Point; + + /** + * Computes an interior point of this Geometry. An interior + * point is guaranteed to lie in the interior of the Geometry, if it possible to + * calculate such a point exactly. Otherwise, the point may lie on the boundary + * of the geometry. + * + * @return {Point} a {@link Point} which is in the interior of this Geometry. + */ + getInteriorPoint(): Point; + + /** + * Returns the dimension of this geometry. The dimension of a geometry is is the + * topological dimension of its embedding in the 2-D Euclidean plane. In the JTS + * spatial model, dimension values are in the set {0,1,2}. + *

      + * Note that this is a different concept to the dimension of the vertex + * {@link Coordinate}s. The geometry dimension can never be greater than the + * coordinate dimension. For example, a 0-dimensional geometry (e.g. a Point) + * may have a coordinate dimension of 3 (X,Y,Z). + * + * @return {number} the topological dimension of this geometry. + */ + getDimension(): number; + + /** + * Returns the boundary, or an empty geometry of appropriate dimension if this + * Geometry is empty. (In the case of zero-dimensional + * geometries, ' an empty GeometryCollection is returned.) For a discussion of + * this function, see the OpenGIS Simple Features Specification. As stated in + * SFS Section 2.1.13.1, "the boundary of a Geometry is a set of Geometries of + * the next lower dimension." + * + * @return {Geometry} the closure of the combinatorial boundary of this + * Geometry. + */ + getBoundary(): Geometry; + + /** + * Returns the dimension of this Geometrys inherent boundary. + * + * @return {number} the dimension of the boundary of the class implementing this + * interface, whether or not this object is the empty geometry. Returns + * Dimension.FALSE if the boundary is the empty geometry. + */ + getBoundaryDimension(): number; + + /** + * Returns this Geometrys bounding box. If this + * Geometry is the empty geometry, returns an empty + * Point. If the Geometry is a point, returns a + * non-empty Point. Otherwise, returns a Polygon + * whose points are (minx, miny), (maxx, miny), (maxx, maxy), (minx, maxy), + * (minx, miny). + * + * @return {Geometry} an empty Point (for empty + * Geometrys), a Point (for + * Points) or a Polygon (in all other + * cases). + */ + getEnvelope(): Geometry; + + /** + * Returns the minimum and maximum x and y values in this Geometry, + * or a null Envelope if this Geometry is empty. + * + * @return {Envelope} this Geometrys bounding box; if the + * Geometry is empty, Envelope#isNull will + * return true. + */ + getEnvelopeInternal(): Envelope; + + /** + * Tests whether this geometry is disjoint from the specified geometry. + *

      + * The disjoint predicate has the following equivalent + * definitions: + *

        + *
      • The two geometries have no point in common + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [FF*FF****] + *
      • ! g.intersects(this) (disjoint is the + * inverse of intersects) + *
      + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * are disjoint. + * + * @see Geometry#intersects + */ + disjoint(g: Geometry): boolean; + + /** + * Tests whether this geometry touches the specified geometry. + *

      + * The touches predicate has the following equivalent + * definitions: + *

        + *
      • The geometries have at least one point in common, but their interiors do + * not intersect. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [FT*******] or [F**T*****] or + * [F***T****] + *
      + * If both geometries have dimension 0, this predicate returns + * false + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * touch; Returns false if both Geometrys + * are points. + */ + touches(g: Geometry): boolean; + + /** + * Tests whether this geometry intersects the specified geometry. + *

      + * The intersects predicate has the following equivalent + * definitions: + *

        + *
      • The two geometries have at least one point in common + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T********] or [*T*******] or + * [***T*****] or [****T****] + *
      • ! g.disjoint(this) (intersects is the + * inverse of disjoint) + *
      + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * intersect. + * + * @see Geometry#disjoint + */ + intersects(g: Geometry): boolean; + + /** + * Tests whether this geometry crosses the specified geometry. + *

      + * The crosses predicate has the following equivalent + * definitions: + *

        + *
      • The geometries have some but not all interior points in common. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + *
          + *
        • [T*T******] (for P/L, P/A, and L/A situations) + *
        • [T*****T**] (for L/P, A/P, and A/L situations) + *
        • [0********] (for L/L situations) + *
        + *
      + * For any other combination of dimensions this predicate returns + * false. + *

      + * The SFS defined this predicate only for P/L, P/A, L/L, and L/A situations. + * JTS extends the definition to apply to L/P, A/P and A/L situations as well, + * in order to make the relation symmetric. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * cross. + */ + crosses(g: Geometry): boolean; + + /** + * Tests whether this geometry is within the specified geometry. + *

      + * The within predicate has the following equivalent definitions: + *

        + *
      • Every point of this geometry is a point of the other geometry, and the + * interiors of the two geometries have at least one point in common. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*F**F***] + *
      • g.contains(this) (within is the converse + * of contains) + *
      + * An implication of the definition is that "The boundary of a Geometry is not + * within the Geometry". In other words, if a geometry A is a subset of the + * points in the boundary of a geomtry B, A.within(B) = false + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if this Geometry is + * within other. + * + * @see Geometry#contains + */ + within(g: Geometry): boolean; + + /** + * Tests whether this geometry contains the specified geometry. + *

      + * The contains predicate has the following equivalent + * definitions: + *

        + *
      • Every point of the other geometry is a point of this geometry, and the + * interiors of the two geometries have at least one point in common. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*****FF*] + *
      • g.within(this) (contains is the converse + * of within) + *
      + * An implication of the definition is that "Geometries do not contain their + * boundary". In other words, if a geometry A is a subset of the points in the + * boundary of a geometry B, B.contains(A) = false + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if this Geometry + * contains g. + * + * @see Geometry#within + */ + contains(g: Geometry): boolean; + + /** + * Tests whether this geometry overlaps the specified geometry. + *

      + * The overlaps predicate has the following equivalent + * definitions: + *

        + *
      • The geometries have at least one point each not shared by the other (or + * equivalently neither covers the other), they have the same dimension, and the + * intersection of the interiors of the two geometries has the same dimension as + * the geometries themselves. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*T***T**] (for two points or two surfaces) or + * [1*T***T**] (for two curves) + *
      + * If the geometries are of different dimension this predicate returns + * false. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * overlap. + */ + overlaps(g: Geometry): boolean; + + /** + * Tests whether this geometry covers the specified geometry. + *

      + * The covers predicate has the following equivalent definitions: + *

        + *
      • Every point of the other geometry is a point of this geometry. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*****FF*] or [*T****FF*] or + * [***T**FF*] or [****T*FF*] + *
      • g.coveredBy(this) (covers is the converse + * of coveredBy) + *
      + * If either geometry is empty, the value of this predicate is false. + *

      + * This predicate is similar to {@link #contains}, but is more inclusive (i.e. + * returns true for more cases). In particular, unlike + * contains it does not distinguish between points in the + * boundary and in the interior of geometries. For most situations, + * covers should be used in preference to contains. + * As an added benefit, covers is more amenable to optimization, + * and hence should be more performant. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if this Geometry covers + * g. + * + * @see Geometry#contains + * @see Geometry#coveredBy + */ + covers(g: Geometry): boolean; + + /** + * Tests whether this geometry is covered by the specified geometry. + *

      + * The coveredBy predicate has the following equivalent + * definitions: + *

        + *
      • Every point of this geometry is a point of the other geometry. + *
      • The DE-9IM Intersection Matrix for the two geometries matches + * [T*F**F***] or [*TF**F***] or + * [**FT*F***] or [**F*TF***] + *
      • g.covers(this) (coveredBy is the converse + * of covers) + *
      + * If either geometry is empty, the value of this predicate is false. + *

      + * This predicate is similar to {@link #within}, but is more inclusive (i.e. + * returns true for more cases). + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if this Geometry is + * covered by g. + * + * @see Geometry#within + * @see Geometry#covers + */ + coveredBy(g: Geometry): boolean; + + /** + * Tests whether the elements in the DE-9IM {@link IntersectionMatrix} for the + * two Geometrys match the elements in + * intersectionPattern. The pattern is a 9-character string, + * with symbols drawn from the following set: + *

        + *
      • 0 (dimension 0) + *
      • 1 (dimension 1) + *
      • 2 (dimension 2) + *
      • T ( matches 0, 1 or 2) + *
      • F ( matches FALSE) + *
      • * ( matches any value) + *
      + * For more information on the DE-9IM, see the OpenGIS Simple Features + * Specification. + * + * @param {Geometry} + * other the Geometry with which to compare this + * Geometry. + * @param {string} + * intersectionPattern the pattern against which to check the + * intersection matrix for the two Geometrys. + * @return {boolean} true if the DE-9IM intersection matrix for + * the two Geometrys match + * intersectionPattern. + * @see IntersectionMatrix + */ + relate(g: Geometry, intersectionPattern: string): boolean; + + /** + * Returns the DE-9IM {@link IntersectionMatrix} for the two + * Geometrys. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {IntersectionMatrix} an {@link IntersectionMatrix} describing the + * intersections of the interiors, boundaries and exteriors of the two + * Geometrys. + */ + relate2(g: Geometry): any; + + /** + * Tests whether this geometry is topologically equal to the argument geometry + * as defined by the SFS equals predicate. + *

      + * The SFS equals predicate has the following equivalent + * definitions: + *

        + *
      • The two geometries have at least one point in common, and no point of + * either geometry lies in the exterior of the other geometry. + *
      • The DE-9IM Intersection Matrix for the two geometries matches the + * pattern T*F**FFF* + *
        +             * T*F
        +             * **F
        +             * FF*
        +             * 
        + * + *
      + * Note that this method computes topologically equality. For + * structural equality, see {@link #equalsExact(Geometry)}. + * + * @param {Geometry} + * g the Geometry with which to compare this + * Geometry. + * @return {boolean} true if the two Geometrys + * are topologically equal. + * + * @see #equalsExact(Geometry) + */ + equalsTopo(g: Geometry): boolean; + + /** + * Tests whether this geometry is structurally and numerically equal to a given + * Object. If the argument Object is not a + * Geometry, the result is false. Otherwise, the result + * is computed using {@link #equalsExact(Geometry)}. + *

      + * This method is provided to fulfill the Java contract for value-based object + * equality. In conjunction with {@link #hashCode()} it provides semantics which + * are most useful for using Geometrys as keys and values in Java + * collections. + *

      + * Note that to produce the expected result the input geometries should be in + * normal form. It is the caller's responsibility to perform this where required + * (using {@link Geometry#norm() or {@link #normalize()} as appropriate). + * + * @param {Object} + * o the Object to compare. + * @return {boolean} true if this geometry is exactly equal to the argument. + * + * @see #equalsExact(Geometry) + * @see #hashCode() + * @see #norm() + * @see #normalize() + */ + equals(o: Object): boolean; + + /** + * Computes a buffer area around this geometry having the given width and with a + * specified accuracy of approximation for circular arcs, and using a specified + * end cap style. + *

      + * Mathematically-exact buffer area boundaries can contain circular arcs. To + * represent these arcs using linear geometry they must be approximated with + * line segments. The quadrantSegments argument allows + * controlling the accuracy of the approximation by specifying the number of + * line segments used to represent a quadrant of a circle + *

      + * The end cap style specifies the buffer geometry that will be created at the + * ends of linestrings. The styles provided are: + *

        + *
      • BufferOp.CAP_ROUND - (default) a semi-circle + *
      • BufferOp.CAP_BUTT - a straight line perpendicular to the end + * segment + *
      • BufferOp.CAP_SQUARE - a half-square + *
      + *

      + * The buffer operation always returns a polygonal result. The negative or + * zero-distance buffer of lines and points is always an empty {@link Polygon}. + * This is also the result for the buffers of degenerate (zero-area) polygons. + * + * @param {number} + * distance the width of the buffer (may be positive, negative or 0). + * @param {number} + * quadrantSegments the number of line segments used to represent a + * quadrant of a circle. + * @param {number} + * endCapStyle the end cap style to use. + * @return {Geometry} a polygonal geometry representing the buffer region (which + * may be empty). + * + * @throws TopologyException + * if a robustness error occurs + * + * @see #buffer(double) + * @see #buffer(double, int) + * @see BufferOp + */ + buffer(distance: number, quadrantSegments: number, endCapStyle: number): Geometry; + + /** + * Computes the smallest convex Polygon that contains all the + * points in the Geometry. This obviously applies only to + * Geometry s which contain 3 or more points; the results for + * degenerate cases are specified as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
      Number of Points in argument Geometry + * Geometry class of result
      0 empty GeometryCollection
      1 Point
      2 LineString
      3 or more Polygon
      + * + * @return {Geometry} the minimum-area convex polygon containing this + * Geometry' s points. + */ + convexHull(): Geometry; + + /** + * Computes a Geometry representing the points shared by this + * Geometry and other. {@link GeometryCollection}s + * support intersection with homogeneous collection types, with the semantics + * that the result is a {@link GeometryCollection} of the intersection of each + * element of the target with the argument. + * + * @param {Geometry} + * other the Geometry with which to compute the + * intersection. + * @return {Geometry} the points common to the two Geometrys. + * @throws TopologyException + * if a robustness error occurs + * @throws IllegalArgumentException + * if the argument is a non-empty GeometryCollection + */ + intersection(other: Geometry): Geometry; + + /** + * Computes a Geometry representing all the points in this + * Geometry and other. + * + * Or without arguments: + * + * Computes the union of all the elements of this geometry. Heterogeneous + * {@link GeometryCollection}s are fully supported. + * + * The result obeys the following contract: + *

        + *
      • Unioning a set of {@link LineString}s has the effect of fully noding + * and dissolving the linework. + *
      • Unioning a set of {@link Polygon}s will always return a + * {@link Polygonal} geometry (unlike {link #union(Geometry)}, which may return + * geometrys of lower dimension if a topology collapse occurred. + *
      + * + * @param {Geometry} + * other the Geometry with which to compute the union. + * @return {Geometry} a set combining the points of this Geometry + * and the points of other. + * @throws TopologyException + * if a robustness error occurs + * @throws IllegalArgumentException + * if either input is a non-empty GeometryCollection + */ + union(other: Geometry): Geometry; + + /** + * Computes a Geometry representing the points making up this + * Geometry that do not make up other. This + * method returns the closure of the resultant Geometry. + * + * @param {Geometry} + * other the Geometry with which to compute the + * difference. + * @return {Geometry} the point set difference of this Geometry + * with other. + * @throws TopologyException + * if a robustness error occurs + * @throws IllegalArgumentException + * if either input is a non-empty GeometryCollection + */ + difference(other: Geometry): Geometry; + + /** + * Returns a set combining the points in this Geometry not in + * other, and the points in other not in this + * Geometry. This method returns the closure of the resultant + * Geometry. + * + * @param {Geometry} + * other the Geometry with which to compute the + * symmetric difference. + * @return {Geometry} the point set symmetric difference of this + * Geometry with other. + * @throws TopologyException + * if a robustness error occurs + * @throws IllegalArgumentException + * if either input is a non-empty GeometryCollection + */ + symDifference(other: Geometry): Geometry; + + /** + * Returns true if the two Geometrys are exactly equal, up to a + * specified distance tolerance. Two Geometries are exactly equal within a + * distance tolerance if and only if: + *
        + *
      • they have the same class + *
      • they have the same values for their vertices, within the given tolerance + * distance, in exactly the same order. + *
      + * If this and the other Geometrys are composites and any + * children are not Geometrys, returns false. + * + * @param {Geometry} + * other the Geometry with which to compare this + * Geometry. + * @param {number} + * tolerance distance at or below which two Coordinates + * are considered equal. + * @return {boolean} + */ + equalsExact(other: Geometry, tolerance: number): boolean; + + /** + * Tests whether two geometries are exactly equal in their normalized forms. + * This is a convenience method which creates normalized versions of both + * geometries before computing {@link #equalsExact(Geometry)}. This method is + * relatively expensive to compute. For maximum performance, the client should + * instead perform normalization itself at an appropriate point during + * execution. + * + * @param {Geometry} + * g a Geometry. + * @return {boolean} true if the input geometries are exactly equal in their + * normalized form. + */ + equalsNorm(g: Geometry): boolean; + + /** + * Performs an operation with or on this Geometry and its + * subelement Geometrys (if any). Only GeometryCollections and + * subclasses have subelement Geometry's. + * + * @param filter + * the filter to apply to this Geometry (and its + * children, if it is a GeometryCollection). + */ + apply(filter: any): void; + + /** + * Creates and returns a full copy of this {@link Geometry} object (including + * all coordinates contained by it). Subclasses are responsible for overriding + * this method and copying their internal data. Overrides should call this + * method first. + * + * @return a clone of this instance. + */ + clone(): Geometry; + + /** + * Converts this Geometry to normal form (or + * canonical form ). Normal form is a unique representation for + * Geometry s. It can be used to test whether two + * Geometrys are equal in a way that is independent of the + * ordering of the coordinates within them. Normal form equality is a stronger + * condition than topological equality, but weaker than pointwise equality. The + * definitions for normal form use the standard lexicographical ordering for + * coordinates. "Sorted in order of coordinates" means the obvious extension of + * this ordering to sequences of coordinates. + */ + normalize(): void; + + /** + * Creates a new Geometry which is a normalized copy of this Geometry. + * + * @return a normalized copy of this geometry. + * @see #normalize() + */ + norm(): Geometry; + + /** + * Returns whether this Geometry is greater than, equal to, or + * less than another Geometry. + *

      + * + * If their classes are different, they are compared using the following + * ordering: + *

        + *
      • Point (lowest) + *
      • MultiPoint + *
      • LineString + *
      • LinearRing + *
      • MultiLineString + *
      • Polygon + *
      • MultiPolygon + *
      • GeometryCollection (highest) + *
      + * If the two Geometrys have the same class, their first + * elements are compared. If those are the same, the second elements are + * compared, etc. + * + * @param {Geometry} + * other a Geometry with which to compare this + * Geometry. + * @return {number} a positive number, 0, or a negative number, depending on + * whether this object is greater than, equal to, or less than + * o, as defined in "Normal Form For Geometry" in the + * JTS Technical Specifications. + */ + compareTo(o: Geometry): number; + + /** + * Returns whether the two Geometrys are equal, from the point + * of view of the equalsExact method. Called by + * equalsExact . In general, two Geometry classes + * are considered to be "equivalent" only if they are the same class. An + * exception is LineString , which is considered to be equivalent + * to its subclasses. + * + * @param {Geometry} + * other the Geometry with which to compare this + * Geometry for equality. + * @return {boolean} true if the classes of the two + * Geometry s are considered to be equal by the + * equalsExact method. + */ + isEquivalentClass(other: Geometry): boolean; + + /** + * Throws an exception if g's class is + * GeometryCollection . (Its subclasses do not trigger an + * exception). + * + * @param {Geometry} + * g the Geometry to check. + * @throws Error + * if g is a GeometryCollection but not + * one of its subclasses + */ + checkNotGeometryCollection(g: Geometry): void; + + /** + * + * @return {boolean} true if this is a GeometryCollection. + */ + isGeometryCollection(): boolean; + + /** + * + * @return {boolean} true if this is a GeometryCollection but not subclass. + */ + isGeometryCollectionBase(): boolean; + + /** + * Returns the minimum and maximum x and y values in this Geometry, + * or a null Envelope if this Geometry is empty. + * Unlike getEnvelopeInternal, this method calculates the + * Envelope each time it is called; + * getEnvelopeInternal caches the result of this method. + * + * @return {Envelope} this Geometrys bounding box; if the + * Geometry is empty, Envelope#isNull will + * return true. + */ + computeEnvelopeInternal(): Envelope; + + /** + * Returns whether this Geometry is greater than, equal to, or + * less than another Geometry having the same class. + * + * @param o + * a Geometry having the same class as this + * Geometry. + * @return a positive number, 0, or a negative number, depending on whether this + * object is greater than, equal to, or less than o, as + * defined in "Normal Form For Geometry" in the JTS Technical + * Specifications. + */ + compareToSameClass(o: Geometry): number; + + /** + * Returns the first non-zero result of compareTo encountered as + * the two Collections are iterated over. If, by the time one of + * the iterations is complete, no non-zero result has been encountered, returns + * 0 if the other iteration is also complete. If b completes + * before a, a positive number is returned; if a before b, a + * negative number. + * + * @param {Array} + * a a Collection of Comparables. + * @param {Array} + * b a Collection of Comparables. + * @return {number} the first non-zero compareTo result, if any; + * otherwise, zero. + */ + compare(a: Array, b: Array): number; + + /** + * @param {jsts.geom.Coordinate} + * a first Coordinate to compare. + * @param {jsts.geom.Coordinate} + * b second Coordinate to compare. + * @param {number} + * tolerance tolerance when comparing. + * @return {boolean} true if equal. + */ + equal(a: Coordinate, b: Coordinate, tolerance: number): boolean; + + /** + * Returns a WKT representation of this geometry. + */ + toString(): string; + } + + /** + * Models an OGC SFS LinearRing. A LinearRing is a LineString + * which is both closed and simple. In other words, the first and last + * coordinate in the ring must be equal, and the interior of the ring must not + * self-intersect. Either orientation of the ring is allowed. + *

      + * A ring must have either 0 or 4 or more points. The first and last points + * must be equal (in 2D). If these conditions are not met, the constructors + * throw an {@link IllegalArgumentException} + */ + export class LinearRing extends LineString { + } + + export class LineString extends Geometry { + /** + * @constructor + */ + constructor(points: Array, factory?: any); + + /** + * @return {jsts.geom.Coordinate} The n'th coordinate of this + * jsts.geom.LineString. + * @param {int} + * n index. + */ + getCoordinateN(n: number): Coordinate; + + /** + * @return {jsts.geom.Point} The n'th point of this + * jsts.geom.LineString. + * @param {int} + * n index. + */ + getPointN(n: number): Point; + + /** + * @return {jsts.geom.Point} The first point of this + * jsts.geom.LineString. + */ + getStartPoint(): Point; + + /** + * @return {jsts.geom.Point} The last point of this + * jsts.geom.LineString. + */ + getEndPoint(): Point; + + /** + * @return {Boolean} true if LineString is Closed. + */ + isClosed(): boolean; + + /** + * @return {Boolean} true if LineString is a Ring. + */ + isRing(): boolean; + } + + export class Point extends Geometry { + /** + * @constructor + */ + constructor(coordinate: Coordinate, factory?: any); + + /** + * @return {number} x-axis value of this Point. + */ + getX(): number; + + /** + * @return {number} y-axis value of this Point. + */ + getY(): number; + + /** + * @return {Point} Reversed point is a cloned point. + */ + reverse(): Point; + } + + /** + * Represents a linear polygon, which may include holes. The shell and holes + * of the polygon are represented by {@link LinearRing}s. In a valid polygon, + * holes may touch the shell or other holes at a single point. However, no + * sequence of touching holes may split the polygon into two pieces. The + * orientation of the rings in the polygon does not matter. + * + * The shell and holes must conform to the assertions specified in the OpenGIS Simple Features + * Specification for SQL. + */ + export class Polygon extends Geometry { + /** + * @constructor + */ + constructor(shell: LinearRing, holes?: Array, factory?: any); + + /** + * Gets the exterior ring. + * + * @return {LinearRing} The exterior ring. + */ + getExteriorRing(): LinearRing; + + /** + * Gets the interior ring at the specified index. + * + * @param {number} n The interior ring index. + * + * @returns {LinearRing} The interior ring at the specified index. + */ + getInteriorRingN(n: number): LinearRing; + + /** + * Gets the number of interior rings. + * + * @return {number} The number of interior rings. + */ + getNumInteriorRing(): number; + } + } + + module io { + export class GeoJSONWriter { + /** + * Writes the GeoJSON representation of a {@link Geometry}. The + * The GeoJSON format is defined here. + *

      + * The GeoJSONWriter outputs coordinates rounded to the precision + * model. Only the maximum number of decimal places necessary to represent the + * ordinates to the required precision will be output. + *

      + * + * @see WKTReader + * @constructor + */ + constructor(); + + /** + * Converts a Geometry to its GeoJSON representation. + * + * @param {jsts.geom.Geometry} + * geometry a Geometry to process. + * @return {Object} The GeoJSON representation of the Geometry. + */ + write(geometry: geom.Geometry): Object; + } + + /** + * Converts a geometry in Well-Known Text format to a {@link Geometry}. + *

      + * WKTReader supports extracting Geometry objects + * from either {@link Reader}s or {@link String}s. This allows it to function + * as a parser to read Geometry objects from text blocks embedded + * in other data formats (e.g. XML). + *

      + *

      + * A WKTReader is parameterized by a GeometryFactory, + * to allow it to create Geometry objects of the appropriate + * implementation. In particular, the GeometryFactory determines + * the PrecisionModel and SRID that is used. + *

      + */ + export class WKTReader { + /** + * @constructor + */ + constructor(geometryFactory?: any); + + /** + * Reads a Well-Known Text representation of a {@link Geometry} + * + * @param {string} + * wkt a string (see the OpenGIS Simple Features + * Specification). + * @return {jsts.geom.Geometry} a Geometry read from + * string. + */ + read(wkt: string): geom.Geometry; + + reducePrecision(geometry: geom.Geometry): void; + } + } +} \ No newline at end of file From aa3f2581c70867f64f02ef15adc6ce86367af103 Mon Sep 17 00:00:00 2001 From: Aleksei Barbarosh Date: Fri, 16 Oct 2015 21:03:08 +0300 Subject: [PATCH 070/357] Update function scope. Add missed function toBeDefined. --- jest/jest.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jest/jest.d.ts b/jest/jest.d.ts index d500525b6..2ee765728 100644 --- a/jest/jest.d.ts +++ b/jest/jest.d.ts @@ -40,6 +40,7 @@ declare module jest { toBeFalsy(): boolean; toBeTruthy(): boolean; toBeNull(): boolean; + toBeDefined(): boolean; toBeUndefined(): boolean; toMatch(expected: RegExp): boolean; toContain(expected: string): boolean; From cdd23d1c610cc97f38bcd6e402b6da5edeea1bae Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 16 Oct 2015 13:21:46 -0700 Subject: [PATCH 071/357] Angular 2 typings are now distributed via NPM --- angular2/angular2-tests.ts | 42 +- angular2/angular2-tests.ts.tscparams | 1 - angular2/angular2.d.ts | 17110 +------------------------ angular2/http.d.ts | 1310 -- angular2/router.d.ts | 1330 -- angular2/test_lib.d.ts | 408 - 6 files changed, 10 insertions(+), 20191 deletions(-) delete mode 100644 angular2/angular2-tests.ts.tscparams delete mode 100644 angular2/http.d.ts delete mode 100644 angular2/router.d.ts delete mode 100644 angular2/test_lib.d.ts diff --git a/angular2/angular2-tests.ts b/angular2/angular2-tests.ts index a39cdcf79..1c64de9d7 100644 --- a/angular2/angular2-tests.ts +++ b/angular2/angular2-tests.ts @@ -1,43 +1,3 @@ /// -/// -import {Component, View, Directive, bootstrap, bind, NgFor, NgIf} from "angular2/angular2"; - -class Service { - -} -class Service2 { - -} - -class Cmp { - static annotations: any[]; -} -Cmp.annotations = [ - Component({ - selector: 'cmp', - bindings: [Service, bind(Service2).toValue(null)] - }), - View({ - template: '{{greeting}} world!', - directives: [NgFor, NgIf] - }), - Directive({ - selector: '[tooltip]', - inputs: [ - 'text: tooltip' - ], - outputs: [ - '(mouseenter):onMouseEnter()', - '(mouseleave):onMouseLeave()' - ] - }) -]; - -@Component({selector: 'cmp2'}) -@View({templateUrl: '/index.html'}) -class Cmp2 { - -} - -bootstrap(Cmp); +// No tests, because angular 2 typings are not in DefinitelyTyped. \ No newline at end of file diff --git a/angular2/angular2-tests.ts.tscparams b/angular2/angular2-tests.ts.tscparams deleted file mode 100644 index 3f0863ac6..000000000 --- a/angular2/angular2-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ ---experimentalDecorators --noImplicitAny --target ES5 diff --git a/angular2/angular2.d.ts b/angular2/angular2.d.ts index 616157aaf..356080998 100644 --- a/angular2/angular2.d.ts +++ b/angular2/angular2.d.ts @@ -1,17105 +1,13 @@ -// Type definitions for Angular v2.0.0-39 +// Type definitions for Angular 2 // Project: http://angular.io/ // Definitions by: angular team // Definitions: https://github.com/borisyankov/DefinitelyTyped -// *********************************************************** -// This file is generated by the Angular build process. -// Please do not create manual edits or send pull requests -// modifying this file. -// *********************************************************** - -// angular2/angular2 depends transitively on these libraries. -// If you don't have them installed you can install them using TSD -// https://github.com/DefinitelyTyped/tsd - -/// -// angular2/web_worker/worker depends transitively on these libraries. -// If you don't have them installed you can install them using TSD -// https://github.com/DefinitelyTyped/tsd - -/// -// angular2/web_worker/ui depends transitively on these libraries. -// If you don't have them installed you can install them using TSD -// https://github.com/DefinitelyTyped/tsd - -/// - - -interface Map {} - - -declare module ng { - // See https://github.com/Microsoft/TypeScript/issues/1168 - class BaseException /* extends Error */ { - message: string; - stack: string; - toString(): string; - } - interface InjectableReference {} -} - -declare module ngWorker { - // See https://github.com/Microsoft/TypeScript/issues/1168 - class BaseException /* extends Error */ { - message: string; - stack: string; - toString(): string; - } - interface InjectableReference {} -} - -declare module ngUi { - // See https://github.com/Microsoft/TypeScript/issues/1168 - class BaseException /* extends Error */ { - message: string; - stack: string; - toString(): string; - } - interface InjectableReference {} -} - - - - -declare module ng { - /** - * Declares an injectable parameter to be a live list of directives or variable - * bindings from the content children of a directive. - * - * ### Example ([live demo](http://plnkr.co/edit/lY9m8HLy7z06vDoUaSN2?p=preview)) - * - * Assume that `` component would like to get a list its children `` - * components as shown in this example: - * - * ```html - * - * ... - * {{o.text}} - * - * ``` - * - * The preferred solution is to query for `Pane` directives using this decorator. - * - * ```javascript - * @Component({ - * selector: 'pane', - * inputs: ['title'] - * }) - * @View(...) - * class Pane { - * title:string; - * } - * - * @Component({ - * selector: 'tabs' - * }) - * @View({ - * template: ` - *

        - *
      • {{pane.title}}
      • - *
      - * - * ` - * }) - * class Tabs { - * panes: QueryList; - * constructor(@Query(Pane) panes:QueryList) { - * this.panes = panes; - * } - * } - * ``` - * - * A query can look for variable bindings by passing in a string with desired binding symbol. - * - * ### Example ([live demo](http://plnkr.co/edit/sT2j25cH1dURAyBRCKx1?p=preview)) - * ```html - * - *
      ...
      - *
      - * - * @Component({ - * selector: 'foo' - * }) - * @View(...) - * class seeker { - * constructor(@Query('findme') elList: QueryList) {...} - * } - * ``` - * - * In this case the object that is injected depend on the type of the variable - * binding. It can be an ElementRef, a directive or a component. - * - * Passing in a comma separated list of variable bindings will query for all of them. - * - * ```html - * - *
      ...
      - *
      ...
      - *
      - * - * @Component({ - * selector: 'foo' - * }) - * @View(...) - * class Seeker { - * constructor(@Query('findMe, findMeToo') elList: QueryList) {...} - * } - * ``` - * - * Configure whether query looks for direct children or all descendants - * of the querying element, by using the `descendants` parameter. - * It is set to `false` by default. - * - * ### Example ([live demo](http://plnkr.co/edit/wtGeB977bv7qvA5FTYl9?p=preview)) - * ```html - * - * a - * b - * - * c - * - * - * ``` - * - * When querying for items, the first container will see only `a` and `b` by default, - * but with `Query(TextDirective, {descendants: true})` it will see `c` too. - * - * The queried directives are kept in a depth-first pre-order with respect to their - * positions in the DOM. - * - * Query does not look deep into any subcomponent views. - * - * Query is updated as part of the change-detection cycle. Since change detection - * happens after construction of a directive, QueryList will always be empty when observed in the - * constructor. - * - * The injected object is an unmodifiable live list. - * See {@link QueryList} for more details. - */ - class QueryMetadata extends DependencyMetadata { - - constructor(_selector: Type | string, {descendants, first}?: {descendants?: boolean, first?: boolean}); - - /** - * whether we want to query only direct children (false) or all - * children (true). - */ - descendants: boolean; - - first: boolean; - - /** - * always `false` to differentiate it with {@link ViewQueryMetadata}. - */ - isViewQuery: boolean; - - /** - * what this is querying for. - */ - selector: any; - - /** - * whether this is querying for a variable binding or a directive. - */ - isVarBindingQuery: boolean; - - /** - * returns a list of variable bindings this is querying for. - * Only applicable if this is a variable bindings query. - */ - varBindings: string[]; - - toString(): string; - - } - - - /** - * Configures a content query. - * - * Content queries are set before the `afterContentInit` callback is called. - * - * ### Example - * - * ``` - * @Directive({ - * selector: 'someDir' - * }) - * class SomeDir { - * @ContentChildren(ChildDirective) contentChildren: QueryList; - * - * afterContentInit() { - * // contentChildren is set - * } - * } - * ``` - */ - class ContentChildrenMetadata extends QueryMetadata { - - constructor(_selector: Type | string, {descendants}?: {descendants?: boolean}); - - } - - - /** - * Configures a content query. - * - * Content queries are set before the `afterContentInit` callback is called. - * - * ### Example - * - * ``` - * @Directive({ - * selector: 'someDir' - * }) - * class SomeDir { - * @ContentChild(ChildDirective) contentChild; - * - * afterContentInit() { - * // contentChild is set - * } - * } - * ``` - */ - class ContentChildMetadata extends QueryMetadata { - - constructor(_selector: Type | string); - - } - - - /** - * Configures a view query. - * - * View queries are set before the `afterViewInit` callback is called. - * - * ### Example - * - * ``` - * @Component({ - * selector: 'someDir' - * }) - * @View({templateUrl: 'someTemplate', directives: [ItemDirective]}) - * class SomeDir { - * @ViewChildren(ItemDirective) viewChildren: QueryList; - * - * afterViewInit() { - * // viewChildren is set - * } - * } - * ``` - */ - class ViewChildrenMetadata extends ViewQueryMetadata { - - constructor(_selector: Type | string); - - } - - - /** - * Similar to {@link QueryMetadata}, but querying the component view, instead of - * the content children. - * - * ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview)) - * - * ```javascript - * @Component({...}) - * @View({ - * template: ` - * a - * b - * c - * ` - * }) - * class MyComponent { - * shown: boolean; - * - * constructor(private @Query(Item) items:QueryList) { - * items.onChange(() => console.log(items.length)); - * } - * } - * ``` - * - * Supports the same querying parameters as {@link QueryMetadata}, except - * `descendants`. This always queries the whole view. - * - * As `shown` is flipped between true and false, items will contain zero of one - * items. - * - * Specifies that a {@link QueryList} should be injected. - * - * The injected object is an iterable and observable live list. - * See {@link QueryList} for more details. - */ - class ViewQueryMetadata extends QueryMetadata { - - constructor(_selector: Type | string, {descendants, first}?: {descendants?: boolean, first?: boolean}); - - /** - * always `true` to differentiate it with {@link QueryMetadata}. - */ - isViewQuery: any; - - toString(): string; - - } - - - /** - * Configures a view query. - * - * View queries are set before the `afterViewInit` callback is called. - * - * ### Example - * - * ``` - * @Component({ - * selector: 'someDir' - * }) - * @View({templateUrl: 'someTemplate', directives: [ItemDirective]}) - * class SomeDir { - * @ViewChild(ItemDirective) viewChild:ItemDirective; - * - * afterViewInit() { - * // viewChild is set - * } - * } - * ``` - */ - class ViewChildMetadata extends ViewQueryMetadata { - - constructor(_selector: Type | string); - - } - - - /** - * Specifies that a constant attribute value should be injected. - * - * The directive can inject constant string literals of host element attributes. - * - * ## Example - * - * Suppose we have an `` element and want to know its `type`. - * - * ```html - * - * ``` - * - * A decorator can inject string literal `text` like so: - * - * ```javascript - * @Directive({ - * selector: `input' - * }) - * class InputDirective { - * constructor(@Attribute('type') type) { - * // type would be `text` in this example - * } - * } - * ``` - */ - class AttributeMetadata extends DependencyMetadata { - - constructor(attributeName: string); - - attributeName: string; - - token: any; - - toString(): string; - - } - - - /** - * Declare reusable UI building blocks for an application. - * - * Each Angular component requires a single `@Component` and at least one `@View` annotation. The - * `@Component` - * annotation specifies when a component is instantiated, and which properties and hostListeners it - * binds to. - * - * When a component is instantiated, Angular - * - creates a shadow DOM for the component. - * - loads the selected template into the shadow DOM. - * - creates all the injectable objects configured with `bindings` and `viewBindings`. - * - * All template expressions and statements are then evaluated against the component instance. - * - * For details on the `@View` annotation, see {@link ViewMetadata}. - * - * ## Lifecycle hooks - * - * When the component class implements some {@link angular2/lifecycle_hooks} the callbacks are - * called by the change detection at defined points in time during the life of the component. - * - * ## Example - * - * ``` - * @Component({ - * selector: 'greet' - * }) - * @View({ - * template: 'Hello {{name}}!' - * }) - * class Greet { - * name: string; - * - * constructor() { - * this.name = 'World'; - * } - * } - * ``` - */ - class ComponentMetadata extends DirectiveMetadata { - - constructor({selector, inputs, outputs, properties, events, host, exportAs, moduleId, bindings, - viewBindings, changeDetection, queries}?: { - selector?: string, - inputs?: string[], - outputs?: string[], - properties?: string[], - events?: string[], - host?: {[key: string]: string}, - bindings?: any[], - exportAs?: string, - moduleId?: string, - viewBindings?: any[], - queries?: {[key: string]: any}, - changeDetection?: ChangeDetectionStrategy, - }); - - /** - * Defines the used change detection strategy. - * - * When a component is instantiated, Angular creates a change detector, which is responsible for - * propagating the component's bindings. - * - * The `changeDetection` property defines, whether the change detection will be checked every time - * or only when the component tells it to do so. - */ - changeDetection: ChangeDetectionStrategy; - - /** - * Defines the set of injectable objects that are visible to its view DOM children. - * - * ## Simple Example - * - * Here is an example of a class that can be injected: - * - * ``` - * class Greeter { - * greet(name:string) { - * return 'Hello ' + name + '!'; - * } - * } - * - * @Directive({ - * selector: 'needs-greeter' - * }) - * class NeedsGreeter { - * greeter:Greeter; - * - * constructor(greeter:Greeter) { - * this.greeter = greeter; - * } - * } - * - * @Component({ - * selector: 'greet', - * viewBindings: [ - * Greeter - * ] - * }) - * @View({ - * template: ``, - * directives: [NeedsGreeter] - * }) - * class HelloWorld { - * } - * - * ``` - */ - viewBindings: any[]; - - } - - - /** - * Directives allow you to attach behavior to elements in the DOM. - * - * {@link DirectiveMetadata}s with an embedded view are called {@link ComponentMetadata}s. - * - * A directive consists of a single directive annotation and a controller class. When the - * directive's `selector` matches - * elements in the DOM, the following steps occur: - * - * 1. For each directive, the `ElementInjector` attempts to resolve the directive's constructor - * arguments. - * 2. Angular instantiates directives for each matched element using `ElementInjector` in a - * depth-first order, - * as declared in the HTML. - * - * ## Understanding How Injection Works - * - * There are three stages of injection resolution. - * - *Pre-existing Injectors*: - * - The terminal {@link Injector} cannot resolve dependencies. It either throws an error or, if - * the dependency was - * specified as `@Optional`, returns `null`. - * - The platform injector resolves browser singleton resources, such as: cookies, title, - * location, and others. - * - *Component Injectors*: Each component instance has its own {@link Injector}, and they follow - * the same parent-child hierarchy - * as the component instances in the DOM. - * - *Element Injectors*: Each component instance has a Shadow DOM. Within the Shadow DOM each - * element has an `ElementInjector` - * which follow the same parent-child hierarchy as the DOM elements themselves. - * - * When a template is instantiated, it also must instantiate the corresponding directives in a - * depth-first order. The - * current `ElementInjector` resolves the constructor dependencies for each directive. - * - * Angular then resolves dependencies as follows, according to the order in which they appear in the - * {@link ViewMetadata}: - * - * 1. Dependencies on the current element - * 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM boundary - * 3. Dependencies on component injectors and their parents until it encounters the root component - * 4. Dependencies on pre-existing injectors - * - * - * The `ElementInjector` can inject other directives, element-specific special objects, or it can - * delegate to the parent - * injector. - * - * To inject other directives, declare the constructor parameter as: - * - `directive:DirectiveType`: a directive on the current element only - * - `@Host() directive:DirectiveType`: any directive that matches the type between the current - * element and the - * Shadow DOM root. - * - `@Query(DirectiveType) query:QueryList`: A live collection of direct child - * directives. - * - `@QueryDescendants(DirectiveType) query:QueryList`: A live collection of any - * child directives. - * - * To inject element-specific special objects, declare the constructor parameter as: - * - `element: ElementRef` to obtain a reference to logical element in the view. - * - `viewContainer: ViewContainerRef` to control child template instantiation, for - * {@link DirectiveMetadata} directives only - * - `bindingPropagation: BindingPropagation` to control change detection in a more granular way. - * - * ## Example - * - * The following example demonstrates how dependency injection resolves constructor arguments in - * practice. - * - * - * Assume this HTML template: - * - * ``` - *
      - *
      - *
      - *
      - *
      - *
      - *
      - *
      - *
      - *
      - * ``` - * - * With the following `dependency` decorator and `SomeService` injectable class. - * - * ``` - * @Injectable() - * class SomeService { - * } - * - * @Directive({ - * selector: '[dependency]', - * inputs: [ - * 'id: dependency' - * ] - * }) - * class Dependency { - * id:string; - * } - * ``` - * - * Let's step through the different ways in which `MyDirective` could be declared... - * - * - * ### No injection - * - * Here the constructor is declared with no arguments, therefore nothing is injected into - * `MyDirective`. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor() { - * } - * } - * ``` - * - * This directive would be instantiated with no dependencies. - * - * - * ### Component-level injection - * - * Directives can inject any injectable instance from the closest component injector or any of its - * parents. - * - * Here, the constructor declares a parameter, `someService`, and injects the `SomeService` type - * from the parent - * component's injector. - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(someService: SomeService) { - * } - * } - * ``` - * - * This directive would be instantiated with a dependency on `SomeService`. - * - * - * ### Injecting a directive from the current element - * - * Directives can inject other directives declared on the current element. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(dependency: Dependency) { - * expect(dependency.id).toEqual(3); - * } - * } - * ``` - * This directive would be instantiated with `Dependency` declared at the same element, in this case - * `dependency="3"`. - * - * ### Injecting a directive from any ancestor elements - * - * Directives can inject other directives declared on any ancestor element (in the current Shadow - * DOM), i.e. on the current element, the - * parent element, or its parents. - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(@Host() dependency: Dependency) { - * expect(dependency.id).toEqual(2); - * } - * } - * ``` - * - * `@Host` checks the current element, the parent, as well as its parents recursively. If - * `dependency="2"` didn't - * exist on the direct parent, this injection would - * have returned - * `dependency="1"`. - * - * - * ### Injecting a live collection of direct child directives - * - * - * A directive can also query for other child directives. Since parent directives are instantiated - * before child directives, a directive can't simply inject the list of child directives. Instead, - * the directive injects a {@link QueryList}, which updates its contents as children are added, - * removed, or moved by a directive that uses a {@link ViewContainerRef} such as a `ng-for`, an - * `ng-if`, or an `ng-switch`. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(@Query(Dependency) dependencies:QueryList) { - * } - * } - * ``` - * - * This directive would be instantiated with a {@link QueryList} which contains `Dependency` 4 and - * 6. Here, `Dependency` 5 would not be included, because it is not a direct child. - * - * ### Injecting a live collection of descendant directives - * - * By passing the descendant flag to `@Query` above, we can include the children of the child - * elements. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(@Query(Dependency, {descendants: true}) dependencies:QueryList) { - * } - * } - * ``` - * - * This directive would be instantiated with a Query which would contain `Dependency` 4, 5 and 6. - * - * ### Optional injection - * - * The normal behavior of directives is to return an error when a specified dependency cannot be - * resolved. If you - * would like to inject `null` on unresolved dependency instead, you can annotate that dependency - * with `@Optional()`. - * This explicitly permits the author of a template to treat some of the surrounding directives as - * optional. - * - * ``` - * @Directive({ selector: '[my-directive]' }) - * class MyDirective { - * constructor(@Optional() dependency:Dependency) { - * } - * } - * ``` - * - * This directive would be instantiated with a `Dependency` directive found on the current element. - * If none can be - * found, the injector supplies `null` instead of throwing an error. - * - * ## Example - * - * Here we use a decorator directive to simply define basic tool-tip behavior. - * - * ``` - * @Directive({ - * selector: '[tooltip]', - * inputs: [ - * 'text: tooltip' - * ], - * host: { - * '(mouseenter)': 'onMouseEnter()', - * '(mouseleave)': 'onMouseLeave()' - * } - * }) - * class Tooltip{ - * text:string; - * overlay:Overlay; // NOT YET IMPLEMENTED - * overlayManager:OverlayManager; // NOT YET IMPLEMENTED - * - * constructor(overlayManager:OverlayManager) { - * this.overlay = overlay; - * } - * - * onMouseEnter() { - * // exact signature to be determined - * this.overlay = this.overlayManager.open(text, ...); - * } - * - * onMouseLeave() { - * this.overlay.close(); - * this.overlay = null; - * } - * } - * ``` - * In our HTML template, we can then add this behavior to a `
      ` or any other element with the - * `tooltip` selector, - * like so: - * - * ``` - *
      - * ``` - * - * Directives can also control the instantiation, destruction, and positioning of inline template - * elements: - * - * A directive uses a {@link ViewContainerRef} to instantiate, insert, move, and destroy views at - * runtime. - * The {@link ViewContainerRef} is created as a result of `