@scaleflex/widget-google-drive 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,85 @@
1
+ # @scaleflex/widget-google-drive
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
+ <div align='center'>
11
+ <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"/>
12
+ </div>
13
+
14
+ The Google Drive plugin for [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) lets users import files from their Google Drive account.
15
+
16
+ ## Usage
17
+
18
+ ### NPM
19
+
20
+ ```bash
21
+ npm install --save @scaleflex/widget-google-drive
22
+ ```
23
+
24
+ ### YARN
25
+
26
+ ```bash
27
+ yarn add @scaleflex/widget-google-drive
28
+ ```
29
+
30
+ then
31
+
32
+ ```js
33
+ import GoogleDrive from '@scaleflex/widget-google-drive'
34
+ ...
35
+ ...
36
+ ...
37
+ scaleflexWidget.use(GoogleDrive, propertiesObject)
38
+ ```
39
+
40
+ ### CDN
41
+
42
+ The plugin from CDN is found inside `Scaleflex` global object `Scaleflex.GoogleDrive`
43
+
44
+ ```js
45
+ const googleDrive = window.ScaleflexWidget.GoogleDrive
46
+ ...
47
+ ...
48
+ ...
49
+ scaleflexWidget.use(googleDrive, propertiesObject)
50
+ ```
51
+
52
+ ## Properties
53
+
54
+ ### `title`
55
+
56
+ <u>Type:</u> `string`
57
+
58
+ <u>Default:</u> `'Google Drive'`
59
+
60
+ The title/label that would be shown & used for the plugin.
61
+
62
+ ### `companionHeaders`
63
+
64
+ <u>Type:</u> `null` | `object`
65
+
66
+ <u>Default:</u> `null`
67
+
68
+ If you need to pass additional headers for in companion requests then pass them in this property.
69
+
70
+ <!-- Variables -->
71
+
72
+ [npm-url]: https://www.npmjs.com/package/@scaleflex/widget-google-drive
73
+ [license-url]: https://opensource.org/licenses/MIT
74
+ [sfx-url]: https://www.scaleflex.com/
75
+ [version-url]: https://www.npmjs.com/package/@scaleflex/widget-google-drive
76
+ [codeSandbox-url]: https://codesandbox.io/s/filerobot-widget-v3-c5l9th
77
+
78
+
79
+ [npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
80
+ [license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
81
+ [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
82
+ [plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
83
+ [filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
84
+ [filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-google-drive?label=Version&style=for-the-badge&logo=npm
85
+ [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 _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 _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
12
+ function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
13
+ function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
14
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
15
+ 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); }
16
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
17
+ import ProviderViews from '@scaleflex/widget-provider-views';
18
+ var DriveProviderViews = /*#__PURE__*/function (_ProviderViews) {
19
+ function DriveProviderViews() {
20
+ _classCallCheck(this, DriveProviderViews);
21
+ return _callSuper(this, DriveProviderViews, arguments);
22
+ }
23
+ _inherits(DriveProviderViews, _ProviderViews);
24
+ return _createClass(DriveProviderViews, [{
25
+ key: "toggleCheckbox",
26
+ value: function toggleCheckbox(e, file) {
27
+ e.stopPropagation();
28
+ e.preventDefault();
29
+ if (!file.custom.isTeamDrive && !file.custom.isSharedDrive) {
30
+ _superPropGet(DriveProviderViews, "toggleCheckbox", this, 3)([e, file]);
31
+ }
32
+ }
33
+ }]);
34
+ }(ProviderViews);
35
+ export { DriveProviderViews as default };
@@ -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.GOOGLE_DRIVE,
23
+ initialState: initialState,
24
+ reducers: {
25
+ googleDriveCommonStateUpdated: function googleDriveCommonStateUpdated(state, action) {
26
+ return _objectSpread(_objectSpread({}, state), action.payload);
27
+ }
28
+ }
29
+ });
30
+ var googleDriveCommonStateUpdated = commonSlice.actions.googleDriveCommonStateUpdated;
31
+ export { googleDriveCommonStateUpdated };
32
+ export var selectGoogleDriveCommonState = function selectGoogleDriveCommonState(state) {
33
+ return state[PLUGINS_IDS.GOOGLE_DRIVE];
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 { GoogleDriveIcon } from '@scaleflex/widget-icons';
18
+ import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
19
+ import DriveProviderViews from './DriveProviderViews';
20
+ import googleDriveReducer, { googleDriveCommonStateUpdated } from './common.slice';
21
+ // TODO: find a way to show version of the current plugin
22
+ // why solution below isn't good?
23
+ // first import doesn't work with webpack 5 as it was deprecated
24
+ // second import fixes webpack 5 issue as it was mentioned in their docs
25
+ // but it exposes our package.json to the client and it is mentioned as security rist in mutiple places
26
+ // https://github.com/axelpale/genversion
27
+ // https://stackoverflow.com/questions/64993118/error-should-not-import-the-named-export-version-imported-as-version
28
+ // https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code/10855054#10855054
29
+ // import { version } from '../package.json'
30
+ // import packageInfo from '../package.json'
31
+ var GoogleDrive = /*#__PURE__*/function (_Plugin) {
32
+ // static VERSION = packageInfo.version
33
+
34
+ function GoogleDrive(filerobot) {
35
+ var _this;
36
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
37
+ _classCallCheck(this, GoogleDrive);
38
+ _this = _callSuper(this, GoogleDrive, [filerobot, opts]);
39
+ _this.id = PLUGINS_IDS.GOOGLE_DRIVE;
40
+ Provider.initPlugin(_this, opts);
41
+ _this.title = _this.opts.title || 'Google Drive';
42
+ _this.icon = GoogleDriveIcon;
43
+ _this.provider = new Provider(filerobot, {
44
+ companionHeaders: _this.opts.companionHeaders,
45
+ // in case we want to provide some other custom headers
46
+ provider: 'drive',
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(GoogleDrive, _Plugin);
54
+ return _createClass(GoogleDrive, [{
55
+ key: "install",
56
+ value: function install() {
57
+ this.view = new DriveProviderViews(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(googleDriveCommonStateUpdated(update));
73
+ }
74
+ }, {
75
+ key: "getPluginReducer",
76
+ value: function getPluginReducer() {
77
+ return googleDriveReducer;
78
+ }
79
+ }, {
80
+ key: "onFirstRender",
81
+ value: function onFirstRender() {
82
+ return this.view.getFolder('root', 'Google Drive');
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 { GoogleDrive as default };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@scaleflex/widget-google-drive",
3
+ "description": "Google Drive plugin for Scaleflex Widget lets users import files from their Google Drive account 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 GoogleDrive {
5
+ interface GoogleDriveOptions
6
+ extends Filerobot.PluginOptions,
7
+ CompanionClient.PublicProviderOptions {
8
+ replaceTargetContent?: boolean;
9
+ target?: Filerobot.PluginTarget;
10
+ storage?: CompanionClient.TokenStorage;
11
+ }
12
+ }
13
+
14
+ declare class GoogleDrive extends Filerobot.Plugin<GoogleDrive.GoogleDriveOptions> {}
15
+
16
+ export = GoogleDrive;