@atlaskit/media-file-preview 0.5.1 → 0.6.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +47 -11
  2. package/LICENSE.md +6 -8
  3. package/dist/cjs/index.js +8 -1
  4. package/dist/cjs/useFilePreview.js +2 -2
  5. package/dist/es2019/index.js +2 -1
  6. package/dist/es2019/useFilePreview.js +2 -2
  7. package/dist/esm/index.js +2 -1
  8. package/dist/esm/useFilePreview.js +2 -2
  9. package/dist/types/analytics.d.ts +4 -4
  10. package/dist/types/errors.d.ts +2 -2
  11. package/dist/types/getPreview/cache.d.ts +3 -3
  12. package/dist/types/getPreview/getPreview.d.ts +3 -3
  13. package/dist/types/getPreview/helpers.d.ts +3 -3
  14. package/dist/types/getPreview/objectURLCache.d.ts +1 -1
  15. package/dist/types/globalScope/getSSRData.d.ts +1 -1
  16. package/dist/types/globalScope/globalScope.d.ts +5 -5
  17. package/dist/types/globalScope/types.d.ts +2 -2
  18. package/dist/types/helpers.d.ts +2 -2
  19. package/dist/types/index.d.ts +1 -0
  20. package/dist/types/useFilePreview.d.ts +4 -4
  21. package/dist/types/useMediaImage.d.ts +3 -3
  22. package/dist/types-ts4.5/analytics.d.ts +4 -4
  23. package/dist/types-ts4.5/errors.d.ts +2 -2
  24. package/dist/types-ts4.5/getPreview/cache.d.ts +3 -3
  25. package/dist/types-ts4.5/getPreview/getPreview.d.ts +3 -3
  26. package/dist/types-ts4.5/getPreview/helpers.d.ts +3 -3
  27. package/dist/types-ts4.5/getPreview/objectURLCache.d.ts +1 -1
  28. package/dist/types-ts4.5/globalScope/getSSRData.d.ts +1 -1
  29. package/dist/types-ts4.5/globalScope/globalScope.d.ts +5 -5
  30. package/dist/types-ts4.5/globalScope/types.d.ts +2 -2
  31. package/dist/types-ts4.5/helpers.d.ts +2 -2
  32. package/dist/types-ts4.5/index.d.ts +1 -0
  33. package/dist/types-ts4.5/useFilePreview.d.ts +4 -4
  34. package/dist/types-ts4.5/useMediaImage.d.ts +3 -3
  35. package/example-helpers/TerminalTextDisplay.tsx +31 -21
  36. package/package.json +97 -99
