@scaleflex/widget-preupload-processors 4.1.0 → 4.4.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.4.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.1.0...v4.4.0) (2025-10-07)
7
+
8
+ **Note:** Version bump only for package @scaleflex/widget-preupload-processors
9
+
10
+
11
+
12
+
13
+
14
+ # [4.3.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.1.0...v4.3.0) (2025-10-02)
15
+
16
+ **Note:** Version bump only for package @scaleflex/widget-preupload-processors
17
+
18
+
19
+
20
+
21
+
22
+ # [4.2.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.1.0...v4.2.0) (2025-10-02)
23
+
24
+ **Note:** Version bump only for package @scaleflex/widget-preupload-processors
25
+
26
+
27
+
28
+
29
+
6
30
  # [4.1.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.0.8...v4.1.0) (2025-10-02)
7
31
 
8
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/widget-preupload-processors",
3
- "version": "4.1.0",
3
+ "version": "4.4.0",
4
4
  "description": "Scaleflex preupload-processors module.",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",
@@ -15,10 +15,10 @@
15
15
  "dependencies": {
16
16
  "@scaleflex/icons": "^3.0.0-beta.11",
17
17
  "@scaleflex/ui": "^3.0.0-beta.11",
18
- "@scaleflex/widget-common": "^4.1.0",
19
- "@scaleflex/widget-icons": "^4.1.0",
20
- "@scaleflex/widget-tus": "^4.1.0",
21
- "@scaleflex/widget-utils": "^4.1.0"
18
+ "@scaleflex/widget-common": "^4.4.0",
19
+ "@scaleflex/widget-icons": "^4.4.0",
20
+ "@scaleflex/widget-tus": "^4.4.0",
21
+ "@scaleflex/widget-utils": "^4.4.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "react": "^19.0.0",
@@ -30,5 +30,5 @@
30
30
  "react-dom": ">=19.0.0"
31
31
  },
32
32
  "license": "MIT",
33
- "gitHead": "471120d67066617a0d8824eae11b07d1f2259473"
33
+ "gitHead": "04b8ec545c4f10be89f5a44eed954acf8433360c"
34
34
  }
