mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-10 12:10:18 +00:00
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[{*.json,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -28,10 +28,9 @@ _infrastructure/tests/build
|
||||
.idea
|
||||
*.iml
|
||||
*.js.map
|
||||
|
||||
#rx.js
|
||||
!rx.js
|
||||
!*.js/
|
||||
|
||||
node_modules
|
||||
|
||||
.sublimets
|
||||
.settings/launch.json
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "iojs-v2"
|
||||
|
||||
sudo: false
|
||||
|
||||
|
||||
721
CONTRIBUTORS.md
721
CONTRIBUTORS.md
File diff suppressed because it is too large
Load Diff
180
DataStream.js/DataStream.js-tests.ts
Normal file
180
DataStream.js/DataStream.js-tests.ts
Normal file
@@ -0,0 +1,180 @@
|
||||
/// <reference path="DataStream.js.d.ts" />
|
||||
|
||||
var buf = new ArrayBuffer(100);
|
||||
var ds = new DataStream(buf);
|
||||
ds = new DataStream(buf, 10);
|
||||
ds = new DataStream(buf, 10, DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.save('somefile.ext');
|
||||
ds.dynamicSize = true;
|
||||
|
||||
for (var i=0; i<ds.byteLength; i++) {
|
||||
}
|
||||
|
||||
ds.buffer = buf;
|
||||
ds.byteOffset = 10;
|
||||
ds.seek(0);
|
||||
ds.isEof();
|
||||
|
||||
var int32arr: Int32Array;
|
||||
var int16arr: Int16Array;
|
||||
var int8arr: Int8Array;
|
||||
|
||||
var uint32arr: Uint32Array;
|
||||
var uint16arr: Uint16Array;
|
||||
var uint8arr: Uint8Array;
|
||||
|
||||
var float64arr: Float64Array;
|
||||
var float32arr: Float32Array;
|
||||
|
||||
var val: number;
|
||||
var str: string;
|
||||
|
||||
int32arr = ds.mapInt32Array(2);
|
||||
int32arr = ds.mapInt32Array(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
int16arr = ds.mapInt16Array(2);
|
||||
int16arr = ds.mapInt16Array(2, DataStream.BIG_ENDIAN);
|
||||
|
||||
int8arr = ds.mapInt8Array(2);
|
||||
|
||||
uint32arr = ds.mapUint32Array(2);
|
||||
uint32arr = ds.mapUint32Array(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
uint16arr = ds.mapUint16Array(2);
|
||||
uint16arr = ds.mapUint16Array(2, DataStream.BIG_ENDIAN);
|
||||
|
||||
uint8arr = ds.mapUint8Array(2);
|
||||
|
||||
float64arr = ds.mapFloat64Array(2);
|
||||
float64arr = ds.mapFloat64Array(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
float32arr = ds.mapFloat32Array(2);
|
||||
float32arr = ds.mapFloat32Array(2, DataStream.BIG_ENDIAN);
|
||||
|
||||
int32arr = ds.readInt32Array(2);
|
||||
int32arr = ds.readInt32Array(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
int16arr = ds.readInt16Array(2);
|
||||
int16arr = ds.readInt16Array(2, DataStream.BIG_ENDIAN);
|
||||
|
||||
int8arr = ds.readInt8Array(2);
|
||||
|
||||
uint32arr = ds.readUint32Array(2);
|
||||
uint32arr = ds.readUint32Array(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
uint16arr = ds.readUint16Array(2);
|
||||
uint16arr = ds.readUint16Array(2, DataStream.BIG_ENDIAN);
|
||||
|
||||
uint8arr = ds.readUint8Array(2);
|
||||
|
||||
float64arr = ds.readFloat64Array(2);
|
||||
float64arr = ds.readFloat64Array(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
float32arr = ds.readFloat32Array(2);
|
||||
float32arr = ds.readFloat32Array(2, DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeInt32Array(new Int32Array([1,2,3]));
|
||||
ds.writeInt32Array(new Int32Array([1,2,3]), DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeInt16Array(new Int16Array([1,2,3]));
|
||||
ds.writeInt16Array(new Int16Array([1,2,3]), DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeInt8Array(new Int8Array([1,2,3]));
|
||||
|
||||
ds.writeUint32Array(new Uint32Array([1,2,3]));
|
||||
ds.writeUint32Array(new Uint32Array([1,2,3]), DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeUint16Array(new Uint16Array([1,2,3]));
|
||||
ds.writeUint16Array(new Uint16Array([1,2,3]), DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeUint8Array(new Uint8Array([1,2,3]));
|
||||
|
||||
ds.writeFloat64Array(new Float64Array([1,2,3]));
|
||||
ds.writeFloat64Array(new Float64Array([1,2,3]), DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeFloat32Array(new Float32Array([1,2,3]));
|
||||
ds.writeFloat32Array(new Float32Array([1,2,3]), DataStream.BIG_ENDIAN);
|
||||
|
||||
val = ds.readInt32();
|
||||
val = ds.readInt32(DataStream.LITTLE_ENDIAN);
|
||||
|
||||
val = ds.readInt16();
|
||||
val = ds.readInt16(DataStream.BIG_ENDIAN);
|
||||
|
||||
val = ds.readInt8();
|
||||
|
||||
val = ds.readUint32();
|
||||
val = ds.readUint32(DataStream.LITTLE_ENDIAN);
|
||||
|
||||
val = ds.readUint16();
|
||||
val = ds.readUint16(DataStream.BIG_ENDIAN);
|
||||
|
||||
val = ds.readUint8();
|
||||
|
||||
val = ds.readFloat64();
|
||||
val = ds.readFloat64(DataStream.LITTLE_ENDIAN);
|
||||
|
||||
val = ds.readFloat32();
|
||||
val = ds.readFloat32(DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeInt32(1);
|
||||
ds.writeInt32(2, DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeInt16(1);
|
||||
ds.writeInt16(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
ds.writeInt8(1);
|
||||
|
||||
ds.writeUint32(1);
|
||||
ds.writeUint32(2, DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeUint16(1);
|
||||
ds.writeUint16(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
ds.writeUint8(1);
|
||||
|
||||
ds.writeFloat32(1);
|
||||
ds.writeFloat32(2, DataStream.BIG_ENDIAN);
|
||||
|
||||
ds.writeFloat64(1);
|
||||
ds.writeFloat64(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
var embed = [
|
||||
'tag', 'uint32be',
|
||||
'code', 'uint32le',
|
||||
'greet', 'cstring'
|
||||
];
|
||||
|
||||
var def = [
|
||||
'tag', 'cstring:4',
|
||||
'code', 'uint32le',
|
||||
'embed', embed,
|
||||
'length', 'uint16be',
|
||||
'data', ['[]', 'float32be', 'length'],
|
||||
'greet', 'cstring:20',
|
||||
'endNote', 'uint8'
|
||||
];
|
||||
|
||||
var obj = ds.readStruct(def);
|
||||
ds.writeStruct(def, obj);
|
||||
|
||||
str = ds.readUCS2String(2);
|
||||
str = ds.readUCS2String(2, DataStream.LITTLE_ENDIAN);
|
||||
|
||||
ds.writeUCS2String("str");
|
||||
ds.writeUCS2String("str", DataStream.LITTLE_ENDIAN);
|
||||
ds.writeUCS2String("str", DataStream.LITTLE_ENDIAN, 1);
|
||||
|
||||
str = ds.readString(2);
|
||||
str = ds.readString(2, "ASCII");
|
||||
|
||||
ds.writeString("str");
|
||||
ds.writeString("str", "ASCII");
|
||||
ds.writeString("str", "ASCII", 1);
|
||||
|
||||
str = ds.readCString();
|
||||
str = ds.readCString(2);
|
||||
|
||||
ds.writeCString("str");
|
||||
ds.writeCString("str", 1);
|
||||
937
DataStream.js/DataStream.js.d.ts
vendored
Normal file
937
DataStream.js/DataStream.js.d.ts
vendored
Normal file
@@ -0,0 +1,937 @@
|
||||
// Type definitions for DataStream.js
|
||||
// Project: https://github.com/kig/DataStream.js
|
||||
// Definitions by: Tat <https://github.com/tatchx/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare class DataStream {
|
||||
|
||||
/**
|
||||
Big-endian const to use as default endianness.
|
||||
*/
|
||||
static BIG_ENDIAN: boolean;
|
||||
|
||||
/**
|
||||
Little-endian const to use as default endianness.
|
||||
*/
|
||||
static LITTLE_ENDIAN: boolean;
|
||||
|
||||
/**
|
||||
DataStream reads scalars, arrays and structs of data from an ArrayBuffer.
|
||||
It's like a file-like DataView on steroids.
|
||||
|
||||
@param {ArrayBuffer} arrayBuffer ArrayBuffer to read from.
|
||||
*/
|
||||
constructor(arrayBuffer: ArrayBuffer);
|
||||
|
||||
/**
|
||||
DataStream reads scalars, arrays and structs of data from an ArrayBuffer.
|
||||
It's like a file-like DataView on steroids.
|
||||
|
||||
@param arrayBuffer ArrayBuffer to read from.
|
||||
@param byteOffset Offset from arrayBuffer beginning for the DataStream.
|
||||
*/
|
||||
constructor(arrayBuffer: ArrayBuffer, byteOffset: number);
|
||||
|
||||
/**
|
||||
DataStream reads scalars, arrays and structs of data from an ArrayBuffer.
|
||||
It's like a file-like DataView on steroids.
|
||||
|
||||
@param arrayBuffer ArrayBuffer to read from.
|
||||
@param byteOffset Offset from arrayBuffer beginning for the DataStream.
|
||||
@param endianness DataStream.BIG_ENDIAN or DataStream.LITTLE_ENDIAN (the default).
|
||||
*/
|
||||
constructor(arrayBuffer: ArrayBuffer, byteOffset: number, endianness: boolean);
|
||||
|
||||
/**
|
||||
Saves the DataStream contents to the given filename.
|
||||
Uses Chrome's anchor download property to initiate download.
|
||||
*
|
||||
@param filename Filename to save as.
|
||||
@return nothing
|
||||
*/
|
||||
save(filename: string): void;
|
||||
|
||||
/**
|
||||
Whether to extend DataStream buffer when trying to write beyond its size.
|
||||
If set, the buffer is reallocated to twice its current size until the
|
||||
requested write fits the buffer.
|
||||
*/
|
||||
dynamicSize: boolean;
|
||||
|
||||
/**
|
||||
Returns the byte length of the DataStream object.
|
||||
*/
|
||||
byteLength: number;
|
||||
|
||||
/**
|
||||
Set/get the backing ArrayBuffer of the DataStream object.
|
||||
The setter updates the DataView to point to the new buffer.
|
||||
*/
|
||||
buffer: ArrayBuffer;
|
||||
|
||||
/**
|
||||
Set/get the byteOffset of the DataStream object.
|
||||
The setter updates the DataView to point to the new byteOffset.
|
||||
*/
|
||||
byteOffset: number;
|
||||
|
||||
/**
|
||||
Set/get the backing DataView of the DataStream object.
|
||||
The setter updates the buffer and byteOffset to point to the DataView values.
|
||||
*/
|
||||
dataView: Object;
|
||||
|
||||
/**
|
||||
Sets the DataStream read/write position to given position.
|
||||
Clamps between 0 and DataStream length.
|
||||
*
|
||||
@param pos Position to seek to.
|
||||
@return nothing
|
||||
*/
|
||||
seek(pos: number): void;
|
||||
|
||||
/**
|
||||
Returns true if the DataStream seek pointer is at the end of buffer and
|
||||
there's no more data to read.
|
||||
*
|
||||
@return true if the seek pointer is at the end of the buffer.
|
||||
*/
|
||||
isEof(): boolean;
|
||||
|
||||
/**
|
||||
Maps an Int32Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return Int32Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapInt32Array(length: number): Int32Array;
|
||||
|
||||
/**
|
||||
Maps an Int32Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return Int32Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapInt32Array(length: number, e: boolean): Int32Array;
|
||||
|
||||
/**
|
||||
Maps an Int16Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return Int16Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapInt16Array(length: number): Int16Array;
|
||||
|
||||
/**
|
||||
Maps an Int16Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return Int16Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapInt16Array(length: number, e: boolean): Int16Array;
|
||||
|
||||
/**
|
||||
Maps an Int8Array into the DataStream buffer.
|
||||
*
|
||||
Nice for quickly reading in data.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return Int8Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapInt8Array(length: number): Int8Array;
|
||||
|
||||
/**
|
||||
Maps a Uint32Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return Uint32Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapUint32Array(length: number): Uint32Array;
|
||||
|
||||
/**
|
||||
Maps a Uint32Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return Uint32Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapUint32Array(length: number, e: boolean): Uint32Array;
|
||||
|
||||
/**
|
||||
Maps a Uint16Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return Uint16Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapUint16Array(length: number): Uint16Array;
|
||||
|
||||
/**
|
||||
Maps a Uint16Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return Uint16Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapUint16Array(length: number, e: boolean): Uint16Array;
|
||||
|
||||
/**
|
||||
Maps a Uint8Array into the DataStream buffer.
|
||||
*
|
||||
Nice for quickly reading in data.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return Uint8Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapUint8Array(length: number): Uint8Array;
|
||||
|
||||
/**
|
||||
Maps a Float64Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return Float64Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapFloat64Array(length: number): Float64Array;
|
||||
|
||||
/**
|
||||
Maps a Float64Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return Float64Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapFloat64Array(length: number, e: boolean): Float64Array;
|
||||
|
||||
/**
|
||||
Maps a Float32Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return Float32Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapFloat32Array(length: number): Float32Array;
|
||||
|
||||
/**
|
||||
Maps a Float32Array into the DataStream buffer, swizzling it to native
|
||||
endianness in-place. The current offset from the start of the buffer needs to
|
||||
be a multiple of element size, just like with typed array views.
|
||||
*
|
||||
Nice for quickly reading in data. Warning: potentially modifies the buffer
|
||||
contents.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return Float32Array to the DataStream backing buffer.
|
||||
*/
|
||||
mapFloat32Array(length: number, e: boolean): Float32Array;
|
||||
|
||||
/**
|
||||
Reads an Int32Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return The read Int32Array.
|
||||
*/
|
||||
readInt32Array(length: number): Int32Array;
|
||||
|
||||
/**
|
||||
Reads an Int32Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return The read Int32Array.
|
||||
*/
|
||||
readInt32Array(length: number, e: boolean): Int32Array;
|
||||
|
||||
/**
|
||||
Reads an Int16Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return The read Int16Array.
|
||||
*/
|
||||
readInt16Array(length: number): Int16Array;
|
||||
|
||||
/**
|
||||
Reads an Int16Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return The read Int16Array.
|
||||
*/
|
||||
readInt16Array(length: number, e: boolean): Int16Array;
|
||||
|
||||
/**
|
||||
Reads an Int8Array of desired length from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return The read Int8Array.
|
||||
*/
|
||||
readInt8Array(length: number): Int8Array;
|
||||
|
||||
/**
|
||||
Reads an Uint32Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return The read Uint32Array.
|
||||
*/
|
||||
readUint32Array(length: number): Uint32Array;
|
||||
|
||||
/**
|
||||
Reads an Uint32Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return The read Uint32Array.
|
||||
*/
|
||||
readUint32Array(length: number, e: boolean): Uint32Array;
|
||||
|
||||
/**
|
||||
Reads an Uint16Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return The read Uint16Array.
|
||||
*/
|
||||
readUint16Array(length: number): Uint16Array;
|
||||
|
||||
/**
|
||||
Reads an Uint16Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return The read Uint16Array.
|
||||
*/
|
||||
readUint16Array(length: number, e: boolean): Uint16Array;
|
||||
|
||||
/**
|
||||
Reads an Uint8Array of desired length from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return The read Uint8Array.
|
||||
*/
|
||||
readUint8Array(length: number): Uint8Array;
|
||||
|
||||
/**
|
||||
Reads a Float64Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return The read Float64Array.
|
||||
*/
|
||||
readFloat64Array(length: number, e: boolean): Float64Array;
|
||||
|
||||
/**
|
||||
Reads a Float64Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return The read Float64Array.
|
||||
*/
|
||||
readFloat64Array(length: number): Float64Array;
|
||||
|
||||
/**
|
||||
Reads a Float32Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@param e Endianness of the data to read.
|
||||
@return The read Float32Array.
|
||||
*/
|
||||
readFloat32Array(length: number, e: boolean): Float32Array;
|
||||
|
||||
/**
|
||||
Reads a Float32Array of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length Number of elements to map.
|
||||
@return The read Float32Array.
|
||||
*/
|
||||
readFloat32Array(length: number): Float32Array;
|
||||
|
||||
/**
|
||||
Writes an Int32Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
@param e Endianness of the data to write.
|
||||
*/
|
||||
writeInt32Array(arr: Int32Array, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes an Int32Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
*/
|
||||
writeInt32Array(arr: Int32Array): void;
|
||||
|
||||
/**
|
||||
Writes an Int16Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
@param e Endianness of the data to write.
|
||||
*/
|
||||
writeInt16Array(arr: Int16Array, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes an Int16Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
*/
|
||||
writeInt16Array(arr: Int16Array): void;
|
||||
|
||||
/**
|
||||
Writes an Int8Array to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
*/
|
||||
writeInt8Array(arr: Int8Array): void;
|
||||
|
||||
/**
|
||||
Writes an Uint32Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
@param e Endianness of the data to write.
|
||||
*/
|
||||
writeUint32Array(arr: Uint32Array, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes an Uint32Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
*/
|
||||
writeUint32Array(arr: Uint32Array): void;
|
||||
|
||||
/**
|
||||
Writes an Uint16Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
@param e Endianness of the data to write.
|
||||
*/
|
||||
writeUint16Array(arr: Uint16Array, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes an Uint16Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
*/
|
||||
writeUint16Array(arr: Uint16Array): void;
|
||||
|
||||
/**
|
||||
Writes an Uint8Array to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
*/
|
||||
writeUint8Array(arr: Uint8Array): void;
|
||||
|
||||
/**
|
||||
Writes a Float64Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
*/
|
||||
writeFloat64Array(arr: Float64Array): void;
|
||||
|
||||
/**
|
||||
Writes a Float64Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
@param e Endianness of the data to write.
|
||||
*/
|
||||
writeFloat64Array(arr: Float64Array, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes a Float32Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
*/
|
||||
writeFloat32Array(arr: Float32Array): void;
|
||||
|
||||
/**
|
||||
Writes a Float32Array of specified endianness to the DataStream.
|
||||
*
|
||||
@param arr The array to write.
|
||||
@param e Endianness of the data to write.
|
||||
*/
|
||||
writeFloat32Array(arr: Float32Array, e: boolean): void;
|
||||
|
||||
/**
|
||||
Reads a 32-bit int from the DataStream with the desired endianness.
|
||||
*
|
||||
@return The read number.
|
||||
*/
|
||||
readInt32(): number;
|
||||
|
||||
/**
|
||||
Reads a 32-bit int from the DataStream with the desired endianness.
|
||||
*
|
||||
@param e Endianness of the number.
|
||||
@return The read number.
|
||||
*/
|
||||
readInt32(e: boolean): number;
|
||||
|
||||
/**
|
||||
Reads a 16-bit int from the DataStream with the desired endianness.
|
||||
*
|
||||
@return The read number.
|
||||
*/
|
||||
readInt16(): number;
|
||||
|
||||
/**
|
||||
Reads a 16-bit int from the DataStream with the desired endianness.
|
||||
*
|
||||
@param e Endianness of the number.
|
||||
@return The read number.
|
||||
*/
|
||||
readInt16(e: boolean): number;
|
||||
|
||||
/**
|
||||
Reads an 8-bit int from the DataStream.
|
||||
*
|
||||
@return The read number.
|
||||
*/
|
||||
readInt8(): number;
|
||||
|
||||
/**
|
||||
Reads a 32-bit unsigned int from the DataStream with the desired endianness.
|
||||
*
|
||||
@return The read number.
|
||||
*/
|
||||
readUint32(): number;
|
||||
|
||||
/**
|
||||
Reads a 32-bit unsigned int from the DataStream with the desired endianness.
|
||||
*
|
||||
@param e Endianness of the number.
|
||||
@return The read number.
|
||||
*/
|
||||
readUint32(e: boolean): number;
|
||||
|
||||
/**
|
||||
Reads a 16-bit unsigned int from the DataStream with the desired endianness.
|
||||
*
|
||||
@return The read number.
|
||||
*/
|
||||
readUint16(): number;
|
||||
|
||||
/**
|
||||
Reads a 16-bit unsigned int from the DataStream with the desired endianness.
|
||||
*
|
||||
@param e Endianness of the number.
|
||||
@return The read number.
|
||||
*/
|
||||
readUint16(e: boolean): number;
|
||||
|
||||
/**
|
||||
Reads an 8-bit unsigned intfrom the DataStream.
|
||||
*
|
||||
@return The read number.
|
||||
*/
|
||||
readUint8(): number;
|
||||
|
||||
/**
|
||||
Reads a 32-bit float from the DataStream with the desired endianness.
|
||||
*
|
||||
@return The read number.
|
||||
*/
|
||||
readFloat32(): number;
|
||||
|
||||
/**
|
||||
Reads a 32-bit float from the DataStream with the desired endianness.
|
||||
*
|
||||
@param e Endianness of the number.
|
||||
@return The read number.
|
||||
*/
|
||||
readFloat32(e: boolean): number;
|
||||
|
||||
/**
|
||||
Reads a 64-bit float from the DataStream with the desired endianness.
|
||||
*
|
||||
@return The read number.
|
||||
*/
|
||||
readFloat64(): number;
|
||||
|
||||
/**
|
||||
Reads a 64-bit float from the DataStream with the desired endianness.
|
||||
*
|
||||
@param e Endianness of the number.
|
||||
@return The read number.
|
||||
*/
|
||||
readFloat64(e: boolean): number;
|
||||
|
||||
/**
|
||||
Writes a 32-bit int to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
*/
|
||||
writeInt32(v: number): void;
|
||||
|
||||
/**
|
||||
Writes a 32-bit int to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
@param e Endianness of the number.
|
||||
*/
|
||||
writeInt32(v: number, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes a 16-bit int to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
*/
|
||||
writeInt16(v: number): void;
|
||||
|
||||
/**
|
||||
Writes a 16-bit int to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
@param e Endianness of the number.
|
||||
*/
|
||||
writeInt16(v: number, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes an 8-bit int to the DataStream.
|
||||
*
|
||||
@param v Number to write.
|
||||
*/
|
||||
writeInt8(v: number): void;
|
||||
|
||||
/**
|
||||
Writes a 32-bit undigned int to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
*/
|
||||
writeUint32(v: number): void;
|
||||
|
||||
/**
|
||||
Writes a 32-bit undigned int to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
@param e Endianness of the number.
|
||||
*/
|
||||
writeUint32(v: number, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes a 16-bit undigned int to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
*/
|
||||
writeUint16(v: number): void;
|
||||
|
||||
/**
|
||||
Writes a 16-bit undigned int to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
@param e Endianness of the number.
|
||||
*/
|
||||
writeUint16(v: number, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes an 8-bit undigned int to the DataStream.
|
||||
*
|
||||
@param v Number to write.
|
||||
*/
|
||||
writeUint8(v: number): void;
|
||||
|
||||
/**
|
||||
Writes a 32-bit float to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
*/
|
||||
writeFloat32(v: number): void;
|
||||
|
||||
/**
|
||||
Writes a 32-bit float to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
@param e Endianness of the number.
|
||||
*/
|
||||
writeFloat32(v: number, e: boolean): void;
|
||||
|
||||
/**
|
||||
Writes a 64-bit float to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
*/
|
||||
writeFloat64(v: number): void;
|
||||
|
||||
/**
|
||||
Writes a 64-bit float to the DataStream with the desired endianness.
|
||||
*
|
||||
@param v Number to write.
|
||||
@param e Endianness of the number.
|
||||
*/
|
||||
writeFloat64(v: number, e: boolean): void;
|
||||
|
||||
/**
|
||||
Reads a struct of data from the DataStream. The struct is defined as
|
||||
a flat array of [name, type]-pairs. See the example below:
|
||||
*
|
||||
ds.readStruct([
|
||||
'headerTag', 'uint32', // Uint32 in DataStream endianness.
|
||||
'headerTag2', 'uint32be', // Big-endian Uint32.
|
||||
'headerTag3', 'uint32le', // Little-endian Uint32.
|
||||
'array', ['[]', 'uint32', 16], // Uint32Array of length 16.
|
||||
'array2Length', 'uint32',
|
||||
'array2', ['[]', 'uint32', 'array2Length'] // Uint32Array of length array2Length
|
||||
]);
|
||||
*
|
||||
The possible values for the type are as follows:
|
||||
*
|
||||
// Number types
|
||||
// Unsuffixed number types use DataStream endianness.
|
||||
// To explicitly specify endianness, suffix the type with
|
||||
// 'le' for little-endian or 'be' for big-endian,
|
||||
// e.g. 'int32be' for big-endian int32.
|
||||
'uint8' -- 8-bit unsigned int
|
||||
'uint16' -- 16-bit unsigned int
|
||||
'uint32' -- 32-bit unsigned int
|
||||
'int8' -- 8-bit int
|
||||
'int16' -- 16-bit int
|
||||
'int32' -- 32-bit int
|
||||
'float32' -- 32-bit float
|
||||
'float64' -- 64-bit float
|
||||
*
|
||||
// String types
|
||||
'cstring' -- ASCII string terminated by a zero byte.
|
||||
'string:N' -- ASCII string of length N, where N is a literal integer.
|
||||
'string:variableName' -- ASCII string of length $variableName,
|
||||
where 'variableName' is a previously parsed number in the current struct.
|
||||
'string,CHARSET:N' -- String of byteLength N encoded with given CHARSET.
|
||||
'u16string:N' -- UCS-2 string of length N in DataStream endianness.
|
||||
'u16stringle:N' -- UCS-2 string of length N in little-endian.
|
||||
'u16stringbe:N' -- UCS-2 string of length N in big-endian.
|
||||
*
|
||||
// Complex types
|
||||
[name, type, name_2, type_2, ..., name_N, type_N] -- Struct
|
||||
function(dataStream, struct) {} -- Callback function to read and return data.
|
||||
{get: function(dataStream, struct) {},
|
||||
set: function(dataStream, struct) {}}
|
||||
-- Getter/setter functions to read and return data, handy for using the same
|
||||
struct definition for reading and writing structs.
|
||||
['[]', type, length] -- Array of given type and length. The length can be either
|
||||
a number, a string that references a previously-read
|
||||
field, or a callback function(struct, dataStream, type){}.
|
||||
If length is '*', reads in as many elements as it can.
|
||||
*
|
||||
@param structDefinition Struct definition object.
|
||||
@return The read struct. Null if failed to read struct.
|
||||
*/
|
||||
readStruct(structDefinition: any[]): Object;
|
||||
|
||||
/**
|
||||
Writes a struct to the DataStream. Takes a structDefinition that gives the
|
||||
types and a struct object that gives the values. Refer to readStruct for the
|
||||
structure of structDefinition.
|
||||
*
|
||||
@param structDefinition Type definition of the struct.
|
||||
@param struct The struct data object.
|
||||
*/
|
||||
writeStruct(structDefinition: Object, struct: Object): void;
|
||||
|
||||
/**
|
||||
Read UCS-2 string of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length The length of the string to read.
|
||||
@return The read string.
|
||||
*/
|
||||
readUCS2String(length: number): string;
|
||||
|
||||
/**
|
||||
Read UCS-2 string of desired length and endianness from the DataStream.
|
||||
*
|
||||
@param length The length of the string to read.
|
||||
@param endianness The endianness of the string data in the DataStream.
|
||||
@return The read string.
|
||||
*/
|
||||
readUCS2String(length: number, endianness: boolean): string;
|
||||
|
||||
/**
|
||||
Write a UCS-2 string of desired endianness to the DataStream. The
|
||||
lengthOverride argument lets you define the number of characters to write.
|
||||
If the string is shorter than lengthOverride, the extra space is padded with
|
||||
zeroes.
|
||||
*
|
||||
@param str The string to write.
|
||||
*/
|
||||
writeUCS2String(str: string): void;
|
||||
|
||||
/**
|
||||
Write a UCS-2 string of desired endianness to the DataStream. The
|
||||
lengthOverride argument lets you define the number of characters to write.
|
||||
If the string is shorter than lengthOverride, the extra space is padded with
|
||||
zeroes.
|
||||
*
|
||||
@param str The string to write.
|
||||
@param endianness The endianness to use for the written string data.
|
||||
*/
|
||||
writeUCS2String(str: string, endianness: boolean): void;
|
||||
|
||||
/**
|
||||
Write a UCS-2 string of desired endianness to the DataStream. The
|
||||
lengthOverride argument lets you define the number of characters to write.
|
||||
If the string is shorter than lengthOverride, the extra space is padded with
|
||||
zeroes.
|
||||
*
|
||||
@param str The string to write.
|
||||
@param endianness The endianness to use for the written string data.
|
||||
@param lengthOverride The number of characters to write.
|
||||
*/
|
||||
writeUCS2String(str: string, endianness: boolean, lengthOverride: number): void;
|
||||
|
||||
/**
|
||||
Read a string of desired length and encoding from the DataStream.
|
||||
*
|
||||
@param length The length of the string to read in bytes.
|
||||
@return The read string.
|
||||
*/
|
||||
readString(length: number): string;
|
||||
|
||||
/**
|
||||
Read a string of desired length and encoding from the DataStream.
|
||||
*
|
||||
@param length The length of the string to read in bytes.
|
||||
@param encoding The encoding of the string data in the DataStream. Defaults to ASCII.
|
||||
@return The read string.
|
||||
*/
|
||||
readString(length: number, encoding: string): string;
|
||||
|
||||
/**
|
||||
Writes a string of desired length and encoding to the DataStream.
|
||||
*
|
||||
@param s The string to write.
|
||||
*/
|
||||
writeString(s: string): void;
|
||||
|
||||
/**
|
||||
Writes a string of desired length and encoding to the DataStream.
|
||||
*
|
||||
@param s The string to write.
|
||||
@param encoding The encoding for the written string data. Defaults to ASCII.
|
||||
*/
|
||||
writeString(s: string, encoding: string): void;
|
||||
|
||||
/**
|
||||
Writes a string of desired length and encoding to the DataStream.
|
||||
*
|
||||
@param s The string to write.
|
||||
@param encoding The encoding for the written string data. Defaults to ASCII.
|
||||
@param length The number of characters to write.
|
||||
*/
|
||||
writeString(s: string, encoding: string, length: number): void;
|
||||
|
||||
/**
|
||||
Read null-terminated string of desired length from the DataStream. Truncates
|
||||
the returned string so that the null byte is not a part of it.
|
||||
*
|
||||
@return The read string.
|
||||
*/
|
||||
readCString(): string;
|
||||
|
||||
/**
|
||||
Read null-terminated string of desired length from the DataStream. Truncates
|
||||
the returned string so that the null byte is not a part of it.
|
||||
*
|
||||
@param length The length of the string to read.
|
||||
@return The read string.
|
||||
*/
|
||||
readCString(length: number): string;
|
||||
|
||||
/**
|
||||
Writes a null-terminated string to DataStream and zero-pads it to length
|
||||
bytes. If length is not given, writes the string followed by a zero.
|
||||
If string is longer than length, the written part of the string does not have
|
||||
a trailing zero.
|
||||
*
|
||||
@param s The string to write.
|
||||
*/
|
||||
writeCString(s: string): void;
|
||||
|
||||
/**
|
||||
Writes a null-terminated string to DataStream and zero-pads it to length
|
||||
bytes. If length is not given, writes the string followed by a zero.
|
||||
If string is longer than length, the written part of the string does not have
|
||||
a trailing zero.
|
||||
*
|
||||
@param s The string to write.
|
||||
@param length The number of characters to write.
|
||||
*/
|
||||
writeCString(s: string, length: number): void;
|
||||
|
||||
/**
|
||||
Reads an object of type t from the DataStream, passing struct as the thus-far
|
||||
read struct to possible callbacks that refer to it. Used by readStruct for
|
||||
reading in the values, so the type is one of the readStruct types.
|
||||
*
|
||||
@param t Type of the object to read.
|
||||
@return Returns the object on successful read, null on unsuccessful.
|
||||
*/
|
||||
readType(t: Object): Object;
|
||||
|
||||
/**
|
||||
Reads an object of type t from the DataStream, passing struct as the thus-far
|
||||
read struct to possible callbacks that refer to it. Used by readStruct for
|
||||
reading in the values, so the type is one of the readStruct types.
|
||||
*
|
||||
@param t Type of the object to read.
|
||||
@param struct Struct to refer to when resolving length references and for calling callbacks.
|
||||
@return Returns the object on successful read, null on unsuccessful.
|
||||
*/
|
||||
readType(t: Object, struct: Object): Object;
|
||||
|
||||
/**
|
||||
Writes object v of type t to the DataStream.
|
||||
*
|
||||
@param t Type of data to write.
|
||||
@param v Value of data to write.
|
||||
@param struct Struct to pass to write callback functions.
|
||||
*/
|
||||
writeType(t: Object, v: Object, struct: Object): void;
|
||||
}
|
||||
11
FileSaver/FileSaver-tests.ts
Normal file
11
FileSaver/FileSaver-tests.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/// <reference path="FileSaver.d.ts" />
|
||||
|
||||
/**
|
||||
* @summary Test for "saveAs" function.
|
||||
*/
|
||||
function testSaveAs() {
|
||||
var data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
var filename: string = 'hello world.txt';
|
||||
|
||||
saveAs(data, filename);
|
||||
}
|
||||
27
FileSaver/FileSaver.d.ts
vendored
Normal file
27
FileSaver/FileSaver.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Type definitions for FileSaver.js
|
||||
// Project: https://github.com/eligrey/FileSaver.js/
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* @summary Interface for "saveAs" function.
|
||||
* @author Cyril Schumacher
|
||||
* @version 1.0
|
||||
*/
|
||||
interface FileSaver {
|
||||
(
|
||||
/**
|
||||
* @summary Data.
|
||||
* @type {Blob}
|
||||
*/
|
||||
data: Blob,
|
||||
|
||||
/**
|
||||
* @summary File name.
|
||||
* @type {DOMString}
|
||||
*/
|
||||
filename: string
|
||||
): void
|
||||
}
|
||||
|
||||
declare var saveAs: FileSaver;
|
||||
115
PayPal-Cordova-Plugin/PayPal-Cordova-Plugin-test.ts
Normal file
115
PayPal-Cordova-Plugin/PayPal-Cordova-Plugin-test.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
|
||||
/// <reference path="PayPal-Cordova-Plugin.d.ts"/>
|
||||
|
||||
var item: PayPalItem;
|
||||
item = new PayPalItem("name", 10, "25.00", "USD");
|
||||
item = new PayPalItem("name", 10, "25.00", "USD", null);
|
||||
item = new PayPalItem("name", 10, "25.00", "USD", "SKU_ID");
|
||||
|
||||
var item_name: string = item.name;
|
||||
var item_quantity: number = item.quantity;
|
||||
var item_price: string = item.price;
|
||||
var item_currency: string = item.currency;
|
||||
var item_sku: string = item.sku;
|
||||
|
||||
|
||||
|
||||
var paymentDetails: PayPalPaymentDetails;
|
||||
paymentDetails = new PayPalPaymentDetails("10.50", "2.50", "1.25");
|
||||
|
||||
var paymentDetails_subtotal: string = paymentDetails.subtotal;
|
||||
var paymentDetails_shipping: string = paymentDetails.shipping;
|
||||
var paymentDetails_tax: string = paymentDetails.tax;
|
||||
|
||||
|
||||
|
||||
var shippingAddress: PayPalShippingAddress;
|
||||
shippingAddress = new PayPalShippingAddress("name", "line1", "line2", "city", "state", "postalCode", "countryCode");
|
||||
|
||||
var shippingAddress_recipientName: string = shippingAddress.recipientName;
|
||||
var shippingAddress_line1: string = shippingAddress.line1;
|
||||
var shippingAddress_line2: string = shippingAddress.line2;
|
||||
var shippingAddress_city: string = shippingAddress.city;
|
||||
var shippingAddress_state: string = shippingAddress.state;
|
||||
var shippingAddress_postalCode: string = shippingAddress.postalCode;
|
||||
var shippingAddress_countryCode: string = shippingAddress.countryCode;
|
||||
|
||||
|
||||
|
||||
var payment: PayPalPayment;
|
||||
payment = new PayPalPayment("10.00", "USD", "description", "Auth");
|
||||
payment = new PayPalPayment("10.00", "USD", "description", "Auth", paymentDetails);
|
||||
|
||||
var payment_amount: string = payment.amount;
|
||||
var payment_currency: string = payment.currency;
|
||||
var payment_shortDescription: string = payment.shortDescription;
|
||||
var payment_intent: string = payment.intent;
|
||||
var payment_details: PayPalPaymentDetails = payment.details;
|
||||
var payment_invoiceNumber: string = payment.invoiceNumber;
|
||||
var payment_custom: string = payment.custom;
|
||||
var payment_softDescriptor: string = payment.softDescriptor;
|
||||
var payment_bnCode: string = payment.bnCode;
|
||||
var payment_items: PayPalItem[] = [item, item, item];
|
||||
var payment_shippingAddress: PayPalShippingAddress = shippingAddress;
|
||||
|
||||
|
||||
|
||||
var configOptions: PayPalConfigurationOptions = {
|
||||
defaultUserEmail: "email",
|
||||
defaultUserPhoneCountryCode: "countryCode",
|
||||
defaultUserPhoneNumber: "phoneNumber",
|
||||
merchantName: "merchantName",
|
||||
merchantPrivacyPolicyURL: "merchantPrivacyPolicyURL",
|
||||
merchantUserAgreementURL: "merchantUserAgreementURL",
|
||||
acceptCreditCards: true,
|
||||
payPalShippingAddressOption: 10,
|
||||
rememberUser: true,
|
||||
languageOrLocale: "languageOrLocal",
|
||||
disableBlurWhenBackgrounding: true,
|
||||
presentingInPopover: true,
|
||||
forceDefaultsInSandbox: true,
|
||||
sandboxUserPassword: "sandboxUserPassword",
|
||||
sandboxUserPin: "sandboxUserPin"
|
||||
};
|
||||
|
||||
|
||||
|
||||
var config: PayPalConfiguration;
|
||||
config = new PayPalConfiguration();
|
||||
config = new PayPalConfiguration(null);
|
||||
config = new PayPalConfiguration(configOptions);
|
||||
|
||||
var config_defaultUserEmail: string = config.defaultUserEmail;
|
||||
var config_defaultUserPhoneCountryCode: string = config.defaultUserPhoneCountryCode;
|
||||
var config_defaultUserPhoneNumber: string = config.defaultUserPhoneNumber;
|
||||
var config_merchantName: string = config.merchantName;
|
||||
var config_merchantPrivacyPolicyURL: string = config.merchantPrivacyPolicyURL;
|
||||
var config_merchantUserAgreementURL: string = config.merchantUserAgreementURL;
|
||||
var config_acceptCreditCards: boolean = config.acceptCreditCards;
|
||||
var config_payPalShippingAddressOption: number = config.payPalShippingAddressOption;
|
||||
var config_rememberUser: boolean = config.rememberUser;
|
||||
var config_languageOrLocale: string = config.languageOrLocale;
|
||||
var config_disableBlurWhenBackgrounding: boolean = config.disableBlurWhenBackgrounding;
|
||||
var config_presentingInPopover: boolean = config.presentingInPopover;
|
||||
var config_forceDefaultsInSandbox: boolean = config.forceDefaultsInSandbox;
|
||||
var config_sandboxUserPasword: string = config.sandboxUserPassword;
|
||||
var config_sandboxUserPin: string = config.sandboxUserPin;
|
||||
|
||||
|
||||
|
||||
var clientIds: PayPalCordovaPlugin.PayPalClientIds = {
|
||||
PayPalEnvironmentProduction: "",
|
||||
PayPalEnvironmentSandbox: ""
|
||||
};
|
||||
|
||||
|
||||
|
||||
var apiModule: PayPalCordovaPlugin.PayPalMobileStatic = PayPalMobile;
|
||||
apiModule.version((result: string) => {});
|
||||
apiModule.init(clientIds, () => {});
|
||||
apiModule.prepareToRender("environment", config, () => {});
|
||||
apiModule.renderSinglePaymentUI(payment, (result: any) => {}, (cancelReason: string) => {});
|
||||
apiModule.applicationCorrelationIDForEnvironment("environment", (applicationCorrelationId: string) => {});
|
||||
apiModule.clientMetadataID((clientMetadataId: string) => {});
|
||||
apiModule.renderFuturePaymentUI((result: any) => {}, (cancelReason: string) => {});
|
||||
apiModule.renderProfileSharingUI(["openid", "profile", "email"], (result: any) => {}, (cancelReason: string) => {});
|
||||
615
PayPal-Cordova-Plugin/PayPal-Cordova-Plugin.d.ts
vendored
Normal file
615
PayPal-Cordova-Plugin/PayPal-Cordova-Plugin.d.ts
vendored
Normal file
@@ -0,0 +1,615 @@
|
||||
// Type definitions for PayPal-Cordova-Plugin 3.1.10
|
||||
// Project: https://github.com/paypal/PayPal-Cordova-Plugin
|
||||
// Definitions by: Justin Unterreiner <https://github.com/Justin-Credible>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
//#region paypal-mobile-js-helper.js
|
||||
|
||||
/**
|
||||
* The PayPalItem class defines an optional itemization for a payment.
|
||||
*
|
||||
* @see https://developer.paypal.com/docs/api/#item-object for more details.
|
||||
*/
|
||||
declare class PayPalItem {
|
||||
|
||||
/**
|
||||
* @param name Name of the item. 127 characters max.
|
||||
* @param quantity Number of units. 10 characters max.
|
||||
* @param price Unit price for this item 10 characters max.
|
||||
* May be negative for "coupon" etc.
|
||||
* @param currency ISO standard currency code.
|
||||
* @param sku The stock keeping unit for this item. 50 characters max (optional).
|
||||
*/
|
||||
constructor(name: string, quantity: number, price: string, currency: string, sku?: string);
|
||||
|
||||
/**
|
||||
* Name of the item. 127 characters max.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Number of units. 10 characters max.
|
||||
*/
|
||||
quantity: number;
|
||||
|
||||
/**
|
||||
* Unit price for this item 10 characters max.
|
||||
* May be negative for "coupon" etc.
|
||||
*/
|
||||
price: string;
|
||||
|
||||
/**
|
||||
* ISO standard currency code.
|
||||
*/
|
||||
currency: string;
|
||||
|
||||
/**
|
||||
* The stock keeping unit for this item. 50 characters max (optional).
|
||||
*/
|
||||
sku: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The PayPalPaymentDetails class defines optional amount details.
|
||||
*
|
||||
* @see https://developer.paypal.com/webapps/developer/docs/api/#details-object for more details.
|
||||
*/
|
||||
declare class PayPalPaymentDetails {
|
||||
|
||||
/**
|
||||
* @param subtotal Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
|
||||
* @param shipping Amount charged for shipping. 10 characters max with support for 2 decimal places.
|
||||
* @param tax Amount charged for tax. 10 characters max with support for 2 decimal places.
|
||||
*/
|
||||
constructor(subtotal: string, shipping: string, tax: string);
|
||||
|
||||
/**
|
||||
* Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
|
||||
*/
|
||||
subtotal: string;
|
||||
|
||||
/**
|
||||
* Amount charged for shipping. 10 characters max with support for 2 decimal places.
|
||||
*/
|
||||
shipping: string;
|
||||
|
||||
/**
|
||||
* Amount charged for tax. 10 characters max with support for 2 decimal places.
|
||||
*/
|
||||
tax: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience constructor. Returns a PayPalPayment with the specified amount, currency code, and short description.
|
||||
*/
|
||||
declare class PayPalPayment {
|
||||
|
||||
/**
|
||||
* @param amount The amount of the payment.
|
||||
* @param currencyCode The ISO 4217 currency for the payment.
|
||||
* @param shortDescription A short descripton of the payment.
|
||||
* @param intent • "Sale" for an immediate payment.
|
||||
* • "Auth" for payment authorization only, to be captured separately at a later time.
|
||||
* • "Order" for taking an order, with authorization and capture to be done separately at a later time.
|
||||
* @param details PayPalPaymentDetails object (optional).
|
||||
*/
|
||||
constructor(amount: string, currency: string, shortDescription: string, intent: string, details?: PayPalPaymentDetails);
|
||||
|
||||
/**
|
||||
* The amount of the payment.
|
||||
*/
|
||||
amount: string;
|
||||
|
||||
/**
|
||||
* The ISO 4217 currency for the payment.
|
||||
*/
|
||||
currency: string;
|
||||
|
||||
/**
|
||||
* A short descripton of the payment.
|
||||
*/
|
||||
shortDescription: string;
|
||||
|
||||
/**
|
||||
* • "Sale" for an immediate payment.
|
||||
* • "Auth" for payment authorization only, to be captured separately at a later time.
|
||||
* • "Order" for taking an order, with authorization and capture to be done separately at a later time.
|
||||
*/
|
||||
intent: string;
|
||||
|
||||
/**
|
||||
* PayPalPaymentDetails object (optional).
|
||||
*/
|
||||
details: PayPalPaymentDetails;
|
||||
|
||||
/**
|
||||
* Optional invoice number, for your tracking purposes. (up to 256 characters).
|
||||
*/
|
||||
invoiceNumber: string;
|
||||
|
||||
/**
|
||||
* Optional text, for your tracking purposes. (up to 256 characters).
|
||||
*/
|
||||
custom: string;
|
||||
|
||||
/**
|
||||
* Optional text which will appear on the customer's credit card statement. (up to 22 characters).
|
||||
*/
|
||||
softDescriptor: string;
|
||||
|
||||
/**
|
||||
* Optional Build Notation code ("BN code"), obtained from partnerprogram@paypal.com, for your tracking purposes.
|
||||
*/
|
||||
bnCode: string;
|
||||
|
||||
/**
|
||||
* Optional array of PayPalItem objects.
|
||||
* @see PayPalItem
|
||||
* @note If you provide one or more items, be sure that the various prices correctly sum to the payment `amount` or to `paymentDetails.subtotal`.
|
||||
*/
|
||||
items: PayPalItem[];
|
||||
|
||||
/**
|
||||
* Optional customer shipping address, if your app wishes to provide this to the SDK.
|
||||
* @note make sure to set `payPalShippingAddressOption` in PayPalConfiguration to 1 or 3.
|
||||
*/
|
||||
shippingAddress: PayPalShippingAddress;
|
||||
}
|
||||
|
||||
declare class PayPalShippingAddress {
|
||||
|
||||
/**
|
||||
* @param recipientName Name of the recipient at this address. 50 characters max.
|
||||
* @param line1 Line 1 of the address (e.g., Number, street, etc). 100 characters max.
|
||||
* @param line2 Line 2 of the address (e.g., Suite, apt #, etc). 100 characters max. Optional.
|
||||
* @param city City name. 50 characters max.
|
||||
* @param state 2-letter code for US states, and the equivalent for other countries. 100 characters max. Required in certain countries.
|
||||
* @param postalCode ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries.
|
||||
* @param countryCode 2-letter country code. 2 characters max.
|
||||
*/
|
||||
constructor(recipientName: string, line1: string, line2: string, city: string, state: string, postalCode: string, countryCode: string);
|
||||
|
||||
/**
|
||||
* Name of the recipient at this address. 50 characters max.
|
||||
*/
|
||||
recipientName: string;
|
||||
|
||||
/**
|
||||
* Line 1 of the address (e.g., Number, street, etc). 100 characters max.
|
||||
*/
|
||||
line1: string;
|
||||
|
||||
/**
|
||||
* Line 2 of the address (e.g., Suite, apt #, etc). 100 characters max. Optional.
|
||||
*/
|
||||
line2: string;
|
||||
|
||||
/**
|
||||
* City name. 50 characters max.
|
||||
*/
|
||||
city: string;
|
||||
|
||||
/**
|
||||
* 2-letter code for US states, and the equivalent for other countries. 100 characters max. Required in certain countries.
|
||||
*/
|
||||
state: string;
|
||||
|
||||
/**
|
||||
* ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries.
|
||||
*/
|
||||
postalCode: string;
|
||||
|
||||
/**
|
||||
* 2-letter country code. 2 characters max.
|
||||
*/
|
||||
countryCode: string;
|
||||
}
|
||||
|
||||
declare class PayPalConfiguration {
|
||||
|
||||
/**
|
||||
* @param options A set of options to use. Any options not specified will assume default values.
|
||||
*/
|
||||
constructor(options?: PayPalConfigurationOptions);
|
||||
|
||||
/**
|
||||
* Will be overridden by email used in most recent PayPal login.
|
||||
*/
|
||||
defaultUserEmail: string;
|
||||
|
||||
/**
|
||||
* Will be overridden by phone country code used in most recent PayPal login
|
||||
*/
|
||||
defaultUserPhoneCountryCode: string;
|
||||
|
||||
/**
|
||||
* Will be overridden by phone number used in most recent PayPal login.
|
||||
* @note If you set defaultUserPhoneNumber, be sure to also set defaultUserPhoneCountryCode.
|
||||
*/
|
||||
defaultUserPhoneNumber: string;
|
||||
|
||||
/**
|
||||
* Your company name, as it should be displayed to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantName: string;
|
||||
|
||||
/**
|
||||
* URL of your company's privacy policy, which will be offered to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantPrivacyPolicyURL: string;
|
||||
|
||||
/**
|
||||
* URL of your company's user agreement, which will be offered to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantUserAgreementURL: string;
|
||||
|
||||
/**
|
||||
* If set to false, the SDK will only support paying with PayPal, not with credit cards.
|
||||
* This applies only to single payments (via PayPalPaymentViewController).
|
||||
* Future payments (via PayPalFuturePaymentViewController) always use PayPal.
|
||||
* Defaults to true.
|
||||
*/
|
||||
acceptCreditCards: boolean;
|
||||
|
||||
/**
|
||||
* For single payments, options for the shipping address.
|
||||
*
|
||||
* - 0 - PayPalShippingAddressOptionNone: no shipping address applies.
|
||||
*
|
||||
* - 1 - PayPalShippingAddressOptionProvided: shipping address will be provided by your app,
|
||||
* in the shippingAddress property of PayPalPayment.
|
||||
*
|
||||
* - 2 - PayPalShippingAddressOptionPayPal: user will choose from shipping addresses on file
|
||||
* for their PayPal account.
|
||||
*
|
||||
* - 3 - PayPalShippingAddressOptionBoth: user will choose from the shipping address provided by your app,
|
||||
* in the shippingAddress property of PayPalPayment, plus the shipping addresses on file for the user's PayPal account.
|
||||
*
|
||||
* Defaults to 0 (PayPalShippingAddressOptionNone).
|
||||
*/
|
||||
payPalShippingAddressOption: number;
|
||||
|
||||
/**
|
||||
* If set to true, then if the user pays via their PayPal account,
|
||||
* the SDK will remember the user's PayPal username or phone number;
|
||||
* if the user pays via their credit card, then the SDK will remember
|
||||
* the PayPal Vault token representing the user's credit card.
|
||||
*
|
||||
* If set to false, then any previously-remembered username, phone number, or
|
||||
* credit card token will be erased, and subsequent payment information will
|
||||
* not be remembered.
|
||||
*
|
||||
* Defaults to true.
|
||||
*/
|
||||
rememberUser: boolean;
|
||||
|
||||
/**
|
||||
* If not set, or if set to nil, defaults to the device's current language setting.
|
||||
*
|
||||
* Can be specified as a language code ("en", "fr", "zh-Hans", etc.) or as a locale ("en_AU", "fr_FR", "zh-Hant_HK", etc.).
|
||||
* If the library does not contain localized strings for a specified locale, then will fall back to the language. E.g., "es_CO" -> "es".
|
||||
* If the library does not contain localized strings for a specified language, then will fall back to American English.
|
||||
*
|
||||
* If you specify only a language code, and that code matches the device's currently preferred language,
|
||||
* then the library will attempt to use the device's current region as well.
|
||||
* E.g., specifying "en" on a device set to "English" and "United Kingdom" will result in "en_GB".
|
||||
*
|
||||
* These localizations are currently included:
|
||||
* da,de,en,en_AU,en_GB,en_SV,es,es_MX,fr,he,it,ja,ko,nb,nl,pl,pt,pt_BR,ru,sv,tr,zh-Hans,zh-Hant_HK,zh-Hant_TW.
|
||||
*/
|
||||
languageOrLocale: string;
|
||||
|
||||
/**
|
||||
* Normally, the SDK blurs the screen when the app is backgrounded,
|
||||
* to obscure credit card or PayPal account details in the iOS-saved screenshot.
|
||||
* If your app already does its own blurring upon backgrounding, you might choose to disable this.
|
||||
* Defaults to false.
|
||||
*/
|
||||
disableBlurWhenBackgrounding: boolean;
|
||||
|
||||
/**
|
||||
* If you will present the SDK's view controller within a popover, then set this property to true.
|
||||
* Defaults to false. (iOS only)
|
||||
*/
|
||||
presentingInPopover: boolean;
|
||||
|
||||
/**
|
||||
* Sandbox credentials can be difficult to type on a mobile device. Setting this flag to true will
|
||||
* cause the sandboxUserPassword and sandboxUserPin to always be pre-populated into login fields.
|
||||
*
|
||||
* This setting will have no effect if the operation mode is production.
|
||||
* Defaults to false.
|
||||
*/
|
||||
forceDefaultsInSandbox: boolean;
|
||||
|
||||
/**
|
||||
* Password to use for sandbox if 'forceDefaultsInSandbox' is set.
|
||||
*/
|
||||
sandboxUserPassword: string;
|
||||
|
||||
/**
|
||||
* PIN to use for sandbox if 'forceDefaultsInSandbox' is set.
|
||||
*/
|
||||
sandboxUserPin: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the options that can be passed into the PayPalConfiguration class constructor.
|
||||
*/
|
||||
interface PayPalConfigurationOptions {
|
||||
|
||||
/**
|
||||
* Will be overridden by email used in most recent PayPal login.
|
||||
*/
|
||||
defaultUserEmail?: string;
|
||||
|
||||
/**
|
||||
* Will be overridden by phone country code used in most recent PayPal login
|
||||
*/
|
||||
defaultUserPhoneCountryCode?: string;
|
||||
|
||||
/**
|
||||
* Will be overridden by phone number used in most recent PayPal login.
|
||||
* @note If you set defaultUserPhoneNumber, be sure to also set defaultUserPhoneCountryCode.
|
||||
*/
|
||||
defaultUserPhoneNumber?: string;
|
||||
|
||||
/**
|
||||
* Your company name, as it should be displayed to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantName?: string;
|
||||
|
||||
/**
|
||||
* URL of your company's privacy policy, which will be offered to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantPrivacyPolicyURL?: string;
|
||||
|
||||
/**
|
||||
* URL of your company's user agreement, which will be offered to the user
|
||||
* when requesting consent via a PayPalFuturePaymentViewController.
|
||||
*/
|
||||
merchantUserAgreementURL?: string;
|
||||
|
||||
/**
|
||||
* If set to false, the SDK will only support paying with PayPal, not with credit cards.
|
||||
* This applies only to single payments (via PayPalPaymentViewController).
|
||||
* Future payments (via PayPalFuturePaymentViewController) always use PayPal.
|
||||
* Defaults to true.
|
||||
*/
|
||||
acceptCreditCards?: boolean;
|
||||
|
||||
/**
|
||||
* For single payments, options for the shipping address.
|
||||
*
|
||||
* - 0 - PayPalShippingAddressOptionNone?: no shipping address applies.
|
||||
*
|
||||
* - 1 - PayPalShippingAddressOptionProvided?: shipping address will be provided by your app,
|
||||
* in the shippingAddress property of PayPalPayment.
|
||||
*
|
||||
* - 2 - PayPalShippingAddressOptionPayPal?: user will choose from shipping addresses on file
|
||||
* for their PayPal account.
|
||||
*
|
||||
* - 3 - PayPalShippingAddressOptionBoth?: user will choose from the shipping address provided by your app,
|
||||
* in the shippingAddress property of PayPalPayment, plus the shipping addresses on file for the user's PayPal account.
|
||||
*
|
||||
* Defaults to 0 (PayPalShippingAddressOptionNone).
|
||||
*/
|
||||
payPalShippingAddressOption?: number;
|
||||
|
||||
/**
|
||||
* If set to true, then if the user pays via their PayPal account,
|
||||
* the SDK will remember the user's PayPal username or phone number;
|
||||
* if the user pays via their credit card, then the SDK will remember
|
||||
* the PayPal Vault token representing the user's credit card.
|
||||
*
|
||||
* If set to false, then any previously-remembered username, phone number, or
|
||||
* credit card token will be erased, and subsequent payment information will
|
||||
* not be remembered.
|
||||
*
|
||||
* Defaults to true.
|
||||
*/
|
||||
rememberUser?: boolean;
|
||||
|
||||
/**
|
||||
* If not set, or if set to nil, defaults to the device's current language setting.
|
||||
*
|
||||
* Can be specified as a language code ("en", "fr", "zh-Hans", etc.) or as a locale ("en_AU", "fr_FR", "zh-Hant_HK", etc.).
|
||||
* If the library does not contain localized strings for a specified locale, then will fall back to the language. E.g., "es_CO" -> "es".
|
||||
* If the library does not contain localized strings for a specified language, then will fall back to American English.
|
||||
*
|
||||
* If you specify only a language code, and that code matches the device's currently preferred language,
|
||||
* then the library will attempt to use the device's current region as well.
|
||||
* E.g., specifying "en" on a device set to "English" and "United Kingdom" will result in "en_GB".
|
||||
*
|
||||
* These localizations are currently included:
|
||||
* da,de,en,en_AU,en_GB,en_SV,es,es_MX,fr,he,it,ja,ko,nb,nl,pl,pt,pt_BR,ru,sv,tr,zh-Hans,zh-Hant_HK,zh-Hant_TW.
|
||||
*/
|
||||
languageOrLocale?: string;
|
||||
|
||||
/**
|
||||
* Normally, the SDK blurs the screen when the app is backgrounded,
|
||||
* to obscure credit card or PayPal account details in the iOS-saved screenshot.
|
||||
* If your app already does its own blurring upon backgrounding, you might choose to disable this.
|
||||
* Defaults to false.
|
||||
*/
|
||||
disableBlurWhenBackgrounding?: boolean;
|
||||
|
||||
/**
|
||||
* If you will present the SDK's view controller within a popover, then set this property to true.
|
||||
* Defaults to false. (iOS only)
|
||||
*/
|
||||
presentingInPopover?: boolean;
|
||||
|
||||
/**
|
||||
* Sandbox credentials can be difficult to type on a mobile device. Setting this flag to true will
|
||||
* cause the sandboxUserPassword and sandboxUserPin to always be pre-populated into login fields.
|
||||
*
|
||||
* This setting will have no effect if the operation mode is production.
|
||||
* Defaults to false.
|
||||
*/
|
||||
forceDefaultsInSandbox?: boolean;
|
||||
|
||||
/**
|
||||
* Password to use for sandbox if 'forceDefaultsInSandbox' is set.
|
||||
*/
|
||||
sandboxUserPassword?: string;
|
||||
|
||||
/**
|
||||
* PIN to use for sandbox if 'forceDefaultsInSandbox' is set.
|
||||
*/
|
||||
sandboxUserPin?: string;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region cdv-plugin-paypal-mobile-sdk.js
|
||||
|
||||
declare module PayPalCordovaPlugin {
|
||||
|
||||
export interface PayPalClientIds {
|
||||
PayPalEnvironmentProduction: string;
|
||||
PayPalEnvironmentSandbox: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the portion of an object that is common to all responses.
|
||||
*/
|
||||
export interface BaseResult {
|
||||
client: Client;
|
||||
response_type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the client portion of the response.
|
||||
*/
|
||||
export interface Client {
|
||||
paypal_sdk_version: string;
|
||||
environment: string;
|
||||
platform: string;
|
||||
product_name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the response for a successful callback from renderSinglePaymentUI().
|
||||
*/
|
||||
export interface SinglePaymentResult extends BaseResult {
|
||||
response: {
|
||||
intent: string;
|
||||
id: string;
|
||||
state: string;
|
||||
authorization_id: string;
|
||||
create_time: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the response for a successful callback from renderFuturePaymentUI().
|
||||
*/
|
||||
export interface FuturePaymentResult extends BaseResult {
|
||||
response: {
|
||||
code: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface PayPalMobileStatic {
|
||||
/**
|
||||
* Retrieve the version of the PayPal iOS SDK library. Useful when contacting support.
|
||||
*
|
||||
* @param completionCallback a callback function accepting a string
|
||||
*/
|
||||
version(completionCallback: (result: string) => void): void;
|
||||
|
||||
/**
|
||||
* You MUST call this method to initialize the PayPal Mobile SDK.
|
||||
*
|
||||
* The PayPal Mobile SDK can operate in different environments to facilitate development and testing.
|
||||
*
|
||||
* @param clientIdsForEnvironments set of client ids for environments
|
||||
* Example: var clientIdsForEnvironments = {
|
||||
* PayPalEnvironmentProduction : @"my-client-id-for-Production",
|
||||
* PayPalEnvironmentSandbox : @"my-client-id-for-Sandbox"
|
||||
* }
|
||||
* @param completionCallback a callback function on success
|
||||
*/
|
||||
init(clientIdsForEnvironments: PayPalCordovaPlugin.PayPalClientIds, completionCallback: () => void): void;
|
||||
|
||||
/**
|
||||
* You must preconnect to PayPal to prepare the device for processing payments.
|
||||
* This improves the user experience, by making the presentation of the
|
||||
* UI faster. The preconnect is valid for a limited time, so
|
||||
* the recommended time to preconnect is on page load.
|
||||
*
|
||||
* @param environment available options are "PayPalEnvironmentNoNetwork", "PayPalEnvironmentProduction" and "PayPalEnvironmentSandbox"
|
||||
* @param configuration PayPalConfiguration object, for Future Payments merchantName, merchantPrivacyPolicyURL
|
||||
* and merchantUserAgreementURL must be set be set
|
||||
* @param completionCallback a callback function on success
|
||||
*/
|
||||
prepareToRender(environment: string, configuration: PayPalConfiguration, completionCallback: () => void): void;
|
||||
|
||||
/**
|
||||
* Start PayPal UI to collect payment from the user.
|
||||
* See https://developer.paypal.com/webapps/developer/docs/integration/mobile/ios-integration-guide/
|
||||
* for more documentation of the params.
|
||||
*
|
||||
* @param payment PayPalPayment object
|
||||
* @param completionCallback a callback function accepting a js object, called when the user has completed payment
|
||||
* @param cancelCallback a callback function accepting a reason string, called when the user cancels the payment
|
||||
*/
|
||||
renderSinglePaymentUI(payment: PayPalPayment, completionCallback: (result: PayPalCordovaPlugin.SinglePaymentResult) => void, cancelCallback: (cancelReason: string) => void): void;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Once a user has consented to future payments, when the user subsequently initiates a PayPal payment
|
||||
* from their device to be completed by your server, PayPal uses a Correlation ID to verify that the
|
||||
* payment is originating from a valid, user-consented device+application.
|
||||
* This helps reduce fraud and decrease declines.
|
||||
* This method MUST be called prior to initiating a pre-consented payment (a "future payment") from a mobile device.
|
||||
* Pass the result to your server, to include in the payment request sent to PayPal.
|
||||
* Do not otherwise cache or store this value.
|
||||
*
|
||||
* @param environment available options are "PayPalEnvironmentNoNetwork", "PayPalEnvironmentProduction" and "PayPalEnvironmentSandbox"
|
||||
* @param callback applicationCorrelationID Your server will send this to PayPal in a 'Paypal-Application-Correlation-Id' header.
|
||||
*/
|
||||
applicationCorrelationIDForEnvironment(environment: string, completionCallback: (applicationCorrelationId: string) => void): void;
|
||||
|
||||
/**
|
||||
* Once a user has consented to future payments, when the user subsequently initiates a PayPal payment
|
||||
* from their device to be completed by your server, PayPal uses a Correlation ID to verify that the
|
||||
* payment is originating from a valid, user-consented device+application.
|
||||
* This helps reduce fraud and decrease declines.
|
||||
* This method MUST be called prior to initiating a pre-consented payment (a "future payment") from a mobile device.
|
||||
* Pass the result to your server, to include in the payment request sent to PayPal.
|
||||
* Do not otherwise cache or store this value.
|
||||
*
|
||||
* @param callback clientMetadataID Your server will send this to PayPal in a 'PayPal-Client-Metadata-Id' header.
|
||||
*/
|
||||
clientMetadataID(completionCallback: (clientMetadataId: string) => void): void;
|
||||
|
||||
/**
|
||||
* Please Read Docs on Future Payments at https://github.com/paypal/PayPal-iOS-SDK#future-payments
|
||||
*
|
||||
* @param completionCallback a callback function accepting a js object with future payment authorization
|
||||
* @param cancelCallback a callback function accepting a reason string, called when the user canceled without agreement
|
||||
*/
|
||||
renderFuturePaymentUI(completionCallback: (result: PayPalCordovaPlugin.FuturePaymentResult) => void, cancelCallback: (cancelReason: string) => void): void;
|
||||
|
||||
/**
|
||||
* Please Read Docs on Profile Sharing at https://github.com/paypal/PayPal-iOS-SDK#profile-sharing
|
||||
*
|
||||
* @param scopes scopes Set of requested scope-values. Accepted scopes are: openid, profile, address, email, phone, futurepayments and paypalattributes
|
||||
* See https://developer.paypal.com/docs/integration/direct/identity/attributes/ for more details
|
||||
* @param completionCallback a callback function accepting a js object with future payment authorization
|
||||
* @param cancelCallback a callback function accepting a reason string, called when the user canceled without agreement
|
||||
*/
|
||||
renderProfileSharingUI(scopes: string[], completionCallback: (result: any) => void, cancelCallback: (cancelReason: string) => void): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare var PayPalMobile: PayPalCordovaPlugin.PayPalMobileStatic;
|
||||
|
||||
//#endregion
|
||||
@@ -1,5 +1,7 @@
|
||||
# DefinitelyTyped [](https://travis-ci.org/borisyankov/DefinitelyTyped)
|
||||
|
||||
[](https://gitter.im/borisyankov/DefinitelyTyped?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
> The repository for *high quality* TypeScript type definitions.
|
||||
|
||||
For more information see the [definitelytyped.org](http://definitelytyped.org) website.
|
||||
@@ -30,7 +32,7 @@ Please see the [contribution guide](http://definitelytyped.org/guides/contributi
|
||||
|
||||
## Requested definitions
|
||||
|
||||
Here is an updated list of [definitions people have requested](https://github.com/borisyankov/DefinitelyTyped/issues?labels=Definition%3ARequest).
|
||||
Here is are the [currently requested definitions](https://github.com/borisyankov/DefinitelyTyped/labels/Definition%3ARequest).
|
||||
|
||||
## Licence
|
||||
|
||||
@@ -38,4 +40,4 @@ This project is licensed under the MIT license.
|
||||
|
||||
Copyrights on the definition files are respective of each contributor listed at the beginning of each definition file.
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
10
_debugger/_debugger-tests.ts
Normal file
10
_debugger/_debugger-tests.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/// <reference path="_debugger.d.ts"/>
|
||||
import _debugger = require("_debugger");
|
||||
var {Client} = _debugger;
|
||||
|
||||
var client = new Client();
|
||||
|
||||
client.connect(8888, 'localhost');
|
||||
client.listbreakpoints((err, res) => {
|
||||
|
||||
});
|
||||
135
_debugger/_debugger.d.ts
vendored
Normal file
135
_debugger/_debugger.d.ts
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
// Type definitions for Node.js debugger API
|
||||
// Project: http://nodejs.org/
|
||||
// Definitions by: Basarat Ali Syed <https://github.com/basarat>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
|
||||
declare module NodeJS {
|
||||
export module _debugger {
|
||||
export interface Packet {
|
||||
raw: string;
|
||||
headers: string[];
|
||||
body: Message;
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
seq: number;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface RequestInfo {
|
||||
command: string;
|
||||
arguments: any;
|
||||
}
|
||||
|
||||
export interface Request extends Message, RequestInfo {
|
||||
}
|
||||
|
||||
export interface Event extends Message {
|
||||
event: string;
|
||||
body?: any;
|
||||
}
|
||||
|
||||
export interface Response extends Message {
|
||||
request_seq: number;
|
||||
success: boolean;
|
||||
/** Contains error message if success === false. */
|
||||
message?: string;
|
||||
/** Contains message body if success === true. */
|
||||
body?: any;
|
||||
}
|
||||
|
||||
export interface BreakpointMessageBody {
|
||||
type: string;
|
||||
target: number;
|
||||
line: number;
|
||||
}
|
||||
|
||||
export class Protocol {
|
||||
res: Packet;
|
||||
state: string;
|
||||
execute(data: string): void;
|
||||
serialize(rq: Request): string;
|
||||
onResponse: (pkt: Packet) => void;
|
||||
}
|
||||
|
||||
export var NO_FRAME: number;
|
||||
export var port: number;
|
||||
|
||||
export interface ScriptDesc {
|
||||
name: string;
|
||||
id: number;
|
||||
isNative?: boolean;
|
||||
handle?: number;
|
||||
type: string;
|
||||
lineOffset?: number;
|
||||
columnOffset?: number;
|
||||
lineCount?: number;
|
||||
}
|
||||
|
||||
export interface Breakpoint {
|
||||
id: number;
|
||||
scriptId: number;
|
||||
script: ScriptDesc;
|
||||
line: number;
|
||||
condition?: string;
|
||||
scriptReq?: string;
|
||||
}
|
||||
|
||||
export interface RequestHandler {
|
||||
(err: boolean, body: Message, res: Packet): void;
|
||||
request_seq?: number;
|
||||
}
|
||||
|
||||
export interface ResponseBodyHandler {
|
||||
(err: boolean, body?: any): void;
|
||||
request_seq?: number;
|
||||
}
|
||||
|
||||
export interface ExceptionInfo {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface BreakResponse {
|
||||
script?: ScriptDesc;
|
||||
exception?: ExceptionInfo;
|
||||
sourceLine: number;
|
||||
sourceLineText: string;
|
||||
sourceColumn: number;
|
||||
}
|
||||
|
||||
export function SourceInfo(body: BreakResponse): string;
|
||||
|
||||
export interface ClientInstance extends EventEmitter {
|
||||
protocol: Protocol;
|
||||
scripts: ScriptDesc[];
|
||||
handles: ScriptDesc[];
|
||||
breakpoints: Breakpoint[];
|
||||
currentSourceLine: number;
|
||||
currentSourceColumn: number;
|
||||
currentSourceLineText: string;
|
||||
currentFrame: number;
|
||||
currentScript: string;
|
||||
|
||||
connect(port: number, host: string): void;
|
||||
req(req: any, cb: RequestHandler): void;
|
||||
reqFrameEval(code: string, frame: number, cb: RequestHandler): void;
|
||||
mirrorObject(obj: any, depth: number, cb: ResponseBodyHandler): void;
|
||||
setBreakpoint(rq: BreakpointMessageBody, cb: RequestHandler): void;
|
||||
clearBreakpoint(rq: Request, cb: RequestHandler): void;
|
||||
listbreakpoints(cb: RequestHandler): void;
|
||||
reqSource(from: number, to: number, cb: RequestHandler): void;
|
||||
reqScripts(cb: any): void;
|
||||
reqContinue(cb: RequestHandler): void;
|
||||
}
|
||||
|
||||
export var Client : {
|
||||
new (): ClientInstance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "_debugger"{
|
||||
export = NodeJS._debugger;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
function readJSON(target) {
|
||||
return JSON.parse(fs.readFileSync(target, 'utf8'));
|
||||
}
|
||||
|
||||
function getSemFloat(str) {
|
||||
var m = /^[^\d]*(\d+)\.(\d+)/.exec(str);
|
||||
return parseFloat(m[1] + '.' + m[2]);
|
||||
}
|
||||
|
||||
var repo = readJSON(path.resolve(__dirname, '..', 'package.json'));
|
||||
|
||||
var testerPath = path.resolve(__dirname, '..', 'node_modules', 'definition-tester', 'package.json');
|
||||
|
||||
// ultra lame semver major/minor check
|
||||
if (!fs.existsSync(testerPath) || getSemFloat(repo.dependencies['definition-tester']) > getSemFloat(readJSON(testerPath).version)) {
|
||||
console.log('DefinitelyTyped tester needs an update!\n\n please run \'npm install\'\n');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
require('definition-tester');
|
||||
9178
_infrastructure/tests/typescript/0.9.1.1/lib.d.ts
vendored
9178
_infrastructure/tests/typescript/0.9.1.1/lib.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14202
_infrastructure/tests/typescript/0.9.5/lib.d.ts
vendored
14202
_infrastructure/tests/typescript/0.9.5/lib.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14931
_infrastructure/tests/typescript/0.9.7/lib.d.ts
vendored
14931
_infrastructure/tests/typescript/0.9.7/lib.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14958
_infrastructure/tests/typescript/1.0.0/lib.d.ts
vendored
14958
_infrastructure/tests/typescript/1.0.0/lib.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14958
_infrastructure/tests/typescript/1.0.1/lib.d.ts
vendored
14958
_infrastructure/tests/typescript/1.0.1/lib.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14958
_infrastructure/tests/typescript/1.0.2.1-225bad/lib.d.ts
vendored
14958
_infrastructure/tests/typescript/1.0.2.1-225bad/lib.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14169
_infrastructure/tests/typescript/1.1.0-1/lib.d.ts
vendored
14169
_infrastructure/tests/typescript/1.1.0-1/lib.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
14169
_infrastructure/tests/typescript/1.3.0/lib.d.ts
vendored
14169
_infrastructure/tests/typescript/1.3.0/lib.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
36
acc-wizard/acc-wizard-tests.ts
Normal file
36
acc-wizard/acc-wizard-tests.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
/// <reference path="acc-wizard.d.ts" />
|
||||
|
||||
/**
|
||||
* @summary Test for "accwizard" without options.
|
||||
*/
|
||||
function testBasic() {
|
||||
$('#test').accwizard();
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for "accwizard" with options.
|
||||
*/
|
||||
function testWithOptions() {
|
||||
var options: AccWizardOptions = {
|
||||
addButtons: true,
|
||||
sidebar: '.acc-wizard-sidebar',
|
||||
activeClass: 'acc-wizard-active',
|
||||
completedClass: 'acc-wizard-completed',
|
||||
todoClass: 'acc-wizard-todo',
|
||||
stepClass: 'acc-wizard-step',
|
||||
nextText: 'Next Step',
|
||||
backText: 'Go Back',
|
||||
nextType: 'submit',
|
||||
backType: 'reset',
|
||||
nextClasses: 'btn btn-primary',
|
||||
backClasses: 'btn',
|
||||
autoScrolling: true,
|
||||
onNext: function() {},
|
||||
onBack: function() {},
|
||||
onInit: function() {},
|
||||
onDestroy: function() {}
|
||||
};
|
||||
|
||||
$('#test').accwizard(options);
|
||||
}
|
||||
113
acc-wizard/acc-wizard.d.ts
vendored
Normal file
113
acc-wizard/acc-wizard.d.ts
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
// Type definitions for acc-wizard
|
||||
// Project: https://github.com/sathomas/acc-wizard
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface AccWizardOptions {
|
||||
/**
|
||||
* @summary Add next/prev buttons to panels.
|
||||
* @type {boolean}
|
||||
*/
|
||||
addButtons: boolean;
|
||||
|
||||
/**
|
||||
* @summary Selector for task sidebar.
|
||||
* @type {string}
|
||||
*/
|
||||
sidebar: string;
|
||||
|
||||
/**
|
||||
* @summary Class to indicate the active task in sidebar.
|
||||
* @type {string}
|
||||
*/
|
||||
activeClass: string;
|
||||
|
||||
/**
|
||||
* @summary Class to indicate task is complete.
|
||||
* @type {string}
|
||||
*/
|
||||
completedClass: string;
|
||||
|
||||
/**
|
||||
* @summary Class to indicate task is still pending.
|
||||
* @type {string}
|
||||
*/
|
||||
todoClass: string;
|
||||
|
||||
/**
|
||||
* @summary Class for step buttons within panels.
|
||||
* @type {string}
|
||||
*/
|
||||
stepClass: string;
|
||||
|
||||
/**
|
||||
* @summary Text for next button.
|
||||
* @type {string}
|
||||
*/
|
||||
nextText: string;
|
||||
|
||||
/**
|
||||
* @summary Text for back button.
|
||||
* @type {string}
|
||||
*/
|
||||
backText: string;
|
||||
|
||||
/**
|
||||
* @summary HTML input type for next button. (default: "submit")
|
||||
* @type {string}
|
||||
*/
|
||||
nextType: string;
|
||||
|
||||
/**
|
||||
* @summary HTML input type for back button. (default: "reset")
|
||||
* @type {string}
|
||||
*/
|
||||
backType: string;
|
||||
|
||||
/**
|
||||
* @summary Class(es) for next button.
|
||||
* @type {string}
|
||||
*/
|
||||
nextClasses: string;
|
||||
|
||||
/**
|
||||
* @summary Class(es) for back button.
|
||||
* @type {string}
|
||||
*/
|
||||
backClasses: string;
|
||||
|
||||
/**
|
||||
* @summary Auto-scrolling.
|
||||
* @type {boolean}
|
||||
*/
|
||||
autoScrolling: boolean;
|
||||
|
||||
/**
|
||||
* @summary Function to call on next step.
|
||||
*/
|
||||
onNext: Function;
|
||||
|
||||
/**
|
||||
* @summary Function to call on back up.
|
||||
*/
|
||||
onBack: Function;
|
||||
|
||||
/**
|
||||
* @summary A chance to hook initialization.
|
||||
*/
|
||||
onInit: Function;
|
||||
|
||||
/**
|
||||
* @summary A chance to hook destruction.
|
||||
*/
|
||||
onDestroy: Function;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Interface for "acc-wizard" JQuery plugin.
|
||||
* @author Cyril Schumacher
|
||||
* @version 1.0
|
||||
*/
|
||||
interface JQuery {
|
||||
accwizard(options?: AccWizardOptions): void;
|
||||
}
|
||||
1
acc-wizard/acc-wizard.ts.tscparams
Normal file
1
acc-wizard/acc-wizard.ts.tscparams
Normal file
@@ -0,0 +1 @@
|
||||
--noImplicitAny
|
||||
51
ace/ace.d.ts
vendored
51
ace/ace.d.ts
vendored
@@ -18,7 +18,9 @@ declare module AceAjax {
|
||||
|
||||
bindKey:any;
|
||||
|
||||
exec:Function;
|
||||
exec: Function;
|
||||
|
||||
readOnly?: boolean;
|
||||
}
|
||||
|
||||
export interface CommandManager {
|
||||
@@ -576,7 +578,7 @@ declare module AceAjax {
|
||||
/**
|
||||
* Returns the current tab size.
|
||||
**/
|
||||
getTabSize(): string;
|
||||
getTabSize(): number;
|
||||
|
||||
/**
|
||||
* Returns `true` if the character at the position is a soft tab.
|
||||
@@ -1034,6 +1036,9 @@ declare module AceAjax {
|
||||
* Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them.
|
||||
**/
|
||||
export interface Editor {
|
||||
|
||||
addEventListener(ev: 'change', callback: (ev: EditorChangeEvent) => any);
|
||||
addEventListener(ev: string, callback: Function);
|
||||
|
||||
inMultiSelectMode: boolean;
|
||||
|
||||
@@ -1060,6 +1065,31 @@ declare module AceAjax {
|
||||
onChangeMode(e?);
|
||||
|
||||
execCommand(command:string, args?: any);
|
||||
|
||||
/**
|
||||
* Sets a Configuration Option
|
||||
**/
|
||||
setOption(optionName: any, optionValue: any);
|
||||
|
||||
/**
|
||||
* Sets Configuration Options
|
||||
**/
|
||||
setOptions(keyValueTuples: any);
|
||||
|
||||
/**
|
||||
* Get a Configuration Option
|
||||
**/
|
||||
getOption(name: any):any;
|
||||
|
||||
/**
|
||||
* Get Configuration Options
|
||||
**/
|
||||
getOptions():any;
|
||||
|
||||
/**
|
||||
* Get rid of console warning by setting this to Infinity
|
||||
**/
|
||||
$blockScrolling:number;
|
||||
|
||||
/**
|
||||
* Sets a new key handler, such as "vim" or "windows".
|
||||
@@ -1710,6 +1740,13 @@ declare module AceAjax {
|
||||
**/
|
||||
new(renderer: VirtualRenderer, session?: IEditSession): Editor;
|
||||
}
|
||||
|
||||
interface EditorChangeEvent {
|
||||
start: Position;
|
||||
end: Position;
|
||||
action: string; // insert, remove
|
||||
lines: any[];
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
/// PlaceHolder
|
||||
@@ -2574,6 +2611,16 @@ declare module AceAjax {
|
||||
* Returns `true` if there are redo operations left to perform.
|
||||
**/
|
||||
hasRedo(): boolean;
|
||||
|
||||
/**
|
||||
* Returns `true` if the dirty counter is 0
|
||||
**/
|
||||
isClean(): boolean;
|
||||
|
||||
/**
|
||||
* Sets dirty counter to 0
|
||||
**/
|
||||
markClean(): void;
|
||||
|
||||
}
|
||||
var UndoManager: {
|
||||
|
||||
16
acl/acl-mongodbBackend-tests.ts
Normal file
16
acl/acl-mongodbBackend-tests.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/// <reference path='acl.d.ts'/>
|
||||
|
||||
// https://github.com/OptimalBits/node_acl/blob/master/Readme.md
|
||||
import Acl = require('acl');
|
||||
import mongodb = require('mongodb');
|
||||
|
||||
var db: mongodb.Db;
|
||||
|
||||
// Using the mongo db backend
|
||||
var acl = new Acl(new Acl.mongodbBackend(db, 'acl_', true));
|
||||
|
||||
// guest is allowed to view blogs
|
||||
acl.allow('guest', 'blogs', 'view');
|
||||
|
||||
// allow function accepts arrays as any parameter
|
||||
acl.allow('member', 'blogs', ['edit','view', 'delete']);
|
||||
16
acl/acl-redisBackend-test.ts
Normal file
16
acl/acl-redisBackend-test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/// <reference path='acl.d.ts'/>
|
||||
|
||||
// https://github.com/OptimalBits/node_acl/blob/master/Readme.md
|
||||
import Acl = require('acl');
|
||||
import redis = require('redis');
|
||||
|
||||
var client: redis.RedisClient;
|
||||
|
||||
// Using the redis backend
|
||||
var acl = new Acl(new Acl.redisBackend(client, 'acl_'));
|
||||
|
||||
// guest is allowed to view blogs
|
||||
acl.allow('guest', 'blogs', 'view');
|
||||
|
||||
// allow function accepts arrays as any parameter
|
||||
acl.allow('member', 'blogs', ['edit','view', 'delete']);
|
||||
65
acl/acl-tests.ts
Normal file
65
acl/acl-tests.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/// <reference path='acl.d.ts'/>
|
||||
|
||||
// Sample code from
|
||||
// https://github.com/OptimalBits/node_acl/blob/master/Readme.md
|
||||
import Acl = require('acl');
|
||||
|
||||
var report = <T>(err: Error, value: T) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
console.info(value);
|
||||
};
|
||||
|
||||
// Using the memory backend
|
||||
var acl = new Acl(new Acl.memoryBackend());
|
||||
|
||||
// guest is allowed to view blogs
|
||||
acl.allow('guest', 'blogs', 'view');
|
||||
|
||||
// allow function accepts arrays as any parameter
|
||||
acl.allow('member', 'blogs', ['edit','view', 'delete']);
|
||||
|
||||
acl.addUserRoles('joed', 'guest');
|
||||
|
||||
acl.addRoleParents('baz', ['foo','bar']);
|
||||
|
||||
acl.allow('foo', ['blogs','forums','news'], ['view', 'delete']);
|
||||
|
||||
acl.allow('admin', ['blogs','forums'], '*');
|
||||
|
||||
acl.allow([
|
||||
{
|
||||
roles:['guest','special-member'],
|
||||
allows:[
|
||||
{resources:'blogs', permissions:'get'},
|
||||
{resources:['forums','news'], permissions:['get','put','delete']}
|
||||
]
|
||||
},
|
||||
{
|
||||
roles:['gold','silver'],
|
||||
allows:[
|
||||
{resources:'cash', permissions:['sell','exchange']},
|
||||
{resources:['account','deposit'], permissions:['put','delete']}
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
acl.isAllowed('joed', 'blogs', 'view', (err, res) => {
|
||||
if (res) {
|
||||
console.log("User joed is allowed to view blogs");
|
||||
}
|
||||
});
|
||||
|
||||
acl.isAllowed('jsmith', 'blogs', ['edit','view','delete'])
|
||||
.then((result) => {
|
||||
console.dir('jsmith is allowed blogs ' + result);
|
||||
acl.addUserRoles('jsmith', 'member');
|
||||
}).then(() =>
|
||||
acl.isAllowed('jsmith', 'blogs', ['edit','view','delete'])
|
||||
).then((result) =>
|
||||
console.dir('jsmith is allowed blogs ' + result)
|
||||
).then(() => {
|
||||
acl.allowedPermissions('james', ['blogs','forums'], report);
|
||||
acl.allowedPermissions('jsmith', ['blogs','forums'], report);
|
||||
});
|
||||
150
acl/acl.d.ts
vendored
Normal file
150
acl/acl.d.ts
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
// Type definitions for node_acl 0.4.7
|
||||
// Project: https://github.com/optimalbits/node_acl
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
/// <reference path='../node/node.d.ts'/>
|
||||
|
||||
/// <reference path='../redis/redis.d.ts'/>
|
||||
/// <reference path="../mongodb/mongodb.d.ts" />
|
||||
|
||||
declare module "acl" {
|
||||
import http = require('http');
|
||||
import Promise = require("bluebird");
|
||||
|
||||
type strings = string|string[];
|
||||
type Value = string|number;
|
||||
type Values = Value|Value[];
|
||||
type Action = () => any;
|
||||
type Callback = (err: Error) => any;
|
||||
type AnyCallback = (err: Error, obj: any) => any;
|
||||
type AllowedCallback = (err: Error, allowed: boolean) => any;
|
||||
type GetUserId = (req: http.ServerRequest, res: http.ServerResponse) => Value;
|
||||
|
||||
interface AclStatic {
|
||||
new (backend: Backend<any>, logger: Logger, options: Option): Acl;
|
||||
new (backend: Backend<any>, logger: Logger): Acl;
|
||||
new (backend: Backend<any>): Acl;
|
||||
memoryBackend: MemoryBackendStatic;
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
debug: (msg: string)=>any;
|
||||
}
|
||||
|
||||
interface Acl {
|
||||
addUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise<void>;
|
||||
removeUserRoles: (userId: Value, roles: strings, cb?: Callback) => Promise<void>;
|
||||
userRoles: (userId: Value, cb?: (err: Error, roles: string[])=>any) => Promise<string[]>;
|
||||
roleUsers: (role: Value, cb?: (err: Error, users: Values)=>any) => Promise<any>;
|
||||
hasRole: (userId: Value, role: string, cb?: (err: Error, isInRole: boolean)=>any) => Promise<boolean>;
|
||||
addRoleParents: (role: string, parents: Values, cb?: Callback) => Promise<void>;
|
||||
removeRole: (role: string, cb?: Callback) => Promise<void>;
|
||||
removeResource: (resource: string, cb?: Callback) => Promise<void>;
|
||||
allow: {
|
||||
(roles: Values, resources: strings, permissions: strings, cb?: Callback): Promise<void>;
|
||||
(aclSets: AclSet|AclSet[]): Promise<void>;
|
||||
}
|
||||
removeAllow: (role: string, resources: strings, permissions: strings, cb?: Callback) => Promise<void>;
|
||||
removePermissions: (role: string, resources: strings, permissions: strings, cb?: Function) => Promise<void>;
|
||||
allowedPermissions: (userId: Value, resources: strings, cb?: AnyCallback) => Promise<void>;
|
||||
isAllowed: (userId: Value, resources: strings, permissions: strings, cb?: AllowedCallback) => Promise<boolean>;
|
||||
areAnyRolesAllowed: (roles: strings, resource: strings, permissions: strings, cb?: AllowedCallback) => Promise<any>;
|
||||
whatResources: (roles: strings, permissions: strings, cb?: AnyCallback) => Promise<any>;
|
||||
permittedResources: (roles: strings, permissions: strings, cb?: Function) => Promise<void>;
|
||||
middleware: (numPathComponents: number, userId: Value|GetUserId, actions: strings) => Promise<any>;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
buckets?: BucketsOption;
|
||||
}
|
||||
|
||||
interface BucketsOption {
|
||||
meta?: string;
|
||||
parents?: string;
|
||||
permissions?: string;
|
||||
resources?: string;
|
||||
roles?: string;
|
||||
users?: string;
|
||||
}
|
||||
|
||||
interface AclSet {
|
||||
roles: strings;
|
||||
allows: AclAllow[];
|
||||
}
|
||||
|
||||
interface AclAllow {
|
||||
resources: strings;
|
||||
permissions: strings;
|
||||
}
|
||||
|
||||
interface MemoryBackend extends Backend<Action[]> { }
|
||||
interface MemoryBackendStatic {
|
||||
new(): MemoryBackend;
|
||||
}
|
||||
|
||||
//
|
||||
// For internal use
|
||||
//
|
||||
interface Backend<T> {
|
||||
begin: () => T;
|
||||
end: (transaction: T, cb?: Action) => void;
|
||||
clean: (cb?: Action) => void;
|
||||
get: (bucket: string, key: Value, cb?: Action) => void;
|
||||
union: (bucket: string, keys: Value[], cb?: Action) => void;
|
||||
add: (transaction: T, bucket: string, key: Value, values: Values) => void;
|
||||
del: (transaction: T, bucket: string, keys: Value[]) => void;
|
||||
remove: (transaction: T, bucket: string, key: Value, values: Values) => void;
|
||||
|
||||
endAsync: Function; //TODO: Give more specific function signature
|
||||
getAsync: Function;
|
||||
cleanAsync: Function;
|
||||
unionAsync: Function;
|
||||
}
|
||||
|
||||
interface Contract {
|
||||
(args: IArguments): Contract|NoOp;
|
||||
debug: boolean;
|
||||
fulfilled: boolean;
|
||||
args: any[];
|
||||
checkedParams: string[];
|
||||
params: (...types: string[]) => Contract|NoOp;
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
interface NoOp {
|
||||
params: (...types: string[]) => NoOp;
|
||||
end: () => void;
|
||||
}
|
||||
|
||||
// for redis backend
|
||||
import redis = require('redis');
|
||||
|
||||
interface AclStatic {
|
||||
redisBackend: RedisBackendStatic;
|
||||
}
|
||||
|
||||
interface RedisBackend extends Backend<redis.RedisClient> { }
|
||||
interface RedisBackendStatic {
|
||||
new(redis: redis.RedisClient, prefix: string): RedisBackend;
|
||||
new(redis: redis.RedisClient): RedisBackend;
|
||||
}
|
||||
|
||||
// for mongodb backend
|
||||
import mongo = require('mongodb');
|
||||
|
||||
interface AclStatic {
|
||||
mongodbBackend: MongodbBackendStatic;
|
||||
}
|
||||
|
||||
interface MongodbBackend extends Backend<Callback> { }
|
||||
interface MongodbBackendStatic {
|
||||
new(db: mongo.Db, prefix: string, useSingle: boolean): MongodbBackend;
|
||||
new(db: mongo.Db, prefix: string): MongodbBackend;
|
||||
new(db: mongo.Db): MongodbBackend;
|
||||
}
|
||||
|
||||
var _: AclStatic;
|
||||
export = _;
|
||||
}
|
||||
30
acorn/acorn-tests.ts
Normal file
30
acorn/acorn-tests.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/// <reference path="../estree/estree.d.ts" />
|
||||
/// <reference path="acorn.d.ts" />
|
||||
|
||||
import acorn = require('acorn');
|
||||
|
||||
var token: acorn.Token;
|
||||
var tokens: acorn.Token[];
|
||||
var comment: acorn.Comment;
|
||||
var comments: acorn.Comment[];
|
||||
var program: ESTree.Program;
|
||||
var any: any;
|
||||
var string: string;
|
||||
|
||||
// acorn
|
||||
string = acorn.version;
|
||||
program = acorn.parse('code');
|
||||
program = acorn.parse('code', {ranges: true, onToken: tokens, onComment: comments});
|
||||
program = acorn.parse('code', {
|
||||
ranges: true,
|
||||
onToken: (token) => tokens.push(token),
|
||||
onComment: (isBlock, text, start, end) => { }
|
||||
});
|
||||
|
||||
// Token
|
||||
token = tokens[0];
|
||||
string = token.type.label;
|
||||
any = token.value;
|
||||
|
||||
// Comment
|
||||
string = comment.value;
|
||||
67
acorn/acorn.d.ts
vendored
Normal file
67
acorn/acorn.d.ts
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
// Type definitions for Acorn v1.0.1
|
||||
// Project: https://github.com/marijnh/acorn
|
||||
// Definitions by: RReverser <https://github.com/RReverser>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../estree/estree.d.ts" />
|
||||
|
||||
declare module acorn {
|
||||
var version: string;
|
||||
function parse(input: string, options?: Options): ESTree.Program;
|
||||
function parseExpressionAt(input: string, pos: number, options?: Options): ESTree.Expression;
|
||||
var defaultOptions: Options;
|
||||
|
||||
interface TokenType {
|
||||
label: string;
|
||||
keyword: string;
|
||||
beforeExpr: boolean;
|
||||
startsExpr: boolean;
|
||||
isLoop: boolean;
|
||||
isAssign: boolean;
|
||||
prefix: boolean;
|
||||
postfix: boolean;
|
||||
binop: number;
|
||||
updateContext: (prevType: TokenType) => any;
|
||||
}
|
||||
|
||||
interface AbstractToken {
|
||||
start: number;
|
||||
end: number;
|
||||
loc: ESTree.SourceLocation;
|
||||
range: [number, number];
|
||||
}
|
||||
|
||||
interface Token extends AbstractToken {
|
||||
type: TokenType;
|
||||
value: any;
|
||||
}
|
||||
|
||||
interface Comment extends AbstractToken {
|
||||
type: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
ecmaVersion?: number;
|
||||
sourceType?: string;
|
||||
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: ESTree.Position) => any;
|
||||
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: ESTree.Position) => any;
|
||||
allowReserved?: boolean;
|
||||
allowReturnOutsideFunction?: boolean;
|
||||
allowImportExportEverywhere?: boolean;
|
||||
allowHashBang?: boolean;
|
||||
locations?: boolean;
|
||||
onToken?: ((token: Token) => any) | Token[];
|
||||
onComment?: ((isBlock: boolean, text: string, start: number, end: number, startLoc?: ESTree.Position, endLoc?: ESTree.Position) => any) | Comment[];
|
||||
ranges?: boolean;
|
||||
program?: ESTree.Program;
|
||||
sourceFile?: string;
|
||||
directSourceFile?: string;
|
||||
preserveParens?: boolean;
|
||||
plugins?: { [name: string]: Function; };
|
||||
}
|
||||
}
|
||||
|
||||
declare module "acorn" {
|
||||
export = acorn
|
||||
}
|
||||
143
alt/alt-tests.ts
Normal file
143
alt/alt-tests.ts
Normal file
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* Created by shearerbeard on 6/28/15.
|
||||
*/
|
||||
///<reference path="alt.d.ts"/>
|
||||
///<reference path="../es6-promise/es6-promise.d.ts" />
|
||||
|
||||
import Alt = require("alt");
|
||||
import Promise = require("es6-promise");
|
||||
|
||||
//New alt instance
|
||||
var alt = new Alt();
|
||||
|
||||
//Interfaces for our Action Types
|
||||
interface TestActionsGenerate {
|
||||
notifyTest(str:string):void;
|
||||
}
|
||||
|
||||
interface TestActionsExplicit {
|
||||
doTest(str:string):void;
|
||||
success():void;
|
||||
error():void;
|
||||
loading():void;
|
||||
}
|
||||
|
||||
//Create abstracts to inherit ghost methods
|
||||
class AbstractActions implements AltJS.ActionsClass {
|
||||
constructor( alt:AltJS.Alt){}
|
||||
actions:any;
|
||||
dispatch: ( ...payload:Array<any>) => void;
|
||||
generateActions:( ...actions:Array<string>) => void;
|
||||
}
|
||||
|
||||
class AbstractStoreModel<S> implements AltJS.StoreModel<S> {
|
||||
bindActions:( ...actions:Array<Object>) => void;
|
||||
bindAction:( ...args:Array<any>) => void;
|
||||
bindListeners:(obj:any)=> void;
|
||||
exportPublicMethods:(config:{[key:string]:(...args:Array<any>) => any}) => any;
|
||||
exportAsync:( source:any) => void;
|
||||
waitFor:any;
|
||||
exportConfig:any;
|
||||
getState:() => S;
|
||||
}
|
||||
|
||||
class GenerateActionsClass extends AbstractActions {
|
||||
constructor(config:AltJS.Alt) {
|
||||
this.generateActions("notifyTest");
|
||||
super(config);
|
||||
}
|
||||
}
|
||||
|
||||
class ExplicitActionsClass extends AbstractActions {
|
||||
doTest(str:string) {
|
||||
this.dispatch(str);
|
||||
}
|
||||
success() {
|
||||
this.dispatch();
|
||||
}
|
||||
error() {
|
||||
this.dispatch();
|
||||
}
|
||||
loading() {
|
||||
this.dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
var generatedActions = alt.createActions<TestActionsGenerate>(GenerateActionsClass);
|
||||
var explicitActions = alt.createActions<ExplicitActionsClass>(ExplicitActionsClass);
|
||||
|
||||
interface AltTestState {
|
||||
hello:string;
|
||||
}
|
||||
|
||||
var testSource:AltJS.Source = {
|
||||
fakeLoad():AltJS.SourceModel<string> {
|
||||
return {
|
||||
remote() {
|
||||
return new Promise.Promise<string>((res:any, rej:any) => {
|
||||
setTimeout(() => {
|
||||
if(true) {
|
||||
res("stuff");
|
||||
} else {
|
||||
rej("Things have broken");
|
||||
}
|
||||
}, 250)
|
||||
});
|
||||
},
|
||||
local() {
|
||||
return "local";
|
||||
},
|
||||
success: explicitActions.success,
|
||||
error: explicitActions.error,
|
||||
loading:explicitActions.loading
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
class TestStore extends AbstractStoreModel<AltTestState> implements AltTestState {
|
||||
hello:string = "world";
|
||||
constructor() {
|
||||
super();
|
||||
this.bindAction(generatedActions.notifyTest, this.onTest);
|
||||
this.bindActions(explicitActions);
|
||||
this.exportAsync(testSource);
|
||||
this.exportPublicMethods({
|
||||
split: this.split
|
||||
});
|
||||
}
|
||||
onTest(str:string) {
|
||||
this.hello = str;
|
||||
}
|
||||
|
||||
onDoTest(str:string) {
|
||||
this.hello = str;
|
||||
}
|
||||
|
||||
split():string[] {
|
||||
return this.hello.split("");
|
||||
}
|
||||
}
|
||||
|
||||
interface ExtendedTestStore extends AltJS.AltStore<AltTestState> {
|
||||
fakeLoad():string;
|
||||
split():Array<string>;
|
||||
}
|
||||
|
||||
var testStore = <ExtendedTestStore>alt.createStore<AltTestState>(TestStore);
|
||||
|
||||
function testCallback(state:AltTestState) {
|
||||
console.log(state);
|
||||
}
|
||||
|
||||
//Listen allows a typed state callback
|
||||
testStore.listen(testCallback);
|
||||
testStore.unlisten(testCallback);
|
||||
|
||||
//State generic passes to derived store
|
||||
var name:string = testStore.getState().hello;
|
||||
var nameChars:Array<string> = testStore.split();
|
||||
|
||||
generatedActions.notifyTest("types");
|
||||
explicitActions.doTest("more types");
|
||||
|
||||
export var result = testStore.getState();
|
||||
167
alt/alt.d.ts
vendored
Normal file
167
alt/alt.d.ts
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
// Type definitions for Alt 0.16.10
|
||||
// Project: https://github.com/goatslacker/alt
|
||||
// Definitions by: Michael Shearer <https://github.com/Shearerbeard>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path="../react/react.d.ts"/>
|
||||
///<reference path="../es6-promise/es6-promise.d.ts" />
|
||||
|
||||
declare module AltJS {
|
||||
|
||||
interface StoreReduce {
|
||||
action:any;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export interface StoreModel<S> {
|
||||
//Actions
|
||||
bindAction?( action:Action<any>, handler:ActionHandler):void;
|
||||
bindActions?(actions:ActionsClass):void;
|
||||
|
||||
//Methods/Listeners
|
||||
exportPublicMethods?(exportConfig:any):void;
|
||||
bindListeners?(config:{[methodName:string]:Action<any> | Actions}):void;
|
||||
exportAsync?(source:Source):void;
|
||||
registerAsync?(datasource:Source):void;
|
||||
|
||||
//state
|
||||
setState?(state:S):void;
|
||||
setState?(stateFn:(currentState:S, nextState:S) => S):void;
|
||||
getState?():S;
|
||||
waitFor?(store:AltStore<any>):void;
|
||||
|
||||
//events
|
||||
onSerialize?(fn:(data:any) => any):void;
|
||||
onDeserialize?(fn:(data:any) => any):void;
|
||||
on?(event:AltJS.lifeCycleEvents, callback:() => any):void;
|
||||
emitChange?():void;
|
||||
waitFor?(storeOrStores:AltStore<any> | Array<AltStore<any>>):void;
|
||||
otherwise?(data:any, action:AltJS.Action<any>):void;
|
||||
observe?(alt:Alt):any;
|
||||
reduce?(state:any, config:StoreReduce):Object;
|
||||
preventDefault?():void;
|
||||
afterEach?(payload:Object, state:Object):void;
|
||||
beforeEach?(payload:Object, state:Object):void;
|
||||
// TODO: Embed dispatcher interface in def
|
||||
dispatcher?:any;
|
||||
|
||||
//instance
|
||||
getInstance?():AltJS.AltStore<S>;
|
||||
alt?:Alt;
|
||||
displayName?:string;
|
||||
}
|
||||
|
||||
export type Source = {[name:string]: () => SourceModel<any>};
|
||||
|
||||
export interface SourceModel<S> {
|
||||
local(state:any):any;
|
||||
remote(state:any):Promise<S>;
|
||||
shouldFetch?(fetchFn:(...args:Array<any>) => boolean):void;
|
||||
loading?:(args:any) => void;
|
||||
success?:(state:S) => void;
|
||||
error?:(args:any) => void;
|
||||
interceptResponse?(response:any, action:Action<any>, ...args:Array<any>):any;
|
||||
}
|
||||
|
||||
export interface AltStore<S> {
|
||||
getState():S;
|
||||
listen(handler:(state:S) => any):() => void;
|
||||
unlisten(handler:(state:S) => any):void;
|
||||
emitChange():void;
|
||||
}
|
||||
|
||||
export enum lifeCycleEvents {
|
||||
bootstrap,
|
||||
snapshot,
|
||||
init,
|
||||
rollback,
|
||||
error
|
||||
}
|
||||
|
||||
export type Actions = {[action:string]:Action<any>};
|
||||
|
||||
export interface Action<T> {
|
||||
( args:T):void;
|
||||
defer(data:any):void;
|
||||
}
|
||||
|
||||
export interface ActionsClass {
|
||||
generateActions?( ...action:Array<string>):void;
|
||||
dispatch( ...payload:Array<any>):void;
|
||||
actions?:Actions;
|
||||
}
|
||||
|
||||
type StateTransform = (store:StoreModel<any>) => AltJS.AltStore<any>;
|
||||
|
||||
interface AltConfig {
|
||||
dispatcher?:any;
|
||||
serialize?:(serializeFn:(data:Object) => string) => void;
|
||||
deserialize?:(deserializeFn:(serialData:string) => Object) => void;
|
||||
storeTransforms?:Array<StateTransform>;
|
||||
batchingFunction?:(callback:( ...data:Array<any>) => any) => void;
|
||||
}
|
||||
|
||||
class Alt {
|
||||
constructor(config?:AltConfig);
|
||||
actions:Actions;
|
||||
bootstrap(jsonData:string):void;
|
||||
takeSnapshot( ...storeNames:Array<string>):string;
|
||||
flush():Object;
|
||||
recycle( ...stores:Array<AltJS.AltStore<any>>):void;
|
||||
rollback():void;
|
||||
dispatch(action?:AltJS.Action<any>, data?:Object, details?:any):void;
|
||||
|
||||
//Actions methods
|
||||
addActions(actionsName:string, ActionsClass: ActionsClassConstructor):void;
|
||||
createActions<T>(ActionsClass: ActionsClassConstructor, exportObj?: Object):T;
|
||||
createActions<T>(ActionsClass: ActionsClassConstructor, exportObj?: Object, ...constructorArgs:Array<any>):T;
|
||||
generateActions<T>( ...actions:Array<string>):T;
|
||||
getActions(actionsName:string):AltJS.Actions;
|
||||
|
||||
//Stores methods
|
||||
addStore(name:string, store:StoreModel<any>, saveStore?:boolean):void;
|
||||
createStore<S>(store:StoreModel<S>, name?:string):AltJS.AltStore<S>;
|
||||
getStore(name:string):AltJS.AltStore<any>;
|
||||
}
|
||||
|
||||
export interface AltFactory {
|
||||
new(config?:AltConfig):Alt;
|
||||
}
|
||||
|
||||
type ActionsClassConstructor = new (alt:Alt) => AltJS.ActionsClass;
|
||||
|
||||
type ActionHandler = ( ...data:Array<any>) => any;
|
||||
type ExportConfig = {[key:string]:(...args:Array<any>) => any};
|
||||
}
|
||||
|
||||
declare module "alt/utils/chromeDebug" {
|
||||
function chromeDebug(alt:AltJS.Alt):void;
|
||||
export = chromeDebug;
|
||||
}
|
||||
|
||||
declare module "alt/AltContainer" {
|
||||
|
||||
import React = require("react");
|
||||
|
||||
interface ContainerProps {
|
||||
store?:AltJS.AltStore<any>;
|
||||
stores?:Array<AltJS.AltStore<any>>;
|
||||
inject?:{[key:string]:any};
|
||||
actions?:{[key:string]:Object};
|
||||
render?:(...props:Array<any>) => React.ReactElement<any>;
|
||||
flux?:AltJS.Alt;
|
||||
transform?:(store:AltJS.AltStore<any>, actions:any) => any;
|
||||
shouldComponentUpdate?:(props:any) => boolean;
|
||||
component?:React.Component<any, any>;
|
||||
}
|
||||
|
||||
type AltContainer = React.ReactElement<ContainerProps>;
|
||||
var AltContainer:React.ComponentClass<ContainerProps>;
|
||||
|
||||
export = AltContainer;
|
||||
}
|
||||
|
||||
declare module "alt" {
|
||||
var alt:AltJS.AltFactory;
|
||||
export = alt;
|
||||
}
|
||||
3
amplifyjs/amplifyjs.d.ts
vendored
3
amplifyjs/amplifyjs.d.ts
vendored
@@ -29,6 +29,7 @@ interface amplifyDecoders {
|
||||
|
||||
interface amplifyAjaxSettings extends JQueryAjaxSettings {
|
||||
cache?: any;
|
||||
dataMap?: {} | ((data: any) => {});
|
||||
decoder?: any /* string or amplifyDecoder */;
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ interface amplifyRequest {
|
||||
* success (optional): Function to invoke on success.
|
||||
* error (optional): Function to invoke on error.
|
||||
*/
|
||||
(settings: amplifyRequestSettings);
|
||||
(settings: amplifyRequestSettings): any;
|
||||
|
||||
/***
|
||||
* Define a resource.
|
||||
|
||||
80
amqp-rpc/amqp-rpc-tests.ts
Normal file
80
amqp-rpc/amqp-rpc-tests.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
/// <reference path="./amqp-rpc.d.ts" />
|
||||
import amqp_rpc = require('amqp-rpc');
|
||||
var rpc = amqp_rpc.factory();
|
||||
|
||||
interface Name {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
rpc.on<number>('inc', function (param, cb) {
|
||||
var prevVal = param;
|
||||
var nextVal = param + 2;
|
||||
cb(++param, prevVal, nextVal);
|
||||
});
|
||||
|
||||
rpc.on<Name>('say.*', function (param, cb, inf) {
|
||||
var arr = inf.cmd.split('.');
|
||||
var name = (param && param.name) ? param.name : 'world';
|
||||
cb(arr[1] + ' ' + name + '!');
|
||||
});
|
||||
|
||||
rpc.on('withoutCB', function (param, cb, inf) {
|
||||
if (cb) {
|
||||
cb('please run function without cb parameter')
|
||||
}
|
||||
else {
|
||||
console.log('this is function withoutCB');
|
||||
}
|
||||
});
|
||||
|
||||
rpc.call<number>('inc', 5, function (param1, param2, param3) {
|
||||
console.log(param1, param2, param3);
|
||||
});
|
||||
|
||||
rpc.call<Name>('say.Hello', { name: 'John' }, function (msg) {
|
||||
console.log('results of say.Hello:', msg); //output: Hello John!
|
||||
});
|
||||
|
||||
rpc.call<any>('withoutCB', {}, function (msg) {
|
||||
console.log('withoutCB results:', msg); //output: please run function without cb parameter
|
||||
});
|
||||
|
||||
rpc.call<any>('withoutCB', {}); //output message on server side console
|
||||
|
||||
import os = require('os');
|
||||
interface State {
|
||||
type: string;
|
||||
}
|
||||
|
||||
var counter = 0;
|
||||
rpc.onBroadcast<State>('getWorkerStat', function (params, cb) {
|
||||
if (params && params.type == 'fullStat') {
|
||||
cb(null, {
|
||||
pid: process.pid,
|
||||
hostname: os.hostname(),
|
||||
uptime: process.uptime(),
|
||||
counter: counter++
|
||||
});
|
||||
}
|
||||
else {
|
||||
cb(null, { counter: counter++ })
|
||||
}
|
||||
});
|
||||
|
||||
var all_stats: any = {};
|
||||
rpc.callBroadcast<State>(
|
||||
'getWorkerStat',
|
||||
{ type: 'fullStat' }, //request parameters
|
||||
{ //call options
|
||||
ttl: 1000, //wait response time (1 seconds), after run onComplete
|
||||
onResponse: function (err: any, stat: any) { //callback on each worker response
|
||||
all_stats[stat.hostname + ':' + stat.pid] = stat;
|
||||
},
|
||||
onComplete: function () { //callback on ttl expired
|
||||
console.log('----------------------- WORKER STATISTICS ----------------------------------------');
|
||||
for (var worker in all_stats) {
|
||||
var s: any = all_stats[worker];
|
||||
console.log(worker, '\tuptime=', s.uptime.toFixed(2) + ' seconds', '\tcounter=', s.counter);
|
||||
}
|
||||
}
|
||||
});
|
||||
72
amqp-rpc/amqp-rpc.d.ts
vendored
Normal file
72
amqp-rpc/amqp-rpc.d.ts
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
// Type definitions for amqp-rpc v0.0.8
|
||||
// Project: https://github.com/demchenkoe/node-amqp-rpc/
|
||||
// Definitions by: Wonshik Kim <https://github.com/wokim/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "amqp-rpc" {
|
||||
|
||||
export interface Options {
|
||||
connection?: any;
|
||||
url?: string;
|
||||
exchangeInstance?: any;
|
||||
exchange?: string;
|
||||
exchange_options?: {
|
||||
exclusive?: boolean;
|
||||
autoDelete?: boolean;
|
||||
};
|
||||
ipml_options?: {
|
||||
defaultExchangeName?: string;
|
||||
}
|
||||
conn_options?: any;
|
||||
}
|
||||
|
||||
export interface CallOptions {
|
||||
correlationId?: string;
|
||||
autoDeleteCallback?: any;
|
||||
}
|
||||
|
||||
export interface HandlerOptions {
|
||||
queueName?: string;
|
||||
durable?: boolean;
|
||||
exclusive?: boolean;
|
||||
autoDelete?: boolean;
|
||||
}
|
||||
|
||||
export interface BroadcastOptions {
|
||||
ttl?: number;
|
||||
onResponse?: any;
|
||||
context?: any;
|
||||
onComplete?: any;
|
||||
}
|
||||
|
||||
export interface CommandInfo {
|
||||
cmd?: string;
|
||||
exchange?: string;
|
||||
contentType?: string;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export interface Callback {
|
||||
(...args: any[]): void;
|
||||
}
|
||||
|
||||
export interface CallbackWithError {
|
||||
(err: any, ...args: any[]): void;
|
||||
}
|
||||
|
||||
export function factory(opt?: Options): amqpRPC;
|
||||
|
||||
export class amqpRPC {
|
||||
constructor(opt?: Options);
|
||||
generateQueueName(type: string): string;
|
||||
disconnect(): void;
|
||||
call<T>(cmd: string, params: T, cb?: Callback, context?: any, options?: CallOptions): string;
|
||||
on<T>(cmd: string, cb: (param?: T, cb?: Callback, info?: CommandInfo) => void, context?: any, options?: HandlerOptions): boolean;
|
||||
off(cmd: string): boolean;
|
||||
callBroadcast<T>(cmd: string, params: T, options?: BroadcastOptions): void;
|
||||
onBroadcast<T>(cmd: string, cb?: (params?: T, cb?: CallbackWithError) => void, context?: any, options?: any): boolean;
|
||||
offBroadcast(cmd: string): boolean;
|
||||
}
|
||||
}
|
||||
21
amqplib/amqplib-tests.ts
Normal file
21
amqplib/amqplib-tests.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/// <reference path="amqplib.d.ts" />
|
||||
|
||||
import amqp = require("amqplib");
|
||||
|
||||
var msg = "Hello World";
|
||||
|
||||
amqp.connect("amqp://localhost")
|
||||
.then(connection => {
|
||||
return connection.createChannel()
|
||||
.tap(channel => channel.checkQueue("myQueue"))
|
||||
.then(channel => channel.sendToQueue("myQueue", new Buffer(msg)))
|
||||
.ensure(() => connection.close());
|
||||
});
|
||||
|
||||
amqp.connect("amqp://localhost")
|
||||
.then(connection => {
|
||||
return connection.createChannel()
|
||||
.tap(channel => channel.checkQueue("myQueue"))
|
||||
.then(channel => channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())))
|
||||
.ensure(() => connection.close());
|
||||
});
|
||||
144
amqplib/amqplib.d.ts
vendored
Normal file
144
amqplib/amqplib.d.ts
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
// Type definitions for amqplib 0.3.x
|
||||
// Project: https://github.com/squaremo/amqp.node
|
||||
// Definitions by: Michael Nahkies <https://github.com/mnahkies>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../when/when.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "amqplib" {
|
||||
|
||||
import events = require("events");
|
||||
import when = require("when");
|
||||
|
||||
interface Connection extends events.EventEmitter {
|
||||
close(): when.Promise<void>;
|
||||
createChannel(): when.Promise<Channel>;
|
||||
createConfirmChannel(): when.Promise<Channel>;
|
||||
}
|
||||
|
||||
module Replies {
|
||||
interface Empty {
|
||||
}
|
||||
interface AssertQueue {
|
||||
queue: string;
|
||||
messageCount: number;
|
||||
consumerCount: number;
|
||||
}
|
||||
interface DeleteQueue {
|
||||
messageCount: number;
|
||||
}
|
||||
interface AssertExchange {
|
||||
exchange: string;
|
||||
}
|
||||
interface Consume {
|
||||
consumerTag: string;
|
||||
}
|
||||
}
|
||||
|
||||
module Options {
|
||||
interface AssertQueue {
|
||||
exclusive?: boolean;
|
||||
durable?: boolean;
|
||||
autoDelete?: boolean;
|
||||
arguments?: any;
|
||||
messageTtl?: number;
|
||||
expires?: number;
|
||||
deadLetterExchange?: string;
|
||||
maxLength?: number;
|
||||
}
|
||||
interface DeleteQueue {
|
||||
ifUnused?: boolean;
|
||||
ifEmpty?: boolean;
|
||||
}
|
||||
interface AssertExchange {
|
||||
durable?: boolean;
|
||||
internal?: boolean;
|
||||
autoDelete?: boolean;
|
||||
alternateExchange?: string;
|
||||
arguments?: any;
|
||||
}
|
||||
interface DeleteExchange {
|
||||
ifUnused?: boolean;
|
||||
}
|
||||
interface Publish {
|
||||
expiration?: string;
|
||||
userId?: string;
|
||||
CC?: string | string[];
|
||||
|
||||
mandatory?: boolean;
|
||||
persistent?: boolean;
|
||||
deliveryMode?: boolean | number;
|
||||
BCC?: string | string[];
|
||||
|
||||
contentType?: string;
|
||||
contentEncoding?: string;
|
||||
headers?: Object;
|
||||
priority?: number;
|
||||
correlationId?: string;
|
||||
replyTo?: string;
|
||||
messageId?: string;
|
||||
timestamp?: number;
|
||||
type?: string;
|
||||
appId?: string;
|
||||
}
|
||||
interface Consume {
|
||||
consumerTag?: string;
|
||||
noLocal?: boolean;
|
||||
noAck?: boolean;
|
||||
exclusive?: boolean;
|
||||
priority?: number;
|
||||
arguments?: Object;
|
||||
}
|
||||
interface Get {
|
||||
noAck?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
interface Message {
|
||||
content: Buffer;
|
||||
fields: Object;
|
||||
properties: Object;
|
||||
}
|
||||
|
||||
interface Channel extends events.EventEmitter {
|
||||
close(): when.Promise<void>;
|
||||
|
||||
assertQueue(queue: string, options?: Options.AssertQueue): when.Promise<Replies.AssertQueue>;
|
||||
checkQueue(queue: string): when.Promise<Replies.AssertQueue>;
|
||||
|
||||
deleteQueue(queue: string, options?: Options.DeleteQueue): when.Promise<Replies.DeleteQueue>;
|
||||
purgeQueue(queue: string): when.Promise<Replies.DeleteQueue>;
|
||||
|
||||
bindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
unbindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
|
||||
assertExchange(exchange: string, type: string, options?: Options.AssertExchange): when.Promise<Replies.AssertExchange>;
|
||||
checkExchange(exchange: string): when.Promise<Replies.Empty>;
|
||||
|
||||
deleteExchange(exchange: string, options?: Options.DeleteExchange): when.Promise<Replies.Empty>;
|
||||
|
||||
bindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
unbindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
|
||||
|
||||
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
|
||||
|
||||
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume): when.Promise<Replies.Consume>;
|
||||
|
||||
cancel(consumerTag: string): when.Promise<Replies.Empty>;
|
||||
get(queue: string, options?: Options.Get): when.Promise<Message | boolean>;
|
||||
|
||||
ack(message: Message, allUpTo?: boolean): void;
|
||||
ackAll(): void;
|
||||
|
||||
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
|
||||
nackAll(requeue?: boolean): void;
|
||||
reject(message: Message, requeue?: boolean): void;
|
||||
|
||||
prefetch(count: number, global?: boolean): when.Promise<Replies.Empty>;
|
||||
recover(): when.Promise<Replies.Empty>;
|
||||
}
|
||||
|
||||
function connect(url: string, socketOptions?: any): when.Promise<Connection>;
|
||||
}
|
||||
23
angular-dynamic-locale/angular-dynamic-locale-tests.ts
Normal file
23
angular-dynamic-locale/angular-dynamic-locale-tests.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/// <reference path='../angularjs/angular.d.ts' />
|
||||
/// <reference path='angular-dynamic-locale.d.ts' />
|
||||
|
||||
var app = angular.module('testModule', ['tmh.dynamicLocale']);
|
||||
app.config((localStorageServiceProvider: angular.dynamicLocale.tmhDynamicLocaleProvider) => {
|
||||
localStorageServiceProvider
|
||||
.localeLocationPattern("app/config/locales/")
|
||||
.useCookieStorage();
|
||||
});
|
||||
|
||||
class LocaleTestController {
|
||||
|
||||
constructor(tmhDynamicLocaleService: angular.dynamicLocale.tmhDynamicLocaleService) {
|
||||
|
||||
var locale = tmhDynamicLocaleService.get();
|
||||
|
||||
var newLocale = "mt"
|
||||
tmhDynamicLocaleService.set(newLocale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.controller('TestController', LocaleTestController);
|
||||
21
angular-dynamic-locale/angular-dynamic-locale.d.ts
vendored
Normal file
21
angular-dynamic-locale/angular-dynamic-locale.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// Type definitions for angular-dynamic-locale v0.1.27
|
||||
// Project: https://github.com/lgalfaso/angular-dynamic-locale
|
||||
// Definitions by: Stephen Lautier <https://github.com/stephenlautier>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular.dynamicLocale {
|
||||
|
||||
interface tmhDynamicLocaleService {
|
||||
set(locale: string): void;
|
||||
get(): string;
|
||||
}
|
||||
|
||||
interface tmhDynamicLocaleProvider extends angular.IServiceProvider {
|
||||
localeLocationPattern(location: string): tmhDynamicLocaleProvider;
|
||||
localeLocationPattern(): string;
|
||||
useStorage(storageName: string): void;
|
||||
useCookieStorage(): void;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/// <reference path="angular-file-upload.d.ts" />
|
||||
|
||||
module controllers {
|
||||
|
||||
"use strict";
|
||||
|
||||
var controllerId = "upload";
|
||||
|
||||
class Upload {
|
||||
|
||||
static $inject = ["$upload"];
|
||||
constructor(
|
||||
private $upload: ng.angularFileUpload.IUploadService
|
||||
) {
|
||||
}
|
||||
|
||||
onFileSelect($files: File[]) {
|
||||
//$files: an array of files selected, each file has name, size, and type.
|
||||
var uploads: ng.IPromise<any>[] = [];
|
||||
for (var i = 0; i < $files.length; i++) {
|
||||
var file = $files[i];
|
||||
uploads.push(this.$upload.upload<any>({
|
||||
url: "/api/upload",
|
||||
method: "POST",
|
||||
data: {
|
||||
extraData: {
|
||||
fileName: file.name, test: "anything"
|
||||
}
|
||||
},
|
||||
file: file
|
||||
})
|
||||
.progress((evt: any) => {
|
||||
console.log('progress');
|
||||
})
|
||||
.then(success => {
|
||||
// file is uploaded successfully
|
||||
console.log(success.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
angular.module("app").controller(controllerId, Upload);
|
||||
}
|
||||
26
angular-file-upload/angular-file-upload.d.ts
vendored
26
angular-file-upload/angular-file-upload.d.ts
vendored
@@ -1,26 +1,8 @@
|
||||
// Type definitions for Angular File Upload 1.6.7
|
||||
// Project: https://github.com/danialfarid/angular-file-upload
|
||||
// Type definitions for Angular File Upload 4.2.1
|
||||
// Project: https://github.com/danialfarid/ng-file-upload
|
||||
// Definitions by: John Reilly <https://github.com/johnnyreilly>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="../ng-file-upload/ng-file-upload.d.ts" />
|
||||
|
||||
declare module ng.angularFileUpload {
|
||||
|
||||
interface IUploadService {
|
||||
|
||||
http<T>(config: IFileUploadConfig): IUploadPromise<T>;
|
||||
upload<T>(config: IFileUploadConfig): IUploadPromise<T>;
|
||||
}
|
||||
|
||||
interface IUploadPromise<T> extends IHttpPromise<T> {
|
||||
|
||||
progress(callback: IHttpPromiseCallback<T>): IUploadPromise<T>;
|
||||
}
|
||||
|
||||
interface IFileUploadConfig extends ng.IRequestConfig {
|
||||
|
||||
file: File;
|
||||
fileName?: string;
|
||||
}
|
||||
}
|
||||
// THIS FILE WILL REMOVE IF angular-file-upload.d.ts incoming.
|
||||
|
||||
108
angular-formly/angular-formly-tests.ts
Normal file
108
angular-formly/angular-formly-tests.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
/// <reference path="angular-formly.d.ts" />
|
||||
|
||||
var app = angular.module('app', ['formly']);
|
||||
|
||||
interface IScope extends ng.IScope {
|
||||
to: { label: string; }
|
||||
}
|
||||
|
||||
class FormConfig {
|
||||
constructor(formlyConfig: AngularFormly.IFormlyConfig, formlyValidationMessages: AngularFormly.IValidationMessages) {
|
||||
formlyConfig.setWrapper({
|
||||
name: 'validation',
|
||||
types: ['input', 'customInput'],
|
||||
templateUrl: 'my-messages.html'
|
||||
});
|
||||
|
||||
formlyValidationMessages.addStringMessage('required', 'This field is required');
|
||||
|
||||
formlyConfig.setType({
|
||||
name: 'customInput',
|
||||
extends: 'input'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class AppController {
|
||||
fields: AngularFormly.IFieldConfigurationObject[];
|
||||
constructor() {
|
||||
var vm = this;
|
||||
vm.fields = [
|
||||
{
|
||||
key: 'firstName',
|
||||
type: 'customInput',
|
||||
templateOptions: {
|
||||
required: true,
|
||||
label: 'First Name',
|
||||
foo: 'hi'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'email',
|
||||
type: 'input',
|
||||
templateOptions: {
|
||||
label: 'Email',
|
||||
required: true,
|
||||
type: 'email',
|
||||
maxlength: 10,
|
||||
minlength: 6,
|
||||
placeholder: 'example@example.com'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'ip',
|
||||
type: 'input',
|
||||
validators: {
|
||||
ipAddress: {
|
||||
expression: function(viewValue, modelValue) {
|
||||
var value = modelValue || viewValue;
|
||||
return /(\d{1,3}\.){3}\d{1,3}/.test(value);
|
||||
},
|
||||
message: '$viewValue + " is not a valid IP Address"'
|
||||
}
|
||||
},
|
||||
templateOptions: {
|
||||
label: 'IP Address',
|
||||
required: true,
|
||||
type: 'text',
|
||||
placeholder: '127.0.0.1',
|
||||
},
|
||||
validation: {
|
||||
messages: {
|
||||
required: function($viewValue: any, $modelValue: any, scope: AngularFormly.ITemplateScope) {
|
||||
return scope.to.label + ' is required'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'mac',
|
||||
type: 'input',
|
||||
templateOptions: {
|
||||
label: 'MAC Address',
|
||||
required: true,
|
||||
placeholder: '49-8A-BD-4E-00-1D',
|
||||
pattern: '([0-9A-F]{2}[:-]){5}([0-9A-F]{2})'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
key: 'checked',
|
||||
templateOptions: {
|
||||
label: 'Check this'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'checked2',
|
||||
type: 'checkbox',
|
||||
wrapper: null,
|
||||
templateOptions: {
|
||||
label: 'no wrapper here...'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
app.controller("AppController", AppController);
|
||||
|
||||
574
angular-formly/angular-formly.d.ts
vendored
Normal file
574
angular-formly/angular-formly.d.ts
vendored
Normal file
@@ -0,0 +1,574 @@
|
||||
// Type definitions for angular-formly 6.18.0
|
||||
// Project: https://github.com/formly-js/angular-formly
|
||||
// Definitions by: Scott Hatcher <https://github.com/scatcher>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module 'AngularFormly' {
|
||||
export = AngularFormly;
|
||||
}
|
||||
|
||||
declare module AngularFormly {
|
||||
|
||||
|
||||
interface IFieldGroup {
|
||||
data?: Object;
|
||||
className?: string;
|
||||
elementAttributes?: { [key: string]: string };
|
||||
fieldGroup: IFieldConfigurationObject[];
|
||||
form?: Object;
|
||||
hide?: boolean;
|
||||
hideExpression?: string | IExpresssionFunction;
|
||||
key?: string | number;
|
||||
model?: string | Object;
|
||||
options?: IFormOptionsAPI
|
||||
}
|
||||
|
||||
|
||||
interface IFormOptionsAPI {
|
||||
data?: Object;
|
||||
fieldTransform?: Function;
|
||||
formState?: Object;
|
||||
removeChromeAutoComplete?: boolean;
|
||||
resetModel?: Function;
|
||||
templateManipulators?: ITemplateManipulators;
|
||||
updateInitialValue?: Function;
|
||||
wrapper?: string | string[];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* see http://docs.angular-formly.com/docs/formly-expressions#expressionproperties-validators--messages
|
||||
*/
|
||||
interface IExpresssionFunction {
|
||||
($viewValue: any, $modelValue: any, scope: ITemplateScope): any;
|
||||
}
|
||||
|
||||
|
||||
interface IModelOptions {
|
||||
updateOn?: string;
|
||||
debounce?: number;
|
||||
allowInvalid?: boolean;
|
||||
getterSetter?: string;
|
||||
timezone?: string;
|
||||
}
|
||||
|
||||
|
||||
interface ITemplateManipulator {
|
||||
(template: string | HTMLElement, options: Object, scope: ITemplateScope): string | HTMLElement;
|
||||
}
|
||||
|
||||
|
||||
interface ITemplateManipulators {
|
||||
preWrapper?: ITemplateManipulator[];
|
||||
postWrapper?: ITemplateManipulator[];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* see http://docs.angular-formly.com/docs/ngmodelattrstemplatemanipulator
|
||||
*/
|
||||
interface ITemplateOptions {
|
||||
|
||||
// both attribute or regular attribute
|
||||
disabled?: boolean;
|
||||
maxlength?: number;
|
||||
minlength?: number;
|
||||
pattern?: string;
|
||||
required?: boolean;
|
||||
|
||||
//attribute only
|
||||
max?: number;
|
||||
min?: number;
|
||||
placeholder?: number | string;
|
||||
tabindex?: number;
|
||||
type?: string;
|
||||
|
||||
//expression types
|
||||
onBlur?: string;
|
||||
onChange?: string;
|
||||
onClick?: string;
|
||||
onFocus?: string;
|
||||
onKeydown?: string;
|
||||
onKeypress?: string;
|
||||
onKeyup?: string;
|
||||
|
||||
//Bootstrap types
|
||||
label?: string;
|
||||
description?: string;
|
||||
[key: string]: any;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#validators-object
|
||||
*/
|
||||
interface IValidator {
|
||||
expression: string | IExpresssionFunction;
|
||||
message?: string | IExpresssionFunction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An object which has at least two properties called expression and listener. The watch.expression
|
||||
* is added to the formly-form directive's scope (to allow it to run even when hide is true). You
|
||||
* can specify a type ($watchCollection or $watchGroup) via the watcher.type property (defaults to
|
||||
* $watch) and whether you want it to be a deep watch via the watcher.deep property (defaults to false).
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#watcher-objectarray-of-watches
|
||||
*/
|
||||
interface IWatcher {
|
||||
deep?: boolean; //Defaults to false
|
||||
expression?: string | { (field: string, scope: ITemplateScope): boolean };
|
||||
listener: (field: string, newValue: any, oldValue: any, scope: ITemplateScope, stopWatching: Function) => void;
|
||||
type?: string; //Defaults to $watch but can be set to $watchCollection or $watchGroup
|
||||
}
|
||||
|
||||
|
||||
// see http://docs.angular-formly.com/docs/field-configuration-object
|
||||
interface IFieldConfigurationObject {
|
||||
|
||||
|
||||
/**
|
||||
* Added in 6.18.0
|
||||
*
|
||||
* Demo
|
||||
* see http://angular-formly.com/#/example/other/unique-value-async-validation
|
||||
*/
|
||||
asyncValidators?: {
|
||||
[key: string]: string | IExpresssionFunction | IValidator;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a great way to add custom behavior to a specific field. It is injectable with the $scope of the
|
||||
* field, and anything else you have in your injector.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#controller-controller-name-as-string--controller-f
|
||||
*/
|
||||
controller?: string | Function;
|
||||
|
||||
|
||||
/**
|
||||
* This is reserved for the developer. You have our guarantee to be able to use this and not worry about
|
||||
* future versions of formly overriding your usage and preventing you from upgrading :-)
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#data-object
|
||||
*/
|
||||
data?: Object;
|
||||
|
||||
|
||||
/**
|
||||
* Use defaultValue to initialize it the model. If this is provided and the value of the
|
||||
* model at compile-time is undefined, then the value of the model will be assigned to defaultValue.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#defaultvalue-any
|
||||
*/
|
||||
defaultValue?: any;
|
||||
|
||||
|
||||
/**
|
||||
* You can specify your own class that will be applied to the formly-field directive (or ng-form of
|
||||
* a fieldGroup).
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#classname-string
|
||||
*/
|
||||
className?: string;
|
||||
|
||||
|
||||
elementAttributes?: string;
|
||||
|
||||
|
||||
/**
|
||||
* An object where the key is a property to be set on the main field config and the value is an
|
||||
* expression used to assign that property. The value is a formly expressions. The returned value is
|
||||
* wrapped in $q.when so you can return a promise from your function :-)
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#expressionproperties-object
|
||||
*/
|
||||
expressionProperties?: {
|
||||
[key: string]: string | IExpresssionFunction | IValidator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Uses ng-if. Whether to hide the field. Defaults to false. If you wish this to be conditional, use
|
||||
* hideExpression. See below.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#hide-boolean
|
||||
*/
|
||||
hide?: boolean
|
||||
|
||||
|
||||
/**
|
||||
* This is similar to expressionProperties with a slight difference. You should (hopefully) never
|
||||
* notice the difference with the most common use case. This is available due to limitations with
|
||||
* expressionProperties and ng-if not working together very nicely.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#hideexpression-string--function
|
||||
*/
|
||||
hideExpression?: string | IExpresssionFunction;
|
||||
|
||||
|
||||
/**
|
||||
* This allows you to specify the id of your field (which will be used for its name as well unless
|
||||
* a name is provided). Note, you can also override the id generation code using the formlyConfig
|
||||
* extra called getFieldId.
|
||||
*
|
||||
* AVOID THIS
|
||||
* If you don't have to do this, don't. Specifying IDs makes it harder to re-use things and it's
|
||||
* just extra work. Part of the beauty that angular-formly provides is the fact that you don't need
|
||||
* to concern yourself with making sure that this is unique.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#id-string
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
|
||||
initialValue?: any;
|
||||
|
||||
|
||||
/**
|
||||
* Can be set instead of type or template to use a custom html template form field. Works
|
||||
* just like a directive templateUrl and uses the $templateCache
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#key-string
|
||||
*/
|
||||
key?: string | number;
|
||||
|
||||
|
||||
/**
|
||||
* This allows you to specify a link function. It is invoked after your template has finished compiling.
|
||||
* You are passed the normal arguments for a normal link function.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#link-link-function
|
||||
*/
|
||||
link?: ng.IDirectiveLinkFn;
|
||||
|
||||
|
||||
/**
|
||||
* By default, the model passed to the formly-field directive is the same as the model passed to the
|
||||
* formly-form. However, if the field has a model specified, then it is used for that field (and that
|
||||
* field only). In addition, a deep watch is added to the formly-field directive's scope to run the
|
||||
* expressionProperties when the specified model changes.
|
||||
*
|
||||
* Note, the formly-form directive will allow you to specify a string which is an (almost) formly
|
||||
* expression which allows you to define the model as relative to the scope of the form.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#model-object--string
|
||||
*/
|
||||
model?: Object | string;
|
||||
|
||||
|
||||
/**
|
||||
* Allows you to take advantage of ng-model-options directive. Formly's built-in templateManipulator (see
|
||||
* below) will add this attribute to your ng-model element automatically if this property exists. Note,
|
||||
* if you use the getter/setter option, formly's templateManipulator will change the value of ng-model
|
||||
* to options.value which is a getterSetter that formly adds to field options.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#modeloptions
|
||||
*/
|
||||
modelOptions?: IModelOptions;
|
||||
|
||||
|
||||
/**
|
||||
* If you wish to, you can specify a specific name for your ng-model. This is useful if you're posting
|
||||
* the form to a server using techniques of yester-year.
|
||||
*
|
||||
* AVOID THIS
|
||||
* If you don't have to do this, don't. It's just extra work. Part of the beauty that angular-formly
|
||||
* provides is the fact that you don't need to concern yourself with stuff like this.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#name-string
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
|
||||
/**
|
||||
* This is used by ngModelAttrsTemplateManipulator to automatically add attributes to the ng-model element
|
||||
* of field templates. You will likely not use this often. This object is a little complex, but extremely
|
||||
* powerful. It's best to explain this api via an example. For more information, see the guide on ngModelAttrs.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#ngmodelattrs-object
|
||||
*/
|
||||
ngModelAttrs?: {
|
||||
attribute?: any;
|
||||
bound?: any;
|
||||
expression?: any;
|
||||
value?: any;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Used to tell angular-formly to not attempt to add the formControl property to your object. This is useful
|
||||
* for things like validation, but not necessary if your "field" doesn't use ng-model (if it's just a horizontal
|
||||
* line for example). Defaults to undefined.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#noformcontrol-boolean
|
||||
*/
|
||||
noFormControl?: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Allows you to specify extra types to get options from. Duplicate options are overridden in later priority
|
||||
* (index 1 will override index 0 properties). Also, these are applied after the type's defaultOptions and
|
||||
* hence will override any duplicates of those properties as well.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#optionstypes-string--array-of-strings
|
||||
*/
|
||||
optionsTypes?: string | string[];
|
||||
|
||||
|
||||
/**
|
||||
* Can be set instead of type or templateUrl to use a custom html
|
||||
* template form field. Recommended to be used with one-liners mostly
|
||||
* (like a directive), or if you're using webpack with the ability to require templates :-)
|
||||
*
|
||||
* If a function is passed, it is invoked with the field configuration object and can return
|
||||
* either a string for the template or a promise that resolves to a string.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#template-string--function
|
||||
*/
|
||||
template?: string | { (fieldConfiguration: IFieldConfigurationObject): string | ng.IPromise<string> };
|
||||
|
||||
|
||||
/**
|
||||
* Allows you to specify custom template manipulators for this specific field. (use defaultOptions in a
|
||||
* type configuration if you want it to apply to all fields of a certain type).
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#templatemanipulator-object-of-arrays-of-functions
|
||||
*/
|
||||
templateManipulators?: ITemplateManipulators;
|
||||
|
||||
|
||||
/**
|
||||
* This is reserved for the templates. Any template-specific options go in here. Look at your specific
|
||||
* template implementation to know the options required for this.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#templateoptions-object
|
||||
*/
|
||||
templateOptions?: ITemplateOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Can be set instead of type or template to use a custom html template form field. Works
|
||||
* just like a directive templateUrl and uses the $templateCache
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#templateurl-string--function
|
||||
*/
|
||||
templateUrl?: string | { (fieldConfiguration: IFieldConfigurationObject): string | ng.IPromise<string> };
|
||||
|
||||
|
||||
/**
|
||||
* The type of field to be rendered. This is the recommended method
|
||||
* for defining fields. Types must be pre-defined using formlyConfig.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#type-string
|
||||
*/
|
||||
type?: string;
|
||||
|
||||
|
||||
/**
|
||||
* An object with a few useful properties mostly handy when used in combination with ng-messages
|
||||
*/
|
||||
validation?: {
|
||||
|
||||
/**
|
||||
* This is set by angular-formly. This is a boolean indicating whether an error message should be shown. Because
|
||||
* you generally only want to show error messages when the user has interacted with a specific field, this value
|
||||
* is set to true based on this rule: field invalid && (field touched || validation.show) (with slight difference
|
||||
* for pre-angular 1.3 because it doesn't have touched support).
|
||||
*/
|
||||
errorExistsAndShouldBeVisible?: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* A map of Formly Expressions mapped to message names. This is really useful when you're using ng-messages
|
||||
* like in this example.
|
||||
*/
|
||||
messages?: {
|
||||
[key: string]: IExpresssionFunction | string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A boolean you as the developer can set to specify to force options.validation.errorExistsAndShouldBeVisible
|
||||
* to be set to true when there are $errors. This is useful when you're trying to call the user's attention to
|
||||
* some fields for some reason.
|
||||
*/
|
||||
show?: boolean;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An object where the keys are the name of the validator and the values are Formly Expressions;
|
||||
*
|
||||
* Async Validation
|
||||
* All function validators can return true/false/Promise. A validator passes if it returns true or a promise
|
||||
* that is resolved. A validator fails if it returns false or a promise that is rejected.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#validators-object
|
||||
*/
|
||||
validators?: {
|
||||
[key: string]: string | IExpresssionFunction | IValidator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is a getter/setter function for the value that your field is representing. Useful when using getterSetter: true
|
||||
* in the modelOptions (in fact, if you don't disable the ngModelAttrsTemplateManipulator that comes built-in with formly,
|
||||
* it will automagically change your field's ng-model attribute to use options.value.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#value-gettersetter-function
|
||||
*/
|
||||
value?(): any; //Getter
|
||||
value?(val: any): void; //Setter
|
||||
|
||||
|
||||
/**
|
||||
* An object which has at least two properties called expression and listener. The watch.expression is added
|
||||
* to the formly-form directive's scope (to allow it to run even when hide is true). You can specify a type
|
||||
* ($watchCollection or $watchGroup) via the watcher.type property (defaults to $watch) and whether you want
|
||||
* it to be a deep watch via the watcher.deep property (defaults to false).
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#watcher-objectarray-of-watches
|
||||
*/
|
||||
watcher?: IWatcher | IWatcher[];
|
||||
|
||||
|
||||
/**
|
||||
* This makes reference to setWrapper in formlyConfig. It is expected to be the name of the wrapper. If
|
||||
* given an array, the formly field template will be wrapped by the first wrapper, then the second, then
|
||||
* the third, etc. You can also specify these as part of a type (which is the recommended approach).
|
||||
* Specifying this property will override the wrappers for the type for this field.
|
||||
*
|
||||
* http://docs.angular-formly.com/docs/field-configuration-object#wrapper-string--array-of-strings
|
||||
*/
|
||||
wrapper?: string | string[];
|
||||
|
||||
|
||||
//ALL PROPERTIES BELOW ARE ADDED (So you should not be setting them yourself.)
|
||||
|
||||
|
||||
/**
|
||||
* This is the NgModelController for the field. It provides you with awesome stuff like $errors :-)
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#formcontrol-ngmodelcontroller
|
||||
*/
|
||||
formControl?: ng.IFormController | ng.IFormController[];
|
||||
|
||||
|
||||
/**
|
||||
* Will reset the field's model and the field control to the last initialValue. This is used by the
|
||||
* formly-form's options.resetModel function.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#resetmodel-function
|
||||
*/
|
||||
resetModel?: () => void;
|
||||
|
||||
|
||||
/**
|
||||
* It is not likely that you'll ever want to invoke this function. It simply runs the expressionProperties expressions.
|
||||
* It is used internally and you shouldn't have to use it, but you can if you want to, and any breaking changes to the
|
||||
* way it works will result in a major version change, so you can rely on its api.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#runexpressions-function
|
||||
*/
|
||||
runExpressions?: () => void;
|
||||
|
||||
|
||||
/**
|
||||
* Will reset the field's initialValue to the current state of the model. Useful if you load the model asynchronously.
|
||||
* Invoke this when the model gets set. This is used by the formly-form's options.updateInitialValue function.
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#updateinitialvalue-function
|
||||
*/
|
||||
updateInitialValue?: () => void;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/custom-templates#section-formlyconfig-settype-options
|
||||
*/
|
||||
interface ITypeOptions {
|
||||
apiCheck?: { [key: string]: Function };
|
||||
apiCheckFunction?: string; //'throw' or 'warn
|
||||
apiCheckInstance?: any;
|
||||
apiCheckOptions?: Object;
|
||||
defaultOptions?: IFieldConfigurationObject | Function;
|
||||
controller?: Function | string | any[];
|
||||
data?: Object;
|
||||
extends?: string;
|
||||
link?: ng.IDirectiveLinkFn;
|
||||
overwriteOk?: boolean;
|
||||
name: string;
|
||||
template?: Function | string;
|
||||
templateUrl?: Function | string;
|
||||
validateOptions?: Function;
|
||||
wrapper?: string | string[];
|
||||
}
|
||||
|
||||
interface IWrapperOptions {
|
||||
apiCheck?: { [key: string]: Function };
|
||||
apiCheckFunction?: string; //'throw' or 'warn
|
||||
apiCheckInstance?: any;
|
||||
apiCheckOptions?: Object;
|
||||
overwriteOk?: boolean;
|
||||
name?: string;
|
||||
template?: string;
|
||||
templateUrl?: string;
|
||||
types?: string[];
|
||||
validateOptions?: Function;
|
||||
}
|
||||
|
||||
interface IFormlyConfig {
|
||||
setType(typeOptions: ITypeOptions): void;
|
||||
setWrapper(wrapperOptions: IWrapperOptions): void;
|
||||
|
||||
}
|
||||
|
||||
interface ITemplateScopeOptions {
|
||||
formControl: ng.IFormController | ng.IFormController[];
|
||||
templateOptions: ITemplateOptions;
|
||||
validation: Object;
|
||||
}
|
||||
|
||||
/**
|
||||
* see http://docs.angular-formly.com/docs/custom-templates#templates-scope
|
||||
*/
|
||||
interface ITemplateScope {
|
||||
options: ITemplateScopeOptions;
|
||||
//Shortcut to options.formControl
|
||||
fc: ng.IFormController | ng.IFormController[];
|
||||
//all the fields for the form
|
||||
fields: IFieldConfigurationObject[];
|
||||
//the form controller the field is in
|
||||
form: any;
|
||||
//The object passed as options.formState to the formly-form directive. Use this to share state between fields.
|
||||
formState: Object;
|
||||
//The id of the field. You shouldn't have to use this.
|
||||
id: string;
|
||||
//The index of the field the form is on (in ng-repeat)
|
||||
index: number;
|
||||
//the model of the form (or the model specified by the field if it was specified).
|
||||
model: Object | string;
|
||||
//Shortcut to options.validation.errorExistsAndShouldBeVisible
|
||||
showError: boolean;
|
||||
//Shortcut to options.templateOptions
|
||||
to: ITemplateOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* see http://docs.angular-formly.com/docs/formlyvalidationmessages#addtemplateoptionvaluemessage
|
||||
*/
|
||||
interface IValidationMessages {
|
||||
addTemplateOptionValueMessage(name: string, prop: string, prefix: string, suffix: string, alternate: string): void;
|
||||
addStringMessage(name: string, string: string): void;
|
||||
messages: { [key: string]: ($viewValue: any, $modelValue: any, scope: ITemplateScope) => string };
|
||||
}
|
||||
|
||||
}
|
||||
61
angular-gettext/angular-gettext-tests.ts
Normal file
61
angular-gettext/angular-gettext-tests.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
/// <reference path="angular-gettext.d.ts" />
|
||||
|
||||
module angular_gettext_tests {
|
||||
|
||||
|
||||
// Configuring angular-gettext
|
||||
// https://angular-gettext.rocketeer.be/dev-guide/configure/
|
||||
//Setting the language
|
||||
angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
gettextCatalog.setCurrentLanguage('nl');
|
||||
});
|
||||
|
||||
//Highlighting untranslated strings
|
||||
angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
gettextCatalog.debug = true;
|
||||
});
|
||||
|
||||
|
||||
// Marking strings in JavaScript code as translatable.
|
||||
// https://angular-gettext.rocketeer.be/dev-guide/annotate-js/
|
||||
angular.module("myApp").controller("helloController", function (gettext: angular.gettext.gettextFunction) {
|
||||
var myString = gettext("Hello");
|
||||
});
|
||||
|
||||
//Translating directly in JavaScript.
|
||||
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
var translated: string = gettextCatalog.getString("Hello");
|
||||
});
|
||||
|
||||
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
var myString2: string = gettextCatalog.getPlural(3, "Bird", "Birds");
|
||||
});
|
||||
|
||||
angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
var translated: string = gettextCatalog.getString("Hello {{name}}", { name: "Ruben" });
|
||||
});
|
||||
|
||||
// Setting strings manually
|
||||
// https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/
|
||||
|
||||
angular.module("myApp").run(function (gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
// Load the strings automatically during initialization.
|
||||
gettextCatalog.setStrings("nl", {
|
||||
"Hello": "Hallo",
|
||||
"One boat": ["Een boot", "{{$count}} boats"]
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
interface helloControllerScope extends ng.IScope {
|
||||
switchLanguage: (lang: string) => void;
|
||||
}
|
||||
// Lazy-loading languages
|
||||
// https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/
|
||||
angular.module("myApp").controller("helloController", function ($scope: helloControllerScope, gettextCatalog: angular.gettext.gettextCatalog) {
|
||||
$scope.switchLanguage = function (lang: string) {
|
||||
gettextCatalog.setCurrentLanguage(lang);
|
||||
gettextCatalog.loadRemote("/languages/" + lang + ".json");
|
||||
};
|
||||
});
|
||||
}
|
||||
73
angular-gettext/angular-gettext.d.ts
vendored
Normal file
73
angular-gettext/angular-gettext.d.ts
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
// Type definitions for angular-gettext v2.1.0
|
||||
// Project: https://angular-gettext.rocketeer.be/
|
||||
// Definitions by: Ákos Lukács <https://github.com/AkosLukacs>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular.gettext {
|
||||
interface gettextCatalog {
|
||||
|
||||
//////////////
|
||||
/// Fields ///
|
||||
//////////////
|
||||
|
||||
/** (default: false): Whether or not to prefix untranslated strings with [MISSING]: or a custom prefix. */
|
||||
debug: boolean;
|
||||
/** (default: [MISSING]:): Custom prefix for untranslated strings. */
|
||||
debugPrefix: string;
|
||||
/** (default: false): Whether or not to wrap all processed text with markers.Example output: [Welcome] */
|
||||
showTranslatedMarkers: boolean;
|
||||
/** (default: [): Custom prefix to mark strings that have been run through angular-gettext. */
|
||||
translatedMarkerPrefix: string;
|
||||
/** (default: ]): Custom suffix to mark strings that have been run through angular-gettext. */
|
||||
translatedMarkerSuffix: string;
|
||||
/** An object of loaded translation strings.Shouldn't be used directly. */
|
||||
strings: {};
|
||||
/** The default language, in which you're application is written. This defaults to English and it's generally a bad idea to use anything else: if your language has different pluralization rules you'll end up with incorrect translations. Deprecated
|
||||
* @deprecreated
|
||||
*/
|
||||
baseLanguage: string;
|
||||
|
||||
|
||||
///////////////
|
||||
/// Methods ///
|
||||
///////////////
|
||||
|
||||
/** Sets the current language and makes sure that all translations get updated correctly. */
|
||||
setCurrentLanguage(lang: string): void;
|
||||
|
||||
/** Returns the current language. */
|
||||
getCurrentLanguage(): string;
|
||||
|
||||
/** Processes an object of string definitions. More details https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/
|
||||
* @param language A language code.
|
||||
* @param strings A dictionary of strings. The format of this dictionary is:
|
||||
* - Keys: Singular English strings (as defined in the source files)
|
||||
* - Values: Either a single string for signular-only strings or an array of plural forms.
|
||||
*/
|
||||
setStrings(language: string, strings: { [key: string]: string|string[] }): void;
|
||||
|
||||
/** Get the correct pluralized (but untranslated) string for the value of n. */
|
||||
getStringForm(string: string, n: number): string;
|
||||
|
||||
/** Translate a string with the given context. Uses Angular.JS interpolation, so something like this will do what you expect:
|
||||
* var hello = gettextCatalog.getString("Hello {{name}}!", { name: "Ruben" });
|
||||
* // var hello will be "Hallo Ruben!" in Dutch.
|
||||
* The context parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
|
||||
*/
|
||||
getString(string: string, context?: any): string;
|
||||
|
||||
/** Translate a plural string with the given context. */
|
||||
getPlural(n: number, string: string, stringPlural: string, context?: any): string;
|
||||
|
||||
/** Load a set of translation strings from a given URL.This should be a JSON catalog generated with grunt-angular-gettext. More details https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/ */
|
||||
loadRemote(url: string): ng.IHttpPromise<any>;
|
||||
}
|
||||
|
||||
/** If you have text that should be translated in your JavaScript code, wrap it with a call to a function named gettext. This module provides an injectable function to do so */
|
||||
interface gettextFunction {
|
||||
(dummyString: string): string;
|
||||
}
|
||||
}
|
||||
|
||||
53
angular-growl-v2/angular-growl-v2-test.ts
Normal file
53
angular-growl-v2/angular-growl-v2-test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/// <reference path="angular-growl-v2.d.ts" />
|
||||
|
||||
var app = angular.module("ag", ["pascalprecht.translate", "$httpProvider"]);
|
||||
|
||||
app.config((growlProvider:angular.growl.IGrowlProvider, $httpProvider:angular.IHttpProvider) => {
|
||||
var ttl:angular.growl.IGrowlTTLConfig = {
|
||||
success: 5000,
|
||||
error: 4000
|
||||
};
|
||||
|
||||
growlProvider.globalTimeToLive(ttl);
|
||||
growlProvider.globalTimeToLive(5000);
|
||||
growlProvider.globalDisableCloseButton(true);
|
||||
growlProvider.globalDisableIcons(true);
|
||||
growlProvider.globalReversedOrder(false);
|
||||
growlProvider.globalDisableCountDown(true);
|
||||
growlProvider.messageVariableKey("someKey");
|
||||
growlProvider.globalInlineMessages(false);
|
||||
growlProvider.globalPosition("top-center");
|
||||
growlProvider.messagesKey("someKey");
|
||||
growlProvider.messageTextKey("someKey");
|
||||
growlProvider.messageTitleKey("someKey");
|
||||
growlProvider.messageSeverityKey("someKey");
|
||||
growlProvider.onlyUniqueMessages(false);
|
||||
|
||||
$httpProvider.interceptors.push(growlProvider.serverMessagesInterceptor);
|
||||
});
|
||||
|
||||
app.controller("Ctrl", ($scope:angular.IScope, growl:angular.growl.IGrowlService) => {
|
||||
var config:angular.growl.IGrowlMessageConfig = {
|
||||
ttl: 5000,
|
||||
disableCountDown: true,
|
||||
disableCloseButton: true
|
||||
};
|
||||
|
||||
var message = "Some message";
|
||||
|
||||
growl.warning(message);
|
||||
growl.warning(message, config);
|
||||
growl.error(message);
|
||||
growl.error(message, config);
|
||||
growl.info(message);
|
||||
growl.info(message, config);
|
||||
growl.success(message);
|
||||
growl.success(message, config);
|
||||
growl.general(message);
|
||||
growl.general(message, config);
|
||||
growl.general(message, config, "error");
|
||||
growl.onlyUnique();
|
||||
growl.reverseOrder();
|
||||
growl.inlineMessages();
|
||||
growl.position();
|
||||
});
|
||||
211
angular-growl-v2/angular-growl-v2.d.ts
vendored
Normal file
211
angular-growl-v2/angular-growl-v2.d.ts
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
// Type definitions for Angular Growl 2 v.0.7.3
|
||||
// Project: http://janstevens.github.io/angular-growl-2
|
||||
// Definitions by: Tadeusz Hucal <https://github.com/mkp05>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular.growl {
|
||||
|
||||
/**
|
||||
* Global Time-To-Leave configuration.
|
||||
*/
|
||||
interface IGrowlTTLConfig {
|
||||
success?: number;
|
||||
error?: number;
|
||||
warning?: number;
|
||||
info?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom configuration used in single message call.
|
||||
*/
|
||||
interface IGrowlMessageConfig {
|
||||
title?: string;
|
||||
ttl?: number;
|
||||
disableCountDown?: boolean;
|
||||
disableIcons?: boolean;
|
||||
disableCloseButton?: boolean;
|
||||
referenceId?: number;
|
||||
onclose?: Function;
|
||||
onopen?: Function;
|
||||
}
|
||||
|
||||
/**
|
||||
* Growl message with configuration.
|
||||
*/
|
||||
interface IGrowlMessage extends IGrowlMessageConfig {
|
||||
text: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Growl service provider.
|
||||
*/
|
||||
interface IGrowlProvider extends angular.IServiceProvider {
|
||||
/**
|
||||
* Pre-defined server error interceptor.
|
||||
*/
|
||||
serverMessagesInterceptor: (string|Function)[];
|
||||
|
||||
/**
|
||||
* Set default TTL settings.
|
||||
* @param ttl configuration of TTL for different type of message
|
||||
*/
|
||||
globalTimeToLive(ttl: IGrowlTTLConfig): void;
|
||||
/**
|
||||
* Set default TTL settings.
|
||||
* @param ttl ttl in milliseconds
|
||||
*/
|
||||
globalTimeToLive(ttl: number): void;
|
||||
/**
|
||||
* Set default setting for disabling close button.
|
||||
* @param disableCloseButton
|
||||
*/
|
||||
globalDisableCloseButton(disableCloseButton: boolean): void;
|
||||
/**
|
||||
* Set default setting for disabling icons.
|
||||
* @param disableIcons
|
||||
*/
|
||||
globalDisableIcons(disableIcons: boolean): void;
|
||||
/**
|
||||
* Set reversing order of displaying new messages.
|
||||
* @param reverseOrder
|
||||
*/
|
||||
globalReversedOrder(reverseOrder: boolean): void
|
||||
/**
|
||||
* Set default setting for displaying message disappear countdown.
|
||||
* @param disableCountDown
|
||||
*/
|
||||
globalDisableCountDown(disableCountDown: boolean): void;
|
||||
/**
|
||||
* Set default allowance for inline messages.
|
||||
* @param inline
|
||||
*/
|
||||
globalInlineMessages(inline: boolean): void;
|
||||
/**
|
||||
* Set default message position.
|
||||
* @param position
|
||||
*/
|
||||
globalPosition(position: string): void;
|
||||
/**
|
||||
* Enable/disable displaying only unique messages.
|
||||
* @param onlyUniqueMessages
|
||||
*/
|
||||
onlyUniqueMessages(onlyUniqueMessages: boolean): void;
|
||||
|
||||
/**
|
||||
* Set key where messages are stored (for http interceptor).
|
||||
* @param messageVariableKey
|
||||
*/
|
||||
messagesKey(messageKey: string): void;
|
||||
/**
|
||||
* Set key where message text is stored (for http interceptor).
|
||||
* @param messageVariableKey
|
||||
*/
|
||||
messageTextKey(messageTextKey: string): void;
|
||||
/**
|
||||
* Set key where title of message is stored (for http interceptor).
|
||||
* @param messageVariableKey
|
||||
*/
|
||||
messageTitleKey(messageTitleKey: string): void;
|
||||
/**
|
||||
* Set key where severity of message is stored (for http interceptor).
|
||||
* @param messageVariableKey
|
||||
*/
|
||||
messageSeverityKey(messageSeverityKey: string): void;
|
||||
/**
|
||||
* Set key where variables for message are stored (for http interceptor).
|
||||
* @param messageVariableKey
|
||||
*/
|
||||
messageVariableKey(messageVariableKey: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Growl service.
|
||||
*/
|
||||
interface IGrowlService {
|
||||
/**
|
||||
* Show warning message.
|
||||
* @param message text to display (or code for angular-translate)
|
||||
*/
|
||||
warning(message: string): IGrowlMessage;
|
||||
/**
|
||||
* Show warning message.
|
||||
* @param message text to display (or code for angular-translate)
|
||||
* @param config additional message configuration
|
||||
*/
|
||||
warning(message: string, config: IGrowlMessageConfig): IGrowlMessage;
|
||||
|
||||
/**
|
||||
* Show error message.
|
||||
* @param message text to display (or code for angular-translate)
|
||||
*/
|
||||
error(message: string): IGrowlMessage;
|
||||
/**
|
||||
* Show error message.
|
||||
* @param message text to display (or code for angular-translate)
|
||||
* @param config additional message configuration
|
||||
*/
|
||||
error(message: string, config: IGrowlMessageConfig): IGrowlMessage;
|
||||
|
||||
/**
|
||||
* Show information message.
|
||||
* @param message text to display (or code for angular-translate)
|
||||
*/
|
||||
info(message: string): IGrowlMessage;
|
||||
/**
|
||||
* Show information message.
|
||||
* @param message text to display (or code for angular-translate)
|
||||
* @param config additional message configuration
|
||||
*/
|
||||
info(message: string, config: IGrowlMessageConfig): IGrowlMessage;
|
||||
|
||||
/**
|
||||
* Show success message.
|
||||
* @param message text to display (or code for angular-translate)
|
||||
* @param config additional message configuration
|
||||
*/
|
||||
success(message: string): IGrowlMessage;
|
||||
/**
|
||||
* Show success message.
|
||||
* @param message text to display (or code for angular-translate)
|
||||
*/
|
||||
success(message: string, config: IGrowlMessageConfig): IGrowlMessage;
|
||||
|
||||
/**
|
||||
* Show message (generic).
|
||||
* @param message text to display (or code for angular-translate)
|
||||
*/
|
||||
general(message: string): IGrowlMessage;
|
||||
/**
|
||||
* Show message (generic).
|
||||
* @param message text to display (or code for angular-translate)
|
||||
* @param config additional message configuration
|
||||
*/
|
||||
general(message: string, config: IGrowlMessageConfig): IGrowlMessage;
|
||||
/**
|
||||
* Show message (generic).
|
||||
* @param message text to display (or code for angular-translate)
|
||||
* @param config additional message configuration
|
||||
* @param severity message severity (error, warning, success, info).
|
||||
*/
|
||||
general(message: string, config: IGrowlMessageConfig, severity: string): IGrowlMessage;
|
||||
|
||||
/**
|
||||
* Get current setting for displaying only unique messages.
|
||||
*/
|
||||
onlyUnique(): boolean;
|
||||
/**
|
||||
* Get current setting for reversing messages order.
|
||||
*/
|
||||
reverseOrder(): boolean;
|
||||
/**
|
||||
* Get current allowance for inline messages.
|
||||
*/
|
||||
inlineMessages(): boolean;
|
||||
/**
|
||||
* Get current messages position.
|
||||
*/
|
||||
position(): string;
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,13 @@ var hotkeyProvider: ng.hotkeys.HotkeysProvider;
|
||||
var hotkeyObj: ng.hotkeys.Hotkey;
|
||||
|
||||
hotkeyProvider.add("mod+s", "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} );
|
||||
hotkeyProvider.add(["mod+s"], "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} );
|
||||
hotkeyProvider.add(hotkeyObj);
|
||||
hotkeyProvider.bindTo(scope);
|
||||
hotkeyProvider.del("mod+s");
|
||||
hotkeyProvider.del(["mod+s"]);
|
||||
hotkeyProvider.get("mod+s");
|
||||
hotkeyProvider.get(["mod+s"]);
|
||||
hotkeyProvider.toggleCheatSheet();
|
||||
|
||||
hotkeyProvider.add(hotkeyObj.combo, hotkeyObj.description ,hotkeyObj.callback);
|
||||
@@ -21,5 +24,10 @@ hotkeyProvider.bindTo(scope)
|
||||
combo: 'w',
|
||||
description: 'blah blah',
|
||||
callback: function() {}
|
||||
})
|
||||
.add({
|
||||
combo: ['w', 'mod+w'],
|
||||
description: 'blah blah',
|
||||
callback: function() {}
|
||||
});
|
||||
|
||||
|
||||
26
angular-hotkeys/angular-hotkeys.d.ts
vendored
26
angular-hotkeys/angular-hotkeys.d.ts
vendored
@@ -1,40 +1,50 @@
|
||||
// Type definitions for angular-hotkeys
|
||||
// Project: https://github.com/chieffancypants/angular-hotkeys
|
||||
// Definitions by: Jason Zhao <https://github.com/jlz27>
|
||||
// Definitions by: Jason Zhao <https://github.com/jlz27>, Stefan Steinhart <https://github.com/reppners>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ng.hotkeys {
|
||||
declare module angular.hotkeys {
|
||||
|
||||
interface HotkeysProvider {
|
||||
template: string;
|
||||
templateTitle:string;
|
||||
includeCheatSheet: boolean;
|
||||
cheatSheetHotkey: string;
|
||||
cheatSheetDescription: string;
|
||||
|
||||
add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): void;
|
||||
add(combo: string|string[], callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array<string>, persistent?: boolean): ng.hotkeys.Hotkey;
|
||||
|
||||
add(hotkeyObj: ng.hotkeys.Hotkey): void;
|
||||
add(combo: string|string[], description: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array<string>, persistent?: boolean): ng.hotkeys.Hotkey;
|
||||
|
||||
add(hotkeyObj: ng.hotkeys.Hotkey): ng.hotkeys.Hotkey;
|
||||
|
||||
bindTo(scope : ng.IScope): ng.hotkeys.HotkeysProviderChained;
|
||||
|
||||
del(combo: string): void;
|
||||
del(combo: string|string[]): void;
|
||||
|
||||
get(combo: string): ng.hotkeys.Hotkey;
|
||||
del(hotkeyObj: ng.hotkeys.Hotkey): void;
|
||||
|
||||
get(combo: string|string[]): ng.hotkeys.Hotkey;
|
||||
|
||||
toggleCheatSheet(): void;
|
||||
|
||||
purgeHotkeys(): void;
|
||||
}
|
||||
|
||||
interface HotkeysProviderChained {
|
||||
add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained;
|
||||
add(combo: string|string[], description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained;
|
||||
|
||||
add(hotkeyObj: ng.hotkeys.Hotkey): HotkeysProviderChained;
|
||||
}
|
||||
|
||||
interface Hotkey {
|
||||
combo: string;
|
||||
combo: string|string[];
|
||||
description?: string;
|
||||
callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void;
|
||||
action?: string;
|
||||
allowIn?: Array<string>;
|
||||
persistent?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
2
angular-http-auth/angular-http-auth.d.ts
vendored
2
angular-http-auth/angular-http-auth.d.ts
vendored
@@ -5,7 +5,7 @@
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ng.httpAuth {
|
||||
declare module angular.httpAuth {
|
||||
interface IAuthService {
|
||||
loginConfirmed(data?:any, configUpdater?:Function):void;
|
||||
loginCancelled(data?:any, reason?:any):void;
|
||||
|
||||
23
angular-idle/angular-idle-tests.ts
Normal file
23
angular-idle/angular-idle-tests.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/// <reference path="./angular-idle.d.ts" />
|
||||
|
||||
angular.module('app', ['ngIdle'])
|
||||
.config(['$keepaliveProvider', '$idleProvider',
|
||||
($keepaliveProvider: ng.idle.IKeepAliveProvider, $idleProvider: ng.idle.IIdleProvider) => {
|
||||
$idleProvider.activeOn('mousemove keydown DOMMouseScroll mousewheel mousedown');
|
||||
$idleProvider.idleDuration(5);
|
||||
$idleProvider.warningDuration(5);
|
||||
$idleProvider.keepalive(true)
|
||||
$idleProvider.autoResume(true);
|
||||
$keepaliveProvider.interval(10);
|
||||
}])
|
||||
.run(['$keepalive', '$idle', ($keepalive: ng.idle.IKeepAliveService, $idle: ng.idle.IIdleService) => {
|
||||
$idle.watch();
|
||||
|
||||
if ($idle.running() || $idle.idling()) {
|
||||
$idle.unwatch();
|
||||
}
|
||||
|
||||
$keepalive.start();
|
||||
$keepalive.ping();
|
||||
$keepalive.stop();
|
||||
}]);
|
||||
134
angular-idle/angular-idle.d.ts
vendored
Normal file
134
angular-idle/angular-idle.d.ts
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
// Type definitions for ng-idle v0.3.5
|
||||
// Project: http://hackedbychinese.github.io/ng-idle/
|
||||
// Definitions by: mthamil <https://github.com/mthamil>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular.idle {
|
||||
|
||||
/**
|
||||
* Used to configure the $keepalive service.
|
||||
*/
|
||||
interface IKeepAliveProvider extends IServiceProvider {
|
||||
|
||||
/**
|
||||
* If configured, options will be used to issue a request using $http.
|
||||
* If the value is null, no HTTP request will be issued.
|
||||
* You can specify a string, which it will assume to be a URL to a simple GET request.
|
||||
* Otherwise, you can use the same options $http takes. However, cache will always be false.
|
||||
*
|
||||
* @param value May be string or object, default is null.
|
||||
*/
|
||||
http(value: any): void;
|
||||
|
||||
/**
|
||||
* This specifies how often the keepalive event is triggered and the
|
||||
* HTTP request is issued.
|
||||
*
|
||||
* @param seconds Integer, default is 5 minutes. Must be greater than 0.
|
||||
*/
|
||||
interval(seconds: number): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* $keepalive will use a timeout to periodically wake, broadcast a $keepalive event on the root scope,
|
||||
* and optionally make an $http request. By default, the $idle service will stop and start $keepalive
|
||||
* when a user becomes idle or returns from idle, respectively. It is also started automatically when
|
||||
* $idle.watch() is called. This can be disabled by configuring the $idleProvider.
|
||||
*/
|
||||
interface IKeepAliveService {
|
||||
|
||||
/**
|
||||
* Starts pinging periodically until stop() is called.
|
||||
*/
|
||||
start(): void;
|
||||
|
||||
/**
|
||||
* Stops pinging.
|
||||
*/
|
||||
stop(): void;
|
||||
|
||||
/**
|
||||
* Performs one ping only.
|
||||
*/
|
||||
ping(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to configure the $idle service.
|
||||
*/
|
||||
interface IIdleProvider extends IServiceProvider {
|
||||
|
||||
/**
|
||||
* Specifies the DOM events the service will watch to reset the idle timeout.
|
||||
* Multiple events should be separated by a space.
|
||||
*
|
||||
* @param events string, default 'mousemove keydown DOMMouseScroll mousewheel mousedown'
|
||||
*/
|
||||
activeOn(events: string): void;
|
||||
|
||||
/**
|
||||
* The idle timeout duration in seconds. After this amount of time passes without the user
|
||||
* performing an action that triggers one of the watched DOM events, the user is considered
|
||||
* idle.
|
||||
*
|
||||
* @param seconds integer, default is 20min
|
||||
*/
|
||||
idleDuration(seconds: number): void;
|
||||
|
||||
/**
|
||||
* The amount of time the user has to respond (in seconds) before they have been considered
|
||||
* timed out.
|
||||
*
|
||||
* @param seconds integer, default is 30s
|
||||
*/
|
||||
warningDuration(seconds: number): void;
|
||||
|
||||
/**
|
||||
* When true, user activity will automatically interrupt the warning countdown and reset the
|
||||
* idle state. If false, you will need to manually call watch() when you want to start
|
||||
* watching for idleness again.
|
||||
*
|
||||
* @param enabled boolean, default is true
|
||||
*/
|
||||
autoResume(enabled: boolean): void;
|
||||
|
||||
/**
|
||||
* When true, the $keepalive service is automatically stopped and started as needed.
|
||||
*
|
||||
* @param enabled boolean, default is true
|
||||
*/
|
||||
keepalive(enabled: boolean): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* $idle, once watch() is called, will start a timeout which if expires, will enter a warning state
|
||||
* countdown. Once the countdown reaches zero, idle will broadcast a timeout event indicating the
|
||||
* user has timed out (where your app should log them out or whatever you like). If the user performs
|
||||
* an action that triggers a watched DOM event that bubbles up to document.body, this will reset the
|
||||
* idle/warning state and start the process over again.
|
||||
*/
|
||||
interface IIdleService {
|
||||
|
||||
/**
|
||||
* Whether or not the watch() has been called and it is watching for idleness.
|
||||
*/
|
||||
running(): boolean;
|
||||
|
||||
/**
|
||||
* Whether or not the user appears to be idle.
|
||||
*/
|
||||
idling(): boolean;
|
||||
|
||||
/**
|
||||
* Starts watching for idleness, or resets the idle/warning state and continues watching.
|
||||
*/
|
||||
watch(): void;
|
||||
|
||||
/**
|
||||
* Stops watching for idleness, and resets the idle/warning state.
|
||||
*/
|
||||
unwatch(): void;
|
||||
}
|
||||
}
|
||||
17
angular-jwt/angular-jwt-tests.ts
Normal file
17
angular-jwt/angular-jwt-tests.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
/// <reference path="angular-jwt.d.ts" />
|
||||
|
||||
var app = angular.module("angular-jwt-tests", ["angular-jwt"]);
|
||||
|
||||
var $jwtHelper: angular.jwt.IJwtHelper;
|
||||
|
||||
var expToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NhbXBsZXMuYXV0aDAuY29tLyIsInN1YiI6ImZhY2Vib29rfDEwMTU0Mjg3MDI3NTEwMzAyIiwiYXVkIjoiQlVJSlNXOXg2MHNJSEJ3OEtkOUVtQ2JqOGVESUZ4REMiLCJleHAiOjE0MTIyMzQ3MzAsImlhdCI6MTQxMjE5ODczMH0.7M5sAV50fF1-_h9qVbdSgqAnXVF7mz3I6RjS6JiH0H8';
|
||||
var tokenPayload = $jwtHelper.decodeToken(expToken);
|
||||
var date = $jwtHelper.getTokenExpirationDate(expToken);
|
||||
var bool = $jwtHelper.isTokenExpired(expToken);
|
||||
|
||||
var $jwtInterceptor: angular.jwt.IJwtInterceptor;
|
||||
|
||||
$jwtInterceptor.tokenGetter = () => {
|
||||
return expToken;
|
||||
}
|
||||
30
angular-jwt/angular-jwt.d.ts
vendored
Normal file
30
angular-jwt/angular-jwt.d.ts
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// Type definitions for angular-jwt 0.0.8
|
||||
// Project: https://github.com/auth0/angular-jwt
|
||||
// Definitions by: Reto Rezzonico <https://github.com/rerezz>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular.jwt {
|
||||
|
||||
interface JwtToken {
|
||||
iss: string;
|
||||
sub: string;
|
||||
aud: string;
|
||||
exp: number;
|
||||
nbf: number;
|
||||
iat: number;
|
||||
jti: string;
|
||||
unique_name: string;
|
||||
}
|
||||
|
||||
interface IJwtHelper {
|
||||
decodeToken(token: string): JwtToken;
|
||||
getTokenExpirationDate(token: any): Date;
|
||||
isTokenExpired(token: any, offsetSeconds?: number): boolean;
|
||||
}
|
||||
|
||||
interface IJwtInterceptor {
|
||||
tokenGetter(): string;
|
||||
}
|
||||
}
|
||||
73
angular-local-storage/angular-local-storage-tests.ts
Normal file
73
angular-local-storage/angular-local-storage-tests.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
/// <reference path='../angularjs/angular.d.ts' />
|
||||
/// <reference path='angular-local-storage.d.ts' />
|
||||
|
||||
interface TestScope extends ng.IScope {
|
||||
submit: (key: string, value: string) => boolean;
|
||||
getItem: (key: string) => string;
|
||||
removeItem: (key: string) => boolean;
|
||||
clearNumbers: () => boolean;
|
||||
clearAll: () => boolean;
|
||||
unbind: Function;
|
||||
update: (val: string) => void;
|
||||
property: string;
|
||||
}
|
||||
|
||||
export class TestController {
|
||||
constructor($scope: TestScope, localStorageService: ng.local.storage.ILocalStorageService) {
|
||||
// isSupported
|
||||
if (localStorageService.isSupported) {
|
||||
// do something
|
||||
}
|
||||
|
||||
// getStorageType
|
||||
var storageType: string = localStorageService.getStorageType();
|
||||
|
||||
// set
|
||||
$scope.submit = (key, value) => {
|
||||
return localStorageService.set(key, value);
|
||||
};
|
||||
|
||||
// get
|
||||
$scope.getItem = (key) => {
|
||||
return localStorageService.get<string>(key);
|
||||
};
|
||||
|
||||
// remove
|
||||
$scope.removeItem = (key) => {
|
||||
return localStorageService.remove(key);
|
||||
};
|
||||
|
||||
// clearAll(regexp)
|
||||
$scope.clearNumbers = () => {
|
||||
return localStorageService.clearAll(/^\d+$/);
|
||||
};
|
||||
|
||||
// clearAll
|
||||
$scope.clearAll = () => {
|
||||
return localStorageService.clearAll();
|
||||
};
|
||||
|
||||
// keys
|
||||
var lsKeys = localStorageService.keys();
|
||||
|
||||
// bind
|
||||
localStorageService.set('property', 'oldValue');
|
||||
$scope.unbind = localStorageService.bind($scope, 'property');
|
||||
|
||||
// deriveKey
|
||||
console.log(localStorageService.deriveKey('property')); // ls.property
|
||||
|
||||
// length
|
||||
var lsLength: number = localStorageService.length();
|
||||
}
|
||||
}
|
||||
|
||||
var app = angular.module('angular-local-storage-tests', ['LocalStorageModule']);
|
||||
app.config(function (localStorageServiceProvider: ng.local.storage.ILocalStorageServiceProvider) {
|
||||
localStorageServiceProvider
|
||||
.setPrefix('myApp')
|
||||
.setStorageType('sessionStorage')
|
||||
.setNotify(true, true);
|
||||
});
|
||||
|
||||
app.controller('TestController', TestController);
|
||||
149
angular-local-storage/angular-local-storage.d.ts
vendored
Normal file
149
angular-local-storage/angular-local-storage.d.ts
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
// Type definitions for angular-local-storage v0.1.5
|
||||
// Project: https://github.com/grevory/angular-local-storage
|
||||
// Definitions by: Ken Fukuyama <https://github.com/kenfdev>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path='../angularjs/angular.d.ts' />
|
||||
|
||||
declare module angular.local.storage {
|
||||
interface ILocalStorageServiceProvider extends angular.IServiceProvider {
|
||||
/**
|
||||
* Setter for the prefix
|
||||
* You should set a prefix to avoid overwriting any local storage variables from the rest of your app
|
||||
* e.g. localStorageServiceProvider.setPrefix('youAppName');
|
||||
* With provider you can use config as this:
|
||||
* myApp.config(function (localStorageServiceProvider) {
|
||||
* localStorageServiceProvider.prefix = 'yourAppName';
|
||||
* });
|
||||
* @param prefix default: ls.<your-key>
|
||||
*/
|
||||
setPrefix(prefix: string):ILocalStorageServiceProvider;
|
||||
/**
|
||||
* Setter for the storageType
|
||||
* @param storageType localstorage or sessionStorage. default: localStorage
|
||||
*/
|
||||
setStorageType(storageType: string):ILocalStorageServiceProvider;
|
||||
/**
|
||||
* Setter for cookie config
|
||||
* @param exp number of days before cookies expire (0 = does not expire). default: 30
|
||||
* @param path the web path the cookie represents. default: '/'
|
||||
*/
|
||||
setStorageCookie(exp: number, path: string):ILocalStorageServiceProvider;
|
||||
/**
|
||||
* Set the cookie domain, since this runs inside a the config() block, only providers and constants can be injected. As a result, $location service can't be used here, use a hardcoded string or window.location.
|
||||
* No default value
|
||||
*/
|
||||
setStorageCookieDomain(domain: string):ILocalStorageServiceProvider;
|
||||
/**
|
||||
* Send signals for each of the following actions:
|
||||
* @param setItem default: true
|
||||
* @param removeItem default: false
|
||||
*/
|
||||
setNotify(setItem: boolean, removeItem: boolean):ILocalStorageServiceProvider;
|
||||
}
|
||||
|
||||
interface ICookie {
|
||||
/**
|
||||
* Checks if cookies are enabled in the browser.
|
||||
* Returns: Boolean
|
||||
*/
|
||||
isSupported:boolean;
|
||||
/**
|
||||
* Directly adds a value to cookies.
|
||||
* Note: Typically used as a fallback if local storage is not supported.
|
||||
* Returns: Boolean
|
||||
* @param key
|
||||
* @param val
|
||||
*/
|
||||
set(key:string, val:string):boolean;
|
||||
/**
|
||||
* Directly get a value from a cookie.
|
||||
* Returns: value from local storage
|
||||
* @param key
|
||||
*/
|
||||
get(key:string):string;
|
||||
/**
|
||||
* Remove directly value from a cookie.
|
||||
* Returns: Boolean
|
||||
* @param key
|
||||
*/
|
||||
remove(key:string):boolean;
|
||||
/**
|
||||
* Remove all data for this app from cookie.
|
||||
*/
|
||||
clearAll():any;
|
||||
|
||||
}
|
||||
|
||||
interface ILocalStorageService {
|
||||
/**
|
||||
* Checks if the browser support the current storage type(e.g: localStorage, sessionStorage).
|
||||
* Returns: Boolean
|
||||
*/
|
||||
isSupported:boolean;
|
||||
/**
|
||||
* Returns: String
|
||||
*/
|
||||
getStorageType():string;
|
||||
/**
|
||||
* Directly adds a value to local storage.
|
||||
* If local storage is not supported, use cookies instead.
|
||||
* Returns: Boolean
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
set<T>(key: string, value: T): boolean;
|
||||
/**
|
||||
* Directly get a value from local storage.
|
||||
* If local storage is not supported, use cookies instead.
|
||||
* Returns: value from local storage
|
||||
* @param key
|
||||
*/
|
||||
get<T>(key: string): T;
|
||||
/**
|
||||
* Return array of keys for local storage, ignore keys that not owned.
|
||||
* Returns: value from local storage
|
||||
*/
|
||||
keys(): string[];
|
||||
/**
|
||||
* Remove an item from local storage by key.
|
||||
* If local storage is not supported, use cookies instead.
|
||||
* Returns: Boolean
|
||||
* @param key
|
||||
*/
|
||||
remove(key: string): boolean;
|
||||
/**
|
||||
* Remove all data for this app from local storage.
|
||||
* If local storage is not supported, use cookies instead.
|
||||
* Note: Optionally takes a regular expression string and removes matching.
|
||||
* Returns: Boolean
|
||||
* @param regularExpression
|
||||
*/
|
||||
clearAll(regularExpression?:RegExp):boolean;
|
||||
/**
|
||||
* Bind $scope key to localStorageService.
|
||||
* Usage: localStorageService.bind(scope, property, value[optional], key[optional])
|
||||
* Returns: deregistration function for this listener.
|
||||
* @param scope
|
||||
* @param property
|
||||
* @param value optional
|
||||
* @param key The corresponding key used in local storage
|
||||
*/
|
||||
bind(scope: angular.IScope, property: string, value?: any, key?: string): Function;
|
||||
/**
|
||||
* Return the derive key
|
||||
* Returns String
|
||||
* @param key
|
||||
*/
|
||||
deriveKey(key:string):string;
|
||||
/**
|
||||
* Return localStorageService.length, ignore keys that not owned.
|
||||
* Returns Number
|
||||
*/
|
||||
length():number;
|
||||
/**
|
||||
* Deal with browser's cookies directly.
|
||||
*/
|
||||
cookie:ICookie;
|
||||
}
|
||||
}
|
||||
141
angular-localForage/angular-localForage-tests.ts
Normal file
141
angular-localForage/angular-localForage-tests.ts
Normal file
@@ -0,0 +1,141 @@
|
||||
/// <reference path='../angularjs/angular.d.ts' />
|
||||
/// <reference path='angular-localForage.d.ts' />
|
||||
|
||||
var app = angular.module('angular-localForage-tests', ['LocalForageModule']);
|
||||
app.config(function (localStorageServiceProvider:angular.localForage.ILocalForageProvider) {
|
||||
|
||||
//TODO
|
||||
});
|
||||
|
||||
var $rootScope:angular.IRootScopeService,
|
||||
$localForage:angular.localForage.ILocalForageService,
|
||||
instanceVersion = 0;
|
||||
|
||||
// create a fresh instance
|
||||
$localForage.clear().then(function () {
|
||||
$localForage = $localForage.createInstance({
|
||||
name: ++instanceVersion
|
||||
});
|
||||
});
|
||||
|
||||
$localForage.getItem('this key is unknown').then(function (value) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
$localForage.setItem('myName', 'Olivier Combe').then(function (data) {
|
||||
|
||||
$localForage.getItem('myName').then(function (data) {
|
||||
});
|
||||
});
|
||||
|
||||
var values = ['Olivier Combe', 'AngularJs', 'Open Source'];
|
||||
|
||||
$localForage.setItem(['myName', 'myPassion', 'myHobbie'], values).then(function (data) {
|
||||
|
||||
$localForage.getItem(['myHobbie', 'myName']).then(function (data) {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$localForage.removeItem('myName').then(function () {
|
||||
|
||||
$localForage.getItem('myName').then(function (data) {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$localForage.removeItem(['myName', 'myPassion']).then(function () {
|
||||
|
||||
$localForage.getItem(['myName', 'myPassion', 'myHobbie']).then(function (data) {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$localForage.pull('myName').then(function (data) {
|
||||
|
||||
$localForage.getItem('myName').then(function (data) {
|
||||
});
|
||||
|
||||
});
|
||||
$localForage.pull(['myName', 'myPassion']).then(function (data) {
|
||||
|
||||
$localForage.getItem(['myName', 'myPassion', 'myHobbie']).then(function (data) {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$localForage.setItem('myName', 'Olivier Combe').then(function (d) {
|
||||
|
||||
$localForage.getItem('myName').then(function (data) {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$localForage.setDriver('localStorageWrapper').then(function () {
|
||||
$localForage.setItem('myName', 'Olivier Combe').then(function (d) {
|
||||
$localForage.getItem('myName').then(function (data) {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$localForage.setItem('myArray', [{
|
||||
$$hashKey: '00A',
|
||||
name: 'Olivier Combe'
|
||||
}]).then(function (d) {
|
||||
|
||||
$localForage.getItem('myArray').then(function (data) {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$localForage.setDriver('localStorageWrapper').then(function () {
|
||||
$localForage.setItem('myArray', [{
|
||||
$$hashKey: '00A',
|
||||
name: 'Olivier Combe'
|
||||
}]).then(function (d) {
|
||||
|
||||
$localForage.getItem('myArray').then(function (data) {
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
var aFileParts = ["<a id=\"a\"><b id=\"b\">hey!<\/b><\/a>"];
|
||||
var oMyBlob = new Blob(aFileParts, {"type": "text\/xml"}); // the blob
|
||||
|
||||
$localForage.setItem('myBlob', oMyBlob).then(function (data) {
|
||||
});
|
||||
|
||||
// $localForage.setItem(['myName', 'myPassion', 'myHobbie'], 'value');
|
||||
|
||||
// $localForage.setItem();
|
||||
|
||||
|
||||
$localForage.iterate(function (value, key) {
|
||||
}).then(function (data) {
|
||||
});
|
||||
|
||||
$localForage.iterate(function (value, key) {
|
||||
if (key == 'myPassion') {
|
||||
return value;
|
||||
}
|
||||
}).then(function (data) {
|
||||
});
|
||||
|
||||
$localForage.bind($rootScope, 'key').then(function(data) {
|
||||
});
|
||||
|
||||
$localForage.bind($rootScope, {key: 'key'}).then(function(data) {
|
||||
});
|
||||
|
||||
$localForage.bind($rootScope, {key: 'key', defaultValue: 'defaultValue'}).then(function(data) {
|
||||
});
|
||||
|
||||
$localForage.bind($rootScope, {key: 'key', scopeKey: 'scopeKey'}).then(function(data) {
|
||||
});
|
||||
|
||||
$localForage.bind($rootScope, {key: 'key', name: 'name'}).then(function(data) {
|
||||
});
|
||||
63
angular-localForage/angular-localForage.d.ts
vendored
Normal file
63
angular-localForage/angular-localForage.d.ts
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Type definitions for angular-localForage 1.2.2
|
||||
// Project: https://github.com/ocombe/angular-localForage
|
||||
// Definitions by: Stefan Steinhart <https://github.com/reppners>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../localForage/localForage.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular.localForage {
|
||||
|
||||
interface LocalForageConfig {
|
||||
driver?:string;
|
||||
name?:string | number;
|
||||
version?:number;
|
||||
storeName?:string;
|
||||
description?:string;
|
||||
}
|
||||
|
||||
interface ILocalForageProvider {
|
||||
config(config:LocalForageConfig):void;
|
||||
setNotify(onItemSet:boolean, onItemRemove:boolean):void;
|
||||
}
|
||||
|
||||
interface ILocalForageService {
|
||||
setDriver(driver:string):angular.IPromise<void>;
|
||||
driver<T>():lf.ILocalForage<T>;
|
||||
|
||||
setItem(key:string, value:any):angular.IPromise<void>;
|
||||
setItem(keys:Array<string>, values:Array<any>):angular.IPromise<void>;
|
||||
|
||||
getItem(key:string):angular.IPromise<any>;
|
||||
getItem(keys:Array<string>):angular.IPromise<Array<any>>;
|
||||
|
||||
removeItem(key:string | Array<string>):angular.IPromise<void>;
|
||||
|
||||
pull(key:string):angular.IPromise<any>;
|
||||
pull(keys:Array<string>):angular.IPromise<Array<any>>;
|
||||
|
||||
clear():angular.IPromise<void>;
|
||||
|
||||
key(n:number):angular.IPromise<string>;
|
||||
|
||||
keys():angular.IPromise<string>;
|
||||
|
||||
length():angular.IPromise<number>;
|
||||
|
||||
iterate<T>(iteratorCallback:(value:string | number, key:string)=>T):angular.IPromise<T>;
|
||||
|
||||
bind($scope:ng.IScope, key:string):angular.IPromise<any>;
|
||||
|
||||
bind($scope:ng.IScope, config:{
|
||||
key:string;
|
||||
defaultValue?:any;
|
||||
scopeKey?:string;
|
||||
name?:string;
|
||||
}):angular.IPromise<any>;
|
||||
|
||||
unbind($scope:ng.IScope, key:string, scopeKey?:string):void;
|
||||
|
||||
createInstance(config:LocalForageConfig):ILocalForageService;
|
||||
instance(name:string):ILocalForageService;
|
||||
}
|
||||
}
|
||||
195
angular-material/angular-material-0.8.3.d.ts
vendored
Normal file
195
angular-material/angular-material-0.8.3.d.ts
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
// Type definitions for Angular Material 0.8.3+ (angular.material module)
|
||||
// Project: https://github.com/angular/material
|
||||
// Definitions by: Matt Traynham <https://github.com/mtraynham>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
declare module angular.material {
|
||||
|
||||
interface MDBottomSheetOptions {
|
||||
templateUrl?: string;
|
||||
template?: string;
|
||||
controller?: any;
|
||||
locals?: {[index: string]: any};
|
||||
targetEvent?: any;
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: Element;
|
||||
disableParentScroll?: boolean;
|
||||
}
|
||||
|
||||
interface MDBottomSheetService {
|
||||
show(options: MDBottomSheetOptions): angular.IPromise<any>;
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
|
||||
interface MDPresetDialog<T> {
|
||||
title(title: string): T;
|
||||
content(content: string): T;
|
||||
ok(content: string): T;
|
||||
theme(theme: string): T;
|
||||
}
|
||||
|
||||
interface MDAlertDialog extends MDPresetDialog<MDAlertDialog> {
|
||||
}
|
||||
|
||||
interface MDConfirmDialog extends MDPresetDialog<MDConfirmDialog> {
|
||||
cancel(reason?: string): MDConfirmDialog;
|
||||
}
|
||||
|
||||
interface MDDialogOptions {
|
||||
templateUrl?: string;
|
||||
template?: string;
|
||||
domClickEvent?: any;
|
||||
disableParentScroll?: boolean;
|
||||
clickOutsideToClose?: boolean;
|
||||
hasBackdrop?: boolean;
|
||||
escapeToClose?: boolean;
|
||||
controller?: any;
|
||||
locals?: {[index: string]: any};
|
||||
bindToController?: boolean;
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: Element;
|
||||
onComplete?: Function;
|
||||
}
|
||||
|
||||
interface MDDialogService {
|
||||
show(dialog: MDDialogOptions|MDPresetDialog<any>): angular.IPromise<any>;
|
||||
confirm(): MDConfirmDialog;
|
||||
alert(): MDAlertDialog;
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
|
||||
interface MDIcon {
|
||||
(path: string): angular.IPromise<Element>;
|
||||
}
|
||||
|
||||
interface MDIconProvider {
|
||||
icon(id: string, url: string, iconSize?: string): MDIconProvider;
|
||||
iconSet(id: string, url: string, iconSize?: string): MDIconProvider;
|
||||
defaultIconSet(url: string, iconSize?: string): MDIconProvider;
|
||||
defaultIconSize(iconSize: string): MDIconProvider;
|
||||
}
|
||||
|
||||
interface MDMedia {
|
||||
(media: string): boolean;
|
||||
}
|
||||
|
||||
interface MDSidenavObject {
|
||||
toggle(): void;
|
||||
open(): void;
|
||||
close(): void;
|
||||
isOpen(): boolean;
|
||||
isLockedOpen(): boolean;
|
||||
}
|
||||
|
||||
interface MDSidenavService {
|
||||
(component: string): MDSidenavObject;
|
||||
}
|
||||
|
||||
interface MDToastPreset<T> {
|
||||
content(content: string): T;
|
||||
action(action: string): T;
|
||||
highlightAction(highlightAction: boolean): T;
|
||||
capsule(capsule: boolean): T;
|
||||
theme(theme: string): T;
|
||||
hideDelay(delay: number): T;
|
||||
}
|
||||
|
||||
interface MDSimpleToastPreset extends MDToastPreset<MDSimpleToastPreset> {
|
||||
}
|
||||
|
||||
interface MDToastOptions {
|
||||
templateUrl?: string;
|
||||
template?: string;
|
||||
hideDelay?: number;
|
||||
position?: string;
|
||||
controller?: any;
|
||||
locals?: {[index: string]: any};
|
||||
bindToController?: boolean;
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: Element;
|
||||
}
|
||||
|
||||
interface MDToastService {
|
||||
show(optionsOrPreset: MDToastOptions|MDToastPreset<any>): angular.IPromise<any>;
|
||||
showSimple(): angular.IPromise<any>;
|
||||
simple(): MDSimpleToastPreset;
|
||||
build(): MDToastPreset<any>;
|
||||
updateContent(): void;
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
|
||||
interface MDPalette {
|
||||
0?: string;
|
||||
50?: string;
|
||||
100?: string;
|
||||
200?: string;
|
||||
300?: string;
|
||||
400?: string;
|
||||
500?: string;
|
||||
600?: string;
|
||||
700?: string;
|
||||
800?: string;
|
||||
900?: string;
|
||||
A100?: string;
|
||||
A200?: string;
|
||||
A400?: string;
|
||||
A700?: string;
|
||||
contrastDefaultColor?: string;
|
||||
contrastDarkColors?: string;
|
||||
contrastStrongLightColors?: string;
|
||||
}
|
||||
|
||||
interface MDThemeHues {
|
||||
default?: string;
|
||||
'hue-1'?: string;
|
||||
'hue-2'?: string;
|
||||
'hue-3'?: string;
|
||||
}
|
||||
|
||||
interface MDThemePalette {
|
||||
name: string;
|
||||
hues: MDThemeHues;
|
||||
}
|
||||
|
||||
interface MDThemeColors {
|
||||
accent: MDThemePalette;
|
||||
background: MDThemePalette;
|
||||
primary: MDThemePalette;
|
||||
warn: MDThemePalette;
|
||||
}
|
||||
|
||||
interface MDThemeGrayScalePalette {
|
||||
1: string;
|
||||
2: string;
|
||||
3: string;
|
||||
4: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface MDTheme {
|
||||
name: string;
|
||||
colors: MDThemeColors;
|
||||
foregroundPalette: MDThemeGrayScalePalette;
|
||||
foregroundShadow: string;
|
||||
accentPalette(name: string, hues?: MDThemeHues): MDTheme;
|
||||
primaryPalette(name: string, hues?: MDThemeHues): MDTheme;
|
||||
warnPalette(name: string, hues?: MDThemeHues): MDTheme;
|
||||
backgroundPalette(name: string, hues?: MDThemeHues): MDTheme;
|
||||
dark(isDark?: boolean): MDTheme;
|
||||
}
|
||||
|
||||
interface MDThemingProvider {
|
||||
theme(name: string, inheritFrom?: string): MDTheme;
|
||||
definePalette(name: string, palette: MDPalette): MDThemingProvider;
|
||||
extendPalette(name: string, palette: MDPalette): MDPalette;
|
||||
setDefaultTheme(theme: string): void;
|
||||
alwaysWatchTheme(alwaysWatch: boolean): void;
|
||||
}
|
||||
}
|
||||
204
angular-material/angular-material-0.9.0.d.ts
vendored
Normal file
204
angular-material/angular-material-0.9.0.d.ts
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
// Type definitions for Angular Material 0.9.0-rc1+ (angular.material module)
|
||||
// Project: https://github.com/angular/material
|
||||
// Definitions by: Matt Traynham <https://github.com/mtraynham>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
declare module angular.material {
|
||||
|
||||
interface MDBottomSheetOptions {
|
||||
templateUrl?: string;
|
||||
template?: string;
|
||||
scope?: angular.IScope; // default: new child scope
|
||||
preserveScope?: boolean; // default: false
|
||||
controller?: string|Function;
|
||||
locals?: {[index: string]: any};
|
||||
targetEvent?: MouseEvent;
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: string|Element|JQuery; // default: root node
|
||||
disableParentScroll?: boolean; // default: true
|
||||
}
|
||||
|
||||
interface MDBottomSheetService {
|
||||
show(options: MDBottomSheetOptions): angular.IPromise<any>;
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
|
||||
interface MDPresetDialog<T> {
|
||||
title(title: string): T;
|
||||
content(content: string): T;
|
||||
ok(ok: string): T;
|
||||
theme(theme: string): T;
|
||||
}
|
||||
|
||||
interface MDAlertDialog extends MDPresetDialog<MDAlertDialog> {
|
||||
}
|
||||
|
||||
interface MDConfirmDialog extends MDPresetDialog<MDConfirmDialog> {
|
||||
cancel(cancel: string): MDConfirmDialog;
|
||||
}
|
||||
|
||||
interface MDDialogOptions {
|
||||
templateUrl?: string;
|
||||
template?: string;
|
||||
targetEvent?: MouseEvent;
|
||||
scope?: angular.IScope; // default: new child scope
|
||||
preserveScope?: boolean; // default: false
|
||||
disableParentScroll?: boolean; // default: true
|
||||
hasBackdrop?: boolean // default: true
|
||||
clickOutsideToClose?: boolean; // default: false
|
||||
escapeToClose?: boolean; // default: true
|
||||
focusOnOpen?: boolean; // default: true
|
||||
controller?: string|Function;
|
||||
locals?: {[index: string]: any};
|
||||
bindToController?: boolean; // default: false
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: string|Element|JQuery; // default: root node
|
||||
onComplete?: Function;
|
||||
}
|
||||
|
||||
interface MDDialogService {
|
||||
show(dialog: MDDialogOptions|MDAlertDialog|MDConfirmDialog): angular.IPromise<any>;
|
||||
confirm(): MDConfirmDialog;
|
||||
alert(): MDAlertDialog;
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
|
||||
interface MDIcon {
|
||||
(id: string): angular.IPromise<Element>; // id is a unique ID or URL
|
||||
}
|
||||
|
||||
interface MDIconProvider {
|
||||
icon(id: string, url: string, iconSize?: string): MDIconProvider; // iconSize default: '24px'
|
||||
iconSet(id: string, url: string, iconSize?: string): MDIconProvider; // iconSize default: '24px'
|
||||
defaultIconSet(url: string, iconSize?: string): MDIconProvider; // iconSize default: '24px'
|
||||
defaultIconSize(iconSize: string): MDIconProvider; // default: '24px'
|
||||
}
|
||||
|
||||
interface MDMedia {
|
||||
(media: string): boolean;
|
||||
}
|
||||
|
||||
interface MDSidenavObject {
|
||||
toggle(): angular.IPromise<void>;
|
||||
open(): angular.IPromise<void>;
|
||||
close(): angular.IPromise<void>;
|
||||
isOpen(): boolean;
|
||||
isLockedOpen(): boolean;
|
||||
}
|
||||
|
||||
interface MDSidenavService {
|
||||
(component: string): MDSidenavObject;
|
||||
}
|
||||
|
||||
interface MDToastPreset<T> {
|
||||
content(content: string): T;
|
||||
action(action: string): T;
|
||||
highlightAction(highlightAction: boolean): T;
|
||||
capsule(capsule: boolean): T;
|
||||
theme(theme: string): T;
|
||||
hideDelay(delay: number): T;
|
||||
position(position: string): T;
|
||||
}
|
||||
|
||||
interface MDSimpleToastPreset extends MDToastPreset<MDSimpleToastPreset> {
|
||||
}
|
||||
|
||||
interface MDToastOptions {
|
||||
templateUrl?: string;
|
||||
template?: string;
|
||||
scope?: angular.IScope; // default: new child scope
|
||||
preserveScope?: boolean; // default: false
|
||||
hideDelay?: number; // default (ms): 3000
|
||||
position?: string; // any combination of 'bottom'/'left'/'top'/'right'/'fit'; default: 'bottom left'
|
||||
controller?: string|Function;
|
||||
locals?: {[index: string]: any};
|
||||
bindToController?: boolean; // default: false
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: string|Element|JQuery; // default: root node
|
||||
}
|
||||
|
||||
interface MDToastService {
|
||||
show(optionsOrPreset: MDToastOptions|MDToastPreset<any>): angular.IPromise<any>;
|
||||
showSimple(): angular.IPromise<any>;
|
||||
simple(): MDSimpleToastPreset;
|
||||
build(): MDToastPreset<any>;
|
||||
updateContent(): void;
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
|
||||
interface MDPalette {
|
||||
0?: string;
|
||||
50?: string;
|
||||
100?: string;
|
||||
200?: string;
|
||||
300?: string;
|
||||
400?: string;
|
||||
500?: string;
|
||||
600?: string;
|
||||
700?: string;
|
||||
800?: string;
|
||||
900?: string;
|
||||
A100?: string;
|
||||
A200?: string;
|
||||
A400?: string;
|
||||
A700?: string;
|
||||
contrastDefaultColor?: string;
|
||||
contrastDarkColors?: string|string[];
|
||||
contrastLightColors?: string|string[];
|
||||
}
|
||||
|
||||
interface MDThemeHues {
|
||||
default?: string;
|
||||
'hue-1'?: string;
|
||||
'hue-2'?: string;
|
||||
'hue-3'?: string;
|
||||
}
|
||||
|
||||
interface MDThemePalette {
|
||||
name: string;
|
||||
hues: MDThemeHues;
|
||||
}
|
||||
|
||||
interface MDThemeColors {
|
||||
accent: MDThemePalette;
|
||||
background: MDThemePalette;
|
||||
primary: MDThemePalette;
|
||||
warn: MDThemePalette;
|
||||
}
|
||||
|
||||
interface MDThemeGrayScalePalette {
|
||||
1: string;
|
||||
2: string;
|
||||
3: string;
|
||||
4: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface MDTheme {
|
||||
name: string;
|
||||
isDark: boolean;
|
||||
colors: MDThemeColors;
|
||||
foregroundPalette: MDThemeGrayScalePalette;
|
||||
foregroundShadow: string;
|
||||
accentPalette(name: string, hues?: MDThemeHues): MDTheme;
|
||||
primaryPalette(name: string, hues?: MDThemeHues): MDTheme;
|
||||
warnPalette(name: string, hues?: MDThemeHues): MDTheme;
|
||||
backgroundPalette(name: string, hues?: MDThemeHues): MDTheme;
|
||||
dark(isDark?: boolean): MDTheme;
|
||||
}
|
||||
|
||||
interface MDThemingProvider {
|
||||
theme(name: string, inheritFrom?: string): MDTheme;
|
||||
definePalette(name: string, palette: MDPalette): MDThemingProvider;
|
||||
extendPalette(name: string, palette: MDPalette): MDPalette;
|
||||
setDefaultTheme(theme: string): void;
|
||||
alwaysWatchTheme(alwaysWatch: boolean): void;
|
||||
}
|
||||
}
|
||||
94
angular-material/angular-material-tests.ts
Normal file
94
angular-material/angular-material-tests.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
/// <reference path="angular-material.d.ts" />
|
||||
|
||||
var myApp = angular.module('testModule', ['ngMaterial']);
|
||||
|
||||
myApp.config((
|
||||
$mdThemingProvider: ng.material.IThemingProvider,
|
||||
$mdIconProvider: ng.material.IIconProvider) => {
|
||||
|
||||
$mdThemingProvider.alwaysWatchTheme(true);
|
||||
var neonRedMap: ng.material.IPalette = $mdThemingProvider.extendPalette('red', {
|
||||
'500': 'ff0000'
|
||||
});
|
||||
// Register the new color palette map with the name <code>neonRed</code>
|
||||
$mdThemingProvider.definePalette('neonRed', neonRedMap);
|
||||
// Use that theme for the primary intentions
|
||||
$mdThemingProvider.theme('default')
|
||||
.primaryPalette('neonRed')
|
||||
.accentPalette('blue')
|
||||
.backgroundPalette('grey')
|
||||
.warnPalette('red')
|
||||
.dark(true);
|
||||
|
||||
$mdIconProvider
|
||||
.defaultIconSet('my/app/icons.svg') // Register a default set of SVG icons
|
||||
.iconSet('social', 'my/app/social.svg') // Register a named icon set of SVGs
|
||||
.icon('android', 'my/app/android.svg') // Register a specific icon (by name)
|
||||
.icon('work:chair', 'my/app/chair.svg'); // Register icon in a specific set
|
||||
});
|
||||
|
||||
myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng.material.IBottomSheetService) => {
|
||||
$scope['openBottomSheet'] = () => {
|
||||
$mdBottomSheet.show({
|
||||
template: '<md-bottom-sheet>Hello!</md-bottom-sheet>'
|
||||
});
|
||||
};
|
||||
$scope['hideBottomSheet'] = $mdBottomSheet.hide.bind($mdBottomSheet, 'hide');
|
||||
$scope['cancelBottomSheet'] = $mdBottomSheet.cancel.bind($mdBottomSheet, 'cancel');
|
||||
});
|
||||
|
||||
myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.IDialogService) => {
|
||||
$scope['openDialog'] = () => {
|
||||
$mdDialog.show({
|
||||
template: '<md-dialog>Hello!</md-dialog>'
|
||||
});
|
||||
};
|
||||
$scope['alertDialog'] = () => {
|
||||
$mdDialog.show($mdDialog.alert().content('Alert!'));
|
||||
};
|
||||
$scope['confirmDialog'] = () => {
|
||||
$mdDialog.show($mdDialog.confirm().content('Confirm!'));
|
||||
};
|
||||
$scope['hideDialog'] = $mdDialog.hide.bind($mdDialog, 'hide');
|
||||
$scope['cancelDialog'] = $mdDialog.cancel.bind($mdDialog, 'cancel');
|
||||
});
|
||||
|
||||
class IconDirective implements ng.IDirective {
|
||||
|
||||
private $mdIcon: ng.material.IIcon;
|
||||
constructor($mdIcon: ng.material.IIcon) {
|
||||
this.$mdIcon = $mdIcon;
|
||||
}
|
||||
|
||||
public link($scope: ng.IScope, $elm: ng.IAugmentedJQuery) {
|
||||
this.$mdIcon('android').then((iconEl: Element) => $elm.append(iconEl));
|
||||
this.$mdIcon('work:chair').then((iconEl: Element) => $elm.append(iconEl));
|
||||
// Load and cache the external SVG using a URL
|
||||
this.$mdIcon('img/icons/android.svg').then((iconEl: Element) => {
|
||||
$elm.append(iconEl);
|
||||
});
|
||||
}
|
||||
}
|
||||
myApp.directive('icon-directive', ($mdIcon: ng.material.IIcon) => new IconDirective($mdIcon));
|
||||
|
||||
myApp.controller('MediaController', ($scope: ng.IScope, $mdMedia: ng.material.IMedia) => {
|
||||
$scope.$watch(() => $mdMedia('lg'), (big: boolean) => {
|
||||
$scope['bigScreen'] = big;
|
||||
});
|
||||
$scope['screenIsSmall'] = $mdMedia('sm');
|
||||
$scope['customQuery'] = $mdMedia('(min-width: 1234px)');
|
||||
$scope['anotherCustom'] = $mdMedia('max-width: 300px');
|
||||
});
|
||||
|
||||
myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.material.ISidenavService) => {
|
||||
var componentId = 'left';
|
||||
$scope['toggle'] = () => $mdSidenav(componentId).toggle();
|
||||
$scope['open'] = () => $mdSidenav(componentId).open();
|
||||
$scope['close'] = () => $mdSidenav(componentId).close();
|
||||
$scope['isOpen'] = $mdSidenav(componentId).isOpen();
|
||||
$scope['isLockedOpen'] = $mdSidenav(componentId).isLockedOpen();
|
||||
});
|
||||
|
||||
myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService) => {
|
||||
$scope['openToast'] = () => $mdToast.show($mdToast.simple().content('Hello!'));
|
||||
});
|
||||
224
angular-material/angular-material.d.ts
vendored
Normal file
224
angular-material/angular-material.d.ts
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
// Type definitions for Angular Material 0.10.1-rc1+ (angular.material module)
|
||||
// Project: https://github.com/angular/material
|
||||
// Definitions by: Matt Traynham <https://github.com/mtraynham>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
declare module angular.material {
|
||||
|
||||
interface IBottomSheetOptions {
|
||||
templateUrl?: string;
|
||||
template?: string;
|
||||
scope?: angular.IScope; // default: new child scope
|
||||
preserveScope?: boolean; // default: false
|
||||
controller?: string|Function;
|
||||
locals?: {[index: string]: any};
|
||||
targetEvent?: MouseEvent;
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: string|Element|JQuery; // default: root node
|
||||
disableParentScroll?: boolean; // default: true
|
||||
}
|
||||
|
||||
interface IBottomSheetService {
|
||||
show(options: IBottomSheetOptions): angular.IPromise<any>;
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
|
||||
interface IPresetDialog<T> {
|
||||
title(title: string): T;
|
||||
content(content: string): T;
|
||||
ok(ok: string): T;
|
||||
theme(theme: string): T;
|
||||
templateUrl(templateUrl?: string): T;
|
||||
template(template?: string): T;
|
||||
targetEvent(targetEvent?: MouseEvent): T;
|
||||
scope(scope?: angular.IScope): T; // default: new child scope
|
||||
preserveScope(preserveScope?: boolean): T; // default: false
|
||||
disableParentScroll(disableParentScroll?: boolean): T; // default: true
|
||||
hasBackdrop(hasBackdrop?: boolean): T; // default: true
|
||||
clickOutsideToClose(clickOutsideToClose?: boolean): T; // default: false
|
||||
escapeToClose(escapeToClose?: boolean): T; // default: true
|
||||
focusOnOpen(focusOnOpen?: boolean): T; // default: true
|
||||
controller(controller?: string|Function): T;
|
||||
locals(locals?: {[index: string]: any}): T;
|
||||
bindToController(bindToController?: boolean): T; // default: false
|
||||
resolve(resolve?: {[index: string]: angular.IPromise<any>}): T;
|
||||
controllerAs(controllerAs?: string): T;
|
||||
parent(parent?: string|Element|JQuery): T; // default: root node
|
||||
onComplete(onComplete?: Function): T;
|
||||
ariaLabel(ariaLabel: string): T;
|
||||
}
|
||||
|
||||
interface IAlertDialog extends IPresetDialog<IAlertDialog> {
|
||||
}
|
||||
|
||||
interface IConfirmDialog extends IPresetDialog<IConfirmDialog> {
|
||||
cancel(cancel: string): IConfirmDialog;
|
||||
}
|
||||
|
||||
interface IDialogOptions {
|
||||
templateUrl?: string;
|
||||
template?: string;
|
||||
targetEvent?: MouseEvent;
|
||||
scope?: angular.IScope; // default: new child scope
|
||||
preserveScope?: boolean; // default: false
|
||||
disableParentScroll?: boolean; // default: true
|
||||
hasBackdrop?: boolean // default: true
|
||||
clickOutsideToClose?: boolean; // default: false
|
||||
escapeToClose?: boolean; // default: true
|
||||
focusOnOpen?: boolean; // default: true
|
||||
controller?: string|Function;
|
||||
locals?: {[index: string]: any};
|
||||
bindToController?: boolean; // default: false
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: string|Element|JQuery; // default: root node
|
||||
onComplete?: Function;
|
||||
}
|
||||
|
||||
interface IDialogService {
|
||||
show(dialog: IDialogOptions|IAlertDialog|IConfirmDialog): angular.IPromise<any>;
|
||||
confirm(): IConfirmDialog;
|
||||
alert(): IAlertDialog;
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
|
||||
interface IIcon {
|
||||
(id: string): angular.IPromise<Element>; // id is a unique ID or URL
|
||||
}
|
||||
|
||||
interface IIconProvider {
|
||||
icon(id: string, url: string, viewBoxSize?: number): IIconProvider; // viewBoxSize default: 24
|
||||
iconSet(id: string, url: string, viewBoxSize?: number): IIconProvider; // viewBoxSize default: 24
|
||||
defaultIconSet(url: string, viewBoxSize?: number): IIconProvider; // viewBoxSize default: 24
|
||||
defaultViewBoxSize(viewBoxSize: number): IIconProvider; // default: 24
|
||||
defaultFontSet(name: string): IIconProvider;
|
||||
}
|
||||
|
||||
interface IMedia {
|
||||
(media: string): boolean;
|
||||
}
|
||||
|
||||
interface ISidenavObject {
|
||||
toggle(): angular.IPromise<void>;
|
||||
open(): angular.IPromise<void>;
|
||||
close(): angular.IPromise<void>;
|
||||
isOpen(): boolean;
|
||||
isLockedOpen(): boolean;
|
||||
}
|
||||
|
||||
interface ISidenavService {
|
||||
(component: string): ISidenavObject;
|
||||
}
|
||||
|
||||
interface IToastPreset<T> {
|
||||
content(content: string): T;
|
||||
action(action: string): T;
|
||||
highlightAction(highlightAction: boolean): T;
|
||||
capsule(capsule: boolean): T;
|
||||
theme(theme: string): T;
|
||||
hideDelay(delay: number): T;
|
||||
position(position: string): T;
|
||||
parent(parent?: string|Element|JQuery): T; // default: root node
|
||||
}
|
||||
|
||||
interface ISimpleToastPreset extends IToastPreset<ISimpleToastPreset> {
|
||||
}
|
||||
|
||||
interface IToastOptions {
|
||||
templateUrl?: string;
|
||||
template?: string;
|
||||
scope?: angular.IScope; // default: new child scope
|
||||
preserveScope?: boolean; // default: false
|
||||
hideDelay?: number; // default (ms): 3000
|
||||
position?: string; // any combination of 'bottom'/'left'/'top'/'right'/'fit'; default: 'bottom left'
|
||||
controller?: string|Function;
|
||||
locals?: {[index: string]: any};
|
||||
bindToController?: boolean; // default: false
|
||||
resolve?: {[index: string]: angular.IPromise<any>}
|
||||
controllerAs?: string;
|
||||
parent?: string|Element|JQuery; // default: root node
|
||||
}
|
||||
|
||||
interface IToastService {
|
||||
show(optionsOrPreset: IToastOptions|IToastPreset<any>): angular.IPromise<any>;
|
||||
showSimple(content: string): angular.IPromise<any>;
|
||||
simple(): ISimpleToastPreset;
|
||||
build(): IToastPreset<any>;
|
||||
updateContent(): void;
|
||||
hide(response?: any): void;
|
||||
cancel(response?: any): void;
|
||||
}
|
||||
|
||||
interface IPalette {
|
||||
0?: string;
|
||||
50?: string;
|
||||
100?: string;
|
||||
200?: string;
|
||||
300?: string;
|
||||
400?: string;
|
||||
500?: string;
|
||||
600?: string;
|
||||
700?: string;
|
||||
800?: string;
|
||||
900?: string;
|
||||
A100?: string;
|
||||
A200?: string;
|
||||
A400?: string;
|
||||
A700?: string;
|
||||
contrastDefaultColor?: string;
|
||||
contrastDarkColors?: string|string[];
|
||||
contrastLightColors?: string|string[];
|
||||
}
|
||||
|
||||
interface IThemeHues {
|
||||
default?: string;
|
||||
'hue-1'?: string;
|
||||
'hue-2'?: string;
|
||||
'hue-3'?: string;
|
||||
}
|
||||
|
||||
interface IThemePalette {
|
||||
name: string;
|
||||
hues: IThemeHues;
|
||||
}
|
||||
|
||||
interface IThemeColors {
|
||||
accent: IThemePalette;
|
||||
background: IThemePalette;
|
||||
primary: IThemePalette;
|
||||
warn: IThemePalette;
|
||||
}
|
||||
|
||||
interface IThemeGrayScalePalette {
|
||||
1: string;
|
||||
2: string;
|
||||
3: string;
|
||||
4: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface ITheme {
|
||||
name: string;
|
||||
isDark: boolean;
|
||||
colors: IThemeColors;
|
||||
foregroundPalette: IThemeGrayScalePalette;
|
||||
foregroundShadow: string;
|
||||
accentPalette(name: string, hues?: IThemeHues): ITheme;
|
||||
primaryPalette(name: string, hues?: IThemeHues): ITheme;
|
||||
warnPalette(name: string, hues?: IThemeHues): ITheme;
|
||||
backgroundPalette(name: string, hues?: IThemeHues): ITheme;
|
||||
dark(isDark?: boolean): ITheme;
|
||||
}
|
||||
|
||||
interface IThemingProvider {
|
||||
theme(name: string, inheritFrom?: string): ITheme;
|
||||
definePalette(name: string, palette: IPalette): IThemingProvider;
|
||||
extendPalette(name: string, palette: IPalette): IPalette;
|
||||
setDefaultTheme(theme: string): void;
|
||||
alwaysWatchTheme(alwaysWatch: boolean): void;
|
||||
}
|
||||
}
|
||||
255
angular-meteor/angular-meteor-tests.ts
Normal file
255
angular-meteor/angular-meteor-tests.ts
Normal file
@@ -0,0 +1,255 @@
|
||||
/// <reference path="angular-meteor.d.ts" />
|
||||
|
||||
interface ITodo {
|
||||
_id?: string;
|
||||
name: string;
|
||||
public?: boolean;
|
||||
sticky?: boolean;
|
||||
}
|
||||
|
||||
interface TodoAngularMeteorObject extends ITodo, angular.meteor.AngularMeteorObject<ITodo> {}
|
||||
|
||||
interface CustomScope extends angular.meteor.IScope {
|
||||
sticky: boolean;
|
||||
|
||||
todos: angular.meteor.AngularMeteorCollection<ITodo>;
|
||||
stickyTodos: angular.meteor.AngularMeteorCollection<ITodo>;
|
||||
notAutoTodos: angular.meteor.AngularMeteorCollection<ITodo>;
|
||||
|
||||
todo: ITodo;
|
||||
todoNotAuto: TodoAngularMeteorObject;
|
||||
todoSubscribed: TodoAngularMeteorObject;
|
||||
|
||||
save: (todo: ITodo) => void;
|
||||
saveAll: () =>void;
|
||||
autoSave: (todo: ITodo) => void;
|
||||
remove: (todoId: string) => void;
|
||||
removeAll: () => void;
|
||||
removeAuto: (todo: ITodo) => void;
|
||||
toSticky: (todo: ITodo) => void;
|
||||
}
|
||||
|
||||
var Todos = new Mongo.Collection<ITodo>('todos');
|
||||
|
||||
var app = angular.module('angularMeteorTestApp');
|
||||
|
||||
app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor: angular.meteor.IMeteorService) => {
|
||||
// Bind all the todos to $scope.todos
|
||||
$scope.todos = $meteor.collection(Todos);
|
||||
|
||||
$scope.sticky = true;
|
||||
// Bind all sticky todos to $scope.stickyTodos
|
||||
// Binds the query to $scope.sticky so that if it changes, Meteor will re-run the query and bind it
|
||||
// to $scope.stickyTodos
|
||||
$scope.stickyTodos = $meteor.collection<ITodo>(function(){
|
||||
return Todos.find({sticky: $scope.getReactively('sticky')});
|
||||
});
|
||||
|
||||
// Bind without auto-save all todos to $scope.notAutoTodos
|
||||
$scope.notAutoTodos = $meteor.collection(Todos, false).subscribe("publicTodos");
|
||||
|
||||
$scope.todoNotAuto = <TodoAngularMeteorObject>$meteor.object(Todos, 'TodoID', false);
|
||||
$scope.todoSubscribed = <TodoAngularMeteorObject>$meteor.object(Todos, 'TodoID').subscribe('todos');
|
||||
$scope.todo = $scope.todoNotAuto.getRawObject();
|
||||
$scope.todoNotAuto.reset();
|
||||
$scope.todoNotAuto.save($scope.todo).then((data) => { return data == 1; });;
|
||||
|
||||
// todo might be an object like this {text: "Learn Angular", sticky: false}
|
||||
// or an array like this:
|
||||
// [{text: "Learn Angular", sticky: false}, {text: "Hello World", sticky: true}]
|
||||
|
||||
$scope.save = function(todo) {
|
||||
$scope.notAutoTodos.save(todo);
|
||||
};
|
||||
|
||||
$scope.saveAll = function() {
|
||||
$scope.notAutoTodos.save();
|
||||
};
|
||||
|
||||
$scope.autoSave = function(todo) {
|
||||
$scope.todos.push(todo);
|
||||
};
|
||||
|
||||
// todoId might be an string like this "WhrnEez5yBRgo4yEm"
|
||||
// or an array like this ["WhrnEez5yBRgo4yEm","gH6Fa4DXA3XxQjXNS"]
|
||||
$scope.remove = function(todoId) {
|
||||
$scope.notAutoTodos.remove(todoId);
|
||||
};
|
||||
|
||||
$scope.removeAll = function() {
|
||||
$scope.notAutoTodos.remove();
|
||||
};
|
||||
|
||||
$scope.removeAuto = function(todo) {
|
||||
$scope.todos.splice( $scope.todos.indexOf(todo), 1 );
|
||||
}
|
||||
|
||||
$scope.toSticky = function(todo) {
|
||||
if (angular.isArray(todo)){
|
||||
angular.forEach(todo, function(object) {
|
||||
object.sticky = true;
|
||||
});
|
||||
} else {
|
||||
todo.sticky = true;
|
||||
}
|
||||
|
||||
$scope.stickyTodos.save(todo);
|
||||
};
|
||||
|
||||
var todoObject = {name:'first todo'};
|
||||
var todosArray = [{name:'second todo'}, {name:'third todo'}];
|
||||
var todoSecondObject = {name:'forth todo'};
|
||||
|
||||
$scope.todos.save(todoObject); // todos equals [{name:'first todo'}]
|
||||
|
||||
$scope.todos.save(todosArray); // todos equals [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
|
||||
|
||||
$scope.todos.push(todoSecondObject); // The scope variable equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
|
||||
// but the collection still equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
|
||||
|
||||
$scope.todos.save(); // Now the collection also equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
|
||||
|
||||
$scope.todos.remove('firstTodoId'); // scope and collection equals to [{name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
|
||||
|
||||
var todoIdsArray = ['secondTodoId', 'thirdTodoId'];
|
||||
$scope.todos.remove(todoIdsArray); // removes everything matches the array of IDs both in scope and in collection
|
||||
|
||||
$scope.todos.pop(); // removes only in scope
|
||||
|
||||
$scope.todos.remove(); // syncs also in Meteor collection
|
||||
|
||||
// Subscribe ->
|
||||
|
||||
$meteor.subscribe('todos').then((subscriptionHandle) => {
|
||||
// Bind all the todos to $scope.todos
|
||||
$scope.todos = $meteor.collection(Todos);
|
||||
|
||||
console.log($scope.todos + ' is ready');
|
||||
|
||||
// You can use the subscription handle to stop the subscription if you want
|
||||
subscriptionHandle.stop();
|
||||
});
|
||||
|
||||
$scope.subscribe('todos').then((subscriptionHandle) => {
|
||||
// Bind all the todos to $scope.books
|
||||
$scope.todos = $meteor.collection(Todos);
|
||||
|
||||
console.log($scope.todos + ' is ready');
|
||||
|
||||
// No need to stop the subscription, it will automatically close on scope destroy
|
||||
});
|
||||
|
||||
$meteor.call<ITodo>('subscribe', $scope.todo._id, $scope.currentUser._id).then((data) => {
|
||||
// Handle success
|
||||
console.log('success subscribing', data.name);
|
||||
}, (err) => {
|
||||
// Handle error
|
||||
console.log('failed', err);
|
||||
});
|
||||
|
||||
if (!$scope.loggingIn) {
|
||||
$meteor.waitForUser();
|
||||
|
||||
$meteor.requireUser();
|
||||
|
||||
$meteor.requireValidUser(user => {
|
||||
return user.username == 'admin';
|
||||
});
|
||||
|
||||
$meteor.loginWithPassword('user', 'password').then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
|
||||
$meteor.createUser({
|
||||
username:'moma',
|
||||
email:'example@gmail.com',
|
||||
password: 'Bksd@asdf',
|
||||
profile: {expertize: 'Developer'}
|
||||
}).then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
|
||||
$meteor.changePassword('old', 'new232f3').then(() => {
|
||||
console.log('Change password success');
|
||||
}, err => {
|
||||
console.log('Error changing password - ', err);
|
||||
});
|
||||
|
||||
$meteor.forgotPassword({email: 'sample@gmail.com'}).then(() => {
|
||||
console.log('Success sending forgot password email');
|
||||
}, err => {
|
||||
console.log('Error sending forgot password email - ', err);
|
||||
});
|
||||
|
||||
$meteor.resetPassword('tokenID', 'new232f3').then(() => {
|
||||
console.log('Reset password success');
|
||||
}, err => {
|
||||
console.log('Error resetting password - ', err);
|
||||
});
|
||||
|
||||
$meteor.verifyEmail('tokenID').then(() => {
|
||||
console.log('Success verifying password ');
|
||||
}, err => {
|
||||
console.log('Error verifying password - ', err);
|
||||
});
|
||||
|
||||
$meteor.logout().then(() => {
|
||||
console.log('Logout success');
|
||||
}, err => {
|
||||
console.log('logout error - ', err);
|
||||
});
|
||||
|
||||
$meteor.logoutOtherClients().then(() => {
|
||||
console.log('Logout success');
|
||||
}, err => {
|
||||
console.log('logout error - ', err);
|
||||
});
|
||||
|
||||
var loginWithOptions = {requestPermissions: ['email']};
|
||||
|
||||
$meteor.loginWithFacebook({requestPermissions: ['email']}).then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
$meteor.loginWithGithub({requestPermissions: ['email']}).then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
$meteor.loginWithGoogle({requestPermissions: ['email']}).then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
$meteor.loginWithMeetup({requestPermissions: ['email']}).then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
$meteor.loginWithTwitter({requestPermissions: ['email']}).then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
$meteor.loginWithWeibo({requestPermissions: ['email']}).then(() => {
|
||||
console.log('Login success');
|
||||
}, err => {
|
||||
console.log('Login error - ', err);
|
||||
});
|
||||
}
|
||||
|
||||
$meteor.autorun($scope, () => { console.log("Aurorun triggered."); });
|
||||
$meteor.getCollectionByName('collectionName');
|
||||
|
||||
// requires meteor add mdg:camera
|
||||
$meteor.getPicture().then(function(data){
|
||||
$scope['picture'] = data;
|
||||
});
|
||||
|
||||
$meteor.session('counter').bind($scope, 'counter');
|
||||
}]);
|
||||
330
angular-meteor/angular-meteor.d.ts
vendored
Normal file
330
angular-meteor/angular-meteor.d.ts
vendored
Normal file
@@ -0,0 +1,330 @@
|
||||
// Type definitions for Angular JS Meteor v0.8.8 (angular.meteor module)
|
||||
// Project: https://github.com/Urigo/angular-meteor
|
||||
// Definitions by: Peter Grman <https://github.com/pgrm>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../meteor/meteor.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular.meteor {
|
||||
interface IRootScopeService extends angular.IRootScopeService {
|
||||
/**
|
||||
* The current logged in user and it's data. it is null if the user is not logged in. A reactive data source.
|
||||
*/
|
||||
currentUser: Meteor.User;
|
||||
|
||||
/**
|
||||
* True if a login method (such as Meteor.loginWithPassword, Meteor.loginWithFacebook, or Accounts.createUser) is currently in progress.
|
||||
* A reactive data source. Can be use to display animation while user is logging in.
|
||||
*/
|
||||
loggingIn: boolean;
|
||||
}
|
||||
|
||||
interface IScope extends angular.IScope, IRootScopeService {
|
||||
/**
|
||||
* A method to get a $scope variable and watch it reactivly
|
||||
*
|
||||
* @param scopeVariableName - The name of the scope's variable to bind to
|
||||
* @param [objectEquality=false] - Watch the object equality using angular.equals instead of comparing for reference equality, deeper watch but also slower
|
||||
*/
|
||||
getReactively(scopeVariableName: string, objectEquality?: boolean): ReactiveResult;
|
||||
|
||||
/**
|
||||
* A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready.
|
||||
* Calling $scope.subscribe will automatically stop the subscription when the scope is destroyed.
|
||||
*
|
||||
* @param name - Name of the subscription. Matches the name of the server's publish() call.
|
||||
* @param publisherArguments - Optional arguments passed to publisher function on server.
|
||||
*
|
||||
* @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle.
|
||||
*/
|
||||
subscribe(name: string, ...publisherArguments: any[]): angular.IPromise<Meteor.SubscriptionHandle>;
|
||||
}
|
||||
|
||||
/**
|
||||
* $meteor in angularjs
|
||||
*/
|
||||
interface IMeteorService {
|
||||
/**
|
||||
* A service that wraps the Meteor collections to enable reactivity within AngularJS.
|
||||
*
|
||||
* @param collection - A Meteor Collection or a reactive function to bind to.
|
||||
* - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor.
|
||||
* @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection.
|
||||
* - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection.
|
||||
*/
|
||||
collection<T>(collection: Mongo.Collection<T>|ReactiveResult|Function|(()=>T), autoClientSave?: boolean): AngularMeteorCollection<T>;
|
||||
|
||||
/**
|
||||
* A service that wraps the Meteor collections to enable reactivity within AngularJS.
|
||||
*
|
||||
* @param collection - A Meteor Collection or a reactive function to bind to.
|
||||
* - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor.
|
||||
* @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection.
|
||||
* - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection.
|
||||
* @param [updateCollection] - A collection object which will be used for updates (insert, update, delete).
|
||||
*/
|
||||
collection<T, U>(collection: Mongo.Collection<T>|ReactiveResult|Function|(()=>T), autoClientSave: boolean, updateCollection: Mongo.Collection<U>): AngularMeteorCollection2<T, U>;
|
||||
|
||||
/**
|
||||
* A service that wraps a Meteor object to enable reactivity within AngularJS.
|
||||
* Finds the first document that matches the selector, as ordered by sort and skip options. Wraps collection.findOne
|
||||
*
|
||||
* @param collection - A Meteor Collection to bind to.
|
||||
* @param selector - A query describing the documents to find or just the ID of the document.
|
||||
* - $meteor.object will find the first document that matches the selector,
|
||||
* - as ordered by sort and skip options, exactly like Meteor's collection.findOne
|
||||
* @param [autoClientSave=true] - By default, changes in the Angular object will automatically update the Meteor object.
|
||||
* - However if set to false, changes in the client won't be automatically propagated back to the Meteor object.
|
||||
*/
|
||||
object<T>(collection: Mongo.Collection<T>, selector: Mongo.Selector|Mongo.ObjectID|string, autoClientSave?: boolean): AngularMeteorObject<T>;
|
||||
|
||||
/**
|
||||
* A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready.
|
||||
*
|
||||
* @param name - Name of the subscription. Matches the name of the server's publish() call.
|
||||
* @param publisherArguments - Optional arguments passed to publisher function on server.
|
||||
*
|
||||
* @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle.
|
||||
*/
|
||||
subscribe(name: string, ...publisherArguments: any[]): angular.IPromise<Meteor.SubscriptionHandle>;
|
||||
|
||||
/**
|
||||
* A service service which wraps up Meteor.methods with AngularJS promises.
|
||||
*
|
||||
* @param name - Name of method to invoke
|
||||
* @param methodArguments - Optional method arguments
|
||||
*
|
||||
* @return The promise solves successfully with the return value of the method or return reject with the error from the method.
|
||||
*/
|
||||
call<T>(name: string, ...methodArguments: any[]): angular.IPromise<T>;
|
||||
|
||||
// User Authentication BEGIN ->
|
||||
|
||||
/**
|
||||
* Returns a promise fulfilled with the currentUser when the user subscription is ready.
|
||||
* This is useful when you want to grab the current user before the route is rendered.
|
||||
* If there is no logged in user, it will return null.
|
||||
* See the “Authentication with Routers” section of our tutorial for more information and a full example.
|
||||
*/
|
||||
waitForUser(): angular.IPromise<Meteor.User>;
|
||||
|
||||
/**
|
||||
* Resolves the promise successfully if a user is authenticated and rejects otherwise.
|
||||
* This is useful in cases where you want to require a route to have an authenticated user.
|
||||
* You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page.
|
||||
* See the “Authentication with Routers” section of our tutorial for more information and a full example.
|
||||
*/
|
||||
requireUser(): angular.IPromise<Meteor.User>;
|
||||
|
||||
/**
|
||||
* Resolves the promise successfully if a user is authenticated and the validatorFn returns true; rejects otherwise.
|
||||
* This is useful in cases where you want to require a route to have an authenticated user and do extra validation like the user's role or group.
|
||||
* You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page.
|
||||
* See the “Authentication with Routers” section of our tutorial for more information and a full example.
|
||||
*
|
||||
* The mandatory validator function will be called with the authenticated user as the single param and it's expected to return true in order to resolve.
|
||||
* If it returns a string, the promise will be rejected using said string as the reason.
|
||||
* Any other return (false, null, undefined) will be rejected with the default "FORBIDDEN" reason.
|
||||
*/
|
||||
requireValidUser(validatorFn: (user: Meteor.User) => boolean|string): angular.IPromise<Meteor.User>;
|
||||
|
||||
/**
|
||||
* Log the user in with a password.
|
||||
*
|
||||
* @param user - Either a string interpreted as a username or an email; or an object with a single key: email, username or id.
|
||||
* @param password - The user's password.
|
||||
*/
|
||||
loginWithPassword(user: string|{email: string}|{username: string}|{id: string}, password: string): angular.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Create a new user. More information: http://docs.meteor.com/#/full/accounts_createuser
|
||||
*
|
||||
* @param options.username - A unique name for this user. Either this, or email is required.
|
||||
* @param options.email - The user's email address. Either this, or username is required.
|
||||
* @param options.password - The user's password. This is not sent in plain text over the wire.
|
||||
* @param options.profile - The user's profile, typically including the name field.
|
||||
*/
|
||||
createUser(options: {username?: string; email?: string; password: string; profile?: Object}): angular.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Change the current user's password. Must be logged in.
|
||||
*
|
||||
* @param oldPassword - The user's current password. This is not sent in plain text over the wire.
|
||||
* @param newPassword - A new password for the user. This is not sent in plain text over the wire.
|
||||
*/
|
||||
changePassword(oldPassword: string, newPassword: string): angular.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Request a forgot password email.
|
||||
*
|
||||
* @param options.email - The email address to send a password reset link.
|
||||
*/
|
||||
forgotPassword(options: {email: string}): angular.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Reset the password for a user using a token received in email. Logs the user in afterwards.
|
||||
*
|
||||
* @param token - The token retrieved from the reset password URL.
|
||||
* @param newPassword - A new password for the user. This is not sent in plain text over the wire.
|
||||
*/
|
||||
resetPassword(token: string, newPassword: string): angular.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Marks the user's email address as verified. Logs the user in afterwards.
|
||||
*
|
||||
* @param token - The token retrieved from the reset password URL.
|
||||
*/
|
||||
verifyEmail(token: string): angular.IPromise<void>;
|
||||
|
||||
loginWithFacebook: ILoginWithExternalService;
|
||||
loginWithTwitter: ILoginWithExternalService;
|
||||
loginWithGoogle: ILoginWithExternalService;
|
||||
loginWithGithub: ILoginWithExternalService;
|
||||
loginWithMeetup: ILoginWithExternalService;
|
||||
loginWithWeibo: ILoginWithExternalService;
|
||||
|
||||
/**
|
||||
* Log the user out.
|
||||
*
|
||||
* @return Resolves with no arguments on success, or reject with a Error argument on failure.
|
||||
*/
|
||||
logout(): angular.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Log out other clients logged in as the current user, but does not log out the client that calls this function.
|
||||
* For example, when called in a user's browser, connections in that browser remain logged in,
|
||||
* but any other browsers or DDP clients logged in as that user will be logged out.
|
||||
*
|
||||
* @return Resolves with no arguments on success, or reject with a Error argument on failure.
|
||||
*/
|
||||
logoutOtherClients(): angular.IPromise<void>;
|
||||
|
||||
// <- User Authentication END
|
||||
// $meteorUtils BEGIN ->
|
||||
|
||||
/**
|
||||
* @param scope - The AngularJS scope you use the autorun on.
|
||||
* @param fn - The function that will re-run every time a reactive variable changes inside it.
|
||||
*/
|
||||
autorun(scope: angular.IScope, fn: Function): void;
|
||||
|
||||
/**
|
||||
* @param collectionName - The name of the collection you want to get back
|
||||
*/
|
||||
getCollectionByName<T>(collectionName: string): Mongo.Collection<T>;
|
||||
|
||||
// <- $meteorUtils END
|
||||
// $meteorCamera BEGIN ->
|
||||
|
||||
/**
|
||||
* A helper service for taking pictures across platforms.
|
||||
* Must add mdg:camera package to use! (meteor add mdg:camera)
|
||||
*
|
||||
* @param [options] - options is an optional argument that is an Object with the following possible keys:
|
||||
* @param options.width - An integer that specifies the minimum width of the returned photo.
|
||||
* @param options.height - An integer that specifies the minimum height of the returned photo.
|
||||
* @param options.quality - A number from 0 to 100 specifying the desired quality of JPEG encoding.
|
||||
*
|
||||
* @return The promise solved successfully when the picture is taken with the data as a parameter or rejected with an error as a parameter in case of error.
|
||||
*/
|
||||
getPicture(options?: {width?: number; height?: number; quality?: number}): angular.IPromise<any>;
|
||||
|
||||
// <- $meteorCamera END
|
||||
|
||||
/**
|
||||
* A service that binds a scope variable to a Meteor Session variable.
|
||||
*
|
||||
* @param sessionKey - The name of the session variable
|
||||
* @return An object with a single function bind - to bind to that variable.
|
||||
*/
|
||||
session(sessionKey: string): {
|
||||
/**
|
||||
* @param scope - The scope the document will be bound to.
|
||||
* @param model - The name of the scope's model variable that the document will be bound to.
|
||||
*/
|
||||
bind: (scope: IScope, model: string) => void;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* An object that connects a Meteor Object to an AngularJS scope variable.
|
||||
*
|
||||
* The object contains also all the properties from the generic type T,
|
||||
* unfortunately TypeScript doesn't at the moment allow to extend a generic type (see https://github.com/Microsoft/TypeScript/issues/2225 for details and updates).
|
||||
* For a workaround, you'll need to implement an interface which will merge AngularMeteorObject<T> together with T and cast it, like this:
|
||||
*
|
||||
* interface TodoAngularMeteorObject extends ITodo, AngularMeteorObject<ITodo> { }
|
||||
* var todo = <TodoAngularMeteorObject>$meteor.object(TodoCollection, 'TodoID');
|
||||
*/
|
||||
interface AngularMeteorObject<T> {
|
||||
/**
|
||||
* @param [doc] - The doc to save to the Meteor Object. If nothing is passed, the method saves everything in the AngularMeteorObject as is.
|
||||
* - Unchanged properties will be overridden with their existing values, which may trigger hooks.
|
||||
* - If doc is passed, the method only updates the Meteor Object with the properties passed, and no other changes will be saved.
|
||||
*
|
||||
* @return Returns a promise with an error in case for an error or a number of successful docs changed in case of success.
|
||||
*/
|
||||
save(doc?: T): angular.IPromise<number>;
|
||||
|
||||
/**
|
||||
* Reset the current value of the object to the one in the server.
|
||||
*/
|
||||
reset(): void;
|
||||
|
||||
/**
|
||||
* Returns a copy of the AngularMeteorObject with all the AngularMeteor-specific internal properties removed.
|
||||
* The returned object is then safe to use as a parameter for method calls, or anywhere else where the data needs to be converted to JSON.
|
||||
*/
|
||||
getRawObject(): T;
|
||||
|
||||
/**
|
||||
* A shorten (Syntactic sugar) function for the $meteor.subscribe function.
|
||||
* Takes only one parameter and not returns a promise like $meteor.subscribe does.
|
||||
*
|
||||
* @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service.
|
||||
*/
|
||||
subscribe(subscriptionName:string): AngularMeteorObject<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object that connects a Meteor Collection to an AngularJS scope variable
|
||||
*/
|
||||
interface AngularMeteorCollection<T> extends AngularMeteorCollection2<T, T> { }
|
||||
|
||||
/**
|
||||
* An object that connects a Meteor Collection to an AngularJS scope variable,
|
||||
* but can use a differen type for updates.
|
||||
*/
|
||||
interface AngularMeteorCollection2<T, U> extends Array<T> {
|
||||
/**
|
||||
* @param [docs] - The docs to save to the Meteor Collection.
|
||||
* - If the docs parameter is empty, the method saves everything in the AngularMeteorCollection as is.
|
||||
* - If an object is passed, the method pushes that object into the AngularMeteorCollection.
|
||||
* - If an array is passed, the method pushes all objects in the array into the AngularMeteorCollection.
|
||||
*/
|
||||
save(docs?: U|U[]): void;
|
||||
|
||||
/**
|
||||
* @param [keys] - The keys of the object to remove from the Meteor Collection.
|
||||
* - If nothing is passed, the method removes all the documents from the AngularMeteorCollection.
|
||||
* - If an object is passed, the method removes the object with that key from the AngularMeteorCollection.
|
||||
* - If an array is passed, the method removes all objects that matches the keys in the array from the AngularMeteorCollection.
|
||||
*/
|
||||
remove(keys?: U|string|number|string[]|number[]): void;
|
||||
|
||||
/**
|
||||
* A shorten (Syntactic sugar) function for the $meteor.subscribe function.
|
||||
* Takes only one parameter and not returns a promise like $meteor.subscribe does.
|
||||
*
|
||||
* @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service.
|
||||
*/
|
||||
subscribe(subscriptionName:string): AngularMeteorCollection2<T, U>;
|
||||
}
|
||||
|
||||
interface ILoginWithExternalService {
|
||||
(options: Meteor.LoginWithExternalServiceOptions): angular.IPromise<void>;
|
||||
}
|
||||
|
||||
interface ReactiveResult { }
|
||||
}
|
||||
12
angular-notifications/angular-notifications-tests.ts
Normal file
12
angular-notifications/angular-notifications-tests.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/// <reference path="angular-notifications.d.ts" />
|
||||
|
||||
var myapp = angular.module("myapp", ["notifications"]);
|
||||
|
||||
myapp.controller("MyController", ["$scope", "notifications",
|
||||
function ($scope:ng.IScope, notifications:angular.notifications.INotificationFactory) { // <-- Inject notifications
|
||||
|
||||
var userData = {'some': 'data', 'optional': true};
|
||||
notifications.info("Something happened", "here is the content of what happened", userData);
|
||||
|
||||
}
|
||||
]);
|
||||
82
angular-notifications/angular-notifications.d.ts
vendored
Normal file
82
angular-notifications/angular-notifications.d.ts
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
// Type definitions for angular-notifications
|
||||
// Project: https://github.com/DerekRies/angular-notifications
|
||||
// Definitions by: Tomasz Ducin <https://github.com/ducin/DefinitelyTyped>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular.notifications {
|
||||
|
||||
interface IAnimation {
|
||||
duration: number;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
interface ISettings {
|
||||
info: IAnimation;
|
||||
warning: IAnimation;
|
||||
error: IAnimation;
|
||||
success: IAnimation;
|
||||
progress: IAnimation;
|
||||
custom: IAnimation;
|
||||
details: boolean;
|
||||
localStorage: boolean;
|
||||
html5Mode: boolean;
|
||||
html5DefaultIcon: string;
|
||||
}
|
||||
|
||||
interface INotification {
|
||||
type: string;
|
||||
image: string;
|
||||
icon: string;
|
||||
title: string;
|
||||
content: string;
|
||||
timestamp: string;
|
||||
userData: string;
|
||||
}
|
||||
|
||||
interface INotificationFactory extends angular.IModule {
|
||||
|
||||
/* ========== SETTINGS RELATED METHODS =============*/
|
||||
|
||||
disableHtml5Mode(): void;
|
||||
disableType(notificationType: string): void;
|
||||
enableHtml5Mode(): void;
|
||||
enableType(notificationType: string): void;
|
||||
getSettings(): ISettings;
|
||||
toggleType(notificationType: string): void;
|
||||
toggleHtml5Mode(): void;
|
||||
requestHtml5ModePermissions(): boolean;
|
||||
|
||||
/* ============ QUERYING RELATED METHODS ============*/
|
||||
|
||||
getAll(): Array<INotification>;
|
||||
getQueue(): Array<INotification>;
|
||||
|
||||
/* ============== NOTIFICATION METHODS ==============*/
|
||||
|
||||
info(title: string): INotification;
|
||||
info(title: string, content: string): INotification;
|
||||
info(title: string, content: string, userData: any): INotification;
|
||||
error(title: string): INotification;
|
||||
error(title: string, content: string): INotification;
|
||||
error(title: string, content: string, userData: any): INotification;
|
||||
success(title: string): INotification;
|
||||
success(title: string, content: string): INotification;
|
||||
success(title: string, content: string, userData: any): INotification;
|
||||
warning(title: string): INotification;
|
||||
warning(title: string, content: string): INotification;
|
||||
warning(title: string, content: string, userData: any): INotification;
|
||||
awesomeNotify(type: string, icon: string, title: string, content: string, userData: any): INotification;
|
||||
notify(image: string, title: string, content: string, userData: any): INotification;
|
||||
makeNotification(type: string, image: string, icon: string, title: string, content: string, userData: any): INotification;
|
||||
|
||||
/* ============ PERSISTENCE METHODS ============ */
|
||||
|
||||
save(): void;
|
||||
restore(): void;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
4
angular-notify/angular-notify.d.ts
vendored
4
angular-notify/angular-notify.d.ts
vendored
@@ -5,7 +5,7 @@
|
||||
|
||||
///<reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ng.cgNotify {
|
||||
declare module angular.cgNotify {
|
||||
|
||||
interface INotifyService {
|
||||
|
||||
@@ -113,4 +113,4 @@ declare module ng.cgNotify {
|
||||
*/
|
||||
close():void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
208
angular-odata-resources/angular-odata-resources-tests.ts
Normal file
208
angular-odata-resources/angular-odata-resources-tests.ts
Normal file
@@ -0,0 +1,208 @@
|
||||
/// <reference path="angular-odata-resources.d.ts" />
|
||||
|
||||
interface IMyResource extends OData.IResource<IMyResource> { };
|
||||
interface IMyResourceClass extends OData.IResourceClass<IMyResource> { };
|
||||
|
||||
///////////////////////////////////////
|
||||
// IActionDescriptor
|
||||
///////////////////////////////////////
|
||||
var actionDescriptor: OData.IActionDescriptor;
|
||||
|
||||
actionDescriptor.url = '/api/test-url/'
|
||||
actionDescriptor.headers = { header: 'value' };
|
||||
actionDescriptor.isArray = true;
|
||||
actionDescriptor.method = 'method action';
|
||||
actionDescriptor.params = { key: 'value' };
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceClass
|
||||
///////////////////////////////////////
|
||||
var resourceClass: IMyResourceClass;
|
||||
var resource: IMyResource;
|
||||
var resourceArray: OData.IResourceArray<IMyResource>;
|
||||
|
||||
resource = resourceClass.delete();
|
||||
resource = resourceClass.delete({ key: 'value' });
|
||||
resource = resourceClass.delete({ key: 'value' }, function() { });
|
||||
resource = resourceClass.delete(function() { });
|
||||
resource = resourceClass.delete(function() { }, function() { });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function() { });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function() { }, function() { });
|
||||
resource.$promise.then(function(data: IMyResource) { });
|
||||
|
||||
resource = resourceClass.get();
|
||||
resource = resourceClass.get({ key: 'value' });
|
||||
resource = resourceClass.get({ key: 'value' }, function() { });
|
||||
resource = resourceClass.get(function() { });
|
||||
resource = resourceClass.get(function() { }, function() { });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function() { });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function() { }, function() { });
|
||||
|
||||
resourceArray = resourceClass.query();
|
||||
resourceArray = resourceClass.query({ key: 'value' });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, function() { });
|
||||
resourceArray = resourceClass.query(function() { });
|
||||
resourceArray = resourceClass.query(function() { }, function() { });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function() { });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function() { }, function() { });
|
||||
resourceArray.push(resource);
|
||||
resourceArray.$promise.then(function(data: OData.IResourceArray<IMyResource>) { });
|
||||
|
||||
resource = resourceClass.remove();
|
||||
resource = resourceClass.remove({ key: 'value' });
|
||||
resource = resourceClass.remove({ key: 'value' }, function() { });
|
||||
resource = resourceClass.remove(function() { });
|
||||
resource = resourceClass.remove(function() { }, function() { });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function() { });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function() { }, function() { });
|
||||
|
||||
resource = resourceClass.save();
|
||||
resource = resourceClass.save({ key: 'value' });
|
||||
resource = resourceClass.save({ key: 'value' }, function() { });
|
||||
resource = resourceClass.save(function() { });
|
||||
resource = resourceClass.save(function() { }, function() { });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function() { });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function() { }, function() { });
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResource
|
||||
///////////////////////////////////////
|
||||
|
||||
var promise: angular.IPromise<IMyResource>;
|
||||
var arrayPromise: angular.IPromise<IMyResource[]>;
|
||||
|
||||
promise = resource.$delete();
|
||||
promise = resource.$delete({ key: 'value' });
|
||||
promise = resource.$delete({ key: 'value' }, function() { });
|
||||
promise = resource.$delete(function() { });
|
||||
promise = resource.$delete(function() { }, function() { });
|
||||
promise = resource.$delete({ key: 'value' }, function() { }, function() { });
|
||||
promise.then(function(data: IMyResource) { });
|
||||
|
||||
promise = resource.$get();
|
||||
promise = resource.$get({ key: 'value' });
|
||||
promise = resource.$get({ key: 'value' }, function() { });
|
||||
promise = resource.$get(function() { });
|
||||
promise = resource.$get(function() { }, function() { });
|
||||
promise = resource.$get({ key: 'value' }, function() { }, function() { });
|
||||
|
||||
arrayPromise = resourceArray[0].$query();
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' });
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' }, function() { });
|
||||
arrayPromise = resourceArray[0].$query(function() { });
|
||||
arrayPromise = resourceArray[0].$query(function() { }, function() { });
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' }, function() { }, function() { });
|
||||
arrayPromise.then(function(data: OData.IResourceArray<IMyResource>) { });
|
||||
|
||||
promise = resource.$remove();
|
||||
promise = resource.$remove({ key: 'value' });
|
||||
promise = resource.$remove({ key: 'value' }, function() { });
|
||||
promise = resource.$remove(function() { });
|
||||
promise = resource.$remove(function() { }, function() { });
|
||||
promise = resource.$remove({ key: 'value' }, function() { }, function() { });
|
||||
|
||||
promise = resource.$save();
|
||||
promise = resource.$save({ key: 'value' });
|
||||
promise = resource.$save({ key: 'value' }, function() { });
|
||||
promise = resource.$save(function() { });
|
||||
promise = resource.$save(function() { }, function() { });
|
||||
promise = resource.$save({ key: 'value' }, function() { }, function() { });
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceService
|
||||
///////////////////////////////////////
|
||||
var resourceService: OData.IResourceService;
|
||||
resourceClass = resourceService<IMyResource, IMyResourceClass>('test');
|
||||
resourceClass = resourceService<IMyResource>('test');
|
||||
resourceClass = resourceService('test');
|
||||
|
||||
///////////////////////////////////////
|
||||
// IModule
|
||||
///////////////////////////////////////
|
||||
var mod: ng.IModule;
|
||||
var resourceServiceFactoryFunction: OData.IResourceServiceFactoryFunction<IMyResource>;
|
||||
var resourceService: OData.IResourceService;
|
||||
|
||||
resourceClass = resourceServiceFactoryFunction<IMyResourceClass>(resourceService);
|
||||
|
||||
resourceServiceFactoryFunction = function(resourceService: OData.IResourceService) { return <any>resourceClass; };
|
||||
mod = mod.factory('factory name', resourceServiceFactoryFunction);
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResource
|
||||
///////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceServiceProvider
|
||||
///////////////////////////////////////
|
||||
var resourceServiceProvider: OData.IResourceServiceProvider;
|
||||
resourceServiceProvider.defaults.stripTrailingSlashes = false;
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// OData
|
||||
///////////////////////////////////////
|
||||
|
||||
interface User extends OData.IResource<User> {
|
||||
name: string;
|
||||
}
|
||||
|
||||
var resourceService: OData.IResourceService;
|
||||
var odataResourceClass = resourceService<User>("my/url", {}, {}, { odata: { method: 'POST' } });
|
||||
|
||||
var Value: OData.ValueFactory;
|
||||
var Property: OData.PropertyFactory;
|
||||
var Predicate: OData.PredicateFactory;
|
||||
|
||||
var users = odataResourceClass.odata().query();
|
||||
|
||||
users[0].name;
|
||||
users[0].$save;
|
||||
users[0].$update;
|
||||
|
||||
var user = odataResourceClass.odata()
|
||||
.filter(new Value("1", OData.ValueTypes.Int32), new Property("abc"))
|
||||
.filter("Name", "John")
|
||||
.filter("Age", ">", 20)
|
||||
.skip(10)
|
||||
.take(20)
|
||||
.orderBy("Name", "desc")
|
||||
.single();
|
||||
user.$save();
|
||||
|
||||
var predicate1 = new Predicate("a", "b");
|
||||
var predicate2 = new Predicate("c", "d");
|
||||
var predicate3 = new Predicate("Age", '>', 10);
|
||||
|
||||
var combination1 = Predicate.or([predicate1, predicate2]);
|
||||
var combination2 = Predicate.and([combination1, predicate2]);
|
||||
|
||||
var predicate = new Predicate("FirstName", "John")
|
||||
.or(new Predicate("LastName", '!=', "Doe"))
|
||||
.and(new Predicate("Age", '>', 10));
|
||||
|
||||
|
||||
users = odataResourceClass.odata()
|
||||
.withInlineCount()
|
||||
.query();
|
||||
|
||||
|
||||
var countResult = odataResourceClass.odata().count();
|
||||
var total = countResult.result;
|
||||
|
||||
|
||||
|
||||
|
||||
var usersSelect1 = odataResourceClass.odata()
|
||||
.select('name', 'user');
|
||||
|
||||
|
||||
var usersSelect2 = odataResourceClass.odata()
|
||||
.select(['name', 'user']);
|
||||
325
angular-odata-resources/angular-odata-resources.d.ts
vendored
Normal file
325
angular-odata-resources/angular-odata-resources.d.ts
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
// Type definitions for OData Angular Resources
|
||||
// Project: https://github.com/devnixs/ODataAngularResources
|
||||
// Definitions by: Raphael ATALLAH <http://raphael.atallah.me>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module OData {
|
||||
|
||||
/**
|
||||
* Currently supported options for the $resource factory options argument.
|
||||
*/
|
||||
interface IResourceOptions {
|
||||
/**
|
||||
* If true then the trailing slashes from any calculated URL will be stripped (defaults to true)
|
||||
*/
|
||||
stripTrailingSlashes?: boolean;
|
||||
odata?: {
|
||||
url?: string;
|
||||
method?: string;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ResourceService
|
||||
// see http://docs.angularjs.org/api/ngResource.$resource
|
||||
// Most part of the following definitions were achieved by analyzing the
|
||||
// actual implementation, since the documentation doesn't seem to cover
|
||||
// that deeply.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IResourceService {
|
||||
(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<IResource<any>>;
|
||||
<T, U>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): U;
|
||||
<T>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<T>;
|
||||
}
|
||||
|
||||
// Just a reference to facilitate describing new actions
|
||||
interface IActionDescriptor {
|
||||
url?: string;
|
||||
method: string;
|
||||
isArray?: boolean;
|
||||
params?: any;
|
||||
headers?: any;
|
||||
}
|
||||
|
||||
// Baseclass for everyresource with default actions.
|
||||
// If you define your new actions for the resource, you will need
|
||||
// to extend this interface and typecast the ResourceClass to it.
|
||||
//
|
||||
// In case of passing the first argument as anything but a function,
|
||||
// it's gonna be considered data if the action method is POST, PUT or
|
||||
// PATCH (in other words, methods with body). Otherwise, it's going
|
||||
// to be considered as parameters to the request.
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465
|
||||
//
|
||||
// Only those methods with an HTTP body do have 'data' as first parameter:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463
|
||||
// More specifically, those methods are POST, PUT and PATCH:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432
|
||||
//
|
||||
// Also, static calls always return the IResource (or IResourceArray) retrieved
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549
|
||||
interface IResourceClass<T> {
|
||||
new(dataOrParams? : any) : IResource<T>;
|
||||
get(): IResource<T>;
|
||||
get(params: Object): IResource<T>;
|
||||
get(success: Function, error?: Function): IResource<T>;
|
||||
get(params: Object, success: Function, error?: Function): IResource<T>;
|
||||
get(params: Object, data: Object, success?: Function, error?: Function): IResource<T>;
|
||||
|
||||
query(): IResourceArray<T>;
|
||||
query(params: Object): IResourceArray<T>;
|
||||
query(success: Function, error?: Function): IResourceArray<T>;
|
||||
query(params: Object, success: Function, error?: Function): IResourceArray<T>;
|
||||
query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray<T>;
|
||||
|
||||
save(): IResource<T>;
|
||||
save(data: Object): IResource<T>;
|
||||
save(success: Function, error?: Function): IResource<T>;
|
||||
save(data: Object, success: Function, error?: Function): IResource<T>;
|
||||
save(params: Object, data: Object, success?: Function, error?: Function): IResource<T>;
|
||||
|
||||
update(): IResource<T>;
|
||||
update(data: Object): IResource<T>;
|
||||
update(success: Function, error?: Function): IResource<T>;
|
||||
update(data: Object, success: Function, error?: Function): IResource<T>;
|
||||
update(params: Object, data: Object, success?: Function, error?: Function): IResource<T>;
|
||||
|
||||
remove(): IResource<T>;
|
||||
remove(params: Object): IResource<T>;
|
||||
remove(success: Function, error?: Function): IResource<T>;
|
||||
remove(params: Object, success: Function, error?: Function): IResource<T>;
|
||||
remove(params: Object, data: Object, success?: Function, error?: Function): IResource<T>;
|
||||
|
||||
delete(): IResource<T>;
|
||||
delete(params: Object): IResource<T>;
|
||||
delete(success: Function, error?: Function): IResource<T>;
|
||||
delete(params: Object, success: Function, error?: Function): IResource<T>;
|
||||
delete(params: Object, data: Object, success?: Function, error?: Function): IResource<T>;
|
||||
|
||||
odata(): OData.Provider<T>;
|
||||
}
|
||||
|
||||
// Instance calls always return the the promise of the request which retrieved the object
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546
|
||||
interface IResource<T> {
|
||||
$get(): angular.IPromise<T>;
|
||||
$get(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$get(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$query(): angular.IPromise<IResourceArray<T>>;
|
||||
$query(params?: Object, success?: Function, error?: Function): angular.IPromise<IResourceArray<T>>;
|
||||
$query(success: Function, error?: Function): angular.IPromise<IResourceArray<T>>;
|
||||
|
||||
$save(): angular.IPromise<T>;
|
||||
$save(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$save(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$update(): angular.IPromise<T>;
|
||||
$update(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$update(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$remove(): angular.IPromise<T>;
|
||||
$remove(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$remove(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$delete(): angular.IPromise<T>;
|
||||
$delete(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$delete(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
/** the promise of the original server interaction that created this instance. **/
|
||||
$promise: angular.IPromise<T>;
|
||||
$resolved: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Really just a regular Array object with $promise and $resolve attached to it
|
||||
*/
|
||||
interface IResourceArray<T> extends Array<T> {
|
||||
/** the promise of the original server interaction that created this collection. **/
|
||||
$promise: angular.IPromise<IResourceArray<T>>;
|
||||
$resolved: boolean;
|
||||
}
|
||||
|
||||
/** when creating a resource factory via IModule.factory */
|
||||
interface IResourceServiceFactoryFunction<T> {
|
||||
($resource: OData.IResourceService): IResourceClass<T>;
|
||||
<U extends IResourceClass<T>>($resource: OData.IResourceService): U;
|
||||
}
|
||||
|
||||
// IResourceServiceProvider used to configure global settings
|
||||
interface IResourceServiceProvider extends angular.IServiceProvider {
|
||||
|
||||
defaults: IResourceOptions;
|
||||
}
|
||||
|
||||
|
||||
interface IExecutable {
|
||||
execute(noParenthesis?: any): string;
|
||||
}
|
||||
class Global {
|
||||
static $inject: string[];
|
||||
constructor(ODataBinaryOperation: any, ODataProvider: any, ODataValue: any, ODataProperty: any, ODataMethodCall: any, ODataPredicate: any, ODataOrderByStatement: any);
|
||||
Provider: Provider<any>;
|
||||
BinaryOperation: typeof BinaryOperation;
|
||||
Value: typeof Value;
|
||||
Property: typeof Property;
|
||||
Func: typeof MethodCall;
|
||||
Predicate: typeof Predicate;
|
||||
OrderBy: typeof OrderByStatement;
|
||||
}
|
||||
|
||||
interface BinaryOperationFactory {
|
||||
new (propertyOrPredicate: any, valueOrOperator?: any, value?: any): BinaryOperation;
|
||||
}
|
||||
class BinaryOperation implements IExecutable {
|
||||
private operandA;
|
||||
private operandB;
|
||||
private filterOperator;
|
||||
constructor(propertyOrPredicate: any, valueOrOperator?: any, value?: any);
|
||||
execute(noParenthesis?: any): string;
|
||||
or(propertyOrPredicate: any, operatorOrValue?: any, value?: any): BinaryOperation;
|
||||
and(propertyOrPredicate: any, operatorOrValue?: any, value?: any): BinaryOperation;
|
||||
}
|
||||
|
||||
interface MethodCallFactory {
|
||||
new (methodName: string, ...args: any[]): MethodCall;
|
||||
}
|
||||
class MethodCall implements IExecutable {
|
||||
private methodName;
|
||||
private params;
|
||||
execute(): string;
|
||||
constructor(methodName: string, ...args: any[]);
|
||||
}
|
||||
|
||||
class Operators {
|
||||
operators: {
|
||||
'eq': string[];
|
||||
'ne': string[];
|
||||
'gt': string[];
|
||||
'ge': string[];
|
||||
'lt': string[];
|
||||
'le': string[];
|
||||
'and': string[];
|
||||
'or': string[];
|
||||
'not': string[];
|
||||
'add': string[];
|
||||
'sub': string[];
|
||||
'mul': string[];
|
||||
'div': string[];
|
||||
'mod': string[];
|
||||
};
|
||||
private rtrim;
|
||||
private trim(value);
|
||||
convert(from: string): any;
|
||||
}
|
||||
|
||||
interface OrderByStatementFactory {
|
||||
new (propertyName: string, sortOrder?: string): OrderByStatement;
|
||||
}
|
||||
class OrderByStatement implements IExecutable {
|
||||
private propertyName;
|
||||
private direction;
|
||||
execute(): string;
|
||||
constructor(propertyName: string, sortOrder?: string);
|
||||
}
|
||||
|
||||
interface PredicateFactory {
|
||||
new (propertyOrValueOrPredicate: any, valueOrOperator?: any, value?: any): Predicate;
|
||||
or(orStatements: any[]): IExecutable;
|
||||
create(propertyOrPredicate: any, operatorOrValue?: any, value?: any): IExecutable;
|
||||
and(andStatements: any): IExecutable;
|
||||
}
|
||||
class Predicate extends BinaryOperation {
|
||||
constructor(propertyOrValueOrPredicate: any, valueOrOperator?: any, value?: any);
|
||||
static or(orStatements: any[]): IExecutable;
|
||||
static create(propertyOrPredicate: any, operatorOrValue?: any, value?: any): IExecutable;
|
||||
static and(andStatements: any): IExecutable;
|
||||
}
|
||||
|
||||
interface PropertyFactory {
|
||||
new (value: string): Property;
|
||||
}
|
||||
class Property implements IExecutable {
|
||||
private value;
|
||||
constructor(value: string);
|
||||
execute(): string;
|
||||
}
|
||||
|
||||
interface ProviderFactory {
|
||||
new <T>(callback: ProviderCallback<T>): Provider<T>;
|
||||
}
|
||||
interface ProviderCallback<T> {
|
||||
(queryString: string, success: () => any, error: () => any): T[];
|
||||
(queryString: string, success: () => any, error: () => any, isSingleElement?: boolean, forceSingleElement?: boolean): T;
|
||||
}
|
||||
|
||||
interface ICountResult{
|
||||
result: number;
|
||||
$promise: angular.IPromise<any>;
|
||||
}
|
||||
|
||||
class Provider<T> {
|
||||
private callback;
|
||||
private filters;
|
||||
private sortOrders;
|
||||
private takeAmount;
|
||||
private skipAmount;
|
||||
private expandables;
|
||||
constructor(callback: ProviderCallback<T>);
|
||||
filter(operand1: any, operand2?: any, operand3?: any): Provider<T>;
|
||||
orderBy(arg1: string, arg2?: string): Provider<T>;
|
||||
take(amount: number): Provider<T>;
|
||||
skip(amount: number): Provider<T>;
|
||||
private execute();
|
||||
query(success?: ((p:T[])=>void), error?: (()=>void)): T[];
|
||||
single(success?: ((p:T)=>void), error?: (()=>void)): T;
|
||||
get(key: any, success?: ((p:T)=>void), error?: (()=>void)): T;
|
||||
expand(...params: string[]): Provider<T>;
|
||||
expand(params: string[]): Provider<T>;
|
||||
select(...params: string[]): Provider<T>;
|
||||
select(params: string[]): Provider<T>;
|
||||
count(success?: (result: ICountResult) => any, error?: () => any):ICountResult;
|
||||
withInlineCount(): Provider<T>;
|
||||
}
|
||||
|
||||
interface ValueFactory {
|
||||
new (value: any, type?: string): Value;
|
||||
}
|
||||
class ValueTypes {
|
||||
static Boolean: string;
|
||||
static Byte: string;
|
||||
static DateTime: string;
|
||||
static Decimal: string;
|
||||
static Double: string;
|
||||
static Single: string;
|
||||
static Guid: string;
|
||||
static Int32: string;
|
||||
static String: string;
|
||||
}
|
||||
class Value {
|
||||
private value;
|
||||
private type;
|
||||
private illegalChars;
|
||||
private escapeIllegalChars(haystack);
|
||||
private generateDate(date);
|
||||
executeWithUndefinedType(): any;
|
||||
executeWithType(): any;
|
||||
execute(): string;
|
||||
constructor(value: any, type?: string);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
/// <reference path="angular-protractor.d.ts" />
|
||||
|
||||
function TestWebDriverExports() {
|
||||
var abstractBuilder: protractor.AbstractBuilder = new protractor.AbstractBuilder();
|
||||
var baseAbstractBuilder: webdriver.AbstractBuilder = abstractBuilder;
|
||||
|
||||
var button: protractor.Button = new protractor.Button();
|
||||
var baseButton: webdriver.Button = button;
|
||||
var button: number = protractor.Button.LEFT;
|
||||
|
||||
var key: string = protractor.Key.ADD;
|
||||
var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1);
|
||||
@@ -18,12 +14,6 @@ function TestWebDriverExports() {
|
||||
var action: protractor.ActionSequence = new protractor.ActionSequence(driver);
|
||||
var baseAction: webdriver.ActionSequence = action;
|
||||
|
||||
var alert: protractor.Alert = new protractor.Alert(driver, 'Message');
|
||||
var baseAlert: webdriver.Alert = alert;
|
||||
|
||||
var unhandledAlertError: protractor.UnhandledAlertError = new protractor.UnhandledAlertError('Message', alert);
|
||||
var baseUnhandledAlertError: webdriver.UnhandledAlertError = unhandledAlertError;
|
||||
|
||||
var browser: string = protractor.Browser.ANDROID;
|
||||
|
||||
var builder: protractor.Builder = new protractor.Builder();
|
||||
@@ -42,89 +32,168 @@ function TestWebDriverExports() {
|
||||
var eventEmitter: protractor.EventEmitter = new protractor.EventEmitter();
|
||||
var baseEventEmitter: webdriver.EventEmitter = eventEmitter;
|
||||
|
||||
var firefoxDomExecutor: protractor.FirefoxDomExecutor = new protractor.FirefoxDomExecutor();
|
||||
var baseFirefoxDomExecutor: webdriver.FirefoxDomExecutor = firefoxDomExecutor;
|
||||
|
||||
var webElement: protractor.WebElement = new protractor.WebElement(driver, new protractor.promise.Promise());
|
||||
var baseWebElement: webdriver.WebElement = webElement;
|
||||
|
||||
var locator: protractor.Locator = new protractor.Locator('id', 'ABC');
|
||||
var baseLocator: webdriver.Locator = locator;
|
||||
var locator: webdriver.Locator = by.id('abc');
|
||||
|
||||
var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android());
|
||||
var baseSession: webdriver.Session = session;
|
||||
|
||||
locator = protractor.By.name('name');
|
||||
|
||||
// logging module
|
||||
var driver: protractor.WebDriver = new protractor.WebDriver(session, <webdriver.CommandExecutor><any>{});
|
||||
driver = new protractor.WebDriver(session, <webdriver.CommandExecutor><any>{}, new webdriver.promise.ControlFlow());
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
|
||||
var levelName: string = protractor.logging.LevelName.ALL;
|
||||
var webElement: protractor.WebElement = new protractor.WebElement(driver, { ELEMENT: 'abc' });
|
||||
var baseWebElement: webdriver.WebElement = webElement;
|
||||
|
||||
var webElementPromise: protractor.WebElementPromise = new protractor.WebElementPromise(driver, { ELEMENT: 'abc' });
|
||||
var baseWebElementPromise: webdriver.WebElementPromise = webElementPromise;
|
||||
}
|
||||
|
||||
function TestWebDriverErrorModule() {
|
||||
var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
|
||||
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
|
||||
var baseError: webdriver.error.Error = error;
|
||||
}
|
||||
|
||||
function TestWebDriverLoggingModule() {
|
||||
var levelName: string = protractor.logging.Level.ALL.name;
|
||||
var loggingType: string = protractor.logging.Type.CLIENT;
|
||||
|
||||
var level: webdriver.logging.Level = protractor.logging.Level.ALL;
|
||||
var level: webdriver.logging.ILevel = protractor.logging.Level.ALL;
|
||||
|
||||
var entry: protractor.logging.Entry = new protractor.logging.Entry(protractor.logging.Level.ALL, 'Message');
|
||||
var baseEntry: webdriver.logging.Entry = entry;
|
||||
|
||||
level = protractor.logging.getLevel('DEBUG');
|
||||
|
||||
protractor.logging.Preferences = { a: 123 };
|
||||
var prefs: protractor.logging.Preferences = new protractor.logging.Preferences();
|
||||
}
|
||||
|
||||
// promise module
|
||||
function TestWebDriverPromiseModule() {
|
||||
var cancelError: protractor.promise.CancellationError = new protractor.promise.CancellationError();
|
||||
cancelError = new protractor.promise.CancellationError('message');
|
||||
var baseCancelError: webdriver.promise.CancellationError = cancelError;
|
||||
|
||||
var promise: protractor.promise.Promise = new protractor.promise.Promise();
|
||||
var basePromise: webdriver.promise.Promise = promise;
|
||||
var thenable: protractor.promise.Thenable<any> = new protractor.promise.Thenable();
|
||||
var baseThenable: webdriver.promise.Thenable<any> = thenable;
|
||||
|
||||
var deferred: protractor.promise.Deferred = new protractor.promise.Deferred();
|
||||
var baseDeferred: webdriver.promise.Deferred = deferred;
|
||||
var promise: protractor.promise.Promise<any> = new protractor.promise.Promise();
|
||||
var basePromise: webdriver.promise.Promise<any> = promise;
|
||||
|
||||
var deferred: protractor.promise.Deferred<any> = new protractor.promise.Deferred();
|
||||
var baseDeferred: webdriver.promise.Deferred<any> = deferred;
|
||||
|
||||
var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow();
|
||||
var baseFlow: webdriver.promise.ControlFlow = flow;
|
||||
|
||||
protractor.promise.asap(promise, function(value: any){ return true; });
|
||||
protractor.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; });
|
||||
var arrayPromise: protractor.promise.Promise<any[]> = protractor.promise.all([new protractor.promise.Promise<number>(), new protractor.promise.Promise<string>()]);
|
||||
|
||||
promise = protractor.promise.checkedNodeCall(function(err: any, value: any) { return 123; });
|
||||
protractor.promise.asap(promise, function (value: any) { return true; });
|
||||
protractor.promise.asap(promise, function (value: any) { }, function (err: any) { return 'ABC'; });
|
||||
|
||||
promise = protractor.promise.checkedNodeCall(function (err: any, value: any) { return 123; });
|
||||
|
||||
promise = protractor.promise.consume(function () {
|
||||
return 5;
|
||||
});
|
||||
promise = protractor.promise.consume(function () {
|
||||
return 5;
|
||||
}, this);
|
||||
promise = protractor.promise.consume(function () {
|
||||
return 5;
|
||||
}, this, 1, 2, 3);
|
||||
|
||||
flow = protractor.promise.controlFlow();
|
||||
|
||||
promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
|
||||
promise = protractor.promise.createFlow(function (newFlow: webdriver.promise.ControlFlow) { });
|
||||
|
||||
deferred = protractor.promise.defer(function() {});
|
||||
deferred = protractor.promise.defer(function(reason?: any) {});
|
||||
deferred = protractor.promise.defer();
|
||||
|
||||
promise = protractor.promise.delayed(123);
|
||||
|
||||
var numbersPromise: protractor.promise.Promise<number[]> = protractor.promise.filter([1, 2, 3], function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = protractor.promise.filter([1, 2, 3], function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
}, this);
|
||||
numbersPromise = protractor.promise.filter(numbersPromise, function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = protractor.promise.filter(numbersPromise, function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
numbersPromise = protractor.promise.map([1, 2, 3], function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = protractor.promise.map([1, 2, 3], function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
}, this);
|
||||
numbersPromise = protractor.promise.map(numbersPromise, function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
});
|
||||
numbersPromise = protractor.promise.map(numbersPromise, function (el: number, index: number, arr: number[]) {
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
promise = protractor.promise.fulfilled();
|
||||
promise = protractor.promise.fulfilled({a: 123});
|
||||
promise = protractor.promise.fulfilled({ a: 123 });
|
||||
|
||||
promise = protractor.promise.fullyResolved({a: 123});
|
||||
promise = protractor.promise.fullyResolved({ a: 123 });
|
||||
|
||||
var isPromise: boolean = protractor.promise.isPromise('ABC');
|
||||
var bool: boolean = protractor.promise.isGenerator(function () { });
|
||||
var bool: boolean = protractor.promise.isPromise('ABC');
|
||||
|
||||
promise = protractor.promise.rejected({a: 123});
|
||||
promise = protractor.promise.rejected({ a: 123 });
|
||||
|
||||
protractor.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
|
||||
|
||||
promise = protractor.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; });
|
||||
promise = protractor.promise.when(promise, function (value: any) { return 123; }, function (err: Error) { return 123; });
|
||||
}
|
||||
|
||||
// error module
|
||||
function TestWebDriverStacktraceModule() {
|
||||
var bool: boolean = protractor.stacktrace.BROWSER_SUPPORTED;
|
||||
|
||||
var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
|
||||
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
|
||||
var baseError: webdriver.error.Error = error;
|
||||
var frame: protractor.stacktrace.Frame = new protractor.stacktrace.Frame();
|
||||
var baseFrame: webdriver.stacktrace.Frame = frame;
|
||||
|
||||
// process module
|
||||
var snapshot: protractor.stacktrace.Snapshot = new protractor.stacktrace.Snapshot();
|
||||
var baseSnapshot: webdriver.stacktrace.Snapshot = snapshot;
|
||||
|
||||
var isNative: boolean = protractor.process.isNative();
|
||||
var value: string;
|
||||
var err: Error = protractor.stacktrace.format(new Error("Error"));
|
||||
var frames: protractor.stacktrace.Frame[] = protractor.stacktrace.get();
|
||||
}
|
||||
|
||||
value = protractor.process.getEnv('name');
|
||||
value = protractor.process.getEnv('name', 'default');
|
||||
function TestWebDriverUntilModule() {
|
||||
var conditionB: protractor.until.Condition<boolean> = new protractor.until.Condition<boolean>('message', function (driver: webdriver.WebDriver) { return true; });
|
||||
var conditionBBase: webdriver.until.Condition<boolean> = conditionB;
|
||||
var conditionWebElement: protractor.until.Condition<webdriver.IWebElement>;
|
||||
var conditionWebElements: protractor.until.Condition<webdriver.IWebElement[]>;
|
||||
|
||||
protractor.process.setEnv('name', 'value');
|
||||
protractor.process.setEnv('name', 123);
|
||||
conditionB = protractor.until.ableToSwitchToFrame(5);
|
||||
var conditionAlert: protractor.until.Condition<webdriver.Alert> = protractor.until.alertIsPresent();
|
||||
var el: protractor.ElementFinder = element(by.id('id'));
|
||||
conditionB = protractor.until.elementIsDisabled(el);
|
||||
conditionB = protractor.until.elementIsEnabled(el);
|
||||
conditionB = protractor.until.elementIsNotSelected(el);
|
||||
conditionB = protractor.until.elementIsNotVisible(el);
|
||||
conditionB = protractor.until.elementIsSelected(el);
|
||||
conditionB = protractor.until.elementIsVisible(el);
|
||||
conditionB = protractor.until.elementTextContains(el, 'text');
|
||||
conditionB = protractor.until.elementTextIs(el, 'text');
|
||||
conditionB = protractor.until.elementTextMatches(el, /text/);
|
||||
conditionB = protractor.until.stalenessOf(el);
|
||||
conditionB = protractor.until.titleContains('text');
|
||||
conditionB = protractor.until.titleIs('text');
|
||||
conditionB = protractor.until.titleMatches(/text/);
|
||||
|
||||
conditionWebElement = protractor.until.elementLocated(by.id('id'));
|
||||
conditionWebElements = protractor.until.elementsLocated(by.className('class'));
|
||||
}
|
||||
|
||||
function TestProtractor() {
|
||||
@@ -133,31 +202,47 @@ function TestProtractor() {
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
ptor = new protractor.Protractor(driver);
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl');
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl', 'rootElement');
|
||||
ptor = protractor.getInstance();
|
||||
protractor.setInstance(ptor);
|
||||
|
||||
ptor = protractor.wrapDriver(driver);
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl');
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl', 'rootElement');
|
||||
|
||||
ptor = browser;
|
||||
|
||||
var actions: protractor.ActionSequence = ptor.actions();
|
||||
|
||||
var promise: protractor.promise.Promise<any> = ptor.call(function () { });
|
||||
var promise: protractor.promise.Promise<any> = ptor.call(function () { }, this);
|
||||
var promise: protractor.promise.Promise<any> = ptor.call(function (a: number, b: number, c:number) { }, this, 1, 2,3);
|
||||
|
||||
promise = ptor.executeAsyncScript('SomeScript');
|
||||
promise = ptor.executeAsyncScript('SomeScript', 1, 2, 3);
|
||||
promise = ptor.executeAsyncScript(function () { });
|
||||
promise = ptor.executeAsyncScript(function (a: number, b: number, c: number) { }, 1, 2, 3);
|
||||
|
||||
promise = ptor.executeScript('SomeScript');
|
||||
promise = ptor.executeScript('SomeScript', 1, 2, 3);
|
||||
promise = ptor.executeScript(function () { });
|
||||
promise = ptor.executeScript(function (a: number, b: number, c: number) { }, 1, 2, 3);
|
||||
|
||||
ptor = browser.forkNewDriverInstance();
|
||||
ptor = browser.forkNewDriverInstance(true);
|
||||
ptor = browser.forkNewDriverInstance(true, false);
|
||||
|
||||
driver = ptor.driver;
|
||||
var baseUrl: string = ptor.baseUrl;
|
||||
var rootEl: string = ptor.rootEl;
|
||||
var ignoreSynchronization: boolean = ptor.ignoreSynchronization;
|
||||
var params: any = ptor.params;
|
||||
ptor.resetUrl = "url";
|
||||
|
||||
ptor.debugger();
|
||||
ptor.close();
|
||||
var controlFlow: protractor.promise.ControlFlow = ptor.controlFlow();
|
||||
|
||||
var webElement: protractor.WebElement = ptor.findElement(by.css('.class'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
promise = ptor.findElements(by.css('.class'));
|
||||
promise = ptor.isElementPresent(by.css('.class'));
|
||||
promise = ptor.isElementPresent(webElement);
|
||||
ptor.findElements(by.css('.class')).then(function (elements: webdriver.WebElement[]) { });
|
||||
ptor.isElementPresent(by.css('.class')).then(function (present: boolean) { });
|
||||
ptor.isElementPresent(webElement).then(function (present: boolean) { });
|
||||
|
||||
ptor.clearMockModules();
|
||||
ptor.addMockModule('name', 'script');
|
||||
@@ -173,16 +258,43 @@ function TestProtractor() {
|
||||
|
||||
elementArrayFinder = ptor.$$('.class');
|
||||
|
||||
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
|
||||
var locationAbsUrl: webdriver.promise.Promise<string> = ptor.getLocationAbsUrl();
|
||||
ptor.setLocation('webaddress.com');
|
||||
|
||||
promise = ptor.get('webaddress.com');
|
||||
promise = ptor.get('webdaddress.com', 45);
|
||||
var voidPromise: webdriver.promise.Promise<void> = ptor.get('webaddress.com');
|
||||
voidPromise = ptor.get('webdaddress.com', 45);
|
||||
voidPromise = ptor.quit();
|
||||
voidPromise = ptor.sleep(5000);
|
||||
|
||||
ptor.refresh();
|
||||
ptor.refresh(45);
|
||||
var navigation: webdriver.WebDriverNavigation = ptor.navigate();
|
||||
ptor.pause();
|
||||
ptor.pause(8080);
|
||||
|
||||
ptor.getAllWindowHandles().then(function (handles: string[]) { });
|
||||
|
||||
var capabilities: protractor.promise.Promise<protractor.Capabilities> = ptor.getCapabilities();
|
||||
|
||||
var stringPromise: webdriver.promise.Promise<string>;
|
||||
stringPromise = ptor.getCurrentUrl();
|
||||
stringPromise = ptor.getPageSource();
|
||||
stringPromise = ptor.getTitle();
|
||||
stringPromise = ptor.getWindowHandle();
|
||||
stringPromise = ptor.takeScreenshot();
|
||||
|
||||
ptor.getPageTimeout = 5000;
|
||||
|
||||
var session: protractor.promise.Promise<protractor.Session> = ptor.getSession();
|
||||
|
||||
var options: webdriver.WebDriverOptions = ptor.manage();
|
||||
|
||||
promise = ptor.schedule(new protractor.Command(protractor.CommandName.ACCEPT_ALERT), 'asdf');
|
||||
|
||||
var targetLocator: webdriver.WebDriverTargetLocator = ptor.switchTo();
|
||||
|
||||
ptor.wait(protractor.until.elementLocated(by.id('id')), 5000).then(function (el: webdriver.IWebElement) { });;
|
||||
ptor.wait(protractor.until.elementLocated(by.id('id')), 5000, 'message').then(function (el: webdriver.IWebElement) { });;
|
||||
}
|
||||
|
||||
function TestElement() {
|
||||
@@ -192,80 +304,121 @@ function TestElement() {
|
||||
|
||||
function TestElementFinder() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
var voidPromise: webdriver.promise.Promise<void>;
|
||||
var stringPromise: webdriver.promise.Promise<string>;
|
||||
var booleanPromise: webdriver.promise.Promise<boolean>;
|
||||
|
||||
promise = elementFinder.click();
|
||||
promise = elementFinder.allowAnimations('string');
|
||||
promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
promise = elementFinder.getTagName();
|
||||
promise = elementFinder.getCssValue('display');
|
||||
promise = elementFinder.getAttribute('atribute');
|
||||
promise = elementFinder.getText();
|
||||
promise = elementFinder.getSize();
|
||||
promise = elementFinder.getLocation();
|
||||
promise = elementFinder.isEnabled();
|
||||
promise = elementFinder.isSelected();
|
||||
promise = elementFinder.submit();
|
||||
promise = elementFinder.clear();
|
||||
promise = elementFinder.isDisplayed();
|
||||
promise = elementFinder.getOuterHtml();
|
||||
promise = elementFinder.getInnerHtml();
|
||||
promise = elementFinder.isElementPresent(by.id('id'));
|
||||
promise = elementFinder.$('.class');
|
||||
promise = elementFinder.$$('.class');
|
||||
promise = elementFinder.evaluate('expression');
|
||||
promise = elementFinder.isPresent();
|
||||
elementFinder.getId().then(function (id: webdriver.IWebElementId) { });
|
||||
voidPromise = elementFinder.click();
|
||||
elementFinder = elementFinder.allowAnimations('string');
|
||||
voidPromise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
stringPromise = elementFinder.getTagName();
|
||||
stringPromise = elementFinder.getCssValue('display');
|
||||
stringPromise = elementFinder.getAttribute('atribute');
|
||||
stringPromise = elementFinder.getText();
|
||||
elementFinder.getSize().then(function (size: webdriver.ISize) { });
|
||||
elementFinder.getLocation().then(function (location: webdriver.ILocation) { });
|
||||
booleanPromise = elementFinder.isEnabled();
|
||||
booleanPromise = elementFinder.isSelected();
|
||||
voidPromise = elementFinder.submit();
|
||||
voidPromise = elementFinder.clear();
|
||||
booleanPromise = elementFinder.isDisplayed();
|
||||
stringPromise = elementFinder.getOuterHtml();
|
||||
stringPromise = elementFinder.getInnerHtml();
|
||||
booleanPromise = elementFinder.isElementPresent(by.id('id'));
|
||||
elementFinder = elementFinder.$('.class');
|
||||
var finders: protractor.ElementArrayFinder = elementFinder.$$('.class');
|
||||
elementFinder = elementFinder.evaluate('expression');
|
||||
booleanPromise = elementFinder.isPresent();
|
||||
|
||||
var webElement: webdriver.WebElement;
|
||||
var webElement: webdriver.WebElement = elementFinder.getWebElement();
|
||||
finders = elementFinder.all(by.className('class'));
|
||||
elementFinder = elementFinder.allowAnimations('abc');
|
||||
elementFinder = elementFinder.clone();
|
||||
elementFinder = elementFinder.element(by.id('id'));
|
||||
|
||||
var b: boolean = elementFinder.isPending();
|
||||
var locator: webdriver.Locator = elementFinder.locator();
|
||||
}
|
||||
|
||||
function TestElementArrayFinder() {
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
var elementFinder: protractor.ElementFinder;
|
||||
|
||||
var voidPromise: webdriver.promise.Promise<void>;
|
||||
var stringPromise: webdriver.promise.Promise<string[]>;
|
||||
var booleanPromise: webdriver.promise.Promise<boolean[]>;
|
||||
|
||||
elementArrayFinder.getId().then(function (id: webdriver.IWebElementId[]) { });
|
||||
voidPromise = elementArrayFinder.click();
|
||||
elementArrayFinder = elementArrayFinder.allowAnimations(true);
|
||||
voidPromise = elementArrayFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
stringPromise = elementArrayFinder.getTagName();
|
||||
stringPromise = elementArrayFinder.getCssValue('display');
|
||||
stringPromise = elementArrayFinder.getAttribute('atribute');
|
||||
stringPromise = elementArrayFinder.getText();
|
||||
elementArrayFinder.getSize().then(function (size: webdriver.ISize[]) { });
|
||||
elementArrayFinder.getLocation().then(function (location: webdriver.ILocation[]) { });
|
||||
booleanPromise = elementArrayFinder.isEnabled();
|
||||
booleanPromise = elementArrayFinder.isSelected();
|
||||
voidPromise = elementArrayFinder.submit();
|
||||
voidPromise = elementArrayFinder.clear();
|
||||
booleanPromise = elementArrayFinder.isDisplayed();
|
||||
stringPromise = elementArrayFinder.getOuterHtml();
|
||||
stringPromise = elementArrayFinder.getInnerHtml();
|
||||
var finders: protractor.ElementArrayFinder = elementArrayFinder.$$('.class');
|
||||
elementArrayFinder = elementArrayFinder.evaluate('expression');
|
||||
|
||||
finders = elementArrayFinder.all(by.className('class'));
|
||||
elementArrayFinder = elementArrayFinder.clone();
|
||||
|
||||
var b: boolean = elementArrayFinder.isPending();
|
||||
var locator: webdriver.Locator = elementArrayFinder.locator();
|
||||
|
||||
var findersArrayPromise: protractor.promise.Promise<protractor.ElementFinder[]> = elementArrayFinder.asElementFinders_();
|
||||
|
||||
var driverElementArray: webdriver.WebElement[] = elementArrayFinder.getWebElements();
|
||||
elementFinder = elementArrayFinder.get(42);
|
||||
var elementFinder: protractor.ElementFinder = elementArrayFinder.get(42);
|
||||
elementFinder = elementArrayFinder.first();
|
||||
elementFinder = elementArrayFinder.last();
|
||||
promise = elementArrayFinder.count();
|
||||
promise = elementArrayFinder.asElementFinders_();
|
||||
elementFinder = elementArrayFinder.toElementFinder_()
|
||||
var numberPromise: protractor.promise.Promise<number> = elementArrayFinder.count();
|
||||
elementArrayFinder.each(function(element: protractor.ElementFinder){
|
||||
// nothing
|
||||
});
|
||||
elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){
|
||||
// nothing
|
||||
});
|
||||
elementArrayFinder.filter(function(element: protractor.ElementFinder, index: number){
|
||||
stringPromise = elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){
|
||||
return 'abc';
|
||||
})
|
||||
elementArrayFinder = elementArrayFinder.filter(function(element: protractor.ElementFinder, index: number){
|
||||
return element.getText().then((text: string) => {
|
||||
return text === "foo";
|
||||
});
|
||||
});
|
||||
elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder){
|
||||
elementArrayFinder.reduce(function (accumulator: string, element: protractor.ElementFinder) {
|
||||
return element.getText().then((text: string) => {
|
||||
return accumulator + ',' + text;
|
||||
});
|
||||
}, '');
|
||||
}, '').then(function (result: string) { });
|
||||
elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder, index: number, array: protractor.ElementFinder[]){
|
||||
return element.getText().then((text: string) => {
|
||||
return accumulator + ',' + text;
|
||||
});
|
||||
}, '');
|
||||
}, '').then(function (result: string) { });
|
||||
elementArrayFinder.then(function(underlyingElementFinders: protractor.ElementFinder[]){
|
||||
//nothing
|
||||
});
|
||||
}
|
||||
|
||||
// This function tests the angular specific locator strategies.
|
||||
// This function tests the locator strategies.
|
||||
function TestLocatorStrategies() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
var ptor: protractor.Protractor = browser;
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
// Protractor Specific Locators
|
||||
protractor.By.addLocator('customLocator', 'script');
|
||||
protractor.By.addLocator('customLocator2', function(){
|
||||
// nothing
|
||||
});
|
||||
|
||||
// Angular specific locators.
|
||||
webElement = ptor.findElement(protractor.By.binding('binding'));
|
||||
webElement = ptor.findElement(protractor.By.exactBinding('exactBinding'));
|
||||
webElement = ptor.findElement(protractor.By.model('model'));
|
||||
@@ -277,4 +430,23 @@ function TestLocatorStrategies() {
|
||||
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
|
||||
webElement = ptor.findElement(protractor.By.cssContainingText('cssSelector', 'search text'));
|
||||
webElement = ptor.findElement(protractor.By.options('options'));
|
||||
// One standard locator for good measure.
|
||||
webElement = ptor.findElement(protractor.By.id('id'));
|
||||
|
||||
var el: protractor.ElementFinder;
|
||||
|
||||
// Angular specific locators.
|
||||
el = element(by.binding('binding'));
|
||||
el = element(by.exactBinding('exactBinding'));
|
||||
el = element(by.model('model'));
|
||||
el = element(by.repeater('repeater'));
|
||||
el = element(by.repeater('repeater').column(0));
|
||||
el = element(by.repeater('repeater').row(0));
|
||||
el = element(by.repeater('repeater').row(0).column(0));
|
||||
el = element(by.buttonText('buttonText'));
|
||||
el = element(by.partialButtonText('partialButtonText'));
|
||||
el = element(by.cssContainingText('cssSelector', 'search text'));
|
||||
el = element(by.options('options'));
|
||||
// One standard locator for good measure.
|
||||
el = element(by.id('id'));
|
||||
}
|
||||
|
||||
1558
angular-protractor/angular-protractor.d.ts
vendored
1558
angular-protractor/angular-protractor.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,244 +0,0 @@
|
||||
/// <reference path="angular-protractor-0.17.0.d.ts" />
|
||||
|
||||
function TestWebDriverExports() {
|
||||
var abstractBuilder: protractor.AbstractBuilder = new protractor.AbstractBuilder();
|
||||
var baseAbstractBuilder: webdriver.AbstractBuilder = abstractBuilder;
|
||||
|
||||
var button: protractor.Button = new protractor.Button();
|
||||
var baseButton: webdriver.Button = button;
|
||||
|
||||
var key: string = protractor.Key.ADD;
|
||||
var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1);
|
||||
|
||||
var driver: protractor.WebDriver = new protractor.Builder().
|
||||
withCapabilities(protractor.Capabilities.chrome()).
|
||||
build();
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
|
||||
var action: protractor.ActionSequence = new protractor.ActionSequence(driver);
|
||||
var baseAction: webdriver.ActionSequence = action;
|
||||
|
||||
var alert: protractor.Alert = new protractor.Alert(driver, 'Message');
|
||||
var baseAlert: webdriver.Alert = alert;
|
||||
|
||||
var unhandledAlertError: protractor.UnhandledAlertError = new protractor.UnhandledAlertError('Message', alert);
|
||||
var baseUnhandledAlertError: webdriver.UnhandledAlertError = unhandledAlertError;
|
||||
|
||||
var browser: string = protractor.Browser.ANDROID;
|
||||
|
||||
var builder: protractor.Builder = new protractor.Builder();
|
||||
var baseBuilder: webdriver.Builder = builder;
|
||||
|
||||
var capability: string = protractor.Capability.BROWSER_NAME;
|
||||
|
||||
var capabilities: protractor.Capabilities = protractor.Capabilities.chrome();
|
||||
var baseCapabilities: webdriver.Capabilities = capabilities;
|
||||
|
||||
var commandName: string = protractor.CommandName.CLICK_ELEMENT;
|
||||
|
||||
var command: protractor.Command = new protractor.Command(protractor.CommandName.CLICK);
|
||||
var baseCommand: webdriver.Command = command;
|
||||
|
||||
var eventEmitter: protractor.EventEmitter = new protractor.EventEmitter();
|
||||
var baseEventEmitter: webdriver.EventEmitter = eventEmitter;
|
||||
|
||||
var firefoxDomExecutor: protractor.FirefoxDomExecutor = new protractor.FirefoxDomExecutor();
|
||||
var baseFirefoxDomExecutor: webdriver.FirefoxDomExecutor = firefoxDomExecutor;
|
||||
|
||||
var webElement: protractor.WebElement = new protractor.WebElement(driver, new protractor.promise.Promise());
|
||||
var baseWebElement: webdriver.WebElement = webElement;
|
||||
|
||||
var locator: protractor.Locator = new protractor.Locator('id', 'ABC');
|
||||
var baseLocator: webdriver.Locator = locator;
|
||||
|
||||
var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android());
|
||||
var baseSession: webdriver.Session = session;
|
||||
|
||||
locator = protractor.By.name('name');
|
||||
|
||||
// logging module
|
||||
|
||||
var levelName: string = protractor.logging.LevelName.ALL;
|
||||
var loggingType: string = protractor.logging.Type.CLIENT;
|
||||
|
||||
var level: webdriver.logging.Level = protractor.logging.Level.ALL;
|
||||
|
||||
var entry: protractor.logging.Entry = new protractor.logging.Entry(protractor.logging.Level.ALL, 'Message');
|
||||
var baseEntry: webdriver.logging.Entry = entry;
|
||||
|
||||
level = protractor.logging.getLevel('DEBUG');
|
||||
|
||||
protractor.logging.Preferences = { a: 123 };
|
||||
|
||||
// promise module
|
||||
|
||||
var promise: protractor.promise.Promise = new protractor.promise.Promise();
|
||||
var basePromise: webdriver.promise.Promise = promise;
|
||||
|
||||
var deferred: protractor.promise.Deferred = new protractor.promise.Deferred();
|
||||
var baseDeferred: webdriver.promise.Deferred = deferred;
|
||||
|
||||
var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow();
|
||||
var baseFlow: webdriver.promise.ControlFlow = flow;
|
||||
|
||||
protractor.promise.asap(promise, function(value: any){ return true; });
|
||||
protractor.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; });
|
||||
|
||||
promise = protractor.promise.checkedNodeCall(function(err: any, value: any) { return 123; });
|
||||
|
||||
flow = protractor.promise.controlFlow();
|
||||
|
||||
promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
|
||||
|
||||
deferred = protractor.promise.defer(function() {});
|
||||
deferred = protractor.promise.defer(function(reason?: any) {});
|
||||
|
||||
promise = protractor.promise.delayed(123);
|
||||
|
||||
promise = protractor.promise.fulfilled();
|
||||
promise = protractor.promise.fulfilled({a: 123});
|
||||
|
||||
promise = protractor.promise.fullyResolved({a: 123});
|
||||
|
||||
var isPromise: boolean = protractor.promise.isPromise('ABC');
|
||||
|
||||
promise = protractor.promise.rejected({a: 123});
|
||||
|
||||
protractor.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
|
||||
|
||||
promise = protractor.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; });
|
||||
|
||||
// error module
|
||||
|
||||
var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
|
||||
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
|
||||
var baseError: webdriver.error.Error = error;
|
||||
|
||||
// process module
|
||||
|
||||
var isNative: boolean = protractor.process.isNative();
|
||||
var value: string;
|
||||
|
||||
value = protractor.process.getEnv('name');
|
||||
value = protractor.process.getEnv('name', 'default');
|
||||
|
||||
protractor.process.setEnv('name', 'value');
|
||||
protractor.process.setEnv('name', 123);
|
||||
|
||||
}
|
||||
|
||||
function TestProtractor() {
|
||||
var ptor: protractor.Protractor;
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
ptor = new protractor.Protractor(driver);
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl');
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl', 'rootElement');
|
||||
ptor = protractor.getInstance();
|
||||
protractor.setInstance(ptor);
|
||||
|
||||
ptor = protractor.wrapDriver(driver);
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl');
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl', 'rootElement');
|
||||
|
||||
ptor = browser;
|
||||
|
||||
driver = ptor.driver;
|
||||
var baseUrl: string = ptor.baseUrl;
|
||||
var rootEl: string = ptor.rootEl;
|
||||
var ignoreSynchronization: boolean = ptor.ignoreSynchronization;
|
||||
var params: any = ptor.params;
|
||||
|
||||
ptor.debugger();
|
||||
|
||||
ptor.clearMockModules();
|
||||
ptor.addMockModule('name', 'script');
|
||||
ptor.addMockModule('name', function() {});
|
||||
ptor.waitForAngular();
|
||||
|
||||
var elementFinder: protractor.ElementFinder;
|
||||
|
||||
elementFinder = ptor.element(by.id('ABC'));
|
||||
elementFinder = ptor.$('.class');
|
||||
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = ptor.$$('.class');
|
||||
|
||||
var webElement: webdriver.WebElement = ptor.wrapWebElement(new webdriver.WebElement(driver, 'id'));
|
||||
|
||||
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
|
||||
}
|
||||
|
||||
function TestElement() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.className('class'));
|
||||
}
|
||||
|
||||
function TestElementFinder() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = elementFinder.click();
|
||||
promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
promise = elementFinder.getTagName();
|
||||
promise = elementFinder.getCssValue('display');
|
||||
promise = elementFinder.getAttribute('atribute');
|
||||
promise = elementFinder.getText();
|
||||
promise = elementFinder.getSize();
|
||||
promise = elementFinder.getLocation();
|
||||
promise = elementFinder.isEnabled();
|
||||
promise = elementFinder.isSelected();
|
||||
promise = elementFinder.submit();
|
||||
promise = elementFinder.clear();
|
||||
promise = elementFinder.isDisplayed();
|
||||
promise = elementFinder.getOuterHtml();
|
||||
promise = elementFinder.getInnerHtml();
|
||||
promise = elementFinder.isElementPresent(by.id('id'));
|
||||
promise = elementFinder.isElementPresent(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
promise = elementFinder.findElements(by.className('class'));
|
||||
promise = elementFinder.findElements(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
promise = elementFinder.$$('.class');
|
||||
promise = elementFinder.evaluate('expression');
|
||||
promise = elementFinder.isPresent();
|
||||
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
webElement = elementFinder.$('.class');
|
||||
webElement = elementFinder.findElement(by.id('id'));
|
||||
webElement = elementFinder.findElement(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
webElement = elementFinder.find();
|
||||
}
|
||||
|
||||
// This function tests the angular specific locator strategies.
|
||||
function TestLocatorStrategies() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
// Protractor Specific Locators
|
||||
webElement = ptor.findElement(protractor.By.binding('binding'));
|
||||
webElement = ptor.findElement(protractor.By.select('select'));
|
||||
webElement = ptor.findElement(protractor.By.selectedOption('selectedOptions'));
|
||||
webElement = ptor.findElement(protractor.By.input('input'));
|
||||
webElement = ptor.findElement(protractor.By.model('model'));
|
||||
webElement = ptor.findElement(protractor.By.textarea('textarea'));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater'));
|
||||
webElement = ptor.findElement(protractor.By.buttonText('buttonText'));
|
||||
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
|
||||
}
|
||||
|
||||
// This function tests the methods that were added to the base WebElement class
|
||||
function TestWebElements() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
|
||||
var webElement: protractor.WebElement;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
webElement = ptor.findElement(by.id('id')).$('.class');
|
||||
promise = ptor.findElement(by.id('id')).$$('.class');
|
||||
promise = ptor.findElement(by.id('id')).evaluate('something');
|
||||
|
||||
webElement = webElement.findElement(by.id('id')).$('.class');
|
||||
promise = webElement.findElement(by.id('id')).$$('.class');
|
||||
promise = webElement.findElement(by.id('id')).evaluate('something');
|
||||
}
|
||||
@@ -1,906 +0,0 @@
|
||||
// Type definitions for Angular Protractor 0.17.0
|
||||
// Project: https://github.com/angular/protractor
|
||||
// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../../selenium-webdriver/selenium-webdriver.d.ts" />
|
||||
|
||||
declare module protractor {
|
||||
//region Wrapped webdriver Items
|
||||
|
||||
class AbstractBuilder extends webdriver.AbstractBuilder {}
|
||||
class ActionSequence extends webdriver.ActionSequence {}
|
||||
class Alert extends webdriver.Alert {}
|
||||
class Builder extends webdriver.Builder {}
|
||||
class Button extends webdriver.Button {}
|
||||
class Capabilities extends webdriver.Capabilities {}
|
||||
class Command extends webdriver.Command {}
|
||||
class EventEmitter extends webdriver.EventEmitter {}
|
||||
class FirefoxDomExecutor extends webdriver.FirefoxDomExecutor {}
|
||||
class Locator extends webdriver.Locator {}
|
||||
class Session extends webdriver.Session {}
|
||||
class WebDriver extends webdriver.WebDriver {}
|
||||
class Browser extends webdriver.Browser {}
|
||||
class Capability extends webdriver.Capability {}
|
||||
class CommandName extends webdriver.CommandName {}
|
||||
class Key extends webdriver.Key {}
|
||||
class UnhandledAlertError extends webdriver.UnhandledAlertError {}
|
||||
|
||||
class WebElement extends webdriver.WebElement {
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElement
|
||||
* @return {!protractor.WebElement}
|
||||
*/
|
||||
$(selector: string): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElements
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
$$(selector: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Evalates the input as if it were on the scope of the current element.
|
||||
* @param {string} expression
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* evaluated expression. The result will be resolved as in
|
||||
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
|
||||
* be resolved as is, functions will be converted to string, and elements
|
||||
* will be returned as a WebElement.
|
||||
*/
|
||||
evaluate(expression: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedule a command to find a descendant of this element. If the element
|
||||
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@code #isElementPresent} instead.
|
||||
* <p/>
|
||||
* The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two
|
||||
* statements are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = element.findElement(By.id('foo'));
|
||||
* var e2 = element.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
|
||||
}
|
||||
|
||||
module command {
|
||||
class Command extends webdriver.Command {}
|
||||
class CommandName extends webdriver.CommandName {}
|
||||
}
|
||||
|
||||
module error {
|
||||
class Error extends webdriver.error.Error {}
|
||||
class ErrorCode extends webdriver.error.ErrorCode {}
|
||||
}
|
||||
|
||||
module events {
|
||||
class EventEmitter extends webdriver.EventEmitter {}
|
||||
}
|
||||
|
||||
module logging {
|
||||
var Preferences: any;
|
||||
|
||||
class LevelName extends webdriver.logging.LevelName {}
|
||||
class Type extends webdriver.logging.Type {}
|
||||
class Level extends webdriver.logging.Level {}
|
||||
class Entry extends webdriver.logging.Entry {}
|
||||
|
||||
function getLevel(nameOrValue: string): webdriver.logging.Level;
|
||||
function getLevel(nameOrValue: number): webdriver.logging.Level;
|
||||
}
|
||||
|
||||
module promise {
|
||||
class Promise extends webdriver.promise.Promise {}
|
||||
class Deferred extends webdriver.promise.Deferred {}
|
||||
class ControlFlow extends webdriver.promise.ControlFlow {}
|
||||
|
||||
/**
|
||||
* @return {!webdriver.promise.ControlFlow} The currently active control flow.
|
||||
*/
|
||||
function controlFlow(): webdriver.promise.ControlFlow;
|
||||
|
||||
/**
|
||||
* Creates a new control flow. The provided callback will be invoked as the
|
||||
* first task within the new flow, with the flow as its sole argument. Returns
|
||||
* a promise that resolves to the callback result.
|
||||
* @param {function(!webdriver.promise.ControlFlow)} callback The entry point
|
||||
* to the newly created flow.
|
||||
* @return {!webdriver.promise.Promise} A promise that resolves to the callback
|
||||
* result.
|
||||
*/
|
||||
function createFlow(callback: (flow: webdriver.promise.ControlFlow) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Determines whether a {@code value} should be treated as a promise.
|
||||
* Any object whose "then" property is a function will be considered a promise.
|
||||
*
|
||||
* @param {*} value The value to test.
|
||||
* @return {boolean} Whether the value is a promise.
|
||||
*/
|
||||
function isPromise(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Creates a promise that will be resolved at a set time in the future.
|
||||
* @param {number} ms The amount of time, in milliseconds, to wait before
|
||||
* resolving the promise.
|
||||
* @return {!webdriver.promise.Promise} The promise.
|
||||
*/
|
||||
function delayed(ms: number): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Creates a new deferred object.
|
||||
* @param {Function=} opt_canceller Function to call when cancelling the
|
||||
* computation of this instance's value.
|
||||
* @return {!webdriver.promise.Deferred} The new deferred object.
|
||||
*/
|
||||
function defer(opt_canceller?: any): webdriver.promise.Deferred;
|
||||
|
||||
/**
|
||||
* Creates a promise that has been resolved with the given value.
|
||||
* @param {*=} opt_value The resolved value.
|
||||
* @return {!webdriver.promise.Promise} The resolved promise.
|
||||
*/
|
||||
function fulfilled(opt_value?: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Creates a promise that has been rejected with the given reason.
|
||||
* @param {*=} opt_reason The rejection reason; may be any value, but is
|
||||
* usually an Error or a string.
|
||||
* @return {!webdriver.promise.Promise} The rejected promise.
|
||||
*/
|
||||
function rejected(opt_reason?: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Wraps a function that is assumed to be a node-style callback as its final
|
||||
* argument. This callback takes two arguments: an error value (which will be
|
||||
* null if the call succeeded), and the success value as the second argument.
|
||||
* If the call fails, the returned promise will be rejected, otherwise it will
|
||||
* be resolved with the result.
|
||||
* @param {!Function} fn The function to wrap.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* result of the provided function's callback.
|
||||
*/
|
||||
function checkedNodeCall(fn: (error: any, value: any) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Registers an observer on a promised {@code value}, returning a new promise
|
||||
* that will be resolved when the value is. If {@code value} is not a promise,
|
||||
* then the return promise will be immediately resolved.
|
||||
* @param {*} value The value to observe.
|
||||
* @param {Function=} opt_callback The function to call when the value is
|
||||
* resolved successfully.
|
||||
* @param {Function=} opt_errback The function to call when the value is
|
||||
* rejected.
|
||||
* @return {!webdriver.promise.Promise} A new promise.
|
||||
*/
|
||||
function when(value: any, opt_callback?: (value: any) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Invokes the appropriate callback function as soon as a promised
|
||||
* {@code value} is resolved. This function is similar to
|
||||
* {@code webdriver.promise.when}, except it does not return a new promise.
|
||||
* @param {*} value The value to observe.
|
||||
* @param {Function} callback The function to call when the value is
|
||||
* resolved successfully.
|
||||
* @param {Function=} opt_errback The function to call when the value is
|
||||
* rejected.
|
||||
*/
|
||||
function asap(value: any, callback: (value: any) => any, opt_errback?: (error: any) => any): void;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be resolved with the input value in a
|
||||
* fully-resolved state. If the value is an array, each element will be fully
|
||||
* resolved. Likewise, if the value is an object, all keys will be fully
|
||||
* resolved. In both cases, all nested arrays and objects will also be
|
||||
* fully resolved. All fields are resolved in place; the returned promise will
|
||||
* resolve on {@code value} and not a copy.
|
||||
*
|
||||
* Warning: This function makes no checks against objects that contain
|
||||
* cyclical references:
|
||||
*
|
||||
* var value = {};
|
||||
* value['self'] = value;
|
||||
* webdriver.promise.fullyResolved(value); // Stack overflow.
|
||||
*
|
||||
* @param {*} value The value to fully resolve.
|
||||
* @return {!webdriver.promise.Promise} A promise for a fully resolved version
|
||||
* of the input value.
|
||||
*/
|
||||
function fullyResolved(value: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Changes the default flow to use when no others are active.
|
||||
* @param {!webdriver.promise.ControlFlow} flow The new default flow.
|
||||
* @throws {Error} If the default flow is not currently active.
|
||||
*/
|
||||
function setDefaultFlow(flow: webdriver.promise.ControlFlow): void;
|
||||
|
||||
}
|
||||
|
||||
module process {
|
||||
|
||||
/**
|
||||
* Queries for a named environment variable.
|
||||
* @param {string} name The name of the environment variable to look up.
|
||||
* @param {string=} opt_default The default value if the named variable is not
|
||||
* defined.
|
||||
* @return {string} The queried environment variable.
|
||||
*/
|
||||
function getEnv(name: string, opt_default?: string): string;
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether the current process is Node's native process
|
||||
* object.
|
||||
*/
|
||||
function isNative(): boolean;
|
||||
|
||||
/**
|
||||
* Sets an environment value. If the new value is either null or undefined, the
|
||||
* environment variable will be cleared.
|
||||
* @param {string} name The value to set.
|
||||
* @param {*} value The new value; will be coerced to a string.
|
||||
*/
|
||||
function setEnv(name: string, value: any): void;
|
||||
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
interface Element {
|
||||
(locator: webdriver.Locator): ElementFinder;
|
||||
all(locator: webdriver.Locator): ElementArrayFinder;
|
||||
}
|
||||
|
||||
interface ElementFinder {
|
||||
/**
|
||||
* Schedules a command to click on this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
* the click command has completed.
|
||||
*/
|
||||
click(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to type a sequence on the DOM element represented by this
|
||||
* instance.
|
||||
* <p/>
|
||||
* Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is
|
||||
* processed in the keysequence, that key state is toggled until one of the
|
||||
* following occurs:
|
||||
* <ul>
|
||||
* <li>The modifier key is encountered again in the sequence. At this point the
|
||||
* state of the key is toggled (along with the appropriate keyup/down events).
|
||||
* </li>
|
||||
* <li>The {@code webdriver.Key.NULL} key is encountered in the sequence. When
|
||||
* this key is encountered, all modifier keys current in the down state are
|
||||
* released (with accompanying keyup events). The NULL key can be used to
|
||||
* simulate common keyboard shortcuts:
|
||||
* <code>
|
||||
* element.sendKeys("text was",
|
||||
* webdriver.Key.CONTROL, "a", webdriver.Key.NULL,
|
||||
* "now text is");
|
||||
* // Alternatively:
|
||||
* element.sendKeys("text was",
|
||||
* webdriver.Key.chord(webdriver.Key.CONTROL, "a"),
|
||||
* "now text is");
|
||||
* </code></li>
|
||||
* <li>The end of the keysequence is encountered. When there are no more keys
|
||||
* to type, all depressed modifier keys are released (with accompanying keyup
|
||||
* events).
|
||||
* </li>
|
||||
* </ul>
|
||||
* <strong>Note:</strong> On browsers where native keyboard events are not yet
|
||||
* supported (e.g. Firefox on OS X), key events will be synthesized. Special
|
||||
* punctionation keys will be synthesized according to a standard QWERTY en-us
|
||||
* keyboard layout.
|
||||
*
|
||||
* @param {...string} var_args The sequence of keys to
|
||||
* type. All arguments will be joined into a single sequence (var_args is
|
||||
* permitted for convenience).
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when all
|
||||
* keys have been typed.
|
||||
*/
|
||||
sendKeys(...var_args: string[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query for the tag/node name of this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's tag name.
|
||||
*/
|
||||
getTagName(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query for the computed style of the element
|
||||
* represented by this instance. If the element inherits the named style from
|
||||
* its parent, the parent will be queried for its value. Where possible, color
|
||||
* values will be converted to their hex representation (e.g. #00ff00 instead of
|
||||
* rgb(0, 255, 0)).
|
||||
* <p/>
|
||||
* <em>Warning:</em> the value returned will be as the browser interprets it, so
|
||||
* it may be tricky to form a proper assertion.
|
||||
*
|
||||
* @param {string} cssStyleProperty The name of the CSS style property to look
|
||||
* up.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* requested CSS value.
|
||||
*/
|
||||
getCssValue(cssStyleProperty: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query for the value of the given attribute of the
|
||||
* element. Will return the current value even if it has been modified after the
|
||||
* page has been loaded. More exactly, this method will return the value of the
|
||||
* given attribute, unless that attribute is not present, in which case the
|
||||
* value of the property with the same name is returned. If neither value is
|
||||
* set, null is returned. The "style" attribute is converted as best can be to a
|
||||
* text representation with a trailing semi-colon. The following are deemed to
|
||||
* be "boolean" attributes and will be returned as thus:
|
||||
*
|
||||
* <p>async, autofocus, autoplay, checked, compact, complete, controls, declare,
|
||||
* defaultchecked, defaultselected, defer, disabled, draggable, ended,
|
||||
* formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope,
|
||||
* loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open,
|
||||
* paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
|
||||
* selected, spellcheck, truespeed, willvalidate
|
||||
*
|
||||
* <p>Finally, the following commonly mis-capitalized attribute/property names
|
||||
* are evaluated as expected:
|
||||
* <ul>
|
||||
* <li>"class"
|
||||
* <li>"readonly"
|
||||
* </ul>
|
||||
* @param {string} attributeName The name of the attribute to query.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* attribute's value.
|
||||
*/
|
||||
getAttribute(attributeName: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Get the visible (i.e. not hidden by CSS) innerText of this element, including
|
||||
* sub-elements, without any leading or trailing whitespace.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's visible text.
|
||||
*/
|
||||
getText(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to compute the size of this element's bounding box, in
|
||||
* pixels.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's size as a {@code {width:number, height:number}} object.
|
||||
*/
|
||||
getSize(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to compute the location of this element in page space.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to the
|
||||
* element's location as a {@code {x:number, y:number}} object.
|
||||
*/
|
||||
getLocation(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query whether the DOM element represented by this
|
||||
* instance is enabled, as dicted by the {@code disabled} attribute.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether this element is currently enabled.
|
||||
*/
|
||||
isEnabled(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query whether this element is selected.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether this element is currently selected.
|
||||
*/
|
||||
isSelected(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to submit the form containing this element (or this
|
||||
* element if it is a FORM element). This command is a no-op if the element is
|
||||
* not contained in a form.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
* the form has been submitted.
|
||||
*/
|
||||
submit(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to clear the {@code value} of this element. This command
|
||||
* has no effect if the underlying DOM element is neither a text INPUT element
|
||||
* nor a TEXTAREA element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
* the element has been cleared.
|
||||
*/
|
||||
clear(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test whether this element is currently displayed.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether this element is currently visible on the page.
|
||||
*/
|
||||
isDisplayed(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the outer HTML of this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* the element's outer HTML.
|
||||
*/
|
||||
getOuterHtml(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the inner HTML of this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's inner HTML.
|
||||
*/
|
||||
getInnerHtml(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test if there is at least one descendant of this
|
||||
* element that matches the given search criteria.
|
||||
*
|
||||
* <p>Note that JS locator searches cannot be restricted to a subtree of the
|
||||
* DOM. All such searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether an element could be located on the page.
|
||||
*/
|
||||
isElementPresent(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
|
||||
isElementPresent(locator: any, ...var_args: any[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to find all of the descendants of this element that match
|
||||
* the given search criteria.
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the elements.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with an
|
||||
* array of located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
|
||||
findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElement
|
||||
* @return {!protractor.WebElement}
|
||||
*/
|
||||
$(selector: string): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElements
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
$$(selector: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedule a command to find a descendant of this element. If the element
|
||||
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@code #isElementPresent} instead.
|
||||
* <p/>
|
||||
* The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two
|
||||
* statements are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = element.findElement(By.id('foo'));
|
||||
* var e2 = element.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Evalates the input as if it were on the scope of the current element.
|
||||
* @param {string} expression
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* evaluated expression. The result will be resolved as in
|
||||
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
|
||||
* be resolved as is, functions will be converted to string, and elements
|
||||
* will be returned as a WebElement.
|
||||
*/
|
||||
evaluate(expression: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Use as: element(locator).element(locator)
|
||||
* Calls to element may be chained to find elements within a parent.
|
||||
*
|
||||
* @param {webdriver.Locator} The locator that will be used to find descendents.
|
||||
*
|
||||
* @return {protractor.ElementFinder} the descendent element found by the locator
|
||||
*/
|
||||
element(locator: webdriver.Locator): protractor.ElementFinder;
|
||||
|
||||
/**
|
||||
* Use as: element(locator).all(locator)
|
||||
* Calls to element may be chained to find an array of elements within a parent.
|
||||
*
|
||||
* @param {webdriver.Locator} The locator that will be used to find descendents.
|
||||
*
|
||||
* @return {protractor.ElementArrayFinder} the descendent elements found by the locator
|
||||
*/
|
||||
all(locator: webdriver.Locator): protractor.ElementArrayFinder;
|
||||
|
||||
find(): protractor.WebElement;
|
||||
|
||||
isPresent(): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
interface ElementArrayFinder{
|
||||
count(): webdriver.promise.Promise;
|
||||
get(index: number): protractor.WebElement;
|
||||
first(): protractor.WebElement;
|
||||
last(): protractor.WebElement;
|
||||
then(fn: (value: any) => any): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
class LocatorWithColumn extends webdriver.Locator {
|
||||
column(index: number): webdriver.Locator;
|
||||
}
|
||||
|
||||
class RepeaterLocator extends LocatorWithColumn {
|
||||
row(index: number): LocatorWithColumn;
|
||||
}
|
||||
|
||||
interface IProtractorLocatorStrategy extends webdriver.ILocatorStrategy {
|
||||
/**
|
||||
* Add a locator to this instance of ProtractorBy. This locator can then be
|
||||
* used with element(by.<name>(<args>)).
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {function|string} script A script to be run in the context of
|
||||
* the browser. This script will be passed an array of arguments
|
||||
* that begins with the element scoping the search, and then
|
||||
* contains any args passed into the locator. It should return
|
||||
* an array of elements.
|
||||
*/
|
||||
addLocator(name: string, script: any): void;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <span>{{status}}</span>
|
||||
* var status = element(by.binding('{{status}}'));
|
||||
*/
|
||||
binding(bindingDescriptor: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <select ng-model="user" ng-options="user.name for user in users"></select>
|
||||
* element(by.select("user"));
|
||||
*/
|
||||
select(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <select ng-model="user" ng-options="user.name for user in users"></select>
|
||||
* element(by.selectedOption("user"));
|
||||
*/
|
||||
selectedOption(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* @DEPRECATED - use 'model' instead.
|
||||
* Usage:
|
||||
* <input ng-model="user" type="text"/>
|
||||
* element(by.input('user'));
|
||||
*/
|
||||
input(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <input ng-model="user" type="text"/>
|
||||
* element(by.model('user'));
|
||||
*/
|
||||
model(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <textarea ng-model="user"></textarea>
|
||||
* element(by.textarea("user"));
|
||||
*/
|
||||
textarea(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <div ng-repeat = "cat in pets">
|
||||
* <span>{{cat.name}}</span>
|
||||
* <span>{{cat.age}}</span>
|
||||
* </div>
|
||||
*
|
||||
* // Returns the DIV for the second cat.
|
||||
* var secondCat = element(by.repeater("cat in pets").row(2));
|
||||
* // Returns the SPAN for the first cat's name.
|
||||
* var firstCatName = element(
|
||||
* by.repeater("cat in pets").row(1).column("{{cat.name}}"));
|
||||
* // Returns a promise that resolves to an array of WebElements from a column
|
||||
* var ages = element(
|
||||
* by.repeater("cat in pets").column("{{cat.age}}"));
|
||||
* // Returns a promise that resolves to an array of WebElements containing
|
||||
* // all rows of the repeater.
|
||||
* var rows = element(by.repeater("cat in pets"));
|
||||
*/
|
||||
repeater(repeatDescriptor: string): RepeaterLocator;
|
||||
|
||||
buttonText(searchText: string): webdriver.Locator;
|
||||
|
||||
partialButtonText(searchText: string): webdriver.Locator;
|
||||
}
|
||||
|
||||
var By: IProtractorLocatorStrategy;
|
||||
|
||||
class Protractor extends webdriver.WebDriver {
|
||||
|
||||
//region Constructors
|
||||
|
||||
/**
|
||||
* @param {webdriver.WebDriver} webdriver
|
||||
* @param {string=} opt_baseUrl A base URL to run get requests against.
|
||||
* @param {string=body} opt_rootElement Selector element that has an ng-app in
|
||||
* scope.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string);
|
||||
|
||||
//endregion
|
||||
|
||||
//region Properties
|
||||
|
||||
/**
|
||||
* The wrapped webdriver instance. Use this to interact with pages that do
|
||||
* not contain Angular (such as a log-in screen).
|
||||
*
|
||||
* @type {webdriver.WebDriver}
|
||||
*/
|
||||
driver: webdriver.WebDriver;
|
||||
|
||||
/**
|
||||
* All get methods will be resolved against this base URL. Relative URLs are =
|
||||
* resolved the way anchor tags resolve.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
baseUrl: string;
|
||||
|
||||
/**
|
||||
* The css selector for an element on which to find Angular. This is usually
|
||||
* 'body' but if your ng-app is on a subsection of the page it may be
|
||||
* a subelement.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
rootEl: string;
|
||||
|
||||
/**
|
||||
* If true, Protractor will not attempt to synchronize with the page before
|
||||
* performing actions. This can be harmful because Protractor will not wait
|
||||
* until $timeouts and $http calls have been processed, which can cause
|
||||
* tests to become flaky. This should be used only when necessary, such as
|
||||
* when a page continuously polls an API using $timeout.
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
ignoreSynchronization: boolean;
|
||||
|
||||
/**
|
||||
* An object that holds custom test parameters.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
params: any;
|
||||
|
||||
//endregion
|
||||
|
||||
//region Methods
|
||||
|
||||
/**
|
||||
* Helper function for finding elements.
|
||||
*
|
||||
* @type {function(webdriver.Locator): ElementFinder}
|
||||
*/
|
||||
element(locator: webdriver.Locator): ElementFinder;
|
||||
|
||||
/**
|
||||
* Helper function for finding elements by css.
|
||||
*
|
||||
* @type {function(string): ElementFinder}
|
||||
*/
|
||||
$(cssLocator: string): ElementFinder;
|
||||
|
||||
/**
|
||||
* Helper function for finding arrays of elements by css.
|
||||
*
|
||||
* @type {function(string): ElementArrayFinder}
|
||||
*/
|
||||
$$(cssLocator: string): ElementArrayFinder;
|
||||
|
||||
/**
|
||||
* Instruct webdriver to wait until Angular has finished rendering and has
|
||||
* no outstanding $http calls before continuing.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* scripts return value.
|
||||
*/
|
||||
waitForAngular(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Wrap a webdriver.WebElement with protractor specific functionality.
|
||||
*
|
||||
* @param {webdriver.WebElement} element
|
||||
* @return {protractor.WebElement} the wrapped web element.
|
||||
*/
|
||||
wrapWebElement(element: webdriver.WebElement): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Add a module to load before Angular whenever Protractor.get is called.
|
||||
* Modules will be registered after existing modules already on the page,
|
||||
* so any module registered here will override preexisting modules with the same
|
||||
* name.
|
||||
*
|
||||
* @param {!string} name The name of the module to load or override.
|
||||
* @param {!string|Function} script The JavaScript to load the module.
|
||||
*/
|
||||
addMockModule(name: string, script: string): void;
|
||||
addMockModule(name: string, script: any): void;
|
||||
|
||||
/**
|
||||
* Clear the list of registered mock modules.
|
||||
*/
|
||||
clearMockModules(): void;
|
||||
|
||||
/**
|
||||
* Returns the current absolute url from AngularJS.
|
||||
*/
|
||||
getLocationAbsUrl(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Pauses the test and injects some helper functions into the browser, so that
|
||||
* debugging may be done in the browser console.
|
||||
*
|
||||
* This should be used under node in debug mode, i.e. with
|
||||
* protractor debug <configuration.js>
|
||||
*
|
||||
* While in the debugger, commands can be scheduled through webdriver by
|
||||
* entering the repl:
|
||||
* debug> repl
|
||||
* Press Ctrl + C to leave rdebug repl
|
||||
* > ptor.findElement(protractor.By.input('user').sendKeys('Laura'));
|
||||
* > ptor.debugger();
|
||||
* debug> c
|
||||
*
|
||||
* This will run the sendKeys command as the next task, then re-enter the
|
||||
* debugger.
|
||||
*/
|
||||
debugger(): void;
|
||||
|
||||
/**
|
||||
* Schedule a command to find an element on the page. If the element cannot be
|
||||
* found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will be returned
|
||||
* by the driver. Unlike other commands, this error cannot be suppressed. In
|
||||
* other words, scheduling a command to find an element doubles as an assert
|
||||
* that the element is present on the page. To test whether an element is
|
||||
* present on the page, use {@code #isElementPresent} instead.
|
||||
*
|
||||
* <p>The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two statements
|
||||
* are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = driver.findElement(By.id('foo'));
|
||||
* var e2 = driver.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
*
|
||||
* <p>When running in the browser, a WebDriver cannot manipulate DOM elements
|
||||
* directly; it may do so only through a {@link webdriver.WebElement} reference.
|
||||
* This function may be used to generate a WebElement from a DOM element. A
|
||||
* reference to the DOM element will be stored in a known location and this
|
||||
* driver will attempt to retrieve it through {@link #executeScript}. If the
|
||||
* element cannot be found (eg, it belongs to a different document than the
|
||||
* one this instance is currently focused on), a
|
||||
* {@link bot.ErrorCode.NO_SUCH_ELEMENT} error will be returned.
|
||||
*
|
||||
* @param {!(webdriver.Locator|Object.<string>|Element)} locatorOrElement The
|
||||
* locator strategy to use when searching for the element, or the actual
|
||||
* DOM element to be located by the server.
|
||||
* @param {...} var_args Arguments to pass to {@code #executeScript} if using a
|
||||
* JavaScript locator. Otherwise ignored.
|
||||
* @return {!protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locatorOrElement: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locatorOrElement: any, ...var_args: any[]): protractor.WebElement;
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of Protractor by wrapping a webdriver instance.
|
||||
*
|
||||
* @param {webdriver.WebDriver} webdriver The configured webdriver instance.
|
||||
* @param {string=} opt_baseUrl A URL to prepend to relative gets.
|
||||
* @return {Protractor}
|
||||
*/
|
||||
function wrapDriver(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string): Protractor;
|
||||
|
||||
/**
|
||||
* Set a singleton instance of protractor.
|
||||
* @param {Protractor} ptor
|
||||
*/
|
||||
function setInstance(ptor: Protractor): void;
|
||||
|
||||
/**
|
||||
* Get the singleton instance.
|
||||
* @return {Protractor}
|
||||
*/
|
||||
function getInstance(): Protractor;
|
||||
|
||||
}
|
||||
|
||||
interface cssSelectorHelper {
|
||||
(cssLocator: string): protractor.ElementFinder;
|
||||
}
|
||||
|
||||
declare var browser: protractor.Protractor;
|
||||
declare var by: protractor.IProtractorLocatorStrategy;
|
||||
declare var element: protractor.Element;
|
||||
declare var $: cssSelectorHelper;
|
||||
declare var $$: cssSelectorHelper;
|
||||
|
||||
declare module 'protractor' {
|
||||
export = protractor;
|
||||
}
|
||||
64
angular-scroll/angular-scroll-tests.ts
Normal file
64
angular-scroll/angular-scroll-tests.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/// <reference path="angular-scroll.d.ts" />
|
||||
|
||||
module TestApp {
|
||||
|
||||
class TestController {
|
||||
|
||||
constructor($scope: ng.IScope, $document: duScroll.IDocumentService) {
|
||||
var positionFromTop = 400;
|
||||
var positionFromLeft = 200;
|
||||
var offsetInPixels = 100;
|
||||
var durationInMillis = 2000;
|
||||
var someElement: ng.IAugmentedJQuery;
|
||||
|
||||
$document.duScrollTo(positionFromLeft, positionFromTop);
|
||||
$document.duScrollTo(positionFromLeft, positionFromTop, durationInMillis).then(this.onScrollCompleted);
|
||||
$document.duScrollTo(positionFromLeft, positionFromTop, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
|
||||
|
||||
$document.duScrollTo(someElement);
|
||||
$document.duScrollTo(someElement, offsetInPixels);
|
||||
$document.duScrollTo(someElement, offsetInPixels, durationInMillis).then(this.onScrollCompleted);
|
||||
$document.duScrollTo(someElement, offsetInPixels, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
|
||||
|
||||
$document.duScrollToElement(someElement);
|
||||
$document.duScrollToElement(someElement, offsetInPixels);
|
||||
$document.duScrollToElement(someElement, offsetInPixels, durationInMillis).then(this.onScrollCompleted);
|
||||
$document.duScrollToElement(someElement, offsetInPixels, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
|
||||
|
||||
$document.duScrollToElementAnimated(someElement).then(this.onScrollCompleted);
|
||||
$document.duScrollToElementAnimated(someElement, offsetInPixels).then(this.onScrollCompleted);
|
||||
$document.duScrollToElementAnimated(someElement, offsetInPixels, durationInMillis).then(this.onScrollCompleted);
|
||||
$document.duScrollToElementAnimated(someElement, offsetInPixels, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
|
||||
|
||||
$document.duScrollTop(positionFromTop);
|
||||
$document.duScrollTop(positionFromTop, durationInMillis).then(this.onScrollCompleted);
|
||||
$document.duScrollTop(positionFromTop, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
|
||||
|
||||
$document.duScrollTopAnimated(positionFromTop).then(this.onScrollCompleted);
|
||||
$document.duScrollTopAnimated(positionFromTop, durationInMillis).then(this.onScrollCompleted);
|
||||
$document.duScrollTopAnimated(positionFromTop, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
|
||||
|
||||
$document.duScrollLeft(positionFromLeft);
|
||||
$document.duScrollLeft(positionFromLeft, durationInMillis).then(this.onScrollCompleted);
|
||||
$document.duScrollLeft(positionFromLeft, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
|
||||
|
||||
$document.duScrollLeftAnimated(positionFromLeft).then(this.onScrollCompleted);
|
||||
$document.duScrollLeftAnimated(positionFromLeft, durationInMillis).then(this.onScrollCompleted);
|
||||
$document.duScrollLeftAnimated(positionFromLeft, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
|
||||
|
||||
var verticalPosition: number = $document.duScrollTop();
|
||||
var horixontalPosition: number = $document.duScrollLeft();
|
||||
}
|
||||
|
||||
private invertedEasingFn = (x: number): number => {
|
||||
return 1 - x;
|
||||
}
|
||||
|
||||
private onScrollCompleted = (): void => {
|
||||
console.log('Done scrolling');
|
||||
}
|
||||
}
|
||||
|
||||
angular.module('testApp', ['duScroll'])
|
||||
.controller('testController', TestController);
|
||||
}
|
||||
44
angular-scroll/angular-scroll.d.ts
vendored
Normal file
44
angular-scroll/angular-scroll.d.ts
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Type definitions for angular-scroll
|
||||
// Project: https://github.com/oblador/angular-scroll
|
||||
// Definitions by: Sam Herrmann <https://github.com/samherrmann>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module duScroll {
|
||||
|
||||
/**
|
||||
* Extends the angular.element object returned by the $document sercive with a few jQuery like functions.
|
||||
* see https://github.com/oblador/angular-scroll#angularelement-scroll-api
|
||||
*/
|
||||
interface IDocumentService extends ng.IDocumentService {
|
||||
|
||||
duScrollTo(left: number, top: number): void;
|
||||
duScrollTo(left: number, top: number, duration: number, easing?: Function): ng.IPromise<void>;
|
||||
|
||||
duScrollTo(element: ng.IAugmentedJQuery, offset?: number): void;
|
||||
duScrollTo(element: ng.IAugmentedJQuery, offset: number, duration: number, easing?: Function): ng.IPromise<void>;
|
||||
|
||||
duScrollToElement(element: ng.IAugmentedJQuery, offset?: number): void;
|
||||
duScrollToElement(element: ng.IAugmentedJQuery, offset: number, duration: number, easing?: Function): ng.IPromise<void>;
|
||||
|
||||
duScrollToElementAnimated(element: ng.IAugmentedJQuery, offset?: number): ng.IPromise<void>;
|
||||
duScrollToElementAnimated(element: ng.IAugmentedJQuery, offset: number, duration: number, easing?: Function): ng.IPromise<void>;
|
||||
|
||||
duScrollTop(top: number): void;
|
||||
duScrollTop(top: number, duration: number, easing?: Function): ng.IPromise<void>;
|
||||
|
||||
duScrollTopAnimated(top: number): ng.IPromise<void>;
|
||||
duScrollTopAnimated(top: number, duration: number, easing?: Function): ng.IPromise<void>;
|
||||
|
||||
duScrollLeft(left: number): void;
|
||||
duScrollLeft(left: number, duration: number, easing?: Function): ng.IPromise<void>;
|
||||
|
||||
duScrollLeftAnimated(left: number): ng.IPromise<void>;
|
||||
duScrollLeftAnimated(left: number, duration: number, easing?: Function): ng.IPromise<void>;
|
||||
|
||||
duScrollTop(): number;
|
||||
duScrollLeft(): number;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user