1 | var _class, _temp;
|
2 |
|
3 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
4 |
|
5 | function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
6 |
|
7 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
8 |
|
9 | var _require = require('@uppy/core'),
|
10 | Plugin = _require.Plugin;
|
11 |
|
12 | var _require2 = require('@uppy/companion-client'),
|
13 | Provider = _require2.Provider;
|
14 |
|
15 | var _require3 = require('@uppy/provider-views'),
|
16 | ProviderViews = _require3.ProviderViews;
|
17 |
|
18 | var _require4 = require('preact'),
|
19 | h = _require4.h;
|
20 |
|
21 | module.exports = (_temp = _class = function (_Plugin) {
|
22 | _inheritsLoose(OneDrive, _Plugin);
|
23 |
|
24 | function OneDrive(uppy, opts) {
|
25 | var _this;
|
26 |
|
27 | _this = _Plugin.call(this, uppy, opts) || this;
|
28 | _this.id = _this.opts.id || 'OneDrive';
|
29 | Provider.initPlugin(_assertThisInitialized(_this), opts);
|
30 | _this.title = _this.opts.title || 'OneDrive';
|
31 |
|
32 | _this.icon = function () {
|
33 | return h("svg", {
|
34 | "aria-hidden": "true",
|
35 | focusable: "false",
|
36 | width: "32",
|
37 | height: "32",
|
38 | viewBox: "0 0 32 32"
|
39 | }, h("g", {
|
40 | fill: "none",
|
41 | fillRule: "evenodd"
|
42 | }, h("rect", {
|
43 | className: "uppy-ProviderIconBg",
|
44 | width: "32",
|
45 | height: "32",
|
46 | rx: "16",
|
47 | fill: "#0262C0"
|
48 | }), h("g", {
|
49 | fill: "#FFF",
|
50 | fillRule: "nonzero"
|
51 | }, h("path", {
|
52 | d: "M24.157 22s1.492-.205 1.79-1.655a2.624 2.624 0 0 0 .03-.878c-.22-1.64-1.988-2.01-1.988-2.01s.307-1.765-1.312-2.69c-1.62-.925-3.1 0-3.1 0S18.711 13 16.366 13c-3.016 0-3.519 3.448-3.519 3.448S10 16.618 10 19.14c0 2.523 2.597 2.86 2.597 2.86h11.56z"
|
53 | }), h("path", {
|
54 | d: "M9.421 19.246c0-2.197 1.606-3.159 2.871-3.472.44-1.477 1.654-3.439 4.135-3.439H16.445c1.721 0 2.79.823 3.368 1.476a3.99 3.99 0 0 1 1.147-.171h.01l.03.002C21.017 13.5 20.691 10 16.757 10c-2.69 0-3.639 2.345-3.639 2.345s-1.95-1.482-3.955.567c-1.028 1.052-.79 2.669-.79 2.669S6 15.824 6 18.412C6 20.757 8.452 21 8.452 21h1.372a3.77 3.77 0 0 1-.403-1.754z"
|
55 | }))));
|
56 | };
|
57 |
|
58 | _this.provider = new Provider(uppy, {
|
59 | companionUrl: _this.opts.companionUrl,
|
60 | companionHeaders: _this.opts.companionHeaders || _this.opts.serverHeaders,
|
61 | companionCookiesRule: _this.opts.companionCookiesRule,
|
62 | provider: 'onedrive',
|
63 | pluginId: _this.id
|
64 | });
|
65 | _this.onFirstRender = _this.onFirstRender.bind(_assertThisInitialized(_this));
|
66 | _this.render = _this.render.bind(_assertThisInitialized(_this));
|
67 | return _this;
|
68 | }
|
69 |
|
70 | var _proto = OneDrive.prototype;
|
71 |
|
72 | _proto.install = function install() {
|
73 | this.view = new ProviderViews(this, {
|
74 | provider: this.provider
|
75 | });
|
76 | var target = this.opts.target;
|
77 |
|
78 | if (target) {
|
79 | this.mount(target, this);
|
80 | }
|
81 | };
|
82 |
|
83 | _proto.uninstall = function uninstall() {
|
84 | this.view.tearDown();
|
85 | this.unmount();
|
86 | };
|
87 |
|
88 | _proto.onFirstRender = function onFirstRender() {
|
89 | return Promise.all([this.provider.fetchPreAuthToken(), this.view.getFolder()]);
|
90 | };
|
91 |
|
92 | _proto.render = function render(state) {
|
93 | return this.view.render(state);
|
94 | };
|
95 |
|
96 | return OneDrive;
|
97 | }(Plugin), _class.VERSION = "1.2.0", _temp); |
\ | No newline at end of file |