@uploadcare/file-uploader 1.13.0-alpha.3 → 1.13.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 (50) hide show
  1. package/abstract/UploaderPublicApi.d.ts.map +1 -1
  2. package/abstract/UploaderPublicApi.js +4 -11
  3. package/blocks/CameraSource/CameraSource.d.ts +12 -22
  4. package/blocks/CameraSource/CameraSource.d.ts.map +1 -1
  5. package/blocks/CameraSource/CameraSource.js +81 -83
  6. package/blocks/CameraSource/camera-source.css +1 -0
  7. package/blocks/CameraSource/constants.d.ts +15 -0
  8. package/blocks/CameraSource/constants.d.ts.map +1 -0
  9. package/blocks/CameraSource/constants.js +17 -0
  10. package/blocks/CloudImageEditor/src/CropFrame.d.ts +0 -7
  11. package/blocks/CloudImageEditor/src/CropFrame.d.ts.map +1 -1
  12. package/blocks/CloudImageEditor/src/CropFrame.js +0 -50
  13. package/blocks/CloudImageEditor/src/css/common.css +0 -4
  14. package/blocks/CloudImageEditor/src/lib/parseTabs.js +2 -2
  15. package/blocks/Config/Config.d.ts +3 -3
  16. package/blocks/Config/Config.d.ts.map +1 -1
  17. package/blocks/Config/Config.js +13 -3
  18. package/blocks/Config/assertions.d.ts +5 -0
  19. package/blocks/Config/assertions.d.ts.map +1 -0
  20. package/blocks/Config/assertions.js +37 -0
  21. package/blocks/Config/initialConfig.d.ts.map +1 -1
  22. package/blocks/Config/initialConfig.js +4 -5
  23. package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
  24. package/blocks/Config/normalizeConfigValue.js +20 -8
  25. package/blocks/Config/side-effects.d.ts +7 -0
  26. package/blocks/Config/side-effects.d.ts.map +1 -0
  27. package/blocks/Config/side-effects.js +32 -0
  28. package/blocks/UploadList/upload-list.css +1 -0
  29. package/blocks/utils/comma-separated.d.ts +1 -1
  30. package/blocks/utils/comma-separated.d.ts.map +1 -1
  31. package/blocks/utils/comma-separated.js +5 -2
  32. package/env.d.ts +1 -1
  33. package/env.js +1 -1
  34. package/index.ssr.d.ts +1 -15
  35. package/index.ssr.d.ts.map +1 -1
  36. package/index.ssr.js +6 -17
  37. package/package.json +3 -5
  38. package/types/exported.d.ts +81 -66
  39. package/web/file-uploader.iife.min.js +4 -4
  40. package/web/file-uploader.min.js +4 -4
  41. package/web/uc-basic.min.css +1 -1
  42. package/web/uc-cloud-image-editor.min.css +1 -1
  43. package/web/uc-cloud-image-editor.min.js +4 -4
  44. package/web/uc-file-uploader-inline.min.css +1 -1
  45. package/web/uc-file-uploader-inline.min.js +4 -4
  46. package/web/uc-file-uploader-minimal.min.css +1 -1
  47. package/web/uc-file-uploader-minimal.min.js +3 -3
  48. package/web/uc-file-uploader-regular.min.css +1 -1
  49. package/web/uc-file-uploader-regular.min.js +4 -4
  50. package/web/uc-img.min.js +1 -1
@@ -1,6 +1,7 @@
1
1
  import type { LocaleDefinition } from '../abstract/localeRegistry';
2
2
  import type { complexConfigKeys } from '../blocks/Config/Config';
3
3
  import type { FuncFileValidator, FuncCollectionValidator } from '../abstract/ValidationManager';
4
+ import type { CameraMode } from '../blocks/CameraSource/CameraSource';
4
5
 
5
6
  export type { FuncFileValidator, FuncCollectionValidator } from '../abstract/ValidationManager';
