@scaleflex/widget-facebook 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,86 @@
1
+ # @scaleflex/widget-facebook
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 Facebook plugin for [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) lets users import files from their Facebook account.
16
+
17
+ ## Usage
18
+
19
+ ### NPM
20
+
21
+ ```bash
22
+ npm install --save @scaleflex/widget-facebook
23
+ ```
24
+
25
+ ### YARN
26
+
27
+ ```bash
28
+ yarn add @scaleflex/widget-facebook
29
+ ```
30
+
31
+ then
32
+
33
+ ```js
34
+ import Facebook from '@scaleflex/widget-facebook'
35
+ ...
36
+ ...
37
+ ...
38
+ scaleflexWidget.use(Facebook, propertiesObject)
39
+ ```
40
+
41
+ ### CDN
42
+
43
+ The plugin from CDN is found inside `Scaleflex` global object `Scaleflex.Facebook`
44
+
45
+ ```js
46
+ const facebook = window.ScaleflexWidget.Facebook
47
+ ...
48
+ ...
49
+ ...
50
+ scaleflexWidget.use(facebook, propertiesObject)
51
+ ```
52
+
53
+ ## Properties
54
+
55
+ ### `title`
56
+
57
+ <u>Type:</u> `string`
58
+
59
+ <u>Default:</u> `'Facebook'`
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
+ <!-- Variables -->
72
+
73
+ [npm-url]: https://www.npmjs.com/package/@scaleflex/widget-facebook
74
+ [license-url]: https://opensource.org/licenses/MIT
75
+ [sfx-url]: https://www.scaleflex.com/
76
+ [version-url]: https://www.npmjs.com/package/@scaleflex/widget-facebook
77
+ [codeSandbox-url]: https://codesandbox.io/s/filerobot-widget-v3-c5l9th
78
+
79
+
80
+ [npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
81
+ [license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
82
+ [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
83
+ [plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
84
+ [filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
85
+ [filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-facebook?label=Version&style=for-the-badge&logo=npm
86
+ [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.FACEBOOK,
23
+ initialState: initialState,
24
+ reducers: {
25
+ facebookCommonStateUpdated: function facebookCommonStateUpdated(state, action) {
26
+ return _objectSpread(_objectSpread({}, state), action.payload);
27
+ }
28
+ }
29
+ });
30
+ var facebookCommonStateUpdated = commonSlice.actions.facebookCommonStateUpdated;
31
+ export { facebookCommonStateUpdated };
32
+ export var selectFacebookCommonState = function selectFacebookCommonState(state) {
33
+ return state[PLUGINS_IDS.FACEBOOK];
34
+ };
35
+ export default commonSlice.reducer;
package/lib/index.js ADDED
@@ -0,0 +1,97 @@
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 { FacebookIcon } from '@scaleflex/widget-icons';
19
+ import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
20
+ import facebookReducer, { facebookCommonStateUpdated } 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 Facebook = /*#__PURE__*/function (_Plugin) {
33
+ // static VERSION = packageInfo.version
34
+
35
+ function Facebook(filerobot) {
36
+ var _this;
37
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
+ _classCallCheck(this, Facebook);
39
+ _this = _callSuper(this, Facebook, [filerobot, opts]);
40
+ _this.id = PLUGINS_IDS.FACEBOOK;
41
+ Provider.initPlugin(_this, opts);
42
+ _this.title = _this.opts.title || 'Facebook';
43
+ _this.icon = FacebookIcon;
44
+ _this.provider = new Provider(filerobot, {
45
+ companionHeaders: _this.opts.companionHeaders,
46
+ provider: 'facebook',
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(Facebook, _Plugin);
54
+ return _createClass(Facebook, [{
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(facebookCommonStateUpdated(update));
73
+ }
74
+ }, {
75
+ key: "getPluginReducer",
76
+ value: function getPluginReducer() {
77
+ return facebookReducer;
78
+ }
79
+ }, {
80
+ key: "onFirstRender",
81
+ value: function onFirstRender() {
82
+ return this.view.getFolder();
83
+ }
84
+ }, {
85
+ key: "render",
86
+ value: function render(state) {
87
+ var viewOptions = {};
88
+ if (this.getPluginCommonState().files.length && !this.getPluginCommonState().folders.length) {
89
+ viewOptions.layoutType = 'grid';
90
+ viewOptions.showFilter = false;
91
+ viewOptions.showTitles = false;
92
+ }
93
+ return this.view.render(state, viewOptions);
94
+ }
95
+ }]);
96
+ }(Plugin);
97
+ export { Facebook as default };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@scaleflex/widget-facebook",
3
+ "description": "Import files from Facebook, 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-provider-views": "^0.0.1",
11
+ "@scaleflex/widget-utils": "^0.0.1"
12
+ },
13
+ "devDependencies": {
14
+ "react": "^19.0.0",
15
+ "react-dom": "^19.0.0"
16
+ },
17
+ "peerDependencies": {
18
+ "@reduxjs/toolkit": "^1.9.5",
19
+ "@scaleflex/widget-core": "^0.0.0",
20
+ "@scaleflex/widget-explorer": "^0.0.0",
21
+ "react": ">=19.0.0",
22
+ "react-dom": ">=19.0.0",
23
+ "react-redux": "^8.1.1"
24
+ },
25
+ "files": [
26
+ "/dist",
27
+ "/lib",
28
+ "/types"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "gitHead": "64ea82e745b7deda36d6794863350e6671e9010d"
34
+ }
@@ -0,0 +1,16 @@
1
+ import Filerobot = require("@scaleflex/widget-core");
2
+ import CompanionClient = require("@scaleflex/widget-companion-client");
3
+
4
+ declare module Facebook {
5
+ interface FacebookOptions
6
+ extends Filerobot.PluginOptions,
7
+ CompanionClient.PublicProviderOptions {
8
+ replaceTargetContent?: boolean;
9
+ target?: Filerobot.PluginTarget;
10
+ storage?: CompanionClient.TokenStorage;
11
+ }
12
+ }
13
+
14
+ declare class Facebook extends Filerobot.Plugin<Facebook.FacebookOptions> {}
15
+
16
+ export = Facebook;