pure-upload
Advanced tools
Comparing version 5.4.0 to 5.5.0
# CHANGELOG | ||
## 5.5.0 | ||
Update to TS 3.8.3 and other fixed dependencies | ||
## 5.4.0 | ||
@@ -4,0 +8,0 @@ |
60
index.js
@@ -709,32 +709,2 @@ "use strict"; | ||
exports.UploadCore = UploadCore; | ||
var Uploader = /** @class */ (function () { | ||
function Uploader(options, callbacks) { | ||
if (options === void 0) { options = {}; } | ||
if (callbacks === void 0) { callbacks = {}; } | ||
this.options = options; | ||
this.uploadAreas = []; | ||
this.queue = new UploadQueue(options, callbacks); | ||
} | ||
Uploader.prototype.registerArea = function (element, options) { | ||
var uploadArea = new UploadArea(element, options, this); | ||
this.uploadAreas.push(uploadArea); | ||
return uploadArea; | ||
}; | ||
Uploader.prototype.unregisterArea = function (area) { | ||
var areaIndex = this.uploadAreas.indexOf(area); | ||
if (areaIndex >= 0) { | ||
this.uploadAreas[areaIndex].destroy(); | ||
this.uploadAreas.splice(areaIndex, 1); | ||
} | ||
}; | ||
Object.defineProperty(Uploader.prototype, "firstUploadArea", { | ||
get: function () { | ||
return this.uploadAreas[0]; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Uploader; | ||
}()); | ||
exports.Uploader = Uploader; | ||
var UploadQueue = /** @class */ (function () { | ||
@@ -917,1 +887,31 @@ function UploadQueue(options, callbacks) { | ||
})(UploadStatus = exports.UploadStatus || (exports.UploadStatus = {})); | ||
var Uploader = /** @class */ (function () { | ||
function Uploader(options, callbacks) { | ||
if (options === void 0) { options = {}; } | ||
if (callbacks === void 0) { callbacks = {}; } | ||
this.options = options; | ||
this.uploadAreas = []; | ||
this.queue = new UploadQueue(options, callbacks); | ||
} | ||
Uploader.prototype.registerArea = function (element, options) { | ||
var uploadArea = new UploadArea(element, options, this); | ||
this.uploadAreas.push(uploadArea); | ||
return uploadArea; | ||
}; | ||
Uploader.prototype.unregisterArea = function (area) { | ||
var areaIndex = this.uploadAreas.indexOf(area); | ||
if (areaIndex >= 0) { | ||
this.uploadAreas[areaIndex].destroy(); | ||
this.uploadAreas.splice(areaIndex, 1); | ||
} | ||
}; | ||
Object.defineProperty(Uploader.prototype, "firstUploadArea", { | ||
get: function () { | ||
return this.uploadAreas[0]; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Uploader; | ||
}()); | ||
exports.Uploader = Uploader; |
286
index.ts
@@ -0,1 +1,35 @@ | ||
export // See: https://wicg.github.io/entries-api | ||
type ErrorCallback = (err: DOMException) => void; | ||
type FileCallback = (file: File) => void; | ||
type FilesCallback = (file: File[]) => void; | ||
type FileSystemEntriesCallback = (entries: FileSystemEntry[]) => void; | ||
interface FileSystemEntry { | ||
readonly isDirectory: boolean; | ||
readonly isFile: boolean; | ||
readonly name: string; | ||
} | ||
interface FileSystemDirectoryEntry extends FileSystemEntry { | ||
createReader(): FileSystemDirectoryReader; | ||
} | ||
interface FileSystemDirectoryReader { | ||
readEntries(successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback): void; | ||
} | ||
interface FileSystemFileEntry extends FileSystemEntry { | ||
getAsFile(): File | null; | ||
file(successCallback: FileCallback, errorCallback?: ErrorCallback): void; | ||
} | ||
interface IFileExt extends File { | ||
fullPath: string; | ||
kind: string; | ||
} | ||
export function addEventHandler( | ||
@@ -136,36 +170,2 @@ el: Element | HTMLElement, | ||
export // See: https://wicg.github.io/entries-api | ||
type ErrorCallback = (err: DOMException) => void; | ||
type FileCallback = (file: File) => void; | ||
type FilesCallback = (file: File[]) => void; | ||
type FileSystemEntriesCallback = (entries: FileSystemEntry[]) => void; | ||
interface FileSystemEntry { | ||
readonly isDirectory: boolean; | ||
readonly isFile: boolean; | ||
readonly name: string; | ||
} | ||
interface FileSystemDirectoryEntry extends FileSystemEntry { | ||
createReader(): FileSystemDirectoryReader; | ||
} | ||
interface FileSystemDirectoryReader { | ||
readEntries(successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback): void; | ||
} | ||
interface FileSystemFileEntry extends FileSystemEntry { | ||
getAsFile(): File | null; | ||
file(successCallback: FileCallback, errorCallback?: ErrorCallback): void; | ||
} | ||
interface IFileExt extends File { | ||
fullPath: string; | ||
kind: string; | ||
} | ||
export interface IFullUploadAreaOptions extends IUploadAreaOptions { | ||
@@ -215,2 +215,78 @@ maxFileSize: number; | ||
export interface IUploadAreaOptions extends IUploadOptions { | ||
maxFileSize?: number; | ||
allowDragDrop?: boolean | (() => boolean); | ||
clickable?: boolean | (() => boolean); | ||
accept?: string; | ||
multiple?: boolean; | ||
validateExtension?: boolean; | ||
manualStart?: boolean; | ||
allowEmptyFile?: boolean; | ||
dragOverStyle?: string; | ||
dragOverGlobalStyle?: string; | ||
useCapture?: boolean; | ||
onFileAdded?: (file: IUploadFile) => void; | ||
onFileSelected?: (file: IUploadFile) => void; | ||
onFilesSelected?: (file: IUploadFile[]) => void; | ||
onFileError?: (file: IUploadFile) => void; | ||
onFileCanceled?: (file: IUploadFile) => void; | ||
} | ||
export interface IUploadCallbacks { | ||
onProgressCallback?: (file: IUploadFile) => void; | ||
onCancelledCallback?: (file: IUploadFile) => void; | ||
onFinishedCallback?: (file: IUploadFile) => void; | ||
onUploadedCallback?: (file: IUploadFile) => void; | ||
onErrorCallback?: (file: IUploadFile) => void; | ||
onUploadStartedCallback?: (file: IUploadFile) => void; | ||
} | ||
export interface IUploadCallbacksExt extends IUploadCallbacks { | ||
onFileStateChangedCallback?: (file: IUploadFile) => void; | ||
} | ||
export interface IUploadFile extends File { | ||
guid: string; | ||
url: string; | ||
uploadStatus: UploadStatus; | ||
responseCode: number; | ||
responseText: string; | ||
progress: number; | ||
sentBytes: number; | ||
cancel: () => void; | ||
remove: () => void; | ||
start: () => void; | ||
onError: (file: IUploadFile) => void; | ||
onCancel: (file: IUploadFile) => void; | ||
} | ||
export interface IUploadOptions { | ||
url: string | ((file: IUploadFile) => string); | ||
method: string; | ||
withCredentials?: boolean; | ||
headers?: { [key: string]: string | number | boolean }; | ||
params?: { [key: string]: string | number | boolean | Blob }; | ||
localizer?: ILocalizer; | ||
} | ||
export interface IUploadQueueCallbacks extends IUploadCallbacks { | ||
onFileAddedCallback?: (file: IUploadFile) => void; | ||
onFileRemovedCallback?: (file: IUploadFile) => void; | ||
onAllFinishedCallback?: () => void; | ||
onQueueChangedCallback?: (queue: IUploadFile[]) => void; | ||
} | ||
export interface IUploadQueueCallbacksExt | ||
extends IUploadQueueCallbacks, | ||
IUploadCallbacksExt {} | ||
export interface IUploadQueueOptions { | ||
maxParallelUploads?: number; | ||
parallelBatchOffset?: number; | ||
autoStart?: boolean; | ||
autoRemove?: boolean; | ||
} | ||
export class ItemProcessor { | ||
@@ -293,78 +369,2 @@ errors: Error[] = []; | ||
export interface IUploadAreaOptions extends IUploadOptions { | ||
maxFileSize?: number; | ||
allowDragDrop?: boolean | (() => boolean); | ||
clickable?: boolean | (() => boolean); | ||
accept?: string; | ||
multiple?: boolean; | ||
validateExtension?: boolean; | ||
manualStart?: boolean; | ||
allowEmptyFile?: boolean; | ||
dragOverStyle?: string; | ||
dragOverGlobalStyle?: string; | ||
useCapture?: boolean; | ||
onFileAdded?: (file: IUploadFile) => void; | ||
onFileSelected?: (file: IUploadFile) => void; | ||
onFilesSelected?: (file: IUploadFile[]) => void; | ||
onFileError?: (file: IUploadFile) => void; | ||
onFileCanceled?: (file: IUploadFile) => void; | ||
} | ||
export interface IUploadCallbacks { | ||
onProgressCallback?: (file: IUploadFile) => void; | ||
onCancelledCallback?: (file: IUploadFile) => void; | ||
onFinishedCallback?: (file: IUploadFile) => void; | ||
onUploadedCallback?: (file: IUploadFile) => void; | ||
onErrorCallback?: (file: IUploadFile) => void; | ||
onUploadStartedCallback?: (file: IUploadFile) => void; | ||
} | ||
export interface IUploadCallbacksExt extends IUploadCallbacks { | ||
onFileStateChangedCallback?: (file: IUploadFile) => void; | ||
} | ||
export interface IUploadFile extends File { | ||
guid: string; | ||
url: string; | ||
uploadStatus: UploadStatus; | ||
responseCode: number; | ||
responseText: string; | ||
progress: number; | ||
sentBytes: number; | ||
cancel: () => void; | ||
remove: () => void; | ||
start: () => void; | ||
onError: (file: IUploadFile) => void; | ||
onCancel: (file: IUploadFile) => void; | ||
} | ||
export interface IUploadOptions { | ||
url: string | ((file: IUploadFile) => string); | ||
method: string; | ||
withCredentials?: boolean; | ||
headers?: { [key: string]: string | number | boolean }; | ||
params?: { [key: string]: string | number | boolean | Blob }; | ||
localizer?: ILocalizer; | ||
} | ||
export interface IUploadQueueCallbacks extends IUploadCallbacks { | ||
onFileAddedCallback?: (file: IUploadFile) => void; | ||
onFileRemovedCallback?: (file: IUploadFile) => void; | ||
onAllFinishedCallback?: () => void; | ||
onQueueChangedCallback?: (queue: IUploadFile[]) => void; | ||
} | ||
export interface IUploadQueueCallbacksExt | ||
extends IUploadQueueCallbacks, | ||
IUploadCallbacksExt {} | ||
export interface IUploadQueueOptions { | ||
maxParallelUploads?: number; | ||
parallelBatchOffset?: number; | ||
autoStart?: boolean; | ||
autoRemove?: boolean; | ||
} | ||
export function removeEventHandler( | ||
@@ -952,35 +952,2 @@ el: HTMLInputElement | Element, | ||
export class Uploader { | ||
uploadAreas: UploadArea[]; | ||
queue: UploadQueue; | ||
options: IUploadQueueOptions; | ||
constructor( | ||
options: IUploadQueueOptions = {}, | ||
callbacks: IUploadQueueCallbacks = {} | ||
) { | ||
this.options = options; | ||
this.uploadAreas = []; | ||
this.queue = new UploadQueue(options, callbacks); | ||
} | ||
registerArea(element: HTMLElement, options: IUploadAreaOptions): UploadArea { | ||
const uploadArea = new UploadArea(element, options, this); | ||
this.uploadAreas.push(uploadArea); | ||
return uploadArea; | ||
} | ||
unregisterArea(area: UploadArea): void { | ||
const areaIndex = this.uploadAreas.indexOf(area); | ||
if (areaIndex >= 0) { | ||
this.uploadAreas[areaIndex].destroy(); | ||
this.uploadAreas.splice(areaIndex, 1); | ||
} | ||
} | ||
get firstUploadArea(): UploadArea | undefined { | ||
return this.uploadAreas[0]; | ||
} | ||
} | ||
export class UploadQueue { | ||
@@ -1213,1 +1180,34 @@ offset: IOffsetInfo = { fileCount: 0, running: false }; | ||
} | ||
export class Uploader { | ||
uploadAreas: UploadArea[]; | ||
queue: UploadQueue; | ||
options: IUploadQueueOptions; | ||
constructor( | ||
options: IUploadQueueOptions = {}, | ||
callbacks: IUploadQueueCallbacks = {} | ||
) { | ||
this.options = options; | ||
this.uploadAreas = []; | ||
this.queue = new UploadQueue(options, callbacks); | ||
} | ||
registerArea(element: HTMLElement, options: IUploadAreaOptions): UploadArea { | ||
const uploadArea = new UploadArea(element, options, this); | ||
this.uploadAreas.push(uploadArea); | ||
return uploadArea; | ||
} | ||
unregisterArea(area: UploadArea): void { | ||
const areaIndex = this.uploadAreas.indexOf(area); | ||
if (areaIndex >= 0) { | ||
this.uploadAreas[areaIndex].destroy(); | ||
this.uploadAreas.splice(areaIndex, 1); | ||
} | ||
} | ||
get firstUploadArea(): UploadArea | undefined { | ||
return this.uploadAreas[0]; | ||
} | ||
} |
138
package.json
{ | ||
"name": "pure-upload", | ||
"version": "5.4.0", | ||
"description": "The pure upload library without dependencies", | ||
"author": { | ||
"name": "t.rut" | ||
}, | ||
"license": "MIT", | ||
"contributors": [ | ||
{ | ||
"name": "Tomáš Růt", | ||
"email": "trut.cz@gmail.com" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/keeema/pure-upload.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/keeema/pure-upload/issues" | ||
}, | ||
"keywords": [ | ||
"pure", | ||
"upload", | ||
"javascript", | ||
"typescript", | ||
"web", | ||
"file", | ||
"api" | ||
], | ||
"prettier": { | ||
"printWidth": 140, | ||
"tabWidth": 4, | ||
"parser": "typescript" | ||
}, | ||
"devDependencies": { | ||
"@types/cors": "^2.8.6", | ||
"@types/jasmine": "^2.8.16", | ||
"@types/multer": "1.3.7", | ||
"cors": "^2.8.5", | ||
"cryptiles": "^4.1.3", | ||
"express": "^4.17.1", | ||
"gulp": "^4.0.2", | ||
"gulp-clean": "^0.4.0", | ||
"gulp-concat": "^2.6.1", | ||
"gulp-flatten": "^0.4.0", | ||
"gulp-foreach": "^0.1.0", | ||
"gulp-insert": "^0.5.0", | ||
"gulp-karma": "^0.0.5", | ||
"gulp-rename": "^1.4.0", | ||
"gulp-replace": "^1.0.0", | ||
"gulp-typescript": "^4.0.2", | ||
"gulp-uglify": "^3.0.2", | ||
"gulp-watch": "^5.0.1", | ||
"hoek": "^5.0.4", | ||
"jasmine-core": "^3.5.0", | ||
"karma": "^3.1.4", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-jasmine": "^1.1.2", | ||
"karma-phantomjs-launcher": "^1.0.4", | ||
"lodash": "^4.17.15", | ||
"merge2": "^1.3.0", | ||
"minimatch": "^3.0.4", | ||
"multer": "^1.4.2", | ||
"phantomjs": "^2.1.7", | ||
"gulp4-run-sequence": "^1.0.0", | ||
"typescript": "^3.7.2" | ||
}, | ||
"dependencies": {} | ||
} | ||
"name": "pure-upload", | ||
"version": "5.5.0", | ||
"description": "The pure upload library without dependencies", | ||
"author": { | ||
"name": "t.rut" | ||
}, | ||
"license": "MIT", | ||
"contributors": [ | ||
{ | ||
"name": "Tomáš Růt", | ||
"email": "trut.cz@gmail.com" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/keeema/pure-upload.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/keeema/pure-upload/issues" | ||
}, | ||
"keywords": [ | ||
"pure", | ||
"upload", | ||
"javascript", | ||
"typescript", | ||
"web", | ||
"file", | ||
"api" | ||
], | ||
"prettier": { | ||
"printWidth": 140, | ||
"tabWidth": 4 | ||
}, | ||
"devDependencies": { | ||
"@types/cors": "^2.8.6", | ||
"@types/jasmine": "^3.5.10", | ||
"@types/multer": "^1.4.3", | ||
"cors": "^2.8.5", | ||
"cryptiles": "^4.1.3", | ||
"express": "^4.17.1", | ||
"gulp": "^4.0.2", | ||
"gulp-clean": "^0.4.0", | ||
"gulp-concat": "^2.6.1", | ||
"gulp-flatten": "^0.4.0", | ||
"gulp-foreach": "^0.1.0", | ||
"gulp-insert": "^0.5.0", | ||
"gulp-karma": "0.0.5", | ||
"gulp-rename": "^2.0.0", | ||
"gulp-replace": "^1.0.0", | ||
"gulp-typescript": "^6.0.0-alpha.1", | ||
"gulp-uglify": "^3.0.2", | ||
"gulp-watch": "^5.0.1", | ||
"gulp4-run-sequence": "^1.0.1", | ||
"hoek": "^6.1.3", | ||
"jasmine-core": "^3.5.0", | ||
"karma": "^5.0.4", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-jasmine": "^3.1.1", | ||
"karma-phantomjs-launcher": "^1.0.4", | ||
"lodash": "^4.17.15", | ||
"merge2": "^1.3.0", | ||
"minimatch": "^3.0.4", | ||
"multer": "^1.4.2", | ||
"phantomjs": "^2.1.7", | ||
"prettier": "^2.0.5", | ||
"typescript": "^3.8.3" | ||
}, | ||
"dependencies": {} | ||
} |
declare module "pure-upload" { | ||
export type ErrorCallback = (err: DOMException) => void; | ||
type FilesCallback = (file: File[]) => void; | ||
export function addEventHandler(el: Element | HTMLElement, event: string, handler: EventListenerOrEventListenerObject, useCapture: boolean): void; | ||
@@ -10,4 +12,2 @@ export const isFileApi: boolean; | ||
export function newGuid(): string; | ||
export type ErrorCallback = (err: DOMException) => void; | ||
type FilesCallback = (file: File[]) => void; | ||
export interface IFullUploadAreaOptions extends IUploadAreaOptions { | ||
@@ -42,19 +42,2 @@ maxFileSize: number; | ||
} | ||
export class ItemProcessor { | ||
errors: Error[]; | ||
files: File[]; | ||
private constructor(); | ||
static processItems(items: DataTransferItem[] | DataTransferItemList, callback?: FilesCallback): void; | ||
processItems(items: DataTransferItem[] | DataTransferItemList, callback?: () => void): void; | ||
private processEntries; | ||
private processEntry; | ||
private processDirectoryEntry; | ||
private processFileEntry; | ||
private processFile; | ||
private callbackAfter; | ||
private pushAndCallback; | ||
private toValidItems; | ||
private isFileSystemFileEntry; | ||
private isFileSystemDirectoryEntry; | ||
} | ||
export interface IUploadAreaOptions extends IUploadOptions { | ||
@@ -129,2 +112,19 @@ maxFileSize?: number; | ||
} | ||
export class ItemProcessor { | ||
errors: Error[]; | ||
files: File[]; | ||
private constructor(); | ||
static processItems(items: DataTransferItem[] | DataTransferItemList, callback?: FilesCallback): void; | ||
processItems(items: DataTransferItem[] | DataTransferItemList, callback?: () => void): void; | ||
private processEntries; | ||
private processEntry; | ||
private processDirectoryEntry; | ||
private processFileEntry; | ||
private processFile; | ||
private callbackAfter; | ||
private pushAndCallback; | ||
private toValidItems; | ||
private isFileSystemFileEntry; | ||
private isFileSystemDirectoryEntry; | ||
} | ||
export function removeEventHandler(el: HTMLInputElement | Element, event: string, handler: EventListenerOrEventListenerObject): void; | ||
@@ -193,11 +193,2 @@ export class UploadArea { | ||
} | ||
export class Uploader { | ||
uploadAreas: UploadArea[]; | ||
queue: UploadQueue; | ||
options: IUploadQueueOptions; | ||
constructor(options?: IUploadQueueOptions, callbacks?: IUploadQueueCallbacks); | ||
registerArea(element: HTMLElement, options: IUploadAreaOptions): UploadArea; | ||
unregisterArea(area: UploadArea): void; | ||
get firstUploadArea(): UploadArea | undefined; | ||
} | ||
export class UploadQueue { | ||
@@ -230,3 +221,12 @@ offset: IOffsetInfo; | ||
} | ||
export class Uploader { | ||
uploadAreas: UploadArea[]; | ||
queue: UploadQueue; | ||
options: IUploadQueueOptions; | ||
constructor(options?: IUploadQueueOptions, callbacks?: IUploadQueueCallbacks); | ||
registerArea(element: HTMLElement, options: IUploadAreaOptions): UploadArea; | ||
unregisterArea(area: UploadArea): void; | ||
get firstUploadArea(): UploadArea | undefined; | ||
} | ||
export {}; | ||
} |
@@ -117,6 +117,5 @@ # Pure-upload | ||
Library used by [GMC Software Technology](http://www.gmchk.cz). | ||
Library used by [Quadient](https://quadient.cz/. | ||
[![npm version](https://media.licdn.com/mpr/mpr/shrink_200_200/AAEAAQAAAAAAAAKkAAAAJDA3MDA4ODRmLWM2ZjQtNDYyNi04NjY2LWFhZjk3NjU3NDg4MQ.png)](http://www.gmchk.cz) | ||
MIT, Copyright © 2015 Tomáš Růt |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87703
32
121