@acorex/core 17.0.18 → 17.0.20
Sign up to get free protection for your applications and to get access to all the features.
@@ -100,4 +100,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImpor
|
|
100
100
|
providedIn: 'root',
|
101
101
|
}]
|
102
102
|
}], ctorParameters: () => [{ type: i1.HttpClient }] });
|
103
|
-
//# sourceMappingURL=data:application/json;base64,
|
103
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZS5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9jb3JlL2ZpbGUvc3JjL2xpYi9maWxlLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQ2xELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDM0MsT0FBTyxFQUE0QixZQUFZLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFDOUQsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDOUQsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFDcEUsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLHlCQUF5QixDQUFDOzs7QUFLMUQsTUFBTSxPQUFPLGFBQWE7SUFDeEIsWUFBb0IsV0FBdUI7UUFBdkIsZ0JBQVcsR0FBWCxXQUFXLENBQVk7UUFnRnBDLGlCQUFZLEdBQUcsQ0FBQyxJQUFVLEVBQUUsRUFBRSxDQUNuQyxJQUFJLE9BQU8sQ0FBUyxDQUFDLE9BQU8sRUFBRSxNQUFNLEVBQUUsRUFBRTtZQUN0QyxNQUFNLE1BQU0sR0FBRyxJQUFJLFVBQVUsRUFBRSxDQUFDO1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ICAgICAgICByZXNvbHZlKEFycmF5LmZyb20oaW5wdXQuZmlsZXMgfHwgW10pKTtcbiAgICAgICAgZG9jdW1lbnQuYm9keS5yZW1vdmVDaGlsZChpbnB1dCk7XG4gICAgICAgIGlucHV0LnJlbW92ZSgpO1xuICAgICAgICBpbnB1dC5yZW1vdmVFdmVudExpc3RlbmVyKCdjaGFuZ2UnLCBvbkNoYW5nZSk7XG4gICAgICAgIGlucHV0LnJlbW92ZUV2ZW50TGlzdGVuZXIoJ2Vycm9yJywgb25FcnJvcik7XG4gICAgICB9O1xuICAgICAgLy9cbiAgICAgIGlucHV0LmFkZEV2ZW50TGlzdGVuZXIoJ2NoYW5nZScsIG9uQ2hhbmdlKTtcbiAgICAgIGlucHV0LmFkZEV2ZW50TGlzdGVuZXIoJ2Vycm9yJywgb25FcnJvcik7XG4gICAgICBpbnB1dC5jbGljaygpO1xuICAgIH0pO1xuICB9XG5cbiAgcHVibGljIGJsb2JUb0Jhc2U2NCA9IChibG9iOiBCbG9iKSA9PlxuICAgIG5ldyBQcm9taXNlPHN0cmluZz4oKHJlc29sdmUsIHJlamVjdCkgPT4ge1xuICAgICAgY29uc3QgcmVhZGVyID0gbmV3IEZpbGVSZWFkZXIoKTtcbiAgICAgIHJlYWRlci5vbmVycm9yID0gcmVqZWN0O1xuICAgICAgcmVhZGVyLm9ubG9hZCA9ICgpID0+IHtcbiAgICAgICAgcmVzb2x2ZShyZWFkZXIucmVzdWx0IGFzIHN0cmluZyk7XG4gICAgICB9O1xuICAgICAgcmVhZGVyLnJlYWRBc0RhdGFVUkwoYmxvYik7XG4gICAgfSk7XG59XG4iXX0=
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"acorex-core-file.mjs","sources":["../../../../libs/core/file/src/lib/file-size-formatter.ts","../../../../libs/core/file/src/lib/file-download-ref.class.ts","../../../../libs/core/file/src/lib/file-download-result.class.ts","../../../../libs/core/file/src/lib/file-upload-ref.class.ts","../../../../libs/core/file/src/lib/file.service.ts","../../../../libs/core/file/src/lib/file.module.ts","../../../../libs/core/file/src/acorex-core-file.ts"],"sourcesContent":["import { AXFormatOptions, AXFormatter } from '@acorex/core/format';\nimport { Injectable } from '@angular/core';\n\nexport interface AXFileSizeFormatterOptions extends AXFormatOptions {\n format: string;\n}\n\ndeclare module '@acorex/core/format' {\n interface AXFormatOptionsMap {\n filesize: AXFileSizeFormatterOptions;\n }\n}\n\n@Injectable()\nexport class AXFileSizeFormatter implements AXFormatter {\n get name(): string {\n return 'filesize';\n }\n\n format(value: number): string {\n const size: number = Number(value);\n\n if (size === 0) return '0 Bytes';\n if (Number.isNaN(size)) return 'Unknown';\n\n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(size) / Math.log(k));\n\n return parseFloat((size / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n }\n}\n","import { AXFileDownloadResult } from './file-download-result.class';\n\nexport class AXFileDownloadRef extends Promise<AXFileDownloadResult> {\n public abortMethod: () => void;\n constructor(\n executor: (\n resolve: (value?: PromiseLike<AXFileDownloadResult>) => void,\n reject: (reason?: any) => void\n ) => void\n ) {\n super(executor as any);\n }\n //abort the operation\n public abort() {\n if (this.abortMethod) {\n this.abortMethod();\n }\n }\n}\n","export class AXFileDownloadResult {\n _response: Blob;\n\n constructor(response: Blob) {\n this._response = response;\n }\n\n save(filename?: string): Promise<void> {\n this._defaultBrowserDownload(filename);\n return Promise.resolve();\n // else {\n // return new Promise((resolve, reject) => {\n // const button = document.createElement(\"button\");\n // button.addEventListener('click', async () => {\n // button.remove();\n // const opts = {\n // types: [{\n // description: 'Save File',\n // suggestedName: filename\n // // accept: {'text/plain': ['.txt']},\n // }],\n // };\n // const result = await window['showSaveFilePicker'](opts);\n\n // resolve();\n // });\n // button.click();\n // });\n\n // }\n }\n\n blob() {\n return this._response;\n }\n\n base64(): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new window.FileReader();\n reader.onloadend = () => resolve(reader.result as string);\n reader.onerror = (e) => reject(e);\n reader.readAsDataURL(this._response);\n });\n }\n\n private _defaultBrowserDownload(filename = 'download') {\n const link = document.createElement('a');\n link.href = URL.createObjectURL(this._response);\n link.download = filename;\n link.click();\n }\n}\n","export class AXFileUploadRef<T = any> extends Promise<T> {\n public abortMethod: () => void;\n constructor(\n executor: (\n resolve: (value?: PromiseLike<T>) => void,\n reject: (reason?: any) => void\n ) => void\n ) {\n super(executor as any);\n }\n //abort the operation\n public abort() {\n if (this.abortMethod) {\n this.abortMethod();\n }\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable, Subscription, isObservable } from 'rxjs';\nimport { AXFileDownloadRef } from './file-download-ref.class';\nimport { AXFileDownloadResult } from './file-download-result.class';\nimport { AXFileUploadRef } from './file-upload-ref.class';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXFileService {\n constructor(private _httpClient: HttpClient) {}\n\n public download(request: string | Observable<Blob>): AXFileDownloadRef {\n let s: Subscription;\n const promiseFunc = (resolve, reject) => {\n //TODO: add custome http request\n //const headers = new HttpHeaders().set('authorization','Bearer '+token);\n let b!: Observable<Blob>;\n if (typeof request === 'string') {\n b = this._httpClient.get(request, { responseType: 'blob' });\n } else if (isObservable(b)) {\n b = request;\n }\n s = b?.subscribe({\n next: (v) => resolve(new AXFileDownloadResult(v)),\n error: (e) => reject(e),\n });\n };\n\n const a = new AXFileDownloadRef(promiseFunc);\n a.abort = () => {\n s?.unsubscribe();\n };\n\n return a;\n }\n\n public upload<T = any>(url: string, files: File[]): AXFileUploadRef<T> {\n let s: Subscription;\n const formData = new FormData();\n files.forEach((f) => {\n formData.append('files', f);\n });\n const promiseFunc = (resolve, reject) => {\n const b: Observable<T> = this._httpClient.post<T>(url, formData);\n s = b?.subscribe({\n next: (v) => resolve(v),\n error: (e) => reject(e),\n });\n };\n\n const a = new AXFileUploadRef(promiseFunc);\n a.abort = () => {\n s?.unsubscribe();\n };\n return a;\n }\n\n public choose(options?: {\n accept?: string;\n multiple?: boolean;\n }): Promise<File[]> {\n return new Promise<File[]>((resolve, reject) => {\n options = Object.assign({ multiple: false }, options);\n const input: HTMLInputElement = document.createElement('input');\n input.style.display = 'none';\n document.body.appendChild(input);\n input.type = 'file';\n input.accept = options.accept || '';\n input.multiple = options.multiple || false;\n //\n const onError = (e) => {\n reject(e);\n document.body.removeChild(input);\n input.remove();\n input.removeEventListener('change', onChange);\n input.removeEventListener('error', onError);\n };\n //\n const onChange = () => {\n resolve(Array.from(input.files || []));\n document.body.removeChild(input);\n input.remove();\n input.removeEventListener('change', onChange);\n input.removeEventListener('error', onError);\n };\n //\n input.addEventListener('change', onChange);\n input.addEventListener('error', onError);\n input.click();\n });\n }\n\n blobToBase64 = (blob: Blob) =>\n new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = reject;\n reader.onload = () => {\n resolve(reader.result as string);\n };\n reader.readAsDataURL(blob);\n });\n}\n","import { AXFormatModule } from '@acorex/core/format';\nimport { NgModule } from '@angular/core';\nimport { AXFileSizeFormatter } from './file-size-formatter';\n\n@NgModule({\n imports: [AXFormatModule.forChild({ formatters: [AXFileSizeFormatter] })],\n exports: [],\n declarations: [],\n providers: [AXFileSizeFormatter],\n})\nexport class AXFileModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;MAca,mBAAmB,CAAA;AAC9B,IAAA,IAAI,IAAI,GAAA;AACN,QAAA,OAAO,UAAU,CAAC;KACnB;AAED,IAAA,MAAM,CAAC,KAAa,EAAA;AAClB,QAAA,MAAM,IAAI,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,IAAI,KAAK,CAAC;AAAE,YAAA,OAAO,SAAS,CAAC;AACjC,QAAA,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;AAAE,YAAA,OAAO,SAAS,CAAC;QAEzC,MAAM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/src/lib/file-size-formatter.ts","../../../../libs/core/file/src/lib/file-download-ref.class.ts","../../../../libs/core/file/src/lib/file-download-result.class.ts","../../../../libs/core/file/src/lib/file-upload-ref.class.ts","../../../../libs/core/file/src/lib/file.service.ts","../../../../libs/core/file/src/lib/file.module.ts","../../../../libs/core/file/src/acorex-core-file.ts"],"sourcesContent":["import { AXFormatOptions, AXFormatter } from '@acorex/core/format';\nimport { Injectable } from '@angular/core';\n\nexport interface AXFileSizeFormatterOptions extends AXFormatOptions {\n format: string;\n}\n\ndeclare module '@acorex/core/format' {\n interface AXFormatOptionsMap {\n filesize: AXFileSizeFormatterOptions;\n }\n}\n\n@Injectable()\nexport class AXFileSizeFormatter implements AXFormatter {\n get name(): string {\n return 'filesize';\n }\n\n format(value: number): string {\n const size: number = Number(value);\n\n if (size === 0) return '0 Bytes';\n if (Number.isNaN(size)) return 'Unknown';\n\n const k = 1024;\n const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n const i = Math.floor(Math.log(size) / Math.log(k));\n\n return parseFloat((size / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];\n }\n}\n","import { AXFileDownloadResult } from './file-download-result.class';\n\nexport class AXFileDownloadRef extends Promise<AXFileDownloadResult> {\n public abortMethod: () => void;\n constructor(\n executor: (\n resolve: (value?: PromiseLike<AXFileDownloadResult>) => void,\n reject: (reason?: any) => void\n ) => void\n ) {\n super(executor as any);\n }\n //abort the operation\n public abort() {\n if (this.abortMethod) {\n this.abortMethod();\n }\n }\n}\n","export class AXFileDownloadResult {\n _response: Blob;\n\n constructor(response: Blob) {\n this._response = response;\n }\n\n save(filename?: string): Promise<void> {\n this._defaultBrowserDownload(filename);\n return Promise.resolve();\n // else {\n // return new Promise((resolve, reject) => {\n // const button = document.createElement(\"button\");\n // button.addEventListener('click', async () => {\n // button.remove();\n // const opts = {\n // types: [{\n // description: 'Save File',\n // suggestedName: filename\n // // accept: {'text/plain': ['.txt']},\n // }],\n // };\n // const result = await window['showSaveFilePicker'](opts);\n\n // resolve();\n // });\n // button.click();\n // });\n\n // }\n }\n\n blob() {\n return this._response;\n }\n\n base64(): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new window.FileReader();\n reader.onloadend = () => resolve(reader.result as string);\n reader.onerror = (e) => reject(e);\n reader.readAsDataURL(this._response);\n });\n }\n\n private _defaultBrowserDownload(filename = 'download') {\n const link = document.createElement('a');\n link.href = URL.createObjectURL(this._response);\n link.download = filename;\n link.click();\n }\n}\n","export class AXFileUploadRef<T = any> extends Promise<T> {\n public abortMethod: () => void;\n constructor(\n executor: (\n resolve: (value?: PromiseLike<T>) => void,\n reject: (reason?: any) => void\n ) => void\n ) {\n super(executor as any);\n }\n //abort the operation\n public abort() {\n if (this.abortMethod) {\n this.abortMethod();\n }\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Observable, Subscription, isObservable } from 'rxjs';\nimport { AXFileDownloadRef } from './file-download-ref.class';\nimport { AXFileDownloadResult } from './file-download-result.class';\nimport { AXFileUploadRef } from './file-upload-ref.class';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AXFileService {\n constructor(private _httpClient: HttpClient) {}\n\n public download(request: string | Observable<Blob>): AXFileDownloadRef {\n let s: Subscription;\n const promiseFunc = (resolve, reject) => {\n //TODO: add custome http request\n //const headers = new HttpHeaders().set('authorization','Bearer '+token);\n let b!: Observable<Blob>;\n if (typeof request === 'string') {\n b = this._httpClient.get(request, { responseType: 'blob' });\n } else if (isObservable(b)) {\n b = request;\n }\n s = b?.subscribe({\n next: (v) => resolve(new AXFileDownloadResult(v)),\n error: (e) => reject(e),\n });\n };\n\n const a = new AXFileDownloadRef(promiseFunc);\n a.abort = () => {\n s?.unsubscribe();\n };\n\n return a;\n }\n\n public upload<T = any>(url: string, files: File[]): AXFileUploadRef<T> {\n let s: Subscription;\n const formData = new FormData();\n files.forEach((f) => {\n formData.append('files', f);\n });\n const promiseFunc = (resolve, reject) => {\n const b: Observable<T> = this._httpClient.post<T>(url, formData);\n s = b?.subscribe({\n next: (v) => resolve(v),\n error: (e) => reject(e),\n });\n };\n\n const a = new AXFileUploadRef(promiseFunc);\n a.abort = () => {\n s?.unsubscribe();\n };\n return a;\n }\n\n public choose(options?: { accept?: string; multiple?: boolean }): Promise<File[]> {\n return new Promise<File[]>((resolve, reject) => {\n options = Object.assign({ multiple: false }, options);\n const input: HTMLInputElement = document.createElement('input');\n input.style.display = 'none';\n document.body.appendChild(input);\n input.type = 'file';\n input.accept = options.accept || '';\n input.multiple = options.multiple || false;\n //\n const onError = (e) => {\n reject(e);\n document.body.removeChild(input);\n input.remove();\n input.removeEventListener('change', onChange);\n input.removeEventListener('error', onError);\n };\n //\n const onChange = () => {\n resolve(Array.from(input.files || []));\n document.body.removeChild(input);\n input.remove();\n input.removeEventListener('change', onChange);\n input.removeEventListener('error', onError);\n };\n //\n input.addEventListener('change', onChange);\n input.addEventListener('error', onError);\n input.click();\n });\n }\n\n public blobToBase64 = (blob: Blob) =>\n new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = reject;\n reader.onload = () => {\n resolve(reader.result as string);\n };\n reader.readAsDataURL(blob);\n });\n}\n","import { AXFormatModule } from '@acorex/core/format';\nimport { NgModule } from '@angular/core';\nimport { AXFileSizeFormatter } from './file-size-formatter';\n\n@NgModule({\n imports: [AXFormatModule.forChild({ formatters: [AXFileSizeFormatter] })],\n exports: [],\n declarations: [],\n providers: [AXFileSizeFormatter],\n})\nexport class AXFileModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1"],"mappings":";;;;;;;MAca,mBAAmB,CAAA;AAC9B,IAAA,IAAI,IAAI,GAAA;AACN,QAAA,OAAO,UAAU,CAAC;KACnB;AAED,IAAA,MAAM,CAAC,KAAa,EAAA;AAClB,QAAA,MAAM,IAAI,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,IAA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