@uploadcare/file-uploader 1.33.2 → 1.34.1
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/dist/abstract/loadFileUploaderFrom.js +2 -2
- package/dist/env.js +3 -3
- package/dist/index.css +3 -3
- package/dist/index.d.ts +277 -105
- package/dist/index.js +5 -5
- package/dist/index.layered.css +3 -3
- package/dist/index.ssr.js +3 -1
- package/dist/locales/file-uploader/ar.js +2 -2
- package/dist/locales/file-uploader/az.js +2 -2
- package/dist/locales/file-uploader/ca.js +2 -2
- package/dist/locales/file-uploader/cs.js +2 -2
- package/dist/locales/file-uploader/da.js +2 -2
- package/dist/locales/file-uploader/de.js +2 -2
- package/dist/locales/file-uploader/el.js +2 -2
- package/dist/locales/file-uploader/en.js +2 -2
- package/dist/locales/file-uploader/es.js +2 -2
- package/dist/locales/file-uploader/et.js +2 -2
- package/dist/locales/file-uploader/fi.js +2 -2
- package/dist/locales/file-uploader/fr.js +2 -2
- package/dist/locales/file-uploader/he.js +2 -2
- package/dist/locales/file-uploader/hy.js +2 -2
- package/dist/locales/file-uploader/is.js +2 -2
- package/dist/locales/file-uploader/it.js +2 -2
- package/dist/locales/file-uploader/ja.js +2 -2
- package/dist/locales/file-uploader/ka.js +2 -2
- package/dist/locales/file-uploader/kk.js +2 -2
- package/dist/locales/file-uploader/ko.js +2 -2
- package/dist/locales/file-uploader/lv.js +2 -2
- package/dist/locales/file-uploader/nb.js +2 -2
- package/dist/locales/file-uploader/nl.js +2 -2
- package/dist/locales/file-uploader/pl.js +2 -2
- package/dist/locales/file-uploader/pt.js +2 -2
- package/dist/locales/file-uploader/ro.js +2 -2
- package/dist/locales/file-uploader/ru.js +2 -2
- package/dist/locales/file-uploader/sk.js +2 -2
- package/dist/locales/file-uploader/sr.js +2 -2
- package/dist/locales/file-uploader/sv.js +2 -2
- package/dist/locales/file-uploader/tr.js +2 -2
- package/dist/locales/file-uploader/uk.js +2 -2
- package/dist/locales/file-uploader/vi.js +2 -2
- package/dist/locales/file-uploader/zh-TW.js +2 -2
- package/dist/locales/file-uploader/zh.js +2 -2
- package/package.json +8 -7
- package/types/jsx.d.ts +29 -1
- package/web/file-uploader.iife.min.d.ts +277 -105
- package/web/file-uploader.iife.min.js +4 -4
- package/web/file-uploader.min.d.ts +277 -105
- package/web/file-uploader.min.js +4 -4
- package/web/uc-basic.layered.min.css +3 -3
- package/web/uc-basic.min.css +3 -3
- package/web/uc-cloud-image-editor.layered.min.css +2 -2
- package/web/uc-cloud-image-editor.min.css +2 -2
- package/web/uc-cloud-image-editor.min.d.ts +159 -10
- package/web/uc-cloud-image-editor.min.js +4 -4
- package/web/uc-file-uploader-inline.layered.min.css +3 -3
- package/web/uc-file-uploader-inline.min.css +3 -3
- package/web/uc-file-uploader-inline.min.d.ts +277 -105
- package/web/uc-file-uploader-inline.min.js +4 -4
- package/web/uc-file-uploader-minimal.layered.min.css +3 -3
- package/web/uc-file-uploader-minimal.min.css +3 -3
- package/web/uc-file-uploader-minimal.min.d.ts +277 -105
- package/web/uc-file-uploader-minimal.min.js +4 -4
- package/web/uc-file-uploader-regular.layered.min.css +3 -3
- package/web/uc-file-uploader-regular.min.css +3 -3
- package/web/uc-file-uploader-regular.min.d.ts +277 -105
- package/web/uc-file-uploader-regular.min.js +4 -4
- package/web/uc-img.min.js +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import _default from './locales/file-uploader/en.js';
|
|
|
4
4
|
import * as lit_html from 'lit-html';
|
|
5
5
|
import * as lit_html_directives_ref_js from 'lit-html/directives/ref.js';
|
|
6
6
|
import * as _uploadcare_upload_client from '@uploadcare/upload-client';
|
|
7
|
-
import { UploadcareFile,
|
|
8
|
-
export { Metadata, NetworkError, Tags, UploadError, UploadcareError, UploadcareFile, UploadcareGroup } from '@uploadcare/upload-client';
|
|
7
|
+
import { UploadcareFile, Metadata, Tags, AuthToken, FileFromOptions, UploadError, AuthTokenResolverError, NetworkError, UploadcareGroup, Queue } from '@uploadcare/upload-client';
|
|
8
|
+
export { AuthToken, AuthTokenResolverError, Metadata, NetworkError, Tags, UploadError, UploadcareError, UploadcareFile, UploadcareGroup } from '@uploadcare/upload-client';
|
|
9
9
|
import { Ref } from 'lit/directives/ref.js';
|
|
10
10
|
import { TelemetryRequest } from '@uploadcare/quality-insights';
|
|
11
11
|
export { PACKAGE_NAME, PACKAGE_VERSION } from './env.js';
|
|
@@ -105,21 +105,6 @@ declare class RouterHooksLayer extends SharedInstance {
|
|
|
105
105
|
navigateAfterFileAdd(): void;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
declare class A11y implements ISharedInstance {
|
|
109
|
-
private _destroyKeyUX;
|
|
110
|
-
private readonly _scopedWindow;
|
|
111
|
-
constructor();
|
|
112
|
-
registerBlock(scope: LitBlock): void;
|
|
113
|
-
destroy(): void;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
declare class LocaleManager extends SharedInstance {
|
|
117
|
-
private _localeName;
|
|
118
|
-
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
119
|
-
private _applyOverrides;
|
|
120
|
-
private _applyPluginLocales;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
108
|
/**
|
|
124
109
|
* Custom configuration options registration system for plugins
|
|
125
110
|
*/
|
|
@@ -180,8 +165,6 @@ declare class CustomConfigRegistry {
|
|
|
180
165
|
interface CustomConfig {
|
|
181
166
|
}
|
|
182
167
|
|
|
183
|
-
declare function buildOutputCollectionState<TCollectionStatus extends OutputCollectionStatus, TGroupFlag extends GroupFlag = 'maybe-has-group'>(bag: SharedInstancesBag): OutputCollectionState<TCollectionStatus, TGroupFlag>;
|
|
184
|
-
|
|
185
168
|
declare class TypedData<T extends Record<string, unknown>> {
|
|
186
169
|
private _ctxId;
|
|
187
170
|
private _data;
|
|
@@ -194,6 +177,91 @@ declare class TypedData<T extends Record<string, unknown>> {
|
|
|
194
177
|
destroy(): void;
|
|
195
178
|
}
|
|
196
179
|
|
|
180
|
+
interface UploadEntryData extends Record<string, unknown> {
|
|
181
|
+
file: File | null;
|
|
182
|
+
externalUrl: string | null;
|
|
183
|
+
fileName: string | null;
|
|
184
|
+
fileSize: number | null;
|
|
185
|
+
lastModified: number;
|
|
186
|
+
uploadProgress: number;
|
|
187
|
+
uuid: string | null;
|
|
188
|
+
isImage: boolean;
|
|
189
|
+
mimeType: string | null;
|
|
190
|
+
ctxName: string | null;
|
|
191
|
+
cdnUrl: string | null;
|
|
192
|
+
cdnUrlModifiers: string | null;
|
|
193
|
+
fileInfo: UploadcareFile | null;
|
|
194
|
+
isUploading: boolean;
|
|
195
|
+
abortController: AbortController | null;
|
|
196
|
+
thumbUrl: string | null;
|
|
197
|
+
silent: boolean;
|
|
198
|
+
source: string | null;
|
|
199
|
+
fullPath: string | null;
|
|
200
|
+
metadata: Metadata | null;
|
|
201
|
+
tags: Tags | null;
|
|
202
|
+
errors: OutputErrorFile[];
|
|
203
|
+
uploadError: Error | null;
|
|
204
|
+
isRemoved: boolean;
|
|
205
|
+
isQueuedForUploading: boolean;
|
|
206
|
+
isValidationPending: boolean;
|
|
207
|
+
isQueuedForValidation: boolean;
|
|
208
|
+
}
|
|
209
|
+
type UploadEntryTypedData = TypedData<UploadEntryData>;
|
|
210
|
+
type UploadEntryKeys = keyof UploadEntryData;
|
|
211
|
+
|
|
212
|
+
declare class PluginRegistry {
|
|
213
|
+
private _sources;
|
|
214
|
+
private _activities;
|
|
215
|
+
private _fileActions;
|
|
216
|
+
private _fileHooks;
|
|
217
|
+
private _icons;
|
|
218
|
+
private _l10n;
|
|
219
|
+
readonly config: CustomConfigRegistry;
|
|
220
|
+
/**
|
|
221
|
+
* Notify consumers (LocaleManager, SourceListController, …) that the registry
|
|
222
|
+
* changed so they re-apply the new state. Coalesces a synchronous burst of
|
|
223
|
+
* registrations — a plugin's setup() typically registers an icon, a source,
|
|
224
|
+
* several l10n maps, … in one tick — into a single, deferred notification.
|
|
225
|
+
* Registrations can also happen lazily, long after setup() ran (e.g. a locale's
|
|
226
|
+
* strings loaded when `localeName` changes), which is why this exists.
|
|
227
|
+
*/
|
|
228
|
+
private readonly _scheduleNotify;
|
|
229
|
+
constructor(onChange?: () => void);
|
|
230
|
+
/** Drop any pending notification (call on teardown). */
|
|
231
|
+
destroy(): void;
|
|
232
|
+
private _own;
|
|
233
|
+
addSource(pluginId: string, item: PluginSourceRegistration): void;
|
|
234
|
+
addActivity(pluginId: string, item: PluginActivityRegistration): void;
|
|
235
|
+
addFileAction(pluginId: string, item: PluginFileActionRegistration): void;
|
|
236
|
+
addFileHook(pluginId: string, item: PluginFileHookRegistration): void;
|
|
237
|
+
addIcon(pluginId: string, item: PluginIconRegistration): void;
|
|
238
|
+
addL10n(pluginId: string, item: PluginL10nRegistration): void;
|
|
239
|
+
addConfig<T>(pluginId: string, definition: CustomConfigDefinition<T>): void;
|
|
240
|
+
purge(pluginId: string): void;
|
|
241
|
+
snapshot(): PluginRegistrySnapshot;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare class PluginManager extends SharedInstance {
|
|
245
|
+
private _plugins;
|
|
246
|
+
private _subscribers;
|
|
247
|
+
private _pluginsUpdate;
|
|
248
|
+
private _lazyPluginLoader;
|
|
249
|
+
readonly registry: PluginRegistry;
|
|
250
|
+
get configRegistry(): CustomConfigRegistry;
|
|
251
|
+
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
252
|
+
pluginsReady(): Promise<void>;
|
|
253
|
+
onPluginsChange(callback: Unsubscriber): Unsubscriber;
|
|
254
|
+
private _syncPlugins;
|
|
255
|
+
private _registerPlugin;
|
|
256
|
+
private _unregisterPlugin;
|
|
257
|
+
snapshot(): PluginRegistrySnapshot;
|
|
258
|
+
runOnAddHooks(entry: UploadEntryTypedData): Promise<void>;
|
|
259
|
+
destroy(): void;
|
|
260
|
+
private _notifySubscribers;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
declare function buildOutputCollectionState<TCollectionStatus extends OutputCollectionStatus, TGroupFlag extends GroupFlag = 'maybe-has-group'>(bag: SharedInstancesBag): OutputCollectionState<TCollectionStatus, TGroupFlag>;
|
|
264
|
+
|
|
197
265
|
type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
|
|
198
266
|
signal?: AbortSignal;
|
|
199
267
|
}) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
|
|
@@ -1204,6 +1272,12 @@ type ApiAddFileCommonOptions = {
|
|
|
1204
1272
|
declare class UploaderPublicApi extends SharedInstance {
|
|
1205
1273
|
private _l10n;
|
|
1206
1274
|
get _uploadCollection(): TypedCollection<UploadEntryData>;
|
|
1275
|
+
/**
|
|
1276
|
+
* The failure of the last group creation, for the validator that reports it.
|
|
1277
|
+
* Underscored like `_uploadCollection`: internal, but a validator has no
|
|
1278
|
+
* other way to reach the context.
|
|
1279
|
+
*/
|
|
1280
|
+
get _groupError(): Error | null;
|
|
1207
1281
|
get cfg(): Readonly<ConfigType>;
|
|
1208
1282
|
get l10n(): (str: string, variables?: Record<string, string | number>) => string;
|
|
1209
1283
|
/**
|
|
@@ -1244,6 +1318,26 @@ declare class UploaderPublicApi extends SharedInstance {
|
|
|
1244
1318
|
private _pluginsReady;
|
|
1245
1319
|
setCurrentActivity: <T extends ActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] extends [never] ? [] : [ActivityParamsMap[T]] : []) => void;
|
|
1246
1320
|
on: <T extends EventKey>(type: T, handler: (payload: EventPayload[T]) => void) => (() => void);
|
|
1321
|
+
/**
|
|
1322
|
+
* The auth token as `@uploadcare/upload-client` receives it: the configured
|
|
1323
|
+
* string, or a resolver whose result the uploader already caches.
|
|
1324
|
+
*
|
|
1325
|
+
* Forward this rather than `cfg.authToken` when something else has to
|
|
1326
|
+
* authenticate with the same token — a plugin, say — so it shares this cache
|
|
1327
|
+
* instead of calling your token endpoint again.
|
|
1328
|
+
*/
|
|
1329
|
+
getAuthToken: () => AuthToken | undefined;
|
|
1330
|
+
/**
|
|
1331
|
+
* Drop the cached auth token, so the next request asks `authToken` for a new
|
|
1332
|
+
* one.
|
|
1333
|
+
*
|
|
1334
|
+
* Assigning a different function to `authToken` does not do this: a new
|
|
1335
|
+
* function identity is taken to be the same function, which is what lets a
|
|
1336
|
+
* React component pass an inline resolver without refetching on every render.
|
|
1337
|
+
* Call this when the change is real — the signed-in user changed, say — or
|
|
1338
|
+
* rely on short-lived tokens.
|
|
1339
|
+
*/
|
|
1340
|
+
invalidateAuthToken: () => void;
|
|
1247
1341
|
getCurrentActivity: () => ActivityType;
|
|
1248
1342
|
historyBack: () => void;
|
|
1249
1343
|
setModalState: (opened: boolean) => void;
|
|
@@ -1292,6 +1386,7 @@ declare class LitUploaderBlock extends LitActivityBlock {
|
|
|
1292
1386
|
'*collectionErrors': OutputErrorCollection[];
|
|
1293
1387
|
'*collectionState': OutputCollectionState | null;
|
|
1294
1388
|
'*groupInfo': _uploadcare_upload_client.UploadcareGroup | null;
|
|
1389
|
+
'*groupError': Error | null;
|
|
1295
1390
|
'*uploadTrigger': Set<string>;
|
|
1296
1391
|
'*currentActivity': null;
|
|
1297
1392
|
'*currentActivityParams': {};
|
|
@@ -1306,11 +1401,26 @@ declare class LitUploaderBlock extends LitActivityBlock {
|
|
|
1306
1401
|
get api(): UploaderPublicApi;
|
|
1307
1402
|
get uploadCollection(): TypedCollection<UploadEntryData>;
|
|
1308
1403
|
get secureUploadsManager(): SecureUploadsManager;
|
|
1404
|
+
get authTokenManager(): AuthTokenManager;
|
|
1309
1405
|
disconnectedCallback(): void;
|
|
1310
1406
|
connectedCallback(): void;
|
|
1311
1407
|
private _initCtxOwner;
|
|
1312
1408
|
private _observeUploadCollection;
|
|
1313
1409
|
private _unobserveUploadCollection;
|
|
1410
|
+
/** Bumped whenever the collection changes; see `_flushOutputItems`. */
|
|
1411
|
+
private _groupGeneration;
|
|
1412
|
+
/**
|
|
1413
|
+
* Creates the group for `collectionState` and reports the outcome, whichever
|
|
1414
|
+
* it is. Never rejects: the caller does not wait for the group, so a
|
|
1415
|
+
* rejection would have nowhere to go.
|
|
1416
|
+
*
|
|
1417
|
+
* A request cannot be cancelled once the API has it, so both outcomes are
|
|
1418
|
+
* dropped when the collection has moved on — a group of files that are no
|
|
1419
|
+
* longer the collection is neither its group nor its error. That is what the
|
|
1420
|
+
* generation tracks; `*collectionState` cannot, since it is republished on a
|
|
1421
|
+
* flush rather than on every change, and is still the same object at the
|
|
1422
|
+
* moment a mid-flight response lands.
|
|
1423
|
+
*/
|
|
1314
1424
|
private _createGroup;
|
|
1315
1425
|
private _flushOutputItems;
|
|
1316
1426
|
private _handleCollectionUpdate;
|
|
@@ -1459,11 +1569,67 @@ declare global {
|
|
|
1459
1569
|
}
|
|
1460
1570
|
|
|
1461
1571
|
/**
|
|
1462
|
-
*
|
|
1572
|
+
* How a built-in config key relates to its DOM attribute — the same idea as a
|
|
1573
|
+
* plugin's {@link CustomConfigDefinition.attribute}, declared for built-ins.
|
|
1574
|
+
*
|
|
1575
|
+
* Both default to `true`; a key only appears here to opt out of something.
|
|
1576
|
+
* - `attribute: false` — property only, no attribute representation at all
|
|
1577
|
+
* (the value is an object or a function).
|
|
1578
|
+
* - `reflect: false` — readable from an attribute, but the value is never
|
|
1579
|
+
* written back to one.
|
|
1463
1580
|
*/
|
|
1464
|
-
|
|
1581
|
+
type ConfigAttributeBehavior = {
|
|
1582
|
+
attribute?: boolean;
|
|
1583
|
+
reflect?: boolean;
|
|
1584
|
+
};
|
|
1585
|
+
declare const configAttributeBehavior: {
|
|
1586
|
+
readonly metadata: {
|
|
1587
|
+
readonly attribute: false;
|
|
1588
|
+
};
|
|
1589
|
+
readonly tags: {
|
|
1590
|
+
readonly attribute: false;
|
|
1591
|
+
};
|
|
1592
|
+
readonly plugins: {
|
|
1593
|
+
readonly attribute: false;
|
|
1594
|
+
};
|
|
1595
|
+
readonly localeDefinitionOverride: {
|
|
1596
|
+
readonly attribute: false;
|
|
1597
|
+
};
|
|
1598
|
+
readonly secureUploadsSignatureResolver: {
|
|
1599
|
+
readonly attribute: false;
|
|
1600
|
+
};
|
|
1601
|
+
readonly secureDeliveryProxyUrlResolver: {
|
|
1602
|
+
readonly attribute: false;
|
|
1603
|
+
};
|
|
1604
|
+
readonly iconHrefResolver: {
|
|
1605
|
+
readonly attribute: false;
|
|
1606
|
+
};
|
|
1607
|
+
readonly fileValidators: {
|
|
1608
|
+
readonly attribute: false;
|
|
1609
|
+
};
|
|
1610
|
+
readonly collectionValidators: {
|
|
1611
|
+
readonly attribute: false;
|
|
1612
|
+
};
|
|
1613
|
+
readonly mediaRecorderOptions: {
|
|
1614
|
+
readonly attribute: false;
|
|
1615
|
+
};
|
|
1616
|
+
/**
|
|
1617
|
+
* Settable either way: the attribute carries a plain token, the property also
|
|
1618
|
+
* accepts a resolver. Never reflected — a resolver has no attribute form, and
|
|
1619
|
+
* a bearer credential is not something to mirror into the DOM unasked.
|
|
1620
|
+
*/
|
|
1621
|
+
readonly authToken: {
|
|
1622
|
+
readonly reflect: false;
|
|
1623
|
+
};
|
|
1624
|
+
};
|
|
1625
|
+
/** Keys of the descriptor whose `field` is declared as `Value`. */
|
|
1626
|
+
type KeysWithBehavior<Field extends keyof ConfigAttributeBehavior, Value extends boolean> = {
|
|
1627
|
+
[K in keyof typeof configAttributeBehavior]: (typeof configAttributeBehavior)[K] extends Record<Field, Value> ? K : never;
|
|
1628
|
+
}[keyof typeof configAttributeBehavior];
|
|
1629
|
+
/** Keys the descriptor marks as having no attribute representation at all. */
|
|
1630
|
+
type PropertyOnlyConfigKey = KeysWithBehavior<'attribute', false>;
|
|
1465
1631
|
declare class Config extends LitBlock {
|
|
1466
|
-
attributesMeta: Partial<
|
|
1632
|
+
attributesMeta: Partial<AttributeConfigType> & {
|
|
1467
1633
|
'ctx-name': string;
|
|
1468
1634
|
};
|
|
1469
1635
|
init$: LitBlock["init$"] & ConfigType;
|
|
@@ -1495,6 +1661,8 @@ declare class Config extends LitBlock {
|
|
|
1495
1661
|
* Get attribute names for a config key (kebab-case and lowercase)
|
|
1496
1662
|
*/
|
|
1497
1663
|
private _getAttributeNames;
|
|
1664
|
+
/** Whether this key's value is written back to the DOM as an attribute. */
|
|
1665
|
+
private _isReflectedToAttribute;
|
|
1498
1666
|
private _flushValueToAttribute;
|
|
1499
1667
|
private _flushValueToState;
|
|
1500
1668
|
private _setValue;
|
|
@@ -2084,6 +2252,12 @@ type ConfigType = {
|
|
|
2084
2252
|
* Resolver for secure uploads signature.
|
|
2085
2253
|
*/
|
|
2086
2254
|
secureUploadsSignatureResolver: SecureUploadsSignatureResolver | null;
|
|
2255
|
+
/**
|
|
2256
|
+
* JWT for the Upload API `Authorization: Bearer <token>` scheme. Accepts a plain token or a resolver function; the
|
|
2257
|
+
* resolver is called before every request, so long-running uploads can supply a fresh token mid-flight. Takes
|
|
2258
|
+
* precedence over `secureSignature`/`secureExpire` and `secureUploadsSignatureResolver`.
|
|
2259
|
+
*/
|
|
2260
|
+
authToken: AuthToken | null;
|
|
2087
2261
|
/**
|
|
2088
2262
|
* Resolver for secure delivery proxy URL.
|
|
2089
2263
|
*/
|
|
@@ -2160,9 +2334,32 @@ type ConfigType = {
|
|
|
2160
2334
|
dynamicButtonViewMode: DynamicButtonMode;
|
|
2161
2335
|
dynamicButtonShowFirstIcon: boolean;
|
|
2162
2336
|
};
|
|
2163
|
-
|
|
2164
|
-
type
|
|
2165
|
-
|
|
2337
|
+
/** Options with no attribute representation: settable only as a DOM property. */
|
|
2338
|
+
type PropertyOnlyConfigType = Pick<ConfigType, PropertyOnlyConfigKey>;
|
|
2339
|
+
/** Options settable via an attribute (as well as as a property). */
|
|
2340
|
+
type AttributeConfigType = Omit<ConfigType, PropertyOnlyConfigKey>;
|
|
2341
|
+
/**
|
|
2342
|
+
* @deprecated Renamed to {@link PropertyOnlyConfigType}. Kept as an alias so
|
|
2343
|
+
* existing imports keep compiling.
|
|
2344
|
+
*/
|
|
2345
|
+
type ConfigComplexType = PropertyOnlyConfigType;
|
|
2346
|
+
/**
|
|
2347
|
+
* @deprecated Renamed to {@link AttributeConfigType}. Kept as an alias so
|
|
2348
|
+
* existing imports keep compiling.
|
|
2349
|
+
*/
|
|
2350
|
+
type ConfigPlainType = AttributeConfigType;
|
|
2351
|
+
/**
|
|
2352
|
+
* A DOM attribute can only ever carry a primitive, so an option whose value type
|
|
2353
|
+
* also admits an object or a function (`authToken` accepts a token *or* a
|
|
2354
|
+
* resolver) exposes only the primitive half here. Without this, JSX would
|
|
2355
|
+
* type-accept a function and silently stringify it into the DOM. For options
|
|
2356
|
+
* that are already primitive this is the identity.
|
|
2357
|
+
*/
|
|
2358
|
+
type AttributeValue<T> = Extract<T, string | number | boolean | null | undefined>;
|
|
2359
|
+
type ConfigAttributeValues = {
|
|
2360
|
+
[K in keyof AttributeConfigType]: AttributeValue<AttributeConfigType[K]>;
|
|
2361
|
+
};
|
|
2362
|
+
type ConfigAttributesType = KebabCaseKeys<ConfigAttributeValues> & LowerCaseKeys<ConfigAttributeValues>;
|
|
2166
2363
|
type KebabCase$1<S extends string> = S extends `${infer C}${infer T}` ? T extends Uncapitalize<T> ? `${Uncapitalize<C>}${KebabCase$1<T>}` : `${Uncapitalize<C>}-${KebabCase$1<T>}` : S;
|
|
2167
2364
|
type KebabCaseKeys<T extends Record<string, unknown>> = {
|
|
2168
2365
|
[Key in keyof T as KebabCase$1<Key & string>]: T[Key];
|
|
@@ -2173,8 +2370,8 @@ type LowerCaseKeys<T extends Record<string, unknown>> = {
|
|
|
2173
2370
|
};
|
|
2174
2371
|
type OutputFileStatus = 'idle' | 'uploading' | 'success' | 'failed' | 'removed';
|
|
2175
2372
|
type OutputCustomErrorType = 'CUSTOM_ERROR';
|
|
2176
|
-
type OutputFileErrorType = OutputCustomErrorType | 'NOT_AN_IMAGE' | 'FORBIDDEN_FILE_TYPE' | 'FILE_SIZE_EXCEEDED' | 'UPLOAD_ERROR' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
|
|
2177
|
-
type OutputCollectionErrorType = OutputCustomErrorType | 'SOME_FILES_HAS_ERRORS' | 'TOO_MANY_FILES' | 'TOO_FEW_FILES';
|
|
2373
|
+
type OutputFileErrorType = OutputCustomErrorType | 'NOT_AN_IMAGE' | 'FORBIDDEN_FILE_TYPE' | 'FILE_SIZE_EXCEEDED' | 'UPLOAD_ERROR' | 'AUTH_TOKEN_ERROR' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
|
|
2374
|
+
type OutputCollectionErrorType = OutputCustomErrorType | 'SOME_FILES_HAS_ERRORS' | 'GROUP_ERROR' | 'TOO_MANY_FILES' | 'TOO_FEW_FILES';
|
|
2178
2375
|
type OutputFileErrorPayload = {
|
|
2179
2376
|
entry: OutputFileEntry;
|
|
2180
2377
|
};
|
|
@@ -2185,6 +2382,9 @@ type OutputErrorTypePayload = {
|
|
|
2185
2382
|
SOME_FILES_HAS_ERRORS: {
|
|
2186
2383
|
[k: string]: never;
|
|
2187
2384
|
};
|
|
2385
|
+
GROUP_ERROR: {
|
|
2386
|
+
error: Error;
|
|
2387
|
+
};
|
|
2188
2388
|
TOO_MANY_FILES: {
|
|
2189
2389
|
min: number;
|
|
2190
2390
|
max: number;
|
|
@@ -2198,6 +2398,9 @@ type OutputErrorTypePayload = {
|
|
|
2198
2398
|
UPLOAD_ERROR: OutputFileErrorPayload & {
|
|
2199
2399
|
error: UploadError;
|
|
2200
2400
|
};
|
|
2401
|
+
AUTH_TOKEN_ERROR: OutputFileErrorPayload & {
|
|
2402
|
+
error: AuthTokenResolverError;
|
|
2403
|
+
};
|
|
2201
2404
|
NETWORK_ERROR: OutputFileErrorPayload & {
|
|
2202
2405
|
error: NetworkError;
|
|
2203
2406
|
};
|
|
@@ -2501,87 +2704,47 @@ type EventMap = {
|
|
|
2501
2704
|
[T in keyof EventPayload]: CustomEvent<EventPayload[T]>;
|
|
2502
2705
|
};
|
|
2503
2706
|
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
isValidationPending: boolean;
|
|
2531
|
-
isQueuedForValidation: boolean;
|
|
2707
|
+
/**
|
|
2708
|
+
* Owns the one long-lived token cache for this uploader context.
|
|
2709
|
+
*
|
|
2710
|
+
* `authToken` may be a resolver, and `@uploadcare/upload-client` calls it
|
|
2711
|
+
* before every authenticated request — so without a cache each upload, each
|
|
2712
|
+
* readiness poll and each multipart start/complete would hit the app's token
|
|
2713
|
+
* endpoint again. (Multipart chunks go to presigned storage URLs and carry no
|
|
2714
|
+
* token, so they are not part of that count.)
|
|
2715
|
+
*/
|
|
2716
|
+
declare class AuthTokenManager extends SharedInstance {
|
|
2717
|
+
private _cache;
|
|
2718
|
+
/**
|
|
2719
|
+
* One function, the same one for the life of this manager, that reads the
|
|
2720
|
+
* configured resolver when it is called rather than capturing it.
|
|
2721
|
+
*
|
|
2722
|
+
* That stability is the point: whoever we hand this to can keep it, and it
|
|
2723
|
+
* still follows later changes to `authToken`. Returning the cache's own
|
|
2724
|
+
* `getToken` instead would mean re-reading it after every config change to
|
|
2725
|
+
* stay current, which is a rule nothing enforces.
|
|
2726
|
+
*/
|
|
2727
|
+
private readonly _resolveAuthToken;
|
|
2728
|
+
/** The value to hand `@uploadcare/upload-client` as `authToken`. */
|
|
2729
|
+
getAuthToken(): AuthToken | undefined;
|
|
2730
|
+
/** Drop the cached token, e.g. once the signed-in user changes. */
|
|
2731
|
+
invalidate(): void;
|
|
2732
|
+
destroy(): void;
|
|
2532
2733
|
}
|
|
2533
|
-
type UploadEntryTypedData = TypedData<UploadEntryData>;
|
|
2534
|
-
type UploadEntryKeys = keyof UploadEntryData;
|
|
2535
2734
|
|
|
2536
|
-
declare class
|
|
2537
|
-
private
|
|
2538
|
-
private
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
private _icons;
|
|
2542
|
-
private _l10n;
|
|
2543
|
-
readonly config: CustomConfigRegistry;
|
|
2544
|
-
/**
|
|
2545
|
-
* Notify consumers (LocaleManager, SourceListController, …) that the registry
|
|
2546
|
-
* changed so they re-apply the new state. Coalesces a synchronous burst of
|
|
2547
|
-
* registrations — a plugin's setup() typically registers an icon, a source,
|
|
2548
|
-
* several l10n maps, … in one tick — into a single, deferred notification.
|
|
2549
|
-
* Registrations can also happen lazily, long after setup() ran (e.g. a locale's
|
|
2550
|
-
* strings loaded when `localeName` changes), which is why this exists.
|
|
2551
|
-
*/
|
|
2552
|
-
private readonly _scheduleNotify;
|
|
2553
|
-
constructor(onChange?: () => void);
|
|
2554
|
-
/** Drop any pending notification (call on teardown). */
|
|
2735
|
+
declare class A11y implements ISharedInstance {
|
|
2736
|
+
private _destroyKeyUX;
|
|
2737
|
+
private readonly _scopedWindow;
|
|
2738
|
+
constructor();
|
|
2739
|
+
registerBlock(scope: LitBlock): void;
|
|
2555
2740
|
destroy(): void;
|
|
2556
|
-
private _own;
|
|
2557
|
-
addSource(pluginId: string, item: PluginSourceRegistration): void;
|
|
2558
|
-
addActivity(pluginId: string, item: PluginActivityRegistration): void;
|
|
2559
|
-
addFileAction(pluginId: string, item: PluginFileActionRegistration): void;
|
|
2560
|
-
addFileHook(pluginId: string, item: PluginFileHookRegistration): void;
|
|
2561
|
-
addIcon(pluginId: string, item: PluginIconRegistration): void;
|
|
2562
|
-
addL10n(pluginId: string, item: PluginL10nRegistration): void;
|
|
2563
|
-
addConfig<T>(pluginId: string, definition: CustomConfigDefinition<T>): void;
|
|
2564
|
-
purge(pluginId: string): void;
|
|
2565
|
-
snapshot(): PluginRegistrySnapshot;
|
|
2566
2741
|
}
|
|
2567
2742
|
|
|
2568
|
-
declare class
|
|
2569
|
-
private
|
|
2570
|
-
private _subscribers;
|
|
2571
|
-
private _pluginsUpdate;
|
|
2572
|
-
private _lazyPluginLoader;
|
|
2573
|
-
readonly registry: PluginRegistry;
|
|
2574
|
-
get configRegistry(): CustomConfigRegistry;
|
|
2743
|
+
declare class LocaleManager extends SharedInstance {
|
|
2744
|
+
private _localeName;
|
|
2575
2745
|
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
private _syncPlugins;
|
|
2579
|
-
private _registerPlugin;
|
|
2580
|
-
private _unregisterPlugin;
|
|
2581
|
-
snapshot(): PluginRegistrySnapshot;
|
|
2582
|
-
runOnAddHooks(entry: UploadEntryTypedData): Promise<void>;
|
|
2583
|
-
destroy(): void;
|
|
2584
|
-
private _notifySubscribers;
|
|
2746
|
+
private _applyOverrides;
|
|
2747
|
+
private _applyPluginLocales;
|
|
2585
2748
|
}
|
|
2586
2749
|
|
|
2587
2750
|
type CommonEventType = InternalEventKey | EventKey;
|
|
@@ -2648,6 +2811,7 @@ declare const instanceKeyMap: {
|
|
|
2648
2811
|
eventEmitter: "*eventEmitter";
|
|
2649
2812
|
uploadCollection: "*uploadCollection";
|
|
2650
2813
|
secureUploadsManager: "*secureUploadsManager";
|
|
2814
|
+
authTokenManager: "*authTokenManager";
|
|
2651
2815
|
api: "*publicApi";
|
|
2652
2816
|
validationManager: "*validationManager";
|
|
2653
2817
|
};
|
|
@@ -2669,6 +2833,7 @@ declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
|
|
|
2669
2833
|
readonly eventEmitter: EventEmitter;
|
|
2670
2834
|
readonly uploadCollection: TypedCollection<UploadEntryData>;
|
|
2671
2835
|
readonly secureUploadsManager: SecureUploadsManager;
|
|
2836
|
+
readonly authTokenManager: AuthTokenManager;
|
|
2672
2837
|
readonly api: UploaderPublicApi;
|
|
2673
2838
|
readonly validationManager: ValidationManager;
|
|
2674
2839
|
when<TName extends InstanceName>(name: TName, callback: (instance: NonNullable<InstanceTypeMap[TName]>) => void): () => void;
|
|
@@ -2724,6 +2889,8 @@ type UploaderBlockCtxState = ActivityBlockCtxState & {
|
|
|
2724
2889
|
'*collectionErrors': OutputErrorCollection[];
|
|
2725
2890
|
'*collectionState': OutputCollectionState | null;
|
|
2726
2891
|
'*groupInfo': UploadcareGroup | null;
|
|
2892
|
+
/** The failure of the last group creation, if it failed. */
|
|
2893
|
+
'*groupError': Error | null;
|
|
2727
2894
|
'*uploadTrigger': Set<Uid>;
|
|
2728
2895
|
};
|
|
2729
2896
|
type SolutionBlockCtxState = UploaderBlockCtxState & {
|
|
@@ -2797,6 +2964,7 @@ type DynamicUploaderBlockState = {
|
|
|
2797
2964
|
'*publicApi': UploaderPublicApi;
|
|
2798
2965
|
'*validationManager': ValidationManager;
|
|
2799
2966
|
'*secureUploadsManager': SecureUploadsManager;
|
|
2967
|
+
'*authTokenManager': AuthTokenManager;
|
|
2800
2968
|
};
|
|
2801
2969
|
type LocaleState = {
|
|
2802
2970
|
[K in keyof LocaleDefinition as `*l10n/${K}`]: string;
|
|
@@ -2830,9 +2998,10 @@ declare class LitBlock extends LitBlockBase {
|
|
|
2830
2998
|
readonly eventEmitter: EventEmitter;
|
|
2831
2999
|
readonly uploadCollection: TypedCollection<UploadEntryData>;
|
|
2832
3000
|
readonly secureUploadsManager: SecureUploadsManager;
|
|
3001
|
+
readonly authTokenManager: AuthTokenManager;
|
|
2833
3002
|
readonly api: UploaderPublicApi;
|
|
2834
3003
|
readonly validationManager: ValidationManager;
|
|
2835
|
-
when<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "routerLayer" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName, callback: (instance: NonNullable<{
|
|
3004
|
+
when<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "routerLayer" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "authTokenManager" | "api" | "validationManager">(name: TName, callback: (instance: NonNullable<{
|
|
2836
3005
|
modalManager: ModalManager | null;
|
|
2837
3006
|
pluginManager: PluginManager;
|
|
2838
3007
|
telemetryManager: TelemetryManager;
|
|
@@ -2844,10 +3013,11 @@ declare class LitBlock extends LitBlockBase {
|
|
|
2844
3013
|
eventEmitter: EventEmitter;
|
|
2845
3014
|
uploadCollection: TypedCollection<UploadEntryData>;
|
|
2846
3015
|
secureUploadsManager: SecureUploadsManager;
|
|
3016
|
+
authTokenManager: AuthTokenManager;
|
|
2847
3017
|
api: UploaderPublicApi;
|
|
2848
3018
|
validationManager: ValidationManager;
|
|
2849
3019
|
}[TName]>) => void): () => void;
|
|
2850
|
-
wait<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "routerLayer" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName): Promise<NonNullable<{
|
|
3020
|
+
wait<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "routerLayer" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "authTokenManager" | "api" | "validationManager">(name: TName): Promise<NonNullable<{
|
|
2851
3021
|
modalManager: ModalManager | null;
|
|
2852
3022
|
pluginManager: PluginManager;
|
|
2853
3023
|
telemetryManager: TelemetryManager;
|
|
@@ -2859,6 +3029,7 @@ declare class LitBlock extends LitBlockBase {
|
|
|
2859
3029
|
eventEmitter: EventEmitter;
|
|
2860
3030
|
uploadCollection: TypedCollection<UploadEntryData>;
|
|
2861
3031
|
secureUploadsManager: SecureUploadsManager;
|
|
3032
|
+
authTokenManager: AuthTokenManager;
|
|
2862
3033
|
api: UploaderPublicApi;
|
|
2863
3034
|
validationManager: ValidationManager;
|
|
2864
3035
|
}[TName]>>;
|
|
@@ -2990,6 +3161,7 @@ declare class LitSolutionBlock extends LitBlock {
|
|
|
2990
3161
|
'*collectionErrors': OutputErrorCollection[];
|
|
2991
3162
|
'*collectionState': OutputCollectionState | null;
|
|
2992
3163
|
'*groupInfo': _uploadcare_upload_client.UploadcareGroup | null;
|
|
3164
|
+
'*groupError': Error | null;
|
|
2993
3165
|
'*uploadTrigger': Set<string>;
|
|
2994
3166
|
'*currentActivity': null;
|
|
2995
3167
|
'*currentActivityParams': {};
|
|
@@ -3315,4 +3487,4 @@ declare global {
|
|
|
3315
3487
|
}
|
|
3316
3488
|
}
|
|
3317
3489
|
|
|
3318
|
-
export { LitActivityBlock as ActivityBlock, ActivityHeader, type ActivityType, type ApiAddFileCommonOptions, BaseComponent, LitBlock as Block, BtnUi, CameraSource, CloudImageEditor, CloudImageEditorActivity, CloudImageEditorBlock, type CollectionValidators, Config, type ConfigAttributesType, type ConfigComplexType, type ConfigPlainType, type ConfigType, Copyright, CropFrame, type CustomActivities, type CustomConfig, type CustomConfigDefinition, type CustomLocaleDefinition, PubSub as Data, DropArea, DropDown, DynamicBtn, EditorAspectRatioButtonControl, EditorCropButtonControl, EditorFilterControl, EditorFreeformButtonControl, EditorImageCropper, EditorImageFader, EditorOperationControl, EditorScroller, EditorSlider, EditorToolbar, type EventMap, type EventPayload, EventType, ExternalSource, ExternalUploadSource, FileActionButton, FileItem, FileUploaderInline, FileUploaderMinimal, FileUploaderRegular, type FileValidator, type FileValidatorDescriptor, type FileValidators, FormInput, type FuncCollectionValidator, type FuncFileValidator, type GroupFlag, Icon, type IconHrefResolver, Img, type KebabCase$1 as KebabCase, type KebabCaseKeys, LineLoaderUi, type LocaleDefinitionOverride, type LowerCase, type LowerCaseKeys, type MetadataCallback, Modal, ModalEvents, type ModalId, NoWrapModeDynamicBtn, type OutputCollectionErrorType, type OutputCollectionState, type OutputCollectionStatus, type OutputCustomErrorType, type OutputError, type OutputErrorCollection, type OutputErrorFile, type OutputErrorTypePayload, type OutputFileEntry, type OutputFileErrorPayload, type OutputFileErrorType, type OutputFileStatus, type Owned, type PluginActivityApi, PluginActivityHost, type PluginActivityRegistration, PluginActivityRenderer, type PluginApi, type PluginConfigApi, type PluginFileActionRegistration, type PluginFileEntryUpdate, type PluginFileHookContext, type PluginFileHookRegistration, type PluginFileHookResult, type PluginFilesApi, type PluginIconRegistration, type PluginL10nRegistration, type PluginRegistryApi, type PluginRegistrySnapshot, type PluginRender, type PluginRenderDispose, type PluginSetupParams, type PluginSetupResult, type PluginSourceRegistration, type PluginUploaderApi, PresenceToggle, PrimaryAction, ProgressBar, ProgressBarCommon, type SecureDeliveryProxyUrlResolver, type SecureUploadsSignatureAndExpire, type SecureUploadsSignatureResolver, Select, SimpleBtn, SliderUi, LitSolutionBlock as SolutionBlock, SourceBtn, SourceList, type SourceTypes, Spinner, StartFrom, type TagsCallback, Thumb, UID, UploadCtxProvider, UploadList, UploadSource, LitUploaderBlock as UploaderBlock, type UploaderPlugin, UploaderPublicApi, UrlSource, defineComponents, defineLocale, toKebabCase };
|
|
3490
|
+
export { LitActivityBlock as ActivityBlock, ActivityHeader, type ActivityType, type ApiAddFileCommonOptions, type AttributeConfigType, BaseComponent, LitBlock as Block, BtnUi, CameraSource, CloudImageEditor, CloudImageEditorActivity, CloudImageEditorBlock, type CollectionValidators, Config, type ConfigAttributesType, type ConfigComplexType, type ConfigPlainType, type ConfigType, Copyright, CropFrame, type CustomActivities, type CustomConfig, type CustomConfigDefinition, type CustomLocaleDefinition, PubSub as Data, DropArea, DropDown, DynamicBtn, EditorAspectRatioButtonControl, EditorCropButtonControl, EditorFilterControl, EditorFreeformButtonControl, EditorImageCropper, EditorImageFader, EditorOperationControl, EditorScroller, EditorSlider, EditorToolbar, type EventMap, type EventPayload, EventType, ExternalSource, ExternalUploadSource, FileActionButton, FileItem, FileUploaderInline, FileUploaderMinimal, FileUploaderRegular, type FileValidator, type FileValidatorDescriptor, type FileValidators, FormInput, type FuncCollectionValidator, type FuncFileValidator, type GroupFlag, Icon, type IconHrefResolver, Img, type KebabCase$1 as KebabCase, type KebabCaseKeys, LineLoaderUi, type LocaleDefinitionOverride, type LowerCase, type LowerCaseKeys, type MetadataCallback, Modal, ModalEvents, type ModalId, NoWrapModeDynamicBtn, type OutputCollectionErrorType, type OutputCollectionState, type OutputCollectionStatus, type OutputCustomErrorType, type OutputError, type OutputErrorCollection, type OutputErrorFile, type OutputErrorTypePayload, type OutputFileEntry, type OutputFileErrorPayload, type OutputFileErrorType, type OutputFileStatus, type Owned, type PluginActivityApi, PluginActivityHost, type PluginActivityRegistration, PluginActivityRenderer, type PluginApi, type PluginConfigApi, type PluginFileActionRegistration, type PluginFileEntryUpdate, type PluginFileHookContext, type PluginFileHookRegistration, type PluginFileHookResult, type PluginFilesApi, type PluginIconRegistration, type PluginL10nRegistration, type PluginRegistryApi, type PluginRegistrySnapshot, type PluginRender, type PluginRenderDispose, type PluginSetupParams, type PluginSetupResult, type PluginSourceRegistration, type PluginUploaderApi, PresenceToggle, PrimaryAction, ProgressBar, ProgressBarCommon, type PropertyOnlyConfigType, type SecureDeliveryProxyUrlResolver, type SecureUploadsSignatureAndExpire, type SecureUploadsSignatureResolver, Select, SimpleBtn, SliderUi, LitSolutionBlock as SolutionBlock, SourceBtn, SourceList, type SourceTypes, Spinner, StartFrom, type TagsCallback, Thumb, UID, UploadCtxProvider, UploadList, UploadSource, LitUploaderBlock as UploaderBlock, type UploaderPlugin, UploaderPublicApi, UrlSource, defineComponents, defineLocale, toKebabCase };
|