Browse Source

🚨`this.core` to `this.uppy` everywhere

danger again
Artur Paikin 7 years ago
parent
commit
ed9aa1a537

+ 11 - 11
src/core/Plugin.js

@@ -13,8 +13,8 @@ const getFormData = require('get-form-data')
  * @return {array | string} files or success/fail message
  */
 module.exports = class Plugin {
-  constructor (core, opts) {
-    this.core = core
+  constructor (uppy, opts) {
+    this.uppy = uppy
     this.opts = opts || {}
 
     // clear everything inside the target selector
@@ -27,14 +27,14 @@ module.exports = class Plugin {
   }
 
   getPluginState () {
-    return this.core.state.plugins[this.id]
+    return this.uppy.state.plugins[this.id]
   }
 
   setPluginState (update) {
-    const plugins = Object.assign({}, this.core.state.plugins)
+    const plugins = Object.assign({}, this.uppy.state.plugins)
     plugins[this.id] = Object.assign({}, plugins[this.id], update)
 
-    this.core.setState({
+    this.uppy.setState({
       plugins: plugins
     })
   }
@@ -68,12 +68,12 @@ module.exports = class Plugin {
         this.el = yo.update(this.el, this.render(state))
       })
 
-      this.core.log(`Installing ${callerPluginName} to a DOM element`)
+      this.uppy.log(`Installing ${callerPluginName} to a DOM element`)
 
       // attempt to extract meta from form element
       if (this.opts.getMetaFromForm && targetElement.nodeName === 'FORM') {
         const formMeta = getFormData(targetElement)
-        this.core.setMeta(formMeta)
+        this.uppy.setMeta(formMeta)
       }
 
       // clear everything inside the target container
@@ -81,7 +81,7 @@ module.exports = class Plugin {
         targetElement.innerHTML = ''
       }
 
-      this.el = plugin.render(this.core.state)
+      this.el = plugin.render(this.uppy.state)
       targetElement.appendChild(this.el)
 
       return this.el
@@ -95,7 +95,7 @@ module.exports = class Plugin {
       // Targeting a plugin type
       const Target = target
       // Find the target plugin instance.
-      this.core.iteratePlugins((plugin) => {
+      this.uppy.iteratePlugins((plugin) => {
         if (plugin instanceof Target) {
           targetPlugin = plugin
           return false
@@ -105,12 +105,12 @@ module.exports = class Plugin {
 
     if (targetPlugin) {
       const targetPluginName = targetPlugin.id
-      this.core.log(`Installing ${callerPluginName} to ${targetPluginName}`)
+      this.uppy.log(`Installing ${callerPluginName} to ${targetPluginName}`)
       this.el = targetPlugin.addTarget(plugin)
       return this.el
     }
 
-    this.core.log(`Not installing ${callerPluginName}`)
+    this.uppy.log(`Not installing ${callerPluginName}`)
     throw new Error(`Invalid target option given to ${callerPluginName}`)
   }
 

+ 15 - 15
src/plugins/AwsS3/index.js

@@ -3,8 +3,8 @@ const Translator = require('../../core/Translator')
 const XHRUpload = require('../XHRUpload')
 
 module.exports = class AwsS3 extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'uploader'
     this.id = 'AwsS3'
     this.title = 'AWS S3'
@@ -45,7 +45,7 @@ module.exports = class AwsS3 extends Plugin {
 
   prepareUpload (fileIDs) {
     fileIDs.forEach((id) => {
-      this.core.emit('preprocess-progress', id, {
+      this.uppy.emit('preprocess-progress', id, {
         mode: 'determinate',
         message: this.i18n('preparingUpload'),
         value: 0
@@ -54,24 +54,24 @@ module.exports = class AwsS3 extends Plugin {
 
     return Promise.all(
       fileIDs.map((id) => {
-        const file = this.core.getFile(id)
+        const file = this.uppy.getFile(id)
         const paramsPromise = Promise.resolve()
           .then(() => this.opts.getUploadParameters(file))
         return paramsPromise.then((params) => {
-          this.core.emit('preprocess-progress', file.id, {
+          this.uppy.emit('preprocess-progress', file.id, {
             mode: 'determinate',
             message: this.i18n('preparingUpload'),
             value: 1
           })
           return params
         }).catch((error) => {
-          this.core.emit('upload-error', file.id, error)
+          this.uppy.emit('upload-error', file.id, error)
         })
       })
     ).then((responses) => {
       const updatedFiles = {}
       fileIDs.forEach((id, index) => {
-        const file = this.core.getFile(id)
+        const file = this.uppy.getFile(id)
         if (file.error) {
           return
         }
@@ -101,20 +101,20 @@ module.exports = class AwsS3 extends Plugin {
         updatedFiles[id] = updatedFile
       })
 
-      this.core.setState({
-        files: Object.assign({}, this.core.getState().files, updatedFiles)
+      this.uppy.setState({
+        files: Object.assign({}, this.uppy.getState().files, updatedFiles)
       })
 
       fileIDs.forEach((id) => {
-        this.core.emit('preprocess-complete', id)
+        this.uppy.emit('preprocess-complete', id)
       })
     })
   }
 
   install () {
-    this.core.addPreProcessor(this.prepareUpload)
+    this.uppy.addPreProcessor(this.prepareUpload)
 
-    this.core.use(XHRUpload, {
+    this.uppy.use(XHRUpload, {
       fieldName: 'file',
       responseUrlFieldName: 'location',
       getResponseData (xhr) {
@@ -146,9 +146,9 @@ module.exports = class AwsS3 extends Plugin {
   }
 
   uninstall () {
-    const uploader = this.core.getPlugin('XHRUpload')
-    this.core.removePlugin(uploader)
+    const uploader = this.uppy.getPlugin('XHRUpload')
+    this.uppy.removePlugin(uploader)
 
-    this.core.removePreProcessor(this.prepareUpload)
+    this.uppy.removePreProcessor(this.prepareUpload)
   }
 }

+ 42 - 42
src/plugins/Dashboard/index.js

@@ -26,8 +26,8 @@ const FOCUSABLE_ELEMENTS = [
  * Dashboard UI with previews, metadata editing, tabs for various services and more
  */
 module.exports = class DashboardUI extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.id = this.opts.id || 'Dashboard'
     this.title = 'Dashboard'
     this.type = 'orchestrator'
@@ -123,7 +123,7 @@ module.exports = class DashboardUI extends Plugin {
         callerPluginType !== 'progressindicator' &&
         callerPluginType !== 'presenter') {
       let msg = 'Dashboard: Modal can only be used by plugins of types: acquirer, progressindicator, presenter'
-      this.core.log(msg)
+      this.uppy.log(msg)
       return
     }
 
@@ -249,7 +249,7 @@ module.exports = class DashboardUI extends Plugin {
     }
 
     if (!this.opts.inline && !showModalTrigger) {
-      this.core.log('Dashboard modal trigger not found, you won’t be able to select files. Make sure `trigger` is set correctly in Dashboard options', 'error')
+      this.uppy.log('Dashboard modal trigger not found, you won’t be able to select files. Make sure `trigger` is set correctly in Dashboard options', 'error')
     }
 
     if (!this.opts.inline) {
@@ -261,8 +261,8 @@ module.exports = class DashboardUI extends Plugin {
       this.handleDrop(files)
     })
 
-    this.core.on('dashboard:file-card', this.handleFileCard)
-    this.core.on('file-added', this.addDashboardMetaToNewFile)
+    this.uppy.on('dashboard:file-card', this.handleFileCard)
+    this.uppy.on('file-added', this.addDashboardMetaToNewFile)
 
     window.addEventListener('resize', this.updateDashboardElWidth)
   }
@@ -279,8 +279,8 @@ module.exports = class DashboardUI extends Plugin {
 
     this.removeDragDropListener()
 
-    this.core.off('dashboard:file-card', this.handleFileCard)
-    this.core.off('file-added', this.addDashboardMetaToNewFile)
+    this.uppy.off('dashboard:file-card', this.handleFileCard)
+    this.uppy.off('file-added', this.addDashboardMetaToNewFile)
 
     window.removeEventListener('resize', this.updateDashboardElWidth)
   }
@@ -291,13 +291,13 @@ module.exports = class DashboardUI extends Plugin {
     metaFields.forEach((item) => {
       const obj = {}
       obj[item.id] = item.value
-      this.core.setFileMeta(file.id, obj)
+      this.uppy.setFileMeta(file.id, obj)
     })
   }
 
   updateDashboardElWidth () {
     const dashboardEl = this.el.querySelector('.UppyDashboard-inner')
-    this.core.log(`Dashboard width: ${dashboardEl.offsetWidth}`)
+    this.uppy.log(`Dashboard width: ${dashboardEl.offsetWidth}`)
 
     this.setPluginState({
       containerWidth: dashboardEl.offsetWidth
@@ -311,10 +311,10 @@ module.exports = class DashboardUI extends Plugin {
   }
 
   handleDrop (files) {
-    this.core.log('[Dashboard] Files were dropped')
+    this.uppy.log('[Dashboard] Files were dropped')
 
     files.forEach((file) => {
-      this.core.addFile({
+      this.uppy.addFile({
         source: this.id,
         name: file.name,
         type: file.type,
@@ -324,15 +324,15 @@ module.exports = class DashboardUI extends Plugin {
   }
 
   cancelAll () {
-    this.core.emit('cancel-all')
+    this.uppy.emit('cancel-all')
   }
 
   pauseAll () {
-    this.core.emit('pause-all')
+    this.uppy.emit('pause-all')
   }
 
   resumeAll () {
-    this.core.emit('resume-all')
+    this.uppy.emit('resume-all')
   }
 
   render (state) {
@@ -363,7 +363,7 @@ module.exports = class DashboardUI extends Plugin {
     totalUploadedSize = prettyBytes(totalUploadedSize)
 
     const attachRenderFunctionToTarget = (target) => {
-      const plugin = this.core.getPlugin(target.id)
+      const plugin = this.uppy.getPlugin(target.id)
       return Object.assign({}, target, {
         icon: plugin.icon || this.opts.defaultTabIcon,
         render: plugin.render
@@ -371,7 +371,7 @@ module.exports = class DashboardUI extends Plugin {
     }
 
     const isSupported = (target) => {
-      const plugin = this.core.getPlugin(target.id)
+      const plugin = this.uppy.getPlugin(target.id)
       // If the plugin does not provide a `supported` check, assume the plugin works everywhere.
       if (typeof plugin.isSupported !== 'function') {
         return true
@@ -388,24 +388,24 @@ module.exports = class DashboardUI extends Plugin {
       .map(attachRenderFunctionToTarget)
 
     const startUpload = (ev) => {
-      this.core.upload().catch((err) => {
+      this.uppy.upload().catch((err) => {
         // Log error.
-        this.core.log(err.stack || err.message || err)
+        this.uppy.log(err.stack || err.message || err)
       })
     }
 
     const cancelUpload = (fileID) => {
-      this.core.emit('upload-cancel', fileID)
-      this.core.removeFile(fileID)
+      this.uppy.emit('upload-cancel', fileID)
+      this.uppy.removeFile(fileID)
     }
 
     const showFileCard = (fileID) => {
-      this.core.emit('dashboard:file-card', fileID)
+      this.uppy.emit('dashboard:file-card', fileID)
     }
 
     const fileCardDone = (meta, fileID) => {
-      this.core.setFileMeta(fileID, meta)
-      this.core.emit('dashboard:file-card')
+      this.uppy.setFileMeta(fileID, meta)
+      this.uppy.emit('dashboard:file-card')
     }
 
     return Dashboard({
@@ -417,9 +417,9 @@ module.exports = class DashboardUI extends Plugin {
       totalProgress: state.totalProgress,
       acquirers: acquirers,
       activePanel: pluginState.activePanel,
-      getPlugin: this.core.getPlugin,
+      getPlugin: this.uppy.getPlugin,
       progressindicators: progressindicators,
-      autoProceed: this.core.opts.autoProceed,
+      autoProceed: this.uppy.opts.autoProceed,
       hideUploadButton: this.opts.hideUploadButton,
       id: this.id,
       closeModal: this.requestCloseModal,
@@ -429,19 +429,19 @@ module.exports = class DashboardUI extends Plugin {
       semiTransparent: this.opts.semiTransparent,
       showPanel: this.showPanel,
       hideAllPanels: this.hideAllPanels,
-      log: this.core.log,
+      log: this.uppy.log,
       i18n: this.i18n,
       pauseAll: this.pauseAll,
       resumeAll: this.resumeAll,
-      addFile: this.core.addFile,
-      removeFile: this.core.removeFile,
-      info: this.core.info,
+      addFile: this.uppy.addFile,
+      removeFile: this.uppy.removeFile,
+      info: this.uppy.info,
       note: this.opts.note,
       metaFields: this.getPluginState().metaFields,
-      resumableUploads: this.core.state.capabilities.resumableUploads || false,
+      resumableUploads: this.uppy.state.capabilities.resumableUploads || false,
       startUpload: startUpload,
-      pauseUpload: this.core.pauseResume,
-      retryUpload: this.core.retryUpload,
+      pauseUpload: this.uppy.pauseResume,
+      retryUpload: this.uppy.retryUpload,
       cancelUpload: cancelUpload,
       fileCardFor: pluginState.fileCardFor,
       showFileCard: showFileCard,
@@ -455,7 +455,7 @@ module.exports = class DashboardUI extends Plugin {
   }
 
   discoverProviderPlugins () {
-    this.core.iteratePlugins((plugin) => {
+    this.uppy.iteratePlugins((plugin) => {
       if (plugin && !plugin.target && plugin.opts && plugin.opts.target === this.constructor) {
         this.addTarget(plugin)
       }
@@ -479,19 +479,19 @@ module.exports = class DashboardUI extends Plugin {
 
     const plugins = this.opts.plugins || []
     plugins.forEach((pluginID) => {
-      const plugin = this.core.getPlugin(pluginID)
+      const plugin = this.uppy.getPlugin(pluginID)
       if (plugin) plugin.mount(this, plugin)
     })
 
     if (!this.opts.disableStatusBar) {
-      this.core.use(StatusBar, {
+      this.uppy.use(StatusBar, {
         target: this,
         hideUploadButton: this.opts.hideUploadButton
       })
     }
 
     if (!this.opts.disableInformer) {
-      this.core.use(Informer, {
+      this.uppy.use(Informer, {
         target: this
       })
     }
@@ -503,20 +503,20 @@ module.exports = class DashboardUI extends Plugin {
 
   uninstall () {
     if (!this.opts.disableInformer) {
-      const informer = this.core.getPlugin('Informer')
-      if (informer) this.core.removePlugin(informer)
+      const informer = this.uppy.getPlugin('Informer')
+      if (informer) this.uppy.removePlugin(informer)
     }
 
     if (!this.opts.disableStatusBar) {
-      const statusBar = this.core.getPlugin('StatusBar')
+      const statusBar = this.uppy.getPlugin('StatusBar')
       // Checking if this plugin exists, in case it was removed by uppy-core
       // before the Dashboard was.
-      if (statusBar) this.core.removePlugin(statusBar)
+      if (statusBar) this.uppy.removePlugin(statusBar)
     }
 
     const plugins = this.opts.plugins || []
     plugins.forEach((pluginID) => {
-      const plugin = this.core.getPlugin(pluginID)
+      const plugin = this.uppy.getPlugin(pluginID)
       if (plugin) plugin.unmount()
     })
 

+ 7 - 7
src/plugins/DragDrop/index.js

@@ -9,8 +9,8 @@ const html = require('yo-yo')
  *
  */
 module.exports = class DragDrop extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'acquirer'
     this.id = this.opts.id || 'DragDrop'
     this.title = 'Drag & Drop'
@@ -83,10 +83,10 @@ module.exports = class DragDrop extends Plugin {
   }
 
   handleDrop (files) {
-    this.core.log('[DragDrop] Files dropped')
+    this.uppy.log('[DragDrop] Files dropped')
 
     files.forEach((file) => {
-      this.core.addFile({
+      this.uppy.addFile({
         source: this.id,
         name: file.name,
         type: file.type,
@@ -96,12 +96,12 @@ module.exports = class DragDrop extends Plugin {
   }
 
   onInputChange (ev) {
-    this.core.log('[DragDrop] Files selected through input')
+    this.uppy.log('[DragDrop] Files selected through input')
 
     const files = toArray(ev.target.files)
 
     files.forEach((file) => {
-      this.core.addFile({
+      this.uppy.addFile({
         source: this.id,
         name: file.name,
         type: file.type,
@@ -146,7 +146,7 @@ module.exports = class DragDrop extends Plugin {
     }
     this.removeDragDropListener = dragDrop(this.el, (files) => {
       this.handleDrop(files)
-      this.core.log(files)
+      this.uppy.log(files)
     })
   }
 }

+ 3 - 3
src/plugins/Dropbox/index.js

@@ -5,8 +5,8 @@ const View = require('../Provider/view')
 const icons = require('./icons')
 
 module.exports = class Dropbox extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'acquirer'
     this.id = this.opts.id || 'Dropbox'
     this.title = 'Dropbox'
@@ -20,7 +20,7 @@ module.exports = class Dropbox extends Plugin {
 
     // writing out the key explicitly for readability the key used to store
     // the provider instance must be equal to this.id.
-    this[this.id] = new Provider(core, {
+    this[this.id] = new Provider(uppy, {
       host: this.opts.host,
       provider: 'dropbox'
     })

+ 4 - 4
src/plugins/Dummy.js

@@ -7,8 +7,8 @@ const html = require('yo-yo')
  * A test plugin, does nothing useful
  */
 module.exports = class Dummy extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'acquirer'
     this.id = this.opts.id || 'Dummy'
     this.title = 'Mr. Plugin'
@@ -54,7 +54,7 @@ module.exports = class Dummy extends Plugin {
   }
 
   install () {
-    this.core.setState({dummy: {text: '123'}})
+    this.uppy.setState({dummy: {text: '123'}})
 
     const target = this.opts.target
     if (target) {
@@ -62,7 +62,7 @@ module.exports = class Dummy extends Plugin {
     }
 
     setTimeout(() => {
-      this.core.setState({dummy: {text: '!!!'}})
+      this.uppy.setState({dummy: {text: '!!!'}})
     }, 2000)
   }
 }

+ 4 - 4
src/plugins/FileInput.js

@@ -4,8 +4,8 @@ const Translator = require('../core/Translator')
 const html = require('yo-yo')
 
 module.exports = class FileInput extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.id = this.opts.id || 'FileInput'
     this.title = 'File Input'
     this.type = 'acquirer'
@@ -41,12 +41,12 @@ module.exports = class FileInput extends Plugin {
   }
 
   handleInputChange (ev) {
-    this.core.log('All right, something selected through input...')
+    this.uppy.log('All right, something selected through input...')
 
     const files = toArray(ev.target.files)
 
     files.forEach((file) => {
-      this.core.addFile({
+      this.uppy.addFile({
         source: this.id,
         name: file.name,
         type: file.type,

+ 40 - 40
src/plugins/GoldenRetriever/index.js

@@ -11,8 +11,8 @@ const MetaDataStore = require('./MetaDataStore')
 * https://uppy.io/blog/2017/07/golden-retriever/
 */
 module.exports = class GoldenRetriever extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'debugger'
     this.id = 'GoldenRetriever'
     this.title = 'Golden Retriever'
@@ -26,16 +26,16 @@ module.exports = class GoldenRetriever extends Plugin {
 
     this.MetaDataStore = new MetaDataStore({
       expires: this.opts.expires,
-      storeName: core.getID()
+      storeName: uppy.getID()
     })
     this.ServiceWorkerStore = null
     if (this.opts.serviceWorker) {
-      this.ServiceWorkerStore = new ServiceWorkerStore({ storeName: core.getID() })
+      this.ServiceWorkerStore = new ServiceWorkerStore({ storeName: uppy.getID() })
     }
     this.IndexedDBStore = new IndexedDBStore(Object.assign(
       { expires: this.opts.expires },
       opts.indexedDB || {},
-      { storeName: core.getID() }))
+      { storeName: uppy.getID() }))
 
     this.saveFilesStateToLocalStorage = this.saveFilesStateToLocalStorage.bind(this)
     this.loadFilesStateFromLocalStorage = this.loadFilesStateFromLocalStorage.bind(this)
@@ -48,8 +48,8 @@ module.exports = class GoldenRetriever extends Plugin {
     const savedState = this.MetaDataStore.load()
 
     if (savedState) {
-      this.core.log('Recovered some state from Local Storage')
-      this.core.setState(savedState)
+      this.uppy.log('Recovered some state from Local Storage')
+      this.uppy.setState(savedState)
     }
   }
 
@@ -60,9 +60,9 @@ module.exports = class GoldenRetriever extends Plugin {
   getWaitingFiles () {
     const waitingFiles = {}
 
-    const allFiles = this.core.state.files
+    const allFiles = this.uppy.state.files
     Object.keys(allFiles).forEach((fileID) => {
-      const file = this.core.getFile(fileID)
+      const file = this.uppy.getFile(fileID)
       if (!file.progress || !file.progress.uploadStarted) {
         waitingFiles[fileID] = file
       }
@@ -79,13 +79,13 @@ module.exports = class GoldenRetriever extends Plugin {
   getUploadingFiles () {
     const uploadingFiles = {}
 
-    const { currentUploads } = this.core.state
+    const { currentUploads } = this.uppy.state
     if (currentUploads) {
       const uploadIDs = Object.keys(currentUploads)
       uploadIDs.forEach((uploadID) => {
         const filesInUpload = currentUploads[uploadID].fileIDs
         filesInUpload.forEach((fileID) => {
-          uploadingFiles[fileID] = this.core.getFile(fileID)
+          uploadingFiles[fileID] = this.uppy.getFile(fileID)
         })
       })
     }
@@ -100,7 +100,7 @@ module.exports = class GoldenRetriever extends Plugin {
     )
 
     this.MetaDataStore.save({
-      currentUploads: this.core.state.currentUploads,
+      currentUploads: this.uppy.state.currentUploads,
       files: filesToSave
     })
   }
@@ -108,13 +108,13 @@ module.exports = class GoldenRetriever extends Plugin {
   loadFileBlobsFromServiceWorker () {
     this.ServiceWorkerStore.list().then((blobs) => {
       const numberOfFilesRecovered = Object.keys(blobs).length
-      const numberOfFilesTryingToRecover = Object.keys(this.core.state.files).length
+      const numberOfFilesTryingToRecover = Object.keys(this.uppy.state.files).length
       if (numberOfFilesRecovered === numberOfFilesTryingToRecover) {
-        this.core.log(`Successfully recovered ${numberOfFilesRecovered} blobs from Service Worker!`)
-        this.core.info(`Successfully recovered ${numberOfFilesRecovered} files`, 'success', 3000)
+        this.uppy.log(`Successfully recovered ${numberOfFilesRecovered} blobs from Service Worker!`)
+        this.uppy.info(`Successfully recovered ${numberOfFilesRecovered} files`, 'success', 3000)
         this.onBlobsLoaded(blobs)
       } else {
-        this.core.log('Failed to recover blobs from Service Worker, trying IndexedDB now...')
+        this.uppy.log('Failed to recover blobs from Service Worker, trying IndexedDB now...')
         this.loadFileBlobsFromIndexedDB()
       }
     })
@@ -125,19 +125,19 @@ module.exports = class GoldenRetriever extends Plugin {
       const numberOfFilesRecovered = Object.keys(blobs).length
 
       if (numberOfFilesRecovered > 0) {
-        this.core.log(`Successfully recovered ${numberOfFilesRecovered} blobs from Indexed DB!`)
-        this.core.info(`Successfully recovered ${numberOfFilesRecovered} files`, 'success', 3000)
+        this.uppy.log(`Successfully recovered ${numberOfFilesRecovered} blobs from Indexed DB!`)
+        this.uppy.info(`Successfully recovered ${numberOfFilesRecovered} files`, 'success', 3000)
         return this.onBlobsLoaded(blobs)
       }
-      this.core.log('Couldn’t recover anything from IndexedDB :(')
+      this.uppy.log('Couldn’t recover anything from IndexedDB :(')
     })
   }
 
   onBlobsLoaded (blobs) {
     const obsoleteBlobs = []
-    const updatedFiles = Object.assign({}, this.core.state.files)
+    const updatedFiles = Object.assign({}, this.uppy.state.files)
     Object.keys(blobs).forEach((fileID) => {
-      const originalFile = this.core.getFile(fileID)
+      const originalFile = this.uppy.getFile(fileID)
       if (!originalFile) {
         obsoleteBlobs.push(fileID)
         return
@@ -152,16 +152,16 @@ module.exports = class GoldenRetriever extends Plugin {
       const updatedFile = Object.assign({}, originalFile, updatedFileData)
       updatedFiles[fileID] = updatedFile
 
-      this.core.generatePreview(updatedFile)
+      this.uppy.generatePreview(updatedFile)
     })
-    this.core.setState({
+    this.uppy.setState({
       files: updatedFiles
     })
-    this.core.emit('restored')
+    this.uppy.emit('restored')
 
     if (obsoleteBlobs.length) {
       this.deleteBlobs(obsoleteBlobs).then(() => {
-        this.core.log(`[GoldenRetriever] cleaned up ${obsoleteBlobs.length} old files`)
+        this.uppy.log(`[GoldenRetriever] cleaned up ${obsoleteBlobs.length} old files`)
       })
     }
   }
@@ -182,52 +182,52 @@ module.exports = class GoldenRetriever extends Plugin {
   install () {
     this.loadFilesStateFromLocalStorage()
 
-    if (Object.keys(this.core.state.files).length > 0) {
+    if (Object.keys(this.uppy.state.files).length > 0) {
       if (this.ServiceWorkerStore) {
-        this.core.log('Attempting to load files from Service Worker...')
+        this.uppy.log('Attempting to load files from Service Worker...')
         this.loadFileBlobsFromServiceWorker()
       } else {
-        this.core.log('Attempting to load files from Indexed DB...')
+        this.uppy.log('Attempting to load files from Indexed DB...')
         this.loadFileBlobsFromIndexedDB()
       }
     }
 
-    this.core.on('file-added', (file) => {
+    this.uppy.on('file-added', (file) => {
       if (file.isRemote) return
 
       if (this.ServiceWorkerStore) {
         this.ServiceWorkerStore.put(file).catch((err) => {
-          this.core.log('Could not store file', 'error')
-          this.core.log(err)
+          this.uppy.log('Could not store file', 'error')
+          this.uppy.log(err)
         })
       }
 
       this.IndexedDBStore.put(file).catch((err) => {
-        this.core.log('Could not store file', 'error')
-        this.core.log(err)
+        this.uppy.log('Could not store file', 'error')
+        this.uppy.log(err)
       })
     })
 
-    this.core.on('file-removed', (fileID) => {
+    this.uppy.on('file-removed', (fileID) => {
       if (this.ServiceWorkerStore) this.ServiceWorkerStore.delete(fileID)
       this.IndexedDBStore.delete(fileID)
     })
 
-    this.core.on('complete', ({ successful }) => {
+    this.uppy.on('complete', ({ successful }) => {
       const fileIDs = successful.map((file) => file.id)
       this.deleteBlobs(fileIDs).then(() => {
-        this.core.log(`[GoldenRetriever] removed ${successful.length} files that finished uploading`)
+        this.uppy.log(`[GoldenRetriever] removed ${successful.length} files that finished uploading`)
       })
     })
 
-    this.core.on('state-update', this.saveFilesStateToLocalStorage)
+    this.uppy.on('state-update', this.saveFilesStateToLocalStorage)
 
-    this.core.on('restored', () => {
+    this.uppy.on('restored', () => {
       // start all uploads again when file blobs are restored
-      const { currentUploads } = this.core.getState()
+      const { currentUploads } = this.uppy.getState()
       if (currentUploads) {
         Object.keys(currentUploads).forEach((uploadId) => {
-          this.core.restore(uploadId, currentUploads[uploadId])
+          this.uppy.restore(uploadId, currentUploads[uploadId])
         })
       }
     })

+ 3 - 3
src/plugins/GoogleDrive/index.js

@@ -4,8 +4,8 @@ const Provider = require('../Provider')
 const View = require('../Provider/view')
 
 module.exports = class GoogleDrive extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'acquirer'
     this.id = this.opts.id || 'GoogleDrive'
     this.title = 'Google Drive'
@@ -17,7 +17,7 @@ module.exports = class GoogleDrive extends Plugin {
 
     // writing out the key explicitly for readability the key used to store
     // the provider instance must be equal to this.id.
-    this[this.id] = new Provider(core, {
+    this[this.id] = new Provider(uppy, {
       host: this.opts.host,
       provider: 'drive',
       authProvider: 'google'

+ 2 - 2
src/plugins/Informer.js

@@ -9,8 +9,8 @@ const html = require('yo-yo')
  *
  */
 module.exports = class Informer extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'progressindicator'
     this.id = this.opts.id || 'Informer'
     this.title = 'Informer'

+ 4 - 4
src/plugins/Instagram/index.js

@@ -4,8 +4,8 @@ const Provider = require('../Provider')
 const View = require('../Provider/view')
 
 module.exports = class Instagram extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'acquirer'
     this.id = this.opts.id || 'Instagram'
     this.title = 'Instagram'
@@ -19,7 +19,7 @@ module.exports = class Instagram extends Plugin {
 
     // writing out the key explicitly for readability the key used to store
     // the provider instance must be equal to this.id.
-    this[this.id] = new Provider(core, {
+    this[this.id] = new Provider(uppy, {
       host: this.opts.host,
       provider: 'instagram',
       authProvider: 'instagram'
@@ -126,7 +126,7 @@ module.exports = class Instagram extends Plugin {
   }
 
   getNextPagePath () {
-    const { files } = this.core.getState()[this.stateId]
+    const { files } = this.uppy.getState()[this.stateId]
     return `recent?max_id=${this.getItemId(files[files.length - 1])}`
   }
 

+ 4 - 4
src/plugins/MagicLog.js

@@ -8,8 +8,8 @@ const Plugin = require('../core/Plugin')
  *
  */
 module.exports = class MagicLog extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'debugger'
     this.id = 'MagicLog'
     this.title = 'Magic Log'
@@ -32,10 +32,10 @@ module.exports = class MagicLog extends Plugin {
   }
 
   install () {
-    this.core.on('state-update', this.handleStateUpdate)
+    this.uppy.on('state-update', this.handleStateUpdate)
   }
 
   uninstall () {
-    this.core.off('state-update', this.handleStateUpdate)
+    this.uppy.off('state-update', this.handleStateUpdate)
   }
 }

+ 2 - 2
src/plugins/ProgressBar.js

@@ -6,8 +6,8 @@ const html = require('yo-yo')
  *
  */
 module.exports = class ProgressBar extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.id = this.opts.id || 'ProgressBar'
     this.title = 'Progress Bar'
     this.type = 'progressindicator'

+ 5 - 5
src/plugins/Provider/index.js

@@ -7,8 +7,8 @@ const _getName = (id) => {
 }
 
 module.exports = class Provider {
-  constructor (core, opts) {
-    this.core = core
+  constructor (uppy, opts) {
+    this.uppy = uppy
     this.opts = opts
     this.provider = opts.provider
     this.id = this.provider
@@ -19,18 +19,18 @@ module.exports = class Provider {
   }
 
   get hostname () {
-    const uppyServer = this.core.state.uppyServer || {}
+    const uppyServer = this.uppy.state.uppyServer || {}
     const host = this.opts.host
     return uppyServer[host] || host
   }
 
   onReceiveResponse (response) {
-    const uppyServer = this.core.state.uppyServer || {}
+    const uppyServer = this.uppy.state.uppyServer || {}
     const host = this.opts.host
     const headers = response.headers
     // Store the self-identified domain name for the uppy-server we just hit.
     if (headers.has('i-am') && headers.get('i-am') !== uppyServer[host]) {
-      this.core.setState({
+      this.uppy.setState({
         uppyServer: Object.assign({}, uppyServer, {
           [host]: headers.get('i-am')
         })

+ 16 - 16
src/plugins/Provider/view/index.js

@@ -70,14 +70,14 @@ module.exports = class View {
     this.handleScroll = this.handleScroll.bind(this)
     this.donePicking = this.donePicking.bind(this)
 
-    this.plugin.core.on('file-removed', this.updateFolderState)
+    this.plugin.uppy.on('file-removed', this.updateFolderState)
 
     // Visual
     this.render = this.render.bind(this)
   }
 
   tearDown () {
-    this.plugin.core.off('file-removed', this.updateFolderState)
+    this.plugin.uppy.off('file-removed', this.updateFolderState)
   }
 
   _updateFilesAndFolders (res, files, folders) {
@@ -167,8 +167,8 @@ module.exports = class View {
       if (fileType && Utils.isPreviewSupported(fileType)) {
         tagFile.preview = this.plugin.getItemThumbnailUrl(file)
       }
-      this.plugin.core.log('Adding remote file')
-      this.plugin.core.addFile(tagFile)
+      this.plugin.uppy.log('Adding remote file')
+      this.plugin.uppy.addFile(tagFile)
       if (!isCheckbox) {
         this.donePicking()
       }
@@ -319,7 +319,7 @@ module.exports = class View {
       }
       return false
     }
-    return (itemId in this.plugin.core.getState().files)
+    return (itemId in this.plugin.uppy.getState().files)
   }
 
   /**
@@ -348,7 +348,7 @@ module.exports = class View {
       state = this.plugin.getPluginState()
       state.selectedFolders[folderId] = {loading: false, files: files}
       this.plugin.setPluginState({selectedFolders: folders})
-      const dashboard = this.plugin.core.getPlugin('Dashboard')
+      const dashboard = this.plugin.uppy.getPlugin('Dashboard')
       let message
       if (files.length) {
         message = dashboard.i18n('folderAdded', {
@@ -357,7 +357,7 @@ module.exports = class View {
       } else {
         message = dashboard.i18n('emptyFolderAdded')
       }
-      this.plugin.core.info(message)
+      this.plugin.uppy.info(message)
     }).catch((e) => {
       state = this.plugin.getPluginState()
       delete state.selectedFolders[folderId]
@@ -382,8 +382,8 @@ module.exports = class View {
     // is removed and 'core:file-removed' is emitted.
     const files = folder.files.concat([])
     for (const fileId of files) {
-      if (fileId in this.plugin.core.getState().files) {
-        this.plugin.core.removeFile(fileId)
+      if (fileId in this.plugin.uppy.getState().files) {
+        this.plugin.uppy.removeFile(fileId)
       }
     }
     delete folders[folderId]
@@ -449,8 +449,8 @@ module.exports = class View {
         if (this.plugin.isFolder(item)) {
           this.removeFolder(itemId)
         } else {
-          if (itemId in this.plugin.core.getState().files) {
-            this.plugin.core.removeFile(itemId)
+          if (itemId in this.plugin.uppy.getState().files) {
+            this.plugin.uppy.removeFile(itemId)
           }
         }
       }
@@ -512,10 +512,10 @@ module.exports = class View {
   }
 
   handleError (error) {
-    const core = this.plugin.core
-    const message = core.i18n('uppyServerError')
-    core.log(error.toString())
-    core.info({message: message, details: error.toString()}, 'error', 5000)
+    const uppy = this.plugin.uppy
+    const message = uppy.i18n('uppyServerError')
+    uppy.log(error.toString())
+    uppy.info({message: message, details: error.toString()}, 'error', 5000)
   }
 
   handleScroll (e) {
@@ -535,7 +535,7 @@ module.exports = class View {
   }
 
   donePicking () {
-    const dashboard = this.plugin.core.getPlugin('Dashboard')
+    const dashboard = this.plugin.uppy.getPlugin('Dashboard')
     if (dashboard) dashboard.hideAllPanels()
   }
 

+ 5 - 5
src/plugins/Redux.js

@@ -1,8 +1,8 @@
 const Plugin = require('../core/Plugin')
 
 module.exports = class Redux extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'state-sync'
     this.id = 'Redux'
     this.title = 'Redux Emitter'
@@ -23,11 +23,11 @@ module.exports = class Redux extends Plugin {
   }
 
   install () {
-    this.core.on('state-update', this.handleStateUpdate)
-    this.handleStateUpdate({}, this.core.state, this.core.state) // set the initial redux state
+    this.uppy.on('state-update', this.handleStateUpdate)
+    this.handleStateUpdate({}, this.uppy.state, this.uppy.state) // set the initial redux state
   }
 
   uninstall () {
-    this.core.off('state-update', this.handleStateUpdate)
+    this.uppy.off('state-update', this.handleStateUpdate)
   }
 }

+ 9 - 9
src/plugins/ReduxDevTools.js

@@ -7,8 +7,8 @@ const Plugin = require('../core/Plugin')
  * and https://github.com/zalmoxisus/mobx-remotedev/blob/master/src/monitorActions.js
  */
 module.exports = class ReduxDevTools extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'debugger'
     this.id = 'ReduxDevTools'
     this.title = 'Redux DevTools'
@@ -36,18 +36,18 @@ module.exports = class ReduxDevTools extends Plugin {
         // Implement monitors actions
         switch (message.payload.type) {
           case 'RESET':
-            this.core.reset()
+            this.uppy.reset()
             return
           case 'IMPORT_STATE':
             const computedStates = message.payload.nextLiftedState.computedStates
-            this.core.state = Object.assign({}, this.core.state, computedStates[computedStates.length - 1].state)
-            this.core.updateAll(this.core.state)
+            this.uppy.state = Object.assign({}, this.uppy.state, computedStates[computedStates.length - 1].state)
+            this.uppy.updateAll(this.uppy.state)
             return
           case 'JUMP_TO_STATE':
           case 'JUMP_TO_ACTION':
             // this.setState(state)
-            this.core.state = Object.assign({}, this.core.state, JSON.parse(message.state))
-            this.core.updateAll(this.core.state)
+            this.uppy.state = Object.assign({}, this.uppy.state, JSON.parse(message.state))
+            this.uppy.updateAll(this.uppy.state)
         }
       }
     })
@@ -57,14 +57,14 @@ module.exports = class ReduxDevTools extends Plugin {
     this.withDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__
     if (this.withDevTools) {
       this.initDevTools()
-      this.core.on('state-update', this.handleStateChange)
+      this.uppy.on('state-update', this.handleStateChange)
     }
   }
 
   uninstall () {
     if (this.withDevTools) {
       this.devToolsUnsubscribe()
-      this.core.off('state-update', this.handleStateUpdate)
+      this.uppy.off('state-update', this.handleStateUpdate)
     }
   }
 }

+ 8 - 8
src/plugins/StatusBar/index.js

@@ -10,8 +10,8 @@ const prettyBytes = require('prettier-bytes')
  * A status bar.
  */
 module.exports = class StatusBarUI extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.id = this.opts.id || 'StatusBar'
     this.title = 'StatusBar'
     this.type = 'progressindicator'
@@ -139,7 +139,7 @@ module.exports = class StatusBarUI extends Plugin {
       !isAllErrored &&
       uploadStartedFiles.length > 0
 
-    const resumableUploads = this.core.getState().capabilities.resumableUploads || false
+    const resumableUploads = this.uppy.getState().capabilities.resumableUploads || false
 
     return StatusBar({
       error: state.error,
@@ -152,11 +152,11 @@ module.exports = class StatusBarUI extends Plugin {
       isAllErrored: isAllErrored,
       isUploadStarted: isUploadStarted,
       i18n: this.i18n,
-      pauseAll: this.core.pauseAll,
-      resumeAll: this.core.resumeAll,
-      retryAll: this.core.retryAll,
-      cancelAll: this.core.cancelAll,
-      startUpload: this.core.upload,
+      pauseAll: this.uppy.pauseAll,
+      resumeAll: this.uppy.resumeAll,
+      retryAll: this.uppy.retryAll,
+      cancelAll: this.uppy.cancelAll,
+      startUpload: this.uppy.upload,
       complete: completeFiles.length,
       newFiles: newFiles.length,
       inProgress: uploadStartedFiles.length,

+ 40 - 40
src/plugins/Transloadit/index.js

@@ -7,8 +7,8 @@ const StatusSocket = require('./Socket')
  * Upload files to Transloadit using Tus.
  */
 module.exports = class Transloadit extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'uploader'
     this.id = 'Transloadit'
     this.title = 'Transloadit'
@@ -85,7 +85,7 @@ module.exports = class Transloadit extends Plugin {
     const options = this.opts
     return Promise.all(
       fileIDs.map((fileID) => {
-        const file = this.core.getFile(fileID)
+        const file = this.uppy.getFile(fileID)
         const promise = Promise.resolve()
           .then(() => options.getAssemblyOptions(file, options))
         return promise.then((assemblyOptions) => {
@@ -120,7 +120,7 @@ module.exports = class Transloadit extends Plugin {
   createAssembly (fileIDs, uploadID, options) {
     const pluginOptions = this.opts
 
-    this.core.log('Transloadit: create assembly')
+    this.uppy.log('Transloadit: create assembly')
 
     return this.client.createAssembly({
       params: options.params,
@@ -175,22 +175,22 @@ module.exports = class Transloadit extends Plugin {
         return newFile
       }
 
-      const files = Object.assign({}, this.core.state.files)
+      const files = Object.assign({}, this.uppy.state.files)
       fileIDs.forEach((id) => {
         files[id] = attachAssemblyMetadata(files[id], assembly)
       })
 
-      this.core.setState({ files })
+      this.uppy.setState({ files })
 
-      this.core.emit('transloadit:assembly-created', assembly, fileIDs)
+      this.uppy.emit('transloadit:assembly-created', assembly, fileIDs)
 
       return this.connectSocket(assembly)
         .then(() => assembly)
     }).then((assembly) => {
-      this.core.log('Transloadit: Created assembly')
+      this.uppy.log('Transloadit: Created assembly')
       return assembly
     }).catch((err) => {
-      this.core.info(this.i18n('creatingAssemblyFailed'), 'error', 0)
+      this.uppy.info(this.i18n('creatingAssemblyFailed'), 'error', 0)
 
       // Reject the promise.
       throw err
@@ -207,7 +207,7 @@ module.exports = class Transloadit extends Plugin {
    */
   reserveFiles (assembly, fileIDs) {
     return Promise.all(fileIDs.map((fileID) => {
-      const file = this.core.getFile(fileID)
+      const file = this.uppy.getFile(fileID)
       return this.client.reserveFile(assembly, file)
     }))
   }
@@ -217,7 +217,7 @@ module.exports = class Transloadit extends Plugin {
    * once they have been fully uploaded.
    */
   onFileUploadURLAvailable (fileID) {
-    const file = this.core.getFile(fileID)
+    const file = this.uppy.getFile(fileID)
     if (!file || !file.transloadit || !file.transloadit.assembly) {
       return
     }
@@ -226,13 +226,13 @@ module.exports = class Transloadit extends Plugin {
     const assembly = state.assemblies[file.transloadit.assembly]
 
     this.client.addFile(assembly, file).catch((err) => {
-      this.core.log(err)
-      this.core.emit('transloadit:import-error', assembly, file.id, err)
+      this.uppy.log(err)
+      this.uppy.emit('transloadit:import-error', assembly, file.id, err)
     })
   }
 
   findFile (uploadedFile) {
-    const files = this.core.state.files
+    const files = this.uppy.state.files
     for (const id in files) {
       if (!files.hasOwnProperty(id)) {
         continue
@@ -254,7 +254,7 @@ module.exports = class Transloadit extends Plugin {
         }
       })
     })
-    this.core.emit('transloadit:upload', uploadedFile, this.getAssembly(assemblyId))
+    this.uppy.emit('transloadit:upload', uploadedFile, this.getAssembly(assemblyId))
   }
 
   onResult (assemblyId, stepName, result) {
@@ -266,7 +266,7 @@ module.exports = class Transloadit extends Plugin {
     this.setPluginState({
       results: state.results.concat(result)
     })
-    this.core.emit('transloadit:result', stepName, result, this.getAssembly(assemblyId))
+    this.uppy.emit('transloadit:result', stepName, result, this.getAssembly(assemblyId))
   }
 
   onAssemblyFinished (url) {
@@ -277,7 +277,7 @@ module.exports = class Transloadit extends Plugin {
           [assembly.assembly_id]: assembly
         })
       })
-      this.core.emit('transloadit:complete', assembly)
+      this.uppy.emit('transloadit:complete', assembly)
     })
   }
 
@@ -290,7 +290,7 @@ module.exports = class Transloadit extends Plugin {
 
     socket.on('upload', this.onFileUploadComplete.bind(this, assembly.assembly_id))
     socket.on('error', (error) => {
-      this.core.emit('transloadit:assembly-error', assembly, error)
+      this.uppy.emit('transloadit:assembly-error', assembly, error)
     })
 
     if (this.opts.waitForEncoding) {
@@ -304,7 +304,7 @@ module.exports = class Transloadit extends Plugin {
     } else if (this.opts.waitForMetadata) {
       socket.on('metadata', () => {
         this.onAssemblyFinished(assembly.assembly_ssl_url)
-        this.core.emit('transloadit:complete', assembly)
+        this.uppy.emit('transloadit:complete', assembly)
       })
     }
 
@@ -312,7 +312,7 @@ module.exports = class Transloadit extends Plugin {
       socket.on('connect', resolve)
       socket.on('error', reject)
     }).then(() => {
-      this.core.log('Transloadit: Socket is ready')
+      this.uppy.log('Transloadit: Socket is ready')
     })
   }
 
@@ -321,7 +321,7 @@ module.exports = class Transloadit extends Plugin {
     fileIDs = fileIDs.filter((file) => !file.error)
 
     fileIDs.forEach((fileID) => {
-      this.core.emit('preprocess-progress', fileID, {
+      this.uppy.emit('preprocess-progress', fileID, {
         mode: 'indeterminate',
         message: this.i18n('creatingAssembly')
       })
@@ -334,7 +334,7 @@ module.exports = class Transloadit extends Plugin {
         }
       }).then(() => {
         fileIDs.forEach((fileID) => {
-          this.core.emit('preprocess-complete', fileID)
+          this.uppy.emit('preprocess-complete', fileID)
         })
       })
     }
@@ -396,7 +396,7 @@ module.exports = class Transloadit extends Plugin {
 
     return new Promise((resolve, reject) => {
       fileIDs.forEach((fileID) => {
-        this.core.emit('postprocess-progress', fileID, {
+        this.uppy.emit('postprocess-progress', fileID, {
           mode: 'indeterminate',
           message: this.i18n('encoding')
         })
@@ -414,7 +414,7 @@ module.exports = class Transloadit extends Plugin {
 
         const files = this.getAssemblyFiles(assembly.assembly_id)
         files.forEach((file) => {
-          this.core.emit('postprocess-complete', file.id)
+          this.uppy.emit('postprocess-complete', file.id)
         })
 
         checkAllComplete()
@@ -430,9 +430,9 @@ module.exports = class Transloadit extends Plugin {
         const files = this.getAssemblyFiles(assembly.assembly_id)
         files.forEach((file) => {
           // TODO Maybe make a postprocess-error event here?
-          this.core.emit('upload-error', file.id, error)
+          this.uppy.emit('upload-error', file.id, error)
 
-          this.core.emit('postprocess-complete', file.id)
+          this.uppy.emit('postprocess-complete', file.id)
         })
 
         checkAllComplete()
@@ -461,14 +461,14 @@ module.exports = class Transloadit extends Plugin {
       }
 
       const removeListeners = () => {
-        this.core.off('transloadit:complete', onAssemblyFinished)
-        this.core.off('transloadit:assembly-error', onAssemblyError)
-        this.core.off('transloadit:import-error', onImportError)
+        this.uppy.off('transloadit:complete', onAssemblyFinished)
+        this.uppy.off('transloadit:assembly-error', onAssemblyError)
+        this.uppy.off('transloadit:import-error', onImportError)
       }
 
-      this.core.on('transloadit:complete', onAssemblyFinished)
-      this.core.on('transloadit:assembly-error', onAssemblyError)
-      this.core.on('transloadit:import-error', onImportError)
+      this.uppy.on('transloadit:complete', onAssemblyFinished)
+      this.uppy.on('transloadit:assembly-error', onAssemblyError)
+      this.uppy.on('transloadit:import-error', onImportError)
     }).then(() => {
       // Clean up uploadID → assemblyIDs, they're no longer going to be used anywhere.
       const state = this.getPluginState()
@@ -479,11 +479,11 @@ module.exports = class Transloadit extends Plugin {
   }
 
   install () {
-    this.core.addPreProcessor(this.prepareUpload)
-    this.core.addPostProcessor(this.afterUpload)
+    this.uppy.addPreProcessor(this.prepareUpload)
+    this.uppy.addPostProcessor(this.afterUpload)
 
     if (this.opts.importFromUploadURLs) {
-      this.core.on('upload-success', this.onFileUploadURLAvailable)
+      this.uppy.on('upload-success', this.onFileUploadURLAvailable)
     }
 
     this.setPluginState({
@@ -499,11 +499,11 @@ module.exports = class Transloadit extends Plugin {
   }
 
   uninstall () {
-    this.core.removePreProcessor(this.prepareUpload)
-    this.core.removePostProcessor(this.afterUpload)
+    this.uppy.removePreProcessor(this.prepareUpload)
+    this.uppy.removePostProcessor(this.afterUpload)
 
     if (this.opts.importFromUploadURLs) {
-      this.core.off('upload-success', this.onFileUploadURLAvailable)
+      this.uppy.off('upload-success', this.onFileUploadURLAvailable)
     }
   }
 
@@ -513,9 +513,9 @@ module.exports = class Transloadit extends Plugin {
   }
 
   getAssemblyFiles (assemblyID) {
-    const fileIDs = Object.keys(this.core.state.files)
+    const fileIDs = Object.keys(this.uppy.state.files)
     return fileIDs.map((fileID) => {
-      return this.core.getFile(fileID)
+      return this.uppy.getFile(fileID)
     }).filter((file) => {
       return file && file.transloadit && file.transloadit.assembly === assemblyID
     })

+ 35 - 35
src/plugins/Tus.js

@@ -50,8 +50,8 @@ function createEventTracker (emitter) {
  *
  */
 module.exports = class Tus extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'uploader'
     this.id = 'Tus'
     this.title = 'Tus'
@@ -75,7 +75,7 @@ module.exports = class Tus extends Plugin {
   }
 
   handleResetProgress () {
-    const files = Object.assign({}, this.core.state.files)
+    const files = Object.assign({}, this.uppy.state.files)
     Object.keys(files).forEach((fileID) => {
       // Only clone the file object if it has a Tus `uploadUrl` attached.
       if (files[fileID].tus && files[fileID].tus.uploadUrl) {
@@ -85,7 +85,7 @@ module.exports = class Tus extends Plugin {
       }
     })
 
-    this.core.setState({ files })
+    this.uppy.setState({ files })
   }
 
   /**
@@ -116,7 +116,7 @@ module.exports = class Tus extends Plugin {
    * @returns {Promise}
    */
   upload (file, current, total) {
-    this.core.log(`uploading ${current} of ${total}`)
+    this.uppy.log(`uploading ${current} of ${total}`)
 
     this.resetUploaderReferences(file.id)
 
@@ -131,8 +131,8 @@ module.exports = class Tus extends Plugin {
       )
 
       optsTus.onError = (err) => {
-        this.core.log(err)
-        this.core.emit('upload-error', file.id, err)
+        this.uppy.log(err)
+        this.uppy.emit('upload-error', file.id, err)
         err.message = `Failed because: ${err.message}`
 
         this.resetUploaderReferences(file.id)
@@ -141,7 +141,7 @@ module.exports = class Tus extends Plugin {
 
       optsTus.onProgress = (bytesUploaded, bytesTotal) => {
         this.onReceiveUploadUrl(file, upload.url)
-        this.core.emit('upload-progress', {
+        this.uppy.emit('upload-progress', {
           uploader: this,
           id: file.id,
           bytesUploaded: bytesUploaded,
@@ -150,10 +150,10 @@ module.exports = class Tus extends Plugin {
       }
 
       optsTus.onSuccess = () => {
-        this.core.emit('upload-success', file.id, upload, upload.url)
+        this.uppy.emit('upload-success', file.id, upload, upload.url)
 
         if (upload.url) {
-          this.core.log('Download ' + upload.file.name + ' from ' + upload.url)
+          this.uppy.log('Download ' + upload.file.name + ' from ' + upload.url)
         }
 
         this.resetUploaderReferences(file.id)
@@ -163,7 +163,7 @@ module.exports = class Tus extends Plugin {
 
       const upload = new tus.Upload(file.data, optsTus)
       this.uploaders[file.id] = upload
-      this.uploaderEvents[file.id] = createEventTracker(this.core)
+      this.uploaderEvents[file.id] = createEventTracker(this.uppy)
 
       this.onFileRemove(file.id, (targetFileID) => {
         this.resetUploaderReferences(file.id)
@@ -197,7 +197,7 @@ module.exports = class Tus extends Plugin {
         upload.start()
       }
       if (!file.isRestored) {
-        this.core.emit('upload-started', file.id, upload)
+        this.uppy.emit('upload-started', file.id, upload)
       }
     })
   }
@@ -206,7 +206,7 @@ module.exports = class Tus extends Plugin {
     this.resetUploaderReferences(file.id)
 
     return new Promise((resolve, reject) => {
-      this.core.log(file.remote.url)
+      this.uppy.log(file.remote.url)
       if (file.serverToken) {
         this.connectToServerSocket(file)
       } else {
@@ -215,7 +215,7 @@ module.exports = class Tus extends Plugin {
           endpoint = file.tus.endpoint
         }
 
-        this.core.emit('upload-started', file.id)
+        this.uppy.emit('upload-started', file.id)
 
         fetch(file.remote.url, {
           method: 'post',
@@ -238,7 +238,7 @@ module.exports = class Tus extends Plugin {
 
           res.json().then((data) => {
             const token = data.token
-            this.core.setFileState(file.id, { serverToken: token })
+            this.uppy.setFileState(file.id, { serverToken: token })
             file = this.getFile(file.id)
             this.connectToServerSocket(file)
             resolve()
@@ -253,7 +253,7 @@ module.exports = class Tus extends Plugin {
     const host = getSocketHost(file.remote.host)
     const socket = new UppySocket({ target: `${host}/api/${token}` })
     this.uploaderSockets[file.id] = socket
-    this.uploaderEvents[file.id] = createEventTracker(this.core)
+    this.uploaderEvents[file.id] = createEventTracker(this.uppy)
 
     this.onFileRemove(file.id, () => socket.send('pause', {}))
 
@@ -289,20 +289,20 @@ module.exports = class Tus extends Plugin {
     socket.on('progress', (progressData) => emitSocketProgress(this, progressData, file))
 
     socket.on('success', (data) => {
-      this.core.emit('upload-success', file.id, data, data.url)
+      this.uppy.emit('upload-success', file.id, data, data.url)
       this.resetUploaderReferences(file.id)
     })
   }
 
   getFile (fileID) {
-    return this.core.state.files[fileID]
+    return this.uppy.state.files[fileID]
   }
 
   updateFile (file) {
-    const files = Object.assign({}, this.core.state.files, {
+    const files = Object.assign({}, this.uppy.state.files, {
       [file.id]: file
     })
-    this.core.setState({ files })
+    this.uppy.setState({ files })
   }
 
   onReceiveUploadUrl (file, uploadURL) {
@@ -328,7 +328,7 @@ module.exports = class Tus extends Plugin {
   onPause (fileID, cb) {
     this.uploaderEvents[fileID].on('upload-pause', (targetFileID, isPaused) => {
       if (fileID === targetFileID) {
-        // const isPaused = this.core.pauseResume(fileID)
+        // const isPaused = this.uppy.pauseResume(fileID)
         cb(isPaused)
       }
     })
@@ -344,28 +344,28 @@ module.exports = class Tus extends Plugin {
 
   onRetryAll (fileID, cb) {
     this.uploaderEvents[fileID].on('retry-all', (filesToRetry) => {
-      if (!this.core.getFile(fileID)) return
+      if (!this.uppy.getFile(fileID)) return
       cb()
     })
   }
 
   onPauseAll (fileID, cb) {
     this.uploaderEvents[fileID].on('pause-all', () => {
-      if (!this.core.getFile(fileID)) return
+      if (!this.uppy.getFile(fileID)) return
       cb()
     })
   }
 
   onCancelAll (fileID, cb) {
     this.uploaderEvents[fileID].on('cancel-all', () => {
-      if (!this.core.getFile(fileID)) return
+      if (!this.uppy.getFile(fileID)) return
       cb()
     })
   }
 
   onResumeAll (fileID, cb) {
     this.uploaderEvents[fileID].on('resume-all', () => {
-      if (!this.core.getFile(fileID)) return
+      if (!this.uppy.getFile(fileID)) return
       cb()
     })
   }
@@ -389,40 +389,40 @@ module.exports = class Tus extends Plugin {
 
   handleUpload (fileIDs) {
     if (fileIDs.length === 0) {
-      this.core.log('Tus: no files to upload!')
+      this.uppy.log('Tus: no files to upload!')
       return Promise.resolve()
     }
 
-    this.core.log('Tus is uploading...')
-    const filesToUpload = fileIDs.map((fileID) => this.core.getFile(fileID))
+    this.uppy.log('Tus is uploading...')
+    const filesToUpload = fileIDs.map((fileID) => this.uppy.getFile(fileID))
 
     return this.uploadFiles(filesToUpload)
   }
 
   addResumableUploadsCapabilityFlag () {
-    const newCapabilities = Object.assign({}, this.core.getState().capabilities)
+    const newCapabilities = Object.assign({}, this.uppy.getState().capabilities)
     newCapabilities.resumableUploads = true
-    this.core.setState({
+    this.uppy.setState({
       capabilities: newCapabilities
     })
   }
 
   install () {
     this.addResumableUploadsCapabilityFlag()
-    this.core.addUploader(this.handleUpload)
+    this.uppy.addUploader(this.handleUpload)
 
-    this.core.on('reset-progress', this.handleResetProgress)
+    this.uppy.on('reset-progress', this.handleResetProgress)
 
     if (this.opts.autoRetry) {
-      this.core.on('back-online', this.core.retryAll)
+      this.uppy.on('back-online', this.uppy.retryAll)
     }
   }
 
   uninstall () {
-    this.core.removeUploader(this.handleUpload)
+    this.uppy.removeUploader(this.handleUpload)
 
     if (this.opts.autoRetry) {
-      this.core.off('back-online', this.core.retryAll)
+      this.uppy.off('back-online', this.uppy.retryAll)
     }
   }
 }

+ 9 - 9
src/plugins/Webcam/index.js

@@ -34,8 +34,8 @@ function getMediaDevices () {
  * Webcam
  */
 module.exports = class Webcam extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.mediaDevices = getMediaDevices()
     this.supportsUserMedia = !!this.mediaDevices
     this.protocol = location.protocol.match(/https/i) ? 'https' : 'http'
@@ -168,7 +168,7 @@ module.exports = class Webcam extends Plugin {
       })
       return this.getVideo()
     }).then((file) => {
-      return this.core.addFile(file)
+      return this.uppy.addFile(file)
     }).then(() => {
       this.recordingChunks = null
       this.recorder = null
@@ -207,11 +207,11 @@ module.exports = class Webcam extends Plugin {
         }
 
         if (count > 0) {
-          this.core.info(`${count}...`, 'warning', 800)
+          this.uppy.info(`${count}...`, 'warning', 800)
           count--
         } else {
           clearInterval(countDown)
-          this.core.info(this.i18n('smile'), 'success', 1500)
+          this.uppy.info(this.i18n('smile'), 'success', 1500)
           setTimeout(() => resolve(), 1500)
         }
       }, 1000)
@@ -224,14 +224,14 @@ module.exports = class Webcam extends Plugin {
 
     this.opts.onBeforeSnapshot().catch((err) => {
       const message = typeof err === 'object' ? err.message : err
-      this.core.info(message, 'error', 5000)
+      this.uppy.info(message, 'error', 5000)
       return Promise.reject(new Error(`onBeforeSnapshot: ${message}`))
     }).then(() => {
       return this.getImage()
     }).then((tagFile) => {
       this.captureInProgress = false
-      this.core.addFile(tagFile)
-      const dashboard = this.core.getPlugin('Dashboard')
+      this.uppy.addFile(tagFile)
+      const dashboard = this.uppy.getPlugin('Dashboard')
       if (dashboard) dashboard.hideAllPanels()
     }, (error) => {
       this.captureInProgress = false
@@ -286,7 +286,7 @@ module.exports = class Webcam extends Plugin {
   focus () {
     if (this.opts.countdown) return
     setTimeout(() => {
-      this.core.info(this.i18n('smile'), 'success', 1500)
+      this.uppy.info(this.i18n('smile'), 'success', 1500)
     }, 1000)
   }
 

+ 28 - 28
src/plugins/XHRUpload.js

@@ -10,8 +10,8 @@ const {
 } = require('../core/Utils')
 
 module.exports = class XHRUpload extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'uploader'
     this.id = 'XHRUpload'
     this.title = 'XHRUpload'
@@ -64,13 +64,13 @@ module.exports = class XHRUpload extends Plugin {
   getOptions (file) {
     const opts = Object.assign({},
       this.opts,
-      this.core.state.xhrUpload || {},
+      this.uppy.state.xhrUpload || {},
       file.xhrUpload || {}
     )
     opts.headers = {}
     Object.assign(opts.headers, this.opts.headers)
-    if (this.core.state.xhrUpload) {
-      Object.assign(opts.headers, this.core.state.xhrUpload.headers)
+    if (this.uppy.state.xhrUpload) {
+      Object.assign(opts.headers, this.uppy.state.xhrUpload.headers)
     }
     if (file.xhrUpload) {
       Object.assign(opts.headers, file.xhrUpload.headers)
@@ -102,7 +102,7 @@ module.exports = class XHRUpload extends Plugin {
   upload (file, current, total) {
     const opts = this.getOptions(file)
 
-    this.core.log(`uploading ${current} of ${total}`)
+    this.uppy.log(`uploading ${current} of ${total}`)
     return new Promise((resolve, reject) => {
       const data = opts.formData
         ? this.createFormDataUpload(file, opts)
@@ -110,9 +110,9 @@ module.exports = class XHRUpload extends Plugin {
 
       const onTimedOut = () => {
         xhr.abort()
-        this.core.log(`[XHRUpload] ${id} timed out`)
+        this.uppy.log(`[XHRUpload] ${id} timed out`)
         const error = new Error(this.i18n('timedOut', { seconds: Math.ceil(opts.timeout / 1000) }))
-        this.core.emit('upload-error', file.id, error)
+        this.uppy.emit('upload-error', file.id, error)
         reject(error)
       }
       let aliveTimer
@@ -125,7 +125,7 @@ module.exports = class XHRUpload extends Plugin {
       const id = cuid()
 
       xhr.upload.addEventListener('loadstart', (ev) => {
-        this.core.log(`[XHRUpload] ${id} started`)
+        this.uppy.log(`[XHRUpload] ${id} started`)
         if (opts.timeout > 0) {
           // Begin checking for timeouts when loading starts.
           isAlive()
@@ -133,13 +133,13 @@ module.exports = class XHRUpload extends Plugin {
       })
 
       xhr.upload.addEventListener('progress', (ev) => {
-        this.core.log(`[XHRUpload] ${id} progress: ${ev.loaded} / ${ev.total}`)
+        this.uppy.log(`[XHRUpload] ${id} progress: ${ev.loaded} / ${ev.total}`)
         if (opts.timeout > 0) {
           isAlive()
         }
 
         if (ev.lengthComputable) {
-          this.core.emit('upload-progress', {
+          this.uppy.emit('upload-progress', {
             uploader: this,
             id: file.id,
             bytesUploaded: ev.loaded,
@@ -149,34 +149,34 @@ module.exports = class XHRUpload extends Plugin {
       })
 
       xhr.addEventListener('load', (ev) => {
-        this.core.log(`[XHRUpload] ${id} finished`)
+        this.uppy.log(`[XHRUpload] ${id} finished`)
         clearTimeout(aliveTimer)
 
         if (ev.target.status >= 200 && ev.target.status < 300) {
           const resp = opts.getResponseData(xhr)
           const uploadURL = resp[opts.responseUrlFieldName]
 
-          this.core.emit('upload-success', file.id, resp, uploadURL)
+          this.uppy.emit('upload-success', file.id, resp, uploadURL)
 
           if (uploadURL) {
-            this.core.log(`Download ${file.name} from ${file.uploadURL}`)
+            this.uppy.log(`Download ${file.name} from ${file.uploadURL}`)
           }
 
           return resolve(file)
         } else {
           const error = opts.getResponseError(xhr) || new Error('Upload error')
           error.request = xhr
-          this.core.emit('upload-error', file.id, error)
+          this.uppy.emit('upload-error', file.id, error)
           return reject(error)
         }
       })
 
       xhr.addEventListener('error', (ev) => {
-        this.core.log(`[XHRUpload] ${id} errored`)
+        this.uppy.log(`[XHRUpload] ${id} errored`)
         clearTimeout(aliveTimer)
 
         const error = opts.getResponseError(xhr) || new Error('Upload error')
-        this.core.emit('upload-error', file.id, error)
+        this.uppy.emit('upload-error', file.id, error)
         return reject(error)
       })
 
@@ -188,26 +188,26 @@ module.exports = class XHRUpload extends Plugin {
 
       xhr.send(data)
 
-      this.core.on('upload-cancel', (fileID) => {
+      this.uppy.on('upload-cancel', (fileID) => {
         if (fileID === file.id) {
           xhr.abort()
         }
       })
 
-      this.core.on('cancel-all', () => {
-        // const files = this.core.getState().files
+      this.uppy.on('cancel-all', () => {
+        // const files = this.uppy.getState().files
         // if (!files[file.id]) return
         xhr.abort()
       })
 
-      this.core.emit('upload-started', file.id)
+      this.uppy.emit('upload-started', file.id)
     })
   }
 
   uploadRemote (file, current, total) {
     const opts = this.getOptions(file)
     return new Promise((resolve, reject) => {
-      this.core.emit('upload-started', file.id)
+      this.uppy.emit('upload-started', file.id)
 
       const fields = {}
       const metaFields = Array.isArray(opts.metaFields)
@@ -247,7 +247,7 @@ module.exports = class XHRUpload extends Plugin {
           socket.on('progress', (progressData) => emitSocketProgress(this, progressData, file))
 
           socket.on('success', (data) => {
-            this.core.emit('upload-success', file.id, data, data.url)
+            this.uppy.emit('upload-success', file.id, data, data.url)
             socket.close()
             return resolve()
           })
@@ -280,24 +280,24 @@ module.exports = class XHRUpload extends Plugin {
 
   handleUpload (fileIDs) {
     if (fileIDs.length === 0) {
-      this.core.log('[XHRUpload] No files to upload!')
+      this.uppy.log('[XHRUpload] No files to upload!')
       return Promise.resolve()
     }
 
-    this.core.log('[XHRUpload] Uploading...')
+    this.uppy.log('[XHRUpload] Uploading...')
     const files = fileIDs.map(getFile, this)
     function getFile (fileID) {
-      return this.core.state.files[fileID]
+      return this.uppy.state.files[fileID]
     }
 
     return this.uploadFiles(files).then(() => null)
   }
 
   install () {
-    this.core.addUploader(this.handleUpload)
+    this.uppy.addUploader(this.handleUpload)
   }
 
   uninstall () {
-    this.core.removeUploader(this.handleUpload)
+    this.uppy.removeUploader(this.handleUpload)
   }
 }

+ 3 - 3
test/mocks/acquirerPlugin1.js

@@ -1,8 +1,8 @@
 import Plugin from '../../src/core/Plugin.js'
 
 export default class TestSelector1 extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'acquirer'
     this.id = 'TestSelector1'
     this.name = this.constructor.name
@@ -15,7 +15,7 @@ export default class TestSelector1 extends Plugin {
   }
 
   run (results) {
-    this.core.log({
+    this.uppy.log({
       class: this.constructor.name,
       method: 'run',
       results: results

+ 3 - 3
test/mocks/acquirerPlugin2.js

@@ -1,8 +1,8 @@
 import Plugin from '../../src/core/Plugin.js'
 
 export default class TestSelector2 extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'acquirer'
     this.id = 'TestSelector2'
     this.name = this.constructor.name
@@ -15,7 +15,7 @@ export default class TestSelector2 extends Plugin {
   }
 
   run (results) {
-    this.core.log({
+    this.uppy.log({
       class: this.constructor.name,
       method: 'run',
       results: results

+ 3 - 3
test/mocks/invalidPluginWithoutId.js

@@ -1,14 +1,14 @@
 import Plugin from '../../src/core/Plugin.js'
 
 export default class InvalidPluginWithoutName extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.type = 'acquirer'
     this.name = this.constructor.name
   }
 
   run (results) {
-    this.core.log({
+    this.uppy.log({
       class: this.constructor.name,
       method: 'run',
       results: results

+ 3 - 3
test/mocks/invalidPluginWithoutType.js

@@ -1,14 +1,14 @@
 import Plugin from '../../src/core/Plugin.js'
 
 export default class InvalidPluginWithoutType extends Plugin {
-  constructor (core, opts) {
-    super(core, opts)
+  constructor (uppy, opts) {
+    super(uppy, opts)
     this.id = 'InvalidPluginWithoutType'
     this.name = this.constructor.name
   }
 
   run (results) {
-    this.core.log({
+    this.uppy.log({
       class: this.constructor.name,
       method: 'run',
       results: results