cozy-viewer 2.0.3 → 2.1.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 +11 -0
- package/dist/ViewerContainer.js +3 -3
- package/dist/components/Toolbar.js +3 -3
- package/dist/components/ViewerByFile.js +3 -3
- package/package.json +6 -6
- package/src/Footer/ForwardButton.spec.jsx +1 -1
- package/src/NoViewer/NoViewer.spec.jsx +1 -1
- package/src/Readme.md +1 -1
- package/src/ViewerContainer.jsx +1 -1
- package/src/ViewersByFile/AudioViewer.spec.jsx +1 -1
- package/src/ViewersByFile/ImageViewer.spec.jsx +2 -2
- package/src/ViewersByFile/PdfMobileViewer.spec.jsx +1 -1
- package/src/ViewersByFile/VideoViewer.spec.jsx +1 -1
- package/src/components/Toolbar.jsx +1 -1
- package/src/components/ViewerByFile.jsx +1 -1
- package/src/components/ViewerControls.spec.jsx +1 -1
- package/dist/providers/EncryptedProvider.d.ts +0 -8
- package/dist/providers/EncryptedProvider.js +0 -43
- package/src/providers/EncryptedProvider.jsx +0 -25
- /package/dist/{docs → providers}/DemoProvider.d.ts +0 -0
- /package/dist/{docs → providers}/DemoProvider.js +0 -0
- /package/src/{docs → providers}/DemoProvider.jsx +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
# 2.1.0 (2024-10-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **Viewer:** Replace Encrypted provider by cozy-ui one ([aa81d02](https://github.com/cozy/cozy-libs/commit/aa81d02f0a70de8044f704cbd895b1d54c9f38b8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 2.0.3 (2024-10-23)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package cozy-viewer
|
package/dist/ViewerContainer.js
CHANGED
|
@@ -29,6 +29,8 @@ var _Breakpoints = _interopRequireDefault(require("cozy-ui/transpiled/react/prov
|
|
|
29
29
|
|
|
30
30
|
var _CozyTheme = require("cozy-ui/transpiled/react/providers/CozyTheme");
|
|
31
31
|
|
|
32
|
+
var _Encrypted = _interopRequireDefault(require("cozy-ui/transpiled/react/providers/Encrypted"));
|
|
33
|
+
|
|
32
34
|
var _I18n = require("cozy-ui/transpiled/react/providers/I18n");
|
|
33
35
|
|
|
34
36
|
var _Viewer = _interopRequireDefault(require("./Viewer"));
|
|
@@ -43,8 +45,6 @@ var _proptypes2 = require("./proptypes");
|
|
|
43
45
|
|
|
44
46
|
var _ActionMenuProvider = require("./providers/ActionMenuProvider");
|
|
45
47
|
|
|
46
|
-
var _EncryptedProvider = _interopRequireDefault(require("./providers/EncryptedProvider"));
|
|
47
|
-
|
|
48
48
|
var _excluded = ["className", "disableFooter", "disablePanel", "editPathByModelProps", "children", "componentsProps", "isPublic"],
|
|
49
49
|
_excluded2 = ["disableModal"];
|
|
50
50
|
|
|
@@ -99,7 +99,7 @@ var ViewerContainer = function ViewerContainer(props) {
|
|
|
99
99
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
100
100
|
id: "viewer-wrapper",
|
|
101
101
|
className: (0, _classnames.default)(styles['viewer-wrapper'], className)
|
|
102
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
102
|
+
}, /*#__PURE__*/_react.default.createElement(_Encrypted.default, {
|
|
103
103
|
url: currentURL
|
|
104
104
|
}, /*#__PURE__*/_react.default.createElement(_Viewer.default, (0, _extends2.default)({}, rest, {
|
|
105
105
|
componentsProps: componentsPropsWithDefault,
|
|
@@ -35,6 +35,8 @@ var _Typography = _interopRequireDefault(require("cozy-ui/transpiled/react/Typog
|
|
|
35
35
|
|
|
36
36
|
var _withBreakpoints = _interopRequireDefault(require("cozy-ui/transpiled/react/helpers/withBreakpoints"));
|
|
37
37
|
|
|
38
|
+
var _Encrypted = require("cozy-ui/transpiled/react/providers/Encrypted");
|
|
39
|
+
|
|
38
40
|
var _I18n = require("cozy-ui/transpiled/react/providers/I18n");
|
|
39
41
|
|
|
40
42
|
var _styles = require("cozy-ui/transpiled/react/styles");
|
|
@@ -45,8 +47,6 @@ var _ToolbarFilePath = require("./ToolbarFilePath");
|
|
|
45
47
|
|
|
46
48
|
var _helpers = require("../Footer/helpers");
|
|
47
49
|
|
|
48
|
-
var _EncryptedProvider = require("../providers/EncryptedProvider");
|
|
49
|
-
|
|
50
50
|
var styles = {
|
|
51
51
|
"viewer-nav": "styles__viewer-nav___3V03k",
|
|
52
52
|
"viewer-nav--visible": "styles__viewer-nav--visible___4GLTe",
|
|
@@ -86,7 +86,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
86
86
|
|
|
87
87
|
var webviewIntent = (0, _cozyIntent.useWebviewIntent)();
|
|
88
88
|
|
|
89
|
-
var _useEncrypted = (0,
|
|
89
|
+
var _useEncrypted = (0, _Encrypted.useEncrypted)(),
|
|
90
90
|
url = _useEncrypted.url;
|
|
91
91
|
|
|
92
92
|
var ToolbarButtons = (0, _helpers.extractChildrenCompByName)({
|
|
@@ -19,6 +19,8 @@ var _withBreakpoints = _interopRequireDefault(require("cozy-ui/transpiled/react/
|
|
|
19
19
|
|
|
20
20
|
var _proptypes = require("cozy-ui/transpiled/react/proptypes");
|
|
21
21
|
|
|
22
|
+
var _Encrypted = require("cozy-ui/transpiled/react/providers/Encrypted");
|
|
23
|
+
|
|
22
24
|
var _NoViewer = _interopRequireDefault(require("../NoViewer"));
|
|
23
25
|
|
|
24
26
|
var _AudioViewer = _interopRequireDefault(require("../ViewersByFile/AudioViewer"));
|
|
@@ -39,8 +41,6 @@ var _TextViewer = _interopRequireDefault(require("../ViewersByFile/TextViewer"))
|
|
|
39
41
|
|
|
40
42
|
var _VideoViewer = _interopRequireDefault(require("../ViewersByFile/VideoViewer"));
|
|
41
43
|
|
|
42
|
-
var _EncryptedProvider = require("../providers/EncryptedProvider");
|
|
43
|
-
|
|
44
44
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
45
|
|
|
46
46
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -101,7 +101,7 @@ var ViewerByFile = (0, _withBreakpoints.default)()(function (_ref2) {
|
|
|
101
101
|
var isOnlyOfficeEnabled = componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$Only = componentsProps.OnlyOfficeViewer) === null || _componentsProps$Only === void 0 ? void 0 : _componentsProps$Only.isEnabled;
|
|
102
102
|
var onlyOfficeOpener = componentsProps === null || componentsProps === void 0 ? void 0 : (_componentsProps$Only2 = componentsProps.OnlyOfficeViewer) === null || _componentsProps$Only2 === void 0 ? void 0 : _componentsProps$Only2.opener;
|
|
103
103
|
|
|
104
|
-
var _useEncrypted = (0,
|
|
104
|
+
var _useEncrypted = (0, _Encrypted.useEncrypted)(),
|
|
105
105
|
url = _useEncrypted.url;
|
|
106
106
|
|
|
107
107
|
var ComponentName = (0, _react.useMemo)(function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-viewer",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Cozy-Viewer provides a component to show files in a viewer.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"@testing-library/react": "11.2.7",
|
|
25
25
|
"@testing-library/react-hooks": "^3.2.1",
|
|
26
26
|
"babel-plugin-inline-json-import": "0.3.2",
|
|
27
|
-
"babel-preset-cozy-app": "^2.
|
|
27
|
+
"babel-preset-cozy-app": "^2.3.0",
|
|
28
28
|
"cozy-client": "48.8.0",
|
|
29
29
|
"cozy-device-helper": "2.0.0",
|
|
30
30
|
"cozy-harvest-lib": "^6.7.3",
|
|
31
31
|
"cozy-intent": "^1.16.1",
|
|
32
|
-
"cozy-logger": "^1.
|
|
32
|
+
"cozy-logger": "^1.11.0",
|
|
33
33
|
"cozy-sharing": "14.1.0",
|
|
34
|
-
"cozy-ui": "^
|
|
34
|
+
"cozy-ui": "^112.0.0",
|
|
35
35
|
"enzyme": "3.11.0",
|
|
36
36
|
"enzyme-adapter-react-16": "1.15.6",
|
|
37
37
|
"enzyme-to-json": "3.6.2",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"cozy-intent": ">=1.16.1",
|
|
57
57
|
"cozy-logger": ">=1.9.0",
|
|
58
58
|
"cozy-sharing": ">=14.1.0",
|
|
59
|
-
"cozy-ui": ">=
|
|
59
|
+
"cozy-ui": ">=112.0.0",
|
|
60
60
|
"react": ">=16.12.0",
|
|
61
61
|
"react-dom": ">=16.12.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "30c23cd07bf3c50a8627fb291c62cc4007d0908a"
|
|
64
64
|
}
|
|
@@ -6,7 +6,7 @@ import { isMobileApp } from 'cozy-device-helper'
|
|
|
6
6
|
|
|
7
7
|
import ForwardButton from './ForwardButton'
|
|
8
8
|
import { exportFilesNative } from './helpers'
|
|
9
|
-
import DemoProvider from '../
|
|
9
|
+
import DemoProvider from '../providers/DemoProvider'
|
|
10
10
|
|
|
11
11
|
jest.mock('cozy-device-helper')
|
|
12
12
|
jest.mock('cozy-client/dist/models/sharing', () => ({
|
package/src/Readme.md
CHANGED
|
@@ -54,7 +54,7 @@ import { Media, Img, Bd } from 'cozy-ui/transpiled/react/deprecated/Media'
|
|
|
54
54
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
55
55
|
import CarbonCopyIcon from 'cozy-ui/transpiled/react/Icons/CarbonCopy'
|
|
56
56
|
// The DemoProvider inserts a fake cozy-client in the React context.
|
|
57
|
-
import DemoProvider from './
|
|
57
|
+
import DemoProvider from './providers/DemoProvider'
|
|
58
58
|
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
59
59
|
import DownloadIcon from 'cozy-ui/transpiled/react/Icons/Download'
|
|
60
60
|
import ShareIcon from 'cozy-ui/transpiled/react/Icons/Share'
|
package/src/ViewerContainer.jsx
CHANGED
|
@@ -7,6 +7,7 @@ import { FileDoctype } from 'cozy-ui/transpiled/react/proptypes'
|
|
|
7
7
|
import AlertProvider from 'cozy-ui/transpiled/react/providers/Alert'
|
|
8
8
|
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
|
|
9
9
|
import { useCozyTheme } from 'cozy-ui/transpiled/react/providers/CozyTheme'
|
|
10
|
+
import EncryptedProvider from 'cozy-ui/transpiled/react/providers/Encrypted'
|
|
10
11
|
import { useExtendI18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
11
12
|
|
|
12
13
|
import Viewer from './Viewer'
|
|
@@ -15,7 +16,6 @@ import { isValidForPanel } from './helpers'
|
|
|
15
16
|
import { locales } from './locales'
|
|
16
17
|
import { toolbarPropsPropType } from './proptypes'
|
|
17
18
|
import { ActionMenuProvider } from './providers/ActionMenuProvider'
|
|
18
|
-
import EncryptedProvider from './providers/EncryptedProvider'
|
|
19
19
|
import styles from './styles.styl'
|
|
20
20
|
|
|
21
21
|
const ViewerContainer = props => {
|
|
@@ -4,7 +4,7 @@ import React from 'react'
|
|
|
4
4
|
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
|
|
5
5
|
|
|
6
6
|
import AudioViewer from './AudioViewer'
|
|
7
|
-
import DemoProvider from '../
|
|
7
|
+
import DemoProvider from '../providers/DemoProvider'
|
|
8
8
|
|
|
9
9
|
const file = {
|
|
10
10
|
_id: 'audio',
|
|
@@ -3,10 +3,10 @@ import React from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { checkImageSource } from 'cozy-ui/transpiled/react/FileImageLoader/checkImageSource'
|
|
5
5
|
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
|
|
6
|
+
import EncryptedProvider from 'cozy-ui/transpiled/react/providers/Encrypted'
|
|
6
7
|
|
|
7
8
|
import ImageViewer from './ImageViewer'
|
|
8
|
-
import DemoProvider from '../
|
|
9
|
-
import EncryptedProvider from '../providers/EncryptedProvider'
|
|
9
|
+
import DemoProvider from '../providers/DemoProvider'
|
|
10
10
|
|
|
11
11
|
jest.mock('cozy-ui/transpiled/react/FileImageLoader/checkImageSource', () => ({
|
|
12
12
|
...jest.requireActual(
|
|
@@ -3,10 +3,10 @@ import React from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { CozyProvider, createMockClient } from 'cozy-client'
|
|
5
5
|
import logger from 'cozy-logger'
|
|
6
|
+
import EncryptedProvider from 'cozy-ui/transpiled/react/providers/Encrypted'
|
|
6
7
|
import { I18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
7
8
|
|
|
8
9
|
import { PdfMobileViewer } from './PdfMobileViewer'
|
|
9
|
-
import EncryptedProvider from '../providers/EncryptedProvider'
|
|
10
10
|
|
|
11
11
|
logger.error = logger.warn = jest.fn()
|
|
12
12
|
|
|
@@ -4,7 +4,7 @@ import React from 'react'
|
|
|
4
4
|
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
|
|
5
5
|
|
|
6
6
|
import VideoViewer from './VideoViewer'
|
|
7
|
-
import DemoProvider from '../
|
|
7
|
+
import DemoProvider from '../providers/DemoProvider'
|
|
8
8
|
|
|
9
9
|
const file = {
|
|
10
10
|
_id: 'video',
|
|
@@ -12,6 +12,7 @@ import PreviousIcon from 'cozy-ui/transpiled/react/Icons/Previous'
|
|
|
12
12
|
import MidEllipsis from 'cozy-ui/transpiled/react/MidEllipsis'
|
|
13
13
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
14
14
|
import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints'
|
|
15
|
+
import { useEncrypted } from 'cozy-ui/transpiled/react/providers/Encrypted'
|
|
15
16
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
16
17
|
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
|
|
17
18
|
|
|
@@ -19,7 +20,6 @@ import PrintButton from './PrintButton'
|
|
|
19
20
|
import { ToolbarFilePath } from './ToolbarFilePath'
|
|
20
21
|
import styles from './styles.styl'
|
|
21
22
|
import { extractChildrenCompByName } from '../Footer/helpers'
|
|
22
|
-
import { useEncrypted } from '../providers/EncryptedProvider'
|
|
23
23
|
|
|
24
24
|
const useClasses = makeStyles(theme => ({
|
|
25
25
|
iconButton: {
|
|
@@ -5,6 +5,7 @@ import { isPlainText } from 'cozy-client/dist/models/file'
|
|
|
5
5
|
import { isMobile as isMobileDevice } from 'cozy-device-helper'
|
|
6
6
|
import withBreakpoints from 'cozy-ui/transpiled/react/helpers/withBreakpoints'
|
|
7
7
|
import { FileDoctype } from 'cozy-ui/transpiled/react/proptypes'
|
|
8
|
+
import { useEncrypted } from 'cozy-ui/transpiled/react/providers/Encrypted'
|
|
8
9
|
|
|
9
10
|
import NoViewer from '../NoViewer'
|
|
10
11
|
import AudioViewer from '../ViewersByFile/AudioViewer'
|
|
@@ -16,7 +17,6 @@ import PdfMobileViewer from '../ViewersByFile/PdfMobileViewer'
|
|
|
16
17
|
import ShortcutViewer from '../ViewersByFile/ShortcutViewer'
|
|
17
18
|
import TextViewer from '../ViewersByFile/TextViewer'
|
|
18
19
|
import VideoViewer from '../ViewersByFile/VideoViewer'
|
|
19
|
-
import { useEncrypted } from '../providers/EncryptedProvider'
|
|
20
20
|
|
|
21
21
|
const isBlankPaper = doc => doc.metadata?.paperProps?.isBlank
|
|
22
22
|
|
|
@@ -5,7 +5,7 @@ import ViewerByFile from './ViewerByFile'
|
|
|
5
5
|
import ViewerControls from './ViewerControls'
|
|
6
6
|
|
|
7
7
|
jest.mock('../ViewersByFile/AudioViewer', () => () => <div>AudioViewer</div>)
|
|
8
|
-
jest.mock('
|
|
8
|
+
jest.mock('cozy-ui/transpiled/react/providers/Encrypted', () => ({
|
|
9
9
|
useEncrypted: () => ({ url: 'random' })
|
|
10
10
|
}))
|
|
11
11
|
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export const EncryptedContext: React.Context<any>;
|
|
2
|
-
export function useEncrypted(): any;
|
|
3
|
-
declare var _default: React.MemoExoticComponent<({ url, children }: {
|
|
4
|
-
url: any;
|
|
5
|
-
children: any;
|
|
6
|
-
}) => JSX.Element>;
|
|
7
|
-
export default _default;
|
|
8
|
-
import React from "react";
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useEncrypted = exports.default = exports.EncryptedContext = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
-
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
|
|
14
|
-
var EncryptedContext = /*#__PURE__*/_react.default.createContext();
|
|
15
|
-
|
|
16
|
-
exports.EncryptedContext = EncryptedContext;
|
|
17
|
-
|
|
18
|
-
var useEncrypted = function useEncrypted() {
|
|
19
|
-
var context = (0, _react.useContext)(EncryptedContext);
|
|
20
|
-
|
|
21
|
-
if (!context) {
|
|
22
|
-
throw new Error('useEncrypted must be used within a EncryptedProvider');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return context;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
exports.useEncrypted = useEncrypted;
|
|
29
|
-
|
|
30
|
-
var EncryptedProvider = function EncryptedProvider(_ref) {
|
|
31
|
-
var url = _ref.url,
|
|
32
|
-
children = _ref.children;
|
|
33
|
-
var contextValue = {
|
|
34
|
-
url: url
|
|
35
|
-
};
|
|
36
|
-
return /*#__PURE__*/_react.default.createElement(EncryptedContext.Provider, {
|
|
37
|
-
value: contextValue
|
|
38
|
-
}, children);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
var _default = /*#__PURE__*/_react.default.memo(EncryptedProvider);
|
|
42
|
-
|
|
43
|
-
exports.default = _default;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react'
|
|
2
|
-
|
|
3
|
-
export const EncryptedContext = React.createContext()
|
|
4
|
-
|
|
5
|
-
export const useEncrypted = () => {
|
|
6
|
-
const context = useContext(EncryptedContext)
|
|
7
|
-
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error('useEncrypted must be used within a EncryptedProvider')
|
|
10
|
-
}
|
|
11
|
-
return context
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const EncryptedProvider = ({ url, children }) => {
|
|
15
|
-
const contextValue = {
|
|
16
|
-
url
|
|
17
|
-
}
|
|
18
|
-
return (
|
|
19
|
-
<EncryptedContext.Provider value={contextValue}>
|
|
20
|
-
{children}
|
|
21
|
-
</EncryptedContext.Provider>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default React.memo(EncryptedProvider)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|