build.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. 'use strict';
  3. Object.defineProperty(exports, '__esModule', {
  4. value: true
  5. });
  6. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  7. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  8. var Transloadit = (function () {
  9. function Transloadit(opts) {
  10. _classCallCheck(this, Transloadit);
  11. // Dictates in what order different plugin types are ran:
  12. this.types = ['presetter', 'selecter', 'uploader'];
  13. // Container for different types of plugins
  14. this.plugins = {};
  15. }
  16. _createClass(Transloadit, [{
  17. key: 'use',
  18. value: function use(Plugin, opts) {
  19. // Instantiate
  20. var plugin = new Plugin(this, opts);
  21. // Save in plugin container
  22. if (!this.plugins[plugin.type]) {
  23. this.plugins[plugin.type] = [];
  24. }
  25. this.plugins[plugin.type].push(plugin);
  26. return this;
  27. }
  28. }, {
  29. key: 'setProgress',
  30. value: function setProgress(plugin, percentage) {
  31. // Any plugin can call this via `this.core.setProgress(this, precentage)`
  32. console.log(plugin.type + ' plugin ' + plugin.name + ' set the progress to ' + percentage);
  33. return this;
  34. }
  35. }, {
  36. key: 'run',
  37. value: function run() {
  38. // Walk over plugins in the order as defined by this.types.
  39. var files = [];
  40. for (var j in this.types) {
  41. var type = this.types[j];
  42. // Walk over all plugins of this type, passing & modifying the files array as we go
  43. for (var i in this.plugins[type]) {
  44. var plugin = this.plugins[type][i];
  45. console.log('--> Now running ' + plugin.type + ' plugin ' + plugin.name + ': ');
  46. files = plugin.run(files);
  47. console.dir(files);
  48. console.log('');
  49. }
  50. }
  51. // core.run is the final step and retuns the results (vs every other method, returning `this`)
  52. // for chainability
  53. return files;
  54. }
  55. }]);
  56. return Transloadit;
  57. })();
  58. exports['default'] = Transloadit;
  59. module.exports = exports['default'];
  60. },{}],2:[function(require,module,exports){
  61. 'use strict';
  62. Object.defineProperty(exports, '__esModule', {
  63. value: true
  64. });
  65. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  66. var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
  67. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  68. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  69. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  70. var _pluginsTransloaditPlugin = require('../plugins/TransloaditPlugin');
  71. var _pluginsTransloaditPlugin2 = _interopRequireDefault(_pluginsTransloaditPlugin);
  72. var DragDrop = (function (_TransloaditPlugin) {
  73. _inherits(DragDrop, _TransloaditPlugin);
  74. function DragDrop(core, opts) {
  75. _classCallCheck(this, DragDrop);
  76. _get(Object.getPrototypeOf(DragDrop.prototype), 'constructor', this).call(this, core, opts);
  77. this.type = 'selecter';
  78. }
  79. _createClass(DragDrop, [{
  80. key: 'run',
  81. value: function run(files) {
  82. this.core.setProgress(this, 0);
  83. var selected = [{ name: 'lolcat.jpeg' }];
  84. this.core.setProgress(this, 100);
  85. return selected;
  86. }
  87. }]);
  88. return DragDrop;
  89. })(_pluginsTransloaditPlugin2['default']);
  90. exports['default'] = DragDrop;
  91. module.exports = exports['default'];
  92. },{"../plugins/TransloaditPlugin":3}],3:[function(require,module,exports){
  93. "use strict";
  94. Object.defineProperty(exports, "__esModule", {
  95. value: true
  96. });
  97. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  98. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  99. var TransloaditPlugin = (function () {
  100. // This contains boilerplate that all TransloaditPlugins share - and should not be used
  101. // directly. It also shows which methods final plugins should implement/override,
  102. // this deciding on structure.
  103. function TransloaditPlugin(core, opts) {
  104. _classCallCheck(this, TransloaditPlugin);
  105. this.core = core;
  106. this.opts = opts;
  107. this.name = this.constructor.name;
  108. }
  109. _createClass(TransloaditPlugin, [{
  110. key: "run",
  111. value: function run(files) {
  112. return files;
  113. }
  114. }]);
  115. return TransloaditPlugin;
  116. })();
  117. exports["default"] = TransloaditPlugin;
  118. module.exports = exports["default"];
  119. },{}],4:[function(require,module,exports){
  120. 'use strict';
  121. Object.defineProperty(exports, '__esModule', {
  122. value: true
  123. });
  124. var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
  125. var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
  126. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  127. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  128. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  129. var _TransloaditPlugin2 = require('./TransloaditPlugin');
  130. var _TransloaditPlugin3 = _interopRequireDefault(_TransloaditPlugin2);
  131. var Tus10 = (function (_TransloaditPlugin) {
  132. _inherits(Tus10, _TransloaditPlugin);
  133. function Tus10(core, opts) {
  134. _classCallCheck(this, Tus10);
  135. _get(Object.getPrototypeOf(Tus10.prototype), 'constructor', this).call(this, core, opts);
  136. this.type = 'uploader';
  137. }
  138. _createClass(Tus10, [{
  139. key: 'run',
  140. value: function run(files) {
  141. this.core.setProgress(this, 0);
  142. var uploaded = [];
  143. for (var i in files) {
  144. var file = files[i];
  145. this.core.setProgress(this, i * 1 + 1);
  146. uploaded[i] = file;
  147. uploaded[i].url = this.opts.endpoint + '/uploaded/' + file.name;
  148. }
  149. this.core.setProgress(this, 100);
  150. return uploaded;
  151. }
  152. }]);
  153. return Tus10;
  154. })(_TransloaditPlugin3['default']);
  155. exports['default'] = Tus10;
  156. module.exports = exports['default'];
  157. },{"./TransloaditPlugin":3}],5:[function(require,module,exports){
  158. 'use strict';
  159. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  160. var _srcCoreTransloadit = require('./src/core/Transloadit');
  161. var _srcCoreTransloadit2 = _interopRequireDefault(_srcCoreTransloadit);
  162. var _srcPluginsDragDrop = require('./src/plugins/DragDrop');
  163. var _srcPluginsDragDrop2 = _interopRequireDefault(_srcPluginsDragDrop);
  164. var _srcPluginsTus10 = require('./src/plugins/Tus10');
  165. var _srcPluginsTus102 = _interopRequireDefault(_srcPluginsTus10);
  166. var transloadit = new _srcCoreTransloadit2['default']({ wait: false });
  167. var files = transloadit.use(_srcPluginsDragDrop2['default'], { modal: true }).use(_srcPluginsTus102['default'], { endpoint: 'http://master.tus.io:8080' }).run();
  168. console.log('--> Finished transloadit. Final result: ');
  169. console.dir(files);
  170. },{"./src/core/Transloadit":1,"./src/plugins/DragDrop":2,"./src/plugins/Tus10":4}]},{},[5]);