@atlaskit/media-client 23.2.0 → 24.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/client/file-fetcher/index.js +110 -34
  3. package/dist/cjs/client/media-client.js +18 -6
  4. package/dist/cjs/client/media-store/index.js +1 -2
  5. package/dist/cjs/client/mobile-upload.js +38 -2
  6. package/dist/cjs/index.js +7 -0
  7. package/dist/cjs/utils/with-media-client-hoc.js +8 -16
  8. package/dist/es2019/client/file-fetcher/index.js +101 -28
  9. package/dist/es2019/client/media-client.js +15 -7
  10. package/dist/es2019/client/media-store/index.js +1 -2
  11. package/dist/es2019/client/mobile-upload.js +33 -2
  12. package/dist/es2019/index.js +1 -0
  13. package/dist/es2019/utils/with-media-client-hoc.js +8 -16
  14. package/dist/esm/client/file-fetcher/index.js +106 -30
  15. package/dist/esm/client/media-client.js +19 -7
  16. package/dist/esm/client/media-store/index.js +1 -2
  17. package/dist/esm/client/mobile-upload.js +38 -2
  18. package/dist/esm/index.js +1 -0
  19. package/dist/esm/utils/with-media-client-hoc.js +8 -16
  20. package/dist/types/client/events.d.ts +1 -1
  21. package/dist/types/client/file-fetcher/index.d.ts +10 -6
  22. package/dist/types/client/media-client.d.ts +10 -5
  23. package/dist/types/client/media-store/index.d.ts +3 -4
  24. package/dist/types/client/mobile-upload.d.ts +6 -2
  25. package/dist/types/file-streams-cache.d.ts +1 -1
  26. package/dist/types/index.d.ts +4 -2
  27. package/dist/types/models/artifacts.d.ts +1 -14
  28. package/dist/types/models/file-state.d.ts +4 -73
  29. package/dist/types/models/media.d.ts +1 -1
  30. package/dist/types/models/mobile-upload.d.ts +1 -1
  31. package/dist/types/utils/createMediaSubject.d.ts +1 -1
  32. package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +1 -1
  33. package/dist/types/utils/mediaSubscribable/toPromise.d.ts +1 -1
  34. package/dist/types/utils/mediaSubscribable/types.d.ts +1 -1
  35. package/dist/types/utils/mobileUpload/helpers.d.ts +1 -1
  36. package/dist/types/utils/mobileUpload/stateMachine/index.d.ts +1 -1
  37. package/dist/types/utils/mobileUpload/stateMachine/types.d.ts +1 -1
  38. package/dist/types/utils/overrideMediaTypeIfUnknown.d.ts +1 -1
  39. package/dist/types/utils/shouldFetchRemoteFileStates.d.ts +1 -1
  40. package/dist/types/utils/with-media-client-hoc.d.ts +2 -3
  41. package/dist/types-ts4.5/client/events.d.ts +1 -1
  42. package/dist/types-ts4.5/client/file-fetcher/index.d.ts +10 -6
  43. package/dist/types-ts4.5/client/media-client.d.ts +10 -5
  44. package/dist/types-ts4.5/client/media-store/index.d.ts +3 -4
  45. package/dist/types-ts4.5/client/mobile-upload.d.ts +6 -2
  46. package/dist/types-ts4.5/file-streams-cache.d.ts +1 -1
  47. package/dist/types-ts4.5/index.d.ts +4 -2
  48. package/dist/types-ts4.5/models/artifacts.d.ts +1 -14
  49. package/dist/types-ts4.5/models/file-state.d.ts +4 -73
  50. package/dist/types-ts4.5/models/media.d.ts +1 -1
  51. package/dist/types-ts4.5/models/mobile-upload.d.ts +1 -1
  52. package/dist/types-ts4.5/utils/createMediaSubject.d.ts +1 -1
  53. package/dist/types-ts4.5/utils/mediaSubscribable/fromObservable.d.ts +1 -1
  54. package/dist/types-ts4.5/utils/mediaSubscribable/toPromise.d.ts +1 -1
  55. package/dist/types-ts4.5/utils/mediaSubscribable/types.d.ts +1 -1
  56. package/dist/types-ts4.5/utils/mobileUpload/helpers.d.ts +1 -1
  57. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/index.d.ts +1 -1
  58. package/dist/types-ts4.5/utils/mobileUpload/stateMachine/types.d.ts +1 -1
  59. package/dist/types-ts4.5/utils/overrideMediaTypeIfUnknown.d.ts +1 -1
  60. package/dist/types-ts4.5/utils/shouldFetchRemoteFileStates.d.ts +1 -1
  61. package/dist/types-ts4.5/utils/with-media-client-hoc.d.ts +2 -3
  62. package/package.json +5 -3
  63. package/report.api.md +51 -168
  64. package/tmp/api-report-tmp.d.ts +51 -160
