@atlaskit/media-card 77.4.10 → 77.5.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 +12 -0
- package/dist/cjs/card/card.js +1 -1
- package/dist/cjs/card/cardLoader.js +3 -47
- package/dist/cjs/card/cardWithMediaClient.js +26 -0
- 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/cardV2Loader.js +3 -54
- package/dist/cjs/card/v2/cardViewV2.js +7 -6
- package/dist/cjs/card/v2/cardWithMediaClientV2.js +34 -0
- package/dist/cjs/card/v2/useFilePreview/errors.js +132 -0
- package/dist/cjs/card/v2/useFilePreview/getPreview/cache.js +39 -0
- package/dist/cjs/card/v2/useFilePreview/getPreview/filePreviewStatus.js +45 -0
- package/dist/cjs/card/v2/useFilePreview/getPreview/getPreview.js +119 -0
- package/dist/cjs/card/v2/useFilePreview/getPreview/helpers.js +167 -0
- package/dist/cjs/card/v2/useFilePreview/getPreview/index.js +62 -0
- package/dist/cjs/card/v2/useFilePreview/getPreview/objectURLCache.js +85 -0
- package/dist/cjs/card/v2/useFilePreview/getPreview/videoSnapshot.js +58 -0
- package/dist/cjs/card/v2/useFilePreview/globalScope/getSSRData.js +14 -0
- package/dist/cjs/card/v2/useFilePreview/globalScope/globalScope.js +66 -0
- package/dist/cjs/card/v2/useFilePreview/globalScope/index.js +37 -0
- package/dist/cjs/card/v2/useFilePreview/globalScope/printScript.js +32 -0
- package/dist/cjs/card/v2/useFilePreview/globalScope/types.js +5 -0
- package/dist/cjs/card/v2/useFilePreview/helpers.js +64 -0
- package/dist/cjs/card/v2/useFilePreview/index.js +12 -0
- package/dist/cjs/card/v2/useFilePreview/types.js +5 -0
- package/dist/cjs/card/v2/{useFilePreview.js → useFilePreview/useFilePreview.js} +58 -194
- 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/cardLoader.js +2 -32
- package/dist/es2019/card/cardWithMediaClient.js +21 -0
- 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/cardV2Loader.js +2 -35
- package/dist/es2019/card/v2/cardViewV2.js +7 -6
- package/dist/es2019/card/v2/cardWithMediaClientV2.js +25 -0
- package/dist/es2019/card/v2/useFilePreview/errors.js +81 -0
- package/dist/es2019/card/v2/useFilePreview/getPreview/cache.js +30 -0
- package/dist/es2019/card/v2/useFilePreview/getPreview/filePreviewStatus.js +43 -0
- package/dist/es2019/card/v2/useFilePreview/getPreview/getPreview.js +75 -0
- package/dist/es2019/card/v2/useFilePreview/getPreview/helpers.js +76 -0
- package/dist/es2019/card/v2/useFilePreview/getPreview/index.js +3 -0
- package/dist/es2019/card/v2/useFilePreview/getPreview/objectURLCache.js +44 -0
- package/dist/es2019/card/v2/useFilePreview/getPreview/videoSnapshot.js +36 -0
- package/dist/es2019/card/v2/useFilePreview/globalScope/getSSRData.js +8 -0
- package/dist/es2019/card/v2/useFilePreview/globalScope/globalScope.js +48 -0
- package/dist/es2019/card/v2/useFilePreview/globalScope/index.js +2 -0
- package/dist/es2019/card/v2/useFilePreview/globalScope/printScript.js +16 -0
- package/dist/es2019/card/v2/useFilePreview/globalScope/types.js +1 -0
- package/dist/es2019/card/v2/useFilePreview/helpers.js +61 -0
- package/dist/es2019/card/v2/useFilePreview/index.js +1 -0
- package/dist/es2019/card/v2/useFilePreview/types.js +1 -0
- package/dist/es2019/card/v2/{useFilePreview.js → useFilePreview/useFilePreview.js} +18 -132
- 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/cardLoader.js +3 -43
- package/dist/esm/card/cardWithMediaClient.js +19 -0
- 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/cardV2Loader.js +3 -50
- package/dist/esm/card/v2/cardViewV2.js +7 -6
- package/dist/esm/card/v2/cardWithMediaClientV2.js +27 -0
- package/dist/esm/card/v2/useFilePreview/errors.js +124 -0
- package/dist/esm/card/v2/useFilePreview/getPreview/cache.js +32 -0
- package/dist/esm/card/v2/useFilePreview/getPreview/filePreviewStatus.js +40 -0
- package/dist/esm/card/v2/useFilePreview/getPreview/getPreview.js +112 -0
- package/dist/esm/card/v2/useFilePreview/getPreview/helpers.js +160 -0
- package/dist/esm/card/v2/useFilePreview/getPreview/index.js +3 -0
- package/dist/esm/card/v2/useFilePreview/getPreview/objectURLCache.js +78 -0
- package/dist/esm/card/v2/useFilePreview/getPreview/videoSnapshot.js +51 -0
- package/dist/esm/card/v2/useFilePreview/globalScope/getSSRData.js +8 -0
- package/dist/esm/card/v2/useFilePreview/globalScope/globalScope.js +56 -0
- package/dist/esm/card/v2/useFilePreview/globalScope/index.js +2 -0
- package/dist/esm/card/v2/useFilePreview/globalScope/printScript.js +25 -0
- package/dist/esm/card/v2/useFilePreview/globalScope/types.js +1 -0
- package/dist/esm/card/v2/useFilePreview/helpers.js +57 -0
- package/dist/esm/card/v2/useFilePreview/index.js +1 -0
- package/dist/esm/card/v2/useFilePreview/types.js +1 -0
- package/dist/esm/card/v2/{useFilePreview.js → useFilePreview/useFilePreview.js} +41 -177
- package/dist/esm/inline/loader.js +1 -1
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/types/card/cardLoader.d.ts +1 -3
- package/dist/types/card/cardSwitcher.d.ts +1 -1
- package/dist/types/card/cardWithMediaClient.d.ts +3 -0
- package/dist/types/card/types.d.ts +3 -0
- package/dist/types/card/v2/cardV2Loader.d.ts +1 -1
- package/dist/types/card/v2/cardViewV2.d.ts +5 -4
- package/dist/types/card/v2/cardWithMediaClientV2.d.ts +3 -0
- package/dist/types/card/v2/useFilePreview/errors.d.ts +38 -0
- package/dist/types/card/v2/useFilePreview/getPreview/cache.d.ts +21 -0
- package/dist/types/card/v2/useFilePreview/getPreview/filePreviewStatus.d.ts +4 -0
- package/dist/types/card/v2/useFilePreview/getPreview/getPreview.d.ts +9 -0
- package/dist/types/card/v2/useFilePreview/getPreview/helpers.d.ts +10 -0
- package/dist/types/card/v2/useFilePreview/getPreview/index.d.ts +3 -0
- package/dist/types/card/v2/useFilePreview/getPreview/objectURLCache.d.ts +12 -0
- package/dist/types/card/v2/useFilePreview/getPreview/videoSnapshot.d.ts +1 -0
- package/dist/types/card/v2/useFilePreview/globalScope/getSSRData.d.ts +3 -0
- package/dist/types/card/v2/useFilePreview/globalScope/globalScope.d.ts +15 -0
- package/dist/types/card/v2/useFilePreview/globalScope/index.d.ts +4 -0
- package/dist/types/card/v2/useFilePreview/globalScope/printScript.d.ts +2 -0
- package/dist/types/card/v2/useFilePreview/globalScope/types.d.ts +8 -0
- package/dist/types/card/v2/useFilePreview/helpers.d.ts +11 -0
- package/dist/types/card/v2/useFilePreview/index.d.ts +2 -0
- package/dist/types/card/v2/useFilePreview/types.d.ts +18 -0
- package/dist/{types-ts4.5/card/v2 → types/card/v2/useFilePreview}/useFilePreview.d.ts +8 -8
- package/dist/types-ts4.5/card/cardLoader.d.ts +1 -3
- package/dist/types-ts4.5/card/cardSwitcher.d.ts +1 -1
- package/dist/types-ts4.5/card/cardWithMediaClient.d.ts +3 -0
- package/dist/types-ts4.5/card/types.d.ts +3 -0
- package/dist/types-ts4.5/card/v2/cardV2Loader.d.ts +1 -1
- package/dist/types-ts4.5/card/v2/cardViewV2.d.ts +5 -4
- package/dist/types-ts4.5/card/v2/cardWithMediaClientV2.d.ts +3 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/errors.d.ts +38 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/cache.d.ts +21 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/filePreviewStatus.d.ts +4 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/getPreview.d.ts +9 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/helpers.d.ts +10 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/index.d.ts +3 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/objectURLCache.d.ts +12 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/getPreview/videoSnapshot.d.ts +1 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/getSSRData.d.ts +3 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/globalScope.d.ts +15 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/index.d.ts +4 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/printScript.d.ts +2 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/globalScope/types.d.ts +8 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/helpers.d.ts +11 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/index.d.ts +2 -0
- package/dist/types-ts4.5/card/v2/useFilePreview/types.d.ts +18 -0
- package/dist/{types/card/v2 → types-ts4.5/card/v2/useFilePreview}/useFilePreview.d.ts +8 -8
- package/package.json +1 -1
|
@@ -4,21 +4,15 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
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
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 {
|
|
7
|
+
import { imageResizeModeToFileImageMode, isImageRepresentationReady } from '@atlaskit/media-client';
|
|
8
8
|
import { MediaFileStateError, useFileState, useMediaClient } from '@atlaskit/media-client-react';
|
|
9
|
-
import {
|
|
10
|
-
import { getOrientation } from '@atlaskit/media-ui';
|
|
9
|
+
import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
|
|
11
10
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
12
|
-
import {
|
|
13
|
-
import { extractErrorInfo } from '
|
|
14
|
-
import { isBigger } from '
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { useCurrentValueRef } from '../../utils/useCurrentValueRef';
|
|
18
|
-
import { usePrevious } from '../../utils/usePrevious';
|
|
19
|
-
import { takeSnapshot } from '../../utils/videoSnapshot';
|
|
20
|
-
import { fetchAndCacheRemotePreview, getCardPreviewFromCache, getSSRCardPreview, isLocalPreview, isSSRClientPreview, isSSRDataPreview, removeCardPreviewFromCache, shouldResolvePreview } from '../getCardPreview';
|
|
21
|
-
import cardPreviewCache from '../getCardPreview/cache';
|
|
11
|
+
import { ensureMediaFilePreviewError, ImageLoadError, isLocalPreviewError, isUnsupportedLocalPreviewError, MediaFilePreviewError } from './errors';
|
|
12
|
+
import { extractErrorInfo } from '../../../utils/analytics';
|
|
13
|
+
import { isBigger, createRequestDimensions, useCurrentValueRef, usePrevious } from './helpers';
|
|
14
|
+
import { generateScriptProps, getSSRData } from './globalScope';
|
|
15
|
+
import { getAndCacheRemotePreview, getSSRCardPreview, isLocalPreview, isSSRClientPreview, isSSRDataPreview, isPreviewableStatus, extractFilePreviewStatus, mediaFilePreviewCache, getAndCacheLocalPreview } from './getPreview';
|
|
22
16
|
export var useFilePreview = function useFilePreview(_ref) {
|
|
23
17
|
var _ref$resizeMode = _ref.resizeMode,
|
|
24
18
|
resizeMode = _ref$resizeMode === void 0 ? 'crop' : _ref$resizeMode,
|
|
@@ -88,7 +82,7 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
88
82
|
var cardPreview;
|
|
89
83
|
var id = identifier.id;
|
|
90
84
|
var fileImageMode = imageResizeModeToFileImageMode(resizeMode);
|
|
91
|
-
cardPreview =
|
|
85
|
+
cardPreview = mediaFilePreviewCache.get(id, fileImageMode);
|
|
92
86
|
if (!cardPreview && ssr) {
|
|
93
87
|
cardPreview = getSSRPreview(ssr, identifier, mediaClient);
|
|
94
88
|
}
|
|
@@ -113,11 +107,11 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
113
107
|
//----------------------------------------------------------------//
|
|
114
108
|
|
|
115
109
|
var fetchRemotePreviewRef = useCurrentValueRef(function (identifier) {
|
|
116
|
-
return
|
|
110
|
+
return getAndCacheRemotePreview(mediaClient, identifier.id, requestDimensions || {}, imageURLParams, mediaBlobUrlAttrs, traceContext);
|
|
117
111
|
});
|
|
118
112
|
var resolvePreviewRef = useCurrentValueRef( /*#__PURE__*/function () {
|
|
119
113
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier, fileState) {
|
|
120
|
-
var filePreview, isRemotePreviewReady, mode, cachedPreview, dimensionsAreBigger, localPreview,
|
|
114
|
+
var filePreview, isRemotePreviewReady, mode, cachedPreview, dimensionsAreBigger, localPreview, remotePreview, wrappedError;
|
|
121
115
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
122
116
|
while (1) switch (_context.prev = _context.next) {
|
|
123
117
|
case 0:
|
|
@@ -125,7 +119,7 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
125
119
|
isRemotePreviewReady = isImageRepresentationReady(fileState);
|
|
126
120
|
_context.prev = 2;
|
|
127
121
|
mode = imageURLParams.mode;
|
|
128
|
-
cachedPreview =
|
|
122
|
+
cachedPreview = mediaFilePreviewCache.get(identifier.id, mode);
|
|
129
123
|
dimensionsAreBigger = isBigger(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, requestDimensions);
|
|
130
124
|
if (!(cachedPreview && !dimensionsAreBigger)) {
|
|
131
125
|
_context.next = 8;
|
|
@@ -135,127 +129,21 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
135
129
|
case 8:
|
|
136
130
|
_context.prev = 8;
|
|
137
131
|
if (!filePreview) {
|
|
138
|
-
_context.next =
|
|
132
|
+
_context.next = 15;
|
|
139
133
|
break;
|
|
140
134
|
}
|
|
141
|
-
_context.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
135
|
+
_context.next = 12;
|
|
136
|
+
return getAndCacheLocalPreview(identifier.id, filePreview, requestDimensions || {}, mode, mediaBlobUrlAttrs);
|
|
137
|
+
case 12:
|
|
138
|
+
localPreview = _context.sent;
|
|
139
|
+
setCardPreview(localPreview);
|
|
140
|
+
return _context.abrupt("return");
|
|
141
|
+
case 15:
|
|
142
|
+
_context.next = 22;
|
|
148
143
|
break;
|
|
149
144
|
case 17:
|
|
150
145
|
_context.prev = 17;
|
|
151
|
-
_context.t0 = _context["catch"](
|
|
152
|
-
throw new LocalPreviewError('local-preview-rejected', _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
153
|
-
case 20:
|
|
154
|
-
if (!(typeof value === 'string')) {
|
|
155
|
-
_context.next = 24;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
localPreview = {
|
|
159
|
-
dataURI: value,
|
|
160
|
-
orientation: 1,
|
|
161
|
-
source: 'local'
|
|
162
|
-
};
|
|
163
|
-
_context.next = 57;
|
|
164
|
-
break;
|
|
165
|
-
case 24:
|
|
166
|
-
if (!(value instanceof Blob)) {
|
|
167
|
-
_context.next = 56;
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
_value = value, type = _value.type;
|
|
171
|
-
mediaType = getMediaTypeFromMimeType(type);
|
|
172
|
-
_context.t1 = mediaType;
|
|
173
|
-
_context.next = _context.t1 === 'image' ? 30 : _context.t1 === 'video' ? 42 : 53;
|
|
174
|
-
break;
|
|
175
|
-
case 30:
|
|
176
|
-
_context.prev = 30;
|
|
177
|
-
_context.next = 33;
|
|
178
|
-
return getOrientation(value);
|
|
179
|
-
case 33:
|
|
180
|
-
orientation = _context.sent;
|
|
181
|
-
_dataURI = URL.createObjectURL(value);
|
|
182
|
-
localPreview = {
|
|
183
|
-
dataURI: _dataURI,
|
|
184
|
-
orientation: orientation,
|
|
185
|
-
source: 'local'
|
|
186
|
-
};
|
|
187
|
-
_context.next = 41;
|
|
188
|
-
break;
|
|
189
|
-
case 38:
|
|
190
|
-
_context.prev = 38;
|
|
191
|
-
_context.t2 = _context["catch"](30);
|
|
192
|
-
throw new LocalPreviewError('local-preview-image', _context.t2 instanceof Error ? _context.t2 : undefined);
|
|
193
|
-
case 41:
|
|
194
|
-
return _context.abrupt("break", 54);
|
|
195
|
-
case 42:
|
|
196
|
-
_context.prev = 42;
|
|
197
|
-
_context.next = 45;
|
|
198
|
-
return takeSnapshot(value);
|
|
199
|
-
case 45:
|
|
200
|
-
_dataURI2 = _context.sent;
|
|
201
|
-
localPreview = {
|
|
202
|
-
dataURI: _dataURI2,
|
|
203
|
-
orientation: 1,
|
|
204
|
-
source: 'local'
|
|
205
|
-
};
|
|
206
|
-
_context.next = 52;
|
|
207
|
-
break;
|
|
208
|
-
case 49:
|
|
209
|
-
_context.prev = 49;
|
|
210
|
-
_context.t3 = _context["catch"](42);
|
|
211
|
-
throw new LocalPreviewError('local-preview-video', _context.t3 instanceof Error ? _context.t3 : undefined);
|
|
212
|
-
case 52:
|
|
213
|
-
return _context.abrupt("break", 54);
|
|
214
|
-
case 53:
|
|
215
|
-
throw new LocalPreviewError('local-preview-unsupported');
|
|
216
|
-
case 54:
|
|
217
|
-
_context.next = 57;
|
|
218
|
-
break;
|
|
219
|
-
case 56:
|
|
220
|
-
throw new LocalPreviewError('local-preview-unsupported');
|
|
221
|
-
case 57:
|
|
222
|
-
preview = _objectSpread(_objectSpread({}, localPreview), {}, {
|
|
223
|
-
dimensions: requestDimensions
|
|
224
|
-
});
|
|
225
|
-
_context.t4 = preview.source;
|
|
226
|
-
_context.next = _context.t4 === 'local' ? 61 : _context.t4 === 'remote' ? 63 : _context.t4 === 'ssr-server' ? 65 : _context.t4 === 'ssr-client' ? 67 : 69;
|
|
227
|
-
break;
|
|
228
|
-
case 61:
|
|
229
|
-
source = 'cache-local';
|
|
230
|
-
return _context.abrupt("break", 70);
|
|
231
|
-
case 63:
|
|
232
|
-
source = 'cache-remote';
|
|
233
|
-
return _context.abrupt("break", 70);
|
|
234
|
-
case 65:
|
|
235
|
-
source = 'cache-ssr-server';
|
|
236
|
-
return _context.abrupt("break", 70);
|
|
237
|
-
case 67:
|
|
238
|
-
source = 'cache-ssr-client';
|
|
239
|
-
return _context.abrupt("break", 70);
|
|
240
|
-
case 69:
|
|
241
|
-
source = preview.source;
|
|
242
|
-
case 70:
|
|
243
|
-
// We want to embed some meta context into dataURI for Copy/Paste to work.
|
|
244
|
-
dataURI = mediaBlobUrlAttrs ? addFileAttrsToUrl(preview.dataURI, mediaBlobUrlAttrs) : preview.dataURI; // We store new cardPreview into cache
|
|
245
|
-
cardPreviewCache.set(identifier.id, mode, _objectSpread(_objectSpread({}, preview), {}, {
|
|
246
|
-
source: source,
|
|
247
|
-
dataURI: dataURI
|
|
248
|
-
}));
|
|
249
|
-
setCardPreview(_objectSpread(_objectSpread({}, preview), {}, {
|
|
250
|
-
dataURI: dataURI
|
|
251
|
-
}));
|
|
252
|
-
return _context.abrupt("return");
|
|
253
|
-
case 74:
|
|
254
|
-
_context.next = 81;
|
|
255
|
-
break;
|
|
256
|
-
case 76:
|
|
257
|
-
_context.prev = 76;
|
|
258
|
-
_context.t5 = _context["catch"](8);
|
|
146
|
+
_context.t0 = _context["catch"](8);
|
|
259
147
|
/**
|
|
260
148
|
* We report the error if:
|
|
261
149
|
* - local preview is supported and fails
|
|
@@ -266,36 +154,36 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
266
154
|
* i.e. local preview is available and not supported,
|
|
267
155
|
* but we are after the remote preview instead.
|
|
268
156
|
*/
|
|
269
|
-
if (!isUnsupportedLocalPreviewError(_context.
|
|
157
|
+
if (!isUnsupportedLocalPreviewError(_context.t0) || isUnsupportedLocalPreviewError(_context.t0) && !isRemotePreviewReady) {
|
|
270
158
|
// CXP-2723 TODO: We might have to wrap this error in MediaCardError
|
|
271
|
-
setNonCriticalError(_context.
|
|
159
|
+
setNonCriticalError(_context.t0);
|
|
272
160
|
}
|
|
273
161
|
/**
|
|
274
162
|
* No matter the reason why the local preview failed, we break the process
|
|
275
163
|
* if there is no remote preview available
|
|
276
164
|
*/
|
|
277
165
|
if (isRemotePreviewReady) {
|
|
278
|
-
_context.next =
|
|
166
|
+
_context.next = 22;
|
|
279
167
|
break;
|
|
280
168
|
}
|
|
281
|
-
throw _context.
|
|
282
|
-
case
|
|
169
|
+
throw _context.t0;
|
|
170
|
+
case 22:
|
|
283
171
|
if (isRemotePreviewReady) {
|
|
284
|
-
_context.next =
|
|
172
|
+
_context.next = 24;
|
|
285
173
|
break;
|
|
286
174
|
}
|
|
287
|
-
throw new
|
|
288
|
-
case
|
|
289
|
-
_context.next =
|
|
175
|
+
throw new MediaFilePreviewError('remote-preview-not-ready');
|
|
176
|
+
case 24:
|
|
177
|
+
_context.next = 26;
|
|
290
178
|
return fetchRemotePreviewRef.current(identifier);
|
|
291
|
-
case
|
|
179
|
+
case 26:
|
|
292
180
|
remotePreview = _context.sent;
|
|
293
181
|
setCardPreview(remotePreview);
|
|
294
182
|
return _context.abrupt("return");
|
|
295
|
-
case
|
|
296
|
-
_context.prev =
|
|
297
|
-
_context.
|
|
298
|
-
wrappedError =
|
|
183
|
+
case 31:
|
|
184
|
+
_context.prev = 31;
|
|
185
|
+
_context.t1 = _context["catch"](2);
|
|
186
|
+
wrappedError = ensureMediaFilePreviewError('preview-fetch', _context.t1); // If remote preview fails, we set status 'error'
|
|
299
187
|
// If local preview fails (i.e, no remote preview available),
|
|
300
188
|
// we can stay in the same status until there is a remote preview available
|
|
301
189
|
// If it's any other error we set status 'error'
|
|
@@ -308,11 +196,11 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
308
196
|
setError(wrappedError);
|
|
309
197
|
}
|
|
310
198
|
}
|
|
311
|
-
case
|
|
199
|
+
case 35:
|
|
312
200
|
case "end":
|
|
313
201
|
return _context.stop();
|
|
314
202
|
}
|
|
315
|
-
}, _callee, null, [[2,
|
|
203
|
+
}, _callee, null, [[2, 31], [8, 17]]);
|
|
316
204
|
}));
|
|
317
205
|
return function (_x, _x2) {
|
|
318
206
|
return _ref2.apply(this, arguments);
|
|
@@ -379,7 +267,7 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
379
267
|
// refetchSRRPreview: If dimensions from Server have changed and are bigger,
|
|
380
268
|
// we need to refetch
|
|
381
269
|
fetchRemotePreviewRef.current(identifier).then(setCardPreview).catch(function (e) {
|
|
382
|
-
var wrappedError =
|
|
270
|
+
var wrappedError = ensureMediaFilePreviewError('remote-preview-fetch-ssr', e, true);
|
|
383
271
|
setNonCriticalError(wrappedError);
|
|
384
272
|
});
|
|
385
273
|
}
|
|
@@ -387,15 +275,7 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
387
275
|
// Both compare dimensions, but the above is only for SSR in order to refetchSRRPreview and
|
|
388
276
|
// will swallow any errors. Below logic only applies when there is no card preview or the dimensions
|
|
389
277
|
// are bigger.
|
|
390
|
-
if (fileState &&
|
|
391
|
-
status: status,
|
|
392
|
-
fileState: fileState,
|
|
393
|
-
prevDimensions: prevRequestDimensions,
|
|
394
|
-
dimensions: requestDimensions,
|
|
395
|
-
hasCardPreview: !!cardPreview,
|
|
396
|
-
isBannedLocalPreview: isBannedLocalPreview,
|
|
397
|
-
wasResolvedUpfrontPreview: wasResolvedUpfrontPreviewRef.current
|
|
398
|
-
})) {
|
|
278
|
+
if (fileState && wasResolvedUpfrontPreviewRef.current && isPreviewableStatus(status, extractFilePreviewStatus(fileState, isBannedLocalPreview)) && (!cardPreview || isBigger(prevRequestDimensions, requestDimensions))) {
|
|
399
279
|
resolvePreviewRef.current(identifier, fileState);
|
|
400
280
|
}
|
|
401
281
|
if (!skipRemote && ssr && !!cardPreview && isSSRClientPreview(cardPreview)) {
|
|
@@ -465,7 +345,7 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
465
345
|
} else {
|
|
466
346
|
var e = new MediaFileStateError(fileState.id, fileState.reason, fileState.message, fileState.details);
|
|
467
347
|
var errorReason = status === 'uploading' ? 'upload' : 'metadata-fetch';
|
|
468
|
-
setError(new
|
|
348
|
+
setError(new MediaFilePreviewError(errorReason, e));
|
|
469
349
|
setStatus('error');
|
|
470
350
|
}
|
|
471
351
|
}
|
|
@@ -505,7 +385,7 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
505
385
|
setNonCriticalError(error);
|
|
506
386
|
}
|
|
507
387
|
var fileImageMode = imageResizeModeToFileImageMode(resizeMode);
|
|
508
|
-
|
|
388
|
+
mediaFilePreviewCache.remove(identifier.id, fileImageMode);
|
|
509
389
|
setCardPreview(undefined);
|
|
510
390
|
} else {
|
|
511
391
|
if (!['complete', 'error', 'failed-processing'].includes(status)) {
|
|
@@ -564,22 +444,6 @@ export var useFilePreview = function useFilePreview(_ref) {
|
|
|
564
444
|
getScriptProps: getScriptProps
|
|
565
445
|
};
|
|
566
446
|
};
|
|
567
|
-
var createRequestDimensions = function createRequestDimensions(dimensions) {
|
|
568
|
-
if (!dimensions) {
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
571
|
-
var retinaFactor = isRetina() ? 2 : 1;
|
|
572
|
-
var width = dimensions.width,
|
|
573
|
-
height = dimensions.height;
|
|
574
|
-
var result = {};
|
|
575
|
-
if (width) {
|
|
576
|
-
result.width = width * retinaFactor;
|
|
577
|
-
}
|
|
578
|
-
if (height) {
|
|
579
|
-
result.height = height * retinaFactor;
|
|
580
|
-
}
|
|
581
|
-
return result;
|
|
582
|
-
};
|
|
583
447
|
var initialSsrReliability = {
|
|
584
448
|
server: {
|
|
585
449
|
status: 'unknown'
|
|
@@ -103,7 +103,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
103
103
|
ErrorBoundary = _this$state.ErrorBoundary;
|
|
104
104
|
var analyticsContext = {
|
|
105
105
|
packageVersion: "@atlaskit/media-card",
|
|
106
|
-
packageName: "77.
|
|
106
|
+
packageName: "77.5.1",
|
|
107
107
|
componentName: 'mediaInlineCard',
|
|
108
108
|
component: 'mediaInlineCard'
|
|
109
109
|
};
|
|
@@ -7,7 +7,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
|
|
|
7
7
|
import { MediaCardError } from '../errors';
|
|
8
8
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
9
9
|
var packageName = "@atlaskit/media-card";
|
|
10
|
-
var packageVersion = "77.
|
|
10
|
+
var packageVersion = "77.5.1";
|
|
11
11
|
var concurrentExperience;
|
|
12
12
|
var getExperience = function getExperience(id) {
|
|
13
13
|
if (!concurrentExperience) {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import type { CardBaseProps } from './card';
|
|
4
|
-
export type CardWithMediaClientConfigProps = WithMediaClientConfigProps<CardBaseProps>;
|
|
2
|
+
import type { CardWithMediaClientConfigProps } from './types';
|
|
5
3
|
declare const CardLoader: React.FC<CardWithMediaClientConfigProps>;
|
|
6
4
|
export default CardLoader;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { CardWithMediaClientConfigProps } from './
|
|
2
|
+
import { CardWithMediaClientConfigProps } from './types';
|
|
3
3
|
declare function CardSwitcher(props: CardWithMediaClientConfigProps): JSX.Element;
|
|
4
4
|
export default CardSwitcher;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement, RefObject } from 'react';
|
|
2
2
|
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
3
|
+
import type { WithMediaClientConfigProps } from '@atlaskit/media-client-react';
|
|
4
|
+
import type { CardBaseProps } from './card';
|
|
3
5
|
import { CardDimensions } from '../types';
|
|
4
6
|
export type InlinePlayerWrapperProps = {
|
|
5
7
|
testId?: string;
|
|
@@ -11,3 +13,4 @@ export type InlinePlayerWrapperProps = {
|
|
|
11
13
|
innerRef?: RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | undefined;
|
|
12
14
|
children?: JSX.Element[] | ReactElement<any, any> | null | any;
|
|
13
15
|
};
|
|
16
|
+
export type CardWithMediaClientConfigProps = WithMediaClientConfigProps<CardBaseProps>;
|
|
@@ -4,7 +4,8 @@ import React, { MouseEvent } from 'react';
|
|
|
4
4
|
import { MessageDescriptor } from 'react-intl-next';
|
|
5
5
|
import { MediaItemType, FileDetails, ImageResizeMode } from '@atlaskit/media-client';
|
|
6
6
|
import { WithAnalyticsEventsProps, UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
7
|
-
import { CardStatus,
|
|
7
|
+
import { CardStatus, MediaCardCursor, CardDimensions, TitleBoxIcon } from '../../types';
|
|
8
|
+
import { MediaFilePreview } from './useFilePreview';
|
|
8
9
|
import { CardAction } from '../actions';
|
|
9
10
|
import { MediaCardError } from '../../errors';
|
|
10
11
|
export interface CardViewV2Props {
|
|
@@ -26,11 +27,11 @@ export interface CardViewV2Props {
|
|
|
26
27
|
readonly onClick?: (event: React.MouseEvent<HTMLDivElement>, analyticsEvent?: UIAnalyticsEvent) => void;
|
|
27
28
|
readonly onMouseEnter?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
28
29
|
readonly onDisplayImage?: () => void;
|
|
29
|
-
readonly cardPreview?:
|
|
30
|
+
readonly cardPreview?: MediaFilePreview;
|
|
30
31
|
readonly progress?: number;
|
|
31
32
|
readonly innerRef?: (instance: HTMLDivElement | null) => void;
|
|
32
|
-
readonly onImageLoad?: (cardPreview:
|
|
33
|
-
readonly onImageError?: (cardPreview:
|
|
33
|
+
readonly onImageLoad?: (cardPreview: MediaFilePreview) => void;
|
|
34
|
+
readonly onImageError?: (cardPreview: MediaFilePreview) => void;
|
|
34
35
|
readonly nativeLazyLoad?: boolean;
|
|
35
36
|
readonly forceSyncDisplay?: boolean;
|
|
36
37
|
disableAnimation?: boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MediaFilePreview } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Primary reason is logged through Data Portal.
|
|
4
|
+
* Make sure all the values are whitelisted in Measure -> Event Regitry -> "mediaCardRender failed" event
|
|
5
|
+
*/
|
|
6
|
+
export type MediaFilePreviewErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'missing-error-data' | 'preview-fetch';
|
|
7
|
+
export type ImageLoadPrimaryReason = 'cache-remote-uri' | 'cache-local-uri' | 'local-uri' | 'remote-uri' | 'external-uri' | 'unknown-uri';
|
|
8
|
+
export type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready' | 'remote-preview-fetch-ssr';
|
|
9
|
+
export type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-unsupported' | 'local-preview-rejected' | 'local-preview-image' | 'local-preview-video';
|
|
10
|
+
export type SsrPreviewPrimaryReason = 'ssr-client-uri' | 'ssr-client-load' | 'ssr-server-uri' | 'ssr-server-load';
|
|
11
|
+
export declare class MediaFilePreviewError extends Error {
|
|
12
|
+
readonly primaryReason: MediaFilePreviewErrorPrimaryReason;
|
|
13
|
+
readonly secondaryError?: Error | undefined;
|
|
14
|
+
constructor(primaryReason: MediaFilePreviewErrorPrimaryReason, secondaryError?: Error | undefined);
|
|
15
|
+
}
|
|
16
|
+
export declare class LocalPreviewError extends MediaFilePreviewError {
|
|
17
|
+
readonly primaryReason: LocalPreviewPrimaryReason;
|
|
18
|
+
readonly secondaryError?: Error | undefined;
|
|
19
|
+
constructor(primaryReason: LocalPreviewPrimaryReason, secondaryError?: Error | undefined);
|
|
20
|
+
}
|
|
21
|
+
export declare class RemotePreviewError extends MediaFilePreviewError {
|
|
22
|
+
readonly primaryReason: RemotePreviewPrimaryReason;
|
|
23
|
+
readonly secondaryError?: Error | undefined;
|
|
24
|
+
constructor(primaryReason: RemotePreviewPrimaryReason, secondaryError?: Error | undefined);
|
|
25
|
+
}
|
|
26
|
+
export declare class SsrPreviewError extends MediaFilePreviewError {
|
|
27
|
+
readonly primaryReason: SsrPreviewPrimaryReason;
|
|
28
|
+
readonly secondaryError?: Error | undefined;
|
|
29
|
+
constructor(primaryReason: SsrPreviewPrimaryReason, secondaryError?: Error | undefined);
|
|
30
|
+
}
|
|
31
|
+
export declare class ImageLoadError extends MediaFilePreviewError {
|
|
32
|
+
constructor(source?: MediaFilePreview['source']);
|
|
33
|
+
}
|
|
34
|
+
export declare function isMediaFilePreviewError(err: Error): err is MediaFilePreviewError;
|
|
35
|
+
export declare const isLocalPreviewError: (err: Error) => err is LocalPreviewError;
|
|
36
|
+
export declare const isRemotePreviewError: (err: Error) => err is RemotePreviewError;
|
|
37
|
+
export declare const isUnsupportedLocalPreviewError: (err: Error) => boolean;
|
|
38
|
+
export declare const ensureMediaFilePreviewError: (primaryReason: MediaFilePreviewErrorPrimaryReason, error: Error, updatePrimaryReason?: boolean) => MediaFilePreviewError;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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 getSSRCardPreview: (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>;
|
|
@@ -0,0 +1,10 @@
|
|
|
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>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { mediaFilePreviewCache } from './cache';
|
|
2
|
+
export { isPreviewableStatus, extractFilePreviewStatus, } from './filePreviewStatus';
|
|
3
|
+
export { getSSRCardPreview, isLocalPreview, isSSRClientPreview, isSSRDataPreview, getAndCacheRemotePreview, getAndCacheLocalPreview, } from './getPreview';
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const takeSnapshot: (blob: Blob) => Promise<string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
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>;
|
|
@@ -0,0 +1,4 @@
|
|
|
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';
|
|
@@ -0,0 +1,8 @@
|
|
|
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>;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 */
|
|
10
|
+
export declare function useCurrentValueRef<T>(value: T): MutableRefObject<T>;
|
|
11
|
+
export declare function usePrevious<T>(value: T | undefined): T | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type MediaFilePreviewSource = 'local' | 'remote' | 'ssr-server' | 'ssr-client' | 'ssr-data' | 'cache-local' | 'cache-remote' | 'cache-ssr-client' | 'cache-ssr-server' | 'external';
|
|
2
|
+
export type MediaFilePreviewDimensions = {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
};
|
|
6
|
+
export interface MediaFilePreview {
|
|
7
|
+
dataURI: string;
|
|
8
|
+
orientation?: number;
|
|
9
|
+
dimensions?: MediaFilePreviewDimensions;
|
|
10
|
+
source: MediaFilePreviewSource;
|
|
11
|
+
}
|
|
12
|
+
export type MediaFilePreviewStatus = 'uploading' | 'loading' | 'processing' | 'loading-preview' | 'complete' | 'error' | 'failed-processing';
|
|
13
|
+
export type FilePreviewStatus = {
|
|
14
|
+
hasFilesize: boolean;
|
|
15
|
+
isPreviewable: boolean;
|
|
16
|
+
hasPreview: boolean;
|
|
17
|
+
isSupportedByBrowser: boolean;
|
|
18
|
+
};
|