Quellcode durchsuchen

Add factory function to create new core.

Harry Hedger vor 9 Jahren
Ursprung
Commit
df30cbe1fb
5 geänderte Dateien mit 31 neuen und 7 gelöschten Zeilen
  1. 1 0
      .gitignore
  2. 6 6
      lib/core/Transloadit.js
  3. 1 1
      src/core/Transloadit.js
  4. 8 0
      src/create.js
  5. 15 0
      src/index.js

+ 1 - 0
.gitignore

@@ -4,6 +4,7 @@ npm-debug.log
 node_modules
 
 build/
+lib/
 examples/playground/static/js/app.js
 examples/playground/static/uppy/
 

+ 6 - 6
lib/core/Transloadit.js

@@ -8,9 +8,9 @@ var _createClass = (function () { function defineProperties(target, props) { for
 
 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
 
-var Transloadit = (function () {
-  function Transloadit(opts) {
-    _classCallCheck(this, Transloadit);
+var _default = (function () {
+  function _default(opts) {
+    _classCallCheck(this, _default);
 
     // Dictates in what order different plugin types are ran:
     this.types = ['presetter', 'selecter', 'uploader'];
@@ -19,7 +19,7 @@ var Transloadit = (function () {
     this.plugins = {};
   }
 
-  _createClass(Transloadit, [{
+  _createClass(_default, [{
     key: 'use',
     value: function use(Plugin, opts) {
       // Instantiate
@@ -64,8 +64,8 @@ var Transloadit = (function () {
     }
   }]);
 
-  return Transloadit;
+  return _default;
 })();
 
-exports['default'] = Transloadit;
+exports['default'] = _default;
 module.exports = exports['default'];

+ 1 - 1
src/core/Transloadit.js

@@ -1,4 +1,4 @@
-export default class Transloadit {
+export default class {
   constructor(opts) {
     // Dictates in what order different plugin types are ran:
     this.types = [ 'presetter', 'selecter', 'uploader' ];

+ 8 - 0
src/create.js

@@ -0,0 +1,8 @@
+import Core from './core'
+
+/**
+ * Factory function for creating a new
+ * instance of the core.
+ * @returns { object } new Core instance
+ */
+export default () => new Core()

+ 15 - 0
src/index.js

@@ -0,0 +1,15 @@
+import Core from './core'
+import {
+  DragDrop,
+  UppyBasic,
+  Tus10
+} from './plugins'
+
+import createUppy from './create'
+
+export default {
+  DragDrop,
+  TransloaditBasic,
+  Tus10,
+  createUppy
+}