@@ -6,11 +6,11 @@ export type { MediaItemType, FileItem, FileProcessingStatus, MediaArtifact, Arti
6
6
  export { isPreviewableType } from './models/media';
7
7
  export type { MediaFileProcessingStatus, MediaType, MediaFile, MediaRepresentations, MediaItemDetails, MediaUpload, MediaChunksProbe, } from './models/media';
8
8
  export { getArtifactUrl } from './models/artifacts';
9
- export type { MediaFileArtifact, MediaFileArtifacts } from './models/artifacts';
10
9
  export { isMediaClientError, getMediaClientErrorReason } from './models/errors';
11
10
  export type { MediaClientError, MediaClientErrorReason, MediaClientErrorAttributes, } from './models/errors';
12
11
  export { isUploadingFileState, isProcessingFileState, isProcessedFileState, isErrorFileState, isPreviewableFileState, isFinalFileState, isImageRepresentationReady, mapMediaFileToFileState, mapMediaItemToFileState, } from './models/file-state';
13
- export type { FileStatus, FilePreview, PreviewOptions, GetFileOptions, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState, ErrorFileState, NonErrorFileState, PreviewableFileState, FileState, } from './models/file-state';
12
+ export type { FileStatus, PreviewOptions, GetFileOptions, NonErrorFileState, PreviewableFileState, } from './models/file-state';
13
+ export type { FileState, FilePreview, ErrorFileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState, MediaFileArtifact, MediaFileArtifacts, } from '@atlaskit/media-state';
14
14
  export type { MobileUpload, MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent, } from './models/mobile-upload';
15
15
  export { uploadFile } from './uploader';
16
16
  export type { UploadableFile, UploadableFileUpfrontIds, UploadFileCallbacks, UploadFileResult, } from './uploader';
@@ -39,12 +39,14 @@ export type { Identifier, FileIdentifier, ExternalImageIdentifier, } from './ide
39
39
  export type { EventPayloadListener, UploadEventPayloadMap, MediaViewedEventPayload, } from './client/events';
40
40
  export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
41
41
  export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClientFunction, WithMediaClient, } from './utils/with-media-client-hoc';
42
+ export type { MediaClientConfig } from '@atlaskit/media-core';
42
43
  export { globalMediaEventEmitter } from './globalMediaEventEmitter';
43
44
  export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
44
45
  export type { MediaBlobUrlAttrs } from './utils/url';
45
46
  export { createMediaSubscribable, fromObservable, } from './utils/mediaSubscribable';
46
47
  export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/mediaSubscribable';
47
48
  export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
49
+ export { getFileStreamsCache } from './file-streams-cache';
48
50
  /**
49
51
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
50
52
  */
@@ -1,15 +1,2 @@
1
- import type { MediaFileProcessingStatus } from './media';
2
- export type MediaFileArtifact = {
3
- readonly url: string;
4
- readonly processingStatus: MediaFileProcessingStatus;
5
- };
6
- export interface MediaFileArtifacts {
7
- 'video_1280.mp4'?: MediaFileArtifact;
8
- 'video_640.mp4'?: MediaFileArtifact;
9
- 'document.pdf'?: MediaFileArtifact;
10
- 'audio.mp3'?: MediaFileArtifact;
11
- 'thumb.jpg'?: MediaFileArtifact;
12
- 'image.png'?: MediaFileArtifact;
13
- 'image.jpg'?: MediaFileArtifact;
14
- }
1
+ import { MediaFileArtifacts } from '@atlaskit/media-state';
15
2
  export declare const getArtifactUrl: (artifacts: MediaFileArtifacts, prop: keyof MediaFileArtifacts) => string | undefined;
@@ -1,19 +1,8 @@
1
- import { FileStatus as CommonFileStatus, MediaTraceContext } from '@atlaskit/media-common';
1
+ import { FileStatus as CommonFileStatus } from '@atlaskit/media-common';
2
2
  import { MediaStoreResponse } from '../client/media-store';
3
- import { MediaFileArtifacts } from './artifacts';
4
- import { MediaItemDetails, MediaFile, MediaRepresentations, MediaType } from './media';
5
- export type BaseFileState = {
6
- metadataTraceContext?: MediaTraceContext;
7
- };
3
+ import { MediaItemDetails, MediaFile } from './media';
4
+ import { FilePreview, FileState, ErrorFileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState } from '@atlaskit/media-state';
8
5
  export type FileStatus = CommonFileStatus;
9
- export interface FilePreview {
10
- value: Blob | string;
11
- origin?: 'local' | 'remote';
12
- originalDimensions?: {
13
- width: number;
14
- height: number;
15
- };
16
- }
17
6
  export interface PreviewOptions {
18
7
  }
