@uploadcare/file-uploader 1.22.0 → 1.23.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 (111) hide show
  1. package/abstract/UploaderBlock.d.ts.map +1 -1
  2. package/abstract/UploaderBlock.js +27 -5
  3. package/abstract/UploaderPublicApi.d.ts.map +1 -1
  4. package/abstract/UploaderPublicApi.js +9 -1
  5. package/abstract/managers/ValidationManager.d.ts +71 -12
  6. package/abstract/managers/ValidationManager.d.ts.map +1 -1
  7. package/abstract/managers/ValidationManager.js +229 -53
  8. package/abstract/uploadEntrySchema.d.ts +10 -2
  9. package/abstract/uploadEntrySchema.d.ts.map +1 -1
  10. package/abstract/uploadEntrySchema.js +10 -2
  11. package/blocks/CloudImageEditor/src/CloudImageEditorBlock.js +1 -1
  12. package/blocks/Config/initialConfig.d.ts.map +1 -1
  13. package/blocks/Config/initialConfig.js +2 -0
  14. package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
  15. package/blocks/Config/normalizeConfigValue.js +2 -0
  16. package/blocks/FileItem/FileItem.d.ts +1 -1
  17. package/blocks/FileItem/FileItem.d.ts.map +1 -1
  18. package/blocks/FileItem/FileItem.js +68 -49
  19. package/blocks/UploadList/UploadList.d.ts +2 -0
  20. package/blocks/UploadList/UploadList.d.ts.map +1 -1
  21. package/blocks/UploadList/UploadList.js +18 -20
  22. package/env.d.ts +1 -1
  23. package/env.js +1 -1
  24. package/index.ssr.d.ts +1 -1
  25. package/index.ssr.d.ts.map +1 -1
  26. package/index.ssr.js +5 -1
  27. package/locales/file-uploader/ar.d.ts +3 -1
  28. package/locales/file-uploader/ar.js +4 -2
  29. package/locales/file-uploader/az.d.ts +3 -1
  30. package/locales/file-uploader/az.js +5 -2
  31. package/locales/file-uploader/ca.d.ts +3 -1
  32. package/locales/file-uploader/ca.js +5 -2
  33. package/locales/file-uploader/cs.d.ts +3 -1
  34. package/locales/file-uploader/cs.js +5 -2
  35. package/locales/file-uploader/da.d.ts +3 -1
  36. package/locales/file-uploader/da.js +5 -2
  37. package/locales/file-uploader/de.d.ts +3 -1
  38. package/locales/file-uploader/de.js +5 -2
  39. package/locales/file-uploader/el.d.ts +3 -1
  40. package/locales/file-uploader/el.js +5 -2
  41. package/locales/file-uploader/en.d.ts +3 -1
  42. package/locales/file-uploader/en.js +4 -2
  43. package/locales/file-uploader/es.d.ts +3 -1
  44. package/locales/file-uploader/es.js +5 -2
  45. package/locales/file-uploader/et.d.ts +3 -1
  46. package/locales/file-uploader/et.js +5 -2
  47. package/locales/file-uploader/fi.d.ts +3 -1
  48. package/locales/file-uploader/fi.js +5 -2
  49. package/locales/file-uploader/fr.d.ts +3 -1
  50. package/locales/file-uploader/fr.js +5 -2
  51. package/locales/file-uploader/he.d.ts +3 -1
  52. package/locales/file-uploader/he.js +5 -2
  53. package/locales/file-uploader/hy.d.ts +3 -1
  54. package/locales/file-uploader/hy.js +4 -2
  55. package/locales/file-uploader/is.d.ts +3 -1
  56. package/locales/file-uploader/is.js +5 -2
  57. package/locales/file-uploader/it.d.ts +3 -1
  58. package/locales/file-uploader/it.js +5 -2
  59. package/locales/file-uploader/ja.d.ts +3 -1
  60. package/locales/file-uploader/ja.js +5 -2
  61. package/locales/file-uploader/ka.d.ts +3 -1
  62. package/locales/file-uploader/ka.js +5 -2
  63. package/locales/file-uploader/kk.d.ts +3 -1
  64. package/locales/file-uploader/kk.js +5 -2
  65. package/locales/file-uploader/ko.d.ts +3 -1
  66. package/locales/file-uploader/ko.js +5 -2
  67. package/locales/file-uploader/lv.d.ts +3 -1
  68. package/locales/file-uploader/lv.js +5 -2
  69. package/locales/file-uploader/nb.d.ts +3 -1
  70. package/locales/file-uploader/nb.js +5 -2
  71. package/locales/file-uploader/nl.d.ts +3 -1
  72. package/locales/file-uploader/nl.js +5 -2
  73. package/locales/file-uploader/pl.d.ts +3 -1
  74. package/locales/file-uploader/pl.js +5 -2
  75. package/locales/file-uploader/pt.d.ts +3 -1
  76. package/locales/file-uploader/pt.js +5 -2
  77. package/locales/file-uploader/ro.d.ts +3 -1
  78. package/locales/file-uploader/ro.js +5 -2
  79. package/locales/file-uploader/ru.d.ts +3 -1
  80. package/locales/file-uploader/ru.js +5 -2
  81. package/locales/file-uploader/sk.d.ts +3 -1
  82. package/locales/file-uploader/sk.js +5 -2
  83. package/locales/file-uploader/sr.d.ts +3 -1
  84. package/locales/file-uploader/sr.js +5 -2
  85. package/locales/file-uploader/sv.d.ts +3 -1
  86. package/locales/file-uploader/sv.js +5 -2
  87. package/locales/file-uploader/tr.d.ts +3 -1
  88. package/locales/file-uploader/tr.js +5 -2
  89. package/locales/file-uploader/uk.d.ts +3 -1
  90. package/locales/file-uploader/uk.js +5 -2
  91. package/locales/file-uploader/vi.d.ts +3 -1
  92. package/locales/file-uploader/vi.js +5 -2
  93. package/locales/file-uploader/zh-TW.d.ts +3 -1
  94. package/locales/file-uploader/zh-TW.js +5 -2
  95. package/locales/file-uploader/zh.d.ts +3 -1
  96. package/locales/file-uploader/zh.js +5 -2
  97. package/package.json +8 -8
  98. package/types/exported.d.ts +26 -4
  99. package/utils/withResolvers.d.ts +6 -0
  100. package/utils/withResolvers.d.ts.map +1 -0
  101. package/utils/withResolvers.js +18 -0
  102. package/utils/withResolvers.test.d.ts +2 -0
  103. package/utils/withResolvers.test.d.ts.map +1 -0
  104. package/utils/withResolvers.test.js +36 -0
  105. package/web/file-uploader.iife.min.js +4 -4
  106. package/web/file-uploader.min.js +4 -4
  107. package/web/uc-cloud-image-editor.min.js +4 -4
  108. package/web/uc-file-uploader-inline.min.js +4 -4
  109. package/web/uc-file-uploader-minimal.min.js +4 -4
  110. package/web/uc-file-uploader-regular.min.js +4 -4
  111. package/web/uc-img.min.js +1 -1
