From 4a86ba7d7f9227dc68c970f05dd667992fd8f40a Mon Sep 17 00:00:00 2001 From: Ryan McNamara Date: Wed, 9 Sep 2015 11:19:57 -0700 Subject: [PATCH 1/2] added definitely typed files and tests for flowjs and ngflow --- flowjs/flow/flowjs-tests.ts | 78 ++++++++++++++++++++++++++++++ flowjs/flow/flowjs.d.ts | 85 +++++++++++++++++++++++++++++++++ flowjs/ng-flow/ng-flow-tests.ts | 4 ++ flowjs/ng-flow/ng-flow.d.ts | 11 +++++ 4 files changed, 178 insertions(+) create mode 100644 flowjs/flow/flowjs-tests.ts create mode 100644 flowjs/flow/flowjs.d.ts create mode 100644 flowjs/ng-flow/ng-flow-tests.ts create mode 100644 flowjs/ng-flow/ng-flow.d.ts diff --git a/flowjs/flow/flowjs-tests.ts b/flowjs/flow/flowjs-tests.ts new file mode 100644 index 000000000..8bedad003 --- /dev/null +++ b/flowjs/flow/flowjs-tests.ts @@ -0,0 +1,78 @@ +/// + +// flow object +var flowObject: flowjs.IFlow; +var bool: boolean = flowObject.support; +bool = flowObject.supportDirectory; +var obj: Object = flowObject.opts; +var flowFileArray: flowjs.IFlowFile[] = flowObject.files; + +flowObject.assignBrowse( [], false, false, {}); +flowObject.assignDrop( []); +flowObject.unAssignDrop( []); +flowObject.on("", () => {}); +flowObject.off("", () => {}); +flowObject.upload(); +flowObject.pause(); +flowObject.resume(); +flowObject.cancel(); +flowObject.progress(); +bool = flowObject.isUploading(); +flowObject.addFile( {}); +flowObject.removeFile( {}); +var flowFile: flowjs.IFlowFile = flowObject.getFromUniqueIdentifier(""); +var num: number = flowObject.getSize(); +num = flowObject.sizeUploaded(); +num = flowObject.timeRemaining(); + +// flow options +var flowOptions: flowjs.IFlowOptions = {}; +flowOptions.target = ""; +flowOptions.singleFile = true; +flowOptions.chunkSize= 0; +flowOptions.forceChunkSize = true; +flowOptions.simultaneousUploads= 0; +flowOptions.fileParameterName = ""; +flowOptions.query = {}; +flowOptions.headers = {}; +flowOptions.withCredentials = true; +flowOptions.method = ""; +flowOptions.testMethod = ""; +flowOptions.uploadMethod = ""; +flowOptions.allowDuplicateUploads = true; +flowOptions.prioritizeFirstAndLastChunk = true; +flowOptions.testchunks = true; +flowOptions.preprocess = () => {}; +flowOptions.initFileFn = () => {}; +flowOptions.generateUniqueIdentifier = () => {}; +flowOptions.maxChunkRetries= 0; +flowOptions.chunkRetryInterval= 0; +flowOptions.progressCallbacksInterval= 0; +flowOptions.speedSmoothingFactor= 0; +flowOptions.successStatuses = [""]; +flowOptions.permanentErrors = [""]; + +// flow file +flowObject = flowFile.flowObj; +var htmlFile: File = flowFile.file; +var str: string = flowFile.name; +str = flowFile.relativePath; +num = flowFile.size; +str = flowFile.uniqueIdentifier; +num = flowFile.averageSpeed; +num = flowFile.currentSpeed; +var anyArray: any[] = flowFile.chunks; +bool = flowFile.paused; +bool = flowFile.error; +num = flowFile.progress(true); +flowFile.pause(); +flowFile.resume(); +flowFile.cancel(); +flowFile.retry(); +flowFile.bootstrap(); +bool = flowFile.isUploading(); +bool = flowFile.isComplete; +num = flowFile.sizeUploaded; +num = flowFile.timeRemaining; +str = flowFile.getExtension; +str = flowFile.getType; diff --git a/flowjs/flow/flowjs.d.ts b/flowjs/flow/flowjs.d.ts new file mode 100644 index 000000000..e9e90055b --- /dev/null +++ b/flowjs/flow/flowjs.d.ts @@ -0,0 +1,85 @@ +// Type definitions for flowjs +// Project: https://github.com/flowjs/flow.js +// Definitions by: Ryan McNamara +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module flowjs { + interface IFlow { + support: boolean; + supportDirectory: boolean; + opts: Object; + files: IFlowFile[]; + + assignBrowse(domNodes: HTMLElement[], isDirectory: boolean, singleFile: boolean, attributes: Object): void; + assignDrop(domNodes: HTMLElement[]): void; + unAssignDrop(domNodes: HTMLElement[]): void; + on(event: string, callback: Function): void; + off(event?: string, callback?: Function): void; + upload(): void; + pause(): void; + resume(): void; + cancel(): void; + progress(): number; + isUploading(): boolean; + addFile(file: File): void; + removeFile(file: IFlowFile): void; + getFromUniqueIdentifier(uniqueIdentifier: string): IFlowFile; + getSize(): number; + sizeUploaded(): number; + timeRemaining(): number; + } + + interface IFlowOptions { + target?: string; + singleFile?: boolean; + chunkSize?: number; + forceChunkSize?: boolean; + simultaneousUploads?: number; + fileParameterName?: string; + query?: Object; + headers?: Object; + withCredentials?: boolean; + method?: string; + testMethod?: string; + uploadMethod?: string; + allowDuplicateUploads?: boolean; + prioritizeFirstAndLastChunk?: boolean; + testchunks?: boolean; + preprocess?: Function; + initFileFn?: Function; + generateUniqueIdentifier?: Function; + maxChunkRetries?: number; + chunkRetryInterval?: number; + progressCallbacksInterval?: number; + speedSmoothingFactor?: number; + successStatuses?: string[]; + permanentErrors?: string[]; + } + + interface IFlowFile { + flowObj: IFlow; + file: File; + name: string; + relativePath: string; + size: number; + uniqueIdentifier: string; + averageSpeed: number; + currentSpeed: number; + chunks: any[]; + paused: boolean; + error: boolean; + + progress(relative: boolean): number; + pause(): void; + resume(): void; + cancel(): void; + retry(): void; + bootstrap(): void; + isUploading(): boolean; + isComplete: boolean; + sizeUploaded: number; + timeRemaining: number; + getExtension: string; + getType: string; + } +} diff --git a/flowjs/ng-flow/ng-flow-tests.ts b/flowjs/ng-flow/ng-flow-tests.ts new file mode 100644 index 000000000..beca6583c --- /dev/null +++ b/flowjs/ng-flow/ng-flow-tests.ts @@ -0,0 +1,4 @@ +/// + +var flowFactory: ng.flow.IFlowFactory; +flowFactory.create( {}); diff --git a/flowjs/ng-flow/ng-flow.d.ts b/flowjs/ng-flow/ng-flow.d.ts new file mode 100644 index 000000000..4ea0afefe --- /dev/null +++ b/flowjs/ng-flow/ng-flow.d.ts @@ -0,0 +1,11 @@ +// Type definitions for ng-flow +// Project: https://github.com/flowjs/ng-flow +// Definitions by: Ryan McNamara +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + +declare module ng.flow { + interface IFlowFactory { + create(options?: flowjs.IFlowOptions): flowjs.IFlow; + } +} From b8a280ebbbe4af4c21256aeaad46c66f4941d3ca Mon Sep 17 00:00:00 2001 From: Ryan McNamara Date: Thu, 17 Sep 2015 11:24:00 -0700 Subject: [PATCH 2/2] renamed flowjs/flow/* to flowjs/* and flowjs/ng-flow/* to ng-flow/* --- flowjs/{flow => }/flowjs-tests.ts | 0 flowjs/{flow => }/flowjs.d.ts | 0 {flowjs/ng-flow => ng-flow}/ng-flow-tests.ts | 0 {flowjs/ng-flow => ng-flow}/ng-flow.d.ts | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) rename flowjs/{flow => }/flowjs-tests.ts (100%) rename flowjs/{flow => }/flowjs.d.ts (100%) rename {flowjs/ng-flow => ng-flow}/ng-flow-tests.ts (100%) rename {flowjs/ng-flow => ng-flow}/ng-flow.d.ts (87%) diff --git a/flowjs/flow/flowjs-tests.ts b/flowjs/flowjs-tests.ts similarity index 100% rename from flowjs/flow/flowjs-tests.ts rename to flowjs/flowjs-tests.ts diff --git a/flowjs/flow/flowjs.d.ts b/flowjs/flowjs.d.ts similarity index 100% rename from flowjs/flow/flowjs.d.ts rename to flowjs/flowjs.d.ts diff --git a/flowjs/ng-flow/ng-flow-tests.ts b/ng-flow/ng-flow-tests.ts similarity index 100% rename from flowjs/ng-flow/ng-flow-tests.ts rename to ng-flow/ng-flow-tests.ts diff --git a/flowjs/ng-flow/ng-flow.d.ts b/ng-flow/ng-flow.d.ts similarity index 87% rename from flowjs/ng-flow/ng-flow.d.ts rename to ng-flow/ng-flow.d.ts index 4ea0afefe..bc8521b68 100644 --- a/flowjs/ng-flow/ng-flow.d.ts +++ b/ng-flow/ng-flow.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/flowjs/ng-flow // Definitions by: Ryan McNamara // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// declare module ng.flow { interface IFlowFactory {