6
7
  export type { UploaderPublicApi } from '../abstract/UploaderPublicApi';
@@ -21,7 +22,7 @@ export type SecureUploadsSignatureResolver = () => Promise<SecureUploadsSignatur
21
22
  export type IconHrefResolver = (iconName: string) => string;
22
23
  export type FileValidators = FuncFileValidator[];
23
24
  export type CollectionValidators = FuncCollectionValidator[];
24
- export type SourceTypes = import('../blocks/utils/UploadSource').SourceTypes
25
+ export type SourceTypes = import('../blocks/utils/UploadSource').SourceTypes;
25
26
 
26
27
  export type ConfigType = {
27
28
  /**
@@ -240,11 +241,20 @@ export type ConfigType = {
240
241
  collectionValidators: CollectionValidators;
241
242
 
242
243
  /**
243
- * The default tab to open in the camera modal,
244
+ * The camera modes to enable in the camera modal,
245
+ * it is possible to select photo or video capture.
246
+ * The first mode is the default mode.
247
+ * @default 'photo,video'
248
+ */
249
+ cameraModes: string;
250
+
251
+ /**
252
+ * The default tab to open in the camera modal,
244
253
  * it is possible to select video or photo capture
245
- * @default 'photo'
254
+ * @default 'null'
255
+ * @deprecated - use `cameraModes` instead
246
256
  */
247
- defaultCameraMode: 'photo' | 'video';
257
+ defaultCameraMode: CameraMode | null;
248
258
  /**
249
259
  * Enable audio recording.
250
260
  * @default true
@@ -252,23 +262,22 @@ export type ConfigType = {
252
262
  enableAudioRecording: boolean;
253
263
  /**
254
264
  * Enable video recording.
255
- * @default true
265
+ * @deprecated - use `cameraModes` instead
266
+ * @default null
256
267
  */
257
- enableVideoRecording: boolean;
268
+ enableVideoRecording: boolean | null;
258
269
 
259
270
  /**
260
271
  * The maximum duration of the video recording in seconds
261
272
  * @default null
262
273
  */
263
- maxVideoRecordingDuration: number | null
274
+ maxVideoRecordingDuration: number | null;
264
275
 
265
276
  /**
266
- * A dictionary object that can contain
277
+ * A dictionary object that can contain
267
278
  * the following properties from MediaRecorderOptions
268
279
  */
269
- mediaRecorerOptions: MediaRecorderOptions | null
270
-
271
- cloudImageEditorMaskHref: string | null;
280
+ mediaRecorderOptions: MediaRecorderOptions | null;
272
281
  };
273
282
  export type ConfigComplexType = Pick<ConfigType, (typeof complexConfigKeys)[number]>;
274
283
  export type ConfigPlainType = Omit<ConfigType, keyof ConfigComplexType>;
@@ -276,8 +285,8 @@ export type ConfigAttributesType = KebabCaseKeys<ConfigPlainType> & LowerCaseKey
276
285
 
277
286
  export type KebabCase<S extends string> = S extends `${infer C}${infer T}`
278
287
  ? T extends Uncapitalize<T>
279
- ? `${Uncapitalize<C>}${KebabCase<T>}`
280
- : `${Uncapitalize<C>}-${KebabCase<T>}`
288
+ ? `${Uncapitalize<C>}${KebabCase<T>}`
289
+ : `${Uncapitalize<C>}-${KebabCase<T>}`
281
290
  : S;
282
291
  export type KebabCaseKeys<T extends Record<string, unknown>> = { [Key in keyof T as KebabCase<Key & string>]: T[Key] };
283
292
  export type LowerCase<S extends string> = Lowercase<S>;