package/CHANGELOG.md CHANGED
@@ -1,65 +1,101 @@
1
1
  # @atlaskit/media-file-preview
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#118216](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/118216)
8
+ [`b2f8064faf92d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b2f8064faf92d) -
9
+ Added new export for verifying MediaFilePreviewError type
10
+
11
+ ## 0.5.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 0.5.1
4
18
 
5
19
  ### Patch Changes
6
20
 
7
- - [#83116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83116) [`8d4e99057fe0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d4e99057fe0) - Upgrade Typescript from `4.9.5` to `5.4.2`
21
+ - [#83116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83116)
22
+ [`8d4e99057fe0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d4e99057fe0) -
23
+ Upgrade Typescript from `4.9.5` to `5.4.2`
8
24
 
9
25
  ## 0.5.0
10
26
 
11
27
  ### Minor Changes
12
28
 
13
- - [#73279](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/73279) [`cdad00f21119`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cdad00f21119) - Create useMediaImage hook
29
+ - [#73279](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/73279)
30
+ [`cdad00f21119`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cdad00f21119) -
31
+ Create useMediaImage hook
14
32
 
15
33
  ## 0.4.2
16
34
 
17
35
  ### Patch Changes
18
36
 
19
- - [#71793](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71793) [`26115be71855`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/26115be71855) - Added support for Error File State
37
+ - [#71793](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71793)
38
+ [`26115be71855`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/26115be71855) -
39
+ Added support for Error File State
20
40
 
21
41
  ## 0.4.1
22
42
 
23
43
  ### Patch Changes
24
44
 
25
- - [#71409](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71409) [`5c76dfba92dd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c76dfba92dd) - Pass trace context to global scope error
45
+ - [#71409](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71409)
46
+ [`5c76dfba92dd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c76dfba92dd) -
47
+ Pass trace context to global scope error
26
48
 
27
49
  ## 0.4.0
28
50
 
29
51
  ### Minor Changes
30
52
 
31
- - [#70446](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70446) [`48eae199c6fa`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/48eae199c6fa) - Breaking: return ref object ssrReliabilityRef is replaced by object ssrReliability
53
+ - [#70446](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70446)
54
+ [`48eae199c6fa`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/48eae199c6fa) -
55
+ Breaking: return ref object ssrReliabilityRef is replaced by object ssrReliability
32
56
 
33
57
  ### Patch Changes
34
58
 
35
- - [#70446](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70446) [`0ff07ca94009`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0ff07ca94009) - Better support for onImageError callback
59
+ - [#70446](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70446)
60
+ [`0ff07ca94009`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0ff07ca94009) -
61
+ Better support for onImageError callback
36
62
 
37
63
  ## 0.3.1
38
64
 
39
65
  ### Patch Changes
40
66
 
41
- - [#70361](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70361) [`6bcee8c57dac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6bcee8c57dac) - Support for files failed to process
67
+ - [#70361](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70361)
68
+ [`6bcee8c57dac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6bcee8c57dac) -
69
+ Support for files failed to process
42
70
 
43
71
  ## 0.3.0
44
72
 
45
73
  ### Minor Changes
46
74
 
47
- - [#70034](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70034) [`0cf829b2ca1f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0cf829b2ca1f) - Breaking: renamed return value from getScriptProps to getSsrScriptProps
75
+ - [#70034](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70034)
76
+ [`0cf829b2ca1f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0cf829b2ca1f) -
77
+ Breaking: renamed return value from getScriptProps to getSsrScriptProps
48
78
 
49
79
  ## 0.2.1
50
80
 
51
81
  ### Patch Changes
52
82
 
53
- - [#69372](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69372) [`d719e8e81e2c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d719e8e81e2c) - Fixed status for processed files with no preview
83
+ - [#69372](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69372)
84
+ [`d719e8e81e2c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d719e8e81e2c) -
85
+ Fixed status for processed files with no preview
54
86
 
55
87
  ## 0.2.0
56
88
 
57
89
  ### Minor Changes
58
90
 
59
- - [#65817](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65817) [`de45ff7a33a9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/de45ff7a33a9) - Breaking: removed previewDidRender property
91
+ - [#65817](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65817)
92
+ [`de45ff7a33a9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/de45ff7a33a9) -
93
+ Breaking: removed previewDidRender property
60
94
 
61
95
  ## 0.1.0
62
96
 
63
97
  ### Minor Changes
64
98
 
65
- - [#65749](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65749) [`cf9674e67f0c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cf9674e67f0c) - Breaking: updated prop types
99
+ - [#65749](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65749)
100
+ [`cf9674e67f0c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cf9674e67f0c) -
101
+ 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
- you may not use this file except in compliance with the License.
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 under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
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
- 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
- */
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 = {
@@ -1,2 +1,3 @@
1
1
  export { useFilePreview } from './useFilePreview';
2
- export { useMediaImage } from './useMediaImage';
2
+ export { useMediaImage } from './useMediaImage';
3
+ export { isMediaFilePreviewError } from './errors';
@@ -248,8 +248,8 @@ export const useFilePreview = ({
248
248
  }
249
249
 
250
250
  /*
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
- */
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
@@ -1,2 +1,3 @@
1
1
  export { useFilePreview } from './useFilePreview';
2
- export { useMediaImage } from './useMediaImage';
2
+ export { useMediaImage } from './useMediaImage';
3
+ export { isMediaFilePreviewError } from './errors';
@@ -267,8 +267,8 @@ export var useFilePreview = function useFilePreview(_ref) {
267
267
  }
268
268
 
269
269
  /*
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
- */
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;
@@ -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,4 +1,4 @@
1
- import { MediaFilePreview } from '../types';
1
+ import { type MediaFilePreview } from '../types';
2
2
  export declare const PREVIEW_CACHE_LRU_SIZE = 50;
3
3
  export declare class ObjectURLCache {
4
4
  private readonly cache;
@@ -1,3 +1,3 @@
1
- import { FileIdentifier } from '@atlaskit/media-client';
1
+ import { type FileIdentifier } from '@atlaskit/media-client';
2
2
  import type { MediaCardSsrData } from './types';
3
3
  export declare const getSSRData: (identifier: FileIdentifier) => MediaCardSsrData | undefined;
@@ -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,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,4 +1,4 @@
1
- import { MediaFilePreview } from '../types';
1
+ import { type MediaFilePreview } from '../types';
2
2
  export declare const PREVIEW_CACHE_LRU_SIZE = 50;
3
3
  export declare class ObjectURLCache {
4
4
  private readonly cache;
@@ -1,3 +1,3 @@
1
- import { FileIdentifier } from '@atlaskit/media-client';
1
+ import { type FileIdentifier } from '@atlaskit/media-client';
2
2
  import type { MediaCardSsrData } from './types';
3
3
  export declare const getSSRData: (identifier: FileIdentifier) => MediaCardSsrData | undefined;
@@ -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
- children: ReactNode;
6
+ children: ReactNode;
7
7
  };
8
8
 
9
9
  export const TerminalTextDisplay: React.FC<TerminalTextDisplayProps> = ({
10
- children,
10
+ children,
11
11
  }): React.ReactElement | null => (
12
- <div
13
- style={{
14
- backgroundColor: '#000000',
15
- color: '#33FF00',
16
- borderRadius: 5,
17
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
18
- padding: 20,
19
- fontFamily: 'Courier New, monospace',
20
- lineHeight: '1.4',
21
- maxWidth: 600,
22
- width: '100%',
23
- fontSize: '1.1em',
24
- whiteSpace: 'pre-wrap',
25
- overflow: 'auto',
26
- }}
27
- >
28
- {children}
29
- </div>
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,98 @@
1
1
  {
2
- "name": "@atlaskit/media-file-preview",
3
- "version": "0.5.1",
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
- },
19
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
20
- "main": "dist/cjs/index.js",
21
- "module": "dist/esm/index.js",
22
- "module:es2019": "dist/es2019/index.js",
23
- "types": "dist/types/index.d.ts",
24
- "typesVersions": {
25
- ">=4.5 <4.9": {
26
- "*": [
27
- "dist/types-ts4.5/*",
28
- "dist/types-ts4.5/index.d.ts"
29
- ]
30
- }
31
- },
32
- "sideEffects": false,
33
- "atlaskit:src": "src/index.ts",
34
- "af:exports": {
35
- ".": "./src/index.ts"
36
- },
37
- "dependencies": {
38
- "@atlaskit/media-client": "^26.2.0",
39
- "@atlaskit/media-client-react": "^2.0.1",
40
- "@atlaskit/media-common": "^11.1.0",
41
- "@atlaskit/media-ui": "^25.4.0",
42
- "@babel/runtime": "^7.0.0",
43
- "eventemitter2": "^4.1.0",
44
- "lru_map": "^0.4.1"
45
- },
46
- "peerDependencies": {
47
- "react": "^16.8.0"
48
- },
49
- "devDependencies": {
50
- "@af/integration-testing": "*",
51
- "@af/visual-regression": "*",
52
- "@atlaskit/media-state": "^1.0.3",
53
- "@atlaskit/media-test-data": "^1.2.0",
54
- "@atlaskit/section-message": "^6.4.17",
55
- "@atlaskit/ssr": "*",
56
- "@atlaskit/visual-regression": "*",
57
- "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
58
- "@testing-library/react": "^12.1.5",
59
- "@testing-library/react-hooks": "^8.0.1",
60
- "react-dom": "^16.8.0",
61
- "typescript": "~5.4.2",
62
- "wait-for-expect": "^1.2.0"
63
- },
64
- "techstack": {
65
- "@atlassian/frontend": {
66
- "import-structure": [
67
- "atlassian-conventions"
68
- ],
69
- "circular-dependencies": [
70
- "file-and-folder-level"
71
- ]
72
- },
73
- "@repo/internal": {
74
- "dom-events": "use-bind-event-listener",
75
- "analytics": [
76
- "analytics-next"
77
- ],
78
- "design-tokens": [
79
- "color"
80
- ],
81
- "theming": [
82
- "react-context"
83
- ],
84
- "ui-components": [
85
- "lite-mode"
86
- ],
87
- "deprecation": [
88
- "no-deprecated-imports"
89
- ],
90
- "styling": [
91
- "static",
92
- "emotion"
93
- ],
94
- "imports": [
95
- "import-no-extraneous-disable-for-examples-and-docs"
96
- ]
97
- }
98
- },
99
- "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
100
- }
2
+ "name": "@atlaskit/media-file-preview",
3
+ "version": "0.6.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
+ },
19
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
20
+ "main": "dist/cjs/index.js",
21
+ "module": "dist/esm/index.js",
22
+ "module:es2019": "dist/es2019/index.js",
23
+ "types": "dist/types/index.d.ts",
24
+ "typesVersions": {
25
+ ">=4.5 <4.9": {
26
+ "*": [
27
+ "dist/types-ts4.5/*",
28
+ "dist/types-ts4.5/index.d.ts"
29
+ ]
30
+ }
31
+ },
32
+ "sideEffects": false,
33
+ "atlaskit:src": "src/index.ts",
34
+ "af:exports": {
35
+ ".": "./src/index.ts"
36
+ },
37
+ "dependencies": {
38
+ "@atlaskit/media-client": "^27.3.0",
39
+ "@atlaskit/media-client-react": "^2.0.1",
40
+ "@atlaskit/media-common": "^11.3.0",
41
+ "@atlaskit/media-ui": "^25.10.0",
42
+ "@babel/runtime": "^7.0.0",
43
+ "eventemitter2": "^4.1.0",
44
+ "lru_map": "^0.4.1"
45
+ },
46
+ "peerDependencies": {
47
+ "react": "^16.8.0"
48
+ },
49
+ "devDependencies": {
50
+ "@af/integration-testing": "*",
51
+ "@af/visual-regression": "*",
52
+ "@atlaskit/media-state": "^1.1.0",
53
+ "@atlaskit/media-test-data": "^2.3.0",
54
+ "@atlaskit/section-message": "^6.5.0",
55
+ "@atlaskit/ssr": "*",
56
+ "@atlaskit/visual-regression": "*",
57
+ "@testing-library/react": "^12.1.5",
58
+ "@testing-library/react-hooks": "^8.0.1",
59
+ "react-dom": "^16.8.0",
60
+ "typescript": "~5.4.2",
61
+ "wait-for-expect": "^1.2.0"
62
+ },
63
+ "techstack": {
64
+ "@atlassian/frontend": {
65
+ "import-structure": [
66
+ "atlassian-conventions"
67
+ ],
68
+ "circular-dependencies": [
69
+ "file-and-folder-level"
70
+ ]
71
+ },
72
+ "@repo/internal": {
73
+ "dom-events": "use-bind-event-listener",
74
+ "analytics": [
75
+ "analytics-next"
76
+ ],
77
+ "design-tokens": [
78
+ "color"
79
+ ],
80
+ "theming": [
81
+ "react-context"
82
+ ],
83
+ "ui-components": [
84
+ "lite-mode"
85
+ ],
86
+ "deprecation": [
87
+ "no-deprecated-imports"
88
+ ],
89
+ "styling": [
90
+ "static",
91
+ "emotion"
92
+ ],
93
+ "imports": [
94
+ "import-no-extraneous-disable-for-examples-and-docs"
95
+ ]
96
+ }
97
+ }
98
+ }