chore(deps): use angular2 0.44 and ensure noImplicitAny:true builds

This commit is contained in:
Dmitriy Schekhovtsov
2015-10-21 13:21:52 +03:00
parent 443c778d0d
commit 61bbb9d3b5
11 changed files with 127 additions and 114 deletions

6
.gitignore vendored
View File

@@ -14,10 +14,14 @@ npm-debug.log
/dist /dist
/demo/**/*.js /demo/**/*.js
/demo/**/*.d.ts
/demo/**/*.js.map /demo/**/*.js.map
/components/**/*.js /components/**/*.js
/components/**/*.d.ts
/components/**/*.js.map /components/**/*.js.map
ng2-file-upload.js
ng2-file-upload.d.ts
ng2-file-upload.js.map
/logs /logs
!/demo/components/file-upload/file-catcher.js !/demo/components/file-upload/file-catcher.js

10
.npmignore Normal file
View File

@@ -0,0 +1,10 @@
.idea
demo
build
gulp-tasks
logs
tsd.d.ts
typings
webpack.config.js

View File

@@ -30,7 +30,7 @@ export class FileDrop {
getFilters() { getFilters() {
} }
onDrop(event) { onDrop(event:any) {
let transfer = this._getTransfer(event); let transfer = this._getTransfer(event);
if (!transfer) { if (!transfer) {
return; return;
@@ -43,7 +43,7 @@ export class FileDrop {
this.fileOver.next(false); this.fileOver.next(false);
} }
onDragOver(event) { onDragOver(event:any) {
let transfer = this._getTransfer(event); let transfer = this._getTransfer(event);
if (!this._haveFiles(transfer.types)) { if (!this._haveFiles(transfer.types)) {
return; return;
@@ -54,8 +54,8 @@ export class FileDrop {
this.fileOver.next(true); this.fileOver.next(true);
} }
onDragLeave(event) { onDragLeave(event:any):any {
if (event.currentTarget === this.element[0]) { if (event.currentTarget === (<any>this).element[0]) {
return; return;
} }
@@ -63,16 +63,16 @@ export class FileDrop {
this.fileOver.next(false); this.fileOver.next(false);
} }
_getTransfer(event) { private _getTransfer(event:any):any {
return event.dataTransfer ? event.dataTransfer : event.originalEvent.dataTransfer; // jQuery fix; return event.dataTransfer ? event.dataTransfer : event.originalEvent.dataTransfer; // jQuery fix;
} }
_preventAndStop(event) { private _preventAndStop(event:any):any {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }
_haveFiles(types) { private _haveFiles(types:any):any {
if (!types) { if (!types) {
return false; return false;
} }
@@ -86,11 +86,11 @@ export class FileDrop {
} }
} }
_addOverClass(item) { _addOverClass(item:any):any {
item.addOverClass(); item.addOverClass();
} }
_removeOverClass(item) { _removeOverClass(item:any):any {
item.removeOverClass(); item.removeOverClass();
} }
} }

View File

@@ -45,19 +45,19 @@ export class FileItem {
public onBeforeUpload() { public onBeforeUpload() {
} }
public onProgress(progress) { public onProgress(progress:number) {
} }
public onSuccess(response, status, headers) { public onSuccess(response:any, status:any, headers:any) {
} }
public onError(response, status, headers) { public onError(response:any, status:any, headers:any) {
} }
public onCancel(response, status, headers) { public onCancel(response:any, status:any, headers:any) {
} }
public onComplete(response, status, headers) { public onComplete(response:any, status:any, headers:any) {
} }
private _onBeforeUpload() { private _onBeforeUpload() {
@@ -71,12 +71,12 @@ export class FileItem {
this.onBeforeUpload(); this.onBeforeUpload();
} }
private _onProgress(progress) { private _onProgress(progress:number) {
this.progress = progress; this.progress = progress;
this.onProgress(progress); this.onProgress(progress);
} }
private _onSuccess(response, status, headers) { private _onSuccess(response:any, status:any, headers:any) {
this.isReady = false; this.isReady = false;
this.isUploading = false; this.isUploading = false;
this.isUploaded = true; this.isUploaded = true;
@@ -88,7 +88,7 @@ export class FileItem {
this.onSuccess(response, status, headers); this.onSuccess(response, status, headers);
} }
private _onError(response, status, headers) { private _onError(response:any, status:any, headers:any) {
this.isReady = false; this.isReady = false;
this.isUploading = false; this.isUploading = false;
this.isUploaded = true; this.isUploaded = true;
@@ -100,7 +100,7 @@ export class FileItem {
this.onError(response, status, headers); this.onError(response, status, headers);
} }
private _onCancel(response, status, headers) { private _onCancel(response:any, status:any, headers:any) {
this.isReady = false; this.isReady = false;
this.isUploading = false; this.isUploading = false;
this.isUploaded = false; this.isUploaded = false;
@@ -112,7 +112,7 @@ export class FileItem {
this.onCancel(response, status, headers); this.onCancel(response, status, headers);
} }
private _onComplete(response, status, headers) { private _onComplete(response:any, status:any, headers:any) {
this.onComplete(response, status, headers); this.onComplete(response, status, headers);
if (this.uploader.removeAfterUpload) { if (this.uploader.removeAfterUpload) {
@@ -120,14 +120,8 @@ export class FileItem {
} }
} }
private _destroy() {
}
private _prepareToUploading() { private _prepareToUploading() {
this.index = this.index || ++this.uploader._nextIndex; this.index = this.index || ++this.uploader._nextIndex;
this.isReady = true; this.isReady = true;
} }
_replaceNode(input) {
}
} }

View File

@@ -1,4 +1,4 @@
function isElement(node) { function isElement(node:any) {
return !!(node && (node.nodeName || node.prop && node.attr && node.find)); return !!(node && (node.nodeName || node.prop && node.attr && node.find));
} }
@@ -13,17 +13,17 @@ export class FileLikeObject {
let fakePathOrObject = isInput ? fileOrInput.value : fileOrInput; let fakePathOrObject = isInput ? fileOrInput.value : fileOrInput;
let postfix = typeof fakePathOrObject === 'string' ? 'FakePath' : 'Object'; let postfix = typeof fakePathOrObject === 'string' ? 'FakePath' : 'Object';
let method = '_createFrom' + postfix; let method = '_createFrom' + postfix;
this[method](fakePathOrObject); (<any>this)[method](fakePathOrObject);
} }
public _createFromFakePath(path) { public _createFromFakePath(path:string) {
this.lastModifiedDate = null; this.lastModifiedDate = null;
this.size = null; this.size = null;
this.type = 'like/' + path.slice(path.lastIndexOf('.') + 1).toLowerCase(); this.type = 'like/' + path.slice(path.lastIndexOf('.') + 1).toLowerCase();
this.name = path.slice(path.lastIndexOf('/') + path.lastIndexOf('\\') + 2); this.name = path.slice(path.lastIndexOf('/') + path.lastIndexOf('\\') + 2);
} }
public _createFromObject(object) { public _createFromObject(object:{size: number, type: string, name: string}) {
// this.lastModifiedDate = copy(object.lastModifiedDate); // this.lastModifiedDate = copy(object.lastModifiedDate);
this.size = object.size; this.size = object.size;
this.type = object.type; this.type = object.type;

View File

@@ -5,11 +5,11 @@ import {
import {FileLikeObject} from './file-like-object'; import {FileLikeObject} from './file-like-object';
import {FileItem} from './file-item'; import {FileItem} from './file-item';
function isFile(value) { function isFile(value:any) {
return (File && value instanceof File); return (File && value instanceof File);
} }
function isFileLikeObject(value) { function isFileLikeObject(value:any) {
return value instanceof FileLikeObject; return value instanceof FileLikeObject;
} }
@@ -33,15 +33,15 @@ export class FileUploader {
this.filters.unshift({name: 'folder', fn: this._folderFilter}); this.filters.unshift({name: 'folder', fn: this._folderFilter});
} }
public addToQueue(files, options, filters) { public addToQueue(files:any[], options:any, filters:any) {
let list = []; let list:any[] = [];
for (let file of files) { for (let file of files) {
list.push(file); list.push(file);
} }
let arrayOfFilters = this._getFilters(filters); let arrayOfFilters = this._getFilters(filters);
let count = this.queue.length; let count = this.queue.length;
let addedFileItems = []; let addedFileItems:any[] = [];
list.map(some => { list.map(some => {
let temp = new FileLikeObject(some); let temp = new FileLikeObject(some);
@@ -69,7 +69,7 @@ export class FileUploader {
} }
} }
public removeFromQueue(value) { public removeFromQueue(value:any) {
let index = this.getIndexOfItem(value); let index = this.getIndexOfItem(value);
let item = this.queue[index]; let item = this.queue[index];
if (item.isUploading) { if (item.isUploading) {
@@ -100,10 +100,10 @@ export class FileUploader {
} }
this.isUploading = true; this.isUploading = true;
this[transport](item); (<any>this)[transport](item);
} }
public cancelItem(value) { public cancelItem(value:any) {
let index = this.getIndexOfItem(value); let index = this.getIndexOfItem(value);
let item = this.queue[index]; let item = this.queue[index];
let prop = this.isHTML5 ? '_xhr' : '_form'; let prop = this.isHTML5 ? '_xhr' : '_form';
@@ -129,15 +129,15 @@ export class FileUploader {
} }
public isFile(value) { public isFile(value:any) {
return isFile(value); return isFile(value);
} }
public isFileLikeObject(value) { public isFileLikeObject(value:any) {
return value instanceof FileLikeObject; return value instanceof FileLikeObject;
} }
public getIndexOfItem(value) { public getIndexOfItem(value:any) {
return typeof value === 'number' ? value : this.queue.indexOf(value); return typeof value === 'number' ? value : this.queue.indexOf(value);
} }
@@ -159,34 +159,34 @@ export class FileUploader {
});*/ });*/
} }
public onAfterAddingAll(fileItems) { public onAfterAddingAll(fileItems:any) {
} }
public onAfterAddingFile(fileItem) { public onAfterAddingFile(fileItem:any) {
} }
public onWhenAddingFileFailed(item, filter, options) { public onWhenAddingFileFailed(item:any, filter:any, options:any) {
} }
public onBeforeUploadItem(fileItem) { public onBeforeUploadItem(fileItem:any) {
} }
public onProgressItem(fileItem, progress) { public onProgressItem(fileItem:any, progress:any) {
} }
public onProgressAll(progress) { public onProgressAll(progress:any) {
} }
public onSuccessItem(item, response, status, headers) { public onSuccessItem(item:any, response:any, status:any, headers:any) {
} }
public onErrorItem(item, response, status, headers) { public onErrorItem(item:any, response:any, status:any, headers:any) {
} }
public onCancelItem(item, response, status, headers) { public onCancelItem(item:any, response:any, status:any, headers:any) {
} }
public onCompleteItem(item, response, status, headers) { public onCompleteItem(item:any, response:any, status:any, headers:any) {
} }
public onCompleteAll() { public onCompleteAll() {
@@ -205,7 +205,7 @@ export class FileUploader {
return Math.round(uploaded * ratio + current); return Math.round(uploaded * ratio + current);
} }
private _getFilters(filters) { private _getFilters(filters:any) {
if (!filters) { if (!filters) {
return this.filters; return this.filters;
} }
@@ -223,7 +223,7 @@ export class FileUploader {
// todo: ? // todo: ?
} }
private _folderFilter(item) { private _folderFilter(item:any) {
return !!(item.size || item.type); return !!(item.size || item.type);
} }
@@ -231,19 +231,19 @@ export class FileUploader {
return this.queue.length < this.queueLimit; return this.queue.length < this.queueLimit;
} }
private _isValidFile(file, filters, options) { private _isValidFile(file:any, filters:any, options:any) {
this._failFilterIndex = -1; this._failFilterIndex = -1;
return !filters.length ? true : filters.every((filter) => { return !filters.length ? true : filters.every((filter:any) => {
this._failFilterIndex++; this._failFilterIndex++;
return filter.fn.call(this, file, options); return filter.fn.call(this, file, options);
}); });
} }
private _isSuccessCode(status) { private _isSuccessCode(status:any) {
return (status >= 200 && status < 300) || status === 304; return (status >= 200 && status < 300) || status === 304;
} }
private _transformResponse(response, headers):any { private _transformResponse(response:any, headers:any):any {
// todo: ? // todo: ?
/*var headersGetter = this._headersGetter(headers); /*var headersGetter = this._headersGetter(headers);
forEach($http.defaults.transformResponse, (transformFn) => { forEach($http.defaults.transformResponse, (transformFn) => {
@@ -252,14 +252,14 @@ export class FileUploader {
return response; return response;
} }
private _parseHeaders(headers) { private _parseHeaders(headers:any) {
let parsed = {}, key, val, i; let parsed:any = {}, key:any, val:any, i:any;
if (!headers) { if (!headers) {
return parsed; return parsed;
} }
headers.split('\n').map(line => { headers.split('\n').map((line:any) => {
i = line.indexOf(':'); i = line.indexOf(':');
key = line.slice(0, i).trim().toLowerCase(); key = line.slice(0, i).trim().toLowerCase();
val = line.slice(i + 1).trim(); val = line.slice(i + 1).trim();
@@ -272,8 +272,8 @@ export class FileUploader {
return parsed; return parsed;
} }
private _headersGetter(parsedHeaders) { private _headersGetter(parsedHeaders:any) {
return (name) => { return (name:any) => {
if (name) { if (name) {
return parsedHeaders[name.toLowerCase()] || null; return parsedHeaders[name.toLowerCase()] || null;
} }
@@ -310,7 +310,7 @@ export class FileUploader {
let response = this._transformResponse(xhr.response, headers); let response = this._transformResponse(xhr.response, headers);
let gist = this._isSuccessCode(xhr.status) ? 'Success' : 'Error'; let gist = this._isSuccessCode(xhr.status) ? 'Success' : 'Error';
let method = '_on' + gist + 'Item'; let method = '_on' + gist + 'Item';
this[method](item, response, xhr.status, headers); (<any>this)[method](item, response, xhr.status, headers);
this._onCompleteItem(item, response, xhr.status, headers); this._onCompleteItem(item, response, xhr.status, headers);
}; };
@@ -340,28 +340,28 @@ export class FileUploader {
this._render(); this._render();
} }
private _iframeTransport(item) { private _iframeTransport(item:any) {
// todo: implement it later // todo: implement it later
} }
private _onWhenAddingFileFailed(item, filter, options) { private _onWhenAddingFileFailed(item:any, filter:any, options:any) {
this.onWhenAddingFileFailed(item, filter, options); this.onWhenAddingFileFailed(item, filter, options);
} }
private _onAfterAddingFile(item) { private _onAfterAddingFile(item:any) {
this.onAfterAddingFile(item); this.onAfterAddingFile(item);
} }
private _onAfterAddingAll(items) { private _onAfterAddingAll(items:any) {
this.onAfterAddingAll(items); this.onAfterAddingAll(items);
} }
private _onBeforeUploadItem(item) { private _onBeforeUploadItem(item:any) {
item._onBeforeUpload(); item._onBeforeUpload();
this.onBeforeUploadItem(item); this.onBeforeUploadItem(item);
} }
private _onProgressItem(item, progress) { private _onProgressItem(item:any, progress:any) {
let total = this._getTotalProgress(progress); let total = this._getTotalProgress(progress);
this.progress = total; this.progress = total;
item._onProgress(progress); item._onProgress(progress);
@@ -370,22 +370,22 @@ export class FileUploader {
this._render(); this._render();
} }
private _onSuccessItem(item, response, status, headers) { private _onSuccessItem(item:any, response:any, status:any, headers:any) {
item._onSuccess(response, status, headers); item._onSuccess(response, status, headers);
this.onSuccessItem(item, response, status, headers); this.onSuccessItem(item, response, status, headers);
} }
public _onErrorItem(item, response, status, headers) { public _onErrorItem(item:any, response:any, status:any, headers:any) {
item._onError(response, status, headers); item._onError(response, status, headers);
this.onErrorItem(item, response, status, headers); this.onErrorItem(item, response, status, headers);
} }
private _onCancelItem(item, response, status, headers) { private _onCancelItem(item:any, response:any, status:any, headers:any) {
item._onCancel(response, status, headers); item._onCancel(response, status, headers);
this.onCancelItem(item, response, status, headers); this.onCancelItem(item, response, status, headers);
} }
public _onCompleteItem(item, response, status, headers) { public _onCompleteItem(item:any, response:any, status:any, headers:any) {
item._onComplete(response, status, headers); item._onComplete(response, status, headers);
this.onCompleteItem(item, response, status, headers); this.onCompleteItem(item, response, status, headers);

View File

@@ -1,6 +0,0 @@
///<reference path="../tsd.d.ts"/>
export * from './file-upload/file-select';
export * from './file-upload/file-drop';
export * from './file-upload/file-uploader';

View File

@@ -9,8 +9,9 @@ gulp.paths = {
'!**/*.{ts,coffee}.js'], '!**/*.{ts,coffee}.js'],
jssrc: [ jssrc: [
'*.js', '*.js',
'!angular2-file-upload.js',
'gulp-tasks/*.js', 'gulp-tasks/*.js',
'!ng2-file-upload.js',
'!angular2-file-upload.js',
'!node_modules', '!node_modules',
'!**/*.{ts,coffee}.js'] '!**/*.{ts,coffee}.js']
}; };

4
ng2-file-upload.ts Normal file
View File

@@ -0,0 +1,4 @@
export * from './components/file-upload/file-select';
export * from './components/file-upload/file-drop';
export * from './components/file-upload/file-uploader';

View File

@@ -1,6 +1,6 @@
{ {
"name": "ng2-file-upload", "name": "ng2-file-upload",
"version": "0.42.0", "version": "0.44.0",
"description": "angular2 file upload directives", "description": "angular2 file upload directives",
"scripts": { "scripts": {
"deploy": "NODE_ENV=production webpack -p --progress --color --optimize-minimize --optimize-dedupe --optimize-occurence-order", "deploy": "NODE_ENV=production webpack -p --progress --color --optimize-minimize --optimize-dedupe --optimize-occurence-order",
@@ -10,12 +10,8 @@
"start": "npm run server", "start": "npm run server",
"test": "gulp lint" "test": "gulp lint"
}, },
"main": "dist/index.js", "main": "ng2-file-upload.js",
"typings": "dist/index.d.ts", "typings": "ng2-file-upload.d.ts",
"files": [
"dist",
"components"
],
"keywords": [ "keywords": [
"angular2", "angular2",
"bootstrap", "bootstrap",
@@ -33,8 +29,8 @@
}, },
"homepage": "https://github.com/valor-software/ng2-file-upload#readme", "homepage": "https://github.com/valor-software/ng2-file-upload#readme",
"dependencies": { "dependencies": {
"angular2": "2.0.0-alpha.42", "angular2": "2.0.0-alpha.44",
"ng2-bootstrap": "0.42.0", "ng2-bootstrap": "0.44.3",
"reflect-metadata": "0.1.2", "reflect-metadata": "0.1.2",
"ts-loader": "0.5.6", "ts-loader": "0.5.6",
"zone.js": "0.5.8" "zone.js": "0.5.8"
@@ -43,7 +39,7 @@
"bootstrap": "3.3.5", "bootstrap": "3.3.5",
"clean-webpack-plugin": "0.1.3", "clean-webpack-plugin": "0.1.3",
"compression-webpack-plugin": "0.2.0", "compression-webpack-plugin": "0.2.0",
"eslint": "1.6.0", "eslint": "1.7.2",
"exports-loader": "0.6.2", "exports-loader": "0.6.2",
"file-loader": "0.8.4", "file-loader": "0.8.4",
"gulp": "3.9.0", "gulp": "3.9.0",
@@ -56,13 +52,25 @@
"markdown-loader": "0.1.7", "markdown-loader": "0.1.7",
"marked": "0.3.5", "marked": "0.3.5",
"moment": "2.10.6", "moment": "2.10.6",
"pre-commit": "1.1.1", "pre-commit": "1.1.2",
"prismjs": "valorkin/prism", "prismjs": "valorkin/prism",
"prismjs-loader": "0.0.2", "prismjs-loader": "0.0.2",
"raw-loader": "0.5.1", "raw-loader": "0.5.1",
"require-dir": "0.3.0", "require-dir": "0.3.0",
"typescript": "1.6.2", "typescript": "1.6.2",
"webpack": "1.12.2", "webpack": "1.12.2",
"webpack-dev-server": "1.12.0" "webpack-dev-server": "1.12.1"
} },
"contributors": [
{
"name": "Vyacheslav Chub",
"email": "vyacheslav.chub@valor-software.com",
"url": "https://github.com/buchslava"
},
{
"name": "Dmitriy Shekhovtsov",
"email": "valorkin@gmail.com",
"url": "https://github.com/valorkin"
}
]
} }

View File

@@ -1,23 +1,21 @@
{ {
"version": "1.6.2", "version": "1.6.2",
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"module": "commonjs", "module": "commonjs",
"outDir": "dist", "sourceMap": true,
"sourceMap": true, "declaration": true,
"declaration": true, "removeComments": true,
"removeComments": true, "emitDecoratorMetadata": true,
"emitDecoratorMetadata": true, "experimentalDecorators": true,
"experimentalDecorators": true, "listFiles": false,
"listFiles": false, "noLib": false,
"noLib": false, "noImplicitAny": true
"noEmitOnError": false, },
"noImplicitAny": false "exclude": [
}, "node_modules"
"exclude": [ ],
"node_modules" "files": [
], "ng2-file-upload.ts"
"files": [ ]
"./components/index.ts"
]
} }