@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.
- package/abstract/UploaderBlock.d.ts.map +1 -1
- package/abstract/UploaderBlock.js +27 -5
- package/abstract/UploaderPublicApi.d.ts.map +1 -1
- package/abstract/UploaderPublicApi.js +9 -1
- package/abstract/managers/ValidationManager.d.ts +71 -12
- package/abstract/managers/ValidationManager.d.ts.map +1 -1
- package/abstract/managers/ValidationManager.js +229 -53
- package/abstract/uploadEntrySchema.d.ts +10 -2
- package/abstract/uploadEntrySchema.d.ts.map +1 -1
- package/abstract/uploadEntrySchema.js +10 -2
- package/blocks/CloudImageEditor/src/CloudImageEditorBlock.js +1 -1
- package/blocks/Config/initialConfig.d.ts.map +1 -1
- package/blocks/Config/initialConfig.js +2 -0
- package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
- package/blocks/Config/normalizeConfigValue.js +2 -0
- package/blocks/FileItem/FileItem.d.ts +1 -1
- package/blocks/FileItem/FileItem.d.ts.map +1 -1
- package/blocks/FileItem/FileItem.js +68 -49
- package/blocks/UploadList/UploadList.d.ts +2 -0
- package/blocks/UploadList/UploadList.d.ts.map +1 -1
- package/blocks/UploadList/UploadList.js +18 -20
- package/env.d.ts +1 -1
- package/env.js +1 -1
- package/index.ssr.d.ts +1 -1
- package/index.ssr.d.ts.map +1 -1
- package/index.ssr.js +5 -1
- package/locales/file-uploader/ar.d.ts +3 -1
- package/locales/file-uploader/ar.js +4 -2
- package/locales/file-uploader/az.d.ts +3 -1
- package/locales/file-uploader/az.js +5 -2
- package/locales/file-uploader/ca.d.ts +3 -1
- package/locales/file-uploader/ca.js +5 -2
- package/locales/file-uploader/cs.d.ts +3 -1
- package/locales/file-uploader/cs.js +5 -2
- package/locales/file-uploader/da.d.ts +3 -1
- package/locales/file-uploader/da.js +5 -2
- package/locales/file-uploader/de.d.ts +3 -1
- package/locales/file-uploader/de.js +5 -2
- package/locales/file-uploader/el.d.ts +3 -1
- package/locales/file-uploader/el.js +5 -2
- package/locales/file-uploader/en.d.ts +3 -1
- package/locales/file-uploader/en.js +4 -2
- package/locales/file-uploader/es.d.ts +3 -1
- package/locales/file-uploader/es.js +5 -2
- package/locales/file-uploader/et.d.ts +3 -1
- package/locales/file-uploader/et.js +5 -2
- package/locales/file-uploader/fi.d.ts +3 -1
- package/locales/file-uploader/fi.js +5 -2
- package/locales/file-uploader/fr.d.ts +3 -1
- package/locales/file-uploader/fr.js +5 -2
- package/locales/file-uploader/he.d.ts +3 -1
- package/locales/file-uploader/he.js +5 -2
- package/locales/file-uploader/hy.d.ts +3 -1
- package/locales/file-uploader/hy.js +4 -2
- package/locales/file-uploader/is.d.ts +3 -1
- package/locales/file-uploader/is.js +5 -2
- package/locales/file-uploader/it.d.ts +3 -1
- package/locales/file-uploader/it.js +5 -2
- package/locales/file-uploader/ja.d.ts +3 -1
- package/locales/file-uploader/ja.js +5 -2
- package/locales/file-uploader/ka.d.ts +3 -1
- package/locales/file-uploader/ka.js +5 -2
- package/locales/file-uploader/kk.d.ts +3 -1
- package/locales/file-uploader/kk.js +5 -2
- package/locales/file-uploader/ko.d.ts +3 -1
- package/locales/file-uploader/ko.js +5 -2
- package/locales/file-uploader/lv.d.ts +3 -1
- package/locales/file-uploader/lv.js +5 -2
- package/locales/file-uploader/nb.d.ts +3 -1
- package/locales/file-uploader/nb.js +5 -2
- package/locales/file-uploader/nl.d.ts +3 -1
- package/locales/file-uploader/nl.js +5 -2
- package/locales/file-uploader/pl.d.ts +3 -1
- package/locales/file-uploader/pl.js +5 -2
- package/locales/file-uploader/pt.d.ts +3 -1
- package/locales/file-uploader/pt.js +5 -2
- package/locales/file-uploader/ro.d.ts +3 -1
- package/locales/file-uploader/ro.js +5 -2
- package/locales/file-uploader/ru.d.ts +3 -1
- package/locales/file-uploader/ru.js +5 -2
- package/locales/file-uploader/sk.d.ts +3 -1
- package/locales/file-uploader/sk.js +5 -2
- package/locales/file-uploader/sr.d.ts +3 -1
- package/locales/file-uploader/sr.js +5 -2
- package/locales/file-uploader/sv.d.ts +3 -1
- package/locales/file-uploader/sv.js +5 -2
- package/locales/file-uploader/tr.d.ts +3 -1
- package/locales/file-uploader/tr.js +5 -2
- package/locales/file-uploader/uk.d.ts +3 -1
- package/locales/file-uploader/uk.js +5 -2
- package/locales/file-uploader/vi.d.ts +3 -1
- package/locales/file-uploader/vi.js +5 -2
- package/locales/file-uploader/zh-TW.d.ts +3 -1
- package/locales/file-uploader/zh-TW.js +5 -2
- package/locales/file-uploader/zh.d.ts +3 -1
- package/locales/file-uploader/zh.js +5 -2
- package/package.json +8 -8
- package/types/exported.d.ts +26 -4
- package/utils/withResolvers.d.ts +6 -0
- package/utils/withResolvers.d.ts.map +1 -0
- package/utils/withResolvers.js +18 -0
- package/utils/withResolvers.test.d.ts +2 -0
- package/utils/withResolvers.test.d.ts.map +1 -0
- package/utils/withResolvers.test.js +36 -0
- package/web/file-uploader.iife.min.js +4 -4
- package/web/file-uploader.min.js +4 -4
- package/web/uc-cloud-image-editor.min.js +4 -4
- package/web/uc-file-uploader-inline.min.js +4 -4
- package/web/uc-file-uploader-minimal.min.js +4 -4
- package/web/uc-file-uploader-regular.min.js +4 -4
- package/web/uc-img.min.js +1 -1
package/types/exported.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import type { LocaleDefinition } from '../abstract/localeRegistry';
|
|
2
2
|
import type { complexConfigKeys } from '../blocks/Config/Config';
|
|
3
|
-
import type {
|
|
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 {
|
|
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 =
|
|
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 @@
|
|
|
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 @@
|
|
|
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
|
+
});
|