@atlaskit/media-card 77.6.4 → 77.6.6
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 +12 -0
- package/dist/cjs/card/card.js +1 -1
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/card/v2/cardV2.js +1 -1
- package/dist/cjs/card/v2/fileCard.js +8 -4
- package/dist/cjs/inline/loader.js +1 -1
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/es2019/card/card.js +1 -1
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/card/v2/cardV2.js +1 -1
- package/dist/es2019/card/v2/fileCard.js +7 -3
- package/dist/es2019/inline/loader.js +1 -1
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/esm/card/card.js +1 -1
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/card/v2/cardV2.js +1 -1
- package/dist/esm/card/v2/fileCard.js +7 -3
- package/dist/esm/inline/loader.js +1 -1
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/types/card/v2/cardViewV2.d.ts +1 -1
- package/dist/types/card/v2/cardviews/cardViewWrapper.d.ts +1 -1
- package/dist/types/card/v2/cardviews/index.d.ts +1 -1
- package/dist/types-ts4.5/card/v2/cardViewV2.d.ts +1 -1
- package/dist/types-ts4.5/card/v2/cardviews/cardViewWrapper.d.ts +1 -1
- package/dist/types-ts4.5/card/v2/cardviews/index.d.ts +1 -1
- package/package.json +4 -3
- package/dist/cjs/card/v2/useFilePreview/analytics.js +0 -50
- package/dist/cjs/card/v2/useFilePreview/errors.js +0 -143
- package/dist/cjs/card/v2/useFilePreview/getPreview/cache.js +0 -39
- package/dist/cjs/card/v2/useFilePreview/getPreview/filePreviewStatus.js +0 -45
- package/dist/cjs/card/v2/useFilePreview/getPreview/getPreview.js +0 -119
- package/dist/cjs/card/v2/useFilePreview/getPreview/helpers.js +0 -167
- package/dist/cjs/card/v2/useFilePreview/getPreview/index.js +0 -62
- package/dist/cjs/card/v2/useFilePreview/getPreview/objectURLCache.js +0 -85
- package/dist/cjs/card/v2/useFilePreview/getPreview/videoSnapshot.js +0 -58
- package/dist/cjs/card/v2/useFilePreview/globalScope/getSSRData.js +0 -14
- package/dist/cjs/card/v2/useFilePreview/globalScope/globalScope.js +0 -66
- package/dist/cjs/card/v2/useFilePreview/globalScope/index.js +0 -37
- package/dist/cjs/card/v2/useFilePreview/globalScope/printScript.js +0 -32
- package/dist/cjs/card/v2/useFilePreview/globalScope/types.js +0 -5
- package/dist/cjs/card/v2/useFilePreview/helpers.js +0 -64
- package/dist/cjs/card/v2/useFilePreview/index.js +0 -12
- package/dist/cjs/card/v2/useFilePreview/types.js +0 -5
- package/dist/cjs/card/v2/useFilePreview/useFilePreview.js +0 -460
- package/dist/es2019/card/v2/useFilePreview/analytics.js +0 -44
- package/dist/es2019/card/v2/useFilePreview/errors.js +0 -90
- package/dist/es2019/card/v2/useFilePreview/getPreview/cache.js +0 -30
- package/dist/es2019/card/v2/useFilePreview/getPreview/filePreviewStatus.js +0 -43
- package/dist/es2019/card/v2/useFilePreview/getPreview/getPreview.js +0 -75
- package/dist/es2019/card/v2/useFilePreview/getPreview/helpers.js +0 -76
- package/dist/es2019/card/v2/useFilePreview/getPreview/index.js +0 -3
- package/dist/es2019/card/v2/useFilePreview/getPreview/objectURLCache.js +0 -44
- package/dist/es2019/card/v2/useFilePreview/getPreview/videoSnapshot.js +0 -36
- package/dist/es2019/card/v2/useFilePreview/globalScope/getSSRData.js +0 -8
- package/dist/es2019/card/v2/useFilePreview/globalScope/globalScope.js +0 -48
- package/dist/es2019/card/v2/useFilePreview/globalScope/index.js +0 -2
- package/dist/es2019/card/v2/useFilePreview/globalScope/printScript.js +0 -16
- package/dist/es2019/card/v2/useFilePreview/globalScope/types.js +0 -1
- package/dist/es2019/card/v2/useFilePreview/helpers.js +0 -61
- package/dist/es2019/card/v2/useFilePreview/index.js +0 -1
- package/dist/es2019/card/v2/useFilePreview/types.js +0 -1
- package/dist/es2019/card/v2/useFilePreview/useFilePreview.js +0 -390
- package/dist/esm/card/v2/useFilePreview/analytics.js +0 -44
- package/dist/esm/card/v2/useFilePreview/errors.js +0 -133
- package/dist/esm/card/v2/useFilePreview/getPreview/cache.js +0 -32
- package/dist/esm/card/v2/useFilePreview/getPreview/filePreviewStatus.js +0 -40
- package/dist/esm/card/v2/useFilePreview/getPreview/getPreview.js +0 -112
- package/dist/esm/card/v2/useFilePreview/getPreview/helpers.js +0 -160
- package/dist/esm/card/v2/useFilePreview/getPreview/index.js +0 -3
- package/dist/esm/card/v2/useFilePreview/getPreview/objectURLCache.js +0 -78
- package/dist/esm/card/v2/useFilePreview/getPreview/videoSnapshot.js +0 -51
- package/dist/esm/card/v2/useFilePreview/globalScope/getSSRData.js +0 -8
- package/dist/esm/card/v2/useFilePreview/globalScope/globalScope.js +0 -56
- package/dist/esm/card/v2/useFilePreview/globalScope/index.js +0 -2
- package/dist/esm/card/v2/useFilePreview/globalScope/printScript.js +0 -25
- package/dist/esm/card/v2/useFilePreview/globalScope/types.js +0 -1
- package/dist/esm/card/v2/useFilePreview/helpers.js +0 -57
- package/dist/esm/card/v2/useFilePreview/index.js +0 -1
- package/dist/esm/card/v2/useFilePreview/types.js +0 -1
- package/dist/esm/card/v2/useFilePreview/useFilePreview.js +0 -453
- package/dist/types/card/v2/useFilePreview/analytics.d.ts +0 -28
- package/dist/types/card/v2/useFilePreview/errors.d.ts +0 -42
- package/dist/types/card/v2/useFilePreview/getPreview/cache.d.ts +0 -21
- package/dist/types/card/v2/useFilePreview/getPreview/filePreviewStatus.d.ts +0 -4
- package/dist/types/card/v2/useFilePreview/getPreview/getPreview.d.ts +0 -9
- package/dist/types/card/v2/useFilePreview/getPreview/helpers.d.ts +0 -10
- package/dist/types/card/v2/useFilePreview/getPreview/index.d.ts +0 -3
- package/dist/types/card/v2/useFilePreview/getPreview/objectURLCache.d.ts +0 -12
- package/dist/types/card/v2/useFilePreview/getPreview/videoSnapshot.d.ts +0 -1
- package/dist/types/card/v2/useFilePreview/globalScope/getSSRData.d.ts +0 -3
- package/dist/types/card/v2/useFilePreview/globalScope/globalScope.d.ts +0 -15
- package/dist/types/card/v2/useFilePreview/globalScope/index.d.ts +0 -4
- package/dist/types/card/v2/useFilePreview/globalScope/printScript.d.ts +0 -2
- package/dist/types/card/v2/useFilePreview/globalScope/types.d.ts +0 -8
- package/dist/types/card/v2/useFilePreview/helpers.d.ts +0 -11
- package/dist/types/card/v2/useFilePreview/index.d.ts +0 -2
- package/dist/types/card/v2/useFilePreview/types.d.ts +0 -18
- package/dist/types/card/v2/useFilePreview/useFilePreview.d.ts +0 -33
- package/dist/types-ts4.5/card/v2/useFilePreview/analytics.d.ts +0 -28
- package/dist/types-ts4.5/card/v2/useFilePreview/errors.d.ts +0 -42
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/cache.d.ts +0 -21
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/filePreviewStatus.d.ts +0 -4
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/getPreview.d.ts +0 -9
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/helpers.d.ts +0 -10
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/index.d.ts +0 -3
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/objectURLCache.d.ts +0 -12
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/videoSnapshot.d.ts +0 -1
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/getSSRData.d.ts +0 -3
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/globalScope.d.ts +0 -15
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/index.d.ts +0 -4
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/printScript.d.ts +0 -2
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/types.d.ts +0 -8
- package/dist/types-ts4.5/card/v2/useFilePreview/helpers.d.ts +0 -11
- package/dist/types-ts4.5/card/v2/useFilePreview/index.d.ts +0 -2
- package/dist/types-ts4.5/card/v2/useFilePreview/types.d.ts +0 -18
- package/dist/types-ts4.5/card/v2/useFilePreview/useFilePreview.d.ts +0 -33
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
-
import { imageResizeModeToFileImageMode, isImageRepresentationReady } from '@atlaskit/media-client';
|
|
8
|
-
import { MediaFileStateError, useFileState, useMediaClient } from '@atlaskit/media-client-react';
|
|
9
|
-
import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
|
|
10
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
11
|
-
import { ensureMediaFilePreviewError, ImageLoadError, isLocalPreviewError, isUnsupportedLocalPreviewError, MediaFilePreviewError } from './errors';
|
|
12
|
-
import { extractErrorInfo } from './analytics';
|
|
13
|
-
import { isBigger, createRequestDimensions, useCurrentValueRef, usePrevious } from './helpers';
|
|
14
|
-
import { generateScriptProps, getSSRData } from './globalScope';
|
|
15
|
-
import { getAndCacheRemotePreview, getSSRPreview, isLocalPreview, isSSRClientPreview, isSSRDataPreview, isPreviewableStatus, extractFilePreviewStatus, mediaFilePreviewCache, getAndCacheLocalPreview } from './getPreview';
|
|
16
|
-
export var useFilePreview = function useFilePreview(_ref) {
|
|
17
|
-
var _ref$resizeMode = _ref.resizeMode,
|
|
18
|
-
resizeMode = _ref$resizeMode === void 0 ? 'crop' : _ref$resizeMode,
|
|
19
|
-
identifier = _ref.identifier,
|
|
20
|
-
ssr = _ref.ssr,
|
|
21
|
-
dimensions = _ref.dimensions,
|
|
22
|
-
traceContext = _ref.traceContext,
|
|
23
|
-
previewDidRender = _ref.previewDidRender,
|
|
24
|
-
skipRemote = _ref.skipRemote,
|
|
25
|
-
mediaBlobUrlAttrs = _ref.mediaBlobUrlAttrs;
|
|
26
|
-
var mediaClient = useMediaClient();
|
|
27
|
-
var _useState = useState('loading'),
|
|
28
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
-
status = _useState2[0],
|
|
30
|
-
setStatus = _useState2[1];
|
|
31
|
-
var _useState3 = useState(),
|
|
32
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
-
error = _useState4[0],
|
|
34
|
-
setError = _useState4[1];
|
|
35
|
-
var _useState5 = useState(),
|
|
36
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
37
|
-
nonCriticalError = _useState6[0],
|
|
38
|
-
setNonCriticalError = _useState6[1];
|
|
39
|
-
var _useState7 = useState(false),
|
|
40
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
41
|
-
isBannedLocalPreview = _useState8[0],
|
|
42
|
-
setIsBannedLocalPreview = _useState8[1];
|
|
43
|
-
var wasResolvedUpfrontPreviewRef = useRef(false);
|
|
44
|
-
var ssrReliabilityRef = useRef(initialSsrReliability);
|
|
45
|
-
var requestDimensions = useMemo(function () {
|
|
46
|
-
return dimensions ? createRequestDimensions(dimensions) : undefined;
|
|
47
|
-
}, [dimensions]);
|
|
48
|
-
var requestDimensionsRef = useCurrentValueRef(requestDimensions);
|
|
49
|
-
var prevRequestDimensions = usePrevious(requestDimensions);
|
|
50
|
-
var imageURLParams = useMemo(function () {
|
|
51
|
-
return _objectSpread(_objectSpread({
|
|
52
|
-
collection: identifier.collectionName,
|
|
53
|
-
mode: resizeMode === 'stretchy-fit' ? 'full-fit' : resizeMode
|
|
54
|
-
}, requestDimensions), {}, {
|
|
55
|
-
allowAnimated: true
|
|
56
|
-
});
|
|
57
|
-
}, [requestDimensions, identifier.collectionName, resizeMode]);
|
|
58
|
-
var previewInitializer = function previewInitializer() {
|
|
59
|
-
var fileImageMode = imageResizeModeToFileImageMode(resizeMode);
|
|
60
|
-
var preview = mediaFilePreviewCache.get(identifier.id, fileImageMode);
|
|
61
|
-
if (preview) {
|
|
62
|
-
return preview;
|
|
63
|
-
}
|
|
64
|
-
if (ssr) {
|
|
65
|
-
var ssrData = getSSRData(identifier);
|
|
66
|
-
if (ssrData !== null && ssrData !== void 0 && ssrData.error) {
|
|
67
|
-
ssrReliabilityRef.current.server = _objectSpread({
|
|
68
|
-
status: 'fail'
|
|
69
|
-
}, ssrData.error);
|
|
70
|
-
}
|
|
71
|
-
if (!(ssrData !== null && ssrData !== void 0 && ssrData.dataURI)) {
|
|
72
|
-
try {
|
|
73
|
-
return getSSRPreview(ssr, mediaClient, identifier.id, imageURLParams, mediaBlobUrlAttrs);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
ssrReliabilityRef.current[ssr] = _objectSpread({
|
|
76
|
-
status: 'fail'
|
|
77
|
-
}, extractErrorInfo(e));
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
var _dimensions = ssrData.dimensions,
|
|
81
|
-
dataURI = ssrData.dataURI;
|
|
82
|
-
return {
|
|
83
|
-
dataURI: dataURI,
|
|
84
|
-
dimensions: _dimensions,
|
|
85
|
-
source: 'ssr-data'
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
var _useState9 = useState(previewInitializer),
|
|
91
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
92
|
-
preview = _useState10[0],
|
|
93
|
-
setPreview = _useState10[1];
|
|
94
|
-
var prevPreview = usePrevious(preview);
|
|
95
|
-
var _useFileState = useFileState(identifier.id, {
|
|
96
|
-
skipRemote: skipRemote,
|
|
97
|
-
collectionName: identifier.collectionName,
|
|
98
|
-
occurrenceKey: identifier.occurrenceKey
|
|
99
|
-
}),
|
|
100
|
-
fileState = _useFileState.fileState;
|
|
101
|
-
|
|
102
|
-
//----------------------------------------------------------------
|
|
103
|
-
// Update status
|
|
104
|
-
//----------------------------------------------------------------
|
|
105
|
-
|
|
106
|
-
// TOOD: make a full hook reset (remount) on New identifier or client
|
|
107
|
-
useEffect(function () {
|
|
108
|
-
setStatus('loading');
|
|
109
|
-
}, [identifier]);
|
|
110
|
-
var updateFileStateRef = useCurrentValueRef(function () {
|
|
111
|
-
if (fileState) {
|
|
112
|
-
// do not update the status if the status is final
|
|
113
|
-
if (['complete', 'error', 'failed-processing'].includes(status)) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (fileState.status !== 'error') {
|
|
117
|
-
var mediaType = 'mediaType' in fileState ? fileState.mediaType : undefined;
|
|
118
|
-
var isPreviewable = !!mediaType && ['audio', 'video', 'image', 'doc'].indexOf(mediaType) > -1;
|
|
119
|
-
var isPreviewableFileState = !!fileState.preview;
|
|
120
|
-
var isSupportedLocalPreview = mediaType === 'image' || mediaType === 'video';
|
|
121
|
-
var hasLocalPreview = !isBannedLocalPreview && isPreviewableFileState && isSupportedLocalPreview && !!fileState.mimeType && isMimeTypeSupportedByBrowser(fileState.mimeType);
|
|
122
|
-
var hasRemotePreview = isImageRepresentationReady(fileState);
|
|
123
|
-
var hasPreview = hasLocalPreview || hasRemotePreview;
|
|
124
|
-
var newStatus;
|
|
125
|
-
switch (fileState.status) {
|
|
126
|
-
case 'uploading':
|
|
127
|
-
case 'failed-processing':
|
|
128
|
-
case 'processing':
|
|
129
|
-
newStatus = fileState.status;
|
|
130
|
-
break;
|
|
131
|
-
case 'processed':
|
|
132
|
-
if (!isPreviewable || !hasPreview) {
|
|
133
|
-
newStatus = 'complete';
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
newStatus = 'loading-preview';
|
|
137
|
-
break;
|
|
138
|
-
default:
|
|
139
|
-
newStatus = 'loading';
|
|
140
|
-
}
|
|
141
|
-
setStatus(newStatus);
|
|
142
|
-
} else {
|
|
143
|
-
var e = new MediaFileStateError(fileState.id, fileState.reason, fileState.message, fileState.details);
|
|
144
|
-
var errorReason = status === 'uploading' ? 'upload' : 'metadata-fetch';
|
|
145
|
-
setError(new MediaFilePreviewError(errorReason, e));
|
|
146
|
-
setStatus('error');
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
useEffect(function () {
|
|
151
|
-
updateFileStateRef.current();
|
|
152
|
-
}, [fileState, updateFileStateRef]);
|
|
153
|
-
useEffect(function () {
|
|
154
|
-
if (previewDidRender &&
|
|
155
|
-
// We should't complete if status is uploading
|
|
156
|
-
['loading-preview', 'processing'].includes(status)) {
|
|
157
|
-
setStatus('complete');
|
|
158
|
-
// TODO MEX-788: add test for "do not remove the preview when unsubscribing".
|
|
159
|
-
setIsBannedLocalPreview(false); // CXP-2723 TODO: we might be able to remove this??
|
|
160
|
-
}
|
|
161
|
-
}, [previewDidRender, status]);
|
|
162
|
-
|
|
163
|
-
// CXP-2723 TODO: Create test cases for banning local preview after status is complete
|
|
164
|
-
|
|
165
|
-
//----------------------------------------------------------------
|
|
166
|
-
// Preview Fetch Helper
|
|
167
|
-
//----------------------------------------------------------------
|
|
168
|
-
var getAndCacheRemotePreviewRef = useCurrentValueRef(function () {
|
|
169
|
-
return getAndCacheRemotePreview(mediaClient, identifier.id, requestDimensions || {}, imageURLParams, mediaBlobUrlAttrs, traceContext);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
//----------------------------------------------------------------
|
|
173
|
-
// Cache SSR Preview
|
|
174
|
-
//----------------------------------------------------------------
|
|
175
|
-
useEffect(function () {
|
|
176
|
-
if (!skipRemote && ssr && !!preview && isSSRClientPreview(preview)) {
|
|
177
|
-
// Since the SSR preview brings the token in the query params,
|
|
178
|
-
// We need to fetch the remote preview to be able to cache it,
|
|
179
|
-
getAndCacheRemotePreviewRef.current().catch(function () {
|
|
180
|
-
// No need to log this error.
|
|
181
|
-
// If preview fails, it will be refetched later
|
|
182
|
-
//TODO: test this catch
|
|
183
|
-
// https://product-fabric.atlassian.net/browse/MEX-1071
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}, [preview, identifier, skipRemote, ssr, getAndCacheRemotePreviewRef]);
|
|
187
|
-
|
|
188
|
-
//----------------------------------------------------------------
|
|
189
|
-
// Refetch SRR Preview if dimensions from Server have changed and are bigger,
|
|
190
|
-
//----------------------------------------------------------------
|
|
191
|
-
useEffect(function () {
|
|
192
|
-
// CXP-2813 TODO: This is called too many times if the refetch failed. Should be called only once
|
|
193
|
-
if (preview && !skipRemote && isSSRDataPreview(preview) && isBigger(preview.dimensions, requestDimensions)) {
|
|
194
|
-
getAndCacheRemotePreviewRef.current().then(setPreview).catch(function (e) {
|
|
195
|
-
var wrappedError = ensureMediaFilePreviewError('remote-preview-fetch-ssr', e, true);
|
|
196
|
-
setNonCriticalError(wrappedError);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
}, [getAndCacheRemotePreviewRef, identifier, preview, requestDimensions, skipRemote]);
|
|
200
|
-
|
|
201
|
-
//----------------------------------------------------------------
|
|
202
|
-
// Upfront Preview
|
|
203
|
-
//----------------------------------------------------------------
|
|
204
|
-
useEffect(function () {
|
|
205
|
-
var resolveUpfrontPreview = /*#__PURE__*/function () {
|
|
206
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
207
|
-
var fetchedDimensions, newPreview, areValidFetchedDimensions;
|
|
208
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
209
|
-
while (1) switch (_context.prev = _context.next) {
|
|
210
|
-
case 0:
|
|
211
|
-
// We block any possible future call to this method regardless of the outcome (success or fail)
|
|
212
|
-
// If it fails, the normal preview fetch should occur after the file state is fetched anyways
|
|
213
|
-
wasResolvedUpfrontPreviewRef.current = true;
|
|
214
|
-
_context.prev = 1;
|
|
215
|
-
fetchedDimensions = _objectSpread({}, requestDimensions);
|
|
216
|
-
_context.next = 5;
|
|
217
|
-
return getAndCacheRemotePreviewRef.current();
|
|
218
|
-
case 5:
|
|
219
|
-
newPreview = _context.sent;
|
|
220
|
-
areValidFetchedDimensions = !isBigger(fetchedDimensions, requestDimensionsRef.current); // If there are new and bigger dimensions in the props, and the upfront preview is still resolving,
|
|
221
|
-
// the fetched preview is no longer valid, and thus, we dismiss it
|
|
222
|
-
if (areValidFetchedDimensions) {
|
|
223
|
-
setPreview(newPreview);
|
|
224
|
-
}
|
|
225
|
-
_context.next = 12;
|
|
226
|
-
break;
|
|
227
|
-
case 10:
|
|
228
|
-
_context.prev = 10;
|
|
229
|
-
_context.t0 = _context["catch"](1);
|
|
230
|
-
case 12:
|
|
231
|
-
case "end":
|
|
232
|
-
return _context.stop();
|
|
233
|
-
}
|
|
234
|
-
}, _callee, null, [[1, 10]]);
|
|
235
|
-
}));
|
|
236
|
-
return function resolveUpfrontPreview() {
|
|
237
|
-
return _ref2.apply(this, arguments);
|
|
238
|
-
};
|
|
239
|
-
}();
|
|
240
|
-
|
|
241
|
-
// CXP-2723 TODO: `hadSSRPreview` is most likely redundant
|
|
242
|
-
var hadSSRPreview = ssr === 'client' && !!prevPreview && isSSRClientPreview(prevPreview);
|
|
243
|
-
if (!preview && !wasResolvedUpfrontPreviewRef.current && (!skipRemote || hadSSRPreview)) {
|
|
244
|
-
resolveUpfrontPreview();
|
|
245
|
-
}
|
|
246
|
-
}, [preview, requestDimensions, requestDimensionsRef, getAndCacheRemotePreviewRef, identifier, skipRemote, prevPreview, ssr]);
|
|
247
|
-
|
|
248
|
-
//----------------------------------------------------------------
|
|
249
|
-
// Fetch Preview
|
|
250
|
-
//----------------------------------------------------------------
|
|
251
|
-
|
|
252
|
-
var resolvePreviewRef = useCurrentValueRef( /*#__PURE__*/function () {
|
|
253
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(identifier, fileState) {
|
|
254
|
-
var filePreview, isRemotePreviewReady, mode, cachedPreview, dimensionsAreBigger, localPreview, remotePreview, wrappedError;
|
|
255
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
256
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
257
|
-
case 0:
|
|
258
|
-
filePreview = isBannedLocalPreview ? undefined : fileState.status !== 'error' && 'mimeType' in fileState && isMimeTypeSupportedByBrowser(fileState.mimeType) ? fileState.preview : undefined;
|
|
259
|
-
isRemotePreviewReady = isImageRepresentationReady(fileState);
|
|
260
|
-
_context2.prev = 2;
|
|
261
|
-
mode = imageURLParams.mode;
|
|
262
|
-
cachedPreview = mediaFilePreviewCache.get(identifier.id, mode);
|
|
263
|
-
dimensionsAreBigger = isBigger(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, requestDimensions);
|
|
264
|
-
if (!(cachedPreview && !dimensionsAreBigger)) {
|
|
265
|
-
_context2.next = 8;
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
return _context2.abrupt("return", cachedPreview);
|
|
269
|
-
case 8:
|
|
270
|
-
_context2.prev = 8;
|
|
271
|
-
if (!filePreview) {
|
|
272
|
-
_context2.next = 15;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
_context2.next = 12;
|
|
276
|
-
return getAndCacheLocalPreview(identifier.id, filePreview, requestDimensions || {}, mode, mediaBlobUrlAttrs);
|
|
277
|
-
case 12:
|
|
278
|
-
localPreview = _context2.sent;
|
|
279
|
-
setPreview(localPreview);
|
|
280
|
-
return _context2.abrupt("return");
|
|
281
|
-
case 15:
|
|
282
|
-
_context2.next = 22;
|
|
283
|
-
break;
|
|
284
|
-
case 17:
|
|
285
|
-
_context2.prev = 17;
|
|
286
|
-
_context2.t0 = _context2["catch"](8);
|
|
287
|
-
/**
|
|
288
|
-
* We report the error if:
|
|
289
|
-
* - local preview is supported and fails
|
|
290
|
-
* - local preview is unsupported and remote preview is NOT READY
|
|
291
|
-
* i.e. the function was called for "no reason".
|
|
292
|
-
* We DON'T report the error if:
|
|
293
|
-
* - local preview is unsupported and remote preview IS READY
|
|
294
|
-
* i.e. local preview is available and not supported,
|
|
295
|
-
* but we are after the remote preview instead.
|
|
296
|
-
*/
|
|
297
|
-
if (!isUnsupportedLocalPreviewError(_context2.t0) || isUnsupportedLocalPreviewError(_context2.t0) && !isRemotePreviewReady) {
|
|
298
|
-
// CXP-2723 TODO: We might have to wrap this error in MediaCardError
|
|
299
|
-
setNonCriticalError(_context2.t0);
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* No matter the reason why the local preview failed, we break the process
|
|
303
|
-
* if there is no remote preview available
|
|
304
|
-
*/
|
|
305
|
-
if (isRemotePreviewReady) {
|
|
306
|
-
_context2.next = 22;
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
throw _context2.t0;
|
|
310
|
-
case 22:
|
|
311
|
-
if (isRemotePreviewReady) {
|
|
312
|
-
_context2.next = 24;
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
throw new MediaFilePreviewError('remote-preview-not-ready');
|
|
316
|
-
case 24:
|
|
317
|
-
_context2.next = 26;
|
|
318
|
-
return getAndCacheRemotePreviewRef.current();
|
|
319
|
-
case 26:
|
|
320
|
-
remotePreview = _context2.sent;
|
|
321
|
-
setPreview(remotePreview);
|
|
322
|
-
return _context2.abrupt("return");
|
|
323
|
-
case 31:
|
|
324
|
-
_context2.prev = 31;
|
|
325
|
-
_context2.t1 = _context2["catch"](2);
|
|
326
|
-
wrappedError = ensureMediaFilePreviewError('preview-fetch', _context2.t1); // If remote preview fails, we set status 'error'
|
|
327
|
-
// If local preview fails (i.e, no remote preview available),
|
|
328
|
-
// we can stay in the same status until there is a remote preview available
|
|
329
|
-
// If it's any other error we set status 'error'
|
|
330
|
-
if (isLocalPreviewError(wrappedError)) {
|
|
331
|
-
// This error should already been logged inside the getCardPreview. No need to log it here.
|
|
332
|
-
setIsBannedLocalPreview(true);
|
|
333
|
-
} else {
|
|
334
|
-
if (!['complete', 'error', 'failed-processing'].includes(status)) {
|
|
335
|
-
setStatus('error');
|
|
336
|
-
setError(wrappedError);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
case 35:
|
|
340
|
-
case "end":
|
|
341
|
-
return _context2.stop();
|
|
342
|
-
}
|
|
343
|
-
}, _callee2, null, [[2, 31], [8, 17]]);
|
|
344
|
-
}));
|
|
345
|
-
return function (_x, _x2) {
|
|
346
|
-
return _ref3.apply(this, arguments);
|
|
347
|
-
};
|
|
348
|
-
}());
|
|
349
|
-
useEffect(function () {
|
|
350
|
-
if (fileState && wasResolvedUpfrontPreviewRef.current && isPreviewableStatus(status, extractFilePreviewStatus(fileState, isBannedLocalPreview)) && (!preview || isBigger(prevRequestDimensions, requestDimensions))) {
|
|
351
|
-
resolvePreviewRef.current(identifier, fileState);
|
|
352
|
-
}
|
|
353
|
-
}, [fileState, identifier, isBannedLocalPreview, prevRequestDimensions, preview, requestDimensions, resolvePreviewRef, status]);
|
|
354
|
-
|
|
355
|
-
//----------------------------------------------------------------
|
|
356
|
-
// RETURN
|
|
357
|
-
//----------------------------------------------------------------
|
|
358
|
-
|
|
359
|
-
var onImageError = useCallback(function (newPreview) {
|
|
360
|
-
if (newPreview) {
|
|
361
|
-
var failedSSRObject = _objectSpread({
|
|
362
|
-
status: 'fail'
|
|
363
|
-
}, extractErrorInfo(new ImageLoadError(newPreview.source)));
|
|
364
|
-
if (isSSRClientPreview(newPreview)) {
|
|
365
|
-
ssrReliabilityRef.current.client = failedSSRObject;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/*
|
|
369
|
-
If the preview failed and it comes from server (global scope / ssrData), it means that we have reused it in client and the error counts for both: server & client.
|
|
370
|
-
*/
|
|
371
|
-
|
|
372
|
-
if (isSSRDataPreview(newPreview)) {
|
|
373
|
-
ssrReliabilityRef.current.server = failedSSRObject;
|
|
374
|
-
ssrReliabilityRef.current.client = failedSSRObject;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// If the dataURI has been replaced, we can dismiss this error
|
|
379
|
-
if ((newPreview === null || newPreview === void 0 ? void 0 : newPreview.dataURI) !== (preview === null || preview === void 0 ? void 0 : preview.dataURI)) {
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
var error = new ImageLoadError(newPreview === null || newPreview === void 0 ? void 0 : newPreview.source);
|
|
383
|
-
var isLocal = newPreview && isLocalPreview(newPreview);
|
|
384
|
-
var isSSR = newPreview && (isSSRClientPreview(newPreview) || isSSRDataPreview(newPreview));
|
|
385
|
-
if (isLocal || isSSR) {
|
|
386
|
-
if (isLocal) {
|
|
387
|
-
setIsBannedLocalPreview(true);
|
|
388
|
-
setNonCriticalError(error);
|
|
389
|
-
}
|
|
390
|
-
var fileImageMode = imageResizeModeToFileImageMode(resizeMode);
|
|
391
|
-
mediaFilePreviewCache.remove(identifier.id, fileImageMode);
|
|
392
|
-
setPreview(undefined);
|
|
393
|
-
} else {
|
|
394
|
-
if (!['complete', 'error', 'failed-processing'].includes(status)) {
|
|
395
|
-
setStatus('error');
|
|
396
|
-
setError(error);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}, [identifier.id, preview === null || preview === void 0 ? void 0 : preview.dataURI, resizeMode, status]);
|
|
400
|
-
var onImageLoad = useCallback(function (newPreview) {
|
|
401
|
-
if (newPreview) {
|
|
402
|
-
if (isSSRClientPreview(newPreview) && ssrReliabilityRef.current.client.status === 'unknown') {
|
|
403
|
-
ssrReliabilityRef.current.client = {
|
|
404
|
-
status: 'success'
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/*
|
|
409
|
-
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.
|
|
410
|
-
*/
|
|
411
|
-
|
|
412
|
-
if (isSSRDataPreview(newPreview) && ssrReliabilityRef.current.server.status === 'unknown') {
|
|
413
|
-
ssrReliabilityRef.current.server = {
|
|
414
|
-
status: 'success'
|
|
415
|
-
};
|
|
416
|
-
ssrReliabilityRef.current.client = {
|
|
417
|
-
status: 'success'
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// If the dataURI has been replaced, we can dismiss this callback
|
|
423
|
-
if ((newPreview === null || newPreview === void 0 ? void 0 : newPreview.dataURI) !== (preview === null || preview === void 0 ? void 0 : preview.dataURI)) {
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
}, [preview === null || preview === void 0 ? void 0 : preview.dataURI]);
|
|
427
|
-
|
|
428
|
-
// FOR SSR
|
|
429
|
-
var getScriptProps = function getScriptProps() {
|
|
430
|
-
var _ssrReliabilityRef$cu;
|
|
431
|
-
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);
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
// CXP-2723 TODO: should consider simplifying our analytics, and how
|
|
435
|
-
// we might get rid of ssrReliabiltyRef from our hook
|
|
436
|
-
return {
|
|
437
|
-
preview: preview,
|
|
438
|
-
error: error,
|
|
439
|
-
nonCriticalError: nonCriticalError,
|
|
440
|
-
ssrReliabilityRef: ssrReliabilityRef,
|
|
441
|
-
onImageError: onImageError,
|
|
442
|
-
onImageLoad: onImageLoad,
|
|
443
|
-
getScriptProps: getScriptProps
|
|
444
|
-
};
|
|
445
|
-
};
|
|
446
|
-
var initialSsrReliability = {
|
|
447
|
-
server: {
|
|
448
|
-
status: 'unknown'
|
|
449
|
-
},
|
|
450
|
-
client: {
|
|
451
|
-
status: 'unknown'
|
|
452
|
-
}
|
|
453
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { MediaClientErrorReason } from '@atlaskit/media-client';
|
|
2
|
-
import { SuccessAttributes, MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
-
import { MediaFilePreviewError, MediaFilePreviewErrorPrimaryReason } from './errors';
|
|
4
|
-
export type FailedErrorFailReason = MediaFilePreviewErrorPrimaryReason | 'nativeError';
|
|
5
|
-
export type MediaFilePreviewErrorInfo = {
|
|
6
|
-
failReason: FailedErrorFailReason;
|
|
7
|
-
error: MediaClientErrorReason | 'nativeError';
|
|
8
|
-
errorDetail: string;
|
|
9
|
-
metadataTraceContext?: MediaTraceContext;
|
|
10
|
-
};
|
|
11
|
-
export type SSRStatusFail = MediaFilePreviewErrorInfo & {
|
|
12
|
-
status: 'fail';
|
|
13
|
-
};
|
|
14
|
-
type SSRStatusSuccess = SuccessAttributes;
|
|
15
|
-
type SSRStatusUnknown = {
|
|
16
|
-
status: 'unknown';
|
|
17
|
-
};
|
|
18
|
-
type SSRStatusAttributes = SSRStatusSuccess | SSRStatusFail | SSRStatusUnknown;
|
|
19
|
-
export type SSRStatus = {
|
|
20
|
-
server: SSRStatusAttributes;
|
|
21
|
-
client: SSRStatusAttributes;
|
|
22
|
-
};
|
|
23
|
-
export declare const getErrorTraceContext: (error: MediaFilePreviewError) => MediaTraceContext | undefined;
|
|
24
|
-
export declare const getRenderErrorFailReason: (error: MediaFilePreviewError) => FailedErrorFailReason;
|
|
25
|
-
export declare const getRenderErrorErrorReason: (error: MediaFilePreviewError) => MediaClientErrorReason | 'nativeError';
|
|
26
|
-
export declare const getRenderErrorErrorDetail: (error: MediaFilePreviewError) => string;
|
|
27
|
-
export declare const extractErrorInfo: (error: MediaFilePreviewError, metadataTraceContext?: MediaTraceContext) => MediaFilePreviewErrorInfo;
|
|
28
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { MediaFileStateError } from '@atlaskit/media-client-react';
|
|
2
|
-
import { MediaClientErrorReason } from '@atlaskit/media-client';
|
|
3
|
-
import { MediaFilePreview } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* Primary reason is logged through Data Portal.
|
|
6
|
-
* Make sure all the values are whitelisted in Measure -> Event Regitry -> "mediaCardRender failed" event
|
|
7
|
-
*/
|
|
8
|
-
export type MediaFilePreviewErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
|
|
9
|
-
export type ImageLoadPrimaryReason = 'cache-remote-uri' | 'cache-local-uri' | 'local-uri' | 'remote-uri' | 'external-uri' | 'unknown-uri';
|
|
10
|
-
export type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready' | 'remote-preview-fetch-ssr';
|
|
11
|
-
export type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-unsupported' | 'local-preview-rejected' | 'local-preview-image' | 'local-preview-video';
|
|
12
|
-
export type SsrPreviewPrimaryReason = 'ssr-client-uri' | 'ssr-client-load' | 'ssr-server-uri' | 'ssr-server-load';
|
|
13
|
-
export declare class MediaFilePreviewError extends Error {
|
|
14
|
-
readonly primaryReason: MediaFilePreviewErrorPrimaryReason;
|
|
15
|
-
readonly secondaryError?: Error | undefined;
|
|
16
|
-
constructor(primaryReason: MediaFilePreviewErrorPrimaryReason, secondaryError?: Error | undefined);
|
|
17
|
-
}
|
|
18
|
-
export declare class LocalPreviewError extends MediaFilePreviewError {
|
|
19
|
-
readonly primaryReason: LocalPreviewPrimaryReason;
|
|
20
|
-
readonly secondaryError?: Error | undefined;
|
|
21
|
-
constructor(primaryReason: LocalPreviewPrimaryReason, secondaryError?: Error | undefined);
|
|
22
|
-
}
|
|
23
|
-
export declare class RemotePreviewError extends MediaFilePreviewError {
|
|
24
|
-
readonly primaryReason: RemotePreviewPrimaryReason;
|
|
25
|
-
readonly secondaryError?: Error | undefined;
|
|
26
|
-
constructor(primaryReason: RemotePreviewPrimaryReason, secondaryError?: Error | undefined);
|
|
27
|
-
}
|
|
28
|
-
export declare class SsrPreviewError extends MediaFilePreviewError {
|
|
29
|
-
readonly primaryReason: SsrPreviewPrimaryReason;
|
|
30
|
-
readonly secondaryError?: Error | undefined;
|
|
31
|
-
constructor(primaryReason: SsrPreviewPrimaryReason, secondaryError?: Error | undefined);
|
|
32
|
-
}
|
|
33
|
-
export declare class ImageLoadError extends MediaFilePreviewError {
|
|
34
|
-
constructor(source?: MediaFilePreview['source']);
|
|
35
|
-
}
|
|
36
|
-
export declare function isMediaFilePreviewError(err: Error): err is MediaFilePreviewError;
|
|
37
|
-
export declare const isLocalPreviewError: (err: Error) => err is LocalPreviewError;
|
|
38
|
-
export declare const isRemotePreviewError: (err: Error) => err is RemotePreviewError;
|
|
39
|
-
export declare const isUnsupportedLocalPreviewError: (err: Error) => boolean;
|
|
40
|
-
export declare const ensureMediaFilePreviewError: (primaryReason: MediaFilePreviewErrorPrimaryReason, error: Error, updatePrimaryReason?: boolean) => MediaFilePreviewError;
|
|
41
|
-
export declare function isMediaFileStateError(err: Error): err is MediaFileStateError;
|
|
42
|
-
export declare function getFileStateErrorReason(err: MediaFileStateError): MediaClientErrorReason | 'unknown';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ImageResizeMode } from '@atlaskit/media-client';
|
|
2
|
-
import { ObjectURLCache } from './objectURLCache';
|
|
3
|
-
import { MediaFilePreview } from '../types';
|
|
4
|
-
type Mode = ImageResizeMode | undefined;
|
|
5
|
-
export declare const getCacheKey: (id: string, mode: Mode) => string;
|
|
6
|
-
export interface MediaFilePreviewCache {
|
|
7
|
-
get(id: string, mode: Mode): MediaFilePreview | undefined;
|
|
8
|
-
set(id: string, mode: Mode, cardPreview: MediaFilePreview): void;
|
|
9
|
-
remove(id: string, mode: Mode): void;
|
|
10
|
-
clear(): void;
|
|
11
|
-
}
|
|
12
|
-
export declare class CardPreviewCacheImpl implements MediaFilePreviewCache {
|
|
13
|
-
private previewCache;
|
|
14
|
-
constructor(previewCache: ObjectURLCache);
|
|
15
|
-
get: (id: string, mode: Mode) => MediaFilePreview | undefined;
|
|
16
|
-
set: (id: string, mode: Mode, cardPreview: MediaFilePreview) => void;
|
|
17
|
-
remove: (id: string, mode: Mode) => void;
|
|
18
|
-
clear: () => void;
|
|
19
|
-
}
|
|
20
|
-
export declare const mediaFilePreviewCache: CardPreviewCacheImpl;
|
|
21
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { MediaFilePreviewStatus, FilePreviewStatus } from '../types';
|
|
2
|
-
import { FileState } from '@atlaskit/media-client';
|
|
3
|
-
export declare const extractFilePreviewStatus: (fileState: FileState, isBannedLocalPreview: boolean) => FilePreviewStatus;
|
|
4
|
-
export declare const isPreviewableStatus: (cardStatus: MediaFilePreviewStatus, { isPreviewable, hasPreview, isSupportedByBrowser }: FilePreviewStatus) => boolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MediaClient, MediaStoreGetFileImageParams, MediaBlobUrlAttrs, FilePreview } from '@atlaskit/media-client';
|
|
2
|
-
import { SSR, MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
-
import { MediaFilePreviewDimensions, MediaFilePreview } from '../types';
|
|
4
|
-
export declare const getSSRPreview: (ssr: SSR, mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs) => MediaFilePreview;
|
|
5
|
-
export declare const isLocalPreview: (preview: MediaFilePreview) => boolean;
|
|
6
|
-
export declare const isSSRClientPreview: (preview: MediaFilePreview) => boolean;
|
|
7
|
-
export declare const isSSRDataPreview: (preview: MediaFilePreview) => boolean;
|
|
8
|
-
export declare const getAndCacheRemotePreview: (mediaClient: MediaClient, id: string, dimensions: MediaFilePreviewDimensions, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs, traceContext?: MediaTraceContext) => Promise<MediaFilePreview>;
|
|
9
|
-
export declare const getAndCacheLocalPreview: (id: string, filePreview: FilePreview | Promise<FilePreview>, dimensions: MediaFilePreviewDimensions, mode: MediaStoreGetFileImageParams['mode'], mediaBlobUrlAttrs?: MediaBlobUrlAttrs) => Promise<MediaFilePreview>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { MediaClient, FilePreview, MediaStoreGetFileImageParams, MediaType } from '@atlaskit/media-client';
|
|
2
|
-
import { MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
-
import { MediaFilePreview } from '../types';
|
|
4
|
-
/**
|
|
5
|
-
* This method tells the support for the media
|
|
6
|
-
* types covered in getCardPreviewFromFilePreview
|
|
7
|
-
*/
|
|
8
|
-
export declare const isSupportedLocalPreview: (mediaType?: MediaType) => boolean;
|
|
9
|
-
export declare const getLocalPreview: (filePreview: FilePreview | Promise<FilePreview>) => Promise<MediaFilePreview>;
|
|
10
|
-
export declare const getRemotePreview: (mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<MediaFilePreview>;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { mediaFilePreviewCache } from './cache';
|
|
2
|
-
export { isPreviewableStatus, extractFilePreviewStatus, } from './filePreviewStatus';
|
|
3
|
-
export { getSSRPreview, isLocalPreview, isSSRClientPreview, isSSRDataPreview, getAndCacheRemotePreview, getAndCacheLocalPreview, } from './getPreview';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MediaFilePreview } from '../types';
|
|
2
|
-
export declare const PREVIEW_CACHE_LRU_SIZE = 50;
|
|
3
|
-
export declare class ObjectURLCache {
|
|
4
|
-
private readonly cache;
|
|
5
|
-
constructor(size: number);
|
|
6
|
-
has(key: string): boolean;
|
|
7
|
-
get(key: string): MediaFilePreview | undefined;
|
|
8
|
-
set(key: string, value: MediaFilePreview): void;
|
|
9
|
-
remove(key: string): void;
|
|
10
|
-
clear(): void;
|
|
11
|
-
}
|
|
12
|
-
export declare const createObjectURLCache: () => ObjectURLCache;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const takeSnapshot: (blob: Blob) => Promise<string>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FileIdentifier } from '@atlaskit/media-client';
|
|
3
|
-
import { NumericalCardDimensions } from '@atlaskit/media-common';
|
|
4
|
-
import { MediaCardErrorInfo } from '../../../../utils/analytics';
|
|
5
|
-
import { MediaCardSsr } from './types';
|
|
6
|
-
export declare const GLOBAL_MEDIA_CARD_SSR = "mediaCardSsr";
|
|
7
|
-
export declare const GLOBAL_MEDIA_NAMESPACE = "__MEDIA_INTERNAL";
|
|
8
|
-
export type MediaGlobalScope = {
|
|
9
|
-
[GLOBAL_MEDIA_CARD_SSR]?: MediaCardSsr;
|
|
10
|
-
};
|
|
11
|
-
export declare function getMediaGlobalScope(globalScope?: any): MediaGlobalScope;
|
|
12
|
-
export declare function getMediaCardSSR(globalScope?: any): MediaCardSsr;
|
|
13
|
-
export declare const getKey: ({ id, collectionName, occurrenceKey }: FileIdentifier) => string;
|
|
14
|
-
export declare const storeDataURI: (key: string, dataURI?: string, dimensions?: Partial<NumericalCardDimensions>, error?: MediaCardErrorInfo, globalScope?: any) => void;
|
|
15
|
-
export declare const generateScriptProps: (identifier: FileIdentifier, dataURI?: string, dimensions?: Partial<NumericalCardDimensions>, error?: MediaCardErrorInfo) => React.ScriptHTMLAttributes<HTMLScriptElement>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { GLOBAL_MEDIA_NAMESPACE, GLOBAL_MEDIA_CARD_SSR, generateScriptProps, getKey, } from './globalScope';
|
|
2
|
-
export { getSSRData } from './getSSRData';
|
|
3
|
-
export type { MediaCardSsrData, MediaCardSsr } from './types';
|
|
4
|
-
export type { MediaGlobalScope } from './globalScope';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { NumericalCardDimensions } from '@atlaskit/media-common';
|
|
2
|
-
import { MediaCardErrorInfo } from '../../../../utils/analytics';
|
|
3
|
-
export type MediaCardSsrData = {
|
|
4
|
-
dataURI?: string;
|
|
5
|
-
dimensions?: Partial<NumericalCardDimensions>;
|
|
6
|
-
error?: MediaCardErrorInfo;
|
|
7
|
-
};
|
|
8
|
-
export type MediaCardSsr = Record<string, MediaCardSsrData>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { MediaFilePreviewDimensions } from './types';
|
|
2
|
-
import { MutableRefObject } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* Checks if at least one of next dimensions is bigger than current
|
|
5
|
-
* If a single dimension is undefined, returns false
|
|
6
|
-
*/
|
|
7
|
-
export declare const isBigger: (current?: MediaFilePreviewDimensions, next?: MediaFilePreviewDimensions) => boolean;
|
|
8
|
-
export declare const createRequestDimensions: (dimensions: Partial<MediaFilePreviewDimensions>) => Partial<MediaFilePreviewDimensions> | undefined;
|
|
9
|
-
/** Stores the provided value in a ref object to avoid "component rerenders" when the value is used as a hook dependency */
|
|
10
|
-
export declare function useCurrentValueRef<T>(value: T): MutableRefObject<T>;
|
|
11
|
-
export declare function usePrevious<T>(value: T | undefined): T | undefined;
|