@atlaskit/media-file-preview 0.5.2 → 0.7.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 +50 -34
- package/LICENSE.md +6 -8
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/useFilePreview.js +2 -2
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/useFilePreview.js +2 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/useFilePreview.js +2 -2
- package/dist/types/analytics.d.ts +4 -4
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/getPreview/cache.d.ts +3 -3
- package/dist/types/getPreview/getPreview.d.ts +3 -3
- package/dist/types/getPreview/helpers.d.ts +3 -3
- package/dist/types/getPreview/objectURLCache.d.ts +1 -1
- package/dist/types/globalScope/getSSRData.d.ts +1 -1
- package/dist/types/globalScope/globalScope.d.ts +5 -5
- package/dist/types/globalScope/types.d.ts +2 -2
- package/dist/types/helpers.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/useFilePreview.d.ts +4 -4
- package/dist/types/useMediaImage.d.ts +3 -3
- package/dist/types-ts4.5/analytics.d.ts +4 -4
- package/dist/types-ts4.5/errors.d.ts +2 -2
- package/dist/types-ts4.5/getPreview/cache.d.ts +3 -3
- package/dist/types-ts4.5/getPreview/getPreview.d.ts +3 -3
- package/dist/types-ts4.5/getPreview/helpers.d.ts +3 -3
- package/dist/types-ts4.5/getPreview/objectURLCache.d.ts +1 -1
- package/dist/types-ts4.5/globalScope/getSSRData.d.ts +1 -1
- package/dist/types-ts4.5/globalScope/globalScope.d.ts +5 -5
- package/dist/types-ts4.5/globalScope/types.d.ts +2 -2
- package/dist/types-ts4.5/helpers.d.ts +2 -2
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/useFilePreview.d.ts +4 -4
- package/dist/types-ts4.5/useMediaImage.d.ts +3 -3
- package/example-helpers/TerminalTextDisplay.tsx +31 -21
- package/package.json +99 -99
package/CHANGELOG.md
CHANGED
|
@@ -1,93 +1,109 @@
|
|
|
1
1
|
# @atlaskit/media-file-preview
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#130406](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/130406)
|
|
8
|
+
[`2132e67c92d0f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2132e67c92d0f) -
|
|
9
|
+
Updates media-file-preview to support React 18
|
|
10
|
+
|
|
11
|
+
## 0.6.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#118216](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/118216)
|
|
16
|
+
[`b2f8064faf92d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b2f8064faf92d) -
|
|
17
|
+
Added new export for verifying MediaFilePreviewError type
|
|
18
|
+
|
|
3
19
|
## 0.5.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
6
22
|
|
|
7
|
-
-
|
|
23
|
+
- Updated dependencies
|
|
8
24
|
|
|
9
25
|
## 0.5.1
|
|
10
26
|
|
|
11
27
|
### Patch Changes
|
|
12
28
|
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
- [#83116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83116)
|
|
30
|
+
[`8d4e99057fe0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d4e99057fe0) -
|
|
31
|
+
Upgrade Typescript from `4.9.5` to `5.4.2`
|
|
16
32
|
|
|
17
33
|
## 0.5.0
|
|
18
34
|
|
|
19
35
|
### Minor Changes
|
|
20
36
|
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
37
|
+
- [#73279](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/73279)
|
|
38
|
+
[`cdad00f21119`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cdad00f21119) -
|
|
39
|
+
Create useMediaImage hook
|
|
24
40
|
|
|
25
41
|
## 0.4.2
|
|
26
42
|
|
|
27
43
|
### Patch Changes
|
|
28
44
|
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
- [#71793](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71793)
|
|
46
|
+
[`26115be71855`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/26115be71855) -
|
|
47
|
+
Added support for Error File State
|
|
32
48
|
|
|
33
49
|
## 0.4.1
|
|
34
50
|
|
|
35
51
|
### Patch Changes
|
|
36
52
|
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
|
|
53
|
+
- [#71409](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71409)
|
|
54
|
+
[`5c76dfba92dd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c76dfba92dd) -
|
|
55
|
+
Pass trace context to global scope error
|
|
40
56
|
|
|
41
57
|
## 0.4.0
|
|
42
58
|
|
|
43
59
|
### Minor Changes
|
|
44
60
|
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
- [#70446](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70446)
|
|
62
|
+
[`48eae199c6fa`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/48eae199c6fa) -
|
|
63
|
+
Breaking: return ref object ssrReliabilityRef is replaced by object ssrReliability
|
|
48
64
|
|
|
49
65
|
### Patch Changes
|
|
50
66
|
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
- [#70446](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70446)
|
|
68
|
+
[`0ff07ca94009`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0ff07ca94009) -
|
|
69
|
+
Better support for onImageError callback
|
|
54
70
|
|
|
55
71
|
## 0.3.1
|
|
56
72
|
|
|
57
73
|
### Patch Changes
|
|
58
74
|
|
|
59
|
-
-
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
- [#70361](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70361)
|
|
76
|
+
[`6bcee8c57dac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6bcee8c57dac) -
|
|
77
|
+
Support for files failed to process
|
|
62
78
|
|
|
63
79
|
## 0.3.0
|
|
64
80
|
|
|
65
81
|
### Minor Changes
|
|
66
82
|
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
- [#70034](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70034)
|
|
84
|
+
[`0cf829b2ca1f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0cf829b2ca1f) -
|
|
85
|
+
Breaking: renamed return value from getScriptProps to getSsrScriptProps
|
|
70
86
|
|
|
71
87
|
## 0.2.1
|
|
72
88
|
|
|
73
89
|
### Patch Changes
|
|
74
90
|
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
|
|
91
|
+
- [#69372](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69372)
|
|
92
|
+
[`d719e8e81e2c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d719e8e81e2c) -
|
|
93
|
+
Fixed status for processed files with no preview
|
|
78
94
|
|
|
79
95
|
## 0.2.0
|
|
80
96
|
|
|
81
97
|
### Minor Changes
|
|
82
98
|
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
- [#65817](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65817)
|
|
100
|
+
[`de45ff7a33a9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/de45ff7a33a9) -
|
|
101
|
+
Breaking: removed previewDidRender property
|
|
86
102
|
|
|
87
103
|
## 0.1.0
|
|
88
104
|
|
|
89
105
|
### Minor Changes
|
|
90
106
|
|
|
91
|
-
-
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
- [#65749](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65749)
|
|
108
|
+
[`cf9674e67f0c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cf9674e67f0c) -
|
|
109
|
+
Breaking: updated prop types
|
package/LICENSE.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
Copyright 2023 Atlassian Pty Ltd
|
|
2
2
|
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
|
|
5
|
-
You may obtain a copy of the License at
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
|
4
|
+
compliance with the License. You may obtain a copy of the License at
|
|
6
5
|
|
|
7
6
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
7
|
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
distributed
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
limitations under the License.
|
|
8
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
|
9
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
10
|
+
implied. See the License for the specific language governing permissions and limitations under the
|
|
11
|
+
License.
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "isMediaFilePreviewError", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _errors.isMediaFilePreviewError;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "useFilePreview", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -16,4 +22,5 @@ Object.defineProperty(exports, "useMediaImage", {
|
|
|
16
22
|
}
|
|
17
23
|
});
|
|
18
24
|
var _useFilePreview = require("./useFilePreview");
|
|
19
|
-
var _useMediaImage = require("./useMediaImage");
|
|
25
|
+
var _useMediaImage = require("./useMediaImage");
|
|
26
|
+
var _errors = require("./errors");
|
|
@@ -274,8 +274,8 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
/*
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
If the image loads successfully and it comes from server (global scope / ssrData), it means that we have reused it in client and the success counts for both: server & client.
|
|
278
|
+
*/
|
|
279
279
|
|
|
280
280
|
if ((0, _getPreview.isSSRDataPreview)(newPreview) && ssrReliabilityRef.current.server.status === 'unknown') {
|
|
281
281
|
ssrReliabilityRef.current.server = {
|
package/dist/es2019/index.js
CHANGED
|
@@ -248,8 +248,8 @@ export const useFilePreview = ({
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
/*
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
If the image loads successfully and it comes from server (global scope / ssrData), it means that we have reused it in client and the success counts for both: server & client.
|
|
252
|
+
*/
|
|
253
253
|
|
|
254
254
|
if (isSSRDataPreview(newPreview) && ssrReliabilityRef.current.server.status === 'unknown') {
|
|
255
255
|
ssrReliabilityRef.current.server = {
|
package/dist/esm/index.js
CHANGED
|
@@ -267,8 +267,8 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
/*
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
If the image loads successfully and it comes from server (global scope / ssrData), it means that we have reused it in client and the success counts for both: server & client.
|
|
271
|
+
*/
|
|
272
272
|
|
|
273
273
|
if (isSSRDataPreview(newPreview) && ssrReliabilityRef.current.server.status === 'unknown') {
|
|
274
274
|
ssrReliabilityRef.current.server = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MediaClientErrorReason } from '@atlaskit/media-client';
|
|
2
|
-
import { MediaTraceContext, SuccessAttributes } from '@atlaskit/media-common';
|
|
3
|
-
import { MediaFilePreviewError, MediaFilePreviewErrorPrimaryReason } from './errors';
|
|
4
|
-
import { MediaFilePreview } from './types';
|
|
1
|
+
import { type MediaClientErrorReason } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaTraceContext, type SuccessAttributes } from '@atlaskit/media-common';
|
|
3
|
+
import { type MediaFilePreviewError, type MediaFilePreviewErrorPrimaryReason } from './errors';
|
|
4
|
+
import { type MediaFilePreview } from './types';
|
|
5
5
|
export type FailedErrorFailReason = MediaFilePreviewErrorPrimaryReason | 'nativeError';
|
|
6
6
|
export type MediaFilePreviewErrorInfo = {
|
|
7
7
|
failReason: FailedErrorFailReason;
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MediaClientErrorReason } from '@atlaskit/media-client';
|
|
1
|
+
import { type MediaClientErrorReason } from '@atlaskit/media-client';
|
|
2
2
|
import { MediaFileStateError } from '@atlaskit/media-client-react';
|
|
3
|
-
import { MediaFilePreview } from './types';
|
|
3
|
+
import { type MediaFilePreview } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Primary reason is logged through Data Portal.
|
|
6
6
|
* Make sure all the values are whitelisted in Measure -> Event Regitry -> "mediaCardRender failed" event
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
-
import { MediaFilePreview } from '../types';
|
|
3
|
-
import { ObjectURLCache } from './objectURLCache';
|
|
1
|
+
import { type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaFilePreview } from '../types';
|
|
3
|
+
import { type ObjectURLCache } from './objectURLCache';
|
|
4
4
|
type Mode = MediaStoreGetFileImageParams['mode'] | undefined;
|
|
5
5
|
export declare const getCacheKey: (id: string, mode: Mode) => string;
|
|
6
6
|
export interface MediaFilePreviewCache {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FilePreview, MediaBlobUrlAttrs, MediaClient, MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
-
import { MediaTraceContext, SSR } from '@atlaskit/media-common';
|
|
3
|
-
import { MediaFilePreview, MediaFilePreviewDimensions } from '../types';
|
|
1
|
+
import { type FilePreview, type MediaBlobUrlAttrs, type MediaClient, type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaTraceContext, type SSR } from '@atlaskit/media-common';
|
|
3
|
+
import { type MediaFilePreview, type MediaFilePreviewDimensions } from '../types';
|
|
4
4
|
export declare const getSSRPreview: (ssr: SSR, mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs) => MediaFilePreview;
|
|
5
5
|
export declare const isLocalPreview: (preview: MediaFilePreview) => boolean;
|
|
6
6
|
export declare const isRemotePreview: (preview: MediaFilePreview) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FilePreview, MediaClient, MediaStoreGetFileImageParams, MediaType } from '@atlaskit/media-client';
|
|
2
|
-
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
-
import { MediaFilePreview } from '../types';
|
|
1
|
+
import { type FilePreview, type MediaClient, type MediaStoreGetFileImageParams, type MediaType } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
+
import { type MediaFilePreview } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* This method tells the support for the media
|
|
6
6
|
* types covered in getCardPreviewFromFilePreview
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FileIdentifier } from '@atlaskit/media-client';
|
|
3
|
-
import { NumericalCardDimensions } from '@atlaskit/media-common';
|
|
4
|
-
import { MediaFilePreviewErrorInfo } from '../analytics';
|
|
5
|
-
import { MediaCardSsr } from './types';
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type FileIdentifier } from '@atlaskit/media-client';
|
|
3
|
+
import { type NumericalCardDimensions } from '@atlaskit/media-common';
|
|
4
|
+
import { type MediaFilePreviewErrorInfo } from '../analytics';
|
|
5
|
+
import { type MediaCardSsr } from './types';
|
|
6
6
|
export declare const GLOBAL_MEDIA_CARD_SSR = "mediaCardSsr";
|
|
7
7
|
export declare const GLOBAL_MEDIA_NAMESPACE = "__MEDIA_INTERNAL";
|
|
8
8
|
export type MediaGlobalScope = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NumericalCardDimensions } from '@atlaskit/media-common';
|
|
2
|
-
import { MediaFilePreviewErrorInfo } from '../analytics';
|
|
1
|
+
import { type NumericalCardDimensions } from '@atlaskit/media-common';
|
|
2
|
+
import { type MediaFilePreviewErrorInfo } from '../analytics';
|
|
3
3
|
export type MediaCardSsrData = {
|
|
4
4
|
dataURI?: string;
|
|
5
5
|
dimensions?: Partial<NumericalCardDimensions>;
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MutableRefObject } from 'react';
|
|
2
|
-
import { MediaFilePreviewDimensions } from './types';
|
|
1
|
+
import { type MutableRefObject } from 'react';
|
|
2
|
+
import { type MediaFilePreviewDimensions } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Checks if at least one of next dimensions is bigger than current
|
|
5
5
|
* If a single dimension is undefined, returns false
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export type { UseFilePreviewParams } from './useFilePreview';
|
|
|
3
3
|
export { useMediaImage } from './useMediaImage';
|
|
4
4
|
export type { UseMediaImageParams } from './useMediaImage';
|
|
5
5
|
export type { MediaFilePreview } from './types';
|
|
6
|
+
export { isMediaFilePreviewError } from './errors';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { FileIdentifier, MediaBlobUrlAttrs, MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
-
import { MediaTraceContext, SSR } from '@atlaskit/media-common';
|
|
4
|
-
import { SSRStatus } from './analytics';
|
|
2
|
+
import { type FileIdentifier, type MediaBlobUrlAttrs, type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
+
import { type MediaTraceContext, type SSR } from '@atlaskit/media-common';
|
|
4
|
+
import { type SSRStatus } from './analytics';
|
|
5
5
|
import { MediaFilePreviewError } from './errors';
|
|
6
|
-
import { MediaFilePreview, MediaFilePreviewDimensions, MediaFilePreviewStatus } from './types';
|
|
6
|
+
import { type MediaFilePreview, type MediaFilePreviewDimensions, type MediaFilePreviewStatus } from './types';
|
|
7
7
|
export interface UseFilePreviewParams {
|
|
8
8
|
/** Instance of file identifier. */
|
|
9
9
|
readonly identifier: FileIdentifier;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { FileIdentifier, MediaBlobUrlAttrs, MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
-
import { MediaTraceContext, SSR } from '@atlaskit/media-common';
|
|
4
|
-
import { MediaFilePreviewDimensions } from './types';
|
|
2
|
+
import { type FileIdentifier, type MediaBlobUrlAttrs, type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
+
import { type MediaTraceContext, type SSR } from '@atlaskit/media-common';
|
|
4
|
+
import { type MediaFilePreviewDimensions } from './types';
|
|
5
5
|
export interface UseMediaImageParams {
|
|
6
6
|
/** Instance of file identifier. */
|
|
7
7
|
readonly identifier: FileIdentifier;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MediaClientErrorReason } from '@atlaskit/media-client';
|
|
2
|
-
import { MediaTraceContext, SuccessAttributes } from '@atlaskit/media-common';
|
|
3
|
-
import { MediaFilePreviewError, MediaFilePreviewErrorPrimaryReason } from './errors';
|
|
4
|
-
import { MediaFilePreview } from './types';
|
|
1
|
+
import { type MediaClientErrorReason } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaTraceContext, type SuccessAttributes } from '@atlaskit/media-common';
|
|
3
|
+
import { type MediaFilePreviewError, type MediaFilePreviewErrorPrimaryReason } from './errors';
|
|
4
|
+
import { type MediaFilePreview } from './types';
|
|
5
5
|
export type FailedErrorFailReason = MediaFilePreviewErrorPrimaryReason | 'nativeError';
|
|
6
6
|
export type MediaFilePreviewErrorInfo = {
|
|
7
7
|
failReason: FailedErrorFailReason;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MediaClientErrorReason } from '@atlaskit/media-client';
|
|
1
|
+
import { type MediaClientErrorReason } from '@atlaskit/media-client';
|
|
2
2
|
import { MediaFileStateError } from '@atlaskit/media-client-react';
|
|
3
|
-
import { MediaFilePreview } from './types';
|
|
3
|
+
import { type MediaFilePreview } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Primary reason is logged through Data Portal.
|
|
6
6
|
* Make sure all the values are whitelisted in Measure -> Event Regitry -> "mediaCardRender failed" event
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
-
import { MediaFilePreview } from '../types';
|
|
3
|
-
import { ObjectURLCache } from './objectURLCache';
|
|
1
|
+
import { type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaFilePreview } from '../types';
|
|
3
|
+
import { type ObjectURLCache } from './objectURLCache';
|
|
4
4
|
type Mode = MediaStoreGetFileImageParams['mode'] | undefined;
|
|
5
5
|
export declare const getCacheKey: (id: string, mode: Mode) => string;
|
|
6
6
|
export interface MediaFilePreviewCache {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FilePreview, MediaBlobUrlAttrs, MediaClient, MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
-
import { MediaTraceContext, SSR } from '@atlaskit/media-common';
|
|
3
|
-
import { MediaFilePreview, MediaFilePreviewDimensions } from '../types';
|
|
1
|
+
import { type FilePreview, type MediaBlobUrlAttrs, type MediaClient, type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaTraceContext, type SSR } from '@atlaskit/media-common';
|
|
3
|
+
import { type MediaFilePreview, type MediaFilePreviewDimensions } from '../types';
|
|
4
4
|
export declare const getSSRPreview: (ssr: SSR, mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs) => MediaFilePreview;
|
|
5
5
|
export declare const isLocalPreview: (preview: MediaFilePreview) => boolean;
|
|
6
6
|
export declare const isRemotePreview: (preview: MediaFilePreview) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FilePreview, MediaClient, MediaStoreGetFileImageParams, MediaType } from '@atlaskit/media-client';
|
|
2
|
-
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
-
import { MediaFilePreview } from '../types';
|
|
1
|
+
import { type FilePreview, type MediaClient, type MediaStoreGetFileImageParams, type MediaType } from '@atlaskit/media-client';
|
|
2
|
+
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
+
import { type MediaFilePreview } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* This method tells the support for the media
|
|
6
6
|
* types covered in getCardPreviewFromFilePreview
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FileIdentifier } from '@atlaskit/media-client';
|
|
3
|
-
import { NumericalCardDimensions } from '@atlaskit/media-common';
|
|
4
|
-
import { MediaFilePreviewErrorInfo } from '../analytics';
|
|
5
|
-
import { MediaCardSsr } from './types';
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { type FileIdentifier } from '@atlaskit/media-client';
|
|
3
|
+
import { type NumericalCardDimensions } from '@atlaskit/media-common';
|
|
4
|
+
import { type MediaFilePreviewErrorInfo } from '../analytics';
|
|
5
|
+
import { type MediaCardSsr } from './types';
|
|
6
6
|
export declare const GLOBAL_MEDIA_CARD_SSR = "mediaCardSsr";
|
|
7
7
|
export declare const GLOBAL_MEDIA_NAMESPACE = "__MEDIA_INTERNAL";
|
|
8
8
|
export type MediaGlobalScope = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NumericalCardDimensions } from '@atlaskit/media-common';
|
|
2
|
-
import { MediaFilePreviewErrorInfo } from '../analytics';
|
|
1
|
+
import { type NumericalCardDimensions } from '@atlaskit/media-common';
|
|
2
|
+
import { type MediaFilePreviewErrorInfo } from '../analytics';
|
|
3
3
|
export type MediaCardSsrData = {
|
|
4
4
|
dataURI?: string;
|
|
5
5
|
dimensions?: Partial<NumericalCardDimensions>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MutableRefObject } from 'react';
|
|
2
|
-
import { MediaFilePreviewDimensions } from './types';
|
|
1
|
+
import { type MutableRefObject } from 'react';
|
|
2
|
+
import { type MediaFilePreviewDimensions } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Checks if at least one of next dimensions is bigger than current
|
|
5
5
|
* If a single dimension is undefined, returns false
|
|
@@ -3,3 +3,4 @@ export type { UseFilePreviewParams } from './useFilePreview';
|
|
|
3
3
|
export { useMediaImage } from './useMediaImage';
|
|
4
4
|
export type { UseMediaImageParams } from './useMediaImage';
|
|
5
5
|
export type { MediaFilePreview } from './types';
|
|
6
|
+
export { isMediaFilePreviewError } from './errors';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { FileIdentifier, MediaBlobUrlAttrs, MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
-
import { MediaTraceContext, SSR } from '@atlaskit/media-common';
|
|
4
|
-
import { SSRStatus } from './analytics';
|
|
2
|
+
import { type FileIdentifier, type MediaBlobUrlAttrs, type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
+
import { type MediaTraceContext, type SSR } from '@atlaskit/media-common';
|
|
4
|
+
import { type SSRStatus } from './analytics';
|
|
5
5
|
import { MediaFilePreviewError } from './errors';
|
|
6
|
-
import { MediaFilePreview, MediaFilePreviewDimensions, MediaFilePreviewStatus } from './types';
|
|
6
|
+
import { type MediaFilePreview, type MediaFilePreviewDimensions, type MediaFilePreviewStatus } from './types';
|
|
7
7
|
export interface UseFilePreviewParams {
|
|
8
8
|
/** Instance of file identifier. */
|
|
9
9
|
readonly identifier: FileIdentifier;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { FileIdentifier, MediaBlobUrlAttrs, MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
-
import { MediaTraceContext, SSR } from '@atlaskit/media-common';
|
|
4
|
-
import { MediaFilePreviewDimensions } from './types';
|
|
2
|
+
import { type FileIdentifier, type MediaBlobUrlAttrs, type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
+
import { type MediaTraceContext, type SSR } from '@atlaskit/media-common';
|
|
4
|
+
import { type MediaFilePreviewDimensions } from './types';
|
|
5
5
|
export interface UseMediaImageParams {
|
|
6
6
|
/** Instance of file identifier. */
|
|
7
7
|
readonly identifier: FileIdentifier;
|
|
@@ -1,30 +1,40 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
2
2
|
/* eslint-disable @atlaskit/design-system/prefer-primitives */
|
|
3
|
-
import React, { ReactNode } from 'react';
|
|
3
|
+
import React, { type ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
type TerminalTextDisplayProps = {
|
|
6
|
-
|
|
6
|
+
children: ReactNode;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export const TerminalTextDisplay: React.FC<TerminalTextDisplayProps> = ({
|
|
10
|
-
|
|
10
|
+
children,
|
|
11
11
|
}): React.ReactElement | null => (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
<div
|
|
13
|
+
style={{
|
|
14
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
15
|
+
backgroundColor: '#000000',
|
|
16
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
17
|
+
color: '#33FF00',
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
19
|
+
borderRadius: 5,
|
|
20
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview, @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
21
|
+
padding: 20,
|
|
22
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
23
|
+
fontFamily: 'Courier New, monospace',
|
|
24
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
25
|
+
lineHeight: '1.4',
|
|
26
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
27
|
+
maxWidth: 600,
|
|
28
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
29
|
+
width: '100%',
|
|
30
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
31
|
+
fontSize: '1.1em',
|
|
32
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
33
|
+
whiteSpace: 'pre-wrap',
|
|
34
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
35
|
+
overflow: 'auto',
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</div>
|
|
30
40
|
);
|
package/package.json
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
2
|
+
"name": "@atlaskit/media-file-preview",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "A React Hook to fetch and render file previews. It's overloaded with fancy features like SSR, lazy loading, memory cache and local preview.",
|
|
5
|
+
"author": "Atlassian Pty Ltd",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"atlassian": {
|
|
11
|
+
"team": "Media Experience",
|
|
12
|
+
"inPublicMirror": false,
|
|
13
|
+
"releaseModel": "continuous",
|
|
14
|
+
"website": {
|
|
15
|
+
"name": "MediaFilePreview",
|
|
16
|
+
"category": "Components"
|
|
17
|
+
},
|
|
18
|
+
"runReact18": true
|
|
19
|
+
},
|
|
20
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
21
|
+
"main": "dist/cjs/index.js",
|
|
22
|
+
"module": "dist/esm/index.js",
|
|
23
|
+
"module:es2019": "dist/es2019/index.js",
|
|
24
|
+
"types": "dist/types/index.d.ts",
|
|
25
|
+
"typesVersions": {
|
|
26
|
+
">=4.5 <4.9": {
|
|
27
|
+
"*": [
|
|
28
|
+
"dist/types-ts4.5/*",
|
|
29
|
+
"dist/types-ts4.5/index.d.ts"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"atlaskit:src": "src/index.ts",
|
|
35
|
+
"af:exports": {
|
|
36
|
+
".": "./src/index.ts"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@atlaskit/media-client": "^27.3.0",
|
|
40
|
+
"@atlaskit/media-client-react": "^2.0.1",
|
|
41
|
+
"@atlaskit/media-common": "^11.3.0",
|
|
42
|
+
"@atlaskit/media-ui": "^25.11.0",
|
|
43
|
+
"@babel/runtime": "^7.0.0",
|
|
44
|
+
"eventemitter2": "^4.1.0",
|
|
45
|
+
"lru_map": "^0.4.1"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": "^16.8.0 || ^17.0.0 || ~18.2.0",
|
|
49
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ~18.2.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@af/integration-testing": "*",
|
|
53
|
+
"@af/visual-regression": "*",
|
|
54
|
+
"@atlaskit/media-state": "^1.1.0",
|
|
55
|
+
"@atlaskit/media-test-data": "^2.5.0",
|
|
56
|
+
"@atlaskit/section-message": "^6.6.0",
|
|
57
|
+
"@atlaskit/ssr": "*",
|
|
58
|
+
"@atlaskit/visual-regression": "*",
|
|
59
|
+
"@testing-library/react": "^12.1.5",
|
|
60
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
61
|
+
"react-dom": "^16.8.0",
|
|
62
|
+
"typescript": "~5.4.2",
|
|
63
|
+
"wait-for-expect": "^1.2.0"
|
|
64
|
+
},
|
|
65
|
+
"techstack": {
|
|
66
|
+
"@atlassian/frontend": {
|
|
67
|
+
"import-structure": [
|
|
68
|
+
"atlassian-conventions"
|
|
69
|
+
],
|
|
70
|
+
"circular-dependencies": [
|
|
71
|
+
"file-and-folder-level"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"@repo/internal": {
|
|
75
|
+
"dom-events": "use-bind-event-listener",
|
|
76
|
+
"analytics": [
|
|
77
|
+
"analytics-next"
|
|
78
|
+
],
|
|
79
|
+
"design-tokens": [
|
|
80
|
+
"color"
|
|
81
|
+
],
|
|
82
|
+
"theming": [
|
|
83
|
+
"react-context"
|
|
84
|
+
],
|
|
85
|
+
"ui-components": [
|
|
86
|
+
"lite-mode"
|
|
87
|
+
],
|
|
88
|
+
"deprecation": [
|
|
89
|
+
"no-deprecated-imports"
|
|
90
|
+
],
|
|
91
|
+
"styling": [
|
|
92
|
+
"static",
|
|
93
|
+
"emotion"
|
|
94
|
+
],
|
|
95
|
+
"imports": [
|
|
96
|
+
"import-no-extraneous-disable-for-examples-and-docs"
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|