@@ -1,10 +1,20 @@
1
1
  import type { LocaleDefinition } from '../abstract/localeRegistry';
2
2
  import type { complexConfigKeys } from '../blocks/Config/Config';
3
- import type { FuncFileValidator, FuncCollectionValidator } from '../abstract/managers/ValidationManager';
3
+ import type {
4
+ FuncFileValidator,
5
+ FuncCollectionValidator,
6
+ FileValidator,
7
+ FileValidatorDescriptor,
8
+ } from '../abstract/managers/ValidationManager';
4
9
  import type { CameraMode } from '../blocks/CameraSource/CameraSource';
5
10
  import type { FilesViewMode } from '../blocks/UploadList/UploadList';
6
11
 
7
- export type { FuncFileValidator, FuncCollectionValidator } from '../abstract/managers/ValidationManager';
12
+ export type {
13
+ FuncFileValidator,
14
+ FuncCollectionValidator,
15
+ FileValidator,
16
+ FileValidatorDescriptor,
17
+ } from '../abstract/managers/ValidationManager';
8
18
  export type { UploaderPublicApi } from '../abstract/UploaderPublicApi';
9
19
 
10
20
  export type UploadError = import('@uploadcare/upload-client').UploadError;
@@ -21,7 +31,7 @@ export type SecureDeliveryProxyUrlResolver = (
21
31
  export type SecureUploadsSignatureAndExpire = { secureSignature: string; secureExpire: string };
22
32
  export type SecureUploadsSignatureResolver = () => Promise<SecureUploadsSignatureAndExpire | null>;
23
33
  export type IconHrefResolver = (iconName: string) => string;
24
- export type FileValidators = FuncFileValidator[];
34
+ export type FileValidators = FileValidator[];
25
35
  export type CollectionValidators = FuncCollectionValidator[];
26
36
  export type SourceTypes = import('../blocks/utils/UploadSource').SourceTypes;
27
37
 
@@ -80,7 +90,7 @@ export type ConfigType = {
80
90
  */
81
91
  sourceList: string;
82
92
  /**
83
- * Top-level origin for the uploader.
93
+ * Top-level origin for the uploader.
84
94
  * This is used for Google Drive Picker if there is no access to the origin due to the cross-origin policy.
85
95
  */
86
96
  topLevelOrigin: string;
@@ -255,6 +265,16 @@ export type ConfigType = {
255
265
  */
256
266
  collectionValidators: CollectionValidators;
257
267
 
268
+ /**
269
+ * Timeout for async validation functions, in milliseconds.
270
+ */
271
+ validationTimeout: number;
272
+
273
+ /**
274
+ * The number of files to validate concurrently.
275
+ */
276
+ validationConcurrency: number;
277
+
258
278
  /**
259
279
  * The camera modes to enable in the camera modal,
260
280
  * it is possible to select photo or video capture.
@@ -407,6 +427,8 @@ export type OutputFileEntry<TStatus extends OutputFileStatus = OutputFileStatus>
407
427
  uploadProgress: number;
408
428
  fullPath: string | null;
409
429
  source: SourceTypes | null;
430
+
431
+ isValidationPending: boolean;
410
432
  } & (
411
433
  | {
412
434
  status: 'success';
@@ -0,0 +1,6 @@
1
+ export function withResolvers<T extends void, R extends unknown>(): {
2
+ promise: Promise<T>;
3
+ resolve: (value?: T | PromiseLike<T>) => void;
4
+ reject: (reason?: R) => void;
5
+ };
6
+ //# sourceMappingURL=withResolvers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withResolvers.d.ts","sourceRoot":"","sources":["withResolvers.js"],"names":[],"mappings":"AAKO,8BAJa,CAAC,SAAR,IAAM,EACI,CAAC,SAAX,OAAS,KACT;IAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAAC,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;CAAE,CAchH"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @template {void} T
3
+ * @template {unknown} R
4
+ * @returns {{ promise: Promise<T>; resolve: (value?: T | PromiseLike<T>) => void; reject: (reason?: R) => void }}
5
+ */
6
+ export const withResolvers = () => {
7
+ /** @type {(value?: any) => void} */
8
+ let resolve;
9
+ /** @type {(reason?: any) => void} */
10
+ let reject;
11
+
12
+ const promise = new Promise((res, rej) => {
13
+ resolve = res;
14
+ reject = rej;
15
+ });
16
+
17
+ return { promise, resolve, reject };
18
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=withResolvers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withResolvers.test.d.ts","sourceRoot":"","sources":["withResolvers.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import { expect } from '@esm-bundle/chai';
2
+ import { withResolvers } from './withResolvers';
3
+
4
+ describe('withResolvers', () => {
5
+ it('resolves when external resolve is called', async () => {
6
+ const { promise, resolve } = withResolvers();
7
+
8
+ setTimeout(() => resolve(42), 10);
9
+
10
+ const result = await promise;
11
+ expect(result).to.equal(42);
12
+ });
13
+
14
+ it('rejects when external reject is called', async () => {
15
+ const { promise, reject } = withResolvers();
16
+
17
+ setTimeout(() => reject(new Error('fail')), 10);
18
+
19
+ try {
20
+ await promise;
21
+ throw new Error('Promise should have been rejected');
22
+ } catch (err) {
23
+ expect(err).to.be.instanceOf(Error);
24
+ expect(err.message).to.equal('fail');
25
+ }
26
+ });
27
+
28
+ it('resolves with a promise-like value (flattened)', async () => {
29
+ const { promise, resolve } = withResolvers();
30
+
31
+ setTimeout(() => resolve(Promise.resolve('ok')), 10);
32
+
33
+ const result = await promise;
34
+ expect(result).to.equal('ok');
35
+ });
36
+ });