@@ -1,15 +0,0 @@
1
- var VIDEO_TRANSCODING = {
2
- resolutions: ['auto', 'hq', 'desktop', 'tablet', 'mobile', 'sample'],
3
- protocols: [{
4
- label: 'HLS',
5
- value: 'hls'
6
- }
7
- // commented because DASH transcoding is not working, task: https://scaleflexhq.atlassian.net/browse/FRA-5131
8
- // TODO: uncomment when issue is fixed
9
- // { label: 'DASH', value: 'dash' },
10
- // { label: 'HLS & DASH', value: 'hls,dash' }
11
- ],
12
- defaultResolution: 'auto',
13
- defaultProtocol: 'hls'
14
- };
15
- export default VIDEO_TRANSCODING;
@@ -1,30 +0,0 @@
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 { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
8
- import { createSlice } from '@reduxjs/toolkit';
9
- var initialState = {
10
- videoTranscoding: {},
11
- isUserAllowedToOptimize: false,
12
- isVideoProcessActive: false,
13
- imageOperation: {},
14
- isImageProcessActive: false
15
- };
16
- var commonSlice = createSlice({
17
- name: PLUGINS_IDS.PREUPLOAD_PROCESSORS,
18
- initialState: initialState,
19
- reducers: {
20
- preUpProcessorsCommonStateUpdated: function preUpProcessorsCommonStateUpdated(state, action) {
21
- return _objectSpread(_objectSpread({}, state), action.payload);
22
- }
23
- }
24
- });
25
- var preUpProcessorsCommonStateUpdated = commonSlice.actions.preUpProcessorsCommonStateUpdated;
26
- export { preUpProcessorsCommonStateUpdated };
27
- export var selectPreUpProcessorsCommonState = function selectPreUpProcessorsCommonState(state) {
28
- return state[PLUGINS_IDS.PREUPLOAD_PROCESSORS];
29
- };
30
- export default commonSlice.reducer;
@@ -1,94 +0,0 @@
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 { Fragment } from 'react';
8
- import { useDispatch, useSelector } from 'react-redux';
9
- import Styled from './PreProcessor.styled';
10
- import { preUpProcessorsCommonStateUpdated, selectPreUpProcessorsCommonState } from '../common.slice';
11
- import ProcessorToggle from './ProcessorToggle';
12
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
- var MIN_DIMENSION = 0;
14
- var ImageAndPdfProcessor = function ImageAndPdfProcessor(_ref) {
15
- var i18n = _ref.i18n,
16
- pluginOpts = _ref.pluginOpts;
17
- var dispatch = useDispatch();
18
- var imageOperation = useSelector(function (state) {
19
- return selectPreUpProcessorsCommonState(state).imageOperation;
20
- });
21
- var isImageProcessActive = useSelector(function (state) {
22
- return selectPreUpProcessorsCommonState(state).isImageProcessActive;
23
- });
24
- var isUserAllowedToOptimize = useSelector(function (state) {
25
- return selectPreUpProcessorsCommonState(state).isUserAllowedToOptimize || false;
26
- });
27
- var imageOperations = pluginOpts.imageOperations;
28
- var imageDimension = {
29
- width: i18n('preuploadMaxWidth'),
30
- height: i18n('preuploadMaxHeight')
31
- };
32
- var toggleImageProcessor = function toggleImageProcessor(e) {
33
- dispatch(preUpProcessorsCommonStateUpdated({
34
- isImageProcessActive: e.target.checked
35
- }));
36
- };
37
- var updateImageOperation = function updateImageOperation(newState) {
38
- dispatch(preUpProcessorsCommonStateUpdated({
39
- imageOperation: _objectSpread(_objectSpread({}, imageOperation), newState)
40
- }));
41
- };
42
- var updateImageOperationVals = function updateImageOperationVals(newState) {
43
- return updateImageOperation({
44
- values: _objectSpread(_objectSpread({}, imageOperation.values), newState)
45
- });
46
- };
47
- var changeWidthOrHeight = function changeWidthOrHeight(key, value) {
48
- var nextValues = _defineProperty({}, key, value >= MIN_DIMENSION ? +value : MIN_DIMENSION);
49
- updateImageOperationVals(nextValues);
50
- };
51
- var renderOperationOption = function renderOperationOption(optionName) {
52
- var _imageOperation$value;
53
- var _onChange = function onChange(value) {
54
- return ['width', 'height'].includes(optionName) ? changeWidthOrHeight(optionName, value) : updateImageOperation(_defineProperty({}, optionName, value));
55
- };
56
- var optionValue = imageOperations[imageOperation.name][optionName];
57
- return /*#__PURE__*/_jsx(Styled.OperationOptionWrapper, {
58
- children: /*#__PURE__*/_jsx(Fragment, {
59
- children: /*#__PURE__*/_jsx(Styled.InputGroup, {
60
- disabled: !isImageProcessActive || !isUserAllowedToOptimize,
61
- label: imageDimension[optionName],
62
- iconEnd: "px",
63
- inputProps: {
64
- type: 'number',
65
- min: 0
66
- },
67
- value: ((_imageOperation$value = imageOperation.values[optionName]) !== null && _imageOperation$value !== void 0 ? _imageOperation$value : optionValue).toString(),
68
- onChange: function onChange(_ref2) {
69
- var target = _ref2.target;
70
- return _onChange(target.value);
71
- }
72
- })
73
- }, optionName)
74
- }, optionName);
75
- };
76
- return /*#__PURE__*/_jsx(_Fragment, {
77
- children: /*#__PURE__*/_jsxs(Styled.SettingsContainer, {
78
- children: [/*#__PURE__*/_jsx(Styled.UploadProcessorTitle, {
79
- children: i18n('preuploadOptimizeImagesTitle')
80
- }), /*#__PURE__*/_jsx(ProcessorToggle, {
81
- toggleText: i18n('preuploadOptimizeImagesSubTitle'),
82
- tooltipText: i18n('preuploadQuickUploadModeHint'),
83
- isProcessActive: isImageProcessActive,
84
- isProcessEnabled: isUserAllowedToOptimize,
85
- toggleProcessor: toggleImageProcessor
86
- }), /*#__PURE__*/_jsx(Styled.OperationsContainer, {
87
- children: /*#__PURE__*/_jsx(Styled.Operation, {
88
- children: Object.keys(imageOperations[imageOperation.name]).map(renderOperationOption)
89
- })
90
- })]
91
- })
92
- });
93
- };
94
- export default ImageAndPdfProcessor;
@@ -1,80 +0,0 @@
1
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
2
- function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
3
- import { FV, PC, PSH } from '@scaleflex/widget-common';
4
- import styled, { css } from 'styled-components';
5
- import { TooltipV2, RadioGroup, StatusLabel as SfxLabel, InputGroup as SfxInputGroup } from '@scaleflex/ui/core';
6
- import { InfoOutline } from '@scaleflex/icons';
7
- var UploadSettingsContainer = styled.div(function (_ref) {
8
- var _ref$theme = _ref.theme,
9
- palette = _ref$theme.palette,
10
- breakpoints = _ref$theme.breakpoints,
11
- shadows = _ref$theme.shadows;
12
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n background: ", ";\n box-shadow: ", ";\n height: 100%;\n padding: 24px 24px 8px 24px;\n width: 302px;\n overflow-y: auto;\n\n ", " {\n padding: 24px 24px 8px 24px;\n }\n\n ", " {\n padding: 24px 24px 8px 24px;\n }\n "])), palette[PC.TextPrimary], palette[PC.BackgroundStateless], shadows[PSH.LeftPanelMd], breakpoints.between('lg', 'xxxl'), breakpoints.down('lg'));
13
- });
14
- var UploadSettingsTitle = styled.div(function (_ref2) {
15
- var palette = _ref2.theme.palette;
16
- return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n font-style: normal;\n font-weight: 500;\n font-size: 18px;\n line-height: 27px;\n width: 100%;\n margin-bottom: 16px;\n border-bottom: 1px solid ", ";\n padding-bottom: 16px;\n align-items: center;\n width: 100%;\n "])), palette[PC.BordersSecondary]);
17
- });
18
- var UploadProcessorTitle = styled.div(function (_ref3) {
19
- var palette = _ref3.theme.palette;
20
- return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n font-weight: 500;\n font-size: 16px;\n line-height: 24px;\n "])), palette[PC.TextPrimary]);
21
- });
22
- var UploadProcessorSubTitle = styled.div(function (_ref4) {
23
- var _ref4$theme = _ref4.theme,
24
- palette = _ref4$theme.palette,
25
- typography = _ref4$theme.typography,
26
- paddingTop = _ref4.paddingTop;
27
- return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n color: ", ";\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 16px 0;\n ", "\n width: 100%;\n > label {\n display: flex;\n align-items: center;\n }\n "])), typography.font[FV.InputLg], palette[PC.TextPrimary], paddingTop && 'padding-top: 24px;');
28
- });
29
- var UploadOptionLabel = styled.div(function (_ref5) {
30
- var palette = _ref5.theme.palette,
31
- disabled = _ref5.disabled;
32
- return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 14px;\n line-height: 16px;\n "])), palette[disabled ? PC.ButtonDisabledText : PC.TextSecondary]);
33
- });
34
- var SettingsContainer = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n width: 100%;\n &:nth-child(3) {\n margin-top: 40px;\n margin-bottom: 12px;\n }\n "])));
35
- var OperationOptionWrapper = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n &:last-child {\n margin-left: 12px;\n }\n "])));
36
- var InputGroup = styled(SfxInputGroup)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: 121px;\n padding: 11px 16px;\n max-width: 100%;\n"])));
37
- var ProcessSelect = styled.div(function (_ref6) {
38
- var palette = _ref6.theme.palette,
39
- disabled = _ref6.disabled;
40
- return css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n display: inline-flex;\n flex-direction: column;\n width: 100%;\n margin-bottom: 16px;\n\n > label {\n display: flex;\n align-items: center;\n margin-bottom: 4px;\n font-size: 14px;\n color: ", ";\n line-height: 16px;\n }\n "])), palette[disabled ? PC.ButtonDisabledText : PC.TextSecondary]);
41
- });
42
- var ProtocolsRadio = styled(RadioGroup)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding-bottom: 12px;\n"])));
43
- var Protocols = styled.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n margin-top: 12px;\n"])));
44
- var ProtocolWrapper = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n margin-right: 16px;\n"])));
45
- var OperationsContainer = styled.div(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n font-size: 14px;\n"])));
46
- var Operation = styled.div(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n display: flex;\n"])));
47
- var InfoOutlined = styled(InfoOutline)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n margin-left: 4px;\n color: ", ";\n"])), function (_ref7) {
48
- var palette = _ref7.theme.palette;
49
- return palette[PC.IconsPrimary];
50
- });
51
- var ResumableUploadWrapper = styled.div(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n width: 100%;\n"])));
52
- var Label = styled(SfxLabel)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n margin-left: 8px;\n background-color: ", ";\n border-radius: 4px;\n font-size: 12px;\n height: 18px;\n width: 32px;\n\n .SfxStatusLabel-Label {\n height: 14px;\n width: 25px;\n }\n\n &:hover {\n background: ", ";\n }\n"])), function (_ref8) {
53
- var palette = _ref8.theme.palette;
54
- return palette[PC.Success];
55
- }, function (_ref9) {
56
- var palette = _ref9.theme.palette;
57
- return palette[PC.SuccessHover];
58
- });
59
- var ShowMoreTooltip = styled(TooltipV2)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n overflow-wrap: anywhere;\n"])));
60
- var Styled = {
61
- UploadSettingsContainer: UploadSettingsContainer,
62
- UploadSettingsTitle: UploadSettingsTitle,
63
- UploadProcessorTitle: UploadProcessorTitle,
64
- UploadProcessorSubTitle: UploadProcessorSubTitle,
65
- UploadOptionLabel: UploadOptionLabel,
66
- SettingsContainer: SettingsContainer,
67
- OperationOptionWrapper: OperationOptionWrapper,
68
- InputGroup: InputGroup,
69
- ProcessSelect: ProcessSelect,
70
- Protocols: Protocols,
71
- ProtocolWrapper: ProtocolWrapper,
72
- Operation: Operation,
73
- OperationsContainer: OperationsContainer,
74
- ProtocolsRadio: ProtocolsRadio,
75
- InfoOutlined: InfoOutlined,
76
- ResumableUploadWrapper: ResumableUploadWrapper,
77
- Label: Label,
78
- ShowMoreTooltip: ShowMoreTooltip
79
- };
80
- export default Styled;
@@ -1,33 +0,0 @@
1
- import { Select, MenuItem } from '@scaleflex/ui/core';
2
- import capitalizeFirstLetter from '@scaleflex/widget-utils/lib/capitalizeFirstLetter';
3
- import Styled from './PreProcessor.styled';
4
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- var ProcessSelect = function ProcessSelect(_ref) {
6
- var title = _ref.title,
7
- options = _ref.options,
8
- value = _ref.value,
9
- onChange = _ref.onChange,
10
- description = _ref.description,
11
- style = _ref.style,
12
- disabled = _ref.disabled;
13
- return /*#__PURE__*/_jsxs(Styled.ProcessSelect, {
14
- disabled: disabled,
15
- children: [/*#__PURE__*/_jsx("label", {
16
- children: title
17
- }), /*#__PURE__*/_jsx(Select, {
18
- disabled: disabled,
19
- value: value,
20
- onChange: onChange,
21
- children: options.map(function (option) {
22
- var _option$value, _option$value2, _ref2, _option$label, _ref3, _option$label2;
23
- return /*#__PURE__*/_jsx(MenuItem, {
24
- active: disabled,
25
- value: (_option$value2 = option.value) !== null && _option$value2 !== void 0 ? _option$value2 : option,
26
- primary: (_ref2 = (_option$label = option.label) !== null && _option$label !== void 0 ? _option$label : option.value) !== null && _ref2 !== void 0 ? _ref2 : option,
27
- children: capitalizeFirstLetter((_ref3 = (_option$label2 = option.label) !== null && _option$label2 !== void 0 ? _option$label2 : option.value) !== null && _ref3 !== void 0 ? _ref3 : option)
28
- }, (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option);
29
- })
30
- })]
31
- });
32
- };
33
- export default ProcessSelect;
@@ -1,37 +0,0 @@
1
- import { TooltipV2, Switcher } from '@scaleflex/ui/core';
2
- import Styled from './PreProcessor.styled';
3
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- var ProcessorToggle = function ProcessorToggle(_ref) {
5
- var _ref$paddingTop = _ref.paddingTop,
6
- paddingTop = _ref$paddingTop === void 0 ? null : _ref$paddingTop,
7
- toggleText = _ref.toggleText,
8
- tooltipText = _ref.tooltipText,
9
- isProcessActive = _ref.isProcessActive,
10
- _ref$isProcessEnabled = _ref.isProcessEnabled,
11
- isProcessEnabled = _ref$isProcessEnabled === void 0 ? true : _ref$isProcessEnabled,
12
- _ref$toggleProcessor = _ref.toggleProcessor,
13
- toggleProcessor = _ref$toggleProcessor === void 0 ? function () {} : _ref$toggleProcessor,
14
- _ref$tooltipContent = _ref.tooltipContent,
15
- tooltipContent = _ref$tooltipContent === void 0 ? null : _ref$tooltipContent;
16
- return /*#__PURE__*/_jsxs(Styled.UploadProcessorSubTitle, {
17
- paddingTop: paddingTop,
18
- children: [/*#__PURE__*/_jsxs("label", {
19
- children: [toggleText, /*#__PURE__*/_jsx(TooltipV2, {
20
- arrow: true,
21
- position: "top",
22
- size: "sm",
23
- title: tooltipText,
24
- children: tooltipContent || /*#__PURE__*/_jsx(Styled.InfoOutlined, {
25
- size: 14
26
- })
27
- })]
28
- }), /*#__PURE__*/_jsx(Switcher, {
29
- size: "md",
30
- checked: isProcessActive,
31
- disabled: !isProcessEnabled,
32
- readOnly: !isProcessEnabled,
33
- onChange: toggleProcessor
34
- })]
35
- });
36
- };
37
- export default ProcessorToggle;
@@ -1,63 +0,0 @@
1
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
- import { useMemo } from 'react';
8
- import { useSelector } from 'react-redux';
9
- import isPdf from '@scaleflex/widget-utils/lib/isPdf';
10
- import isSvg from '@scaleflex/widget-utils/lib/isSvg';
11
- import isSupportedVideo from '@scaleflex/widget-utils/lib/isSupportedVideo';
12
- import isImage from '@scaleflex/widget-utils/lib/isImage';
13
- import { useExplorer } from '@scaleflex/widget-explorer/lib/hooks';
14
- import { selectUploadsArray } from '@scaleflex/widget-core/lib/slices/uploads.slice';
15
- import VideoProcessor from './VideoProcessor';
16
- import ImageAndPdfProcessor from './ImageAndPdfProcessor';
17
- import ResumableUploaderProcessor from './ResumableUploaderProcessor';
18
- import Styled from './PreProcessor.styled';
19
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
- var ProcessorsUI = function ProcessorsUI(_ref) {
21
- var i18n = _ref.i18n,
22
- pluginOpts = _ref.pluginOpts;
23
- var _useExplorer = useExplorer(),
24
- showResumableUploadSwitcher = _useExplorer.opts.showResumableUploadSwitcher;
25
- var uploadableFiles = useSelector(selectUploadsArray);
26
- var _useMemo = useMemo(function () {
27
- var result = [false, false, false];
28
- uploadableFiles.forEach(function (file) {
29
- if (isImage(file) && !isSvg(file)) {
30
- result[0] = true;
31
- } else if (isSupportedVideo(file)) {
32
- result[1] = true;
33
- } else if (isPdf(file)) {
34
- result[2] = true;
35
- }
36
- if (result[0] && result[1] && result[2]) {
37
- return result;
38
- }
39
- });
40
- return result;
41
- }, [uploadableFiles]),
42
- _useMemo2 = _slicedToArray(_useMemo, 3),
43
- hasImage = _useMemo2[0],
44
- hasVideo = _useMemo2[1],
45
- hasPdf = _useMemo2[2];
46
- return /*#__PURE__*/_jsxs(Styled.UploadSettingsContainer, {
47
- children: [/*#__PURE__*/_jsx(Styled.UploadSettingsTitle, {
48
- children: /*#__PURE__*/_jsx("label", {
49
- children: i18n('preuploadUploadSettingsLabel')
50
- })
51
- }), (hasImage || hasPdf) && /*#__PURE__*/_jsx(ImageAndPdfProcessor, {
52
- i18n: i18n,
53
- pluginOpts: pluginOpts
54
- }), hasVideo && /*#__PURE__*/_jsx(VideoProcessor, {
55
- i18n: i18n,
56
- pluginOpts: pluginOpts
57
- }), showResumableUploadSwitcher && /*#__PURE__*/_jsx(ResumableUploaderProcessor, {
58
- i18n: i18n,
59
- uploadableFiles: uploadableFiles
60
- })]
61
- });
62
- };
63
- export default ProcessorsUI;
@@ -1,59 +0,0 @@
1
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
- import { useEffect, useState } from 'react';
8
- import { useSelector } from 'react-redux';
9
- import { selectUploadCapabilities } from '@scaleflex/widget-core/lib/slices/uploads.slice';
10
- import useCore from '@scaleflex/widget-core/lib/hooks/useCore';
11
- import Tus from '@scaleflex/widget-tus';
12
- import XHRUpload from '@scaleflex/widget-xhr-upload';
13
- import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
14
- import Styled from './PreProcessor.styled';
15
- import ProcessorToggle from './ProcessorToggle';
16
- import { jsx as _jsx } from "react/jsx-runtime";
17
- var ResumableUploaderProcessor = function ResumableUploaderProcessor(_ref) {
18
- var i18n = _ref.i18n,
19
- uploadableFiles = _ref.uploadableFiles;
20
- var _useSelector = useSelector(selectUploadCapabilities),
21
- allowResumableUploads = _useSelector.allowResumableUploads;
22
- var _useCore = useCore(),
23
- removePlugin = _useCore.removePlugin,
24
- getPlugin = _useCore.getPlugin,
25
- use = _useCore.use;
26
- var tusInstance = getPlugin(PLUGINS_IDS.TUS);
27
- var XHRUploadInstance = getPlugin(PLUGINS_IDS.XHR_UPLOAD);
28
- var progressPanelInstance = getPlugin(PLUGINS_IDS.PROGRESS_PANEL);
29
- var isResumableUploadSwitcherDisabled = (progressPanelInstance === null || progressPanelInstance === void 0 ? void 0 : progressPanelInstance.getUploadingActivitiesIds().length) > 0;
30
- var _useState = useState(allowResumableUploads),
31
- _useState2 = _slicedToArray(_useState, 2),
32
- isResumableUpload = _useState2[0],
33
- setIsResumableUpload = _useState2[1];
34
- var handleResumableSwitcher = function handleResumableSwitcher() {
35
- setIsResumableUpload(!isResumableUpload);
36
- };
37
- useEffect(function () {
38
- if (isResumableUpload) {
39
- if (XHRUploadInstance) removePlugin(XHRUploadInstance);
40
- if (!tusInstance) use(Tus, {});
41
- } else {
42
- if (tusInstance) removePlugin(tusInstance);
43
- if (!XHRUploadInstance) use(XHRUpload, {});
44
- }
45
- }, [isResumableUpload]);
46
- return /*#__PURE__*/_jsx(Styled.ResumableUploadWrapper, {
47
- children: /*#__PURE__*/_jsx(ProcessorToggle, {
48
- toggleText: i18n('preuploadResumableUploadTitle'),
49
- tooltipText: i18n('preuploadResumableUploadBetaMsg'),
50
- tooltipContent: /*#__PURE__*/_jsx(Styled.Label, {
51
- label: i18n('preuploadResumableUploadBetaTitle')
52
- }),
53
- isProcessActive: isResumableUpload,
54
- toggleProcessor: handleResumableSwitcher,
55
- isProcessEnabled: !isResumableUploadSwitcherDisabled
56
- })
57
- });
58
- };
59
- export default ResumableUploaderProcessor;
@@ -1,95 +0,0 @@
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 { useDispatch, useSelector } from 'react-redux';
8
- import ProcessSelect from './ProcessSelect';
9
- import Styled from './PreProcessor.styled';
10
- import { preUpProcessorsCommonStateUpdated, selectPreUpProcessorsCommonState } from '../common.slice';
11
- import ProcessorToggle from './ProcessorToggle';
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- var VideoProcessor = function VideoProcessor(_ref) {
14
- var i18n = _ref.i18n,
15
- pluginOpts = _ref.pluginOpts;
16
- var dispatch = useDispatch();
17
- var isVideoProcessActive = useSelector(function (state) {
18
- return selectPreUpProcessorsCommonState(state).isVideoProcessActive;
19
- });
20
- var videoTranscoding = useSelector(function (state) {
21
- return selectPreUpProcessorsCommonState(state).videoTranscoding;
22
- });
23
- var videoTranscodingOptions = pluginOpts.videoTranscodingOptions;
24
- var toggleVideoProcessor = function toggleVideoProcessor(e) {
25
- dispatch(preUpProcessorsCommonStateUpdated({
26
- isVideoProcessActive: e.target.checked
27
- }));
28
- };
29
- var updateVideoTranscoding = function updateVideoTranscoding(newState) {
30
- dispatch(preUpProcessorsCommonStateUpdated({
31
- videoTranscoding: _objectSpread(_objectSpread({}, videoTranscoding), newState)
32
- }));
33
- };
34
- var renderVideoProtocols = function renderVideoProtocols() {
35
- var protocols = videoTranscodingOptions.protocols;
36
- var updateProtocol = function updateProtocol(protocol) {
37
- updateVideoTranscoding({
38
- protocol: protocol
39
- });
40
- };
41
- return /*#__PURE__*/_jsxs("div", {
42
- children: [/*#__PURE__*/_jsx(Styled.UploadOptionLabel, {
43
- disabled: !isVideoProcessActive,
44
- children: i18n('preuploadProtocolsText')
45
- }), /*#__PURE__*/_jsx(Styled.Protocols, {
46
- children: protocols.map(function (protocol) {
47
- return /*#__PURE__*/_jsx(Styled.ProtocolWrapper, {
48
- children: /*#__PURE__*/_jsx(Styled.ProtocolsRadio, {
49
- size: "md",
50
- disabled: !isVideoProcessActive,
51
- checked: videoTranscoding.protocol.toLowerCase() === protocol.value.toLowerCase(),
52
- label: protocol.label,
53
- onChange: function onChange() {
54
- return updateProtocol(protocol.value);
55
- },
56
- labelStyle: {
57
- marginBottom: 2,
58
- fontSize: 16,
59
- lineHeight: '18px'
60
- }
61
- })
62
- }, protocol.value);
63
- })
64
- })]
65
- });
66
- };
67
- var renderVideoResolution = function renderVideoResolution() {
68
- var resolutionSelectProps = {
69
- title: i18n('preuploadVideoResolutionTitle'),
70
- options: videoTranscodingOptions.resolutions,
71
- value: videoTranscoding.resolution,
72
- onChange: function onChange(resolution) {
73
- return updateVideoTranscoding({
74
- resolution: resolution
75
- });
76
- },
77
- description: i18n('preuploadVideoResolutionText'),
78
- disabled: !isVideoProcessActive
79
- };
80
- return /*#__PURE__*/_jsx(ProcessSelect, _objectSpread({}, resolutionSelectProps));
81
- };
82
- return /*#__PURE__*/_jsxs(Styled.SettingsContainer, {
83
- children: [/*#__PURE__*/_jsx(Styled.UploadProcessorTitle, {
84
- children: i18n('preuploadOptimizeVideoTitle')
85
- }), /*#__PURE__*/_jsx(ProcessorToggle, {
86
- toggleText: i18n('preuploadOptimizeVideoSubTitle'),
87
- tooltipText: i18n('preuploadQuickUploadModeHint'),
88
- isProcessActive: isVideoProcessActive,
89
- toggleProcessor: toggleVideoProcessor
90
- }), /*#__PURE__*/_jsxs(Styled.OperationsContainer, {
91
- children: [renderVideoResolution(), renderVideoProtocols()]
92
- })]
93
- });
94
- };
95
- export default VideoProcessor;
@@ -1,27 +0,0 @@
1
- export default {
2
- preuploadUploadSettingsLabel: 'Upload Settings',
3
- preuploadQuickUploadModeLabel: 'Quick upload mode',
4
- preuploadQuickUploadModeHint: 'In quick mode, the file is send, but the file is still in being processed and will not be visible in the Filerobot infra before its finished. Its useful for uploading big files to not have freezing behaviour',
5
- preuploadOptimizeImagesLabel: 'Optimize image(s)',
6
- preuploadImageOperationLabel: 'Operation',
7
- preuploadImageOperationText: 'Operation that is being applied automatically before passing the image to uploading stage',
8
- preuploadTranscodeLabel: 'Transcode video(s)',
9
- preuploadVideoResolutionTitle: 'Resolution',
10
- preuploadVideoResolutionText: 'The resolution of video transcoding',
11
- preuploadProtocolsText: 'Protocols',
12
- preuploadMaxWidth: 'Max Width',
13
- preuploadMaxHeight: 'Max Height',
14
- preuploadOptimizeImagesTitle: 'Image settings',
15
- preuploadOptimizeImagesSubTitle: 'Resize Images',
16
- preuploadOptimizeVideoTitle: 'Video settings',
17
- preuploadOptimizeVideoSubTitle: 'Transcode video',
18
- preuploadResumableUploadTitle: 'Resumable upload',
19
- preuploadAssetsTransformationsLabel: 'Transformations',
20
- preuploadAssetsTransformationsHint: 'Transformations are dynamically created variants based on image presets.',
21
- preuploadAssetsTransformationsPresetsLabel: 'Presets',
22
- preuploadAssetsTransformationsPresetPlaceholder: 'Select preset',
23
- preuploadAssetsTransformationsPresetShowMore: 'more',
24
- preuploadResumableUploadInfo: '(experimental feature) Resumable file transfer protocol designed to ensure smooth and efficient file uploads. Adds the functionality to pause and resume upload, optimizing data delivery for a seamless experience.',
25
- preuploadResumableUploadBetaTitle: 'Beta',
26
- preuploadResumableUploadBetaMsg: 'This functionality is in Beta and may not work in all cases until official release'
27
- };
package/lib/index.js DELETED
@@ -1,175 +0,0 @@
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 _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
- 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; }
4
- 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; }
5
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
6
- 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); } }
7
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
- 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); }
10
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
11
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
13
- 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); }
14
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
15
- 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; }
16
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
- 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); }
18
- import { createElement } from 'react';
19
- import { Plugin } from '@scaleflex/widget-core';
20
- import Translator from '@scaleflex/widget-utils/lib/Translator';
21
- import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
22
- import defaultLocale from './defaultLocale';
23
- import DEFAULT_VIDEO_TRANSCODING from './DEFAULT_VIDEO_TRANSCODING';
24
- import ProcessorsUI from './components/ProcessorsUI';
25
- import preUploadProcessorsReducer, { preUpProcessorsCommonStateUpdated, selectPreUpProcessorsCommonState } from './common.slice';
26
- var PreUploadProcessors = /*#__PURE__*/function (_Plugin) {
27
- function PreUploadProcessors(filerobot) {
28
- var _this;
29
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30
- _classCallCheck(this, PreUploadProcessors);
31
- _this = _callSuper(this, PreUploadProcessors, [filerobot, opts]);
32
- _defineProperty(_this, "_pluginObject", void 0);
33
- _defineProperty(_this, "triggerImageProcessor", function (filesIds) {
34
- var _selectPreUpProcessor = selectPreUpProcessorsCommonState(_this.getGlobalState()),
35
- imageOperation = _selectPreUpProcessor.imageOperation,
36
- isImageProcessActive = _selectPreUpProcessor.isImageProcessActive,
37
- isUserAllowedToOptimize = _selectPreUpProcessor.isUserAllowedToOptimize;
38
- _this.filerobot.setCoreCommonState({
39
- imageProcessor: _objectSpread(_objectSpread({}, imageOperation), {}, {
40
- isImageProcessActive: isImageProcessActive,
41
- isUserAllowedToOptimize: isUserAllowedToOptimize,
42
- filesIds: filesIds
43
- })
44
- });
45
- });
46
- _defineProperty(_this, "triggerVideoProcessor", function (filesIds) {
47
- var _selectPreUpProcessor2 = selectPreUpProcessorsCommonState(_this.getGlobalState()),
48
- videoTranscoding = _selectPreUpProcessor2.videoTranscoding,
49
- isUserAllowedToOptimize = _selectPreUpProcessor2.isUserAllowedToOptimize,
50
- isVideoProcessActive = _selectPreUpProcessor2.isVideoProcessActive;
51
- _this.filerobot.setCoreCommonState({
52
- videoTranscoding: _objectSpread(_objectSpread({}, videoTranscoding), {}, {
53
- isUserAllowedToOptimize: isUserAllowedToOptimize,
54
- isVideoProcessActive: isVideoProcessActive,
55
- filesIds: filesIds
56
- })
57
- });
58
- });
59
- _defineProperty(_this, "resetState", function () {
60
- _this.dispatch(preUpProcessorsCommonStateUpdated(_this.defaultPluginState));
61
- });
62
- _this.id = PLUGINS_IDS.PREUPLOAD_PROCESSORS;
63
- _this.type = 'modifier';
64
- _this.invisible = false;
65
- _this.defaultLocale = {
66
- strings: defaultLocale
67
- };
68
- var defaultOptions = {
69
- imageProcessorByDefault: false,
70
- videoProcessorByDefault: false,
71
- imageOperations: null,
72
- videoTranscodingOptions: DEFAULT_VIDEO_TRANSCODING
73
- };
74
- _this.getPluginObject = _this.getPluginObject.bind(_this);
75
- _this.areThereOperations = _this.areThereOperations.bind(_this);
76
- _this.render = _this.render.bind(_this);
77
- _this.i18nInit();
78
- _this.opts = _extends({}, defaultOptions, opts);
79
- _this.handleProcess = _this.handleProcess.bind(_this);
80
- return _this;
81
- }
82
- _inherits(PreUploadProcessors, _Plugin);
83
- return _createClass(PreUploadProcessors, [{
84
- key: "i18nInit",
85
- value: function i18nInit() {
86
- this.translator = new Translator([this.defaultLocale, this.filerobot.locale, this.opts.locale]);
87
- this.i18n = this.translator.translate.bind(this.translator);
88
- }
89
- }, {
90
- key: "handleProcess",
91
- value: function handleProcess(filesIds) {
92
- filesIds = filesIds.filter(function (file) {
93
- return !file.error;
94
- });
95
- this.triggerImageProcessor(filesIds);
96
- this.triggerVideoProcessor(filesIds);
97
- }
98
- }, {
99
- key: "areThereOperations",
100
- value: function areThereOperations() {
101
- return this.opts.imageOperations && Object.keys(this.opts.imageOperations).length > 0;
102
- }
103
- }, {
104
- key: "getPluginObject",
105
- value: function getPluginObject() {
106
- if (!this._pluginObject) {
107
- this._pluginObject = {
108
- render: this.render,
109
- process: this.handleProcess
110
- };
111
- }
112
- return this._pluginObject;
113
- }
114
- }, {
115
- key: "getOperationOptionsFirstValues",
116
- value: function getOperationOptionsFirstValues(operation) {
117
- var optionValues = {};
118
- Object.keys(operation).forEach(function (optionKey) {
119
- optionValues[optionKey] = operation[optionKey];
120
- });
121
- return optionValues;
122
- }
123
- }, {
124
- key: "install",
125
- value: function install() {
126
- if (this.areThereOperations()) {
127
- this.filerobot.addPreProcessor(this.getPluginObject());
128
- var firstOperationKey = Object.keys(this.opts.imageOperations)[0];
129
- this.defaultPluginState = {
130
- imageOperation: {
131
- name: firstOperationKey,
132
- values: this.getOperationOptionsFirstValues(this.opts.imageOperations[firstOperationKey]),
133
- isRatioLocked: true
134
- },
135
- videoTranscoding: {
136
- resolution: this.opts.videoTranscodingOptions.defaultResolution,
137
- protocol: this.opts.videoTranscodingOptions.defaultProtocol
138
- },
139
- isImageProcessActive: this.opts.imageProcessorByDefault,
140
- isUserAllowedToOptimize: this.opts.imageProcessorUserAllowance,
141
- isVideoProcessActive: this.opts.videoProcessorByDefault
142
- };
143
- this.resetState();
144
- this.filerobot.on('cancel-uploads', this.resetState);
145
- }
146
- }
147
- }, {
148
- key: "uninstall",
149
- value: function uninstall() {
150
- this.filerobot.removePreProcessor(this.getPluginObject());
151
- this.filerobot.off('cancel-uploads', this.resetState);
152
- }
153
- }, {
154
- key: "getPluginReducer",
155
- value: function getPluginReducer() {
156
- return preUploadProcessorsReducer;
157
- }
158
- }, {
159
- key: "render",
160
- value: function render(_state) {
161
- if (_state.autoProceed) {
162
- return null;
163
- }
164
- if (this.areThereOperations()) {
165
- // we're using createElement here as ProcessorsUI contains react's hooks and we need this to be considered as react component
166
-
167
- return /*#__PURE__*/createElement(ProcessorsUI, {
168
- i18n: this.i18n,
169
- pluginOpts: this.opts
170
- });
171
- }
172
- }
173
- }]);
174
- }(Plugin);
175
- export default PreUploadProcessors;