mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
improve types for flowjs
This commit is contained in:
Vendored
+2
-1
@@ -1,6 +1,7 @@
|
||||
// Type definitions for flowjs
|
||||
// Type definitions for flowjs 2.13
|
||||
// Project: https://github.com/flowjs/flow.js
|
||||
// Definitions by: Ryan McNamara <https://github.com/ryan10132>
|
||||
// Martin Nuc <https://github.com/martinnuc>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace flowjs {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"types": "index",
|
||||
"typesVersions": {
|
||||
">=3.1.0-0": { "*": ["ts3.1/*"] }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// flow object
|
||||
let flowObject!: flowjs.Flow;
|
||||
let bool: boolean = flowObject.support;
|
||||
bool = flowObject.supportDirectory;
|
||||
let flowOpts: flowjs.FlowOptions = flowObject.opts;
|
||||
let flowFileArray: flowjs.FlowFile[] = flowObject.files;
|
||||
let flowChunkParams: flowjs.FlowChunkParams;
|
||||
|
||||
flowObject.assignBrowse(<HTMLElement[]> []);
|
||||
flowObject.assignBrowse(<HTMLElement[]> [], false, false, {});
|
||||
flowObject.assignDrop(<HTMLElement[]> []);
|
||||
flowObject.unAssignDrop(<HTMLElement[]> []);
|
||||
flowObject.on("fileSuccess", (file: flowjs.FlowFile, serverMessage: string, chunk: flowjs.FlowChunk) => {});
|
||||
flowObject.off("fileSuccess", () => {});
|
||||
flowObject.upload();
|
||||
flowObject.pause();
|
||||
flowObject.resume();
|
||||
flowObject.cancel();
|
||||
flowObject.progress();
|
||||
bool = flowObject.isUploading();
|
||||
flowObject.addFile({} as any as File);
|
||||
flowObject.removeFile({} as any as flowjs.FlowFile);
|
||||
let flowFile: flowjs.FlowFile = flowObject.getFromUniqueIdentifier("");
|
||||
let num: number = flowObject.getSize();
|
||||
num = flowObject.sizeUploaded();
|
||||
num = flowObject.timeRemaining();
|
||||
|
||||
// flow options
|
||||
let flowOptions: flowjs.FlowOptions = {};
|
||||
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;
|
||||
let htmlFile: File = flowFile.file;
|
||||
let str: string = flowFile.name;
|
||||
str = flowFile.relativePath;
|
||||
num = flowFile.size;
|
||||
str = flowFile.uniqueIdentifier;
|
||||
num = flowFile.averageSpeed;
|
||||
num = flowFile.currentSpeed;
|
||||
let chunksArray: ReadonlyArray<flowjs.FlowChunk> = flowFile.chunks;
|
||||
chunksArray[0].abort();
|
||||
num = chunksArray[0].chunkSize;
|
||||
num = chunksArray[0].endByte;
|
||||
flowFile = chunksArray[0].fileObj;
|
||||
flowObject = chunksArray[0].flowObj;
|
||||
flowChunkParams = chunksArray[0].getParams();
|
||||
num = chunksArray[0].startByte;
|
||||
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();
|
||||
Vendored
+159
@@ -0,0 +1,159 @@
|
||||
declare namespace flowjs {
|
||||
interface Flow {
|
||||
support: boolean;
|
||||
supportDirectory: boolean;
|
||||
opts: FlowOptions;
|
||||
files: FlowFile[];
|
||||
|
||||
assignBrowse(
|
||||
domNodes: ReadonlyArray<HTMLElement>,
|
||||
isDirectory?: boolean,
|
||||
singleFile?: boolean,
|
||||
attributes?: object
|
||||
): void;
|
||||
assignDrop(node: HTMLElement | ReadonlyArray<HTMLElement>): void;
|
||||
unAssignDrop(node: HTMLElement | ReadonlyArray<HTMLElement>): void;
|
||||
on<T extends EventName>(event: T, callback: (...args: FlowEventMap[T]) => void): void;
|
||||
off(event?: EventName, callback?: () => void): void;
|
||||
upload(): void;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
cancel(): void;
|
||||
progress(): number;
|
||||
isUploading(): boolean;
|
||||
addFile(file: File): void;
|
||||
removeFile(file: FlowFile): void;
|
||||
getFromUniqueIdentifier(uniqueIdentifier: string): FlowFile;
|
||||
getSize(): number;
|
||||
sizeUploaded(): number;
|
||||
timeRemaining(): number;
|
||||
}
|
||||
|
||||
interface FlowOptions {
|
||||
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?: (chunk: FlowChunk) => void;
|
||||
initFileFn?: (file: FlowFile, chunk: FlowChunk) => void;
|
||||
readFileFn?: (file: FlowFile, startByte: number, endByte: number, fileType: string, chunk: FlowChunk) => void;
|
||||
generateUniqueIdentifier?: (file: FlowFile) => any;
|
||||
maxChunkRetries?: number;
|
||||
chunkRetryInterval?: number;
|
||||
progressCallbacksInterval?: number;
|
||||
speedSmoothingFactor?: number;
|
||||
successStatuses?: string[];
|
||||
permanentErrors?: string[];
|
||||
}
|
||||
|
||||
interface FlowFile {
|
||||
flowObj: Flow;
|
||||
file: File;
|
||||
name: string;
|
||||
relativePath: string;
|
||||
size: number;
|
||||
uniqueIdentifier: string;
|
||||
averageSpeed: number;
|
||||
currentSpeed: number;
|
||||
chunks: ReadonlyArray<FlowChunk>;
|
||||
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;
|
||||
}
|
||||
|
||||
interface FlowChunk {
|
||||
flowObj: Flow;
|
||||
fileObj: FlowFile;
|
||||
offset: number;
|
||||
tested: boolean;
|
||||
retries: number;
|
||||
pendingRetry: false;
|
||||
preprocessState: 0 | 1 | 2;
|
||||
readState: 0 | 1 | 2;
|
||||
loaded: number;
|
||||
total: number;
|
||||
chunkSize: number;
|
||||
startByte: number;
|
||||
endByte: number;
|
||||
xhr: XMLHttpRequest;
|
||||
getParams(): FlowChunkParams;
|
||||
test(): void;
|
||||
send(): void;
|
||||
abort(): void;
|
||||
status(): void;
|
||||
message(): void;
|
||||
progress(): void;
|
||||
sizeUploaded(): number;
|
||||
}
|
||||
|
||||
interface FlowChunkParams {
|
||||
flowChunkNumber: number;
|
||||
flowChunkSize: number;
|
||||
flowCurrentChunkSize: number;
|
||||
flowTotalSize: number;
|
||||
flowIdentifier: any;
|
||||
flowFilename: string;
|
||||
flowRelativePath: string;
|
||||
flowTotalChunks: number;
|
||||
}
|
||||
|
||||
interface FlowEventMap {
|
||||
fileSuccess: FileSuccessCallbackArguments;
|
||||
fileProgress: FileProgressCallbackArguments;
|
||||
fileAdded: FilesAddedCallbackArguments;
|
||||
filesAdded: FileAddedCallbackArguments;
|
||||
filesSubmitted: FilesSubmittedCallbackArguments;
|
||||
fileRemoved: FileRemovedCallbackArguments;
|
||||
fileRetry: FileRetryCallbackArguments;
|
||||
fileError: FileErrorCallbackArguments;
|
||||
uploadStart: UploadStartCallbackArguments;
|
||||
complete: UploadStartCallbackArguments;
|
||||
progress: ProgressCallbackArguments;
|
||||
error: ErrorCallbackArguments;
|
||||
catchAll: CatchAllCallbackArguments;
|
||||
}
|
||||
|
||||
type EventName = keyof FlowEventMap;
|
||||
type FlowEvent = FlowEventMap[keyof FlowEventMap];
|
||||
|
||||
type FlowEventFromEventName<T extends EventName> = FlowEventMap[T];
|
||||
type FlowEventTypeFromFlowEvent<T extends FlowEvent> =
|
||||
T extends FlowEventFromEventName<infer U> ? U : never;
|
||||
|
||||
type FileSuccessCallbackArguments = [FlowFile, string, FlowChunk];
|
||||
type FileProgressCallbackArguments = [FlowFile, FlowChunk];
|
||||
type FileAddedCallbackArguments = [FlowFile, Event];
|
||||
type FilesAddedCallbackArguments = [FlowFile[], Event];
|
||||
type FilesSubmittedCallbackArguments = [FlowFile[], Event];
|
||||
type FileRemovedCallbackArguments = [FlowFile];
|
||||
type FileRetryCallbackArguments = [FlowFile, FlowChunk];
|
||||
type FileErrorCallbackArguments = [FlowFile, string, FlowChunk];
|
||||
type UploadStartCallbackArguments = [];
|
||||
type CompleteCallbackArguments = [];
|
||||
type ProgressCallbackArguments = [];
|
||||
type ErrorCallbackArguments = [string, FlowFile, FlowChunk];
|
||||
type CatchAllCallbackArguments = [Event];
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": ["../../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "flowjs-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
@@ -1,6 +1,7 @@
|
||||
// Type definitions for ng-flow
|
||||
// Project: https://github.com/flowjs/ng-flow
|
||||
// Definitions by: Ryan McNamara <https://github.com/ryan10132>
|
||||
// Martin Nuc <https://github.com/martinnuc>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
/// <reference types="flowjs" />
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"types": "index",
|
||||
"typesVersions": {
|
||||
">=3.1.0-0": { "*": ["ts3.1/*"] }
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
/// <reference types="flowjs" />
|
||||
|
||||
import * as angular from 'angular';
|
||||
|
||||
declare module 'angular' {
|
||||
namespace flow {
|
||||
interface FlowFactory {
|
||||
create(options?: flowjs.FlowOptions): flowjs.Flow;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
let flowFactory: ng.flow.FlowFactory;
|
||||
flowFactory.create({} as any as flowjs.FlowOptions);
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": ["../../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "ng-flow-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user