From 1b718961940d46754115ef6015607fe29a30b521 Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Tue, 3 Mar 2015 16:35:24 -0500 Subject: [PATCH 001/274] Updated with new definitions for Foundation 5.2 -- patches from https://github.com/georgemarshall --- foundation/foundation.d.ts | 303 ++++++++++++++++++++++++++++--------- 1 file changed, 235 insertions(+), 68 deletions(-) diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index d74e954e6e..326574ff41 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Foundation 3.2 +// Type definitions for Foundation 5.2.1 // Project: http://foundation.zurb.com/ // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -6,83 +6,250 @@ /// -interface OrbitOptions { - animation?: string; - animationSpeed?: number; - timer?: boolean; - resetTimerOnClick?: boolean; - advanceSpeed?: number; - pauseOnHover?: boolean; - startClockOnMouseOut?: boolean; - startClockOnMouseOutAfter?: number; - directionalNav?: number; - captions?: number; - captionAnimation?: string; - captionAnimationSpeed?: number; - bullets?: boolean; - bulletThumbs?: boolean; - bulletThumbLocation?: string; - afterSlideChange?: () => void; - fluid?: boolean; +interface AbideOptions { + live_validate?: boolean; + focus_on_invalid?: boolean; + error_labels?: boolean; + timeout?: number; + patterns?: Object; + validators?: { + equalTo?: () => boolean; + }; } -interface RevealOptions { - animation?: string; - animationSpeed?: number; - closeOnBackgroundClick?: boolean; - dismissModalClass?: string; - /** - * The class of the modals background. - */ - bgClass?: string; - open?: () => void; +interface AccordionOptions { + active_class?: string; + multi_expand?: boolean; + toggleable?: boolean; +} + +interface AlertOptions { + callback?: () => void; +} + +interface ClearingOptions { + templates?: { + viewing?: string; + }; +} + +interface DropdownOptions { + active_class?: string; + align?: string; + is_hover?: boolean; opened?: () => void; - close?: () => void; closed?: () => void; - /** - * The modals background object. - */ - bg: JQuery; - /** - * The css property for when the modal is opened and closed. - */ - css: { - open: { - opacity?: number; - visibility?: string; - display: string; - }; - close: { - opacity: number; - visibility: string; - display: string; - }; +} + +interface EqualizerOptions { + use_tallest?: boolean; + before_height_change?: () => void; + after_height_change?: () => void; +} + +interface InterchangeOptions { + load_attr?: string; + named_queries?: Object; + directives?: { + replace?: (el: HTMLElement, path: string, trigger: (...args: any[]) => any) => any; }; } interface JoyrideOptions { - tipLocation?: string; - nubPosition?: string; - scrollSpeed?: number; + expose?: boolean; + modal?: boolean; + tip_location?: string; + nub_position?: string; + scroll_speed?: number; timer?: number; - startTimerOnClick?: boolean; - nextButton?: boolean; - tipAnimation?: string; - pauseAfter?: number[]; - tipAnimationFadeSpeed?: number; - cookieMonster?: boolean; - cookieName?: string; - cookieDomain?: boolean; - tipContainer?: string; - postRideCallback?: () => void; - postStepCallback?: () => void; + start_timer_on_click?: boolean; + start_offset?: number; + next_button?: boolean; + tip_animation?: string; + pause_after?: number[]; + exposed?: HTMLElement[]; + tip_animation_fade_speed?: number; + cookie_monster?: boolean; + cookie_name?: string; + cookie_domain?: boolean; + cookie_expires?: number; + tip_container?: string; + abort_on_close?: boolean; + tip_location_patterns?: { + top?: string[]; + bottom?: string[]; + left?: string[]; + right?: string[]; + }; + post_ride_callback?: () => void; + post_step_callback?: () => void; + pre_step_callback?: () => void; + pre_ride_callback?: () => void; + post_expose_callback?: () => void; + template?: { + link?: string; + timer?: string; + tip?: string; + wrapper?: string; + button?: string; + modal?: string; + expose?: string; + expose_cover?: string; + }; + expose_add_class?: string; +} + +interface MagellanOptions { + active_class?: string; + threshold?: number; + destination_threshold?: number; + throttle_delay?: number; +} + +interface OffCanvasOptions {} + +interface OrbitOptions { + animation?: string; + timer_speed?: number; + pause_on_hover?: boolean; + resume_on_mouseout?: boolean; + next_on_click?: boolean; + animation_speed?: number; + stack_on_small?: boolean; + navigation_arrows?: boolean; + slide_number?: boolean; + slide_number_text?: string; + container_class?: string; + stack_on_small_class?: string; + next_class?: string; + prev_class?: string; + timer_container_class?: string; + timer_paused_class?: string; + timer_progress_class?: string; + slides_container_class?: string; + preloader_class?: string; + slide_selector?: string; + bullets_container_class?: string; + bullets_active_class?: string; + slide_number_class?: string; + caption_class?: string; + active_slide_class?: string; + orbit_transition_class?: string; + bullets?: boolean; + circular?: boolean; + timer?: boolean; + variable_height?: boolean; + swipe?: boolean; + before_slide_change?: () => void; + after_slide_change?: () => void; +} + +interface RevealOptions { + animation?: string; + animation_speed?: number; + close_on_background_click?: boolean; + close_on_esc?: boolean; + dismiss_modal_class?: string; + bg_class?: string; + open?: () => void; + opened?: () => void; + close?: () => void; + closed?: () => void; + bg?: JQuery; + css?: { + open?: Object; + close?: Object; + }; +} + +interface SliderOptions { + start?: number; + end?: number; + step?: number; + initial?: number; + display_selector?: string; + on_change?: () => void; +} + +interface TabOptions { + active_class?: string; + callback?: () => void; + deep_linking?: boolean; + scroll_to_content?: boolean; +} + +interface TooltipOptions { + additional_inheritable_classes?: string[]; + tooltip_class?: string; + append_to?: string; + touch_close_text?: string; + disable_for_touch?: boolean; + hover_delay?: number; + tip_template?: (selector: string, content: string) => string; +} + +interface TopbarOptions{ + index?: number; + sticky_class?: string; + custom_back_text?: boolean; + back_text?: string; + is_hover?: boolean; + mobile_show_parent_link?: boolean; + scrolltop?: boolean; + sticky_on?: string; +} + +interface FoundationOptions { + abide?: AbideOptions; + accordion?: AccordionOptions; + alert?: AlertOptions; + clearing?: ClearingOptions; + dropdown?: DropdownOptions; + interchange?: InterchangeOptions; + joyride?: JoyrideOptions; + magellan?: MagellanOptions; + offcanvas: OffCanvasOptions; + orbit?: OrbitOptions; + reveal?: RevealOptions; + tab?: TabOptions; + tooltip?: TooltipOptions; + topbar?: TopbarOptions; +} + +interface FoundationStatic { + name: string; + version: string; + media_queries: Object; + stylesheet: CSSStyleSheet; + global: { + namespace: string; + }; + init(scope: JQuery): JQuery; + init(scope: JQuery, libraries: FoundationOptions): JQuery; + init(scope: JQuery, libraries: string, method: FoundationOptions): JQuery; + init(scope: JQuery, libraries: string, method: string, options: Object): JQuery; + init_lib(lib: any, args: any): (...args: any[]) => any; + patch(lib: any): void; + inherit(scope: JQuery, methods: string): void; + set_namespace(): void; + libs: Object; + utils: { + S(selector: any, context: any): JQuery; + throttle(func: (...args: any[]) => any, delay: number): (...args: any[]) => any; + debounce(func: (...args: any[]) => any, delay: number, immediate: boolean): (...args: any[]) => any; + data_options(el: JQuery): Object; + register_media(media: string, media_class: string): void; + add_custom_rule(rule: string, media: string): void; + image_loaded(images: JQuery, callback: (...args: any[]) => any): void; + random_str(length?: number): string; + }; } interface JQuery { - orbit(): JQuery; - orbit(OrbitOptions): JQuery; - reveal(): JQuery; - reveal(RevealOptions): JQuery; - joyride(): JQuery; - joyride(JoyrideOptions): JQuery; + foundation(): JQuery; + foundation(libraries: FoundationOptions): JQuery; + foundation(libraries: string, method: FoundationOptions): JQuery; + foundation(libraries: string, method: string, options: Object): JQuery; } + +declare var Foundation: FoundationStatic; From 1bcc72555ee6fa70353326ca3baf2d3b4b7be796 Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Wed, 4 Mar 2015 09:23:34 -0500 Subject: [PATCH 002/274] Updated definitions for Foundation 5.5.1. --- CONTRIBUTORS.md | 2 +- foundation/foundation-tests.ts | 379 ++++++++++++++++++++-- foundation/foundation.d.ts | 570 ++++++++++++++++++--------------- 3 files changed, 662 insertions(+), 289 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 88905c88a5..da416132c8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -220,7 +220,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam * [:link:](ion.rangeSlider/ion.rangeSlider.d.ts) [for Ion.RangeSlider](https://github.com/IonDen/ion.rangeSlider) by [Sixin Li](https://github.com/sixinli) * [:link:](form-data/form-data.d.ts) [form-data](https://github.com/felixge/node-form-data) by [Carlos Ballesteros Velasco](https://github.com/soywiz) * [:link:](formidable/formidable.d.ts) [Formidable](https://github.com/felixge/node-formidable) by [Wim Looman](https://github.com/Nemo157) -* [:link:](foundation/foundation.d.ts) [Foundation](http://foundation.zurb.com) by [Boris Yankov](https://github.com/borisyankov) +* [:link:](foundation/foundation.d.ts) [Foundation](http://foundation.zurb.com) by [Boris Yankov](https://github.com/borisyankov), [George Marshall](https://github.com/georgemarshall), [Boltmade](https://github.com/Boltmade) * [:link:](fpsmeter/FPSMeter.d.ts) [FPSmeter](http://darsa.in/fpsmeter) by [Aaron Lampros](http://github.com/alampros) * [:link:](from/from.d.ts) [from](https://github.com/dominictarr/from) by [Bart van der Schoor](https://github.com/Bartvds) * [:link:](fs-extra/fs-extra.d.ts) [fs-extra](https://github.com/jprichardson/node-fs-extra) by [midknight41](https://github.com/midknight41) diff --git a/foundation/foundation-tests.ts b/foundation/foundation-tests.ts index f64c83483a..c95b54a5bb 100644 --- a/foundation/foundation-tests.ts +++ b/foundation/foundation-tests.ts @@ -1,33 +1,346 @@ -/// -/// - -function test_orbit() { - $("#featured").orbit(); - $('#featured').orbit({ - animation: 'fade', - animationSpeed: 800, - timer: true, - resetTimerOnClick: false, - advanceSpeed: 4000, - pauseOnHover: false, - startClockOnMouseOut: false, - startClockOnMouseOutAfter: 1000, - directionalNav: true, - captions: true, - captionAnimation: 'fade', - captionAnimationSpeed: 800, - bullets: false, - bulletThumbs: false, - bulletThumbLocation: '', - afterSlideChange: function () { }, - fluid: true - }); -} - -function test_fluid() { - $("#myModal").reveal(); -} - -function test_joyride() { - $("#chooseID").joyride(); -} \ No newline at end of file +/// +/// + +function empty_callback() : void {} + +function plugin_list() { + return [ + "abide", + "accordion", + "alert", + "clearing", + "dropdown", + "interchange", + "joyride", + "magellan", + "offcanvas", + "orbit", + "reveal", + "slider", + "tab", + "tooltip", + "topbar" + ]; +} + +function abide_patterns() { + var patterns : AbidePatterns; + patterns.alpha = /^[a-zA-Z]+$/; + patterns.alpha_numeric = /^[a-zA-Z0-9]+$/; + patterns.integer = /^[-+]?\d+$/; + patterns.number = /^[-+]?[1-9]\d*$/; + patterns.card = /^[0-9]{8}$/; + patterns.cvv = /^([0-9]){3,4}$/; + patterns.email = /^test@example\.org$/; + patterns.url = /http:\/\/www\.google\.com\//; + patterns.domain = /definitelytyped\.org/; + patterns.datetime = /([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))/; + patterns.date = /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))/; + patterns.time = /(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}/; + patterns.dateISO = /\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/; + patterns.month_day_year = /(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d/; + patterns.color = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/; + return patterns; +} + +function abide_options() { + var opts : AbideOptions = {}; + opts.live_validate = false; + opts.validate_on_blur = true; + opts.focus_on_invalid = true; + opts.error_labels = true; + opts.timeout = 500; + opts.patterns = abide_patterns(); + opts.validators = { + diceRoll: function(el : HTMLInputElement, required : boolean, parent : HTMLElement) { + var possibilities = [true, false]; + return possibilities[Math.round(Math.random())]; + }, + isAllowed: function(el : HTMLInputElement, required : boolean, parent : HTMLElement) { + var possibilities = ["a@zurb.com", "b.zurb.com"]; + return possibilities.indexOf(el.value) > -1; + } + } + return opts; +} + +function accordion_options() { + var opts : AccordionOptions = {}; + opts.content_class = "content"; + opts.active_class = "class-name"; + opts.multi_expand = false; + opts.toggleable = true; + opts.callback = empty_callback; + return opts; +} + +function alert_options() { + var opts : AlertOptions = {}; + opts.callback = empty_callback; + return opts; +} + +function clearing_options() { + var opts : ClearingOptions = {}; + opts.templates = { + viewing : '
Some HTML
' + }; + opts.close_selectors = "#id-value, .class-name"; + opts.open_selectors = "li#id-value"; + opts.skip_selector = ".skip-class"; + opts.touch_label = "Display string"; + opts.init = true; + opts.locked = false; + return opts; +} + +function dropdown_options() { + var opts : DropdownOptions = {}; + opts.active_class = "class-name"; + opts.disabled_class = "disabled-class"; + opts.mega_class = "big"; + opts.align = "top"; + opts.is_hover = false; + opts.hover_timeout = 250; + opts.opened = empty_callback; + opts.closed = empty_callback; + return opts; +} + +function equalizer_options() { + var opts : EqualizerOptions = {}; + opts.use_tallest = true; + opts.equalize_on_stack = false; + return opts; +} + +function interchange_options() { + var opts : InterchangeOptions = {}; + opts.load_attr = "interchange"; + opts.named_queries = { + my_custom_query: "only screen and (max-width: 200px)" + }; + opts.directives = { + replace: empty_callback + }; + return opts; +} + +function joyride_options() { + var opts : JoyrideOptions = {}; + opts.expose = false; + opts.modal = true; + opts.keyboard = true; + opts.tip_location = "bottom"; + opts.nub_position = "left"; + opts.scroll_speed = 2500; + opts.scroll_animation = "lineaer"; + opts.timer = 100; + opts.start_timer_on_click = true; + opts.start_offset = 3; + opts.next_button = false; + opts.prev_button = false; + opts.tip_animation = "pulse"; + opts.pause_after = [4, 7, 10, 14]; + opts.exposed = ["#elm-id-one", "#elm-id-two"]; + opts.tip_animation_fade_speed = 100; + opts.cookie_monster = true; + opts.cookie_name = "ts_joyride"; + opts.cookie_domain = false; + opts.cookie_expires = 7; + opts.tip_container = '#header'; + opts.tip_location_patterns = { + top: ['botom'], + bottom: [], + left: ['right', 'top', 'bottom'], + right: ['left', 'top', 'bottom'] + }; + opts.post_ride_callback = empty_callback; + opts.post_step_callback = empty_callback; + opts.pre_step_callback = empty_callback; + opts.pre_ride_callback = empty_callback; + opts.post_expose_callback = empty_callback; + opts.template = { + link: '×', + timer: '
', + tip: '
', + wrapper: '
', + button: '', + prev_button: '', + modal: '
', + expose: '
', + expose_cover: '
' + }; + opts.expose_add_class = ".expose .class-name"; + return opts; +} + +function magellan_options() { + var opts : MagellanOptions = {}; + opts.active_class = ".active-element"; + opts.threshold = 20; + opts.destination_threshold = 30; + opts.throttle_delay = 24; + opts.fixed_top = 0; + opts.offset_by_height = false; + opts.duration = 1000; + opts.easing = "linear"; + return opts; +} + +function offcanvas_options() { + var opts : OffCanvasOptions = {}; + opts.open_method = "overlap_single"; + opts.close_on_click = true; + return opts; +} + +function orbit_options() { + var opts : OrbitOptions = {}; + opts.animation = 'slide'; + opts.timer_speed = 10000; + opts.pause_on_hover = true; + opts.resume_on_mouseout = false; + opts.next_on_click = true; + opts.animation_speed = 500; + opts.stack_on_small = false; + opts.navigation_arrows = true; + opts.slide_number = true; + opts.slide_number_text = 'of'; + opts.container_class = 'orbit-container'; + opts.stack_on_small_class = 'orbit-stack-on-small'; + opts.next_class = 'orbit-next'; + opts.prev_class = 'orbit-prev'; + opts.timer_container_class = 'orbit-timer'; + opts.timer_paused_class = 'paused'; + opts.timer_progress_class = 'orbit-progress'; + opts.slides_container_class = 'orbit-slides-container'; + opts.preloader_class = 'preloader'; + opts.slide_selector = 'li'; + opts.bullets_container_class = 'orbit-bullets'; + opts.bullets_active_class = 'active'; + opts.slide_number_class = 'orbit-slide-number'; + opts.caption_class = 'orbit-caption'; + opts.active_slide_class = 'active'; + opts.orbit_transition_class = 'orbit-transitioning'; + opts.bullets = true; + opts.circular = true; + opts.timer = true; + opts.variable_height = false; + opts.swipe = true; + opts.before_slide_change = empty_callback; + opts.after_slide_change = empty_callback; + return opts; +} + +function reveal_css_options() { + var opts : RevealCSSOptions = {}; + opts.opacity = 0; + opts.visibility = 'hidden'; + opts.display = "inline-block"; + return opts; +} + +function reveal_options() { + var opts : RevealOptions = {}; + opts.animation = "linear"; + opts.animation_speed = 500; + opts.close_on_background_click = false; + opts.dismiss_modal_class = ".modal-bye-bye"; + opts.multiple_opened = true; + opts.bg_class = ".modal-background"; + opts.root_element = "#element-id.element-class"; + opts.on_ajax_error = empty_callback; + opts.open = empty_callback; + opts.opened = empty_callback; + opts.close = empty_callback; + opts.close = empty_callback; + opts.bg = $("#my-modal-id .background"); + opts.css = { + open: reveal_css_options(), + close: reveal_css_options() + }; + return opts; +} + +function slider_options() { + var opts : SliderOptions; + opts.start = -1000; + opts.end = 1000; + opts.step = 50; + opts.precision = 4; + opts.initial = 0; + opts.vertical = false; + opts.trigger_input_change = true; + opts.on_change = empty_callback; + return opts; +} + +function tab_options() { + var opts : TabOptions = {}; + opts.active_class = "class-name"; + opts.callback = empty_callback; + opts.deep_linking = false; + opts.scroll_to_content = true; + opts.is_hover = false; + return opts; +} + +function tooltip_options() { + var opts : TooltipOptions = {}; + opts.additional_inheritable_classes = ["class1", "class2"]; + opts.tooltip_class = "tooltip"; + opts.append_to = "append-class"; + opts.touch_close_text = "Close"; + opts.disable_for_touch = true; + opts.hover_delay = 100; + opts.show_on = "all"; + opts.tip_template = function (selector, content) { + return '' + content + ''; + }; + return opts; +} + +function topbar_options() { + var opts : TopbarOptions = {}; + opts.index = 1; + opts.sticky_class = "top-bar"; + opts.custom_back_text = true; + opts.back_text = "Return"; + opts.is_hover = false; + opts.mobile_show_parent_link = true; + opts.scrolltop = true; + opts.sticky_on = "all"; + return opts; +} + +function foundation_options() : FoundationOptions { + var opts : FoundationOptions = {}; + opts.abide = abide_options(); + opts.accordion = accordion_options(); + opts.alert = alert_options(); + opts.clearing = clearing_options(); + opts.dropdown = dropdown_options(); + opts.equalizer = equalizer_options(); + opts.joyride = joyride_options(); + opts.magellan = magellan_options(); + opts.offcanvas = offcanvas_options(); + opts.orbit = orbit_options(); + opts.reveal = reveal_options(); + opts.slider = slider_options(); + opts.tab = tab_options(); + opts.tooltip = tooltip_options(); + opts.topbar = topbar_options(); + return opts; +} + +$(document).foundation(); + +$(document).foundation(foundation_options()); + +$(document).foundation("reflow"); +plugin_list().forEach((plugin) => $(document).foundation(plugin, "reflow")); + +$(document).foundation("slider", "set_value", 100); diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index 326574ff41..a531a051e1 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -1,255 +1,315 @@ -// Type definitions for Foundation 5.2.1 -// Project: http://foundation.zurb.com/ -// Definitions by: Boris Yankov -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - -/// - -interface AbideOptions { - live_validate?: boolean; - focus_on_invalid?: boolean; - error_labels?: boolean; - timeout?: number; - patterns?: Object; - validators?: { - equalTo?: () => boolean; - }; -} - -interface AccordionOptions { - active_class?: string; - multi_expand?: boolean; - toggleable?: boolean; -} - -interface AlertOptions { - callback?: () => void; -} - -interface ClearingOptions { - templates?: { - viewing?: string; - }; -} - -interface DropdownOptions { - active_class?: string; - align?: string; - is_hover?: boolean; - opened?: () => void; - closed?: () => void; -} - -interface EqualizerOptions { - use_tallest?: boolean; - before_height_change?: () => void; - after_height_change?: () => void; -} - -interface InterchangeOptions { - load_attr?: string; - named_queries?: Object; - directives?: { - replace?: (el: HTMLElement, path: string, trigger: (...args: any[]) => any) => any; - }; -} - -interface JoyrideOptions { - expose?: boolean; - modal?: boolean; - tip_location?: string; - nub_position?: string; - scroll_speed?: number; - timer?: number; - start_timer_on_click?: boolean; - start_offset?: number; - next_button?: boolean; - tip_animation?: string; - pause_after?: number[]; - exposed?: HTMLElement[]; - tip_animation_fade_speed?: number; - cookie_monster?: boolean; - cookie_name?: string; - cookie_domain?: boolean; - cookie_expires?: number; - tip_container?: string; - abort_on_close?: boolean; - tip_location_patterns?: { - top?: string[]; - bottom?: string[]; - left?: string[]; - right?: string[]; - }; - post_ride_callback?: () => void; - post_step_callback?: () => void; - pre_step_callback?: () => void; - pre_ride_callback?: () => void; - post_expose_callback?: () => void; - template?: { - link?: string; - timer?: string; - tip?: string; - wrapper?: string; - button?: string; - modal?: string; - expose?: string; - expose_cover?: string; - }; - expose_add_class?: string; -} - -interface MagellanOptions { - active_class?: string; - threshold?: number; - destination_threshold?: number; - throttle_delay?: number; -} - -interface OffCanvasOptions {} - -interface OrbitOptions { - animation?: string; - timer_speed?: number; - pause_on_hover?: boolean; - resume_on_mouseout?: boolean; - next_on_click?: boolean; - animation_speed?: number; - stack_on_small?: boolean; - navigation_arrows?: boolean; - slide_number?: boolean; - slide_number_text?: string; - container_class?: string; - stack_on_small_class?: string; - next_class?: string; - prev_class?: string; - timer_container_class?: string; - timer_paused_class?: string; - timer_progress_class?: string; - slides_container_class?: string; - preloader_class?: string; - slide_selector?: string; - bullets_container_class?: string; - bullets_active_class?: string; - slide_number_class?: string; - caption_class?: string; - active_slide_class?: string; - orbit_transition_class?: string; - bullets?: boolean; - circular?: boolean; - timer?: boolean; - variable_height?: boolean; - swipe?: boolean; - before_slide_change?: () => void; - after_slide_change?: () => void; -} - -interface RevealOptions { - animation?: string; - animation_speed?: number; - close_on_background_click?: boolean; - close_on_esc?: boolean; - dismiss_modal_class?: string; - bg_class?: string; - open?: () => void; - opened?: () => void; - close?: () => void; - closed?: () => void; - bg?: JQuery; - css?: { - open?: Object; - close?: Object; - }; -} - -interface SliderOptions { - start?: number; - end?: number; - step?: number; - initial?: number; - display_selector?: string; - on_change?: () => void; -} - -interface TabOptions { - active_class?: string; - callback?: () => void; - deep_linking?: boolean; - scroll_to_content?: boolean; -} - -interface TooltipOptions { - additional_inheritable_classes?: string[]; - tooltip_class?: string; - append_to?: string; - touch_close_text?: string; - disable_for_touch?: boolean; - hover_delay?: number; - tip_template?: (selector: string, content: string) => string; -} - -interface TopbarOptions{ - index?: number; - sticky_class?: string; - custom_back_text?: boolean; - back_text?: string; - is_hover?: boolean; - mobile_show_parent_link?: boolean; - scrolltop?: boolean; - sticky_on?: string; -} - -interface FoundationOptions { - abide?: AbideOptions; - accordion?: AccordionOptions; - alert?: AlertOptions; - clearing?: ClearingOptions; - dropdown?: DropdownOptions; - interchange?: InterchangeOptions; - joyride?: JoyrideOptions; - magellan?: MagellanOptions; - offcanvas: OffCanvasOptions; - orbit?: OrbitOptions; - reveal?: RevealOptions; - tab?: TabOptions; - tooltip?: TooltipOptions; - topbar?: TopbarOptions; -} - -interface FoundationStatic { - name: string; - version: string; - media_queries: Object; - stylesheet: CSSStyleSheet; - global: { - namespace: string; - }; - init(scope: JQuery): JQuery; - init(scope: JQuery, libraries: FoundationOptions): JQuery; - init(scope: JQuery, libraries: string, method: FoundationOptions): JQuery; - init(scope: JQuery, libraries: string, method: string, options: Object): JQuery; - init_lib(lib: any, args: any): (...args: any[]) => any; - patch(lib: any): void; - inherit(scope: JQuery, methods: string): void; - set_namespace(): void; - libs: Object; - utils: { - S(selector: any, context: any): JQuery; - throttle(func: (...args: any[]) => any, delay: number): (...args: any[]) => any; - debounce(func: (...args: any[]) => any, delay: number, immediate: boolean): (...args: any[]) => any; - data_options(el: JQuery): Object; - register_media(media: string, media_class: string): void; - add_custom_rule(rule: string, media: string): void; - image_loaded(images: JQuery, callback: (...args: any[]) => any): void; - random_str(length?: number): string; - }; -} - -interface JQuery { - foundation(): JQuery; - foundation(libraries: FoundationOptions): JQuery; - foundation(libraries: string, method: FoundationOptions): JQuery; - foundation(libraries: string, method: string, options: Object): JQuery; -} - -declare var Foundation: FoundationStatic; +// Type definitions for Foundation 5.5.1 +// Project : http://foundation.zurb.com/ +// Definitions by : Boris Yankov +// Definitions : https://github.com/borisyankov/DefinitelyTyped + + +/// + +// http://foundation.zurb.com/docs/components/abide.html#optional-javascript-configuration +interface AbidePatterns { + alpha? : RegExp; + alpha_numeric? : RegExp; + integer? : RegExp; + number? : RegExp; + card? : RegExp; + cvv? : RegExp; + email? : RegExp; + url? : RegExp; + domain? : RegExp; + datetime? : RegExp; + date? : RegExp; + time? : RegExp; + dateISO? : RegExp; + month_day_year? : RegExp; + color? : RegExp; +} + +interface AbideOptions { + live_validate? : boolean; + validate_on_blur? : boolean; + focus_on_invalid? : boolean; + error_labels? : boolean; + timeout? : number; + patterns? : AbidePatterns; + validators? : Object; +} + +// http://foundation.zurb.com/docs/components/accordion.html#optional-javascript-configuration +interface AccordionOptions { + content_class? : string; + active_class? : string; + multi_expand? : boolean; + toggleable? : boolean; + callback? : () => any; +} + +// http://foundation.zurb.com/docs/components/alert_boxes.html +interface AlertOptions { + callback? : () => any; +} + +// http://foundation.zurb.com/docs/components/clearing.html#optional-javascript-configuration +interface ClearingOptions { + templates? : Object; + close_selectors? : string; + open_selectors? : string; + skip_selector? : string; + touch_label? : string; + init? : boolean; + locked? : boolean; +} + +// http://foundation.zurb.com/docs/components/dropdown.html#optional-javascript-configuration +interface DropdownOptions { + active_class? : string; + disabled_class? : string; + mega_class? : string; + align? : string; + is_hover? : boolean; + hover_timeout? : number; + opened? : () => any; + closed? : () => any; +} + +// http://foundation.zurb.com/docs/components/equalizer.html#optional-javascript-configuration +interface EqualizerOptions { + use_tallest? : boolean; + equalize_on_stack? : boolean; +} + +// http://foundation.zurb.com/docs/components/interchange.html#custom-named-queries +interface InterchangeOptions { + load_attr? : string; + named_queries? : Object; + directives? : Object; +} + +// http://foundation.zurb.com/docs/components/joyride.html#optional-javascript-configuration +interface JoyrideOptions { + expose? : boolean; + modal? : boolean; + keyboard? : boolean; + tip_location? : string; + nub_position? : string; + scroll_speed? : number; + scroll_animation? : string; + timer? : number; + start_timer_on_click? : boolean; + start_offset? : number; + next_button? : boolean; + prev_button? : boolean; + tip_animation? : string; + pause_after? : number[]; + exposed? : string[]; + tip_animation_fade_speed? : number; + cookie_monster? : boolean; + cookie_name? : string; + cookie_domain? : boolean; + cookie_expires? : number; + tip_container? : string; + tip_location_patterns? : { + top? : string[]; + bottom? : string[]; + left? : string[]; + right? : string[]; + }; + post_ride_callback? : () => void; + post_step_callback? : () => void; + pre_step_callback? : () => void; + pre_ride_callback? : () => void; + post_expose_callback? : () => void; + template? : { + link? : string; + timer? : string; + tip? : string; + wrapper? : string; + button? : string; + modal? : string; + expose? : string; + expose_cover? : string; + }; + expose_add_class? : string; +} + +// http://foundation.zurb.com/docs/components/magellan.html#js +interface MagellanOptions { + active_class? : string; + threshold? : number; + destination_threshold? : number; + throttle_delay? : number; + fixed_top? : number; + offset_by_height? : boolean; + duration? : number; + easing? : string; +} + +// http://foundation.zurb.com/docs/components/offcanvas.html#optional-javascript-configuration +interface OffCanvasOptions { + open_method? : string; + close_on_click? : boolean; +} + +// http://foundation.zurb.com/docs/components/orbit.html#advanced +interface OrbitOptions { + animation? : string; + timer_speed? : number; + pause_on_hover? : boolean; + resume_on_mouseout? : boolean; + next_on_click? : boolean; + animation_speed? : number; + stack_on_small? : boolean; + navigation_arrows? : boolean; + slide_number? : boolean; + slide_number_text? : string; + container_class? : string; + stack_on_small_class? : string; + next_class? : string; + prev_class? : string; + timer_container_class? : string; + timer_paused_class? : string; + timer_progress_class? : string; + slides_container_class? : string; + preloader_class? : string; + slide_selector? : string; + bullets_container_class? : string; + bullets_active_class? : string; + slide_number_class? : string; + caption_class? : string; + active_slide_class? : string; + orbit_transition_class? : string; + bullets? : boolean; + circular? : boolean; + timer? : boolean; + variable_height? : boolean; + swipe? : boolean; + before_slide_change? : () => any; + after_slide_change? : () => any; +} + +// http://foundation.zurb.com/docs/components/reveal.html +interface RevealCSSOptions { + opacity? : number; + visibility? : string; + display? : string; +} + +interface RevealOptions { + animation? : string; + animation_speed? : number; + close_on_background_click? : boolean; + dismiss_modal_class? : string; + multiple_opened? : boolean; + bg_class? : string; + root_element? : string; + on_ajax_error? : () => any; + open? : () => any; + opened? : () => any; + close? : () => any; + closed? : () => any; + bg? : JQuery; + css? : { + open? : RevealCSSOptions; + close? : RevealCSSOptions; + }; +} + +// http://foundation.zurb.com/docs/components/range_slider.html +interface SliderOptions { + start? : number; + end? : number; + step? : number; + precision? : number; + initial? : number; + vertical? : boolean; + trigger_input_change? : boolean; + on_change? : () => any; +} + +// http://foundation.zurb.com/docs/components/tabs.html +interface TabOptions { + active_class? : string; + callback? : () => any; + deep_linking? : boolean; + scroll_to_content? : boolean; + is_hover? : boolean; +} + +interface TooltipOptions { + additional_inheritable_classes? : string[]; + tooltip_class? : string; + append_to? : string; + touch_close_text? : string; + disable_for_touch? : boolean; + hover_delay? : number; + show_on? : string; + tip_template? : (selector : string, content : string) => string; +} + +interface TopbarOptions { + index? : number; + sticky_class? : string; + custom_back_text? : boolean; + back_text? : string; + is_hover? : boolean; + mobile_show_parent_link? : boolean; + scrolltop? : boolean; + sticky_on? : string; +} + +interface FoundationOptions { + abide? : AbideOptions; + accordion? : AccordionOptions; + alert? : AlertOptions; + clearing? : ClearingOptions; + dropdown? : DropdownOptions; + equalizer? : EqualizerOptions; + interchange? : InterchangeOptions; + joyride? : JoyrideOptions; + magellan? : MagellanOptions; + offcanvas? : OffCanvasOptions; + orbit? : OrbitOptions; + reveal? : RevealOptions; + slider? : SliderOptions; + tab? : TabOptions; + tooltip? : TooltipOptions; + topbar? : TopbarOptions; +} + +interface FoundationStatic { + name : string; + version : string; + media_queries : Object; + stylesheet : CSSStyleSheet; + global : { + namespace : string; + }; + init(scope : JQuery) : JQuery; + init(scope : JQuery, libraries : FoundationOptions) : JQuery; + init(scope : JQuery, libraries : string, method : FoundationOptions) : JQuery; + init(scope : JQuery, libraries : string, method : string, options : Object) : JQuery; + init_lib(lib : any, args : any) : (...args : any[]) => any; + patch(lib : any) : void; + inherit(scope : JQuery, methods : string) : void; + set_namespace() : void; + libs : any; + utils : { + S(selector : any, context : any) : JQuery; + throttle(func : (...args : any[]) => any, delay : number) : (...args : any[]) => any; + debounce(func : (...args : any[]) => any, delay : number, immediate : boolean) : (...args : any[]) => any; + data_options(el : JQuery) : Object; + register_media(media : string, media_class : string) : void; + add_custom_rule(rule : string, media : string) : void; + image_loaded(images : JQuery, callback : (...args : any[]) => any) : void; + random_str(length? : number) : string; + }; +} + +interface JQuery { + foundation() : JQuery; + foundation(libraries : FoundationOptions | string) : JQuery; + foundation(libraries : string, method : FoundationOptions | string) : JQuery; + foundation(libraries : string, method : string, options : Object) : JQuery; +} + +declare var Foundation : FoundationStatic; From 25cad4036620470b17be460cdf823319b345634a Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Sun, 8 Mar 2015 13:47:14 -0400 Subject: [PATCH 003/274] Fixed up header to meet spec requirements. --- foundation/foundation.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index a531a051e1..0f4ef3be1f 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -1,7 +1,7 @@ -// Type definitions for Foundation 5.5.1 -// Project : http://foundation.zurb.com/ -// Definitions by : Boris Yankov -// Definitions : https://github.com/borisyankov/DefinitelyTyped +// Type definitions for Foundation v5.5.1 +// Project: http://foundation.zurb.com/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 9e24a051107337c96c1d47b15b540d5e6b75610e Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Sun, 8 Mar 2015 13:54:16 -0400 Subject: [PATCH 004/274] Namespace the various Foundation option interfaces to prevent conflicts. --- foundation/foundation-tests.ts | 38 ++++++++--------- foundation/foundation.d.ts | 74 +++++++++++++++++----------------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/foundation/foundation-tests.ts b/foundation/foundation-tests.ts index c95b54a5bb..062fcc04ba 100644 --- a/foundation/foundation-tests.ts +++ b/foundation/foundation-tests.ts @@ -24,7 +24,7 @@ function plugin_list() { } function abide_patterns() { - var patterns : AbidePatterns; + var patterns : FoundationAbidePatterns; patterns.alpha = /^[a-zA-Z]+$/; patterns.alpha_numeric = /^[a-zA-Z0-9]+$/; patterns.integer = /^[-+]?\d+$/; @@ -44,7 +44,7 @@ function abide_patterns() { } function abide_options() { - var opts : AbideOptions = {}; + var opts : FoundationAbideOptions = {}; opts.live_validate = false; opts.validate_on_blur = true; opts.focus_on_invalid = true; @@ -65,7 +65,7 @@ function abide_options() { } function accordion_options() { - var opts : AccordionOptions = {}; + var opts : FoundationAccordionOptions = {}; opts.content_class = "content"; opts.active_class = "class-name"; opts.multi_expand = false; @@ -75,13 +75,13 @@ function accordion_options() { } function alert_options() { - var opts : AlertOptions = {}; + var opts : FoundationAlertOptions = {}; opts.callback = empty_callback; return opts; } function clearing_options() { - var opts : ClearingOptions = {}; + var opts : FoundationClearingOptions = {}; opts.templates = { viewing : '
Some HTML
' }; @@ -95,7 +95,7 @@ function clearing_options() { } function dropdown_options() { - var opts : DropdownOptions = {}; + var opts : FoundationDropdownOptions = {}; opts.active_class = "class-name"; opts.disabled_class = "disabled-class"; opts.mega_class = "big"; @@ -108,14 +108,14 @@ function dropdown_options() { } function equalizer_options() { - var opts : EqualizerOptions = {}; + var opts : FoundationEqualizerOptions = {}; opts.use_tallest = true; opts.equalize_on_stack = false; return opts; } function interchange_options() { - var opts : InterchangeOptions = {}; + var opts : FoundationInterchangeOptions = {}; opts.load_attr = "interchange"; opts.named_queries = { my_custom_query: "only screen and (max-width: 200px)" @@ -127,7 +127,7 @@ function interchange_options() { } function joyride_options() { - var opts : JoyrideOptions = {}; + var opts : FoundationJoyrideOptions = {}; opts.expose = false; opts.modal = true; opts.keyboard = true; @@ -176,7 +176,7 @@ function joyride_options() { } function magellan_options() { - var opts : MagellanOptions = {}; + var opts : FoundationMagellanOptions = {}; opts.active_class = ".active-element"; opts.threshold = 20; opts.destination_threshold = 30; @@ -189,14 +189,14 @@ function magellan_options() { } function offcanvas_options() { - var opts : OffCanvasOptions = {}; + var opts : FoundationOffCanvasOptions = {}; opts.open_method = "overlap_single"; opts.close_on_click = true; return opts; } function orbit_options() { - var opts : OrbitOptions = {}; + var opts : FoundationOrbitOptions = {}; opts.animation = 'slide'; opts.timer_speed = 10000; opts.pause_on_hover = true; @@ -234,7 +234,7 @@ function orbit_options() { } function reveal_css_options() { - var opts : RevealCSSOptions = {}; + var opts : FoundationRevealCSSOptions = {}; opts.opacity = 0; opts.visibility = 'hidden'; opts.display = "inline-block"; @@ -242,7 +242,7 @@ function reveal_css_options() { } function reveal_options() { - var opts : RevealOptions = {}; + var opts : FoundationRevealOptions = {}; opts.animation = "linear"; opts.animation_speed = 500; opts.close_on_background_click = false; @@ -264,7 +264,7 @@ function reveal_options() { } function slider_options() { - var opts : SliderOptions; + var opts : FoundationSliderOptions; opts.start = -1000; opts.end = 1000; opts.step = 50; @@ -277,7 +277,7 @@ function slider_options() { } function tab_options() { - var opts : TabOptions = {}; + var opts : FoundationTabOptions = {}; opts.active_class = "class-name"; opts.callback = empty_callback; opts.deep_linking = false; @@ -287,7 +287,7 @@ function tab_options() { } function tooltip_options() { - var opts : TooltipOptions = {}; + var opts : FoundationTooltipOptions = {}; opts.additional_inheritable_classes = ["class1", "class2"]; opts.tooltip_class = "tooltip"; opts.append_to = "append-class"; @@ -304,7 +304,7 @@ function tooltip_options() { } function topbar_options() { - var opts : TopbarOptions = {}; + var opts : FoundationTopbarOptions = {}; opts.index = 1; opts.sticky_class = "top-bar"; opts.custom_back_text = true; @@ -316,7 +316,7 @@ function topbar_options() { return opts; } -function foundation_options() : FoundationOptions { +function foundation_options() { var opts : FoundationOptions = {}; opts.abide = abide_options(); opts.accordion = accordion_options(); diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index 0f4ef3be1f..ad3696f019 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -7,7 +7,7 @@ /// // http://foundation.zurb.com/docs/components/abide.html#optional-javascript-configuration -interface AbidePatterns { +interface FoundationAbidePatterns { alpha? : RegExp; alpha_numeric? : RegExp; integer? : RegExp; @@ -25,18 +25,18 @@ interface AbidePatterns { color? : RegExp; } -interface AbideOptions { +interface FoundationAbideOptions { live_validate? : boolean; validate_on_blur? : boolean; focus_on_invalid? : boolean; error_labels? : boolean; timeout? : number; - patterns? : AbidePatterns; + patterns? : FoundationAbidePatterns; validators? : Object; } // http://foundation.zurb.com/docs/components/accordion.html#optional-javascript-configuration -interface AccordionOptions { +interface FoundationAccordionOptions { content_class? : string; active_class? : string; multi_expand? : boolean; @@ -45,12 +45,12 @@ interface AccordionOptions { } // http://foundation.zurb.com/docs/components/alert_boxes.html -interface AlertOptions { +interface FoundationAlertOptions { callback? : () => any; } // http://foundation.zurb.com/docs/components/clearing.html#optional-javascript-configuration -interface ClearingOptions { +interface FoundationClearingOptions { templates? : Object; close_selectors? : string; open_selectors? : string; @@ -61,7 +61,7 @@ interface ClearingOptions { } // http://foundation.zurb.com/docs/components/dropdown.html#optional-javascript-configuration -interface DropdownOptions { +interface FoundationDropdownOptions { active_class? : string; disabled_class? : string; mega_class? : string; @@ -73,20 +73,20 @@ interface DropdownOptions { } // http://foundation.zurb.com/docs/components/equalizer.html#optional-javascript-configuration -interface EqualizerOptions { +interface FoundationEqualizerOptions { use_tallest? : boolean; equalize_on_stack? : boolean; } // http://foundation.zurb.com/docs/components/interchange.html#custom-named-queries -interface InterchangeOptions { +interface FoundationInterchangeOptions { load_attr? : string; named_queries? : Object; directives? : Object; } // http://foundation.zurb.com/docs/components/joyride.html#optional-javascript-configuration -interface JoyrideOptions { +interface FoundationJoyrideOptions { expose? : boolean; modal? : boolean; keyboard? : boolean; @@ -133,7 +133,7 @@ interface JoyrideOptions { } // http://foundation.zurb.com/docs/components/magellan.html#js -interface MagellanOptions { +interface FoundationMagellanOptions { active_class? : string; threshold? : number; destination_threshold? : number; @@ -145,13 +145,13 @@ interface MagellanOptions { } // http://foundation.zurb.com/docs/components/offcanvas.html#optional-javascript-configuration -interface OffCanvasOptions { +interface FoundationOffCanvasOptions { open_method? : string; close_on_click? : boolean; } // http://foundation.zurb.com/docs/components/orbit.html#advanced -interface OrbitOptions { +interface FoundationOrbitOptions { animation? : string; timer_speed? : number; pause_on_hover? : boolean; @@ -188,13 +188,13 @@ interface OrbitOptions { } // http://foundation.zurb.com/docs/components/reveal.html -interface RevealCSSOptions { +interface FoundationRevealCSSOptions { opacity? : number; visibility? : string; display? : string; } -interface RevealOptions { +interface FoundationRevealOptions { animation? : string; animation_speed? : number; close_on_background_click? : boolean; @@ -209,13 +209,13 @@ interface RevealOptions { closed? : () => any; bg? : JQuery; css? : { - open? : RevealCSSOptions; - close? : RevealCSSOptions; + open? : FoundationRevealCSSOptions; + close? : FoundationRevealCSSOptions; }; } // http://foundation.zurb.com/docs/components/range_slider.html -interface SliderOptions { +interface FoundationSliderOptions { start? : number; end? : number; step? : number; @@ -227,7 +227,7 @@ interface SliderOptions { } // http://foundation.zurb.com/docs/components/tabs.html -interface TabOptions { +interface FoundationTabOptions { active_class? : string; callback? : () => any; deep_linking? : boolean; @@ -235,7 +235,7 @@ interface TabOptions { is_hover? : boolean; } -interface TooltipOptions { +interface FoundationTooltipOptions { additional_inheritable_classes? : string[]; tooltip_class? : string; append_to? : string; @@ -246,7 +246,7 @@ interface TooltipOptions { tip_template? : (selector : string, content : string) => string; } -interface TopbarOptions { +interface FoundationTopbarOptions { index? : number; sticky_class? : string; custom_back_text? : boolean; @@ -258,22 +258,22 @@ interface TopbarOptions { } interface FoundationOptions { - abide? : AbideOptions; - accordion? : AccordionOptions; - alert? : AlertOptions; - clearing? : ClearingOptions; - dropdown? : DropdownOptions; - equalizer? : EqualizerOptions; - interchange? : InterchangeOptions; - joyride? : JoyrideOptions; - magellan? : MagellanOptions; - offcanvas? : OffCanvasOptions; - orbit? : OrbitOptions; - reveal? : RevealOptions; - slider? : SliderOptions; - tab? : TabOptions; - tooltip? : TooltipOptions; - topbar? : TopbarOptions; + abide? : FoundationAbideOptions; + accordion? : FoundationAccordionOptions; + alert? : FoundationAlertOptions; + clearing? : FoundationClearingOptions; + dropdown? : FoundationDropdownOptions; + equalizer? : FoundationEqualizerOptions; + interchange? : FoundationInterchangeOptions; + joyride? : FoundationJoyrideOptions; + magellan? : FoundationMagellanOptions; + offcanvas? : FoundationOffCanvasOptions; + orbit? : FoundationOrbitOptions; + reveal? : FoundationRevealOptions; + slider? : FoundationSliderOptions; + tab? : FoundationTabOptions; + tooltip? : FoundationTooltipOptions; + topbar? : FoundationTopbarOptions; } interface FoundationStatic { From 7dd9a59ab0c37c19178735dfa02b2ad69dde7d82 Mon Sep 17 00:00:00 2001 From: Justin Filip Date: Sun, 15 Mar 2015 14:16:25 -0400 Subject: [PATCH 005/274] Don't pollute the global namespace with interfaces used for Foundation. --- foundation/foundation-tests.ts | 38 +-- foundation/foundation.d.ts | 564 +++++++++++++++++---------------- 2 files changed, 302 insertions(+), 300 deletions(-) diff --git a/foundation/foundation-tests.ts b/foundation/foundation-tests.ts index 062fcc04ba..9706fbf97c 100644 --- a/foundation/foundation-tests.ts +++ b/foundation/foundation-tests.ts @@ -24,7 +24,7 @@ function plugin_list() { } function abide_patterns() { - var patterns : FoundationAbidePatterns; + var patterns : Foundation.AbidePatterns = {}; patterns.alpha = /^[a-zA-Z]+$/; patterns.alpha_numeric = /^[a-zA-Z0-9]+$/; patterns.integer = /^[-+]?\d+$/; @@ -44,7 +44,7 @@ function abide_patterns() { } function abide_options() { - var opts : FoundationAbideOptions = {}; + var opts : Foundation.AbideOptions = {}; opts.live_validate = false; opts.validate_on_blur = true; opts.focus_on_invalid = true; @@ -65,7 +65,7 @@ function abide_options() { } function accordion_options() { - var opts : FoundationAccordionOptions = {}; + var opts : Foundation.AccordionOptions = {}; opts.content_class = "content"; opts.active_class = "class-name"; opts.multi_expand = false; @@ -75,13 +75,13 @@ function accordion_options() { } function alert_options() { - var opts : FoundationAlertOptions = {}; + var opts : Foundation.AlertOptions = {}; opts.callback = empty_callback; return opts; } function clearing_options() { - var opts : FoundationClearingOptions = {}; + var opts : Foundation.ClearingOptions = {}; opts.templates = { viewing : '
Some HTML
' }; @@ -95,7 +95,7 @@ function clearing_options() { } function dropdown_options() { - var opts : FoundationDropdownOptions = {}; + var opts : Foundation.DropdownOptions = {}; opts.active_class = "class-name"; opts.disabled_class = "disabled-class"; opts.mega_class = "big"; @@ -108,14 +108,14 @@ function dropdown_options() { } function equalizer_options() { - var opts : FoundationEqualizerOptions = {}; + var opts : Foundation.EqualizerOptions = {}; opts.use_tallest = true; opts.equalize_on_stack = false; return opts; } function interchange_options() { - var opts : FoundationInterchangeOptions = {}; + var opts : Foundation.InterchangeOptions = {}; opts.load_attr = "interchange"; opts.named_queries = { my_custom_query: "only screen and (max-width: 200px)" @@ -127,7 +127,7 @@ function interchange_options() { } function joyride_options() { - var opts : FoundationJoyrideOptions = {}; + var opts : Foundation.JoyrideOptions = {}; opts.expose = false; opts.modal = true; opts.keyboard = true; @@ -176,7 +176,7 @@ function joyride_options() { } function magellan_options() { - var opts : FoundationMagellanOptions = {}; + var opts : Foundation.MagellanOptions = {}; opts.active_class = ".active-element"; opts.threshold = 20; opts.destination_threshold = 30; @@ -189,14 +189,14 @@ function magellan_options() { } function offcanvas_options() { - var opts : FoundationOffCanvasOptions = {}; + var opts : Foundation.OffCanvasOptions = {}; opts.open_method = "overlap_single"; opts.close_on_click = true; return opts; } function orbit_options() { - var opts : FoundationOrbitOptions = {}; + var opts : Foundation.OrbitOptions = {}; opts.animation = 'slide'; opts.timer_speed = 10000; opts.pause_on_hover = true; @@ -234,7 +234,7 @@ function orbit_options() { } function reveal_css_options() { - var opts : FoundationRevealCSSOptions = {}; + var opts : Foundation.RevealCSSOptions = {}; opts.opacity = 0; opts.visibility = 'hidden'; opts.display = "inline-block"; @@ -242,7 +242,7 @@ function reveal_css_options() { } function reveal_options() { - var opts : FoundationRevealOptions = {}; + var opts : Foundation.RevealOptions = {}; opts.animation = "linear"; opts.animation_speed = 500; opts.close_on_background_click = false; @@ -264,7 +264,7 @@ function reveal_options() { } function slider_options() { - var opts : FoundationSliderOptions; + var opts : Foundation.SliderOptions = {}; opts.start = -1000; opts.end = 1000; opts.step = 50; @@ -277,7 +277,7 @@ function slider_options() { } function tab_options() { - var opts : FoundationTabOptions = {}; + var opts : Foundation.TabOptions = {}; opts.active_class = "class-name"; opts.callback = empty_callback; opts.deep_linking = false; @@ -287,7 +287,7 @@ function tab_options() { } function tooltip_options() { - var opts : FoundationTooltipOptions = {}; + var opts : Foundation.TooltipOptions = {}; opts.additional_inheritable_classes = ["class1", "class2"]; opts.tooltip_class = "tooltip"; opts.append_to = "append-class"; @@ -304,7 +304,7 @@ function tooltip_options() { } function topbar_options() { - var opts : FoundationTopbarOptions = {}; + var opts : Foundation.TopbarOptions = {}; opts.index = 1; opts.sticky_class = "top-bar"; opts.custom_back_text = true; @@ -317,7 +317,7 @@ function topbar_options() { } function foundation_options() { - var opts : FoundationOptions = {}; + var opts : Foundation.Options = {}; opts.abide = abide_options(); opts.accordion = accordion_options(); opts.alert = alert_options(); diff --git a/foundation/foundation.d.ts b/foundation/foundation.d.ts index ad3696f019..c2dc4fc244 100644 --- a/foundation/foundation.d.ts +++ b/foundation/foundation.d.ts @@ -6,310 +6,312 @@ /// -// http://foundation.zurb.com/docs/components/abide.html#optional-javascript-configuration -interface FoundationAbidePatterns { - alpha? : RegExp; - alpha_numeric? : RegExp; - integer? : RegExp; - number? : RegExp; - card? : RegExp; - cvv? : RegExp; - email? : RegExp; - url? : RegExp; - domain? : RegExp; - datetime? : RegExp; - date? : RegExp; - time? : RegExp; - dateISO? : RegExp; - month_day_year? : RegExp; - color? : RegExp; -} +declare module Foundation { + // http://foundation.zurb.com/docs/components/abide.html#optional-javascript-configuration + interface AbidePatterns { + alpha? : RegExp; + alpha_numeric? : RegExp; + integer? : RegExp; + number? : RegExp; + card? : RegExp; + cvv? : RegExp; + email? : RegExp; + url? : RegExp; + domain? : RegExp; + datetime? : RegExp; + date? : RegExp; + time? : RegExp; + dateISO? : RegExp; + month_day_year? : RegExp; + color? : RegExp; + } -interface FoundationAbideOptions { - live_validate? : boolean; - validate_on_blur? : boolean; - focus_on_invalid? : boolean; - error_labels? : boolean; - timeout? : number; - patterns? : FoundationAbidePatterns; - validators? : Object; -} + interface AbideOptions { + live_validate? : boolean; + validate_on_blur? : boolean; + focus_on_invalid? : boolean; + error_labels? : boolean; + timeout? : number; + patterns? : AbidePatterns; + validators? : Object; + } -// http://foundation.zurb.com/docs/components/accordion.html#optional-javascript-configuration -interface FoundationAccordionOptions { - content_class? : string; - active_class? : string; - multi_expand? : boolean; - toggleable? : boolean; - callback? : () => any; -} + // http://foundation.zurb.com/docs/components/accordion.html#optional-javascript-configuration + interface AccordionOptions { + content_class? : string; + active_class? : string; + multi_expand? : boolean; + toggleable? : boolean; + callback? : () => any; + } -// http://foundation.zurb.com/docs/components/alert_boxes.html -interface FoundationAlertOptions { - callback? : () => any; -} + // http://foundation.zurb.com/docs/components/alert_boxes.html + interface AlertOptions { + callback? : () => any; + } -// http://foundation.zurb.com/docs/components/clearing.html#optional-javascript-configuration -interface FoundationClearingOptions { - templates? : Object; - close_selectors? : string; - open_selectors? : string; - skip_selector? : string; - touch_label? : string; - init? : boolean; - locked? : boolean; -} + // http://foundation.zurb.com/docs/components/clearing.html#optional-javascript-configuration + interface ClearingOptions { + templates? : Object; + close_selectors? : string; + open_selectors? : string; + skip_selector? : string; + touch_label? : string; + init? : boolean; + locked? : boolean; + } -// http://foundation.zurb.com/docs/components/dropdown.html#optional-javascript-configuration -interface FoundationDropdownOptions { - active_class? : string; - disabled_class? : string; - mega_class? : string; - align? : string; - is_hover? : boolean; - hover_timeout? : number; - opened? : () => any; - closed? : () => any; -} + // http://foundation.zurb.com/docs/components/dropdown.html#optional-javascript-configuration + interface DropdownOptions { + active_class? : string; + disabled_class? : string; + mega_class? : string; + align? : string; + is_hover? : boolean; + hover_timeout? : number; + opened? : () => any; + closed? : () => any; + } -// http://foundation.zurb.com/docs/components/equalizer.html#optional-javascript-configuration -interface FoundationEqualizerOptions { - use_tallest? : boolean; - equalize_on_stack? : boolean; -} + // http://foundation.zurb.com/docs/components/equalizer.html#optional-javascript-configuration + interface EqualizerOptions { + use_tallest? : boolean; + equalize_on_stack? : boolean; + } -// http://foundation.zurb.com/docs/components/interchange.html#custom-named-queries -interface FoundationInterchangeOptions { - load_attr? : string; - named_queries? : Object; - directives? : Object; -} + // http://foundation.zurb.com/docs/components/interchange.html#custom-named-queries + interface InterchangeOptions { + load_attr? : string; + named_queries? : Object; + directives? : Object; + } -// http://foundation.zurb.com/docs/components/joyride.html#optional-javascript-configuration -interface FoundationJoyrideOptions { - expose? : boolean; - modal? : boolean; - keyboard? : boolean; - tip_location? : string; - nub_position? : string; - scroll_speed? : number; - scroll_animation? : string; - timer? : number; - start_timer_on_click? : boolean; - start_offset? : number; - next_button? : boolean; - prev_button? : boolean; - tip_animation? : string; - pause_after? : number[]; - exposed? : string[]; - tip_animation_fade_speed? : number; - cookie_monster? : boolean; - cookie_name? : string; - cookie_domain? : boolean; - cookie_expires? : number; - tip_container? : string; - tip_location_patterns? : { - top? : string[]; - bottom? : string[]; - left? : string[]; - right? : string[]; - }; - post_ride_callback? : () => void; - post_step_callback? : () => void; - pre_step_callback? : () => void; - pre_ride_callback? : () => void; - post_expose_callback? : () => void; - template? : { - link? : string; - timer? : string; - tip? : string; - wrapper? : string; - button? : string; - modal? : string; - expose? : string; - expose_cover? : string; - }; - expose_add_class? : string; -} + // http://foundation.zurb.com/docs/components/joyride.html#optional-javascript-configuration + interface JoyrideOptions { + expose? : boolean; + modal? : boolean; + keyboard? : boolean; + tip_location? : string; + nub_position? : string; + scroll_speed? : number; + scroll_animation? : string; + timer? : number; + start_timer_on_click? : boolean; + start_offset? : number; + next_button? : boolean; + prev_button? : boolean; + tip_animation? : string; + pause_after? : number[]; + exposed? : string[]; + tip_animation_fade_speed? : number; + cookie_monster? : boolean; + cookie_name? : string; + cookie_domain? : boolean; + cookie_expires? : number; + tip_container? : string; + tip_location_patterns? : { + top? : string[]; + bottom? : string[]; + left? : string[]; + right? : string[]; + }; + post_ride_callback? : () => void; + post_step_callback? : () => void; + pre_step_callback? : () => void; + pre_ride_callback? : () => void; + post_expose_callback? : () => void; + template? : { + link? : string; + timer? : string; + tip? : string; + wrapper? : string; + button? : string; + modal? : string; + expose? : string; + expose_cover? : string; + }; + expose_add_class? : string; + } -// http://foundation.zurb.com/docs/components/magellan.html#js -interface FoundationMagellanOptions { - active_class? : string; - threshold? : number; - destination_threshold? : number; - throttle_delay? : number; - fixed_top? : number; - offset_by_height? : boolean; - duration? : number; - easing? : string; -} + // http://foundation.zurb.com/docs/components/magellan.html#js + interface MagellanOptions { + active_class? : string; + threshold? : number; + destination_threshold? : number; + throttle_delay? : number; + fixed_top? : number; + offset_by_height? : boolean; + duration? : number; + easing? : string; + } -// http://foundation.zurb.com/docs/components/offcanvas.html#optional-javascript-configuration -interface FoundationOffCanvasOptions { - open_method? : string; - close_on_click? : boolean; -} + // http://foundation.zurb.com/docs/components/offcanvas.html#optional-javascript-configuration + interface OffCanvasOptions { + open_method? : string; + close_on_click? : boolean; + } -// http://foundation.zurb.com/docs/components/orbit.html#advanced -interface FoundationOrbitOptions { - animation? : string; - timer_speed? : number; - pause_on_hover? : boolean; - resume_on_mouseout? : boolean; - next_on_click? : boolean; - animation_speed? : number; - stack_on_small? : boolean; - navigation_arrows? : boolean; - slide_number? : boolean; - slide_number_text? : string; - container_class? : string; - stack_on_small_class? : string; - next_class? : string; - prev_class? : string; - timer_container_class? : string; - timer_paused_class? : string; - timer_progress_class? : string; - slides_container_class? : string; - preloader_class? : string; - slide_selector? : string; - bullets_container_class? : string; - bullets_active_class? : string; - slide_number_class? : string; - caption_class? : string; - active_slide_class? : string; - orbit_transition_class? : string; - bullets? : boolean; - circular? : boolean; - timer? : boolean; - variable_height? : boolean; - swipe? : boolean; - before_slide_change? : () => any; - after_slide_change? : () => any; -} + // http://foundation.zurb.com/docs/components/orbit.html#advanced + interface OrbitOptions { + animation? : string; + timer_speed? : number; + pause_on_hover? : boolean; + resume_on_mouseout? : boolean; + next_on_click? : boolean; + animation_speed? : number; + stack_on_small? : boolean; + navigation_arrows? : boolean; + slide_number? : boolean; + slide_number_text? : string; + container_class? : string; + stack_on_small_class? : string; + next_class? : string; + prev_class? : string; + timer_container_class? : string; + timer_paused_class? : string; + timer_progress_class? : string; + slides_container_class? : string; + preloader_class? : string; + slide_selector? : string; + bullets_container_class? : string; + bullets_active_class? : string; + slide_number_class? : string; + caption_class? : string; + active_slide_class? : string; + orbit_transition_class? : string; + bullets? : boolean; + circular? : boolean; + timer? : boolean; + variable_height? : boolean; + swipe? : boolean; + before_slide_change? : () => any; + after_slide_change? : () => any; + } -// http://foundation.zurb.com/docs/components/reveal.html -interface FoundationRevealCSSOptions { - opacity? : number; - visibility? : string; - display? : string; -} + // http://foundation.zurb.com/docs/components/reveal.html + interface RevealCSSOptions { + opacity? : number; + visibility? : string; + display? : string; + } -interface FoundationRevealOptions { - animation? : string; - animation_speed? : number; - close_on_background_click? : boolean; - dismiss_modal_class? : string; - multiple_opened? : boolean; - bg_class? : string; - root_element? : string; - on_ajax_error? : () => any; - open? : () => any; - opened? : () => any; - close? : () => any; - closed? : () => any; - bg? : JQuery; - css? : { - open? : FoundationRevealCSSOptions; - close? : FoundationRevealCSSOptions; - }; -} + interface RevealOptions { + animation? : string; + animation_speed? : number; + close_on_background_click? : boolean; + dismiss_modal_class? : string; + multiple_opened? : boolean; + bg_class? : string; + root_element? : string; + on_ajax_error? : () => any; + open? : () => any; + opened? : () => any; + close? : () => any; + closed? : () => any; + bg? : JQuery; + css? : { + open? : RevealCSSOptions; + close? : RevealCSSOptions; + }; + } -// http://foundation.zurb.com/docs/components/range_slider.html -interface FoundationSliderOptions { - start? : number; - end? : number; - step? : number; - precision? : number; - initial? : number; - vertical? : boolean; - trigger_input_change? : boolean; - on_change? : () => any; -} + // http://foundation.zurb.com/docs/components/range_slider.html + interface SliderOptions { + start? : number; + end? : number; + step? : number; + precision? : number; + initial? : number; + vertical? : boolean; + trigger_input_change? : boolean; + on_change? : () => any; + } -// http://foundation.zurb.com/docs/components/tabs.html -interface FoundationTabOptions { - active_class? : string; - callback? : () => any; - deep_linking? : boolean; - scroll_to_content? : boolean; - is_hover? : boolean; -} + // http://foundation.zurb.com/docs/components/tabs.html + interface TabOptions { + active_class? : string; + callback? : () => any; + deep_linking? : boolean; + scroll_to_content? : boolean; + is_hover? : boolean; + } -interface FoundationTooltipOptions { - additional_inheritable_classes? : string[]; - tooltip_class? : string; - append_to? : string; - touch_close_text? : string; - disable_for_touch? : boolean; - hover_delay? : number; - show_on? : string; - tip_template? : (selector : string, content : string) => string; -} + interface TooltipOptions { + additional_inheritable_classes? : string[]; + tooltip_class? : string; + append_to? : string; + touch_close_text? : string; + disable_for_touch? : boolean; + hover_delay? : number; + show_on? : string; + tip_template? : (selector : string, content : string) => string; + } -interface FoundationTopbarOptions { - index? : number; - sticky_class? : string; - custom_back_text? : boolean; - back_text? : string; - is_hover? : boolean; - mobile_show_parent_link? : boolean; - scrolltop? : boolean; - sticky_on? : string; -} + interface TopbarOptions { + index? : number; + sticky_class? : string; + custom_back_text? : boolean; + back_text? : string; + is_hover? : boolean; + mobile_show_parent_link? : boolean; + scrolltop? : boolean; + sticky_on? : string; + } -interface FoundationOptions { - abide? : FoundationAbideOptions; - accordion? : FoundationAccordionOptions; - alert? : FoundationAlertOptions; - clearing? : FoundationClearingOptions; - dropdown? : FoundationDropdownOptions; - equalizer? : FoundationEqualizerOptions; - interchange? : FoundationInterchangeOptions; - joyride? : FoundationJoyrideOptions; - magellan? : FoundationMagellanOptions; - offcanvas? : FoundationOffCanvasOptions; - orbit? : FoundationOrbitOptions; - reveal? : FoundationRevealOptions; - slider? : FoundationSliderOptions; - tab? : FoundationTabOptions; - tooltip? : FoundationTooltipOptions; - topbar? : FoundationTopbarOptions; -} + interface Options { + abide? : AbideOptions; + accordion? : AccordionOptions; + alert? : AlertOptions; + clearing? : ClearingOptions; + dropdown? : DropdownOptions; + equalizer? : EqualizerOptions; + interchange? : InterchangeOptions; + joyride? : JoyrideOptions; + magellan? : MagellanOptions; + offcanvas? : OffCanvasOptions; + orbit? : OrbitOptions; + reveal? : RevealOptions; + slider? : SliderOptions; + tab? : TabOptions; + tooltip? : TooltipOptions; + topbar? : TopbarOptions; + } -interface FoundationStatic { - name : string; - version : string; - media_queries : Object; - stylesheet : CSSStyleSheet; - global : { - namespace : string; - }; - init(scope : JQuery) : JQuery; - init(scope : JQuery, libraries : FoundationOptions) : JQuery; - init(scope : JQuery, libraries : string, method : FoundationOptions) : JQuery; - init(scope : JQuery, libraries : string, method : string, options : Object) : JQuery; - init_lib(lib : any, args : any) : (...args : any[]) => any; - patch(lib : any) : void; - inherit(scope : JQuery, methods : string) : void; - set_namespace() : void; - libs : any; - utils : { - S(selector : any, context : any) : JQuery; - throttle(func : (...args : any[]) => any, delay : number) : (...args : any[]) => any; - debounce(func : (...args : any[]) => any, delay : number, immediate : boolean) : (...args : any[]) => any; - data_options(el : JQuery) : Object; - register_media(media : string, media_class : string) : void; - add_custom_rule(rule : string, media : string) : void; - image_loaded(images : JQuery, callback : (...args : any[]) => any) : void; - random_str(length? : number) : string; - }; + interface FoundationStatic { + name : string; + version : string; + media_queries : Object; + stylesheet : CSSStyleSheet; + global : { + namespace : string; + }; + init(scope : JQuery) : JQuery; + init(scope : JQuery, libraries : Options) : JQuery; + init(scope : JQuery, libraries : string, method : Options) : JQuery; + init(scope : JQuery, libraries : string, method : string, options : Object) : JQuery; + init_lib(lib : any, args : any) : (...args : any[]) => any; + patch(lib : any) : void; + inherit(scope : JQuery, methods : string) : void; + set_namespace() : void; + libs : any; + utils : { + S(selector : any, context : any) : JQuery; + throttle(func : (...args : any[]) => any, delay : number) : (...args : any[]) => any; + debounce(func : (...args : any[]) => any, delay : number, immediate : boolean) : (...args : any[]) => any; + data_options(el : JQuery) : Object; + register_media(media : string, media_class : string) : void; + add_custom_rule(rule : string, media : string) : void; + image_loaded(images : JQuery, callback : (...args : any[]) => any) : void; + random_str(length? : number) : string; + }; + } } interface JQuery { foundation() : JQuery; - foundation(libraries : FoundationOptions | string) : JQuery; - foundation(libraries : string, method : FoundationOptions | string) : JQuery; + foundation(libraries : Foundation.Options | string) : JQuery; + foundation(libraries : string, method : Foundation.Options | string) : JQuery; foundation(libraries : string, method : string, options : Object) : JQuery; } -declare var Foundation : FoundationStatic; +declare var Foundation : Foundation.FoundationStatic; From 403894c47328ead23d90b576d564558fda447dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Ostroz=CC=8Cli=CC=81k?= Date: Wed, 20 May 2015 21:54:16 +0200 Subject: [PATCH 006/274] React-router 0.13 support --- react-router/react-router-test.ts | 86 ++--- react-router/react-router.d.ts | 559 +++++++++++++++--------------- 2 files changed, 324 insertions(+), 321 deletions(-) diff --git a/react-router/react-router-test.ts b/react-router/react-router-test.ts index 41b352af36..fa335e9346 100644 --- a/react-router/react-router-test.ts +++ b/react-router/react-router-test.ts @@ -7,7 +7,7 @@ import Router = require('react-router'); // Mixin class NavigationTest { v: T; - + makePath() { var v1: string = this.v.makePath('to'); var v2: string = this.v.makePath('to', {id: 1}); @@ -35,27 +35,27 @@ class NavigationTest { class StateTest { v: T; - + getPath() { var v1: string = this.v.getPath(); } - + getRoutes() { var v1: Router.Route[] = this.v.getRoutes(); } - + getPathname() { var v1: string = this.v.getPathname(); } - + getParams() { var v1: {} = this.v.getParams(); } - + getQuery() { var v1: {} = this.v.getQuery(); } - + isActive() { var v1: boolean = this.v.isActive('to'); var v2: boolean = this.v.isActive('to', {id: 1}); @@ -63,35 +63,23 @@ class StateTest { } } -class RouteHandlerMixinTest { - v: T; - - getRouteDepth() { - var v1: number = this.v.getRouteDepth(); - } - - createChildRouteHandler() { - var v1: Router.RouteHandler = this.v.createChildRouteHandler({ref: 'hoge'}); - } -} - // Location -class LocationTest { +class LocationTest { v: T; - + push() { var v1: void = this.v.push('path/to/hoge'); } - + replace() { var v1: void = this.v.replace('path/to/hoge'); } - + pop() { var v1: void = this.v.pop(); } - + getCurrentPath() { var v1: void = this.v.getCurrentPath(); } @@ -102,11 +90,11 @@ new LocationTest(); class LocationListenerTest { v: T; - + addChangeListener() { var v1: void = this.v.addChangeListener(() => console.log(1)); } - + removeChangeListener() { var v1: void = this.v.removeChangeListener(() => console.log(1)); } @@ -118,7 +106,7 @@ new LocationListenerTest(); // Behavior class ScrollBehaviorTest { v: T; - + updateScrollPosition() { var v1: void = this.v.updateScrollPosition({x: 33, y: 102}, 'scrollTop'); } @@ -130,12 +118,12 @@ new ScrollBehaviorTest(); // Component class DefaultRouteTest { v: Router.DefaultRoute; - + props() { var name: string = this.v.props.name; var handler: React.ComponentClass = this.v.props.handler; } - + createElement() { var Handler: React.ComponentClass; React.createElement(Router.DefaultRoute, null); @@ -145,12 +133,12 @@ class DefaultRouteTest { class LinkTest { v: Router.Link; - + constructor() { new NavigationTest(); new StateTest(); } - + props() { var activeClassName: string = this.v.props.activeClassName; var to: string = this.v.props.to; @@ -158,15 +146,15 @@ class LinkTest { var query: {} = this.v.props.query; var onClick: Function = this.v.props.onClick; } - + getHref() { var v1: string = this.v.getHref(); } - + getClassName() { var v1: string = this.v.getClassName(); } - + createElement() { React.createElement(Router.Link, null); React.createElement(Router.Link, {to: 'home'}); @@ -182,12 +170,12 @@ class LinkTest { class NotFoundRouteTest { v: Router.NotFoundRoute; - + props() { var name: string = this.v.props.name; var handler: React.ComponentClass = this.v.props.handler; } - + createElement() { var Handler: React.ComponentClass; React.createElement(Router.NotFoundRoute, null); @@ -198,13 +186,13 @@ class NotFoundRouteTest { class RedirectTest { v: Router.Redirect; - + props() { var path: string = this.v.props.path; var from: string = this.v.props.from; var to: string = this.v.props.to; } - + createElement() { React.createElement(Router.Redirect, null); React.createElement(Router.Redirect, {}); @@ -214,14 +202,14 @@ class RedirectTest { class RouteTest { v: Router.Route; - + props() { var name: string = this.v.props.name; var path: string = this.v.props.path; var handler: React.ComponentClass = this.v.props.handler; var ignoreScrollBehavior: boolean = this.v.props.ignoreScrollBehavior; } - + createElement() { var Handler: React.ComponentClass; React.createElement(Router.Route, null); @@ -232,11 +220,7 @@ class RouteTest { class RouteHandlerTest { v: Router.RouteHandler; - - constructor() { - new RouteHandlerMixinTest(); - } - + createElement() { React.createElement(Router.RouteHandler, null); React.createElement(Router.RouteHandler, {}); @@ -247,11 +231,11 @@ class RouteHandlerTest { // History class HistoryTest { v: Router.History; - + length() { var v1: number = this.v.length; } - + back() { var v1: void = this.v.back(); } @@ -261,7 +245,7 @@ class HistoryTest { // Router class CreateTest { v: Router.Router; - + constructor() { // React.createElement() version this.v = Router.create({ @@ -272,7 +256,7 @@ class CreateTest { location: Router.HistoryLocation, scrollBehavior: Router.ImitateBrowserBehavior }); - + // React.createFactory() version this.v = Router.create({ routes: React.createFactory(Router.Route)() @@ -283,7 +267,7 @@ class CreateTest { scrollBehavior: Router.ImitateBrowserBehavior }); } - + run() { this.v.run((Handler) => console.log(Handler)); this.v.run((Handler, state) => console.log(Handler, state)); @@ -299,7 +283,7 @@ class RunTest { var v2: Router.Router = Router.run(React.createElement(Router.Route, null), Router.HistoryLocation, (Handler, state) => { React.render(React.createElement(Handler, null), document.body); }); - + // React.createFactory() version var v3: Router.Router = Router.run(React.createFactory(Router.Route)(), (Handler) => { React.render(React.createElement(Handler, null), document.body); diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index 58ec9069a4..c02892ffe1 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -1,278 +1,297 @@ -// Type definitions for React Router 0.12.0 +// Type definitions for React Router 0.13.3 // Project: https://github.com/rackt/react-router -// Definitions by: Yuichi Murata +// Definitions by: Yuichi Murata , Václav Ostrožlík // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// -declare module ReactRouter { - // - // Mixin - // ---------------------------------------------------------------------- - interface Navigation { - makePath(to: string, params?: {}, query?: {}): string; - makeHref(to: string, params?: {}, query?: {}): string; - transitionTo(to: string, params?: {}, query?: {}): void; - replaceWith(to: string, params?: {}, query?: {}): void; - goBack(): void; - } - - interface RouteHandlerMixin { - getRouteDepth(): number; - createChildRouteHandler(props: {}): RouteHandler; - } - - interface State { - getPath(): string; - getRoutes(): Route[]; - getPathname(): string; - getParams(): {}; - getQuery(): {}; - isActive(to: string, params?: {}, query?: {}): boolean; - } - - var Navigation: Navigation; - var State: State; - var RouteHandlerMixin: RouteHandlerMixin; - - - // - // Component - // ---------------------------------------------------------------------- - // DefaultRoute - interface DefaultRouteProp { - name?: string; - handler: React.ComponentClass; - } - interface DefaultRoute extends React.ReactElement { - __react_router_default_route__: any; // dummy - } - interface DefaultRouteClass extends React.ComponentClass { - __react_router_default_route__: any; // dummy - } - - // Link - interface LinkProp { - activeClassName?: string; - to: string; - params?: {}; - query?: {}; - onClick?: Function; - } - interface Link extends React.ReactElement, Navigation, State { - __react_router_link__: any; // dummy - - getHref(): string; - getClassName(): string; - } - interface LinkClass extends React.ComponentClass { - __react_router_link__: any; // dummy - } - - // NotFoundRoute - interface NotFoundRouteProp { - name?: string; - handler: React.ComponentClass; - } - interface NotFoundRoute extends React.ReactElement { - __react_router_not_found_route__: any; // dummy - } - interface NotFoundRouteClass extends React.ComponentClass { - __react_router_not_found_route__: any; // dummy - } - - // Redirect - interface RedirectProp { - path?: string; - from?: string; - to?: string; - } - interface Redirect extends React.ReactElement { - __react_router_redirect__: any; // dummy - } - interface RedirectClass extends React.ComponentClass { - __react_router_redirect__: any; // dummy - } - - // Route - interface RouteProp { - name?: string; - path?: string; - handler?: React.ComponentClass; - ignoreScrollBehavior?: boolean; - } - interface Route extends React.ReactElement { - __react_router_route__: any; // dummy - } - interface RouteClass extends React.ComponentClass { - __react_router_route__: any; // dummy - } - - // RouteHandler - interface RouteHandlerProp {} - interface RouteHandler extends React.ReactElement, RouteHandlerMixin { - __react_router_route_handler__: any; // dummy - } - interface RouteHandlerClass extends React.ReactElement { - __react_router_route_handler__: any; // dummy - } - - var DefaultRoute: DefaultRouteClass; - var Link: LinkClass; - var NotFoundRoute: NotFoundRouteClass; - var Redirect: RedirectClass; - var Route: RouteClass; - var RouteHandler: RouteHandlerClass; - - - // - // Location - // ---------------------------------------------------------------------- - interface LocationBase { - push(path: string): void; - replace(path: string): void; - pop(): void; - getCurrentPath(): void; - } - - interface LocationListener { - addChangeListener(listener: Function): void; - removeChangeListener(listener: Function): void; - } - - interface HashLocation extends LocationBase, LocationListener {} - interface HistoryLocation extends LocationBase, LocationListener {} - interface RefreshLocation extends LocationBase {} - - var HashLocation: HashLocation; - var HistoryLocation: HistoryLocation; - var RefreshLocation: RefreshLocation; - - - // - // Behavior - // ---------------------------------------------------------------------- - interface ScrollBehaviorBase { - updateScrollPosition(position: {x: number; y: number;}, actionType: string): void; - } - interface ImitateBrowserBehavior extends ScrollBehaviorBase {} - interface ScrollToTopBehavior extends ScrollBehaviorBase {} - - var ImitateBrowserBehavior: ImitateBrowserBehavior; - var ScrollToTopBehavior: ScrollToTopBehavior; - - - // - // Router - // ---------------------------------------------------------------------- - interface Router extends React.ReactElement { - run(callback: RouterRunCallback): void; - } - - interface RouterState { - path: string; - action: string; - pathname: string; - params: {}; - query: {}; - routes : Route[]; - } - - interface RouterCreateOption { - routes: React.ReactElement; - location?: LocationBase; - scrollBehavior?: ScrollBehaviorBase; - } - - type RouterRunCallback = (Handler: Router, state: RouterState) => void; - - function create(options: RouterCreateOption): Router; - function run(routes: React.ReactElement, callback: RouterRunCallback): Router; - function run(routes: React.ReactElement, location: LocationBase, callback: RouterRunCallback): Router; - - - // - // History - // ---------------------------------------------------------------------- - interface History { - back(): void; - length: number; - } - var History: History; - - - // - // Transition - // ---------------------------------------------------------------------- - interface Transition { - abort(): void; - redirect(to: string, params?: {}, query?: {}): void; - retry(): void; - } - - interface TransitionStaticLifecycle { - willTransitionTo?( - transition: Transition, - params: {}, - query: {}, - callback: Function - ): void; - - willTransitionFrom?( - transition: Transition, - component: React.ReactElement, - callback: Function - ): void; - } +declare module "react-router" { + + import React = require("react"); + + // + // Transition + // ---------------------------------------------------------------------- + interface Transition { + path: string; + abortReason: any; + retry(): void; + abort(reason?: any): void; + redirect(to: string, params?: {}, query?: {}): void; + cancel(): void; + from: (transition: Transition, routes: Route[], components?: React.ReactElement[], callback?: (error?: any) => void) => void; + to: (transition: Transition, routes: Route[], params?: {}, query?: {}, callback?: (error?: any) => void) => void; + } + + interface TransitionStaticLifecycle { + willTransitionTo?( + transition: Transition, + params: {}, + query: {}, + callback: Function + ): void; + + willTransitionFrom?( + transition: Transition, + component: React.ReactElement, + callback: Function + ): void; + } + + // + // Route Configuration + // ---------------------------------------------------------------------- + // DefaultRoute + interface DefaultRouteProp { + name?: string; + handler: React.ComponentClass; + } + interface DefaultRoute extends React.ReactElement {} + interface DefaultRouteClass extends React.ComponentClass {} + + // NotFoundRoute + interface NotFoundRouteProp { + name?: string; + handler: React.ComponentClass; + } + interface NotFoundRoute extends React.ReactElement {} + interface NotFoundRouteClass extends React.ComponentClass {} + + // Redirect + interface RedirectProp { + path?: string; + from?: string; + to?: string; + } + interface Redirect extends React.ReactElement {} + interface RedirectClass extends React.ComponentClass {} + + // Route + interface RouteProp { + name?: string; + path?: string; + handler?: React.ComponentClass; + ignoreScrollBehavior?: boolean; + } + interface Route extends React.ReactElement {} + interface RouteClass extends React.ComponentClass {} + + var DefaultRoute: DefaultRouteClass; + var NotFoundRoute: NotFoundRouteClass; + var Redirect: RedirectClass; + var Route: RouteClass; + + interface CreateRouteOptions { + name?: string; + path?: string; + ignoreScrollBehavior?: boolean; + isDefault?: boolean; + isNotFound?: boolean; + onEnter?: (transition: Transition, params: {}, query: {}, callback: Function) => void; + onLeave?: (transition: Transition, wtf: any, callback: Function) => void; + handler?: Function; + parentRoute?: Route; + } + + type CreateRouteCallback = (route: Route) => void; + + function createRoute(callback: CreateRouteCallback): Route; + function createRoute(options: CreateRouteOptions | string, callback: CreateRouteCallback): Route; + function createDefaultRoute(options?: CreateRouteOptions | string): Route; + function createNotFoundRoute(options?: CreateRouteOptions | string): Route; + + interface CreateRedirectOptions extends CreateRouteOptions { + path?: string; + from?: string; + to: string; + params?: {}; + query?: {}; + } + function createRedirect(options: CreateRedirectOptions): Redirect; + function createRoutesFromReactChildren(children: Route): Route[]; + + // + // Components + // ---------------------------------------------------------------------- + // Link + interface LinkProp { + activeClassName?: string; + activeStyle?: {}; + to: string; + params?: {}; + query?: {}; + onClick?: Function; + } + interface Link extends React.ReactElement, Navigation, State { + handleClick(event: any): void; + getHref(): string; + getClassName(): string; + getActiveState(): boolean; + } + interface LinkClass extends React.ComponentClass {} + + // RouteHandler + interface RouteHandlerProp { } + interface RouteHandlerChildContext { + routeDepth: number; + } + interface RouteHandler extends React.ReactElement { + getChildContext(): RouteHandlerChildContext; + getRouteDepth(): number; + createChildRouteHandler(props: {}): RouteHandler; + } + interface RouteHandlerClass extends React.ReactElement {} + + var Link: LinkClass; + var RouteHandler: RouteHandlerClass; + + + // + // Top-Level + // ---------------------------------------------------------------------- + interface Router extends React.ReactElement { + run(callback: RouterRunCallback): void; + } + + interface RouterState { + path: string; + action: string; + pathname: string; + params: {}; + query: {}; + routes: Route[]; + } + + interface RouterCreateOption { + routes: Route; + location?: LocationBase; + scrollBehavior?: ScrollBehaviorBase; + onError?: (error: any) => void; + onAbort?: (error: any) => void; + } + + type RouterRunCallback = (Handler: RouteClass, state: RouterState) => void; + + function create(options: RouterCreateOption): Router; + function run(routes: Route, callback: RouterRunCallback): Router; + function run(routes: Route, location: LocationBase, callback: RouterRunCallback): Router; + + + // + // Location + // ---------------------------------------------------------------------- + interface LocationBase { + getCurrentPath(): void; + toString(): string; + } + interface Location extends LocationBase { + push(path: string): void; + replace(path: string): void; + pop(): void; + } + + interface LocationListener { + addChangeListener(listener: Function): void; + removeChangeListener(listener: Function): void; + } + + interface HashLocation extends Location, LocationListener { } + interface HistoryLocation extends Location, LocationListener { } + interface RefreshLocation extends Location { } + interface StaticLocation extends LocationBase { } + interface TestLocation extends Location, LocationListener { } + + var HashLocation: HashLocation; + var HistoryLocation: HistoryLocation; + var RefreshLocation: RefreshLocation; + var StaticLocation: StaticLocation; + var TestLocation: TestLocation; + + + // + // Behavior + // ---------------------------------------------------------------------- + interface ScrollBehaviorBase { + updateScrollPosition(position: { x: number; y: number; }, actionType: string): void; + } + interface ImitateBrowserBehavior extends ScrollBehaviorBase { } + interface ScrollToTopBehavior extends ScrollBehaviorBase { } + + var ImitateBrowserBehavior: ImitateBrowserBehavior; + var ScrollToTopBehavior: ScrollToTopBehavior; + + + // + // Mixin + // ---------------------------------------------------------------------- + interface Navigation { + makePath(to: string, params?: {}, query?: {}): string; + makeHref(to: string, params?: {}, query?: {}): string; + transitionTo(to: string, params?: {}, query?: {}): void; + replaceWith(to: string, params?: {}, query?: {}): void; + goBack(): void; + } + + interface State { + getPath(): string; + getRoutes(): Route[]; + getPathname(): string; + getParams(): {}; + getQuery(): {}; + isActive(to: string, params?: {}, query?: {}): boolean; + } + + var Navigation: Navigation; + var State: State; + + + // + // History + // ---------------------------------------------------------------------- + interface History { + back(): void; + length: number; + } + var History: History; } -declare module 'react-router' { - import Export = ReactRouter; - export = Export; -} -declare module React { - interface TopLevelAPI { - // for DefaultRoute - createElement( - type: ReactRouter.DefaultRouteClass, - props: ReactRouter.DefaultRouteProp, - ...children: ReactNode[] - ): ReactRouter.DefaultRoute; - - // for Link - createElement( - type: ReactRouter.LinkClass, - props: ReactRouter.LinkProp, - ...children: ReactNode[] - ): ReactRouter.Link; - - // for NotFoundRoute - createElement( - type: ReactRouter.NotFoundRouteClass, - props: ReactRouter.NotFoundRouteProp, - ...children: ReactNode[] - ): ReactRouter.NotFoundRoute; - - // for Redirect - createElement( - type: ReactRouter.RedirectClass, - props: ReactRouter.RedirectProp, - ...children: ReactNode[] - ): ReactRouter.Redirect; - - // for Route - createElement( - type: ReactRouter.RouteClass, - props: ReactRouter.RouteProp, - ...children: ReactNode[] - ): ReactRouter.Route; - - // for RouteHandler - createElement( - type: ReactRouter.RouteHandlerClass, - props: ReactRouter.RouteHandlerProp, - ...children: ReactNode[] - ): ReactRouter.RouteHandler; - } +declare module "react" { + import ReactRouter = require("react-router"); + + // for DefaultRoute + function createElement( + type: ReactRouter.DefaultRouteClass, + props: ReactRouter.DefaultRouteProp, + ...children: ReactNode[]): ReactRouter.DefaultRoute; + + // for Link + function createElement( + type: ReactRouter.LinkClass, + props: ReactRouter.LinkProp, + ...children: ReactNode[]): ReactRouter.Link; + + // for NotFoundRoute + function createElement( + type: ReactRouter.NotFoundRouteClass, + props: ReactRouter.NotFoundRouteProp, + ...children: ReactNode[]): ReactRouter.NotFoundRoute; + + // for Redirect + function createElement( + type: ReactRouter.RedirectClass, + props: ReactRouter.RedirectProp, + ...children: ReactNode[]): ReactRouter.Redirect; + + // for Route + function createElement( + type: ReactRouter.RouteClass, + props: ReactRouter.RouteProp, + ...children: ReactNode[]): ReactRouter.Route; + + // for RouteHandler + function createElement( + type: ReactRouter.RouteHandlerClass, + props: ReactRouter.RouteHandlerProp, + ...children: ReactNode[]): ReactRouter.RouteHandler; } From 3e467db265658e0dbc80de8c1be71e4531a52530 Mon Sep 17 00:00:00 2001 From: Chris Wrench Date: Wed, 27 May 2015 17:24:46 +0100 Subject: [PATCH 007/274] Begin update of Google Maps definitions to v3.20 As part of #4364, update some of the Google Maps API to the latest version, v3.20. Changes include: - Addition of `LatLngLiteral` type; - Remove `MarkerImage` type; - Update `Marker` class. The following areas of the API have been updated and checked for consistency with the latest API reference: - Map; - Controls; - Data; - Overlays; - Services; - Save to Google Maps; - Base; - MVC. All other areas of the API still need to be updated. --- googlemaps/google.maps.d.ts | 328 ++++++++++++++++++++++-------------- 1 file changed, 202 insertions(+), 126 deletions(-) diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index fe4e7459cd..f5d197773f 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Google Maps JavaScript API 3.19 +// Type definitions for Google Maps JavaScript API 3.20 // Project: https://developers.google.com/maps/ // Definitions by: Folia A/S , Chris Wrench // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -29,34 +29,6 @@ THE SOFTWARE. declare module google.maps { - /***** MVC *****/ - export class MVCObject { - constructor (); - addListener(eventName: string, handler: (...args: any[]) => void): MapsEventListener; - bindTo(key: string, target: MVCObject, targetKey?: string, noNotify?: boolean): void; - changed(key: string): void; - get(key: string): any; - notify(key: string): void; - set(key: string, value: any): void; - setValues(values: any): void; - unbind(key: string): void; - unbindAll(): void; - } - - export class MVCArray extends MVCObject { - constructor (array?: any[]); - clear(): void; - forEach(callback: (elem: any, index: number) => void ): void; - getArray(): any[]; - getAt(i: number): any; - getLength(): number; - insertAt(i: number, elem: any): void; - pop(): void; - push(elem: any): number; - removeAt(i: number): any; - setAt(i: number, elem: any): void; - } - /***** Map *****/ export class Map extends MVCObject { constructor (mapDiv: Element, opts?: MapOptions); @@ -65,17 +37,17 @@ declare module google.maps { getCenter(): LatLng; getDiv(): Element; getHeading(): number; - getMapTypeId(): MapTypeId; + getMapTypeId(): MapTypeId|string; getProjection(): Projection; getStreetView(): StreetViewPanorama; getTilt(): number; getZoom(): number; panBy(x: number, y: number): void; - panTo(latLng: LatLng): void; + panTo(latLng: LatLng|LatLngLiteral): void; panToBounds(latLngBounds: LatLngBounds): void; - setCenter(latlng: LatLng): void; + setCenter(latlng: LatLng|LatLngLiteral): void; setHeading(heading: number): void; - setMapTypeId(mapTypeId: MapTypeId): void; + setMapTypeId(mapTypeId: MapTypeId|string): void; setOptions(options: MapOptions): void; setStreetView(panorama: StreetViewPanorama): void; setTilt(tilt: number): void; @@ -99,8 +71,6 @@ declare module google.maps { mapMaker?: boolean; mapTypeControl?: boolean; mapTypeControlOptions?: MapTypeControlOptions; - navigationControl?: boolean; - navigationControlOptions?: NavigationControlOptions; mapTypeId?: MapTypeId; maxZoom?: number; minZoom?: number; @@ -133,7 +103,7 @@ declare module google.maps { /***** Controls *****/ export interface MapTypeControlOptions { - mapTypeIds?: MapTypeId[]; + mapTypeIds?: MapTypeId[]|string[]; position?: ControlPosition; style?: MapTypeControlStyle; } @@ -157,7 +127,6 @@ declare module google.maps { } export interface ScaleControlOptions { - position?: ControlPosition; style?: ScaleControlStyle; } @@ -195,18 +164,6 @@ declare module google.maps { TOP_RIGHT } - export interface NavigationControlOptions { - position?: ControlPosition; - style?: NavigationControlStyle; - } - - export enum NavigationControlStyle { - DEFAULT, - SMALL, - ANDROID, - ZOOM_PAN - } - /***** Data *****/ export class Data extends MVCObject { constructor(options?: Data.DataOptions); @@ -214,6 +171,9 @@ declare module google.maps { addGeoJson(geoJson: Object, options?: Data.GeoJsonOptions): Data.Feature[]; contains(feature: Data.Feature): boolean; forEach(callback: (feature: Data.Feature) => void): void; + getControlPosition(): ControlPosition; + getControls(): string[]; + getDrawingMode(): string; getFeatureById(id: number|string): Data.Feature; getMap(): Map; getStyle(): Data.StylingFunction|Data.StyleOptions; @@ -221,6 +181,9 @@ declare module google.maps { overrideStyle(feature: Data.Feature, style: Data.StyleOptions): void; remove(feature: Data.Feature): void; revertStyle(feature?: Data.Feature): void; + setControlPosition(controlPosition: ControlPosition): void; + setControls(controls: string[]): void; + setDrawingMode(drawingMode: string): void; setMap(map: Map): void; setStyle(style: Data.StylingFunction|Data.StyleOptions): void; toGeoJson(callback: (feature: Object) => void): void; @@ -228,6 +191,10 @@ declare module google.maps { export module Data { export interface DataOptions { + controlPosition?: ControlPosition; + controls?: string[]; + drawingMode?: string; + featureFactory?: (geometry: Data.Geometry) => Data.Feature; map?: Map; style?: Data.StylingFunction|Data.StyleOptions; } @@ -239,9 +206,11 @@ declare module google.maps { export interface StyleOptions { clickable?: boolean; cursor?: string; + draggable?: boolean; + editable?: boolean; fillColor?: string; fillOpacity?: number; - icon?: any; // TODO string|Icon|Symbol; + icon?: string|Icon|Symbol; shape?: MarkerShape; strokeColor?: string; strokeOpacity?: number; @@ -260,13 +229,13 @@ declare module google.maps { getId(): number|string; getProperty(name: string): any; removeProperty(name: string): void; - setGeometry(newGeometry: Data.Geometry|LatLng): void; // TODO LatLngLiteral + setGeometry(newGeometry: Data.Geometry|LatLng|LatLngLiteral): void; setProperty(name: string, newValue: any): void toGeoJson(callback: (feature: Object) => void): void } export interface FeatureOptions { - geometry?: Data.Geometry|LatLng; // TODO LatLngLiteral + geometry?: Data.Geometry|LatLng|LatLngLiteral; id?: number|string; properties?: Object; } @@ -276,53 +245,54 @@ declare module google.maps { } export class Point extends Data.Geometry { - constructor(latLng: LatLng); // TODO LatLngLiteral + constructor(latLng: LatLng|LatLngLiteral); get(): LatLng; } export class MultiPoint extends Data.Geometry { - constructor(elements: LatLng[]); // TODO LatLngLiteral + constructor(elements: LatLng[]|LatLngLiteral[]); + getArray(): LatLng[]; getAt(n: number): LatLng; getLength(): number; } export class LineString extends Data.Geometry { - constructor(elements: LatLng[]); // TODO LatLngLiteral + constructor(elements: LatLng[]|LatLngLiteral[]); getArray(): LatLng[]; getAt(n: number): LatLng; getLength(): number; } export class MultiLineString extends Data.Geometry { - constructor(elements: Data.LineString[]|LatLng[]); // TODO LatLngLiteral + constructor(elements: Data.LineString[]|LatLng[]|LatLngLiteral[]); getArray(): Data.LineString[]; getAt(n: number): Data.LineString; getLength(): number; } export class LinearRing extends Data.Geometry { - constructor(elements: LatLng[]); // TODO LatLngLiteral + constructor(elements: LatLng[]|LatLngLiteral[]); getArray(): LatLng[]; getAt(n: number): LatLng; getLength(): number; } export class Polygon extends Data.Geometry { - constructor(elements: LinearRing[]|LatLng[][]); // TODO LatLngLiteral - getArray(): LinearRing[]; - getAt(n: number): LinearRing; + constructor(elements: Data.LinearRing[]|LatLng[][]|LatLngLiteral[][]); + getArray(): Data.LinearRing[]; + getAt(n: number): Data.LinearRing; getLength(): number; } export class MultiPolygon extends Data.Geometry { - constructor(elements: Data.Polygon[]|LinearRing[][]|LatLng[][][]); // TODO LatLngLiteral + constructor(elements: Data.Polygon[]|LinearRing[][]|LatLng[][][]|LatLngLiteral[][][]); getArray(): Data.Polygon[]; getAt(n: number): Data.Polygon; getLength(): number; } export class GeometryCollection extends Data.Geometry { - constructor(elements: Data.Geometry[]|LatLng[]); // TODO LatLngLiteral + constructor(elements: Data.Geometry[]|LatLng[]|LatLngLiteral[]); getArray(): Data.Geometry[]; getAt(n: number): Data.Geometry; getLength(): number; @@ -365,31 +335,30 @@ declare module google.maps { static MAX_ZINDEX: number; constructor (opts?: MarkerOptions); getAnimation(): Animation; + getAttribution(): Attribution; getClickable(): boolean; getCursor(): string; getDraggable(): boolean; - getFlat(): boolean; - getIcon(): MarkerImage; - getMap(): any; // Map or StreetViewPanorama + getIcon(): string|Icon|Symbol; + getMap(): Map|StreetViewPanorama; + getOpacity(): number; + getPlace(): Place; getPosition(): LatLng; - getShadow(): MarkerImage; getShape(): MarkerShape; getTitle(): string; getVisible(): boolean; getZIndex(): number; setAnimation(animation: Animation): void; + setAttribution(attribution: Attribution): void; setClickable(flag: boolean): void; setCursor(cursor: string): void; setDraggable(flag: boolean): void; - setFlat(flag: boolean): void; - setIcon(icon: MarkerImage): void; - setIcon(icon: string): void; - setMap(map: Map): void; - setMap(map: StreetViewPanorama): void; + setIcon(icon: string|Icon|Symbol): void; + setMap(map: Map|StreetViewPanorama): void; + getOpacity(opacity: number): void; setOptions(options: MarkerOptions): void; - setPosition(latlng: LatLng): void; - setShadow(shadow: MarkerImage): void; - setShadow(shadow: string): void; + setPlace(place: Place): void; + setPosition(latlng: LatLng|LatLngLiteral): void; setShape(shape: MarkerShape): void; setTitle(title: string): void; setVisible(visible: boolean): void; @@ -397,30 +366,31 @@ declare module google.maps { } export interface MarkerOptions { + anchorPoint?:Point; animation?: Animation; + attribution?: Attribution; clickable?: boolean; + crossOnDrag?: boolean; cursor?: string; draggable?: boolean; - flat?: boolean; - icon?: any; - map?: any; + icon?: string|Icon|Symbol; + map?: Map|StreetViewPanorama; + opacity?: number; optimized?: boolean; + place?: Place; position?: LatLng; - raiseOnDrag?: boolean; - shadow?: any; shape?: MarkerShape; title?: string; visible?: boolean; zIndex?: number; } - export class MarkerImage { - constructor (url: string, size?: Size, origin?: Point, anchor?: Point, scaledSize?: Size); - anchor: Point; - origin: Point; - scaledSize: Size; - size: Size; - url: string; + export interface Icon { + anchor?: Point; + origin?: Point; + scaledSize?: Size; + size?: Size; + url?: string; } export interface MarkerShape { @@ -432,7 +402,7 @@ declare module google.maps { anchor?: Point; fillColor?: string; fillOpacity?: number; - path?: any; + path?: SymbolPath|string; rotation?: number; scale?: number; strokeColor?: string; @@ -456,24 +426,22 @@ declare module google.maps { export class InfoWindow extends MVCObject { constructor (opts?: InfoWindowOptions); close(): void; - getContent(): any; // string or Element + getContent(): string|Element; getPosition(): LatLng; getZIndex(): number; - open(map?: Map, anchor?: MVCObject): void; - open(map?: StreetViewPanorama, anchor?: MVCObject): void; - setContent(content: Node): void; - setContent(content: string): void; + open(map?: Map|StreetViewPanorama, anchor?: MVCObject): void; + setContent(content: string|Node): void; setOptions(options: InfoWindowOptions): void; setPosition(position: LatLng): void; setZIndex(zIndex: number): void; } export interface InfoWindowOptions { - content?: any; + content?: string|Node; disableAutoPan?: boolean; maxWidth?: number; pixelOffset?: Size; - position?: LatLng; + position?: LatLng|LatLngLiteral; zIndex?: number; } @@ -482,14 +450,13 @@ declare module google.maps { getDraggable(): boolean; getEditable(): boolean; getMap(): Map; - getPath(): MVCArray; + getPath(): MVCArray; // MVCArray getVisible(): boolean; setDraggable(draggable: boolean): void; setEditable(editable: boolean): void; setMap(map: Map): void; setOptions(options: PolylineOptions): void; - setPath(path: MVCArray): void; - setPath(path: LatLng[]): void; + setPath(path: MVCArray|LatLng[]|LatLngLiteral[]): void; // MVCArray|Array setVisible(visible: boolean): void; } @@ -500,7 +467,7 @@ declare module google.maps { geodesic?: boolean; icons?: IconSequence[]; map?: Map; - path?: any[]; + path?: MVCArray|LatLng[]|LatLngLiteral[]; // MVCArray|Array strokeColor?: string; strokeOpacity?: number; strokeWeight?: number; @@ -520,19 +487,20 @@ declare module google.maps { getDraggable(): boolean; getEditable(): boolean; getMap(): Map; - getPath(): MVCArray; - getPaths(): MVCArray; + getPath(): MVCArray; // MVCArray + getPaths(): MVCArray; // MVCArray> getVisible(): boolean; setDraggable(draggable: boolean): void; setEditable(editable: boolean): void; setMap(map: Map): void; setOptions(options: PolygonOptions): void; - setPath(path: MVCArray): void; - setPath(path: LatLng[]): void; + setPath(path: MVCArray|LatLng[]|LatLngLiteral[]): void; setPaths(paths: MVCArray): void; setPaths(paths: MVCArray[]): void; setPaths(path: LatLng[]): void; setPaths(path: LatLng[][]): void; + setPaths(path: LatLngLiteral[]): void; + setPaths(path: LatLngLiteral[][]): void; setVisible(visible: boolean): void; } @@ -544,7 +512,7 @@ declare module google.maps { fillOpacity?: number; geodesic?: boolean; map?: Map; - paths?: any[]; + paths?: any[]; // MVCArray>|MVCArray|Array>|Array strokeColor?: string; strokeOpacity?: number; strokePosition?: StrokePosition; @@ -599,7 +567,7 @@ declare module google.maps { getMap(): Map; getRadius(): number; getVisible(): boolean; - setCenter(center: LatLng): void; + setCenter(center: LatLng|LatLngLiteral): void; setDraggable(draggable: boolean): void; setEditable(editable: boolean): void; setMap(map: Map): void; @@ -649,23 +617,20 @@ declare module google.maps { export class OverlayView extends MVCObject { draw(): void; - getMap(): Map; + getMap(): Map|StreetViewPanorama; getPanes(): MapPanes; getProjection(): MapCanvasProjection; onAdd(): void; onRemove(): void; - setMap(map: Map): void; - setMap(map: StreetViewPanorama): void; + setMap(map: Map|StreetViewPanorama): void; } export interface MapPanes { floatPane: Element; - floatShadow: Element; mapPane: Element; - overlayImage: Element; + markerLayer: Element; overlayLayer: Element; overlayMouseTarget: Element; - overlayShadow: Element; } export class MapCanvasProjection extends MVCObject { @@ -678,17 +643,25 @@ declare module google.maps { /***** Services *****/ export class Geocoder { - constructor (); geocode(request: GeocoderRequest, callback: (results: GeocoderResult[], status: GeocoderStatus) => void ): void; } export interface GeocoderRequest { address?: string; bounds?: LatLngBounds; - location?: LatLng; + componentRestrictions: GeocoderComponentRestrictions; + location?: LatLng|LatLngLiteral; region?: string; } + export interface GeocoderComponentRestrictions { + administrativeArea: string; + country: string; + locality: string; + postalCode: string; + route: string; + } + export enum GeocoderStatus { ERROR, INVALID_REQUEST, @@ -703,6 +676,8 @@ declare module google.maps { address_components: GeocoderAddressComponent[]; formatted_address: string; geometry: GeocoderGeometry; + partial_match: boolean; + postcode_localities: string[] types: string[]; } @@ -757,16 +732,17 @@ declare module google.maps { } export class DirectionsService { - constructor (); route(request: DirectionsRequest, callback: (result: DirectionsResult, status: DirectionsStatus) => void ): void; } export interface DirectionsRequest { + avoidFerries?: boolean; avoidHighways?: boolean; avoidTolls?: boolean; - destination?: any; + destination?: LatLng|string; + durationInTraffic?: boolean; optimizeWaypoints?: boolean; - origin?: any; + origin?: LatLng|string; provideRouteAlternatives?: boolean; region?: string; transitOptions?: TransitOptions; @@ -790,10 +766,28 @@ declare module google.maps { export interface TransitOptions { arrivalTime?: Date; departureTime?: Date; + modes: TransitMode[]; + routingPreference: TransitRoutePreference; } + export enum TransitMode { + BUS, + RAIL, + SUBWAY, + TRAIN, + TRAM + } + + export enum TransitRoutePreference + { + FEWER_TRANSFERS, + LESS_WALKING + } + + export interface TransitFare { } + export interface DirectionsWaypoint { - location: any; + location: LatLng|string; stopover: boolean; } @@ -815,17 +809,20 @@ declare module google.maps { export interface DirectionsRoute { bounds: LatLngBounds; copyrights: string; + fare: TransitFare; legs: DirectionsLeg[]; overview_path: LatLng[]; + overview_polyline: string; warnings: string[]; waypoint_order: number[]; } export interface DirectionsLeg { - arrival_time: Distance; - departure_time: Duration; + arrival_time: Time; + departure_time: Time; distance: Distance; duration: Duration; + duration_in_traffic: Duration; end_address: string; end_location: LatLng; start_address: string; @@ -899,11 +896,31 @@ declare module google.maps { icon: string; local_icon: string; name: string; - type: string; + type: VehicleType; + } + + export enum VehicleType + { + BUS, + CABLE_CAR, + COMMUTER_TRAIN, + FERRY, + FUNICULAR, + GONDOLA_LIFT, + HEAVY_RAIL, + HIGH_SPEED_TRAIN, + INTERCITY_BUS, + METRO_RAIL, + MONORAIL, + OTHER, + RAIL, + SHARE_TAXI, + SUBWAY, + TRAM, + TROLLEYBUS } export class ElevationService { - constructor (); getElevationAlongPath(request: PathElevationRequest, callback: (results: ElevationResult[], status: ElevationStatus) => void ): void; getElevationForLocations(request: LocationElevationRequest, callback: (results: ElevationResult[], status: ElevationStatus) => void ): void; } @@ -932,8 +949,7 @@ declare module google.maps { } export class MaxZoomService { - constructor (); - getMaxZoomAtLatLng(latlng: LatLng, callback: (result: MaxZoomResult) => void ): void; + getMaxZoomAtLatLng(latlng: LatLng|LatLngLiteral, callback: (result: MaxZoomResult) => void ): void; } export interface MaxZoomResult { @@ -947,16 +963,18 @@ declare module google.maps { } export class DistanceMatrixService { - constructor (); getDistanceMatrix(request: DistanceMatrixRequest, callback: (response: DistanceMatrixResponse, status: DistanceMatrixStatus) => void ): void; } export interface DistanceMatrixRequest { + avoidFerries?: boolean; avoidHighways?: boolean; avoidTolls?: boolean; - destinations?: any[]; - origins?: any[]; + destinations?: LatLng[]|string[]; + durationInTraffic?: boolean; + origins?: LatLng[]|string[]; region?: string; + transitOptions?: TransitOptions; travelMode?: TravelMode; unitSystem?: UnitSystem; } @@ -974,6 +992,7 @@ declare module google.maps { export interface DistanceMatrixResponseElement { distance: Distance; duration: Duration; + fare: TransitFare; status: DistanceMatrixElementStatus; } @@ -992,6 +1011,33 @@ declare module google.maps { OK, ZERO_RESULTS } + + /***** Save to Google Maps *****/ + export interface Attribution { + iosDeepLinkId?: string; + source?: string; + webUrl?: string; + } + + export interface Place { + location?: LatLng|LatLngLiteral; + placeId?: string; + query?: string; + } + + export class SaveWidget { + constructor(container: Node, opts?: SaveWidgetOptions); + getAttribution(): Attribution; + getPlace(): Place; + setAttribution(attribution: Attribution): void; + setOptions(opts: SaveWidgetOptions): void; + setPlace(place: Place): void; + } + + export interface SaveWidgetOptions{ + attribution?: Attribution; + place?: Place; + } /***** Map Types *****/ export interface MapType { @@ -1333,7 +1379,7 @@ declare module google.maps { ZERO_RESULTS } - /***** Event *****/ + /***** Events *****/ export interface MapsEventListener { } export class event { @@ -1367,6 +1413,8 @@ declare module google.maps { } + export type LatLngLiteral = { lat: number; lng: number } + export class LatLngBounds { constructor (sw?: LatLng, ne?: LatLng); contains(latLng: LatLng): boolean; @@ -1399,6 +1447,34 @@ declare module google.maps { toString(): string; } + /***** MVC *****/ + export class MVCObject { + constructor (); + addListener(eventName: string, handler: (...args: any[]) => void): MapsEventListener; + bindTo(key: string, target: MVCObject, targetKey?: string, noNotify?: boolean): void; + changed(key: string): void; + get(key: string): any; + notify(key: string): void; + set(key: string, value: any): void; + setValues(values: any): void; + unbind(key: string): void; + unbindAll(): void; + } + + export class MVCArray extends MVCObject { + constructor (array?: any[]); + clear(): void; + forEach(callback: (elem: any, i: number) => void): void; + getArray(): any[]; + getAt(i: number): any; + getLength(): number; + insertAt(i: number, elem: any): void; + pop(): any; + push(elem: any): number; + removeAt(i: number): any; + setAt(i: number, elem: any): void; + } + /***** Geometry Library *****/ export module geometry { export class encoding { From eb5f7c2d2a1ee0de72fe9d8b40c9d33ec2612e63 Mon Sep 17 00:00:00 2001 From: Michael Nahkies Date: Wed, 10 Jun 2015 16:38:16 +1200 Subject: [PATCH 008/274] Add definition with test for when.settle, add a test for when.all --- when/when-tests.ts | 10 ++++++++++ when/when.d.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/when/when-tests.ts b/when/when-tests.ts index 61b688a035..7f365b4cc1 100644 --- a/when/when-tests.ts +++ b/when/when-tests.ts @@ -91,6 +91,16 @@ promise = liftedFunc5(when(1), when('2'), when(true), when(4), when('5')); var joinedPromise: when.Promise = when.join(when(1), when(2), when(3)); +/* when.all(arr) */ +when.all([when(1), when(2), when(3)]).then(results => { + return results.reduce((r, x) => r + x, 0); +}); + +/* when.settle(arr) */ +when.settle([when(1), when(2), when.reject(new Error("Foo"))]).then(descriptors => { + return descriptors.filter(d => d.state === 'rejected').reduce((r, d) => r + d.value, 0); +}); + /* when.promise(resolver) */ promise = when.promise(resolve => resolve(5)); diff --git a/when/when.d.ts b/when/when.d.ts index be5e25f154..ab44901de6 100644 --- a/when/when.d.ts +++ b/when/when.d.ts @@ -101,6 +101,32 @@ declare module When { */ function all(promisesOrValues: any[]): Promise; + /** + * Describes the status of a promise. + * state may be one of: + * "fulfilled" - the promise has resolved + * "pending" - the promise is still pending to resolve/reject + * "rejected" - the promise has rejected + */ + interface Descriptor { + state: string; + value?: T; + reason?: any; + } + + /** + * Returns a promise for an array containing the same number of elements as the input array. + * Each element is a descriptor object describing of the outcome of the corresponding element in the input. + * The returned promise will only reject if array itself is a rejected promise. Otherwise, + * it will always fulfill with an array of descriptors. This is in contrast to when.all, + * which will reject if any element of array rejects. + * @memberOf when + * + * @param promisesOrValues array of anything, may contain a mix + * of {@link Promise}s and values + */ + function settle(promisesOrValues: any[]): Promise[]>; + /** * Creates a {promise, resolver} pair, either or both of which * may be given out safely to consumers. From ce644f3dd330e22fa0e5b7eb43a728618d3fd41b Mon Sep 17 00:00:00 2001 From: vilicvane Date: Thu, 11 Jun 2015 18:00:48 +0800 Subject: [PATCH 009/274] complete multer declaration. --- multer/multer.d.ts | 87 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/multer/multer.d.ts b/multer/multer.d.ts index b188c22ae4..7e152894f6 100644 --- a/multer/multer.d.ts +++ b/multer/multer.d.ts @@ -1,14 +1,95 @@ // Type definitions for multer // Project: https://github.com/expressjs/multer -// Definitions by: jt000 +// Definitions by: jt000 vilicvane // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +declare module Express { + export interface Request { + files: { + [fieldname: string]: { + /** Field name specified in the form */ + fieldname: string; + /** Name of the file on the user's computer */ + originalname: string; + /** Renamed file name */ + name: string; + /** Encoding type of the file */ + encoding: string; + /** Mime type of the file */ + mimetype: string; + /** Location of the uploaded file */ + path: string; + /** Extension of the file */ + extension: string; + /** Size of the file in bytes */ + size: number; + /** If the file was truncated due to size limitation */ + truncated: boolean; + /** Raw data (is null unless the inMemory option is true) */ + buffer: Buffer; + } + } + } +} + declare module "multer" { import express = require('express'); - function multer(options?: any): express.RequestHandler; + function multer(options?: multer.Options): express.RequestHandler; + + module multer { + type Options = { + /** The destination directory for the uploaded files. */ + dest?: string; + /** An object specifying the size limits of the following optional properties. This object is passed to busboy directly, and the details of properties can be found on https://github.com/mscdex/busboy#busboy-methods */ + limits?: { + /** Max field name size (Default: 100 bytes) */ + fieldNameSize?: number; + /** Max field value size (Default: 1MB) */ + fieldSize?: number; + /** Max number of non- file fields (Default: Infinity) */ + fields?: number; + /** For multipart forms, the max file size (in bytes)(Default: Infinity) */ + fileSize?: number; + /** For multipart forms, the max number of file fields (Default: Infinity) */ + files?: number; + /** For multipart forms, the max number of parts (fields + files)(Default: Infinity) */ + parts?: number; + /** For multipart forms, the max number of header key=> value pairs to parse Default: 2000(same as node's http). */ + headerPairs?: number; + }; + /** A Boolean value to specify whether empty submitted values should be processed and applied to req.body; defaults to false; */ + includeEmptyFields?: boolean; + /** If this Boolean value is true, the file.buffer property holds the data in-memory that Multer would have written to disk. The dest option is still populated and the path property contains the proposed path to save the file. Defaults to false. */ + inMemory?: boolean; + /** Function to rename the uploaded files. Whatever the function returns will become the new name of the uploaded file (extension is not included). The fieldname and filename of the file will be available in this function, use them if you need to. */ + rename?: (fieldname: string, filename: string, req: Express.Request, res: Express.Response) => string; + /** Function to rename the directory in which to place uploaded files. The dest parameter is the default value originally assigned or passed into multer. The req and res parameters are also passed into the function because they may contain information (eg session data) needed to create the path (eg get userid from the session). */ + changeDest?: (dest: string, req: Express.Request, res: Express.Response) => string; + /** Event handler triggered when a file starts to be uploaded. A file object, with the following properties, is available to this function: fieldname, originalname, name, encoding, mimetype, path, and extension. */ + onFileUploadStart?: (file: string, req: Express.Request, res: Express.Response) => void; + /** Event handler triggered when a chunk of buffer is received. A buffer object along with a file object is available to the function. */ + onFileUploadData?: (file: string, data: Buffer, req: Express.Request, res: Express.Response) => void; + /** Event handler trigger when a file is completely uploaded. A file object is available to the function. */ + onFileUploadComplete?: (file: string, req: Express.Request, res: Express.Response) => void; + /** Event handler triggered when the form parsing starts. */ + onParseStart?: () => void; + /** Event handler triggered when the form parsing completes. The request object and the next objects are are passed to the function. */ + onParseEnd?: (req: Express.Request, next: () => void) => void; + /** Event handler for any errors encountering while processing the form. The error object and the next object is available to the function. If you are handling errors yourself, make sure to terminate the request or call the next() function, else the request will be left hanging. */ + onError?: () => void; + /** Event handler triggered when a file size exceeds the specification in the limit object. No more files will be parsed after the limit is reached. */ + onFileSizeLimit?: (file: string) => void; + /** Event handler triggered when the number of files exceed the specification in the limit object. No more files will be parsed after the limit is reached. */ + onFilesLimit?: () => void; + /** Event handler triggered when the number of fields exceed the specification in the limit object. No more fields will be parsed after the limit is reached. */ + onFieldsLimit?: () => void; + /** Event handler triggered when the number of parts exceed the specification in the limit object. No more files or fields will be parsed after the limit is reached. */ + onPartsLimit?: () => void; + }; + } export = multer; -} \ No newline at end of file +} From 376aa3d4ba6651c5c22a2a66fe67a2b32fc1d98a Mon Sep 17 00:00:00 2001 From: vilicvane Date: Thu, 11 Jun 2015 18:06:03 +0800 Subject: [PATCH 010/274] now multer extended `files` property --- express/express.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/express/express.d.ts b/express/express.d.ts index 0bd42b82f6..c5c623c9ba 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -389,8 +389,6 @@ declare module "express" { authenticatedUser: any; - files: any; - /** * Clear cookie `name`. * From a94992717c1800017483dc7de8aafdcfa0d87cd7 Mon Sep 17 00:00:00 2001 From: vilicvane Date: Thu, 11 Jun 2015 18:10:41 +0800 Subject: [PATCH 011/274] add missing comma --- multer/multer.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multer/multer.d.ts b/multer/multer.d.ts index 7e152894f6..fdde44b54f 100644 --- a/multer/multer.d.ts +++ b/multer/multer.d.ts @@ -1,6 +1,6 @@ // Type definitions for multer // Project: https://github.com/expressjs/multer -// Definitions by: jt000 vilicvane +// Definitions by: jt000 , vilicvane // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From b1192f0e1571397a03137b0df39652047d03c1db Mon Sep 17 00:00:00 2001 From: Kristof Mattei Date: Sat, 13 Jun 2015 16:21:22 +0200 Subject: [PATCH 012/274] Set the correct namespace --- angular-local-storage/angular-local-storage.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-local-storage/angular-local-storage.d.ts b/angular-local-storage/angular-local-storage.d.ts index f0500a96f6..940874d23b 100644 --- a/angular-local-storage/angular-local-storage.d.ts +++ b/angular-local-storage/angular-local-storage.d.ts @@ -6,7 +6,7 @@ /// declare module angular.local.storage { - interface ILocalStorageServiceProvider extends IServiceProvider { + interface ILocalStorageServiceProvider extends ng.IServiceProvider { /** * Setter for the prefix * You should set a prefix to avoid overwriting any local storage variables from the rest of your app @@ -129,7 +129,7 @@ declare module angular.local.storage { * @param value optional * @param key The corresponding key used in local storage */ - bind(scope: angular.IScope, property: string, value?: any, key?: string): Function; + bind(scope: ng.IScope, property: string, value?: any, key?: string): Function; /** * Return the derive key * Returns String From 7da2851ffc22ac4b875d0d91584232e03a79c25b Mon Sep 17 00:00:00 2001 From: nfantone Date: Sun, 14 Jun 2015 17:38:54 -0300 Subject: [PATCH 013/274] Add sample() to LoDashArrayWrapper interface --- lodash/lodash-tests.ts | 2 ++ lodash/lodash.d.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 633c4ed0d4..e0f2b82269 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -605,6 +605,8 @@ result = _(foodsCombined).reject({ 'type': 'fruit' }).value(); result = _.sample([1, 2, 3, 4]); result = _.sample([1, 2, 3, 4], 2); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).sample(); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).sample(2); result = _.shuffle([1, 2, 3, 4, 5, 6]); result = <_.LoDashArrayWrapper>_([1, 2, 3]).shuffle(); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 9cb55485d9..a906b907f3 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -22,7 +22,7 @@ declare module _ { * forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, functions, groupBy, * indexBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min, * object, omit, once, pairs, partial, partialRight, pick, pluck, pull, push, range, reject, - * remove, rest, reverse, shuffle, slice, sort, sortBy, splice, tap, throttle, times, + * remove, rest, reverse, sample, shuffle, slice, sort, sortBy, splice, tap, throttle, times, * toArray, transform, union, uniq, unshift, unzip, values, where, without, wrap, and zip * * The non-chainable wrapper functions are: @@ -4559,6 +4559,18 @@ declare module _ { sample(collection: Dictionary, n: number): T[]; } + interface LoDashArrayWrapper { + /** + * @see _.sample + **/ + sample(n: number): LoDashArrayWrapper; + + /** + * @see _.sample + **/ + sample(): LoDashArrayWrapper; + } + //_.shuffle interface LoDashStatic { /** From f9c3edf6c6c32726e7e424fc3690da5ff1b0eef6 Mon Sep 17 00:00:00 2001 From: Haskell Camargo Date: Sun, 14 Jun 2015 23:21:47 -0300 Subject: [PATCH 014/274] Each is not void, it returns a parameter of type A[] --- prelude-ls/prelude-ls-tests.ts | 16 ++++++++++------ prelude-ls/prelude-ls.d.ts | 6 ++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts index b6e50e2256..8c37a1e717 100644 --- a/prelude-ls/prelude-ls-tests.ts +++ b/prelude-ls/prelude-ls-tests.ts @@ -1,23 +1,27 @@ +/// + import prelude = require("prelude-ls"); -prelude.id(5); //=> 5 -prelude.id({}); //=> {} +var five: number = prelude.id(5); //=> 5 +var emptyObj: Object = prelude.id({}); //=> {} -prelude.isType("Undefined", void 8); //=> true +var expectBool: boolean = prelude.isType("Undefined", void 8); //=> true prelude.isType("Boolean", true); //=> true prelude.isType("Number", 1); //=> true prelude.isType("String", "hi"); //=> true prelude.isType("Object", {}); //=> true prelude.isType("Array", []); //=> true -prelude.replicate(4, 3); //=> [3, 3, 3, 3] -prelude.replicate(4, "a"); //=> ["a", "a", "a", "a"] +var numberArray: Array = prelude.replicate(4, 3); //=> [3, 3, 3, 3] +var strArray: Array = + prelude.replicate(4, "a"); //=> ["a", "a", "a", "a"] prelude.replicate(0, "a"); //=> [] // List -prelude.each(x => x.push("boom"), [["a"], ["b"], ["c"]]); +var dblStrArray: Array> = + prelude.each(x => x.push("boom"), [["a"], ["b"], ["c"]]); //=> [["a", "boom"], ["b", "boom"], ["c", "boom"]] prelude.map(x => x * 2, [1, 2, 3, 4, 5]); //=> [2, 4, 6, 8, 10] diff --git a/prelude-ls/prelude-ls.d.ts b/prelude-ls/prelude-ls.d.ts index 848077c822..0de28f63a8 100644 --- a/prelude-ls/prelude-ls.d.ts +++ b/prelude-ls/prelude-ls.d.ts @@ -3,6 +3,8 @@ // Definitions by: Aya Morisawa // Definitions: https://github.com/borisyankov/DefinitelyTyped +// Change [0]: 2015/06/14 - Marcelo Camargo + declare module "prelude-ls" { module PreludeLS { export function id(x: A): A; @@ -14,8 +16,8 @@ declare module "prelude-ls" { // List - export function each(f: (x: A) => void): (xs: A[]) => void; - export function each(f: (x: A) => void, xs: A[]): void; + export function each(f: (x: A) => void): (xs: A[]) => A[]; + export function each(f: (x: A) => void, xs: A[]): A[]; export function map(f: (x: A) => B): (xs: A[]) => B[]; export function map(f: (x: A) => B, xs: A[]): B[]; export function compact(xs: A[]): A[]; From 19795463b32a83f4f68b55e8c8068f3956a4b7d3 Mon Sep 17 00:00:00 2001 From: Haskell Camargo Date: Sun, 14 Jun 2015 23:31:32 -0300 Subject: [PATCH 015/274] Correction on return types for find, head and last --- prelude-ls/prelude-ls-tests.ts | 30 +++++++++++++++++++----------- prelude-ls/prelude-ls.d.ts | 8 ++++---- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts index 8c37a1e717..080f40afbd 100644 --- a/prelude-ls/prelude-ls-tests.ts +++ b/prelude-ls/prelude-ls-tests.ts @@ -20,32 +20,40 @@ prelude.replicate(0, "a"); //=> [] // List -var dblStrArray: Array> = +var eachRes: Array> = prelude.each(x => x.push("boom"), [["a"], ["b"], ["c"]]); //=> [["a", "boom"], ["b", "boom"], ["c", "boom"]] -prelude.map(x => x * 2, [1, 2, 3, 4, 5]); //=> [2, 4, 6, 8, 10] +var mapRes: Array = + prelude.map(x => x.toString(), [1, 2, 3, 4, 5]) //=> ["1", "2", "3", "4", "5"] + prelude.map(x => x.toUpperCase(), ["ha", "ma"]); //=> ["HA", "MA"] prelude.map(x => x.num, [{num: 3}, {num: 1}]); //=> [3, 1] -prelude.compact([0, 1, false, true, "", "ha"]) //=> [1, true, "ha"] +var compactRes: Array = + prelude.compact([0, 1, false, true, "", "ha"]) //=> [1, true, "ha"] -prelude.filter(x => x < 3, [1, 2, 3, 4, 5]); //=> [1, 2] +var filterRes: Array = + prelude.filter(x => x < 3, [1, 2, 3, 4, 5]); //=> [1, 2] prelude.filter(prelude.even, [3, 4, 0]); //=> [4, 0] -prelude.reject(prelude.odd, [1, 2, 3, 4, 5]); //=> [2, 4] +var rejectRes: Array = + prelude.reject(prelude.odd, [1, 2, 3, 4, 5]); //=> [2, 4] -prelude.partition(x => x > 60, [49, 58, 76, 43, 88, 77, 90]); //=> [[76, 88, 77, 90], [49, 58, 43]] +var partitionRes: Array> = + prelude.partition(x => x > 60, [49, 58, 76, 43, 88, 77, 90]); + //=> [[76, 88, 77, 90], [49, 58, 43]] -prelude.find(prelude.odd, [2, 4, 6, 7, 8, 9, 10]); //=> 7 +var findRes: number = prelude.find(prelude.odd, [2, 4, 6, 7, 8, 9, 10]); //=> 7 -prelude.head([1, 2, 3, 4, 5]); //=> 1 +var headRes: number = prelude.head([1, 2, 3, 4, 5]); //=> 1 -prelude.tail([1, 2, 3, 4, 5]); //=> [2, 3, 4, 5] +var tailRes: Array = prelude.tail([1, 2, 3, 4, 5]); //=> [2, 3, 4, 5] -prelude.last([1, 2, 3, 4, 5]); //=> 5 +var lastRes: number = prelude.last([1, 2, 3, 4, 5]); //=> 5 -prelude.initial([1, 2, 3, 4, 5]); //=> [1, 2, 3, 4] +var initialRes: Array = + prelude.initial([1, 2, 3, 4, 5]); //=> [1, 2, 3, 4] prelude.empty([]); //=> true diff --git a/prelude-ls/prelude-ls.d.ts b/prelude-ls/prelude-ls.d.ts index 0de28f63a8..f72db01800 100644 --- a/prelude-ls/prelude-ls.d.ts +++ b/prelude-ls/prelude-ls.d.ts @@ -27,11 +27,11 @@ declare module "prelude-ls" { export function reject(f: (x: A) => boolean, xs: A[]): A[]; export function partition(f: (x: A) => Boolean): (xs: A[]) => [A[], A[]]; export function partition(f: (x: A) => Boolean, xs: A[]): [A[], A[]]; - export function find(f: (x: A) => Boolean): (xs: A[]) => (A | void); - export function find(f: (x: A) => Boolean, xs: A[]): (A | void); - export function head(xs: A[]): (A | void); + export function find(f: (x: A) => Boolean): (xs: A[]) => A; + export function find(f: (x: A) => Boolean, xs: A[]): A; + export function head(xs: A[]): A; export function tail(xs: A[]): A[]; - export function last(xs: A[]): (A | void); + export function last(xs: A[]): A; export function initial(xs: A[]): A[]; export function empty(xs: A[]): boolean; export function reverse(xs: A[]): A[]; From c5eee1bdc66ce227a58140a8ae166de4485bd883 Mon Sep 17 00:00:00 2001 From: Haskell Camargo Date: Sun, 14 Jun 2015 23:40:03 -0300 Subject: [PATCH 016/274] Correction on argument types for intersection and union --- prelude-ls/prelude-ls-tests.ts | 56 ++++++++++++++++++++++------------ prelude-ls/prelude-ls.d.ts | 4 +-- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts index 080f40afbd..d3d5fcd4dd 100644 --- a/prelude-ls/prelude-ls-tests.ts +++ b/prelude-ls/prelude-ls-tests.ts @@ -55,41 +55,57 @@ var lastRes: number = prelude.last([1, 2, 3, 4, 5]); //=> 5 var initialRes: Array = prelude.initial([1, 2, 3, 4, 5]); //=> [1, 2, 3, 4] -prelude.empty([]); //=> true +var emptyRes: boolean = prelude.empty([]); //=> true -prelude.reverse([1, 2, 3]); //=> [3, 2, 1] +var reverseRes: Array = prelude.reverse([1, 2, 3]); //=> [3, 2, 1] -prelude.unique([1, 1, 1, 3, 3, 6, 7, 8]); //=> [1, 3, 6, 7, 8] +var uniqueRes: Array = + prelude.unique([1, 1, 1, 3, 3, 6, 7, 8]); //=> [1, 3, 6, 7, 8] -prelude.uniqueBy(x => x.length, ["and", "here", "are", "some", "words"]); //=> ["and", "here", "words"] +var uniqueByRes: Array = + prelude.uniqueBy(x => x.length, ["and", "here", "are", "some", "words"]); //=> ["and", "here", "words"] -prelude.fold(x => y => x + y, 0, [1, 2, 3, 4, 5]); //=> 15 -var product = prelude.fold(x => y => x * y, 1); +var foldRes: number = + prelude.fold(x => y => x + y, 0, [1, 2, 3, 4, 5]); //=> 15 -prelude.fold1(x => y => x + y, [1, 2, 3]); //=> 6 +var fold1Res: number = + prelude.fold1(x => y => x + y, [1, 2, 3]); //=> 6 -prelude.foldr(x => y => x - y, 9, [1, 2, 3, 4]); //=> 7 -prelude.foldr(x => y => x + y, "e", ["a", "b", "c", "d"]); //=> "abcde" +var foldrRes: number = + prelude.foldr(x => y => x - y, 9, [1, 2, 3, 4]); //=> 7 -prelude.foldr1(x => y => x - y, [1, 2, 3, 4, 9]); //=> 7 +var foldrStrRes: string = + prelude.foldr(x => y => x + y, "e", ["a", "b", "c", "d"]); //=> "abcde" -prelude.unfoldr(x => x === 0 ? null : [x, x - 1], 10); -//=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] +var foldr1Res: number = + prelude.foldr1(x => y => x - y, [1, 2, 3, 4, 9]); //=> 7 -prelude.concat([[1], [2, 3], [4]]); //=> [1, 2, 3, 4] +var unfoldrRes: Array = + prelude.unfoldr(x => x === 0 ? null : [x, x - 1], 10); + //=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] -prelude.concatMap(x => ["hoge", x, x + 2], [1, 2, 3]); //=> ["hoge", 1, 3, "hoge", 2, 4, "hoge", 3, 5] +var concatRes: Array = + prelude.concat([[1], [2, 3], [4]]); //=> [1, 2, 3, 4] -prelude.flatten([1, [[2], 3], [4, [[5]]]]); //=> [1, 2, 3, 4, 5] +var concatMapRes: Array = + prelude.concatMap(x => ["hoge", x, x + 2], [1, 2, 3]); + //=> ["hoge", 1, 3, "hoge", 2, 4, "hoge", 3, 5] -prelude.difference([1, 2, 3], [1]); //=> [2, 3] +var flattenRes: Array = + prelude.flatten([1, [[2], 3], [4, [[5]]]]); //=> [1, 2, 3, 4, 5] + +var differenceRes: Array = + prelude.difference([1, 2, 3], [1]); //=> [2, 3] prelude.difference([1, 2, 3, 4, 5], [5, 2, 10], [9]); //=> [1, 3, 4] -prelude.intersection([2, 3], [9, 8], [12, 1], [99]); //=> [] -prelude.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1], [-1, 0, 1, 2]); //=> [1, 2] -prelude.intersection([1, 2, 3], [2, 1, 3], [3, 1, 2]); //=> [1, 2, 3] +prelude.intersection([2, 3], [9, 8], [12, 1], [99]); //=> [] +var intersectionRes: Array = + prelude.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1], [-1, 0, 1, 2]); +//=> [1, 2] +prelude.intersection([1, 2, 3], [2, 1, 3], [3, 1, 2]); //=> [1, 2, 3] -prelude.union([1, 5, 7], [3, 5], []); //=> [1, 5, 7, 3] +var unionRes: Array = + prelude.union([1, 5, 7], [3, 5], []); //=> [1, 5, 7, 3] prelude.countBy(prelude.floor, [4.2, 6.1, 6.4]); //=> {4: 1, 6: 2} prelude.countBy(x => x.length, ["one", "two", "three"]); //=> {3: 2, 5: 1} diff --git a/prelude-ls/prelude-ls.d.ts b/prelude-ls/prelude-ls.d.ts index f72db01800..fde6ed1578 100644 --- a/prelude-ls/prelude-ls.d.ts +++ b/prelude-ls/prelude-ls.d.ts @@ -60,8 +60,8 @@ declare module "prelude-ls" { export function concatMap(f: (x: A) => B[], xs: A[]): B[]; export function flatten(xs: any[]): any[]; export function difference(...xss: A[][]): A[]; - export function intersection(...xss: A[]): A[]; - export function union(...xss: A[]): A[]; + export function intersection(...xss: A[][]): A[]; + export function union(...xss: A[][]): A[]; export function countBy(f: (x: A) => B): (xs: A[]) => any; export function countBy(f: (x: A) => B, xs: A[]): any; export function groupBy(f: (x: A) => B): (xs: A[]) => any; From b64f70ca142cb7932abfd2c2db501c182362ab25 Mon Sep 17 00:00:00 2001 From: Haskell Camargo Date: Sun, 14 Jun 2015 23:50:43 -0300 Subject: [PATCH 017/274] Added tests for numbers and strings, with assignment --- prelude-ls/prelude-ls-tests.ts | 80 +++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts index d3d5fcd4dd..5bc034bc48 100644 --- a/prelude-ls/prelude-ls-tests.ts +++ b/prelude-ls/prelude-ls-tests.ts @@ -107,6 +107,8 @@ prelude.intersection([1, 2, 3], [2, 1, 3], [3, 1, 2]); //=> [1, 2, 3] var unionRes: Array = prelude.union([1, 5, 7], [3, 5], []); //=> [1, 5, 7, 3] +// --- UNION --- + prelude.countBy(prelude.floor, [4.2, 6.1, 6.4]); //=> {4: 1, 6: 2} prelude.countBy(x => x.length, ["one", "two", "three"]); //=> {3: 2, 5: 1} @@ -300,94 +302,100 @@ prelude.Str.breakStr(x => x === "h", "mmmmmhmm"); //=> ["mmmmm", "hmm"] // Func -prelude.apply((x, y) => x + y, [2, 3]); //=> 5 +var applyRes: number = prelude.apply((x, y) => x + y, [2, 3]); //=> 5 var add = (x: number, y: number) => x + y; var addCurried = prelude.curry(add); var addFour = addCurried(4); addFour(2); //=> 6 -var invertedPower = prelude.flip(x => y => Math.pow(x, y)); -invertedPower(2)(3); //=> 9 +var flipRes: (x: number) => (y: number) => number + = prelude.flip(x => y => Math.pow(x, y)); -prelude.fix((fib: (n: number) => number) => (n: number) => n <= 1 ? 1 : fib(n - 1) + fib(n - 2))(9); //=> 55 +var fixRes: number = prelude.fix( + (fib: (n: number) => number) => (n: number) => + n <= 1 + ? 1 + : fib(n - 1) + fib(n - 2) +)(9); //=> 55 -var sameLength = prelude.over((x, y) => x == y, x => x.length); +var sameLength: (x: string, y: string) => boolean + = prelude.over((x, y) => x == y, x => x.length); sameLength('hi', 'me'); //=> true sameLength('one', 'boom'); //=> false // Num prelude.max(3, 1); //=> 3 -prelude.max("a", "c"); //=> "c" +var maxRes: string = prelude.max("a", "c"); //=> "c" -prelude.min(3, 1); //=> 1 +var minRes: number = prelude.min(3, 1); //=> 1 prelude.min("a", "c"); //=> "a" -prelude.negate(3); //=> -3 +var negateRes: number = prelude.negate(3); //=> -3 prelude.negate(-2); //=> 2 -prelude.abs(-2); //=> 2 +var absRes: number = prelude.abs(-2); //=> 2 prelude.abs(2); //=> 2 -prelude.signum(-5); //=> -1 +var signumRes: number = prelude.signum(-5); //=> -1 prelude.signum(0); //=> 0 prelude.signum(9); //=> 1 -prelude.quot(-20, 3); //=> -6 +var quotRes: number = prelude.quot(-20, 3); //=> -6 -prelude.rem(-20, 3); //=> -2 +var remRes: number = prelude.rem(-20, 3); //=> -2 -prelude.div(-20, 3); //=> -7 +var divRes: number = prelude.div(-20, 3); //=> -7 -prelude.mod(-20, 3); //=> 1 +var modRes: number = prelude.mod(-20, 3); //=> 1 -prelude.recip(4); //=> 0.25 +var recipRes: number = prelude.recip(4); //=> 0.25 -prelude.pi; //=> 3.141592653589793 +var piRes: number = prelude.pi; //=> 3.141592653589793 -prelude.tau; //=> 6.283185307179586 +var tauRes: number = prelude.tau; //=> 6.283185307179586 -prelude.exp(1); //=> 2.718281828459045 +var expRes: number = prelude.exp(1); //=> 2.718281828459045 -prelude.sqrt(4); //=> 2 +var sqrtRes: number = prelude.sqrt(4); //=> 2 -prelude.ln(10); //=> 2.302585092994046 +var lnRes: number = prelude.ln(10); //=> 2.302585092994046 -prelude.pow(-2, 2); //=> 4 +var powRes: number = prelude.pow(-2, 2); //=> 4 -prelude.sin(prelude.pi / 2); //=> 1 +var sinRes: number = prelude.sin(prelude.pi / 2); //=> 1 -prelude.cos(prelude.pi); //=> -1 +var cosRes: number = prelude.cos(prelude.pi); //=> -1 -prelude.tan(prelude.pi / 4); //=> 1 +var aTanRes: number = prelude.tan(prelude.pi / 4); //=> 1 -prelude.asin(0); //=> 0 +var asinRes: number = prelude.asin(0); //=> 0 -prelude.acos(1); //=> 0 +var acosRes: number = prelude.acos(1); //=> 0 prelude.atan(0); //=> 0 -prelude.atan2(1, 0); //=> 1.5707963267948966 +var atanRes: number = prelude.atan2(1, 0); //=> 1.5707963267948966 -prelude.truncate(-1.5); //=> -1 +var truncateRes: number = prelude.truncate(-1.5); //=> -1 prelude.truncate(1.5); //=> 1 -prelude.round(0.6); //=> 1 +var roundRes: number = prelude.round(0.6); //=> 1 prelude.round(0.5); //=> 1 prelude.round(0.4); //=> 0 -prelude.ceiling(0.1); //=> 1 +var ceilingRes: number = prelude.ceiling(0.1); //=> 1 -prelude.floor(0.9); //=> 0 +var floorRes: number = prelude.floor(0.9); //=> 0 -prelude.isItNaN(prelude.sqrt(-1)); //=> true +var isItNanRes: boolean = prelude.isItNaN(prelude.sqrt(-1)); //=> true -prelude.even(4); //=> true +var evenRes: boolean = prelude.even(4); //=> true prelude.even(0); //=> true -prelude.odd(3); //=> true +var oddRes: boolean = prelude.odd(3); //=> true -prelude.gcd(12, 18); //=> 6 +var gcdRes: number = prelude.gcd(12, 18); //=> 6 -prelude.lcm(12, 18); //=> 36 \ No newline at end of file +var lcmRes: number = prelude.lcm(12, 18); //=> 36 \ No newline at end of file From 827ec75fbbf3d125a680b0b74e10f0c5e6beb567 Mon Sep 17 00:00:00 2001 From: Haskell Camargo Date: Sun, 14 Jun 2015 23:56:22 -0300 Subject: [PATCH 018/274] sortBy should return A[] instead of A --- prelude-ls/prelude-ls-tests.ts | 36 ++++++++++++++++++++++------------ prelude-ls/prelude-ls.d.ts | 4 ++-- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts index 5bc034bc48..c04fb2277e 100644 --- a/prelude-ls/prelude-ls-tests.ts +++ b/prelude-ls/prelude-ls-tests.ts @@ -107,28 +107,31 @@ prelude.intersection([1, 2, 3], [2, 1, 3], [3, 1, 2]); //=> [1, 2, 3] var unionRes: Array = prelude.union([1, 5, 7], [3, 5], []); //=> [1, 5, 7, 3] -// --- UNION --- - -prelude.countBy(prelude.floor, [4.2, 6.1, 6.4]); //=> {4: 1, 6: 2} +var countByRes: Object = prelude.countBy(prelude.floor, [4.2, 6.1, 6.4]); +//=> {4: 1, 6: 2} prelude.countBy(x => x.length, ["one", "two", "three"]); //=> {3: 2, 5: 1} -prelude.groupBy(prelude.floor, [4.2, 6.1, 6.4]); //=> {4: [4.2], 6: [6.1, 6.4]} -prelude.groupBy(x => x.length, ["one", "two", "three"]); //=> {3: ["one", "two"], 5: ["three"]} +var groupByRes: Object = prelude.groupBy(prelude.floor, [4.2, 6.1, 6.4]); +//=> {4: [4.2], 6: [6.1, 6.4]} +prelude.groupBy(x => x.length, ["one", "two", "three"]); +//=> {3: ["one", "two"], 5: ["three"]} -prelude.andList([true, 2 + 2 == 4]); //=> true +var andListRes: boolean = prelude.andList([true, 2 + 2 == 4]); //=> true prelude.andList([true, true, false]); //=> false prelude.andList([]); //=> true -prelude.orList([false, false, true, false]); //=> true +var orListRes: boolean = prelude.orList([false, false, true, false]); //=> true prelude.orList([]); //=> false -prelude.any(prelude.even, [3, 5, 7, 8, 9]); //=> true +var anyRes: boolean = prelude.any(prelude.even, [3, 5, 7, 8, 9]); //=> true prelude.any(prelude.even, []); //=> false -prelude.all(prelude.isType("String"), ["ha", "ma", "la"]); //=> true +var allRes: boolean = prelude.all(prelude.isType("String"), ["ha", "ma", "la"]); +//=> true prelude.all(prelude.isType("String"), []); //=> true -prelude.sort([3, 1, 5, 2, 4, 6]); //=> [1, 2, 3, 4, 5, 6] +var sortRes: Array = prelude.sort([3, 1, 5, 2, 4, 6]); +//=> [1, 2, 3, 4, 5, 6] var f = (x: string) => (y: string) => x.length > y.length ? @@ -137,11 +140,18 @@ var f = (x: string) => (y: string) => -1 : 0; -prelude.sortWith(f, ["three", "one", "two"]); //=> ["one", "two", "three"] -prelude.sortBy(x => x.length, ["there", "hey", "a", "ha"]); //=> ["a", "ha", "hey", "there"] +var sortWithRes: Array = prelude.sortWith(f, ["three", "one", "two"]); +//=> ["one", "two", "three"] -var table = [{ +var sortByRes: Array = + prelude.sortBy(x => x.length, ["there", "hey", "a", "ha"]); + //=> ["a", "ha", "hey", "there"] + +var table: Array<{ + id: number, + name: string +}> = [{ id: 1, name: "george" }, { diff --git a/prelude-ls/prelude-ls.d.ts b/prelude-ls/prelude-ls.d.ts index fde6ed1578..26c1890d4f 100644 --- a/prelude-ls/prelude-ls.d.ts +++ b/prelude-ls/prelude-ls.d.ts @@ -75,8 +75,8 @@ declare module "prelude-ls" { export function sort(xs: A[]): A[]; export function sortWith(f: (x: A) => (y: A) => number): (xs: A[]) => A[]; export function sortWith(f: (x: A) => (y: A) => number, xs: A[]): A[]; - export function sortBy(f: (x: A) => B): (xs: A[]) => A; - export function sortBy(f: (x: A) => B, xs: A[]): A; + export function sortBy(f: (x: A) => B): (xs: A[]) => A[]; + export function sortBy(f: (x: A) => B, xs: A[]): A[]; export function sum(xs: number[]): number[]; export function product(xs: number[]): number[]; export function mean(xs: number[]): number[]; From d8822b4a8c471de06715e6bb23a494e62a643c68 Mon Sep 17 00:00:00 2001 From: Haskell Camargo Date: Mon, 15 Jun 2015 00:00:47 -0300 Subject: [PATCH 019/274] Return type for sum, product and mean are number, not number[] --- prelude-ls/prelude-ls-tests.ts | 20 +++++++++++--------- prelude-ls/prelude-ls.d.ts | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts index c04fb2277e..a92c3c4243 100644 --- a/prelude-ls/prelude-ls-tests.ts +++ b/prelude-ls/prelude-ls-tests.ts @@ -162,23 +162,25 @@ var table: Array<{ name: "donald" }]; prelude.sortBy(x => x.name, table); -//=> [{"id": 3, "name": "donald"}, {"id": 1, "name": "george"}, {"id": 2, "name": "mike"}] +//=> [{"id": 3, "name": "donald"}, +// {"id": 1, "name": "george"}, +// {"id": 2, "name": "mike"}] -prelude.sum([1, 2, 3, 4, 5]); //=> 15 +var sumRes: number = prelude.sum([1, 2, 3, 4, 5]); //=> 15 prelude.sum([]); //=> 0 -prelude.product([1, 2, 3]); //=> 6 +var productRes: number = prelude.product([1, 2, 3]); //=> 6 prelude.product([]); //=> 1 -prelude.mean([1, 2, 3, 4, 5]); //=> 3 +var meanRes: number = prelude.mean([1, 2, 3, 4, 5]); //=> 3 -prelude.maximum([4, 1, 9, 3]); //=> 9 +var maximumRes: number = prelude.maximum([4, 1, 9, 3]); //=> 9 -prelude.minimum(["c", "e", "a", "d", "b"]); //=> "a" +var minimumRes: string = prelude.minimum(["c", "e", "a", "d", "b"]); //=> "a" -prelude.maximumBy(x => x.length, ["hi", "there", "I", "am", "looooong"]); //=> "looooong" - -prelude.maximumBy(x => x.length, ["hi", "there", "I", "am", "looooong"]); //=> "looooong" +var maximumByRes: string = + prelude.maximumBy(x => x.length, ["hi", "there", "I", "am", "looooong"]); + //=> "looooong" prelude.scan(x => y => x + y, 0, [1, 2, 3]); //=> [0, 1, 3, 6] diff --git a/prelude-ls/prelude-ls.d.ts b/prelude-ls/prelude-ls.d.ts index 26c1890d4f..053ed53a4a 100644 --- a/prelude-ls/prelude-ls.d.ts +++ b/prelude-ls/prelude-ls.d.ts @@ -77,9 +77,9 @@ declare module "prelude-ls" { export function sortWith(f: (x: A) => (y: A) => number, xs: A[]): A[]; export function sortBy(f: (x: A) => B): (xs: A[]) => A[]; export function sortBy(f: (x: A) => B, xs: A[]): A[]; - export function sum(xs: number[]): number[]; - export function product(xs: number[]): number[]; - export function mean(xs: number[]): number[]; + export function sum(xs: number[]): number; + export function product(xs: number[]): number; + export function mean(xs: number[]): number; export function maximum(xs: A[]): A; export function minimum(xs: A[]): A; export function maximumBy(f: (x: A) => B): (xs: A[]) => A; From e7c93592608108364fcbb09771c4a3222d9ac9dc Mon Sep 17 00:00:00 2001 From: Haskell Camargo Date: Mon, 15 Jun 2015 00:07:00 -0300 Subject: [PATCH 020/274] Passed tests for Prelude.List --- prelude-ls/prelude-ls-tests.ts | 51 ++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts index a92c3c4243..e21893e525 100644 --- a/prelude-ls/prelude-ls-tests.ts +++ b/prelude-ls/prelude-ls-tests.ts @@ -182,48 +182,63 @@ var maximumByRes: string = prelude.maximumBy(x => x.length, ["hi", "there", "I", "am", "looooong"]); //=> "looooong" -prelude.scan(x => y => x + y, 0, [1, 2, 3]); //=> [0, 1, 3, 6] +var scanRes: Array = prelude.scan(x => y => x + y, 0, [1, 2, 3]); +//=> [0, 1, 3, 6] -prelude.scan1(x => y => x + y, [1, 2, 3]); //=> [1, 3, 6] +var scan1Res: Array = prelude.scan1(x => y => x + y, [1, 2, 3]); +//=> [1, 3, 6] -prelude.scanr(x => y => x + y, 0, [1, 2, 3]); //=> [6, 5, 3, 0] +var scanrRes: Array = prelude.scanr(x => y => x + y, 0, [1, 2, 3]); +//=> [6, 5, 3, 0] -prelude.scanr1(x => y => x + y, [1, 2, 3]); //=> [6, 5, 3] +var scanr1Res: Array = prelude.scanr1(x => y => x + y, [1, 2, 3]); +//=> [6, 5, 3] -prelude.slice(2, 4, [1, 2, 3, 4, 5]); //=> [3, 4] +var sliceRes: Array = prelude.slice(2, 4, [1, 2, 3, 4, 5]); //=> [3, 4] -prelude.take(2, [1, 2, 3, 4, 5]); //=> [1, 2] +var takeRes: Array = prelude.take(2, [1, 2, 3, 4, 5]); //=> [1, 2] -prelude.drop(2, [1, 2, 3, 4, 5]); //=> [3, 4, 5] +var dropRes: Array = prelude.drop(2, [1, 2, 3, 4, 5]); //=> [3, 4, 5] -prelude.splitAt(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [3, 4, 5]] +var splitAtRes: Array> = + prelude.splitAt(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [3, 4, 5]] -prelude.takeWhile(prelude.odd, [1, 3, 5, 4, 8, 7, 9]); //=> [1, 3, 5] +var takeWhileRes: Array = + prelude.takeWhile(prelude.odd, [1, 3, 5, 4, 8, 7, 9]); //=> [1, 3, 5] -prelude.dropWhile(prelude.even, [2, 4, 5, 6]); //=> [5, 6] +var dropWhileRes: Array = + prelude.dropWhile(prelude.even, [2, 4, 5, 6]); //=> [5, 6] +var spanRes: Array> = prelude.span(prelude.even, [2, 4, 5, 6]); //=> [[2, 4], [5, 6]] -prelude.breakList(x => x == 3, [1, 2, 3, 4, 5]); //=> [[1, 2], [3, 4, 5]] +var breakListRes: Array> = + prelude.breakList(x => x == 3, [1, 2, 3, 4, 5]); //=> [[1, 2], [3, 4, 5]] -prelude.zip([1, 2, 3], [4, 5, 6]); //=> [[1, 4], [2, 5], [3, 6]] +var zipRes: Array> = prelude.zip([1, 2, 3], [4, 5, 6]); +//=> [[1, 4], [2, 5], [3, 6]] -prelude.zipWith(x => y => x + y, [1, 2, 3], [4, 5, 6]); //=> [5, 7, 9] +var zipWithRes: Array = + prelude.zipWith(x => y => x + y, [1, 2, 3], [4, 5, 6]); //=> [5, 7, 9] +var zipAllRes: Array> = prelude.zipAll([1, 2, 3], [4, 5, 6], [7, 8, 9]); //=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]] +var zipAllWithRes: Array = prelude.zipAllWith((a, b, c) => a + b + c, [1, 2, 3], [3, 2, 1], [1, 1, 1]); //=> [5, 5, 5] -prelude.at(2, [1, 2, 3, 4]); //=> 3 +var atRes: number = prelude.at(2, [1, 2, 3, 4]); //=> 3 prelude.at(-3, [1, 2, 3, 4]); //=> 2 -prelude.elemIndex("a", ["c", "a", "b", "a"]); //=> 1 +var elemIndexRes: number = prelude.elemIndex("a", ["c", "a", "b", "a"]); //=> 1 -prelude.elemIndices("a", ["c", "a", "b", "a"]); //=> [1, 3] +var elemIndicesRes: Array = + prelude.elemIndices("a", ["c", "a", "b", "a"]); //=> [1, 3] -prelude.findIndex(prelude.even, [1, 2, 3, 4]); //=> 1 +var findIndexRes: number = prelude.findIndex(prelude.even, [1, 2, 3, 4]); //=> 1 -prelude.findIndices(prelude.even, [1, 2, 3, 4]); //=> [1, 3] +var findIndicesRes: Array = + prelude.findIndices(prelude.even, [1, 2, 3, 4]); //=> [1, 3] // Obj From 835b936c5a3080da4f960631f23dadd0ccd69fe4 Mon Sep 17 00:00:00 2001 From: Haskell Camargo Date: Mon, 15 Jun 2015 00:16:37 -0300 Subject: [PATCH 021/274] Final tests --- prelude-ls/prelude-ls-tests.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts index e21893e525..bea29403b2 100644 --- a/prelude-ls/prelude-ls-tests.ts +++ b/prelude-ls/prelude-ls-tests.ts @@ -242,19 +242,27 @@ var findIndicesRes: Array = // Obj -prelude.keys({a: 2, b: 3, c: 9}); //=> ["a", "b", "c"] +var keysRes: Array = prelude.keys({a: 2, b: 3, c: 9}); +//=> ["a", "b", "c"] -prelude.values({a: 2, b: 3, c: 9}); //=> [2, 3, 9] +var valuesRes: Array = prelude.values({a: 2, b: 3, c: 9}); +//=> [2, 3, 9] -prelude.pairsToObj([["a", "b"], ["c", "d"], ["e", 1]]); //=> {a: "b", c: "d", e: 1} +var pairsToObjRes: Object = + prelude.pairsToObj([["a", "b"], ["c", "d"], ["e", 1]]); //=> {a: "b", c: "d", e: 1} -prelude.objToPairs({a: "b", c: "d", e: 1}); //=> [["a", "b"], ["c", "d"], ["e", 1]] +var objToPairsRes: Array> = + prelude.objToPairs({a: "b", c: "d", e: 1}); + //=> [["a", "b"], ["c", "d"], ["e", 1]] -prelude.listsToObj(["a", "b", "c"], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} +var listsToObjRes: Object = + prelude.listsToObj(["a", "b", "c"], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} -prelude.objToLists({a: 1, b: 2, c: 3}); //=> [["a", "b", "c"], [1, 2, 3]] +var objToListsRes = + prelude.objToLists({a: 1, b: 2, c: 3}); + //=> [["a", "b", "c"], [1, 2, 3]] -prelude.Obj.empty({}); //=> true +var objEmptyRes: boolean = prelude.Obj.empty({}); //=> true var count = 4; prelude.Obj.each(x => count += x, {a: 1, b: 2, c: 3}); From 87ed92fda4291cbb83e58241ad7956ada6895662 Mon Sep 17 00:00:00 2001 From: Haskell Camargo Date: Mon, 15 Jun 2015 00:25:15 -0300 Subject: [PATCH 022/274] (;) for Travis --- prelude-ls/prelude-ls-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prelude-ls/prelude-ls-tests.ts b/prelude-ls/prelude-ls-tests.ts index bea29403b2..dc36e9913b 100644 --- a/prelude-ls/prelude-ls-tests.ts +++ b/prelude-ls/prelude-ls-tests.ts @@ -149,8 +149,8 @@ var sortByRes: Array = //=> ["a", "ha", "hey", "there"] var table: Array<{ - id: number, - name: string + id: number; + name: string; }> = [{ id: 1, name: "george" From 503a60a6d656b20950157c201c0787ed157e6b12 Mon Sep 17 00:00:00 2001 From: Kristof Mattei Date: Mon, 15 Jun 2015 08:09:02 +0200 Subject: [PATCH 023/274] Changed namespace to angular as per comment --- angular-local-storage/angular-local-storage.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-local-storage/angular-local-storage.d.ts b/angular-local-storage/angular-local-storage.d.ts index 940874d23b..ae027527a4 100644 --- a/angular-local-storage/angular-local-storage.d.ts +++ b/angular-local-storage/angular-local-storage.d.ts @@ -6,7 +6,7 @@ /// declare module angular.local.storage { - interface ILocalStorageServiceProvider extends ng.IServiceProvider { + interface ILocalStorageServiceProvider extends angular.IServiceProvider { /** * Setter for the prefix * You should set a prefix to avoid overwriting any local storage variables from the rest of your app @@ -129,7 +129,7 @@ declare module angular.local.storage { * @param value optional * @param key The corresponding key used in local storage */ - bind(scope: ng.IScope, property: string, value?: any, key?: string): Function; + bind(scope: angular.IScope, property: string, value?: any, key?: string): Function; /** * Return the derive key * Returns String From f00a559ddc36e8ec0b96063fbe7df9f532a21fc6 Mon Sep 17 00:00:00 2001 From: David Lipowicz Date: Wed, 17 Jun 2015 15:20:38 -0700 Subject: [PATCH 024/274] Adding in a few missing definitions for Dagre. --- dagre/dagre.d.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dagre/dagre.d.ts b/dagre/dagre.d.ts index ce389f2d7e..75d7e389a7 100644 --- a/dagre/dagre.d.ts +++ b/dagre/dagre.d.ts @@ -10,20 +10,24 @@ declare module Dagre{ interface Graph { new (): Graph; - edges(): string[]; - edge(id: string): any; + edges(): Edge[]; + edge(id: any): any; nodes(): string[]; - node(id: string): any; + node(id: any): any; setDefaultEdgeLabel(callback: () => void): Graph; setEdge(sourceId: string, targetId: string): Graph; setGraph(options: { [key: string]: any }): Graph; setNode(id: string, node: { [key: string]: any }): Graph; } + interface Edge { + v: string; + w: string; + } + interface GraphLib { Graph: Graph; } } -declare var dagre: Dagre.DagreFactory; - +declare var dagre: Dagre.DagreFactory; \ No newline at end of file From b0dcd5ebfbb5441252cb27439e441b07567c4710 Mon Sep 17 00:00:00 2001 From: David Lipowicz Date: Wed, 17 Jun 2015 15:20:56 -0700 Subject: [PATCH 025/274] Adding in some missing definitions for SigmaJs. --- sigmajs/sigmajs.d.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/sigmajs/sigmajs.d.ts b/sigmajs/sigmajs.d.ts index 62bee1980d..985686ad45 100644 --- a/sigmajs/sigmajs.d.ts +++ b/sigmajs/sigmajs.d.ts @@ -15,10 +15,17 @@ declare module SigmaJs{ graphPosition(x: number, y:number): {x: number; y: number}; ratio: number; readPrefix: string; + settings(setting: string) : any; x: number; y: number; } + interface Canvas { + edges: {[renderType: string]: Function}; + labels: {[renderType: string]: Function}; + nodes: {[renderType: string]: Function}; + } + interface Classes { configurable: Configurable; graph: Graph; @@ -39,6 +46,7 @@ declare module SigmaJs{ } interface Edge { + [key : string] : any; color?: string; id: string; size?: number; @@ -74,6 +82,11 @@ declare module SigmaJs{ nodes(ids: string[]): Node[]; } + interface GraphData { + edges: Edge[]; + nodes: Node[]; + } + interface Image { clip?: number; scale?: number; @@ -87,6 +100,7 @@ declare module SigmaJs{ } interface Node { + [key : string] : any; color?: string; id: string; image?: any; @@ -149,7 +163,7 @@ declare module SigmaJs{ interface SigmaConfigs { container?: Element; - graph?: Graph; + graph?: GraphData; id?: string; renderers?: Renderer[]; settings?: { [index: string]: any }; @@ -160,10 +174,12 @@ declare module SigmaJs{ new(container: string): Sigma; new(container: Element): Sigma; new(configuration: SigmaConfigs): Sigma; + canvas: Canvas; classes:Classes; misc: Miscellaneous; parsers: Parsers; plugins: Plugins; + svg: SVG; } interface Settings { @@ -269,8 +285,19 @@ declare module SigmaJs{ // Animation settings animationsTime?: number; } + + interface SVG { + edges: {[renderType: string]: SVGObject}; + labels: {[renderType: string]: SVGObject}; + nodes: {[renderType: string]: SVGObject}; + } + + interface SVGObject { + create: (object: T, ...a:any[]) => Element; + update: (object: T, ...a:any[]) => void; + } } declare var sigma: SigmaJs.SigmaFactory; declare var CustomShapes: SigmaJs.CustomShapes; -declare var ShapeLibrary: SigmaJs.CustomShapes; +declare var ShapeLibrary: SigmaJs.CustomShapes; \ No newline at end of file From 35de88ab7d506af1fea5d02b69fbb69d8523153d Mon Sep 17 00:00:00 2001 From: David Lipowicz Date: Wed, 17 Jun 2015 16:33:12 -0700 Subject: [PATCH 026/274] Added a SigmaJs test. --- sigmajs/sigmajs-tests.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sigmajs/sigmajs-tests.ts b/sigmajs/sigmajs-tests.ts index 10c6ce0294..f28a9395bd 100644 --- a/sigmajs/sigmajs-tests.ts +++ b/sigmajs/sigmajs-tests.ts @@ -23,6 +23,10 @@ module SigmaJsTests { s.refresh(); }); + sigma.canvas.edges['def'] = function() {}; + sigma.svg.nodes['def'] = {create: (obj: SigmaJs.Node) => { return new Element(); }, + update: (obj: SigmaJs.Node) => { return; }}; + var N = 100; var E = 500; // Generate a random graph: From 70a17401f6388a2121a9ccaa195dbef586f071b0 Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Fri, 19 Jun 2015 12:27:58 -0500 Subject: [PATCH 027/274] Reflect actual Argv#check() usage in check() type declaration --- yargs/yargs.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/yargs/yargs.d.ts b/yargs/yargs.d.ts index 6a6adebe8b..0e42090fcd 100644 --- a/yargs/yargs.d.ts +++ b/yargs/yargs.d.ts @@ -57,8 +57,7 @@ declare module "yargs" { example(command: string, description: string): Argv; - check(func: (argv: { [key: string]: any }, aliases: { [alias: string]: string }) => boolean): Argv; - check(func: (argv: { [key: string]: any }, aliases: { [alias: string]: string }) => string): Argv; + check(func: (argv: any, aliases: { [alias: string]: string }) => any): Argv; boolean(key: string): Argv; boolean(keys: string[]): Argv; From a81e731a5a8cee6b8e30762b2d02c9d63b22a550 Mon Sep 17 00:00:00 2001 From: woutergd Date: Sun, 21 Jun 2015 21:48:09 +0200 Subject: [PATCH 028/274] First type definitions for openlayers 3, all base classes implemented --- openlayers3/openlayers3.d.ts | 2002 ++++++++++++++++++++++++++++++++++ 1 file changed, 2002 insertions(+) create mode 100644 openlayers3/openlayers3.d.ts diff --git a/openlayers3/openlayers3.d.ts b/openlayers3/openlayers3.d.ts new file mode 100644 index 0000000000..d89c65ecca --- /dev/null +++ b/openlayers3/openlayers3.d.ts @@ -0,0 +1,2002 @@ +// Type definitions for OpenLayers v3.6.0 +// Project: http://openlayers.org/ +// Definitions by: Wouter Goedhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * A high-performance, feature-packed library for all your mapping needs. + */ +declare module ol { + + /** + * An attribution for a layer source. + */ + class Attribution { + /** + * @constructor + * @param options Attribution options. + */ + constructor(options: AttributionOptions); + + /** + * Get the attribution markup. + * @returns The attribution HTML. + */ + getHTML(): string; + } + interface AttributionOptions { + + /** HTML markup for this attribution. */ + html: string; + } + + /** + * An expanded version of standard JS Array, adding convenience methods for manipulation. Add and remove changes to the Collection trigger a Collection event. Note that this does not cover changes to the objects within the Collection; they trigger events on the appropriate object, not on the Collection as a whole. + */ + class Collection extends ol.Object { + + /** + * @constructor + * @param values Array. + */ + constructor(values: Array) + + /** + * Remove all elements from the collection. + */ + clear(): void; + + /** + * Add elements to the collection. This pushes each item in the provided array to the end of the collection. + * @param arr Array. + * @returns This collection. + */ + extend(arr: Array): Collection; + + /** + * Iterate over each element, calling the provided callback. + * @param f The function to call for every element. This function takes 3 arguments (the element, the index and the array). + * @param ref The object to use as this in f. + */ + forEach(f: (element: T, index: number, array: Array) => void, ref?: any): void; + + /** + * Get a reference to the underlying Array object. Warning: if the array is mutated, no events will be dispatched by the collection, and the collection's "length" property won't be in sync with the actual length of the array. + * @returns Array. + */ + getArray(): Array; + + /** + * Get the length of this collection. + * @returns The length of the array. + */ + getLength(): number; + + /** + * Insert an element at the provided index. + * @param index Index. + * @param elem Element. + */ + insertAt(index: number, elem: T): void; + + /** + * Get the element at the provided index. + * @param index Index. + * @returns Element. + */ + item(index: number): T; + + /** + * Remove the last element of the collection and return it. Return undefined if the collection is empty. + * @returns Element + */ + pop(): T; + + /** + * Insert the provided element at the end of the collection. + * @param Element. + * @returns Length. + */ + push(elem: T): number; + + /** + * Remove the first occurrence of an element from the collection. + * @param elem Element. + * @returns The removed element or undefined if none found. + */ + remove(elem: T): T; + + /** + * Remove the element at the provided index and return it. Return undefined if the collection does not contain this index. + * @param index Index. + * @returns Value. + */ + removeAt(index: number): T; + + /** + * Set the element at the provided index. + * @param index Index. + * @param elem Element. + */ + setAt(index: number, elem: T): void; + } + + /** + * Events emitted by ol.Collection instances are instances of this type. + */ + class CollectionEvent { + + /** + * The element that is added to or removed from the collection. + */ + element: T; + } + + /** + * The ol.DeviceOrientation class provides access to information from DeviceOrientation events. + */ + class DeviceOrientation extends ol.Object { + + /** + * @constructor + * @param options Options. + */ + constructor(options: DeviceOrientationOptions); + + /** + * Rotation around the device z-axis (in radians). + * @returns The euler angle in radians of the device from the standard Z axis. + */ + getAlpha(): number; + + /** + * Rotation around the device x-axis (in radians). + * @returns The euler angle in radians of the device from the planar X axis. + */ + getBeta(): number; + + /** + * Rotation around the device y-axis (in radians). + * @returns The euler angle in radians of the device from the planar Y axis. + */ + getGamma(): number; + + /** + * The heading of the device relative to north (in radians). + * @returns The heading of the device relative to north, in radians, normalizing for different browser behavior. + */ + getHeading(): number; + + /** + * Determine if orientation is being tracked. + * @returns Changes in device orientation are being tracked. + */ + getTracking(): boolean; + + /** + * Enable or disable tracking of device orientation events. + * @param tracking The status of tracking changes to alpha, beta and gamma. If true, changes are tracked and reported immediately. + */ + setTracking(tracking: boolean): void; + } + interface DeviceOrientationOptions { + + /** + * Start tracking. Default is false. + */ + tracking?: boolean; + } + + /** + * Events emitted by ol.interaction.DragBox instances are instances of this type. + */ + class DragBoxEvent { + + /** + * The coordinate of the drag event. + */ + coordinate: ol.Coordinate; + } + + /** + * A vector object for geographic features with a geometry and other attribute properties, similar to the features in vector file formats like GeoJSON. + */ + class Feature extends ol.Object { + + /** + * @constructor + * @param geometry Geometry. + */ + constructor(geometry: ol.geom.Geometry); + + /** + * Clone this feature. If the original feature has a geometry it is also cloned. The feature id is not set in the clone. + * @returns The clone. + */ + clone(): Feature; + + /** + * Get the feature's default geometry. A feature may have any number of named geometries. The "default" geometry (the one that is rendered by default) is set when calling ol.Feature#setGeometry. + * @returns The default geometry for the feature. + */ + getGeometry(): ol.geom.Geometry; + + /** + * Get the name of the feature's default geometry. By default, the default geometry is named geometry. + * @returns Get the property name associated with the default geometry for this feature. + */ + getGeometryName(): string; + + /** + * @returns Id. + */ + getId(): string; + + /** + * Get the feature's style. This return for this method depends on what was provided to the ol.Feature#setStyle method. + * The feature style. + */ + // TODO: Implement FeatureStyleFunction + getStyle(): ol.style.Style | Array | any; + + /** + * Get the feature's style function. + * @returns Return a function representing the current style of this feature. + */ + // TODO: Implement FeatureStyleFunction + getStyleFunction(): any; + + /** + * Set the default geometry for the feature. This will update the property with the name returned by ol.Feature#getGeometryName. + * @param geometry The new geometry. + */ + setGeometry(geometry: ol.geom.Geometry): void; + + /** + * Set the property name to be used when getting the feature's default geometry. When calling ol.Feature#getGeometry, the value of the property with this name will be returned. + * @param name The property name of the default geometry. + */ + setGeometryName(name: string): void; + + /** + * Set the feature id. The feature id is considered stable and may be used when requesting features or comparing identifiers returned from a remote source. The feature id can be used with the ol.source.Vector#getFeatureById method. + * @param id The feature id. + */ + setId(id: number): void; + setId(id: string): void; + + /** + * Set the style for the feature. This can be a single style object, an array of styles, or a function that takes a resolution and returns an array of styles. If it is null the feature has no style (a null style). + * @param style Style for this feature. + */ + // TODO: Implement FeatureStyleFunction + setStyle(style: ol.style.Style): void; + setStyle(style: Array): void; + setStyle(style: any): void; + } + + /** + * A mechanism for changing the style of a small number of features on a temporary basis, for example highlighting. + */ + class FeatureOverlay { + + /** + * @constructor + * @param options Options. + */ + constructor(options: FeatureOverlayOptions); + + /** + * Add a feature to the overlay. + * @param feature Feature. + */ + addFeature(feature: ol.Feature): void; + + /** + * Get the features on the overlay. + * @returns Features collection. + */ + getFeatures: ol.Collection; + + /** + * Get the map associated with the overlay. + * @returns The map with which this feature overlay is associated. + */ + getMap(): ol.Map; + + /** + * Get the style for features. This returns whatever was passed to the style option at construction or to the setStyle method. + * @returns Overlay style. + */ + // TODO: implement stylefunction + getStyle(): ol.style.Style | Array | any; + + /** + * Get the style function + * @returns Style function + */ + getStyleFunction(): any; + + /** + * Remove a feature from the overlay. + * @param feature The feature to be removed. + */ + removeFeature(feature: ol.Feature): void; + + /** + * Set the features for the overlay. + * @param features Features collection. + */ + setFeatures(features: ol.Collection): void; + + /** + * Set the map for the overlay. + * @param map Map. + */ + setMap(map: ol.Map): void; + + /** + * Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. + * @param style Overlay style + */ + // TODO: implement stylefunction + setStyle(style: ol.style.Style): void; + setStyle(style: Array): void; + setStyle(style: any): void; + } + interface FeatureOverlayOptions { + + /** + * Features + */ + // TODO: implement stylefunction + features?: Array | Collection | any; + + /** + * Map + */ + map: Map; + + /** + * Style + */ + style: style.Style | Array; + } + + /** + * Helper class for providing HTML5 Geolocation capabilities. The Geolocation API is used to locate a user's position. + */ + class Geolocation extends ol.Object { + + /** + * @constructor + * @param options Options. + */ + constructor(options: GeolocationOptions); + + /** + * Get the accuracy of the position in meters. + * @returns The accuracy of the position measurement in meters. + */ + getAccuracy(): number; + + /** + * Get a geometry of the position accuracy. + * @returns A geometry of the position accuracy. + */ + getAccuracyGeometry(): ol.geom.Geometry; + + /** + * Get the altitude associated with the position. + * @returns The altitude of the position in meters above mean sea level. + */ + getAltitude(): number; + + /** + * Get the altitude accuracy of the position. + * @returns The accuracy of the altitude measurement in meters. + */ + getAltitudeAccuracy(): number; + + /** + * Get the heading as radians clockwise from North. + * @returns The heading of the device in radians from north. + */ + getHeading(): number; + + /** + * Get the position of the device. + * @returns The current position of the device reported in the current projection. + */ + getPosition(): ol.Coordinate; + + /** + * Get the projection associated with the position. + * @returns The projection the position is reported in. + */ + getProjection(): ol.proj.Projection; + + /** + * Get the speed in meters per second. + * @returns The instantaneous speed of the device in meters per second. + */ + getSpeed(): number; + + /** + * Determine if the device location is being tracked. + * @returns The device location is being tracked. + */ + getTracking(): boolean; + + /** + * Get the tracking options. + * @returns PositionOptions as defined by the HTML5 Geolocation spec. + */ + getTrackingOptions(): PositionOptions; + + /** + * Set the projection to use for transforming the coordinates. + * @param projection The projection the position is reported in. + */ + setProjection(projection: ol.proj.Projection): void; + + /** + * Enable or disable tracking. + * @param tracking Enable tracking + */ + setTracking(tracking: boolean): void; + + /** + * Set the tracking options. + * @param PositionOptions as defined by the HTML5 Geolocation spec. + */ + setTrackingOptions(options: PositionOptions): void; + } + interface GeolocationOptions { + + /** + * Start Tracking. Default is false. + */ + tracking?: boolean; + + /** + * Tracking options. See http://www.w3.org/TR/geolocation-API/#position_options_interface. + */ + trackingOptions?: PositionOptions; + + /** + * The projection the position is reported in. + */ + projection?: ol.proj.ProjectionLike; + } + + /** + * Render a grid for a coordinate system on a map. + */ + class Graticule { + /** + * @constructor + * @param options Options. + */ + constructor(options: GraticuleOptions); + + /** + * Get the map associated with this graticule. + * @returns The map. + */ + getMap(): Map; + + /** + * Get the list of meridians. Meridians are lines of equal longitude. + * @returns The meridians. + */ + getMeridians(): Array; + + /** + * Get the list of parallels. Pallels are lines of equal latitude. + * @returns The parallels. + */ + getParallels(): Array; + + /** + * Set the map for this graticule.The graticule will be rendered on the provided map. + * @param map Map + */ + setMap(map: Map): void; + } + interface GraticuleOptions { + + /** Reference to an ol.Map object. */ + map?: Map; + + /** The maximum number of meridians and parallels from the center of the map. The default value is 100, which means that at most 200 meridians and 200 parallels will be displayed. The default value is appropriate for conformal projections like Spherical Mercator. If you increase the value more lines will be drawn and the drawing performance will decrease. */ + maxLines?: number; + + /** The stroke style to use for drawing the graticule. If not provided, the lines will be drawn with rgba(0,0,0,0.2), a not fully opaque black. */ + strokeStyle?: style.Stroke; + + /** The target size of the graticule cells, in pixels. Default value is 100 pixels. */ + targetSize?: number; + } + + /** + * + */ + class Image extends ol.ImageBase { + + /** + * Get the HTML image element (may be a Canvas, Image, or Video). + * @param context Object. + * @returns Image. + */ + getImage(context: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement): Image; + } + + /** + * + */ + class ImageBase { + } + + /** + * + */ + class ImageTile extends ol.Tile { + + /** + * Get the HTML image element for this tile (may be a Canvas, Image, or Video). + * @param context Object. + * @returns Image. + */ + getImage(context: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement): Image; + } + + /** + * Implementation of inertial deceleration for map movement. + */ + class Kinetic { + + /** + * @constructor + * @param decay Rate of decay (must be negative). + * @param Minimum velocity (pixels/millisecond). + * @param Delay to consider to calculate the kinetic initial values (milliseconds). + */ + constructor(decay: number, minVelocity: number, delay: number); + } + + /** + * The map is the core component of OpenLayers. For a map to render, a view, one or more layers, and a target container are needed. + */ + class Map extends ol.Object { + + /** + * @constructor + * @params options Options. + */ + constructor(options: MapOptions); + + /** + * Add the given control to the map. + * @param control Control. + */ + addControl(control: ol.control.Control): void; + + /** + * Add the given interaction to the map. + * @param interaction Interaction to add. + */ + addInteraction(interaction: ol.interaction.Interaction): void; + + /** + * Adds the given layer to the top of this map. If you want to add a layer elsewhere in the stack, use getLayers() and the methods available on ol.Collection. + * @param Layer. + */ + addLayer(layer: ol.layer.Base): void; + + /** + * Add the given overlay to the map. + * @param overlay Overlay. + */ + addOverlay(overlay: ol.Overlay): void; + + /** + * Add functions to be called before rendering. This can be used for attaching animations before updating the map's view. The ol.animation namespace provides several static methods for creating prerender functions. + * @param var_args Any number of pre-render functions. + */ + // TODO: Implement PreRenderFunction + beforeRender(var_args: any): void; + + /** + * Detect features that intersect a pixel on the viewport, and execute a callback with each intersecting feature. Layers included in the detection can be configured through opt_layerFilter. Feature overlays will always be included in the detection. + * @param pixel Pixel. + * @param callback Feature callback. The callback will be called with two arguments. The first argument is one feature at the pixel, the second is the layer of the feature. If the detected feature is not on a layer, but on a ol.FeatureOverlay, then the second argument to this function will be null. To stop detection, callback functions can return a truthy value. + * @param ref Value to use as this when executing callback. + * @param layerFilter Layer filter function. The filter function will receive one argument, the layer-candidate and it should return a boolean value. Only layers which are visible and for which this function returns true will be tested for features. By default, all visible layers will be tested. Feature overlays will always be tested. + * @param ref2 Value to use as this when executing layerFilter. + * @returns Callback result, i.e. the return value of last callback execution, or the first truthy callback return value. + */ + forEachFeatureAtPixel(pixel: ol.Pixel, callback: (feature: ol.Feature, layer: ol.layer.Layer) => any, ref?: any, layerFilter?: (layerCandidate: ol.layer.Layer) => boolean, ref2?: any): void; + + /** + * Detect layers that have a color value at a pixel on the viewport, and execute a callback with each matching layer. Layers included in the detection can be configured through opt_layerFilter. Feature overlays will always be included in the detection. + * @param pixel Pixel. + * @param callback Layer callback. Will receive one argument, the layer that contains the color pixel. If the detected color value is not from a layer, but from a ol.FeatureOverlay, then the argument to this function will be null. To stop detection, callback functions can return a truthy value. + * @param ref Value to use as this when executing callback. + * @param layerFilter Layer filter function. The filter function will receive one argument, the layer-candidate and it should return a boolean value. Only layers which are visible and for which this function returns true will be tested for features. By default, all visible layers will be tested. Feature overlays will always be tested. + * @param ref2 Value to use as this when executing layerFilter. + * @returns Callback result, i.e. the return value of last callback execution, or the first truthy callback return value. + */ + forEachLayerAtPixel(pixel: ol.Pixel, callback: (layer: ol.layer.Layer) => any, ref?: any, layerFilter?: (layerCandidate: ol.layer.Layer) => boolean, ref2?: any): void; + + /** + * Get the map controls. Modifying this collection changes the controls associated with the map. + * @returns Controls. + */ + getControls(): ol.Collection; + + /** + * Get the coordinate for a given pixel. This returns a coordinate in the map view projection. + * @param pixel Pixel position in the map viewport. + * @returns The coordinate for the pixel position. + */ + getCoordinateFromPixel(pixel: ol.Pixel): ol.Coordinate; + + /** + * Returns the geographical coordinate for a browser event. + * @param event Event. + * @returns Coordinate. + */ + getEventCoordinate(event: Event): ol.Coordinate; + + /** + * Returns the map pixel position for a browser event relative to the viewport. + * @param event Event. + * @returns Pixel. + */ + getEventPixel(event: Event): ol.Pixel; + + /** + * Get the map interactions. Modifying this collection changes the interactions associated with the map. + * @returns Interactions + */ + getInteractions(): ol.Collection; + + /** + * Get the layergroup associated with this map. + * @returns A layer group containing the layers in this map. + */ + getLayerGroup(): ol.layer.Group; + + /** + * Get the collection of layers associated with this map. + * @returns Layers. + */ + getLayers(): ol.Collection; + + /** + * Get the map overlays. Modifying this collection changes the overlays associated with the map. + * @returns Overlays. + */ + getOverlays(): ol.Collection; + + /** + * Get the pixel for a coordinate. This takes a coordinate in the map view projection and returns the corresponding pixel. + * @param coordinate A map coordinate. + * @returns A pixel position in the map viewport. + */ + getPixelFromCoordinate(coordinate: ol.Coordinate): ol.Pixel; + + /** + * Get the size of this map. + * @returns The size in pixels of the map in the DOM. + */ + getSize(): ol.Size; + + /** + * Get the target in which this map is rendered. Note that this returns what is entered as an option or in setTarget: if that was an element, it returns an element; if a string, it returns that. + * @returns The Element or id of the Element that the map is rendered in. + */ + getTarget(): Element | string; + + /** + * Get the DOM element into which this map is rendered. In contrast to getTarget this method always return an Element, or null if the map has no target. + * @returns The element that the map is rendered in. + */ + getTargetElement(): Element; + + /** + * Get the view associated with this map. A view manages properties such as center and resolution. + * @returns The view that controls this map. + */ + getView(): View; + + /** + * Get the element that serves as the map viewport. + * @returns Viewport. + */ + getViewport(): Element; + + /** + * Detect if features intersect a pixel on the viewport. Layers included in the detection can be configured through opt_layerFilter. Feature overlays will always be included in the detection. + * @param pixel Pixel. + * @param layerFilter Layer filter function. The filter function will receive one argument, the layer-candidate and it should return a boolean value. Only layers which are visible and for which this function returns true will be tested for features. By default, all visible layers will be tested. Feature overlays will always be tested. + * @param ref Value to use as this when executing layerFilter. + * @returns Is there a feature at the given pixel? + */ + hasFeatureAtPixel(pixel: ol.Pixel, layerFilter?: (layer: ol.layer.Layer) => boolean, ref?: any): boolean; + + /** + * Remove the given control from the map. + * @param Control. + * @returns The removed control (or undefined if the control was not found). + */ + removeControl(control: ol.control.Control): ol.control.Control; + + /** + * Remove the given interaction from the map. + * @param interaction Interaction to remove. + * @returns The removed interaction (or undefined if the interaction was not found). + */ + removeInteraction(interaction: ol.interaction.Interaction): ol.interaction.Interaction; + + /** + * Removes the given layer from the map. + * @param Layer. + * @returns The removed layer (or undefined if the layer was not found). + */ + removeLayer(layer: ol.layer.Base): ol.layer.Base; + + /** + * Remove the given overlay from the map. + * @param Overlay. + * @returns The removed overlay (or undefined if the overlay was not found). + */ + removeOverlay(overlay: ol.Overlay): ol.Overlay; + + /** + * Request a map rendering (at the next animation frame). + */ + render(): void; + + /** + * Requests an immediate render in a synchronous manner. + */ + renderSync(): void; + + /** + * Sets the layergroup of this map. + * @param layerGroup A layer group containing the layers in this map. + */ + setLayerGroup(layerGroup: ol.layer.Group): void; + + /** + * Set the size of this map. + * @param size The size in pixels of the map in the DOM. + */ + setSize(size: ol.Size): void; + + /** + * Set the target element to render this map into. + * @param target The Element or id of the Element that the map is rendered in. + */ + setTarget(target: Element): void; + setTarget(target: string): void; + + /** + * Set the view for this map. + * @param view The view that controls this map. + */ + setView(view: View): void; + + /** + * Force a recalculation of the map viewport size. This should be called when third-party code changes the size of the map viewport. + * */ + updateSize(): void; + } + interface MapOptions { + + /** Controls initially added to the map. If not specified, ol.control.defaults() is used. */ + controls?: any; + + /** The ratio between physical pixels and device-independent pixels (dips) on the device. If undefined then it gets set by using window.devicePixelRatio. */ + pixelRatio?: number; + + /** Interactions that are initially added to the map. If not specified, ol.interaction.defaults() is used. */ + interactions?: any; + + /** The element to listen to keyboard events on. This determines when the KeyboardPan and KeyboardZoom interactions trigger. For example, if this option is set to document the keyboard interactions will always trigger. If this option is not specified, the element the library listens to keyboard events on is the map target (i.e. the user-provided div for the map). If this is not document the target element needs to be focused for key events to be emitted, requiring that the target element has a tabindex attribute. */ + keyboardEventTarget?: any; + + /** Layers. If this is not defined, a map with no layers will be rendered. Note that layers are rendered in the order supplied, so if you want, for example, a vector layer to appear on top of a tile layer, it must come after the tile layer. */ + layers?: Array + + /** When set to true, tiles will be loaded during animations. This may improve the user experience, but can also make animations stutter on devices with slow memory. Default is false. */ + loadTilesWhileAnimating?: boolean; + + /** When set to true, tiles will be loaded while interacting with the map. This may improve the user experience, but can also make map panning and zooming choppy on devices with slow memory. Default is false. */ + loadTilesWhileInteracting?: boolean; + + /** The map logo. A logo to be displayed on the map at all times. If a string is provided, it will be set as the image source of the logo. If an object is provided, the src property should be the URL for an image and the href property should be a URL for creating a link. To disable the map logo, set the option to false. By default, the OpenLayers 3 logo is shown. */ + logo?: any; + + /** Overlays initially added to the map. By default, no overlays are added. */ + overlays?: any; + + /** Renderer. By default, Canvas, DOM and WebGL renderers are tested for support in that order, and the first supported used. Specify a ol.RendererType here to use a specific renderer. Note that at present only the Canvas renderer supports vector data. */ + renderer?: any; + + /** The container for the map, either the element itself or the id of the element. If not specified at construction time, ol.Map#setTarget must be called for the map to be rendered. */ + target?: any; + + /** The map's view. No layer sources will be fetched unless this is specified at construction time or through ol.Map#setView. */ + view?: ViewOptions; + } + + /** + * Events emitted as map browser events are instances of this type. See ol.Map for which events trigger a map browser event. + */ + class MapBrowserEvent extends MapEvent { + + /** + * The coordinate of the original browser event + */ + coordinate: Coordinate; + + /** + * Indicates if the map is currently being dragged. Only set for POINTERDRAG and POINTERMOVE events. Default is false. + */ + dragging: boolean; + + /** + * The frame state at the time of the event + */ + // TODO: Replace with olx.FrameState + frameState: any; + + /** + * The map where the event occured + */ + map: Map; + + /** + * The original browser event + */ + originalEvent: Event; + + /** + * The pixel of the original browser event. + */ + pixel: Pixel; + + + // Methods + + /** + * Prevents the default browser action. + */ + preventDefault(): void; + + /** + * Prevents further propagation of the current event. + */ + stopPropagation(): void; + } + + /** + * Events emitted as map events are instances of this type. See ol.Map for which events trigger a map event. + */ + class MapEvent { + + /** + * The frame state at the time of the event. + */ + // TODO: Replace with olx.FrameState + frameState: any; + + /** + * The map where the event occurred. + */ + map: Map; + } + + /** + * Abstract base class; normally only used for creating subclasses and not instantiated in apps. Most non-trivial classes inherit from this. + */ + class Object extends Observable { + + /** + * @constructor + * @param values An object with key-value pairs. + */ + constructor(values?: Object); + + /** + * Gets a value. + * @param key Key name. + * @returns Value. + */ + get(key: string): any; + + /** + * Get a list of object property names. + * @returns List of property names. + */ + getKeys(): Array; + + /** + * Get an object of all property names and values. + * @returns Object. + */ + getProperties(): Object; + + /** + * @returns Revision. + */ + getRevision(): number; + + /** + * Sets a value. + * @param key Key name. + * @param value Value. + */ + set(key: string, value: any): void; + + /** + * Sets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties). + * @param Values. + */ + setProperties(values: Object): void; + + /** + * Unsets a property. + */ + unset(key: string): void; + } + + /** + * Events emitted by ol.Object instances are instances of this type. + */ + class ObjectEvent { + + /** + * The name of the property whose value is changing. + */ + key: string; + + /** + * The old value. To get the new value use e.target.get(e.key) where e is the event object. + */ + oldValue: any; + } + + /** + * Abstract base class; normally only used for creating subclasses and not instantiated in apps. An event target providing convenient methods for listener registration and unregistration. A generic change event is always available through ol.Observable#changed. + */ + class Observable { + + /** + * Removes an event listener using the key returned by on() or once(). + */ + unByKey(key: any): void; + + /** + * Increases the revision counter and dispatches a 'change' event. + */ + changed(): void; + + /** + * @returns Revision. + */ + getRevision(): number; + + /** + * Listen for a certain type of event. + * @param type The event type. + * @param listener The listener function. + * @param ref The object to use as this in listener. + * @returns Unique key for the listener. + */ + on(type: string, listener: (event: MapBrowserEvent) => void, ref?: any): any; + + /** + * Listen for a certain type of event. + * @param type The array of event types. + * @param listener The listener function. + * @param ref The object to use as this in listener. + * @returns Unique key for the listener. + */ + on(type: Array, listener: (event: MapBrowserEvent) => void, ref?: any): any; + + /** + * Listen once for a certain type of event. + * @param type The event type. + * @param listener The listener function. + * @param ref The object to use as this in listener. + * @returns Unique key for the listener. + */ + once(type: string, listener: (event: MapBrowserEvent) => void, ref?: any): any; + + /** + * Listen once for a certain type of event. + * @param type The array of event types. + * @param listener The listener function. + * @param ref The object to use as this in listener. + * @returns Unique key for the listener. + */ + once(type: Array, listener: (event: MapBrowserEvent) => void, ref?: any): any; + + /** + * Unlisten for a certain type of event. + * @param type The array of event types. + * @param listener The listener function. + * @param ref The object to use as this in listener. + * @returns Unique key for the listener. + */ + un(type: Array, listener: (event: MapBrowserEvent) => void, ref?: any): any; + + /** + * Removes an event listener using the key returned by on() or once(). Note that using the ol.Observable.unByKey static function is to be preferred. + * @param key The key returned by on() or once() + */ + unByKey(key: any): void; + } + + /** + * An element to be displayed over the map and attached to a single map location. + */ + class Overlay extends ol.Object { + + /** + * @constructor + * @param options Overlay options. + */ + constructor(options: OverlayOptions); + + /** + * Get the DOM element of this overlay. + * @returns The Element containing the overlay. + */ + getElement(): Element; + + /** + * Get the map associated with this overlay. + * @returns The map that the overlay is part of. + */ + getMap(): ol.Map; + + /** + * Get the offset of this overlay. + * @returns The offset. + */ + getOffset(): Array; + + /** + * Get the current position of this overlay. + * @returns The spatial point that the overlay is anchored at. + */ + getPosition(): ol.Coordinate; + + /** + * Get the current positioning of this overlay. + * @returns How the overlay is positioned relative to its point on the map. + */ + getPositioning(): ol.OverlayPositioning; + + /** + * Set the DOM element to be associated with this overlay. + * @param element The element containing the overlay. + */ + setElement(element: Element): void; + + /** + * Set the map to be associated with this overlay. + * @param map The map that the overlay is part of. + */ + setMap(map: Map): void; + + /** + * Set the offset for this overlay. + * @param offset Offset. + */ + setOffset(offset: Array): void; + + /** + * Set the position for this overlay. If the position is undefined the overlay is hidden. + * @param position The spatial point that the overlay is anchored at. + */ + setPosition(position: ol.Coordinate): void; + + /** + * Set the positioning for this overlay. + * @param How the overlay is positioned relative to its point on the map. + */ + setPositioning(positioning: ol.OverlayPositioning): void; + } + interface OverlayOptions { + + /** + * The overlay element. + */ + element?: Element; + + /** + * Offsets in pixels used when positioning the overlay. The fist element in the array is the horizontal offset. A positive value shifts the overlay right. The second element in the array is the vertical offset. A positive value shifts the overlay down. Default is [0, 0]. + */ + offset?: Array; + + /** + * The overlay position in map projection. + */ + position?: ol.Coordinate; + + /** + * Defines how the overlay is actually positioned with respect to its position property. Possible values are 'bottom-left', 'bottom-center', 'bottom-right', 'center-left', 'center-center', 'center-right', 'top-left', 'top-center', and 'top-right'. Default is 'top-left'. + */ + positioning?: ol.OverlayPositioning; + + /** + * Whether event propagation to the map viewport should be stopped. Default is true. If true the overlay is placed in the same container as that of the controls (CSS class name ol-overlaycontainer-stopevent); if false it is placed in the container with CSS class name ol-overlaycontainer. + */ + stopEvent?: boolean; + + /** + * Whether the overlay is inserted first in the overlay container, or appended. Default is true. If the overlay is placed in the same container as that of the controls (see the stopEvent option) you will probably set insertFirst to true so the overlay is displayed below the controls. + */ + insertFirst?: boolean; + + /** + * If set to true the map is panned when calling setPosition, so that the overlay is entirely visible in the current viewport. The default is false. + */ + autoPan?: boolean; + + /** + * The options used to create a ol.animation.pan animation. This animation is only used when autoPan is enabled. By default the default options for ol.animation.pan are used. If set to null the panning is not animated. + */ + //TODO: replace with olx.animation.PanOptions + autoPanAnimation?: any; + + /** + * The margin (in pixels) between the overlay and the borders of the map when autopanning. The default is 20. + */ + autoPanMargin?: number; + } + + /** + * Events emitted by ol.interaction.Select instances are instances of this type. + */ + class SelectEvent { + + /** + * Deselected features array. + */ + deselected: Array; + + /** + * Associated ol.MapBrowserEvent; + */ + mapBrowserEvent: ol.MapBrowserEvent; + + /** + * Selected features array. + */ + selected: Array + } + + /** + * Class to create objects that can be used with ol.geom.Polygon.circular. + */ + class Sphere { + + /** + * @constructor + * @param radius Radius. + */ + constructor(radius: number); + + /** + * Returns the geodesic area for a list of coordinates. + * @param coordinates List of coordinates of a linear ring. If the ring is oriented clockwise, the area will be positive, otherwise it will be negative. + * @returns Area. + */ + geodesicArea(coordinates: Array): number; + + /** + * Returns the distance from c1 to c2 using the haversine formula. + * @param c1 Coordinate 1. + * @param c2 Coordinate 2. + * @returns Haversine distance. + */ + haversineDistance(c1: ol.Coordinate, c2: ol.Coordinate): number; + } + + /** + * Base class for tiles. + */ + class Tile { + + /** + * Get the tile coordinate for this tile. + * @returns TileCoord. + */ + getTileCoord(): ol.TileCoord; + } + + /** + * An ol.View object represents a simple 2D view of the map. + */ + class View extends ol.Object { + + /** + * @constructor + * @param options Options. + */ + constructor(options: ViewOptions); + + /** + * Calculate the extent for the current view state and the passed size. The size is the pixel dimensions of the box into which the calculated extent should fit. In most cases you want to get the extent of the entire map, that is map.getSize(). + * @param size Box pixel size + * @returns Extent. + */ + calculateExtent(size: ol.Size): ol.Extent; + + /** + * Center on coordinate and view position. + * @param coordinate Coordinate. + * @param size Box pixel size + * @param position Position on the view to center on + */ + centerOn(coordinate: ol.Coordinate, size: ol.Size, position: ol.Pixel): void; + + /** + * Get the constrained center of this view. + * @param center Center. + * @returns Constrained center. + */ + constrainCenter(center: ol.Coordinate): ol.Coordinate; + + /** + * Get the constrained resolution of this view. + * @param resolution: Resolution. + * @param delta Delta. Default is 0. + * @param direction Direction. Default is 0. + * @returns Constrained resolution + */ + constrainResolution(resolution: number, delta?: number, direction?: number): number; + + /** + * Fit the map view to the passed extent and size. The size is pixel dimensions of the box to fit the extent into. In most cases you will want to use the map size, that is map.getSize(). + * @param extent Extent. + * @param size Box pixel size. + */ + fitExtent(extent: ol.Extent, size: ol.Size): void; + + /** + * Fit the given geometry into the view based on the given map size and border. + * @param geometry Geometry. + * @param size Box pixel size. + * @param options Options + */ + fitGeometry(geometry: ol.geom.SimpleGeometry, size: ol.Size, options?: ViewFitGeometryOptions): void; + + /** + * Get the view center. + * @returns The center of the view. + */ + getCenter(): ol.Coordinate; + + /** + * Get the view projection + * @returns The projection of the view. + */ + getProjection(): ol.proj.Projection; + + /** + * Get the view resolution + * @returns The resolution of the view. + */ + getResolution(): number; + + /** + * Get the view rotation + * @returns The rotation of the view in radians + */ + getRotation(): number; + + /** + * Get the current zoom level. Return undefined if the current resolution is undefined or not a "constrained resolution". + * @returns Zoom. + */ + getZoom(): number; + + /** + * Rotate the view around a given coordinate. + * @param rotation New rotation value for the view. + * @param anchor The rotation center. + */ + rotate(rotation: number, anchor: ol.Coordinate): void; + + /** + * Set the center of the current view. + * @param center The center of the view. + */ + setCenter(center: ol.Coordinate): void; + + /** + * Set the resolution for this view. + * @param resolution The resolution of the view. + */ + setResolution(resolution: number): void; + + /** + * Set the rotation for this view. + * @param rotation The rotation of the view in radians. + */ + setRotation(rotation: number): void; + + /** + * Zoom to a specific zoom level. + * @param zoom Zoom level. + */ + setZoom(zoom: number): void; + } + interface ViewOptions { + + /** The initial center for the view. The coordinate system for the center is specified with the projection option. Default is undefined, and layer sources will not be fetched if this is not set. */ + center?: Coordinate; + + /** Rotation constraint. false means no constraint. true means no constraint, but snap to zero near zero. A number constrains the rotation to that number of values. For example, 4 will constrain the rotation to 0, 90, 180, and 270 degrees. The default is true. */ + constrainRotation?: boolean; + + /** Enable rotation. Default is true. If false a rotation constraint that always sets the rotation to zero is used. The constrainRotation option has no effect if enableRotation is false. */ + enableRotation?: boolean; + + /**The extent that constrains the center, in other words, center cannot be set outside this extent. Default is undefined. */ + extent?: Extent; + + /** The maximum resolution used to determine the resolution constraint. It is used together with minResolution (or maxZoom) and zoomFactor. If unspecified it is calculated in such a way that the projection's validity extent fits in a 256x256 px tile. If the projection is Spherical Mercator (the default) then maxResolution defaults to 40075016.68557849 / 256 = 156543.03392804097. */ + maxResolution?: number; + + /** The minimum resolution used to determine the resolution constraint. It is used together with maxResolution (or minZoom) and zoomFactor. If unspecified it is calculated assuming 29 zoom levels (with a factor of 2). If the projection is Spherical Mercator (the default) then minResolution defaults to 40075016.68557849 / 256 / Math.pow(2, 28) = 0.0005831682455839253. */ + minResolution?: number; + + /** The maximum zoom level used to determine the resolution constraint. It is used together with minZoom (or maxResolution) and zoomFactor. Default is 28. Note that if minResolution is also provided, it is given precedence over maxZoom. */ + maxZoom?: number; + + /** The minimum zoom level used to determine the resolution constraint. It is used together with maxZoom (or minResolution) and zoomFactor. Default is 0. Note that if maxResolution is also provided, it is given precedence over minZoom. */ + minZoom?: number; + + /** The projection. Default is EPSG:3857 (Spherical Mercator). */ + projection?: any; + + /** The initial resolution for the view. The units are projection units per pixel (e.g. meters per pixel). An alternative to setting this is to set zoom. Default is undefined, and layer sources will not be fetched if neither this nor zoom are defined. */ + resolution?: number; + + /** Resolutions to determine the resolution constraint. If set the maxResolution, minResolution, minZoom, maxZoom, and zoomFactor options are ignored. */ + resolutions?: Array; + + /** The initial rotation for the view in radians (positive rotation clockwise). Default is 0. */ + rotation?: number; + + /** Only used if resolution is not defined. Zoom level used to calculate the initial resolution for the view. The initial resolution is determined using the ol.View#constrainResolution method. */ + zoom?: number; + + /** The zoom factor used to determine the resolution constraint. Default is 2. */ + zoomFactor?: number; + } + interface ViewFitGeometryOptions { + + /** + * Padding (in pixels) to be cleared inside the view. Values in the array are top, right, bottom and left padding. Default is [0, 0, 0, 0]. + */ + padding?: Array; + + /** + * Constrain the resolution. Default is true. + */ + constrainResolution?: boolean; + + /** + * Get the nearest extent. Default is false. + */ + nearest?: boolean; + + /** + * Minimum resolution that we zoom to. Default is 0. + */ + minResolution?: number; + + /** + * Maximum zoom level that we zoom to. If minResolution is given, this property is ignored. + */ + maxZoom?: number; + } + + // NAMESPACES + module animation { + } + + module color { + } + + module control { + class Attribution { + } + + class Control { + } + + class FullScreen { + } + + class MousePosition { + } + + class OverviewMap { + } + + class Rotate { + } + + class ScaleLine { + } + + class Zoom { + } + + class ZoomSlider { + } + + class ZoomToExtent { + } + } + + module coordinate { + } + + module easing { + } + + module events { + module condition { + } + } + + module extent { + } + + module featureloader { + } + + module format { + + // Type definitions + interface IGCZ extends String { } + + // Classes + class EsriJSON { + } + + class Feature { + } + + class GeoJSON { + } + + class GML { + } + + class GML2 { + } + + class GML3 { + } + + class GMLBase { + } + + class GPX { + } + + class IGC { + } + + class JSONFeature { + } + + class KML { + } + + class OSMXML { + } + + class Polyline { + } + + class TextFeature { + } + + class TopoJSON { + } + + class WFS { + } + + class WKT { + } + + class WMSCapabilities { + } + + class WMSGetFeatureInfo { + } + + class WMTSCapabilities { + } + + class XML { + } + + class XMLFeature { + } + } + + module geom { + + // Type definitions + interface GeometryLayout extends String { } + interface GeometryType extends String { } + + class Circle { + } + + class Geometry { + } + + class GeometryCollection { + } + + class LinearRing { + } + + class LineString { + new(): LineString; + } + + class MultiLineString { + } + + class MultiPoint { + } + + class MultiPolygon { + } + + class Point { + } + + class Polygon { + } + + class SimpleGeometry { + } + } + + module has { + } + + module interaction { + + class DoubleClickZoom { + } + + class DragAndDrop { + } + + class DragAndDropEvent { + } + + class DragBox { + } + + class DragPan { + } + + class DragRotate { + } + + class DragRotateAndZoom { + } + + class DragZoom { + } + + class Draw { + } + + class DrawEvent { + } + + class Interaction { + } + + class KeyboardPan { + } + + class KeyboardZoom { + } + + class Modify { + } + + class MouseWheelZoom { + } + + class PinchRotate { + } + + class PinchZoom { + } + + class Pointer { + } + + class Select { + } + + class Snap { + } + } + + module layer { + + class Base { + } + + class Group { + } + + class Heatmap { + } + + class Image { + } + + class Layer { + } + + class Tile { + constructor(options: any); + } + + class Vector { + } + } + + module loadingstrategy { + } + + module proj { + + // Type definitions + interface ProjectionLike extends String { } + interface Units extends String { } + + // Methods + + /** + * Meters per unit lookup table. + */ + //TODO: validate! + var METERS_PER_UNIT: Object; + + /** + * Registers coordinate transform functions to convert coordinates between the source projection and the destination projection. The forward and inverse functions convert coordinate pairs; this function converts these into the functions used internally which also handle extents and coordinate arrays. + * @param source Source projection + * @param destination Destination projection + * @param forward The forward transform function (that is, from the source projection to the destination projection) that takes a ol.Coordinate as argument and returns the transformed ol.Coordinate. + * @param inverse The inverse transform function (that is, from the destination projection to the source projection) that takes a ol.Coordinate as argument and returns the transformed ol.Coordinate. + */ + function addCoordinateTransforms(source: ProjectionLike, destination: ProjectionLike, forward: (coordinate: Coordinate) => Coordinate, inverse: (coordinate: Coordinate) => Coordinate): void; + + /** + * Registers transformation functions that don't alter coordinates. Those allow to transform between projections with equal meaning. + * @param projections Projections. + */ + function addEquivalentProjections(projections: Array): void; + + /** + * Add a Projection object to the list of supported projections that can be looked up by their code. + * @param projection Projection instance. + */ + function addProjection(projection: Projection): void; + + /** + * Transforms a coordinate from longitude/latitude to a different projection. + * @param coordinate Coordinate as longitude and latitude, i.e. an array with longitude as 1st and latitude as 2nd element. + * @param projection Target projection. The default is Web Mercator, i.e. 'EPSG:3857'. + */ + function fromLonLat(coordinate: Coordinate, opt_projection: ProjectionLike): Coordinate; + + /** + * Fetches a Projection object for the code specified. + * @param projectionLike Either a code string which is a combination of authority and identifier such as "EPSG:4326", or an existing projection object, or undefined. + * @returns Projection object, or null if not in list. + */ + function get(projectionLike: ProjectionLike): Projection; + + /** + * Given the projection-like objects, searches for a transformation function to convert a coordinates array from the source projection to the destination projection. + * @param source Source. + * @param destination Destination. + * @returns Transform function. + */ + // TODO: Transformfunction + function getTransform(source: ProjectionLike, destination: ProjectionLike): any; + + /** + * Transforms a coordinate to longitude/latitude. + * @param coordinate Projected coordinate. + * @param projection Projection of the coordinate. The default is Web Mercator, i.e. 'EPSG:3857'. + * @returns Coordinate as longitude and latitude, i.e. an array with longitude as 1st and latitude as 2nd element. + */ + function toLonLat(coordinate: Coordinate, projection: ProjectionLike): Coordinate; + + /** + * Transforms a coordinate from source projection to destination projection. This returns a new coordinate (and does not modify the original). + * @param coordinate Coordinate. + * @param source Source projection-like. + * @param destination Destination projection-like. + * @returns Coordinate. + */ + function transform(coordinate: Coordinate, source: ProjectionLike, destination: ProjectionLike): Coordinate; + + /** + * Transforms an extent from source projection to destination projection. This returns a new extent (and does not modify the original). + * @param extent The extent to transform. + * @param source Source projection-like. + * @param destination Destination projection-like. + * @returns The transformed extent. + */ + function transformExtent(extent: Extent, source: ProjectionLike, destination: ProjectionLike): Extent; + + interface Projection { + } + } + + module render { + + class Event { + } + + class VectorContext { + } + + module canvas { + class Immediate { + } + } + } + + module source { + + class BingMaps { + } + + class Cluster { + } + + class Image { + } + + class ImageCanvas { + } + + class ImageEvent { + } + + class ImageMapGuide { + } + + class ImageStatic { + } + + class ImageVector { + } + + class ImageWMS { + } + + class MapQuest { + constructor(options: any); + } + + class OSM { + } + + class Source { + } + + class Stamen { + } + + class Tile { + } + + class TileArcGISRest { + } + + class TileDebug { + } + + class TileEvent { + } + + class TileImage { + } + + class TileJSON { + } + + class TileUTFGrid { + } + + class TileVector { + } + + class TileWMS { + } + + class Vector { + } + + class VectorEvent { + } + + class WMTS { + } + + class XYZ { + } + + class Zoomify { + } + + // Namespaces + module wms { + interface ServerType extends String { } + } + + // Type definitions + interface State extends String { } + interface WMTSRequestEncoding extends String { } + } + + module style { + + class AtlasManager { + } + + class Circle { + } + + class Fill { + } + + class Icon { + } + + class Image { + } + + class RegularShape { + } + + class Stroke { + constructor(); + } + + class Style { + } + + class Text { + } + } + + module tilegrid { + + class TileGrid { + } + + class WMTS { + } + + class Zoomify { + } + } + + module webgl { + + class Context { + new(canvas: HTMLCanvasElement, gl: WebGLRenderingContext): Context; + + /** + Get the WebGL rendering context + @returns The rendering context. + */ + getGL(): WebGLRenderingContext; + + /** + * Get the frame buffer for hit detection. + * @returns The hit detection frame buffer. + */ + getHitDetectionFramebuffer(): WebGLFramebuffer; + + /** + * Use a program. If the program is already in use, this will return false. + * @param program Program. + * @returns Changed. + */ + useProgram(program: WebGLProgram): boolean; + } + } + + // Type definitions + + /** + * A function returning the canvas element ({HTMLCanvasElement}) used by the source as an image. The arguments passed to the function are: ol.Extent the image extent, {number} the image resolution, {number} the device pixel ratio, ol.Size the image size, and ol.proj.Projection the image projection. The canvas returned by this function is cached by the source. The this keyword inside the function references the ol.source.ImageCanvas. + */ + function CanvasFunctionType(extent: Extent, resolution: number, pixelRatio: number, size: Size, projection: proj.Projection): HTMLCanvasElement; + + /** + * A color represented as a short array [red, green, blue, alpha]. red, green, and blue should be integers in the range 0..255 inclusive. alpha should be a float in the range 0..1 inclusive. + */ + interface Color extends Array { } + + /** + * An array of numbers representing an xy coordinate. Example: [16, 48]. + */ + interface Coordinate extends Array { } + + /** + * A function that takes a ol.Coordinate and transforms it into a {string}. + */ + function CoordinateFormatType(coordinate?: Coordinate): string; + + /** + * An array of numbers representing an extent: [minx, miny, maxx, maxy]. + */ + interface Extent extends Array { } + + /** + * Overlay position: 'bottom-left', 'bottom-center', 'bottom-right', 'center-left', 'center-center', 'center-right', 'top-left', 'top-center', 'top-right' + */ + interface OverlayPositioning extends String { } + + /** + * An array with two elements, representing a pixel. The first element is the x-coordinate, the second the y-coordinate of the pixel. + */ + interface Pixel extends Array { } + + /** + * Available renderers: 'canvas', 'dom' or 'webgl'. + */ + interface RendererType extends String { } + + /** + * An array of numbers representing a size: [width, height]. + */ + interface Size extends Array { } + + /** + * An array of three numbers representing the location of a tile in a tile grid. The order is z, x, and y. z is the zoom level. + */ + interface TileCoord extends Array { } + + // Functions + + /** + * A transform function accepts an array of input coordinate values, an optional output array, and an optional dimension (default should be 2). The function transforms the input coordinate values, populates the output array, and returns the output array. + */ + function TransformFunction(input: Array, output?: Array, dimension?: number): Array; +} \ No newline at end of file From 098def61bc44ee29dae7e7a5c719873195086ac2 Mon Sep 17 00:00:00 2001 From: vvakame Date: Tue, 23 Jun 2015 21:38:32 +0900 Subject: [PATCH 029/274] separate mocha node.js definition --- mocha/mocha-node-tests.ts | 37 +++++++++++++++++++++++++++++++++++++ mocha/mocha-node.d.ts | 16 ++++++++++++++++ mocha/mocha-tests.ts | 34 ---------------------------------- mocha/mocha.d.ts | 18 ++++++++---------- 4 files changed, 61 insertions(+), 44 deletions(-) create mode 100644 mocha/mocha-node-tests.ts create mode 100644 mocha/mocha-node.d.ts diff --git a/mocha/mocha-node-tests.ts b/mocha/mocha-node-tests.ts new file mode 100644 index 0000000000..e27ec8e6d9 --- /dev/null +++ b/mocha/mocha-node-tests.ts @@ -0,0 +1,37 @@ +/// + +import MochaDef = require('mocha'); + +class CustomSpecReporter extends MochaDef.reporters.Spec { + constructor(runner: Mocha.IRunner) { + super(runner); + + runner.on('test', (test: Mocha.ITest) => { + console.log(test.parent.title + '/' + test.title); + }); + } +} + +class MyReporter extends MochaDef.reporters.Base { + passes: number = 0; + failures: number = 0; + + constructor(runner: Mocha.IRunner) { + super(runner); + + runner.on('pass', (test: Mocha.ITest) => { + this.passes++; + console.log('pass: %s', test.fullTitle()); + }); + + runner.on('fail', (test: Mocha.ITest, err: Error) => { + this.failures++; + console.log('fail: %s -- error: %s', test.fullTitle(), err.message); + }); + + runner.on('end', () => { + console.log('end: %d/%d', this.passes, this.passes + this.failures); + process.exit(this.failures); + }); + } +} diff --git a/mocha/mocha-node.d.ts b/mocha/mocha-node.d.ts new file mode 100644 index 0000000000..b0fa0a6ac7 --- /dev/null +++ b/mocha/mocha-node.d.ts @@ -0,0 +1,16 @@ +// Type definitions for mocha 2.2.5 +// Project: http://mochajs.org/ +// Definitions by: Vadim Macagon , vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module Mocha { + interface IRunnable extends NodeJS.EventEmitter { + } + interface ISuite extends NodeJS.EventEmitter { + } + interface IRunner extends NodeJS.EventEmitter { + } +} diff --git a/mocha/mocha-tests.ts b/mocha/mocha-tests.ts index a2e2b07961..f90fefaf96 100644 --- a/mocha/mocha-tests.ts +++ b/mocha/mocha-tests.ts @@ -249,37 +249,3 @@ function test_run_withOnComplete() { console.log(failures); }); } - -class CustomSpecReporter extends MochaDef.reporters.Spec { - constructor(runner: Mocha.IRunner) { - super(runner); - - runner.on('test', (test: Mocha.ITest) => { - console.log(test.parent.title + '/' + test.title); - }); - } -} - -class MyReporter extends MochaDef.reporters.Base { - passes: number = 0; - failures: number = 0; - - constructor(runner: Mocha.IRunner) { - super(runner); - - runner.on('pass', (test: Mocha.ITest) => { - this.passes++; - console.log('pass: %s', test.fullTitle()); - }); - - runner.on('fail', (test: Mocha.ITest, err: Error) => { - this.failures++; - console.log('fail: %s -- error: %s', test.fullTitle(), err.message); - }); - - runner.on('end', () => { - console.log('end: %d/%d', this.passes, this.passes + this.failures); - process.exit(this.failures); - }); - } -} diff --git a/mocha/mocha.d.ts b/mocha/mocha.d.ts index fefd919466..e3484bd72c 100644 --- a/mocha/mocha.d.ts +++ b/mocha/mocha.d.ts @@ -3,8 +3,6 @@ // Definitions by: Kazi Manzur Rashid , otiai10 , jt000 , Vadim Macagon // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// - interface MochaSetupOptions { //milliseconds to wait before considering a test slow slow?: number; @@ -30,7 +28,7 @@ interface MochaSetupOptions { // grep string or regexp to filter tests with grep?: any; } - + interface MochaDone { (error?: Error): void; } @@ -118,7 +116,7 @@ declare class Mocha { // merge the Mocha class declaration with a module declare module Mocha { /** Partial interface for Mocha's `Runnable` class. */ - interface IRunnable extends NodeJS.EventEmitter { + interface IRunnable { title: string; fn: Function; async: boolean; @@ -127,10 +125,10 @@ declare module Mocha { } /** Partial interface for Mocha's `Suite` class. */ - interface ISuite extends NodeJS.EventEmitter { + interface ISuite { parent: ISuite; title: string; - + fullTitle(): string; } @@ -138,12 +136,12 @@ declare module Mocha { interface ITest extends IRunnable { parent: ISuite; pending: boolean; - + fullTitle(): string; } /** Partial interface for Mocha's `Runner` class. */ - interface IRunner extends NodeJS.EventEmitter {} + interface IRunner {} interface IContextDefinition { (description: string, spec: () => void): ISuite; @@ -151,7 +149,7 @@ declare module Mocha { skip(description: string, spec: () => void): void; timeout(ms: number): void; } - + interface ITestDefinition { (expectation: string, assertion?: () => void): ITest; (expectation: string, assertion?: (done: MochaDone) => void): ITest; @@ -174,7 +172,7 @@ declare module Mocha { constructor(runner: IRunner); } - + export class Doc extends Base {} export class Dot extends Base {} export class HTML extends Base {} From 2d07596b6f407239307f1292b4a2c63abfda653e Mon Sep 17 00:00:00 2001 From: Arseniy Maximov Date: Tue, 23 Jun 2015 17:45:29 +0300 Subject: [PATCH 030/274] Create declaration file for Polyline --- polyline/polyline-tests.ts | 16 ++++++++++++++++ polyline/polyline.d.ts | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 polyline/polyline-tests.ts create mode 100644 polyline/polyline.d.ts diff --git a/polyline/polyline-tests.ts b/polyline/polyline-tests.ts new file mode 100644 index 0000000000..888d15f91a --- /dev/null +++ b/polyline/polyline-tests.ts @@ -0,0 +1,16 @@ +/// + +// returns an array of lat, lon pairs +polyline.decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@'); + +// returns a string-encoded polyline +polyline.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]); + +// returns a string-encoded polyline from a GeoJSON LineString +polyline.fromGeoJSON({ "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [[-120.2, 38.5], [-120.95, 40.7], [-126.453, 43.252]] + }, + "properties": {} +}); \ No newline at end of file diff --git a/polyline/polyline.d.ts b/polyline/polyline.d.ts new file mode 100644 index 0000000000..5663fac491 --- /dev/null +++ b/polyline/polyline.d.ts @@ -0,0 +1,22 @@ +// Type definitions for Polyline 0.1.0 +// Project: https://github.com/mapbox/polyline +// Definitions by: Arseniy Maximov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface NumberArray { + [index: number]: number; +} + +interface Polyline { + decode(string: string, precision?: number): NumberArray[]; + encode(coordinate: NumberArray[], precision?: number): string; + fromGeoJSON(geojson: GeoJSON.GeoJsonObject, precision?: number): string; +} + +declare var polyline: Polyline; + +declare module "polyline" { + export = polyline; +} \ No newline at end of file From b56e56736a54393e3ff3c08d9cebd0d697f8bd10 Mon Sep 17 00:00:00 2001 From: Arseniy Maximov Date: Tue, 23 Jun 2015 18:36:36 +0300 Subject: [PATCH 031/274] we don't need NumberArray, omg. --- polyline/polyline.d.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/polyline/polyline.d.ts b/polyline/polyline.d.ts index 5663fac491..0f220e1d30 100644 --- a/polyline/polyline.d.ts +++ b/polyline/polyline.d.ts @@ -5,13 +5,9 @@ /// -interface NumberArray { - [index: number]: number; -} - interface Polyline { - decode(string: string, precision?: number): NumberArray[]; - encode(coordinate: NumberArray[], precision?: number): string; + decode(string: string, precision?: number): number[][]; + encode(coordinate: number[][], precision?: number): string; fromGeoJSON(geojson: GeoJSON.GeoJsonObject, precision?: number): string; } From 8833ceece1ed48b36b00b53ed7d66acc8aedfde5 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 23 Jun 2015 09:42:37 -0700 Subject: [PATCH 032/274] Combine internal/external React .d.ts files and prepare for TS JSX support --- react/react-addons-global.d.ts | 2 +- react/react-global.d.ts | 781 --------------------------------- react/react-jsx.d.ts | 147 +++++++ react/react.d.ts | 12 +- 4 files changed, 158 insertions(+), 784 deletions(-) delete mode 100644 react/react-global.d.ts create mode 100644 react/react-jsx.d.ts diff --git a/react/react-addons-global.d.ts b/react/react-addons-global.d.ts index 508ae05225..ed6096fa6f 100644 --- a/react/react-addons-global.d.ts +++ b/react/react-addons-global.d.ts @@ -2,7 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// declare module React { // diff --git a/react/react-global.d.ts b/react/react-global.d.ts deleted file mode 100644 index 5a4893862f..0000000000 --- a/react/react-global.d.ts +++ /dev/null @@ -1,781 +0,0 @@ -// Type definitions for React v0.13.1 (internal module) -// Project: http://facebook.github.io/react/ -// Definitions by: Asana , AssureSign -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare module React { - // - // React Elements - // ---------------------------------------------------------------------- - - type ReactType = ComponentClass | string; - - interface ReactElement

{ - type: string | ComponentClass

; - props: P; - key: string | number; - ref: string | ((component: Component) => any); - } - - interface ClassicElement

extends ReactElement

{ - type: string | ClassicComponentClass

; - ref: string | ((component: ClassicComponent) => any); - } - - interface DOMElement

extends ClassicElement

{ - type: string; - ref: string | ((component: DOMComponent

) => any); - } - - type HTMLElement = DOMElement; - type SVGElement = DOMElement; - - // - // Factories - // ---------------------------------------------------------------------- - - interface Factory

{ - (props?: P, ...children: ReactNode[]): ReactElement

; - } - - interface ClassicFactory

extends Factory

{ - (props?: P, ...children: ReactNode[]): ClassicElement

; - } - - interface DOMFactory

extends ClassicFactory

{ - (props?: P, ...children: ReactNode[]): DOMElement

; - } - - type HTMLFactory = DOMFactory; - type SVGFactory = DOMFactory; - - // - // React Nodes - // http://facebook.github.io/react/docs/glossary.html - // ---------------------------------------------------------------------- - - type ReactText = string | number; - type ReactChild = ReactElement | ReactText; - - // Should be Array but type aliases cannot be recursive - type ReactFragment = {} | Array; - type ReactNode = ReactChild | ReactFragment | boolean; - - // - // Top Level API - // ---------------------------------------------------------------------- - - function createClass(spec: ComponentSpec): ClassicComponentClass

; - - function createFactory

(type: string): DOMFactory

; - function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; - function createFactory

(type: ComponentClass

): Factory

; - - function createElement

( - type: string, - props?: P, - ...children: ReactNode[]): DOMElement

; - function createElement

( - type: ClassicComponentClass

| string, - props?: P, - ...children: ReactNode[]): ClassicElement

; - function createElement

( - type: ComponentClass

, - props?: P, - ...children: ReactNode[]): ReactElement

; - - function cloneElement

( - element: DOMElement

, - props?: P, - ...children: ReactNode[]): DOMElement

; - function cloneElement

( - element: ClassicElement

, - props?: P, - ...children: ReactNode[]): ClassicElement

; - function cloneElement

( - element: ReactElement

, - props?: P, - ...children: ReactNode[]): ReactElement

; - - function render

( - element: DOMElement

, - container: Element, - callback?: () => any): DOMComponent

; - function render( - element: ClassicElement

, - container: Element, - callback?: () => any): ClassicComponent; - function render( - element: ReactElement

, - container: Element, - callback?: () => any): Component; - - function unmountComponentAtNode(container: Element): boolean; - function renderToString(element: ReactElement): string; - function renderToStaticMarkup(element: ReactElement): string; - function isValidElement(object: {}): boolean; - function initializeTouchEvents(shouldUseTouch: boolean): void; - - function findDOMNode( - componentOrElement: Component | Element): TElement; - function findDOMNode( - componentOrElement: Component | Element): Element; - - var DOM: ReactDOM; - var PropTypes: ReactPropTypes; - var Children: ReactChildren; - - // - // Component API - // ---------------------------------------------------------------------- - - // Base component for plain JS classes - class Component implements ComponentLifecycle { - constructor(props?: P, context?: any); - setState(f: (prevState: S, props: P) => S, callback?: () => any): void; - setState(state: S, callback?: () => any): void; - forceUpdate(): void; - props: P; - state: S; - context: any; - refs: { - [key: string]: Component - }; - } - - interface ClassicComponent extends Component { - replaceState(nextState: S, callback?: () => any): void; - getDOMNode(): TElement; - getDOMNode(): Element; - isMounted(): boolean; - getInitialState?(): S; - setProps(nextProps: P, callback?: () => any): void; - replaceProps(nextProps: P, callback?: () => any): void; - } - - interface DOMComponent

extends ClassicComponent { - tagName: string; - } - - type HTMLComponent = DOMComponent; - type SVGComponent = DOMComponent; - - interface ChildContextProvider { - getChildContext(): CC; - } - - // - // Class Interfaces - // ---------------------------------------------------------------------- - - interface ComponentClass

{ - new(props?: P, context?: any): Component; - propTypes?: ValidationMap

; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap; - defaultProps?: P; - } - - interface ClassicComponentClass

extends ComponentClass

{ - new(props?: P, context?: any): ClassicComponent; - getDefaultProps?(): P; - displayName?: string; - } - - // - // Component Specs and Lifecycle - // ---------------------------------------------------------------------- - - interface ComponentLifecycle { - componentWillMount?(): void; - componentDidMount?(): void; - componentWillReceiveProps?(nextProps: P, nextContext: any): void; - shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; - componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; - componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; - componentWillUnmount?(): void; - } - - interface Mixin extends ComponentLifecycle { - mixins?: Mixin; - statics?: { - [key: string]: any; - }; - - displayName?: string; - propTypes?: ValidationMap; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap - - getDefaultProps?(): P; - getInitialState?(): S; - } - - interface ComponentSpec extends Mixin { - render(): ReactElement; - } - - // - // Event System - // ---------------------------------------------------------------------- - - interface SyntheticEvent { - bubbles: boolean; - cancelable: boolean; - currentTarget: EventTarget; - defaultPrevented: boolean; - eventPhase: number; - isTrusted: boolean; - nativeEvent: Event; - preventDefault(): void; - stopPropagation(): void; - target: EventTarget; - timeStamp: Date; - type: string; - } - - interface DragEvent extends SyntheticEvent { - dataTransfer: DataTransfer; - } - - interface ClipboardEvent extends SyntheticEvent { - clipboardData: DataTransfer; - } - - interface KeyboardEvent extends SyntheticEvent { - altKey: boolean; - charCode: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - key: string; - keyCode: number; - locale: string; - location: number; - metaKey: boolean; - repeat: boolean; - shiftKey: boolean; - which: number; - } - - interface FocusEvent extends SyntheticEvent { - relatedTarget: EventTarget; - } - - interface FormEvent extends SyntheticEvent { - } - - interface MouseEvent extends SyntheticEvent { - altKey: boolean; - button: number; - buttons: number; - clientX: number; - clientY: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - pageX: number; - pageY: number; - relatedTarget: EventTarget; - screenX: number; - screenY: number; - shiftKey: boolean; - } - - interface TouchEvent extends SyntheticEvent { - altKey: boolean; - changedTouches: TouchList; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - shiftKey: boolean; - targetTouches: TouchList; - touches: TouchList; - } - - interface UIEvent extends SyntheticEvent { - detail: number; - view: AbstractView; - } - - interface WheelEvent extends SyntheticEvent { - deltaMode: number; - deltaX: number; - deltaY: number; - deltaZ: number; - } - - // - // Event Handler Types - // ---------------------------------------------------------------------- - - interface EventHandler { - (event: E): void; - } - - interface DragEventHandler extends EventHandler {} - interface ClipboardEventHandler extends EventHandler {} - interface KeyboardEventHandler extends EventHandler {} - interface FocusEventHandler extends EventHandler {} - interface FormEventHandler extends EventHandler {} - interface MouseEventHandler extends EventHandler {} - interface TouchEventHandler extends EventHandler {} - interface UIEventHandler extends EventHandler {} - interface WheelEventHandler extends EventHandler {} - - // - // Props / DOM Attributes - // ---------------------------------------------------------------------- - - interface Props { - children?: ReactNode; - key?: string | number; - ref?: string | ((component: T) => any); - } - - interface DOMAttributes extends Props> { - onCopy?: ClipboardEventHandler; - onCut?: ClipboardEventHandler; - onPaste?: ClipboardEventHandler; - onKeyDown?: KeyboardEventHandler; - onKeyPress?: KeyboardEventHandler; - onKeyUp?: KeyboardEventHandler; - onFocus?: FocusEventHandler; - onBlur?: FocusEventHandler; - onChange?: FormEventHandler; - onInput?: FormEventHandler; - onSubmit?: FormEventHandler; - onClick?: MouseEventHandler; - onDoubleClick?: MouseEventHandler; - onDrag?: DragEventHandler; - onDragEnd?: DragEventHandler; - onDragEnter?: DragEventHandler; - onDragExit?: DragEventHandler; - onDragLeave?: DragEventHandler; - onDragOver?: DragEventHandler; - onDragStart?: DragEventHandler; - onDrop?: DragEventHandler; - onMouseDown?: MouseEventHandler; - onMouseEnter?: MouseEventHandler; - onMouseLeave?: MouseEventHandler; - onMouseMove?: MouseEventHandler; - onMouseOut?: MouseEventHandler; - onMouseOver?: MouseEventHandler; - onMouseUp?: MouseEventHandler; - onTouchCancel?: TouchEventHandler; - onTouchEnd?: TouchEventHandler; - onTouchMove?: TouchEventHandler; - onTouchStart?: TouchEventHandler; - onScroll?: UIEventHandler; - onWheel?: WheelEventHandler; - - dangerouslySetInnerHTML?: { - __html: string; - }; - } - - // This interface is not complete. Only properties accepting - // unitless numbers are listed here (see CSSProperty.js in React) - interface CSSProperties { - boxFlex?: number; - boxFlexGroup?: number; - columnCount?: number; - flex?: number | string; - flexGrow?: number; - flexShrink?: number; - fontWeight?: number | string; - lineClamp?: number; - lineHeight?: number | string; - opacity?: number; - order?: number; - orphans?: number; - widows?: number; - zIndex?: number; - zoom?: number; - - // SVG-related properties - fillOpacity?: number; - strokeOpacity?: number; - strokeWidth?: number; - } - - interface HTMLAttributes extends DOMAttributes { - ref?: string | ((component: HTMLComponent) => void); - - accept?: string; - acceptCharset?: string; - accessKey?: string; - action?: string; - allowFullScreen?: boolean; - allowTransparency?: boolean; - alt?: string; - async?: boolean; - autoComplete?: boolean; - autoFocus?: boolean; - autoPlay?: boolean; - cellPadding?: number | string; - cellSpacing?: number | string; - charSet?: string; - checked?: boolean; - classID?: string; - className?: string; - cols?: number; - colSpan?: number; - content?: string; - contentEditable?: boolean; - contextMenu?: string; - controls?: any; - coords?: string; - crossOrigin?: string; - data?: string; - dateTime?: string; - defer?: boolean; - dir?: string; - disabled?: boolean; - download?: any; - draggable?: boolean; - encType?: string; - form?: string; - formAction?: string; - formEncType?: string; - formMethod?: string; - formNoValidate?: boolean; - formTarget?: string; - frameBorder?: number | string; - headers?: string; - height?: number | string; - hidden?: boolean; - high?: number; - href?: string; - hrefLang?: string; - htmlFor?: string; - httpEquiv?: string; - icon?: string; - id?: string; - label?: string; - lang?: string; - list?: string; - loop?: boolean; - low?: number; - manifest?: string; - marginHeight?: number; - marginWidth?: number; - max?: number | string; - maxLength?: number; - media?: string; - mediaGroup?: string; - method?: string; - min?: number | string; - multiple?: boolean; - muted?: boolean; - name?: string; - noValidate?: boolean; - open?: boolean; - optimum?: number; - pattern?: string; - placeholder?: string; - poster?: string; - preload?: string; - radioGroup?: string; - readOnly?: boolean; - rel?: string; - required?: boolean; - role?: string; - rows?: number; - rowSpan?: number; - sandbox?: string; - scope?: string; - scoped?: boolean; - scrolling?: string; - seamless?: boolean; - selected?: boolean; - shape?: string; - size?: number; - sizes?: string; - span?: number; - spellCheck?: boolean; - src?: string; - srcDoc?: string; - srcSet?: string; - start?: number; - step?: number | string; - style?: CSSProperties; - tabIndex?: number; - target?: string; - title?: string; - type?: string; - useMap?: string; - value?: string; - width?: number | string; - wmode?: string; - - // Non-standard Attributes - autoCapitalize?: boolean; - autoCorrect?: boolean; - property?: string; - itemProp?: string; - itemScope?: boolean; - itemType?: string; - unselectable?: boolean; - } - - interface SVGAttributes extends DOMAttributes { - ref?: string | ((component: SVGComponent) => void); - - cx?: number | string; - cy?: number | string; - d?: string; - dx?: number | string; - dy?: number | string; - fill?: string; - fillOpacity?: number | string; - fontFamily?: string; - fontSize?: number | string; - fx?: number | string; - fy?: number | string; - gradientTransform?: string; - gradientUnits?: string; - markerEnd?: string; - markerMid?: string; - markerStart?: string; - offset?: number | string; - opacity?: number | string; - patternContentUnits?: string; - patternUnits?: string; - points?: string; - preserveAspectRatio?: string; - r?: number | string; - rx?: number | string; - ry?: number | string; - spreadMethod?: string; - stopColor?: string; - stopOpacity?: number | string; - stroke?: string; - strokeDasharray?: string; - strokeLinecap?: string; - strokeOpacity?: number | string; - strokeWidth?: number | string; - textAnchor?: string; - transform?: string; - version?: string; - viewBox?: string; - x1?: number | string; - x2?: number | string; - x?: number | string; - y1?: number | string; - y2?: number | string - y?: number | string; - } - - // - // React.DOM - // ---------------------------------------------------------------------- - - interface ReactDOM { - // HTML - a: HTMLFactory; - abbr: HTMLFactory; - address: HTMLFactory; - area: HTMLFactory; - article: HTMLFactory; - aside: HTMLFactory; - audio: HTMLFactory; - b: HTMLFactory; - base: HTMLFactory; - bdi: HTMLFactory; - bdo: HTMLFactory; - big: HTMLFactory; - blockquote: HTMLFactory; - body: HTMLFactory; - br: HTMLFactory; - button: HTMLFactory; - canvas: HTMLFactory; - caption: HTMLFactory; - cite: HTMLFactory; - code: HTMLFactory; - col: HTMLFactory; - colgroup: HTMLFactory; - data: HTMLFactory; - datalist: HTMLFactory; - dd: HTMLFactory; - del: HTMLFactory; - details: HTMLFactory; - dfn: HTMLFactory; - dialog: HTMLFactory; - div: HTMLFactory; - dl: HTMLFactory; - dt: HTMLFactory; - em: HTMLFactory; - embed: HTMLFactory; - fieldset: HTMLFactory; - figcaption: HTMLFactory; - figure: HTMLFactory; - footer: HTMLFactory; - form: HTMLFactory; - h1: HTMLFactory; - h2: HTMLFactory; - h3: HTMLFactory; - h4: HTMLFactory; - h5: HTMLFactory; - h6: HTMLFactory; - head: HTMLFactory; - header: HTMLFactory; - hr: HTMLFactory; - html: HTMLFactory; - i: HTMLFactory; - iframe: HTMLFactory; - img: HTMLFactory; - input: HTMLFactory; - ins: HTMLFactory; - kbd: HTMLFactory; - keygen: HTMLFactory; - label: HTMLFactory; - legend: HTMLFactory; - li: HTMLFactory; - link: HTMLFactory; - main: HTMLFactory; - map: HTMLFactory; - mark: HTMLFactory; - menu: HTMLFactory; - menuitem: HTMLFactory; - meta: HTMLFactory; - meter: HTMLFactory; - nav: HTMLFactory; - noscript: HTMLFactory; - object: HTMLFactory; - ol: HTMLFactory; - optgroup: HTMLFactory; - option: HTMLFactory; - output: HTMLFactory; - p: HTMLFactory; - param: HTMLFactory; - picture: HTMLFactory; - pre: HTMLFactory; - progress: HTMLFactory; - q: HTMLFactory; - rp: HTMLFactory; - rt: HTMLFactory; - ruby: HTMLFactory; - s: HTMLFactory; - samp: HTMLFactory; - script: HTMLFactory; - section: HTMLFactory; - select: HTMLFactory; - small: HTMLFactory; - source: HTMLFactory; - span: HTMLFactory; - strong: HTMLFactory; - style: HTMLFactory; - sub: HTMLFactory; - summary: HTMLFactory; - sup: HTMLFactory; - table: HTMLFactory; - tbody: HTMLFactory; - td: HTMLFactory; - textarea: HTMLFactory; - tfoot: HTMLFactory; - th: HTMLFactory; - thead: HTMLFactory; - time: HTMLFactory; - title: HTMLFactory; - tr: HTMLFactory; - track: HTMLFactory; - u: HTMLFactory; - ul: HTMLFactory; - "var": HTMLFactory; - video: HTMLFactory; - wbr: HTMLFactory; - - // SVG - circle: SVGFactory; - defs: SVGFactory; - ellipse: SVGFactory; - g: SVGFactory; - line: SVGFactory; - linearGradient: SVGFactory; - mask: SVGFactory; - path: SVGFactory; - pattern: SVGFactory; - polygon: SVGFactory; - polyline: SVGFactory; - radialGradient: SVGFactory; - rect: SVGFactory; - stop: SVGFactory; - svg: SVGFactory; - text: SVGFactory; - tspan: SVGFactory; - } - - // - // React.PropTypes - // ---------------------------------------------------------------------- - - interface Validator { - (object: T, key: string, componentName: string): Error; - } - - interface Requireable extends Validator { - isRequired: Validator; - } - - interface ValidationMap { - [key: string]: Validator; - } - - interface ReactPropTypes { - any: Requireable; - array: Requireable; - bool: Requireable; - func: Requireable; - number: Requireable; - object: Requireable; - string: Requireable; - node: Requireable; - element: Requireable; - instanceOf(expectedClass: {}): Requireable; - oneOf(types: any[]): Requireable; - oneOfType(types: Validator[]): Requireable; - arrayOf(type: Validator): Requireable; - objectOf(type: Validator): Requireable; - shape(type: ValidationMap): Requireable; - } - - // - // React.Children - // ---------------------------------------------------------------------- - - interface ReactChildren { - map(children: ReactNode, fn: (child: ReactChild) => T): { [key:string]: T }; - forEach(children: ReactNode, fn: (child: ReactChild) => any): void; - count(children: ReactNode): number; - only(children: ReactNode): ReactChild; - } - - // - // Browser Interfaces - // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts - // ---------------------------------------------------------------------- - - interface AbstractView { - styleMedia: StyleMedia; - document: Document; - } - - interface Touch { - identifier: number; - target: EventTarget; - screenX: number; - screenY: number; - clientX: number; - clientY: number; - pageX: number; - pageY: number; - } - - interface TouchList { - [index: number]: Touch; - length: number; - item(index: number): Touch; - identifiedTouch(identifier: number): Touch; - } -} - diff --git a/react/react-jsx.d.ts b/react/react-jsx.d.ts new file mode 100644 index 0000000000..25070734f1 --- /dev/null +++ b/react/react-jsx.d.ts @@ -0,0 +1,147 @@ +// Type definitions for React v0.13.1 (JSX support) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + +declare module JSX { + interface Element extends React.ReactElement { } + interface ElementClass extends React.Component { } + interface ElementAttributesProperty { props: {}; } + + interface IntrinsicElements { + // HTML + a: React.HTMLAttributes; + abbr: React.HTMLAttributes; + address: React.HTMLAttributes; + area: React.HTMLAttributes; + article: React.HTMLAttributes; + aside: React.HTMLAttributes; + audio: React.HTMLAttributes; + b: React.HTMLAttributes; + base: React.HTMLAttributes; + bdi: React.HTMLAttributes; + bdo: React.HTMLAttributes; + big: React.HTMLAttributes; + blockquote: React.HTMLAttributes; + body: React.HTMLAttributes; + br: React.HTMLAttributes; + button: React.HTMLAttributes; + canvas: React.HTMLAttributes; + caption: React.HTMLAttributes; + cite: React.HTMLAttributes; + code: React.HTMLAttributes; + col: React.HTMLAttributes; + colgroup: React.HTMLAttributes; + data: React.HTMLAttributes; + datalist: React.HTMLAttributes; + dd: React.HTMLAttributes; + del: React.HTMLAttributes; + details: React.HTMLAttributes; + dfn: React.HTMLAttributes; + dialog: React.HTMLAttributes; + div: React.HTMLAttributes; + dl: React.HTMLAttributes; + dt: React.HTMLAttributes; + em: React.HTMLAttributes; + embed: React.HTMLAttributes; + fieldset: React.HTMLAttributes; + figcaption: React.HTMLAttributes; + figure: React.HTMLAttributes; + footer: React.HTMLAttributes; + form: React.HTMLAttributes; + h1: React.HTMLAttributes; + h2: React.HTMLAttributes; + h3: React.HTMLAttributes; + h4: React.HTMLAttributes; + h5: React.HTMLAttributes; + h6: React.HTMLAttributes; + head: React.HTMLAttributes; + header: React.HTMLAttributes; + hr: React.HTMLAttributes; + html: React.HTMLAttributes; + i: React.HTMLAttributes; + iframe: React.HTMLAttributes; + img: React.HTMLAttributes; + input: React.HTMLAttributes; + ins: React.HTMLAttributes; + kbd: React.HTMLAttributes; + keygen: React.HTMLAttributes; + label: React.HTMLAttributes; + legend: React.HTMLAttributes; + li: React.HTMLAttributes; + link: React.HTMLAttributes; + main: React.HTMLAttributes; + map: React.HTMLAttributes; + mark: React.HTMLAttributes; + menu: React.HTMLAttributes; + menuitem: React.HTMLAttributes; + meta: React.HTMLAttributes; + meter: React.HTMLAttributes; + nav: React.HTMLAttributes; + noscript: React.HTMLAttributes; + object: React.HTMLAttributes; + ol: React.HTMLAttributes; + optgroup: React.HTMLAttributes; + option: React.HTMLAttributes; + output: React.HTMLAttributes; + p: React.HTMLAttributes; + param: React.HTMLAttributes; + picture: React.HTMLAttributes; + pre: React.HTMLAttributes; + progress: React.HTMLAttributes; + q: React.HTMLAttributes; + rp: React.HTMLAttributes; + rt: React.HTMLAttributes; + ruby: React.HTMLAttributes; + s: React.HTMLAttributes; + samp: React.HTMLAttributes; + script: React.HTMLAttributes; + section: React.HTMLAttributes; + select: React.HTMLAttributes; + small: React.HTMLAttributes; + source: React.HTMLAttributes; + span: React.HTMLAttributes; + strong: React.HTMLAttributes; + style: React.HTMLAttributes; + sub: React.HTMLAttributes; + summary: React.HTMLAttributes; + sup: React.HTMLAttributes; + table: React.HTMLAttributes; + tbody: React.HTMLAttributes; + td: React.HTMLAttributes; + textarea: React.HTMLAttributes; + tfoot: React.HTMLAttributes; + th: React.HTMLAttributes; + thead: React.HTMLAttributes; + time: React.HTMLAttributes; + title: React.HTMLAttributes; + tr: React.HTMLAttributes; + track: React.HTMLAttributes; + u: React.HTMLAttributes; + ul: React.HTMLAttributes; + "var": React.HTMLAttributes; + video: React.HTMLAttributes; + wbr: React.HTMLAttributes; + + // SVG + svg: React.SVGElementAttributes; + + circle: React.SVGAttributes; + defs: React.SVGAttributes; + ellipse: React.SVGAttributes; + g: React.SVGAttributes; + line: React.SVGAttributes; + linearGradient: React.SVGAttributes; + mask: React.SVGAttributes; + path: React.SVGAttributes; + pattern: React.SVGAttributes; + polygon: React.SVGAttributes; + polyline: React.SVGAttributes; + radialGradient: React.SVGAttributes; + rect: React.SVGAttributes; + stop: React.SVGAttributes; + text: React.SVGAttributes; + tspan: React.SVGAttributes; + } +} diff --git a/react/react.d.ts b/react/react.d.ts index 0b202f20e8..b23a8240ea 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -1,9 +1,9 @@ -// Type definitions for React v0.13.1 (external module) +// Type definitions for React v0.13.1 (internal and external module) // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module "react" { +declare module React { // // React Elements // ---------------------------------------------------------------------- @@ -518,6 +518,11 @@ declare module "react" { unselectable?: boolean; } + interface SVGElementAttributes extends HTMLAttributes { + viewBox?: string; + preserveAspectRatio?: string; + } + interface SVGAttributes extends DOMAttributes { ref?: string | ((component: SVGComponent) => void); @@ -779,3 +784,6 @@ declare module "react" { } } +declare module "react" { + export = React; +} From 432d6563a69fa1a71e3305394dbc629d7cfd95d5 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Tue, 23 Jun 2015 10:23:54 -0700 Subject: [PATCH 033/274] Update angular-translate to return module name. --- angular-translate/angular-translate.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/angular-translate/angular-translate.d.ts b/angular-translate/angular-translate.d.ts index 87a75439b2..1abb13ae81 100644 --- a/angular-translate/angular-translate.d.ts +++ b/angular-translate/angular-translate.d.ts @@ -5,6 +5,11 @@ /// +declare module "angular-translate" { + var _: string; + export = _; +} + declare module angular.translate { interface ITranslationTable { From 75e849a4e07d17f44e15f00d2d251260b352df53 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 23 Jun 2015 11:30:21 -0700 Subject: [PATCH 034/274] Add Microsoft attribute URL --- react/react-jsx.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/react-jsx.d.ts b/react/react-jsx.d.ts index 25070734f1..26ee4b2201 100644 --- a/react/react-jsx.d.ts +++ b/react/react-jsx.d.ts @@ -1,6 +1,6 @@ // Type definitions for React v0.13.1 (JSX support) // Project: http://facebook.github.io/react/ -// Definitions by: Asana , AssureSign , Microsoft +// Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From ab1501ff39245a2193ce00ada980170321404ce3 Mon Sep 17 00:00:00 2001 From: slozier Date: Tue, 23 Jun 2015 15:57:21 -0400 Subject: [PATCH 035/274] Make getRenderedRange arguments optional The getRenderedRange arguments are optional. https://github.com/mleibman/SlickGrid/wiki/Slick.Grid#getRenderedRange --- slickgrid/SlickGrid.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slickgrid/SlickGrid.d.ts b/slickgrid/SlickGrid.d.ts index 904e4f1271..cfdd3c690a 100644 --- a/slickgrid/SlickGrid.d.ts +++ b/slickgrid/SlickGrid.d.ts @@ -1172,7 +1172,7 @@ declare module Slick { public updateCell(row: number, cell: number): void; public updateRow(row: number): void; public getViewport(viewportTop?: number, viewportLeft?: number): Viewport; - public getRenderedRange(viewportTop: number, viewportLeft: number): Viewport; + public getRenderedRange(viewportTop?: number, viewportLeft?: number): Viewport; public resizeCanvas(): void; public updateRowCount(): void; public scrollRowIntoView(row: number, doPaging: boolean): void; From f7803b5aac1e082f2555dac477016629cc394693 Mon Sep 17 00:00:00 2001 From: David Lipowicz Date: Tue, 23 Jun 2015 14:30:08 -0700 Subject: [PATCH 036/274] Made a few small changes to address merge feedback. --- sigmajs/sigmajs.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sigmajs/sigmajs.d.ts b/sigmajs/sigmajs.d.ts index 985686ad45..fbc9bf45dd 100644 --- a/sigmajs/sigmajs.d.ts +++ b/sigmajs/sigmajs.d.ts @@ -21,9 +21,9 @@ declare module SigmaJs{ } interface Canvas { - edges: {[renderType: string]: Function}; - labels: {[renderType: string]: Function}; - nodes: {[renderType: string]: Function}; + edges: {[renderType: string]: (edge: Edge, source: Node, target: Node, ...a:any[]) => void}; + labels: {[renderType: string]: (node: Node, ...a:any[]) => void}; + nodes: {[renderType: string]: (node: Node, ...a:any[]) => void}; } interface Classes { From eff6f5ec54ec73d7b9ad2cc2f7af7495958a12ee Mon Sep 17 00:00:00 2001 From: Trevor Baron Date: Tue, 23 Jun 2015 20:48:31 -0400 Subject: [PATCH 037/274] change fromEvent to allow element of any type this function can take a wide range of types for element as seen from docs: https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/fromevent.md "element (Any): The DOMElement, NodeList, jQuery element, Zepto Element, Angular element, Ember.js element or EventEmitter to attach a listener. For Backbone.Marionette this would be the application or an EventAggregator object." --- rx/rx.async-lite.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rx/rx.async-lite.d.ts b/rx/rx.async-lite.d.ts index f86dc326f3..94eb398007 100644 --- a/rx/rx.async-lite.d.ts +++ b/rx/rx.async-lite.d.ts @@ -65,8 +65,7 @@ declare module Rx { (func: Function, context?: any): (...args: any[]) => Observable; }; - fromEvent(element: NodeList, eventName: string, selector?: (arguments: any[]) => T): Observable; - fromEvent(element: Node, eventName: string, selector?: (arguments: any[]) => T): Observable; + fromEvent(element: any, eventName: string, selector?: (arguments: any[]) => T): Observable; fromEventPattern(addHandler: (handler: Function) => void, removeHandler: (handler: Function) => void, selector?: (arguments: any[])=>T): Observable; } } From 1740c40614e1c9480a801c9aba69c4a032b4208d Mon Sep 17 00:00:00 2001 From: Gildor Date: Tue, 23 Jun 2015 18:03:16 -0700 Subject: [PATCH 038/274] fix d3 bisector type signature --- d3/d3.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index be329db811..e6e1941c94 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1090,8 +1090,8 @@ declare module d3 { export function bisectRight(array: T[], x: T, lo?: number, hi?: number): number; export function bisector(accessor: (x: T) => U): { - left: (array: T[], x: T, lo?: number, hi?: number) => number; - right: (array: T[], x: T, lo?: number, hi?: number) => number; + left: (array: T[], x: U, lo?: number, hi?: number) => number; + right: (array: T[], x: U, lo?: number, hi?: number) => number; } export function bisector(comparator: (a: T, b: U) => number): { From a14d724826174d1669d4df04c80f4838b7e71fdf Mon Sep 17 00:00:00 2001 From: itokentr Date: Wed, 24 Jun 2015 15:32:49 +0900 Subject: [PATCH 039/274] glob: Update to 5.0.10 --- glob/glob.d.ts | 123 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 41 deletions(-) diff --git a/glob/glob.d.ts b/glob/glob.d.ts index a15417f72c..6e97143758 100644 --- a/glob/glob.d.ts +++ b/glob/glob.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Glob +// Type definitions for Glob 5.0.10 // Project: https://github.com/isaacs/node-glob // Definitions by: vvakame // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -9,63 +9,104 @@ declare module "glob" { import events = require("events"); + import fs = require('fs'); import minimatch = require("minimatch"); - function G(pattern:string, cb:(err:Error, matches:string[])=>void):void; - - function G(pattern:string, options:G.IOptions, cb:(err:Error, matches:string[])=>void):void; + function G(pattern: string, cb: (err: Error, matches: string[]) => void): void; + function G(pattern: string, options: G.IOptions, cb: (err: Error, matches: string[]) => void): void; module G { - function sync(pattern:string, options?:IOptions):string[]; + function sync(pattern: string, options?: IOptions): string[]; - var Glob:IGlobStatic; + function hasMagic(pattern: string, options?: IOptions): boolean; + + var Glob: IGlobStatic; + var GlobSync: IGlobSyncStatic; interface IOptions extends minimatch.IOptions { cwd?: string; - sync?: boolean; + root?: string; + dot?: boolean; nomount?: boolean; - matchBase?:any; - noglobstar?:any; + mark?: boolean; + nosort?: boolean; + stat?: boolean; + silent?: boolean; strict?: boolean; - dot?:boolean; - mark?:boolean; - nounique?:boolean; - nonull?:boolean; - nosort?:boolean; - nocase?:boolean; - stat?:boolean; - debug?:boolean; - globDebug?:boolean; - silent?:boolean; + cache?: { [path: string]: any /* boolean | string | string[] */ }; + statCache?: { [path: string]: fs.Stats }; + symlinks?: any; + sync?: boolean; + nounique?: boolean; + nonull?: boolean; + debug?: boolean; + nobrace?: boolean; + noglobstar?: boolean; + noext?: boolean; + nocase?: boolean; + matchBase?: any; + nodir?: boolean; + ignore?: any; /* string | string[] */ + follow?: boolean; + realpath?: boolean; + nonegate?: boolean; + nocomment?: boolean; + + /** Deprecated. */ + globDebug?: boolean; } interface IGlobStatic extends events.EventEmitter { - new (pattern:string, cb?:(err:Error, matches:string[])=>void):IGlob; - new (pattern:string, options:any, cb?:(err:Error, matches:string[])=>void):IGlob; + new (pattern: string, cb?: (err: Error, matches: string[]) => void): IGlob; + new (pattern: string, options: IOptions, cb?: (err: Error, matches: string[]) => void): IGlob; + prototype: IGlob; } - interface IGlob { - EOF:any; - paused:boolean; - maxDepth:number; - maxLength:number; - cache:any; - statCache:any; - changedCwd:boolean; - cwd: string; - root: string; - error: any; - aborted: boolean; - minimatch: minimatch.IMinimatch; - matches:string[]; + interface IGlobSyncStatic { + new (pattern: string, options?: IOptions): IGlobBase + prototype: IGlobBase; + } - log(...args:any[]):void; - abort():void; - pause():void; - resume():void; - emitMatch(m:any):void; + interface IGlobBase { + minimatch: minimatch.IMinimatch; + options: IOptions; + aborted: boolean; + cache: { [path: string]: any /* boolean | string | string[] */ }; + statCache: { [path: string]: fs.Stats }; + symlinks: { [path: string]: boolean }; + realpathCache: { [path: string]: string }; + found: string[]; + } + + interface IGlob extends IGlobBase, events.EventEmitter { + pause(): void; + resume(): void; + abort(): void; + + /** Deprecated. */ + EOF: any; + /** Deprecated. */ + paused: boolean; + /** Deprecated. */ + maxDepth: number; + /** Deprecated. */ + maxLength: number; + /** Deprecated. */ + changedCwd: boolean; + /** Deprecated. */ + cwd: string; + /** Deprecated. */ + root: string; + /** Deprecated. */ + error: any; + /** Deprecated. */ + matches: string[]; + /** Deprecated. */ + log(...args: any[]): void; + /** Deprecated. */ + emitMatch(m: any): void; } } -export = G; + export = G; } From a3900b896f7b3361b79f9b503224777619907d53 Mon Sep 17 00:00:00 2001 From: itokentr Date: Wed, 24 Jun 2015 15:32:59 +0900 Subject: [PATCH 040/274] minimatch: Update to v2.0.8 --- minimatch/minimatch-tests.ts | 2 +- minimatch/minimatch.d.ts | 71 ++++++++++++++++++++++-------------- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/minimatch/minimatch-tests.ts b/minimatch/minimatch-tests.ts index 382a2c0a8f..38c699e0f0 100644 --- a/minimatch/minimatch-tests.ts +++ b/minimatch/minimatch-tests.ts @@ -12,7 +12,7 @@ var r = m.makeRe(); var f = ["test.ts"]; mm.match(f, pattern, options); -mm.filter('foo')('bar'); +f.filter(mm.filter(pattern, options)); var s: string = "hello"; var b: boolean = mm(s, pattern, options); diff --git a/minimatch/minimatch.d.ts b/minimatch/minimatch.d.ts index 697f9e21fc..a79c6ff114 100644 --- a/minimatch/minimatch.d.ts +++ b/minimatch/minimatch.d.ts @@ -1,47 +1,64 @@ -// Type definitions for Minimatch 1.0.0 +// Type definitions for Minimatch 2.0.8 // Project: https://github.com/isaacs/minimatch // Definitions by: vvakame // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module "minimatch" { - function M(target:string, pattern:string, options?:M.IOptions): boolean; + function M(target: string, pattern: string, options?: M.IOptions): boolean; module M { - function match(filenames:string[], pattern:string, options?:IOptions):string[]; - function filter(pattern:string, options?:IOptions): (target: string) => boolean; - - var Minimatch:IMinimatchStatic; + function match(list: string[], pattern: string, options?: IOptions): string[]; + function filter(pattern: string, options?: IOptions): (element: string, indexed: number, array: string[]) => boolean; + function makeRe(pattern: string, options?: IOptions): RegExp; + var Minimatch: IMinimatchStatic; + interface IOptions { - debug?:boolean; - nobrace?:boolean; - noglobstar?:boolean; - dot?:boolean; - noext?:boolean; - nocase?:boolean; - nonull?:boolean; - matchBase?:boolean; - nocomment?:boolean; - nonegate?:boolean; - flipNegate?:boolean; + debug?: boolean; + nobrace?: boolean; + noglobstar?: boolean; + dot?: boolean; + noext?: boolean; + nocase?: boolean; + nonull?: boolean; + matchBase?: boolean; + nocomment?: boolean; + nonegate?: boolean; + flipNegate?: boolean; } interface IMinimatchStatic { - new (pattern:string, options?:IOptions):IMinimatch; + new (pattern: string, options?: IOptions): IMinimatch; + prototype: IMinimatch; } interface IMinimatch { - debug():void; - make():void; - parseNegate():void; - braceExpand(pattern:string, options:IOptions):void; - parse(pattern:string, isSub?:boolean):void; - makeRe():RegExp; // regexp or boolean - match(file:string):boolean; - matchOne(files:string[], pattern:string[], partial:any):boolean; + pattern: string; + options: IOptions; + /** 2-dimensional array of regexp or string expressions. */ + set: any[][]; // (RegExp | string)[][] + regexp: RegExp; + negate: boolean; + comment: boolean; + empty: boolean; + + makeRe(): RegExp; // regexp or boolean + match(fname: string): boolean; + matchOne(files: string[], pattern: string[], partial: boolean): boolean; + + /** Deprecated. For internal use. */ + debug(): void; + /** Deprecated. For internal use. */ + make(): void; + /** Deprecated. For internal use. */ + parseNegate(): void; + /** Deprecated. For internal use. */ + braceExpand(pattern: string, options: IOptions): void; + /** Deprecated. For internal use. */ + parse(pattern: string, isSub?: boolean): void; } } -export = M; + export = M; } From 159edfacefca154b92f9a5c623538b4c95e81c28 Mon Sep 17 00:00:00 2001 From: Shearerbeard Date: Wed, 17 Jun 2015 19:36:40 -0600 Subject: [PATCH 041/274] typings for altjs flux library --- alt/alt.d.ts | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 alt/alt.d.ts diff --git a/alt/alt.d.ts b/alt/alt.d.ts new file mode 100644 index 0000000000..15bbc8e8e0 --- /dev/null +++ b/alt/alt.d.ts @@ -0,0 +1,158 @@ +// Type definitions for Alt 0.16.7 +// Project: https://github.com/goatslacker/alt +// Definitions by: Michael Shearer +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + + +declare module AltJS { + + export interface StoreModel { + bindActions?( ...actions:Array); + exportPublicMethods?(exportConfig:M):void; + getState?():S; + exportAsync?(source:Source); + waitFor?(store:AltStore):void; + } + + export type Source = {[name:string]:() => SourceModel}; + + export interface SourceModel { + local( ...args:Array); + remote( ...args:Array); + shouldFetch?(state:Object, ...args:Array); + loading: ( ...args:Array) => void; + success:( ...args:Array) => void; + error:( ...args:Array) => void; + interceptResponse?(response:Object, action:AltJS.Action, ...args:Array); + } + + export interface AltStore { + getState():S; + listen(handler:(state:S) => any):() => void; + unlisten(handler:(state:S) => any):void; + emitChange():void; + getEventEmitter():EventEmitter3.EventEmitter; + } + + export enum lifeCycleEvents { + bootstrap, + snapshot, + init, + rollback, + error + } + + export type Actions = {[action:string]:Action}; + + export interface Action { + (T); + defer(data:any):void; + } + + export interface ActionsClass { + generateActions?( ...action:Array); + dispatch( ...payload:Array); + actions?:Actions; + } +} + +declare module "alt/utils/chromeDebug" { + function chromeDebug(alt:any):void; + export = chromeDebug; +} + +declare module "alt/AltContainer" { + + import * as React from "react"; + + interface ContainerProps { + store:AltJS.AltStore + } + + class AltContainer extends React.Component { + } + + export = AltContainer; +} + +declare module "alt" { + + import {Dispatcher} from "flux"; + + type StateTransform = (store:StoreModel) => AltJS.AltStore; + + interface AltConfig { + dispatcher?:Dispatcher; + serialize?:(data:Object) => string; + deserialize?:(serialized:string) => Object; + storeTransforms?:Array; + batchingFunction?:(callback:( ...data:Array) => any) => void; + } + + class Alt { + constructor(config?:AltConfig); + actions:AltJS.Actions; + bootstrap(data:string); + takeSnapshot( ...storeNames:Array):string; + flush():Object; + recycle( ...store:Array>); + rollback(); + dispatch(action?:AltJS.Action, data?:Object, details?:any); + addActions(actionsName:string, actions:AltJS.ActionsClass); + addStore(name:string, store:StoreModel, saveStore?:boolean); + getStore(name:string):AltJS.AltStore; + getActions(actionsName:string):AltJS.Actions; + createAction(name:string, implementation:AltJS.ActionsClass):AltJS.Action; + createAction(name:string, implementation:AltJS.ActionsClass, ...args:Array):AltJS.Action; + createActions(ActionsClass: ActionsClassConstructor, exportObj?: Object):T; + createActions(ActionsClass: ActionsClassConstructor, exportObj?: Object, ...constructorArgs:Array):T; + generateActions( ...action:Array):T; + createStore(store:StoreModel, name?:string):AltJS.AltStore; + } + + type ActionsClassConstructor = new (alt:Alt) => AltJS.ActionsClass; + + type ActionHandler = ( ...data:Array) => any; + type ExportConfig = {[key:string]:( ...args:Array) => any}; + + interface StoreReduce { + action:any; + data: any; + } + + interface StoreModel extends AltJS.StoreModel { + setState?(currentState:Object, nextState:Object):Object; + getState?():S; + onSerialize?(data:any):void; + onDeserialize?(data:any):void; + on?(event:AltJS.lifeCycleEvents, callback:() => any):void; + bindActions?(action:AltJS.Action, method:ActionHandler):void; + bindListeners?(config:{string: AltJS.Action | AltJS.Actions}); + waitFor?(dispatcherSource:any):void; + exportPublicMethods?(exportConfig:ExportConfig):void; + getInstance?():AltJS.AltStore; + emitChange?():void; + dispatcher?:Dispatcher; + alt?:Alt; + displayName?:string; + otherwise?(data:any, action:AltJS.Action); + reduce?(state:any, config:StoreReduce):Object; + preventDefault?(); + observe?(alt:Alt):any; + registerAsync?(datasource:AltJS.Source); + beforeEach?(payload:Object, state:Object); + afterEach?(payload:Object, state:Object); + unlisten?(); + } + + type StoreModelConstructor = (alt:Alt) => StoreModel; + + interface AltFactory { + new(config?:AltConfig):Alt; + } + + export = Alt; +} From bfd9f256783c15000d5a3e957ef06323650ea8db Mon Sep 17 00:00:00 2001 From: Shearerbeard Date: Wed, 24 Jun 2015 08:59:31 -0600 Subject: [PATCH 042/274] committing revisions to keep in sync with alt 0.16.10/0.17.0 --- alt/alt.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/alt/alt.d.ts b/alt/alt.d.ts index 15bbc8e8e0..7f74b069e0 100644 --- a/alt/alt.d.ts +++ b/alt/alt.d.ts @@ -1,10 +1,9 @@ -// Type definitions for Alt 0.16.7 +// Type definitions for Alt 0.16.10 // Project: https://github.com/goatslacker/alt // Definitions by: Michael Shearer // Definitions: https://github.com/borisyankov/DefinitelyTyped /// -/// declare module AltJS { @@ -34,7 +33,6 @@ declare module AltJS { listen(handler:(state:S) => any):() => void; unlisten(handler:(state:S) => any):void; emitChange():void; - getEventEmitter():EventEmitter3.EventEmitter; } export enum lifeCycleEvents { @@ -74,7 +72,7 @@ declare module "alt/AltContainer" { class AltContainer extends React.Component { } - + export = AltContainer; } From d0e842e2f96893b86a2ea2d1e0a4dc504379cd69 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 25 Jun 2015 00:21:40 +0200 Subject: [PATCH 043/274] Q: Support for the Q.noConflict() method. --- q/Q.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/q/Q.d.ts b/q/Q.d.ts index 2a239dc18e..8453d5e73d 100644 --- a/q/Q.d.ts +++ b/q/Q.d.ts @@ -316,6 +316,13 @@ declare module Q { * Calling resolve with a non-promise value causes promise to be fulfilled with that value. */ export function resolve(object: T): Promise; + + /** + * Resets the global "Q" variable to the value it has before Q was loaded. + * This will either be undefined if there was no version or the version of Q which was already loaded before. + * @returns { The last version of Q. } + */ + export function noConflict(): typeof Q; } declare module "q" { From 39293fc55d77b5089cf1bdc57b61d9c8a975975a Mon Sep 17 00:00:00 2001 From: shaban Date: Thu, 25 Jun 2015 01:48:44 +0200 Subject: [PATCH 044/274] Update ace.d.ts Add isClean and markClean methods. Reference https://github.com/ajaxorg/ace/issues/324 --- ace/ace.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ace/ace.d.ts b/ace/ace.d.ts index 4758b59e96..f0668da3c4 100644 --- a/ace/ace.d.ts +++ b/ace/ace.d.ts @@ -2609,6 +2609,16 @@ declare module AceAjax { * Returns `true` if there are redo operations left to perform. **/ hasRedo(): boolean; + + /** + * Returns `true` if the dirty counter is 0 + **/ + isClean(): boolean; + + /** + * Sets dirty counter to 0 + **/ + markClean(): void; } var UndoManager: { From 78b83e0c238c7da99d4ac88994f877d2d718a181 Mon Sep 17 00:00:00 2001 From: heycalmdown Date: Thu, 25 Jun 2015 09:12:31 +0900 Subject: [PATCH 045/274] lodash: Add _.matchesProperty style to _.find --- lodash/lodash-tests.ts | 10 +-- lodash/lodash.d.ts | 171 +++++++++++++---------------------------- 2 files changed, 58 insertions(+), 123 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 633c4ed0d4..193f87c08c 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -403,15 +403,13 @@ result = _([1, 2, 3, 4, 5, 6]).select(function (num) { return num % 2 result = _(foodsCombined).select('organic').value(); result = _(foodsCombined).select({ 'type': 'fruit' }).value(); -result = _.find([1, 2, 3, 4], function (num) { - return num % 2 == 0; -}); +result = _.find([1, 2, 3, 4], num => num % 2 == 0); result = _.find(foodsCombined, { 'type': 'vegetable' }); +result = _.find(foodsCombined, 'type', 'vegetable'); result = _.find(foodsCombined, 'organic'); -result = _([1, 2, 3, 4]).find(function (num) { - return num % 2 == 0; -}); +result = _([1, 2, 3, 4]).find(num => num % 2 == 0); result = _(foodsCombined).find({ 'type': 'vegetable' }); +result = _(foodsCombined).find('type', 'vegetable'); result = _(foodsCombined).find('organic'); result = _.detect([1, 2, 3, 4], function (num) { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 9cb55485d9..faf921c57c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2710,15 +2710,19 @@ declare module _ { //_.find interface LoDashStatic { /** - * Iterates over elements of a collection, returning the first element that the callback - * returns truey for. The callback is bound to thisArg and invoked with three arguments; - * (value, index|key, collection). + * Iterates over elements of collection, returning the first element predicate returns + * truthy for. The predicate is bound to thisArg and invoked with three arguments: + * (value, index|key, collection). * - * If a property name is provided for callback the created "_.pluck" style callback will - * return the property value of the given element. + * If a property name is provided for predicate the created _.property style callback + * returns the property value of the given element. * - * If an object is provided for callback the created "_.where" style callback will return + * 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 collection Searches for a value in this list. * @param callback The function called per iteration. * @param thisArg The this binding of callback. @@ -2728,6 +2732,10 @@ declare module _ { collection: Array, callback: ListIterator, thisArg?: any): T; + detect( + collection: Array, + callback: ListIterator, + thisArg?: any): T; /** * @see _.find @@ -2736,6 +2744,10 @@ declare module _ { collection: List, callback: ListIterator, thisArg?: any): T; + detect( + collection: List, + callback: ListIterator, + thisArg?: any): T; /** * @see _.find @@ -2744,74 +2756,6 @@ declare module _ { collection: Dictionary, callback: DictionaryIterator, thisArg?: any): T; - - /** - * @see _.find - * @param _.pluck style callback - **/ - find( - collection: Array, - whereValue: W): T; - - /** - * @see _.find - * @param _.pluck style callback - **/ - find( - collection: List, - whereValue: W): T; - - /** - * @see _.find - * @param _.pluck style callback - **/ - find( - collection: Dictionary, - whereValue: W): T; - - /** - * @see _.find - * @param _.where style callback - **/ - find( - collection: Array, - pluckValue: string): T; - - /** - * @see _.find - * @param _.where style callback - **/ - find( - collection: List, - pluckValue: string): T; - - /** - * @see _.find - * @param _.where style callback - **/ - find( - collection: Dictionary, - pluckValue: string): T; - - /** - * @see _.find - **/ - detect( - collection: Array, - callback: ListIterator, - thisArg?: any): T; - - /** - * @see _.find - **/ - detect( - collection: List, - callback: ListIterator, - thisArg?: any): T; - - /** - * @see _.find - **/ detect( collection: Dictionary, callback: DictionaryIterator, @@ -2819,50 +2763,37 @@ declare module _ { /** * @see _.find - * @param _.pluck style callback + * @param _.matches style callback **/ + find( + collection: Array|List|Dictionary, + whereValue: W): T; detect( - collection: Array, + collection: Array|List|Dictionary, whereValue: W): T; /** * @see _.find - * @param _.pluck style callback - **/ - detect( - collection: List, - whereValue: W): T; - - /** - * @see _.find - * @param _.pluck style callback - **/ - detect( - collection: Dictionary, - whereValue: W): T; - - /** - * @see _.find - * @param _.where style callback + * @param _.matchesProperty style callback **/ + find( + collection: Array|List|Dictionary, + path: string, + srcValue: any): T; detect( - collection: Array, + collection: Array|List|Dictionary, + path: string, + srcValue: any): T; + + /** + * @see _.find + * @param _.property style callback + **/ + find( + collection: Array|List|Dictionary, pluckValue: string): T; - - /** - * @see _.find - * @param _.where style callback - **/ detect( - collection: List, - pluckValue: string): T; - - /** - * @see _.find - * @param _.where style callback - **/ - detect( - collection: Dictionary, + collection: Array|List|Dictionary, pluckValue: string): T; /** @@ -2891,7 +2822,7 @@ declare module _ { /** * @see _.find - * @param _.pluck style callback + * @param _.matches style callback **/ findWhere( collection: Array, @@ -2899,7 +2830,7 @@ declare module _ { /** * @see _.find - * @param _.pluck style callback + * @param _.matches style callback **/ findWhere( collection: List, @@ -2907,7 +2838,7 @@ declare module _ { /** * @see _.find - * @param _.pluck style callback + * @param _.matches style callback **/ findWhere( collection: Dictionary, @@ -2915,7 +2846,7 @@ declare module _ { /** * @see _.find - * @param _.where style callback + * @param _.property style callback **/ findWhere( collection: Array, @@ -2923,7 +2854,7 @@ declare module _ { /** * @see _.find - * @param _.where style callback + * @param _.property style callback **/ findWhere( collection: List, @@ -2931,7 +2862,7 @@ declare module _ { /** * @see _.find - * @param _.where style callback + * @param _.property style callback **/ findWhere( collection: Dictionary, @@ -2947,14 +2878,20 @@ declare module _ { thisArg?: any): T; /** * @see _.find - * @param _.where style callback + * @param _.matches style callback */ find( whereValue: W): T; - /** * @see _.find - * @param _.where style callback + * @param _.matchesProperty style callback + */ + find( + path: string, + srcValue: any): T; + /** + * @see _.find + * @param _.property style callback */ find( pluckValue: string): T; From 661e01689612eeb784e931e4f5274d4ea5d588b7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Jun 2015 10:17:24 +0300 Subject: [PATCH 046/274] Update for karma-jasmine 0.3.3+ --- karma-jasmine/karma-jasmine-tests.ts | 4 ++-- karma-jasmine/karma-jasmine.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/karma-jasmine/karma-jasmine-tests.ts b/karma-jasmine/karma-jasmine-tests.ts index 6e7a8db9fa..19e5436129 100644 --- a/karma-jasmine/karma-jasmine-tests.ts +++ b/karma-jasmine/karma-jasmine-tests.ts @@ -1,7 +1,7 @@ /// -ddescribe("A suite", () => { - iit("contains spec with an expectation", () => { +fdescribe("A suite", () => { + fit("contains spec with an expectation", () => { expect(true).toBe(true); }); }); diff --git a/karma-jasmine/karma-jasmine.d.ts b/karma-jasmine/karma-jasmine.d.ts index e4cdc5a816..6f61ca26e8 100644 --- a/karma-jasmine/karma-jasmine.d.ts +++ b/karma-jasmine/karma-jasmine.d.ts @@ -5,5 +5,5 @@ /// -declare function ddescribe(description: string, specDefinitions: () => void): void; -declare function iit(expectation: string, assertion: () => void): void; +declare function fdescribe(description: string, specDefinitions: () => void): void; +declare function fit(expectation: string, assertion: () => void): void; From dbd0c4066421c223535ec003e564a02b7f3b8367 Mon Sep 17 00:00:00 2001 From: woutergd Date: Thu, 25 Jun 2015 15:29:26 +0200 Subject: [PATCH 047/274] Added animation and default controls --- openlayers3/openlayers3.d.ts | 193 +++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) diff --git a/openlayers3/openlayers3.d.ts b/openlayers3/openlayers3.d.ts index d89c65ecca..7703a2d5ea 100644 --- a/openlayers3/openlayers3.d.ts +++ b/openlayers3/openlayers3.d.ts @@ -1413,13 +1413,206 @@ declare module ol { } // NAMESPACES + + /** + * The animation static methods are designed to be used with the ol.Map#beforeRender method. + */ module animation { + + /** + * Generate an animated transition that will "bounce" the resolution as it approaches the final value. + * @param options Bounce options. + */ + //TODO: return ol.PreRenderFunction + function bounce(options: AnimationBounceOptions): any; + interface AnimationBounceOptions { + + /** + * The resolution to start the bounce from, typically map.getView().getResolution(). + */ + resolution: number; + + /** + * The start time of the animation. Default is immediately. + */ + start?: number; + + /** + * The duration of the animation in milliseconds. Default is 1000. + */ + duration?: number; + + /** + * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. + */ + // TODO: Check if it is an ol.easing function + easing: () => void; + } + + /** + * Generate an animated transition while updating the view center. + * @param options Pan options. + */ + //TODO: return ol.PreRenderFunction + function pan(options: AnimationPanOptions): any; + interface AnimationPanOptions { + + /** + * The resolution to start the bounce from, typically map.getView().getResolution(). + */ + source: ol.Coordinate; + + /** + * The start time of the animation. Default is immediately. + */ + start?: number; + + /** + * The duration of the animation in milliseconds. Default is 1000. + */ + duration?: number; + + /** + * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. + */ + // TODO: Check if it is an ol.easing function + easing: () => void; + } + + /** + * Generate an animated transition while updating the view rotation. + * @param options Rotate options. + */ + //TODO: return ol.PreRenderFunction + function rotate(options: AnimationRotateOptions): any; + interface AnimationRotateOptions { + + /** + * The rotation value (in radians) to begin rotating from, typically map.getView().getRotation(). If undefined then 0 is assumed. + */ + rotation?: number; + + /** + * The rotation center/anchor. The map rotates around the center of the view if unspecified. + */ + anchor?: ol.Coordinate; + + /** + * The start time of the animation. Default is immediately. + */ + start?: number; + + /** + * The duration of the animation in milliseconds. Default is 1000. + */ + duration?: number; + + /** + * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. + */ + // TODO: Check if it is an ol.easing function + easing: () => void; + } + + /** + * Generate an animated transition while updating the view resolution. + * @param options Zoom options. + */ + function pan(options: AnimationZoomOptions): any; + interface AnimationZoomOptions { + + /** + * The resolution to begin zooming from, typically map.getView().getResolution(). + */ + resolution: number; + + /** + * The start time of the animation. Default is immediately. + */ + start?: number; + + /** + * The duration of the animation in milliseconds. Default is 1000. + */ + duration?: number; + + /** + * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. + */ + // TODO: Check if it is an ol.easing function + easing: () => void; + } } + /** + * Return the color as an array. This function maintains a cache of calculated arrays which means the result should not be modified. + */ module color { + + /** + * Return the color as an array. This function maintains a cache of calculated arrays which means the result should not be modified. + * @param color Color. + */ + function asArray(color: ol.Color): ol.Color; + function asArray(color: string): ol.Color; + + /** + * Return the color as an rgba string. + * @param color Color. + */ + function asString(color: ol.Color): string; + function asString(color: string): string; } module control { + + /** + * Set of controls included in maps by default. Unless configured otherwise, this returns a collection containing an instance of each of the following controls: ol.control.Zoom, ol.control.Rotate, ol.control.Attribution + * @param options Defaults options + * @returns Control.s + */ + function defaults(opt_options: ControlDefaultsOptions): ol.Collection; + interface ControlDefaultsOptions { + + /** + * Attribution. Default is true. + */ + attribution?: boolean; + + /** + * Attribution options. + */ + //TODO: Replace with olx.control.AttributionOptions + attributionOptions?: any; + + /** + * Rotate. Default is true; + */ + rotate?: boolean; + + /** + * Rotate options + */ + //TODO: Replace with olx.control.RotateOptions + rotateOptions?: any; + + /** + * Zoom. Default is true + */ + zoom?: boolean; + + /** + * + */ + //TODO: Replace with olx.control.ZoomOptions + zoomOptions?: any; + } + + /** + * Units for the scale line. Supported values are 'degrees', 'imperial', 'nautical', 'metric', 'us'. + */ + interface ScaleLineUnits extends String { } + class Attribution { } From 986e1ea0cbc079999f5941ee7660c29a0b1bfc63 Mon Sep 17 00:00:00 2001 From: mariusfilipowski Date: Thu, 25 Jun 2015 16:08:48 +0200 Subject: [PATCH 048/274] Support for Deactivating Compiler Option "Allow implicit any" --- amplifyjs/amplifyjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amplifyjs/amplifyjs.d.ts b/amplifyjs/amplifyjs.d.ts index 364845f3c4..30e8272943 100644 --- a/amplifyjs/amplifyjs.d.ts +++ b/amplifyjs/amplifyjs.d.ts @@ -50,7 +50,7 @@ interface amplifyRequest { * success (optional): Function to invoke on success. * error (optional): Function to invoke on error. */ - (settings: amplifyRequestSettings); + (settings: amplifyRequestSettings): any; /*** * Define a resource. From f06b7f6d022ce286e6438019fbb1100e04f585ba Mon Sep 17 00:00:00 2001 From: woutergd Date: Thu, 25 Jun 2015 17:28:10 +0200 Subject: [PATCH 049/274] Added ol.layer.* definitions --- openlayers3/openlayers3.d.ts | 467 ++++++++++++++++++++++++++++++++++- 1 file changed, 459 insertions(+), 8 deletions(-) diff --git a/openlayers3/openlayers3.d.ts b/openlayers3/openlayers3.d.ts index 7703a2d5ea..9f06166dab 100644 --- a/openlayers3/openlayers3.d.ts +++ b/openlayers3/openlayers3.d.ts @@ -1843,26 +1843,477 @@ declare module ol { module layer { - class Base { + /** + * Abstract base class; normally only used for creating subclasses and not instantiated in apps. Note that with ol.layer.Base and all its subclasses, any property set in the options is set as a ol.Object property on the layer object, so is observable, and has get/set accessors. + */ + class Base extends ol.Object { + + /** + * @constructor + * @param options Layer options. + */ + constructor(options?: BaseOptions); + + /** + * Return the brightness of the layer. + * @returns The brightness of the layer. + */ + getBrightness(): number; + + /** + * Return the contrast of the layer. + * @returns The contrast of the layer. + */ + getContrast(): number; + + /** + * Return the extent of the layer or undefined if it will be visible regardless of extent. + * @returns The layer extent. + */ + getExtent(): ol.Extent; + + /** + * Return the hue of the layer. + * @returns The hue of the layer + */ + getHue(): number; + + /** + * Return the maximum resolution of the layer. + * @returns The maximum resolution of the layer + */ + getMaxResolution(): number; + + /** + * Return the minimum resolution of the layer. + * @returns The minimum resolution of the layer. + */ + getMinResolution(): number; + + /** + * Return the opacity of the layer (between 0 and 1). + * @returns The opacity of the layer. + */ + getOpacity(): number; + + /** + * Return the saturation of the layer. + * @returns The saturation of the layer. + */ + getSaturation(): number; + + /** + * Return the visibility of the layer (true or false). + * The visibility of the layer + */ + getVisible(): boolean; + + /** + * Adjust the layer brightness. A value of -1 will render the layer completely black. A value of 0 will leave the brightness unchanged. A value of 1 will render the layer completely white. Other values are linear multipliers on the effect (values are clamped between -1 and 1). + * @param brightness The brightness of the layer + */ + setBrightness(brigthness: number): void; + + /** + * Adjust the layer contrast. A value of 0 will render the layer completely grey. A value of 1 will leave the contrast unchanged. Other values are linear multipliers on the effect (and values over 1 are permitted). + * @param contrast The contrast of the layer + */ + setContrast(contrast: number): void; + + /** + * Set the extent at which the layer is visible. If undefined, the layer will be visible at all extents. + * @param extent The extent of the layer + */ + setExtent(extent?: ol.Extent): void; + + /** + * Apply a hue-rotation to the layer. A value of 0 will leave the hue unchanged. Other values are radians around the color circle. + * @param hue The hue of the layer + */ + setHue(hue: number): void; + + /** + * Set the maximum resolution at which the layer is visible. + * @param maxResolution The maximum resolution of the layer. + */ + setMaxResolution(maxResolution: number): void; + + /** + * Set the minimum resolution at which the layer is visible. + * @param minResolution The minimum resolution of the layer. + */ + setMinResolution(minResolution: number): void; + + /** + * Set the opacity of the layer, allowed values range from 0 to 1. + * @param opactity The opacity of the layer. + */ + setOpacity(opacity: number): void; + + /** + * Adjust layer saturation. A value of 0 will render the layer completely unsaturated. A value of 1 will leave the saturation unchanged. Other values are linear multipliers of the effect (and values over 1 are permitted). + * @param saturation The saturation of the layer. + */ + setSaturation(saturation: number): void; + + /** + * Set the visibility of the layer (true or false). + * @param visible The visibility of the layer. + */ + setVisible(visible: boolean): void; } - class Group { + /** + * A ol.Collection of layers that are handled together. + */ + class Group extends ol.layer.Base { + + /** + * @constructor + * @param options Layer options. + */ + constructor(options?: GroupOptions); + + /** + * Returns the collection of layers in this group. + * @returns Collection of layers that are part of this group. + */ + getLayers(): ol.Collection; + + /** + * Set the collection of layers in this group. + * @param layers Collection of layers that are part of this group. + */ + setLayers(layers: ol.Collection): void; } - class Heatmap { + /** + * Layer for rendering vector data as a heatmap. Note that any property set in the options is set as a ol.Object property on the layer object; for example, setting title: 'My Title' in the options means that title is observable, and has get/set accessors. + */ + class Heatmap extends ol.layer.Vector { + + /** + * @constructor + * @param options Options + */ + constructor(options?: HeatmapOptions); + + /** + * Return the blur size in pixels. + * @returns Blur size in pixels + */ + getBlur(): number; + + /** + * Return the gradient colors as array of strings. + * @returns Colors + */ + getGradient(): Array; + + /** + * Return the size of the radius in pixels. + * @returns Radius size in pixel + */ + getRadius(): number; + + /** + * Set the blur size in pixels. + * @param blur Blur size in pixels + */ + setBlur(blur: number): void; + + /** + * Set the gradient colors as array of strings. + * @param colors Gradient + */ + setGradient(colors: Array): void; + + /** + * Set the size of the radius in pixels. + * @param radius Radius size in pixels + */ + setRadius(radius: number): void; } - class Image { + /** + * Server-rendered images that are available for arbitrary extents and resolutions. Note that any property set in the options is set as a ol.Object property on the layer object; for example, setting title: 'My Title' in the options means that title is observable, and has get/set accessors. + */ + class Image extends ol.layer.Layer { + + /** + * @constructor + * @param options Layer options + */ + constructor(options?: ImageOptions); + + /** + * Return the associated source of the image layer. + * @returns Source. + */ + getSource(): ol.source.Image; } - class Layer { + /** + * Abstract base class; normally only used for creating subclasses and not instantiated in apps. A visual representation of raster or vector map data. Layers group together those properties that pertain to how the data is to be displayed, irrespective of the source of that data. + */ + class Layer extends ol.layer.Base { + + /** + * @constructor + * @param options Layer options + */ + constructor(options?: LayerOptions); + + /** + * Get the layer source. + * @returns The layer source (or null if not yet set) + */ + getSource(): ol.source.Source; + + /** + * Set the layer source. + * @param source The layer source. + */ + setSource(source: ol.source.Source): void; + } + + /** + * For layer sources that provide pre-rendered, tiled images in grids that are organized by zoom levels for specific resolutions. Note that any property set in the options is set as a ol.Object property on the layer object; for example, setting title: 'My Title' in the options means that title is observable, and has get/set accessors. + */ + class Tile extends ol.layer.Layer { + + /** + * @constructor + * @param options Tile layer options. + */ + constructor(options?: TileOptions); + + /** + * Return the level as number to which we will preload tiles up to. + * @retruns The level to preload tiled up to. + */ + getPreload(): number; + + /** + * Return the associated tilesource of the layer. + * @returns Source + */ + getSource(): ol.source.Tile; + + /** + * Whether we use interim tiles on error. + * @returns Use interim tiles on error. + */ + getUseInterimTilesOnError(): boolean; + + /** + * Set the level as number to which we will preload tiles up to. + * @param preload The level to preload tiled up to + */ + setPreload(preload: number): void; + + /** + * Set whether we use interim tiles on error. + * @param useInterimTilesOnError Use interim tiles on error. + */ + setUseInterimTilesOnError(useInterimTilesOnError: boolean): void; } - class Tile { - constructor(options: any); + /** + * Vector data that is rendered client-side. Note that any property set in the options is set as a ol.Object property on the layer object; for example, setting title: 'My Title' in the options means that title is observable, and has get/set accessors. + */ + class Vector extends ol.layer.Layer { + + /** + * @constructor + * @param options Options + */ + constructor(options?: VectorOptions); + + /** + * Return the associated vectorsource of the layer. + * @returns Source. + */ + getSource(): ol.source.Vector; + + /** + * Get the style for features. This returns whatever was passed to the style option at construction or to the setStyle method. + */ + // TODO: Replace returntype any with ol.style.StyleFunction + getStyle(): ol.style.Style | Array | any; + + /** + * Get the style function. + * @returns Layer style function + */ + // TODO: Replace returntype any with ol.style.StyleFunction + getStyleFunction(): any; + + /** + * Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. If it is undefined the default style is used. If it is null the layer has no style (a null style), so only features that have their own styles will be rendered in the layer. See ol.style for information on the default style. + */ + setStyle(); + + /** + * Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. If it is undefined the default style is used. If it is null the layer has no style (a null style), so only features that have their own styles will be rendered in the layer. See ol.style for information on the default style. + * @param layer Layer style + */ + setStyle(style: ol.style.Style); + + /** + * Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. If it is undefined the default style is used. If it is null the layer has no style (a null style), so only features that have their own styles will be rendered in the layer. See ol.style for information on the default style. + * @param layer Layer style + */ + setStyle(style: Array); + + /** + * Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. If it is undefined the default style is used. If it is null the layer has no style (a null style), so only features that have their own styles will be rendered in the layer. See ol.style for information on the default style. + * @param Layer style + */ + // TODO: Replace 'any' with ol.style.StyleFunction + setStyle(style: any); } - class Vector { + interface BaseOptions { + + /** + * Brightness. Default is 0. + */ + brightness?: number; + + /** + * Contrast. Default is 1. + */ + contrast?: number; + + /** + * Hue. Default is 0. + */ + hue?: number; + + /** + * Opacity (0, 1). Default is 1. + */ + opacity?: number; + + /** + * Saturation. Default is 1. + */ + saturation?: number; + + /** + * Visibility. Default is true. + */ + visible?: boolean; + + /** + * The bounding extent for layer rendering. The layer will not be rendered outside of this extent. + */ + extent?: ol.Extent; + + /** + * The minimum resolution (inclusive) at which this layer will be visible. + */ + minResolution?: number; + + /** + * The maximum resolution (exclusive) below which this layer will be visible. + */ + maxResolution?: number; + } + + interface LayerOptions extends BaseOptions { + + /** + * The layer source (or null if not yet set). + */ + source?: ol.source.Source; + } + + interface GroupOptions extends BaseOptions { + + /** + * Child layers + */ + layers?: Array | ol.Collection; + } + + interface TileOptions extends LayerOptions { + + /** + * Preload. Load low-resolution tiles up to preload levels. By default preload is 0, which means no preloading. + */ + preload?: number; + + /** + * Source for this layer. + */ + source?: ol.source.Tile; + + /** + * Use interim tiles on error. Default is true. + */ + useInterimTilesOnError?: boolean; + } + + interface ImageOptions extends LayerOptions { + } + + interface VectorOptions extends LayerOptions { + + /** + * When set to true, feature batches will be recreated during animations. This means that no vectors will be shown clipped, but the setting will have a performance impact for large amounts of vector data. When set to false, batches will be recreated when no animation is active. Default is false. + */ + updateWhileAnimating?: boolean; + + /** + * When set to true, feature batches will be recreated during interactions. See also updateWhileInteracting. Default is false. + */ + updateWhileInteracting?: boolean; + + /** + * Render order. Function to be used when sorting features before rendering. By default features are drawn in the order that they are created. Use null to avoid the sort, but get an undefined draw order. + */ + // TODO: replace any with the expected function, unclear in documentation what the parameters are + renderOrder?: any; + + /** + * The buffer around the viewport extent used by the renderer when getting features from the vector source for the rendering or hit-detection. Recommended value: the size of the largest symbol, line width or label. Default is 100 pixels. + */ + renderBuffer?: number; + + /** + * Source. + */ + source?: ol.source.Vector; + + /** + * Layer style. See ol.style for default style which will be used if this is not defined. + */ + style?: ol.style.Style | Array | any; + } + + interface HeatmapOptions extends VectorOptions { + + /** + * The color gradient of the heatmap, specified as an array of CSS color strings. Default is ['#00f', '#0ff', '#0f0', '#ff0', '#f00']. + */ + gradient?: Array; + + /** + * Radius size in pixels. Default is 8. + */ + radius?: number; + + /** + * Blur size in pixels. Default is 15. + */ + blur?: number; + + /** + * Shadow size in pixels. Default is 250. + */ + shadow?: number; } } From 0673d97c2eb0956ed5fe833fdd3d99f91fb09284 Mon Sep 17 00:00:00 2001 From: woutergd Date: Thu, 25 Jun 2015 18:19:40 +0200 Subject: [PATCH 050/274] Resolve build errors --- openlayers3/openlayers3.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlayers3/openlayers3.d.ts b/openlayers3/openlayers3.d.ts index 9f06166dab..28050055d7 100644 --- a/openlayers3/openlayers3.d.ts +++ b/openlayers3/openlayers3.d.ts @@ -2152,26 +2152,26 @@ declare module ol { /** * Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. If it is undefined the default style is used. If it is null the layer has no style (a null style), so only features that have their own styles will be rendered in the layer. See ol.style for information on the default style. */ - setStyle(); + setStyle(): void; /** * Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. If it is undefined the default style is used. If it is null the layer has no style (a null style), so only features that have their own styles will be rendered in the layer. See ol.style for information on the default style. * @param layer Layer style */ - setStyle(style: ol.style.Style); + setStyle(style: ol.style.Style): void; /** * Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. If it is undefined the default style is used. If it is null the layer has no style (a null style), so only features that have their own styles will be rendered in the layer. See ol.style for information on the default style. * @param layer Layer style */ - setStyle(style: Array); + setStyle(style: Array): void; /** * Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. If it is undefined the default style is used. If it is null the layer has no style (a null style), so only features that have their own styles will be rendered in the layer. See ol.style for information on the default style. * @param Layer style */ // TODO: Replace 'any' with ol.style.StyleFunction - setStyle(style: any); + setStyle(style: any): void; } interface BaseOptions { From 996fd283e0af7c4b50915c8284fcf5f8f83cc7b3 Mon Sep 17 00:00:00 2001 From: woutergd Date: Thu, 25 Jun 2015 19:00:25 +0200 Subject: [PATCH 051/274] Added ol.tilegrid.* definitions --- openlayers3/openlayers3.d.ts | 228 ++++++++++++++++++++++++++++++++++- 1 file changed, 226 insertions(+), 2 deletions(-) diff --git a/openlayers3/openlayers3.d.ts b/openlayers3/openlayers3.d.ts index 28050055d7..63ef200825 100644 --- a/openlayers3/openlayers3.d.ts +++ b/openlayers3/openlayers3.d.ts @@ -2549,13 +2549,237 @@ declare module ol { module tilegrid { + /** + * Base class for setting the grid pattern for sources accessing tiled-image servers. + */ class TileGrid { + + /** + * @constructor + * @param options Tile grid options + */ + constructor(options?: TileGridOptions); + + /** + * Creates a TileCoord transform function for use with this tile grid. Transforms the internal tile coordinates with bottom-left origin to the tile coordinates used by the ol.TileUrlFunction. The returned function expects an ol.TileCoord as first and an ol.proj.Projection as second argument and returns a transformed ol.TileCoord. + */ + // TODO: Check if this is correct, unclear in documentation + createTileCoordTransform(): any; + + /** + * Get the maximum zoom level for the grid. + * @returns Max zoom + */ + getMaxZoom(): number; + + /** + * Get the minimum zoom level for the grid. + * @returns Min zoom + */ + getMinZoom(): number; + + /** + * Get the origin for the grid at the given zoom level. + * @param z Z + * @returns Origin + */ + getOrigin(z: number): ol.Coordinate; + + /** + * Get the list of resolutions for the tile grid. + * @param z Z + * @returns Resolution + */ + getResolution(z: number): number; + + /** + * Get the list of resolutions for the tile grid. + * @returns Resolutions + */ + getResolutions(): Array; + + /** + * Get the tile coordinate for the given map coordinate and resolution. This method considers that coordinates that intersect tile boundaries should be assigned the higher tile coordinate. + * @param coordinate Coordinate + * @param resolution Resolution + * @param tileCoord Destination ol.TileCoord object. + * @returns Tile coordinate + */ + getTileCoordForCoordAndResolution(coordinate: ol.Coordinate, resolution: number, tileCoord?: ol.TileCoord): ol.TileCoord; + + /** + * Get a tile coordinate given a map coordinate and zoom level. + * @param coordinate Coordinate + * @param z Zoom level + * @param tileCoord Destination ol.TileCoord object + * @returns Tile coordinate + */ + getTileCoordForCoordAndZ(coordinate: ol.Coordinate, z: number, tileCoord?: ol.TileCoord): ol.TileCoord; + + /** + * Get the tile size for a zoom level. The type of the return value matches the tileSize or tileSizes that the tile grid was configured with. To always get an ol.Size, run the result through ol.size.toSize(). + * @param z Z + * @returns Tile size + */ + getTileSize(z: number): number | ol.Size; + } + interface TileGridOptions { + + /** + * Extent for the tile grid. No tiles outside this extent will be requested by ol.source.Tile sources. When no origin or origins are configured, the origin will be set to the bottom-left corner of the extent. When no sizes are configured, they will be calculated from the extent. + */ + extent?: ol.Extent; + + /** + * Minimum zoom. Default is 0. + */ + minZoom?: number; + + /** + * Origin, i.e. the bottom-left corner of the grid. Default is null. + */ + origin?: ol.Coordinate; + + /** + * Origins, i.e. the bottom-left corners of the grid for each zoom level. If given, the array length should match the length of the resolutions array, i.e. each resolution can have a different origin. + */ + origins?: Array; + + /** + * Resolutions. The array index of each resolution needs to match the zoom level. This means that even if a minZoom is configured, the resolutions array will have a length of maxZoom + 1. + */ + resolutions?: Array; + + /** + * Tile size. Default is [256, 256]. + */ + tileSize?: number | ol.Size; + + /** + * Tile sizes. If given, the array length should match the length of the resolutions array, i.e. each resolution can have a different tile size. + */ + tileSizes?: Array; } - class WMTS { + /** + * Set the grid pattern for sources accessing WMTS tiled-image servers. + */ + class WMTS extends TileGrid { + + /** + * @constructor + * @param options WMTS options + */ + constructor(options: WMTSOptions); + + /** + * Create a tile grid from a WMTS capabilities matrix set. + * @param matrixSet An object representing a matrixSet in the capabilities document. + * @param extent An optional extent to restrict the tile ranges the server provides. + * @returns WMTS tilegrid instance + */ + createFromCapabilitiesMatrixSet(matrixSet: any, extent: ol.Extent): ol.tilegrid.WMTS; + + /** + * Get the list of matrix identifiers. + * @returns MatrixIds + */ + getMatrixIds(): Array; + } + interface WMTSOptions { + + /** + * Extent for the tile grid. No tiles outside this extent will be requested by ol.source.WMTS sources. When no origin or origins are configured, the origin will be calculated from the extent. When no sizes are configured, they will be calculated from the extent. + */ + extent?: ol.Extent; + + /** + * Origin, i.e. the top-left corner of the grid. + */ + origin?: ol.Coordinate; + + /** + * Origins, i.e. the top-left corners of the grid for each zoom level. The length of this array needs to match the length of the resolutions array. + */ + origins?: Array; + + /** + * Resolutions. The array index of each resolution needs to match the zoom level. This means that even if a minZoom is configured, the resolutions array will have a length of maxZoom + 1 + */ + resolutions?: Array; + + /** + * matrix IDs. The length of this array needs to match the length of the resolutions array. + */ + matrixIds?: Array; + + /** + * Number of tile rows and columns of the grid for each zoom level. The values here are the TileMatrixWidth and TileMatrixHeight advertised in the GetCapabilities response of the WMTS, and define the grid's extent together with the origin. An extent can be configured in addition, and will further limit the extent for which tile requests are made by sources. + */ + sizes?: Array; + + /** + * Tile size. + */ + tileSize?: number | ol.Size; + + /** + * Tile sizes. The length of this array needs to match the length of the resolutions array. + */ + tileSizes?: Array; + + /** + * Number of tile columns that cover the grid's extent for each zoom level. Only required when used with a source that has wrapX set to true, and only when the grid's origin differs from the one of the projection's extent. The array length has to match the length of the resolutions array, i.e. each resolution will have a matching entry here. + */ + widths?: Array; } - class Zoomify { + /** + * Set the grid pattern for sources accessing Zoomify tiled-image servers. + */ + class Zoomify extends TileGrid { + + /** + * @constructor + * @param options Options + */ + constructor(options?: ZoomifyOptions); + } + interface ZoomifyOptions { + + /** + * Resolutions + */ + resolutions: Array; + } + + /** + * Creates a tile grid with a standard XYZ tiling scheme. + * @param options Tile grid options. + * @returns The grid instance + */ + function createXYZ(options: CreateXYZOptions): ol.tilegrid.TileGrid; + interface CreateXYZOptions { + + /** + * Extent for the tile grid. The origin for an XYZ tile grid is the top-left corner of the extent. The zero level of the grid is defined by the resolution at which one tile fits in the provided extent. If not provided, the extent of the EPSG:3857 projection is used. + */ + extent?: ol.Extent; + + /** + * Maximum zoom. The default is ol.DEFAULT_MAX_ZOOM. This determines the number of levels in the grid set. For example, a maxZoom of 21 means there are 22 levels in the grid set. + */ + maxZoom?: number; + + /** + * Minimum zoom. Default is 0. + */ + minZoom?: number; + + /** + * Tile size in pixels. Default is [256, 256]. + */ + tileSize?: number | ol.Size; } } From 293fa7a6529461ff0d8cc4e15d3f4c055c0ef4be Mon Sep 17 00:00:00 2001 From: woutergd Date: Thu, 25 Jun 2015 19:34:30 +0200 Subject: [PATCH 052/274] Moved all options definition typings into the olx-module as defined in the docs of openlayers --- openlayers3/openlayers3.d.ts | 1316 +++++++++++++++++----------------- 1 file changed, 676 insertions(+), 640 deletions(-) diff --git a/openlayers3/openlayers3.d.ts b/openlayers3/openlayers3.d.ts index 63ef200825..7b3b16c7be 100644 --- a/openlayers3/openlayers3.d.ts +++ b/openlayers3/openlayers3.d.ts @@ -3,6 +3,647 @@ // Definitions by: Wouter Goedhart // Definitions: https://github.com/borisyankov/DefinitelyTyped +declare module olx { + + interface AttributionOptions { + + /** HTML markup for this attribution. */ + html: string; + } + + interface DeviceOrientationOptions { + + /** + * Start tracking. Default is false. + */ + tracking?: boolean; + } + + interface FeatureOverlayOptions { + + /** + * Features + */ + // TODO: implement stylefunction + features?: Array | ol.Collection | any; + + /** + * Map + */ + map: ol.Map; + + /** + * Style + */ + style: ol.style.Style | Array; + } + + interface GeolocationOptions { + + /** + * Start Tracking. Default is false. + */ + tracking?: boolean; + + /** + * Tracking options. See http://www.w3.org/TR/geolocation-API/#position_options_interface. + */ + trackingOptions?: PositionOptions; + + /** + * The projection the position is reported in. + */ + projection?: ol.proj.ProjectionLike; + } + + interface GraticuleOptions { + + /** Reference to an ol.Map object. */ + map?: ol.Map; + + /** The maximum number of meridians and parallels from the center of the map. The default value is 100, which means that at most 200 meridians and 200 parallels will be displayed. The default value is appropriate for conformal projections like Spherical Mercator. If you increase the value more lines will be drawn and the drawing performance will decrease. */ + maxLines?: number; + + /** The stroke style to use for drawing the graticule. If not provided, the lines will be drawn with rgba(0,0,0,0.2), a not fully opaque black. */ + strokeStyle?: ol.style.Stroke; + + /** The target size of the graticule cells, in pixels. Default value is 100 pixels. */ + targetSize?: number; + } + + interface MapOptions { + + /** Controls initially added to the map. If not specified, ol.control.defaults() is used. */ + controls?: any; + + /** The ratio between physical pixels and device-independent pixels (dips) on the device. If undefined then it gets set by using window.devicePixelRatio. */ + pixelRatio?: number; + + /** Interactions that are initially added to the map. If not specified, ol.interaction.defaults() is used. */ + interactions?: any; + + /** The element to listen to keyboard events on. This determines when the KeyboardPan and KeyboardZoom interactions trigger. For example, if this option is set to document the keyboard interactions will always trigger. If this option is not specified, the element the library listens to keyboard events on is the map target (i.e. the user-provided div for the map). If this is not document the target element needs to be focused for key events to be emitted, requiring that the target element has a tabindex attribute. */ + keyboardEventTarget?: any; + + /** Layers. If this is not defined, a map with no layers will be rendered. Note that layers are rendered in the order supplied, so if you want, for example, a vector layer to appear on top of a tile layer, it must come after the tile layer. */ + layers?: Array + + /** When set to true, tiles will be loaded during animations. This may improve the user experience, but can also make animations stutter on devices with slow memory. Default is false. */ + loadTilesWhileAnimating?: boolean; + + /** When set to true, tiles will be loaded while interacting with the map. This may improve the user experience, but can also make map panning and zooming choppy on devices with slow memory. Default is false. */ + loadTilesWhileInteracting?: boolean; + + /** The map logo. A logo to be displayed on the map at all times. If a string is provided, it will be set as the image source of the logo. If an object is provided, the src property should be the URL for an image and the href property should be a URL for creating a link. To disable the map logo, set the option to false. By default, the OpenLayers 3 logo is shown. */ + logo?: any; + + /** Overlays initially added to the map. By default, no overlays are added. */ + overlays?: any; + + /** Renderer. By default, Canvas, DOM and WebGL renderers are tested for support in that order, and the first supported used. Specify a ol.RendererType here to use a specific renderer. Note that at present only the Canvas renderer supports vector data. */ + renderer?: any; + + /** The container for the map, either the element itself or the id of the element. If not specified at construction time, ol.Map#setTarget must be called for the map to be rendered. */ + target?: any; + + /** The map's view. No layer sources will be fetched unless this is specified at construction time or through ol.Map#setView. */ + view?: ViewOptions; + } + + interface OverlayOptions { + + /** + * The overlay element. + */ + element?: Element; + + /** + * Offsets in pixels used when positioning the overlay. The fist element in the array is the horizontal offset. A positive value shifts the overlay right. The second element in the array is the vertical offset. A positive value shifts the overlay down. Default is [0, 0]. + */ + offset?: Array; + + /** + * The overlay position in map projection. + */ + position?: ol.Coordinate; + + /** + * Defines how the overlay is actually positioned with respect to its position property. Possible values are 'bottom-left', 'bottom-center', 'bottom-right', 'center-left', 'center-center', 'center-right', 'top-left', 'top-center', and 'top-right'. Default is 'top-left'. + */ + positioning?: ol.OverlayPositioning; + + /** + * Whether event propagation to the map viewport should be stopped. Default is true. If true the overlay is placed in the same container as that of the controls (CSS class name ol-overlaycontainer-stopevent); if false it is placed in the container with CSS class name ol-overlaycontainer. + */ + stopEvent?: boolean; + + /** + * Whether the overlay is inserted first in the overlay container, or appended. Default is true. If the overlay is placed in the same container as that of the controls (see the stopEvent option) you will probably set insertFirst to true so the overlay is displayed below the controls. + */ + insertFirst?: boolean; + + /** + * If set to true the map is panned when calling setPosition, so that the overlay is entirely visible in the current viewport. The default is false. + */ + autoPan?: boolean; + + /** + * The options used to create a ol.animation.pan animation. This animation is only used when autoPan is enabled. By default the default options for ol.animation.pan are used. If set to null the panning is not animated. + */ + //TODO: replace with olx.animation.PanOptions + autoPanAnimation?: any; + + /** + * The margin (in pixels) between the overlay and the borders of the map when autopanning. The default is 20. + */ + autoPanMargin?: number; + } + + interface ViewOptions { + + /** The initial center for the view. The coordinate system for the center is specified with the projection option. Default is undefined, and layer sources will not be fetched if this is not set. */ + center?: ol.Coordinate; + + /** Rotation constraint. false means no constraint. true means no constraint, but snap to zero near zero. A number constrains the rotation to that number of values. For example, 4 will constrain the rotation to 0, 90, 180, and 270 degrees. The default is true. */ + constrainRotation?: boolean; + + /** Enable rotation. Default is true. If false a rotation constraint that always sets the rotation to zero is used. The constrainRotation option has no effect if enableRotation is false. */ + enableRotation?: boolean; + + /**The extent that constrains the center, in other words, center cannot be set outside this extent. Default is undefined. */ + extent?: ol.Extent; + + /** The maximum resolution used to determine the resolution constraint. It is used together with minResolution (or maxZoom) and zoomFactor. If unspecified it is calculated in such a way that the projection's validity extent fits in a 256x256 px tile. If the projection is Spherical Mercator (the default) then maxResolution defaults to 40075016.68557849 / 256 = 156543.03392804097. */ + maxResolution?: number; + + /** The minimum resolution used to determine the resolution constraint. It is used together with maxResolution (or minZoom) and zoomFactor. If unspecified it is calculated assuming 29 zoom levels (with a factor of 2). If the projection is Spherical Mercator (the default) then minResolution defaults to 40075016.68557849 / 256 / Math.pow(2, 28) = 0.0005831682455839253. */ + minResolution?: number; + + /** The maximum zoom level used to determine the resolution constraint. It is used together with minZoom (or maxResolution) and zoomFactor. Default is 28. Note that if minResolution is also provided, it is given precedence over maxZoom. */ + maxZoom?: number; + + /** The minimum zoom level used to determine the resolution constraint. It is used together with maxZoom (or minResolution) and zoomFactor. Default is 0. Note that if maxResolution is also provided, it is given precedence over minZoom. */ + minZoom?: number; + + /** The projection. Default is EPSG:3857 (Spherical Mercator). */ + projection?: ol.proj.ProjectionLike; + + /** The initial resolution for the view. The units are projection units per pixel (e.g. meters per pixel). An alternative to setting this is to set zoom. Default is undefined, and layer sources will not be fetched if neither this nor zoom are defined. */ + resolution?: number; + + /** Resolutions to determine the resolution constraint. If set the maxResolution, minResolution, minZoom, maxZoom, and zoomFactor options are ignored. */ + resolutions?: Array; + + /** The initial rotation for the view in radians (positive rotation clockwise). Default is 0. */ + rotation?: number; + + /** Only used if resolution is not defined. Zoom level used to calculate the initial resolution for the view. The initial resolution is determined using the ol.View#constrainResolution method. */ + zoom?: number; + + /** The zoom factor used to determine the resolution constraint. Default is 2. */ + zoomFactor?: number; + } + + module animation { + + interface BounceOptions { + + /** + * The resolution to start the bounce from, typically map.getView().getResolution(). + */ + resolution: number; + + /** + * The start time of the animation. Default is immediately. + */ + start?: number; + + /** + * The duration of the animation in milliseconds. Default is 1000. + */ + duration?: number; + + /** + * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. + */ + // TODO: Check if it is an ol.easing function + easing: () => void; + } + + interface PanOptions { + + /** + * The resolution to start the bounce from, typically map.getView().getResolution(). + */ + source: ol.Coordinate; + + /** + * The start time of the animation. Default is immediately. + */ + start?: number; + + /** + * The duration of the animation in milliseconds. Default is 1000. + */ + duration?: number; + + /** + * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. + */ + // TODO: Check if it is an ol.easing function + easing: () => void; + } + + interface RotateOptions { + + /** + * The rotation value (in radians) to begin rotating from, typically map.getView().getRotation(). If undefined then 0 is assumed. + */ + rotation?: number; + + /** + * The rotation center/anchor. The map rotates around the center of the view if unspecified. + */ + anchor?: ol.Coordinate; + + /** + * The start time of the animation. Default is immediately. + */ + start?: number; + + /** + * The duration of the animation in milliseconds. Default is 1000. + */ + duration?: number; + + /** + * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. + */ + // TODO: Check if it is an ol.easing function + easing: () => void; + } + + interface ZoomOptions { + + /** + * The resolution to begin zooming from, typically map.getView().getResolution(). + */ + resolution: number; + + /** + * The start time of the animation. Default is immediately. + */ + start?: number; + + /** + * The duration of the animation in milliseconds. Default is 1000. + */ + duration?: number; + + /** + * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. + */ + // TODO: Check if it is an ol.easing function + easing: () => void; + } + } + + module control { + + interface DefaultsOptions { + + /** + * Attribution. Default is true. + */ + attribution?: boolean; + + /** + * Attribution options. + */ + //TODO: Replace with olx.control.AttributionOptions + attributionOptions?: any; + + /** + * Rotate. Default is true; + */ + rotate?: boolean; + + /** + * Rotate options + */ + //TODO: Replace with olx.control.RotateOptions + rotateOptions?: any; + + /** + * Zoom. Default is true + */ + zoom?: boolean; + + /** + * + */ + //TODO: Replace with olx.control.ZoomOptions + zoomOptions?: any; + } + } + + module layer { + + interface BaseOptions { + + /** + * Brightness. Default is 0. + */ + brightness?: number; + + /** + * Contrast. Default is 1. + */ + contrast?: number; + + /** + * Hue. Default is 0. + */ + hue?: number; + + /** + * Opacity (0, 1). Default is 1. + */ + opacity?: number; + + /** + * Saturation. Default is 1. + */ + saturation?: number; + + /** + * Visibility. Default is true. + */ + visible?: boolean; + + /** + * The bounding extent for layer rendering. The layer will not be rendered outside of this extent. + */ + extent?: ol.Extent; + + /** + * The minimum resolution (inclusive) at which this layer will be visible. + */ + minResolution?: number; + + /** + * The maximum resolution (exclusive) below which this layer will be visible. + */ + maxResolution?: number; + } + + interface GroupOptions extends BaseOptions { + + /** + * Child layers + */ + layers?: Array | ol.Collection; + } + + interface HeatmapOptions extends VectorOptions { + + /** + * The color gradient of the heatmap, specified as an array of CSS color strings. Default is ['#00f', '#0ff', '#0f0', '#ff0', '#f00']. + */ + gradient?: Array; + + /** + * Radius size in pixels. Default is 8. + */ + radius?: number; + + /** + * Blur size in pixels. Default is 15. + */ + blur?: number; + + /** + * Shadow size in pixels. Default is 250. + */ + shadow?: number; + } + + interface ImageOptions extends LayerOptions { + } + + interface LayerOptions extends BaseOptions { + + /** + * The layer source (or null if not yet set). + */ + source?: ol.source.Source; + } + + interface TileOptions extends LayerOptions { + + /** + * Preload. Load low-resolution tiles up to preload levels. By default preload is 0, which means no preloading. + */ + preload?: number; + + /** + * Source for this layer. + */ + source?: ol.source.Tile; + + /** + * Use interim tiles on error. Default is true. + */ + useInterimTilesOnError?: boolean; + } + + interface VectorOptions extends LayerOptions { + + /** + * When set to true, feature batches will be recreated during animations. This means that no vectors will be shown clipped, but the setting will have a performance impact for large amounts of vector data. When set to false, batches will be recreated when no animation is active. Default is false. + */ + updateWhileAnimating?: boolean; + + /** + * When set to true, feature batches will be recreated during interactions. See also updateWhileInteracting. Default is false. + */ + updateWhileInteracting?: boolean; + + /** + * Render order. Function to be used when sorting features before rendering. By default features are drawn in the order that they are created. Use null to avoid the sort, but get an undefined draw order. + */ + // TODO: replace any with the expected function, unclear in documentation what the parameters are + renderOrder?: any; + + /** + * The buffer around the viewport extent used by the renderer when getting features from the vector source for the rendering or hit-detection. Recommended value: the size of the largest symbol, line width or label. Default is 100 pixels. + */ + renderBuffer?: number; + + /** + * Source. + */ + source?: ol.source.Vector; + + /** + * Layer style. See ol.style for default style which will be used if this is not defined. + */ + style?: ol.style.Style | Array | any; + } + } + + module tilegrid { + + interface TileGridOptions { + + /** + * Extent for the tile grid. No tiles outside this extent will be requested by ol.source.Tile sources. When no origin or origins are configured, the origin will be set to the bottom-left corner of the extent. When no sizes are configured, they will be calculated from the extent. + */ + extent?: ol.Extent; + + /** + * Minimum zoom. Default is 0. + */ + minZoom?: number; + + /** + * Origin, i.e. the bottom-left corner of the grid. Default is null. + */ + origin?: ol.Coordinate; + + /** + * Origins, i.e. the bottom-left corners of the grid for each zoom level. If given, the array length should match the length of the resolutions array, i.e. each resolution can have a different origin. + */ + origins?: Array; + + /** + * Resolutions. The array index of each resolution needs to match the zoom level. This means that even if a minZoom is configured, the resolutions array will have a length of maxZoom + 1. + */ + resolutions?: Array; + + /** + * Tile size. Default is [256, 256]. + */ + tileSize?: number | ol.Size; + + /** + * Tile sizes. If given, the array length should match the length of the resolutions array, i.e. each resolution can have a different tile size. + */ + tileSizes?: Array; + } + + interface WMTSOptions { + + /** + * Extent for the tile grid. No tiles outside this extent will be requested by ol.source.WMTS sources. When no origin or origins are configured, the origin will be calculated from the extent. When no sizes are configured, they will be calculated from the extent. + */ + extent?: ol.Extent; + + /** + * Origin, i.e. the top-left corner of the grid. + */ + origin?: ol.Coordinate; + + /** + * Origins, i.e. the top-left corners of the grid for each zoom level. The length of this array needs to match the length of the resolutions array. + */ + origins?: Array; + + /** + * Resolutions. The array index of each resolution needs to match the zoom level. This means that even if a minZoom is configured, the resolutions array will have a length of maxZoom + 1 + */ + resolutions?: Array; + + /** + * matrix IDs. The length of this array needs to match the length of the resolutions array. + */ + matrixIds?: Array; + + /** + * Number of tile rows and columns of the grid for each zoom level. The values here are the TileMatrixWidth and TileMatrixHeight advertised in the GetCapabilities response of the WMTS, and define the grid's extent together with the origin. An extent can be configured in addition, and will further limit the extent for which tile requests are made by sources. + */ + sizes?: Array; + + /** + * Tile size. + */ + tileSize?: number | ol.Size; + + /** + * Tile sizes. The length of this array needs to match the length of the resolutions array. + */ + tileSizes?: Array; + + /** + * Number of tile columns that cover the grid's extent for each zoom level. Only required when used with a source that has wrapX set to true, and only when the grid's origin differs from the one of the projection's extent. The array length has to match the length of the resolutions array, i.e. each resolution will have a matching entry here. + */ + widths?: Array; + } + + interface XYZOptions { + + /** + * Extent for the tile grid. The origin for an XYZ tile grid is the top-left corner of the extent. The zero level of the grid is defined by the resolution at which one tile fits in the provided extent. If not provided, the extent of the EPSG:3857 projection is used. + */ + extent?: ol.Extent; + + /** + * Maximum zoom. The default is ol.DEFAULT_MAX_ZOOM. This determines the number of levels in the grid set. For example, a maxZoom of 21 means there are 22 levels in the grid set. + */ + maxZoom?: number; + + /** + * Minimum zoom. Default is 0. + */ + minZoom?: number; + + /** + * Tile size in pixels. Default is [256, 256]. + */ + tileSize?: number | ol.Size; + } + + interface ZoomifyOptions { + + /** + * Resolutions + */ + resolutions: Array; + } + } + + module view { + + interface FitGeometryOptions { + + /** + * Padding (in pixels) to be cleared inside the view. Values in the array are top, right, bottom and left padding. Default is [0, 0, 0, 0]. + */ + padding?: Array; + + /** + * Constrain the resolution. Default is true. + */ + constrainResolution?: boolean; + + /** + * Get the nearest extent. Default is false. + */ + nearest?: boolean; + + /** + * Minimum resolution that we zoom to. Default is 0. + */ + minResolution?: number; + + /** + * Maximum zoom level that we zoom to. If minResolution is given, this property is ignored. + */ + maxZoom?: number; + } + } +} + /** * A high-performance, feature-packed library for all your mapping needs. */ @@ -16,7 +657,7 @@ declare module ol { * @constructor * @param options Attribution options. */ - constructor(options: AttributionOptions); + constructor(options: olx.AttributionOptions); /** * Get the attribution markup. @@ -24,12 +665,7 @@ declare module ol { */ getHTML(): string; } - interface AttributionOptions { - - /** HTML markup for this attribution. */ - html: string; - } - + /** * An expanded version of standard JS Array, adding convenience methods for manipulation. Add and remove changes to the Collection trigger a Collection event. Note that this does not cover changes to the objects within the Collection; they trigger events on the appropriate object, not on the Collection as a whole. */ @@ -141,7 +777,7 @@ declare module ol { * @constructor * @param options Options. */ - constructor(options: DeviceOrientationOptions); + constructor(options?: olx.DeviceOrientationOptions); /** * Rotation around the device z-axis (in radians). @@ -179,14 +815,7 @@ declare module ol { */ setTracking(tracking: boolean): void; } - interface DeviceOrientationOptions { - - /** - * Start tracking. Default is false. - */ - tracking?: boolean; - } - + /** * Events emitted by ol.interaction.DragBox instances are instances of this type. */ @@ -284,7 +913,7 @@ declare module ol { * @constructor * @param options Options. */ - constructor(options: FeatureOverlayOptions); + constructor(options?: olx.FeatureOverlayOptions); /** * Add a feature to the overlay. @@ -344,24 +973,6 @@ declare module ol { setStyle(style: Array): void; setStyle(style: any): void; } - interface FeatureOverlayOptions { - - /** - * Features - */ - // TODO: implement stylefunction - features?: Array | Collection | any; - - /** - * Map - */ - map: Map; - - /** - * Style - */ - style: style.Style | Array; - } /** * Helper class for providing HTML5 Geolocation capabilities. The Geolocation API is used to locate a user's position. @@ -372,7 +983,7 @@ declare module ol { * @constructor * @param options Options. */ - constructor(options: GeolocationOptions); + constructor(options?: olx.GeolocationOptions); /** * Get the accuracy of the position in meters. @@ -452,23 +1063,6 @@ declare module ol { */ setTrackingOptions(options: PositionOptions): void; } - interface GeolocationOptions { - - /** - * Start Tracking. Default is false. - */ - tracking?: boolean; - - /** - * Tracking options. See http://www.w3.org/TR/geolocation-API/#position_options_interface. - */ - trackingOptions?: PositionOptions; - - /** - * The projection the position is reported in. - */ - projection?: ol.proj.ProjectionLike; - } /** * Render a grid for a coordinate system on a map. @@ -478,7 +1072,7 @@ declare module ol { * @constructor * @param options Options. */ - constructor(options: GraticuleOptions); + constructor(options?: olx.GraticuleOptions); /** * Get the map associated with this graticule. @@ -504,21 +1098,7 @@ declare module ol { */ setMap(map: Map): void; } - interface GraticuleOptions { - - /** Reference to an ol.Map object. */ - map?: Map; - - /** The maximum number of meridians and parallels from the center of the map. The default value is 100, which means that at most 200 meridians and 200 parallels will be displayed. The default value is appropriate for conformal projections like Spherical Mercator. If you increase the value more lines will be drawn and the drawing performance will decrease. */ - maxLines?: number; - - /** The stroke style to use for drawing the graticule. If not provided, the lines will be drawn with rgba(0,0,0,0.2), a not fully opaque black. */ - strokeStyle?: style.Stroke; - - /** The target size of the graticule cells, in pixels. Default value is 100 pixels. */ - targetSize?: number; - } - + /** * */ @@ -574,7 +1154,7 @@ declare module ol { * @constructor * @params options Options. */ - constructor(options: MapOptions); + constructor(options: olx.MapOptions); /** * Add the given control to the map. @@ -794,45 +1374,7 @@ declare module ol { * */ updateSize(): void; } - interface MapOptions { - - /** Controls initially added to the map. If not specified, ol.control.defaults() is used. */ - controls?: any; - - /** The ratio between physical pixels and device-independent pixels (dips) on the device. If undefined then it gets set by using window.devicePixelRatio. */ - pixelRatio?: number; - - /** Interactions that are initially added to the map. If not specified, ol.interaction.defaults() is used. */ - interactions?: any; - - /** The element to listen to keyboard events on. This determines when the KeyboardPan and KeyboardZoom interactions trigger. For example, if this option is set to document the keyboard interactions will always trigger. If this option is not specified, the element the library listens to keyboard events on is the map target (i.e. the user-provided div for the map). If this is not document the target element needs to be focused for key events to be emitted, requiring that the target element has a tabindex attribute. */ - keyboardEventTarget?: any; - - /** Layers. If this is not defined, a map with no layers will be rendered. Note that layers are rendered in the order supplied, so if you want, for example, a vector layer to appear on top of a tile layer, it must come after the tile layer. */ - layers?: Array - - /** When set to true, tiles will be loaded during animations. This may improve the user experience, but can also make animations stutter on devices with slow memory. Default is false. */ - loadTilesWhileAnimating?: boolean; - - /** When set to true, tiles will be loaded while interacting with the map. This may improve the user experience, but can also make map panning and zooming choppy on devices with slow memory. Default is false. */ - loadTilesWhileInteracting?: boolean; - - /** The map logo. A logo to be displayed on the map at all times. If a string is provided, it will be set as the image source of the logo. If an object is provided, the src property should be the URL for an image and the href property should be a URL for creating a link. To disable the map logo, set the option to false. By default, the OpenLayers 3 logo is shown. */ - logo?: any; - - /** Overlays initially added to the map. By default, no overlays are added. */ - overlays?: any; - - /** Renderer. By default, Canvas, DOM and WebGL renderers are tested for support in that order, and the first supported used. Specify a ol.RendererType here to use a specific renderer. Note that at present only the Canvas renderer supports vector data. */ - renderer?: any; - - /** The container for the map, either the element itself or the id of the element. If not specified at construction time, ol.Map#setTarget must be called for the map to be rendered. */ - target?: any; - - /** The map's view. No layer sources will be fetched unless this is specified at construction time or through ol.Map#setView. */ - view?: ViewOptions; - } - + /** * Events emitted as map browser events are instances of this type. See ol.Map for which events trigger a map browser event. */ @@ -1051,7 +1593,7 @@ declare module ol { * @constructor * @param options Overlay options. */ - constructor(options: OverlayOptions); + constructor(options: olx.OverlayOptions); /** * Get the DOM element of this overlay. @@ -1113,55 +1655,7 @@ declare module ol { */ setPositioning(positioning: ol.OverlayPositioning): void; } - interface OverlayOptions { - - /** - * The overlay element. - */ - element?: Element; - - /** - * Offsets in pixels used when positioning the overlay. The fist element in the array is the horizontal offset. A positive value shifts the overlay right. The second element in the array is the vertical offset. A positive value shifts the overlay down. Default is [0, 0]. - */ - offset?: Array; - - /** - * The overlay position in map projection. - */ - position?: ol.Coordinate; - - /** - * Defines how the overlay is actually positioned with respect to its position property. Possible values are 'bottom-left', 'bottom-center', 'bottom-right', 'center-left', 'center-center', 'center-right', 'top-left', 'top-center', and 'top-right'. Default is 'top-left'. - */ - positioning?: ol.OverlayPositioning; - - /** - * Whether event propagation to the map viewport should be stopped. Default is true. If true the overlay is placed in the same container as that of the controls (CSS class name ol-overlaycontainer-stopevent); if false it is placed in the container with CSS class name ol-overlaycontainer. - */ - stopEvent?: boolean; - - /** - * Whether the overlay is inserted first in the overlay container, or appended. Default is true. If the overlay is placed in the same container as that of the controls (see the stopEvent option) you will probably set insertFirst to true so the overlay is displayed below the controls. - */ - insertFirst?: boolean; - - /** - * If set to true the map is panned when calling setPosition, so that the overlay is entirely visible in the current viewport. The default is false. - */ - autoPan?: boolean; - - /** - * The options used to create a ol.animation.pan animation. This animation is only used when autoPan is enabled. By default the default options for ol.animation.pan are used. If set to null the panning is not animated. - */ - //TODO: replace with olx.animation.PanOptions - autoPanAnimation?: any; - - /** - * The margin (in pixels) between the overlay and the borders of the map when autopanning. The default is 20. - */ - autoPanMargin?: number; - } - + /** * Events emitted by ol.interaction.Select instances are instances of this type. */ @@ -1231,7 +1725,7 @@ declare module ol { * @constructor * @param options Options. */ - constructor(options: ViewOptions); + constructor(options?: olx.ViewOptions); /** * Calculate the extent for the current view state and the passed size. The size is the pixel dimensions of the box into which the calculated extent should fit. In most cases you want to get the extent of the entire map, that is map.getSize(). @@ -1277,7 +1771,7 @@ declare module ol { * @param size Box pixel size. * @param options Options */ - fitGeometry(geometry: ol.geom.SimpleGeometry, size: ol.Size, options?: ViewFitGeometryOptions): void; + fitGeometry(geometry: ol.geom.SimpleGeometry, size: ol.Size, options?: olx.view.FitGeometryOptions): void; /** * Get the view center. @@ -1340,78 +1834,7 @@ declare module ol { */ setZoom(zoom: number): void; } - interface ViewOptions { - - /** The initial center for the view. The coordinate system for the center is specified with the projection option. Default is undefined, and layer sources will not be fetched if this is not set. */ - center?: Coordinate; - - /** Rotation constraint. false means no constraint. true means no constraint, but snap to zero near zero. A number constrains the rotation to that number of values. For example, 4 will constrain the rotation to 0, 90, 180, and 270 degrees. The default is true. */ - constrainRotation?: boolean; - - /** Enable rotation. Default is true. If false a rotation constraint that always sets the rotation to zero is used. The constrainRotation option has no effect if enableRotation is false. */ - enableRotation?: boolean; - - /**The extent that constrains the center, in other words, center cannot be set outside this extent. Default is undefined. */ - extent?: Extent; - - /** The maximum resolution used to determine the resolution constraint. It is used together with minResolution (or maxZoom) and zoomFactor. If unspecified it is calculated in such a way that the projection's validity extent fits in a 256x256 px tile. If the projection is Spherical Mercator (the default) then maxResolution defaults to 40075016.68557849 / 256 = 156543.03392804097. */ - maxResolution?: number; - - /** The minimum resolution used to determine the resolution constraint. It is used together with maxResolution (or minZoom) and zoomFactor. If unspecified it is calculated assuming 29 zoom levels (with a factor of 2). If the projection is Spherical Mercator (the default) then minResolution defaults to 40075016.68557849 / 256 / Math.pow(2, 28) = 0.0005831682455839253. */ - minResolution?: number; - - /** The maximum zoom level used to determine the resolution constraint. It is used together with minZoom (or maxResolution) and zoomFactor. Default is 28. Note that if minResolution is also provided, it is given precedence over maxZoom. */ - maxZoom?: number; - - /** The minimum zoom level used to determine the resolution constraint. It is used together with maxZoom (or minResolution) and zoomFactor. Default is 0. Note that if maxResolution is also provided, it is given precedence over minZoom. */ - minZoom?: number; - - /** The projection. Default is EPSG:3857 (Spherical Mercator). */ - projection?: any; - - /** The initial resolution for the view. The units are projection units per pixel (e.g. meters per pixel). An alternative to setting this is to set zoom. Default is undefined, and layer sources will not be fetched if neither this nor zoom are defined. */ - resolution?: number; - - /** Resolutions to determine the resolution constraint. If set the maxResolution, minResolution, minZoom, maxZoom, and zoomFactor options are ignored. */ - resolutions?: Array; - - /** The initial rotation for the view in radians (positive rotation clockwise). Default is 0. */ - rotation?: number; - - /** Only used if resolution is not defined. Zoom level used to calculate the initial resolution for the view. The initial resolution is determined using the ol.View#constrainResolution method. */ - zoom?: number; - - /** The zoom factor used to determine the resolution constraint. Default is 2. */ - zoomFactor?: number; - } - interface ViewFitGeometryOptions { - - /** - * Padding (in pixels) to be cleared inside the view. Values in the array are top, right, bottom and left padding. Default is [0, 0, 0, 0]. - */ - padding?: Array; - - /** - * Constrain the resolution. Default is true. - */ - constrainResolution?: boolean; - - /** - * Get the nearest extent. Default is false. - */ - nearest?: boolean; - - /** - * Minimum resolution that we zoom to. Default is 0. - */ - minResolution?: number; - - /** - * Maximum zoom level that we zoom to. If minResolution is given, this property is ignored. - */ - maxZoom?: number; - } - + // NAMESPACES /** @@ -1424,124 +1847,27 @@ declare module ol { * @param options Bounce options. */ //TODO: return ol.PreRenderFunction - function bounce(options: AnimationBounceOptions): any; - interface AnimationBounceOptions { - - /** - * The resolution to start the bounce from, typically map.getView().getResolution(). - */ - resolution: number; - - /** - * The start time of the animation. Default is immediately. - */ - start?: number; - - /** - * The duration of the animation in milliseconds. Default is 1000. - */ - duration?: number; - - /** - * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. - */ - // TODO: Check if it is an ol.easing function - easing: () => void; - } - + function bounce(options: olx.animation.BounceOptions): any; + /** * Generate an animated transition while updating the view center. * @param options Pan options. */ //TODO: return ol.PreRenderFunction - function pan(options: AnimationPanOptions): any; - interface AnimationPanOptions { - - /** - * The resolution to start the bounce from, typically map.getView().getResolution(). - */ - source: ol.Coordinate; - - /** - * The start time of the animation. Default is immediately. - */ - start?: number; - - /** - * The duration of the animation in milliseconds. Default is 1000. - */ - duration?: number; - - /** - * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. - */ - // TODO: Check if it is an ol.easing function - easing: () => void; - } + function pan(options: olx.animation.PanOptions): any; /** * Generate an animated transition while updating the view rotation. * @param options Rotate options. */ //TODO: return ol.PreRenderFunction - function rotate(options: AnimationRotateOptions): any; - interface AnimationRotateOptions { - - /** - * The rotation value (in radians) to begin rotating from, typically map.getView().getRotation(). If undefined then 0 is assumed. - */ - rotation?: number; - - /** - * The rotation center/anchor. The map rotates around the center of the view if unspecified. - */ - anchor?: ol.Coordinate; - - /** - * The start time of the animation. Default is immediately. - */ - start?: number; - - /** - * The duration of the animation in milliseconds. Default is 1000. - */ - duration?: number; - - /** - * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. - */ - // TODO: Check if it is an ol.easing function - easing: () => void; - } + function rotate(options: olx.animation.RotateOptions): any; /** * Generate an animated transition while updating the view resolution. * @param options Zoom options. */ - function pan(options: AnimationZoomOptions): any; - interface AnimationZoomOptions { - - /** - * The resolution to begin zooming from, typically map.getView().getResolution(). - */ - resolution: number; - - /** - * The start time of the animation. Default is immediately. - */ - start?: number; - - /** - * The duration of the animation in milliseconds. Default is 1000. - */ - duration?: number; - - /** - * The easing function to use. Can be an ol.easing or a custom function. Default is ol.easing.upAndDown. - */ - // TODO: Check if it is an ol.easing function - easing: () => void; - } + function pan(options: olx.animation.PanOptions): any; } /** @@ -1571,43 +1897,8 @@ declare module ol { * @param options Defaults options * @returns Control.s */ - function defaults(opt_options: ControlDefaultsOptions): ol.Collection; - interface ControlDefaultsOptions { - - /** - * Attribution. Default is true. - */ - attribution?: boolean; - - /** - * Attribution options. - */ - //TODO: Replace with olx.control.AttributionOptions - attributionOptions?: any; - - /** - * Rotate. Default is true; - */ - rotate?: boolean; - - /** - * Rotate options - */ - //TODO: Replace with olx.control.RotateOptions - rotateOptions?: any; - - /** - * Zoom. Default is true - */ - zoom?: boolean; - - /** - * - */ - //TODO: Replace with olx.control.ZoomOptions - zoomOptions?: any; - } - + function defaults(options?: olx.control.DefaultsOptions): ol.Collection; + /** * Units for the scale line. Supported values are 'degrees', 'imperial', 'nautical', 'metric', 'us'. */ @@ -1852,7 +2143,7 @@ declare module ol { * @constructor * @param options Layer options. */ - constructor(options?: BaseOptions); + constructor(options?: olx.layer.BaseOptions); /** * Return the brightness of the layer. @@ -1972,7 +2263,7 @@ declare module ol { * @constructor * @param options Layer options. */ - constructor(options?: GroupOptions); + constructor(options?: olx.layer.GroupOptions); /** * Returns the collection of layers in this group. @@ -1996,7 +2287,7 @@ declare module ol { * @constructor * @param options Options */ - constructor(options?: HeatmapOptions); + constructor(options?: olx.layer.HeatmapOptions); /** * Return the blur size in pixels. @@ -2044,7 +2335,7 @@ declare module ol { * @constructor * @param options Layer options */ - constructor(options?: ImageOptions); + constructor(options?: olx.layer.ImageOptions); /** * Return the associated source of the image layer. @@ -2062,7 +2353,7 @@ declare module ol { * @constructor * @param options Layer options */ - constructor(options?: LayerOptions); + constructor(options?: olx.layer.LayerOptions); /** * Get the layer source. @@ -2086,7 +2377,7 @@ declare module ol { * @constructor * @param options Tile layer options. */ - constructor(options?: TileOptions); + constructor(options?: olx.layer.TileOptions); /** * Return the level as number to which we will preload tiles up to. @@ -2128,7 +2419,7 @@ declare module ol { * @constructor * @param options Options */ - constructor(options?: VectorOptions); + constructor(options?: olx.layer.VectorOptions); /** * Return the associated vectorsource of the layer. @@ -2173,148 +2464,6 @@ declare module ol { // TODO: Replace 'any' with ol.style.StyleFunction setStyle(style: any): void; } - - interface BaseOptions { - - /** - * Brightness. Default is 0. - */ - brightness?: number; - - /** - * Contrast. Default is 1. - */ - contrast?: number; - - /** - * Hue. Default is 0. - */ - hue?: number; - - /** - * Opacity (0, 1). Default is 1. - */ - opacity?: number; - - /** - * Saturation. Default is 1. - */ - saturation?: number; - - /** - * Visibility. Default is true. - */ - visible?: boolean; - - /** - * The bounding extent for layer rendering. The layer will not be rendered outside of this extent. - */ - extent?: ol.Extent; - - /** - * The minimum resolution (inclusive) at which this layer will be visible. - */ - minResolution?: number; - - /** - * The maximum resolution (exclusive) below which this layer will be visible. - */ - maxResolution?: number; - } - - interface LayerOptions extends BaseOptions { - - /** - * The layer source (or null if not yet set). - */ - source?: ol.source.Source; - } - - interface GroupOptions extends BaseOptions { - - /** - * Child layers - */ - layers?: Array | ol.Collection; - } - - interface TileOptions extends LayerOptions { - - /** - * Preload. Load low-resolution tiles up to preload levels. By default preload is 0, which means no preloading. - */ - preload?: number; - - /** - * Source for this layer. - */ - source?: ol.source.Tile; - - /** - * Use interim tiles on error. Default is true. - */ - useInterimTilesOnError?: boolean; - } - - interface ImageOptions extends LayerOptions { - } - - interface VectorOptions extends LayerOptions { - - /** - * When set to true, feature batches will be recreated during animations. This means that no vectors will be shown clipped, but the setting will have a performance impact for large amounts of vector data. When set to false, batches will be recreated when no animation is active. Default is false. - */ - updateWhileAnimating?: boolean; - - /** - * When set to true, feature batches will be recreated during interactions. See also updateWhileInteracting. Default is false. - */ - updateWhileInteracting?: boolean; - - /** - * Render order. Function to be used when sorting features before rendering. By default features are drawn in the order that they are created. Use null to avoid the sort, but get an undefined draw order. - */ - // TODO: replace any with the expected function, unclear in documentation what the parameters are - renderOrder?: any; - - /** - * The buffer around the viewport extent used by the renderer when getting features from the vector source for the rendering or hit-detection. Recommended value: the size of the largest symbol, line width or label. Default is 100 pixels. - */ - renderBuffer?: number; - - /** - * Source. - */ - source?: ol.source.Vector; - - /** - * Layer style. See ol.style for default style which will be used if this is not defined. - */ - style?: ol.style.Style | Array | any; - } - - interface HeatmapOptions extends VectorOptions { - - /** - * The color gradient of the heatmap, specified as an array of CSS color strings. Default is ['#00f', '#0ff', '#0f0', '#ff0', '#f00']. - */ - gradient?: Array; - - /** - * Radius size in pixels. Default is 8. - */ - radius?: number; - - /** - * Blur size in pixels. Default is 15. - */ - blur?: number; - - /** - * Shadow size in pixels. Default is 250. - */ - shadow?: number; - } } module loadingstrategy { @@ -2558,7 +2707,7 @@ declare module ol { * @constructor * @param options Tile grid options */ - constructor(options?: TileGridOptions); + constructor(options: olx.tilegrid.TileGridOptions); /** * Creates a TileCoord transform function for use with this tile grid. Transforms the internal tile coordinates with bottom-left origin to the tile coordinates used by the ol.TileUrlFunction. The returned function expects an ol.TileCoord as first and an ol.proj.Projection as second argument and returns a transformed ol.TileCoord. @@ -2623,44 +2772,7 @@ declare module ol { */ getTileSize(z: number): number | ol.Size; } - interface TileGridOptions { - - /** - * Extent for the tile grid. No tiles outside this extent will be requested by ol.source.Tile sources. When no origin or origins are configured, the origin will be set to the bottom-left corner of the extent. When no sizes are configured, they will be calculated from the extent. - */ - extent?: ol.Extent; - - /** - * Minimum zoom. Default is 0. - */ - minZoom?: number; - - /** - * Origin, i.e. the bottom-left corner of the grid. Default is null. - */ - origin?: ol.Coordinate; - - /** - * Origins, i.e. the bottom-left corners of the grid for each zoom level. If given, the array length should match the length of the resolutions array, i.e. each resolution can have a different origin. - */ - origins?: Array; - - /** - * Resolutions. The array index of each resolution needs to match the zoom level. This means that even if a minZoom is configured, the resolutions array will have a length of maxZoom + 1. - */ - resolutions?: Array; - - /** - * Tile size. Default is [256, 256]. - */ - tileSize?: number | ol.Size; - - /** - * Tile sizes. If given, the array length should match the length of the resolutions array, i.e. each resolution can have a different tile size. - */ - tileSizes?: Array; - } - + /** * Set the grid pattern for sources accessing WMTS tiled-image servers. */ @@ -2670,7 +2782,7 @@ declare module ol { * @constructor * @param options WMTS options */ - constructor(options: WMTSOptions); + constructor(options: olx.tilegrid.WMTSOptions); /** * Create a tile grid from a WMTS capabilities matrix set. @@ -2686,54 +2798,7 @@ declare module ol { */ getMatrixIds(): Array; } - interface WMTSOptions { - - /** - * Extent for the tile grid. No tiles outside this extent will be requested by ol.source.WMTS sources. When no origin or origins are configured, the origin will be calculated from the extent. When no sizes are configured, they will be calculated from the extent. - */ - extent?: ol.Extent; - - /** - * Origin, i.e. the top-left corner of the grid. - */ - origin?: ol.Coordinate; - - /** - * Origins, i.e. the top-left corners of the grid for each zoom level. The length of this array needs to match the length of the resolutions array. - */ - origins?: Array; - - /** - * Resolutions. The array index of each resolution needs to match the zoom level. This means that even if a minZoom is configured, the resolutions array will have a length of maxZoom + 1 - */ - resolutions?: Array; - - /** - * matrix IDs. The length of this array needs to match the length of the resolutions array. - */ - matrixIds?: Array; - - /** - * Number of tile rows and columns of the grid for each zoom level. The values here are the TileMatrixWidth and TileMatrixHeight advertised in the GetCapabilities response of the WMTS, and define the grid's extent together with the origin. An extent can be configured in addition, and will further limit the extent for which tile requests are made by sources. - */ - sizes?: Array; - - /** - * Tile size. - */ - tileSize?: number | ol.Size; - - /** - * Tile sizes. The length of this array needs to match the length of the resolutions array. - */ - tileSizes?: Array; - - /** - * Number of tile columns that cover the grid's extent for each zoom level. Only required when used with a source that has wrapX set to true, and only when the grid's origin differs from the one of the projection's extent. The array length has to match the length of the resolutions array, i.e. each resolution will have a matching entry here. - */ - widths?: Array; - } - + /** * Set the grid pattern for sources accessing Zoomify tiled-image servers. */ @@ -2743,14 +2808,7 @@ declare module ol { * @constructor * @param options Options */ - constructor(options?: ZoomifyOptions); - } - interface ZoomifyOptions { - - /** - * Resolutions - */ - resolutions: Array; + constructor(options?: olx.tilegrid.ZoomifyOptions); } /** @@ -2758,29 +2816,7 @@ declare module ol { * @param options Tile grid options. * @returns The grid instance */ - function createXYZ(options: CreateXYZOptions): ol.tilegrid.TileGrid; - interface CreateXYZOptions { - - /** - * Extent for the tile grid. The origin for an XYZ tile grid is the top-left corner of the extent. The zero level of the grid is defined by the resolution at which one tile fits in the provided extent. If not provided, the extent of the EPSG:3857 projection is used. - */ - extent?: ol.Extent; - - /** - * Maximum zoom. The default is ol.DEFAULT_MAX_ZOOM. This determines the number of levels in the grid set. For example, a maxZoom of 21 means there are 22 levels in the grid set. - */ - maxZoom?: number; - - /** - * Minimum zoom. Default is 0. - */ - minZoom?: number; - - /** - * Tile size in pixels. Default is [256, 256]. - */ - tileSize?: number | ol.Size; - } + function createXYZ(options?: olx.tilegrid.XYZOptions): ol.tilegrid.TileGrid; } module webgl { From c70200ca8f04479d969903e9f37f37726f3fadda Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 24 Jun 2015 17:20:37 -0700 Subject: [PATCH 053/274] Update angular2 typings for alpha.28. --- angular2/angular2-2.0.0-alpha.26.d.ts | 4624 +++++++++++++++++ angular2/angular2-2.0.0-alpha.28.d.ts | 6162 ++++++++++++++++++++++ angular2/angular2.d.ts | 6833 +++++++++++++++---------- 3 files changed, 14971 insertions(+), 2648 deletions(-) create mode 100644 angular2/angular2-2.0.0-alpha.26.d.ts create mode 100644 angular2/angular2-2.0.0-alpha.28.d.ts diff --git a/angular2/angular2-2.0.0-alpha.26.d.ts b/angular2/angular2-2.0.0-alpha.26.d.ts new file mode 100644 index 0000000000..a527b13cab --- /dev/null +++ b/angular2/angular2-2.0.0-alpha.26.d.ts @@ -0,0 +1,4624 @@ +// Type definitions for Angular v2.0.0-alpha.26 +// 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. +// *********************************************************** + +// Angular depends transitively on these libraries. +// If you don't have them installed you can run +// $ tsd query es6-promise rx rx-lite --action install --save +/// +/// + +interface List extends Array {} +interface Map {} +interface StringMap {} +interface Type {} + +declare module "angular2/angular2" { + type SetterFn = typeof Function; + type int = number; + + // See https://github.com/Microsoft/TypeScript/issues/1168 + class BaseException /* extends Error */ { + message: any; + stack: any; + toString(): string; + } +} + + +declare module "angular2/angular2" { + class AbstractChangeDetector extends ChangeDetector { + addChild(cd: ChangeDetector): any; + addShadowDomChild(cd: ChangeDetector): any; + callOnAllChangesDone(): any; + checkNoChanges(): any; + detectChanges(): any; + detectChangesInRecords(throwOnChange: boolean): any; + lightDomChildren: List; + markAsCheckOnce(): any; + markPathToRootAsCheckOnce(): any; + mode: string; + parent: ChangeDetector; + ref: ChangeDetectorRef; + remove(): any; + removeChild(cd: ChangeDetector): any; + removeShadowDomChild(cd: ChangeDetector): any; + shadowDomChildren: List; + } + + class ProtoRecord { + args: List; + bindingRecord: BindingRecord; + contextIndex: number; + directiveIndex: DirectiveIndex; + expressionAsString: string; + fixedArgs: List; + funcOrValue: any; + isLifeCycleRecord(): boolean; + isPipeRecord(): boolean; + isPureFunction(): boolean; + lastInBinding: boolean; + lastInDirective: boolean; + mode: number; + name: string; + selfIndex: number; + } + + class LifecycleEvent { + name: string; + } + + interface FormDirective { + addControl(dir: ControlDirective): void; + addControlGroup(dir: ControlGroupDirective): void; + getControl(dir: ControlDirective): Control; + removeControl(dir: ControlDirective): void; + removeControlGroup(dir: ControlGroupDirective): void; + updateModel(dir: ControlDirective, value: any): void; + } + + + /** + * A directive that contains a group of [ControlDirective]. + * + * @exportedAs angular2/forms + */ + class ControlContainerDirective { + formDirective: FormDirective; + name: string; + path: List; + } + + + /** + * A marker annotation that marks a class as available to `Injector` for creation. Used by tooling + * for generating constructor stubs. + * + * ``` + * class NeedsService { + * constructor(svc:UsefulService) {} + * } + * + * @Injectable + * class UsefulService {} + * ``` + * @exportedAs angular2/di_annotations + */ + class Injectable { + } + + + /** + * Injectable Objects that contains a live list of child directives in the light Dom of a directive. + * The directives are kept in depth-first pre-order traversal of the DOM. + * + * In the future this class will implement an Observable interface. + * For now it uses a plain list of observable callbacks. + * + * @exportedAs angular2/view + */ + class BaseQueryList { + add(obj: any): any; + fireCallbacks(): any; + onChange(callback: any): any; + removeCallback(callback: any): any; + reset(newList: any): any; + } + + class AppProtoView { + bindElement(parent: ElementBinder, distanceToParent: int, protoElementInjector: ProtoElementInjector, componentDirective?: DirectiveBinding): ElementBinder; + + /** + * Adds an event binding for the last created ElementBinder via bindElement. + * + * If the directive index is a positive integer, the event is evaluated in the context of + * the given directive. + * + * If the directive index is -1, the event is evaluated in the context of the enclosing view. + * + * @param {string} eventName + * @param {AST} expression + * @param {int} directiveIndex The directive index in the binder or -1 when the event is not bound + * to a directive + */ + bindEvent(eventBindings: List, boundElementIndex: number, directiveIndex?: int): void; + elementBinders: List; + protoChangeDetector: ProtoChangeDetector; + protoLocals: Map; + render: RenderProtoViewRef; + variableBindings: Map; + } + + + /** + * Const of making objects: http://jsperf.com/instantiate-size-of-object + */ + class AppView implements ChangeDispatcher, EventDispatcher { + callAction(elementIndex: number, actionExpression: string, action: Object): any; + changeDetector: ChangeDetector; + componentChildViews: List; + + /** + * The context against which data-binding expressions in this view are evaluated against. + * This is always a component instance. + */ + context: any; + dispatchEvent(elementIndex: number, eventName: string, locals: Map): boolean; + elementInjectors: List; + freeHostViews: List; + getDetectorFor(directive: DirectiveIndex): any; + getDirectiveFor(directive: DirectiveIndex): any; + hydrated(): boolean; + init(changeDetector: ChangeDetector, elementInjectors: List, rootElementInjectors: List, preBuiltObjects: List, componentChildViews: List): any; + + /** + * Variables, local to this view, that can be used in binding expressions (in addition to the + * context). This is used for thing like `