@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
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "23.2.0",
3
+ "version": "24.0.0",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@atlaskit/chunkinator": "^4.2.0",
40
- "@atlaskit/media-common": "^8.2.0",
40
+ "@atlaskit/media-common": "^9.0.0",
41
41
  "@babel/runtime": "^7.0.0",
42
42
  "dataloader": "^2.0.0",
43
43
  "deep-equal": "^1.0.1",
@@ -52,6 +52,7 @@
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@atlaskit/media-core": "^34.1.2",
55
+ "@atlaskit/media-state": "^1.0.0",
55
56
  "@emotion/react": "^11.7.1",
56
57
  "enzyme": ">=3.10.0",
57
58
  "react": "^16.8.0"
@@ -64,8 +65,9 @@
64
65
  },
65
66
  "devDependencies": {
66
67
  "@atlaskit/media-core": "^34.1.0",
68
+ "@atlaskit/media-state": "^1.0.0",
67
69
  "@atlaskit/ssr": "*",
68
- "@atlaskit/tokens": "^1.18.0",
70
+ "@atlaskit/tokens": "^1.20.0",
69
71
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
70
72
  "@emotion/react": "^11.7.1",
71
73
  "@types/deep-equal": "^1.0.1",
package/report.api.md CHANGED
@@ -21,14 +21,24 @@ import { AuthContext } from '@atlaskit/media-core';
21
21
  import { AuthProvider } from '@atlaskit/media-core';
22
22
  import { ChunkinatorFile } from '@atlaskit/chunkinator';
23
23
  import { ClientAltBasedAuth } from '@atlaskit/media-core';
24
+ import { ErrorFileState } from '@atlaskit/media-state';
25
+ import { FilePreview } from '@atlaskit/media-state';
26
+ import { FileState } from '@atlaskit/media-state';
24
27
  import { FileStatus as FileStatus_2 } from '@atlaskit/media-common';
28
+ import { LRUMap } from 'lru_map';
25
29
  import { MediaApiConfig } from '@atlaskit/media-core';
26
30
  import { MediaClientConfig } from '@atlaskit/media-core';
27
- import { MediaFeatureFlags } from '@atlaskit/media-common';
31
+ import { MediaFileArtifact } from '@atlaskit/media-state';
32
+ import { MediaFileArtifacts } from '@atlaskit/media-state';
33
+ import { MediaStore as MediaStore_2 } from '@atlaskit/media-state';
28
34
  import { MediaTraceContext } from '@atlaskit/media-common';
29
35
  import { MediaType } from '@atlaskit/media-common';
36
+ import { ProcessedFileState } from '@atlaskit/media-state';
37
+ import { ProcessingFailedState } from '@atlaskit/media-state';
38
+ import { ProcessingFileState } from '@atlaskit/media-state';
30
39
  import { default as React_2 } from 'react';
31
40
  import { ReplaySubject } from 'rxjs/ReplaySubject';
41
+ import { UploadingFileState } from '@atlaskit/media-state';
32
42
 
33
43
  // @public (undocumented)
34
44
  export type AbortFunction = () => void;
@@ -51,11 +61,6 @@ export type Artifacts = {
51
61
  [name: string]: MediaArtifact;
52
62
  };
53
63
 
54
- // @public (undocumented)
55
- type BaseFileState = {
56
- metadataTraceContext?: MediaTraceContext;
57
- };
58
-
59
64
  // @public
60
65
  abstract class BaseMediaClientError<
61
66
  Attributes extends MediaClientErrorAttributes,
@@ -170,17 +175,7 @@ export interface EmptyFile {
170
175
  readonly id: string;
171
176
  }
172
177
 
173
- // @public (undocumented)
174
- export interface ErrorFileState extends BaseFileState {
175
- // (undocumented)
176
- id: string;
177
- // (undocumented)
178
- message?: string;
179
- // (undocumented)
180
- occurrenceKey?: string;
181
- // (undocumented)
182
- status: 'error';
183
- }
178
+ export { ErrorFileState };
184
179
 
185
180
  // @public (undocumented)
186
181
  type ErrorObserver = PartialObserver & Required<Pick<PartialObserver, 'error'>>;
@@ -337,7 +332,7 @@ export type FileFetcherErrorReason =
337
332
 
338
333
  // @public (undocumented)
339
334
  export class FileFetcherImpl implements FileFetcher {
340
- constructor(mediaStore: MediaStore);
335
+ constructor(mediaApi: MediaStore, store?: MediaStore_2);
341
336
  // (undocumented)
342
337
  copyFile(
343
338
  source: CopySourceFile,
@@ -404,18 +399,7 @@ export interface FileItem {
404
399
  type: 'file';
405
400
  }
406
401
 
407
- // @public (undocumented)
408
- export interface FilePreview {
409
- // (undocumented)
410
- origin?: 'local' | 'remote';
411
- // (undocumented)
412
- originalDimensions?: {
413
- width: number;
414
- height: number;
415
- };
416
- // (undocumented)
417
- value: Blob | string;
418
- }
402
+ export { FilePreview };
419
403
 
420
404
  // @public (undocumented)
421
405
  export type FileProcessingStatus =
@@ -424,13 +408,7 @@ export type FileProcessingStatus =
424
408
  | 'running'
425
409
  | 'succeeded';
426
410
 
427
- // @public (undocumented)
428
- export type FileState =
429
- | ErrorFileState
430
- | ProcessedFileState
431
- | ProcessingFailedState
432
- | ProcessingFileState
433
- | UploadingFileState;
411
+ export { FileState };
434
412
 
435
413
  // @public (undocumented)
436
414
  export type FileStatus = FileStatus_2;
@@ -467,10 +445,12 @@ export interface GetFileOptions {
467
445
  preview?: PreviewOptions;
468
446
  }
469
447
 
448
+ // @public (undocumented)
449
+ export const getFileStreamsCache: () => StreamsCache<FileState>;
450
+
470
451
  // @public (undocumented)
471
452
  export const getMediaClient: (
472
453
  mediaClientConfig: MediaClientConfig,
473
- featureFlags?: MediaFeatureFlags,
474
454
  ) => MediaClient;
475
455
 
476
456
  // @public (undocumented)
@@ -720,8 +700,11 @@ export type MediaChunksProbe = {
720
700
  export class MediaClient {
721
701
  constructor(
722
702
  mediaClientConfig: MediaClientConfig,
723
- featureFlags?: MediaFeatureFlags | undefined,
703
+ store?: MediaStore_2,
704
+ mediaApi?: MediaStore,
724
705
  );
706
+ // @internal (undocumented)
707
+ __DO_NOT_USE__getMediaStore(): MediaStore_2;
725
708
  // (undocumented)
726
709
  readonly config: MediaClientConfig;
727
710
  // (undocumented)
@@ -730,8 +713,6 @@ export class MediaClient {
730
713
  payload: UploadEventPayloadMap[E],
731
714
  ): boolean;
732
715
  // (undocumented)
733
- readonly featureFlags?: MediaFeatureFlags | undefined;
734
- // (undocumented)
735
716
  readonly file: FileFetcher;
736
717
  // (undocumented)
737
718
  getImage(
@@ -780,6 +761,8 @@ export class MediaClient {
780
761
  readonly stargate: StargateClient;
781
762
  }
782
763
 
764
+ export { MediaClientConfig };
765
+
783
766
  // @public
784
767
  export interface MediaClientError<Attributes extends MediaClientErrorAttributes>
785
768
  extends Error {
@@ -834,29 +817,9 @@ export type MediaFile = {
834
817
  readonly metadataTraceContext?: MediaTraceContext;
835
818
  };
836
819
 
837
- // @public (undocumented)
838
- export type MediaFileArtifact = {
839
- readonly url: string;
840
- readonly processingStatus: MediaFileProcessingStatus;
841
- };
820
+ export { MediaFileArtifact };
842
821
 
843
- // @public (undocumented)
844
- export interface MediaFileArtifacts {
845
- // (undocumented)
846
- 'audio.mp3'?: MediaFileArtifact;
847
- // (undocumented)
848
- 'document.pdf'?: MediaFileArtifact;
849
- // (undocumented)
850
- 'image.jpg'?: MediaFileArtifact;
851
- // (undocumented)
852
- 'image.png'?: MediaFileArtifact;
853
- // (undocumented)
854
- 'thumb.jpg'?: MediaFileArtifact;
855
- // (undocumented)
856
- 'video_1280.mp4'?: MediaFileArtifact;
857
- // (undocumented)
858
- 'video_640.mp4'?: MediaFileArtifact;
859
- }
822
+ export { MediaFileArtifacts };
860
823
 
861
824
  // @public (undocumented)
862
825
  export type MediaFileProcessingStatus = 'failed' | 'pending' | 'succeeded';
@@ -891,10 +854,7 @@ export type MediaRepresentations = {
891
854
 
892
855
  // @public (undocumented)
893
856
  export class MediaStore {
894
- constructor(
895
- config: MediaApiConfig,
896
- featureFlags?: MediaFeatureFlags | undefined,
897
- );
857
+ constructor(config: MediaApiConfig);
898
858
  // (undocumented)
899
859
  appendChunksToUpload(
900
860
  uploadId: string,
@@ -921,8 +881,6 @@ export class MediaStore {
921
881
  traceContext?: MediaTraceContext,
922
882
  ): Promise<MediaStoreResponse<MediaUpload[]>>;
923
883
  // (undocumented)
924
- readonly featureFlags?: MediaFeatureFlags | undefined;
925
- // (undocumented)
926
884
  getArtifactURL(
927
885
  artifacts: MediaFileArtifacts,
928
886
  artifactName: keyof MediaFileArtifacts,
@@ -1298,83 +1256,11 @@ export interface PreviewableFileState {
1298
1256
  // @public (undocumented)
1299
1257
  export interface PreviewOptions {}
1300
1258
 
1301
- // @public (undocumented)
1302
- export interface ProcessedFileState extends BaseFileState {
1303
- // (undocumented)
1304
- artifacts: MediaFileArtifacts;
1305
- // (undocumented)
1306
- createdAt?: number;
1307
- // (undocumented)
1308
- id: string;
1309
- // (undocumented)
1310
- mediaType: MediaType;
1311
- // (undocumented)
1312
- mimeType: string;
1313
- // (undocumented)
1314
- name: string;
1315
- // (undocumented)
1316
- occurrenceKey?: string;
1317
- // (undocumented)
1318
- preview?: FilePreview | Promise<FilePreview>;
1319
- // (undocumented)
1320
- representations?: MediaRepresentations;
1321
- // (undocumented)
1322
- size: number;
1323
- // (undocumented)
1324
- status: 'processed';
1325
- }
1259
+ export { ProcessedFileState };
1326
1260
 
1327
- // @public (undocumented)
1328
- export interface ProcessingFailedState extends BaseFileState {
1329
- // (undocumented)
1330
- artifacts: Object;
1331
- // (undocumented)
1332
- createdAt?: number;
1333
- // (undocumented)
1334
- id: string;
1335
- // (undocumented)
1336
- mediaType: MediaType;
1337
- // (undocumented)
1338
- mimeType: string;
1339
- // (undocumented)
1340
- name: string;
1341
- // (undocumented)
1342
- occurrenceKey?: string;
1343
- // (undocumented)
1344
- preview?: FilePreview | Promise<FilePreview>;
1345
- // (undocumented)
1346
- representations?: MediaRepresentations;
1347
- // (undocumented)
1348
- size: number;
1349
- // (undocumented)
1350
- status: 'failed-processing';
1351
- }
1261
+ export { ProcessingFailedState };
1352
1262
 
1353
- // @public (undocumented)
1354
- export interface ProcessingFileState extends BaseFileState {
1355
- // (undocumented)
1356
- artifacts?: MediaFileArtifacts;
1357
- // (undocumented)
1358
- createdAt?: number;
1359
- // (undocumented)
1360
- id: string;
1361
- // (undocumented)
1362
- mediaType: MediaType;
1363
- // (undocumented)
1364
- mimeType: string;
1365
- // (undocumented)
1366
- name: string;
1367
- // (undocumented)
1368
- occurrenceKey?: string;
1369
- // (undocumented)
1370
- preview?: FilePreview | Promise<FilePreview>;
1371
- // (undocumented)
1372
- representations?: MediaRepresentations;
1373
- // (undocumented)
1374
- size: number;
1375
- // (undocumented)
1376
- status: 'processing';
1377
- }
1263
+ export { ProcessingFileState };
1378
1264
 
1379
1265
  // @public (undocumented)
1380
1266
  export const RECENTS_COLLECTION = 'recents';
@@ -1534,6 +1420,25 @@ export class StargateClient {
1534
1420
  isTokenExpired(token: EdgeData): boolean;
1535
1421
  }
1536
1422
 
1423
+ // @public (undocumented)
1424
+ class StreamsCache<T> {
1425
+ constructor(streams: LRUMap<string, ReplaySubject<T>>);
1426
+ // (undocumented)
1427
+ get(id: string): ReplaySubject<T> | undefined;
1428
+ // (undocumented)
1429
+ getOrInsert(id: string, callback: () => ReplaySubject<T>): ReplaySubject<T>;
1430
+ // (undocumented)
1431
+ has(id: string): boolean;
1432
+ // (undocumented)
1433
+ remove(id: string): void;
1434
+ // (undocumented)
1435
+ removeAll(): void;
1436
+ // (undocumented)
1437
+ set(id: string, stream: ReplaySubject<T>): void;
1438
+ // (undocumented)
1439
+ get size(): number;
1440
+ }
1441
+
1537
1442
  // @public (undocumented)
1538
1443
  export type TouchedFiles = {
1539
1444
  created: CreatedTouchedFile[];
@@ -1610,29 +1515,7 @@ export interface UploadFileResult {
1610
1515
  cancel: () => void;
1611
1516
  }
1612
1517
 
1613
- // @public (undocumented)
1614
- export interface UploadingFileState extends BaseFileState {
1615
- // (undocumented)
1616
- createdAt?: number;
1617
- // (undocumented)
1618
- id: string;
1619
- // (undocumented)
1620
- mediaType: MediaType;
1621
- // (undocumented)
1622
- mimeType: string;
1623
- // (undocumented)
1624
- name: string;
1625
- // (undocumented)
1626
- occurrenceKey?: string;
1627
- // (undocumented)
1628
- preview?: FilePreview | Promise<FilePreview>;
1629
- // (undocumented)
1630
- progress: number;
1631
- // (undocumented)
1632
- size: number;
1633
- // (undocumented)
1634
- status: 'uploading';
1635
- }
1518
+ export { UploadingFileState };
1636
1519
 
1637
1520
  // @public (undocumented)
1638
1521
  export interface WithMediaClient {
@@ -1661,7 +1544,6 @@ export type WithMediaClientConfigProps<P extends WithMediaClient> = Omit<
1661
1544
  // @public (undocumented)
1662
1545
  export type WithMediaClientFunction = <P extends WithMediaClient>(
1663
1546
  Component: React_2.ComponentType<P>,
1664
- featureFlags?: MediaFeatureFlags,
1665
1547
  ) => React_2.ComponentType<WithMediaClientConfigProps<P>>;
1666
1548
 
1667
1549
  // (No @packageDocumentation comment for this package)
@@ -1676,6 +1558,7 @@ export type WithMediaClientFunction = <P extends WithMediaClient>(
1676
1558
  ```json
1677
1559
  {
1678
1560
  "@atlaskit/media-core": "^34.1.2",
1561
+ "@atlaskit/media-state": "^1.0.0",
1679
1562
  "@emotion/react": "^11.7.1",
1680
1563
  "enzyme": ">=3.10.0",
1681
1564
  "react": "^16.8.0"