mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-30 11:14:27 +08:00
Merge branch 'master' of https://github.com/CaselIT/DefinitelyTyped
This commit is contained in:
@@ -20,6 +20,18 @@ class FormConfig {
|
||||
name: 'customInput',
|
||||
extends: 'input'
|
||||
});
|
||||
|
||||
formlyConfig.disableWarnings = true;
|
||||
formlyConfig.templateManipulators = undefined;
|
||||
|
||||
formlyConfig.extras.apiCheckInstance = null;
|
||||
formlyConfig.extras.defaultHideDirective = 'ng-if';
|
||||
formlyConfig.extras.disableNgModelAttrsManipulator = true;
|
||||
formlyConfig.extras.errorExistsAndShouldBeVisibleExpression = angular.noop;
|
||||
formlyConfig.extras.explicitAsync = true;
|
||||
formlyConfig.extras.fieldTransform = angular.noop;
|
||||
formlyConfig.extras.getFieldId = angular.noop;
|
||||
formlyConfig.extras.ngModelAttrsManipulatorPreferUnbound = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+23
-9
@@ -16,15 +16,15 @@ declare module 'angular-formly' {
|
||||
|
||||
declare module AngularFormly {
|
||||
|
||||
interface IFieldArray extends Array<IFieldConfigurationObject|IFieldGroup> {
|
||||
|
||||
interface IFieldArray extends Array<IFieldConfigurationObject | IFieldGroup> {
|
||||
|
||||
}
|
||||
|
||||
interface IFieldGroup {
|
||||
data?: Object;
|
||||
className?: string;
|
||||
elementAttributes?: string;
|
||||
fieldGroup: IFieldArray;
|
||||
fieldGroup?: IFieldArray;
|
||||
form?: Object;
|
||||
hide?: boolean;
|
||||
hideExpression?: string | IExpressionFunction;
|
||||
@@ -160,7 +160,7 @@ declare module AngularFormly {
|
||||
*/
|
||||
asyncValidators?: {
|
||||
[key: string]: string | IExpressionFunction | IValidator;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a great way to add custom behavior to a specific field. It is injectable with the $scope of the
|
||||
@@ -210,7 +210,7 @@ declare module AngularFormly {
|
||||
*/
|
||||
expressionProperties?: {
|
||||
[key: string]: string | IExpressionFunction | IValidator;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@@ -219,7 +219,7 @@ declare module AngularFormly {
|
||||
*
|
||||
* see http://docs.angular-formly.com/docs/field-configuration-object#hide-boolean
|
||||
*/
|
||||
hide?: boolean
|
||||
hide?: boolean;
|
||||
|
||||
|
||||
/**
|
||||
@@ -432,7 +432,7 @@ declare module AngularFormly {
|
||||
*/
|
||||
show?: boolean;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@@ -446,7 +446,7 @@ declare module AngularFormly {
|
||||
*/
|
||||
validators?: {
|
||||
[key: string]: string | IExpressionFunction | IValidator;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@@ -558,10 +558,24 @@ declare module AngularFormly {
|
||||
validateOptions?: Function;
|
||||
}
|
||||
|
||||
interface IFormlyConfigExtras {
|
||||
disableNgModelAttrsManipulator: boolean;
|
||||
apiCheckInstance: any;
|
||||
ngModelAttrsManipulatorPreferUnbound: boolean;
|
||||
removeChromeAutoComplete: boolean;
|
||||
defaultHideDirective: string;
|
||||
errorExistsAndShouldBeVisibleExpression: any;
|
||||
getFieldId: Function;
|
||||
fieldTransform: Function;
|
||||
explicitAsync: boolean;
|
||||
}
|
||||
|
||||
interface IFormlyConfig {
|
||||
disableWarnings: boolean;
|
||||
extras: IFormlyConfigExtras;
|
||||
setType(typeOptions: ITypeOptions): void;
|
||||
setWrapper(wrapperOptions: IWrapperOptions): void;
|
||||
|
||||
templateManipulators: ITemplateManipulators;
|
||||
}
|
||||
|
||||
interface ITemplateScopeOptions {
|
||||
|
||||
@@ -58,4 +58,8 @@ app.controller("Ctrl", ($scope:angular.IScope,
|
||||
growlMessages.destroyAllMessages(0);
|
||||
growlMessages.addMessage(messages[0]);
|
||||
growlMessages.deleteMessage(messages[1]);
|
||||
|
||||
var testMessage = growl.warning(message);
|
||||
testMessage.setText("Some other message");
|
||||
testMessage.destroy();
|
||||
});
|
||||
|
||||
+11
-1
@@ -39,6 +39,16 @@ declare module angular.growl {
|
||||
*/
|
||||
interface IGrowlMessage extends IGrowlMessageConfig {
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* Destroy the message.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Update the message body.
|
||||
* @param newText new message body
|
||||
*/
|
||||
setText(newText: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +233,7 @@ declare module angular.growl {
|
||||
* @param referenceId
|
||||
* @param limitMessages
|
||||
*/
|
||||
initDirective(referenceId: number, limitMessages: number): ng.IDirective;
|
||||
initDirective(referenceId: number, limitMessages: number): angular.IDirective;
|
||||
|
||||
/**
|
||||
* Get current messages
|
||||
|
||||
@@ -177,8 +177,13 @@ class UrlLocatorTestService implements IUrlLocatorTestService {
|
||||
if (this.$state.href("myState") === "/myState") {
|
||||
//
|
||||
}
|
||||
this.$state.get("myState");
|
||||
this.$state.get();
|
||||
this.$state.get("myState");
|
||||
this.$state.get("myState", "yourState");
|
||||
this.$state.get("myState", this.$state.current);
|
||||
this.$state.get(this.$state.current);
|
||||
this.$state.get(this.$state.current, "yourState");
|
||||
this.$state.get(this.$state.current, this.$state.current);
|
||||
this.$state.reload();
|
||||
|
||||
// http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state#properties
|
||||
|
||||
+4
-1
@@ -261,7 +261,10 @@ declare module angular.ui {
|
||||
is(state: IState, params?: {}): boolean;
|
||||
href(state: IState, params?: {}, options?: IHrefOptions): string;
|
||||
href(state: string, params?: {}, options?: IHrefOptions): string;
|
||||
get(state: string): IState;
|
||||
get(state: string, context?: string): IState;
|
||||
get(state: IState, context?: string): IState;
|
||||
get(state: string, context?: IState): IState;
|
||||
get(state: IState, context?: IState): IState;
|
||||
get(): IState[];
|
||||
/** A reference to the state's config object. However you passed it in. Useful for accessing custom data. */
|
||||
current: IState;
|
||||
|
||||
@@ -6,9 +6,8 @@ import express = require('express');
|
||||
import exphbs = require('express-handlebars');
|
||||
|
||||
var app = express();
|
||||
var hbs: Exphbs = exphbs.create({defaultLayout: 'main'});
|
||||
|
||||
app.engine('handlebars', hbs.engine);
|
||||
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
|
||||
app.set('view engine', 'handlebars');
|
||||
|
||||
app.listen(1337);
|
||||
|
||||
+7
-2
@@ -1,6 +1,6 @@
|
||||
// Type definitions for express-handlebars
|
||||
// Project: https://github.com/ericf/express-handlebars
|
||||
// Definitions by: Sam Saint-Pettersen <https://github.com/stpettersens>
|
||||
// Definitions by: Sam Saint-Pettersen <https://github.com/stpettersens>, Igor Dultsev <https://github.com/yhaskell>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts" />
|
||||
@@ -40,7 +40,12 @@ interface Exphbs {
|
||||
renderView(viewPath: string, optionsOrCallback: any, callback?: () => string): void;
|
||||
}
|
||||
|
||||
interface ExpressHandlebars {
|
||||
(options?: ExphbsOptions): Function;
|
||||
create (options?: ExphbsOptions): Exphbs;
|
||||
}
|
||||
|
||||
declare module "express-handlebars" {
|
||||
var exphbs: Exphbs;
|
||||
var exphbs: ExpressHandlebars;
|
||||
export = exphbs;
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -161,7 +161,7 @@ interface Entry {
|
||||
* A move of a file on top of an existing file must attempt to delete and replace that file.
|
||||
* A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.
|
||||
*/
|
||||
moveTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):string;
|
||||
moveTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void;
|
||||
|
||||
/**
|
||||
* Copy an entry to a different location on the file system. It is an error to try to:
|
||||
@@ -178,7 +178,7 @@ interface Entry {
|
||||
*
|
||||
* Directory copies are always recursive--that is, they copy all contents of the directory.
|
||||
*/
|
||||
copyTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):string;
|
||||
copyTo(parent:DirectoryEntry, newName?:string, successCallback?:EntryCallback, errorCallback?:ErrorCallback):void;
|
||||
|
||||
/**
|
||||
* Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific expiration; as it describes a location on disk, it should be valid at least as long as that location exists.
|
||||
|
||||
@@ -161,3 +161,27 @@ class MyTable4 extends React.Component<{}, MyTable4State> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Listen for events
|
||||
class MyTable5 extends React.Component<{}, {}> {
|
||||
render(): React.ReactElement<any> {
|
||||
return (
|
||||
<Table
|
||||
rowsCount={100}
|
||||
rowHeight={50}
|
||||
width={1000}
|
||||
height={500}
|
||||
onScrollStart={(x: number, y: number) => {}}
|
||||
onScrollEnd={(x: number, y: number) => {}}
|
||||
onContentHeightChange={(newHeight: number) => {}}
|
||||
onRowClick={(event: React.SyntheticEvent, rowIndex: number) => {}}
|
||||
onRowDoubleClick={(event: React.SyntheticEvent, rowIndex: number) => {}}
|
||||
onRowMouseDown={(event: React.SyntheticEvent, rowIndex: number) => {}}
|
||||
onRowMouseEnter={(event: React.SyntheticEvent, rowIndex: number) => {}}
|
||||
onRowMouseLeave={(event: React.SyntheticEvent, rowIndex: number) => {}}
|
||||
onColumnResizeEndCallback={(newColumnWidth: number, columnKey: string) => {}}>
|
||||
// add columns
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -187,13 +187,13 @@ declare module FixedDataTable {
|
||||
* Callback that is called when scrolling starts with
|
||||
* current horizontal and vertical scroll values.
|
||||
*/
|
||||
onScrollStart?: (horizontalScroll: number, verticalScroll: number) => void;
|
||||
onScrollStart?: (x: number, y: number) => void;
|
||||
|
||||
/**
|
||||
* Callback that is called when scrolling ends or stops with
|
||||
* new horizontal and vertical scroll values.
|
||||
*/
|
||||
onScrollEnd?: (horizontalScroll: number, verticalScroll: number) => void;
|
||||
onScrollEnd?: (x: number, y: number) => void;
|
||||
|
||||
/**
|
||||
* Callback that is called when rowHeightGetter returns a
|
||||
@@ -201,35 +201,35 @@ declare module FixedDataTable {
|
||||
* is necessary because initially table estimates heights
|
||||
* of some parts of the content.
|
||||
*/
|
||||
onContentHeightChange?: (height: number) => void;
|
||||
onContentHeightChange?: (newHeight: number) => void;
|
||||
|
||||
/**
|
||||
* Callback that is called when a row is clicked.
|
||||
*/
|
||||
onRowClick?: (index: number) => void;
|
||||
onRowClick?: (event: __React.SyntheticEvent, rowIndex: number) => void;
|
||||
|
||||
/**
|
||||
* Callback that is called when a row is double clicked.
|
||||
*/
|
||||
onRowDoubleClick?: (index: number) => void;
|
||||
onRowDoubleClick?: (event: __React.SyntheticEvent, rowIndex: number) => void;
|
||||
|
||||
/**
|
||||
* Callback that is called when a mouse-down event happens
|
||||
* on a row.
|
||||
*/
|
||||
onRowMouseDown?: (index: number) => void;
|
||||
onRowMouseDown?: (event: __React.SyntheticEvent, rowIndex: number) => void;
|
||||
|
||||
/**
|
||||
* Callback that is called when a mouse-enter event happens
|
||||
* on a row.
|
||||
*/
|
||||
onRowMouseEnter?: (index: number) => void;
|
||||
onRowMouseEnter?: (event: __React.SyntheticEvent, rowIndex: number) => void;
|
||||
|
||||
/**
|
||||
* Callback that is called when a mouse-leave event happens
|
||||
* on a row.
|
||||
*/
|
||||
onRowMouseLeave?: (index: number) => void;
|
||||
onRowMouseLeave?: (event: __React.SyntheticEvent, rowIndex: number) => void;
|
||||
|
||||
/**
|
||||
* Callback that is called when resizer has been released
|
||||
|
||||
@@ -1710,6 +1710,20 @@ function test_focusout() {
|
||||
});
|
||||
}
|
||||
|
||||
function test_easing() {
|
||||
const easing = jQuery.easing;
|
||||
|
||||
function test_easing_function( name: string, fn: JQueryEasingFunction ) {
|
||||
const step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error
|
||||
for( let i = 0; i <= 1; i += step ) {
|
||||
console.log( `$.easing.${name}(${i}): ${fn.call(easing, i)}` );
|
||||
}
|
||||
}
|
||||
|
||||
test_easing_function( "linear", easing.linear );
|
||||
test_easing_function( "swing", easing.swing );
|
||||
}
|
||||
|
||||
function test_fx() {
|
||||
jQuery.fx.interval = 100;
|
||||
$("input").click(function () {
|
||||
|
||||
Vendored
+13
@@ -607,6 +607,16 @@ interface JQueryAnimationOptions {
|
||||
specialEasing?: Object;
|
||||
}
|
||||
|
||||
interface JQueryEasingFunction {
|
||||
( percent: number ): number;
|
||||
}
|
||||
|
||||
interface JQueryEasingFunctions {
|
||||
[ name: string ]: JQueryEasingFunction;
|
||||
linear: JQueryEasingFunction;
|
||||
swing: JQueryEasingFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static members of jQuery (those on $ and jQuery themselves)
|
||||
*/
|
||||
@@ -889,6 +899,9 @@ interface JQueryStatic {
|
||||
/**
|
||||
* Effects
|
||||
*/
|
||||
|
||||
easing: JQueryEasingFunctions;
|
||||
|
||||
fx: {
|
||||
tick: () => void;
|
||||
/**
|
||||
|
||||
@@ -1819,3 +1819,45 @@ function test_widget() {
|
||||
$(".selector").jQuery.Widget("option", "disabled", true);
|
||||
$(".selector").jQuery.Widget("option", { disabled: true });
|
||||
}
|
||||
|
||||
function test_easing() {
|
||||
const easing = jQuery.easing;
|
||||
|
||||
function test_easing_function( name: string, fn: JQueryEasingFunction ) {
|
||||
const step = Math.pow( 2, -3 ); // use power of 2 to prevent floating point rounding error
|
||||
for( let i = 0; i <= 1; i += step ) {
|
||||
console.log( `$.easing.${name}(${i}): ${fn.call(easing, i)}` );
|
||||
}
|
||||
}
|
||||
|
||||
test_easing_function("easeInQuad", easing.easeInQuad);
|
||||
test_easing_function("easeOutQuad", easing.easeOutQuad);
|
||||
test_easing_function("easeInOutQuad", easing.easeInOutQuad);
|
||||
test_easing_function("easeInCubic", easing.easeInCubic);
|
||||
test_easing_function("easeOutCubic", easing.easeOutCubic);
|
||||
test_easing_function("easeInOutCubic", easing.easeInOutCubic);
|
||||
test_easing_function("easeInQuart", easing.easeInQuart);
|
||||
test_easing_function("easeOutQuart", easing.easeOutQuart);
|
||||
test_easing_function("easeInOutQuart", easing.easeInOutQuart);
|
||||
test_easing_function("easeInQuint", easing.easeInQuint);
|
||||
test_easing_function("easeOutQuint", easing.easeOutQuint);
|
||||
test_easing_function("easeInOutQuint", easing.easeInOutQuint);
|
||||
test_easing_function("easeInExpo", easing.easeInExpo);
|
||||
test_easing_function("easeOutExpo", easing.easeOutExpo);
|
||||
test_easing_function("easeInOutExpo", easing.easeInOutExpo);
|
||||
test_easing_function("easeInSine", easing.easeInSine);
|
||||
test_easing_function("easeOutSine", easing.easeOutSine);
|
||||
test_easing_function("easeInOutSine", easing.easeInOutSine);
|
||||
test_easing_function("easeInCirc", easing.easeInCirc);
|
||||
test_easing_function("easeOutCirc", easing.easeOutCirc);
|
||||
test_easing_function("easeInOutCirc", easing.easeInOutCirc);
|
||||
test_easing_function("easeInElastic", easing.easeInElastic);
|
||||
test_easing_function("easeOutElastic", easing.easeOutElastic);
|
||||
test_easing_function("easeInOutElastic", easing.easeInOutElastic);
|
||||
test_easing_function("easeInBack", easing.easeInBack);
|
||||
test_easing_function("easeOutBack", easing.easeOutBack);
|
||||
test_easing_function("easeInOutBack", easing.easeInOutBack);
|
||||
test_easing_function("easeInBounce", easing.easeInBounce);
|
||||
test_easing_function("easeOutBounce", easing.easeOutBounce);
|
||||
test_easing_function("easeInOutBounce", easing.easeInOutBounce);
|
||||
}
|
||||
|
||||
Vendored
+33
@@ -1805,3 +1805,36 @@ interface JQueryStatic {
|
||||
widget: JQueryUI.Widget;
|
||||
Widget: JQueryUI.Widget;
|
||||
}
|
||||
|
||||
interface JQueryEasingFunctions {
|
||||
easeInQuad: JQueryEasingFunction;
|
||||
easeOutQuad: JQueryEasingFunction;
|
||||
easeInOutQuad: JQueryEasingFunction;
|
||||
easeInCubic: JQueryEasingFunction;
|
||||
easeOutCubic: JQueryEasingFunction;
|
||||
easeInOutCubic: JQueryEasingFunction;
|
||||
easeInQuart: JQueryEasingFunction;
|
||||
easeOutQuart: JQueryEasingFunction;
|
||||
easeInOutQuart: JQueryEasingFunction;
|
||||
easeInQuint: JQueryEasingFunction;
|
||||
easeOutQuint: JQueryEasingFunction;
|
||||
easeInOutQuint: JQueryEasingFunction;
|
||||
easeInExpo: JQueryEasingFunction;
|
||||
easeOutExpo: JQueryEasingFunction;
|
||||
easeInOutExpo: JQueryEasingFunction;
|
||||
easeInSine: JQueryEasingFunction;
|
||||
easeOutSine: JQueryEasingFunction;
|
||||
easeInOutSine: JQueryEasingFunction;
|
||||
easeInCirc: JQueryEasingFunction;
|
||||
easeOutCirc: JQueryEasingFunction;
|
||||
easeInOutCirc: JQueryEasingFunction;
|
||||
easeInElastic: JQueryEasingFunction;
|
||||
easeOutElastic: JQueryEasingFunction;
|
||||
easeInOutElastic: JQueryEasingFunction;
|
||||
easeInBack: JQueryEasingFunction;
|
||||
easeOutBack: JQueryEasingFunction;
|
||||
easeInOutBack: JQueryEasingFunction;
|
||||
easeInBounce: JQueryEasingFunction;
|
||||
easeOutBounce: JQueryEasingFunction;
|
||||
easeInOutBounce: JQueryEasingFunction;
|
||||
}
|
||||
|
||||
+26
-12
@@ -7000,15 +7000,13 @@ module TestToArray {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let dictionary: _.Dictionary<TResult>;
|
||||
let numericDictionary: _.NumericDictionary<TResult>;
|
||||
|
||||
{
|
||||
let result: string[];
|
||||
|
||||
result = _.toArray<string>('');
|
||||
result = _.toArray('');
|
||||
|
||||
result = (function (a: string) {return _.toArray<IArguments, string>(arguments);})('');
|
||||
|
||||
result = _((function (a: string) {return arguments;})('')).toArray<string>().value();
|
||||
}
|
||||
|
||||
{
|
||||
@@ -7017,22 +7015,38 @@ module TestToArray {
|
||||
result = _.toArray<TResult>(array);
|
||||
result = _.toArray<TResult>(list);
|
||||
result = _.toArray<TResult>(dictionary);
|
||||
result = _.toArray<TResult>(numericDictionary);
|
||||
|
||||
result = _(array).toArray().value();
|
||||
result = _(list).toArray<TResult>().value();
|
||||
result = _(dictionary).toArray<TResult>().value();
|
||||
result = _.toArray(array);
|
||||
result = _.toArray(list);
|
||||
result = _.toArray(dictionary);
|
||||
result = _.toArray(numericDictionary);
|
||||
}
|
||||
|
||||
{
|
||||
let result: any[];
|
||||
|
||||
result = _.toArray();
|
||||
result = _.toArray<number>(42);
|
||||
result = _.toArray<boolean>(true);
|
||||
result = _.toArray(42);
|
||||
result = _.toArray(true);
|
||||
}
|
||||
|
||||
result = _('').toArray<string>().value();
|
||||
result = _(42).toArray<any>().value();
|
||||
result = _(true).toArray<any>().value();
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).toArray();
|
||||
result = _(list).toArray<TResult>();
|
||||
result = _(dictionary).toArray<TResult>();
|
||||
result = _(numericDictionary).toArray<TResult>();
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().toArray();
|
||||
result = _(list).chain().toArray<TResult>();
|
||||
result = _(dictionary).chain().toArray<TResult>();
|
||||
result = _(numericDictionary).chain().toArray<TResult>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+23
-12
@@ -10928,12 +10928,7 @@ declare module _ {
|
||||
* @param value The value to convert.
|
||||
* @return Returns the converted array.
|
||||
*/
|
||||
toArray(value: string): string[];
|
||||
|
||||
/**
|
||||
* @see _.toArray
|
||||
*/
|
||||
toArray<T>(value: List<T>|Dictionary<T>): T[];
|
||||
toArray<T>(value: List<T>|Dictionary<T>|NumericDictionary<T>): T[];
|
||||
|
||||
/**
|
||||
* @see _.toArray
|
||||
@@ -10943,12 +10938,7 @@ declare module _ {
|
||||
/**
|
||||
* @see _.toArray
|
||||
*/
|
||||
toArray<TValue>(value: TValue): any[];
|
||||
|
||||
/**
|
||||
* @see _.toArray
|
||||
*/
|
||||
toArray(value?: any): any[];
|
||||
toArray<TResult>(value?: any): TResult[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
@@ -10972,6 +10962,27 @@ declare module _ {
|
||||
toArray<TResult>(): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.toArray
|
||||
*/
|
||||
toArray<TResult>(): LoDashExplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.toArray
|
||||
*/
|
||||
toArray(): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.toArray
|
||||
*/
|
||||
toArray<TResult>(): LoDashExplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.toPlainObject
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,19 @@ function test() {
|
||||
makerjs.exporter.toDXF(model);
|
||||
makerjs.exporter.toOpenJsCad(model);
|
||||
makerjs.exporter.toSTL(model);
|
||||
makerjs.exporter.toSVG(model);
|
||||
makerjs.exporter.toSVG(model,
|
||||
{
|
||||
annotate: true,
|
||||
fontSize: '',
|
||||
origin: [],
|
||||
scale: 9.9,
|
||||
stroke: '',
|
||||
strokeWidth: '',
|
||||
svgAttrs: {},
|
||||
units: '',
|
||||
useSvgPathOnly: false,
|
||||
viewBox: false
|
||||
});
|
||||
makerjs.exporter.tryGetModelUnits(model);
|
||||
}
|
||||
|
||||
@@ -51,6 +63,7 @@ function test() {
|
||||
makerjs.kit.getParameterValues(null);
|
||||
(<MakerJs.IMetaParameter>{}).max;
|
||||
(<MakerJs.IKit>{}).metaParameters;
|
||||
(<MakerJs.IKit>{}).notes;
|
||||
}
|
||||
|
||||
function testMeasure() {
|
||||
@@ -83,6 +96,7 @@ function test() {
|
||||
makerjs.model.rotate(makerjs.model.scale(model, 6), 45, [0,0]);
|
||||
makerjs.model.scale(model, 7);
|
||||
makerjs.model.walkPaths(model, (modelContext: MakerJs.IModel, pathId: string, pathContext: MakerJs.IPath) => {});
|
||||
model.exporterOptions = { foo: 'bar' };
|
||||
}
|
||||
|
||||
function testModels(): MakerJs.IModel[] {
|
||||
|
||||
Vendored
+44
-6
@@ -345,6 +345,12 @@ declare module MakerJs {
|
||||
* Optional layer of this model.
|
||||
*/
|
||||
layer?: string;
|
||||
/**
|
||||
* Optional exporter options for this model.
|
||||
*/
|
||||
exporterOptions?: {
|
||||
[exporterName: string]: any;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Callback signature for model.walkPaths().
|
||||
@@ -412,6 +418,10 @@ declare module MakerJs {
|
||||
* Each element of the array corresponds to a parameter of the constructor, in order.
|
||||
*/
|
||||
metaParameters?: IMetaParameter[];
|
||||
/**
|
||||
* Information about this kit, in plain text or markdown format.
|
||||
*/
|
||||
notes?: string;
|
||||
}
|
||||
}
|
||||
declare module MakerJs.angle {
|
||||
@@ -1225,12 +1235,36 @@ declare module MakerJs.exporter {
|
||||
* Optional size of curve facets.
|
||||
*/
|
||||
facetSize?: number;
|
||||
/**
|
||||
* Optional override of function name, default is "main".
|
||||
*/
|
||||
functionName?: string;
|
||||
/**
|
||||
* Optional options applied to specific first-child models by model id.
|
||||
*/
|
||||
modelMap?: IOpenJsCadOptionsMap;
|
||||
}
|
||||
interface IOpenJsCadOptionsMap {
|
||||
[modelId: string]: IOpenJsCadOptions;
|
||||
}
|
||||
}
|
||||
declare module MakerJs.exporter {
|
||||
function toSVG(modelToExport: IModel, options?: ISVGRenderOptions): string;
|
||||
function toSVG(pathsToExport: IPath[], options?: ISVGRenderOptions): string;
|
||||
function toSVG(pathToExport: IPath, options?: ISVGRenderOptions): string;
|
||||
/**
|
||||
* Map of MakerJs unit system to SVG unit system
|
||||
*/
|
||||
interface svgUnitConversion {
|
||||
[unitType: string]: {
|
||||
svgUnitType: string;
|
||||
scaleConversion: number;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Map of MakerJs unit system to SVG unit system
|
||||
*/
|
||||
var svgUnit: svgUnitConversion;
|
||||
/**
|
||||
* SVG rendering options.
|
||||
*/
|
||||
@@ -1239,6 +1273,10 @@ declare module MakerJs.exporter {
|
||||
* Optional attributes to add to the root svg tag.
|
||||
*/
|
||||
svgAttrs?: IXmlTagAttrs;
|
||||
/**
|
||||
* SVG font size and font size units.
|
||||
*/
|
||||
fontSize?: string;
|
||||
/**
|
||||
* SVG stroke width of paths. This may have a unit type suffix, if not, the value will be in the same unit system as the units property.
|
||||
*/
|
||||
@@ -1246,27 +1284,27 @@ declare module MakerJs.exporter {
|
||||
/**
|
||||
* SVG color of the rendered paths.
|
||||
*/
|
||||
stroke: string;
|
||||
stroke?: string;
|
||||
/**
|
||||
* Scale of the SVG rendering.
|
||||
*/
|
||||
scale: number;
|
||||
scale?: number;
|
||||
/**
|
||||
* Indicate that the id's of paths should be rendered as SVG text elements.
|
||||
*/
|
||||
annotate: boolean;
|
||||
annotate?: boolean;
|
||||
/**
|
||||
* Rendered reference origin.
|
||||
*/
|
||||
origin: IPoint;
|
||||
origin?: IPoint;
|
||||
/**
|
||||
* Use SVG < path > elements instead of < line >, < circle > etc.
|
||||
*/
|
||||
useSvgPathOnly: boolean;
|
||||
useSvgPathOnly?: boolean;
|
||||
/**
|
||||
* Flag to use SVG viewbox.
|
||||
*/
|
||||
viewBox: boolean;
|
||||
viewBox?: boolean;
|
||||
}
|
||||
}
|
||||
declare module MakerJs.models {
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/// <reference path="../meteor/meteor.d.ts" />
|
||||
/// <reference path="../underscore/underscore.d.ts" />
|
||||
/// <reference path="meteor-roles.d.ts" />
|
||||
|
||||
/**
|
||||
* All code below was copied from the examples at https://github.com/alanning/meteor-roles/.
|
||||
* When necessary, code was added to make the examples work (e.g. declaring a variable
|
||||
* that was assumed to have been declared earlier)
|
||||
*/
|
||||
|
||||
var joesUserId = '1234';
|
||||
Roles.addUsersToRoles(joesUserId, ['manage-team','schedule-game'], 'manchester-united.com')
|
||||
Roles.addUsersToRoles(joesUserId, ['player','goalie'], 'real-madrid.com')
|
||||
|
||||
Roles.userIsInRole(joesUserId, 'manage-team', 'manchester-united.com') // => true
|
||||
Roles.userIsInRole(joesUserId, 'manage-team', 'real-madrid.com') // => false
|
||||
|
||||
Roles.addUsersToRoles(joesUserId, 'super-admin', Roles.GLOBAL_GROUP)
|
||||
|
||||
var bobsUserId = '1234';
|
||||
Roles.addUsersToRoles(bobsUserId, ['manage-team','schedule-game'])
|
||||
// internal representation - no groups
|
||||
// user.roles = ['manage-team','schedule-game']
|
||||
|
||||
Roles.addUsersToRoles(joesUserId, ['manage-team','schedule-game'], 'manchester-united.com')
|
||||
Roles.addUsersToRoles(joesUserId, ['player','goalie'], 'real-madrid.com')
|
||||
// internal representation - groups
|
||||
// NOTE: MongoDB uses periods to represent hierarchy so periods in group names
|
||||
// are converted to underscores.
|
||||
//
|
||||
// user.roles = {
|
||||
// 'manchester-united_com': ['manage-team','schedule-game'],
|
||||
// 'real-madrid_com': ['player','goalie']
|
||||
// }
|
||||
|
||||
Meteor.roles.find({});
|
||||
|
||||
|
||||
|
||||
var users = [
|
||||
{name:"Normal User",email:"normal@example.com",roles:[]},
|
||||
{name:"View-Secrets User",email:"view@example.com",roles:['view-secrets']},
|
||||
{name:"Manage-Users User",email:"manage@example.com",roles:['manage-users']},
|
||||
{name:"Admin User",email:"admin@example.com",roles:['admin']}
|
||||
];
|
||||
|
||||
_.each(users, function (user) {
|
||||
var id : string;
|
||||
|
||||
id = Accounts.createUser({
|
||||
email: user.email,
|
||||
password: "apple1",
|
||||
profile: { name: user.name }
|
||||
});
|
||||
|
||||
if (user.roles.length > 0) {
|
||||
// Need _id of existing user record so this call must come
|
||||
// after `Accounts.createUser` or `Accounts.onCreate`
|
||||
Roles.addUsersToRoles(id, user.roles, 'default-group');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
// server/publish.js
|
||||
|
||||
// Give authorized users access to sensitive data by group
|
||||
Meteor.publish('secrets', function (group : string) {
|
||||
if (Roles.userIsInRole(this.userId, ['view-secrets','admin'], group)) {
|
||||
|
||||
// return Meteor.secrets.find({group: group});
|
||||
|
||||
} else {
|
||||
|
||||
// user not authorized. do not publish secrets
|
||||
this.stop();
|
||||
return;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Accounts.validateNewUser(function (user : Meteor.User) {
|
||||
var loggedInUser = Meteor.user();
|
||||
|
||||
if (Roles.userIsInRole(loggedInUser, ['admin','manage-users'])) {
|
||||
// NOTE: This example assumes the user is not using groups.
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new Meteor.Error('403', "Not authorized to create new users");
|
||||
});
|
||||
|
||||
|
||||
// server/userMethods.js
|
||||
|
||||
Meteor.methods({
|
||||
/**
|
||||
* delete a user from a specific group
|
||||
*
|
||||
* @method deleteUser
|
||||
* @param {String} targetUserId _id of user to delete
|
||||
* @param {String} group Company to update permissions for
|
||||
*/
|
||||
deleteUser: function (targetUserId : string, group : string) {
|
||||
var loggedInUser = Meteor.user()
|
||||
|
||||
if (!loggedInUser ||
|
||||
!Roles.userIsInRole(loggedInUser,
|
||||
['manage-users', 'support-staff'], group)) {
|
||||
throw new Meteor.Error('403', "Access denied")
|
||||
}
|
||||
|
||||
// remove permissions for target group
|
||||
Roles.setUserRoles(targetUserId, [], group)
|
||||
|
||||
// do other actions required when a user is removed...
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
// server/userMethods.js
|
||||
|
||||
Meteor.methods({
|
||||
/**
|
||||
* update a user's permissions
|
||||
*
|
||||
* @param {Object} targetUserId Id of user to update
|
||||
* @param {Array} roles User's new permissions
|
||||
* @param {String} group Company to update permissions for
|
||||
*/
|
||||
updateRoles: function (targetUserId : string, roles : string[], group : string) {
|
||||
var loggedInUser = Meteor.user()
|
||||
|
||||
if (!loggedInUser ||
|
||||
!Roles.userIsInRole(loggedInUser,
|
||||
['manage-users', 'support-staff'], group)) {
|
||||
throw new Meteor.Error('403', "Access denied")
|
||||
}
|
||||
|
||||
Roles.setUserRoles(targetUserId, roles, group)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Vendored
+264
@@ -0,0 +1,264 @@
|
||||
// Type definitions for Meteor Roles 1.2.14
|
||||
// Project: https://github.com/alanning/meteor-roles/
|
||||
// Definitions by: Robbie Van Gorkom <https://github.com/vangorra>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../meteor/meteor.d.ts" />
|
||||
|
||||
/**
|
||||
* Provides functions related to user authorization. Compatible with built-in Meteor accounts packages.
|
||||
*
|
||||
* @module Roles
|
||||
*/
|
||||
declare module Roles {
|
||||
/**
|
||||
* Constant used to reference the special 'global' group that
|
||||
* can be used to apply blanket permissions across all groups.
|
||||
*
|
||||
* @example
|
||||
* Roles.addUsersToRoles(user, 'admin', Roles.GLOBAL_GROUP)
|
||||
* Roles.userIsInRole(user, 'admin') // => true
|
||||
*
|
||||
* Roles.setUserRoles(user, 'support-staff', Roles.GLOBAL_GROUP)
|
||||
* Roles.userIsInRole(user, 'support-staff') // => true
|
||||
* Roles.userIsInRole(user, 'admin') // => false
|
||||
*
|
||||
* @property GLOBAL_GROUP
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
*/
|
||||
var GLOBAL_GROUP : string;
|
||||
|
||||
/**
|
||||
* Subscription handle for the currently logged in user's permissions.
|
||||
*
|
||||
* NOTE: The corresponding publish function, `_roles`, depends on
|
||||
* `this.userId` so it will automatically re-run when the currently
|
||||
* logged-in user changes.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* `Roles.subscription.ready()` // => `true` if user roles have been loaded
|
||||
*
|
||||
* @property subscription
|
||||
* @type Object
|
||||
* @for Roles
|
||||
*/
|
||||
var subscription : Subscription;
|
||||
|
||||
/**
|
||||
* Add users to roles. Will create roles as needed.
|
||||
*
|
||||
* NOTE: Mixing grouped and non-grouped roles for the same user
|
||||
* is not supported and will throw an error.
|
||||
*
|
||||
* Makes 2 calls to database:
|
||||
* 1. retrieve list of all existing roles
|
||||
* 2. update users' roles
|
||||
*
|
||||
* @example
|
||||
* Roles.addUsersToRoles(userId, 'admin')
|
||||
* Roles.addUsersToRoles(userId, ['view-secrets'], 'example.com')
|
||||
* Roles.addUsersToRoles([user1, user2], ['user','editor'])
|
||||
* Roles.addUsersToRoles([user1, user2], ['glorious-admin', 'perform-action'], 'example.org')
|
||||
* Roles.addUsersToRoles(userId, 'admin', Roles.GLOBAL_GROUP)
|
||||
*
|
||||
* @method addUsersToRoles
|
||||
* @param {Array|String} users User id(s) or object(s) with an _id field
|
||||
* @param {Array|String} roles Name(s) of roles/permissions to add users to
|
||||
* @param {String} [group] Optional group name. If supplied, roles will be
|
||||
* specific to that group.
|
||||
* Group names can not start with '$' or numbers.
|
||||
* Periods in names '.' are automatically converted
|
||||
* to underscores.
|
||||
* The special group Roles.GLOBAL_GROUP provides
|
||||
* a convenient way to assign blanket roles/permissions
|
||||
* across all groups. The roles/permissions in the
|
||||
* Roles.GLOBAL_GROUP group will be automatically
|
||||
* included in checks for any group.
|
||||
*/
|
||||
function addUsersToRoles(
|
||||
user : string|string[]|Object|Object[],
|
||||
roles : string|string[],
|
||||
group? : string
|
||||
) : void;
|
||||
|
||||
/**
|
||||
* Create a new role. Whitespace will be trimmed.
|
||||
*
|
||||
* @method createRole
|
||||
* @param {String} role Name of role
|
||||
* @return {String} id of new role
|
||||
*/
|
||||
function createRole(role : string) : string;
|
||||
|
||||
/**
|
||||
* Delete an existing role. Will throw "Role in use" error if any users
|
||||
* are currently assigned to the target role.
|
||||
*
|
||||
* @method deleteRole
|
||||
* @param {String} role Name of role
|
||||
*/
|
||||
function deleteRole (role : string) : void;
|
||||
|
||||
/**
|
||||
* Retrieve set of all existing roles
|
||||
*
|
||||
* @method getAllRoles
|
||||
* @return {Cursor} cursor of existing roles
|
||||
*/
|
||||
function getAllRoles() : Mongo.Cursor<Role>;
|
||||
|
||||
/**
|
||||
* Retrieve users groups, if any
|
||||
*
|
||||
* @method getGroupsForUser
|
||||
* @param {String|Object} user User Id or actual user object
|
||||
* @param {String} [role] Optional name of roles to restrict groups to.
|
||||
*
|
||||
* @return {Array} Array of user's groups, unsorted. Roles.GLOBAL_GROUP will be omitted
|
||||
*/
|
||||
function getGroupsForUser(
|
||||
user : string|Object,
|
||||
role? : string
|
||||
) : string[];
|
||||
|
||||
/**
|
||||
* Retrieve users roles
|
||||
*
|
||||
* @method getRolesForUser
|
||||
* @param {String|Object} user User Id or actual user object
|
||||
* @param {String} [group] Optional name of group to restrict roles to.
|
||||
* User's Roles.GLOBAL_GROUP will also be included.
|
||||
* @return {Array} Array of user's roles, unsorted.
|
||||
*/
|
||||
function getRolesForUser(
|
||||
user : string|Object,
|
||||
group? : string
|
||||
) : Role[];
|
||||
|
||||
/**
|
||||
* Retrieve all users who are in target role.
|
||||
*
|
||||
* NOTE: This is an expensive query; it performs a full collection scan
|
||||
* on the users collection since there is no index set on the 'roles' field.
|
||||
* This is by design as most queries will specify an _id so the _id index is
|
||||
* used automatically.
|
||||
*
|
||||
* @method getUsersInRole
|
||||
* @param {Array|String} role Name of role/permission. If array, users
|
||||
* returned will have at least one of the roles
|
||||
* specified but need not have _all_ roles.
|
||||
* @param {String} [group] Optional name of group to restrict roles to.
|
||||
* User's Roles.GLOBAL_GROUP will also be checked.
|
||||
* @param {Object} [options] Optional options which are passed directly
|
||||
* through to `Meteor.users.find(query, options)`
|
||||
* @return {Cursor} cursor of users in role
|
||||
*/
|
||||
function getUsersInRole(
|
||||
role : string|string[],
|
||||
group? : string,
|
||||
options? : {
|
||||
sort?: Mongo.SortSpecifier;
|
||||
skip?: number;
|
||||
limit?: number;
|
||||
fields?: Mongo.FieldSpecifier;
|
||||
reactive?: boolean;
|
||||
transform?: Function;
|
||||
}) : Mongo.Cursor<Meteor.User>;
|
||||
|
||||
/**
|
||||
* Remove users from roles
|
||||
*
|
||||
* @example
|
||||
* Roles.removeUsersFromRoles(users.bob, 'admin')
|
||||
* Roles.removeUsersFromRoles([users.bob, users.joe], ['editor'])
|
||||
* Roles.removeUsersFromRoles([users.bob, users.joe], ['editor', 'user'])
|
||||
* Roles.removeUsersFromRoles(users.eve, ['user'], 'group1')
|
||||
*
|
||||
* @method removeUsersFromRoles
|
||||
* @param {Array|String} users User id(s) or object(s) with an _id field
|
||||
* @param {Array|String} roles Name(s) of roles to add users to
|
||||
* @param {String} [group] Optional. Group name. If supplied, only that
|
||||
* group will have roles removed.
|
||||
*/
|
||||
function removeUsersFromRoles(
|
||||
user : string|string[]|Object|Object[],
|
||||
roles? : string[],
|
||||
group? : string
|
||||
) : void;
|
||||
|
||||
/**
|
||||
* Set a users roles/permissions.
|
||||
*
|
||||
* @example
|
||||
* Roles.setUserRoles(userId, 'admin')
|
||||
* Roles.setUserRoles(userId, ['view-secrets'], 'example.com')
|
||||
* Roles.setUserRoles([user1, user2], ['user','editor'])
|
||||
* Roles.setUserRoles([user1, user2], ['glorious-admin', 'perform-action'], 'example.org')
|
||||
* Roles.setUserRoles(userId, 'admin', Roles.GLOBAL_GROUP)
|
||||
*
|
||||
* @method setUserRoles
|
||||
* @param {Array|String} users User id(s) or object(s) with an _id field
|
||||
* @param {Array|String} roles Name(s) of roles/permissions to add users to
|
||||
* @param {String} [group] Optional group name. If supplied, roles will be
|
||||
* specific to that group.
|
||||
* Group names can not start with '$'.
|
||||
* Periods in names '.' are automatically converted
|
||||
* to underscores.
|
||||
* The special group Roles.GLOBAL_GROUP provides
|
||||
* a convenient way to assign blanket roles/permissions
|
||||
* across all groups. The roles/permissions in the
|
||||
* Roles.GLOBAL_GROUP group will be automatically
|
||||
* included in checks for any group.
|
||||
*/
|
||||
function setUserRoles (
|
||||
user : string|string[]|Object|Object[],
|
||||
roles : string|string[],
|
||||
group? : string
|
||||
) : void;
|
||||
|
||||
/**
|
||||
* Check if user has specified permissions/roles
|
||||
*
|
||||
* @example
|
||||
* // non-group usage
|
||||
* Roles.userIsInRole(user, 'admin')
|
||||
* Roles.userIsInRole(user, ['admin','editor'])
|
||||
* Roles.userIsInRole(userId, 'admin')
|
||||
* Roles.userIsInRole(userId, ['admin','editor'])
|
||||
*
|
||||
* // per-group usage
|
||||
* Roles.userIsInRole(user, ['admin','editor'], 'group1')
|
||||
* Roles.userIsInRole(userId, ['admin','editor'], 'group1')
|
||||
* Roles.userIsInRole(userId, ['admin','editor'], Roles.GLOBAL_GROUP)
|
||||
*
|
||||
* // this format can also be used as short-hand for Roles.GLOBAL_GROUP
|
||||
* Roles.userIsInRole(user, 'admin')
|
||||
*
|
||||
* @method userIsInRole
|
||||
* @param {String|Object} user User Id or actual user object
|
||||
* @param {String|Array} roles Name of role/permission or Array of
|
||||
* roles/permissions to check against. If array,
|
||||
* will return true if user is in _any_ role.
|
||||
* @param {String} [group] Optional. Name of group. If supplied, limits check
|
||||
* to just that group.
|
||||
* The user's Roles.GLOBAL_GROUP will always be checked
|
||||
* whether group is specified or not.
|
||||
* @return {Boolean} true if user is in _any_ of the target roles
|
||||
*/
|
||||
function userIsInRole(
|
||||
user : string|string[]|Object|Object[],
|
||||
roles : string|string[],
|
||||
group? : string
|
||||
) : boolean;
|
||||
|
||||
interface Role {
|
||||
name : string;
|
||||
}
|
||||
} // module
|
||||
|
||||
declare module Meteor {
|
||||
var roles : Mongo.Collection<Roles.Role>;
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/// <reference path="ng-table.d.ts" />
|
||||
|
||||
interface IPerson {
|
||||
age: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
function printPerson(p: IPerson) {
|
||||
console.log('age: ' + p.age);
|
||||
console.log('name: ' + p.name);
|
||||
}
|
||||
|
||||
// NgTableParams signature tests
|
||||
namespace NgTableParamsTests {
|
||||
|
||||
let initialParams: NgTable.IParamValues<IPerson> = {
|
||||
filter: { name: 'Christian' },
|
||||
sorting: { age: 'asc' }
|
||||
};
|
||||
let settings: NgTable.ISettings<IPerson> = {
|
||||
dataset: [{ age: 1, name: 'Christian' }, { age: 2, name: 'Lee' }, { age: 40, name: 'Christian' }],
|
||||
filterOptions: {
|
||||
filterComparator: true,
|
||||
filterDelay: 100
|
||||
},
|
||||
counts: [10, 20, 50]
|
||||
};
|
||||
|
||||
export let tableParams = new NgTableParams(initialParams, settings);
|
||||
|
||||
// modify parameters
|
||||
tableParams.filter({ name: 'Lee' });
|
||||
tableParams.sorting('age', 'desc');
|
||||
tableParams.count(10);
|
||||
tableParams.group(item => (item.age * 10).toString());
|
||||
|
||||
// modify settings at runtime
|
||||
tableParams.settings({
|
||||
dataset: [{ age: 1, name: 'Brandon' }, { age: 2, name: 'Lee' }]
|
||||
});
|
||||
|
||||
tableParams.reload<IPerson>().then(rows => {
|
||||
rows.forEach(printPerson);
|
||||
});
|
||||
}
|
||||
|
||||
// Dynamic table column signature tests
|
||||
namespace ColumnTests {
|
||||
interface ICustomColFields {
|
||||
field: string;
|
||||
}
|
||||
let dynamicCols: (NgTable.Columns.IDynamicTableColDef & ICustomColFields)[];
|
||||
|
||||
dynamicCols.push({
|
||||
class: () => 'table',
|
||||
field: 'age',
|
||||
filter: { age: 'number' },
|
||||
sortable: true,
|
||||
show: true,
|
||||
title: 'Age of Person',
|
||||
titleAlt: 'Age'
|
||||
});
|
||||
}
|
||||
|
||||
namespace EventsTests {
|
||||
declare let events: NgTable.Events.IEventsChannel;
|
||||
|
||||
let unregistrationFuncs: NgTable.Events.IUnregistrationFunc[] = [];
|
||||
let x: NgTable.Events.IUnregistrationFunc;
|
||||
|
||||
x = events.onAfterCreated(params => {
|
||||
// do stuff
|
||||
});
|
||||
unregistrationFuncs.push(x);
|
||||
|
||||
x = events.onAfterReloadData((params, newData, oldData) => {
|
||||
newData.forEach(row => {
|
||||
if (isDataGroup(row)) {
|
||||
row.data.forEach(printPerson)
|
||||
} else {
|
||||
printPerson(row);
|
||||
}
|
||||
});
|
||||
}, NgTableParamsTests.tableParams);
|
||||
unregistrationFuncs.push(x);
|
||||
|
||||
x = events.onDatasetChanged((params, newDataset, oldDataset) => {
|
||||
if (newDataset != null) {
|
||||
newDataset.forEach(printPerson);
|
||||
}
|
||||
}, NgTableParamsTests.tableParams);
|
||||
unregistrationFuncs.push(x);
|
||||
|
||||
x = events.onPagesChanged((params, newButtons, oldButtons) => {
|
||||
newButtons.forEach(printPageButton);
|
||||
}, NgTableParamsTests.tableParams);
|
||||
unregistrationFuncs.push(x);
|
||||
|
||||
unregistrationFuncs.forEach(f => {
|
||||
f();
|
||||
});
|
||||
|
||||
|
||||
function printPageButton(btn: NgTable.IPageButton) {
|
||||
console.log('type: ' + btn.type);
|
||||
console.log('number: ' + btn['number']);
|
||||
console.log('current: ' + btn.current);
|
||||
console.log('active: ' + btn.active);
|
||||
}
|
||||
|
||||
function isDataGroup(row: any): row is NgTable.Data.IDataRowGroup<any> {
|
||||
return ('$hideRows' in row);
|
||||
}
|
||||
}
|
||||
Vendored
+838
@@ -0,0 +1,838 @@
|
||||
// Type definitions for ng-table
|
||||
// Project: https://github.com/esvit/ng-table
|
||||
// Definitions by: Christian Crowhurst <https://github.com/christianacca>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
/**
|
||||
* Parameters manager for an ngTable directive
|
||||
*/
|
||||
declare class NgTableParams<T> {
|
||||
/**
|
||||
* The page of data rows currently being displayed in the table
|
||||
*/
|
||||
data: T[];
|
||||
|
||||
constructor(baseParameters?: NgTable.IParamValues<T>, baseSettings?: NgTable.ISettings<T>)
|
||||
|
||||
/**
|
||||
* Returns the number of data rows per page
|
||||
*/
|
||||
count(): number
|
||||
/**
|
||||
* Sets the number of data rows per page.
|
||||
* Changes to count will cause `isDataReloadRequired` to return true
|
||||
*/
|
||||
count(count: number): NgTableParams<T>
|
||||
|
||||
/**
|
||||
* Returns the current filter values used to restrict the set of data rows.
|
||||
* @param trim supply true to return the current filter minus any insignificant values
|
||||
* (null, undefined and empty string)
|
||||
*/
|
||||
filter(trim?: boolean): NgTable.IFilterValues
|
||||
/**
|
||||
* Sets filter values to the `filter` supplied; any existing filter will be removed
|
||||
* Changes to filter will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
|
||||
*/
|
||||
filter(filter: NgTable.IFilterValues): NgTableParams<T>
|
||||
/**
|
||||
* Generate array of pages.
|
||||
* When no arguments supplied, the current parameter state of this `NgTableParams` instance will be used
|
||||
*/
|
||||
generatePagesArray(currentPage?: number, totalItems?: number, pageSize?: number, maxBlocks?: number): NgTable.IPageButton[]
|
||||
/**
|
||||
* Returns the current grouping used to group the data rows
|
||||
*/
|
||||
group(): NgTable.Grouping<T>
|
||||
/**
|
||||
* Sets grouping to the `field` and `sortDirection` supplied; any existing grouping will be removed
|
||||
* Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
|
||||
*/
|
||||
group(field: string, sortDirection?: string): NgTableParams<T>
|
||||
/**
|
||||
* Sets grouping to the `group` supplied; any existing grouping will be removed.
|
||||
* Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
|
||||
*/
|
||||
group(group: NgTable.Grouping<T>): NgTableParams<T>
|
||||
/**
|
||||
* Returns true when an attempt to `reload` the current `parameter` values have resulted in a failure.
|
||||
* This method will continue to return true until the `reload` is successfully called or when the
|
||||
* `parameter` values have changed
|
||||
*/
|
||||
hasErrorState(): boolean
|
||||
/**
|
||||
* Returns true if `filter` has significant filter value(s) (any value except null, undefined, or empty string),
|
||||
* otherwise false
|
||||
*/
|
||||
hasFilter(): boolean
|
||||
/**
|
||||
* Return true when a change to `filters` require the `reload` method
|
||||
* to be run so as to ensure the data presented to the user reflects these filters
|
||||
*/
|
||||
hasFilterChanges(): boolean
|
||||
/**
|
||||
* Returns true when at least one group has been set
|
||||
*/
|
||||
hasGroup(): boolean
|
||||
/**
|
||||
* Returns true when the `group` and when supplied, the `sortDirection` matches an existing group
|
||||
*/
|
||||
hasGroup(group: string | NgTable.IGroupingFunc<T>, sortDirection?: string): boolean
|
||||
/**
|
||||
* Return true when a change to this instance should require the `reload` method
|
||||
* to be run so as to ensure the data rows presented to the user reflects the current state.
|
||||
*
|
||||
* Note that this method will return false when the `reload` method has run but fails. In this case
|
||||
* `hasErrorState` will return true.
|
||||
*
|
||||
* The built-in `ngTable` directives will watch for when this function returns true and will then call
|
||||
* the `reload` method to load its data rows
|
||||
*/
|
||||
isDataReloadRequired(): boolean
|
||||
/**
|
||||
* Returns sorting values in a format that can be consumed by the angular `$orderBy` filter service
|
||||
*/
|
||||
orderBy(): string[]
|
||||
/**
|
||||
* Trigger a reload of the data rows
|
||||
*/
|
||||
reload<TResult extends NgTable.Data.DataResult<T>>(): ng.IPromise<TResult[]>
|
||||
/**
|
||||
* Returns the settings for the table.
|
||||
*/
|
||||
settings(): NgTable.ISettings<T>
|
||||
/**
|
||||
* Sets the settings for the table; new setting values will be merged with the existing settings.
|
||||
* Supplying a new `dataset` will cause `isDataReloadRequired` to return true and the `ngTableEventsChannel`
|
||||
* to fire its `datasetChanged` event
|
||||
*/
|
||||
settings(newSettings: NgTable.ISettings<T>): NgTableParams<T>
|
||||
/**
|
||||
* Returns the current sorting used to order the data rows.
|
||||
* Changes to sorting will cause `isDataReloadRequired` to return true
|
||||
*/
|
||||
sorting(): NgTable.ISortingValues
|
||||
/**
|
||||
* Sets sorting values to the `sorting` supplied; any existing sorting will be removed.
|
||||
* Changes to sorting will cause `isDataReloadRequired` to return true
|
||||
*/
|
||||
sorting(sorting: NgTable.ISortingValues): NgTableParams<T>
|
||||
/**
|
||||
* Sets sorting to the `field` and `direction` supplied; any existing sorting will be removed
|
||||
*/
|
||||
sorting(field: string, direction: string): NgTableParams<T>
|
||||
/**
|
||||
* Returns the index of the current "slice" of data rows
|
||||
*/
|
||||
page(): number
|
||||
/**
|
||||
* Sets the index of the current "slice" of data rows. The index starts at 1.
|
||||
* Changing the page number will cause `isDataReloadRequired` to return true
|
||||
*/
|
||||
page(page: number): NgTableParams<T>
|
||||
/**
|
||||
* Returns the count of the data rows that match the current `filter`
|
||||
*/
|
||||
total(): number
|
||||
/**
|
||||
* Sets `settings().total` to the value supplied.
|
||||
* Typically you will need to set a `total` in the body of any custom `getData` function
|
||||
* you supply as a setting value to this instance.
|
||||
* @example
|
||||
* var tp = new NgTableParams({}, { getData: customGetData })
|
||||
* function customGetData(params) {
|
||||
* var queryResult = /* code to fetch current data rows and total *\/
|
||||
* params.total(queryResult.total);
|
||||
* return queryResult.dataRowsPage;
|
||||
* }
|
||||
*/
|
||||
total(total: number): NgTableParams<T>
|
||||
/**
|
||||
* Returns the current parameter values uri-encoded. Set `asString` to
|
||||
* true for the parameters to be returned as an array of strings of the form 'paramName=value'
|
||||
* otherwise parameters returned as a key-value object
|
||||
*/
|
||||
url(asString?: boolean): { [name: string]: string } | string[]
|
||||
}
|
||||
|
||||
declare namespace NgTable {
|
||||
|
||||
interface IDataSettings {
|
||||
applyPaging?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* An angular value object that allow for overriding of the initial default values used when constructing
|
||||
* an instance of `NgTableParams`
|
||||
*/
|
||||
interface IDefaults {
|
||||
params?: IParamValues<any>;
|
||||
settings?: ISettings<any>
|
||||
}
|
||||
|
||||
/**
|
||||
* Map of the names of fields declared on a data row and the corrosponding filter value
|
||||
*/
|
||||
interface IFilterValues { [name: string]: any }
|
||||
|
||||
/**
|
||||
* Map of the names of fields on a data row and the corrosponding sort direction;
|
||||
* Set the value of a key to undefined to let value of `ISettings.defaultSort` apply
|
||||
*/
|
||||
interface ISortingValues { [name: string]: string }
|
||||
|
||||
type Grouping<T> = IGroupValues | IGroupingFunc<T>;
|
||||
|
||||
/**
|
||||
* Map of the names of fields on a data row and the corrosponding sort direction
|
||||
*/
|
||||
interface IGroupValues { [name: string]: string }
|
||||
|
||||
/**
|
||||
* Signature of a function that should return the name of the group
|
||||
* that the `item` should be placed within
|
||||
*/
|
||||
interface IGroupingFunc<T> {
|
||||
(item: T): string;
|
||||
/**
|
||||
* 'asc' or 'desc'; leave undefined to let the value of `ISettings.groupOptions.defaultSort` apply
|
||||
*/
|
||||
sortDirection?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The runtime values for `NgTableParams` that determine the set of data rows and
|
||||
* how they are to be displayed in a table
|
||||
*/
|
||||
interface IParamValues<T> {
|
||||
/**
|
||||
* The index of the "slice" of data rows, starting at 1, to be displayed by the table.
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* The number of data rows per page
|
||||
*/
|
||||
count?: number;
|
||||
/**
|
||||
* The filter that should be applied to restrict the set of data rows
|
||||
*/
|
||||
filter?: IFilterValues;
|
||||
/**
|
||||
* The sort order that should be applied to the data rows.
|
||||
*/
|
||||
sorting?: ISortingValues;
|
||||
/**
|
||||
* The grouping that should be applied to the data rows
|
||||
*/
|
||||
group?: string | Grouping<T>;
|
||||
}
|
||||
|
||||
|
||||
type FilterComparator<T> = boolean | IFilterComparatorFunc<T>;
|
||||
|
||||
interface IFilterComparatorFunc<T> {
|
||||
(actual: T, expected: T): boolean;
|
||||
}
|
||||
|
||||
interface IFilterFunc<T> {
|
||||
(data: T[], filter: IFilterValues, filterComparator: FilterComparator<T>): T[]
|
||||
}
|
||||
|
||||
|
||||
interface IFilterSettings<T> {
|
||||
/**
|
||||
* Use this to determine how items are matched against the filter values.
|
||||
* This setting is identical to the `comparator` parameter supported by the angular
|
||||
* `$filter` filter service
|
||||
*
|
||||
* Defaults to `undefined` which will result in a case insensitive susbstring match when
|
||||
* `IDefaultGetData` service is supplying the implementation for the
|
||||
* `ISettings.getData` function
|
||||
*/
|
||||
filterComparator?: FilterComparator<T>;
|
||||
/**
|
||||
* A duration to wait for the user to stop typing before applying the filter.
|
||||
* - Defaults to 0 for small managed inmemory arrays ie where a `ISettings.dataset` argument is
|
||||
* supplied to `NgTableParams.settings`.
|
||||
* - Defaults to 500 milliseconds otherwise.
|
||||
*/
|
||||
filterDelay?: number;
|
||||
/**
|
||||
* The number of elements up to which a managed inmemory array is considered small. Defaults to 10000.
|
||||
*/
|
||||
filterDelayThreshold?: number;
|
||||
/**
|
||||
* Overrides `IDefaultGetDataProvider.filterFilterName`.
|
||||
* The value supplied should be the name of the angular `$filter` service that will be selected to perform
|
||||
* the actual filter logic.
|
||||
* Defaults to 'filter'.
|
||||
*/
|
||||
filterFilterName?: string;
|
||||
/**
|
||||
* Tells `IDefaultGetData` to use this function supplied to perform the filtering instead of selecting an angular $filter.
|
||||
*/
|
||||
filterFn?: IFilterFunc<T>;
|
||||
/**
|
||||
* The layout to use when multiple html templates are to rendered in a single table header column.
|
||||
* Available values:
|
||||
* - stack (the default)
|
||||
* - horizontal
|
||||
*/
|
||||
filterLayout?: string
|
||||
}
|
||||
|
||||
interface IGroupSettings {
|
||||
/**
|
||||
* The default sort direction that will be used whenever a group is supplied that
|
||||
* does not define its own sort direction
|
||||
*/
|
||||
defaultSort?: string;
|
||||
/**
|
||||
* Determines whether groups should be displayed expanded to show their items. Defaults to true
|
||||
*/
|
||||
isExpanded?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Definition of the buttons rendered by the data row pager directive
|
||||
*/
|
||||
interface IPageButton {
|
||||
type: string;
|
||||
number?: number;
|
||||
active: boolean;
|
||||
current?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration settings for `NgTableParams`
|
||||
*/
|
||||
interface ISettings<T> {
|
||||
/**
|
||||
* Returns true whenever a call to `getData` is in progress
|
||||
*/
|
||||
$loading?: boolean;
|
||||
/**
|
||||
* An array that contains all the data rows that NgTable should manage.
|
||||
* The `gateData` function will be used to manage the data rows
|
||||
* that ultimately will be displayed.
|
||||
*/
|
||||
dataset?: T[];
|
||||
dataOptions?: {};
|
||||
/**
|
||||
* The total number of data rows before paging has been applied.
|
||||
* Typically you will not need to supply this yourself
|
||||
*/
|
||||
total?: number;
|
||||
/**
|
||||
* The default sort direction that will be used whenever a sorting is supplied that
|
||||
* does not define its own sort direction
|
||||
*/
|
||||
defaultSort?: string;
|
||||
filterOptions?: IFilterSettings<T>;
|
||||
groupOptions?: IGroupSettings;
|
||||
/**
|
||||
* The page size buttons that should be displayed. Each value defined in the array
|
||||
* determines the possible values that can be supplied to `NgTableParams.page()`
|
||||
*/
|
||||
counts?: number[];
|
||||
/**
|
||||
* The collection of interceptors that should apply to the results of a call to
|
||||
* the `getData` function before the data rows are displayed in the table
|
||||
*/
|
||||
interceptors?: IInterceptor<T>[];
|
||||
/**
|
||||
* Configuration for the template that will display the page size buttons
|
||||
*/
|
||||
paginationMaxBlocks?: number;
|
||||
/**
|
||||
* Configuration for the template that will display the page size buttons
|
||||
*/
|
||||
paginationMinBlocks?: number;
|
||||
/**
|
||||
* The html tag that will be used to display the sorting indicator in the table header
|
||||
*/
|
||||
sortingIndicator?: string;
|
||||
/**
|
||||
* The function that will be used fetch data rows. Leave undefined to let the `IDefaultGetData`
|
||||
* service provide a default implementation that will work with the `dataset` array you supply.
|
||||
*
|
||||
* Typically you will supply a custom function when you need to execute filtering, paging and sorting
|
||||
* on the server
|
||||
*/
|
||||
getData?: Data.IGetDataFunc<T> | Data.IInterceptableGetDataFunc<T>;
|
||||
/**
|
||||
* The function that will be used group data rows according to the groupings returned by `NgTableParams.group()`
|
||||
*/
|
||||
getGroups?: Data.IGetGroupFunc<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration values that determine the behaviour of the `ngTableFilterConfig` service
|
||||
*/
|
||||
interface IFilterConfigValues {
|
||||
/**
|
||||
* The default base url to use when deriving the url for a filter template given just an alias name
|
||||
* Defaults to 'ng-table/filters/'
|
||||
*/
|
||||
defaultBaseUrl?: string;
|
||||
/**
|
||||
* The extension to use when deriving the url of a filter template when given just an alias name
|
||||
*/
|
||||
defaultExt?: string;
|
||||
/**
|
||||
* A map of alias names and their corrosponding urls. A lookup against this map will be used
|
||||
* to find the url matching an alias name.
|
||||
* If no match is found then a url will be derived using the following pattern `${defaultBaseUrl}${aliasName}.${defaultExt}`
|
||||
*/
|
||||
aliasUrls?: { [name: string]: string };
|
||||
}
|
||||
|
||||
/**
|
||||
* The angular provider used to configure the behaviour of the `ngTableFilterConfig` service
|
||||
*/
|
||||
interface IFilterConfigProvider {
|
||||
$get: IFilterConfig;
|
||||
/**
|
||||
* Reset back to factory defaults the config values that `ngTableFilterConfig` service will use
|
||||
*/
|
||||
resetConfigs(): void;
|
||||
/**
|
||||
* Set the config values used by `ngTableFilterConfig` service
|
||||
*/
|
||||
setConfig(customConfig: IFilterConfigValues): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A key value-pair map where the key is the name of a field in a data row and the value is the definition
|
||||
* for the template used to render a filter cell in the header of a html table.
|
||||
* Where the value is supplied as a string this should either be url to a html template or an alias to a url registered
|
||||
* using the `ngTableFilterConfigProvider`
|
||||
* @example
|
||||
* vm.ageFilter = { "age": "number" }
|
||||
* @example
|
||||
* vm.ageFilter = { "age": "my/custom/ageTemplate.html" }
|
||||
* @example
|
||||
* vm.ageFilter = { "age": { id: "number", placeholder: "Age of person"} }
|
||||
*/
|
||||
interface IFilterTemplateDefMap {
|
||||
[name: string]: string | IFilterTemplateDef
|
||||
}
|
||||
|
||||
/**
|
||||
* A fully qualified template definition for a single filter
|
||||
*/
|
||||
interface IFilterTemplateDef {
|
||||
/**
|
||||
* A url to a html template of an alias to a url registered using the `ngTableFilterConfigProvider`
|
||||
*/
|
||||
id: string,
|
||||
/**
|
||||
* The text that should be rendered as a prompt to assist the user when entering a filter value
|
||||
*/
|
||||
placeholder: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Exposes configuration values and methods used to return the location of the html
|
||||
* templates used to render the filter row of an ng-table directive
|
||||
*/
|
||||
interface IFilterConfig {
|
||||
/**
|
||||
* Readonly copy of the final values used to configure the service.
|
||||
*/
|
||||
config: IFilterConfigValues,
|
||||
/**
|
||||
* Return the url of the html filter template for the supplied definition and key.
|
||||
* For more information see the documentation for `IFilterTemplateMap`
|
||||
*/
|
||||
getTemplateUrl(filterDef: string | IFilterTemplateDef, filterKey?: string): string,
|
||||
/**
|
||||
* Return the url of the html filter template registered with the alias supplied
|
||||
*/
|
||||
getUrlForAlias(aliasName: string, filterKey?: string): string
|
||||
}
|
||||
|
||||
interface InternalTableParams<T> extends NgTableParams<T> {
|
||||
isNullInstance: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* A custom object that can be registered with an NgTableParams instance that can be used
|
||||
* to post-process the results (and failures) returned by its `getData` function
|
||||
*/
|
||||
interface IInterceptor<T> {
|
||||
response?: <TData>(data: TData, params: NgTableParams<T>) => TData;
|
||||
responseError?: (reason: any, params: NgTableParams<T>) => any;
|
||||
}
|
||||
|
||||
type SelectData = ISelectOption[] | ISelectDataFunc
|
||||
|
||||
interface ISelectOption {
|
||||
id: string | number;
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface ISelectDataFunc {
|
||||
(): ISelectOption[] | ng.IPromise<ISelectOption[]>
|
||||
}
|
||||
|
||||
/**
|
||||
* Definition of the constructor function that will construct new instances of `NgTableParams`.
|
||||
* On construction of `NgTableParams` the `ngTableEventsChannel` will fire its `afterCreated` event.
|
||||
*/
|
||||
interface ITableParamsConstructor<T> {
|
||||
new (baseParameters?: IParamValues<T>, baseSettings?: ISettings<T>): NgTableParams<T>
|
||||
}
|
||||
|
||||
|
||||
namespace Data {
|
||||
|
||||
type DataResult<T> = T | IDataRowGroup<T>;
|
||||
|
||||
interface IDataRowGroup<T> {
|
||||
data: T[];
|
||||
$hideRows: boolean;
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A default implementation of the getData function that will apply the `filter`, `orderBy` and
|
||||
* paging values from the `NgTableParams` instance supplied to the data array supplied.
|
||||
*
|
||||
* A call to this function will:
|
||||
* - return the resulting array
|
||||
* - assign the total item count after filtering to the `total` of the `NgTableParams` instance supplied
|
||||
*/
|
||||
interface IDefaultGetData<T> {
|
||||
(data: T[], params: NgTableParams<T>): T[];
|
||||
/**
|
||||
* Convenience function that this service will use to apply paging to the data rows.
|
||||
*
|
||||
* Returns a slice of rows from the `data` array supplied and sets the `NgTableParams.total()`
|
||||
* on the `params` instance supplied to `data.length`
|
||||
*/
|
||||
applyPaging(data: T[], params: NgTableParams<T>): T[],
|
||||
/**
|
||||
* Returns a reference to the function that this service will use to filter data rows
|
||||
*/
|
||||
getFilterFn(params: NgTableParams<T>): IFilterFunc<T>,
|
||||
/**
|
||||
* Returns a reference to the function that this service will use to sort data rows
|
||||
*/
|
||||
getOrderByFn(params?: NgTableParams<T>): void
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows for the configuration of the ngTableDefaultGetData service.
|
||||
*/
|
||||
interface IDefaultGetDataProvider {
|
||||
$get<T>(): IDefaultGetData<T>;
|
||||
/**
|
||||
* The name of a angular filter that knows how to apply the values returned by
|
||||
* `NgTableParams.filter()` to restrict an array of data.
|
||||
* (defaults to the angular `filter` filter service)
|
||||
*/
|
||||
filterFilterName: string,
|
||||
/**
|
||||
* The name of a angular filter that knows how to apply the values returned by
|
||||
* `NgTableParams.orderBy()` to sort an array of data.
|
||||
* (defaults to the angular `orderBy` filter service)
|
||||
*/
|
||||
sortingFilterName: string
|
||||
}
|
||||
|
||||
interface IGetDataBcShimFunc<T> {
|
||||
(originalFunc: ILegacyGetDataFunc<T>): { (params: NgTableParams<T>): ng.IPromise<T[]> }
|
||||
}
|
||||
|
||||
/**
|
||||
* Signature of a function that will called whenever NgTable requires to load data rows
|
||||
* into the table.
|
||||
* `params` is the table requesting the data rows
|
||||
*/
|
||||
interface IGetDataFunc<T> {
|
||||
(params: NgTableParams<T>): T[] | ng.IPromise<T[]>;
|
||||
}
|
||||
|
||||
interface IGetGroupFunc<T> {
|
||||
(params: NgTableParams<T>): { [name: string]: IDataRowGroup<T>[] }
|
||||
}
|
||||
|
||||
/**
|
||||
* Variation of the `IGetDataFunc` function signature that allows for flexibility for
|
||||
* the shape of the return value.
|
||||
* Typcially you will use this function signature when you want to configure `NgTableParams` with
|
||||
* interceptors that will return the final data rows array.
|
||||
*/
|
||||
interface IInterceptableGetDataFunc<T> {
|
||||
<TResult>(params: NgTableParams<T>): TResult;
|
||||
}
|
||||
|
||||
interface ILegacyGetDataFunc<T> {
|
||||
($defer: ng.IDeferred<T[]>, params: NgTableParams<T>): void
|
||||
}
|
||||
}
|
||||
|
||||
namespace Events {
|
||||
interface IEventSelectorFunc {
|
||||
(publisher: NgTableParams<any>): boolean
|
||||
}
|
||||
|
||||
type EventSelector<T> = NgTableParams<T> | IEventSelectorFunc
|
||||
|
||||
interface IDatasetChangedListener<T> {
|
||||
(publisher: NgTableParams<T>, newDataset: T[], oldDataset: T[]): any
|
||||
}
|
||||
interface IAfterCreatedListener {
|
||||
(publisher: NgTableParams<any>): any
|
||||
}
|
||||
interface IAfterReloadDataListener<T> {
|
||||
(publisher: NgTableParams<T>, newData: NgTable.Data.DataResult<T>[], oldData: NgTable.Data.DataResult<T>[]): any
|
||||
}
|
||||
interface IPagesChangedListener {
|
||||
(publisher: NgTableParams<any>, newPages: NgTable.IPageButton[], oldPages: NgTable.IPageButton[]): any
|
||||
}
|
||||
|
||||
interface IUnregistrationFunc {
|
||||
(): void
|
||||
}
|
||||
|
||||
interface IEventsChannel {
|
||||
/**
|
||||
* Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed.
|
||||
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
|
||||
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
|
||||
*
|
||||
* @param listener the function that will be called when the event fires
|
||||
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
|
||||
* @param eventFilter a predicate function that should return true to receive the event
|
||||
* @return a unregistration function that when called will unregister the `listener`
|
||||
*/
|
||||
onAfterCreated(listener: Events.IAfterCreatedListener, scope: ng.IScope, eventFilter?: Events.IEventSelectorFunc): IUnregistrationFunc;
|
||||
/**
|
||||
* Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed.
|
||||
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
|
||||
*
|
||||
* @param listener the function that will be called when the event fires
|
||||
* @param eventFilter a predicate function that should return true to receive the event
|
||||
* @return a unregistration function that when called will unregister the `listener`
|
||||
*/
|
||||
onAfterCreated(listener: Events.IAfterCreatedListener, eventFilter?: Events.IEventSelectorFunc): IUnregistrationFunc;
|
||||
/**
|
||||
* Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed
|
||||
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
|
||||
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
|
||||
*
|
||||
* @param listener the function that will be called when the event fires
|
||||
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
|
||||
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
|
||||
* @return a unregistration function that when called will unregister the `listener`
|
||||
*/
|
||||
onAfterReloadData<T>(listener: Events.IAfterReloadDataListener<T>, scope: ng.IScope, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
|
||||
/**
|
||||
* Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed
|
||||
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
|
||||
*
|
||||
* @param listener the function that will be called when the event fires
|
||||
* @param eventFilter a predicate function that should return true to receive the event
|
||||
* @return a unregistration function that when called will unregister the `listener`
|
||||
*/
|
||||
onAfterReloadData<T>(listener: Events.IAfterReloadDataListener<T>, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
|
||||
|
||||
/**
|
||||
* Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance.
|
||||
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
|
||||
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
|
||||
*
|
||||
* @param listener the function that will be called when the event fires
|
||||
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
|
||||
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
|
||||
* @return a unregistration function that when called will unregister the `listener`
|
||||
*/
|
||||
onDatasetChanged<T>(listener: Events.IDatasetChangedListener<T>, scope: ng.IScope, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
|
||||
/**
|
||||
* Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance.
|
||||
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
|
||||
*
|
||||
* @param listener the function that will be called when the event fires
|
||||
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
|
||||
* @return a unregistration function that when called will unregister the `listener`
|
||||
*/
|
||||
onDatasetChanged<T>(listener: Events.IDatasetChangedListener<T>, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
|
||||
|
||||
/**
|
||||
* Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change
|
||||
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
|
||||
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
|
||||
*
|
||||
* @param listener the function that will be called when the event fires
|
||||
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
|
||||
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
|
||||
* @return a unregistration function that when called will unregister the `listener`
|
||||
*/
|
||||
onPagesChanged<T>(listener: Events.IPagesChangedListener, scope: ng.IScope, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
|
||||
/**
|
||||
* Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change
|
||||
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
|
||||
*
|
||||
* @param listener the function that will be called when the event fires
|
||||
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
|
||||
* @return a unregistration function that when called will unregister the `listener`
|
||||
*/
|
||||
onPagesChanged<T>(listener: Events.IPagesChangedListener, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
|
||||
|
||||
publishAfterCreated<T>(publisher: NgTableParams<T>): void;
|
||||
publishAfterReloadData<T>(publisher: NgTableParams<T>, newData: T[], oldData: T[]): void;
|
||||
publishDatasetChanged<T>(publisher: NgTableParams<T>, newDataset: T[], oldDataset: T[]): void;
|
||||
publishPagesChanged<T>(publisher: NgTableParams<T>, newPages: NgTable.IPageButton[], oldPages: NgTable.IPageButton[]): void;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Columns {
|
||||
|
||||
type ColumnFieldContext = ng.IScope & {
|
||||
$column: IColumnDef;
|
||||
$columns: IColumnDef[];
|
||||
}
|
||||
|
||||
interface IColumnField<T> {
|
||||
(context?: ColumnFieldContext): T;
|
||||
assign($scope: ng.IScope, value: T): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The definition of the column within a ngTable.
|
||||
* When using `ng-table` directive a column definition will be parsed from each `td` tag found in the
|
||||
* `tr` data row tag.
|
||||
*
|
||||
* @example
|
||||
* <tr>
|
||||
* <td data-title="'Name of User'" filter="{ username: 'text'}" sortable="'username'" />
|
||||
* <td data-title="'Age of User'" filter="{ age: 'number'}" sortable="'age'" />
|
||||
* </tr>
|
||||
*/
|
||||
interface IColumnDef {
|
||||
/**
|
||||
* Custom CSS class that should be added to the `th` tag(s) of this column in the table header
|
||||
*
|
||||
* To set this on the `td` tag of a html table use the attribute `header-class` or `data-header-class`
|
||||
*/
|
||||
class: IColumnField<string>;
|
||||
/**
|
||||
* The `ISelectOption`s that can be used in a html filter template for this colums.
|
||||
*/
|
||||
data?: SelectData;
|
||||
/**
|
||||
* The index position of this column within the `$columns` container array
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* The definition of 0 or more html filter templates that should be rendered for this column in
|
||||
* the table header
|
||||
*/
|
||||
filter: IColumnField<IFilterTemplateDefMap>;
|
||||
/**
|
||||
* Supplies the `ISelectOption`s that can be used in a html filter template for this colums.
|
||||
* At the creation of the `NgTableParams` this field will be called and the result then assigned
|
||||
* to the `data` field of this column.
|
||||
*/
|
||||
filterData: IColumnField<ng.IPromise<SelectData> | SelectData>;
|
||||
/**
|
||||
* The name of the data row field that will be used to group on, or false when this column
|
||||
* does not support grouping
|
||||
*/
|
||||
groupable: IColumnField<string | boolean>;
|
||||
/**
|
||||
* The url of a custom html template that should be used to render a table header for this column
|
||||
*
|
||||
* To set this on the `td` tag for a html table use the attribute `header` or `data-header`
|
||||
*/
|
||||
headerTemplateURL: IColumnField<string | boolean>;
|
||||
/**
|
||||
* The text that should be used as a tooltip for this column in the table header
|
||||
*/
|
||||
headerTitle: IColumnField<string>;
|
||||
/**
|
||||
* Determines whether this column should be displayed in the table
|
||||
*
|
||||
* To set this on the `td` tag for a html table use the attribute `ng-if`
|
||||
*/
|
||||
show: IColumnField<boolean>;
|
||||
/**
|
||||
* The name of the data row field that will be used to sort on, or false when this column
|
||||
* does not support sorting
|
||||
*/
|
||||
sortable: IColumnField<string | boolean>;
|
||||
/**
|
||||
* The title of this column that should be displayed in the table header
|
||||
*/
|
||||
title: IColumnField<string>;
|
||||
/**
|
||||
* An alternate column title. Typically this can be used for responsive table layouts
|
||||
* where the titleAlt should be used for small screen sizes
|
||||
*/
|
||||
titleAlt: IColumnField<string>;
|
||||
}
|
||||
|
||||
type DynamicTableColField<T> = IDynamicTableColFieldFunc<T> | T;
|
||||
|
||||
interface IDynamicTableColFieldFunc<T> {
|
||||
(context: ColumnFieldContext): T;
|
||||
}
|
||||
|
||||
/**
|
||||
* The definition of the column supplied to a ngTableDynamic directive.
|
||||
*/
|
||||
interface IDynamicTableColDef {
|
||||
/**
|
||||
* Custom CSS class that should be added to the `th` tag(s) of this column in the table header
|
||||
*/
|
||||
class?: DynamicTableColField<string>;
|
||||
/**
|
||||
* The definition of 0 or more html filter templates that should be rendered for this column in
|
||||
* the table header
|
||||
*/
|
||||
filter?: DynamicTableColField<IFilterTemplateDefMap>;
|
||||
/**
|
||||
* Supplies the `ISelectOption`s that can be used in a html filter template for this colums.
|
||||
* At the creation of the `NgTableParams` this field will be called and the result then assigned
|
||||
* to the `data` field of this column.
|
||||
*/
|
||||
filterData?: DynamicTableColField<ng.IPromise<SelectData> | SelectData>;
|
||||
/**
|
||||
* The name of the data row field that will be used to group on, or false when this column
|
||||
* does not support grouping
|
||||
*/
|
||||
groupable?: DynamicTableColField<string | boolean>;
|
||||
/**
|
||||
* The url of a custom html template that should be used to render a table header for this column
|
||||
*/
|
||||
headerTemplateURL?: DynamicTableColField<string | boolean>;
|
||||
/**
|
||||
* The text that should be used as a tooltip for this column in the table header
|
||||
*/
|
||||
headerTitle?: DynamicTableColField<string>;
|
||||
/**
|
||||
* Determines whether this column should be displayed in the table
|
||||
*/
|
||||
show?: DynamicTableColField<boolean>;
|
||||
/**
|
||||
* The name of the data row field that will be used to sort on, or false when this column
|
||||
* does not support sorting
|
||||
*/
|
||||
sortable?: DynamicTableColField<string|boolean>;
|
||||
/**
|
||||
* The title of this column that should be displayed in the table header
|
||||
*/
|
||||
title?: DynamicTableColField<string>;
|
||||
/**
|
||||
* An alternate column title. Typically this can be used for responsive table layouts
|
||||
* where the titleAlt should be used for small screen sizes
|
||||
*/
|
||||
titleAlt?: DynamicTableColField<string>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +203,13 @@ function stream_readable_pipe_test() {
|
||||
|
||||
var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex');
|
||||
|
||||
{
|
||||
let hmac: crypto.Hmac;
|
||||
(hmac = crypto.createHmac('md5', 'hello')).end('world', 'utf8', () => {
|
||||
let hash: Buffer|string = hmac.read();
|
||||
});
|
||||
}
|
||||
|
||||
function crypto_cipher_decipher_string_test() {
|
||||
var key:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
|
||||
var clearText:string = "This is the clear text.";
|
||||
|
||||
Vendored
+7
-7
@@ -1681,13 +1681,13 @@ declare module "crypto" {
|
||||
export function createHash(algorithm: string): Hash;
|
||||
export function createHmac(algorithm: string, key: string): Hmac;
|
||||
export function createHmac(algorithm: string, key: Buffer): Hmac;
|
||||
interface Hash {
|
||||
export interface Hash {
|
||||
update(data: any, input_encoding?: string): Hash;
|
||||
digest(encoding: 'buffer'): Buffer;
|
||||
digest(encoding: string): any;
|
||||
digest(): Buffer;
|
||||
}
|
||||
interface Hmac {
|
||||
export interface Hmac extends NodeJS.ReadWriteStream {
|
||||
update(data: any, input_encoding?: string): Hmac;
|
||||
digest(encoding: 'buffer'): Buffer;
|
||||
digest(encoding: string): any;
|
||||
@@ -1695,7 +1695,7 @@ declare module "crypto" {
|
||||
}
|
||||
export function createCipher(algorithm: string, password: any): Cipher;
|
||||
export function createCipheriv(algorithm: string, key: any, iv: any): Cipher;
|
||||
interface Cipher {
|
||||
export interface Cipher {
|
||||
update(data: Buffer): Buffer;
|
||||
update(data: string, input_encoding?: string, output_encoding?: string): string;
|
||||
final(): Buffer;
|
||||
@@ -1704,7 +1704,7 @@ declare module "crypto" {
|
||||
}
|
||||
export function createDecipher(algorithm: string, password: any): Decipher;
|
||||
export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher;
|
||||
interface Decipher {
|
||||
export interface Decipher {
|
||||
update(data: Buffer): Buffer;
|
||||
update(data: string, input_encoding?: string, output_encoding?: string): string;
|
||||
final(): Buffer;
|
||||
@@ -1712,18 +1712,18 @@ declare module "crypto" {
|
||||
setAutoPadding(auto_padding: boolean): void;
|
||||
}
|
||||
export function createSign(algorithm: string): Signer;
|
||||
interface Signer extends NodeJS.WritableStream {
|
||||
export interface Signer extends NodeJS.WritableStream {
|
||||
update(data: any): void;
|
||||
sign(private_key: string, output_format: string): string;
|
||||
}
|
||||
export function createVerify(algorith: string): Verify;
|
||||
interface Verify extends NodeJS.WritableStream {
|
||||
export interface Verify extends NodeJS.WritableStream {
|
||||
update(data: any): void;
|
||||
verify(object: string, signature: string, signature_format?: string): boolean;
|
||||
}
|
||||
export function createDiffieHellman(prime_length: number): DiffieHellman;
|
||||
export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman;
|
||||
interface DiffieHellman {
|
||||
export interface DiffieHellman {
|
||||
generateKeys(encoding?: string): string;
|
||||
computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string;
|
||||
getPrime(encoding?: string): string;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path="prettyjson.d.ts" />
|
||||
|
||||
var options: prettyjson.RendererOptions,
|
||||
input: string,
|
||||
output: string,
|
||||
version: string;
|
||||
|
||||
|
||||
console.log("using prettyjson v" + prettyjson.version)
|
||||
version = prettyjson.version;
|
||||
|
||||
input = 'This is a string';
|
||||
output = prettyjson.render(input);
|
||||
|
||||
output = prettyjson.render(input, {}, 4);
|
||||
|
||||
output = prettyjson.render(['first string', ['nested 1', 'nested 2'], 'second string']);
|
||||
|
||||
output = prettyjson.render({param1: 'first string', param2: 'second string'});
|
||||
|
||||
output = prettyjson.render({first_param: {subparam: 'first string', subparam2: 'another string'}, second_param: 'second string'});
|
||||
|
||||
prettyjson.renderString('{name: "Wael", nested: {list: ["a", "b"], int: 3}}')
|
||||
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
// Type definitions for prettyjson
|
||||
// Project: https://github.com/rafeca/prettyjson
|
||||
// Definitions by: Wael BEN ZID EL GUEBSI <https://github.com/benzid-wael/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare module prettyjson {
|
||||
|
||||
/**
|
||||
* Defines prettyjson version
|
||||
*/
|
||||
export var version: string;
|
||||
|
||||
/**
|
||||
* Render pretty json.
|
||||
*
|
||||
* @param data {any} Data to prettify.
|
||||
* @param options {IOptions} Hash with different options to configure the renderer.
|
||||
* @param indentation {number} Indentation size.
|
||||
*
|
||||
* @return {string} pretty serialized json data ready to display.
|
||||
*/
|
||||
export function render(data: any, options?: RendererOptions, indentation?: number): string;
|
||||
|
||||
/**
|
||||
* Render pretty json from a string.
|
||||
*
|
||||
* @param data {string} Serialized JSON data to prettify.
|
||||
* @param options {IOptions} Hash with different options to configure the renderer.
|
||||
* @param indentation {number} Indentation size.
|
||||
*
|
||||
* @return {string} pretty serialized json data ready to display.
|
||||
*/
|
||||
export function renderString(data: string, options?: RendererOptions, indentation?: number): string;
|
||||
|
||||
export interface RendererOptions {
|
||||
|
||||
/**
|
||||
* Define behavior for Array objects
|
||||
*/
|
||||
emptyArrayMsg ?: string; // default: (empty)
|
||||
inlineArrays ?: boolean;
|
||||
|
||||
/**
|
||||
* Color definition
|
||||
*/
|
||||
noColor ?: boolean;
|
||||
keysColor ?: string;
|
||||
dashColor ?: string;
|
||||
numberColor ?: string;
|
||||
stringColor ?: string;
|
||||
|
||||
defaultIndentation ?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/// <reference path="react-notification-system.d.ts" />
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
import React = require('react');
|
||||
import NotificationSystem = require('react-notification-system');
|
||||
|
||||
|
||||
class MyComponent extends React.Component<any, any> {
|
||||
private notificationSystem: NotificationSystem.System = null;
|
||||
|
||||
private notification: NotificationSystem.Notification = {
|
||||
message: 'Notification message',
|
||||
level: 'success',
|
||||
action: {
|
||||
label: "Button inside this notification",
|
||||
callback: () => {
|
||||
this.notificationSystem.removeNotification(this.notification);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private addNotification() {
|
||||
this.notification = this.notificationSystem.addNotification(this.notification);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.notificationSystem = this.refs['notificationSystem'] as NotificationSystem.System;
|
||||
this.addNotification();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
var style = {
|
||||
NotificationItem: { // Override the notification item
|
||||
DefaultStyle: { // Applied to every notification, regardless of the notification level
|
||||
margin: '10px 5px 2px 1px'
|
||||
},
|
||||
|
||||
success: { // Applied only to the success notification item
|
||||
color: 'red'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var attributes: NotificationSystem.Attributes = {
|
||||
style: {
|
||||
Containers: {
|
||||
DefaultStyle: {
|
||||
margin: '10px 5px 2px 1px'
|
||||
}
|
||||
},
|
||||
Title: {
|
||||
success: {
|
||||
color: 'green'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return React.createElement(NotificationSystem, { title: "NotificationTitile", style: style, } as NotificationSystem.Attributes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
// Type definitions for React Notification System v0.2.6
|
||||
// Project: https://www.npmjs.com/package/react-notification-system
|
||||
// Definitions by: Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>, Deividas Bakanas <https://github.com/DeividasBakanas>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module NotificationSystem {
|
||||
|
||||
import React = __React;
|
||||
|
||||
export interface System extends React.Component<any, any> {
|
||||
addNotification(notification: Notification): Notification;
|
||||
removeNotification(notification: Notification): void;
|
||||
removeNotification(uid: string): void;
|
||||
}
|
||||
|
||||
export interface CallBackFunction {
|
||||
(notification: Notification): void;
|
||||
}
|
||||
|
||||
export interface Notification {
|
||||
title?: string;
|
||||
message?: string;
|
||||
level?: string;
|
||||
position?: string;
|
||||
autoDismiss?: number;
|
||||
dismissible?: boolean;
|
||||
action?: ActionObject;
|
||||
onAdd?: CallBackFunction;
|
||||
onRemove?: CallBackFunction;
|
||||
uid?: number | string;
|
||||
}
|
||||
|
||||
export interface ActionObject {
|
||||
label: string;
|
||||
callback?: Function;
|
||||
}
|
||||
|
||||
export interface ContainersStyle {
|
||||
DefaultStyle: React.CSSProperties;
|
||||
tl?: React.CSSProperties;
|
||||
tr?: React.CSSProperties;
|
||||
tc?: React.CSSProperties;
|
||||
bl?: React.CSSProperties;
|
||||
br?: React.CSSProperties;
|
||||
bc?: React.CSSProperties;
|
||||
}
|
||||
|
||||
export interface ItemStyle {
|
||||
DefaultStyle?: React.CSSProperties;
|
||||
success?: React.CSSProperties;
|
||||
error?: React.CSSProperties;
|
||||
warning?: React.CSSProperties;
|
||||
info?: React.CSSProperties;
|
||||
}
|
||||
|
||||
export interface WrapperStyle {
|
||||
DefaultStyle?: React.CSSProperties;
|
||||
}
|
||||
|
||||
export interface Style {
|
||||
Wrapper?: any;
|
||||
Containers?: ContainersStyle;
|
||||
NotificationItem?: ItemStyle;
|
||||
Title?: ItemStyle;
|
||||
MessageWrapper?: WrapperStyle;
|
||||
Dismiss?: ItemStyle;
|
||||
Action?: ItemStyle;
|
||||
ActionWrapper?: WrapperStyle;
|
||||
}
|
||||
|
||||
export interface Attributes {
|
||||
noAnimation?: boolean;
|
||||
ref?: string;
|
||||
style?: Style | boolean;
|
||||
}
|
||||
|
||||
|
||||
export interface Component {
|
||||
(): React.ReactElement<Attributes>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
declare module 'react-notification-system' {
|
||||
var component: NotificationSystem.Component;
|
||||
export = component;
|
||||
}
|
||||
+5
-2
@@ -3,13 +3,16 @@
|
||||
// Definitions by: Elisée Maurer <https://github.com/elisee/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "recursive-readdir" {
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "recursive-readdir" {
|
||||
import * as fs from "fs";
|
||||
module RecursiveReaddir {
|
||||
interface readdir {
|
||||
(path: string, callback: (error: Error, files: string[]) => any): void;
|
||||
// ignorePattern supports glob syntax via https://github.com/isaacs/minimatch
|
||||
(path: string, ignorePattern: string[], callback: (error: Error, files: string[]) => any): void;
|
||||
(path: string, ignorePattern: (string | ((file: string, stats: fs.Stats) => void))[], callback: (error: Error, files: string[]) => any): void;
|
||||
(path: string, ignoreFunction: (file: string, stats: fs.Stats) => void, callback: (error: Error, files: string[]) => any): void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
/// <reference path="./redux-devtools-dock-monitor.d.ts" />
|
||||
|
||||
import * as React from 'react'
|
||||
import DockMonitor from 'redux-devtools-dock-monitor'
|
||||
|
||||
let dockMonitor = <DockMonitor toggleVisibilityKey='ctrl-h' changePositionKey='ctrl-q' />
|
||||
@@ -0,0 +1,59 @@
|
||||
// Type definitions for redux-devtools-dock-monitor 1.0.1
|
||||
// Project: https://github.com/gaearon/redux-devtools-dock-monitor
|
||||
// Definitions by: Petryshyn Sergii <https://github.com/mc-petry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module "redux-devtools-dock-monitor" {
|
||||
import * as React from 'react'
|
||||
|
||||
interface IDockMonitorProps {
|
||||
/**
|
||||
* Any valid Redux DevTools monitor.
|
||||
*/
|
||||
children?: React.ReactNode
|
||||
|
||||
/**
|
||||
* A key or a key combination that toggles the dock visibility.
|
||||
* Must be recognizable by parse-key (for example, 'ctrl-h')
|
||||
*/
|
||||
toggleVisibilityKey: string
|
||||
|
||||
/**
|
||||
* A key or a key combination that toggles the dock position.
|
||||
* Must be recognizable by parse-key (for example, 'ctrl-w')
|
||||
*/
|
||||
changePositionKey: string
|
||||
|
||||
/**
|
||||
* When true, the dock size is a fraction of the window size, fixed otherwise.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
fluid?: boolean
|
||||
|
||||
/**
|
||||
* Size of the dock. When fluid is true, a float (0.5 means half the window size).
|
||||
* When fluid is false, a width in pixels
|
||||
*
|
||||
* @default 0.3 (3/10th of the window size)
|
||||
*/
|
||||
defaultSize?: number
|
||||
|
||||
/**
|
||||
* Where the dock appears on the screen.
|
||||
* Valid values: 'left', 'top', 'right', 'bottom'
|
||||
*
|
||||
* @default 'right'
|
||||
*/
|
||||
defaultPosition?: string
|
||||
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
defaultIsVisible?: boolean
|
||||
}
|
||||
|
||||
export default class DockMonitor extends React.Component<IDockMonitorProps, any> {}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
/// <reference path="./redux-devtools-log-monitor.d.ts" />
|
||||
|
||||
import * as React from 'react'
|
||||
import LogMonitor from 'redux-devtools-log-monitor'
|
||||
|
||||
let logMonitor = <LogMonitor />
|
||||
@@ -0,0 +1,39 @@
|
||||
// Type definitions for redux-devtools-log-monitor 1.0.1
|
||||
// Project: https://github.com/gaearon/redux-devtools-log-monitor
|
||||
// Definitions by: Petryshyn Sergii <https://github.com/mc-petry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module "redux-devtools-log-monitor" {
|
||||
import * as React from 'react'
|
||||
|
||||
interface ILogMonitorProps {
|
||||
/**
|
||||
* Either a string referring to one of the themes provided by
|
||||
* redux-devtools-themes or a custom object of the same format.
|
||||
*
|
||||
* @see https://github.com/gaearon/redux-devtools-themes
|
||||
*/
|
||||
theme?: string
|
||||
|
||||
/**
|
||||
* A function that selects the slice of the state for DevTools to show.
|
||||
*
|
||||
* @example state => state.thePart.iCare.about.
|
||||
* @default state => state.
|
||||
*/
|
||||
select?: (state: any) => any
|
||||
|
||||
/**
|
||||
* When true, records the current scroll top every second so it
|
||||
* can be restored on refresh. This only has effect when used together
|
||||
* with persistState() enhancer from Redux DevTools.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
preserveScrollTop?: boolean
|
||||
}
|
||||
|
||||
export default class LogMonitor extends React.Component<ILogMonitorProps, any> {}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/// <reference path="redux-devtools-2.1.4.d.ts" />
|
||||
/// <reference path="../redux/redux.d.ts" />
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
import { compose, createStore, applyMiddleware, Middleware, Reducer } from 'redux';
|
||||
import { devTools, persistState } from 'redux-devtools';
|
||||
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react';
|
||||
import * as React from 'react';
|
||||
import { Component } from 'react';
|
||||
|
||||
declare var m1: Middleware;
|
||||
declare var m2: Middleware;
|
||||
declare var m3: Middleware;
|
||||
declare var reducer: Reducer;
|
||||
class CounterApp extends Component<any, any> { };
|
||||
class Provider extends Component<{ store: any }, any> { };
|
||||
|
||||
const finalCreateStore = compose(
|
||||
// Enables your middleware:
|
||||
applyMiddleware(m1, m2, m3), // any Redux middleware, e.g. redux-thunk
|
||||
// Provides support for DevTools:
|
||||
devTools(),
|
||||
// Lets you write ?debug_session=<name> in address bar to persist debug sessions
|
||||
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
|
||||
)(createStore);
|
||||
const store = finalCreateStore(reducer);
|
||||
|
||||
class Root extends Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Provider store={store}>
|
||||
{() => <CounterApp />}
|
||||
</Provider>
|
||||
<DebugPanel top right bottom>
|
||||
<DevTools store={store} monitor={LogMonitor} />
|
||||
</DebugPanel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// https://github.com/gaearon/redux-devtools/blob/master/examples/counter/containers/App.js
|
||||
//
|
||||
|
||||
class App extends Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Provider store={store}>
|
||||
{() => <CounterApp />}
|
||||
</Provider>
|
||||
<DebugPanel top right bottom>
|
||||
<DevTools store={store}
|
||||
monitor={LogMonitor}
|
||||
visibleOnLoad={true} />
|
||||
</DebugPanel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
// Type definitions for redux-devtools 2.1.4
|
||||
// Project: https://github.com/gaearon/redux-devtools
|
||||
// Definitions by: Qubo <https://github.com/tkqubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../redux/redux.d.ts" />
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module "redux-devtools" {
|
||||
export function devTools(): Function;
|
||||
export function persistState(sessionId: any, stateDeserializer?: Function, actionDeserializer?: Function): Function;
|
||||
}
|
||||
|
||||
declare module "redux-devtools/lib/react" {
|
||||
import * as React from 'react';
|
||||
|
||||
export class DevTools extends React.Component<any, any> {
|
||||
|
||||
}
|
||||
|
||||
export interface DevToolsProps {
|
||||
monitor: Function;
|
||||
store: Store;
|
||||
}
|
||||
|
||||
export interface Store {
|
||||
devToolStore: DevToolStore;
|
||||
}
|
||||
|
||||
export class DevToolStore extends React.Component<any, any> {
|
||||
dispatch: Function;
|
||||
}
|
||||
|
||||
export class DebugPanel extends React.Component<DebugPanelProps, any> { }
|
||||
|
||||
export interface DebugPanelProps {
|
||||
position?: string;
|
||||
zIndex?: number;
|
||||
fontSize?: string;
|
||||
overflow?: string;
|
||||
opacity?: number;
|
||||
color?: string;
|
||||
left?: boolean|number;
|
||||
right?: boolean|number;
|
||||
top?: boolean|number;
|
||||
bottom?: boolean|number;
|
||||
maxHeight?: string;
|
||||
maxWidth?: string;
|
||||
wordWrap?: string;
|
||||
boxSizing?: string;
|
||||
boxShadow?: string;
|
||||
getStyle?: () => DebugPanelProps;
|
||||
}
|
||||
|
||||
export class LogMonitor extends React.Component<LogMonitorProps, any> { }
|
||||
|
||||
export interface LogMonitorProps {
|
||||
computedStates?: ComputedState[];
|
||||
currentStateIndex?: number;
|
||||
monitorState?: MonitorState;
|
||||
stagedActions?: Action[];
|
||||
skippedActions?: boolean[];
|
||||
reset?: Function;
|
||||
commit?: Function;
|
||||
rollback?: Function;
|
||||
sweep?: Function;
|
||||
toggleAction?: Function;
|
||||
jumpToState?: Function;
|
||||
setMonitorState?: Function;
|
||||
select?: Function;
|
||||
visibleOnLoad?: boolean;
|
||||
theme?: Theme|string;
|
||||
}
|
||||
|
||||
export interface ComputedState {
|
||||
state?: any;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface MonitorState {
|
||||
isViaible?: boolean;
|
||||
}
|
||||
|
||||
export interface Action {
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface Theme {
|
||||
scheme: string;
|
||||
author: string;
|
||||
base00: string;
|
||||
base01: string;
|
||||
base02: string;
|
||||
base03: string;
|
||||
base04: string;
|
||||
base05: string;
|
||||
base06: string;
|
||||
base07: string;
|
||||
base08: string;
|
||||
base09: string;
|
||||
base0A: string;
|
||||
base0B: string;
|
||||
base0C: string;
|
||||
base0D: string;
|
||||
base0E: string;
|
||||
base0F: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,31 @@
|
||||
/// <reference path="redux-devtools.d.ts" />
|
||||
/// <reference path="../redux/redux.d.ts" />
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
/// <reference path="../redux/redux.d.ts" />
|
||||
/// <reference path="../react-redux/react-redux.d.ts" />
|
||||
/// <reference path="redux-devtools.d.ts" />
|
||||
|
||||
import { compose, createStore, applyMiddleware, Middleware, Reducer } from 'redux';
|
||||
import { devTools, persistState } from 'redux-devtools';
|
||||
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react';
|
||||
import * as React from 'react';
|
||||
import { Component } from 'react';
|
||||
import * as React from 'react'
|
||||
import { createStore, applyMiddleware, compose } from 'redux'
|
||||
import { Provider } from 'react-redux'
|
||||
import { createDevTools, persistState } from 'redux-devtools'
|
||||
|
||||
declare var m1: Middleware;
|
||||
declare var m2: Middleware;
|
||||
declare var m3: Middleware;
|
||||
declare var reducer: Reducer;
|
||||
class CounterApp extends Component<any, any> { };
|
||||
class Provider extends Component<{ store: any }, any> { };
|
||||
class DevToolsMonitor extends React.Component<any, any> {
|
||||
}
|
||||
|
||||
const DevTools = createDevTools(
|
||||
<DevToolsMonitor />
|
||||
)
|
||||
|
||||
const finalCreateStore = compose(
|
||||
// Enables your middleware:
|
||||
applyMiddleware(m1, m2, m3), // any Redux middleware, e.g. redux-thunk
|
||||
// Provides support for DevTools:
|
||||
devTools(),
|
||||
// Lets you write ?debug_session=<name> in address bar to persist debug sessions
|
||||
persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
|
||||
)(createStore);
|
||||
const store = finalCreateStore(reducer);
|
||||
DevTools.instrument(),
|
||||
persistState('test-session')
|
||||
)(createStore)
|
||||
|
||||
class Root extends Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Provider store={store}>
|
||||
{() => <CounterApp />}
|
||||
</Provider>
|
||||
<DebugPanel top right bottom>
|
||||
<DevTools store={store} monitor={LogMonitor} />
|
||||
</DebugPanel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// https://github.com/gaearon/redux-devtools/blob/master/examples/counter/containers/App.js
|
||||
//
|
||||
|
||||
class App extends Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Provider store={store}>
|
||||
{() => <CounterApp />}
|
||||
</Provider>
|
||||
<DebugPanel top right bottom>
|
||||
<DevTools store={store}
|
||||
monitor={LogMonitor}
|
||||
visibleOnLoad={true} />
|
||||
</DebugPanel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
class App extends React.Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<Provider>
|
||||
<DevTools />
|
||||
</Provider>
|
||||
)
|
||||
}
|
||||
}
|
||||
Vendored
+13
-100
@@ -1,109 +1,22 @@
|
||||
// Type definitions for redux-devtools 2.1.4
|
||||
// Type definitions for redux-devtools 3.0.0
|
||||
// Project: https://github.com/gaearon/redux-devtools
|
||||
// Definitions by: Qubo <https://github.com/tkqubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions by: Petryshyn Sergii <https://github.com/mc-petry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../redux/redux.d.ts" />
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module "redux-devtools" {
|
||||
export function devTools(): Function;
|
||||
export function persistState(sessionId: any, stateDeserializer?: Function, actionDeserializer?: Function): Function;
|
||||
}
|
||||
import * as React from 'react'
|
||||
|
||||
declare module "redux-devtools/lib/react" {
|
||||
import * as React from 'react';
|
||||
interface IDevTools {
|
||||
new (): JSX.ElementClass
|
||||
instrument(): Function
|
||||
}
|
||||
|
||||
export class DevTools extends React.Component<any, any> {
|
||||
export function createDevTools(el: React.ReactElement<any>): IDevTools
|
||||
export function persistState(debugSessionKey: string): Function
|
||||
|
||||
}
|
||||
|
||||
export interface DevToolsProps {
|
||||
monitor: Function;
|
||||
store: Store;
|
||||
}
|
||||
|
||||
export interface Store {
|
||||
devToolStore: DevToolStore;
|
||||
}
|
||||
|
||||
export class DevToolStore extends React.Component<any, any> {
|
||||
dispatch: Function;
|
||||
}
|
||||
|
||||
export class DebugPanel extends React.Component<DebugPanelProps, any> { }
|
||||
|
||||
export interface DebugPanelProps {
|
||||
position?: string;
|
||||
zIndex?: number;
|
||||
fontSize?: string;
|
||||
overflow?: string;
|
||||
opacity?: number;
|
||||
color?: string;
|
||||
left?: boolean|number;
|
||||
right?: boolean|number;
|
||||
top?: boolean|number;
|
||||
bottom?: boolean|number;
|
||||
maxHeight?: string;
|
||||
maxWidth?: string;
|
||||
wordWrap?: string;
|
||||
boxSizing?: string;
|
||||
boxShadow?: string;
|
||||
getStyle?: () => DebugPanelProps;
|
||||
}
|
||||
|
||||
export class LogMonitor extends React.Component<LogMonitorProps, any> { }
|
||||
|
||||
export interface LogMonitorProps {
|
||||
computedStates?: ComputedState[];
|
||||
currentStateIndex?: number;
|
||||
monitorState?: MonitorState;
|
||||
stagedActions?: Action[];
|
||||
skippedActions?: boolean[];
|
||||
reset?: Function;
|
||||
commit?: Function;
|
||||
rollback?: Function;
|
||||
sweep?: Function;
|
||||
toggleAction?: Function;
|
||||
jumpToState?: Function;
|
||||
setMonitorState?: Function;
|
||||
select?: Function;
|
||||
visibleOnLoad?: boolean;
|
||||
theme?: Theme|string;
|
||||
}
|
||||
|
||||
export interface ComputedState {
|
||||
state?: any;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface MonitorState {
|
||||
isViaible?: boolean;
|
||||
}
|
||||
|
||||
export interface Action {
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface Theme {
|
||||
scheme: string;
|
||||
author: string;
|
||||
base00: string;
|
||||
base01: string;
|
||||
base02: string;
|
||||
base03: string;
|
||||
base04: string;
|
||||
base05: string;
|
||||
base06: string;
|
||||
base07: string;
|
||||
base08: string;
|
||||
base09: string;
|
||||
base0A: string;
|
||||
base0B: string;
|
||||
base0C: string;
|
||||
base0D: string;
|
||||
base0E: string;
|
||||
base0F: string;
|
||||
}
|
||||
}
|
||||
var factory: { instrument(): Function }
|
||||
|
||||
export default factory;
|
||||
}
|
||||
Vendored
+1
@@ -80,5 +80,6 @@ declare module Chai {
|
||||
|
||||
declare module "sinon-chai" {
|
||||
function sinonChai(chai: any, utils: any): void;
|
||||
namespace sinonChai { }
|
||||
export = sinonChai;
|
||||
}
|
||||
|
||||
Vendored
+5
@@ -329,6 +329,11 @@ interface tinycolorInstance {
|
||||
* Gets the complement of the current color
|
||||
*/
|
||||
complement(): tinycolorInstance;
|
||||
|
||||
/**
|
||||
* Gets a new instance with the current color
|
||||
*/
|
||||
clone(): tinycolorInstance;
|
||||
}
|
||||
|
||||
declare module Readable {
|
||||
|
||||
Vendored
+108
@@ -0,0 +1,108 @@
|
||||
// Type definitions for vinyl 0.4.3
|
||||
// Project: https://github.com/wearefractal/vinyl
|
||||
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "vinyl" {
|
||||
|
||||
import fs = require("fs");
|
||||
|
||||
/**
|
||||
* A virtual file format.
|
||||
*/
|
||||
class File {
|
||||
constructor(options?: {
|
||||
/**
|
||||
* Default: process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
/**
|
||||
* Used for relative pathing. Typically where a glob starts.
|
||||
*/
|
||||
base?: string;
|
||||
/**
|
||||
* Full path to the file.
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* Path history. Has no effect if options.path is passed.
|
||||
*/
|
||||
history?: string[];
|
||||
/**
|
||||
* The result of an fs.stat call. See fs.Stats for more information.
|
||||
*/
|
||||
stat?: fs.Stats;
|
||||
/**
|
||||
* File contents.
|
||||
* Type: Buffer, Stream, or null
|
||||
*/
|
||||
contents?: Buffer | NodeJS.ReadWriteStream;
|
||||
});
|
||||
|
||||
/**
|
||||
* Default: process.cwd()
|
||||
*/
|
||||
public cwd: string;
|
||||
/**
|
||||
* Used for relative pathing. Typically where a glob starts.
|
||||
*/
|
||||
public base: string;
|
||||
/**
|
||||
* Full path to the file.
|
||||
*/
|
||||
public path: string;
|
||||
public stat: fs.Stats;
|
||||
/**
|
||||
* Type: Buffer|Stream|null (Default: null)
|
||||
*/
|
||||
public contents: Buffer | NodeJS.ReadableStream;
|
||||
/**
|
||||
* Returns path.relative for the file base and file path.
|
||||
* Example:
|
||||
* var file = new File({
|
||||
* cwd: "/",
|
||||
* base: "/test/",
|
||||
* path: "/test/file.js"
|
||||
* });
|
||||
* console.log(file.relative); // file.js
|
||||
*/
|
||||
public relative: string;
|
||||
|
||||
public isBuffer(): boolean;
|
||||
|
||||
public isStream(): boolean;
|
||||
|
||||
public isNull(): boolean;
|
||||
|
||||
public isDirectory(): boolean;
|
||||
|
||||
/**
|
||||
* Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
|
||||
*/
|
||||
public clone(opts?: { contents?: boolean }): File;
|
||||
|
||||
/**
|
||||
* If file.contents is a Buffer, it will write it to the stream.
|
||||
* If file.contents is a Stream, it will pipe it to the stream.
|
||||
* If file.contents is null, it will do nothing.
|
||||
*/
|
||||
public pipe<T extends NodeJS.ReadWriteStream>(
|
||||
stream: T,
|
||||
opts?: {
|
||||
/**
|
||||
* If false, the destination stream will not be ended (same as node core).
|
||||
*/
|
||||
end?: boolean;
|
||||
}): T;
|
||||
|
||||
/**
|
||||
* Returns a pretty String interpretation of the File. Useful for console.log.
|
||||
*/
|
||||
public inspect(): string;
|
||||
}
|
||||
|
||||
export = File;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,560 @@
|
||||
/// <reference path="../mocha/mocha.d.ts" />
|
||||
/// <reference path="../should/should.d.ts" />
|
||||
|
||||
/// <reference path="./vinyl-0.4.3.d.ts" />
|
||||
|
||||
import File = require('vinyl');
|
||||
import Stream = require('stream');
|
||||
import fs = require('fs');
|
||||
|
||||
declare var fakeStream: NodeJS.ReadWriteStream;
|
||||
|
||||
describe('File', () => {
|
||||
|
||||
describe('constructor()', () => {
|
||||
|
||||
it('should default cwd to process.cwd', done => {
|
||||
var file = new File();
|
||||
file.cwd.should.equal(process.cwd());
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default base to cwd', done => {
|
||||
var cwd = "/";
|
||||
var file = new File({cwd: cwd});
|
||||
file.base.should.equal(cwd);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default base to cwd even when none is given', done => {
|
||||
var file = new File();
|
||||
file.base.should.equal(process.cwd());
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default path to null', done => {
|
||||
var file = new File();
|
||||
should.not.exist(file.path);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default stat to null', done => {
|
||||
var file = new File();
|
||||
should.not.exist(file.stat);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default contents to null', done => {
|
||||
var file = new File();
|
||||
should.not.exist(file.contents);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set base to given value', done => {
|
||||
var val = "/";
|
||||
var file = new File({base: val});
|
||||
file.base.should.equal(val);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set cwd to given value', done => {
|
||||
var val = "/";
|
||||
var file = new File({cwd: val});
|
||||
file.cwd.should.equal(val);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set path to given value', done => {
|
||||
var val = "/test.coffee";
|
||||
var file = new File({path: val});
|
||||
file.path.should.equal(val);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set stat to given value', done => {
|
||||
var val = {};
|
||||
var file = new File(<fs.Stats><any>{stat: val});
|
||||
file.stat.should.equal(val);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set contents to given value', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File({contents: val});
|
||||
file.contents.should.equal(val);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('isBuffer()', () => {
|
||||
it('should return true when the contents are a Buffer', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File({contents: val});
|
||||
file.isBuffer().should.equal(true);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return false when the contents are a Stream', done => {
|
||||
var file = new File({ contents: fakeStream});
|
||||
file.isBuffer().should.equal(false);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return false when the contents are a null', done => {
|
||||
var file = new File({contents: null});
|
||||
file.isBuffer().should.equal(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('isStream()', () => {
|
||||
it('should return false when the contents are a Buffer', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File({contents: val});
|
||||
file.isStream().should.equal(false);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return true when the contents are a Stream', done => {
|
||||
var file = new File({ contents: fakeStream});
|
||||
file.isStream().should.equal(true);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return false when the contents are a null', done => {
|
||||
var file = new File({contents: null});
|
||||
file.isStream().should.equal(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('isNull()', () => {
|
||||
it('should return false when the contents are a Buffer', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File({contents: val});
|
||||
file.isNull().should.equal(false);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return false when the contents are a Stream', done => {
|
||||
var file = new File({ contents: fakeStream});
|
||||
file.isNull().should.equal(false);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return true when the contents are a null', done => {
|
||||
var file = new File({contents: null});
|
||||
file.isNull().should.equal(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDirectory()', () => {
|
||||
var fakeStat = <fs.Stats>{
|
||||
isDirectory() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
it('should return false when the contents are a Buffer', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File({contents: val, stat: fakeStat});
|
||||
file.isDirectory().should.equal(false);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return false when the contents are a Stream', done => {
|
||||
var file = new File({ contents: fakeStream, stat: fakeStat});
|
||||
file.isDirectory().should.equal(false);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return true when the contents are a null', done => {
|
||||
var file = new File({contents: null, stat: fakeStat});
|
||||
file.isDirectory().should.equal(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('clone()', () => {
|
||||
it('should copy all attributes over with Buffer', done => {
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: new Buffer("test")
|
||||
};
|
||||
var file = new File(options);
|
||||
var file2 = file.clone();
|
||||
|
||||
file2.should.not.equal(file, 'refs should be different');
|
||||
file2.cwd.should.equal(file.cwd);
|
||||
file2.base.should.equal(file.base);
|
||||
file2.path.should.equal(file.path);
|
||||
|
||||
let fileContents = file.contents;
|
||||
let file2Contents = file2.contents;
|
||||
|
||||
file2Contents.should.not.equal(fileContents, 'buffer ref should be different');
|
||||
|
||||
let fileUtf8Contents = fileContents instanceof Buffer ?
|
||||
fileContents.toString('utf8') :
|
||||
(<NodeJS.ReadableStream>fileContents).toString();
|
||||
let file2Utf8Contents = file2Contents instanceof Buffer ?
|
||||
file2Contents.toString('utf8') :
|
||||
(<NodeJS.ReadableStream>file2Contents).toString();
|
||||
|
||||
file2Utf8Contents.should.equal(fileUtf8Contents);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should copy all attributes over with Stream', done => {
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: fakeStream
|
||||
};
|
||||
var file = new File(options);
|
||||
var file2 = file.clone();
|
||||
|
||||
file2.should.not.equal(file, 'refs should be different');
|
||||
file2.cwd.should.equal(file.cwd);
|
||||
file2.base.should.equal(file.base);
|
||||
file2.path.should.equal(file.path);
|
||||
file2.contents.should.equal(file.contents, 'stream ref should be the same');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should copy all attributes over with null', done => {
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: fakeStream
|
||||
};
|
||||
var file = new File(options);
|
||||
var file2 = file.clone();
|
||||
|
||||
file2.should.not.equal(file, 'refs should be different');
|
||||
file2.cwd.should.equal(file.cwd);
|
||||
file2.base.should.equal(file.base);
|
||||
file2.path.should.equal(file.path);
|
||||
should.not.exist(file2.contents);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly clone the `stat` property', done => {
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.js",
|
||||
contents: new Buffer("test"),
|
||||
stat: fs.statSync(__filename)
|
||||
};
|
||||
|
||||
var file = new File(options);
|
||||
var copy = file.clone();
|
||||
|
||||
// ReSharper disable WrongExpressionStatement
|
||||
copy.stat.isFile().should.be.true;
|
||||
copy.stat.isDirectory().should.be.false;
|
||||
// ReSharper restore WrongExpressionStatement
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('pipe()', () => {
|
||||
it('should write to stream with Buffer', done => {
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: new Buffer("test")
|
||||
};
|
||||
var file = new File(options);
|
||||
var stream = new Stream.PassThrough();
|
||||
stream.on('data', (chunk: any) => {
|
||||
should.exist(chunk);
|
||||
(chunk instanceof Buffer).should.equal(true, 'should write as a buffer');
|
||||
chunk.toString('utf8').should.equal(options.contents.toString('utf8'));
|
||||
});
|
||||
stream.on('end', () => {
|
||||
done();
|
||||
});
|
||||
var ret = file.pipe(stream);
|
||||
ret.should.equal(stream, 'should return the stream');
|
||||
});
|
||||
|
||||
it('should pipe to stream with Stream', done => {
|
||||
var testChunk = new Buffer("test");
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: new Stream.PassThrough()
|
||||
};
|
||||
var file = new File(options);
|
||||
var stream = new Stream.PassThrough();
|
||||
stream.on('data', (chunk: any) => {
|
||||
should.exist(chunk);
|
||||
(chunk instanceof Buffer).should.equal(true, 'should write as a buffer');
|
||||
chunk.toString('utf8').should.equal(testChunk.toString('utf8'));
|
||||
done();
|
||||
});
|
||||
var ret = file.pipe(stream);
|
||||
ret.should.equal(stream, 'should return the stream');
|
||||
|
||||
let fileContents = file.contents;
|
||||
if (fileContents instanceof Buffer) {
|
||||
fileContents.write(testChunk.toString());
|
||||
}
|
||||
});
|
||||
|
||||
it('should do nothing with null', done => {
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: fakeStream
|
||||
};
|
||||
var file = new File(options);
|
||||
var stream = new Stream.PassThrough();
|
||||
stream.on('data', () => {
|
||||
throw new Error("should not write");
|
||||
});
|
||||
stream.on('end', () => {
|
||||
done();
|
||||
});
|
||||
var ret = file.pipe(stream);
|
||||
ret.should.equal(stream, 'should return the stream');
|
||||
});
|
||||
|
||||
it('should write to stream with Buffer', done => {
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: new Buffer("test")
|
||||
};
|
||||
var file = new File(options);
|
||||
var stream = new Stream.PassThrough();
|
||||
stream.on('data', (chunk: any) => {
|
||||
should.exist(chunk);
|
||||
(chunk instanceof Buffer).should.equal(true, 'should write as a buffer');
|
||||
chunk.toString('utf8').should.equal(options.contents.toString('utf8'));
|
||||
done();
|
||||
});
|
||||
stream.on('end', () => {
|
||||
throw new Error("should not end");
|
||||
});
|
||||
var ret = file.pipe(stream, {end: false});
|
||||
ret.should.equal(stream, 'should return the stream');
|
||||
});
|
||||
|
||||
it('should pipe to stream with Stream', done => {
|
||||
var testChunk = new Buffer("test");
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: new Stream.PassThrough()
|
||||
};
|
||||
var file = new File(options);
|
||||
var stream = new Stream.PassThrough();
|
||||
stream.on('data', (chunk: any) => {
|
||||
should.exist(chunk);
|
||||
(chunk instanceof Buffer).should.equal(true, 'should write as a buffer');
|
||||
chunk.toString('utf8').should.equal(testChunk.toString('utf8'));
|
||||
done();
|
||||
});
|
||||
stream.on('end', () => {
|
||||
throw new Error("should not end");
|
||||
});
|
||||
var ret = file.pipe(stream, {end: false});
|
||||
ret.should.equal(stream, 'should return the stream');
|
||||
|
||||
let fileContents = file.contents;
|
||||
if (fileContents instanceof Buffer) {
|
||||
fileContents.write(testChunk.toString());
|
||||
}
|
||||
});
|
||||
|
||||
it('should do nothing with null', done => {
|
||||
var options = {
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: fakeStream
|
||||
};
|
||||
var file = new File(options);
|
||||
var stream = new Stream.PassThrough();
|
||||
stream.on('data', () => {
|
||||
throw new Error("should not write");
|
||||
});
|
||||
stream.on('end', () => {
|
||||
throw new Error("should not end");
|
||||
});
|
||||
var ret = file.pipe(stream, {end: false});
|
||||
ret.should.equal(stream, 'should return the stream');
|
||||
process.nextTick(done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('inspect()', () => {
|
||||
it('should return correct format when no contents and no path', done => {
|
||||
var file = new File();
|
||||
file.inspect().should.equal('<File >');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return correct format when Buffer and no path', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File({
|
||||
contents: val
|
||||
});
|
||||
file.inspect().should.equal('<File <Buffer 74 65 73 74>>');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return correct format when Buffer and relative path', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: val
|
||||
});
|
||||
file.inspect().should.equal('<File "test.coffee" <Buffer 74 65 73 74>>');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return correct format when Buffer and only path and no base', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
path: "/test/test.coffee",
|
||||
contents: val
|
||||
});
|
||||
delete file.base;
|
||||
file.inspect().should.equal('<File "/test/test.coffee" <Buffer 74 65 73 74>>');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return correct format when Stream and relative path', done => {
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: new Stream.PassThrough()
|
||||
});
|
||||
file.inspect().should.equal('<File "test.coffee" <PassThroughStream>>');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return correct format when null and relative path', done => {
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee",
|
||||
contents: null
|
||||
});
|
||||
file.inspect().should.equal('<File "test.coffee">');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('contents get/set', () => {
|
||||
it('should work with Buffer', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File();
|
||||
file.contents = val;
|
||||
file.contents.should.equal(val);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should work with Stream', done => {
|
||||
var val = new Stream.PassThrough();
|
||||
var file = new File();
|
||||
file.contents = val;
|
||||
file.contents.should.equal(val);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should work with null', done => {
|
||||
var file = new File();
|
||||
file.contents = null;
|
||||
(file.contents === null).should.equal(true);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not work with string', done => {
|
||||
var val = "test";
|
||||
var file = new File();
|
||||
try {
|
||||
file.contents = new Buffer(val);
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('relative get/set', () => {
|
||||
it('should error on set', done => {
|
||||
var file = new File();
|
||||
try {
|
||||
file.relative = "test";
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should error on get when no base', done => {
|
||||
var a: string;
|
||||
var file = new File();
|
||||
delete file.base;
|
||||
try {
|
||||
// ReSharper disable once AssignedValueIsNeverUsed
|
||||
a = file.relative;
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should error on get when no path', done => {
|
||||
var a: string;
|
||||
var file = new File();
|
||||
try {
|
||||
// ReSharper disable once AssignedValueIsNeverUsed
|
||||
a = file.relative;
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should return a relative path from base', done => {
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee"
|
||||
});
|
||||
file.relative.should.equal("test.coffee");
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return a relative path from cwd', done => {
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
path: "/test/test.coffee"
|
||||
});
|
||||
file.relative.should.equal("test/test.coffee");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
+134
-36
@@ -22,13 +22,13 @@ describe('File', () => {
|
||||
it('should default base to cwd', done => {
|
||||
var cwd = "/";
|
||||
var file = new File({cwd: cwd});
|
||||
file.base.should.equal(cwd);
|
||||
file.basename.should.equal(cwd);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default base to cwd even when none is given', done => {
|
||||
var file = new File();
|
||||
file.base.should.equal(process.cwd());
|
||||
file.basename.should.equal(process.cwd());
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('File', () => {
|
||||
it('should set base to given value', done => {
|
||||
var val = "/";
|
||||
var file = new File({base: val});
|
||||
file.base.should.equal(val);
|
||||
file.basename.should.equal(val);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -84,6 +84,41 @@ describe('File', () => {
|
||||
file.contents.should.equal(val);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default basename to cwd', done => {
|
||||
var cwd = "/";
|
||||
var file = new File({cwd: cwd});
|
||||
file.basename.should.equal(cwd);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default basename to cwd even when none is given', done => {
|
||||
var file = new File();
|
||||
file.basename.should.equal(process.cwd());
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set basename to given value', done => {
|
||||
var val = "/";
|
||||
var file = new File({base: val});
|
||||
file.basename.should.equal(val);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default extname to null', done => {
|
||||
var cwd = "/";
|
||||
var file = new File({cwd: cwd});
|
||||
should.not.exist(file.path);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should default dirname to null', done => {
|
||||
var cwd = "/";
|
||||
var file = new File({cwd: cwd});
|
||||
should.not.exist(file.dirname);
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('isBuffer()', () => {
|
||||
@@ -149,33 +184,6 @@ describe('File', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDirectory()', () => {
|
||||
var fakeStat = <fs.Stats>{
|
||||
isDirectory() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
it('should return false when the contents are a Buffer', done => {
|
||||
var val = new Buffer("test");
|
||||
var file = new File({contents: val, stat: fakeStat});
|
||||
file.isDirectory().should.equal(false);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return false when the contents are a Stream', done => {
|
||||
var file = new File({ contents: fakeStream, stat: fakeStat});
|
||||
file.isDirectory().should.equal(false);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return true when the contents are a null', done => {
|
||||
var file = new File({contents: null, stat: fakeStat});
|
||||
file.isDirectory().should.equal(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('clone()', () => {
|
||||
it('should copy all attributes over with Buffer', done => {
|
||||
var options = {
|
||||
@@ -189,7 +197,7 @@ describe('File', () => {
|
||||
|
||||
file2.should.not.equal(file, 'refs should be different');
|
||||
file2.cwd.should.equal(file.cwd);
|
||||
file2.base.should.equal(file.base);
|
||||
file2.basename.should.equal(file.basename);
|
||||
file2.path.should.equal(file.path);
|
||||
|
||||
let fileContents = file.contents;
|
||||
@@ -220,7 +228,7 @@ describe('File', () => {
|
||||
|
||||
file2.should.not.equal(file, 'refs should be different');
|
||||
file2.cwd.should.equal(file.cwd);
|
||||
file2.base.should.equal(file.base);
|
||||
file2.basename.should.equal(file.basename);
|
||||
file2.path.should.equal(file.path);
|
||||
file2.contents.should.equal(file.contents, 'stream ref should be the same');
|
||||
done();
|
||||
@@ -238,7 +246,7 @@ describe('File', () => {
|
||||
|
||||
file2.should.not.equal(file, 'refs should be different');
|
||||
file2.cwd.should.equal(file.cwd);
|
||||
file2.base.should.equal(file.base);
|
||||
file2.basename.should.equal(file.basename);
|
||||
file2.path.should.equal(file.path);
|
||||
should.not.exist(file2.contents);
|
||||
done();
|
||||
@@ -258,7 +266,6 @@ describe('File', () => {
|
||||
|
||||
// ReSharper disable WrongExpressionStatement
|
||||
copy.stat.isFile().should.be.true;
|
||||
copy.stat.isDirectory().should.be.false;
|
||||
// ReSharper restore WrongExpressionStatement
|
||||
|
||||
done();
|
||||
@@ -437,7 +444,7 @@ describe('File', () => {
|
||||
path: "/test/test.coffee",
|
||||
contents: val
|
||||
});
|
||||
delete file.base;
|
||||
delete file.basename;
|
||||
file.inspect().should.equal('<File "/test/test.coffee" <Buffer 74 65 73 74>>');
|
||||
done();
|
||||
});
|
||||
@@ -515,7 +522,7 @@ describe('File', () => {
|
||||
it('should error on get when no base', done => {
|
||||
var a: string;
|
||||
var file = new File();
|
||||
delete file.base;
|
||||
delete file.basename;
|
||||
try {
|
||||
// ReSharper disable once AssignedValueIsNeverUsed
|
||||
a = file.relative;
|
||||
@@ -557,4 +564,95 @@ describe('File', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('path get/set', () => {
|
||||
|
||||
it('should return an absolute path', done => {
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee"
|
||||
});
|
||||
file.path.should.equal("/test/test.coffee");
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('history get', () => {
|
||||
it('should error on set', done => {
|
||||
var file = new File();
|
||||
try {
|
||||
file.history = [];
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should return an history', done => {
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee"
|
||||
});
|
||||
file.history.should.equal(["/test/test.coffee"]);
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('dirname get', () => {
|
||||
|
||||
it('should return an dirname', done => {
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee"
|
||||
});
|
||||
file.dirname.should.equal("test");
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set dirname to given value', done => {
|
||||
var file = new File();
|
||||
file.dirname = ".ext"
|
||||
file.dirname.should.equal(".ext")
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set dirname to null', done => {
|
||||
var file = new File();
|
||||
file.dirname = null
|
||||
should.not.exist(file.dirname)
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('extname get/set', () => {
|
||||
|
||||
it('should return an extname', done => {
|
||||
var file = new File({
|
||||
cwd: "/",
|
||||
base: "/test/",
|
||||
path: "/test/test.coffee"
|
||||
});
|
||||
file.dirname.should.equal(".coffee");
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set extname to given value', done => {
|
||||
var file = new File();
|
||||
file.extname = ".ext"
|
||||
file.extname.should.equal(".ext")
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set extname to null', done => {
|
||||
var file = new File();
|
||||
file.extname = null
|
||||
should.not.exist(file.extname)
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Vendored
+38
-4
@@ -1,4 +1,4 @@
|
||||
// Type definitions for vinyl 0.4.3
|
||||
// Type definitions for vinyl 1.1.0
|
||||
// Project: https://github.com/wearefractal/vinyl
|
||||
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -14,26 +14,32 @@ declare module "vinyl" {
|
||||
*/
|
||||
class File {
|
||||
constructor(options?: {
|
||||
|
||||
/**
|
||||
* Default: process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* Used for relative pathing. Typically where a glob starts.
|
||||
*/
|
||||
base?: string;
|
||||
|
||||
/**
|
||||
* Full path to the file.
|
||||
*/
|
||||
path?: string;
|
||||
|
||||
/**
|
||||
* Path history. Has no effect if options.path is passed.
|
||||
*/
|
||||
history?: string[];
|
||||
|
||||
/**
|
||||
* The result of an fs.stat call. See fs.Stats for more information.
|
||||
*/
|
||||
stat?: fs.Stats;
|
||||
|
||||
/**
|
||||
* File contents.
|
||||
* Type: Buffer, Stream, or null
|
||||
@@ -45,19 +51,40 @@ declare module "vinyl" {
|
||||
* Default: process.cwd()
|
||||
*/
|
||||
public cwd: string;
|
||||
|
||||
/**
|
||||
* Used for relative pathing. Typically where a glob starts.
|
||||
*/
|
||||
public dirname: string;
|
||||
public basename: string;
|
||||
public base: string;
|
||||
|
||||
/**
|
||||
* Full path to the file.
|
||||
*/
|
||||
public path: string;
|
||||
public stat: fs.Stats;
|
||||
|
||||
/**
|
||||
* Gets and sets stem (filename without suffix) for the file path.
|
||||
*/
|
||||
public stem: string;
|
||||
|
||||
/**
|
||||
* Gets and sets path.extname for the file path
|
||||
*/
|
||||
public extname: string;
|
||||
|
||||
/**
|
||||
* Array of path values the file object has had
|
||||
*/
|
||||
public history: string[];
|
||||
|
||||
/**
|
||||
* Type: Buffer|Stream|null (Default: null)
|
||||
*/
|
||||
public contents: Buffer | NodeJS.ReadableStream;
|
||||
|
||||
/**
|
||||
* Returns path.relative for the file base and file path.
|
||||
* Example:
|
||||
@@ -70,18 +97,25 @@ declare module "vinyl" {
|
||||
*/
|
||||
public relative: string;
|
||||
|
||||
/**
|
||||
* Returns true if file.contents is a Buffer.
|
||||
*/
|
||||
public isBuffer(): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if file.contents is a Stream.
|
||||
*/
|
||||
public isStream(): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if file.contents is null.
|
||||
*/
|
||||
public isNull(): boolean;
|
||||
|
||||
public isDirectory(): boolean;
|
||||
|
||||
/**
|
||||
* Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
|
||||
*/
|
||||
public clone(opts?: { contents?: boolean }): File;
|
||||
public clone(opts?: { contents?: boolean, deep?:boolean }): File;
|
||||
|
||||
/**
|
||||
* If file.contents is a Buffer, it will write it to the stream.
|
||||
|
||||
Vendored
+3
-3
@@ -35,8 +35,8 @@ declare module WebFont {
|
||||
monotype?:Monotype;
|
||||
}
|
||||
export interface Google {
|
||||
families?:Array<string>;
|
||||
text: string;
|
||||
families:Array<string>;
|
||||
text?: string;
|
||||
}
|
||||
export interface Typekit {
|
||||
id?:Array<string>;
|
||||
@@ -57,4 +57,4 @@ declare module WebFont {
|
||||
}
|
||||
declare module "webfontloader" {
|
||||
export = WebFont;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/// <reference path="./wiiu.d.ts" />
|
||||
|
||||
var state = window.wiiu.gamepad.update();
|
||||
if( !state.isEnabled || !state.isDataValid ){
|
||||
console.log('gyro X:' + state.gyroX.toString() + ' Y:' + state.gyroY.toString() + ' Z:' + state.gyroZ.toString());
|
||||
console.log('angle X:' + state.angleX.toString() + ' Y:' + state.angleY.toString() + ' Z:' + state.angleZ.toString());
|
||||
console.log('dirX X:' + state.dirXx.toString() + ' Y:' + state.dirXy.toString() + ' Z:' + state.dirXz.toString());
|
||||
console.log('dirY X:' + state.dirYx.toString() + ' Y:' + state.dirYy.toString() + ' Z:' + state.dirYz.toString());
|
||||
console.log('dirZ X:' + state.dirZx.toString() + ' Y:' + state.dirZy.toString() + ' Z:' + state.dirZz.toString());
|
||||
console.log('acc X:' + state.accX.toString() + ' Y:' + state.accY.toString() + ' Z:' + state.accZ.toString());
|
||||
console.log('LStick axis X:' + state.lStickX.toString() + ' Y:' + state.lStickY.toString());
|
||||
console.log('RStick axis X:' + state.rStickX.toString() + ' Y:' + state.rStickY.toString());
|
||||
|
||||
if(state.hold & window.wiiu.Button.A){
|
||||
console.log('pushing A button');
|
||||
}
|
||||
|
||||
if( state.tpTouch && state.tpValidity == window.wiiu.TPValidity.VALID ){
|
||||
console.log("touch X:" + state.contentX.toString() + " Y:" + state.contentY.toString());
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('video').addEventListener('wiiu_videoplayer_end', (e) => {
|
||||
console.log(e);
|
||||
console.log('VideoPlayer end');
|
||||
});
|
||||
|
||||
if(window.wiiu.videoplayer.viewMode == 0){
|
||||
window.wiiu.videoplayer.viewMode = 1;
|
||||
}
|
||||
window.wiiu.videoplayer.end();
|
||||
|
||||
window.addEventListener('wiiu_imageview_start', (e) => {
|
||||
console.log(e);
|
||||
console.log('ImageViewer start');
|
||||
});
|
||||
window.addEventListener('wiiu_imageview_end', (e) => {
|
||||
console.log(e);
|
||||
console.log('ImageViewer end');
|
||||
});
|
||||
window.addEventListener('wiiu_imageview_change_viewmode', (e) => {
|
||||
console.log(e);
|
||||
console.log('ImageViewer change viewmode');
|
||||
if(window.wiiu.imageview.viewMode == 1){
|
||||
window.wiiu.imageview.viewMode = 0;
|
||||
}
|
||||
});
|
||||
window.addEventListener('wiiu_imageview_change_content', (e) => {
|
||||
console.log(e);
|
||||
console.log('ImageViewer change content');
|
||||
});
|
||||
window.addEventListener('wiiu_imageview_error', (e) => {
|
||||
console.log(e);
|
||||
console.log('ImageViewer error');
|
||||
console.log(window.wiiu.imageview.getErrorCode());
|
||||
});
|
||||
Vendored
+112
@@ -0,0 +1,112 @@
|
||||
// Type definitions for Extended Functionality of Wii U Internet Browser
|
||||
// Project: https://www.nintendo.co.jp/wiiu/hardware/internetbrowser/extended_functionality.html
|
||||
// Definitions by: MIZUSHIMA Junki <https://github.com/mzsm>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module wiiu {
|
||||
const enum TPValidity {
|
||||
VALID = 0,
|
||||
X_INVALID = 1,
|
||||
Y_INVALID = 2,
|
||||
INVALID = 3
|
||||
}
|
||||
const enum Button {
|
||||
MINUS = 0x00000004,
|
||||
SELECT = MINUS,
|
||||
PLUS = 0x00000008,
|
||||
START = PLUS,
|
||||
R = 0x00000010,
|
||||
L = 0x00000020,
|
||||
ZR = 0x00000040,
|
||||
ZL = 0x00000080,
|
||||
DOWN = 0x00000100,
|
||||
UP = 0x00000200,
|
||||
RIGHT = 0x00000400,
|
||||
LEFT = 0x00000800,
|
||||
Y = 0x00001000,
|
||||
X = 0x00002000,
|
||||
B = 0x00004000,
|
||||
A = 0x00008000,
|
||||
R_STICK = 0x00020000,
|
||||
L_STICK = 0x00040000,
|
||||
R_STICK_DOWN = 0x00800000,
|
||||
R_STICK_UP = 0x01000000,
|
||||
R_STICK_RIGHT = 0x02000000,
|
||||
R_STICK_LEFT = 0x04000000,
|
||||
L_STICK_DOWN = 0x08000000,
|
||||
L_STICK_UP = 0x10000000,
|
||||
L_STICK_RIGHT = 0x20000000,
|
||||
L_STICK_LEFT = 0x40000000
|
||||
}
|
||||
|
||||
interface WiiuGamePad {
|
||||
isEnabled: boolean;
|
||||
isDataValid: boolean;
|
||||
tpTouch: boolean;
|
||||
tpValidity: number;
|
||||
contentX: number;
|
||||
contentY: number;
|
||||
lStickX: number;
|
||||
lStickY: number;
|
||||
rStickX: number;
|
||||
rStickY: number;
|
||||
hold: number;
|
||||
accX: number;
|
||||
accY: number;
|
||||
accZ: number;
|
||||
gyroX: number;
|
||||
gyroY: number;
|
||||
gyroZ: number;
|
||||
angleX: number;
|
||||
angleY: number;
|
||||
angleZ: number;
|
||||
dirXx: number;
|
||||
dirXy: number;
|
||||
dirYx: number;
|
||||
dirXz: number;
|
||||
dirYy: number;
|
||||
dirYz: number;
|
||||
dirZx: number;
|
||||
dirZz: number;
|
||||
dirZy: number;
|
||||
|
||||
update(): WiiuGamePad;
|
||||
}
|
||||
|
||||
interface VideoPlayer {
|
||||
viewMode: number;
|
||||
|
||||
end(): boolean;
|
||||
}
|
||||
|
||||
const enum ImageViewErrorCode {
|
||||
UNSUPPORTED_FORMAT = 202,
|
||||
DIMENSIONS_TOO_LARGE = 203,
|
||||
FILE_SIZE_TOO_LARGE = 204,
|
||||
TOO_MANY_PIXELS_PROGRESSIVE_JPEG = 205
|
||||
}
|
||||
|
||||
interface ImageView {
|
||||
viewMode: number;
|
||||
|
||||
end(): boolean;
|
||||
getErrorCode(): number;
|
||||
}
|
||||
|
||||
var gamepad: WiiuGamePad;
|
||||
var videoplayer: VideoPlayer;
|
||||
var imageview: ImageView;
|
||||
}
|
||||
|
||||
interface HTMLElement {
|
||||
addEventListener(type: "wiiu_videoplayer_end", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
interface Window {
|
||||
wiiu: typeof wiiu;
|
||||
addEventListener(type: "wiiu_imageview_start", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "wiiu_imageview_end", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "wiiu_imageview_change_viewmode", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "wiiu_imageview_change_content", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "wiiu_imageview_error", listener: (ev: CustomEvent) => any, useCapture?: boolean): void;
|
||||
}
|
||||
Reference in New Issue
Block a user