From c3f1017368a0fd8e61c24619ad83be8b4160a3dc Mon Sep 17 00:00:00 2001 From: rnicholus Date: Tue, 17 Oct 2017 11:35:13 -0500 Subject: [PATCH] feat(wrappers): expose qq namespace via wrapper module named export --- README.md | 11 +++++++++++ package.json | 4 ++-- src/azure.js | 2 ++ src/s3.js | 2 ++ src/test/unit/base-wrapper.spec.js | 13 +++++++++++-- src/traditional.js | 2 ++ 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 30c3b6b..636268a 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,21 @@ You'll also need to explicitly install [Fine Uploader](https://github.com/FineUp Note: You can access the entire `qq` namespace on any uploader instance. For example, if you are using Fine Uploader S3, and want to access the `status` object, your code may look something like this: ```js +import FineUploaderS3 from 'fine-uploader-wrappers/s3' + const uploader = new FineUploaderS3({ ... }) const queuedFileStatus = uploader.qq.status.QUEUED ``` +_-or-_ via the wrapper module: + +```js +import FineUploaderS3, { qq } from 'fine-uploader-wrappers/s3' + +const uploader = new FineUploaderS3({ ... }) +const queuedFileStatus = qq.status.QUEUED +``` + #### Azure This enables you to upload to Azure directly. Your server must provide signature and done endpoints. The Azure uploading workflow is documented on the [Azure feature page](http://docs.fineuploader.com/branch/master/features/azure.html). Some examples servers can be found in the [server-examples repository](https://github.com/FineUploader/server-examples). diff --git a/package.json b/package.json index ca3eb92..5d5368f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fine-uploader-wrappers", - "version": "1.0.1", + "version": "1.1.0", "license": "MIT", "description": "Fine Uploader core ES6 class wrappers that provide additional features.", "author": { @@ -55,7 +55,7 @@ "build": "rm -rf lib && mkdir -p lib && cp -pR src/ lib && babel lib --out-dir lib", "lint": "eslint src/. --ext .js --cache", "manual-test": "webpack --config config/webpack.manual-test.config.js --watch --display-error-details", - "push-to-npm": "cp package.json README.md LICENSE lib && (cd lib ; npm publish)", + "push-to-npm": "cp package.json README.md LICENSE lib && (cd lib ; npm publish --tag next)", "release": "npm run test && npm run build && npm run push-to-npm", "test": "npm run lint && if [ $CI ]; then karma start config/karma.conf; else karma start config/karma.dev.conf; fi" } diff --git a/src/azure.js b/src/azure.js index bf57212..44bb205 100644 --- a/src/azure.js +++ b/src/azure.js @@ -12,3 +12,5 @@ export default class FineUploaderAzure extends BaseWrapper { }) } } + +export { qq } diff --git a/src/s3.js b/src/s3.js index 9222f30..1b28dae 100644 --- a/src/s3.js +++ b/src/s3.js @@ -12,3 +12,5 @@ export default class FineUploaderS3 extends BaseWrapper { }) } } + +export { qq } diff --git a/src/test/unit/base-wrapper.spec.js b/src/test/unit/base-wrapper.spec.js index 06bd0ae..5a4c5ea 100644 --- a/src/test/unit/base-wrapper.spec.js +++ b/src/test/unit/base-wrapper.spec.js @@ -1,6 +1,9 @@ import qq from 'fine-uploader/lib/core' -import FineUploaderTraditional from 'src/traditional' +import FineUploaderTraditional, { qq as traditionalQq } from 'src/traditional' +import { qq as s3Qq } from 'src/s3' +import { qq as azureQq } from 'src/azure' + const sampleBlob = new Blob(['hi!'], { type : 'text/plain' }) const sampleBlobWrapper = { blob: sampleBlob, name: 'test' } @@ -315,11 +318,17 @@ describe('Fine Uploader wrapper classes', () => { }, 100) }) - it('provides access to the entire qq namespace', () => { + it('provides access to the entire qq namespace from wrapper instance', () => { const wrapper = new FineUploaderTraditional({ options: {} }) expect(wrapper.qq).toBeTruthy() expect(wrapper.qq.status.QUEUED).toBe('queued') }) + + it('provides access to the entire qq namespace from wrapper export', () => { + expect(traditionalQq.status.QUEUED).toBe('queued') + expect(s3Qq.status.QUEUED).toBe('queued') + expect(azureQq.status.QUEUED).toBe('queued') + }) }) }) diff --git a/src/traditional.js b/src/traditional.js index acee598..9edc3f1 100644 --- a/src/traditional.js +++ b/src/traditional.js @@ -12,3 +12,5 @@ export default class FineUploaderTraditional extends BaseWrapper { }) } } + +export { qq }