19
8
  export interface GetFileOptions {
@@ -21,74 +10,16 @@ export interface GetFileOptions {
21
10
  collectionName?: string;
22
11
  occurrenceKey?: string;
23
12
  }
24
- export interface UploadingFileState extends BaseFileState {
25
- status: 'uploading';
26
- id: string;
27
- occurrenceKey?: string;
28
- name: string;
29
- size: number;
30
- progress: number;
31
- mediaType: MediaType;
32
- mimeType: string;
33
- preview?: FilePreview | Promise<FilePreview>;
34
- createdAt?: number;
35
- }
36
13
  export interface PreviewableFileState {
37
14
  preview: FilePreview | Promise<FilePreview>;
38
15
  }
39
- export interface ProcessingFileState extends BaseFileState {
40
- status: 'processing';
41
- id: string;
42
- occurrenceKey?: string;
43
- name: string;
44
- size: number;
45
- artifacts?: MediaFileArtifacts;
46
- mediaType: MediaType;
47
- mimeType: string;
48
- preview?: FilePreview | Promise<FilePreview>;
49
- representations?: MediaRepresentations;
50
- createdAt?: number;
51
- }
52
- export interface ProcessedFileState extends BaseFileState {
53
- status: 'processed';
54
- id: string;
55
- occurrenceKey?: string;
56
- name: string;
57
- size: number;
58
- artifacts: MediaFileArtifacts;
59
- mediaType: MediaType;
60
- mimeType: string;
61
- preview?: FilePreview | Promise<FilePreview>;
62
- representations?: MediaRepresentations;
63
- createdAt?: number;
64
- }
65
- export interface ProcessingFailedState extends BaseFileState {
66
- status: 'failed-processing';
67
- id: string;
68
- occurrenceKey?: string;
69
- name: string;
70
- size: number;
71
- artifacts: Object;
72
- mediaType: MediaType;
73
- mimeType: string;
74
- preview?: FilePreview | Promise<FilePreview>;
75
- representations?: MediaRepresentations;
76
- createdAt?: number;
77
- }
78
- export interface ErrorFileState extends BaseFileState {
79
- status: 'error';
80
- id: string;
81
- occurrenceKey?: string;
82
- message?: string;
83
- }
84
- export type FileState = UploadingFileState | ProcessingFileState | ProcessedFileState | ErrorFileState | ProcessingFailedState;
85
16
  export type NonErrorFileState = Exclude<FileState, ErrorFileState>;
86
17
  export declare const isUploadingFileState: (fileState: FileState) => fileState is UploadingFileState;
87
18
  export declare const isProcessingFileState: (fileState: FileState) => fileState is ProcessingFileState;
88
19
  export declare const isProcessedFileState: (fileState: FileState) => fileState is ProcessedFileState;
89
20
  export declare const isErrorFileState: (fileState: FileState) => fileState is ErrorFileState;
90
21
  export declare const isPreviewableFileState: (fileState: FileState) => fileState is (UploadingFileState | ProcessingFileState | ProcessedFileState | ProcessingFailedState) & PreviewableFileState;
91
- export declare const isFinalFileState: (fileState: FileState) => fileState is ProcessedFileState | ProcessingFailedState | ErrorFileState;
22
+ export declare const isFinalFileState: (fileState: FileState) => fileState is ProcessedFileState | ErrorFileState | ProcessingFailedState;
92
23
  export declare const isImageRepresentationReady: (fileState: FileState) => boolean;
93
24
  export declare const mapMediaFileToFileState: (mediaFile: MediaStoreResponse<MediaFile>) => FileState;
94
25
  export declare const mapMediaItemToFileState: (id: string, item: MediaItemDetails) => FileState;
@@ -1,5 +1,5 @@
1
1
  import { MediaTraceContext, MediaType } from '@atlaskit/media-common';
2
- import type { MediaFileArtifacts } from './artifacts';
2
+ import { MediaFileArtifacts } from '@atlaskit/media-state';
3
3
  export type MediaFileProcessingStatus = 'pending' | 'succeeded' | 'failed';
4
4
  export type { MediaType } from '@atlaskit/media-common';
5
5
  export declare const isPreviewableType: (type: MediaType) => boolean;
@@ -1,4 +1,4 @@
1
- import { FilePreview } from './file-state';
1
+ import { FilePreview } from '@atlaskit/media-state';
2
2
  export type MobileUploadStartEvent = {
3
3
  fileId: string;
4
4
  collectionName?: string;
@@ -1,3 +1,3 @@
1
1
  import { ReplaySubject } from 'rxjs/ReplaySubject';
2
- import { FileState } from '../models/file-state';
2
+ import { FileState } from '@atlaskit/media-state';
3
3
  export declare function createMediaSubject<T extends FileState>(initialState?: T | Error): ReplaySubject<T>;
@@ -1,5 +1,5 @@
1
1
  import { ReplaySubject } from 'rxjs/ReplaySubject';
2
- import { FileState } from '../../models/file-state';
2
+ import { FileState } from '@atlaskit/media-state';
3
3
  import { MediaSubscribable } from './types';
4
4
  export declare function fromObservable(observable: ReplaySubject<FileState>): MediaSubscribable;
5
5
  export declare function createMediaSubscribable(item?: FileState | Error): MediaSubscribable;
@@ -1,6 +1,6 @@
1
1
  import { Subscription } from 'rxjs/Subscription';
2
2
  import { MediaSubscribable } from './types';
3
- import { FileState } from '../../models/file-state';
3
+ import { FileState } from '@atlaskit/media-state';
4
4
  /**
5
5
  * This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
6
6
  *
@@ -1,4 +1,4 @@
1
- import { FileState } from '../../models/file-state';
1
+ import { FileState } from '@atlaskit/media-state';
2
2
  export type MediaSubscription = {
3
3
  unsubscribe: () => void;
4
4
  };
@@ -1,7 +1,7 @@
1
1
  import Dataloader from 'dataloader';
2
2
  import { ReplaySubject } from 'rxjs/ReplaySubject';
3
3
  import { Interpreter } from 'xstate';
4
- import { FileState } from '../../models/file-state';
4
+ import { FileState } from '@atlaskit/media-state';
5
5
  import { DataloaderKey, DataloaderResult } from '../createFileDataLoader';
6
6
  import { StateMachineContext, StateMachineEvent, StateMachineTypestate } from './stateMachine/types';
7
7
  export declare const createMobileFileStateSubject: (service: Interpreter<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>) => ReplaySubject<FileState>;
@@ -1,6 +1,6 @@
1
1
  import DataLoader from 'dataloader';
2
2
  import { Interpreter, StateMachine } from 'xstate';
3
- import { UploadingFileState } from '../../../models/file-state';
3
+ import { UploadingFileState } from '@atlaskit/media-state';
4
4
  import { DataloaderKey, DataloaderResult } from '../../createFileDataLoader';
5
5
  import { StateMachineContext, StateMachineEvent, StateMachineSchema, StateMachineTypestate } from './types';
6
6
  export declare const createMobileUploadStateMachine: (dataloader: DataLoader<DataloaderKey, DataloaderResult>, initialState: UploadingFileState, collectionName?: string) => StateMachine<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>;
@@ -1,5 +1,5 @@
1
1
  import { StateSchema } from 'xstate';
2
- import { FileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ErrorFileState, ProcessingFailedState } from '../../../models/file-state';
2
+ import { FileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ErrorFileState, ProcessingFailedState } from '@atlaskit/media-state';
3
3
  export type StateMachineContext = {
4
4
  currentFileState: FileState;
5
5
  };
@@ -1,4 +1,4 @@
1
- import { FileState } from '../models/file-state';
1
+ import { FileState } from '@atlaskit/media-state';
2
2
  import { MediaType } from '../models/media';
3
3
  export declare const overrideMediaTypeIfUnknown: (fileState: FileState, mediaType?: MediaType) => {
4
4
  mediaType?: MediaType | undefined;
@@ -1,4 +1,4 @@
1
- import { FilePreview } from '../models/file-state';
1
+ import { FilePreview } from '@atlaskit/media-state';
2
2
  import { MediaType } from '../models/media';
3
3
  /**
4
4
  * Async helper determining if we should fetch remote fileStates from the backend:
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { MediaClientConfig } from '@atlaskit/media-core';
3
- import { MediaFeatureFlags } from '@atlaskit/media-common';
4
3
  import { MediaClient } from '../client/media-client';
5
4
  import { Identifier } from '../identifier';
6
5
  export interface WithMediaClientConfig {
@@ -10,7 +9,7 @@ export interface WithMediaClient {
10
9
  mediaClient: MediaClient;
11
10
  identifier?: Identifier;
12
11
  }
13
- export declare const getMediaClient: (mediaClientConfig: MediaClientConfig, featureFlags?: MediaFeatureFlags) => MediaClient;
12
+ export declare const getMediaClient: (mediaClientConfig: MediaClientConfig) => MediaClient;
14
13
  export type WithMediaClientConfigProps<P extends WithMediaClient> = Omit<P, 'mediaClient'> & WithMediaClientConfig;
15
- export type WithMediaClientFunction = <P extends WithMediaClient>(Component: React.ComponentType<P>, featureFlags?: MediaFeatureFlags) => React.ComponentType<WithMediaClientConfigProps<P>>;
14
+ export type WithMediaClientFunction = <P extends WithMediaClient>(Component: React.ComponentType<P>) => React.ComponentType<WithMediaClientConfigProps<P>>;
16
15
  export declare const withMediaClient: WithMediaClientFunction;
@@ -1,4 +1,4 @@
1
- import { FileState } from '../models/file-state';
1
+ import { FileState } from '@atlaskit/media-state';
2
2
  export type EventPayloadMap<P> = {
3
3
  readonly [event: string]: P;
4
4
  };
@@ -1,14 +1,15 @@
1
1
  import 'setimmediate';
2
2
  import { AuthProvider } from '@atlaskit/media-core';
3
- import { MediaStore, MediaStoreCopyFileWithTokenParams, TouchedFiles, TouchFileDescriptor } from '../media-store';
4
- import { FilePreview, FileState, GetFileOptions } from '../../models/file-state';
3
+ import { MediaFileArtifacts } from '@atlaskit/media-state';
4
+ import { MediaStore as MediaApi, MediaStoreCopyFileWithTokenParams, TouchedFiles, TouchFileDescriptor } from '../media-store';
5
+ import { GetFileOptions } from '../../models/file-state';
5
6
  import { MediaFile } from '../../models/media';
6
7
  import { UploadableFile, UploadableFileUpfrontIds } from '../../uploader';
7
- import { MediaFileArtifacts } from '../../models/artifacts';
8
8
  import { UploadController } from '../../upload-controller';
9
9
  import { MediaSubscribable } from '../../utils/mediaSubscribable';
10
10
  import { Dimensions } from '../../utils/getDimensionsFromBlob';
11
11
  import { MediaTraceContext } from '@atlaskit/media-common';
12
+ import { FilePreview, FileState, MediaStore } from '@atlaskit/media-state';
12
13
  export type { FileFetcherErrorAttributes, FileFetcherErrorReason, } from './error';
13
14
  export { isFileFetcherError, FileFetcherError } from './error';
14
15
  export interface CopySourceFile {
@@ -18,7 +19,7 @@ export interface CopySourceFile {
18
19
  }
19
20
  export interface CopyDestination extends MediaStoreCopyFileWithTokenParams {
20
21
  authProvider: AuthProvider;
21
- mediaStore?: MediaStore;
22
+ mediaStore?: MediaApi;
22
23
  }
23
24
  export interface CopyFileOptions {
24
25
  preview?: FilePreview | Promise<FilePreview>;
@@ -40,9 +41,12 @@ export interface FileFetcher {
40
41
  getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
41
42
  }
42
43
  export declare class FileFetcherImpl implements FileFetcher {
43
- private readonly mediaStore;
44
+ private readonly mediaApi;
45
+ private readonly store;
44
46
  private readonly dataloader;
45
- constructor(mediaStore: MediaStore);
47
+ constructor(mediaApi: MediaApi, store?: MediaStore);
48
+ private getErrorFileState;
49
+ private setFileState;
46
50
  getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
47
51
  getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
48
52
  getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
@@ -1,20 +1,25 @@
1
1
  import { MediaClientConfig } from '@atlaskit/media-core';
2
- import { MediaFeatureFlags, MediaTraceContext } from '@atlaskit/media-common';
3
- import { MediaStore, MediaStoreGetFileImageParams, ImageMetadata } from './media-store';
2
+ import { MediaTraceContext } from '@atlaskit/media-common';
3
+ import { MediaStore as MediaApi, MediaStoreGetFileImageParams, ImageMetadata } from './media-store';
4
4
  import { FileFetcher } from './file-fetcher';
5
5
  import { UploadEventPayloadMap, EventPayloadListener } from './events';
6
6
  import { StargateClient } from './stargate-client';
7
7
  import { MobileUpload } from '../models/mobile-upload';
8
+ import { MediaStore } from '@atlaskit/media-state';
8
9
  export declare class MediaClient {
9
10
  readonly mediaClientConfig: MediaClientConfig;
10
- readonly featureFlags?: MediaFeatureFlags | undefined;
11
- readonly mediaStore: MediaStore;
11
+ private readonly store;
12
+ readonly mediaStore: MediaApi;
12
13
  readonly file: FileFetcher;
13
14
  readonly stargate: StargateClient;
14
15
  private readonly eventEmitter;
15
16
  private mobileUpload?;
16
17
  readonly config: MediaClientConfig;
17
- constructor(mediaClientConfig: MediaClientConfig, featureFlags?: MediaFeatureFlags | undefined);
18
+ constructor(mediaClientConfig: MediaClientConfig, store?: MediaStore, mediaApi?: MediaApi);
19
+ /**
20
+ * @internal
21
+ */
22
+ __DO_NOT_USE__getMediaStore(): MediaStore;
18
23
  getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceContext?: MediaTraceContext): Promise<Blob>;
19
24
  getImageUrl(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
20
25
  getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
@@ -1,14 +1,13 @@
1
1
  import { AsapBasedAuth, AuthContext, ClientAltBasedAuth, MediaApiConfig, Auth } from '@atlaskit/media-core';
2
- import { MediaFeatureFlags, MediaTraceContext } from '@atlaskit/media-common';
3
- import { MediaFileArtifacts } from '../../models/artifacts';
2
+ import { MediaTraceContext } from '@atlaskit/media-common';
3
+ import { MediaFileArtifacts } from '@atlaskit/media-state';
4
4
  import { MediaChunksProbe, MediaItemDetails, MediaFile, MediaUpload } from '../../models/media';
5
5
  import { ClientOptions, RequestHeaders, RequestMethod, RequestParams, RequestMetadata } from '../../utils/request/types';
6
6
  export type { MediaStoreErrorReason, MediaStoreErrorAttributes } from './error';
7
7
  export { MediaStoreError, isMediaStoreError } from './error';
8
8
  export declare class MediaStore {
9
9
  private readonly config;
10
- readonly featureFlags?: MediaFeatureFlags | undefined;
11
- constructor(config: MediaApiConfig, featureFlags?: MediaFeatureFlags | undefined);
10
+ constructor(config: MediaApiConfig);
12
11
  removeCollectionFile(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
13
12
  createUpload(createUpTo?: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaUpload[]>>;
14
13
  uploadChunk(etag: string, blob: Blob, uploadId: string, partNumber: number, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
@@ -1,11 +1,15 @@
1
+ import { MediaStore } from '@atlaskit/media-state';
1
2
  import { MobileUpload, MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent } from '../models/mobile-upload';
2
- import { MediaStore } from './media-store';
3
+ import { MediaStore as MediaApi } from './media-store';
3
4
  export declare class MobileUploadImpl implements MobileUpload {
5
+ private readonly store;
4
6
  private readonly dataloader;
5
7
  private readonly servicesCache;
6
- constructor(mediaStore: MediaStore);
8
+ constructor(mediaApi: MediaApi, store?: MediaStore);
7
9
  notifyUploadStart(event: MobileUploadStartEvent): void;
8
10
  notifyUploadProgress(event: MobileUploadProgressEvent): void;
9
11
  notifyUploadEnd(event: MobileUploadEndEvent): void;
10
12
  notifyUploadError(event: MobileUploadErrorEvent): void;
13
+ private getErrorFileState;
14
+ private setFileState;
11
15
  }
@@ -1,6 +1,6 @@
1
1
  import { LRUMap } from 'lru_map';
2
2
  import { ReplaySubject } from 'rxjs/ReplaySubject';
3
- import { FileState } from './models/file-state';
3
+ import { FileState } from '@atlaskit/media-state';
4
4
  export declare class StreamsCache<T> {
5
5
  private readonly streams;
6
6
  constructor(streams: LRUMap<string, ReplaySubject<T>>);
@@ -6,11 +6,11 @@ export type { MediaItemType, FileItem, FileProcessingStatus, MediaArtifact, Arti
6
6
  export { isPreviewableType } from './models/media';
7
7
  export type { MediaFileProcessingStatus, MediaType, MediaFile, MediaRepresentations, MediaItemDetails, MediaUpload, MediaChunksProbe, } from './models/media';
8
8
  export { getArtifactUrl } from './models/artifacts';
9
- export type { MediaFileArtifact, MediaFileArtifacts } from './models/artifacts';
10
9
  export { isMediaClientError, getMediaClientErrorReason } from './models/errors';
11
10
  export type { MediaClientError, MediaClientErrorReason, MediaClientErrorAttributes, } from './models/errors';
12
11
  export { isUploadingFileState, isProcessingFileState, isProcessedFileState, isErrorFileState, isPreviewableFileState, isFinalFileState, isImageRepresentationReady, mapMediaFileToFileState, mapMediaItemToFileState, } from './models/file-state';
13
- export type { FileStatus, FilePreview, PreviewOptions, GetFileOptions, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState, ErrorFileState, NonErrorFileState, PreviewableFileState, FileState, } from './models/file-state';
12
+ export type { FileStatus, PreviewOptions, GetFileOptions, NonErrorFileState, PreviewableFileState, } from './models/file-state';
13
+ export type { FileState, FilePreview, ErrorFileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState, MediaFileArtifact, MediaFileArtifacts, } from '@atlaskit/media-state';
14
14
  export type { MobileUpload, MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent, } from './models/mobile-upload';
15
15
  export { uploadFile } from './uploader';
16
16
  export type { UploadableFile, UploadableFileUpfrontIds, UploadFileCallbacks, UploadFileResult, } from './uploader';
@@ -39,12 +39,14 @@ export type { Identifier, FileIdentifier, ExternalImageIdentifier, } from './ide
39
39
  export type { EventPayloadListener, UploadEventPayloadMap, MediaViewedEventPayload, } from './client/events';
40
40
  export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
41
41
  export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClientFunction, WithMediaClient, } from './utils/with-media-client-hoc';
42
+ export type { MediaClientConfig } from '@atlaskit/media-core';
42
43
  export { globalMediaEventEmitter } from './globalMediaEventEmitter';
43
44
  export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
44
45
  export type { MediaBlobUrlAttrs } from './utils/url';
45
46
  export { createMediaSubscribable, fromObservable, } from './utils/mediaSubscribable';
46
47
  export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/mediaSubscribable';
47
48
  export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
49
+ export { getFileStreamsCache } from './file-streams-cache';
48
50
  /**
49
51
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
50
52
  */
@@ -1,15 +1,2 @@
1
- import type { MediaFileProcessingStatus } from './media';
2
- export type MediaFileArtifact = {
3
- readonly url: string;
4
- readonly processingStatus: MediaFileProcessingStatus;
5
- };
6
- export interface MediaFileArtifacts {
7
- 'video_1280.mp4'?: MediaFileArtifact;
8
- 'video_640.mp4'?: MediaFileArtifact;
9
- 'document.pdf'?: MediaFileArtifact;
10
- 'audio.mp3'?: MediaFileArtifact;
11
- 'thumb.jpg'?: MediaFileArtifact;
12
- 'image.png'?: MediaFileArtifact;
13
- 'image.jpg'?: MediaFileArtifact;
14
- }
1
+ import { MediaFileArtifacts } from '@atlaskit/media-state';
15
2
  export declare const getArtifactUrl: (artifacts: MediaFileArtifacts, prop: keyof MediaFileArtifacts) => string | undefined;
@@ -1,19 +1,8 @@
1
- import { FileStatus as CommonFileStatus, MediaTraceContext } from '@atlaskit/media-common';
1
+ import { FileStatus as CommonFileStatus } from '@atlaskit/media-common';
2
2
  import { MediaStoreResponse } from '../client/media-store';
3
- import { MediaFileArtifacts } from './artifacts';
4
- import { MediaItemDetails, MediaFile, MediaRepresentations, MediaType } from './media';
5
- export type BaseFileState = {
6
- metadataTraceContext?: MediaTraceContext;
7
- };
3
+ import { MediaItemDetails, MediaFile } from './media';
4
+ import { FilePreview, FileState, ErrorFileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ProcessingFailedState } from '@atlaskit/media-state';
8
5
  export type FileStatus = CommonFileStatus;
9
- export interface FilePreview {
10
- value: Blob | string;
11
- origin?: 'local' | 'remote';
12
- originalDimensions?: {
13
- width: number;
14
- height: number;
15
- };
16
- }
17
6
  export interface PreviewOptions {
18
7
  }
19
8
  export interface GetFileOptions {
@@ -21,74 +10,16 @@ export interface GetFileOptions {
21
10
  collectionName?: string;
22
11
  occurrenceKey?: string;
23
12
  }
24
- export interface UploadingFileState extends BaseFileState {
25
- status: 'uploading';
26
- id: string;
27
- occurrenceKey?: string;
28
- name: string;
29
- size: number;
30
- progress: number;
31
- mediaType: MediaType;
32
- mimeType: string;
33
- preview?: FilePreview | Promise<FilePreview>;
34
- createdAt?: number;
35
- }
36
13
  export interface PreviewableFileState {
37
14
  preview: FilePreview | Promise<FilePreview>;
38
15
  }
39
- export interface ProcessingFileState extends BaseFileState {
40
- status: 'processing';
41
- id: string;
42
- occurrenceKey?: string;
43
- name: string;
44
- size: number;
45
- artifacts?: MediaFileArtifacts;
46
- mediaType: MediaType;
47
- mimeType: string;
48
- preview?: FilePreview | Promise<FilePreview>;
49
- representations?: MediaRepresentations;
50
- createdAt?: number;
51
- }
52
- export interface ProcessedFileState extends BaseFileState {
53
- status: 'processed';
54
- id: string;
55
- occurrenceKey?: string;
56
- name: string;
57
- size: number;
58
- artifacts: MediaFileArtifacts;
59
- mediaType: MediaType;
60
- mimeType: string;
61
- preview?: FilePreview | Promise<FilePreview>;
62
- representations?: MediaRepresentations;
63
- createdAt?: number;
64
- }
65
- export interface ProcessingFailedState extends BaseFileState {
66
- status: 'failed-processing';
67
- id: string;
68
- occurrenceKey?: string;
69
- name: string;
70
- size: number;
71
- artifacts: Object;
72
- mediaType: MediaType;
73
- mimeType: string;
74
- preview?: FilePreview | Promise<FilePreview>;
75
- representations?: MediaRepresentations;
76
- createdAt?: number;
77
- }
78
- export interface ErrorFileState extends BaseFileState {
79
- status: 'error';
80
- id: string;
81
- occurrenceKey?: string;
82
- message?: string;
83
- }
84
- export type FileState = UploadingFileState | ProcessingFileState | ProcessedFileState | ErrorFileState | ProcessingFailedState;
85
16
  export type NonErrorFileState = Exclude<FileState, ErrorFileState>;
86
17
  export declare const isUploadingFileState: (fileState: FileState) => fileState is UploadingFileState;
87
18
  export declare const isProcessingFileState: (fileState: FileState) => fileState is ProcessingFileState;
88
19
  export declare const isProcessedFileState: (fileState: FileState) => fileState is ProcessedFileState;
89
20
  export declare const isErrorFileState: (fileState: FileState) => fileState is ErrorFileState;
90
21
  export declare const isPreviewableFileState: (fileState: FileState) => fileState is (UploadingFileState | ProcessingFileState | ProcessedFileState | ProcessingFailedState) & PreviewableFileState;
91
- export declare const isFinalFileState: (fileState: FileState) => fileState is ProcessedFileState | ProcessingFailedState | ErrorFileState;
22
+ export declare const isFinalFileState: (fileState: FileState) => fileState is ProcessedFileState | ErrorFileState | ProcessingFailedState;
92
23
  export declare const isImageRepresentationReady: (fileState: FileState) => boolean;
93
24
  export declare const mapMediaFileToFileState: (mediaFile: MediaStoreResponse<MediaFile>) => FileState;
94
25
  export declare const mapMediaItemToFileState: (id: string, item: MediaItemDetails) => FileState;
@@ -1,5 +1,5 @@
1
1
  import { MediaTraceContext, MediaType } from '@atlaskit/media-common';
2
- import type { MediaFileArtifacts } from './artifacts';
2
+ import { MediaFileArtifacts } from '@atlaskit/media-state';
3
3
  export type MediaFileProcessingStatus = 'pending' | 'succeeded' | 'failed';
4
4
  export type { MediaType } from '@atlaskit/media-common';
5
5
  export declare const isPreviewableType: (type: MediaType) => boolean;
@@ -1,4 +1,4 @@
1
- import { FilePreview } from './file-state';
1
+ import { FilePreview } from '@atlaskit/media-state';
2
2
  export type MobileUploadStartEvent = {
3
3
  fileId: string;
4
4
  collectionName?: string;
@@ -1,3 +1,3 @@
1
1
  import { ReplaySubject } from 'rxjs/ReplaySubject';
2
- import { FileState } from '../models/file-state';
2
+ import { FileState } from '@atlaskit/media-state';
3
3
  export declare function createMediaSubject<T extends FileState>(initialState?: T | Error): ReplaySubject<T>;
@@ -1,5 +1,5 @@
1
1
  import { ReplaySubject } from 'rxjs/ReplaySubject';
2
- import { FileState } from '../../models/file-state';
2
+ import { FileState } from '@atlaskit/media-state';
3
3
  import { MediaSubscribable } from './types';
4
4
  export declare function fromObservable(observable: ReplaySubject<FileState>): MediaSubscribable;
5
5
  export declare function createMediaSubscribable(item?: FileState | Error): MediaSubscribable;
@@ -1,6 +1,6 @@
1
1
  import { Subscription } from 'rxjs/Subscription';
2
2
  import { MediaSubscribable } from './types';
3
- import { FileState } from '../../models/file-state';
3
+ import { FileState } from '@atlaskit/media-state';
4
4
  /**
5
5
  * This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
6
6
  *
@@ -1,4 +1,4 @@
1
- import { FileState } from '../../models/file-state';
1
+ import { FileState } from '@atlaskit/media-state';
2
2
  export type MediaSubscription = {
3
3
  unsubscribe: () => void;
4
4
  };
@@ -1,7 +1,7 @@
1
1
  import Dataloader from 'dataloader';
2
2
  import { ReplaySubject } from 'rxjs/ReplaySubject';
3
3
  import { Interpreter } from 'xstate';
4
- import { FileState } from '../../models/file-state';
4
+ import { FileState } from '@atlaskit/media-state';
5
5
  import { DataloaderKey, DataloaderResult } from '../createFileDataLoader';
6
6
  import { StateMachineContext, StateMachineEvent, StateMachineTypestate } from './stateMachine/types';
7
7
  export declare const createMobileFileStateSubject: (service: Interpreter<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>) => ReplaySubject<FileState>;
@@ -1,6 +1,6 @@
1
1
  import DataLoader from 'dataloader';
2
2
  import { Interpreter, StateMachine } from 'xstate';
3
- import { UploadingFileState } from '../../../models/file-state';
3
+ import { UploadingFileState } from '@atlaskit/media-state';
4
4
  import { DataloaderKey, DataloaderResult } from '../../createFileDataLoader';
5
5
  import { StateMachineContext, StateMachineEvent, StateMachineSchema, StateMachineTypestate } from './types';
6
6
  export declare const createMobileUploadStateMachine: (dataloader: DataLoader<DataloaderKey, DataloaderResult>, initialState: UploadingFileState, collectionName?: string) => StateMachine<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>;
@@ -1,5 +1,5 @@
1
1
  import { StateSchema } from 'xstate';
2
- import { FileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ErrorFileState, ProcessingFailedState } from '../../../models/file-state';
2
+ import { FileState, UploadingFileState, ProcessingFileState, ProcessedFileState, ErrorFileState, ProcessingFailedState } from '@atlaskit/media-state';
3
3
  export type StateMachineContext = {
4
4
  currentFileState: FileState;
5
5
  };
@@ -1,4 +1,4 @@
1
- import { FileState } from '../models/file-state';
1
+ import { FileState } from '@atlaskit/media-state';
2
2
  import { MediaType } from '../models/media';
3
3
  export declare const overrideMediaTypeIfUnknown: (fileState: FileState, mediaType?: MediaType) => {
4
4
  mediaType?: MediaType | undefined;
@@ -1,4 +1,4 @@
1
- import { FilePreview } from '../models/file-state';
1
+ import { FilePreview } from '@atlaskit/media-state';
2
2
  import { MediaType } from '../models/media';
3
3
  /**
4
4
  * Async helper determining if we should fetch remote fileStates from the backend: