@atlaskit/media-file-preview 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/media-file-preview
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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
8
+
9
+ ## 0.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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
14
+
3
15
  ## 0.2.0
4
16
 
5
17
  ### Minor Changes
@@ -114,13 +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) {
117
+ if (!preview && (!fileState || fileState.status === 'processing' || fileState.status === 'uploading')) {
118
118
  setStatus('loading');
119
119
  } else {
120
120
  setStatus('complete');
121
121
  }
122
122
  }
123
- }, [preview, status]);
123
+ }, [preview, status, fileState]);
124
124
 
125
125
  //----------------------------------------------------------------
126
126
  // Preview Fetch Helper
@@ -264,10 +264,10 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
264
264
  }, [preview === null || preview === void 0 ? void 0 : preview.dataURI]);
265
265
 
266
266
  // FOR SSR
267
- var getScriptProps = function getScriptProps() {
267
+ var getSsrScriptProps = ssr === 'server' ? function () {
268
268
  var _ssrReliabilityRef$cu;
269
269
  return (0, _globalScope.generateScriptProps)(identifier, preview === null || preview === void 0 ? void 0 : preview.dataURI, requestDimensions, ((_ssrReliabilityRef$cu = ssrReliabilityRef.current.server) === null || _ssrReliabilityRef$cu === void 0 ? void 0 : _ssrReliabilityRef$cu.status) === 'fail' ? ssrReliabilityRef.current.server : undefined);
270
- };
270
+ } : undefined;
271
271
 
272
272
  // CXP-2723 TODO: should consider simplifying our analytics, and how
273
273
  // we might get rid of ssrReliabiltyRef from our hook
@@ -279,7 +279,7 @@ var useFilePreview = exports.useFilePreview = function useFilePreview(_ref) {
279
279
  ssrReliabilityRef: ssrReliabilityRef,
280
280
  onImageError: onImageError,
281
281
  onImageLoad: onImageLoad,
282
- getScriptProps: getScriptProps
282
+ getSsrScriptProps: getSsrScriptProps
283
283
  };
284
284
  };
285
285
  var initialSsrReliability = {
@@ -15,6 +15,7 @@ export const useFilePreview = ({
15
15
  traceContext,
16
16
  skipRemote,
17
17
  mediaBlobUrlAttrs,
18
+ // TODO: mediaBlobUrlAttrs can be missing several values contained in the file details. The preview hook is not updating the params in the preview after the file details are available.
18
19
  allowAnimated = true,
19
20
  upscale,
20
21
  maxAge
@@ -90,13 +91,13 @@ export const useFilePreview = ({
90
91
  }, [identifier]);
91
92
  useEffect(() => {
92
93
  if (status !== 'error') {
93
- if (!preview) {
94
+ if (!preview && (!fileState || fileState.status === 'processing' || fileState.status === 'uploading')) {
94
95
  setStatus('loading');
95
96
  } else {
96
97
  setStatus('complete');
97
98
  }
98
99
  }
99
- }, [preview, status]);
100
+ }, [preview, status, fileState]);
100
101
 
101
102
  //----------------------------------------------------------------
102
103
  // Preview Fetch Helper
@@ -243,10 +244,10 @@ export const useFilePreview = ({
243
244
  }, [preview === null || preview === void 0 ? void 0 : preview.dataURI]);
244
245
 
245
246
  // FOR SSR
246
- const getScriptProps = () => {
247
+ const getSsrScriptProps = ssr === 'server' ? () => {
247
248
  var _ssrReliabilityRef$cu;
248
249
  return generateScriptProps(identifier, preview === null || preview === void 0 ? void 0 : preview.dataURI, requestDimensions, ((_ssrReliabilityRef$cu = ssrReliabilityRef.current.server) === null || _ssrReliabilityRef$cu === void 0 ? void 0 : _ssrReliabilityRef$cu.status) === 'fail' ? ssrReliabilityRef.current.server : undefined);
249
- };
250
+ } : undefined;
250
251
 
251
252
  // CXP-2723 TODO: should consider simplifying our analytics, and how
252
253
  // we might get rid of ssrReliabiltyRef from our hook
@@ -258,7 +259,7 @@ export const useFilePreview = ({
258
259
  ssrReliabilityRef,
259
260
  onImageError,
260
261
  onImageLoad,
261
- getScriptProps
262
+ getSsrScriptProps
262
263
  };
263
264
  };
264
265
  const initialSsrReliability = {
@@ -107,13 +107,13 @@ export var useFilePreview = function useFilePreview(_ref) {
107
107
  }, [identifier]);
108
108
  useEffect(function () {
109
109
  if (status !== 'error') {
110
- if (!preview) {
110
+ if (!preview && (!fileState || fileState.status === 'processing' || fileState.status === 'uploading')) {
111
111
  setStatus('loading');
112
112
  } else {
113
113
  setStatus('complete');
114
114
  }
115
115
  }
116
- }, [preview, status]);
116
+ }, [preview, status, fileState]);
117
117
 
118
118
  //----------------------------------------------------------------
119
119
  // Preview Fetch Helper
@@ -257,10 +257,10 @@ export var useFilePreview = function useFilePreview(_ref) {
257
257
  }, [preview === null || preview === void 0 ? void 0 : preview.dataURI]);
