@atlaskit/media-file-preview 0.18.0 → 1.0.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/AGENTS.md +59 -0
- package/CHANGELOG.md +35 -0
- package/errors/package.json +1 -8
- package/package.json +12 -20
- 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 -22
- 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 -46
- package/dist/types-ts4.5/useMediaImage.d.ts +0 -45
package/AGENTS.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# media-file-preview — Agent Guide
|
|
2
|
+
|
|
3
|
+
> **Parent guide:** Always read [`../AGENTS.md`](../AGENTS.md) before working in this package — it
|
|
4
|
+
> contains workspace-wide rules covering platform guidelines, changeset workflow, accessibility
|
|
5
|
+
> standards, and the knowledge index protocol that applies to every Media package.
|
|
6
|
+
|
|
7
|
+
## Package identity
|
|
8
|
+
|
|
9
|
+
| Field | Value |
|
|
10
|
+
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
11
|
+
| NPM name | `@atlaskit/media-file-preview` |
|
|
12
|
+
| Path | `media-file-preview/` |
|
|
13
|
+
| Owner | Media Exif |
|
|
14
|
+
| Purpose | React hooks for fetching and rendering media file previews — `useFilePreview` for general previews and `useMediaImage` for image rendering |
|
|
15
|
+
|
|
16
|
+
## Knowledge index
|
|
17
|
+
|
|
18
|
+
> Read, search, edit, investigate, and validate the repository knowledge index at
|
|
19
|
+
> `.agents/knowledge-index/`. ALWAYS use this skill before making ANY repo change, or when exploring
|
|
20
|
+
> the codebase. The knowledge index is the canonical starting point for every coding task in this
|
|
21
|
+
> repo, trigger this skill aggressively whenever the user mentions architecture, conventions,
|
|
22
|
+
> packages, modules, services, build, coding, writing code, APIs, feature flags, testing, or
|
|
23
|
+
> anything similar. Also trigger when "is the knowledge index up to date?" / "update the knowledge
|
|
24
|
+
> index" / "what does the knowledge index say about Y?" — even if they don't say the words
|
|
25
|
+
> "knowledge index". Also use it (via the `validate` subcommand) to detect drift between the
|
|
26
|
+
> codebase and the docs after any code change. Use the `generate` subcommand to bootstrap the index
|
|
27
|
+
> in a new repository.
|
|
28
|
+
|
|
29
|
+
**Entry point:** `.agents/knowledge-index/INDEX.md`
|
|
30
|
+
**Unit doc:** `.agents/knowledge-index/domains/media/units/atlaskit-media-file-preview.md`
|
|
31
|
+
**Standards page:** `.agents/knowledge-index/domains/media/units/atlaskit-media-file-preview/standards-and-patterns.md`
|
|
32
|
+
**CLI:** `python3 .agents/skills/knowledge-index/scripts/kg.py {find,read,edit,investigate,validate,init,explore,generate} …`
|
|
33
|
+
**Refresh protocol:** never silently bump `Last verified` — always re-read the listed `Sources` first, edit, then `kg.py edit <path> --message "<reason>"`.
|
|
34
|
+
|
|
35
|
+
## Key source files
|
|
36
|
+
|
|
37
|
+
- `src/index.ts` — public API entry point
|
|
38
|
+
- `src/useFilePreview.tsx` — primary hook for file preview state
|
|
39
|
+
- `src/useMediaImage.tsx` — hook for image blob URL resolution
|
|
40
|
+
- `src/getPreview/` — preview resolution strategies per media type
|
|
41
|
+
- `src/globalScope/` — browser globals abstraction (for SSR safety)
|
|
42
|
+
- `src/types.ts` — shared type definitions
|
|
43
|
+
- `src/errors.ts` — error types and predicates
|
|
44
|
+
- `src/analytics.ts` — analytics event helpers
|
|
45
|
+
|
|
46
|
+
## Public API (key exports)
|
|
47
|
+
|
|
48
|
+
`useFilePreview`, `UseFilePreviewParams`, `useMediaImage`, `UseMediaImageParams`,
|
|
49
|
+
`MediaFilePreview`, `isMediaFilePreviewError`, `MediaFilePreviewErrorPrimaryReason`
|
|
50
|
+
|
|
51
|
+
## Development notes
|
|
52
|
+
|
|
53
|
+
- React Compiler is enabled for this package
|
|
54
|
+
- Peer dependencies: `react`, `react-dom`
|
|
55
|
+
- 5 feature flags registered (see `package.json` → `platform-feature-flags`)
|
|
56
|
+
- Includes SSR-safe preview behaviour
|
|
57
|
+
- Export subpaths: `.`, `./errors`, `./types`, `./use-file-preview`, `./use-media-image`
|
|
58
|
+
- All new behaviour changes must be behind a feature gate (`fg()` from
|
|
59
|
+
`@atlaskit/platform-feature-flags`)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @atlaskit/media-file-preview
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ee28cf33718b0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ee28cf33718b0) -
|
|
8
|
+
Add @atlassian/react-compiler-gating as a runtime dependency to enable React Compiler platform
|
|
9
|
+
gating.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 1.0.0
|
|
13
|
+
|
|
14
|
+
### Major Changes
|
|
15
|
+
|
|
16
|
+
- [`f2dc9097319f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2dc9097319f0) - ###
|
|
17
|
+
Dropped support for _legacy_ Typescript 4 types. **Typescript 5 is now the new minimum**.
|
|
18
|
+
|
|
19
|
+
Removes the `typesVersions` property and `dist/types-ts4.5` directory from the dist.
|
|
20
|
+
|
|
21
|
+
Types are now exclusively via the `"types": "dist/types/index.d.ts"` property.
|
|
22
|
+
|
|
23
|
+
```diff
|
|
24
|
+
- "typesVersions": {
|
|
25
|
+
- ">=4.5 <4.9": {
|
|
26
|
+
- "*": [
|
|
27
|
+
- "dist/types-ts4.5/*",
|
|
28
|
+
- "dist/types-ts4.5/index.d.ts"
|
|
29
|
+
- ]
|
|
30
|
+
- }
|
|
31
|
+
- },
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies
|
|
37
|
+
|
|
3
38
|
## 0.18.0
|
|
4
39
|
|
|
5
40
|
### Minor Changes
|
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.1",
|
|
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,16 @@
|
|
|
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.1.0",
|
|
33
|
+
"@atlaskit/media-client-react": "^6.0.0",
|
|
34
|
+
"@atlaskit/media-common": "^14.1.0",
|
|
35
|
+
"@atlaskit/media-ui": "^30.3.0",
|
|
36
|
+
"@atlaskit/platform-feature-flags": "^2.0.0",
|
|
37
|
+
"@atlaskit/react-ufo": "^7.1.0",
|
|
38
|
+
"@atlassian/react-compiler-gating": "^0.2.0",
|
|
46
39
|
"@babel/runtime": "^7.0.0",
|
|
47
40
|
"lru_map": "^0.4.1"
|
|
48
41
|
},
|
|
@@ -53,13 +46,12 @@
|
|
|
53
46
|
"devDependencies": {
|
|
54
47
|
"@af/integration-testing": "workspace:^",
|
|
55
48
|
"@af/visual-regression": "workspace:^",
|
|
56
|
-
"@atlaskit/media-state": "^
|
|
57
|
-
"@atlaskit/media-test-data": "^
|
|
58
|
-
"@atlaskit/section-message": "^
|
|
49
|
+
"@atlaskit/media-state": "^3.0.0",
|
|
50
|
+
"@atlaskit/media-test-data": "^4.0.0",
|
|
51
|
+
"@atlaskit/section-message": "^9.1.0",
|
|
59
52
|
"@atlaskit/ssr": "workspace:^",
|
|
60
|
-
"@atlassian/a11y-jest-testing": "^0.
|
|
53
|
+
"@atlassian/a11y-jest-testing": "^0.12.0",
|
|
61
54
|
"@atlassian/feature-flags-test-utils": "^1.1.0",
|
|
62
|
-
"@atlassian/react-compiler-gating": "workspace:^",
|
|
63
55
|
"@atlassian/testing-library": "^0.6.0",
|
|
64
56
|
"@testing-library/react": "^16.3.0",
|
|
65
57
|
"react": "^18.2.0",
|
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,22 +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
|
-
/**
|
|
5
|
-
* Pull the CDN-signing query params (token / Policy / Key-Pair-Id / Signature
|
|
6
|
-
* / Expires) out of a pre-signed CDN URL so they can be overlaid on a URL
|
|
7
|
-
* built independently by `getImageUrlSync` (which constructs path, image
|
|
8
|
-
* params, pathBased routing, wmv, etc.). Image-shape params from the cdn URL
|
|
9
|
-
* itself (width/height/mode/...) are intentionally NOT extracted — those come
|
|
10
|
-
* from `imageURLParams` via `getImageUrlSync`.
|
|
11
|
-
*
|
|
12
|
-
* Returns `{}` on parse failure so we degrade rather than throw.
|
|
13
|
-
*/
|
|
14
|
-
export declare const extractCdnSigningParams: (cdnUrl: string) => Record<string, string>;
|
|
15
|
-
export declare const getSSRPreview: (ssr: SSR, mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs, cdnSigningParams?: Record<string, string>) => MediaFilePreview;
|
|
16
|
-
export declare const isLocalPreview: (preview: MediaFilePreview) => boolean;
|
|
17
|
-
export declare const isRemotePreview: (preview: MediaFilePreview) => boolean;
|
|
18
|
-
export declare const isSSRClientPreview: (preview: MediaFilePreview) => boolean;
|
|
19
|
-
export declare const isSSRDataPreview: (preview: MediaFilePreview) => boolean;
|
|
20
|
-
export declare const isSSRPreview: (preview: MediaFilePreview) => boolean;
|
|
21
|
-
export declare const getAndCacheRemotePreview: (mediaClient: MediaClient, id: string, dimensions: MediaFilePreviewDimensions, params: MediaStoreGetFileImageParams, mediaBlobUrlAttrs?: MediaBlobUrlAttrs, traceContext?: MediaTraceContext) => Promise<MediaFilePreview>;
|
|
22
|
-
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, extractCdnSigningParams, } 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,46 +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 FileState, 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
|
-
/** Initial file state to be used for the preview. */
|
|
34
|
-
readonly initialFileState?: FileState;
|
|
35
|
-
}
|
|
36
|
-
export declare const useFilePreview: ({ resizeMode, identifier, ssr, dimensions, useSrcSet, traceContext, skipRemote, mediaBlobUrlAttrs, allowAnimated, upscale, maxAge, source, initialFileState, }: UseFilePreviewParams) => {
|
|
37
|
-
preview: MediaFilePreview | undefined;
|
|
38
|
-
status: MediaFilePreviewStatus;
|
|
39
|
-
error: MediaFilePreviewError | undefined;
|
|
40
|
-
nonCriticalError: MediaFilePreviewError | undefined;
|
|
41
|
-
ssrReliability: SSRStatus;
|
|
42
|
-
onImageError: (failedPreview?: MediaFilePreview) => void;
|
|
43
|
-
onImageLoad: (newPreview?: MediaFilePreview) => void;
|
|
44
|
-
getSsrScriptProps: (() => ScriptHTMLAttributes<HTMLScriptElement>) | undefined;
|
|
45
|
-
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];
|
|
46
|
-
};
|
|
@@ -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
|
-
};
|