Upstream Sync

This commit is contained in:
Hinell
2017-01-13 23:03:42 +03:00
56 changed files with 1755 additions and 294 deletions
@@ -0,0 +1,27 @@
import * as ng from "angular";
import * as angular from "angular";
import gridster from "angular-gridster";
var myApp = angular.module("testModule", ["gridster"]);
// configure gridster's global options
myApp.run(["gridsterConfig", (gridsterConfig: angular.gridster.GridsterConfig) => {
gridsterConfig.mobileBreakPoint = 697;
gridsterConfig.colWidth = "100";
gridsterConfig.rowHeight = "100";
gridsterConfig.minColumns = 1;
gridsterConfig.columns = 20;
gridsterConfig.margins = [5, 5];
gridsterConfig.minSizeX = 2;
gridsterConfig.minSizeY = 2;
gridsterConfig.outerMargin = true;
gridsterConfig.pushing = true;
gridsterConfig.floating = true;
gridsterConfig.swapping = true;
gridsterConfig.draggable = { enabled: true};
gridsterConfig.resizable = { enabled: true,
handles: ["n", "s", "e", "w", "ne", "se", "sw", "nw"]};
}
]);
+145
View File
@@ -0,0 +1,145 @@
// Type definitions for angular-gridster (gridster module) 0.13
// Project: https://github.com/ManifestWebDesign/angular-gridster
// Definitions by: Joao Monteiro <https://github.com/jpmnteiro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as angular from "angular";
export default "gridster";
declare module "angular" {
export namespace gridster {
interface GridsterConfig {
// number of columns in the grid
columns?: number;
// whether to push other items out of the way
// whether to push other items out of the way
pushing?: boolean;
// whether to automatically float items up so they stack
floating?: boolean;
// whether or not to have items switch places instead of push down if they are the same size
swapping?: boolean;
// width of the grid. "auto" will expand the grid to its parent container
width?: string;
// width of grid columns. "auto" will divide the width of the grid evenly among the columns
colWidth?: string;
// height of grid rows. 'match' will make it the same as the column width, a numeric value will be interpreted as pixels,
// '/2' is half the column width, '*5' is five times the column width, etc.
rowHeight?: string;
// margins in between grid items
margins?: number[];
// whether to set the outer margin
outerMargin?: boolean;
// toggle mobile view
isMobile?: boolean;
// width threshold to toggle mobile mode
mobileBreakPoint?: number;
// whether or not to toggle mobile mode when screen width is less than mobileBreakPoint
mobileModeEnabled?: boolean;
// minimum amount of columns the grid can scale down to
minColumns?: number;
// minimum amount of rows to show if the grid is empty
minRows?: number;
// maximum amount of rows in the grid
maxRows?: number;
// default width of an item in columns
defaultSizeX?: number;
// default height of an item in rows
defaultSizeY?: number;
// minimum column width of an item
minSizeX?: number;
// maximum column width of an item
maxSizeX?: number;
// minumum row height of an item
minSizeY?: number;
// maximum row height of an item
maxSizeY?: number;
saveGridItemCalculatedHeightInMobile?: boolean;
// grid item height in mobile display. true- to use the calculated height by sizeY given
// options to pass to resizable handler
resizable?: {
// whether the items are resizable
enabled?: boolean;
// location of the resize handles
// e.g // ['s', 'e', 'n', 'w', 'se', 'ne', 'sw', 'nw']
handles?: string[];
// optional callback fired when drag is started
start?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
// optional callback fired when item is resized
resize?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
// optional callback fired when item is finished dragging
stop?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
};
// options to pass to draggable handler
draggable?: {
// whether the items are resizable
enabled?: boolean;
// Distance in pixels from the edge of the viewport after which the viewport should scroll, relative to pointer
scrollSensitivity?: number;
// Speed at which the window should scroll once the mouse pointer gets within scrollSensitivity distance
scrollSpeed?: number;
// optional selector for drag handle
handle?: string;
// optional callback fired when drag is started
start?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
// optional callback fired when item is moved,
drag?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
// optional callback fired when item is finished dragging
stop?(event: angular.IAngularEvent, $element: angular.IAugmentedJQuery, options: any): void;
};
}
interface StandardGridsterItem {
// width of the item expressed in terms of number of columns it will occupy
sizeX: number;
// height of the item expressed in terms of number of rows it will occupy
sizeY: number;
// starting row where the item will be placed
row: number;
// starting column where the item will be placed
col: number;
}
}
}
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"angular-gridster-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+6 -2
View File
@@ -3,6 +3,10 @@
// Definitions by: Paul Lockwood <https://github.com/PaulLockwood>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export * from "bunyan";
import bunyan = require("bunyan");
export function ConsoleFormattedStream(): void;
declare module "bunyan" {
export function ConsoleFormattedStream(): void;
}
export = bunyan;
+2 -2
View File
@@ -1,7 +1,7 @@
import bunyan = require("bunyan");
import Logger = require("bunyan");
import bunyanLogentries = require("bunyan-logentries");
var logger: bunyan.Logger = bunyan.createLogger({
var logger: Logger = Logger.createLogger({
name: "foobar",
streams: [{
level: "info",
+38 -32
View File
@@ -1,83 +1,83 @@
import * as bunyan from 'bunyan';
import Logger = require('bunyan');
var ringBufferOptions:bunyan.RingBufferOptions = {
var ringBufferOptions: Logger.RingBufferOptions = {
limit: 100
};
var ringBuffer:bunyan.RingBuffer = new bunyan.RingBuffer(ringBufferOptions);
var ringBuffer: Logger.RingBuffer = new Logger.RingBuffer(ringBufferOptions);
ringBuffer.write("hello");
ringBuffer.end();
ringBuffer.destroy();
ringBuffer.destroySoon();
var level:number;
level = bunyan.resolveLevel("trace");
level = bunyan.resolveLevel("debug");
level = bunyan.resolveLevel("info");
level = bunyan.resolveLevel("warn");
level = bunyan.resolveLevel("error");
level = bunyan.resolveLevel("fatal");
level = bunyan.resolveLevel(bunyan.TRACE);
level = bunyan.resolveLevel(bunyan.DEBUG);
level = bunyan.resolveLevel(bunyan.INFO);
level = bunyan.resolveLevel(bunyan.WARN);
level = bunyan.resolveLevel(bunyan.ERROR);
level = bunyan.resolveLevel(bunyan.FATAL);
var level: number;
level = Logger.resolveLevel("trace");
level = Logger.resolveLevel("debug");
level = Logger.resolveLevel("info");
level = Logger.resolveLevel("warn");
level = Logger.resolveLevel("error");
level = Logger.resolveLevel("fatal");
level = Logger.resolveLevel(Logger.TRACE);
level = Logger.resolveLevel(Logger.DEBUG);
level = Logger.resolveLevel(Logger.INFO);
level = Logger.resolveLevel(Logger.WARN);
level = Logger.resolveLevel(Logger.ERROR);
level = Logger.resolveLevel(Logger.FATAL);
var options:bunyan.LoggerOptions = {
var options: Logger.LoggerOptions = {
name: 'test-logger',
serializers: bunyan.stdSerializers,
serializers: Logger.stdSerializers,
streams: [{
type: 'stream',
stream: process.stdout,
level: bunyan.TRACE
level: Logger.TRACE
}, {
type: 'file',
path: '/tmp/test.log',
level: bunyan.DEBUG,
level: Logger.DEBUG,
closeOnExit: true
}, {
type: 'rotating-file',
path: '/tmp/test2.log',
level: bunyan.INFO,
level: Logger.INFO,
closeOnExit: false,
period: '1d',
count: 3
}, {
type: 'raw',
stream: process.stderr,
level: bunyan.WARN
level: Logger.WARN
}, {
type: 'raw',
stream: ringBuffer,
level: bunyan.ERROR
level: Logger.ERROR
}]
};
var log = bunyan.createLogger(options);
var log = Logger.createLogger(options);
var customSerializer = function(anything: any) {
return { obj: anything};
};
log.addSerializers({anything: customSerializer});
log.addSerializers(bunyan.stdSerializers);
log.addSerializers(Logger.stdSerializers);
log.addSerializers(
{
err: bunyan.stdSerializers.err,
req: bunyan.stdSerializers.req,
res: bunyan.stdSerializers.res
err: Logger.stdSerializers.err,
req: Logger.stdSerializers.req,
res: Logger.stdSerializers.res
}
);
var child = log.child({name: 'child'});
child.reopenFileStreams();
log.addStream({path: '/dev/null'});
child.level(bunyan.DEBUG);
child.level(Logger.DEBUG);
child.level('debug');
child.levels(0, bunyan.ERROR);
child.levels(0, Logger.ERROR);
child.levels(0, 'error');
child.levels('stream1', bunyan.FATAL);
child.levels('stream1', Logger.FATAL);
child.levels('stream1', 'fatal');
var buffer = new Buffer(0);
@@ -118,4 +118,10 @@ var recursive: any = {
}
}
JSON.stringify(recursive, bunyan.safeCycles());
JSON.stringify(recursive, Logger.safeCycles());
class MyLogger extends Logger {
constructor() {
super(options);
}
}
+46 -43
View File
@@ -5,14 +5,13 @@
/// <reference types="node" />
import { EventEmitter } from 'events';
declare class Logger extends EventEmitter {
constructor(options: LoggerOptions);
addStream(stream: Stream): void;
addSerializers(serializers:Serializers | StdSerializers):void;
child(options: LoggerOptions, simple?: boolean): Logger;
constructor(options: Logger.LoggerOptions);
addStream(stream: Logger.Stream): void;
addSerializers(serializers: Logger.Serializers | Logger.StdSerializers): void;
child(options: Logger.LoggerOptions, simple?: boolean): Logger;
child(obj: Object, simple?: boolean): Logger;
reopenFileStreams(): void;
@@ -21,7 +20,7 @@ declare class Logger extends EventEmitter {
levels(name: number | string, value: number | string): void;
fields: any;
src:boolean;
src: boolean;
trace(error: Error, format?: any, ...params: any[]): void;
trace(buffer: Buffer, format?: any, ...params: any[]): void;
@@ -49,31 +48,23 @@ declare class Logger extends EventEmitter {
fatal(format: string, ...params: any[]): void;
}
interface LoggerOptions {
name: string;
streams?: Stream[];
level?: string | number;
stream?: NodeJS.WritableStream;
serializers?: Serializers | StdSerializers;
src?: boolean;
[custom: string]: any;
}
declare namespace Logger {
const TRACE: number;
const DEBUG: number;
const INFO: number;
const WARN: number;
const ERROR: number;
const FATAL: number;
interface Serializer {
(input:any): any;
}
const stdSerializers: StdSerializers;
interface Serializers {
[key: string]: Serializer
}
function createLogger(options: LoggerOptions): Logger;
interface StdSerializers {
err: Serializer;
res: Serializer;
req: Serializer;
}
function safeCycles(): (key: string, value: any) => any;
interface Stream {
function resolveLevel(value: number | string): number;
interface Stream {
type?: string;
level?: number | string;
path?: string;
@@ -81,22 +72,37 @@ interface Stream {
closeOnExit?: boolean;
period?: string;
count?: number;
}
}
export declare var stdSerializers: StdSerializers;
interface LoggerOptions {
name: string;
streams?: Stream[];
level?: string | number;
stream?: NodeJS.WritableStream;
serializers?: Serializers | StdSerializers;
src?: boolean;
[custom: string]: any;
}
export declare var TRACE: number;
export declare var DEBUG: number;
export declare var INFO: number;
export declare var WARN: number;
export declare var ERROR: number;
export declare var FATAL: number;
interface Serializer {
(input:any): any;
}
export declare function resolveLevel(value: number | string): number;
interface Serializers {
[key: string]: Serializer
}
export declare function createLogger(options: LoggerOptions): Logger;
interface StdSerializers {
err: Serializer;
res: Serializer;
req: Serializer;
}
declare class RingBuffer extends EventEmitter {
interface RingBufferOptions {
limit?: number;
}
class RingBuffer extends EventEmitter {
constructor(options: RingBufferOptions);
writable: boolean;
@@ -106,10 +112,7 @@ declare class RingBuffer extends EventEmitter {
end(record?: any): void;
destroy(): void;
destroySoon(): void;
}
}
interface RingBufferOptions {
limit?: number;
}
export declare function safeCycles(): (key: string, value: any) => any;
export = Logger;
+2 -2
View File
@@ -9,7 +9,7 @@
import stream = require('stream');
import http = require('http');
import request = require('request');
import bunyan = require('bunyan');
import Logger = require('bunyan');
import express = require('express');
import Q = require('q');
@@ -35,7 +35,7 @@ interface Result {
declare class BaseRequest {
protected base: request.Request;
protected req: express.Request;
protected log: bunyan.Logger;
protected log: Logger;
protected replyCookies: string[];
protected jSend: boolean;
constructor(opts: any);
+2 -2
View File
@@ -18,7 +18,7 @@ declare namespace Express {
declare module "easy-xapi" {
import express = require('express');
import http = require('http');
import bunyan = require('bunyan');
import Logger = require('bunyan');
interface InitConfig {
jSend?: {partial: boolean};
@@ -40,7 +40,7 @@ declare module "easy-xapi" {
express: any;
app: express.Application;
server: http.Server;
log: bunyan.Logger;
log: Logger;
listen: () => void;
}
+6
View File
@@ -0,0 +1,6 @@
export const isExtraneousPopstateEvent: boolean;
export function addEventListener(node: EventTarget, event: string, listener: EventListenerOrEventListenerObject): void;
export function removeEventListener(node: EventTarget, event: string, listener: EventListenerOrEventListenerObject): void;
export function getConfirmation(message: string, callback: (result: boolean) => void): void;
export function supportsHistory(): boolean;
export function supportsGoWithoutReloadUsingHash(): boolean;
+1
View File
@@ -0,0 +1 @@
export const canUseDOM: boolean;
+5
View File
@@ -0,0 +1,5 @@
import { Path, LocationState, LocationKey, Location, LocationDescriptor } from './index';
export function locationsAreEqual(lv: LocationDescriptor, rv: LocationDescriptor): boolean;
export function createLocation(options: LocationDescriptor): Location;
export function createLocation(path: Path, state?: LocationState, key?: LocationKey, currentLocation?: Location): Location;
+7
View File
@@ -0,0 +1,7 @@
import { Path, Location, LocationDescriptor } from './index';
export function addLeadingSlash(path: Path): Path;
export function stripLeadingSlash(path: Path): Path;
export function stripPrefix(path: Path, prefix: string): Path;
export function parsePath(path: Path): Location;
export function createPath(location: LocationDescriptor): Path;
+11
View File
@@ -0,0 +1,11 @@
import { History } from './index';
import { getConfirmation } from './DOMUtils';
export interface BrowserHistoryBuildOptions {
basename?: string;
forceRefresh?: boolean;
getUserConfirmation?: typeof getConfirmation;
keyLength?: number;
}
export default function createBrowserHistory(options?: BrowserHistoryBuildOptions): History;
+12
View File
@@ -0,0 +1,12 @@
import { History } from './index';
import { getConfirmation } from './DOMUtils';
export type HashType = 'hashbang' | 'noslash' | 'slash';
export interface HashHistoryBuildOptions {
basename?: string;
hashType?: HashType;
getUserConfirmation?: typeof getConfirmation;
}
export default function createHashHistory(options?: HashHistoryBuildOptions): History;
+17
View File
@@ -0,0 +1,17 @@
import { History, Location } from './index';
import { getConfirmation } from './DOMUtils';
export interface MemoryHistoryBuildOptions {
getUserConfirmation?: typeof getConfirmation;
initialEntries?: string[];
initialIndex?: number;
keyLength?: number;
}
export interface MemoryHistory extends History {
index: number;
entries: Location[];
canGo(n: number): boolean;
}
export default function createMemoryHistory(options?: MemoryHistoryBuildOptions): MemoryHistory;
+15
View File
@@ -0,0 +1,15 @@
import { Location, Action, LocationListener, UnregisterCallback } from './index';
import { getConfirmation } from './DOMUtils';
export type PromptFunction = (location: Location, action: Action) => any;
export type Prompt = PromptFunction | boolean;
export interface TransitionManager {
setPrompt(nextPrompt?: Prompt): UnregisterCallback;
appendListener(listener: LocationListener): UnregisterCallback;
notifyListeners(location: Location, action: Action): void;
confirmTransitionTo(location: Location, action: Action, getUserConfirmation: typeof getConfirmation, callback: (result: boolean) => void): void;
}
export default function createTransitionManager(): TransitionManager;
+63 -73
View File
@@ -1,31 +1,28 @@
import { createHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history'
import { createBrowserHistory, createMemoryHistory, createHashHistory, createLocation, Location } from 'history';
import * as LocationUtils from 'history/LocationUtils';
import * as PathUtils from 'history/PathUtils';
import * as DOMUtils from 'history/DOMUtils';
import * as ExecutionEnvironment from 'history/ExecutionEnvironment';
import { getUserConfirmation } from 'history/lib/DOMUtils'
interface Promise<T> {
then<TResult>(onfulfilled?: (value: T) => TResult): Promise<TResult>;
}
let doSomethingAsync: () => Promise<Function>;
let input = { value: "" };
{
let history = createHistory()
let history = createBrowserHistory();
// Listen for changes to the current location. The
// listener is called once immediately.
let unlisten = history.listen(function(location) {
console.log(location.pathname)
})
let unlisten = history.listen(function (location) {
console.log(location.pathname);
});
// When you're finished, stop the listener.
unlisten()
unlisten();
// Push a new entry onto the history stack.
history.push('/home')
history.push('/home');
// Replace the current entry on the history stack.
history.replace('/profile')
history.replace('/profile');
// Push a new entry with state onto the history stack.
history.push({
@@ -35,97 +32,90 @@ let input = { value: "" };
});
// Change just the search on an existing location.
//history.push({ ...location, search: '?the=other+search' })
history.push({ pathname: location.pathname, search: '?the=other+search' });
// Go back to the previous history entry. The following
// two lines are synonymous.
history.go(-1)
history.goBack()
history.go(-1);
history.goBack();
let href = history.createHref('/the/path')
let href = history.createHref({ pathname: '/the/path' });
}
{
let history = createHistory()
let history = createMemoryHistory();
// Pushing a path string.
history.push('/the/path')
history.push('/the/path');
// Omitting location state when pushing a location descriptor.
history.push({ pathname: '/the/path', search: '?the=search' })
history.push({ pathname: '/the/path', search: '?the=search' });
let location = createLocation('/a/path?a=query', { the: 'state' });
// Extending an existing location object.
//history.push({ ...location, search: '?other=search' })
history.push({ pathname: location.pathname, search: '?other=search' });
let location = createLocation('/a/path?a=query', { the: 'state' })
if (history.canGo(-1)) {
history.go(-1);
history.goBack();
}
location = history.createLocation('/a/path?a=query', { the: 'state' })
let unblock = history.block(true);
unblock();
history.entries.forEach(function (location) {
let typedLocation: Location = location;
});
}
{
let history = createHistory()
history.listenBefore(function(location) {
if (input.value !== '')
return 'Are you sure you want to leave this page?'
})
let history = createHashHistory()
history.listen(function (location) {
if (input.value !== '') {
return 'Are you sure you want to leave this page?';
}
});
history.listenBefore(function(location, callback) {
doSomethingAsync().then(callback)
})
history.listen(function (location, action) {
if (typeof action === 'string') {
console.log(action);
}
});
}
{
let history = createHistory({
let history = createBrowserHistory({
basename: 'base',
keyLength: 10,
forceRefresh: false,
getUserConfirmation(message, callback) {
callback(window.confirm(message)) // The default behavior
callback(window.confirm(message)); // The default behavior
}
})
});
}
{
let history = useBeforeUnload(createHistory)()
history.listenBeforeUnload(function() {
return 'Are you sure you want to leave this page?'
})
let location1 = LocationUtils.createLocation('path/1', { state: 1 });
let location2 = LocationUtils.createLocation({ pathname: 'pathname', state: 2 });
LocationUtils.locationsAreEqual(location1, location2);
}
{
let history = useQueries(createHistory)()
history.listen(function(location) {
console.log(location.query)
})
let path = PathUtils.createPath({ pathname: '/a/path', hash: '#hash' });
let strippedPath = PathUtils.stripPrefix(path, '/a/');
let location = PathUtils.parsePath(strippedPath);
}
{
let history = useQueries(createHistory)({
parseQueryString: function(queryString) {
// TODO: return a parsed version of queryString
return {};
},
stringifyQuery: function(query) {
// TODO: return a query string created from query
return "";
}
})
history.createPath({ pathname: '/the/path', query: { the: 'query' } })
history.push({ pathname: '/the/path', query: { the: 'query' } })
let eventTarget: EventTarget;
DOMUtils.addEventListener(eventTarget, 'onload', function (event) { event.preventDefault(); });
DOMUtils.removeEventListener(eventTarget, 'onload', function (event) { event.preventDefault(); });
DOMUtils.getConfirmation('confirm?', (result) => console.log(result));
let booleanValues = DOMUtils.supportsGoWithoutReloadUsingHash() && DOMUtils.supportsHistory();
}
{
// Run our app under the /base URL.
let history = useBasename(createHistory)({
basename: '/base'
})
// At the /base/hello/world URL:
history.listen(function(location) {
console.log(location.pathname) // /hello/world
console.log(location.basename) // /base
})
history.createPath('/the/path') // /base/the/path
history.push('/the/path') // push /base/the/path
}
let supportsDOM = ExecutionEnvironment.canUseDOM;
let isExtraneousPopstateEvent = DOMUtils.isExtraneousPopstateEvent;
}
+47 -95
View File
@@ -1,138 +1,90 @@
// Type definitions for history v2.0.0
// Type definitions for history 4.5
// Project: https://github.com/mjackson/history
// Definitions by: Sergey Buturlakin <https://github.com/sergey-buturlakin>, Nathan Brown <https://github.com/ngbrown>
// Definitions by: Sergey Buturlakin <https://github.com/sergey-buturlakin>, Nathan Brown <https://github.com/ngbrown>, Young Rok Kim <https://github.com/rokoroku>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace History;
export type Action = string;
export type BeforeUnloadHook = () => string | boolean;
export type CreateHistory<T> = (options?: HistoryOptions) => T;
export type CreateHistoryEnhancer<T, E> = (createHistory: CreateHistory<T>) => CreateHistory<T & E>;
export type Action = 'PUSH' | 'POP' | 'REPLACE';
export type UnregisterCallback = () => void;
export interface History {
listenBefore(hook: TransitionHook): () => void;
listen(listener: LocationListener): () => void;
transitionTo(location: Location): void;
push(path: LocationDescriptor): void;
replace(path: LocationDescriptor): void;
length: number;
action: Action;
location: Location;
push(path: Path, state?: LocationState): void;
push(location: LocationDescriptorObject): void;
replace(path: Path, state?: LocationState): void;
replace(location: LocationDescriptorObject): void;
go(n: number): void;
goBack(): void;
goForward(): void;
createKey(): LocationKey;
createPath(path: LocationDescriptor): Path;
createHref(path: LocationDescriptor): Href;
createLocation(path?: LocationDescriptor, action?: Action, key?: LocationKey): Location;
getCurrentLocation: () => Location
/** @deprecated use a location descriptor instead */
createLocation(path?: Path, state?: LocationState, action?: Action, key?: LocationKey): Location;
/** @deprecated use location.key to save state instead */
pushState(state: LocationState, path: Path): void;
/** @deprecated use location.key to save state instead */
replaceState(state: LocationState, path: Path): void;
/** @deprecated use location.key to save state instead */
setState(state: LocationState): void;
/** @deprecated use listenBefore instead */
registerTransitionHook(hook: TransitionHook): void;
/** @deprecated use the callback returned from listenBefore instead */
unregisterTransitionHook(hook: TransitionHook): void;
block(prompt?: boolean): UnregisterCallback;
listen(listener: LocationListener): UnregisterCallback;
createHref(location: Path | LocationDescriptorObject): Href;
}
export type HistoryOptions = {
getCurrentLocation?: () => Location;
finishTransition?: (nextLocation: Location) => boolean;
saveState?: (key: LocationKey, state: LocationState) => void;
go?: (n: number) => void;
getUserConfirmation?: (message: string, callback: (result: boolean) => void) => void;
keyLength?: number;
queryKey?: string | boolean;
stringifyQuery?: (obj: any) => string;
parseQueryString?: (str: string) => any;
basename?: string;
entries?: string | [any];
current?: number;
}
export type Location = {
export interface Location {
pathname: Pathname;
search: Search;
query: Query;
state: LocationState;
action: Action;
hash: Hash;
key: LocationKey;
basename?: string;
};
}
export type LocationDescriptorObject = {
export interface LocationDescriptorObject {
pathname?: Pathname;
search?: Search;
query?: Query;
state?: LocationState;
};
hash?: Hash;
key?: LocationKey;
}
export namespace History {
export type LocationDescriptor = LocationDescriptorObject | Path;
export type LocationDescriptor = Path | LocationDescriptorObject;
export type LocationKey = string;
export type LocationListener = (location: Location) => void;
export type LocationState = Object;
export type Path = string // Pathname + QueryString;
export type LocationListener = (location: Location, action: Action) => void;
export type LocationState = any;
export type Path = string;
export type Pathname = string;
export type Query = Object;
export type QueryString = string;
export type Search = string;
export type TransitionHook = (location: Location, callback: (result: any) => void) => any
export type TransitionHook = (location: Location, callback: (result: any) => void) => any;
export type Hash = string;
export type Href = string;
}
// Back-compat aliases
export type LocationDescriptor = History.LocationDescriptor;
export type LocationKey = History.LocationKey;
export type LocationListener = History.LocationListener;
export type LocationState = History.LocationState;
export type Path = History.Path;
export type Pathname = History.Pathname;
export type Query = History.Query;
export type QueryString = History.QueryString;
export type Search = History.Search;
export type TransitionHook = History.TransitionHook;
export type Hash = History.Hash;
export type Href = History.Href;
export interface HistoryBeforeUnload {
listenBeforeUnload(hook: BeforeUnloadHook): () => void;
}
export interface HistoryQueries {
pushState(state: LocationState, pathname: Pathname | Path, query?: Query): void;
replaceState(state: LocationState, pathname: Pathname | Path, query?: Query): void;
createPath(path: Path, query?: Query): Path;
createHref(path: Path, query?: Query): Href;
}
import { default as createBrowserHistory } from "./createBrowserHistory";
import { default as createHashHistory } from "./createHashHistory";
import { default as createMemoryHistory } from "./createMemoryHistory";
import { createLocation, locationsAreEqual } from "./LocationUtils";
import { parsePath, createPath } from "./PathUtils";
// Global usage, without modules, needs the small trick, because lib.d.ts
// already has `history` and `History` global definitions:
// var createHistory = ((window as any).History as HistoryModule.Module).createHistory;
export interface Module {
createHistory: CreateHistory<History>;
createHashHistory: CreateHistory<History>;
createMemoryHistory: CreateHistory<History>;
createLocation(path?: Path, state?: LocationState, action?: Action, key?: LocationKey): Location;
useBasename<T>(createHistory: CreateHistory<T>): CreateHistory<T>;
useBeforeUnload<T>(createHistory: CreateHistory<T>): CreateHistory<T & HistoryBeforeUnload>;
useQueries<T>(createHistory: CreateHistory<T>): CreateHistory<T & HistoryQueries>;
actions: {
PUSH: string;
REPLACE: string;
POP: string;
};
createBrowserHistory: typeof createBrowserHistory;
createHashHistory: typeof createHashHistory;
createMemoryHistory: typeof createMemoryHistory;
createLocation: typeof createLocation;
locationsAreEqual: typeof locationsAreEqual;
parsePath: typeof parsePath;
createPath: typeof createPath;
}
export { default as createHistory } from "./lib/createBrowserHistory";
export { default as createHashHistory } from "./lib/createHashHistory";
export { default as createMemoryHistory } from "./lib/createMemoryHistory";
export { default as createLocation } from "./lib/createLocation";
export { default as useBasename } from "./lib/useBasename";
export { default as useBeforeUnload } from "./lib/useBeforeUnload";
export { default as useQueries } from "./lib/useQueries";
import * as Actions from "./lib/actions";
export { Actions };
export * from "./createBrowserHistory";
export * from "./createHashHistory";
export * from "./createMemoryHistory";
export { createLocation, locationsAreEqual } from "./LocationUtils";
export { parsePath, createPath } from "./PathUtils";
export { createBrowserHistory, createHashHistory, createMemoryHistory };
+9 -10
View File
@@ -16,14 +16,13 @@
"files": [
"index.d.ts",
"history-tests.ts",
"lib/actions.d.ts",
"lib/createBrowserHistory.d.ts",
"lib/createHashHistory.d.ts",
"lib/createLocation.d.ts",
"lib/createMemoryHistory.d.ts",
"lib/DOMUtils.d.ts",
"lib/useBasename.d.ts",
"lib/useBeforeUnload.d.ts",
"lib/useQueries.d.ts"
"createBrowserHistory.d.ts",
"createMemoryHistory.d.ts",
"createHashHistory.d.ts",
"createTransitionManager.d.ts",
"DOMUtils.d.ts",
"ExecutionEnvironment.d.ts",
"LocationUtils.d.ts",
"PathUtils.d.ts"
]
}
}
+131
View File
@@ -0,0 +1,131 @@
import { createBrowserHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history'
import { getUserConfirmation } from 'history/lib/DOMUtils'
interface Promise<T> {
then<TResult>(onfulfilled?: (value: T) => TResult): Promise<TResult>;
}
let doSomethingAsync: () => Promise<Function>;
let input = { value: "" };
{
let history = createBrowserHistory()
// Listen for changes to the current location. The
// listener is called once immediately.
let unlisten = history.listen(function(location) {
console.log(location.pathname)
})
// When you're finished, stop the listener.
unlisten()
// Push a new entry onto the history stack.
history.push('/home')
// Replace the current entry on the history stack.
history.replace('/profile')
// Push a new entry with state onto the history stack.
history.push({
pathname: '/about',
search: '?the=search',
state: { some: 'state' }
});
// Change just the search on an existing location.
//history.push({ ...location, search: '?the=other+search' })
// Go back to the previous history entry. The following
// two lines are synonymous.
history.go(-1)
history.goBack()
let href = history.createHref('/the/path')
}
{
let history = createBrowserHistory()
// Pushing a path string.
history.push('/the/path')
// Omitting location state when pushing a location descriptor.
history.push({ pathname: '/the/path', search: '?the=search' })
// Extending an existing location object.
//history.push({ ...location, search: '?other=search' })
let location = createLocation('/a/path?a=query', { the: 'state' })
location = history.createLocation('/a/path?a=query', { the: 'state' })
}
{
let history = createBrowserHistory()
history.listenBefore(function(location) {
if (input.value !== '')
return 'Are you sure you want to leave this page?'
})
history.listenBefore(function(location, callback) {
doSomethingAsync().then(callback)
})
}
{
let history = createBrowserHistory({
getUserConfirmation(message, callback) {
callback(window.confirm(message)) // The default behavior
}
})
}
{
let history = useBeforeUnload(createBrowserHistory)()
history.listenBeforeUnload(function() {
return 'Are you sure you want to leave this page?'
})
}
{
let history = useQueries(createBrowserHistory)()
history.listen(function(location) {
console.log(location.query)
})
}
{
let history = useQueries(createBrowserHistory)({
parseQueryString: function(queryString) {
// TODO: return a parsed version of queryString
return {};
},
stringifyQuery: function(query) {
// TODO: return a query string created from query
return "";
}
})
history.createPath({ pathname: '/the/path', query: { the: 'query' } })
history.push({ pathname: '/the/path', query: { the: 'query' } })
}
{
// Run our app under the /base URL.
let history = useBasename(createBrowserHistory)({
basename: '/base'
})
// At the /base/hello/world URL:
history.listen(function(location) {
console.log(location.pathname) // /hello/world
console.log(location.basename) // /base
})
history.createPath('/the/path') // /base/the/path
history.push('/the/path') // push /base/the/path
}
+138
View File
@@ -0,0 +1,138 @@
// Type definitions for history v2.0.0
// Project: https://github.com/mjackson/history
// Definitions by: Sergey Buturlakin <https://github.com/sergey-buturlakin>, Nathan Brown <https://github.com/ngbrown>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace History;
export type Action = string;
export type BeforeUnloadHook = () => string | boolean;
export type CreateHistory<T> = (options?: HistoryOptions) => T;
export type CreateHistoryEnhancer<T, E> = (createHistory: CreateHistory<T>) => CreateHistory<T & E>;
export interface History {
listenBefore(hook: TransitionHook): () => void;
listen(listener: LocationListener): () => void;
transitionTo(location: Location): void;
push(path: LocationDescriptor): void;
replace(path: LocationDescriptor): void;
go(n: number): void;
goBack(): void;
goForward(): void;
createKey(): LocationKey;
createPath(path: LocationDescriptor): Path;
createHref(path: LocationDescriptor): Href;
createLocation(path?: LocationDescriptor, action?: Action, key?: LocationKey): Location;
getCurrentLocation: () => Location
/** @deprecated use a location descriptor instead */
createLocation(path?: Path, state?: LocationState, action?: Action, key?: LocationKey): Location;
/** @deprecated use location.key to save state instead */
pushState(state: LocationState, path: Path): void;
/** @deprecated use location.key to save state instead */
replaceState(state: LocationState, path: Path): void;
/** @deprecated use location.key to save state instead */
setState(state: LocationState): void;
/** @deprecated use listenBefore instead */
registerTransitionHook(hook: TransitionHook): void;
/** @deprecated use the callback returned from listenBefore instead */
unregisterTransitionHook(hook: TransitionHook): void;
}
export type HistoryOptions = {
getCurrentLocation?: () => Location;
finishTransition?: (nextLocation: Location) => boolean;
saveState?: (key: LocationKey, state: LocationState) => void;
go?: (n: number) => void;
getUserConfirmation?: (message: string, callback: (result: boolean) => void) => void;
keyLength?: number;
queryKey?: string | boolean;
stringifyQuery?: (obj: any) => string;
parseQueryString?: (str: string) => any;
basename?: string;
entries?: string | [any];
current?: number;
}
export type Location = {
pathname: Pathname;
search: Search;
query: Query;
state: LocationState;
action: Action;
key: LocationKey;
basename?: string;
};
export type LocationDescriptorObject = {
pathname?: Pathname;
search?: Search;
query?: Query;
state?: LocationState;
};
export namespace History {
export type LocationDescriptor = LocationDescriptorObject | Path;
export type LocationKey = string;
export type LocationListener = (location: Location) => void;
export type LocationState = Object;
export type Path = string // Pathname + QueryString;
export type Pathname = string;
export type Query = Object;
export type QueryString = string;
export type Search = string;
export type TransitionHook = (location: Location, callback: (result: any) => void) => any
export type Href = string;
}
// Back-compat aliases
export type LocationDescriptor = History.LocationDescriptor;
export type LocationKey = History.LocationKey;
export type LocationListener = History.LocationListener;
export type LocationState = History.LocationState;
export type Path = History.Path;
export type Pathname = History.Pathname;
export type Query = History.Query;
export type QueryString = History.QueryString;
export type Search = History.Search;
export type TransitionHook = History.TransitionHook;
export type Href = History.Href;
export interface HistoryBeforeUnload {
listenBeforeUnload(hook: BeforeUnloadHook): () => void;
}
export interface HistoryQueries {
pushState(state: LocationState, pathname: Pathname | Path, query?: Query): void;
replaceState(state: LocationState, pathname: Pathname | Path, query?: Query): void;
createPath(path: Path, query?: Query): Path;
createHref(path: Path, query?: Query): Href;
}
// Global usage, without modules, needs the small trick, because lib.d.ts
// already has `history` and `History` global definitions:
// var createHistory = ((window as any).History as HistoryModule.Module).createHistory;
export interface Module {
createHistory: CreateHistory<History>;
createHashHistory: CreateHistory<History>;
createMemoryHistory: CreateHistory<History>;
createLocation(path?: Path, state?: LocationState, action?: Action, key?: LocationKey): Location;
useBasename<T>(createHistory: CreateHistory<T>): CreateHistory<T>;
useBeforeUnload<T>(createHistory: CreateHistory<T>): CreateHistory<T & HistoryBeforeUnload>;
useQueries<T>(createHistory: CreateHistory<T>): CreateHistory<T & HistoryQueries>;
actions: {
PUSH: string;
REPLACE: string;
POP: string;
};
}
export { default as createBrowserHistory } from "./lib/createBrowserHistory";
export { default as createHashHistory } from "./lib/createHashHistory";
export { default as createMemoryHistory } from "./lib/createMemoryHistory";
export { default as createLocation } from "./lib/createLocation";
export { default as useBasename } from "./lib/useBasename";
export { default as useBeforeUnload } from "./lib/useBeforeUnload";
export { default as useQueries } from "./lib/useQueries";
import * as Actions from "./lib/actions";
export { Actions };
+33
View File
@@ -0,0 +1,33 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"paths": {
"history": ["history/v2"],
"history/*": ["history/v2/*"]
},
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"history-tests.ts",
"lib/actions.d.ts",
"lib/createBrowserHistory.d.ts",
"lib/createHashHistory.d.ts",
"lib/createLocation.d.ts",
"lib/createMemoryHistory.d.ts",
"lib/DOMUtils.d.ts",
"lib/useBasename.d.ts",
"lib/useBeforeUnload.d.ts",
"lib/useQueries.d.ts"
]
}
+1 -4
View File
@@ -6,9 +6,6 @@
/// <reference types="leaflet" />
declare namespace L {
// TODO: This should be defined by leaflet itself, not by leaflet-geocoder-mapzen
type PositionString = 'topleft' | 'topright' | 'bottomleft' | 'bottomright';
namespace Control {
export interface GeocoderStatic extends ClassStatic {
/**
@@ -80,7 +77,7 @@ declare namespace L {
*
* Default value: 'topleft'.
*/
position?: PositionString;
position?: L.PositionString;
/**
* Attribution text to include.
+11
View File
@@ -6,6 +6,7 @@
/// <reference types="geojson" />
type NativeMouseEvent = MouseEvent;
type NativeKeyboardEvent = KeyboardEvent;
declare namespace L {
export class Class {
@@ -1137,6 +1138,10 @@ declare namespace L {
originalEvent: NativeMouseEvent;
}
export interface KeyboardEvent extends Event {
originalEvent: NativeKeyboardEvent;
}
export interface LocationEvent extends Event {
latlng: LatLng;
bounds: LatLngBounds;
@@ -1194,6 +1199,12 @@ declare namespace L {
distance: number;
}
export interface ZoomAnimEvent extends Event {
center: LatLng;
zoom: number;
noUpdate: boolean;
}
export namespace DomEvent {
export function on(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: any): typeof DomEvent;
+4 -1
View File
@@ -6,6 +6,9 @@
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"paths": {
"history": ["history/v2"]
},
"typeRoots": [
"../"
],
@@ -18,4 +21,4 @@
"index.d.ts",
"react-breadcrumbs-tests.tsx"
]
}
}
+5 -1
View File
@@ -6,6 +6,10 @@
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"paths": {
"history": ["history/v2"],
"history/*": ["history/v2/*"]
},
"typeRoots": [
"../"
],
@@ -19,4 +23,4 @@
"index.d.ts",
"react-i18next-tests.tsx"
]
}
}
+238
View File
@@ -0,0 +1,238 @@
// Type definitions for react-leaflet 1.0
// Project: https://github.com/PaulLeCam/react-leaflet
// Definitions by: Dave Leaver <https://github.com/danzel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="geojson" />
import * as Leaflet from 'leaflet';
import * as React from 'react';
//All events need to be lowercase so they don't collide with React.DOMAttributes<T>
// which already declares things with some of the same names
interface LeafletLayerEvents {
onbaselayerchange?: (event: Leaflet.LayersControlEvent) => void;
onoverlayadd?: (event: Leaflet.LayersControlEvent) => void;
onoverlayremove?: (event: Leaflet.LayersControlEvent) => void;
onlayeradd?: (event: Leaflet.LayerEvent) => void;
onlayerremove?: (event: Leaflet.LayerEvent) => void;
}
interface LeafletMapStateChangeEvents {
onzoomlevelschange?: (event: Leaflet.Event) => void;
onresize?: (event: Leaflet.ResizeEvent) => void;
onunload?: (event: Leaflet.Event) => void;
onviewreset?: (event: Leaflet.Event) => void;
onload?: (event: Leaflet.Event) => void;
onzoomstart?: (event: Leaflet.Event) => void;
onmovestart?: (event: Leaflet.Event) => void;
onzoom?: (event: Leaflet.Event) => void;
onmove?: (event: Leaflet.Event) => void;
onzoomend?: (event: Leaflet.Event) => void;
onmoveend?: (event: Leaflet.Event) => void;
}
interface LeafletPopupEvents {
onpopupopen?: (event: Leaflet.PopupEvent) => void;
onpopupclose?: (event: Leaflet.PopupEvent) => void;
onautopanstart?: (event: Leaflet.Event) => void;
}
interface LeafletTooltipEvents {
ontooltipopen?: (event: Leaflet.TooltipEvent) => void;
ontooltipclose?: (event: Leaflet.TooltipEvent) => void;
}
interface LeafletLocationEvents {
onlocationerror?: (event: Leaflet.ErrorEvent) => void;
onlocationfound?: (event: Leaflet.LocationEvent) => void;
}
interface LeafletInteractionEvents {
onclick?: (event: Leaflet.MouseEvent) => void;
ondblclick?: (event: Leaflet.MouseEvent) => void;
onmousedown?: (event: Leaflet.MouseEvent) => void;
onmouseup?: (event: Leaflet.MouseEvent) => void;
onmouseover?: (event: Leaflet.MouseEvent) => void;
onmouseout?: (event: Leaflet.MouseEvent) => void;
onmousemove?: (event: Leaflet.MouseEvent) => void;
oncontextmenu?: (event: Leaflet.MouseEvent) => void;
onkeypress?: (event: Leaflet.KeyboardEvent) => void;
onpreclick?: (event: Leaflet.MouseEvent) => void;
}
interface LeafletOtherEvents {
onzoomanim?: (event: Leaflet.ZoomAnimEvent) => void;
}
interface LeafletDraggingEvents {
ondragstart?: (event: Leaflet.Event) => void;
onmovestart?: (event: Leaflet.Event) => void;
ondrag?: (event: Leaflet.Event) => void;
ondragend?: (event: Leaflet.DragEndEvent) => void;
onmoveend?: (event: Leaflet.Event) => void;
}
interface MapProps extends React.HTMLProps<Map>, LeafletLayerEvents, LeafletMapStateChangeEvents, LeafletPopupEvents, LeafletTooltipEvents, LeafletLocationEvents, LeafletInteractionEvents, LeafletOtherEvents, Leaflet.MapOptions {
animate?: boolean;
bounds?: Leaflet.LatLngBoundsExpression;
boundsOptions?: Leaflet.FitBoundsOptions;
className?: string;
style?: React.CSSProperties;
useFlyTo?: boolean;
id?: string;
}
declare type Map = React.ComponentClass<MapProps>;
declare const Map: Map;
interface MapInstance extends React.Component<MapProps, {}> {
leafletElement: Leaflet.Map;
}
interface PaneProps {
name?: string;
style?: React.CSSProperties;
className?: string;
}
declare const Pane: React.ComponentClass<PaneProps>;
//There is no Layer class, these are the base props for all layers on the map
interface LayerProps {
onadd?: (event: Leaflet.Event) => void;
onremove?: (event: Leaflet.Event) => void;
//Popup events
onpopupopen?: (event: Leaflet.PopupEvent) => void;
onpopupclose?: (event: Leaflet.PopupEvent) => void;
//Tooltip events
ontooltipopen?: (event: Leaflet.TooltipEvent) => void;
ontooltipclose?: (event: Leaflet.TooltipEvent) => void;
}
interface MarkerProps extends LayerProps, LeafletInteractionEvents, LeafletDraggingEvents {
position: Leaflet.LatLngExpression;
draggable?: boolean;
icon?: Leaflet.Icon;
zIndexOffset?: number;
opacity?: number;
}
declare const Marker: React.ComponentClass<MarkerProps>;
interface MarkerInstance extends React.Component<MarkerProps, {}> {
leafletElement: Leaflet.Marker;
}
interface PopupProps extends LayerProps, Leaflet.PopupOptions {
position?: Leaflet.LatLngExpression;
}
declare const Popup: React.ComponentClass<PopupProps>;
//tslint:disable-next-line:no-empty-interface
interface TooltipProps extends LayerProps, Leaflet.TooltipOptions { }
declare const Tooltip: React.ComponentClass<TooltipProps>;
interface GridLayerProps extends LayerProps {
opacity?: number;
zIndex?: number;
onloading?: (event: Leaflet.Event) => void;
ontileunload?: (event: Leaflet.TileEvent) => void;
ontileloadstart?: (event: Leaflet.TileEvent) => void;
ontileerror?: (event: Leaflet.TileErrorEvent) => void;
ontileload?: (event: Leaflet.TileEvent) => void;
onload?: (event: Leaflet.Event) => void;
}
declare const GridLayer: React.ComponentClass<GridLayerProps>;
interface TileLayerProps extends GridLayerProps, Leaflet.TileLayerOptions {
url: string;
}
declare const TileLayer: React.ComponentClass<TileLayerProps>;
interface ImageOverlayProps extends LayerProps, LeafletInteractionEvents {
url: string;
opacity?: string;
}
declare const ImageOverlay: React.ComponentClass<ImageOverlayProps>;
interface WMSTileLayerProps extends TileLayerProps {
url: string;
}
declare const WMSTileLayer: React.ComponentClass<WMSTileLayerProps>;
//Path is an abstract class
//tslint:disable-next-line:no-empty-interface
interface PathProps extends LeafletLayerEvents, LeafletInteractionEvents, Leaflet.PathOptions {
}
interface CircleProps extends PathProps {
center: Leaflet.LatLngExpression;
radius?: number;
}
declare const Circle: React.ComponentClass<CircleProps>;
interface CircleMarkerProps extends PathProps {
center: Leaflet.LatLngExpression;
radius?: number;
}
declare const CircleMarker: React.ComponentClass<CircleMarkerProps>;
interface PolylineProps extends PathProps {
positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][];
}
declare const Polyline: React.ComponentClass<PolylineProps>;
interface PolygonProps extends PathProps {
positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][] | Leaflet.LatLngExpression[][][];
}
declare const Polygon: React.ComponentClass<PolygonProps>;
interface RectangleProps extends PathProps {
bounds: Leaflet.LatLngBoundsExpression;
}
declare const Rectangle: React.ComponentClass<RectangleProps>;
//tslint:disable-next-line:no-empty-interface
interface LayerGroupProps extends LayerProps { }
declare const LayerGroup: React.ComponentClass<LayerGroupProps>;
//tslint:disable-next-line:no-empty-interface
interface FeatureGroupProps extends LayerGroupProps, Leaflet.PathOptions { }
declare const FeatureGroup: React.ComponentClass<FeatureGroupProps>;
interface GeoJSONProps extends FeatureGroupProps {
data: GeoJSON.GeoJsonObject;
}
declare const GeoJSON: React.ComponentClass<GeoJSONProps>;
interface AttributionControlProps {
position?: Leaflet.ControlPosition;
}
declare const AttributionControl: React.ComponentClass<AttributionControlProps>;
interface LayersControlProps {
position?: Leaflet.ControlPosition;
}
declare const LayersControl: React.ComponentClass<LayersControlProps> & { BaseLayer: LayersControl.BaseLayer, Overlay: LayersControl.Overlay };
declare namespace LayersControl {
interface LayersControlLayerProps {
name: string;
checked?: boolean;
}
type BaseLayer = React.ComponentClass<LayersControlLayerProps>;
type Overlay = React.ComponentClass<LayersControlLayerProps>;
}
interface ScaleControlProps {
position: Leaflet.ControlPosition;
}
declare const ScaleControl: React.ComponentClass<ScaleControlProps>;
interface ZoomControlProps {
position: Leaflet.ControlPosition;
}
declare const ZoomControl: React.ComponentClass<ZoomControlProps>;
+589
View File
@@ -0,0 +1,589 @@
import * as React from 'react';
import * as Leaflet from 'leaflet';
import { Component, PropTypes } from 'react';
import {
Circle,
CircleMarker,
FeatureGroup,
LayerGroup,
LayersControl,
Map,
MapInstance,
Marker,
MarkerInstance,
Pane,
Polygon,
Polyline,
Popup,
Rectangle,
TileLayer,
Tooltip,
WMSTileLayer,
ZoomControl
} from 'react-leaflet';
const { BaseLayer, Overlay } = LayersControl;
///animate.js
export class AnimateExample extends Component<any, any> {
state = {
animate: false,
hasLocation: false,
latlng: {
lat: 51.505,
lng: -0.09,
},
}
handleClick = (e: Leaflet.MouseEvent) => {
this.setState({
latlng: e.latlng,
})
}
toggleAnimate = () => {
this.setState({
animate: !this.state.animate,
})
}
render() {
const marker = this.state.hasLocation ? (
<Marker position={this.state.latlng}>
<Popup>
<span>You are here</span>
</Popup>
</Marker>
) : null
return (
<div style={{ textAlign: 'center' }}>
<label>
<input checked={this.state.animate} onChange={this.toggleAnimate} type='checkbox' />
Animate panning
</label>
<Map
animate={this.state.animate}
center={this.state.latlng}
//TODO length={4}
onclick={this.handleClick}
ref='map'
zoom={13}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
{marker}
</Map>
</div>
)
}
}
//bounds.js
const outer: Array<[number, number]> = [
[50.505, -29.09],
[52.505, 29.09],
]
const inner: Array<[number, number]> = [
[49.505, -2.09],
[53.505, 2.09],
]
export class BoundsExample extends Component<any, any> {
state = {
bounds: outer,
}
onClickInner = () => {
this.setState({ bounds: inner })
}
onClickOuter = () => {
this.setState({ bounds: outer })
}
render() {
return (
<Map bounds={this.state.bounds}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<Rectangle
bounds={outer}
color={this.state.bounds === outer ? 'red' : 'white'}
onclick={this.onClickOuter}
/>
<Rectangle
bounds={inner}
color={this.state.bounds === inner ? 'red' : 'white'}
onclick={this.onClickInner}
/>
</Map>
)
}
}
//custom-component.js
const SomeFn = (asd: string) => (
asd + asd
)
const MyPopupMarker = ({ children, position }: any) => (
<Marker position={position}>
<Popup>
<span>{children}</span>
</Popup>
</Marker>
);
/*(MyPopupMarker as any).propTypes = {
children: MapPropTypes.children,
position: MapPropTypes.latlng,
}*/
const MyMarkersList = ({ markers }: any) => {
const items = markers.map(({ key, ...props }: any) => (
<MyPopupMarker key={key} {...props} />
))
return <div style={{ display: 'none' }}>{items}</div>
}
(MyMarkersList as any).propTypes = {
markers: PropTypes.array.isRequired,
}
export class CustomComponent extends Component<any, any> {
state = {
lat: 51.505,
lng: -0.09,
zoom: 13,
};
render() {
const center: [number, number] = [this.state.lat, this.state.lng]
const markers = [
{ key: 'marker1', position: [51.5, -0.1], children: 'My first popup' },
{ key: 'marker2', position: [51.51, -0.1], children: 'My second popup' },
{ key: 'marker3', position: [51.49, -0.05], children: 'My third popup' },
]
return (
<Map center={center} zoom={this.state.zoom}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<MyMarkersList markers={markers} />
</Map>
)
}
}
//draggable-marker.js
export class DraggableExample extends Component<any, any> {
state = {
center: {
lat: 51.505,
lng: -0.09,
},
marker: {
lat: 51.505,
lng: -0.09,
},
zoom: 13,
draggable: true,
}
toggleDraggable = () => {
this.setState({ draggable: !this.state.draggable })
}
updatePosition = () => {
const { lat, lng } = (this.refs['marker'] as MarkerInstance).leafletElement.getLatLng()
this.setState({
marker: { lat, lng },
})
}
render() {
const position: [number, number] = [this.state.center.lat, this.state.center.lng]
const markerPosition: [number, number] = [this.state.marker.lat, this.state.marker.lng]
return (
<Map center={position} zoom={this.state.zoom}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<Marker
draggable={this.state.draggable}
ondragend={this.updatePosition}
position={markerPosition}
ref='marker'>
<Popup minWidth={90}>
<span onClick={this.toggleDraggable}>
{this.state.draggable ? 'DRAG MARKER' : 'MARKER FIXED'}
</span>
</Popup>
</Marker>
</Map>
)
}
}
//events.js
export class EventsExample extends Component<any, any> {
state = {
hasLocation: false,
latlng: {
lat: 51.505,
lng: -0.09,
},
}
handleClick = () => {
(this.refs['map'] as MapInstance).leafletElement.locate()
}
handleLocationFound = (e: Leaflet.LocationEvent) => {
this.setState({
hasLocation: true,
latlng: e.latlng,
})
}
render() {
const marker = this.state.hasLocation ? (
<Marker position={this.state.latlng}>
<Popup>
<span>You are here</span>
</Popup>
</Marker>
) : null
return (
<Map
center={this.state.latlng}
//TODO length={4}
onClick={this.handleClick}
onlocationfound={this.handleLocationFound}
ref='map'
zoom={13}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
{marker}
</Map>
)
}
}
//layers-control.js
export class LayersControlExample extends Component<any, any> {
render() {
const center: [number, number] = [51.505, -0.09]
const rectangle: Array<[number, number]> = [
[51.49, -0.08],
[51.5, -0.06],
]
return (
<Map center={center} zoom={13}>
<LayersControl position='topright'>
<BaseLayer checked name='OpenStreetMap.Mapnik'>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
</BaseLayer>
<BaseLayer name='OpenStreetMap.BlackAndWhite'>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png'
/>
</BaseLayer>
<Overlay name='Marker with popup'>
<Marker position={center}>
<Popup>
<span>A pretty CSS3 popup. <br /> Easily customizable.</span>
</Popup>
</Marker>
</Overlay>
<Overlay checked name='Layer group with circles'>
<LayerGroup>
<Circle center={center} fillColor='blue' radius={200} />
<Circle center={center} fillColor='red' radius={100} stroke={false} />
<LayerGroup>
<Circle center={[51.51, -0.08]} color='green' fillColor='green' radius={100} />
</LayerGroup>
</LayerGroup>
</Overlay>
<Overlay name='Feature group'>
<FeatureGroup color='purple'>
<Popup>
<span>Popup in FeatureGroup</span>
</Popup>
<Circle center={[51.51, -0.06]} radius={200} />
<Rectangle bounds={rectangle} />
</FeatureGroup>
</Overlay>
</LayersControl>
</Map>
)
}
}
//other-layers.js
export class OtherLayersExample extends Component<any, any> {
render() {
const center: [number, number] = [51.505, -0.09]
const rectangle: Array<[number, number]> = [
[51.49, -0.08],
[51.5, -0.06],
]
return (
<Map center={center} zoom={13}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<LayerGroup>
<Circle center={center} fillColor='blue' radius={200} />
<Circle center={center} fillColor='red' radius={100} stroke={false} />
<LayerGroup>
<Circle center={[51.51, -0.08]} color='green' fillColor='green' radius={100} />
</LayerGroup>
</LayerGroup>
<FeatureGroup color='purple'>
<Popup>
<span>Popup in FeatureGroup</span>
</Popup>
<Circle center={[51.51, -0.06]} radius={200} />
<Rectangle bounds={rectangle} />
</FeatureGroup>
</Map>
)
}
}
//pane.js
export class PaneExample extends Component<any, any> {
state = {
render: true,
}
componentDidMount() {
setInterval(() => {
this.setState({
render: !this.state.render,
})
}, 5000)
}
render() {
return (
<Map bounds={outer}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
{this.state.render ? (
<Pane name='cyan-rectangle' style={{ zIndex: 500 }}>
<Rectangle bounds={outer} color='cyan' />
</Pane>
) : null}
<Pane name='yellow-rectangle' style={{ zIndex: 499 }}>
<Rectangle bounds={inner} color='yellow' />
<Pane name='purple-rectangle' className='purplePane-purplePane'>
<Rectangle bounds={outer} color='purple' />
</Pane>
</Pane>
</Map>
)
}
}
//simple.js
export class SimpleExample extends Component<any, any> {
state = {
lat: 51.505,
lng: -0.09,
zoom: 13,
}
render() {
const position: [number, number] = [this.state.lat, this.state.lng]
return (
<Map center={position} zoom={this.state.zoom}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<Marker position={position}>
<Popup>
<span>A pretty CSS3 popup. <br /> Easily customizable.</span>
</Popup>
</Marker>
</Map>
)
}
}
//tooltip.js
export class TooltipExample extends Component<any, any> {
state = {
clicked: 0,
}
onClickCircle = () => {
this.setState({ clicked: this.state.clicked + 1 })
}
render() {
const center: [number, number] = [51.505, -0.09]
const multiPolygon: Array<Array<[number, number]>> = [
[[51.51, -0.12], [51.51, -0.13], [51.53, -0.13]],
[[51.51, -0.05], [51.51, -0.07], [51.53, -0.07]],
]
const rectangle: Array<[number, number]> = [
[51.49, -0.08],
[51.5, -0.06],
]
const clickedText = this.state.clicked === 0
? 'Click this Circle to change the Tooltip text'
: `Circle click: ${this.state.clicked}`
return (
<Map center={center} zoom={13}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<Circle center={center} fillColor='blue' onclick={this.onClickCircle} radius={200}>
<Tooltip>
<span>{clickedText}</span>
</Tooltip>
</Circle>
<CircleMarker center={[51.51, -0.12]} color='red' radius={20}>
<Tooltip>
<span>Tooltip for CircleMarker</span>
</Tooltip>
</CircleMarker>
<Polygon color='purple' positions={multiPolygon}>
<Tooltip sticky>
<span>sticky Tooltip for Polygon</span>
</Tooltip>
</Polygon>
<Rectangle bounds={rectangle} color='black'>
<Tooltip direction='bottom' offset={[0, 20]} opacity={1} permanent>
<span>permanent Tooltip for Rectangle</span>
</Tooltip>
</Rectangle>
</Map>
)
}
}
//vector-layers.js
export class VectorLayersExample extends Component<any, any> {
render() {
const center: [number, number] = [51.505, -0.09]
const polyline: Array<[number, number]> = [
[51.505, -0.09],
[51.51, -0.1],
[51.51, -0.12],
]
const multiPolyline: Array<Array<[number, number]>> = [
[[51.5, -0.1], [51.5, -0.12], [51.52, -0.12]],
[[51.5, -0.05], [51.5, -0.06], [51.52, -0.06]],
]
const polygon: Array<[number, number]> = [
[51.515, -0.09],
[51.52, -0.1],
[51.52, -0.12],
]
const multiPolygon: Array<Array<[number, number]>> = [
[[51.51, -0.12], [51.51, -0.13], [51.53, -0.13]],
[[51.51, -0.05], [51.51, -0.07], [51.53, -0.07]],
]
const rectangle: Array<[number, number]> = [
[51.49, -0.08],
[51.5, -0.06],
]
return (
<Map center={center} zoom={13}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<Circle center={center} fillColor='blue' radius={200} />
<CircleMarker center={[51.51, -0.12]} color='red' radius={20}>
<Popup>
<span>Popup in CircleMarker</span>
</Popup>
</CircleMarker>
<Polyline color='lime' positions={polyline} />
<Polyline color='lime' positions={multiPolyline} />
<Polygon color='purple' positions={polygon} />
<Polygon color='purple' positions={multiPolygon} />
<Rectangle bounds={rectangle} color='black' />
</Map>
)
}
}
//wms-tile-layer.js
export class WMSTileLayerExample extends Component<any, any> {
state = {
lat: 51.505,
lng: -0.09,
zoom: 5,
bluemarble: false,
}
onClick = () => {
this.setState({
bluemarble: !this.state.bluemarble,
})
}
render() {
return (
<Map
center={[this.state.lat, this.state.lng]}
zoom={this.state.zoom}
onClick={this.onClick}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<WMSTileLayer
layers={this.state.bluemarble ? 'nasa:bluemarble' : 'ne:ne'}
url='http://demo.opengeo.org/geoserver/ows?'
/>
</Map>
)
}
}
//zoom-control.js
const ZoomControlExample = () => (
<Map center={[51.505, -0.09]} zoom={13} zoomControl={false}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
<ZoomControl position='topright' />
</Map>
)
+21
View File
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"jsx": "react",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-leaflet-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+5 -2
View File
@@ -5,8 +5,11 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"jsx": "preserve",
"baseUrl": "../",
"paths": {
"history": ["history/v2"]
},
"typeRoots": [
"../"
],
@@ -18,4 +21,4 @@
"index.d.ts",
"react-router-bootstrap-tests.tsx"
]
}
}
+1 -1
View File
@@ -2,4 +2,4 @@
"dependencies": {
"redux": "^3.6.0"
}
}
}
+3
View File
@@ -10,6 +10,9 @@
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"paths": {
"history": ["history/v2"]
},
"typeRoots": [
"../"
],
+3 -2
View File
@@ -9,10 +9,11 @@
"typeRoots": [
"../../"
],
"types": [],
"paths": {
"history": ["history/v2"],
"react-router-redux": ["react-router-redux/v3"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
@@ -20,4 +21,4 @@
"index.d.ts",
"react-router-redux-tests.ts"
]
}
}
+5 -2
View File
@@ -9,8 +9,11 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"jsx": "react",
"baseUrl": "../",
"paths": {
"history": ["history/v2"]
},
"typeRoots": [
"../"
],
@@ -18,4 +21,4 @@
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}
}
+1 -1
View File
@@ -2,4 +2,4 @@
"dependencies": {
"redux": "^3.6.0"
}
}
}
+4 -1
View File
@@ -6,6 +6,9 @@
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"paths": {
"history": ["history/v2"]
},
"typeRoots": [
"../"
],
@@ -18,4 +21,4 @@
"index.d.ts",
"redux-bootstrap-tests.tsx"
]
}
}
+1 -1
View File
@@ -2,4 +2,4 @@
"dependencies": {
"redux": "^3.6.0"
}
}
}
+4 -1
View File
@@ -6,6 +6,9 @@
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"paths": {
"history": ["history/v2"]
},
"typeRoots": [
"../"
],
@@ -17,4 +20,4 @@
"index.d.ts",
"redux-router-tests.ts"
]
}
}
+13 -13
View File
@@ -4,7 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import {RequestHandler, Server, Request, Response, Route} from 'restify';
import * as bunyan from 'bunyan';
import Logger = require('bunyan');
//*************** This module includes the follow pre plugins, which are intended to be used prior to the routing of a request:
@@ -15,7 +15,7 @@ export namespace pre {
function context(): RequestHandler;
/**
*
*
*/
function dedupeSlashes(): RequestHandler;
@@ -56,7 +56,7 @@ interface AuditLoggerOptions {
/**
* Bunyan logger
*/
log: bunyan.Logger;
log: Logger;
/**
* Restify server. If passed in, causes server to emit 'auditlog' event after audit logs are flushed
@@ -74,7 +74,7 @@ interface AuditLoggerOptions {
printLog?: boolean;
/**
*
*
*/
body?: boolean;
}
@@ -165,12 +165,12 @@ interface BodyParserOptions {
rejectUnknown?: boolean;
/**
*
*
*/
reviver?: any;
/**
*
*
*/
maxFieldsSize?: number;
}
@@ -192,7 +192,7 @@ interface UrlEncodedBodyParser {
/**
* Parse the HTTP request body IFF the contentType is application/x-www-form-urlencoded.
*
*
* If req.params already contains a given key, that key is skipped and an
* error is logged.
*/
@@ -287,7 +287,7 @@ interface RequestLogger {
/**
* Adds timers for each handler in your request chain
*
*
* `options.properties` properties to pass to bunyan's `log.child()` method
*/
export function requestLogger(options?: RequestLogger): RequestHandler;
@@ -341,7 +341,7 @@ interface MetricsCallback {
err: Error;
/**
*
*
*/
metrics: MetricsCallbackOptions;
@@ -380,7 +380,7 @@ interface MetricsCallbackOptions {
/**
* If this value is set, err will be a corresponding `RequestCloseError` or `RequestAbortedError`.
*
*
* If connectionState is either 'close' or 'aborted', then the statusCode is not applicable since the connection was severed before a response was written.
*/
connectionState: TMetricsCallback;
@@ -395,7 +395,7 @@ interface MetricsReturns {
/**
* Listens to the server's after event and emits information about that request (5.x compatible only).
*
*
* ```
* server.on('after', plugins.metrics( (err, metrics) =>
* {
@@ -407,7 +407,7 @@ export function metrics(opts: {server: Server}, callback: (options: MetricsCallb
/**
* Parse the client's request for an OAUTH2 access tokensTable
*
*
* Subsequent handlers will see `req.oauth2`, which looks like:
* ```
* {
@@ -441,7 +441,7 @@ interface RequestExpiryOptions {
/**
* A request expiry will use headers to tell if the incoming request has expired or not.
*
*
* There are two options for this plugin:
* 1. Absolute Time
* * Time in Milliseconds since the Epoch when this request should be considered expired
+3 -3
View File
@@ -6,7 +6,7 @@
/// <reference types="node" />
import http = require('http');
import bunyan = require('bunyan');
import Logger = require('bunyan');
import url = require('url');
@@ -196,7 +196,7 @@ interface Request extends http.IncomingMessage {
*/
href: () => string;
log: bunyan.Logger;
log: Logger;
/**
* retrieves the request uuid. was created when the request was setup.
* @public
@@ -486,7 +486,7 @@ interface HttpClient extends Client {
patch: (opts?: string | { path?: string; [name: string]: any }, callback?: Function) => any;
del: (opts?: string | { path?: string; [name: string]: any }, callback?: Function) => any;
}
interface ThrottleOptions {
burst?: number;
rate?: number;
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for webpack-notifier 1.5
// Project: https://github.com/Turbo87/webpack-notifier#readme
// Definitions by: Benjamin Lim <https://github.com/bumbleblym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, Webpack } from 'webpack';
export = WebpackNotifierPlugin;
declare class WebpackNotifierPlugin implements Plugin {
constructor(options?: WebpackNotifierPlugin.Config);
apply(thisArg: Webpack, ...args: any[]): void;
}
declare namespace WebpackNotifierPlugin {
export interface Config {
title?: string;
contentImage?: string;
excludeWarnings?: boolean;
alwaysNotify?: boolean;
skipFirstNotification?: boolean;
}
}
+20
View File
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"webpack-notifier-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
@@ -0,0 +1,14 @@
import WebpackNotifierPlugin = require('webpack-notifier');
import { Plugin } from 'webpack';
const configs: Array<WebpackNotifierPlugin.Config> = [
{
title: 'Webpack',
contentImage: 'logo.png',
excludeWarnings: true,
alwaysNotify: true,
skipFirstNotification: true,
},
];
const plugins: Array<Plugin> = configs.map(config => new WebpackNotifierPlugin(config));