Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Troy Weber
2017-03-21 10:01:14 -07:00
24 changed files with 1067 additions and 1702 deletions
+2
View File
@@ -80,6 +80,8 @@ declare global {
// then: typeof Bluebird.prototype.then;
thenReturn: typeof Bluebird.prototype.thenReturn;
thenThrow: typeof Bluebird.prototype.thenThrow;
catchReturn: typeof Bluebird.prototype.catchReturn;
catchThrow: typeof Bluebird.prototype.catchThrow;
throw: typeof Bluebird.prototype.throw;
timeout: typeof Bluebird.prototype.timeout;
toJSON: typeof Bluebird.prototype.toJSON;
+9
View File
@@ -506,6 +506,15 @@ fooProm = fooProm.thenThrow(err);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.catchReturn(bar);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooProm
fooProm = fooProm.catchThrow(err);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
str = fooProm.toString();
obj = fooProm.toJSON();
+31
View File
@@ -248,6 +248,37 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
throw(reason: Error): Bluebird<R>;
thenThrow(reason: Error): Bluebird<R>;
/**
* Convenience method for:
*
* <code>
* .catch(function() {
* return value;
* });
* </code>
*
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.catchReturn()`
*/
catchReturn<U>(value: U): Bluebird<U>;
catchReturn<U>(predicate: (error: any) => boolean, value: U): Bluebird<U | R>;
catchReturn<E extends Error, U>(ErrorClass: new (...args: any[]) => E, value: U): Bluebird<U | R>;
catchReturn<U>(predicate: Object, value: U): Bluebird<U | R>;
/**
* Convenience method for:
*
* <code>
* .catch(function() {
* throw reason;
* });
* </code>
* Same limitations apply as with `.catchReturn()`.
*/
catchThrow(reason: Error): Bluebird<R>;
catchThrow(predicate: (error: any) => boolean, reason: Error): Bluebird<R>;
catchThrow<E extends Error, U>(ErrorClass: new (...args: any[]) => E, reason: Error): Bluebird<R>;
catchThrow(predicate: Object, reason: Error): Bluebird<R>;
/**
* Convert to String.
*/
+14
View File
@@ -37,6 +37,13 @@ namespace ShallowWrapperTest {
elementWrapper: ShallowWrapper<HTMLAttributes<{}>, {}>,
statelessWrapper: ShallowWrapper<StatelessProps, never>;
function test_props_state_inferring() {
let wrapper: ShallowWrapper<MyComponentProps, MyComponentState>;
wrapper = shallow(<MyComponent stringProp="value" />);
wrapper.state().stateProperty;
wrapper.props().stringProp.toUpperCase();
}
function test_shallow_options() {
shallow(<MyComponent stringProp="1"/>, {
context: {
@@ -337,6 +344,13 @@ namespace ReactWrapperTest {
elementWrapper: ReactWrapper<HTMLAttributes<{}>, {}>,
statelessWrapper: ReactWrapper<StatelessProps, never>;
function test_prop_state_inferring() {
let wrapper: ReactWrapper<MyComponentProps, MyComponentState>;
wrapper = mount(<MyComponent stringProp="value" />);
wrapper.state().stateProperty;
wrapper.props().stringProp.toUpperCase();
}
function test_unmount() {
reactWrapper = reactWrapper.unmount();
}
+2
View File
@@ -546,6 +546,7 @@ export interface MountRendererProps {
* @param node
* @param [options]
*/
export function shallow<P>(node: ReactElement<P>, options?: ShallowRendererProps): ShallowWrapper<P, any>;
export function shallow<P, S>(node: ReactElement<P>, options?: ShallowRendererProps): ShallowWrapper<P, S>;
/**
@@ -553,6 +554,7 @@ export function shallow<P, S>(node: ReactElement<P>, options?: ShallowRendererPr
* @param node
* @param [options]
*/
export function mount<P>(node: ReactElement<P>, options?: MountRendererProps): ReactWrapper<P, any>;
export function mount<P, S>(node: ReactElement<P>, options?: MountRendererProps): ReactWrapper<P, S>;
/**
+1 -1
View File
@@ -2276,7 +2276,7 @@ declare namespace google.maps {
}
export interface PlaceDetailsRequest {
placeId: string;
placeid: string;
}
export interface PlaceGeometry {
+852 -851
View File
File diff suppressed because it is too large Load Diff
-115
View File
@@ -1,115 +0,0 @@
// Type definitions for Mozilla's localForage
// Project: https://github.com/mozilla/localforage
// Definitions by: yuichi david pichsenmeister <https://github.com/3x14159265>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface LocalForageOptions {
driver?: string | LocalForageDriver | LocalForageDriver[];
name?: string;
size?: number;
storeName?: string;
version?: number;
description?: string;
}
interface LocalForageDbMethods {
getItem<T>(key: string): Promise<T>;
getItem<T>(key: string, callback: (err: any, value: T) => void): void;
setItem<T>(key: string, value: T): Promise<T>;
setItem<T>(key: string, value: T, callback: (err: any, value: T) => void): void;
removeItem(key: string): Promise<void>;
removeItem(key: string, callback: (err: any) => void): void;
clear(): Promise<void>;
clear(callback: (err: any) => void): void;
length(): Promise<number>;
length(callback: (err: any, numberOfKeys: number) => void): void;
key(keyIndex: number): Promise<string>;
key(keyIndex: number, callback: (err: any, key: string) => void): void;
keys(): Promise<string[]>;
keys(callback: (err: any, keys: string[]) => void): void;
iterate(iteratee: (value: any, key: string, iterationNumber: number) => any): Promise<any>;
iterate(iteratee: (value: any, key: string, iterationNumber: number) => any,
callback: (err: any, result: any) => void): void;
}
interface LocalForageDriverSupportFunc {
(): Promise<boolean>;
}
interface LocalForageDriver extends LocalForageDbMethods {
_driver: string;
_initStorage(options: LocalForageOptions): void;
_support?: boolean | LocalForageDriverSupportFunc;
}
interface LocalForageSerializer {
serialize<T>(value: T | ArrayBuffer | Blob, callback: (value: string, error: any) => void): void;
deserialize<T>(value: string): T | ArrayBuffer | Blob;
stringToBuffer(serializedString: string): ArrayBuffer;
bufferToString(buffer: ArrayBuffer): string;
}
interface LocalForage extends LocalForageDbMethods {
LOCALSTORAGE: string;
WEBSQL: string;
INDEXEDDB: string;
/**
* Set and persist localForage options. This must be called before any other calls to localForage are made, but can be called after localForage is loaded.
* If you set any config values with this method they will persist after driver changes, so you can call config() then setDriver()
* @param {LocalForageOptions} options?
*/
config(options: LocalForageOptions): boolean;
/**
* Create a new instance of localForage to point to a different store.
* All the configuration options used by config are supported.
* @param {LocalForageOptions} options
*/
createInstance(options: LocalForageOptions): LocalForage;
driver(): string;
/**
* Force usage of a particular driver or drivers, if available.
* @param {string} driver
*/
setDriver(driver: string | string[]): Promise<void>;
setDriver(driver: string | string[], callback: () => void, errorCallback: (error: any) => void): void;
defineDriver(driver: LocalForageDriver): Promise<void>;
defineDriver(driver: LocalForageDriver, callback: () => void, errorCallback: (error: any) => void): void;
/**
* Return a particular driver
* @param {string} driver
*/
getDriver(driver: string): Promise<LocalForageDriver>;
getSerializer(): Promise<LocalForageSerializer>;
getSerializer(callback: (serializer: LocalForageSerializer) => void): void;
supports(driverName: string): boolean;
ready(callback: () => void): void;
ready(): Promise<void>;
}
declare module "localforage" {
let localforage: LocalForage;
export = localforage;
}
-117
View File
@@ -1,117 +0,0 @@
declare let localForage: LocalForage;
namespace LocalForageTest {
localForage.clear((err: any) => {
let newError: any = err;
});
localForage.iterate((str: string, key: string, num: number) => {
let newStr: string = str;
let newKey: string = key;
let newNum: number = num;
});
localForage.length((err: any, num: number) => {
let newError: any = err;
let newNumber: number = num;
});
localForage.length().then((num: number) => {
var newNumber: number = num;
});
localForage.key(0, (err: any, value: string) => {
let newError: any = err;
let newValue: string = value;
});
localForage.keys((err: any, keys: Array<string>) => {
let newError: any = err;
let newArray: Array<string> = keys;
});
localForage.keys().then((keys: Array<string>) => {
var newArray: Array<string> = keys;
});
localForage.getItem("key",(err: any, str: string) => {
let newError: any = err;
let newStr: string = str
});
localForage.getItem<string>("key").then((str: string) => {
let newStr: string = str;
});
localForage.setItem("key", "value",(err: any, str: string) => {
let newError: any = err;
let newStr: string = str
});
localForage.setItem("key", "value").then((str: string) => {
let newStr: string = str;
});
localForage.removeItem("key",(err: any) => {
let newError: any = err;
});
localForage.removeItem("key").then(() => {
});
localForage.getDriver("CustomDriver").then((result: LocalForageDriver) => {
var driver: LocalForageDriver = result;
// we need to use a variable for proper type guards before TS 2.0
var _support = driver._support;
if (typeof _support === "function") {
// _support = _support.bind(driver);
_support().then((result: boolean) => {
let doesSupport: boolean = result;
});
} else if (typeof _support === "boolean") {
let doesSupport: boolean = _support;
}
});
{
let config: boolean;
config = localForage.config({
name: "testyo",
driver: localForage.LOCALSTORAGE
});
}
{
let store: LocalForage;
store = localForage.createInstance({
name: "da instance",
driver: localForage.LOCALSTORAGE
});
}
{
let testSerializer: LocalForageSerializer;
localForage.getSerializer()
.then((serializer: LocalForageSerializer) => {
testSerializer = serializer;
});
localForage.getSerializer((serializer: LocalForageSerializer) => {
testSerializer = serializer;
});
}
{
let store: LocalForage;
store.ready()
.then(() => {});
store.ready(() => {});
}
}
-23
View File
@@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"localforage-tests.ts"
]
}
+18
View File
@@ -5,6 +5,12 @@
"typingsPackageName": "ajv",
"sourceRepoURL": "https://github.com/epoberezkin/ajv",
"asOfVersion": "1.0.0"
},
{
"libraryName": "Numbro",
"typingsPackageName": "numbro",
"sourceRepoURL": "https://github.com/foretagsplatsen/numbro/",
"asOfVersion": "1.9.3"
},
{
"libraryName": "antd",
@@ -156,6 +162,12 @@
"sourceRepoURL": "https://github.com/brunolm/LinqSharp",
"asOfVersion": "1.0.0"
},
{
"libraryName": "localforage",
"typingsPackageName": "localforage",
"sourceRepoURL": "https://github.com/localForage/localForage",
"asOfVersion": "0.0.34"
},
{
"libraryName": "lower-case",
"typingsPackageName": "lower-case",
@@ -342,6 +354,12 @@
"sourceRepoURL": "https://github.com/vuejs/vue-router",
"asOfVersion": "2.0.0"
},
{
"libraryName": "x2js",
"typingsPackageName": "x2js",
"sourceRepoURL": "https://code.google.com/p/x2js/",
"asOfVersion": "3.1.0"
},
{
"libraryName": "@xmpp/jid",
"typingsPackageName": "xmpp-jid",
-49
View File
@@ -1,49 +0,0 @@
// Type definitions for Numbro.js
// Project: https://github.com/foretagsplatsen/numbro
// Definitions by: Vincent Bortone <https://github.com/vbortone/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface NumbroLanguage {
delimiters: {
thousands: string;
decimal: string;
};
abbreviations: {
thousand: string;
million: string;
billion: string;
trillion: string;
};
ordinal(num: number): string;
currency: {
symbol: string;
};
}
interface Numbro {
(value?: any): Numbro;
version: string;
isNumbro: boolean;
language(key: string, values?: NumbroLanguage): Numbro;
zeroFormat(format: string): string;
clone(): Numbro;
format(inputString?: string): string;
formatCurrency(inputString?: string): string;
unformat(inputString: string): number;
value(): number;
valueOf(): number;
set (value: any): Numbro;
add(value: any): Numbro;
subtract(value: any): Numbro;
multiply(value: any): Numbro;
divide(value: any): Numbro;
difference(value: any): number;
}
declare var numbro: Numbro;
declare module "numbro" {
export = numbro;
}
-43
View File
@@ -1,43 +0,0 @@
var valueFormat: string = numbro(1000).format('0,0');
// '1,000'
var valueUnformat: number = numbro().unformat('($10,000.00)');
// '-10000'
var value3: Numbro = numbro(1000);
var added: Numbro = value3.add(10);
// 1010
var value4: Numbro = numbro(1000);
var formatValue4a: string = value4.format('0,0');
// '1,000'
var formatValue4b: number = value4.value();
// 1000
var value5: Numbro = numbro();
value5.set(1000);
var value5Num: number = value5.value();
// 1000
var value6: Numbro = numbro(1000);
var value: number = 100;
var difference = value6.difference(value);
// 900
var value7: Numbro = numbro(0);
numbro.zeroFormat('N/A');
var zeroString: string = value7.format('0.0');
// 'N/A'
var a: Numbro = numbro(1000);
var b: Numbro = numbro(a);
var c: Numbro = a.clone();
var aVal: number = a.set(2000).value();
// 2000
var bVal: number = b.value();
// 1000
var cVal: number = c.add(10).value();
// 1010
-22
View File
@@ -1,22 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"numbro-tests.ts"
]
}
+13 -13
View File
@@ -1,10 +1,9 @@
// Type definitions for Platform 1.0.0
// Type definitions for Platform 1.3
// Project: https://github.com/bestiejs/platform.js
// Definitions by: Jake Hickman <https://github.com/JakeH/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface PlatformStatic {
declare interface Platform {
description?: string;
layout?: string;
manufacturer?: string;
@@ -13,18 +12,19 @@ interface PlatformStatic {
product?: string;
ua?: string;
version?: string;
os?: PlatformOS;
parse?(ua: string): PlatformStatic;
os?: {
architecture?: number;
family?: string;
version?: string;
toString(): string;
};
parse?(ua: string): Platform;
toString?(): string;
}
interface PlatformOS {
architecture?: number; //platform's docs say this is a string, but their code doesn't agree
family?: string;
version?: string;
toString(): string;
declare var platform: Platform;
declare module "platform" {
export = platform;
}
declare var platform: PlatformStatic;
+17 -25
View File
@@ -1,11 +1,8 @@
interface ITestContainer {
[name: string]: PlatformStatic;
interface TestContainer {
[name: string]: Platform;
}
var tests: ITestContainer = {
var tests: TestContainer = {
'Chrome Mobile 16.0.912.77 on Android 4.0.3': {
description: "Chrome Mobile 16.0.912.77 on Android 4.0.3",
layout: "WebKit",
@@ -40,41 +37,36 @@ var tests: ITestContainer = {
function runTests() {
var t: PlatformStatic;
var p: PlatformStatic;
var t: Platform;
var p: Platform;
var x: string;
var px: any;
var res: boolean;
var onFalse: (name: string) => () => any;
for (var n in tests) {
for (const [n, value] of Object.entries(tests)) {
t = tests[n];
p = platform.parse(t.ua);
onFalse = (name: string) => {
return () => {
console.log('\tfailed on prop "' + name + '" for "' + n + '"');
}
}
};
};
console.log('Starting tests for: ' + n);
falsy(() => { return t.description === p.description }, onFalse('description'));
falsy(() => { return t.layout === p.layout }, onFalse('layout'));
falsy(() => { return t.name === p.name }, onFalse('name'));
falsy(() => { return t.prerelease === p.prerelease }, onFalse('prerelease'));
falsy(() => { return t.ua === p.ua }, onFalse('ua'));
falsy(() => { return t.version === p.version }, onFalse('version'));
falsy(() => { return t.os.architecture === p.os.architecture }, onFalse('os.architecture'));
falsy(() => { return t.os.family === p.os.family }, onFalse('os.family'));
falsy(() => { return t.os.version === p.os.version }, onFalse('os.version'));
falsy(() => t.description === p.description, onFalse('description'));
falsy(() => t.layout === p.layout, onFalse('layout'));
falsy(() => t.name === p.name, onFalse('name'));
falsy(() => t.prerelease === p.prerelease, onFalse('prerelease'));
falsy(() => t.ua === p.ua, onFalse('ua'));
falsy(() => t.version === p.version, onFalse('version'));
falsy(() => t.os.architecture === p.os.architecture, onFalse('os.architecture'));
falsy(() => t.os.family === p.os.family, onFalse('os.family'));
falsy(() => t.os.version === p.os.version, onFalse('os.version'));
console.log('Finished tests for: ' + n);
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"es2017",
"dom"
],
"noImplicitAny": true,
+26 -23
View File
@@ -5,33 +5,36 @@
/// <reference types="jointjs" />
declare namespace joint {
namespace ui {
interface Handle {
name: string;
position: string;
icon: string;
}
import * as joint from 'jointjs';
import * as Backbone from "backbone";
class SelectionView extends Backbone.Model {
export as namespace joint;
export namespace ui {
interface Handle {
name: string;
position: string;
icon: string;
}
class SelectionView extends Backbone.Model {
paper: joint.dia.Paper;
graph: joint.dia.Graph;
model: Backbone.Collection<joint.dia.Cell>;
constructor(opt: {
paper: joint.dia.Paper;
graph: joint.dia.Graph;
model: Backbone.Collection<joint.dia.Cell>;
model: Backbone.Collection<joint.dia.Cell>
});
constructor(opt: {
paper: joint.dia.Paper;
graph: joint.dia.Graph;
model: Backbone.Collection<joint.dia.Cell>
});
createSelectionBox(cellView: joint.dia.CellView): void;
destroySelectionBox(cellView: joint.dia.CellView): void;
startSelecting(evt: any): void;
cancelSelection(): void;
createSelectionBox(cellView: joint.dia.CellView): void;
destroySelectionBox(cellView: joint.dia.CellView): void;
startSelecting(evt: any): void;
cancelSelection(): void;
addHandle(handle: Handle): void;
removeHandle(name: string): void;
changeHandle(name: string, handle: Handle): void;
}
addHandle(handle: Handle): void;
removeHandle(name: string): void;
changeHandle(name: string, handle: Handle): void;
}
}
+74 -57
View File
@@ -437,7 +437,7 @@ declare namespace React {
interface ChangeTargetHTMLProps<T extends HTMLElement> extends ChangeTargetHTMLAttributes<T>, ClassAttributes<T> {
}
interface SVGProps extends SVGAttributes<SVGElement>, ClassAttributes<SVGElement> {
interface SVGProps<T> extends SVGAttributes<T>, ClassAttributes<T> {
}
interface DOMAttributes<T> {
@@ -2211,7 +2211,25 @@ declare namespace React {
// - "number | string"
// - "string"
// - union of string literals
interface SVGAttributes<T> extends HTMLAttributes<T> {
interface SVGAttributes<T> extends DOMAttributes<T> {
// Attributes which also defined in HTMLAttributes
// See comment in SVGDOMPropertyConfig.js
className?: string;
color?: string;
height?: number | string;
id?: string;
lang?: string;
max?: number | string;
media?: string;
method?: string;
min?: number | string;
name?: string;
style?: CSSProperties;
target?: string;
type?: string;
width?: number | string;
// SVG Specific attributes
accentHeight?: number | string;
accumulate?: "none" | "sum";
additive?: "replace" | "sum";
@@ -2404,7 +2422,6 @@ declare namespace React {
textRendering?: number | string;
to?: number | string;
transform?: string;
type?: string;
u1?: number | string;
u2?: number | string;
underlinePosition?: number | string;
@@ -2802,61 +2819,61 @@ declare global {
wbr: React.HTMLProps<HTMLElement>;
// SVG
svg: React.SVGProps;
svg: React.SVGProps<SVGSVGElement>;
animate: React.SVGProps;
circle: React.SVGProps;
clipPath: React.SVGProps;
defs: React.SVGProps;
desc: React.SVGProps;
ellipse: React.SVGProps;
feBlend: React.SVGProps;
feColorMatrix: React.SVGProps;
feComponentTransfer: React.SVGProps;
feComposite: React.SVGProps;
feConvolveMatrix: React.SVGProps;
feDiffuseLighting: React.SVGProps;
feDisplacementMap: React.SVGProps;
feDistantLight: React.SVGProps;
feFlood: React.SVGProps;
feFuncA: React.SVGProps;
feFuncB: React.SVGProps;
feFuncG: React.SVGProps;
feFuncR: React.SVGProps;
feGaussianBlur: React.SVGProps;
feImage: React.SVGProps;
feMerge: React.SVGProps;
feMergeNode: React.SVGProps;
feMorphology: React.SVGProps;
feOffset: React.SVGProps;
fePointLight: React.SVGProps;
feSpecularLighting: React.SVGProps;
feSpotLight: React.SVGProps;
feTile: React.SVGProps;
feTurbulence: React.SVGProps;
filter: React.SVGProps;
foreignObject: React.SVGProps;
g: React.SVGProps;
image: React.SVGProps;
line: React.SVGProps;
linearGradient: React.SVGProps;
marker: React.SVGProps;
mask: React.SVGProps;
metadata: React.SVGProps;
path: React.SVGProps;
pattern: React.SVGProps;
polygon: React.SVGProps;
polyline: React.SVGProps;
radialGradient: React.SVGProps;
rect: React.SVGProps;
stop: React.SVGProps;
switch: React.SVGProps;
symbol: React.SVGProps;
text: React.SVGProps;
textPath: React.SVGProps;
tspan: React.SVGProps;
use: React.SVGProps;
view: React.SVGProps;
animate: React.SVGProps<SVGElement>; // TODO: It is SVGAnimateElement but is not in TypeScript's lib.dom.d.ts for now.
circle: React.SVGProps<SVGCircleElement>;
clipPath: React.SVGProps<SVGClipPathElement>;
defs: React.SVGProps<SVGDefsElement>;
desc: React.SVGProps<SVGDescElement>;
ellipse: React.SVGProps<SVGEllipseElement>;
feBlend: React.SVGProps<SVGFEBlendElement>;
feColorMatrix: React.SVGProps<SVGFEColorMatrixElement>;
feComponentTransfer: React.SVGProps<SVGFEComponentTransferElement>;
feComposite: React.SVGProps<SVGFECompositeElement>;
feConvolveMatrix: React.SVGProps<SVGFEConvolveMatrixElement>;
feDiffuseLighting: React.SVGProps<SVGFEDiffuseLightingElement>;
feDisplacementMap: React.SVGProps<SVGFEDisplacementMapElement>;
feDistantLight: React.SVGProps<SVGFEDistantLightElement>;
feFlood: React.SVGProps<SVGFEFloodElement>;
feFuncA: React.SVGProps<SVGFEFuncAElement>;
feFuncB: React.SVGProps<SVGFEFuncBElement>;
feFuncG: React.SVGProps<SVGFEFuncGElement>;
feFuncR: React.SVGProps<SVGFEFuncRElement>;
feGaussianBlur: React.SVGProps<SVGFEGaussianBlurElement>;
feImage: React.SVGProps<SVGFEImageElement>;
feMerge: React.SVGProps<SVGFEMergeElement>;
feMergeNode: React.SVGProps<SVGFEMergeNodeElement>;
feMorphology: React.SVGProps<SVGFEMorphologyElement>;
feOffset: React.SVGProps<SVGFEOffsetElement>;
fePointLight: React.SVGProps<SVGFEPointLightElement>;
feSpecularLighting: React.SVGProps<SVGFESpecularLightingElement>;
feSpotLight: React.SVGProps<SVGFESpotLightElement>;
feTile: React.SVGProps<SVGFETileElement>;
feTurbulence: React.SVGProps<SVGFETurbulenceElement>;
filter: React.SVGProps<SVGFilterElement>;
foreignObject: React.SVGProps<SVGForeignObjectElement>;
g: React.SVGProps<SVGGElement>;
image: React.SVGProps<SVGImageElement>;
line: React.SVGProps<SVGLineElement>;
linearGradient: React.SVGProps<SVGLinearGradientElement>;
marker: React.SVGProps<SVGMarkerElement>;
mask: React.SVGProps<SVGMaskElement>;
metadata: React.SVGProps<SVGMetadataElement>;
path: React.SVGProps<SVGPathElement>;
pattern: React.SVGProps<SVGPatternElement>;
polygon: React.SVGProps<SVGPolygonElement>;
polyline: React.SVGProps<SVGPolylineElement>;
radialGradient: React.SVGProps<SVGRadialGradientElement>;
rect: React.SVGProps<SVGRectElement>;
stop: React.SVGProps<SVGStopElement>;
switch: React.SVGProps<SVGSwitchElement>;
symbol: React.SVGProps<SVGSymbolElement>;
text: React.SVGProps<SVGTextElement>;
textPath: React.SVGProps<SVGTextPathElement>;
tspan: React.SVGProps<SVGTSpanElement>;
use: React.SVGProps<SVGUseElement>;
view: React.SVGProps<SVGViewElement>;
}
}
}
+3
View File
@@ -342,6 +342,9 @@ React.DOM.svg({
xmlns: "http://www.w3.org/2000/svg"
},
React.DOM.rect({
className: 'foobar',
id: 'foo',
color: 'black',
x: 22,
y: 10,
width: 4,
@@ -1,14 +1,13 @@
import FileStore = require("session-file-store");
const options:FileStore.Options = {
const options: FileStore.Options = {
path: "./tmp/sessions/",
logFn:function(a:string) {
logFn: (a: string) => {
}
};
const sessionStore = new FileStore(options);
sessionStore.list(function (err: any, file: Array<string>) {
sessionStore.list((err: any, file: Array<string>) => {
});
});
-36
View File
@@ -1,36 +0,0 @@
// Type definitions for x2js
// Project: https://code.google.com/p/x2js/
// Definitions by: Horiuchi_H <https://github.com/horiuchi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface IX2JS {
new (config?: IX2JSOption): IX2JS;
getVersion(): string;
xml2json<T>(dom: Node): T;
json2xml<T>(json: T): Node;
xml_str2json<T>(xml: string): T;
json2xml_str<T>(json: T): string;
parseXmlString(xml: string): Node;
asArray(prop: any): any[];
asDateTime(key: string): string;
asXmlDateTime(date: Date): string;
asXmlDateTime(date: number): string;
}
interface IX2JSOption {
escapeMode?: boolean;
attributePrefix?: string;
arrayAccessForm?: string;
emptyNodeForm?: string;
enableToStringFunc?: boolean;
arrayAccessFormPaths?: any[];
skipEmptyTextNodesForObj?: boolean;
stripWhitespaces?: boolean;
datetimeAccessFormPaths?: any[];
}
declare var X2JS: IX2JS;
-23
View File
@@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"x2js-tests.ts"
]
}
-298
View File
@@ -1,298 +0,0 @@
// Create x2js instance with default config
var x2js = new X2JS();
// JSON to DOM
var xmlDoc = x2js.json2xml(
{
MyRoot: {
MyChild: 'my_child_value',
MyAnotherChild: 10,
MyArray: [ 'test', 'test2' ],
MyArrayRecords: [
{
ttt: 'vvvv'
},
{
ttt: 'vvvv2'
}
]
}
}
);
// JSON to XML string
var xmlDocStr = x2js.json2xml_str(
{
MyRoot: {
MyChild: 'my_child_value',
MyAnotherChild: 10,
MyArray: [ 'test', 'test2' ],
MyArrayRecords: [
{
ttt: 'vvvv'
},
{
ttt: 'vvvv2'
}
]
}
}
);
console.log(xmlDocStr);
// JSON arrays to string
var xmlDocStr = x2js.json2xml_str(
{
MyRoot: {
namedItemArray: {
item: [
{ first: 'success1' } ,
{ first: 'success2' }
]
},
namedArray: [
{ first: 'success1' } ,
{ first: 'success2' }
],
justArray: [ 'just success1', 'just success2' ],
arrayWithAttrs: [
{
_test: 'successAttr',
__text: 'success',
temp: 'successTemp'
},
{
_test: 'successAttr2',
__text: 'success2',
temp: 'successTemp2'
}
]
}
}
);
console.log(xmlDocStr);
// XML string to JSON
var xmlText = "<MyOperation><test>Success</test><test2><item>ddsfg</item><item>dsdgfdgfd</item></test2></MyOperation>";
var jsonObj = x2js.xml_str2json<any>(xmlText);
console.log(jsonObj.MyOperation.test);
// Array access form examples
console.log(x2js.asArray(jsonObj.MyOperation.test)[0]);
// Or old style (1.0.+):
var x2jsOld = new X2JS({arrayAccessForm: "property"});
jsonObj = x2jsOld.xml_str2json(xmlText);
console.log("Old is " + jsonObj.MyOperation.test_asArray[0]);
// XML/DOM to JSON
var xmlText = " <MyOperation> <test>- Success -</test> <test2> TestText <item> ddsfg </item> TestText2 <item>dsdgfdgfd</item></test2></MyOperation>"
xmlDoc = x2js.parseXmlString(xmlText);
var jsonObj = x2js.xml2json<any>(xmlDoc);
console.log(jsonObj.MyOperation.test);
// Parsing XML attrs
var xmlText = "<MyOperation myAttr='SuccessAttrValue'><txtAttrChild sAttr='SUCCESS TXT ATTR CHILD'>SUCCESS TXT</txtAttrChild><test>Success</test><test2 myAttr='SuccessAttrValueTest2'><item>ddsfg</item><item>dsdgfdgfd</item></test2></MyOperation>";
var jsonObj = x2js.xml_str2json<any>(xmlText);
console.log(jsonObj.MyOperation._myAttr);
console.log(jsonObj.MyOperation.test2._myAttr);
console.log(jsonObj.MyOperation.txtAttrChild._sAttr);
console.log(jsonObj.MyOperation.txtAttrChild.__text);
console.log(jsonObj.MyOperation.txtAttrChild.toString());
// JSON to XML attrs
var xmlDocStr = x2js.json2xml_str(
{
TestAttrRoot: {
_myAttr: 'myAttrValue',
MyChild: 'my_child_value',
MyAnotherChild: 10,
MyTextAttrChild: {
_myTextAttr: 'myTextAttrValue',
__text: 'HelloText'
}
}
}
);
console.log(xmlDocStr);
//Change prefix for attributes
var x2jsChangedAttrs = new X2JS({
// XML attributes. Default is "_"
attributePrefix: "$"
});
jsonObj = x2jsChangedAttrs.xml_str2json(xmlText);
console.log(jsonObj.MyOperation.$myAttr);
console.log(jsonObj.MyOperation.test2.$myAttr);
console.log(jsonObj.MyOperation.txtAttrChild.$sAttr);
xmlDocStr = x2jsChangedAttrs.json2xml_str({
TestAttrRoot: {
_myAttr: 'myAttrValue',
MyChild: 'my_child_value',
MyAnotherChild: 10,
MyTextAttrChild: {
$myTextAttr: 'myTextAttrValue',
__text: 'HelloText'
}
}
}
);
console.log(xmlDocStr);
// Parse XML with namespaces
var xmlText = "<testns:MyOperation xmlns:testns='http://www.example.org'><test>Success</test><test2 myAttr='SuccessAttrValueTest2'><item>ddsfg</item><item>dsdgfdgfd</item><item2>testArrSize</item2></test2></testns:MyOperation>";
var jsonObj = x2js.xml_str2json<any>(xmlText);
console.log(jsonObj.MyOperation.test);
if (jsonObj.MyOperation.test2.item.length > 2)
console.log("Error! Incorrect array len!");
var testObjC = {
'm:TestAttrRoot': {
'_tns:m': 'http://www.example.org',
'_tns:cms': 'http://www.example.org',
MyChild: 'my_child_value',
'cms:MyAnotherChild': 'vdfd'
}
}
// Parse JSON object with namespaces
var xmlDocStr = x2js.json2xml_str(
testObjC
);
console.log(xmlDocStr);
// Parse JSON object constructed with another NS-style
var testObjNew = {
TestAttrRoot: {
__prefix: 'm',
'_tns:m': 'http://www.example.org',
'_tns:cms': 'http://www.example.org',
MyChild: 'my_child_value',
MyAnotherChild: {
__prefix: 'cms',
__text: 'vdfd'
}
}
}
// Parse JSON object with namespaces
var xmlDocStr = x2js.json2xml_str(
testObjNew
);
console.log(xmlDocStr);
// Parse XML with header
var xmlText = "<?xml version='1.0' encoding='utf-8' ?>\n" +
"<test>XML HEADER SUCCESS!</test>";
var jsonObj = x2js.xml_str2json<any>(xmlText);
console.log(jsonObj.test);
// Parse XML with CDATA
var xmlText = "<test><simple>simple success</simple><data><![CDATA[<success/>]]></data> </test>";
var jsonObj = x2js.xml_str2json<any>(xmlText);
console.log(jsonObj.test.data.toString());
console.log(jsonObj.test.data.__cdata);
console.log(jsonObj.test.simple);
// Parse JSON object with CDATA
var xmlDocStr = x2js.json2xml_str(
jsonObj
);
console.log(xmlDocStr);
// Parse JSON with emtpy attributes
var xmlDocStr = x2js.json2xml_str(
{
MyRoot: {
MyNullChild: <any>null,
MyNullChild2: <any>undefined,
MyAnotherChild: 10,
MyEmptyChild: {
_attr: "test"
},
MyEmptyChild2: {
_attr: "test",
__text: "Empty Nodes Test"
}
}
}
);
console.log(xmlDocStr);
// Escaping XML characters
xmlDocStr = x2js.json2xml_str(
{
MyRoot: {
MyEscapeXmlChild: "<success> & \" ' / </success>",
MyEscapeXmlChild2: {
_attr: "success",
__text: "<success> & \" ' / </success>"
},
MyEscapeXmlChildNonString: false
}
}
);
console.log(xmlDocStr);
jsonObj = x2js.xml_str2json(xmlDocStr);
console.log(jsonObj.MyRoot.MyEscapeXmlChild);
console.log(jsonObj.MyRoot.MyEscapeXmlChild2.toString());
console.log(x2js.getVersion());
// Array access path demos
x2js = new X2JS({
arrayAccessFormPaths: [
"MyArrays.test4.item",
/.*\.test3\.item/
]
});
xmlText = "<MyArrays>" +
"<test2><item>success</item><item>second</item></test2>" +
"<test3><item>success</item></test3>" +
"<test4><item>success</item></test4>" +
"<test5><item>success</item></test5>" +
"</MyArrays>";
jsonObj = x2js.xml_str2json(xmlText);
console.log(jsonObj.MyArrays.test3.item[0]);
console.log(jsonObj.MyArrays.test4.item[0]);
console.log(jsonObj.MyArrays.test5.item);
// Working with datetimes
x2js = new X2JS({
datetimeAccessFormPaths: [
"MyDts.testds",
/.*\.testdt.*/
]
});
xmlText = "<MyDts>" +
"<testds>2002-10-10T12:00:00+04:00</testds>" +
"<testdt1>2002-10-10T12:00:00Z</testdt1>" +
"<testdt2>2002-10-10T12:00:00</testdt2>" +
"<testdc>2002-10-10T12:00:00Z</testdc>" +
"</MyDts>";
jsonObj = x2js.xml_str2json(xmlText);
console.log(jsonObj.MyDts.testds);
console.log(jsonObj.MyDts.testdt1);
console.log(jsonObj.MyDts.testdt2);
console.log(x2js.asDateTime(jsonObj.MyDts.testdc));