@@ -285,9 +294,10 @@ export type LowerCaseKeys<T extends Record<string, unknown>> = { [Key in keyof T
285
294
 
286
295
  export type OutputFileStatus = 'idle' | 'uploading' | 'success' | 'failed' | 'removed';
287
296
 
288
- export type OutputCustomErrorType = 'CUSTOM_ERROR'
297
+ export type OutputCustomErrorType = 'CUSTOM_ERROR';
289
298
 
290
- export type OutputFileErrorType = OutputCustomErrorType
299
+ export type OutputFileErrorType =
300
+ | OutputCustomErrorType
291
301
  | 'NOT_AN_IMAGE'
292
302
  | 'FORBIDDEN_FILE_TYPE'
293
303
  | 'FILE_SIZE_EXCEEDED'
@@ -295,7 +305,11 @@ export type OutputFileErrorType = OutputCustomErrorType
295
305
  | 'NETWORK_ERROR'
296
306
  | 'UNKNOWN_ERROR';
297
307
 
298
- export type OutputCollectionErrorType = OutputCustomErrorType | 'SOME_FILES_HAS_ERRORS' | 'TOO_MANY_FILES' | 'TOO_FEW_FILES';
308
+ export type OutputCollectionErrorType =
309
+ | OutputCustomErrorType
310
+ | 'SOME_FILES_HAS_ERRORS'
311
+ | 'TOO_MANY_FILES'
312
+ | 'TOO_FEW_FILES';
299
313
 
300
314
  export type OutputFileErrorPayload = {
301
315
  entry: OutputFileEntry;
@@ -329,22 +343,23 @@ export type OutputErrorTypePayload = {
329
343
  CUSTOM_ERROR: Record<string, unknown>;
330
344
  };
331
345
 
332
- export type OutputError<T extends OutputFileErrorType | OutputCollectionErrorType> =
333
- T extends OutputCustomErrorType
346
+ export type OutputError<T extends OutputFileErrorType | OutputCollectionErrorType> = T extends OutputCustomErrorType
334
347
  ? {
335
- type?: T;
336
- message: string;
337
- payload?: OutputErrorTypePayload[T];
338
- }
339
- : T extends keyof OutputErrorTypePayload ? {
340
- type: T;
341
- message: string;
342
- payload?: OutputErrorTypePayload[T];
343
- } : never
348
+ type?: T;
349
+ message: string;
350
+ payload?: OutputErrorTypePayload[T];
351
+ }
352
+ : T extends keyof OutputErrorTypePayload
353
+ ? {
354
+ type: T;
355
+ message: string;
356
+ payload?: OutputErrorTypePayload[T];
357
+ }
358
+ : never;
344
359
 
345
- export type OutputErrorFile = OutputError<OutputFileErrorType>
360
+ export type OutputErrorFile = OutputError<OutputFileErrorType>;
346
361
 
347
- export type OutputErrorCollection = OutputError<OutputCollectionErrorType>
362
+ export type OutputErrorCollection = OutputError<OutputCollectionErrorType>;
348
363
 
349
364
  export type OutputFileEntry<TStatus extends OutputFileStatus = OutputFileStatus> = {
350
365
  status: TStatus;
@@ -362,7 +377,7 @@ export type OutputFileEntry<TStatus extends OutputFileStatus = OutputFileStatus>
362
377
  fullPath: string | null;
363
378
  source: SourceTypes | null;
364
379
  } & (
365
- | {
380
+ | {
366
381
  status: 'success';
367
382
  fileInfo: UploadcareFile;
368
383
  uuid: string;
@@ -374,7 +389,7 @@ export type OutputFileEntry<TStatus extends OutputFileStatus = OutputFileStatus>
374
389
  isRemoved: false;
375
390
  errors: [];
376
391
  }
377
- | {
392
+ | {
378
393
  status: 'failed';
379
394
  fileInfo: UploadcareFile | null;
380
395
  uuid: string | null;
@@ -386,7 +401,7 @@ export type OutputFileEntry<TStatus extends OutputFileStatus = OutputFileStatus>
386
401
  isRemoved: false;
387
402
  errors: OutputError<OutputFileErrorType>[];
388
403
  }
389
- | {
404
+ | {
390
405
  status: 'uploading';
391
406
  fileInfo: null;
392
407
  uuid: null;
@@ -398,7 +413,7 @@ export type OutputFileEntry<TStatus extends OutputFileStatus = OutputFileStatus>
398
413
  isRemoved: false;
399
414
  errors: [];
400
415
  }
401
- | {
416
+ | {
402
417
  status: 'removed';
403
418
  fileInfo: UploadcareFile | null;
404
419
  uuid: string | null;
@@ -410,7 +425,7 @@ export type OutputFileEntry<TStatus extends OutputFileStatus = OutputFileStatus>
410
425
  isRemoved: true;
411
426
  errors: OutputError<OutputFileErrorType>[];
412
427
  }
413
- | {
428
+ | {
414
429
  status: 'idle';
415
430
  fileInfo: null;
416
431
  uuid: null;
@@ -422,7 +437,7 @@ export type OutputFileEntry<TStatus extends OutputFileStatus = OutputFileStatus>
422
437
  isRemoved: false;
423
438
  errors: [];
424
439
  }
425
- );
440
+ );
426
441
 
427
442
  export type OutputCollectionStatus = 'idle' | 'uploading' | 'success' | 'failed';
428
443
 
@@ -446,43 +461,43 @@ export type OutputCollectionState<
446
461
  } & (TGroupFlag extends 'has-group'
447
462
  ? { group: UploadcareGroup }
448
463
  : TGroupFlag extends 'maybe-has-group'
449
- ? { group: UploadcareGroup | null }
450
- : never) &
464
+ ? { group: UploadcareGroup | null }
465
+ : never) &
451
466
  (
452
467
  | {
453
- status: 'idle';
454
- isFailed: false;
455
- isUploading: false;
456
- isSuccess: false;
457
- errors: [];
458
- allEntries: OutputFileEntry<'idle' | 'success'>[];
459
- }
468
+ status: 'idle';
469
+ isFailed: false;
470
+ isUploading: false;
471
+ isSuccess: false;
472
+ errors: [];
473
+ allEntries: OutputFileEntry<'idle' | 'success'>[];
474
+ }
460
475
  | {
461
- status: 'uploading';
462
- isFailed: false;
463
- isUploading: true;
464
- isSuccess: false;
465
- errors: [];
466
- allEntries: OutputFileEntry[];
467
- }
476
+ status: 'uploading';
477
+ isFailed: false;
478
+ isUploading: true;
479
+ isSuccess: false;
480
+ errors: [];
481
+ allEntries: OutputFileEntry[];
482
+ }
468
483
  | {
469
- status: 'success';
470
- isFailed: false;
471
- isUploading: false;
472
- isSuccess: true;
473
- errors: [];
474
- allEntries: OutputFileEntry<'success'>[];
475
- }
484
+ status: 'success';
485
+ isFailed: false;
486
+ isUploading: false;
487
+ isSuccess: true;
488
+ errors: [];
489
+ allEntries: OutputFileEntry<'success'>[];
490
+ }
476
491
  | {
477
- status: 'failed';
478
- isFailed: true;
479
- isUploading: false;
480
- isSuccess: false;
481
- errors: OutputError<OutputCollectionErrorType>[];
482
- allEntries: OutputFileEntry[];
483
- }
492
+ status: 'failed';
493
+ isFailed: true;
494
+ isUploading: false;
495
+ isSuccess: false;
496
+ errors: OutputError<OutputCollectionErrorType>[];
497
+ allEntries: OutputFileEntry[];
498
+ }
484
499
  );
485
500
 
486
501
  export { EventType, EventPayload } from '../blocks/UploadCtxProvider/EventEmitter';
487
502
 
488
- export { };
503
+ export {};