@atlaskit/media-card 78.0.7 → 78.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/card/card.js +3 -4
  3. package/dist/cjs/card/externalImageCard.js +4 -2
  4. package/dist/cjs/card/fileCard.js +5 -3
  5. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  6. package/dist/cjs/card/svgView/svgView.js +2 -1
  7. package/dist/cjs/inline/loader.js +1 -1
  8. package/dist/cjs/types.js +16 -1
  9. package/dist/cjs/utils/ufoExperiences.js +1 -1
  10. package/dist/es2019/card/card.js +3 -4
  11. package/dist/es2019/card/externalImageCard.js +5 -2
  12. package/dist/es2019/card/fileCard.js +5 -2
  13. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  14. package/dist/es2019/card/svgView/svgView.js +2 -1
  15. package/dist/es2019/inline/loader.js +1 -1
  16. package/dist/es2019/types.js +10 -0
  17. package/dist/es2019/utils/ufoExperiences.js +1 -1
  18. package/dist/esm/card/card.js +3 -4
  19. package/dist/esm/card/externalImageCard.js +4 -2
  20. package/dist/esm/card/fileCard.js +4 -2
  21. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  22. package/dist/esm/card/svgView/svgView.js +2 -1
  23. package/dist/esm/inline/loader.js +1 -1
  24. package/dist/esm/types.js +14 -0
  25. package/dist/esm/utils/ufoExperiences.js +1 -1
  26. package/dist/types/card/card.d.ts +1 -2
  27. package/dist/types/card/externalImageCard.d.ts +1 -3
  28. package/dist/types/card/fileCard.d.ts +1 -3
  29. package/dist/types/types.d.ts +4 -0
  30. package/dist/types-ts4.5/card/card.d.ts +1 -2
  31. package/dist/types-ts4.5/card/externalImageCard.d.ts +1 -3
  32. package/dist/types-ts4.5/card/fileCard.d.ts +1 -3
  33. package/dist/types-ts4.5/types.d.ts +4 -0
  34. package/example-helpers/index.tsx +4 -2
  35. package/package.json +3 -3
  36. package/dist/cjs/card/cardState.js +0 -37
  37. package/dist/cjs/card/getCardPreview/cache.js +0 -39
  38. package/dist/cjs/card/getCardPreview/filePreviewStatus.js +0 -45
  39. package/dist/cjs/card/getCardPreview/helpers.js +0 -165
  40. package/dist/cjs/card/getCardPreview/index.js +0 -245
  41. package/dist/es2019/card/cardState.js +0 -30
  42. package/dist/es2019/card/getCardPreview/cache.js +0 -33
  43. package/dist/es2019/card/getCardPreview/filePreviewStatus.js +0 -43
  44. package/dist/es2019/card/getCardPreview/helpers.js +0 -74
  45. package/dist/es2019/card/getCardPreview/index.js +0 -170
  46. package/dist/esm/card/cardState.js +0 -32
  47. package/dist/esm/card/getCardPreview/cache.js +0 -35
  48. package/dist/esm/card/getCardPreview/filePreviewStatus.js +0 -40
  49. package/dist/esm/card/getCardPreview/helpers.js +0 -158
  50. package/dist/esm/card/getCardPreview/index.js +0 -213
  51. package/dist/types/card/cardState.d.ts +0 -9
  52. package/dist/types/card/getCardPreview/cache.d.ts +0 -21
  53. package/dist/types/card/getCardPreview/filePreviewStatus.d.ts +0 -4
  54. package/dist/types/card/getCardPreview/helpers.d.ts +0 -10
  55. package/dist/types/card/getCardPreview/index.d.ts +0 -53
  56. package/dist/types-ts4.5/card/cardState.d.ts +0 -9
  57. package/dist/types-ts4.5/card/getCardPreview/cache.d.ts +0 -21
  58. package/dist/types-ts4.5/card/getCardPreview/filePreviewStatus.d.ts +0 -4
  59. package/dist/types-ts4.5/card/getCardPreview/helpers.d.ts +0 -10
  60. package/dist/types-ts4.5/card/getCardPreview/index.d.ts +0 -53
