@atlaskit/media-file-preview 0.17.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +59 -0
- package/CHANGELOG.md +38 -0
- package/dist/cjs/getPreview/getPreview.js +89 -36
- package/dist/cjs/getPreview/helpers.js +51 -51
- package/dist/cjs/getPreview/index.js +6 -0
- package/dist/cjs/getPreview/videoSnapshot.js +1 -1
- package/dist/cjs/useFilePreview.js +12 -2
- package/dist/es2019/getPreview/getPreview.js +54 -5
- package/dist/es2019/getPreview/index.js +1 -1
- package/dist/es2019/useFilePreview.js +13 -3
- package/dist/esm/getPreview/getPreview.js +88 -35
- package/dist/esm/getPreview/helpers.js +51 -51
- package/dist/esm/getPreview/index.js +1 -1
- package/dist/esm/getPreview/videoSnapshot.js +1 -1
- package/dist/esm/useFilePreview.js +13 -3
- package/dist/types/getPreview/getPreview.d.ts +12 -1
- package/dist/types/getPreview/index.d.ts +1 -1
- package/dist/types/useFilePreview.d.ts +4 -2
- package/errors/package.json +1 -8
- package/package.json +16 -19
- package/types/package.json +1 -8
- package/use-file-preview/package.json +1 -8
- package/use-media-image/package.json +1 -8
- package/dist/types-ts4.5/analytics.d.ts +0 -30
- package/dist/types-ts4.5/errors.d.ts +0 -38
- package/dist/types-ts4.5/getPreview/cache.d.ts +0 -25
- package/dist/types-ts4.5/getPreview/getPreview.d.ts +0 -11
- package/dist/types-ts4.5/getPreview/helpers.d.ts +0 -10
- package/dist/types-ts4.5/getPreview/index.d.ts +0 -3
- package/dist/types-ts4.5/getPreview/objectURLCache.d.ts +0 -21
- package/dist/types-ts4.5/getPreview/videoSnapshot.d.ts +0 -1
- package/dist/types-ts4.5/globalScope/getSSRData.d.ts +0 -3
- package/dist/types-ts4.5/globalScope/globalScope.d.ts +0 -23
- package/dist/types-ts4.5/globalScope/index.d.ts +0 -4
- package/dist/types-ts4.5/globalScope/originalScriptCode.d.ts +0 -0
- package/dist/types-ts4.5/globalScope/types.d.ts +0 -12
- package/dist/types-ts4.5/helpers.d.ts +0 -11
- package/dist/types-ts4.5/index.d.ts +0 -7
- package/dist/types-ts4.5/types.d.ts +0 -14
- package/dist/types-ts4.5/useFilePreview.d.ts +0 -44
- package/dist/types-ts4.5/useMediaImage.d.ts +0 -45
package/errors/package.json
CHANGED
|
@@ -4,12 +4,5 @@
|
|
|
4
4
|
"module": "../dist/esm/errors.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/errors.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/errors.d.ts"
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.9": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/errors.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
"types": "../dist/types/errors.d.ts"
|
|
15
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-file-preview",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A React Hook to fetch and render file previews. It's overloaded with fancy features like SSR, lazy loading, memory cache and local preview.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,23 +26,15 @@
|
|
|
26
26
|
"module": "dist/esm/index.js",
|
|
27
27
|
"module:es2019": "dist/es2019/index.js",
|
|
28
28
|
"types": "dist/types/index.d.ts",
|
|
29
|
-
"typesVersions": {
|
|
30
|
-
">=4.5 <4.9": {
|
|
31
|
-
"*": [
|
|
32
|
-
"dist/types-ts4.5/*",
|
|
33
|
-
"dist/types-ts4.5/index.d.ts"
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
29
|
"sideEffects": false,
|
|
38
30
|
"atlaskit:src": "src/index.ts",
|
|
39
31
|
"dependencies": {
|
|
40
|
-
"@atlaskit/media-client": "^
|
|
41
|
-
"@atlaskit/media-client-react": "^
|
|
42
|
-
"@atlaskit/media-common": "^
|
|
43
|
-
"@atlaskit/media-ui": "^
|
|
44
|
-
"@atlaskit/platform-feature-flags": "^
|
|
45
|
-
"@atlaskit/react-ufo": "^
|
|
32
|
+
"@atlaskit/media-client": "^37.0.0",
|
|
33
|
+
"@atlaskit/media-client-react": "^6.0.0",
|
|
34
|
+
"@atlaskit/media-common": "^14.0.0",
|
|
35
|
+
"@atlaskit/media-ui": "^30.0.0",
|
|
36
|
+
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
37
|
+
"@atlaskit/react-ufo": "^7.0.0",
|
|
46
38
|
"@babel/runtime": "^7.0.0",
|
|
47
39
|
"lru_map": "^0.4.1"
|
|
48
40
|
},
|
|
@@ -53,14 +45,16 @@
|
|
|
53
45
|
"devDependencies": {
|
|
54
46
|
"@af/integration-testing": "workspace:^",
|
|
55
47
|
"@af/visual-regression": "workspace:^",
|
|
56
|
-
"@atlaskit/media-state": "^
|
|
57
|
-
"@atlaskit/media-test-data": "^
|
|
58
|
-
"@atlaskit/section-message": "^
|
|
48
|
+
"@atlaskit/media-state": "^3.0.0",
|
|
49
|
+
"@atlaskit/media-test-data": "^4.0.0",
|
|
50
|
+
"@atlaskit/section-message": "^9.0.0",
|
|
59
51
|
"@atlaskit/ssr": "workspace:^",
|
|
60
|
-
"@atlassian/a11y-jest-testing": "^0.
|
|
52
|
+
"@atlassian/a11y-jest-testing": "^0.12.0",
|
|
61
53
|
"@atlassian/feature-flags-test-utils": "^1.1.0",
|
|
62
54
|
"@atlassian/react-compiler-gating": "workspace:^",
|
|
55
|
+
"@atlassian/testing-library": "^0.6.0",
|
|
63
56
|
"@testing-library/react": "^16.3.0",
|
|
57
|
+
"react": "^18.2.0",
|
|
64
58
|
"react-dom": "^18.2.0",
|
|
65
59
|
"wait-for-expect": "^1.2.0"
|
|
66
60
|
},
|
|
@@ -114,6 +108,9 @@
|
|
|
114
108
|
},
|
|
115
109
|
"platform_media_safe_blob_url_eviction": {
|
|
116
110
|
"type": "boolean"
|
|
111
|
+
},
|
|
112
|
+
"platform_media_ssr_data_seed": {
|
|
113
|
+
"type": "boolean"
|
|
117
114
|
}
|
|
118
115
|
}
|
|
119
116
|
}
|
package/types/package.json
CHANGED
|
@@ -4,12 +4,5 @@
|
|
|
4
4
|
"module": "../dist/esm/types.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/types.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/types.d.ts"
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.9": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/types.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
"types": "../dist/types/types.d.ts"
|
|
15
8
|
}
|
|
@@ -4,12 +4,5 @@
|
|
|
4
4
|
"module": "../dist/esm/useFilePreview.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/useFilePreview.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/useFilePreview.d.ts"
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.9": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/useFilePreview.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
"types": "../dist/types/useFilePreview.d.ts"
|
|
15
8
|
}
|
|
@@ -4,12 +4,5 @@
|
|
|
4
4
|
"module": "../dist/esm/useMediaImage.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/useMediaImage.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/useMediaImage.d.ts"
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.9": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/useMediaImage.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
"types": "../dist/types/useMediaImage.d.ts"
|
|
15
8
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type MediaClientErrorReason } from '@atlaskit/media-client';
|
|
2
|
-
import { type MediaTraceContext, type SuccessAttributes } from '@atlaskit/media-common';
|
|
3
|
-
import { type MediaFilePreviewError, type MediaFilePreviewErrorPrimaryReason } from './errors';
|
|
4
|
-
import { type MediaFilePreview } from './types';
|
|
5
|
-
export type FailedErrorFailReason = MediaFilePreviewErrorPrimaryReason | 'nativeError';
|
|
6
|
-
export type MediaFilePreviewErrorInfo = {
|
|
7
|
-
failReason: FailedErrorFailReason;
|
|
8
|
-
error: MediaClientErrorReason | 'nativeError';
|
|
9
|
-
errorDetail: string;
|
|
10
|
-
metadataTraceContext?: MediaTraceContext;
|
|
11
|
-
};
|
|
12
|
-
export type SSRStatusFail = MediaFilePreviewErrorInfo & {
|
|
13
|
-
status: 'fail';
|
|
14
|
-
};
|
|
15
|
-
type SSRStatusSuccess = SuccessAttributes;
|
|
16
|
-
type SSRStatusUnknown = {
|
|
17
|
-
status: 'unknown';
|
|
18
|
-
};
|
|
19
|
-
type SSRStatusAttributes = SSRStatusSuccess | SSRStatusFail | SSRStatusUnknown;
|
|
20
|
-
export type SSRStatus = {
|
|
21
|
-
server: SSRStatusAttributes;
|
|
22
|
-
client: SSRStatusAttributes;
|
|
23
|
-
};
|
|
24
|
-
export declare const getErrorTraceContext: (error: MediaFilePreviewError) => MediaTraceContext | undefined;
|
|
25
|
-
export declare const getRenderErrorFailReason: (error: MediaFilePreviewError) => FailedErrorFailReason;
|
|
26
|
-
export declare const getRenderErrorErrorReason: (error: MediaFilePreviewError) => MediaClientErrorReason | "nativeError";
|
|
27
|
-
export declare const getRenderErrorErrorDetail: (error: MediaFilePreviewError) => string;
|
|
28
|
-
export declare const extractErrorInfo: (error: MediaFilePreviewError, metadataTraceContext?: MediaTraceContext) => MediaFilePreviewErrorInfo;
|
|
29
|
-
export declare const createFailedSSRObject: (preview: MediaFilePreview, metadataTraceContext?: MediaTraceContext) => SSRStatusFail;
|
|
30
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type 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' | 'failed-processing' | 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' | 'ssr-client-uri' | 'ssr-server-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;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
-
import { type MediaFilePreview } from '../types';
|
|
3
|
-
import { type ObjectURLCache } from './objectURLCache';
|
|
4
|
-
type Mode = MediaStoreGetFileImageParams['mode'] | 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
|
-
acquire(id: string, mode: Mode): void;
|
|
12
|
-
release(id: string, mode: Mode): void;
|
|
13
|
-
}
|
|
14
|
-
export declare class CardPreviewCacheImpl implements MediaFilePreviewCache {
|
|
15
|
-
private previewCache;
|
|
16
|
-
constructor(previewCache: ObjectURLCache);
|
|
17
|
-
get: (id: string, mode: Mode) => MediaFilePreview | undefined;
|
|
18
|
-
set: (id: string, mode: Mode, cardPreview: MediaFilePreview) => void;
|
|
19
|
-
remove: (id: string, mode: Mode) => void;
|
|
20
|
-
clear: () => void;
|
|
21
|
-
acquire: (id: string, mode: Mode) => void;
|
|
22
|
-
release: (id: string, mode: Mode) => void;
|
|
23
|
-
}
|
|
24
|
-
export declare const mediaFilePreviewCache: CardPreviewCacheImpl;
|
|
25
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type FilePreview, type MediaBlobUrlAttrs, type MediaClient, type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
2
|
-
import { type MediaTraceContext, type SSR } from '@atlaskit/media-common';
|
|
3
|
-
import { type MediaFilePreview, type MediaFilePreviewDimensions } 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 isRemotePreview: (preview: MediaFilePreview) => boolean;
|
|
7
|
-
export declare const isSSRClientPreview: (preview: MediaFilePreview) => boolean;
|
|
8
|
-
export declare const isSSRDataPreview: (preview: MediaFilePreview) => boolean;
|
|
9
|
-
export declare const isSSRPreview: (preview: MediaFilePreview) => boolean;
|
|
10
|
-
export declare const getAndCacheRemotePreview: (mediaClient: MediaClient, id: string, dimensions: MediaFilePreviewDimensions, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs, traceContext?: MediaTraceContext) => Promise<MediaFilePreview>;
|
|
11
|
-
export declare const getAndCacheLocalPreview: (mediaClient: MediaClient, id: string, filePreview: FilePreview | Promise<FilePreview>, dimensions: MediaFilePreviewDimensions, mode: MediaStoreGetFileImageParams["mode"], mediaBlobUrlAttrs?: MediaBlobUrlAttrs, collectionName?: string) => Promise<MediaFilePreview>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type FilePreview, type MediaClient, type MediaStoreGetFileImageParams, type MediaType } from '@atlaskit/media-client';
|
|
2
|
-
import { type MediaTraceContext } from '@atlaskit/media-common';
|
|
3
|
-
import { type 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) => mediaType is "video" | "image";
|
|
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 { getSSRPreview, isLocalPreview, isRemotePreview, isSSRPreview, isSSRClientPreview, isSSRDataPreview, getAndCacheRemotePreview, getAndCacheLocalPreview, } from './getPreview';
|
|
3
|
-
export { isSupportedLocalPreview } from './helpers';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type MediaFilePreview } from '../types';
|
|
2
|
-
export declare const PREVIEW_CACHE_LRU_SIZE = 50;
|
|
3
|
-
export declare class ObjectURLCache {
|
|
4
|
-
private readonly cache;
|
|
5
|
-
private readonly activeRefs;
|
|
6
|
-
constructor(size: number);
|
|
7
|
-
/**
|
|
8
|
-
* Marks a cache key as actively in use by a consumer.
|
|
9
|
-
* Multiple consumers can acquire the same key; eviction is
|
|
10
|
-
* blocked until all consumers have released it.
|
|
11
|
-
*/
|
|
12
|
-
acquire(key: string): void;
|
|
13
|
-
release(key: string): void;
|
|
14
|
-
private isInUse;
|
|
15
|
-
has(key: string): boolean;
|
|
16
|
-
get(key: string): MediaFilePreview | undefined;
|
|
17
|
-
set(key: string, value: MediaFilePreview): void;
|
|
18
|
-
remove(key: string): void;
|
|
19
|
-
clear(): void;
|
|
20
|
-
}
|
|
21
|
-
export declare const createObjectURLCache: () => ObjectURLCache;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const takeSnapshot: (blob: Blob) => Promise<string>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { type FileIdentifier } from '@atlaskit/media-client';
|
|
3
|
-
import { type NumericalCardDimensions } from '@atlaskit/media-common';
|
|
4
|
-
import { type MediaFilePreviewErrorInfo } from '../analytics';
|
|
5
|
-
import { type MediaCardSsr } from './types';
|
|
6
|
-
export declare const GLOBAL_MEDIA_CARD_SSR = "mediaCardSsr";
|
|
7
|
-
export declare const GLOBAL_MEDIA_COUNT_SSR = "mediaCountSsr";
|
|
8
|
-
export declare const GLOBAL_MEDIA_PERFORMANCE_ENTRIES = "performanceEntries";
|
|
9
|
-
export declare const GLOBAL_MEDIA_NAMESPACE = "__MEDIA_INTERNAL";
|
|
10
|
-
export type MediaGlobalScope = {
|
|
11
|
-
[GLOBAL_MEDIA_CARD_SSR]?: MediaCardSsr;
|
|
12
|
-
[GLOBAL_MEDIA_COUNT_SSR]?: number;
|
|
13
|
-
[GLOBAL_MEDIA_PERFORMANCE_ENTRIES]?: PerformanceEntry[];
|
|
14
|
-
};
|
|
15
|
-
type MediaFeatureFlags = {
|
|
16
|
-
'media-perf-uplift-mutation-fix'?: boolean;
|
|
17
|
-
'media-perf-lazy-loading-optimisation'?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare function getMediaGlobalScope(globalScope?: any): MediaGlobalScope;
|
|
20
|
-
export declare function getMediaCardSSR(globalScope?: any): MediaCardSsr;
|
|
21
|
-
export declare const getKey: ({ id, collectionName, occurrenceKey }: FileIdentifier, resizeMode?: string) => string;
|
|
22
|
-
export declare const generateScriptProps: (identifier: FileIdentifier, dataURI?: string, mode?: string, srcSet?: string, dimensions?: Partial<NumericalCardDimensions>, error?: MediaFilePreviewErrorInfo, featureFlags?: MediaFeatureFlags) => React.ScriptHTMLAttributes<HTMLScriptElement>;
|
|
23
|
-
export {};
|
|
@@ -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';
|
|
File without changes
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type NumericalCardDimensions } from '@atlaskit/media-common';
|
|
2
|
-
import { type MediaFilePreviewErrorInfo } from '../analytics';
|
|
3
|
-
export type MediaCardSsrData = {
|
|
4
|
-
dataURI?: string;
|
|
5
|
-
dimensions?: Partial<NumericalCardDimensions>;
|
|
6
|
-
error?: MediaFilePreviewErrorInfo;
|
|
7
|
-
mode?: string;
|
|
8
|
-
srcSet?: string;
|
|
9
|
-
loadPromise?: Promise<void>;
|
|
10
|
-
loading?: 'lazy' | '';
|
|
11
|
-
};
|
|
12
|
-
export type MediaCardSsr = Record<string, MediaCardSsrData>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type MutableRefObject } from 'react';
|
|
2
|
-
import { type MediaFilePreviewDimensions } from './types';
|
|
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 isWider: (current?: MediaFilePreviewDimensions, next?: MediaFilePreviewDimensions) => boolean;
|
|
9
|
-
export declare const createRequestDimensions: (dimensions: Partial<MediaFilePreviewDimensions>) => Partial<MediaFilePreviewDimensions> | undefined;
|
|
10
|
-
/** Stores the provided value in a ref object to avoid "component rerenders" when the value is used as a hook dependency */
|
|
11
|
-
export declare function useCurrentValueRef<T>(value: T): MutableRefObject<T>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { useFilePreview } from './useFilePreview';
|
|
2
|
-
export type { UseFilePreviewParams } from './useFilePreview';
|
|
3
|
-
export { useMediaImage } from './useMediaImage';
|
|
4
|
-
export type { UseMediaImageParams } from './useMediaImage';
|
|
5
|
-
export type { MediaFilePreview } from './types';
|
|
6
|
-
export { isMediaFilePreviewError } from './errors';
|
|
7
|
-
export type { MediaFilePreviewErrorPrimaryReason } from './errors';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type MediaFilePreviewSource = 'local' | 'remote' | 'ssr-server' | 'ssr-client' | 'ssr-data' | 'cache-local' | 'cache-remote' | 'external';
|
|
2
|
-
export type MediaFilePreviewDimensions = {
|
|
3
|
-
width?: number;
|
|
4
|
-
height?: number;
|
|
5
|
-
};
|
|
6
|
-
export interface MediaFilePreview {
|
|
7
|
-
dataURI: string;
|
|
8
|
-
srcSet?: string;
|
|
9
|
-
lazy?: boolean;
|
|
10
|
-
orientation?: number;
|
|
11
|
-
dimensions?: MediaFilePreviewDimensions;
|
|
12
|
-
source: MediaFilePreviewSource;
|
|
13
|
-
}
|
|
14
|
-
export type MediaFilePreviewStatus = 'loading' | 'complete' | 'error';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES, type ScriptHTMLAttributes } from 'react';
|
|
2
|
-
import { type FileIdentifier, type MediaBlobUrlAttrs, type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
-
import { type MediaTraceContext, type SSR } from '@atlaskit/media-common';
|
|
4
|
-
import { type SSRStatus } from './analytics';
|
|
5
|
-
import { MediaFilePreviewError } from './errors';
|
|
6
|
-
import { type MediaFilePreview, type MediaFilePreviewDimensions, type MediaFilePreviewStatus } from './types';
|
|
7
|
-
export interface UseFilePreviewParams {
|
|
8
|
-
/** Instance of file identifier. */
|
|
9
|
-
readonly identifier: FileIdentifier;
|
|
10
|
-
/** Resize the media to 'crop' | 'fit' | 'full-fit' */
|
|
11
|
-
readonly resizeMode?: MediaStoreGetFileImageParams['mode'];
|
|
12
|
-
/** Dimensions to be requested to the server. Will be scaled x2 in Retina Displays */
|
|
13
|
-
readonly dimensions?: MediaFilePreviewDimensions;
|
|
14
|
-
/** Server-Side-Rendering modes are "server" and "client" */
|
|
15
|
-
readonly ssr?: SSR;
|
|
16
|
-
/** Whether to use the srcSet for the preview. */
|
|
17
|
-
readonly useSrcSet?: boolean;
|
|
18
|
-
/** Attributes to attach to the created Blob Url */
|
|
19
|
-
readonly mediaBlobUrlAttrs?: MediaBlobUrlAttrs;
|
|
20
|
-
/** Trace context to be passed to the backend requests */
|
|
21
|
-
readonly traceContext?: MediaTraceContext;
|
|
22
|
-
/** Do not fetch a remote preview. Helpful for lazy loading */
|
|
23
|
-
readonly skipRemote?: boolean;
|
|
24
|
-
/** Define whether an animated image is acceptable to return */
|
|
25
|
-
readonly allowAnimated?: boolean;
|
|
26
|
-
/** Define the upscale strategy for this image. */
|
|
27
|
-
readonly upscale?: boolean;
|
|
28
|
-
/** Make the client receive the response with the given max-age cache control header. Minimum: 0, maximum: 9223372036854776000.
|
|
29
|
-
*/
|
|
30
|
-
readonly maxAge?: number;
|
|
31
|
-
/** Defines the source component */
|
|
32
|
-
readonly source?: string;
|
|
33
|
-
}
|
|
34
|
-
export declare const useFilePreview: ({ resizeMode, identifier, ssr, dimensions, useSrcSet, traceContext, skipRemote, mediaBlobUrlAttrs, allowAnimated, upscale, maxAge, source, }: UseFilePreviewParams) => {
|
|
35
|
-
preview: MediaFilePreview | undefined;
|
|
36
|
-
status: MediaFilePreviewStatus;
|
|
37
|
-
error: MediaFilePreviewError | undefined;
|
|
38
|
-
nonCriticalError: MediaFilePreviewError | undefined;
|
|
39
|
-
ssrReliability: SSRStatus;
|
|
40
|
-
onImageError: (failedPreview?: MediaFilePreview) => void;
|
|
41
|
-
onImageLoad: (newPreview?: MediaFilePreview) => void;
|
|
42
|
-
getSsrScriptProps: (() => ScriptHTMLAttributes<HTMLScriptElement>) | undefined;
|
|
43
|
-
copyNodeRef: (instance: HTMLDivElement | HTMLImageElement | null) => void | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES];
|
|
44
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type ScriptHTMLAttributes } from 'react';
|
|
2
|
-
import { type FileIdentifier, type MediaBlobUrlAttrs, type MediaStoreGetFileImageParams } from '@atlaskit/media-client';
|
|
3
|
-
import { type MediaTraceContext, type SSR } from '@atlaskit/media-common';
|
|
4
|
-
import type { MediaFilePreviewError } from './errors';
|
|
5
|
-
import { type MediaFilePreviewDimensions, type MediaFilePreviewSource, type MediaFilePreviewStatus } from './types';
|
|
6
|
-
export interface UseMediaImageParams {
|
|
7
|
-
/** Instance of file identifier. */
|
|
8
|
-
readonly identifier: FileIdentifier;
|
|
9
|
-
/** Resize the media to 'crop' | 'fit' | 'full-fit' */
|
|
10
|
-
readonly resizeMode?: MediaStoreGetFileImageParams['mode'];
|
|
11
|
-
/** Dimensions to be requested to the server. Will be scaled x2 in Retina Displays */
|
|
12
|
-
readonly dimensions?: MediaFilePreviewDimensions;
|
|
13
|
-
/** Server-Side-Rendering modes are "server" and "client" */
|
|
14
|
-
readonly ssr?: SSR;
|
|
15
|
-
/** Attributes to attach to the created Blob Url */
|
|
16
|
-
readonly mediaBlobUrlAttrs?: MediaBlobUrlAttrs;
|
|
17
|
-
/** Trace context to be passed to the backend requests */
|
|
18
|
-
readonly traceContext?: MediaTraceContext;
|
|
19
|
-
/** Do not fetch a remote preview. Helpful for lazy loading */
|
|
20
|
-
readonly skipRemote?: boolean;
|
|
21
|
-
/** Define whether an animated image is acceptable to return */
|
|
22
|
-
readonly allowAnimated?: boolean;
|
|
23
|
-
/** Define the upscale strategy for this image. */
|
|
24
|
-
readonly upscale?: boolean;
|
|
25
|
-
/** Make the client receive the response with the given max-age cache control header. Minimum: 0, maximum: 9223372036854776000.
|
|
26
|
-
*/
|
|
27
|
-
readonly maxAge?: number;
|
|
28
|
-
/** On image load and on error callback from the parent. We are keeping the name same to streamline the customer experience when using these properties back to their image components */
|
|
29
|
-
readonly onLoad?: () => void;
|
|
30
|
-
readonly onError?: () => void;
|
|
31
|
-
}
|
|
32
|
-
export declare const useMediaImage: ({ identifier, resizeMode, dimensions, ssr, mediaBlobUrlAttrs, traceContext, skipRemote, allowAnimated, upscale, maxAge, onLoad: onLoadCallback, onError: onErrorCallback, }: UseMediaImageParams) => {
|
|
33
|
-
status: MediaFilePreviewStatus;
|
|
34
|
-
error: MediaFilePreviewError | undefined;
|
|
35
|
-
getImgProps: () => {
|
|
36
|
-
src: string | undefined;
|
|
37
|
-
onLoad: () => void;
|
|
38
|
-
onError: () => void;
|
|
39
|
-
alt: string;
|
|
40
|
-
"data-test-file-id": string;
|
|
41
|
-
"data-test-collection": string | undefined;
|
|
42
|
-
"data-test-preview-source": MediaFilePreviewSource | undefined;
|
|
43
|
-
};
|
|
44
|
-
getSsrScriptProps: (() => ScriptHTMLAttributes<HTMLScriptElement>) | undefined;
|
|
45
|
-
};
|