@atlaskit/media-file-preview 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/media-file-preview
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  ### Minor Changes
@@ -114,10 +114,13 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
114
114
  }, [identifier]);
115
115
  (0, _react.useEffect)(function () {
116
116
  if (status !== 'error') {
117
- if (!preview && (!fileState || fileState.status === 'processing' || fileState.status === 'uploading')) {
118
- setStatus('loading');
119
- } else {
117
+ if (preview || fileState && fileState.status === 'processed' && !(0, _mediaClient.isImageRepresentationReady)(fileState)) {
120
118
  setStatus('complete');
119
+ } else if (!preview && fileState && fileState.status === 'failed-processing' && !(0, _mediaClient.isImageRepresentationReady)(fileState)) {
120
+ setStatus('error');
121
+ setError(new _errors.MediaFilePreviewError('failed-processing'));
122
+ } else {
123
+ setStatus('loading');
121
124
  }
122
125
  }
123
126
  }, [preview, status, fileState]);
@@ -3,7 +3,7 @@ import { isImageRepresentationReady } from '@atlaskit/media-client';
3
3
  import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
4
4
  import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
5
5
  import { extractErrorInfo } from './analytics';
6
- import { ensureMediaFilePreviewError, ImageLoadError } from './errors';
6
+ import { ensureMediaFilePreviewError, ImageLoadError, MediaFilePreviewError } from './errors';
7
7
  import { getAndCacheLocalPreview, getAndCacheRemotePreview, getSSRPreview, isLocalPreview, isSSRClientPreview, isSSRDataPreview, isSSRPreview, isSupportedLocalPreview, mediaFilePreviewCache } from './getPreview';
8
8
  import { generateScriptProps, getSSRData } from './globalScope';
9
9
  import { createRequestDimensions, isBigger, useCurrentValueRef } from './helpers';
@@ -91,10 +91,13 @@ export const useFilePreview = ({
91
91
  }, [identifier]);
92
92
  useEffect(() => {
93
93
  if (status !== 'error') {
94
- if (!preview && (!fileState || fileState.status === 'processing' || fileState.status === 'uploading')) {
95
- setStatus('loading');
96
- } else {
94
+ if (preview || fileState && fileState.status === 'processed' && !isImageRepresentationReady(fileState)) {
97
95
  setStatus('complete');
96
+ } else if (!preview && fileState && fileState.status === 'failed-processing' && !isImageRepresentationReady(fileState)) {
97
+ setStatus('error');
98
+ setError(new MediaFilePreviewError('failed-processing'));
99
+ } else {
100
+ setStatus('loading');
98
101
  }
99
102
  }
100
103
  }, [preview, status, fileState]);
@@ -7,7 +7,7 @@ import { isImageRepresentationReady } from '@atlaskit/media-client';
7
7
  import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
8
8
  import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
9
9
  import { extractErrorInfo } from './analytics';
10
- import { ensureMediaFilePreviewError, ImageLoadError } from './errors';
10
+ import { ensureMediaFilePreviewError, ImageLoadError, MediaFilePreviewError } from './errors';
11
11
  import { getAndCacheLocalPreview, getAndCacheRemotePreview, getSSRPreview, isLocalPreview, isSSRClientPreview, isSSRDataPreview, isSSRPreview, isSupportedLocalPreview, mediaFilePreviewCache } from './getPreview';
12
12
  import { generateScriptProps, getSSRData } from './globalScope';
13
13
  import { createRequestDimensions, isBigger, useCurrentValueRef } from './helpers';
@@ -107,10 +107,13 @@ export var useFilePreview = function useFilePreview(_ref) {
107
107
  }, [identifier]);
108
108
  useEffect(function () {
109
109
  if (status !== 'error') {
110
- if (!preview && (!fileState || fileState.status === 'processing' || fileState.status === 'uploading')) {
111
- setStatus('loading');
112
- } else {
110
+ if (preview || fileState && fileState.status === 'processed' && !isImageRepresentationReady(fileState)) {
113
111
  setStatus('complete');
112
+ } else if (!preview && fileState && fileState.status === 'failed-processing' && !isImageRepresentationReady(fileState)) {
113
+ setStatus('error');
114
+ setError(new MediaFilePreviewError('failed-processing'));
115
+ } else {
116
+ setStatus('loading');
114
117
  }
115
118
  }
116
119
  }, [preview, status, fileState]);
@@ -5,7 +5,7 @@ import { MediaFilePreview } from './types';
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
7
7
  */
8
- export type MediaFilePreviewErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
8
+ export type MediaFilePreviewErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | 'failed-processing' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
9
9
  export type ImageLoadPrimaryReason = 'cache-remote-uri' | 'cache-local-uri' | 'local-uri' | 'remote-uri' | 'external-uri' | 'unknown-uri';
10
10
  export type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready' | 'remote-preview-fetch-ssr';
11
11
  export type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-unsupported' | 'local-preview-rejected' | 'local-preview-image' | 'local-preview-video';
@@ -5,7 +5,7 @@ import { MediaFilePreview } from './types';
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
7
7
  */
8
- export type MediaFilePreviewErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
8
+ export type MediaFilePreviewErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | 'failed-processing' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
9
9
  export type ImageLoadPrimaryReason = 'cache-remote-uri' | 'cache-local-uri' | 'local-uri' | 'remote-uri' | 'external-uri' | 'unknown-uri';
10
10
  export type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready' | 'remote-preview-fetch-ssr';
11
11
  export type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-unsupported' | 'local-preview-rejected' | 'local-preview-image' | 'local-preview-video';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-file-preview",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
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
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",