@@ -1,213 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- 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; }
5
- 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; }
6
- import { isPreviewableFileState, addFileAttrsToUrl } from '@atlaskit/media-client';
7
- import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
8
- import cardPreviewCache from './cache';
9
- import { getCardPreviewFromFilePreview, getCardPreviewFromBackend } from './helpers';
10
- import { MediaCardError, SsrPreviewError, isUnsupportedLocalPreviewError } from '../../errors';
11
- import { isBigger } from '../../utils/dimensionComparer';
12
- import { extractFilePreviewStatus, isPreviewableStatus } from './filePreviewStatus';
13
- export { getCardPreviewFromFilePreview, getCardPreviewFromBackend, isSupportedLocalPreview } from './helpers';
14
- export { extractFilePreviewStatus } from './filePreviewStatus';
15
- export var getCardPreviewFromCache = cardPreviewCache.get;
16
- export var removeCardPreviewFromCache = cardPreviewCache.remove;
17
-
18
- /**
19
- * Will return the preview if available and supported by the browser
20
- * See extractFilePreviewStatus "hasLocalPreview" logic
21
- */
22
- export var getFilePreviewFromFileState = function getFilePreviewFromFileState(fileState) {
23
- return 'mimeType' in fileState && isMimeTypeSupportedByBrowser(fileState.mimeType) && isPreviewableFileState(fileState) ? fileState.preview : undefined;
24
- };
25
- var extendAndCachePreview = function extendAndCachePreview(id, mode, preview, mediaBlobUrlAttrs) {
26
- var source;
27
- switch (preview.source) {
28
- case 'local':
29
- source = 'cache-local';
30
- break;
31
- case 'remote':
32
- source = 'cache-remote';
33
- break;
34
- case 'ssr-server':
35
- source = 'cache-ssr-server';
36
- break;
37
- case 'ssr-client':
38
- source = 'cache-ssr-client';
39
- break;
40
- default:
41
- source = preview.source;
42
- }
43
- // We want to embed some meta context into dataURI for Copy/Paste to work.
44
- var dataURI = mediaBlobUrlAttrs ? addFileAttrsToUrl(preview.dataURI, mediaBlobUrlAttrs) : preview.dataURI;
45
- // We store new cardPreview into cache
46
- cardPreviewCache.set(id, mode, _objectSpread(_objectSpread({}, preview), {}, {
47
- source: source,
48
- dataURI: dataURI
49
- }));
50
- return _objectSpread(_objectSpread({}, preview), {}, {
51
- dataURI: dataURI
52
- });
53
- };
54
-
55
- /**
56
- * This function will try to return a Card preview, either from cache, local preview or remote preview.
57
- * It should only be called if there is a chance to get either a remote or a local preview, or both.
58
- * This, in order to ensure there is always going to be a valid return value OR throw an error if the process fails.
59
- * It is worth noting that local preview failures break the process if there is no remote preview available.
60
- * In that case we throw an error immediately.
61
- * Otherwise, if the local preview fails but there is a remote preview available, the failure does not break the process.
62
- * In that case, we still want to report the local preview error to the caller, for feature realiability track.
63
- * hence the use of the optional callback onLocalPreviewError
64
- */
65
- export var getCardPreview = /*#__PURE__*/function () {
66
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
67
- var mediaClient, id, _ref$dimensions, dimensions, filePreview, onLocalPreviewError, isRemotePreviewReady, imageUrlParams, mediaBlobUrlAttrs, traceContext, mode, cachedPreview, dimensionsAreBigger, localPreview, remotePreview;
68
- return _regeneratorRuntime.wrap(function _callee$(_context) {
69
- while (1) switch (_context.prev = _context.next) {
70
- case 0:
71
- mediaClient = _ref.mediaClient, id = _ref.id, _ref$dimensions = _ref.dimensions, dimensions = _ref$dimensions === void 0 ? {} : _ref$dimensions, filePreview = _ref.filePreview, onLocalPreviewError = _ref.onLocalPreviewError, isRemotePreviewReady = _ref.isRemotePreviewReady, imageUrlParams = _ref.imageUrlParams, mediaBlobUrlAttrs = _ref.mediaBlobUrlAttrs, traceContext = _ref.traceContext;
72
- mode = imageUrlParams.mode;
73
- cachedPreview = cardPreviewCache.get(id, mode);
74
- dimensionsAreBigger = isBigger(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions);
75
- if (!(cachedPreview && !dimensionsAreBigger)) {
76
- _context.next = 6;
77
- break;
78
- }
79
- return _context.abrupt("return", cachedPreview);
80
- case 6:
81
- _context.prev = 6;
82
- if (!filePreview) {
83
- _context.next = 12;
84
- break;
85
- }
86
- _context.next = 10;
87
- return getCardPreviewFromFilePreview(filePreview);
88
- case 10:
89
- localPreview = _context.sent;
90
- return _context.abrupt("return", extendAndCachePreview(id, mode, _objectSpread(_objectSpread({}, localPreview), {}, {
91
- dimensions: dimensions
92
- }), mediaBlobUrlAttrs));
93
- case 12:
94
- _context.next = 19;
95
- break;
96
- case 14:
97
- _context.prev = 14;
98
- _context.t0 = _context["catch"](6);
99
- /**
100
- * We report the error if:
101
- * - local preview is supported and fails
102
- * - local preview is unsupported and remote preview is NOT READY
103
- * i.e. the function was called for "no reason".
104
- * We DON'T report the error if:
105
- * - local preview is unsupported and remote preview IS READY
106
- * i.e. local preview is available and not supported,
107
- * but we are after the remote preview instead.
108
- */
109
- if (!isUnsupportedLocalPreviewError(_context.t0) || isUnsupportedLocalPreviewError(_context.t0) && !isRemotePreviewReady) {
110
- onLocalPreviewError && onLocalPreviewError(_context.t0);
111
- }
112
- /**
113
- * No matter the reason why the local preview failed, we break the process
114
- * if there is no remote preview available
115
- */
116
- if (isRemotePreviewReady) {
117
- _context.next = 19;
118
- break;
119
- }
120
- throw _context.t0;
121
- case 19:
122
- if (isRemotePreviewReady) {
123
- _context.next = 21;
124
- break;
125
- }
126
- throw new MediaCardError('remote-preview-not-ready');
127
- case 21:
128
- _context.next = 23;
129
- return fetchAndCacheRemotePreview(mediaClient, id, dimensions, imageUrlParams, mediaBlobUrlAttrs, traceContext);
130
- case 23:
131
- remotePreview = _context.sent;
132
- return _context.abrupt("return", remotePreview);
133
- case 25:
134
- case "end":
135
- return _context.stop();
136
- }
137
- }, _callee, null, [[6, 14]]);
138
- }));
139
- return function getCardPreview(_x) {
140
- return _ref2.apply(this, arguments);
141
- };
142
- }();
143
- export var shouldResolvePreview = function shouldResolvePreview(_ref3) {
144
- var status = _ref3.status,
145
- fileState = _ref3.fileState,
146
- prevDimensions = _ref3.prevDimensions,
147
- dimensions = _ref3.dimensions,
148
- hasCardPreview = _ref3.hasCardPreview,
149
- isBannedLocalPreview = _ref3.isBannedLocalPreview,
150
- wasResolvedUpfrontPreview = _ref3.wasResolvedUpfrontPreview;
151
- var statusIsPreviewable = isPreviewableStatus(status, extractFilePreviewStatus(fileState, isBannedLocalPreview));
152
- var dimensionsAreBigger = isBigger(prevDimensions, dimensions);
153
- // We should not fetch the preview if the upfront one hasn't been resolved yet (it could be resolving now), even if there are new dimensions.
154
- return wasResolvedUpfrontPreview && statusIsPreviewable && (!hasCardPreview || dimensionsAreBigger);
155
- };
156
- export var getSSRCardPreview = function getSSRCardPreview(ssr, mediaClient, id, params, mediaBlobUrlAttrs) {
157
- var dataURI;
158
- try {
159
- var rawDataURI = mediaClient.getImageUrlSync(id, params);
160
- // We want to embed some meta context into dataURI for Copy/Paste to work.
161
- dataURI = mediaBlobUrlAttrs ? addFileAttrsToUrl(rawDataURI, mediaBlobUrlAttrs) : rawDataURI;
162
- var source = ssr === 'client' ? 'ssr-client' : 'ssr-server';
163
- return {
164
- dataURI: dataURI,
165
- source: source,
166
- orientation: 1
167
- };
168
- } catch (e) {
169
- var reason = ssr === 'server' ? 'ssr-server-uri' : 'ssr-client-uri';
170
- throw new SsrPreviewError(reason, e instanceof Error ? e : undefined);
171
- }
172
- };
173
- export var isLocalPreview = function isLocalPreview(preview) {
174
- var localSources = ['local', 'cache-local'];
175
- return localSources.includes(preview.source);
176
- };
177
- export var isSSRPreview = function isSSRPreview(preview) {
178
- return isSSRClientPreview(preview) || isSSRServerPreview(preview) || isSSRDataPreview(preview);
179
- };
180
- export var isSSRServerPreview = function isSSRServerPreview(preview) {
181
- var ssrClientSources = ['ssr-server', 'cache-ssr-server'];
182
- return ssrClientSources.includes(preview.source);
183
- };
184
- export var isSSRClientPreview = function isSSRClientPreview(preview) {
185
- var ssrClientSources = ['ssr-client', 'cache-ssr-client'];
186
- return ssrClientSources.includes(preview.source);
187
- };
188
- export var isSSRDataPreview = function isSSRDataPreview(preview) {
189
- return preview.source === 'ssr-data';
190
- };
191
- export var fetchAndCacheRemotePreview = /*#__PURE__*/function () {
192
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mediaClient, id, dimensions, params, mediaBlobUrlAttrs, traceContext) {
193
- var remotePreview;
194
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
195
- while (1) switch (_context2.prev = _context2.next) {
196
- case 0:
197
- _context2.next = 2;
198
- return getCardPreviewFromBackend(mediaClient, id, params, traceContext);
199
- case 2:
200
- remotePreview = _context2.sent;
201
- return _context2.abrupt("return", extendAndCachePreview(id, params.mode, _objectSpread(_objectSpread({}, remotePreview), {}, {
202
- dimensions: dimensions
203
- }), mediaBlobUrlAttrs));
204
- case 4:
205
- case "end":
206
- return _context2.stop();
207
- }
208
- }, _callee2);
209
- }));
210
- return function fetchAndCacheRemotePreview(_x2, _x3, _x4, _x5, _x6, _x7) {
211
- return _ref4.apply(this, arguments);
212
- };
213
- }();
@@ -1,9 +0,0 @@
1
- import { type FileState } from '@atlaskit/media-client';
2
- import { type CardState } from '../types';
3
- import { MediaCardError } from '../errors';
4
- /**
5
- * From docs: "Both state and props received by the updater function are guaranteed to be up-to-date.
6
- * The output of the updater is shallowly merged with state."
7
- */
8
- export declare const createStateUpdater: (newState: Partial<CardState>, fireErrorEvent: (error: MediaCardError) => void) => (prevState: CardState) => Partial<CardState>;
9
- export declare const getCardStateFromFileState: (fileState: FileState, isBannedLocalPreview: boolean) => Partial<CardState>;
@@ -1,21 +0,0 @@
1
- import { type ImageResizeMode } from '@atlaskit/media-client';
2
- import { type ObjectURLCache } from '../../utils/objectURLCache';
3
- import { type CardPreview } from '../../types';
4
- type Mode = ImageResizeMode | undefined;
5
- export declare const getCacheKey: (id: string, mode: Mode) => string;
6
- export interface CardPreviewCache {
7
- get(id: string, mode: Mode): CardPreview | undefined;
8
- set(id: string, mode: Mode, cardPreview: CardPreview): void;
9
- remove(id: string, mode: Mode): void;
10
- clear(): void;
11
- }
12
- export declare class CardPreviewCacheImpl implements CardPreviewCache {
13
- private previewCache;
14
- constructor(previewCache: ObjectURLCache);
15
- get: (id: string, mode: Mode) => CardPreview | undefined;
16
- set: (id: string, mode: Mode, cardPreview: CardPreview) => void;
17
- remove: (id: string, mode: Mode) => void;
18
- clear: () => void;
19
- }
20
- declare const _default: CardPreviewCacheImpl;
21
- export default _default;
@@ -1,4 +0,0 @@
1
- import { type CardStatus, type FilePreviewStatus } from '../../types';
2
- import { type FileState } from '@atlaskit/media-client';
3
- export declare const extractFilePreviewStatus: (fileState: FileState, isBannedLocalPreview: boolean) => FilePreviewStatus;
4
- export declare const isPreviewableStatus: (cardStatus: CardStatus, { isPreviewable, hasPreview, isSupportedByBrowser }: FilePreviewStatus) => boolean;
@@ -1,10 +0,0 @@
1
- import { type MediaClient, type FilePreview, type MediaStoreGetFileImageParams, type MediaType } from '@atlaskit/media-client';
2
- import { type MediaTraceContext } from '@atlaskit/media-common';
3
- import { type CardPreview } 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 getCardPreviewFromFilePreview: (filePreview: FilePreview | Promise<FilePreview>) => Promise<CardPreview>;
10
- export declare const getCardPreviewFromBackend: (mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<CardPreview>;
@@ -1,53 +0,0 @@
1
- import { type MediaClient, type FilePreview, type FileState, type MediaStoreGetFileImageParams, type MediaBlobUrlAttrs } from '@atlaskit/media-client';
2
- import { type SSR, type MediaTraceContext } from '@atlaskit/media-common';
3
- import { type ImageResizeMode } from '@atlaskit/media-client';
4
- import { type CardDimensions } from '../../types';
5
- import { MediaCardError } from '../../errors';
6
- import { type CardStatus, type CardPreview } from '../../types';
7
- export { getCardPreviewFromFilePreview, getCardPreviewFromBackend, isSupportedLocalPreview, } from './helpers';
8
- export { extractFilePreviewStatus } from './filePreviewStatus';
9
- export declare const getCardPreviewFromCache: (id: string, mode: ImageResizeMode | undefined) => CardPreview | undefined;
10
- export declare const removeCardPreviewFromCache: (id: string, mode: ImageResizeMode | undefined) => void;
11
- /**
12
- * Will return the preview if available and supported by the browser
13
- * See extractFilePreviewStatus "hasLocalPreview" logic
14
- */
15
- export declare const getFilePreviewFromFileState: (fileState: FileState) => FilePreview | Promise<FilePreview> | undefined;
16
- export type CardPreviewParams = {
17
- mediaClient: MediaClient;
18
- id: string;
19
- dimensions?: CardDimensions;
20
- filePreview?: FilePreview | Promise<FilePreview>;
21
- onLocalPreviewError: (error: MediaCardError) => void;
22
- isRemotePreviewReady: boolean;
23
- imageUrlParams: MediaStoreGetFileImageParams;
24
- mediaBlobUrlAttrs?: MediaBlobUrlAttrs;
25
- traceContext?: MediaTraceContext;
26
- };
27
- /**
28
- * This function will try to return a Card preview, either from cache, local preview or remote preview.
29
- * It should only be called if there is a chance to get either a remote or a local preview, or both.
30
- * This, in order to ensure there is always going to be a valid return value OR throw an error if the process fails.
31
- * It is worth noting that local preview failures break the process if there is no remote preview available.
32
- * In that case we throw an error immediately.
33
- * Otherwise, if the local preview fails but there is a remote preview available, the failure does not break the process.
34
- * In that case, we still want to report the local preview error to the caller, for feature realiability track.
35
- * hence the use of the optional callback onLocalPreviewError
36
- */
37
- export declare const getCardPreview: ({ mediaClient, id, dimensions, filePreview, onLocalPreviewError, isRemotePreviewReady, imageUrlParams, mediaBlobUrlAttrs, traceContext, }: CardPreviewParams) => Promise<CardPreview>;
38
- export declare const shouldResolvePreview: ({ status, fileState, prevDimensions, dimensions, hasCardPreview, isBannedLocalPreview, wasResolvedUpfrontPreview, }: {
39
- status: CardStatus;
40
- fileState: FileState;
41
- prevDimensions?: CardDimensions | undefined;
42
- dimensions?: CardDimensions | undefined;
43
- hasCardPreview: boolean;
44
- isBannedLocalPreview: boolean;
45
- wasResolvedUpfrontPreview: boolean;
46
- }) => boolean;
47
- export declare const getSSRCardPreview: (ssr: SSR, mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs) => CardPreview;
48
- export declare const isLocalPreview: (preview: CardPreview) => boolean;
49
- export declare const isSSRPreview: (preview: CardPreview) => boolean;
50
- export declare const isSSRServerPreview: (preview: CardPreview) => boolean;
51
- export declare const isSSRClientPreview: (preview: CardPreview) => boolean;
52
- export declare const isSSRDataPreview: (preview: CardPreview) => boolean;
53
- export declare const fetchAndCacheRemotePreview: (mediaClient: MediaClient, id: string, dimensions: CardDimensions, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs, traceContext?: MediaTraceContext) => Promise<CardPreview>;
@@ -1,9 +0,0 @@
1
- import { type FileState } from '@atlaskit/media-client';
2
- import { type CardState } from '../types';
3
- import { MediaCardError } from '../errors';
4
- /**
5
- * From docs: "Both state and props received by the updater function are guaranteed to be up-to-date.
6
- * The output of the updater is shallowly merged with state."
7
- */
8
- export declare const createStateUpdater: (newState: Partial<CardState>, fireErrorEvent: (error: MediaCardError) => void) => (prevState: CardState) => Partial<CardState>;
9
- export declare const getCardStateFromFileState: (fileState: FileState, isBannedLocalPreview: boolean) => Partial<CardState>;
@@ -1,21 +0,0 @@
1
- import { type ImageResizeMode } from '@atlaskit/media-client';
2
- import { type ObjectURLCache } from '../../utils/objectURLCache';
3
- import { type CardPreview } from '../../types';
4
- type Mode = ImageResizeMode | undefined;
5
- export declare const getCacheKey: (id: string, mode: Mode) => string;
6
- export interface CardPreviewCache {
7
- get(id: string, mode: Mode): CardPreview | undefined;
8
- set(id: string, mode: Mode, cardPreview: CardPreview): void;
9
- remove(id: string, mode: Mode): void;
10
- clear(): void;
11
- }
12
- export declare class CardPreviewCacheImpl implements CardPreviewCache {
13
- private previewCache;
14
- constructor(previewCache: ObjectURLCache);
15
- get: (id: string, mode: Mode) => CardPreview | undefined;
16
- set: (id: string, mode: Mode, cardPreview: CardPreview) => void;
17
- remove: (id: string, mode: Mode) => void;
18
- clear: () => void;
19
- }
20
- declare const _default: CardPreviewCacheImpl;
21
- export default _default;
@@ -1,4 +0,0 @@
1
- import { type CardStatus, type FilePreviewStatus } from '../../types';
2
- import { type FileState } from '@atlaskit/media-client';
3
- export declare const extractFilePreviewStatus: (fileState: FileState, isBannedLocalPreview: boolean) => FilePreviewStatus;
4
- export declare const isPreviewableStatus: (cardStatus: CardStatus, { isPreviewable, hasPreview, isSupportedByBrowser }: FilePreviewStatus) => boolean;
@@ -1,10 +0,0 @@
1
- import { type MediaClient, type FilePreview, type MediaStoreGetFileImageParams, type MediaType } from '@atlaskit/media-client';
2
- import { type MediaTraceContext } from '@atlaskit/media-common';
3
- import { type CardPreview } 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 getCardPreviewFromFilePreview: (filePreview: FilePreview | Promise<FilePreview>) => Promise<CardPreview>;
10
- export declare const getCardPreviewFromBackend: (mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<CardPreview>;
@@ -1,53 +0,0 @@
1
- import { type MediaClient, type FilePreview, type FileState, type MediaStoreGetFileImageParams, type MediaBlobUrlAttrs } from '@atlaskit/media-client';
2
- import { type SSR, type MediaTraceContext } from '@atlaskit/media-common';
3
- import { type ImageResizeMode } from '@atlaskit/media-client';
4
- import { type CardDimensions } from '../../types';
5
- import { MediaCardError } from '../../errors';
6
- import { type CardStatus, type CardPreview } from '../../types';
7
- export { getCardPreviewFromFilePreview, getCardPreviewFromBackend, isSupportedLocalPreview, } from './helpers';
8
- export { extractFilePreviewStatus } from './filePreviewStatus';
9
- export declare const getCardPreviewFromCache: (id: string, mode: ImageResizeMode | undefined) => CardPreview | undefined;
10
- export declare const removeCardPreviewFromCache: (id: string, mode: ImageResizeMode | undefined) => void;
11
- /**
12
- * Will return the preview if available and supported by the browser
13
- * See extractFilePreviewStatus "hasLocalPreview" logic
14
- */
15
- export declare const getFilePreviewFromFileState: (fileState: FileState) => FilePreview | Promise<FilePreview> | undefined;
16
- export type CardPreviewParams = {
17
- mediaClient: MediaClient;
18
- id: string;
19
- dimensions?: CardDimensions;
20
- filePreview?: FilePreview | Promise<FilePreview>;
21
- onLocalPreviewError: (error: MediaCardError) => void;
22
- isRemotePreviewReady: boolean;
23
- imageUrlParams: MediaStoreGetFileImageParams;
24
- mediaBlobUrlAttrs?: MediaBlobUrlAttrs;
25
- traceContext?: MediaTraceContext;
26
- };
27
- /**
28
- * This function will try to return a Card preview, either from cache, local preview or remote preview.
29
- * It should only be called if there is a chance to get either a remote or a local preview, or both.
30
- * This, in order to ensure there is always going to be a valid return value OR throw an error if the process fails.
31
- * It is worth noting that local preview failures break the process if there is no remote preview available.
32
- * In that case we throw an error immediately.
33
- * Otherwise, if the local preview fails but there is a remote preview available, the failure does not break the process.
34
- * In that case, we still want to report the local preview error to the caller, for feature realiability track.
35
- * hence the use of the optional callback onLocalPreviewError
36
- */
37
- export declare const getCardPreview: ({ mediaClient, id, dimensions, filePreview, onLocalPreviewError, isRemotePreviewReady, imageUrlParams, mediaBlobUrlAttrs, traceContext, }: CardPreviewParams) => Promise<CardPreview>;
38
- export declare const shouldResolvePreview: ({ status, fileState, prevDimensions, dimensions, hasCardPreview, isBannedLocalPreview, wasResolvedUpfrontPreview, }: {
39
- status: CardStatus;
40
- fileState: FileState;
41
- prevDimensions?: CardDimensions | undefined;
42
- dimensions?: CardDimensions | undefined;
43
- hasCardPreview: boolean;
44
- isBannedLocalPreview: boolean;
45
- wasResolvedUpfrontPreview: boolean;
46
- }) => boolean;
47
- export declare const getSSRCardPreview: (ssr: SSR, mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs) => CardPreview;
48
- export declare const isLocalPreview: (preview: CardPreview) => boolean;
49
- export declare const isSSRPreview: (preview: CardPreview) => boolean;
50
- export declare const isSSRServerPreview: (preview: CardPreview) => boolean;
51
- export declare const isSSRClientPreview: (preview: CardPreview) => boolean;
52
- export declare const isSSRDataPreview: (preview: CardPreview) => boolean;
53
- export declare const fetchAndCacheRemotePreview: (mediaClient: MediaClient, id: string, dimensions: CardDimensions, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs, traceContext?: MediaTraceContext) => Promise<CardPreview>;