258
258
 
259
259
  // FOR SSR
260
- var getScriptProps = function getScriptProps() {
260
+ var getSsrScriptProps = ssr === 'server' ? function () {
261
261
  var _ssrReliabilityRef$cu;
262
262
  return generateScriptProps(identifier, preview === null || preview === void 0 ? void 0 : preview.dataURI, requestDimensions, ((_ssrReliabilityRef$cu = ssrReliabilityRef.current.server) === null || _ssrReliabilityRef$cu === void 0 ? void 0 : _ssrReliabilityRef$cu.status) === 'fail' ? ssrReliabilityRef.current.server : undefined);
263
- };
263
+ } : undefined;
264
264
 
265
265
  // CXP-2723 TODO: should consider simplifying our analytics, and how
266
266
  // we might get rid of ssrReliabiltyRef from our hook
@@ -272,7 +272,7 @@ export var useFilePreview = function useFilePreview(_ref) {
272
272
  ssrReliabilityRef: ssrReliabilityRef,
273
273
  onImageError: onImageError,
274
274
  onImageLoad: onImageLoad,
275
- getScriptProps: getScriptProps
275
+ getSsrScriptProps: getSsrScriptProps
276
276
  };
277
277
  };
278
278
  var initialSsrReliability = {
@@ -35,5 +35,5 @@ export declare const useFilePreview: ({ resizeMode, identifier, ssr, dimensions,
35
35
  ssrReliabilityRef: import("react").MutableRefObject<SSRStatus>;
36
36
  onImageError: (newPreview?: MediaFilePreview) => void;
37
37
  onImageLoad: (newPreview?: MediaFilePreview) => void;
38
- getScriptProps: () => import("react").ScriptHTMLAttributes<HTMLScriptElement>;
38
+ getSsrScriptProps: (() => import("react").ScriptHTMLAttributes<HTMLScriptElement>) | undefined;
39
39
  };
@@ -35,5 +35,5 @@ export declare const useFilePreview: ({ resizeMode, identifier, ssr, dimensions,
35
35
  ssrReliabilityRef: import("react").MutableRefObject<SSRStatus>;
36
36
  onImageError: (newPreview?: MediaFilePreview) => void;
37
37
  onImageLoad: (newPreview?: MediaFilePreview) => void;
38
- getScriptProps: () => import("react").ScriptHTMLAttributes<HTMLScriptElement>;
38
+ getSsrScriptProps: (() => import("react").ScriptHTMLAttributes<HTMLScriptElement>) | undefined;
39
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-file-preview",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
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",
@@ -50,7 +50,7 @@
50
50
  "@af/integration-testing": "*",
51
51
  "@af/visual-regression": "*",
52
52
  "@atlaskit/media-state": "^1.0.3",
53
- "@atlaskit/media-test-data": "^1.1.1",
53
+ "@atlaskit/media-test-data": "^1.2.0",
54
54
  "@atlaskit/section-message": "^6.4.17",
55
55
  "@atlaskit/ssr": "*",
56
56
  "@atlaskit/visual-regression": "*",