@scaleflex/widget-dropbox 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 scaleflex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @scaleflex/widget-dropbox
2
+
3
+ [![Plugins][plugins-image]](#plugins)
4
+ [![Website][filerobot-image]][sfx-url]
5
+ [![Version][filerobot-version]][version-url]
6
+ [![Scaleflex team][made-by-image]][sfx-url]
7
+ [![License][license-image]][license-url]
8
+ [![CodeSandbox][codeSandbox-image]][codeSandbox-url]
9
+
10
+
11
+ <div align='center'>
12
+ <img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://cdn.scaleflex.com/plugins/filerobot-widget/assets/filerobot_widget_logo_with_fire.png?vh=b2ff09" width="140"/>
13
+ </div>
14
+
15
+ The Dropbox plugin for [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core). lets users import files from their Dropbox account.
16
+
17
+
18
+ ## Usage
19
+
20
+ ### NPM
21
+
22
+ ```bash
23
+ npm install --save @scaleflex/widget-dropbox
24
+ ```
25
+ ### YARN
26
+
27
+ ```bash
28
+ yarn add @scaleflex/widget-dropbox
29
+ ```
30
+
31
+ then
32
+
33
+ ```js
34
+ import Dropbox from '@scaleflex/widget-dropbox'
35
+ ...
36
+ ...
37
+ ...
38
+ scaleflexWidget.use(Dropbox, propertiesObject)
39
+ ```
40
+
41
+ ### CDN
42
+
43
+ The plugin from CDN is found inside `Scaleflex` global object `Scaleflex.Dropbox`
44
+
45
+ ```js
46
+ const dropbox = window.ScaleflexWidget.Dropbox
47
+ ...
48
+ ...
49
+ ...
50
+ scaleflexWidget.use(dropbox, propertiesObject)
51
+ ```
52
+
53
+ ## Properties
54
+
55
+ ### `title`
56
+
57
+ <u>Type:</u> `string`
58
+
59
+ <u>Default:</u> `'Dropbox'`
60
+
61
+ The title/label that would be shown & used for the plugin.
62
+
63
+ ### `companionHeaders`
64
+
65
+ <u>Type:</u> `null` | `object`
66
+
67
+ <u>Default:</u> `null`
68
+
69
+ If you need to pass additional headers for in companion requests then pass them in this property.
70
+
71
+
72
+ <!-- Variables -->
73
+
74
+ [npm-url]: https://www.npmjs.com/package/@scaleflex/widget-dropbox
75
+ [license-url]: https://opensource.org/licenses/MIT
76
+ [sfx-url]: https://www.scaleflex.com/
77
+ [version-url]: https://www.npmjs.com/package/@scaleflex/widget-dropbox
78
+ [codeSandbox-url]: https://codesandbox.io/s/filerobot-widget-v3-c5l9th
79
+
80
+
81
+ [npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
82
+ [license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
83
+ [made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
84
+ [plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
85
+ [filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
86
+ [filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-dropbox?label=Version&style=for-the-badge&logo=npm
87
+ [codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
@@ -0,0 +1,35 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { createSlice } from '@reduxjs/toolkit';
8
+ import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
9
+
10
+ // If the plugin instantiates a Provider, then we must have a common slice for it, as it will get updated through the provider.
11
+ var initialState = {
12
+ authenticated: false,
13
+ files: [],
14
+ folders: [],
15
+ openedFolders: [],
16
+ selectedFolders: {},
17
+ activeRow: -1,
18
+ filterInput: '',
19
+ isSearchVisible: false
20
+ };
21
+ var commonSlice = createSlice({
22
+ name: PLUGINS_IDS.DROPBOX,
23
+ initialState: initialState,
24
+ reducers: {
25
+ dropboxCommonStateUpdated: function dropboxCommonStateUpdated(state, action) {
26
+ return _objectSpread(_objectSpread({}, state), action.payload);
27
+ }
28
+ }
29
+ });
30
+ var dropboxCommonStateUpdated = commonSlice.actions.dropboxCommonStateUpdated;
31
+ export { dropboxCommonStateUpdated };
32
+ export var selectDropboxCommonState = function selectDropboxCommonState(state) {
33
+ return state[PLUGINS_IDS.DROPBOX];
34
+ };
35
+ export default commonSlice.reducer;
package/lib/index.js ADDED
@@ -0,0 +1,101 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
9
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
10
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
12
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
13
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
14
+ import { Plugin } from '@scaleflex/widget-core';
15
+ import Explorer from '@scaleflex/widget-explorer';
16
+ import { Provider } from '@scaleflex/widget-companion-client';
17
+ import ProviderViews from '@scaleflex/widget-provider-views';
18
+ import { DropboxIcon } from '@scaleflex/widget-icons/lib';
19
+ import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
20
+ import dropboxReducer, { dropboxCommonStateUpdated } from './common.slice';
21
+
22
+ // TODO: find a way to show version of the current plugin
23
+ // why solution below isn't good?
24
+ // first import doesn't work with webpack 5 as it was deprecated
25
+ // second import fixes webpack 5 issue as it was mentioned in their docs
26
+ // but it exposes our package.json to the client and it is mentioned as security rist in mutiple places
27
+ // https://github.com/axelpale/genversion
28
+ // https://stackoverflow.com/questions/64993118/error-should-not-import-the-named-export-version-imported-as-version
29
+ // https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code/10855054#10855054
30
+ // import { version } from '../package.json'
31
+ // import packageInfo from '../package.json'
32
+ var Dropbox = /*#__PURE__*/function (_Plugin) {
33
+ // static VERSION = packageInfo.version
34
+
35
+ function Dropbox(filerobot) {
36
+ var _this;
37
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
+ _classCallCheck(this, Dropbox);
39
+ _this = _callSuper(this, Dropbox, [filerobot, opts]);
40
+ _this.id = PLUGINS_IDS.DROPBOX;
41
+ Provider.initPlugin(_this, opts);
42
+ _this.title = _this.opts.title || 'Dropbox';
43
+ _this.icon = DropboxIcon;
44
+ _this.provider = new Provider(filerobot, {
45
+ companionHeaders: _this.opts.companionHeaders,
46
+ provider: 'dropbox',
47
+ pluginId: _this.id
48
+ });
49
+ _this.onFirstRender = _this.onFirstRender.bind(_this);
50
+ _this.render = _this.render.bind(_this);
51
+ return _this;
52
+ }
53
+ _inherits(Dropbox, _Plugin);
54
+ return _createClass(Dropbox, [{
55
+ key: "install",
56
+ value: function install() {
57
+ this.view = new ProviderViews(this, {
58
+ provider: this.provider
59
+ });
60
+ if (Explorer) {
61
+ this.mount(Explorer, this);
62
+ }
63
+ }
64
+ }, {
65
+ key: "uninstall",
66
+ value: function uninstall() {
67
+ this.unmount();
68
+ }
69
+ }, {
70
+ key: "setPluginCommonState",
71
+ value: function setPluginCommonState(update) {
72
+ return this.dispatch(dropboxCommonStateUpdated(update));
73
+ }
74
+ }, {
75
+ key: "getPluginReducer",
76
+ value: function getPluginReducer() {
77
+ return dropboxReducer;
78
+ }
79
+ }, {
80
+ key: "onFirstRender",
81
+ value: function onFirstRender() {
82
+ return this.view.getFolder('', 'Dropbox');
83
+ }
84
+ }, {
85
+ key: "addSelectedItems",
86
+ value: function addSelectedItems() {
87
+ return this.view.addSelectedItems();
88
+ }
89
+ }, {
90
+ key: "getPrevFolder",
91
+ value: function getPrevFolder(folder) {
92
+ return this.view.getNextFolder(folder);
93
+ }
94
+ }, {
95
+ key: "render",
96
+ value: function render(state) {
97
+ return this.view.render(state);
98
+ }
99
+ }]);
100
+ }(Plugin);
101
+ export { Dropbox as default };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@scaleflex/widget-dropbox",
3
+ "description": "Import files from Dropbox, into Scaleflex.",
4
+ "version": "0.0.1",
5
+ "license": "MIT",
6
+ "main": "lib/index.js",
7
+ "types": "types/index.d.ts",
8
+ "dependencies": {
9
+ "@scaleflex/widget-companion-client": "^0.0.1",
10
+ "@scaleflex/widget-icons": "^0.0.1",
11
+ "@scaleflex/widget-provider-views": "^0.0.1",
12
+ "@scaleflex/widget-utils": "^0.0.1"
13
+ },
14
+ "devDependencies": {
15
+ "react": "^19.0.0",
16
+ "react-dom": "^19.0.0"
17
+ },
18
+ "peerDependencies": {
19
+ "@reduxjs/toolkit": "^1.9.5",
20
+ "@scaleflex/widget-core": "^0.0.0",
21
+ "@scaleflex/widget-explorer": "^0.0.0",
22
+ "react": ">=19.0.0",
23
+ "react-dom": ">=19.0.0",
24
+ "react-redux": "^8.1.1"
25
+ },
26
+ "files": [
27
+ "/dist",
28
+ "/lib",
29
+ "/types"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "gitHead": "64ea82e745b7deda36d6794863350e6671e9010d"
35
+ }
@@ -0,0 +1,16 @@
1
+ import Filerobot = require("@scaleflex/widget-core");
2
+ import CompanionClient = require("@scaleflex/widget-companion-client");
3
+
4
+ declare module Dropbox {
5
+ interface DropboxOptions
6
+ extends Filerobot.PluginOptions,
7
+ CompanionClient.PublicProviderOptions {
8
+ replaceTargetContent?: boolean;
9
+ target?: Filerobot.PluginTarget;
10
+ storage?: CompanionClient.TokenStorage;
11
+ }
12
+ }
13
+
14
+ declare class Dropbox extends Filerobot.Plugin<Dropbox.DropboxOptions> {}
15
+
16
+ export = Dropbox;